1 (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Mapillary = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
4 var Queue = require('tinyqueue');
6 module.exports = polylabel;
7 module.exports.default = polylabel;
9 function polylabel(polygon, precision, debug) {
10 precision = precision || 1.0;
12 // find the bounding box of the outer ring
13 var minX, minY, maxX, maxY;
14 for (var i = 0; i < polygon[0].length; i++) {
15 var p = polygon[0][i];
16 if (!i || p[0] < minX) minX = p[0];
17 if (!i || p[1] < minY) minY = p[1];
18 if (!i || p[0] > maxX) maxX = p[0];
19 if (!i || p[1] > maxY) maxY = p[1];
22 var width = maxX - minX;
23 var height = maxY - minY;
24 var cellSize = Math.min(width, height);
27 // a priority queue of cells in order of their "potential" (max distance to polygon)
28 var cellQueue = new Queue(null, compareMax);
30 if (cellSize === 0) return [minX, minY];
32 // cover polygon with initial cells
33 for (var x = minX; x < maxX; x += cellSize) {
34 for (var y = minY; y < maxY; y += cellSize) {
35 cellQueue.push(new Cell(x + h, y + h, h, polygon));
39 // take centroid as the first best guess
40 var bestCell = getCentroidCell(polygon);
42 // special case for rectangular polygons
43 var bboxCell = new Cell(minX + width / 2, minY + height / 2, 0, polygon);
44 if (bboxCell.d > bestCell.d) bestCell = bboxCell;
46 var numProbes = cellQueue.length;
48 while (cellQueue.length) {
49 // pick the most promising cell from the queue
50 var cell = cellQueue.pop();
52 // update the best cell if we found a better one
53 if (cell.d > bestCell.d) {
55 if (debug) console.log('found best %d after %d probes', Math.round(1e4 * cell.d) / 1e4, numProbes);
58 // do not drill down further if there's no chance of a better solution
59 if (cell.max - bestCell.d <= precision) continue;
61 // split the cell into four cells
63 cellQueue.push(new Cell(cell.x - h, cell.y - h, h, polygon));
64 cellQueue.push(new Cell(cell.x + h, cell.y - h, h, polygon));
65 cellQueue.push(new Cell(cell.x - h, cell.y + h, h, polygon));
66 cellQueue.push(new Cell(cell.x + h, cell.y + h, h, polygon));
71 console.log('num probes: ' + numProbes);
72 console.log('best distance: ' + bestCell.d);
75 return [bestCell.x, bestCell.y];
78 function compareMax(a, b) {
82 function Cell(x, y, h, polygon) {
83 this.x = x; // cell center x
84 this.y = y; // cell center y
85 this.h = h; // half the cell size
86 this.d = pointToPolygonDist(x, y, polygon); // distance from cell center to polygon
87 this.max = this.d + this.h * Math.SQRT2; // max distance to polygon within a cell
90 // signed distance from point to polygon outline (negative if point is outside)
91 function pointToPolygonDist(x, y, polygon) {
93 var minDistSq = Infinity;
95 for (var k = 0; k < polygon.length; k++) {
96 var ring = polygon[k];
98 for (var i = 0, len = ring.length, j = len - 1; i < len; j = i++) {
102 if ((a[1] > y !== b[1] > y) &&
103 (x < (b[0] - a[0]) * (y - a[1]) / (b[1] - a[1]) + a[0])) inside = !inside;
105 minDistSq = Math.min(minDistSq, getSegDistSq(x, y, a, b));
109 return (inside ? 1 : -1) * Math.sqrt(minDistSq);
112 // get polygon centroid
113 function getCentroidCell(polygon) {
117 var points = polygon[0];
119 for (var i = 0, len = points.length, j = len - 1; i < len; j = i++) {
122 var f = a[0] * b[1] - b[0] * a[1];
123 x += (a[0] + b[0]) * f;
124 y += (a[1] + b[1]) * f;
127 if (area === 0) return new Cell(points[0][0], points[0][1], 0, polygon);
128 return new Cell(x / area, y / area, 0, polygon);
131 // get squared distance from a point to a segment
132 function getSegDistSq(px, py, a, b) {
139 if (dx !== 0 || dy !== 0) {
141 var t = ((px - x) * dx + (py - y) * dy) / (dx * dx + dy * dy);
156 return dx * dx + dy * dy;
159 },{"tinyqueue":227}],2:[function(require,module,exports){
161 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
163 * Redistribution and use in source and binary forms, with or without
164 * modification, are permitted provided that the following conditions
166 * 1. Redistributions of source code must retain the above copyright
167 * notice, this list of conditions and the following disclaimer.
168 * 2. Redistributions in binary form must reproduce the above copyright
169 * notice, this list of conditions and the following disclaimer in the
170 * documentation and/or other materials provided with the distribution.
172 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
173 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
174 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
175 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
176 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
177 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
178 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
179 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
180 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
181 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
182 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
185 * http://svn.webkit.org/repository/webkit/trunk/Source/WebCore/platform/graphics/UnitBezier.h
188 module.exports = UnitBezier;
190 function UnitBezier(p1x, p1y, p2x, p2y) {
191 // Calculate the polynomial coefficients, implicit first and last control points are (0,0) and (1,1).
193 this.bx = 3.0 * (p2x - p1x) - this.cx;
194 this.ax = 1.0 - this.cx - this.bx;
197 this.by = 3.0 * (p2y - p1y) - this.cy;
198 this.ay = 1.0 - this.cy - this.by;
206 UnitBezier.prototype.sampleCurveX = function(t) {
207 // `ax t^3 + bx t^2 + cx t' expanded using Horner's rule.
208 return ((this.ax * t + this.bx) * t + this.cx) * t;
211 UnitBezier.prototype.sampleCurveY = function(t) {
212 return ((this.ay * t + this.by) * t + this.cy) * t;
215 UnitBezier.prototype.sampleCurveDerivativeX = function(t) {
216 return (3.0 * this.ax * t + 2.0 * this.bx) * t + this.cx;
219 UnitBezier.prototype.solveCurveX = function(x, epsilon) {
220 if (typeof epsilon === 'undefined') epsilon = 1e-6;
222 var t0, t1, t2, x2, i;
224 // First try a few iterations of Newton's method -- normally very fast.
225 for (t2 = x, i = 0; i < 8; i++) {
227 x2 = this.sampleCurveX(t2) - x;
228 if (Math.abs(x2) < epsilon) return t2;
230 var d2 = this.sampleCurveDerivativeX(t2);
231 if (Math.abs(d2) < 1e-6) break;
236 // Fall back to the bisection method for reliability.
241 if (t2 < t0) return t0;
242 if (t2 > t1) return t1;
246 x2 = this.sampleCurveX(t2);
247 if (Math.abs(x2 - x) < epsilon) return t2;
255 t2 = (t1 - t0) * 0.5 + t0;
262 UnitBezier.prototype.solve = function(x, epsilon) {
263 return this.sampleCurveY(this.solveCurveX(x, epsilon));
266 },{}],3:[function(require,module,exports){
269 exports.byteLength = byteLength
270 exports.toByteArray = toByteArray
271 exports.fromByteArray = fromByteArray
275 var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
277 var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
278 for (var i = 0, len = code.length; i < len; ++i) {
280 revLookup[code.charCodeAt(i)] = i
283 revLookup['-'.charCodeAt(0)] = 62
284 revLookup['_'.charCodeAt(0)] = 63
286 function placeHoldersCount (b64) {
289 throw new Error('Invalid string. Length must be a multiple of 4')
292 // the number of equal signs (place holders)
293 // if there are two placeholders, than the two characters before it
294 // represent one byte
295 // if there is only one, then the three characters before it represent 2 bytes
296 // this is just a cheap hack to not do indexOf twice
297 return b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0
300 function byteLength (b64) {
301 // base64 is 4/3 + up to two characters of the original data
302 return (b64.length * 3 / 4) - placeHoldersCount(b64)
305 function toByteArray (b64) {
306 var i, l, tmp, placeHolders, arr
308 placeHolders = placeHoldersCount(b64)
310 arr = new Arr((len * 3 / 4) - placeHolders)
312 // if there are placeholders, only get up to the last complete 4 chars
313 l = placeHolders > 0 ? len - 4 : len
317 for (i = 0; i < l; i += 4) {
318 tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)]
319 arr[L++] = (tmp >> 16) & 0xFF
320 arr[L++] = (tmp >> 8) & 0xFF
321 arr[L++] = tmp & 0xFF
324 if (placeHolders === 2) {
325 tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4)
326 arr[L++] = tmp & 0xFF
327 } else if (placeHolders === 1) {
328 tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2)
329 arr[L++] = (tmp >> 8) & 0xFF
330 arr[L++] = tmp & 0xFF
336 function tripletToBase64 (num) {
337 return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F]
340 function encodeChunk (uint8, start, end) {
343 for (var i = start; i < end; i += 3) {
344 tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2])
345 output.push(tripletToBase64(tmp))
347 return output.join('')
350 function fromByteArray (uint8) {
352 var len = uint8.length
353 var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
356 var maxChunkLength = 16383 // must be multiple of 3
358 // go through the array every three bytes, we'll deal with trailing stuff later
359 for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
360 parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))
363 // pad the end with zeros, but make sure to not forget the extra bytes
364 if (extraBytes === 1) {
366 output += lookup[tmp >> 2]
367 output += lookup[(tmp << 4) & 0x3F]
369 } else if (extraBytes === 2) {
370 tmp = (uint8[len - 2] << 8) + (uint8[len - 1])
371 output += lookup[tmp >> 10]
372 output += lookup[(tmp >> 4) & 0x3F]
373 output += lookup[(tmp << 2) & 0x3F]
379 return parts.join('')
382 },{}],4:[function(require,module,exports){
384 },{}],5:[function(require,module,exports){
386 * Cross-Browser Split 1.1.1
387 * Copyright 2007-2012 Steven Levithan <stevenlevithan.com>
388 * Available under the MIT License
389 * ECMAScript compliant, uniform cross-browser split method
393 * Splits a string into an array of strings using a regex or string separator. Matches of the
394 * separator are not included in the result array. However, if `separator` is a regex that contains
395 * capturing groups, backreferences are spliced into the result each time `separator` is matched.
396 * Fixes browser bugs compared to the native `String.prototype.split` and can be used reliably
398 * @param {String} str String to split.
399 * @param {RegExp|String} separator Regex or string to use for separating the string.
400 * @param {Number} [limit] Maximum number of items to include in the result array.
401 * @returns {Array} Array of substrings.
405 * split('a b c d', ' ');
406 * // -> ['a', 'b', 'c', 'd']
409 * split('a b c d', ' ', 2);
412 * // Backreferences in result array
413 * split('..word1 word2..', /([a-z]+)(\d+)/i);
414 * // -> ['..', 'word', '1', ' ', 'word', '2', '..']
416 module.exports = (function split(undef) {
418 var nativeSplit = String.prototype.split,
419 compliantExecNpcg = /()??/.exec("")[1] === undef,
420 // NPCG: nonparticipating capturing group
423 self = function(str, separator, limit) {
424 // If `separator` is not a regex, use `nativeSplit`
425 if (Object.prototype.toString.call(separator) !== "[object RegExp]") {
426 return nativeSplit.call(str, separator, limit);
429 flags = (separator.ignoreCase ? "i" : "") + (separator.multiline ? "m" : "") + (separator.extended ? "x" : "") + // Proposed for ES6
430 (separator.sticky ? "y" : ""),
433 // Make `global` and avoid `lastIndex` issues by working with a copy
434 separator = new RegExp(separator.source, flags + "g"),
435 separator2, match, lastIndex, lastLength;
436 str += ""; // Type-convert
437 if (!compliantExecNpcg) {
438 // Doesn't need flags gy, but they don't hurt
439 separator2 = new RegExp("^" + separator.source + "$(?!\\s)", flags);
441 /* Values for `limit`, per the spec:
442 * If undefined: 4294967295 // Math.pow(2, 32) - 1
443 * If 0, Infinity, or NaN: 0
444 * If positive number: limit = Math.floor(limit); if (limit > 4294967295) limit -= 4294967296;
445 * If negative number: 4294967296 - Math.floor(Math.abs(limit))
446 * If other: Type-convert, then use the above rules
448 limit = limit === undef ? -1 >>> 0 : // Math.pow(2, 32) - 1
449 limit >>> 0; // ToUint32(limit)
450 while (match = separator.exec(str)) {
451 // `separator.lastIndex` is not reliable cross-browser
452 lastIndex = match.index + match[0].length;
453 if (lastIndex > lastLastIndex) {
454 output.push(str.slice(lastLastIndex, match.index));
455 // Fix browsers whose `exec` methods don't consistently return `undefined` for
456 // nonparticipating capturing groups
457 if (!compliantExecNpcg && match.length > 1) {
458 match[0].replace(separator2, function() {
459 for (var i = 1; i < arguments.length - 2; i++) {
460 if (arguments[i] === undef) {
466 if (match.length > 1 && match.index < str.length) {
467 Array.prototype.push.apply(output, match.slice(1));
469 lastLength = match[0].length;
470 lastLastIndex = lastIndex;
471 if (output.length >= limit) {
475 if (separator.lastIndex === match.index) {
476 separator.lastIndex++; // Avoid an infinite loop
479 if (lastLastIndex === str.length) {
480 if (lastLength || !separator.test("")) {
484 output.push(str.slice(lastLastIndex));
486 return output.length > limit ? output.slice(0, limit) : output;
492 },{}],6:[function(require,module,exports){
493 // shim for using process in browser
494 var process = module.exports = {};
496 // cached from whatever global is present so that test runners that stub it
497 // don't break things. But we need to wrap it in a try catch in case it is
498 // wrapped in strict mode code which doesn't define any globals. It's inside a
499 // function because try/catches deoptimize in certain engines.
501 var cachedSetTimeout;
502 var cachedClearTimeout;
504 function defaultSetTimout() {
505 throw new Error('setTimeout has not been defined');
507 function defaultClearTimeout () {
508 throw new Error('clearTimeout has not been defined');
512 if (typeof setTimeout === 'function') {
513 cachedSetTimeout = setTimeout;
515 cachedSetTimeout = defaultSetTimout;
518 cachedSetTimeout = defaultSetTimout;
521 if (typeof clearTimeout === 'function') {
522 cachedClearTimeout = clearTimeout;
524 cachedClearTimeout = defaultClearTimeout;
527 cachedClearTimeout = defaultClearTimeout;
530 function runTimeout(fun) {
531 if (cachedSetTimeout === setTimeout) {
532 //normal enviroments in sane situations
533 return setTimeout(fun, 0);
535 // if setTimeout wasn't available but was latter defined
536 if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
537 cachedSetTimeout = setTimeout;
538 return setTimeout(fun, 0);
541 // when when somebody has screwed with setTimeout but no I.E. maddness
542 return cachedSetTimeout(fun, 0);
545 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
546 return cachedSetTimeout.call(null, fun, 0);
548 // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
549 return cachedSetTimeout.call(this, fun, 0);
555 function runClearTimeout(marker) {
556 if (cachedClearTimeout === clearTimeout) {
557 //normal enviroments in sane situations
558 return clearTimeout(marker);
560 // if clearTimeout wasn't available but was latter defined
561 if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
562 cachedClearTimeout = clearTimeout;
563 return clearTimeout(marker);
566 // when when somebody has screwed with setTimeout but no I.E. maddness
567 return cachedClearTimeout(marker);
570 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
571 return cachedClearTimeout.call(null, marker);
573 // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
574 // Some versions of I.E. have different rules for clearTimeout vs setTimeout
575 return cachedClearTimeout.call(this, marker);
583 var draining = false;
587 function cleanUpNextTick() {
588 if (!draining || !currentQueue) {
592 if (currentQueue.length) {
593 queue = currentQueue.concat(queue);
602 function drainQueue() {
606 var timeout = runTimeout(cleanUpNextTick);
609 var len = queue.length;
611 currentQueue = queue;
613 while (++queueIndex < len) {
615 currentQueue[queueIndex].run();
623 runClearTimeout(timeout);
626 process.nextTick = function (fun) {
627 var args = new Array(arguments.length - 1);
628 if (arguments.length > 1) {
629 for (var i = 1; i < arguments.length; i++) {
630 args[i - 1] = arguments[i];
633 queue.push(new Item(fun, args));
634 if (queue.length === 1 && !draining) {
635 runTimeout(drainQueue);
639 // v8 likes predictible objects
640 function Item(fun, array) {
644 Item.prototype.run = function () {
645 this.fun.apply(null, this.array);
647 process.title = 'browser';
648 process.browser = true;
651 process.version = ''; // empty string to avoid regexp issues
652 process.versions = {};
657 process.addListener = noop;
660 process.removeListener = noop;
661 process.removeAllListeners = noop;
663 process.prependListener = noop;
664 process.prependOnceListener = noop;
666 process.listeners = function (name) { return [] }
668 process.binding = function (name) {
669 throw new Error('process.binding is not supported');
672 process.cwd = function () { return '/' };
673 process.chdir = function (dir) {
674 throw new Error('process.chdir is not supported');
676 process.umask = function() { return 0; };
678 },{}],7:[function(require,module,exports){
680 * The buffer module from node.js, for the browser.
682 * @author Feross Aboukhadijeh <https://feross.org>
685 /* eslint-disable no-proto */
689 var base64 = require('base64-js')
690 var ieee754 = require('ieee754')
692 exports.Buffer = Buffer
693 exports.SlowBuffer = SlowBuffer
694 exports.INSPECT_MAX_BYTES = 50
696 var K_MAX_LENGTH = 0x7fffffff
697 exports.kMaxLength = K_MAX_LENGTH
700 * If `Buffer.TYPED_ARRAY_SUPPORT`:
701 * === true Use Uint8Array implementation (fastest)
702 * === false Print warning and recommend using `buffer` v4.x which has an Object
703 * implementation (most compatible, even IE6)
705 * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
706 * Opera 11.6+, iOS 4.2+.
708 * We report that the browser does not support typed arrays if the are not subclassable
709 * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`
710 * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support
711 * for __proto__ and has a buggy typed array implementation.
713 Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport()
715 if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' &&
716 typeof console.error === 'function') {
718 'This browser lacks typed array (Uint8Array) support which is required by ' +
719 '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.'
723 function typedArraySupport () {
724 // Can typed array instances can be augmented?
726 var arr = new Uint8Array(1)
727 arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
728 return arr.foo() === 42
734 function createBuffer (length) {
735 if (length > K_MAX_LENGTH) {
736 throw new RangeError('Invalid typed array length')
738 // Return an augmented `Uint8Array` instance
739 var buf = new Uint8Array(length)
740 buf.__proto__ = Buffer.prototype
745 * The Buffer constructor returns instances of `Uint8Array` that have their
746 * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
747 * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
748 * and the `Uint8Array` methods. Square bracket notation works as expected -- it
749 * returns a single octet.
751 * The `Uint8Array` prototype remains unmodified.
754 function Buffer (arg, encodingOrOffset, length) {
756 if (typeof arg === 'number') {
757 if (typeof encodingOrOffset === 'string') {
759 'If encoding is specified then the first argument must be a string'
762 return allocUnsafe(arg)
764 return from(arg, encodingOrOffset, length)
767 // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
768 if (typeof Symbol !== 'undefined' && Symbol.species &&
769 Buffer[Symbol.species] === Buffer) {
770 Object.defineProperty(Buffer, Symbol.species, {
778 Buffer.poolSize = 8192 // not used by this implementation
780 function from (value, encodingOrOffset, length) {
781 if (typeof value === 'number') {
782 throw new TypeError('"value" argument must not be a number')
785 if (isArrayBuffer(value)) {
786 return fromArrayBuffer(value, encodingOrOffset, length)
789 if (typeof value === 'string') {
790 return fromString(value, encodingOrOffset)
793 return fromObject(value)
797 * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
798 * if value is a number.
799 * Buffer.from(str[, encoding])
801 * Buffer.from(buffer)
802 * Buffer.from(arrayBuffer[, byteOffset[, length]])
804 Buffer.from = function (value, encodingOrOffset, length) {
805 return from(value, encodingOrOffset, length)
808 // Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:
809 // https://github.com/feross/buffer/pull/148
810 Buffer.prototype.__proto__ = Uint8Array.prototype
811 Buffer.__proto__ = Uint8Array
813 function assertSize (size) {
814 if (typeof size !== 'number') {
815 throw new TypeError('"size" argument must be a number')
816 } else if (size < 0) {
817 throw new RangeError('"size" argument must not be negative')
821 function alloc (size, fill, encoding) {
824 return createBuffer(size)
826 if (fill !== undefined) {
827 // Only pay attention to encoding if it's a string. This
828 // prevents accidentally sending in a number that would
829 // be interpretted as a start offset.
830 return typeof encoding === 'string'
831 ? createBuffer(size).fill(fill, encoding)
832 : createBuffer(size).fill(fill)
834 return createBuffer(size)
838 * Creates a new filled Buffer instance.
839 * alloc(size[, fill[, encoding]])
841 Buffer.alloc = function (size, fill, encoding) {
842 return alloc(size, fill, encoding)
845 function allocUnsafe (size) {
847 return createBuffer(size < 0 ? 0 : checked(size) | 0)
851 * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
853 Buffer.allocUnsafe = function (size) {
854 return allocUnsafe(size)
857 * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
859 Buffer.allocUnsafeSlow = function (size) {
860 return allocUnsafe(size)
863 function fromString (string, encoding) {
864 if (typeof encoding !== 'string' || encoding === '') {
868 if (!Buffer.isEncoding(encoding)) {
869 throw new TypeError('"encoding" must be a valid string encoding')
872 var length = byteLength(string, encoding) | 0
873 var buf = createBuffer(length)
875 var actual = buf.write(string, encoding)
877 if (actual !== length) {
878 // Writing a hex string, for example, that contains invalid characters will
879 // cause everything after the first invalid character to be ignored. (e.g.
880 // 'abxxcd' will be treated as 'ab')
881 buf = buf.slice(0, actual)
887 function fromArrayLike (array) {
888 var length = array.length < 0 ? 0 : checked(array.length) | 0
889 var buf = createBuffer(length)
890 for (var i = 0; i < length; i += 1) {
891 buf[i] = array[i] & 255
896 function fromArrayBuffer (array, byteOffset, length) {
897 if (byteOffset < 0 || array.byteLength < byteOffset) {
898 throw new RangeError('\'offset\' is out of bounds')
901 if (array.byteLength < byteOffset + (length || 0)) {
902 throw new RangeError('\'length\' is out of bounds')
906 if (byteOffset === undefined && length === undefined) {
907 buf = new Uint8Array(array)
908 } else if (length === undefined) {
909 buf = new Uint8Array(array, byteOffset)
911 buf = new Uint8Array(array, byteOffset, length)
914 // Return an augmented `Uint8Array` instance
915 buf.__proto__ = Buffer.prototype
919 function fromObject (obj) {
920 if (Buffer.isBuffer(obj)) {
921 var len = checked(obj.length) | 0
922 var buf = createBuffer(len)
924 if (buf.length === 0) {
928 obj.copy(buf, 0, 0, len)
933 if (isArrayBufferView(obj) || 'length' in obj) {
934 if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {
935 return createBuffer(0)
937 return fromArrayLike(obj)
940 if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
941 return fromArrayLike(obj.data)
945 throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
948 function checked (length) {
949 // Note: cannot use `length < K_MAX_LENGTH` here because that fails when
950 // length is NaN (which is otherwise coerced to zero.)
951 if (length >= K_MAX_LENGTH) {
952 throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
953 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')
958 function SlowBuffer (length) {
959 if (+length != length) { // eslint-disable-line eqeqeq
962 return Buffer.alloc(+length)
965 Buffer.isBuffer = function isBuffer (b) {
966 return b != null && b._isBuffer === true
969 Buffer.compare = function compare (a, b) {
970 if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
971 throw new TypeError('Arguments must be Buffers')
974 if (a === b) return 0
979 for (var i = 0, len = Math.min(x, y); i < len; ++i) {
992 Buffer.isEncoding = function isEncoding (encoding) {
993 switch (String(encoding).toLowerCase()) {
1011 Buffer.concat = function concat (list, length) {
1012 if (!Array.isArray(list)) {
1013 throw new TypeError('"list" argument must be an Array of Buffers')
1016 if (list.length === 0) {
1017 return Buffer.alloc(0)
1021 if (length === undefined) {
1023 for (i = 0; i < list.length; ++i) {
1024 length += list[i].length
1028 var buffer = Buffer.allocUnsafe(length)
1030 for (i = 0; i < list.length; ++i) {
1032 if (!Buffer.isBuffer(buf)) {
1033 throw new TypeError('"list" argument must be an Array of Buffers')
1035 buf.copy(buffer, pos)
1041 function byteLength (string, encoding) {
1042 if (Buffer.isBuffer(string)) {
1043 return string.length
1045 if (isArrayBufferView(string) || isArrayBuffer(string)) {
1046 return string.byteLength
1048 if (typeof string !== 'string') {
1049 string = '' + string
1052 var len = string.length
1053 if (len === 0) return 0
1055 // Use a for loop to avoid recursion
1056 var loweredCase = false
1066 return utf8ToBytes(string).length
1075 return base64ToBytes(string).length
1077 if (loweredCase) return utf8ToBytes(string).length // assume utf8
1078 encoding = ('' + encoding).toLowerCase()
1083 Buffer.byteLength = byteLength
1085 function slowToString (encoding, start, end) {
1086 var loweredCase = false
1088 // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
1089 // property of a typed array.
1091 // This behaves neither like String nor Uint8Array in that we set start/end
1092 // to their upper/lower bounds if the value passed is out of range.
1093 // undefined is handled specially as per ECMA-262 6th Edition,
1094 // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
1095 if (start === undefined || start < 0) {
1098 // Return early if start > this.length. Done here to prevent potential uint32
1099 // coercion fail below.
1100 if (start > this.length) {
1104 if (end === undefined || end > this.length) {
1112 // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
1120 if (!encoding) encoding = 'utf8'
1125 return hexSlice(this, start, end)
1129 return utf8Slice(this, start, end)
1132 return asciiSlice(this, start, end)
1136 return latin1Slice(this, start, end)
1139 return base64Slice(this, start, end)
1145 return utf16leSlice(this, start, end)
1148 if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
1149 encoding = (encoding + '').toLowerCase()
1155 // This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)
1156 // to detect a Buffer instance. It's not possible to use `instanceof Buffer`
1157 // reliably in a browserify context because there could be multiple different
1158 // copies of the 'buffer' package in use. This method works even for Buffer
1159 // instances that were created from another copy of the `buffer` package.
1160 // See: https://github.com/feross/buffer/issues/154
1161 Buffer.prototype._isBuffer = true
1163 function swap (b, n, m) {
1169 Buffer.prototype.swap16 = function swap16 () {
1170 var len = this.length
1171 if (len % 2 !== 0) {
1172 throw new RangeError('Buffer size must be a multiple of 16-bits')
1174 for (var i = 0; i < len; i += 2) {
1175 swap(this, i, i + 1)
1180 Buffer.prototype.swap32 = function swap32 () {
1181 var len = this.length
1182 if (len % 4 !== 0) {
1183 throw new RangeError('Buffer size must be a multiple of 32-bits')
1185 for (var i = 0; i < len; i += 4) {
1186 swap(this, i, i + 3)
1187 swap(this, i + 1, i + 2)
1192 Buffer.prototype.swap64 = function swap64 () {
1193 var len = this.length
1194 if (len % 8 !== 0) {
1195 throw new RangeError('Buffer size must be a multiple of 64-bits')
1197 for (var i = 0; i < len; i += 8) {
1198 swap(this, i, i + 7)
1199 swap(this, i + 1, i + 6)
1200 swap(this, i + 2, i + 5)
1201 swap(this, i + 3, i + 4)
1206 Buffer.prototype.toString = function toString () {
1207 var length = this.length
1208 if (length === 0) return ''
1209 if (arguments.length === 0) return utf8Slice(this, 0, length)
1210 return slowToString.apply(this, arguments)
1213 Buffer.prototype.equals = function equals (b) {
1214 if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
1215 if (this === b) return true
1216 return Buffer.compare(this, b) === 0
1219 Buffer.prototype.inspect = function inspect () {
1221 var max = exports.INSPECT_MAX_BYTES
1222 if (this.length > 0) {
1223 str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
1224 if (this.length > max) str += ' ... '
1226 return '<Buffer ' + str + '>'
1229 Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
1230 if (!Buffer.isBuffer(target)) {
1231 throw new TypeError('Argument must be a Buffer')
1234 if (start === undefined) {
1237 if (end === undefined) {
1238 end = target ? target.length : 0
1240 if (thisStart === undefined) {
1243 if (thisEnd === undefined) {
1244 thisEnd = this.length
1247 if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
1248 throw new RangeError('out of range index')
1251 if (thisStart >= thisEnd && start >= end) {
1254 if (thisStart >= thisEnd) {
1266 if (this === target) return 0
1268 var x = thisEnd - thisStart
1270 var len = Math.min(x, y)
1272 var thisCopy = this.slice(thisStart, thisEnd)
1273 var targetCopy = target.slice(start, end)
1275 for (var i = 0; i < len; ++i) {
1276 if (thisCopy[i] !== targetCopy[i]) {
1283 if (x < y) return -1
1288 // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
1289 // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
1292 // - buffer - a Buffer to search
1293 // - val - a string, Buffer, or number
1294 // - byteOffset - an index into `buffer`; will be clamped to an int32
1295 // - encoding - an optional encoding, relevant is val is a string
1296 // - dir - true for indexOf, false for lastIndexOf
1297 function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
1298 // Empty buffer means no match
1299 if (buffer.length === 0) return -1
1301 // Normalize byteOffset
1302 if (typeof byteOffset === 'string') {
1303 encoding = byteOffset
1305 } else if (byteOffset > 0x7fffffff) {
1306 byteOffset = 0x7fffffff
1307 } else if (byteOffset < -0x80000000) {
1308 byteOffset = -0x80000000
1310 byteOffset = +byteOffset // Coerce to Number.
1311 if (numberIsNaN(byteOffset)) {
1312 // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
1313 byteOffset = dir ? 0 : (buffer.length - 1)
1316 // Normalize byteOffset: negative offsets start from the end of the buffer
1317 if (byteOffset < 0) byteOffset = buffer.length + byteOffset
1318 if (byteOffset >= buffer.length) {
1320 else byteOffset = buffer.length - 1
1321 } else if (byteOffset < 0) {
1322 if (dir) byteOffset = 0
1327 if (typeof val === 'string') {
1328 val = Buffer.from(val, encoding)
1331 // Finally, search either indexOf (if dir is true) or lastIndexOf
1332 if (Buffer.isBuffer(val)) {
1333 // Special case: looking for empty string/buffer always fails
1334 if (val.length === 0) {
1337 return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
1338 } else if (typeof val === 'number') {
1339 val = val & 0xFF // Search for a byte value [0-255]
1340 if (typeof Uint8Array.prototype.indexOf === 'function') {
1342 return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
1344 return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
1347 return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
1350 throw new TypeError('val must be string, number or Buffer')
1353 function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
1355 var arrLength = arr.length
1356 var valLength = val.length
1358 if (encoding !== undefined) {
1359 encoding = String(encoding).toLowerCase()
1360 if (encoding === 'ucs2' || encoding === 'ucs-2' ||
1361 encoding === 'utf16le' || encoding === 'utf-16le') {
1362 if (arr.length < 2 || val.length < 2) {
1372 function read (buf, i) {
1373 if (indexSize === 1) {
1376 return buf.readUInt16BE(i * indexSize)
1383 for (i = byteOffset; i < arrLength; i++) {
1384 if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
1385 if (foundIndex === -1) foundIndex = i
1386 if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
1388 if (foundIndex !== -1) i -= i - foundIndex
1393 if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
1394 for (i = byteOffset; i >= 0; i--) {
1396 for (var j = 0; j < valLength; j++) {
1397 if (read(arr, i + j) !== read(val, j)) {
1409 Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
1410 return this.indexOf(val, byteOffset, encoding) !== -1
1413 Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
1414 return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
1417 Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
1418 return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
1421 function hexWrite (buf, string, offset, length) {
1422 offset = Number(offset) || 0
1423 var remaining = buf.length - offset
1427 length = Number(length)
1428 if (length > remaining) {
1433 // must be an even number of digits
1434 var strLen = string.length
1435 if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
1437 if (length > strLen / 2) {
1440 for (var i = 0; i < length; ++i) {
1441 var parsed = parseInt(string.substr(i * 2, 2), 16)
1442 if (numberIsNaN(parsed)) return i
1443 buf[offset + i] = parsed
1448 function utf8Write (buf, string, offset, length) {
1449 return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
1452 function asciiWrite (buf, string, offset, length) {
1453 return blitBuffer(asciiToBytes(string), buf, offset, length)
1456 function latin1Write (buf, string, offset, length) {
1457 return asciiWrite(buf, string, offset, length)
1460 function base64Write (buf, string, offset, length) {
1461 return blitBuffer(base64ToBytes(string), buf, offset, length)
1464 function ucs2Write (buf, string, offset, length) {
1465 return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
1468 Buffer.prototype.write = function write (string, offset, length, encoding) {
1469 // Buffer#write(string)
1470 if (offset === undefined) {
1472 length = this.length
1474 // Buffer#write(string, encoding)
1475 } else if (length === undefined && typeof offset === 'string') {
1477 length = this.length
1479 // Buffer#write(string, offset[, length][, encoding])
1480 } else if (isFinite(offset)) {
1481 offset = offset >>> 0
1482 if (isFinite(length)) {
1483 length = length >>> 0
1484 if (encoding === undefined) encoding = 'utf8'
1491 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
1495 var remaining = this.length - offset
1496 if (length === undefined || length > remaining) length = remaining
1498 if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
1499 throw new RangeError('Attempt to write outside buffer bounds')
1502 if (!encoding) encoding = 'utf8'
1504 var loweredCase = false
1508 return hexWrite(this, string, offset, length)
1512 return utf8Write(this, string, offset, length)
1515 return asciiWrite(this, string, offset, length)
1519 return latin1Write(this, string, offset, length)
1522 // Warning: maxLength not taken into account in base64Write
1523 return base64Write(this, string, offset, length)
1529 return ucs2Write(this, string, offset, length)
1532 if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
1533 encoding = ('' + encoding).toLowerCase()
1539 Buffer.prototype.toJSON = function toJSON () {
1542 data: Array.prototype.slice.call(this._arr || this, 0)
1546 function base64Slice (buf, start, end) {
1547 if (start === 0 && end === buf.length) {
1548 return base64.fromByteArray(buf)
1550 return base64.fromByteArray(buf.slice(start, end))
1554 function utf8Slice (buf, start, end) {
1555 end = Math.min(buf.length, end)
1560 var firstByte = buf[i]
1561 var codePoint = null
1562 var bytesPerSequence = (firstByte > 0xEF) ? 4
1563 : (firstByte > 0xDF) ? 3
1564 : (firstByte > 0xBF) ? 2
1567 if (i + bytesPerSequence <= end) {
1568 var secondByte, thirdByte, fourthByte, tempCodePoint
1570 switch (bytesPerSequence) {
1572 if (firstByte < 0x80) {
1573 codePoint = firstByte
1577 secondByte = buf[i + 1]
1578 if ((secondByte & 0xC0) === 0x80) {
1579 tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
1580 if (tempCodePoint > 0x7F) {
1581 codePoint = tempCodePoint
1586 secondByte = buf[i + 1]
1587 thirdByte = buf[i + 2]
1588 if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
1589 tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
1590 if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
1591 codePoint = tempCodePoint
1596 secondByte = buf[i + 1]
1597 thirdByte = buf[i + 2]
1598 fourthByte = buf[i + 3]
1599 if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
1600 tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
1601 if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
1602 codePoint = tempCodePoint
1608 if (codePoint === null) {
1609 // we did not generate a valid codePoint so insert a
1610 // replacement char (U+FFFD) and advance only 1 byte
1612 bytesPerSequence = 1
1613 } else if (codePoint > 0xFFFF) {
1614 // encode to utf16 (surrogate pair dance)
1615 codePoint -= 0x10000
1616 res.push(codePoint >>> 10 & 0x3FF | 0xD800)
1617 codePoint = 0xDC00 | codePoint & 0x3FF
1621 i += bytesPerSequence
1624 return decodeCodePointsArray(res)
1627 // Based on http://stackoverflow.com/a/22747272/680742, the browser with
1628 // the lowest limit is Chrome, with 0x10000 args.
1629 // We go 1 magnitude less, for safety
1630 var MAX_ARGUMENTS_LENGTH = 0x1000
1632 function decodeCodePointsArray (codePoints) {
1633 var len = codePoints.length
1634 if (len <= MAX_ARGUMENTS_LENGTH) {
1635 return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
1638 // Decode in chunks to avoid "call stack size exceeded".
1642 res += String.fromCharCode.apply(
1644 codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
1650 function asciiSlice (buf, start, end) {
1652 end = Math.min(buf.length, end)
1654 for (var i = start; i < end; ++i) {
1655 ret += String.fromCharCode(buf[i] & 0x7F)
1660 function latin1Slice (buf, start, end) {
1662 end = Math.min(buf.length, end)
1664 for (var i = start; i < end; ++i) {
1665 ret += String.fromCharCode(buf[i])
1670 function hexSlice (buf, start, end) {
1671 var len = buf.length
1673 if (!start || start < 0) start = 0
1674 if (!end || end < 0 || end > len) end = len
1677 for (var i = start; i < end; ++i) {
1678 out += toHex(buf[i])
1683 function utf16leSlice (buf, start, end) {
1684 var bytes = buf.slice(start, end)
1686 for (var i = 0; i < bytes.length; i += 2) {
1687 res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256))
1692 Buffer.prototype.slice = function slice (start, end) {
1693 var len = this.length
1695 end = end === undefined ? len : ~~end
1699 if (start < 0) start = 0
1700 } else if (start > len) {
1706 if (end < 0) end = 0
1707 } else if (end > len) {
1711 if (end < start) end = start
1713 var newBuf = this.subarray(start, end)
1714 // Return an augmented `Uint8Array` instance
1715 newBuf.__proto__ = Buffer.prototype
1720 * Need to make sure that buffer isn't trying to write out of bounds.
1722 function checkOffset (offset, ext, length) {
1723 if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
1724 if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
1727 Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
1728 offset = offset >>> 0
1729 byteLength = byteLength >>> 0
1730 if (!noAssert) checkOffset(offset, byteLength, this.length)
1732 var val = this[offset]
1735 while (++i < byteLength && (mul *= 0x100)) {
1736 val += this[offset + i] * mul
1742 Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
1743 offset = offset >>> 0
1744 byteLength = byteLength >>> 0
1746 checkOffset(offset, byteLength, this.length)
1749 var val = this[offset + --byteLength]
1751 while (byteLength > 0 && (mul *= 0x100)) {
1752 val += this[offset + --byteLength] * mul
1758 Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
1759 offset = offset >>> 0
1760 if (!noAssert) checkOffset(offset, 1, this.length)
1764 Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
1765 offset = offset >>> 0
1766 if (!noAssert) checkOffset(offset, 2, this.length)
1767 return this[offset] | (this[offset + 1] << 8)
1770 Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
1771 offset = offset >>> 0
1772 if (!noAssert) checkOffset(offset, 2, this.length)
1773 return (this[offset] << 8) | this[offset + 1]
1776 Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
1777 offset = offset >>> 0
1778 if (!noAssert) checkOffset(offset, 4, this.length)
1780 return ((this[offset]) |
1781 (this[offset + 1] << 8) |
1782 (this[offset + 2] << 16)) +
1783 (this[offset + 3] * 0x1000000)
1786 Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
1787 offset = offset >>> 0
1788 if (!noAssert) checkOffset(offset, 4, this.length)
1790 return (this[offset] * 0x1000000) +
1791 ((this[offset + 1] << 16) |
1792 (this[offset + 2] << 8) |
1796 Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
1797 offset = offset >>> 0
1798 byteLength = byteLength >>> 0
1799 if (!noAssert) checkOffset(offset, byteLength, this.length)
1801 var val = this[offset]
1804 while (++i < byteLength && (mul *= 0x100)) {
1805 val += this[offset + i] * mul
1809 if (val >= mul) val -= Math.pow(2, 8 * byteLength)
1814 Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
1815 offset = offset >>> 0
1816 byteLength = byteLength >>> 0
1817 if (!noAssert) checkOffset(offset, byteLength, this.length)
1821 var val = this[offset + --i]
1822 while (i > 0 && (mul *= 0x100)) {
1823 val += this[offset + --i] * mul
1827 if (val >= mul) val -= Math.pow(2, 8 * byteLength)
1832 Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
1833 offset = offset >>> 0
1834 if (!noAssert) checkOffset(offset, 1, this.length)
1835 if (!(this[offset] & 0x80)) return (this[offset])
1836 return ((0xff - this[offset] + 1) * -1)
1839 Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
1840 offset = offset >>> 0
1841 if (!noAssert) checkOffset(offset, 2, this.length)
1842 var val = this[offset] | (this[offset + 1] << 8)
1843 return (val & 0x8000) ? val | 0xFFFF0000 : val
1846 Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
1847 offset = offset >>> 0
1848 if (!noAssert) checkOffset(offset, 2, this.length)
1849 var val = this[offset + 1] | (this[offset] << 8)
1850 return (val & 0x8000) ? val | 0xFFFF0000 : val
1853 Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
1854 offset = offset >>> 0
1855 if (!noAssert) checkOffset(offset, 4, this.length)
1857 return (this[offset]) |
1858 (this[offset + 1] << 8) |
1859 (this[offset + 2] << 16) |
1860 (this[offset + 3] << 24)
1863 Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
1864 offset = offset >>> 0
1865 if (!noAssert) checkOffset(offset, 4, this.length)
1867 return (this[offset] << 24) |
1868 (this[offset + 1] << 16) |
1869 (this[offset + 2] << 8) |
1873 Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
1874 offset = offset >>> 0
1875 if (!noAssert) checkOffset(offset, 4, this.length)
1876 return ieee754.read(this, offset, true, 23, 4)
1879 Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
1880 offset = offset >>> 0
1881 if (!noAssert) checkOffset(offset, 4, this.length)
1882 return ieee754.read(this, offset, false, 23, 4)
1885 Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
1886 offset = offset >>> 0
1887 if (!noAssert) checkOffset(offset, 8, this.length)
1888 return ieee754.read(this, offset, true, 52, 8)
1891 Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
1892 offset = offset >>> 0
1893 if (!noAssert) checkOffset(offset, 8, this.length)
1894 return ieee754.read(this, offset, false, 52, 8)
1897 function checkInt (buf, value, offset, ext, max, min) {
1898 if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
1899 if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
1900 if (offset + ext > buf.length) throw new RangeError('Index out of range')
1903 Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
1905 offset = offset >>> 0
1906 byteLength = byteLength >>> 0
1908 var maxBytes = Math.pow(2, 8 * byteLength) - 1
1909 checkInt(this, value, offset, byteLength, maxBytes, 0)
1914 this[offset] = value & 0xFF
1915 while (++i < byteLength && (mul *= 0x100)) {
1916 this[offset + i] = (value / mul) & 0xFF
1919 return offset + byteLength
1922 Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
1924 offset = offset >>> 0
1925 byteLength = byteLength >>> 0
1927 var maxBytes = Math.pow(2, 8 * byteLength) - 1
1928 checkInt(this, value, offset, byteLength, maxBytes, 0)
1931 var i = byteLength - 1
1933 this[offset + i] = value & 0xFF
1934 while (--i >= 0 && (mul *= 0x100)) {
1935 this[offset + i] = (value / mul) & 0xFF
1938 return offset + byteLength
1941 Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
1943 offset = offset >>> 0
1944 if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
1945 this[offset] = (value & 0xff)
1949 Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
1951 offset = offset >>> 0
1952 if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
1953 this[offset] = (value & 0xff)
1954 this[offset + 1] = (value >>> 8)
1958 Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
1960 offset = offset >>> 0
1961 if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
1962 this[offset] = (value >>> 8)
1963 this[offset + 1] = (value & 0xff)
1967 Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
1969 offset = offset >>> 0
1970 if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
1971 this[offset + 3] = (value >>> 24)
1972 this[offset + 2] = (value >>> 16)
1973 this[offset + 1] = (value >>> 8)
1974 this[offset] = (value & 0xff)
1978 Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
1980 offset = offset >>> 0
1981 if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
1982 this[offset] = (value >>> 24)
1983 this[offset + 1] = (value >>> 16)
1984 this[offset + 2] = (value >>> 8)
1985 this[offset + 3] = (value & 0xff)
1989 Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
1991 offset = offset >>> 0
1993 var limit = Math.pow(2, (8 * byteLength) - 1)
1995 checkInt(this, value, offset, byteLength, limit - 1, -limit)
2001 this[offset] = value & 0xFF
2002 while (++i < byteLength && (mul *= 0x100)) {
2003 if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
2006 this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
2009 return offset + byteLength
2012 Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
2014 offset = offset >>> 0
2016 var limit = Math.pow(2, (8 * byteLength) - 1)
2018 checkInt(this, value, offset, byteLength, limit - 1, -limit)
2021 var i = byteLength - 1
2024 this[offset + i] = value & 0xFF
2025 while (--i >= 0 && (mul *= 0x100)) {
2026 if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
2029 this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
2032 return offset + byteLength
2035 Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
2037 offset = offset >>> 0
2038 if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
2039 if (value < 0) value = 0xff + value + 1
2040 this[offset] = (value & 0xff)
2044 Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
2046 offset = offset >>> 0
2047 if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
2048 this[offset] = (value & 0xff)
2049 this[offset + 1] = (value >>> 8)
2053 Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
2055 offset = offset >>> 0
2056 if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
2057 this[offset] = (value >>> 8)
2058 this[offset + 1] = (value & 0xff)
2062 Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
2064 offset = offset >>> 0
2065 if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
2066 this[offset] = (value & 0xff)
2067 this[offset + 1] = (value >>> 8)
2068 this[offset + 2] = (value >>> 16)
2069 this[offset + 3] = (value >>> 24)
2073 Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
2075 offset = offset >>> 0
2076 if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
2077 if (value < 0) value = 0xffffffff + value + 1
2078 this[offset] = (value >>> 24)
2079 this[offset + 1] = (value >>> 16)
2080 this[offset + 2] = (value >>> 8)
2081 this[offset + 3] = (value & 0xff)
2085 function checkIEEE754 (buf, value, offset, ext, max, min) {
2086 if (offset + ext > buf.length) throw new RangeError('Index out of range')
2087 if (offset < 0) throw new RangeError('Index out of range')
2090 function writeFloat (buf, value, offset, littleEndian, noAssert) {
2092 offset = offset >>> 0
2094 checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
2096 ieee754.write(buf, value, offset, littleEndian, 23, 4)
2100 Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
2101 return writeFloat(this, value, offset, true, noAssert)
2104 Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
2105 return writeFloat(this, value, offset, false, noAssert)
2108 function writeDouble (buf, value, offset, littleEndian, noAssert) {
2110 offset = offset >>> 0
2112 checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
2114 ieee754.write(buf, value, offset, littleEndian, 52, 8)
2118 Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
2119 return writeDouble(this, value, offset, true, noAssert)
2122 Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
2123 return writeDouble(this, value, offset, false, noAssert)
2126 // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
2127 Buffer.prototype.copy = function copy (target, targetStart, start, end) {
2128 if (!start) start = 0
2129 if (!end && end !== 0) end = this.length
2130 if (targetStart >= target.length) targetStart = target.length
2131 if (!targetStart) targetStart = 0
2132 if (end > 0 && end < start) end = start
2134 // Copy 0 bytes; we're done
2135 if (end === start) return 0
2136 if (target.length === 0 || this.length === 0) return 0
2138 // Fatal error conditions
2139 if (targetStart < 0) {
2140 throw new RangeError('targetStart out of bounds')
2142 if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
2143 if (end < 0) throw new RangeError('sourceEnd out of bounds')
2146 if (end > this.length) end = this.length
2147 if (target.length - targetStart < end - start) {
2148 end = target.length - targetStart + start
2151 var len = end - start
2154 if (this === target && start < targetStart && targetStart < end) {
2155 // descending copy from end
2156 for (i = len - 1; i >= 0; --i) {
2157 target[i + targetStart] = this[i + start]
2159 } else if (len < 1000) {
2160 // ascending copy from start
2161 for (i = 0; i < len; ++i) {
2162 target[i + targetStart] = this[i + start]
2165 Uint8Array.prototype.set.call(
2167 this.subarray(start, start + len),
2176 // buffer.fill(number[, offset[, end]])
2177 // buffer.fill(buffer[, offset[, end]])
2178 // buffer.fill(string[, offset[, end]][, encoding])
2179 Buffer.prototype.fill = function fill (val, start, end, encoding) {
2180 // Handle string cases:
2181 if (typeof val === 'string') {
2182 if (typeof start === 'string') {
2186 } else if (typeof end === 'string') {
2190 if (val.length === 1) {
2191 var code = val.charCodeAt(0)
2196 if (encoding !== undefined && typeof encoding !== 'string') {
2197 throw new TypeError('encoding must be a string')
2199 if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
2200 throw new TypeError('Unknown encoding: ' + encoding)
2202 } else if (typeof val === 'number') {
2206 // Invalid ranges are not set to a default, so can range check early.
2207 if (start < 0 || this.length < start || this.length < end) {
2208 throw new RangeError('Out of range index')
2216 end = end === undefined ? this.length : end >>> 0
2221 if (typeof val === 'number') {
2222 for (i = start; i < end; ++i) {
2226 var bytes = Buffer.isBuffer(val)
2228 : new Buffer(val, encoding)
2229 var len = bytes.length
2230 for (i = 0; i < end - start; ++i) {
2231 this[i + start] = bytes[i % len]
2241 var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g
2243 function base64clean (str) {
2244 // Node strips out invalid characters like \n and \t from the string, base64-js does not
2245 str = str.trim().replace(INVALID_BASE64_RE, '')
2246 // Node converts strings with length < 2 to ''
2247 if (str.length < 2) return ''
2248 // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
2249 while (str.length % 4 !== 0) {
2255 function toHex (n) {
2256 if (n < 16) return '0' + n.toString(16)
2257 return n.toString(16)
2260 function utf8ToBytes (string, units) {
2261 units = units || Infinity
2263 var length = string.length
2264 var leadSurrogate = null
2267 for (var i = 0; i < length; ++i) {
2268 codePoint = string.charCodeAt(i)
2270 // is surrogate component
2271 if (codePoint > 0xD7FF && codePoint < 0xE000) {
2272 // last char was a lead
2273 if (!leadSurrogate) {
2275 if (codePoint > 0xDBFF) {
2277 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
2279 } else if (i + 1 === length) {
2281 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
2286 leadSurrogate = codePoint
2292 if (codePoint < 0xDC00) {
2293 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
2294 leadSurrogate = codePoint
2298 // valid surrogate pair
2299 codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
2300 } else if (leadSurrogate) {
2301 // valid bmp char, but last char was a lead
2302 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
2305 leadSurrogate = null
2308 if (codePoint < 0x80) {
2309 if ((units -= 1) < 0) break
2310 bytes.push(codePoint)
2311 } else if (codePoint < 0x800) {
2312 if ((units -= 2) < 0) break
2314 codePoint >> 0x6 | 0xC0,
2315 codePoint & 0x3F | 0x80
2317 } else if (codePoint < 0x10000) {
2318 if ((units -= 3) < 0) break
2320 codePoint >> 0xC | 0xE0,
2321 codePoint >> 0x6 & 0x3F | 0x80,
2322 codePoint & 0x3F | 0x80
2324 } else if (codePoint < 0x110000) {
2325 if ((units -= 4) < 0) break
2327 codePoint >> 0x12 | 0xF0,
2328 codePoint >> 0xC & 0x3F | 0x80,
2329 codePoint >> 0x6 & 0x3F | 0x80,
2330 codePoint & 0x3F | 0x80
2333 throw new Error('Invalid code point')
2340 function asciiToBytes (str) {
2342 for (var i = 0; i < str.length; ++i) {
2343 // Node's code seems to be doing this and not & 0x7F..
2344 byteArray.push(str.charCodeAt(i) & 0xFF)
2349 function utf16leToBytes (str, units) {
2352 for (var i = 0; i < str.length; ++i) {
2353 if ((units -= 2) < 0) break
2355 c = str.charCodeAt(i)
2365 function base64ToBytes (str) {
2366 return base64.toByteArray(base64clean(str))
2369 function blitBuffer (src, dst, offset, length) {
2370 for (var i = 0; i < length; ++i) {
2371 if ((i + offset >= dst.length) || (i >= src.length)) break
2372 dst[i + offset] = src[i]
2377 // ArrayBuffers from another context (i.e. an iframe) do not pass the `instanceof` check
2378 // but they should be treated as valid. See: https://github.com/feross/buffer/issues/166
2379 function isArrayBuffer (obj) {
2380 return obj instanceof ArrayBuffer ||
2381 (obj != null && obj.constructor != null && obj.constructor.name === 'ArrayBuffer' &&
2382 typeof obj.byteLength === 'number')
2385 // Node 0.10 supports `ArrayBuffer` but lacks `ArrayBuffer.isView`
2386 function isArrayBufferView (obj) {
2387 return (typeof ArrayBuffer.isView === 'function') && ArrayBuffer.isView(obj)
2390 function numberIsNaN (obj) {
2391 return obj !== obj // eslint-disable-line no-self-compare
2394 },{"base64-js":3,"ieee754":17}],8:[function(require,module,exports){
2397 module.exports = earcut;
2398 module.exports.default = earcut;
2400 function earcut(data, holeIndices, dim) {
2404 var hasHoles = holeIndices && holeIndices.length,
2405 outerLen = hasHoles ? holeIndices[0] * dim : data.length,
2406 outerNode = linkedList(data, 0, outerLen, dim, true),
2409 if (!outerNode) return triangles;
2411 var minX, minY, maxX, maxY, x, y, invSize;
2413 if (hasHoles) outerNode = eliminateHoles(data, holeIndices, outerNode, dim);
2415 // if the shape is not too simple, we'll use z-order curve hash later; calculate polygon bbox
2416 if (data.length > 80 * dim) {
2417 minX = maxX = data[0];
2418 minY = maxY = data[1];
2420 for (var i = dim; i < outerLen; i += dim) {
2423 if (x < minX) minX = x;
2424 if (y < minY) minY = y;
2425 if (x > maxX) maxX = x;
2426 if (y > maxY) maxY = y;
2429 // minX, minY and invSize are later used to transform coords into integers for z-order calculation
2430 invSize = Math.max(maxX - minX, maxY - minY);
2431 invSize = invSize !== 0 ? 1 / invSize : 0;
2434 earcutLinked(outerNode, triangles, dim, minX, minY, invSize);
2439 // create a circular doubly linked list from polygon points in the specified winding order
2440 function linkedList(data, start, end, dim, clockwise) {
2443 if (clockwise === (signedArea(data, start, end, dim) > 0)) {
2444 for (i = start; i < end; i += dim) last = insertNode(i, data[i], data[i + 1], last);
2446 for (i = end - dim; i >= start; i -= dim) last = insertNode(i, data[i], data[i + 1], last);
2449 if (last && equals(last, last.next)) {
2457 // eliminate colinear or duplicate points
2458 function filterPoints(start, end) {
2459 if (!start) return start;
2460 if (!end) end = start;
2467 if (!p.steiner && (equals(p, p.next) || area(p.prev, p, p.next) === 0)) {
2470 if (p === p.next) break;
2476 } while (again || p !== end);
2481 // main ear slicing loop which triangulates a polygon (given as a linked list)
2482 function earcutLinked(ear, triangles, dim, minX, minY, invSize, pass) {
2485 // interlink polygon nodes in z-order
2486 if (!pass && invSize) indexCurve(ear, minX, minY, invSize);
2491 // iterate through ears, slicing them one by one
2492 while (ear.prev !== ear.next) {
2496 if (invSize ? isEarHashed(ear, minX, minY, invSize) : isEar(ear)) {
2497 // cut off the triangle
2498 triangles.push(prev.i / dim);
2499 triangles.push(ear.i / dim);
2500 triangles.push(next.i / dim);
2504 // skipping the next vertice leads to less sliver triangles
2513 // if we looped through the whole remaining polygon and can't find any more ears
2515 // try filtering points and slicing again
2517 earcutLinked(filterPoints(ear), triangles, dim, minX, minY, invSize, 1);
2519 // if this didn't work, try curing all small self-intersections locally
2520 } else if (pass === 1) {
2521 ear = cureLocalIntersections(ear, triangles, dim);
2522 earcutLinked(ear, triangles, dim, minX, minY, invSize, 2);
2524 // as a last resort, try splitting the remaining polygon into two
2525 } else if (pass === 2) {
2526 splitEarcut(ear, triangles, dim, minX, minY, invSize);
2534 // check whether a polygon node forms a valid ear with adjacent nodes
2535 function isEar(ear) {
2540 if (area(a, b, c) >= 0) return false; // reflex, can't be an ear
2542 // now make sure we don't have other points inside the potential ear
2543 var p = ear.next.next;
2545 while (p !== ear.prev) {
2546 if (pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) &&
2547 area(p.prev, p, p.next) >= 0) return false;
2554 function isEarHashed(ear, minX, minY, invSize) {
2559 if (area(a, b, c) >= 0) return false; // reflex, can't be an ear
2561 // triangle bbox; min & max are calculated like this for speed
2562 var minTX = a.x < b.x ? (a.x < c.x ? a.x : c.x) : (b.x < c.x ? b.x : c.x),
2563 minTY = a.y < b.y ? (a.y < c.y ? a.y : c.y) : (b.y < c.y ? b.y : c.y),
2564 maxTX = a.x > b.x ? (a.x > c.x ? a.x : c.x) : (b.x > c.x ? b.x : c.x),
2565 maxTY = a.y > b.y ? (a.y > c.y ? a.y : c.y) : (b.y > c.y ? b.y : c.y);
2567 // z-order range for the current triangle bbox;
2568 var minZ = zOrder(minTX, minTY, minX, minY, invSize),
2569 maxZ = zOrder(maxTX, maxTY, minX, minY, invSize);
2574 // look for points inside the triangle in both directions
2575 while (p && p.z >= minZ && n && n.z <= maxZ) {
2576 if (p !== ear.prev && p !== ear.next &&
2577 pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) &&
2578 area(p.prev, p, p.next) >= 0) return false;
2581 if (n !== ear.prev && n !== ear.next &&
2582 pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, n.x, n.y) &&
2583 area(n.prev, n, n.next) >= 0) return false;
2587 // look for remaining points in decreasing z-order
2588 while (p && p.z >= minZ) {
2589 if (p !== ear.prev && p !== ear.next &&
2590 pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) &&
2591 area(p.prev, p, p.next) >= 0) return false;
2595 // look for remaining points in increasing z-order
2596 while (n && n.z <= maxZ) {
2597 if (n !== ear.prev && n !== ear.next &&
2598 pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, n.x, n.y) &&
2599 area(n.prev, n, n.next) >= 0) return false;
2606 // go through all polygon nodes and cure small local self-intersections
2607 function cureLocalIntersections(start, triangles, dim) {
2613 if (!equals(a, b) && intersects(a, p, p.next, b) && locallyInside(a, b) && locallyInside(b, a)) {
2615 triangles.push(a.i / dim);
2616 triangles.push(p.i / dim);
2617 triangles.push(b.i / dim);
2619 // remove two nodes involved
2626 } while (p !== start);
2631 // try splitting polygon into two and triangulate them independently
2632 function splitEarcut(start, triangles, dim, minX, minY, invSize) {
2633 // look for a valid diagonal that divides the polygon into two
2636 var b = a.next.next;
2637 while (b !== a.prev) {
2638 if (a.i !== b.i && isValidDiagonal(a, b)) {
2639 // split the polygon in two by the diagonal
2640 var c = splitPolygon(a, b);
2642 // filter colinear points around the cuts
2643 a = filterPoints(a, a.next);
2644 c = filterPoints(c, c.next);
2646 // run earcut on each half
2647 earcutLinked(a, triangles, dim, minX, minY, invSize);
2648 earcutLinked(c, triangles, dim, minX, minY, invSize);
2654 } while (a !== start);
2657 // link every hole into the outer loop, producing a single-ring polygon without holes
2658 function eliminateHoles(data, holeIndices, outerNode, dim) {
2660 i, len, start, end, list;
2662 for (i = 0, len = holeIndices.length; i < len; i++) {
2663 start = holeIndices[i] * dim;
2664 end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;
2665 list = linkedList(data, start, end, dim, false);
2666 if (list === list.next) list.steiner = true;
2667 queue.push(getLeftmost(list));
2670 queue.sort(compareX);
2672 // process holes from left to right
2673 for (i = 0; i < queue.length; i++) {
2674 eliminateHole(queue[i], outerNode);
2675 outerNode = filterPoints(outerNode, outerNode.next);
2681 function compareX(a, b) {
2685 // find a bridge between vertices that connects hole with an outer ring and and link it
2686 function eliminateHole(hole, outerNode) {
2687 outerNode = findHoleBridge(hole, outerNode);
2689 var b = splitPolygon(outerNode, hole);
2690 filterPoints(b, b.next);
2694 // David Eberly's algorithm for finding a bridge between hole and outer polygon
2695 function findHoleBridge(hole, outerNode) {
2702 // find a segment intersected by a ray from the hole's leftmost point to the left;
2703 // segment's endpoint with lesser x will be potential connection point
2705 if (hy <= p.y && hy >= p.next.y && p.next.y !== p.y) {
2706 var x = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y);
2707 if (x <= hx && x > qx) {
2710 if (hy === p.y) return p;
2711 if (hy === p.next.y) return p.next;
2713 m = p.x < p.next.x ? p : p.next;
2717 } while (p !== outerNode);
2719 if (!m) return null;
2721 if (hx === qx) return m.prev; // hole touches outer segment; pick lower endpoint
2723 // look for points inside the triangle of hole point, segment intersection and endpoint;
2724 // if there are no points found, we have a valid connection;
2725 // otherwise choose the point of the minimum angle with the ray as connection point
2735 while (p !== stop) {
2736 if (hx >= p.x && p.x >= mx && hx !== p.x &&
2737 pointInTriangle(hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p.x, p.y)) {
2739 tan = Math.abs(hy - p.y) / (hx - p.x); // tangential
2741 if ((tan < tanMin || (tan === tanMin && p.x > m.x)) && locallyInside(p, hole)) {
2753 // interlink polygon nodes in z-order
2754 function indexCurve(start, minX, minY, invSize) {
2757 if (p.z === null) p.z = zOrder(p.x, p.y, minX, minY, invSize);
2761 } while (p !== start);
2763 p.prevZ.nextZ = null;
2769 // Simon Tatham's linked list merge sort algorithm
2770 // http://www.chiark.greenend.org.uk/~sgtatham/algorithms/listsort.html
2771 function sortLinked(list) {
2772 var i, p, q, e, tail, numMerges, pSize, qSize,
2785 for (i = 0; i < inSize; i++) {
2792 while (pSize > 0 || (qSize > 0 && q)) {
2794 if (pSize !== 0 && (qSize === 0 || !q || p.z <= q.z)) {
2804 if (tail) tail.nextZ = e;
2817 } while (numMerges > 1);
2822 // z-order of a point given coords and inverse of the longer side of data bbox
2823 function zOrder(x, y, minX, minY, invSize) {
2824 // coords are transformed into non-negative 15-bit integer range
2825 x = 32767 * (x - minX) * invSize;
2826 y = 32767 * (y - minY) * invSize;
2828 x = (x | (x << 8)) & 0x00FF00FF;
2829 x = (x | (x << 4)) & 0x0F0F0F0F;
2830 x = (x | (x << 2)) & 0x33333333;
2831 x = (x | (x << 1)) & 0x55555555;
2833 y = (y | (y << 8)) & 0x00FF00FF;
2834 y = (y | (y << 4)) & 0x0F0F0F0F;
2835 y = (y | (y << 2)) & 0x33333333;
2836 y = (y | (y << 1)) & 0x55555555;
2838 return x | (y << 1);
2841 // find the leftmost node of a polygon ring
2842 function getLeftmost(start) {
2846 if (p.x < leftmost.x) leftmost = p;
2848 } while (p !== start);
2853 // check if a point lies within a convex triangle
2854 function pointInTriangle(ax, ay, bx, by, cx, cy, px, py) {
2855 return (cx - px) * (ay - py) - (ax - px) * (cy - py) >= 0 &&
2856 (ax - px) * (by - py) - (bx - px) * (ay - py) >= 0 &&
2857 (bx - px) * (cy - py) - (cx - px) * (by - py) >= 0;
2860 // check if a diagonal between two polygon nodes is valid (lies in polygon interior)
2861 function isValidDiagonal(a, b) {
2862 return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) &&
2863 locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b);
2866 // signed area of a triangle
2867 function area(p, q, r) {
2868 return (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);
2871 // check if two points are equal
2872 function equals(p1, p2) {
2873 return p1.x === p2.x && p1.y === p2.y;
2876 // check if two segments intersect
2877 function intersects(p1, q1, p2, q2) {
2878 if ((equals(p1, q1) && equals(p2, q2)) ||
2879 (equals(p1, q2) && equals(p2, q1))) return true;
2880 return area(p1, q1, p2) > 0 !== area(p1, q1, q2) > 0 &&
2881 area(p2, q2, p1) > 0 !== area(p2, q2, q1) > 0;
2884 // check if a polygon diagonal intersects any polygon segments
2885 function intersectsPolygon(a, b) {
2888 if (p.i !== a.i && p.next.i !== a.i && p.i !== b.i && p.next.i !== b.i &&
2889 intersects(p, p.next, a, b)) return true;
2896 // check if a polygon diagonal is locally inside the polygon
2897 function locallyInside(a, b) {
2898 return area(a.prev, a, a.next) < 0 ?
2899 area(a, b, a.next) >= 0 && area(a, a.prev, b) >= 0 :
2900 area(a, b, a.prev) < 0 || area(a, a.next, b) < 0;
2903 // check if the middle point of a polygon diagonal is inside the polygon
2904 function middleInside(a, b) {
2907 px = (a.x + b.x) / 2,
2908 py = (a.y + b.y) / 2;
2910 if (((p.y > py) !== (p.next.y > py)) && p.next.y !== p.y &&
2911 (px < (p.next.x - p.x) * (py - p.y) / (p.next.y - p.y) + p.x))
2919 // link two polygon vertices with a bridge; if the vertices belong to the same ring, it splits polygon into two;
2920 // if one belongs to the outer ring and another to a hole, it merges it into a single ring
2921 function splitPolygon(a, b) {
2922 var a2 = new Node(a.i, a.x, a.y),
2923 b2 = new Node(b.i, b.x, b.y),
2942 // create a node and optionally link it with previous one (in a circular doubly linked list)
2943 function insertNode(i, x, y, last) {
2944 var p = new Node(i, x, y);
2959 function removeNode(p) {
2960 p.next.prev = p.prev;
2961 p.prev.next = p.next;
2963 if (p.prevZ) p.prevZ.nextZ = p.nextZ;
2964 if (p.nextZ) p.nextZ.prevZ = p.prevZ;
2967 function Node(i, x, y) {
2968 // vertice index in coordinates array
2971 // vertex coordinates
2975 // previous and next vertice nodes in a polygon ring
2979 // z-order curve value
2982 // previous and next nodes in z-order
2986 // indicates whether this is a steiner point
2987 this.steiner = false;
2990 // return a percentage difference between the polygon area and its triangulation area;
2991 // used to verify correctness of triangulation
2992 earcut.deviation = function (data, holeIndices, dim, triangles) {
2993 var hasHoles = holeIndices && holeIndices.length;
2994 var outerLen = hasHoles ? holeIndices[0] * dim : data.length;
2996 var polygonArea = Math.abs(signedArea(data, 0, outerLen, dim));
2998 for (var i = 0, len = holeIndices.length; i < len; i++) {
2999 var start = holeIndices[i] * dim;
3000 var end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;
3001 polygonArea -= Math.abs(signedArea(data, start, end, dim));
3005 var trianglesArea = 0;
3006 for (i = 0; i < triangles.length; i += 3) {
3007 var a = triangles[i] * dim;
3008 var b = triangles[i + 1] * dim;
3009 var c = triangles[i + 2] * dim;
3010 trianglesArea += Math.abs(
3011 (data[a] - data[c]) * (data[b + 1] - data[a + 1]) -
3012 (data[a] - data[b]) * (data[c + 1] - data[a + 1]));
3015 return polygonArea === 0 && trianglesArea === 0 ? 0 :
3016 Math.abs((trianglesArea - polygonArea) / polygonArea);
3019 function signedArea(data, start, end, dim) {
3021 for (var i = start, j = end - dim; i < end; i += dim) {
3022 sum += (data[j] - data[i]) * (data[i + 1] + data[j + 1]);
3028 // turn a polygon in a multi-dimensional array form (e.g. as in GeoJSON) into a form Earcut accepts
3029 earcut.flatten = function (data) {
3030 var dim = data[0][0].length,
3031 result = {vertices: [], holes: [], dimensions: dim},
3034 for (var i = 0; i < data.length; i++) {
3035 for (var j = 0; j < data[i].length; j++) {
3036 for (var d = 0; d < dim; d++) result.vertices.push(data[i][j][d]);
3039 holeIndex += data[i - 1].length;
3040 result.holes.push(holeIndex);
3046 },{}],9:[function(require,module,exports){
3049 var OneVersionConstraint = require('individual/one-version');
3051 var MY_VERSION = '7';
3052 OneVersionConstraint('ev-store', MY_VERSION);
3054 var hashKey = '__EV_STORE_KEY@' + MY_VERSION;
3056 module.exports = EvStore;
3058 function EvStore(elem) {
3059 var hash = elem[hashKey];
3062 hash = elem[hashKey] = {};
3068 },{"individual/one-version":19}],10:[function(require,module,exports){
3070 var request = require('./request');
3071 var buildQueryObject = require('./buildQueryObject');
3072 var isArray = Array.isArray;
3074 function simpleExtend(obj, obj2) {
3076 for (prop in obj2) {
3077 obj[prop] = obj2[prop];
3082 function XMLHttpSource(jsongUrl, config) {
3083 this._jsongUrl = jsongUrl;
3084 if (typeof config === 'number') {
3090 this._config = simpleExtend({
3096 XMLHttpSource.prototype = {
3097 // because javascript
3098 constructor: XMLHttpSource,
3100 * buildQueryObject helper
3102 buildQueryObject: buildQueryObject,
3105 * @inheritDoc DataSource#get
3107 get: function httpSourceGet(pathSet) {
3109 var queryObject = this.buildQueryObject(this._jsongUrl, method, {
3113 var config = simpleExtend(queryObject, this._config);
3114 // pass context for onBeforeRequest callback
3116 return request(method, config, context);
3120 * @inheritDoc DataSource#set
3122 set: function httpSourceSet(jsongEnv) {
3123 var method = 'POST';
3124 var queryObject = this.buildQueryObject(this._jsongUrl, method, {
3125 jsonGraph: jsongEnv,
3128 var config = simpleExtend(queryObject, this._config);
3129 config.headers["Content-Type"] = "application/x-www-form-urlencoded";
3131 // pass context for onBeforeRequest callback
3133 return request(method, config, context);
3138 * @inheritDoc DataSource#call
3140 call: function httpSourceCall(callPath, args, pathSuffix, paths) {
3141 // arguments defaults
3143 pathSuffix = pathSuffix || [];
3144 paths = paths || [];
3146 var method = 'POST';
3148 queryData.push('method=call');
3149 queryData.push('callPath=' + encodeURIComponent(JSON.stringify(callPath)));
3150 queryData.push('arguments=' + encodeURIComponent(JSON.stringify(args)));
3151 queryData.push('pathSuffixes=' + encodeURIComponent(JSON.stringify(pathSuffix)));
3152 queryData.push('paths=' + encodeURIComponent(JSON.stringify(paths)));
3154 var queryObject = this.buildQueryObject(this._jsongUrl, method, queryData.join('&'));
3155 var config = simpleExtend(queryObject, this._config);
3156 config.headers["Content-Type"] = "application/x-www-form-urlencoded";
3158 // pass context for onBeforeRequest callback
3160 return request(method, config, context);
3164 XMLHttpSource.XMLHttpSource = XMLHttpSource;
3165 XMLHttpSource['default'] = XMLHttpSource;
3167 module.exports = XMLHttpSource;
3169 },{"./buildQueryObject":11,"./request":14}],11:[function(require,module,exports){
3171 module.exports = function buildQueryObject(url, method, queryData) {
3174 var data = {url: url};
3175 var isQueryParamUrl = url.indexOf('?') !== -1;
3176 var startUrl = (isQueryParamUrl) ? '&' : '?';
3178 if (typeof queryData === 'string') {
3179 qData.push(queryData);
3182 keys = Object.keys(queryData);
3183 keys.forEach(function (k) {
3184 var value = (typeof queryData[k] === 'object') ? JSON.stringify(queryData[k]) : queryData[k];
3185 qData.push(k + '=' + encodeURIComponent(value));
3189 if (method === 'GET') {
3190 data.url += startUrl + qData.join('&');
3192 data.data = qData.join('&');
3198 },{}],12:[function(require,module,exports){
3201 // Get CORS support even for older IE
3202 module.exports = function getCORSRequest() {
3203 var xhr = new global.XMLHttpRequest();
3204 if ('withCredentials' in xhr) {
3206 } else if (!!global.XDomainRequest) {
3207 return new XDomainRequest();
3209 throw new Error('CORS is not supported by your browser');
3213 }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
3215 },{}],13:[function(require,module,exports){
3218 module.exports = function getXMLHttpRequest() {
3222 if (global.XMLHttpRequest) {
3223 return new global.XMLHttpRequest();
3226 progIds = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0'];
3227 for (i = 0; i < 3; i++) {
3229 progId = progIds[i];
3230 if (new global.ActiveXObject(progId)) {
3235 return new global.ActiveXObject(progId);
3237 throw new Error('XMLHttpRequest is not supported by your browser');
3242 }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
3244 },{}],14:[function(require,module,exports){
3246 var getXMLHttpRequest = require('./getXMLHttpRequest');
3247 var getCORSRequest = require('./getCORSRequest');
3248 var hasOwnProp = Object.prototype.hasOwnProperty;
3250 var noop = function() {};
3252 function Observable() {}
3254 Observable.create = function(subscribe) {
3255 var o = new Observable();
3257 o.subscribe = function(onNext, onError, onCompleted) {
3262 if (typeof onNext === 'function') {
3265 onError: (onError || noop),
3266 onCompleted: (onCompleted || noop)
3272 disposable = subscribe(observer);
3274 if (typeof disposable === 'function') {
3286 function request(method, options, context) {
3287 return Observable.create(function requestObserver(observer) {
3290 method: method || 'GET',
3294 responseType: 'json'
3303 for (prop in options) {
3304 if (hasOwnProp.call(options, prop)) {
3305 config[prop] = options[prop];
3309 // Add request with Headers
3310 if (!config.crossDomain && !config.headers['X-Requested-With']) {
3311 config.headers['X-Requested-With'] = 'XMLHttpRequest';
3314 // allow the user to mutate the config open
3315 if (context.onBeforeRequest != null) {
3316 context.onBeforeRequest(config);
3321 xhr = config.crossDomain ? getCORSRequest() : getXMLHttpRequest();
3323 observer.onError(err);
3326 // Takes the url and opens the connection
3328 xhr.open(config.method, config.url, config.async, config.user, config.password);
3330 xhr.open(config.method, config.url, config.async);
3333 // Sets timeout information
3334 xhr.timeout = config.timeout;
3336 // Anything but explicit false results in true.
3337 xhr.withCredentials = config.withCredentials !== false;
3339 // Fills the request headers
3340 headers = config.headers;
3341 for (header in headers) {
3342 if (hasOwnProp.call(headers, header)) {
3343 xhr.setRequestHeader(header, headers[header]);
3347 if (config.responseType) {
3349 xhr.responseType = config.responseType;
3351 // WebKit added support for the json responseType value on 09/03/2013
3352 // https://bugs.webkit.org/show_bug.cgi?id=73648. Versions of Safari prior to 7 are
3353 // known to throw when setting the value "json" as the response type. Other older
3354 // browsers implementing the responseType
3356 // The json response type can be ignored if not supported, because JSON payloads are
3357 // parsed on the client-side regardless.
3358 if (config.responseType !== 'json') {
3364 xhr.onreadystatechange = function onreadystatechange(e) {
3366 if (xhr.readyState === 4) {
3369 onXhrLoad(observer, xhr, e);
3375 xhr.ontimeout = function ontimeout(e) {
3378 onXhrError(observer, xhr, 'timeout error', e);
3383 xhr.send(config.data);
3386 observer.onError(e);
3389 return function dispose() {
3390 // Doesn't work in IE9
3391 if (!isDone && xhr.readyState !== 4) {
3400 * General handling of ultimate failure (after appropriate retries)
3402 function _handleXhrError(observer, textStatus, errorThrown) {
3403 // IE9: cross-domain request may be considered errors
3405 errorThrown = new Error(textStatus);
3408 observer.onError(errorThrown);
3411 function onXhrLoad(observer, xhr, e) {
3416 // If there's no observer, the request has been (or is being) cancelled.
3417 if (xhr && observer) {
3418 responseType = xhr.responseType;
3419 // responseText is the old-school way of retrieving response (supported by IE8 & 9)
3420 // response/responseType properties were introduced in XHR Level2 spec (supported by IE10)
3421 responseData = ('response' in xhr) ? xhr.response : xhr.responseText;
3423 // normalize IE9 bug (http://bugs.jquery.com/ticket/1450)
3424 var status = (xhr.status === 1223) ? 204 : xhr.status;
3426 if (status >= 200 && status <= 399) {
3428 if (responseType !== 'json') {
3429 responseData = JSON.parse(responseData || '');
3431 if (typeof responseData === 'string') {
3432 responseData = JSON.parse(responseData || '');
3435 _handleXhrError(observer, 'invalid json', e);
3437 observer.onNext(responseData);
3438 observer.onCompleted();
3441 } else if (status === 401 || status === 403 || status === 407) {
3443 return _handleXhrError(observer, responseData);
3445 } else if (status === 410) {
3447 return _handleXhrError(observer, responseData);
3449 } else if (status === 408 || status === 504) {
3451 return _handleXhrError(observer, responseData);
3455 return _handleXhrError(observer, responseData || ('Response code ' + status));
3461 function onXhrError(observer, xhr, status, e) {
3462 _handleXhrError(observer, status || xhr.statusText || 'request error', e);
3465 module.exports = request;
3467 },{"./getCORSRequest":12,"./getXMLHttpRequest":13}],15:[function(require,module,exports){
3469 !function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.falcor=t()}}(function(){var t;return function e(t,n,r){function o(s,u){if(!n[s]){if(!t[s]){var a="function"==typeof require&&require;if(!u&&a)return a(s,!0);if(i)return i(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var p=n[s]={exports:{}};t[s][0].call(p.exports,function(e){var n=t[s][1][e];return o(n?n:e)},p,p.exports,e,t,n,r)}return n[s].exports}for(var i="function"==typeof require&&require,s=0;s<r.length;s++)o(r[s]);return o}({1:[function(t,e,n){var r=t(32),o=t(130);r.atom=o.atom,r.ref=o.ref,r.error=o.error,r.pathValue=o.pathValue,r.HttpDataSource=t(125),e.exports=r},{125:125,130:130,32:32}],2:[function(t,e,n){function r(t){var e=t||{};this._root=e._root||new o(e),this._path=e.path||e._path||[],this._scheduler=e.scheduler||e._scheduler||new l,this._source=e.source||e._source,this._request=e.request||e._request||new s(this,this._scheduler),this._ID=N++,"number"==typeof e.maxSize?this._maxSize=e.maxSize:this._maxSize=e._maxSize||r.prototype._maxSize,"number"==typeof e.collectRatio?this._collectRatio=e.collectRatio:this._collectRatio=e._collectRatio||r.prototype._collectRatio,(e.boxed||e.hasOwnProperty("_boxed"))&&(this._boxed=e.boxed||e._boxed),(e.materialized||e.hasOwnProperty("_materialized"))&&(this._materialized=e.materialized||e._materialized),"boolean"==typeof e.treatErrorsAsValues?this._treatErrorsAsValues=e.treatErrorsAsValues:e.hasOwnProperty("_treatErrorsAsValues")&&(this._treatErrorsAsValues=e._treatErrorsAsValues),e.cache&&this.setCache(e.cache)}var o=t(4),i=t(3),s=t(55),u=t(64),a=t(65),c=t(61),p=t(63),h=t(73),f=t(75),l=t(74),d=t(81),v=t(84),y=t(49),b=t(134),m=t(88),g=t(100),w=t(96),x=t(102),_=t(98),S=t(99),E=t(77),C=t(76),A=t(130),N=0,k=t(116),O=function(){},P=t(14),j=t(19),D={pathValue:!0,pathSyntax:!0,json:!0,jsonGraph:!0},q=t(72);e.exports=r,r.ref=A.ref,r.atom=A.atom,r.error=A.error,r.pathValue=A.pathValue,r.prototype.constructor=r,r.prototype._materialized=!1,r.prototype._boxed=!1,r.prototype._progressive=!1,r.prototype._treatErrorsAsValues=!1,r.prototype._maxSize=Math.pow(2,53)-1,r.prototype._collectRatio=.75,r.prototype.get=t(71),r.prototype._getWithPaths=t(70),r.prototype.set=function(){var t=k(arguments,D,"set");return t!==!0?new u(function(e){e.onError(t)}):this._set.apply(this,arguments)},r.prototype.preload=function(){var t=k(arguments,q,"preload");if(t!==!0)return new u(function(e){e.onError(t)});var e=Array.prototype.slice.call(arguments),n=this;return new u(function(t){return n.get.apply(n,e).subscribe(function(){},function(e){t.onError(e)},function(){t.onCompleted()})})},r.prototype._set=function(){var t,e=-1,n=arguments.length,r=arguments[n-1];for(w(r)?n-=1:r=void 0,t=new Array(n);++e<n;)t[e]=arguments[e];return a.create(this,t,r)},r.prototype.call=function(){var t,e=-1,n=arguments.length;for(t=new Array(n);++e<n;){var r=arguments[e];t[e]=r;var o=typeof r;if(e>1&&!Array.isArray(r)||0===e&&!Array.isArray(r)&&"string"!==o||1===e&&!Array.isArray(r)&&!x(r))return new u(function(t){t.onError(new Error("Invalid argument"))})}return c.create(this,t)},r.prototype.invalidate=function(){var t,e=-1,n=arguments.length,r=arguments[n-1];for(t=new Array(n);++e<n;)if(t[e]=b.fromPath(arguments[e]),"object"!=typeof t[e])throw new Error("Invalid argument");p.create(this,t,r).subscribe(O,function(t){throw t})},r.prototype.deref=t(5),r.prototype.getValue=t(16),r.prototype.setValue=t(79),r.prototype._getValueSync=t(24),r.prototype._setValueSync=t(80),r.prototype._derefSync=t(6),r.prototype.setCache=function(t){var e=this._root.cache;if(t!==e){var n=this._root,r=this._path;this._path=[],this._root.cache={},"undefined"!=typeof e&&y(n,n.expired,m(e),0),S(t)?C(this,[t]):_(t)?E(this,[t]):g(t)&&E(this,[{json:t}]),this._path=r}else"undefined"==typeof e&&(this._root.cache={});return this},r.prototype.getCache=function(){var t=v(arguments);if(0===t.length)return P(this._root.cache);var e=[{}],n=this._path;return j.getWithPathsAsJSONGraph(this,t,e),this._path=n,e[0].jsonGraph},r.prototype.getVersion=function(t){var e=t&&b.fromPath(t)||[];if(Array.isArray(e)===!1)throw new Error("Model#getVersion must be called with an Array path.");return this._path.length&&(e=this._path.concat(e)),this._getVersion(this,e)},r.prototype._syncCheck=function(t){if(Boolean(this._source)&&this._root.syncRefCount<=0&&this._root.unsafeMode===!1)throw new Error("Model#"+t+" may only be called within the context of a request selector.");return!0},r.prototype._clone=function(t){var e=new r(this);for(var n in t){var o=t[n];"delete"===o?delete e[n]:e[n]=o}return e.setCache=void 0,e},r.prototype.batch=function(t){var e=t;"number"==typeof e?e=new f(Math.round(Math.abs(e))):e&&e.schedule||(e=new h);var n=this._clone();return n._request=new s(n,e),n},r.prototype.unbatch=function(){var t=this._clone();return t._request=new s(t,new l),t},r.prototype.treatErrorsAsValues=function(){return this._clone({_treatErrorsAsValues:!0})},r.prototype.asDataSource=function(){return new i(this)},r.prototype._materialize=function(){return this._clone({_materialized:!0})},r.prototype._dematerialize=function(){return this._clone({_materialized:"delete"})},r.prototype.boxValues=function(){return this._clone({_boxed:!0})},r.prototype.unboxValues=function(){return this._clone({_boxed:"delete"})},r.prototype.withoutDataSource=function(){return this._clone({_source:"delete"})},r.prototype.toJSON=function(){return{$type:"ref",value:this._path}},r.prototype.getPath=function(){return d(this._path)},r.prototype._getBoundValue=t(13),r.prototype._getVersion=t(18),r.prototype._getValueSync=t(17),r.prototype._getPathValuesAsPathMap=j.getWithPathsAsPathMap,r.prototype._getPathValuesAsJSONG=j.getWithPathsAsJSONGraph,r.prototype._setPathValuesAsJSON=t(78),r.prototype._setPathValuesAsJSONG=t(78),r.prototype._setPathValuesAsPathMap=t(78),r.prototype._setPathValuesAsValues=t(78),r.prototype._setPathMapsAsJSON=t(77),r.prototype._setPathMapsAsJSONG=t(77),r.prototype._setPathMapsAsPathMap=t(77),r.prototype._setPathMapsAsValues=t(77),r.prototype._setJSONGsAsJSON=t(76),r.prototype._setJSONGsAsJSONG=t(76),r.prototype._setJSONGsAsPathMap=t(76),r.prototype._setJSONGsAsValues=t(76),r.prototype._setCache=t(77),r.prototype._invalidatePathValuesAsJSON=t(48),r.prototype._invalidatePathMapsAsJSON=t(47)},{100:100,102:102,116:116,13:13,130:130,134:134,14:14,16:16,17:17,18:18,19:19,24:24,3:3,4:4,47:47,48:48,49:49,5:5,55:55,6:6,61:61,63:63,64:64,65:65,70:70,71:71,72:72,73:73,74:74,75:75,76:76,77:77,78:78,79:79,80:80,81:81,84:84,88:88,96:96,98:98,99:99}],3:[function(t,e,n){function r(t){this._model=t._materialize().treatErrorsAsValues()}r.prototype.get=function(t){return this._model.get.apply(this._model,t)._toJSONG()},r.prototype.set=function(t){return this._model.set(t)._toJSONG()},r.prototype.call=function(t,e,n,r){var o=[t,e,n].concat(r);return this._model.call.apply(this._model,o)._toJSONG()},e.exports=r},{}],4:[function(t,e,n){function r(t){var e=t||{};this.syncRefCount=0,this.expired=e.expired||[],this.unsafeMode=e.unsafeMode||!1,this.collectionScheduler=e.collectionScheduler||new s,this.cache={},o(e.comparator)&&(this.comparator=e.comparator),o(e.errorSelector)&&(this.errorSelector=e.errorSelector),o(e.onChange)&&(this.onChange=e.onChange)}var o=t(96),i=t(91),s=t(74);r.prototype.errorSelector=function(t,e){return e},r.prototype.comparator=function(t,e){return i(t,"value")&&i(e,"value")?t.value===e.value&&t.$type===e.$type&&t.$expires===e.$expires:t===e},e.exports=r},{74:74,91:91,96:96}],5:[function(t,e,n){function r(t,e){var n,r=!1;try{++t._root.syncRefCount,n=t._derefSync(e)}catch(i){n=i,r=!0}finally{--t._root.syncRefCount}return r?o.Observable["throw"](n):o.Observable["return"](n)}var o=t(159),i=t(134);e.exports=function(t){for(var e=this,n=-1,s=arguments.length-1,u=new Array(s),a=i.fromPath(t);++n<s;)u[n]=i.fromPath(arguments[n+1]);if(0===s)throw new Error("Model#deref requires at least one value path.");return o.Observable.defer(function(){return r(e,a)}).flatMap(function(t){if(Boolean(t)){if(s>0){var n=o.Observable.of(t);return t.get.apply(t,u)["catch"](o.Observable.empty()).concat(n).last().flatMap(function(){return r(e,a)}).filter(function(t){return t})}return o.Observable["return"](t)}if(s>0){var i=u.map(function(t){return a.concat(t)});return e.get.apply(e,i).concat(o.Observable.defer(function(){return r(e,a)})).last().filter(function(t){return t})}return o.Observable.empty()})}},{134:134,159:159}],6:[function(t,e,n){var r=t(134),o=t(13),i=t(8),s=t(118);e.exports=function(t){var e=r.fromPath(t);if(!Array.isArray(e))throw new Error("Model#derefSync must be called with an Array path.");var n=o(this,this._path.concat(e),!1),u=n.path,a=n.value,c=n.found;if(c&&void 0!==a&&(a.$type!==s||void 0!==a.value)){if(a.$type)throw new i;return this._clone({_path:u})}}},{118:118,13:13,134:134,8:8}],7:[function(t,e,n){function r(){this.message=r.message,this.stack=(new Error).stack}r.prototype=new Error,r.prototype.name="BoundJSONGraphModelError",r.message="It is not legal to use the JSON Graph format from a bound Model. JSON Graph format can only be used from a root model.",e.exports=r},{}],8:[function(t,e,n){function r(t,e){this.message=i,this.stack=(new Error).stack,this.boundPath=t,this.shortedPath=e}var o="InvalidModelError",i="The boundPath of the model is not valid since a value or error was found before the path end.";r.prototype=new Error,r.prototype.name=o,r.message=i,e.exports=r},{}],9:[function(t,e,n){function r(t){this.message="An exception was thrown when making a request.",this.stack=(new Error).stack,this.innerError=t}var o="InvalidSourceError";r.prototype=new Error,r.prototype.name=o,r.is=function(t){return t&&t.name===o},e.exports=r},{}],10:[function(t,e,n){function r(){this.message="The allowed number of retries have been exceeded.",this.stack=(new Error).stack}var o="MaxRetryExceededError";r.prototype=new Error,r.prototype.name=o,r.is=function(t){return t&&t.name===o},e.exports=r},{}],11:[function(t,e,n){function r(t,e,n,r,o,h,f){for(var l,d,v=n,y=o,b=r,m=0;;){if(0===m&&b[c]?(m=y.length,d=b[c]):(l=y[m++],d=v[l]),d){var g=d.$type,w=g&&d.value||d;if(m<y.length){if(g){v=d;break}v=d;continue}if(v=d,g&&u(d))break;if(b[c]||i(b,d),g===a){f?s(t,d,h,null,null,null,y,y.length,f):p(t,d),m=0,y=w,b=d,v=e;continue}break}v=void 0;break}if(m<y.length&&void 0!==v){for(var x=[],_=0;m>_;_++)x[_]=y[_];y=x}return[v,y]}var o=t(26),i=o.create,s=t(22),u=t(27),a=t(120),c=t(33),p=t(29).promote;e.exports=r},{120:120,22:22,26:26,27:27,29:29,33:33}],12:[function(t,e,n){var r=t(15),o=t(8),i=t(7);e.exports=function(t,e){return function(n,s,u){var a,c,p,h=u[0],f={values:u,optimizedPaths:[]},l=n._root.cache,d=n._path,v=l,y=d.length,b=[];if(y){if(e)return{criticalError:new i};if(v=r(n,d),v.$type)return{criticalError:new o(d,d)};for(a=[],c=0;y>c;++c)a[c]=d[c]}else a=[],y=0;for(c=0,p=s.length;p>c;c++)t(n,l,v,s[c],0,h,f,b,a,y,e);return f}}},{15:15,7:7,8:8}],13:[function(t,e,n){var r=t(17),o=t(8);e.exports=function(t,e,n){var i,s,u,a,c,p=e,h=e;for(i=t._boxed,n=t._materialized,s=t._treatErrorsAsValues,t._boxed=!0,t._materialized=void 0===n||n,t._treatErrorsAsValues=!0,u=r(t,p.concat(null),!0),t._boxed=i,t._materialized=n,t._treatErrorsAsValues=s,p=u.optimizedPath,a=u.shorted,c=u.found,u=u.value;p.length&&null===p[p.length-1];)p.pop();if(c&&a)throw new o(h,p);return{path:p,value:u,shorted:a,found:c}}},{17:17,8:8}],14:[function(t,e,n){function r(t){var e,n,r,o={},i=Object.keys(t);for(n=0,r=i.length;r>n;n++)e=i[n],s(e)||(o[e]=t[e]);return o}function o(t,e,n){Object.keys(t).filter(function(e){return!s(e)&&t[e]}).forEach(function(n){var s=t[n],u=e[n];if(u||(u=e[n]={}),s.$type){var a,c=s.value&&"object"==typeof s.value,p=!t[i];return a=c||p?r(s):s.value,void(e[n]=a)}o(s,u,n)})}var i=t(37),s=t(97);e.exports=function(t){var e={};return o(t,e),e}},{37:37,97:97}],15:[function(t,e,n){e.exports=function(t,e){for(var n=t._root.cache,r=-1,o=e.length;++r<o&&n&&!n.$type;)n=n[e[r]];return n}},{}],16:[function(t,e,n){var r=t(64),o=t(134);e.exports=function(t){for(var e=o.fromPath(t),n=0,i=e.length;++n<i;)if("object"==typeof e[n])return new r(function(t){t.onError(new Error("Paths must be simple paths"))});var s=this;return new r(function(t){return s.get(e).subscribe(function(n){for(var r=n.json,o=-1,i=e.length;r&&++o<i;)r=r[e[o]];t.onNext(r)},function(e){t.onError(e)},function(){t.onCompleted()})})}},{134:134,64:64}],17:[function(t,e,n){var r=t(11),o=t(25),i=t(27),s=t(29).promote,u=t(120),a=t(118),c=t(119);e.exports=function(t,e,n){for(var p,h,f,l,d,v=t._root.cache,y=e.length,b=[],m=!1,g=!1,w=0,x=v,_=v,S=v,E=!0,C=!1;x&&y>w;){if(p=e[w++],null!==p&&(x=_[p],b[b.length]=p),!x){S=void 0,m=!0,E=!1;break}if(f=x.$type,f===a&&void 0===x.value){S=void 0,E=!1,m=y>w;break}if(y>w){if(f===u){if(i(x)){C=!0,S=void 0,E=!1;break}if(l=r(t,v,v,x,x.value),d=l[0],!d){S=void 0,x=void 0,E=!1;break}f=d.$type,x=d,b=l[1].slice(0)}if(f)break}else S=x;_=x}if(y>w&&!C){for(h=w;y>h;++h)if(null!==e[w]){g=!0;break}for(g?(m=!0,S=void 0):S=x,h=w;y>h;++h)null!==e[h]&&(b[b.length]=e[h])}if(S&&f&&(i(S)?S=void 0:s(t,S)),S&&f===c&&!t._treatErrorsAsValues)throw{path:w===y?e:e.slice(0,w),value:S.value};return S&&t._boxed?S=Boolean(f)&&!n?o(S):S:!S&&t._materialized?S={$type:a}:S&&(S=S.value),{value:S,shorted:m,optimizedPath:b,found:E}}},{11:11,118:118,119:119,120:120,25:25,27:27,29:29}],18:[function(t,e,n){var r=t(46);e.exports=function(t,e){var n=t._getValueSync({_boxed:!0,_root:t._root,_treatErrorsAsValues:t._treatErrorsAsValues},e,!0).value,o=n&&n[r];return null==o?-1:o}},{46:46}],19:[function(t,e,n){var r=t(12),o=t(31),i=r(o,!1),s=r(o,!0);e.exports={getValueSync:t(17),getBoundValue:t(13),getWithPathsAsPathMap:i,getWithPathsAsJSONGraph:s}},{12:12,13:13,17:17,31:31}],20:[function(t,e,n){var r=t(29),o=t(25),i=r.promote;e.exports=function(t,e,n,r,s){var u=e.value;s.errors||(s.errors=[]),t._boxed&&(u=o(e)),s.errors.push({path:r.slice(0,n+1),value:u}),i(t,e)}},{25:25,29:29}],21:[function(t,e,n){function r(t,e,n,r,o,i,s){s.requestedMissingPaths.push(r.slice(0,n).concat(e)),s.optimizedMissingPaths.push(o.slice(0,i).concat(e))}var o=t(30),i=o.fastCopy;e.exports=function(t,e,n,o,s,u,a){var c;o.requestedMissingPaths||(o.requestedMissingPaths=[],o.optimizedMissingPaths=[]),c=n<e.length?i(e,n):[],r(t,c,n,s,u,a,o)}},{30:30}],22:[function(t,e,n){var r=t(29),o=t(25),i=r.promote,s=t(120),u=t(118),a=t(119),c=t(37);e.exports=function(t,e,n,r,p,h,f,l,d,v){if(n){var y,b,m,g,w,x,_,S,E=!1;if(e&&i(t,e),e&&void 0!==e.value||(E=t._materialized),E)S={$type:u};else if(t._boxed)S=o(e);else if(e.$type===s||e.$type===a)S=d?o(e):e.value;else if(d){var C=e.value&&"object"==typeof e.value,A=!e[c];S=C||A?o(e):e.value}else S=e.value;if(p&&(p.hasValue=!0),d){for(w=n.jsonGraph,w||(w=n.jsonGraph={},n.paths=[]),y=0,b=l-1;b>y;y++)g=f[y],w[g]||(w[g]={}),w=w[g];g=f[y],w[g]=E?{$type:u}:S,h&&n.paths.push(h.slice(0,r))}else if(0===r)n.json=S;else{for(w=n.json,w||(w=n.json={}),y=0;r-1>y;y++)m=h[y],w[m]||(w[m]={}),x=w,_=m,w=w[m];m=h[y],null!==m?w[m]=S:x[_]=S}}}},{118:118,119:119,120:120,25:25,29:29,37:37}],23:[function(t,e,n){var r=t(27),o=t(26),i=t(29),s=o.remove,u=i.splice,a=t(119),c=t(20),p=t(22),h=t(21),f=t(28),l=t(35);e.exports=function(t,e,n,o,i,d,v,y,b,m,g){var w=e&&e.$type,x=e&&void 0===e.value;return e&&w?void(r(e)?(e[l]||(u(t,e),s(e)),h(t,n,o,d,v,y,b)):w===a?(g&&(v[o]=null),m||t._treatErrorsAsValues?p(t,e,i,o,d,v,y,b,m,g):c(t,e,o,v,d)):(g&&(v[o]=null),(!x||x&&t._materialized)&&p(t,e,i,o,d,v,y,b,m,g))):void(f(t)?p(t,e,i,o,d,v,y,b,m,g):h(t,n,o,d,v,y,b))}},{119:119,20:20,21:21,22:22,26:26,27:27,28:28,29:29,35:35}],24:[function(t,e,n){var r=t(134);e.exports=function(t){var e=r.fromPath(t);if(Array.isArray(e)===!1)throw new Error("Model#getValueSync must be called with an Array path.");return this._path.length&&(e=this._path.concat(e)),this._syncCheck("getValueSync")&&this._getValueSync(this,e).value}},{134:134}],25:[function(t,e,n){var r=t(40);e.exports=function(t){var e,n,o,i=Object.keys(t);for(e={},n=0,o=i.length;o>n;n++){var s=i[n];s[0]!==r&&(e[s]=t[s])}return e}},{40:40}],26:[function(t,e,n){function r(t,e){var n=e[a]||0;e[i+n]=t,e[a]=n+1,t[u]=n,t[s]=e}function o(t){var e=t[s];if(e){for(var n=t[u],r=e[a];r>n;)e[i+n]=e[i+n+1],++n;e[a]=r-1,t[s]=void 0,t[u]=void 0}}var i=t(43),s=t(33),u=t(42),a=t(44);e.exports={create:r,remove:o}},{33:33,42:42,43:43,44:44}],27:[function(t,e,n){var r=t(106);e.exports=function(t){var e=void 0===t.$expires&&-1||t.$expires;return-1!==e&&1!==e&&(0===e||e<r())}},{106:106}],28:[function(t,e,n){e.exports=function(t){return t._materialized&&!t._source}},{}],29:[function(t,e,n){function r(t,e){var n=t._root,r=n[i];if(r!==e){var o=e[a],s=e[u];s&&(s[a]=o),o&&(o[u]=s),e[a]=void 0,n[i]=e,e[u]=r,r[a]=e}}function o(t,e){var n=t._root,r=e[a],o=e[u];o&&(o[a]=r),r&&(r[u]=o),e[a]=void 0,e===n[i]&&(n[i]=void 0),e===n[s]&&(n[s]=void 0),e[c]=!0,n.expired.push(e)}var i=t(34),s=t(45),u=t(38),a=t(41),c=t(35);e.exports={promote:r,splice:o}},{34:34,35:35,38:38,41:41,45:45}],30:[function(t,e,n){function r(t,e){var n,r,o,i=[];for(r=0,o=e||0,n=t.length;n>o;r++,o++)i[r]=t[o];return i}function o(t,e){var n,r,o,i=[];for(n=0,r=t.length;r>n;n++)i[n]=t[n];for(o=0,r=e.length;r>o;o++)null!==e[o]&&(i[n++]=e[o]);return i}function i(t,e){var n,r,o,i=[];for(n=0,r=t.length;r>n;n++)i[n]=t[n];for(o=0,r=e.length;r>o;o++)i[n++]=e[o];return i}e.exports={fastCat:i,fastCatSkipNulls:o,fastCopy:r}},{}],31:[function(t,e,n){var r=t(11),o=t(23),i=t(27),s=t(143).iterateKeySet,u=t(120),a=t(29).promote;e.exports=function c(t,e,n,p,h,f,l,d,v,y,b,m){var g=m,w=v;if(!n||n&&n.$type||h===p.length)return void o(t,n,p,h,f,l,d,w,y,b,g);var x,_;x=p[h];var S="object"==typeof x,E=h+1,C=!1,A=x;if(S&&(C={},A=s(x,C)),void 0!==A||!C.done){var N=y+1;do{g=!1;var k;null===A?k=n:(k=n[A],w[y]=A,d[h]=A);var O=w,P=N;if(k){var j=k.$type,D=j&&k.value||k;if(E<p.length&&j&&j===u&&!i(k)){b&&o(t,k,p,E,f,l,null,w,P,b,g),a(t,k);var q=r(t,e,e,k,D,f,b);g=!0,k=q[0];var R=q[1];for(O=[],P=R.length,_=0;P>_;++_)O[_]=R[_]}}c(t,e,k,p,E,f,l,d,O,P,b,g),C&&!C.done&&(A=s(x,C))}while(C&&!C.done)}}},{11:11,120:120,143:143,23:23,27:27,29:29}],32:[function(t,e,n){"use strict";function r(t){return new r.Model(t)}"function"==typeof Promise?r.Promise=Promise:r.Promise=t(151),e.exports=r,r.Model=t(2)},{151:151,2:2}],33:[function(t,e,n){e.exports=t(40)+"context"},{40:40}],34:[function(t,e,n){e.exports=t(40)+"head"},{40:40}],35:[function(t,e,n){e.exports=t(40)+"invalidated"},{40:40}],36:[function(t,e,n){e.exports=t(40)+"key"},{40:40}],37:[function(t,e,n){e.exports="$modelCreated"},{}],38:[function(t,e,n){e.exports=t(40)+"next"},{40:40}],39:[function(t,e,n){e.exports=t(40)+"parent"},{40:40}],40:[function(t,e,n){e.exports=String.fromCharCode(30)},{}],41:[function(t,e,n){e.exports=t(40)+"prev"},{40:40}],42:[function(t,e,n){e.exports=t(40)+"ref-index"},{40:40}],43:[function(t,e,n){e.exports=t(40)+"ref"},{40:40}],44:[function(t,e,n){e.exports=t(40)+"refs-length"},{40:40}],45:[function(t,e,n){e.exports=t(40)+"tail"},{40:40}],46:[function(t,e,n){e.exports=t(40)+"version"},{40:40}],47:[function(t,e,n){function r(t,e,n,o,s,u,c,p,h,f){if(!_(t)&&!t.$type)for(var l in t)if(l[0]!==a&&"$"!==l[0]&&m(t,l)){var d=t[l],v=g(d)&&!d.$type,y=i(n,o,s,l,d,v,!1,u,c,p,h,f),w=y[0],x=y[1];w&&(v?r(d,e+1,n,x,w,u,c,p,h,f):A(w,x,l,p)&&C(x,b(w),p,u))}}function o(t,e,n,r,o,s,a,h){if(w(n))return S(n,o,s),[void 0,e];y(s,n);var d=n,v=n.value,b=e;if(n=n[p],null!=n)b=n[c]||e;else{var m=0,g=v.length-1;b=n=e;do{var x=v[m],E=g>m,C=i(e,b,n,x,t,E,!0,r,o,s,a,h);if(n=C[0],_(n))return C;b=C[1]}while(m++<g);if(d[p]!==n){var A=n[l]||0;n[l]=A+1,n[u+A]=d,d[p]=n,d[f]=A}}return[n,b]}function i(t,e,n,r,i,u,a,c,p,h,f,l){for(var v=n.$type;v===d;){var y=o(i,t,n,c,p,h,f,l);if(n=y[0],_(n))return y;e=y[1],v=n&&n.$type}if(void 0!==v)return[n,e];if(null==r){if(u)throw new Error("`null` is not allowed in branch key positions.");n&&(r=n[s])}else e=n,n=e[r];return[n,e]}var s=t(36),u=t(43),a=t(40),c=t(39),p=t(33),h=t(46),f=t(42),l=t(44),d=t(120),v=t(13),y=t(50),b=t(88),m=t(91),g=t(100),w=t(95),x=t(96),_=t(102),S=t(86),E=t(92),C=t(115),A=t(109);e.exports=function(t,e){for(var n=t._root,o=n,i=n.expired,s=E(),u=n._comparator,a=n._errorSelector,p=t._path,f=n.cache,l=p.length?v(t,p).value:f,d=l[c]||f,y=f[h],b=-1,m=e.length;++b<m;){var g=e[b];r(g.json,0,f,d,l,s,i,o,u,a)}var w=f[h],_=n.onChange;x(_)&&y!==w&&_()}},{100:100,102:102,109:109,115:115,120:120,13:13,33:33,36:36,39:39,40:40,42:42,43:43,44:44,46:46,50:50,86:86,88:88,91:91,92:92,95:95,96:96}],48:[function(t,e,n){function r(t,e,n,o,s,u,a,c){var p={},h=e<t.length-1,f=t[e],l=x(f,p);do{var d=i(n,o,s,l,h,!1,u,a,c),v=d[0],b=d[1];v&&(h?r(t,e+1,n,b,v,u,a,c):E(v,b,l,c)&&S(b,y(v),c,u)),l=x(f,p)}while(!p.done)}function o(t,e,n,r,o){if(b(e))return w(e,r,o),[void 0,t];v(o,e);var s=e,p=e.value,l=t;if(e=e[c],null!=e)l=e[a]||t;else{var d=0,y=p.length-1;l=e=t;do{var m=p[d],x=y>d,_=i(t,l,e,m,x,!0,n,r,o);if(e=_[0],g(e))return _;l=_[1]}while(d++<y);if(s[c]!==e){var S=e[f]||0;e[f]=S+1,e[u+S]=s,s[c]=e,s[h]=S}}return[e,l]}function i(t,e,n,r,i,u,a,c,p){for(var h=n.$type;h===l;){var f=o(t,n,a,c,p);if(n=f[0],g(n))return f;e=f[1],h=n.$type}if(void 0!==h)return[n,e];if(null==r){if(i)throw new Error("`null` is not allowed in branch key positions.");n&&(r=n[s])}else e=n,n=e[r];return[n,e]}var s=t(36),u=t(43),a=t(39),c=t(33),p=t(46),h=t(42),f=t(44),l=t(120),d=t(13),v=t(50),y=t(88),b=t(95),m=t(96),g=t(102),w=t(86),x=t(143).iterateKeySet,_=t(92),S=t(115),E=t(109);e.exports=function(t,e){for(var n=t._root,o=n,i=n.expired,s=_(),u=t._path,c=n.cache,h=u.length?d(t,u).value:c,f=h[a]||c,l=c[p],v=-1,y=e.length;++v<y;){var b=e[v];r(b,0,c,f,h,s,i,o)}var g=c[p],w=n.onChange;m(w)&&l!==g&&w()}},{102:102,109:109,115:115,120:120,13:13,143:143,33:33,36:36,39:39,42:42,43:43,44:44,46:46,50:50,86:86,88:88,92:92,95:95,96:96}],49:[function(t,e,n){var r=t(36),o=t(39),i=t(34),s=t(45),u=t(38),a=t(41),c=t(108),p=t(115);e.exports=function(t,e,n,h,f,l){var d=n,v=f;"number"!=typeof v&&(v=.75);var y,b,m,g="number"==typeof l,w=h*v;for(b=e.pop();b;)m=b.$size||0,d-=m,g===!0?p(b,m,t,l):(y=b[o])&&c(b,y,b[r],t),b=e.pop();if(d>=h){var x=t[s];for(b=x;d>=w&&b;)x=x[a],m=b.$size||0,d-=m,g===!0&&p(b,m,t,l),b=x;t[s]=t[a]=b,null==b?t[i]=t[u]=void 0:b[u]=void 0}}},{108:108,115:115,34:34,36:36,38:38,39:39,41:41,45:45}],50:[function(t,e,n){var r=t(121),o=t(34),i=t(45),s=t(38),u=t(41),a=t(100);e.exports=function(t,e){if(a(e)&&e.$expires!==r){var n=t[o],c=t[i],p=e[s],h=e[u];e!==n&&(null!=p&&"object"==typeof p&&(p[u]=h),null!=h&&"object"==typeof h&&(h[s]=p),p=n,null!=n&&"object"==typeof n&&(n[u]=e),t[o]=t[s]=n=e,n[s]=p,n[u]=void 0),null!=c&&e!==c||(t[i]=t[u]=c=h||e)}return e}},{100:100,121:121,34:34,38:38,41:41,45:45}],51:[function(t,e,n){var r=t(34),o=t(45),i=t(38),s=t(41);e.exports=function(t,e){var n=t[r],u=t[o],a=e[i],c=e[s];null!=a&&"object"==typeof a&&(a[s]=c),null!=c&&"object"==typeof c&&(c[i]=a),e===n&&(t[r]=t[i]=a),e===u&&(t[o]=t[s]=c),e[i]=e[s]=void 0,n=u=a=c=void 0}},{34:34,38:38,41:41,45:45}],52:[function(t,e,n){function r(t,e){var n=!1;return function(){if(!n&&!t._disposed){n=!0,t._callbacks[e]=null,t._optimizedPaths[e]=[],t._requestedPaths[e]=[];var r=--t._count;0!==r||t.sent||(t._disposable.dispose(),t.requestQueue.removeRequest(t))}}}function o(t){for(var e=[],n=-1,r=0,o=t.length;o>r;++r)for(var i=t[r],s=0,u=i.length;u>s;++s)e[++n]=i[s];return e}var i=t(59),s=t(60),u=0,a=t(57).GetRequest,c=t(76),p=t(78),h=t(119),f=[],l=function(t,e){this.sent=!1,this.scheduled=!1,this.requestQueue=e,this.id=++u,this.type=a,this._scheduler=t,this._pathMap={},this._optimizedPaths=[],this._requestedPaths=[],this._callbacks=[],this._count=0,this._disposable=null,this._collapsed=null,this._disposed=!1};l.prototype={batch:function(t,e,n){var o=this,i=o._optimizedPaths,u=o._requestedPaths,a=o._callbacks,c=i.length;return i[c]=e,u[c]=t,a[c]=n,++o._count,o.scheduled||(o.scheduled=!0,o._disposable=o._scheduler.schedule(function(){s(o,i,function(t,e){if(o.requestQueue.removeRequest(o),o._disposed=!0,o._count){o._merge(u,t,e);for(var n=0,r=a.length;r>n;++n){var i=a[n];i&&i(t,e)}}})})),r(o,c)},add:function(t,e,n){var o,s,u=this,a=i(t,e,u._pathMap);a?(s=a[2],o=a[1]):(s=t,o=e);var c=!1,p=!1;if(o.length<e.length){c=!0;var h=u._callbacks.length;u._callbacks[h]=n,u._requestedPaths[h]=a[0],u._optimizedPaths[h]=[],++u._count,p=r(u,h)}return[c,s,o,p]},_merge:function(t,e,n){var r=this,i=r.requestQueue.model,s=i._root,u=s.errorSelector,a=s.comparator,l=i._path;i._path=f;var d=o(t);if(e){var v=e;v instanceof Error&&(v={message:v.message}),v.$type||(v={$type:h,value:v});var y=d.map(function(t){return{path:t,value:v}});p(i,y,null,u,a)}else c(i,[{paths:d,jsonGraph:n.jsonGraph}],null,u,a);i._path=l}},e.exports=l},{119:119,57:57,59:59,60:60,76:76,78:78}],53:[function(t,e,n){function r(){this.length=0,this.pending=!1,this.pathmaps=[],s.call(this,this._subscribe)}var o=t(159),i=o.Observer,s=o.Observable,u=o.Disposable,a=o.SerialDisposable,c=o.CompositeDisposable,p=t(9),h=t(143),f=h.iterateKeySet;r.create=function(t,e,n){var r=new this;return r.queue=t,r.model=e,r.index=n,r},r.prototype=Object.create(s.prototype),r.prototype.constructor=r,r.prototype.insertPath=function(t,e,n,r,o){var i=r||0,s=o||t.length-1,u=n||this.pathmaps[s+1]||(this.pathmaps[s+1]=Object.create(null));if(void 0===u||null===u)return!1;var a,c,p=t[i],h={};a=f(p,h);do{if(c=u[a],s>i){if(null==c){if(e)return!1;c=u[a]=Object.create(null)}if(this.insertPath(t,e,c,i+1,s)===!1)return!1}else u[a]=(c||0)+1,this.length+=1;h.done||(a=f(p,h))}while(!h.done);return!0},r.prototype.removePath=function(t,e,n,r){var o=n||0,i=r||t.length-1,s=e||this.pathmaps[i+1];if(void 0===s||null===s)return!0;var u,a,c=0,p=t[o],h={};u=f(p,h);do if(a=s[u],void 0!==a&&null!==a){if(i>o){c+=this.removePath(t,a,o+1,i);var l=void 0;for(l in a)break;void 0===l&&delete s[u]}else a=s[u]=(a||1)-1,0===a&&delete s[u],c+=1,this.length-=1;h.done||(u=f(p,h))}while(!h.done);return c},r.prototype.getSourceObserver=function(t){var e=this;return i.create(function(n){n.jsonGraph=n.jsonGraph||n.jsong||n.values||n.value,n.index=e.index,t.onNext(n)},function(e){t.onError(e)},function(){t.onCompleted()})},r.prototype._subscribe=function(t){var e=this,n=this.queue;e.pending=!0;var r=!1,o=new a,i=u.create(function(){r||(r=!0,n&&n._remove(e))}),s=new c(o,i);try{o.setDisposable(this.model._source[this.method](this.getSourceArgs()).subscribe(this.getSourceObserver(t)))}catch(h){throw new p(h)}return s},e.exports=r},{143:143,159:159,9:9}],54:[function(t,e,n){function r(t,e){this.total=0,this.model=t,this.requests=[],this.scheduler=e}var o=t(58),i=t(40),s=t(90),u=t(100),a=t(143);r.prototype.set=function(t){return t.paths=a.collapse(t.paths),o.create(this.model,t)},r.prototype._remove=function(t){var e=this.requests,n=e.indexOf(t);-1!==n&&e.splice(n,1)},r.prototype.distributePaths=function(t,e,n){var r,o,i=this.model,s=-1,u=t.length,a=-1,c=e.length,p=[];t:for(;++s<u;){var h=t[s];for(a=-1;++a<c;)if(o=e[a],o.insertPath(h,o.pending)){p[a]=o;continue t}r||(r=n.create(this,i,this.total++),e[a]=r,p[c++]=r),r.insertPath(h,!1)}var f=[],l=-1;for(a=-1;++a<c;)o=p[a],null!=o&&(f[++l]=o);return f},r.prototype.mergeJSONGraphs=function(t,e){var n=0,r=[],o=[],a=[],c=t.index,p=e.index;t.index=Math.max(c,p),r[-1]=t.jsonGraph||{},o[-1]=e.jsonGraph||{};t:for(;n>-1;){for(var h=r[n-1],f=o[n-1],l=a[n-1]||(a[n-1]=Object.keys(f));l.length>0;){var d=l.pop();if(d[0]!==i)if(h.hasOwnProperty(d)){var v=h[d],y=s(v),b=f[d],m=s(b);if(u(v)&&u(b)&&!y&&!m){r[n]=v,o[n]=b,n+=1;continue t}p>c&&(h[d]=b)}else h[d]=f[d]}n-=1}return t},e.exports=r},{100:100,143:143,40:40,58:58,90:90}],55:[function(t,e,n){function r(t,e){this.model=t,this.scheduler=e,this.requests=this._requests=[]}var o=t(54),i=t(56);r.prototype.get=i.prototype.get,r.prototype.removeRequest=i.prototype.removeRequest,r.prototype.set=o.prototype.set,r.prototype.call=o.prototype.call,e.exports=r},{54:54,56:56}],56:[function(t,e,n){function r(t,e){this.model=t,this.scheduler=e,this.requests=this._requests=[]}var o=t(57),i=t(52);r.prototype={setScheduler:function(t){this.scheduler=t},get:function(t,e,n){function r(){v||(--h,0===h&&n())}var s,u,a,c=this,p=[],h=0,f=c._requests,l=e,d=t,v=!1;for(s=0,u=f.length;u>s;++s)if(a=f[s],a.type===o.GetRequest){if(a.sent){var y=a.add(d,l,r);y[0]&&(d=y[1],l=y[2],p[p.length]=y[3],++h)}else a.batch(d,l,r),l=[],d=[],++h;if(!l.length)break}if(l.length){a=new i(c.scheduler,c),f[f.length]=a,++h;var b=a.batch(d,l,r);p[p.length]=b}return function(){if(!v&&0!==h){v=!0;for(var t=p.length,e=0;t>e;++e)p[e]()}}},removeRequest:function(t){for(var e=this._requests,n=e.length;--n>=0;)if(e[n].id===t.id){e.splice(n,1);break}}},e.exports=r},{52:52,57:57}],57:[function(t,e,n){e.exports={GetRequest:"GET"}},{}],58:[function(t,e,n){function r(){s.call(this)}var o=t(159),i=o.Observer,s=t(53),u=t(83),a=t(76),c=t(78),p=new Array(0);r.create=function(t,e){var n=new r;return n.model=t,n.jsonGraphEnvelope=e,n},r.prototype=Object.create(s.prototype),r.prototype.constructor=r,r.prototype.method="set",r.prototype.insertPath=function(){return!1},r.prototype.removePath=function(){return 0},r.prototype.getSourceArgs=function(){return this.jsonGraphEnvelope},r.prototype.getSourceObserver=function(t){var e=this.model,n=e._path,r=this.jsonGraphEnvelope.paths,o=e._root,h=o.errorSelector,f=o.comparator;return s.prototype.getSourceObserver.call(this,i.create(function(o){e._path=p;var i=a(e,[{paths:r,jsonGraph:o.jsonGraph}],null,h,f);o.paths=i[1],e._path=n,t.onNext(o)},function(o){e._path=p,c(e,u(r,function(t){return{path:t,value:o}}),null,h,f),e._path=n,t.onError(o)},function(){t.onCompleted()}))},e.exports=r},{159:159,53:53,76:76,78:78,83:83}],59:[function(t,e,n){var r=t(143).hasIntersection,o=t(84);e.exports=function(t,e,n){for(var i=[],s=[],u=[],a=-1,c=-1,p=!1,h=0,f=e.length;f>h;++h){var l=e[h],d=n[l.length];d&&r(d,l,0)?(!p&&h>0&&(s=o(t,0,h),i=o(e,0,h)),u[++a]=t[h],p=!0):p&&(i[++c]=l,s[c]=t[h])}return p?[u,i,s]:null}},{143:143,84:84}],60:[function(t,e,n){var r=t(143),o=r.toTree,i=r.toPaths;e.exports=function(t,e,n){if(0===t._count)return void t.requestQueue.removeRequest(t);t.sent=!0,t.scheduled=!1;for(var r=t._pathMap,s=Object.keys(e),u=0,a=s.length;a>u;++u)for(var c=e[u],p=0,h=c.length;h>p;++p){var f=c[p],l=f.length;if(r[l]){var d=r[l];d[d.length]=f}else r[l]=[f]}for(var v=Object.keys(r),y=0,b=v.length;b>y;++y){var m=v[y];r[m]=o(r[m])}var g,w=t._collasped=i(r);t.requestQueue.model._source.get(w).subscribe(function(t){g=t},function(t){n(t,g)},function(){n(null,g)})}},{143:143}],61:[function(t,e,n){function r(t){u.call(this,t||i)}function o(t){return s.Observable.defer(function(){return t})}function i(t){function e(t){function e(t,e){if(Boolean(e.invalidated))t.invalidations.push(t.localThisPath.concat(e.path));else{var n=e.path,r=e.value;Boolean(r)&&"object"==typeof r&&r.$type===f?t.references.push({path:i(n),value:e.value}):t.values.push({path:i(n),value:e.value})}return t}function n(t){var e=t.values.concat(t.references);return e.length>0?o(g.set.apply(g,e)._toJSONG()).map(function(e){return{results:t,envelope:e}}):u["return"]({results:t,envelope:{jsonGraph:{},paths:[]}})}function r(t){var e,n=t.envelope,r=t.results,c=r.values,p=r.references,h=r.invalidations,f=c.map(a).map(i),l=p.reduce(s,[]),d=b.map(i),v=l.concat(d);return e=v.length>0?o(m.get.apply(m,f.concat(v))._toJSONG()):u["return"](n),e.doAction(function(t){t.invalidated=h})}function s(t,e){var n=e.path;return t.push.apply(t,y.map(function(t){return n.concat(t)})),t}function a(t){return t.path}var c=t&&t.localFn;if("function"==typeof c){var p=t.model,h=p._path,l=c.apply(p,v).reduce(e,{values:[],references:[],invalidations:[],localThisPath:h}).flatMap(n).flatMap(r);return u["return"](l)}return u.empty()}function n(t){function e(t){var e=t.invalidated;return e&&e.length&&m.invalidate.apply(m,e),t}return t&&"object"==typeof t?s.Observable.defer(function(){
3470 var e;try{e=t.call(x,v,y,b)}catch(n){e=u["throw"](new p(n))}return e}).map(e):u.empty()}function r(t){return o(g.set(t)).reduce(function(t){return t},null).map(function(){return{invalidated:t.invalidated,paths:t.paths.map(function(t){return t.slice(w.length)})}})}function i(t){return _.concat(t)}var c=this.args,l=this.model,d=h.fromPath(c[0]),v=c[1]||[],y=(c[2]||[]).map(h.fromPath),b=(c[3]||[]).map(h.fromPath),m=l._clone({_path:[]}),g=m.withoutDataSource(),w=l._path,x=w.concat(d),_=x.slice(0,-1),S=o(l.withoutDataSource().get(d)).map(function(t){for(var e=t.json,n=-1,r=d.length;e&&++n<r;)e=e[d[n]];var o=m._derefSync(_).boxValues();return{model:o,localFn:e}}).flatMap(e).defaultIfEmpty(n(l._source)).mergeAll().flatMap(r),E=new a;return E.add(S.subscribe(function(e){var n=e.paths,r=e.invalidated,i=l.get.apply(l,n);"AsJSONG"===t.outputFormat&&(i=o(i._toJSONG()).doAction(function(t){t.invalidated=r})),E.add(i.subscribe(t))},function(e){t.onError(e)})),E}var s=t(159)&&t(158),u=s.Observable,a=s.CompositeDisposable,c=t(64),p=t(9),h=t(134),f=t(120);r.create=c.create,r.prototype=Object.create(u.prototype),r.prototype.constructor=r,r.prototype.invokeSourceRequest=function(t){return this},r.prototype.ensureCollect=function(t){return this},r.prototype.initialize=function(){return this},e.exports=r},{120:120,134:134,158:158,159:159,64:64,9:9}],62:[function(t,e,n){function r(t){i.call(this,t)}var o=t(159),i=o.Observable,s=t(64),u=t(134),a=t(88),c=t(49),p=t(81),h=t(46),f=Array.isArray,l=t(101),d=t(98),v=t(99);r.create=s.create,r.prototype=Object.create(i.prototype),r.prototype.constructor=r,r.prototype.subscribeCount=0,r.prototype.subscribeLimit=10,r.prototype.initialize=function(){for(var t,e,n=this.model,r=this.outputFormat||"AsPathMap",o=this.isProgressive,i=[{}],s=[],a=this.args,c=-1,h=a.length;++c<h;){var y,b=a[c];f(b)||"string"==typeof b?(b=u.fromPath(b),y="PathValues"):l(b)?(b.path=u.fromPath(b.path),y="PathValues"):v(b)?y="JSONGs":d(b)&&(y="PathMaps"),e!==y&&(e=y,t={inputType:y,arguments:[]},s.push(t),t.values=i),t.arguments.push(b)}return this.boundPath=p(n._path),this.groups=s,this.outputFormat=r,this.isProgressive=o,this.isCompleted=!1,this.isMaster=null==n._source,this.values=i,this},r.prototype.invokeSourceRequest=function(t){return this},r.prototype.ensureCollect=function(t){var e=this["finally"](function(){var e=t._root,n=e.cache;e.collectionScheduler.schedule(function(){c(e,e.expired,a(n),t._maxSize,t._collectRatio,n[h])})});return new this.constructor(function(t){return e.subscribe(t)})},e.exports=r},{101:101,134:134,159:159,46:46,49:49,64:64,81:81,88:88,98:98,99:99}],63:[function(t,e,n){function r(t){u.call(this,t||o)}function o(t){for(var e=this.model,n=this.method,r=this.groups,o=-1,i=r.length;++o<i;){var u=r[o],a=u.inputType,c=u.arguments;if(c.length>0){var p="_"+n+a+"AsJSON",h=e[p];h(e,c)}}return t.onCompleted(),s.empty}var i=t(159),s=i.Disposable,u=t(62);r.create=u.create,r.prototype=Object.create(u.prototype),r.prototype.method="invalidate",r.prototype.constructor=r,e.exports=r},{159:159,62:62}],64:[function(t,e,n){function r(t){this._subscribe=t}function o(t){var e=this.model,n=new this.type;return n.model=e,n.args=this.args,n.outputFormat=t.outputFormat||"AsPathMap",n.isProgressive=t.isProgressive||!1,n.subscribeCount=0,n.subscribeLimit=t.retryLimit||10,n.initialize().invokeSourceRequest(e).ensureCollect(e).subscribe(t)}var i=t(32),s=t(159)&&t(158),u=s.Observable,a=t(84),c=t(105),p={outputFormat:{value:"AsJSONG"}},h={isProgressive:{value:!0}};r.create=function(t,e){var n=new r(o);return n.args=e,n.type=this,n.model=t,n},r.prototype=Object.create(u.prototype),r.prototype.constructor=r,r.prototype._mixin=function(){var t=this,e=a(arguments);return new t.constructor(function(n){return t.subscribe(e.reduce(function(t,e){return Object.create(t,e)},n))})},r.prototype._toJSONG=function(){return this._mixin(p)},r.prototype.progressively=function(){return this._mixin(h)},r.prototype.subscribe=function(t,e,n){var r=t;r&&"object"==typeof r||(r={onNext:t||c,onError:e||c,onCompleted:n||c});var o=this._subscribe(r);switch(typeof o){case"function":return{dispose:o};case"object":return o||{dispose:c};default:return{dispose:c}}},r.prototype.then=function(t,e){var n=this;return new i.Promise(function(t,e){var r,o=!1;n.toArray().subscribe(function(t){r=t.length<=1?t[0]:t},function(t){o=!0,e(t)},function(){o===!1&&t(r)})}).then(t,e)},e.exports=r},{105:105,158:158,159:159,32:32,84:84}],65:[function(t,e,n){function r(t){l.call(this,t||o)}function o(t){return this.isCompleted?s.call(this,t):i.call(this,t)}function i(t){if(this.subscribeCount++>this.subscribeLimit)return t.onError("Loop kill switch thrown."),h.empty;for(var e=[],n=[],r=this.model,o=this.isMaster,i=r._root,c=this.outputFormat,p=i.errorSelector,f=this.method,l=this.groups,d=-1,y=l.length;++d<y;){var b=l[d],m=b.inputType,g=b.arguments;if(g.length>0){var w="_"+f+m+c,x=r[w],_=x(r,g,null,p);n.push.apply(n,_[1]),"PathValues"===m?e.push.apply(e,g.map(u)):"JSONGs"===m?e.push.apply(e,v(g,a)):e.push.apply(e,_[0])}}return this.requestedPaths=e,o?(this.isCompleted=!0,s.call(this,t)):void t.onError({method:f,optimizedPaths:n,invokeSourceRequest:!0})}function s(t){var e=new f(this.model,this.requestedPaths);return"AsJSONG"===this.outputFormat&&(e=e._toJSONG()),this.isProgressive&&(e=e.progressively()),e.subscribe(t)}function u(t){return t.path}function a(t){return t.paths}var c=t(159),p=c.Observable,h=c.Disposable,f=t(67),l=t(62),d=t(9),v=t(82),y=new Array(0);r.create=l.create,r.prototype=Object.create(l.prototype),r.prototype.method="set",r.prototype.constructor=r,r.prototype.invokeSourceRequest=function(t){var e=this,n=this["catch"](function(r){var o;if(r&&r.invokeSourceRequest===!0){var i={},s=t._path,u=r.optimizedPaths;t._path=y,t._getPathValuesAsJSONG(t._materialize().withoutDataSource(),u,[i]),t._path=s,o=t._request.set(i)["do"](function(t){e.isCompleted=u.length===t.paths.length},function(){e.isCompleted=!0}).materialize().flatMap(function(t){if("C"===t.kind)return p.empty();if("E"===t.kind){var e=t.exception;if(d.is(e))return p["throw"](t.exception)}return n})}else o=p["throw"](r);return o});return new this.constructor(function(t){return n.subscribe(t)})},e.exports=r},{159:159,62:62,67:67,82:82,9:9}],66:[function(t,e,n){var r=function(t){this.disposed=!1,this.currentDisposable=t};r.prototype={dispose:function(){if(!this.disposed&&this.currentDisposable){this.disposed=!0;var t=this.currentDisposable;t.dispose?t.dispose():t()}}},e.exports=r},{}],67:[function(t,e,n){var r=t(64),o=t(68),i=t(69),s={dispose:function(){}},u=t(159).Observable,a=e.exports=function(t,e,n,r){this.model=t,this.currentRemainingPaths=e,this.isJSONGraph=n||!1,this.isProgressive=r||!1};a.prototype=Object.create(u.prototype),a.prototype.subscribe=r.prototype.subscribe,a.prototype.then=r.prototype.then,a.prototype._toJSONG=function(){return new a(this.model,this.currentRemainingPaths,!0,this.isProgressive)},a.prototype.progressively=function(){return new a(this.model,this.currentRemainingPaths,this.isJSONGraph,!0)},a.prototype._subscribe=function(t){var e=[{}],n=[],r=t.isJSONG=this.isJSONGraph,u=this.isProgressive,a=o(this.model,this.currentRemainingPaths,t,u,r,e,n);return a?i(this,this.model,a,t,e,n,1):s}},{159:159,64:64,68:68,69:69}],68:[function(t,e,n){var r=t(19),o=r.getWithPathsAsJSONGraph,i=r.getWithPathsAsPathMap;e.exports=function(t,e,n,r,s,u,a){var c;if(c=s?o(t,e,u):i(t,e,u),c.criticalError)return n.onError(c.criticalError),null;var p=c.hasValue,h=!c.requestedMissingPaths||!t._source,f=u[0].json||u[0].jsonGraph;if(c.errors)for(var l=c.errors,d=a.length,v=0,y=l.length;y>v;++v,++d)a[d]=l[v];if(p&&r||f&&h)try{++t._root.syncRefCount,n.onNext(u[0])}catch(b){throw b}finally{--t._root.syncRefCount}return h?(a.length?n.onError(a):n.onCompleted(),null):c}},{19:19}],69:[function(t,e,n){var r=t(68),o=t(10),i=t(30).fastCat,s=t(49),u=t(88),a=t(66),c=t(46);e.exports=function p(t,e,n,h,f,l,d){if(10===d)throw new o;var v=e._request,y=n.requestedMissingPaths,b=n.optimizedMissingPaths,m=new a,g=[],w=e._path;if(w.length)for(var x=0,_=y.length;_>x;++x)g[x]=i(w,y[x]);else g=y;var S=v.get(g,b,function(){var n=r(e,y,h,t.isProgressive,t.isJSONGraph,f,l);if(n)m.currentDisposable=p(t,e,n,h,f,l,d+1);else{var o=e._root,i=o.cache,a=i[c];s(o,o.expired,u(i),e._maxSize,e._collectRatio,a)}});return m.currentDisposable=S,m}},{10:10,30:30,46:46,49:49,66:66,68:68,88:88}],70:[function(t,e,n){var r=t(67);e.exports=function(t){return new r(this,t)}},{67:67}],71:[function(t,e,n){var r=t(134),o=t(64),i=t(72),s=t(116),u=t(67);e.exports=function(){var t=s(arguments,i,"get");if(t!==!0)return new o(function(e){e.onError(t)});var e=r.fromPathsOrPathValues(arguments);return new u(this,e)}},{116:116,134:134,64:64,67:67,72:72}],72:[function(t,e,n){e.exports={path:!0,pathSyntax:!0}},{}],73:[function(t,e,n){function r(){}var o=t(123),i=t(159),s=i.Disposable;r.prototype.schedule=function(t){return o(t),s.empty},r.prototype.scheduleWithState=function(t,e){var n=this;return o(function(){e(n,t)}),s.empty},e.exports=r},{123:123,159:159}],74:[function(t,e,n){function r(){}var o=t(159),i=o.Disposable;r.prototype.schedule=function(t){return t(),i.empty},r.prototype.scheduleWithState=function(t,e){return e(this,t),i.empty},e.exports=r},{159:159}],75:[function(t,e,n){function r(t){this.delay=t}var o=t(159),i=o.Disposable;r.prototype.schedule=function(t){var e=setTimeout(t,this.delay);return i.create(function(){void 0!==e&&(clearTimeout(e),e=void 0)})},r.prototype.scheduleWithState=function(t,e){var n=this,r=setTimeout(function(){e(n,t)},this.delay);return i.create(function(){void 0!==r&&(clearTimeout(r),r=void 0)})},e.exports=r},{159:159}],76:[function(t,e,n){function r(t,e,n,o,s,u,a,c,p,h,f,d,v,y,b,g,w){for(var x={},_=e<t.length-1,S=t[e],E=m(S,x),C=d.index;;){f.depth=e;var A=i(n,o,s,u,a,c,E,_,!1,f,d,v,y,b,g,w);f[e]=E,f.index=e,d[d.index++]=E;var N=A[0],k=A[1];if(N&&(_?r(t,e+1,n,k,N,u,A[3],A[2],p,h,f,d,v,y,b,g,w):(l(b,N),p.push(f.slice(0,f.index+1)),h.push(d.slice(0,d.index)))),E=m(S,x),x.done)break;d.index=C}}function o(t,e,n,r,o,s,c,f,v,m,g){var w=e.value;if(s.splice(0,s.length),s.push.apply(s,w),d(e))return s.index=w.length,b(e,f,v),[void 0,t,r,n];l(v,e);var x=0,_=e,S=w.length-1,E=e=t,C=r=n;do{var A=w[x],N=S>x,k=i(t,E,e,n,C,r,A,N,!0,o,s,c,f,v,m,g);if(e=k[0],y(e))return s.index=x,k;E=k[1],r=k[2],C=k[3]}while(x++<S);if(s.index=x,_[a]!==e){var O=e[h]||0;e[h]=O+1,e[u+O]=_,_[a]=e,_[p]=O}return[e,E,r,C]}function i(t,e,n,r,i,u,a,c,p,h,l,d,v,b,m,g){for(var x=n.$type;x===f;){var _=o(t,n,r,u,h,l,d,v,b,m,g);if(n=_[0],y(n))return _;e=_[1],u=_[2],i=_[3],x=n.$type}if(void 0!==x)return[n,e,u,i];if(null==a){if(c)throw new Error("`null` is not allowed in branch key positions.");n&&(a=n[s])}else e=n,i=u,n=e[a],u=i&&i[a];return n=w(e,n,u,a,h,l,d,v,b,m,g),[n,e,u,i]}var s=t(36),u=t(43),a=t(33),c=t(46),p=t(42),h=t(44),f=t(120),l=t(50),d=t(94),v=t(96),y=t(102),b=t(86),m=t(143).iterateKeySet,g=t(92),w=t(103);e.exports=function(t,e,n,o,i){for(var s=t._root,u=s,a=s.expired,p=g(),h=s.cache,f=h[c],l=[],d=[],y=[],b=[],m=-1,w=e.length;++m<w;)for(var x=e[m],_=x.paths,S=x.jsonGraph,E=-1,C=_.length;++E<C;){var A=_[E];d.index=0,r(A,0,h,h,h,S,S,S,y,b,l,d,p,a,u,i,o)}var N=h[c],k=s.onChange;return v(k)&&f!==N&&k(),[y,b]}},{102:102,103:103,120:120,143:143,33:33,36:36,42:42,43:43,44:44,46:46,50:50,86:86,92:92,94:94,96:96}],77:[function(t,e,n){function r(t,e,n,o,u,a,c,p,h,f,l,d,v,y){var b=s(t);if(b&&b.length)for(var g=0,x=b.length,_=h.index;;){var S=b[g],E=t[S],C=w(E)&&!E.$type;p.depth=e;var A=i(n,o,u,S,E,C,!1,p,h,f,l,d,v,y);p[e]=S,p.index=e,h[h.index++]=S;var N=A[0],k=A[1];if(N&&(C?r(E,e+1,n,k,N,a,c,p,h,f,l,d,v,y):(m(d,N),a.push(p.slice(0,p.index+1)),c.push(h.slice(0,h.index)))),++g>=x)break;h.index=_}}function o(t,e,n,r,o,s,u,c,f,v){var y=n.value;if(o.splice(0,o.length),o.push.apply(o,y),x(n))return o.index=y.length,E(n,u,c),[void 0,e];m(c,n);var b=n,g=e;if(n=n[h],null!=n)g=n[p]||e,o.index=y.length;else{var w=0,_=y.length-1;g=n=e;do{var C=y[w],A=_>w,N=i(e,g,n,C,t,A,!0,r,o,s,u,c,f,v);if(n=N[0],S(n))return o.index=w,N;g=N[1]}while(w++<_);if(o.index=w,b[h]!==n){var k=n[d]||0;n[d]=k+1,n[a+k]=b,b[h]=n,b[l]=k}}return[n,g]}function i(t,e,n,r,i,s,a,c,p,h,f,l,d,y){for(var b=n.$type;b===v;){var m=o(i,t,n,c,p,h,f,l,d,y);if(n=m[0],S(n))return m;e=m[1],b=n&&n.$type}if(void 0!==b)return[n,e];if(null==r){if(s)throw new Error("`null` is not allowed in branch key positions.");n&&(r=n[u])}else e=n,n=e[r];return n=A(e,n,r,i,s,a,c,p,h,f,l,d,y),[n,e]}function s(t){if(w(t)&&!t.$type){var e=[],n=0;b(t)&&(e[n++]="length");for(var r in t)r[0]!==c&&"$"!==r[0]&&g(t,r)&&(e[n++]=r);return e}}var u=t(36),a=t(43),c=t(40),p=t(39),h=t(33),f=t(46),l=t(42),d=t(44),v=t(120),y=t(13),b=Array.isArray,m=t(50),g=t(91),w=t(100),x=t(95),_=t(96),S=t(102),E=t(86),C=t(92),A=t(104);e.exports=function(t,e,n,o,i){for(var s=t._root,u=s,a=s.expired,c=C(),h=t._path,l=s.cache,d=h.length?y(t,h).value:l,v=d[p]||l,b=l[f],m=[],g=[],w=[],x=h.length,S=-1,E=e.length;++S<E;){var A=e[S],N=h.slice(0);N.index=x,r(A.json,0,l,v,d,g,w,m,N,c,a,u,i,o)}var k=l[f],O=s.onChange;return _(O)&&b!==k&&O(),[g,w]}},{100:100,102:102,104:104,120:120,13:13,33:33,36:36,39:39,40:40,42:42,43:43,44:44,46:46,50:50,86:86,91:91,92:92,95:95,96:96}],78:[function(t,e,n){function r(t,e,n,o,s,u,a,c,p,h,f,l,d,y,b){for(var m={},g=n<e.length-1,x=e[n],_=w(x,m),S=h.index;;){p.depth=n;var E=i(o,s,u,_,t,g,!1,p,h,f,l,d,y,b);p[n]=_,p.index=n,h[h.index++]=_;var C=E[0],A=E[1];if(C&&(g?r(t,e,n+1,o,A,C,a,c,p,h,f,l,d,y,b):(v(d,C),a.push(p.slice(0,p.index+1)),c.push(h.slice(0,h.index)))),_=w(x,m),m.done)break;h.index=S}}function o(t,e,n,r,o,s,p,l,d,b){var w=n.value;if(o.splice(0,o.length),o.push.apply(o,w),y(n))return o.index=w.length,g(n,p,l),[void 0,e];v(l,n);var x=n,_=e;if(n=n[c],null!=n)_=n[a]||e,o.index=w.length;else{var S=0,E=w.length-1;_=n=e;do{var C=w[S],A=E>S,N=i(e,_,n,C,t,A,!0,r,o,s,p,l,d,b);if(n=N[0],m(n))return o.index=S,N;_=N[1]}while(S++<E);if(o.index=S,x[c]!==n){var k=n[f]||0;n[f]=k+1,n[u+k]=x,x[c]=n,x[h]=k}}return[n,_]}function i(t,e,n,r,i,u,a,c,p,h,f,d,v,y){for(var b=n.$type;b===l;){var g=o(i,t,n,c,p,h,f,d,v,y);if(n=g[0],m(n))return g;e=g[1],b=n.$type}if(void 0!==b)return[n,e];if(null==r){if(u)throw new Error("`null` is not allowed in branch key positions.");n&&(r=n[s])}else e=n,n=e[r];return n=_(e,n,r,i,u,a,c,p,h,f,d,v,y),[n,e]}var s=t(36),u=t(43),a=t(39),c=t(33),p=t(46),h=t(42),f=t(44),l=t(120),d=t(13),v=t(50),y=t(95),b=t(96),m=t(102),g=t(86),w=t(143).iterateKeySet,x=t(92),_=t(104);e.exports=function(t,e,n,o,i){for(var s=t._root,u=s,c=s.expired,h=x(),f=t._path,l=s.cache,v=f.length?d(t,f).value:l,y=v[a]||l,m=l[p],g=[],w=[],_=[],S=f.length,E=-1,C=e.length;++E<C;){var A=e[E],N=A.path,k=A.value,O=f.slice(0);O.index=S,r(k,N,0,l,y,v,w,_,g,O,h,c,u,i,o)}var P=l[p],j=s.onChange;return b(j)&&m!==P&&j(),[w,_]}},{102:102,104:104,120:120,13:13,143:143,33:33,36:36,39:39,42:42,43:43,44:44,46:46,50:50,86:86,92:92,95:95,96:96}],79:[function(t,e,n){var r=t(130),o=t(64),i=t(101);e.exports=function(t,e){for(var n=i(t)?t:r.pathValue(t,e),s=0,u=n.path,a=u.length;++s<a;)if("object"==typeof u[s])return new o(function(t){t.onError(new Error("Paths must be simple paths"))});var c=this;return new o(function(t){return c._set(n).subscribe(function(e){for(var n=e.json,r=-1,o=u.length;n&&++r<o;)n=n[u[r]];t.onNext(n)},function(e){t.onError(e)},function(){t.onCompleted()})})}},{101:101,130:130,64:64}],80:[function(t,e,n){var r=t(134),o=t(101),i=t(78);e.exports=function(t,e,n,s){var u=r.fromPath(t),a=e,c=n,p=s;if(o(u)?(p=c,c=a,a=u):a={path:u,value:a},o(a)===!1)throw new Error("Model#setValueSync must be called with an Array path.");return"function"!=typeof c&&(c=this._root._errorSelector),"function"!=typeof p&&(p=this._root._comparator),this._syncCheck("setValueSync")?(i(this,[a]),this._getValueSync(this,a.path).value):void 0}},{101:101,134:134,78:78}],81:[function(t,e,n){e.exports=function(t){if(!t)return t;for(var e=-1,n=t.length,r=[];++e<n;)r[e]=t[e];return r}},{}],82:[function(t,e,n){e.exports=function(t,e){for(var n=-1,r=-1,o=t.length,i=[];++r<o;)for(var s=e(t[r],r,t),u=-1,a=s.length;++u<a;)i[++n]=s[u];return i}},{}],83:[function(t,e,n){e.exports=function(t,e){for(var n=-1,r=t.length,o=new Array(r);++n<r;)o[n]=e(t[n],n,t);return o}},{}],84:[function(t,e,n){e.exports=function(t,e,n){var r=e||0,o=-1,i=t.length-r;0>i&&(i=0),n>0&&i>n&&(i=n);for(var s=new Array(i);++o<i;)s[o]=t[o+r];return s}},{}],85:[function(t,e,n){var r=t(40),o=t(91),i=Array.isArray,s=t(100);e.exports=function(t){var e=t;if(s(e)){e=i(t)?[]:{};var n=t;for(var u in n)u[0]!==r&&o(n,u)&&(e[u]=n[u])}return e}},{100:100,40:40,91:91}],86:[function(t,e,n){var r=t(51),o=t(35);e.exports=function(t,e,n){return t[o]||(t[o]=!0,e.push(t),r(n,t)),t}},{35:35,51:51}],87:[function(t,e,n){var r=t(100);e.exports=function(t){return r(t)&&t.$expires||void 0}},{100:100}],88:[function(t,e,n){var r=t(100);e.exports=function(t){return r(t)&&t.$size||0}},{100:100}],89:[function(t,e,n){var r=t(100);e.exports=function(t){return r(t)&&t.$timestamp||void 0}},{100:100}],90:[function(t,e,n){var r=t(100);e.exports=function(t,e){var n=r(t)&&t.$type||void 0;return e&&n?"branch":n}},{100:100}],91:[function(t,e,n){var r=t(100),o=Object.prototype.hasOwnProperty;e.exports=function(t,e){return r(t)&&o.call(t,e)}},{100:100}],92:[function(t,e,n){var r=1;e.exports=function(){return r++}},{}],93:[function(t,e,n){var r=t(36),o=t(39),i=t(46);e.exports=function(t,e,n,s){return t[r]=n,t[o]=e,t[i]=s,e[n]=t,t}},{36:36,39:39,46:46}],94:[function(t,e,n){var r=t(106),o=t(122),i=t(121);e.exports=function(t){var e=t.$expires;return null!=e&&e!==i&&e!==o&&e<r()}},{106:106,121:121,122:122}],95:[function(t,e,n){var r=t(106),o=t(122),i=t(121);e.exports=function(t){var e=t.$expires;return null!=e&&e!==i&&(e===o||e<r())}},{106:106,121:121,122:122}],96:[function(t,e,n){var r="function";e.exports=function(t){return Boolean(t)&&typeof t===r}},{}],97:[function(t,e,n){var r=t(40);e.exports=function(t){return"$size"===t||t&&t.charAt(0)===r}},{40:40}],98:[function(t,e,n){var r=t(100);e.exports=function(t){return r(t)&&"json"in t}},{100:100}],99:[function(t,e,n){var r=Array.isArray,o=t(100);e.exports=function(t){return o(t)&&r(t.paths)&&(o(t.jsonGraph)||o(t.jsong)||o(t.json)||o(t.values)||o(t.value))}},{100:100}],100:[function(t,e,n){var r="object";e.exports=function(t){return null!==t&&typeof t===r}},{}],101:[function(t,e,n){var r=Array.isArray,o=t(100);e.exports=function(t){return o(t)&&(r(t.path)||"string"==typeof t.path)}},{100:100}],102:[function(t,e,n){var r="object";e.exports=function(t){return null==t||typeof t!==r}},{}],103:[function(t,e,n){var r=t(36),o=t(39),i=t(120),s=t(119),u=t(88),a=t(89),c=t(100),p=t(95),h=t(96),f=t(50),l=t(117),d=t(93),v=t(86),y=t(110),b=t(115),m=t(107);e.exports=function(t,e,n,g,w,x,_,S,E,C,A){var N,k,O,P,j,D,q;if(e===n){if(null===n)return e=l(n,void 0,n),t=b(t,-e.$size,E,_),e=d(e,t,g),f(E,e),e;if(void 0===n)return n;if(P=c(e),P&&(k=e.$type,null==k))return null==e[o]&&(e[r]=g,e[o]=t),e}else P=c(e),P&&(k=e.$type);if(k!==i){if(j=c(n),j&&(O=n.$type),P&&!k&&(null==n||j&&!O))return e}else{if(null==n)return p(e)?void v(e,S,E):e;if(j=c(n),j&&(O=n.$type,O===i))if(e===n){if(null!=e[o])return e}else if(D=e.$timestamp,q=n.$timestamp,!p(e)&&!p(n)&&D>q)return}if(k&&j&&!O)return d(y(e,n,t,g,E),t,g);if(O||!j){if(O===s&&h(A)&&(n=A(m(w,g),n)),O&&e===n)null==e[o]&&(e=l(e,k,e.value),t=b(t,-e.$size,E,_),e=d(e,t,g,_));else{var R=!0;!k&&P||(R=a(n)<a(e)==!1,(k||O)&&h(C)&&(R=!C(e,n,x.slice(0,x.index)))),R&&(n=l(n,O,O?n.value:n),N=u(e)-u(n),e=y(e,n,t,g,E),t=b(t,N,E,_),e=d(e,t,g,_))}p(e)?v(e,S,E):f(E,e)}else null==e&&(e=d(n,t,g));return e}},{100:100,107:107,110:110,115:115,117:117,119:119,120:120,36:36,39:39,50:50,86:86,88:88,89:89,93:93,95:95,96:96}],104:[function(t,e,n){var r=t(120),o=t(119),i=t(90),s=t(88),u=t(89),a=t(95),c=t(102),p=t(96),h=t(117),f=t(86),l=t(93),d=t(110),v=t(115),y=t(114),b=t(107);e.exports=function(t,e,n,m,g,w,x,_,S,E,C,A,N){var k=i(e,w);if(g||w)k&&a(e)&&(k="expired",f(e,E,C)),(k&&k!==r||c(e))&&(e=d(e,{},t,n,C),e=l(e,t,n,S),e=y(e,S));else{var O=m,P=i(O),j=u(O)<u(e)==!1;if((k||P)&&p(A)&&(j=!A(e,O,_.slice(0,_.index))),j){P===o&&p(N)&&(O=N(b(x,n),O)),O=h(O,P,P?O.value:O);var D=s(e)-s(O);e=d(e,O,t,n,C),t=v(t,D,C,S),e=l(e,t,n,S)}}return e}},{102:102,107:107,110:110,114:114,115:115,117:117,119:119,120:120,86:86,88:88,89:89,90:90,93:93,95:95,96:96}],105:[function(t,e,n){e.exports=function(){}},{}],106:[function(t,e,n){e.exports=Date.now},{}],107:[function(t,e,n){e.exports=function(t,e){var n=t.slice(0,t.depth);return n[n.length]=e,n}},{}],108:[function(t,e,n){var r=t(120),o=t(39),i=t(51),s=t(100),u=t(112),a=t(113);e.exports=function(t,e,n,c){if(s(t)){var p=t.$type;return Boolean(p)&&(p===r&&a(t),i(c,t)),u(t),e[n]=t[o]=void 0,!0}return!1}},{100:100,112:112,113:113,120:120,39:39,51:51}],109:[function(t,e,n){var r=t(91),o=t(40),i=t(108);e.exports=function s(t,e,n,u){if(i(t,e,n,u)){if(null==t.$type)for(var a in t)a[0]!==o&&"$"!==a[0]&&r(t,a)&&s(t[a],t,a,u);return!0}return!1}},{108:108,40:40,91:91}],110:[function(t,e,n){var r=t(100),o=t(111),i=t(109);e.exports=function(t,e,n,s,u){return t===e?t:(r(t)&&(o(t,e),i(t,n,s,u)),n[s]=e,e)}},{100:100,109:109,111:111}],111:[function(t,e,n){var r=t(43),o=t(33),i=t(44);e.exports=function(t,e){for(var n=t[i]||0,s=e[i]||0,u=-1;++u<n;){var a=t[r+u];void 0!==a&&(a[o]=e,e[r+(s+u)]=a,t[r+u]=void 0)}return e[i]=n+s,t[i]=void 0,e}},{33:33,43:43,44:44}],112:[function(t,e,n){var r=t(43),o=t(33),i=t(42),s=t(44);e.exports=function(t){for(var e=-1,n=t[s]||0;++e<n;){var u=t[r+e];null!=u&&(u[o]=u[i]=t[r+e]=void 0)}return t[s]=void 0,t}},{33:33,42:42,43:43,44:44}],113:[function(t,e,n){var r=t(43),o=t(33),i=t(42),s=t(44);e.exports=function(t){var e=t[o];if(e){for(var n=(t[i]||0)-1,u=(e[s]||0)-1;++n<=u;)e[r+n]=e[r+(n+1)];e[s]=u,t[i]=t[o]=e=void 0}return t}},{33:33,42:42,43:43,44:44}],114:[function(t,e,n){var r=t(43),o=t(39),i=t(46),s=t(44);e.exports=function(t,e){var n=[t],u=0;do{var a=n[u--];if(a&&a[i]!==e){a[i]=e,n[u++]=a[o];for(var c=-1,p=a[s]||0;++c<p;)n[u++]=a[r+c]}}while(u>-1);return t}},{39:39,43:43,44:44,46:46}],115:[function(t,e,n){var r=t(36),o=t(46),i=t(39),s=t(108),u=t(114);e.exports=function(t,e,n,a){var c=t;do{var p=c[i],h=c.$size=(c.$size||0)-e;0>=h&&null!=p?s(c,p,c[r],n):c[o]!==a&&u(c,a),c=p}while(c);return t}},{108:108,114:114,36:36,39:39,46:46}],116:[function(t,e,n){var r=Array.isArray,o=t(101),i=t(99),s=t(98),u=t(134);e.exports=function(t,e,n){for(var a=0,c=t.length;c>a;++a){var p=t[a],h=!1;if(r(p)&&e.path?h=!0:"string"==typeof p&&e.pathSyntax?h=!0:o(p)&&e.pathValue?(p.path=u.fromPath(p.path),h=!0):i(p)&&e.jsonGraph?h=!0:s(p)&&e.json?h=!0:"function"==typeof p&&a+1===c&&e.selector&&(h=!0),!h)return new Error("Unrecognized argument "+typeof p+" ["+String(p)+"] to Model#"+n)}return!0}},{101:101,134:134,98:98,99:99}],117:[function(t,e,n){var r=t(130),o=r.atom,i=t(106),s=t(122),u=t(37),a=50,c=t(85),p=Array.isArray,h=t(88),f=t(87);e.exports=function(t,e,n){var r=0,l=t,d=e;if(d?(l=c(l),r=h(l),l.$type=d):(l=o(n),d=l.$type,l[u]=!0),null==n)r=a+1;else if(null==r||0>=r)switch(typeof n){case"object":r=p(n)?a+n.length:a+1;break;case"string":r=a+n.length;break;default:r=a+1}var v=f(l);return"number"==typeof v&&s>v&&(l.$expires=i()+-1*v),l.$size=r,l}},{106:106,122:122,130:130,37:37,85:85,87:87,88:88}],118:[function(t,e,n){e.exports="atom"},{}],119:[function(t,e,n){e.exports="error"},{}],120:[function(t,e,n){e.exports="ref"},{}],121:[function(t,e,n){e.exports=1},{}],122:[function(t,e,n){e.exports=0},{}],123:[function(t,e,n){"use strict";function r(){if(a.length)throw a.shift()}function o(t){var e;e=u.length?u.pop():new i,e.task=t,s(e)}function i(){this.task=null}var s=t(124),u=[],a=[],c=s.makeRequestCallFromTimer(r);e.exports=o,i.prototype.call=function(){try{this.task.call()}catch(t){o.onerror?o.onerror(t):(a.push(t),c())}finally{this.task=null,u[u.length]=this}}},{124:124}],124:[function(t,e,n){(function(t){"use strict";function n(t){u.length||(s(),a=!0),u[u.length]=t}function r(){for(;c<u.length;){var t=c;if(c+=1,u[t].call(),c>p){for(var e=0,n=u.length-c;n>e;e++)u[e]=u[e+c];u.length-=c,c=0}}u.length=0,c=0,a=!1}function o(t){var e=1,n=new h(t),r=document.createTextNode("");return n.observe(r,{characterData:!0}),function(){e=-e,r.data=e}}function i(t){return function(){function e(){clearTimeout(n),clearInterval(r),t()}var n=setTimeout(e,0),r=setInterval(e,50)}}e.exports=n;var s,u=[],a=!1,c=0,p=1024,h=t.MutationObserver||t.WebKitMutationObserver;s="function"==typeof h?o(r):i(r),n.requestFlush=s,n.makeRequestCallFromTimer=i}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],125:[function(t,e,n){"use strict";function r(t,e){var n;for(n in e)t[n]=e[n];return t}function o(t,e){if(this._jsongUrl=t,"number"==typeof e){var n={timeout:e};e=n}this._config=r({timeout:15e3,headers:{}},e||{})}var i=t(129),s=t(126);Array.isArray;o.prototype={constructor:o,buildQueryObject:s,get:function(t){var e="GET",n=this.buildQueryObject(this._jsongUrl,e,{paths:t,method:"get"}),o=r(n,this._config),s=this;return i(e,o,s)},set:function(t){var e="POST",n=this.buildQueryObject(this._jsongUrl,e,{jsonGraph:t,method:"set"}),o=r(n,this._config);o.headers["Content-Type"]="application/x-www-form-urlencoded";var s=this;return i(e,o,s)},call:function(t,e,n,o){e=e||[],n=n||[],o=o||[];var s="POST",u=[];u.push("method=call"),u.push("callPath="+encodeURIComponent(JSON.stringify(t))),u.push("arguments="+encodeURIComponent(JSON.stringify(e))),u.push("pathSuffixes="+encodeURIComponent(JSON.stringify(n))),u.push("paths="+encodeURIComponent(JSON.stringify(o)));var a=this.buildQueryObject(this._jsongUrl,s,u.join("&")),c=r(a,this._config);c.headers["Content-Type"]="application/x-www-form-urlencoded";var p=this;return i(s,c,p)}},o.XMLHttpSource=o,o["default"]=o,e.exports=o},{126:126,129:129}],126:[function(t,e,n){"use strict";e.exports=function(t,e,n){var r,o=[],i={url:t},s=-1!==t.indexOf("?"),u=s?"&":"?";return"string"==typeof n?o.push(n):(r=Object.keys(n),r.forEach(function(t){var e="object"==typeof n[t]?JSON.stringify(n[t]):n[t];o.push(t+"="+encodeURIComponent(e))})),"GET"===e?i.url+=u+o.join("&"):i.data=o.join("&"),i}},{}],127:[function(t,e,n){(function(t){"use strict";e.exports=function(){var e=new t.XMLHttpRequest;if("withCredentials"in e)return e;if(t.XDomainRequest)return new XDomainRequest;throw new Error("CORS is not supported by your browser")}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],128:[function(t,e,n){(function(t){"use strict";e.exports=function(){var e,n,r;if(t.XMLHttpRequest)return new t.XMLHttpRequest;try{for(n=["Msxml2.XMLHTTP","Microsoft.XMLHTTP","Msxml2.XMLHTTP.4.0"],r=0;3>r;r++)try{if(e=n[r],new t.ActiveXObject(e))break}catch(o){}return new t.ActiveXObject(e)}catch(o){throw new Error("XMLHttpRequest is not supported by your browser")}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],129:[function(t,e,n){"use strict";function r(){}function o(t,e,n){return r.create(function(r){var o,i,h,f,l,d={method:t||"GET",crossDomain:!1,async:!0,headers:{},responseType:"json"};for(l in e)p.call(e,l)&&(d[l]=e[l]);d.crossDomain||d.headers["X-Requested-With"]||(d.headers["X-Requested-With"]="XMLHttpRequest"),null!=n.onBeforeRequest&&n.onBeforeRequest(d);try{o=d.crossDomain?c():a()}catch(v){r.onError(v)}try{d.user?o.open(d.method,d.url,d.async,d.user,d.password):o.open(d.method,d.url,d.async),o.timeout=d.timeout,o.withCredentials=d.withCredentials!==!1,h=d.headers;for(f in h)p.call(h,f)&&o.setRequestHeader(f,h[f]);if(d.responseType)try{o.responseType=d.responseType}catch(y){if("json"!==d.responseType)throw y}o.onreadystatechange=function(t){4===o.readyState&&(i||(i=!0,s(r,o,t)))},o.ontimeout=function(t){i||(i=!0,u(r,o,"timeout error",t))},o.send(d.data)}catch(y){r.onError(y)}return function(){i||4===o.readyState||(i=!0,o.abort())}})}function i(t,e,n){n||(n=new Error(e)),t.onError(n)}function s(t,e,n){var r,o;if(e&&t){o=e.responseType,r="response"in e?e.response:e.responseText;var s=1223===e.status?204:e.status;if(s>=200&&399>=s){try{"json"!==o&&(r=JSON.parse(r||"")),"string"==typeof r&&(r=JSON.parse(r||""))}catch(n){i(t,"invalid json",n)}return t.onNext(r),void t.onCompleted()}return 401===s||403===s||407===s?i(t,r):410===s?i(t,r):408===s||504===s?i(t,r):i(t,r||"Response code "+s)}}function u(t,e,n,r){i(t,n||e.statusText||"request error",r)}var a=t(128),c=t(127),p=Object.prototype.hasOwnProperty,h=function(){};r.create=function(t){var e=new r;return e.subscribe=function(e,n,r){var o,i;return o="function"==typeof e?{onNext:e,onError:n||h,onCompleted:r||h}:e,i=t(o),"function"==typeof i?{dispose:i}:i},e},e.exports=o},{127:127,128:128}],130:[function(t,e,n){function r(t,e,n){var r=Object.create(null);if(null!=n){for(var o in n)r[o]=n[o];return r.$type=t,r.value=e,r}return{$type:t,value:e}}var o=t(134);e.exports={ref:function(t,e){return r("ref",o.fromPath(t),e)},atom:function(t,e){return r("atom",t,e)},undefined:function(){return r("atom")},error:function(t,e){return r("error",t,e)},pathValue:function(t,e){return{path:o.fromPath(t),value:e}},pathInvalidation:function(t){return{path:o.fromPath(t),invalidated:!0}}}},{134:134}],131:[function(t,e,n){e.exports={integers:"integers",ranges:"ranges",keys:"keys"}},{}],132:[function(t,e,n){var r={token:"token",dotSeparator:".",commaSeparator:",",openingBracket:"[",closingBracket:"]",openingBrace:"{",closingBrace:"}",escape:"\\",space:" ",colon:":",quote:"quote",unknown:"unknown"};e.exports=r},{}],133:[function(t,e,n){e.exports={indexer:{nested:"Indexers cannot be nested.",needQuotes:"unquoted indexers must be numeric.",empty:"cannot have empty indexers.",leadingDot:"Indexers cannot have leading dots.",leadingComma:"Indexers cannot have leading comma.",requiresComma:"Indexers require commas between indexer args.",routedTokens:"Only one token can be used per indexer when specifying routed tokens."},range:{precedingNaN:"ranges must be preceded by numbers.",suceedingNaN:"ranges must be suceeded by numbers."},routed:{invalid:"Invalid routed token. only integers|ranges|keys are supported."},quote:{empty:"cannot have empty quoted keys.",illegalEscape:"Invalid escape character. Only quotes are escapable."},unexpectedToken:"Unexpected token.",invalidIdentifier:"Invalid Identifier.",invalidPath:"Please provide a valid path.",throwError:function(t,e,n){if(n)throw t+" -- "+e.parseString+" with next token: "+n;throw t+" -- "+e.parseString}}},{}],134:[function(t,e,n){var r=t(140),o=t(135),i=t(131),s=function(t,e){return o(new r(t,e))};e.exports=s,s.fromPathsOrPathValues=function(t,e){if(!t)return[];for(var n=[],r=0,o=t.length;o>r;r++)"string"==typeof t[r]?n[r]=s(t[r],e):"string"==typeof t[r].path?n[r]={path:s(t[r].path,e),value:t[r].value}:n[r]=t[r];return n},s.fromPath=function(t,e){return t?"string"==typeof t?s(t,e):t:[]},s.RoutedTokens=i},{131:131,135:135,140:140}],135:[function(t,e,n){var r=t(132),o=t(133),i=t(136);e.exports=function(t){for(var e=t.next(),n={},s=[];!e.done;){switch(e.type){case r.token:var u=+e.token[0];isNaN(u)||o.throwError(o.invalidIdentifier,t),s[s.length]=e.token;break;case r.dotSeparator:0===s.length&&o.throwError(o.unexpectedToken,t);break;case r.space:break;case r.openingBracket:i(t,e,n,s);break;default:o.throwError(o.unexpectedToken,t)}e=t.next()}return 0===s.length&&o.throwError(o.invalidPath,t),s}},{132:132,133:133,136:136}],136:[function(t,e,n){var r=t(132),o=t(133),i=o.indexer,s=t(138),u=t(137),a=t(139);e.exports=function(t,e,n,c){var p=t.next(),h=!1,f=1,l=!1;for(n.indexer=[];!p.done;){switch(p.type){case r.token:case r.quote:n.indexer.length===f&&o.throwError(i.requiresComma,t)}switch(p.type){case r.openingBrace:l=!0,a(t,p,n,c);break;case r.token:var d=+p.token;isNaN(d)&&o.throwError(i.needQuotes,t),n.indexer[n.indexer.length]=d;break;case r.dotSeparator:n.indexer.length||o.throwError(i.leadingDot,t),s(t,p,n,c);
3471 break;case r.space:break;case r.closingBracket:h=!0;break;case r.quote:u(t,p,n,c);break;case r.openingBracket:o.throwError(i.nested,t);break;case r.commaSeparator:++f;break;default:o.throwError(o.unexpectedToken,t)}if(h)break;p=t.next()}0===n.indexer.length&&o.throwError(i.empty,t),n.indexer.length>1&&l&&o.throwError(i.routedTokens,t),1===n.indexer.length&&(n.indexer=n.indexer[0]),c[c.length]=n.indexer,n.indexer=void 0}},{132:132,133:133,137:137,138:138,139:139}],137:[function(t,e,n){var r=t(132),o=t(133),i=o.quote;e.exports=function(t,e,n,s){for(var u=t.next(),a="",c=e.token,p=!1,h=!1;!u.done;){switch(u.type){case r.token:case r.space:case r.dotSeparator:case r.commaSeparator:case r.openingBracket:case r.closingBracket:case r.openingBrace:case r.closingBrace:p&&o.throwError(i.illegalEscape,t),a+=u.token;break;case r.quote:p?(a+=u.token,p=!1):u.token!==c?a+=u.token:h=!0;break;case r.escape:p=!0;break;default:o.throwError(o.unexpectedToken,t)}if(h)break;u=t.next()}0===a.length&&o.throwError(i.empty,t),n.indexer[n.indexer.length]=a}},{132:132,133:133}],138:[function(t,e,n){var r=t(140),o=t(132),i=t(133);e.exports=function(t,e,n,s){var u,a=t.peek(),c=1,p=!1,h=!0,f=n.indexer.length-1,l=r.toNumber(n.indexer[f]);for(isNaN(l)&&i.throwError(i.range.precedingNaN,t);!p&&!a.done;){switch(a.type){case o.dotSeparator:3===c&&i.throwError(i.unexpectedToken,t),++c,3===c&&(h=!1);break;case o.token:u=r.toNumber(t.next().token),isNaN(u)&&i.throwError(i.range.suceedingNaN,t),p=!0;break;default:p=!0}if(p)break;t.next(),a=t.peek()}n.indexer[f]={from:l,to:h?u:u-1}}},{132:132,133:133,140:140}],139:[function(t,e,n){var r=t(132),o=t(131),i=t(133),s=i.routed;e.exports=function(t,e,n,u){var a=t.next(),c=!1,p="";switch(a.token){case o.integers:case o.ranges:case o.keys:break;default:i.throwError(s.invalid,t)}var h=t.next();if(h.type===r.colon&&(c=!0,h=t.next(),h.type!==r.token&&i.throwError(s.invalid,t),p=h.token,h=t.next()),h.type===r.closingBrace){var f={type:a.token,named:c,name:p};n.indexer[n.indexer.length]=f}else i.throwError(s.invalid,t)}},{131:131,132:132,133:133}],140:[function(t,e,n){function r(t,e,n){return{token:t,done:n,type:e}}function o(t,e,n){var o,g=!1,w="",x=n?m:b;do{if(o=e+1>=t.length)break;var _=t[e+1];if(void 0===_||-1!==x.indexOf(_)){if(w.length)break;++e;var S;switch(_){case s:S=i.dotSeparator;break;case u:S=i.commaSeparator;break;case a:S=i.openingBracket;break;case c:S=i.closingBracket;break;case p:S=i.openingBrace;break;case h:S=i.closingBrace;break;case y:S=i.space;break;case d:case v:S=i.quote;break;case l:S=i.escape;break;case f:S=i.colon;break;default:S=i.unknown}g=r(_,S,!1);break}w+=_,++e}while(!o);return!g&&w.length&&(g=r(w,i.token,!1)),g||(g={done:!0}),{token:g,idx:e}}var i=t(132),s=".",u=",",a="[",c="]",p="{",h="}",f=":",l="\\",d='"',v="'",y=" ",b="\\'\"[]., ",m="\\{}'\"[]., :",g=e.exports=function(t,e){this._string=t,this._idx=-1,this._extended=e,this.parseString=""};g.prototype={next:function(){var t=this._nextToken?this._nextToken:o(this._string,this._idx,this._extended);return this._idx=t.idx,this._nextToken=!1,this.parseString+=t.token.token,t.token},peek:function(){var t=this._nextToken?this._nextToken:o(this._string,this._idx,this._extended);return this._nextToken=t,t.token}},g.toNumber=function(t){return isNaN(+t)?NaN:+t}},{132:132}],141:[function(t,e,n){var r=t(147),o=t(148);e.exports=function(t){var e=t.reduce(function(t,e){var n=e.length;return t[n]||(t[n]=[]),t[n].push(e),t},{});return Object.keys(e).forEach(function(t){e[t]=o(e[t])}),r(e)}},{147:147,148:148}],142:[function(t,e,n){var r=t(144);e.exports=function o(t,e,n){for(var i=t,s=!0;s&&n<e.length;++n){var u=e[n],a=typeof u;if(u&&"object"===a){var c={},p=r(u,c),h=n+1;do{var f=i[p];s=void 0!==f,s&&(s=o(f,e,h)),p=r(u,c)}while(s&&!c.done);break}i=i[u],s=void 0!==i}return s}},{144:144}],143:[function(t,e,n){e.exports={iterateKeySet:t(144),toTree:t(148),toTreeWithUnion:t(149),pathsComplementFromTree:t(146),pathsComplementFromLengthTree:t(145),hasIntersection:t(142),toPaths:t(147),collapse:t(141)}},{141:141,142:142,144:144,145:145,146:146,147:147,148:148,149:149}],144:[function(t,e,n){function r(t,e){var n=e.from=t.from||0,r=e.to=t.to||"number"==typeof t.length&&e.from+t.length-1||0;e.rangeOffset=e.from,e.loaded=!0,n>r&&(e.empty=!0)}function o(t,e){e.done=!1;var n=e.isObject=!(!t||"object"!=typeof t);e.isArray=n&&i(t),e.arrayOffset=0}var i=Array.isArray;e.exports=function(t,e){if(void 0===e.isArray&&o(t,e),e.isArray){var n;do{e.loaded&&e.rangeOffset>e.to&&(++e.arrayOffset,e.loaded=!1);var i=e.arrayOffset,s=t.length;if(i>=s){e.done=!0;break}var u=t[e.arrayOffset],a=typeof u;if("object"===a){if(e.loaded||r(u,e),e.empty)continue;n=e.rangeOffset++}else++e.arrayOffset,n=u}while(void 0===n);return n}return e.isObject?(e.loaded||r(t,e),e.rangeOffset>e.to?void(e.done=!0):e.rangeOffset++):(e.done=!0,t)}},{}],145:[function(t,e,n){var r=t(142);e.exports=function(t,e){for(var n=[],o=-1,i=0,s=t.length;s>i;++i){var u=t[i];r(e[u.length],u,0)||(n[++o]=u)}return n}},{142:142}],146:[function(t,e,n){var r=t(142);e.exports=function(t,e){for(var n=[],o=-1,i=0,s=t.length;s>i;++i)r(e,t[i],0)||(n[++o]=t[i]);return n}},{142:142}],147:[function(t,e,n){function r(t){return null!==t&&typeof t===f}function o(t,e,n){var r,i,s,u,h,f,l,d,v,y,b,m,g,w,x=c(String(e)),_=Object.create(null),S=[],E=-1,C=0,A=[],N=0;if(u=[],h=-1,n-1>e){for(f=a(t,u);++h<f;)r=u[h],i=o(t[r],e+1,n),s=i.code,_[s]?i=_[s]:(S[C++]=s,i=_[s]={keys:[],sets:i.sets}),x=c(x+r+s),p(r)&&i.keys.push(parseInt(r,10))||i.keys.push(r);for(;++E<C;)if(r=S[E],i=_[r],u=i.keys,f=u.length,f>0)for(l=i.sets,d=-1,v=l.length,g=u[0];++d<v;){for(y=l[d],b=-1,m=y.length,w=new Array(m+1),w[0]=f>1&&u||g;++b<m;)w[b+1]=y[b];A[N++]=w}}else for(f=a(t,u),f>1?A[N++]=[u]:A[N++]=u;++h<f;)x=c(x+u[h]);return{code:x,sets:A}}function i(t){for(var e=-1,n=t.length;++e<n;){var r=t[e];h(r)&&(t[e]=s(r))}return t}function s(t){for(var e=-1,n=t.length-1,r=n>0;++e<=n;){var o=t[e];if(!p(o)){r=!1;break}t[e]=parseInt(o,10)}if(r===!0){t.sort(u);var i=t[0],s=t[n];if(n>=s-i)return{from:i,to:s}}return t}function u(t,e){return t-e}function a(t,e,n){var r=0;for(var o in t)e[r++]=o;return r>1&&e.sort(n),r}function c(t){for(var e=5381,n=-1,r=t.length;++n<r;)e=(e<<5)+e+t.charCodeAt(n);return String(e)}function p(t){return!h(t)&&t-parseFloat(t)+1>=0}var h=Array.isArray,f="object";e.exports=function(t){var e,n=[],s=0;for(var u in t)if(p(u)&&r(e=t[u]))for(var a=o(e,0,parseInt(u,10)).sets,c=-1,h=a.length;++c<h;)n[s++]=i(a[c]);return n}},{}],148:[function(t,e,n){function r(t,e,n){var i,s=e[n],u={},a=n+1;i=o(s,u);do{var c=t[i];c||(a===e.length?t[i]=null:c=t[i]={}),a<e.length&&r(c,e,a),u.done||(i=o(s,u))}while(!u.done)}var o=t(144);Array.isArray;e.exports=function(t){return t.reduce(function(t,e){return r(t,e,0),t},{})}},{144:144}],149:[function(t,e,n){},{}],150:[function(t,e,n){function r(){p=!1,u.length?c=u.concat(c):h=-1,c.length&&o()}function o(){if(!p){var t=setTimeout(r);p=!0;for(var e=c.length;e;){for(u=c,c=[];++h<e;)u&&u[h].run();h=-1,e=c.length}u=null,p=!1,clearTimeout(t)}}function i(t,e){this.fun=t,this.array=e}function s(){}var u,a=e.exports={},c=[],p=!1,h=-1;a.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];c.push(new i(t,e)),1!==c.length||p||setTimeout(o,0)},i.prototype.run=function(){this.fun.apply(null,this.array)},a.title="browser",a.browser=!0,a.env={},a.argv=[],a.version="",a.versions={},a.on=s,a.addListener=s,a.once=s,a.off=s,a.removeListener=s,a.removeAllListeners=s,a.emit=s,a.binding=function(t){throw new Error("process.binding is not supported")},a.cwd=function(){return"/"},a.chdir=function(t){throw new Error("process.chdir is not supported")},a.umask=function(){return 0}},{}],151:[function(t,e,n){"use strict";e.exports=t(156)},{156:156}],152:[function(t,e,n){"use strict";function r(){}function o(t){try{return t.then}catch(e){return y=e,b}}function i(t,e){try{return t(e)}catch(n){return y=n,b}}function s(t,e,n){try{t(e,n)}catch(r){return y=r,b}}function u(t){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof t)throw new TypeError("not a function");this._37=0,this._12=null,this._59=[],t!==r&&d(t,this)}function a(t,e,n){return new t.constructor(function(o,i){var s=new u(r);s.then(o,i),c(t,new l(e,n,s))})}function c(t,e){for(;3===t._37;)t=t._12;return 0===t._37?void t._59.push(e):void v(function(){var n=1===t._37?e.onFulfilled:e.onRejected;if(null===n)return void(1===t._37?p(e.promise,t._12):h(e.promise,t._12));var r=i(n,t._12);r===b?h(e.promise,y):p(e.promise,r)})}function p(t,e){if(e===t)return h(t,new TypeError("A promise cannot be resolved with itself."));if(e&&("object"==typeof e||"function"==typeof e)){var n=o(e);if(n===b)return h(t,y);if(n===t.then&&e instanceof u)return t._37=3,t._12=e,void f(t);if("function"==typeof n)return void d(n.bind(e),t)}t._37=1,t._12=e,f(t)}function h(t,e){t._37=2,t._12=e,f(t)}function f(t){for(var e=0;e<t._59.length;e++)c(t,t._59[e]);t._59=null}function l(t,e,n){this.onFulfilled="function"==typeof t?t:null,this.onRejected="function"==typeof e?e:null,this.promise=n}function d(t,e){var n=!1,r=s(t,function(t){n||(n=!0,p(e,t))},function(t){n||(n=!0,h(e,t))});n||r!==b||(n=!0,h(e,y))}var v=t(124),y=null,b={};e.exports=u,u._99=r,u.prototype.then=function(t,e){if(this.constructor!==u)return a(this,t,e);var n=new u(r);return c(this,new l(t,e,n)),n}},{124:124}],153:[function(t,e,n){"use strict";var r=t(152);e.exports=r,r.prototype.done=function(t,e){var n=arguments.length?this.then.apply(this,arguments):this;n.then(null,function(t){setTimeout(function(){throw t},0)})}},{152:152}],154:[function(t,e,n){"use strict";function r(t){var e=new o(o._99);return e._37=1,e._12=t,e}var o=t(152);e.exports=o;var i=r(!0),s=r(!1),u=r(null),a=r(void 0),c=r(0),p=r("");o.resolve=function(t){if(t instanceof o)return t;if(null===t)return u;if(void 0===t)return a;if(t===!0)return i;if(t===!1)return s;if(0===t)return c;if(""===t)return p;if("object"==typeof t||"function"==typeof t)try{var e=t.then;if("function"==typeof e)return new o(e.bind(t))}catch(n){return new o(function(t,e){e(n)})}return r(t)},o.all=function(t){var e=Array.prototype.slice.call(t);return new o(function(t,n){function r(s,u){if(u&&("object"==typeof u||"function"==typeof u)){if(u instanceof o&&u.then===o.prototype.then){for(;3===u._37;)u=u._12;return 1===u._37?r(s,u._12):(2===u._37&&n(u._12),void u.then(function(t){r(s,t)},n))}var a=u.then;if("function"==typeof a){var c=new o(a.bind(u));return void c.then(function(t){r(s,t)},n)}}e[s]=u,0===--i&&t(e)}if(0===e.length)return t([]);for(var i=e.length,s=0;s<e.length;s++)r(s,e[s])})},o.reject=function(t){return new o(function(e,n){n(t)})},o.race=function(t){return new o(function(e,n){t.forEach(function(t){o.resolve(t).then(e,n)})})},o.prototype["catch"]=function(t){return this.then(null,t)}},{152:152}],155:[function(t,e,n){"use strict";var r=t(152);e.exports=r,r.prototype["finally"]=function(t){return this.then(function(e){return r.resolve(t()).then(function(){return e})},function(e){return r.resolve(t()).then(function(){throw e})})}},{152:152}],156:[function(t,e,n){"use strict";e.exports=t(152),t(153),t(155),t(154),t(157)},{152:152,153:153,154:154,155:155,157:157}],157:[function(t,e,n){"use strict";var r=t(152),o=t(123);e.exports=r,r.denodeify=function(t,e){return e=e||1/0,function(){var n=this,o=Array.prototype.slice.call(arguments,0,e>0?e:0);return new r(function(e,r){o.push(function(t,n){t?r(t):e(n)});var i=t.apply(n,o);!i||"object"!=typeof i&&"function"!=typeof i||"function"!=typeof i.then||e(i)})}},r.nodeify=function(t){return function(){var e=Array.prototype.slice.call(arguments),n="function"==typeof e[e.length-1]?e.pop():null,i=this;try{return t.apply(this,arguments).nodeify(n,i)}catch(s){if(null===n||"undefined"==typeof n)return new r(function(t,e){e(s)});o(function(){n.call(i,s)})}}},r.prototype.nodeify=function(t,e){return"function"!=typeof t?this:void this.then(function(n){o(function(){t.call(e,null,n)})},function(n){o(function(){t.call(e,n)})})}},{123:123,152:152}],158:[function(e,n,r){(function(o){(function(i){var s={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},u=s[typeof window]&&window||this,a=s[typeof r]&&r&&!r.nodeType&&r,c=s[typeof n]&&n&&!n.nodeType&&n,p=(c&&c.exports===a&&a,s[typeof o]&&o);!p||p.global!==p&&p.window!==p||(u=p),"function"==typeof t&&t.amd?t(["rx"],function(t,e){return i(u,e,t)}):"object"==typeof n&&n&&n.exports===a?n.exports=i(u,n.exports,e(159)):u.Rx=i(u,{},u.Rx)}).call(this,function(t,e,n,r){function o(){try{return l.apply(this,arguments)}catch(t){return M.e=t,M}}function i(t){if(!E(t))throw new TypeError("fn must be a function");return l=t,o}function s(t,e,n){return new b(function(r){var o=!1,i=null,s=[];return t.subscribe(function(t){var u,a;try{a=e(t)}catch(c){return void r.onError(c)}if(u=0,o)try{u=n(a,i)}catch(p){return void r.onError(p)}else o=!0,i=a;u>0&&(i=a,s=[]),u>=0&&s.push(t)},function(t){r.onError(t)},function(){r.onNext(s),r.onCompleted()})},t)}function u(t){if(0===t.length)throw new D;return t[0]}function a(t,e,n,r){if(0>e)throw new R;return new b(function(o){var i=e;return t.subscribe(function(t){0===i--&&(o.onNext(t),o.onCompleted())},function(t){o.onError(t)},function(){n?(o.onNext(r),o.onCompleted()):o.onError(new R)})},t)}function c(t,e,n){return new b(function(r){var o=n,i=!1;return t.subscribe(function(t){i?r.onError(new Error("Sequence contains more than one element")):(o=t,i=!0)},function(t){r.onError(t)},function(){i||e?(r.onNext(o),r.onCompleted()):r.onError(new D)})},t)}function p(t,e,n){return new b(function(r){return t.subscribe(function(t){r.onNext(t),r.onCompleted()},function(t){r.onError(t)},function(){e?(r.onNext(n),r.onCompleted()):r.onError(new D)})},t)}function h(t,e,n){return new b(function(r){var o=n,i=!1;return t.subscribe(function(t){o=t,i=!0},function(t){r.onError(t)},function(){i||e?(r.onNext(o),r.onCompleted()):r.onError(new D)})},t)}function f(t,e,n,o){var i=j(e,n,3);return new b(function(e){var n=0;return t.subscribe(function(r){var s;try{s=i(r,n,t)}catch(u){return void e.onError(u)}s?(e.onNext(o?n:r),e.onCompleted()):n++},function(t){e.onError(t)},function(){e.onNext(o?-1:r),e.onCompleted()})},t)}var l,d=n.Observable,v=d.prototype,y=n.CompositeDisposable,b=n.AnonymousObservable,m=n.Disposable.empty,g=(n.internals.isEqual,n.helpers),w=g.not,x=g.defaultComparer,_=g.identity,S=g.defaultSubComparer,E=g.isFunction,C=g.isPromise,A=g.isArrayLike,N=g.isIterable,k=n.internals.inherits,O=d.fromPromise,P=d.from,j=n.internals.bindCallback,D=n.EmptyError,q=n.ObservableBase,R=n.ArgumentOutOfRangeError,M={e:{}};v.aggregate=function(){var t,e,n=!1,r=this;return 2===arguments.length?(n=!0,e=arguments[0],t=arguments[1]):t=arguments[0],new b(function(o){var i,s,u;return r.subscribe(function(r){!u&&(u=!0);try{i?s=t(s,r):(s=n?t(e,r):r,i=!0)}catch(a){return o.onError(a)}},function(t){o.onError(t)},function(){u&&o.onNext(s),!u&&n&&o.onNext(e),!u&&!n&&o.onError(new D),o.onCompleted()})},r)};var T=function(t){function e(e,n,r,o){this.source=e,this.acc=n,this.hasSeed=r,this.seed=o,t.call(this)}function n(t,e){this.o=t,this.acc=e.acc,this.hasSeed=e.hasSeed,this.seed=e.seed,this.hasAccumulation=!1,this.result=null,this.hasValue=!1,this.isStopped=!1}return k(e,t),e.prototype.subscribeCore=function(t){return this.source.subscribe(new n(t,this))},n.prototype.onNext=function(t){this.isStopped||(!this.hasValue&&(this.hasValue=!0),this.hasAccumulation?this.result=i(this.acc)(this.result,t):(this.result=this.hasSeed?i(this.acc)(this.seed,t):t,this.hasAccumulation=!0),this.result===M&&this.o.onError(this.result.e))},n.prototype.onError=function(t){this.isStopped||(this.isStopped=!0,this.o.onError(t))},n.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,this.hasValue&&this.o.onNext(this.result),!this.hasValue&&this.hasSeed&&this.o.onNext(this.seed),!this.hasValue&&!this.hasSeed&&this.o.onError(new D),this.o.onCompleted())},n.prototype.dispose=function(){this.isStopped=!0},n.prototype.fail=function(t){return this.isStopped?!1:(this.isStopped=!0,this.o.onError(t),!0)},e}(q);return v.reduce=function(t){var e=!1;if(2===arguments.length){e=!0;var n=arguments[1]}return new T(this,t,e,n)},v.some=function(t,e){var n=this;return t?n.filter(t,e).some():new b(function(t){return n.subscribe(function(){t.onNext(!0),t.onCompleted()},function(e){t.onError(e)},function(){t.onNext(!1),t.onCompleted()})},n)},v.any=function(){return this.some.apply(this,arguments)},v.isEmpty=function(){return this.any().map(w)},v.every=function(t,e){return this.filter(function(e){return!t(e)},e).some().map(w)},v.all=function(){return this.every.apply(this,arguments)},v.includes=function(t,e){function n(t,e){return 0===t&&0===e||t===e||isNaN(t)&&isNaN(e)}var r=this;return new b(function(o){var i=0,s=+e||0;return Math.abs(s)===1/0&&(s=0),0>s?(o.onNext(!1),o.onCompleted(),m):r.subscribe(function(e){i++>=s&&n(e,t)&&(o.onNext(!0),o.onCompleted())},function(t){o.onError(t)},function(){o.onNext(!1),o.onCompleted()})},this)},v.contains=function(t,e){v.includes(t,e)},v.count=function(t,e){return t?this.filter(t,e).count():this.reduce(function(t){return t+1},0)},v.indexOf=function(t,e){var n=this;return new b(function(r){var o=0,i=+e||0;return Math.abs(i)===1/0&&(i=0),0>i?(r.onNext(-1),r.onCompleted(),m):n.subscribe(function(e){o>=i&&e===t&&(r.onNext(o),r.onCompleted()),o++},function(t){r.onError(t)},function(){r.onNext(-1),r.onCompleted()})},n)},v.sum=function(t,e){return t&&E(t)?this.map(t,e).sum():this.reduce(function(t,e){return t+e},0)},v.minBy=function(t,e){return e||(e=S),s(this,t,function(t,n){return-1*e(t,n)})},v.min=function(t){return this.minBy(_,t).map(function(t){return u(t)})},v.maxBy=function(t,e){return e||(e=S),s(this,t,e)},v.max=function(t){return this.maxBy(_,t).map(function(t){return u(t)})},v.average=function(t,e){return t&&E(t)?this.map(t,e).average():this.reduce(function(t,e){return{sum:t.sum+e,count:t.count+1}},{sum:0,count:0}).map(function(t){if(0===t.count)throw new D;return t.sum/t.count})},v.sequenceEqual=function(t,e){var n=this;return e||(e=x),new b(function(r){var o=!1,i=!1,s=[],u=[],a=n.subscribe(function(t){var n,o;if(u.length>0){o=u.shift();try{n=e(o,t)}catch(a){return void r.onError(a)}n||(r.onNext(!1),r.onCompleted())}else i?(r.onNext(!1),r.onCompleted()):s.push(t)},function(t){r.onError(t)},function(){o=!0,0===s.length&&(u.length>0?(r.onNext(!1),r.onCompleted()):i&&(r.onNext(!0),r.onCompleted()))});(A(t)||N(t))&&(t=P(t)),C(t)&&(t=O(t));var c=t.subscribe(function(t){var n;if(s.length>0){var i=s.shift();try{n=e(i,t)}catch(a){return void r.onError(a)}n||(r.onNext(!1),r.onCompleted())}else o?(r.onNext(!1),r.onCompleted()):u.push(t)},function(t){r.onError(t)},function(){i=!0,0===u.length&&(s.length>0?(r.onNext(!1),r.onCompleted()):o&&(r.onNext(!0),r.onCompleted()))});return new y(a,c)},n)},v.elementAt=function(t){return a(this,t,!1)},v.elementAtOrDefault=function(t,e){return a(this,t,!0,e)},v.single=function(t,e){return t&&E(t)?this.where(t,e).single():c(this,!1)},v.singleOrDefault=function(t,e,n){return t&&E(t)?this.filter(t,n).singleOrDefault(null,e):c(this,!0,e)},v.first=function(t,e){return t?this.where(t,e).first():p(this,!1)},v.firstOrDefault=function(t,e,n){return t?this.where(t).firstOrDefault(null,e):p(this,!0,e)},v.last=function(t,e){return t?this.where(t,e).last():h(this,!1)},v.lastOrDefault=function(t,e,n){return t?this.where(t,n).lastOrDefault(null,e):h(this,!0,e)},v.find=function(t,e){return f(this,t,e,!1)},v.findIndex=function(t,e){return f(this,t,e,!0)},v.toSet=function(){if("undefined"==typeof t.Set)throw new TypeError;var e=this;return new b(function(n){var r=new t.Set;return e.subscribe(function(t){r.add(t)},function(t){n.onError(t)},function(){n.onNext(r),n.onCompleted()})},e)},v.toMap=function(e,n){if("undefined"==typeof t.Map)throw new TypeError;var r=this;return new b(function(o){var i=new t.Map;return r.subscribe(function(t){var r;try{r=e(t)}catch(s){return void o.onError(s)}var u=t;if(n)try{u=n(t)}catch(s){return void o.onError(s)}i.set(r,u)},function(t){o.onError(t)},function(){o.onNext(i),o.onCompleted()})},r)},n})}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{159:159}],159:[function(e,n,r){(function(e,o){(function(i){function u(t){for(var e=[],n=0,r=t.length;r>n;n++)e.push(t[n]);return e}function a(t,e){if(ct&&e.stack&&"object"==typeof t&&null!==t&&t.stack&&-1===t.stack.indexOf(lt)){for(var n=[],r=e;r;r=r.source)r.stack&&n.unshift(r.stack);n.unshift(t.stack);var o=n.join("\n"+lt+"\n");t.stack=c(o)}}function c(t){for(var e=t.split("\n"),n=[],r=0,o=e.length;o>r;r++){var i=e[r];p(i)||h(i)||!i||n.push(i)}return n.join("\n")}function p(t){var e=l(t);if(!e)return!1;var n=e[0],r=e[1];return n===ht&&r>=ft&&$n>=r}function h(t){return-1!==t.indexOf("(module.js:")||-1!==t.indexOf("(node.js:")}function f(){if(ct)try{throw new Error}catch(t){var e=t.stack.split("\n"),n=e[0].indexOf("@")>0?e[1]:e[2],r=l(n);if(!r)return;return ht=r[0],r[1]}}function l(t){var e=/at .+ \((.+):(\d+):(?:\d+)\)$/.exec(t);if(e)return[e[1],Number(e[2])];var n=/at ([^ ]+):(\d+):(?:\d+)$/.exec(t);if(n)return[n[1],Number(n[2])];var r=/.*@(.+):(\d+)$/.exec(t);return r?[r[1],Number(r[2])]:void 0}function d(t){var e=[];if(!Ht(t))return e;Ut.nonEnumArgs&&t.length&&Xt(t)&&(t=Yt.call(t));var n=Ut.enumPrototypes&&"function"==typeof t,r=Ut.enumErrorProps&&(t===Jt||t instanceof Error);for(var o in t)n&&"prototype"==o||r&&("message"==o||"name"==o)||e.push(o);if(Ut.nonEnumShadows&&t!==It){var i=t.constructor,s=-1,u=kt;if(t===(i&&i.prototype))var a=t===Lt?$t:t===Jt?qt:Wt.call(t),c=Ft[a];for(;++s<u;)o=Nt[s],c&&c[o]||!zt.call(t,o)||e.push(o)}return e}function v(t,e,n){for(var r=-1,o=n(t),i=o.length;++r<i;){var s=o[r];if(e(t[s],s,t)===!1)break}return t}function y(t,e){return v(t,e,d)}function b(t){return"function"!=typeof t.toString&&"string"==typeof(t+"")}function m(t,e,n,r){if(t===e)return 0!==t||1/t==1/e;var o=typeof t,i=typeof e;if(t===t&&(null==t||null==e||"function"!=o&&"object"!=o&&"function"!=i&&"object"!=i))return!1;var s=Wt.call(t),u=Wt.call(e);if(s==Ot&&(s=Tt),u==Ot&&(u=Tt),s!=u)return!1;switch(s){case jt:case Dt:return+t==+e;case Mt:return t!=+t?e!=+e:0==t?1/t==1/e:t==+e;case Vt:case $t:return t==String(e)}var a=s==Pt;if(!a){if(s!=Tt||!Ut.nodeClass&&(b(t)||b(e)))return!1;var c=!Ut.argsObject&&Xt(t)?Object:t.constructor,p=!Ut.argsObject&&Xt(e)?Object:e.constructor;if(!(c==p||zt.call(t,"constructor")&&zt.call(e,"constructor")||at(c)&&c instanceof c&&at(p)&&p instanceof p||!("constructor"in t&&"constructor"in e)))return!1}n||(n=[]),r||(r=[]);for(var h=n.length;h--;)if(n[h]==t)return r[h]==e;var f=0,l=!0;if(n.push(t),r.push(e),a){if(h=t.length,f=e.length,l=f==h)for(;f--;){var d=e[f];if(!(l=m(t[f],d,n,r)))break}}else y(e,function(e,o,i){return zt.call(i,o)?(f++,l=zt.call(t,o)&&m(t[o],e,n,r)):void 0}),l&&y(t,function(t,e,n){return zt.call(n,e)?l=--f>-1:void 0});return n.pop(),r.pop(),l}function g(t,e){for(var n=new Array(t),r=0;t>r;r++)n[r]=e();return n}function w(){try{return Qt.apply(this,arguments)}catch(t){return ne.e=t,ne}}function x(t){if(!at(t))throw new TypeError("fn must be a function");return Qt=t,w}function _(t){throw t}function S(t,e){this.id=t,this.value=e}function E(t,e){this.scheduler=t,this.disposable=e,this.isDisposed=!1}function C(t,e){e.isDisposed||(e.isDisposed=!0,e.disposable.dispose())}function A(t){this._s=s}function N(t){this._s=s,this._l=s.length,this._i=0}function k(t){this._a=t}function O(t){this._a=t,this._l=q(t),this._i=0}function P(t){return"number"==typeof t&&X.isFinite(t)}function j(t){var e,n=t[xt];if(!n&&"string"==typeof t)return e=new A(t),e[xt]();if(!n&&t.length!==i)return e=new k(t),e[xt]();if(!n)throw new TypeError("Object is not iterable");return t[xt]()}function D(t){var e=+t;return 0===e?e:isNaN(e)?e:0>e?-1:1}function q(t){var e=+t.length;return isNaN(e)?0:0!==e&&P(e)?(e=D(e)*Math.floor(Math.abs(e)),0>=e?0:e>en?en:e):e}function R(t,e){this.observer=t,this.parent=e}function M(t,e){return me(t)||(t=_e),new rn(e,t)}function T(t,e){this.observer=t,this.parent=e}function V(t,e){this.observer=t,this.parent=e}function $(t,e){return new qn(function(n){var r=new fe,o=new le;return o.setDisposable(r),r.setDisposable(t.subscribe(function(t){n.onNext(t)},function(t){try{var r=e(t)}catch(i){return n.onError(i)}ut(r)&&(r=Xe(r));var s=new fe;o.setDisposable(s),s.setDisposable(r.subscribe(n))},function(t){n.onCompleted(t)})),o},t)}function W(){return!1}function z(t,e){var n=this;return new qn(function(r){var o=0,i=t.length;return n.subscribe(function(n){if(i>o){var s=t[o++],u=x(e)(n,s);if(u===ne)return r.onError(u.e);r.onNext(u)}else r.onCompleted()},function(t){r.onError(t)},function(){r.onCompleted()})},n)}function W(){return!1}function G(){return[]}function W(){return!1}function J(){return[]}function I(t,e){this.observer=t,this.accumulator=e.accumulator,this.hasSeed=e.hasSeed,this.seed=e.seed,this.hasAccumulation=!1,this.accumulation=null,this.hasValue=!1,this.isStopped=!1}function L(t,e,n){var r=At(e,n,3);return t.map(function(e,n){var o=r(e,n,t);return ut(o)&&(o=Xe(o)),(Et(o)||St(o))&&(o=nn(o)),o}).concatAll()}function B(t,e,n){for(var r=0,o=t.length;o>r;r++)if(n(t[r],e))return r;return-1}function F(t){this.comparer=t,this.set=[]}function U(t,e,n){var r=At(e,n,3);return t.map(function(e,n){var o=r(e,n,t);return ut(o)&&(o=Xe(o)),(Et(o)||St(o))&&(o=nn(o)),o}).mergeAll()}var H={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},X=H[typeof window]&&window||this,Q=H[typeof r]&&r&&!r.nodeType&&r,K=H[typeof n]&&n&&!n.nodeType&&n,Y=K&&K.exports===Q&&Q,Z=H[typeof o]&&o;!Z||Z.global!==Z&&Z.window!==Z||(X=Z);var tt={internals:{},config:{Promise:X.Promise},helpers:{}},et=tt.helpers.noop=function(){},nt=(tt.helpers.notDefined=function(t){return"undefined"==typeof t},tt.helpers.identity=function(t){return t}),rt=(tt.helpers.pluck=function(t){return function(e){return e[t]}},tt.helpers.just=function(t){return function(){return t}},tt.helpers.defaultNow=Date.now),ot=tt.helpers.defaultComparer=function(t,e){return Kt(t,e)},it=tt.helpers.defaultSubComparer=function(t,e){return t>e?1:e>t?-1:0},st=(tt.helpers.defaultKeySerializer=function(t){return t.toString()},tt.helpers.defaultError=function(t){throw t}),ut=tt.helpers.isPromise=function(t){return!!t&&"function"!=typeof t.subscribe&&"function"==typeof t.then},at=(tt.helpers.asArray=function(){return Array.prototype.slice.call(arguments)},tt.helpers.not=function(t){return!t},tt.helpers.isFunction=function(){var t=function(t){return"function"==typeof t||!1};return t(/x/)&&(t=function(t){return"function"==typeof t&&"[object Function]"==Wt.call(t)}),t}());tt.config.longStackSupport=!1;var ct=!1;try{throw new Error}catch(pt){ct=!!pt.stack}var ht,ft=f(),lt="From previous event:",dt=tt.EmptyError=function(){this.message="Sequence contains no elements.",Error.call(this)};dt.prototype=Error.prototype;var vt=tt.ObjectDisposedError=function(){this.message="Object has been disposed",Error.call(this)};vt.prototype=Error.prototype;var yt=tt.ArgumentOutOfRangeError=function(){this.message="Argument out of range",Error.call(this)};yt.prototype=Error.prototype;var bt=tt.NotSupportedError=function(t){this.message=t||"This operation is not supported",Error.call(this)};bt.prototype=Error.prototype;var mt=tt.NotImplementedError=function(t){this.message=t||"This operation is not implemented",Error.call(this)};mt.prototype=Error.prototype;var gt=tt.helpers.notImplemented=function(){throw new mt},wt=tt.helpers.notSupported=function(){throw new bt},xt="function"==typeof Symbol&&Symbol.iterator||"_es6shim_iterator_";X.Set&&"function"==typeof(new X.Set)["@@iterator"]&&(xt="@@iterator");var _t=tt.doneEnumerator={done:!0,value:i},St=tt.helpers.isIterable=function(t){return t[xt]!==i},Et=tt.helpers.isArrayLike=function(t){return t&&t.length!==i};tt.helpers.iterator=xt;var Ct,At=tt.internals.bindCallback=function(t,e,n){if("undefined"==typeof e)return t;switch(n){case 0:return function(){return t.call(e)};case 1:return function(n){return t.call(e,n)};case 2:return function(n,r){return t.call(e,n,r)};case 3:return function(n,r,o){return t.call(e,n,r,o)}}return function(){return t.apply(e,arguments)}},Nt=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],kt=Nt.length,Ot="[object Arguments]",Pt="[object Array]",jt="[object Boolean]",Dt="[object Date]",qt="[object Error]",Rt="[object Function]",Mt="[object Number]",Tt="[object Object]",Vt="[object RegExp]",$t="[object String]",Wt=Object.prototype.toString,zt=Object.prototype.hasOwnProperty,Gt=Wt.call(arguments)==Ot,Jt=Error.prototype,It=Object.prototype,Lt=String.prototype,Bt=It.propertyIsEnumerable;try{Ct=!(Wt.call(document)==Tt&&!({toString:0}+""))}catch(pt){Ct=!0}var Ft={};Ft[Pt]=Ft[Dt]=Ft[Mt]={constructor:!0,toLocaleString:!0,toString:!0,valueOf:!0},Ft[jt]=Ft[$t]={constructor:!0,toString:!0,valueOf:!0},Ft[qt]=Ft[Rt]=Ft[Vt]={constructor:!0,toString:!0},Ft[Tt]={constructor:!0};var Ut={};!function(){var t=function(){this.x=1},e=[];t.prototype={valueOf:1,y:1};for(var n in new t)e.push(n);for(n in arguments);Ut.enumErrorProps=Bt.call(Jt,"message")||Bt.call(Jt,"name"),Ut.enumPrototypes=Bt.call(t,"prototype"),Ut.nonEnumArgs=0!=n,Ut.nonEnumShadows=!/valueOf/.test(e)}(1);var Ht=tt.internals.isObject=function(t){var e=typeof t;return t&&("function"==e||"object"==e)||!1},Xt=function(t){return t&&"object"==typeof t?Wt.call(t)==Ot:!1};Gt||(Xt=function(t){return t&&"object"==typeof t?zt.call(t,"callee"):!1});var Qt,Kt=tt.internals.isEqual=function(t,e){return m(t,e,[],[])},Yt=({}.hasOwnProperty,Array.prototype.slice),Zt=this.inherits=tt.internals.inherits=function(t,e){function n(){this.constructor=t}n.prototype=e.prototype,t.prototype=new n},te=tt.internals.addProperties=function(t){for(var e=[],n=1,r=arguments.length;r>n;n++)e.push(arguments[n]);for(var o=0,i=e.length;i>o;o++){var s=e[o];for(var u in s)t[u]=s[u]}},ee=tt.internals.addRef=function(t,e){return new qn(function(n){return new ie(e.getDisposable(),t.subscribe(n))})},ne={e:{}};S.prototype.compareTo=function(t){var e=this.value.compareTo(t.value);return 0===e&&(e=this.id-t.id),e};var re=tt.internals.PriorityQueue=function(t){this.items=new Array(t),this.length=0},oe=re.prototype;oe.isHigherPriority=function(t,e){return this.items[t].compareTo(this.items[e])<0},oe.percolate=function(t){if(!(t>=this.length||0>t)){var e=t-1>>1;if(!(0>e||e===t)&&this.isHigherPriority(t,e)){var n=this.items[t];this.items[t]=this.items[e],this.items[e]=n,this.percolate(e)}}},oe.heapify=function(t){if(+t||(t=0),!(t>=this.length||0>t)){var e=2*t+1,n=2*t+2,r=t;if(e<this.length&&this.isHigherPriority(e,r)&&(r=e),n<this.length&&this.isHigherPriority(n,r)&&(r=n),r!==t){var o=this.items[t];this.items[t]=this.items[r],this.items[r]=o,this.heapify(r)}}},oe.peek=function(){return this.items[0].value},oe.removeAt=function(t){this.items[t]=this.items[--this.length],this.items[this.length]=i,this.heapify()},oe.dequeue=function(){var t=this.peek();return this.removeAt(0),t},oe.enqueue=function(t){var e=this.length++;this.items[e]=new S(re.count++,t),this.percolate(e)},oe.remove=function(t){for(var e=0;e<this.length;e++)if(this.items[e].value===t)return this.removeAt(e),!0;return!1},re.count=0;var ie=tt.CompositeDisposable=function(){var t,e,n=[];if(Array.isArray(arguments[0]))n=arguments[0],e=n.length;else for(e=arguments.length,n=new Array(e),t=0;e>t;t++)n[t]=arguments[t];for(t=0;e>t;t++)if(!pe(n[t]))throw new TypeError("Not a disposable");this.disposables=n,this.isDisposed=!1,this.length=n.length},se=ie.prototype;se.add=function(t){this.isDisposed?t.dispose():(this.disposables.push(t),this.length++)},se.remove=function(t){var e=!1;if(!this.isDisposed){var n=this.disposables.indexOf(t);-1!==n&&(e=!0,this.disposables.splice(n,1),this.length--,t.dispose())}return e},se.dispose=function(){
3472 if(!this.isDisposed){this.isDisposed=!0;for(var t=this.disposables.length,e=new Array(t),n=0;t>n;n++)e[n]=this.disposables[n];for(this.disposables=[],this.length=0,n=0;t>n;n++)e[n].dispose()}};var ue=tt.Disposable=function(t){this.isDisposed=!1,this.action=t||et};ue.prototype.dispose=function(){this.isDisposed||(this.action(),this.isDisposed=!0)};var ae=ue.create=function(t){return new ue(t)},ce=ue.empty={dispose:et},pe=ue.isDisposable=function(t){return t&&at(t.dispose)},he=ue.checkDisposed=function(t){if(t.isDisposed)throw new vt},fe=tt.SingleAssignmentDisposable=function(){this.isDisposed=!1,this.current=null};fe.prototype.getDisposable=function(){return this.current},fe.prototype.setDisposable=function(t){if(this.current)throw new Error("Disposable has already been assigned");var e=this.isDisposed;!e&&(this.current=t),e&&t&&t.dispose()},fe.prototype.dispose=function(){if(!this.isDisposed){this.isDisposed=!0;var t=this.current;this.current=null}t&&t.dispose()};var le=tt.SerialDisposable=function(){this.isDisposed=!1,this.current=null};le.prototype.getDisposable=function(){return this.current},le.prototype.setDisposable=function(t){var e=this.isDisposed;if(!e){var n=this.current;this.current=t}n&&n.dispose(),e&&t&&t.dispose()},le.prototype.dispose=function(){if(!this.isDisposed){this.isDisposed=!0;var t=this.current;this.current=null}t&&t.dispose()};var de=tt.RefCountDisposable=function(){function t(t){this.disposable=t,this.disposable.count++,this.isInnerDisposed=!1}function e(t){this.underlyingDisposable=t,this.isDisposed=!1,this.isPrimaryDisposed=!1,this.count=0}return t.prototype.dispose=function(){this.disposable.isDisposed||this.isInnerDisposed||(this.isInnerDisposed=!0,this.disposable.count--,0===this.disposable.count&&this.disposable.isPrimaryDisposed&&(this.disposable.isDisposed=!0,this.disposable.underlyingDisposable.dispose()))},e.prototype.dispose=function(){this.isDisposed||this.isPrimaryDisposed||(this.isPrimaryDisposed=!0,0===this.count&&(this.isDisposed=!0,this.underlyingDisposable.dispose()))},e.prototype.getDisposable=function(){return this.isDisposed?ce:new t(this)},e}();E.prototype.dispose=function(){this.scheduler.scheduleWithState(this,C)};var ve=tt.internals.ScheduledItem=function(t,e,n,r,o){this.scheduler=t,this.state=e,this.action=n,this.dueTime=r,this.comparer=o||it,this.disposable=new fe};ve.prototype.invoke=function(){this.disposable.setDisposable(this.invokeCore())},ve.prototype.compareTo=function(t){return this.comparer(this.dueTime,t.dueTime)},ve.prototype.isCancelled=function(){return this.disposable.isDisposed},ve.prototype.invokeCore=function(){return this.action(this.scheduler,this.state)};var ye=tt.Scheduler=function(){function t(t,e,n,r){this.now=t,this._schedule=e,this._scheduleRelative=n,this._scheduleAbsolute=r}function e(t,e){return e(),ce}t.isScheduler=function(e){return e instanceof t};var n=t.prototype;return n.schedule=function(t){return this._schedule(t,e)},n.scheduleWithState=function(t,e){return this._schedule(t,e)},n.scheduleWithRelative=function(t,n){return this._scheduleRelative(n,t,e)},n.scheduleWithRelativeAndState=function(t,e,n){return this._scheduleRelative(t,e,n)},n.scheduleWithAbsolute=function(t,n){return this._scheduleAbsolute(n,t,e)},n.scheduleWithAbsoluteAndState=function(t,e,n){return this._scheduleAbsolute(t,e,n)},t.now=rt,t.normalize=function(t){return 0>t&&(t=0),t},t}(),be=ye.normalize,me=ye.isScheduler;!function(t){function e(t,e){function n(e){o(e,function(e){var r=!1,o=!1,s=t.scheduleWithState(e,function(t,e){return r?i.remove(s):o=!0,n(e),ce});o||(i.add(s),r=!0)})}var r=e[0],o=e[1],i=new ie;return n(r),i}function n(t,e,n){function r(e){i(e,function(e,o){var i=!1,u=!1,a=t[n](e,o,function(t,e){return i?s.remove(a):u=!0,r(e),ce});u||(s.add(a),i=!0)})}var o=e[0],i=e[1],s=new ie;return r(o),s}function r(t,e){t(function(n){e(t,n)})}t.scheduleRecursive=function(t){return this.scheduleRecursiveWithState(t,r)},t.scheduleRecursiveWithState=function(t,n){return this.scheduleWithState([t,n],e)},t.scheduleRecursiveWithRelative=function(t,e){return this.scheduleRecursiveWithRelativeAndState(e,t,r)},t.scheduleRecursiveWithRelativeAndState=function(t,e,r){return this._scheduleRelative([t,r],e,function(t,e){return n(t,e,"scheduleWithRelativeAndState")})},t.scheduleRecursiveWithAbsolute=function(t,e){return this.scheduleRecursiveWithAbsoluteAndState(e,t,r)},t.scheduleRecursiveWithAbsoluteAndState=function(t,e,r){return this._scheduleAbsolute([t,r],e,function(t,e){return n(t,e,"scheduleWithAbsoluteAndState")})}}(ye.prototype),function(t){ye.prototype.schedulePeriodic=function(t,e){return this.schedulePeriodicWithState(null,t,e)},ye.prototype.schedulePeriodicWithState=function(t,e,n){if("undefined"==typeof X.setInterval)throw new bt;e=be(e);var r=t,o=X.setInterval(function(){r=n(r)},e);return ae(function(){X.clearInterval(o)})}}(ye.prototype),function(t){t.catchError=t["catch"]=function(t){return new Ae(this,t)}}(ye.prototype);var ge,we,xe=(tt.internals.SchedulePeriodicRecursive=function(){function t(t,e){e(0,this._period);try{this._state=this._action(this._state)}catch(n){throw this._cancel.dispose(),n}}function e(t,e,n,r){this._scheduler=t,this._state=e,this._period=n,this._action=r}return e.prototype.start=function(){var e=new fe;return this._cancel=e,e.setDisposable(this._scheduler.scheduleRecursiveWithRelativeAndState(0,this._period,t.bind(this))),e},e}(),ye.immediate=function(){function t(t,e){return e(this,t)}return new ye(rt,t,wt,wt)}()),_e=ye.currentThread=function(){function t(){for(;n.length>0;){var t=n.dequeue();!t.isCancelled()&&t.invoke()}}function e(e,r){var o=new ve(this,e,r,this.now());if(n)n.enqueue(o);else{n=new re(4),n.enqueue(o);var i=x(t)();if(n=null,i===ne)return _(i.e)}return o.disposable}var n,r=new ye(rt,e,wt,wt);return r.scheduleRequired=function(){return!n},r}(),Se=function(){var t,e=et;if(X.setTimeout)t=X.setTimeout,e=X.clearTimeout;else{if(!X.WScript)throw new bt;t=function(t,e){X.WScript.Sleep(e),t()}}return{setTimeout:t,clearTimeout:e}}(),Ee=Se.setTimeout,Ce=Se.clearTimeout;!function(){function t(e){if(s)Ee(function(){t(e)},0);else{var n=i[e];if(n){s=!0;var r=x(n)();if(we(e),s=!1,r===ne)return _(r.e)}}}function n(){if(!X.postMessage||X.importScripts)return!1;var t=!1,e=X.onmessage;return X.onmessage=function(){t=!0},X.postMessage("","*"),X.onmessage=e,t}function r(e){"string"==typeof e.data&&e.data.substring(0,c.length)===c&&t(e.data.substring(c.length))}var o=1,i={},s=!1;we=function(t){delete i[t]};var u=RegExp("^"+String(Wt).replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString| for [^\]]+/g,".*?")+"$"),a="function"==typeof(a=Z&&Y&&Z.setImmediate)&&!u.test(a)&&a;if(at(a))ge=function(e){var n=o++;return i[n]=e,a(function(){t(n)}),n};else if("undefined"!=typeof e&&"[object process]"==={}.toString.call(e))ge=function(n){var r=o++;return i[r]=n,e.nextTick(function(){t(r)}),r};else if(n()){var c="ms.rx.schedule"+Math.random();X.addEventListener?X.addEventListener("message",r,!1):X.attachEvent?X.attachEvent("onmessage",r):X.onmessage=r,ge=function(t){var e=o++;return i[e]=t,X.postMessage(c+currentId,"*"),e}}else if(X.MessageChannel){var p=new X.MessageChannel;p.port1.onmessage=function(e){t(e.data)},ge=function(t){var e=o++;return i[e]=t,p.port2.postMessage(e),e}}else ge="document"in X&&"onreadystatechange"in X.document.createElement("script")?function(e){var n=X.document.createElement("script"),r=o++;return i[r]=e,n.onreadystatechange=function(){t(r),n.onreadystatechange=null,n.parentNode.removeChild(n),n=null},X.document.documentElement.appendChild(n),r}:function(e){var n=o++;return i[n]=e,Ee(function(){t(n)},0),n}}();var Ae=(ye.timeout=ye["default"]=function(){function t(t,e){var n=this,r=new fe,o=ge(function(){!r.isDisposed&&r.setDisposable(e(n,t))});return new ie(r,ae(function(){we(o)}))}function e(t,e,n){var r=this,o=ye.normalize(e),i=new fe;if(0===o)return r.scheduleWithState(t,n);var s=Ee(function(){!i.isDisposed&&i.setDisposable(n(r,t))},o);return new ie(i,ae(function(){Ce(s)}))}function n(t,e,n){return this.scheduleWithRelativeAndState(t,e-this.now(),n)}return new ye(rt,t,e,n)}(),function(t){function e(t,e){return this._scheduler.scheduleWithState(t,this._wrap(e))}function n(t,e,n){return this._scheduler.scheduleWithRelativeAndState(t,e,this._wrap(n))}function r(t,e,n){return this._scheduler.scheduleWithAbsoluteAndState(t,e,this._wrap(n))}function o(o,i){this._scheduler=o,this._handler=i,this._recursiveOriginal=null,this._recursiveWrapper=null,t.call(this,this._scheduler.now.bind(this._scheduler),e,n,r)}return Zt(o,t),o.prototype._clone=function(t){return new o(t,this._handler)},o.prototype._wrap=function(t){var e=this;return function(n,r){try{return t(e._getRecursiveWrapper(n),r)}catch(o){if(!e._handler(o))throw o;return ce}}},o.prototype._getRecursiveWrapper=function(t){if(this._recursiveOriginal!==t){this._recursiveOriginal=t;var e=this._clone(t);e._recursiveOriginal=t,e._recursiveWrapper=e,this._recursiveWrapper=e}return this._recursiveWrapper},o.prototype.schedulePeriodicWithState=function(t,e,n){var r=this,o=!1,i=new fe;return i.setDisposable(this._scheduler.schedulePeriodicWithState(t,e,function(t){if(o)return null;try{return n(t)}catch(e){if(o=!0,!r._handler(e))throw e;return i.dispose(),null}})),i},o}(ye)),Ne=tt.Notification=function(){function t(t,e,n,r,o,i){this.kind=t,this.value=e,this.exception=n,this._accept=r,this._acceptObservable=o,this.toString=i}return t.prototype.accept=function(t,e,n){return t&&"object"==typeof t?this._acceptObservable(t):this._accept(t,e,n)},t.prototype.toObservable=function(t){var e=this;return me(t)||(t=xe),new qn(function(n){return t.scheduleWithState(e,function(t,e){e._acceptObservable(n),"N"===e.kind&&n.onCompleted()})})},t}(),ke=Ne.createOnNext=function(){function t(t){return t(this.value)}function e(t){return t.onNext(this.value)}function n(){return"OnNext("+this.value+")"}return function(r){return new Ne("N",r,null,t,e,n)}}(),Oe=Ne.createOnError=function(){function t(t,e){return e(this.exception)}function e(t){return t.onError(this.exception)}function n(){return"OnError("+this.exception+")"}return function(r){return new Ne("E",null,r,t,e,n)}}(),Pe=Ne.createOnCompleted=function(){function t(t,e,n){return n()}function e(t){return t.onCompleted()}function n(){return"OnCompleted()"}return function(){return new Ne("C",null,null,t,e,n)}}(),je=tt.Observer=function(){};je.prototype.toNotifier=function(){var t=this;return function(e){return e.accept(t)}},je.prototype.asObserver=function(){return new Me(this.onNext.bind(this),this.onError.bind(this),this.onCompleted.bind(this))},je.prototype.checked=function(){return new Te(this)};var De=je.create=function(t,e,n){return t||(t=et),e||(e=st),n||(n=et),new Me(t,e,n)};je.fromNotifier=function(t,e){return new Me(function(n){return t.call(e,ke(n))},function(n){return t.call(e,Oe(n))},function(){return t.call(e,Pe())})},je.prototype.notifyOn=function(t){return new $e(t,this)},je.prototype.makeSafe=function(t){return new AnonymousSafeObserver(this._onNext,this._onError,this._onCompleted,t)};var qe,Re=tt.internals.AbstractObserver=function(t){function e(){this.isStopped=!1,t.call(this)}return Zt(e,t),e.prototype.next=gt,e.prototype.error=gt,e.prototype.completed=gt,e.prototype.onNext=function(t){this.isStopped||this.next(t)},e.prototype.onError=function(t){this.isStopped||(this.isStopped=!0,this.error(t))},e.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,this.completed())},e.prototype.dispose=function(){this.isStopped=!0},e.prototype.fail=function(t){return this.isStopped?!1:(this.isStopped=!0,this.error(t),!0)},e}(je),Me=tt.AnonymousObserver=function(t){function e(e,n,r){t.call(this),this._onNext=e,this._onError=n,this._onCompleted=r}return Zt(e,t),e.prototype.next=function(t){this._onNext(t)},e.prototype.error=function(t){this._onError(t)},e.prototype.completed=function(){this._onCompleted()},e}(Re),Te=function(t){function e(e){t.call(this),this._observer=e,this._state=0}Zt(e,t);var n=e.prototype;return n.onNext=function(t){this.checkAccess();var e=x(this._observer.onNext).call(this._observer,t);this._state=0,e===ne&&_(e.e)},n.onError=function(t){this.checkAccess();var e=x(this._observer.onError).call(this._observer,t);this._state=2,e===ne&&_(e.e)},n.onCompleted=function(){this.checkAccess();var t=x(this._observer.onCompleted).call(this._observer);this._state=2,t===ne&&_(t.e)},n.checkAccess=function(){if(1===this._state)throw new Error("Re-entrancy detected");if(2===this._state)throw new Error("Observer completed");0===this._state&&(this._state=1)},e}(je),Ve=tt.internals.ScheduledObserver=function(t){function e(e,n){t.call(this),this.scheduler=e,this.observer=n,this.isAcquired=!1,this.hasFaulted=!1,this.queue=[],this.disposable=new le}return Zt(e,t),e.prototype.next=function(t){var e=this;this.queue.push(function(){e.observer.onNext(t)})},e.prototype.error=function(t){var e=this;this.queue.push(function(){e.observer.onError(t)})},e.prototype.completed=function(){var t=this;this.queue.push(function(){t.observer.onCompleted()})},e.prototype.ensureActive=function(){var t=!1,e=this;!this.hasFaulted&&this.queue.length>0&&(t=!this.isAcquired,this.isAcquired=!0),t&&this.disposable.setDisposable(this.scheduler.scheduleRecursive(function(t){var n;if(!(e.queue.length>0))return void(e.isAcquired=!1);n=e.queue.shift();try{n()}catch(r){throw e.queue=[],e.hasFaulted=!0,r}t()}))},e.prototype.dispose=function(){t.prototype.dispose.call(this),this.disposable.dispose()},e}(Re),$e=function(t){function e(e,n,r){t.call(this,e,n),this._cancel=r}return Zt(e,t),e.prototype.next=function(e){t.prototype.next.call(this,e),this.ensureActive()},e.prototype.error=function(e){t.prototype.error.call(this,e),this.ensureActive()},e.prototype.completed=function(){t.prototype.completed.call(this),this.ensureActive()},e.prototype.dispose=function(){t.prototype.dispose.call(this),this._cancel&&this._cancel.dispose(),this._cancel=null},e}(Ve),We=tt.Observable=function(){function t(t){if(tt.config.longStackSupport&&ct){try{throw new Error}catch(e){this.stack=e.stack.substring(e.stack.indexOf("\n")+1)}var n=this;this._subscribe=function(e){var r=e.onError.bind(e);return e.onError=function(t){a(t,n),r(t)},t.call(n,e)}}else this._subscribe=t}return qe=t.prototype,qe.subscribe=qe.forEach=function(t,e,n){return this._subscribe("object"==typeof t?t:De(t,e,n))},qe.subscribeOnNext=function(t,e){return this._subscribe(De("undefined"!=typeof e?function(n){t.call(e,n)}:t))},qe.subscribeOnError=function(t,e){return this._subscribe(De(null,"undefined"!=typeof e?function(n){t.call(e,n)}:t))},qe.subscribeOnCompleted=function(t,e){return this._subscribe(De(null,null,"undefined"!=typeof e?function(){t.call(e)}:t))},t}(),ze=tt.ObservableBase=function(t){function e(t){return t&&at(t.dispose)?t:at(t)?ae(t):ce}function n(t,n){var r=n[0],o=n[1],i=x(o.subscribeCore).call(o,r);return i!==ne||r.fail(ne.e)?void r.setDisposable(e(i)):_(ne.e)}function r(t){var e=new Rn(t),r=[e,this];return _e.scheduleRequired()?_e.scheduleWithState(r,n):n(null,r),e}function o(){t.call(this,r)}return Zt(o,t),o.prototype.subscribeCore=gt,o}(We),Ge=tt.internals.Enumerable=function(){},Je=function(t){function e(e){this.sources=e,t.call(this)}function n(t,e,n){this.o=t,this.s=e,this.e=n,this.isStopped=!1}return Zt(e,t),e.prototype.subscribeCore=function(t){var e,r=new le,o=xe.scheduleRecursiveWithState(this.sources[xt](),function(o,i){if(!e){var s=x(o.next).call(o);if(s===ne)return t.onError(s.e);if(s.done)return t.onCompleted();var u=s.value;ut(u)&&(u=Xe(u));var a=new fe;r.setDisposable(a),a.setDisposable(u.subscribe(new n(t,i,o)))}});return new ie(r,o,ae(function(){e=!0}))},n.prototype.onNext=function(t){this.isStopped||this.o.onNext(t)},n.prototype.onError=function(t){this.isStopped||(this.isStopped=!0,this.o.onError(t))},n.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,this.s(this.e))},n.prototype.dispose=function(){this.isStopped=!0},n.prototype.fail=function(t){return this.isStopped?!1:(this.isStopped=!0,this.o.onError(t),!0)},e}(ze);Ge.prototype.concat=function(){return new Je(this)};var Ie=function(t){function e(e){this.sources=e,t.call(this)}return Zt(e,t),e.prototype.subscribeCore=function(t){var e,n=this.sources[xt](),r=new le,o=xe.scheduleRecursiveWithState(null,function(o,i){if(!e){var s=x(n.next).call(n);if(s===ne)return t.onError(s.e);if(s.done)return null!==o?t.onError(o):t.onCompleted();var u=s.value;ut(u)&&(u=Xe(u));var a=new fe;r.setDisposable(a),a.setDisposable(u.subscribe(function(e){t.onNext(e)},i,function(){t.onCompleted()}))}});return new ie(r,o,ae(function(){e=!0}))},e}(ze);Ge.prototype.catchError=function(){return new Ie(this)},Ge.prototype.catchErrorWhen=function(t){var e=this;return new qn(function(n){var r,o,i=new Tn,s=new Tn,u=t(i),a=u.subscribe(s),c=e[xt](),p=new le,h=xe.scheduleRecursive(function(t){if(!r){var e=x(c.next).call(c);if(e===ne)return n.onError(e.e);if(e.done)return void(o?n.onError(o):n.onCompleted());var u=e.value;ut(u)&&(u=Xe(u));var a=new fe,h=new fe;p.setDisposable(new ie(h,a)),a.setDisposable(u.subscribe(function(t){n.onNext(t)},function(e){h.setDisposable(s.subscribe(t,function(t){n.onError(t)},function(){n.onCompleted()})),i.onNext(e)},function(){n.onCompleted()}))}});return new ie(a,p,h,ae(function(){r=!0}))})};var Le=function(t){function e(t,e){this.v=t,this.c=null==e?-1:e}function n(t){this.v=t.v,this.l=t.c}return Zt(e,t),e.prototype[xt]=function(){return new n(this)},n.prototype.next=function(){return 0===this.l?_t:(this.l>0&&this.l--,{done:!1,value:this.v})},e}(Ge),Be=Ge.repeat=function(t,e){return new Le(t,e)},Fe=function(t){function e(t,e,n){this.s=t,this.fn=e?At(e,n,3):null}function n(t){this.i=-1,this.s=t.s,this.l=this.s.length,this.fn=t.fn}return Zt(e,t),e.prototype[xt]=function(){return new n(this)},n.prototype.next=function(){return++this.i<this.l?{done:!1,value:this.fn?this.fn(this.s[this.i],this.i,this.s):this.s[this.i]}:_t},e}(Ge),Ue=Ge.of=function(t,e,n){return new Fe(t,e,n)};qe.observeOn=function(t){var e=this;return new qn(function(n){return e.subscribe(new $e(t,n))},e)},qe.subscribeOn=function(t){var e=this;return new qn(function(n){var r=new fe,o=new le;return o.setDisposable(r),r.setDisposable(t.schedule(function(){o.setDisposable(new E(t,e.subscribe(n)))})),o},e)};var He=function(t){function e(e){this.p=e,t.call(this)}return Zt(e,t),e.prototype.subscribeCore=function(t){return this.p.then(function(e){t.onNext(e),t.onCompleted()},function(e){t.onError(e)}),ce},e}(ze),Xe=We.fromPromise=function(t){return new He(t)};qe.toPromise=function(t){if(t||(t=tt.config.Promise),!t)throw new bt("Promise type not provided nor in Rx.config.Promise");var e=this;return new t(function(t,n){var r,o=!1;e.subscribe(function(t){r=t,o=!0},n,function(){o&&t(r)})})};var Qe=function(t){function e(e){this.source=e,t.call(this)}function n(t){this.o=t,this.a=[],this.isStopped=!1}return Zt(e,t),e.prototype.subscribeCore=function(t){return this.source.subscribe(new n(t))},n.prototype.onNext=function(t){this.isStopped||this.a.push(t)},n.prototype.onError=function(t){this.isStopped||(this.isStopped=!0,this.o.onError(t))},n.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,this.o.onNext(this.a),this.o.onCompleted())},n.prototype.dispose=function(){this.isStopped=!0},n.prototype.fail=function(t){return this.isStopped?!1:(this.isStopped=!0,this.o.onError(t),!0)},e}(ze);qe.toArray=function(){return new Qe(this)},We.create=We.createWithDisposable=function(t,e){return new qn(t,e)};var Ke=(We.defer=function(t){return new qn(function(e){var n;try{n=t()}catch(r){return dn(r).subscribe(e)}return ut(n)&&(n=Xe(n)),n.subscribe(e)})},function(t){function e(e){this.scheduler=e,t.call(this)}function n(t,e){this.observer=t,this.parent=e}function r(t,e){e.onCompleted()}return Zt(e,t),e.prototype.subscribeCore=function(t){var e=new n(t,this);return e.run()},n.prototype.run=function(){return this.parent.scheduler.scheduleWithState(this.observer,r)},e}(ze)),Ye=We.empty=function(t){return me(t)||(t=xe),new Ke(t)},Ze=function(t){function e(e,n,r){this.iterable=e,this.mapper=n,this.scheduler=r,t.call(this)}return Zt(e,t),e.prototype.subscribeCore=function(t){var e=new tn(t,this);return e.run()},e}(ze),tn=function(){function t(t,e){this.observer=t,this.parent=e}return t.prototype.run=function(){function t(t,e){try{var i=n.next()}catch(s){return r.onError(s)}if(i.done)return r.onCompleted();var u=i.value;if(o)try{u=o(u,t)}catch(s){return r.onError(s)}r.onNext(u),e(t+1)}var e=Object(this.parent.iterable),n=j(e),r=this.observer,o=this.parent.mapper;return this.parent.scheduler.scheduleRecursiveWithState(0,t)},t}(),en=Math.pow(2,53)-1;A.prototype[xt]=function(){return new N(this._s)},N.prototype[xt]=function(){return this},N.prototype.next=function(){return this._i<this._l?{done:!1,value:this._s.charAt(this._i++)}:_t},k.prototype[xt]=function(){return new O(this._a)},O.prototype[xt]=function(){return this},O.prototype.next=function(){return this._i<this._l?{done:!1,value:this._a[this._i++]}:_t};var nn=We.from=function(t,e,n,r){if(null==t)throw new Error("iterable cannot be null.");if(e&&!at(e))throw new Error("mapFn when provided must be a function");if(e)var o=At(e,n,2);return me(r)||(r=_e),new Ze(t,o,r)},rn=function(t){function e(e,n){this.args=e,this.scheduler=n,t.call(this)}return Zt(e,t),e.prototype.subscribeCore=function(t){var e=new R(t,this);return e.run()},e}(ze);R.prototype.run=function(){function t(t,o){r>t?(e.onNext(n[t]),o(t+1)):e.onCompleted()}var e=this.observer,n=this.parent.args,r=n.length;return this.parent.scheduler.scheduleRecursiveWithState(0,t)};var on=We.fromArray=function(t,e){return me(e)||(e=_e),new rn(t,e)};We.generate=function(t,e,n,r,o){return me(o)||(o=_e),new qn(function(i){var s=!0;return o.scheduleRecursiveWithState(t,function(t,o){var u,a;try{s?s=!1:t=n(t),u=e(t),u&&(a=r(t))}catch(c){return i.onError(c)}u?(i.onNext(a),o(t)):i.onCompleted()})})};var sn=function(t){function e(){t.call(this)}return Zt(e,t),e.prototype.subscribeCore=function(t){return ce},e}(ze),un=We.never=function(){return new sn};We.of=function(){for(var t=arguments.length,e=new Array(t),n=0;t>n;n++)e[n]=arguments[n];return new rn(e,_e)},We.ofWithScheduler=function(t){for(var e=arguments.length,n=new Array(e-1),r=1;e>r;r++)n[r-1]=arguments[r];return new rn(n,t)};var an=function(t){function e(e,n){this.obj=e,this.keys=Object.keys(e),this.scheduler=n,t.call(this)}return Zt(e,t),e.prototype.subscribeCore=function(t){var e=new T(t,this);return e.run()},e}(ze);T.prototype.run=function(){function t(t,i){if(o>t){var s=r[t];e.onNext([s,n[s]]),i(t+1)}else e.onCompleted()}var e=this.observer,n=this.parent.obj,r=this.parent.keys,o=r.length;return this.parent.scheduler.scheduleRecursiveWithState(0,t)},We.pairs=function(t,e){return e||(e=_e),new an(t,e)};var cn=function(t){function e(e,n,r){this.start=e,this.rangeCount=n,this.scheduler=r,t.call(this)}return Zt(e,t),e.prototype.subscribeCore=function(t){var e=new pn(t,this);return e.run()},e}(ze),pn=function(){function t(t,e){this.observer=t,this.parent=e}return t.prototype.run=function(){function t(t,o){n>t?(r.onNext(e+t),o(t+1)):r.onCompleted()}var e=this.parent.start,n=this.parent.rangeCount,r=this.observer;return this.parent.scheduler.scheduleRecursiveWithState(0,t)},t}();We.range=function(t,e,n){return me(n)||(n=_e),new cn(t,e,n)};var hn=function(t){function e(e,n,r){this.value=e,this.repeatCount=null==n?-1:n,this.scheduler=r,t.call(this)}return Zt(e,t),e.prototype.subscribeCore=function(t){var e=new V(t,this);return e.run()},e}(ze);V.prototype.run=function(){function t(t,r){return(-1===t||t>0)&&(e.onNext(n),t>0&&t--),0===t?e.onCompleted():void r(t)}var e=this.observer,n=this.parent.value;return this.parent.scheduler.scheduleRecursiveWithState(this.parent.repeatCount,t)},We.repeat=function(t,e,n){return me(n)||(n=_e),new hn(t,e,n)};var fn=function(t){function e(e,n){this.value=e,this.scheduler=n,t.call(this)}function n(t,e){this.observer=t,this.parent=e}function r(t,e){var n=e[0],r=e[1];r.onNext(n),r.onCompleted()}return Zt(e,t),e.prototype.subscribeCore=function(t){var e=new n(t,this);return e.run()},n.prototype.run=function(){return this.parent.scheduler.scheduleWithState([this.parent.value,this.observer],r)},e}(ze),ln=(We["return"]=We.just=We.returnValue=function(t,e){return me(e)||(e=xe),new fn(t,e)},function(t){function e(e,n){this.error=e,this.scheduler=n,t.call(this)}function n(t,e){this.o=t,this.p=e}function r(t,e){var n=e[0],r=e[1];r.onError(n)}return Zt(e,t),e.prototype.subscribeCore=function(t){var e=new n(t,this);return e.run()},n.prototype.run=function(){return this.p.scheduler.scheduleWithState([this.p.error,this.o],r)},e}(ze)),dn=We["throw"]=We.throwError=We.throwException=function(t,e){return me(e)||(e=xe),new ln(t,e)};We.using=function(t,e){return new qn(function(n){var r,o,i=ce;try{r=t(),r&&(i=r),o=e(r)}catch(s){return new ie(dn(s).subscribe(n),i)}return new ie(o.subscribe(n),i)})},qe.amb=function(t){var e=this;return new qn(function(n){function r(){i||(i=s,c.dispose())}function o(){i||(i=u,a.dispose())}var i,s="L",u="R",a=new fe,c=new fe;return ut(t)&&(t=Xe(t)),a.setDisposable(e.subscribe(function(t){r(),i===s&&n.onNext(t)},function(t){r(),i===s&&n.onError(t)},function(){r(),i===s&&n.onCompleted()})),c.setDisposable(t.subscribe(function(t){o(),i===u&&n.onNext(t)},function(t){o(),i===u&&n.onError(t)},function(){o(),i===u&&n.onCompleted()})),new ie(a,c)})},We.amb=function(){function t(t,e){return t.amb(e)}var e=un(),n=[];if(Array.isArray(arguments[0]))n=arguments[0];else for(var r=0,o=arguments.length;o>r;r++)n.push(arguments[r]);for(var r=0,o=n.length;o>r;r++)e=t(e,n[r]);return e},qe["catch"]=qe.catchError=qe.catchException=function(t){return"function"==typeof t?$(this,t):vn([this,t])};var vn=We.catchError=We["catch"]=We.catchException=function(){var t=[];if(Array.isArray(arguments[0]))t=arguments[0];else for(var e=0,n=arguments.length;n>e;e++)t.push(arguments[e]);return Ue(t).catchError()};qe.combineLatest=function(){for(var t=arguments.length,e=new Array(t),n=0;t>n;n++)e[n]=arguments[n];return Array.isArray(e[0])?e[0].unshift(this):e.unshift(this),yn.apply(this,e)};var yn=We.combineLatest=function(){for(var t=arguments.length,e=new Array(t),n=0;t>n;n++)e[n]=arguments[n];var r=e.pop();return Array.isArray(e[0])&&(e=e[0]),new qn(function(t){function n(e){if(u[e]=!0,a||(a=u.every(nt))){try{var n=r.apply(null,p)}catch(o){return t.onError(o)}t.onNext(n)}else c.filter(function(t,n){return n!==e}).every(nt)&&t.onCompleted()}function o(e){c[e]=!0,c.every(nt)&&t.onCompleted()}for(var i=e.length,s=function(){return!1},u=g(i,s),a=!1,c=g(i,s),p=new Array(i),h=new Array(i),f=0;i>f;f++)!function(r){var i=e[r],s=new fe;ut(i)&&(i=Xe(i)),s.setDisposable(i.subscribe(function(t){p[r]=t,n(r)},function(e){t.onError(e)},function(){o(r)})),h[r]=s}(f);return new ie(h)},this)};qe.concat=function(){for(var t=[],e=0,n=arguments.length;n>e;e++)t.push(arguments[e]);return t.unshift(this),mn.apply(null,t)};var bn=function(t){function e(e){this.sources=e,t.call(this)}function n(t,e){this.sources=t,this.o=e}return Zt(e,t),e.prototype.subscribeCore=function(t){var e=new n(this.sources,t);return e.run()},n.prototype.run=function(){var t,e=new le,n=this.sources,r=n.length,o=this.o,i=xe.scheduleRecursiveWithState(0,function(i,s){if(!t){if(i===r)return o.onCompleted();var u=n[i];ut(u)&&(u=Xe(u));var a=new fe;e.setDisposable(a),a.setDisposable(u.subscribe(function(t){o.onNext(t)},function(t){o.onError(t)},function(){s(i+1)}))}});return new ie(e,i,ae(function(){t=!0}))},e}(ze),mn=We.concat=function(){var t;if(Array.isArray(arguments[0]))t=arguments[0];else{t=new Array(arguments.length);for(var e=0,n=arguments.length;n>e;e++)t[e]=arguments[e]}return new bn(t)};qe.concatAll=qe.concatObservable=function(){return this.merge(1)};var gn=function(t){function e(e,n){this.source=e,this.maxConcurrent=n,t.call(this)}return Zt(e,t),e.prototype.subscribeCore=function(t){var e=new ie;return e.add(this.source.subscribe(new wn(t,this.maxConcurrent,e))),e},e}(ze),wn=function(){function t(t,e,n){this.o=t,this.max=e,this.g=n,this.done=!1,this.q=[],this.activeCount=0,this.isStopped=!1}function e(t,e){this.parent=t,this.sad=e,this.isStopped=!1}return t.prototype.handleSubscribe=function(t){var n=new fe;this.g.add(n),ut(t)&&(t=Xe(t)),n.setDisposable(t.subscribe(new e(this,n)))},t.prototype.onNext=function(t){this.isStopped||(this.activeCount<this.max?(this.activeCount++,this.handleSubscribe(t)):this.q.push(t))},t.prototype.onError=function(t){this.isStopped||(this.isStopped=!0,this.o.onError(t))},t.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,this.done=!0,0===this.activeCount&&this.o.onCompleted())},t.prototype.dispose=function(){this.isStopped=!0},t.prototype.fail=function(t){return this.isStopped?!1:(this.isStopped=!0,this.o.onError(t),!0)},e.prototype.onNext=function(t){this.isStopped||this.parent.o.onNext(t)},e.prototype.onError=function(t){this.isStopped||(this.isStopped=!0,this.parent.o.onError(t))},e.prototype.onCompleted=function(){if(!this.isStopped){this.isStopped=!0;var t=this.parent;t.g.remove(this.sad),t.q.length>0?t.handleSubscribe(t.q.shift()):(t.activeCount--,t.done&&0===t.activeCount&&t.o.onCompleted())}},e.prototype.dispose=function(){this.isStopped=!0},e.prototype.fail=function(t){return this.isStopped?!1:(this.isStopped=!0,this.parent.o.onError(t),!0)},t}();qe.merge=function(t){return"number"!=typeof t?xn(this,t):new gn(this,t)};var xn=We.merge=function(){var t,e,n=[],r=arguments.length;if(arguments[0])if(me(arguments[0]))for(t=arguments[0],e=1;r>e;e++)n.push(arguments[e]);else for(t=xe,e=0;r>e;e++)n.push(arguments[e]);else for(t=xe,e=1;r>e;e++)n.push(arguments[e]);return Array.isArray(n[0])&&(n=n[0]),M(t,n).mergeAll()},_n=tt.CompositeError=function(t){this.name="NotImplementedError",this.innerErrors=t,this.message="This contains multiple errors. Check the innerErrors",Error.call(this)};_n.prototype=Error.prototype,We.mergeDelayError=function(){var t;if(Array.isArray(arguments[0]))t=arguments[0];else{var e=arguments.length;t=new Array(e);for(var n=0;e>n;n++)t[n]=arguments[n]}var r=M(null,t);return new qn(function(t){function e(){0===s.length?t.onCompleted():1===s.length?t.onError(s[0]):t.onError(new _n(s))}var n=new ie,o=new fe,i=!1,s=[];return n.add(o),o.setDisposable(r.subscribe(function(r){var o=new fe;n.add(o),ut(r)&&(r=Xe(r)),o.setDisposable(r.subscribe(function(e){t.onNext(e)},function(t){s.push(t),n.remove(o),i&&1===n.length&&e()},function(){n.remove(o),i&&1===n.length&&e()}))},function(t){s.push(t),i=!0,1===n.length&&e()},function(){i=!0,1===n.length&&e()})),n})};var Sn=function(t){function e(e){this.source=e,t.call(this)}function n(t,e){this.o=t,this.g=e,this.isStopped=!1,this.done=!1}function r(t,e,n){this.parent=t,this.g=e,this.sad=n,this.isStopped=!1}return Zt(e,t),e.prototype.subscribeCore=function(t){var e=new ie,r=new fe;return e.add(r),r.setDisposable(this.source.subscribe(new n(t,e))),e},n.prototype.onNext=function(t){if(!this.isStopped){var e=new fe;this.g.add(e),ut(t)&&(t=Xe(t)),e.setDisposable(t.subscribe(new r(this,this.g,e)))}},n.prototype.onError=function(t){this.isStopped||(this.isStopped=!0,this.o.onError(t))},n.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,this.done=!0,1===this.g.length&&this.o.onCompleted())},n.prototype.dispose=function(){this.isStopped=!0},n.prototype.fail=function(t){return this.isStopped?!1:(this.isStopped=!0,this.o.onError(t),!0)},r.prototype.onNext=function(t){this.isStopped||this.parent.o.onNext(t)},r.prototype.onError=function(t){this.isStopped||(this.isStopped=!0,this.parent.o.onError(t))},r.prototype.onCompleted=function(){if(!this.isStopped){var t=this.parent;this.isStopped=!0,t.g.remove(this.sad),t.done&&1===t.g.length&&t.o.onCompleted()}},r.prototype.dispose=function(){this.isStopped=!0},r.prototype.fail=function(t){return this.isStopped?!1:(this.isStopped=!0,this.parent.o.onError(t),!0)},e}(ze);qe.mergeAll=qe.mergeObservable=function(){
3473 return new Sn(this)},qe.onErrorResumeNext=function(t){if(!t)throw new Error("Second observable is required");return En([this,t])};var En=We.onErrorResumeNext=function(){var t=[];if(Array.isArray(arguments[0]))t=arguments[0];else for(var e=0,n=arguments.length;n>e;e++)t.push(arguments[e]);return new qn(function(e){var n=0,r=new le,o=xe.scheduleRecursive(function(o){var i,s;n<t.length?(i=t[n++],ut(i)&&(i=Xe(i)),s=new fe,r.setDisposable(s),s.setDisposable(i.subscribe(e.onNext.bind(e),o,o))):e.onCompleted()});return new ie(r,o)})};qe.skipUntil=function(t){var e=this;return new qn(function(n){var r=!1,o=new ie(e.subscribe(function(t){r&&n.onNext(t)},function(t){n.onError(t)},function(){r&&n.onCompleted()}));ut(t)&&(t=Xe(t));var i=new fe;return o.add(i),i.setDisposable(t.subscribe(function(){r=!0,i.dispose()},function(t){n.onError(t)},function(){i.dispose()})),o},e)};var Cn=function(t){function e(e){this.source=e,t.call(this)}function n(t,e){this.o=t,this.inner=e,this.stopped=!1,this.latest=0,this.hasLatest=!1,this.isStopped=!1}function r(t,e){this.parent=t,this.id=e,this.isStopped=!1}return Zt(e,t),e.prototype.subscribeCore=function(t){var e=new le,r=this.source.subscribe(new n(t,e));return new ie(r,e)},n.prototype.onNext=function(t){if(!this.isStopped){var e=new fe,n=++this.latest;this.hasLatest=!0,this.inner.setDisposable(e),ut(t)&&(t=Xe(t)),e.setDisposable(t.subscribe(new r(this,n)))}},n.prototype.onError=function(t){this.isStopped||(this.isStopped=!0,this.o.onError(t))},n.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,this.stopped=!0,!this.hasLatest&&this.o.onCompleted())},n.prototype.dispose=function(){this.isStopped=!0},n.prototype.fail=function(t){return this.isStopped?!1:(this.isStopped=!0,this.o.onError(t),!0)},r.prototype.onNext=function(t){this.isStopped||this.parent.latest===this.id&&this.parent.o.onNext(t)},r.prototype.onError=function(t){this.isStopped||(this.isStopped=!0,this.parent.latest===this.id&&this.parent.o.onError(t))},r.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,this.parent.latest===this.id&&(this.parent.hasLatest=!1,this.parent.isStopped&&this.parent.o.onCompleted()))},r.prototype.dispose=function(){this.isStopped=!0},r.prototype.fail=function(t){return this.isStopped?!1:(this.isStopped=!0,this.parent.o.onError(t),!0)},e}(ze);qe["switch"]=qe.switchLatest=function(){return new Cn(this)};var An=function(t){function e(e,n){this.source=e,this.other=ut(n)?Xe(n):n,t.call(this)}function n(t){this.o=t,this.isStopped=!1}return Zt(e,t),e.prototype.subscribeCore=function(t){return new ie(this.source.subscribe(t),this.other.subscribe(new n(t)))},n.prototype.onNext=function(t){this.isStopped||this.o.onCompleted()},n.prototype.onError=function(t){this.isStopped||(this.isStopped=!0,this.o.onError(t))},n.prototype.onCompleted=function(){!this.isStopped&&(this.isStopped=!0)},n.prototype.dispose=function(){this.isStopped=!0},n.prototype.fail=function(t){return this.isStopped?!1:(this.isStopped=!0,this.o.onError(t),!0)},e}(ze);qe.takeUntil=function(t){return new An(this,t)},qe.withLatestFrom=function(){for(var t=arguments.length,e=new Array(t),n=0;t>n;n++)e[n]=arguments[n];var r=e.pop(),o=this;return Array.isArray(e[0])&&(e=e[0]),new qn(function(t){for(var n=e.length,i=g(n,W),s=!1,u=new Array(n),a=new Array(n+1),c=0;n>c;c++)!function(n){var r=e[n],o=new fe;ut(r)&&(r=Xe(r)),o.setDisposable(r.subscribe(function(t){u[n]=t,i[n]=!0,s=i.every(nt)},function(e){t.onError(e)},et)),a[n]=o}(c);var p=new fe;return p.setDisposable(o.subscribe(function(e){var n=[e].concat(u);if(s){var o=x(r).apply(null,n);return o===ne?t.onError(o.e):void t.onNext(o)}},function(e){t.onError(e)},function(){t.onCompleted()})),a[n]=p,new ie(a)},this)},qe.zip=function(){if(Array.isArray(arguments[0]))return z.apply(this,arguments);for(var t=arguments.length,e=new Array(t),n=0;t>n;n++)e[n]=arguments[n];var r=this,o=e.pop();return e.unshift(r),new qn(function(t){for(var n=e.length,i=g(n,G),s=g(n,W),u=new Array(n),a=0;n>a;a++)!function(n){var a=e[n],c=new fe;ut(a)&&(a=Xe(a)),c.setDisposable(a.subscribe(function(e){if(i[n].push(e),i.every(function(t){return t.length>0})){var u=i.map(function(t){return t.shift()}),a=x(o).apply(r,u);if(a===ne)return t.onError(a.e);t.onNext(a)}else s.filter(function(t,e){return e!==n}).every(nt)&&t.onCompleted()},function(e){t.onError(e)},function(){s[n]=!0,s.every(nt)&&t.onCompleted()})),u[n]=c}(a);return new ie(u)},r)},We.zip=function(){for(var t=arguments.length,e=new Array(t),n=0;t>n;n++)e[n]=arguments[n];var r=e.shift();return r.zip.apply(r,e)},We.zipArray=function(){var t;if(Array.isArray(arguments[0]))t=arguments[0];else{var e=arguments.length;t=new Array(e);for(var n=0;e>n;n++)t[n]=arguments[n]}return new qn(function(e){for(var n=t.length,r=g(n,J),o=g(n,W),i=new Array(n),s=0;n>s;s++)!function(n){i[n]=new fe,i[n].setDisposable(t[n].subscribe(function(t){if(r[n].push(t),r.every(function(t){return t.length>0})){var i=r.map(function(t){return t.shift()});e.onNext(i)}else if(o.filter(function(t,e){return e!==n}).every(nt))return e.onCompleted()},function(t){e.onError(t)},function(){o[n]=!0,o.every(nt)&&e.onCompleted()}))}(s);return new ie(i)})},qe.asObservable=function(){var t=this;return new qn(function(e){return t.subscribe(e)},t)},qe.bufferWithCount=function(t,e){return"number"!=typeof e&&(e=t),this.windowWithCount(t,e).selectMany(function(t){return t.toArray()}).where(function(t){return t.length>0})},qe.dematerialize=function(){var t=this;return new qn(function(e){return t.subscribe(function(t){return t.accept(e)},function(t){e.onError(t)},function(){e.onCompleted()})},this)},qe.distinctUntilChanged=function(t,e){var n=this;return e||(e=ot),new qn(function(r){var o,i=!1;return n.subscribe(function(n){var s=n;if(t&&(s=x(t)(n),s===ne))return r.onError(s.e);if(i){var u=x(e)(o,s);if(u===ne)return r.onError(u.e)}i&&u||(i=!0,o=s,r.onNext(n))},function(t){r.onError(t)},function(){r.onCompleted()})},this)};var Nn=function(t){function e(e,n,r,o){this.source=e,this.t=!n||at(n)?De(n||et,r||et,o||et):n,t.call(this)}function n(t,e){this.o=t,this.t=e,this.isStopped=!1}return Zt(e,t),e.prototype.subscribeCore=function(t){return this.source.subscribe(new n(t,this.t))},n.prototype.onNext=function(t){if(!this.isStopped){var e=x(this.t.onNext).call(this.t,t);e===ne&&this.o.onError(e.e),this.o.onNext(t)}},n.prototype.onError=function(t){if(!this.isStopped){this.isStopped=!0;var e=x(this.t.onError).call(this.t,t);if(e===ne)return this.o.onError(e.e);this.o.onError(t)}},n.prototype.onCompleted=function(){if(!this.isStopped){this.isStopped=!0;var t=x(this.t.onCompleted).call(this.t);if(t===ne)return this.o.onError(t.e);this.o.onCompleted()}},n.prototype.dispose=function(){this.isStopped=!0},n.prototype.fail=function(t){return this.isStopped?!1:(this.isStopped=!0,this.o.onError(t),!0)},e}(ze);qe["do"]=qe.tap=qe.doAction=function(t,e,n){return new Nn(this,t,e,n)},qe.doOnNext=qe.tapOnNext=function(t,e){return this.tap("undefined"!=typeof e?function(n){t.call(e,n)}:t)},qe.doOnError=qe.tapOnError=function(t,e){return this.tap(et,"undefined"!=typeof e?function(n){t.call(e,n)}:t)},qe.doOnCompleted=qe.tapOnCompleted=function(t,e){return this.tap(et,null,"undefined"!=typeof e?function(){t.call(e)}:t)},qe["finally"]=qe.ensure=function(t){var e=this;return new qn(function(n){var r;try{r=e.subscribe(n)}catch(o){throw t(),o}return ae(function(){try{r.dispose()}catch(e){throw e}finally{t()}})},this)},qe.finallyAction=function(t){return this.ensure(t)};var kn=function(t){function e(e){this.source=e,t.call(this)}function n(t){this.o=t,this.isStopped=!1}return Zt(e,t),e.prototype.subscribeCore=function(t){return this.source.subscribe(new n(t))},n.prototype.onNext=et,n.prototype.onError=function(t){this.isStopped||(this.isStopped=!0,this.o.onError(t))},n.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,this.o.onCompleted())},n.prototype.dispose=function(){this.isStopped=!0},n.prototype.fail=function(t){return this.isStopped?!1:(this.isStopped=!0,this.observer.onError(t),!0)},e}(ze);qe.ignoreElements=function(){return new kn(this)},qe.materialize=function(){var t=this;return new qn(function(e){return t.subscribe(function(t){e.onNext(ke(t))},function(t){e.onNext(Oe(t)),e.onCompleted()},function(){e.onNext(Pe()),e.onCompleted()})},t)},qe.repeat=function(t){return Be(this,t).concat()},qe.retry=function(t){return Be(this,t).catchError()},qe.retryWhen=function(t){return Be(this).catchErrorWhen(t)};var On=function(t){function e(e,n,r,o){this.source=e,this.accumulator=n,this.hasSeed=r,this.seed=o,t.call(this)}return Zt(e,t),e.prototype.subscribeCore=function(t){return this.source.subscribe(new I(t,this))},e}(ze);I.prototype.onNext=function(t){if(!this.isStopped){!this.hasValue&&(this.hasValue=!0);try{this.hasAccumulation?this.accumulation=this.accumulator(this.accumulation,t):(this.accumulation=this.hasSeed?this.accumulator(this.seed,t):t,this.hasAccumulation=!0)}catch(e){return this.observer.onError(e)}this.observer.onNext(this.accumulation)}},I.prototype.onError=function(t){this.isStopped||(this.isStopped=!0,this.observer.onError(t))},I.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,!this.hasValue&&this.hasSeed&&this.observer.onNext(this.seed),this.observer.onCompleted())},I.prototype.dispose=function(){this.isStopped=!0},I.prototype.fail=function(t){return this.isStopped?!1:(this.isStopped=!0,this.observer.onError(t),!0)},qe.scan=function(){var t,e,n=!1;return 2===arguments.length?(n=!0,t=arguments[0],e=arguments[1]):e=arguments[0],new On(this,e,n,t)},qe.skipLast=function(t){if(0>t)throw new yt;var e=this;return new qn(function(n){var r=[];return e.subscribe(function(e){r.push(e),r.length>t&&n.onNext(r.shift())},function(t){n.onError(t)},function(){n.onCompleted()})},e)},qe.startWith=function(){var t,e=0;arguments.length&&me(arguments[0])?(t=arguments[0],e=1):t=xe;for(var n=[],r=e,o=arguments.length;o>r;r++)n.push(arguments[r]);return Ue([on(n,t),this]).concat()},qe.takeLast=function(t){if(0>t)throw new yt;var e=this;return new qn(function(n){var r=[];return e.subscribe(function(e){r.push(e),r.length>t&&r.shift()},function(t){n.onError(t)},function(){for(;r.length>0;)n.onNext(r.shift());n.onCompleted()})},e)},qe.takeLastBuffer=function(t){var e=this;return new qn(function(n){var r=[];return e.subscribe(function(e){r.push(e),r.length>t&&r.shift()},function(t){n.onError(t)},function(){n.onNext(r),n.onCompleted()})},e)},qe.windowWithCount=function(t,e){var n=this;if(+t||(t=0),Math.abs(t)===1/0&&(t=0),0>=t)throw new yt;if(null==e&&(e=t),+e||(e=0),Math.abs(e)===1/0&&(e=0),0>=e)throw new yt;return new qn(function(r){function o(){var t=new Tn;a.push(t),r.onNext(ee(t,s))}var i=new fe,s=new de(i),u=0,a=[];return o(),i.setDisposable(n.subscribe(function(n){for(var r=0,i=a.length;i>r;r++)a[r].onNext(n);var s=u-t+1;s>=0&&s%e===0&&a.shift().onCompleted(),++u%e===0&&o()},function(t){for(;a.length>0;)a.shift().onError(t);r.onError(t)},function(){for(;a.length>0;)a.shift().onCompleted();r.onCompleted()})),s},n)},qe.selectConcat=qe.concatMap=function(t,e,n){return at(t)&&at(e)?this.concatMap(function(n,r){var o=t(n,r);return ut(o)&&(o=Xe(o)),(Et(o)||St(o))&&(o=nn(o)),o.map(function(t,o){return e(n,t,r,o)})}):at(t)?L(this,t,n):L(this,function(){return t})},qe.concatMapObserver=qe.selectConcatObserver=function(t,e,n,r){var o=this,i=At(t,r,2),s=At(e,r,1),u=At(n,r,0);return new qn(function(t){var e=0;return o.subscribe(function(n){var r;try{r=i(n,e++)}catch(o){return void t.onError(o)}ut(r)&&(r=Xe(r)),t.onNext(r)},function(e){var n;try{n=s(e)}catch(r){return void t.onError(r)}ut(n)&&(n=Xe(n)),t.onNext(n),t.onCompleted()},function(){var e;try{e=u()}catch(n){return void t.onError(n)}ut(e)&&(e=Xe(e)),t.onNext(e),t.onCompleted()})},this).concatAll()},qe.defaultIfEmpty=function(t){var e=this;return t===i&&(t=null),new qn(function(n){var r=!1;return e.subscribe(function(t){r=!0,n.onNext(t)},function(t){n.onError(t)},function(){!r&&n.onNext(t),n.onCompleted()})},e)},F.prototype.push=function(t){var e=-1===B(this.set,t,this.comparer);return e&&this.set.push(t),e},qe.distinct=function(t,e){var n=this;return e||(e=ot),new qn(function(r){var o=new F(e);return n.subscribe(function(e){var n=e;if(t)try{n=t(e)}catch(i){return void r.onError(i)}o.push(n)&&r.onNext(e)},function(t){r.onError(t)},function(){r.onCompleted()})},this)};var Pn=function(t){function e(e,n,r){this.source=e,this.selector=At(n,r,3),t.call(this)}function n(t,e){return function(n,r,o){return t.call(this,e.selector(n,r,o),r,o)}}function r(t,e,n){this.o=t,this.selector=e,this.source=n,this.i=0,this.isStopped=!1}return Zt(e,t),e.prototype.internalMap=function(t,r){return new e(this.source,n(t,this),r)},e.prototype.subscribeCore=function(t){return this.source.subscribe(new r(t,this.selector,this))},r.prototype.onNext=function(t){if(!this.isStopped){var e=x(this.selector)(t,this.i++,this.source);return e===ne?this.o.onError(e.e):void this.o.onNext(e)}},r.prototype.onError=function(t){this.isStopped||(this.isStopped=!0,this.o.onError(t))},r.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,this.o.onCompleted())},r.prototype.dispose=function(){this.isStopped=!0},r.prototype.fail=function(t){return this.isStopped?!1:(this.isStopped=!0,this.o.onError(t),!0)},e}(ze);qe.map=qe.select=function(t,e){var n="function"==typeof t?t:function(){return t};return this instanceof Pn?this.internalMap(n,e):new Pn(this,n,e)},qe.pluck=function(){var t=arguments,e=arguments.length;if(0===e)throw new Error("List of properties cannot be empty.");return this.map(function(n){for(var r=n,o=0;e>o;o++){var s=r[t[o]];if("undefined"==typeof s)return i;r=s}return r})},qe.flatMapObserver=qe.selectManyObserver=function(t,e,n,r){var o=this;return new qn(function(i){var s=0;return o.subscribe(function(e){var n;try{n=t.call(r,e,s++)}catch(o){return void i.onError(o)}ut(n)&&(n=Xe(n)),i.onNext(n)},function(t){var n;try{n=e.call(r,t)}catch(o){return void i.onError(o)}ut(n)&&(n=Xe(n)),i.onNext(n),i.onCompleted()},function(){var t;try{t=n.call(r)}catch(e){return void i.onError(e)}ut(t)&&(t=Xe(t)),i.onNext(t),i.onCompleted()})},o).mergeAll()},qe.selectMany=qe.flatMap=function(t,e,n){return at(t)&&at(e)?this.flatMap(function(n,r){var o=t(n,r);return ut(o)&&(o=Xe(o)),(Et(o)||St(o))&&(o=nn(o)),o.map(function(t,o){return e(n,t,r,o)})},n):at(t)?U(this,t,n):U(this,function(){return t})},qe.selectSwitch=qe.flatMapLatest=qe.switchMap=function(t,e){return this.select(t,e).switchLatest()};var jn=function(t){function e(e,n){this.source=e,this.skipCount=n,t.call(this)}function n(t,e){this.c=e,this.r=e,this.o=t,this.isStopped=!1}return Zt(e,t),e.prototype.subscribeCore=function(t){return this.source.subscribe(new n(t,this.skipCount))},n.prototype.onNext=function(t){this.isStopped||(this.r<=0?this.o.onNext(t):this.r--)},n.prototype.onError=function(t){this.isStopped||(this.isStopped=!0,this.o.onError(t))},n.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,this.o.onCompleted())},n.prototype.dispose=function(){this.isStopped=!0},n.prototype.fail=function(t){return this.isStopped?!1:(this.isStopped=!0,this.o.onError(t),!0)},e}(ze);qe.skip=function(t){if(0>t)throw new yt;return new jn(this,t)},qe.skipWhile=function(t,e){var n=this,r=At(t,e,3);return new qn(function(t){var e=0,o=!1;return n.subscribe(function(i){if(!o)try{o=!r(i,e++,n)}catch(s){return void t.onError(s)}o&&t.onNext(i)},function(e){t.onError(e)},function(){t.onCompleted()})},n)},qe.take=function(t,e){if(0>t)throw new yt;if(0===t)return Ye(e);var n=this;return new qn(function(e){var r=t;return n.subscribe(function(t){r-- >0&&(e.onNext(t),0>=r&&e.onCompleted())},function(t){e.onError(t)},function(){e.onCompleted()})},n)},qe.takeWhile=function(t,e){var n=this,r=At(t,e,3);return new qn(function(t){var e=0,o=!0;return n.subscribe(function(i){if(o){try{o=r(i,e++,n)}catch(s){return void t.onError(s)}o?t.onNext(i):t.onCompleted()}},function(e){t.onError(e)},function(){t.onCompleted()})},n)};var Dn=function(t){function e(e,n,r){this.source=e,this.predicate=At(n,r,3),t.call(this)}function n(t,e){return function(n,r,o){return e.predicate(n,r,o)&&t.call(this,n,r,o)}}function r(t,e,n){this.o=t,this.predicate=e,this.source=n,this.i=0,this.isStopped=!1}return Zt(e,t),e.prototype.subscribeCore=function(t){return this.source.subscribe(new r(t,this.predicate,this))},e.prototype.internalFilter=function(t,r){return new e(this.source,n(t,this),r)},r.prototype.onNext=function(t){if(!this.isStopped){var e=x(this.predicate)(t,this.i++,this.source);return e===ne?this.o.onError(e.e):void(e&&this.o.onNext(t))}},r.prototype.onError=function(t){this.isStopped||(this.isStopped=!0,this.o.onError(t))},r.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,this.o.onCompleted())},r.prototype.dispose=function(){this.isStopped=!0},r.prototype.fail=function(t){return this.isStopped?!1:(this.isStopped=!0,this.o.onError(t),!0)},e}(ze);qe.filter=qe.where=function(t,e){return this instanceof Dn?this.internalFilter(t,e):new Dn(this,t,e)},qe.transduce=function(t){function e(t){return{"@@transducer/init":function(){return t},"@@transducer/step":function(t,e){return t.onNext(e)},"@@transducer/result":function(t){return t.onCompleted()}}}var n=this;return new qn(function(r){var o=t(e(r));return n.subscribe(function(t){try{o["@@transducer/step"](r,t)}catch(e){r.onError(e)}},function(t){r.onError(t)},function(){o["@@transducer/result"](r)})},n)};var qn=tt.AnonymousObservable=function(t){function e(t){return t&&at(t.dispose)?t:at(t)?ae(t):ce}function n(t,n){var r=n[0],o=n[1],i=x(o)(r);return i!==ne||r.fail(ne.e)?void r.setDisposable(e(i)):_(ne.e)}function r(e,r){function o(t){var r=new Rn(t),o=[r,e];return _e.scheduleRequired()?_e.scheduleWithState(o,n):n(null,o),r}this.source=r,t.call(this,o)}return Zt(r,t),r}(We),Rn=function(t){function e(e){t.call(this),this.observer=e,this.m=new fe}Zt(e,t);var n=e.prototype;return n.next=function(t){var e=x(this.observer.onNext).call(this.observer,t);e===ne&&(this.dispose(),_(e.e))},n.error=function(t){var e=x(this.observer.onError).call(this.observer,t);this.dispose(),e===ne&&_(e.e)},n.completed=function(){var t=x(this.observer.onCompleted).call(this.observer);this.dispose(),t===ne&&_(t.e)},n.setDisposable=function(t){this.m.setDisposable(t)},n.getDisposable=function(){return this.m.getDisposable()},n.dispose=function(){t.prototype.dispose.call(this),this.m.dispose()},e}(Re),Mn=function(t,e){this.subject=t,this.observer=e};Mn.prototype.dispose=function(){if(!this.subject.isDisposed&&null!==this.observer){var t=this.subject.observers.indexOf(this.observer);this.subject.observers.splice(t,1),this.observer=null}};var Tn=tt.Subject=function(t){function e(t){return he(this),this.isStopped?this.hasError?(t.onError(this.error),ce):(t.onCompleted(),ce):(this.observers.push(t),new Mn(this,t))}function n(){t.call(this,e),this.isDisposed=!1,this.isStopped=!1,this.observers=[],this.hasError=!1}return Zt(n,t),te(n.prototype,je.prototype,{hasObservers:function(){return this.observers.length>0},onCompleted:function(){if(he(this),!this.isStopped){this.isStopped=!0;for(var t=0,e=u(this.observers),n=e.length;n>t;t++)e[t].onCompleted();this.observers.length=0}},onError:function(t){if(he(this),!this.isStopped){this.isStopped=!0,this.error=t,this.hasError=!0;for(var e=0,n=u(this.observers),r=n.length;r>e;e++)n[e].onError(t);this.observers.length=0}},onNext:function(t){if(he(this),!this.isStopped)for(var e=0,n=u(this.observers),r=n.length;r>e;e++)n[e].onNext(t)},dispose:function(){this.isDisposed=!0,this.observers=null}}),n.create=function(t,e){return new Vn(t,e)},n}(We),Vn=(tt.AsyncSubject=function(t){function e(t){return he(this),this.isStopped?(this.hasError?t.onError(this.error):this.hasValue?(t.onNext(this.value),t.onCompleted()):t.onCompleted(),ce):(this.observers.push(t),new Mn(this,t))}function n(){t.call(this,e),this.isDisposed=!1,this.isStopped=!1,this.hasValue=!1,this.observers=[],this.hasError=!1}return Zt(n,t),te(n.prototype,je,{hasObservers:function(){return he(this),this.observers.length>0},onCompleted:function(){var t,e;if(he(this),!this.isStopped){this.isStopped=!0;var n=u(this.observers),e=n.length;if(this.hasValue)for(t=0;e>t;t++){var r=n[t];r.onNext(this.value),r.onCompleted()}else for(t=0;e>t;t++)n[t].onCompleted();this.observers.length=0}},onError:function(t){if(he(this),!this.isStopped){this.isStopped=!0,this.hasError=!0,this.error=t;for(var e=0,n=u(this.observers),r=n.length;r>e;e++)n[e].onError(t);this.observers.length=0}},onNext:function(t){he(this),this.isStopped||(this.value=t,this.hasValue=!0)},dispose:function(){this.isDisposed=!0,this.observers=null,this.exception=null,this.value=null}}),n}(We),tt.AnonymousSubject=function(t){function e(t){return this.observable.subscribe(t)}function n(n,r){this.observer=n,this.observable=r,t.call(this,e)}return Zt(n,t),te(n.prototype,je.prototype,{onCompleted:function(){this.observer.onCompleted()},onError:function(t){this.observer.onError(t)},onNext:function(t){this.observer.onNext(t)}}),n}(We));"function"==typeof t&&"object"==typeof t.amd&&t.amd?(X.Rx=tt,t(function(){return tt})):Q&&K?Y?(K.exports=tt).Rx=tt:Q.Rx=tt:X.Rx=tt;var $n=f()}).call(this)}).call(this,e(150),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{150:150}]},{},[1])(1)});
3474 }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
3476 },{}],16:[function(require,module,exports){
3478 var topLevel = typeof global !== 'undefined' ? global :
3479 typeof window !== 'undefined' ? window : {}
3480 var minDoc = require('min-document');
3484 if (typeof document !== 'undefined') {
3487 doccy = topLevel['__GLOBAL_DOCUMENT_CACHE@4'];
3490 doccy = topLevel['__GLOBAL_DOCUMENT_CACHE@4'] = minDoc;
3494 module.exports = doccy;
3496 }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
3498 },{"min-document":4}],17:[function(require,module,exports){
3499 exports.read = function (buffer, offset, isLE, mLen, nBytes) {
3501 var eLen = nBytes * 8 - mLen - 1
3502 var eMax = (1 << eLen) - 1
3503 var eBias = eMax >> 1
3505 var i = isLE ? (nBytes - 1) : 0
3506 var d = isLE ? -1 : 1
3507 var s = buffer[offset + i]
3511 e = s & ((1 << (-nBits)) - 1)
3514 for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {}
3516 m = e & ((1 << (-nBits)) - 1)
3519 for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {}
3523 } else if (e === eMax) {
3524 return m ? NaN : ((s ? -1 : 1) * Infinity)
3526 m = m + Math.pow(2, mLen)
3529 return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
3532 exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
3534 var eLen = nBytes * 8 - mLen - 1
3535 var eMax = (1 << eLen) - 1
3536 var eBias = eMax >> 1
3537 var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
3538 var i = isLE ? 0 : (nBytes - 1)
3539 var d = isLE ? 1 : -1
3540 var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
3542 value = Math.abs(value)
3544 if (isNaN(value) || value === Infinity) {
3545 m = isNaN(value) ? 1 : 0
3548 e = Math.floor(Math.log(value) / Math.LN2)
3549 if (value * (c = Math.pow(2, -e)) < 1) {
3553 if (e + eBias >= 1) {
3556 value += rt * Math.pow(2, 1 - eBias)
3558 if (value * c >= 2) {
3563 if (e + eBias >= eMax) {
3566 } else if (e + eBias >= 1) {
3567 m = (value * c - 1) * Math.pow(2, mLen)
3570 m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
3575 for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
3579 for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
3581 buffer[offset + i - d] |= s * 128
3584 },{}],18:[function(require,module,exports){
3588 /*global window, global*/
3590 var root = typeof window !== 'undefined' ?
3591 window : typeof global !== 'undefined' ?
3594 module.exports = Individual;
3596 function Individual(key, value) {
3606 }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
3608 },{}],19:[function(require,module,exports){
3611 var Individual = require('./index.js');
3613 module.exports = OneVersion;
3615 function OneVersion(moduleName, version, defaultValue) {
3616 var key = '__INDIVIDUAL_ONE_VERSION_' + moduleName;
3617 var enforceKey = key + '_ENFORCE_SINGLETON';
3619 var versionValue = Individual(enforceKey, version);
3621 if (versionValue !== version) {
3622 throw new Error('Can only have one copy of ' +
3623 moduleName + '.\n' +
3624 'You already have version ' + versionValue +
3626 'This means you cannot install version ' + version);
3629 return Individual(key, defaultValue);
3632 },{"./index.js":18}],20:[function(require,module,exports){
3635 module.exports = function isObject(x) {
3636 return typeof x === "object" && x !== null;
3639 },{}],21:[function(require,module,exports){
3640 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
3641 /* Geohash encoding/decoding and associated functions (c) Chris Veness 2014-2016 / MIT Licence */
3642 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
3648 * Geohash encode, decode, bounds, neighbours.
3654 /* (Geohash-specific) Base32 map */
3655 Geohash.base32 = '0123456789bcdefghjkmnpqrstuvwxyz';
3658 * Encodes latitude/longitude to geohash, either to specified precision or to automatically
3659 * evaluated precision.
3661 * @param {number} lat - Latitude in degrees.
3662 * @param {number} lon - Longitude in degrees.
3663 * @param {number} [precision] - Number of characters in resulting geohash.
3664 * @returns {string} Geohash of supplied latitude/longitude.
3665 * @throws Invalid geohash.
3668 * var geohash = Geohash.encode(52.205, 0.119, 7); // geohash: 'u120fxw'
3670 Geohash.encode = function(lat, lon, precision) {
3672 if (typeof precision == 'undefined') {
3673 // refine geohash until it matches precision of supplied lat/lon
3674 for (var p=1; p<=12; p++) {
3675 var hash = Geohash.encode(lat, lon, p);
3676 var posn = Geohash.decode(hash);
3677 if (posn.lat==lat && posn.lon==lon) return hash;
3679 precision = 12; // set to maximum
3684 precision = Number(precision);
3686 if (isNaN(lat) || isNaN(lon) || isNaN(precision)) throw new Error('Invalid geohash');
3688 var idx = 0; // index into base32 map
3689 var bit = 0; // each char holds 5 bits
3693 var latMin = -90, latMax = 90;
3694 var lonMin = -180, lonMax = 180;
3696 while (geohash.length < precision) {
3698 // bisect E-W longitude
3699 var lonMid = (lonMin + lonMax) / 2;
3700 if (lon >= lonMid) {
3708 // bisect N-S latitude
3709 var latMid = (latMin + latMax) / 2;
3710 if (lat >= latMid) {
3721 // 5 bits gives us a character: append it and start over
3722 geohash += Geohash.base32.charAt(idx);
3733 * Decode geohash to latitude/longitude (location is approximate centre of geohash cell,
3734 * to reasonable precision).
3736 * @param {string} geohash - Geohash string to be converted to latitude/longitude.
3737 * @returns {{lat:number, lon:number}} (Center of) geohashed location.
3738 * @throws Invalid geohash.
3741 * var latlon = Geohash.decode('u120fxw'); // latlon: { lat: 52.205, lon: 0.1188 }
3743 Geohash.decode = function(geohash) {
3745 var bounds = Geohash.bounds(geohash); // <-- the hard work
3746 // now just determine the centre of the cell...
3748 var latMin = bounds.sw.lat, lonMin = bounds.sw.lon;
3749 var latMax = bounds.ne.lat, lonMax = bounds.ne.lon;
3752 var lat = (latMin + latMax)/2;
3753 var lon = (lonMin + lonMax)/2;
3755 // round to close to centre without excessive precision: ⌊2-log10(Δ°)⌋ decimal places
3756 lat = lat.toFixed(Math.floor(2-Math.log(latMax-latMin)/Math.LN10));
3757 lon = lon.toFixed(Math.floor(2-Math.log(lonMax-lonMin)/Math.LN10));
3759 return { lat: Number(lat), lon: Number(lon) };
3764 * Returns SW/NE latitude/longitude bounds of specified geohash.
3766 * @param {string} geohash - Cell that bounds are required of.
3767 * @returns {{sw: {lat: number, lon: number}, ne: {lat: number, lon: number}}}
3768 * @throws Invalid geohash.
3770 Geohash.bounds = function(geohash) {
3771 if (geohash.length === 0) throw new Error('Invalid geohash');
3773 geohash = geohash.toLowerCase();
3776 var latMin = -90, latMax = 90;
3777 var lonMin = -180, lonMax = 180;
3779 for (var i=0; i<geohash.length; i++) {
3780 var chr = geohash.charAt(i);
3781 var idx = Geohash.base32.indexOf(chr);
3782 if (idx == -1) throw new Error('Invalid geohash');
3784 for (var n=4; n>=0; n--) {
3785 var bitN = idx >> n & 1;
3788 var lonMid = (lonMin+lonMax) / 2;
3796 var latMid = (latMin+latMax) / 2;
3808 sw: { lat: latMin, lon: lonMin },
3809 ne: { lat: latMax, lon: lonMax },
3817 * Determines adjacent cell in given direction.
3819 * @param geohash - Cell to which adjacent cell is required.
3820 * @param direction - Direction from geohash (N/S/E/W).
3821 * @returns {string} Geocode of adjacent cell.
3822 * @throws Invalid geohash.
3824 Geohash.adjacent = function(geohash, direction) {
3825 // based on github.com/davetroy/geohash-js
3827 geohash = geohash.toLowerCase();
3828 direction = direction.toLowerCase();
3830 if (geohash.length === 0) throw new Error('Invalid geohash');
3831 if ('nsew'.indexOf(direction) == -1) throw new Error('Invalid direction');
3834 n: [ 'p0r21436x8zb9dcf5h7kjnmqesgutwvy', 'bc01fg45238967deuvhjyznpkmstqrwx' ],
3835 s: [ '14365h7k9dcfesgujnmqp0r2twvyx8zb', '238967debc01fg45kmstqrwxuvhjyznp' ],
3836 e: [ 'bc01fg45238967deuvhjyznpkmstqrwx', 'p0r21436x8zb9dcf5h7kjnmqesgutwvy' ],
3837 w: [ '238967debc01fg45kmstqrwxuvhjyznp', '14365h7k9dcfesgujnmqp0r2twvyx8zb' ],
3840 n: [ 'prxz', 'bcfguvyz' ],
3841 s: [ '028b', '0145hjnp' ],
3842 e: [ 'bcfguvyz', 'prxz' ],
3843 w: [ '0145hjnp', '028b' ],
3846 var lastCh = geohash.slice(-1); // last character of hash
3847 var parent = geohash.slice(0, -1); // hash without last character
3849 var type = geohash.length % 2;
3851 // check for edge-cases which don't share common prefix
3852 if (border[direction][type].indexOf(lastCh) != -1 && parent !== '') {
3853 parent = Geohash.adjacent(parent, direction);
3856 // append letter for direction to parent
3857 return parent + Geohash.base32.charAt(neighbour[direction][type].indexOf(lastCh));
3862 * Returns all 8 adjacent cells to specified geohash.
3864 * @param {string} geohash - Geohash neighbours are required of.
3865 * @returns {{n,ne,e,se,s,sw,w,nw: string}}
3866 * @throws Invalid geohash.
3868 Geohash.neighbours = function(geohash) {
3870 'n': Geohash.adjacent(geohash, 'n'),
3871 'ne': Geohash.adjacent(Geohash.adjacent(geohash, 'n'), 'e'),
3872 'e': Geohash.adjacent(geohash, 'e'),
3873 'se': Geohash.adjacent(Geohash.adjacent(geohash, 's'), 'e'),
3874 's': Geohash.adjacent(geohash, 's'),
3875 'sw': Geohash.adjacent(Geohash.adjacent(geohash, 's'), 'w'),
3876 'w': Geohash.adjacent(geohash, 'w'),
3877 'nw': Geohash.adjacent(Geohash.adjacent(geohash, 'n'), 'w'),
3882 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
3883 if (typeof module != 'undefined' && module.exports) module.exports = Geohash; // CommonJS, node.js
3885 },{}],22:[function(require,module,exports){
3888 * Martinez polygon clipping algorithm, does boolean operation on polygons (multipolygons, polygons with holes etc): intersection, union, difference, xor
3890 * @author Alex Milevski <info@w8r.name>
3895 (function (global, factory) {
3896 typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
3897 typeof define === 'function' && define.amd ? define(['exports'], factory) :
3898 (factory((global.martinez = {})));
3899 }(this, (function (exports) { 'use strict';
3901 function DEFAULT_COMPARE (a, b) { return a > b ? 1 : a < b ? -1 : 0; }
3903 var SplayTree = function SplayTree(compare, noDuplicates) {
3904 if ( compare === void 0 ) compare = DEFAULT_COMPARE;
3905 if ( noDuplicates === void 0 ) noDuplicates = false;
3907 this._compare = compare;
3910 this._noDuplicates = !!noDuplicates;
3913 var prototypeAccessors = { size: { configurable: true } };
3916 SplayTree.prototype.rotateLeft = function rotateLeft (x) {
3920 if (y.left) { y.left.parent = x; }
3921 y.parent = x.parent;
3924 if (!x.parent) { this._root = y; }
3925 else if (x === x.parent.left) { x.parent.left = y; }
3926 else { x.parent.right = y; }
3927 if (y) { y.left = x; }
3932 SplayTree.prototype.rotateRight = function rotateRight (x) {
3936 if (y.right) { y.right.parent = x; }
3937 y.parent = x.parent;
3940 if (!x.parent) { this._root = y; }
3941 else if(x === x.parent.left) { x.parent.left = y; }
3942 else { x.parent.right = y; }
3943 if (y) { y.right = x; }
3948 SplayTree.prototype._splay = function _splay (x) {
3954 if (p.left === x) { this$1.rotateRight(p); }
3955 else { this$1.rotateLeft(p); }
3956 } else if (p.left === x && p.parent.left === p) {
3957 this$1.rotateRight(p.parent);
3958 this$1.rotateRight(p);
3959 } else if (p.right === x && p.parent.right === p) {
3960 this$1.rotateLeft(p.parent);
3961 this$1.rotateLeft(p);
3962 } else if (p.left === x && p.parent.right === p) {
3963 this$1.rotateRight(p);
3964 this$1.rotateLeft(p);
3966 this$1.rotateLeft(p);
3967 this$1.rotateRight(p);
3973 SplayTree.prototype.splay = function splay (x) {
3976 var p, gp, ggp, l, r;
3982 if (gp && gp.parent) {
3984 if (ggp.left === gp) { ggp.left= x; }
3985 else { ggp.right = x; }
3992 l = x.left; r = x.right;
3994 if (x === p.left) { // left
3996 if (gp.left === p) {
4000 gp.left.parent = gp;
4001 } else { gp.left = null; }
4010 } else { gp.right = null; }
4019 } else { p.left = null; }
4025 if (gp.right === p) {
4029 gp.right.parent = gp;
4030 } else { gp.right = null; }
4039 } else { gp.left = null; }
4048 } else { p.right = null; }
4057 SplayTree.prototype.replace = function replace (u, v) {
4058 if (!u.parent) { this._root = v; }
4059 else if (u === u.parent.left) { u.parent.left = v; }
4060 else { u.parent.right = v; }
4061 if (v) { v.parent = u.parent; }
4065 SplayTree.prototype.minNode = function minNode (u) {
4066 if ( u === void 0 ) u = this._root;
4068 if (u) { while (u.left) { u = u.left; } }
4073 SplayTree.prototype.maxNode = function maxNode (u) {
4074 if ( u === void 0 ) u = this._root;
4076 if (u) { while (u.right) { u = u.right; } }
4081 SplayTree.prototype.insert = function insert (key, data) {
4084 var comp = this._compare;
4087 if (this._noDuplicates) {
4090 cmp = comp(z.key, key);
4091 if (cmp === 0) { return; }
4092 else if (comp(z.key, key) < 0) { z = z.right; }
4093 else { z = z.left; }
4098 if (comp(z.key, key) < 0) { z = z.right; }
4099 else { z = z.left; }
4103 z = { key: key, data: data, left: null, right: null, parent: p };
4105 if (!p) { this._root = z; }
4106 else if (comp(p.key, z.key) < 0) { p.right = z; }
4115 SplayTree.prototype.find = function find (key) {
4117 var comp = this._compare;
4119 var cmp = comp(z.key, key);
4120 if (cmp < 0) { z = z.right; }
4121 else if (cmp > 0) { z = z.left; }
4128 * Whether the tree contains a node with the given key
4130 * @return {boolean} true/false
4132 SplayTree.prototype.contains = function contains (key) {
4133 var node = this._root;
4134 var comparator = this._compare;
4136 var cmp = comparator(key, node.key);
4137 if (cmp === 0) { return true; }
4138 else if (cmp < 0) { node = node.left; }
4139 else { node = node.right; }
4146 SplayTree.prototype.remove = function remove (key) {
4147 var z = this.find(key);
4149 if (!z) { return false; }
4153 if (!z.left) { this.replace(z, z.right); }
4154 else if (!z.right) { this.replace(z, z.left); }
4156 var y = this.minNode(z.right);
4157 if (y.parent !== z) {
4158 this.replace(y, y.right);
4172 SplayTree.prototype.removeNode = function removeNode (z) {
4173 if (!z) { return false; }
4177 if (!z.left) { this.replace(z, z.right); }
4178 else if (!z.right) { this.replace(z, z.left); }
4180 var y = this.minNode(z.right);
4181 if (y.parent !== z) {
4182 this.replace(y, y.right);
4196 SplayTree.prototype.erase = function erase (key) {
4197 var z = this.find(key);
4208 sMax = this.maxNode(s);
4213 if (s) { sMax.right = t; }
4214 else { this._root = t; }
4222 * Removes and returns the node with smallest key
4225 SplayTree.prototype.pop = function pop () {
4226 var node = this._root, returnValue = null;
4228 while (node.left) { node = node.left; }
4229 returnValue = { key: node.key, data: node.data };
4230 this.remove(node.key);
4236 /* eslint-disable class-methods-use-this */
4243 SplayTree.prototype.next = function next (node) {
4244 var successor = node;
4246 if (successor.right) {
4247 successor = successor.right;
4248 while (successor && successor.left) { successor = successor.left; }
4250 successor = node.parent;
4251 while (successor && successor.right === node) {
4252 node = successor; successor = successor.parent;
4265 SplayTree.prototype.prev = function prev (node) {
4266 var predecessor = node;
4268 if (predecessor.left) {
4269 predecessor = predecessor.left;
4270 while (predecessor && predecessor.right) { predecessor = predecessor.right; }
4272 predecessor = node.parent;
4273 while (predecessor && predecessor.left === node) {
4275 predecessor = predecessor.parent;
4281 /* eslint-enable class-methods-use-this */
4285 * @param{forEachCallback} callback
4286 * @return {SplayTree}
4288 SplayTree.prototype.forEach = function forEach (callback) {
4289 var current = this._root;
4290 var s = [], done = false, i = 0;
4293 // Reach the left most Node of the current Node
4295 // Place pointer to a tree node on the stack
4296 // before traversing the node's left subtree
4298 current = current.left;
4300 // BackTrack from the empty subtree and visit the Node
4301 // at the top of the stack; however, if the stack is
4302 // empty you are done
4305 callback(current, i++);
4307 // We have visited the node and its left
4308 // subtree. Now, it's right subtree's turn
4309 current = current.right;
4310 } else { done = true; }
4318 * Walk key range from `low` to `high`. Stops if `fn` returns a value.
4321 * @param{Function} fn
4323 * @return {SplayTree}
4325 SplayTree.prototype.range = function range (low, high, fn, ctx) {
4329 var compare = this._compare;
4330 var node = this._root, cmp;
4332 while (Q.length !== 0 || node) {
4338 cmp = compare(node.key, high);
4341 } else if (compare(node.key, low) >= 0) {
4342 if (fn.call(ctx, node)) { return this$1; } // stop if smth is returned
4351 * Returns all keys in order
4352 * @return {Array<Key>}
4354 SplayTree.prototype.keys = function keys () {
4355 var current = this._root;
4356 var s = [], r = [], done = false;
4361 current = current.left;
4365 r.push(current.key);
4366 current = current.right;
4367 } else { done = true; }
4375 * Returns `data` fields of all nodes in order.
4376 * @return {Array<Value>}
4378 SplayTree.prototype.values = function values () {
4379 var current = this._root;
4380 var s = [], r = [], done = false;
4385 current = current.left;
4389 r.push(current.data);
4390 current = current.right;
4391 } else { done = true; }
4399 * Returns node at given index
4400 * @param{number} index
4403 SplayTree.prototype.at = function at (index) {
4404 // removed after a consideration, more misleading than useful
4405 // index = index % this.size;
4406 // if (index < 0) index = this.size - index;
4408 var current = this._root;
4409 var s = [], done = false, i = 0;
4414 current = current.left;
4418 if (i === index) { return current; }
4420 current = current.right;
4421 } else { done = true; }
4428 * Bulk-load items. Both array have to be same size
4429 * @param{Array<Key>} keys
4430 * @param{Array<Value>}[values]
4431 * @param{Boolean} [presort=false] Pre-sort keys and values, using
4432 * tree's comparator. Sorting is done
4436 SplayTree.prototype.load = function load (keys, values, presort) {
4437 if ( keys === void 0 ) keys = [];
4438 if ( values === void 0 ) values = [];
4439 if ( presort === void 0 ) presort = false;
4441 if (this._size !== 0) { throw new Error('bulk-load: tree is not empty'); }
4442 var size = keys.length;
4443 if (presort) { sort(keys, values, 0, size - 1, this._compare); }
4444 this._root = loadRecursive(null, keys, values, 0, size);
4450 SplayTree.prototype.min = function min () {
4451 var node = this.minNode(this._root);
4452 if (node) { return node.key; }
4453 else { return null; }
4457 SplayTree.prototype.max = function max () {
4458 var node = this.maxNode(this._root);
4459 if (node) { return node.key; }
4460 else { return null; }
4463 SplayTree.prototype.isEmpty = function isEmpty () { return this._root === null; };
4464 prototypeAccessors.size.get = function () { return this._size; };
4468 * Create a tree and load it with items
4469 * @param{Array<Key>} keys
4470 * @param{Array<Value>?} [values]
4472 * @param{Function?} [comparator]
4473 * @param{Boolean?} [presort=false] Pre-sort keys and values, using
4474 * tree's comparator. Sorting is done
4476 * @param{Boolean?} [noDuplicates=false] Allow duplicates
4477 * @return {SplayTree}
4479 SplayTree.createTree = function createTree (keys, values, comparator, presort, noDuplicates) {
4480 return new SplayTree(comparator, noDuplicates).load(keys, values, presort);
4483 Object.defineProperties( SplayTree.prototype, prototypeAccessors );
4486 function loadRecursive (parent, keys, values, start, end) {
4487 var size = end - start;
4489 var middle = start + Math.floor(size / 2);
4490 var key = keys[middle];
4491 var data = values[middle];
4492 var node = { key: key, data: data, parent: parent };
4493 node.left = loadRecursive(node, keys, values, start, middle);
4494 node.right = loadRecursive(node, keys, values, middle + 1, end);
4501 function sort(keys, values, left, right, compare) {
4502 if (left >= right) { return; }
4504 var pivot = keys[(left + right) >> 1];
4509 do { i++; } while (compare(keys[i], pivot) < 0);
4510 do { j--; } while (compare(keys[j], pivot) > 0);
4511 if (i >= j) { break; }
4518 values[i] = values[j];
4522 sort(keys, values, left, j, compare);
4523 sort(keys, values, j + 1, right, compare);
4527 var NON_CONTRIBUTING = 1;
4528 var SAME_TRANSITION = 2;
4529 var DIFFERENT_TRANSITION = 3;
4531 var INTERSECTION = 0;
4537 * @param {SweepEvent} event
4538 * @param {SweepEvent} prev
4539 * @param {Operation} operation
4541 function computeFields (event, prev, operation) {
4542 // compute inOut and otherInOut fields
4543 if (prev === null) {
4544 event.inOut = false;
4545 event.otherInOut = true;
4547 // previous line segment in sweepline belongs to the same polygon
4549 if (event.isSubject === prev.isSubject) {
4550 event.inOut = !prev.inOut;
4551 event.otherInOut = prev.otherInOut;
4553 // previous line segment in sweepline belongs to the clipping polygon
4555 event.inOut = !prev.otherInOut;
4556 event.otherInOut = prev.isVertical() ? !prev.inOut : prev.inOut;
4559 // compute prevInResult field
4561 event.prevInResult = (!inResult(prev, operation) || prev.isVertical())
4562 ? prev.prevInResult : prev;
4566 // check if the line segment belongs to the Boolean operation
4567 event.inResult = inResult(event, operation);
4571 /* eslint-disable indent */
4572 function inResult(event, operation) {
4573 switch (event.type) {
4575 switch (operation) {
4577 return !event.otherInOut;
4579 return event.otherInOut;
4581 // return (event.isSubject && !event.otherInOut) ||
4582 // (!event.isSubject && event.otherInOut);
4583 return (event.isSubject && event.otherInOut) ||
4584 (!event.isSubject && !event.otherInOut);
4589 case SAME_TRANSITION:
4590 return operation === INTERSECTION || operation === UNION;
4591 case DIFFERENT_TRANSITION:
4592 return operation === DIFFERENCE;
4593 case NON_CONTRIBUTING:
4598 /* eslint-enable indent */
4600 var SweepEvent = function SweepEvent (point, left, otherEvent, isSubject, edgeType) {
4609 * @type {Array.<Number>}
4614 * Other edge reference
4615 * @type {SweepEvent}
4617 this.otherEvent = otherEvent;
4620 * Belongs to source or clipping polygon
4623 this.isSubject = isSubject;
4626 * Edge contribution type
4629 this.type = edgeType || NORMAL;
4633 * In-out transition for the sweepline crossing polygon
4642 this.otherInOut = false;
4645 * Previous event in result?
4646 * @type {SweepEvent}
4648 this.prevInResult = null;
4651 * Does event belong to result?
4654 this.inResult = false;
4662 this.resultInOut = false;
4664 this.isExteriorRing = true;
4669 * @param{Array.<Number>}p
4672 SweepEvent.prototype.isBelow = function isBelow (p) {
4673 var p0 = this.point, p1 = this.otherEvent.point;
4675 ? (p0[0] - p[0]) * (p1[1] - p[1]) - (p1[0] - p[0]) * (p0[1] - p[1]) > 0
4676 // signedArea(this.point, this.otherEvent.point, p) > 0 :
4677 : (p1[0] - p[0]) * (p0[1] - p[1]) - (p0[0] - p[0]) * (p1[1] - p[1]) > 0;
4678 //signedArea(this.otherEvent.point, this.point, p) > 0;
4683 * @param{Array.<Number>}p
4686 SweepEvent.prototype.isAbove = function isAbove (p) {
4687 return !this.isBelow(p);
4694 SweepEvent.prototype.isVertical = function isVertical () {
4695 return this.point[0] === this.otherEvent.point[0];
4699 SweepEvent.prototype.clone = function clone () {
4700 var copy = new SweepEvent(
4701 this.point, this.left, this.otherEvent, this.isSubject, this.type);
4703 copy.inResult = this.inResult;
4704 copy.prevInResult = this.prevInResult;
4705 copy.isExteriorRing = this.isExteriorRing;
4706 copy.inOut = this.inOut;
4707 copy.otherInOut = this.otherInOut;
4712 function equals(p1, p2) {
4713 if (p1[0] === p2[0]) {
4714 if (p1[1] === p2[1]) {
4723 // const EPSILON = 1e-9;
4724 // const abs = Math.abs;
4725 // TODO https://github.com/w8r/martinez/issues/6#issuecomment-262847164
4726 // Precision problem.
4728 // module.exports = function equals(p1, p2) {
4729 // return abs(p1[0] - p2[0]) <= EPSILON && abs(p1[1] - p2[1]) <= EPSILON;
4733 * Signed area of the triangle (p0, p1, p2)
4734 * @param {Array.<Number>} p0
4735 * @param {Array.<Number>} p1
4736 * @param {Array.<Number>} p2
4739 function signedArea(p0, p1, p2) {
4740 return (p0[0] - p2[0]) * (p1[1] - p2[1]) - (p1[0] - p2[0]) * (p0[1] - p2[1]);
4744 * @param {SweepEvent} e1
4745 * @param {SweepEvent} e2
4748 function compareEvents(e1, e2) {
4752 // Different x-coordinate
4753 if (p1[0] > p2[0]) { return 1; }
4754 if (p1[0] < p2[0]) { return -1; }
4756 // Different points, but same x-coordinate
4757 // Event with lower y-coordinate is processed first
4758 if (p1[1] !== p2[1]) { return p1[1] > p2[1] ? 1 : -1; }
4760 return specialCases(e1, e2, p1, p2);
4764 /* eslint-disable no-unused-vars */
4765 function specialCases(e1, e2, p1, p2) {
4766 // Same coordinates, but one is a left endpoint and the other is
4767 // a right endpoint. The right endpoint is processed first
4768 if (e1.left !== e2.left)
4769 { return e1.left ? 1 : -1; }
4771 // const p2 = e1.otherEvent.point, p3 = e2.otherEvent.point;
4772 // const sa = (p1[0] - p3[0]) * (p2[1] - p3[1]) - (p2[0] - p3[0]) * (p1[1] - p3[1])
4773 // Same coordinates, both events
4774 // are left endpoints or right endpoints.
4776 if (signedArea(p1, e1.otherEvent.point, e2.otherEvent.point) !== 0) {
4777 // the event associate to the bottom segment is processed first
4778 return (!e1.isBelow(e2.otherEvent.point)) ? 1 : -1;
4781 return (!e1.isSubject && e2.isSubject) ? 1 : -1;
4783 /* eslint-enable no-unused-vars */
4786 * @param {SweepEvent} se
4787 * @param {Array.<Number>} p
4788 * @param {Queue} queue
4791 function divideSegment(se, p, queue) {
4792 var r = new SweepEvent(p, false, se, se.isSubject);
4793 var l = new SweepEvent(p, true, se.otherEvent, se.isSubject);
4795 /* eslint-disable no-console */
4796 if (equals(se.point, se.otherEvent.point)) {
4798 console.warn('what is that, a collapsed segment?', se);
4800 /* eslint-enable no-console */
4802 r.contourId = l.contourId = se.contourId;
4804 // avoid a rounding error. The left event would be processed after the right event
4805 if (compareEvents(l, se.otherEvent) > 0) {
4806 se.otherEvent.left = true;
4810 // avoid a rounding error. The left event would be processed after the right event
4811 // if (compareEvents(se, r) > 0) {}
4813 se.otherEvent.otherEvent = l;
4825 * Finds the magnitude of the cross product of two vectors (if we pretend
4826 * they're in three dimensions)
4828 * @param {Object} a First vector
4829 * @param {Object} b Second vector
4831 * @returns {Number} The magnitude of the cross product
4833 function crossProduct(a, b) {
4834 return (a[0] * b[1]) - (a[1] * b[0]);
4838 * Finds the dot product of two vectors.
4840 * @param {Object} a First vector
4841 * @param {Object} b Second vector
4843 * @returns {Number} The dot product
4845 function dotProduct(a, b) {
4846 return (a[0] * b[0]) + (a[1] * b[1]);
4850 * Finds the intersection (if any) between two line segments a and b, given the
4851 * line segments' end points a1, a2 and b1, b2.
4853 * This algorithm is based on Schneider and Eberly.
4854 * http://www.cimec.org.ar/~ncalvo/Schneider_Eberly.pdf
4857 * @param {Array.<Number>} a1 point of first line
4858 * @param {Array.<Number>} a2 point of first line
4859 * @param {Array.<Number>} b1 point of second line
4860 * @param {Array.<Number>} b2 point of second line
4861 * @param {Boolean=} noEndpointTouch whether to skip single touchpoints
4862 * (meaning connected segments) as
4864 * @returns {Array.<Array.<Number>>|Null} If the lines intersect, the point of
4865 * intersection. If they overlap, the two end points of the overlapping segment.
4868 function intersection (a1, a2, b1, b2, noEndpointTouch) {
4869 // The algorithm expects our lines in the form P + sd, where P is a point,
4870 // s is on the interval [0, 1], and d is a vector.
4871 // We are passed two points. P can be the first point of each pair. The
4872 // vector, then, could be thought of as the distance (in x and y components)
4873 // from the first point to the second point.
4874 // So first, let's make our vectors:
4875 var va = [a2[0] - a1[0], a2[1] - a1[1]];
4876 var vb = [b2[0] - b1[0], b2[1] - b1[1]];
4877 // We also define a function to convert back to regular point form:
4879 /* eslint-disable arrow-body-style */
4881 function toPoint(p, s, d) {
4888 /* eslint-enable arrow-body-style */
4890 // The rest is pretty much a straight port of the algorithm.
4891 var e = [b1[0] - a1[0], b1[1] - a1[1]];
4892 var kross = crossProduct(va, vb);
4893 var sqrKross = kross * kross;
4894 var sqrLenA = dotProduct(va, va);
4895 //const sqrLenB = dotProduct(vb, vb);
4897 // Check for line intersection. This works because of the properties of the
4898 // cross product -- specifically, two vectors are parallel if and only if the
4899 // cross product is the 0 vector. The full calculation involves relative error
4900 // to account for possible very small line segments. See Schneider & Eberly
4902 if (sqrKross > 0/* EPS * sqrLenB * sqLenA */) {
4903 // If they're not parallel, then (because these are line segments) they
4904 // still might not actually intersect. This code checks that the
4905 // intersection point of the lines is actually on both line segments.
4906 var s = crossProduct(e, vb) / kross;
4907 if (s < 0 || s > 1) {
4908 // not on line segment a
4911 var t = crossProduct(e, va) / kross;
4912 if (t < 0 || t > 1) {
4913 // not on line segment b
4916 if (s === 0 || s === 1) {
4917 // on an endpoint of line segment a
4918 return noEndpointTouch ? null : [toPoint(a1, s, va)];
4920 if (t === 0 || t === 1) {
4921 // on an endpoint of line segment b
4922 return noEndpointTouch ? null : [toPoint(b1, t, vb)];
4924 return [toPoint(a1, s, va)];
4927 // If we've reached this point, then the lines are either parallel or the
4928 // same, but the segments could overlap partially or fully, or not at all.
4929 // So we need to find the overlap, if any. To do that, we can use e, which is
4930 // the (vector) difference between the two initial points. If this is parallel
4931 // with the line itself, then the two lines are the same line, and there will
4933 //const sqrLenE = dotProduct(e, e);
4934 kross = crossProduct(e, va);
4935 sqrKross = kross * kross;
4937 if (sqrKross > 0 /* EPS * sqLenB * sqLenE */) {
4938 // Lines are just parallel, not the same. No overlap.
4942 var sa = dotProduct(va, e) / sqrLenA;
4943 var sb = sa + dotProduct(va, vb) / sqrLenA;
4944 var smin = Math.min(sa, sb);
4945 var smax = Math.max(sa, sb);
4947 // this is, essentially, the FindIntersection acting on floats from
4948 // Schneider & Eberly, just inlined into this function.
4949 if (smin <= 1 && smax >= 0) {
4951 // overlap on an end point
4953 return noEndpointTouch ? null : [toPoint(a1, smin > 0 ? smin : 0, va)];
4957 return noEndpointTouch ? null : [toPoint(a1, smax < 1 ? smax : 1, va)];
4960 if (noEndpointTouch && smin === 0 && smax === 1) { return null; }
4962 // There's overlap on a segment -- two points of intersection. Return both.
4964 toPoint(a1, smin > 0 ? smin : 0, va),
4965 toPoint(a1, smax < 1 ? smax : 1, va)
4973 * @param {SweepEvent} se1
4974 * @param {SweepEvent} se2
4975 * @param {Queue} queue
4978 function possibleIntersection (se1, se2, queue) {
4979 // that disallows self-intersecting polygons,
4980 // did cost us half a day, so I'll leave it
4982 // if (se1.isSubject === se2.isSubject) return;
4983 var inter = intersection(
4984 se1.point, se1.otherEvent.point,
4985 se2.point, se2.otherEvent.point
4988 var nintersections = inter ? inter.length : 0;
4989 if (nintersections === 0) { return 0; } // no intersection
4991 // the line segments intersect at an endpoint of both line segments
4992 if ((nintersections === 1) &&
4993 (equals(se1.point, se2.point) ||
4994 equals(se1.otherEvent.point, se2.otherEvent.point))) {
4998 if (nintersections === 2 && se1.isSubject === se2.isSubject) {
4999 // if(se1.contourId === se2.contourId){
5000 // console.warn('Edges of the same polygon overlap',
5001 // se1.point, se1.otherEvent.point, se2.point, se2.otherEvent.point);
5003 //throw new Error('Edges of the same polygon overlap');
5007 // The line segments associated to se1 and se2 intersect
5008 if (nintersections === 1) {
5010 // if the intersection point is not an endpoint of se1
5011 if (!equals(se1.point, inter[0]) && !equals(se1.otherEvent.point, inter[0])) {
5012 divideSegment(se1, inter[0], queue);
5015 // if the intersection point is not an endpoint of se2
5016 if (!equals(se2.point, inter[0]) && !equals(se2.otherEvent.point, inter[0])) {
5017 divideSegment(se2, inter[0], queue);
5022 // The line segments associated to se1 and se2 overlap
5024 var leftCoincide = false;
5025 var rightCoincide = false;
5027 if (equals(se1.point, se2.point)) {
5028 leftCoincide = true; // linked
5029 } else if (compareEvents(se1, se2) === 1) {
5030 events.push(se2, se1);
5032 events.push(se1, se2);
5035 if (equals(se1.otherEvent.point, se2.otherEvent.point)) {
5036 rightCoincide = true;
5037 } else if (compareEvents(se1.otherEvent, se2.otherEvent) === 1) {
5038 events.push(se2.otherEvent, se1.otherEvent);
5040 events.push(se1.otherEvent, se2.otherEvent);
5043 if ((leftCoincide && rightCoincide) || leftCoincide) {
5044 // both line segments are equal or share the left endpoint
5045 se2.type = NON_CONTRIBUTING;
5046 se1.type = (se2.inOut === se1.inOut)
5047 ? SAME_TRANSITION : DIFFERENT_TRANSITION;
5049 if (leftCoincide && !rightCoincide) {
5050 // honestly no idea, but changing events selection from [2, 1]
5051 // to [0, 1] fixes the overlapping self-intersecting polygons issue
5052 divideSegment(events[1].otherEvent, events[0].point, queue);
5057 // the line segments share the right endpoint
5058 if (rightCoincide) {
5059 divideSegment(events[0], events[1].point, queue);
5063 // no line segment includes totally the other one
5064 if (events[0] !== events[3].otherEvent) {
5065 divideSegment(events[0], events[1].point, queue);
5066 divideSegment(events[1], events[2].point, queue);
5070 // one line segment includes the other one
5071 divideSegment(events[0], events[1].point, queue);
5072 divideSegment(events[3].otherEvent, events[2].point, queue);
5078 * @param {SweepEvent} le1
5079 * @param {SweepEvent} le2
5082 function compareSegments(le1, le2) {
5083 if (le1 === le2) { return 0; }
5085 // Segments are not collinear
5086 if (signedArea(le1.point, le1.otherEvent.point, le2.point) !== 0 ||
5087 signedArea(le1.point, le1.otherEvent.point, le2.otherEvent.point) !== 0) {
5089 // If they share their left endpoint use the right endpoint to sort
5090 if (equals(le1.point, le2.point)) { return le1.isBelow(le2.otherEvent.point) ? -1 : 1; }
5092 // Different left endpoint: use the left endpoint to sort
5093 if (le1.point[0] === le2.point[0]) { return le1.point[1] < le2.point[1] ? -1 : 1; }
5095 // has the line segment associated to e1 been inserted
5096 // into S after the line segment associated to e2 ?
5097 if (compareEvents(le1, le2) === 1) { return le2.isAbove(le1.point) ? -1 : 1; }
5099 // The line segment associated to e2 has been inserted
5100 // into S after the line segment associated to e1
5101 return le1.isBelow(le2.point) ? -1 : 1;
5104 if (le1.isSubject === le2.isSubject) { // same polygon
5105 var p1 = le1.point, p2 = le2.point;
5106 if (p1[0] === p2[0] && p1[1] === p2[1]/*equals(le1.point, le2.point)*/) {
5107 p1 = le1.otherEvent.point; p2 = le2.otherEvent.point;
5108 if (p1[0] === p2[0] && p1[1] === p2[1]) { return 0; }
5109 else { return le1.contourId > le2.contourId ? 1 : -1; }
5111 } else { // Segments are collinear, but belong to separate polygons
5112 return le1.isSubject ? -1 : 1;
5115 return compareEvents(le1, le2) === 1 ? 1 : -1;
5118 function subdivide(eventQueue, subject, clipping, sbbox, cbbox, operation) {
5119 var sweepLine = new SplayTree(compareSegments);
5120 var sortedEvents = [];
5122 var rightbound = Math.min(sbbox[2], cbbox[2]);
5124 var prev, next, begin;
5126 while (eventQueue.length !== 0) {
5127 var event = eventQueue.pop();
5128 sortedEvents.push(event);
5130 // optimization by bboxes for intersection and difference goes here
5131 if ((operation === INTERSECTION && event.point[0] > rightbound) ||
5132 (operation === DIFFERENCE && event.point[0] > sbbox[2])) {
5137 next = prev = sweepLine.insert(event);
5138 begin = sweepLine.minNode();
5140 if (prev !== begin) { prev = sweepLine.prev(prev); }
5141 else { prev = null; }
5143 next = sweepLine.next(next);
5145 var prevEvent = prev ? prev.key : null;
5146 var prevprevEvent = (void 0);
5147 computeFields(event, prevEvent, operation);
5149 if (possibleIntersection(event, next.key, eventQueue) === 2) {
5150 computeFields(event, prevEvent, operation);
5151 computeFields(event, next.key, operation);
5156 if (possibleIntersection(prev.key, event, eventQueue) === 2) {
5157 var prevprev = prev;
5158 if (prevprev !== begin) { prevprev = sweepLine.prev(prevprev); }
5159 else { prevprev = null; }
5161 prevprevEvent = prevprev ? prevprev.key : null;
5162 computeFields(prevEvent, prevprevEvent, operation);
5163 computeFields(event, prevEvent, operation);
5167 event = event.otherEvent;
5168 next = prev = sweepLine.find(event);
5172 if (prev !== begin) { prev = sweepLine.prev(prev); }
5173 else { prev = null; }
5175 next = sweepLine.next(next);
5176 sweepLine.remove(event);
5179 possibleIntersection(prev.key, next.key, eventQueue);
5184 return sortedEvents;
5188 * @param {Array.<SweepEvent>} sortedEvents
5189 * @return {Array.<SweepEvent>}
5191 function orderEvents(sortedEvents) {
5192 var event, i, len, tmp;
5193 var resultEvents = [];
5194 for (i = 0, len = sortedEvents.length; i < len; i++) {
5195 event = sortedEvents[i];
5196 if ((event.left && event.inResult) ||
5197 (!event.left && event.otherEvent.inResult)) {
5198 resultEvents.push(event);
5201 // Due to overlapping edges the resultEvents array can be not wholly sorted
5205 for (i = 0, len = resultEvents.length; i < len; i++) {
5206 if ((i + 1) < len &&
5207 compareEvents(resultEvents[i], resultEvents[i + 1]) === 1) {
5208 tmp = resultEvents[i];
5209 resultEvents[i] = resultEvents[i + 1];
5210 resultEvents[i + 1] = tmp;
5217 for (i = 0, len = resultEvents.length; i < len; i++) {
5218 event = resultEvents[i];
5222 // imagine, the right event is found in the beginning of the queue,
5223 // when his left counterpart is not marked yet
5224 for (i = 0, len = resultEvents.length; i < len; i++) {
5225 event = resultEvents[i];
5228 event.pos = event.otherEvent.pos;
5229 event.otherEvent.pos = tmp;
5233 return resultEvents;
5238 * @param {Number} pos
5239 * @param {Array.<SweepEvent>} resultEvents
5240 * @param {Object>} processed
5243 function nextPos(pos, resultEvents, processed, origIndex) {
5245 var newPos = pos + 1;
5246 var length = resultEvents.length;
5248 p = resultEvents[pos].point;
5250 if (newPos < length)
5251 { p1 = resultEvents[newPos].point; }
5254 // while in range and not the current one by value
5255 while (newPos < length && p1[0] === p[0] && p1[1] === p[1]) {
5256 if (!processed[newPos]) {
5261 p1 = resultEvents[newPos].point;
5266 while (processed[newPos] && newPos >= origIndex) {
5274 * @param {Array.<SweepEvent>} sortedEvents
5275 * @return {Array.<*>} polygons
5277 function connectEdges(sortedEvents, operation) {
5279 var resultEvents = orderEvents(sortedEvents);
5281 // "false"-filled array
5286 for (i = 0, len = resultEvents.length; i < len; i++) {
5287 if (processed[i]) { continue; }
5290 if (!resultEvents[i].isExteriorRing) {
5291 if (operation === DIFFERENCE && !resultEvents[i].isSubject && result.length === 0) {
5292 result.push(contour);
5293 } else if (result.length === 0) {
5294 result.push([[contour]]);
5296 result[result.length - 1].push(contour[0]);
5298 } else if (operation === DIFFERENCE && !resultEvents[i].isSubject && result.length > 1) {
5299 result[result.length - 1].push(contour[0]);
5301 result.push(contour);
5304 var ringId = result.length - 1;
5307 var initial = resultEvents[i].point;
5308 contour[0].push(initial);
5311 event = resultEvents[pos];
5312 processed[pos] = true;
5315 event.resultInOut = false;
5316 event.contourId = ringId;
5318 event.otherEvent.resultInOut = true;
5319 event.otherEvent.contourId = ringId;
5323 processed[pos] = true;
5324 contour[0].push(resultEvents[pos].point);
5325 pos = nextPos(pos, resultEvents, processed, i);
5328 pos = pos === -1 ? i : pos;
5330 event = resultEvents[pos];
5331 processed[pos] = processed[event.pos] = true;
5332 event.otherEvent.resultInOut = true;
5333 event.otherEvent.contourId = ringId;
5336 // Handle if the result is a polygon (eg not multipoly)
5337 // Commented it again, let's see what do we mean by that
5338 // if (result.length === 1) result = result[0];
5342 var tinyqueue = TinyQueue;
5343 var default_1 = TinyQueue;
5345 function TinyQueue(data, compare) {
5348 if (!(this instanceof TinyQueue)) { return new TinyQueue(data, compare); }
5350 this.data = data || [];
5351 this.length = this.data.length;
5352 this.compare = compare || defaultCompare;
5354 if (this.length > 0) {
5355 for (var i = (this.length >> 1) - 1; i >= 0; i--) { this$1._down(i); }
5359 function defaultCompare(a, b) {
5360 return a < b ? -1 : a > b ? 1 : 0;
5363 TinyQueue.prototype = {
5365 push: function (item) {
5366 this.data.push(item);
5368 this._up(this.length - 1);
5372 if (this.length === 0) { return undefined; }
5374 var top = this.data[0];
5377 if (this.length > 0) {
5378 this.data[0] = this.data[this.length];
5387 return this.data[0];
5390 _up: function (pos) {
5391 var data = this.data;
5392 var compare = this.compare;
5393 var item = data[pos];
5396 var parent = (pos - 1) >> 1;
5397 var current = data[parent];
5398 if (compare(item, current) >= 0) { break; }
5399 data[pos] = current;
5406 _down: function (pos) {
5409 var data = this.data;
5410 var compare = this.compare;
5411 var halfLength = this.length >> 1;
5412 var item = data[pos];
5414 while (pos < halfLength) {
5415 var left = (pos << 1) + 1;
5416 var right = left + 1;
5417 var best = data[left];
5419 if (right < this$1.length && compare(data[right], best) < 0) {
5423 if (compare(best, item) >= 0) { break; }
5432 tinyqueue.default = default_1;
5440 function processPolygon(contourOrHole, isSubject, depth, Q, bbox, isExteriorRing) {
5441 var i, len, s1, s2, e1, e2;
5442 for (i = 0, len = contourOrHole.length - 1; i < len; i++) {
5443 s1 = contourOrHole[i];
5444 s2 = contourOrHole[i + 1];
5445 e1 = new SweepEvent(s1, false, undefined, isSubject);
5446 e2 = new SweepEvent(s2, false, e1, isSubject);
5449 if (s1[0] === s2[0] && s1[1] === s2[1]) {
5450 continue; // skip collapsed edges, or it breaks
5453 e1.contourId = e2.contourId = depth;
5454 if (!isExteriorRing) {
5455 e1.isExteriorRing = false;
5456 e2.isExteriorRing = false;
5458 if (compareEvents(e1, e2) > 0) {
5464 var x = s1[0], y = s1[1];
5465 bbox[0] = min(bbox[0], x);
5466 bbox[1] = min(bbox[1], y);
5467 bbox[2] = max(bbox[2], x);
5468 bbox[3] = max(bbox[3], y);
5470 // Pushing it so the queue is sorted from left to right,
5471 // with object on the left having the highest priority.
5478 function fillQueue(subject, clipping, sbbox, cbbox, operation) {
5479 var eventQueue = new tinyqueue(null, compareEvents);
5480 var polygonSet, isExteriorRing, i, ii, j, jj; //, k, kk;
5482 for (i = 0, ii = subject.length; i < ii; i++) {
5483 polygonSet = subject[i];
5484 for (j = 0, jj = polygonSet.length; j < jj; j++) {
5485 isExteriorRing = j === 0;
5486 if (isExteriorRing) { contourId++; }
5487 processPolygon(polygonSet[j], true, contourId, eventQueue, sbbox, isExteriorRing);
5491 for (i = 0, ii = clipping.length; i < ii; i++) {
5492 polygonSet = clipping[i];
5493 for (j = 0, jj = polygonSet.length; j < jj; j++) {
5494 isExteriorRing = j === 0;
5495 if (operation === DIFFERENCE) { isExteriorRing = false; }
5496 if (isExteriorRing) { contourId++; }
5497 processPolygon(polygonSet[j], false, contourId, eventQueue, cbbox, isExteriorRing);
5507 function trivialOperation(subject, clipping, operation) {
5509 if (subject.length * clipping.length === 0) {
5510 if (operation === INTERSECTION) {
5512 } else if (operation === DIFFERENCE) {
5514 } else if (operation === UNION ||
5515 operation === XOR) {
5516 result = (subject.length === 0) ? clipping : subject;
5523 function compareBBoxes(subject, clipping, sbbox, cbbox, operation) {
5525 if (sbbox[0] > cbbox[2] ||
5526 cbbox[0] > sbbox[2] ||
5527 sbbox[1] > cbbox[3] ||
5528 cbbox[1] > sbbox[3]) {
5529 if (operation === INTERSECTION) {
5531 } else if (operation === DIFFERENCE) {
5533 } else if (operation === UNION ||
5534 operation === XOR) {
5535 result = subject.concat(clipping);
5542 function boolean(subject, clipping, operation) {
5543 if (typeof subject[0][0][0] === 'number') {
5544 subject = [subject];
5546 if (typeof clipping[0][0][0] === 'number') {
5547 clipping = [clipping];
5549 var trivial = trivialOperation(subject, clipping, operation);
5551 return trivial === EMPTY ? null : trivial;
5553 var sbbox = [Infinity, Infinity, -Infinity, -Infinity];
5554 var cbbox = [Infinity, Infinity, -Infinity, -Infinity];
5556 //console.time('fill queue');
5557 var eventQueue = fillQueue(subject, clipping, sbbox, cbbox, operation);
5558 //console.timeEnd('fill queue');
5560 trivial = compareBBoxes(subject, clipping, sbbox, cbbox, operation);
5562 return trivial === EMPTY ? null : trivial;
5564 //console.time('subdivide edges');
5565 var sortedEvents = subdivide(eventQueue, subject, clipping, sbbox, cbbox, operation);
5566 //console.timeEnd('subdivide edges');
5568 //console.time('connect vertices');
5569 var result = connectEdges(sortedEvents, operation);
5570 //console.timeEnd('connect vertices');
5574 function union (subject, clipping) {
5575 return boolean(subject, clipping, UNION);
5578 function diff (subject, clipping) {
5579 return boolean(subject, clipping, DIFFERENCE);
5582 function xor (subject, clipping){
5583 return boolean(subject, clipping, XOR);
5586 function intersection$1 (subject, clipping) {
5587 return boolean(subject, clipping, INTERSECTION);
5593 var operations = { UNION: UNION, DIFFERENCE: DIFFERENCE, INTERSECTION: INTERSECTION, XOR: XOR };
5595 exports.union = union;
5596 exports.diff = diff;
5598 exports.intersection = intersection$1;
5599 exports.operations = operations;
5601 Object.defineProperty(exports, '__esModule', { value: true });
5606 },{}],23:[function(require,module,exports){
5607 (function (process){
5608 // Copyright Joyent, Inc. and other Node contributors.
5610 // Permission is hereby granted, free of charge, to any person obtaining a
5611 // copy of this software and associated documentation files (the
5612 // "Software"), to deal in the Software without restriction, including
5613 // without limitation the rights to use, copy, modify, merge, publish,
5614 // distribute, sublicense, and/or sell copies of the Software, and to permit
5615 // persons to whom the Software is furnished to do so, subject to the
5616 // following conditions:
5618 // The above copyright notice and this permission notice shall be included
5619 // in all copies or substantial portions of the Software.
5621 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
5622 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
5623 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
5624 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
5625 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
5626 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
5627 // USE OR OTHER DEALINGS IN THE SOFTWARE.
5629 // resolves . and .. elements in a path array with directory names there
5630 // must be no slashes, empty elements, or device names (c:\) in the array
5631 // (so also no leading and trailing slashes - it does not distinguish
5632 // relative and absolute paths)
5633 function normalizeArray(parts, allowAboveRoot) {
5634 // if the path tries to go above the root, `up` ends up > 0
5636 for (var i = parts.length - 1; i >= 0; i--) {
5637 var last = parts[i];
5640 } else if (last === '..') {
5649 // if the path is allowed to go above the root, restore leading ..s
5650 if (allowAboveRoot) {
5652 parts.unshift('..');
5659 // Split a filename into [root, dir, basename, ext], unix version
5660 // 'root' is just a slash, or nothing.
5662 /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
5663 var splitPath = function(filename) {
5664 return splitPathRe.exec(filename).slice(1);
5667 // path.resolve([from ...], to)
5669 exports.resolve = function() {
5670 var resolvedPath = '',
5671 resolvedAbsolute = false;
5673 for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
5674 var path = (i >= 0) ? arguments[i] : process.cwd();
5676 // Skip empty and invalid entries
5677 if (typeof path !== 'string') {
5678 throw new TypeError('Arguments to path.resolve must be strings');
5683 resolvedPath = path + '/' + resolvedPath;
5684 resolvedAbsolute = path.charAt(0) === '/';
5687 // At this point the path should be resolved to a full absolute path, but
5688 // handle relative paths to be safe (might happen when process.cwd() fails)
5690 // Normalize the path
5691 resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {
5693 }), !resolvedAbsolute).join('/');
5695 return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
5698 // path.normalize(path)
5700 exports.normalize = function(path) {
5701 var isAbsolute = exports.isAbsolute(path),
5702 trailingSlash = substr(path, -1) === '/';
5704 // Normalize the path
5705 path = normalizeArray(filter(path.split('/'), function(p) {
5707 }), !isAbsolute).join('/');
5709 if (!path && !isAbsolute) {
5712 if (path && trailingSlash) {
5716 return (isAbsolute ? '/' : '') + path;
5720 exports.isAbsolute = function(path) {
5721 return path.charAt(0) === '/';
5725 exports.join = function() {
5726 var paths = Array.prototype.slice.call(arguments, 0);
5727 return exports.normalize(filter(paths, function(p, index) {
5728 if (typeof p !== 'string') {
5729 throw new TypeError('Arguments to path.join must be strings');
5736 // path.relative(from, to)
5738 exports.relative = function(from, to) {
5739 from = exports.resolve(from).substr(1);
5740 to = exports.resolve(to).substr(1);
5742 function trim(arr) {
5744 for (; start < arr.length; start++) {
5745 if (arr[start] !== '') break;
5748 var end = arr.length - 1;
5749 for (; end >= 0; end--) {
5750 if (arr[end] !== '') break;
5753 if (start > end) return [];
5754 return arr.slice(start, end - start + 1);
5757 var fromParts = trim(from.split('/'));
5758 var toParts = trim(to.split('/'));
5760 var length = Math.min(fromParts.length, toParts.length);
5761 var samePartsLength = length;
5762 for (var i = 0; i < length; i++) {
5763 if (fromParts[i] !== toParts[i]) {
5764 samePartsLength = i;
5769 var outputParts = [];
5770 for (var i = samePartsLength; i < fromParts.length; i++) {
5771 outputParts.push('..');
5774 outputParts = outputParts.concat(toParts.slice(samePartsLength));
5776 return outputParts.join('/');
5780 exports.delimiter = ':';
5782 exports.dirname = function(path) {
5783 var result = splitPath(path),
5787 if (!root && !dir) {
5788 // No dirname whatsoever
5793 // It has a dirname, strip trailing slash
5794 dir = dir.substr(0, dir.length - 1);
5801 exports.basename = function(path, ext) {
5802 var f = splitPath(path)[2];
5803 // TODO: make this comparison case-insensitive on windows?
5804 if (ext && f.substr(-1 * ext.length) === ext) {
5805 f = f.substr(0, f.length - ext.length);
5811 exports.extname = function(path) {
5812 return splitPath(path)[3];
5815 function filter (xs, f) {
5816 if (xs.filter) return xs.filter(f);
5818 for (var i = 0; i < xs.length; i++) {
5819 if (f(xs[i], i, xs)) res.push(xs[i]);
5824 // String.prototype.substr - negative index don't work in IE8
5825 var substr = 'ab'.substr(-1) === 'b'
5826 ? function (str, start, len) { return str.substr(start, len) }
5827 : function (str, start, len) {
5828 if (start < 0) start = str.length + start;
5829 return str.substr(start, len);
5833 }).call(this,require('_process'))
5835 },{"_process":6}],24:[function(require,module,exports){
5838 module.exports = Pbf;
5840 var ieee754 = require('ieee754');
5843 this.buf = ArrayBuffer.isView && ArrayBuffer.isView(buf) ? buf : new Uint8Array(buf || 0);
5846 this.length = this.buf.length;
5849 Pbf.Varint = 0; // varint: int32, int64, uint32, uint64, sint32, sint64, bool, enum
5850 Pbf.Fixed64 = 1; // 64-bit: double, fixed64, sfixed64
5851 Pbf.Bytes = 2; // length-delimited: string, bytes, embedded messages, packed repeated fields
5852 Pbf.Fixed32 = 5; // 32-bit: float, fixed32, sfixed32
5854 var SHIFT_LEFT_32 = (1 << 16) * (1 << 16),
5855 SHIFT_RIGHT_32 = 1 / SHIFT_LEFT_32;
5859 destroy: function() {
5863 // === READING =================================================================
5865 readFields: function(readField, result, end) {
5866 end = end || this.length;
5868 while (this.pos < end) {
5869 var val = this.readVarint(),
5871 startPos = this.pos;
5873 this.type = val & 0x7;
5874 readField(tag, result, this);
5876 if (this.pos === startPos) this.skip(val);
5881 readMessage: function(readField, result) {
5882 return this.readFields(readField, result, this.readVarint() + this.pos);
5885 readFixed32: function() {
5886 var val = readUInt32(this.buf, this.pos);
5891 readSFixed32: function() {
5892 var val = readInt32(this.buf, this.pos);
5897 // 64-bit int handling is based on github.com/dpw/node-buffer-more-ints (MIT-licensed)
5899 readFixed64: function() {
5900 var val = readUInt32(this.buf, this.pos) + readUInt32(this.buf, this.pos + 4) * SHIFT_LEFT_32;
5905 readSFixed64: function() {
5906 var val = readUInt32(this.buf, this.pos) + readInt32(this.buf, this.pos + 4) * SHIFT_LEFT_32;
5911 readFloat: function() {
5912 var val = ieee754.read(this.buf, this.pos, true, 23, 4);
5917 readDouble: function() {
5918 var val = ieee754.read(this.buf, this.pos, true, 52, 8);
5923 readVarint: function(isSigned) {
5927 b = buf[this.pos++]; val = b & 0x7f; if (b < 0x80) return val;
5928 b = buf[this.pos++]; val |= (b & 0x7f) << 7; if (b < 0x80) return val;
5929 b = buf[this.pos++]; val |= (b & 0x7f) << 14; if (b < 0x80) return val;
5930 b = buf[this.pos++]; val |= (b & 0x7f) << 21; if (b < 0x80) return val;
5931 b = buf[this.pos]; val |= (b & 0x0f) << 28;
5933 return readVarintRemainder(val, isSigned, this);
5936 readVarint64: function() { // for compatibility with v2.0.1
5937 return this.readVarint(true);
5940 readSVarint: function() {
5941 var num = this.readVarint();
5942 return num % 2 === 1 ? (num + 1) / -2 : num / 2; // zigzag encoding
5945 readBoolean: function() {
5946 return Boolean(this.readVarint());
5949 readString: function() {
5950 var end = this.readVarint() + this.pos,
5951 str = readUtf8(this.buf, this.pos, end);
5956 readBytes: function() {
5957 var end = this.readVarint() + this.pos,
5958 buffer = this.buf.subarray(this.pos, end);
5963 // verbose for performance reasons; doesn't affect gzipped size
5965 readPackedVarint: function(arr, isSigned) {
5966 var end = readPackedEnd(this);
5968 while (this.pos < end) arr.push(this.readVarint(isSigned));
5971 readPackedSVarint: function(arr) {
5972 var end = readPackedEnd(this);
5974 while (this.pos < end) arr.push(this.readSVarint());
5977 readPackedBoolean: function(arr) {
5978 var end = readPackedEnd(this);
5980 while (this.pos < end) arr.push(this.readBoolean());
5983 readPackedFloat: function(arr) {
5984 var end = readPackedEnd(this);
5986 while (this.pos < end) arr.push(this.readFloat());
5989 readPackedDouble: function(arr) {
5990 var end = readPackedEnd(this);
5992 while (this.pos < end) arr.push(this.readDouble());
5995 readPackedFixed32: function(arr) {
5996 var end = readPackedEnd(this);
5998 while (this.pos < end) arr.push(this.readFixed32());
6001 readPackedSFixed32: function(arr) {
6002 var end = readPackedEnd(this);
6004 while (this.pos < end) arr.push(this.readSFixed32());
6007 readPackedFixed64: function(arr) {
6008 var end = readPackedEnd(this);
6010 while (this.pos < end) arr.push(this.readFixed64());
6013 readPackedSFixed64: function(arr) {
6014 var end = readPackedEnd(this);
6016 while (this.pos < end) arr.push(this.readSFixed64());
6020 skip: function(val) {
6021 var type = val & 0x7;
6022 if (type === Pbf.Varint) while (this.buf[this.pos++] > 0x7f) {}
6023 else if (type === Pbf.Bytes) this.pos = this.readVarint() + this.pos;
6024 else if (type === Pbf.Fixed32) this.pos += 4;
6025 else if (type === Pbf.Fixed64) this.pos += 8;
6026 else throw new Error('Unimplemented type: ' + type);
6029 // === WRITING =================================================================
6031 writeTag: function(tag, type) {
6032 this.writeVarint((tag << 3) | type);
6035 realloc: function(min) {
6036 var length = this.length || 16;
6038 while (length < this.pos + min) length *= 2;
6040 if (length !== this.length) {
6041 var buf = new Uint8Array(length);
6044 this.length = length;
6048 finish: function() {
6049 this.length = this.pos;
6051 return this.buf.subarray(0, this.length);
6054 writeFixed32: function(val) {
6056 writeInt32(this.buf, val, this.pos);
6060 writeSFixed32: function(val) {
6062 writeInt32(this.buf, val, this.pos);
6066 writeFixed64: function(val) {
6068 writeInt32(this.buf, val & -1, this.pos);
6069 writeInt32(this.buf, Math.floor(val * SHIFT_RIGHT_32), this.pos + 4);
6073 writeSFixed64: function(val) {
6075 writeInt32(this.buf, val & -1, this.pos);
6076 writeInt32(this.buf, Math.floor(val * SHIFT_RIGHT_32), this.pos + 4);
6080 writeVarint: function(val) {
6083 if (val > 0xfffffff || val < 0) {
6084 writeBigVarint(val, this);
6090 this.buf[this.pos++] = val & 0x7f | (val > 0x7f ? 0x80 : 0); if (val <= 0x7f) return;
6091 this.buf[this.pos++] = ((val >>>= 7) & 0x7f) | (val > 0x7f ? 0x80 : 0); if (val <= 0x7f) return;
6092 this.buf[this.pos++] = ((val >>>= 7) & 0x7f) | (val > 0x7f ? 0x80 : 0); if (val <= 0x7f) return;
6093 this.buf[this.pos++] = (val >>> 7) & 0x7f;
6096 writeSVarint: function(val) {
6097 this.writeVarint(val < 0 ? -val * 2 - 1 : val * 2);
6100 writeBoolean: function(val) {
6101 this.writeVarint(Boolean(val));
6104 writeString: function(str) {
6106 this.realloc(str.length * 4);
6108 this.pos++; // reserve 1 byte for short string length
6110 var startPos = this.pos;
6111 // write the string directly to the buffer and see how much was written
6112 this.pos = writeUtf8(this.buf, str, this.pos);
6113 var len = this.pos - startPos;
6115 if (len >= 0x80) makeRoomForExtraLength(startPos, len, this);
6117 // finally, write the message length in the reserved place and restore the position
6118 this.pos = startPos - 1;
6119 this.writeVarint(len);
6123 writeFloat: function(val) {
6125 ieee754.write(this.buf, val, this.pos, true, 23, 4);
6129 writeDouble: function(val) {
6131 ieee754.write(this.buf, val, this.pos, true, 52, 8);
6135 writeBytes: function(buffer) {
6136 var len = buffer.length;
6137 this.writeVarint(len);
6139 for (var i = 0; i < len; i++) this.buf[this.pos++] = buffer[i];
6142 writeRawMessage: function(fn, obj) {
6143 this.pos++; // reserve 1 byte for short message length
6145 // write the message directly to the buffer and see how much was written
6146 var startPos = this.pos;
6148 var len = this.pos - startPos;
6150 if (len >= 0x80) makeRoomForExtraLength(startPos, len, this);
6152 // finally, write the message length in the reserved place and restore the position
6153 this.pos = startPos - 1;
6154 this.writeVarint(len);
6158 writeMessage: function(tag, fn, obj) {
6159 this.writeTag(tag, Pbf.Bytes);
6160 this.writeRawMessage(fn, obj);
6163 writePackedVarint: function(tag, arr) { this.writeMessage(tag, writePackedVarint, arr); },
6164 writePackedSVarint: function(tag, arr) { this.writeMessage(tag, writePackedSVarint, arr); },
6165 writePackedBoolean: function(tag, arr) { this.writeMessage(tag, writePackedBoolean, arr); },
6166 writePackedFloat: function(tag, arr) { this.writeMessage(tag, writePackedFloat, arr); },
6167 writePackedDouble: function(tag, arr) { this.writeMessage(tag, writePackedDouble, arr); },
6168 writePackedFixed32: function(tag, arr) { this.writeMessage(tag, writePackedFixed32, arr); },
6169 writePackedSFixed32: function(tag, arr) { this.writeMessage(tag, writePackedSFixed32, arr); },
6170 writePackedFixed64: function(tag, arr) { this.writeMessage(tag, writePackedFixed64, arr); },
6171 writePackedSFixed64: function(tag, arr) { this.writeMessage(tag, writePackedSFixed64, arr); },
6173 writeBytesField: function(tag, buffer) {
6174 this.writeTag(tag, Pbf.Bytes);
6175 this.writeBytes(buffer);
6177 writeFixed32Field: function(tag, val) {
6178 this.writeTag(tag, Pbf.Fixed32);
6179 this.writeFixed32(val);
6181 writeSFixed32Field: function(tag, val) {
6182 this.writeTag(tag, Pbf.Fixed32);
6183 this.writeSFixed32(val);
6185 writeFixed64Field: function(tag, val) {
6186 this.writeTag(tag, Pbf.Fixed64);
6187 this.writeFixed64(val);
6189 writeSFixed64Field: function(tag, val) {
6190 this.writeTag(tag, Pbf.Fixed64);
6191 this.writeSFixed64(val);
6193 writeVarintField: function(tag, val) {
6194 this.writeTag(tag, Pbf.Varint);
6195 this.writeVarint(val);
6197 writeSVarintField: function(tag, val) {
6198 this.writeTag(tag, Pbf.Varint);
6199 this.writeSVarint(val);
6201 writeStringField: function(tag, str) {
6202 this.writeTag(tag, Pbf.Bytes);
6203 this.writeString(str);
6205 writeFloatField: function(tag, val) {
6206 this.writeTag(tag, Pbf.Fixed32);
6207 this.writeFloat(val);
6209 writeDoubleField: function(tag, val) {
6210 this.writeTag(tag, Pbf.Fixed64);
6211 this.writeDouble(val);
6213 writeBooleanField: function(tag, val) {
6214 this.writeVarintField(tag, Boolean(val));
6218 function readVarintRemainder(l, s, p) {
6222 b = buf[p.pos++]; h = (b & 0x70) >> 4; if (b < 0x80) return toNum(l, h, s);
6223 b = buf[p.pos++]; h |= (b & 0x7f) << 3; if (b < 0x80) return toNum(l, h, s);
6224 b = buf[p.pos++]; h |= (b & 0x7f) << 10; if (b < 0x80) return toNum(l, h, s);
6225 b = buf[p.pos++]; h |= (b & 0x7f) << 17; if (b < 0x80) return toNum(l, h, s);
6226 b = buf[p.pos++]; h |= (b & 0x7f) << 24; if (b < 0x80) return toNum(l, h, s);
6227 b = buf[p.pos++]; h |= (b & 0x01) << 31; if (b < 0x80) return toNum(l, h, s);
6229 throw new Error('Expected varint not more than 10 bytes');
6232 function readPackedEnd(pbf) {
6233 return pbf.type === Pbf.Bytes ?
6234 pbf.readVarint() + pbf.pos : pbf.pos + 1;
6237 function toNum(low, high, isSigned) {
6239 return high * 0x100000000 + (low >>> 0);
6242 return ((high >>> 0) * 0x100000000) + (low >>> 0);
6245 function writeBigVarint(val, pbf) {
6249 low = (val % 0x100000000) | 0;
6250 high = (val / 0x100000000) | 0;
6252 low = ~(-val % 0x100000000);
6253 high = ~(-val / 0x100000000);
6255 if (low ^ 0xffffffff) {
6256 low = (low + 1) | 0;
6259 high = (high + 1) | 0;
6263 if (val >= 0x10000000000000000 || val < -0x10000000000000000) {
6264 throw new Error('Given varint doesn\'t fit into 10 bytes');
6269 writeBigVarintLow(low, high, pbf);
6270 writeBigVarintHigh(high, pbf);
6273 function writeBigVarintLow(low, high, pbf) {
6274 pbf.buf[pbf.pos++] = low & 0x7f | 0x80; low >>>= 7;
6275 pbf.buf[pbf.pos++] = low & 0x7f | 0x80; low >>>= 7;
6276 pbf.buf[pbf.pos++] = low & 0x7f | 0x80; low >>>= 7;
6277 pbf.buf[pbf.pos++] = low & 0x7f | 0x80; low >>>= 7;
6278 pbf.buf[pbf.pos] = low & 0x7f;
6281 function writeBigVarintHigh(high, pbf) {
6282 var lsb = (high & 0x07) << 4;
6284 pbf.buf[pbf.pos++] |= lsb | ((high >>>= 3) ? 0x80 : 0); if (!high) return;
6285 pbf.buf[pbf.pos++] = high & 0x7f | ((high >>>= 7) ? 0x80 : 0); if (!high) return;
6286 pbf.buf[pbf.pos++] = high & 0x7f | ((high >>>= 7) ? 0x80 : 0); if (!high) return;
6287 pbf.buf[pbf.pos++] = high & 0x7f | ((high >>>= 7) ? 0x80 : 0); if (!high) return;
6288 pbf.buf[pbf.pos++] = high & 0x7f | ((high >>>= 7) ? 0x80 : 0); if (!high) return;
6289 pbf.buf[pbf.pos++] = high & 0x7f;
6292 function makeRoomForExtraLength(startPos, len, pbf) {
6295 len <= 0x1fffff ? 2 :
6296 len <= 0xfffffff ? 3 : Math.ceil(Math.log(len) / (Math.LN2 * 7));
6298 // if 1 byte isn't enough for encoding message length, shift the data to the right
6299 pbf.realloc(extraLen);
6300 for (var i = pbf.pos - 1; i >= startPos; i--) pbf.buf[i + extraLen] = pbf.buf[i];
6303 function writePackedVarint(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeVarint(arr[i]); }
6304 function writePackedSVarint(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeSVarint(arr[i]); }
6305 function writePackedFloat(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeFloat(arr[i]); }
6306 function writePackedDouble(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeDouble(arr[i]); }
6307 function writePackedBoolean(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeBoolean(arr[i]); }
6308 function writePackedFixed32(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeFixed32(arr[i]); }
6309 function writePackedSFixed32(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeSFixed32(arr[i]); }
6310 function writePackedFixed64(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeFixed64(arr[i]); }
6311 function writePackedSFixed64(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeSFixed64(arr[i]); }
6313 // Buffer code below from https://github.com/feross/buffer, MIT-licensed
6315 function readUInt32(buf, pos) {
6316 return ((buf[pos]) |
6317 (buf[pos + 1] << 8) |
6318 (buf[pos + 2] << 16)) +
6319 (buf[pos + 3] * 0x1000000);
6322 function writeInt32(buf, val, pos) {
6324 buf[pos + 1] = (val >>> 8);
6325 buf[pos + 2] = (val >>> 16);
6326 buf[pos + 3] = (val >>> 24);
6329 function readInt32(buf, pos) {
6330 return ((buf[pos]) |
6331 (buf[pos + 1] << 8) |
6332 (buf[pos + 2] << 16)) +
6333 (buf[pos + 3] << 24);
6336 function readUtf8(buf, pos, end) {
6342 var c = null; // codepoint
6343 var bytesPerSequence =
6348 if (i + bytesPerSequence > end) break;
6352 if (bytesPerSequence === 1) {
6356 } else if (bytesPerSequence === 2) {
6358 if ((b1 & 0xC0) === 0x80) {
6359 c = (b0 & 0x1F) << 0x6 | (b1 & 0x3F);
6364 } else if (bytesPerSequence === 3) {
6367 if ((b1 & 0xC0) === 0x80 && (b2 & 0xC0) === 0x80) {
6368 c = (b0 & 0xF) << 0xC | (b1 & 0x3F) << 0x6 | (b2 & 0x3F);
6369 if (c <= 0x7FF || (c >= 0xD800 && c <= 0xDFFF)) {
6373 } else if (bytesPerSequence === 4) {
6377 if ((b1 & 0xC0) === 0x80 && (b2 & 0xC0) === 0x80 && (b3 & 0xC0) === 0x80) {
6378 c = (b0 & 0xF) << 0x12 | (b1 & 0x3F) << 0xC | (b2 & 0x3F) << 0x6 | (b3 & 0x3F);
6379 if (c <= 0xFFFF || c >= 0x110000) {
6387 bytesPerSequence = 1;
6389 } else if (c > 0xFFFF) {
6391 str += String.fromCharCode(c >>> 10 & 0x3FF | 0xD800);
6392 c = 0xDC00 | c & 0x3FF;
6395 str += String.fromCharCode(c);
6396 i += bytesPerSequence;
6402 function writeUtf8(buf, str, pos) {
6403 for (var i = 0, c, lead; i < str.length; i++) {
6404 c = str.charCodeAt(i); // code point
6406 if (c > 0xD7FF && c < 0xE000) {
6415 c = lead - 0xD800 << 10 | c - 0xDC00 | 0x10000;
6419 if (c > 0xDBFF || (i + 1 === str.length)) {
6439 buf[pos++] = c >> 0x6 | 0xC0;
6442 buf[pos++] = c >> 0xC | 0xE0;
6444 buf[pos++] = c >> 0x12 | 0xF0;
6445 buf[pos++] = c >> 0xC & 0x3F | 0x80;
6447 buf[pos++] = c >> 0x6 & 0x3F | 0x80;
6449 buf[pos++] = c & 0x3F | 0x80;
6455 },{"ieee754":17}],25:[function(require,module,exports){
6456 (function (global, factory) {
6457 typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
6458 typeof define === 'function' && define.amd ? define(factory) :
6459 (global.quickselect = factory());
6460 }(this, (function () { 'use strict';
6462 function quickselect(arr, k, left, right, compare) {
6463 quickselectStep(arr, k, left || 0, right || (arr.length - 1), compare || defaultCompare);
6466 function quickselectStep(arr, k, left, right, compare) {
6468 while (right > left) {
6469 if (right - left > 600) {
6470 var n = right - left + 1;
6471 var m = k - left + 1;
6472 var z = Math.log(n);
6473 var s = 0.5 * Math.exp(2 * z / 3);
6474 var sd = 0.5 * Math.sqrt(z * s * (n - s) / n) * (m - n / 2 < 0 ? -1 : 1);
6475 var newLeft = Math.max(left, Math.floor(k - m * s / n + sd));
6476 var newRight = Math.min(right, Math.floor(k + (n - m) * s / n + sd));
6477 quickselectStep(arr, k, newLeft, newRight, compare);
6485 if (compare(arr[right], t) > 0) swap(arr, left, right);
6491 while (compare(arr[i], t) < 0) i++;
6492 while (compare(arr[j], t) > 0) j--;
6495 if (compare(arr[left], t) === 0) swap(arr, left, j);
6498 swap(arr, j, right);
6501 if (j <= k) left = j + 1;
6502 if (k <= j) right = j - 1;
6506 function swap(arr, i, j) {
6512 function defaultCompare(a, b) {
6513 return a < b ? -1 : a > b ? 1 : 0;
6520 },{}],26:[function(require,module,exports){
6523 module.exports = rbush;
6524 module.exports.default = rbush;
6526 var quickselect = require('quickselect');
6528 function rbush(maxEntries, format) {
6529 if (!(this instanceof rbush)) return new rbush(maxEntries, format);
6531 // max entries in a node is 9 by default; min node fill is 40% for best performance
6532 this._maxEntries = Math.max(4, maxEntries || 9);
6533 this._minEntries = Math.max(2, Math.ceil(this._maxEntries * 0.4));
6536 this._initFormat(format);
6545 return this._all(this.data, []);
6548 search: function (bbox) {
6550 var node = this.data,
6552 toBBox = this.toBBox;
6554 if (!intersects(bbox, node)) return result;
6556 var nodesToSearch = [],
6557 i, len, child, childBBox;
6560 for (i = 0, len = node.children.length; i < len; i++) {
6562 child = node.children[i];
6563 childBBox = node.leaf ? toBBox(child) : child;
6565 if (intersects(bbox, childBBox)) {
6566 if (node.leaf) result.push(child);
6567 else if (contains(bbox, childBBox)) this._all(child, result);
6568 else nodesToSearch.push(child);
6571 node = nodesToSearch.pop();
6577 collides: function (bbox) {
6579 var node = this.data,
6580 toBBox = this.toBBox;
6582 if (!intersects(bbox, node)) return false;
6584 var nodesToSearch = [],
6585 i, len, child, childBBox;
6588 for (i = 0, len = node.children.length; i < len; i++) {
6590 child = node.children[i];
6591 childBBox = node.leaf ? toBBox(child) : child;
6593 if (intersects(bbox, childBBox)) {
6594 if (node.leaf || contains(bbox, childBBox)) return true;
6595 nodesToSearch.push(child);
6598 node = nodesToSearch.pop();
6604 load: function (data) {
6605 if (!(data && data.length)) return this;
6607 if (data.length < this._minEntries) {
6608 for (var i = 0, len = data.length; i < len; i++) {
6609 this.insert(data[i]);
6614 // recursively build the tree with the given data from scratch using OMT algorithm
6615 var node = this._build(data.slice(), 0, data.length - 1, 0);
6617 if (!this.data.children.length) {
6618 // save as is if tree is empty
6621 } else if (this.data.height === node.height) {
6622 // split root if trees have the same height
6623 this._splitRoot(this.data, node);
6626 if (this.data.height < node.height) {
6627 // swap trees if inserted one is bigger
6628 var tmpNode = this.data;
6633 // insert the small tree into the large tree at appropriate level
6634 this._insert(node, this.data.height - node.height - 1, true);
6640 insert: function (item) {
6641 if (item) this._insert(item, this.data.height - 1);
6645 clear: function () {
6646 this.data = createNode([]);
6650 remove: function (item, equalsFn) {
6651 if (!item) return this;
6653 var node = this.data,
6654 bbox = this.toBBox(item),
6657 i, parent, index, goingUp;
6659 // depth-first iterative tree traversal
6660 while (node || path.length) {
6662 if (!node) { // go up
6664 parent = path[path.length - 1];
6669 if (node.leaf) { // check current node
6670 index = findItem(item, node.children, equalsFn);
6673 // item found, remove the item and condense tree upwards
6674 node.children.splice(index, 1);
6676 this._condense(path);
6681 if (!goingUp && !node.leaf && contains(node, bbox)) { // go down
6686 node = node.children[0];
6688 } else if (parent) { // go right
6690 node = parent.children[i];
6693 } else node = null; // nothing found
6699 toBBox: function (item) { return item; },
6701 compareMinX: compareNodeMinX,
6702 compareMinY: compareNodeMinY,
6704 toJSON: function () { return this.data; },
6706 fromJSON: function (data) {
6711 _all: function (node, result) {
6712 var nodesToSearch = [];
6714 if (node.leaf) result.push.apply(result, node.children);
6715 else nodesToSearch.push.apply(nodesToSearch, node.children);
6717 node = nodesToSearch.pop();
6722 _build: function (items, left, right, height) {
6724 var N = right - left + 1,
6725 M = this._maxEntries,
6729 // reached leaf level; return leaf
6730 node = createNode(items.slice(left, right + 1));
6731 calcBBox(node, this.toBBox);
6736 // target height of the bulk-loaded tree
6737 height = Math.ceil(Math.log(N) / Math.log(M));
6739 // target number of root entries to maximize storage utilization
6740 M = Math.ceil(N / Math.pow(M, height - 1));
6743 node = createNode([]);
6745 node.height = height;
6747 // split the items into M mostly square tiles
6749 var N2 = Math.ceil(N / M),
6750 N1 = N2 * Math.ceil(Math.sqrt(M)),
6751 i, j, right2, right3;
6753 multiSelect(items, left, right, N1, this.compareMinX);
6755 for (i = left; i <= right; i += N1) {
6757 right2 = Math.min(i + N1 - 1, right);
6759 multiSelect(items, i, right2, N2, this.compareMinY);
6761 for (j = i; j <= right2; j += N2) {
6763 right3 = Math.min(j + N2 - 1, right2);
6765 // pack each entry recursively
6766 node.children.push(this._build(items, j, right3, height - 1));
6770 calcBBox(node, this.toBBox);
6775 _chooseSubtree: function (bbox, node, level, path) {
6777 var i, len, child, targetNode, area, enlargement, minArea, minEnlargement;
6782 if (node.leaf || path.length - 1 === level) break;
6784 minArea = minEnlargement = Infinity;
6786 for (i = 0, len = node.children.length; i < len; i++) {
6787 child = node.children[i];
6788 area = bboxArea(child);
6789 enlargement = enlargedArea(bbox, child) - area;
6791 // choose entry with the least area enlargement
6792 if (enlargement < minEnlargement) {
6793 minEnlargement = enlargement;
6794 minArea = area < minArea ? area : minArea;
6797 } else if (enlargement === minEnlargement) {
6798 // otherwise choose one with the smallest area
6799 if (area < minArea) {
6806 node = targetNode || node.children[0];
6812 _insert: function (item, level, isNode) {
6814 var toBBox = this.toBBox,
6815 bbox = isNode ? item : toBBox(item),
6818 // find the best node for accommodating the item, saving all nodes along the path too
6819 var node = this._chooseSubtree(bbox, this.data, level, insertPath);
6821 // put the item into the node
6822 node.children.push(item);
6825 // split on node overflow; propagate upwards if necessary
6826 while (level >= 0) {
6827 if (insertPath[level].children.length > this._maxEntries) {
6828 this._split(insertPath, level);
6833 // adjust bboxes along the insertion path
6834 this._adjustParentBBoxes(bbox, insertPath, level);
6837 // split overflowed node into two
6838 _split: function (insertPath, level) {
6840 var node = insertPath[level],
6841 M = node.children.length,
6842 m = this._minEntries;
6844 this._chooseSplitAxis(node, m, M);
6846 var splitIndex = this._chooseSplitIndex(node, m, M);
6848 var newNode = createNode(node.children.splice(splitIndex, node.children.length - splitIndex));
6849 newNode.height = node.height;
6850 newNode.leaf = node.leaf;
6852 calcBBox(node, this.toBBox);
6853 calcBBox(newNode, this.toBBox);
6855 if (level) insertPath[level - 1].children.push(newNode);
6856 else this._splitRoot(node, newNode);
6859 _splitRoot: function (node, newNode) {
6861 this.data = createNode([node, newNode]);
6862 this.data.height = node.height + 1;
6863 this.data.leaf = false;
6864 calcBBox(this.data, this.toBBox);
6867 _chooseSplitIndex: function (node, m, M) {
6869 var i, bbox1, bbox2, overlap, area, minOverlap, minArea, index;
6871 minOverlap = minArea = Infinity;
6873 for (i = m; i <= M - m; i++) {
6874 bbox1 = distBBox(node, 0, i, this.toBBox);
6875 bbox2 = distBBox(node, i, M, this.toBBox);
6877 overlap = intersectionArea(bbox1, bbox2);
6878 area = bboxArea(bbox1) + bboxArea(bbox2);
6880 // choose distribution with minimum overlap
6881 if (overlap < minOverlap) {
6882 minOverlap = overlap;
6885 minArea = area < minArea ? area : minArea;
6887 } else if (overlap === minOverlap) {
6888 // otherwise choose distribution with minimum area
6889 if (area < minArea) {
6899 // sorts node children by the best axis for split
6900 _chooseSplitAxis: function (node, m, M) {
6902 var compareMinX = node.leaf ? this.compareMinX : compareNodeMinX,
6903 compareMinY = node.leaf ? this.compareMinY : compareNodeMinY,
6904 xMargin = this._allDistMargin(node, m, M, compareMinX),
6905 yMargin = this._allDistMargin(node, m, M, compareMinY);
6907 // if total distributions margin value is minimal for x, sort by minX,
6908 // otherwise it's already sorted by minY
6909 if (xMargin < yMargin) node.children.sort(compareMinX);
6912 // total margin of all possible split distributions where each node is at least m full
6913 _allDistMargin: function (node, m, M, compare) {
6915 node.children.sort(compare);
6917 var toBBox = this.toBBox,
6918 leftBBox = distBBox(node, 0, m, toBBox),
6919 rightBBox = distBBox(node, M - m, M, toBBox),
6920 margin = bboxMargin(leftBBox) + bboxMargin(rightBBox),
6923 for (i = m; i < M - m; i++) {
6924 child = node.children[i];
6925 extend(leftBBox, node.leaf ? toBBox(child) : child);
6926 margin += bboxMargin(leftBBox);
6929 for (i = M - m - 1; i >= m; i--) {
6930 child = node.children[i];
6931 extend(rightBBox, node.leaf ? toBBox(child) : child);
6932 margin += bboxMargin(rightBBox);
6938 _adjustParentBBoxes: function (bbox, path, level) {
6939 // adjust bboxes along the given tree path
6940 for (var i = level; i >= 0; i--) {
6941 extend(path[i], bbox);
6945 _condense: function (path) {
6946 // go through the path, removing empty nodes and updating bboxes
6947 for (var i = path.length - 1, siblings; i >= 0; i--) {
6948 if (path[i].children.length === 0) {
6950 siblings = path[i - 1].children;
6951 siblings.splice(siblings.indexOf(path[i]), 1);
6953 } else this.clear();
6955 } else calcBBox(path[i], this.toBBox);
6959 _initFormat: function (format) {
6960 // data format (minX, minY, maxX, maxY accessors)
6962 // uses eval-type function compilation instead of just accepting a toBBox function
6963 // because the algorithms are very sensitive to sorting functions performance,
6964 // so they should be dead simple and without inner calls
6966 var compareArr = ['return a', ' - b', ';'];
6968 this.compareMinX = new Function('a', 'b', compareArr.join(format[0]));
6969 this.compareMinY = new Function('a', 'b', compareArr.join(format[1]));
6971 this.toBBox = new Function('a',
6972 'return {minX: a' + format[0] +
6973 ', minY: a' + format[1] +
6974 ', maxX: a' + format[2] +
6975 ', maxY: a' + format[3] + '};');
6979 function findItem(item, items, equalsFn) {
6980 if (!equalsFn) return items.indexOf(item);
6982 for (var i = 0; i < items.length; i++) {
6983 if (equalsFn(item, items[i])) return i;
6988 // calculate node's bbox from bboxes of its children
6989 function calcBBox(node, toBBox) {
6990 distBBox(node, 0, node.children.length, toBBox, node);
6993 // min bounding rectangle of node children from k to p-1
6994 function distBBox(node, k, p, toBBox, destNode) {
6995 if (!destNode) destNode = createNode(null);
6996 destNode.minX = Infinity;
6997 destNode.minY = Infinity;
6998 destNode.maxX = -Infinity;
6999 destNode.maxY = -Infinity;
7001 for (var i = k, child; i < p; i++) {
7002 child = node.children[i];
7003 extend(destNode, node.leaf ? toBBox(child) : child);
7009 function extend(a, b) {
7010 a.minX = Math.min(a.minX, b.minX);
7011 a.minY = Math.min(a.minY, b.minY);
7012 a.maxX = Math.max(a.maxX, b.maxX);
7013 a.maxY = Math.max(a.maxY, b.maxY);
7017 function compareNodeMinX(a, b) { return a.minX - b.minX; }
7018 function compareNodeMinY(a, b) { return a.minY - b.minY; }
7020 function bboxArea(a) { return (a.maxX - a.minX) * (a.maxY - a.minY); }
7021 function bboxMargin(a) { return (a.maxX - a.minX) + (a.maxY - a.minY); }
7023 function enlargedArea(a, b) {
7024 return (Math.max(b.maxX, a.maxX) - Math.min(b.minX, a.minX)) *
7025 (Math.max(b.maxY, a.maxY) - Math.min(b.minY, a.minY));
7028 function intersectionArea(a, b) {
7029 var minX = Math.max(a.minX, b.minX),
7030 minY = Math.max(a.minY, b.minY),
7031 maxX = Math.min(a.maxX, b.maxX),
7032 maxY = Math.min(a.maxY, b.maxY);
7034 return Math.max(0, maxX - minX) *
7035 Math.max(0, maxY - minY);
7038 function contains(a, b) {
7039 return a.minX <= b.minX &&
7045 function intersects(a, b) {
7046 return b.minX <= a.maxX &&
7052 function createNode(children) {
7064 // sort an array so that items come in groups of n unsorted items, with groups sorted between each other;
7065 // combines selection algorithm with binary divide & conquer approach
7067 function multiSelect(arr, left, right, n, compare) {
7068 var stack = [left, right],
7071 while (stack.length) {
7072 right = stack.pop();
7075 if (right - left <= n) continue;
7077 mid = left + Math.ceil((right - left) / n / 2) * n;
7078 quickselect(arr, mid, left, right, compare);
7080 stack.push(left, mid, mid, right);
7084 },{"quickselect":25}],27:[function(require,module,exports){
7086 Object.defineProperty(exports, "__esModule", { value: true });
7087 var Observable_1 = require("./internal/Observable");
7088 exports.Observable = Observable_1.Observable;
7089 var ConnectableObservable_1 = require("./internal/observable/ConnectableObservable");
7090 exports.ConnectableObservable = ConnectableObservable_1.ConnectableObservable;
7091 var groupBy_1 = require("./internal/operators/groupBy");
7092 exports.GroupedObservable = groupBy_1.GroupedObservable;
7093 var observable_1 = require("./internal/symbol/observable");
7094 exports.observable = observable_1.observable;
7095 var Subject_1 = require("./internal/Subject");
7096 exports.Subject = Subject_1.Subject;
7097 var BehaviorSubject_1 = require("./internal/BehaviorSubject");
7098 exports.BehaviorSubject = BehaviorSubject_1.BehaviorSubject;
7099 var ReplaySubject_1 = require("./internal/ReplaySubject");
7100 exports.ReplaySubject = ReplaySubject_1.ReplaySubject;
7101 var AsyncSubject_1 = require("./internal/AsyncSubject");
7102 exports.AsyncSubject = AsyncSubject_1.AsyncSubject;
7103 var asap_1 = require("./internal/scheduler/asap");
7104 exports.asapScheduler = asap_1.asap;
7105 var async_1 = require("./internal/scheduler/async");
7106 exports.asyncScheduler = async_1.async;
7107 var queue_1 = require("./internal/scheduler/queue");
7108 exports.queueScheduler = queue_1.queue;
7109 var animationFrame_1 = require("./internal/scheduler/animationFrame");
7110 exports.animationFrameScheduler = animationFrame_1.animationFrame;
7111 var VirtualTimeScheduler_1 = require("./internal/scheduler/VirtualTimeScheduler");
7112 exports.VirtualTimeScheduler = VirtualTimeScheduler_1.VirtualTimeScheduler;
7113 exports.VirtualAction = VirtualTimeScheduler_1.VirtualAction;
7114 var Scheduler_1 = require("./internal/Scheduler");
7115 exports.Scheduler = Scheduler_1.Scheduler;
7116 var Subscription_1 = require("./internal/Subscription");
7117 exports.Subscription = Subscription_1.Subscription;
7118 var Subscriber_1 = require("./internal/Subscriber");
7119 exports.Subscriber = Subscriber_1.Subscriber;
7120 var Notification_1 = require("./internal/Notification");
7121 exports.Notification = Notification_1.Notification;
7122 var pipe_1 = require("./internal/util/pipe");
7123 exports.pipe = pipe_1.pipe;
7124 var noop_1 = require("./internal/util/noop");
7125 exports.noop = noop_1.noop;
7126 var identity_1 = require("./internal/util/identity");
7127 exports.identity = identity_1.identity;
7128 var isObservable_1 = require("./internal/util/isObservable");
7129 exports.isObservable = isObservable_1.isObservable;
7130 var ArgumentOutOfRangeError_1 = require("./internal/util/ArgumentOutOfRangeError");
7131 exports.ArgumentOutOfRangeError = ArgumentOutOfRangeError_1.ArgumentOutOfRangeError;
7132 var EmptyError_1 = require("./internal/util/EmptyError");
7133 exports.EmptyError = EmptyError_1.EmptyError;
7134 var ObjectUnsubscribedError_1 = require("./internal/util/ObjectUnsubscribedError");
7135 exports.ObjectUnsubscribedError = ObjectUnsubscribedError_1.ObjectUnsubscribedError;
7136 var UnsubscriptionError_1 = require("./internal/util/UnsubscriptionError");
7137 exports.UnsubscriptionError = UnsubscriptionError_1.UnsubscriptionError;
7138 var TimeoutError_1 = require("./internal/util/TimeoutError");
7139 exports.TimeoutError = TimeoutError_1.TimeoutError;
7140 var bindCallback_1 = require("./internal/observable/bindCallback");
7141 exports.bindCallback = bindCallback_1.bindCallback;
7142 var bindNodeCallback_1 = require("./internal/observable/bindNodeCallback");
7143 exports.bindNodeCallback = bindNodeCallback_1.bindNodeCallback;
7144 var combineLatest_1 = require("./internal/observable/combineLatest");
7145 exports.combineLatest = combineLatest_1.combineLatest;
7146 var concat_1 = require("./internal/observable/concat");
7147 exports.concat = concat_1.concat;
7148 var defer_1 = require("./internal/observable/defer");
7149 exports.defer = defer_1.defer;
7150 var empty_1 = require("./internal/observable/empty");
7151 exports.empty = empty_1.empty;
7152 var forkJoin_1 = require("./internal/observable/forkJoin");
7153 exports.forkJoin = forkJoin_1.forkJoin;
7154 var from_1 = require("./internal/observable/from");
7155 exports.from = from_1.from;
7156 var fromEvent_1 = require("./internal/observable/fromEvent");
7157 exports.fromEvent = fromEvent_1.fromEvent;
7158 var fromEventPattern_1 = require("./internal/observable/fromEventPattern");
7159 exports.fromEventPattern = fromEventPattern_1.fromEventPattern;
7160 var generate_1 = require("./internal/observable/generate");
7161 exports.generate = generate_1.generate;
7162 var iif_1 = require("./internal/observable/iif");
7163 exports.iif = iif_1.iif;
7164 var interval_1 = require("./internal/observable/interval");
7165 exports.interval = interval_1.interval;
7166 var merge_1 = require("./internal/observable/merge");
7167 exports.merge = merge_1.merge;
7168 var never_1 = require("./internal/observable/never");
7169 exports.never = never_1.never;
7170 var of_1 = require("./internal/observable/of");
7171 exports.of = of_1.of;
7172 var onErrorResumeNext_1 = require("./internal/observable/onErrorResumeNext");
7173 exports.onErrorResumeNext = onErrorResumeNext_1.onErrorResumeNext;
7174 var pairs_1 = require("./internal/observable/pairs");
7175 exports.pairs = pairs_1.pairs;
7176 var race_1 = require("./internal/observable/race");
7177 exports.race = race_1.race;
7178 var range_1 = require("./internal/observable/range");
7179 exports.range = range_1.range;
7180 var throwError_1 = require("./internal/observable/throwError");
7181 exports.throwError = throwError_1.throwError;
7182 var timer_1 = require("./internal/observable/timer");
7183 exports.timer = timer_1.timer;
7184 var using_1 = require("./internal/observable/using");
7185 exports.using = using_1.using;
7186 var zip_1 = require("./internal/observable/zip");
7187 exports.zip = zip_1.zip;
7188 var empty_2 = require("./internal/observable/empty");
7189 exports.EMPTY = empty_2.EMPTY;
7190 var never_2 = require("./internal/observable/never");
7191 exports.NEVER = never_2.NEVER;
7192 var config_1 = require("./internal/config");
7193 exports.config = config_1.config;
7195 },{"./internal/AsyncSubject":28,"./internal/BehaviorSubject":29,"./internal/Notification":31,"./internal/Observable":32,"./internal/ReplaySubject":35,"./internal/Scheduler":36,"./internal/Subject":37,"./internal/Subscriber":39,"./internal/Subscription":40,"./internal/config":41,"./internal/observable/ConnectableObservable":42,"./internal/observable/bindCallback":44,"./internal/observable/bindNodeCallback":45,"./internal/observable/combineLatest":46,"./internal/observable/concat":47,"./internal/observable/defer":48,"./internal/observable/empty":49,"./internal/observable/forkJoin":50,"./internal/observable/from":51,"./internal/observable/fromEvent":53,"./internal/observable/fromEventPattern":54,"./internal/observable/generate":58,"./internal/observable/iif":59,"./internal/observable/interval":60,"./internal/observable/merge":61,"./internal/observable/never":62,"./internal/observable/of":63,"./internal/observable/onErrorResumeNext":64,"./internal/observable/pairs":65,"./internal/observable/race":66,"./internal/observable/range":67,"./internal/observable/throwError":69,"./internal/observable/timer":70,"./internal/observable/using":71,"./internal/observable/zip":72,"./internal/operators/groupBy":108,"./internal/scheduler/VirtualTimeScheduler":185,"./internal/scheduler/animationFrame":186,"./internal/scheduler/asap":187,"./internal/scheduler/async":188,"./internal/scheduler/queue":189,"./internal/symbol/observable":191,"./internal/util/ArgumentOutOfRangeError":193,"./internal/util/EmptyError":194,"./internal/util/ObjectUnsubscribedError":196,"./internal/util/TimeoutError":197,"./internal/util/UnsubscriptionError":198,"./internal/util/identity":202,"./internal/util/isObservable":211,"./internal/util/noop":214,"./internal/util/pipe":216}],28:[function(require,module,exports){
7197 var __extends = (this && this.__extends) || (function () {
7198 var extendStatics = function (d, b) {
7199 extendStatics = Object.setPrototypeOf ||
7200 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
7201 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7202 return extendStatics(d, b);
7204 return function (d, b) {
7205 extendStatics(d, b);
7206 function __() { this.constructor = d; }
7207 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
7210 Object.defineProperty(exports, "__esModule", { value: true });
7211 var Subject_1 = require("./Subject");
7212 var Subscription_1 = require("./Subscription");
7213 var AsyncSubject = (function (_super) {
7214 __extends(AsyncSubject, _super);
7215 function AsyncSubject() {
7216 var _this = _super !== null && _super.apply(this, arguments) || this;
7218 _this.hasNext = false;
7219 _this.hasCompleted = false;
7222 AsyncSubject.prototype._subscribe = function (subscriber) {
7223 if (this.hasError) {
7224 subscriber.error(this.thrownError);
7225 return Subscription_1.Subscription.EMPTY;
7227 else if (this.hasCompleted && this.hasNext) {
7228 subscriber.next(this.value);
7229 subscriber.complete();
7230 return Subscription_1.Subscription.EMPTY;
7232 return _super.prototype._subscribe.call(this, subscriber);
7234 AsyncSubject.prototype.next = function (value) {
7235 if (!this.hasCompleted) {
7237 this.hasNext = true;
7240 AsyncSubject.prototype.error = function (error) {
7241 if (!this.hasCompleted) {
7242 _super.prototype.error.call(this, error);
7245 AsyncSubject.prototype.complete = function () {
7246 this.hasCompleted = true;
7248 _super.prototype.next.call(this, this.value);
7250 _super.prototype.complete.call(this);
7252 return AsyncSubject;
7253 }(Subject_1.Subject));
7254 exports.AsyncSubject = AsyncSubject;
7256 },{"./Subject":37,"./Subscription":40}],29:[function(require,module,exports){
7258 var __extends = (this && this.__extends) || (function () {
7259 var extendStatics = function (d, b) {
7260 extendStatics = Object.setPrototypeOf ||
7261 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
7262 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7263 return extendStatics(d, b);
7265 return function (d, b) {
7266 extendStatics(d, b);
7267 function __() { this.constructor = d; }
7268 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
7271 Object.defineProperty(exports, "__esModule", { value: true });
7272 var Subject_1 = require("./Subject");
7273 var ObjectUnsubscribedError_1 = require("./util/ObjectUnsubscribedError");
7274 var BehaviorSubject = (function (_super) {
7275 __extends(BehaviorSubject, _super);
7276 function BehaviorSubject(_value) {
7277 var _this = _super.call(this) || this;
7278 _this._value = _value;
7281 Object.defineProperty(BehaviorSubject.prototype, "value", {
7283 return this.getValue();
7288 BehaviorSubject.prototype._subscribe = function (subscriber) {
7289 var subscription = _super.prototype._subscribe.call(this, subscriber);
7290 if (subscription && !subscription.closed) {
7291 subscriber.next(this._value);
7293 return subscription;
7295 BehaviorSubject.prototype.getValue = function () {
7296 if (this.hasError) {
7297 throw this.thrownError;
7299 else if (this.closed) {
7300 throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError();
7306 BehaviorSubject.prototype.next = function (value) {
7307 _super.prototype.next.call(this, this._value = value);
7309 return BehaviorSubject;
7310 }(Subject_1.Subject));
7311 exports.BehaviorSubject = BehaviorSubject;
7313 },{"./Subject":37,"./util/ObjectUnsubscribedError":196}],30:[function(require,module,exports){
7315 var __extends = (this && this.__extends) || (function () {
7316 var extendStatics = function (d, b) {
7317 extendStatics = Object.setPrototypeOf ||
7318 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
7319 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7320 return extendStatics(d, b);
7322 return function (d, b) {
7323 extendStatics(d, b);
7324 function __() { this.constructor = d; }
7325 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
7328 Object.defineProperty(exports, "__esModule", { value: true });
7329 var Subscriber_1 = require("./Subscriber");
7330 var InnerSubscriber = (function (_super) {
7331 __extends(InnerSubscriber, _super);
7332 function InnerSubscriber(parent, outerValue, outerIndex) {
7333 var _this = _super.call(this) || this;
7334 _this.parent = parent;
7335 _this.outerValue = outerValue;
7336 _this.outerIndex = outerIndex;
7340 InnerSubscriber.prototype._next = function (value) {
7341 this.parent.notifyNext(this.outerValue, value, this.outerIndex, this.index++, this);
7343 InnerSubscriber.prototype._error = function (error) {
7344 this.parent.notifyError(error, this);
7347 InnerSubscriber.prototype._complete = function () {
7348 this.parent.notifyComplete(this);
7351 return InnerSubscriber;
7352 }(Subscriber_1.Subscriber));
7353 exports.InnerSubscriber = InnerSubscriber;
7355 },{"./Subscriber":39}],31:[function(require,module,exports){
7357 Object.defineProperty(exports, "__esModule", { value: true });
7358 var empty_1 = require("./observable/empty");
7359 var of_1 = require("./observable/of");
7360 var throwError_1 = require("./observable/throwError");
7361 var Notification = (function () {
7362 function Notification(kind, value, error) {
7366 this.hasValue = kind === 'N';
7368 Notification.prototype.observe = function (observer) {
7369 switch (this.kind) {
7371 return observer.next && observer.next(this.value);
7373 return observer.error && observer.error(this.error);
7375 return observer.complete && observer.complete();
7378 Notification.prototype.do = function (next, error, complete) {
7379 var kind = this.kind;
7382 return next && next(this.value);
7384 return error && error(this.error);
7386 return complete && complete();
7389 Notification.prototype.accept = function (nextOrObserver, error, complete) {
7390 if (nextOrObserver && typeof nextOrObserver.next === 'function') {
7391 return this.observe(nextOrObserver);
7394 return this.do(nextOrObserver, error, complete);
7397 Notification.prototype.toObservable = function () {
7398 var kind = this.kind;
7401 return of_1.of(this.value);
7403 return throwError_1.throwError(this.error);
7405 return empty_1.empty();
7407 throw new Error('unexpected notification kind value');
7409 Notification.createNext = function (value) {
7410 if (typeof value !== 'undefined') {
7411 return new Notification('N', value);
7413 return Notification.undefinedValueNotification;
7415 Notification.createError = function (err) {
7416 return new Notification('E', undefined, err);
7418 Notification.createComplete = function () {
7419 return Notification.completeNotification;
7421 Notification.completeNotification = new Notification('C');
7422 Notification.undefinedValueNotification = new Notification('N', undefined);
7423 return Notification;
7425 exports.Notification = Notification;
7427 },{"./observable/empty":49,"./observable/of":63,"./observable/throwError":69}],32:[function(require,module,exports){
7429 Object.defineProperty(exports, "__esModule", { value: true });
7430 var canReportError_1 = require("./util/canReportError");
7431 var toSubscriber_1 = require("./util/toSubscriber");
7432 var observable_1 = require("../internal/symbol/observable");
7433 var pipe_1 = require("./util/pipe");
7434 var config_1 = require("./config");
7435 var Observable = (function () {
7436 function Observable(subscribe) {
7437 this._isScalar = false;
7439 this._subscribe = subscribe;
7442 Observable.prototype.lift = function (operator) {
7443 var observable = new Observable();
7444 observable.source = this;
7445 observable.operator = operator;
7448 Observable.prototype.subscribe = function (observerOrNext, error, complete) {
7449 var operator = this.operator;
7450 var sink = toSubscriber_1.toSubscriber(observerOrNext, error, complete);
7452 operator.call(sink, this.source);
7455 sink.add(this.source || (config_1.config.useDeprecatedSynchronousErrorHandling && !sink.syncErrorThrowable) ?
7456 this._subscribe(sink) :
7457 this._trySubscribe(sink));
7459 if (config_1.config.useDeprecatedSynchronousErrorHandling) {
7460 if (sink.syncErrorThrowable) {
7461 sink.syncErrorThrowable = false;
7462 if (sink.syncErrorThrown) {
7463 throw sink.syncErrorValue;
7469 Observable.prototype._trySubscribe = function (sink) {
7471 return this._subscribe(sink);
7474 if (config_1.config.useDeprecatedSynchronousErrorHandling) {
7475 sink.syncErrorThrown = true;
7476 sink.syncErrorValue = err;
7478 if (canReportError_1.canReportError(sink)) {
7486 Observable.prototype.forEach = function (next, promiseCtor) {
7488 promiseCtor = getPromiseCtor(promiseCtor);
7489 return new promiseCtor(function (resolve, reject) {
7491 subscription = _this.subscribe(function (value) {
7498 subscription.unsubscribe();
7501 }, reject, resolve);
7504 Observable.prototype._subscribe = function (subscriber) {
7505 var source = this.source;
7506 return source && source.subscribe(subscriber);
7508 Observable.prototype[observable_1.observable] = function () {
7511 Observable.prototype.pipe = function () {
7512 var operations = [];
7513 for (var _i = 0; _i < arguments.length; _i++) {
7514 operations[_i] = arguments[_i];
7516 if (operations.length === 0) {
7519 return pipe_1.pipeFromArray(operations)(this);
7521 Observable.prototype.toPromise = function (promiseCtor) {
7523 promiseCtor = getPromiseCtor(promiseCtor);
7524 return new promiseCtor(function (resolve, reject) {
7526 _this.subscribe(function (x) { return value = x; }, function (err) { return reject(err); }, function () { return resolve(value); });
7529 Observable.create = function (subscribe) {
7530 return new Observable(subscribe);
7534 exports.Observable = Observable;
7535 function getPromiseCtor(promiseCtor) {
7537 promiseCtor = config_1.config.Promise || Promise;
7540 throw new Error('no Promise impl found');
7545 },{"../internal/symbol/observable":191,"./config":41,"./util/canReportError":199,"./util/pipe":216,"./util/toSubscriber":223}],33:[function(require,module,exports){
7547 Object.defineProperty(exports, "__esModule", { value: true });
7548 var config_1 = require("./config");
7549 var hostReportError_1 = require("./util/hostReportError");
7552 next: function (value) { },
7553 error: function (err) {
7554 if (config_1.config.useDeprecatedSynchronousErrorHandling) {
7558 hostReportError_1.hostReportError(err);
7561 complete: function () { }
7564 },{"./config":41,"./util/hostReportError":201}],34:[function(require,module,exports){
7566 var __extends = (this && this.__extends) || (function () {
7567 var extendStatics = function (d, b) {
7568 extendStatics = Object.setPrototypeOf ||
7569 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
7570 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7571 return extendStatics(d, b);
7573 return function (d, b) {
7574 extendStatics(d, b);
7575 function __() { this.constructor = d; }
7576 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
7579 Object.defineProperty(exports, "__esModule", { value: true });
7580 var Subscriber_1 = require("./Subscriber");
7581 var OuterSubscriber = (function (_super) {
7582 __extends(OuterSubscriber, _super);
7583 function OuterSubscriber() {
7584 return _super !== null && _super.apply(this, arguments) || this;
7586 OuterSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
7587 this.destination.next(innerValue);
7589 OuterSubscriber.prototype.notifyError = function (error, innerSub) {
7590 this.destination.error(error);
7592 OuterSubscriber.prototype.notifyComplete = function (innerSub) {
7593 this.destination.complete();
7595 return OuterSubscriber;
7596 }(Subscriber_1.Subscriber));
7597 exports.OuterSubscriber = OuterSubscriber;
7599 },{"./Subscriber":39}],35:[function(require,module,exports){
7601 var __extends = (this && this.__extends) || (function () {
7602 var extendStatics = function (d, b) {
7603 extendStatics = Object.setPrototypeOf ||
7604 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
7605 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7606 return extendStatics(d, b);
7608 return function (d, b) {
7609 extendStatics(d, b);
7610 function __() { this.constructor = d; }
7611 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
7614 Object.defineProperty(exports, "__esModule", { value: true });
7615 var Subject_1 = require("./Subject");
7616 var queue_1 = require("./scheduler/queue");
7617 var Subscription_1 = require("./Subscription");
7618 var observeOn_1 = require("./operators/observeOn");
7619 var ObjectUnsubscribedError_1 = require("./util/ObjectUnsubscribedError");
7620 var SubjectSubscription_1 = require("./SubjectSubscription");
7621 var ReplaySubject = (function (_super) {
7622 __extends(ReplaySubject, _super);
7623 function ReplaySubject(bufferSize, windowTime, scheduler) {
7624 if (bufferSize === void 0) { bufferSize = Number.POSITIVE_INFINITY; }
7625 if (windowTime === void 0) { windowTime = Number.POSITIVE_INFINITY; }
7626 var _this = _super.call(this) || this;
7627 _this.scheduler = scheduler;
7629 _this._infiniteTimeWindow = false;
7630 _this._bufferSize = bufferSize < 1 ? 1 : bufferSize;
7631 _this._windowTime = windowTime < 1 ? 1 : windowTime;
7632 if (windowTime === Number.POSITIVE_INFINITY) {
7633 _this._infiniteTimeWindow = true;
7634 _this.next = _this.nextInfiniteTimeWindow;
7637 _this.next = _this.nextTimeWindow;
7641 ReplaySubject.prototype.nextInfiniteTimeWindow = function (value) {
7642 var _events = this._events;
7643 _events.push(value);
7644 if (_events.length > this._bufferSize) {
7647 _super.prototype.next.call(this, value);
7649 ReplaySubject.prototype.nextTimeWindow = function (value) {
7650 this._events.push(new ReplayEvent(this._getNow(), value));
7651 this._trimBufferThenGetEvents();
7652 _super.prototype.next.call(this, value);
7654 ReplaySubject.prototype._subscribe = function (subscriber) {
7655 var _infiniteTimeWindow = this._infiniteTimeWindow;
7656 var _events = _infiniteTimeWindow ? this._events : this._trimBufferThenGetEvents();
7657 var scheduler = this.scheduler;
7658 var len = _events.length;
7661 throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError();
7663 else if (this.isStopped || this.hasError) {
7664 subscription = Subscription_1.Subscription.EMPTY;
7667 this.observers.push(subscriber);
7668 subscription = new SubjectSubscription_1.SubjectSubscription(this, subscriber);
7671 subscriber.add(subscriber = new observeOn_1.ObserveOnSubscriber(subscriber, scheduler));
7673 if (_infiniteTimeWindow) {
7674 for (var i = 0; i < len && !subscriber.closed; i++) {
7675 subscriber.next(_events[i]);
7679 for (var i = 0; i < len && !subscriber.closed; i++) {
7680 subscriber.next(_events[i].value);
7683 if (this.hasError) {
7684 subscriber.error(this.thrownError);
7686 else if (this.isStopped) {
7687 subscriber.complete();
7689 return subscription;
7691 ReplaySubject.prototype._getNow = function () {
7692 return (this.scheduler || queue_1.queue).now();
7694 ReplaySubject.prototype._trimBufferThenGetEvents = function () {
7695 var now = this._getNow();
7696 var _bufferSize = this._bufferSize;
7697 var _windowTime = this._windowTime;
7698 var _events = this._events;
7699 var eventsCount = _events.length;
7700 var spliceCount = 0;
7701 while (spliceCount < eventsCount) {
7702 if ((now - _events[spliceCount].time) < _windowTime) {
7707 if (eventsCount > _bufferSize) {
7708 spliceCount = Math.max(spliceCount, eventsCount - _bufferSize);
7710 if (spliceCount > 0) {
7711 _events.splice(0, spliceCount);
7715 return ReplaySubject;
7716 }(Subject_1.Subject));
7717 exports.ReplaySubject = ReplaySubject;
7718 var ReplayEvent = (function () {
7719 function ReplayEvent(time, value) {
7726 },{"./Subject":37,"./SubjectSubscription":38,"./Subscription":40,"./operators/observeOn":123,"./scheduler/queue":189,"./util/ObjectUnsubscribedError":196}],36:[function(require,module,exports){
7728 Object.defineProperty(exports, "__esModule", { value: true });
7729 var Scheduler = (function () {
7730 function Scheduler(SchedulerAction, now) {
7731 if (now === void 0) { now = Scheduler.now; }
7732 this.SchedulerAction = SchedulerAction;
7735 Scheduler.prototype.schedule = function (work, delay, state) {
7736 if (delay === void 0) { delay = 0; }
7737 return new this.SchedulerAction(this, work).schedule(state, delay);
7739 Scheduler.now = function () { return Date.now(); };
7742 exports.Scheduler = Scheduler;
7744 },{}],37:[function(require,module,exports){
7746 var __extends = (this && this.__extends) || (function () {
7747 var extendStatics = function (d, b) {
7748 extendStatics = Object.setPrototypeOf ||
7749 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
7750 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7751 return extendStatics(d, b);
7753 return function (d, b) {
7754 extendStatics(d, b);
7755 function __() { this.constructor = d; }
7756 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
7759 Object.defineProperty(exports, "__esModule", { value: true });
7760 var Observable_1 = require("./Observable");
7761 var Subscriber_1 = require("./Subscriber");
7762 var Subscription_1 = require("./Subscription");
7763 var ObjectUnsubscribedError_1 = require("./util/ObjectUnsubscribedError");
7764 var SubjectSubscription_1 = require("./SubjectSubscription");
7765 var rxSubscriber_1 = require("../internal/symbol/rxSubscriber");
7766 var SubjectSubscriber = (function (_super) {
7767 __extends(SubjectSubscriber, _super);
7768 function SubjectSubscriber(destination) {
7769 var _this = _super.call(this, destination) || this;
7770 _this.destination = destination;
7773 return SubjectSubscriber;
7774 }(Subscriber_1.Subscriber));
7775 exports.SubjectSubscriber = SubjectSubscriber;
7776 var Subject = (function (_super) {
7777 __extends(Subject, _super);
7778 function Subject() {
7779 var _this = _super.call(this) || this;
7780 _this.observers = [];
7781 _this.closed = false;
7782 _this.isStopped = false;
7783 _this.hasError = false;
7784 _this.thrownError = null;
7787 Subject.prototype[rxSubscriber_1.rxSubscriber] = function () {
7788 return new SubjectSubscriber(this);
7790 Subject.prototype.lift = function (operator) {
7791 var subject = new AnonymousSubject(this, this);
7792 subject.operator = operator;
7795 Subject.prototype.next = function (value) {
7797 throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError();
7799 if (!this.isStopped) {
7800 var observers = this.observers;
7801 var len = observers.length;
7802 var copy = observers.slice();
7803 for (var i = 0; i < len; i++) {
7804 copy[i].next(value);
7808 Subject.prototype.error = function (err) {
7810 throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError();
7812 this.hasError = true;
7813 this.thrownError = err;
7814 this.isStopped = true;
7815 var observers = this.observers;
7816 var len = observers.length;
7817 var copy = observers.slice();
7818 for (var i = 0; i < len; i++) {
7821 this.observers.length = 0;
7823 Subject.prototype.complete = function () {
7825 throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError();
7827 this.isStopped = true;
7828 var observers = this.observers;
7829 var len = observers.length;
7830 var copy = observers.slice();
7831 for (var i = 0; i < len; i++) {
7834 this.observers.length = 0;
7836 Subject.prototype.unsubscribe = function () {
7837 this.isStopped = true;
7839 this.observers = null;
7841 Subject.prototype._trySubscribe = function (subscriber) {
7843 throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError();
7846 return _super.prototype._trySubscribe.call(this, subscriber);
7849 Subject.prototype._subscribe = function (subscriber) {
7851 throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError();
7853 else if (this.hasError) {
7854 subscriber.error(this.thrownError);
7855 return Subscription_1.Subscription.EMPTY;
7857 else if (this.isStopped) {
7858 subscriber.complete();
7859 return Subscription_1.Subscription.EMPTY;
7862 this.observers.push(subscriber);
7863 return new SubjectSubscription_1.SubjectSubscription(this, subscriber);
7866 Subject.prototype.asObservable = function () {
7867 var observable = new Observable_1.Observable();
7868 observable.source = this;
7871 Subject.create = function (destination, source) {
7872 return new AnonymousSubject(destination, source);
7875 }(Observable_1.Observable));
7876 exports.Subject = Subject;
7877 var AnonymousSubject = (function (_super) {
7878 __extends(AnonymousSubject, _super);
7879 function AnonymousSubject(destination, source) {
7880 var _this = _super.call(this) || this;
7881 _this.destination = destination;
7882 _this.source = source;
7885 AnonymousSubject.prototype.next = function (value) {
7886 var destination = this.destination;
7887 if (destination && destination.next) {
7888 destination.next(value);
7891 AnonymousSubject.prototype.error = function (err) {
7892 var destination = this.destination;
7893 if (destination && destination.error) {
7894 this.destination.error(err);
7897 AnonymousSubject.prototype.complete = function () {
7898 var destination = this.destination;
7899 if (destination && destination.complete) {
7900 this.destination.complete();
7903 AnonymousSubject.prototype._subscribe = function (subscriber) {
7904 var source = this.source;
7906 return this.source.subscribe(subscriber);
7909 return Subscription_1.Subscription.EMPTY;
7912 return AnonymousSubject;
7914 exports.AnonymousSubject = AnonymousSubject;
7916 },{"../internal/symbol/rxSubscriber":192,"./Observable":32,"./SubjectSubscription":38,"./Subscriber":39,"./Subscription":40,"./util/ObjectUnsubscribedError":196}],38:[function(require,module,exports){
7918 var __extends = (this && this.__extends) || (function () {
7919 var extendStatics = function (d, b) {
7920 extendStatics = Object.setPrototypeOf ||
7921 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
7922 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7923 return extendStatics(d, b);
7925 return function (d, b) {
7926 extendStatics(d, b);
7927 function __() { this.constructor = d; }
7928 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
7931 Object.defineProperty(exports, "__esModule", { value: true });
7932 var Subscription_1 = require("./Subscription");
7933 var SubjectSubscription = (function (_super) {
7934 __extends(SubjectSubscription, _super);
7935 function SubjectSubscription(subject, subscriber) {
7936 var _this = _super.call(this) || this;
7937 _this.subject = subject;
7938 _this.subscriber = subscriber;
7939 _this.closed = false;
7942 SubjectSubscription.prototype.unsubscribe = function () {
7947 var subject = this.subject;
7948 var observers = subject.observers;
7949 this.subject = null;
7950 if (!observers || observers.length === 0 || subject.isStopped || subject.closed) {
7953 var subscriberIndex = observers.indexOf(this.subscriber);
7954 if (subscriberIndex !== -1) {
7955 observers.splice(subscriberIndex, 1);
7958 return SubjectSubscription;
7959 }(Subscription_1.Subscription));
7960 exports.SubjectSubscription = SubjectSubscription;
7962 },{"./Subscription":40}],39:[function(require,module,exports){
7964 var __extends = (this && this.__extends) || (function () {
7965 var extendStatics = function (d, b) {
7966 extendStatics = Object.setPrototypeOf ||
7967 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
7968 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7969 return extendStatics(d, b);
7971 return function (d, b) {
7972 extendStatics(d, b);
7973 function __() { this.constructor = d; }
7974 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
7977 Object.defineProperty(exports, "__esModule", { value: true });
7978 var isFunction_1 = require("./util/isFunction");
7979 var Observer_1 = require("./Observer");
7980 var Subscription_1 = require("./Subscription");
7981 var rxSubscriber_1 = require("../internal/symbol/rxSubscriber");
7982 var config_1 = require("./config");
7983 var hostReportError_1 = require("./util/hostReportError");
7984 var Subscriber = (function (_super) {
7985 __extends(Subscriber, _super);
7986 function Subscriber(destinationOrNext, error, complete) {
7987 var _this = _super.call(this) || this;
7988 _this.syncErrorValue = null;
7989 _this.syncErrorThrown = false;
7990 _this.syncErrorThrowable = false;
7991 _this.isStopped = false;
7992 _this._parentSubscription = null;
7993 switch (arguments.length) {
7995 _this.destination = Observer_1.empty;
7998 if (!destinationOrNext) {
7999 _this.destination = Observer_1.empty;
8002 if (typeof destinationOrNext === 'object') {
8003 if (destinationOrNext instanceof Subscriber) {
8004 _this.syncErrorThrowable = destinationOrNext.syncErrorThrowable;
8005 _this.destination = destinationOrNext;
8006 destinationOrNext.add(_this);
8009 _this.syncErrorThrowable = true;
8010 _this.destination = new SafeSubscriber(_this, destinationOrNext);
8015 _this.syncErrorThrowable = true;
8016 _this.destination = new SafeSubscriber(_this, destinationOrNext, error, complete);
8021 Subscriber.prototype[rxSubscriber_1.rxSubscriber] = function () { return this; };
8022 Subscriber.create = function (next, error, complete) {
8023 var subscriber = new Subscriber(next, error, complete);
8024 subscriber.syncErrorThrowable = false;
8027 Subscriber.prototype.next = function (value) {
8028 if (!this.isStopped) {
8032 Subscriber.prototype.error = function (err) {
8033 if (!this.isStopped) {
8034 this.isStopped = true;
8038 Subscriber.prototype.complete = function () {
8039 if (!this.isStopped) {
8040 this.isStopped = true;
8044 Subscriber.prototype.unsubscribe = function () {
8048 this.isStopped = true;
8049 _super.prototype.unsubscribe.call(this);
8051 Subscriber.prototype._next = function (value) {
8052 this.destination.next(value);
8054 Subscriber.prototype._error = function (err) {
8055 this.destination.error(err);
8058 Subscriber.prototype._complete = function () {
8059 this.destination.complete();
8062 Subscriber.prototype._unsubscribeAndRecycle = function () {
8063 var _a = this, _parent = _a._parent, _parents = _a._parents;
8064 this._parent = null;
8065 this._parents = null;
8067 this.closed = false;
8068 this.isStopped = false;
8069 this._parent = _parent;
8070 this._parents = _parents;
8071 this._parentSubscription = null;
8075 }(Subscription_1.Subscription));
8076 exports.Subscriber = Subscriber;
8077 var SafeSubscriber = (function (_super) {
8078 __extends(SafeSubscriber, _super);
8079 function SafeSubscriber(_parentSubscriber, observerOrNext, error, complete) {
8080 var _this = _super.call(this) || this;
8081 _this._parentSubscriber = _parentSubscriber;
8083 var context = _this;
8084 if (isFunction_1.isFunction(observerOrNext)) {
8085 next = observerOrNext;
8087 else if (observerOrNext) {
8088 next = observerOrNext.next;
8089 error = observerOrNext.error;
8090 complete = observerOrNext.complete;
8091 if (observerOrNext !== Observer_1.empty) {
8092 context = Object.create(observerOrNext);
8093 if (isFunction_1.isFunction(context.unsubscribe)) {
8094 _this.add(context.unsubscribe.bind(context));
8096 context.unsubscribe = _this.unsubscribe.bind(_this);
8099 _this._context = context;
8101 _this._error = error;
8102 _this._complete = complete;
8105 SafeSubscriber.prototype.next = function (value) {
8106 if (!this.isStopped && this._next) {
8107 var _parentSubscriber = this._parentSubscriber;
8108 if (!config_1.config.useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
8109 this.__tryOrUnsub(this._next, value);
8111 else if (this.__tryOrSetError(_parentSubscriber, this._next, value)) {
8116 SafeSubscriber.prototype.error = function (err) {
8117 if (!this.isStopped) {
8118 var _parentSubscriber = this._parentSubscriber;
8119 var useDeprecatedSynchronousErrorHandling = config_1.config.useDeprecatedSynchronousErrorHandling;
8121 if (!useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
8122 this.__tryOrUnsub(this._error, err);
8126 this.__tryOrSetError(_parentSubscriber, this._error, err);
8130 else if (!_parentSubscriber.syncErrorThrowable) {
8132 if (useDeprecatedSynchronousErrorHandling) {
8135 hostReportError_1.hostReportError(err);
8138 if (useDeprecatedSynchronousErrorHandling) {
8139 _parentSubscriber.syncErrorValue = err;
8140 _parentSubscriber.syncErrorThrown = true;
8143 hostReportError_1.hostReportError(err);
8149 SafeSubscriber.prototype.complete = function () {
8151 if (!this.isStopped) {
8152 var _parentSubscriber = this._parentSubscriber;
8153 if (this._complete) {
8154 var wrappedComplete = function () { return _this._complete.call(_this._context); };
8155 if (!config_1.config.useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
8156 this.__tryOrUnsub(wrappedComplete);
8160 this.__tryOrSetError(_parentSubscriber, wrappedComplete);
8169 SafeSubscriber.prototype.__tryOrUnsub = function (fn, value) {
8171 fn.call(this._context, value);
8175 if (config_1.config.useDeprecatedSynchronousErrorHandling) {
8179 hostReportError_1.hostReportError(err);
8183 SafeSubscriber.prototype.__tryOrSetError = function (parent, fn, value) {
8184 if (!config_1.config.useDeprecatedSynchronousErrorHandling) {
8185 throw new Error('bad call');
8188 fn.call(this._context, value);
8191 if (config_1.config.useDeprecatedSynchronousErrorHandling) {
8192 parent.syncErrorValue = err;
8193 parent.syncErrorThrown = true;
8197 hostReportError_1.hostReportError(err);
8203 SafeSubscriber.prototype._unsubscribe = function () {
8204 var _parentSubscriber = this._parentSubscriber;
8205 this._context = null;
8206 this._parentSubscriber = null;
8207 _parentSubscriber.unsubscribe();
8209 return SafeSubscriber;
8211 exports.SafeSubscriber = SafeSubscriber;
8213 },{"../internal/symbol/rxSubscriber":192,"./Observer":33,"./Subscription":40,"./config":41,"./util/hostReportError":201,"./util/isFunction":206}],40:[function(require,module,exports){
8215 Object.defineProperty(exports, "__esModule", { value: true });
8216 var isArray_1 = require("./util/isArray");
8217 var isObject_1 = require("./util/isObject");
8218 var isFunction_1 = require("./util/isFunction");
8219 var tryCatch_1 = require("./util/tryCatch");
8220 var errorObject_1 = require("./util/errorObject");
8221 var UnsubscriptionError_1 = require("./util/UnsubscriptionError");
8222 var Subscription = (function () {
8223 function Subscription(unsubscribe) {
8224 this.closed = false;
8225 this._parent = null;
8226 this._parents = null;
8227 this._subscriptions = null;
8229 this._unsubscribe = unsubscribe;
8232 Subscription.prototype.unsubscribe = function () {
8233 var hasErrors = false;
8238 var _a = this, _parent = _a._parent, _parents = _a._parents, _unsubscribe = _a._unsubscribe, _subscriptions = _a._subscriptions;
8240 this._parent = null;
8241 this._parents = null;
8242 this._subscriptions = null;
8244 var len = _parents ? _parents.length : 0;
8246 _parent.remove(this);
8247 _parent = ++index < len && _parents[index] || null;
8249 if (isFunction_1.isFunction(_unsubscribe)) {
8250 var trial = tryCatch_1.tryCatch(_unsubscribe).call(this);
8251 if (trial === errorObject_1.errorObject) {
8253 errors = errors || (errorObject_1.errorObject.e instanceof UnsubscriptionError_1.UnsubscriptionError ?
8254 flattenUnsubscriptionErrors(errorObject_1.errorObject.e.errors) : [errorObject_1.errorObject.e]);
8257 if (isArray_1.isArray(_subscriptions)) {
8259 len = _subscriptions.length;
8260 while (++index < len) {
8261 var sub = _subscriptions[index];
8262 if (isObject_1.isObject(sub)) {
8263 var trial = tryCatch_1.tryCatch(sub.unsubscribe).call(sub);
8264 if (trial === errorObject_1.errorObject) {
8266 errors = errors || [];
8267 var err = errorObject_1.errorObject.e;
8268 if (err instanceof UnsubscriptionError_1.UnsubscriptionError) {
8269 errors = errors.concat(flattenUnsubscriptionErrors(err.errors));
8279 throw new UnsubscriptionError_1.UnsubscriptionError(errors);
8282 Subscription.prototype.add = function (teardown) {
8283 if (!teardown || (teardown === Subscription.EMPTY)) {
8284 return Subscription.EMPTY;
8286 if (teardown === this) {
8289 var subscription = teardown;
8290 switch (typeof teardown) {
8292 subscription = new Subscription(teardown);
8294 if (subscription.closed || typeof subscription.unsubscribe !== 'function') {
8295 return subscription;
8297 else if (this.closed) {
8298 subscription.unsubscribe();
8299 return subscription;
8301 else if (typeof subscription._addParent !== 'function') {
8302 var tmp = subscription;
8303 subscription = new Subscription();
8304 subscription._subscriptions = [tmp];
8308 throw new Error('unrecognized teardown ' + teardown + ' added to Subscription.');
8310 var subscriptions = this._subscriptions || (this._subscriptions = []);
8311 subscriptions.push(subscription);
8312 subscription._addParent(this);
8313 return subscription;
8315 Subscription.prototype.remove = function (subscription) {
8316 var subscriptions = this._subscriptions;
8317 if (subscriptions) {
8318 var subscriptionIndex = subscriptions.indexOf(subscription);
8319 if (subscriptionIndex !== -1) {
8320 subscriptions.splice(subscriptionIndex, 1);
8324 Subscription.prototype._addParent = function (parent) {
8325 var _a = this, _parent = _a._parent, _parents = _a._parents;
8326 if (!_parent || _parent === parent) {
8327 this._parent = parent;
8329 else if (!_parents) {
8330 this._parents = [parent];
8332 else if (_parents.indexOf(parent) === -1) {
8333 _parents.push(parent);
8336 Subscription.EMPTY = (function (empty) {
8337 empty.closed = true;
8339 }(new Subscription()));
8340 return Subscription;
8342 exports.Subscription = Subscription;
8343 function flattenUnsubscriptionErrors(errors) {
8344 return errors.reduce(function (errs, err) { return errs.concat((err instanceof UnsubscriptionError_1.UnsubscriptionError) ? err.errors : err); }, []);
8347 },{"./util/UnsubscriptionError":198,"./util/errorObject":200,"./util/isArray":203,"./util/isFunction":206,"./util/isObject":210,"./util/tryCatch":224}],41:[function(require,module,exports){
8349 Object.defineProperty(exports, "__esModule", { value: true });
8350 var _enable_super_gross_mode_that_will_cause_bad_things = false;
8353 set useDeprecatedSynchronousErrorHandling(value) {
8355 var error = new Error();
8356 console.warn('DEPRECATED! RxJS was set to use deprecated synchronous error handling behavior by code at: \n' + error.stack);
8358 else if (_enable_super_gross_mode_that_will_cause_bad_things) {
8359 console.log('RxJS: Back to a better error behavior. Thank you. <3');
8361 _enable_super_gross_mode_that_will_cause_bad_things = value;
8363 get useDeprecatedSynchronousErrorHandling() {
8364 return _enable_super_gross_mode_that_will_cause_bad_things;
8368 },{}],42:[function(require,module,exports){
8370 var __extends = (this && this.__extends) || (function () {
8371 var extendStatics = function (d, b) {
8372 extendStatics = Object.setPrototypeOf ||
8373 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
8374 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
8375 return extendStatics(d, b);
8377 return function (d, b) {
8378 extendStatics(d, b);
8379 function __() { this.constructor = d; }
8380 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
8383 Object.defineProperty(exports, "__esModule", { value: true });
8384 var Subject_1 = require("../Subject");
8385 var Observable_1 = require("../Observable");
8386 var Subscriber_1 = require("../Subscriber");
8387 var Subscription_1 = require("../Subscription");
8388 var refCount_1 = require("../operators/refCount");
8389 var ConnectableObservable = (function (_super) {
8390 __extends(ConnectableObservable, _super);
8391 function ConnectableObservable(source, subjectFactory) {
8392 var _this = _super.call(this) || this;
8393 _this.source = source;
8394 _this.subjectFactory = subjectFactory;
8395 _this._refCount = 0;
8396 _this._isComplete = false;
8399 ConnectableObservable.prototype._subscribe = function (subscriber) {
8400 return this.getSubject().subscribe(subscriber);
8402 ConnectableObservable.prototype.getSubject = function () {
8403 var subject = this._subject;
8404 if (!subject || subject.isStopped) {
8405 this._subject = this.subjectFactory();
8407 return this._subject;
8409 ConnectableObservable.prototype.connect = function () {
8410 var connection = this._connection;
8412 this._isComplete = false;
8413 connection = this._connection = new Subscription_1.Subscription();
8414 connection.add(this.source
8415 .subscribe(new ConnectableSubscriber(this.getSubject(), this)));
8416 if (connection.closed) {
8417 this._connection = null;
8418 connection = Subscription_1.Subscription.EMPTY;
8421 this._connection = connection;
8426 ConnectableObservable.prototype.refCount = function () {
8427 return refCount_1.refCount()(this);
8429 return ConnectableObservable;
8430 }(Observable_1.Observable));
8431 exports.ConnectableObservable = ConnectableObservable;
8432 var connectableProto = ConnectableObservable.prototype;
8433 exports.connectableObservableDescriptor = {
8434 operator: { value: null },
8435 _refCount: { value: 0, writable: true },
8436 _subject: { value: null, writable: true },
8437 _connection: { value: null, writable: true },
8438 _subscribe: { value: connectableProto._subscribe },
8439 _isComplete: { value: connectableProto._isComplete, writable: true },
8440 getSubject: { value: connectableProto.getSubject },
8441 connect: { value: connectableProto.connect },
8442 refCount: { value: connectableProto.refCount }
8444 var ConnectableSubscriber = (function (_super) {
8445 __extends(ConnectableSubscriber, _super);
8446 function ConnectableSubscriber(destination, connectable) {
8447 var _this = _super.call(this, destination) || this;
8448 _this.connectable = connectable;
8451 ConnectableSubscriber.prototype._error = function (err) {
8452 this._unsubscribe();
8453 _super.prototype._error.call(this, err);
8455 ConnectableSubscriber.prototype._complete = function () {
8456 this.connectable._isComplete = true;
8457 this._unsubscribe();
8458 _super.prototype._complete.call(this);
8460 ConnectableSubscriber.prototype._unsubscribe = function () {
8461 var connectable = this.connectable;
8463 this.connectable = null;
8464 var connection = connectable._connection;
8465 connectable._refCount = 0;
8466 connectable._subject = null;
8467 connectable._connection = null;
8469 connection.unsubscribe();
8473 return ConnectableSubscriber;
8474 }(Subject_1.SubjectSubscriber));
8475 var RefCountOperator = (function () {
8476 function RefCountOperator(connectable) {
8477 this.connectable = connectable;
8479 RefCountOperator.prototype.call = function (subscriber, source) {
8480 var connectable = this.connectable;
8481 connectable._refCount++;
8482 var refCounter = new RefCountSubscriber(subscriber, connectable);
8483 var subscription = source.subscribe(refCounter);
8484 if (!refCounter.closed) {
8485 refCounter.connection = connectable.connect();
8487 return subscription;
8489 return RefCountOperator;
8491 var RefCountSubscriber = (function (_super) {
8492 __extends(RefCountSubscriber, _super);
8493 function RefCountSubscriber(destination, connectable) {
8494 var _this = _super.call(this, destination) || this;
8495 _this.connectable = connectable;
8498 RefCountSubscriber.prototype._unsubscribe = function () {
8499 var connectable = this.connectable;
8501 this.connection = null;
8504 this.connectable = null;
8505 var refCount = connectable._refCount;
8506 if (refCount <= 0) {
8507 this.connection = null;
8510 connectable._refCount = refCount - 1;
8512 this.connection = null;
8515 var connection = this.connection;
8516 var sharedConnection = connectable._connection;
8517 this.connection = null;
8518 if (sharedConnection && (!connection || sharedConnection === connection)) {
8519 sharedConnection.unsubscribe();
8522 return RefCountSubscriber;
8523 }(Subscriber_1.Subscriber));
8525 },{"../Observable":32,"../Subject":37,"../Subscriber":39,"../Subscription":40,"../operators/refCount":134}],43:[function(require,module,exports){
8527 var __extends = (this && this.__extends) || (function () {
8528 var extendStatics = function (d, b) {
8529 extendStatics = Object.setPrototypeOf ||
8530 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
8531 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
8532 return extendStatics(d, b);
8534 return function (d, b) {
8535 extendStatics(d, b);
8536 function __() { this.constructor = d; }
8537 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
8540 Object.defineProperty(exports, "__esModule", { value: true });
8541 var Observable_1 = require("../Observable");
8542 var asap_1 = require("../scheduler/asap");
8543 var isNumeric_1 = require("../util/isNumeric");
8544 var SubscribeOnObservable = (function (_super) {
8545 __extends(SubscribeOnObservable, _super);
8546 function SubscribeOnObservable(source, delayTime, scheduler) {
8547 if (delayTime === void 0) { delayTime = 0; }
8548 if (scheduler === void 0) { scheduler = asap_1.asap; }
8549 var _this = _super.call(this) || this;
8550 _this.source = source;
8551 _this.delayTime = delayTime;
8552 _this.scheduler = scheduler;
8553 if (!isNumeric_1.isNumeric(delayTime) || delayTime < 0) {
8554 _this.delayTime = 0;
8556 if (!scheduler || typeof scheduler.schedule !== 'function') {
8557 _this.scheduler = asap_1.asap;
8561 SubscribeOnObservable.create = function (source, delay, scheduler) {
8562 if (delay === void 0) { delay = 0; }
8563 if (scheduler === void 0) { scheduler = asap_1.asap; }
8564 return new SubscribeOnObservable(source, delay, scheduler);
8566 SubscribeOnObservable.dispatch = function (arg) {
8567 var source = arg.source, subscriber = arg.subscriber;
8568 return this.add(source.subscribe(subscriber));
8570 SubscribeOnObservable.prototype._subscribe = function (subscriber) {
8571 var delay = this.delayTime;
8572 var source = this.source;
8573 var scheduler = this.scheduler;
8574 return scheduler.schedule(SubscribeOnObservable.dispatch, delay, {
8575 source: source, subscriber: subscriber
8578 return SubscribeOnObservable;
8579 }(Observable_1.Observable));
8580 exports.SubscribeOnObservable = SubscribeOnObservable;
8582 },{"../Observable":32,"../scheduler/asap":187,"../util/isNumeric":209}],44:[function(require,module,exports){
8584 Object.defineProperty(exports, "__esModule", { value: true });
8585 var Observable_1 = require("../Observable");
8586 var AsyncSubject_1 = require("../AsyncSubject");
8587 var map_1 = require("../operators/map");
8588 var canReportError_1 = require("../util/canReportError");
8589 var isArray_1 = require("../util/isArray");
8590 var isScheduler_1 = require("../util/isScheduler");
8591 function bindCallback(callbackFunc, resultSelector, scheduler) {
8592 if (resultSelector) {
8593 if (isScheduler_1.isScheduler(resultSelector)) {
8594 scheduler = resultSelector;
8597 return function () {
8599 for (var _i = 0; _i < arguments.length; _i++) {
8600 args[_i] = arguments[_i];
8602 return bindCallback(callbackFunc, scheduler).apply(void 0, args).pipe(map_1.map(function (args) { return isArray_1.isArray(args) ? resultSelector.apply(void 0, args) : resultSelector(args); }));
8606 return function () {
8608 for (var _i = 0; _i < arguments.length; _i++) {
8609 args[_i] = arguments[_i];
8616 callbackFunc: callbackFunc,
8617 scheduler: scheduler,
8619 return new Observable_1.Observable(function (subscriber) {
8622 subject = new AsyncSubject_1.AsyncSubject();
8623 var handler = function () {
8625 for (var _i = 0; _i < arguments.length; _i++) {
8626 innerArgs[_i] = arguments[_i];
8628 subject.next(innerArgs.length <= 1 ? innerArgs[0] : innerArgs);
8632 callbackFunc.apply(context, args.concat([handler]));
8635 if (canReportError_1.canReportError(subject)) {
8643 return subject.subscribe(subscriber);
8647 args: args, subscriber: subscriber, params: params,
8649 return scheduler.schedule(dispatch, 0, state);
8654 exports.bindCallback = bindCallback;
8655 function dispatch(state) {
8658 var args = state.args, subscriber = state.subscriber, params = state.params;
8659 var callbackFunc = params.callbackFunc, context = params.context, scheduler = params.scheduler;
8660 var subject = params.subject;
8662 subject = params.subject = new AsyncSubject_1.AsyncSubject();
8663 var handler = function () {
8665 for (var _i = 0; _i < arguments.length; _i++) {
8666 innerArgs[_i] = arguments[_i];
8668 var value = innerArgs.length <= 1 ? innerArgs[0] : innerArgs;
8669 _this.add(scheduler.schedule(dispatchNext, 0, { value: value, subject: subject }));
8672 callbackFunc.apply(context, args.concat([handler]));
8678 this.add(subject.subscribe(subscriber));
8680 function dispatchNext(state) {
8681 var value = state.value, subject = state.subject;
8682 subject.next(value);
8685 function dispatchError(state) {
8686 var err = state.err, subject = state.subject;
8690 },{"../AsyncSubject":28,"../Observable":32,"../operators/map":112,"../util/canReportError":199,"../util/isArray":203,"../util/isScheduler":213}],45:[function(require,module,exports){
8692 Object.defineProperty(exports, "__esModule", { value: true });
8693 var Observable_1 = require("../Observable");
8694 var AsyncSubject_1 = require("../AsyncSubject");
8695 var map_1 = require("../operators/map");
8696 var canReportError_1 = require("../util/canReportError");
8697 var isScheduler_1 = require("../util/isScheduler");
8698 var isArray_1 = require("../util/isArray");
8699 function bindNodeCallback(callbackFunc, resultSelector, scheduler) {
8700 if (resultSelector) {
8701 if (isScheduler_1.isScheduler(resultSelector)) {
8702 scheduler = resultSelector;
8705 return function () {
8707 for (var _i = 0; _i < arguments.length; _i++) {
8708 args[_i] = arguments[_i];
8710 return bindNodeCallback(callbackFunc, scheduler).apply(void 0, args).pipe(map_1.map(function (args) { return isArray_1.isArray(args) ? resultSelector.apply(void 0, args) : resultSelector(args); }));
8714 return function () {
8716 for (var _i = 0; _i < arguments.length; _i++) {
8717 args[_i] = arguments[_i];
8722 callbackFunc: callbackFunc,
8723 scheduler: scheduler,
8726 return new Observable_1.Observable(function (subscriber) {
8727 var context = params.context;
8728 var subject = params.subject;
8731 subject = params.subject = new AsyncSubject_1.AsyncSubject();
8732 var handler = function () {
8734 for (var _i = 0; _i < arguments.length; _i++) {
8735 innerArgs[_i] = arguments[_i];
8737 var err = innerArgs.shift();
8742 subject.next(innerArgs.length <= 1 ? innerArgs[0] : innerArgs);
8746 callbackFunc.apply(context, args.concat([handler]));
8749 if (canReportError_1.canReportError(subject)) {
8757 return subject.subscribe(subscriber);
8760 return scheduler.schedule(dispatch, 0, { params: params, subscriber: subscriber, context: context });
8765 exports.bindNodeCallback = bindNodeCallback;
8766 function dispatch(state) {
8768 var params = state.params, subscriber = state.subscriber, context = state.context;
8769 var callbackFunc = params.callbackFunc, args = params.args, scheduler = params.scheduler;
8770 var subject = params.subject;
8772 subject = params.subject = new AsyncSubject_1.AsyncSubject();
8773 var handler = function () {
8775 for (var _i = 0; _i < arguments.length; _i++) {
8776 innerArgs[_i] = arguments[_i];
8778 var err = innerArgs.shift();
8780 _this.add(scheduler.schedule(dispatchError, 0, { err: err, subject: subject }));
8783 var value = innerArgs.length <= 1 ? innerArgs[0] : innerArgs;
8784 _this.add(scheduler.schedule(dispatchNext, 0, { value: value, subject: subject }));
8788 callbackFunc.apply(context, args.concat([handler]));
8791 this.add(scheduler.schedule(dispatchError, 0, { err: err, subject: subject }));
8794 this.add(subject.subscribe(subscriber));
8796 function dispatchNext(arg) {
8797 var value = arg.value, subject = arg.subject;
8798 subject.next(value);
8801 function dispatchError(arg) {
8802 var err = arg.err, subject = arg.subject;
8806 },{"../AsyncSubject":28,"../Observable":32,"../operators/map":112,"../util/canReportError":199,"../util/isArray":203,"../util/isScheduler":213}],46:[function(require,module,exports){
8808 var __extends = (this && this.__extends) || (function () {
8809 var extendStatics = function (d, b) {
8810 extendStatics = Object.setPrototypeOf ||
8811 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
8812 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
8813 return extendStatics(d, b);
8815 return function (d, b) {
8816 extendStatics(d, b);
8817 function __() { this.constructor = d; }
8818 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
8821 Object.defineProperty(exports, "__esModule", { value: true });
8822 var isScheduler_1 = require("../util/isScheduler");
8823 var isArray_1 = require("../util/isArray");
8824 var OuterSubscriber_1 = require("../OuterSubscriber");
8825 var subscribeToResult_1 = require("../util/subscribeToResult");
8826 var fromArray_1 = require("./fromArray");
8828 function combineLatest() {
8829 var observables = [];
8830 for (var _i = 0; _i < arguments.length; _i++) {
8831 observables[_i] = arguments[_i];
8833 var resultSelector = null;
8834 var scheduler = null;
8835 if (isScheduler_1.isScheduler(observables[observables.length - 1])) {
8836 scheduler = observables.pop();
8838 if (typeof observables[observables.length - 1] === 'function') {
8839 resultSelector = observables.pop();
8841 if (observables.length === 1 && isArray_1.isArray(observables[0])) {
8842 observables = observables[0];
8844 return fromArray_1.fromArray(observables, scheduler).lift(new CombineLatestOperator(resultSelector));
8846 exports.combineLatest = combineLatest;
8847 var CombineLatestOperator = (function () {
8848 function CombineLatestOperator(resultSelector) {
8849 this.resultSelector = resultSelector;
8851 CombineLatestOperator.prototype.call = function (subscriber, source) {
8852 return source.subscribe(new CombineLatestSubscriber(subscriber, this.resultSelector));
8854 return CombineLatestOperator;
8856 exports.CombineLatestOperator = CombineLatestOperator;
8857 var CombineLatestSubscriber = (function (_super) {
8858 __extends(CombineLatestSubscriber, _super);
8859 function CombineLatestSubscriber(destination, resultSelector) {
8860 var _this = _super.call(this, destination) || this;
8861 _this.resultSelector = resultSelector;
8864 _this.observables = [];
8867 CombineLatestSubscriber.prototype._next = function (observable) {
8868 this.values.push(NONE);
8869 this.observables.push(observable);
8871 CombineLatestSubscriber.prototype._complete = function () {
8872 var observables = this.observables;
8873 var len = observables.length;
8875 this.destination.complete();
8879 this.toRespond = len;
8880 for (var i = 0; i < len; i++) {
8881 var observable = observables[i];
8882 this.add(subscribeToResult_1.subscribeToResult(this, observable, observable, i));
8886 CombineLatestSubscriber.prototype.notifyComplete = function (unused) {
8887 if ((this.active -= 1) === 0) {
8888 this.destination.complete();
8891 CombineLatestSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
8892 var values = this.values;
8893 var oldVal = values[outerIndex];
8894 var toRespond = !this.toRespond
8896 : oldVal === NONE ? --this.toRespond : this.toRespond;
8897 values[outerIndex] = innerValue;
8898 if (toRespond === 0) {
8899 if (this.resultSelector) {
8900 this._tryResultSelector(values);
8903 this.destination.next(values.slice());
8907 CombineLatestSubscriber.prototype._tryResultSelector = function (values) {
8910 result = this.resultSelector.apply(this, values);
8913 this.destination.error(err);
8916 this.destination.next(result);
8918 return CombineLatestSubscriber;
8919 }(OuterSubscriber_1.OuterSubscriber));
8920 exports.CombineLatestSubscriber = CombineLatestSubscriber;
8922 },{"../OuterSubscriber":34,"../util/isArray":203,"../util/isScheduler":213,"../util/subscribeToResult":222,"./fromArray":52}],47:[function(require,module,exports){
8924 Object.defineProperty(exports, "__esModule", { value: true });
8925 var isScheduler_1 = require("../util/isScheduler");
8926 var of_1 = require("./of");
8927 var from_1 = require("./from");
8928 var concatAll_1 = require("../operators/concatAll");
8930 var observables = [];
8931 for (var _i = 0; _i < arguments.length; _i++) {
8932 observables[_i] = arguments[_i];
8934 if (observables.length === 1 || (observables.length === 2 && isScheduler_1.isScheduler(observables[1]))) {
8935 return from_1.from(observables[0]);
8937 return concatAll_1.concatAll()(of_1.of.apply(void 0, observables));
8939 exports.concat = concat;
8941 },{"../operators/concatAll":84,"../util/isScheduler":213,"./from":51,"./of":63}],48:[function(require,module,exports){
8943 Object.defineProperty(exports, "__esModule", { value: true });
8944 var Observable_1 = require("../Observable");
8945 var from_1 = require("./from");
8946 var empty_1 = require("./empty");
8947 function defer(observableFactory) {
8948 return new Observable_1.Observable(function (subscriber) {
8951 input = observableFactory();
8954 subscriber.error(err);
8957 var source = input ? from_1.from(input) : empty_1.empty();
8958 return source.subscribe(subscriber);
8961 exports.defer = defer;
8963 },{"../Observable":32,"./empty":49,"./from":51}],49:[function(require,module,exports){
8965 Object.defineProperty(exports, "__esModule", { value: true });
8966 var Observable_1 = require("../Observable");
8967 exports.EMPTY = new Observable_1.Observable(function (subscriber) { return subscriber.complete(); });
8968 function empty(scheduler) {
8969 return scheduler ? emptyScheduled(scheduler) : exports.EMPTY;
8971 exports.empty = empty;
8972 function emptyScheduled(scheduler) {
8973 return new Observable_1.Observable(function (subscriber) { return scheduler.schedule(function () { return subscriber.complete(); }); });
8975 exports.emptyScheduled = emptyScheduled;
8977 },{"../Observable":32}],50:[function(require,module,exports){
8979 var __extends = (this && this.__extends) || (function () {
8980 var extendStatics = function (d, b) {
8981 extendStatics = Object.setPrototypeOf ||
8982 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
8983 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
8984 return extendStatics(d, b);
8986 return function (d, b) {
8987 extendStatics(d, b);
8988 function __() { this.constructor = d; }
8989 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
8992 Object.defineProperty(exports, "__esModule", { value: true });
8993 var Observable_1 = require("../Observable");
8994 var isArray_1 = require("../util/isArray");
8995 var empty_1 = require("./empty");
8996 var subscribeToResult_1 = require("../util/subscribeToResult");
8997 var OuterSubscriber_1 = require("../OuterSubscriber");
8998 var map_1 = require("../operators/map");
8999 function forkJoin() {
9001 for (var _i = 0; _i < arguments.length; _i++) {
9002 sources[_i] = arguments[_i];
9005 if (typeof sources[sources.length - 1] === 'function') {
9006 resultSelector = sources.pop();
9008 if (sources.length === 1 && isArray_1.isArray(sources[0])) {
9009 sources = sources[0];
9011 if (sources.length === 0) {
9012 return empty_1.EMPTY;
9014 if (resultSelector) {
9015 return forkJoin(sources).pipe(map_1.map(function (args) { return resultSelector.apply(void 0, args); }));
9017 return new Observable_1.Observable(function (subscriber) {
9018 return new ForkJoinSubscriber(subscriber, sources);
9021 exports.forkJoin = forkJoin;
9022 var ForkJoinSubscriber = (function (_super) {
9023 __extends(ForkJoinSubscriber, _super);
9024 function ForkJoinSubscriber(destination, sources) {
9025 var _this = _super.call(this, destination) || this;
9026 _this.sources = sources;
9027 _this.completed = 0;
9028 _this.haveValues = 0;
9029 var len = sources.length;
9030 _this.values = new Array(len);
9031 for (var i = 0; i < len; i++) {
9032 var source = sources[i];
9033 var innerSubscription = subscribeToResult_1.subscribeToResult(_this, source, null, i);
9034 if (innerSubscription) {
9035 _this.add(innerSubscription);
9040 ForkJoinSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
9041 this.values[outerIndex] = innerValue;
9042 if (!innerSub._hasValue) {
9043 innerSub._hasValue = true;
9047 ForkJoinSubscriber.prototype.notifyComplete = function (innerSub) {
9048 var _a = this, destination = _a.destination, haveValues = _a.haveValues, values = _a.values;
9049 var len = values.length;
9050 if (!innerSub._hasValue) {
9051 destination.complete();
9055 if (this.completed !== len) {
9058 if (haveValues === len) {
9059 destination.next(values);
9061 destination.complete();
9063 return ForkJoinSubscriber;
9064 }(OuterSubscriber_1.OuterSubscriber));
9066 },{"../Observable":32,"../OuterSubscriber":34,"../operators/map":112,"../util/isArray":203,"../util/subscribeToResult":222,"./empty":49}],51:[function(require,module,exports){
9068 Object.defineProperty(exports, "__esModule", { value: true });
9069 var Observable_1 = require("../Observable");
9070 var isPromise_1 = require("../util/isPromise");
9071 var isArrayLike_1 = require("../util/isArrayLike");
9072 var isInteropObservable_1 = require("../util/isInteropObservable");
9073 var isIterable_1 = require("../util/isIterable");
9074 var fromArray_1 = require("./fromArray");
9075 var fromPromise_1 = require("./fromPromise");
9076 var fromIterable_1 = require("./fromIterable");
9077 var fromObservable_1 = require("./fromObservable");
9078 var subscribeTo_1 = require("../util/subscribeTo");
9079 function from(input, scheduler) {
9081 if (input instanceof Observable_1.Observable) {
9084 return new Observable_1.Observable(subscribeTo_1.subscribeTo(input));
9086 if (input != null) {
9087 if (isInteropObservable_1.isInteropObservable(input)) {
9088 return fromObservable_1.fromObservable(input, scheduler);
9090 else if (isPromise_1.isPromise(input)) {
9091 return fromPromise_1.fromPromise(input, scheduler);
9093 else if (isArrayLike_1.isArrayLike(input)) {
9094 return fromArray_1.fromArray(input, scheduler);
9096 else if (isIterable_1.isIterable(input) || typeof input === 'string') {
9097 return fromIterable_1.fromIterable(input, scheduler);
9100 throw new TypeError((input !== null && typeof input || input) + ' is not observable');
9102 exports.from = from;
9104 },{"../Observable":32,"../util/isArrayLike":204,"../util/isInteropObservable":207,"../util/isIterable":208,"../util/isPromise":212,"../util/subscribeTo":217,"./fromArray":52,"./fromIterable":55,"./fromObservable":56,"./fromPromise":57}],52:[function(require,module,exports){
9106 Object.defineProperty(exports, "__esModule", { value: true });
9107 var Observable_1 = require("../Observable");
9108 var Subscription_1 = require("../Subscription");
9109 var subscribeToArray_1 = require("../util/subscribeToArray");
9110 function fromArray(input, scheduler) {
9112 return new Observable_1.Observable(subscribeToArray_1.subscribeToArray(input));
9115 return new Observable_1.Observable(function (subscriber) {
9116 var sub = new Subscription_1.Subscription();
9118 sub.add(scheduler.schedule(function () {
9119 if (i === input.length) {
9120 subscriber.complete();
9123 subscriber.next(input[i++]);
9124 if (!subscriber.closed) {
9125 sub.add(this.schedule());
9132 exports.fromArray = fromArray;
9134 },{"../Observable":32,"../Subscription":40,"../util/subscribeToArray":218}],53:[function(require,module,exports){
9136 Object.defineProperty(exports, "__esModule", { value: true });
9137 var Observable_1 = require("../Observable");
9138 var isArray_1 = require("../util/isArray");
9139 var isFunction_1 = require("../util/isFunction");
9140 var map_1 = require("../operators/map");
9141 var toString = Object.prototype.toString;
9142 function fromEvent(target, eventName, options, resultSelector) {
9143 if (isFunction_1.isFunction(options)) {
9144 resultSelector = options;
9145 options = undefined;
9147 if (resultSelector) {
9148 return fromEvent(target, eventName, options).pipe(map_1.map(function (args) { return isArray_1.isArray(args) ? resultSelector.apply(void 0, args) : resultSelector(args); }));
9150 return new Observable_1.Observable(function (subscriber) {
9151 function handler(e) {
9152 if (arguments.length > 1) {
9153 subscriber.next(Array.prototype.slice.call(arguments));
9159 setupSubscription(target, eventName, handler, subscriber, options);
9162 exports.fromEvent = fromEvent;
9163 function setupSubscription(sourceObj, eventName, handler, subscriber, options) {
9165 if (isEventTarget(sourceObj)) {
9166 var source_1 = sourceObj;
9167 sourceObj.addEventListener(eventName, handler, options);
9168 unsubscribe = function () { return source_1.removeEventListener(eventName, handler, options); };
9170 else if (isJQueryStyleEventEmitter(sourceObj)) {
9171 var source_2 = sourceObj;
9172 sourceObj.on(eventName, handler);
9173 unsubscribe = function () { return source_2.off(eventName, handler); };
9175 else if (isNodeStyleEventEmitter(sourceObj)) {
9176 var source_3 = sourceObj;
9177 sourceObj.addListener(eventName, handler);
9178 unsubscribe = function () { return source_3.removeListener(eventName, handler); };
9180 else if (sourceObj && sourceObj.length) {
9181 for (var i = 0, len = sourceObj.length; i < len; i++) {
9182 setupSubscription(sourceObj[i], eventName, handler, subscriber, options);
9186 throw new TypeError('Invalid event target');
9188 subscriber.add(unsubscribe);
9190 function isNodeStyleEventEmitter(sourceObj) {
9191 return sourceObj && typeof sourceObj.addListener === 'function' && typeof sourceObj.removeListener === 'function';
9193 function isJQueryStyleEventEmitter(sourceObj) {
9194 return sourceObj && typeof sourceObj.on === 'function' && typeof sourceObj.off === 'function';
9196 function isEventTarget(sourceObj) {
9197 return sourceObj && typeof sourceObj.addEventListener === 'function' && typeof sourceObj.removeEventListener === 'function';
9200 },{"../Observable":32,"../operators/map":112,"../util/isArray":203,"../util/isFunction":206}],54:[function(require,module,exports){
9202 Object.defineProperty(exports, "__esModule", { value: true });
9203 var Observable_1 = require("../Observable");
9204 var isArray_1 = require("../util/isArray");
9205 var isFunction_1 = require("../util/isFunction");
9206 var map_1 = require("../operators/map");
9207 function fromEventPattern(addHandler, removeHandler, resultSelector) {
9208 if (resultSelector) {
9209 return fromEventPattern(addHandler, removeHandler).pipe(map_1.map(function (args) { return isArray_1.isArray(args) ? resultSelector.apply(void 0, args) : resultSelector(args); }));
9211 return new Observable_1.Observable(function (subscriber) {
9212 var handler = function () {
9214 for (var _i = 0; _i < arguments.length; _i++) {
9215 e[_i] = arguments[_i];
9217 return subscriber.next(e.length === 1 ? e[0] : e);
9221 retValue = addHandler(handler);
9224 subscriber.error(err);
9227 if (!isFunction_1.isFunction(removeHandler)) {
9230 return function () { return removeHandler(handler, retValue); };
9233 exports.fromEventPattern = fromEventPattern;
9235 },{"../Observable":32,"../operators/map":112,"../util/isArray":203,"../util/isFunction":206}],55:[function(require,module,exports){
9237 Object.defineProperty(exports, "__esModule", { value: true });
9238 var Observable_1 = require("../Observable");
9239 var Subscription_1 = require("../Subscription");
9240 var iterator_1 = require("../symbol/iterator");
9241 var subscribeToIterable_1 = require("../util/subscribeToIterable");
9242 function fromIterable(input, scheduler) {
9244 throw new Error('Iterable cannot be null');
9247 return new Observable_1.Observable(subscribeToIterable_1.subscribeToIterable(input));
9250 return new Observable_1.Observable(function (subscriber) {
9251 var sub = new Subscription_1.Subscription();
9253 sub.add(function () {
9254 if (iterator && typeof iterator.return === 'function') {
9258 sub.add(scheduler.schedule(function () {
9259 iterator = input[iterator_1.iterator]();
9260 sub.add(scheduler.schedule(function () {
9261 if (subscriber.closed) {
9267 var result = iterator.next();
9268 value = result.value;
9272 subscriber.error(err);
9276 subscriber.complete();
9279 subscriber.next(value);
9288 exports.fromIterable = fromIterable;
9290 },{"../Observable":32,"../Subscription":40,"../symbol/iterator":190,"../util/subscribeToIterable":219}],56:[function(require,module,exports){
9292 Object.defineProperty(exports, "__esModule", { value: true });
9293 var Observable_1 = require("../Observable");
9294 var Subscription_1 = require("../Subscription");
9295 var observable_1 = require("../symbol/observable");
9296 var subscribeToObservable_1 = require("../util/subscribeToObservable");
9297 function fromObservable(input, scheduler) {
9299 return new Observable_1.Observable(subscribeToObservable_1.subscribeToObservable(input));
9302 return new Observable_1.Observable(function (subscriber) {
9303 var sub = new Subscription_1.Subscription();
9304 sub.add(scheduler.schedule(function () {
9305 var observable = input[observable_1.observable]();
9306 sub.add(observable.subscribe({
9307 next: function (value) { sub.add(scheduler.schedule(function () { return subscriber.next(value); })); },
9308 error: function (err) { sub.add(scheduler.schedule(function () { return subscriber.error(err); })); },
9309 complete: function () { sub.add(scheduler.schedule(function () { return subscriber.complete(); })); },
9316 exports.fromObservable = fromObservable;
9318 },{"../Observable":32,"../Subscription":40,"../symbol/observable":191,"../util/subscribeToObservable":220}],57:[function(require,module,exports){
9320 Object.defineProperty(exports, "__esModule", { value: true });
9321 var Observable_1 = require("../Observable");
9322 var Subscription_1 = require("../Subscription");
9323 var subscribeToPromise_1 = require("../util/subscribeToPromise");
9324 function fromPromise(input, scheduler) {
9326 return new Observable_1.Observable(subscribeToPromise_1.subscribeToPromise(input));
9329 return new Observable_1.Observable(function (subscriber) {
9330 var sub = new Subscription_1.Subscription();
9331 sub.add(scheduler.schedule(function () { return input.then(function (value) {
9332 sub.add(scheduler.schedule(function () {
9333 subscriber.next(value);
9334 sub.add(scheduler.schedule(function () { return subscriber.complete(); }));
9337 sub.add(scheduler.schedule(function () { return subscriber.error(err); }));
9343 exports.fromPromise = fromPromise;
9345 },{"../Observable":32,"../Subscription":40,"../util/subscribeToPromise":221}],58:[function(require,module,exports){
9347 Object.defineProperty(exports, "__esModule", { value: true });
9348 var Observable_1 = require("../Observable");
9349 var identity_1 = require("../util/identity");
9350 var isScheduler_1 = require("../util/isScheduler");
9351 function generate(initialStateOrOptions, condition, iterate, resultSelectorOrObservable, scheduler) {
9354 if (arguments.length == 1) {
9355 var options = initialStateOrOptions;
9356 initialState = options.initialState;
9357 condition = options.condition;
9358 iterate = options.iterate;
9359 resultSelector = options.resultSelector || identity_1.identity;
9360 scheduler = options.scheduler;
9362 else if (resultSelectorOrObservable === undefined || isScheduler_1.isScheduler(resultSelectorOrObservable)) {
9363 initialState = initialStateOrOptions;
9364 resultSelector = identity_1.identity;
9365 scheduler = resultSelectorOrObservable;
9368 initialState = initialStateOrOptions;
9369 resultSelector = resultSelectorOrObservable;
9371 return new Observable_1.Observable(function (subscriber) {
9372 var state = initialState;
9374 return scheduler.schedule(dispatch, 0, {
9375 subscriber: subscriber,
9377 condition: condition,
9378 resultSelector: resultSelector,
9384 var conditionResult = void 0;
9386 conditionResult = condition(state);
9389 subscriber.error(err);
9392 if (!conditionResult) {
9393 subscriber.complete();
9399 value = resultSelector(state);
9402 subscriber.error(err);
9405 subscriber.next(value);
9406 if (subscriber.closed) {
9410 state = iterate(state);
9413 subscriber.error(err);
9420 exports.generate = generate;
9421 function dispatch(state) {
9422 var subscriber = state.subscriber, condition = state.condition;
9423 if (subscriber.closed) {
9426 if (state.needIterate) {
9428 state.state = state.iterate(state.state);
9431 subscriber.error(err);
9436 state.needIterate = true;
9439 var conditionResult = void 0;
9441 conditionResult = condition(state.state);
9444 subscriber.error(err);
9447 if (!conditionResult) {
9448 subscriber.complete();
9451 if (subscriber.closed) {
9457 value = state.resultSelector(state.state);
9460 subscriber.error(err);
9463 if (subscriber.closed) {
9466 subscriber.next(value);
9467 if (subscriber.closed) {
9470 return this.schedule(state);
9473 },{"../Observable":32,"../util/identity":202,"../util/isScheduler":213}],59:[function(require,module,exports){
9475 Object.defineProperty(exports, "__esModule", { value: true });
9476 var defer_1 = require("./defer");
9477 var empty_1 = require("./empty");
9478 function iif(condition, trueResult, falseResult) {
9479 if (trueResult === void 0) { trueResult = empty_1.EMPTY; }
9480 if (falseResult === void 0) { falseResult = empty_1.EMPTY; }
9481 return defer_1.defer(function () { return condition() ? trueResult : falseResult; });
9485 },{"./defer":48,"./empty":49}],60:[function(require,module,exports){
9487 Object.defineProperty(exports, "__esModule", { value: true });
9488 var Observable_1 = require("../Observable");
9489 var async_1 = require("../scheduler/async");
9490 var isNumeric_1 = require("../util/isNumeric");
9491 function interval(period, scheduler) {
9492 if (period === void 0) { period = 0; }
9493 if (scheduler === void 0) { scheduler = async_1.async; }
9494 if (!isNumeric_1.isNumeric(period) || period < 0) {
9497 if (!scheduler || typeof scheduler.schedule !== 'function') {
9498 scheduler = async_1.async;
9500 return new Observable_1.Observable(function (subscriber) {
9501 subscriber.add(scheduler.schedule(dispatch, period, { subscriber: subscriber, counter: 0, period: period }));
9505 exports.interval = interval;
9506 function dispatch(state) {
9507 var subscriber = state.subscriber, counter = state.counter, period = state.period;
9508 subscriber.next(counter);
9509 this.schedule({ subscriber: subscriber, counter: counter + 1, period: period }, period);
9512 },{"../Observable":32,"../scheduler/async":188,"../util/isNumeric":209}],61:[function(require,module,exports){
9514 Object.defineProperty(exports, "__esModule", { value: true });
9515 var Observable_1 = require("../Observable");
9516 var isScheduler_1 = require("../util/isScheduler");
9517 var mergeAll_1 = require("../operators/mergeAll");
9518 var fromArray_1 = require("./fromArray");
9520 var observables = [];
9521 for (var _i = 0; _i < arguments.length; _i++) {
9522 observables[_i] = arguments[_i];
9524 var concurrent = Number.POSITIVE_INFINITY;
9525 var scheduler = null;
9526 var last = observables[observables.length - 1];
9527 if (isScheduler_1.isScheduler(last)) {
9528 scheduler = observables.pop();
9529 if (observables.length > 1 && typeof observables[observables.length - 1] === 'number') {
9530 concurrent = observables.pop();
9533 else if (typeof last === 'number') {
9534 concurrent = observables.pop();
9536 if (scheduler === null && observables.length === 1 && observables[0] instanceof Observable_1.Observable) {
9537 return observables[0];
9539 return mergeAll_1.mergeAll(concurrent)(fromArray_1.fromArray(observables, scheduler));
9541 exports.merge = merge;
9543 },{"../Observable":32,"../operators/mergeAll":117,"../util/isScheduler":213,"./fromArray":52}],62:[function(require,module,exports){
9545 Object.defineProperty(exports, "__esModule", { value: true });
9546 var Observable_1 = require("../Observable");
9547 var noop_1 = require("../util/noop");
9548 exports.NEVER = new Observable_1.Observable(noop_1.noop);
9550 return exports.NEVER;
9552 exports.never = never;
9554 },{"../Observable":32,"../util/noop":214}],63:[function(require,module,exports){
9556 Object.defineProperty(exports, "__esModule", { value: true });
9557 var isScheduler_1 = require("../util/isScheduler");
9558 var fromArray_1 = require("./fromArray");
9559 var empty_1 = require("./empty");
9560 var scalar_1 = require("./scalar");
9563 for (var _i = 0; _i < arguments.length; _i++) {
9564 args[_i] = arguments[_i];
9566 var scheduler = args[args.length - 1];
9567 if (isScheduler_1.isScheduler(scheduler)) {
9571 scheduler = undefined;
9573 switch (args.length) {
9575 return empty_1.empty(scheduler);
9577 return scheduler ? fromArray_1.fromArray(args, scheduler) : scalar_1.scalar(args[0]);
9579 return fromArray_1.fromArray(args, scheduler);
9584 },{"../util/isScheduler":213,"./empty":49,"./fromArray":52,"./scalar":68}],64:[function(require,module,exports){
9586 Object.defineProperty(exports, "__esModule", { value: true });
9587 var Observable_1 = require("../Observable");
9588 var from_1 = require("./from");
9589 var isArray_1 = require("../util/isArray");
9590 var empty_1 = require("./empty");
9591 function onErrorResumeNext() {
9593 for (var _i = 0; _i < arguments.length; _i++) {
9594 sources[_i] = arguments[_i];
9596 if (sources.length === 0) {
9597 return empty_1.EMPTY;
9599 var first = sources[0], remainder = sources.slice(1);
9600 if (sources.length === 1 && isArray_1.isArray(first)) {
9601 return onErrorResumeNext.apply(void 0, first);
9603 return new Observable_1.Observable(function (subscriber) {
9604 var subNext = function () { return subscriber.add(onErrorResumeNext.apply(void 0, remainder).subscribe(subscriber)); };
9605 return from_1.from(first).subscribe({
9606 next: function (value) { subscriber.next(value); },
9612 exports.onErrorResumeNext = onErrorResumeNext;
9614 },{"../Observable":32,"../util/isArray":203,"./empty":49,"./from":51}],65:[function(require,module,exports){
9616 Object.defineProperty(exports, "__esModule", { value: true });
9617 var Observable_1 = require("../Observable");
9618 var Subscription_1 = require("../Subscription");
9619 function pairs(obj, scheduler) {
9621 return new Observable_1.Observable(function (subscriber) {
9622 var keys = Object.keys(obj);
9623 for (var i = 0; i < keys.length && !subscriber.closed; i++) {
9625 if (obj.hasOwnProperty(key)) {
9626 subscriber.next([key, obj[key]]);
9629 subscriber.complete();
9633 return new Observable_1.Observable(function (subscriber) {
9634 var keys = Object.keys(obj);
9635 var subscription = new Subscription_1.Subscription();
9636 subscription.add(scheduler.schedule(dispatch, 0, { keys: keys, index: 0, subscriber: subscriber, subscription: subscription, obj: obj }));
9637 return subscription;
9641 exports.pairs = pairs;
9642 function dispatch(state) {
9643 var keys = state.keys, index = state.index, subscriber = state.subscriber, subscription = state.subscription, obj = state.obj;
9644 if (!subscriber.closed) {
9645 if (index < keys.length) {
9646 var key = keys[index];
9647 subscriber.next([key, obj[key]]);
9648 subscription.add(this.schedule({ keys: keys, index: index + 1, subscriber: subscriber, subscription: subscription, obj: obj }));
9651 subscriber.complete();
9655 exports.dispatch = dispatch;
9657 },{"../Observable":32,"../Subscription":40}],66:[function(require,module,exports){
9659 var __extends = (this && this.__extends) || (function () {
9660 var extendStatics = function (d, b) {
9661 extendStatics = Object.setPrototypeOf ||
9662 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
9663 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
9664 return extendStatics(d, b);
9666 return function (d, b) {
9667 extendStatics(d, b);
9668 function __() { this.constructor = d; }
9669 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
9672 Object.defineProperty(exports, "__esModule", { value: true });
9673 var isArray_1 = require("../util/isArray");
9674 var fromArray_1 = require("./fromArray");
9675 var OuterSubscriber_1 = require("../OuterSubscriber");
9676 var subscribeToResult_1 = require("../util/subscribeToResult");
9678 var observables = [];
9679 for (var _i = 0; _i < arguments.length; _i++) {
9680 observables[_i] = arguments[_i];
9682 if (observables.length === 1) {
9683 if (isArray_1.isArray(observables[0])) {
9684 observables = observables[0];
9687 return observables[0];
9690 return fromArray_1.fromArray(observables, undefined).lift(new RaceOperator());
9692 exports.race = race;
9693 var RaceOperator = (function () {
9694 function RaceOperator() {
9696 RaceOperator.prototype.call = function (subscriber, source) {
9697 return source.subscribe(new RaceSubscriber(subscriber));
9699 return RaceOperator;
9701 exports.RaceOperator = RaceOperator;
9702 var RaceSubscriber = (function (_super) {
9703 __extends(RaceSubscriber, _super);
9704 function RaceSubscriber(destination) {
9705 var _this = _super.call(this, destination) || this;
9706 _this.hasFirst = false;
9707 _this.observables = [];
9708 _this.subscriptions = [];
9711 RaceSubscriber.prototype._next = function (observable) {
9712 this.observables.push(observable);
9714 RaceSubscriber.prototype._complete = function () {
9715 var observables = this.observables;
9716 var len = observables.length;
9718 this.destination.complete();
9721 for (var i = 0; i < len && !this.hasFirst; i++) {
9722 var observable = observables[i];
9723 var subscription = subscribeToResult_1.subscribeToResult(this, observable, observable, i);
9724 if (this.subscriptions) {
9725 this.subscriptions.push(subscription);
9727 this.add(subscription);
9729 this.observables = null;
9732 RaceSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
9733 if (!this.hasFirst) {
9734 this.hasFirst = true;
9735 for (var i = 0; i < this.subscriptions.length; i++) {
9736 if (i !== outerIndex) {
9737 var subscription = this.subscriptions[i];
9738 subscription.unsubscribe();
9739 this.remove(subscription);
9742 this.subscriptions = null;
9744 this.destination.next(innerValue);
9746 return RaceSubscriber;
9747 }(OuterSubscriber_1.OuterSubscriber));
9748 exports.RaceSubscriber = RaceSubscriber;
9750 },{"../OuterSubscriber":34,"../util/isArray":203,"../util/subscribeToResult":222,"./fromArray":52}],67:[function(require,module,exports){
9752 Object.defineProperty(exports, "__esModule", { value: true });
9753 var Observable_1 = require("../Observable");
9754 function range(start, count, scheduler) {
9755 if (start === void 0) { start = 0; }
9756 if (count === void 0) { count = 0; }
9757 return new Observable_1.Observable(function (subscriber) {
9759 var current = start;
9761 return scheduler.schedule(dispatch, 0, {
9762 index: index, count: count, start: start, subscriber: subscriber
9767 if (index++ >= count) {
9768 subscriber.complete();
9771 subscriber.next(current++);
9772 if (subscriber.closed) {
9780 exports.range = range;
9781 function dispatch(state) {
9782 var start = state.start, index = state.index, count = state.count, subscriber = state.subscriber;
9783 if (index >= count) {
9784 subscriber.complete();
9787 subscriber.next(start);
9788 if (subscriber.closed) {
9791 state.index = index + 1;
9792 state.start = start + 1;
9793 this.schedule(state);
9795 exports.dispatch = dispatch;
9797 },{"../Observable":32}],68:[function(require,module,exports){
9799 Object.defineProperty(exports, "__esModule", { value: true });
9800 var Observable_1 = require("../Observable");
9801 function scalar(value) {
9802 var result = new Observable_1.Observable(function (subscriber) {
9803 subscriber.next(value);
9804 subscriber.complete();
9806 result._isScalar = true;
9807 result.value = value;
9810 exports.scalar = scalar;
9812 },{"../Observable":32}],69:[function(require,module,exports){
9814 Object.defineProperty(exports, "__esModule", { value: true });
9815 var Observable_1 = require("../Observable");
9816 function throwError(error, scheduler) {
9818 return new Observable_1.Observable(function (subscriber) { return subscriber.error(error); });
9821 return new Observable_1.Observable(function (subscriber) { return scheduler.schedule(dispatch, 0, { error: error, subscriber: subscriber }); });
9824 exports.throwError = throwError;
9825 function dispatch(_a) {
9826 var error = _a.error, subscriber = _a.subscriber;
9827 subscriber.error(error);
9830 },{"../Observable":32}],70:[function(require,module,exports){
9832 Object.defineProperty(exports, "__esModule", { value: true });
9833 var Observable_1 = require("../Observable");
9834 var async_1 = require("../scheduler/async");
9835 var isNumeric_1 = require("../util/isNumeric");
9836 var isScheduler_1 = require("../util/isScheduler");
9837 function timer(dueTime, periodOrScheduler, scheduler) {
9838 if (dueTime === void 0) { dueTime = 0; }
9840 if (isNumeric_1.isNumeric(periodOrScheduler)) {
9841 period = Number(periodOrScheduler) < 1 && 1 || Number(periodOrScheduler);
9843 else if (isScheduler_1.isScheduler(periodOrScheduler)) {
9844 scheduler = periodOrScheduler;
9846 if (!isScheduler_1.isScheduler(scheduler)) {
9847 scheduler = async_1.async;
9849 return new Observable_1.Observable(function (subscriber) {
9850 var due = isNumeric_1.isNumeric(dueTime)
9852 : (+dueTime - scheduler.now());
9853 return scheduler.schedule(dispatch, due, {
9854 index: 0, period: period, subscriber: subscriber
9858 exports.timer = timer;
9859 function dispatch(state) {
9860 var index = state.index, period = state.period, subscriber = state.subscriber;
9861 subscriber.next(index);
9862 if (subscriber.closed) {
9865 else if (period === -1) {
9866 return subscriber.complete();
9868 state.index = index + 1;
9869 this.schedule(state, period);
9872 },{"../Observable":32,"../scheduler/async":188,"../util/isNumeric":209,"../util/isScheduler":213}],71:[function(require,module,exports){
9874 Object.defineProperty(exports, "__esModule", { value: true });
9875 var Observable_1 = require("../Observable");
9876 var from_1 = require("./from");
9877 var empty_1 = require("./empty");
9878 function using(resourceFactory, observableFactory) {
9879 return new Observable_1.Observable(function (subscriber) {
9882 resource = resourceFactory();
9885 subscriber.error(err);
9890 result = observableFactory(resource);
9893 subscriber.error(err);
9896 var source = result ? from_1.from(result) : empty_1.EMPTY;
9897 var subscription = source.subscribe(subscriber);
9898 return function () {
9899 subscription.unsubscribe();
9901 resource.unsubscribe();
9906 exports.using = using;
9908 },{"../Observable":32,"./empty":49,"./from":51}],72:[function(require,module,exports){
9910 var __extends = (this && this.__extends) || (function () {
9911 var extendStatics = function (d, b) {
9912 extendStatics = Object.setPrototypeOf ||
9913 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
9914 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
9915 return extendStatics(d, b);
9917 return function (d, b) {
9918 extendStatics(d, b);
9919 function __() { this.constructor = d; }
9920 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
9923 Object.defineProperty(exports, "__esModule", { value: true });
9924 var fromArray_1 = require("./fromArray");
9925 var isArray_1 = require("../util/isArray");
9926 var Subscriber_1 = require("../Subscriber");
9927 var OuterSubscriber_1 = require("../OuterSubscriber");
9928 var subscribeToResult_1 = require("../util/subscribeToResult");
9929 var iterator_1 = require("../../internal/symbol/iterator");
9931 var observables = [];
9932 for (var _i = 0; _i < arguments.length; _i++) {
9933 observables[_i] = arguments[_i];
9935 var resultSelector = observables[observables.length - 1];
9936 if (typeof resultSelector === 'function') {
9939 return fromArray_1.fromArray(observables, undefined).lift(new ZipOperator(resultSelector));
9942 var ZipOperator = (function () {
9943 function ZipOperator(resultSelector) {
9944 this.resultSelector = resultSelector;
9946 ZipOperator.prototype.call = function (subscriber, source) {
9947 return source.subscribe(new ZipSubscriber(subscriber, this.resultSelector));
9951 exports.ZipOperator = ZipOperator;
9952 var ZipSubscriber = (function (_super) {
9953 __extends(ZipSubscriber, _super);
9954 function ZipSubscriber(destination, resultSelector, values) {
9955 if (values === void 0) { values = Object.create(null); }
9956 var _this = _super.call(this, destination) || this;
9957 _this.iterators = [];
9959 _this.resultSelector = (typeof resultSelector === 'function') ? resultSelector : null;
9960 _this.values = values;
9963 ZipSubscriber.prototype._next = function (value) {
9964 var iterators = this.iterators;
9965 if (isArray_1.isArray(value)) {
9966 iterators.push(new StaticArrayIterator(value));
9968 else if (typeof value[iterator_1.iterator] === 'function') {
9969 iterators.push(new StaticIterator(value[iterator_1.iterator]()));
9972 iterators.push(new ZipBufferIterator(this.destination, this, value));
9975 ZipSubscriber.prototype._complete = function () {
9976 var iterators = this.iterators;
9977 var len = iterators.length;
9980 this.destination.complete();
9984 for (var i = 0; i < len; i++) {
9985 var iterator = iterators[i];
9986 if (iterator.stillUnsubscribed) {
9987 var destination = this.destination;
9988 destination.add(iterator.subscribe(iterator, i));
9995 ZipSubscriber.prototype.notifyInactive = function () {
9997 if (this.active === 0) {
9998 this.destination.complete();
10001 ZipSubscriber.prototype.checkIterators = function () {
10002 var iterators = this.iterators;
10003 var len = iterators.length;
10004 var destination = this.destination;
10005 for (var i = 0; i < len; i++) {
10006 var iterator = iterators[i];
10007 if (typeof iterator.hasValue === 'function' && !iterator.hasValue()) {
10011 var shouldComplete = false;
10013 for (var i = 0; i < len; i++) {
10014 var iterator = iterators[i];
10015 var result = iterator.next();
10016 if (iterator.hasCompleted()) {
10017 shouldComplete = true;
10020 destination.complete();
10023 args.push(result.value);
10025 if (this.resultSelector) {
10026 this._tryresultSelector(args);
10029 destination.next(args);
10031 if (shouldComplete) {
10032 destination.complete();
10035 ZipSubscriber.prototype._tryresultSelector = function (args) {
10038 result = this.resultSelector.apply(this, args);
10041 this.destination.error(err);
10044 this.destination.next(result);
10046 return ZipSubscriber;
10047 }(Subscriber_1.Subscriber));
10048 exports.ZipSubscriber = ZipSubscriber;
10049 var StaticIterator = (function () {
10050 function StaticIterator(iterator) {
10051 this.iterator = iterator;
10052 this.nextResult = iterator.next();
10054 StaticIterator.prototype.hasValue = function () {
10057 StaticIterator.prototype.next = function () {
10058 var result = this.nextResult;
10059 this.nextResult = this.iterator.next();
10062 StaticIterator.prototype.hasCompleted = function () {
10063 var nextResult = this.nextResult;
10064 return nextResult && nextResult.done;
10066 return StaticIterator;
10068 var StaticArrayIterator = (function () {
10069 function StaticArrayIterator(array) {
10070 this.array = array;
10073 this.length = array.length;
10075 StaticArrayIterator.prototype[iterator_1.iterator] = function () {
10078 StaticArrayIterator.prototype.next = function (value) {
10079 var i = this.index++;
10080 var array = this.array;
10081 return i < this.length ? { value: array[i], done: false } : { value: null, done: true };
10083 StaticArrayIterator.prototype.hasValue = function () {
10084 return this.array.length > this.index;
10086 StaticArrayIterator.prototype.hasCompleted = function () {
10087 return this.array.length === this.index;
10089 return StaticArrayIterator;
10091 var ZipBufferIterator = (function (_super) {
10092 __extends(ZipBufferIterator, _super);
10093 function ZipBufferIterator(destination, parent, observable) {
10094 var _this = _super.call(this, destination) || this;
10095 _this.parent = parent;
10096 _this.observable = observable;
10097 _this.stillUnsubscribed = true;
10099 _this.isComplete = false;
10102 ZipBufferIterator.prototype[iterator_1.iterator] = function () {
10105 ZipBufferIterator.prototype.next = function () {
10106 var buffer = this.buffer;
10107 if (buffer.length === 0 && this.isComplete) {
10108 return { value: null, done: true };
10111 return { value: buffer.shift(), done: false };
10114 ZipBufferIterator.prototype.hasValue = function () {
10115 return this.buffer.length > 0;
10117 ZipBufferIterator.prototype.hasCompleted = function () {
10118 return this.buffer.length === 0 && this.isComplete;
10120 ZipBufferIterator.prototype.notifyComplete = function () {
10121 if (this.buffer.length > 0) {
10122 this.isComplete = true;
10123 this.parent.notifyInactive();
10126 this.destination.complete();
10129 ZipBufferIterator.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
10130 this.buffer.push(innerValue);
10131 this.parent.checkIterators();
10133 ZipBufferIterator.prototype.subscribe = function (value, index) {
10134 return subscribeToResult_1.subscribeToResult(this, this.observable, this, index);
10136 return ZipBufferIterator;
10137 }(OuterSubscriber_1.OuterSubscriber));
10139 },{"../../internal/symbol/iterator":190,"../OuterSubscriber":34,"../Subscriber":39,"../util/isArray":203,"../util/subscribeToResult":222,"./fromArray":52}],73:[function(require,module,exports){
10141 var __extends = (this && this.__extends) || (function () {
10142 var extendStatics = function (d, b) {
10143 extendStatics = Object.setPrototypeOf ||
10144 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
10145 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
10146 return extendStatics(d, b);
10148 return function (d, b) {
10149 extendStatics(d, b);
10150 function __() { this.constructor = d; }
10151 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
10154 Object.defineProperty(exports, "__esModule", { value: true });
10155 var tryCatch_1 = require("../util/tryCatch");
10156 var errorObject_1 = require("../util/errorObject");
10157 var OuterSubscriber_1 = require("../OuterSubscriber");
10158 var subscribeToResult_1 = require("../util/subscribeToResult");
10159 function audit(durationSelector) {
10160 return function auditOperatorFunction(source) {
10161 return source.lift(new AuditOperator(durationSelector));
10164 exports.audit = audit;
10165 var AuditOperator = (function () {
10166 function AuditOperator(durationSelector) {
10167 this.durationSelector = durationSelector;
10169 AuditOperator.prototype.call = function (subscriber, source) {
10170 return source.subscribe(new AuditSubscriber(subscriber, this.durationSelector));
10172 return AuditOperator;
10174 var AuditSubscriber = (function (_super) {
10175 __extends(AuditSubscriber, _super);
10176 function AuditSubscriber(destination, durationSelector) {
10177 var _this = _super.call(this, destination) || this;
10178 _this.durationSelector = durationSelector;
10179 _this.hasValue = false;
10182 AuditSubscriber.prototype._next = function (value) {
10183 this.value = value;
10184 this.hasValue = true;
10185 if (!this.throttled) {
10186 var duration = tryCatch_1.tryCatch(this.durationSelector)(value);
10187 if (duration === errorObject_1.errorObject) {
10188 this.destination.error(errorObject_1.errorObject.e);
10191 var innerSubscription = subscribeToResult_1.subscribeToResult(this, duration);
10192 if (!innerSubscription || innerSubscription.closed) {
10193 this.clearThrottle();
10196 this.add(this.throttled = innerSubscription);
10201 AuditSubscriber.prototype.clearThrottle = function () {
10202 var _a = this, value = _a.value, hasValue = _a.hasValue, throttled = _a.throttled;
10204 this.remove(throttled);
10205 this.throttled = null;
10206 throttled.unsubscribe();
10210 this.hasValue = false;
10211 this.destination.next(value);
10214 AuditSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex) {
10215 this.clearThrottle();
10217 AuditSubscriber.prototype.notifyComplete = function () {
10218 this.clearThrottle();
10220 return AuditSubscriber;
10221 }(OuterSubscriber_1.OuterSubscriber));
10223 },{"../OuterSubscriber":34,"../util/errorObject":200,"../util/subscribeToResult":222,"../util/tryCatch":224}],74:[function(require,module,exports){
10225 Object.defineProperty(exports, "__esModule", { value: true });
10226 var async_1 = require("../scheduler/async");
10227 var audit_1 = require("./audit");
10228 var timer_1 = require("../observable/timer");
10229 function auditTime(duration, scheduler) {
10230 if (scheduler === void 0) { scheduler = async_1.async; }
10231 return audit_1.audit(function () { return timer_1.timer(duration, scheduler); });
10233 exports.auditTime = auditTime;
10235 },{"../observable/timer":70,"../scheduler/async":188,"./audit":73}],75:[function(require,module,exports){
10237 var __extends = (this && this.__extends) || (function () {
10238 var extendStatics = function (d, b) {
10239 extendStatics = Object.setPrototypeOf ||
10240 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
10241 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
10242 return extendStatics(d, b);
10244 return function (d, b) {
10245 extendStatics(d, b);
10246 function __() { this.constructor = d; }
10247 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
10250 Object.defineProperty(exports, "__esModule", { value: true });
10251 var OuterSubscriber_1 = require("../OuterSubscriber");
10252 var subscribeToResult_1 = require("../util/subscribeToResult");
10253 function buffer(closingNotifier) {
10254 return function bufferOperatorFunction(source) {
10255 return source.lift(new BufferOperator(closingNotifier));
10258 exports.buffer = buffer;
10259 var BufferOperator = (function () {
10260 function BufferOperator(closingNotifier) {
10261 this.closingNotifier = closingNotifier;
10263 BufferOperator.prototype.call = function (subscriber, source) {
10264 return source.subscribe(new BufferSubscriber(subscriber, this.closingNotifier));
10266 return BufferOperator;
10268 var BufferSubscriber = (function (_super) {
10269 __extends(BufferSubscriber, _super);
10270 function BufferSubscriber(destination, closingNotifier) {
10271 var _this = _super.call(this, destination) || this;
10273 _this.add(subscribeToResult_1.subscribeToResult(_this, closingNotifier));
10276 BufferSubscriber.prototype._next = function (value) {
10277 this.buffer.push(value);
10279 BufferSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
10280 var buffer = this.buffer;
10282 this.destination.next(buffer);
10284 return BufferSubscriber;
10285 }(OuterSubscriber_1.OuterSubscriber));
10287 },{"../OuterSubscriber":34,"../util/subscribeToResult":222}],76:[function(require,module,exports){
10289 var __extends = (this && this.__extends) || (function () {
10290 var extendStatics = function (d, b) {
10291 extendStatics = Object.setPrototypeOf ||
10292 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
10293 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
10294 return extendStatics(d, b);
10296 return function (d, b) {
10297 extendStatics(d, b);
10298 function __() { this.constructor = d; }
10299 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
10302 Object.defineProperty(exports, "__esModule", { value: true });
10303 var Subscriber_1 = require("../Subscriber");
10304 function bufferCount(bufferSize, startBufferEvery) {
10305 if (startBufferEvery === void 0) { startBufferEvery = null; }
10306 return function bufferCountOperatorFunction(source) {
10307 return source.lift(new BufferCountOperator(bufferSize, startBufferEvery));
10310 exports.bufferCount = bufferCount;
10311 var BufferCountOperator = (function () {
10312 function BufferCountOperator(bufferSize, startBufferEvery) {
10313 this.bufferSize = bufferSize;
10314 this.startBufferEvery = startBufferEvery;
10315 if (!startBufferEvery || bufferSize === startBufferEvery) {
10316 this.subscriberClass = BufferCountSubscriber;
10319 this.subscriberClass = BufferSkipCountSubscriber;
10322 BufferCountOperator.prototype.call = function (subscriber, source) {
10323 return source.subscribe(new this.subscriberClass(subscriber, this.bufferSize, this.startBufferEvery));
10325 return BufferCountOperator;
10327 var BufferCountSubscriber = (function (_super) {
10328 __extends(BufferCountSubscriber, _super);
10329 function BufferCountSubscriber(destination, bufferSize) {
10330 var _this = _super.call(this, destination) || this;
10331 _this.bufferSize = bufferSize;
10335 BufferCountSubscriber.prototype._next = function (value) {
10336 var buffer = this.buffer;
10337 buffer.push(value);
10338 if (buffer.length == this.bufferSize) {
10339 this.destination.next(buffer);
10343 BufferCountSubscriber.prototype._complete = function () {
10344 var buffer = this.buffer;
10345 if (buffer.length > 0) {
10346 this.destination.next(buffer);
10348 _super.prototype._complete.call(this);
10350 return BufferCountSubscriber;
10351 }(Subscriber_1.Subscriber));
10352 var BufferSkipCountSubscriber = (function (_super) {
10353 __extends(BufferSkipCountSubscriber, _super);
10354 function BufferSkipCountSubscriber(destination, bufferSize, startBufferEvery) {
10355 var _this = _super.call(this, destination) || this;
10356 _this.bufferSize = bufferSize;
10357 _this.startBufferEvery = startBufferEvery;
10358 _this.buffers = [];
10362 BufferSkipCountSubscriber.prototype._next = function (value) {
10363 var _a = this, bufferSize = _a.bufferSize, startBufferEvery = _a.startBufferEvery, buffers = _a.buffers, count = _a.count;
10365 if (count % startBufferEvery === 0) {
10368 for (var i = buffers.length; i--;) {
10369 var buffer = buffers[i];
10370 buffer.push(value);
10371 if (buffer.length === bufferSize) {
10372 buffers.splice(i, 1);
10373 this.destination.next(buffer);
10377 BufferSkipCountSubscriber.prototype._complete = function () {
10378 var _a = this, buffers = _a.buffers, destination = _a.destination;
10379 while (buffers.length > 0) {
10380 var buffer = buffers.shift();
10381 if (buffer.length > 0) {
10382 destination.next(buffer);
10385 _super.prototype._complete.call(this);
10387 return BufferSkipCountSubscriber;
10388 }(Subscriber_1.Subscriber));
10390 },{"../Subscriber":39}],77:[function(require,module,exports){
10392 var __extends = (this && this.__extends) || (function () {
10393 var extendStatics = function (d, b) {
10394 extendStatics = Object.setPrototypeOf ||
10395 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
10396 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
10397 return extendStatics(d, b);
10399 return function (d, b) {
10400 extendStatics(d, b);
10401 function __() { this.constructor = d; }
10402 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
10405 Object.defineProperty(exports, "__esModule", { value: true });
10406 var async_1 = require("../scheduler/async");
10407 var Subscriber_1 = require("../Subscriber");
10408 var isScheduler_1 = require("../util/isScheduler");
10409 function bufferTime(bufferTimeSpan) {
10410 var length = arguments.length;
10411 var scheduler = async_1.async;
10412 if (isScheduler_1.isScheduler(arguments[arguments.length - 1])) {
10413 scheduler = arguments[arguments.length - 1];
10416 var bufferCreationInterval = null;
10418 bufferCreationInterval = arguments[1];
10420 var maxBufferSize = Number.POSITIVE_INFINITY;
10422 maxBufferSize = arguments[2];
10424 return function bufferTimeOperatorFunction(source) {
10425 return source.lift(new BufferTimeOperator(bufferTimeSpan, bufferCreationInterval, maxBufferSize, scheduler));
10428 exports.bufferTime = bufferTime;
10429 var BufferTimeOperator = (function () {
10430 function BufferTimeOperator(bufferTimeSpan, bufferCreationInterval, maxBufferSize, scheduler) {
10431 this.bufferTimeSpan = bufferTimeSpan;
10432 this.bufferCreationInterval = bufferCreationInterval;
10433 this.maxBufferSize = maxBufferSize;
10434 this.scheduler = scheduler;
10436 BufferTimeOperator.prototype.call = function (subscriber, source) {
10437 return source.subscribe(new BufferTimeSubscriber(subscriber, this.bufferTimeSpan, this.bufferCreationInterval, this.maxBufferSize, this.scheduler));
10439 return BufferTimeOperator;
10441 var Context = (function () {
10442 function Context() {
10447 var BufferTimeSubscriber = (function (_super) {
10448 __extends(BufferTimeSubscriber, _super);
10449 function BufferTimeSubscriber(destination, bufferTimeSpan, bufferCreationInterval, maxBufferSize, scheduler) {
10450 var _this = _super.call(this, destination) || this;
10451 _this.bufferTimeSpan = bufferTimeSpan;
10452 _this.bufferCreationInterval = bufferCreationInterval;
10453 _this.maxBufferSize = maxBufferSize;
10454 _this.scheduler = scheduler;
10455 _this.contexts = [];
10456 var context = _this.openContext();
10457 _this.timespanOnly = bufferCreationInterval == null || bufferCreationInterval < 0;
10458 if (_this.timespanOnly) {
10459 var timeSpanOnlyState = { subscriber: _this, context: context, bufferTimeSpan: bufferTimeSpan };
10460 _this.add(context.closeAction = scheduler.schedule(dispatchBufferTimeSpanOnly, bufferTimeSpan, timeSpanOnlyState));
10463 var closeState = { subscriber: _this, context: context };
10464 var creationState = { bufferTimeSpan: bufferTimeSpan, bufferCreationInterval: bufferCreationInterval, subscriber: _this, scheduler: scheduler };
10465 _this.add(context.closeAction = scheduler.schedule(dispatchBufferClose, bufferTimeSpan, closeState));
10466 _this.add(scheduler.schedule(dispatchBufferCreation, bufferCreationInterval, creationState));
10470 BufferTimeSubscriber.prototype._next = function (value) {
10471 var contexts = this.contexts;
10472 var len = contexts.length;
10473 var filledBufferContext;
10474 for (var i = 0; i < len; i++) {
10475 var context_1 = contexts[i];
10476 var buffer = context_1.buffer;
10477 buffer.push(value);
10478 if (buffer.length == this.maxBufferSize) {
10479 filledBufferContext = context_1;
10482 if (filledBufferContext) {
10483 this.onBufferFull(filledBufferContext);
10486 BufferTimeSubscriber.prototype._error = function (err) {
10487 this.contexts.length = 0;
10488 _super.prototype._error.call(this, err);
10490 BufferTimeSubscriber.prototype._complete = function () {
10491 var _a = this, contexts = _a.contexts, destination = _a.destination;
10492 while (contexts.length > 0) {
10493 var context_2 = contexts.shift();
10494 destination.next(context_2.buffer);
10496 _super.prototype._complete.call(this);
10498 BufferTimeSubscriber.prototype._unsubscribe = function () {
10499 this.contexts = null;
10501 BufferTimeSubscriber.prototype.onBufferFull = function (context) {
10502 this.closeContext(context);
10503 var closeAction = context.closeAction;
10504 closeAction.unsubscribe();
10505 this.remove(closeAction);
10506 if (!this.closed && this.timespanOnly) {
10507 context = this.openContext();
10508 var bufferTimeSpan = this.bufferTimeSpan;
10509 var timeSpanOnlyState = { subscriber: this, context: context, bufferTimeSpan: bufferTimeSpan };
10510 this.add(context.closeAction = this.scheduler.schedule(dispatchBufferTimeSpanOnly, bufferTimeSpan, timeSpanOnlyState));
10513 BufferTimeSubscriber.prototype.openContext = function () {
10514 var context = new Context();
10515 this.contexts.push(context);
10518 BufferTimeSubscriber.prototype.closeContext = function (context) {
10519 this.destination.next(context.buffer);
10520 var contexts = this.contexts;
10521 var spliceIndex = contexts ? contexts.indexOf(context) : -1;
10522 if (spliceIndex >= 0) {
10523 contexts.splice(contexts.indexOf(context), 1);
10526 return BufferTimeSubscriber;
10527 }(Subscriber_1.Subscriber));
10528 function dispatchBufferTimeSpanOnly(state) {
10529 var subscriber = state.subscriber;
10530 var prevContext = state.context;
10532 subscriber.closeContext(prevContext);
10534 if (!subscriber.closed) {
10535 state.context = subscriber.openContext();
10536 state.context.closeAction = this.schedule(state, state.bufferTimeSpan);
10539 function dispatchBufferCreation(state) {
10540 var bufferCreationInterval = state.bufferCreationInterval, bufferTimeSpan = state.bufferTimeSpan, subscriber = state.subscriber, scheduler = state.scheduler;
10541 var context = subscriber.openContext();
10543 if (!subscriber.closed) {
10544 subscriber.add(context.closeAction = scheduler.schedule(dispatchBufferClose, bufferTimeSpan, { subscriber: subscriber, context: context }));
10545 action.schedule(state, bufferCreationInterval);
10548 function dispatchBufferClose(arg) {
10549 var subscriber = arg.subscriber, context = arg.context;
10550 subscriber.closeContext(context);
10553 },{"../Subscriber":39,"../scheduler/async":188,"../util/isScheduler":213}],78:[function(require,module,exports){
10555 var __extends = (this && this.__extends) || (function () {
10556 var extendStatics = function (d, b) {
10557 extendStatics = Object.setPrototypeOf ||
10558 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
10559 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
10560 return extendStatics(d, b);
10562 return function (d, b) {
10563 extendStatics(d, b);
10564 function __() { this.constructor = d; }
10565 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
10568 Object.defineProperty(exports, "__esModule", { value: true });
10569 var Subscription_1 = require("../Subscription");
10570 var subscribeToResult_1 = require("../util/subscribeToResult");
10571 var OuterSubscriber_1 = require("../OuterSubscriber");
10572 function bufferToggle(openings, closingSelector) {
10573 return function bufferToggleOperatorFunction(source) {
10574 return source.lift(new BufferToggleOperator(openings, closingSelector));
10577 exports.bufferToggle = bufferToggle;
10578 var BufferToggleOperator = (function () {
10579 function BufferToggleOperator(openings, closingSelector) {
10580 this.openings = openings;
10581 this.closingSelector = closingSelector;
10583 BufferToggleOperator.prototype.call = function (subscriber, source) {
10584 return source.subscribe(new BufferToggleSubscriber(subscriber, this.openings, this.closingSelector));
10586 return BufferToggleOperator;
10588 var BufferToggleSubscriber = (function (_super) {
10589 __extends(BufferToggleSubscriber, _super);
10590 function BufferToggleSubscriber(destination, openings, closingSelector) {
10591 var _this = _super.call(this, destination) || this;
10592 _this.openings = openings;
10593 _this.closingSelector = closingSelector;
10594 _this.contexts = [];
10595 _this.add(subscribeToResult_1.subscribeToResult(_this, openings));
10598 BufferToggleSubscriber.prototype._next = function (value) {
10599 var contexts = this.contexts;
10600 var len = contexts.length;
10601 for (var i = 0; i < len; i++) {
10602 contexts[i].buffer.push(value);
10605 BufferToggleSubscriber.prototype._error = function (err) {
10606 var contexts = this.contexts;
10607 while (contexts.length > 0) {
10608 var context_1 = contexts.shift();
10609 context_1.subscription.unsubscribe();
10610 context_1.buffer = null;
10611 context_1.subscription = null;
10613 this.contexts = null;
10614 _super.prototype._error.call(this, err);
10616 BufferToggleSubscriber.prototype._complete = function () {
10617 var contexts = this.contexts;
10618 while (contexts.length > 0) {
10619 var context_2 = contexts.shift();
10620 this.destination.next(context_2.buffer);
10621 context_2.subscription.unsubscribe();
10622 context_2.buffer = null;
10623 context_2.subscription = null;
10625 this.contexts = null;
10626 _super.prototype._complete.call(this);
10628 BufferToggleSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
10629 outerValue ? this.closeBuffer(outerValue) : this.openBuffer(innerValue);
10631 BufferToggleSubscriber.prototype.notifyComplete = function (innerSub) {
10632 this.closeBuffer(innerSub.context);
10634 BufferToggleSubscriber.prototype.openBuffer = function (value) {
10636 var closingSelector = this.closingSelector;
10637 var closingNotifier = closingSelector.call(this, value);
10638 if (closingNotifier) {
10639 this.trySubscribe(closingNotifier);
10646 BufferToggleSubscriber.prototype.closeBuffer = function (context) {
10647 var contexts = this.contexts;
10648 if (contexts && context) {
10649 var buffer = context.buffer, subscription = context.subscription;
10650 this.destination.next(buffer);
10651 contexts.splice(contexts.indexOf(context), 1);
10652 this.remove(subscription);
10653 subscription.unsubscribe();
10656 BufferToggleSubscriber.prototype.trySubscribe = function (closingNotifier) {
10657 var contexts = this.contexts;
10659 var subscription = new Subscription_1.Subscription();
10660 var context = { buffer: buffer, subscription: subscription };
10661 contexts.push(context);
10662 var innerSubscription = subscribeToResult_1.subscribeToResult(this, closingNotifier, context);
10663 if (!innerSubscription || innerSubscription.closed) {
10664 this.closeBuffer(context);
10667 innerSubscription.context = context;
10668 this.add(innerSubscription);
10669 subscription.add(innerSubscription);
10672 return BufferToggleSubscriber;
10673 }(OuterSubscriber_1.OuterSubscriber));
10675 },{"../OuterSubscriber":34,"../Subscription":40,"../util/subscribeToResult":222}],79:[function(require,module,exports){
10677 var __extends = (this && this.__extends) || (function () {
10678 var extendStatics = function (d, b) {
10679 extendStatics = Object.setPrototypeOf ||
10680 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
10681 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
10682 return extendStatics(d, b);
10684 return function (d, b) {
10685 extendStatics(d, b);
10686 function __() { this.constructor = d; }
10687 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
10690 Object.defineProperty(exports, "__esModule", { value: true });
10691 var Subscription_1 = require("../Subscription");
10692 var tryCatch_1 = require("../util/tryCatch");
10693 var errorObject_1 = require("../util/errorObject");
10694 var OuterSubscriber_1 = require("../OuterSubscriber");
10695 var subscribeToResult_1 = require("../util/subscribeToResult");
10696 function bufferWhen(closingSelector) {
10697 return function (source) {
10698 return source.lift(new BufferWhenOperator(closingSelector));
10701 exports.bufferWhen = bufferWhen;
10702 var BufferWhenOperator = (function () {
10703 function BufferWhenOperator(closingSelector) {
10704 this.closingSelector = closingSelector;
10706 BufferWhenOperator.prototype.call = function (subscriber, source) {
10707 return source.subscribe(new BufferWhenSubscriber(subscriber, this.closingSelector));
10709 return BufferWhenOperator;
10711 var BufferWhenSubscriber = (function (_super) {
10712 __extends(BufferWhenSubscriber, _super);
10713 function BufferWhenSubscriber(destination, closingSelector) {
10714 var _this = _super.call(this, destination) || this;
10715 _this.closingSelector = closingSelector;
10716 _this.subscribing = false;
10717 _this.openBuffer();
10720 BufferWhenSubscriber.prototype._next = function (value) {
10721 this.buffer.push(value);
10723 BufferWhenSubscriber.prototype._complete = function () {
10724 var buffer = this.buffer;
10726 this.destination.next(buffer);
10728 _super.prototype._complete.call(this);
10730 BufferWhenSubscriber.prototype._unsubscribe = function () {
10731 this.buffer = null;
10732 this.subscribing = false;
10734 BufferWhenSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
10737 BufferWhenSubscriber.prototype.notifyComplete = function () {
10738 if (this.subscribing) {
10745 BufferWhenSubscriber.prototype.openBuffer = function () {
10746 var closingSubscription = this.closingSubscription;
10747 if (closingSubscription) {
10748 this.remove(closingSubscription);
10749 closingSubscription.unsubscribe();
10751 var buffer = this.buffer;
10753 this.destination.next(buffer);
10756 var closingNotifier = tryCatch_1.tryCatch(this.closingSelector)();
10757 if (closingNotifier === errorObject_1.errorObject) {
10758 this.error(errorObject_1.errorObject.e);
10761 closingSubscription = new Subscription_1.Subscription();
10762 this.closingSubscription = closingSubscription;
10763 this.add(closingSubscription);
10764 this.subscribing = true;
10765 closingSubscription.add(subscribeToResult_1.subscribeToResult(this, closingNotifier));
10766 this.subscribing = false;
10769 return BufferWhenSubscriber;
10770 }(OuterSubscriber_1.OuterSubscriber));
10772 },{"../OuterSubscriber":34,"../Subscription":40,"../util/errorObject":200,"../util/subscribeToResult":222,"../util/tryCatch":224}],80:[function(require,module,exports){
10774 var __extends = (this && this.__extends) || (function () {
10775 var extendStatics = function (d, b) {
10776 extendStatics = Object.setPrototypeOf ||
10777 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
10778 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
10779 return extendStatics(d, b);
10781 return function (d, b) {
10782 extendStatics(d, b);
10783 function __() { this.constructor = d; }
10784 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
10787 Object.defineProperty(exports, "__esModule", { value: true });
10788 var OuterSubscriber_1 = require("../OuterSubscriber");
10789 var InnerSubscriber_1 = require("../InnerSubscriber");
10790 var subscribeToResult_1 = require("../util/subscribeToResult");
10791 function catchError(selector) {
10792 return function catchErrorOperatorFunction(source) {
10793 var operator = new CatchOperator(selector);
10794 var caught = source.lift(operator);
10795 return (operator.caught = caught);
10798 exports.catchError = catchError;
10799 var CatchOperator = (function () {
10800 function CatchOperator(selector) {
10801 this.selector = selector;
10803 CatchOperator.prototype.call = function (subscriber, source) {
10804 return source.subscribe(new CatchSubscriber(subscriber, this.selector, this.caught));
10806 return CatchOperator;
10808 var CatchSubscriber = (function (_super) {
10809 __extends(CatchSubscriber, _super);
10810 function CatchSubscriber(destination, selector, caught) {
10811 var _this = _super.call(this, destination) || this;
10812 _this.selector = selector;
10813 _this.caught = caught;
10816 CatchSubscriber.prototype.error = function (err) {
10817 if (!this.isStopped) {
10818 var result = void 0;
10820 result = this.selector(err, this.caught);
10823 _super.prototype.error.call(this, err2);
10826 this._unsubscribeAndRecycle();
10827 var innerSubscriber = new InnerSubscriber_1.InnerSubscriber(this, undefined, undefined);
10828 this.add(innerSubscriber);
10829 subscribeToResult_1.subscribeToResult(this, result, undefined, undefined, innerSubscriber);
10832 return CatchSubscriber;
10833 }(OuterSubscriber_1.OuterSubscriber));
10835 },{"../InnerSubscriber":30,"../OuterSubscriber":34,"../util/subscribeToResult":222}],81:[function(require,module,exports){
10837 Object.defineProperty(exports, "__esModule", { value: true });
10838 var combineLatest_1 = require("../observable/combineLatest");
10839 function combineAll(project) {
10840 return function (source) { return source.lift(new combineLatest_1.CombineLatestOperator(project)); };
10842 exports.combineAll = combineAll;
10844 },{"../observable/combineLatest":46}],82:[function(require,module,exports){
10846 Object.defineProperty(exports, "__esModule", { value: true });
10847 var isArray_1 = require("../util/isArray");
10848 var combineLatest_1 = require("../observable/combineLatest");
10849 var from_1 = require("../observable/from");
10851 function combineLatest() {
10852 var observables = [];
10853 for (var _i = 0; _i < arguments.length; _i++) {
10854 observables[_i] = arguments[_i];
10856 var project = null;
10857 if (typeof observables[observables.length - 1] === 'function') {
10858 project = observables.pop();
10860 if (observables.length === 1 && isArray_1.isArray(observables[0])) {
10861 observables = observables[0].slice();
10863 return function (source) { return source.lift.call(from_1.from([source].concat(observables)), new combineLatest_1.CombineLatestOperator(project)); };
10865 exports.combineLatest = combineLatest;
10867 },{"../observable/combineLatest":46,"../observable/from":51,"../util/isArray":203}],83:[function(require,module,exports){
10869 Object.defineProperty(exports, "__esModule", { value: true });
10870 var concat_1 = require("../observable/concat");
10871 function concat() {
10872 var observables = [];
10873 for (var _i = 0; _i < arguments.length; _i++) {
10874 observables[_i] = arguments[_i];
10876 return function (source) { return source.lift.call(concat_1.concat.apply(void 0, [source].concat(observables))); };
10878 exports.concat = concat;
10880 },{"../observable/concat":47}],84:[function(require,module,exports){
10882 Object.defineProperty(exports, "__esModule", { value: true });
10883 var mergeAll_1 = require("./mergeAll");
10884 function concatAll() {
10885 return mergeAll_1.mergeAll(1);
10887 exports.concatAll = concatAll;
10889 },{"./mergeAll":117}],85:[function(require,module,exports){
10891 Object.defineProperty(exports, "__esModule", { value: true });
10892 var mergeMap_1 = require("./mergeMap");
10893 function concatMap(project, resultSelector) {
10894 return mergeMap_1.mergeMap(project, resultSelector, 1);
10896 exports.concatMap = concatMap;
10898 },{"./mergeMap":118}],86:[function(require,module,exports){
10900 Object.defineProperty(exports, "__esModule", { value: true });
10901 var concatMap_1 = require("./concatMap");
10902 function concatMapTo(innerObservable, resultSelector) {
10903 return concatMap_1.concatMap(function () { return innerObservable; }, resultSelector);
10905 exports.concatMapTo = concatMapTo;
10907 },{"./concatMap":85}],87:[function(require,module,exports){
10909 var __extends = (this && this.__extends) || (function () {
10910 var extendStatics = function (d, b) {
10911 extendStatics = Object.setPrototypeOf ||
10912 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
10913 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
10914 return extendStatics(d, b);
10916 return function (d, b) {
10917 extendStatics(d, b);
10918 function __() { this.constructor = d; }
10919 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
10922 Object.defineProperty(exports, "__esModule", { value: true });
10923 var Subscriber_1 = require("../Subscriber");
10924 function count(predicate) {
10925 return function (source) { return source.lift(new CountOperator(predicate, source)); };
10927 exports.count = count;
10928 var CountOperator = (function () {
10929 function CountOperator(predicate, source) {
10930 this.predicate = predicate;
10931 this.source = source;
10933 CountOperator.prototype.call = function (subscriber, source) {
10934 return source.subscribe(new CountSubscriber(subscriber, this.predicate, this.source));
10936 return CountOperator;
10938 var CountSubscriber = (function (_super) {
10939 __extends(CountSubscriber, _super);
10940 function CountSubscriber(destination, predicate, source) {
10941 var _this = _super.call(this, destination) || this;
10942 _this.predicate = predicate;
10943 _this.source = source;
10948 CountSubscriber.prototype._next = function (value) {
10949 if (this.predicate) {
10950 this._tryPredicate(value);
10956 CountSubscriber.prototype._tryPredicate = function (value) {
10959 result = this.predicate(value, this.index++, this.source);
10962 this.destination.error(err);
10969 CountSubscriber.prototype._complete = function () {
10970 this.destination.next(this.count);
10971 this.destination.complete();
10973 return CountSubscriber;
10974 }(Subscriber_1.Subscriber));
10976 },{"../Subscriber":39}],88:[function(require,module,exports){
10978 var __extends = (this && this.__extends) || (function () {
10979 var extendStatics = function (d, b) {
10980 extendStatics = Object.setPrototypeOf ||
10981 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
10982 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
10983 return extendStatics(d, b);
10985 return function (d, b) {
10986 extendStatics(d, b);
10987 function __() { this.constructor = d; }
10988 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
10991 Object.defineProperty(exports, "__esModule", { value: true });
10992 var OuterSubscriber_1 = require("../OuterSubscriber");
10993 var subscribeToResult_1 = require("../util/subscribeToResult");
10994 function debounce(durationSelector) {
10995 return function (source) { return source.lift(new DebounceOperator(durationSelector)); };
10997 exports.debounce = debounce;
10998 var DebounceOperator = (function () {
10999 function DebounceOperator(durationSelector) {
11000 this.durationSelector = durationSelector;
11002 DebounceOperator.prototype.call = function (subscriber, source) {
11003 return source.subscribe(new DebounceSubscriber(subscriber, this.durationSelector));
11005 return DebounceOperator;
11007 var DebounceSubscriber = (function (_super) {
11008 __extends(DebounceSubscriber, _super);
11009 function DebounceSubscriber(destination, durationSelector) {
11010 var _this = _super.call(this, destination) || this;
11011 _this.durationSelector = durationSelector;
11012 _this.hasValue = false;
11013 _this.durationSubscription = null;
11016 DebounceSubscriber.prototype._next = function (value) {
11018 var result = this.durationSelector.call(this, value);
11020 this._tryNext(value, result);
11024 this.destination.error(err);
11027 DebounceSubscriber.prototype._complete = function () {
11029 this.destination.complete();
11031 DebounceSubscriber.prototype._tryNext = function (value, duration) {
11032 var subscription = this.durationSubscription;
11033 this.value = value;
11034 this.hasValue = true;
11035 if (subscription) {
11036 subscription.unsubscribe();
11037 this.remove(subscription);
11039 subscription = subscribeToResult_1.subscribeToResult(this, duration);
11040 if (subscription && !subscription.closed) {
11041 this.add(this.durationSubscription = subscription);
11044 DebounceSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
11047 DebounceSubscriber.prototype.notifyComplete = function () {
11050 DebounceSubscriber.prototype.emitValue = function () {
11051 if (this.hasValue) {
11052 var value = this.value;
11053 var subscription = this.durationSubscription;
11054 if (subscription) {
11055 this.durationSubscription = null;
11056 subscription.unsubscribe();
11057 this.remove(subscription);
11060 this.hasValue = false;
11061 _super.prototype._next.call(this, value);
11064 return DebounceSubscriber;
11065 }(OuterSubscriber_1.OuterSubscriber));
11067 },{"../OuterSubscriber":34,"../util/subscribeToResult":222}],89:[function(require,module,exports){
11069 var __extends = (this && this.__extends) || (function () {
11070 var extendStatics = function (d, b) {
11071 extendStatics = Object.setPrototypeOf ||
11072 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
11073 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
11074 return extendStatics(d, b);
11076 return function (d, b) {
11077 extendStatics(d, b);
11078 function __() { this.constructor = d; }
11079 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
11082 Object.defineProperty(exports, "__esModule", { value: true });
11083 var Subscriber_1 = require("../Subscriber");
11084 var async_1 = require("../scheduler/async");
11085 function debounceTime(dueTime, scheduler) {
11086 if (scheduler === void 0) { scheduler = async_1.async; }
11087 return function (source) { return source.lift(new DebounceTimeOperator(dueTime, scheduler)); };
11089 exports.debounceTime = debounceTime;
11090 var DebounceTimeOperator = (function () {
11091 function DebounceTimeOperator(dueTime, scheduler) {
11092 this.dueTime = dueTime;
11093 this.scheduler = scheduler;
11095 DebounceTimeOperator.prototype.call = function (subscriber, source) {
11096 return source.subscribe(new DebounceTimeSubscriber(subscriber, this.dueTime, this.scheduler));
11098 return DebounceTimeOperator;
11100 var DebounceTimeSubscriber = (function (_super) {
11101 __extends(DebounceTimeSubscriber, _super);
11102 function DebounceTimeSubscriber(destination, dueTime, scheduler) {
11103 var _this = _super.call(this, destination) || this;
11104 _this.dueTime = dueTime;
11105 _this.scheduler = scheduler;
11106 _this.debouncedSubscription = null;
11107 _this.lastValue = null;
11108 _this.hasValue = false;
11111 DebounceTimeSubscriber.prototype._next = function (value) {
11112 this.clearDebounce();
11113 this.lastValue = value;
11114 this.hasValue = true;
11115 this.add(this.debouncedSubscription = this.scheduler.schedule(dispatchNext, this.dueTime, this));
11117 DebounceTimeSubscriber.prototype._complete = function () {
11118 this.debouncedNext();
11119 this.destination.complete();
11121 DebounceTimeSubscriber.prototype.debouncedNext = function () {
11122 this.clearDebounce();
11123 if (this.hasValue) {
11124 var lastValue = this.lastValue;
11125 this.lastValue = null;
11126 this.hasValue = false;
11127 this.destination.next(lastValue);
11130 DebounceTimeSubscriber.prototype.clearDebounce = function () {
11131 var debouncedSubscription = this.debouncedSubscription;
11132 if (debouncedSubscription !== null) {
11133 this.remove(debouncedSubscription);
11134 debouncedSubscription.unsubscribe();
11135 this.debouncedSubscription = null;
11138 return DebounceTimeSubscriber;
11139 }(Subscriber_1.Subscriber));
11140 function dispatchNext(subscriber) {
11141 subscriber.debouncedNext();
11144 },{"../Subscriber":39,"../scheduler/async":188}],90:[function(require,module,exports){
11146 var __extends = (this && this.__extends) || (function () {
11147 var extendStatics = function (d, b) {
11148 extendStatics = Object.setPrototypeOf ||
11149 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
11150 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
11151 return extendStatics(d, b);
11153 return function (d, b) {
11154 extendStatics(d, b);
11155 function __() { this.constructor = d; }
11156 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
11159 Object.defineProperty(exports, "__esModule", { value: true });
11160 var Subscriber_1 = require("../Subscriber");
11161 function defaultIfEmpty(defaultValue) {
11162 if (defaultValue === void 0) { defaultValue = null; }
11163 return function (source) { return source.lift(new DefaultIfEmptyOperator(defaultValue)); };
11165 exports.defaultIfEmpty = defaultIfEmpty;
11166 var DefaultIfEmptyOperator = (function () {
11167 function DefaultIfEmptyOperator(defaultValue) {
11168 this.defaultValue = defaultValue;
11170 DefaultIfEmptyOperator.prototype.call = function (subscriber, source) {
11171 return source.subscribe(new DefaultIfEmptySubscriber(subscriber, this.defaultValue));
11173 return DefaultIfEmptyOperator;
11175 var DefaultIfEmptySubscriber = (function (_super) {
11176 __extends(DefaultIfEmptySubscriber, _super);
11177 function DefaultIfEmptySubscriber(destination, defaultValue) {
11178 var _this = _super.call(this, destination) || this;
11179 _this.defaultValue = defaultValue;
11180 _this.isEmpty = true;
11183 DefaultIfEmptySubscriber.prototype._next = function (value) {
11184 this.isEmpty = false;
11185 this.destination.next(value);
11187 DefaultIfEmptySubscriber.prototype._complete = function () {
11188 if (this.isEmpty) {
11189 this.destination.next(this.defaultValue);
11191 this.destination.complete();
11193 return DefaultIfEmptySubscriber;
11194 }(Subscriber_1.Subscriber));
11196 },{"../Subscriber":39}],91:[function(require,module,exports){
11198 var __extends = (this && this.__extends) || (function () {
11199 var extendStatics = function (d, b) {
11200 extendStatics = Object.setPrototypeOf ||
11201 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
11202 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
11203 return extendStatics(d, b);
11205 return function (d, b) {
11206 extendStatics(d, b);
11207 function __() { this.constructor = d; }
11208 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
11211 Object.defineProperty(exports, "__esModule", { value: true });
11212 var async_1 = require("../scheduler/async");
11213 var isDate_1 = require("../util/isDate");
11214 var Subscriber_1 = require("../Subscriber");
11215 var Notification_1 = require("../Notification");
11216 function delay(delay, scheduler) {
11217 if (scheduler === void 0) { scheduler = async_1.async; }
11218 var absoluteDelay = isDate_1.isDate(delay);
11219 var delayFor = absoluteDelay ? (+delay - scheduler.now()) : Math.abs(delay);
11220 return function (source) { return source.lift(new DelayOperator(delayFor, scheduler)); };
11222 exports.delay = delay;
11223 var DelayOperator = (function () {
11224 function DelayOperator(delay, scheduler) {
11225 this.delay = delay;
11226 this.scheduler = scheduler;
11228 DelayOperator.prototype.call = function (subscriber, source) {
11229 return source.subscribe(new DelaySubscriber(subscriber, this.delay, this.scheduler));
11231 return DelayOperator;
11233 var DelaySubscriber = (function (_super) {
11234 __extends(DelaySubscriber, _super);
11235 function DelaySubscriber(destination, delay, scheduler) {
11236 var _this = _super.call(this, destination) || this;
11237 _this.delay = delay;
11238 _this.scheduler = scheduler;
11240 _this.active = false;
11241 _this.errored = false;
11244 DelaySubscriber.dispatch = function (state) {
11245 var source = state.source;
11246 var queue = source.queue;
11247 var scheduler = state.scheduler;
11248 var destination = state.destination;
11249 while (queue.length > 0 && (queue[0].time - scheduler.now()) <= 0) {
11250 queue.shift().notification.observe(destination);
11252 if (queue.length > 0) {
11253 var delay_1 = Math.max(0, queue[0].time - scheduler.now());
11254 this.schedule(state, delay_1);
11257 this.unsubscribe();
11258 source.active = false;
11261 DelaySubscriber.prototype._schedule = function (scheduler) {
11262 this.active = true;
11263 var destination = this.destination;
11264 destination.add(scheduler.schedule(DelaySubscriber.dispatch, this.delay, {
11265 source: this, destination: this.destination, scheduler: scheduler
11268 DelaySubscriber.prototype.scheduleNotification = function (notification) {
11269 if (this.errored === true) {
11272 var scheduler = this.scheduler;
11273 var message = new DelayMessage(scheduler.now() + this.delay, notification);
11274 this.queue.push(message);
11275 if (this.active === false) {
11276 this._schedule(scheduler);
11279 DelaySubscriber.prototype._next = function (value) {
11280 this.scheduleNotification(Notification_1.Notification.createNext(value));
11282 DelaySubscriber.prototype._error = function (err) {
11283 this.errored = true;
11285 this.destination.error(err);
11286 this.unsubscribe();
11288 DelaySubscriber.prototype._complete = function () {
11289 this.scheduleNotification(Notification_1.Notification.createComplete());
11290 this.unsubscribe();
11292 return DelaySubscriber;
11293 }(Subscriber_1.Subscriber));
11294 var DelayMessage = (function () {
11295 function DelayMessage(time, notification) {
11297 this.notification = notification;
11299 return DelayMessage;
11302 },{"../Notification":31,"../Subscriber":39,"../scheduler/async":188,"../util/isDate":205}],92:[function(require,module,exports){
11304 var __extends = (this && this.__extends) || (function () {
11305 var extendStatics = function (d, b) {
11306 extendStatics = Object.setPrototypeOf ||
11307 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
11308 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
11309 return extendStatics(d, b);
11311 return function (d, b) {
11312 extendStatics(d, b);
11313 function __() { this.constructor = d; }
11314 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
11317 Object.defineProperty(exports, "__esModule", { value: true });
11318 var Subscriber_1 = require("../Subscriber");
11319 var Observable_1 = require("../Observable");
11320 var OuterSubscriber_1 = require("../OuterSubscriber");
11321 var subscribeToResult_1 = require("../util/subscribeToResult");
11322 function delayWhen(delayDurationSelector, subscriptionDelay) {
11323 if (subscriptionDelay) {
11324 return function (source) {
11325 return new SubscriptionDelayObservable(source, subscriptionDelay)
11326 .lift(new DelayWhenOperator(delayDurationSelector));
11329 return function (source) { return source.lift(new DelayWhenOperator(delayDurationSelector)); };
11331 exports.delayWhen = delayWhen;
11332 var DelayWhenOperator = (function () {
11333 function DelayWhenOperator(delayDurationSelector) {
11334 this.delayDurationSelector = delayDurationSelector;
11336 DelayWhenOperator.prototype.call = function (subscriber, source) {
11337 return source.subscribe(new DelayWhenSubscriber(subscriber, this.delayDurationSelector));
11339 return DelayWhenOperator;
11341 var DelayWhenSubscriber = (function (_super) {
11342 __extends(DelayWhenSubscriber, _super);
11343 function DelayWhenSubscriber(destination, delayDurationSelector) {
11344 var _this = _super.call(this, destination) || this;
11345 _this.delayDurationSelector = delayDurationSelector;
11346 _this.completed = false;
11347 _this.delayNotifierSubscriptions = [];
11351 DelayWhenSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
11352 this.destination.next(outerValue);
11353 this.removeSubscription(innerSub);
11354 this.tryComplete();
11356 DelayWhenSubscriber.prototype.notifyError = function (error, innerSub) {
11357 this._error(error);
11359 DelayWhenSubscriber.prototype.notifyComplete = function (innerSub) {
11360 var value = this.removeSubscription(innerSub);
11362 this.destination.next(value);
11364 this.tryComplete();
11366 DelayWhenSubscriber.prototype._next = function (value) {
11367 var index = this.index++;
11369 var delayNotifier = this.delayDurationSelector(value, index);
11370 if (delayNotifier) {
11371 this.tryDelay(delayNotifier, value);
11375 this.destination.error(err);
11378 DelayWhenSubscriber.prototype._complete = function () {
11379 this.completed = true;
11380 this.tryComplete();
11381 this.unsubscribe();
11383 DelayWhenSubscriber.prototype.removeSubscription = function (subscription) {
11384 subscription.unsubscribe();
11385 var subscriptionIdx = this.delayNotifierSubscriptions.indexOf(subscription);
11386 if (subscriptionIdx !== -1) {
11387 this.delayNotifierSubscriptions.splice(subscriptionIdx, 1);
11389 return subscription.outerValue;
11391 DelayWhenSubscriber.prototype.tryDelay = function (delayNotifier, value) {
11392 var notifierSubscription = subscribeToResult_1.subscribeToResult(this, delayNotifier, value);
11393 if (notifierSubscription && !notifierSubscription.closed) {
11394 var destination = this.destination;
11395 destination.add(notifierSubscription);
11396 this.delayNotifierSubscriptions.push(notifierSubscription);
11399 DelayWhenSubscriber.prototype.tryComplete = function () {
11400 if (this.completed && this.delayNotifierSubscriptions.length === 0) {
11401 this.destination.complete();
11404 return DelayWhenSubscriber;
11405 }(OuterSubscriber_1.OuterSubscriber));
11406 var SubscriptionDelayObservable = (function (_super) {
11407 __extends(SubscriptionDelayObservable, _super);
11408 function SubscriptionDelayObservable(source, subscriptionDelay) {
11409 var _this = _super.call(this) || this;
11410 _this.source = source;
11411 _this.subscriptionDelay = subscriptionDelay;
11414 SubscriptionDelayObservable.prototype._subscribe = function (subscriber) {
11415 this.subscriptionDelay.subscribe(new SubscriptionDelaySubscriber(subscriber, this.source));
11417 return SubscriptionDelayObservable;
11418 }(Observable_1.Observable));
11419 var SubscriptionDelaySubscriber = (function (_super) {
11420 __extends(SubscriptionDelaySubscriber, _super);
11421 function SubscriptionDelaySubscriber(parent, source) {
11422 var _this = _super.call(this) || this;
11423 _this.parent = parent;
11424 _this.source = source;
11425 _this.sourceSubscribed = false;
11428 SubscriptionDelaySubscriber.prototype._next = function (unused) {
11429 this.subscribeToSource();
11431 SubscriptionDelaySubscriber.prototype._error = function (err) {
11432 this.unsubscribe();
11433 this.parent.error(err);
11435 SubscriptionDelaySubscriber.prototype._complete = function () {
11436 this.unsubscribe();
11437 this.subscribeToSource();
11439 SubscriptionDelaySubscriber.prototype.subscribeToSource = function () {
11440 if (!this.sourceSubscribed) {
11441 this.sourceSubscribed = true;
11442 this.unsubscribe();
11443 this.source.subscribe(this.parent);
11446 return SubscriptionDelaySubscriber;
11447 }(Subscriber_1.Subscriber));
11449 },{"../Observable":32,"../OuterSubscriber":34,"../Subscriber":39,"../util/subscribeToResult":222}],93:[function(require,module,exports){
11451 var __extends = (this && this.__extends) || (function () {
11452 var extendStatics = function (d, b) {
11453 extendStatics = Object.setPrototypeOf ||
11454 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
11455 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
11456 return extendStatics(d, b);
11458 return function (d, b) {
11459 extendStatics(d, b);
11460 function __() { this.constructor = d; }
11461 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
11464 Object.defineProperty(exports, "__esModule", { value: true });
11465 var Subscriber_1 = require("../Subscriber");
11466 function dematerialize() {
11467 return function dematerializeOperatorFunction(source) {
11468 return source.lift(new DeMaterializeOperator());
11471 exports.dematerialize = dematerialize;
11472 var DeMaterializeOperator = (function () {
11473 function DeMaterializeOperator() {
11475 DeMaterializeOperator.prototype.call = function (subscriber, source) {
11476 return source.subscribe(new DeMaterializeSubscriber(subscriber));
11478 return DeMaterializeOperator;
11480 var DeMaterializeSubscriber = (function (_super) {
11481 __extends(DeMaterializeSubscriber, _super);
11482 function DeMaterializeSubscriber(destination) {
11483 return _super.call(this, destination) || this;
11485 DeMaterializeSubscriber.prototype._next = function (value) {
11486 value.observe(this.destination);
11488 return DeMaterializeSubscriber;
11489 }(Subscriber_1.Subscriber));
11491 },{"../Subscriber":39}],94:[function(require,module,exports){
11493 var __extends = (this && this.__extends) || (function () {
11494 var extendStatics = function (d, b) {
11495 extendStatics = Object.setPrototypeOf ||
11496 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
11497 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
11498 return extendStatics(d, b);
11500 return function (d, b) {
11501 extendStatics(d, b);
11502 function __() { this.constructor = d; }
11503 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
11506 Object.defineProperty(exports, "__esModule", { value: true });
11507 var OuterSubscriber_1 = require("../OuterSubscriber");
11508 var subscribeToResult_1 = require("../util/subscribeToResult");
11509 function distinct(keySelector, flushes) {
11510 return function (source) { return source.lift(new DistinctOperator(keySelector, flushes)); };
11512 exports.distinct = distinct;
11513 var DistinctOperator = (function () {
11514 function DistinctOperator(keySelector, flushes) {
11515 this.keySelector = keySelector;
11516 this.flushes = flushes;
11518 DistinctOperator.prototype.call = function (subscriber, source) {
11519 return source.subscribe(new DistinctSubscriber(subscriber, this.keySelector, this.flushes));
11521 return DistinctOperator;
11523 var DistinctSubscriber = (function (_super) {
11524 __extends(DistinctSubscriber, _super);
11525 function DistinctSubscriber(destination, keySelector, flushes) {
11526 var _this = _super.call(this, destination) || this;
11527 _this.keySelector = keySelector;
11528 _this.values = new Set();
11530 _this.add(subscribeToResult_1.subscribeToResult(_this, flushes));
11534 DistinctSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
11535 this.values.clear();
11537 DistinctSubscriber.prototype.notifyError = function (error, innerSub) {
11538 this._error(error);
11540 DistinctSubscriber.prototype._next = function (value) {
11541 if (this.keySelector) {
11542 this._useKeySelector(value);
11545 this._finalizeNext(value, value);
11548 DistinctSubscriber.prototype._useKeySelector = function (value) {
11550 var destination = this.destination;
11552 key = this.keySelector(value);
11555 destination.error(err);
11558 this._finalizeNext(key, value);
11560 DistinctSubscriber.prototype._finalizeNext = function (key, value) {
11561 var values = this.values;
11562 if (!values.has(key)) {
11564 this.destination.next(value);
11567 return DistinctSubscriber;
11568 }(OuterSubscriber_1.OuterSubscriber));
11569 exports.DistinctSubscriber = DistinctSubscriber;
11571 },{"../OuterSubscriber":34,"../util/subscribeToResult":222}],95:[function(require,module,exports){
11573 var __extends = (this && this.__extends) || (function () {
11574 var extendStatics = function (d, b) {
11575 extendStatics = Object.setPrototypeOf ||
11576 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
11577 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
11578 return extendStatics(d, b);
11580 return function (d, b) {
11581 extendStatics(d, b);
11582 function __() { this.constructor = d; }
11583 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
11586 Object.defineProperty(exports, "__esModule", { value: true });
11587 var Subscriber_1 = require("../Subscriber");
11588 var tryCatch_1 = require("../util/tryCatch");
11589 var errorObject_1 = require("../util/errorObject");
11590 function distinctUntilChanged(compare, keySelector) {
11591 return function (source) { return source.lift(new DistinctUntilChangedOperator(compare, keySelector)); };
11593 exports.distinctUntilChanged = distinctUntilChanged;
11594 var DistinctUntilChangedOperator = (function () {
11595 function DistinctUntilChangedOperator(compare, keySelector) {
11596 this.compare = compare;
11597 this.keySelector = keySelector;
11599 DistinctUntilChangedOperator.prototype.call = function (subscriber, source) {
11600 return source.subscribe(new DistinctUntilChangedSubscriber(subscriber, this.compare, this.keySelector));
11602 return DistinctUntilChangedOperator;
11604 var DistinctUntilChangedSubscriber = (function (_super) {
11605 __extends(DistinctUntilChangedSubscriber, _super);
11606 function DistinctUntilChangedSubscriber(destination, compare, keySelector) {
11607 var _this = _super.call(this, destination) || this;
11608 _this.keySelector = keySelector;
11609 _this.hasKey = false;
11610 if (typeof compare === 'function') {
11611 _this.compare = compare;
11615 DistinctUntilChangedSubscriber.prototype.compare = function (x, y) {
11618 DistinctUntilChangedSubscriber.prototype._next = function (value) {
11619 var keySelector = this.keySelector;
11622 key = tryCatch_1.tryCatch(this.keySelector)(value);
11623 if (key === errorObject_1.errorObject) {
11624 return this.destination.error(errorObject_1.errorObject.e);
11627 var result = false;
11629 result = tryCatch_1.tryCatch(this.compare)(this.key, key);
11630 if (result === errorObject_1.errorObject) {
11631 return this.destination.error(errorObject_1.errorObject.e);
11635 this.hasKey = true;
11637 if (Boolean(result) === false) {
11639 this.destination.next(value);
11642 return DistinctUntilChangedSubscriber;
11643 }(Subscriber_1.Subscriber));
11645 },{"../Subscriber":39,"../util/errorObject":200,"../util/tryCatch":224}],96:[function(require,module,exports){
11647 Object.defineProperty(exports, "__esModule", { value: true });
11648 var distinctUntilChanged_1 = require("./distinctUntilChanged");
11649 function distinctUntilKeyChanged(key, compare) {
11650 return distinctUntilChanged_1.distinctUntilChanged(function (x, y) { return compare ? compare(x[key], y[key]) : x[key] === y[key]; });
11652 exports.distinctUntilKeyChanged = distinctUntilKeyChanged;
11654 },{"./distinctUntilChanged":95}],97:[function(require,module,exports){
11656 Object.defineProperty(exports, "__esModule", { value: true });
11657 var ArgumentOutOfRangeError_1 = require("../util/ArgumentOutOfRangeError");
11658 var filter_1 = require("./filter");
11659 var throwIfEmpty_1 = require("./throwIfEmpty");
11660 var defaultIfEmpty_1 = require("./defaultIfEmpty");
11661 var take_1 = require("./take");
11662 function elementAt(index, defaultValue) {
11664 throw new ArgumentOutOfRangeError_1.ArgumentOutOfRangeError();
11666 var hasDefaultValue = arguments.length >= 2;
11667 return function (source) { return source.pipe(filter_1.filter(function (v, i) { return i === index; }), take_1.take(1), hasDefaultValue
11668 ? defaultIfEmpty_1.defaultIfEmpty(defaultValue)
11669 : throwIfEmpty_1.throwIfEmpty(function () { return new ArgumentOutOfRangeError_1.ArgumentOutOfRangeError(); })); };
11671 exports.elementAt = elementAt;
11673 },{"../util/ArgumentOutOfRangeError":193,"./defaultIfEmpty":90,"./filter":103,"./take":155,"./throwIfEmpty":162}],98:[function(require,module,exports){
11675 Object.defineProperty(exports, "__esModule", { value: true });
11676 var fromArray_1 = require("../observable/fromArray");
11677 var scalar_1 = require("../observable/scalar");
11678 var empty_1 = require("../observable/empty");
11679 var concat_1 = require("../observable/concat");
11680 var isScheduler_1 = require("../util/isScheduler");
11681 function endWith() {
11683 for (var _i = 0; _i < arguments.length; _i++) {
11684 array[_i] = arguments[_i];
11686 return function (source) {
11687 var scheduler = array[array.length - 1];
11688 if (isScheduler_1.isScheduler(scheduler)) {
11694 var len = array.length;
11695 if (len === 1 && !scheduler) {
11696 return concat_1.concat(source, scalar_1.scalar(array[0]));
11698 else if (len > 0) {
11699 return concat_1.concat(source, fromArray_1.fromArray(array, scheduler));
11702 return concat_1.concat(source, empty_1.empty(scheduler));
11706 exports.endWith = endWith;
11708 },{"../observable/concat":47,"../observable/empty":49,"../observable/fromArray":52,"../observable/scalar":68,"../util/isScheduler":213}],99:[function(require,module,exports){
11710 var __extends = (this && this.__extends) || (function () {
11711 var extendStatics = function (d, b) {
11712 extendStatics = Object.setPrototypeOf ||
11713 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
11714 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
11715 return extendStatics(d, b);
11717 return function (d, b) {
11718 extendStatics(d, b);
11719 function __() { this.constructor = d; }
11720 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
11723 Object.defineProperty(exports, "__esModule", { value: true });
11724 var Subscriber_1 = require("../Subscriber");
11725 function every(predicate, thisArg) {
11726 return function (source) { return source.lift(new EveryOperator(predicate, thisArg, source)); };
11728 exports.every = every;
11729 var EveryOperator = (function () {
11730 function EveryOperator(predicate, thisArg, source) {
11731 this.predicate = predicate;
11732 this.thisArg = thisArg;
11733 this.source = source;
11735 EveryOperator.prototype.call = function (observer, source) {
11736 return source.subscribe(new EverySubscriber(observer, this.predicate, this.thisArg, this.source));
11738 return EveryOperator;
11740 var EverySubscriber = (function (_super) {
11741 __extends(EverySubscriber, _super);
11742 function EverySubscriber(destination, predicate, thisArg, source) {
11743 var _this = _super.call(this, destination) || this;
11744 _this.predicate = predicate;
11745 _this.thisArg = thisArg;
11746 _this.source = source;
11748 _this.thisArg = thisArg || _this;
11751 EverySubscriber.prototype.notifyComplete = function (everyValueMatch) {
11752 this.destination.next(everyValueMatch);
11753 this.destination.complete();
11755 EverySubscriber.prototype._next = function (value) {
11756 var result = false;
11758 result = this.predicate.call(this.thisArg, value, this.index++, this.source);
11761 this.destination.error(err);
11765 this.notifyComplete(false);
11768 EverySubscriber.prototype._complete = function () {
11769 this.notifyComplete(true);
11771 return EverySubscriber;
11772 }(Subscriber_1.Subscriber));
11774 },{"../Subscriber":39}],100:[function(require,module,exports){
11776 var __extends = (this && this.__extends) || (function () {
11777 var extendStatics = function (d, b) {
11778 extendStatics = Object.setPrototypeOf ||
11779 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
11780 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
11781 return extendStatics(d, b);
11783 return function (d, b) {
11784 extendStatics(d, b);
11785 function __() { this.constructor = d; }
11786 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
11789 Object.defineProperty(exports, "__esModule", { value: true });
11790 var OuterSubscriber_1 = require("../OuterSubscriber");
11791 var subscribeToResult_1 = require("../util/subscribeToResult");
11792 function exhaust() {
11793 return function (source) { return source.lift(new SwitchFirstOperator()); };
11795 exports.exhaust = exhaust;
11796 var SwitchFirstOperator = (function () {
11797 function SwitchFirstOperator() {
11799 SwitchFirstOperator.prototype.call = function (subscriber, source) {
11800 return source.subscribe(new SwitchFirstSubscriber(subscriber));
11802 return SwitchFirstOperator;
11804 var SwitchFirstSubscriber = (function (_super) {
11805 __extends(SwitchFirstSubscriber, _super);
11806 function SwitchFirstSubscriber(destination) {
11807 var _this = _super.call(this, destination) || this;
11808 _this.hasCompleted = false;
11809 _this.hasSubscription = false;
11812 SwitchFirstSubscriber.prototype._next = function (value) {
11813 if (!this.hasSubscription) {
11814 this.hasSubscription = true;
11815 this.add(subscribeToResult_1.subscribeToResult(this, value));
11818 SwitchFirstSubscriber.prototype._complete = function () {
11819 this.hasCompleted = true;
11820 if (!this.hasSubscription) {
11821 this.destination.complete();
11824 SwitchFirstSubscriber.prototype.notifyComplete = function (innerSub) {
11825 this.remove(innerSub);
11826 this.hasSubscription = false;
11827 if (this.hasCompleted) {
11828 this.destination.complete();
11831 return SwitchFirstSubscriber;
11832 }(OuterSubscriber_1.OuterSubscriber));
11834 },{"../OuterSubscriber":34,"../util/subscribeToResult":222}],101:[function(require,module,exports){
11836 var __extends = (this && this.__extends) || (function () {
11837 var extendStatics = function (d, b) {
11838 extendStatics = Object.setPrototypeOf ||
11839 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
11840 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
11841 return extendStatics(d, b);
11843 return function (d, b) {
11844 extendStatics(d, b);
11845 function __() { this.constructor = d; }
11846 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
11849 Object.defineProperty(exports, "__esModule", { value: true });
11850 var OuterSubscriber_1 = require("../OuterSubscriber");
11851 var InnerSubscriber_1 = require("../InnerSubscriber");
11852 var subscribeToResult_1 = require("../util/subscribeToResult");
11853 var map_1 = require("./map");
11854 var from_1 = require("../observable/from");
11855 function exhaustMap(project, resultSelector) {
11856 if (resultSelector) {
11857 return function (source) { return source.pipe(exhaustMap(function (a, i) { return from_1.from(project(a, i)).pipe(map_1.map(function (b, ii) { return resultSelector(a, b, i, ii); })); })); };
11859 return function (source) {
11860 return source.lift(new ExhauseMapOperator(project));
11863 exports.exhaustMap = exhaustMap;
11864 var ExhauseMapOperator = (function () {
11865 function ExhauseMapOperator(project) {
11866 this.project = project;
11868 ExhauseMapOperator.prototype.call = function (subscriber, source) {
11869 return source.subscribe(new ExhaustMapSubscriber(subscriber, this.project));
11871 return ExhauseMapOperator;
11873 var ExhaustMapSubscriber = (function (_super) {
11874 __extends(ExhaustMapSubscriber, _super);
11875 function ExhaustMapSubscriber(destination, project) {
11876 var _this = _super.call(this, destination) || this;
11877 _this.project = project;
11878 _this.hasSubscription = false;
11879 _this.hasCompleted = false;
11883 ExhaustMapSubscriber.prototype._next = function (value) {
11884 if (!this.hasSubscription) {
11885 this.tryNext(value);
11888 ExhaustMapSubscriber.prototype.tryNext = function (value) {
11890 var index = this.index++;
11892 result = this.project(value, index);
11895 this.destination.error(err);
11898 this.hasSubscription = true;
11899 this._innerSub(result, value, index);
11901 ExhaustMapSubscriber.prototype._innerSub = function (result, value, index) {
11902 var innerSubscriber = new InnerSubscriber_1.InnerSubscriber(this, undefined, undefined);
11903 var destination = this.destination;
11904 destination.add(innerSubscriber);
11905 subscribeToResult_1.subscribeToResult(this, result, value, index, innerSubscriber);
11907 ExhaustMapSubscriber.prototype._complete = function () {
11908 this.hasCompleted = true;
11909 if (!this.hasSubscription) {
11910 this.destination.complete();
11912 this.unsubscribe();
11914 ExhaustMapSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
11915 this.destination.next(innerValue);
11917 ExhaustMapSubscriber.prototype.notifyError = function (err) {
11918 this.destination.error(err);
11920 ExhaustMapSubscriber.prototype.notifyComplete = function (innerSub) {
11921 var destination = this.destination;
11922 destination.remove(innerSub);
11923 this.hasSubscription = false;
11924 if (this.hasCompleted) {
11925 this.destination.complete();
11928 return ExhaustMapSubscriber;
11929 }(OuterSubscriber_1.OuterSubscriber));
11931 },{"../InnerSubscriber":30,"../OuterSubscriber":34,"../observable/from":51,"../util/subscribeToResult":222,"./map":112}],102:[function(require,module,exports){
11933 var __extends = (this && this.__extends) || (function () {
11934 var extendStatics = function (d, b) {
11935 extendStatics = Object.setPrototypeOf ||
11936 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
11937 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
11938 return extendStatics(d, b);
11940 return function (d, b) {
11941 extendStatics(d, b);
11942 function __() { this.constructor = d; }
11943 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
11946 Object.defineProperty(exports, "__esModule", { value: true });
11947 var tryCatch_1 = require("../util/tryCatch");
11948 var errorObject_1 = require("../util/errorObject");
11949 var OuterSubscriber_1 = require("../OuterSubscriber");
11950 var subscribeToResult_1 = require("../util/subscribeToResult");
11951 function expand(project, concurrent, scheduler) {
11952 if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
11953 if (scheduler === void 0) { scheduler = undefined; }
11954 concurrent = (concurrent || 0) < 1 ? Number.POSITIVE_INFINITY : concurrent;
11955 return function (source) { return source.lift(new ExpandOperator(project, concurrent, scheduler)); };
11957 exports.expand = expand;
11958 var ExpandOperator = (function () {
11959 function ExpandOperator(project, concurrent, scheduler) {
11960 this.project = project;
11961 this.concurrent = concurrent;
11962 this.scheduler = scheduler;
11964 ExpandOperator.prototype.call = function (subscriber, source) {
11965 return source.subscribe(new ExpandSubscriber(subscriber, this.project, this.concurrent, this.scheduler));
11967 return ExpandOperator;
11969 exports.ExpandOperator = ExpandOperator;
11970 var ExpandSubscriber = (function (_super) {
11971 __extends(ExpandSubscriber, _super);
11972 function ExpandSubscriber(destination, project, concurrent, scheduler) {
11973 var _this = _super.call(this, destination) || this;
11974 _this.project = project;
11975 _this.concurrent = concurrent;
11976 _this.scheduler = scheduler;
11979 _this.hasCompleted = false;
11980 if (concurrent < Number.POSITIVE_INFINITY) {
11985 ExpandSubscriber.dispatch = function (arg) {
11986 var subscriber = arg.subscriber, result = arg.result, value = arg.value, index = arg.index;
11987 subscriber.subscribeToProjection(result, value, index);
11989 ExpandSubscriber.prototype._next = function (value) {
11990 var destination = this.destination;
11991 if (destination.closed) {
11995 var index = this.index++;
11996 if (this.active < this.concurrent) {
11997 destination.next(value);
11998 var result = tryCatch_1.tryCatch(this.project)(value, index);
11999 if (result === errorObject_1.errorObject) {
12000 destination.error(errorObject_1.errorObject.e);
12002 else if (!this.scheduler) {
12003 this.subscribeToProjection(result, value, index);
12006 var state = { subscriber: this, result: result, value: value, index: index };
12007 var destination_1 = this.destination;
12008 destination_1.add(this.scheduler.schedule(ExpandSubscriber.dispatch, 0, state));
12012 this.buffer.push(value);
12015 ExpandSubscriber.prototype.subscribeToProjection = function (result, value, index) {
12017 var destination = this.destination;
12018 destination.add(subscribeToResult_1.subscribeToResult(this, result, value, index));
12020 ExpandSubscriber.prototype._complete = function () {
12021 this.hasCompleted = true;
12022 if (this.hasCompleted && this.active === 0) {
12023 this.destination.complete();
12025 this.unsubscribe();
12027 ExpandSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
12028 this._next(innerValue);
12030 ExpandSubscriber.prototype.notifyComplete = function (innerSub) {
12031 var buffer = this.buffer;
12032 var destination = this.destination;
12033 destination.remove(innerSub);
12035 if (buffer && buffer.length > 0) {
12036 this._next(buffer.shift());
12038 if (this.hasCompleted && this.active === 0) {
12039 this.destination.complete();
12042 return ExpandSubscriber;
12043 }(OuterSubscriber_1.OuterSubscriber));
12044 exports.ExpandSubscriber = ExpandSubscriber;
12046 },{"../OuterSubscriber":34,"../util/errorObject":200,"../util/subscribeToResult":222,"../util/tryCatch":224}],103:[function(require,module,exports){
12048 var __extends = (this && this.__extends) || (function () {
12049 var extendStatics = function (d, b) {
12050 extendStatics = Object.setPrototypeOf ||
12051 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
12052 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
12053 return extendStatics(d, b);
12055 return function (d, b) {
12056 extendStatics(d, b);
12057 function __() { this.constructor = d; }
12058 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12061 Object.defineProperty(exports, "__esModule", { value: true });
12062 var Subscriber_1 = require("../Subscriber");
12063 function filter(predicate, thisArg) {
12064 return function filterOperatorFunction(source) {
12065 return source.lift(new FilterOperator(predicate, thisArg));
12068 exports.filter = filter;
12069 var FilterOperator = (function () {
12070 function FilterOperator(predicate, thisArg) {
12071 this.predicate = predicate;
12072 this.thisArg = thisArg;
12074 FilterOperator.prototype.call = function (subscriber, source) {
12075 return source.subscribe(new FilterSubscriber(subscriber, this.predicate, this.thisArg));
12077 return FilterOperator;
12079 var FilterSubscriber = (function (_super) {
12080 __extends(FilterSubscriber, _super);
12081 function FilterSubscriber(destination, predicate, thisArg) {
12082 var _this = _super.call(this, destination) || this;
12083 _this.predicate = predicate;
12084 _this.thisArg = thisArg;
12088 FilterSubscriber.prototype._next = function (value) {
12091 result = this.predicate.call(this.thisArg, value, this.count++);
12094 this.destination.error(err);
12098 this.destination.next(value);
12101 return FilterSubscriber;
12102 }(Subscriber_1.Subscriber));
12104 },{"../Subscriber":39}],104:[function(require,module,exports){
12106 var __extends = (this && this.__extends) || (function () {
12107 var extendStatics = function (d, b) {
12108 extendStatics = Object.setPrototypeOf ||
12109 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
12110 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
12111 return extendStatics(d, b);
12113 return function (d, b) {
12114 extendStatics(d, b);
12115 function __() { this.constructor = d; }
12116 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12119 Object.defineProperty(exports, "__esModule", { value: true });
12120 var Subscriber_1 = require("../Subscriber");
12121 var Subscription_1 = require("../Subscription");
12122 function finalize(callback) {
12123 return function (source) { return source.lift(new FinallyOperator(callback)); };
12125 exports.finalize = finalize;
12126 var FinallyOperator = (function () {
12127 function FinallyOperator(callback) {
12128 this.callback = callback;
12130 FinallyOperator.prototype.call = function (subscriber, source) {
12131 return source.subscribe(new FinallySubscriber(subscriber, this.callback));
12133 return FinallyOperator;
12135 var FinallySubscriber = (function (_super) {
12136 __extends(FinallySubscriber, _super);
12137 function FinallySubscriber(destination, callback) {
12138 var _this = _super.call(this, destination) || this;
12139 _this.add(new Subscription_1.Subscription(callback));
12142 return FinallySubscriber;
12143 }(Subscriber_1.Subscriber));
12145 },{"../Subscriber":39,"../Subscription":40}],105:[function(require,module,exports){
12147 var __extends = (this && this.__extends) || (function () {
12148 var extendStatics = function (d, b) {
12149 extendStatics = Object.setPrototypeOf ||
12150 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
12151 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
12152 return extendStatics(d, b);
12154 return function (d, b) {
12155 extendStatics(d, b);
12156 function __() { this.constructor = d; }
12157 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12160 Object.defineProperty(exports, "__esModule", { value: true });
12161 var Subscriber_1 = require("../Subscriber");
12162 function find(predicate, thisArg) {
12163 if (typeof predicate !== 'function') {
12164 throw new TypeError('predicate is not a function');
12166 return function (source) { return source.lift(new FindValueOperator(predicate, source, false, thisArg)); };
12168 exports.find = find;
12169 var FindValueOperator = (function () {
12170 function FindValueOperator(predicate, source, yieldIndex, thisArg) {
12171 this.predicate = predicate;
12172 this.source = source;
12173 this.yieldIndex = yieldIndex;
12174 this.thisArg = thisArg;
12176 FindValueOperator.prototype.call = function (observer, source) {
12177 return source.subscribe(new FindValueSubscriber(observer, this.predicate, this.source, this.yieldIndex, this.thisArg));
12179 return FindValueOperator;
12181 exports.FindValueOperator = FindValueOperator;
12182 var FindValueSubscriber = (function (_super) {
12183 __extends(FindValueSubscriber, _super);
12184 function FindValueSubscriber(destination, predicate, source, yieldIndex, thisArg) {
12185 var _this = _super.call(this, destination) || this;
12186 _this.predicate = predicate;
12187 _this.source = source;
12188 _this.yieldIndex = yieldIndex;
12189 _this.thisArg = thisArg;
12193 FindValueSubscriber.prototype.notifyComplete = function (value) {
12194 var destination = this.destination;
12195 destination.next(value);
12196 destination.complete();
12197 this.unsubscribe();
12199 FindValueSubscriber.prototype._next = function (value) {
12200 var _a = this, predicate = _a.predicate, thisArg = _a.thisArg;
12201 var index = this.index++;
12203 var result = predicate.call(thisArg || this, value, index, this.source);
12205 this.notifyComplete(this.yieldIndex ? index : value);
12209 this.destination.error(err);
12212 FindValueSubscriber.prototype._complete = function () {
12213 this.notifyComplete(this.yieldIndex ? -1 : undefined);
12215 return FindValueSubscriber;
12216 }(Subscriber_1.Subscriber));
12217 exports.FindValueSubscriber = FindValueSubscriber;
12219 },{"../Subscriber":39}],106:[function(require,module,exports){
12221 Object.defineProperty(exports, "__esModule", { value: true });
12222 var find_1 = require("../operators/find");
12223 function findIndex(predicate, thisArg) {
12224 return function (source) { return source.lift(new find_1.FindValueOperator(predicate, source, true, thisArg)); };
12226 exports.findIndex = findIndex;
12228 },{"../operators/find":105}],107:[function(require,module,exports){
12230 Object.defineProperty(exports, "__esModule", { value: true });
12231 var EmptyError_1 = require("../util/EmptyError");
12232 var filter_1 = require("./filter");
12233 var take_1 = require("./take");
12234 var defaultIfEmpty_1 = require("./defaultIfEmpty");
12235 var throwIfEmpty_1 = require("./throwIfEmpty");
12236 var identity_1 = require("../util/identity");
12237 function first(predicate, defaultValue) {
12238 var hasDefaultValue = arguments.length >= 2;
12239 return function (source) { return source.pipe(predicate ? filter_1.filter(function (v, i) { return predicate(v, i, source); }) : identity_1.identity, take_1.take(1), hasDefaultValue ? defaultIfEmpty_1.defaultIfEmpty(defaultValue) : throwIfEmpty_1.throwIfEmpty(function () { return new EmptyError_1.EmptyError(); })); };
12241 exports.first = first;
12243 },{"../util/EmptyError":194,"../util/identity":202,"./defaultIfEmpty":90,"./filter":103,"./take":155,"./throwIfEmpty":162}],108:[function(require,module,exports){
12245 var __extends = (this && this.__extends) || (function () {
12246 var extendStatics = function (d, b) {
12247 extendStatics = Object.setPrototypeOf ||
12248 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
12249 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
12250 return extendStatics(d, b);
12252 return function (d, b) {
12253 extendStatics(d, b);
12254 function __() { this.constructor = d; }
12255 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12258 Object.defineProperty(exports, "__esModule", { value: true });
12259 var Subscriber_1 = require("../Subscriber");
12260 var Subscription_1 = require("../Subscription");
12261 var Observable_1 = require("../Observable");
12262 var Subject_1 = require("../Subject");
12263 function groupBy(keySelector, elementSelector, durationSelector, subjectSelector) {
12264 return function (source) {
12265 return source.lift(new GroupByOperator(keySelector, elementSelector, durationSelector, subjectSelector));
12268 exports.groupBy = groupBy;
12269 var GroupByOperator = (function () {
12270 function GroupByOperator(keySelector, elementSelector, durationSelector, subjectSelector) {
12271 this.keySelector = keySelector;
12272 this.elementSelector = elementSelector;
12273 this.durationSelector = durationSelector;
12274 this.subjectSelector = subjectSelector;
12276 GroupByOperator.prototype.call = function (subscriber, source) {
12277 return source.subscribe(new GroupBySubscriber(subscriber, this.keySelector, this.elementSelector, this.durationSelector, this.subjectSelector));
12279 return GroupByOperator;
12281 var GroupBySubscriber = (function (_super) {
12282 __extends(GroupBySubscriber, _super);
12283 function GroupBySubscriber(destination, keySelector, elementSelector, durationSelector, subjectSelector) {
12284 var _this = _super.call(this, destination) || this;
12285 _this.keySelector = keySelector;
12286 _this.elementSelector = elementSelector;
12287 _this.durationSelector = durationSelector;
12288 _this.subjectSelector = subjectSelector;
12289 _this.groups = null;
12290 _this.attemptedToUnsubscribe = false;
12294 GroupBySubscriber.prototype._next = function (value) {
12297 key = this.keySelector(value);
12303 this._group(value, key);
12305 GroupBySubscriber.prototype._group = function (value, key) {
12306 var groups = this.groups;
12308 groups = this.groups = new Map();
12310 var group = groups.get(key);
12312 if (this.elementSelector) {
12314 element = this.elementSelector(value);
12324 group = (this.subjectSelector ? this.subjectSelector() : new Subject_1.Subject());
12325 groups.set(key, group);
12326 var groupedObservable = new GroupedObservable(key, group, this);
12327 this.destination.next(groupedObservable);
12328 if (this.durationSelector) {
12329 var duration = void 0;
12331 duration = this.durationSelector(new GroupedObservable(key, group));
12337 this.add(duration.subscribe(new GroupDurationSubscriber(key, group, this)));
12340 if (!group.closed) {
12341 group.next(element);
12344 GroupBySubscriber.prototype._error = function (err) {
12345 var groups = this.groups;
12347 groups.forEach(function (group, key) {
12352 this.destination.error(err);
12354 GroupBySubscriber.prototype._complete = function () {
12355 var groups = this.groups;
12357 groups.forEach(function (group, key) {
12362 this.destination.complete();
12364 GroupBySubscriber.prototype.removeGroup = function (key) {
12365 this.groups.delete(key);
12367 GroupBySubscriber.prototype.unsubscribe = function () {
12368 if (!this.closed) {
12369 this.attemptedToUnsubscribe = true;
12370 if (this.count === 0) {
12371 _super.prototype.unsubscribe.call(this);
12375 return GroupBySubscriber;
12376 }(Subscriber_1.Subscriber));
12377 var GroupDurationSubscriber = (function (_super) {
12378 __extends(GroupDurationSubscriber, _super);
12379 function GroupDurationSubscriber(key, group, parent) {
12380 var _this = _super.call(this, group) || this;
12382 _this.group = group;
12383 _this.parent = parent;
12386 GroupDurationSubscriber.prototype._next = function (value) {
12389 GroupDurationSubscriber.prototype._unsubscribe = function () {
12390 var _a = this, parent = _a.parent, key = _a.key;
12391 this.key = this.parent = null;
12393 parent.removeGroup(key);
12396 return GroupDurationSubscriber;
12397 }(Subscriber_1.Subscriber));
12398 var GroupedObservable = (function (_super) {
12399 __extends(GroupedObservable, _super);
12400 function GroupedObservable(key, groupSubject, refCountSubscription) {
12401 var _this = _super.call(this) || this;
12403 _this.groupSubject = groupSubject;
12404 _this.refCountSubscription = refCountSubscription;
12407 GroupedObservable.prototype._subscribe = function (subscriber) {
12408 var subscription = new Subscription_1.Subscription();
12409 var _a = this, refCountSubscription = _a.refCountSubscription, groupSubject = _a.groupSubject;
12410 if (refCountSubscription && !refCountSubscription.closed) {
12411 subscription.add(new InnerRefCountSubscription(refCountSubscription));
12413 subscription.add(groupSubject.subscribe(subscriber));
12414 return subscription;
12416 return GroupedObservable;
12417 }(Observable_1.Observable));
12418 exports.GroupedObservable = GroupedObservable;
12419 var InnerRefCountSubscription = (function (_super) {
12420 __extends(InnerRefCountSubscription, _super);
12421 function InnerRefCountSubscription(parent) {
12422 var _this = _super.call(this) || this;
12423 _this.parent = parent;
12427 InnerRefCountSubscription.prototype.unsubscribe = function () {
12428 var parent = this.parent;
12429 if (!parent.closed && !this.closed) {
12430 _super.prototype.unsubscribe.call(this);
12432 if (parent.count === 0 && parent.attemptedToUnsubscribe) {
12433 parent.unsubscribe();
12437 return InnerRefCountSubscription;
12438 }(Subscription_1.Subscription));
12440 },{"../Observable":32,"../Subject":37,"../Subscriber":39,"../Subscription":40}],109:[function(require,module,exports){
12442 var __extends = (this && this.__extends) || (function () {
12443 var extendStatics = function (d, b) {
12444 extendStatics = Object.setPrototypeOf ||
12445 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
12446 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
12447 return extendStatics(d, b);
12449 return function (d, b) {
12450 extendStatics(d, b);
12451 function __() { this.constructor = d; }
12452 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12455 Object.defineProperty(exports, "__esModule", { value: true });
12456 var Subscriber_1 = require("../Subscriber");
12457 function ignoreElements() {
12458 return function ignoreElementsOperatorFunction(source) {
12459 return source.lift(new IgnoreElementsOperator());
12462 exports.ignoreElements = ignoreElements;
12463 var IgnoreElementsOperator = (function () {
12464 function IgnoreElementsOperator() {
12466 IgnoreElementsOperator.prototype.call = function (subscriber, source) {
12467 return source.subscribe(new IgnoreElementsSubscriber(subscriber));
12469 return IgnoreElementsOperator;
12471 var IgnoreElementsSubscriber = (function (_super) {
12472 __extends(IgnoreElementsSubscriber, _super);
12473 function IgnoreElementsSubscriber() {
12474 return _super !== null && _super.apply(this, arguments) || this;
12476 IgnoreElementsSubscriber.prototype._next = function (unused) {
12478 return IgnoreElementsSubscriber;
12479 }(Subscriber_1.Subscriber));
12481 },{"../Subscriber":39}],110:[function(require,module,exports){
12483 var __extends = (this && this.__extends) || (function () {
12484 var extendStatics = function (d, b) {
12485 extendStatics = Object.setPrototypeOf ||
12486 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
12487 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
12488 return extendStatics(d, b);
12490 return function (d, b) {
12491 extendStatics(d, b);
12492 function __() { this.constructor = d; }
12493 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12496 Object.defineProperty(exports, "__esModule", { value: true });
12497 var Subscriber_1 = require("../Subscriber");
12498 function isEmpty() {
12499 return function (source) { return source.lift(new IsEmptyOperator()); };
12501 exports.isEmpty = isEmpty;
12502 var IsEmptyOperator = (function () {
12503 function IsEmptyOperator() {
12505 IsEmptyOperator.prototype.call = function (observer, source) {
12506 return source.subscribe(new IsEmptySubscriber(observer));
12508 return IsEmptyOperator;
12510 var IsEmptySubscriber = (function (_super) {
12511 __extends(IsEmptySubscriber, _super);
12512 function IsEmptySubscriber(destination) {
12513 return _super.call(this, destination) || this;
12515 IsEmptySubscriber.prototype.notifyComplete = function (isEmpty) {
12516 var destination = this.destination;
12517 destination.next(isEmpty);
12518 destination.complete();
12520 IsEmptySubscriber.prototype._next = function (value) {
12521 this.notifyComplete(false);
12523 IsEmptySubscriber.prototype._complete = function () {
12524 this.notifyComplete(true);
12526 return IsEmptySubscriber;
12527 }(Subscriber_1.Subscriber));
12529 },{"../Subscriber":39}],111:[function(require,module,exports){
12531 Object.defineProperty(exports, "__esModule", { value: true });
12532 var EmptyError_1 = require("../util/EmptyError");
12533 var filter_1 = require("./filter");
12534 var takeLast_1 = require("./takeLast");
12535 var throwIfEmpty_1 = require("./throwIfEmpty");
12536 var defaultIfEmpty_1 = require("./defaultIfEmpty");
12537 var identity_1 = require("../util/identity");
12538 function last(predicate, defaultValue) {
12539 var hasDefaultValue = arguments.length >= 2;
12540 return function (source) { return source.pipe(predicate ? filter_1.filter(function (v, i) { return predicate(v, i, source); }) : identity_1.identity, takeLast_1.takeLast(1), hasDefaultValue ? defaultIfEmpty_1.defaultIfEmpty(defaultValue) : throwIfEmpty_1.throwIfEmpty(function () { return new EmptyError_1.EmptyError(); })); };
12542 exports.last = last;
12544 },{"../util/EmptyError":194,"../util/identity":202,"./defaultIfEmpty":90,"./filter":103,"./takeLast":156,"./throwIfEmpty":162}],112:[function(require,module,exports){
12546 var __extends = (this && this.__extends) || (function () {
12547 var extendStatics = function (d, b) {
12548 extendStatics = Object.setPrototypeOf ||
12549 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
12550 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
12551 return extendStatics(d, b);
12553 return function (d, b) {
12554 extendStatics(d, b);
12555 function __() { this.constructor = d; }
12556 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12559 Object.defineProperty(exports, "__esModule", { value: true });
12560 var Subscriber_1 = require("../Subscriber");
12561 function map(project, thisArg) {
12562 return function mapOperation(source) {
12563 if (typeof project !== 'function') {
12564 throw new TypeError('argument is not a function. Are you looking for `mapTo()`?');
12566 return source.lift(new MapOperator(project, thisArg));
12570 var MapOperator = (function () {
12571 function MapOperator(project, thisArg) {
12572 this.project = project;
12573 this.thisArg = thisArg;
12575 MapOperator.prototype.call = function (subscriber, source) {
12576 return source.subscribe(new MapSubscriber(subscriber, this.project, this.thisArg));
12578 return MapOperator;
12580 exports.MapOperator = MapOperator;
12581 var MapSubscriber = (function (_super) {
12582 __extends(MapSubscriber, _super);
12583 function MapSubscriber(destination, project, thisArg) {
12584 var _this = _super.call(this, destination) || this;
12585 _this.project = project;
12587 _this.thisArg = thisArg || _this;
12590 MapSubscriber.prototype._next = function (value) {
12593 result = this.project.call(this.thisArg, value, this.count++);
12596 this.destination.error(err);
12599 this.destination.next(result);
12601 return MapSubscriber;
12602 }(Subscriber_1.Subscriber));
12604 },{"../Subscriber":39}],113:[function(require,module,exports){
12606 var __extends = (this && this.__extends) || (function () {
12607 var extendStatics = function (d, b) {
12608 extendStatics = Object.setPrototypeOf ||
12609 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
12610 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
12611 return extendStatics(d, b);
12613 return function (d, b) {
12614 extendStatics(d, b);
12615 function __() { this.constructor = d; }
12616 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12619 Object.defineProperty(exports, "__esModule", { value: true });
12620 var Subscriber_1 = require("../Subscriber");
12621 function mapTo(value) {
12622 return function (source) { return source.lift(new MapToOperator(value)); };
12624 exports.mapTo = mapTo;
12625 var MapToOperator = (function () {
12626 function MapToOperator(value) {
12627 this.value = value;
12629 MapToOperator.prototype.call = function (subscriber, source) {
12630 return source.subscribe(new MapToSubscriber(subscriber, this.value));
12632 return MapToOperator;
12634 var MapToSubscriber = (function (_super) {
12635 __extends(MapToSubscriber, _super);
12636 function MapToSubscriber(destination, value) {
12637 var _this = _super.call(this, destination) || this;
12638 _this.value = value;
12641 MapToSubscriber.prototype._next = function (x) {
12642 this.destination.next(this.value);
12644 return MapToSubscriber;
12645 }(Subscriber_1.Subscriber));
12647 },{"../Subscriber":39}],114:[function(require,module,exports){
12649 var __extends = (this && this.__extends) || (function () {
12650 var extendStatics = function (d, b) {
12651 extendStatics = Object.setPrototypeOf ||
12652 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
12653 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
12654 return extendStatics(d, b);
12656 return function (d, b) {
12657 extendStatics(d, b);
12658 function __() { this.constructor = d; }
12659 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12662 Object.defineProperty(exports, "__esModule", { value: true });
12663 var Subscriber_1 = require("../Subscriber");
12664 var Notification_1 = require("../Notification");
12665 function materialize() {
12666 return function materializeOperatorFunction(source) {
12667 return source.lift(new MaterializeOperator());
12670 exports.materialize = materialize;
12671 var MaterializeOperator = (function () {
12672 function MaterializeOperator() {
12674 MaterializeOperator.prototype.call = function (subscriber, source) {
12675 return source.subscribe(new MaterializeSubscriber(subscriber));
12677 return MaterializeOperator;
12679 var MaterializeSubscriber = (function (_super) {
12680 __extends(MaterializeSubscriber, _super);
12681 function MaterializeSubscriber(destination) {
12682 return _super.call(this, destination) || this;
12684 MaterializeSubscriber.prototype._next = function (value) {
12685 this.destination.next(Notification_1.Notification.createNext(value));
12687 MaterializeSubscriber.prototype._error = function (err) {
12688 var destination = this.destination;
12689 destination.next(Notification_1.Notification.createError(err));
12690 destination.complete();
12692 MaterializeSubscriber.prototype._complete = function () {
12693 var destination = this.destination;
12694 destination.next(Notification_1.Notification.createComplete());
12695 destination.complete();
12697 return MaterializeSubscriber;
12698 }(Subscriber_1.Subscriber));
12700 },{"../Notification":31,"../Subscriber":39}],115:[function(require,module,exports){
12702 Object.defineProperty(exports, "__esModule", { value: true });
12703 var reduce_1 = require("./reduce");
12704 function max(comparer) {
12705 var max = (typeof comparer === 'function')
12706 ? function (x, y) { return comparer(x, y) > 0 ? x : y; }
12707 : function (x, y) { return x > y ? x : y; };
12708 return reduce_1.reduce(max);
12712 },{"./reduce":133}],116:[function(require,module,exports){
12714 Object.defineProperty(exports, "__esModule", { value: true });
12715 var merge_1 = require("../observable/merge");
12717 var observables = [];
12718 for (var _i = 0; _i < arguments.length; _i++) {
12719 observables[_i] = arguments[_i];
12721 return function (source) { return source.lift.call(merge_1.merge.apply(void 0, [source].concat(observables))); };
12723 exports.merge = merge;
12725 },{"../observable/merge":61}],117:[function(require,module,exports){
12727 Object.defineProperty(exports, "__esModule", { value: true });
12728 var mergeMap_1 = require("./mergeMap");
12729 var identity_1 = require("../util/identity");
12730 function mergeAll(concurrent) {
12731 if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
12732 return mergeMap_1.mergeMap(identity_1.identity, concurrent);
12734 exports.mergeAll = mergeAll;
12736 },{"../util/identity":202,"./mergeMap":118}],118:[function(require,module,exports){
12738 var __extends = (this && this.__extends) || (function () {
12739 var extendStatics = function (d, b) {
12740 extendStatics = Object.setPrototypeOf ||
12741 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
12742 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
12743 return extendStatics(d, b);
12745 return function (d, b) {
12746 extendStatics(d, b);
12747 function __() { this.constructor = d; }
12748 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12751 Object.defineProperty(exports, "__esModule", { value: true });
12752 var subscribeToResult_1 = require("../util/subscribeToResult");
12753 var OuterSubscriber_1 = require("../OuterSubscriber");
12754 var InnerSubscriber_1 = require("../InnerSubscriber");
12755 var map_1 = require("./map");
12756 var from_1 = require("../observable/from");
12757 function mergeMap(project, resultSelector, concurrent) {
12758 if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
12759 if (typeof resultSelector === 'function') {
12760 return function (source) { return source.pipe(mergeMap(function (a, i) { return from_1.from(project(a, i)).pipe(map_1.map(function (b, ii) { return resultSelector(a, b, i, ii); })); }, concurrent)); };
12762 else if (typeof resultSelector === 'number') {
12763 concurrent = resultSelector;
12765 return function (source) { return source.lift(new MergeMapOperator(project, concurrent)); };
12767 exports.mergeMap = mergeMap;
12768 var MergeMapOperator = (function () {
12769 function MergeMapOperator(project, concurrent) {
12770 if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
12771 this.project = project;
12772 this.concurrent = concurrent;
12774 MergeMapOperator.prototype.call = function (observer, source) {
12775 return source.subscribe(new MergeMapSubscriber(observer, this.project, this.concurrent));
12777 return MergeMapOperator;
12779 exports.MergeMapOperator = MergeMapOperator;
12780 var MergeMapSubscriber = (function (_super) {
12781 __extends(MergeMapSubscriber, _super);
12782 function MergeMapSubscriber(destination, project, concurrent) {
12783 if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
12784 var _this = _super.call(this, destination) || this;
12785 _this.project = project;
12786 _this.concurrent = concurrent;
12787 _this.hasCompleted = false;
12793 MergeMapSubscriber.prototype._next = function (value) {
12794 if (this.active < this.concurrent) {
12795 this._tryNext(value);
12798 this.buffer.push(value);
12801 MergeMapSubscriber.prototype._tryNext = function (value) {
12803 var index = this.index++;
12805 result = this.project(value, index);
12808 this.destination.error(err);
12812 this._innerSub(result, value, index);
12814 MergeMapSubscriber.prototype._innerSub = function (ish, value, index) {
12815 var innerSubscriber = new InnerSubscriber_1.InnerSubscriber(this, undefined, undefined);
12816 var destination = this.destination;
12817 destination.add(innerSubscriber);
12818 subscribeToResult_1.subscribeToResult(this, ish, value, index, innerSubscriber);
12820 MergeMapSubscriber.prototype._complete = function () {
12821 this.hasCompleted = true;
12822 if (this.active === 0 && this.buffer.length === 0) {
12823 this.destination.complete();
12825 this.unsubscribe();
12827 MergeMapSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
12828 this.destination.next(innerValue);
12830 MergeMapSubscriber.prototype.notifyComplete = function (innerSub) {
12831 var buffer = this.buffer;
12832 this.remove(innerSub);
12834 if (buffer.length > 0) {
12835 this._next(buffer.shift());
12837 else if (this.active === 0 && this.hasCompleted) {
12838 this.destination.complete();
12841 return MergeMapSubscriber;
12842 }(OuterSubscriber_1.OuterSubscriber));
12843 exports.MergeMapSubscriber = MergeMapSubscriber;
12845 },{"../InnerSubscriber":30,"../OuterSubscriber":34,"../observable/from":51,"../util/subscribeToResult":222,"./map":112}],119:[function(require,module,exports){
12847 Object.defineProperty(exports, "__esModule", { value: true });
12848 var mergeMap_1 = require("./mergeMap");
12849 function mergeMapTo(innerObservable, resultSelector, concurrent) {
12850 if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
12851 if (typeof resultSelector === 'function') {
12852 return mergeMap_1.mergeMap(function () { return innerObservable; }, resultSelector, concurrent);
12854 if (typeof resultSelector === 'number') {
12855 concurrent = resultSelector;
12857 return mergeMap_1.mergeMap(function () { return innerObservable; }, concurrent);
12859 exports.mergeMapTo = mergeMapTo;
12861 },{"./mergeMap":118}],120:[function(require,module,exports){
12863 var __extends = (this && this.__extends) || (function () {
12864 var extendStatics = function (d, b) {
12865 extendStatics = Object.setPrototypeOf ||
12866 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
12867 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
12868 return extendStatics(d, b);
12870 return function (d, b) {
12871 extendStatics(d, b);
12872 function __() { this.constructor = d; }
12873 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12876 Object.defineProperty(exports, "__esModule", { value: true });
12877 var tryCatch_1 = require("../util/tryCatch");
12878 var errorObject_1 = require("../util/errorObject");
12879 var subscribeToResult_1 = require("../util/subscribeToResult");
12880 var OuterSubscriber_1 = require("../OuterSubscriber");
12881 var InnerSubscriber_1 = require("../InnerSubscriber");
12882 function mergeScan(accumulator, seed, concurrent) {
12883 if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
12884 return function (source) { return source.lift(new MergeScanOperator(accumulator, seed, concurrent)); };
12886 exports.mergeScan = mergeScan;
12887 var MergeScanOperator = (function () {
12888 function MergeScanOperator(accumulator, seed, concurrent) {
12889 this.accumulator = accumulator;
12891 this.concurrent = concurrent;
12893 MergeScanOperator.prototype.call = function (subscriber, source) {
12894 return source.subscribe(new MergeScanSubscriber(subscriber, this.accumulator, this.seed, this.concurrent));
12896 return MergeScanOperator;
12898 exports.MergeScanOperator = MergeScanOperator;
12899 var MergeScanSubscriber = (function (_super) {
12900 __extends(MergeScanSubscriber, _super);
12901 function MergeScanSubscriber(destination, accumulator, acc, concurrent) {
12902 var _this = _super.call(this, destination) || this;
12903 _this.accumulator = accumulator;
12905 _this.concurrent = concurrent;
12906 _this.hasValue = false;
12907 _this.hasCompleted = false;
12913 MergeScanSubscriber.prototype._next = function (value) {
12914 if (this.active < this.concurrent) {
12915 var index = this.index++;
12916 var ish = tryCatch_1.tryCatch(this.accumulator)(this.acc, value);
12917 var destination = this.destination;
12918 if (ish === errorObject_1.errorObject) {
12919 destination.error(errorObject_1.errorObject.e);
12923 this._innerSub(ish, value, index);
12927 this.buffer.push(value);
12930 MergeScanSubscriber.prototype._innerSub = function (ish, value, index) {
12931 var innerSubscriber = new InnerSubscriber_1.InnerSubscriber(this, undefined, undefined);
12932 var destination = this.destination;
12933 destination.add(innerSubscriber);
12934 subscribeToResult_1.subscribeToResult(this, ish, value, index, innerSubscriber);
12936 MergeScanSubscriber.prototype._complete = function () {
12937 this.hasCompleted = true;
12938 if (this.active === 0 && this.buffer.length === 0) {
12939 if (this.hasValue === false) {
12940 this.destination.next(this.acc);
12942 this.destination.complete();
12944 this.unsubscribe();
12946 MergeScanSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
12947 var destination = this.destination;
12948 this.acc = innerValue;
12949 this.hasValue = true;
12950 destination.next(innerValue);
12952 MergeScanSubscriber.prototype.notifyComplete = function (innerSub) {
12953 var buffer = this.buffer;
12954 var destination = this.destination;
12955 destination.remove(innerSub);
12957 if (buffer.length > 0) {
12958 this._next(buffer.shift());
12960 else if (this.active === 0 && this.hasCompleted) {
12961 if (this.hasValue === false) {
12962 this.destination.next(this.acc);
12964 this.destination.complete();
12967 return MergeScanSubscriber;
12968 }(OuterSubscriber_1.OuterSubscriber));
12969 exports.MergeScanSubscriber = MergeScanSubscriber;
12971 },{"../InnerSubscriber":30,"../OuterSubscriber":34,"../util/errorObject":200,"../util/subscribeToResult":222,"../util/tryCatch":224}],121:[function(require,module,exports){
12973 Object.defineProperty(exports, "__esModule", { value: true });
12974 var reduce_1 = require("./reduce");
12975 function min(comparer) {
12976 var min = (typeof comparer === 'function')
12977 ? function (x, y) { return comparer(x, y) < 0 ? x : y; }
12978 : function (x, y) { return x < y ? x : y; };
12979 return reduce_1.reduce(min);
12983 },{"./reduce":133}],122:[function(require,module,exports){
12985 Object.defineProperty(exports, "__esModule", { value: true });
12986 var ConnectableObservable_1 = require("../observable/ConnectableObservable");
12987 function multicast(subjectOrSubjectFactory, selector) {
12988 return function multicastOperatorFunction(source) {
12989 var subjectFactory;
12990 if (typeof subjectOrSubjectFactory === 'function') {
12991 subjectFactory = subjectOrSubjectFactory;
12994 subjectFactory = function subjectFactory() {
12995 return subjectOrSubjectFactory;
12998 if (typeof selector === 'function') {
12999 return source.lift(new MulticastOperator(subjectFactory, selector));
13001 var connectable = Object.create(source, ConnectableObservable_1.connectableObservableDescriptor);
13002 connectable.source = source;
13003 connectable.subjectFactory = subjectFactory;
13004 return connectable;
13007 exports.multicast = multicast;
13008 var MulticastOperator = (function () {
13009 function MulticastOperator(subjectFactory, selector) {
13010 this.subjectFactory = subjectFactory;
13011 this.selector = selector;
13013 MulticastOperator.prototype.call = function (subscriber, source) {
13014 var selector = this.selector;
13015 var subject = this.subjectFactory();
13016 var subscription = selector(subject).subscribe(subscriber);
13017 subscription.add(source.subscribe(subject));
13018 return subscription;
13020 return MulticastOperator;
13022 exports.MulticastOperator = MulticastOperator;
13024 },{"../observable/ConnectableObservable":42}],123:[function(require,module,exports){
13026 var __extends = (this && this.__extends) || (function () {
13027 var extendStatics = function (d, b) {
13028 extendStatics = Object.setPrototypeOf ||
13029 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
13030 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
13031 return extendStatics(d, b);
13033 return function (d, b) {
13034 extendStatics(d, b);
13035 function __() { this.constructor = d; }
13036 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13039 Object.defineProperty(exports, "__esModule", { value: true });
13040 var Subscriber_1 = require("../Subscriber");
13041 var Notification_1 = require("../Notification");
13042 function observeOn(scheduler, delay) {
13043 if (delay === void 0) { delay = 0; }
13044 return function observeOnOperatorFunction(source) {
13045 return source.lift(new ObserveOnOperator(scheduler, delay));
13048 exports.observeOn = observeOn;
13049 var ObserveOnOperator = (function () {
13050 function ObserveOnOperator(scheduler, delay) {
13051 if (delay === void 0) { delay = 0; }
13052 this.scheduler = scheduler;
13053 this.delay = delay;
13055 ObserveOnOperator.prototype.call = function (subscriber, source) {
13056 return source.subscribe(new ObserveOnSubscriber(subscriber, this.scheduler, this.delay));
13058 return ObserveOnOperator;
13060 exports.ObserveOnOperator = ObserveOnOperator;
13061 var ObserveOnSubscriber = (function (_super) {
13062 __extends(ObserveOnSubscriber, _super);
13063 function ObserveOnSubscriber(destination, scheduler, delay) {
13064 if (delay === void 0) { delay = 0; }
13065 var _this = _super.call(this, destination) || this;
13066 _this.scheduler = scheduler;
13067 _this.delay = delay;
13070 ObserveOnSubscriber.dispatch = function (arg) {
13071 var notification = arg.notification, destination = arg.destination;
13072 notification.observe(destination);
13073 this.unsubscribe();
13075 ObserveOnSubscriber.prototype.scheduleMessage = function (notification) {
13076 var destination = this.destination;
13077 destination.add(this.scheduler.schedule(ObserveOnSubscriber.dispatch, this.delay, new ObserveOnMessage(notification, this.destination)));
13079 ObserveOnSubscriber.prototype._next = function (value) {
13080 this.scheduleMessage(Notification_1.Notification.createNext(value));
13082 ObserveOnSubscriber.prototype._error = function (err) {
13083 this.scheduleMessage(Notification_1.Notification.createError(err));
13084 this.unsubscribe();
13086 ObserveOnSubscriber.prototype._complete = function () {
13087 this.scheduleMessage(Notification_1.Notification.createComplete());
13088 this.unsubscribe();
13090 return ObserveOnSubscriber;
13091 }(Subscriber_1.Subscriber));
13092 exports.ObserveOnSubscriber = ObserveOnSubscriber;
13093 var ObserveOnMessage = (function () {
13094 function ObserveOnMessage(notification, destination) {
13095 this.notification = notification;
13096 this.destination = destination;
13098 return ObserveOnMessage;
13100 exports.ObserveOnMessage = ObserveOnMessage;
13102 },{"../Notification":31,"../Subscriber":39}],124:[function(require,module,exports){
13104 var __extends = (this && this.__extends) || (function () {
13105 var extendStatics = function (d, b) {
13106 extendStatics = Object.setPrototypeOf ||
13107 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
13108 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
13109 return extendStatics(d, b);
13111 return function (d, b) {
13112 extendStatics(d, b);
13113 function __() { this.constructor = d; }
13114 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13117 Object.defineProperty(exports, "__esModule", { value: true });
13118 var from_1 = require("../observable/from");
13119 var isArray_1 = require("../util/isArray");
13120 var OuterSubscriber_1 = require("../OuterSubscriber");
13121 var InnerSubscriber_1 = require("../InnerSubscriber");
13122 var subscribeToResult_1 = require("../util/subscribeToResult");
13123 function onErrorResumeNext() {
13124 var nextSources = [];
13125 for (var _i = 0; _i < arguments.length; _i++) {
13126 nextSources[_i] = arguments[_i];
13128 if (nextSources.length === 1 && isArray_1.isArray(nextSources[0])) {
13129 nextSources = nextSources[0];
13131 return function (source) { return source.lift(new OnErrorResumeNextOperator(nextSources)); };
13133 exports.onErrorResumeNext = onErrorResumeNext;
13134 function onErrorResumeNextStatic() {
13135 var nextSources = [];
13136 for (var _i = 0; _i < arguments.length; _i++) {
13137 nextSources[_i] = arguments[_i];
13140 if (nextSources.length === 1 && isArray_1.isArray(nextSources[0])) {
13141 nextSources = nextSources[0];
13143 source = nextSources.shift();
13144 return from_1.from(source, null).lift(new OnErrorResumeNextOperator(nextSources));
13146 exports.onErrorResumeNextStatic = onErrorResumeNextStatic;
13147 var OnErrorResumeNextOperator = (function () {
13148 function OnErrorResumeNextOperator(nextSources) {
13149 this.nextSources = nextSources;
13151 OnErrorResumeNextOperator.prototype.call = function (subscriber, source) {
13152 return source.subscribe(new OnErrorResumeNextSubscriber(subscriber, this.nextSources));
13154 return OnErrorResumeNextOperator;
13156 var OnErrorResumeNextSubscriber = (function (_super) {
13157 __extends(OnErrorResumeNextSubscriber, _super);
13158 function OnErrorResumeNextSubscriber(destination, nextSources) {
13159 var _this = _super.call(this, destination) || this;
13160 _this.destination = destination;
13161 _this.nextSources = nextSources;
13164 OnErrorResumeNextSubscriber.prototype.notifyError = function (error, innerSub) {
13165 this.subscribeToNextSource();
13167 OnErrorResumeNextSubscriber.prototype.notifyComplete = function (innerSub) {
13168 this.subscribeToNextSource();
13170 OnErrorResumeNextSubscriber.prototype._error = function (err) {
13171 this.subscribeToNextSource();
13172 this.unsubscribe();
13174 OnErrorResumeNextSubscriber.prototype._complete = function () {
13175 this.subscribeToNextSource();
13176 this.unsubscribe();
13178 OnErrorResumeNextSubscriber.prototype.subscribeToNextSource = function () {
13179 var next = this.nextSources.shift();
13181 var innerSubscriber = new InnerSubscriber_1.InnerSubscriber(this, undefined, undefined);
13182 var destination = this.destination;
13183 destination.add(innerSubscriber);
13184 subscribeToResult_1.subscribeToResult(this, next, undefined, undefined, innerSubscriber);
13187 this.destination.complete();
13190 return OnErrorResumeNextSubscriber;
13191 }(OuterSubscriber_1.OuterSubscriber));
13193 },{"../InnerSubscriber":30,"../OuterSubscriber":34,"../observable/from":51,"../util/isArray":203,"../util/subscribeToResult":222}],125:[function(require,module,exports){
13195 var __extends = (this && this.__extends) || (function () {
13196 var extendStatics = function (d, b) {
13197 extendStatics = Object.setPrototypeOf ||
13198 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
13199 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
13200 return extendStatics(d, b);
13202 return function (d, b) {
13203 extendStatics(d, b);
13204 function __() { this.constructor = d; }
13205 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13208 Object.defineProperty(exports, "__esModule", { value: true });
13209 var Subscriber_1 = require("../Subscriber");
13210 function pairwise() {
13211 return function (source) { return source.lift(new PairwiseOperator()); };
13213 exports.pairwise = pairwise;
13214 var PairwiseOperator = (function () {
13215 function PairwiseOperator() {
13217 PairwiseOperator.prototype.call = function (subscriber, source) {
13218 return source.subscribe(new PairwiseSubscriber(subscriber));
13220 return PairwiseOperator;
13222 var PairwiseSubscriber = (function (_super) {
13223 __extends(PairwiseSubscriber, _super);
13224 function PairwiseSubscriber(destination) {
13225 var _this = _super.call(this, destination) || this;
13226 _this.hasPrev = false;
13229 PairwiseSubscriber.prototype._next = function (value) {
13230 if (this.hasPrev) {
13231 this.destination.next([this.prev, value]);
13234 this.hasPrev = true;
13238 return PairwiseSubscriber;
13239 }(Subscriber_1.Subscriber));
13241 },{"../Subscriber":39}],126:[function(require,module,exports){
13243 Object.defineProperty(exports, "__esModule", { value: true });
13244 var not_1 = require("../util/not");
13245 var filter_1 = require("./filter");
13246 function partition(predicate, thisArg) {
13247 return function (source) { return [
13248 filter_1.filter(predicate, thisArg)(source),
13249 filter_1.filter(not_1.not(predicate, thisArg))(source)
13252 exports.partition = partition;
13254 },{"../util/not":215,"./filter":103}],127:[function(require,module,exports){
13256 Object.defineProperty(exports, "__esModule", { value: true });
13257 var map_1 = require("./map");
13259 var properties = [];
13260 for (var _i = 0; _i < arguments.length; _i++) {
13261 properties[_i] = arguments[_i];
13263 var length = properties.length;
13264 if (length === 0) {
13265 throw new Error('list of properties cannot be empty.');
13267 return function (source) { return map_1.map(plucker(properties, length))(source); };
13269 exports.pluck = pluck;
13270 function plucker(props, length) {
13271 var mapper = function (x) {
13272 var currentProp = x;
13273 for (var i = 0; i < length; i++) {
13274 var p = currentProp[props[i]];
13275 if (typeof p !== 'undefined') {
13282 return currentProp;
13287 },{"./map":112}],128:[function(require,module,exports){
13289 Object.defineProperty(exports, "__esModule", { value: true });
13290 var Subject_1 = require("../Subject");
13291 var multicast_1 = require("./multicast");
13292 function publish(selector) {
13294 multicast_1.multicast(function () { return new Subject_1.Subject(); }, selector) :
13295 multicast_1.multicast(new Subject_1.Subject());
13297 exports.publish = publish;
13299 },{"../Subject":37,"./multicast":122}],129:[function(require,module,exports){
13301 Object.defineProperty(exports, "__esModule", { value: true });
13302 var BehaviorSubject_1 = require("../BehaviorSubject");
13303 var multicast_1 = require("./multicast");
13304 function publishBehavior(value) {
13305 return function (source) { return multicast_1.multicast(new BehaviorSubject_1.BehaviorSubject(value))(source); };
13307 exports.publishBehavior = publishBehavior;
13309 },{"../BehaviorSubject":29,"./multicast":122}],130:[function(require,module,exports){
13311 Object.defineProperty(exports, "__esModule", { value: true });
13312 var AsyncSubject_1 = require("../AsyncSubject");
13313 var multicast_1 = require("./multicast");
13314 function publishLast() {
13315 return function (source) { return multicast_1.multicast(new AsyncSubject_1.AsyncSubject())(source); };
13317 exports.publishLast = publishLast;
13319 },{"../AsyncSubject":28,"./multicast":122}],131:[function(require,module,exports){
13321 Object.defineProperty(exports, "__esModule", { value: true });
13322 var ReplaySubject_1 = require("../ReplaySubject");
13323 var multicast_1 = require("./multicast");
13324 function publishReplay(bufferSize, windowTime, selectorOrScheduler, scheduler) {
13325 if (selectorOrScheduler && typeof selectorOrScheduler !== 'function') {
13326 scheduler = selectorOrScheduler;
13328 var selector = typeof selectorOrScheduler === 'function' ? selectorOrScheduler : undefined;
13329 var subject = new ReplaySubject_1.ReplaySubject(bufferSize, windowTime, scheduler);
13330 return function (source) { return multicast_1.multicast(function () { return subject; }, selector)(source); };
13332 exports.publishReplay = publishReplay;
13334 },{"../ReplaySubject":35,"./multicast":122}],132:[function(require,module,exports){
13336 Object.defineProperty(exports, "__esModule", { value: true });
13337 var isArray_1 = require("../util/isArray");
13338 var race_1 = require("../observable/race");
13340 var observables = [];
13341 for (var _i = 0; _i < arguments.length; _i++) {
13342 observables[_i] = arguments[_i];
13344 return function raceOperatorFunction(source) {
13345 if (observables.length === 1 && isArray_1.isArray(observables[0])) {
13346 observables = observables[0];
13348 return source.lift.call(race_1.race.apply(void 0, [source].concat(observables)));
13351 exports.race = race;
13353 },{"../observable/race":66,"../util/isArray":203}],133:[function(require,module,exports){
13355 Object.defineProperty(exports, "__esModule", { value: true });
13356 var scan_1 = require("./scan");
13357 var takeLast_1 = require("./takeLast");
13358 var defaultIfEmpty_1 = require("./defaultIfEmpty");
13359 var pipe_1 = require("../util/pipe");
13360 function reduce(accumulator, seed) {
13361 if (arguments.length >= 2) {
13362 return function reduceOperatorFunctionWithSeed(source) {
13363 return pipe_1.pipe(scan_1.scan(accumulator, seed), takeLast_1.takeLast(1), defaultIfEmpty_1.defaultIfEmpty(seed))(source);
13366 return function reduceOperatorFunction(source) {
13367 return pipe_1.pipe(scan_1.scan(function (acc, value, index) { return accumulator(acc, value, index + 1); }), takeLast_1.takeLast(1))(source);
13370 exports.reduce = reduce;
13372 },{"../util/pipe":216,"./defaultIfEmpty":90,"./scan":141,"./takeLast":156}],134:[function(require,module,exports){
13374 var __extends = (this && this.__extends) || (function () {
13375 var extendStatics = function (d, b) {
13376 extendStatics = Object.setPrototypeOf ||
13377 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
13378 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
13379 return extendStatics(d, b);
13381 return function (d, b) {
13382 extendStatics(d, b);
13383 function __() { this.constructor = d; }
13384 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13387 Object.defineProperty(exports, "__esModule", { value: true });
13388 var Subscriber_1 = require("../Subscriber");
13389 function refCount() {
13390 return function refCountOperatorFunction(source) {
13391 return source.lift(new RefCountOperator(source));
13394 exports.refCount = refCount;
13395 var RefCountOperator = (function () {
13396 function RefCountOperator(connectable) {
13397 this.connectable = connectable;
13399 RefCountOperator.prototype.call = function (subscriber, source) {
13400 var connectable = this.connectable;
13401 connectable._refCount++;
13402 var refCounter = new RefCountSubscriber(subscriber, connectable);
13403 var subscription = source.subscribe(refCounter);
13404 if (!refCounter.closed) {
13405 refCounter.connection = connectable.connect();
13407 return subscription;
13409 return RefCountOperator;
13411 var RefCountSubscriber = (function (_super) {
13412 __extends(RefCountSubscriber, _super);
13413 function RefCountSubscriber(destination, connectable) {
13414 var _this = _super.call(this, destination) || this;
13415 _this.connectable = connectable;
13418 RefCountSubscriber.prototype._unsubscribe = function () {
13419 var connectable = this.connectable;
13420 if (!connectable) {
13421 this.connection = null;
13424 this.connectable = null;
13425 var refCount = connectable._refCount;
13426 if (refCount <= 0) {
13427 this.connection = null;
13430 connectable._refCount = refCount - 1;
13431 if (refCount > 1) {
13432 this.connection = null;
13435 var connection = this.connection;
13436 var sharedConnection = connectable._connection;
13437 this.connection = null;
13438 if (sharedConnection && (!connection || sharedConnection === connection)) {
13439 sharedConnection.unsubscribe();
13442 return RefCountSubscriber;
13443 }(Subscriber_1.Subscriber));
13445 },{"../Subscriber":39}],135:[function(require,module,exports){
13447 var __extends = (this && this.__extends) || (function () {
13448 var extendStatics = function (d, b) {
13449 extendStatics = Object.setPrototypeOf ||
13450 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
13451 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
13452 return extendStatics(d, b);
13454 return function (d, b) {
13455 extendStatics(d, b);
13456 function __() { this.constructor = d; }
13457 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13460 Object.defineProperty(exports, "__esModule", { value: true });
13461 var Subscriber_1 = require("../Subscriber");
13462 var empty_1 = require("../observable/empty");
13463 function repeat(count) {
13464 if (count === void 0) { count = -1; }
13465 return function (source) {
13467 return empty_1.empty();
13469 else if (count < 0) {
13470 return source.lift(new RepeatOperator(-1, source));
13473 return source.lift(new RepeatOperator(count - 1, source));
13477 exports.repeat = repeat;
13478 var RepeatOperator = (function () {
13479 function RepeatOperator(count, source) {
13480 this.count = count;
13481 this.source = source;
13483 RepeatOperator.prototype.call = function (subscriber, source) {
13484 return source.subscribe(new RepeatSubscriber(subscriber, this.count, this.source));
13486 return RepeatOperator;
13488 var RepeatSubscriber = (function (_super) {
13489 __extends(RepeatSubscriber, _super);
13490 function RepeatSubscriber(destination, count, source) {
13491 var _this = _super.call(this, destination) || this;
13492 _this.count = count;
13493 _this.source = source;
13496 RepeatSubscriber.prototype.complete = function () {
13497 if (!this.isStopped) {
13498 var _a = this, source = _a.source, count = _a.count;
13500 return _super.prototype.complete.call(this);
13502 else if (count > -1) {
13503 this.count = count - 1;
13505 source.subscribe(this._unsubscribeAndRecycle());
13508 return RepeatSubscriber;
13509 }(Subscriber_1.Subscriber));
13511 },{"../Subscriber":39,"../observable/empty":49}],136:[function(require,module,exports){
13513 var __extends = (this && this.__extends) || (function () {
13514 var extendStatics = function (d, b) {
13515 extendStatics = Object.setPrototypeOf ||
13516 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
13517 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
13518 return extendStatics(d, b);
13520 return function (d, b) {
13521 extendStatics(d, b);
13522 function __() { this.constructor = d; }
13523 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13526 Object.defineProperty(exports, "__esModule", { value: true });
13527 var Subject_1 = require("../Subject");
13528 var tryCatch_1 = require("../util/tryCatch");
13529 var errorObject_1 = require("../util/errorObject");
13530 var OuterSubscriber_1 = require("../OuterSubscriber");
13531 var subscribeToResult_1 = require("../util/subscribeToResult");
13532 function repeatWhen(notifier) {
13533 return function (source) { return source.lift(new RepeatWhenOperator(notifier)); };
13535 exports.repeatWhen = repeatWhen;
13536 var RepeatWhenOperator = (function () {
13537 function RepeatWhenOperator(notifier) {
13538 this.notifier = notifier;
13540 RepeatWhenOperator.prototype.call = function (subscriber, source) {
13541 return source.subscribe(new RepeatWhenSubscriber(subscriber, this.notifier, source));
13543 return RepeatWhenOperator;
13545 var RepeatWhenSubscriber = (function (_super) {
13546 __extends(RepeatWhenSubscriber, _super);
13547 function RepeatWhenSubscriber(destination, notifier, source) {
13548 var _this = _super.call(this, destination) || this;
13549 _this.notifier = notifier;
13550 _this.source = source;
13551 _this.sourceIsBeingSubscribedTo = true;
13554 RepeatWhenSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
13555 this.sourceIsBeingSubscribedTo = true;
13556 this.source.subscribe(this);
13558 RepeatWhenSubscriber.prototype.notifyComplete = function (innerSub) {
13559 if (this.sourceIsBeingSubscribedTo === false) {
13560 return _super.prototype.complete.call(this);
13563 RepeatWhenSubscriber.prototype.complete = function () {
13564 this.sourceIsBeingSubscribedTo = false;
13565 if (!this.isStopped) {
13566 if (!this.retries) {
13567 this.subscribeToRetries();
13569 if (!this.retriesSubscription || this.retriesSubscription.closed) {
13570 return _super.prototype.complete.call(this);
13572 this._unsubscribeAndRecycle();
13573 this.notifications.next();
13576 RepeatWhenSubscriber.prototype._unsubscribe = function () {
13577 var _a = this, notifications = _a.notifications, retriesSubscription = _a.retriesSubscription;
13578 if (notifications) {
13579 notifications.unsubscribe();
13580 this.notifications = null;
13582 if (retriesSubscription) {
13583 retriesSubscription.unsubscribe();
13584 this.retriesSubscription = null;
13586 this.retries = null;
13588 RepeatWhenSubscriber.prototype._unsubscribeAndRecycle = function () {
13589 var _unsubscribe = this._unsubscribe;
13590 this._unsubscribe = null;
13591 _super.prototype._unsubscribeAndRecycle.call(this);
13592 this._unsubscribe = _unsubscribe;
13595 RepeatWhenSubscriber.prototype.subscribeToRetries = function () {
13596 this.notifications = new Subject_1.Subject();
13597 var retries = tryCatch_1.tryCatch(this.notifier)(this.notifications);
13598 if (retries === errorObject_1.errorObject) {
13599 return _super.prototype.complete.call(this);
13601 this.retries = retries;
13602 this.retriesSubscription = subscribeToResult_1.subscribeToResult(this, retries);
13604 return RepeatWhenSubscriber;
13605 }(OuterSubscriber_1.OuterSubscriber));
13607 },{"../OuterSubscriber":34,"../Subject":37,"../util/errorObject":200,"../util/subscribeToResult":222,"../util/tryCatch":224}],137:[function(require,module,exports){
13609 var __extends = (this && this.__extends) || (function () {
13610 var extendStatics = function (d, b) {
13611 extendStatics = Object.setPrototypeOf ||
13612 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
13613 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
13614 return extendStatics(d, b);
13616 return function (d, b) {
13617 extendStatics(d, b);
13618 function __() { this.constructor = d; }
13619 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13622 Object.defineProperty(exports, "__esModule", { value: true });
13623 var Subscriber_1 = require("../Subscriber");
13624 function retry(count) {
13625 if (count === void 0) { count = -1; }
13626 return function (source) { return source.lift(new RetryOperator(count, source)); };
13628 exports.retry = retry;
13629 var RetryOperator = (function () {
13630 function RetryOperator(count, source) {
13631 this.count = count;
13632 this.source = source;
13634 RetryOperator.prototype.call = function (subscriber, source) {
13635 return source.subscribe(new RetrySubscriber(subscriber, this.count, this.source));
13637 return RetryOperator;
13639 var RetrySubscriber = (function (_super) {
13640 __extends(RetrySubscriber, _super);
13641 function RetrySubscriber(destination, count, source) {
13642 var _this = _super.call(this, destination) || this;
13643 _this.count = count;
13644 _this.source = source;
13647 RetrySubscriber.prototype.error = function (err) {
13648 if (!this.isStopped) {
13649 var _a = this, source = _a.source, count = _a.count;
13651 return _super.prototype.error.call(this, err);
13653 else if (count > -1) {
13654 this.count = count - 1;
13656 source.subscribe(this._unsubscribeAndRecycle());
13659 return RetrySubscriber;
13660 }(Subscriber_1.Subscriber));
13662 },{"../Subscriber":39}],138:[function(require,module,exports){
13664 var __extends = (this && this.__extends) || (function () {
13665 var extendStatics = function (d, b) {
13666 extendStatics = Object.setPrototypeOf ||
13667 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
13668 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
13669 return extendStatics(d, b);
13671 return function (d, b) {
13672 extendStatics(d, b);
13673 function __() { this.constructor = d; }
13674 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13677 Object.defineProperty(exports, "__esModule", { value: true });
13678 var Subject_1 = require("../Subject");
13679 var tryCatch_1 = require("../util/tryCatch");
13680 var errorObject_1 = require("../util/errorObject");
13681 var OuterSubscriber_1 = require("../OuterSubscriber");
13682 var subscribeToResult_1 = require("../util/subscribeToResult");
13683 function retryWhen(notifier) {
13684 return function (source) { return source.lift(new RetryWhenOperator(notifier, source)); };
13686 exports.retryWhen = retryWhen;
13687 var RetryWhenOperator = (function () {
13688 function RetryWhenOperator(notifier, source) {
13689 this.notifier = notifier;
13690 this.source = source;
13692 RetryWhenOperator.prototype.call = function (subscriber, source) {
13693 return source.subscribe(new RetryWhenSubscriber(subscriber, this.notifier, this.source));
13695 return RetryWhenOperator;
13697 var RetryWhenSubscriber = (function (_super) {
13698 __extends(RetryWhenSubscriber, _super);
13699 function RetryWhenSubscriber(destination, notifier, source) {
13700 var _this = _super.call(this, destination) || this;
13701 _this.notifier = notifier;
13702 _this.source = source;
13705 RetryWhenSubscriber.prototype.error = function (err) {
13706 if (!this.isStopped) {
13707 var errors = this.errors;
13708 var retries = this.retries;
13709 var retriesSubscription = this.retriesSubscription;
13711 errors = new Subject_1.Subject();
13712 retries = tryCatch_1.tryCatch(this.notifier)(errors);
13713 if (retries === errorObject_1.errorObject) {
13714 return _super.prototype.error.call(this, errorObject_1.errorObject.e);
13716 retriesSubscription = subscribeToResult_1.subscribeToResult(this, retries);
13719 this.errors = null;
13720 this.retriesSubscription = null;
13722 this._unsubscribeAndRecycle();
13723 this.errors = errors;
13724 this.retries = retries;
13725 this.retriesSubscription = retriesSubscription;
13729 RetryWhenSubscriber.prototype._unsubscribe = function () {
13730 var _a = this, errors = _a.errors, retriesSubscription = _a.retriesSubscription;
13732 errors.unsubscribe();
13733 this.errors = null;
13735 if (retriesSubscription) {
13736 retriesSubscription.unsubscribe();
13737 this.retriesSubscription = null;
13739 this.retries = null;
13741 RetryWhenSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
13742 var _unsubscribe = this._unsubscribe;
13743 this._unsubscribe = null;
13744 this._unsubscribeAndRecycle();
13745 this._unsubscribe = _unsubscribe;
13746 this.source.subscribe(this);
13748 return RetryWhenSubscriber;
13749 }(OuterSubscriber_1.OuterSubscriber));
13751 },{"../OuterSubscriber":34,"../Subject":37,"../util/errorObject":200,"../util/subscribeToResult":222,"../util/tryCatch":224}],139:[function(require,module,exports){
13753 var __extends = (this && this.__extends) || (function () {
13754 var extendStatics = function (d, b) {
13755 extendStatics = Object.setPrototypeOf ||
13756 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
13757 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
13758 return extendStatics(d, b);
13760 return function (d, b) {
13761 extendStatics(d, b);
13762 function __() { this.constructor = d; }
13763 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13766 Object.defineProperty(exports, "__esModule", { value: true });
13767 var OuterSubscriber_1 = require("../OuterSubscriber");
13768 var subscribeToResult_1 = require("../util/subscribeToResult");
13769 function sample(notifier) {
13770 return function (source) { return source.lift(new SampleOperator(notifier)); };
13772 exports.sample = sample;
13773 var SampleOperator = (function () {
13774 function SampleOperator(notifier) {
13775 this.notifier = notifier;
13777 SampleOperator.prototype.call = function (subscriber, source) {
13778 var sampleSubscriber = new SampleSubscriber(subscriber);
13779 var subscription = source.subscribe(sampleSubscriber);
13780 subscription.add(subscribeToResult_1.subscribeToResult(sampleSubscriber, this.notifier));
13781 return subscription;
13783 return SampleOperator;
13785 var SampleSubscriber = (function (_super) {
13786 __extends(SampleSubscriber, _super);
13787 function SampleSubscriber() {
13788 var _this = _super !== null && _super.apply(this, arguments) || this;
13789 _this.hasValue = false;
13792 SampleSubscriber.prototype._next = function (value) {
13793 this.value = value;
13794 this.hasValue = true;
13796 SampleSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
13799 SampleSubscriber.prototype.notifyComplete = function () {
13802 SampleSubscriber.prototype.emitValue = function () {
13803 if (this.hasValue) {
13804 this.hasValue = false;
13805 this.destination.next(this.value);
13808 return SampleSubscriber;
13809 }(OuterSubscriber_1.OuterSubscriber));
13811 },{"../OuterSubscriber":34,"../util/subscribeToResult":222}],140:[function(require,module,exports){
13813 var __extends = (this && this.__extends) || (function () {
13814 var extendStatics = function (d, b) {
13815 extendStatics = Object.setPrototypeOf ||
13816 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
13817 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
13818 return extendStatics(d, b);
13820 return function (d, b) {
13821 extendStatics(d, b);
13822 function __() { this.constructor = d; }
13823 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13826 Object.defineProperty(exports, "__esModule", { value: true });
13827 var Subscriber_1 = require("../Subscriber");
13828 var async_1 = require("../scheduler/async");
13829 function sampleTime(period, scheduler) {
13830 if (scheduler === void 0) { scheduler = async_1.async; }
13831 return function (source) { return source.lift(new SampleTimeOperator(period, scheduler)); };
13833 exports.sampleTime = sampleTime;
13834 var SampleTimeOperator = (function () {
13835 function SampleTimeOperator(period, scheduler) {
13836 this.period = period;
13837 this.scheduler = scheduler;
13839 SampleTimeOperator.prototype.call = function (subscriber, source) {
13840 return source.subscribe(new SampleTimeSubscriber(subscriber, this.period, this.scheduler));
13842 return SampleTimeOperator;
13844 var SampleTimeSubscriber = (function (_super) {
13845 __extends(SampleTimeSubscriber, _super);
13846 function SampleTimeSubscriber(destination, period, scheduler) {
13847 var _this = _super.call(this, destination) || this;
13848 _this.period = period;
13849 _this.scheduler = scheduler;
13850 _this.hasValue = false;
13851 _this.add(scheduler.schedule(dispatchNotification, period, { subscriber: _this, period: period }));
13854 SampleTimeSubscriber.prototype._next = function (value) {
13855 this.lastValue = value;
13856 this.hasValue = true;
13858 SampleTimeSubscriber.prototype.notifyNext = function () {
13859 if (this.hasValue) {
13860 this.hasValue = false;
13861 this.destination.next(this.lastValue);
13864 return SampleTimeSubscriber;
13865 }(Subscriber_1.Subscriber));
13866 function dispatchNotification(state) {
13867 var subscriber = state.subscriber, period = state.period;
13868 subscriber.notifyNext();
13869 this.schedule(state, period);
13872 },{"../Subscriber":39,"../scheduler/async":188}],141:[function(require,module,exports){
13874 var __extends = (this && this.__extends) || (function () {
13875 var extendStatics = function (d, b) {
13876 extendStatics = Object.setPrototypeOf ||
13877 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
13878 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
13879 return extendStatics(d, b);
13881 return function (d, b) {
13882 extendStatics(d, b);
13883 function __() { this.constructor = d; }
13884 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13887 Object.defineProperty(exports, "__esModule", { value: true });
13888 var Subscriber_1 = require("../Subscriber");
13889 function scan(accumulator, seed) {
13890 var hasSeed = false;
13891 if (arguments.length >= 2) {
13894 return function scanOperatorFunction(source) {
13895 return source.lift(new ScanOperator(accumulator, seed, hasSeed));
13898 exports.scan = scan;
13899 var ScanOperator = (function () {
13900 function ScanOperator(accumulator, seed, hasSeed) {
13901 if (hasSeed === void 0) { hasSeed = false; }
13902 this.accumulator = accumulator;
13904 this.hasSeed = hasSeed;
13906 ScanOperator.prototype.call = function (subscriber, source) {
13907 return source.subscribe(new ScanSubscriber(subscriber, this.accumulator, this.seed, this.hasSeed));
13909 return ScanOperator;
13911 var ScanSubscriber = (function (_super) {
13912 __extends(ScanSubscriber, _super);
13913 function ScanSubscriber(destination, accumulator, _seed, hasSeed) {
13914 var _this = _super.call(this, destination) || this;
13915 _this.accumulator = accumulator;
13916 _this._seed = _seed;
13917 _this.hasSeed = hasSeed;
13921 Object.defineProperty(ScanSubscriber.prototype, "seed", {
13925 set: function (value) {
13926 this.hasSeed = true;
13927 this._seed = value;
13932 ScanSubscriber.prototype._next = function (value) {
13933 if (!this.hasSeed) {
13935 this.destination.next(value);
13938 return this._tryNext(value);
13941 ScanSubscriber.prototype._tryNext = function (value) {
13942 var index = this.index++;
13945 result = this.accumulator(this.seed, value, index);
13948 this.destination.error(err);
13950 this.seed = result;
13951 this.destination.next(result);
13953 return ScanSubscriber;
13954 }(Subscriber_1.Subscriber));
13956 },{"../Subscriber":39}],142:[function(require,module,exports){
13958 var __extends = (this && this.__extends) || (function () {
13959 var extendStatics = function (d, b) {
13960 extendStatics = Object.setPrototypeOf ||
13961 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
13962 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
13963 return extendStatics(d, b);
13965 return function (d, b) {
13966 extendStatics(d, b);
13967 function __() { this.constructor = d; }
13968 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13971 Object.defineProperty(exports, "__esModule", { value: true });
13972 var Subscriber_1 = require("../Subscriber");
13973 var tryCatch_1 = require("../util/tryCatch");
13974 var errorObject_1 = require("../util/errorObject");
13975 function sequenceEqual(compareTo, comparor) {
13976 return function (source) { return source.lift(new SequenceEqualOperator(compareTo, comparor)); };
13978 exports.sequenceEqual = sequenceEqual;
13979 var SequenceEqualOperator = (function () {
13980 function SequenceEqualOperator(compareTo, comparor) {
13981 this.compareTo = compareTo;
13982 this.comparor = comparor;
13984 SequenceEqualOperator.prototype.call = function (subscriber, source) {
13985 return source.subscribe(new SequenceEqualSubscriber(subscriber, this.compareTo, this.comparor));
13987 return SequenceEqualOperator;
13989 exports.SequenceEqualOperator = SequenceEqualOperator;
13990 var SequenceEqualSubscriber = (function (_super) {
13991 __extends(SequenceEqualSubscriber, _super);
13992 function SequenceEqualSubscriber(destination, compareTo, comparor) {
13993 var _this = _super.call(this, destination) || this;
13994 _this.compareTo = compareTo;
13995 _this.comparor = comparor;
13998 _this._oneComplete = false;
13999 _this.destination.add(compareTo.subscribe(new SequenceEqualCompareToSubscriber(destination, _this)));
14002 SequenceEqualSubscriber.prototype._next = function (value) {
14003 if (this._oneComplete && this._b.length === 0) {
14007 this._a.push(value);
14008 this.checkValues();
14011 SequenceEqualSubscriber.prototype._complete = function () {
14012 if (this._oneComplete) {
14013 this.emit(this._a.length === 0 && this._b.length === 0);
14016 this._oneComplete = true;
14018 this.unsubscribe();
14020 SequenceEqualSubscriber.prototype.checkValues = function () {
14021 var _c = this, _a = _c._a, _b = _c._b, comparor = _c.comparor;
14022 while (_a.length > 0 && _b.length > 0) {
14023 var a = _a.shift();
14024 var b = _b.shift();
14025 var areEqual = false;
14027 areEqual = tryCatch_1.tryCatch(comparor)(a, b);
14028 if (areEqual === errorObject_1.errorObject) {
14029 this.destination.error(errorObject_1.errorObject.e);
14033 areEqual = a === b;
14040 SequenceEqualSubscriber.prototype.emit = function (value) {
14041 var destination = this.destination;
14042 destination.next(value);
14043 destination.complete();
14045 SequenceEqualSubscriber.prototype.nextB = function (value) {
14046 if (this._oneComplete && this._a.length === 0) {
14050 this._b.push(value);
14051 this.checkValues();
14054 SequenceEqualSubscriber.prototype.completeB = function () {
14055 if (this._oneComplete) {
14056 this.emit(this._a.length === 0 && this._b.length === 0);
14059 this._oneComplete = true;
14062 return SequenceEqualSubscriber;
14063 }(Subscriber_1.Subscriber));
14064 exports.SequenceEqualSubscriber = SequenceEqualSubscriber;
14065 var SequenceEqualCompareToSubscriber = (function (_super) {
14066 __extends(SequenceEqualCompareToSubscriber, _super);
14067 function SequenceEqualCompareToSubscriber(destination, parent) {
14068 var _this = _super.call(this, destination) || this;
14069 _this.parent = parent;
14072 SequenceEqualCompareToSubscriber.prototype._next = function (value) {
14073 this.parent.nextB(value);
14075 SequenceEqualCompareToSubscriber.prototype._error = function (err) {
14076 this.parent.error(err);
14077 this.unsubscribe();
14079 SequenceEqualCompareToSubscriber.prototype._complete = function () {
14080 this.parent.completeB();
14081 this.unsubscribe();
14083 return SequenceEqualCompareToSubscriber;
14084 }(Subscriber_1.Subscriber));
14086 },{"../Subscriber":39,"../util/errorObject":200,"../util/tryCatch":224}],143:[function(require,module,exports){
14088 Object.defineProperty(exports, "__esModule", { value: true });
14089 var multicast_1 = require("./multicast");
14090 var refCount_1 = require("./refCount");
14091 var Subject_1 = require("../Subject");
14092 function shareSubjectFactory() {
14093 return new Subject_1.Subject();
14096 return function (source) { return refCount_1.refCount()(multicast_1.multicast(shareSubjectFactory)(source)); };
14098 exports.share = share;
14100 },{"../Subject":37,"./multicast":122,"./refCount":134}],144:[function(require,module,exports){
14102 Object.defineProperty(exports, "__esModule", { value: true });
14103 var ReplaySubject_1 = require("../ReplaySubject");
14104 function shareReplay(bufferSize, windowTime, scheduler) {
14105 if (bufferSize === void 0) { bufferSize = Number.POSITIVE_INFINITY; }
14106 if (windowTime === void 0) { windowTime = Number.POSITIVE_INFINITY; }
14107 return function (source) { return source.lift(shareReplayOperator(bufferSize, windowTime, scheduler)); };
14109 exports.shareReplay = shareReplay;
14110 function shareReplayOperator(bufferSize, windowTime, scheduler) {
14114 var hasError = false;
14115 var isComplete = false;
14116 return function shareReplayOperation(source) {
14118 if (!subject || hasError) {
14120 subject = new ReplaySubject_1.ReplaySubject(bufferSize, windowTime, scheduler);
14121 subscription = source.subscribe({
14122 next: function (value) { subject.next(value); },
14123 error: function (err) {
14125 subject.error(err);
14127 complete: function () {
14129 subject.complete();
14133 var innerSub = subject.subscribe(this);
14134 return function () {
14136 innerSub.unsubscribe();
14137 if (subscription && refCount === 0 && isComplete) {
14138 subscription.unsubscribe();
14144 },{"../ReplaySubject":35}],145:[function(require,module,exports){
14146 var __extends = (this && this.__extends) || (function () {
14147 var extendStatics = function (d, b) {
14148 extendStatics = Object.setPrototypeOf ||
14149 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
14150 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
14151 return extendStatics(d, b);
14153 return function (d, b) {
14154 extendStatics(d, b);
14155 function __() { this.constructor = d; }
14156 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14159 Object.defineProperty(exports, "__esModule", { value: true });
14160 var Subscriber_1 = require("../Subscriber");
14161 var EmptyError_1 = require("../util/EmptyError");
14162 function single(predicate) {
14163 return function (source) { return source.lift(new SingleOperator(predicate, source)); };
14165 exports.single = single;
14166 var SingleOperator = (function () {
14167 function SingleOperator(predicate, source) {
14168 this.predicate = predicate;
14169 this.source = source;
14171 SingleOperator.prototype.call = function (subscriber, source) {
14172 return source.subscribe(new SingleSubscriber(subscriber, this.predicate, this.source));
14174 return SingleOperator;
14176 var SingleSubscriber = (function (_super) {
14177 __extends(SingleSubscriber, _super);
14178 function SingleSubscriber(destination, predicate, source) {
14179 var _this = _super.call(this, destination) || this;
14180 _this.predicate = predicate;
14181 _this.source = source;
14182 _this.seenValue = false;
14186 SingleSubscriber.prototype.applySingleValue = function (value) {
14187 if (this.seenValue) {
14188 this.destination.error('Sequence contains more than one element');
14191 this.seenValue = true;
14192 this.singleValue = value;
14195 SingleSubscriber.prototype._next = function (value) {
14196 var index = this.index++;
14197 if (this.predicate) {
14198 this.tryNext(value, index);
14201 this.applySingleValue(value);
14204 SingleSubscriber.prototype.tryNext = function (value, index) {
14206 if (this.predicate(value, index, this.source)) {
14207 this.applySingleValue(value);
14211 this.destination.error(err);
14214 SingleSubscriber.prototype._complete = function () {
14215 var destination = this.destination;
14216 if (this.index > 0) {
14217 destination.next(this.seenValue ? this.singleValue : undefined);
14218 destination.complete();
14221 destination.error(new EmptyError_1.EmptyError);
14224 return SingleSubscriber;
14225 }(Subscriber_1.Subscriber));
14227 },{"../Subscriber":39,"../util/EmptyError":194}],146:[function(require,module,exports){
14229 var __extends = (this && this.__extends) || (function () {
14230 var extendStatics = function (d, b) {
14231 extendStatics = Object.setPrototypeOf ||
14232 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
14233 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
14234 return extendStatics(d, b);
14236 return function (d, b) {
14237 extendStatics(d, b);
14238 function __() { this.constructor = d; }
14239 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14242 Object.defineProperty(exports, "__esModule", { value: true });
14243 var Subscriber_1 = require("../Subscriber");
14244 function skip(count) {
14245 return function (source) { return source.lift(new SkipOperator(count)); };
14247 exports.skip = skip;
14248 var SkipOperator = (function () {
14249 function SkipOperator(total) {
14250 this.total = total;
14252 SkipOperator.prototype.call = function (subscriber, source) {
14253 return source.subscribe(new SkipSubscriber(subscriber, this.total));
14255 return SkipOperator;
14257 var SkipSubscriber = (function (_super) {
14258 __extends(SkipSubscriber, _super);
14259 function SkipSubscriber(destination, total) {
14260 var _this = _super.call(this, destination) || this;
14261 _this.total = total;
14265 SkipSubscriber.prototype._next = function (x) {
14266 if (++this.count > this.total) {
14267 this.destination.next(x);
14270 return SkipSubscriber;
14271 }(Subscriber_1.Subscriber));
14273 },{"../Subscriber":39}],147:[function(require,module,exports){
14275 var __extends = (this && this.__extends) || (function () {
14276 var extendStatics = function (d, b) {
14277 extendStatics = Object.setPrototypeOf ||
14278 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
14279 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
14280 return extendStatics(d, b);
14282 return function (d, b) {
14283 extendStatics(d, b);
14284 function __() { this.constructor = d; }
14285 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14288 Object.defineProperty(exports, "__esModule", { value: true });
14289 var Subscriber_1 = require("../Subscriber");
14290 var ArgumentOutOfRangeError_1 = require("../util/ArgumentOutOfRangeError");
14291 function skipLast(count) {
14292 return function (source) { return source.lift(new SkipLastOperator(count)); };
14294 exports.skipLast = skipLast;
14295 var SkipLastOperator = (function () {
14296 function SkipLastOperator(_skipCount) {
14297 this._skipCount = _skipCount;
14298 if (this._skipCount < 0) {
14299 throw new ArgumentOutOfRangeError_1.ArgumentOutOfRangeError;
14302 SkipLastOperator.prototype.call = function (subscriber, source) {
14303 if (this._skipCount === 0) {
14304 return source.subscribe(new Subscriber_1.Subscriber(subscriber));
14307 return source.subscribe(new SkipLastSubscriber(subscriber, this._skipCount));
14310 return SkipLastOperator;
14312 var SkipLastSubscriber = (function (_super) {
14313 __extends(SkipLastSubscriber, _super);
14314 function SkipLastSubscriber(destination, _skipCount) {
14315 var _this = _super.call(this, destination) || this;
14316 _this._skipCount = _skipCount;
14318 _this._ring = new Array(_skipCount);
14321 SkipLastSubscriber.prototype._next = function (value) {
14322 var skipCount = this._skipCount;
14323 var count = this._count++;
14324 if (count < skipCount) {
14325 this._ring[count] = value;
14328 var currentIndex = count % skipCount;
14329 var ring = this._ring;
14330 var oldValue = ring[currentIndex];
14331 ring[currentIndex] = value;
14332 this.destination.next(oldValue);
14335 return SkipLastSubscriber;
14336 }(Subscriber_1.Subscriber));
14338 },{"../Subscriber":39,"../util/ArgumentOutOfRangeError":193}],148:[function(require,module,exports){
14340 var __extends = (this && this.__extends) || (function () {
14341 var extendStatics = function (d, b) {
14342 extendStatics = Object.setPrototypeOf ||
14343 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
14344 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
14345 return extendStatics(d, b);
14347 return function (d, b) {
14348 extendStatics(d, b);
14349 function __() { this.constructor = d; }
14350 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14353 Object.defineProperty(exports, "__esModule", { value: true });
14354 var OuterSubscriber_1 = require("../OuterSubscriber");
14355 var InnerSubscriber_1 = require("../InnerSubscriber");
14356 var subscribeToResult_1 = require("../util/subscribeToResult");
14357 function skipUntil(notifier) {
14358 return function (source) { return source.lift(new SkipUntilOperator(notifier)); };
14360 exports.skipUntil = skipUntil;
14361 var SkipUntilOperator = (function () {
14362 function SkipUntilOperator(notifier) {
14363 this.notifier = notifier;
14365 SkipUntilOperator.prototype.call = function (destination, source) {
14366 return source.subscribe(new SkipUntilSubscriber(destination, this.notifier));
14368 return SkipUntilOperator;
14370 var SkipUntilSubscriber = (function (_super) {
14371 __extends(SkipUntilSubscriber, _super);
14372 function SkipUntilSubscriber(destination, notifier) {
14373 var _this = _super.call(this, destination) || this;
14374 _this.hasValue = false;
14375 var innerSubscriber = new InnerSubscriber_1.InnerSubscriber(_this, undefined, undefined);
14376 _this.add(innerSubscriber);
14377 _this.innerSubscription = innerSubscriber;
14378 subscribeToResult_1.subscribeToResult(_this, notifier, undefined, undefined, innerSubscriber);
14381 SkipUntilSubscriber.prototype._next = function (value) {
14382 if (this.hasValue) {
14383 _super.prototype._next.call(this, value);
14386 SkipUntilSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
14387 this.hasValue = true;
14388 if (this.innerSubscription) {
14389 this.innerSubscription.unsubscribe();
14392 SkipUntilSubscriber.prototype.notifyComplete = function () {
14394 return SkipUntilSubscriber;
14395 }(OuterSubscriber_1.OuterSubscriber));
14397 },{"../InnerSubscriber":30,"../OuterSubscriber":34,"../util/subscribeToResult":222}],149:[function(require,module,exports){
14399 var __extends = (this && this.__extends) || (function () {
14400 var extendStatics = function (d, b) {
14401 extendStatics = Object.setPrototypeOf ||
14402 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
14403 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
14404 return extendStatics(d, b);
14406 return function (d, b) {
14407 extendStatics(d, b);
14408 function __() { this.constructor = d; }
14409 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14412 Object.defineProperty(exports, "__esModule", { value: true });
14413 var Subscriber_1 = require("../Subscriber");
14414 function skipWhile(predicate) {
14415 return function (source) { return source.lift(new SkipWhileOperator(predicate)); };
14417 exports.skipWhile = skipWhile;
14418 var SkipWhileOperator = (function () {
14419 function SkipWhileOperator(predicate) {
14420 this.predicate = predicate;
14422 SkipWhileOperator.prototype.call = function (subscriber, source) {
14423 return source.subscribe(new SkipWhileSubscriber(subscriber, this.predicate));
14425 return SkipWhileOperator;
14427 var SkipWhileSubscriber = (function (_super) {
14428 __extends(SkipWhileSubscriber, _super);
14429 function SkipWhileSubscriber(destination, predicate) {
14430 var _this = _super.call(this, destination) || this;
14431 _this.predicate = predicate;
14432 _this.skipping = true;
14436 SkipWhileSubscriber.prototype._next = function (value) {
14437 var destination = this.destination;
14438 if (this.skipping) {
14439 this.tryCallPredicate(value);
14441 if (!this.skipping) {
14442 destination.next(value);
14445 SkipWhileSubscriber.prototype.tryCallPredicate = function (value) {
14447 var result = this.predicate(value, this.index++);
14448 this.skipping = Boolean(result);
14451 this.destination.error(err);
14454 return SkipWhileSubscriber;
14455 }(Subscriber_1.Subscriber));
14457 },{"../Subscriber":39}],150:[function(require,module,exports){
14459 Object.defineProperty(exports, "__esModule", { value: true });
14460 var fromArray_1 = require("../observable/fromArray");
14461 var scalar_1 = require("../observable/scalar");
14462 var empty_1 = require("../observable/empty");
14463 var concat_1 = require("../observable/concat");
14464 var isScheduler_1 = require("../util/isScheduler");
14465 function startWith() {
14467 for (var _i = 0; _i < arguments.length; _i++) {
14468 array[_i] = arguments[_i];
14470 return function (source) {
14471 var scheduler = array[array.length - 1];
14472 if (isScheduler_1.isScheduler(scheduler)) {
14478 var len = array.length;
14479 if (len === 1 && !scheduler) {
14480 return concat_1.concat(scalar_1.scalar(array[0]), source);
14482 else if (len > 0) {
14483 return concat_1.concat(fromArray_1.fromArray(array, scheduler), source);
14486 return concat_1.concat(empty_1.empty(scheduler), source);
14490 exports.startWith = startWith;
14492 },{"../observable/concat":47,"../observable/empty":49,"../observable/fromArray":52,"../observable/scalar":68,"../util/isScheduler":213}],151:[function(require,module,exports){
14494 Object.defineProperty(exports, "__esModule", { value: true });
14495 var SubscribeOnObservable_1 = require("../observable/SubscribeOnObservable");
14496 function subscribeOn(scheduler, delay) {
14497 if (delay === void 0) { delay = 0; }
14498 return function subscribeOnOperatorFunction(source) {
14499 return source.lift(new SubscribeOnOperator(scheduler, delay));
14502 exports.subscribeOn = subscribeOn;
14503 var SubscribeOnOperator = (function () {
14504 function SubscribeOnOperator(scheduler, delay) {
14505 this.scheduler = scheduler;
14506 this.delay = delay;
14508 SubscribeOnOperator.prototype.call = function (subscriber, source) {
14509 return new SubscribeOnObservable_1.SubscribeOnObservable(source, this.delay, this.scheduler).subscribe(subscriber);
14511 return SubscribeOnOperator;
14514 },{"../observable/SubscribeOnObservable":43}],152:[function(require,module,exports){
14516 Object.defineProperty(exports, "__esModule", { value: true });
14517 var switchMap_1 = require("./switchMap");
14518 var identity_1 = require("../util/identity");
14519 function switchAll() {
14520 return switchMap_1.switchMap(identity_1.identity);
14522 exports.switchAll = switchAll;
14524 },{"../util/identity":202,"./switchMap":153}],153:[function(require,module,exports){
14526 var __extends = (this && this.__extends) || (function () {
14527 var extendStatics = function (d, b) {
14528 extendStatics = Object.setPrototypeOf ||
14529 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
14530 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
14531 return extendStatics(d, b);
14533 return function (d, b) {
14534 extendStatics(d, b);
14535 function __() { this.constructor = d; }
14536 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14539 Object.defineProperty(exports, "__esModule", { value: true });
14540 var OuterSubscriber_1 = require("../OuterSubscriber");
14541 var InnerSubscriber_1 = require("../InnerSubscriber");
14542 var subscribeToResult_1 = require("../util/subscribeToResult");
14543 var map_1 = require("./map");
14544 var from_1 = require("../observable/from");
14545 function switchMap(project, resultSelector) {
14546 if (typeof resultSelector === 'function') {
14547 return function (source) { return source.pipe(switchMap(function (a, i) { return from_1.from(project(a, i)).pipe(map_1.map(function (b, ii) { return resultSelector(a, b, i, ii); })); })); };
14549 return function (source) { return source.lift(new SwitchMapOperator(project)); };
14551 exports.switchMap = switchMap;
14552 var SwitchMapOperator = (function () {
14553 function SwitchMapOperator(project) {
14554 this.project = project;
14556 SwitchMapOperator.prototype.call = function (subscriber, source) {
14557 return source.subscribe(new SwitchMapSubscriber(subscriber, this.project));
14559 return SwitchMapOperator;
14561 var SwitchMapSubscriber = (function (_super) {
14562 __extends(SwitchMapSubscriber, _super);
14563 function SwitchMapSubscriber(destination, project) {
14564 var _this = _super.call(this, destination) || this;
14565 _this.project = project;
14569 SwitchMapSubscriber.prototype._next = function (value) {
14571 var index = this.index++;
14573 result = this.project(value, index);
14576 this.destination.error(error);
14579 this._innerSub(result, value, index);
14581 SwitchMapSubscriber.prototype._innerSub = function (result, value, index) {
14582 var innerSubscription = this.innerSubscription;
14583 if (innerSubscription) {
14584 innerSubscription.unsubscribe();
14586 var innerSubscriber = new InnerSubscriber_1.InnerSubscriber(this, undefined, undefined);
14587 var destination = this.destination;
14588 destination.add(innerSubscriber);
14589 this.innerSubscription = subscribeToResult_1.subscribeToResult(this, result, value, index, innerSubscriber);
14591 SwitchMapSubscriber.prototype._complete = function () {
14592 var innerSubscription = this.innerSubscription;
14593 if (!innerSubscription || innerSubscription.closed) {
14594 _super.prototype._complete.call(this);
14596 this.unsubscribe();
14598 SwitchMapSubscriber.prototype._unsubscribe = function () {
14599 this.innerSubscription = null;
14601 SwitchMapSubscriber.prototype.notifyComplete = function (innerSub) {
14602 var destination = this.destination;
14603 destination.remove(innerSub);
14604 this.innerSubscription = null;
14605 if (this.isStopped) {
14606 _super.prototype._complete.call(this);
14609 SwitchMapSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
14610 this.destination.next(innerValue);
14612 return SwitchMapSubscriber;
14613 }(OuterSubscriber_1.OuterSubscriber));
14615 },{"../InnerSubscriber":30,"../OuterSubscriber":34,"../observable/from":51,"../util/subscribeToResult":222,"./map":112}],154:[function(require,module,exports){
14617 Object.defineProperty(exports, "__esModule", { value: true });
14618 var switchMap_1 = require("./switchMap");
14619 function switchMapTo(innerObservable, resultSelector) {
14620 return resultSelector ? switchMap_1.switchMap(function () { return innerObservable; }, resultSelector) : switchMap_1.switchMap(function () { return innerObservable; });
14622 exports.switchMapTo = switchMapTo;
14624 },{"./switchMap":153}],155:[function(require,module,exports){
14626 var __extends = (this && this.__extends) || (function () {
14627 var extendStatics = function (d, b) {
14628 extendStatics = Object.setPrototypeOf ||
14629 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
14630 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
14631 return extendStatics(d, b);
14633 return function (d, b) {
14634 extendStatics(d, b);
14635 function __() { this.constructor = d; }
14636 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14639 Object.defineProperty(exports, "__esModule", { value: true });
14640 var Subscriber_1 = require("../Subscriber");
14641 var ArgumentOutOfRangeError_1 = require("../util/ArgumentOutOfRangeError");
14642 var empty_1 = require("../observable/empty");
14643 function take(count) {
14644 return function (source) {
14646 return empty_1.empty();
14649 return source.lift(new TakeOperator(count));
14653 exports.take = take;
14654 var TakeOperator = (function () {
14655 function TakeOperator(total) {
14656 this.total = total;
14657 if (this.total < 0) {
14658 throw new ArgumentOutOfRangeError_1.ArgumentOutOfRangeError;
14661 TakeOperator.prototype.call = function (subscriber, source) {
14662 return source.subscribe(new TakeSubscriber(subscriber, this.total));
14664 return TakeOperator;
14666 var TakeSubscriber = (function (_super) {
14667 __extends(TakeSubscriber, _super);
14668 function TakeSubscriber(destination, total) {
14669 var _this = _super.call(this, destination) || this;
14670 _this.total = total;
14674 TakeSubscriber.prototype._next = function (value) {
14675 var total = this.total;
14676 var count = ++this.count;
14677 if (count <= total) {
14678 this.destination.next(value);
14679 if (count === total) {
14680 this.destination.complete();
14681 this.unsubscribe();
14685 return TakeSubscriber;
14686 }(Subscriber_1.Subscriber));
14688 },{"../Subscriber":39,"../observable/empty":49,"../util/ArgumentOutOfRangeError":193}],156:[function(require,module,exports){
14690 var __extends = (this && this.__extends) || (function () {
14691 var extendStatics = function (d, b) {
14692 extendStatics = Object.setPrototypeOf ||
14693 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
14694 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
14695 return extendStatics(d, b);
14697 return function (d, b) {
14698 extendStatics(d, b);
14699 function __() { this.constructor = d; }
14700 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14703 Object.defineProperty(exports, "__esModule", { value: true });
14704 var Subscriber_1 = require("../Subscriber");
14705 var ArgumentOutOfRangeError_1 = require("../util/ArgumentOutOfRangeError");
14706 var empty_1 = require("../observable/empty");
14707 function takeLast(count) {
14708 return function takeLastOperatorFunction(source) {
14710 return empty_1.empty();
14713 return source.lift(new TakeLastOperator(count));
14717 exports.takeLast = takeLast;
14718 var TakeLastOperator = (function () {
14719 function TakeLastOperator(total) {
14720 this.total = total;
14721 if (this.total < 0) {
14722 throw new ArgumentOutOfRangeError_1.ArgumentOutOfRangeError;
14725 TakeLastOperator.prototype.call = function (subscriber, source) {
14726 return source.subscribe(new TakeLastSubscriber(subscriber, this.total));
14728 return TakeLastOperator;
14730 var TakeLastSubscriber = (function (_super) {
14731 __extends(TakeLastSubscriber, _super);
14732 function TakeLastSubscriber(destination, total) {
14733 var _this = _super.call(this, destination) || this;
14734 _this.total = total;
14735 _this.ring = new Array();
14739 TakeLastSubscriber.prototype._next = function (value) {
14740 var ring = this.ring;
14741 var total = this.total;
14742 var count = this.count++;
14743 if (ring.length < total) {
14747 var index = count % total;
14748 ring[index] = value;
14751 TakeLastSubscriber.prototype._complete = function () {
14752 var destination = this.destination;
14753 var count = this.count;
14755 var total = this.count >= this.total ? this.total : this.count;
14756 var ring = this.ring;
14757 for (var i = 0; i < total; i++) {
14758 var idx = (count++) % total;
14759 destination.next(ring[idx]);
14762 destination.complete();
14764 return TakeLastSubscriber;
14765 }(Subscriber_1.Subscriber));
14767 },{"../Subscriber":39,"../observable/empty":49,"../util/ArgumentOutOfRangeError":193}],157:[function(require,module,exports){
14769 var __extends = (this && this.__extends) || (function () {
14770 var extendStatics = function (d, b) {
14771 extendStatics = Object.setPrototypeOf ||
14772 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
14773 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
14774 return extendStatics(d, b);
14776 return function (d, b) {
14777 extendStatics(d, b);
14778 function __() { this.constructor = d; }
14779 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14782 Object.defineProperty(exports, "__esModule", { value: true });
14783 var OuterSubscriber_1 = require("../OuterSubscriber");
14784 var subscribeToResult_1 = require("../util/subscribeToResult");
14785 function takeUntil(notifier) {
14786 return function (source) { return source.lift(new TakeUntilOperator(notifier)); };
14788 exports.takeUntil = takeUntil;
14789 var TakeUntilOperator = (function () {
14790 function TakeUntilOperator(notifier) {
14791 this.notifier = notifier;
14793 TakeUntilOperator.prototype.call = function (subscriber, source) {
14794 var takeUntilSubscriber = new TakeUntilSubscriber(subscriber);
14795 var notifierSubscription = subscribeToResult_1.subscribeToResult(takeUntilSubscriber, this.notifier);
14796 if (notifierSubscription && !takeUntilSubscriber.seenValue) {
14797 takeUntilSubscriber.add(notifierSubscription);
14798 return source.subscribe(takeUntilSubscriber);
14800 return takeUntilSubscriber;
14802 return TakeUntilOperator;
14804 var TakeUntilSubscriber = (function (_super) {
14805 __extends(TakeUntilSubscriber, _super);
14806 function TakeUntilSubscriber(destination) {
14807 var _this = _super.call(this, destination) || this;
14808 _this.seenValue = false;
14811 TakeUntilSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
14812 this.seenValue = true;
14815 TakeUntilSubscriber.prototype.notifyComplete = function () {
14817 return TakeUntilSubscriber;
14818 }(OuterSubscriber_1.OuterSubscriber));
14820 },{"../OuterSubscriber":34,"../util/subscribeToResult":222}],158:[function(require,module,exports){
14822 var __extends = (this && this.__extends) || (function () {
14823 var extendStatics = function (d, b) {
14824 extendStatics = Object.setPrototypeOf ||
14825 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
14826 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
14827 return extendStatics(d, b);
14829 return function (d, b) {
14830 extendStatics(d, b);
14831 function __() { this.constructor = d; }
14832 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14835 Object.defineProperty(exports, "__esModule", { value: true });
14836 var Subscriber_1 = require("../Subscriber");
14837 function takeWhile(predicate) {
14838 return function (source) { return source.lift(new TakeWhileOperator(predicate)); };
14840 exports.takeWhile = takeWhile;
14841 var TakeWhileOperator = (function () {
14842 function TakeWhileOperator(predicate) {
14843 this.predicate = predicate;
14845 TakeWhileOperator.prototype.call = function (subscriber, source) {
14846 return source.subscribe(new TakeWhileSubscriber(subscriber, this.predicate));
14848 return TakeWhileOperator;
14850 var TakeWhileSubscriber = (function (_super) {
14851 __extends(TakeWhileSubscriber, _super);
14852 function TakeWhileSubscriber(destination, predicate) {
14853 var _this = _super.call(this, destination) || this;
14854 _this.predicate = predicate;
14858 TakeWhileSubscriber.prototype._next = function (value) {
14859 var destination = this.destination;
14862 result = this.predicate(value, this.index++);
14865 destination.error(err);
14868 this.nextOrComplete(value, result);
14870 TakeWhileSubscriber.prototype.nextOrComplete = function (value, predicateResult) {
14871 var destination = this.destination;
14872 if (Boolean(predicateResult)) {
14873 destination.next(value);
14876 destination.complete();
14879 return TakeWhileSubscriber;
14880 }(Subscriber_1.Subscriber));
14882 },{"../Subscriber":39}],159:[function(require,module,exports){
14884 var __extends = (this && this.__extends) || (function () {
14885 var extendStatics = function (d, b) {
14886 extendStatics = Object.setPrototypeOf ||
14887 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
14888 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
14889 return extendStatics(d, b);
14891 return function (d, b) {
14892 extendStatics(d, b);
14893 function __() { this.constructor = d; }
14894 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14897 Object.defineProperty(exports, "__esModule", { value: true });
14898 var Subscriber_1 = require("../Subscriber");
14899 var noop_1 = require("../util/noop");
14900 var isFunction_1 = require("../util/isFunction");
14901 function tap(nextOrObserver, error, complete) {
14902 return function tapOperatorFunction(source) {
14903 return source.lift(new DoOperator(nextOrObserver, error, complete));
14907 var DoOperator = (function () {
14908 function DoOperator(nextOrObserver, error, complete) {
14909 this.nextOrObserver = nextOrObserver;
14910 this.error = error;
14911 this.complete = complete;
14913 DoOperator.prototype.call = function (subscriber, source) {
14914 return source.subscribe(new TapSubscriber(subscriber, this.nextOrObserver, this.error, this.complete));
14918 var TapSubscriber = (function (_super) {
14919 __extends(TapSubscriber, _super);
14920 function TapSubscriber(destination, observerOrNext, error, complete) {
14921 var _this = _super.call(this, destination) || this;
14922 _this._tapNext = noop_1.noop;
14923 _this._tapError = noop_1.noop;
14924 _this._tapComplete = noop_1.noop;
14925 _this._tapError = error || noop_1.noop;
14926 _this._tapComplete = complete || noop_1.noop;
14927 if (isFunction_1.isFunction(observerOrNext)) {
14928 _this._context = _this;
14929 _this._tapNext = observerOrNext;
14931 else if (observerOrNext) {
14932 _this._context = observerOrNext;
14933 _this._tapNext = observerOrNext.next || noop_1.noop;
14934 _this._tapError = observerOrNext.error || noop_1.noop;
14935 _this._tapComplete = observerOrNext.complete || noop_1.noop;
14939 TapSubscriber.prototype._next = function (value) {
14941 this._tapNext.call(this._context, value);
14944 this.destination.error(err);
14947 this.destination.next(value);
14949 TapSubscriber.prototype._error = function (err) {
14951 this._tapError.call(this._context, err);
14954 this.destination.error(err);
14957 this.destination.error(err);
14959 TapSubscriber.prototype._complete = function () {
14961 this._tapComplete.call(this._context);
14964 this.destination.error(err);
14967 return this.destination.complete();
14969 return TapSubscriber;
14970 }(Subscriber_1.Subscriber));
14972 },{"../Subscriber":39,"../util/isFunction":206,"../util/noop":214}],160:[function(require,module,exports){
14974 var __extends = (this && this.__extends) || (function () {
14975 var extendStatics = function (d, b) {
14976 extendStatics = Object.setPrototypeOf ||
14977 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
14978 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
14979 return extendStatics(d, b);
14981 return function (d, b) {
14982 extendStatics(d, b);
14983 function __() { this.constructor = d; }
14984 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14987 Object.defineProperty(exports, "__esModule", { value: true });
14988 var OuterSubscriber_1 = require("../OuterSubscriber");
14989 var subscribeToResult_1 = require("../util/subscribeToResult");
14990 exports.defaultThrottleConfig = {
14994 function throttle(durationSelector, config) {
14995 if (config === void 0) { config = exports.defaultThrottleConfig; }
14996 return function (source) { return source.lift(new ThrottleOperator(durationSelector, config.leading, config.trailing)); };
14998 exports.throttle = throttle;
14999 var ThrottleOperator = (function () {
15000 function ThrottleOperator(durationSelector, leading, trailing) {
15001 this.durationSelector = durationSelector;
15002 this.leading = leading;
15003 this.trailing = trailing;
15005 ThrottleOperator.prototype.call = function (subscriber, source) {
15006 return source.subscribe(new ThrottleSubscriber(subscriber, this.durationSelector, this.leading, this.trailing));
15008 return ThrottleOperator;
15010 var ThrottleSubscriber = (function (_super) {
15011 __extends(ThrottleSubscriber, _super);
15012 function ThrottleSubscriber(destination, durationSelector, _leading, _trailing) {
15013 var _this = _super.call(this, destination) || this;
15014 _this.destination = destination;
15015 _this.durationSelector = durationSelector;
15016 _this._leading = _leading;
15017 _this._trailing = _trailing;
15018 _this._hasValue = false;
15021 ThrottleSubscriber.prototype._next = function (value) {
15022 this._hasValue = true;
15023 this._sendValue = value;
15024 if (!this._throttled) {
15025 if (this._leading) {
15029 this.throttle(value);
15033 ThrottleSubscriber.prototype.send = function () {
15034 var _a = this, _hasValue = _a._hasValue, _sendValue = _a._sendValue;
15036 this.destination.next(_sendValue);
15037 this.throttle(_sendValue);
15039 this._hasValue = false;
15040 this._sendValue = null;
15042 ThrottleSubscriber.prototype.throttle = function (value) {
15043 var duration = this.tryDurationSelector(value);
15045 this.add(this._throttled = subscribeToResult_1.subscribeToResult(this, duration));
15048 ThrottleSubscriber.prototype.tryDurationSelector = function (value) {
15050 return this.durationSelector(value);
15053 this.destination.error(err);
15057 ThrottleSubscriber.prototype.throttlingDone = function () {
15058 var _a = this, _throttled = _a._throttled, _trailing = _a._trailing;
15060 _throttled.unsubscribe();
15062 this._throttled = null;
15067 ThrottleSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
15068 this.throttlingDone();
15070 ThrottleSubscriber.prototype.notifyComplete = function () {
15071 this.throttlingDone();
15073 return ThrottleSubscriber;
15074 }(OuterSubscriber_1.OuterSubscriber));
15076 },{"../OuterSubscriber":34,"../util/subscribeToResult":222}],161:[function(require,module,exports){
15078 var __extends = (this && this.__extends) || (function () {
15079 var extendStatics = function (d, b) {
15080 extendStatics = Object.setPrototypeOf ||
15081 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
15082 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
15083 return extendStatics(d, b);
15085 return function (d, b) {
15086 extendStatics(d, b);
15087 function __() { this.constructor = d; }
15088 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15091 Object.defineProperty(exports, "__esModule", { value: true });
15092 var Subscriber_1 = require("../Subscriber");
15093 var async_1 = require("../scheduler/async");
15094 var throttle_1 = require("./throttle");
15095 function throttleTime(duration, scheduler, config) {
15096 if (scheduler === void 0) { scheduler = async_1.async; }
15097 if (config === void 0) { config = throttle_1.defaultThrottleConfig; }
15098 return function (source) { return source.lift(new ThrottleTimeOperator(duration, scheduler, config.leading, config.trailing)); };
15100 exports.throttleTime = throttleTime;
15101 var ThrottleTimeOperator = (function () {
15102 function ThrottleTimeOperator(duration, scheduler, leading, trailing) {
15103 this.duration = duration;
15104 this.scheduler = scheduler;
15105 this.leading = leading;
15106 this.trailing = trailing;
15108 ThrottleTimeOperator.prototype.call = function (subscriber, source) {
15109 return source.subscribe(new ThrottleTimeSubscriber(subscriber, this.duration, this.scheduler, this.leading, this.trailing));
15111 return ThrottleTimeOperator;
15113 var ThrottleTimeSubscriber = (function (_super) {
15114 __extends(ThrottleTimeSubscriber, _super);
15115 function ThrottleTimeSubscriber(destination, duration, scheduler, leading, trailing) {
15116 var _this = _super.call(this, destination) || this;
15117 _this.duration = duration;
15118 _this.scheduler = scheduler;
15119 _this.leading = leading;
15120 _this.trailing = trailing;
15121 _this._hasTrailingValue = false;
15122 _this._trailingValue = null;
15125 ThrottleTimeSubscriber.prototype._next = function (value) {
15126 if (this.throttled) {
15127 if (this.trailing) {
15128 this._trailingValue = value;
15129 this._hasTrailingValue = true;
15133 this.add(this.throttled = this.scheduler.schedule(dispatchNext, this.duration, { subscriber: this }));
15134 if (this.leading) {
15135 this.destination.next(value);
15139 ThrottleTimeSubscriber.prototype._complete = function () {
15140 if (this._hasTrailingValue) {
15141 this.destination.next(this._trailingValue);
15142 this.destination.complete();
15145 this.destination.complete();
15148 ThrottleTimeSubscriber.prototype.clearThrottle = function () {
15149 var throttled = this.throttled;
15151 if (this.trailing && this._hasTrailingValue) {
15152 this.destination.next(this._trailingValue);
15153 this._trailingValue = null;
15154 this._hasTrailingValue = false;
15156 throttled.unsubscribe();
15157 this.remove(throttled);
15158 this.throttled = null;
15161 return ThrottleTimeSubscriber;
15162 }(Subscriber_1.Subscriber));
15163 function dispatchNext(arg) {
15164 var subscriber = arg.subscriber;
15165 subscriber.clearThrottle();
15168 },{"../Subscriber":39,"../scheduler/async":188,"./throttle":160}],162:[function(require,module,exports){
15170 Object.defineProperty(exports, "__esModule", { value: true });
15171 var tap_1 = require("./tap");
15172 var EmptyError_1 = require("../util/EmptyError");
15173 exports.throwIfEmpty = function (errorFactory) {
15174 if (errorFactory === void 0) { errorFactory = defaultErrorFactory; }
15177 next: function () { this.hasValue = true; },
15178 complete: function () {
15179 if (!this.hasValue) {
15180 throw errorFactory();
15185 function defaultErrorFactory() {
15186 return new EmptyError_1.EmptyError();
15189 },{"../util/EmptyError":194,"./tap":159}],163:[function(require,module,exports){
15191 Object.defineProperty(exports, "__esModule", { value: true });
15192 var async_1 = require("../scheduler/async");
15193 var scan_1 = require("./scan");
15194 var defer_1 = require("../observable/defer");
15195 var map_1 = require("./map");
15196 function timeInterval(scheduler) {
15197 if (scheduler === void 0) { scheduler = async_1.async; }
15198 return function (source) { return defer_1.defer(function () {
15199 return source.pipe(scan_1.scan(function (_a, value) {
15200 var current = _a.current;
15201 return ({ value: value, current: scheduler.now(), last: current });
15202 }, { current: scheduler.now(), value: undefined, last: undefined }), map_1.map(function (_a) {
15203 var current = _a.current, last = _a.last, value = _a.value;
15204 return new TimeInterval(value, current - last);
15208 exports.timeInterval = timeInterval;
15209 var TimeInterval = (function () {
15210 function TimeInterval(value, interval) {
15211 this.value = value;
15212 this.interval = interval;
15214 return TimeInterval;
15216 exports.TimeInterval = TimeInterval;
15218 },{"../observable/defer":48,"../scheduler/async":188,"./map":112,"./scan":141}],164:[function(require,module,exports){
15220 Object.defineProperty(exports, "__esModule", { value: true });
15221 var async_1 = require("../scheduler/async");
15222 var TimeoutError_1 = require("../util/TimeoutError");
15223 var timeoutWith_1 = require("./timeoutWith");
15224 var throwError_1 = require("../observable/throwError");
15225 function timeout(due, scheduler) {
15226 if (scheduler === void 0) { scheduler = async_1.async; }
15227 return timeoutWith_1.timeoutWith(due, throwError_1.throwError(new TimeoutError_1.TimeoutError()), scheduler);
15229 exports.timeout = timeout;
15231 },{"../observable/throwError":69,"../scheduler/async":188,"../util/TimeoutError":197,"./timeoutWith":165}],165:[function(require,module,exports){
15233 var __extends = (this && this.__extends) || (function () {
15234 var extendStatics = function (d, b) {
15235 extendStatics = Object.setPrototypeOf ||
15236 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
15237 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
15238 return extendStatics(d, b);
15240 return function (d, b) {
15241 extendStatics(d, b);
15242 function __() { this.constructor = d; }
15243 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15246 Object.defineProperty(exports, "__esModule", { value: true });
15247 var async_1 = require("../scheduler/async");
15248 var isDate_1 = require("../util/isDate");
15249 var OuterSubscriber_1 = require("../OuterSubscriber");
15250 var subscribeToResult_1 = require("../util/subscribeToResult");
15251 function timeoutWith(due, withObservable, scheduler) {
15252 if (scheduler === void 0) { scheduler = async_1.async; }
15253 return function (source) {
15254 var absoluteTimeout = isDate_1.isDate(due);
15255 var waitFor = absoluteTimeout ? (+due - scheduler.now()) : Math.abs(due);
15256 return source.lift(new TimeoutWithOperator(waitFor, absoluteTimeout, withObservable, scheduler));
15259 exports.timeoutWith = timeoutWith;
15260 var TimeoutWithOperator = (function () {
15261 function TimeoutWithOperator(waitFor, absoluteTimeout, withObservable, scheduler) {
15262 this.waitFor = waitFor;
15263 this.absoluteTimeout = absoluteTimeout;
15264 this.withObservable = withObservable;
15265 this.scheduler = scheduler;
15267 TimeoutWithOperator.prototype.call = function (subscriber, source) {
15268 return source.subscribe(new TimeoutWithSubscriber(subscriber, this.absoluteTimeout, this.waitFor, this.withObservable, this.scheduler));
15270 return TimeoutWithOperator;
15272 var TimeoutWithSubscriber = (function (_super) {
15273 __extends(TimeoutWithSubscriber, _super);
15274 function TimeoutWithSubscriber(destination, absoluteTimeout, waitFor, withObservable, scheduler) {
15275 var _this = _super.call(this, destination) || this;
15276 _this.absoluteTimeout = absoluteTimeout;
15277 _this.waitFor = waitFor;
15278 _this.withObservable = withObservable;
15279 _this.scheduler = scheduler;
15280 _this.action = null;
15281 _this.scheduleTimeout();
15284 TimeoutWithSubscriber.dispatchTimeout = function (subscriber) {
15285 var withObservable = subscriber.withObservable;
15286 subscriber._unsubscribeAndRecycle();
15287 subscriber.add(subscribeToResult_1.subscribeToResult(subscriber, withObservable));
15289 TimeoutWithSubscriber.prototype.scheduleTimeout = function () {
15290 var action = this.action;
15292 this.action = action.schedule(this, this.waitFor);
15295 this.add(this.action = this.scheduler.schedule(TimeoutWithSubscriber.dispatchTimeout, this.waitFor, this));
15298 TimeoutWithSubscriber.prototype._next = function (value) {
15299 if (!this.absoluteTimeout) {
15300 this.scheduleTimeout();
15302 _super.prototype._next.call(this, value);
15304 TimeoutWithSubscriber.prototype._unsubscribe = function () {
15305 this.action = null;
15306 this.scheduler = null;
15307 this.withObservable = null;
15309 return TimeoutWithSubscriber;
15310 }(OuterSubscriber_1.OuterSubscriber));
15312 },{"../OuterSubscriber":34,"../scheduler/async":188,"../util/isDate":205,"../util/subscribeToResult":222}],166:[function(require,module,exports){
15314 Object.defineProperty(exports, "__esModule", { value: true });
15315 var async_1 = require("../scheduler/async");
15316 var map_1 = require("./map");
15317 function timestamp(scheduler) {
15318 if (scheduler === void 0) { scheduler = async_1.async; }
15319 return map_1.map(function (value) { return new Timestamp(value, scheduler.now()); });
15321 exports.timestamp = timestamp;
15322 var Timestamp = (function () {
15323 function Timestamp(value, timestamp) {
15324 this.value = value;
15325 this.timestamp = timestamp;
15329 exports.Timestamp = Timestamp;
15331 },{"../scheduler/async":188,"./map":112}],167:[function(require,module,exports){
15333 Object.defineProperty(exports, "__esModule", { value: true });
15334 var reduce_1 = require("./reduce");
15335 function toArrayReducer(arr, item, index) {
15342 function toArray() {
15343 return reduce_1.reduce(toArrayReducer, []);
15345 exports.toArray = toArray;
15347 },{"./reduce":133}],168:[function(require,module,exports){
15349 var __extends = (this && this.__extends) || (function () {
15350 var extendStatics = function (d, b) {
15351 extendStatics = Object.setPrototypeOf ||
15352 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
15353 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
15354 return extendStatics(d, b);
15356 return function (d, b) {
15357 extendStatics(d, b);
15358 function __() { this.constructor = d; }
15359 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15362 Object.defineProperty(exports, "__esModule", { value: true });
15363 var Subject_1 = require("../Subject");
15364 var OuterSubscriber_1 = require("../OuterSubscriber");
15365 var subscribeToResult_1 = require("../util/subscribeToResult");
15366 function window(windowBoundaries) {
15367 return function windowOperatorFunction(source) {
15368 return source.lift(new WindowOperator(windowBoundaries));
15371 exports.window = window;
15372 var WindowOperator = (function () {
15373 function WindowOperator(windowBoundaries) {
15374 this.windowBoundaries = windowBoundaries;
15376 WindowOperator.prototype.call = function (subscriber, source) {
15377 var windowSubscriber = new WindowSubscriber(subscriber);
15378 var sourceSubscription = source.subscribe(windowSubscriber);
15379 if (!sourceSubscription.closed) {
15380 windowSubscriber.add(subscribeToResult_1.subscribeToResult(windowSubscriber, this.windowBoundaries));
15382 return sourceSubscription;
15384 return WindowOperator;
15386 var WindowSubscriber = (function (_super) {
15387 __extends(WindowSubscriber, _super);
15388 function WindowSubscriber(destination) {
15389 var _this = _super.call(this, destination) || this;
15390 _this.window = new Subject_1.Subject();
15391 destination.next(_this.window);
15394 WindowSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
15397 WindowSubscriber.prototype.notifyError = function (error, innerSub) {
15398 this._error(error);
15400 WindowSubscriber.prototype.notifyComplete = function (innerSub) {
15403 WindowSubscriber.prototype._next = function (value) {
15404 this.window.next(value);
15406 WindowSubscriber.prototype._error = function (err) {
15407 this.window.error(err);
15408 this.destination.error(err);
15410 WindowSubscriber.prototype._complete = function () {
15411 this.window.complete();
15412 this.destination.complete();
15414 WindowSubscriber.prototype._unsubscribe = function () {
15415 this.window = null;
15417 WindowSubscriber.prototype.openWindow = function () {
15418 var prevWindow = this.window;
15420 prevWindow.complete();
15422 var destination = this.destination;
15423 var newWindow = this.window = new Subject_1.Subject();
15424 destination.next(newWindow);
15426 return WindowSubscriber;
15427 }(OuterSubscriber_1.OuterSubscriber));
15429 },{"../OuterSubscriber":34,"../Subject":37,"../util/subscribeToResult":222}],169:[function(require,module,exports){
15431 var __extends = (this && this.__extends) || (function () {
15432 var extendStatics = function (d, b) {
15433 extendStatics = Object.setPrototypeOf ||
15434 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
15435 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
15436 return extendStatics(d, b);
15438 return function (d, b) {
15439 extendStatics(d, b);
15440 function __() { this.constructor = d; }
15441 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15444 Object.defineProperty(exports, "__esModule", { value: true });
15445 var Subscriber_1 = require("../Subscriber");
15446 var Subject_1 = require("../Subject");
15447 function windowCount(windowSize, startWindowEvery) {
15448 if (startWindowEvery === void 0) { startWindowEvery = 0; }
15449 return function windowCountOperatorFunction(source) {
15450 return source.lift(new WindowCountOperator(windowSize, startWindowEvery));
15453 exports.windowCount = windowCount;
15454 var WindowCountOperator = (function () {
15455 function WindowCountOperator(windowSize, startWindowEvery) {
15456 this.windowSize = windowSize;
15457 this.startWindowEvery = startWindowEvery;
15459 WindowCountOperator.prototype.call = function (subscriber, source) {
15460 return source.subscribe(new WindowCountSubscriber(subscriber, this.windowSize, this.startWindowEvery));
15462 return WindowCountOperator;
15464 var WindowCountSubscriber = (function (_super) {
15465 __extends(WindowCountSubscriber, _super);
15466 function WindowCountSubscriber(destination, windowSize, startWindowEvery) {
15467 var _this = _super.call(this, destination) || this;
15468 _this.destination = destination;
15469 _this.windowSize = windowSize;
15470 _this.startWindowEvery = startWindowEvery;
15471 _this.windows = [new Subject_1.Subject()];
15473 destination.next(_this.windows[0]);
15476 WindowCountSubscriber.prototype._next = function (value) {
15477 var startWindowEvery = (this.startWindowEvery > 0) ? this.startWindowEvery : this.windowSize;
15478 var destination = this.destination;
15479 var windowSize = this.windowSize;
15480 var windows = this.windows;
15481 var len = windows.length;
15482 for (var i = 0; i < len && !this.closed; i++) {
15483 windows[i].next(value);
15485 var c = this.count - windowSize + 1;
15486 if (c >= 0 && c % startWindowEvery === 0 && !this.closed) {
15487 windows.shift().complete();
15489 if (++this.count % startWindowEvery === 0 && !this.closed) {
15490 var window_1 = new Subject_1.Subject();
15491 windows.push(window_1);
15492 destination.next(window_1);
15495 WindowCountSubscriber.prototype._error = function (err) {
15496 var windows = this.windows;
15498 while (windows.length > 0 && !this.closed) {
15499 windows.shift().error(err);
15502 this.destination.error(err);
15504 WindowCountSubscriber.prototype._complete = function () {
15505 var windows = this.windows;
15507 while (windows.length > 0 && !this.closed) {
15508 windows.shift().complete();
15511 this.destination.complete();
15513 WindowCountSubscriber.prototype._unsubscribe = function () {
15515 this.windows = null;
15517 return WindowCountSubscriber;
15518 }(Subscriber_1.Subscriber));
15520 },{"../Subject":37,"../Subscriber":39}],170:[function(require,module,exports){
15522 var __extends = (this && this.__extends) || (function () {
15523 var extendStatics = function (d, b) {
15524 extendStatics = Object.setPrototypeOf ||
15525 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
15526 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
15527 return extendStatics(d, b);
15529 return function (d, b) {
15530 extendStatics(d, b);
15531 function __() { this.constructor = d; }
15532 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15535 Object.defineProperty(exports, "__esModule", { value: true });
15536 var Subject_1 = require("../Subject");
15537 var async_1 = require("../scheduler/async");
15538 var Subscriber_1 = require("../Subscriber");
15539 var isNumeric_1 = require("../util/isNumeric");
15540 var isScheduler_1 = require("../util/isScheduler");
15541 function windowTime(windowTimeSpan) {
15542 var scheduler = async_1.async;
15543 var windowCreationInterval = null;
15544 var maxWindowSize = Number.POSITIVE_INFINITY;
15545 if (isScheduler_1.isScheduler(arguments[3])) {
15546 scheduler = arguments[3];
15548 if (isScheduler_1.isScheduler(arguments[2])) {
15549 scheduler = arguments[2];
15551 else if (isNumeric_1.isNumeric(arguments[2])) {
15552 maxWindowSize = arguments[2];
15554 if (isScheduler_1.isScheduler(arguments[1])) {
15555 scheduler = arguments[1];
15557 else if (isNumeric_1.isNumeric(arguments[1])) {
15558 windowCreationInterval = arguments[1];
15560 return function windowTimeOperatorFunction(source) {
15561 return source.lift(new WindowTimeOperator(windowTimeSpan, windowCreationInterval, maxWindowSize, scheduler));
15564 exports.windowTime = windowTime;
15565 var WindowTimeOperator = (function () {
15566 function WindowTimeOperator(windowTimeSpan, windowCreationInterval, maxWindowSize, scheduler) {
15567 this.windowTimeSpan = windowTimeSpan;
15568 this.windowCreationInterval = windowCreationInterval;
15569 this.maxWindowSize = maxWindowSize;
15570 this.scheduler = scheduler;
15572 WindowTimeOperator.prototype.call = function (subscriber, source) {
15573 return source.subscribe(new WindowTimeSubscriber(subscriber, this.windowTimeSpan, this.windowCreationInterval, this.maxWindowSize, this.scheduler));
15575 return WindowTimeOperator;
15577 var CountedSubject = (function (_super) {
15578 __extends(CountedSubject, _super);
15579 function CountedSubject() {
15580 var _this = _super !== null && _super.apply(this, arguments) || this;
15581 _this._numberOfNextedValues = 0;
15584 CountedSubject.prototype.next = function (value) {
15585 this._numberOfNextedValues++;
15586 _super.prototype.next.call(this, value);
15588 Object.defineProperty(CountedSubject.prototype, "numberOfNextedValues", {
15590 return this._numberOfNextedValues;
15595 return CountedSubject;
15596 }(Subject_1.Subject));
15597 var WindowTimeSubscriber = (function (_super) {
15598 __extends(WindowTimeSubscriber, _super);
15599 function WindowTimeSubscriber(destination, windowTimeSpan, windowCreationInterval, maxWindowSize, scheduler) {
15600 var _this = _super.call(this, destination) || this;
15601 _this.destination = destination;
15602 _this.windowTimeSpan = windowTimeSpan;
15603 _this.windowCreationInterval = windowCreationInterval;
15604 _this.maxWindowSize = maxWindowSize;
15605 _this.scheduler = scheduler;
15606 _this.windows = [];
15607 var window = _this.openWindow();
15608 if (windowCreationInterval !== null && windowCreationInterval >= 0) {
15609 var closeState = { subscriber: _this, window: window, context: null };
15610 var creationState = { windowTimeSpan: windowTimeSpan, windowCreationInterval: windowCreationInterval, subscriber: _this, scheduler: scheduler };
15611 _this.add(scheduler.schedule(dispatchWindowClose, windowTimeSpan, closeState));
15612 _this.add(scheduler.schedule(dispatchWindowCreation, windowCreationInterval, creationState));
15615 var timeSpanOnlyState = { subscriber: _this, window: window, windowTimeSpan: windowTimeSpan };
15616 _this.add(scheduler.schedule(dispatchWindowTimeSpanOnly, windowTimeSpan, timeSpanOnlyState));
15620 WindowTimeSubscriber.prototype._next = function (value) {
15621 var windows = this.windows;
15622 var len = windows.length;
15623 for (var i = 0; i < len; i++) {
15624 var window_1 = windows[i];
15625 if (!window_1.closed) {
15626 window_1.next(value);
15627 if (window_1.numberOfNextedValues >= this.maxWindowSize) {
15628 this.closeWindow(window_1);
15633 WindowTimeSubscriber.prototype._error = function (err) {
15634 var windows = this.windows;
15635 while (windows.length > 0) {
15636 windows.shift().error(err);
15638 this.destination.error(err);
15640 WindowTimeSubscriber.prototype._complete = function () {
15641 var windows = this.windows;
15642 while (windows.length > 0) {
15643 var window_2 = windows.shift();
15644 if (!window_2.closed) {
15645 window_2.complete();
15648 this.destination.complete();
15650 WindowTimeSubscriber.prototype.openWindow = function () {
15651 var window = new CountedSubject();
15652 this.windows.push(window);
15653 var destination = this.destination;
15654 destination.next(window);
15657 WindowTimeSubscriber.prototype.closeWindow = function (window) {
15659 var windows = this.windows;
15660 windows.splice(windows.indexOf(window), 1);
15662 return WindowTimeSubscriber;
15663 }(Subscriber_1.Subscriber));
15664 function dispatchWindowTimeSpanOnly(state) {
15665 var subscriber = state.subscriber, windowTimeSpan = state.windowTimeSpan, window = state.window;
15667 subscriber.closeWindow(window);
15669 state.window = subscriber.openWindow();
15670 this.schedule(state, windowTimeSpan);
15672 function dispatchWindowCreation(state) {
15673 var windowTimeSpan = state.windowTimeSpan, subscriber = state.subscriber, scheduler = state.scheduler, windowCreationInterval = state.windowCreationInterval;
15674 var window = subscriber.openWindow();
15676 var context = { action: action, subscription: null };
15677 var timeSpanState = { subscriber: subscriber, window: window, context: context };
15678 context.subscription = scheduler.schedule(dispatchWindowClose, windowTimeSpan, timeSpanState);
15679 action.add(context.subscription);
15680 action.schedule(state, windowCreationInterval);
15682 function dispatchWindowClose(state) {
15683 var subscriber = state.subscriber, window = state.window, context = state.context;
15684 if (context && context.action && context.subscription) {
15685 context.action.remove(context.subscription);
15687 subscriber.closeWindow(window);
15690 },{"../Subject":37,"../Subscriber":39,"../scheduler/async":188,"../util/isNumeric":209,"../util/isScheduler":213}],171:[function(require,module,exports){
15692 var __extends = (this && this.__extends) || (function () {
15693 var extendStatics = function (d, b) {
15694 extendStatics = Object.setPrototypeOf ||
15695 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
15696 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
15697 return extendStatics(d, b);
15699 return function (d, b) {
15700 extendStatics(d, b);
15701 function __() { this.constructor = d; }
15702 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15705 Object.defineProperty(exports, "__esModule", { value: true });
15706 var Subject_1 = require("../Subject");
15707 var Subscription_1 = require("../Subscription");
15708 var tryCatch_1 = require("../util/tryCatch");
15709 var errorObject_1 = require("../util/errorObject");
15710 var OuterSubscriber_1 = require("../OuterSubscriber");
15711 var subscribeToResult_1 = require("../util/subscribeToResult");
15712 function windowToggle(openings, closingSelector) {
15713 return function (source) { return source.lift(new WindowToggleOperator(openings, closingSelector)); };
15715 exports.windowToggle = windowToggle;
15716 var WindowToggleOperator = (function () {
15717 function WindowToggleOperator(openings, closingSelector) {
15718 this.openings = openings;
15719 this.closingSelector = closingSelector;
15721 WindowToggleOperator.prototype.call = function (subscriber, source) {
15722 return source.subscribe(new WindowToggleSubscriber(subscriber, this.openings, this.closingSelector));
15724 return WindowToggleOperator;
15726 var WindowToggleSubscriber = (function (_super) {
15727 __extends(WindowToggleSubscriber, _super);
15728 function WindowToggleSubscriber(destination, openings, closingSelector) {
15729 var _this = _super.call(this, destination) || this;
15730 _this.openings = openings;
15731 _this.closingSelector = closingSelector;
15732 _this.contexts = [];
15733 _this.add(_this.openSubscription = subscribeToResult_1.subscribeToResult(_this, openings, openings));
15736 WindowToggleSubscriber.prototype._next = function (value) {
15737 var contexts = this.contexts;
15739 var len = contexts.length;
15740 for (var i = 0; i < len; i++) {
15741 contexts[i].window.next(value);
15745 WindowToggleSubscriber.prototype._error = function (err) {
15746 var contexts = this.contexts;
15747 this.contexts = null;
15749 var len = contexts.length;
15751 while (++index < len) {
15752 var context_1 = contexts[index];
15753 context_1.window.error(err);
15754 context_1.subscription.unsubscribe();
15757 _super.prototype._error.call(this, err);
15759 WindowToggleSubscriber.prototype._complete = function () {
15760 var contexts = this.contexts;
15761 this.contexts = null;
15763 var len = contexts.length;
15765 while (++index < len) {
15766 var context_2 = contexts[index];
15767 context_2.window.complete();
15768 context_2.subscription.unsubscribe();
15771 _super.prototype._complete.call(this);
15773 WindowToggleSubscriber.prototype._unsubscribe = function () {
15774 var contexts = this.contexts;
15775 this.contexts = null;
15777 var len = contexts.length;
15779 while (++index < len) {
15780 var context_3 = contexts[index];
15781 context_3.window.unsubscribe();
15782 context_3.subscription.unsubscribe();
15786 WindowToggleSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
15787 if (outerValue === this.openings) {
15788 var closingSelector = this.closingSelector;
15789 var closingNotifier = tryCatch_1.tryCatch(closingSelector)(innerValue);
15790 if (closingNotifier === errorObject_1.errorObject) {
15791 return this.error(errorObject_1.errorObject.e);
15794 var window_1 = new Subject_1.Subject();
15795 var subscription = new Subscription_1.Subscription();
15796 var context_4 = { window: window_1, subscription: subscription };
15797 this.contexts.push(context_4);
15798 var innerSubscription = subscribeToResult_1.subscribeToResult(this, closingNotifier, context_4);
15799 if (innerSubscription.closed) {
15800 this.closeWindow(this.contexts.length - 1);
15803 innerSubscription.context = context_4;
15804 subscription.add(innerSubscription);
15806 this.destination.next(window_1);
15810 this.closeWindow(this.contexts.indexOf(outerValue));
15813 WindowToggleSubscriber.prototype.notifyError = function (err) {
15816 WindowToggleSubscriber.prototype.notifyComplete = function (inner) {
15817 if (inner !== this.openSubscription) {
15818 this.closeWindow(this.contexts.indexOf(inner.context));
15821 WindowToggleSubscriber.prototype.closeWindow = function (index) {
15822 if (index === -1) {
15825 var contexts = this.contexts;
15826 var context = contexts[index];
15827 var window = context.window, subscription = context.subscription;
15828 contexts.splice(index, 1);
15830 subscription.unsubscribe();
15832 return WindowToggleSubscriber;
15833 }(OuterSubscriber_1.OuterSubscriber));
15835 },{"../OuterSubscriber":34,"../Subject":37,"../Subscription":40,"../util/errorObject":200,"../util/subscribeToResult":222,"../util/tryCatch":224}],172:[function(require,module,exports){
15837 var __extends = (this && this.__extends) || (function () {
15838 var extendStatics = function (d, b) {
15839 extendStatics = Object.setPrototypeOf ||
15840 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
15841 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
15842 return extendStatics(d, b);
15844 return function (d, b) {
15845 extendStatics(d, b);
15846 function __() { this.constructor = d; }
15847 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15850 Object.defineProperty(exports, "__esModule", { value: true });
15851 var Subject_1 = require("../Subject");
15852 var tryCatch_1 = require("../util/tryCatch");
15853 var errorObject_1 = require("../util/errorObject");
15854 var OuterSubscriber_1 = require("../OuterSubscriber");
15855 var subscribeToResult_1 = require("../util/subscribeToResult");
15856 function windowWhen(closingSelector) {
15857 return function windowWhenOperatorFunction(source) {
15858 return source.lift(new WindowOperator(closingSelector));
15861 exports.windowWhen = windowWhen;
15862 var WindowOperator = (function () {
15863 function WindowOperator(closingSelector) {
15864 this.closingSelector = closingSelector;
15866 WindowOperator.prototype.call = function (subscriber, source) {
15867 return source.subscribe(new WindowSubscriber(subscriber, this.closingSelector));
15869 return WindowOperator;
15871 var WindowSubscriber = (function (_super) {
15872 __extends(WindowSubscriber, _super);
15873 function WindowSubscriber(destination, closingSelector) {
15874 var _this = _super.call(this, destination) || this;
15875 _this.destination = destination;
15876 _this.closingSelector = closingSelector;
15877 _this.openWindow();
15880 WindowSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
15881 this.openWindow(innerSub);
15883 WindowSubscriber.prototype.notifyError = function (error, innerSub) {
15884 this._error(error);
15886 WindowSubscriber.prototype.notifyComplete = function (innerSub) {
15887 this.openWindow(innerSub);
15889 WindowSubscriber.prototype._next = function (value) {
15890 this.window.next(value);
15892 WindowSubscriber.prototype._error = function (err) {
15893 this.window.error(err);
15894 this.destination.error(err);
15895 this.unsubscribeClosingNotification();
15897 WindowSubscriber.prototype._complete = function () {
15898 this.window.complete();
15899 this.destination.complete();
15900 this.unsubscribeClosingNotification();
15902 WindowSubscriber.prototype.unsubscribeClosingNotification = function () {
15903 if (this.closingNotification) {
15904 this.closingNotification.unsubscribe();
15907 WindowSubscriber.prototype.openWindow = function (innerSub) {
15908 if (innerSub === void 0) { innerSub = null; }
15910 this.remove(innerSub);
15911 innerSub.unsubscribe();
15913 var prevWindow = this.window;
15915 prevWindow.complete();
15917 var window = this.window = new Subject_1.Subject();
15918 this.destination.next(window);
15919 var closingNotifier = tryCatch_1.tryCatch(this.closingSelector)();
15920 if (closingNotifier === errorObject_1.errorObject) {
15921 var err = errorObject_1.errorObject.e;
15922 this.destination.error(err);
15923 this.window.error(err);
15926 this.add(this.closingNotification = subscribeToResult_1.subscribeToResult(this, closingNotifier));
15929 return WindowSubscriber;
15930 }(OuterSubscriber_1.OuterSubscriber));
15932 },{"../OuterSubscriber":34,"../Subject":37,"../util/errorObject":200,"../util/subscribeToResult":222,"../util/tryCatch":224}],173:[function(require,module,exports){
15934 var __extends = (this && this.__extends) || (function () {
15935 var extendStatics = function (d, b) {
15936 extendStatics = Object.setPrototypeOf ||
15937 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
15938 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
15939 return extendStatics(d, b);
15941 return function (d, b) {
15942 extendStatics(d, b);
15943 function __() { this.constructor = d; }
15944 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15947 Object.defineProperty(exports, "__esModule", { value: true });
15948 var OuterSubscriber_1 = require("../OuterSubscriber");
15949 var subscribeToResult_1 = require("../util/subscribeToResult");
15950 function withLatestFrom() {
15952 for (var _i = 0; _i < arguments.length; _i++) {
15953 args[_i] = arguments[_i];
15955 return function (source) {
15957 if (typeof args[args.length - 1] === 'function') {
15958 project = args.pop();
15960 var observables = args;
15961 return source.lift(new WithLatestFromOperator(observables, project));
15964 exports.withLatestFrom = withLatestFrom;
15965 var WithLatestFromOperator = (function () {
15966 function WithLatestFromOperator(observables, project) {
15967 this.observables = observables;
15968 this.project = project;
15970 WithLatestFromOperator.prototype.call = function (subscriber, source) {
15971 return source.subscribe(new WithLatestFromSubscriber(subscriber, this.observables, this.project));
15973 return WithLatestFromOperator;
15975 var WithLatestFromSubscriber = (function (_super) {
15976 __extends(WithLatestFromSubscriber, _super);
15977 function WithLatestFromSubscriber(destination, observables, project) {
15978 var _this = _super.call(this, destination) || this;
15979 _this.observables = observables;
15980 _this.project = project;
15981 _this.toRespond = [];
15982 var len = observables.length;
15983 _this.values = new Array(len);
15984 for (var i = 0; i < len; i++) {
15985 _this.toRespond.push(i);
15987 for (var i = 0; i < len; i++) {
15988 var observable = observables[i];
15989 _this.add(subscribeToResult_1.subscribeToResult(_this, observable, observable, i));
15993 WithLatestFromSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
15994 this.values[outerIndex] = innerValue;
15995 var toRespond = this.toRespond;
15996 if (toRespond.length > 0) {
15997 var found = toRespond.indexOf(outerIndex);
15998 if (found !== -1) {
15999 toRespond.splice(found, 1);
16003 WithLatestFromSubscriber.prototype.notifyComplete = function () {
16005 WithLatestFromSubscriber.prototype._next = function (value) {
16006 if (this.toRespond.length === 0) {
16007 var args = [value].concat(this.values);
16008 if (this.project) {
16009 this._tryProject(args);
16012 this.destination.next(args);
16016 WithLatestFromSubscriber.prototype._tryProject = function (args) {
16019 result = this.project.apply(this, args);
16022 this.destination.error(err);
16025 this.destination.next(result);
16027 return WithLatestFromSubscriber;
16028 }(OuterSubscriber_1.OuterSubscriber));
16030 },{"../OuterSubscriber":34,"../util/subscribeToResult":222}],174:[function(require,module,exports){
16032 Object.defineProperty(exports, "__esModule", { value: true });
16033 var zip_1 = require("../observable/zip");
16035 var observables = [];
16036 for (var _i = 0; _i < arguments.length; _i++) {
16037 observables[_i] = arguments[_i];
16039 return function zipOperatorFunction(source) {
16040 return source.lift.call(zip_1.zip.apply(void 0, [source].concat(observables)));
16045 },{"../observable/zip":72}],175:[function(require,module,exports){
16047 Object.defineProperty(exports, "__esModule", { value: true });
16048 var zip_1 = require("../observable/zip");
16049 function zipAll(project) {
16050 return function (source) { return source.lift(new zip_1.ZipOperator(project)); };
16052 exports.zipAll = zipAll;
16054 },{"../observable/zip":72}],176:[function(require,module,exports){
16056 var __extends = (this && this.__extends) || (function () {
16057 var extendStatics = function (d, b) {
16058 extendStatics = Object.setPrototypeOf ||
16059 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
16060 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
16061 return extendStatics(d, b);
16063 return function (d, b) {
16064 extendStatics(d, b);
16065 function __() { this.constructor = d; }
16066 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
16069 Object.defineProperty(exports, "__esModule", { value: true });
16070 var Subscription_1 = require("../Subscription");
16071 var Action = (function (_super) {
16072 __extends(Action, _super);
16073 function Action(scheduler, work) {
16074 return _super.call(this) || this;
16076 Action.prototype.schedule = function (state, delay) {
16077 if (delay === void 0) { delay = 0; }
16081 }(Subscription_1.Subscription));
16082 exports.Action = Action;
16084 },{"../Subscription":40}],177:[function(require,module,exports){
16086 var __extends = (this && this.__extends) || (function () {
16087 var extendStatics = function (d, b) {
16088 extendStatics = Object.setPrototypeOf ||
16089 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
16090 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
16091 return extendStatics(d, b);
16093 return function (d, b) {
16094 extendStatics(d, b);
16095 function __() { this.constructor = d; }
16096 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
16099 Object.defineProperty(exports, "__esModule", { value: true });
16100 var AsyncAction_1 = require("./AsyncAction");
16101 var AnimationFrameAction = (function (_super) {
16102 __extends(AnimationFrameAction, _super);
16103 function AnimationFrameAction(scheduler, work) {
16104 var _this = _super.call(this, scheduler, work) || this;
16105 _this.scheduler = scheduler;
16109 AnimationFrameAction.prototype.requestAsyncId = function (scheduler, id, delay) {
16110 if (delay === void 0) { delay = 0; }
16111 if (delay !== null && delay > 0) {
16112 return _super.prototype.requestAsyncId.call(this, scheduler, id, delay);
16114 scheduler.actions.push(this);
16115 return scheduler.scheduled || (scheduler.scheduled = requestAnimationFrame(function () { return scheduler.flush(null); }));
16117 AnimationFrameAction.prototype.recycleAsyncId = function (scheduler, id, delay) {
16118 if (delay === void 0) { delay = 0; }
16119 if ((delay !== null && delay > 0) || (delay === null && this.delay > 0)) {
16120 return _super.prototype.recycleAsyncId.call(this, scheduler, id, delay);
16122 if (scheduler.actions.length === 0) {
16123 cancelAnimationFrame(id);
16124 scheduler.scheduled = undefined;
16128 return AnimationFrameAction;
16129 }(AsyncAction_1.AsyncAction));
16130 exports.AnimationFrameAction = AnimationFrameAction;
16132 },{"./AsyncAction":181}],178:[function(require,module,exports){
16134 var __extends = (this && this.__extends) || (function () {
16135 var extendStatics = function (d, b) {
16136 extendStatics = Object.setPrototypeOf ||
16137 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
16138 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
16139 return extendStatics(d, b);
16141 return function (d, b) {
16142 extendStatics(d, b);
16143 function __() { this.constructor = d; }
16144 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
16147 Object.defineProperty(exports, "__esModule", { value: true });
16148 var AsyncScheduler_1 = require("./AsyncScheduler");
16149 var AnimationFrameScheduler = (function (_super) {
16150 __extends(AnimationFrameScheduler, _super);
16151 function AnimationFrameScheduler() {
16152 return _super !== null && _super.apply(this, arguments) || this;
16154 AnimationFrameScheduler.prototype.flush = function (action) {
16155 this.active = true;
16156 this.scheduled = undefined;
16157 var actions = this.actions;
16160 var count = actions.length;
16161 action = action || actions.shift();
16163 if (error = action.execute(action.state, action.delay)) {
16166 } while (++index < count && (action = actions.shift()));
16167 this.active = false;
16169 while (++index < count && (action = actions.shift())) {
16170 action.unsubscribe();
16175 return AnimationFrameScheduler;
16176 }(AsyncScheduler_1.AsyncScheduler));
16177 exports.AnimationFrameScheduler = AnimationFrameScheduler;
16179 },{"./AsyncScheduler":182}],179:[function(require,module,exports){
16181 var __extends = (this && this.__extends) || (function () {
16182 var extendStatics = function (d, b) {
16183 extendStatics = Object.setPrototypeOf ||
16184 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
16185 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
16186 return extendStatics(d, b);
16188 return function (d, b) {
16189 extendStatics(d, b);
16190 function __() { this.constructor = d; }
16191 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
16194 Object.defineProperty(exports, "__esModule", { value: true });
16195 var Immediate_1 = require("../util/Immediate");
16196 var AsyncAction_1 = require("./AsyncAction");
16197 var AsapAction = (function (_super) {
16198 __extends(AsapAction, _super);
16199 function AsapAction(scheduler, work) {
16200 var _this = _super.call(this, scheduler, work) || this;
16201 _this.scheduler = scheduler;
16205 AsapAction.prototype.requestAsyncId = function (scheduler, id, delay) {
16206 if (delay === void 0) { delay = 0; }
16207 if (delay !== null && delay > 0) {
16208 return _super.prototype.requestAsyncId.call(this, scheduler, id, delay);
16210 scheduler.actions.push(this);
16211 return scheduler.scheduled || (scheduler.scheduled = Immediate_1.Immediate.setImmediate(scheduler.flush.bind(scheduler, null)));
16213 AsapAction.prototype.recycleAsyncId = function (scheduler, id, delay) {
16214 if (delay === void 0) { delay = 0; }
16215 if ((delay !== null && delay > 0) || (delay === null && this.delay > 0)) {
16216 return _super.prototype.recycleAsyncId.call(this, scheduler, id, delay);
16218 if (scheduler.actions.length === 0) {
16219 Immediate_1.Immediate.clearImmediate(id);
16220 scheduler.scheduled = undefined;
16225 }(AsyncAction_1.AsyncAction));
16226 exports.AsapAction = AsapAction;
16228 },{"../util/Immediate":195,"./AsyncAction":181}],180:[function(require,module,exports){
16230 var __extends = (this && this.__extends) || (function () {
16231 var extendStatics = function (d, b) {
16232 extendStatics = Object.setPrototypeOf ||
16233 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
16234 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
16235 return extendStatics(d, b);
16237 return function (d, b) {
16238 extendStatics(d, b);
16239 function __() { this.constructor = d; }
16240 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
16243 Object.defineProperty(exports, "__esModule", { value: true });
16244 var AsyncScheduler_1 = require("./AsyncScheduler");
16245 var AsapScheduler = (function (_super) {
16246 __extends(AsapScheduler, _super);
16247 function AsapScheduler() {
16248 return _super !== null && _super.apply(this, arguments) || this;
16250 AsapScheduler.prototype.flush = function (action) {
16251 this.active = true;
16252 this.scheduled = undefined;
16253 var actions = this.actions;
16256 var count = actions.length;
16257 action = action || actions.shift();
16259 if (error = action.execute(action.state, action.delay)) {
16262 } while (++index < count && (action = actions.shift()));
16263 this.active = false;
16265 while (++index < count && (action = actions.shift())) {
16266 action.unsubscribe();
16271 return AsapScheduler;
16272 }(AsyncScheduler_1.AsyncScheduler));
16273 exports.AsapScheduler = AsapScheduler;
16275 },{"./AsyncScheduler":182}],181:[function(require,module,exports){
16277 var __extends = (this && this.__extends) || (function () {
16278 var extendStatics = function (d, b) {
16279 extendStatics = Object.setPrototypeOf ||
16280 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
16281 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
16282 return extendStatics(d, b);
16284 return function (d, b) {
16285 extendStatics(d, b);
16286 function __() { this.constructor = d; }
16287 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
16290 Object.defineProperty(exports, "__esModule", { value: true });
16291 var Action_1 = require("./Action");
16292 var AsyncAction = (function (_super) {
16293 __extends(AsyncAction, _super);
16294 function AsyncAction(scheduler, work) {
16295 var _this = _super.call(this, scheduler, work) || this;
16296 _this.scheduler = scheduler;
16298 _this.pending = false;
16301 AsyncAction.prototype.schedule = function (state, delay) {
16302 if (delay === void 0) { delay = 0; }
16306 this.state = state;
16308 var scheduler = this.scheduler;
16310 this.id = this.recycleAsyncId(scheduler, id, delay);
16312 this.pending = true;
16313 this.delay = delay;
16314 this.id = this.id || this.requestAsyncId(scheduler, this.id, delay);
16317 AsyncAction.prototype.requestAsyncId = function (scheduler, id, delay) {
16318 if (delay === void 0) { delay = 0; }
16319 return setInterval(scheduler.flush.bind(scheduler, this), delay);
16321 AsyncAction.prototype.recycleAsyncId = function (scheduler, id, delay) {
16322 if (delay === void 0) { delay = 0; }
16323 if (delay !== null && this.delay === delay && this.pending === false) {
16328 AsyncAction.prototype.execute = function (state, delay) {
16330 return new Error('executing a cancelled action');
16332 this.pending = false;
16333 var error = this._execute(state, delay);
16337 else if (this.pending === false && this.id != null) {
16338 this.id = this.recycleAsyncId(this.scheduler, this.id, null);
16341 AsyncAction.prototype._execute = function (state, delay) {
16342 var errored = false;
16343 var errorValue = undefined;
16349 errorValue = !!e && e || new Error(e);
16352 this.unsubscribe();
16356 AsyncAction.prototype._unsubscribe = function () {
16358 var scheduler = this.scheduler;
16359 var actions = scheduler.actions;
16360 var index = actions.indexOf(this);
16363 this.pending = false;
16364 this.scheduler = null;
16365 if (index !== -1) {
16366 actions.splice(index, 1);
16369 this.id = this.recycleAsyncId(scheduler, id, null);
16373 return AsyncAction;
16374 }(Action_1.Action));
16375 exports.AsyncAction = AsyncAction;
16377 },{"./Action":176}],182:[function(require,module,exports){
16379 var __extends = (this && this.__extends) || (function () {
16380 var extendStatics = function (d, b) {
16381 extendStatics = Object.setPrototypeOf ||
16382 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
16383 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
16384 return extendStatics(d, b);
16386 return function (d, b) {
16387 extendStatics(d, b);
16388 function __() { this.constructor = d; }
16389 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
16392 Object.defineProperty(exports, "__esModule", { value: true });
16393 var Scheduler_1 = require("../Scheduler");
16394 var AsyncScheduler = (function (_super) {
16395 __extends(AsyncScheduler, _super);
16396 function AsyncScheduler(SchedulerAction, now) {
16397 if (now === void 0) { now = Scheduler_1.Scheduler.now; }
16398 var _this = _super.call(this, SchedulerAction, function () {
16399 if (AsyncScheduler.delegate && AsyncScheduler.delegate !== _this) {
16400 return AsyncScheduler.delegate.now();
16406 _this.actions = [];
16407 _this.active = false;
16408 _this.scheduled = undefined;
16411 AsyncScheduler.prototype.schedule = function (work, delay, state) {
16412 if (delay === void 0) { delay = 0; }
16413 if (AsyncScheduler.delegate && AsyncScheduler.delegate !== this) {
16414 return AsyncScheduler.delegate.schedule(work, delay, state);
16417 return _super.prototype.schedule.call(this, work, delay, state);
16420 AsyncScheduler.prototype.flush = function (action) {
16421 var actions = this.actions;
16423 actions.push(action);
16427 this.active = true;
16429 if (error = action.execute(action.state, action.delay)) {
16432 } while (action = actions.shift());
16433 this.active = false;
16435 while (action = actions.shift()) {
16436 action.unsubscribe();
16441 return AsyncScheduler;
16442 }(Scheduler_1.Scheduler));
16443 exports.AsyncScheduler = AsyncScheduler;
16445 },{"../Scheduler":36}],183:[function(require,module,exports){
16447 var __extends = (this && this.__extends) || (function () {
16448 var extendStatics = function (d, b) {
16449 extendStatics = Object.setPrototypeOf ||
16450 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
16451 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
16452 return extendStatics(d, b);
16454 return function (d, b) {
16455 extendStatics(d, b);
16456 function __() { this.constructor = d; }
16457 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
16460 Object.defineProperty(exports, "__esModule", { value: true });
16461 var AsyncAction_1 = require("./AsyncAction");
16462 var QueueAction = (function (_super) {
16463 __extends(QueueAction, _super);
16464 function QueueAction(scheduler, work) {
16465 var _this = _super.call(this, scheduler, work) || this;
16466 _this.scheduler = scheduler;
16470 QueueAction.prototype.schedule = function (state, delay) {
16471 if (delay === void 0) { delay = 0; }
16473 return _super.prototype.schedule.call(this, state, delay);
16475 this.delay = delay;
16476 this.state = state;
16477 this.scheduler.flush(this);
16480 QueueAction.prototype.execute = function (state, delay) {
16481 return (delay > 0 || this.closed) ?
16482 _super.prototype.execute.call(this, state, delay) :
16483 this._execute(state, delay);
16485 QueueAction.prototype.requestAsyncId = function (scheduler, id, delay) {
16486 if (delay === void 0) { delay = 0; }
16487 if ((delay !== null && delay > 0) || (delay === null && this.delay > 0)) {
16488 return _super.prototype.requestAsyncId.call(this, scheduler, id, delay);
16490 return scheduler.flush(this);
16492 return QueueAction;
16493 }(AsyncAction_1.AsyncAction));
16494 exports.QueueAction = QueueAction;
16496 },{"./AsyncAction":181}],184:[function(require,module,exports){
16498 var __extends = (this && this.__extends) || (function () {
16499 var extendStatics = function (d, b) {
16500 extendStatics = Object.setPrototypeOf ||
16501 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
16502 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
16503 return extendStatics(d, b);
16505 return function (d, b) {
16506 extendStatics(d, b);
16507 function __() { this.constructor = d; }
16508 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
16511 Object.defineProperty(exports, "__esModule", { value: true });
16512 var AsyncScheduler_1 = require("./AsyncScheduler");
16513 var QueueScheduler = (function (_super) {
16514 __extends(QueueScheduler, _super);
16515 function QueueScheduler() {
16516 return _super !== null && _super.apply(this, arguments) || this;
16518 return QueueScheduler;
16519 }(AsyncScheduler_1.AsyncScheduler));
16520 exports.QueueScheduler = QueueScheduler;
16522 },{"./AsyncScheduler":182}],185:[function(require,module,exports){
16524 var __extends = (this && this.__extends) || (function () {
16525 var extendStatics = function (d, b) {
16526 extendStatics = Object.setPrototypeOf ||
16527 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
16528 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
16529 return extendStatics(d, b);
16531 return function (d, b) {
16532 extendStatics(d, b);
16533 function __() { this.constructor = d; }
16534 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
16537 Object.defineProperty(exports, "__esModule", { value: true });
16538 var AsyncAction_1 = require("./AsyncAction");
16539 var AsyncScheduler_1 = require("./AsyncScheduler");
16540 var VirtualTimeScheduler = (function (_super) {
16541 __extends(VirtualTimeScheduler, _super);
16542 function VirtualTimeScheduler(SchedulerAction, maxFrames) {
16543 if (SchedulerAction === void 0) { SchedulerAction = VirtualAction; }
16544 if (maxFrames === void 0) { maxFrames = Number.POSITIVE_INFINITY; }
16545 var _this = _super.call(this, SchedulerAction, function () { return _this.frame; }) || this;
16546 _this.maxFrames = maxFrames;
16551 VirtualTimeScheduler.prototype.flush = function () {
16552 var _a = this, actions = _a.actions, maxFrames = _a.maxFrames;
16554 while ((action = actions.shift()) && (this.frame = action.delay) <= maxFrames) {
16555 if (error = action.execute(action.state, action.delay)) {
16560 while (action = actions.shift()) {
16561 action.unsubscribe();
16566 VirtualTimeScheduler.frameTimeFactor = 10;
16567 return VirtualTimeScheduler;
16568 }(AsyncScheduler_1.AsyncScheduler));
16569 exports.VirtualTimeScheduler = VirtualTimeScheduler;
16570 var VirtualAction = (function (_super) {
16571 __extends(VirtualAction, _super);
16572 function VirtualAction(scheduler, work, index) {
16573 if (index === void 0) { index = scheduler.index += 1; }
16574 var _this = _super.call(this, scheduler, work) || this;
16575 _this.scheduler = scheduler;
16577 _this.index = index;
16578 _this.active = true;
16579 _this.index = scheduler.index = index;
16582 VirtualAction.prototype.schedule = function (state, delay) {
16583 if (delay === void 0) { delay = 0; }
16585 return _super.prototype.schedule.call(this, state, delay);
16587 this.active = false;
16588 var action = new VirtualAction(this.scheduler, this.work);
16590 return action.schedule(state, delay);
16592 VirtualAction.prototype.requestAsyncId = function (scheduler, id, delay) {
16593 if (delay === void 0) { delay = 0; }
16594 this.delay = scheduler.frame + delay;
16595 var actions = scheduler.actions;
16596 actions.push(this);
16597 actions.sort(VirtualAction.sortActions);
16600 VirtualAction.prototype.recycleAsyncId = function (scheduler, id, delay) {
16601 if (delay === void 0) { delay = 0; }
16604 VirtualAction.prototype._execute = function (state, delay) {
16605 if (this.active === true) {
16606 return _super.prototype._execute.call(this, state, delay);
16609 VirtualAction.sortActions = function (a, b) {
16610 if (a.delay === b.delay) {
16611 if (a.index === b.index) {
16614 else if (a.index > b.index) {
16621 else if (a.delay > b.delay) {
16628 return VirtualAction;
16629 }(AsyncAction_1.AsyncAction));
16630 exports.VirtualAction = VirtualAction;
16632 },{"./AsyncAction":181,"./AsyncScheduler":182}],186:[function(require,module,exports){
16634 Object.defineProperty(exports, "__esModule", { value: true });
16635 var AnimationFrameAction_1 = require("./AnimationFrameAction");
16636 var AnimationFrameScheduler_1 = require("./AnimationFrameScheduler");
16637 exports.animationFrame = new AnimationFrameScheduler_1.AnimationFrameScheduler(AnimationFrameAction_1.AnimationFrameAction);
16639 },{"./AnimationFrameAction":177,"./AnimationFrameScheduler":178}],187:[function(require,module,exports){
16641 Object.defineProperty(exports, "__esModule", { value: true });
16642 var AsapAction_1 = require("./AsapAction");
16643 var AsapScheduler_1 = require("./AsapScheduler");
16644 exports.asap = new AsapScheduler_1.AsapScheduler(AsapAction_1.AsapAction);
16646 },{"./AsapAction":179,"./AsapScheduler":180}],188:[function(require,module,exports){
16648 Object.defineProperty(exports, "__esModule", { value: true });
16649 var AsyncAction_1 = require("./AsyncAction");
16650 var AsyncScheduler_1 = require("./AsyncScheduler");
16651 exports.async = new AsyncScheduler_1.AsyncScheduler(AsyncAction_1.AsyncAction);
16653 },{"./AsyncAction":181,"./AsyncScheduler":182}],189:[function(require,module,exports){
16655 Object.defineProperty(exports, "__esModule", { value: true });
16656 var QueueAction_1 = require("./QueueAction");
16657 var QueueScheduler_1 = require("./QueueScheduler");
16658 exports.queue = new QueueScheduler_1.QueueScheduler(QueueAction_1.QueueAction);
16660 },{"./QueueAction":183,"./QueueScheduler":184}],190:[function(require,module,exports){
16662 Object.defineProperty(exports, "__esModule", { value: true });
16663 function getSymbolIterator() {
16664 if (typeof Symbol !== 'function' || !Symbol.iterator) {
16665 return '@@iterator';
16667 return Symbol.iterator;
16669 exports.getSymbolIterator = getSymbolIterator;
16670 exports.iterator = getSymbolIterator();
16671 exports.$$iterator = exports.iterator;
16673 },{}],191:[function(require,module,exports){
16675 Object.defineProperty(exports, "__esModule", { value: true });
16676 exports.observable = typeof Symbol === 'function' && Symbol.observable || '@@observable';
16678 },{}],192:[function(require,module,exports){
16680 Object.defineProperty(exports, "__esModule", { value: true });
16681 exports.rxSubscriber = typeof Symbol === 'function'
16682 ? Symbol('rxSubscriber')
16683 : '@@rxSubscriber_' + Math.random();
16684 exports.$$rxSubscriber = exports.rxSubscriber;
16686 },{}],193:[function(require,module,exports){
16688 Object.defineProperty(exports, "__esModule", { value: true });
16689 function ArgumentOutOfRangeErrorImpl() {
16691 this.message = 'argument out of range';
16692 this.name = 'ArgumentOutOfRangeError';
16695 ArgumentOutOfRangeErrorImpl.prototype = Object.create(Error.prototype);
16696 exports.ArgumentOutOfRangeError = ArgumentOutOfRangeErrorImpl;
16698 },{}],194:[function(require,module,exports){
16700 Object.defineProperty(exports, "__esModule", { value: true });
16701 function EmptyErrorImpl() {
16703 this.message = 'no elements in sequence';
16704 this.name = 'EmptyError';
16707 EmptyErrorImpl.prototype = Object.create(Error.prototype);
16708 exports.EmptyError = EmptyErrorImpl;
16710 },{}],195:[function(require,module,exports){
16712 Object.defineProperty(exports, "__esModule", { value: true });
16713 var nextHandle = 1;
16714 var tasksByHandle = {};
16715 function runIfPresent(handle) {
16716 var cb = tasksByHandle[handle];
16721 exports.Immediate = {
16722 setImmediate: function (cb) {
16723 var handle = nextHandle++;
16724 tasksByHandle[handle] = cb;
16725 Promise.resolve().then(function () { return runIfPresent(handle); });
16728 clearImmediate: function (handle) {
16729 delete tasksByHandle[handle];
16733 },{}],196:[function(require,module,exports){
16735 Object.defineProperty(exports, "__esModule", { value: true });
16736 function ObjectUnsubscribedErrorImpl() {
16738 this.message = 'object unsubscribed';
16739 this.name = 'ObjectUnsubscribedError';
16742 ObjectUnsubscribedErrorImpl.prototype = Object.create(Error.prototype);
16743 exports.ObjectUnsubscribedError = ObjectUnsubscribedErrorImpl;
16745 },{}],197:[function(require,module,exports){
16747 Object.defineProperty(exports, "__esModule", { value: true });
16748 function TimeoutErrorImpl() {
16750 this.message = 'Timeout has occurred';
16751 this.name = 'TimeoutError';
16754 TimeoutErrorImpl.prototype = Object.create(Error.prototype);
16755 exports.TimeoutError = TimeoutErrorImpl;
16757 },{}],198:[function(require,module,exports){
16759 Object.defineProperty(exports, "__esModule", { value: true });
16760 function UnsubscriptionErrorImpl(errors) {
16762 this.message = errors ?
16763 errors.length + " errors occurred during unsubscription:\n" + errors.map(function (err, i) { return i + 1 + ") " + err.toString(); }).join('\n ') : '';
16764 this.name = 'UnsubscriptionError';
16765 this.errors = errors;
16768 UnsubscriptionErrorImpl.prototype = Object.create(Error.prototype);
16769 exports.UnsubscriptionError = UnsubscriptionErrorImpl;
16771 },{}],199:[function(require,module,exports){
16773 Object.defineProperty(exports, "__esModule", { value: true });
16774 var Subscriber_1 = require("../Subscriber");
16775 function canReportError(observer) {
16777 var _a = observer, closed_1 = _a.closed, destination = _a.destination, isStopped = _a.isStopped;
16778 if (closed_1 || isStopped) {
16781 else if (destination && destination instanceof Subscriber_1.Subscriber) {
16782 observer = destination;
16790 exports.canReportError = canReportError;
16792 },{"../Subscriber":39}],200:[function(require,module,exports){
16794 Object.defineProperty(exports, "__esModule", { value: true });
16795 exports.errorObject = { e: {} };
16797 },{}],201:[function(require,module,exports){
16799 Object.defineProperty(exports, "__esModule", { value: true });
16800 function hostReportError(err) {
16801 setTimeout(function () { throw err; });
16803 exports.hostReportError = hostReportError;
16805 },{}],202:[function(require,module,exports){
16807 Object.defineProperty(exports, "__esModule", { value: true });
16808 function identity(x) {
16811 exports.identity = identity;
16813 },{}],203:[function(require,module,exports){
16815 Object.defineProperty(exports, "__esModule", { value: true });
16816 exports.isArray = Array.isArray || (function (x) { return x && typeof x.length === 'number'; });
16818 },{}],204:[function(require,module,exports){
16820 Object.defineProperty(exports, "__esModule", { value: true });
16821 exports.isArrayLike = (function (x) { return x && typeof x.length === 'number' && typeof x !== 'function'; });
16823 },{}],205:[function(require,module,exports){
16825 Object.defineProperty(exports, "__esModule", { value: true });
16826 function isDate(value) {
16827 return value instanceof Date && !isNaN(+value);
16829 exports.isDate = isDate;
16831 },{}],206:[function(require,module,exports){
16833 Object.defineProperty(exports, "__esModule", { value: true });
16834 function isFunction(x) {
16835 return typeof x === 'function';
16837 exports.isFunction = isFunction;
16839 },{}],207:[function(require,module,exports){
16841 Object.defineProperty(exports, "__esModule", { value: true });
16842 var observable_1 = require("../symbol/observable");
16843 function isInteropObservable(input) {
16844 return input && typeof input[observable_1.observable] === 'function';
16846 exports.isInteropObservable = isInteropObservable;
16848 },{"../symbol/observable":191}],208:[function(require,module,exports){
16850 Object.defineProperty(exports, "__esModule", { value: true });
16851 var iterator_1 = require("../symbol/iterator");
16852 function isIterable(input) {
16853 return input && typeof input[iterator_1.iterator] === 'function';
16855 exports.isIterable = isIterable;
16857 },{"../symbol/iterator":190}],209:[function(require,module,exports){
16859 Object.defineProperty(exports, "__esModule", { value: true });
16860 var isArray_1 = require("./isArray");
16861 function isNumeric(val) {
16862 return !isArray_1.isArray(val) && (val - parseFloat(val) + 1) >= 0;
16864 exports.isNumeric = isNumeric;
16866 },{"./isArray":203}],210:[function(require,module,exports){
16868 Object.defineProperty(exports, "__esModule", { value: true });
16869 function isObject(x) {
16870 return x != null && typeof x === 'object';
16872 exports.isObject = isObject;
16874 },{}],211:[function(require,module,exports){
16876 Object.defineProperty(exports, "__esModule", { value: true });
16877 var Observable_1 = require("../Observable");
16878 function isObservable(obj) {
16879 return !!obj && (obj instanceof Observable_1.Observable || (typeof obj.lift === 'function' && typeof obj.subscribe === 'function'));
16881 exports.isObservable = isObservable;
16883 },{"../Observable":32}],212:[function(require,module,exports){
16885 Object.defineProperty(exports, "__esModule", { value: true });
16886 function isPromise(value) {
16887 return value && typeof value.subscribe !== 'function' && typeof value.then === 'function';
16889 exports.isPromise = isPromise;
16891 },{}],213:[function(require,module,exports){
16893 Object.defineProperty(exports, "__esModule", { value: true });
16894 function isScheduler(value) {
16895 return value && typeof value.schedule === 'function';
16897 exports.isScheduler = isScheduler;
16899 },{}],214:[function(require,module,exports){
16901 Object.defineProperty(exports, "__esModule", { value: true });
16902 function noop() { }
16903 exports.noop = noop;
16905 },{}],215:[function(require,module,exports){
16907 Object.defineProperty(exports, "__esModule", { value: true });
16908 function not(pred, thisArg) {
16909 function notPred() {
16910 return !(notPred.pred.apply(notPred.thisArg, arguments));
16912 notPred.pred = pred;
16913 notPred.thisArg = thisArg;
16918 },{}],216:[function(require,module,exports){
16920 Object.defineProperty(exports, "__esModule", { value: true });
16921 var noop_1 = require("./noop");
16924 for (var _i = 0; _i < arguments.length; _i++) {
16925 fns[_i] = arguments[_i];
16927 return pipeFromArray(fns);
16929 exports.pipe = pipe;
16930 function pipeFromArray(fns) {
16932 return noop_1.noop;
16934 if (fns.length === 1) {
16937 return function piped(input) {
16938 return fns.reduce(function (prev, fn) { return fn(prev); }, input);
16941 exports.pipeFromArray = pipeFromArray;
16943 },{"./noop":214}],217:[function(require,module,exports){
16945 Object.defineProperty(exports, "__esModule", { value: true });
16946 var Observable_1 = require("../Observable");
16947 var subscribeToArray_1 = require("./subscribeToArray");
16948 var subscribeToPromise_1 = require("./subscribeToPromise");
16949 var subscribeToIterable_1 = require("./subscribeToIterable");
16950 var subscribeToObservable_1 = require("./subscribeToObservable");
16951 var isArrayLike_1 = require("./isArrayLike");
16952 var isPromise_1 = require("./isPromise");
16953 var isObject_1 = require("./isObject");
16954 var iterator_1 = require("../symbol/iterator");
16955 var observable_1 = require("../symbol/observable");
16956 exports.subscribeTo = function (result) {
16957 if (result instanceof Observable_1.Observable) {
16958 return function (subscriber) {
16959 if (result._isScalar) {
16960 subscriber.next(result.value);
16961 subscriber.complete();
16965 return result.subscribe(subscriber);
16969 else if (result && typeof result[observable_1.observable] === 'function') {
16970 return subscribeToObservable_1.subscribeToObservable(result);
16972 else if (isArrayLike_1.isArrayLike(result)) {
16973 return subscribeToArray_1.subscribeToArray(result);
16975 else if (isPromise_1.isPromise(result)) {
16976 return subscribeToPromise_1.subscribeToPromise(result);
16978 else if (result && typeof result[iterator_1.iterator] === 'function') {
16979 return subscribeToIterable_1.subscribeToIterable(result);
16982 var value = isObject_1.isObject(result) ? 'an invalid object' : "'" + result + "'";
16983 var msg = "You provided " + value + " where a stream was expected."
16984 + ' You can provide an Observable, Promise, Array, or Iterable.';
16985 throw new TypeError(msg);
16989 },{"../Observable":32,"../symbol/iterator":190,"../symbol/observable":191,"./isArrayLike":204,"./isObject":210,"./isPromise":212,"./subscribeToArray":218,"./subscribeToIterable":219,"./subscribeToObservable":220,"./subscribeToPromise":221}],218:[function(require,module,exports){
16991 Object.defineProperty(exports, "__esModule", { value: true });
16992 exports.subscribeToArray = function (array) { return function (subscriber) {
16993 for (var i = 0, len = array.length; i < len && !subscriber.closed; i++) {
16994 subscriber.next(array[i]);
16996 if (!subscriber.closed) {
16997 subscriber.complete();
17001 },{}],219:[function(require,module,exports){
17003 Object.defineProperty(exports, "__esModule", { value: true });
17004 var iterator_1 = require("../symbol/iterator");
17005 exports.subscribeToIterable = function (iterable) { return function (subscriber) {
17006 var iterator = iterable[iterator_1.iterator]();
17008 var item = iterator.next();
17010 subscriber.complete();
17013 subscriber.next(item.value);
17014 if (subscriber.closed) {
17018 if (typeof iterator.return === 'function') {
17019 subscriber.add(function () {
17020 if (iterator.return) {
17028 },{"../symbol/iterator":190}],220:[function(require,module,exports){
17030 Object.defineProperty(exports, "__esModule", { value: true });
17031 var observable_1 = require("../symbol/observable");
17032 exports.subscribeToObservable = function (obj) { return function (subscriber) {
17033 var obs = obj[observable_1.observable]();
17034 if (typeof obs.subscribe !== 'function') {
17035 throw new TypeError('Provided object does not correctly implement Symbol.observable');
17038 return obs.subscribe(subscriber);
17042 },{"../symbol/observable":191}],221:[function(require,module,exports){
17044 Object.defineProperty(exports, "__esModule", { value: true });
17045 var hostReportError_1 = require("./hostReportError");
17046 exports.subscribeToPromise = function (promise) { return function (subscriber) {
17047 promise.then(function (value) {
17048 if (!subscriber.closed) {
17049 subscriber.next(value);
17050 subscriber.complete();
17052 }, function (err) { return subscriber.error(err); })
17053 .then(null, hostReportError_1.hostReportError);
17057 },{"./hostReportError":201}],222:[function(require,module,exports){
17059 Object.defineProperty(exports, "__esModule", { value: true });
17060 var InnerSubscriber_1 = require("../InnerSubscriber");
17061 var subscribeTo_1 = require("./subscribeTo");
17062 function subscribeToResult(outerSubscriber, result, outerValue, outerIndex, destination) {
17063 if (destination === void 0) { destination = new InnerSubscriber_1.InnerSubscriber(outerSubscriber, outerValue, outerIndex); }
17064 if (destination.closed) {
17067 return subscribeTo_1.subscribeTo(result)(destination);
17069 exports.subscribeToResult = subscribeToResult;
17071 },{"../InnerSubscriber":30,"./subscribeTo":217}],223:[function(require,module,exports){
17073 Object.defineProperty(exports, "__esModule", { value: true });
17074 var Subscriber_1 = require("../Subscriber");
17075 var rxSubscriber_1 = require("../symbol/rxSubscriber");
17076 var Observer_1 = require("../Observer");
17077 function toSubscriber(nextOrObserver, error, complete) {
17078 if (nextOrObserver) {
17079 if (nextOrObserver instanceof Subscriber_1.Subscriber) {
17080 return nextOrObserver;
17082 if (nextOrObserver[rxSubscriber_1.rxSubscriber]) {
17083 return nextOrObserver[rxSubscriber_1.rxSubscriber]();
17086 if (!nextOrObserver && !error && !complete) {
17087 return new Subscriber_1.Subscriber(Observer_1.empty);
17089 return new Subscriber_1.Subscriber(nextOrObserver, error, complete);
17091 exports.toSubscriber = toSubscriber;
17093 },{"../Observer":33,"../Subscriber":39,"../symbol/rxSubscriber":192}],224:[function(require,module,exports){
17095 Object.defineProperty(exports, "__esModule", { value: true });
17096 var errorObject_1 = require("./errorObject");
17097 var tryCatchTarget;
17098 function tryCatcher() {
17100 return tryCatchTarget.apply(this, arguments);
17103 errorObject_1.errorObject.e = e;
17104 return errorObject_1.errorObject;
17107 function tryCatch(fn) {
17108 tryCatchTarget = fn;
17111 exports.tryCatch = tryCatch;
17113 },{"./errorObject":200}],225:[function(require,module,exports){
17115 Object.defineProperty(exports, "__esModule", { value: true });
17116 var audit_1 = require("../internal/operators/audit");
17117 exports.audit = audit_1.audit;
17118 var auditTime_1 = require("../internal/operators/auditTime");
17119 exports.auditTime = auditTime_1.auditTime;
17120 var buffer_1 = require("../internal/operators/buffer");
17121 exports.buffer = buffer_1.buffer;
17122 var bufferCount_1 = require("../internal/operators/bufferCount");
17123 exports.bufferCount = bufferCount_1.bufferCount;
17124 var bufferTime_1 = require("../internal/operators/bufferTime");
17125 exports.bufferTime = bufferTime_1.bufferTime;
17126 var bufferToggle_1 = require("../internal/operators/bufferToggle");
17127 exports.bufferToggle = bufferToggle_1.bufferToggle;
17128 var bufferWhen_1 = require("../internal/operators/bufferWhen");
17129 exports.bufferWhen = bufferWhen_1.bufferWhen;
17130 var catchError_1 = require("../internal/operators/catchError");
17131 exports.catchError = catchError_1.catchError;
17132 var combineAll_1 = require("../internal/operators/combineAll");
17133 exports.combineAll = combineAll_1.combineAll;
17134 var combineLatest_1 = require("../internal/operators/combineLatest");
17135 exports.combineLatest = combineLatest_1.combineLatest;
17136 var concat_1 = require("../internal/operators/concat");
17137 exports.concat = concat_1.concat;
17138 var concatAll_1 = require("../internal/operators/concatAll");
17139 exports.concatAll = concatAll_1.concatAll;
17140 var concatMap_1 = require("../internal/operators/concatMap");
17141 exports.concatMap = concatMap_1.concatMap;
17142 var concatMapTo_1 = require("../internal/operators/concatMapTo");
17143 exports.concatMapTo = concatMapTo_1.concatMapTo;
17144 var count_1 = require("../internal/operators/count");
17145 exports.count = count_1.count;
17146 var debounce_1 = require("../internal/operators/debounce");
17147 exports.debounce = debounce_1.debounce;
17148 var debounceTime_1 = require("../internal/operators/debounceTime");
17149 exports.debounceTime = debounceTime_1.debounceTime;
17150 var defaultIfEmpty_1 = require("../internal/operators/defaultIfEmpty");
17151 exports.defaultIfEmpty = defaultIfEmpty_1.defaultIfEmpty;
17152 var delay_1 = require("../internal/operators/delay");
17153 exports.delay = delay_1.delay;
17154 var delayWhen_1 = require("../internal/operators/delayWhen");
17155 exports.delayWhen = delayWhen_1.delayWhen;
17156 var dematerialize_1 = require("../internal/operators/dematerialize");
17157 exports.dematerialize = dematerialize_1.dematerialize;
17158 var distinct_1 = require("../internal/operators/distinct");
17159 exports.distinct = distinct_1.distinct;
17160 var distinctUntilChanged_1 = require("../internal/operators/distinctUntilChanged");
17161 exports.distinctUntilChanged = distinctUntilChanged_1.distinctUntilChanged;
17162 var distinctUntilKeyChanged_1 = require("../internal/operators/distinctUntilKeyChanged");
17163 exports.distinctUntilKeyChanged = distinctUntilKeyChanged_1.distinctUntilKeyChanged;
17164 var elementAt_1 = require("../internal/operators/elementAt");
17165 exports.elementAt = elementAt_1.elementAt;
17166 var endWith_1 = require("../internal/operators/endWith");
17167 exports.endWith = endWith_1.endWith;
17168 var every_1 = require("../internal/operators/every");
17169 exports.every = every_1.every;
17170 var exhaust_1 = require("../internal/operators/exhaust");
17171 exports.exhaust = exhaust_1.exhaust;
17172 var exhaustMap_1 = require("../internal/operators/exhaustMap");
17173 exports.exhaustMap = exhaustMap_1.exhaustMap;
17174 var expand_1 = require("../internal/operators/expand");
17175 exports.expand = expand_1.expand;
17176 var filter_1 = require("../internal/operators/filter");
17177 exports.filter = filter_1.filter;
17178 var finalize_1 = require("../internal/operators/finalize");
17179 exports.finalize = finalize_1.finalize;
17180 var find_1 = require("../internal/operators/find");
17181 exports.find = find_1.find;
17182 var findIndex_1 = require("../internal/operators/findIndex");
17183 exports.findIndex = findIndex_1.findIndex;
17184 var first_1 = require("../internal/operators/first");
17185 exports.first = first_1.first;
17186 var groupBy_1 = require("../internal/operators/groupBy");
17187 exports.groupBy = groupBy_1.groupBy;
17188 var ignoreElements_1 = require("../internal/operators/ignoreElements");
17189 exports.ignoreElements = ignoreElements_1.ignoreElements;
17190 var isEmpty_1 = require("../internal/operators/isEmpty");
17191 exports.isEmpty = isEmpty_1.isEmpty;
17192 var last_1 = require("../internal/operators/last");
17193 exports.last = last_1.last;
17194 var map_1 = require("../internal/operators/map");
17195 exports.map = map_1.map;
17196 var mapTo_1 = require("../internal/operators/mapTo");
17197 exports.mapTo = mapTo_1.mapTo;
17198 var materialize_1 = require("../internal/operators/materialize");
17199 exports.materialize = materialize_1.materialize;
17200 var max_1 = require("../internal/operators/max");
17201 exports.max = max_1.max;
17202 var merge_1 = require("../internal/operators/merge");
17203 exports.merge = merge_1.merge;
17204 var mergeAll_1 = require("../internal/operators/mergeAll");
17205 exports.mergeAll = mergeAll_1.mergeAll;
17206 var mergeMap_1 = require("../internal/operators/mergeMap");
17207 exports.mergeMap = mergeMap_1.mergeMap;
17208 var mergeMap_2 = require("../internal/operators/mergeMap");
17209 exports.flatMap = mergeMap_2.mergeMap;
17210 var mergeMapTo_1 = require("../internal/operators/mergeMapTo");
17211 exports.mergeMapTo = mergeMapTo_1.mergeMapTo;
17212 var mergeScan_1 = require("../internal/operators/mergeScan");
17213 exports.mergeScan = mergeScan_1.mergeScan;
17214 var min_1 = require("../internal/operators/min");
17215 exports.min = min_1.min;
17216 var multicast_1 = require("../internal/operators/multicast");
17217 exports.multicast = multicast_1.multicast;
17218 var observeOn_1 = require("../internal/operators/observeOn");
17219 exports.observeOn = observeOn_1.observeOn;
17220 var onErrorResumeNext_1 = require("../internal/operators/onErrorResumeNext");
17221 exports.onErrorResumeNext = onErrorResumeNext_1.onErrorResumeNext;
17222 var pairwise_1 = require("../internal/operators/pairwise");
17223 exports.pairwise = pairwise_1.pairwise;
17224 var partition_1 = require("../internal/operators/partition");
17225 exports.partition = partition_1.partition;
17226 var pluck_1 = require("../internal/operators/pluck");
17227 exports.pluck = pluck_1.pluck;
17228 var publish_1 = require("../internal/operators/publish");
17229 exports.publish = publish_1.publish;
17230 var publishBehavior_1 = require("../internal/operators/publishBehavior");
17231 exports.publishBehavior = publishBehavior_1.publishBehavior;
17232 var publishLast_1 = require("../internal/operators/publishLast");
17233 exports.publishLast = publishLast_1.publishLast;
17234 var publishReplay_1 = require("../internal/operators/publishReplay");
17235 exports.publishReplay = publishReplay_1.publishReplay;
17236 var race_1 = require("../internal/operators/race");
17237 exports.race = race_1.race;
17238 var reduce_1 = require("../internal/operators/reduce");
17239 exports.reduce = reduce_1.reduce;
17240 var repeat_1 = require("../internal/operators/repeat");
17241 exports.repeat = repeat_1.repeat;
17242 var repeatWhen_1 = require("../internal/operators/repeatWhen");
17243 exports.repeatWhen = repeatWhen_1.repeatWhen;
17244 var retry_1 = require("../internal/operators/retry");
17245 exports.retry = retry_1.retry;
17246 var retryWhen_1 = require("../internal/operators/retryWhen");
17247 exports.retryWhen = retryWhen_1.retryWhen;
17248 var refCount_1 = require("../internal/operators/refCount");
17249 exports.refCount = refCount_1.refCount;
17250 var sample_1 = require("../internal/operators/sample");
17251 exports.sample = sample_1.sample;
17252 var sampleTime_1 = require("../internal/operators/sampleTime");
17253 exports.sampleTime = sampleTime_1.sampleTime;
17254 var scan_1 = require("../internal/operators/scan");
17255 exports.scan = scan_1.scan;
17256 var sequenceEqual_1 = require("../internal/operators/sequenceEqual");
17257 exports.sequenceEqual = sequenceEqual_1.sequenceEqual;
17258 var share_1 = require("../internal/operators/share");
17259 exports.share = share_1.share;
17260 var shareReplay_1 = require("../internal/operators/shareReplay");
17261 exports.shareReplay = shareReplay_1.shareReplay;
17262 var single_1 = require("../internal/operators/single");
17263 exports.single = single_1.single;
17264 var skip_1 = require("../internal/operators/skip");
17265 exports.skip = skip_1.skip;
17266 var skipLast_1 = require("../internal/operators/skipLast");
17267 exports.skipLast = skipLast_1.skipLast;
17268 var skipUntil_1 = require("../internal/operators/skipUntil");
17269 exports.skipUntil = skipUntil_1.skipUntil;
17270 var skipWhile_1 = require("../internal/operators/skipWhile");
17271 exports.skipWhile = skipWhile_1.skipWhile;
17272 var startWith_1 = require("../internal/operators/startWith");
17273 exports.startWith = startWith_1.startWith;
17274 var subscribeOn_1 = require("../internal/operators/subscribeOn");
17275 exports.subscribeOn = subscribeOn_1.subscribeOn;
17276 var switchAll_1 = require("../internal/operators/switchAll");
17277 exports.switchAll = switchAll_1.switchAll;
17278 var switchMap_1 = require("../internal/operators/switchMap");
17279 exports.switchMap = switchMap_1.switchMap;
17280 var switchMapTo_1 = require("../internal/operators/switchMapTo");
17281 exports.switchMapTo = switchMapTo_1.switchMapTo;
17282 var take_1 = require("../internal/operators/take");
17283 exports.take = take_1.take;
17284 var takeLast_1 = require("../internal/operators/takeLast");
17285 exports.takeLast = takeLast_1.takeLast;
17286 var takeUntil_1 = require("../internal/operators/takeUntil");
17287 exports.takeUntil = takeUntil_1.takeUntil;
17288 var takeWhile_1 = require("../internal/operators/takeWhile");
17289 exports.takeWhile = takeWhile_1.takeWhile;
17290 var tap_1 = require("../internal/operators/tap");
17291 exports.tap = tap_1.tap;
17292 var throttle_1 = require("../internal/operators/throttle");
17293 exports.throttle = throttle_1.throttle;
17294 var throttleTime_1 = require("../internal/operators/throttleTime");
17295 exports.throttleTime = throttleTime_1.throttleTime;
17296 var throwIfEmpty_1 = require("../internal/operators/throwIfEmpty");
17297 exports.throwIfEmpty = throwIfEmpty_1.throwIfEmpty;
17298 var timeInterval_1 = require("../internal/operators/timeInterval");
17299 exports.timeInterval = timeInterval_1.timeInterval;
17300 var timeout_1 = require("../internal/operators/timeout");
17301 exports.timeout = timeout_1.timeout;
17302 var timeoutWith_1 = require("../internal/operators/timeoutWith");
17303 exports.timeoutWith = timeoutWith_1.timeoutWith;
17304 var timestamp_1 = require("../internal/operators/timestamp");
17305 exports.timestamp = timestamp_1.timestamp;
17306 var toArray_1 = require("../internal/operators/toArray");
17307 exports.toArray = toArray_1.toArray;
17308 var window_1 = require("../internal/operators/window");
17309 exports.window = window_1.window;
17310 var windowCount_1 = require("../internal/operators/windowCount");
17311 exports.windowCount = windowCount_1.windowCount;
17312 var windowTime_1 = require("../internal/operators/windowTime");
17313 exports.windowTime = windowTime_1.windowTime;
17314 var windowToggle_1 = require("../internal/operators/windowToggle");
17315 exports.windowToggle = windowToggle_1.windowToggle;
17316 var windowWhen_1 = require("../internal/operators/windowWhen");
17317 exports.windowWhen = windowWhen_1.windowWhen;
17318 var withLatestFrom_1 = require("../internal/operators/withLatestFrom");
17319 exports.withLatestFrom = withLatestFrom_1.withLatestFrom;
17320 var zip_1 = require("../internal/operators/zip");
17321 exports.zip = zip_1.zip;
17322 var zipAll_1 = require("../internal/operators/zipAll");
17323 exports.zipAll = zipAll_1.zipAll;
17325 },{"../internal/operators/audit":73,"../internal/operators/auditTime":74,"../internal/operators/buffer":75,"../internal/operators/bufferCount":76,"../internal/operators/bufferTime":77,"../internal/operators/bufferToggle":78,"../internal/operators/bufferWhen":79,"../internal/operators/catchError":80,"../internal/operators/combineAll":81,"../internal/operators/combineLatest":82,"../internal/operators/concat":83,"../internal/operators/concatAll":84,"../internal/operators/concatMap":85,"../internal/operators/concatMapTo":86,"../internal/operators/count":87,"../internal/operators/debounce":88,"../internal/operators/debounceTime":89,"../internal/operators/defaultIfEmpty":90,"../internal/operators/delay":91,"../internal/operators/delayWhen":92,"../internal/operators/dematerialize":93,"../internal/operators/distinct":94,"../internal/operators/distinctUntilChanged":95,"../internal/operators/distinctUntilKeyChanged":96,"../internal/operators/elementAt":97,"../internal/operators/endWith":98,"../internal/operators/every":99,"../internal/operators/exhaust":100,"../internal/operators/exhaustMap":101,"../internal/operators/expand":102,"../internal/operators/filter":103,"../internal/operators/finalize":104,"../internal/operators/find":105,"../internal/operators/findIndex":106,"../internal/operators/first":107,"../internal/operators/groupBy":108,"../internal/operators/ignoreElements":109,"../internal/operators/isEmpty":110,"../internal/operators/last":111,"../internal/operators/map":112,"../internal/operators/mapTo":113,"../internal/operators/materialize":114,"../internal/operators/max":115,"../internal/operators/merge":116,"../internal/operators/mergeAll":117,"../internal/operators/mergeMap":118,"../internal/operators/mergeMapTo":119,"../internal/operators/mergeScan":120,"../internal/operators/min":121,"../internal/operators/multicast":122,"../internal/operators/observeOn":123,"../internal/operators/onErrorResumeNext":124,"../internal/operators/pairwise":125,"../internal/operators/partition":126,"../internal/operators/pluck":127,"../internal/operators/publish":128,"../internal/operators/publishBehavior":129,"../internal/operators/publishLast":130,"../internal/operators/publishReplay":131,"../internal/operators/race":132,"../internal/operators/reduce":133,"../internal/operators/refCount":134,"../internal/operators/repeat":135,"../internal/operators/repeatWhen":136,"../internal/operators/retry":137,"../internal/operators/retryWhen":138,"../internal/operators/sample":139,"../internal/operators/sampleTime":140,"../internal/operators/scan":141,"../internal/operators/sequenceEqual":142,"../internal/operators/share":143,"../internal/operators/shareReplay":144,"../internal/operators/single":145,"../internal/operators/skip":146,"../internal/operators/skipLast":147,"../internal/operators/skipUntil":148,"../internal/operators/skipWhile":149,"../internal/operators/startWith":150,"../internal/operators/subscribeOn":151,"../internal/operators/switchAll":152,"../internal/operators/switchMap":153,"../internal/operators/switchMapTo":154,"../internal/operators/take":155,"../internal/operators/takeLast":156,"../internal/operators/takeUntil":157,"../internal/operators/takeWhile":158,"../internal/operators/tap":159,"../internal/operators/throttle":160,"../internal/operators/throttleTime":161,"../internal/operators/throwIfEmpty":162,"../internal/operators/timeInterval":163,"../internal/operators/timeout":164,"../internal/operators/timeoutWith":165,"../internal/operators/timestamp":166,"../internal/operators/toArray":167,"../internal/operators/window":168,"../internal/operators/windowCount":169,"../internal/operators/windowTime":170,"../internal/operators/windowToggle":171,"../internal/operators/windowWhen":172,"../internal/operators/withLatestFrom":173,"../internal/operators/zip":174,"../internal/operators/zipAll":175}],226:[function(require,module,exports){
17326 // threejs.org/license
17327 (function(l,ya){"object"===typeof exports&&"undefined"!==typeof module?ya(exports):"function"===typeof define&&define.amd?define(["exports"],ya):ya(l.THREE={})})(this,function(l){function ya(){}function z(a,b){this.x=a||0;this.y=b||0}function I(){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];0<arguments.length&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}function fa(a,b,c,d){this._x=a||0;this._y=b||0;this._z=c||0;this._w=void 0!==d?d:1}function p(a,
17328 b,c){this.x=a||0;this.y=b||0;this.z=c||0}function ra(){this.elements=[1,0,0,0,1,0,0,0,1];0<arguments.length&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}function T(a,b,c,d,e,f,g,h,k,m){Object.defineProperty(this,"id",{value:Ef++});this.uuid=H.generateUUID();this.name="";this.image=void 0!==a?a:T.DEFAULT_IMAGE;this.mipmaps=[];this.mapping=void 0!==b?b:T.DEFAULT_MAPPING;this.wrapS=void 0!==c?c:1001;this.wrapT=void 0!==d?d:1001;this.magFilter=void 0!==
17329 e?e:1006;this.minFilter=void 0!==f?f:1008;this.anisotropy=void 0!==k?k:1;this.format=void 0!==g?g:1023;this.type=void 0!==h?h:1009;this.offset=new z(0,0);this.repeat=new z(1,1);this.center=new z(0,0);this.rotation=0;this.matrixAutoUpdate=!0;this.matrix=new ra;this.generateMipmaps=!0;this.premultiplyAlpha=!1;this.flipY=!0;this.unpackAlignment=4;this.encoding=void 0!==m?m:3E3;this.version=0;this.onUpdate=null}function V(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=void 0!==d?d:1}function fb(a,
17330 b,c){this.width=a;this.height=b;this.scissor=new V(0,0,a,b);this.scissorTest=!1;this.viewport=new V(0,0,a,b);c=c||{};void 0===c.minFilter&&(c.minFilter=1006);this.texture=new T(void 0,void 0,c.wrapS,c.wrapT,c.magFilter,c.minFilter,c.format,c.type,c.anisotropy,c.encoding);this.texture.generateMipmaps=void 0!==c.generateMipmaps?c.generateMipmaps:!0;this.depthBuffer=void 0!==c.depthBuffer?c.depthBuffer:!0;this.stencilBuffer=void 0!==c.stencilBuffer?c.stencilBuffer:!0;this.depthTexture=void 0!==c.depthTexture?
17331 c.depthTexture:null}function Gb(a,b,c){fb.call(this,a,b,c);this.activeMipMapLevel=this.activeCubeFace=0}function gb(a,b,c,d,e,f,g,h,k,m,q,n){T.call(this,null,f,g,h,k,m,d,e,q,n);this.image={data:a,width:b,height:c};this.magFilter=void 0!==k?k:1003;this.minFilter=void 0!==m?m:1003;this.flipY=this.generateMipmaps=!1;this.unpackAlignment=1}function Sa(a,b){this.min=void 0!==a?a:new p(Infinity,Infinity,Infinity);this.max=void 0!==b?b:new p(-Infinity,-Infinity,-Infinity)}function Da(a,b){this.center=void 0!==
17332 a?a:new p;this.radius=void 0!==b?b:0}function Ma(a,b){this.normal=void 0!==a?a:new p(1,0,0);this.constant=void 0!==b?b:0}function md(a,b,c,d,e,f){this.planes=[void 0!==a?a:new Ma,void 0!==b?b:new Ma,void 0!==c?c:new Ma,void 0!==d?d:new Ma,void 0!==e?e:new Ma,void 0!==f?f:new Ma]}function G(a,b,c){return void 0===b&&void 0===c?this.set(a):this.setRGB(a,b,c)}function Qd(){function a(e,f){!1!==c&&(d(e,f),b.requestAnimationFrame(a))}var b=null,c=!1,d=null;return{start:function(){!0!==c&&null!==d&&(b.requestAnimationFrame(a),
17333 c=!0)},stop:function(){c=!1},setAnimationLoop:function(a){d=a},setContext:function(a){b=a}}}function Ff(a){function b(b,c){var d=b.array,e=b.dynamic?a.DYNAMIC_DRAW:a.STATIC_DRAW,h=a.createBuffer();a.bindBuffer(c,h);a.bufferData(c,d,e);b.onUploadCallback();c=a.FLOAT;d instanceof Float32Array?c=a.FLOAT:d instanceof Float64Array?console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array."):d instanceof Uint16Array?c=a.UNSIGNED_SHORT:d instanceof Int16Array?c=a.SHORT:d instanceof
17334 Uint32Array?c=a.UNSIGNED_INT:d instanceof Int32Array?c=a.INT:d instanceof Int8Array?c=a.BYTE:d instanceof Uint8Array&&(c=a.UNSIGNED_BYTE);return{buffer:h,type:c,bytesPerElement:d.BYTES_PER_ELEMENT,version:b.version}}var c=new WeakMap;return{get:function(a){a.isInterleavedBufferAttribute&&(a=a.data);return c.get(a)},remove:function(b){b.isInterleavedBufferAttribute&&(b=b.data);var d=c.get(b);d&&(a.deleteBuffer(d.buffer),c.delete(b))},update:function(d,e){d.isInterleavedBufferAttribute&&(d=d.data);
17335 var f=c.get(d);if(void 0===f)c.set(d,b(d,e));else if(f.version<d.version){var g=d,h=g.array,k=g.updateRange;a.bindBuffer(e,f.buffer);!1===g.dynamic?a.bufferData(e,h,a.STATIC_DRAW):-1===k.count?a.bufferSubData(e,0,h):0===k.count?console.error("THREE.WebGLObjects.updateBuffer: dynamic THREE.BufferAttribute marked as needsUpdate but updateRange.count is 0, ensure you are using set methods or updating manually."):(a.bufferSubData(e,k.offset*h.BYTES_PER_ELEMENT,h.subarray(k.offset,k.offset+k.count)),k.count=
17336 -1);f.version=d.version}}}}function hb(a,b,c,d){this._x=a||0;this._y=b||0;this._z=c||0;this._order=d||hb.DefaultOrder}function Rd(){this.mask=1}function D(){Object.defineProperty(this,"id",{value:Gf++});this.uuid=H.generateUUID();this.name="";this.type="Object3D";this.parent=null;this.children=[];this.up=D.DefaultUp.clone();var a=new p,b=new hb,c=new fa,d=new p(1,1,1);b.onChange(function(){c.setFromEuler(b,!1)});c.onChange(function(){b.setFromQuaternion(c,void 0,!1)});Object.defineProperties(this,
17337 {position:{enumerable:!0,value:a},rotation:{enumerable:!0,value:b},quaternion:{enumerable:!0,value:c},scale:{enumerable:!0,value:d},modelViewMatrix:{value:new I},normalMatrix:{value:new ra}});this.matrix=new I;this.matrixWorld=new I;this.matrixAutoUpdate=D.DefaultMatrixAutoUpdate;this.matrixWorldNeedsUpdate=!1;this.layers=new Rd;this.visible=!0;this.receiveShadow=this.castShadow=!1;this.frustumCulled=!0;this.renderOrder=0;this.userData={}}function Na(){D.call(this);this.type="Camera";this.matrixWorldInverse=
17338 new I;this.projectionMatrix=new I}function Hb(a,b,c,d,e,f){Na.call(this);this.type="OrthographicCamera";this.zoom=1;this.view=null;this.left=a;this.right=b;this.top=c;this.bottom=d;this.near=void 0!==e?e:.1;this.far=void 0!==f?f:2E3;this.updateProjectionMatrix()}function Ta(a,b,c,d,e,f){this.a=a;this.b=b;this.c=c;this.normal=d&&d.isVector3?d:new p;this.vertexNormals=Array.isArray(d)?d:[];this.color=e&&e.isColor?e:new G;this.vertexColors=Array.isArray(e)?e:[];this.materialIndex=void 0!==f?f:0}function R(){Object.defineProperty(this,
17339 "id",{value:Hf+=2});this.uuid=H.generateUUID();this.name="";this.type="Geometry";this.vertices=[];this.colors=[];this.faces=[];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphNormals=[];this.skinWeights=[];this.skinIndices=[];this.lineDistances=[];this.boundingSphere=this.boundingBox=null;this.groupsNeedUpdate=this.lineDistancesNeedUpdate=this.colorsNeedUpdate=this.normalsNeedUpdate=this.uvsNeedUpdate=this.verticesNeedUpdate=this.elementsNeedUpdate=!1}function Q(a,b,c){if(Array.isArray(a))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");
17340 this.name="";this.array=a;this.itemSize=b;this.count=void 0!==a?a.length/b:0;this.normalized=!0===c;this.dynamic=!1;this.updateRange={offset:0,count:-1};this.version=0}function oc(a,b,c){Q.call(this,new Int8Array(a),b,c)}function pc(a,b,c){Q.call(this,new Uint8Array(a),b,c)}function qc(a,b,c){Q.call(this,new Uint8ClampedArray(a),b,c)}function rc(a,b,c){Q.call(this,new Int16Array(a),b,c)}function ib(a,b,c){Q.call(this,new Uint16Array(a),b,c)}function sc(a,b,c){Q.call(this,new Int32Array(a),b,c)}function jb(a,
17341 b,c){Q.call(this,new Uint32Array(a),b,c)}function A(a,b,c){Q.call(this,new Float32Array(a),b,c)}function tc(a,b,c){Q.call(this,new Float64Array(a),b,c)}function Ee(){this.vertices=[];this.normals=[];this.colors=[];this.uvs=[];this.uvs2=[];this.groups=[];this.morphTargets={};this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.groupsNeedUpdate=this.uvsNeedUpdate=this.colorsNeedUpdate=this.normalsNeedUpdate=this.verticesNeedUpdate=!1}function Fe(a){if(0===a.length)return-Infinity;
17342 for(var b=a[0],c=1,d=a.length;c<d;++c)a[c]>b&&(b=a[c]);return b}function C(){Object.defineProperty(this,"id",{value:If+=2});this.uuid=H.generateUUID();this.name="";this.type="BufferGeometry";this.index=null;this.attributes={};this.morphAttributes={};this.groups=[];this.boundingSphere=this.boundingBox=null;this.drawRange={start:0,count:Infinity};this.userData={}}function Ib(a,b,c,d,e,f){R.call(this);this.type="BoxGeometry";this.parameters={width:a,height:b,depth:c,widthSegments:d,heightSegments:e,
17343 depthSegments:f};this.fromBufferGeometry(new kb(a,b,c,d,e,f));this.mergeVertices()}function kb(a,b,c,d,e,f){function g(a,b,c,d,e,f,g,l,N,O,Jf){var r=f/N,v=g/O,P=f/2,y=g/2,w=l/2;g=N+1;var E=O+1,x=f=0,B,z,A=new p;for(z=0;z<E;z++){var D=z*v-y;for(B=0;B<g;B++)A[a]=(B*r-P)*d,A[b]=D*e,A[c]=w,m.push(A.x,A.y,A.z),A[a]=0,A[b]=0,A[c]=0<l?1:-1,q.push(A.x,A.y,A.z),n.push(B/N),n.push(1-z/O),f+=1}for(z=0;z<O;z++)for(B=0;B<N;B++)a=t+B+g*(z+1),b=t+(B+1)+g*(z+1),c=t+(B+1)+g*z,k.push(t+B+g*z,a,c),k.push(a,b,c),x+=
17344 6;h.addGroup(u,x,Jf);u+=x;t+=f}C.call(this);this.type="BoxBufferGeometry";this.parameters={width:a,height:b,depth:c,widthSegments:d,heightSegments:e,depthSegments:f};var h=this;a=a||1;b=b||1;c=c||1;d=Math.floor(d)||1;e=Math.floor(e)||1;f=Math.floor(f)||1;var k=[],m=[],q=[],n=[],t=0,u=0;g("z","y","x",-1,-1,c,b,a,f,e,0);g("z","y","x",1,-1,c,b,-a,f,e,1);g("x","z","y",1,1,a,c,b,d,f,2);g("x","z","y",1,-1,a,c,-b,d,f,3);g("x","y","z",1,-1,a,b,c,d,e,4);g("x","y","z",-1,-1,a,b,-c,d,e,5);this.setIndex(k);this.addAttribute("position",
17345 new A(m,3));this.addAttribute("normal",new A(q,3));this.addAttribute("uv",new A(n,2))}function uc(a,b,c,d){R.call(this);this.type="PlaneGeometry";this.parameters={width:a,height:b,widthSegments:c,heightSegments:d};this.fromBufferGeometry(new lb(a,b,c,d));this.mergeVertices()}function lb(a,b,c,d){C.call(this);this.type="PlaneBufferGeometry";this.parameters={width:a,height:b,widthSegments:c,heightSegments:d};a=a||1;b=b||1;var e=a/2,f=b/2;c=Math.floor(c)||1;d=Math.floor(d)||1;var g=c+1,h=d+1,k=a/c,m=
17346 b/d,q=[],n=[],t=[],u=[];for(a=0;a<h;a++){var r=a*m-f;for(b=0;b<g;b++)n.push(b*k-e,-r,0),t.push(0,0,1),u.push(b/c),u.push(1-a/d)}for(a=0;a<d;a++)for(b=0;b<c;b++)e=b+g*(a+1),f=b+1+g*(a+1),h=b+1+g*a,q.push(b+g*a,e,h),q.push(e,f,h);this.setIndex(q);this.addAttribute("position",new A(n,3));this.addAttribute("normal",new A(t,3));this.addAttribute("uv",new A(u,2))}function J(){Object.defineProperty(this,"id",{value:Kf++});this.uuid=H.generateUUID();this.name="";this.type="Material";this.lights=this.fog=
17347 !0;this.blending=1;this.side=0;this.flatShading=!1;this.vertexColors=0;this.opacity=1;this.transparent=!1;this.blendSrc=204;this.blendDst=205;this.blendEquation=100;this.blendEquationAlpha=this.blendDstAlpha=this.blendSrcAlpha=null;this.depthFunc=3;this.depthWrite=this.depthTest=!0;this.clippingPlanes=null;this.clipShadows=this.clipIntersection=!1;this.shadowSide=null;this.colorWrite=!0;this.precision=null;this.polygonOffset=!1;this.polygonOffsetUnits=this.polygonOffsetFactor=0;this.dithering=!1;
17348 this.alphaTest=0;this.premultipliedAlpha=!1;this.overdraw=0;this.visible=!0;this.userData={};this.needsUpdate=!0}function da(a){J.call(this);this.type="MeshBasicMaterial";this.color=new G(16777215);this.lightMap=this.map=null;this.lightMapIntensity=1;this.aoMap=null;this.aoMapIntensity=1;this.envMap=this.alphaMap=this.specularMap=null;this.combine=0;this.reflectivity=1;this.refractionRatio=.98;this.wireframe=!1;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.lights=
17349 this.morphTargets=this.skinning=!1;this.setValues(a)}function ta(a){J.call(this);this.type="ShaderMaterial";this.defines={};this.uniforms={};this.vertexShader="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}";this.fragmentShader="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}";this.linewidth=1;this.wireframe=!1;this.wireframeLinewidth=1;this.morphNormals=this.morphTargets=this.skinning=this.clipping=this.lights=this.fog=!1;this.extensions=
17350 {derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1};this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv2:[0,0]};this.index0AttributeName=void 0;this.uniformsNeedUpdate=!1;void 0!==a&&(void 0!==a.attributes&&console.error("THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead."),this.setValues(a))}function mb(a,b){this.origin=void 0!==a?a:new p;this.direction=void 0!==b?b:new p}function ja(a,b,c){this.a=void 0!==a?a:new p;this.b=void 0!==b?b:new p;this.c=
17351 void 0!==c?c:new p}function la(a,b){D.call(this);this.type="Mesh";this.geometry=void 0!==a?a:new C;this.material=void 0!==b?b:new da({color:16777215*Math.random()});this.drawMode=0;this.updateMorphTargets()}function Lf(a,b,c,d){function e(a,c){b.buffers.color.setClear(a.r,a.g,a.b,c,d)}var f=new G(0),g=0,h,k,m;return{getClearColor:function(){return f},setClearColor:function(a,b){f.set(a);g=void 0!==b?b:1;e(f,g)},getClearAlpha:function(){return g},setClearAlpha:function(a){g=a;e(f,g)},render:function(b,
17352 d,t,u){d=d.background;null===d?e(f,g):d&&d.isColor&&(e(d,1),u=!0);(a.autoClear||u)&&a.clear(a.autoClearColor,a.autoClearDepth,a.autoClearStencil);d&&d.isCubeTexture?(void 0===m&&(m=new la(new kb(1,1,1),new ta({uniforms:nb.cube.uniforms,vertexShader:nb.cube.vertexShader,fragmentShader:nb.cube.fragmentShader,side:1,depthTest:!0,depthWrite:!1,fog:!1})),m.geometry.removeAttribute("normal"),m.geometry.removeAttribute("uv"),m.onBeforeRender=function(a,b,c){this.matrixWorld.copyPosition(c.matrixWorld)},
17353 c.update(m)),m.material.uniforms.tCube.value=d,b.push(m,m.geometry,m.material,0,null)):d&&d.isTexture&&(void 0===h&&(h=new Hb(-1,1,1,-1,0,1),k=new la(new lb(2,2),new da({depthTest:!1,depthWrite:!1,fog:!1})),c.update(k)),k.material.map=d,a.renderBufferDirect(h,null,k.geometry,k.material,k,null))}}}function Mf(a,b,c,d){var e;this.setMode=function(a){e=a};this.render=function(b,d){a.drawArrays(e,b,d);c.update(d,e)};this.renderInstances=function(f,g,h){if(d.isWebGL2)var k=a;else if(k=b.get("ANGLE_instanced_arrays"),
17354 null===k){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}k[d.isWebGL2?"drawArraysInstanced":"drawArraysInstancedANGLE"](e,g,h,f.maxInstancedCount);c.update(h,e,f.maxInstancedCount)}}function Nf(a,b,c){function d(b){if("highp"===b){if(0<a.getShaderPrecisionFormat(a.VERTEX_SHADER,a.HIGH_FLOAT).precision&&0<a.getShaderPrecisionFormat(a.FRAGMENT_SHADER,a.HIGH_FLOAT).precision)return"highp";b="mediump"}return"mediump"===
17355 b&&0<a.getShaderPrecisionFormat(a.VERTEX_SHADER,a.MEDIUM_FLOAT).precision&&0<a.getShaderPrecisionFormat(a.FRAGMENT_SHADER,a.MEDIUM_FLOAT).precision?"mediump":"lowp"}var e,f="undefined"!==typeof WebGL2RenderingContext&&a instanceof WebGL2RenderingContext,g=void 0!==c.precision?c.precision:"highp",h=d(g);h!==g&&(console.warn("THREE.WebGLRenderer:",g,"not supported, using",h,"instead."),g=h);c=!0===c.logarithmicDepthBuffer;h=a.getParameter(a.MAX_TEXTURE_IMAGE_UNITS);var k=a.getParameter(a.MAX_VERTEX_TEXTURE_IMAGE_UNITS),
17356 m=a.getParameter(a.MAX_TEXTURE_SIZE),q=a.getParameter(a.MAX_CUBE_MAP_TEXTURE_SIZE),n=a.getParameter(a.MAX_VERTEX_ATTRIBS),t=a.getParameter(a.MAX_VERTEX_UNIFORM_VECTORS),u=a.getParameter(a.MAX_VARYING_VECTORS),r=a.getParameter(a.MAX_FRAGMENT_UNIFORM_VECTORS),l=0<k,y=f||!!b.get("OES_texture_float");return{isWebGL2:f,getMaxAnisotropy:function(){if(void 0!==e)return e;var c=b.get("EXT_texture_filter_anisotropic");return e=null!==c?a.getParameter(c.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0},getMaxPrecision:d,
17357 precision:g,logarithmicDepthBuffer:c,maxTextures:h,maxVertexTextures:k,maxTextureSize:m,maxCubemapSize:q,maxAttributes:n,maxVertexUniforms:t,maxVaryings:u,maxFragmentUniforms:r,vertexTextures:l,floatFragmentTextures:y,floatVertexTextures:l&&y}}function Of(){function a(){m.value!==d&&(m.value=d,m.needsUpdate=0<e);c.numPlanes=e;c.numIntersection=0}function b(a,b,d,e){var f=null!==a?a.length:0,g=null;if(0!==f){g=m.value;if(!0!==e||null===g){e=d+4*f;b=b.matrixWorldInverse;k.getNormalMatrix(b);if(null===
17358 g||g.length<e)g=new Float32Array(e);for(e=0;e!==f;++e,d+=4)h.copy(a[e]).applyMatrix4(b,k),h.normal.toArray(g,d),g[d+3]=h.constant}m.value=g;m.needsUpdate=!0}c.numPlanes=f;return g}var c=this,d=null,e=0,f=!1,g=!1,h=new Ma,k=new ra,m={value:null,needsUpdate:!1};this.uniform=m;this.numIntersection=this.numPlanes=0;this.init=function(a,c,g){var h=0!==a.length||c||0!==e||f;f=c;d=b(a,g,0);e=a.length;return h};this.beginShadows=function(){g=!0;b(null)};this.endShadows=function(){g=!1;a()};this.setState=
17359 function(c,h,k,u,r,l){if(!f||null===c||0===c.length||g&&!k)g?b(null):a();else{k=g?0:e;var n=4*k,q=r.clippingState||null;m.value=q;q=b(c,u,n,l);for(c=0;c!==n;++c)q[c]=d[c];r.clippingState=q;this.numIntersection=h?this.numPlanes:0;this.numPlanes+=k}}}function Pf(a){var b={};return{get:function(c){if(void 0!==b[c])return b[c];switch(c){case "WEBGL_depth_texture":var d=a.getExtension("WEBGL_depth_texture")||a.getExtension("MOZ_WEBGL_depth_texture")||a.getExtension("WEBKIT_WEBGL_depth_texture");break;
17360 case "EXT_texture_filter_anisotropic":d=a.getExtension("EXT_texture_filter_anisotropic")||a.getExtension("MOZ_EXT_texture_filter_anisotropic")||a.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case "WEBGL_compressed_texture_s3tc":d=a.getExtension("WEBGL_compressed_texture_s3tc")||a.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||a.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case "WEBGL_compressed_texture_pvrtc":d=a.getExtension("WEBGL_compressed_texture_pvrtc")||a.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");
17361 break;default:d=a.getExtension(c)}null===d&&console.warn("THREE.WebGLRenderer: "+c+" extension not supported.");return b[c]=d}}}function Qf(a,b,c){function d(a){var h=a.target;a=e[h.id];null!==a.index&&b.remove(a.index);for(var g in a.attributes)b.remove(a.attributes[g]);h.removeEventListener("dispose",d);delete e[h.id];if(g=f[a.id])b.remove(g),delete f[a.id];c.memory.geometries--}var e={},f={};return{get:function(a,b){var f=e[b.id];if(f)return f;b.addEventListener("dispose",d);b.isBufferGeometry?
17362 f=b:b.isGeometry&&(void 0===b._bufferGeometry&&(b._bufferGeometry=(new C).setFromObject(a)),f=b._bufferGeometry);e[b.id]=f;c.memory.geometries++;return f},update:function(c){var d=c.index,e=c.attributes;null!==d&&b.update(d,a.ELEMENT_ARRAY_BUFFER);for(var f in e)b.update(e[f],a.ARRAY_BUFFER);c=c.morphAttributes;for(f in c){d=c[f];e=0;for(var g=d.length;e<g;e++)b.update(d[e],a.ARRAY_BUFFER)}},getWireframeAttribute:function(c){var d=f[c.id];if(d)return d;d=[];var e=c.index,g=c.attributes;if(null!==
17363 e){e=e.array;g=0;for(var q=e.length;g<q;g+=3){var n=e[g+0],t=e[g+1],u=e[g+2];d.push(n,t,t,u,u,n)}}else for(e=g.position.array,g=0,q=e.length/3-1;g<q;g+=3)n=g+0,t=g+1,u=g+2,d.push(n,t,t,u,u,n);d=new (65535<Fe(d)?jb:ib)(d,1);b.update(d,a.ELEMENT_ARRAY_BUFFER);return f[c.id]=d}}}function Rf(a,b,c,d){var e,f,g;this.setMode=function(a){e=a};this.setIndex=function(a){f=a.type;g=a.bytesPerElement};this.render=function(b,d){a.drawElements(e,d,f,b*g);c.update(d,e)};this.renderInstances=function(h,k,m){if(d.isWebGL2)var q=
17364 a;else if(q=b.get("ANGLE_instanced_arrays"),null===q){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}q[d.isWebGL2?"drawElementsInstanced":"drawElementsInstancedANGLE"](e,m,f,k*g,h.maxInstancedCount);c.update(m,e,h.maxInstancedCount)}}function Sf(a){var b={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:b,programs:null,autoReset:!0,reset:function(){b.frame++;
17365 b.calls=0;b.triangles=0;b.points=0;b.lines=0},update:function(c,d,e){e=e||1;b.calls++;switch(d){case a.TRIANGLES:b.triangles+=c/3*e;break;case a.TRIANGLE_STRIP:case a.TRIANGLE_FAN:b.triangles+=e*(c-2);break;case a.LINES:b.lines+=c/2*e;break;case a.LINE_STRIP:b.lines+=e*(c-1);break;case a.LINE_LOOP:b.lines+=e*c;break;case a.POINTS:b.points+=e*c;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",d)}}}}function Tf(a,b){return Math.abs(b[1])-Math.abs(a[1])}function Uf(a){var b={},c=new Float32Array(8);
17366 return{update:function(d,e,f,g){var h=d.morphTargetInfluences,k=h.length;d=b[e.id];if(void 0===d){d=[];for(var m=0;m<k;m++)d[m]=[m,0];b[e.id]=d}var q=f.morphTargets&&e.morphAttributes.position;f=f.morphNormals&&e.morphAttributes.normal;for(m=0;m<k;m++){var n=d[m];0!==n[1]&&(q&&e.removeAttribute("morphTarget"+m),f&&e.removeAttribute("morphNormal"+m))}for(m=0;m<k;m++)n=d[m],n[0]=m,n[1]=h[m];d.sort(Tf);for(m=0;8>m;m++){if(n=d[m])if(h=n[0],k=n[1]){q&&e.addAttribute("morphTarget"+m,q[h]);f&&e.addAttribute("morphNormal"+
17367 m,f[h]);c[m]=k;continue}c[m]=0}g.getUniforms().setValue(a,"morphTargetInfluences",c)}}}function Vf(a,b){var c={};return{update:function(d){var e=b.render.frame,f=d.geometry,g=a.get(d,f);c[g.id]!==e&&(f.isGeometry&&g.updateFromObject(d),a.update(g),c[g.id]=e);return g},dispose:function(){c={}}}}function Ua(a,b,c,d,e,f,g,h,k,m){a=void 0!==a?a:[];T.call(this,a,void 0!==b?b:301,c,d,e,f,g,h,k,m);this.flipY=!1}function Jb(a,b,c){var d=a[0];if(0>=d||0<d)return a;var e=b*c,f=Ge[e];void 0===f&&(f=new Float32Array(e),
17368 Ge[e]=f);if(0!==b)for(d.toArray(f,0),d=1,e=0;d!==b;++d)e+=c,a[d].toArray(f,e);return f}function ea(a,b){if(a.length!==b.length)return!1;for(var c=0,d=a.length;c<d;c++)if(a[c]!==b[c])return!1;return!0}function qa(a,b){for(var c=0,d=b.length;c<d;c++)a[c]=b[c]}function He(a,b){var c=Ie[b];void 0===c&&(c=new Int32Array(b),Ie[b]=c);for(var d=0;d!==b;++d)c[d]=a.allocTextureUnit();return c}function Wf(a,b){var c=this.cache;c[0]!==b&&(a.uniform1f(this.addr,b),c[0]=b)}function Xf(a,b){var c=this.cache;c[0]!==
17369 b&&(a.uniform1i(this.addr,b),c[0]=b)}function Yf(a,b){var c=this.cache;if(void 0!==b.x){if(c[0]!==b.x||c[1]!==b.y)a.uniform2f(this.addr,b.x,b.y),c[0]=b.x,c[1]=b.y}else ea(c,b)||(a.uniform2fv(this.addr,b),qa(c,b))}function Zf(a,b){var c=this.cache;if(void 0!==b.x){if(c[0]!==b.x||c[1]!==b.y||c[2]!==b.z)a.uniform3f(this.addr,b.x,b.y,b.z),c[0]=b.x,c[1]=b.y,c[2]=b.z}else if(void 0!==b.r){if(c[0]!==b.r||c[1]!==b.g||c[2]!==b.b)a.uniform3f(this.addr,b.r,b.g,b.b),c[0]=b.r,c[1]=b.g,c[2]=b.b}else ea(c,b)||(a.uniform3fv(this.addr,
17370 b),qa(c,b))}function $f(a,b){var c=this.cache;if(void 0!==b.x){if(c[0]!==b.x||c[1]!==b.y||c[2]!==b.z||c[3]!==b.w)a.uniform4f(this.addr,b.x,b.y,b.z,b.w),c[0]=b.x,c[1]=b.y,c[2]=b.z,c[3]=b.w}else ea(c,b)||(a.uniform4fv(this.addr,b),qa(c,b))}function ag(a,b){var c=this.cache,d=b.elements;void 0===d?ea(c,b)||(a.uniformMatrix2fv(this.addr,!1,b),qa(c,b)):ea(c,d)||(Je.set(d),a.uniformMatrix2fv(this.addr,!1,Je),qa(c,d))}function bg(a,b){var c=this.cache,d=b.elements;void 0===d?ea(c,b)||(a.uniformMatrix3fv(this.addr,
17371 !1,b),qa(c,b)):ea(c,d)||(Ke.set(d),a.uniformMatrix3fv(this.addr,!1,Ke),qa(c,d))}function cg(a,b){var c=this.cache,d=b.elements;void 0===d?ea(c,b)||(a.uniformMatrix4fv(this.addr,!1,b),qa(c,b)):ea(c,d)||(Le.set(d),a.uniformMatrix4fv(this.addr,!1,Le),qa(c,d))}function dg(a,b,c){var d=this.cache,e=c.allocTextureUnit();d[0]!==e&&(a.uniform1i(this.addr,e),d[0]=e);c.setTexture2D(b||Me,e)}function eg(a,b,c){var d=this.cache,e=c.allocTextureUnit();d[0]!==e&&(a.uniform1i(this.addr,e),d[0]=e);c.setTextureCube(b||
17372 Ne,e)}function Oe(a,b){var c=this.cache;ea(c,b)||(a.uniform2iv(this.addr,b),qa(c,b))}function Pe(a,b){var c=this.cache;ea(c,b)||(a.uniform3iv(this.addr,b),qa(c,b))}function Qe(a,b){var c=this.cache;ea(c,b)||(a.uniform4iv(this.addr,b),qa(c,b))}function fg(a){switch(a){case 5126:return Wf;case 35664:return Yf;case 35665:return Zf;case 35666:return $f;case 35674:return ag;case 35675:return bg;case 35676:return cg;case 35678:case 36198:return dg;case 35680:return eg;case 5124:case 35670:return Xf;case 35667:case 35671:return Oe;
17373 case 35668:case 35672:return Pe;case 35669:case 35673:return Qe}}function gg(a,b){var c=this.cache;ea(c,b)||(a.uniform1fv(this.addr,b),qa(c,b))}function hg(a,b){var c=this.cache;ea(c,b)||(a.uniform1iv(this.addr,b),qa(c,b))}function ig(a,b){var c=this.cache;b=Jb(b,this.size,2);ea(c,b)||(a.uniform2fv(this.addr,b),this.updateCache(b))}function jg(a,b){var c=this.cache;b=Jb(b,this.size,3);ea(c,b)||(a.uniform3fv(this.addr,b),this.updateCache(b))}function kg(a,b){var c=this.cache;b=Jb(b,this.size,4);ea(c,
17374 b)||(a.uniform4fv(this.addr,b),this.updateCache(b))}function lg(a,b){var c=this.cache;b=Jb(b,this.size,4);ea(c,b)||(a.uniformMatrix2fv(this.addr,!1,b),this.updateCache(b))}function mg(a,b){var c=this.cache;b=Jb(b,this.size,9);ea(c,b)||(a.uniformMatrix3fv(this.addr,!1,b),this.updateCache(b))}function ng(a,b){var c=this.cache;b=Jb(b,this.size,16);ea(c,b)||(a.uniformMatrix4fv(this.addr,!1,b),this.updateCache(b))}function og(a,b,c){var d=this.cache,e=b.length,f=He(c,e);!1===ea(d,f)&&(a.uniform1iv(this.addr,
17375 f),qa(d,f));for(a=0;a!==e;++a)c.setTexture2D(b[a]||Me,f[a])}function pg(a,b,c){var d=this.cache,e=b.length,f=He(c,e);!1===ea(d,f)&&(a.uniform1iv(this.addr,f),qa(d,f));for(a=0;a!==e;++a)c.setTextureCube(b[a]||Ne,f[a])}function qg(a){switch(a){case 5126:return gg;case 35664:return ig;case 35665:return jg;case 35666:return kg;case 35674:return lg;case 35675:return mg;case 35676:return ng;case 35678:return og;case 35680:return pg;case 5124:case 35670:return hg;case 35667:case 35671:return Oe;case 35668:case 35672:return Pe;
17376 case 35669:case 35673:return Qe}}function rg(a,b,c){this.id=a;this.addr=c;this.cache=[];this.setValue=fg(b.type)}function Re(a,b,c){this.id=a;this.addr=c;this.cache=[];this.size=b.size;this.setValue=qg(b.type)}function Se(a){this.id=a;this.seq=[];this.map={}}function Za(a,b,c){this.seq=[];this.map={};this.renderer=c;c=a.getProgramParameter(b,a.ACTIVE_UNIFORMS);for(var d=0;d<c;++d){var e=a.getActiveUniform(b,d),f=a.getUniformLocation(b,e.name),g=this,h=e.name,k=h.length;for(Vd.lastIndex=0;;){var m=
17377 Vd.exec(h),q=Vd.lastIndex,n=m[1],t=m[3];"]"===m[2]&&(n|=0);if(void 0===t||"["===t&&q+2===k){h=g;e=void 0===t?new rg(n,e,f):new Re(n,e,f);h.seq.push(e);h.map[e.id]=e;break}else t=g.map[n],void 0===t&&(t=new Se(n),n=g,g=t,n.seq.push(g),n.map[g.id]=g),g=t}}}function sg(a){a=a.split("\n");for(var b=0;b<a.length;b++)a[b]=b+1+": "+a[b];return a.join("\n")}function Te(a,b,c){var d=a.createShader(b);a.shaderSource(d,c);a.compileShader(d);!1===a.getShaderParameter(d,a.COMPILE_STATUS)&&console.error("THREE.WebGLShader: Shader couldn't compile.");
17378 ""!==a.getShaderInfoLog(d)&&console.warn("THREE.WebGLShader: gl.getShaderInfoLog()",b===a.VERTEX_SHADER?"vertex":"fragment",a.getShaderInfoLog(d),sg(c));return d}function Ue(a){switch(a){case 3E3:return["Linear","( value )"];case 3001:return["sRGB","( value )"];case 3002:return["RGBE","( value )"];case 3004:return["RGBM","( value, 7.0 )"];case 3005:return["RGBM","( value, 16.0 )"];case 3006:return["RGBD","( value, 256.0 )"];case 3007:return["Gamma","( value, float( GAMMA_FACTOR ) )"];default:throw Error("unsupported encoding: "+
17379 a);}}function Wd(a,b){b=Ue(b);return"vec4 "+a+"( vec4 value ) { return "+b[0]+"ToLinear"+b[1]+"; }"}function tg(a,b){b=Ue(b);return"vec4 "+a+"( vec4 value ) { return LinearTo"+b[0]+b[1]+"; }"}function ug(a,b){switch(b){case 1:b="Linear";break;case 2:b="Reinhard";break;case 3:b="Uncharted2";break;case 4:b="OptimizedCineon";break;default:throw Error("unsupported toneMapping: "+b);}return"vec3 "+a+"( vec3 color ) { return "+b+"ToneMapping( color ); }"}function vg(a,b,c){a=a||{};return[a.derivatives||
17380 b.envMapCubeUV||b.bumpMap||b.normalMap&&!b.objectSpaceNormalMap||b.flatShading?"#extension GL_OES_standard_derivatives : enable":"",(a.fragDepth||b.logarithmicDepthBuffer)&&c.get("EXT_frag_depth")?"#extension GL_EXT_frag_depth : enable":"",a.drawBuffers&&c.get("WEBGL_draw_buffers")?"#extension GL_EXT_draw_buffers : require":"",(a.shaderTextureLOD||b.envMap)&&c.get("EXT_shader_texture_lod")?"#extension GL_EXT_shader_texture_lod : enable":""].filter(vc).join("\n")}function wg(a){var b=[],c;for(c in a){var d=
17381 a[c];!1!==d&&b.push("#define "+c+" "+d)}return b.join("\n")}function vc(a){return""!==a}function Ve(a,b){return a.replace(/NUM_DIR_LIGHTS/g,b.numDirLights).replace(/NUM_SPOT_LIGHTS/g,b.numSpotLights).replace(/NUM_RECT_AREA_LIGHTS/g,b.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,b.numPointLights).replace(/NUM_HEMI_LIGHTS/g,b.numHemiLights)}function We(a,b){return a.replace(/NUM_CLIPPING_PLANES/g,b.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,b.numClippingPlanes-b.numClipIntersection)}function Xd(a){return a.replace(/^[ \t]*#include +<([\w\d./]+)>/gm,
17382 function(a,c){a=S[c];if(void 0===a)throw Error("Can not resolve #include <"+c+">");return Xd(a)})}function Xe(a){return a.replace(/#pragma unroll_loop[\s]+?for \( int i = (\d+); i < (\d+); i \+\+ \) \{([\s\S]+?)(?=\})\}/g,function(a,c,d,e){a="";for(c=parseInt(c);c<parseInt(d);c++)a+=e.replace(/\[ i \]/g,"[ "+c+" ]");return a})}function xg(a,b,c,d,e,f,g){var h=a.context,k=d.defines,m=e.vertexShader,q=e.fragmentShader,n="SHADOWMAP_TYPE_BASIC";1===f.shadowMapType?n="SHADOWMAP_TYPE_PCF":2===f.shadowMapType&&
17383 (n="SHADOWMAP_TYPE_PCF_SOFT");var t="ENVMAP_TYPE_CUBE",u="ENVMAP_MODE_REFLECTION",r="ENVMAP_BLENDING_MULTIPLY";if(f.envMap){switch(d.envMap.mapping){case 301:case 302:t="ENVMAP_TYPE_CUBE";break;case 306:case 307:t="ENVMAP_TYPE_CUBE_UV";break;case 303:case 304:t="ENVMAP_TYPE_EQUIREC";break;case 305:t="ENVMAP_TYPE_SPHERE"}switch(d.envMap.mapping){case 302:case 304:u="ENVMAP_MODE_REFRACTION"}switch(d.combine){case 0:r="ENVMAP_BLENDING_MULTIPLY";break;case 1:r="ENVMAP_BLENDING_MIX";break;case 2:r="ENVMAP_BLENDING_ADD"}}var l=
17384 0<a.gammaFactor?a.gammaFactor:1,y=g.isWebGL2?"":vg(d.extensions,f,b),p=wg(k),w=h.createProgram();d.isRawShaderMaterial?(k=[p].filter(vc).join("\n"),0<k.length&&(k+="\n"),b=[y,p].filter(vc).join("\n"),0<b.length&&(b+="\n")):(k=["precision "+f.precision+" float;","precision "+f.precision+" int;","#define SHADER_NAME "+e.name,p,f.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+l,"#define MAX_BONES "+f.maxBones,f.useFog&&f.fog?"#define USE_FOG":"",f.useFog&&f.fogExp?"#define FOG_EXP2":
17385 "",f.map?"#define USE_MAP":"",f.envMap?"#define USE_ENVMAP":"",f.envMap?"#define "+u:"",f.lightMap?"#define USE_LIGHTMAP":"",f.aoMap?"#define USE_AOMAP":"",f.emissiveMap?"#define USE_EMISSIVEMAP":"",f.bumpMap?"#define USE_BUMPMAP":"",f.normalMap?"#define USE_NORMALMAP":"",f.normalMap&&f.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",f.displacementMap&&f.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",f.specularMap?"#define USE_SPECULARMAP":"",f.roughnessMap?"#define USE_ROUGHNESSMAP":
17386 "",f.metalnessMap?"#define USE_METALNESSMAP":"",f.alphaMap?"#define USE_ALPHAMAP":"",f.vertexColors?"#define USE_COLOR":"",f.flatShading?"#define FLAT_SHADED":"",f.skinning?"#define USE_SKINNING":"",f.useVertexTexture?"#define BONE_TEXTURE":"",f.morphTargets?"#define USE_MORPHTARGETS":"",f.morphNormals&&!1===f.flatShading?"#define USE_MORPHNORMALS":"",f.doubleSided?"#define DOUBLE_SIDED":"",f.flipSided?"#define FLIP_SIDED":"",f.shadowMapEnabled?"#define USE_SHADOWMAP":"",f.shadowMapEnabled?"#define "+
17387 n:"",f.sizeAttenuation?"#define USE_SIZEATTENUATION":"",f.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",f.logarithmicDepthBuffer&&(g.isWebGL2||b.get("EXT_frag_depth"))?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_COLOR","\tattribute vec3 color;",
17388 "#endif","#ifdef USE_MORPHTARGETS","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif",
17389 "#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(vc).join("\n"),b=[y,"precision "+f.precision+" float;","precision "+f.precision+" int;","#define SHADER_NAME "+e.name,p,f.alphaTest?"#define ALPHATEST "+f.alphaTest+(f.alphaTest%1?"":".0"):"","#define GAMMA_FACTOR "+l,f.useFog&&f.fog?"#define USE_FOG":"",f.useFog&&f.fogExp?"#define FOG_EXP2":"",f.map?"#define USE_MAP":"",f.envMap?"#define USE_ENVMAP":"",f.envMap?"#define "+t:"",f.envMap?"#define "+
17390 u:"",f.envMap?"#define "+r:"",f.lightMap?"#define USE_LIGHTMAP":"",f.aoMap?"#define USE_AOMAP":"",f.emissiveMap?"#define USE_EMISSIVEMAP":"",f.bumpMap?"#define USE_BUMPMAP":"",f.normalMap?"#define USE_NORMALMAP":"",f.normalMap&&f.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",f.specularMap?"#define USE_SPECULARMAP":"",f.roughnessMap?"#define USE_ROUGHNESSMAP":"",f.metalnessMap?"#define USE_METALNESSMAP":"",f.alphaMap?"#define USE_ALPHAMAP":"",f.vertexColors?"#define USE_COLOR":"",f.gradientMap?
17391 "#define USE_GRADIENTMAP":"",f.flatShading?"#define FLAT_SHADED":"",f.doubleSided?"#define DOUBLE_SIDED":"",f.flipSided?"#define FLIP_SIDED":"",f.shadowMapEnabled?"#define USE_SHADOWMAP":"",f.shadowMapEnabled?"#define "+n:"",f.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",f.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",f.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",f.logarithmicDepthBuffer&&(g.isWebGL2||b.get("EXT_frag_depth"))?"#define USE_LOGDEPTHBUF_EXT":"",f.envMap&&
17392 (g.isWebGL2||b.get("EXT_shader_texture_lod"))?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;",0!==f.toneMapping?"#define TONE_MAPPING":"",0!==f.toneMapping?S.tonemapping_pars_fragment:"",0!==f.toneMapping?ug("toneMapping",f.toneMapping):"",f.dithering?"#define DITHERING":"",f.outputEncoding||f.mapEncoding||f.envMapEncoding||f.emissiveMapEncoding?S.encodings_pars_fragment:"",f.mapEncoding?Wd("mapTexelToLinear",f.mapEncoding):"",f.envMapEncoding?Wd("envMapTexelToLinear",
17393 f.envMapEncoding):"",f.emissiveMapEncoding?Wd("emissiveMapTexelToLinear",f.emissiveMapEncoding):"",f.outputEncoding?tg("linearToOutputTexel",f.outputEncoding):"",f.depthPacking?"#define DEPTH_PACKING "+d.depthPacking:"","\n"].filter(vc).join("\n"));m=Xd(m);m=Ve(m,f);m=We(m,f);q=Xd(q);q=Ve(q,f);q=We(q,f);m=Xe(m);q=Xe(q);g.isWebGL2&&!d.isRawShaderMaterial&&(g=!1,n=/^\s*#version\s+300\s+es\s*\n/,d.isShaderMaterial&&null!==m.match(n)&&null!==q.match(n)&&(g=!0,m=m.replace(n,""),q=q.replace(n,"")),k="#version 300 es\n\n#define attribute in\n#define varying out\n#define texture2D texture\n"+
17394 k,b=["#version 300 es\n\n#define varying in",g?"":"out highp vec4 pc_fragColor;",g?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth\n#define texture2D texture\n#define textureCube texture\n#define texture2DProj textureProj\n#define texture2DLodEXT textureLod\n#define texture2DProjLodEXT textureProjLod\n#define textureCubeLodEXT textureLod\n#define texture2DGradEXT textureGrad\n#define texture2DProjGradEXT textureProjGrad\n#define textureCubeGradEXT textureGrad"].join("\n")+
17395 "\n"+b);q=b+q;m=Te(h,h.VERTEX_SHADER,k+m);q=Te(h,h.FRAGMENT_SHADER,q);h.attachShader(w,m);h.attachShader(w,q);void 0!==d.index0AttributeName?h.bindAttribLocation(w,0,d.index0AttributeName):!0===f.morphTargets&&h.bindAttribLocation(w,0,"position");h.linkProgram(w);f=h.getProgramInfoLog(w).trim();g=h.getShaderInfoLog(m).trim();n=h.getShaderInfoLog(q).trim();u=t=!0;if(!1===h.getProgramParameter(w,h.LINK_STATUS))t=!1,console.error("THREE.WebGLProgram: shader error: ",h.getError(),"gl.VALIDATE_STATUS",
17396 h.getProgramParameter(w,h.VALIDATE_STATUS),"gl.getProgramInfoLog",f,g,n);else if(""!==f)console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",f);else if(""===g||""===n)u=!1;u&&(this.diagnostics={runnable:t,material:d,programLog:f,vertexShader:{log:g,prefix:k},fragmentShader:{log:n,prefix:b}});h.deleteShader(m);h.deleteShader(q);var B;this.getUniforms=function(){void 0===B&&(B=new Za(h,w,a));return B};var E;this.getAttributes=function(){if(void 0===E){for(var a={},b=h.getProgramParameter(w,h.ACTIVE_ATTRIBUTES),
17397 c=0;c<b;c++){var d=h.getActiveAttrib(w,c).name;a[d]=h.getAttribLocation(w,d)}E=a}return E};this.destroy=function(){h.deleteProgram(w);this.program=void 0};Object.defineProperties(this,{uniforms:{get:function(){console.warn("THREE.WebGLProgram: .uniforms is now .getUniforms().");return this.getUniforms()}},attributes:{get:function(){console.warn("THREE.WebGLProgram: .attributes is now .getAttributes().");return this.getAttributes()}}});this.name=e.name;this.id=yg++;this.code=c;this.usedTimes=1;this.program=
17398 w;this.vertexShader=m;this.fragmentShader=q;return this}function zg(a,b,c){function d(a,b){if(a)a.isTexture?c=a.encoding:a.isWebGLRenderTarget&&(console.warn("THREE.WebGLPrograms.getTextureEncodingFromMap: don't use render targets as textures. Use their .texture property instead."),c=a.texture.encoding);else var c=3E3;3E3===c&&b&&(c=3007);return c}var e=[],f={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",
17399 MeshPhongMaterial:"phong",MeshToonMaterial:"phong",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"},g="precision supportsVertexTextures map mapEncoding envMap envMapMode envMapEncoding lightMap aoMap emissiveMap emissiveMapEncoding bumpMap normalMap objectSpaceNormalMap displacementMap specularMap roughnessMap metalnessMap gradientMap alphaMap combine vertexColors fog useFog fogExp flatShading sizeAttenuation logarithmicDepthBuffer skinning maxBones useVertexTexture morphTargets morphNormals maxMorphTargets maxMorphNormals premultipliedAlpha numDirLights numPointLights numSpotLights numHemiLights numRectAreaLights shadowMapEnabled shadowMapType toneMapping physicallyCorrectLights alphaTest doubleSided flipSided numClippingPlanes numClipIntersection depthPacking dithering".split(" ");
17400 this.getParameters=function(b,e,g,q,n,t,u){var h=f[b.type];if(u.isSkinnedMesh){var k=u.skeleton.bones;if(c.floatVertexTextures)k=1024;else{var m=Math.min(Math.floor((c.maxVertexUniforms-20)/4),k.length);m<k.length?(console.warn("THREE.WebGLRenderer: Skeleton has "+k.length+" bones. This GPU supports "+m+"."),k=0):k=m}}else k=0;m=c.precision;null!==b.precision&&(m=c.getMaxPrecision(b.precision),m!==b.precision&&console.warn("THREE.WebGLProgram.getParameters:",b.precision,"not supported, using",m,"instead."));
17401 var l=a.getRenderTarget();return{shaderID:h,precision:m,supportsVertexTextures:c.vertexTextures,outputEncoding:d(l?l.texture:null,a.gammaOutput),map:!!b.map,mapEncoding:d(b.map,a.gammaInput),envMap:!!b.envMap,envMapMode:b.envMap&&b.envMap.mapping,envMapEncoding:d(b.envMap,a.gammaInput),envMapCubeUV:!!b.envMap&&(306===b.envMap.mapping||307===b.envMap.mapping),lightMap:!!b.lightMap,aoMap:!!b.aoMap,emissiveMap:!!b.emissiveMap,emissiveMapEncoding:d(b.emissiveMap,a.gammaInput),bumpMap:!!b.bumpMap,normalMap:!!b.normalMap,
17402 objectSpaceNormalMap:1===b.normalMapType,displacementMap:!!b.displacementMap,roughnessMap:!!b.roughnessMap,metalnessMap:!!b.metalnessMap,specularMap:!!b.specularMap,alphaMap:!!b.alphaMap,gradientMap:!!b.gradientMap,combine:b.combine,vertexColors:b.vertexColors,fog:!!q,useFog:b.fog,fogExp:q&&q.isFogExp2,flatShading:b.flatShading,sizeAttenuation:b.sizeAttenuation,logarithmicDepthBuffer:c.logarithmicDepthBuffer,skinning:b.skinning&&0<k,maxBones:k,useVertexTexture:c.floatVertexTextures,morphTargets:b.morphTargets,
17403 morphNormals:b.morphNormals,maxMorphTargets:a.maxMorphTargets,maxMorphNormals:a.maxMorphNormals,numDirLights:e.directional.length,numPointLights:e.point.length,numSpotLights:e.spot.length,numRectAreaLights:e.rectArea.length,numHemiLights:e.hemi.length,numClippingPlanes:n,numClipIntersection:t,dithering:b.dithering,shadowMapEnabled:a.shadowMap.enabled&&u.receiveShadow&&0<g.length,shadowMapType:a.shadowMap.type,toneMapping:a.toneMapping,physicallyCorrectLights:a.physicallyCorrectLights,premultipliedAlpha:b.premultipliedAlpha,
17404 alphaTest:b.alphaTest,doubleSided:2===b.side,flipSided:1===b.side,depthPacking:void 0!==b.depthPacking?b.depthPacking:!1}};this.getProgramCode=function(b,c){var d=[];c.shaderID?d.push(c.shaderID):(d.push(b.fragmentShader),d.push(b.vertexShader));if(void 0!==b.defines)for(var e in b.defines)d.push(e),d.push(b.defines[e]);for(e=0;e<g.length;e++)d.push(c[g[e]]);d.push(b.onBeforeCompile.toString());d.push(a.gammaOutput);return d.join()};this.acquireProgram=function(d,f,g,q){for(var h,k=0,m=e.length;k<
17405 m;k++){var r=e[k];if(r.code===q){h=r;++h.usedTimes;break}}void 0===h&&(h=new xg(a,b,q,d,f,g,c),e.push(h));return h};this.releaseProgram=function(a){if(0===--a.usedTimes){var b=e.indexOf(a);e[b]=e[e.length-1];e.pop();a.destroy()}};this.programs=e}function Ag(){var a=new WeakMap;return{get:function(b){var c=a.get(b);void 0===c&&(c={},a.set(b,c));return c},remove:function(b){a.delete(b)},update:function(b,c,d){a.get(b)[c]=d},dispose:function(){a=new WeakMap}}}function Bg(a,b){return a.renderOrder!==
17406 b.renderOrder?a.renderOrder-b.renderOrder:a.program&&b.program&&a.program!==b.program?a.program.id-b.program.id:a.material.id!==b.material.id?a.material.id-b.material.id:a.z!==b.z?a.z-b.z:a.id-b.id}function Cg(a,b){return a.renderOrder!==b.renderOrder?a.renderOrder-b.renderOrder:a.z!==b.z?b.z-a.z:a.id-b.id}function Dg(){var a=[],b=0,c=[],d=[];return{opaque:c,transparent:d,init:function(){b=0;c.length=0;d.length=0},push:function(e,f,g,h,k){var m=a[b];void 0===m?(m={id:e.id,object:e,geometry:f,material:g,
17407 program:g.program,renderOrder:e.renderOrder,z:h,group:k},a[b]=m):(m.id=e.id,m.object=e,m.geometry=f,m.material=g,m.program=g.program,m.renderOrder=e.renderOrder,m.z=h,m.group=k);(!0===g.transparent?d:c).push(m);b++},sort:function(){1<c.length&&c.sort(Bg);1<d.length&&d.sort(Cg)}}}function Eg(){var a={};return{get:function(b,c){b=b.id+","+c.id;c=a[b];void 0===c&&(c=new Dg,a[b]=c);return c},dispose:function(){a={}}}}function Fg(){var a={};return{get:function(b){if(void 0!==a[b.id])return a[b.id];switch(b.type){case "DirectionalLight":var c=
17408 {direction:new p,color:new G,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new z};break;case "SpotLight":c={position:new p,direction:new p,color:new G,distance:0,coneCos:0,penumbraCos:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new z};break;case "PointLight":c={position:new p,color:new G,distance:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new z,shadowCameraNear:1,shadowCameraFar:1E3};break;case "HemisphereLight":c={direction:new p,skyColor:new G,groundColor:new G};
17409 break;case "RectAreaLight":c={color:new G,position:new p,halfWidth:new p,halfHeight:new p}}return a[b.id]=c}}}function Gg(){var a=new Fg,b={id:Hg++,hash:{stateID:-1,directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,shadowsLength:-1},ambient:[0,0,0],directional:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],point:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[]},c=new p,d=new I,e=new I;return{setup:function(f,
17410 g,h){var k=0,m=0,q=0,n=0,t=0,u=0,r=0,l=0;h=h.matrixWorldInverse;for(var y=0,p=f.length;y<p;y++){var w=f[y],B=w.color,E=w.intensity,P=w.distance,N=w.shadow&&w.shadow.map?w.shadow.map.texture:null;if(w.isAmbientLight)k+=B.r*E,m+=B.g*E,q+=B.b*E;else if(w.isDirectionalLight){var O=a.get(w);O.color.copy(w.color).multiplyScalar(w.intensity);O.direction.setFromMatrixPosition(w.matrixWorld);c.setFromMatrixPosition(w.target.matrixWorld);O.direction.sub(c);O.direction.transformDirection(h);if(O.shadow=w.castShadow)B=
17411 w.shadow,O.shadowBias=B.bias,O.shadowRadius=B.radius,O.shadowMapSize=B.mapSize;b.directionalShadowMap[n]=N;b.directionalShadowMatrix[n]=w.shadow.matrix;b.directional[n]=O;n++}else if(w.isSpotLight){O=a.get(w);O.position.setFromMatrixPosition(w.matrixWorld);O.position.applyMatrix4(h);O.color.copy(B).multiplyScalar(E);O.distance=P;O.direction.setFromMatrixPosition(w.matrixWorld);c.setFromMatrixPosition(w.target.matrixWorld);O.direction.sub(c);O.direction.transformDirection(h);O.coneCos=Math.cos(w.angle);
17412 O.penumbraCos=Math.cos(w.angle*(1-w.penumbra));O.decay=0===w.distance?0:w.decay;if(O.shadow=w.castShadow)B=w.shadow,O.shadowBias=B.bias,O.shadowRadius=B.radius,O.shadowMapSize=B.mapSize;b.spotShadowMap[u]=N;b.spotShadowMatrix[u]=w.shadow.matrix;b.spot[u]=O;u++}else if(w.isRectAreaLight)O=a.get(w),O.color.copy(B).multiplyScalar(E),O.position.setFromMatrixPosition(w.matrixWorld),O.position.applyMatrix4(h),e.identity(),d.copy(w.matrixWorld),d.premultiply(h),e.extractRotation(d),O.halfWidth.set(.5*w.width,
17413 0,0),O.halfHeight.set(0,.5*w.height,0),O.halfWidth.applyMatrix4(e),O.halfHeight.applyMatrix4(e),b.rectArea[r]=O,r++;else if(w.isPointLight){O=a.get(w);O.position.setFromMatrixPosition(w.matrixWorld);O.position.applyMatrix4(h);O.color.copy(w.color).multiplyScalar(w.intensity);O.distance=w.distance;O.decay=0===w.distance?0:w.decay;if(O.shadow=w.castShadow)B=w.shadow,O.shadowBias=B.bias,O.shadowRadius=B.radius,O.shadowMapSize=B.mapSize,O.shadowCameraNear=B.camera.near,O.shadowCameraFar=B.camera.far;
17414 b.pointShadowMap[t]=N;b.pointShadowMatrix[t]=w.shadow.matrix;b.point[t]=O;t++}else w.isHemisphereLight&&(O=a.get(w),O.direction.setFromMatrixPosition(w.matrixWorld),O.direction.transformDirection(h),O.direction.normalize(),O.skyColor.copy(w.color).multiplyScalar(E),O.groundColor.copy(w.groundColor).multiplyScalar(E),b.hemi[l]=O,l++)}b.ambient[0]=k;b.ambient[1]=m;b.ambient[2]=q;b.directional.length=n;b.spot.length=u;b.rectArea.length=r;b.point.length=t;b.hemi.length=l;b.hash.stateID=b.id;b.hash.directionalLength=
17415 n;b.hash.pointLength=t;b.hash.spotLength=u;b.hash.rectAreaLength=r;b.hash.hemiLength=l;b.hash.shadowsLength=g.length},state:b}}function Ye(){var a=new Gg,b=[],c=[];return{init:function(){b.length=0;c.length=0},state:{lightsArray:b,shadowsArray:c,lights:a},setupLights:function(d){a.setup(b,c,d)},pushLight:function(a){b.push(a)},pushShadow:function(a){c.push(a)}}}function Ig(){var a={};return{get:function(b,c){if(void 0===a[b.id]){var d=new Ye;a[b.id]={};a[b.id][c.id]=d}else void 0===a[b.id][c.id]?
17416 (d=new Ye,a[b.id][c.id]=d):d=a[b.id][c.id];return d},dispose:function(){a={}}}}function $a(a){J.call(this);this.type="MeshDepthMaterial";this.depthPacking=3200;this.morphTargets=this.skinning=!1;this.displacementMap=this.alphaMap=this.map=null;this.displacementScale=1;this.displacementBias=0;this.wireframe=!1;this.wireframeLinewidth=1;this.lights=this.fog=!1;this.setValues(a)}function ab(a){J.call(this);this.type="MeshDistanceMaterial";this.referencePosition=new p;this.nearDistance=1;this.farDistance=
17417 1E3;this.morphTargets=this.skinning=!1;this.displacementMap=this.alphaMap=this.map=null;this.displacementScale=1;this.displacementBias=0;this.lights=this.fog=!1;this.setValues(a)}function Ze(a,b,c){function d(b,c,d,e,f,g){var h=b.geometry;var k=n;var m=b.customDepthMaterial;d&&(k=t,m=b.customDistanceMaterial);m?k=m:(m=!1,c.morphTargets&&(h&&h.isBufferGeometry?m=h.morphAttributes&&h.morphAttributes.position&&0<h.morphAttributes.position.length:h&&h.isGeometry&&(m=h.morphTargets&&0<h.morphTargets.length)),
17418 b.isSkinnedMesh&&!1===c.skinning&&console.warn("THREE.WebGLShadowMap: THREE.SkinnedMesh with material.skinning set to false:",b),b=b.isSkinnedMesh&&c.skinning,h=0,m&&(h|=1),b&&(h|=2),k=k[h]);a.localClippingEnabled&&!0===c.clipShadows&&0!==c.clippingPlanes.length&&(h=k.uuid,m=c.uuid,b=u[h],void 0===b&&(b={},u[h]=b),h=b[m],void 0===h&&(h=k.clone(),b[m]=h),k=h);k.visible=c.visible;k.wireframe=c.wireframe;k.side=null!=c.shadowSide?c.shadowSide:r[c.side];k.clipShadows=c.clipShadows;k.clippingPlanes=c.clippingPlanes;
17419 k.clipIntersection=c.clipIntersection;k.wireframeLinewidth=c.wireframeLinewidth;k.linewidth=c.linewidth;d&&k.isMeshDistanceMaterial&&(k.referencePosition.copy(e),k.nearDistance=f,k.farDistance=g);return k}function e(c,g,h,k){if(!1!==c.visible){if(c.layers.test(g.layers)&&(c.isMesh||c.isLine||c.isPoints)&&c.castShadow&&(!c.frustumCulled||f.intersectsObject(c))){c.modelViewMatrix.multiplyMatrices(h.matrixWorldInverse,c.matrixWorld);var m=b.update(c),n=c.material;if(Array.isArray(n))for(var t=m.groups,
17420 u=0,r=t.length;u<r;u++){var l=t[u],P=n[l.materialIndex];P&&P.visible&&(P=d(c,P,k,q,h.near,h.far),a.renderBufferDirect(h,null,m,P,c,l))}else n.visible&&(P=d(c,n,k,q,h.near,h.far),a.renderBufferDirect(h,null,m,P,c,null))}c=c.children;m=0;for(n=c.length;m<n;m++)e(c[m],g,h,k)}}var f=new md,g=new I,h=new z,k=new z(c,c),m=new p,q=new p,n=Array(4),t=Array(4),u={},r={0:1,1:0,2:2},l=[new p(1,0,0),new p(-1,0,0),new p(0,0,1),new p(0,0,-1),new p(0,1,0),new p(0,-1,0)],y=[new p(0,1,0),new p(0,1,0),new p(0,1,0),
17421 new p(0,1,0),new p(0,0,1),new p(0,0,-1)],x=[new V,new V,new V,new V,new V,new V];for(c=0;4!==c;++c){var w=0!==(c&1),B=0!==(c&2),E=new $a({depthPacking:3201,morphTargets:w,skinning:B});n[c]=E;w=new ab({morphTargets:w,skinning:B});t[c]=w}var P=this;this.enabled=!1;this.autoUpdate=!0;this.needsUpdate=!1;this.type=1;this.render=function(b,c,d){if(!1!==P.enabled&&(!1!==P.autoUpdate||!1!==P.needsUpdate)&&0!==b.length){var n=a.state;n.disable(a.context.BLEND);n.buffers.color.setClear(1,1,1,1);n.buffers.depth.setTest(!0);
17422 n.setScissorTest(!1);for(var t,u=0,r=b.length;u<r;u++){var v=b[u];t=v.shadow;var p=v&&v.isPointLight;if(void 0===t)console.warn("THREE.WebGLShadowMap:",v,"has no shadow.");else{var w=t.camera;h.copy(t.mapSize);h.min(k);if(p){var N=h.x,E=h.y;x[0].set(2*N,E,N,E);x[1].set(0,E,N,E);x[2].set(3*N,E,N,E);x[3].set(N,E,N,E);x[4].set(3*N,0,N,E);x[5].set(N,0,N,E);h.x*=4;h.y*=2}null===t.map&&(t.map=new fb(h.x,h.y,{minFilter:1003,magFilter:1003,format:1023}),t.map.texture.name=v.name+".shadowMap",w.updateProjectionMatrix());
17423 t.isSpotLightShadow&&t.update(v);N=t.map;E=t.matrix;q.setFromMatrixPosition(v.matrixWorld);w.position.copy(q);p?(t=6,E.makeTranslation(-q.x,-q.y,-q.z)):(t=1,m.setFromMatrixPosition(v.target.matrixWorld),w.lookAt(m),w.updateMatrixWorld(),E.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),E.multiply(w.projectionMatrix),E.multiply(w.matrixWorldInverse));a.setRenderTarget(N);a.clear();for(v=0;v<t;v++)p&&(m.copy(w.position),m.add(l[v]),w.up.copy(y[v]),w.lookAt(m),w.updateMatrixWorld(),n.viewport(x[v])),g.multiplyMatrices(w.projectionMatrix,
17424 w.matrixWorldInverse),f.setFromMatrix(g),e(c,d,w,p)}}P.needsUpdate=!1}}}function Jg(a,b,c,d){function e(b,c,d){var e=new Uint8Array(4),f=a.createTexture();a.bindTexture(b,f);a.texParameteri(b,a.TEXTURE_MIN_FILTER,a.NEAREST);a.texParameteri(b,a.TEXTURE_MAG_FILTER,a.NEAREST);for(b=0;b<d;b++)a.texImage2D(c+b,0,a.RGBA,1,1,0,a.RGBA,a.UNSIGNED_BYTE,e);return f}function f(c,e){x[c]=1;0===w[c]&&(a.enableVertexAttribArray(c),w[c]=1);B[c]!==e&&((d.isWebGL2?a:b.get("ANGLE_instanced_arrays"))[d.isWebGL2?"vertexAttribDivisor":
17425 "vertexAttribDivisorANGLE"](c,e),B[c]=e)}function g(b){!0!==E[b]&&(a.enable(b),E[b]=!0)}function h(b){!1!==E[b]&&(a.disable(b),E[b]=!1)}function k(b,d,e,f,k,m,n,q){0!==b?g(a.BLEND):h(a.BLEND);if(5!==b){if(b!==O||q!==C)switch(b){case 2:q?(a.blendEquationSeparate(a.FUNC_ADD,a.FUNC_ADD),a.blendFuncSeparate(a.ONE,a.ONE,a.ONE,a.ONE)):(a.blendEquation(a.FUNC_ADD),a.blendFunc(a.SRC_ALPHA,a.ONE));break;case 3:q?(a.blendEquationSeparate(a.FUNC_ADD,a.FUNC_ADD),a.blendFuncSeparate(a.ZERO,a.ZERO,a.ONE_MINUS_SRC_COLOR,
17426 a.ONE_MINUS_SRC_ALPHA)):(a.blendEquation(a.FUNC_ADD),a.blendFunc(a.ZERO,a.ONE_MINUS_SRC_COLOR));break;case 4:q?(a.blendEquationSeparate(a.FUNC_ADD,a.FUNC_ADD),a.blendFuncSeparate(a.ZERO,a.SRC_COLOR,a.ZERO,a.SRC_ALPHA)):(a.blendEquation(a.FUNC_ADD),a.blendFunc(a.ZERO,a.SRC_COLOR));break;default:q?(a.blendEquationSeparate(a.FUNC_ADD,a.FUNC_ADD),a.blendFuncSeparate(a.ONE,a.ONE_MINUS_SRC_ALPHA,a.ONE,a.ONE_MINUS_SRC_ALPHA)):(a.blendEquationSeparate(a.FUNC_ADD,a.FUNC_ADD),a.blendFuncSeparate(a.SRC_ALPHA,
17427 a.ONE_MINUS_SRC_ALPHA,a.ONE,a.ONE_MINUS_SRC_ALPHA))}D=A=Ud=Td=Sd=z=null}else{k=k||d;m=m||e;n=n||f;if(d!==z||k!==Ud)a.blendEquationSeparate(c.convert(d),c.convert(k)),z=d,Ud=k;if(e!==Sd||f!==Td||m!==A||n!==D)a.blendFuncSeparate(c.convert(e),c.convert(f),c.convert(m),c.convert(n)),Sd=e,Td=f,A=m,D=n}O=b;C=q}function m(b){G!==b&&(b?a.frontFace(a.CW):a.frontFace(a.CCW),G=b)}function q(b){0!==b?(g(a.CULL_FACE),b!==K&&(1===b?a.cullFace(a.BACK):2===b?a.cullFace(a.FRONT):a.cullFace(a.FRONT_AND_BACK))):h(a.CULL_FACE);
17428 K=b}function n(b,c,d){if(b){if(g(a.POLYGON_OFFSET_FILL),R!==c||I!==d)a.polygonOffset(c,d),R=c,I=d}else h(a.POLYGON_OFFSET_FILL)}function t(b){void 0===b&&(b=a.TEXTURE0+J-1);Q!==b&&(a.activeTexture(b),Q=b)}var u=new function(){var b=!1,c=new V,d=null,e=new V(0,0,0,0);return{setMask:function(c){d===c||b||(a.colorMask(c,c,c,c),d=c)},setLocked:function(a){b=a},setClear:function(b,d,f,g,h){!0===h&&(b*=g,d*=g,f*=g);c.set(b,d,f,g);!1===e.equals(c)&&(a.clearColor(b,d,f,g),e.copy(c))},reset:function(){b=!1;
17429 d=null;e.set(-1,0,0,0)}}},r=new function(){var b=!1,c=null,d=null,e=null;return{setTest:function(b){b?g(a.DEPTH_TEST):h(a.DEPTH_TEST)},setMask:function(d){c===d||b||(a.depthMask(d),c=d)},setFunc:function(b){if(d!==b){if(b)switch(b){case 0:a.depthFunc(a.NEVER);break;case 1:a.depthFunc(a.ALWAYS);break;case 2:a.depthFunc(a.LESS);break;case 3:a.depthFunc(a.LEQUAL);break;case 4:a.depthFunc(a.EQUAL);break;case 5:a.depthFunc(a.GEQUAL);break;case 6:a.depthFunc(a.GREATER);break;case 7:a.depthFunc(a.NOTEQUAL);
17430 break;default:a.depthFunc(a.LEQUAL)}else a.depthFunc(a.LEQUAL);d=b}},setLocked:function(a){b=a},setClear:function(b){e!==b&&(a.clearDepth(b),e=b)},reset:function(){b=!1;e=d=c=null}}},l=new function(){var b=!1,c=null,d=null,e=null,f=null,k=null,m=null,n=null,q=null;return{setTest:function(b){b?g(a.STENCIL_TEST):h(a.STENCIL_TEST)},setMask:function(d){c===d||b||(a.stencilMask(d),c=d)},setFunc:function(b,c,g){if(d!==b||e!==c||f!==g)a.stencilFunc(b,c,g),d=b,e=c,f=g},setOp:function(b,c,d){if(k!==b||m!==
17431 c||n!==d)a.stencilOp(b,c,d),k=b,m=c,n=d},setLocked:function(a){b=a},setClear:function(b){q!==b&&(a.clearStencil(b),q=b)},reset:function(){b=!1;q=n=m=k=f=e=d=c=null}}},p=a.getParameter(a.MAX_VERTEX_ATTRIBS),x=new Uint8Array(p),w=new Uint8Array(p),B=new Uint8Array(p),E={},P=null,N=null,O=null,z=null,Sd=null,Td=null,Ud=null,A=null,D=null,C=!1,G=null,K=null,L=null,R=null,I=null,J=a.getParameter(a.MAX_COMBINED_TEXTURE_IMAGE_UNITS),H=!1;p=0;p=a.getParameter(a.VERSION);-1!==p.indexOf("WebGL")?(p=parseFloat(/^WebGL ([0-9])/.exec(p)[1]),
17432 H=1<=p):-1!==p.indexOf("OpenGL ES")&&(p=parseFloat(/^OpenGL ES ([0-9])/.exec(p)[1]),H=2<=p);var Q=null,S={},Y=new V,W=new V,M={};M[a.TEXTURE_2D]=e(a.TEXTURE_2D,a.TEXTURE_2D,1);M[a.TEXTURE_CUBE_MAP]=e(a.TEXTURE_CUBE_MAP,a.TEXTURE_CUBE_MAP_POSITIVE_X,6);u.setClear(0,0,0,1);r.setClear(1);l.setClear(0);g(a.DEPTH_TEST);r.setFunc(3);m(!1);q(1);g(a.CULL_FACE);g(a.BLEND);k(1);return{buffers:{color:u,depth:r,stencil:l},initAttributes:function(){for(var a=0,b=x.length;a<b;a++)x[a]=0},enableAttribute:function(a){f(a,
17433 0)},enableAttributeAndDivisor:f,disableUnusedAttributes:function(){for(var b=0,c=w.length;b!==c;++b)w[b]!==x[b]&&(a.disableVertexAttribArray(b),w[b]=0)},enable:g,disable:h,getCompressedTextureFormats:function(){if(null===P&&(P=[],b.get("WEBGL_compressed_texture_pvrtc")||b.get("WEBGL_compressed_texture_s3tc")||b.get("WEBGL_compressed_texture_etc1")||b.get("WEBGL_compressed_texture_astc")))for(var c=a.getParameter(a.COMPRESSED_TEXTURE_FORMATS),d=0;d<c.length;d++)P.push(c[d]);return P},useProgram:function(b){return N!==
17434 b?(a.useProgram(b),N=b,!0):!1},setBlending:k,setMaterial:function(b,c){2===b.side?h(a.CULL_FACE):g(a.CULL_FACE);var d=1===b.side;c&&(d=!d);m(d);1===b.blending&&!1===b.transparent?k(0):k(b.blending,b.blendEquation,b.blendSrc,b.blendDst,b.blendEquationAlpha,b.blendSrcAlpha,b.blendDstAlpha,b.premultipliedAlpha);r.setFunc(b.depthFunc);r.setTest(b.depthTest);r.setMask(b.depthWrite);u.setMask(b.colorWrite);n(b.polygonOffset,b.polygonOffsetFactor,b.polygonOffsetUnits)},setFlipSided:m,setCullFace:q,setLineWidth:function(b){b!==
17435 L&&(H&&a.lineWidth(b),L=b)},setPolygonOffset:n,setScissorTest:function(b){b?g(a.SCISSOR_TEST):h(a.SCISSOR_TEST)},activeTexture:t,bindTexture:function(b,c){null===Q&&t();var d=S[Q];void 0===d&&(d={type:void 0,texture:void 0},S[Q]=d);if(d.type!==b||d.texture!==c)a.bindTexture(b,c||M[b]),d.type=b,d.texture=c},compressedTexImage2D:function(){try{a.compressedTexImage2D.apply(a,arguments)}catch(U){console.error("THREE.WebGLState:",U)}},texImage2D:function(){try{a.texImage2D.apply(a,arguments)}catch(U){console.error("THREE.WebGLState:",
17436 U)}},scissor:function(b){!1===Y.equals(b)&&(a.scissor(b.x,b.y,b.z,b.w),Y.copy(b))},viewport:function(b){!1===W.equals(b)&&(a.viewport(b.x,b.y,b.z,b.w),W.copy(b))},reset:function(){for(var b=0;b<w.length;b++)1===w[b]&&(a.disableVertexAttribArray(b),w[b]=0);E={};Q=P=null;S={};K=G=O=N=null;u.reset();r.reset();l.reset()}}}function Kg(a,b,c,d,e,f,g){function h(a,b){if(a.width>b||a.height>b){if("data"in a){console.warn("THREE.WebGLRenderer: image in DataTexture is too big ("+a.width+"x"+a.height+").");
17437 return}b/=Math.max(a.width,a.height);var c=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");c.width=Math.floor(a.width*b);c.height=Math.floor(a.height*b);c.getContext("2d").drawImage(a,0,0,a.width,a.height,0,0,c.width,c.height);console.warn("THREE.WebGLRenderer: image is too big ("+a.width+"x"+a.height+"). Resized to "+c.width+"x"+c.height);return c}return a}function k(a){return H.isPowerOfTwo(a.width)&&H.isPowerOfTwo(a.height)}function m(a,b){return a.generateMipmaps&&b&&1003!==
17438 a.minFilter&&1006!==a.minFilter}function q(b,c,e,f){a.generateMipmap(b);d.get(c).__maxMipLevel=Math.log(Math.max(e,f))*Math.LOG2E}function n(b,c){if(!e.isWebGL2)return b;if(b===a.RGB){if(c===a.FLOAT)return a.RGB32F;if(c===a.HALF_FLOAT)return a.RGB16F;if(c===a.UNSIGNED_BYTE)return a.RGB8}if(b===a.RGBA){if(c===a.FLOAT)return a.RGBA32F;if(c===a.HALF_FLOAT)return a.RGBA16F;if(c===a.UNSIGNED_BYTE)return a.RGBA8}return b}function t(b){return 1003===b||1004===b||1005===b?a.NEAREST:a.LINEAR}function u(b){b=
17439 b.target;b.removeEventListener("dispose",u);a:{var c=d.get(b);if(b.image&&c.__image__webglTextureCube)a.deleteTexture(c.__image__webglTextureCube);else{if(void 0===c.__webglInit)break a;a.deleteTexture(c.__webglTexture)}d.remove(b)}b.isVideoTexture&&delete B[b.id];g.memory.textures--}function r(b){b=b.target;b.removeEventListener("dispose",r);var c=d.get(b),e=d.get(b.texture);if(b){void 0!==e.__webglTexture&&a.deleteTexture(e.__webglTexture);b.depthTexture&&b.depthTexture.dispose();if(b.isWebGLRenderTargetCube)for(e=
17440 0;6>e;e++)a.deleteFramebuffer(c.__webglFramebuffer[e]),c.__webglDepthbuffer&&a.deleteRenderbuffer(c.__webglDepthbuffer[e]);else a.deleteFramebuffer(c.__webglFramebuffer),c.__webglDepthbuffer&&a.deleteRenderbuffer(c.__webglDepthbuffer);d.remove(b.texture);d.remove(b)}g.memory.textures--}function l(b,t){var r=d.get(b);if(b.isVideoTexture){var l=b.id,v=g.render.frame;B[l]!==v&&(B[l]=v,b.update())}if(0<b.version&&r.__version!==b.version)if(l=b.image,void 0===l)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined");
17441 else if(!1===l.complete)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{void 0===r.__webglInit&&(r.__webglInit=!0,b.addEventListener("dispose",u),r.__webglTexture=a.createTexture(),g.memory.textures++);c.activeTexture(a.TEXTURE0+t);c.bindTexture(a.TEXTURE_2D,r.__webglTexture);a.pixelStorei(a.UNPACK_FLIP_Y_WEBGL,b.flipY);a.pixelStorei(a.UNPACK_PREMULTIPLY_ALPHA_WEBGL,b.premultiplyAlpha);a.pixelStorei(a.UNPACK_ALIGNMENT,b.unpackAlignment);t=h(b.image,e.maxTextureSize);
17442 (e.isWebGL2?0:1001!==b.wrapS||1001!==b.wrapT||1003!==b.minFilter&&1006!==b.minFilter)&&!1===k(t)&&(t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof ImageBitmap)&&(void 0===E&&(E=document.createElementNS("http://www.w3.org/1999/xhtml","canvas")),E.width=H.floorPowerOfTwo(t.width),E.height=H.floorPowerOfTwo(t.height),E.getContext("2d").drawImage(t,0,0,E.width,E.height),console.warn("THREE.WebGLRenderer: image is not power of two ("+t.width+"x"+t.height+"). Resized to "+E.width+
17443 "x"+E.height),t=E);l=k(t);v=f.convert(b.format);var w=f.convert(b.type),y=n(v,w);p(a.TEXTURE_2D,b,l);var P=b.mipmaps;if(b.isDepthTexture){y=a.DEPTH_COMPONENT;if(1015===b.type){if(!e.isWebGL2)throw Error("Float Depth Texture only supported in WebGL2.0");y=a.DEPTH_COMPONENT32F}else e.isWebGL2&&(y=a.DEPTH_COMPONENT16);1026===b.format&&y===a.DEPTH_COMPONENT&&1012!==b.type&&1014!==b.type&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),b.type=
17444 1012,w=f.convert(b.type));1027===b.format&&(y=a.DEPTH_STENCIL,1020!==b.type&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),b.type=1020,w=f.convert(b.type)));c.texImage2D(a.TEXTURE_2D,0,y,t.width,t.height,0,v,w,null)}else if(b.isDataTexture)if(0<P.length&&l){for(var N=0,x=P.length;N<x;N++){var z=P[N];c.texImage2D(a.TEXTURE_2D,N,y,z.width,z.height,0,v,w,z.data)}b.generateMipmaps=!1;r.__maxMipLevel=P.length-1}else c.texImage2D(a.TEXTURE_2D,0,y,t.width,
17445 t.height,0,v,w,t.data),r.__maxMipLevel=0;else if(b.isCompressedTexture){N=0;for(x=P.length;N<x;N++)z=P[N],1023!==b.format&&1022!==b.format?-1<c.getCompressedTextureFormats().indexOf(v)?c.compressedTexImage2D(a.TEXTURE_2D,N,y,z.width,z.height,0,z.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):c.texImage2D(a.TEXTURE_2D,N,y,z.width,z.height,0,v,w,z.data);r.__maxMipLevel=P.length-1}else if(0<P.length&&l){N=0;for(x=P.length;N<x;N++)z=
17446 P[N],c.texImage2D(a.TEXTURE_2D,N,y,v,w,z);b.generateMipmaps=!1;r.__maxMipLevel=P.length-1}else c.texImage2D(a.TEXTURE_2D,0,y,v,w,t),r.__maxMipLevel=0;m(b,l)&&q(a.TEXTURE_2D,b,t.width,t.height);r.__version=b.version;if(b.onUpdate)b.onUpdate(b);return}c.activeTexture(a.TEXTURE0+t);c.bindTexture(a.TEXTURE_2D,r.__webglTexture)}function p(c,g,h){h?(a.texParameteri(c,a.TEXTURE_WRAP_S,f.convert(g.wrapS)),a.texParameteri(c,a.TEXTURE_WRAP_T,f.convert(g.wrapT)),a.texParameteri(c,a.TEXTURE_MAG_FILTER,f.convert(g.magFilter)),
17447 a.texParameteri(c,a.TEXTURE_MIN_FILTER,f.convert(g.minFilter))):(a.texParameteri(c,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(c,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE),1001===g.wrapS&&1001===g.wrapT||console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),a.texParameteri(c,a.TEXTURE_MAG_FILTER,t(g.magFilter)),a.texParameteri(c,a.TEXTURE_MIN_FILTER,t(g.minFilter)),1003!==g.minFilter&&1006!==g.minFilter&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter."));
17448 !(h=b.get("EXT_texture_filter_anisotropic"))||1015===g.type&&null===b.get("OES_texture_float_linear")||1016===g.type&&null===(e.isWebGL2||b.get("OES_texture_half_float_linear"))||!(1<g.anisotropy||d.get(g).__currentAnisotropy)||(a.texParameterf(c,h.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(g.anisotropy,e.getMaxAnisotropy())),d.get(g).__currentAnisotropy=g.anisotropy)}function x(b,e,g,h){var k=f.convert(e.texture.format),m=f.convert(e.texture.type),q=n(k,m);c.texImage2D(h,0,q,e.width,e.height,0,k,m,null);
17449 a.bindFramebuffer(a.FRAMEBUFFER,b);a.framebufferTexture2D(a.FRAMEBUFFER,g,h,d.get(e.texture).__webglTexture,0);a.bindFramebuffer(a.FRAMEBUFFER,null)}function w(b,c){a.bindRenderbuffer(a.RENDERBUFFER,b);c.depthBuffer&&!c.stencilBuffer?(a.renderbufferStorage(a.RENDERBUFFER,a.DEPTH_COMPONENT16,c.width,c.height),a.framebufferRenderbuffer(a.FRAMEBUFFER,a.DEPTH_ATTACHMENT,a.RENDERBUFFER,b)):c.depthBuffer&&c.stencilBuffer?(a.renderbufferStorage(a.RENDERBUFFER,a.DEPTH_STENCIL,c.width,c.height),a.framebufferRenderbuffer(a.FRAMEBUFFER,
17450 a.DEPTH_STENCIL_ATTACHMENT,a.RENDERBUFFER,b)):a.renderbufferStorage(a.RENDERBUFFER,a.RGBA4,c.width,c.height);a.bindRenderbuffer(a.RENDERBUFFER,null)}var B={},E;this.setTexture2D=l;this.setTextureCube=function(b,t){var r=d.get(b);if(6===b.image.length)if(0<b.version&&r.__version!==b.version){r.__image__webglTextureCube||(b.addEventListener("dispose",u),r.__image__webglTextureCube=a.createTexture(),g.memory.textures++);c.activeTexture(a.TEXTURE0+t);c.bindTexture(a.TEXTURE_CUBE_MAP,r.__image__webglTextureCube);
17451 a.pixelStorei(a.UNPACK_FLIP_Y_WEBGL,b.flipY);t=b&&b.isCompressedTexture;for(var l=b.image[0]&&b.image[0].isDataTexture,v=[],w=0;6>w;w++)v[w]=t||l?l?b.image[w].image:b.image[w]:h(b.image[w],e.maxCubemapSize);var y=v[0],E=k(y),P=f.convert(b.format),x=f.convert(b.type),N=n(P,x);p(a.TEXTURE_CUBE_MAP,b,E);for(w=0;6>w;w++)if(t)for(var B,z=v[w].mipmaps,A=0,D=z.length;A<D;A++)B=z[A],1023!==b.format&&1022!==b.format?-1<c.getCompressedTextureFormats().indexOf(P)?c.compressedTexImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+
17452 w,A,N,B.width,B.height,0,B.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):c.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+w,A,N,B.width,B.height,0,P,x,B.data);else l?c.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+w,0,N,v[w].width,v[w].height,0,P,x,v[w].data):c.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+w,0,N,P,x,v[w]);r.__maxMipLevel=t?z.length-1:0;m(b,E)&&q(a.TEXTURE_CUBE_MAP,b,y.width,y.height);r.__version=b.version;if(b.onUpdate)b.onUpdate(b)}else c.activeTexture(a.TEXTURE0+
17453 t),c.bindTexture(a.TEXTURE_CUBE_MAP,r.__image__webglTextureCube)};this.setTextureCubeDynamic=function(b,e){c.activeTexture(a.TEXTURE0+e);c.bindTexture(a.TEXTURE_CUBE_MAP,d.get(b).__webglTexture)};this.setupRenderTarget=function(b){var e=d.get(b),f=d.get(b.texture);b.addEventListener("dispose",r);f.__webglTexture=a.createTexture();g.memory.textures++;var h=!0===b.isWebGLRenderTargetCube,n=k(b);if(h){e.__webglFramebuffer=[];for(var t=0;6>t;t++)e.__webglFramebuffer[t]=a.createFramebuffer()}else e.__webglFramebuffer=
17454 a.createFramebuffer();if(h){c.bindTexture(a.TEXTURE_CUBE_MAP,f.__webglTexture);p(a.TEXTURE_CUBE_MAP,b.texture,n);for(t=0;6>t;t++)x(e.__webglFramebuffer[t],b,a.COLOR_ATTACHMENT0,a.TEXTURE_CUBE_MAP_POSITIVE_X+t);m(b.texture,n)&&q(a.TEXTURE_CUBE_MAP,b.texture,b.width,b.height);c.bindTexture(a.TEXTURE_CUBE_MAP,null)}else c.bindTexture(a.TEXTURE_2D,f.__webglTexture),p(a.TEXTURE_2D,b.texture,n),x(e.__webglFramebuffer,b,a.COLOR_ATTACHMENT0,a.TEXTURE_2D),m(b.texture,n)&&q(a.TEXTURE_2D,b.texture,b.width,b.height),
17455 c.bindTexture(a.TEXTURE_2D,null);if(b.depthBuffer){e=d.get(b);f=!0===b.isWebGLRenderTargetCube;if(b.depthTexture){if(f)throw Error("target.depthTexture not supported in Cube render targets");if(b&&b.isWebGLRenderTargetCube)throw Error("Depth Texture with cube render targets is not supported");a.bindFramebuffer(a.FRAMEBUFFER,e.__webglFramebuffer);if(!b.depthTexture||!b.depthTexture.isDepthTexture)throw Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");d.get(b.depthTexture).__webglTexture&&
17456 b.depthTexture.image.width===b.width&&b.depthTexture.image.height===b.height||(b.depthTexture.image.width=b.width,b.depthTexture.image.height=b.height,b.depthTexture.needsUpdate=!0);l(b.depthTexture,0);e=d.get(b.depthTexture).__webglTexture;if(1026===b.depthTexture.format)a.framebufferTexture2D(a.FRAMEBUFFER,a.DEPTH_ATTACHMENT,a.TEXTURE_2D,e,0);else if(1027===b.depthTexture.format)a.framebufferTexture2D(a.FRAMEBUFFER,a.DEPTH_STENCIL_ATTACHMENT,a.TEXTURE_2D,e,0);else throw Error("Unknown depthTexture format");
17457 }else if(f)for(e.__webglDepthbuffer=[],f=0;6>f;f++)a.bindFramebuffer(a.FRAMEBUFFER,e.__webglFramebuffer[f]),e.__webglDepthbuffer[f]=a.createRenderbuffer(),w(e.__webglDepthbuffer[f],b);else a.bindFramebuffer(a.FRAMEBUFFER,e.__webglFramebuffer),e.__webglDepthbuffer=a.createRenderbuffer(),w(e.__webglDepthbuffer,b);a.bindFramebuffer(a.FRAMEBUFFER,null)}};this.updateRenderTargetMipmap=function(b){var e=b.texture,f=k(b);if(m(e,f)){f=b.isWebGLRenderTargetCube?a.TEXTURE_CUBE_MAP:a.TEXTURE_2D;var g=d.get(e).__webglTexture;
17458 c.bindTexture(f,g);q(f,e,b.width,b.height);c.bindTexture(f,null)}}}function $e(a,b,c){return{convert:function(d){if(1E3===d)return a.REPEAT;if(1001===d)return a.CLAMP_TO_EDGE;if(1002===d)return a.MIRRORED_REPEAT;if(1003===d)return a.NEAREST;if(1004===d)return a.NEAREST_MIPMAP_NEAREST;if(1005===d)return a.NEAREST_MIPMAP_LINEAR;if(1006===d)return a.LINEAR;if(1007===d)return a.LINEAR_MIPMAP_NEAREST;if(1008===d)return a.LINEAR_MIPMAP_LINEAR;if(1009===d)return a.UNSIGNED_BYTE;if(1017===d)return a.UNSIGNED_SHORT_4_4_4_4;
17459 if(1018===d)return a.UNSIGNED_SHORT_5_5_5_1;if(1019===d)return a.UNSIGNED_SHORT_5_6_5;if(1010===d)return a.BYTE;if(1011===d)return a.SHORT;if(1012===d)return a.UNSIGNED_SHORT;if(1013===d)return a.INT;if(1014===d)return a.UNSIGNED_INT;if(1015===d)return a.FLOAT;if(1016===d){if(c.isWebGL2)return a.HALF_FLOAT;var e=b.get("OES_texture_half_float");if(null!==e)return e.HALF_FLOAT_OES}if(1021===d)return a.ALPHA;if(1022===d)return a.RGB;if(1023===d)return a.RGBA;if(1024===d)return a.LUMINANCE;if(1025===
17460 d)return a.LUMINANCE_ALPHA;if(1026===d)return a.DEPTH_COMPONENT;if(1027===d)return a.DEPTH_STENCIL;if(100===d)return a.FUNC_ADD;if(101===d)return a.FUNC_SUBTRACT;if(102===d)return a.FUNC_REVERSE_SUBTRACT;if(200===d)return a.ZERO;if(201===d)return a.ONE;if(202===d)return a.SRC_COLOR;if(203===d)return a.ONE_MINUS_SRC_COLOR;if(204===d)return a.SRC_ALPHA;if(205===d)return a.ONE_MINUS_SRC_ALPHA;if(206===d)return a.DST_ALPHA;if(207===d)return a.ONE_MINUS_DST_ALPHA;if(208===d)return a.DST_COLOR;if(209===
17461 d)return a.ONE_MINUS_DST_COLOR;if(210===d)return a.SRC_ALPHA_SATURATE;if(33776===d||33777===d||33778===d||33779===d)if(e=b.get("WEBGL_compressed_texture_s3tc"),null!==e){if(33776===d)return e.COMPRESSED_RGB_S3TC_DXT1_EXT;if(33777===d)return e.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(33778===d)return e.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(33779===d)return e.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(35840===d||35841===d||35842===d||35843===d)if(e=b.get("WEBGL_compressed_texture_pvrtc"),null!==e){if(35840===d)return e.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;
17462 if(35841===d)return e.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(35842===d)return e.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(35843===d)return e.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(36196===d&&(e=b.get("WEBGL_compressed_texture_etc1"),null!==e))return e.COMPRESSED_RGB_ETC1_WEBGL;if(37808===d||37809===d||37810===d||37811===d||37812===d||37813===d||37814===d||37815===d||37816===d||37817===d||37818===d||37819===d||37820===d||37821===d)if(e=b.get("WEBGL_compressed_texture_astc"),null!==e)return d;if(103===d||104===
17463 d){if(c.isWebGL2){if(103===d)return a.MIN;if(104===d)return a.MAX}e=b.get("EXT_blend_minmax");if(null!==e){if(103===d)return e.MIN_EXT;if(104===d)return e.MAX_EXT}}if(1020===d){if(c.isWebGL2)return a.UNSIGNED_INT_24_8;e=b.get("WEBGL_depth_texture");if(null!==e)return e.UNSIGNED_INT_24_8_WEBGL}return 0}}}function Kb(){D.call(this);this.type="Group"}function Z(a,b,c,d){Na.call(this);this.type="PerspectiveCamera";this.fov=void 0!==a?a:50;this.zoom=1;this.near=void 0!==c?c:.1;this.far=void 0!==d?d:2E3;
17464 this.focus=10;this.aspect=void 0!==b?b:1;this.view=null;this.filmGauge=35;this.filmOffset=0;this.updateProjectionMatrix()}function yc(a){Z.call(this);this.cameras=a||[]}function af(a){function b(){return null!==e&&!0===e.isPresenting}function c(){if(b()){var c=e.getEyeParameters("left"),f=c.renderWidth;c=c.renderHeight;x=a.getPixelRatio();y=a.getSize();a.setDrawingBufferSize(2*f,c,1);B.start()}else d.enabled&&(a.setDrawingBufferSize(y.width,y.height,x),B.stop())}var d=this,e=null,f=null,g=null,h=
17465 [],k=new I,m=new I;"undefined"!==typeof window&&"VRFrameData"in window&&(f=new window.VRFrameData,window.addEventListener("vrdisplaypresentchange",c,!1));var q=new I,n=new fa,t=new p,u=new Z;u.bounds=new V(0,0,.5,1);u.layers.enable(1);var r=new Z;r.bounds=new V(.5,0,.5,1);r.layers.enable(2);var l=new yc([u,r]);l.layers.enable(1);l.layers.enable(2);var y,x,w=[];this.enabled=!1;this.userHeight=1.6;this.getController=function(a){var b=h[a];void 0===b&&(b=new Kb,b.matrixAutoUpdate=!1,b.visible=!1,h[a]=
17466 b);return b};this.getDevice=function(){return e};this.setDevice=function(a){void 0!==a&&(e=a);B.setContext(a)};this.setPoseTarget=function(a){void 0!==a&&(g=a)};this.getCamera=function(a){if(null===e)return a.position.set(0,d.userHeight,0),a;e.depthNear=a.near;e.depthFar=a.far;e.getFrameData(f);var b=e.stageParameters;b?k.fromArray(b.sittingToStandingTransform):k.makeTranslation(0,d.userHeight,0);b=f.pose;var c=null!==g?g:a;c.matrix.copy(k);c.matrix.decompose(c.position,c.quaternion,c.scale);null!==
17467 b.orientation&&(n.fromArray(b.orientation),c.quaternion.multiply(n));null!==b.position&&(n.setFromRotationMatrix(k),t.fromArray(b.position),t.applyQuaternion(n),c.position.add(t));c.updateMatrixWorld();if(!1===e.isPresenting)return a;u.near=a.near;r.near=a.near;u.far=a.far;r.far=a.far;l.matrixWorld.copy(a.matrixWorld);l.matrixWorldInverse.copy(a.matrixWorldInverse);u.matrixWorldInverse.fromArray(f.leftViewMatrix);r.matrixWorldInverse.fromArray(f.rightViewMatrix);m.getInverse(k);u.matrixWorldInverse.multiply(m);
17468 r.matrixWorldInverse.multiply(m);a=c.parent;null!==a&&(q.getInverse(a.matrixWorld),u.matrixWorldInverse.multiply(q),r.matrixWorldInverse.multiply(q));u.matrixWorld.getInverse(u.matrixWorldInverse);r.matrixWorld.getInverse(r.matrixWorldInverse);u.projectionMatrix.fromArray(f.leftProjectionMatrix);r.projectionMatrix.fromArray(f.rightProjectionMatrix);l.projectionMatrix.copy(u.projectionMatrix);a=e.getLayers();a.length&&(a=a[0],null!==a.leftBounds&&4===a.leftBounds.length&&u.bounds.fromArray(a.leftBounds),
17469 null!==a.rightBounds&&4===a.rightBounds.length&&r.bounds.fromArray(a.rightBounds));a:for(a=0;a<h.length;a++){b=h[a];b:{c=a;for(var v=navigator.getGamepads&&navigator.getGamepads(),p=0,y=0,x=v.length;p<x;p++){var E=v[p];if(E&&("Daydream Controller"===E.id||"Gear VR Controller"===E.id||"Oculus Go Controller"===E.id||"OpenVR Gamepad"===E.id||E.id.startsWith("Oculus Touch")||E.id.startsWith("Spatial Controller"))){if(y===c){c=E;break b}y++}}c=void 0}if(void 0!==c&&void 0!==c.pose){if(null===c.pose)break a;
17470 v=c.pose;!1===v.hasPosition&&b.position.set(.2,-.6,-.05);null!==v.position&&b.position.fromArray(v.position);null!==v.orientation&&b.quaternion.fromArray(v.orientation);b.matrix.compose(b.position,b.quaternion,b.scale);b.matrix.premultiply(k);b.matrix.decompose(b.position,b.quaternion,b.scale);b.matrixWorldNeedsUpdate=!0;b.visible=!0;v="Daydream Controller"===c.id?0:1;w[a]!==c.buttons[v].pressed&&(w[a]=c.buttons[v].pressed,!0===w[a]?b.dispatchEvent({type:"selectstart"}):(b.dispatchEvent({type:"selectend"}),
17471 b.dispatchEvent({type:"select"})))}else b.visible=!1}return l};this.getStandingMatrix=function(){return k};this.isPresenting=b;var B=new Qd;this.setAnimationLoop=function(a){B.setAnimationLoop(a)};this.submitFrame=function(){b()&&e.submitFrame()};this.dispose=function(){"undefined"!==typeof window&&window.removeEventListener("vrdisplaypresentchange",c)}}function Lg(a){function b(){return null!==h&&null!==k}function c(a){var b=q[n.indexOf(a.inputSource)];b&&b.dispatchEvent({type:a.type})}function d(){a.setFramebuffer(null);
17472 p.stop()}function e(a,b){null===b?a.matrixWorld.copy(a.matrix):a.matrixWorld.multiplyMatrices(b.matrixWorld,a.matrix);a.matrixWorldInverse.getInverse(a.matrixWorld)}var f=a.context,g=null,h=null,k=null,m=null,q=[],n=[],t=new Z;t.layers.enable(1);t.viewport=new V;var u=new Z;u.layers.enable(2);u.viewport=new V;var r=new yc([t,u]);r.layers.enable(1);r.layers.enable(2);this.enabled=!1;this.getController=function(a){var b=q[a];void 0===b&&(b=new Kb,b.matrixAutoUpdate=!1,b.visible=!1,q[a]=b);return b};
17473 this.getDevice=function(){return g};this.setDevice=function(a){void 0!==a&&(g=a);a instanceof XRDevice&&f.setCompatibleXRDevice(a)};this.setSession=function(b,e){h=b;null!==h&&(h.addEventListener("select",c),h.addEventListener("selectstart",c),h.addEventListener("selectend",c),h.addEventListener("end",d),h.baseLayer=new XRWebGLLayer(h,f),h.requestFrameOfReference(e.frameOfReferenceType).then(function(b){k=b;a.setFramebuffer(h.baseLayer.framebuffer);p.setContext(h);p.start()}),n=h.getInputSources(),
17474 h.addEventListener("inputsourceschange",function(){n=h.getInputSources();console.log(n)}))};this.getCamera=function(a){if(b()){var c=a.parent,d=r.cameras;e(r,c);for(var f=0;f<d.length;f++)e(d[f],c);a.matrixWorld.copy(r.matrixWorld);a=a.children;f=0;for(c=a.length;f<c;f++)a[f].updateMatrixWorld(!0);return r}return a};this.isPresenting=b;var l=null,p=new Qd;p.setAnimationLoop(function(a,b){m=b.getDevicePose(k);if(null!==m)for(var c=h.baseLayer,d=b.views,e=0;e<d.length;e++){var f=d[e],g=c.getViewport(f),
17475 t=m.getViewMatrix(f),u=r.cameras[e];u.matrix.fromArray(t).getInverse(u.matrix);u.projectionMatrix.fromArray(f.projectionMatrix);u.viewport.set(g.x,g.y,g.width,g.height);0===e&&(r.matrix.copy(u.matrix),r.projectionMatrix.copy(u.projectionMatrix))}for(e=0;e<q.length;e++){c=q[e];if(d=n[e])if(d=b.getInputPose(d,k),null!==d){c.matrix.elements=d.pointerMatrix;c.matrix.decompose(c.position,c.rotation,c.scale);c.visible=!0;continue}c.visible=!1}l&&l(a)});this.setAnimationLoop=function(a){l=a};this.dispose=
17476 function(){};this.getStandingMatrix=function(){console.warn("THREE.WebXRManager: getStandingMatrix() is no longer needed.");return new THREE.Matrix4};this.submitFrame=function(){}}function Zd(a){var b;function c(){ha=new Pf(F);ua=new Nf(F,ha,a);ua.isWebGL2||(ha.get("WEBGL_depth_texture"),ha.get("OES_texture_float"),ha.get("OES_texture_half_float"),ha.get("OES_texture_half_float_linear"),ha.get("OES_standard_derivatives"),ha.get("OES_element_index_uint"),ha.get("ANGLE_instanced_arrays"));ha.get("OES_texture_float_linear");
17477 da=new $e(F,ha,ua);ba=new Jg(F,ha,da,ua);ba.scissor(wc.copy(fa).multiplyScalar(U));ba.viewport(T.copy(od).multiplyScalar(U));ca=new Sf(F);Ba=new Ag;ia=new Kg(F,ha,ba,Ba,ua,da,ca);pa=new Ff(F);ra=new Qf(F,pa,ca);ma=new Vf(ra,ca);va=new Uf(F);la=new zg(C,ha,ua);sa=new Eg;na=new Ig;ka=new Lf(C,ba,ma,N);xa=new Mf(F,ha,ca,ua);ya=new Rf(F,ha,ca,ua);ca.programs=la.programs;C.context=F;C.capabilities=ua;C.extensions=ha;C.properties=Ba;C.renderLists=sa;C.state=ba;C.info=ca}function d(a){a.preventDefault();
17478 console.log("THREE.WebGLRenderer: Context Lost.");G=!0}function e(){console.log("THREE.WebGLRenderer: Context Restored.");G=!1;c()}function f(a){a=a.target;a.removeEventListener("dispose",f);g(a);Ba.remove(a)}function g(a){var b=Ba.get(a).program;a.program=void 0;void 0!==b&&la.releaseProgram(b)}function h(a,b){a.render(function(a){C.renderBufferImmediate(a,b)})}function k(a,b,c){if(!1!==a.visible){if(a.layers.test(b.layers))if(a.isLight)D.pushLight(a),a.castShadow&&D.pushShadow(a);else if(a.isSprite){if(!a.frustumCulled||
17479 oa.intersectsSprite(a)){c&&bb.setFromMatrixPosition(a.matrixWorld).applyMatrix4(xc);var d=ma.update(a),e=a.material;A.push(a,d,e,bb.z,null)}}else if(a.isImmediateRenderObject)c&&bb.setFromMatrixPosition(a.matrixWorld).applyMatrix4(xc),A.push(a,null,a.material,bb.z,null);else if(a.isMesh||a.isLine||a.isPoints)if(a.isSkinnedMesh&&a.skeleton.update(),!a.frustumCulled||oa.intersectsObject(a))if(c&&bb.setFromMatrixPosition(a.matrixWorld).applyMatrix4(xc),d=ma.update(a),e=a.material,Array.isArray(e))for(var f=
17480 d.groups,g=0,h=f.length;g<h;g++){var m=f[g],n=e[m.materialIndex];n&&n.visible&&A.push(a,d,n,bb.z,m)}else e.visible&&A.push(a,d,e,bb.z,null);a=a.children;g=0;for(h=a.length;g<h;g++)k(a[g],b,c)}}function m(a,b,c,d){for(var e=0,f=a.length;e<f;e++){var g=a[e],h=g.object,k=g.geometry,m=void 0===d?g.material:d;g=g.group;if(c.isArrayCamera){W=c;for(var n=c.cameras,t=0,u=n.length;t<u;t++){var l=n[t];if(h.layers.test(l.layers)){if("viewport"in l)ba.viewport(T.copy(l.viewport));else{var r=l.bounds;ba.viewport(T.set(r.x*
17481 Z,r.y*M,r.z*Z,r.w*M).multiplyScalar(U))}q(h,b,l,k,m,g)}}}else W=null,q(h,b,c,k,m,g)}}function q(a,c,d,e,f,g){a.onBeforeRender(C,c,d,e,f,g);D=na.get(c,W||d);a.modelViewMatrix.multiplyMatrices(d.matrixWorldInverse,a.matrixWorld);a.normalMatrix.getNormalMatrix(a.modelViewMatrix);if(a.isImmediateRenderObject){ba.setMaterial(f);var k=t(d,c.fog,f,a);S=b=null;nd=!1;h(a,k)}else C.renderBufferDirect(d,c.fog,e,f,a,g);a.onAfterRender(C,c,d,e,f,g);D=na.get(c,W||d)}function n(a,b,c){var d=Ba.get(a),e=D.state.lights,
17482 h=d.lightsHash,k=e.state.hash;c=la.getParameters(a,e.state,D.state.shadowsArray,b,aa.numPlanes,aa.numIntersection,c);var m=la.getProgramCode(a,c),n=d.program,q=!0;if(void 0===n)a.addEventListener("dispose",f);else if(n.code!==m)g(a);else{if(h.stateID!==k.stateID||h.directionalLength!==k.directionalLength||h.pointLength!==k.pointLength||h.spotLength!==k.spotLength||h.rectAreaLength!==k.rectAreaLength||h.hemiLength!==k.hemiLength||h.shadowsLength!==k.shadowsLength)h.stateID=k.stateID,h.directionalLength=
17483 k.directionalLength,h.pointLength=k.pointLength,h.spotLength=k.spotLength,h.rectAreaLength=k.rectAreaLength,h.hemiLength=k.hemiLength,h.shadowsLength=k.shadowsLength;else if(void 0!==c.shaderID)return;q=!1}q&&(c.shaderID?(m=nb[c.shaderID],d.shader={name:a.type,uniforms:Aa.clone(m.uniforms),vertexShader:m.vertexShader,fragmentShader:m.fragmentShader}):d.shader={name:a.type,uniforms:a.uniforms,vertexShader:a.vertexShader,fragmentShader:a.fragmentShader},a.onBeforeCompile(d.shader,C),m=la.getProgramCode(a,
17484 c),n=la.acquireProgram(a,d.shader,c,m),d.program=n,a.program=n);c=n.getAttributes();if(a.morphTargets)for(m=a.numSupportedMorphTargets=0;m<C.maxMorphTargets;m++)0<=c["morphTarget"+m]&&a.numSupportedMorphTargets++;if(a.morphNormals)for(m=a.numSupportedMorphNormals=0;m<C.maxMorphNormals;m++)0<=c["morphNormal"+m]&&a.numSupportedMorphNormals++;c=d.shader.uniforms;if(!a.isShaderMaterial&&!a.isRawShaderMaterial||!0===a.clipping)d.numClippingPlanes=aa.numPlanes,d.numIntersection=aa.numIntersection,c.clippingPlanes=
17485 aa.uniform;d.fog=b;void 0===h&&(d.lightsHash=h={});h.stateID=k.stateID;h.directionalLength=k.directionalLength;h.pointLength=k.pointLength;h.spotLength=k.spotLength;h.rectAreaLength=k.rectAreaLength;h.hemiLength=k.hemiLength;h.shadowsLength=k.shadowsLength;a.lights&&(c.ambientLightColor.value=e.state.ambient,c.directionalLights.value=e.state.directional,c.spotLights.value=e.state.spot,c.rectAreaLights.value=e.state.rectArea,c.pointLights.value=e.state.point,c.hemisphereLights.value=e.state.hemi,c.directionalShadowMap.value=
17486 e.state.directionalShadowMap,c.directionalShadowMatrix.value=e.state.directionalShadowMatrix,c.spotShadowMap.value=e.state.spotShadowMap,c.spotShadowMatrix.value=e.state.spotShadowMatrix,c.pointShadowMap.value=e.state.pointShadowMap,c.pointShadowMatrix.value=e.state.pointShadowMatrix);a=d.program.getUniforms();a=Za.seqWithValue(a.seq,c);d.uniformsList=a}function t(a,b,c,d){X=0;var e=Ba.get(c),f=e.lightsHash,g=D.state.lights.state.hash;pd&&(Yd||a!==Y)&&aa.setState(c.clippingPlanes,c.clipIntersection,
17487 c.clipShadows,a,e,a===Y&&c.id===J);!1===c.needsUpdate&&(void 0===e.program?c.needsUpdate=!0:c.fog&&e.fog!==b?c.needsUpdate=!0:!c.lights||f.stateID===g.stateID&&f.directionalLength===g.directionalLength&&f.pointLength===g.pointLength&&f.spotLength===g.spotLength&&f.rectAreaLength===g.rectAreaLength&&f.hemiLength===g.hemiLength&&f.shadowsLength===g.shadowsLength?void 0===e.numClippingPlanes||e.numClippingPlanes===aa.numPlanes&&e.numIntersection===aa.numIntersection||(c.needsUpdate=!0):c.needsUpdate=
17488 !0);c.needsUpdate&&(n(c,b,d),c.needsUpdate=!1);var h=!1,k=!1,m=!1;f=e.program;g=f.getUniforms();var q=e.shader.uniforms;ba.useProgram(f.program)&&(m=k=h=!0);c.id!==J&&(J=c.id,k=!0);if(h||a!==Y){g.setValue(F,"projectionMatrix",a.projectionMatrix);ua.logarithmicDepthBuffer&&g.setValue(F,"logDepthBufFC",2/(Math.log(a.far+1)/Math.LN2));Y!==(W||a)&&(Y=W||a,m=k=!0);if(c.isShaderMaterial||c.isMeshPhongMaterial||c.isMeshStandardMaterial||c.envMap)h=g.map.cameraPosition,void 0!==h&&h.setValue(F,bb.setFromMatrixPosition(a.matrixWorld));
17489 (c.isMeshPhongMaterial||c.isMeshLambertMaterial||c.isMeshBasicMaterial||c.isMeshStandardMaterial||c.isShaderMaterial||c.skinning)&&g.setValue(F,"viewMatrix",a.matrixWorldInverse)}if(c.skinning&&(g.setOptional(F,d,"bindMatrix"),g.setOptional(F,d,"bindMatrixInverse"),a=d.skeleton))if(h=a.bones,ua.floatVertexTextures){if(void 0===a.boneTexture){h=Math.sqrt(4*h.length);h=H.ceilPowerOfTwo(h);h=Math.max(h,4);var t=new Float32Array(h*h*4);t.set(a.boneMatrices);var v=new gb(t,h,h,1023,1015);v.needsUpdate=
17490 !0;a.boneMatrices=t;a.boneTexture=v;a.boneTextureSize=h}g.setValue(F,"boneTexture",a.boneTexture);g.setValue(F,"boneTextureSize",a.boneTextureSize)}else g.setOptional(F,a,"boneMatrices");k&&(g.setValue(F,"toneMappingExposure",C.toneMappingExposure),g.setValue(F,"toneMappingWhitePoint",C.toneMappingWhitePoint),c.lights&&(k=m,q.ambientLightColor.needsUpdate=k,q.directionalLights.needsUpdate=k,q.pointLights.needsUpdate=k,q.spotLights.needsUpdate=k,q.rectAreaLights.needsUpdate=k,q.hemisphereLights.needsUpdate=
17491 k),b&&c.fog&&(q.fogColor.value=b.color,b.isFog?(q.fogNear.value=b.near,q.fogFar.value=b.far):b.isFogExp2&&(q.fogDensity.value=b.density)),c.isMeshBasicMaterial?u(q,c):c.isMeshLambertMaterial?(u(q,c),c.emissiveMap&&(q.emissiveMap.value=c.emissiveMap)):c.isMeshPhongMaterial?(u(q,c),c.isMeshToonMaterial?(r(q,c),c.gradientMap&&(q.gradientMap.value=c.gradientMap)):r(q,c)):c.isMeshStandardMaterial?(u(q,c),c.isMeshPhysicalMaterial?(l(q,c),q.reflectivity.value=c.reflectivity,q.clearCoat.value=c.clearCoat,
17492 q.clearCoatRoughness.value=c.clearCoatRoughness):l(q,c)):c.isMeshDepthMaterial?(u(q,c),c.displacementMap&&(q.displacementMap.value=c.displacementMap,q.displacementScale.value=c.displacementScale,q.displacementBias.value=c.displacementBias)):c.isMeshDistanceMaterial?(u(q,c),c.displacementMap&&(q.displacementMap.value=c.displacementMap,q.displacementScale.value=c.displacementScale,q.displacementBias.value=c.displacementBias),q.referencePosition.value.copy(c.referencePosition),q.nearDistance.value=c.nearDistance,
17493 q.farDistance.value=c.farDistance):c.isMeshNormalMaterial?(u(q,c),c.bumpMap&&(q.bumpMap.value=c.bumpMap,q.bumpScale.value=c.bumpScale,1===c.side&&(q.bumpScale.value*=-1)),c.normalMap&&(q.normalMap.value=c.normalMap,q.normalScale.value.copy(c.normalScale),1===c.side&&q.normalScale.value.negate()),c.displacementMap&&(q.displacementMap.value=c.displacementMap,q.displacementScale.value=c.displacementScale,q.displacementBias.value=c.displacementBias)):c.isLineBasicMaterial?(q.diffuse.value=c.color,q.opacity.value=
17494 c.opacity,c.isLineDashedMaterial&&(q.dashSize.value=c.dashSize,q.totalSize.value=c.dashSize+c.gapSize,q.scale.value=c.scale)):c.isPointsMaterial?(q.diffuse.value=c.color,q.opacity.value=c.opacity,q.size.value=c.size*U,q.scale.value=.5*M,q.map.value=c.map,null!==c.map&&(!0===c.map.matrixAutoUpdate&&c.map.updateMatrix(),q.uvTransform.value.copy(c.map.matrix))):c.isSpriteMaterial?(q.diffuse.value=c.color,q.opacity.value=c.opacity,q.rotation.value=c.rotation,q.map.value=c.map,null!==c.map&&(!0===c.map.matrixAutoUpdate&&
17495 c.map.updateMatrix(),q.uvTransform.value.copy(c.map.matrix))):c.isShadowMaterial&&(q.color.value=c.color,q.opacity.value=c.opacity),void 0!==q.ltc_1&&(q.ltc_1.value=K.LTC_1),void 0!==q.ltc_2&&(q.ltc_2.value=K.LTC_2),Za.upload(F,e.uniformsList,q,C));c.isShaderMaterial&&!0===c.uniformsNeedUpdate&&(Za.upload(F,e.uniformsList,q,C),c.uniformsNeedUpdate=!1);c.isSpriteMaterial&&g.setValue(F,"center",d.center);g.setValue(F,"modelViewMatrix",d.modelViewMatrix);g.setValue(F,"normalMatrix",d.normalMatrix);g.setValue(F,
17496 "modelMatrix",d.matrixWorld);return f}function u(a,b){a.opacity.value=b.opacity;b.color&&(a.diffuse.value=b.color);b.emissive&&a.emissive.value.copy(b.emissive).multiplyScalar(b.emissiveIntensity);b.map&&(a.map.value=b.map);b.alphaMap&&(a.alphaMap.value=b.alphaMap);b.specularMap&&(a.specularMap.value=b.specularMap);b.envMap&&(a.envMap.value=b.envMap,a.flipEnvMap.value=b.envMap&&b.envMap.isCubeTexture?-1:1,a.reflectivity.value=b.reflectivity,a.refractionRatio.value=b.refractionRatio,a.maxMipLevel.value=
17497 Ba.get(b.envMap).__maxMipLevel);b.lightMap&&(a.lightMap.value=b.lightMap,a.lightMapIntensity.value=b.lightMapIntensity);b.aoMap&&(a.aoMap.value=b.aoMap,a.aoMapIntensity.value=b.aoMapIntensity);if(b.map)var c=b.map;else b.specularMap?c=b.specularMap:b.displacementMap?c=b.displacementMap:b.normalMap?c=b.normalMap:b.bumpMap?c=b.bumpMap:b.roughnessMap?c=b.roughnessMap:b.metalnessMap?c=b.metalnessMap:b.alphaMap?c=b.alphaMap:b.emissiveMap&&(c=b.emissiveMap);void 0!==c&&(c.isWebGLRenderTarget&&(c=c.texture),
17498 !0===c.matrixAutoUpdate&&c.updateMatrix(),a.uvTransform.value.copy(c.matrix))}function r(a,b){a.specular.value=b.specular;a.shininess.value=Math.max(b.shininess,1E-4);b.emissiveMap&&(a.emissiveMap.value=b.emissiveMap);b.bumpMap&&(a.bumpMap.value=b.bumpMap,a.bumpScale.value=b.bumpScale,1===b.side&&(a.bumpScale.value*=-1));b.normalMap&&(a.normalMap.value=b.normalMap,a.normalScale.value.copy(b.normalScale),1===b.side&&a.normalScale.value.negate());b.displacementMap&&(a.displacementMap.value=b.displacementMap,
17499 a.displacementScale.value=b.displacementScale,a.displacementBias.value=b.displacementBias)}function l(a,b){a.roughness.value=b.roughness;a.metalness.value=b.metalness;b.roughnessMap&&(a.roughnessMap.value=b.roughnessMap);b.metalnessMap&&(a.metalnessMap.value=b.metalnessMap);b.emissiveMap&&(a.emissiveMap.value=b.emissiveMap);b.bumpMap&&(a.bumpMap.value=b.bumpMap,a.bumpScale.value=b.bumpScale,1===b.side&&(a.bumpScale.value*=-1));b.normalMap&&(a.normalMap.value=b.normalMap,a.normalScale.value.copy(b.normalScale),
17500 1===b.side&&a.normalScale.value.negate());b.displacementMap&&(a.displacementMap.value=b.displacementMap,a.displacementScale.value=b.displacementScale,a.displacementBias.value=b.displacementBias);b.envMap&&(a.envMapIntensity.value=b.envMapIntensity)}console.log("THREE.WebGLRenderer","95");a=a||{};var y=void 0!==a.canvas?a.canvas:document.createElementNS("http://www.w3.org/1999/xhtml","canvas"),x=void 0!==a.context?a.context:null,w=void 0!==a.alpha?a.alpha:!1,B=void 0!==a.depth?a.depth:!0,E=void 0!==
17501 a.stencil?a.stencil:!0,P=void 0!==a.antialias?a.antialias:!1,N=void 0!==a.premultipliedAlpha?a.premultipliedAlpha:!0,O=void 0!==a.preserveDrawingBuffer?a.preserveDrawingBuffer:!1,z=void 0!==a.powerPreference?a.powerPreference:"default",A=null,D=null;this.domElement=y;this.context=null;this.sortObjects=this.autoClearStencil=this.autoClearDepth=this.autoClearColor=this.autoClear=!0;this.clippingPlanes=[];this.localClippingEnabled=!1;this.gammaFactor=2;this.physicallyCorrectLights=this.gammaOutput=this.gammaInput=
17502 !1;this.toneMappingWhitePoint=this.toneMappingExposure=this.toneMapping=1;this.maxMorphTargets=8;this.maxMorphNormals=4;var C=this,G=!1,L=null,R=null,Q=null,J=-1;var S=b=null;var nd=!1;var Y=null,W=null,T=new V,wc=new V,ea=null,X=0,Z=y.width,M=y.height,U=1,od=new V(0,0,Z,M),fa=new V(0,0,Z,M),qa=!1,oa=new md,aa=new Of,pd=!1,Yd=!1,xc=new I,bb=new p;try{w={alpha:w,depth:B,stencil:E,antialias:P,premultipliedAlpha:N,preserveDrawingBuffer:O,powerPreference:z};y.addEventListener("webglcontextlost",d,!1);
17503 y.addEventListener("webglcontextrestored",e,!1);var F=x||y.getContext("webgl",w)||y.getContext("experimental-webgl",w);if(null===F){if(null!==y.getContext("webgl"))throw Error("Error creating WebGL context with your selected attributes.");throw Error("Error creating WebGL context.");}void 0===F.getShaderPrecisionFormat&&(F.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(Mg){console.error("THREE.WebGLRenderer: "+Mg.message)}var ha,ua,ba,ca,Ba,ia,pa,ra,ma,la,sa,
17504 na,ka,va,xa,ya,da;c();var ja="xr"in navigator?new Lg(C):new af(C);this.vr=ja;var za=new Ze(C,ma,ua.maxTextureSize);this.shadowMap=za;this.getContext=function(){return F};this.getContextAttributes=function(){return F.getContextAttributes()};this.forceContextLoss=function(){var a=ha.get("WEBGL_lose_context");a&&a.loseContext()};this.forceContextRestore=function(){var a=ha.get("WEBGL_lose_context");a&&a.restoreContext()};this.getPixelRatio=function(){return U};this.setPixelRatio=function(a){void 0!==
17505 a&&(U=a,this.setSize(Z,M,!1))};this.getSize=function(){return{width:Z,height:M}};this.setSize=function(a,b,c){ja.isPresenting()?console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."):(Z=a,M=b,y.width=a*U,y.height=b*U,!1!==c&&(y.style.width=a+"px",y.style.height=b+"px"),this.setViewport(0,0,a,b))};this.getDrawingBufferSize=function(){return{width:Z*U,height:M*U}};this.setDrawingBufferSize=function(a,b,c){Z=a;M=b;U=c;y.width=a*c;y.height=b*c;this.setViewport(0,0,a,b)};
17506 this.getCurrentViewport=function(){return T};this.setViewport=function(a,b,c,d){od.set(a,M-b-d,c,d);ba.viewport(T.copy(od).multiplyScalar(U))};this.setScissor=function(a,b,c,d){fa.set(a,M-b-d,c,d);ba.scissor(wc.copy(fa).multiplyScalar(U))};this.setScissorTest=function(a){ba.setScissorTest(qa=a)};this.getClearColor=function(){return ka.getClearColor()};this.setClearColor=function(){ka.setClearColor.apply(ka,arguments)};this.getClearAlpha=function(){return ka.getClearAlpha()};this.setClearAlpha=function(){ka.setClearAlpha.apply(ka,
17507 arguments)};this.clear=function(a,b,c){var d=0;if(void 0===a||a)d|=F.COLOR_BUFFER_BIT;if(void 0===b||b)d|=F.DEPTH_BUFFER_BIT;if(void 0===c||c)d|=F.STENCIL_BUFFER_BIT;F.clear(d)};this.clearColor=function(){this.clear(!0,!1,!1)};this.clearDepth=function(){this.clear(!1,!0,!1)};this.clearStencil=function(){this.clear(!1,!1,!0)};this.clearTarget=function(a,b,c,d){this.setRenderTarget(a);this.clear(b,c,d)};this.dispose=function(){y.removeEventListener("webglcontextlost",d,!1);y.removeEventListener("webglcontextrestored",
17508 e,!1);sa.dispose();na.dispose();Ba.dispose();ma.dispose();ja.dispose();ta.stop()};this.renderBufferImmediate=function(a,b){ba.initAttributes();var c=Ba.get(a);a.hasPositions&&!c.position&&(c.position=F.createBuffer());a.hasNormals&&!c.normal&&(c.normal=F.createBuffer());a.hasUvs&&!c.uv&&(c.uv=F.createBuffer());a.hasColors&&!c.color&&(c.color=F.createBuffer());b=b.getAttributes();a.hasPositions&&(F.bindBuffer(F.ARRAY_BUFFER,c.position),F.bufferData(F.ARRAY_BUFFER,a.positionArray,F.DYNAMIC_DRAW),ba.enableAttribute(b.position),
17509 F.vertexAttribPointer(b.position,3,F.FLOAT,!1,0,0));a.hasNormals&&(F.bindBuffer(F.ARRAY_BUFFER,c.normal),F.bufferData(F.ARRAY_BUFFER,a.normalArray,F.DYNAMIC_DRAW),ba.enableAttribute(b.normal),F.vertexAttribPointer(b.normal,3,F.FLOAT,!1,0,0));a.hasUvs&&(F.bindBuffer(F.ARRAY_BUFFER,c.uv),F.bufferData(F.ARRAY_BUFFER,a.uvArray,F.DYNAMIC_DRAW),ba.enableAttribute(b.uv),F.vertexAttribPointer(b.uv,2,F.FLOAT,!1,0,0));a.hasColors&&(F.bindBuffer(F.ARRAY_BUFFER,c.color),F.bufferData(F.ARRAY_BUFFER,a.colorArray,
17510 F.DYNAMIC_DRAW),ba.enableAttribute(b.color),F.vertexAttribPointer(b.color,3,F.FLOAT,!1,0,0));ba.disableUnusedAttributes();F.drawArrays(F.TRIANGLES,0,a.count);a.count=0};this.renderBufferDirect=function(a,c,d,e,f,g){var h=f.isMesh&&0>f.normalMatrix.determinant();ba.setMaterial(e,h);var k=t(a,c,e,f),m=!1;if(b!==d.id||S!==k.id||nd!==(!0===e.wireframe))b=d.id,S=k.id,nd=!0===e.wireframe,m=!0;f.morphTargetInfluences&&(va.update(f,d,e,k),m=!0);h=d.index;var q=d.attributes.position;c=1;!0===e.wireframe&&
17511 (h=ra.getWireframeAttribute(d),c=2);a=xa;if(null!==h){var n=pa.get(h);a=ya;a.setIndex(n)}if(m){if(d&&d.isInstancedBufferGeometry&!ua.isWebGL2&&null===ha.get("ANGLE_instanced_arrays"))console.error("THREE.WebGLRenderer.setupVertexAttributes: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");else{ba.initAttributes();m=d.attributes;k=k.getAttributes();var u=e.defaultAttributeValues;for(N in k){var l=k[N];if(0<=l){var r=m[N];if(void 0!==r){var v=r.normalized,
17512 p=r.itemSize,w=pa.get(r);if(void 0!==w){var y=w.buffer,E=w.type;w=w.bytesPerElement;if(r.isInterleavedBufferAttribute){var x=r.data,B=x.stride;r=r.offset;x&&x.isInstancedInterleavedBuffer?(ba.enableAttributeAndDivisor(l,x.meshPerAttribute),void 0===d.maxInstancedCount&&(d.maxInstancedCount=x.meshPerAttribute*x.count)):ba.enableAttribute(l);F.bindBuffer(F.ARRAY_BUFFER,y);F.vertexAttribPointer(l,p,E,v,B*w,r*w)}else r.isInstancedBufferAttribute?(ba.enableAttributeAndDivisor(l,r.meshPerAttribute),void 0===
17513 d.maxInstancedCount&&(d.maxInstancedCount=r.meshPerAttribute*r.count)):ba.enableAttribute(l),F.bindBuffer(F.ARRAY_BUFFER,y),F.vertexAttribPointer(l,p,E,v,0,0)}}else if(void 0!==u&&(v=u[N],void 0!==v))switch(v.length){case 2:F.vertexAttrib2fv(l,v);break;case 3:F.vertexAttrib3fv(l,v);break;case 4:F.vertexAttrib4fv(l,v);break;default:F.vertexAttrib1fv(l,v)}}}ba.disableUnusedAttributes()}null!==h&&F.bindBuffer(F.ELEMENT_ARRAY_BUFFER,n.buffer)}n=Infinity;null!==h?n=h.count:void 0!==q&&(n=q.count);h=d.drawRange.start*
17514 c;q=null!==g?g.start*c:0;var N=Math.max(h,q);g=Math.max(0,Math.min(n,h+d.drawRange.count*c,q+(null!==g?g.count*c:Infinity))-1-N+1);if(0!==g){if(f.isMesh)if(!0===e.wireframe)ba.setLineWidth(e.wireframeLinewidth*(null===R?U:1)),a.setMode(F.LINES);else switch(f.drawMode){case 0:a.setMode(F.TRIANGLES);break;case 1:a.setMode(F.TRIANGLE_STRIP);break;case 2:a.setMode(F.TRIANGLE_FAN)}else f.isLine?(e=e.linewidth,void 0===e&&(e=1),ba.setLineWidth(e*(null===R?U:1)),f.isLineSegments?a.setMode(F.LINES):f.isLineLoop?
17515 a.setMode(F.LINE_LOOP):a.setMode(F.LINE_STRIP)):f.isPoints?a.setMode(F.POINTS):f.isSprite&&a.setMode(F.TRIANGLES);d&&d.isInstancedBufferGeometry?0<d.maxInstancedCount&&a.renderInstances(d,N,g):a.render(N,g)}};this.compile=function(a,b){D=na.get(a,b);D.init();a.traverse(function(a){a.isLight&&(D.pushLight(a),a.castShadow&&D.pushShadow(a))});D.setupLights(b);a.traverse(function(b){if(b.material)if(Array.isArray(b.material))for(var c=0;c<b.material.length;c++)n(b.material[c],a.fog,b);else n(b.material,
17516 a.fog,b)})};var wa=null,ta=new Qd;ta.setAnimationLoop(function(a){ja.isPresenting()||wa&&wa(a)});"undefined"!==typeof window&&ta.setContext(window);this.setAnimationLoop=function(a){wa=a;ja.setAnimationLoop(a);ta.start()};this.render=function(a,c,d,e){if(!c||!c.isCamera)console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");else if(!G){S=b=null;nd=!1;J=-1;Y=null;!0===a.autoUpdate&&a.updateMatrixWorld();null===c.parent&&c.updateMatrixWorld();ja.enabled&&(c=ja.getCamera(c));
17517 D=na.get(a,c);D.init();a.onBeforeRender(C,a,c,d);xc.multiplyMatrices(c.projectionMatrix,c.matrixWorldInverse);oa.setFromMatrix(xc);Yd=this.localClippingEnabled;pd=aa.init(this.clippingPlanes,Yd,c);A=sa.get(a,c);A.init();k(a,c,C.sortObjects);!0===C.sortObjects&&A.sort();pd&&aa.beginShadows();za.render(D.state.shadowsArray,a,c);D.setupLights(c);pd&&aa.endShadows();this.info.autoReset&&this.info.reset();void 0===d&&(d=null);this.setRenderTarget(d);ka.render(A,a,c,e);e=A.opaque;var f=A.transparent;if(a.overrideMaterial){var g=
17518 a.overrideMaterial;e.length&&m(e,a,c,g);f.length&&m(f,a,c,g)}else e.length&&m(e,a,c),f.length&&m(f,a,c);d&&ia.updateRenderTargetMipmap(d);ba.buffers.depth.setTest(!0);ba.buffers.depth.setMask(!0);ba.buffers.color.setMask(!0);ba.setPolygonOffset(!1);a.onAfterRender(C,a,c);ja.enabled&&ja.submitFrame();D=A=null}};this.allocTextureUnit=function(){var a=X;a>=ua.maxTextures&&console.warn("THREE.WebGLRenderer: Trying to use "+a+" texture units while this GPU supports only "+ua.maxTextures);X+=1;return a};
17519 this.setTexture2D=function(){var a=!1;return function(b,c){b&&b.isWebGLRenderTarget&&(a||(console.warn("THREE.WebGLRenderer.setTexture2D: don't use render targets as textures. Use their .texture property instead."),a=!0),b=b.texture);ia.setTexture2D(b,c)}}();this.setTexture=function(){var a=!1;return function(b,c){a||(console.warn("THREE.WebGLRenderer: .setTexture is deprecated, use setTexture2D instead."),a=!0);ia.setTexture2D(b,c)}}();this.setTextureCube=function(){var a=!1;return function(b,c){b&&
17520 b.isWebGLRenderTargetCube&&(a||(console.warn("THREE.WebGLRenderer.setTextureCube: don't use cube render targets as textures. Use their .texture property instead."),a=!0),b=b.texture);b&&b.isCubeTexture||Array.isArray(b.image)&&6===b.image.length?ia.setTextureCube(b,c):ia.setTextureCubeDynamic(b,c)}}();this.setFramebuffer=function(a){L=a};this.getRenderTarget=function(){return R};this.setRenderTarget=function(a){(R=a)&&void 0===Ba.get(a).__webglFramebuffer&&ia.setupRenderTarget(a);var b=L,c=!1;a?(b=
17521 Ba.get(a).__webglFramebuffer,a.isWebGLRenderTargetCube&&(b=b[a.activeCubeFace],c=!0),T.copy(a.viewport),wc.copy(a.scissor),ea=a.scissorTest):(T.copy(od).multiplyScalar(U),wc.copy(fa).multiplyScalar(U),ea=qa);Q!==b&&(F.bindFramebuffer(F.FRAMEBUFFER,b),Q=b);ba.viewport(T);ba.scissor(wc);ba.setScissorTest(ea);c&&(c=Ba.get(a.texture),F.framebufferTexture2D(F.FRAMEBUFFER,F.COLOR_ATTACHMENT0,F.TEXTURE_CUBE_MAP_POSITIVE_X+a.activeCubeFace,c.__webglTexture,a.activeMipMapLevel))};this.readRenderTargetPixels=
17522 function(a,b,c,d,e,f){if(a&&a.isWebGLRenderTarget){var g=Ba.get(a).__webglFramebuffer;if(g){var h=!1;g!==Q&&(F.bindFramebuffer(F.FRAMEBUFFER,g),h=!0);try{var k=a.texture,m=k.format,q=k.type;1023!==m&&da.convert(m)!==F.getParameter(F.IMPLEMENTATION_COLOR_READ_FORMAT)?console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format."):1009===q||da.convert(q)===F.getParameter(F.IMPLEMENTATION_COLOR_READ_TYPE)||1015===q&&(ua.isWebGL2||ha.get("OES_texture_float")||
17523 ha.get("WEBGL_color_buffer_float"))||1016===q&&(ua.isWebGL2?ha.get("EXT_color_buffer_float"):ha.get("EXT_color_buffer_half_float"))?F.checkFramebufferStatus(F.FRAMEBUFFER)===F.FRAMEBUFFER_COMPLETE?0<=b&&b<=a.width-d&&0<=c&&c<=a.height-e&&F.readPixels(b,c,d,e,da.convert(m),da.convert(q),f):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete."):console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.")}finally{h&&
17524 F.bindFramebuffer(F.FRAMEBUFFER,Q)}}}else console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.")};this.copyFramebufferToTexture=function(a,b,c){var d=b.image.width,e=b.image.height,f=da.convert(b.format);this.setTexture2D(b,0);F.copyTexImage2D(F.TEXTURE_2D,c||0,f,a.x,a.y,d,e,0)};this.copyTextureToTexture=function(a,b,c,d){var e=b.image.width,f=b.image.height,g=da.convert(c.format),h=da.convert(c.type);this.setTexture2D(c,0);b.isDataTexture?F.texSubImage2D(F.TEXTURE_2D,
17525 d||0,a.x,a.y,e,f,g,h,b.image.data):F.texSubImage2D(F.TEXTURE_2D,d||0,a.x,a.y,g,h,b.image)}}function Lb(a,b){this.name="";this.color=new G(a);this.density=void 0!==b?b:2.5E-4}function Mb(a,b,c){this.name="";this.color=new G(a);this.near=void 0!==b?b:1;this.far=void 0!==c?c:1E3}function qd(){D.call(this);this.type="Scene";this.overrideMaterial=this.fog=this.background=null;this.autoUpdate=!0}function ob(a,b){this.array=a;this.stride=b;this.count=void 0!==a?a.length/b:0;this.dynamic=!1;this.updateRange=
17526 {offset:0,count:-1};this.version=0}function zc(a,b,c,d){this.data=a;this.itemSize=b;this.offset=c;this.normalized=!0===d}function cb(a){J.call(this);this.type="SpriteMaterial";this.color=new G(16777215);this.map=null;this.rotation=0;this.lights=!1;this.transparent=!0;this.setValues(a)}function Ac(a){D.call(this);this.type="Sprite";if(void 0===Nb){Nb=new C;var b=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]);b=new ob(b,5);Nb.setIndex([0,1,2,0,2,3]);Nb.addAttribute("position",
17527 new zc(b,3,0,!1));Nb.addAttribute("uv",new zc(b,2,3,!1))}this.geometry=Nb;this.material=void 0!==a?a:new cb;this.center=new z(.5,.5)}function Bc(){D.call(this);this.type="LOD";Object.defineProperties(this,{levels:{enumerable:!0,value:[]}})}function Cc(a,b){a=a||[];this.bones=a.slice(0);this.boneMatrices=new Float32Array(16*this.bones.length);if(void 0===b)this.calculateInverses();else if(this.bones.length===b.length)this.boneInverses=b.slice(0);else for(console.warn("THREE.Skeleton boneInverses is the wrong length."),
17528 this.boneInverses=[],a=0,b=this.bones.length;a<b;a++)this.boneInverses.push(new I)}function rd(){D.call(this);this.type="Bone"}function sd(a,b){la.call(this,a,b);this.type="SkinnedMesh";this.bindMode="attached";this.bindMatrix=new I;this.bindMatrixInverse=new I;a=this.initBones();a=new Cc(a);this.bind(a,this.matrixWorld);this.normalizeSkinWeights()}function Y(a){J.call(this);this.type="LineBasicMaterial";this.color=new G(16777215);this.linewidth=1;this.linejoin=this.linecap="round";this.lights=!1;
17529 this.setValues(a)}function sa(a,b,c){1===c&&console.error("THREE.Line: parameter THREE.LinePieces no longer supported. Use THREE.LineSegments instead.");D.call(this);this.type="Line";this.geometry=void 0!==a?a:new C;this.material=void 0!==b?b:new Y({color:16777215*Math.random()})}function W(a,b){sa.call(this,a,b);this.type="LineSegments"}function td(a,b){sa.call(this,a,b);this.type="LineLoop"}function Ea(a){J.call(this);this.type="PointsMaterial";this.color=new G(16777215);this.map=null;this.size=
17530 1;this.sizeAttenuation=!0;this.lights=this.morphTargets=!1;this.setValues(a)}function Ob(a,b){D.call(this);this.type="Points";this.geometry=void 0!==a?a:new C;this.material=void 0!==b?b:new Ea({color:16777215*Math.random()})}function $d(a,b,c,d,e,f,g,h,k){T.call(this,a,b,c,d,e,f,g,h,k);this.generateMipmaps=!1}function Pb(a,b,c,d,e,f,g,h,k,m,q,n){T.call(this,null,f,g,h,k,m,d,e,q,n);this.image={width:b,height:c};this.mipmaps=a;this.generateMipmaps=this.flipY=!1}function Dc(a,b,c,d,e,f,g,h,k){T.call(this,
17531 a,b,c,d,e,f,g,h,k);this.needsUpdate=!0}function Ec(a,b,c,d,e,f,g,h,k,m){m=void 0!==m?m:1026;if(1026!==m&&1027!==m)throw Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===c&&1026===m&&(c=1012);void 0===c&&1027===m&&(c=1020);T.call(this,null,d,e,f,g,h,m,c,k);this.image={width:a,height:b};this.magFilter=void 0!==g?g:1003;this.minFilter=void 0!==h?h:1003;this.generateMipmaps=this.flipY=!1}function Qb(a){C.call(this);this.type="WireframeGeometry";var b=
17532 [],c,d,e,f=[0,0],g={},h=["a","b","c"];if(a&&a.isGeometry){var k=a.faces;var m=0;for(d=k.length;m<d;m++){var q=k[m];for(c=0;3>c;c++){var n=q[h[c]];var t=q[h[(c+1)%3]];f[0]=Math.min(n,t);f[1]=Math.max(n,t);n=f[0]+","+f[1];void 0===g[n]&&(g[n]={index1:f[0],index2:f[1]})}}for(n in g)m=g[n],h=a.vertices[m.index1],b.push(h.x,h.y,h.z),h=a.vertices[m.index2],b.push(h.x,h.y,h.z)}else if(a&&a.isBufferGeometry)if(h=new p,null!==a.index){k=a.attributes.position;q=a.index;var u=a.groups;0===u.length&&(u=[{start:0,
17533 count:q.count,materialIndex:0}]);a=0;for(e=u.length;a<e;++a)for(m=u[a],c=m.start,d=m.count,m=c,d=c+d;m<d;m+=3)for(c=0;3>c;c++)n=q.getX(m+c),t=q.getX(m+(c+1)%3),f[0]=Math.min(n,t),f[1]=Math.max(n,t),n=f[0]+","+f[1],void 0===g[n]&&(g[n]={index1:f[0],index2:f[1]});for(n in g)m=g[n],h.fromBufferAttribute(k,m.index1),b.push(h.x,h.y,h.z),h.fromBufferAttribute(k,m.index2),b.push(h.x,h.y,h.z)}else for(k=a.attributes.position,m=0,d=k.count/3;m<d;m++)for(c=0;3>c;c++)g=3*m+c,h.fromBufferAttribute(k,g),b.push(h.x,
17534 h.y,h.z),g=3*m+(c+1)%3,h.fromBufferAttribute(k,g),b.push(h.x,h.y,h.z);this.addAttribute("position",new A(b,3))}function Fc(a,b,c){R.call(this);this.type="ParametricGeometry";this.parameters={func:a,slices:b,stacks:c};this.fromBufferGeometry(new Rb(a,b,c));this.mergeVertices()}function Rb(a,b,c){C.call(this);this.type="ParametricBufferGeometry";this.parameters={func:a,slices:b,stacks:c};var d=[],e=[],f=[],g=[],h=new p,k=new p,m=new p,q=new p,n=new p,t,u;3>a.length&&console.error("THREE.ParametricGeometry: Function must now modify a Vector3 as third parameter.");
17535 var r=b+1;for(t=0;t<=c;t++){var l=t/c;for(u=0;u<=b;u++){var y=u/b;a(y,l,k);e.push(k.x,k.y,k.z);0<=y-1E-5?(a(y-1E-5,l,m),q.subVectors(k,m)):(a(y+1E-5,l,m),q.subVectors(m,k));0<=l-1E-5?(a(y,l-1E-5,m),n.subVectors(k,m)):(a(y,l+1E-5,m),n.subVectors(m,k));h.crossVectors(q,n).normalize();f.push(h.x,h.y,h.z);g.push(y,l)}}for(t=0;t<c;t++)for(u=0;u<b;u++)a=t*r+u+1,h=(t+1)*r+u+1,k=(t+1)*r+u,d.push(t*r+u,a,k),d.push(a,h,k);this.setIndex(d);this.addAttribute("position",new A(e,3));this.addAttribute("normal",
17536 new A(f,3));this.addAttribute("uv",new A(g,2))}function Gc(a,b,c,d){R.call(this);this.type="PolyhedronGeometry";this.parameters={vertices:a,indices:b,radius:c,detail:d};this.fromBufferGeometry(new na(a,b,c,d));this.mergeVertices()}function na(a,b,c,d){function e(a){h.push(a.x,a.y,a.z)}function f(b,c){b*=3;c.x=a[b+0];c.y=a[b+1];c.z=a[b+2]}function g(a,b,c,d){0>d&&1===a.x&&(k[b]=a.x-1);0===c.x&&0===c.z&&(k[b]=d/2/Math.PI+.5)}C.call(this);this.type="PolyhedronBufferGeometry";this.parameters={vertices:a,
17537 indices:b,radius:c,detail:d};c=c||1;d=d||0;var h=[],k=[];(function(a){for(var c=new p,d=new p,g=new p,h=0;h<b.length;h+=3){f(b[h+0],c);f(b[h+1],d);f(b[h+2],g);var k,m,l=c,x=d,w=g,B=Math.pow(2,a),E=[];for(m=0;m<=B;m++){E[m]=[];var P=l.clone().lerp(w,m/B),N=x.clone().lerp(w,m/B),O=B-m;for(k=0;k<=O;k++)E[m][k]=0===k&&m===B?P:P.clone().lerp(N,k/O)}for(m=0;m<B;m++)for(k=0;k<2*(B-m)-1;k++)l=Math.floor(k/2),0===k%2?(e(E[m][l+1]),e(E[m+1][l]),e(E[m][l])):(e(E[m][l+1]),e(E[m+1][l+1]),e(E[m+1][l]))}})(d);(function(a){for(var b=
17538 new p,c=0;c<h.length;c+=3)b.x=h[c+0],b.y=h[c+1],b.z=h[c+2],b.normalize().multiplyScalar(a),h[c+0]=b.x,h[c+1]=b.y,h[c+2]=b.z})(c);(function(){for(var a=new p,b=0;b<h.length;b+=3)a.x=h[b+0],a.y=h[b+1],a.z=h[b+2],k.push(Math.atan2(a.z,-a.x)/2/Math.PI+.5,1-(Math.atan2(-a.y,Math.sqrt(a.x*a.x+a.z*a.z))/Math.PI+.5));a=new p;b=new p;for(var c=new p,d=new p,e=new z,f=new z,l=new z,y=0,x=0;y<h.length;y+=9,x+=6){a.set(h[y+0],h[y+1],h[y+2]);b.set(h[y+3],h[y+4],h[y+5]);c.set(h[y+6],h[y+7],h[y+8]);e.set(k[x+0],
17539 k[x+1]);f.set(k[x+2],k[x+3]);l.set(k[x+4],k[x+5]);d.copy(a).add(b).add(c).divideScalar(3);var w=Math.atan2(d.z,-d.x);g(e,x+0,a,w);g(f,x+2,b,w);g(l,x+4,c,w)}for(a=0;a<k.length;a+=6)b=k[a+0],c=k[a+2],d=k[a+4],e=Math.min(b,c,d),.9<Math.max(b,c,d)&&.1>e&&(.2>b&&(k[a+0]+=1),.2>c&&(k[a+2]+=1),.2>d&&(k[a+4]+=1))})();this.addAttribute("position",new A(h,3));this.addAttribute("normal",new A(h.slice(),3));this.addAttribute("uv",new A(k,2));0===d?this.computeVertexNormals():this.normalizeNormals()}function Hc(a,
17540 b){R.call(this);this.type="TetrahedronGeometry";this.parameters={radius:a,detail:b};this.fromBufferGeometry(new Sb(a,b));this.mergeVertices()}function Sb(a,b){na.call(this,[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],[2,1,0,0,3,2,1,3,0,2,3,1],a,b);this.type="TetrahedronBufferGeometry";this.parameters={radius:a,detail:b}}function Ic(a,b){R.call(this);this.type="OctahedronGeometry";this.parameters={radius:a,detail:b};this.fromBufferGeometry(new pb(a,b));this.mergeVertices()}function pb(a,b){na.call(this,[1,0,0,
17541 -1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],a,b);this.type="OctahedronBufferGeometry";this.parameters={radius:a,detail:b}}function Jc(a,b){R.call(this);this.type="IcosahedronGeometry";this.parameters={radius:a,detail:b};this.fromBufferGeometry(new Tb(a,b));this.mergeVertices()}function Tb(a,b){var c=(1+Math.sqrt(5))/2;na.call(this,[-1,c,0,1,c,0,-1,-c,0,1,-c,0,0,-1,c,0,1,c,0,-1,-c,0,1,-c,c,0,-1,c,0,1,-c,0,-1,-c,0,1],[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,
17542 11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],a,b);this.type="IcosahedronBufferGeometry";this.parameters={radius:a,detail:b}}function Kc(a,b){R.call(this);this.type="DodecahedronGeometry";this.parameters={radius:a,detail:b};this.fromBufferGeometry(new Ub(a,b));this.mergeVertices()}function Ub(a,b){var c=(1+Math.sqrt(5))/2,d=1/c;na.call(this,[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-d,-c,0,-d,c,0,d,-c,0,d,c,-d,-c,0,-d,c,0,d,-c,0,d,c,
17543 0,-c,0,-d,c,0,-d,-c,0,d,c,0,d],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],a,b);this.type="DodecahedronBufferGeometry";this.parameters={radius:a,detail:b}}function Lc(a,b,c,d,e,f){R.call(this);this.type="TubeGeometry";this.parameters={path:a,tubularSegments:b,radius:c,radialSegments:d,
17544 closed:e};void 0!==f&&console.warn("THREE.TubeGeometry: taper has been removed.");a=new Vb(a,b,c,d,e);this.tangents=a.tangents;this.normals=a.normals;this.binormals=a.binormals;this.fromBufferGeometry(a);this.mergeVertices()}function Vb(a,b,c,d,e){function f(e){q=a.getPointAt(e/b,q);var f=g.normals[e];e=g.binormals[e];for(t=0;t<=d;t++){var m=t/d*Math.PI*2,n=Math.sin(m);m=-Math.cos(m);k.x=m*f.x+n*e.x;k.y=m*f.y+n*e.y;k.z=m*f.z+n*e.z;k.normalize();r.push(k.x,k.y,k.z);h.x=q.x+c*k.x;h.y=q.y+c*k.y;h.z=
17545 q.z+c*k.z;l.push(h.x,h.y,h.z)}}C.call(this);this.type="TubeBufferGeometry";this.parameters={path:a,tubularSegments:b,radius:c,radialSegments:d,closed:e};b=b||64;c=c||1;d=d||8;e=e||!1;var g=a.computeFrenetFrames(b,e);this.tangents=g.tangents;this.normals=g.normals;this.binormals=g.binormals;var h=new p,k=new p,m=new z,q=new p,n,t,l=[],r=[],v=[],y=[];for(n=0;n<b;n++)f(n);f(!1===e?b:0);for(n=0;n<=b;n++)for(t=0;t<=d;t++)m.x=n/b,m.y=t/d,v.push(m.x,m.y);(function(){for(t=1;t<=b;t++)for(n=1;n<=d;n++){var a=
17546 (d+1)*t+(n-1),c=(d+1)*t+n,e=(d+1)*(t-1)+n;y.push((d+1)*(t-1)+(n-1),a,e);y.push(a,c,e)}})();this.setIndex(y);this.addAttribute("position",new A(l,3));this.addAttribute("normal",new A(r,3));this.addAttribute("uv",new A(v,2))}function Mc(a,b,c,d,e,f,g){R.call(this);this.type="TorusKnotGeometry";this.parameters={radius:a,tube:b,tubularSegments:c,radialSegments:d,p:e,q:f};void 0!==g&&console.warn("THREE.TorusKnotGeometry: heightScale has been deprecated. Use .scale( x, y, z ) instead.");this.fromBufferGeometry(new Wb(a,
17547 b,c,d,e,f));this.mergeVertices()}function Wb(a,b,c,d,e,f){function g(a,b,c,d,e){var f=Math.sin(a);b=c/b*a;c=Math.cos(b);e.x=d*(2+c)*.5*Math.cos(a);e.y=d*(2+c)*f*.5;e.z=d*Math.sin(b)*.5}C.call(this);this.type="TorusKnotBufferGeometry";this.parameters={radius:a,tube:b,tubularSegments:c,radialSegments:d,p:e,q:f};a=a||1;b=b||.4;c=Math.floor(c)||64;d=Math.floor(d)||8;e=e||2;f=f||3;var h=[],k=[],m=[],q=[],n,t=new p,l=new p,r=new p,v=new p,y=new p,x=new p,w=new p;for(n=0;n<=c;++n){var B=n/c*e*Math.PI*2;
17548 g(B,e,f,a,r);g(B+.01,e,f,a,v);x.subVectors(v,r);w.addVectors(v,r);y.crossVectors(x,w);w.crossVectors(y,x);y.normalize();w.normalize();for(B=0;B<=d;++B){var E=B/d*Math.PI*2,P=-b*Math.cos(E);E=b*Math.sin(E);t.x=r.x+(P*w.x+E*y.x);t.y=r.y+(P*w.y+E*y.y);t.z=r.z+(P*w.z+E*y.z);k.push(t.x,t.y,t.z);l.subVectors(t,r).normalize();m.push(l.x,l.y,l.z);q.push(n/c);q.push(B/d)}}for(B=1;B<=c;B++)for(n=1;n<=d;n++)a=(d+1)*B+(n-1),b=(d+1)*B+n,e=(d+1)*(B-1)+n,h.push((d+1)*(B-1)+(n-1),a,e),h.push(a,b,e);this.setIndex(h);
17549 this.addAttribute("position",new A(k,3));this.addAttribute("normal",new A(m,3));this.addAttribute("uv",new A(q,2))}function Nc(a,b,c,d,e){R.call(this);this.type="TorusGeometry";this.parameters={radius:a,tube:b,radialSegments:c,tubularSegments:d,arc:e};this.fromBufferGeometry(new Xb(a,b,c,d,e));this.mergeVertices()}function Xb(a,b,c,d,e){C.call(this);this.type="TorusBufferGeometry";this.parameters={radius:a,tube:b,radialSegments:c,tubularSegments:d,arc:e};a=a||1;b=b||.4;c=Math.floor(c)||8;d=Math.floor(d)||
17550 6;e=e||2*Math.PI;var f=[],g=[],h=[],k=[],m=new p,q=new p,n=new p,t,l;for(t=0;t<=c;t++)for(l=0;l<=d;l++){var r=l/d*e,v=t/c*Math.PI*2;q.x=(a+b*Math.cos(v))*Math.cos(r);q.y=(a+b*Math.cos(v))*Math.sin(r);q.z=b*Math.sin(v);g.push(q.x,q.y,q.z);m.x=a*Math.cos(r);m.y=a*Math.sin(r);n.subVectors(q,m).normalize();h.push(n.x,n.y,n.z);k.push(l/d);k.push(t/c)}for(t=1;t<=c;t++)for(l=1;l<=d;l++)a=(d+1)*(t-1)+l-1,b=(d+1)*(t-1)+l,e=(d+1)*t+l,f.push((d+1)*t+l-1,a,e),f.push(a,b,e);this.setIndex(f);this.addAttribute("position",
17551 new A(g,3));this.addAttribute("normal",new A(h,3));this.addAttribute("uv",new A(k,2))}function bf(a,b,c,d,e){for(var f,g=0,h=b,k=c-d;h<c;h+=d)g+=(a[k]-a[h])*(a[h+1]+a[k+1]),k=h;if(e===0<g)for(e=b;e<c;e+=d)f=cf(e,a[e],a[e+1],f);else for(e=c-d;e>=b;e-=d)f=cf(e,a[e],a[e+1],f);f&&qb(f,f.next)&&(Oc(f),f=f.next);return f}function Pc(a,b){if(!a)return a;b||(b=a);do{var c=!1;if(a.steiner||!qb(a,a.next)&&0!==ma(a.prev,a,a.next))a=a.next;else{Oc(a);a=b=a.prev;if(a===a.next)break;c=!0}}while(c||a!==b);return b}
17552 function Qc(a,b,c,d,e,f,g){if(a){if(!g&&f){var h=a,k=h;do null===k.z&&(k.z=ae(k.x,k.y,d,e,f)),k.prevZ=k.prev,k=k.nextZ=k.next;while(k!==h);k.prevZ.nextZ=null;k.prevZ=null;h=k;var m,q,n,t,l=1;do{k=h;var r=h=null;for(q=0;k;){q++;var v=k;for(m=n=0;m<l&&(n++,v=v.nextZ,v);m++);for(t=l;0<n||0<t&&v;)0!==n&&(0===t||!v||k.z<=v.z)?(m=k,k=k.nextZ,n--):(m=v,v=v.nextZ,t--),r?r.nextZ=m:h=m,m.prevZ=r,r=m;k=v}r.nextZ=null;l*=2}while(1<q)}for(h=a;a.prev!==a.next;){k=a.prev;v=a.next;if(f)a:{r=a;t=d;var p=e,x=f;q=r.prev;
17553 n=r;l=r.next;if(0<=ma(q,n,l))r=!1;else{var w=q.x>n.x?q.x>l.x?q.x:l.x:n.x>l.x?n.x:l.x,B=q.y>n.y?q.y>l.y?q.y:l.y:n.y>l.y?n.y:l.y;m=ae(q.x<n.x?q.x<l.x?q.x:l.x:n.x<l.x?n.x:l.x,q.y<n.y?q.y<l.y?q.y:l.y:n.y<l.y?n.y:l.y,t,p,x);t=ae(w,B,t,p,x);for(p=r.nextZ;p&&p.z<=t;){if(p!==r.prev&&p!==r.next&&ud(q.x,q.y,n.x,n.y,l.x,l.y,p.x,p.y)&&0<=ma(p.prev,p,p.next)){r=!1;break a}p=p.nextZ}for(p=r.prevZ;p&&p.z>=m;){if(p!==r.prev&&p!==r.next&&ud(q.x,q.y,n.x,n.y,l.x,l.y,p.x,p.y)&&0<=ma(p.prev,p,p.next)){r=!1;break a}p=
17554 p.prevZ}r=!0}}else a:if(r=a,q=r.prev,n=r,l=r.next,0<=ma(q,n,l))r=!1;else{for(m=r.next.next;m!==r.prev;){if(ud(q.x,q.y,n.x,n.y,l.x,l.y,m.x,m.y)&&0<=ma(m.prev,m,m.next)){r=!1;break a}m=m.next}r=!0}if(r)b.push(k.i/c),b.push(a.i/c),b.push(v.i/c),Oc(a),h=a=v.next;else if(a=v,a===h){if(!g)Qc(Pc(a),b,c,d,e,f,1);else if(1===g){g=b;h=c;k=a;do v=k.prev,r=k.next.next,!qb(v,r)&&df(v,k,k.next,r)&&Rc(v,r)&&Rc(r,v)&&(g.push(v.i/h),g.push(k.i/h),g.push(r.i/h),Oc(k),Oc(k.next),k=a=r),k=k.next;while(k!==a);a=k;Qc(a,
17555 b,c,d,e,f,2)}else if(2===g)a:{g=a;do{for(h=g.next.next;h!==g.prev;){if(k=g.i!==h.i){k=g;v=h;if(r=k.next.i!==v.i&&k.prev.i!==v.i){b:{r=k;do{if(r.i!==k.i&&r.next.i!==k.i&&r.i!==v.i&&r.next.i!==v.i&&df(r,r.next,k,v)){r=!0;break b}r=r.next}while(r!==k);r=!1}r=!r}if(r=r&&Rc(k,v)&&Rc(v,k)){r=k;q=!1;n=(k.x+v.x)/2;v=(k.y+v.y)/2;do r.y>v!==r.next.y>v&&r.next.y!==r.y&&n<(r.next.x-r.x)*(v-r.y)/(r.next.y-r.y)+r.x&&(q=!q),r=r.next;while(r!==k);r=q}k=r}if(k){a=ef(g,h);g=Pc(g,g.next);a=Pc(a,a.next);Qc(g,b,c,d,e,
17556 f);Qc(a,b,c,d,e,f);break a}h=h.next}g=g.next}while(g!==a)}break}}}}function Ng(a,b){return a.x-b.x}function Og(a,b){var c=b,d=a.x,e=a.y,f=-Infinity;do{if(e<=c.y&&e>=c.next.y&&c.next.y!==c.y){var g=c.x+(e-c.y)*(c.next.x-c.x)/(c.next.y-c.y);if(g<=d&&g>f){f=g;if(g===d){if(e===c.y)return c;if(e===c.next.y)return c.next}var h=c.x<c.next.x?c:c.next}}c=c.next}while(c!==b);if(!h)return null;if(d===f)return h.prev;b=h;g=h.x;var k=h.y,m=Infinity;for(c=h.next;c!==b;){if(d>=c.x&&c.x>=g&&d!==c.x&&ud(e<k?d:f,e,
17557 g,k,e<k?f:d,e,c.x,c.y)){var q=Math.abs(e-c.y)/(d-c.x);(q<m||q===m&&c.x>h.x)&&Rc(c,a)&&(h=c,m=q)}c=c.next}return h}function ae(a,b,c,d,e){a=32767*(a-c)*e;b=32767*(b-d)*e;a=(a|a<<8)&16711935;a=(a|a<<4)&252645135;a=(a|a<<2)&858993459;b=(b|b<<8)&16711935;b=(b|b<<4)&252645135;b=(b|b<<2)&858993459;return(a|a<<1)&1431655765|((b|b<<1)&1431655765)<<1}function Pg(a){var b=a,c=a;do b.x<c.x&&(c=b),b=b.next;while(b!==a);return c}function ud(a,b,c,d,e,f,g,h){return 0<=(e-g)*(b-h)-(a-g)*(f-h)&&0<=(a-g)*(d-h)-(c-
17558 g)*(b-h)&&0<=(c-g)*(f-h)-(e-g)*(d-h)}function ma(a,b,c){return(b.y-a.y)*(c.x-b.x)-(b.x-a.x)*(c.y-b.y)}function qb(a,b){return a.x===b.x&&a.y===b.y}function df(a,b,c,d){return qb(a,b)&&qb(c,d)||qb(a,d)&&qb(c,b)?!0:0<ma(a,b,c)!==0<ma(a,b,d)&&0<ma(c,d,a)!==0<ma(c,d,b)}function Rc(a,b){return 0>ma(a.prev,a,a.next)?0<=ma(a,b,a.next)&&0<=ma(a,a.prev,b):0>ma(a,b,a.prev)||0>ma(a,a.next,b)}function ef(a,b){var c=new be(a.i,a.x,a.y),d=new be(b.i,b.x,b.y),e=a.next,f=b.prev;a.next=b;b.prev=a;c.next=e;e.prev=
17559 c;d.next=c;c.prev=d;f.next=d;d.prev=f;return d}function cf(a,b,c,d){a=new be(a,b,c);d?(a.next=d.next,a.prev=d,d.next.prev=a,d.next=a):(a.prev=a,a.next=a);return a}function Oc(a){a.next.prev=a.prev;a.prev.next=a.next;a.prevZ&&(a.prevZ.nextZ=a.nextZ);a.nextZ&&(a.nextZ.prevZ=a.prevZ)}function be(a,b,c){this.i=a;this.x=b;this.y=c;this.nextZ=this.prevZ=this.z=this.next=this.prev=null;this.steiner=!1}function ff(a){var b=a.length;2<b&&a[b-1].equals(a[0])&&a.pop()}function gf(a,b){for(var c=0;c<b.length;c++)a.push(b[c].x),
17560 a.push(b[c].y)}function rb(a,b){R.call(this);this.type="ExtrudeGeometry";this.parameters={shapes:a,options:b};this.fromBufferGeometry(new Oa(a,b));this.mergeVertices()}function Oa(a,b){function c(a){function c(a,b,c){b||console.error("THREE.ExtrudeGeometry: vec does not exist");return b.clone().multiplyScalar(c).add(a)}function g(a,b,c){var d=a.x-b.x;var e=a.y-b.y;var f=c.x-a.x;var g=c.y-a.y,h=d*d+e*e;if(Math.abs(d*g-e*f)>Number.EPSILON){var k=Math.sqrt(h),m=Math.sqrt(f*f+g*g);h=b.x-e/k;b=b.y+d/k;
17561 g=((c.x-g/m-h)*g-(c.y+f/m-b)*f)/(d*g-e*f);f=h+d*g-a.x;d=b+e*g-a.y;e=f*f+d*d;if(2>=e)return new z(f,d);e=Math.sqrt(e/2)}else a=!1,d>Number.EPSILON?f>Number.EPSILON&&(a=!0):d<-Number.EPSILON?f<-Number.EPSILON&&(a=!0):Math.sign(e)===Math.sign(g)&&(a=!0),a?(f=-e,e=Math.sqrt(h)):(f=d,d=e,e=Math.sqrt(h/2));return new z(f/e,d/e)}function h(a,b){for(M=a.length;0<=--M;){var c=M;var f=M-1;0>f&&(f=a.length-1);var g,h=w+2*O;for(g=0;g<h;g++){var k=Z*g,m=Z*(g+1),q=b+f+k,n=b+f+m;m=b+c+m;r(b+c+k);r(q);r(m);r(q);
17562 r(n);r(m);k=e.length/3;k=D.generateSideWallUV(d,e,k-6,k-3,k-2,k-1);v(k[0]);v(k[1]);v(k[3]);v(k[1]);v(k[2]);v(k[3])}}}function k(a,b,c){y.push(a);y.push(b);y.push(c)}function l(a,b,c){r(a);r(b);r(c);a=e.length/3;a=D.generateTopUV(d,e,a-3,a-2,a-1);v(a[0]);v(a[1]);v(a[2])}function r(a){e.push(y[3*a]);e.push(y[3*a+1]);e.push(y[3*a+2])}function v(a){f.push(a.x);f.push(a.y)}var y=[],x=void 0!==b.curveSegments?b.curveSegments:12,w=void 0!==b.steps?b.steps:1,B=void 0!==b.depth?b.depth:100,E=void 0!==b.bevelEnabled?
17563 b.bevelEnabled:!0,P=void 0!==b.bevelThickness?b.bevelThickness:6,N=void 0!==b.bevelSize?b.bevelSize:P-2,O=void 0!==b.bevelSegments?b.bevelSegments:3,A=b.extrudePath,D=void 0!==b.UVGenerator?b.UVGenerator:Qg;void 0!==b.amount&&(console.warn("THREE.ExtrudeBufferGeometry: amount has been renamed to depth."),B=b.amount);var C=!1;if(A){var G=A.getSpacedPoints(w);C=!0;E=!1;var K=A.computeFrenetFrames(w,!1);var L=new p;var R=new p;var Q=new p}E||(N=P=O=0);var I;x=a.extractPoints(x);a=x.shape;var J=x.holes;
17564 if(!Va.isClockWise(a)){a=a.reverse();var H=0;for(I=J.length;H<I;H++){var S=J[H];Va.isClockWise(S)&&(J[H]=S.reverse())}}var Y=Va.triangulateShape(a,J),W=a;H=0;for(I=J.length;H<I;H++)S=J[H],a=a.concat(S);var T,Z=a.length,V,ea=Y.length;x=[];var M=0;var U=W.length;var X=U-1;for(T=M+1;M<U;M++,X++,T++)X===U&&(X=0),T===U&&(T=0),x[M]=g(W[M],W[X],W[T]);A=[];var fa=x.concat();H=0;for(I=J.length;H<I;H++){S=J[H];var ca=[];M=0;U=S.length;X=U-1;for(T=M+1;M<U;M++,X++,T++)X===U&&(X=0),T===U&&(T=0),ca[M]=g(S[M],S[X],
17565 S[T]);A.push(ca);fa=fa.concat(ca)}for(X=0;X<O;X++){U=X/O;var da=P*Math.cos(U*Math.PI/2);T=N*Math.sin(U*Math.PI/2);M=0;for(U=W.length;M<U;M++){var aa=c(W[M],x[M],T);k(aa.x,aa.y,-da)}H=0;for(I=J.length;H<I;H++)for(S=J[H],ca=A[H],M=0,U=S.length;M<U;M++)aa=c(S[M],ca[M],T),k(aa.x,aa.y,-da)}T=N;for(M=0;M<Z;M++)aa=E?c(a[M],fa[M],T):a[M],C?(R.copy(K.normals[0]).multiplyScalar(aa.x),L.copy(K.binormals[0]).multiplyScalar(aa.y),Q.copy(G[0]).add(R).add(L),k(Q.x,Q.y,Q.z)):k(aa.x,aa.y,0);for(U=1;U<=w;U++)for(M=
17566 0;M<Z;M++)aa=E?c(a[M],fa[M],T):a[M],C?(R.copy(K.normals[U]).multiplyScalar(aa.x),L.copy(K.binormals[U]).multiplyScalar(aa.y),Q.copy(G[U]).add(R).add(L),k(Q.x,Q.y,Q.z)):k(aa.x,aa.y,B/w*U);for(X=O-1;0<=X;X--){U=X/O;da=P*Math.cos(U*Math.PI/2);T=N*Math.sin(U*Math.PI/2);M=0;for(U=W.length;M<U;M++)aa=c(W[M],x[M],T),k(aa.x,aa.y,B+da);H=0;for(I=J.length;H<I;H++)for(S=J[H],ca=A[H],M=0,U=S.length;M<U;M++)aa=c(S[M],ca[M],T),C?k(aa.x,aa.y+G[w-1].y,G[w-1].x+da):k(aa.x,aa.y,B+da)}(function(){var a=e.length/3;if(E){var b=
17567 0*Z;for(M=0;M<ea;M++)V=Y[M],l(V[2]+b,V[1]+b,V[0]+b);b=Z*(w+2*O);for(M=0;M<ea;M++)V=Y[M],l(V[0]+b,V[1]+b,V[2]+b)}else{for(M=0;M<ea;M++)V=Y[M],l(V[2],V[1],V[0]);for(M=0;M<ea;M++)V=Y[M],l(V[0]+Z*w,V[1]+Z*w,V[2]+Z*w)}d.addGroup(a,e.length/3-a,0)})();(function(){var a=e.length/3,b=0;h(W,b);b+=W.length;H=0;for(I=J.length;H<I;H++)S=J[H],h(S,b),b+=S.length;d.addGroup(a,e.length/3-a,1)})()}C.call(this);this.type="ExtrudeBufferGeometry";this.parameters={shapes:a,options:b};a=Array.isArray(a)?a:[a];for(var d=
17568 this,e=[],f=[],g=0,h=a.length;g<h;g++)c(a[g]);this.addAttribute("position",new A(e,3));this.addAttribute("uv",new A(f,2));this.computeVertexNormals()}function hf(a,b,c){c.shapes=[];if(Array.isArray(a))for(var d=0,e=a.length;d<e;d++)c.shapes.push(a[d].uuid);else c.shapes.push(a.uuid);void 0!==b.extrudePath&&(c.options.extrudePath=b.extrudePath.toJSON());return c}function Sc(a,b){R.call(this);this.type="TextGeometry";this.parameters={text:a,parameters:b};this.fromBufferGeometry(new Yb(a,b));this.mergeVertices()}
17569 function Yb(a,b){b=b||{};var c=b.font;if(!c||!c.isFont)return console.error("THREE.TextGeometry: font parameter is not an instance of THREE.Font."),new R;a=c.generateShapes(a,b.size);b.depth=void 0!==b.height?b.height:50;void 0===b.bevelThickness&&(b.bevelThickness=10);void 0===b.bevelSize&&(b.bevelSize=8);void 0===b.bevelEnabled&&(b.bevelEnabled=!1);Oa.call(this,a,b);this.type="TextBufferGeometry"}function Tc(a,b,c,d,e,f,g){R.call(this);this.type="SphereGeometry";this.parameters={radius:a,widthSegments:b,
17570 heightSegments:c,phiStart:d,phiLength:e,thetaStart:f,thetaLength:g};this.fromBufferGeometry(new sb(a,b,c,d,e,f,g));this.mergeVertices()}function sb(a,b,c,d,e,f,g){C.call(this);this.type="SphereBufferGeometry";this.parameters={radius:a,widthSegments:b,heightSegments:c,phiStart:d,phiLength:e,thetaStart:f,thetaLength:g};a=a||1;b=Math.max(3,Math.floor(b)||8);c=Math.max(2,Math.floor(c)||6);d=void 0!==d?d:0;e=void 0!==e?e:2*Math.PI;f=void 0!==f?f:0;g=void 0!==g?g:Math.PI;var h=f+g,k,m,q=0,n=[],l=new p,
17571 u=new p,r=[],v=[],y=[],x=[];for(m=0;m<=c;m++){var w=[],B=m/c;for(k=0;k<=b;k++){var E=k/b;l.x=-a*Math.cos(d+E*e)*Math.sin(f+B*g);l.y=a*Math.cos(f+B*g);l.z=a*Math.sin(d+E*e)*Math.sin(f+B*g);v.push(l.x,l.y,l.z);u.set(l.x,l.y,l.z).normalize();y.push(u.x,u.y,u.z);x.push(E,1-B);w.push(q++)}n.push(w)}for(m=0;m<c;m++)for(k=0;k<b;k++)a=n[m][k+1],d=n[m][k],e=n[m+1][k],g=n[m+1][k+1],(0!==m||0<f)&&r.push(a,d,g),(m!==c-1||h<Math.PI)&&r.push(d,e,g);this.setIndex(r);this.addAttribute("position",new A(v,3));this.addAttribute("normal",
17572 new A(y,3));this.addAttribute("uv",new A(x,2))}function Uc(a,b,c,d,e,f){R.call(this);this.type="RingGeometry";this.parameters={innerRadius:a,outerRadius:b,thetaSegments:c,phiSegments:d,thetaStart:e,thetaLength:f};this.fromBufferGeometry(new Zb(a,b,c,d,e,f));this.mergeVertices()}function Zb(a,b,c,d,e,f){C.call(this);this.type="RingBufferGeometry";this.parameters={innerRadius:a,outerRadius:b,thetaSegments:c,phiSegments:d,thetaStart:e,thetaLength:f};a=a||.5;b=b||1;e=void 0!==e?e:0;f=void 0!==f?f:2*Math.PI;
17573 c=void 0!==c?Math.max(3,c):8;d=void 0!==d?Math.max(1,d):1;var g=[],h=[],k=[],m=[],q=a,n=(b-a)/d,l=new p,u=new z,r,v;for(r=0;r<=d;r++){for(v=0;v<=c;v++)a=e+v/c*f,l.x=q*Math.cos(a),l.y=q*Math.sin(a),h.push(l.x,l.y,l.z),k.push(0,0,1),u.x=(l.x/b+1)/2,u.y=(l.y/b+1)/2,m.push(u.x,u.y);q+=n}for(r=0;r<d;r++)for(b=r*(c+1),v=0;v<c;v++)a=v+b,e=a+c+1,f=a+c+2,q=a+1,g.push(a,e,q),g.push(e,f,q);this.setIndex(g);this.addAttribute("position",new A(h,3));this.addAttribute("normal",new A(k,3));this.addAttribute("uv",
17574 new A(m,2))}function Vc(a,b,c,d){R.call(this);this.type="LatheGeometry";this.parameters={points:a,segments:b,phiStart:c,phiLength:d};this.fromBufferGeometry(new $b(a,b,c,d));this.mergeVertices()}function $b(a,b,c,d){C.call(this);this.type="LatheBufferGeometry";this.parameters={points:a,segments:b,phiStart:c,phiLength:d};b=Math.floor(b)||12;c=c||0;d=d||2*Math.PI;d=H.clamp(d,0,2*Math.PI);var e=[],f=[],g=[],h=1/b,k=new p,m=new z,q;for(q=0;q<=b;q++){var n=c+q*h*d;var l=Math.sin(n),u=Math.cos(n);for(n=
17575 0;n<=a.length-1;n++)k.x=a[n].x*l,k.y=a[n].y,k.z=a[n].x*u,f.push(k.x,k.y,k.z),m.x=q/b,m.y=n/(a.length-1),g.push(m.x,m.y)}for(q=0;q<b;q++)for(n=0;n<a.length-1;n++)c=n+q*a.length,h=c+a.length,k=c+a.length+1,m=c+1,e.push(c,h,m),e.push(h,k,m);this.setIndex(e);this.addAttribute("position",new A(f,3));this.addAttribute("uv",new A(g,2));this.computeVertexNormals();if(d===2*Math.PI)for(d=this.attributes.normal.array,e=new p,f=new p,g=new p,c=b*a.length*3,n=q=0;q<a.length;q++,n+=3)e.x=d[n+0],e.y=d[n+1],e.z=
17576 d[n+2],f.x=d[c+n+0],f.y=d[c+n+1],f.z=d[c+n+2],g.addVectors(e,f).normalize(),d[n+0]=d[c+n+0]=g.x,d[n+1]=d[c+n+1]=g.y,d[n+2]=d[c+n+2]=g.z}function tb(a,b){R.call(this);this.type="ShapeGeometry";"object"===typeof b&&(console.warn("THREE.ShapeGeometry: Options parameter has been removed."),b=b.curveSegments);this.parameters={shapes:a,curveSegments:b};this.fromBufferGeometry(new ub(a,b));this.mergeVertices()}function ub(a,b){function c(a){var c,h=e.length/3;a=a.extractPoints(b);var m=a.shape,q=a.holes;
17577 if(!1===Va.isClockWise(m))for(m=m.reverse(),a=0,c=q.length;a<c;a++){var l=q[a];!0===Va.isClockWise(l)&&(q[a]=l.reverse())}var p=Va.triangulateShape(m,q);a=0;for(c=q.length;a<c;a++)l=q[a],m=m.concat(l);a=0;for(c=m.length;a<c;a++)l=m[a],e.push(l.x,l.y,0),f.push(0,0,1),g.push(l.x,l.y);a=0;for(c=p.length;a<c;a++)m=p[a],d.push(m[0]+h,m[1]+h,m[2]+h),k+=3}C.call(this);this.type="ShapeBufferGeometry";this.parameters={shapes:a,curveSegments:b};b=b||12;var d=[],e=[],f=[],g=[],h=0,k=0;if(!1===Array.isArray(a))c(a);
17578 else for(var m=0;m<a.length;m++)c(a[m]),this.addGroup(h,k,m),h+=k,k=0;this.setIndex(d);this.addAttribute("position",new A(e,3));this.addAttribute("normal",new A(f,3));this.addAttribute("uv",new A(g,2))}function jf(a,b){b.shapes=[];if(Array.isArray(a))for(var c=0,d=a.length;c<d;c++)b.shapes.push(a[c].uuid);else b.shapes.push(a.uuid);return b}function ac(a,b){C.call(this);this.type="EdgesGeometry";this.parameters={thresholdAngle:b};var c=[];b=Math.cos(H.DEG2RAD*(void 0!==b?b:1));var d=[0,0],e={},f=
17579 ["a","b","c"];if(a.isBufferGeometry){var g=new R;g.fromBufferGeometry(a)}else g=a.clone();g.mergeVertices();g.computeFaceNormals();a=g.vertices;g=g.faces;for(var h=0,k=g.length;h<k;h++)for(var m=g[h],q=0;3>q;q++){var n=m[f[q]];var l=m[f[(q+1)%3]];d[0]=Math.min(n,l);d[1]=Math.max(n,l);n=d[0]+","+d[1];void 0===e[n]?e[n]={index1:d[0],index2:d[1],face1:h,face2:void 0}:e[n].face2=h}for(n in e)if(d=e[n],void 0===d.face2||g[d.face1].normal.dot(g[d.face2].normal)<=b)f=a[d.index1],c.push(f.x,f.y,f.z),f=a[d.index2],
17580 c.push(f.x,f.y,f.z);this.addAttribute("position",new A(c,3))}function vb(a,b,c,d,e,f,g,h){R.call(this);this.type="CylinderGeometry";this.parameters={radiusTop:a,radiusBottom:b,height:c,radialSegments:d,heightSegments:e,openEnded:f,thetaStart:g,thetaLength:h};this.fromBufferGeometry(new Wa(a,b,c,d,e,f,g,h));this.mergeVertices()}function Wa(a,b,c,d,e,f,g,h){function k(c){var e,f=new z,k=new p,t=0,v=!0===c?a:b,w=!0===c?1:-1;var A=r;for(e=1;e<=d;e++)n.push(0,y*w,0),l.push(0,w,0),u.push(.5,.5),r++;var C=
17581 r;for(e=0;e<=d;e++){var D=e/d*h+g,H=Math.cos(D);D=Math.sin(D);k.x=v*D;k.y=y*w;k.z=v*H;n.push(k.x,k.y,k.z);l.push(0,w,0);f.x=.5*H+.5;f.y=.5*D*w+.5;u.push(f.x,f.y);r++}for(e=0;e<d;e++)f=A+e,k=C+e,!0===c?q.push(k,k+1,f):q.push(k+1,k,f),t+=3;m.addGroup(x,t,!0===c?1:2);x+=t}C.call(this);this.type="CylinderBufferGeometry";this.parameters={radiusTop:a,radiusBottom:b,height:c,radialSegments:d,heightSegments:e,openEnded:f,thetaStart:g,thetaLength:h};var m=this;a=void 0!==a?a:1;b=void 0!==b?b:1;c=c||1;d=Math.floor(d)||
17582 8;e=Math.floor(e)||1;f=void 0!==f?f:!1;g=void 0!==g?g:0;h=void 0!==h?h:2*Math.PI;var q=[],n=[],l=[],u=[],r=0,v=[],y=c/2,x=0;(function(){var f,k,t=new p,P=new p,N=0,z=(b-a)/c;for(k=0;k<=e;k++){var A=[],D=k/e,C=D*(b-a)+a;for(f=0;f<=d;f++){var H=f/d,G=H*h+g,K=Math.sin(G);G=Math.cos(G);P.x=C*K;P.y=-D*c+y;P.z=C*G;n.push(P.x,P.y,P.z);t.set(K,z,G).normalize();l.push(t.x,t.y,t.z);u.push(H,1-D);A.push(r++)}v.push(A)}for(f=0;f<d;f++)for(k=0;k<e;k++)t=v[k+1][f],P=v[k+1][f+1],z=v[k][f+1],q.push(v[k][f],t,z),
17583 q.push(t,P,z),N+=6;m.addGroup(x,N,0);x+=N})();!1===f&&(0<a&&k(!0),0<b&&k(!1));this.setIndex(q);this.addAttribute("position",new A(n,3));this.addAttribute("normal",new A(l,3));this.addAttribute("uv",new A(u,2))}function Wc(a,b,c,d,e,f,g){vb.call(this,0,a,b,c,d,e,f,g);this.type="ConeGeometry";this.parameters={radius:a,height:b,radialSegments:c,heightSegments:d,openEnded:e,thetaStart:f,thetaLength:g}}function Xc(a,b,c,d,e,f,g){Wa.call(this,0,a,b,c,d,e,f,g);this.type="ConeBufferGeometry";this.parameters=
17584 {radius:a,height:b,radialSegments:c,heightSegments:d,openEnded:e,thetaStart:f,thetaLength:g}}function Yc(a,b,c,d){R.call(this);this.type="CircleGeometry";this.parameters={radius:a,segments:b,thetaStart:c,thetaLength:d};this.fromBufferGeometry(new bc(a,b,c,d));this.mergeVertices()}function bc(a,b,c,d){C.call(this);this.type="CircleBufferGeometry";this.parameters={radius:a,segments:b,thetaStart:c,thetaLength:d};a=a||1;b=void 0!==b?Math.max(3,b):8;c=void 0!==c?c:0;d=void 0!==d?d:2*Math.PI;var e=[],f=
17585 [],g=[],h=[],k,m=new p,q=new z;f.push(0,0,0);g.push(0,0,1);h.push(.5,.5);var n=0;for(k=3;n<=b;n++,k+=3){var l=c+n/b*d;m.x=a*Math.cos(l);m.y=a*Math.sin(l);f.push(m.x,m.y,m.z);g.push(0,0,1);q.x=(f[k]/a+1)/2;q.y=(f[k+1]/a+1)/2;h.push(q.x,q.y)}for(k=1;k<=b;k++)e.push(k,k+1,0);this.setIndex(e);this.addAttribute("position",new A(f,3));this.addAttribute("normal",new A(g,3));this.addAttribute("uv",new A(h,2))}function wb(a){J.call(this);this.type="ShadowMaterial";this.color=new G(0);this.transparent=!0;this.setValues(a)}
17586 function cc(a){ta.call(this,a);this.type="RawShaderMaterial"}function Pa(a){J.call(this);this.defines={STANDARD:""};this.type="MeshStandardMaterial";this.color=new G(16777215);this.metalness=this.roughness=.5;this.lightMap=this.map=null;this.lightMapIntensity=1;this.aoMap=null;this.aoMapIntensity=1;this.emissive=new G(0);this.emissiveIntensity=1;this.bumpMap=this.emissiveMap=null;this.bumpScale=1;this.normalMap=null;this.normalMapType=0;this.normalScale=new z(1,1);this.displacementMap=null;this.displacementScale=
17587 1;this.displacementBias=0;this.envMap=this.alphaMap=this.metalnessMap=this.roughnessMap=null;this.envMapIntensity=1;this.refractionRatio=.98;this.wireframe=!1;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.morphNormals=this.morphTargets=this.skinning=!1;this.setValues(a)}function xb(a){Pa.call(this);this.defines={PHYSICAL:""};this.type="MeshPhysicalMaterial";this.reflectivity=.5;this.clearCoatRoughness=this.clearCoat=0;this.setValues(a)}function Fa(a){J.call(this);
17588 this.type="MeshPhongMaterial";this.color=new G(16777215);this.specular=new G(1118481);this.shininess=30;this.lightMap=this.map=null;this.lightMapIntensity=1;this.aoMap=null;this.aoMapIntensity=1;this.emissive=new G(0);this.emissiveIntensity=1;this.bumpMap=this.emissiveMap=null;this.bumpScale=1;this.normalMap=null;this.normalMapType=0;this.normalScale=new z(1,1);this.displacementMap=null;this.displacementScale=1;this.displacementBias=0;this.envMap=this.alphaMap=this.specularMap=null;this.combine=0;
17589 this.reflectivity=1;this.refractionRatio=.98;this.wireframe=!1;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.morphNormals=this.morphTargets=this.skinning=!1;this.setValues(a)}function yb(a){Fa.call(this);this.defines={TOON:""};this.type="MeshToonMaterial";this.gradientMap=null;this.setValues(a)}function zb(a){J.call(this);this.type="MeshNormalMaterial";this.bumpMap=null;this.bumpScale=1;this.normalMap=null;this.normalMapType=0;this.normalScale=new z(1,1);this.displacementMap=
17590 null;this.displacementScale=1;this.displacementBias=0;this.wireframe=!1;this.wireframeLinewidth=1;this.morphNormals=this.morphTargets=this.skinning=this.lights=this.fog=!1;this.setValues(a)}function Ab(a){J.call(this);this.type="MeshLambertMaterial";this.color=new G(16777215);this.lightMap=this.map=null;this.lightMapIntensity=1;this.aoMap=null;this.aoMapIntensity=1;this.emissive=new G(0);this.emissiveIntensity=1;this.envMap=this.alphaMap=this.specularMap=this.emissiveMap=null;this.combine=0;this.reflectivity=
17591 1;this.refractionRatio=.98;this.wireframe=!1;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.morphNormals=this.morphTargets=this.skinning=!1;this.setValues(a)}function Bb(a){Y.call(this);this.type="LineDashedMaterial";this.scale=1;this.dashSize=3;this.gapSize=1;this.setValues(a)}function ce(a,b,c){var d=this,e=!1,f=0,g=0,h=void 0;this.onStart=void 0;this.onLoad=a;this.onProgress=b;this.onError=c;this.itemStart=function(a){g++;if(!1===e&&void 0!==d.onStart)d.onStart(a,
17592 f,g);e=!0};this.itemEnd=function(a){f++;if(void 0!==d.onProgress)d.onProgress(a,f,g);if(f===g&&(e=!1,void 0!==d.onLoad))d.onLoad()};this.itemError=function(a){if(void 0!==d.onError)d.onError(a)};this.resolveURL=function(a){return h?h(a):a};this.setURLModifier=function(a){h=a;return this}}function Ga(a){this.manager=void 0!==a?a:ka}function kf(a){this.manager=void 0!==a?a:ka;this._parser=null}function de(a){this.manager=void 0!==a?a:ka;this._parser=null}function Zc(a){this.manager=void 0!==a?a:ka}
17593 function ee(a){this.manager=void 0!==a?a:ka}function vd(a){this.manager=void 0!==a?a:ka}function L(){this.type="Curve";this.arcLengthDivisions=200}function za(a,b,c,d,e,f,g,h){L.call(this);this.type="EllipseCurve";this.aX=a||0;this.aY=b||0;this.xRadius=c||1;this.yRadius=d||1;this.aStartAngle=e||0;this.aEndAngle=f||2*Math.PI;this.aClockwise=g||!1;this.aRotation=h||0}function dc(a,b,c,d,e,f){za.call(this,a,b,c,c,d,e,f);this.type="ArcCurve"}function fe(){var a=0,b=0,c=0,d=0;return{initCatmullRom:function(e,
17594 f,g,h,k){e=k*(g-e);h=k*(h-f);a=f;b=e;c=-3*f+3*g-2*e-h;d=2*f-2*g+e+h},initNonuniformCatmullRom:function(e,f,g,h,k,m,q){e=((f-e)/k-(g-e)/(k+m)+(g-f)/m)*m;h=((g-f)/m-(h-f)/(m+q)+(h-g)/q)*m;a=f;b=e;c=-3*f+3*g-2*e-h;d=2*f-2*g+e+h},calc:function(e){var f=e*e;return a+b*e+c*f+d*f*e}}}function ca(a,b,c,d){L.call(this);this.type="CatmullRomCurve3";this.points=a||[];this.closed=b||!1;this.curveType=c||"centripetal";this.tension=d||.5}function lf(a,b,c,d,e){b=.5*(d-b);e=.5*(e-c);var f=a*a;return(2*c-2*d+b+e)*
17595 a*f+(-3*c+3*d-2*b-e)*f+b*a+c}function $c(a,b,c,d){var e=1-a;return e*e*b+2*(1-a)*a*c+a*a*d}function ad(a,b,c,d,e){var f=1-a,g=1-a;return f*f*f*b+3*g*g*a*c+3*(1-a)*a*a*d+a*a*a*e}function Ha(a,b,c,d){L.call(this);this.type="CubicBezierCurve";this.v0=a||new z;this.v1=b||new z;this.v2=c||new z;this.v3=d||new z}function Qa(a,b,c,d){L.call(this);this.type="CubicBezierCurve3";this.v0=a||new p;this.v1=b||new p;this.v2=c||new p;this.v3=d||new p}function va(a,b){L.call(this);this.type="LineCurve";this.v1=a||
17596 new z;this.v2=b||new z}function Ia(a,b){L.call(this);this.type="LineCurve3";this.v1=a||new p;this.v2=b||new p}function Ja(a,b,c){L.call(this);this.type="QuadraticBezierCurve";this.v0=a||new z;this.v1=b||new z;this.v2=c||new z}function Ra(a,b,c){L.call(this);this.type="QuadraticBezierCurve3";this.v0=a||new p;this.v1=b||new p;this.v2=c||new p}function Ka(a){L.call(this);this.type="SplineCurve";this.points=a||[]}function Xa(){L.call(this);this.type="CurvePath";this.curves=[];this.autoClose=!1}function La(a){Xa.call(this);
17597 this.type="Path";this.currentPoint=new z;a&&this.setFromPoints(a)}function db(a){La.call(this,a);this.uuid=H.generateUUID();this.type="Shape";this.holes=[]}function X(a,b){D.call(this);this.type="Light";this.color=new G(a);this.intensity=void 0!==b?b:1;this.receiveShadow=void 0}function wd(a,b,c){X.call(this,a,c);this.type="HemisphereLight";this.castShadow=void 0;this.position.copy(D.DefaultUp);this.updateMatrix();this.groundColor=new G(b)}function Cb(a){this.camera=a;this.bias=0;this.radius=1;this.mapSize=
17598 new z(512,512);this.map=null;this.matrix=new I}function xd(){Cb.call(this,new Z(50,1,.5,500))}function yd(a,b,c,d,e,f){X.call(this,a,b);this.type="SpotLight";this.position.copy(D.DefaultUp);this.updateMatrix();this.target=new D;Object.defineProperty(this,"power",{get:function(){return this.intensity*Math.PI},set:function(a){this.intensity=a/Math.PI}});this.distance=void 0!==c?c:0;this.angle=void 0!==d?d:Math.PI/3;this.penumbra=void 0!==e?e:0;this.decay=void 0!==f?f:1;this.shadow=new xd}function zd(a,
17599 b,c,d){X.call(this,a,b);this.type="PointLight";Object.defineProperty(this,"power",{get:function(){return 4*this.intensity*Math.PI},set:function(a){this.intensity=a/(4*Math.PI)}});this.distance=void 0!==c?c:0;this.decay=void 0!==d?d:1;this.shadow=new Cb(new Z(90,1,.5,500))}function Ad(){Cb.call(this,new Hb(-5,5,5,-5,.5,500))}function Bd(a,b){X.call(this,a,b);this.type="DirectionalLight";this.position.copy(D.DefaultUp);this.updateMatrix();this.target=new D;this.shadow=new Ad}function Cd(a,b){X.call(this,
17600 a,b);this.type="AmbientLight";this.castShadow=void 0}function Dd(a,b,c,d){X.call(this,a,b);this.type="RectAreaLight";this.width=void 0!==c?c:10;this.height=void 0!==d?d:10}function wa(a,b,c,d){this.parameterPositions=a;this._cachedIndex=0;this.resultBuffer=void 0!==d?d:new b.constructor(c);this.sampleValues=b;this.valueSize=c}function Ed(a,b,c,d){wa.call(this,a,b,c,d);this._offsetNext=this._weightNext=this._offsetPrev=this._weightPrev=-0}function bd(a,b,c,d){wa.call(this,a,b,c,d)}function Fd(a,b,
17601 c,d){wa.call(this,a,b,c,d)}function oa(a,b,c,d){if(void 0===a)throw Error("THREE.KeyframeTrack: track name is undefined");if(void 0===b||0===b.length)throw Error("THREE.KeyframeTrack: no keyframes in track named "+a);this.name=a;this.times=ia.convertArray(b,this.TimeBufferType);this.values=ia.convertArray(c,this.ValueBufferType);this.setInterpolation(d||this.DefaultInterpolation)}function Gd(a,b,c){oa.call(this,a,b,c)}function Hd(a,b,c,d){oa.call(this,a,b,c,d)}function ec(a,b,c,d){oa.call(this,a,
17602 b,c,d)}function Id(a,b,c,d){wa.call(this,a,b,c,d)}function cd(a,b,c,d){oa.call(this,a,b,c,d)}function Jd(a,b,c,d){oa.call(this,a,b,c,d)}function fc(a,b,c,d){oa.call(this,a,b,c,d)}function Ca(a,b,c){this.name=a;this.tracks=c;this.duration=void 0!==b?b:-1;this.uuid=H.generateUUID();0>this.duration&&this.resetDuration()}function Rg(a){switch(a.toLowerCase()){case "scalar":case "double":case "float":case "number":case "integer":return ec;case "vector":case "vector2":case "vector3":case "vector4":return fc;
17603 case "color":return Hd;case "quaternion":return cd;case "bool":case "boolean":return Gd;case "string":return Jd}throw Error("THREE.KeyframeTrack: Unsupported typeName: "+a);}function Sg(a){if(void 0===a.type)throw Error("THREE.KeyframeTrack: track type undefined, can not parse");var b=Rg(a.type);if(void 0===a.times){var c=[],d=[];ia.flattenJSON(a.keys,c,d,"value");a.times=c;a.values=d}return void 0!==b.parse?b.parse(a):new b(a.name,a.times,a.values,a.interpolation)}function Kd(a){this.manager=void 0!==
17604 a?a:ka;this.textures={}}function ge(a){this.manager=void 0!==a?a:ka}function gc(){}function he(a){"boolean"===typeof a&&(console.warn("THREE.JSONLoader: showStatus parameter has been removed from constructor."),a=void 0);this.manager=void 0!==a?a:ka;this.withCredentials=!1}function mf(a){this.manager=void 0!==a?a:ka;this.texturePath=""}function ie(a){"undefined"===typeof createImageBitmap&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported.");"undefined"===typeof fetch&&console.warn("THREE.ImageBitmapLoader: fetch() not supported.");
17605 this.manager=void 0!==a?a:ka;this.options=void 0}function je(){this.type="ShapePath";this.color=new G;this.subPaths=[];this.currentPath=null}function ke(a){this.type="Font";this.data=a}function nf(a){this.manager=void 0!==a?a:ka}function le(a){this.manager=void 0!==a?a:ka}function of(){this.type="StereoCamera";this.aspect=1;this.eyeSep=.064;this.cameraL=new Z;this.cameraL.layers.enable(1);this.cameraL.matrixAutoUpdate=!1;this.cameraR=new Z;this.cameraR.layers.enable(2);this.cameraR.matrixAutoUpdate=
17606 !1}function dd(a,b,c){D.call(this);this.type="CubeCamera";var d=new Z(90,1,a,b);d.up.set(0,-1,0);d.lookAt(new p(1,0,0));this.add(d);var e=new Z(90,1,a,b);e.up.set(0,-1,0);e.lookAt(new p(-1,0,0));this.add(e);var f=new Z(90,1,a,b);f.up.set(0,0,1);f.lookAt(new p(0,1,0));this.add(f);var g=new Z(90,1,a,b);g.up.set(0,0,-1);g.lookAt(new p(0,-1,0));this.add(g);var h=new Z(90,1,a,b);h.up.set(0,-1,0);h.lookAt(new p(0,0,1));this.add(h);var k=new Z(90,1,a,b);k.up.set(0,-1,0);k.lookAt(new p(0,0,-1));this.add(k);
17607 this.renderTarget=new Gb(c,c,{format:1022,magFilter:1006,minFilter:1006});this.renderTarget.texture.name="CubeCamera";this.update=function(a,b){null===this.parent&&this.updateMatrixWorld();var c=this.renderTarget,m=c.texture.generateMipmaps;c.texture.generateMipmaps=!1;c.activeCubeFace=0;a.render(b,d,c);c.activeCubeFace=1;a.render(b,e,c);c.activeCubeFace=2;a.render(b,f,c);c.activeCubeFace=3;a.render(b,g,c);c.activeCubeFace=4;a.render(b,h,c);c.texture.generateMipmaps=m;c.activeCubeFace=5;a.render(b,
17608 k,c);a.setRenderTarget(null)};this.clear=function(a,b,c,d){for(var e=this.renderTarget,f=0;6>f;f++)e.activeCubeFace=f,a.setRenderTarget(e),a.clear(b,c,d);a.setRenderTarget(null)}}function me(){D.call(this);this.type="AudioListener";this.context=ne.getContext();this.gain=this.context.createGain();this.gain.connect(this.context.destination);this.filter=null}function hc(a){D.call(this);this.type="Audio";this.context=a.context;this.gain=this.context.createGain();this.gain.connect(a.getInput());this.autoplay=
17609 !1;this.buffer=null;this.loop=!1;this.offset=this.startTime=0;this.playbackRate=1;this.isPlaying=!1;this.hasPlaybackControl=!0;this.sourceType="empty";this.filters=[]}function oe(a){hc.call(this,a);this.panner=this.context.createPanner();this.panner.connect(this.gain)}function pe(a,b){this.analyser=a.context.createAnalyser();this.analyser.fftSize=void 0!==b?b:2048;this.data=new Uint8Array(this.analyser.frequencyBinCount);a.getOutput().connect(this.analyser)}function qe(a,b,c){this.binding=a;this.valueSize=
17610 c;a=Float64Array;switch(b){case "quaternion":b=this._slerp;break;case "string":case "bool":a=Array;b=this._select;break;default:b=this._lerp}this.buffer=new a(4*c);this._mixBufferRegion=b;this.referenceCount=this.useCount=this.cumulativeWeight=0}function pf(a,b,c){c=c||pa.parseTrackName(b);this._targetGroup=a;this._bindings=a.subscribe_(b,c)}function pa(a,b,c){this.path=b;this.parsedPath=c||pa.parseTrackName(b);this.node=pa.findNode(a,this.parsedPath.nodeName)||a;this.rootNode=a}function qf(){this.uuid=
17611 H.generateUUID();this._objects=Array.prototype.slice.call(arguments);this.nCachedObjects_=0;var a={};this._indicesByUUID=a;for(var b=0,c=arguments.length;b!==c;++b)a[arguments[b].uuid]=b;this._paths=[];this._parsedPaths=[];this._bindings=[];this._bindingsIndicesByPath={};var d=this;this.stats={objects:{get total(){return d._objects.length},get inUse(){return this.total-d.nCachedObjects_}},get bindingsPerObject(){return d._bindings.length}}}function rf(a,b,c){this._mixer=a;this._clip=b;this._localRoot=
17612 c||null;a=b.tracks;b=a.length;c=Array(b);for(var d={endingStart:2400,endingEnd:2400},e=0;e!==b;++e){var f=a[e].createInterpolant(null);c[e]=f;f.settings=d}this._interpolantSettings=d;this._interpolants=c;this._propertyBindings=Array(b);this._weightInterpolant=this._timeScaleInterpolant=this._byClipCacheIndex=this._cacheIndex=null;this.loop=2201;this._loopCount=-1;this._startTime=null;this.time=0;this._effectiveWeight=this.weight=this._effectiveTimeScale=this.timeScale=1;this.repetitions=Infinity;
17613 this.paused=!1;this.enabled=!0;this.clampWhenFinished=!1;this.zeroSlopeAtEnd=this.zeroSlopeAtStart=!0}function re(a){this._root=a;this._initMemoryManager();this.time=this._accuIndex=0;this.timeScale=1}function Ld(a,b){"string"===typeof a&&(console.warn("THREE.Uniform: Type parameter is no longer needed."),a=b);this.value=a}function se(){C.call(this);this.type="InstancedBufferGeometry";this.maxInstancedCount=void 0}function te(a,b,c){ob.call(this,a,b);this.meshPerAttribute=c||1}function ue(a,b,c){Q.call(this,
17614 a,b);this.meshPerAttribute=c||1}function sf(a,b,c,d){this.ray=new mb(a,b);this.near=c||0;this.far=d||Infinity;this.params={Mesh:{},Line:{},LOD:{},Points:{threshold:1},Sprite:{}};Object.defineProperties(this.params,{PointCloud:{get:function(){console.warn("THREE.Raycaster: params.PointCloud has been renamed to params.Points.");return this.Points}}})}function tf(a,b){return a.distance-b.distance}function ve(a,b,c,d){if(!1!==a.visible&&(a.raycast(b,c),!0===d)){a=a.children;d=0;for(var e=a.length;d<e;d++)ve(a[d],
17615 b,c,!0)}}function uf(a){this.autoStart=void 0!==a?a:!0;this.elapsedTime=this.oldTime=this.startTime=0;this.running=!1}function vf(a,b,c){this.radius=void 0!==a?a:1;this.phi=void 0!==b?b:0;this.theta=void 0!==c?c:0;return this}function wf(a,b,c){this.radius=void 0!==a?a:1;this.theta=void 0!==b?b:0;this.y=void 0!==c?c:0;return this}function we(a,b){this.min=void 0!==a?a:new z(Infinity,Infinity);this.max=void 0!==b?b:new z(-Infinity,-Infinity)}function xe(a,b){this.start=void 0!==a?a:new p;this.end=
17616 void 0!==b?b:new p}function ed(a){D.call(this);this.material=a;this.render=function(){}}function fd(a,b,c,d){this.object=a;this.size=void 0!==b?b:1;a=void 0!==c?c:16711680;d=void 0!==d?d:1;b=0;(c=this.object.geometry)&&c.isGeometry?b=3*c.faces.length:c&&c.isBufferGeometry&&(b=c.attributes.normal.count);c=new C;b=new A(6*b,3);c.addAttribute("position",b);W.call(this,c,new Y({color:a,linewidth:d}));this.matrixAutoUpdate=!1;this.update()}function ic(a,b){D.call(this);this.light=a;this.light.updateMatrixWorld();
17617 this.matrix=a.matrixWorld;this.matrixAutoUpdate=!1;this.color=b;a=new C;b=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(var c=0,d=1;32>c;c++,d++){var e=c/32*Math.PI*2,f=d/32*Math.PI*2;b.push(Math.cos(e),Math.sin(e),1,Math.cos(f),Math.sin(f),1)}a.addAttribute("position",new A(b,3));b=new Y({fog:!1});this.cone=new W(a,b);this.add(this.cone);this.update()}function xf(a){var b=[];a&&a.isBone&&b.push(a);for(var c=0;c<a.children.length;c++)b.push.apply(b,xf(a.children[c]));return b}
17618 function jc(a){for(var b=xf(a),c=new C,d=[],e=[],f=new G(0,0,1),g=new G(0,1,0),h=0;h<b.length;h++){var k=b[h];k.parent&&k.parent.isBone&&(d.push(0,0,0),d.push(0,0,0),e.push(f.r,f.g,f.b),e.push(g.r,g.g,g.b))}c.addAttribute("position",new A(d,3));c.addAttribute("color",new A(e,3));d=new Y({vertexColors:2,depthTest:!1,depthWrite:!1,transparent:!0});W.call(this,c,d);this.root=a;this.bones=b;this.matrix=a.matrixWorld;this.matrixAutoUpdate=!1}function kc(a,b,c){this.light=a;this.light.updateMatrixWorld();
17619 this.color=c;a=new sb(b,4,2);b=new da({wireframe:!0,fog:!1});la.call(this,a,b);this.matrix=this.light.matrixWorld;this.matrixAutoUpdate=!1;this.update()}function lc(a,b){D.call(this);this.light=a;this.light.updateMatrixWorld();this.matrix=a.matrixWorld;this.matrixAutoUpdate=!1;this.color=b;a=new Y({fog:!1});b=new C;b.addAttribute("position",new Q(new Float32Array(15),3));this.line=new sa(b,a);this.add(this.line);this.update()}function mc(a,b,c){D.call(this);this.light=a;this.light.updateMatrixWorld();
17620 this.matrix=a.matrixWorld;this.matrixAutoUpdate=!1;this.color=c;a=new pb(b);a.rotateY(.5*Math.PI);this.material=new da({wireframe:!0,fog:!1});void 0===this.color&&(this.material.vertexColors=2);b=a.getAttribute("position");b=new Float32Array(3*b.count);a.addAttribute("color",new Q(b,3));this.add(new la(a,this.material));this.update()}function gd(a,b,c,d){a=a||10;b=b||10;c=new G(void 0!==c?c:4473924);d=new G(void 0!==d?d:8947848);var e=b/2,f=a/b,g=a/2;a=[];for(var h=[],k=0,m=0,q=-g;k<=b;k++,q+=f){a.push(-g,
17621 0,q,g,0,q);a.push(q,0,-g,q,0,g);var n=k===e?c:d;n.toArray(h,m);m+=3;n.toArray(h,m);m+=3;n.toArray(h,m);m+=3;n.toArray(h,m);m+=3}b=new C;b.addAttribute("position",new A(a,3));b.addAttribute("color",new A(h,3));c=new Y({vertexColors:2});W.call(this,b,c)}function Md(a,b,c,d,e,f){a=a||10;b=b||16;c=c||8;d=d||64;e=new G(void 0!==e?e:4473924);f=new G(void 0!==f?f:8947848);var g=[],h=[],k;for(k=0;k<=b;k++){var m=k/b*2*Math.PI;var q=Math.sin(m)*a;m=Math.cos(m)*a;g.push(0,0,0);g.push(q,0,m);var n=k&1?e:f;h.push(n.r,
17622 n.g,n.b);h.push(n.r,n.g,n.b)}for(k=0;k<=c;k++){n=k&1?e:f;var l=a-a/c*k;for(b=0;b<d;b++)m=b/d*2*Math.PI,q=Math.sin(m)*l,m=Math.cos(m)*l,g.push(q,0,m),h.push(n.r,n.g,n.b),m=(b+1)/d*2*Math.PI,q=Math.sin(m)*l,m=Math.cos(m)*l,g.push(q,0,m),h.push(n.r,n.g,n.b)}a=new C;a.addAttribute("position",new A(g,3));a.addAttribute("color",new A(h,3));g=new Y({vertexColors:2});W.call(this,a,g)}function hd(a,b,c,d){this.object=a;this.size=void 0!==b?b:1;a=void 0!==c?c:16776960;d=void 0!==d?d:1;b=0;(c=this.object.geometry)&&
17623 c.isGeometry?b=c.faces.length:console.warn("THREE.FaceNormalsHelper: only THREE.Geometry is supported. Use THREE.VertexNormalsHelper, instead.");c=new C;b=new A(6*b,3);c.addAttribute("position",b);W.call(this,c,new Y({color:a,linewidth:d}));this.matrixAutoUpdate=!1;this.update()}function nc(a,b,c){D.call(this);this.light=a;this.light.updateMatrixWorld();this.matrix=a.matrixWorld;this.matrixAutoUpdate=!1;this.color=c;void 0===b&&(b=1);a=new C;a.addAttribute("position",new A([-b,b,0,b,b,0,b,-b,0,-b,
17624 -b,0,-b,b,0],3));b=new Y({fog:!1});this.lightPlane=new sa(a,b);this.add(this.lightPlane);a=new C;a.addAttribute("position",new A([0,0,0,0,0,1],3));this.targetLine=new sa(a,b);this.add(this.targetLine);this.update()}function id(a){function b(a,b,d){c(a,d);c(b,d)}function c(a,b){f.push(0,0,0);g.push(b.r,b.g,b.b);void 0===h[a]&&(h[a]=[]);h[a].push(f.length/3-1)}var d=new C,e=new Y({color:16777215,vertexColors:1}),f=[],g=[],h={},k=new G(16755200),m=new G(16711680),q=new G(43775),n=new G(16777215),l=new G(3355443);
17625 b("n1","n2",k);b("n2","n4",k);b("n4","n3",k);b("n3","n1",k);b("f1","f2",k);b("f2","f4",k);b("f4","f3",k);b("f3","f1",k);b("n1","f1",k);b("n2","f2",k);b("n3","f3",k);b("n4","f4",k);b("p","n1",m);b("p","n2",m);b("p","n3",m);b("p","n4",m);b("u1","u2",q);b("u2","u3",q);b("u3","u1",q);b("c","t",n);b("p","c",l);b("cn1","cn2",l);b("cn3","cn4",l);b("cf1","cf2",l);b("cf3","cf4",l);d.addAttribute("position",new A(f,3));d.addAttribute("color",new A(g,3));W.call(this,d,e);this.camera=a;this.camera.updateProjectionMatrix&&
17626 this.camera.updateProjectionMatrix();this.matrix=a.matrixWorld;this.matrixAutoUpdate=!1;this.pointMap=h;this.update()}function Db(a,b){this.object=a;void 0===b&&(b=16776960);a=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]);var c=new Float32Array(24),d=new C;d.setIndex(new Q(a,1));d.addAttribute("position",new Q(c,3));W.call(this,d,new Y({color:b}));this.matrixAutoUpdate=!1;this.update()}function jd(a,b){this.type="Box3Helper";this.box=a;a=void 0!==b?b:16776960;b=new Uint16Array([0,
17627 1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]);var c=new C;c.setIndex(new Q(b,1));c.addAttribute("position",new A([1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],3));W.call(this,c,new Y({color:a}));this.geometry.computeBoundingSphere()}function kd(a,b,c){this.type="PlaneHelper";this.plane=a;this.size=void 0===b?1:b;a=void 0!==c?c:16776960;b=new C;b.addAttribute("position",new A([1,-1,1,-1,1,1,-1,-1,1,1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,0,0,1,0,0,0],3));b.computeBoundingSphere();sa.call(this,
17628 b,new Y({color:a}));b=new C;b.addAttribute("position",new A([1,1,1,-1,1,1,-1,-1,1,1,1,1,-1,-1,1,1,-1,1],3));b.computeBoundingSphere();this.add(new la(b,new da({color:a,opacity:.2,transparent:!0,depthWrite:!1})))}function Eb(a,b,c,d,e,f){D.call(this);void 0===d&&(d=16776960);void 0===c&&(c=1);void 0===e&&(e=.2*c);void 0===f&&(f=.2*e);void 0===Nd&&(Nd=new C,Nd.addAttribute("position",new A([0,0,0,0,1,0],3)),ye=new Wa(0,.5,1,5,1),ye.translate(0,-.5,0));this.position.copy(b);this.line=new sa(Nd,new Y({color:d}));
17629 this.line.matrixAutoUpdate=!1;this.add(this.line);this.cone=new la(ye,new da({color:d}));this.cone.matrixAutoUpdate=!1;this.add(this.cone);this.setDirection(a);this.setLength(c,e,f)}function ld(a){a=a||1;var b=[0,0,0,a,0,0,0,0,0,0,a,0,0,0,0,0,0,a];a=new C;a.addAttribute("position",new A(b,3));a.addAttribute("color",new A([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3));b=new Y({vertexColors:2});W.call(this,a,b)}function yf(a){console.warn("THREE.ClosedSplineCurve3 has been deprecated. Use THREE.CatmullRomCurve3 instead.");
17630 ca.call(this,a);this.type="catmullrom";this.closed=!0}function zf(a){console.warn("THREE.SplineCurve3 has been deprecated. Use THREE.CatmullRomCurve3 instead.");ca.call(this,a);this.type="catmullrom"}function ze(a){console.warn("THREE.Spline has been removed. Use THREE.CatmullRomCurve3 instead.");ca.call(this,a);this.type="catmullrom"}void 0===Number.EPSILON&&(Number.EPSILON=Math.pow(2,-52));void 0===Number.isInteger&&(Number.isInteger=function(a){return"number"===typeof a&&isFinite(a)&&Math.floor(a)===
17631 a});void 0===Math.sign&&(Math.sign=function(a){return 0>a?-1:0<a?1:+a});!1==="name"in Function.prototype&&Object.defineProperty(Function.prototype,"name",{get:function(){return this.toString().match(/^\s*function\s*([^\(\s]*)/)[1]}});void 0===Object.assign&&function(){Object.assign=function(a){if(void 0===a||null===a)throw new TypeError("Cannot convert undefined or null to object");for(var b=Object(a),c=1;c<arguments.length;c++){var d=arguments[c];if(void 0!==d&&null!==d)for(var e in d)Object.prototype.hasOwnProperty.call(d,
17632 e)&&(b[e]=d[e])}return b}}();Object.assign(ya.prototype,{addEventListener:function(a,b){void 0===this._listeners&&(this._listeners={});var c=this._listeners;void 0===c[a]&&(c[a]=[]);-1===c[a].indexOf(b)&&c[a].push(b)},hasEventListener:function(a,b){if(void 0===this._listeners)return!1;var c=this._listeners;return void 0!==c[a]&&-1!==c[a].indexOf(b)},removeEventListener:function(a,b){void 0!==this._listeners&&(a=this._listeners[a],void 0!==a&&(b=a.indexOf(b),-1!==b&&a.splice(b,1)))},dispatchEvent:function(a){if(void 0!==
17633 this._listeners){var b=this._listeners[a.type];if(void 0!==b){a.target=this;b=b.slice(0);for(var c=0,d=b.length;c<d;c++)b[c].call(this,a)}}}});var H={DEG2RAD:Math.PI/180,RAD2DEG:180/Math.PI,generateUUID:function(){for(var a=[],b=0;256>b;b++)a[b]=(16>b?"0":"")+b.toString(16);return function(){var b=4294967295*Math.random()|0,d=4294967295*Math.random()|0,e=4294967295*Math.random()|0,f=4294967295*Math.random()|0;return(a[b&255]+a[b>>8&255]+a[b>>16&255]+a[b>>24&255]+"-"+a[d&255]+a[d>>8&255]+"-"+a[d>>
17634 16&15|64]+a[d>>24&255]+"-"+a[e&63|128]+a[e>>8&255]+"-"+a[e>>16&255]+a[e>>24&255]+a[f&255]+a[f>>8&255]+a[f>>16&255]+a[f>>24&255]).toUpperCase()}}(),clamp:function(a,b,c){return Math.max(b,Math.min(c,a))},euclideanModulo:function(a,b){return(a%b+b)%b},mapLinear:function(a,b,c,d,e){return d+(a-b)*(e-d)/(c-b)},lerp:function(a,b,c){return(1-c)*a+c*b},smoothstep:function(a,b,c){if(a<=b)return 0;if(a>=c)return 1;a=(a-b)/(c-b);return a*a*(3-2*a)},smootherstep:function(a,b,c){if(a<=b)return 0;if(a>=c)return 1;
17635 a=(a-b)/(c-b);return a*a*a*(a*(6*a-15)+10)},randInt:function(a,b){return a+Math.floor(Math.random()*(b-a+1))},randFloat:function(a,b){return a+Math.random()*(b-a)},randFloatSpread:function(a){return a*(.5-Math.random())},degToRad:function(a){return a*H.DEG2RAD},radToDeg:function(a){return a*H.RAD2DEG},isPowerOfTwo:function(a){return 0===(a&a-1)&&0!==a},ceilPowerOfTwo:function(a){return Math.pow(2,Math.ceil(Math.log(a)/Math.LN2))},floorPowerOfTwo:function(a){return Math.pow(2,Math.floor(Math.log(a)/
17636 Math.LN2))}};Object.defineProperties(z.prototype,{width:{get:function(){return this.x},set:function(a){this.x=a}},height:{get:function(){return this.y},set:function(a){this.y=a}}});Object.assign(z.prototype,{isVector2:!0,set:function(a,b){this.x=a;this.y=b;return this},setScalar:function(a){this.y=this.x=a;return this},setX:function(a){this.x=a;return this},setY:function(a){this.y=a;return this},setComponent:function(a,b){switch(a){case 0:this.x=b;break;case 1:this.y=b;break;default:throw Error("index is out of range: "+
17637 a);}return this},getComponent:function(a){switch(a){case 0:return this.x;case 1:return this.y;default:throw Error("index is out of range: "+a);}},clone:function(){return new this.constructor(this.x,this.y)},copy:function(a){this.x=a.x;this.y=a.y;return this},add:function(a,b){if(void 0!==b)return console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(a,b);this.x+=a.x;this.y+=a.y;return this},addScalar:function(a){this.x+=a;this.y+=a;return this},
17638 addVectors:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},addScaledVector:function(a,b){this.x+=a.x*b;this.y+=a.y*b;return this},sub:function(a,b){if(void 0!==b)return console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(a,b);this.x-=a.x;this.y-=a.y;return this},subScalar:function(a){this.x-=a;this.y-=a;return this},subVectors:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;return this},multiply:function(a){this.x*=a.x;this.y*=
17639 a.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},divide:function(a){this.x/=a.x;this.y/=a.y;return this},divideScalar:function(a){return this.multiplyScalar(1/a)},applyMatrix3:function(a){var b=this.x,c=this.y;a=a.elements;this.x=a[0]*b+a[3]*c+a[6];this.y=a[1]*b+a[4]*c+a[7];return this},min:function(a){this.x=Math.min(this.x,a.x);this.y=Math.min(this.y,a.y);return this},max:function(a){this.x=Math.max(this.x,a.x);this.y=Math.max(this.y,a.y);return this},clamp:function(a,
17640 b){this.x=Math.max(a.x,Math.min(b.x,this.x));this.y=Math.max(a.y,Math.min(b.y,this.y));return this},clampScalar:function(){var a=new z,b=new z;return function(c,d){a.set(c,c);b.set(d,d);return this.clamp(a,b)}}(),clampLength:function(a,b){var c=this.length();return this.divideScalar(c||1).multiplyScalar(Math.max(a,Math.min(b,c)))},floor:function(){this.x=Math.floor(this.x);this.y=Math.floor(this.y);return this},ceil:function(){this.x=Math.ceil(this.x);this.y=Math.ceil(this.y);return this},round:function(){this.x=
17641 Math.round(this.x);this.y=Math.round(this.y);return this},roundToZero:function(){this.x=0>this.x?Math.ceil(this.x):Math.floor(this.x);this.y=0>this.y?Math.ceil(this.y):Math.floor(this.y);return this},negate:function(){this.x=-this.x;this.y=-this.y;return this},dot:function(a){return this.x*a.x+this.y*a.y},cross:function(a){return this.x*a.y-this.y*a.x},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},manhattanLength:function(){return Math.abs(this.x)+
17642 Math.abs(this.y)},normalize:function(){return this.divideScalar(this.length()||1)},angle:function(){var a=Math.atan2(this.y,this.x);0>a&&(a+=2*Math.PI);return a},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var b=this.x-a.x;a=this.y-a.y;return b*b+a*a},manhattanDistanceTo:function(a){return Math.abs(this.x-a.x)+Math.abs(this.y-a.y)},setLength:function(a){return this.normalize().multiplyScalar(a)},lerp:function(a,b){this.x+=(a.x-this.x)*b;this.y+=
17643 (a.y-this.y)*b;return this},lerpVectors:function(a,b,c){return this.subVectors(b,a).multiplyScalar(c).add(a)},equals:function(a){return a.x===this.x&&a.y===this.y},fromArray:function(a,b){void 0===b&&(b=0);this.x=a[b];this.y=a[b+1];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this.x;a[b+1]=this.y;return a},fromBufferAttribute:function(a,b,c){void 0!==c&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute().");this.x=a.getX(b);this.y=a.getY(b);
17644 return this},rotateAround:function(a,b){var c=Math.cos(b);b=Math.sin(b);var d=this.x-a.x,e=this.y-a.y;this.x=d*c-e*b+a.x;this.y=d*b+e*c+a.y;return this}});Object.assign(I.prototype,{isMatrix4:!0,set:function(a,b,c,d,e,f,g,h,k,m,q,n,l,u,r,p){var t=this.elements;t[0]=a;t[4]=b;t[8]=c;t[12]=d;t[1]=e;t[5]=f;t[9]=g;t[13]=h;t[2]=k;t[6]=m;t[10]=q;t[14]=n;t[3]=l;t[7]=u;t[11]=r;t[15]=p;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},clone:function(){return(new I).fromArray(this.elements)},
17645 copy:function(a){var b=this.elements;a=a.elements;b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];b[4]=a[4];b[5]=a[5];b[6]=a[6];b[7]=a[7];b[8]=a[8];b[9]=a[9];b[10]=a[10];b[11]=a[11];b[12]=a[12];b[13]=a[13];b[14]=a[14];b[15]=a[15];return this},copyPosition:function(a){var b=this.elements;a=a.elements;b[12]=a[12];b[13]=a[13];b[14]=a[14];return this},extractBasis:function(a,b,c){a.setFromMatrixColumn(this,0);b.setFromMatrixColumn(this,1);c.setFromMatrixColumn(this,2);return this},makeBasis:function(a,b,c){this.set(a.x,
17646 b.x,c.x,0,a.y,b.y,c.y,0,a.z,b.z,c.z,0,0,0,0,1);return this},extractRotation:function(){var a=new p;return function(b){var c=this.elements,d=b.elements,e=1/a.setFromMatrixColumn(b,0).length(),f=1/a.setFromMatrixColumn(b,1).length();b=1/a.setFromMatrixColumn(b,2).length();c[0]=d[0]*e;c[1]=d[1]*e;c[2]=d[2]*e;c[3]=0;c[4]=d[4]*f;c[5]=d[5]*f;c[6]=d[6]*f;c[7]=0;c[8]=d[8]*b;c[9]=d[9]*b;c[10]=d[10]*b;c[11]=0;c[12]=0;c[13]=0;c[14]=0;c[15]=1;return this}}(),makeRotationFromEuler:function(a){a&&a.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");
17647 var b=this.elements,c=a.x,d=a.y,e=a.z,f=Math.cos(c);c=Math.sin(c);var g=Math.cos(d);d=Math.sin(d);var h=Math.cos(e);e=Math.sin(e);if("XYZ"===a.order){a=f*h;var k=f*e,m=c*h,q=c*e;b[0]=g*h;b[4]=-g*e;b[8]=d;b[1]=k+m*d;b[5]=a-q*d;b[9]=-c*g;b[2]=q-a*d;b[6]=m+k*d;b[10]=f*g}else"YXZ"===a.order?(a=g*h,k=g*e,m=d*h,q=d*e,b[0]=a+q*c,b[4]=m*c-k,b[8]=f*d,b[1]=f*e,b[5]=f*h,b[9]=-c,b[2]=k*c-m,b[6]=q+a*c,b[10]=f*g):"ZXY"===a.order?(a=g*h,k=g*e,m=d*h,q=d*e,b[0]=a-q*c,b[4]=-f*e,b[8]=m+k*c,b[1]=k+m*c,b[5]=f*h,b[9]=
17648 q-a*c,b[2]=-f*d,b[6]=c,b[10]=f*g):"ZYX"===a.order?(a=f*h,k=f*e,m=c*h,q=c*e,b[0]=g*h,b[4]=m*d-k,b[8]=a*d+q,b[1]=g*e,b[5]=q*d+a,b[9]=k*d-m,b[2]=-d,b[6]=c*g,b[10]=f*g):"YZX"===a.order?(a=f*g,k=f*d,m=c*g,q=c*d,b[0]=g*h,b[4]=q-a*e,b[8]=m*e+k,b[1]=e,b[5]=f*h,b[9]=-c*h,b[2]=-d*h,b[6]=k*e+m,b[10]=a-q*e):"XZY"===a.order&&(a=f*g,k=f*d,m=c*g,q=c*d,b[0]=g*h,b[4]=-e,b[8]=d*h,b[1]=a*e+q,b[5]=f*h,b[9]=k*e-m,b[2]=m*e-k,b[6]=c*h,b[10]=q*e+a);b[3]=0;b[7]=0;b[11]=0;b[12]=0;b[13]=0;b[14]=0;b[15]=1;return this},makeRotationFromQuaternion:function(){var a=
17649 new p(0,0,0),b=new p(1,1,1);return function(c){return this.compose(a,c,b)}}(),lookAt:function(){var a=new p,b=new p,c=new p;return function(d,e,f){var g=this.elements;c.subVectors(d,e);0===c.lengthSq()&&(c.z=1);c.normalize();a.crossVectors(f,c);0===a.lengthSq()&&(1===Math.abs(f.z)?c.x+=1E-4:c.z+=1E-4,c.normalize(),a.crossVectors(f,c));a.normalize();b.crossVectors(c,a);g[0]=a.x;g[4]=b.x;g[8]=c.x;g[1]=a.y;g[5]=b.y;g[9]=c.y;g[2]=a.z;g[6]=b.z;g[10]=c.z;return this}}(),multiply:function(a,b){return void 0!==
17650 b?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(a,b)):this.multiplyMatrices(this,a)},premultiply:function(a){return this.multiplyMatrices(a,this)},multiplyMatrices:function(a,b){var c=a.elements,d=b.elements;b=this.elements;a=c[0];var e=c[4],f=c[8],g=c[12],h=c[1],k=c[5],m=c[9],q=c[13],n=c[2],l=c[6],u=c[10],r=c[14],p=c[3],y=c[7],x=c[11];c=c[15];var w=d[0],B=d[4],E=d[8],P=d[12],N=d[1],z=d[5],A=d[9],D=d[13],C=d[2],
17651 H=d[6],G=d[10],K=d[14],L=d[3],I=d[7],J=d[11];d=d[15];b[0]=a*w+e*N+f*C+g*L;b[4]=a*B+e*z+f*H+g*I;b[8]=a*E+e*A+f*G+g*J;b[12]=a*P+e*D+f*K+g*d;b[1]=h*w+k*N+m*C+q*L;b[5]=h*B+k*z+m*H+q*I;b[9]=h*E+k*A+m*G+q*J;b[13]=h*P+k*D+m*K+q*d;b[2]=n*w+l*N+u*C+r*L;b[6]=n*B+l*z+u*H+r*I;b[10]=n*E+l*A+u*G+r*J;b[14]=n*P+l*D+u*K+r*d;b[3]=p*w+y*N+x*C+c*L;b[7]=p*B+y*z+x*H+c*I;b[11]=p*E+y*A+x*G+c*J;b[15]=p*P+y*D+x*K+c*d;return this},multiplyScalar:function(a){var b=this.elements;b[0]*=a;b[4]*=a;b[8]*=a;b[12]*=a;b[1]*=a;b[5]*=
17652 a;b[9]*=a;b[13]*=a;b[2]*=a;b[6]*=a;b[10]*=a;b[14]*=a;b[3]*=a;b[7]*=a;b[11]*=a;b[15]*=a;return this},applyToBufferAttribute:function(){var a=new p;return function(b){for(var c=0,d=b.count;c<d;c++)a.x=b.getX(c),a.y=b.getY(c),a.z=b.getZ(c),a.applyMatrix4(this),b.setXYZ(c,a.x,a.y,a.z);return b}}(),determinant:function(){var a=this.elements,b=a[0],c=a[4],d=a[8],e=a[12],f=a[1],g=a[5],h=a[9],k=a[13],m=a[2],q=a[6],n=a[10],l=a[14];return a[3]*(+e*h*q-d*k*q-e*g*n+c*k*n+d*g*l-c*h*l)+a[7]*(+b*h*l-b*k*n+e*f*n-
17653 d*f*l+d*k*m-e*h*m)+a[11]*(+b*k*q-b*g*l-e*f*q+c*f*l+e*g*m-c*k*m)+a[15]*(-d*g*m-b*h*q+b*g*n+d*f*q-c*f*n+c*h*m)},transpose:function(){var a=this.elements;var b=a[1];a[1]=a[4];a[4]=b;b=a[2];a[2]=a[8];a[8]=b;b=a[6];a[6]=a[9];a[9]=b;b=a[3];a[3]=a[12];a[12]=b;b=a[7];a[7]=a[13];a[13]=b;b=a[11];a[11]=a[14];a[14]=b;return this},setPosition:function(a){var b=this.elements;b[12]=a.x;b[13]=a.y;b[14]=a.z;return this},getInverse:function(a,b){var c=this.elements,d=a.elements;a=d[0];var e=d[1],f=d[2],g=d[3],h=d[4],
17654 k=d[5],m=d[6],q=d[7],n=d[8],l=d[9],u=d[10],r=d[11],p=d[12],y=d[13],x=d[14];d=d[15];var w=l*x*q-y*u*q+y*m*r-k*x*r-l*m*d+k*u*d,B=p*u*q-n*x*q-p*m*r+h*x*r+n*m*d-h*u*d,E=n*y*q-p*l*q+p*k*r-h*y*r-n*k*d+h*l*d,z=p*l*m-n*y*m-p*k*u+h*y*u+n*k*x-h*l*x,N=a*w+e*B+f*E+g*z;if(0===N){if(!0===b)throw Error("THREE.Matrix4: .getInverse() can't invert matrix, determinant is 0");console.warn("THREE.Matrix4: .getInverse() can't invert matrix, determinant is 0");return this.identity()}b=1/N;c[0]=w*b;c[1]=(y*u*g-l*x*g-y*f*
17655 r+e*x*r+l*f*d-e*u*d)*b;c[2]=(k*x*g-y*m*g+y*f*q-e*x*q-k*f*d+e*m*d)*b;c[3]=(l*m*g-k*u*g-l*f*q+e*u*q+k*f*r-e*m*r)*b;c[4]=B*b;c[5]=(n*x*g-p*u*g+p*f*r-a*x*r-n*f*d+a*u*d)*b;c[6]=(p*m*g-h*x*g-p*f*q+a*x*q+h*f*d-a*m*d)*b;c[7]=(h*u*g-n*m*g+n*f*q-a*u*q-h*f*r+a*m*r)*b;c[8]=E*b;c[9]=(p*l*g-n*y*g-p*e*r+a*y*r+n*e*d-a*l*d)*b;c[10]=(h*y*g-p*k*g+p*e*q-a*y*q-h*e*d+a*k*d)*b;c[11]=(n*k*g-h*l*g-n*e*q+a*l*q+h*e*r-a*k*r)*b;c[12]=z*b;c[13]=(n*y*f-p*l*f+p*e*u-a*y*u-n*e*x+a*l*x)*b;c[14]=(p*k*f-h*y*f-p*e*m+a*y*m+h*e*x-a*k*x)*
17656 b;c[15]=(h*l*f-n*k*f+n*e*m-a*l*m-h*e*u+a*k*u)*b;return this},scale:function(a){var b=this.elements,c=a.x,d=a.y;a=a.z;b[0]*=c;b[4]*=d;b[8]*=a;b[1]*=c;b[5]*=d;b[9]*=a;b[2]*=c;b[6]*=d;b[10]*=a;b[3]*=c;b[7]*=d;b[11]*=a;return this},getMaxScaleOnAxis:function(){var a=this.elements;return Math.sqrt(Math.max(a[0]*a[0]+a[1]*a[1]+a[2]*a[2],a[4]*a[4]+a[5]*a[5]+a[6]*a[6],a[8]*a[8]+a[9]*a[9]+a[10]*a[10]))},makeTranslation:function(a,b,c){this.set(1,0,0,a,0,1,0,b,0,0,1,c,0,0,0,1);return this},makeRotationX:function(a){var b=
17657 Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,b,-a,0,0,a,b,0,0,0,0,1);return this},makeRotationY:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},makeRotationZ:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0,0,0,1,0,0,0,0,1);return this},makeRotationAxis:function(a,b){var c=Math.cos(b);b=Math.sin(b);var d=1-c,e=a.x,f=a.y;a=a.z;var g=d*e,h=d*f;this.set(g*e+c,g*f-b*a,g*a+b*f,0,g*f+b*a,h*f+c,h*a-b*e,0,g*a-b*f,h*a+b*e,d*a*a+c,0,0,
17658 0,0,1);return this},makeScale:function(a,b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},makeShear:function(a,b,c){this.set(1,b,c,0,a,1,c,0,a,b,1,0,0,0,0,1);return this},compose:function(a,b,c){var d=this.elements,e=b._x,f=b._y,g=b._z,h=b._w,k=e+e,m=f+f,q=g+g;b=e*k;var l=e*m;e*=q;var t=f*m;f*=q;g*=q;k*=h;m*=h;h*=q;q=c.x;var u=c.y;c=c.z;d[0]=(1-(t+g))*q;d[1]=(l+h)*q;d[2]=(e-m)*q;d[3]=0;d[4]=(l-h)*u;d[5]=(1-(b+g))*u;d[6]=(f+k)*u;d[7]=0;d[8]=(e+m)*c;d[9]=(f-k)*c;d[10]=(1-(b+t))*c;d[11]=0;
17659 d[12]=a.x;d[13]=a.y;d[14]=a.z;d[15]=1;return this},decompose:function(){var a=new p,b=new I;return function(c,d,e){var f=this.elements,g=a.set(f[0],f[1],f[2]).length(),h=a.set(f[4],f[5],f[6]).length(),k=a.set(f[8],f[9],f[10]).length();0>this.determinant()&&(g=-g);c.x=f[12];c.y=f[13];c.z=f[14];b.copy(this);c=1/g;f=1/h;var m=1/k;b.elements[0]*=c;b.elements[1]*=c;b.elements[2]*=c;b.elements[4]*=f;b.elements[5]*=f;b.elements[6]*=f;b.elements[8]*=m;b.elements[9]*=m;b.elements[10]*=m;d.setFromRotationMatrix(b);
17660 e.x=g;e.y=h;e.z=k;return this}}(),makePerspective:function(a,b,c,d,e,f){void 0===f&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");var g=this.elements;g[0]=2*e/(b-a);g[4]=0;g[8]=(b+a)/(b-a);g[12]=0;g[1]=0;g[5]=2*e/(c-d);g[9]=(c+d)/(c-d);g[13]=0;g[2]=0;g[6]=0;g[10]=-(f+e)/(f-e);g[14]=-2*f*e/(f-e);g[3]=0;g[7]=0;g[11]=-1;g[15]=0;return this},makeOrthographic:function(a,b,c,d,e,f){var g=this.elements,h=1/(b-a),k=1/(c-d),m=1/(f-e);g[0]=
17661 2*h;g[4]=0;g[8]=0;g[12]=-((b+a)*h);g[1]=0;g[5]=2*k;g[9]=0;g[13]=-((c+d)*k);g[2]=0;g[6]=0;g[10]=-2*m;g[14]=-((f+e)*m);g[3]=0;g[7]=0;g[11]=0;g[15]=1;return this},equals:function(a){var b=this.elements;a=a.elements;for(var c=0;16>c;c++)if(b[c]!==a[c])return!1;return!0},fromArray:function(a,b){void 0===b&&(b=0);for(var c=0;16>c;c++)this.elements[c]=a[c+b];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);var c=this.elements;a[b]=c[0];a[b+1]=c[1];a[b+2]=c[2];a[b+3]=c[3];a[b+4]=c[4];
17662 a[b+5]=c[5];a[b+6]=c[6];a[b+7]=c[7];a[b+8]=c[8];a[b+9]=c[9];a[b+10]=c[10];a[b+11]=c[11];a[b+12]=c[12];a[b+13]=c[13];a[b+14]=c[14];a[b+15]=c[15];return a}});Object.assign(fa,{slerp:function(a,b,c,d){return c.copy(a).slerp(b,d)},slerpFlat:function(a,b,c,d,e,f,g){var h=c[d+0],k=c[d+1],m=c[d+2];c=c[d+3];d=e[f+0];var q=e[f+1],l=e[f+2];e=e[f+3];if(c!==e||h!==d||k!==q||m!==l){f=1-g;var t=h*d+k*q+m*l+c*e,u=0<=t?1:-1,r=1-t*t;r>Number.EPSILON&&(r=Math.sqrt(r),t=Math.atan2(r,t*u),f=Math.sin(f*t)/r,g=Math.sin(g*
17663 t)/r);u*=g;h=h*f+d*u;k=k*f+q*u;m=m*f+l*u;c=c*f+e*u;f===1-g&&(g=1/Math.sqrt(h*h+k*k+m*m+c*c),h*=g,k*=g,m*=g,c*=g)}a[b]=h;a[b+1]=k;a[b+2]=m;a[b+3]=c}});Object.defineProperties(fa.prototype,{x:{get:function(){return this._x},set:function(a){this._x=a;this.onChangeCallback()}},y:{get:function(){return this._y},set:function(a){this._y=a;this.onChangeCallback()}},z:{get:function(){return this._z},set:function(a){this._z=a;this.onChangeCallback()}},w:{get:function(){return this._w},set:function(a){this._w=
17664 a;this.onChangeCallback()}}});Object.assign(fa.prototype,{set:function(a,b,c,d){this._x=a;this._y=b;this._z=c;this._w=d;this.onChangeCallback();return this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._w)},copy:function(a){this._x=a.x;this._y=a.y;this._z=a.z;this._w=a.w;this.onChangeCallback();return this},setFromEuler:function(a,b){if(!a||!a.isEuler)throw Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");var c=
17665 a._x,d=a._y,e=a._z;a=a.order;var f=Math.cos,g=Math.sin,h=f(c/2),k=f(d/2);f=f(e/2);c=g(c/2);d=g(d/2);e=g(e/2);"XYZ"===a?(this._x=c*k*f+h*d*e,this._y=h*d*f-c*k*e,this._z=h*k*e+c*d*f,this._w=h*k*f-c*d*e):"YXZ"===a?(this._x=c*k*f+h*d*e,this._y=h*d*f-c*k*e,this._z=h*k*e-c*d*f,this._w=h*k*f+c*d*e):"ZXY"===a?(this._x=c*k*f-h*d*e,this._y=h*d*f+c*k*e,this._z=h*k*e+c*d*f,this._w=h*k*f-c*d*e):"ZYX"===a?(this._x=c*k*f-h*d*e,this._y=h*d*f+c*k*e,this._z=h*k*e-c*d*f,this._w=h*k*f+c*d*e):"YZX"===a?(this._x=c*k*f+
17666 h*d*e,this._y=h*d*f+c*k*e,this._z=h*k*e-c*d*f,this._w=h*k*f-c*d*e):"XZY"===a&&(this._x=c*k*f-h*d*e,this._y=h*d*f-c*k*e,this._z=h*k*e+c*d*f,this._w=h*k*f+c*d*e);if(!1!==b)this.onChangeCallback();return this},setFromAxisAngle:function(a,b){b/=2;var c=Math.sin(b);this._x=a.x*c;this._y=a.y*c;this._z=a.z*c;this._w=Math.cos(b);this.onChangeCallback();return this},setFromRotationMatrix:function(a){var b=a.elements,c=b[0];a=b[4];var d=b[8],e=b[1],f=b[5],g=b[9],h=b[2],k=b[6];b=b[10];var m=c+f+b;0<m?(c=.5/
17667 Math.sqrt(m+1),this._w=.25/c,this._x=(k-g)*c,this._y=(d-h)*c,this._z=(e-a)*c):c>f&&c>b?(c=2*Math.sqrt(1+c-f-b),this._w=(k-g)/c,this._x=.25*c,this._y=(a+e)/c,this._z=(d+h)/c):f>b?(c=2*Math.sqrt(1+f-c-b),this._w=(d-h)/c,this._x=(a+e)/c,this._y=.25*c,this._z=(g+k)/c):(c=2*Math.sqrt(1+b-c-f),this._w=(e-a)/c,this._x=(d+h)/c,this._y=(g+k)/c,this._z=.25*c);this.onChangeCallback();return this},setFromUnitVectors:function(){var a=new p,b;return function(c,d){void 0===a&&(a=new p);b=c.dot(d)+1;1E-6>b?(b=0,
17668 Math.abs(c.x)>Math.abs(c.z)?a.set(-c.y,c.x,0):a.set(0,-c.z,c.y)):a.crossVectors(c,d);this._x=a.x;this._y=a.y;this._z=a.z;this._w=b;return this.normalize()}}(),angleTo:function(a){return 2*Math.acos(Math.abs(H.clamp(this.dot(a),-1,1)))},rotateTowards:function(a,b){var c=this.angleTo(a);if(0===c)return this;this.slerp(a,Math.min(1,b/c));return this},inverse:function(){return this.conjugate()},conjugate:function(){this._x*=-1;this._y*=-1;this._z*=-1;this.onChangeCallback();return this},dot:function(a){return this._x*
17669 a._x+this._y*a._y+this._z*a._z+this._w*a._w},lengthSq:function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},length:function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},normalize:function(){var a=this.length();0===a?(this._z=this._y=this._x=0,this._w=1):(a=1/a,this._x*=a,this._y*=a,this._z*=a,this._w*=a);this.onChangeCallback();return this},multiply:function(a,b){return void 0!==b?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),
17670 this.multiplyQuaternions(a,b)):this.multiplyQuaternions(this,a)},premultiply:function(a){return this.multiplyQuaternions(a,this)},multiplyQuaternions:function(a,b){var c=a._x,d=a._y,e=a._z;a=a._w;var f=b._x,g=b._y,h=b._z;b=b._w;this._x=c*b+a*f+d*h-e*g;this._y=d*b+a*g+e*f-c*h;this._z=e*b+a*h+c*g-d*f;this._w=a*b-c*f-d*g-e*h;this.onChangeCallback();return this},slerp:function(a,b){if(0===b)return this;if(1===b)return this.copy(a);var c=this._x,d=this._y,e=this._z,f=this._w,g=f*a._w+c*a._x+d*a._y+e*a._z;
17671 0>g?(this._w=-a._w,this._x=-a._x,this._y=-a._y,this._z=-a._z,g=-g):this.copy(a);if(1<=g)return this._w=f,this._x=c,this._y=d,this._z=e,this;a=1-g*g;if(a<=Number.EPSILON)return g=1-b,this._w=g*f+b*this._w,this._x=g*c+b*this._x,this._y=g*d+b*this._y,this._z=g*e+b*this._z,this.normalize();a=Math.sqrt(a);var h=Math.atan2(a,g);g=Math.sin((1-b)*h)/a;b=Math.sin(b*h)/a;this._w=f*g+this._w*b;this._x=c*g+this._x*b;this._y=d*g+this._y*b;this._z=e*g+this._z*b;this.onChangeCallback();return this},equals:function(a){return a._x===
17672 this._x&&a._y===this._y&&a._z===this._z&&a._w===this._w},fromArray:function(a,b){void 0===b&&(b=0);this._x=a[b];this._y=a[b+1];this._z=a[b+2];this._w=a[b+3];this.onChangeCallback();return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this._x;a[b+1]=this._y;a[b+2]=this._z;a[b+3]=this._w;return a},onChange:function(a){this.onChangeCallback=a;return this},onChangeCallback:function(){}});Object.assign(p.prototype,{isVector3:!0,set:function(a,b,c){this.x=a;this.y=b;this.z=c;return this},
17673 setScalar:function(a){this.z=this.y=this.x=a;return this},setX:function(a){this.x=a;return this},setY:function(a){this.y=a;return this},setZ:function(a){this.z=a;return this},setComponent:function(a,b){switch(a){case 0:this.x=b;break;case 1:this.y=b;break;case 2:this.z=b;break;default:throw Error("index is out of range: "+a);}return this},getComponent:function(a){switch(a){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error("index is out of range: "+a);}},clone:function(){return new this.constructor(this.x,
17674 this.y,this.z)},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,b){if(void 0!==b)return console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(a,b);this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;return this},addVectors:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;return this},addScaledVector:function(a,b){this.x+=a.x*b;this.y+=a.y*b;this.z+=
17675 a.z*b;return this},sub:function(a,b){if(void 0!==b)return console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(a,b);this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},subScalar:function(a){this.x-=a;this.y-=a;this.z-=a;return this},subVectors:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this},multiply:function(a,b){if(void 0!==b)return console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),
17676 this.multiplyVectors(a,b);this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;return this},multiplyVectors:function(a,b){this.x=a.x*b.x;this.y=a.y*b.y;this.z=a.z*b.z;return this},applyEuler:function(){var a=new fa;return function(b){b&&b.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order.");return this.applyQuaternion(a.setFromEuler(b))}}(),applyAxisAngle:function(){var a=new fa;return function(b,
17677 c){return this.applyQuaternion(a.setFromAxisAngle(b,c))}}(),applyMatrix3:function(a){var b=this.x,c=this.y,d=this.z;a=a.elements;this.x=a[0]*b+a[3]*c+a[6]*d;this.y=a[1]*b+a[4]*c+a[7]*d;this.z=a[2]*b+a[5]*c+a[8]*d;return this},applyMatrix4:function(a){var b=this.x,c=this.y,d=this.z;a=a.elements;var e=1/(a[3]*b+a[7]*c+a[11]*d+a[15]);this.x=(a[0]*b+a[4]*c+a[8]*d+a[12])*e;this.y=(a[1]*b+a[5]*c+a[9]*d+a[13])*e;this.z=(a[2]*b+a[6]*c+a[10]*d+a[14])*e;return this},applyQuaternion:function(a){var b=this.x,
17678 c=this.y,d=this.z,e=a.x,f=a.y,g=a.z;a=a.w;var h=a*b+f*d-g*c,k=a*c+g*b-e*d,m=a*d+e*c-f*b;b=-e*b-f*c-g*d;this.x=h*a+b*-e+k*-g-m*-f;this.y=k*a+b*-f+m*-e-h*-g;this.z=m*a+b*-g+h*-f-k*-e;return this},project:function(){var a=new I;return function(b){a.multiplyMatrices(b.projectionMatrix,a.getInverse(b.matrixWorld));return this.applyMatrix4(a)}}(),unproject:function(){var a=new I;return function(b){a.multiplyMatrices(b.matrixWorld,a.getInverse(b.projectionMatrix));return this.applyMatrix4(a)}}(),transformDirection:function(a){var b=
17679 this.x,c=this.y,d=this.z;a=a.elements;this.x=a[0]*b+a[4]*c+a[8]*d;this.y=a[1]*b+a[5]*c+a[9]*d;this.z=a[2]*b+a[6]*c+a[10]*d;return this.normalize()},divide:function(a){this.x/=a.x;this.y/=a.y;this.z/=a.z;return this},divideScalar:function(a){return this.multiplyScalar(1/a)},min:function(a){this.x=Math.min(this.x,a.x);this.y=Math.min(this.y,a.y);this.z=Math.min(this.z,a.z);return this},max:function(a){this.x=Math.max(this.x,a.x);this.y=Math.max(this.y,a.y);this.z=Math.max(this.z,a.z);return this},clamp:function(a,
17680 b){this.x=Math.max(a.x,Math.min(b.x,this.x));this.y=Math.max(a.y,Math.min(b.y,this.y));this.z=Math.max(a.z,Math.min(b.z,this.z));return this},clampScalar:function(){var a=new p,b=new p;return function(c,d){a.set(c,c,c);b.set(d,d,d);return this.clamp(a,b)}}(),clampLength:function(a,b){var c=this.length();return this.divideScalar(c||1).multiplyScalar(Math.max(a,Math.min(b,c)))},floor:function(){this.x=Math.floor(this.x);this.y=Math.floor(this.y);this.z=Math.floor(this.z);return this},ceil:function(){this.x=
17681 Math.ceil(this.x);this.y=Math.ceil(this.y);this.z=Math.ceil(this.z);return this},round:function(){this.x=Math.round(this.x);this.y=Math.round(this.y);this.z=Math.round(this.z);return this},roundToZero:function(){this.x=0>this.x?Math.ceil(this.x):Math.floor(this.x);this.y=0>this.y?Math.ceil(this.y):Math.floor(this.y);this.z=0>this.z?Math.ceil(this.z):Math.floor(this.z);return this},negate:function(){this.x=-this.x;this.y=-this.y;this.z=-this.z;return this},dot:function(a){return this.x*a.x+this.y*
17682 a.y+this.z*a.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length()||1)},setLength:function(a){return this.normalize().multiplyScalar(a)},lerp:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;return this},lerpVectors:function(a,
17683 b,c){return this.subVectors(b,a).multiplyScalar(c).add(a)},cross:function(a,b){return void 0!==b?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(a,b)):this.crossVectors(this,a)},crossVectors:function(a,b){var c=a.x,d=a.y;a=a.z;var e=b.x,f=b.y;b=b.z;this.x=d*b-a*f;this.y=a*e-c*b;this.z=c*f-d*e;return this},projectOnVector:function(a){var b=a.dot(this)/a.lengthSq();return this.copy(a).multiplyScalar(b)},projectOnPlane:function(){var a=
17684 new p;return function(b){a.copy(this).projectOnVector(b);return this.sub(a)}}(),reflect:function(){var a=new p;return function(b){return this.sub(a.copy(b).multiplyScalar(2*this.dot(b)))}}(),angleTo:function(a){a=this.dot(a)/Math.sqrt(this.lengthSq()*a.lengthSq());return Math.acos(H.clamp(a,-1,1))},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var b=this.x-a.x,c=this.y-a.y;a=this.z-a.z;return b*b+c*c+a*a},manhattanDistanceTo:function(a){return Math.abs(this.x-
17685 a.x)+Math.abs(this.y-a.y)+Math.abs(this.z-a.z)},setFromSpherical:function(a){var b=Math.sin(a.phi)*a.radius;this.x=b*Math.sin(a.theta);this.y=Math.cos(a.phi)*a.radius;this.z=b*Math.cos(a.theta);return this},setFromCylindrical:function(a){this.x=a.radius*Math.sin(a.theta);this.y=a.y;this.z=a.radius*Math.cos(a.theta);return this},setFromMatrixPosition:function(a){a=a.elements;this.x=a[12];this.y=a[13];this.z=a[14];return this},setFromMatrixScale:function(a){var b=this.setFromMatrixColumn(a,0).length(),
17686 c=this.setFromMatrixColumn(a,1).length();a=this.setFromMatrixColumn(a,2).length();this.x=b;this.y=c;this.z=a;return this},setFromMatrixColumn:function(a,b){return this.fromArray(a.elements,4*b)},equals:function(a){return a.x===this.x&&a.y===this.y&&a.z===this.z},fromArray:function(a,b){void 0===b&&(b=0);this.x=a[b];this.y=a[b+1];this.z=a[b+2];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this.x;a[b+1]=this.y;a[b+2]=this.z;return a},fromBufferAttribute:function(a,b,c){void 0!==
17687 c&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute().");this.x=a.getX(b);this.y=a.getY(b);this.z=a.getZ(b);return this}});Object.assign(ra.prototype,{isMatrix3:!0,set:function(a,b,c,d,e,f,g,h,k){var m=this.elements;m[0]=a;m[1]=d;m[2]=g;m[3]=b;m[4]=e;m[5]=h;m[6]=c;m[7]=f;m[8]=k;return this},identity:function(){this.set(1,0,0,0,1,0,0,0,1);return this},clone:function(){return(new this.constructor).fromArray(this.elements)},copy:function(a){var b=this.elements;a=a.elements;
17688 b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];b[4]=a[4];b[5]=a[5];b[6]=a[6];b[7]=a[7];b[8]=a[8];return this},setFromMatrix4:function(a){a=a.elements;this.set(a[0],a[4],a[8],a[1],a[5],a[9],a[2],a[6],a[10]);return this},applyToBufferAttribute:function(){var a=new p;return function(b){for(var c=0,d=b.count;c<d;c++)a.x=b.getX(c),a.y=b.getY(c),a.z=b.getZ(c),a.applyMatrix3(this),b.setXYZ(c,a.x,a.y,a.z);return b}}(),multiply:function(a){return this.multiplyMatrices(this,a)},premultiply:function(a){return this.multiplyMatrices(a,
17689 this)},multiplyMatrices:function(a,b){var c=a.elements,d=b.elements;b=this.elements;a=c[0];var e=c[3],f=c[6],g=c[1],h=c[4],k=c[7],m=c[2],q=c[5];c=c[8];var l=d[0],t=d[3],u=d[6],r=d[1],p=d[4],y=d[7],x=d[2],w=d[5];d=d[8];b[0]=a*l+e*r+f*x;b[3]=a*t+e*p+f*w;b[6]=a*u+e*y+f*d;b[1]=g*l+h*r+k*x;b[4]=g*t+h*p+k*w;b[7]=g*u+h*y+k*d;b[2]=m*l+q*r+c*x;b[5]=m*t+q*p+c*w;b[8]=m*u+q*y+c*d;return this},multiplyScalar:function(a){var b=this.elements;b[0]*=a;b[3]*=a;b[6]*=a;b[1]*=a;b[4]*=a;b[7]*=a;b[2]*=a;b[5]*=a;b[8]*=
17690 a;return this},determinant:function(){var a=this.elements,b=a[0],c=a[1],d=a[2],e=a[3],f=a[4],g=a[5],h=a[6],k=a[7];a=a[8];return b*f*a-b*g*k-c*e*a+c*g*h+d*e*k-d*f*h},getInverse:function(a,b){a&&a.isMatrix4&&console.error("THREE.Matrix3: .getInverse() no longer takes a Matrix4 argument.");var c=a.elements;a=this.elements;var d=c[0],e=c[1],f=c[2],g=c[3],h=c[4],k=c[5],m=c[6],q=c[7];c=c[8];var l=c*h-k*q,t=k*m-c*g,u=q*g-h*m,r=d*l+e*t+f*u;if(0===r){if(!0===b)throw Error("THREE.Matrix3: .getInverse() can't invert matrix, determinant is 0");
17691 console.warn("THREE.Matrix3: .getInverse() can't invert matrix, determinant is 0");return this.identity()}b=1/r;a[0]=l*b;a[1]=(f*q-c*e)*b;a[2]=(k*e-f*h)*b;a[3]=t*b;a[4]=(c*d-f*m)*b;a[5]=(f*g-k*d)*b;a[6]=u*b;a[7]=(e*m-q*d)*b;a[8]=(h*d-e*g)*b;return this},transpose:function(){var a=this.elements;var b=a[1];a[1]=a[3];a[3]=b;b=a[2];a[2]=a[6];a[6]=b;b=a[5];a[5]=a[7];a[7]=b;return this},getNormalMatrix:function(a){return this.setFromMatrix4(a).getInverse(this).transpose()},transposeIntoArray:function(a){var b=
17692 this.elements;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this},setUvTransform:function(a,b,c,d,e,f,g){var h=Math.cos(e);e=Math.sin(e);this.set(c*h,c*e,-c*(h*f+e*g)+f+a,-d*e,d*h,-d*(-e*f+h*g)+g+b,0,0,1)},scale:function(a,b){var c=this.elements;c[0]*=a;c[3]*=a;c[6]*=a;c[1]*=b;c[4]*=b;c[7]*=b;return this},rotate:function(a){var b=Math.cos(a);a=Math.sin(a);var c=this.elements,d=c[0],e=c[3],f=c[6],g=c[1],h=c[4],k=c[7];c[0]=b*d+a*g;c[3]=b*e+a*h;c[6]=
17693 b*f+a*k;c[1]=-a*d+b*g;c[4]=-a*e+b*h;c[7]=-a*f+b*k;return this},translate:function(a,b){var c=this.elements;c[0]+=a*c[2];c[3]+=a*c[5];c[6]+=a*c[8];c[1]+=b*c[2];c[4]+=b*c[5];c[7]+=b*c[8];return this},equals:function(a){var b=this.elements;a=a.elements;for(var c=0;9>c;c++)if(b[c]!==a[c])return!1;return!0},fromArray:function(a,b){void 0===b&&(b=0);for(var c=0;9>c;c++)this.elements[c]=a[c+b];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);var c=this.elements;a[b]=c[0];a[b+1]=c[1];
17694 a[b+2]=c[2];a[b+3]=c[3];a[b+4]=c[4];a[b+5]=c[5];a[b+6]=c[6];a[b+7]=c[7];a[b+8]=c[8];return a}});var eb={getDataURL:function(a){if(a instanceof HTMLCanvasElement)var b=a;else{"undefined"!==typeof OffscreenCanvas?b=new OffscreenCanvas(a.width,a.height):(b=document.createElementNS("http://www.w3.org/1999/xhtml","canvas"),b.width=a.width,b.height=a.height);var c=b.getContext("2d");a instanceof ImageData?c.putImageData(a,0,0):c.drawImage(a,0,0,a.width,a.height)}return 2048<b.width||2048<b.height?b.toDataURL("image/jpeg",
17695 .6):b.toDataURL("image/png")}},Ef=0;T.DEFAULT_IMAGE=void 0;T.DEFAULT_MAPPING=300;T.prototype=Object.assign(Object.create(ya.prototype),{constructor:T,isTexture:!0,updateMatrix:function(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.name=a.name;this.image=a.image;this.mipmaps=a.mipmaps.slice(0);this.mapping=a.mapping;this.wrapS=a.wrapS;this.wrapT=
17696 a.wrapT;this.magFilter=a.magFilter;this.minFilter=a.minFilter;this.anisotropy=a.anisotropy;this.format=a.format;this.type=a.type;this.offset.copy(a.offset);this.repeat.copy(a.repeat);this.center.copy(a.center);this.rotation=a.rotation;this.matrixAutoUpdate=a.matrixAutoUpdate;this.matrix.copy(a.matrix);this.generateMipmaps=a.generateMipmaps;this.premultiplyAlpha=a.premultiplyAlpha;this.flipY=a.flipY;this.unpackAlignment=a.unpackAlignment;this.encoding=a.encoding;return this},toJSON:function(a){var b=
17697 void 0===a||"string"===typeof a;if(!b&&void 0!==a.textures[this.uuid])return a.textures[this.uuid];var c={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,mapping:this.mapping,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY};if(void 0!==
17698 this.image){var d=this.image;void 0===d.uuid&&(d.uuid=H.generateUUID());if(!b&&void 0===a.images[d.uuid]){if(Array.isArray(d)){var e=[];for(var f=0,g=d.length;f<g;f++)e.push(eb.getDataURL(d[f]))}else e=eb.getDataURL(d);a.images[d.uuid]={uuid:d.uuid,url:e}}c.image=d.uuid}b||(a.textures[this.uuid]=c);return c},dispose:function(){this.dispatchEvent({type:"dispose"})},transformUv:function(a){if(300===this.mapping){a.applyMatrix3(this.matrix);if(0>a.x||1<a.x)switch(this.wrapS){case 1E3:a.x-=Math.floor(a.x);
17699 break;case 1001:a.x=0>a.x?0:1;break;case 1002:a.x=1===Math.abs(Math.floor(a.x)%2)?Math.ceil(a.x)-a.x:a.x-Math.floor(a.x)}if(0>a.y||1<a.y)switch(this.wrapT){case 1E3:a.y-=Math.floor(a.y);break;case 1001:a.y=0>a.y?0:1;break;case 1002:a.y=1===Math.abs(Math.floor(a.y)%2)?Math.ceil(a.y)-a.y:a.y-Math.floor(a.y)}this.flipY&&(a.y=1-a.y)}}});Object.defineProperty(T.prototype,"needsUpdate",{set:function(a){!0===a&&this.version++}});Object.assign(V.prototype,{isVector4:!0,set:function(a,b,c,d){this.x=a;this.y=
17700 b;this.z=c;this.w=d;return this},setScalar:function(a){this.w=this.z=this.y=this.x=a;return this},setX:function(a){this.x=a;return this},setY:function(a){this.y=a;return this},setZ:function(a){this.z=a;return this},setW:function(a){this.w=a;return this},setComponent:function(a,b){switch(a){case 0:this.x=b;break;case 1:this.y=b;break;case 2:this.z=b;break;case 3:this.w=b;break;default:throw Error("index is out of range: "+a);}return this},getComponent:function(a){switch(a){case 0:return this.x;case 1:return this.y;
17701 case 2:return this.z;case 3:return this.w;default:throw Error("index is out of range: "+a);}},clone:function(){return new this.constructor(this.x,this.y,this.z,this.w)},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=void 0!==a.w?a.w:1;return this},add:function(a,b){if(void 0!==b)return console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(a,b);this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},addScalar:function(a){this.x+=
17702 a;this.y+=a;this.z+=a;this.w+=a;return this},addVectors:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addScaledVector:function(a,b){this.x+=a.x*b;this.y+=a.y*b;this.z+=a.z*b;this.w+=a.w*b;return this},sub:function(a,b){if(void 0!==b)return console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(a,b);this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;return this},subScalar:function(a){this.x-=a;this.y-=
17703 a;this.z-=a;this.w-=a;return this},subVectors:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},applyMatrix4:function(a){var b=this.x,c=this.y,d=this.z,e=this.w;a=a.elements;this.x=a[0]*b+a[4]*c+a[8]*d+a[12]*e;this.y=a[1]*b+a[5]*c+a[9]*d+a[13]*e;this.z=a[2]*b+a[6]*c+a[10]*d+a[14]*e;this.w=a[3]*b+a[7]*c+a[11]*d+a[15]*e;return this},divideScalar:function(a){return this.multiplyScalar(1/
17704 a)},setAxisAngleFromQuaternion:function(a){this.w=2*Math.acos(a.w);var b=Math.sqrt(1-a.w*a.w);1E-4>b?(this.x=1,this.z=this.y=0):(this.x=a.x/b,this.y=a.y/b,this.z=a.z/b);return this},setAxisAngleFromRotationMatrix:function(a){a=a.elements;var b=a[0];var c=a[4];var d=a[8],e=a[1],f=a[5],g=a[9];var h=a[2];var k=a[6];var m=a[10];if(.01>Math.abs(c-e)&&.01>Math.abs(d-h)&&.01>Math.abs(g-k)){if(.1>Math.abs(c+e)&&.1>Math.abs(d+h)&&.1>Math.abs(g+k)&&.1>Math.abs(b+f+m-3))return this.set(1,0,0,0),this;a=Math.PI;
17705 b=(b+1)/2;f=(f+1)/2;m=(m+1)/2;c=(c+e)/4;d=(d+h)/4;g=(g+k)/4;b>f&&b>m?.01>b?(k=0,c=h=.707106781):(k=Math.sqrt(b),h=c/k,c=d/k):f>m?.01>f?(k=.707106781,h=0,c=.707106781):(h=Math.sqrt(f),k=c/h,c=g/h):.01>m?(h=k=.707106781,c=0):(c=Math.sqrt(m),k=d/c,h=g/c);this.set(k,h,c,a);return this}a=Math.sqrt((k-g)*(k-g)+(d-h)*(d-h)+(e-c)*(e-c));.001>Math.abs(a)&&(a=1);this.x=(k-g)/a;this.y=(d-h)/a;this.z=(e-c)/a;this.w=Math.acos((b+f+m-1)/2);return this},min:function(a){this.x=Math.min(this.x,a.x);this.y=Math.min(this.y,
17706 a.y);this.z=Math.min(this.z,a.z);this.w=Math.min(this.w,a.w);return this},max:function(a){this.x=Math.max(this.x,a.x);this.y=Math.max(this.y,a.y);this.z=Math.max(this.z,a.z);this.w=Math.max(this.w,a.w);return this},clamp:function(a,b){this.x=Math.max(a.x,Math.min(b.x,this.x));this.y=Math.max(a.y,Math.min(b.y,this.y));this.z=Math.max(a.z,Math.min(b.z,this.z));this.w=Math.max(a.w,Math.min(b.w,this.w));return this},clampScalar:function(){var a,b;return function(c,d){void 0===a&&(a=new V,b=new V);a.set(c,
17707 c,c,c);b.set(d,d,d,d);return this.clamp(a,b)}}(),clampLength:function(a,b){var c=this.length();return this.divideScalar(c||1).multiplyScalar(Math.max(a,Math.min(b,c)))},floor:function(){this.x=Math.floor(this.x);this.y=Math.floor(this.y);this.z=Math.floor(this.z);this.w=Math.floor(this.w);return this},ceil:function(){this.x=Math.ceil(this.x);this.y=Math.ceil(this.y);this.z=Math.ceil(this.z);this.w=Math.ceil(this.w);return this},round:function(){this.x=Math.round(this.x);this.y=Math.round(this.y);
17708 this.z=Math.round(this.z);this.w=Math.round(this.w);return this},roundToZero:function(){this.x=0>this.x?Math.ceil(this.x):Math.floor(this.x);this.y=0>this.y?Math.ceil(this.y):Math.floor(this.y);this.z=0>this.z?Math.ceil(this.z):Math.floor(this.z);this.w=0>this.w?Math.ceil(this.w):Math.floor(this.w);return this},negate:function(){this.x=-this.x;this.y=-this.y;this.z=-this.z;this.w=-this.w;return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z+this.w*a.w},lengthSq:function(){return this.x*
17709 this.x+this.y*this.y+this.z*this.z+this.w*this.w},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)},normalize:function(){return this.divideScalar(this.length()||1)},setLength:function(a){return this.normalize().multiplyScalar(a)},lerp:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b;return this},lerpVectors:function(a,
17710 b,c){return this.subVectors(b,a).multiplyScalar(c).add(a)},equals:function(a){return a.x===this.x&&a.y===this.y&&a.z===this.z&&a.w===this.w},fromArray:function(a,b){void 0===b&&(b=0);this.x=a[b];this.y=a[b+1];this.z=a[b+2];this.w=a[b+3];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this.x;a[b+1]=this.y;a[b+2]=this.z;a[b+3]=this.w;return a},fromBufferAttribute:function(a,b,c){void 0!==c&&console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute().");
17711 this.x=a.getX(b);this.y=a.getY(b);this.z=a.getZ(b);this.w=a.getW(b);return this}});fb.prototype=Object.assign(Object.create(ya.prototype),{constructor:fb,isWebGLRenderTarget:!0,setSize:function(a,b){if(this.width!==a||this.height!==b)this.width=a,this.height=b,this.dispose();this.viewport.set(0,0,a,b);this.scissor.set(0,0,a,b)},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.width=a.width;this.height=a.height;this.viewport.copy(a.viewport);this.texture=a.texture.clone();
17712 this.depthBuffer=a.depthBuffer;this.stencilBuffer=a.stencilBuffer;this.depthTexture=a.depthTexture;return this},dispose:function(){this.dispatchEvent({type:"dispose"})}});Gb.prototype=Object.create(fb.prototype);Gb.prototype.constructor=Gb;Gb.prototype.isWebGLRenderTargetCube=!0;gb.prototype=Object.create(T.prototype);gb.prototype.constructor=gb;gb.prototype.isDataTexture=!0;Object.assign(Sa.prototype,{isBox3:!0,set:function(a,b){this.min.copy(a);this.max.copy(b);return this},setFromArray:function(a){for(var b=
17713 Infinity,c=Infinity,d=Infinity,e=-Infinity,f=-Infinity,g=-Infinity,h=0,k=a.length;h<k;h+=3){var m=a[h],q=a[h+1],l=a[h+2];m<b&&(b=m);q<c&&(c=q);l<d&&(d=l);m>e&&(e=m);q>f&&(f=q);l>g&&(g=l)}this.min.set(b,c,d);this.max.set(e,f,g);return this},setFromBufferAttribute:function(a){for(var b=Infinity,c=Infinity,d=Infinity,e=-Infinity,f=-Infinity,g=-Infinity,h=0,k=a.count;h<k;h++){var m=a.getX(h),l=a.getY(h),n=a.getZ(h);m<b&&(b=m);l<c&&(c=l);n<d&&(d=n);m>e&&(e=m);l>f&&(f=l);n>g&&(g=n)}this.min.set(b,c,d);
17714 this.max.set(e,f,g);return this},setFromPoints:function(a){this.makeEmpty();for(var b=0,c=a.length;b<c;b++)this.expandByPoint(a[b]);return this},setFromCenterAndSize:function(){var a=new p;return function(b,c){c=a.copy(c).multiplyScalar(.5);this.min.copy(b).sub(c);this.max.copy(b).add(c);return this}}(),setFromObject:function(a){this.makeEmpty();return this.expandByObject(a)},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.min.copy(a.min);this.max.copy(a.max);return this},
17715 makeEmpty:function(){this.min.x=this.min.y=this.min.z=Infinity;this.max.x=this.max.y=this.max.z=-Infinity;return this},isEmpty:function(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z},getCenter:function(a){void 0===a&&(console.warn("THREE.Box3: .getCenter() target is now required"),a=new p);return this.isEmpty()?a.set(0,0,0):a.addVectors(this.min,this.max).multiplyScalar(.5)},getSize:function(a){void 0===a&&(console.warn("THREE.Box3: .getSize() target is now required"),
17716 a=new p);return this.isEmpty()?a.set(0,0,0):a.subVectors(this.max,this.min)},expandByPoint:function(a){this.min.min(a);this.max.max(a);return this},expandByVector:function(a){this.min.sub(a);this.max.add(a);return this},expandByScalar:function(a){this.min.addScalar(-a);this.max.addScalar(a);return this},expandByObject:function(){function a(a){var f=a.geometry;if(void 0!==f)if(f.isGeometry)for(f=f.vertices,c=0,d=f.length;c<d;c++)e.copy(f[c]),e.applyMatrix4(a.matrixWorld),b.expandByPoint(e);else if(f.isBufferGeometry&&
17717 (f=f.attributes.position,void 0!==f))for(c=0,d=f.count;c<d;c++)e.fromBufferAttribute(f,c).applyMatrix4(a.matrixWorld),b.expandByPoint(e)}var b,c,d,e=new p;return function(c){b=this;c.updateMatrixWorld(!0);c.traverse(a);return this}}(),containsPoint:function(a){return a.x<this.min.x||a.x>this.max.x||a.y<this.min.y||a.y>this.max.y||a.z<this.min.z||a.z>this.max.z?!1:!0},containsBox:function(a){return this.min.x<=a.min.x&&a.max.x<=this.max.x&&this.min.y<=a.min.y&&a.max.y<=this.max.y&&this.min.z<=a.min.z&&
17718 a.max.z<=this.max.z},getParameter:function(a,b){void 0===b&&(console.warn("THREE.Box3: .getParameter() target is now required"),b=new p);return b.set((a.x-this.min.x)/(this.max.x-this.min.x),(a.y-this.min.y)/(this.max.y-this.min.y),(a.z-this.min.z)/(this.max.z-this.min.z))},intersectsBox:function(a){return a.max.x<this.min.x||a.min.x>this.max.x||a.max.y<this.min.y||a.min.y>this.max.y||a.max.z<this.min.z||a.min.z>this.max.z?!1:!0},intersectsSphere:function(){var a=new p;return function(b){this.clampPoint(b.center,
17719 a);return a.distanceToSquared(b.center)<=b.radius*b.radius}}(),intersectsPlane:function(a){if(0<a.normal.x){var b=a.normal.x*this.min.x;var c=a.normal.x*this.max.x}else b=a.normal.x*this.max.x,c=a.normal.x*this.min.x;0<a.normal.y?(b+=a.normal.y*this.min.y,c+=a.normal.y*this.max.y):(b+=a.normal.y*this.max.y,c+=a.normal.y*this.min.y);0<a.normal.z?(b+=a.normal.z*this.min.z,c+=a.normal.z*this.max.z):(b+=a.normal.z*this.max.z,c+=a.normal.z*this.min.z);return b<=a.constant&&c>=a.constant},intersectsTriangle:function(){function a(a){var e;
17720 var f=0;for(e=a.length-3;f<=e;f+=3){h.fromArray(a,f);var g=m.x*Math.abs(h.x)+m.y*Math.abs(h.y)+m.z*Math.abs(h.z),k=b.dot(h),l=c.dot(h),q=d.dot(h);if(Math.max(-Math.max(k,l,q),Math.min(k,l,q))>g)return!1}return!0}var b=new p,c=new p,d=new p,e=new p,f=new p,g=new p,h=new p,k=new p,m=new p,l=new p;return function(h){if(this.isEmpty())return!1;this.getCenter(k);m.subVectors(this.max,k);b.subVectors(h.a,k);c.subVectors(h.b,k);d.subVectors(h.c,k);e.subVectors(c,b);f.subVectors(d,c);g.subVectors(b,d);h=
17721 [0,-e.z,e.y,0,-f.z,f.y,0,-g.z,g.y,e.z,0,-e.x,f.z,0,-f.x,g.z,0,-g.x,-e.y,e.x,0,-f.y,f.x,0,-g.y,g.x,0];if(!a(h))return!1;h=[1,0,0,0,1,0,0,0,1];if(!a(h))return!1;l.crossVectors(e,f);h=[l.x,l.y,l.z];return a(h)}}(),clampPoint:function(a,b){void 0===b&&(console.warn("THREE.Box3: .clampPoint() target is now required"),b=new p);return b.copy(a).clamp(this.min,this.max)},distanceToPoint:function(){var a=new p;return function(b){return a.copy(b).clamp(this.min,this.max).sub(b).length()}}(),getBoundingSphere:function(){var a=
17722 new p;return function(b){void 0===b&&(console.warn("THREE.Box3: .getBoundingSphere() target is now required"),b=new Da);this.getCenter(b.center);b.radius=.5*this.getSize(a).length();return b}}(),intersect:function(a){this.min.max(a.min);this.max.min(a.max);this.isEmpty()&&this.makeEmpty();return this},union:function(a){this.min.min(a.min);this.max.max(a.max);return this},applyMatrix4:function(a){if(this.isEmpty())return this;a=a.elements;var b=a[0]*this.min.x,c=a[1]*this.min.x,d=a[2]*this.min.x,e=
17723 a[0]*this.max.x,f=a[1]*this.max.x,g=a[2]*this.max.x,h=a[4]*this.min.y,k=a[5]*this.min.y,m=a[6]*this.min.y,l=a[4]*this.max.y,n=a[5]*this.max.y,t=a[6]*this.max.y,u=a[8]*this.min.z,r=a[9]*this.min.z,p=a[10]*this.min.z,y=a[8]*this.max.z,x=a[9]*this.max.z,w=a[10]*this.max.z;this.min.x=Math.min(b,e)+Math.min(h,l)+Math.min(u,y)+a[12];this.min.y=Math.min(c,f)+Math.min(k,n)+Math.min(r,x)+a[13];this.min.z=Math.min(d,g)+Math.min(m,t)+Math.min(p,w)+a[14];this.max.x=Math.max(b,e)+Math.max(h,l)+Math.max(u,y)+a[12];
17724 this.max.y=Math.max(c,f)+Math.max(k,n)+Math.max(r,x)+a[13];this.max.z=Math.max(d,g)+Math.max(m,t)+Math.max(p,w)+a[14];return this},translate:function(a){this.min.add(a);this.max.add(a);return this},equals:function(a){return a.min.equals(this.min)&&a.max.equals(this.max)}});Object.assign(Da.prototype,{set:function(a,b){this.center.copy(a);this.radius=b;return this},setFromPoints:function(){var a=new Sa;return function(b,c){var d=this.center;void 0!==c?d.copy(c):a.setFromPoints(b).getCenter(d);for(var e=
17725 c=0,f=b.length;e<f;e++)c=Math.max(c,d.distanceToSquared(b[e]));this.radius=Math.sqrt(c);return this}}(),clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.center.copy(a.center);this.radius=a.radius;return this},empty:function(){return 0>=this.radius},containsPoint:function(a){return a.distanceToSquared(this.center)<=this.radius*this.radius},distanceToPoint:function(a){return a.distanceTo(this.center)-this.radius},intersectsSphere:function(a){var b=this.radius+a.radius;
17726 return a.center.distanceToSquared(this.center)<=b*b},intersectsBox:function(a){return a.intersectsSphere(this)},intersectsPlane:function(a){return Math.abs(a.distanceToPoint(this.center))<=this.radius},clampPoint:function(a,b){var c=this.center.distanceToSquared(a);void 0===b&&(console.warn("THREE.Sphere: .clampPoint() target is now required"),b=new p);b.copy(a);c>this.radius*this.radius&&(b.sub(this.center).normalize(),b.multiplyScalar(this.radius).add(this.center));return b},getBoundingBox:function(a){void 0===
17727 a&&(console.warn("THREE.Sphere: .getBoundingBox() target is now required"),a=new Sa);a.set(this.center,this.center);a.expandByScalar(this.radius);return a},applyMatrix4:function(a){this.center.applyMatrix4(a);this.radius*=a.getMaxScaleOnAxis();return this},translate:function(a){this.center.add(a);return this},equals:function(a){return a.center.equals(this.center)&&a.radius===this.radius}});Object.assign(Ma.prototype,{set:function(a,b){this.normal.copy(a);this.constant=b;return this},setComponents:function(a,
17728 b,c,d){this.normal.set(a,b,c);this.constant=d;return this},setFromNormalAndCoplanarPoint:function(a,b){this.normal.copy(a);this.constant=-b.dot(this.normal);return this},setFromCoplanarPoints:function(){var a=new p,b=new p;return function(c,d,e){d=a.subVectors(e,d).cross(b.subVectors(c,d)).normalize();this.setFromNormalAndCoplanarPoint(d,c);return this}}(),clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.normal.copy(a.normal);this.constant=a.constant;return this},normalize:function(){var a=
17729 1/this.normal.length();this.normal.multiplyScalar(a);this.constant*=a;return this},negate:function(){this.constant*=-1;this.normal.negate();return this},distanceToPoint:function(a){return this.normal.dot(a)+this.constant},distanceToSphere:function(a){return this.distanceToPoint(a.center)-a.radius},projectPoint:function(a,b){void 0===b&&(console.warn("THREE.Plane: .projectPoint() target is now required"),b=new p);return b.copy(this.normal).multiplyScalar(-this.distanceToPoint(a)).add(a)},intersectLine:function(){var a=
17730 new p;return function(b,c){void 0===c&&(console.warn("THREE.Plane: .intersectLine() target is now required"),c=new p);var d=b.delta(a),e=this.normal.dot(d);if(0===e){if(0===this.distanceToPoint(b.start))return c.copy(b.start)}else if(e=-(b.start.dot(this.normal)+this.constant)/e,!(0>e||1<e))return c.copy(d).multiplyScalar(e).add(b.start)}}(),intersectsLine:function(a){var b=this.distanceToPoint(a.start);a=this.distanceToPoint(a.end);return 0>b&&0<a||0>a&&0<b},intersectsBox:function(a){return a.intersectsPlane(this)},
17731 intersectsSphere:function(a){return a.intersectsPlane(this)},coplanarPoint:function(a){void 0===a&&(console.warn("THREE.Plane: .coplanarPoint() target is now required"),a=new p);return a.copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:function(){var a=new p,b=new ra;return function(c,d){d=d||b.getNormalMatrix(c);c=this.coplanarPoint(a).applyMatrix4(c);d=this.normal.applyMatrix3(d).normalize();this.constant=-c.dot(d);return this}}(),translate:function(a){this.constant-=a.dot(this.normal);
17732 return this},equals:function(a){return a.normal.equals(this.normal)&&a.constant===this.constant}});Object.assign(md.prototype,{set:function(a,b,c,d,e,f){var g=this.planes;g[0].copy(a);g[1].copy(b);g[2].copy(c);g[3].copy(d);g[4].copy(e);g[5].copy(f);return this},clone:function(){return(new this.constructor).copy(this)},copy:function(a){for(var b=this.planes,c=0;6>c;c++)b[c].copy(a.planes[c]);return this},setFromMatrix:function(a){var b=this.planes,c=a.elements;a=c[0];var d=c[1],e=c[2],f=c[3],g=c[4],
17733 h=c[5],k=c[6],m=c[7],l=c[8],n=c[9],t=c[10],p=c[11],r=c[12],v=c[13],y=c[14];c=c[15];b[0].setComponents(f-a,m-g,p-l,c-r).normalize();b[1].setComponents(f+a,m+g,p+l,c+r).normalize();b[2].setComponents(f+d,m+h,p+n,c+v).normalize();b[3].setComponents(f-d,m-h,p-n,c-v).normalize();b[4].setComponents(f-e,m-k,p-t,c-y).normalize();b[5].setComponents(f+e,m+k,p+t,c+y).normalize();return this},intersectsObject:function(){var a=new Da;return function(b){var c=b.geometry;null===c.boundingSphere&&c.computeBoundingSphere();
17734 a.copy(c.boundingSphere).applyMatrix4(b.matrixWorld);return this.intersectsSphere(a)}}(),intersectsSprite:function(){var a=new Da;return function(b){a.center.set(0,0,0);a.radius=.7071067811865476;a.applyMatrix4(b.matrixWorld);return this.intersectsSphere(a)}}(),intersectsSphere:function(a){var b=this.planes,c=a.center;a=-a.radius;for(var d=0;6>d;d++)if(b[d].distanceToPoint(c)<a)return!1;return!0},intersectsBox:function(){var a=new p;return function(b){for(var c=this.planes,d=0;6>d;d++){var e=c[d];
17735 a.x=0<e.normal.x?b.max.x:b.min.x;a.y=0<e.normal.y?b.max.y:b.min.y;a.z=0<e.normal.z?b.max.z:b.min.z;if(0>e.distanceToPoint(a))return!1}return!0}}(),containsPoint:function(a){for(var b=this.planes,c=0;6>c;c++)if(0>b[c].distanceToPoint(a))return!1;return!0}});var S={alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n#endif\n",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif\n",alphatest_fragment:"#ifdef ALPHATEST\n\tif ( diffuseColor.a < ALPHATEST ) discard;\n#endif\n",
17736 aomap_fragment:"#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_ENVMAP ) && defined( PHYSICAL )\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );\n\t#endif\n#endif\n",aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",
17737 begin_vertex:"\nvec3 transformed = vec3( position );\n",beginnormal_vertex:"\nvec3 objectNormal = vec3( normal );\n",bsdfs:"float punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\tif( decayExponent > 0.0 ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tfloat maxDistanceCutoffFactor = pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\treturn distanceFalloff * maxDistanceCutoffFactor;\n#else\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n#endif\n\t}\n\treturn 1.0;\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\treturn 1.0 / ( gl * gv );\n}\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNL = saturate( dot( geometry.normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\nvec3 BRDF_Specular_GGX_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 AB = vec2( -1.04, 1.04 ) * a004 + r.zw;\n\treturn specularColor * AB.x + AB.y;\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n",
17738 bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\n\t\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 );\n\t\tfDet *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif\n",
17739 clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vViewPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vViewPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\tif ( clipped ) discard;\n\t#endif\n#endif\n",
17740 clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\t#if ! defined( PHYSICAL ) && ! defined( PHONG )\n\t\tvarying vec3 vViewPosition;\n\t#endif\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif\n",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\n\tvarying vec3 vViewPosition;\n#endif\n",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n",
17741 color_fragment:"#ifdef USE_COLOR\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif\n",color_pars_vertex:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\n\tvColor.xyz = color.xyz;\n#endif",common:"#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI_HALF 1.5707963267949\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#define whiteCompliment(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}\n",
17742 cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n#define cubeUV_textureSize (1024.0)\nint getFaceFromDirection(vec3 direction) {\n\tvec3 absDirection = abs(direction);\n\tint face = -1;\n\tif( absDirection.x > absDirection.z ) {\n\t\tif(absDirection.x > absDirection.y )\n\t\t\tface = direction.x > 0.0 ? 0 : 3;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\telse {\n\t\tif(absDirection.z > absDirection.y )\n\t\t\tface = direction.z > 0.0 ? 2 : 5;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\treturn face;\n}\n#define cubeUV_maxLods1 (log2(cubeUV_textureSize*0.25) - 1.0)\n#define cubeUV_rangeClamp (exp2((6.0 - 1.0) * 2.0))\nvec2 MipLevelInfo( vec3 vec, float roughnessLevel, float roughness ) {\n\tfloat scale = exp2(cubeUV_maxLods1 - roughnessLevel);\n\tfloat dxRoughness = dFdx(roughness);\n\tfloat dyRoughness = dFdy(roughness);\n\tvec3 dx = dFdx( vec * scale * dxRoughness );\n\tvec3 dy = dFdy( vec * scale * dyRoughness );\n\tfloat d = max( dot( dx, dx ), dot( dy, dy ) );\n\td = clamp(d, 1.0, cubeUV_rangeClamp);\n\tfloat mipLevel = 0.5 * log2(d);\n\treturn vec2(floor(mipLevel), fract(mipLevel));\n}\n#define cubeUV_maxLods2 (log2(cubeUV_textureSize*0.25) - 2.0)\n#define cubeUV_rcpTextureSize (1.0 / cubeUV_textureSize)\nvec2 getCubeUV(vec3 direction, float roughnessLevel, float mipLevel) {\n\tmipLevel = roughnessLevel > cubeUV_maxLods2 - 3.0 ? 0.0 : mipLevel;\n\tfloat a = 16.0 * cubeUV_rcpTextureSize;\n\tvec2 exp2_packed = exp2( vec2( roughnessLevel, mipLevel ) );\n\tvec2 rcp_exp2_packed = vec2( 1.0 ) / exp2_packed;\n\tfloat powScale = exp2_packed.x * exp2_packed.y;\n\tfloat scale = rcp_exp2_packed.x * rcp_exp2_packed.y * 0.25;\n\tfloat mipOffset = 0.75*(1.0 - rcp_exp2_packed.y) * rcp_exp2_packed.x;\n\tbool bRes = mipLevel == 0.0;\n\tscale = bRes && (scale < a) ? a : scale;\n\tvec3 r;\n\tvec2 offset;\n\tint face = getFaceFromDirection(direction);\n\tfloat rcpPowScale = 1.0 / powScale;\n\tif( face == 0) {\n\t\tr = vec3(direction.x, -direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 1) {\n\t\tr = vec3(direction.y, direction.x, direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 2) {\n\t\tr = vec3(direction.z, direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 3) {\n\t\tr = vec3(direction.x, direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse if( face == 4) {\n\t\tr = vec3(direction.y, direction.x, -direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse {\n\t\tr = vec3(direction.z, -direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\tr = normalize(r);\n\tfloat texelOffset = 0.5 * cubeUV_rcpTextureSize;\n\tvec2 s = ( r.yz / abs( r.x ) + vec2( 1.0 ) ) * 0.5;\n\tvec2 base = offset + vec2( texelOffset );\n\treturn base + s * ( scale - 2.0 * texelOffset );\n}\n#define cubeUV_maxLods3 (log2(cubeUV_textureSize*0.25) - 3.0)\nvec4 textureCubeUV( sampler2D envMap, vec3 reflectedDirection, float roughness ) {\n\tfloat roughnessVal = roughness* cubeUV_maxLods3;\n\tfloat r1 = floor(roughnessVal);\n\tfloat r2 = r1 + 1.0;\n\tfloat t = fract(roughnessVal);\n\tvec2 mipInfo = MipLevelInfo(reflectedDirection, r1, roughness);\n\tfloat s = mipInfo.y;\n\tfloat level0 = mipInfo.x;\n\tfloat level1 = level0 + 1.0;\n\tlevel1 = level1 > 5.0 ? 5.0 : level1;\n\tlevel0 += min( floor( s + 0.5 ), 5.0 );\n\tvec2 uv_10 = getCubeUV(reflectedDirection, r1, level0);\n\tvec4 color10 = envMapTexelToLinear(texture2D(envMap, uv_10));\n\tvec2 uv_20 = getCubeUV(reflectedDirection, r2, level0);\n\tvec4 color20 = envMapTexelToLinear(texture2D(envMap, uv_20));\n\tvec4 result = mix(color10, color20, t);\n\treturn vec4(result.rgb, 1.0);\n}\n#endif\n",
17743 defaultnormal_vertex:"vec3 transformedNormal = normalMatrix * objectNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif\n",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, uv ).x * displacementScale + displacementBias );\n#endif\n",
17744 emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif\n",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif\n",encodings_fragment:" gl_FragColor = linearToOutputTexel( gl_FragColor );\n",encodings_pars_fragment:"\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.xyz * value.w * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = min( floor( D ) / 255.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = value.rgb * cLogLuvM;\n\tXp_Y_XYZp = max(Xp_Y_XYZp, vec3(1e-6, 1e-6, 1e-6));\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract(Le);\n\tvResult.z = (Le - (floor(vResult.w*255.0))/255.0)/255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2((Le - 127.0) / 2.0);\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = Xp_Y_XYZp.rgb * cLogLuvInverseM;\n\treturn vec4( max(vRGB, 0.0), 1.0 );\n}\n",
17745 envmap_fragment:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\tvec2 sampleUV;\n\t\treflectVec = normalize( reflectVec );\n\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\tvec4 envColor = texture2D( envMap, sampleUV );\n\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\treflectVec = normalize( reflectVec );\n\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) );\n\t\tvec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\tenvColor = envMapTexelToLinear( envColor );\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif\n",
17746 envmap_pars_fragment:"#if defined( USE_ENVMAP ) || defined( PHYSICAL )\n\tuniform float reflectivity;\n\tuniform float envMapIntensity;\n#endif\n#ifdef USE_ENVMAP\n\t#if ! defined( PHYSICAL ) && ( defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) )\n\t\tvarying vec3 vWorldPosition;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\tuniform float flipEnvMap;\n\tuniform int maxMipLevel;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( PHYSICAL )\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif\n",
17747 envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif\n",envmap_physical_pars_fragment:"#if defined( USE_ENVMAP ) && defined( PHYSICAL )\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, queryVec, 1.0 );\n\t\t#else\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\t\t#endif\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar + 0.79248 - 0.5 * log2( pow2( blinnShininessExponent ) + 1.0 );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in GeometricContext geometry, const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( -geometry.viewDir, geometry.normal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( -geometry.viewDir, geometry.normal, refractionRatio );\n\t\t#endif\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( blinnShininessExponent, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, queryReflectVec, BlinnExponentToGGXRoughness(blinnShininessExponent ));\n\t\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\t\tvec2 sampleUV;\n\t\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0,0.0,1.0 ) );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#endif\n\t\treturn envMapColor.rgb * envMapIntensity;\n\t}\n#endif\n",
17748 envmap_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif\n",
17749 fog_vertex:"\n#ifdef USE_FOG\nfogDepth = -mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n varying float fogDepth;\n#endif\n",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * fogDepth * fogDepth * LOG2 ) );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif\n",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float fogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif\n",
17750 gradientmap_pars_fragment:"#ifdef TOON\n\tuniform sampler2D gradientMap;\n\tvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\t\tfloat dotNL = dot( normal, lightDirection );\n\t\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t\t#ifdef USE_GRADIENTMAP\n\t\t\treturn texture2D( gradientMap, coord ).rgb;\n\t\t#else\n\t\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t\t#endif\n\t}\n#endif\n",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\treflectedLight.indirectDiffuse += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n#endif\n",
17751 lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_vertex:"vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\n#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvLightFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n#endif\n",
17752 lights_pars_begin:"uniform vec3 ambientLightColor;\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treturn irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tdirectLight.color = directionalLight.color;\n\t\tdirectLight.direction = directionalLight.direction;\n\t\tdirectLight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t\tfloat shadowCameraNear;\n\t\tfloat shadowCameraFar;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tdirectLight.color = pointLight.color;\n\t\tdirectLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\n\t\tdirectLight.visible = ( directLight.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat angleCos = dot( directLight.direction, spotLight.direction );\n\t\tif ( angleCos > spotLight.coneCos ) {\n\t\t\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\t\tdirectLight.color = spotLight.color;\n\t\t\tdirectLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tdirectLight.visible = true;\n\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tirradiance *= PI;\n\t\t#endif\n\t\treturn irradiance;\n\t}\n#endif\n",
17753 lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;\n",lights_phong_pars_fragment:"varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct BlinnPhongMaterial {\n\tvec3\tdiffuseColor;\n\tvec3\tspecularColor;\n\tfloat\tspecularShininess;\n\tfloat\tspecularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\t#ifdef TOON\n\t\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\t#else\n\t\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\t\tvec3 irradiance = dotNL * directLight.color;\n\t#endif\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)\n",
17754 lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );\n#ifdef STANDARD\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.clearCoat = saturate( clearCoat );\tmaterial.clearCoatRoughness = clamp( clearCoatRoughness, 0.04, 1.0 );\n#endif\n",
17755 lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3\tdiffuseColor;\n\tfloat\tspecularRoughness;\n\tvec3\tspecularColor;\n\t#ifndef STANDARD\n\t\tfloat clearCoat;\n\t\tfloat clearCoatRoughness;\n\t#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearCoatDHRApprox( const in float roughness, const in float dotNL ) {\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.specularRoughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos - halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos + halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos + halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos - halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\t#ifndef STANDARD\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.directSpecular += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry, material.specularColor, material.specularRoughness );\n\treflectedLight.directDiffuse += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\t#ifndef STANDARD\n\t\treflectedLight.directSpecular += irradiance * material.clearCoat * BRDF_Specular_GGX( directLight, geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#endif\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 clearCoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t#ifndef STANDARD\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\tfloat dotNL = dotNV;\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.indirectSpecular += ( 1.0 - clearCoatDHR ) * radiance * BRDF_Specular_GGX_Environment( geometry, material.specularColor, material.specularRoughness );\n\t#ifndef STANDARD\n\t\treflectedLight.indirectSpecular += clearCoatRadiance * material.clearCoat * BRDF_Specular_GGX_Environment( geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#endif\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\n#define Material_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.specularRoughness )\n#define Material_ClearCoat_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.clearCoatRoughness )\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}\n",
17756 lights_fragment_begin:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = normalize( vViewPosition );\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( pointLight.shadow, directLight.visible ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( spotLight.shadow, directLight.visible ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( directionalLight.shadow, directLight.visible ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearCoatRadiance = vec3( 0.0 );\n#endif\n",
17757 lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec3 lightMapIrradiance = texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( PHYSICAL ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tirradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getLightProbeIndirectRadiance( geometry, Material_BlinnShininessExponent( material ), maxMipLevel );\n\t#ifndef STANDARD\n\t\tclearCoatRadiance += getLightProbeIndirectRadiance( geometry, Material_ClearCoat_BlinnShininessExponent( material ), maxMipLevel );\n\t#endif\n#endif\n",
17758 lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, clearCoatRadiance, geometry, material, reflectedLight );\n#endif\n",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#ifdef USE_LOGDEPTHBUF\n\tuniform float logDepthBufFC;\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t#endif\n#endif\n",
17759 logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t#endif\n\tuniform float logDepthBufFC;\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t#else\n\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\tgl_Position.z *= gl_Position.w;\n\t#endif\n#endif\n",map_fragment:"#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif\n",
17760 map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n",map_particle_fragment:"#ifdef USE_MAP\n\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\tvec4 mapTexel = texture2D( map, uv );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n",map_particle_pars_fragment:"#ifdef USE_MAP\n\tuniform mat3 uvTransform;\n\tuniform sampler2D map;\n#endif\n",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif\n",
17761 metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal += ( morphNormal0 - normal ) * morphTargetInfluences[ 0 ];\n\tobjectNormal += ( morphNormal1 - normal ) * morphTargetInfluences[ 1 ];\n\tobjectNormal += ( morphNormal2 - normal ) * morphTargetInfluences[ 2 ];\n\tobjectNormal += ( morphNormal3 - normal ) * morphTargetInfluences[ 3 ];\n#endif\n",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\t#ifndef USE_MORPHNORMALS\n\tuniform float morphTargetInfluences[ 8 ];\n\t#else\n\tuniform float morphTargetInfluences[ 4 ];\n\t#endif\n#endif",
17762 morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];\n\ttransformed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];\n\ttransformed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];\n\ttransformed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];\n\t#ifndef USE_MORPHNORMALS\n\ttransformed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];\n\ttransformed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];\n\ttransformed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];\n\ttransformed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];\n\t#endif\n#endif\n",
17763 normal_fragment_begin:"#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\n#endif\n",normal_fragment_maps:"#ifdef USE_NORMALMAP\n\t#ifdef OBJECTSPACE_NORMALMAP\n\t\tnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\t#ifdef FLIP_SIDED\n\t\t\tnormal = - normal;\n\t\t#endif\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t#endif\n\t\tnormal = normalize( normalMatrix * normal );\n\t#else\n\t\tnormal = perturbNormal2Arb( -vViewPosition, normal );\n\t#endif\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n#endif\n",
17764 normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n\t#ifdef OBJECTSPACE_NORMALMAP\n\t\tuniform mat3 normalMatrix;\n\t#else\n\t\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm ) {\n\t\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\t\tvec2 st0 = dFdx( vUv.st );\n\t\t\tvec2 st1 = dFdy( vUv.st );\n\t\t\tfloat scale = sign( st1.t * st0.s - st0.t * st1.s );\n\t\t\tvec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );\n\t\t\tvec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale );\n\t\t\tvec3 N = normalize( surf_norm );\n\t\t\tmat3 tsn = mat3( S, T, N );\n\t\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\t\tmapN.xy *= normalScale;\n\t\t\tmapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t\treturn normalize( tsn * mapN );\n\t\t}\n\t#endif\n#endif\n",
17765 packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn (( near + viewZ ) * far ) / (( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}\n",
17766 premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif\n",project_vertex:"vec4 mvPosition = modelViewMatrix * vec4( transformed, 1.0 );\ngl_Position = projectionMatrix * mvPosition;\n",dithering_fragment:"#if defined( DITHERING )\n gl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif\n",dithering_pars_fragment:"#if defined( DITHERING )\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif\n",
17767 roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif\n",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHTS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHTS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHTS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tfloat texture2DShadowLerp( sampler2D depths, vec2 size, vec2 uv, float compare ) {\n\t\tconst vec2 offset = vec2( 0.0, 1.0 );\n\t\tvec2 texelSize = vec2( 1.0 ) / size;\n\t\tvec2 centroidUV = floor( uv * size + 0.5 ) / size;\n\t\tfloat lb = texture2DCompare( depths, centroidUV + texelSize * offset.xx, compare );\n\t\tfloat lt = texture2DCompare( depths, centroidUV + texelSize * offset.xy, compare );\n\t\tfloat rb = texture2DCompare( depths, centroidUV + texelSize * offset.yx, compare );\n\t\tfloat rt = texture2DCompare( depths, centroidUV + texelSize * offset.yy, compare );\n\t\tvec2 f = fract( uv * size + 0.5 );\n\t\tfloat a = mix( lb, lt, f.y );\n\t\tfloat b = mix( rb, rt, f.y );\n\t\tfloat c = mix( a, b, f.x );\n\t\treturn c;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tshadow = (\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif\n",
17768 shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHTS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHTS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHTS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n\t#endif\n#endif\n",
17769 shadowmap_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n#endif\n",
17770 shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\tDirectionalLight directionalLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tshadow *= bool( directionalLight.shadow ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\tSpotLight spotLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tshadow *= bool( spotLight.shadow ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\tPointLight pointLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tshadow *= bool( pointLight.shadow ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#endif\n\t#endif\n\treturn shadow;\n}\n",
17771 skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t#ifdef BONE_TEXTURE\n\t\tuniform sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif\n",
17772 skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif\n",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n#endif\n",
17773 specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif\n",tonemapping_pars_fragment:"#ifndef saturate\n\t#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nuniform float toneMappingWhitePoint;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\n#define Uncharted2Helper( x ) max( ( ( x * ( 0.15 * x + 0.10 * 0.50 ) + 0.20 * 0.02 ) / ( x * ( 0.15 * x + 0.50 ) + 0.20 * 0.30 ) ) - 0.02 / 0.30, vec3( 0.0 ) )\nvec3 Uncharted2ToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\n",
17774 uv_pars_fragment:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvarying vec2 vUv;\n#endif",uv_pars_vertex:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif\n",
17775 uv_vertex:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n#endif",uv2_pars_fragment:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif",uv2_pars_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n#endif",
17776 uv2_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = uv2;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )\n\tvec4 worldPosition = modelMatrix * vec4( transformed, 1.0 );\n#endif\n",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldPosition;\nvoid main() {\n\tgl_FragColor = textureCube( tCube, vec3( tFlip * vWorldPosition.x, vWorldPosition.yz ) );\n\tgl_FragColor.a *= opacity;\n}\n",
17777 cube_vert:"varying vec3 vWorldPosition;\n#include <common>\nvoid main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}\n",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <logdepthbuf_fragment>\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - gl_FragCoord.z ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( gl_FragCoord.z );\n\t#endif\n}\n",
17778 depth_vert:"#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n}\n",
17779 distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main () {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}\n",
17780 distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition.xyz;\n}\n",
17781 equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldPosition;\n#include <common>\nvoid main() {\n\tvec3 direction = normalize( vWorldPosition );\n\tvec2 sampleUV;\n\tsampleUV.y = asin( clamp( direction.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\tsampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n}\n",equirect_vert:"varying vec3 vWorldPosition;\n#include <common>\nvoid main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}\n",
17782 linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <premultiplied_alpha_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}\n",
17783 linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <color_vertex>\n\tvLineDistance = scale * lineDistance;\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}\n",
17784 meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\treflectedLight.indirectDiffuse += texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <envmap_fragment>\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <premultiplied_alpha_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}\n",
17785 meshbasic_vert:"#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_ENVMAP\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}\n",
17786 meshlambert_frag:"uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <fog_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <emissivemap_fragment>\n\treflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor );\n\t#include <lightmap_fragment>\n\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}\n",
17787 meshlambert_vert:"#define LAMBERT\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <lights_lambert_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}\n",
17788 meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}\n",
17789 meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}\n",
17790 meshphysical_frag:"#define PHYSICAL\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifndef STANDARD\n\tuniform float clearCoat;\n\tuniform float clearCoatRoughness;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <bsdfs>\n#include <cube_uv_reflection_fragment>\n#include <envmap_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <lights_physical_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}\n",
17791 meshphysical_vert:"#define PHYSICAL\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}\n",
17792 normal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || ( defined( USE_NORMALMAP ) && ! defined( OBJECTSPACE_NORMALMAP ) )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <packing>\n#include <uv_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\nvoid main() {\n\t#include <logdepthbuf_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}\n",
17793 normal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || ( defined( USE_NORMALMAP ) && ! defined( OBJECTSPACE_NORMALMAP ) )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || ( defined( USE_NORMALMAP ) && ! defined( OBJECTSPACE_NORMALMAP ) )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}\n",
17794 points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <premultiplied_alpha_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}\n",
17795 points_vert:"uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <color_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\t#ifdef USE_SIZEATTENUATION\n\t\tgl_PointSize = size * ( scale / - mvPosition.z );\n\t#else\n\t\tgl_PointSize = size;\n\t#endif\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <fog_vertex>\n}\n",
17796 shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include <fog_fragment>\n}\n",shadow_vert:"#include <fog_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}\n",
17797 sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphatest_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}\n",
17798 sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tvec4 mvPosition;\n\tmvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}\n"},
17799 Aa={merge:function(a){for(var b={},c=0;c<a.length;c++){var d=this.clone(a[c]),e;for(e in d)b[e]=d[e]}return b},clone:function(a){var b={},c;for(c in a){b[c]={};for(var d in a[c]){var e=a[c][d];e&&(e.isColor||e.isMatrix3||e.isMatrix4||e.isVector2||e.isVector3||e.isVector4||e.isTexture)?b[c][d]=e.clone():Array.isArray(e)?b[c][d]=e.slice():b[c][d]=e}}return b}},Tg={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,
17800 blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,
17801 darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,
17802 lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,
17803 mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,
17804 rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Object.assign(G.prototype,
17805 {isColor:!0,r:1,g:1,b:1,set:function(a){a&&a.isColor?this.copy(a):"number"===typeof a?this.setHex(a):"string"===typeof a&&this.setStyle(a);return this},setScalar:function(a){this.b=this.g=this.r=a;return this},setHex:function(a){a=Math.floor(a);this.r=(a>>16&255)/255;this.g=(a>>8&255)/255;this.b=(a&255)/255;return this},setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;return this},setHSL:function(){function a(a,c,d){0>d&&(d+=1);1<d&&--d;return d<1/6?a+6*(c-a)*d:.5>d?c:d<2/3?a+6*(c-a)*(2/3-d):a}return function(b,
17806 c,d){b=H.euclideanModulo(b,1);c=H.clamp(c,0,1);d=H.clamp(d,0,1);0===c?this.r=this.g=this.b=d:(c=.5>=d?d*(1+c):d+c-d*c,d=2*d-c,this.r=a(d,c,b+1/3),this.g=a(d,c,b),this.b=a(d,c,b-1/3));return this}}(),setStyle:function(a){function b(b){void 0!==b&&1>parseFloat(b)&&console.warn("THREE.Color: Alpha component of "+a+" will be ignored.")}var c;if(c=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(a)){var d=c[2];switch(c[1]){case "rgb":case "rgba":if(c=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(d))return this.r=
17807 Math.min(255,parseInt(c[1],10))/255,this.g=Math.min(255,parseInt(c[2],10))/255,this.b=Math.min(255,parseInt(c[3],10))/255,b(c[5]),this;if(c=/^(\d+)%\s*,\s*(\d+)%\s*,\s*(\d+)%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(d))return this.r=Math.min(100,parseInt(c[1],10))/100,this.g=Math.min(100,parseInt(c[2],10))/100,this.b=Math.min(100,parseInt(c[3],10))/100,b(c[5]),this;break;case "hsl":case "hsla":if(c=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(d)){d=parseFloat(c[1])/
17808 360;var e=parseInt(c[2],10)/100,f=parseInt(c[3],10)/100;b(c[5]);return this.setHSL(d,e,f)}}}else if(c=/^#([A-Fa-f0-9]+)$/.exec(a)){c=c[1];d=c.length;if(3===d)return this.r=parseInt(c.charAt(0)+c.charAt(0),16)/255,this.g=parseInt(c.charAt(1)+c.charAt(1),16)/255,this.b=parseInt(c.charAt(2)+c.charAt(2),16)/255,this;if(6===d)return this.r=parseInt(c.charAt(0)+c.charAt(1),16)/255,this.g=parseInt(c.charAt(2)+c.charAt(3),16)/255,this.b=parseInt(c.charAt(4)+c.charAt(5),16)/255,this}a&&0<a.length&&(c=Tg[a],
17809 void 0!==c?this.setHex(c):console.warn("THREE.Color: Unknown color "+a));return this},clone:function(){return new this.constructor(this.r,this.g,this.b)},copy:function(a){this.r=a.r;this.g=a.g;this.b=a.b;return this},copyGammaToLinear:function(a,b){void 0===b&&(b=2);this.r=Math.pow(a.r,b);this.g=Math.pow(a.g,b);this.b=Math.pow(a.b,b);return this},copyLinearToGamma:function(a,b){void 0===b&&(b=2);b=0<b?1/b:1;this.r=Math.pow(a.r,b);this.g=Math.pow(a.g,b);this.b=Math.pow(a.b,b);return this},convertGammaToLinear:function(a){this.copyGammaToLinear(this,
17810 a);return this},convertLinearToGamma:function(a){this.copyLinearToGamma(this,a);return this},copySRGBToLinear:function(){function a(a){return.04045>a?.0773993808*a:Math.pow(.9478672986*a+.0521327014,2.4)}return function(b){this.r=a(b.r);this.g=a(b.g);this.b=a(b.b);return this}}(),copyLinearToSRGB:function(){function a(a){return.0031308>a?12.92*a:1.055*Math.pow(a,.41666)-.055}return function(b){this.r=a(b.r);this.g=a(b.g);this.b=a(b.b);return this}}(),convertSRGBToLinear:function(){this.copySRGBToLinear(this);
17811 return this},convertLinearToSRGB:function(){this.copyLinearToSRGB(this);return this},getHex:function(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0},getHexString:function(){return("000000"+this.getHex().toString(16)).slice(-6)},getHSL:function(a){void 0===a&&(console.warn("THREE.Color: .getHSL() target is now required"),a={h:0,s:0,l:0});var b=this.r,c=this.g,d=this.b,e=Math.max(b,c,d),f=Math.min(b,c,d),g,h=(f+e)/2;if(f===e)f=g=0;else{var k=e-f;f=.5>=h?k/(e+f):k/(2-e-f);switch(e){case b:g=(c-
17812 d)/k+(c<d?6:0);break;case c:g=(d-b)/k+2;break;case d:g=(b-c)/k+4}g/=6}a.h=g;a.s=f;a.l=h;return a},getStyle:function(){return"rgb("+(255*this.r|0)+","+(255*this.g|0)+","+(255*this.b|0)+")"},offsetHSL:function(){var a={};return function(b,c,d){this.getHSL(a);a.h+=b;a.s+=c;a.l+=d;this.setHSL(a.h,a.s,a.l);return this}}(),add:function(a){this.r+=a.r;this.g+=a.g;this.b+=a.b;return this},addColors:function(a,b){this.r=a.r+b.r;this.g=a.g+b.g;this.b=a.b+b.b;return this},addScalar:function(a){this.r+=a;this.g+=
17813 a;this.b+=a;return this},sub:function(a){this.r=Math.max(0,this.r-a.r);this.g=Math.max(0,this.g-a.g);this.b=Math.max(0,this.b-a.b);return this},multiply:function(a){this.r*=a.r;this.g*=a.g;this.b*=a.b;return this},multiplyScalar:function(a){this.r*=a;this.g*=a;this.b*=a;return this},lerp:function(a,b){this.r+=(a.r-this.r)*b;this.g+=(a.g-this.g)*b;this.b+=(a.b-this.b)*b;return this},equals:function(a){return a.r===this.r&&a.g===this.g&&a.b===this.b},fromArray:function(a,b){void 0===b&&(b=0);this.r=
17814 a[b];this.g=a[b+1];this.b=a[b+2];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this.r;a[b+1]=this.g;a[b+2]=this.b;return a},toJSON:function(){return this.getHex()}});var K={common:{diffuse:{value:new G(15658734)},opacity:{value:1},map:{value:null},uvTransform:{value:new ra},alphaMap:{value:null}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},refractionRatio:{value:.98},maxMipLevel:{value:0}},aomap:{aoMap:{value:null},
17815 aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new z(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:2.5E-4},fogNear:{value:1},
17816 fogFar:{value:2E3},fogColor:{value:new G(16777215)}},lights:{ambientLightColor:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{},shadow:{},shadowBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{},shadow:{},shadowBias:{},shadowRadius:{},shadowMapSize:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},
17817 pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{},shadow:{},shadowBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}}},points:{diffuse:{value:new G(15658734)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},uvTransform:{value:new ra}},
17818 sprite:{diffuse:{value:new G(15658734)},opacity:{value:1},center:{value:new z(.5,.5)},rotation:{value:0},map:{value:null},uvTransform:{value:new ra}}},nb={basic:{uniforms:Aa.merge([K.common,K.specularmap,K.envmap,K.aomap,K.lightmap,K.fog]),vertexShader:S.meshbasic_vert,fragmentShader:S.meshbasic_frag},lambert:{uniforms:Aa.merge([K.common,K.specularmap,K.envmap,K.aomap,K.lightmap,K.emissivemap,K.fog,K.lights,{emissive:{value:new G(0)}}]),vertexShader:S.meshlambert_vert,fragmentShader:S.meshlambert_frag},
17819 phong:{uniforms:Aa.merge([K.common,K.specularmap,K.envmap,K.aomap,K.lightmap,K.emissivemap,K.bumpmap,K.normalmap,K.displacementmap,K.gradientmap,K.fog,K.lights,{emissive:{value:new G(0)},specular:{value:new G(1118481)},shininess:{value:30}}]),vertexShader:S.meshphong_vert,fragmentShader:S.meshphong_frag},standard:{uniforms:Aa.merge([K.common,K.envmap,K.aomap,K.lightmap,K.emissivemap,K.bumpmap,K.normalmap,K.displacementmap,K.roughnessmap,K.metalnessmap,K.fog,K.lights,{emissive:{value:new G(0)},roughness:{value:.5},
17820 metalness:{value:.5},envMapIntensity:{value:1}}]),vertexShader:S.meshphysical_vert,fragmentShader:S.meshphysical_frag},points:{uniforms:Aa.merge([K.points,K.fog]),vertexShader:S.points_vert,fragmentShader:S.points_frag},dashed:{uniforms:Aa.merge([K.common,K.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:S.linedashed_vert,fragmentShader:S.linedashed_frag},depth:{uniforms:Aa.merge([K.common,K.displacementmap]),vertexShader:S.depth_vert,fragmentShader:S.depth_frag},normal:{uniforms:Aa.merge([K.common,
17821 K.bumpmap,K.normalmap,K.displacementmap,{opacity:{value:1}}]),vertexShader:S.normal_vert,fragmentShader:S.normal_frag},sprite:{uniforms:Aa.merge([K.sprite,K.fog]),vertexShader:S.sprite_vert,fragmentShader:S.sprite_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:S.cube_vert,fragmentShader:S.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:S.equirect_vert,fragmentShader:S.equirect_frag},distanceRGBA:{uniforms:Aa.merge([K.common,K.displacementmap,
17822 {referencePosition:{value:new p},nearDistance:{value:1},farDistance:{value:1E3}}]),vertexShader:S.distanceRGBA_vert,fragmentShader:S.distanceRGBA_frag},shadow:{uniforms:Aa.merge([K.lights,K.fog,{color:{value:new G(0)},opacity:{value:1}}]),vertexShader:S.shadow_vert,fragmentShader:S.shadow_frag}};nb.physical={uniforms:Aa.merge([nb.standard.uniforms,{clearCoat:{value:0},clearCoatRoughness:{value:0}}]),vertexShader:S.meshphysical_vert,fragmentShader:S.meshphysical_frag};hb.RotationOrders="XYZ YZX ZXY XZY YXZ ZYX".split(" ");
17823 hb.DefaultOrder="XYZ";Object.defineProperties(hb.prototype,{x:{get:function(){return this._x},set:function(a){this._x=a;this.onChangeCallback()}},y:{get:function(){return this._y},set:function(a){this._y=a;this.onChangeCallback()}},z:{get:function(){return this._z},set:function(a){this._z=a;this.onChangeCallback()}},order:{get:function(){return this._order},set:function(a){this._order=a;this.onChangeCallback()}}});Object.assign(hb.prototype,{isEuler:!0,set:function(a,b,c,d){this._x=a;this._y=b;this._z=
17824 c;this._order=d||this._order;this.onChangeCallback();return this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._order)},copy:function(a){this._x=a._x;this._y=a._y;this._z=a._z;this._order=a._order;this.onChangeCallback();return this},setFromRotationMatrix:function(a,b,c){var d=H.clamp,e=a.elements;a=e[0];var f=e[4],g=e[8],h=e[1],k=e[5],m=e[9],l=e[2],n=e[6];e=e[10];b=b||this._order;"XYZ"===b?(this._y=Math.asin(d(g,-1,1)),.99999>Math.abs(g)?(this._x=Math.atan2(-m,e),this._z=
17825 Math.atan2(-f,a)):(this._x=Math.atan2(n,k),this._z=0)):"YXZ"===b?(this._x=Math.asin(-d(m,-1,1)),.99999>Math.abs(m)?(this._y=Math.atan2(g,e),this._z=Math.atan2(h,k)):(this._y=Math.atan2(-l,a),this._z=0)):"ZXY"===b?(this._x=Math.asin(d(n,-1,1)),.99999>Math.abs(n)?(this._y=Math.atan2(-l,e),this._z=Math.atan2(-f,k)):(this._y=0,this._z=Math.atan2(h,a))):"ZYX"===b?(this._y=Math.asin(-d(l,-1,1)),.99999>Math.abs(l)?(this._x=Math.atan2(n,e),this._z=Math.atan2(h,a)):(this._x=0,this._z=Math.atan2(-f,k))):"YZX"===
17826 b?(this._z=Math.asin(d(h,-1,1)),.99999>Math.abs(h)?(this._x=Math.atan2(-m,k),this._y=Math.atan2(-l,a)):(this._x=0,this._y=Math.atan2(g,e))):"XZY"===b?(this._z=Math.asin(-d(f,-1,1)),.99999>Math.abs(f)?(this._x=Math.atan2(n,k),this._y=Math.atan2(g,a)):(this._x=Math.atan2(-m,e),this._y=0)):console.warn("THREE.Euler: .setFromRotationMatrix() given unsupported order: "+b);this._order=b;if(!1!==c)this.onChangeCallback();return this},setFromQuaternion:function(){var a=new I;return function(b,c,d){a.makeRotationFromQuaternion(b);
17827 return this.setFromRotationMatrix(a,c,d)}}(),setFromVector3:function(a,b){return this.set(a.x,a.y,a.z,b||this._order)},reorder:function(){var a=new fa;return function(b){a.setFromEuler(this);return this.setFromQuaternion(a,b)}}(),equals:function(a){return a._x===this._x&&a._y===this._y&&a._z===this._z&&a._order===this._order},fromArray:function(a){this._x=a[0];this._y=a[1];this._z=a[2];void 0!==a[3]&&(this._order=a[3]);this.onChangeCallback();return this},toArray:function(a,b){void 0===a&&(a=[]);
17828 void 0===b&&(b=0);a[b]=this._x;a[b+1]=this._y;a[b+2]=this._z;a[b+3]=this._order;return a},toVector3:function(a){return a?a.set(this._x,this._y,this._z):new p(this._x,this._y,this._z)},onChange:function(a){this.onChangeCallback=a;return this},onChangeCallback:function(){}});Object.assign(Rd.prototype,{set:function(a){this.mask=1<<a|0},enable:function(a){this.mask=this.mask|1<<a|0},toggle:function(a){this.mask^=1<<a|0},disable:function(a){this.mask&=~(1<<a|0)},test:function(a){return 0!==(this.mask&
17829 a.mask)}});var Gf=0;D.DefaultUp=new p(0,1,0);D.DefaultMatrixAutoUpdate=!0;D.prototype=Object.assign(Object.create(ya.prototype),{constructor:D,isObject3D:!0,onBeforeRender:function(){},onAfterRender:function(){},applyMatrix:function(a){this.matrix.multiplyMatrices(a,this.matrix);this.matrix.decompose(this.position,this.quaternion,this.scale)},applyQuaternion:function(a){this.quaternion.premultiply(a);return this},setRotationFromAxisAngle:function(a,b){this.quaternion.setFromAxisAngle(a,b)},setRotationFromEuler:function(a){this.quaternion.setFromEuler(a,
17830 !0)},setRotationFromMatrix:function(a){this.quaternion.setFromRotationMatrix(a)},setRotationFromQuaternion:function(a){this.quaternion.copy(a)},rotateOnAxis:function(){var a=new fa;return function(b,c){a.setFromAxisAngle(b,c);this.quaternion.multiply(a);return this}}(),rotateOnWorldAxis:function(){var a=new fa;return function(b,c){a.setFromAxisAngle(b,c);this.quaternion.premultiply(a);return this}}(),rotateX:function(){var a=new p(1,0,0);return function(b){return this.rotateOnAxis(a,b)}}(),rotateY:function(){var a=
17831 new p(0,1,0);return function(b){return this.rotateOnAxis(a,b)}}(),rotateZ:function(){var a=new p(0,0,1);return function(b){return this.rotateOnAxis(a,b)}}(),translateOnAxis:function(){var a=new p;return function(b,c){a.copy(b).applyQuaternion(this.quaternion);this.position.add(a.multiplyScalar(c));return this}}(),translateX:function(){var a=new p(1,0,0);return function(b){return this.translateOnAxis(a,b)}}(),translateY:function(){var a=new p(0,1,0);return function(b){return this.translateOnAxis(a,
17832 b)}}(),translateZ:function(){var a=new p(0,0,1);return function(b){return this.translateOnAxis(a,b)}}(),localToWorld:function(a){return a.applyMatrix4(this.matrixWorld)},worldToLocal:function(){var a=new I;return function(b){return b.applyMatrix4(a.getInverse(this.matrixWorld))}}(),lookAt:function(){var a=new I,b=new p;return function(c,d,e){c.isVector3?b.copy(c):b.set(c,d,e);this.isCamera?a.lookAt(this.position,b,this.up):a.lookAt(b,this.position,this.up);this.quaternion.setFromRotationMatrix(a)}}(),
17833 add:function(a){if(1<arguments.length){for(var b=0;b<arguments.length;b++)this.add(arguments[b]);return this}if(a===this)return console.error("THREE.Object3D.add: object can't be added as a child of itself.",a),this;a&&a.isObject3D?(null!==a.parent&&a.parent.remove(a),a.parent=this,a.dispatchEvent({type:"added"}),this.children.push(a)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",a);return this},remove:function(a){if(1<arguments.length){for(var b=0;b<arguments.length;b++)this.remove(arguments[b]);
17834 return this}b=this.children.indexOf(a);-1!==b&&(a.parent=null,a.dispatchEvent({type:"removed"}),this.children.splice(b,1));return this},getObjectById:function(a){return this.getObjectByProperty("id",a)},getObjectByName:function(a){return this.getObjectByProperty("name",a)},getObjectByProperty:function(a,b){if(this[a]===b)return this;for(var c=0,d=this.children.length;c<d;c++){var e=this.children[c].getObjectByProperty(a,b);if(void 0!==e)return e}},getWorldPosition:function(a){void 0===a&&(console.warn("THREE.Object3D: .getWorldPosition() target is now required"),
17835 a=new p);this.updateMatrixWorld(!0);return a.setFromMatrixPosition(this.matrixWorld)},getWorldQuaternion:function(){var a=new p,b=new p;return function(c){void 0===c&&(console.warn("THREE.Object3D: .getWorldQuaternion() target is now required"),c=new fa);this.updateMatrixWorld(!0);this.matrixWorld.decompose(a,c,b);return c}}(),getWorldScale:function(){var a=new p,b=new fa;return function(c){void 0===c&&(console.warn("THREE.Object3D: .getWorldScale() target is now required"),c=new p);this.updateMatrixWorld(!0);
17836 this.matrixWorld.decompose(a,b,c);return c}}(),getWorldDirection:function(){var a=new fa;return function(b){void 0===b&&(console.warn("THREE.Object3D: .getWorldDirection() target is now required"),b=new p);this.getWorldQuaternion(a);return b.set(0,0,1).applyQuaternion(a)}}(),raycast:function(){},traverse:function(a){a(this);for(var b=this.children,c=0,d=b.length;c<d;c++)b[c].traverse(a)},traverseVisible:function(a){if(!1!==this.visible){a(this);for(var b=this.children,c=0,d=b.length;c<d;c++)b[c].traverseVisible(a)}},
17837 traverseAncestors:function(a){var b=this.parent;null!==b&&(a(b),b.traverseAncestors(a))},updateMatrix:function(){this.matrix.compose(this.position,this.quaternion,this.scale);this.matrixWorldNeedsUpdate=!0},updateMatrixWorld:function(a){this.matrixAutoUpdate&&this.updateMatrix();if(this.matrixWorldNeedsUpdate||a)null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,a=!0;for(var b=this.children,c=
17838 0,d=b.length;c<d;c++)b[c].updateMatrixWorld(a)},toJSON:function(a){function b(b,c){void 0===b[c.uuid]&&(b[c.uuid]=c.toJSON(a));return c.uuid}function c(a){var b=[],c;for(c in a){var d=a[c];delete d.metadata;b.push(d)}return b}var d=void 0===a||"string"===typeof a,e={};d&&(a={geometries:{},materials:{},textures:{},images:{},shapes:{}},e.metadata={version:4.5,type:"Object",generator:"Object3D.toJSON"});var f={};f.uuid=this.uuid;f.type=this.type;""!==this.name&&(f.name=this.name);!0===this.castShadow&&
17839 (f.castShadow=!0);!0===this.receiveShadow&&(f.receiveShadow=!0);!1===this.visible&&(f.visible=!1);!1===this.frustumCulled&&(f.frustumCulled=!1);0!==this.renderOrder&&(f.renderOrder=this.renderOrder);"{}"!==JSON.stringify(this.userData)&&(f.userData=this.userData);f.layers=this.layers.mask;f.matrix=this.matrix.toArray();!1===this.matrixAutoUpdate&&(f.matrixAutoUpdate=!1);if(this.isMesh||this.isLine||this.isPoints){f.geometry=b(a.geometries,this.geometry);var g=this.geometry.parameters;if(void 0!==
17840 g&&void 0!==g.shapes)if(g=g.shapes,Array.isArray(g))for(var h=0,k=g.length;h<k;h++)b(a.shapes,g[h]);else b(a.shapes,g)}if(void 0!==this.material)if(Array.isArray(this.material)){g=[];h=0;for(k=this.material.length;h<k;h++)g.push(b(a.materials,this.material[h]));f.material=g}else f.material=b(a.materials,this.material);if(0<this.children.length)for(f.children=[],h=0;h<this.children.length;h++)f.children.push(this.children[h].toJSON(a).object);if(d){d=c(a.geometries);h=c(a.materials);k=c(a.textures);
17841 var m=c(a.images);g=c(a.shapes);0<d.length&&(e.geometries=d);0<h.length&&(e.materials=h);0<k.length&&(e.textures=k);0<m.length&&(e.images=m);0<g.length&&(e.shapes=g)}e.object=f;return e},clone:function(a){return(new this.constructor).copy(this,a)},copy:function(a,b){void 0===b&&(b=!0);this.name=a.name;this.up.copy(a.up);this.position.copy(a.position);this.quaternion.copy(a.quaternion);this.scale.copy(a.scale);this.matrix.copy(a.matrix);this.matrixWorld.copy(a.matrixWorld);this.matrixAutoUpdate=a.matrixAutoUpdate;
17842 this.matrixWorldNeedsUpdate=a.matrixWorldNeedsUpdate;this.layers.mask=a.layers.mask;this.visible=a.visible;this.castShadow=a.castShadow;this.receiveShadow=a.receiveShadow;this.frustumCulled=a.frustumCulled;this.renderOrder=a.renderOrder;this.userData=JSON.parse(JSON.stringify(a.userData));if(!0===b)for(b=0;b<a.children.length;b++)this.add(a.children[b].clone());return this}});Na.prototype=Object.assign(Object.create(D.prototype),{constructor:Na,isCamera:!0,copy:function(a,b){D.prototype.copy.call(this,
17843 a,b);this.matrixWorldInverse.copy(a.matrixWorldInverse);this.projectionMatrix.copy(a.projectionMatrix);return this},getWorldDirection:function(){var a=new fa;return function(b){void 0===b&&(console.warn("THREE.Camera: .getWorldDirection() target is now required"),b=new p);this.getWorldQuaternion(a);return b.set(0,0,-1).applyQuaternion(a)}}(),updateMatrixWorld:function(a){D.prototype.updateMatrixWorld.call(this,a);this.matrixWorldInverse.getInverse(this.matrixWorld)},clone:function(){return(new this.constructor).copy(this)}});
17844 Hb.prototype=Object.assign(Object.create(Na.prototype),{constructor:Hb,isOrthographicCamera:!0,copy:function(a,b){Na.prototype.copy.call(this,a,b);this.left=a.left;this.right=a.right;this.top=a.top;this.bottom=a.bottom;this.near=a.near;this.far=a.far;this.zoom=a.zoom;this.view=null===a.view?null:Object.assign({},a.view);return this},setViewOffset:function(a,b,c,d,e,f){null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1});this.view.enabled=!0;this.view.fullWidth=
17845 a;this.view.fullHeight=b;this.view.offsetX=c;this.view.offsetY=d;this.view.width=e;this.view.height=f;this.updateProjectionMatrix()},clearViewOffset:function(){null!==this.view&&(this.view.enabled=!1);this.updateProjectionMatrix()},updateProjectionMatrix:function(){var a=(this.right-this.left)/(2*this.zoom),b=(this.top-this.bottom)/(2*this.zoom),c=(this.right+this.left)/2,d=(this.top+this.bottom)/2,e=c-a;c+=a;a=d+b;b=d-b;if(null!==this.view&&this.view.enabled){c=this.zoom/(this.view.width/this.view.fullWidth);
17846 b=this.zoom/(this.view.height/this.view.fullHeight);var f=(this.right-this.left)/this.view.width;d=(this.top-this.bottom)/this.view.height;e+=this.view.offsetX/c*f;c=e+this.view.width/c*f;a-=this.view.offsetY/b*d;b=a-this.view.height/b*d}this.projectionMatrix.makeOrthographic(e,c,a,b,this.near,this.far)},toJSON:function(a){a=D.prototype.toJSON.call(this,a);a.object.zoom=this.zoom;a.object.left=this.left;a.object.right=this.right;a.object.top=this.top;a.object.bottom=this.bottom;a.object.near=this.near;
17847 a.object.far=this.far;null!==this.view&&(a.object.view=Object.assign({},this.view));return a}});Object.assign(Ta.prototype,{clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.a=a.a;this.b=a.b;this.c=a.c;this.normal.copy(a.normal);this.color.copy(a.color);this.materialIndex=a.materialIndex;for(var b=0,c=a.vertexNormals.length;b<c;b++)this.vertexNormals[b]=a.vertexNormals[b].clone();b=0;for(c=a.vertexColors.length;b<c;b++)this.vertexColors[b]=a.vertexColors[b].clone();return this}});
17848 var Hf=0;R.prototype=Object.assign(Object.create(ya.prototype),{constructor:R,isGeometry:!0,applyMatrix:function(a){for(var b=(new ra).getNormalMatrix(a),c=0,d=this.vertices.length;c<d;c++)this.vertices[c].applyMatrix4(a);c=0;for(d=this.faces.length;c<d;c++){a=this.faces[c];a.normal.applyMatrix3(b).normalize();for(var e=0,f=a.vertexNormals.length;e<f;e++)a.vertexNormals[e].applyMatrix3(b).normalize()}null!==this.boundingBox&&this.computeBoundingBox();null!==this.boundingSphere&&this.computeBoundingSphere();
17849 this.normalsNeedUpdate=this.verticesNeedUpdate=!0;return this},rotateX:function(){var a=new I;return function(b){a.makeRotationX(b);this.applyMatrix(a);return this}}(),rotateY:function(){var a=new I;return function(b){a.makeRotationY(b);this.applyMatrix(a);return this}}(),rotateZ:function(){var a=new I;return function(b){a.makeRotationZ(b);this.applyMatrix(a);return this}}(),translate:function(){var a=new I;return function(b,c,d){a.makeTranslation(b,c,d);this.applyMatrix(a);return this}}(),scale:function(){var a=
17850 new I;return function(b,c,d){a.makeScale(b,c,d);this.applyMatrix(a);return this}}(),lookAt:function(){var a=new D;return function(b){a.lookAt(b);a.updateMatrix();this.applyMatrix(a.matrix)}}(),fromBufferGeometry:function(a){function b(a,b,d,e){var f=void 0!==g?[l[a].clone(),l[b].clone(),l[d].clone()]:[],q=void 0!==h?[c.colors[a].clone(),c.colors[b].clone(),c.colors[d].clone()]:[];e=new Ta(a,b,d,f,q,e);c.faces.push(e);void 0!==k&&c.faceVertexUvs[0].push([n[a].clone(),n[b].clone(),n[d].clone()]);void 0!==
17851 m&&c.faceVertexUvs[1].push([t[a].clone(),t[b].clone(),t[d].clone()])}var c=this,d=null!==a.index?a.index.array:void 0,e=a.attributes,f=e.position.array,g=void 0!==e.normal?e.normal.array:void 0,h=void 0!==e.color?e.color.array:void 0,k=void 0!==e.uv?e.uv.array:void 0,m=void 0!==e.uv2?e.uv2.array:void 0;void 0!==m&&(this.faceVertexUvs[1]=[]);for(var l=[],n=[],t=[],u=e=0;e<f.length;e+=3,u+=2)c.vertices.push(new p(f[e],f[e+1],f[e+2])),void 0!==g&&l.push(new p(g[e],g[e+1],g[e+2])),void 0!==h&&c.colors.push(new G(h[e],
17852 h[e+1],h[e+2])),void 0!==k&&n.push(new z(k[u],k[u+1])),void 0!==m&&t.push(new z(m[u],m[u+1]));var r=a.groups;if(0<r.length)for(e=0;e<r.length;e++){f=r[e];var v=f.start,y=f.count;u=v;for(v+=y;u<v;u+=3)void 0!==d?b(d[u],d[u+1],d[u+2],f.materialIndex):b(u,u+1,u+2,f.materialIndex)}else if(void 0!==d)for(e=0;e<d.length;e+=3)b(d[e],d[e+1],d[e+2]);else for(e=0;e<f.length/3;e+=3)b(e,e+1,e+2);this.computeFaceNormals();null!==a.boundingBox&&(this.boundingBox=a.boundingBox.clone());null!==a.boundingSphere&&
17853 (this.boundingSphere=a.boundingSphere.clone());return this},center:function(){var a=new p;return function(){this.computeBoundingBox();this.boundingBox.getCenter(a).negate();this.translate(a.x,a.y,a.z);return this}}(),normalize:function(){this.computeBoundingSphere();var a=this.boundingSphere.center,b=this.boundingSphere.radius;b=0===b?1:1/b;var c=new I;c.set(b,0,0,-b*a.x,0,b,0,-b*a.y,0,0,b,-b*a.z,0,0,0,1);this.applyMatrix(c);return this},computeFaceNormals:function(){for(var a=new p,b=new p,c=0,d=
17854 this.faces.length;c<d;c++){var e=this.faces[c],f=this.vertices[e.a],g=this.vertices[e.b];a.subVectors(this.vertices[e.c],g);b.subVectors(f,g);a.cross(b);a.normalize();e.normal.copy(a)}},computeVertexNormals:function(a){void 0===a&&(a=!0);var b;var c=Array(this.vertices.length);var d=0;for(b=this.vertices.length;d<b;d++)c[d]=new p;if(a){var e=new p,f=new p;a=0;for(d=this.faces.length;a<d;a++){b=this.faces[a];var g=this.vertices[b.a];var h=this.vertices[b.b];var k=this.vertices[b.c];e.subVectors(k,
17855 h);f.subVectors(g,h);e.cross(f);c[b.a].add(e);c[b.b].add(e);c[b.c].add(e)}}else for(this.computeFaceNormals(),a=0,d=this.faces.length;a<d;a++)b=this.faces[a],c[b.a].add(b.normal),c[b.b].add(b.normal),c[b.c].add(b.normal);d=0;for(b=this.vertices.length;d<b;d++)c[d].normalize();a=0;for(d=this.faces.length;a<d;a++)b=this.faces[a],g=b.vertexNormals,3===g.length?(g[0].copy(c[b.a]),g[1].copy(c[b.b]),g[2].copy(c[b.c])):(g[0]=c[b.a].clone(),g[1]=c[b.b].clone(),g[2]=c[b.c].clone());0<this.faces.length&&(this.normalsNeedUpdate=
17856 !0)},computeFlatVertexNormals:function(){var a;this.computeFaceNormals();var b=0;for(a=this.faces.length;b<a;b++){var c=this.faces[b];var d=c.vertexNormals;3===d.length?(d[0].copy(c.normal),d[1].copy(c.normal),d[2].copy(c.normal)):(d[0]=c.normal.clone(),d[1]=c.normal.clone(),d[2]=c.normal.clone())}0<this.faces.length&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){var a,b;var c=0;for(b=this.faces.length;c<b;c++){var d=this.faces[c];d.__originalFaceNormal?d.__originalFaceNormal.copy(d.normal):
17857 d.__originalFaceNormal=d.normal.clone();d.__originalVertexNormals||(d.__originalVertexNormals=[]);var e=0;for(a=d.vertexNormals.length;e<a;e++)d.__originalVertexNormals[e]?d.__originalVertexNormals[e].copy(d.vertexNormals[e]):d.__originalVertexNormals[e]=d.vertexNormals[e].clone()}var f=new R;f.faces=this.faces;e=0;for(a=this.morphTargets.length;e<a;e++){if(!this.morphNormals[e]){this.morphNormals[e]={};this.morphNormals[e].faceNormals=[];this.morphNormals[e].vertexNormals=[];d=this.morphNormals[e].faceNormals;
17858 var g=this.morphNormals[e].vertexNormals;c=0;for(b=this.faces.length;c<b;c++){var h=new p;var k={a:new p,b:new p,c:new p};d.push(h);g.push(k)}}g=this.morphNormals[e];f.vertices=this.morphTargets[e].vertices;f.computeFaceNormals();f.computeVertexNormals();c=0;for(b=this.faces.length;c<b;c++)d=this.faces[c],h=g.faceNormals[c],k=g.vertexNormals[c],h.copy(d.normal),k.a.copy(d.vertexNormals[0]),k.b.copy(d.vertexNormals[1]),k.c.copy(d.vertexNormals[2])}c=0;for(b=this.faces.length;c<b;c++)d=this.faces[c],
17859 d.normal=d.__originalFaceNormal,d.vertexNormals=d.__originalVertexNormals},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new Sa);this.boundingBox.setFromPoints(this.vertices)},computeBoundingSphere:function(){null===this.boundingSphere&&(this.boundingSphere=new Da);this.boundingSphere.setFromPoints(this.vertices)},merge:function(a,b,c){if(a&&a.isGeometry){var d,e=this.vertices.length,f=this.vertices,g=a.vertices,h=this.faces,k=a.faces,m=this.faceVertexUvs[0],l=a.faceVertexUvs[0],
17860 n=this.colors,t=a.colors;void 0===c&&(c=0);void 0!==b&&(d=(new ra).getNormalMatrix(b));a=0;for(var p=g.length;a<p;a++){var r=g[a].clone();void 0!==b&&r.applyMatrix4(b);f.push(r)}a=0;for(p=t.length;a<p;a++)n.push(t[a].clone());a=0;for(p=k.length;a<p;a++){g=k[a];var v=g.vertexNormals;t=g.vertexColors;n=new Ta(g.a+e,g.b+e,g.c+e);n.normal.copy(g.normal);void 0!==d&&n.normal.applyMatrix3(d).normalize();b=0;for(f=v.length;b<f;b++)r=v[b].clone(),void 0!==d&&r.applyMatrix3(d).normalize(),n.vertexNormals.push(r);
17861 n.color.copy(g.color);b=0;for(f=t.length;b<f;b++)r=t[b],n.vertexColors.push(r.clone());n.materialIndex=g.materialIndex+c;h.push(n)}a=0;for(p=l.length;a<p;a++)if(c=l[a],d=[],void 0!==c){b=0;for(f=c.length;b<f;b++)d.push(c[b].clone());m.push(d)}}else console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",a)},mergeMesh:function(a){a&&a.isMesh?(a.matrixAutoUpdate&&a.updateMatrix(),this.merge(a.geometry,a.matrix)):console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",
17862 a)},mergeVertices:function(){var a={},b=[],c=[],d=Math.pow(10,4),e;var f=0;for(e=this.vertices.length;f<e;f++){var g=this.vertices[f];g=Math.round(g.x*d)+"_"+Math.round(g.y*d)+"_"+Math.round(g.z*d);void 0===a[g]?(a[g]=f,b.push(this.vertices[f]),c[f]=b.length-1):c[f]=c[a[g]]}a=[];f=0;for(e=this.faces.length;f<e;f++)for(d=this.faces[f],d.a=c[d.a],d.b=c[d.b],d.c=c[d.c],d=[d.a,d.b,d.c],g=0;3>g;g++)if(d[g]===d[(g+1)%3]){a.push(f);break}for(f=a.length-1;0<=f;f--)for(d=a[f],this.faces.splice(d,1),c=0,e=
17863 this.faceVertexUvs.length;c<e;c++)this.faceVertexUvs[c].splice(d,1);f=this.vertices.length-b.length;this.vertices=b;return f},setFromPoints:function(a){this.vertices=[];for(var b=0,c=a.length;b<c;b++){var d=a[b];this.vertices.push(new p(d.x,d.y,d.z||0))}return this},sortFacesByMaterialIndex:function(){for(var a=this.faces,b=a.length,c=0;c<b;c++)a[c]._id=c;a.sort(function(a,b){return a.materialIndex-b.materialIndex});var d=this.faceVertexUvs[0],e=this.faceVertexUvs[1],f,g;d&&d.length===b&&(f=[]);e&&
17864 e.length===b&&(g=[]);for(c=0;c<b;c++){var h=a[c]._id;f&&f.push(d[h]);g&&g.push(e[h])}f&&(this.faceVertexUvs[0]=f);g&&(this.faceVertexUvs[1]=g)},toJSON:function(){function a(a,b,c){return c?a|1<<b:a&~(1<<b)}function b(a){var b=a.x.toString()+a.y.toString()+a.z.toString();if(void 0!==m[b])return m[b];m[b]=k.length/3;k.push(a.x,a.y,a.z);return m[b]}function c(a){var b=a.r.toString()+a.g.toString()+a.b.toString();if(void 0!==n[b])return n[b];n[b]=l.length;l.push(a.getHex());return n[b]}function d(a){var b=
17865 a.x.toString()+a.y.toString();if(void 0!==p[b])return p[b];p[b]=t.length/2;t.push(a.x,a.y);return p[b]}var e={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};e.uuid=this.uuid;e.type=this.type;""!==this.name&&(e.name=this.name);if(void 0!==this.parameters){var f=this.parameters,g;for(g in f)void 0!==f[g]&&(e[g]=f[g]);return e}f=[];for(g=0;g<this.vertices.length;g++){var h=this.vertices[g];f.push(h.x,h.y,h.z)}h=[];var k=[],m={},l=[],n={},t=[],p={};for(g=0;g<this.faces.length;g++){var r=
17866 this.faces[g],v=void 0!==this.faceVertexUvs[0][g],y=0<r.normal.length(),x=0<r.vertexNormals.length,w=1!==r.color.r||1!==r.color.g||1!==r.color.b,B=0<r.vertexColors.length,E=0;E=a(E,0,0);E=a(E,1,!0);E=a(E,2,!1);E=a(E,3,v);E=a(E,4,y);E=a(E,5,x);E=a(E,6,w);E=a(E,7,B);h.push(E);h.push(r.a,r.b,r.c);h.push(r.materialIndex);v&&(v=this.faceVertexUvs[0][g],h.push(d(v[0]),d(v[1]),d(v[2])));y&&h.push(b(r.normal));x&&(y=r.vertexNormals,h.push(b(y[0]),b(y[1]),b(y[2])));w&&h.push(c(r.color));B&&(r=r.vertexColors,
17867 h.push(c(r[0]),c(r[1]),c(r[2])))}e.data={};e.data.vertices=f;e.data.normals=k;0<l.length&&(e.data.colors=l);0<t.length&&(e.data.uvs=[t]);e.data.faces=h;return e},clone:function(){return(new R).copy(this)},copy:function(a){var b,c,d;this.vertices=[];this.colors=[];this.faces=[];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphNormals=[];this.skinWeights=[];this.skinIndices=[];this.lineDistances=[];this.boundingSphere=this.boundingBox=null;this.name=a.name;var e=a.vertices;var f=0;for(b=e.length;f<
17868 b;f++)this.vertices.push(e[f].clone());e=a.colors;f=0;for(b=e.length;f<b;f++)this.colors.push(e[f].clone());e=a.faces;f=0;for(b=e.length;f<b;f++)this.faces.push(e[f].clone());f=0;for(b=a.faceVertexUvs.length;f<b;f++){var g=a.faceVertexUvs[f];void 0===this.faceVertexUvs[f]&&(this.faceVertexUvs[f]=[]);e=0;for(c=g.length;e<c;e++){var h=g[e],k=[];var m=0;for(d=h.length;m<d;m++)k.push(h[m].clone());this.faceVertexUvs[f].push(k)}}m=a.morphTargets;f=0;for(b=m.length;f<b;f++){d={};d.name=m[f].name;if(void 0!==
17869 m[f].vertices)for(d.vertices=[],e=0,c=m[f].vertices.length;e<c;e++)d.vertices.push(m[f].vertices[e].clone());if(void 0!==m[f].normals)for(d.normals=[],e=0,c=m[f].normals.length;e<c;e++)d.normals.push(m[f].normals[e].clone());this.morphTargets.push(d)}m=a.morphNormals;f=0;for(b=m.length;f<b;f++){d={};if(void 0!==m[f].vertexNormals)for(d.vertexNormals=[],e=0,c=m[f].vertexNormals.length;e<c;e++)g=m[f].vertexNormals[e],h={},h.a=g.a.clone(),h.b=g.b.clone(),h.c=g.c.clone(),d.vertexNormals.push(h);if(void 0!==
17870 m[f].faceNormals)for(d.faceNormals=[],e=0,c=m[f].faceNormals.length;e<c;e++)d.faceNormals.push(m[f].faceNormals[e].clone());this.morphNormals.push(d)}e=a.skinWeights;f=0;for(b=e.length;f<b;f++)this.skinWeights.push(e[f].clone());e=a.skinIndices;f=0;for(b=e.length;f<b;f++)this.skinIndices.push(e[f].clone());e=a.lineDistances;f=0;for(b=e.length;f<b;f++)this.lineDistances.push(e[f]);f=a.boundingBox;null!==f&&(this.boundingBox=f.clone());f=a.boundingSphere;null!==f&&(this.boundingSphere=f.clone());this.elementsNeedUpdate=
17871 a.elementsNeedUpdate;this.verticesNeedUpdate=a.verticesNeedUpdate;this.uvsNeedUpdate=a.uvsNeedUpdate;this.normalsNeedUpdate=a.normalsNeedUpdate;this.colorsNeedUpdate=a.colorsNeedUpdate;this.lineDistancesNeedUpdate=a.lineDistancesNeedUpdate;this.groupsNeedUpdate=a.groupsNeedUpdate;return this},dispose:function(){this.dispatchEvent({type:"dispose"})}});Object.defineProperty(Q.prototype,"needsUpdate",{set:function(a){!0===a&&this.version++}});Object.assign(Q.prototype,{isBufferAttribute:!0,onUploadCallback:function(){},
17872 setArray:function(a){if(Array.isArray(a))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.count=void 0!==a?a.length/this.itemSize:0;this.array=a;return this},setDynamic:function(a){this.dynamic=a;return this},copy:function(a){this.name=a.name;this.array=new a.array.constructor(a.array);this.itemSize=a.itemSize;this.count=a.count;this.normalized=a.normalized;this.dynamic=a.dynamic;return this},copyAt:function(a,b,c){a*=this.itemSize;c*=b.itemSize;for(var d=0,e=this.itemSize;d<
17873 e;d++)this.array[a+d]=b.array[c+d];return this},copyArray:function(a){this.array.set(a);return this},copyColorsArray:function(a){for(var b=this.array,c=0,d=0,e=a.length;d<e;d++){var f=a[d];void 0===f&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",d),f=new G);b[c++]=f.r;b[c++]=f.g;b[c++]=f.b}return this},copyVector2sArray:function(a){for(var b=this.array,c=0,d=0,e=a.length;d<e;d++){var f=a[d];void 0===f&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",
17874 d),f=new z);b[c++]=f.x;b[c++]=f.y}return this},copyVector3sArray:function(a){for(var b=this.array,c=0,d=0,e=a.length;d<e;d++){var f=a[d];void 0===f&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",d),f=new p);b[c++]=f.x;b[c++]=f.y;b[c++]=f.z}return this},copyVector4sArray:function(a){for(var b=this.array,c=0,d=0,e=a.length;d<e;d++){var f=a[d];void 0===f&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",d),f=new V);b[c++]=f.x;b[c++]=f.y;
17875 b[c++]=f.z;b[c++]=f.w}return this},set:function(a,b){void 0===b&&(b=0);this.array.set(a,b);return this},getX:function(a){return this.array[a*this.itemSize]},setX:function(a,b){this.array[a*this.itemSize]=b;return this},getY:function(a){return this.array[a*this.itemSize+1]},setY:function(a,b){this.array[a*this.itemSize+1]=b;return this},getZ:function(a){return this.array[a*this.itemSize+2]},setZ:function(a,b){this.array[a*this.itemSize+2]=b;return this},getW:function(a){return this.array[a*this.itemSize+
17876 3]},setW:function(a,b){this.array[a*this.itemSize+3]=b;return this},setXY:function(a,b,c){a*=this.itemSize;this.array[a+0]=b;this.array[a+1]=c;return this},setXYZ:function(a,b,c,d){a*=this.itemSize;this.array[a+0]=b;this.array[a+1]=c;this.array[a+2]=d;return this},setXYZW:function(a,b,c,d,e){a*=this.itemSize;this.array[a+0]=b;this.array[a+1]=c;this.array[a+2]=d;this.array[a+3]=e;return this},onUpload:function(a){this.onUploadCallback=a;return this},clone:function(){return(new this.constructor(this.array,
17877 this.itemSize)).copy(this)}});oc.prototype=Object.create(Q.prototype);oc.prototype.constructor=oc;pc.prototype=Object.create(Q.prototype);pc.prototype.constructor=pc;qc.prototype=Object.create(Q.prototype);qc.prototype.constructor=qc;rc.prototype=Object.create(Q.prototype);rc.prototype.constructor=rc;ib.prototype=Object.create(Q.prototype);ib.prototype.constructor=ib;sc.prototype=Object.create(Q.prototype);sc.prototype.constructor=sc;jb.prototype=Object.create(Q.prototype);jb.prototype.constructor=
17878 jb;A.prototype=Object.create(Q.prototype);A.prototype.constructor=A;tc.prototype=Object.create(Q.prototype);tc.prototype.constructor=tc;Object.assign(Ee.prototype,{computeGroups:function(a){var b=[],c=void 0;a=a.faces;for(var d=0;d<a.length;d++){var e=a[d];if(e.materialIndex!==c){c=e.materialIndex;void 0!==f&&(f.count=3*d-f.start,b.push(f));var f={start:3*d,materialIndex:c}}}void 0!==f&&(f.count=3*d-f.start,b.push(f));this.groups=b},fromGeometry:function(a){var b=a.faces,c=a.vertices,d=a.faceVertexUvs,
17879 e=d[0]&&0<d[0].length,f=d[1]&&0<d[1].length,g=a.morphTargets,h=g.length;if(0<h){var k=[];for(var m=0;m<h;m++)k[m]=[];this.morphTargets.position=k}var l=a.morphNormals,n=l.length;if(0<n){var t=[];for(m=0;m<n;m++)t[m]=[];this.morphTargets.normal=t}var p=a.skinIndices,r=a.skinWeights,v=p.length===c.length,y=r.length===c.length;0<c.length&&0===b.length&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(m=0;m<b.length;m++){var x=b[m];this.vertices.push(c[x.a],c[x.b],c[x.c]);
17880 var w=x.vertexNormals;3===w.length?this.normals.push(w[0],w[1],w[2]):(w=x.normal,this.normals.push(w,w,w));w=x.vertexColors;3===w.length?this.colors.push(w[0],w[1],w[2]):(w=x.color,this.colors.push(w,w,w));!0===e&&(w=d[0][m],void 0!==w?this.uvs.push(w[0],w[1],w[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",m),this.uvs.push(new z,new z,new z)));!0===f&&(w=d[1][m],void 0!==w?this.uvs2.push(w[0],w[1],w[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",
17881 m),this.uvs2.push(new z,new z,new z)));for(w=0;w<h;w++){var B=g[w].vertices;k[w].push(B[x.a],B[x.b],B[x.c])}for(w=0;w<n;w++)B=l[w].vertexNormals[m],t[w].push(B.a,B.b,B.c);v&&this.skinIndices.push(p[x.a],p[x.b],p[x.c]);y&&this.skinWeights.push(r[x.a],r[x.b],r[x.c])}this.computeGroups(a);this.verticesNeedUpdate=a.verticesNeedUpdate;this.normalsNeedUpdate=a.normalsNeedUpdate;this.colorsNeedUpdate=a.colorsNeedUpdate;this.uvsNeedUpdate=a.uvsNeedUpdate;this.groupsNeedUpdate=a.groupsNeedUpdate;return this}});
17882 var If=1;C.prototype=Object.assign(Object.create(ya.prototype),{constructor:C,isBufferGeometry:!0,getIndex:function(){return this.index},setIndex:function(a){Array.isArray(a)?this.index=new (65535<Fe(a)?jb:ib)(a,1):this.index=a},addAttribute:function(a,b,c){if(!(b&&b.isBufferAttribute||b&&b.isInterleavedBufferAttribute))return console.warn("THREE.BufferGeometry: .addAttribute() now expects ( name, attribute )."),this.addAttribute(a,new Q(b,c));if("index"===a)return console.warn("THREE.BufferGeometry.addAttribute: Use .setIndex() for index attribute."),
17883 this.setIndex(b),this;this.attributes[a]=b;return this},getAttribute:function(a){return this.attributes[a]},removeAttribute:function(a){delete this.attributes[a];return this},addGroup:function(a,b,c){this.groups.push({start:a,count:b,materialIndex:void 0!==c?c:0})},clearGroups:function(){this.groups=[]},setDrawRange:function(a,b){this.drawRange.start=a;this.drawRange.count=b},applyMatrix:function(a){var b=this.attributes.position;void 0!==b&&(a.applyToBufferAttribute(b),b.needsUpdate=!0);b=this.attributes.normal;
17884 void 0!==b&&((new ra).getNormalMatrix(a).applyToBufferAttribute(b),b.needsUpdate=!0);null!==this.boundingBox&&this.computeBoundingBox();null!==this.boundingSphere&&this.computeBoundingSphere();return this},rotateX:function(){var a=new I;return function(b){a.makeRotationX(b);this.applyMatrix(a);return this}}(),rotateY:function(){var a=new I;return function(b){a.makeRotationY(b);this.applyMatrix(a);return this}}(),rotateZ:function(){var a=new I;return function(b){a.makeRotationZ(b);this.applyMatrix(a);
17885 return this}}(),translate:function(){var a=new I;return function(b,c,d){a.makeTranslation(b,c,d);this.applyMatrix(a);return this}}(),scale:function(){var a=new I;return function(b,c,d){a.makeScale(b,c,d);this.applyMatrix(a);return this}}(),lookAt:function(){var a=new D;return function(b){a.lookAt(b);a.updateMatrix();this.applyMatrix(a.matrix)}}(),center:function(){var a=new p;return function(){this.computeBoundingBox();this.boundingBox.getCenter(a).negate();this.translate(a.x,a.y,a.z);return this}}(),
17886 setFromObject:function(a){var b=a.geometry;if(a.isPoints||a.isLine){a=new A(3*b.vertices.length,3);var c=new A(3*b.colors.length,3);this.addAttribute("position",a.copyVector3sArray(b.vertices));this.addAttribute("color",c.copyColorsArray(b.colors));b.lineDistances&&b.lineDistances.length===b.vertices.length&&(a=new A(b.lineDistances.length,1),this.addAttribute("lineDistance",a.copyArray(b.lineDistances)));null!==b.boundingSphere&&(this.boundingSphere=b.boundingSphere.clone());null!==b.boundingBox&&
17887 (this.boundingBox=b.boundingBox.clone())}else a.isMesh&&b&&b.isGeometry&&this.fromGeometry(b);return this},setFromPoints:function(a){for(var b=[],c=0,d=a.length;c<d;c++){var e=a[c];b.push(e.x,e.y,e.z||0)}this.addAttribute("position",new A(b,3));return this},updateFromObject:function(a){var b=a.geometry;if(a.isMesh){var c=b.__directGeometry;!0===b.elementsNeedUpdate&&(c=void 0,b.elementsNeedUpdate=!1);if(void 0===c)return this.fromGeometry(b);c.verticesNeedUpdate=b.verticesNeedUpdate;c.normalsNeedUpdate=
17888 b.normalsNeedUpdate;c.colorsNeedUpdate=b.colorsNeedUpdate;c.uvsNeedUpdate=b.uvsNeedUpdate;c.groupsNeedUpdate=b.groupsNeedUpdate;b.verticesNeedUpdate=!1;b.normalsNeedUpdate=!1;b.colorsNeedUpdate=!1;b.uvsNeedUpdate=!1;b.groupsNeedUpdate=!1;b=c}!0===b.verticesNeedUpdate&&(c=this.attributes.position,void 0!==c&&(c.copyVector3sArray(b.vertices),c.needsUpdate=!0),b.verticesNeedUpdate=!1);!0===b.normalsNeedUpdate&&(c=this.attributes.normal,void 0!==c&&(c.copyVector3sArray(b.normals),c.needsUpdate=!0),b.normalsNeedUpdate=
17889 !1);!0===b.colorsNeedUpdate&&(c=this.attributes.color,void 0!==c&&(c.copyColorsArray(b.colors),c.needsUpdate=!0),b.colorsNeedUpdate=!1);b.uvsNeedUpdate&&(c=this.attributes.uv,void 0!==c&&(c.copyVector2sArray(b.uvs),c.needsUpdate=!0),b.uvsNeedUpdate=!1);b.lineDistancesNeedUpdate&&(c=this.attributes.lineDistance,void 0!==c&&(c.copyArray(b.lineDistances),c.needsUpdate=!0),b.lineDistancesNeedUpdate=!1);b.groupsNeedUpdate&&(b.computeGroups(a.geometry),this.groups=b.groups,b.groupsNeedUpdate=!1);return this},
17890 fromGeometry:function(a){a.__directGeometry=(new Ee).fromGeometry(a);return this.fromDirectGeometry(a.__directGeometry)},fromDirectGeometry:function(a){var b=new Float32Array(3*a.vertices.length);this.addAttribute("position",(new Q(b,3)).copyVector3sArray(a.vertices));0<a.normals.length&&(b=new Float32Array(3*a.normals.length),this.addAttribute("normal",(new Q(b,3)).copyVector3sArray(a.normals)));0<a.colors.length&&(b=new Float32Array(3*a.colors.length),this.addAttribute("color",(new Q(b,3)).copyColorsArray(a.colors)));
17891 0<a.uvs.length&&(b=new Float32Array(2*a.uvs.length),this.addAttribute("uv",(new Q(b,2)).copyVector2sArray(a.uvs)));0<a.uvs2.length&&(b=new Float32Array(2*a.uvs2.length),this.addAttribute("uv2",(new Q(b,2)).copyVector2sArray(a.uvs2)));this.groups=a.groups;for(var c in a.morphTargets){b=[];for(var d=a.morphTargets[c],e=0,f=d.length;e<f;e++){var g=d[e],h=new A(3*g.length,3);b.push(h.copyVector3sArray(g))}this.morphAttributes[c]=b}0<a.skinIndices.length&&(c=new A(4*a.skinIndices.length,4),this.addAttribute("skinIndex",
17892 c.copyVector4sArray(a.skinIndices)));0<a.skinWeights.length&&(c=new A(4*a.skinWeights.length,4),this.addAttribute("skinWeight",c.copyVector4sArray(a.skinWeights)));null!==a.boundingSphere&&(this.boundingSphere=a.boundingSphere.clone());null!==a.boundingBox&&(this.boundingBox=a.boundingBox.clone());return this},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new Sa);var a=this.attributes.position;void 0!==a?this.boundingBox.setFromBufferAttribute(a):this.boundingBox.makeEmpty();
17893 (isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox: Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)},computeBoundingSphere:function(){var a=new Sa,b=new p;return function(){null===this.boundingSphere&&(this.boundingSphere=new Da);var c=this.attributes.position;if(c){var d=this.boundingSphere.center;a.setFromBufferAttribute(c);a.getCenter(d);for(var e=0,
17894 f=0,g=c.count;f<g;f++)b.x=c.getX(f),b.y=c.getY(f),b.z=c.getZ(f),e=Math.max(e,d.distanceToSquared(b));this.boundingSphere.radius=Math.sqrt(e);isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}}(),computeFaceNormals:function(){},computeVertexNormals:function(){var a=this.index,b=this.attributes,c=this.groups;if(b.position){var d=b.position.array;if(void 0===b.normal)this.addAttribute("normal",
17895 new Q(new Float32Array(d.length),3));else for(var e=b.normal.array,f=0,g=e.length;f<g;f++)e[f]=0;e=b.normal.array;var h=new p,k=new p,m=new p,l=new p,n=new p;if(a){a=a.array;0===c.length&&this.addGroup(0,a.length);for(var t=0,u=c.length;t<u;++t){f=c[t];g=f.start;var r=f.count;f=g;for(g+=r;f<g;f+=3){r=3*a[f+0];var v=3*a[f+1];var y=3*a[f+2];h.fromArray(d,r);k.fromArray(d,v);m.fromArray(d,y);l.subVectors(m,k);n.subVectors(h,k);l.cross(n);e[r]+=l.x;e[r+1]+=l.y;e[r+2]+=l.z;e[v]+=l.x;e[v+1]+=l.y;e[v+2]+=
17896 l.z;e[y]+=l.x;e[y+1]+=l.y;e[y+2]+=l.z}}}else for(f=0,g=d.length;f<g;f+=9)h.fromArray(d,f),k.fromArray(d,f+3),m.fromArray(d,f+6),l.subVectors(m,k),n.subVectors(h,k),l.cross(n),e[f]=l.x,e[f+1]=l.y,e[f+2]=l.z,e[f+3]=l.x,e[f+4]=l.y,e[f+5]=l.z,e[f+6]=l.x,e[f+7]=l.y,e[f+8]=l.z;this.normalizeNormals();b.normal.needsUpdate=!0}},merge:function(a,b){if(a&&a.isBufferGeometry){void 0===b&&(b=0,console.warn("THREE.BufferGeometry.merge(): Overwriting original geometry, starting at offset=0. Use BufferGeometryUtils.mergeBufferGeometries() for lossless merge."));
17897 var c=this.attributes,d;for(d in c)if(void 0!==a.attributes[d]){var e=c[d].array,f=a.attributes[d],g=f.array,h=0;for(f=f.itemSize*b;h<g.length;h++,f++)e[f]=g[h]}return this}console.error("THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.",a)},normalizeNormals:function(){var a=new p;return function(){for(var b=this.attributes.normal,c=0,d=b.count;c<d;c++)a.x=b.getX(c),a.y=b.getY(c),a.z=b.getZ(c),a.normalize(),b.setXYZ(c,a.x,a.y,a.z)}}(),toNonIndexed:function(){if(null===
17898 this.index)return console.warn("THREE.BufferGeometry.toNonIndexed(): Geometry is already non-indexed."),this;var a=new C,b=this.index.array,c=this.attributes,d;for(d in c){var e=c[d],f=e.array,g=e.itemSize,h=new f.constructor(b.length*g),k=0;e=0;for(var m=b.length;e<m;e++){var l=b[e]*g;for(var n=0;n<g;n++)h[k++]=f[l++]}a.addAttribute(d,new Q(h,g))}b=this.groups;e=0;for(m=b.length;e<m;e++)c=b[e],a.addGroup(c.start,c.count,c.materialIndex);return a},toJSON:function(){var a={metadata:{version:4.5,type:"BufferGeometry",
17899 generator:"BufferGeometry.toJSON"}};a.uuid=this.uuid;a.type=this.type;""!==this.name&&(a.name=this.name);0<Object.keys(this.userData).length&&(a.userData=this.userData);if(void 0!==this.parameters){var b=this.parameters;for(e in b)void 0!==b[e]&&(a[e]=b[e]);return a}a.data={attributes:{}};var c=this.index;null!==c&&(b=Array.prototype.slice.call(c.array),a.data.index={type:c.array.constructor.name,array:b});c=this.attributes;for(e in c){var d=c[e];b=Array.prototype.slice.call(d.array);a.data.attributes[e]=
17900 {itemSize:d.itemSize,type:d.array.constructor.name,array:b,normalized:d.normalized}}var e=this.groups;0<e.length&&(a.data.groups=JSON.parse(JSON.stringify(e)));e=this.boundingSphere;null!==e&&(a.data.boundingSphere={center:e.center.toArray(),radius:e.radius});return a},clone:function(){return(new C).copy(this)},copy:function(a){var b;this.index=null;this.attributes={};this.morphAttributes={};this.groups=[];this.boundingSphere=this.boundingBox=null;this.name=a.name;var c=a.index;null!==c&&this.setIndex(c.clone());
17901 c=a.attributes;for(g in c)this.addAttribute(g,c[g].clone());var d=a.morphAttributes;for(g in d){var e=[],f=d[g];c=0;for(b=f.length;c<b;c++)e.push(f[c].clone());this.morphAttributes[g]=e}var g=a.groups;c=0;for(b=g.length;c<b;c++)d=g[c],this.addGroup(d.start,d.count,d.materialIndex);g=a.boundingBox;null!==g&&(this.boundingBox=g.clone());g=a.boundingSphere;null!==g&&(this.boundingSphere=g.clone());this.drawRange.start=a.drawRange.start;this.drawRange.count=a.drawRange.count;this.userData=a.userData;
17902 return this},dispose:function(){this.dispatchEvent({type:"dispose"})}});Ib.prototype=Object.create(R.prototype);Ib.prototype.constructor=Ib;kb.prototype=Object.create(C.prototype);kb.prototype.constructor=kb;uc.prototype=Object.create(R.prototype);uc.prototype.constructor=uc;lb.prototype=Object.create(C.prototype);lb.prototype.constructor=lb;var Kf=0;J.prototype=Object.assign(Object.create(ya.prototype),{constructor:J,isMaterial:!0,onBeforeCompile:function(){},setValues:function(a){if(void 0!==a)for(var b in a){var c=
17903 a[b];if(void 0===c)console.warn("THREE.Material: '"+b+"' parameter is undefined.");else if("shading"===b)console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=1===c?!0:!1;else{var d=this[b];void 0===d?console.warn("THREE."+this.type+": '"+b+"' is not a property of this material."):d&&d.isColor?d.set(c):d&&d.isVector3&&c&&c.isVector3?d.copy(c):this[b]="overdraw"===b?Number(c):c}}},toJSON:function(a){function b(a){var b=[],c;for(c in a){var d=
17904 a[c];delete d.metadata;b.push(d)}return b}var c=void 0===a||"string"===typeof a;c&&(a={textures:{},images:{}});var d={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};d.uuid=this.uuid;d.type=this.type;""!==this.name&&(d.name=this.name);this.color&&this.color.isColor&&(d.color=this.color.getHex());void 0!==this.roughness&&(d.roughness=this.roughness);void 0!==this.metalness&&(d.metalness=this.metalness);this.emissive&&this.emissive.isColor&&(d.emissive=this.emissive.getHex());1!==
17905 this.emissiveIntensity&&(d.emissiveIntensity=this.emissiveIntensity);this.specular&&this.specular.isColor&&(d.specular=this.specular.getHex());void 0!==this.shininess&&(d.shininess=this.shininess);void 0!==this.clearCoat&&(d.clearCoat=this.clearCoat);void 0!==this.clearCoatRoughness&&(d.clearCoatRoughness=this.clearCoatRoughness);this.map&&this.map.isTexture&&(d.map=this.map.toJSON(a).uuid);this.alphaMap&&this.alphaMap.isTexture&&(d.alphaMap=this.alphaMap.toJSON(a).uuid);this.lightMap&&this.lightMap.isTexture&&
17906 (d.lightMap=this.lightMap.toJSON(a).uuid);this.aoMap&&this.aoMap.isTexture&&(d.aoMap=this.aoMap.toJSON(a).uuid,d.aoMapIntensity=this.aoMapIntensity);this.bumpMap&&this.bumpMap.isTexture&&(d.bumpMap=this.bumpMap.toJSON(a).uuid,d.bumpScale=this.bumpScale);this.normalMap&&this.normalMap.isTexture&&(d.normalMap=this.normalMap.toJSON(a).uuid,d.normalMapType=this.normalMapType,d.normalScale=this.normalScale.toArray());this.displacementMap&&this.displacementMap.isTexture&&(d.displacementMap=this.displacementMap.toJSON(a).uuid,
17907 d.displacementScale=this.displacementScale,d.displacementBias=this.displacementBias);this.roughnessMap&&this.roughnessMap.isTexture&&(d.roughnessMap=this.roughnessMap.toJSON(a).uuid);this.metalnessMap&&this.metalnessMap.isTexture&&(d.metalnessMap=this.metalnessMap.toJSON(a).uuid);this.emissiveMap&&this.emissiveMap.isTexture&&(d.emissiveMap=this.emissiveMap.toJSON(a).uuid);this.specularMap&&this.specularMap.isTexture&&(d.specularMap=this.specularMap.toJSON(a).uuid);this.envMap&&this.envMap.isTexture&&
17908 (d.envMap=this.envMap.toJSON(a).uuid,d.reflectivity=this.reflectivity);this.gradientMap&&this.gradientMap.isTexture&&(d.gradientMap=this.gradientMap.toJSON(a).uuid);void 0!==this.size&&(d.size=this.size);void 0!==this.sizeAttenuation&&(d.sizeAttenuation=this.sizeAttenuation);1!==this.blending&&(d.blending=this.blending);!0===this.flatShading&&(d.flatShading=this.flatShading);0!==this.side&&(d.side=this.side);0!==this.vertexColors&&(d.vertexColors=this.vertexColors);1>this.opacity&&(d.opacity=this.opacity);
17909 !0===this.transparent&&(d.transparent=this.transparent);d.depthFunc=this.depthFunc;d.depthTest=this.depthTest;d.depthWrite=this.depthWrite;0!==this.rotation&&(d.rotation=this.rotation);1!==this.linewidth&&(d.linewidth=this.linewidth);void 0!==this.dashSize&&(d.dashSize=this.dashSize);void 0!==this.gapSize&&(d.gapSize=this.gapSize);void 0!==this.scale&&(d.scale=this.scale);!0===this.dithering&&(d.dithering=!0);0<this.alphaTest&&(d.alphaTest=this.alphaTest);!0===this.premultipliedAlpha&&(d.premultipliedAlpha=
17910 this.premultipliedAlpha);!0===this.wireframe&&(d.wireframe=this.wireframe);1<this.wireframeLinewidth&&(d.wireframeLinewidth=this.wireframeLinewidth);"round"!==this.wireframeLinecap&&(d.wireframeLinecap=this.wireframeLinecap);"round"!==this.wireframeLinejoin&&(d.wireframeLinejoin=this.wireframeLinejoin);!0===this.morphTargets&&(d.morphTargets=!0);!0===this.skinning&&(d.skinning=!0);!1===this.visible&&(d.visible=!1);"{}"!==JSON.stringify(this.userData)&&(d.userData=this.userData);c&&(c=b(a.textures),
17911 a=b(a.images),0<c.length&&(d.textures=c),0<a.length&&(d.images=a));return d},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.name=a.name;this.fog=a.fog;this.lights=a.lights;this.blending=a.blending;this.side=a.side;this.flatShading=a.flatShading;this.vertexColors=a.vertexColors;this.opacity=a.opacity;this.transparent=a.transparent;this.blendSrc=a.blendSrc;this.blendDst=a.blendDst;this.blendEquation=a.blendEquation;this.blendSrcAlpha=a.blendSrcAlpha;this.blendDstAlpha=
17912 a.blendDstAlpha;this.blendEquationAlpha=a.blendEquationAlpha;this.depthFunc=a.depthFunc;this.depthTest=a.depthTest;this.depthWrite=a.depthWrite;this.colorWrite=a.colorWrite;this.precision=a.precision;this.polygonOffset=a.polygonOffset;this.polygonOffsetFactor=a.polygonOffsetFactor;this.polygonOffsetUnits=a.polygonOffsetUnits;this.dithering=a.dithering;this.alphaTest=a.alphaTest;this.premultipliedAlpha=a.premultipliedAlpha;this.overdraw=a.overdraw;this.visible=a.visible;this.userData=JSON.parse(JSON.stringify(a.userData));
17913 this.clipShadows=a.clipShadows;this.clipIntersection=a.clipIntersection;var b=a.clippingPlanes,c=null;if(null!==b){var d=b.length;c=Array(d);for(var e=0;e!==d;++e)c[e]=b[e].clone()}this.clippingPlanes=c;this.shadowSide=a.shadowSide;return this},dispose:function(){this.dispatchEvent({type:"dispose"})}});da.prototype=Object.create(J.prototype);da.prototype.constructor=da;da.prototype.isMeshBasicMaterial=!0;da.prototype.copy=function(a){J.prototype.copy.call(this,a);this.color.copy(a.color);this.map=
17914 a.map;this.lightMap=a.lightMap;this.lightMapIntensity=a.lightMapIntensity;this.aoMap=a.aoMap;this.aoMapIntensity=a.aoMapIntensity;this.specularMap=a.specularMap;this.alphaMap=a.alphaMap;this.envMap=a.envMap;this.combine=a.combine;this.reflectivity=a.reflectivity;this.refractionRatio=a.refractionRatio;this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;this.wireframeLinecap=a.wireframeLinecap;this.wireframeLinejoin=a.wireframeLinejoin;this.skinning=a.skinning;this.morphTargets=
17915 a.morphTargets;return this};ta.prototype=Object.create(J.prototype);ta.prototype.constructor=ta;ta.prototype.isShaderMaterial=!0;ta.prototype.copy=function(a){J.prototype.copy.call(this,a);this.fragmentShader=a.fragmentShader;this.vertexShader=a.vertexShader;this.uniforms=Aa.clone(a.uniforms);this.defines=Object.assign({},a.defines);this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;this.lights=a.lights;this.clipping=a.clipping;this.skinning=a.skinning;this.morphTargets=a.morphTargets;
17916 this.morphNormals=a.morphNormals;this.extensions=a.extensions;return this};ta.prototype.toJSON=function(a){a=J.prototype.toJSON.call(this,a);a.uniforms=this.uniforms;a.vertexShader=this.vertexShader;a.fragmentShader=this.fragmentShader;return a};Object.assign(mb.prototype,{set:function(a,b){this.origin.copy(a);this.direction.copy(b);return this},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.origin.copy(a.origin);this.direction.copy(a.direction);return this},at:function(a,
17917 b){void 0===b&&(console.warn("THREE.Ray: .at() target is now required"),b=new p);return b.copy(this.direction).multiplyScalar(a).add(this.origin)},lookAt:function(a){this.direction.copy(a).sub(this.origin).normalize();return this},recast:function(){var a=new p;return function(b){this.origin.copy(this.at(b,a));return this}}(),closestPointToPoint:function(a,b){void 0===b&&(console.warn("THREE.Ray: .closestPointToPoint() target is now required"),b=new p);b.subVectors(a,this.origin);a=b.dot(this.direction);
17918 return 0>a?b.copy(this.origin):b.copy(this.direction).multiplyScalar(a).add(this.origin)},distanceToPoint:function(a){return Math.sqrt(this.distanceSqToPoint(a))},distanceSqToPoint:function(){var a=new p;return function(b){var c=a.subVectors(b,this.origin).dot(this.direction);if(0>c)return this.origin.distanceToSquared(b);a.copy(this.direction).multiplyScalar(c).add(this.origin);return a.distanceToSquared(b)}}(),distanceSqToSegment:function(){var a=new p,b=new p,c=new p;return function(d,e,f,g){a.copy(d).add(e).multiplyScalar(.5);
17919 b.copy(e).sub(d).normalize();c.copy(this.origin).sub(a);var h=.5*d.distanceTo(e),k=-this.direction.dot(b),m=c.dot(this.direction),l=-c.dot(b),n=c.lengthSq(),t=Math.abs(1-k*k);if(0<t){d=k*l-m;e=k*m-l;var p=h*t;0<=d?e>=-p?e<=p?(h=1/t,d*=h,e*=h,k=d*(d+k*e+2*m)+e*(k*d+e+2*l)+n):(e=h,d=Math.max(0,-(k*e+m)),k=-d*d+e*(e+2*l)+n):(e=-h,d=Math.max(0,-(k*e+m)),k=-d*d+e*(e+2*l)+n):e<=-p?(d=Math.max(0,-(-k*h+m)),e=0<d?-h:Math.min(Math.max(-h,-l),h),k=-d*d+e*(e+2*l)+n):e<=p?(d=0,e=Math.min(Math.max(-h,-l),h),k=
17920 e*(e+2*l)+n):(d=Math.max(0,-(k*h+m)),e=0<d?h:Math.min(Math.max(-h,-l),h),k=-d*d+e*(e+2*l)+n)}else e=0<k?-h:h,d=Math.max(0,-(k*e+m)),k=-d*d+e*(e+2*l)+n;f&&f.copy(this.direction).multiplyScalar(d).add(this.origin);g&&g.copy(b).multiplyScalar(e).add(a);return k}}(),intersectSphere:function(){var a=new p;return function(b,c){a.subVectors(b.center,this.origin);var d=a.dot(this.direction),e=a.dot(a)-d*d;b=b.radius*b.radius;if(e>b)return null;b=Math.sqrt(b-e);e=d-b;d+=b;return 0>e&&0>d?null:0>e?this.at(d,
17921 c):this.at(e,c)}}(),intersectsSphere:function(a){return this.distanceToPoint(a.center)<=a.radius},distanceToPlane:function(a){var b=a.normal.dot(this.direction);if(0===b)return 0===a.distanceToPoint(this.origin)?0:null;a=-(this.origin.dot(a.normal)+a.constant)/b;return 0<=a?a:null},intersectPlane:function(a,b){a=this.distanceToPlane(a);return null===a?null:this.at(a,b)},intersectsPlane:function(a){var b=a.distanceToPoint(this.origin);return 0===b||0>a.normal.dot(this.direction)*b?!0:!1},intersectBox:function(a,
17922 b){var c=1/this.direction.x;var d=1/this.direction.y;var e=1/this.direction.z,f=this.origin;if(0<=c){var g=(a.min.x-f.x)*c;c*=a.max.x-f.x}else g=(a.max.x-f.x)*c,c*=a.min.x-f.x;if(0<=d){var h=(a.min.y-f.y)*d;d*=a.max.y-f.y}else h=(a.max.y-f.y)*d,d*=a.min.y-f.y;if(g>d||h>c)return null;if(h>g||g!==g)g=h;if(d<c||c!==c)c=d;0<=e?(h=(a.min.z-f.z)*e,a=(a.max.z-f.z)*e):(h=(a.max.z-f.z)*e,a=(a.min.z-f.z)*e);if(g>a||h>c)return null;if(h>g||g!==g)g=h;if(a<c||c!==c)c=a;return 0>c?null:this.at(0<=g?g:c,b)},intersectsBox:function(){var a=
17923 new p;return function(b){return null!==this.intersectBox(b,a)}}(),intersectTriangle:function(){var a=new p,b=new p,c=new p,d=new p;return function(e,f,g,h,k){b.subVectors(f,e);c.subVectors(g,e);d.crossVectors(b,c);f=this.direction.dot(d);if(0<f){if(h)return null;h=1}else if(0>f)h=-1,f=-f;else return null;a.subVectors(this.origin,e);e=h*this.direction.dot(c.crossVectors(a,c));if(0>e)return null;g=h*this.direction.dot(b.cross(a));if(0>g||e+g>f)return null;e=-h*a.dot(d);return 0>e?null:this.at(e/f,k)}}(),
17924 applyMatrix4:function(a){this.origin.applyMatrix4(a);this.direction.transformDirection(a);return this},equals:function(a){return a.origin.equals(this.origin)&&a.direction.equals(this.direction)}});Object.assign(ja,{getNormal:function(){var a=new p;return function(b,c,d,e){void 0===e&&(console.warn("THREE.Triangle: .getNormal() target is now required"),e=new p);e.subVectors(d,c);a.subVectors(b,c);e.cross(a);b=e.lengthSq();return 0<b?e.multiplyScalar(1/Math.sqrt(b)):e.set(0,0,0)}}(),getBarycoord:function(){var a=
17925 new p,b=new p,c=new p;return function(d,e,f,g,h){a.subVectors(g,e);b.subVectors(f,e);c.subVectors(d,e);d=a.dot(a);e=a.dot(b);f=a.dot(c);var k=b.dot(b);g=b.dot(c);var m=d*k-e*e;void 0===h&&(console.warn("THREE.Triangle: .getBarycoord() target is now required"),h=new p);if(0===m)return h.set(-2,-1,-1);m=1/m;k=(k*f-e*g)*m;d=(d*g-e*f)*m;return h.set(1-k-d,d,k)}}(),containsPoint:function(){var a=new p;return function(b,c,d,e){ja.getBarycoord(b,c,d,e,a);return 0<=a.x&&0<=a.y&&1>=a.x+a.y}}()});Object.assign(ja.prototype,
17926 {set:function(a,b,c){this.a.copy(a);this.b.copy(b);this.c.copy(c);return this},setFromPointsAndIndices:function(a,b,c,d){this.a.copy(a[b]);this.b.copy(a[c]);this.c.copy(a[d]);return this},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.a.copy(a.a);this.b.copy(a.b);this.c.copy(a.c);return this},getArea:function(){var a=new p,b=new p;return function(){a.subVectors(this.c,this.b);b.subVectors(this.a,this.b);return.5*a.cross(b).length()}}(),getMidpoint:function(a){void 0===
17927 a&&(console.warn("THREE.Triangle: .getMidpoint() target is now required"),a=new p);return a.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},getNormal:function(a){return ja.getNormal(this.a,this.b,this.c,a)},getPlane:function(a){void 0===a&&(console.warn("THREE.Triangle: .getPlane() target is now required"),a=new p);return a.setFromCoplanarPoints(this.a,this.b,this.c)},getBarycoord:function(a,b){return ja.getBarycoord(a,this.a,this.b,this.c,b)},containsPoint:function(a){return ja.containsPoint(a,
17928 this.a,this.b,this.c)},intersectsBox:function(a){return a.intersectsTriangle(this)},closestPointToPoint:function(){var a=new p,b=new p,c=new p,d=new p,e=new p,f=new p;return function(g,h){void 0===h&&(console.warn("THREE.Triangle: .closestPointToPoint() target is now required"),h=new p);var k=this.a,m=this.b,l=this.c;a.subVectors(m,k);b.subVectors(l,k);d.subVectors(g,k);var n=a.dot(d),t=b.dot(d);if(0>=n&&0>=t)return h.copy(k);e.subVectors(g,m);var u=a.dot(e),r=b.dot(e);if(0<=u&&r<=u)return h.copy(m);
17929 var v=n*r-u*t;if(0>=v&&0<=n&&0>=u)return m=n/(n-u),h.copy(k).addScaledVector(a,m);f.subVectors(g,l);g=a.dot(f);var y=b.dot(f);if(0<=y&&g<=y)return h.copy(l);n=g*t-n*y;if(0>=n&&0<=t&&0>=y)return v=t/(t-y),h.copy(k).addScaledVector(b,v);t=u*y-g*r;if(0>=t&&0<=r-u&&0<=g-y)return c.subVectors(l,m),v=(r-u)/(r-u+(g-y)),h.copy(m).addScaledVector(c,v);l=1/(t+n+v);m=n*l;v*=l;return h.copy(k).addScaledVector(a,m).addScaledVector(b,v)}}(),equals:function(a){return a.a.equals(this.a)&&a.b.equals(this.b)&&a.c.equals(this.c)}});
17930 la.prototype=Object.assign(Object.create(D.prototype),{constructor:la,isMesh:!0,setDrawMode:function(a){this.drawMode=a},copy:function(a){D.prototype.copy.call(this,a);this.drawMode=a.drawMode;void 0!==a.morphTargetInfluences&&(this.morphTargetInfluences=a.morphTargetInfluences.slice());void 0!==a.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},a.morphTargetDictionary));return this},updateMorphTargets:function(){var a=this.geometry;if(a.isBufferGeometry){a=a.morphAttributes;var b=
17931 Object.keys(a);if(0<b.length){var c=a[b[0]];if(void 0!==c)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},a=0,b=c.length;a<b;a++){var d=c[a].name||String(a);this.morphTargetInfluences.push(0);this.morphTargetDictionary[d]=a}}}else if(c=a.morphTargets,void 0!==c&&0<c.length)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},a=0,b=c.length;a<b;a++)d=c[a].name||String(a),this.morphTargetInfluences.push(0),this.morphTargetDictionary[d]=a},raycast:function(){function a(a,b,
17932 c,d,e,f,g){ja.getBarycoord(a,b,c,d,v);e.multiplyScalar(v.x);f.multiplyScalar(v.y);g.multiplyScalar(v.z);e.add(f).add(g);return e.clone()}function b(a,b,c,d,e,f,g,h){if(null===(1===b.side?d.intersectTriangle(g,f,e,!0,h):d.intersectTriangle(e,f,g,2!==b.side,h)))return null;x.copy(h);x.applyMatrix4(a.matrixWorld);b=c.ray.origin.distanceTo(x);return b<c.near||b>c.far?null:{distance:b,point:x.clone(),object:a}}function c(c,d,e,f,m,l,n,q,p){g.fromBufferAttribute(m,n);h.fromBufferAttribute(m,q);k.fromBufferAttribute(m,
17933 p);if(c=b(c,d,e,f,g,h,k,y))l&&(t.fromBufferAttribute(l,n),u.fromBufferAttribute(l,q),r.fromBufferAttribute(l,p),c.uv=a(y,g,h,k,t,u,r)),l=new Ta(n,q,p),ja.getNormal(g,h,k,l.normal),c.face=l;return c}var d=new I,e=new mb,f=new Da,g=new p,h=new p,k=new p,m=new p,l=new p,n=new p,t=new z,u=new z,r=new z,v=new p,y=new p,x=new p;return function(q,p){var v=this.geometry,w=this.material,x=this.matrixWorld;if(void 0!==w&&(null===v.boundingSphere&&v.computeBoundingSphere(),f.copy(v.boundingSphere),f.applyMatrix4(x),
17934 !1!==q.ray.intersectsSphere(f)&&(d.getInverse(x),e.copy(q.ray).applyMatrix4(d),null===v.boundingBox||!1!==e.intersectsBox(v.boundingBox))))if(v.isBufferGeometry){var z=v.index,B=v.attributes.position,A=v.attributes.uv,D=v.groups;v=v.drawRange;var C;if(null!==z)if(Array.isArray(w)){var H=0;for(C=D.length;H<C;H++){var G=D[H];var K=w[G.materialIndex];x=Math.max(G.start,v.start);var L=Math.min(G.start+G.count,v.start+v.count);for(G=x;G<L;G+=3){x=z.getX(G);var I=z.getX(G+1);var J=z.getX(G+2);if(x=c(this,
17935 K,q,e,B,A,x,I,J))x.faceIndex=Math.floor(G/3),p.push(x)}}}else for(x=Math.max(0,v.start),L=Math.min(z.count,v.start+v.count),H=x,C=L;H<C;H+=3){if(x=z.getX(H),I=z.getX(H+1),J=z.getX(H+2),x=c(this,w,q,e,B,A,x,I,J))x.faceIndex=Math.floor(H/3),p.push(x)}else if(void 0!==B)if(Array.isArray(w))for(H=0,C=D.length;H<C;H++)for(G=D[H],K=w[G.materialIndex],x=Math.max(G.start,v.start),L=Math.min(G.start+G.count,v.start+v.count),G=x;G<L;G+=3){if(x=G,I=G+1,J=G+2,x=c(this,K,q,e,B,A,x,I,J))x.faceIndex=Math.floor(G/
17936 3),p.push(x)}else for(x=Math.max(0,v.start),L=Math.min(B.count,v.start+v.count),H=x,C=L;H<C;H+=3)if(x=H,I=H+1,J=H+2,x=c(this,w,q,e,B,A,x,I,J))x.faceIndex=Math.floor(H/3),p.push(x)}else if(v.isGeometry)for(B=Array.isArray(w),A=v.vertices,D=v.faces,x=v.faceVertexUvs[0],0<x.length&&(z=x),G=0,L=D.length;G<L;G++)if(I=D[G],x=B?w[I.materialIndex]:w,void 0!==x){H=A[I.a];C=A[I.b];K=A[I.c];if(!0===x.morphTargets){J=v.morphTargets;var R=this.morphTargetInfluences;g.set(0,0,0);h.set(0,0,0);k.set(0,0,0);for(var Q=
17937 0,S=J.length;Q<S;Q++){var T=R[Q];if(0!==T){var V=J[Q].vertices;g.addScaledVector(m.subVectors(V[I.a],H),T);h.addScaledVector(l.subVectors(V[I.b],C),T);k.addScaledVector(n.subVectors(V[I.c],K),T)}}g.add(H);h.add(C);k.add(K);H=g;C=h;K=k}if(x=b(this,x,q,e,H,C,K,y))z&&z[G]&&(J=z[G],t.copy(J[0]),u.copy(J[1]),r.copy(J[2]),x.uv=a(y,H,C,K,t,u,r)),x.face=I,x.faceIndex=G,p.push(x)}}}(),clone:function(){return(new this.constructor(this.geometry,this.material)).copy(this)}});Ua.prototype=Object.create(T.prototype);
17938 Ua.prototype.constructor=Ua;Ua.prototype.isCubeTexture=!0;Object.defineProperty(Ua.prototype,"images",{get:function(){return this.image},set:function(a){this.image=a}});var Me=new T,Ne=new Ua,Ge=[],Ie=[],Le=new Float32Array(16),Ke=new Float32Array(9),Je=new Float32Array(4);Re.prototype.updateCache=function(a){var b=this.cache;a instanceof Float32Array&&b.length!==a.length&&(this.cache=new Float32Array(a.length));qa(b,a)};Se.prototype.setValue=function(a,b,c){for(var d=this.seq,e=0,f=d.length;e!==
17939 f;++e){var g=d[e];g.setValue(a,b[g.id],c)}};var Vd=/([\w\d_]+)(\])?(\[|\.)?/g;Za.prototype.setValue=function(a,b,c){b=this.map[b];void 0!==b&&b.setValue(a,c,this.renderer)};Za.prototype.setOptional=function(a,b,c){b=b[c];void 0!==b&&this.setValue(a,c,b)};Za.upload=function(a,b,c,d){for(var e=0,f=b.length;e!==f;++e){var g=b[e],h=c[g.id];!1!==h.needsUpdate&&g.setValue(a,h.value,d)}};Za.seqWithValue=function(a,b){for(var c=[],d=0,e=a.length;d!==e;++d){var f=a[d];f.id in b&&c.push(f)}return c};var yg=
17940 0,Hg=0;$a.prototype=Object.create(J.prototype);$a.prototype.constructor=$a;$a.prototype.isMeshDepthMaterial=!0;$a.prototype.copy=function(a){J.prototype.copy.call(this,a);this.depthPacking=a.depthPacking;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.map=a.map;this.alphaMap=a.alphaMap;this.displacementMap=a.displacementMap;this.displacementScale=a.displacementScale;this.displacementBias=a.displacementBias;this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;return this};
17941 ab.prototype=Object.create(J.prototype);ab.prototype.constructor=ab;ab.prototype.isMeshDistanceMaterial=!0;ab.prototype.copy=function(a){J.prototype.copy.call(this,a);this.referencePosition.copy(a.referencePosition);this.nearDistance=a.nearDistance;this.farDistance=a.farDistance;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.map=a.map;this.alphaMap=a.alphaMap;this.displacementMap=a.displacementMap;this.displacementScale=a.displacementScale;this.displacementBias=a.displacementBias;
17942 return this};Kb.prototype=Object.assign(Object.create(D.prototype),{constructor:Kb,isGroup:!0});Z.prototype=Object.assign(Object.create(Na.prototype),{constructor:Z,isPerspectiveCamera:!0,copy:function(a,b){Na.prototype.copy.call(this,a,b);this.fov=a.fov;this.zoom=a.zoom;this.near=a.near;this.far=a.far;this.focus=a.focus;this.aspect=a.aspect;this.view=null===a.view?null:Object.assign({},a.view);this.filmGauge=a.filmGauge;this.filmOffset=a.filmOffset;return this},setFocalLength:function(a){a=.5*this.getFilmHeight()/
17943 a;this.fov=2*H.RAD2DEG*Math.atan(a);this.updateProjectionMatrix()},getFocalLength:function(){var a=Math.tan(.5*H.DEG2RAD*this.fov);return.5*this.getFilmHeight()/a},getEffectiveFOV:function(){return 2*H.RAD2DEG*Math.atan(Math.tan(.5*H.DEG2RAD*this.fov)/this.zoom)},getFilmWidth:function(){return this.filmGauge*Math.min(this.aspect,1)},getFilmHeight:function(){return this.filmGauge/Math.max(this.aspect,1)},setViewOffset:function(a,b,c,d,e,f){this.aspect=a/b;null===this.view&&(this.view={enabled:!0,fullWidth:1,
17944 fullHeight:1,offsetX:0,offsetY:0,width:1,height:1});this.view.enabled=!0;this.view.fullWidth=a;this.view.fullHeight=b;this.view.offsetX=c;this.view.offsetY=d;this.view.width=e;this.view.height=f;this.updateProjectionMatrix()},clearViewOffset:function(){null!==this.view&&(this.view.enabled=!1);this.updateProjectionMatrix()},updateProjectionMatrix:function(){var a=this.near,b=a*Math.tan(.5*H.DEG2RAD*this.fov)/this.zoom,c=2*b,d=this.aspect*c,e=-.5*d,f=this.view;if(null!==this.view&&this.view.enabled){var g=
17945 f.fullWidth,h=f.fullHeight;e+=f.offsetX*d/g;b-=f.offsetY*c/h;d*=f.width/g;c*=f.height/h}f=this.filmOffset;0!==f&&(e+=a*f/this.getFilmWidth());this.projectionMatrix.makePerspective(e,e+d,b,b-c,a,this.far)},toJSON:function(a){a=D.prototype.toJSON.call(this,a);a.object.fov=this.fov;a.object.zoom=this.zoom;a.object.near=this.near;a.object.far=this.far;a.object.focus=this.focus;a.object.aspect=this.aspect;null!==this.view&&(a.object.view=Object.assign({},this.view));a.object.filmGauge=this.filmGauge;a.object.filmOffset=
17946 this.filmOffset;return a}});yc.prototype=Object.assign(Object.create(Z.prototype),{constructor:yc,isArrayCamera:!0});Lb.prototype.isFogExp2=!0;Lb.prototype.clone=function(){return new Lb(this.color,this.density)};Lb.prototype.toJSON=function(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}};Mb.prototype.isFog=!0;Mb.prototype.clone=function(){return new Mb(this.color,this.near,this.far)};Mb.prototype.toJSON=function(){return{type:"Fog",color:this.color.getHex(),near:this.near,
17947 far:this.far}};qd.prototype=Object.assign(Object.create(D.prototype),{constructor:qd,copy:function(a,b){D.prototype.copy.call(this,a,b);null!==a.background&&(this.background=a.background.clone());null!==a.fog&&(this.fog=a.fog.clone());null!==a.overrideMaterial&&(this.overrideMaterial=a.overrideMaterial.clone());this.autoUpdate=a.autoUpdate;this.matrixAutoUpdate=a.matrixAutoUpdate;return this},toJSON:function(a){var b=D.prototype.toJSON.call(this,a);null!==this.background&&(b.object.background=this.background.toJSON(a));
17948 null!==this.fog&&(b.object.fog=this.fog.toJSON());return b}});Object.defineProperty(ob.prototype,"needsUpdate",{set:function(a){!0===a&&this.version++}});Object.assign(ob.prototype,{isInterleavedBuffer:!0,onUploadCallback:function(){},setArray:function(a){if(Array.isArray(a))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.count=void 0!==a?a.length/this.stride:0;this.array=a;return this},setDynamic:function(a){this.dynamic=a;return this},copy:function(a){this.array=
17949 new a.array.constructor(a.array);this.count=a.count;this.stride=a.stride;this.dynamic=a.dynamic;return this},copyAt:function(a,b,c){a*=this.stride;c*=b.stride;for(var d=0,e=this.stride;d<e;d++)this.array[a+d]=b.array[c+d];return this},set:function(a,b){void 0===b&&(b=0);this.array.set(a,b);return this},clone:function(){return(new this.constructor).copy(this)},onUpload:function(a){this.onUploadCallback=a;return this}});Object.defineProperties(zc.prototype,{count:{get:function(){return this.data.count}},
17950 array:{get:function(){return this.data.array}}});Object.assign(zc.prototype,{isInterleavedBufferAttribute:!0,setX:function(a,b){this.data.array[a*this.data.stride+this.offset]=b;return this},setY:function(a,b){this.data.array[a*this.data.stride+this.offset+1]=b;return this},setZ:function(a,b){this.data.array[a*this.data.stride+this.offset+2]=b;return this},setW:function(a,b){this.data.array[a*this.data.stride+this.offset+3]=b;return this},getX:function(a){return this.data.array[a*this.data.stride+
17951 this.offset]},getY:function(a){return this.data.array[a*this.data.stride+this.offset+1]},getZ:function(a){return this.data.array[a*this.data.stride+this.offset+2]},getW:function(a){return this.data.array[a*this.data.stride+this.offset+3]},setXY:function(a,b,c){a=a*this.data.stride+this.offset;this.data.array[a+0]=b;this.data.array[a+1]=c;return this},setXYZ:function(a,b,c,d){a=a*this.data.stride+this.offset;this.data.array[a+0]=b;this.data.array[a+1]=c;this.data.array[a+2]=d;return this},setXYZW:function(a,
17952 b,c,d,e){a=a*this.data.stride+this.offset;this.data.array[a+0]=b;this.data.array[a+1]=c;this.data.array[a+2]=d;this.data.array[a+3]=e;return this}});cb.prototype=Object.create(J.prototype);cb.prototype.constructor=cb;cb.prototype.isSpriteMaterial=!0;cb.prototype.copy=function(a){J.prototype.copy.call(this,a);this.color.copy(a.color);this.map=a.map;this.rotation=a.rotation;return this};var Nb;Ac.prototype=Object.assign(Object.create(D.prototype),{constructor:Ac,isSprite:!0,raycast:function(){function a(a,
17953 b,c,d,h,k){e.subVectors(a,c).addScalar(.5).multiply(d);void 0!==h?(f.x=k*e.x-h*e.y,f.y=h*e.x+k*e.y):f.copy(e);a.copy(b);a.x+=f.x;a.y+=f.y;a.applyMatrix4(g)}var b=new p,c=new p,d=new p,e=new z,f=new z,g=new I,h=new p,k=new p,m=new p;return function(e,f){c.setFromMatrixScale(this.matrixWorld);g.getInverse(this.modelViewMatrix).premultiply(this.matrixWorld);d.setFromMatrixPosition(this.modelViewMatrix);var l=this.material.rotation;if(0!==l){var n=Math.cos(l);var q=Math.sin(l)}l=this.center;a(h.set(-.5,
17954 -.5,0),d,l,c,q,n);a(k.set(.5,-.5,0),d,l,c,q,n);a(m.set(.5,.5,0),d,l,c,q,n);var p=e.ray.intersectTriangle(h,k,m,!1,b);if(null===p&&(a(k.set(-.5,.5,0),d,l,c,q,n),p=e.ray.intersectTriangle(h,m,k,!1,b),null===p))return;q=e.ray.origin.distanceTo(b);q<e.near||q>e.far||f.push({distance:q,point:b.clone(),face:null,object:this})}}(),clone:function(){return(new this.constructor(this.material)).copy(this)},copy:function(a){D.prototype.copy.call(this,a);void 0!==a.center&&this.center.copy(a.center);return this}});
17955 Bc.prototype=Object.assign(Object.create(D.prototype),{constructor:Bc,copy:function(a){D.prototype.copy.call(this,a,!1);a=a.levels;for(var b=0,c=a.length;b<c;b++){var d=a[b];this.addLevel(d.object.clone(),d.distance)}return this},addLevel:function(a,b){void 0===b&&(b=0);b=Math.abs(b);for(var c=this.levels,d=0;d<c.length&&!(b<c[d].distance);d++);c.splice(d,0,{distance:b,object:a});this.add(a)},getObjectForDistance:function(a){for(var b=this.levels,c=1,d=b.length;c<d&&!(a<b[c].distance);c++);return b[c-
17956 1].object},raycast:function(){var a=new p;return function(b,c){a.setFromMatrixPosition(this.matrixWorld);var d=b.ray.origin.distanceTo(a);this.getObjectForDistance(d).raycast(b,c)}}(),update:function(){var a=new p,b=new p;return function(c){var d=this.levels;if(1<d.length){a.setFromMatrixPosition(c.matrixWorld);b.setFromMatrixPosition(this.matrixWorld);c=a.distanceTo(b);d[0].object.visible=!0;for(var e=1,f=d.length;e<f;e++)if(c>=d[e].distance)d[e-1].object.visible=!1,d[e].object.visible=!0;else break;
17957 for(;e<f;e++)d[e].object.visible=!1}}}(),toJSON:function(a){a=D.prototype.toJSON.call(this,a);a.object.levels=[];for(var b=this.levels,c=0,d=b.length;c<d;c++){var e=b[c];a.object.levels.push({object:e.object.uuid,distance:e.distance})}return a}});Object.assign(Cc.prototype,{calculateInverses:function(){this.boneInverses=[];for(var a=0,b=this.bones.length;a<b;a++){var c=new I;this.bones[a]&&c.getInverse(this.bones[a].matrixWorld);this.boneInverses.push(c)}},pose:function(){var a,b;var c=0;for(b=this.bones.length;c<
17958 b;c++)(a=this.bones[c])&&a.matrixWorld.getInverse(this.boneInverses[c]);c=0;for(b=this.bones.length;c<b;c++)if(a=this.bones[c])a.parent&&a.parent.isBone?(a.matrix.getInverse(a.parent.matrixWorld),a.matrix.multiply(a.matrixWorld)):a.matrix.copy(a.matrixWorld),a.matrix.decompose(a.position,a.quaternion,a.scale)},update:function(){var a=new I,b=new I;return function(){for(var c=this.bones,d=this.boneInverses,e=this.boneMatrices,f=this.boneTexture,g=0,h=c.length;g<h;g++)a.multiplyMatrices(c[g]?c[g].matrixWorld:
17959 b,d[g]),a.toArray(e,16*g);void 0!==f&&(f.needsUpdate=!0)}}(),clone:function(){return new Cc(this.bones,this.boneInverses)},getBoneByName:function(a){for(var b=0,c=this.bones.length;b<c;b++){var d=this.bones[b];if(d.name===a)return d}}});rd.prototype=Object.assign(Object.create(D.prototype),{constructor:rd,isBone:!0});sd.prototype=Object.assign(Object.create(la.prototype),{constructor:sd,isSkinnedMesh:!0,initBones:function(){var a=[],b;if(this.geometry&&void 0!==this.geometry.bones){var c=0;for(b=
17960 this.geometry.bones.length;c<b;c++){var d=this.geometry.bones[c];var e=new rd;a.push(e);e.name=d.name;e.position.fromArray(d.pos);e.quaternion.fromArray(d.rotq);void 0!==d.scl&&e.scale.fromArray(d.scl)}c=0;for(b=this.geometry.bones.length;c<b;c++)d=this.geometry.bones[c],-1!==d.parent&&null!==d.parent&&void 0!==a[d.parent]?a[d.parent].add(a[c]):this.add(a[c])}this.updateMatrixWorld(!0);return a},bind:function(a,b){this.skeleton=a;void 0===b&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),
17961 b=this.matrixWorld);this.bindMatrix.copy(b);this.bindMatrixInverse.getInverse(b)},pose:function(){this.skeleton.pose()},normalizeSkinWeights:function(){var a;if(this.geometry&&this.geometry.isGeometry)for(a=0;a<this.geometry.skinWeights.length;a++){var b=this.geometry.skinWeights[a];var c=1/b.manhattanLength();Infinity!==c?b.multiplyScalar(c):b.set(1,0,0,0)}else if(this.geometry&&this.geometry.isBufferGeometry){b=new V;var d=this.geometry.attributes.skinWeight;for(a=0;a<d.count;a++)b.x=d.getX(a),
17962 b.y=d.getY(a),b.z=d.getZ(a),b.w=d.getW(a),c=1/b.manhattanLength(),Infinity!==c?b.multiplyScalar(c):b.set(1,0,0,0),d.setXYZW(a,b.x,b.y,b.z,b.w)}},updateMatrixWorld:function(a){la.prototype.updateMatrixWorld.call(this,a);"attached"===this.bindMode?this.bindMatrixInverse.getInverse(this.matrixWorld):"detached"===this.bindMode?this.bindMatrixInverse.getInverse(this.bindMatrix):console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)},clone:function(){return(new this.constructor(this.geometry,
17963 this.material)).copy(this)}});Y.prototype=Object.create(J.prototype);Y.prototype.constructor=Y;Y.prototype.isLineBasicMaterial=!0;Y.prototype.copy=function(a){J.prototype.copy.call(this,a);this.color.copy(a.color);this.linewidth=a.linewidth;this.linecap=a.linecap;this.linejoin=a.linejoin;return this};sa.prototype=Object.assign(Object.create(D.prototype),{constructor:sa,isLine:!0,computeLineDistances:function(){var a=new p,b=new p;return function(){var c=this.geometry;if(c.isBufferGeometry)if(null===
17964 c.index){for(var d=c.attributes.position,e=[0],f=1,g=d.count;f<g;f++)a.fromBufferAttribute(d,f-1),b.fromBufferAttribute(d,f),e[f]=e[f-1],e[f]+=a.distanceTo(b);c.addAttribute("lineDistance",new A(e,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else if(c.isGeometry)for(d=c.vertices,e=c.lineDistances,e[0]=0,f=1,g=d.length;f<g;f++)e[f]=e[f-1],e[f]+=d[f-1].distanceTo(d[f]);return this}}(),raycast:function(){var a=new I,b=new mb,c=
17965 new Da;return function(d,e){var f=d.linePrecision;f*=f;var g=this.geometry,h=this.matrixWorld;null===g.boundingSphere&&g.computeBoundingSphere();c.copy(g.boundingSphere);c.applyMatrix4(h);if(!1!==d.ray.intersectsSphere(c)){a.getInverse(h);b.copy(d.ray).applyMatrix4(a);var k=new p,m=new p;h=new p;var l=new p,n=this&&this.isLineSegments?2:1;if(g.isBufferGeometry){var t=g.index,u=g.attributes.position.array;if(null!==t){t=t.array;g=0;for(var r=t.length-1;g<r;g+=n){var v=t[g+1];k.fromArray(u,3*t[g]);
17966 m.fromArray(u,3*v);v=b.distanceSqToSegment(k,m,l,h);v>f||(l.applyMatrix4(this.matrixWorld),v=d.ray.origin.distanceTo(l),v<d.near||v>d.far||e.push({distance:v,point:h.clone().applyMatrix4(this.matrixWorld),index:g,face:null,faceIndex:null,object:this}))}}else for(g=0,r=u.length/3-1;g<r;g+=n)k.fromArray(u,3*g),m.fromArray(u,3*g+3),v=b.distanceSqToSegment(k,m,l,h),v>f||(l.applyMatrix4(this.matrixWorld),v=d.ray.origin.distanceTo(l),v<d.near||v>d.far||e.push({distance:v,point:h.clone().applyMatrix4(this.matrixWorld),
17967 index:g,face:null,faceIndex:null,object:this}))}else if(g.isGeometry)for(k=g.vertices,m=k.length,g=0;g<m-1;g+=n)v=b.distanceSqToSegment(k[g],k[g+1],l,h),v>f||(l.applyMatrix4(this.matrixWorld),v=d.ray.origin.distanceTo(l),v<d.near||v>d.far||e.push({distance:v,point:h.clone().applyMatrix4(this.matrixWorld),index:g,face:null,faceIndex:null,object:this}))}}}(),clone:function(){return(new this.constructor(this.geometry,this.material)).copy(this)}});W.prototype=Object.assign(Object.create(sa.prototype),
17968 {constructor:W,isLineSegments:!0,computeLineDistances:function(){var a=new p,b=new p;return function(){var c=this.geometry;if(c.isBufferGeometry)if(null===c.index){for(var d=c.attributes.position,e=[],f=0,g=d.count;f<g;f+=2)a.fromBufferAttribute(d,f),b.fromBufferAttribute(d,f+1),e[f]=0===f?0:e[f-1],e[f+1]=e[f]+a.distanceTo(b);c.addAttribute("lineDistance",new A(e,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else if(c.isGeometry)for(d=
17969 c.vertices,e=c.lineDistances,f=0,g=d.length;f<g;f+=2)a.copy(d[f]),b.copy(d[f+1]),e[f]=0===f?0:e[f-1],e[f+1]=e[f]+a.distanceTo(b);return this}}()});td.prototype=Object.assign(Object.create(sa.prototype),{constructor:td,isLineLoop:!0});Ea.prototype=Object.create(J.prototype);Ea.prototype.constructor=Ea;Ea.prototype.isPointsMaterial=!0;Ea.prototype.copy=function(a){J.prototype.copy.call(this,a);this.color.copy(a.color);this.map=a.map;this.size=a.size;this.sizeAttenuation=a.sizeAttenuation;this.morphTargets=
17970 a.morphTargets;return this};Ob.prototype=Object.assign(Object.create(D.prototype),{constructor:Ob,isPoints:!0,raycast:function(){var a=new I,b=new mb,c=new Da;return function(d,e){function f(a,c){var f=b.distanceSqToPoint(a);f<l&&(b.closestPointToPoint(a,n),n.applyMatrix4(k),a=d.ray.origin.distanceTo(n),a<d.near||a>d.far||e.push({distance:a,distanceToRay:Math.sqrt(f),point:n.clone(),index:c,face:null,object:g}))}var g=this,h=this.geometry,k=this.matrixWorld,m=d.params.Points.threshold;null===h.boundingSphere&&
17971 h.computeBoundingSphere();c.copy(h.boundingSphere);c.applyMatrix4(k);c.radius+=m;if(!1!==d.ray.intersectsSphere(c)){a.getInverse(k);b.copy(d.ray).applyMatrix4(a);m/=(this.scale.x+this.scale.y+this.scale.z)/3;var l=m*m;m=new p;var n=new p;if(h.isBufferGeometry){var t=h.index;h=h.attributes.position.array;if(null!==t){var u=t.array;t=0;for(var r=u.length;t<r;t++){var v=u[t];m.fromArray(h,3*v);f(m,v)}}else for(t=0,u=h.length/3;t<u;t++)m.fromArray(h,3*t),f(m,t)}else for(m=h.vertices,t=0,u=m.length;t<
17972 u;t++)f(m[t],t)}}}(),clone:function(){return(new this.constructor(this.geometry,this.material)).copy(this)}});$d.prototype=Object.assign(Object.create(T.prototype),{constructor:$d,isVideoTexture:!0,update:function(){var a=this.image;a.readyState>=a.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}});Pb.prototype=Object.create(T.prototype);Pb.prototype.constructor=Pb;Pb.prototype.isCompressedTexture=!0;Dc.prototype=Object.create(T.prototype);Dc.prototype.constructor=Dc;Dc.prototype.isCanvasTexture=!0;Ec.prototype=
17973 Object.create(T.prototype);Ec.prototype.constructor=Ec;Ec.prototype.isDepthTexture=!0;Qb.prototype=Object.create(C.prototype);Qb.prototype.constructor=Qb;Fc.prototype=Object.create(R.prototype);Fc.prototype.constructor=Fc;Rb.prototype=Object.create(C.prototype);Rb.prototype.constructor=Rb;Gc.prototype=Object.create(R.prototype);Gc.prototype.constructor=Gc;na.prototype=Object.create(C.prototype);na.prototype.constructor=na;Hc.prototype=Object.create(R.prototype);Hc.prototype.constructor=Hc;Sb.prototype=
17974 Object.create(na.prototype);Sb.prototype.constructor=Sb;Ic.prototype=Object.create(R.prototype);Ic.prototype.constructor=Ic;pb.prototype=Object.create(na.prototype);pb.prototype.constructor=pb;Jc.prototype=Object.create(R.prototype);Jc.prototype.constructor=Jc;Tb.prototype=Object.create(na.prototype);Tb.prototype.constructor=Tb;Kc.prototype=Object.create(R.prototype);Kc.prototype.constructor=Kc;Ub.prototype=Object.create(na.prototype);Ub.prototype.constructor=Ub;Lc.prototype=Object.create(R.prototype);
17975 Lc.prototype.constructor=Lc;Vb.prototype=Object.create(C.prototype);Vb.prototype.constructor=Vb;Mc.prototype=Object.create(R.prototype);Mc.prototype.constructor=Mc;Wb.prototype=Object.create(C.prototype);Wb.prototype.constructor=Wb;Nc.prototype=Object.create(R.prototype);Nc.prototype.constructor=Nc;Xb.prototype=Object.create(C.prototype);Xb.prototype.constructor=Xb;var Ug={triangulate:function(a,b,c){c=c||2;var d=b&&b.length,e=d?b[0]*c:a.length,f=bf(a,0,e,c,!0),g=[];if(!f)return g;var h;if(d){var k=
17976 c;d=[];var m;var l=0;for(m=b.length;l<m;l++){var n=b[l]*k;var t=l<m-1?b[l+1]*k:a.length;n=bf(a,n,t,k,!1);n===n.next&&(n.steiner=!0);d.push(Pg(n))}d.sort(Ng);for(l=0;l<d.length;l++){b=d[l];k=f;if(k=Og(b,k))b=ef(k,b),Pc(b,b.next);f=Pc(f,f.next)}}if(a.length>80*c){var p=h=a[0];var r=d=a[1];for(k=c;k<e;k+=c)l=a[k],b=a[k+1],l<p&&(p=l),b<r&&(r=b),l>h&&(h=l),b>d&&(d=b);h=Math.max(h-p,d-r);h=0!==h?1/h:0}Qc(f,g,c,p,r,h);return g}},Va={area:function(a){for(var b=a.length,c=0,d=b-1,e=0;e<b;d=e++)c+=a[d].x*a[e].y-
17977 a[e].x*a[d].y;return.5*c},isClockWise:function(a){return 0>Va.area(a)},triangulateShape:function(a,b){var c=[],d=[],e=[];ff(a);gf(c,a);var f=a.length;b.forEach(ff);for(a=0;a<b.length;a++)d.push(f),f+=b[a].length,gf(c,b[a]);b=Ug.triangulate(c,d);for(a=0;a<b.length;a+=3)e.push(b.slice(a,a+3));return e}};rb.prototype=Object.create(R.prototype);rb.prototype.constructor=rb;rb.prototype.toJSON=function(){var a=R.prototype.toJSON.call(this);return hf(this.parameters.shapes,this.parameters.options,a)};Oa.prototype=
17978 Object.create(C.prototype);Oa.prototype.constructor=Oa;Oa.prototype.toJSON=function(){var a=C.prototype.toJSON.call(this);return hf(this.parameters.shapes,this.parameters.options,a)};var Qg={generateTopUV:function(a,b,c,d,e){a=b[3*d];d=b[3*d+1];var f=b[3*e];e=b[3*e+1];return[new z(b[3*c],b[3*c+1]),new z(a,d),new z(f,e)]},generateSideWallUV:function(a,b,c,d,e,f){a=b[3*c];var g=b[3*c+1];c=b[3*c+2];var h=b[3*d],k=b[3*d+1];d=b[3*d+2];var m=b[3*e],l=b[3*e+1];e=b[3*e+2];var n=b[3*f],t=b[3*f+1];b=b[3*f+
17979 2];return.01>Math.abs(g-k)?[new z(a,1-c),new z(h,1-d),new z(m,1-e),new z(n,1-b)]:[new z(g,1-c),new z(k,1-d),new z(l,1-e),new z(t,1-b)]}};Sc.prototype=Object.create(R.prototype);Sc.prototype.constructor=Sc;Yb.prototype=Object.create(Oa.prototype);Yb.prototype.constructor=Yb;Tc.prototype=Object.create(R.prototype);Tc.prototype.constructor=Tc;sb.prototype=Object.create(C.prototype);sb.prototype.constructor=sb;Uc.prototype=Object.create(R.prototype);Uc.prototype.constructor=Uc;Zb.prototype=Object.create(C.prototype);
17980 Zb.prototype.constructor=Zb;Vc.prototype=Object.create(R.prototype);Vc.prototype.constructor=Vc;$b.prototype=Object.create(C.prototype);$b.prototype.constructor=$b;tb.prototype=Object.create(R.prototype);tb.prototype.constructor=tb;tb.prototype.toJSON=function(){var a=R.prototype.toJSON.call(this);return jf(this.parameters.shapes,a)};ub.prototype=Object.create(C.prototype);ub.prototype.constructor=ub;ub.prototype.toJSON=function(){var a=C.prototype.toJSON.call(this);return jf(this.parameters.shapes,
17981 a)};ac.prototype=Object.create(C.prototype);ac.prototype.constructor=ac;vb.prototype=Object.create(R.prototype);vb.prototype.constructor=vb;Wa.prototype=Object.create(C.prototype);Wa.prototype.constructor=Wa;Wc.prototype=Object.create(vb.prototype);Wc.prototype.constructor=Wc;Xc.prototype=Object.create(Wa.prototype);Xc.prototype.constructor=Xc;Yc.prototype=Object.create(R.prototype);Yc.prototype.constructor=Yc;bc.prototype=Object.create(C.prototype);bc.prototype.constructor=bc;var xa=Object.freeze({WireframeGeometry:Qb,
17982 ParametricGeometry:Fc,ParametricBufferGeometry:Rb,TetrahedronGeometry:Hc,TetrahedronBufferGeometry:Sb,OctahedronGeometry:Ic,OctahedronBufferGeometry:pb,IcosahedronGeometry:Jc,IcosahedronBufferGeometry:Tb,DodecahedronGeometry:Kc,DodecahedronBufferGeometry:Ub,PolyhedronGeometry:Gc,PolyhedronBufferGeometry:na,TubeGeometry:Lc,TubeBufferGeometry:Vb,TorusKnotGeometry:Mc,TorusKnotBufferGeometry:Wb,TorusGeometry:Nc,TorusBufferGeometry:Xb,TextGeometry:Sc,TextBufferGeometry:Yb,SphereGeometry:Tc,SphereBufferGeometry:sb,
17983 RingGeometry:Uc,RingBufferGeometry:Zb,PlaneGeometry:uc,PlaneBufferGeometry:lb,LatheGeometry:Vc,LatheBufferGeometry:$b,ShapeGeometry:tb,ShapeBufferGeometry:ub,ExtrudeGeometry:rb,ExtrudeBufferGeometry:Oa,EdgesGeometry:ac,ConeGeometry:Wc,ConeBufferGeometry:Xc,CylinderGeometry:vb,CylinderBufferGeometry:Wa,CircleGeometry:Yc,CircleBufferGeometry:bc,BoxGeometry:Ib,BoxBufferGeometry:kb});wb.prototype=Object.create(J.prototype);wb.prototype.constructor=wb;wb.prototype.isShadowMaterial=!0;wb.prototype.copy=
17984 function(a){J.prototype.copy.call(this,a);this.color.copy(a.color);return this};cc.prototype=Object.create(ta.prototype);cc.prototype.constructor=cc;cc.prototype.isRawShaderMaterial=!0;Pa.prototype=Object.create(J.prototype);Pa.prototype.constructor=Pa;Pa.prototype.isMeshStandardMaterial=!0;Pa.prototype.copy=function(a){J.prototype.copy.call(this,a);this.defines={STANDARD:""};this.color.copy(a.color);this.roughness=a.roughness;this.metalness=a.metalness;this.map=a.map;this.lightMap=a.lightMap;this.lightMapIntensity=
17985 a.lightMapIntensity;this.aoMap=a.aoMap;this.aoMapIntensity=a.aoMapIntensity;this.emissive.copy(a.emissive);this.emissiveMap=a.emissiveMap;this.emissiveIntensity=a.emissiveIntensity;this.bumpMap=a.bumpMap;this.bumpScale=a.bumpScale;this.normalMap=a.normalMap;this.normalMapType=a.normalMapType;this.normalScale.copy(a.normalScale);this.displacementMap=a.displacementMap;this.displacementScale=a.displacementScale;this.displacementBias=a.displacementBias;this.roughnessMap=a.roughnessMap;this.metalnessMap=
17986 a.metalnessMap;this.alphaMap=a.alphaMap;this.envMap=a.envMap;this.envMapIntensity=a.envMapIntensity;this.refractionRatio=a.refractionRatio;this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;this.wireframeLinecap=a.wireframeLinecap;this.wireframeLinejoin=a.wireframeLinejoin;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;return this};xb.prototype=Object.create(Pa.prototype);xb.prototype.constructor=xb;xb.prototype.isMeshPhysicalMaterial=
17987 !0;xb.prototype.copy=function(a){Pa.prototype.copy.call(this,a);this.defines={PHYSICAL:""};this.reflectivity=a.reflectivity;this.clearCoat=a.clearCoat;this.clearCoatRoughness=a.clearCoatRoughness;return this};Fa.prototype=Object.create(J.prototype);Fa.prototype.constructor=Fa;Fa.prototype.isMeshPhongMaterial=!0;Fa.prototype.copy=function(a){J.prototype.copy.call(this,a);this.color.copy(a.color);this.specular.copy(a.specular);this.shininess=a.shininess;this.map=a.map;this.lightMap=a.lightMap;this.lightMapIntensity=
17988 a.lightMapIntensity;this.aoMap=a.aoMap;this.aoMapIntensity=a.aoMapIntensity;this.emissive.copy(a.emissive);this.emissiveMap=a.emissiveMap;this.emissiveIntensity=a.emissiveIntensity;this.bumpMap=a.bumpMap;this.bumpScale=a.bumpScale;this.normalMap=a.normalMap;this.normalMapType=a.normalMapType;this.normalScale.copy(a.normalScale);this.displacementMap=a.displacementMap;this.displacementScale=a.displacementScale;this.displacementBias=a.displacementBias;this.specularMap=a.specularMap;this.alphaMap=a.alphaMap;
17989 this.envMap=a.envMap;this.combine=a.combine;this.reflectivity=a.reflectivity;this.refractionRatio=a.refractionRatio;this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;this.wireframeLinecap=a.wireframeLinecap;this.wireframeLinejoin=a.wireframeLinejoin;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;return this};yb.prototype=Object.create(Fa.prototype);yb.prototype.constructor=yb;yb.prototype.isMeshToonMaterial=!0;yb.prototype.copy=function(a){Fa.prototype.copy.call(this,
17990 a);this.gradientMap=a.gradientMap;return this};zb.prototype=Object.create(J.prototype);zb.prototype.constructor=zb;zb.prototype.isMeshNormalMaterial=!0;zb.prototype.copy=function(a){J.prototype.copy.call(this,a);this.bumpMap=a.bumpMap;this.bumpScale=a.bumpScale;this.normalMap=a.normalMap;this.normalMapType=a.normalMapType;this.normalScale.copy(a.normalScale);this.displacementMap=a.displacementMap;this.displacementScale=a.displacementScale;this.displacementBias=a.displacementBias;this.wireframe=a.wireframe;
17991 this.wireframeLinewidth=a.wireframeLinewidth;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;return this};Ab.prototype=Object.create(J.prototype);Ab.prototype.constructor=Ab;Ab.prototype.isMeshLambertMaterial=!0;Ab.prototype.copy=function(a){J.prototype.copy.call(this,a);this.color.copy(a.color);this.map=a.map;this.lightMap=a.lightMap;this.lightMapIntensity=a.lightMapIntensity;this.aoMap=a.aoMap;this.aoMapIntensity=a.aoMapIntensity;this.emissive.copy(a.emissive);
17992 this.emissiveMap=a.emissiveMap;this.emissiveIntensity=a.emissiveIntensity;this.specularMap=a.specularMap;this.alphaMap=a.alphaMap;this.envMap=a.envMap;this.combine=a.combine;this.reflectivity=a.reflectivity;this.refractionRatio=a.refractionRatio;this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;this.wireframeLinecap=a.wireframeLinecap;this.wireframeLinejoin=a.wireframeLinejoin;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;return this};
17993 Bb.prototype=Object.create(Y.prototype);Bb.prototype.constructor=Bb;Bb.prototype.isLineDashedMaterial=!0;Bb.prototype.copy=function(a){Y.prototype.copy.call(this,a);this.scale=a.scale;this.dashSize=a.dashSize;this.gapSize=a.gapSize;return this};var Vg=Object.freeze({ShadowMaterial:wb,SpriteMaterial:cb,RawShaderMaterial:cc,ShaderMaterial:ta,PointsMaterial:Ea,MeshPhysicalMaterial:xb,MeshStandardMaterial:Pa,MeshPhongMaterial:Fa,MeshToonMaterial:yb,MeshNormalMaterial:zb,MeshLambertMaterial:Ab,MeshDepthMaterial:$a,
17994 MeshDistanceMaterial:ab,MeshBasicMaterial:da,LineDashedMaterial:Bb,LineBasicMaterial:Y,Material:J}),Fb={enabled:!1,files:{},add:function(a,b){!1!==this.enabled&&(this.files[a]=b)},get:function(a){if(!1!==this.enabled)return this.files[a]},remove:function(a){delete this.files[a]},clear:function(){this.files={}}},ka=new ce,Ya={};Object.assign(Ga.prototype,{load:function(a,b,c,d){void 0===a&&(a="");void 0!==this.path&&(a=this.path+a);a=this.manager.resolveURL(a);var e=this,f=Fb.get(a);if(void 0!==f)return e.manager.itemStart(a),
17995 setTimeout(function(){b&&b(f);e.manager.itemEnd(a)},0),f;if(void 0!==Ya[a])Ya[a].push({onLoad:b,onProgress:c,onError:d});else{var g=a.match(/^data:(.*?)(;base64)?,(.*)$/);if(g){c=g[1];var h=!!g[2];g=g[3];g=window.decodeURIComponent(g);h&&(g=window.atob(g));try{var k=(this.responseType||"").toLowerCase();switch(k){case "arraybuffer":case "blob":var m=new Uint8Array(g.length);for(h=0;h<g.length;h++)m[h]=g.charCodeAt(h);var l="blob"===k?new Blob([m.buffer],{type:c}):m.buffer;break;case "document":l=
17996 (new DOMParser).parseFromString(g,c);break;case "json":l=JSON.parse(g);break;default:l=g}window.setTimeout(function(){b&&b(l);e.manager.itemEnd(a)},0)}catch(t){window.setTimeout(function(){d&&d(t);e.manager.itemEnd(a);e.manager.itemError(a)},0)}}else{Ya[a]=[];Ya[a].push({onLoad:b,onProgress:c,onError:d});var n=new XMLHttpRequest;n.open("GET",a,!0);n.addEventListener("load",function(b){var c=this.response;Fb.add(a,c);var d=Ya[a];delete Ya[a];if(200===this.status||0===this.status){0===this.status&&
17997 console.warn("THREE.FileLoader: HTTP Status 0 received.");for(var f=0,g=d.length;f<g;f++){var h=d[f];if(h.onLoad)h.onLoad(c)}e.manager.itemEnd(a)}else{f=0;for(g=d.length;f<g;f++)if(h=d[f],h.onError)h.onError(b);e.manager.itemEnd(a);e.manager.itemError(a)}},!1);n.addEventListener("progress",function(b){for(var c=Ya[a],d=0,e=c.length;d<e;d++){var f=c[d];if(f.onProgress)f.onProgress(b)}},!1);n.addEventListener("error",function(b){var c=Ya[a];delete Ya[a];for(var d=0,f=c.length;d<f;d++){var g=c[d];if(g.onError)g.onError(b)}e.manager.itemEnd(a);
17998 e.manager.itemError(a)},!1);void 0!==this.responseType&&(n.responseType=this.responseType);void 0!==this.withCredentials&&(n.withCredentials=this.withCredentials);n.overrideMimeType&&n.overrideMimeType(void 0!==this.mimeType?this.mimeType:"text/plain");for(h in this.requestHeader)n.setRequestHeader(h,this.requestHeader[h]);n.send(null)}e.manager.itemStart(a);return n}},setPath:function(a){this.path=a;return this},setResponseType:function(a){this.responseType=a;return this},setWithCredentials:function(a){this.withCredentials=
17999 a;return this},setMimeType:function(a){this.mimeType=a;return this},setRequestHeader:function(a){this.requestHeader=a;return this}});Object.assign(kf.prototype,{load:function(a,b,c,d){function e(e){k.load(a[e],function(a){a=f._parser(a,!0);g[e]={width:a.width,height:a.height,format:a.format,mipmaps:a.mipmaps};m+=1;6===m&&(1===a.mipmapCount&&(h.minFilter=1006),h.format=a.format,h.needsUpdate=!0,b&&b(h))},c,d)}var f=this,g=[],h=new Pb;h.image=g;var k=new Ga(this.manager);k.setPath(this.path);k.setResponseType("arraybuffer");
18000 if(Array.isArray(a))for(var m=0,l=0,n=a.length;l<n;++l)e(l);else k.load(a,function(a){a=f._parser(a,!0);if(a.isCubemap)for(var c=a.mipmaps.length/a.mipmapCount,d=0;d<c;d++){g[d]={mipmaps:[]};for(var e=0;e<a.mipmapCount;e++)g[d].mipmaps.push(a.mipmaps[d*a.mipmapCount+e]),g[d].format=a.format,g[d].width=a.width,g[d].height=a.height}else h.image.width=a.width,h.image.height=a.height,h.mipmaps=a.mipmaps;1===a.mipmapCount&&(h.minFilter=1006);h.format=a.format;h.needsUpdate=!0;b&&b(h)},c,d);return h},setPath:function(a){this.path=
18001 a;return this}});Object.assign(de.prototype,{load:function(a,b,c,d){var e=this,f=new gb,g=new Ga(this.manager);g.setResponseType("arraybuffer");g.load(a,function(a){if(a=e._parser(a))void 0!==a.image?f.image=a.image:void 0!==a.data&&(f.image.width=a.width,f.image.height=a.height,f.image.data=a.data),f.wrapS=void 0!==a.wrapS?a.wrapS:1001,f.wrapT=void 0!==a.wrapT?a.wrapT:1001,f.magFilter=void 0!==a.magFilter?a.magFilter:1006,f.minFilter=void 0!==a.minFilter?a.minFilter:1008,f.anisotropy=void 0!==a.anisotropy?
18002 a.anisotropy:1,void 0!==a.format&&(f.format=a.format),void 0!==a.type&&(f.type=a.type),void 0!==a.mipmaps&&(f.mipmaps=a.mipmaps),1===a.mipmapCount&&(f.minFilter=1006),f.needsUpdate=!0,b&&b(f,a)},c,d);return f}});Object.assign(Zc.prototype,{crossOrigin:"anonymous",load:function(a,b,c,d){function e(){k.removeEventListener("load",e,!1);k.removeEventListener("error",f,!1);Fb.add(a,this);b&&b(this);g.manager.itemEnd(a)}function f(b){k.removeEventListener("load",e,!1);k.removeEventListener("error",f,!1);
18003 d&&d(b);g.manager.itemEnd(a);g.manager.itemError(a)}void 0===a&&(a="");void 0!==this.path&&(a=this.path+a);a=this.manager.resolveURL(a);var g=this,h=Fb.get(a);if(void 0!==h)return g.manager.itemStart(a),setTimeout(function(){b&&b(h);g.manager.itemEnd(a)},0),h;var k=document.createElementNS("http://www.w3.org/1999/xhtml","img");k.addEventListener("load",e,!1);k.addEventListener("error",f,!1);"data:"!==a.substr(0,5)&&void 0!==this.crossOrigin&&(k.crossOrigin=this.crossOrigin);g.manager.itemStart(a);
18004 k.src=a;return k},setCrossOrigin:function(a){this.crossOrigin=a;return this},setPath:function(a){this.path=a;return this}});Object.assign(ee.prototype,{crossOrigin:"anonymous",load:function(a,b,c,d){function e(c){g.load(a[c],function(a){f.images[c]=a;h++;6===h&&(f.needsUpdate=!0,b&&b(f))},void 0,d)}var f=new Ua,g=new Zc(this.manager);g.setCrossOrigin(this.crossOrigin);g.setPath(this.path);var h=0;for(c=0;c<a.length;++c)e(c);return f},setCrossOrigin:function(a){this.crossOrigin=a;return this},setPath:function(a){this.path=
18005 a;return this}});Object.assign(vd.prototype,{crossOrigin:"anonymous",load:function(a,b,c,d){var e=new T,f=new Zc(this.manager);f.setCrossOrigin(this.crossOrigin);f.setPath(this.path);f.load(a,function(c){e.image=c;c=0<a.search(/\.(jpg|jpeg)$/)||0===a.search(/^data:image\/jpeg/);e.format=c?1022:1023;e.needsUpdate=!0;void 0!==b&&b(e)},c,d);return e},setCrossOrigin:function(a){this.crossOrigin=a;return this},setPath:function(a){this.path=a;return this}});Object.assign(L.prototype,{getPoint:function(){console.warn("THREE.Curve: .getPoint() not implemented.");
18006 return null},getPointAt:function(a,b){a=this.getUtoTmapping(a);return this.getPoint(a,b)},getPoints:function(a){void 0===a&&(a=5);for(var b=[],c=0;c<=a;c++)b.push(this.getPoint(c/a));return b},getSpacedPoints:function(a){void 0===a&&(a=5);for(var b=[],c=0;c<=a;c++)b.push(this.getPointAt(c/a));return b},getLength:function(){var a=this.getLengths();return a[a.length-1]},getLengths:function(a){void 0===a&&(a=this.arcLengthDivisions);if(this.cacheArcLengths&&this.cacheArcLengths.length===a+1&&!this.needsUpdate)return this.cacheArcLengths;
18007 this.needsUpdate=!1;var b=[],c=this.getPoint(0),d,e=0;b.push(0);for(d=1;d<=a;d++){var f=this.getPoint(d/a);e+=f.distanceTo(c);b.push(e);c=f}return this.cacheArcLengths=b},updateArcLengths:function(){this.needsUpdate=!0;this.getLengths()},getUtoTmapping:function(a,b){var c=this.getLengths(),d=c.length;b=b?b:a*c[d-1];for(var e=0,f=d-1,g;e<=f;)if(a=Math.floor(e+(f-e)/2),g=c[a]-b,0>g)e=a+1;else if(0<g)f=a-1;else{f=a;break}a=f;if(c[a]===b)return a/(d-1);e=c[a];return(a+(b-e)/(c[a+1]-e))/(d-1)},getTangent:function(a){var b=
18008 a-1E-4;a+=1E-4;0>b&&(b=0);1<a&&(a=1);b=this.getPoint(b);return this.getPoint(a).clone().sub(b).normalize()},getTangentAt:function(a){a=this.getUtoTmapping(a);return this.getTangent(a)},computeFrenetFrames:function(a,b){var c=new p,d=[],e=[],f=[],g=new p,h=new I,k;for(k=0;k<=a;k++){var m=k/a;d[k]=this.getTangentAt(m);d[k].normalize()}e[0]=new p;f[0]=new p;k=Number.MAX_VALUE;m=Math.abs(d[0].x);var l=Math.abs(d[0].y),n=Math.abs(d[0].z);m<=k&&(k=m,c.set(1,0,0));l<=k&&(k=l,c.set(0,1,0));n<=k&&c.set(0,
18009 0,1);g.crossVectors(d[0],c).normalize();e[0].crossVectors(d[0],g);f[0].crossVectors(d[0],e[0]);for(k=1;k<=a;k++)e[k]=e[k-1].clone(),f[k]=f[k-1].clone(),g.crossVectors(d[k-1],d[k]),g.length()>Number.EPSILON&&(g.normalize(),c=Math.acos(H.clamp(d[k-1].dot(d[k]),-1,1)),e[k].applyMatrix4(h.makeRotationAxis(g,c))),f[k].crossVectors(d[k],e[k]);if(!0===b)for(c=Math.acos(H.clamp(e[0].dot(e[a]),-1,1)),c/=a,0<d[0].dot(g.crossVectors(e[0],e[a]))&&(c=-c),k=1;k<=a;k++)e[k].applyMatrix4(h.makeRotationAxis(d[k],
18010 c*k)),f[k].crossVectors(d[k],e[k]);return{tangents:d,normals:e,binormals:f}},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.arcLengthDivisions=a.arcLengthDivisions;return this},toJSON:function(){var a={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};a.arcLengthDivisions=this.arcLengthDivisions;a.type=this.type;return a},fromJSON:function(a){this.arcLengthDivisions=a.arcLengthDivisions;return this}});za.prototype=Object.create(L.prototype);za.prototype.constructor=
18011 za;za.prototype.isEllipseCurve=!0;za.prototype.getPoint=function(a,b){b=b||new z;for(var c=2*Math.PI,d=this.aEndAngle-this.aStartAngle,e=Math.abs(d)<Number.EPSILON;0>d;)d+=c;for(;d>c;)d-=c;d<Number.EPSILON&&(d=e?0:c);!0!==this.aClockwise||e||(d=d===c?-c:d-c);c=this.aStartAngle+a*d;a=this.aX+this.xRadius*Math.cos(c);var f=this.aY+this.yRadius*Math.sin(c);0!==this.aRotation&&(c=Math.cos(this.aRotation),d=Math.sin(this.aRotation),e=a-this.aX,f-=this.aY,a=e*c-f*d+this.aX,f=e*d+f*c+this.aY);return b.set(a,
18012 f)};za.prototype.copy=function(a){L.prototype.copy.call(this,a);this.aX=a.aX;this.aY=a.aY;this.xRadius=a.xRadius;this.yRadius=a.yRadius;this.aStartAngle=a.aStartAngle;this.aEndAngle=a.aEndAngle;this.aClockwise=a.aClockwise;this.aRotation=a.aRotation;return this};za.prototype.toJSON=function(){var a=L.prototype.toJSON.call(this);a.aX=this.aX;a.aY=this.aY;a.xRadius=this.xRadius;a.yRadius=this.yRadius;a.aStartAngle=this.aStartAngle;a.aEndAngle=this.aEndAngle;a.aClockwise=this.aClockwise;a.aRotation=
18013 this.aRotation;return a};za.prototype.fromJSON=function(a){L.prototype.fromJSON.call(this,a);this.aX=a.aX;this.aY=a.aY;this.xRadius=a.xRadius;this.yRadius=a.yRadius;this.aStartAngle=a.aStartAngle;this.aEndAngle=a.aEndAngle;this.aClockwise=a.aClockwise;this.aRotation=a.aRotation;return this};dc.prototype=Object.create(za.prototype);dc.prototype.constructor=dc;dc.prototype.isArcCurve=!0;var Od=new p,Ae=new fe,Be=new fe,Ce=new fe;ca.prototype=Object.create(L.prototype);ca.prototype.constructor=ca;ca.prototype.isCatmullRomCurve3=
18014 !0;ca.prototype.getPoint=function(a,b){b=b||new p;var c=this.points,d=c.length;a*=d-(this.closed?0:1);var e=Math.floor(a);a-=e;this.closed?e+=0<e?0:(Math.floor(Math.abs(e)/d)+1)*d:0===a&&e===d-1&&(e=d-2,a=1);if(this.closed||0<e)var f=c[(e-1)%d];else Od.subVectors(c[0],c[1]).add(c[0]),f=Od;var g=c[e%d];var h=c[(e+1)%d];this.closed||e+2<d?c=c[(e+2)%d]:(Od.subVectors(c[d-1],c[d-2]).add(c[d-1]),c=Od);if("centripetal"===this.curveType||"chordal"===this.curveType){var k="chordal"===this.curveType?.5:.25;
18015 d=Math.pow(f.distanceToSquared(g),k);e=Math.pow(g.distanceToSquared(h),k);k=Math.pow(h.distanceToSquared(c),k);1E-4>e&&(e=1);1E-4>d&&(d=e);1E-4>k&&(k=e);Ae.initNonuniformCatmullRom(f.x,g.x,h.x,c.x,d,e,k);Be.initNonuniformCatmullRom(f.y,g.y,h.y,c.y,d,e,k);Ce.initNonuniformCatmullRom(f.z,g.z,h.z,c.z,d,e,k)}else"catmullrom"===this.curveType&&(Ae.initCatmullRom(f.x,g.x,h.x,c.x,this.tension),Be.initCatmullRom(f.y,g.y,h.y,c.y,this.tension),Ce.initCatmullRom(f.z,g.z,h.z,c.z,this.tension));b.set(Ae.calc(a),
18016 Be.calc(a),Ce.calc(a));return b};ca.prototype.copy=function(a){L.prototype.copy.call(this,a);this.points=[];for(var b=0,c=a.points.length;b<c;b++)this.points.push(a.points[b].clone());this.closed=a.closed;this.curveType=a.curveType;this.tension=a.tension;return this};ca.prototype.toJSON=function(){var a=L.prototype.toJSON.call(this);a.points=[];for(var b=0,c=this.points.length;b<c;b++)a.points.push(this.points[b].toArray());a.closed=this.closed;a.curveType=this.curveType;a.tension=this.tension;return a};
18017 ca.prototype.fromJSON=function(a){L.prototype.fromJSON.call(this,a);this.points=[];for(var b=0,c=a.points.length;b<c;b++){var d=a.points[b];this.points.push((new p).fromArray(d))}this.closed=a.closed;this.curveType=a.curveType;this.tension=a.tension;return this};Ha.prototype=Object.create(L.prototype);Ha.prototype.constructor=Ha;Ha.prototype.isCubicBezierCurve=!0;Ha.prototype.getPoint=function(a,b){b=b||new z;var c=this.v0,d=this.v1,e=this.v2,f=this.v3;b.set(ad(a,c.x,d.x,e.x,f.x),ad(a,c.y,d.y,e.y,
18018 f.y));return b};Ha.prototype.copy=function(a){L.prototype.copy.call(this,a);this.v0.copy(a.v0);this.v1.copy(a.v1);this.v2.copy(a.v2);this.v3.copy(a.v3);return this};Ha.prototype.toJSON=function(){var a=L.prototype.toJSON.call(this);a.v0=this.v0.toArray();a.v1=this.v1.toArray();a.v2=this.v2.toArray();a.v3=this.v3.toArray();return a};Ha.prototype.fromJSON=function(a){L.prototype.fromJSON.call(this,a);this.v0.fromArray(a.v0);this.v1.fromArray(a.v1);this.v2.fromArray(a.v2);this.v3.fromArray(a.v3);return this};
18019 Qa.prototype=Object.create(L.prototype);Qa.prototype.constructor=Qa;Qa.prototype.isCubicBezierCurve3=!0;Qa.prototype.getPoint=function(a,b){b=b||new p;var c=this.v0,d=this.v1,e=this.v2,f=this.v3;b.set(ad(a,c.x,d.x,e.x,f.x),ad(a,c.y,d.y,e.y,f.y),ad(a,c.z,d.z,e.z,f.z));return b};Qa.prototype.copy=function(a){L.prototype.copy.call(this,a);this.v0.copy(a.v0);this.v1.copy(a.v1);this.v2.copy(a.v2);this.v3.copy(a.v3);return this};Qa.prototype.toJSON=function(){var a=L.prototype.toJSON.call(this);a.v0=this.v0.toArray();
18020 a.v1=this.v1.toArray();a.v2=this.v2.toArray();a.v3=this.v3.toArray();return a};Qa.prototype.fromJSON=function(a){L.prototype.fromJSON.call(this,a);this.v0.fromArray(a.v0);this.v1.fromArray(a.v1);this.v2.fromArray(a.v2);this.v3.fromArray(a.v3);return this};va.prototype=Object.create(L.prototype);va.prototype.constructor=va;va.prototype.isLineCurve=!0;va.prototype.getPoint=function(a,b){b=b||new z;1===a?b.copy(this.v2):(b.copy(this.v2).sub(this.v1),b.multiplyScalar(a).add(this.v1));return b};va.prototype.getPointAt=
18021 function(a,b){return this.getPoint(a,b)};va.prototype.getTangent=function(){return this.v2.clone().sub(this.v1).normalize()};va.prototype.copy=function(a){L.prototype.copy.call(this,a);this.v1.copy(a.v1);this.v2.copy(a.v2);return this};va.prototype.toJSON=function(){var a=L.prototype.toJSON.call(this);a.v1=this.v1.toArray();a.v2=this.v2.toArray();return a};va.prototype.fromJSON=function(a){L.prototype.fromJSON.call(this,a);this.v1.fromArray(a.v1);this.v2.fromArray(a.v2);return this};Ia.prototype=
18022 Object.create(L.prototype);Ia.prototype.constructor=Ia;Ia.prototype.isLineCurve3=!0;Ia.prototype.getPoint=function(a,b){b=b||new p;1===a?b.copy(this.v2):(b.copy(this.v2).sub(this.v1),b.multiplyScalar(a).add(this.v1));return b};Ia.prototype.getPointAt=function(a,b){return this.getPoint(a,b)};Ia.prototype.copy=function(a){L.prototype.copy.call(this,a);this.v1.copy(a.v1);this.v2.copy(a.v2);return this};Ia.prototype.toJSON=function(){var a=L.prototype.toJSON.call(this);a.v1=this.v1.toArray();a.v2=this.v2.toArray();
18023 return a};Ia.prototype.fromJSON=function(a){L.prototype.fromJSON.call(this,a);this.v1.fromArray(a.v1);this.v2.fromArray(a.v2);return this};Ja.prototype=Object.create(L.prototype);Ja.prototype.constructor=Ja;Ja.prototype.isQuadraticBezierCurve=!0;Ja.prototype.getPoint=function(a,b){b=b||new z;var c=this.v0,d=this.v1,e=this.v2;b.set($c(a,c.x,d.x,e.x),$c(a,c.y,d.y,e.y));return b};Ja.prototype.copy=function(a){L.prototype.copy.call(this,a);this.v0.copy(a.v0);this.v1.copy(a.v1);this.v2.copy(a.v2);return this};
18024 Ja.prototype.toJSON=function(){var a=L.prototype.toJSON.call(this);a.v0=this.v0.toArray();a.v1=this.v1.toArray();a.v2=this.v2.toArray();return a};Ja.prototype.fromJSON=function(a){L.prototype.fromJSON.call(this,a);this.v0.fromArray(a.v0);this.v1.fromArray(a.v1);this.v2.fromArray(a.v2);return this};Ra.prototype=Object.create(L.prototype);Ra.prototype.constructor=Ra;Ra.prototype.isQuadraticBezierCurve3=!0;Ra.prototype.getPoint=function(a,b){b=b||new p;var c=this.v0,d=this.v1,e=this.v2;b.set($c(a,c.x,
18025 d.x,e.x),$c(a,c.y,d.y,e.y),$c(a,c.z,d.z,e.z));return b};Ra.prototype.copy=function(a){L.prototype.copy.call(this,a);this.v0.copy(a.v0);this.v1.copy(a.v1);this.v2.copy(a.v2);return this};Ra.prototype.toJSON=function(){var a=L.prototype.toJSON.call(this);a.v0=this.v0.toArray();a.v1=this.v1.toArray();a.v2=this.v2.toArray();return a};Ra.prototype.fromJSON=function(a){L.prototype.fromJSON.call(this,a);this.v0.fromArray(a.v0);this.v1.fromArray(a.v1);this.v2.fromArray(a.v2);return this};Ka.prototype=Object.create(L.prototype);
18026 Ka.prototype.constructor=Ka;Ka.prototype.isSplineCurve=!0;Ka.prototype.getPoint=function(a,b){b=b||new z;var c=this.points,d=(c.length-1)*a;a=Math.floor(d);d-=a;var e=c[0===a?a:a-1],f=c[a],g=c[a>c.length-2?c.length-1:a+1];c=c[a>c.length-3?c.length-1:a+2];b.set(lf(d,e.x,f.x,g.x,c.x),lf(d,e.y,f.y,g.y,c.y));return b};Ka.prototype.copy=function(a){L.prototype.copy.call(this,a);this.points=[];for(var b=0,c=a.points.length;b<c;b++)this.points.push(a.points[b].clone());return this};Ka.prototype.toJSON=function(){var a=
18027 L.prototype.toJSON.call(this);a.points=[];for(var b=0,c=this.points.length;b<c;b++)a.points.push(this.points[b].toArray());return a};Ka.prototype.fromJSON=function(a){L.prototype.fromJSON.call(this,a);this.points=[];for(var b=0,c=a.points.length;b<c;b++){var d=a.points[b];this.points.push((new z).fromArray(d))}return this};var Af=Object.freeze({ArcCurve:dc,CatmullRomCurve3:ca,CubicBezierCurve:Ha,CubicBezierCurve3:Qa,EllipseCurve:za,LineCurve:va,LineCurve3:Ia,QuadraticBezierCurve:Ja,QuadraticBezierCurve3:Ra,
18028 SplineCurve:Ka});Xa.prototype=Object.assign(Object.create(L.prototype),{constructor:Xa,add:function(a){this.curves.push(a)},closePath:function(){var a=this.curves[0].getPoint(0),b=this.curves[this.curves.length-1].getPoint(1);a.equals(b)||this.curves.push(new va(b,a))},getPoint:function(a){var b=a*this.getLength(),c=this.getCurveLengths();for(a=0;a<c.length;){if(c[a]>=b)return b=c[a]-b,a=this.curves[a],c=a.getLength(),a.getPointAt(0===c?0:1-b/c);a++}return null},getLength:function(){var a=this.getCurveLengths();
18029 return a[a.length-1]},updateArcLengths:function(){this.needsUpdate=!0;this.cacheLengths=null;this.getCurveLengths()},getCurveLengths:function(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;for(var a=[],b=0,c=0,d=this.curves.length;c<d;c++)b+=this.curves[c].getLength(),a.push(b);return this.cacheLengths=a},getSpacedPoints:function(a){void 0===a&&(a=40);for(var b=[],c=0;c<=a;c++)b.push(this.getPoint(c/a));this.autoClose&&b.push(b[0]);return b},getPoints:function(a){a=
18030 a||12;for(var b=[],c,d=0,e=this.curves;d<e.length;d++){var f=e[d];f=f.getPoints(f&&f.isEllipseCurve?2*a:f&&(f.isLineCurve||f.isLineCurve3)?1:f&&f.isSplineCurve?a*f.points.length:a);for(var g=0;g<f.length;g++){var h=f[g];c&&c.equals(h)||(b.push(h),c=h)}}this.autoClose&&1<b.length&&!b[b.length-1].equals(b[0])&&b.push(b[0]);return b},copy:function(a){L.prototype.copy.call(this,a);this.curves=[];for(var b=0,c=a.curves.length;b<c;b++)this.curves.push(a.curves[b].clone());this.autoClose=a.autoClose;return this},
18031 toJSON:function(){var a=L.prototype.toJSON.call(this);a.autoClose=this.autoClose;a.curves=[];for(var b=0,c=this.curves.length;b<c;b++)a.curves.push(this.curves[b].toJSON());return a},fromJSON:function(a){L.prototype.fromJSON.call(this,a);this.autoClose=a.autoClose;this.curves=[];for(var b=0,c=a.curves.length;b<c;b++){var d=a.curves[b];this.curves.push((new Af[d.type]).fromJSON(d))}return this}});La.prototype=Object.assign(Object.create(Xa.prototype),{constructor:La,setFromPoints:function(a){this.moveTo(a[0].x,
18032 a[0].y);for(var b=1,c=a.length;b<c;b++)this.lineTo(a[b].x,a[b].y)},moveTo:function(a,b){this.currentPoint.set(a,b)},lineTo:function(a,b){var c=new va(this.currentPoint.clone(),new z(a,b));this.curves.push(c);this.currentPoint.set(a,b)},quadraticCurveTo:function(a,b,c,d){a=new Ja(this.currentPoint.clone(),new z(a,b),new z(c,d));this.curves.push(a);this.currentPoint.set(c,d)},bezierCurveTo:function(a,b,c,d,e,f){a=new Ha(this.currentPoint.clone(),new z(a,b),new z(c,d),new z(e,f));this.curves.push(a);
18033 this.currentPoint.set(e,f)},splineThru:function(a){var b=[this.currentPoint.clone()].concat(a);b=new Ka(b);this.curves.push(b);this.currentPoint.copy(a[a.length-1])},arc:function(a,b,c,d,e,f){this.absarc(a+this.currentPoint.x,b+this.currentPoint.y,c,d,e,f)},absarc:function(a,b,c,d,e,f){this.absellipse(a,b,c,c,d,e,f)},ellipse:function(a,b,c,d,e,f,g,h){this.absellipse(a+this.currentPoint.x,b+this.currentPoint.y,c,d,e,f,g,h)},absellipse:function(a,b,c,d,e,f,g,h){a=new za(a,b,c,d,e,f,g,h);0<this.curves.length&&
18034 (b=a.getPoint(0),b.equals(this.currentPoint)||this.lineTo(b.x,b.y));this.curves.push(a);a=a.getPoint(1);this.currentPoint.copy(a)},copy:function(a){Xa.prototype.copy.call(this,a);this.currentPoint.copy(a.currentPoint);return this},toJSON:function(){var a=Xa.prototype.toJSON.call(this);a.currentPoint=this.currentPoint.toArray();return a},fromJSON:function(a){Xa.prototype.fromJSON.call(this,a);this.currentPoint.fromArray(a.currentPoint);return this}});db.prototype=Object.assign(Object.create(La.prototype),
18035 {constructor:db,getPointsHoles:function(a){for(var b=[],c=0,d=this.holes.length;c<d;c++)b[c]=this.holes[c].getPoints(a);return b},extractPoints:function(a){return{shape:this.getPoints(a),holes:this.getPointsHoles(a)}},copy:function(a){La.prototype.copy.call(this,a);this.holes=[];for(var b=0,c=a.holes.length;b<c;b++)this.holes.push(a.holes[b].clone());return this},toJSON:function(){var a=La.prototype.toJSON.call(this);a.uuid=this.uuid;a.holes=[];for(var b=0,c=this.holes.length;b<c;b++)a.holes.push(this.holes[b].toJSON());
18036 return a},fromJSON:function(a){La.prototype.fromJSON.call(this,a);this.uuid=a.uuid;this.holes=[];for(var b=0,c=a.holes.length;b<c;b++){var d=a.holes[b];this.holes.push((new La).fromJSON(d))}return this}});X.prototype=Object.assign(Object.create(D.prototype),{constructor:X,isLight:!0,copy:function(a){D.prototype.copy.call(this,a);this.color.copy(a.color);this.intensity=a.intensity;return this},toJSON:function(a){a=D.prototype.toJSON.call(this,a);a.object.color=this.color.getHex();a.object.intensity=
18037 this.intensity;void 0!==this.groundColor&&(a.object.groundColor=this.groundColor.getHex());void 0!==this.distance&&(a.object.distance=this.distance);void 0!==this.angle&&(a.object.angle=this.angle);void 0!==this.decay&&(a.object.decay=this.decay);void 0!==this.penumbra&&(a.object.penumbra=this.penumbra);void 0!==this.shadow&&(a.object.shadow=this.shadow.toJSON());return a}});wd.prototype=Object.assign(Object.create(X.prototype),{constructor:wd,isHemisphereLight:!0,copy:function(a){X.prototype.copy.call(this,
18038 a);this.groundColor.copy(a.groundColor);return this}});Object.assign(Cb.prototype,{copy:function(a){this.camera=a.camera.clone();this.bias=a.bias;this.radius=a.radius;this.mapSize.copy(a.mapSize);return this},clone:function(){return(new this.constructor).copy(this)},toJSON:function(){var a={};0!==this.bias&&(a.bias=this.bias);1!==this.radius&&(a.radius=this.radius);if(512!==this.mapSize.x||512!==this.mapSize.y)a.mapSize=this.mapSize.toArray();a.camera=this.camera.toJSON(!1).object;delete a.camera.matrix;
18039 return a}});xd.prototype=Object.assign(Object.create(Cb.prototype),{constructor:xd,isSpotLightShadow:!0,update:function(a){var b=this.camera,c=2*H.RAD2DEG*a.angle,d=this.mapSize.width/this.mapSize.height;a=a.distance||b.far;if(c!==b.fov||d!==b.aspect||a!==b.far)b.fov=c,b.aspect=d,b.far=a,b.updateProjectionMatrix()}});yd.prototype=Object.assign(Object.create(X.prototype),{constructor:yd,isSpotLight:!0,copy:function(a){X.prototype.copy.call(this,a);this.distance=a.distance;this.angle=a.angle;this.penumbra=
18040 a.penumbra;this.decay=a.decay;this.target=a.target.clone();this.shadow=a.shadow.clone();return this}});zd.prototype=Object.assign(Object.create(X.prototype),{constructor:zd,isPointLight:!0,copy:function(a){X.prototype.copy.call(this,a);this.distance=a.distance;this.decay=a.decay;this.shadow=a.shadow.clone();return this}});Ad.prototype=Object.assign(Object.create(Cb.prototype),{constructor:Ad});Bd.prototype=Object.assign(Object.create(X.prototype),{constructor:Bd,isDirectionalLight:!0,copy:function(a){X.prototype.copy.call(this,
18041 a);this.target=a.target.clone();this.shadow=a.shadow.clone();return this}});Cd.prototype=Object.assign(Object.create(X.prototype),{constructor:Cd,isAmbientLight:!0});Dd.prototype=Object.assign(Object.create(X.prototype),{constructor:Dd,isRectAreaLight:!0,copy:function(a){X.prototype.copy.call(this,a);this.width=a.width;this.height=a.height;return this},toJSON:function(a){a=X.prototype.toJSON.call(this,a);a.object.width=this.width;a.object.height=this.height;return a}});var ia={arraySlice:function(a,
18042 b,c){return ia.isTypedArray(a)?new a.constructor(a.subarray(b,void 0!==c?c:a.length)):a.slice(b,c)},convertArray:function(a,b,c){return!a||!c&&a.constructor===b?a:"number"===typeof b.BYTES_PER_ELEMENT?new b(a):Array.prototype.slice.call(a)},isTypedArray:function(a){return ArrayBuffer.isView(a)&&!(a instanceof DataView)},getKeyframeOrder:function(a){for(var b=a.length,c=Array(b),d=0;d!==b;++d)c[d]=d;c.sort(function(b,c){return a[b]-a[c]});return c},sortedArray:function(a,b,c){for(var d=a.length,e=
18043 new a.constructor(d),f=0,g=0;g!==d;++f)for(var h=c[f]*b,k=0;k!==b;++k)e[g++]=a[h+k];return e},flattenJSON:function(a,b,c,d){for(var e=1,f=a[0];void 0!==f&&void 0===f[d];)f=a[e++];if(void 0!==f){var g=f[d];if(void 0!==g)if(Array.isArray(g)){do g=f[d],void 0!==g&&(b.push(f.time),c.push.apply(c,g)),f=a[e++];while(void 0!==f)}else if(void 0!==g.toArray){do g=f[d],void 0!==g&&(b.push(f.time),g.toArray(c,c.length)),f=a[e++];while(void 0!==f)}else{do g=f[d],void 0!==g&&(b.push(f.time),c.push(g)),f=a[e++];
18044 while(void 0!==f)}}}};Object.assign(wa.prototype,{evaluate:function(a){var b=this.parameterPositions,c=this._cachedIndex,d=b[c],e=b[c-1];a:{b:{c:{d:if(!(a<d)){for(var f=c+2;;){if(void 0===d){if(a<e)break d;this._cachedIndex=c=b.length;return this.afterEnd_(c-1,a,e)}if(c===f)break;e=d;d=b[++c];if(a<d)break b}d=b.length;break c}if(a>=e)break a;else{f=b[1];a<f&&(c=2,e=f);for(f=c-2;;){if(void 0===e)return this._cachedIndex=0,this.beforeStart_(0,a,d);if(c===f)break;d=e;e=b[--c-1];if(a>=e)break b}d=c;c=
18045 0}}for(;c<d;)e=c+d>>>1,a<b[e]?d=e:c=e+1;d=b[c];e=b[c-1];if(void 0===e)return this._cachedIndex=0,this.beforeStart_(0,a,d);if(void 0===d)return this._cachedIndex=c=b.length,this.afterEnd_(c-1,e,a)}this._cachedIndex=c;this.intervalChanged_(c,e,d)}return this.interpolate_(c,e,a,d)},settings:null,DefaultSettings_:{},getSettings_:function(){return this.settings||this.DefaultSettings_},copySampleValue_:function(a){var b=this.resultBuffer,c=this.sampleValues,d=this.valueSize;a*=d;for(var e=0;e!==d;++e)b[e]=
18046 c[a+e];return b},interpolate_:function(){throw Error("call to abstract method");},intervalChanged_:function(){}});Object.assign(wa.prototype,{beforeStart_:wa.prototype.copySampleValue_,afterEnd_:wa.prototype.copySampleValue_});Ed.prototype=Object.assign(Object.create(wa.prototype),{constructor:Ed,DefaultSettings_:{endingStart:2400,endingEnd:2400},intervalChanged_:function(a,b,c){var d=this.parameterPositions,e=a-2,f=a+1,g=d[e],h=d[f];if(void 0===g)switch(this.getSettings_().endingStart){case 2401:e=
18047 a;g=2*b-c;break;case 2402:e=d.length-2;g=b+d[e]-d[e+1];break;default:e=a,g=c}if(void 0===h)switch(this.getSettings_().endingEnd){case 2401:f=a;h=2*c-b;break;case 2402:f=1;h=c+d[1]-d[0];break;default:f=a-1,h=b}a=.5*(c-b);d=this.valueSize;this._weightPrev=a/(b-g);this._weightNext=a/(h-c);this._offsetPrev=e*d;this._offsetNext=f*d},interpolate_:function(a,b,c,d){var e=this.resultBuffer,f=this.sampleValues,g=this.valueSize;a*=g;var h=a-g,k=this._offsetPrev,m=this._offsetNext,l=this._weightPrev,n=this._weightNext,
18048 p=(c-b)/(d-b);c=p*p;d=c*p;b=-l*d+2*l*c-l*p;l=(1+l)*d+(-1.5-2*l)*c+(-.5+l)*p+1;p=(-1-n)*d+(1.5+n)*c+.5*p;n=n*d-n*c;for(c=0;c!==g;++c)e[c]=b*f[k+c]+l*f[h+c]+p*f[a+c]+n*f[m+c];return e}});bd.prototype=Object.assign(Object.create(wa.prototype),{constructor:bd,interpolate_:function(a,b,c,d){var e=this.resultBuffer,f=this.sampleValues,g=this.valueSize;a*=g;var h=a-g;b=(c-b)/(d-b);c=1-b;for(d=0;d!==g;++d)e[d]=f[h+d]*c+f[a+d]*b;return e}});Fd.prototype=Object.assign(Object.create(wa.prototype),{constructor:Fd,
18049 interpolate_:function(a){return this.copySampleValue_(a-1)}});Object.assign(oa,{toJSON:function(a){var b=a.constructor;if(void 0!==b.toJSON)b=b.toJSON(a);else{b={name:a.name,times:ia.convertArray(a.times,Array),values:ia.convertArray(a.values,Array)};var c=a.getInterpolation();c!==a.DefaultInterpolation&&(b.interpolation=c)}b.type=a.ValueTypeName;return b}});Object.assign(oa.prototype,{constructor:oa,TimeBufferType:Float32Array,ValueBufferType:Float32Array,DefaultInterpolation:2301,InterpolantFactoryMethodDiscrete:function(a){return new Fd(this.times,
18050 this.values,this.getValueSize(),a)},InterpolantFactoryMethodLinear:function(a){return new bd(this.times,this.values,this.getValueSize(),a)},InterpolantFactoryMethodSmooth:function(a){return new Ed(this.times,this.values,this.getValueSize(),a)},setInterpolation:function(a){switch(a){case 2300:var b=this.InterpolantFactoryMethodDiscrete;break;case 2301:b=this.InterpolantFactoryMethodLinear;break;case 2302:b=this.InterpolantFactoryMethodSmooth}if(void 0===b){b="unsupported interpolation for "+this.ValueTypeName+
18051 " keyframe track named "+this.name;if(void 0===this.createInterpolant)if(a!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw Error(b);console.warn("THREE.KeyframeTrack:",b);return this}this.createInterpolant=b;return this},getInterpolation:function(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return 2300;case this.InterpolantFactoryMethodLinear:return 2301;case this.InterpolantFactoryMethodSmooth:return 2302}},getValueSize:function(){return this.values.length/
18052 this.times.length},shift:function(a){if(0!==a)for(var b=this.times,c=0,d=b.length;c!==d;++c)b[c]+=a;return this},scale:function(a){if(1!==a)for(var b=this.times,c=0,d=b.length;c!==d;++c)b[c]*=a;return this},trim:function(a,b){for(var c=this.times,d=c.length,e=0,f=d-1;e!==d&&c[e]<a;)++e;for(;-1!==f&&c[f]>b;)--f;++f;if(0!==e||f!==d)e>=f&&(f=Math.max(f,1),e=f-1),a=this.getValueSize(),this.times=ia.arraySlice(c,e,f),this.values=ia.arraySlice(this.values,e*a,f*a);return this},validate:function(){var a=
18053 !0,b=this.getValueSize();0!==b-Math.floor(b)&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),a=!1);var c=this.times;b=this.values;var d=c.length;0===d&&(console.error("THREE.KeyframeTrack: Track is empty.",this),a=!1);for(var e=null,f=0;f!==d;f++){var g=c[f];if("number"===typeof g&&isNaN(g)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,f,g);a=!1;break}if(null!==e&&e>g){console.error("THREE.KeyframeTrack: Out of order keys.",this,f,g,e);a=!1;break}e=
18054 g}if(void 0!==b&&ia.isTypedArray(b))for(f=0,c=b.length;f!==c;++f)if(d=b[f],isNaN(d)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,f,d);a=!1;break}return a},optimize:function(){for(var a=this.times,b=this.values,c=this.getValueSize(),d=2302===this.getInterpolation(),e=1,f=a.length-1,g=1;g<f;++g){var h=!1,k=a[g];if(k!==a[g+1]&&(1!==g||k!==k[0]))if(d)h=!0;else{var m=g*c,l=m-c,n=m+c;for(k=0;k!==c;++k){var p=b[m+k];if(p!==b[l+k]||p!==b[n+k]){h=!0;break}}}if(h){if(g!==e)for(a[e]=
18055 a[g],h=g*c,m=e*c,k=0;k!==c;++k)b[m+k]=b[h+k];++e}}if(0<f){a[e]=a[f];h=f*c;m=e*c;for(k=0;k!==c;++k)b[m+k]=b[h+k];++e}e!==a.length&&(this.times=ia.arraySlice(a,0,e),this.values=ia.arraySlice(b,0,e*c));return this}});Gd.prototype=Object.assign(Object.create(oa.prototype),{constructor:Gd,ValueTypeName:"bool",ValueBufferType:Array,DefaultInterpolation:2300,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0});Hd.prototype=Object.assign(Object.create(oa.prototype),{constructor:Hd,
18056 ValueTypeName:"color"});ec.prototype=Object.assign(Object.create(oa.prototype),{constructor:ec,ValueTypeName:"number"});Id.prototype=Object.assign(Object.create(wa.prototype),{constructor:Id,interpolate_:function(a,b,c,d){var e=this.resultBuffer,f=this.sampleValues,g=this.valueSize;a*=g;b=(c-b)/(d-b);for(c=a+g;a!==c;a+=4)fa.slerpFlat(e,0,f,a-g,f,a,b);return e}});cd.prototype=Object.assign(Object.create(oa.prototype),{constructor:cd,ValueTypeName:"quaternion",DefaultInterpolation:2301,InterpolantFactoryMethodLinear:function(a){return new Id(this.times,
18057 this.values,this.getValueSize(),a)},InterpolantFactoryMethodSmooth:void 0});Jd.prototype=Object.assign(Object.create(oa.prototype),{constructor:Jd,ValueTypeName:"string",ValueBufferType:Array,DefaultInterpolation:2300,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0});fc.prototype=Object.assign(Object.create(oa.prototype),{constructor:fc,ValueTypeName:"vector"});Object.assign(Ca,{parse:function(a){for(var b=[],c=a.tracks,d=1/(a.fps||1),e=0,f=c.length;e!==f;++e)b.push(Sg(c[e]).scale(d));
18058 return new Ca(a.name,a.duration,b)},toJSON:function(a){var b=[],c=a.tracks;a={name:a.name,duration:a.duration,tracks:b,uuid:a.uuid};for(var d=0,e=c.length;d!==e;++d)b.push(oa.toJSON(c[d]));return a},CreateFromMorphTargetSequence:function(a,b,c,d){for(var e=b.length,f=[],g=0;g<e;g++){var h=[],k=[];h.push((g+e-1)%e,g,(g+1)%e);k.push(0,1,0);var m=ia.getKeyframeOrder(h);h=ia.sortedArray(h,1,m);k=ia.sortedArray(k,1,m);d||0!==h[0]||(h.push(e),k.push(k[0]));f.push((new ec(".morphTargetInfluences["+b[g].name+
18059 "]",h,k)).scale(1/c))}return new Ca(a,-1,f)},findByName:function(a,b){var c=a;Array.isArray(a)||(c=a.geometry&&a.geometry.animations||a.animations);for(a=0;a<c.length;a++)if(c[a].name===b)return c[a];return null},CreateClipsFromMorphTargetSequences:function(a,b,c){for(var d={},e=/^([\w-]*?)([\d]+)$/,f=0,g=a.length;f<g;f++){var h=a[f],k=h.name.match(e);if(k&&1<k.length){var m=k[1];(k=d[m])||(d[m]=k=[]);k.push(h)}}a=[];for(m in d)a.push(Ca.CreateFromMorphTargetSequence(m,d[m],b,c));return a},parseAnimation:function(a,
18060 b){if(!a)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;var c=function(a,b,c,d,e){if(0!==c.length){var f=[],g=[];ia.flattenJSON(c,f,g,d);0!==f.length&&e.push(new a(b,f,g))}},d=[],e=a.name||"default",f=a.length||-1,g=a.fps||30;a=a.hierarchy||[];for(var h=0;h<a.length;h++){var k=a[h].keys;if(k&&0!==k.length)if(k[0].morphTargets){f={};for(var m=0;m<k.length;m++)if(k[m].morphTargets)for(var l=0;l<k[m].morphTargets.length;l++)f[k[m].morphTargets[l]]=-1;for(var n in f){var p=
18061 [],u=[];for(l=0;l!==k[m].morphTargets.length;++l){var r=k[m];p.push(r.time);u.push(r.morphTarget===n?1:0)}d.push(new ec(".morphTargetInfluence["+n+"]",p,u))}f=f.length*(g||1)}else m=".bones["+b[h].name+"]",c(fc,m+".position",k,"pos",d),c(cd,m+".quaternion",k,"rot",d),c(fc,m+".scale",k,"scl",d)}return 0===d.length?null:new Ca(e,f,d)}});Object.assign(Ca.prototype,{resetDuration:function(){for(var a=0,b=0,c=this.tracks.length;b!==c;++b){var d=this.tracks[b];a=Math.max(a,d.times[d.times.length-1])}this.duration=
18062 a;return this},trim:function(){for(var a=0;a<this.tracks.length;a++)this.tracks[a].trim(0,this.duration);return this},validate:function(){for(var a=!0,b=0;b<this.tracks.length;b++)a=a&&this.tracks[b].validate();return a},optimize:function(){for(var a=0;a<this.tracks.length;a++)this.tracks[a].optimize();return this}});Object.assign(Kd.prototype,{load:function(a,b,c,d){var e=this;(new Ga(e.manager)).load(a,function(a){b(e.parse(JSON.parse(a)))},c,d)},setTextures:function(a){this.textures=a},parse:function(a){function b(a){void 0===
18063 c[a]&&console.warn("THREE.MaterialLoader: Undefined texture",a);return c[a]}var c=this.textures,d=new Vg[a.type];void 0!==a.uuid&&(d.uuid=a.uuid);void 0!==a.name&&(d.name=a.name);void 0!==a.color&&d.color.setHex(a.color);void 0!==a.roughness&&(d.roughness=a.roughness);void 0!==a.metalness&&(d.metalness=a.metalness);void 0!==a.emissive&&d.emissive.setHex(a.emissive);void 0!==a.specular&&d.specular.setHex(a.specular);void 0!==a.shininess&&(d.shininess=a.shininess);void 0!==a.clearCoat&&(d.clearCoat=
18064 a.clearCoat);void 0!==a.clearCoatRoughness&&(d.clearCoatRoughness=a.clearCoatRoughness);void 0!==a.uniforms&&(d.uniforms=a.uniforms);void 0!==a.vertexShader&&(d.vertexShader=a.vertexShader);void 0!==a.fragmentShader&&(d.fragmentShader=a.fragmentShader);void 0!==a.vertexColors&&(d.vertexColors=a.vertexColors);void 0!==a.fog&&(d.fog=a.fog);void 0!==a.flatShading&&(d.flatShading=a.flatShading);void 0!==a.blending&&(d.blending=a.blending);void 0!==a.side&&(d.side=a.side);void 0!==a.opacity&&(d.opacity=
18065 a.opacity);void 0!==a.transparent&&(d.transparent=a.transparent);void 0!==a.alphaTest&&(d.alphaTest=a.alphaTest);void 0!==a.depthTest&&(d.depthTest=a.depthTest);void 0!==a.depthWrite&&(d.depthWrite=a.depthWrite);void 0!==a.colorWrite&&(d.colorWrite=a.colorWrite);void 0!==a.wireframe&&(d.wireframe=a.wireframe);void 0!==a.wireframeLinewidth&&(d.wireframeLinewidth=a.wireframeLinewidth);void 0!==a.wireframeLinecap&&(d.wireframeLinecap=a.wireframeLinecap);void 0!==a.wireframeLinejoin&&(d.wireframeLinejoin=
18066 a.wireframeLinejoin);void 0!==a.rotation&&(d.rotation=a.rotation);1!==a.linewidth&&(d.linewidth=a.linewidth);void 0!==a.dashSize&&(d.dashSize=a.dashSize);void 0!==a.gapSize&&(d.gapSize=a.gapSize);void 0!==a.scale&&(d.scale=a.scale);void 0!==a.polygonOffset&&(d.polygonOffset=a.polygonOffset);void 0!==a.polygonOffsetFactor&&(d.polygonOffsetFactor=a.polygonOffsetFactor);void 0!==a.polygonOffsetUnits&&(d.polygonOffsetUnits=a.polygonOffsetUnits);void 0!==a.skinning&&(d.skinning=a.skinning);void 0!==a.morphTargets&&
18067 (d.morphTargets=a.morphTargets);void 0!==a.dithering&&(d.dithering=a.dithering);void 0!==a.visible&&(d.visible=a.visible);void 0!==a.userData&&(d.userData=a.userData);void 0!==a.shading&&(d.flatShading=1===a.shading);void 0!==a.size&&(d.size=a.size);void 0!==a.sizeAttenuation&&(d.sizeAttenuation=a.sizeAttenuation);void 0!==a.map&&(d.map=b(a.map));void 0!==a.alphaMap&&(d.alphaMap=b(a.alphaMap),d.transparent=!0);void 0!==a.bumpMap&&(d.bumpMap=b(a.bumpMap));void 0!==a.bumpScale&&(d.bumpScale=a.bumpScale);
18068 void 0!==a.normalMap&&(d.normalMap=b(a.normalMap));void 0!==a.normalMapType&&(d.normalMapType=a.normalMapType);if(void 0!==a.normalScale){var e=a.normalScale;!1===Array.isArray(e)&&(e=[e,e]);d.normalScale=(new z).fromArray(e)}void 0!==a.displacementMap&&(d.displacementMap=b(a.displacementMap));void 0!==a.displacementScale&&(d.displacementScale=a.displacementScale);void 0!==a.displacementBias&&(d.displacementBias=a.displacementBias);void 0!==a.roughnessMap&&(d.roughnessMap=b(a.roughnessMap));void 0!==
18069 a.metalnessMap&&(d.metalnessMap=b(a.metalnessMap));void 0!==a.emissiveMap&&(d.emissiveMap=b(a.emissiveMap));void 0!==a.emissiveIntensity&&(d.emissiveIntensity=a.emissiveIntensity);void 0!==a.specularMap&&(d.specularMap=b(a.specularMap));void 0!==a.envMap&&(d.envMap=b(a.envMap));void 0!==a.reflectivity&&(d.reflectivity=a.reflectivity);void 0!==a.lightMap&&(d.lightMap=b(a.lightMap));void 0!==a.lightMapIntensity&&(d.lightMapIntensity=a.lightMapIntensity);void 0!==a.aoMap&&(d.aoMap=b(a.aoMap));void 0!==
18070 a.aoMapIntensity&&(d.aoMapIntensity=a.aoMapIntensity);void 0!==a.gradientMap&&(d.gradientMap=b(a.gradientMap));return d}});Object.assign(ge.prototype,{load:function(a,b,c,d){var e=this;(new Ga(e.manager)).load(a,function(a){b(e.parse(JSON.parse(a)))},c,d)},parse:function(a){var b=new C,c=a.data.index;void 0!==c&&(c=new Bf[c.type](c.array),b.setIndex(new Q(c,1)));var d=a.data.attributes;for(f in d){var e=d[f];c=new Bf[e.type](e.array);b.addAttribute(f,new Q(c,e.itemSize,e.normalized))}var f=a.data.groups||
18071 a.data.drawcalls||a.data.offsets;if(void 0!==f)for(c=0,d=f.length;c!==d;++c)e=f[c],b.addGroup(e.start,e.count,e.materialIndex);a=a.data.boundingSphere;void 0!==a&&(f=new p,void 0!==a.center&&f.fromArray(a.center),b.boundingSphere=new Da(f,a.radius));return b}});var Bf={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:"undefined"!==typeof Uint8ClampedArray?Uint8ClampedArray:Uint8Array,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,
18072 Float64Array:Float64Array};gc.Handlers={handlers:[],add:function(a,b){this.handlers.push(a,b)},get:function(a){for(var b=this.handlers,c=0,d=b.length;c<d;c+=2){var e=b[c+1];if(b[c].test(a))return e}return null}};Object.assign(gc.prototype,{crossOrigin:"anonymous",onLoadStart:function(){},onLoadProgress:function(){},onLoadComplete:function(){},initMaterials:function(a,b,c){for(var d=[],e=0;e<a.length;++e)d[e]=this.createMaterial(a[e],b,c);return d},createMaterial:function(){var a={NoBlending:0,NormalBlending:1,
18073 AdditiveBlending:2,SubtractiveBlending:3,MultiplyBlending:4,CustomBlending:5},b=new G,c=new vd,d=new Kd;return function(e,f,g){function h(a,b,d,e,h){a=f+a;var m=gc.Handlers.get(a);null!==m?a=m.load(a):(c.setCrossOrigin(g),a=c.load(a));void 0!==b&&(a.repeat.fromArray(b),1!==b[0]&&(a.wrapS=1E3),1!==b[1]&&(a.wrapT=1E3));void 0!==d&&a.offset.fromArray(d);void 0!==e&&("repeat"===e[0]&&(a.wrapS=1E3),"mirror"===e[0]&&(a.wrapS=1002),"repeat"===e[1]&&(a.wrapT=1E3),"mirror"===e[1]&&(a.wrapT=1002));void 0!==
18074 h&&(a.anisotropy=h);b=H.generateUUID();k[b]=a;return b}var k={},m={uuid:H.generateUUID(),type:"MeshLambertMaterial"},l;for(l in e){var n=e[l];switch(l){case "DbgColor":case "DbgIndex":case "opticalDensity":case "illumination":break;case "DbgName":m.name=n;break;case "blending":m.blending=a[n];break;case "colorAmbient":case "mapAmbient":console.warn("THREE.Loader.createMaterial:",l,"is no longer supported.");break;case "colorDiffuse":m.color=b.fromArray(n).getHex();break;case "colorSpecular":m.specular=
18075 b.fromArray(n).getHex();break;case "colorEmissive":m.emissive=b.fromArray(n).getHex();break;case "specularCoef":m.shininess=n;break;case "shading":"basic"===n.toLowerCase()&&(m.type="MeshBasicMaterial");"phong"===n.toLowerCase()&&(m.type="MeshPhongMaterial");"standard"===n.toLowerCase()&&(m.type="MeshStandardMaterial");break;case "mapDiffuse":m.map=h(n,e.mapDiffuseRepeat,e.mapDiffuseOffset,e.mapDiffuseWrap,e.mapDiffuseAnisotropy);break;case "mapDiffuseRepeat":case "mapDiffuseOffset":case "mapDiffuseWrap":case "mapDiffuseAnisotropy":break;
18076 case "mapEmissive":m.emissiveMap=h(n,e.mapEmissiveRepeat,e.mapEmissiveOffset,e.mapEmissiveWrap,e.mapEmissiveAnisotropy);break;case "mapEmissiveRepeat":case "mapEmissiveOffset":case "mapEmissiveWrap":case "mapEmissiveAnisotropy":break;case "mapLight":m.lightMap=h(n,e.mapLightRepeat,e.mapLightOffset,e.mapLightWrap,e.mapLightAnisotropy);break;case "mapLightRepeat":case "mapLightOffset":case "mapLightWrap":case "mapLightAnisotropy":break;case "mapAO":m.aoMap=h(n,e.mapAORepeat,e.mapAOOffset,e.mapAOWrap,
18077 e.mapAOAnisotropy);break;case "mapAORepeat":case "mapAOOffset":case "mapAOWrap":case "mapAOAnisotropy":break;case "mapBump":m.bumpMap=h(n,e.mapBumpRepeat,e.mapBumpOffset,e.mapBumpWrap,e.mapBumpAnisotropy);break;case "mapBumpScale":m.bumpScale=n;break;case "mapBumpRepeat":case "mapBumpOffset":case "mapBumpWrap":case "mapBumpAnisotropy":break;case "mapNormal":m.normalMap=h(n,e.mapNormalRepeat,e.mapNormalOffset,e.mapNormalWrap,e.mapNormalAnisotropy);break;case "mapNormalFactor":m.normalScale=n;break;
18078 case "mapNormalRepeat":case "mapNormalOffset":case "mapNormalWrap":case "mapNormalAnisotropy":break;case "mapSpecular":m.specularMap=h(n,e.mapSpecularRepeat,e.mapSpecularOffset,e.mapSpecularWrap,e.mapSpecularAnisotropy);break;case "mapSpecularRepeat":case "mapSpecularOffset":case "mapSpecularWrap":case "mapSpecularAnisotropy":break;case "mapMetalness":m.metalnessMap=h(n,e.mapMetalnessRepeat,e.mapMetalnessOffset,e.mapMetalnessWrap,e.mapMetalnessAnisotropy);break;case "mapMetalnessRepeat":case "mapMetalnessOffset":case "mapMetalnessWrap":case "mapMetalnessAnisotropy":break;
18079 case "mapRoughness":m.roughnessMap=h(n,e.mapRoughnessRepeat,e.mapRoughnessOffset,e.mapRoughnessWrap,e.mapRoughnessAnisotropy);break;case "mapRoughnessRepeat":case "mapRoughnessOffset":case "mapRoughnessWrap":case "mapRoughnessAnisotropy":break;case "mapAlpha":m.alphaMap=h(n,e.mapAlphaRepeat,e.mapAlphaOffset,e.mapAlphaWrap,e.mapAlphaAnisotropy);break;case "mapAlphaRepeat":case "mapAlphaOffset":case "mapAlphaWrap":case "mapAlphaAnisotropy":break;case "flipSided":m.side=1;break;case "doubleSided":m.side=
18080 2;break;case "transparency":console.warn("THREE.Loader.createMaterial: transparency has been renamed to opacity");m.opacity=n;break;case "depthTest":case "depthWrite":case "colorWrite":case "opacity":case "reflectivity":case "transparent":case "visible":case "wireframe":m[l]=n;break;case "vertexColors":!0===n&&(m.vertexColors=2);"face"===n&&(m.vertexColors=1);break;default:console.error("THREE.Loader.createMaterial: Unsupported",l,n)}}"MeshBasicMaterial"===m.type&&delete m.emissive;"MeshPhongMaterial"!==
18081 m.type&&delete m.specular;1>m.opacity&&(m.transparent=!0);d.setTextures(k);return d.parse(m)}}()});var De={decodeText:function(a){if("undefined"!==typeof TextDecoder)return(new TextDecoder).decode(a);for(var b="",c=0,d=a.length;c<d;c++)b+=String.fromCharCode(a[c]);return decodeURIComponent(escape(b))},extractUrlBase:function(a){var b=a.lastIndexOf("/");return-1===b?"./":a.substr(0,b+1)}};Object.assign(he.prototype,{crossOrigin:"anonymous",load:function(a,b,c,d){var e=this,f=this.texturePath&&"string"===
18082 typeof this.texturePath?this.texturePath:De.extractUrlBase(a),g=new Ga(this.manager);g.setWithCredentials(this.withCredentials);g.load(a,function(c){c=JSON.parse(c);var d=c.metadata;if(void 0!==d&&(d=d.type,void 0!==d&&"object"===d.toLowerCase())){console.error("THREE.JSONLoader: "+a+" should be loaded with THREE.ObjectLoader instead.");return}c=e.parse(c,f);b(c.geometry,c.materials)},c,d)},setCrossOrigin:function(a){this.crossOrigin=a;return this},setTexturePath:function(a){this.texturePath=a;return this},
18083 parse:function(){return function(a,b){void 0!==a.data&&(a=a.data);a.scale=void 0!==a.scale?1/a.scale:1;var c=new R,d=a,e,f,g,h=d.faces;var k=d.vertices;var m=d.normals,l=d.colors;var n=d.scale;var t=0;if(void 0!==d.uvs){for(e=0;e<d.uvs.length;e++)d.uvs[e].length&&t++;for(e=0;e<t;e++)c.faceVertexUvs[e]=[]}var u=0;for(g=k.length;u<g;)e=new p,e.x=k[u++]*n,e.y=k[u++]*n,e.z=k[u++]*n,c.vertices.push(e);u=0;for(g=h.length;u<g;){k=h[u++];var r=k&1;var v=k&2;e=k&8;var y=k&16;var x=k&32;n=k&64;k&=128;if(r){r=
18084 new Ta;r.a=h[u];r.b=h[u+1];r.c=h[u+3];var w=new Ta;w.a=h[u+1];w.b=h[u+2];w.c=h[u+3];u+=4;v&&(v=h[u++],r.materialIndex=v,w.materialIndex=v);v=c.faces.length;if(e)for(e=0;e<t;e++){var B=d.uvs[e];c.faceVertexUvs[e][v]=[];c.faceVertexUvs[e][v+1]=[];for(f=0;4>f;f++){var E=h[u++];var A=B[2*E];E=B[2*E+1];A=new z(A,E);2!==f&&c.faceVertexUvs[e][v].push(A);0!==f&&c.faceVertexUvs[e][v+1].push(A)}}y&&(y=3*h[u++],r.normal.set(m[y++],m[y++],m[y]),w.normal.copy(r.normal));if(x)for(e=0;4>e;e++)y=3*h[u++],x=new p(m[y++],
18085 m[y++],m[y]),2!==e&&r.vertexNormals.push(x),0!==e&&w.vertexNormals.push(x);n&&(n=h[u++],n=l[n],r.color.setHex(n),w.color.setHex(n));if(k)for(e=0;4>e;e++)n=h[u++],n=l[n],2!==e&&r.vertexColors.push(new G(n)),0!==e&&w.vertexColors.push(new G(n));c.faces.push(r);c.faces.push(w)}else{r=new Ta;r.a=h[u++];r.b=h[u++];r.c=h[u++];v&&(v=h[u++],r.materialIndex=v);v=c.faces.length;if(e)for(e=0;e<t;e++)for(B=d.uvs[e],c.faceVertexUvs[e][v]=[],f=0;3>f;f++)E=h[u++],A=B[2*E],E=B[2*E+1],A=new z(A,E),c.faceVertexUvs[e][v].push(A);
18086 y&&(y=3*h[u++],r.normal.set(m[y++],m[y++],m[y]));if(x)for(e=0;3>e;e++)y=3*h[u++],x=new p(m[y++],m[y++],m[y]),r.vertexNormals.push(x);n&&(n=h[u++],r.color.setHex(l[n]));if(k)for(e=0;3>e;e++)n=h[u++],r.vertexColors.push(new G(l[n]));c.faces.push(r)}}d=a;u=void 0!==d.influencesPerVertex?d.influencesPerVertex:2;if(d.skinWeights)for(g=0,h=d.skinWeights.length;g<h;g+=u)c.skinWeights.push(new V(d.skinWeights[g],1<u?d.skinWeights[g+1]:0,2<u?d.skinWeights[g+2]:0,3<u?d.skinWeights[g+3]:0));if(d.skinIndices)for(g=
18087 0,h=d.skinIndices.length;g<h;g+=u)c.skinIndices.push(new V(d.skinIndices[g],1<u?d.skinIndices[g+1]:0,2<u?d.skinIndices[g+2]:0,3<u?d.skinIndices[g+3]:0));c.bones=d.bones;c.bones&&0<c.bones.length&&(c.skinWeights.length!==c.skinIndices.length||c.skinIndices.length!==c.vertices.length)&&console.warn("When skinning, number of vertices ("+c.vertices.length+"), skinIndices ("+c.skinIndices.length+"), and skinWeights ("+c.skinWeights.length+") should match.");g=a;h=g.scale;if(void 0!==g.morphTargets)for(d=
18088 0,u=g.morphTargets.length;d<u;d++)for(c.morphTargets[d]={},c.morphTargets[d].name=g.morphTargets[d].name,c.morphTargets[d].vertices=[],m=c.morphTargets[d].vertices,l=g.morphTargets[d].vertices,t=0,k=l.length;t<k;t+=3)n=new p,n.x=l[t]*h,n.y=l[t+1]*h,n.z=l[t+2]*h,m.push(n);if(void 0!==g.morphColors&&0<g.morphColors.length)for(console.warn('THREE.JSONLoader: "morphColors" no longer supported. Using them as face colors.'),h=c.faces,g=g.morphColors[0].colors,d=0,u=h.length;d<u;d++)h[d].color.fromArray(g,
18089 3*d);g=a;d=[];u=[];void 0!==g.animation&&u.push(g.animation);void 0!==g.animations&&(g.animations.length?u=u.concat(g.animations):u.push(g.animations));for(g=0;g<u.length;g++)(h=Ca.parseAnimation(u[g],c.bones))&&d.push(h);c.morphTargets&&(u=Ca.CreateClipsFromMorphTargetSequences(c.morphTargets,10),d=d.concat(u));0<d.length&&(c.animations=d);c.computeFaceNormals();c.computeBoundingSphere();if(void 0===a.materials||0===a.materials.length)return{geometry:c};a=gc.prototype.initMaterials(a.materials,b,
18090 this.crossOrigin);return{geometry:c,materials:a}}}()});Object.assign(mf.prototype,{crossOrigin:"anonymous",load:function(a,b,c,d){""===this.texturePath&&(this.texturePath=a.substring(0,a.lastIndexOf("/")+1));var e=this;(new Ga(e.manager)).load(a,function(c){var f=null;try{f=JSON.parse(c)}catch(h){void 0!==d&&d(h);console.error("THREE:ObjectLoader: Can't parse "+a+".",h.message);return}c=f.metadata;void 0===c||void 0===c.type||"geometry"===c.type.toLowerCase()?console.error("THREE.ObjectLoader: Can't load "+
18091 a+". Use THREE.JSONLoader instead."):e.parse(f,b)},c,d)},setTexturePath:function(a){this.texturePath=a;return this},setCrossOrigin:function(a){this.crossOrigin=a;return this},parse:function(a,b){var c=this.parseShape(a.shapes);c=this.parseGeometries(a.geometries,c);var d=this.parseImages(a.images,function(){void 0!==b&&b(e)});d=this.parseTextures(a.textures,d);d=this.parseMaterials(a.materials,d);var e=this.parseObject(a.object,c,d);a.animations&&(e.animations=this.parseAnimations(a.animations));
18092 void 0!==a.images&&0!==a.images.length||void 0===b||b(e);return e},parseShape:function(a){var b={};if(void 0!==a)for(var c=0,d=a.length;c<d;c++){var e=(new db).fromJSON(a[c]);b[e.uuid]=e}return b},parseGeometries:function(a,b){var c={};if(void 0!==a)for(var d=new he,e=new ge,f=0,g=a.length;f<g;f++){var h=a[f];switch(h.type){case "PlaneGeometry":case "PlaneBufferGeometry":var k=new xa[h.type](h.width,h.height,h.widthSegments,h.heightSegments);break;case "BoxGeometry":case "BoxBufferGeometry":case "CubeGeometry":k=
18093 new xa[h.type](h.width,h.height,h.depth,h.widthSegments,h.heightSegments,h.depthSegments);break;case "CircleGeometry":case "CircleBufferGeometry":k=new xa[h.type](h.radius,h.segments,h.thetaStart,h.thetaLength);break;case "CylinderGeometry":case "CylinderBufferGeometry":k=new xa[h.type](h.radiusTop,h.radiusBottom,h.height,h.radialSegments,h.heightSegments,h.openEnded,h.thetaStart,h.thetaLength);break;case "ConeGeometry":case "ConeBufferGeometry":k=new xa[h.type](h.radius,h.height,h.radialSegments,
18094 h.heightSegments,h.openEnded,h.thetaStart,h.thetaLength);break;case "SphereGeometry":case "SphereBufferGeometry":k=new xa[h.type](h.radius,h.widthSegments,h.heightSegments,h.phiStart,h.phiLength,h.thetaStart,h.thetaLength);break;case "DodecahedronGeometry":case "DodecahedronBufferGeometry":case "IcosahedronGeometry":case "IcosahedronBufferGeometry":case "OctahedronGeometry":case "OctahedronBufferGeometry":case "TetrahedronGeometry":case "TetrahedronBufferGeometry":k=new xa[h.type](h.radius,h.detail);
18095 break;case "RingGeometry":case "RingBufferGeometry":k=new xa[h.type](h.innerRadius,h.outerRadius,h.thetaSegments,h.phiSegments,h.thetaStart,h.thetaLength);break;case "TorusGeometry":case "TorusBufferGeometry":k=new xa[h.type](h.radius,h.tube,h.radialSegments,h.tubularSegments,h.arc);break;case "TorusKnotGeometry":case "TorusKnotBufferGeometry":k=new xa[h.type](h.radius,h.tube,h.tubularSegments,h.radialSegments,h.p,h.q);break;case "LatheGeometry":case "LatheBufferGeometry":k=new xa[h.type](h.points,
18096 h.segments,h.phiStart,h.phiLength);break;case "PolyhedronGeometry":case "PolyhedronBufferGeometry":k=new xa[h.type](h.vertices,h.indices,h.radius,h.details);break;case "ShapeGeometry":case "ShapeBufferGeometry":k=[];for(var m=0,l=h.shapes.length;m<l;m++){var n=b[h.shapes[m]];k.push(n)}k=new xa[h.type](k,h.curveSegments);break;case "ExtrudeGeometry":case "ExtrudeBufferGeometry":k=[];m=0;for(l=h.shapes.length;m<l;m++)n=b[h.shapes[m]],k.push(n);m=h.options.extrudePath;void 0!==m&&(h.options.extrudePath=
18097 (new Af[m.type]).fromJSON(m));k=new xa[h.type](k,h.options);break;case "BufferGeometry":k=e.parse(h);break;case "Geometry":k=d.parse(h,this.texturePath).geometry;break;default:console.warn('THREE.ObjectLoader: Unsupported geometry type "'+h.type+'"');continue}k.uuid=h.uuid;void 0!==h.name&&(k.name=h.name);!0===k.isBufferGeometry&&void 0!==h.userData&&(k.userData=h.userData);c[h.uuid]=k}return c},parseMaterials:function(a,b){var c={};if(void 0!==a){var d=new Kd;d.setTextures(b);b=0;for(var e=a.length;b<
18098 e;b++){var f=a[b];if("MultiMaterial"===f.type){for(var g=[],h=0;h<f.materials.length;h++)g.push(d.parse(f.materials[h]));c[f.uuid]=g}else c[f.uuid]=d.parse(f)}}return c},parseAnimations:function(a){for(var b=[],c=0;c<a.length;c++){var d=a[c],e=Ca.parse(d);void 0!==d.uuid&&(e.uuid=d.uuid);b.push(e)}return b},parseImages:function(a,b){function c(a){d.manager.itemStart(a);return f.load(a,function(){d.manager.itemEnd(a)},void 0,function(){d.manager.itemEnd(a);d.manager.itemError(a)})}var d=this,e={};
18099 if(void 0!==a&&0<a.length){b=new ce(b);var f=new Zc(b);f.setCrossOrigin(this.crossOrigin);b=0;for(var g=a.length;b<g;b++){var h=a[b],k=h.url;if(Array.isArray(k)){e[h.uuid]=[];for(var m=0,l=k.length;m<l;m++){var n=k[m];n=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(n)?n:d.texturePath+n;e[h.uuid].push(c(n))}}else n=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(h.url)?h.url:d.texturePath+h.url,e[h.uuid]=c(n)}}return e},parseTextures:function(a,b){function c(a,b){if("number"===typeof a)return a;console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",
18100 a);return b[a]}var d={};if(void 0!==a)for(var e=0,f=a.length;e<f;e++){var g=a[e];void 0===g.image&&console.warn('THREE.ObjectLoader: No "image" specified for',g.uuid);void 0===b[g.image]&&console.warn("THREE.ObjectLoader: Undefined image",g.image);var h=Array.isArray(b[g.image])?new Ua(b[g.image]):new T(b[g.image]);h.needsUpdate=!0;h.uuid=g.uuid;void 0!==g.name&&(h.name=g.name);void 0!==g.mapping&&(h.mapping=c(g.mapping,Wg));void 0!==g.offset&&h.offset.fromArray(g.offset);void 0!==g.repeat&&h.repeat.fromArray(g.repeat);
18101 void 0!==g.center&&h.center.fromArray(g.center);void 0!==g.rotation&&(h.rotation=g.rotation);void 0!==g.wrap&&(h.wrapS=c(g.wrap[0],Cf),h.wrapT=c(g.wrap[1],Cf));void 0!==g.format&&(h.format=g.format);void 0!==g.minFilter&&(h.minFilter=c(g.minFilter,Df));void 0!==g.magFilter&&(h.magFilter=c(g.magFilter,Df));void 0!==g.anisotropy&&(h.anisotropy=g.anisotropy);void 0!==g.flipY&&(h.flipY=g.flipY);d[g.uuid]=h}return d},parseObject:function(a,b,c){function d(a){void 0===b[a]&&console.warn("THREE.ObjectLoader: Undefined geometry",
18102 a);return b[a]}function e(a){if(void 0!==a){if(Array.isArray(a)){for(var b=[],d=0,e=a.length;d<e;d++){var f=a[d];void 0===c[f]&&console.warn("THREE.ObjectLoader: Undefined material",f);b.push(c[f])}return b}void 0===c[a]&&console.warn("THREE.ObjectLoader: Undefined material",a);return c[a]}}switch(a.type){case "Scene":var f=new qd;void 0!==a.background&&Number.isInteger(a.background)&&(f.background=new G(a.background));void 0!==a.fog&&("Fog"===a.fog.type?f.fog=new Mb(a.fog.color,a.fog.near,a.fog.far):
18103 "FogExp2"===a.fog.type&&(f.fog=new Lb(a.fog.color,a.fog.density)));break;case "PerspectiveCamera":f=new Z(a.fov,a.aspect,a.near,a.far);void 0!==a.focus&&(f.focus=a.focus);void 0!==a.zoom&&(f.zoom=a.zoom);void 0!==a.filmGauge&&(f.filmGauge=a.filmGauge);void 0!==a.filmOffset&&(f.filmOffset=a.filmOffset);void 0!==a.view&&(f.view=Object.assign({},a.view));break;case "OrthographicCamera":f=new Hb(a.left,a.right,a.top,a.bottom,a.near,a.far);void 0!==a.zoom&&(f.zoom=a.zoom);void 0!==a.view&&(f.view=Object.assign({},
18104 a.view));break;case "AmbientLight":f=new Cd(a.color,a.intensity);break;case "DirectionalLight":f=new Bd(a.color,a.intensity);break;case "PointLight":f=new zd(a.color,a.intensity,a.distance,a.decay);break;case "RectAreaLight":f=new Dd(a.color,a.intensity,a.width,a.height);break;case "SpotLight":f=new yd(a.color,a.intensity,a.distance,a.angle,a.penumbra,a.decay);break;case "HemisphereLight":f=new wd(a.color,a.groundColor,a.intensity);break;case "SkinnedMesh":console.warn("THREE.ObjectLoader.parseObject() does not support SkinnedMesh yet.");
18105 case "Mesh":f=d(a.geometry);var g=e(a.material);f=f.bones&&0<f.bones.length?new sd(f,g):new la(f,g);break;case "LOD":f=new Bc;break;case "Line":f=new sa(d(a.geometry),e(a.material),a.mode);break;case "LineLoop":f=new td(d(a.geometry),e(a.material));break;case "LineSegments":f=new W(d(a.geometry),e(a.material));break;case "PointCloud":case "Points":f=new Ob(d(a.geometry),e(a.material));break;case "Sprite":f=new Ac(e(a.material));break;case "Group":f=new Kb;break;default:f=new D}f.uuid=a.uuid;void 0!==
18106 a.name&&(f.name=a.name);void 0!==a.matrix?(f.matrix.fromArray(a.matrix),void 0!==a.matrixAutoUpdate&&(f.matrixAutoUpdate=a.matrixAutoUpdate),f.matrixAutoUpdate&&f.matrix.decompose(f.position,f.quaternion,f.scale)):(void 0!==a.position&&f.position.fromArray(a.position),void 0!==a.rotation&&f.rotation.fromArray(a.rotation),void 0!==a.quaternion&&f.quaternion.fromArray(a.quaternion),void 0!==a.scale&&f.scale.fromArray(a.scale));void 0!==a.castShadow&&(f.castShadow=a.castShadow);void 0!==a.receiveShadow&&
18107 (f.receiveShadow=a.receiveShadow);a.shadow&&(void 0!==a.shadow.bias&&(f.shadow.bias=a.shadow.bias),void 0!==a.shadow.radius&&(f.shadow.radius=a.shadow.radius),void 0!==a.shadow.mapSize&&f.shadow.mapSize.fromArray(a.shadow.mapSize),void 0!==a.shadow.camera&&(f.shadow.camera=this.parseObject(a.shadow.camera)));void 0!==a.visible&&(f.visible=a.visible);void 0!==a.frustumCulled&&(f.frustumCulled=a.frustumCulled);void 0!==a.renderOrder&&(f.renderOrder=a.renderOrder);void 0!==a.userData&&(f.userData=a.userData);
18108 void 0!==a.layers&&(f.layers.mask=a.layers);if(void 0!==a.children){g=a.children;for(var h=0;h<g.length;h++)f.add(this.parseObject(g[h],b,c))}if("LOD"===a.type)for(a=a.levels,g=0;g<a.length;g++){h=a[g];var k=f.getObjectByProperty("uuid",h.object);void 0!==k&&f.addLevel(k,h.distance)}return f}});var Wg={UVMapping:300,CubeReflectionMapping:301,CubeRefractionMapping:302,EquirectangularReflectionMapping:303,EquirectangularRefractionMapping:304,SphericalReflectionMapping:305,CubeUVReflectionMapping:306,
18109 CubeUVRefractionMapping:307},Cf={RepeatWrapping:1E3,ClampToEdgeWrapping:1001,MirroredRepeatWrapping:1002},Df={NearestFilter:1003,NearestMipMapNearestFilter:1004,NearestMipMapLinearFilter:1005,LinearFilter:1006,LinearMipMapNearestFilter:1007,LinearMipMapLinearFilter:1008};ie.prototype={constructor:ie,setOptions:function(a){this.options=a;return this},load:function(a,b,c,d){void 0===a&&(a="");void 0!==this.path&&(a=this.path+a);a=this.manager.resolveURL(a);var e=this,f=Fb.get(a);if(void 0!==f)return e.manager.itemStart(a),
18110 setTimeout(function(){b&&b(f);e.manager.itemEnd(a)},0),f;fetch(a).then(function(a){return a.blob()}).then(function(a){return createImageBitmap(a,e.options)}).then(function(c){Fb.add(a,c);b&&b(c);e.manager.itemEnd(a)}).catch(function(b){d&&d(b);e.manager.itemEnd(a);e.manager.itemError(a)})},setCrossOrigin:function(){return this},setPath:function(a){this.path=a;return this}};Object.assign(je.prototype,{moveTo:function(a,b){this.currentPath=new La;this.subPaths.push(this.currentPath);this.currentPath.moveTo(a,
18111 b)},lineTo:function(a,b){this.currentPath.lineTo(a,b)},quadraticCurveTo:function(a,b,c,d){this.currentPath.quadraticCurveTo(a,b,c,d)},bezierCurveTo:function(a,b,c,d,e,f){this.currentPath.bezierCurveTo(a,b,c,d,e,f)},splineThru:function(a){this.currentPath.splineThru(a)},toShapes:function(a,b){function c(a){for(var b=[],c=0,d=a.length;c<d;c++){var e=a[c],f=new db;f.curves=e.curves;b.push(f)}return b}function d(a,b){for(var c=b.length,d=!1,e=c-1,f=0;f<c;e=f++){var g=b[e],h=b[f],k=h.x-g.x,m=h.y-g.y;if(Math.abs(m)>
18112 Number.EPSILON){if(0>m&&(g=b[f],k=-k,h=b[e],m=-m),!(a.y<g.y||a.y>h.y))if(a.y===g.y){if(a.x===g.x)return!0}else{e=m*(a.x-g.x)-k*(a.y-g.y);if(0===e)return!0;0>e||(d=!d)}}else if(a.y===g.y&&(h.x<=a.x&&a.x<=g.x||g.x<=a.x&&a.x<=h.x))return!0}return d}var e=Va.isClockWise,f=this.subPaths;if(0===f.length)return[];if(!0===b)return c(f);b=[];if(1===f.length){var g=f[0];var h=new db;h.curves=g.curves;b.push(h);return b}var k=!e(f[0].getPoints());k=a?!k:k;h=[];var m=[],l=[],n=0;m[n]=void 0;l[n]=[];for(var p=
18113 0,u=f.length;p<u;p++){g=f[p];var r=g.getPoints();var v=e(r);(v=a?!v:v)?(!k&&m[n]&&n++,m[n]={s:new db,p:r},m[n].s.curves=g.curves,k&&n++,l[n]=[]):l[n].push({h:g,p:r[0]})}if(!m[0])return c(f);if(1<m.length){p=!1;a=[];e=0;for(f=m.length;e<f;e++)h[e]=[];e=0;for(f=m.length;e<f;e++)for(g=l[e],v=0;v<g.length;v++){k=g[v];n=!0;for(r=0;r<m.length;r++)d(k.p,m[r].p)&&(e!==r&&a.push({froms:e,tos:r,hole:v}),n?(n=!1,h[r].push(k)):p=!0);n&&h[e].push(k)}0<a.length&&(p||(l=h))}p=0;for(e=m.length;p<e;p++)for(h=m[p].s,
18114 b.push(h),a=l[p],f=0,g=a.length;f<g;f++)h.holes.push(a[f].h);return b}});Object.assign(ke.prototype,{isFont:!0,generateShapes:function(a,b){void 0===b&&(b=100);var c=[],d=b;b=this.data;var e=Array.from?Array.from(a):String(a).split("");d/=b.resolution;var f=(b.boundingBox.yMax-b.boundingBox.yMin+b.underlineThickness)*d;a=[];for(var g=0,h=0,k=0;k<e.length;k++){var m=e[k];if("\n"===m)g=0,h-=f;else{var l=d;var n=g,p=h;if(m=b.glyphs[m]||b.glyphs["?"]){var u=new je;if(m.o)for(var r=m._cachedOutline||(m._cachedOutline=
18115 m.o.split(" ")),v=0,y=r.length;v<y;)switch(r[v++]){case "m":var x=r[v++]*l+n;var w=r[v++]*l+p;u.moveTo(x,w);break;case "l":x=r[v++]*l+n;w=r[v++]*l+p;u.lineTo(x,w);break;case "q":var z=r[v++]*l+n;var A=r[v++]*l+p;var C=r[v++]*l+n;var D=r[v++]*l+p;u.quadraticCurveTo(C,D,z,A);break;case "b":z=r[v++]*l+n,A=r[v++]*l+p,C=r[v++]*l+n,D=r[v++]*l+p,x=r[v++]*l+n,w=r[v++]*l+p,u.bezierCurveTo(C,D,x,w,z,A)}l={offsetX:m.ha*l,path:u}}else l=void 0;g+=l.offsetX;a.push(l.path)}}b=0;for(e=a.length;b<e;b++)Array.prototype.push.apply(c,
18116 a[b].toShapes());return c}});Object.assign(nf.prototype,{load:function(a,b,c,d){var e=this,f=new Ga(this.manager);f.setPath(this.path);f.load(a,function(a){try{var c=JSON.parse(a)}catch(k){console.warn("THREE.FontLoader: typeface.js support is being deprecated. Use typeface.json instead."),c=JSON.parse(a.substring(65,a.length-2))}a=e.parse(c);b&&b(a)},c,d)},parse:function(a){return new ke(a)},setPath:function(a){this.path=a;return this}});var Pd,ne={getContext:function(){void 0===Pd&&(Pd=new (window.AudioContext||
18117 window.webkitAudioContext));return Pd},setContext:function(a){Pd=a}};Object.assign(le.prototype,{load:function(a,b,c,d){var e=new Ga(this.manager);e.setResponseType("arraybuffer");e.load(a,function(a){a=a.slice(0);ne.getContext().decodeAudioData(a,function(a){b(a)})},c,d)}});Object.assign(of.prototype,{update:function(){var a,b,c,d,e,f,g,h,k=new I,l=new I;return function(m){if(a!==this||b!==m.focus||c!==m.fov||d!==m.aspect*this.aspect||e!==m.near||f!==m.far||g!==m.zoom||h!==this.eyeSep){a=this;b=
18118 m.focus;c=m.fov;d=m.aspect*this.aspect;e=m.near;f=m.far;g=m.zoom;var n=m.projectionMatrix.clone();h=this.eyeSep/2;var p=h*e/b,q=e*Math.tan(H.DEG2RAD*c*.5)/g;l.elements[12]=-h;k.elements[12]=h;var r=-q*d+p;var v=q*d+p;n.elements[0]=2*e/(v-r);n.elements[8]=(v+r)/(v-r);this.cameraL.projectionMatrix.copy(n);r=-q*d-p;v=q*d-p;n.elements[0]=2*e/(v-r);n.elements[8]=(v+r)/(v-r);this.cameraR.projectionMatrix.copy(n)}this.cameraL.matrixWorld.copy(m.matrixWorld).multiply(l);this.cameraR.matrixWorld.copy(m.matrixWorld).multiply(k)}}()});
18119 dd.prototype=Object.create(D.prototype);dd.prototype.constructor=dd;me.prototype=Object.assign(Object.create(D.prototype),{constructor:me,getInput:function(){return this.gain},removeFilter:function(){null!==this.filter&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null);return this},getFilter:function(){return this.filter},setFilter:function(a){null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):
18120 this.gain.disconnect(this.context.destination);this.filter=a;this.gain.connect(this.filter);this.filter.connect(this.context.destination);return this},getMasterVolume:function(){return this.gain.gain.value},setMasterVolume:function(a){this.gain.gain.setTargetAtTime(a,this.context.currentTime,.01);return this},updateMatrixWorld:function(){var a=new p,b=new fa,c=new p,d=new p;return function(e){D.prototype.updateMatrixWorld.call(this,e);e=this.context.listener;var f=this.up;this.matrixWorld.decompose(a,
18121 b,c);d.set(0,0,-1).applyQuaternion(b);e.positionX?(e.positionX.setValueAtTime(a.x,this.context.currentTime),e.positionY.setValueAtTime(a.y,this.context.currentTime),e.positionZ.setValueAtTime(a.z,this.context.currentTime),e.forwardX.setValueAtTime(d.x,this.context.currentTime),e.forwardY.setValueAtTime(d.y,this.context.currentTime),e.forwardZ.setValueAtTime(d.z,this.context.currentTime),e.upX.setValueAtTime(f.x,this.context.currentTime),e.upY.setValueAtTime(f.y,this.context.currentTime),e.upZ.setValueAtTime(f.z,
18122 this.context.currentTime)):(e.setPosition(a.x,a.y,a.z),e.setOrientation(d.x,d.y,d.z,f.x,f.y,f.z))}}()});hc.prototype=Object.assign(Object.create(D.prototype),{constructor:hc,getOutput:function(){return this.gain},setNodeSource:function(a){this.hasPlaybackControl=!1;this.sourceType="audioNode";this.source=a;this.connect();return this},setMediaElementSource:function(a){this.hasPlaybackControl=!1;this.sourceType="mediaNode";this.source=this.context.createMediaElementSource(a);this.connect();return this},
18123 setBuffer:function(a){this.buffer=a;this.sourceType="buffer";this.autoplay&&this.play();return this},play:function(){if(!0===this.isPlaying)console.warn("THREE.Audio: Audio is already playing.");else if(!1===this.hasPlaybackControl)console.warn("THREE.Audio: this Audio has no playback control.");else{var a=this.context.createBufferSource();a.buffer=this.buffer;a.loop=this.loop;a.onended=this.onEnded.bind(this);a.playbackRate.setValueAtTime(this.playbackRate,this.startTime);this.startTime=this.context.currentTime;
18124 a.start(this.startTime,this.offset);this.isPlaying=!0;this.source=a;return this.connect()}},pause:function(){if(!1===this.hasPlaybackControl)console.warn("THREE.Audio: this Audio has no playback control.");else return!0===this.isPlaying&&(this.source.stop(),this.source.onended=null,this.offset+=(this.context.currentTime-this.startTime)*this.playbackRate,this.isPlaying=!1),this},stop:function(){if(!1===this.hasPlaybackControl)console.warn("THREE.Audio: this Audio has no playback control.");else return this.source.stop(),
18125 this.source.onended=null,this.offset=0,this.isPlaying=!1,this},connect:function(){if(0<this.filters.length){this.source.connect(this.filters[0]);for(var a=1,b=this.filters.length;a<b;a++)this.filters[a-1].connect(this.filters[a]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this},disconnect:function(){if(0<this.filters.length){this.source.disconnect(this.filters[0]);for(var a=1,b=this.filters.length;a<b;a++)this.filters[a-1].disconnect(this.filters[a]);
18126 this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this},getFilters:function(){return this.filters},setFilters:function(a){a||(a=[]);!0===this.isPlaying?(this.disconnect(),this.filters=a,this.connect()):this.filters=a;return this},getFilter:function(){return this.getFilters()[0]},setFilter:function(a){return this.setFilters(a?[a]:[])},setPlaybackRate:function(a){if(!1===this.hasPlaybackControl)console.warn("THREE.Audio: this Audio has no playback control.");
18127 else return this.playbackRate=a,!0===this.isPlaying&&this.source.playbackRate.setValueAtTime(this.playbackRate,this.context.currentTime),this},getPlaybackRate:function(){return this.playbackRate},onEnded:function(){this.isPlaying=!1},getLoop:function(){return!1===this.hasPlaybackControl?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop},setLoop:function(a){if(!1===this.hasPlaybackControl)console.warn("THREE.Audio: this Audio has no playback control.");else return this.loop=
18128 a,!0===this.isPlaying&&(this.source.loop=this.loop),this},getVolume:function(){return this.gain.gain.value},setVolume:function(a){this.gain.gain.setTargetAtTime(a,this.context.currentTime,.01);return this}});oe.prototype=Object.assign(Object.create(hc.prototype),{constructor:oe,getOutput:function(){return this.panner},getRefDistance:function(){return this.panner.refDistance},setRefDistance:function(a){this.panner.refDistance=a;return this},getRolloffFactor:function(){return this.panner.rolloffFactor},
18129 setRolloffFactor:function(a){this.panner.rolloffFactor=a;return this},getDistanceModel:function(){return this.panner.distanceModel},setDistanceModel:function(a){this.panner.distanceModel=a;return this},getMaxDistance:function(){return this.panner.maxDistance},setMaxDistance:function(a){this.panner.maxDistance=a;return this},setDirectionalCone:function(a,b,c){this.panner.coneInnerAngle=a;this.panner.coneOuterAngle=b;this.panner.coneOuterGain=c;return this},updateMatrixWorld:function(){var a=new p,
18130 b=new fa,c=new p,d=new p;return function(e){D.prototype.updateMatrixWorld.call(this,e);e=this.panner;this.matrixWorld.decompose(a,b,c);d.set(0,0,1).applyQuaternion(b);e.setPosition(a.x,a.y,a.z);e.setOrientation(d.x,d.y,d.z)}}()});Object.assign(pe.prototype,{getFrequencyData:function(){this.analyser.getByteFrequencyData(this.data);return this.data},getAverageFrequency:function(){for(var a=0,b=this.getFrequencyData(),c=0;c<b.length;c++)a+=b[c];return a/b.length}});Object.assign(qe.prototype,{accumulate:function(a,
18131 b){var c=this.buffer,d=this.valueSize;a=a*d+d;var e=this.cumulativeWeight;if(0===e){for(e=0;e!==d;++e)c[a+e]=c[e];e=b}else e+=b,this._mixBufferRegion(c,a,0,b/e,d);this.cumulativeWeight=e},apply:function(a){var b=this.valueSize,c=this.buffer;a=a*b+b;var d=this.cumulativeWeight,e=this.binding;this.cumulativeWeight=0;1>d&&this._mixBufferRegion(c,a,3*b,1-d,b);d=b;for(var f=b+b;d!==f;++d)if(c[d]!==c[d+b]){e.setValue(c,a);break}},saveOriginalState:function(){var a=this.buffer,b=this.valueSize,c=3*b;this.binding.getValue(a,
18132 c);for(var d=b;d!==c;++d)a[d]=a[c+d%b];this.cumulativeWeight=0},restoreOriginalState:function(){this.binding.setValue(this.buffer,3*this.valueSize)},_select:function(a,b,c,d,e){if(.5<=d)for(d=0;d!==e;++d)a[b+d]=a[c+d]},_slerp:function(a,b,c,d){fa.slerpFlat(a,b,a,b,a,c,d)},_lerp:function(a,b,c,d,e){for(var f=1-d,g=0;g!==e;++g){var h=b+g;a[h]=a[h]*f+a[c+g]*d}}});Object.assign(pf.prototype,{getValue:function(a,b){this.bind();var c=this._bindings[this._targetGroup.nCachedObjects_];void 0!==c&&c.getValue(a,
18133 b)},setValue:function(a,b){for(var c=this._bindings,d=this._targetGroup.nCachedObjects_,e=c.length;d!==e;++d)c[d].setValue(a,b)},bind:function(){for(var a=this._bindings,b=this._targetGroup.nCachedObjects_,c=a.length;b!==c;++b)a[b].bind()},unbind:function(){for(var a=this._bindings,b=this._targetGroup.nCachedObjects_,c=a.length;b!==c;++b)a[b].unbind()}});Object.assign(pa,{Composite:pf,create:function(a,b,c){return a&&a.isAnimationObjectGroup?new pa.Composite(a,b,c):new pa(a,b,c)},sanitizeNodeName:function(){var a=
18134 /[\[\]\.:\/]/g;return function(b){return b.replace(/\s/g,"_").replace(a,"")}}(),parseTrackName:function(){var a="[^"+"\\[\\]\\.:\\/".replace("\\.","")+"]",b=/((?:WC+[\/:])*)/.source.replace("WC","[^\\[\\]\\.:\\/]");a=/(WCOD+)?/.source.replace("WCOD",a);var c=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC","[^\\[\\]\\.:\\/]"),d=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC","[^\\[\\]\\.:\\/]"),e=new RegExp("^"+b+a+c+d+"$"),f=["material","materials","bones"];return function(a){var b=e.exec(a);if(!b)throw Error("PropertyBinding: Cannot parse trackName: "+
18135 a);b={nodeName:b[2],objectName:b[3],objectIndex:b[4],propertyName:b[5],propertyIndex:b[6]};var c=b.nodeName&&b.nodeName.lastIndexOf(".");if(void 0!==c&&-1!==c){var d=b.nodeName.substring(c+1);-1!==f.indexOf(d)&&(b.nodeName=b.nodeName.substring(0,c),b.objectName=d)}if(null===b.propertyName||0===b.propertyName.length)throw Error("PropertyBinding: can not parse propertyName from trackName: "+a);return b}}(),findNode:function(a,b){if(!b||""===b||"root"===b||"."===b||-1===b||b===a.name||b===a.uuid)return a;
18136 if(a.skeleton){var c=a.skeleton.getBoneByName(b);if(void 0!==c)return c}if(a.children){var d=function(a){for(var c=0;c<a.length;c++){var e=a[c];if(e.name===b||e.uuid===b||(e=d(e.children)))return e}return null};if(a=d(a.children))return a}return null}});Object.assign(pa.prototype,{_getValue_unavailable:function(){},_setValue_unavailable:function(){},BindingType:{Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},Versioning:{None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},GetterByBindingType:[function(a,
18137 b){a[b]=this.node[this.propertyName]},function(a,b){for(var c=this.resolvedProperty,d=0,e=c.length;d!==e;++d)a[b++]=c[d]},function(a,b){a[b]=this.resolvedProperty[this.propertyIndex]},function(a,b){this.resolvedProperty.toArray(a,b)}],SetterByBindingTypeAndVersioning:[[function(a,b){this.targetObject[this.propertyName]=a[b]},function(a,b){this.targetObject[this.propertyName]=a[b];this.targetObject.needsUpdate=!0},function(a,b){this.targetObject[this.propertyName]=a[b];this.targetObject.matrixWorldNeedsUpdate=
18138 !0}],[function(a,b){for(var c=this.resolvedProperty,d=0,e=c.length;d!==e;++d)c[d]=a[b++]},function(a,b){for(var c=this.resolvedProperty,d=0,e=c.length;d!==e;++d)c[d]=a[b++];this.targetObject.needsUpdate=!0},function(a,b){for(var c=this.resolvedProperty,d=0,e=c.length;d!==e;++d)c[d]=a[b++];this.targetObject.matrixWorldNeedsUpdate=!0}],[function(a,b){this.resolvedProperty[this.propertyIndex]=a[b]},function(a,b){this.resolvedProperty[this.propertyIndex]=a[b];this.targetObject.needsUpdate=!0},function(a,
18139 b){this.resolvedProperty[this.propertyIndex]=a[b];this.targetObject.matrixWorldNeedsUpdate=!0}],[function(a,b){this.resolvedProperty.fromArray(a,b)},function(a,b){this.resolvedProperty.fromArray(a,b);this.targetObject.needsUpdate=!0},function(a,b){this.resolvedProperty.fromArray(a,b);this.targetObject.matrixWorldNeedsUpdate=!0}]],getValue:function(a,b){this.bind();this.getValue(a,b)},setValue:function(a,b){this.bind();this.setValue(a,b)},bind:function(){var a=this.node,b=this.parsedPath,c=b.objectName,
18140 d=b.propertyName,e=b.propertyIndex;a||(this.node=a=pa.findNode(this.rootNode,b.nodeName)||this.rootNode);this.getValue=this._getValue_unavailable;this.setValue=this._setValue_unavailable;if(a){if(c){var f=b.objectIndex;switch(c){case "materials":if(!a.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!a.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",
18141 this);return}a=a.material.materials;break;case "bones":if(!a.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}a=a.skeleton.bones;for(c=0;c<a.length;c++)if(a[c].name===f){f=c;break}break;default:if(void 0===a[c]){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}a=a[c]}if(void 0!==f){if(void 0===a[f]){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",
18142 this,a);return}a=a[f]}}f=a[d];if(void 0===f)console.error("THREE.PropertyBinding: Trying to update property for track: "+b.nodeName+"."+d+" but it wasn't found.",a);else{b=this.Versioning.None;void 0!==a.needsUpdate?(b=this.Versioning.NeedsUpdate,this.targetObject=a):void 0!==a.matrixWorldNeedsUpdate&&(b=this.Versioning.MatrixWorldNeedsUpdate,this.targetObject=a);c=this.BindingType.Direct;if(void 0!==e){if("morphTargetInfluences"===d){if(!a.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",
18143 this);return}if(a.geometry.isBufferGeometry){if(!a.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}for(c=0;c<this.node.geometry.morphAttributes.position.length;c++)if(a.geometry.morphAttributes.position[c].name===e){e=c;break}}else{if(!a.geometry.morphTargets){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphTargets.",
18144 this);return}for(c=0;c<this.node.geometry.morphTargets.length;c++)if(a.geometry.morphTargets[c].name===e){e=c;break}}}c=this.BindingType.ArrayElement;this.resolvedProperty=f;this.propertyIndex=e}else void 0!==f.fromArray&&void 0!==f.toArray?(c=this.BindingType.HasFromToArray,this.resolvedProperty=f):Array.isArray(f)?(c=this.BindingType.EntireArray,this.resolvedProperty=f):this.propertyName=d;this.getValue=this.GetterByBindingType[c];this.setValue=this.SetterByBindingTypeAndVersioning[c][b]}}else console.error("THREE.PropertyBinding: Trying to update node for track: "+
18145 this.path+" but it wasn't found.")},unbind:function(){this.node=null;this.getValue=this._getValue_unbound;this.setValue=this._setValue_unbound}});Object.assign(pa.prototype,{_getValue_unbound:pa.prototype.getValue,_setValue_unbound:pa.prototype.setValue});Object.assign(qf.prototype,{isAnimationObjectGroup:!0,add:function(){for(var a=this._objects,b=a.length,c=this.nCachedObjects_,d=this._indicesByUUID,e=this._paths,f=this._parsedPaths,g=this._bindings,h=g.length,k=void 0,l=0,p=arguments.length;l!==
18146 p;++l){var n=arguments[l],t=n.uuid,u=d[t];if(void 0===u){u=b++;d[t]=u;a.push(n);t=0;for(var r=h;t!==r;++t)g[t].push(new pa(n,e[t],f[t]))}else if(u<c){k=a[u];var v=--c;r=a[v];d[r.uuid]=u;a[u]=r;d[t]=v;a[v]=n;t=0;for(r=h;t!==r;++t){var y=g[t],x=y[u];y[u]=y[v];void 0===x&&(x=new pa(n,e[t],f[t]));y[v]=x}}else a[u]!==k&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=
18147 c},remove:function(){for(var a=this._objects,b=this.nCachedObjects_,c=this._indicesByUUID,d=this._bindings,e=d.length,f=0,g=arguments.length;f!==g;++f){var h=arguments[f],k=h.uuid,l=c[k];if(void 0!==l&&l>=b){var p=b++,n=a[p];c[n.uuid]=l;a[l]=n;c[k]=p;a[p]=h;h=0;for(k=e;h!==k;++h){n=d[h];var t=n[l];n[l]=n[p];n[p]=t}}}this.nCachedObjects_=b},uncache:function(){for(var a=this._objects,b=a.length,c=this.nCachedObjects_,d=this._indicesByUUID,e=this._bindings,f=e.length,g=0,h=arguments.length;g!==h;++g){var k=
18148 arguments[g].uuid,l=d[k];if(void 0!==l)if(delete d[k],l<c){k=--c;var p=a[k],n=--b,t=a[n];d[p.uuid]=l;a[l]=p;d[t.uuid]=k;a[k]=t;a.pop();p=0;for(t=f;p!==t;++p){var u=e[p],r=u[n];u[l]=u[k];u[k]=r;u.pop()}}else for(n=--b,t=a[n],d[t.uuid]=l,a[l]=t,a.pop(),p=0,t=f;p!==t;++p)u=e[p],u[l]=u[n],u.pop()}this.nCachedObjects_=c},subscribe_:function(a,b){var c=this._bindingsIndicesByPath,d=c[a],e=this._bindings;if(void 0!==d)return e[d];var f=this._paths,g=this._parsedPaths,h=this._objects,k=this.nCachedObjects_,
18149 l=Array(h.length);d=e.length;c[a]=d;f.push(a);g.push(b);e.push(l);c=k;for(d=h.length;c!==d;++c)l[c]=new pa(h[c],a,b);return l},unsubscribe_:function(a){var b=this._bindingsIndicesByPath,c=b[a];if(void 0!==c){var d=this._paths,e=this._parsedPaths,f=this._bindings,g=f.length-1,h=f[g];b[a[g]]=c;f[c]=h;f.pop();e[c]=e[g];e.pop();d[c]=d[g];d.pop()}}});Object.assign(rf.prototype,{play:function(){this._mixer._activateAction(this);return this},stop:function(){this._mixer._deactivateAction(this);return this.reset()},
18150 reset:function(){this.paused=!1;this.enabled=!0;this.time=0;this._loopCount=-1;this._startTime=null;return this.stopFading().stopWarping()},isRunning:function(){return this.enabled&&!this.paused&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)},isScheduled:function(){return this._mixer._isActiveAction(this)},startAt:function(a){this._startTime=a;return this},setLoop:function(a,b){this.loop=a;this.repetitions=b;return this},setEffectiveWeight:function(a){this.weight=a;
18151 this._effectiveWeight=this.enabled?a:0;return this.stopFading()},getEffectiveWeight:function(){return this._effectiveWeight},fadeIn:function(a){return this._scheduleFading(a,0,1)},fadeOut:function(a){return this._scheduleFading(a,1,0)},crossFadeFrom:function(a,b,c){a.fadeOut(b);this.fadeIn(b);if(c){c=this._clip.duration;var d=a._clip.duration,e=c/d;a.warp(1,d/c,b);this.warp(e,1,b)}return this},crossFadeTo:function(a,b,c){return a.crossFadeFrom(this,b,c)},stopFading:function(){var a=this._weightInterpolant;
18152 null!==a&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(a));return this},setEffectiveTimeScale:function(a){this.timeScale=a;this._effectiveTimeScale=this.paused?0:a;return this.stopWarping()},getEffectiveTimeScale:function(){return this._effectiveTimeScale},setDuration:function(a){this.timeScale=this._clip.duration/a;return this.stopWarping()},syncWith:function(a){this.time=a.time;this.timeScale=a.timeScale;return this.stopWarping()},halt:function(a){return this.warp(this._effectiveTimeScale,
18153 0,a)},warp:function(a,b,c){var d=this._mixer,e=d.time,f=this._timeScaleInterpolant,g=this.timeScale;null===f&&(this._timeScaleInterpolant=f=d._lendControlInterpolant());d=f.parameterPositions;f=f.sampleValues;d[0]=e;d[1]=e+c;f[0]=a/g;f[1]=b/g;return this},stopWarping:function(){var a=this._timeScaleInterpolant;null!==a&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(a));return this},getMixer:function(){return this._mixer},getClip:function(){return this._clip},getRoot:function(){return this._localRoot||
18154 this._mixer._root},_update:function(a,b,c,d){if(this.enabled){var e=this._startTime;if(null!==e){b=(a-e)*c;if(0>b||0===c)return;this._startTime=null;b*=c}b*=this._updateTimeScale(a);c=this._updateTime(b);a=this._updateWeight(a);if(0<a){b=this._interpolants;e=this._propertyBindings;for(var f=0,g=b.length;f!==g;++f)b[f].evaluate(c),e[f].accumulate(d,a)}}else this._updateWeight(a)},_updateWeight:function(a){var b=0;if(this.enabled){b=this.weight;var c=this._weightInterpolant;if(null!==c){var d=c.evaluate(a)[0];
18155 b*=d;a>c.parameterPositions[1]&&(this.stopFading(),0===d&&(this.enabled=!1))}}return this._effectiveWeight=b},_updateTimeScale:function(a){var b=0;if(!this.paused){b=this.timeScale;var c=this._timeScaleInterpolant;if(null!==c){var d=c.evaluate(a)[0];b*=d;a>c.parameterPositions[1]&&(this.stopWarping(),0===b?this.paused=!0:this.timeScale=b)}}return this._effectiveTimeScale=b},_updateTime:function(a){var b=this.time+a,c=this._clip.duration,d=this.loop,e=this._loopCount,f=2202===d;if(0===a)return-1===
18156 e?b:f&&1===(e&1)?c-b:b;if(2200===d)a:{if(-1===e&&(this._loopCount=0,this._setEndings(!0,!0,!1)),b>=c)b=c;else if(0>b)b=0;else break a;this.clampWhenFinished?this.paused=!0:this.enabled=!1;this._mixer.dispatchEvent({type:"finished",action:this,direction:0>a?-1:1})}else{-1===e&&(0<=a?(e=0,this._setEndings(!0,0===this.repetitions,f)):this._setEndings(0===this.repetitions,!0,f));if(b>=c||0>b){d=Math.floor(b/c);b-=c*d;e+=Math.abs(d);var g=this.repetitions-e;0>=g?(this.clampWhenFinished?this.paused=!0:
18157 this.enabled=!1,b=0<a?c:0,this._mixer.dispatchEvent({type:"finished",action:this,direction:0<a?1:-1})):(1===g?(a=0>a,this._setEndings(a,!a,f)):this._setEndings(!1,!1,f),this._loopCount=e,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:d}))}if(f&&1===(e&1))return this.time=b,c-b}return this.time=b},_setEndings:function(a,b,c){var d=this._interpolantSettings;c?(d.endingStart=2401,d.endingEnd=2401):(d.endingStart=a?this.zeroSlopeAtStart?2401:2400:2402,d.endingEnd=b?this.zeroSlopeAtEnd?2401:
18158 2400:2402)},_scheduleFading:function(a,b,c){var d=this._mixer,e=d.time,f=this._weightInterpolant;null===f&&(this._weightInterpolant=f=d._lendControlInterpolant());d=f.parameterPositions;f=f.sampleValues;d[0]=e;f[0]=b;d[1]=e+a;f[1]=c;return this}});re.prototype=Object.assign(Object.create(ya.prototype),{constructor:re,_bindAction:function(a,b){var c=a._localRoot||this._root,d=a._clip.tracks,e=d.length,f=a._propertyBindings;a=a._interpolants;var g=c.uuid,h=this._bindingsByRootAndName,k=h[g];void 0===
18159 k&&(k={},h[g]=k);for(h=0;h!==e;++h){var l=d[h],p=l.name,n=k[p];if(void 0===n){n=f[h];if(void 0!==n){null===n._cacheIndex&&(++n.referenceCount,this._addInactiveBinding(n,g,p));continue}n=new qe(pa.create(c,p,b&&b._propertyBindings[h].binding.parsedPath),l.ValueTypeName,l.getValueSize());++n.referenceCount;this._addInactiveBinding(n,g,p)}f[h]=n;a[h].resultBuffer=n.buffer}},_activateAction:function(a){if(!this._isActiveAction(a)){if(null===a._cacheIndex){var b=(a._localRoot||this._root).uuid,c=a._clip.uuid,
18160 d=this._actionsByClip[c];this._bindAction(a,d&&d.knownActions[0]);this._addInactiveAction(a,c,b)}b=a._propertyBindings;c=0;for(d=b.length;c!==d;++c){var e=b[c];0===e.useCount++&&(this._lendBinding(e),e.saveOriginalState())}this._lendAction(a)}},_deactivateAction:function(a){if(this._isActiveAction(a)){for(var b=a._propertyBindings,c=0,d=b.length;c!==d;++c){var e=b[c];0===--e.useCount&&(e.restoreOriginalState(),this._takeBackBinding(e))}this._takeBackAction(a)}},_initMemoryManager:function(){this._actions=
18161 [];this._nActiveActions=0;this._actionsByClip={};this._bindings=[];this._nActiveBindings=0;this._bindingsByRootAndName={};this._controlInterpolants=[];this._nActiveControlInterpolants=0;var a=this;this.stats={actions:{get total(){return a._actions.length},get inUse(){return a._nActiveActions}},bindings:{get total(){return a._bindings.length},get inUse(){return a._nActiveBindings}},controlInterpolants:{get total(){return a._controlInterpolants.length},get inUse(){return a._nActiveControlInterpolants}}}},
18162 _isActiveAction:function(a){a=a._cacheIndex;return null!==a&&a<this._nActiveActions},_addInactiveAction:function(a,b,c){var d=this._actions,e=this._actionsByClip,f=e[b];void 0===f?(f={knownActions:[a],actionByRoot:{}},a._byClipCacheIndex=0,e[b]=f):(b=f.knownActions,a._byClipCacheIndex=b.length,b.push(a));a._cacheIndex=d.length;d.push(a);f.actionByRoot[c]=a},_removeInactiveAction:function(a){var b=this._actions,c=b[b.length-1],d=a._cacheIndex;c._cacheIndex=d;b[d]=c;b.pop();a._cacheIndex=null;b=a._clip.uuid;
18163 c=this._actionsByClip;d=c[b];var e=d.knownActions,f=e[e.length-1],g=a._byClipCacheIndex;f._byClipCacheIndex=g;e[g]=f;e.pop();a._byClipCacheIndex=null;delete d.actionByRoot[(a._localRoot||this._root).uuid];0===e.length&&delete c[b];this._removeInactiveBindingsForAction(a)},_removeInactiveBindingsForAction:function(a){a=a._propertyBindings;for(var b=0,c=a.length;b!==c;++b){var d=a[b];0===--d.referenceCount&&this._removeInactiveBinding(d)}},_lendAction:function(a){var b=this._actions,c=a._cacheIndex,
18164 d=this._nActiveActions++,e=b[d];a._cacheIndex=d;b[d]=a;e._cacheIndex=c;b[c]=e},_takeBackAction:function(a){var b=this._actions,c=a._cacheIndex,d=--this._nActiveActions,e=b[d];a._cacheIndex=d;b[d]=a;e._cacheIndex=c;b[c]=e},_addInactiveBinding:function(a,b,c){var d=this._bindingsByRootAndName,e=d[b],f=this._bindings;void 0===e&&(e={},d[b]=e);e[c]=a;a._cacheIndex=f.length;f.push(a)},_removeInactiveBinding:function(a){var b=this._bindings,c=a.binding,d=c.rootNode.uuid;c=c.path;var e=this._bindingsByRootAndName,
18165 f=e[d],g=b[b.length-1];a=a._cacheIndex;g._cacheIndex=a;b[a]=g;b.pop();delete f[c];a:{for(var h in f)break a;delete e[d]}},_lendBinding:function(a){var b=this._bindings,c=a._cacheIndex,d=this._nActiveBindings++,e=b[d];a._cacheIndex=d;b[d]=a;e._cacheIndex=c;b[c]=e},_takeBackBinding:function(a){var b=this._bindings,c=a._cacheIndex,d=--this._nActiveBindings,e=b[d];a._cacheIndex=d;b[d]=a;e._cacheIndex=c;b[c]=e},_lendControlInterpolant:function(){var a=this._controlInterpolants,b=this._nActiveControlInterpolants++,
18166 c=a[b];void 0===c&&(c=new bd(new Float32Array(2),new Float32Array(2),1,this._controlInterpolantsResultBuffer),c.__cacheIndex=b,a[b]=c);return c},_takeBackControlInterpolant:function(a){var b=this._controlInterpolants,c=a.__cacheIndex,d=--this._nActiveControlInterpolants,e=b[d];a.__cacheIndex=d;b[d]=a;e.__cacheIndex=c;b[c]=e},_controlInterpolantsResultBuffer:new Float32Array(1),clipAction:function(a,b){var c=b||this._root,d=c.uuid;c="string"===typeof a?Ca.findByName(c,a):a;a=null!==c?c.uuid:a;var e=
18167 this._actionsByClip[a],f=null;if(void 0!==e){f=e.actionByRoot[d];if(void 0!==f)return f;f=e.knownActions[0];null===c&&(c=f._clip)}if(null===c)return null;b=new rf(this,c,b);this._bindAction(b,f);this._addInactiveAction(b,a,d);return b},existingAction:function(a,b){var c=b||this._root;b=c.uuid;c="string"===typeof a?Ca.findByName(c,a):a;a=this._actionsByClip[c?c.uuid:a];return void 0!==a?a.actionByRoot[b]||null:null},stopAllAction:function(){for(var a=this._actions,b=this._nActiveActions,c=this._bindings,
18168 d=this._nActiveBindings,e=this._nActiveBindings=this._nActiveActions=0;e!==b;++e)a[e].reset();for(e=0;e!==d;++e)c[e].useCount=0;return this},update:function(a){a*=this.timeScale;for(var b=this._actions,c=this._nActiveActions,d=this.time+=a,e=Math.sign(a),f=this._accuIndex^=1,g=0;g!==c;++g)b[g]._update(d,a,e,f);a=this._bindings;b=this._nActiveBindings;for(g=0;g!==b;++g)a[g].apply(f);return this},getRoot:function(){return this._root},uncacheClip:function(a){var b=this._actions;a=a.uuid;var c=this._actionsByClip,
18169 d=c[a];if(void 0!==d){d=d.knownActions;for(var e=0,f=d.length;e!==f;++e){var g=d[e];this._deactivateAction(g);var h=g._cacheIndex,k=b[b.length-1];g._cacheIndex=null;g._byClipCacheIndex=null;k._cacheIndex=h;b[h]=k;b.pop();this._removeInactiveBindingsForAction(g)}delete c[a]}},uncacheRoot:function(a){a=a.uuid;var b=this._actionsByClip;for(d in b){var c=b[d].actionByRoot[a];void 0!==c&&(this._deactivateAction(c),this._removeInactiveAction(c))}var d=this._bindingsByRootAndName[a];if(void 0!==d)for(var e in d)a=
18170 d[e],a.restoreOriginalState(),this._removeInactiveBinding(a)},uncacheAction:function(a,b){a=this.existingAction(a,b);null!==a&&(this._deactivateAction(a),this._removeInactiveAction(a))}});Ld.prototype.clone=function(){return new Ld(void 0===this.value.clone?this.value:this.value.clone())};se.prototype=Object.assign(Object.create(C.prototype),{constructor:se,isInstancedBufferGeometry:!0,copy:function(a){C.prototype.copy.call(this,a);this.maxInstancedCount=a.maxInstancedCount;return this},clone:function(){return(new this.constructor).copy(this)}});
18171 te.prototype=Object.assign(Object.create(ob.prototype),{constructor:te,isInstancedInterleavedBuffer:!0,copy:function(a){ob.prototype.copy.call(this,a);this.meshPerAttribute=a.meshPerAttribute;return this}});ue.prototype=Object.assign(Object.create(Q.prototype),{constructor:ue,isInstancedBufferAttribute:!0,copy:function(a){Q.prototype.copy.call(this,a);this.meshPerAttribute=a.meshPerAttribute;return this}});Object.assign(sf.prototype,{linePrecision:1,set:function(a,b){this.ray.set(a,b)},setFromCamera:function(a,
18172 b){b&&b.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(b.matrixWorld),this.ray.direction.set(a.x,a.y,.5).unproject(b).sub(this.ray.origin).normalize()):b&&b.isOrthographicCamera?(this.ray.origin.set(a.x,a.y,(b.near+b.far)/(b.near-b.far)).unproject(b),this.ray.direction.set(0,0,-1).transformDirection(b.matrixWorld)):console.error("THREE.Raycaster: Unsupported camera type.")},intersectObject:function(a,b,c){c=c||[];ve(a,this,c,b);c.sort(tf);return c},intersectObjects:function(a,b,c){c=c||
18173 [];if(!1===Array.isArray(a))return console.warn("THREE.Raycaster.intersectObjects: objects is not an Array."),c;for(var d=0,e=a.length;d<e;d++)ve(a[d],this,c,b);c.sort(tf);return c}});Object.assign(uf.prototype,{start:function(){this.oldTime=this.startTime=("undefined"===typeof performance?Date:performance).now();this.elapsedTime=0;this.running=!0},stop:function(){this.getElapsedTime();this.autoStart=this.running=!1},getElapsedTime:function(){this.getDelta();return this.elapsedTime},getDelta:function(){var a=
18174 0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){var b=("undefined"===typeof performance?Date:performance).now();a=(b-this.oldTime)/1E3;this.oldTime=b;this.elapsedTime+=a}return a}});Object.assign(vf.prototype,{set:function(a,b,c){this.radius=a;this.phi=b;this.theta=c;return this},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.radius=a.radius;this.phi=a.phi;this.theta=a.theta;return this},makeSafe:function(){this.phi=Math.max(1E-6,Math.min(Math.PI-
18175 1E-6,this.phi));return this},setFromVector3:function(a){this.radius=a.length();0===this.radius?this.phi=this.theta=0:(this.theta=Math.atan2(a.x,a.z),this.phi=Math.acos(H.clamp(a.y/this.radius,-1,1)));return this}});Object.assign(wf.prototype,{set:function(a,b,c){this.radius=a;this.theta=b;this.y=c;return this},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.radius=a.radius;this.theta=a.theta;this.y=a.y;return this},setFromVector3:function(a){this.radius=Math.sqrt(a.x*
18176 a.x+a.z*a.z);this.theta=Math.atan2(a.x,a.z);this.y=a.y;return this}});Object.assign(we.prototype,{set:function(a,b){this.min.copy(a);this.max.copy(b);return this},setFromPoints:function(a){this.makeEmpty();for(var b=0,c=a.length;b<c;b++)this.expandByPoint(a[b]);return this},setFromCenterAndSize:function(){var a=new z;return function(b,c){c=a.copy(c).multiplyScalar(.5);this.min.copy(b).sub(c);this.max.copy(b).add(c);return this}}(),clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.min.copy(a.min);
18177 this.max.copy(a.max);return this},makeEmpty:function(){this.min.x=this.min.y=Infinity;this.max.x=this.max.y=-Infinity;return this},isEmpty:function(){return this.max.x<this.min.x||this.max.y<this.min.y},getCenter:function(a){void 0===a&&(console.warn("THREE.Box2: .getCenter() target is now required"),a=new z);return this.isEmpty()?a.set(0,0):a.addVectors(this.min,this.max).multiplyScalar(.5)},getSize:function(a){void 0===a&&(console.warn("THREE.Box2: .getSize() target is now required"),a=new z);return this.isEmpty()?
18178 a.set(0,0):a.subVectors(this.max,this.min)},expandByPoint:function(a){this.min.min(a);this.max.max(a);return this},expandByVector:function(a){this.min.sub(a);this.max.add(a);return this},expandByScalar:function(a){this.min.addScalar(-a);this.max.addScalar(a);return this},containsPoint:function(a){return a.x<this.min.x||a.x>this.max.x||a.y<this.min.y||a.y>this.max.y?!1:!0},containsBox:function(a){return this.min.x<=a.min.x&&a.max.x<=this.max.x&&this.min.y<=a.min.y&&a.max.y<=this.max.y},getParameter:function(a,
18179 b){void 0===b&&(console.warn("THREE.Box2: .getParameter() target is now required"),b=new z);return b.set((a.x-this.min.x)/(this.max.x-this.min.x),(a.y-this.min.y)/(this.max.y-this.min.y))},intersectsBox:function(a){return a.max.x<this.min.x||a.min.x>this.max.x||a.max.y<this.min.y||a.min.y>this.max.y?!1:!0},clampPoint:function(a,b){void 0===b&&(console.warn("THREE.Box2: .clampPoint() target is now required"),b=new z);return b.copy(a).clamp(this.min,this.max)},distanceToPoint:function(){var a=new z;
18180 return function(b){return a.copy(b).clamp(this.min,this.max).sub(b).length()}}(),intersect:function(a){this.min.max(a.min);this.max.min(a.max);return this},union:function(a){this.min.min(a.min);this.max.max(a.max);return this},translate:function(a){this.min.add(a);this.max.add(a);return this},equals:function(a){return a.min.equals(this.min)&&a.max.equals(this.max)}});Object.assign(xe.prototype,{set:function(a,b){this.start.copy(a);this.end.copy(b);return this},clone:function(){return(new this.constructor).copy(this)},
18181 copy:function(a){this.start.copy(a.start);this.end.copy(a.end);return this},getCenter:function(a){void 0===a&&(console.warn("THREE.Line3: .getCenter() target is now required"),a=new p);return a.addVectors(this.start,this.end).multiplyScalar(.5)},delta:function(a){void 0===a&&(console.warn("THREE.Line3: .delta() target is now required"),a=new p);return a.subVectors(this.end,this.start)},distanceSq:function(){return this.start.distanceToSquared(this.end)},distance:function(){return this.start.distanceTo(this.end)},
18182 at:function(a,b){void 0===b&&(console.warn("THREE.Line3: .at() target is now required"),b=new p);return this.delta(b).multiplyScalar(a).add(this.start)},closestPointToPointParameter:function(){var a=new p,b=new p;return function(c,d){a.subVectors(c,this.start);b.subVectors(this.end,this.start);c=b.dot(b);c=b.dot(a)/c;d&&(c=H.clamp(c,0,1));return c}}(),closestPointToPoint:function(a,b,c){a=this.closestPointToPointParameter(a,b);void 0===c&&(console.warn("THREE.Line3: .closestPointToPoint() target is now required"),
18183 c=new p);return this.delta(c).multiplyScalar(a).add(this.start)},applyMatrix4:function(a){this.start.applyMatrix4(a);this.end.applyMatrix4(a);return this},equals:function(a){return a.start.equals(this.start)&&a.end.equals(this.end)}});ed.prototype=Object.create(D.prototype);ed.prototype.constructor=ed;ed.prototype.isImmediateRenderObject=!0;fd.prototype=Object.create(W.prototype);fd.prototype.constructor=fd;fd.prototype.update=function(){var a=new p,b=new p,c=new ra;return function(){var d=["a","b",
18184 "c"];this.object.updateMatrixWorld(!0);c.getNormalMatrix(this.object.matrixWorld);var e=this.object.matrixWorld,f=this.geometry.attributes.position,g=this.object.geometry;if(g&&g.isGeometry)for(var h=g.vertices,k=g.faces,l=g=0,p=k.length;l<p;l++)for(var n=k[l],t=0,u=n.vertexNormals.length;t<u;t++){var r=n.vertexNormals[t];a.copy(h[n[d[t]]]).applyMatrix4(e);b.copy(r).applyMatrix3(c).normalize().multiplyScalar(this.size).add(a);f.setXYZ(g,a.x,a.y,a.z);g+=1;f.setXYZ(g,b.x,b.y,b.z);g+=1}else if(g&&g.isBufferGeometry)for(d=
18185 g.attributes.position,h=g.attributes.normal,t=g=0,u=d.count;t<u;t++)a.set(d.getX(t),d.getY(t),d.getZ(t)).applyMatrix4(e),b.set(h.getX(t),h.getY(t),h.getZ(t)),b.applyMatrix3(c).normalize().multiplyScalar(this.size).add(a),f.setXYZ(g,a.x,a.y,a.z),g+=1,f.setXYZ(g,b.x,b.y,b.z),g+=1;f.needsUpdate=!0}}();ic.prototype=Object.create(D.prototype);ic.prototype.constructor=ic;ic.prototype.dispose=function(){this.cone.geometry.dispose();this.cone.material.dispose()};ic.prototype.update=function(){var a=new p,
18186 b=new p;return function(){this.light.updateMatrixWorld();var c=this.light.distance?this.light.distance:1E3,d=c*Math.tan(this.light.angle);this.cone.scale.set(d,d,c);a.setFromMatrixPosition(this.light.matrixWorld);b.setFromMatrixPosition(this.light.target.matrixWorld);this.cone.lookAt(b.sub(a));void 0!==this.color?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}();jc.prototype=Object.create(W.prototype);jc.prototype.constructor=jc;jc.prototype.updateMatrixWorld=
18187 function(){var a=new p,b=new I,c=new I;return function(d){var e=this.bones,f=this.geometry,g=f.getAttribute("position");c.getInverse(this.root.matrixWorld);for(var h=0,k=0;h<e.length;h++){var l=e[h];l.parent&&l.parent.isBone&&(b.multiplyMatrices(c,l.matrixWorld),a.setFromMatrixPosition(b),g.setXYZ(k,a.x,a.y,a.z),b.multiplyMatrices(c,l.parent.matrixWorld),a.setFromMatrixPosition(b),g.setXYZ(k+1,a.x,a.y,a.z),k+=2)}f.getAttribute("position").needsUpdate=!0;D.prototype.updateMatrixWorld.call(this,d)}}();
18188 kc.prototype=Object.create(la.prototype);kc.prototype.constructor=kc;kc.prototype.dispose=function(){this.geometry.dispose();this.material.dispose()};kc.prototype.update=function(){void 0!==this.color?this.material.color.set(this.color):this.material.color.copy(this.light.color)};lc.prototype=Object.create(D.prototype);lc.prototype.constructor=lc;lc.prototype.dispose=function(){this.children[0].geometry.dispose();this.children[0].material.dispose()};lc.prototype.update=function(){var a=.5*this.light.width,
18189 b=.5*this.light.height,c=this.line.geometry.attributes.position,d=c.array;d[0]=a;d[1]=-b;d[2]=0;d[3]=a;d[4]=b;d[5]=0;d[6]=-a;d[7]=b;d[8]=0;d[9]=-a;d[10]=-b;d[11]=0;d[12]=a;d[13]=-b;d[14]=0;c.needsUpdate=!0;void 0!==this.color?this.line.material.color.set(this.color):this.line.material.color.copy(this.light.color)};mc.prototype=Object.create(D.prototype);mc.prototype.constructor=mc;mc.prototype.dispose=function(){this.children[0].geometry.dispose();this.children[0].material.dispose()};mc.prototype.update=
18190 function(){var a=new p,b=new G,c=new G;return function(){var d=this.children[0];if(void 0!==this.color)this.material.color.set(this.color);else{var e=d.geometry.getAttribute("color");b.copy(this.light.color);c.copy(this.light.groundColor);for(var f=0,g=e.count;f<g;f++){var h=f<g/2?b:c;e.setXYZ(f,h.r,h.g,h.b)}e.needsUpdate=!0}d.lookAt(a.setFromMatrixPosition(this.light.matrixWorld).negate())}}();gd.prototype=Object.create(W.prototype);gd.prototype.constructor=gd;Md.prototype=Object.create(W.prototype);
18191 Md.prototype.constructor=Md;hd.prototype=Object.create(W.prototype);hd.prototype.constructor=hd;hd.prototype.update=function(){var a=new p,b=new p,c=new ra;return function(){this.object.updateMatrixWorld(!0);c.getNormalMatrix(this.object.matrixWorld);var d=this.object.matrixWorld,e=this.geometry.attributes.position,f=this.object.geometry,g=f.vertices;f=f.faces;for(var h=0,k=0,l=f.length;k<l;k++){var p=f[k],n=p.normal;a.copy(g[p.a]).add(g[p.b]).add(g[p.c]).divideScalar(3).applyMatrix4(d);b.copy(n).applyMatrix3(c).normalize().multiplyScalar(this.size).add(a);
18192 e.setXYZ(h,a.x,a.y,a.z);h+=1;e.setXYZ(h,b.x,b.y,b.z);h+=1}e.needsUpdate=!0}}();nc.prototype=Object.create(D.prototype);nc.prototype.constructor=nc;nc.prototype.dispose=function(){this.lightPlane.geometry.dispose();this.lightPlane.material.dispose();this.targetLine.geometry.dispose();this.targetLine.material.dispose()};nc.prototype.update=function(){var a=new p,b=new p,c=new p;return function(){a.setFromMatrixPosition(this.light.matrixWorld);b.setFromMatrixPosition(this.light.target.matrixWorld);c.subVectors(b,
18193 a);this.lightPlane.lookAt(c);void 0!==this.color?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color));this.targetLine.lookAt(c);this.targetLine.scale.z=c.length()}}();id.prototype=Object.create(W.prototype);id.prototype.constructor=id;id.prototype.update=function(){function a(a,g,h,k){d.set(g,h,k).unproject(e);a=c[a];if(void 0!==a)for(g=b.getAttribute("position"),
18194 h=0,k=a.length;h<k;h++)g.setXYZ(a[h],d.x,d.y,d.z)}var b,c,d=new p,e=new Na;return function(){b=this.geometry;c=this.pointMap;e.projectionMatrix.copy(this.camera.projectionMatrix);a("c",0,0,-1);a("t",0,0,1);a("n1",-1,-1,-1);a("n2",1,-1,-1);a("n3",-1,1,-1);a("n4",1,1,-1);a("f1",-1,-1,1);a("f2",1,-1,1);a("f3",-1,1,1);a("f4",1,1,1);a("u1",.7,1.1,-1);a("u2",-.7,1.1,-1);a("u3",0,2,-1);a("cf1",-1,0,1);a("cf2",1,0,1);a("cf3",0,-1,1);a("cf4",0,1,1);a("cn1",-1,0,-1);a("cn2",1,0,-1);a("cn3",0,-1,-1);a("cn4",
18195 0,1,-1);b.getAttribute("position").needsUpdate=!0}}();Db.prototype=Object.create(W.prototype);Db.prototype.constructor=Db;Db.prototype.update=function(){var a=new Sa;return function(b){void 0!==b&&console.warn("THREE.BoxHelper: .update() has no longer arguments.");void 0!==this.object&&a.setFromObject(this.object);if(!a.isEmpty()){b=a.min;var c=a.max,d=this.geometry.attributes.position,e=d.array;e[0]=c.x;e[1]=c.y;e[2]=c.z;e[3]=b.x;e[4]=c.y;e[5]=c.z;e[6]=b.x;e[7]=b.y;e[8]=c.z;e[9]=c.x;e[10]=b.y;e[11]=
18196 c.z;e[12]=c.x;e[13]=c.y;e[14]=b.z;e[15]=b.x;e[16]=c.y;e[17]=b.z;e[18]=b.x;e[19]=b.y;e[20]=b.z;e[21]=c.x;e[22]=b.y;e[23]=b.z;d.needsUpdate=!0;this.geometry.computeBoundingSphere()}}}();Db.prototype.setFromObject=function(a){this.object=a;this.update();return this};jd.prototype=Object.create(W.prototype);jd.prototype.constructor=jd;jd.prototype.updateMatrixWorld=function(a){var b=this.box;b.isEmpty()||(b.getCenter(this.position),b.getSize(this.scale),this.scale.multiplyScalar(.5),D.prototype.updateMatrixWorld.call(this,
18197 a))};kd.prototype=Object.create(sa.prototype);kd.prototype.constructor=kd;kd.prototype.updateMatrixWorld=function(a){var b=-this.plane.constant;1E-8>Math.abs(b)&&(b=1E-8);this.scale.set(.5*this.size,.5*this.size,b);this.children[0].material.side=0>b?1:0;this.lookAt(this.plane.normal);D.prototype.updateMatrixWorld.call(this,a)};var Nd,ye;Eb.prototype=Object.create(D.prototype);Eb.prototype.constructor=Eb;Eb.prototype.setDirection=function(){var a=new p,b;return function(c){.99999<c.y?this.quaternion.set(0,
18198 0,0,1):-.99999>c.y?this.quaternion.set(1,0,0,0):(a.set(c.z,0,-c.x).normalize(),b=Math.acos(c.y),this.quaternion.setFromAxisAngle(a,b))}}();Eb.prototype.setLength=function(a,b,c){void 0===b&&(b=.2*a);void 0===c&&(c=.2*b);this.line.scale.set(1,Math.max(0,a-b),1);this.line.updateMatrix();this.cone.scale.set(c,b,c);this.cone.position.y=a;this.cone.updateMatrix()};Eb.prototype.setColor=function(a){this.line.material.color.copy(a);this.cone.material.color.copy(a)};ld.prototype=Object.create(W.prototype);
18199 ld.prototype.constructor=ld;L.create=function(a,b){console.log("THREE.Curve.create() has been deprecated");a.prototype=Object.create(L.prototype);a.prototype.constructor=a;a.prototype.getPoint=b;return a};Object.assign(Xa.prototype,{createPointsGeometry:function(a){console.warn("THREE.CurvePath: .createPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");a=this.getPoints(a);return this.createGeometry(a)},createSpacedPointsGeometry:function(a){console.warn("THREE.CurvePath: .createSpacedPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");
18200 a=this.getSpacedPoints(a);return this.createGeometry(a)},createGeometry:function(a){console.warn("THREE.CurvePath: .createGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");for(var b=new R,c=0,d=a.length;c<d;c++){var e=a[c];b.vertices.push(new p(e.x,e.y,e.z||0))}return b}});Object.assign(La.prototype,{fromPoints:function(a){console.warn("THREE.Path: .fromPoints() has been renamed to .setFromPoints().");this.setFromPoints(a)}});yf.prototype=Object.create(ca.prototype);
18201 zf.prototype=Object.create(ca.prototype);ze.prototype=Object.create(ca.prototype);Object.assign(ze.prototype,{initFromArray:function(){console.error("THREE.Spline: .initFromArray() has been removed.")},getControlPointsArray:function(){console.error("THREE.Spline: .getControlPointsArray() has been removed.")},reparametrizeByArcLength:function(){console.error("THREE.Spline: .reparametrizeByArcLength() has been removed.")}});gd.prototype.setColors=function(){console.error("THREE.GridHelper: setColors() has been deprecated, pass them in the constructor instead.")};
18202 jc.prototype.update=function(){console.error("THREE.SkeletonHelper: update() no longer needs to be called.")};Object.assign(gc.prototype,{extractUrlBase:function(a){console.warn("THREE.Loader: .extractUrlBase() has been deprecated. Use THREE.LoaderUtils.extractUrlBase() instead.");return De.extractUrlBase(a)}});Object.assign(we.prototype,{center:function(a){console.warn("THREE.Box2: .center() has been renamed to .getCenter().");return this.getCenter(a)},empty:function(){console.warn("THREE.Box2: .empty() has been renamed to .isEmpty().");
18203 return this.isEmpty()},isIntersectionBox:function(a){console.warn("THREE.Box2: .isIntersectionBox() has been renamed to .intersectsBox().");return this.intersectsBox(a)},size:function(a){console.warn("THREE.Box2: .size() has been renamed to .getSize().");return this.getSize(a)}});Object.assign(Sa.prototype,{center:function(a){console.warn("THREE.Box3: .center() has been renamed to .getCenter().");return this.getCenter(a)},empty:function(){console.warn("THREE.Box3: .empty() has been renamed to .isEmpty().");
18204 return this.isEmpty()},isIntersectionBox:function(a){console.warn("THREE.Box3: .isIntersectionBox() has been renamed to .intersectsBox().");return this.intersectsBox(a)},isIntersectionSphere:function(a){console.warn("THREE.Box3: .isIntersectionSphere() has been renamed to .intersectsSphere().");return this.intersectsSphere(a)},size:function(a){console.warn("THREE.Box3: .size() has been renamed to .getSize().");return this.getSize(a)}});xe.prototype.center=function(a){console.warn("THREE.Line3: .center() has been renamed to .getCenter().");
18205 return this.getCenter(a)};Object.assign(H,{random16:function(){console.warn("THREE.Math: .random16() has been deprecated. Use Math.random() instead.");return Math.random()},nearestPowerOfTwo:function(a){console.warn("THREE.Math: .nearestPowerOfTwo() has been renamed to .floorPowerOfTwo().");return H.floorPowerOfTwo(a)},nextPowerOfTwo:function(a){console.warn("THREE.Math: .nextPowerOfTwo() has been renamed to .ceilPowerOfTwo().");return H.ceilPowerOfTwo(a)}});Object.assign(ra.prototype,{flattenToArrayOffset:function(a,
18206 b){console.warn("THREE.Matrix3: .flattenToArrayOffset() has been deprecated. Use .toArray() instead.");return this.toArray(a,b)},multiplyVector3:function(a){console.warn("THREE.Matrix3: .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead.");return a.applyMatrix3(this)},multiplyVector3Array:function(){console.error("THREE.Matrix3: .multiplyVector3Array() has been removed.")},applyToBuffer:function(a){console.warn("THREE.Matrix3: .applyToBuffer() has been removed. Use matrix.applyToBufferAttribute( attribute ) instead.");
18207 return this.applyToBufferAttribute(a)},applyToVector3Array:function(){console.error("THREE.Matrix3: .applyToVector3Array() has been removed.")}});Object.assign(I.prototype,{extractPosition:function(a){console.warn("THREE.Matrix4: .extractPosition() has been renamed to .copyPosition().");return this.copyPosition(a)},flattenToArrayOffset:function(a,b){console.warn("THREE.Matrix4: .flattenToArrayOffset() has been deprecated. Use .toArray() instead.");return this.toArray(a,b)},getPosition:function(){var a;
18208 return function(){void 0===a&&(a=new p);console.warn("THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead.");return a.setFromMatrixColumn(this,3)}}(),setRotationFromQuaternion:function(a){console.warn("THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion().");return this.makeRotationFromQuaternion(a)},multiplyToArray:function(){console.warn("THREE.Matrix4: .multiplyToArray() has been removed.")},multiplyVector3:function(a){console.warn("THREE.Matrix4: .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) instead.");
18209 return a.applyMatrix4(this)},multiplyVector4:function(a){console.warn("THREE.Matrix4: .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead.");return a.applyMatrix4(this)},multiplyVector3Array:function(){console.error("THREE.Matrix4: .multiplyVector3Array() has been removed.")},rotateAxis:function(a){console.warn("THREE.Matrix4: .rotateAxis() has been removed. Use Vector3.transformDirection( matrix ) instead.");a.transformDirection(this)},crossVector:function(a){console.warn("THREE.Matrix4: .crossVector() has been removed. Use vector.applyMatrix4( matrix ) instead.");
18210 return a.applyMatrix4(this)},translate:function(){console.error("THREE.Matrix4: .translate() has been removed.")},rotateX:function(){console.error("THREE.Matrix4: .rotateX() has been removed.")},rotateY:function(){console.error("THREE.Matrix4: .rotateY() has been removed.")},rotateZ:function(){console.error("THREE.Matrix4: .rotateZ() has been removed.")},rotateByAxis:function(){console.error("THREE.Matrix4: .rotateByAxis() has been removed.")},applyToBuffer:function(a){console.warn("THREE.Matrix4: .applyToBuffer() has been removed. Use matrix.applyToBufferAttribute( attribute ) instead.");
18211 return this.applyToBufferAttribute(a)},applyToVector3Array:function(){console.error("THREE.Matrix4: .applyToVector3Array() has been removed.")},makeFrustum:function(a,b,c,d,e,f){console.warn("THREE.Matrix4: .makeFrustum() has been removed. Use .makePerspective( left, right, top, bottom, near, far ) instead.");return this.makePerspective(a,b,d,c,e,f)}});Ma.prototype.isIntersectionLine=function(a){console.warn("THREE.Plane: .isIntersectionLine() has been renamed to .intersectsLine().");return this.intersectsLine(a)};
18212 fa.prototype.multiplyVector3=function(a){console.warn("THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead.");return a.applyQuaternion(this)};Object.assign(mb.prototype,{isIntersectionBox:function(a){console.warn("THREE.Ray: .isIntersectionBox() has been renamed to .intersectsBox().");return this.intersectsBox(a)},isIntersectionPlane:function(a){console.warn("THREE.Ray: .isIntersectionPlane() has been renamed to .intersectsPlane().");return this.intersectsPlane(a)},
18213 isIntersectionSphere:function(a){console.warn("THREE.Ray: .isIntersectionSphere() has been renamed to .intersectsSphere().");return this.intersectsSphere(a)}});Object.assign(ja.prototype,{area:function(){console.warn("THREE.Triangle: .area() has been renamed to .getArea().");return this.getArea()},barycoordFromPoint:function(a,b){console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord().");return this.getBarycoord(a,b)},midpoint:function(a){console.warn("THREE.Triangle: .midpoint() has been renamed to .getMidpoint().");
18214 return this.getMidpoint(a)},normal:function(a){console.warn("THREE.Triangle: .normal() has been renamed to .getNormal().");return this.getNormal(a)},plane:function(a){console.warn("THREE.Triangle: .plane() has been renamed to .getPlane().");return this.getPlane(a)}});Object.assign(ja,{barycoordFromPoint:function(a,b,c,d,e){console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord().");return ja.getBarycoord(a,b,c,d,e)},normal:function(a,b,c,d){console.warn("THREE.Triangle: .normal() has been renamed to .getNormal().");
18215 return ja.getNormal(a,b,c,d)}});Object.assign(db.prototype,{extractAllPoints:function(a){console.warn("THREE.Shape: .extractAllPoints() has been removed. Use .extractPoints() instead.");return this.extractPoints(a)},extrude:function(a){console.warn("THREE.Shape: .extrude() has been removed. Use ExtrudeGeometry() instead.");return new rb(this,a)},makeGeometry:function(a){console.warn("THREE.Shape: .makeGeometry() has been removed. Use ShapeGeometry() instead.");return new tb(this,a)}});Object.assign(z.prototype,
18216 {fromAttribute:function(a,b,c){console.warn("THREE.Vector2: .fromAttribute() has been renamed to .fromBufferAttribute().");return this.fromBufferAttribute(a,b,c)},distanceToManhattan:function(a){console.warn("THREE.Vector2: .distanceToManhattan() has been renamed to .manhattanDistanceTo().");return this.manhattanDistanceTo(a)},lengthManhattan:function(){console.warn("THREE.Vector2: .lengthManhattan() has been renamed to .manhattanLength().");return this.manhattanLength()}});Object.assign(p.prototype,
18217 {setEulerFromRotationMatrix:function(){console.error("THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.")},setEulerFromQuaternion:function(){console.error("THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead.")},getPositionFromMatrix:function(a){console.warn("THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition().");return this.setFromMatrixPosition(a)},getScaleFromMatrix:function(a){console.warn("THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale().");
18218 return this.setFromMatrixScale(a)},getColumnFromMatrix:function(a,b){console.warn("THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn().");return this.setFromMatrixColumn(b,a)},applyProjection:function(a){console.warn("THREE.Vector3: .applyProjection() has been removed. Use .applyMatrix4( m ) instead.");return this.applyMatrix4(a)},fromAttribute:function(a,b,c){console.warn("THREE.Vector3: .fromAttribute() has been renamed to .fromBufferAttribute().");return this.fromBufferAttribute(a,
18219 b,c)},distanceToManhattan:function(a){console.warn("THREE.Vector3: .distanceToManhattan() has been renamed to .manhattanDistanceTo().");return this.manhattanDistanceTo(a)},lengthManhattan:function(){console.warn("THREE.Vector3: .lengthManhattan() has been renamed to .manhattanLength().");return this.manhattanLength()}});Object.assign(V.prototype,{fromAttribute:function(a,b,c){console.warn("THREE.Vector4: .fromAttribute() has been renamed to .fromBufferAttribute().");return this.fromBufferAttribute(a,
18220 b,c)},lengthManhattan:function(){console.warn("THREE.Vector4: .lengthManhattan() has been renamed to .manhattanLength().");return this.manhattanLength()}});Object.assign(R.prototype,{computeTangents:function(){console.error("THREE.Geometry: .computeTangents() has been removed.")},computeLineDistances:function(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")}});Object.assign(D.prototype,{getChildByName:function(a){console.warn("THREE.Object3D: .getChildByName() has been renamed to .getObjectByName().");
18221 return this.getObjectByName(a)},renderDepth:function(){console.warn("THREE.Object3D: .renderDepth has been removed. Use .renderOrder, instead.")},translate:function(a,b){console.warn("THREE.Object3D: .translate() has been removed. Use .translateOnAxis( axis, distance ) instead.");return this.translateOnAxis(b,a)},getWorldRotation:function(){console.error("THREE.Object3D: .getWorldRotation() has been removed. Use THREE.Object3D.getWorldQuaternion( target ) instead.")}});Object.defineProperties(D.prototype,
18222 {eulerOrder:{get:function(){console.warn("THREE.Object3D: .eulerOrder is now .rotation.order.");return this.rotation.order},set:function(a){console.warn("THREE.Object3D: .eulerOrder is now .rotation.order.");this.rotation.order=a}},useQuaternion:{get:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")},set:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")}}});
18223 Object.defineProperties(Bc.prototype,{objects:{get:function(){console.warn("THREE.LOD: .objects has been renamed to .levels.");return this.levels}}});Object.defineProperty(Cc.prototype,"useVertexTexture",{get:function(){console.warn("THREE.Skeleton: useVertexTexture has been removed.")},set:function(){console.warn("THREE.Skeleton: useVertexTexture has been removed.")}});Object.defineProperty(L.prototype,"__arcLengthDivisions",{get:function(){console.warn("THREE.Curve: .__arcLengthDivisions is now .arcLengthDivisions.");
18224 return this.arcLengthDivisions},set:function(a){console.warn("THREE.Curve: .__arcLengthDivisions is now .arcLengthDivisions.");this.arcLengthDivisions=a}});Z.prototype.setLens=function(a,b){console.warn("THREE.PerspectiveCamera.setLens is deprecated. Use .setFocalLength and .filmGauge for a photographic setup.");void 0!==b&&(this.filmGauge=b);this.setFocalLength(a)};Object.defineProperties(X.prototype,{onlyShadow:{set:function(){console.warn("THREE.Light: .onlyShadow has been removed.")}},shadowCameraFov:{set:function(a){console.warn("THREE.Light: .shadowCameraFov is now .shadow.camera.fov.");
18225 this.shadow.camera.fov=a}},shadowCameraLeft:{set:function(a){console.warn("THREE.Light: .shadowCameraLeft is now .shadow.camera.left.");this.shadow.camera.left=a}},shadowCameraRight:{set:function(a){console.warn("THREE.Light: .shadowCameraRight is now .shadow.camera.right.");this.shadow.camera.right=a}},shadowCameraTop:{set:function(a){console.warn("THREE.Light: .shadowCameraTop is now .shadow.camera.top.");this.shadow.camera.top=a}},shadowCameraBottom:{set:function(a){console.warn("THREE.Light: .shadowCameraBottom is now .shadow.camera.bottom.");
18226 this.shadow.camera.bottom=a}},shadowCameraNear:{set:function(a){console.warn("THREE.Light: .shadowCameraNear is now .shadow.camera.near.");this.shadow.camera.near=a}},shadowCameraFar:{set:function(a){console.warn("THREE.Light: .shadowCameraFar is now .shadow.camera.far.");this.shadow.camera.far=a}},shadowCameraVisible:{set:function(){console.warn("THREE.Light: .shadowCameraVisible has been removed. Use new THREE.CameraHelper( light.shadow.camera ) instead.")}},shadowBias:{set:function(a){console.warn("THREE.Light: .shadowBias is now .shadow.bias.");
18227 this.shadow.bias=a}},shadowDarkness:{set:function(){console.warn("THREE.Light: .shadowDarkness has been removed.")}},shadowMapWidth:{set:function(a){console.warn("THREE.Light: .shadowMapWidth is now .shadow.mapSize.width.");this.shadow.mapSize.width=a}},shadowMapHeight:{set:function(a){console.warn("THREE.Light: .shadowMapHeight is now .shadow.mapSize.height.");this.shadow.mapSize.height=a}}});Object.defineProperties(Q.prototype,{length:{get:function(){console.warn("THREE.BufferAttribute: .length has been deprecated. Use .count instead.");
18228 return this.array.length}},copyIndicesArray:function(){console.error("THREE.BufferAttribute: .copyIndicesArray() has been removed.")}});Object.assign(C.prototype,{addIndex:function(a){console.warn("THREE.BufferGeometry: .addIndex() has been renamed to .setIndex().");this.setIndex(a)},addDrawCall:function(a,b,c){void 0!==c&&console.warn("THREE.BufferGeometry: .addDrawCall() no longer supports indexOffset.");console.warn("THREE.BufferGeometry: .addDrawCall() is now .addGroup().");this.addGroup(a,b)},
18229 clearDrawCalls:function(){console.warn("THREE.BufferGeometry: .clearDrawCalls() is now .clearGroups().");this.clearGroups()},computeTangents:function(){console.warn("THREE.BufferGeometry: .computeTangents() has been removed.")},computeOffsets:function(){console.warn("THREE.BufferGeometry: .computeOffsets() has been removed.")}});Object.defineProperties(C.prototype,{drawcalls:{get:function(){console.error("THREE.BufferGeometry: .drawcalls has been renamed to .groups.");return this.groups}},offsets:{get:function(){console.warn("THREE.BufferGeometry: .offsets has been renamed to .groups.");
18230 return this.groups}}});Object.assign(Oa.prototype,{getArrays:function(){console.error("THREE.ExtrudeBufferGeometry: .getArrays() has been removed.")},addShapeList:function(){console.error("THREE.ExtrudeBufferGeometry: .addShapeList() has been removed.")},addShape:function(){console.error("THREE.ExtrudeBufferGeometry: .addShape() has been removed.")}});Object.defineProperties(Ld.prototype,{dynamic:{set:function(){console.warn("THREE.Uniform: .dynamic has been removed. Use object.onBeforeRender() instead.")}},
18231 onUpdate:{value:function(){console.warn("THREE.Uniform: .onUpdate() has been removed. Use object.onBeforeRender() instead.");return this}}});Object.defineProperties(J.prototype,{wrapAround:{get:function(){console.warn("THREE.Material: .wrapAround has been removed.")},set:function(){console.warn("THREE.Material: .wrapAround has been removed.")}},wrapRGB:{get:function(){console.warn("THREE.Material: .wrapRGB has been removed.");return new G}},shading:{get:function(){console.error("THREE."+this.type+
18232 ": .shading has been removed. Use the boolean .flatShading instead.")},set:function(a){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead.");this.flatShading=1===a}}});Object.defineProperties(Fa.prototype,{metal:{get:function(){console.warn("THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead.");return!1},set:function(){console.warn("THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead")}}});
18233 Object.defineProperties(ta.prototype,{derivatives:{get:function(){console.warn("THREE.ShaderMaterial: .derivatives has been moved to .extensions.derivatives.");return this.extensions.derivatives},set:function(a){console.warn("THREE. ShaderMaterial: .derivatives has been moved to .extensions.derivatives.");this.extensions.derivatives=a}}});Object.assign(Zd.prototype,{animate:function(a){console.warn("THREE.WebGLRenderer: .animate() is now .setAnimationLoop().");this.setAnimationLoop(a)},getCurrentRenderTarget:function(){console.warn("THREE.WebGLRenderer: .getCurrentRenderTarget() is now .getRenderTarget().");
18234 return this.getRenderTarget()},getMaxAnisotropy:function(){console.warn("THREE.WebGLRenderer: .getMaxAnisotropy() is now .capabilities.getMaxAnisotropy().");return this.capabilities.getMaxAnisotropy()},getPrecision:function(){console.warn("THREE.WebGLRenderer: .getPrecision() is now .capabilities.precision.");return this.capabilities.precision},resetGLState:function(){console.warn("THREE.WebGLRenderer: .resetGLState() is now .state.reset().");return this.state.reset()},supportsFloatTextures:function(){console.warn("THREE.WebGLRenderer: .supportsFloatTextures() is now .extensions.get( 'OES_texture_float' ).");
18235 return this.extensions.get("OES_texture_float")},supportsHalfFloatTextures:function(){console.warn("THREE.WebGLRenderer: .supportsHalfFloatTextures() is now .extensions.get( 'OES_texture_half_float' ).");return this.extensions.get("OES_texture_half_float")},supportsStandardDerivatives:function(){console.warn("THREE.WebGLRenderer: .supportsStandardDerivatives() is now .extensions.get( 'OES_standard_derivatives' ).");return this.extensions.get("OES_standard_derivatives")},supportsCompressedTextureS3TC:function(){console.warn("THREE.WebGLRenderer: .supportsCompressedTextureS3TC() is now .extensions.get( 'WEBGL_compressed_texture_s3tc' ).");
18236 return this.extensions.get("WEBGL_compressed_texture_s3tc")},supportsCompressedTexturePVRTC:function(){console.warn("THREE.WebGLRenderer: .supportsCompressedTexturePVRTC() is now .extensions.get( 'WEBGL_compressed_texture_pvrtc' ).");return this.extensions.get("WEBGL_compressed_texture_pvrtc")},supportsBlendMinMax:function(){console.warn("THREE.WebGLRenderer: .supportsBlendMinMax() is now .extensions.get( 'EXT_blend_minmax' ).");return this.extensions.get("EXT_blend_minmax")},supportsVertexTextures:function(){console.warn("THREE.WebGLRenderer: .supportsVertexTextures() is now .capabilities.vertexTextures.");
18237 return this.capabilities.vertexTextures},supportsInstancedArrays:function(){console.warn("THREE.WebGLRenderer: .supportsInstancedArrays() is now .extensions.get( 'ANGLE_instanced_arrays' ).");return this.extensions.get("ANGLE_instanced_arrays")},enableScissorTest:function(a){console.warn("THREE.WebGLRenderer: .enableScissorTest() is now .setScissorTest().");this.setScissorTest(a)},initMaterial:function(){console.warn("THREE.WebGLRenderer: .initMaterial() has been removed.")},addPrePlugin:function(){console.warn("THREE.WebGLRenderer: .addPrePlugin() has been removed.")},
18238 addPostPlugin:function(){console.warn("THREE.WebGLRenderer: .addPostPlugin() has been removed.")},updateShadowMap:function(){console.warn("THREE.WebGLRenderer: .updateShadowMap() has been removed.")},setFaceCulling:function(){console.warn("THREE.WebGLRenderer: .setFaceCulling() has been removed.")}});Object.defineProperties(Zd.prototype,{shadowMapEnabled:{get:function(){return this.shadowMap.enabled},set:function(a){console.warn("THREE.WebGLRenderer: .shadowMapEnabled is now .shadowMap.enabled.");
18239 this.shadowMap.enabled=a}},shadowMapType:{get:function(){return this.shadowMap.type},set:function(a){console.warn("THREE.WebGLRenderer: .shadowMapType is now .shadowMap.type.");this.shadowMap.type=a}},shadowMapCullFace:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.")}}});Object.defineProperties(Ze.prototype,
18240 {cullFace:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.")}},renderReverseSided:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")}},
18241 renderSingleSided:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.")}}});Object.defineProperties(fb.prototype,{wrapS:{get:function(){console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS.");return this.texture.wrapS},set:function(a){console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS.");
18242 this.texture.wrapS=a}},wrapT:{get:function(){console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT.");return this.texture.wrapT},set:function(a){console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT.");this.texture.wrapT=a}},magFilter:{get:function(){console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter.");return this.texture.magFilter},set:function(a){console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter.");this.texture.magFilter=
18243 a}},minFilter:{get:function(){console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter.");return this.texture.minFilter},set:function(a){console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter.");this.texture.minFilter=a}},anisotropy:{get:function(){console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy.");return this.texture.anisotropy},set:function(a){console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy.");this.texture.anisotropy=
18244 a}},offset:{get:function(){console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset.");return this.texture.offset},set:function(a){console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset.");this.texture.offset=a}},repeat:{get:function(){console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat.");return this.texture.repeat},set:function(a){console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat.");this.texture.repeat=a}},format:{get:function(){console.warn("THREE.WebGLRenderTarget: .format is now .texture.format.");
18245 return this.texture.format},set:function(a){console.warn("THREE.WebGLRenderTarget: .format is now .texture.format.");this.texture.format=a}},type:{get:function(){console.warn("THREE.WebGLRenderTarget: .type is now .texture.type.");return this.texture.type},set:function(a){console.warn("THREE.WebGLRenderTarget: .type is now .texture.type.");this.texture.type=a}},generateMipmaps:{get:function(){console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps.");return this.texture.generateMipmaps},
18246 set:function(a){console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps.");this.texture.generateMipmaps=a}}});Object.defineProperties(af.prototype,{standing:{set:function(){console.warn("THREE.WebVRManager: .standing has been removed.")}}});hc.prototype.load=function(a){console.warn("THREE.Audio: .load has been deprecated. Use THREE.AudioLoader instead.");var b=this;(new le).load(a,function(a){b.setBuffer(a)});return this};pe.prototype.getData=function(){console.warn("THREE.AudioAnalyser: .getData() is now .getFrequencyData().");
18247 return this.getFrequencyData()};dd.prototype.updateCubeMap=function(a,b){console.warn("THREE.CubeCamera: .updateCubeMap() is now .update().");return this.update(a,b)};eb.crossOrigin=void 0;eb.loadTexture=function(a,b,c,d){console.warn("THREE.ImageUtils.loadTexture has been deprecated. Use THREE.TextureLoader() instead.");var e=new vd;e.setCrossOrigin(this.crossOrigin);a=e.load(a,c,void 0,d);b&&(a.mapping=b);return a};eb.loadTextureCube=function(a,b,c,d){console.warn("THREE.ImageUtils.loadTextureCube has been deprecated. Use THREE.CubeTextureLoader() instead.");
18248 var e=new ee;e.setCrossOrigin(this.crossOrigin);a=e.load(a,c,void 0,d);b&&(a.mapping=b);return a};eb.loadCompressedTexture=function(){console.error("THREE.ImageUtils.loadCompressedTexture has been removed. Use THREE.DDSLoader instead.")};eb.loadCompressedTextureCube=function(){console.error("THREE.ImageUtils.loadCompressedTextureCube has been removed. Use THREE.DDSLoader instead.")};l.WebGLRenderTargetCube=Gb;l.WebGLRenderTarget=fb;l.WebGLRenderer=Zd;l.ShaderLib=nb;l.UniformsLib=K;l.UniformsUtils=
18249 Aa;l.ShaderChunk=S;l.FogExp2=Lb;l.Fog=Mb;l.Scene=qd;l.Sprite=Ac;l.LOD=Bc;l.SkinnedMesh=sd;l.Skeleton=Cc;l.Bone=rd;l.Mesh=la;l.LineSegments=W;l.LineLoop=td;l.Line=sa;l.Points=Ob;l.Group=Kb;l.VideoTexture=$d;l.DataTexture=gb;l.CompressedTexture=Pb;l.CubeTexture=Ua;l.CanvasTexture=Dc;l.DepthTexture=Ec;l.Texture=T;l.CompressedTextureLoader=kf;l.DataTextureLoader=de;l.CubeTextureLoader=ee;l.TextureLoader=vd;l.ObjectLoader=mf;l.MaterialLoader=Kd;l.BufferGeometryLoader=ge;l.DefaultLoadingManager=ka;l.LoadingManager=
18250 ce;l.JSONLoader=he;l.ImageLoader=Zc;l.ImageBitmapLoader=ie;l.FontLoader=nf;l.FileLoader=Ga;l.Loader=gc;l.LoaderUtils=De;l.Cache=Fb;l.AudioLoader=le;l.SpotLightShadow=xd;l.SpotLight=yd;l.PointLight=zd;l.RectAreaLight=Dd;l.HemisphereLight=wd;l.DirectionalLightShadow=Ad;l.DirectionalLight=Bd;l.AmbientLight=Cd;l.LightShadow=Cb;l.Light=X;l.StereoCamera=of;l.PerspectiveCamera=Z;l.OrthographicCamera=Hb;l.CubeCamera=dd;l.ArrayCamera=yc;l.Camera=Na;l.AudioListener=me;l.PositionalAudio=oe;l.AudioContext=ne;
18251 l.AudioAnalyser=pe;l.Audio=hc;l.VectorKeyframeTrack=fc;l.StringKeyframeTrack=Jd;l.QuaternionKeyframeTrack=cd;l.NumberKeyframeTrack=ec;l.ColorKeyframeTrack=Hd;l.BooleanKeyframeTrack=Gd;l.PropertyMixer=qe;l.PropertyBinding=pa;l.KeyframeTrack=oa;l.AnimationUtils=ia;l.AnimationObjectGroup=qf;l.AnimationMixer=re;l.AnimationClip=Ca;l.Uniform=Ld;l.InstancedBufferGeometry=se;l.BufferGeometry=C;l.Geometry=R;l.InterleavedBufferAttribute=zc;l.InstancedInterleavedBuffer=te;l.InterleavedBuffer=ob;l.InstancedBufferAttribute=
18252 ue;l.Face3=Ta;l.Object3D=D;l.Raycaster=sf;l.Layers=Rd;l.EventDispatcher=ya;l.Clock=uf;l.QuaternionLinearInterpolant=Id;l.LinearInterpolant=bd;l.DiscreteInterpolant=Fd;l.CubicInterpolant=Ed;l.Interpolant=wa;l.Triangle=ja;l.Math=H;l.Spherical=vf;l.Cylindrical=wf;l.Plane=Ma;l.Frustum=md;l.Sphere=Da;l.Ray=mb;l.Matrix4=I;l.Matrix3=ra;l.Box3=Sa;l.Box2=we;l.Line3=xe;l.Euler=hb;l.Vector4=V;l.Vector3=p;l.Vector2=z;l.Quaternion=fa;l.Color=G;l.ImmediateRenderObject=ed;l.VertexNormalsHelper=fd;l.SpotLightHelper=
18253 ic;l.SkeletonHelper=jc;l.PointLightHelper=kc;l.RectAreaLightHelper=lc;l.HemisphereLightHelper=mc;l.GridHelper=gd;l.PolarGridHelper=Md;l.FaceNormalsHelper=hd;l.DirectionalLightHelper=nc;l.CameraHelper=id;l.BoxHelper=Db;l.Box3Helper=jd;l.PlaneHelper=kd;l.ArrowHelper=Eb;l.AxesHelper=ld;l.Shape=db;l.Path=La;l.ShapePath=je;l.Font=ke;l.CurvePath=Xa;l.Curve=L;l.ImageUtils=eb;l.ShapeUtils=Va;l.WebGLUtils=$e;l.WireframeGeometry=Qb;l.ParametricGeometry=Fc;l.ParametricBufferGeometry=Rb;l.TetrahedronGeometry=
18254 Hc;l.TetrahedronBufferGeometry=Sb;l.OctahedronGeometry=Ic;l.OctahedronBufferGeometry=pb;l.IcosahedronGeometry=Jc;l.IcosahedronBufferGeometry=Tb;l.DodecahedronGeometry=Kc;l.DodecahedronBufferGeometry=Ub;l.PolyhedronGeometry=Gc;l.PolyhedronBufferGeometry=na;l.TubeGeometry=Lc;l.TubeBufferGeometry=Vb;l.TorusKnotGeometry=Mc;l.TorusKnotBufferGeometry=Wb;l.TorusGeometry=Nc;l.TorusBufferGeometry=Xb;l.TextGeometry=Sc;l.TextBufferGeometry=Yb;l.SphereGeometry=Tc;l.SphereBufferGeometry=sb;l.RingGeometry=Uc;l.RingBufferGeometry=
18255 Zb;l.PlaneGeometry=uc;l.PlaneBufferGeometry=lb;l.LatheGeometry=Vc;l.LatheBufferGeometry=$b;l.ShapeGeometry=tb;l.ShapeBufferGeometry=ub;l.ExtrudeGeometry=rb;l.ExtrudeBufferGeometry=Oa;l.EdgesGeometry=ac;l.ConeGeometry=Wc;l.ConeBufferGeometry=Xc;l.CylinderGeometry=vb;l.CylinderBufferGeometry=Wa;l.CircleGeometry=Yc;l.CircleBufferGeometry=bc;l.BoxGeometry=Ib;l.BoxBufferGeometry=kb;l.ShadowMaterial=wb;l.SpriteMaterial=cb;l.RawShaderMaterial=cc;l.ShaderMaterial=ta;l.PointsMaterial=Ea;l.MeshPhysicalMaterial=
18256 xb;l.MeshStandardMaterial=Pa;l.MeshPhongMaterial=Fa;l.MeshToonMaterial=yb;l.MeshNormalMaterial=zb;l.MeshLambertMaterial=Ab;l.MeshDepthMaterial=$a;l.MeshDistanceMaterial=ab;l.MeshBasicMaterial=da;l.LineDashedMaterial=Bb;l.LineBasicMaterial=Y;l.Material=J;l.Float64BufferAttribute=tc;l.Float32BufferAttribute=A;l.Uint32BufferAttribute=jb;l.Int32BufferAttribute=sc;l.Uint16BufferAttribute=ib;l.Int16BufferAttribute=rc;l.Uint8ClampedBufferAttribute=qc;l.Uint8BufferAttribute=pc;l.Int8BufferAttribute=oc;l.BufferAttribute=
18257 Q;l.ArcCurve=dc;l.CatmullRomCurve3=ca;l.CubicBezierCurve=Ha;l.CubicBezierCurve3=Qa;l.EllipseCurve=za;l.LineCurve=va;l.LineCurve3=Ia;l.QuadraticBezierCurve=Ja;l.QuadraticBezierCurve3=Ra;l.SplineCurve=Ka;l.REVISION="95";l.MOUSE={LEFT:0,MIDDLE:1,RIGHT:2};l.CullFaceNone=0;l.CullFaceBack=1;l.CullFaceFront=2;l.CullFaceFrontBack=3;l.FrontFaceDirectionCW=0;l.FrontFaceDirectionCCW=1;l.BasicShadowMap=0;l.PCFShadowMap=1;l.PCFSoftShadowMap=2;l.FrontSide=0;l.BackSide=1;l.DoubleSide=2;l.FlatShading=1;l.SmoothShading=
18258 2;l.NoColors=0;l.FaceColors=1;l.VertexColors=2;l.NoBlending=0;l.NormalBlending=1;l.AdditiveBlending=2;l.SubtractiveBlending=3;l.MultiplyBlending=4;l.CustomBlending=5;l.AddEquation=100;l.SubtractEquation=101;l.ReverseSubtractEquation=102;l.MinEquation=103;l.MaxEquation=104;l.ZeroFactor=200;l.OneFactor=201;l.SrcColorFactor=202;l.OneMinusSrcColorFactor=203;l.SrcAlphaFactor=204;l.OneMinusSrcAlphaFactor=205;l.DstAlphaFactor=206;l.OneMinusDstAlphaFactor=207;l.DstColorFactor=208;l.OneMinusDstColorFactor=
18259 209;l.SrcAlphaSaturateFactor=210;l.NeverDepth=0;l.AlwaysDepth=1;l.LessDepth=2;l.LessEqualDepth=3;l.EqualDepth=4;l.GreaterEqualDepth=5;l.GreaterDepth=6;l.NotEqualDepth=7;l.MultiplyOperation=0;l.MixOperation=1;l.AddOperation=2;l.NoToneMapping=0;l.LinearToneMapping=1;l.ReinhardToneMapping=2;l.Uncharted2ToneMapping=3;l.CineonToneMapping=4;l.UVMapping=300;l.CubeReflectionMapping=301;l.CubeRefractionMapping=302;l.EquirectangularReflectionMapping=303;l.EquirectangularRefractionMapping=304;l.SphericalReflectionMapping=
18260 305;l.CubeUVReflectionMapping=306;l.CubeUVRefractionMapping=307;l.RepeatWrapping=1E3;l.ClampToEdgeWrapping=1001;l.MirroredRepeatWrapping=1002;l.NearestFilter=1003;l.NearestMipMapNearestFilter=1004;l.NearestMipMapLinearFilter=1005;l.LinearFilter=1006;l.LinearMipMapNearestFilter=1007;l.LinearMipMapLinearFilter=1008;l.UnsignedByteType=1009;l.ByteType=1010;l.ShortType=1011;l.UnsignedShortType=1012;l.IntType=1013;l.UnsignedIntType=1014;l.FloatType=1015;l.HalfFloatType=1016;l.UnsignedShort4444Type=1017;
18261 l.UnsignedShort5551Type=1018;l.UnsignedShort565Type=1019;l.UnsignedInt248Type=1020;l.AlphaFormat=1021;l.RGBFormat=1022;l.RGBAFormat=1023;l.LuminanceFormat=1024;l.LuminanceAlphaFormat=1025;l.RGBEFormat=1023;l.DepthFormat=1026;l.DepthStencilFormat=1027;l.RGB_S3TC_DXT1_Format=33776;l.RGBA_S3TC_DXT1_Format=33777;l.RGBA_S3TC_DXT3_Format=33778;l.RGBA_S3TC_DXT5_Format=33779;l.RGB_PVRTC_4BPPV1_Format=35840;l.RGB_PVRTC_2BPPV1_Format=35841;l.RGBA_PVRTC_4BPPV1_Format=35842;l.RGBA_PVRTC_2BPPV1_Format=35843;l.RGB_ETC1_Format=
18262 36196;l.RGBA_ASTC_4x4_Format=37808;l.RGBA_ASTC_5x4_Format=37809;l.RGBA_ASTC_5x5_Format=37810;l.RGBA_ASTC_6x5_Format=37811;l.RGBA_ASTC_6x6_Format=37812;l.RGBA_ASTC_8x5_Format=37813;l.RGBA_ASTC_8x6_Format=37814;l.RGBA_ASTC_8x8_Format=37815;l.RGBA_ASTC_10x5_Format=37816;l.RGBA_ASTC_10x6_Format=37817;l.RGBA_ASTC_10x8_Format=37818;l.RGBA_ASTC_10x10_Format=37819;l.RGBA_ASTC_12x10_Format=37820;l.RGBA_ASTC_12x12_Format=37821;l.LoopOnce=2200;l.LoopRepeat=2201;l.LoopPingPong=2202;l.InterpolateDiscrete=2300;
18263 l.InterpolateLinear=2301;l.InterpolateSmooth=2302;l.ZeroCurvatureEnding=2400;l.ZeroSlopeEnding=2401;l.WrapAroundEnding=2402;l.TrianglesDrawMode=0;l.TriangleStripDrawMode=1;l.TriangleFanDrawMode=2;l.LinearEncoding=3E3;l.sRGBEncoding=3001;l.GammaEncoding=3007;l.RGBEEncoding=3002;l.LogLuvEncoding=3003;l.RGBM7Encoding=3004;l.RGBM16Encoding=3005;l.RGBDEncoding=3006;l.BasicDepthPacking=3200;l.RGBADepthPacking=3201;l.TangentSpaceNormalMap=0;l.ObjectSpaceNormalMap=1;l.CubeGeometry=Ib;l.Face4=function(a,b,
18264 c,d,e,f,g){console.warn("THREE.Face4 has been removed. A THREE.Face3 will be created instead.");return new Ta(a,b,c,e,f,g)};l.LineStrip=0;l.LinePieces=1;l.MeshFaceMaterial=function(a){console.warn("THREE.MeshFaceMaterial has been removed. Use an Array instead.");return a};l.MultiMaterial=function(a){void 0===a&&(a=[]);console.warn("THREE.MultiMaterial has been removed. Use an Array instead.");a.isMultiMaterial=!0;a.materials=a;a.clone=function(){return a.slice()};return a};l.PointCloud=function(a,
18265 b){console.warn("THREE.PointCloud has been renamed to THREE.Points.");return new Ob(a,b)};l.Particle=function(a){console.warn("THREE.Particle has been renamed to THREE.Sprite.");return new Ac(a)};l.ParticleSystem=function(a,b){console.warn("THREE.ParticleSystem has been renamed to THREE.Points.");return new Ob(a,b)};l.PointCloudMaterial=function(a){console.warn("THREE.PointCloudMaterial has been renamed to THREE.PointsMaterial.");return new Ea(a)};l.ParticleBasicMaterial=function(a){console.warn("THREE.ParticleBasicMaterial has been renamed to THREE.PointsMaterial.");
18266 return new Ea(a)};l.ParticleSystemMaterial=function(a){console.warn("THREE.ParticleSystemMaterial has been renamed to THREE.PointsMaterial.");return new Ea(a)};l.Vertex=function(a,b,c){console.warn("THREE.Vertex has been removed. Use THREE.Vector3 instead.");return new p(a,b,c)};l.DynamicBufferAttribute=function(a,b){console.warn("THREE.DynamicBufferAttribute has been removed. Use new THREE.BufferAttribute().setDynamic( true ) instead.");return(new Q(a,b)).setDynamic(!0)};l.Int8Attribute=function(a,
18267 b){console.warn("THREE.Int8Attribute has been removed. Use new THREE.Int8BufferAttribute() instead.");return new oc(a,b)};l.Uint8Attribute=function(a,b){console.warn("THREE.Uint8Attribute has been removed. Use new THREE.Uint8BufferAttribute() instead.");return new pc(a,b)};l.Uint8ClampedAttribute=function(a,b){console.warn("THREE.Uint8ClampedAttribute has been removed. Use new THREE.Uint8ClampedBufferAttribute() instead.");return new qc(a,b)};l.Int16Attribute=function(a,b){console.warn("THREE.Int16Attribute has been removed. Use new THREE.Int16BufferAttribute() instead.");
18268 return new rc(a,b)};l.Uint16Attribute=function(a,b){console.warn("THREE.Uint16Attribute has been removed. Use new THREE.Uint16BufferAttribute() instead.");return new ib(a,b)};l.Int32Attribute=function(a,b){console.warn("THREE.Int32Attribute has been removed. Use new THREE.Int32BufferAttribute() instead.");return new sc(a,b)};l.Uint32Attribute=function(a,b){console.warn("THREE.Uint32Attribute has been removed. Use new THREE.Uint32BufferAttribute() instead.");return new jb(a,b)};l.Float32Attribute=
18269 function(a,b){console.warn("THREE.Float32Attribute has been removed. Use new THREE.Float32BufferAttribute() instead.");return new A(a,b)};l.Float64Attribute=function(a,b){console.warn("THREE.Float64Attribute has been removed. Use new THREE.Float64BufferAttribute() instead.");return new tc(a,b)};l.ClosedSplineCurve3=yf;l.SplineCurve3=zf;l.Spline=ze;l.AxisHelper=function(a){console.warn("THREE.AxisHelper has been renamed to THREE.AxesHelper.");return new ld(a)};l.BoundingBoxHelper=function(a,b){console.warn("THREE.BoundingBoxHelper has been deprecated. Creating a THREE.BoxHelper instead.");
18270 return new Db(a,b)};l.EdgesHelper=function(a,b){console.warn("THREE.EdgesHelper has been removed. Use THREE.EdgesGeometry instead.");return new W(new ac(a.geometry),new Y({color:void 0!==b?b:16777215}))};l.WireframeHelper=function(a,b){console.warn("THREE.WireframeHelper has been removed. Use THREE.WireframeGeometry instead.");return new W(new Qb(a.geometry),new Y({color:void 0!==b?b:16777215}))};l.XHRLoader=function(a){console.warn("THREE.XHRLoader has been renamed to THREE.FileLoader.");return new Ga(a)};
18271 l.BinaryTextureLoader=function(a){console.warn("THREE.BinaryTextureLoader has been renamed to THREE.DataTextureLoader.");return new de(a)};l.GeometryUtils={merge:function(a,b,c){console.warn("THREE.GeometryUtils: .merge() has been moved to Geometry. Use geometry.merge( geometry2, matrix, materialIndexOffset ) instead.");if(b.isMesh){b.matrixAutoUpdate&&b.updateMatrix();var d=b.matrix;b=b.geometry}a.merge(b,d,c)},center:function(a){console.warn("THREE.GeometryUtils: .center() has been moved to Geometry. Use geometry.center() instead.");
18272 return a.center()}};l.Projector=function(){console.error("THREE.Projector has been moved to /examples/js/renderers/Projector.js.");this.projectVector=function(a,b){console.warn("THREE.Projector: .projectVector() is now vector.project().");a.project(b)};this.unprojectVector=function(a,b){console.warn("THREE.Projector: .unprojectVector() is now vector.unproject().");a.unproject(b)};this.pickingRay=function(){console.error("THREE.Projector: .pickingRay() is now raycaster.setFromCamera().")}};l.CanvasRenderer=
18273 function(){console.error("THREE.CanvasRenderer has been moved to /examples/js/renderers/CanvasRenderer.js");this.domElement=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");this.clear=function(){};this.render=function(){};this.setClearColor=function(){};this.setSize=function(){}};l.SceneUtils={createMultiMaterialObject:function(){console.error("THREE.SceneUtils has been moved to /examples/js/utils/SceneUtils.js")},detach:function(){console.error("THREE.SceneUtils has been moved to /examples/js/utils/SceneUtils.js")},
18274 attach:function(){console.error("THREE.SceneUtils has been moved to /examples/js/utils/SceneUtils.js")}};l.LensFlare=function(){console.error("THREE.LensFlare has been moved to /examples/js/objects/Lensflare.js")};Object.defineProperty(l,"__esModule",{value:!0})});
18276 },{}],227:[function(require,module,exports){
18279 module.exports = TinyQueue;
18281 function TinyQueue(data, compare) {
18282 if (!(this instanceof TinyQueue)) return new TinyQueue(data, compare);
18284 this.data = data || [];
18285 this.length = this.data.length;
18286 this.compare = compare || defaultCompare;
18288 if (this.length > 0) {
18289 for (var i = (this.length >> 1); i >= 0; i--) this._down(i);
18293 function defaultCompare(a, b) {
18294 return a < b ? -1 : a > b ? 1 : 0;
18297 TinyQueue.prototype = {
18299 push: function (item) {
18300 this.data.push(item);
18302 this._up(this.length - 1);
18306 if (this.length === 0) return undefined;
18307 var top = this.data[0];
18309 if (this.length > 0) {
18310 this.data[0] = this.data[this.length];
18317 peek: function () {
18318 return this.data[0];
18321 _up: function (pos) {
18322 var data = this.data;
18323 var compare = this.compare;
18324 var item = data[pos];
18327 var parent = (pos - 1) >> 1;
18328 var current = data[parent];
18329 if (compare(item, current) >= 0) break;
18330 data[pos] = current;
18337 _down: function (pos) {
18338 var data = this.data;
18339 var compare = this.compare;
18340 var len = this.length;
18341 var halfLen = len >> 1;
18342 var item = data[pos];
18344 while (pos < halfLen) {
18345 var left = (pos << 1) + 1;
18346 var right = left + 1;
18347 var best = data[left];
18349 if (right < len && compare(data[right], best) < 0) {
18351 best = data[right];
18353 if (compare(best, item) >= 0) break;
18363 },{}],228:[function(require,module,exports){
18364 var createElement = require("./vdom/create-element.js")
18366 module.exports = createElement
18368 },{"./vdom/create-element.js":234}],229:[function(require,module,exports){
18369 var diff = require("./vtree/diff.js")
18371 module.exports = diff
18373 },{"./vtree/diff.js":254}],230:[function(require,module,exports){
18374 var h = require("./virtual-hyperscript/index.js")
18378 },{"./virtual-hyperscript/index.js":241}],231:[function(require,module,exports){
18379 var diff = require("./diff.js")
18380 var patch = require("./patch.js")
18381 var h = require("./h.js")
18382 var create = require("./create-element.js")
18383 var VNode = require('./vnode/vnode.js')
18384 var VText = require('./vnode/vtext.js')
18395 },{"./create-element.js":228,"./diff.js":229,"./h.js":230,"./patch.js":232,"./vnode/vnode.js":250,"./vnode/vtext.js":252}],232:[function(require,module,exports){
18396 var patch = require("./vdom/patch.js")
18398 module.exports = patch
18400 },{"./vdom/patch.js":237}],233:[function(require,module,exports){
18401 var isObject = require("is-object")
18402 var isHook = require("../vnode/is-vhook.js")
18404 module.exports = applyProperties
18406 function applyProperties(node, props, previous) {
18407 for (var propName in props) {
18408 var propValue = props[propName]
18410 if (propValue === undefined) {
18411 removeProperty(node, propName, propValue, previous);
18412 } else if (isHook(propValue)) {
18413 removeProperty(node, propName, propValue, previous)
18414 if (propValue.hook) {
18415 propValue.hook(node,
18417 previous ? previous[propName] : undefined)
18420 if (isObject(propValue)) {
18421 patchObject(node, props, previous, propName, propValue);
18423 node[propName] = propValue
18429 function removeProperty(node, propName, propValue, previous) {
18431 var previousValue = previous[propName]
18433 if (!isHook(previousValue)) {
18434 if (propName === "attributes") {
18435 for (var attrName in previousValue) {
18436 node.removeAttribute(attrName)
18438 } else if (propName === "style") {
18439 for (var i in previousValue) {
18442 } else if (typeof previousValue === "string") {
18443 node[propName] = ""
18445 node[propName] = null
18447 } else if (previousValue.unhook) {
18448 previousValue.unhook(node, propName, propValue)
18453 function patchObject(node, props, previous, propName, propValue) {
18454 var previousValue = previous ? previous[propName] : undefined
18457 if (propName === "attributes") {
18458 for (var attrName in propValue) {
18459 var attrValue = propValue[attrName]
18461 if (attrValue === undefined) {
18462 node.removeAttribute(attrName)
18464 node.setAttribute(attrName, attrValue)
18471 if(previousValue && isObject(previousValue) &&
18472 getPrototype(previousValue) !== getPrototype(propValue)) {
18473 node[propName] = propValue
18477 if (!isObject(node[propName])) {
18478 node[propName] = {}
18481 var replacer = propName === "style" ? "" : undefined
18483 for (var k in propValue) {
18484 var value = propValue[k]
18485 node[propName][k] = (value === undefined) ? replacer : value
18489 function getPrototype(value) {
18490 if (Object.getPrototypeOf) {
18491 return Object.getPrototypeOf(value)
18492 } else if (value.__proto__) {
18493 return value.__proto__
18494 } else if (value.constructor) {
18495 return value.constructor.prototype
18499 },{"../vnode/is-vhook.js":245,"is-object":20}],234:[function(require,module,exports){
18500 var document = require("global/document")
18502 var applyProperties = require("./apply-properties")
18504 var isVNode = require("../vnode/is-vnode.js")
18505 var isVText = require("../vnode/is-vtext.js")
18506 var isWidget = require("../vnode/is-widget.js")
18507 var handleThunk = require("../vnode/handle-thunk.js")
18509 module.exports = createElement
18511 function createElement(vnode, opts) {
18512 var doc = opts ? opts.document || document : document
18513 var warn = opts ? opts.warn : null
18515 vnode = handleThunk(vnode).a
18517 if (isWidget(vnode)) {
18518 return vnode.init()
18519 } else if (isVText(vnode)) {
18520 return doc.createTextNode(vnode.text)
18521 } else if (!isVNode(vnode)) {
18523 warn("Item is not a valid virtual dom node", vnode)
18528 var node = (vnode.namespace === null) ?
18529 doc.createElement(vnode.tagName) :
18530 doc.createElementNS(vnode.namespace, vnode.tagName)
18532 var props = vnode.properties
18533 applyProperties(node, props)
18535 var children = vnode.children
18537 for (var i = 0; i < children.length; i++) {
18538 var childNode = createElement(children[i], opts)
18540 node.appendChild(childNode)
18547 },{"../vnode/handle-thunk.js":243,"../vnode/is-vnode.js":246,"../vnode/is-vtext.js":247,"../vnode/is-widget.js":248,"./apply-properties":233,"global/document":16}],235:[function(require,module,exports){
18548 // Maps a virtual DOM tree onto a real DOM tree in an efficient manner.
18549 // We don't want to read all of the DOM nodes in the tree so we use
18550 // the in-order tree indexing to eliminate recursion down certain branches.
18551 // We only recurse into a DOM node if we know that it contains a child of
18556 module.exports = domIndex
18558 function domIndex(rootNode, tree, indices, nodes) {
18559 if (!indices || indices.length === 0) {
18562 indices.sort(ascending)
18563 return recurse(rootNode, tree, indices, nodes, 0)
18567 function recurse(rootNode, tree, indices, nodes, rootIndex) {
18568 nodes = nodes || {}
18572 if (indexInRange(indices, rootIndex, rootIndex)) {
18573 nodes[rootIndex] = rootNode
18576 var vChildren = tree.children
18580 var childNodes = rootNode.childNodes
18582 for (var i = 0; i < tree.children.length; i++) {
18585 var vChild = vChildren[i] || noChild
18586 var nextIndex = rootIndex + (vChild.count || 0)
18588 // skip recursion down the tree if there are no nodes down here
18589 if (indexInRange(indices, rootIndex, nextIndex)) {
18590 recurse(childNodes[i], vChild, indices, nodes, rootIndex)
18593 rootIndex = nextIndex
18601 // Binary search for an index in the interval [left, right]
18602 function indexInRange(indices, left, right) {
18603 if (indices.length === 0) {
18608 var maxIndex = indices.length - 1
18612 while (minIndex <= maxIndex) {
18613 currentIndex = ((maxIndex + minIndex) / 2) >> 0
18614 currentItem = indices[currentIndex]
18616 if (minIndex === maxIndex) {
18617 return currentItem >= left && currentItem <= right
18618 } else if (currentItem < left) {
18619 minIndex = currentIndex + 1
18620 } else if (currentItem > right) {
18621 maxIndex = currentIndex - 1
18630 function ascending(a, b) {
18631 return a > b ? 1 : -1
18634 },{}],236:[function(require,module,exports){
18635 var applyProperties = require("./apply-properties")
18637 var isWidget = require("../vnode/is-widget.js")
18638 var VPatch = require("../vnode/vpatch.js")
18640 var updateWidget = require("./update-widget")
18642 module.exports = applyPatch
18644 function applyPatch(vpatch, domNode, renderOptions) {
18645 var type = vpatch.type
18646 var vNode = vpatch.vNode
18647 var patch = vpatch.patch
18650 case VPatch.REMOVE:
18651 return removeNode(domNode, vNode)
18652 case VPatch.INSERT:
18653 return insertNode(domNode, patch, renderOptions)
18655 return stringPatch(domNode, vNode, patch, renderOptions)
18656 case VPatch.WIDGET:
18657 return widgetPatch(domNode, vNode, patch, renderOptions)
18659 return vNodePatch(domNode, vNode, patch, renderOptions)
18661 reorderChildren(domNode, patch)
18664 applyProperties(domNode, patch, vNode.properties)
18667 return replaceRoot(domNode,
18668 renderOptions.patch(domNode, patch, renderOptions))
18674 function removeNode(domNode, vNode) {
18675 var parentNode = domNode.parentNode
18678 parentNode.removeChild(domNode)
18681 destroyWidget(domNode, vNode);
18686 function insertNode(parentNode, vNode, renderOptions) {
18687 var newNode = renderOptions.render(vNode, renderOptions)
18690 parentNode.appendChild(newNode)
18696 function stringPatch(domNode, leftVNode, vText, renderOptions) {
18699 if (domNode.nodeType === 3) {
18700 domNode.replaceData(0, domNode.length, vText.text)
18703 var parentNode = domNode.parentNode
18704 newNode = renderOptions.render(vText, renderOptions)
18706 if (parentNode && newNode !== domNode) {
18707 parentNode.replaceChild(newNode, domNode)
18714 function widgetPatch(domNode, leftVNode, widget, renderOptions) {
18715 var updating = updateWidget(leftVNode, widget)
18719 newNode = widget.update(leftVNode, domNode) || domNode
18721 newNode = renderOptions.render(widget, renderOptions)
18724 var parentNode = domNode.parentNode
18726 if (parentNode && newNode !== domNode) {
18727 parentNode.replaceChild(newNode, domNode)
18731 destroyWidget(domNode, leftVNode)
18737 function vNodePatch(domNode, leftVNode, vNode, renderOptions) {
18738 var parentNode = domNode.parentNode
18739 var newNode = renderOptions.render(vNode, renderOptions)
18741 if (parentNode && newNode !== domNode) {
18742 parentNode.replaceChild(newNode, domNode)
18748 function destroyWidget(domNode, w) {
18749 if (typeof w.destroy === "function" && isWidget(w)) {
18754 function reorderChildren(domNode, moves) {
18755 var childNodes = domNode.childNodes
18761 for (var i = 0; i < moves.removes.length; i++) {
18762 remove = moves.removes[i]
18763 node = childNodes[remove.from]
18765 keyMap[remove.key] = node
18767 domNode.removeChild(node)
18770 var length = childNodes.length
18771 for (var j = 0; j < moves.inserts.length; j++) {
18772 insert = moves.inserts[j]
18773 node = keyMap[insert.key]
18774 // this is the weirdest bug i've ever seen in webkit
18775 domNode.insertBefore(node, insert.to >= length++ ? null : childNodes[insert.to])
18779 function replaceRoot(oldRoot, newRoot) {
18780 if (oldRoot && newRoot && oldRoot !== newRoot && oldRoot.parentNode) {
18781 oldRoot.parentNode.replaceChild(newRoot, oldRoot)
18787 },{"../vnode/is-widget.js":248,"../vnode/vpatch.js":251,"./apply-properties":233,"./update-widget":238}],237:[function(require,module,exports){
18788 var document = require("global/document")
18789 var isArray = require("x-is-array")
18791 var render = require("./create-element")
18792 var domIndex = require("./dom-index")
18793 var patchOp = require("./patch-op")
18794 module.exports = patch
18796 function patch(rootNode, patches, renderOptions) {
18797 renderOptions = renderOptions || {}
18798 renderOptions.patch = renderOptions.patch && renderOptions.patch !== patch
18799 ? renderOptions.patch
18801 renderOptions.render = renderOptions.render || render
18803 return renderOptions.patch(rootNode, patches, renderOptions)
18806 function patchRecursive(rootNode, patches, renderOptions) {
18807 var indices = patchIndices(patches)
18809 if (indices.length === 0) {
18813 var index = domIndex(rootNode, patches.a, indices)
18814 var ownerDocument = rootNode.ownerDocument
18816 if (!renderOptions.document && ownerDocument !== document) {
18817 renderOptions.document = ownerDocument
18820 for (var i = 0; i < indices.length; i++) {
18821 var nodeIndex = indices[i]
18822 rootNode = applyPatch(rootNode,
18824 patches[nodeIndex],
18831 function applyPatch(rootNode, domNode, patchList, renderOptions) {
18838 if (isArray(patchList)) {
18839 for (var i = 0; i < patchList.length; i++) {
18840 newNode = patchOp(patchList[i], domNode, renderOptions)
18842 if (domNode === rootNode) {
18847 newNode = patchOp(patchList, domNode, renderOptions)
18849 if (domNode === rootNode) {
18857 function patchIndices(patches) {
18860 for (var key in patches) {
18862 indices.push(Number(key))
18869 },{"./create-element":234,"./dom-index":235,"./patch-op":236,"global/document":16,"x-is-array":273}],238:[function(require,module,exports){
18870 var isWidget = require("../vnode/is-widget.js")
18872 module.exports = updateWidget
18874 function updateWidget(a, b) {
18875 if (isWidget(a) && isWidget(b)) {
18876 if ("name" in a && "name" in b) {
18877 return a.id === b.id
18879 return a.init === b.init
18886 },{"../vnode/is-widget.js":248}],239:[function(require,module,exports){
18889 var EvStore = require('ev-store');
18891 module.exports = EvHook;
18893 function EvHook(value) {
18894 if (!(this instanceof EvHook)) {
18895 return new EvHook(value);
18898 this.value = value;
18901 EvHook.prototype.hook = function (node, propertyName) {
18902 var es = EvStore(node);
18903 var propName = propertyName.substr(3);
18905 es[propName] = this.value;
18908 EvHook.prototype.unhook = function(node, propertyName) {
18909 var es = EvStore(node);
18910 var propName = propertyName.substr(3);
18912 es[propName] = undefined;
18915 },{"ev-store":9}],240:[function(require,module,exports){
18918 module.exports = SoftSetHook;
18920 function SoftSetHook(value) {
18921 if (!(this instanceof SoftSetHook)) {
18922 return new SoftSetHook(value);
18925 this.value = value;
18928 SoftSetHook.prototype.hook = function (node, propertyName) {
18929 if (node[propertyName] !== this.value) {
18930 node[propertyName] = this.value;
18934 },{}],241:[function(require,module,exports){
18937 var isArray = require('x-is-array');
18939 var VNode = require('../vnode/vnode.js');
18940 var VText = require('../vnode/vtext.js');
18941 var isVNode = require('../vnode/is-vnode');
18942 var isVText = require('../vnode/is-vtext');
18943 var isWidget = require('../vnode/is-widget');
18944 var isHook = require('../vnode/is-vhook');
18945 var isVThunk = require('../vnode/is-thunk');
18947 var parseTag = require('./parse-tag.js');
18948 var softSetHook = require('./hooks/soft-set-hook.js');
18949 var evHook = require('./hooks/ev-hook.js');
18951 module.exports = h;
18953 function h(tagName, properties, children) {
18954 var childNodes = [];
18955 var tag, props, key, namespace;
18957 if (!children && isChildren(properties)) {
18958 children = properties;
18962 props = props || properties || {};
18963 tag = parseTag(tagName, props);
18966 if (props.hasOwnProperty('key')) {
18968 props.key = undefined;
18971 // support namespace
18972 if (props.hasOwnProperty('namespace')) {
18973 namespace = props.namespace;
18974 props.namespace = undefined;
18978 if (tag === 'INPUT' &&
18980 props.hasOwnProperty('value') &&
18981 props.value !== undefined &&
18982 !isHook(props.value)
18984 props.value = softSetHook(props.value);
18987 transformProperties(props);
18989 if (children !== undefined && children !== null) {
18990 addChild(children, childNodes, tag, props);
18994 return new VNode(tag, props, childNodes, key, namespace);
18997 function addChild(c, childNodes, tag, props) {
18998 if (typeof c === 'string') {
18999 childNodes.push(new VText(c));
19000 } else if (typeof c === 'number') {
19001 childNodes.push(new VText(String(c)));
19002 } else if (isChild(c)) {
19003 childNodes.push(c);
19004 } else if (isArray(c)) {
19005 for (var i = 0; i < c.length; i++) {
19006 addChild(c[i], childNodes, tag, props);
19008 } else if (c === null || c === undefined) {
19011 throw UnexpectedVirtualElement({
19021 function transformProperties(props) {
19022 for (var propName in props) {
19023 if (props.hasOwnProperty(propName)) {
19024 var value = props[propName];
19026 if (isHook(value)) {
19030 if (propName.substr(0, 3) === 'ev-') {
19031 // add ev-foo support
19032 props[propName] = evHook(value);
19038 function isChild(x) {
19039 return isVNode(x) || isVText(x) || isWidget(x) || isVThunk(x);
19042 function isChildren(x) {
19043 return typeof x === 'string' || isArray(x) || isChild(x);
19046 function UnexpectedVirtualElement(data) {
19047 var err = new Error();
19049 err.type = 'virtual-hyperscript.unexpected.virtual-element';
19050 err.message = 'Unexpected virtual child passed to h().\n' +
19051 'Expected a VNode / Vthunk / VWidget / string but:\n' +
19053 errorString(data.foreignObject) +
19055 'The parent vnode is:\n' +
19056 errorString(data.parentVnode)
19058 'Suggested fix: change your `h(..., [ ... ])` callsite.';
19059 err.foreignObject = data.foreignObject;
19060 err.parentVnode = data.parentVnode;
19065 function errorString(obj) {
19067 return JSON.stringify(obj, null, ' ');
19069 return String(obj);
19073 },{"../vnode/is-thunk":244,"../vnode/is-vhook":245,"../vnode/is-vnode":246,"../vnode/is-vtext":247,"../vnode/is-widget":248,"../vnode/vnode.js":250,"../vnode/vtext.js":252,"./hooks/ev-hook.js":239,"./hooks/soft-set-hook.js":240,"./parse-tag.js":242,"x-is-array":273}],242:[function(require,module,exports){
19076 var split = require('browser-split');
19078 var classIdSplit = /([\.#]?[a-zA-Z0-9\u007F-\uFFFF_:-]+)/;
19079 var notClassId = /^\.|#/;
19081 module.exports = parseTag;
19083 function parseTag(tag, props) {
19088 var noId = !(props.hasOwnProperty('id'));
19090 var tagParts = split(tag, classIdSplit);
19091 var tagName = null;
19093 if (notClassId.test(tagParts[1])) {
19097 var classes, part, type, i;
19099 for (i = 0; i < tagParts.length; i++) {
19100 part = tagParts[i];
19106 type = part.charAt(0);
19110 } else if (type === '.') {
19111 classes = classes || [];
19112 classes.push(part.substring(1, part.length));
19113 } else if (type === '#' && noId) {
19114 props.id = part.substring(1, part.length);
19119 if (props.className) {
19120 classes.push(props.className);
19123 props.className = classes.join(' ');
19126 return props.namespace ? tagName : tagName.toUpperCase();
19129 },{"browser-split":5}],243:[function(require,module,exports){
19130 var isVNode = require("./is-vnode")
19131 var isVText = require("./is-vtext")
19132 var isWidget = require("./is-widget")
19133 var isThunk = require("./is-thunk")
19135 module.exports = handleThunk
19137 function handleThunk(a, b) {
19142 renderedB = renderThunk(b, a)
19146 renderedA = renderThunk(a, null)
19155 function renderThunk(thunk, previous) {
19156 var renderedThunk = thunk.vnode
19158 if (!renderedThunk) {
19159 renderedThunk = thunk.vnode = thunk.render(previous)
19162 if (!(isVNode(renderedThunk) ||
19163 isVText(renderedThunk) ||
19164 isWidget(renderedThunk))) {
19165 throw new Error("thunk did not return a valid node");
19168 return renderedThunk
19171 },{"./is-thunk":244,"./is-vnode":246,"./is-vtext":247,"./is-widget":248}],244:[function(require,module,exports){
19172 module.exports = isThunk
19174 function isThunk(t) {
19175 return t && t.type === "Thunk"
19178 },{}],245:[function(require,module,exports){
19179 module.exports = isHook
19181 function isHook(hook) {
19183 (typeof hook.hook === "function" && !hook.hasOwnProperty("hook") ||
19184 typeof hook.unhook === "function" && !hook.hasOwnProperty("unhook"))
19187 },{}],246:[function(require,module,exports){
19188 var version = require("./version")
19190 module.exports = isVirtualNode
19192 function isVirtualNode(x) {
19193 return x && x.type === "VirtualNode" && x.version === version
19196 },{"./version":249}],247:[function(require,module,exports){
19197 var version = require("./version")
19199 module.exports = isVirtualText
19201 function isVirtualText(x) {
19202 return x && x.type === "VirtualText" && x.version === version
19205 },{"./version":249}],248:[function(require,module,exports){
19206 module.exports = isWidget
19208 function isWidget(w) {
19209 return w && w.type === "Widget"
19212 },{}],249:[function(require,module,exports){
19213 module.exports = "2"
19215 },{}],250:[function(require,module,exports){
19216 var version = require("./version")
19217 var isVNode = require("./is-vnode")
19218 var isWidget = require("./is-widget")
19219 var isThunk = require("./is-thunk")
19220 var isVHook = require("./is-vhook")
19222 module.exports = VirtualNode
19224 var noProperties = {}
19225 var noChildren = []
19227 function VirtualNode(tagName, properties, children, key, namespace) {
19228 this.tagName = tagName
19229 this.properties = properties || noProperties
19230 this.children = children || noChildren
19231 this.key = key != null ? String(key) : undefined
19232 this.namespace = (typeof namespace === "string") ? namespace : null
19234 var count = (children && children.length) || 0
19235 var descendants = 0
19236 var hasWidgets = false
19237 var hasThunks = false
19238 var descendantHooks = false
19241 for (var propName in properties) {
19242 if (properties.hasOwnProperty(propName)) {
19243 var property = properties[propName]
19244 if (isVHook(property) && property.unhook) {
19249 hooks[propName] = property
19254 for (var i = 0; i < count; i++) {
19255 var child = children[i]
19256 if (isVNode(child)) {
19257 descendants += child.count || 0
19259 if (!hasWidgets && child.hasWidgets) {
19263 if (!hasThunks && child.hasThunks) {
19267 if (!descendantHooks && (child.hooks || child.descendantHooks)) {
19268 descendantHooks = true
19270 } else if (!hasWidgets && isWidget(child)) {
19271 if (typeof child.destroy === "function") {
19274 } else if (!hasThunks && isThunk(child)) {
19279 this.count = count + descendants
19280 this.hasWidgets = hasWidgets
19281 this.hasThunks = hasThunks
19283 this.descendantHooks = descendantHooks
19286 VirtualNode.prototype.version = version
19287 VirtualNode.prototype.type = "VirtualNode"
19289 },{"./is-thunk":244,"./is-vhook":245,"./is-vnode":246,"./is-widget":248,"./version":249}],251:[function(require,module,exports){
19290 var version = require("./version")
19292 VirtualPatch.NONE = 0
19293 VirtualPatch.VTEXT = 1
19294 VirtualPatch.VNODE = 2
19295 VirtualPatch.WIDGET = 3
19296 VirtualPatch.PROPS = 4
19297 VirtualPatch.ORDER = 5
19298 VirtualPatch.INSERT = 6
19299 VirtualPatch.REMOVE = 7
19300 VirtualPatch.THUNK = 8
19302 module.exports = VirtualPatch
19304 function VirtualPatch(type, vNode, patch) {
19305 this.type = Number(type)
19310 VirtualPatch.prototype.version = version
19311 VirtualPatch.prototype.type = "VirtualPatch"
19313 },{"./version":249}],252:[function(require,module,exports){
19314 var version = require("./version")
19316 module.exports = VirtualText
19318 function VirtualText(text) {
19319 this.text = String(text)
19322 VirtualText.prototype.version = version
19323 VirtualText.prototype.type = "VirtualText"
19325 },{"./version":249}],253:[function(require,module,exports){
19326 var isObject = require("is-object")
19327 var isHook = require("../vnode/is-vhook")
19329 module.exports = diffProps
19331 function diffProps(a, b) {
19334 for (var aKey in a) {
19335 if (!(aKey in b)) {
19337 diff[aKey] = undefined
19340 var aValue = a[aKey]
19341 var bValue = b[aKey]
19343 if (aValue === bValue) {
19345 } else if (isObject(aValue) && isObject(bValue)) {
19346 if (getPrototype(bValue) !== getPrototype(aValue)) {
19348 diff[aKey] = bValue
19349 } else if (isHook(bValue)) {
19351 diff[aKey] = bValue
19353 var objectDiff = diffProps(aValue, bValue)
19356 diff[aKey] = objectDiff
19361 diff[aKey] = bValue
19365 for (var bKey in b) {
19366 if (!(bKey in a)) {
19368 diff[bKey] = b[bKey]
19375 function getPrototype(value) {
19376 if (Object.getPrototypeOf) {
19377 return Object.getPrototypeOf(value)
19378 } else if (value.__proto__) {
19379 return value.__proto__
19380 } else if (value.constructor) {
19381 return value.constructor.prototype
19385 },{"../vnode/is-vhook":245,"is-object":20}],254:[function(require,module,exports){
19386 var isArray = require("x-is-array")
19388 var VPatch = require("../vnode/vpatch")
19389 var isVNode = require("../vnode/is-vnode")
19390 var isVText = require("../vnode/is-vtext")
19391 var isWidget = require("../vnode/is-widget")
19392 var isThunk = require("../vnode/is-thunk")
19393 var handleThunk = require("../vnode/handle-thunk")
19395 var diffProps = require("./diff-props")
19397 module.exports = diff
19399 function diff(a, b) {
19400 var patch = { a: a }
19401 walk(a, b, patch, 0)
19405 function walk(a, b, patch, index) {
19410 var apply = patch[index]
19411 var applyClear = false
19413 if (isThunk(a) || isThunk(b)) {
19414 thunks(a, b, patch, index)
19415 } else if (b == null) {
19417 // If a is a widget we will add a remove patch for it
19418 // Otherwise any child widgets/hooks must be destroyed.
19419 // This prevents adding two remove patches for a widget.
19420 if (!isWidget(a)) {
19421 clearState(a, patch, index)
19422 apply = patch[index]
19425 apply = appendPatch(apply, new VPatch(VPatch.REMOVE, a, b))
19426 } else if (isVNode(b)) {
19428 if (a.tagName === b.tagName &&
19429 a.namespace === b.namespace &&
19431 var propsPatch = diffProps(a.properties, b.properties)
19433 apply = appendPatch(apply,
19434 new VPatch(VPatch.PROPS, a, propsPatch))
19436 apply = diffChildren(a, b, patch, apply, index)
19438 apply = appendPatch(apply, new VPatch(VPatch.VNODE, a, b))
19442 apply = appendPatch(apply, new VPatch(VPatch.VNODE, a, b))
19445 } else if (isVText(b)) {
19447 apply = appendPatch(apply, new VPatch(VPatch.VTEXT, a, b))
19449 } else if (a.text !== b.text) {
19450 apply = appendPatch(apply, new VPatch(VPatch.VTEXT, a, b))
19452 } else if (isWidget(b)) {
19453 if (!isWidget(a)) {
19457 apply = appendPatch(apply, new VPatch(VPatch.WIDGET, a, b))
19461 patch[index] = apply
19465 clearState(a, patch, index)
19469 function diffChildren(a, b, patch, apply, index) {
19470 var aChildren = a.children
19471 var orderedSet = reorder(aChildren, b.children)
19472 var bChildren = orderedSet.children
19474 var aLen = aChildren.length
19475 var bLen = bChildren.length
19476 var len = aLen > bLen ? aLen : bLen
19478 for (var i = 0; i < len; i++) {
19479 var leftNode = aChildren[i]
19480 var rightNode = bChildren[i]
19485 // Excess nodes in b need to be added
19486 apply = appendPatch(apply,
19487 new VPatch(VPatch.INSERT, null, rightNode))
19490 walk(leftNode, rightNode, patch, index)
19493 if (isVNode(leftNode) && leftNode.count) {
19494 index += leftNode.count
19498 if (orderedSet.moves) {
19499 // Reorder nodes last
19500 apply = appendPatch(apply, new VPatch(
19510 function clearState(vNode, patch, index) {
19511 // TODO: Make this a single walk, not two
19512 unhook(vNode, patch, index)
19513 destroyWidgets(vNode, patch, index)
19516 // Patch records for all destroyed widgets must be added because we need
19517 // a DOM node reference for the destroy function
19518 function destroyWidgets(vNode, patch, index) {
19519 if (isWidget(vNode)) {
19520 if (typeof vNode.destroy === "function") {
19521 patch[index] = appendPatch(
19523 new VPatch(VPatch.REMOVE, vNode, null)
19526 } else if (isVNode(vNode) && (vNode.hasWidgets || vNode.hasThunks)) {
19527 var children = vNode.children
19528 var len = children.length
19529 for (var i = 0; i < len; i++) {
19530 var child = children[i]
19533 destroyWidgets(child, patch, index)
19535 if (isVNode(child) && child.count) {
19536 index += child.count
19539 } else if (isThunk(vNode)) {
19540 thunks(vNode, null, patch, index)
19544 // Create a sub-patch for thunks
19545 function thunks(a, b, patch, index) {
19546 var nodes = handleThunk(a, b)
19547 var thunkPatch = diff(nodes.a, nodes.b)
19548 if (hasPatches(thunkPatch)) {
19549 patch[index] = new VPatch(VPatch.THUNK, null, thunkPatch)
19553 function hasPatches(patch) {
19554 for (var index in patch) {
19555 if (index !== "a") {
19563 // Execute hooks when two nodes are identical
19564 function unhook(vNode, patch, index) {
19565 if (isVNode(vNode)) {
19567 patch[index] = appendPatch(
19572 undefinedKeys(vNode.hooks)
19577 if (vNode.descendantHooks || vNode.hasThunks) {
19578 var children = vNode.children
19579 var len = children.length
19580 for (var i = 0; i < len; i++) {
19581 var child = children[i]
19584 unhook(child, patch, index)
19586 if (isVNode(child) && child.count) {
19587 index += child.count
19591 } else if (isThunk(vNode)) {
19592 thunks(vNode, null, patch, index)
19596 function undefinedKeys(obj) {
19599 for (var key in obj) {
19600 result[key] = undefined
19606 // List diff, naive left to right reordering
19607 function reorder(aChildren, bChildren) {
19608 // O(M) time, O(M) memory
19609 var bChildIndex = keyIndex(bChildren)
19610 var bKeys = bChildIndex.keys
19611 var bFree = bChildIndex.free
19613 if (bFree.length === bChildren.length) {
19615 children: bChildren,
19620 // O(N) time, O(N) memory
19621 var aChildIndex = keyIndex(aChildren)
19622 var aKeys = aChildIndex.keys
19623 var aFree = aChildIndex.free
19625 if (aFree.length === aChildren.length) {
19627 children: bChildren,
19632 // O(MAX(N, M)) memory
19633 var newChildren = []
19636 var freeCount = bFree.length
19637 var deletedItems = 0
19639 // Iterate through a and match a node in b
19641 for (var i = 0 ; i < aChildren.length; i++) {
19642 var aItem = aChildren[i]
19646 if (bKeys.hasOwnProperty(aItem.key)) {
19647 // Match up the old keys
19648 itemIndex = bKeys[aItem.key]
19649 newChildren.push(bChildren[itemIndex])
19652 // Remove old keyed items
19653 itemIndex = i - deletedItems++
19654 newChildren.push(null)
19657 // Match the item in a with the next free item in b
19658 if (freeIndex < freeCount) {
19659 itemIndex = bFree[freeIndex++]
19660 newChildren.push(bChildren[itemIndex])
19662 // There are no free items in b to match with
19663 // the free items in a, so the extra free nodes
19665 itemIndex = i - deletedItems++
19666 newChildren.push(null)
19671 var lastFreeIndex = freeIndex >= bFree.length ?
19675 // Iterate through b and append any new keys
19677 for (var j = 0; j < bChildren.length; j++) {
19678 var newItem = bChildren[j]
19681 if (!aKeys.hasOwnProperty(newItem.key)) {
19682 // Add any new keyed items
19683 // We are adding new items to the end and then sorting them
19684 // in place. In future we should insert new items in place.
19685 newChildren.push(newItem)
19687 } else if (j >= lastFreeIndex) {
19688 // Add any leftover non-keyed items
19689 newChildren.push(newItem)
19693 var simulate = newChildren.slice()
19694 var simulateIndex = 0
19699 for (var k = 0; k < bChildren.length;) {
19700 var wantedItem = bChildren[k]
19701 simulateItem = simulate[simulateIndex]
19704 while (simulateItem === null && simulate.length) {
19705 removes.push(remove(simulate, simulateIndex, null))
19706 simulateItem = simulate[simulateIndex]
19709 if (!simulateItem || simulateItem.key !== wantedItem.key) {
19710 // if we need a key in this position...
19711 if (wantedItem.key) {
19712 if (simulateItem && simulateItem.key) {
19713 // if an insert doesn't put this key in place, it needs to move
19714 if (bKeys[simulateItem.key] !== k + 1) {
19715 removes.push(remove(simulate, simulateIndex, simulateItem.key))
19716 simulateItem = simulate[simulateIndex]
19717 // if the remove didn't put the wanted item in place, we need to insert it
19718 if (!simulateItem || simulateItem.key !== wantedItem.key) {
19719 inserts.push({key: wantedItem.key, to: k})
19721 // items are matching, so skip ahead
19727 inserts.push({key: wantedItem.key, to: k})
19731 inserts.push({key: wantedItem.key, to: k})
19735 // a key in simulate has no matching wanted key, remove it
19736 else if (simulateItem && simulateItem.key) {
19737 removes.push(remove(simulate, simulateIndex, simulateItem.key))
19746 // remove all the remaining nodes from simulate
19747 while(simulateIndex < simulate.length) {
19748 simulateItem = simulate[simulateIndex]
19749 removes.push(remove(simulate, simulateIndex, simulateItem && simulateItem.key))
19752 // If the only moves we have are deletes then we can just
19753 // let the delete patch remove these items.
19754 if (removes.length === deletedItems && !inserts.length) {
19756 children: newChildren,
19762 children: newChildren,
19770 function remove(arr, index, key) {
19771 arr.splice(index, 1)
19779 function keyIndex(children) {
19782 var length = children.length
19784 for (var i = 0; i < length; i++) {
19785 var child = children[i]
19788 keys[child.key] = i
19795 keys: keys, // A hash of key name to index
19796 free: free // An array of unkeyed item indices
19800 function appendPatch(apply, patch) {
19802 if (isArray(apply)) {
19805 apply = [apply, patch]
19814 },{"../vnode/handle-thunk":243,"../vnode/is-thunk":244,"../vnode/is-vnode":246,"../vnode/is-vtext":247,"../vnode/is-widget":248,"../vnode/vpatch":251,"./diff-props":253,"x-is-array":273}],255:[function(require,module,exports){
19815 /** @license MIT License (c) copyright 2010-2014 original author or authors */
19816 /** @author Brian Cavalier */
19817 /** @author John Hann */
19819 (function(define) { 'use strict';
19820 define(function (require) {
19822 var makePromise = require('./makePromise');
19823 var Scheduler = require('./Scheduler');
19824 var async = require('./env').asap;
19826 return makePromise({
19827 scheduler: new Scheduler(async)
19831 })(typeof define === 'function' && define.amd ? define : function (factory) { module.exports = factory(require); });
19833 },{"./Scheduler":256,"./env":268,"./makePromise":270}],256:[function(require,module,exports){
19834 /** @license MIT License (c) copyright 2010-2014 original author or authors */
19835 /** @author Brian Cavalier */
19836 /** @author John Hann */
19838 (function(define) { 'use strict';
19839 define(function() {
19841 // Credit to Twisol (https://github.com/Twisol) for suggesting
19842 // this type of extensible queue + trampoline approach for next-tick conflation.
19845 * Async task scheduler
19846 * @param {function} async function to schedule a single async function
19849 function Scheduler(async) {
19850 this._async = async;
19851 this._running = false;
19853 this._queue = this;
19854 this._queueLen = 0;
19855 this._afterQueue = {};
19856 this._afterQueueLen = 0;
19859 this.drain = function() {
19866 * @param {{ run:function }} task
19868 Scheduler.prototype.enqueue = function(task) {
19869 this._queue[this._queueLen++] = task;
19874 * Enqueue a task to run after the main task queue
19875 * @param {{ run:function }} task
19877 Scheduler.prototype.afterQueue = function(task) {
19878 this._afterQueue[this._afterQueueLen++] = task;
19882 Scheduler.prototype.run = function() {
19883 if (!this._running) {
19884 this._running = true;
19885 this._async(this.drain);
19890 * Drain the handler queue entirely, and then the after queue
19892 Scheduler.prototype._drain = function() {
19894 for (; i < this._queueLen; ++i) {
19895 this._queue[i].run();
19896 this._queue[i] = void 0;
19899 this._queueLen = 0;
19900 this._running = false;
19902 for (i = 0; i < this._afterQueueLen; ++i) {
19903 this._afterQueue[i].run();
19904 this._afterQueue[i] = void 0;
19907 this._afterQueueLen = 0;
19913 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); }));
19915 },{}],257:[function(require,module,exports){
19916 /** @license MIT License (c) copyright 2010-2014 original author or authors */
19917 /** @author Brian Cavalier */
19918 /** @author John Hann */
19920 (function(define) { 'use strict';
19921 define(function() {
19924 * Custom error type for promises rejected by promise.timeout
19925 * @param {string} message
19928 function TimeoutError (message) {
19930 this.message = message;
19931 this.name = TimeoutError.name;
19932 if (typeof Error.captureStackTrace === 'function') {
19933 Error.captureStackTrace(this, TimeoutError);
19937 TimeoutError.prototype = Object.create(Error.prototype);
19938 TimeoutError.prototype.constructor = TimeoutError;
19940 return TimeoutError;
19942 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); }));
19943 },{}],258:[function(require,module,exports){
19944 /** @license MIT License (c) copyright 2010-2014 original author or authors */
19945 /** @author Brian Cavalier */
19946 /** @author John Hann */
19948 (function(define) { 'use strict';
19949 define(function() {
19951 makeApply.tryCatchResolve = tryCatchResolve;
19955 function makeApply(Promise, call) {
19956 if(arguments.length < 2) {
19957 call = tryCatchResolve;
19962 function apply(f, thisArg, args) {
19963 var p = Promise._defer();
19964 var l = args.length;
19965 var params = new Array(l);
19966 callAndResolve({ f:f, thisArg:thisArg, args:args, params:params, i:l-1, call:call }, p._handler);
19971 function callAndResolve(c, h) {
19973 return call(c.f, c.thisArg, c.params, h);
19976 var handler = Promise._handler(c.args[c.i]);
19977 handler.fold(callAndResolveNext, c, void 0, h);
19980 function callAndResolveNext(c, x, h) {
19983 callAndResolve(c, h);
19987 function tryCatchResolve(f, thisArg, args, resolver) {
19989 resolver.resolve(f.apply(thisArg, args));
19991 resolver.reject(e);
19996 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); }));
20000 },{}],259:[function(require,module,exports){
20001 /** @license MIT License (c) copyright 2010-2014 original author or authors */
20002 /** @author Brian Cavalier */
20003 /** @author John Hann */
20005 (function(define) { 'use strict';
20006 define(function(require) {
20008 var state = require('../state');
20009 var applier = require('../apply');
20011 return function array(Promise) {
20013 var applyFold = applier(Promise);
20014 var toPromise = Promise.resolve;
20015 var all = Promise.all;
20017 var ar = Array.prototype.reduce;
20018 var arr = Array.prototype.reduceRight;
20019 var slice = Array.prototype.slice;
20021 // Additional array combinators
20024 Promise.some = some;
20025 Promise.settle = settle;
20028 Promise.filter = filter;
20029 Promise.reduce = reduce;
20030 Promise.reduceRight = reduceRight;
20033 * When this promise fulfills with an array, do
20034 * onFulfilled.apply(void 0, array)
20035 * @param {function} onFulfilled function to apply
20036 * @returns {Promise} promise for the result of applying onFulfilled
20038 Promise.prototype.spread = function(onFulfilled) {
20039 return this.then(all).then(function(array) {
20040 return onFulfilled.apply(this, array);
20047 * One-winner competitive race.
20048 * Return a promise that will fulfill when one of the promises
20049 * in the input array fulfills, or will reject when all promises
20051 * @param {array} promises
20052 * @returns {Promise} promise for the first fulfilled value
20054 function any(promises) {
20055 var p = Promise._defer();
20056 var resolver = p._handler;
20057 var l = promises.length>>>0;
20062 for (var h, x, i = 0; i < l; ++i) {
20064 if(x === void 0 && !(i in promises)) {
20069 h = Promise._handler(x);
20070 if(h.state() > 0) {
20071 resolver.become(h);
20072 Promise._visitRemaining(promises, i, h);
20075 h.visit(resolver, handleFulfill, handleReject);
20079 if(pending === 0) {
20080 resolver.reject(new RangeError('any(): array must not be empty'));
20085 function handleFulfill(x) {
20086 /*jshint validthis:true*/
20088 this.resolve(x); // this === resolver
20091 function handleReject(e) {
20092 /*jshint validthis:true*/
20093 if(this.resolved) { // this === resolver
20098 if(--pending === 0) {
20099 this.reject(errors);
20105 * N-winner competitive race
20106 * Return a promise that will fulfill when n input promises have
20107 * fulfilled, or will reject when it becomes impossible for n
20108 * input promises to fulfill (ie when promises.length - n + 1
20110 * @param {array} promises
20111 * @param {number} n
20112 * @returns {Promise} promise for the earliest n fulfillment values
20116 function some(promises, n) {
20117 /*jshint maxcomplexity:7*/
20118 var p = Promise._defer();
20119 var resolver = p._handler;
20124 var l = promises.length>>>0;
20127 var x, i; // reused in both for() loops
20129 // First pass: count actual array items
20130 for(i=0; i<l; ++i) {
20132 if(x === void 0 && !(i in promises)) {
20138 // Compute actual goals
20139 n = Math.max(n, 0);
20140 nReject = (nFulfill - n + 1);
20141 nFulfill = Math.min(n, nFulfill);
20144 resolver.reject(new RangeError('some(): array must contain at least '
20145 + n + ' item(s), but had ' + nFulfill));
20146 } else if(nFulfill === 0) {
20147 resolver.resolve(results);
20150 // Second pass: observe each array item, make progress toward goals
20151 for(i=0; i<l; ++i) {
20153 if(x === void 0 && !(i in promises)) {
20157 Promise._handler(x).visit(resolver, fulfill, reject, resolver.notify);
20162 function fulfill(x) {
20163 /*jshint validthis:true*/
20164 if(this.resolved) { // this === resolver
20169 if(--nFulfill === 0) {
20171 this.resolve(results);
20175 function reject(e) {
20176 /*jshint validthis:true*/
20177 if(this.resolved) { // this === resolver
20182 if(--nReject === 0) {
20184 this.reject(errors);
20190 * Apply f to the value of each promise in a list of promises
20191 * and return a new list containing the results.
20192 * @param {array} promises
20193 * @param {function(x:*, index:Number):*} f mapping function
20194 * @returns {Promise}
20196 function map(promises, f) {
20197 return Promise._traverse(f, promises);
20201 * Filter the provided array of promises using the provided predicate. Input may
20202 * contain promises and values
20203 * @param {Array} promises array of promises and values
20204 * @param {function(x:*, index:Number):boolean} predicate filtering predicate.
20205 * Must return truthy (or promise for truthy) for items to retain.
20206 * @returns {Promise} promise that will fulfill with an array containing all items
20207 * for which predicate returned truthy.
20209 function filter(promises, predicate) {
20210 var a = slice.call(promises);
20211 return Promise._traverse(predicate, a).then(function(keep) {
20212 return filterSync(a, keep);
20216 function filterSync(promises, keep) {
20217 // Safe because we know all promises have fulfilled if we've made it this far
20218 var l = keep.length;
20219 var filtered = new Array(l);
20220 for(var i=0, j=0; i<l; ++i) {
20222 filtered[j++] = Promise._handler(promises[i]).value;
20225 filtered.length = j;
20231 * Return a promise that will always fulfill with an array containing
20232 * the outcome states of all input promises. The returned promise
20233 * will never reject.
20234 * @param {Array} promises
20235 * @returns {Promise} promise for array of settled state descriptors
20237 function settle(promises) {
20238 return all(promises.map(settleOne));
20241 function settleOne(p) {
20242 // Optimize the case where we get an already-resolved when.js promise
20243 // by extracting its state:
20245 if (p instanceof Promise) {
20246 // This is our own Promise type and we can reach its handler internals:
20247 handler = p._handler.join();
20249 if((handler && handler.state() === 0) || !handler) {
20250 // Either still pending, or not a Promise at all:
20251 return toPromise(p).then(state.fulfilled, state.rejected);
20254 // The promise is our own, but it is already resolved. Take a shortcut.
20255 // Since we're not actually handling the resolution, we need to disable
20256 // rejection reporting.
20257 handler._unreport();
20258 return state.inspect(handler);
20262 * Traditional reduce function, similar to `Array.prototype.reduce()`, but
20263 * input may contain promises and/or values, and reduceFunc
20264 * may return either a value or a promise, *and* initialValue may
20265 * be a promise for the starting value.
20266 * @param {Array|Promise} promises array or promise for an array of anything,
20267 * may contain a mix of promises and values.
20268 * @param {function(accumulated:*, x:*, index:Number):*} f reduce function
20269 * @returns {Promise} that will resolve to the final reduced value
20271 function reduce(promises, f /*, initialValue */) {
20272 return arguments.length > 2 ? ar.call(promises, liftCombine(f), arguments[2])
20273 : ar.call(promises, liftCombine(f));
20277 * Traditional reduce function, similar to `Array.prototype.reduceRight()`, but
20278 * input may contain promises and/or values, and reduceFunc
20279 * may return either a value or a promise, *and* initialValue may
20280 * be a promise for the starting value.
20281 * @param {Array|Promise} promises array or promise for an array of anything,
20282 * may contain a mix of promises and values.
20283 * @param {function(accumulated:*, x:*, index:Number):*} f reduce function
20284 * @returns {Promise} that will resolve to the final reduced value
20286 function reduceRight(promises, f /*, initialValue */) {
20287 return arguments.length > 2 ? arr.call(promises, liftCombine(f), arguments[2])
20288 : arr.call(promises, liftCombine(f));
20291 function liftCombine(f) {
20292 return function(z, x, i) {
20293 return applyFold(f, void 0, [z,x,i]);
20299 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(require); }));
20301 },{"../apply":258,"../state":271}],260:[function(require,module,exports){
20302 /** @license MIT License (c) copyright 2010-2014 original author or authors */
20303 /** @author Brian Cavalier */
20304 /** @author John Hann */
20306 (function(define) { 'use strict';
20307 define(function() {
20309 return function flow(Promise) {
20311 var resolve = Promise.resolve;
20312 var reject = Promise.reject;
20313 var origCatch = Promise.prototype['catch'];
20316 * Handle the ultimate fulfillment value or rejection reason, and assume
20317 * responsibility for all errors. If an error propagates out of result
20318 * or handleFatalError, it will be rethrown to the host, resulting in a
20319 * loud stack track on most platforms and a crash on some.
20320 * @param {function?} onResult
20321 * @param {function?} onError
20322 * @returns {undefined}
20324 Promise.prototype.done = function(onResult, onError) {
20325 this._handler.visit(this._handler.receiver, onResult, onError);
20329 * Add Error-type and predicate matching to catch. Examples:
20330 * promise.catch(TypeError, handleTypeError)
20331 * .catch(predicate, handleMatchedErrors)
20332 * .catch(handleRemainingErrors)
20333 * @param onRejected
20336 Promise.prototype['catch'] = Promise.prototype.otherwise = function(onRejected) {
20337 if (arguments.length < 2) {
20338 return origCatch.call(this, onRejected);
20341 if(typeof onRejected !== 'function') {
20342 return this.ensure(rejectInvalidPredicate);
20345 return origCatch.call(this, createCatchFilter(arguments[1], onRejected));
20349 * Wraps the provided catch handler, so that it will only be called
20350 * if the predicate evaluates truthy
20351 * @param {?function} handler
20352 * @param {function} predicate
20353 * @returns {function} conditional catch handler
20355 function createCatchFilter(handler, predicate) {
20356 return function(e) {
20357 return evaluatePredicate(e, predicate)
20358 ? handler.call(this, e)
20364 * Ensures that onFulfilledOrRejected will be called regardless of whether
20365 * this promise is fulfilled or rejected. onFulfilledOrRejected WILL NOT
20366 * receive the promises' value or reason. Any returned value will be disregarded.
20367 * onFulfilledOrRejected may throw or return a rejected promise to signal
20368 * an additional error.
20369 * @param {function} handler handler to be called regardless of
20370 * fulfillment or rejection
20371 * @returns {Promise}
20373 Promise.prototype['finally'] = Promise.prototype.ensure = function(handler) {
20374 if(typeof handler !== 'function') {
20378 return this.then(function(x) {
20379 return runSideEffect(handler, this, identity, x);
20381 return runSideEffect(handler, this, reject, e);
20385 function runSideEffect (handler, thisArg, propagate, value) {
20386 var result = handler.call(thisArg);
20387 return maybeThenable(result)
20388 ? propagateValue(result, propagate, value)
20389 : propagate(value);
20392 function propagateValue (result, propagate, x) {
20393 return resolve(result).then(function () {
20394 return propagate(x);
20399 * Recover from a failure by returning a defaultValue. If defaultValue
20400 * is a promise, it's fulfillment value will be used. If defaultValue is
20401 * a promise that rejects, the returned promise will reject with the
20403 * @param {*} defaultValue
20404 * @returns {Promise} new promise
20406 Promise.prototype['else'] = Promise.prototype.orElse = function(defaultValue) {
20407 return this.then(void 0, function() {
20408 return defaultValue;
20413 * Shortcut for .then(function() { return value; })
20415 * @return {Promise} a promise that:
20416 * - is fulfilled if value is not a promise, or
20417 * - if value is a promise, will fulfill with its value, or reject
20420 Promise.prototype['yield'] = function(value) {
20421 return this.then(function() {
20427 * Runs a side effect when this promise fulfills, without changing the
20428 * fulfillment value.
20429 * @param {function} onFulfilledSideEffect
20430 * @returns {Promise}
20432 Promise.prototype.tap = function(onFulfilledSideEffect) {
20433 return this.then(onFulfilledSideEffect)['yield'](this);
20439 function rejectInvalidPredicate() {
20440 throw new TypeError('catch predicate must be a function');
20443 function evaluatePredicate(e, predicate) {
20444 return isError(predicate) ? e instanceof predicate : predicate(e);
20447 function isError(predicate) {
20448 return predicate === Error
20449 || (predicate != null && predicate.prototype instanceof Error);
20452 function maybeThenable(x) {
20453 return (typeof x === 'object' || typeof x === 'function') && x !== null;
20456 function identity(x) {
20461 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); }));
20463 },{}],261:[function(require,module,exports){
20464 /** @license MIT License (c) copyright 2010-2014 original author or authors */
20465 /** @author Brian Cavalier */
20466 /** @author John Hann */
20467 /** @author Jeff Escalante */
20469 (function(define) { 'use strict';
20470 define(function() {
20472 return function fold(Promise) {
20474 Promise.prototype.fold = function(f, z) {
20475 var promise = this._beget();
20477 this._handler.fold(function(z, x, to) {
20478 Promise._handler(z).fold(function(x, z, to) {
20479 to.resolve(f.call(this, z, x));
20481 }, z, promise._handler.receiver, promise._handler);
20490 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); }));
20492 },{}],262:[function(require,module,exports){
20493 /** @license MIT License (c) copyright 2010-2014 original author or authors */
20494 /** @author Brian Cavalier */
20495 /** @author John Hann */
20497 (function(define) { 'use strict';
20498 define(function(require) {
20500 var inspect = require('../state').inspect;
20502 return function inspection(Promise) {
20504 Promise.prototype.inspect = function() {
20505 return inspect(Promise._handler(this));
20512 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(require); }));
20514 },{"../state":271}],263:[function(require,module,exports){
20515 /** @license MIT License (c) copyright 2010-2014 original author or authors */
20516 /** @author Brian Cavalier */
20517 /** @author John Hann */
20519 (function(define) { 'use strict';
20520 define(function() {
20522 return function generate(Promise) {
20524 var resolve = Promise.resolve;
20526 Promise.iterate = iterate;
20527 Promise.unfold = unfold;
20532 * @deprecated Use github.com/cujojs/most streams and most.iterate
20533 * Generate a (potentially infinite) stream of promised values:
20534 * x, f(x), f(f(x)), etc. until condition(x) returns true
20535 * @param {function} f function to generate a new x from the previous x
20536 * @param {function} condition function that, given the current x, returns
20537 * truthy when the iterate should stop
20538 * @param {function} handler function to handle the value produced by f
20539 * @param {*|Promise} x starting value, may be a promise
20540 * @return {Promise} the result of the last call to f before
20541 * condition returns true
20543 function iterate(f, condition, handler, x) {
20544 return unfold(function(x) {
20546 }, condition, handler, x);
20550 * @deprecated Use github.com/cujojs/most streams and most.unfold
20551 * Generate a (potentially infinite) stream of promised values
20552 * by applying handler(generator(seed)) iteratively until
20553 * condition(seed) returns true.
20554 * @param {function} unspool function that generates a [value, newSeed]
20556 * @param {function} condition function that, given the current seed, returns
20557 * truthy when the unfold should stop
20558 * @param {function} handler function to handle the value produced by unspool
20559 * @param x {*|Promise} starting value, may be a promise
20560 * @return {Promise} the result of the last value produced by unspool before
20561 * condition returns true
20563 function unfold(unspool, condition, handler, x) {
20564 return resolve(x).then(function(seed) {
20565 return resolve(condition(seed)).then(function(done) {
20566 return done ? seed : resolve(unspool(seed)).spread(next);
20570 function next(item, newSeed) {
20571 return resolve(handler(item)).then(function() {
20572 return unfold(unspool, condition, handler, newSeed);
20579 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); }));
20581 },{}],264:[function(require,module,exports){
20582 /** @license MIT License (c) copyright 2010-2014 original author or authors */
20583 /** @author Brian Cavalier */
20584 /** @author John Hann */
20586 (function(define) { 'use strict';
20587 define(function() {
20589 return function progress(Promise) {
20593 * Register a progress handler for this promise
20594 * @param {function} onProgress
20595 * @returns {Promise}
20597 Promise.prototype.progress = function(onProgress) {
20598 return this.then(void 0, void 0, onProgress);
20605 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); }));
20607 },{}],265:[function(require,module,exports){
20608 /** @license MIT License (c) copyright 2010-2014 original author or authors */
20609 /** @author Brian Cavalier */
20610 /** @author John Hann */
20612 (function(define) { 'use strict';
20613 define(function(require) {
20615 var env = require('../env');
20616 var TimeoutError = require('../TimeoutError');
20618 function setTimeout(f, ms, x, y) {
20619 return env.setTimer(function() {
20624 return function timed(Promise) {
20626 * Return a new promise whose fulfillment value is revealed only
20627 * after ms milliseconds
20628 * @param {number} ms milliseconds
20629 * @returns {Promise}
20631 Promise.prototype.delay = function(ms) {
20632 var p = this._beget();
20633 this._handler.fold(handleDelay, ms, void 0, p._handler);
20637 function handleDelay(ms, x, h) {
20638 setTimeout(resolveDelay, ms, x, h);
20641 function resolveDelay(x, h) {
20646 * Return a new promise that rejects after ms milliseconds unless
20647 * this promise fulfills earlier, in which case the returned promise
20648 * fulfills with the same value.
20649 * @param {number} ms milliseconds
20650 * @param {Error|*=} reason optional rejection reason to use, defaults
20651 * to a TimeoutError if not provided
20652 * @returns {Promise}
20654 Promise.prototype.timeout = function(ms, reason) {
20655 var p = this._beget();
20656 var h = p._handler;
20658 var t = setTimeout(onTimeout, ms, reason, p._handler);
20660 this._handler.visit(h,
20661 function onFulfill(x) {
20663 this.resolve(x); // this = h
20665 function onReject(x) {
20667 this.reject(x); // this = h
20674 function onTimeout(reason, h, ms) {
20675 var e = typeof reason === 'undefined'
20676 ? new TimeoutError('timed out after ' + ms + 'ms')
20685 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(require); }));
20687 },{"../TimeoutError":257,"../env":268}],266:[function(require,module,exports){
20688 /** @license MIT License (c) copyright 2010-2014 original author or authors */
20689 /** @author Brian Cavalier */
20690 /** @author John Hann */
20692 (function(define) { 'use strict';
20693 define(function(require) {
20695 var setTimer = require('../env').setTimer;
20696 var format = require('../format');
20698 return function unhandledRejection(Promise) {
20700 var logError = noop;
20701 var logInfo = noop;
20704 if(typeof console !== 'undefined') {
20705 // Alias console to prevent things like uglify's drop_console option from
20706 // removing console.log/error. Unhandled rejections fall into the same
20707 // category as uncaught exceptions, and build tools shouldn't silence them.
20708 localConsole = console;
20709 logError = typeof localConsole.error !== 'undefined'
20710 ? function (e) { localConsole.error(e); }
20711 : function (e) { localConsole.log(e); };
20713 logInfo = typeof localConsole.info !== 'undefined'
20714 ? function (e) { localConsole.info(e); }
20715 : function (e) { localConsole.log(e); };
20718 Promise.onPotentiallyUnhandledRejection = function(rejection) {
20719 enqueue(report, rejection);
20722 Promise.onPotentiallyUnhandledRejectionHandled = function(rejection) {
20723 enqueue(unreport, rejection);
20726 Promise.onFatalRejection = function(rejection) {
20727 enqueue(throwit, rejection.value);
20732 var running = null;
20734 function report(r) {
20737 logError('Potentially unhandled rejection [' + r.id + '] ' + format.formatError(r.value));
20741 function unreport(r) {
20742 var i = reported.indexOf(r);
20744 reported.splice(i, 1);
20745 logInfo('Handled previous rejection [' + r.id + '] ' + format.formatObject(r.value));
20749 function enqueue(f, x) {
20751 if(running === null) {
20752 running = setTimer(flush, 0);
20758 while(tasks.length > 0) {
20759 tasks.shift()(tasks.shift());
20766 function throwit(e) {
20773 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(require); }));
20775 },{"../env":268,"../format":269}],267:[function(require,module,exports){
20776 /** @license MIT License (c) copyright 2010-2014 original author or authors */
20777 /** @author Brian Cavalier */
20778 /** @author John Hann */
20780 (function(define) { 'use strict';
20781 define(function() {
20783 return function addWith(Promise) {
20785 * Returns a promise whose handlers will be called with `this` set to
20786 * the supplied receiver. Subsequent promises derived from the
20787 * returned promise will also have their handlers called with receiver
20788 * as `this`. Calling `with` with undefined or no arguments will return
20789 * a promise whose handlers will again be called in the usual Promises/A+
20790 * way (no `this`) thus safely undoing any previous `with` in the
20793 * WARNING: Promises returned from `with`/`withThis` are NOT Promises/A+
20794 * compliant, specifically violating 2.2.5 (http://promisesaplus.com/#point-41)
20796 * @param {object} receiver `this` value for all handlers attached to
20797 * the returned promise.
20798 * @returns {Promise}
20800 Promise.prototype['with'] = Promise.prototype.withThis = function(receiver) {
20801 var p = this._beget();
20802 var child = p._handler;
20803 child.receiver = receiver;
20804 this._handler.chain(child, receiver);
20812 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); }));
20815 },{}],268:[function(require,module,exports){
20816 (function (process){
20817 /** @license MIT License (c) copyright 2010-2014 original author or authors */
20818 /** @author Brian Cavalier */
20819 /** @author John Hann */
20821 /*global process,document,setTimeout,clearTimeout,MutationObserver,WebKitMutationObserver*/
20822 (function(define) { 'use strict';
20823 define(function(require) {
20824 /*jshint maxcomplexity:6*/
20826 // Sniff "best" async scheduling option
20827 // Prefer process.nextTick or MutationObserver, then check for
20828 // setTimeout, and finally vertx, since its the only env that doesn't
20832 var capturedSetTimeout = typeof setTimeout !== 'undefined' && setTimeout;
20835 var setTimer = function(f, ms) { return setTimeout(f, ms); };
20836 var clearTimer = function(t) { return clearTimeout(t); };
20837 var asap = function (f) { return capturedSetTimeout(f, 0); };
20839 // Detect specific env
20840 if (isNode()) { // Node
20841 asap = function (f) { return process.nextTick(f); };
20843 } else if (MutationObs = hasMutationObserver()) { // Modern browser
20844 asap = initMutationObserver(MutationObs);
20846 } else if (!capturedSetTimeout) { // vert.x
20847 var vertxRequire = require;
20848 var vertx = vertxRequire('vertx');
20849 setTimer = function (f, ms) { return vertx.setTimer(ms, f); };
20850 clearTimer = vertx.cancelTimer;
20851 asap = vertx.runOnLoop || vertx.runOnContext;
20855 setTimer: setTimer,
20856 clearTimer: clearTimer,
20860 function isNode () {
20861 return typeof process !== 'undefined' &&
20862 Object.prototype.toString.call(process) === '[object process]';
20865 function hasMutationObserver () {
20866 return (typeof MutationObserver !== 'undefined' && MutationObserver) ||
20867 (typeof WebKitMutationObserver !== 'undefined' && WebKitMutationObserver);
20870 function initMutationObserver(MutationObserver) {
20872 var node = document.createTextNode('');
20873 var o = new MutationObserver(run);
20874 o.observe(node, { characterData: true });
20878 scheduled = void 0;
20883 return function (f) {
20885 node.data = (i ^= 1);
20889 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(require); }));
20891 }).call(this,require('_process'))
20893 },{"_process":6}],269:[function(require,module,exports){
20894 /** @license MIT License (c) copyright 2010-2014 original author or authors */
20895 /** @author Brian Cavalier */
20896 /** @author John Hann */
20898 (function(define) { 'use strict';
20899 define(function() {
20902 formatError: formatError,
20903 formatObject: formatObject,
20904 tryStringify: tryStringify
20908 * Format an error into a string. If e is an Error and has a stack property,
20909 * it's returned. Otherwise, e is formatted using formatObject, with a
20910 * warning added about e not being a proper Error.
20912 * @returns {String} formatted string, suitable for output to developers
20914 function formatError(e) {
20915 var s = typeof e === 'object' && e !== null && (e.stack || e.message) ? e.stack || e.message : formatObject(e);
20916 return e instanceof Error ? s : s + ' (WARNING: non-Error used)';
20920 * Format an object, detecting "plain" objects and running them through
20921 * JSON.stringify if possible.
20922 * @param {Object} o
20923 * @returns {string}
20925 function formatObject(o) {
20927 if(s === '[object Object]' && typeof JSON !== 'undefined') {
20928 s = tryStringify(o, s);
20934 * Try to return the result of JSON.stringify(x). If that fails, return
20937 * @param {*} defaultValue
20938 * @returns {String|*} JSON.stringify(x) or defaultValue
20940 function tryStringify(x, defaultValue) {
20942 return JSON.stringify(x);
20944 return defaultValue;
20949 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); }));
20951 },{}],270:[function(require,module,exports){
20952 (function (process){
20953 /** @license MIT License (c) copyright 2010-2014 original author or authors */
20954 /** @author Brian Cavalier */
20955 /** @author John Hann */
20957 (function(define) { 'use strict';
20958 define(function() {
20960 return function makePromise(environment) {
20962 var tasks = environment.scheduler;
20963 var emitRejection = initEmitRejection();
20965 var objectCreate = Object.create ||
20967 function Child() {}
20968 Child.prototype = proto;
20969 return new Child();
20973 * Create a promise whose fate is determined by resolver
20975 * @returns {Promise} promise
20978 function Promise(resolver, handler) {
20979 this._handler = resolver === Handler ? handler : init(resolver);
20983 * Run the supplied resolver
20985 * @returns {Pending}
20987 function init(resolver) {
20988 var handler = new Pending();
20991 resolver(promiseResolve, promiseReject, promiseNotify);
20999 * Transition from pre-resolution state to post-resolution state, notifying
21000 * all listeners of the ultimate fulfillment or rejection
21001 * @param {*} x resolution value
21003 function promiseResolve (x) {
21004 handler.resolve(x);
21007 * Reject this promise with reason, which will be used verbatim
21008 * @param {Error|*} reason rejection reason, strongly suggested
21009 * to be an Error type
21011 function promiseReject (reason) {
21012 handler.reject(reason);
21017 * Issue a progress event, notifying all progress listeners
21018 * @param {*} x progress event payload to pass to all listeners
21020 function promiseNotify (x) {
21027 Promise.resolve = resolve;
21028 Promise.reject = reject;
21029 Promise.never = never;
21031 Promise._defer = defer;
21032 Promise._handler = getHandler;
21035 * Returns a trusted promise. If x is already a trusted promise, it is
21036 * returned, otherwise returns a new trusted Promise which follows x.
21038 * @return {Promise} promise
21040 function resolve(x) {
21041 return isPromise(x) ? x
21042 : new Promise(Handler, new Async(getHandler(x)));
21046 * Return a reject promise with x as its reason (x is used verbatim)
21048 * @returns {Promise} rejected promise
21050 function reject(x) {
21051 return new Promise(Handler, new Async(new Rejected(x)));
21055 * Return a promise that remains pending forever
21056 * @returns {Promise} forever-pending promise.
21059 return foreverPendingPromise; // Should be frozen
21063 * Creates an internal {promise, resolver} pair
21065 * @returns {Promise}
21068 return new Promise(Handler, new Pending());
21071 // Transformation and flow control
21074 * Transform this promise's fulfillment value, returning a new Promise
21075 * for the transformed result. If the promise cannot be fulfilled, onRejected
21076 * is called with the reason. onProgress *may* be called with updates toward
21077 * this promise's fulfillment.
21078 * @param {function=} onFulfilled fulfillment handler
21079 * @param {function=} onRejected rejection handler
21080 * @param {function=} onProgress @deprecated progress handler
21081 * @return {Promise} new promise
21083 Promise.prototype.then = function(onFulfilled, onRejected, onProgress) {
21084 var parent = this._handler;
21085 var state = parent.join().state();
21087 if ((typeof onFulfilled !== 'function' && state > 0) ||
21088 (typeof onRejected !== 'function' && state < 0)) {
21089 // Short circuit: value will not change, simply share handler
21090 return new this.constructor(Handler, parent);
21093 var p = this._beget();
21094 var child = p._handler;
21096 parent.chain(child, parent.receiver, onFulfilled, onRejected, onProgress);
21102 * If this promise cannot be fulfilled due to an error, call onRejected to
21103 * handle the error. Shortcut for .then(undefined, onRejected)
21104 * @param {function?} onRejected
21105 * @return {Promise}
21107 Promise.prototype['catch'] = function(onRejected) {
21108 return this.then(void 0, onRejected);
21112 * Creates a new, pending promise of the same type as this promise
21114 * @returns {Promise}
21116 Promise.prototype._beget = function() {
21117 return begetFrom(this._handler, this.constructor);
21120 function begetFrom(parent, Promise) {
21121 var child = new Pending(parent.receiver, parent.join().context);
21122 return new Promise(Handler, child);
21125 // Array combinators
21128 Promise.race = race;
21129 Promise._traverse = traverse;
21132 * Return a promise that will fulfill when all promises in the
21133 * input array have fulfilled, or will reject when one of the
21134 * promises rejects.
21135 * @param {array} promises array of promises
21136 * @returns {Promise} promise for array of fulfillment values
21138 function all(promises) {
21139 return traverseWith(snd, null, promises);
21143 * Array<Promise<X>> -> Promise<Array<f(X)>>
21145 * @param {function} f function to apply to each promise's value
21146 * @param {Array} promises array of promises
21147 * @returns {Promise} promise for transformed values
21149 function traverse(f, promises) {
21150 return traverseWith(tryCatch2, f, promises);
21153 function traverseWith(tryMap, f, promises) {
21154 var handler = typeof f === 'function' ? mapAt : settleAt;
21156 var resolver = new Pending();
21157 var pending = promises.length >>> 0;
21158 var results = new Array(pending);
21160 for (var i = 0, x; i < promises.length && !resolver.resolved; ++i) {
21163 if (x === void 0 && !(i in promises)) {
21168 traverseAt(promises, handler, i, x, resolver);
21171 if(pending === 0) {
21172 resolver.become(new Fulfilled(results));
21175 return new Promise(Handler, resolver);
21177 function mapAt(i, x, resolver) {
21178 if(!resolver.resolved) {
21179 traverseAt(promises, settleAt, i, tryMap(f, x, i), resolver);
21183 function settleAt(i, x, resolver) {
21185 if(--pending === 0) {
21186 resolver.become(new Fulfilled(results));
21191 function traverseAt(promises, handler, i, x, resolver) {
21192 if (maybeThenable(x)) {
21193 var h = getHandlerMaybeThenable(x);
21197 h.fold(handler, i, void 0, resolver);
21198 } else if (s > 0) {
21199 handler(i, h.value, resolver);
21201 resolver.become(h);
21202 visitRemaining(promises, i+1, h);
21205 handler(i, x, resolver);
21209 Promise._visitRemaining = visitRemaining;
21210 function visitRemaining(promises, start, handler) {
21211 for(var i=start; i<promises.length; ++i) {
21212 markAsHandled(getHandler(promises[i]), handler);
21216 function markAsHandled(h, handler) {
21217 if(h === handler) {
21223 h.visit(h, void 0, h._unreport);
21230 * Fulfill-reject competitive race. Return a promise that will settle
21231 * to the same state as the earliest input promise to settle.
21233 * WARNING: The ES6 Promise spec requires that race()ing an empty array
21234 * must return a promise that is pending forever. This implementation
21235 * returns a singleton forever-pending promise, the same singleton that is
21236 * returned by Promise.never(), thus can be checked with ===
21238 * @param {array} promises array of promises to race
21239 * @returns {Promise} if input is non-empty, a promise that will settle
21240 * to the same outcome as the earliest input promise to settle. if empty
21241 * is empty, returns a promise that will never settle.
21243 function race(promises) {
21244 if(typeof promises !== 'object' || promises === null) {
21245 return reject(new TypeError('non-iterable passed to race()'));
21248 // Sigh, race([]) is untestable unless we return *something*
21249 // that is recognizable without calling .then() on it.
21250 return promises.length === 0 ? never()
21251 : promises.length === 1 ? resolve(promises[0])
21252 : runRace(promises);
21255 function runRace(promises) {
21256 var resolver = new Pending();
21258 for(i=0; i<promises.length; ++i) {
21260 if (x === void 0 && !(i in promises)) {
21265 if(h.state() !== 0) {
21266 resolver.become(h);
21267 visitRemaining(promises, i+1, h);
21270 h.visit(resolver, resolver.resolve, resolver.reject);
21273 return new Promise(Handler, resolver);
21276 // Promise internals
21277 // Below this, everything is @private
21280 * Get an appropriate handler for x, without checking for cycles
21282 * @returns {object} handler
21284 function getHandler(x) {
21286 return x._handler.join();
21288 return maybeThenable(x) ? getHandlerUntrusted(x) : new Fulfilled(x);
21292 * Get a handler for thenable x.
21293 * NOTE: You must only call this if maybeThenable(x) == true
21294 * @param {object|function|Promise} x
21295 * @returns {object} handler
21297 function getHandlerMaybeThenable(x) {
21298 return isPromise(x) ? x._handler.join() : getHandlerUntrusted(x);
21302 * Get a handler for potentially untrusted thenable x
21304 * @returns {object} handler
21306 function getHandlerUntrusted(x) {
21308 var untrustedThen = x.then;
21309 return typeof untrustedThen === 'function'
21310 ? new Thenable(untrustedThen, x)
21311 : new Fulfilled(x);
21313 return new Rejected(e);
21318 * Handler for a promise that is pending forever
21321 function Handler() {}
21323 Handler.prototype.when
21324 = Handler.prototype.become
21325 = Handler.prototype.notify // deprecated
21326 = Handler.prototype.fail
21327 = Handler.prototype._unreport
21328 = Handler.prototype._report
21331 Handler.prototype._state = 0;
21333 Handler.prototype.state = function() {
21334 return this._state;
21338 * Recursively collapse handler chain to find the handler
21339 * nearest to the fully resolved value.
21340 * @returns {object} handler nearest the fully resolved value
21342 Handler.prototype.join = function() {
21344 while(h.handler !== void 0) {
21350 Handler.prototype.chain = function(to, receiver, fulfilled, rejected, progress) {
21353 receiver: receiver,
21354 fulfilled: fulfilled,
21355 rejected: rejected,
21360 Handler.prototype.visit = function(receiver, fulfilled, rejected, progress) {
21361 this.chain(failIfRejected, receiver, fulfilled, rejected, progress);
21364 Handler.prototype.fold = function(f, z, c, to) {
21365 this.when(new Fold(f, z, c, to));
21369 * Handler that invokes fail() on any handler it becomes
21372 function FailIfRejected() {}
21374 inherit(Handler, FailIfRejected);
21376 FailIfRejected.prototype.become = function(h) {
21380 var failIfRejected = new FailIfRejected();
21383 * Handler that manages a queue of consumers waiting on a pending promise
21386 function Pending(receiver, inheritedContext) {
21387 Promise.createContext(this, inheritedContext);
21389 this.consumers = void 0;
21390 this.receiver = receiver;
21391 this.handler = void 0;
21392 this.resolved = false;
21395 inherit(Handler, Pending);
21397 Pending.prototype._state = 0;
21399 Pending.prototype.resolve = function(x) {
21400 this.become(getHandler(x));
21403 Pending.prototype.reject = function(x) {
21404 if(this.resolved) {
21408 this.become(new Rejected(x));
21411 Pending.prototype.join = function() {
21412 if (!this.resolved) {
21418 while (h.handler !== void 0) {
21421 return this.handler = cycle();
21428 Pending.prototype.run = function() {
21429 var q = this.consumers;
21430 var handler = this.handler;
21431 this.handler = this.handler.join();
21432 this.consumers = void 0;
21434 for (var i = 0; i < q.length; ++i) {
21435 handler.when(q[i]);
21439 Pending.prototype.become = function(handler) {
21440 if(this.resolved) {
21444 this.resolved = true;
21445 this.handler = handler;
21446 if(this.consumers !== void 0) {
21447 tasks.enqueue(this);
21450 if(this.context !== void 0) {
21451 handler._report(this.context);
21455 Pending.prototype.when = function(continuation) {
21456 if(this.resolved) {
21457 tasks.enqueue(new ContinuationTask(continuation, this.handler));
21459 if(this.consumers === void 0) {
21460 this.consumers = [continuation];
21462 this.consumers.push(continuation);
21470 Pending.prototype.notify = function(x) {
21471 if(!this.resolved) {
21472 tasks.enqueue(new ProgressTask(x, this));
21476 Pending.prototype.fail = function(context) {
21477 var c = typeof context === 'undefined' ? this.context : context;
21478 this.resolved && this.handler.join().fail(c);
21481 Pending.prototype._report = function(context) {
21482 this.resolved && this.handler.join()._report(context);
21485 Pending.prototype._unreport = function() {
21486 this.resolved && this.handler.join()._unreport();
21490 * Wrap another handler and force it into a future stack
21491 * @param {object} handler
21494 function Async(handler) {
21495 this.handler = handler;
21498 inherit(Handler, Async);
21500 Async.prototype.when = function(continuation) {
21501 tasks.enqueue(new ContinuationTask(continuation, this));
21504 Async.prototype._report = function(context) {
21505 this.join()._report(context);
21508 Async.prototype._unreport = function() {
21509 this.join()._unreport();
21513 * Handler that wraps an untrusted thenable and assimilates it in a future stack
21514 * @param {function} then
21515 * @param {{then: function}} thenable
21518 function Thenable(then, thenable) {
21519 Pending.call(this);
21520 tasks.enqueue(new AssimilateTask(then, thenable, this));
21523 inherit(Pending, Thenable);
21526 * Handler for a fulfilled promise
21527 * @param {*} x fulfillment value
21530 function Fulfilled(x) {
21531 Promise.createContext(this);
21535 inherit(Handler, Fulfilled);
21537 Fulfilled.prototype._state = 1;
21539 Fulfilled.prototype.fold = function(f, z, c, to) {
21540 runContinuation3(f, z, this, c, to);
21543 Fulfilled.prototype.when = function(cont) {
21544 runContinuation1(cont.fulfilled, this, cont.receiver, cont.resolver);
21550 * Handler for a rejected promise
21551 * @param {*} x rejection reason
21554 function Rejected(x) {
21555 Promise.createContext(this);
21557 this.id = ++errorId;
21559 this.handled = false;
21560 this.reported = false;
21565 inherit(Handler, Rejected);
21567 Rejected.prototype._state = -1;
21569 Rejected.prototype.fold = function(f, z, c, to) {
21573 Rejected.prototype.when = function(cont) {
21574 if(typeof cont.rejected === 'function') {
21577 runContinuation1(cont.rejected, this, cont.receiver, cont.resolver);
21580 Rejected.prototype._report = function(context) {
21581 tasks.afterQueue(new ReportTask(this, context));
21584 Rejected.prototype._unreport = function() {
21588 this.handled = true;
21589 tasks.afterQueue(new UnreportTask(this));
21592 Rejected.prototype.fail = function(context) {
21593 this.reported = true;
21594 emitRejection('unhandledRejection', this);
21595 Promise.onFatalRejection(this, context === void 0 ? this.context : context);
21598 function ReportTask(rejection, context) {
21599 this.rejection = rejection;
21600 this.context = context;
21603 ReportTask.prototype.run = function() {
21604 if(!this.rejection.handled && !this.rejection.reported) {
21605 this.rejection.reported = true;
21606 emitRejection('unhandledRejection', this.rejection) ||
21607 Promise.onPotentiallyUnhandledRejection(this.rejection, this.context);
21611 function UnreportTask(rejection) {
21612 this.rejection = rejection;
21615 UnreportTask.prototype.run = function() {
21616 if(this.rejection.reported) {
21617 emitRejection('rejectionHandled', this.rejection) ||
21618 Promise.onPotentiallyUnhandledRejectionHandled(this.rejection);
21622 // Unhandled rejection hooks
21623 // By default, everything is a noop
21625 Promise.createContext
21626 = Promise.enterContext
21627 = Promise.exitContext
21628 = Promise.onPotentiallyUnhandledRejection
21629 = Promise.onPotentiallyUnhandledRejectionHandled
21630 = Promise.onFatalRejection
21633 // Errors and singletons
21635 var foreverPendingHandler = new Handler();
21636 var foreverPendingPromise = new Promise(Handler, foreverPendingHandler);
21639 return new Rejected(new TypeError('Promise cycle'));
21645 * Run a single consumer
21648 function ContinuationTask(continuation, handler) {
21649 this.continuation = continuation;
21650 this.handler = handler;
21653 ContinuationTask.prototype.run = function() {
21654 this.handler.join().when(this.continuation);
21658 * Run a queue of progress handlers
21661 function ProgressTask(value, handler) {
21662 this.handler = handler;
21663 this.value = value;
21666 ProgressTask.prototype.run = function() {
21667 var q = this.handler.consumers;
21672 for (var c, i = 0; i < q.length; ++i) {
21674 runNotify(c.progress, this.value, this.handler, c.receiver, c.resolver);
21679 * Assimilate a thenable, sending it's value to resolver
21680 * @param {function} then
21681 * @param {object|function} thenable
21682 * @param {object} resolver
21685 function AssimilateTask(then, thenable, resolver) {
21687 this.thenable = thenable;
21688 this.resolver = resolver;
21691 AssimilateTask.prototype.run = function() {
21692 var h = this.resolver;
21693 tryAssimilate(this._then, this.thenable, _resolve, _reject, _notify);
21695 function _resolve(x) { h.resolve(x); }
21696 function _reject(x) { h.reject(x); }
21697 function _notify(x) { h.notify(x); }
21700 function tryAssimilate(then, thenable, resolve, reject, notify) {
21702 then.call(thenable, resolve, reject, notify);
21709 * Fold a handler value with z
21712 function Fold(f, z, c, to) {
21713 this.f = f; this.z = z; this.c = c; this.to = to;
21714 this.resolver = failIfRejected;
21715 this.receiver = this;
21718 Fold.prototype.fulfilled = function(x) {
21719 this.f.call(this.c, this.z, x, this.to);
21722 Fold.prototype.rejected = function(x) {
21726 Fold.prototype.progress = function(x) {
21734 * @returns {boolean} true iff x is a trusted Promise
21736 function isPromise(x) {
21737 return x instanceof Promise;
21741 * Test just enough to rule out primitives, in order to take faster
21742 * paths in some code
21744 * @returns {boolean} false iff x is guaranteed *not* to be a thenable
21746 function maybeThenable(x) {
21747 return (typeof x === 'object' || typeof x === 'function') && x !== null;
21750 function runContinuation1(f, h, receiver, next) {
21751 if(typeof f !== 'function') {
21752 return next.become(h);
21755 Promise.enterContext(h);
21756 tryCatchReject(f, h.value, receiver, next);
21757 Promise.exitContext();
21760 function runContinuation3(f, x, h, receiver, next) {
21761 if(typeof f !== 'function') {
21762 return next.become(h);
21765 Promise.enterContext(h);
21766 tryCatchReject3(f, x, h.value, receiver, next);
21767 Promise.exitContext();
21773 function runNotify(f, x, h, receiver, next) {
21774 if(typeof f !== 'function') {
21775 return next.notify(x);
21778 Promise.enterContext(h);
21779 tryCatchReturn(f, x, receiver, next);
21780 Promise.exitContext();
21783 function tryCatch2(f, a, b) {
21792 * Return f.call(thisArg, x), or if it throws return a rejected promise for
21793 * the thrown exception
21795 function tryCatchReject(f, x, thisArg, next) {
21797 next.become(getHandler(f.call(thisArg, x)));
21799 next.become(new Rejected(e));
21804 * Same as above, but includes the extra argument parameter.
21806 function tryCatchReject3(f, x, y, thisArg, next) {
21808 f.call(thisArg, x, y, next);
21810 next.become(new Rejected(e));
21816 * Return f.call(thisArg, x), or if it throws, *return* the exception
21818 function tryCatchReturn(f, x, thisArg, next) {
21820 next.notify(f.call(thisArg, x));
21826 function inherit(Parent, Child) {
21827 Child.prototype = objectCreate(Parent.prototype);
21828 Child.prototype.constructor = Child;
21831 function snd(x, y) {
21837 function hasCustomEvent() {
21838 if(typeof CustomEvent === 'function') {
21840 var ev = new CustomEvent('unhandledRejection');
21841 return ev instanceof CustomEvent;
21842 } catch (ignoredException) {}
21847 function hasInternetExplorerCustomEvent() {
21848 if(typeof document !== 'undefined' && typeof document.createEvent === 'function') {
21850 // Try to create one event to make sure it's supported
21851 var ev = document.createEvent('CustomEvent');
21852 ev.initCustomEvent('eventType', false, true, {});
21854 } catch (ignoredException) {}
21859 function initEmitRejection() {
21860 /*global process, self, CustomEvent*/
21861 if(typeof process !== 'undefined' && process !== null
21862 && typeof process.emit === 'function') {
21863 // Returning falsy here means to call the default
21864 // onPotentiallyUnhandledRejection API. This is safe even in
21865 // browserify since process.emit always returns falsy in browserify:
21866 // https://github.com/defunctzombie/node-process/blob/master/browser.js#L40-L46
21867 return function(type, rejection) {
21868 return type === 'unhandledRejection'
21869 ? process.emit(type, rejection.value, rejection)
21870 : process.emit(type, rejection);
21872 } else if(typeof self !== 'undefined' && hasCustomEvent()) {
21873 return (function (self, CustomEvent) {
21874 return function (type, rejection) {
21875 var ev = new CustomEvent(type, {
21877 reason: rejection.value,
21884 return !self.dispatchEvent(ev);
21886 }(self, CustomEvent));
21887 } else if(typeof self !== 'undefined' && hasInternetExplorerCustomEvent()) {
21888 return (function(self, document) {
21889 return function(type, rejection) {
21890 var ev = document.createEvent('CustomEvent');
21891 ev.initCustomEvent(type, false, true, {
21892 reason: rejection.value,
21896 return !self.dispatchEvent(ev);
21898 }(self, document));
21907 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); }));
21909 }).call(this,require('_process'))
21911 },{"_process":6}],271:[function(require,module,exports){
21912 /** @license MIT License (c) copyright 2010-2014 original author or authors */
21913 /** @author Brian Cavalier */
21914 /** @author John Hann */
21916 (function(define) { 'use strict';
21917 define(function() {
21920 pending: toPendingState,
21921 fulfilled: toFulfilledState,
21922 rejected: toRejectedState,
21926 function toPendingState() {
21927 return { state: 'pending' };
21930 function toRejectedState(e) {
21931 return { state: 'rejected', reason: e };
21934 function toFulfilledState(x) {
21935 return { state: 'fulfilled', value: x };
21938 function inspect(handler) {
21939 var state = handler.state();
21940 return state === 0 ? toPendingState()
21941 : state > 0 ? toFulfilledState(handler.value)
21942 : toRejectedState(handler.value);
21946 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); }));
21948 },{}],272:[function(require,module,exports){
21949 /** @license MIT License (c) copyright 2010-2014 original author or authors */
21952 * Promises/A+ and when() implementation
21953 * when is part of the cujoJS family of libraries (http://cujojs.com/)
21954 * @author Brian Cavalier
21955 * @author John Hann
21957 (function(define) { 'use strict';
21958 define(function (require) {
21960 var timed = require('./lib/decorators/timed');
21961 var array = require('./lib/decorators/array');
21962 var flow = require('./lib/decorators/flow');
21963 var fold = require('./lib/decorators/fold');
21964 var inspect = require('./lib/decorators/inspect');
21965 var generate = require('./lib/decorators/iterate');
21966 var progress = require('./lib/decorators/progress');
21967 var withThis = require('./lib/decorators/with');
21968 var unhandledRejection = require('./lib/decorators/unhandledRejection');
21969 var TimeoutError = require('./lib/TimeoutError');
21971 var Promise = [array, flow, fold, generate, progress,
21972 inspect, withThis, timed, unhandledRejection]
21973 .reduce(function(Promise, feature) {
21974 return feature(Promise);
21975 }, require('./lib/Promise'));
21977 var apply = require('./lib/apply')(Promise);
21981 when.promise = promise; // Create a pending promise
21982 when.resolve = Promise.resolve; // Create a resolved promise
21983 when.reject = Promise.reject; // Create a rejected promise
21985 when.lift = lift; // lift a function to return promises
21986 when['try'] = attempt; // call a function and return a promise
21987 when.attempt = attempt; // alias for when.try
21989 when.iterate = Promise.iterate; // DEPRECATED (use cujojs/most streams) Generate a stream of promises
21990 when.unfold = Promise.unfold; // DEPRECATED (use cujojs/most streams) Generate a stream of promises
21992 when.join = join; // Join 2 or more promises
21994 when.all = all; // Resolve a list of promises
21995 when.settle = settle; // Settle a list of promises
21997 when.any = lift(Promise.any); // One-winner race
21998 when.some = lift(Promise.some); // Multi-winner race
21999 when.race = lift(Promise.race); // First-to-settle race
22001 when.map = map; // Array.map() for promises
22002 when.filter = filter; // Array.filter() for promises
22003 when.reduce = lift(Promise.reduce); // Array.reduce() for promises
22004 when.reduceRight = lift(Promise.reduceRight); // Array.reduceRight() for promises
22006 when.isPromiseLike = isPromiseLike; // Is something promise-like, aka thenable
22008 when.Promise = Promise; // Promise constructor
22009 when.defer = defer; // Create a {promise, resolve, reject} tuple
22013 when.TimeoutError = TimeoutError;
22016 * Get a trusted promise for x, or by transforming x with onFulfilled
22019 * @param {function?} onFulfilled callback to be called when x is
22020 * successfully fulfilled. If promiseOrValue is an immediate value, callback
22021 * will be invoked immediately.
22022 * @param {function?} onRejected callback to be called when x is
22024 * @param {function?} onProgress callback to be called when progress updates
22025 * are issued for x. @deprecated
22026 * @returns {Promise} a new promise that will fulfill with the return
22027 * value of callback or errback or the completion value of promiseOrValue if
22028 * callback and/or errback is not supplied.
22030 function when(x, onFulfilled, onRejected, onProgress) {
22031 var p = Promise.resolve(x);
22032 if (arguments.length < 2) {
22036 return p.then(onFulfilled, onRejected, onProgress);
22040 * Creates a new promise whose fate is determined by resolver.
22041 * @param {function} resolver function(resolve, reject, notify)
22042 * @returns {Promise} promise whose fate is determine by resolver
22044 function promise(resolver) {
22045 return new Promise(resolver);
22049 * Lift the supplied function, creating a version of f that returns
22050 * promises, and accepts promises as arguments.
22051 * @param {function} f
22052 * @returns {Function} version of f that returns promises
22055 return function() {
22056 for(var i=0, l=arguments.length, a=new Array(l); i<l; ++i) {
22057 a[i] = arguments[i];
22059 return apply(f, this, a);
22064 * Call f in a future turn, with the supplied args, and return a promise
22066 * @param {function} f
22067 * @returns {Promise}
22069 function attempt(f /*, args... */) {
22070 /*jshint validthis:true */
22071 for(var i=0, l=arguments.length-1, a=new Array(l); i<l; ++i) {
22072 a[i] = arguments[i+1];
22074 return apply(f, this, a);
22078 * Creates a {promise, resolver} pair, either or both of which
22079 * may be given out safely to consumers.
22080 * @return {{promise: Promise, resolve: function, reject: function, notify: function}}
22083 return new Deferred();
22086 function Deferred() {
22087 var p = Promise._defer();
22089 function resolve(x) { p._handler.resolve(x); }
22090 function reject(x) { p._handler.reject(x); }
22091 function notify(x) { p._handler.notify(x); }
22094 this.resolve = resolve;
22095 this.reject = reject;
22096 this.notify = notify;
22097 this.resolver = { resolve: resolve, reject: reject, notify: notify };
22101 * Determines if x is promise-like, i.e. a thenable object
22102 * NOTE: Will return true for *any thenable object*, and isn't truly
22103 * safe, since it may attempt to access the `then` property of x (i.e.
22104 * clever/malicious getters may do weird things)
22105 * @param {*} x anything
22106 * @returns {boolean} true if x is promise-like
22108 function isPromiseLike(x) {
22109 return x && typeof x.then === 'function';
22113 * Return a promise that will resolve only once all the supplied arguments
22114 * have resolved. The resolution value of the returned promise will be an array
22115 * containing the resolution values of each of the arguments.
22116 * @param {...*} arguments may be a mix of promises and values
22117 * @returns {Promise}
22119 function join(/* ...promises */) {
22120 return Promise.all(arguments);
22124 * Return a promise that will fulfill once all input promises have
22125 * fulfilled, or reject when any one input promise rejects.
22126 * @param {array|Promise} promises array (or promise for an array) of promises
22127 * @returns {Promise}
22129 function all(promises) {
22130 return when(promises, Promise.all);
22134 * Return a promise that will always fulfill with an array containing
22135 * the outcome states of all input promises. The returned promise
22136 * will only reject if `promises` itself is a rejected promise.
22137 * @param {array|Promise} promises array (or promise for an array) of promises
22138 * @returns {Promise} promise for array of settled state descriptors
22140 function settle(promises) {
22141 return when(promises, Promise.settle);
22145 * Promise-aware array map function, similar to `Array.prototype.map()`,
22146 * but input array may contain promises or values.
22147 * @param {Array|Promise} promises array of anything, may contain promises and values
22148 * @param {function(x:*, index:Number):*} mapFunc map function which may
22149 * return a promise or value
22150 * @returns {Promise} promise that will fulfill with an array of mapped values
22151 * or reject if any input promise rejects.
22153 function map(promises, mapFunc) {
22154 return when(promises, function(promises) {
22155 return Promise.map(promises, mapFunc);
22160 * Filter the provided array of promises using the provided predicate. Input may
22161 * contain promises and values
22162 * @param {Array|Promise} promises array of promises and values
22163 * @param {function(x:*, index:Number):boolean} predicate filtering predicate.
22164 * Must return truthy (or promise for truthy) for items to retain.
22165 * @returns {Promise} promise that will fulfill with an array containing all items
22166 * for which predicate returned truthy.
22168 function filter(promises, predicate) {
22169 return when(promises, function(promises) {
22170 return Promise.filter(promises, predicate);
22176 })(typeof define === 'function' && define.amd ? define : function (factory) { module.exports = factory(require); });
22178 },{"./lib/Promise":255,"./lib/TimeoutError":257,"./lib/apply":258,"./lib/decorators/array":259,"./lib/decorators/flow":260,"./lib/decorators/fold":261,"./lib/decorators/inspect":262,"./lib/decorators/iterate":263,"./lib/decorators/progress":264,"./lib/decorators/timed":265,"./lib/decorators/unhandledRejection":266,"./lib/decorators/with":267}],273:[function(require,module,exports){
22179 var nativeIsArray = Array.isArray
22180 var toString = Object.prototype.toString
22182 module.exports = nativeIsArray || isArray
22184 function isArray(obj) {
22185 return toString.call(obj) === "[object Array]"
22188 },{}],274:[function(require,module,exports){
22190 Object.defineProperty(exports, "__esModule", { value: true });
22191 var APIv3_1 = require("./api/APIv3");
22192 exports.APIv3 = APIv3_1.APIv3;
22193 var ModelCreator_1 = require("./api/ModelCreator");
22194 exports.ModelCreator = ModelCreator_1.ModelCreator;
22196 },{"./api/APIv3":287,"./api/ModelCreator":288}],275:[function(require,module,exports){
22198 function __export(m) {
22199 for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
22201 Object.defineProperty(exports, "__esModule", { value: true });
22202 var Component_1 = require("./component/Component");
22203 exports.Component = Component_1.Component;
22204 var ComponentService_1 = require("./component/ComponentService");
22205 exports.ComponentService = ComponentService_1.ComponentService;
22206 var HandlerBase_1 = require("./component/utils/HandlerBase");
22207 exports.HandlerBase = HandlerBase_1.HandlerBase;
22208 var MeshFactory_1 = require("./component/utils/MeshFactory");
22209 exports.MeshFactory = MeshFactory_1.MeshFactory;
22210 var MeshScene_1 = require("./component/utils/MeshScene");
22211 exports.MeshScene = MeshScene_1.MeshScene;
22212 var MouseOperator_1 = require("./component/utils/MouseOperator");
22213 exports.MouseOperator = MouseOperator_1.MouseOperator;
22214 var AttributionComponent_1 = require("./component/AttributionComponent");
22215 exports.AttributionComponent = AttributionComponent_1.AttributionComponent;
22216 var BackgroundComponent_1 = require("./component/BackgroundComponent");
22217 exports.BackgroundComponent = BackgroundComponent_1.BackgroundComponent;
22218 var BearingComponent_1 = require("./component/BearingComponent");
22219 exports.BearingComponent = BearingComponent_1.BearingComponent;
22220 var CacheComponent_1 = require("./component/CacheComponent");
22221 exports.CacheComponent = CacheComponent_1.CacheComponent;
22222 var CoverComponent_1 = require("./component/CoverComponent");
22223 exports.CoverComponent = CoverComponent_1.CoverComponent;
22224 var DebugComponent_1 = require("./component/DebugComponent");
22225 exports.DebugComponent = DebugComponent_1.DebugComponent;
22226 var DirectionComponent_1 = require("./component/direction/DirectionComponent");
22227 exports.DirectionComponent = DirectionComponent_1.DirectionComponent;
22228 var DirectionDOMCalculator_1 = require("./component/direction/DirectionDOMCalculator");
22229 exports.DirectionDOMCalculator = DirectionDOMCalculator_1.DirectionDOMCalculator;
22230 var DirectionDOMRenderer_1 = require("./component/direction/DirectionDOMRenderer");
22231 exports.DirectionDOMRenderer = DirectionDOMRenderer_1.DirectionDOMRenderer;
22232 var ImageComponent_1 = require("./component/ImageComponent");
22233 exports.ImageComponent = ImageComponent_1.ImageComponent;
22234 var KeyboardComponent_1 = require("./component/keyboard/KeyboardComponent");
22235 exports.KeyboardComponent = KeyboardComponent_1.KeyboardComponent;
22236 var KeyPlayHandler_1 = require("./component/keyboard/KeyPlayHandler");
22237 exports.KeyPlayHandler = KeyPlayHandler_1.KeyPlayHandler;
22238 var KeyZoomHandler_1 = require("./component/keyboard/KeyZoomHandler");
22239 exports.KeyZoomHandler = KeyZoomHandler_1.KeyZoomHandler;
22240 var KeySequenceNavigationHandler_1 = require("./component/keyboard/KeySequenceNavigationHandler");
22241 exports.KeySequenceNavigationHandler = KeySequenceNavigationHandler_1.KeySequenceNavigationHandler;
22242 var KeySpatialNavigationHandler_1 = require("./component/keyboard/KeySpatialNavigationHandler");
22243 exports.KeySpatialNavigationHandler = KeySpatialNavigationHandler_1.KeySpatialNavigationHandler;
22244 var LoadingComponent_1 = require("./component/LoadingComponent");
22245 exports.LoadingComponent = LoadingComponent_1.LoadingComponent;
22246 var Marker_1 = require("./component/marker/marker/Marker");
22247 exports.Marker = Marker_1.Marker;
22248 var MarkerComponent_1 = require("./component/marker/MarkerComponent");
22249 exports.MarkerComponent = MarkerComponent_1.MarkerComponent;
22250 var MarkerScene_1 = require("./component/marker/MarkerScene");
22251 exports.MarkerScene = MarkerScene_1.MarkerScene;
22252 var MarkerSet_1 = require("./component/marker/MarkerSet");
22253 exports.MarkerSet = MarkerSet_1.MarkerSet;
22254 var MouseComponent_1 = require("./component/mouse/MouseComponent");
22255 exports.MouseComponent = MouseComponent_1.MouseComponent;
22256 var BounceHandler_1 = require("./component/mouse/BounceHandler");
22257 exports.BounceHandler = BounceHandler_1.BounceHandler;
22258 var DragPanHandler_1 = require("./component/mouse/DragPanHandler");
22259 exports.DragPanHandler = DragPanHandler_1.DragPanHandler;
22260 var DoubleClickZoomHandler_1 = require("./component/mouse/DoubleClickZoomHandler");
22261 exports.DoubleClickZoomHandler = DoubleClickZoomHandler_1.DoubleClickZoomHandler;
22262 var EarthControlHandler_1 = require("./component/mouse/EarthControlHandler");
22263 exports.EarthControlHandler = EarthControlHandler_1.EarthControlHandler;
22264 var ScrollZoomHandler_1 = require("./component/mouse/ScrollZoomHandler");
22265 exports.ScrollZoomHandler = ScrollZoomHandler_1.ScrollZoomHandler;
22266 var TouchZoomHandler_1 = require("./component/mouse/TouchZoomHandler");
22267 exports.TouchZoomHandler = TouchZoomHandler_1.TouchZoomHandler;
22268 var ImageBoundary = require("./component/mouse/ImageBoundary");
22269 exports.ImageBoundary = ImageBoundary;
22270 var Popup_1 = require("./component/popup/popup/Popup");
22271 exports.Popup = Popup_1.Popup;
22272 var PopupComponent_1 = require("./component/popup/PopupComponent");
22273 exports.PopupComponent = PopupComponent_1.PopupComponent;
22274 var NavigationComponent_1 = require("./component/NavigationComponent");
22275 exports.NavigationComponent = NavigationComponent_1.NavigationComponent;
22276 var RouteComponent_1 = require("./component/RouteComponent");
22277 exports.RouteComponent = RouteComponent_1.RouteComponent;
22278 var SequenceComponent_1 = require("./component/sequence/SequenceComponent");
22279 exports.SequenceComponent = SequenceComponent_1.SequenceComponent;
22280 var SequenceDOMRenderer_1 = require("./component/sequence/SequenceDOMRenderer");
22281 exports.SequenceDOMRenderer = SequenceDOMRenderer_1.SequenceDOMRenderer;
22282 var SequenceMode_1 = require("./component/sequence/SequenceMode");
22283 exports.SequenceMode = SequenceMode_1.SequenceMode;
22284 var SpatialDataCache_1 = require("./component/spatialdata/SpatialDataCache");
22285 exports.SpatialDataCache = SpatialDataCache_1.SpatialDataCache;
22286 var SpatialDataComponent_1 = require("./component/spatialdata/SpatialDataComponent");
22287 exports.SpatialDataComponent = SpatialDataComponent_1.SpatialDataComponent;
22288 var SpatialDataScene_1 = require("./component/spatialdata/SpatialDataScene");
22289 exports.SpatialDataScene = SpatialDataScene_1.SpatialDataScene;
22290 var ImagePlaneComponent_1 = require("./component/imageplane/ImagePlaneComponent");
22291 exports.ImagePlaneComponent = ImagePlaneComponent_1.ImagePlaneComponent;
22292 var ImagePlaneGLRenderer_1 = require("./component/imageplane/ImagePlaneGLRenderer");
22293 exports.ImagePlaneGLRenderer = ImagePlaneGLRenderer_1.ImagePlaneGLRenderer;
22294 var Shaders_1 = require("./component/shaders/Shaders");
22295 exports.Shaders = Shaders_1.Shaders;
22296 var SimpleMarker_1 = require("./component/marker/marker/SimpleMarker");
22297 exports.SimpleMarker = SimpleMarker_1.SimpleMarker;
22298 var CircleMarker_1 = require("./component/marker/marker/CircleMarker");
22299 exports.CircleMarker = CircleMarker_1.CircleMarker;
22300 var SliderComponent_1 = require("./component/slider/SliderComponent");
22301 exports.SliderComponent = SliderComponent_1.SliderComponent;
22302 var SliderDOMRenderer_1 = require("./component/slider/SliderDOMRenderer");
22303 exports.SliderDOMRenderer = SliderDOMRenderer_1.SliderDOMRenderer;
22304 var SliderGLRenderer_1 = require("./component/slider/SliderGLRenderer");
22305 exports.SliderGLRenderer = SliderGLRenderer_1.SliderGLRenderer;
22306 var StatsComponent_1 = require("./component/StatsComponent");
22307 exports.StatsComponent = StatsComponent_1.StatsComponent;
22308 var TagHandlerBase_1 = require("./component/tag/handlers/TagHandlerBase");
22309 exports.TagHandlerBase = TagHandlerBase_1.TagHandlerBase;
22310 var CreateHandlerBase_1 = require("./component/tag/handlers/CreateHandlerBase");
22311 exports.CreateHandlerBase = CreateHandlerBase_1.CreateHandlerBase;
22312 var CreatePointHandler_1 = require("./component/tag/handlers/CreatePointHandler");
22313 exports.CreatePointHandler = CreatePointHandler_1.CreatePointHandler;
22314 var CreateVertexHandler_1 = require("./component/tag/handlers/CreateVertexHandler");
22315 exports.CreateVertexHandler = CreateVertexHandler_1.CreateVertexHandler;
22316 var CreatePolygonHandler_1 = require("./component/tag/handlers/CreatePolygonHandler");
22317 exports.CreatePolygonHandler = CreatePolygonHandler_1.CreatePolygonHandler;
22318 var CreateRectHandler_1 = require("./component/tag/handlers/CreateRectHandler");
22319 exports.CreateRectHandler = CreateRectHandler_1.CreateRectHandler;
22320 var CreateRectDragHandler_1 = require("./component/tag/handlers/CreateRectDragHandler");
22321 exports.CreateRectDragHandler = CreateRectDragHandler_1.CreateRectDragHandler;
22322 var EditVertexHandler_1 = require("./component/tag/handlers/EditVertexHandler");
22323 exports.EditVertexHandler = EditVertexHandler_1.EditVertexHandler;
22324 var Tag_1 = require("./component/tag/tag/Tag");
22325 exports.Tag = Tag_1.Tag;
22326 var OutlineTag_1 = require("./component/tag/tag/OutlineTag");
22327 exports.OutlineTag = OutlineTag_1.OutlineTag;
22328 var RenderTag_1 = require("./component/tag/tag/RenderTag");
22329 exports.RenderTag = RenderTag_1.RenderTag;
22330 var OutlineRenderTag_1 = require("./component/tag/tag/OutlineRenderTag");
22331 exports.OutlineRenderTag = OutlineRenderTag_1.OutlineRenderTag;
22332 var OutlineCreateTag_1 = require("./component/tag/tag/OutlineCreateTag");
22333 exports.OutlineCreateTag = OutlineCreateTag_1.OutlineCreateTag;
22334 var SpotTag_1 = require("./component/tag/tag/SpotTag");
22335 exports.SpotTag = SpotTag_1.SpotTag;
22336 var SpotRenderTag_1 = require("./component/tag/tag/SpotRenderTag");
22337 exports.SpotRenderTag = SpotRenderTag_1.SpotRenderTag;
22338 var TagDomain_1 = require("./component/tag/tag/TagDomain");
22339 exports.TagDomain = TagDomain_1.TagDomain;
22340 var TagComponent_1 = require("./component/tag/TagComponent");
22341 exports.TagComponent = TagComponent_1.TagComponent;
22342 var TagCreator_1 = require("./component/tag/TagCreator");
22343 exports.TagCreator = TagCreator_1.TagCreator;
22344 var TagDOMRenderer_1 = require("./component/tag/TagDOMRenderer");
22345 exports.TagDOMRenderer = TagDOMRenderer_1.TagDOMRenderer;
22346 var TagMode_1 = require("./component/tag/TagMode");
22347 exports.TagMode = TagMode_1.TagMode;
22348 var TagOperation_1 = require("./component/tag/TagOperation");
22349 exports.TagOperation = TagOperation_1.TagOperation;
22350 var TagScene_1 = require("./component/tag/TagScene");
22351 exports.TagScene = TagScene_1.TagScene;
22352 var TagSet_1 = require("./component/tag/TagSet");
22353 exports.TagSet = TagSet_1.TagSet;
22354 var Geometry_1 = require("./component/tag/geometry/Geometry");
22355 exports.Geometry = Geometry_1.Geometry;
22356 var VertexGeometry_1 = require("./component/tag/geometry/VertexGeometry");
22357 exports.VertexGeometry = VertexGeometry_1.VertexGeometry;
22358 var RectGeometry_1 = require("./component/tag/geometry/RectGeometry");
22359 exports.RectGeometry = RectGeometry_1.RectGeometry;
22360 var PointGeometry_1 = require("./component/tag/geometry/PointGeometry");
22361 exports.PointGeometry = PointGeometry_1.PointGeometry;
22362 var PolygonGeometry_1 = require("./component/tag/geometry/PolygonGeometry");
22363 exports.PolygonGeometry = PolygonGeometry_1.PolygonGeometry;
22364 var GeometryTagError_1 = require("./component/tag/error/GeometryTagError");
22365 exports.GeometryTagError = GeometryTagError_1.GeometryTagError;
22366 var ZoomComponent_1 = require("./component/zoom/ZoomComponent");
22367 exports.ZoomComponent = ZoomComponent_1.ZoomComponent;
22368 __export(require("./component/interfaces/interfaces"));
22370 },{"./component/AttributionComponent":289,"./component/BackgroundComponent":290,"./component/BearingComponent":291,"./component/CacheComponent":292,"./component/Component":293,"./component/ComponentService":294,"./component/CoverComponent":295,"./component/DebugComponent":296,"./component/ImageComponent":297,"./component/LoadingComponent":298,"./component/NavigationComponent":299,"./component/RouteComponent":300,"./component/StatsComponent":301,"./component/direction/DirectionComponent":302,"./component/direction/DirectionDOMCalculator":303,"./component/direction/DirectionDOMRenderer":304,"./component/imageplane/ImagePlaneComponent":305,"./component/imageplane/ImagePlaneGLRenderer":306,"./component/interfaces/interfaces":309,"./component/keyboard/KeyPlayHandler":310,"./component/keyboard/KeySequenceNavigationHandler":311,"./component/keyboard/KeySpatialNavigationHandler":312,"./component/keyboard/KeyZoomHandler":313,"./component/keyboard/KeyboardComponent":314,"./component/marker/MarkerComponent":316,"./component/marker/MarkerScene":317,"./component/marker/MarkerSet":318,"./component/marker/marker/CircleMarker":319,"./component/marker/marker/Marker":320,"./component/marker/marker/SimpleMarker":321,"./component/mouse/BounceHandler":322,"./component/mouse/DoubleClickZoomHandler":323,"./component/mouse/DragPanHandler":324,"./component/mouse/EarthControlHandler":325,"./component/mouse/ImageBoundary":326,"./component/mouse/MouseComponent":327,"./component/mouse/ScrollZoomHandler":328,"./component/mouse/TouchZoomHandler":329,"./component/popup/PopupComponent":331,"./component/popup/popup/Popup":332,"./component/sequence/SequenceComponent":333,"./component/sequence/SequenceDOMRenderer":334,"./component/sequence/SequenceMode":335,"./component/shaders/Shaders":336,"./component/slider/SliderComponent":337,"./component/slider/SliderDOMRenderer":338,"./component/slider/SliderGLRenderer":339,"./component/spatialdata/SpatialDataCache":340,"./component/spatialdata/SpatialDataComponent":341,"./component/spatialdata/SpatialDataScene":342,"./component/tag/TagComponent":344,"./component/tag/TagCreator":345,"./component/tag/TagDOMRenderer":346,"./component/tag/TagMode":347,"./component/tag/TagOperation":348,"./component/tag/TagScene":349,"./component/tag/TagSet":350,"./component/tag/error/GeometryTagError":351,"./component/tag/geometry/Geometry":352,"./component/tag/geometry/PointGeometry":353,"./component/tag/geometry/PolygonGeometry":354,"./component/tag/geometry/RectGeometry":355,"./component/tag/geometry/VertexGeometry":356,"./component/tag/handlers/CreateHandlerBase":357,"./component/tag/handlers/CreatePointHandler":358,"./component/tag/handlers/CreatePolygonHandler":359,"./component/tag/handlers/CreateRectDragHandler":360,"./component/tag/handlers/CreateRectHandler":361,"./component/tag/handlers/CreateVertexHandler":362,"./component/tag/handlers/EditVertexHandler":363,"./component/tag/handlers/TagHandlerBase":364,"./component/tag/tag/OutlineCreateTag":365,"./component/tag/tag/OutlineRenderTag":366,"./component/tag/tag/OutlineTag":367,"./component/tag/tag/RenderTag":368,"./component/tag/tag/SpotRenderTag":369,"./component/tag/tag/SpotTag":370,"./component/tag/tag/Tag":371,"./component/tag/tag/TagDomain":372,"./component/utils/HandlerBase":373,"./component/utils/MeshFactory":374,"./component/utils/MeshScene":375,"./component/utils/MouseOperator":376,"./component/zoom/ZoomComponent":377}],276:[function(require,module,exports){
22372 Object.defineProperty(exports, "__esModule", { value: true });
22373 var EdgeDirection_1 = require("./graph/edge/EdgeDirection");
22374 exports.EdgeDirection = EdgeDirection_1.EdgeDirection;
22375 var EdgeCalculatorSettings_1 = require("./graph/edge/EdgeCalculatorSettings");
22376 exports.EdgeCalculatorSettings = EdgeCalculatorSettings_1.EdgeCalculatorSettings;
22377 var EdgeCalculatorDirections_1 = require("./graph/edge/EdgeCalculatorDirections");
22378 exports.EdgeCalculatorDirections = EdgeCalculatorDirections_1.EdgeCalculatorDirections;
22379 var EdgeCalculatorCoefficients_1 = require("./graph/edge/EdgeCalculatorCoefficients");
22380 exports.EdgeCalculatorCoefficients = EdgeCalculatorCoefficients_1.EdgeCalculatorCoefficients;
22381 var EdgeCalculator_1 = require("./graph/edge/EdgeCalculator");
22382 exports.EdgeCalculator = EdgeCalculator_1.EdgeCalculator;
22384 },{"./graph/edge/EdgeCalculator":399,"./graph/edge/EdgeCalculatorCoefficients":400,"./graph/edge/EdgeCalculatorDirections":401,"./graph/edge/EdgeCalculatorSettings":402,"./graph/edge/EdgeDirection":403}],277:[function(require,module,exports){
22386 Object.defineProperty(exports, "__esModule", { value: true });
22387 var AbortMapillaryError_1 = require("./error/AbortMapillaryError");
22388 exports.AbortMapillaryError = AbortMapillaryError_1.AbortMapillaryError;
22389 var ArgumentMapillaryError_1 = require("./error/ArgumentMapillaryError");
22390 exports.ArgumentMapillaryError = ArgumentMapillaryError_1.ArgumentMapillaryError;
22391 var GraphMapillaryError_1 = require("./error/GraphMapillaryError");
22392 exports.GraphMapillaryError = GraphMapillaryError_1.GraphMapillaryError;
22393 var MapillaryError_1 = require("./error/MapillaryError");
22394 exports.MapillaryError = MapillaryError_1.MapillaryError;
22396 },{"./error/AbortMapillaryError":378,"./error/ArgumentMapillaryError":379,"./error/GraphMapillaryError":380,"./error/MapillaryError":381}],278:[function(require,module,exports){
22398 Object.defineProperty(exports, "__esModule", { value: true });
22399 var Camera_1 = require("./geo/Camera");
22400 exports.Camera = Camera_1.Camera;
22401 var GeoCoords_1 = require("./geo/GeoCoords");
22402 exports.GeoCoords = GeoCoords_1.GeoCoords;
22403 var ViewportCoords_1 = require("./geo/ViewportCoords");
22404 exports.ViewportCoords = ViewportCoords_1.ViewportCoords;
22405 var Spatial_1 = require("./geo/Spatial");
22406 exports.Spatial = Spatial_1.Spatial;
22407 var Transform_1 = require("./geo/Transform");
22408 exports.Transform = Transform_1.Transform;
22409 var Geo = require("./geo/Geo");
22411 var Lines = require("./geo/Lines");
22412 exports.Lines = Lines;
22414 },{"./geo/Camera":382,"./geo/Geo":383,"./geo/GeoCoords":384,"./geo/Lines":385,"./geo/Spatial":386,"./geo/Transform":387,"./geo/ViewportCoords":388}],279:[function(require,module,exports){
22416 Object.defineProperty(exports, "__esModule", { value: true });
22417 var FilterCreator_1 = require("./graph/FilterCreator");
22418 exports.FilterCreator = FilterCreator_1.FilterCreator;
22419 var Graph_1 = require("./graph/Graph");
22420 exports.Graph = Graph_1.Graph;
22421 var GraphCalculator_1 = require("./graph/GraphCalculator");
22422 exports.GraphCalculator = GraphCalculator_1.GraphCalculator;
22423 var GraphMode_1 = require("./graph/GraphMode");
22424 exports.GraphMode = GraphMode_1.GraphMode;
22425 var GraphService_1 = require("./graph/GraphService");
22426 exports.GraphService = GraphService_1.GraphService;
22427 var ImageLoadingService_1 = require("./graph/ImageLoadingService");
22428 exports.ImageLoadingService = ImageLoadingService_1.ImageLoadingService;
22429 var MeshReader_1 = require("./graph/MeshReader");
22430 exports.MeshReader = MeshReader_1.MeshReader;
22431 var Node_1 = require("./graph/Node");
22432 exports.Node = Node_1.Node;
22433 var NodeCache_1 = require("./graph/NodeCache");
22434 exports.NodeCache = NodeCache_1.NodeCache;
22435 var Sequence_1 = require("./graph/Sequence");
22436 exports.Sequence = Sequence_1.Sequence;
22438 },{"./graph/FilterCreator":389,"./graph/Graph":390,"./graph/GraphCalculator":391,"./graph/GraphMode":392,"./graph/GraphService":393,"./graph/ImageLoadingService":394,"./graph/MeshReader":395,"./graph/Node":396,"./graph/NodeCache":397,"./graph/Sequence":398}],280:[function(require,module,exports){
22441 * MapillaryJS is a WebGL JavaScript library for exploring street level imagery
22444 function __export(m) {
22445 for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
22447 Object.defineProperty(exports, "__esModule", { value: true });
22448 __export(require("./Support"));
22449 var Edge_1 = require("./Edge");
22450 exports.EdgeDirection = Edge_1.EdgeDirection;
22451 var Error_1 = require("./Error");
22452 exports.AbortMapillaryError = Error_1.AbortMapillaryError;
22453 var Render_1 = require("./Render");
22454 exports.RenderMode = Render_1.RenderMode;
22455 var State_1 = require("./State");
22456 exports.TransitionMode = State_1.TransitionMode;
22457 var Viewer_1 = require("./Viewer");
22458 exports.Alignment = Viewer_1.Alignment;
22459 exports.ImageSize = Viewer_1.ImageSize;
22460 exports.Viewer = Viewer_1.Viewer;
22461 var Component_1 = require("./Component");
22462 exports.SliderMode = Component_1.SliderMode;
22463 var TagComponent = require("./component/tag/Tag");
22464 exports.TagComponent = TagComponent;
22465 var MarkerComponent = require("./component/marker/Marker");
22466 exports.MarkerComponent = MarkerComponent;
22467 var PopupComponent = require("./component/popup/Popup");
22468 exports.PopupComponent = PopupComponent;
22470 },{"./Component":275,"./Edge":276,"./Error":277,"./Render":281,"./State":282,"./Support":283,"./Viewer":286,"./component/marker/Marker":315,"./component/popup/Popup":330,"./component/tag/Tag":343}],281:[function(require,module,exports){
22472 Object.defineProperty(exports, "__esModule", { value: true });
22473 var DOMRenderer_1 = require("./render/DOMRenderer");
22474 exports.DOMRenderer = DOMRenderer_1.DOMRenderer;
22475 var GLRenderer_1 = require("./render/GLRenderer");
22476 exports.GLRenderer = GLRenderer_1.GLRenderer;
22477 var GLRenderStage_1 = require("./render/GLRenderStage");
22478 exports.GLRenderStage = GLRenderStage_1.GLRenderStage;
22479 var RenderCamera_1 = require("./render/RenderCamera");
22480 exports.RenderCamera = RenderCamera_1.RenderCamera;
22481 var RenderMode_1 = require("./render/RenderMode");
22482 exports.RenderMode = RenderMode_1.RenderMode;
22483 var RenderService_1 = require("./render/RenderService");
22484 exports.RenderService = RenderService_1.RenderService;
22486 },{"./render/DOMRenderer":404,"./render/GLRenderStage":405,"./render/GLRenderer":406,"./render/RenderCamera":407,"./render/RenderMode":408,"./render/RenderService":409}],282:[function(require,module,exports){
22488 Object.defineProperty(exports, "__esModule", { value: true });
22489 var FrameGenerator_1 = require("./state/FrameGenerator");
22490 exports.FrameGenerator = FrameGenerator_1.FrameGenerator;
22491 var RotationDelta_1 = require("./state/RotationDelta");
22492 exports.RotationDelta = RotationDelta_1.RotationDelta;
22493 var State_1 = require("./state/State");
22494 exports.State = State_1.State;
22495 var StateBase_1 = require("./state/states/StateBase");
22496 exports.StateBase = StateBase_1.StateBase;
22497 var StateContext_1 = require("./state/StateContext");
22498 exports.StateContext = StateContext_1.StateContext;
22499 var StateService_1 = require("./state/StateService");
22500 exports.StateService = StateService_1.StateService;
22501 var TransitionMode_1 = require("./state/TransitionMode");
22502 exports.TransitionMode = TransitionMode_1.TransitionMode;
22503 var EarthState_1 = require("./state/states/EarthState");
22504 exports.EarthState = EarthState_1.EarthState;
22505 var InteractiveStateBase_1 = require("./state/states/InteractiveStateBase");
22506 exports.InteractiveStateBase = InteractiveStateBase_1.InteractiveStateBase;
22507 var InteractiveWaitingState_1 = require("./state/states/InteractiveWaitingState");
22508 exports.InteractiveWaitingState = InteractiveWaitingState_1.InteractiveWaitingState;
22509 var TraversingState_1 = require("./state/states/TraversingState");
22510 exports.TraversingState = TraversingState_1.TraversingState;
22511 var WaitingState_1 = require("./state/states/WaitingState");
22512 exports.WaitingState = WaitingState_1.WaitingState;
22514 },{"./state/FrameGenerator":410,"./state/RotationDelta":411,"./state/State":412,"./state/StateContext":413,"./state/StateService":414,"./state/TransitionMode":415,"./state/states/EarthState":416,"./state/states/InteractiveStateBase":417,"./state/states/InteractiveWaitingState":418,"./state/states/StateBase":419,"./state/states/TraversingState":420,"./state/states/WaitingState":421}],283:[function(require,module,exports){
22516 Object.defineProperty(exports, "__esModule", { value: true });
22517 var support = require("./utils/Support");
22519 * Test whether the current browser supports the full
22520 * functionality of MapillaryJS.
22522 * @description The full functionality includes WebGL rendering.
22524 * @return {boolean}
22526 * @example `var supported = Mapillary.isSupported();`
22528 function isSupported() {
22529 return isFallbackSupported() &&
22530 support.isWebGLSupportedCached();
22532 exports.isSupported = isSupported;
22534 * Test whether the current browser supports the fallback
22535 * functionality of MapillaryJS.
22537 * @description The fallback functionality does not include WebGL
22538 * rendering, only 2D canvas rendering.
22540 * @return {boolean}
22542 * @example `var fallbackSupported = Mapillary.isFallbackSupported();`
22544 function isFallbackSupported() {
22545 return support.isBrowser() &&
22546 support.isBlobSupported() &&
22547 support.isArraySupported() &&
22548 support.isFunctionSupported() &&
22549 support.isJSONSupported() &&
22550 support.isObjectSupported();
22552 exports.isFallbackSupported = isFallbackSupported;
22554 },{"./utils/Support":429}],284:[function(require,module,exports){
22556 Object.defineProperty(exports, "__esModule", { value: true });
22557 var ImageTileLoader_1 = require("./tiles/ImageTileLoader");
22558 exports.ImageTileLoader = ImageTileLoader_1.ImageTileLoader;
22559 var ImageTileStore_1 = require("./tiles/ImageTileStore");
22560 exports.ImageTileStore = ImageTileStore_1.ImageTileStore;
22561 var TextureProvider_1 = require("./tiles/TextureProvider");
22562 exports.TextureProvider = TextureProvider_1.TextureProvider;
22563 var RegionOfInterestCalculator_1 = require("./tiles/RegionOfInterestCalculator");
22564 exports.RegionOfInterestCalculator = RegionOfInterestCalculator_1.RegionOfInterestCalculator;
22566 },{"./tiles/ImageTileLoader":422,"./tiles/ImageTileStore":423,"./tiles/RegionOfInterestCalculator":424,"./tiles/TextureProvider":425}],285:[function(require,module,exports){
22568 function __export(m) {
22569 for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
22571 Object.defineProperty(exports, "__esModule", { value: true });
22572 var DOM_1 = require("./utils/DOM");
22573 exports.DOM = DOM_1.DOM;
22574 var EventEmitter_1 = require("./utils/EventEmitter");
22575 exports.EventEmitter = EventEmitter_1.EventEmitter;
22576 var Settings_1 = require("./utils/Settings");
22577 exports.Settings = Settings_1.Settings;
22578 __export(require("./utils/Support"));
22579 var Urls_1 = require("./utils/Urls");
22580 exports.Urls = Urls_1.Urls;
22582 },{"./utils/DOM":426,"./utils/EventEmitter":427,"./utils/Settings":428,"./utils/Support":429,"./utils/Urls":430}],286:[function(require,module,exports){
22584 Object.defineProperty(exports, "__esModule", { value: true });
22585 var Alignment_1 = require("./viewer/Alignment");
22586 exports.Alignment = Alignment_1.Alignment;
22587 var CacheService_1 = require("./viewer/CacheService");
22588 exports.CacheService = CacheService_1.CacheService;
22589 var ComponentController_1 = require("./viewer/ComponentController");
22590 exports.ComponentController = ComponentController_1.ComponentController;
22591 var Container_1 = require("./viewer/Container");
22592 exports.Container = Container_1.Container;
22593 var Observer_1 = require("./viewer/Observer");
22594 exports.Observer = Observer_1.Observer;
22595 var ImageSize_1 = require("./viewer/ImageSize");
22596 exports.ImageSize = ImageSize_1.ImageSize;
22597 var KeyboardService_1 = require("./viewer/KeyboardService");
22598 exports.KeyboardService = KeyboardService_1.KeyboardService;
22599 var LoadingService_1 = require("./viewer/LoadingService");
22600 exports.LoadingService = LoadingService_1.LoadingService;
22601 var MouseService_1 = require("./viewer/MouseService");
22602 exports.MouseService = MouseService_1.MouseService;
22603 var Navigator_1 = require("./viewer/Navigator");
22604 exports.Navigator = Navigator_1.Navigator;
22605 var PlayService_1 = require("./viewer/PlayService");
22606 exports.PlayService = PlayService_1.PlayService;
22607 var Projection_1 = require("./viewer/Projection");
22608 exports.Projection = Projection_1.Projection;
22609 var SpriteService_1 = require("./viewer/SpriteService");
22610 exports.SpriteService = SpriteService_1.SpriteService;
22611 var TouchService_1 = require("./viewer/TouchService");
22612 exports.TouchService = TouchService_1.TouchService;
22613 var Viewer_1 = require("./viewer/Viewer");
22614 exports.Viewer = Viewer_1.Viewer;
22616 },{"./viewer/Alignment":431,"./viewer/CacheService":432,"./viewer/ComponentController":433,"./viewer/Container":434,"./viewer/ImageSize":435,"./viewer/KeyboardService":436,"./viewer/LoadingService":437,"./viewer/MouseService":438,"./viewer/Navigator":439,"./viewer/Observer":440,"./viewer/PlayService":441,"./viewer/Projection":442,"./viewer/SpriteService":443,"./viewer/TouchService":444,"./viewer/Viewer":445}],287:[function(require,module,exports){
22618 Object.defineProperty(exports, "__esModule", { value: true });
22619 var operators_1 = require("rxjs/operators");
22620 var rxjs_1 = require("rxjs");
22621 var API_1 = require("../API");
22625 * @classdesc Provides methods for access of API v3.
22627 var APIv3 = /** @class */ (function () {
22629 * Create a new api v3 instance.
22631 * @param {number} clientId - Client id for API requests.
22632 * @param {number} [token] - Optional bearer token for API requests of
22633 * protected resources.
22634 * @param {ModelCreator} [creator] - Optional model creator instance.
22636 function APIv3(clientId, token, creator) {
22637 this._clientId = clientId;
22638 this._modelCreator = creator != null ? creator : new API_1.ModelCreator();
22639 this._model = this._modelCreator.createModel(clientId, token);
22640 this._pageCount = 999;
22641 this._pathImageByKey = "imageByKey";
22642 this._pathImageCloseTo = "imageCloseTo";
22643 this._pathImagesByH = "imagesByH";
22644 this._pathImageViewAdd = "imageViewAdd";
22645 this._pathSequenceByKey = "sequenceByKey";
22646 this._pathSequenceViewAdd = "sequenceViewAdd";
22647 this._propertiesCore = [
22652 this._propertiesFill = [
22654 "captured_with_camera_uuid",
22656 "organization_key",
22660 this._propertiesKey = [
22663 this._propertiesSequence = [
22666 this._propertiesSpatial = [
22671 "camera_projection_type",
22683 this._propertiesUser = [
22687 APIv3.prototype.imageByKeyFill$ = function (keys) {
22688 return this._catchInvalidateGet$(this._wrapModelResponse$(this._model.get([
22689 this._pathImageByKey,
22691 this._propertiesKey
22692 .concat(this._propertiesFill)
22693 .concat(this._propertiesSpatial),
22694 this._propertiesKey
22695 .concat(this._propertiesUser)
22696 ])).pipe(operators_1.map(function (value) {
22698 throw new Error("Images (" + keys.join(", ") + ") could not be found.");
22700 return value.json.imageByKey;
22701 })), this._pathImageByKey, keys);
22703 APIv3.prototype.imageByKeyFull$ = function (keys) {
22704 return this._catchInvalidateGet$(this._wrapModelResponse$(this._model.get([
22705 this._pathImageByKey,
22707 this._propertiesKey
22708 .concat(this._propertiesCore)
22709 .concat(this._propertiesFill)
22710 .concat(this._propertiesSpatial),
22711 this._propertiesKey
22712 .concat(this._propertiesUser)
22713 ])).pipe(operators_1.map(function (value) {
22715 throw new Error("Images (" + keys.join(", ") + ") could not be found.");
22717 return value.json.imageByKey;
22718 })), this._pathImageByKey, keys);
22720 APIv3.prototype.imageCloseTo$ = function (lat, lon) {
22721 var lonLat = lon + ":" + lat;
22722 return this._catchInvalidateGet$(this._wrapModelResponse$(this._model.get([
22723 this._pathImageCloseTo,
22725 this._propertiesKey
22726 .concat(this._propertiesCore)
22727 .concat(this._propertiesFill)
22728 .concat(this._propertiesSpatial),
22729 this._propertiesKey
22730 .concat(this._propertiesUser)
22731 ])).pipe(operators_1.map(function (value) {
22732 return value != null ? value.json.imageCloseTo[lonLat] : null;
22733 })), this._pathImageCloseTo, [lonLat]);
22735 APIv3.prototype.imagesByH$ = function (hs) {
22737 return this._catchInvalidateGet$(this._wrapModelResponse$(this._model.get([
22738 this._pathImagesByH,
22740 { from: 0, to: this._pageCount },
22741 this._propertiesKey
22742 .concat(this._propertiesCore)
22743 ])).pipe(operators_1.map(function (value) {
22745 value = { json: { imagesByH: {} } };
22746 for (var _i = 0, hs_1 = hs; _i < hs_1.length; _i++) {
22748 value.json.imagesByH[h] = {};
22749 for (var i = 0; i <= _this._pageCount; i++) {
22750 value.json.imagesByH[h][i] = null;
22754 return value.json.imagesByH;
22755 })), this._pathImagesByH, hs);
22757 APIv3.prototype.imageViewAdd$ = function (keys) {
22758 return this._catchInvalidateCall$(this._wrapCallModelResponse$(this._model.call([this._pathImageViewAdd], [keys])), this._pathImageViewAdd, keys);
22760 APIv3.prototype.invalidateImageByKey = function (keys) {
22761 this._invalidateGet(this._pathImageByKey, keys);
22763 APIv3.prototype.invalidateImagesByH = function (hs) {
22764 this._invalidateGet(this._pathImagesByH, hs);
22766 APIv3.prototype.invalidateSequenceByKey = function (sKeys) {
22767 this._invalidateGet(this._pathSequenceByKey, sKeys);
22769 APIv3.prototype.setToken = function (token) {
22770 this._model.invalidate([]);
22771 this._model = null;
22772 this._model = this._modelCreator.createModel(this._clientId, token);
22774 APIv3.prototype.sequenceByKey$ = function (sequenceKeys) {
22775 return this._catchInvalidateGet$(this._wrapModelResponse$(this._model.get([
22776 this._pathSequenceByKey,
22778 this._propertiesKey
22779 .concat(this._propertiesSequence)
22780 ])).pipe(operators_1.map(function (value) {
22782 value = { json: { sequenceByKey: {} } };
22784 for (var _i = 0, sequenceKeys_1 = sequenceKeys; _i < sequenceKeys_1.length; _i++) {
22785 var sequenceKey = sequenceKeys_1[_i];
22786 if (!(sequenceKey in value.json.sequenceByKey)) {
22787 console.warn("Sequence data missing (" + sequenceKey + ")");
22788 value.json.sequenceByKey[sequenceKey] = { key: sequenceKey, keys: [] };
22791 return value.json.sequenceByKey;
22792 })), this._pathSequenceByKey, sequenceKeys);
22794 APIv3.prototype.sequenceViewAdd$ = function (sequenceKeys) {
22795 return this._catchInvalidateCall$(this._wrapCallModelResponse$(this._model.call([this._pathSequenceViewAdd], [sequenceKeys])), this._pathSequenceViewAdd, sequenceKeys);
22797 Object.defineProperty(APIv3.prototype, "clientId", {
22799 return this._clientId;
22804 APIv3.prototype._catchInvalidateGet$ = function (observable, path, paths) {
22806 return observable.pipe(operators_1.catchError(function (error) {
22807 _this._invalidateGet(path, paths);
22811 APIv3.prototype._catchInvalidateCall$ = function (observable, path, paths) {
22813 return observable.pipe(operators_1.catchError(function (error) {
22814 _this._invalidateCall(path, paths);
22818 APIv3.prototype._invalidateGet = function (path, paths) {
22819 this._model.invalidate([path, paths]);
22821 APIv3.prototype._invalidateCall = function (path, paths) {
22822 this._model.invalidate([path], [paths]);
22824 APIv3.prototype._wrapModelResponse$ = function (modelResponse) {
22825 return rxjs_1.Observable
22826 .create(function (subscriber) {
22828 .then(function (value) {
22829 subscriber.next(value);
22830 subscriber.complete();
22831 }, function (error) {
22832 subscriber.error(error);
22836 APIv3.prototype._wrapCallModelResponse$ = function (modelResponse) {
22837 return this._wrapModelResponse$(modelResponse).pipe(operators_1.map(function (value) {
22843 exports.APIv3 = APIv3;
22844 exports.default = APIv3;
22846 },{"../API":274,"rxjs":27,"rxjs/operators":225}],288:[function(require,module,exports){
22848 Object.defineProperty(exports, "__esModule", { value: true });
22849 var falcor = require("falcor");
22850 var falcor_http_datasource_1 = require("falcor-http-datasource");
22851 var Utils_1 = require("../Utils");
22853 * @class ModelCreator
22855 * @classdesc Creates API models.
22857 var ModelCreator = /** @class */ (function () {
22858 function ModelCreator() {
22861 * Creates a Falcor model.
22863 * @description Max cache size will be set to 16 MB. Authorization
22864 * header will be added if bearer token is supplied.
22866 * @param {number} clientId - Client id for API requests.
22867 * @param {number} [token] - Optional bearer token for API requests of
22868 * protected resources.
22869 * @returns {falcor.Model} Falcor model for HTTP requests.
22871 ModelCreator.prototype.createModel = function (clientId, token) {
22872 var configuration = {
22874 withCredentials: false,
22876 if (token != null) {
22877 configuration.headers = { "Authorization": "Bearer " + token };
22879 return new falcor.Model({
22880 maxSize: 16 * 1024 * 1024,
22881 source: new falcor_http_datasource_1.default(Utils_1.Urls.falcorModel(clientId), configuration),
22884 return ModelCreator;
22886 exports.ModelCreator = ModelCreator;
22887 exports.default = ModelCreator;
22889 },{"../Utils":285,"falcor":15,"falcor-http-datasource":10}],289:[function(require,module,exports){
22891 var __extends = (this && this.__extends) || (function () {
22892 var extendStatics = function (d, b) {
22893 extendStatics = Object.setPrototypeOf ||
22894 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
22895 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
22896 return extendStatics(d, b);
22898 return function (d, b) {
22899 extendStatics(d, b);
22900 function __() { this.constructor = d; }
22901 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
22904 Object.defineProperty(exports, "__esModule", { value: true });
22905 var rxjs_1 = require("rxjs");
22906 var operators_1 = require("rxjs/operators");
22907 var vd = require("virtual-dom");
22908 var Component_1 = require("../Component");
22909 var Utils_1 = require("../Utils");
22910 var AttributionComponent = /** @class */ (function (_super) {
22911 __extends(AttributionComponent, _super);
22912 function AttributionComponent(name, container, navigator) {
22913 return _super.call(this, name, container, navigator) || this;
22915 AttributionComponent.prototype._activate = function () {
22917 this._disposable = rxjs_1.combineLatest(this._navigator.stateService.currentNode$, this._container.renderService.size$).pipe(operators_1.map(function (_a) {
22918 var node = _a[0], size = _a[1];
22921 vnode: _this._getAttributionNode(node.username, node.key, node.capturedAt, size.width),
22924 .subscribe(this._container.domRenderer.render$);
22926 AttributionComponent.prototype._deactivate = function () {
22927 this._disposable.unsubscribe();
22929 AttributionComponent.prototype._getDefaultConfiguration = function () {
22932 AttributionComponent.prototype._getAttributionNode = function (username, key, capturedAt, width) {
22933 var compact = width <= 640;
22934 var mapillaryIcon = vd.h("div.AttributionMapillaryLogo", []);
22935 var mapillaryLink = vd.h("a.AttributionIconContainer", { href: Utils_1.Urls.explore, target: "_blank" }, [mapillaryIcon]);
22936 var imageBy = compact ? "" + username : "image by " + username;
22937 var imageByContent = vd.h("div.AttributionUsername", { textContent: imageBy }, []);
22938 var date = new Date(capturedAt).toDateString().split(" ");
22939 var formatted = (date.length > 3 ?
22942 [date[1], date[2] + ",", date[3]] :
22944 var dateContent = vd.h("div.AttributionDate", { textContent: formatted }, []);
22945 var imageLink = vd.h("a.AttributionImageContainer", { href: Utils_1.Urls.exporeImage(key), target: "_blank" }, [imageByContent, dateContent]);
22946 var compactClass = compact ? ".AttributionCompact" : "";
22947 return vd.h("div.AttributionContainer" + compactClass, {}, [mapillaryLink, imageLink]);
22949 AttributionComponent.componentName = "attribution";
22950 return AttributionComponent;
22951 }(Component_1.Component));
22952 exports.AttributionComponent = AttributionComponent;
22953 Component_1.ComponentService.register(AttributionComponent);
22954 exports.default = AttributionComponent;
22956 },{"../Component":275,"../Utils":285,"rxjs":27,"rxjs/operators":225,"virtual-dom":231}],290:[function(require,module,exports){
22958 var __extends = (this && this.__extends) || (function () {
22959 var extendStatics = function (d, b) {
22960 extendStatics = Object.setPrototypeOf ||
22961 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
22962 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
22963 return extendStatics(d, b);
22965 return function (d, b) {
22966 extendStatics(d, b);
22967 function __() { this.constructor = d; }
22968 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
22971 Object.defineProperty(exports, "__esModule", { value: true });
22972 var vd = require("virtual-dom");
22973 var Component_1 = require("../Component");
22974 var BackgroundComponent = /** @class */ (function (_super) {
22975 __extends(BackgroundComponent, _super);
22976 function BackgroundComponent(name, container, navigator) {
22977 return _super.call(this, name, container, navigator) || this;
22979 BackgroundComponent.prototype._activate = function () {
22980 this._container.domRenderer.render$
22981 .next({ name: this._name, vnode: this._getBackgroundNode("The viewer can't display the given image.") });
22983 BackgroundComponent.prototype._deactivate = function () {
22986 BackgroundComponent.prototype._getDefaultConfiguration = function () {
22989 BackgroundComponent.prototype._getBackgroundNode = function (notice) {
22990 // todo: add condition for when to display the DOM node
22991 return vd.h("div.BackgroundWrapper", {}, [
22992 vd.h("p", { textContent: notice }, []),
22995 BackgroundComponent.componentName = "background";
22996 return BackgroundComponent;
22997 }(Component_1.Component));
22998 exports.BackgroundComponent = BackgroundComponent;
22999 Component_1.ComponentService.register(BackgroundComponent);
23000 exports.default = BackgroundComponent;
23002 },{"../Component":275,"virtual-dom":231}],291:[function(require,module,exports){
23004 var __extends = (this && this.__extends) || (function () {
23005 var extendStatics = function (d, b) {
23006 extendStatics = Object.setPrototypeOf ||
23007 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
23008 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
23009 return extendStatics(d, b);
23011 return function (d, b) {
23012 extendStatics(d, b);
23013 function __() { this.constructor = d; }
23014 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
23017 Object.defineProperty(exports, "__esModule", { value: true });
23018 var operators_1 = require("rxjs/operators");
23019 var vd = require("virtual-dom");
23020 var Component_1 = require("../Component");
23021 var Geo_1 = require("../Geo");
23022 var BearingComponent = /** @class */ (function (_super) {
23023 __extends(BearingComponent, _super);
23024 function BearingComponent(name, container, navigator) {
23025 var _this = _super.call(this, name, container, navigator) || this;
23026 _this._spatial = new Geo_1.Spatial();
23027 _this._svgNamespace = "http://www.w3.org/2000/svg";
23028 _this._distinctThreshold = Math.PI / 360;
23031 BearingComponent.prototype._activate = function () {
23033 var cameraBearingFov$ = this._container.renderService.renderCamera$.pipe(operators_1.map(function (rc) {
23034 var vFov = _this._spatial.degToRad(rc.perspective.fov);
23035 var hFov = rc.perspective.aspect === Number.POSITIVE_INFINITY ?
23037 Math.atan(rc.perspective.aspect * Math.tan(0.5 * vFov)) * 2;
23038 return [_this._spatial.azimuthalToBearing(rc.rotation.phi), hFov];
23039 }), operators_1.distinctUntilChanged(function (a1, a2) {
23040 return Math.abs(a2[0] - a1[0]) < _this._distinctThreshold &&
23041 Math.abs(a2[1] - a1[1]) < _this._distinctThreshold;
23043 this._renderSubscription = cameraBearingFov$.pipe(operators_1.map(function (_a) {
23044 var bearing = _a[0], fov = _a[1];
23045 var background = vd.h("div.BearingIndicatorBackground", {}, []);
23046 var backgroundCircle = vd.h("div.BearingIndicatorBackgroundCircle", {}, []);
23047 var north = _this._createNorth(bearing);
23048 var cameraSector = _this._createCircleSectorCompass(_this._createCircleSector(Math.max(Math.PI / 20, fov), "#FFF"));
23051 vnode: vd.h("div.BearingIndicatorContainer", { oncontextmenu: function (event) { event.preventDefault(); } }, [
23059 .subscribe(this._container.domRenderer.render$);
23061 BearingComponent.prototype._deactivate = function () {
23062 this._renderSubscription.unsubscribe();
23064 BearingComponent.prototype._getDefaultConfiguration = function () {
23067 BearingComponent.prototype._createCircleSectorCompass = function (cameraSector) {
23068 var group = vd.h("g", {
23069 attributes: { transform: "translate(1,1)" },
23070 namespace: this._svgNamespace,
23071 }, [cameraSector]);
23072 var svg = vd.h("svg", {
23073 attributes: { viewBox: "0 0 2 2" },
23074 namespace: this._svgNamespace,
23078 position: "absolute",
23085 BearingComponent.prototype._createCircleSector = function (fov, fill) {
23086 if (fov > 2 * Math.PI - Math.PI / 90) {
23087 return vd.h("circle", {
23088 attributes: { cx: "0", cy: "0", fill: fill, r: "1" },
23089 namespace: this._svgNamespace,
23092 var arcStart = -Math.PI / 2 - fov / 2;
23093 var arcEnd = arcStart + fov;
23094 var startX = Math.cos(arcStart);
23095 var startY = Math.sin(arcStart);
23096 var endX = Math.cos(arcEnd);
23097 var endY = Math.sin(arcEnd);
23098 var largeArc = fov >= Math.PI ? 1 : 0;
23099 var description = "M 0 0 " + startX + " " + startY + " A 1 1 0 " + largeArc + " 1 " + endX + " " + endY;
23100 return vd.h("path", {
23101 attributes: { d: description, fill: fill },
23102 namespace: this._svgNamespace,
23105 BearingComponent.prototype._createNorth = function (bearing) {
23106 var north = vd.h("div.BearingNorth", []);
23107 var container = vd.h("div.BearingNorthContainer", { style: { transform: "rotateZ(" + -bearing * 180 / Math.PI + "deg)" } }, [north]);
23110 BearingComponent.componentName = "bearing";
23111 return BearingComponent;
23112 }(Component_1.Component));
23113 exports.BearingComponent = BearingComponent;
23114 Component_1.ComponentService.register(BearingComponent);
23115 exports.default = BearingComponent;
23117 },{"../Component":275,"../Geo":278,"rxjs/operators":225,"virtual-dom":231}],292:[function(require,module,exports){
23119 var __extends = (this && this.__extends) || (function () {
23120 var extendStatics = function (d, b) {
23121 extendStatics = Object.setPrototypeOf ||
23122 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
23123 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
23124 return extendStatics(d, b);
23126 return function (d, b) {
23127 extendStatics(d, b);
23128 function __() { this.constructor = d; }
23129 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
23132 Object.defineProperty(exports, "__esModule", { value: true });
23133 var rxjs_1 = require("rxjs");
23134 var operators_1 = require("rxjs/operators");
23135 var Edge_1 = require("../Edge");
23136 var Component_1 = require("../Component");
23137 var CacheComponent = /** @class */ (function (_super) {
23138 __extends(CacheComponent, _super);
23139 function CacheComponent(name, container, navigator) {
23140 return _super.call(this, name, container, navigator) || this;
23143 * Set the cache depth.
23145 * Configures the cache depth. The cache depth can be different for
23146 * different edge direction types.
23148 * @param {ICacheDepth} depth - Cache depth structure.
23150 CacheComponent.prototype.setDepth = function (depth) {
23151 this.configure({ depth: depth });
23153 CacheComponent.prototype._activate = function () {
23155 this._sequenceSubscription = rxjs_1.combineLatest(this._navigator.stateService.currentNode$.pipe(operators_1.switchMap(function (node) {
23156 return node.sequenceEdges$;
23157 }), operators_1.filter(function (status) {
23158 return status.cached;
23159 })), this._configuration$).pipe(operators_1.switchMap(function (nc) {
23160 var status = nc[0];
23161 var configuration = nc[1];
23162 var sequenceDepth = Math.max(0, Math.min(4, configuration.depth.sequence));
23163 var next$ = _this._cache$(status.edges, Edge_1.EdgeDirection.Next, sequenceDepth);
23164 var prev$ = _this._cache$(status.edges, Edge_1.EdgeDirection.Prev, sequenceDepth);
23165 return rxjs_1.merge(next$, prev$).pipe(operators_1.catchError(function (error, caught) {
23166 console.error("Failed to cache sequence edges.", error);
23167 return rxjs_1.empty();
23170 .subscribe(function () { });
23171 this._spatialSubscription = rxjs_1.combineLatest(this._navigator.stateService.currentNode$.pipe(operators_1.switchMap(function (node) {
23172 return rxjs_1.combineLatest(rxjs_1.of(node), node.spatialEdges$.pipe(operators_1.filter(function (status) {
23173 return status.cached;
23175 })), this._configuration$).pipe(operators_1.switchMap(function (_a) {
23176 var _b = _a[0], node = _b[0], edgeStatus = _b[1], configuration = _a[1];
23177 var edges = edgeStatus.edges;
23178 var depth = configuration.depth;
23179 var panoDepth = Math.max(0, Math.min(2, depth.pano));
23180 var stepDepth = node.pano ? 0 : Math.max(0, Math.min(3, depth.step));
23181 var turnDepth = node.pano ? 0 : Math.max(0, Math.min(1, depth.turn));
23182 var pano$ = _this._cache$(edges, Edge_1.EdgeDirection.Pano, panoDepth);
23183 var forward$ = _this._cache$(edges, Edge_1.EdgeDirection.StepForward, stepDepth);
23184 var backward$ = _this._cache$(edges, Edge_1.EdgeDirection.StepBackward, stepDepth);
23185 var left$ = _this._cache$(edges, Edge_1.EdgeDirection.StepLeft, stepDepth);
23186 var right$ = _this._cache$(edges, Edge_1.EdgeDirection.StepRight, stepDepth);
23187 var turnLeft$ = _this._cache$(edges, Edge_1.EdgeDirection.TurnLeft, turnDepth);
23188 var turnRight$ = _this._cache$(edges, Edge_1.EdgeDirection.TurnRight, turnDepth);
23189 var turnU$ = _this._cache$(edges, Edge_1.EdgeDirection.TurnU, turnDepth);
23190 return rxjs_1.merge(forward$, backward$, left$, right$, pano$, turnLeft$, turnRight$, turnU$).pipe(operators_1.catchError(function (error, caught) {
23191 console.error("Failed to cache spatial edges.", error);
23192 return rxjs_1.empty();
23195 .subscribe(function () { });
23197 CacheComponent.prototype._deactivate = function () {
23198 this._sequenceSubscription.unsubscribe();
23199 this._spatialSubscription.unsubscribe();
23201 CacheComponent.prototype._getDefaultConfiguration = function () {
23202 return { depth: { pano: 1, sequence: 2, step: 1, turn: 0 } };
23204 CacheComponent.prototype._cache$ = function (edges, direction, depth) {
23206 return rxjs_1.zip(rxjs_1.of(edges), rxjs_1.of(depth)).pipe(operators_1.expand(function (ed) {
23209 var edgesDepths$ = [];
23211 for (var _i = 0, es_1 = es; _i < es_1.length; _i++) {
23212 var edge = es_1[_i];
23213 if (edge.data.direction === direction) {
23214 edgesDepths$.push(rxjs_1.zip(_this._navigator.graphService.cacheNode$(edge.to).pipe(operators_1.mergeMap(function (n) {
23215 return _this._nodeToEdges$(n, direction);
23216 })), rxjs_1.of(d - 1)));
23220 return rxjs_1.from(edgesDepths$).pipe(operators_1.mergeAll());
23221 }), operators_1.skip(1));
23223 CacheComponent.prototype._nodeToEdges$ = function (node, direction) {
23224 return ([Edge_1.EdgeDirection.Next, Edge_1.EdgeDirection.Prev].indexOf(direction) > -1 ?
23225 node.sequenceEdges$ :
23226 node.spatialEdges$).pipe(operators_1.first(function (status) {
23227 return status.cached;
23228 }), operators_1.map(function (status) {
23229 return status.edges;
23232 CacheComponent.componentName = "cache";
23233 return CacheComponent;
23234 }(Component_1.Component));
23235 exports.CacheComponent = CacheComponent;
23236 Component_1.ComponentService.register(CacheComponent);
23237 exports.default = CacheComponent;
23239 },{"../Component":275,"../Edge":276,"rxjs":27,"rxjs/operators":225}],293:[function(require,module,exports){
23241 var __extends = (this && this.__extends) || (function () {
23242 var extendStatics = function (d, b) {
23243 extendStatics = Object.setPrototypeOf ||
23244 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
23245 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
23246 return extendStatics(d, b);
23248 return function (d, b) {
23249 extendStatics(d, b);
23250 function __() { this.constructor = d; }
23251 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
23254 Object.defineProperty(exports, "__esModule", { value: true });
23255 var operators_1 = require("rxjs/operators");
23256 var rxjs_1 = require("rxjs");
23257 var Utils_1 = require("../Utils");
23258 var Component = /** @class */ (function (_super) {
23259 __extends(Component, _super);
23260 function Component(name, container, navigator) {
23261 var _this = _super.call(this) || this;
23262 _this._activated$ = new rxjs_1.BehaviorSubject(false);
23263 _this._configurationSubject$ = new rxjs_1.Subject();
23264 _this._activated = false;
23265 _this._container = container;
23266 _this._name = name;
23267 _this._navigator = navigator;
23268 _this._configuration$ =
23269 _this._configurationSubject$.pipe(operators_1.startWith(_this.defaultConfiguration), operators_1.scan(function (conf, newConf) {
23270 for (var key in newConf) {
23271 if (newConf.hasOwnProperty(key)) {
23272 conf[key] = newConf[key];
23276 }), operators_1.publishReplay(1), operators_1.refCount());
23277 _this._configuration$.subscribe(function () { });
23280 Object.defineProperty(Component.prototype, "activated", {
23282 return this._activated;
23287 Object.defineProperty(Component.prototype, "activated$", {
23290 return this._activated$;
23295 Object.defineProperty(Component.prototype, "defaultConfiguration", {
23297 * Get default configuration.
23299 * @returns {TConfiguration} Default configuration for component.
23302 return this._getDefaultConfiguration();
23307 Object.defineProperty(Component.prototype, "configuration$", {
23310 return this._configuration$;
23315 Object.defineProperty(Component.prototype, "name", {
23319 * @description The name of the component. Used when interacting with the
23320 * component through the Viewer's API.
23328 Component.prototype.activate = function (conf) {
23329 if (this._activated) {
23332 if (conf !== undefined) {
23333 this._configurationSubject$.next(conf);
23335 this._activated = true;
23337 this._activated$.next(true);
23339 Component.prototype.configure = function (conf) {
23340 this._configurationSubject$.next(conf);
23342 Component.prototype.deactivate = function () {
23343 if (!this._activated) {
23346 this._activated = false;
23347 this._deactivate();
23348 this._container.domRenderer.clear(this._name);
23349 this._container.glRenderer.clear(this._name);
23350 this._activated$.next(false);
23353 * Detect the viewer's new width and height and resize the component's
23354 * rendered elements accordingly if applicable.
23358 Component.prototype.resize = function () { return; };
23359 Component.componentName = "not_worthy";
23361 }(Utils_1.EventEmitter));
23362 exports.Component = Component;
23363 exports.default = Component;
23365 },{"../Utils":285,"rxjs":27,"rxjs/operators":225}],294:[function(require,module,exports){
23367 Object.defineProperty(exports, "__esModule", { value: true });
23368 var Error_1 = require("../Error");
23369 var ComponentService = /** @class */ (function () {
23370 function ComponentService(container, navigator) {
23371 this._components = {};
23372 for (var componentName in ComponentService.registeredComponents) {
23373 if (!ComponentService.registeredComponents.hasOwnProperty(componentName)) {
23376 var component = ComponentService.registeredComponents[componentName];
23377 this._components[componentName] = {
23379 component: new component(componentName, container, navigator),
23382 this._coverComponent = new ComponentService.registeredCoverComponent("cover", container, navigator);
23383 this._coverComponent.activate();
23384 this._coverActivated = true;
23386 ComponentService.register = function (component) {
23387 if (ComponentService.registeredComponents[component.componentName] === undefined) {
23388 ComponentService.registeredComponents[component.componentName] = component;
23391 ComponentService.registerCover = function (coverComponent) {
23392 ComponentService.registeredCoverComponent = coverComponent;
23394 Object.defineProperty(ComponentService.prototype, "coverActivated", {
23396 return this._coverActivated;
23401 ComponentService.prototype.activateCover = function () {
23402 if (this._coverActivated) {
23405 this._coverActivated = true;
23406 for (var componentName in this._components) {
23407 if (!this._components.hasOwnProperty(componentName)) {
23410 var component = this._components[componentName];
23411 if (component.active) {
23412 component.component.deactivate();
23416 ComponentService.prototype.deactivateCover = function () {
23417 if (!this._coverActivated) {
23420 this._coverActivated = false;
23421 for (var componentName in this._components) {
23422 if (!this._components.hasOwnProperty(componentName)) {
23425 var component = this._components[componentName];
23426 if (component.active) {
23427 component.component.activate();
23431 ComponentService.prototype.activate = function (name) {
23432 this._checkName(name);
23433 this._components[name].active = true;
23434 if (!this._coverActivated) {
23435 this.get(name).activate();
23438 ComponentService.prototype.configure = function (name, conf) {
23439 this._checkName(name);
23440 this.get(name).configure(conf);
23442 ComponentService.prototype.deactivate = function (name) {
23443 this._checkName(name);
23444 this._components[name].active = false;
23445 if (!this._coverActivated) {
23446 this.get(name).deactivate();
23449 ComponentService.prototype.get = function (name) {
23450 return this._components[name].component;
23452 ComponentService.prototype.getCover = function () {
23453 return this._coverComponent;
23455 ComponentService.prototype._checkName = function (name) {
23456 if (!(name in this._components)) {
23457 throw new Error_1.ArgumentMapillaryError("Component does not exist: " + name);
23460 ComponentService.registeredComponents = {};
23461 return ComponentService;
23463 exports.ComponentService = ComponentService;
23464 exports.default = ComponentService;
23466 },{"../Error":277}],295:[function(require,module,exports){
23468 var __extends = (this && this.__extends) || (function () {
23469 var extendStatics = function (d, b) {
23470 extendStatics = Object.setPrototypeOf ||
23471 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
23472 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
23473 return extendStatics(d, b);
23475 return function (d, b) {
23476 extendStatics(d, b);
23477 function __() { this.constructor = d; }
23478 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
23481 Object.defineProperty(exports, "__esModule", { value: true });
23482 var rxjs_1 = require("rxjs");
23483 var operators_1 = require("rxjs/operators");
23484 var vd = require("virtual-dom");
23485 var Component_1 = require("../Component");
23486 var Utils_1 = require("../Utils");
23487 var Viewer_1 = require("../Viewer");
23488 var CoverComponent = /** @class */ (function (_super) {
23489 __extends(CoverComponent, _super);
23490 function CoverComponent(name, container, navigator) {
23491 return _super.call(this, name, container, navigator) || this;
23493 CoverComponent.prototype._activate = function () {
23495 this._configuration$.pipe(operators_1.distinctUntilChanged(undefined, function (configuration) {
23496 return configuration.state;
23497 }), operators_1.switchMap(function (configuration) {
23498 return rxjs_1.combineLatest(rxjs_1.of(configuration.state), _this._navigator.stateService.currentNode$);
23499 }), operators_1.switchMap(function (_a) {
23500 var state = _a[0], node = _a[1];
23501 var keySrc$ = rxjs_1.combineLatest(rxjs_1.of(node.key), node.image$.pipe(operators_1.filter(function (image) {
23503 }), operators_1.map(function (image) {
23506 return state === Component_1.CoverState.Visible ? keySrc$.pipe(operators_1.first()) : keySrc$;
23507 }), operators_1.distinctUntilChanged(function (_a, _b) {
23508 var k1 = _a[0], s1 = _a[1];
23509 var k2 = _b[0], s2 = _b[1];
23510 return k1 === k2 && s1 === s2;
23511 }), operators_1.map(function (_a) {
23512 var key = _a[0], src = _a[1];
23513 return { key: key, src: src };
23515 .subscribe(this._configurationSubject$);
23516 this._renderSubscription = rxjs_1.combineLatest(this._configuration$, this._container.renderService.size$).pipe(operators_1.map(function (_a) {
23517 var configuration = _a[0], size = _a[1];
23518 if (!configuration.key) {
23519 return { name: _this._name, vnode: vd.h("div", []) };
23521 var compactClass = size.width <= 640 || size.height <= 480 ? ".CoverCompact" : "";
23522 if (configuration.state === Component_1.CoverState.Hidden) {
23523 var doneContainer = vd.h("div.CoverContainer.CoverDone" + compactClass, [_this._getCoverBackgroundVNode(configuration)]);
23524 return { name: _this._name, vnode: doneContainer };
23526 var container = vd.h("div.CoverContainer" + compactClass, [_this._getCoverButtonVNode(configuration)]);
23527 return { name: _this._name, vnode: container };
23529 .subscribe(this._container.domRenderer.render$);
23531 CoverComponent.prototype._deactivate = function () {
23532 this._renderSubscription.unsubscribe();
23533 this._keySubscription.unsubscribe();
23535 CoverComponent.prototype._getDefaultConfiguration = function () {
23536 return { state: Component_1.CoverState.Visible };
23538 CoverComponent.prototype._getCoverButtonVNode = function (configuration) {
23540 var cover = configuration.state === Component_1.CoverState.Loading ? "div.Cover.CoverLoading" : "div.Cover";
23541 var coverButton = vd.h("div.CoverButton", { onclick: function () { _this.configure({ state: Component_1.CoverState.Loading }); } }, [vd.h("div.CoverButtonIcon", [])]);
23542 var coverLogo = vd.h("a.CoverLogo", { href: Utils_1.Urls.explore, target: "_blank" }, []);
23543 return vd.h(cover, [this._getCoverBackgroundVNode(configuration), coverButton, coverLogo]);
23545 CoverComponent.prototype._getCoverBackgroundVNode = function (conf) {
23546 var url = conf.src != null ?
23547 conf.src : Utils_1.Urls.thumbnail(conf.key, Viewer_1.ImageSize.Size640);
23548 var properties = { style: { backgroundImage: "url(" + url + ")" } };
23550 if (conf.state === Component_1.CoverState.Loading) {
23551 children.push(vd.h("div.Spinner", {}, []));
23553 return vd.h("div.CoverBackground", properties, children);
23555 CoverComponent.componentName = "cover";
23556 return CoverComponent;
23557 }(Component_1.Component));
23558 exports.CoverComponent = CoverComponent;
23559 Component_1.ComponentService.registerCover(CoverComponent);
23560 exports.default = CoverComponent;
23562 },{"../Component":275,"../Utils":285,"../Viewer":286,"rxjs":27,"rxjs/operators":225,"virtual-dom":231}],296:[function(require,module,exports){
23564 var __extends = (this && this.__extends) || (function () {
23565 var extendStatics = function (d, b) {
23566 extendStatics = Object.setPrototypeOf ||
23567 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
23568 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
23569 return extendStatics(d, b);
23571 return function (d, b) {
23572 extendStatics(d, b);
23573 function __() { this.constructor = d; }
23574 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
23577 Object.defineProperty(exports, "__esModule", { value: true });
23578 var rxjs_1 = require("rxjs");
23579 var operators_1 = require("rxjs/operators");
23580 var vd = require("virtual-dom");
23581 var Component_1 = require("../Component");
23582 var DebugComponent = /** @class */ (function (_super) {
23583 __extends(DebugComponent, _super);
23584 function DebugComponent() {
23585 var _this = _super !== null && _super.apply(this, arguments) || this;
23586 _this._open$ = new rxjs_1.BehaviorSubject(false);
23589 DebugComponent.prototype._activate = function () {
23591 this._disposable = rxjs_1.combineLatest(this._navigator.stateService.currentState$, this._open$, this._navigator.imageLoadingService.loadstatus$).pipe(operators_1.map(function (_a) {
23592 var frame = _a[0], open = _a[1], loadStatus = _a[2];
23593 return { name: _this._name, vnode: _this._getDebugVNode(open, _this._getDebugInfo(frame, loadStatus)) };
23595 .subscribe(this._container.domRenderer.render$);
23597 DebugComponent.prototype._deactivate = function () {
23598 this._disposable.unsubscribe();
23600 DebugComponent.prototype._getDefaultConfiguration = function () {
23603 DebugComponent.prototype._getDebugInfo = function (frame, loadStatus) {
23605 ret.push(vd.h("h2", "Node"));
23606 if (frame.state.currentNode) {
23607 ret.push(vd.h("p", "currentNode: " + frame.state.currentNode.key));
23609 if (frame.state.previousNode) {
23610 ret.push(vd.h("p", "previousNode: " + frame.state.previousNode.key));
23612 ret.push(vd.h("h2", "Loading"));
23616 for (var key in loadStatus) {
23617 if (!loadStatus.hasOwnProperty(key)) {
23620 var status_1 = loadStatus[key];
23621 total += status_1.loaded;
23622 if (status_1.loaded !== status_1.total) {
23629 ret.push(vd.h("p", "Loaded Images: " + loaded));
23630 ret.push(vd.h("p", "Loading Images: " + loading));
23631 ret.push(vd.h("p", "Total bytes loaded: " + total));
23632 ret.push(vd.h("h2", "Camera"));
23633 ret.push(vd.h("p", "camera.position.x: " + frame.state.camera.position.x));
23634 ret.push(vd.h("p", "camera.position.y: " + frame.state.camera.position.y));
23635 ret.push(vd.h("p", "camera.position.z: " + frame.state.camera.position.z));
23636 ret.push(vd.h("p", "camera.lookat.x: " + frame.state.camera.lookat.x));
23637 ret.push(vd.h("p", "camera.lookat.y: " + frame.state.camera.lookat.y));
23638 ret.push(vd.h("p", "camera.lookat.z: " + frame.state.camera.lookat.z));
23639 ret.push(vd.h("p", "camera.up.x: " + frame.state.camera.up.x));
23640 ret.push(vd.h("p", "camera.up.y: " + frame.state.camera.up.y));
23641 ret.push(vd.h("p", "camera.up.z: " + frame.state.camera.up.z));
23644 DebugComponent.prototype._getDebugVNode = function (open, info) {
23646 return vd.h("div.Debug", {}, [
23647 vd.h("h2", {}, ["Debug"]),
23648 this._getDebugVNodeButton(open),
23649 vd.h("pre", {}, info),
23653 return this._getDebugVNodeButton(open);
23656 DebugComponent.prototype._getDebugVNodeButton = function (open) {
23657 var buttonText = open ? "Disable Debug" : "D";
23658 var buttonCssClass = open ? "" : ".DebugButtonFixed";
23660 return vd.h("button.DebugButton" + buttonCssClass, { onclick: this._closeDebugElement.bind(this) }, [buttonText]);
23663 return vd.h("button.DebugButton" + buttonCssClass, { onclick: this._openDebugElement.bind(this) }, [buttonText]);
23666 DebugComponent.prototype._closeDebugElement = function (open) {
23667 this._open$.next(false);
23669 DebugComponent.prototype._openDebugElement = function () {
23670 this._open$.next(true);
23672 DebugComponent.componentName = "debug";
23673 return DebugComponent;
23674 }(Component_1.Component));
23675 exports.DebugComponent = DebugComponent;
23676 Component_1.ComponentService.register(DebugComponent);
23677 exports.default = DebugComponent;
23679 },{"../Component":275,"rxjs":27,"rxjs/operators":225,"virtual-dom":231}],297:[function(require,module,exports){
23681 var __extends = (this && this.__extends) || (function () {
23682 var extendStatics = function (d, b) {
23683 extendStatics = Object.setPrototypeOf ||
23684 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
23685 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
23686 return extendStatics(d, b);
23688 return function (d, b) {
23689 extendStatics(d, b);
23690 function __() { this.constructor = d; }
23691 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
23694 Object.defineProperty(exports, "__esModule", { value: true });
23695 var rxjs_1 = require("rxjs");
23696 var operators_1 = require("rxjs/operators");
23697 var vd = require("virtual-dom");
23698 var Component_1 = require("../Component");
23699 var Utils_1 = require("../Utils");
23700 var ImageComponent = /** @class */ (function (_super) {
23701 __extends(ImageComponent, _super);
23702 function ImageComponent(name, container, navigator, dom) {
23703 var _this = _super.call(this, name, container, navigator) || this;
23704 _this._canvasId = container.id + "-" + _this._name;
23705 _this._dom = !!dom ? dom : new Utils_1.DOM();
23708 ImageComponent.prototype._activate = function () {
23710 var canvasSize$ = this._container.domRenderer.element$.pipe(operators_1.map(function (element) {
23711 return _this._dom.document.getElementById(_this._canvasId);
23712 }), operators_1.filter(function (canvas) {
23714 }), operators_1.map(function (canvas) {
23715 var adaptableDomRenderer = canvas.parentElement;
23716 var width = adaptableDomRenderer.offsetWidth;
23717 var height = adaptableDomRenderer.offsetHeight;
23718 return [canvas, { height: height, width: width }];
23719 }), operators_1.distinctUntilChanged(function (s1, s2) {
23720 return s1.height === s2.height && s1.width === s2.width;
23722 var canvas = _a[0], size = _a[1];
23725 this.drawSubscription = rxjs_1.combineLatest(canvasSize$, this._navigator.stateService.currentNode$)
23726 .subscribe(function (_a) {
23727 var _b = _a[0], canvas = _b[0], size = _b[1], node = _a[1];
23728 canvas.width = size.width;
23729 canvas.height = size.height;
23732 .drawImage(node.image, 0, 0, size.width, size.height);
23734 this._container.domRenderer.renderAdaptive$.next({ name: this._name, vnode: vd.h("canvas#" + this._canvasId, []) });
23736 ImageComponent.prototype._deactivate = function () {
23737 this.drawSubscription.unsubscribe();
23739 ImageComponent.prototype._getDefaultConfiguration = function () {
23742 ImageComponent.componentName = "image";
23743 return ImageComponent;
23744 }(Component_1.Component));
23745 exports.ImageComponent = ImageComponent;
23746 Component_1.ComponentService.register(ImageComponent);
23747 exports.default = ImageComponent;
23750 },{"../Component":275,"../Utils":285,"rxjs":27,"rxjs/operators":225,"virtual-dom":231}],298:[function(require,module,exports){
23752 var __extends = (this && this.__extends) || (function () {
23753 var extendStatics = function (d, b) {
23754 extendStatics = Object.setPrototypeOf ||
23755 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
23756 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
23757 return extendStatics(d, b);
23759 return function (d, b) {
23760 extendStatics(d, b);
23761 function __() { this.constructor = d; }
23762 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
23765 Object.defineProperty(exports, "__esModule", { value: true });
23766 var rxjs_1 = require("rxjs");
23767 var operators_1 = require("rxjs/operators");
23768 var vd = require("virtual-dom");
23769 var Component_1 = require("../Component");
23770 var LoadingComponent = /** @class */ (function (_super) {
23771 __extends(LoadingComponent, _super);
23772 function LoadingComponent(name, container, navigator) {
23773 return _super.call(this, name, container, navigator) || this;
23775 LoadingComponent.prototype._activate = function () {
23777 this._loadingSubscription = this._navigator.loadingService.loading$.pipe(operators_1.switchMap(function (loading) {
23779 _this._navigator.imageLoadingService.loadstatus$ :
23781 }), operators_1.map(function (loadStatus) {
23784 for (var key in loadStatus) {
23785 if (!loadStatus.hasOwnProperty(key)) {
23788 var status_1 = loadStatus[key];
23789 if (status_1.loaded !== status_1.total) {
23790 loaded += status_1.loaded;
23791 total += status_1.total;
23794 var percentage = 100;
23796 percentage = (loaded / total) * 100;
23798 return { name: _this._name, vnode: _this._getBarVNode(percentage) };
23800 .subscribe(this._container.domRenderer.render$);
23802 LoadingComponent.prototype._deactivate = function () {
23803 this._loadingSubscription.unsubscribe();
23805 LoadingComponent.prototype._getDefaultConfiguration = function () {
23808 LoadingComponent.prototype._getBarVNode = function (percentage) {
23809 var loadingBarStyle = {};
23810 var loadingContainerStyle = {};
23811 if (percentage !== 100) {
23812 loadingBarStyle.width = percentage.toFixed(0) + "%";
23813 loadingBarStyle.opacity = "1";
23816 loadingBarStyle.width = "100%";
23817 loadingBarStyle.opacity = "0";
23819 return vd.h("div.Loading", { style: loadingContainerStyle }, [vd.h("div.LoadingBar", { style: loadingBarStyle }, [])]);
23821 LoadingComponent.componentName = "loading";
23822 return LoadingComponent;
23823 }(Component_1.Component));
23824 exports.LoadingComponent = LoadingComponent;
23825 Component_1.ComponentService.register(LoadingComponent);
23826 exports.default = LoadingComponent;
23828 },{"../Component":275,"rxjs":27,"rxjs/operators":225,"virtual-dom":231}],299:[function(require,module,exports){
23830 var __extends = (this && this.__extends) || (function () {
23831 var extendStatics = function (d, b) {
23832 extendStatics = Object.setPrototypeOf ||
23833 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
23834 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
23835 return extendStatics(d, b);
23837 return function (d, b) {
23838 extendStatics(d, b);
23839 function __() { this.constructor = d; }
23840 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
23843 Object.defineProperty(exports, "__esModule", { value: true });
23844 var rxjs_1 = require("rxjs");
23845 var operators_1 = require("rxjs/operators");
23846 var vd = require("virtual-dom");
23847 var Edge_1 = require("../Edge");
23848 var Error_1 = require("../Error");
23849 var Component_1 = require("../Component");
23851 * @class NavigationComponent
23853 * @classdesc Fallback navigation component for environments without WebGL support.
23855 * Replaces the functionality in the Direction and Sequence components.
23857 var NavigationComponent = /** @class */ (function (_super) {
23858 __extends(NavigationComponent, _super);
23860 function NavigationComponent(name, container, navigator) {
23861 var _this = _super.call(this, name, container, navigator) || this;
23862 _this._seqNames = {};
23863 _this._seqNames[Edge_1.EdgeDirection[Edge_1.EdgeDirection.Prev]] = "Prev";
23864 _this._seqNames[Edge_1.EdgeDirection[Edge_1.EdgeDirection.Next]] = "Next";
23865 _this._spaTopNames = {};
23866 _this._spaTopNames[Edge_1.EdgeDirection[Edge_1.EdgeDirection.TurnLeft]] = "Turnleft";
23867 _this._spaTopNames[Edge_1.EdgeDirection[Edge_1.EdgeDirection.StepLeft]] = "Left";
23868 _this._spaTopNames[Edge_1.EdgeDirection[Edge_1.EdgeDirection.StepForward]] = "Forward";
23869 _this._spaTopNames[Edge_1.EdgeDirection[Edge_1.EdgeDirection.StepRight]] = "Right";
23870 _this._spaTopNames[Edge_1.EdgeDirection[Edge_1.EdgeDirection.TurnRight]] = "Turnright";
23871 _this._spaBottomNames = {};
23872 _this._spaBottomNames[Edge_1.EdgeDirection[Edge_1.EdgeDirection.TurnU]] = "Turnaround";
23873 _this._spaBottomNames[Edge_1.EdgeDirection[Edge_1.EdgeDirection.StepBackward]] = "Backward";
23876 NavigationComponent.prototype._activate = function () {
23878 this._renderSubscription = rxjs_1.combineLatest(this._navigator.stateService.currentNode$, this._configuration$).pipe(operators_1.switchMap(function (_a) {
23879 var node = _a[0], configuration = _a[1];
23880 var sequenceEdges$ = configuration.sequence ?
23881 node.sequenceEdges$.pipe(operators_1.map(function (status) {
23882 return status.edges
23883 .map(function (edge) {
23884 return edge.data.direction;
23888 var spatialEdges$ = !node.pano && configuration.spatial ?
23889 node.spatialEdges$.pipe(operators_1.map(function (status) {
23890 return status.edges
23891 .map(function (edge) {
23892 return edge.data.direction;
23896 return rxjs_1.combineLatest(sequenceEdges$, spatialEdges$).pipe(operators_1.map(function (_a) {
23897 var seq = _a[0], spa = _a[1];
23898 return seq.concat(spa);
23900 }), operators_1.map(function (edgeDirections) {
23901 var seqs = _this._createArrowRow(_this._seqNames, edgeDirections);
23902 var spaTops = _this._createArrowRow(_this._spaTopNames, edgeDirections);
23903 var spaBottoms = _this._createArrowRow(_this._spaBottomNames, edgeDirections);
23904 var seqContainer = vd.h("div.NavigationSequence", seqs);
23905 var spaTopContainer = vd.h("div.NavigationSpatialTop", spaTops);
23906 var spaBottomContainer = vd.h("div.NavigationSpatialBottom", spaBottoms);
23907 var spaContainer = vd.h("div.NavigationSpatial", [spaTopContainer, spaBottomContainer]);
23908 return { name: _this._name, vnode: vd.h("div.NavigationContainer", [seqContainer, spaContainer]) };
23910 .subscribe(this._container.domRenderer.render$);
23912 NavigationComponent.prototype._deactivate = function () {
23913 this._renderSubscription.unsubscribe();
23915 NavigationComponent.prototype._getDefaultConfiguration = function () {
23916 return { sequence: true, spatial: true };
23918 NavigationComponent.prototype._createArrowRow = function (arrowNames, edgeDirections) {
23920 for (var arrowName in arrowNames) {
23921 if (!(arrowNames.hasOwnProperty(arrowName))) {
23924 var direction = Edge_1.EdgeDirection[arrowName];
23925 if (edgeDirections.indexOf(direction) !== -1) {
23926 arrows.push(this._createVNode(direction, arrowNames[arrowName], "visible"));
23929 arrows.push(this._createVNode(direction, arrowNames[arrowName], "hidden"));
23934 NavigationComponent.prototype._createVNode = function (direction, name, visibility) {
23936 return vd.h("span.Direction.Direction" + name, {
23937 onclick: function (ev) {
23938 _this._navigator.moveDir$(direction)
23939 .subscribe(undefined, function (error) {
23940 if (!(error instanceof Error_1.AbortMapillaryError)) {
23941 console.error(error);
23946 visibility: visibility,
23950 NavigationComponent.componentName = "navigation";
23951 return NavigationComponent;
23952 }(Component_1.Component));
23953 exports.NavigationComponent = NavigationComponent;
23954 Component_1.ComponentService.register(NavigationComponent);
23955 exports.default = NavigationComponent;
23957 },{"../Component":275,"../Edge":276,"../Error":277,"rxjs":27,"rxjs/operators":225,"virtual-dom":231}],300:[function(require,module,exports){
23959 var __extends = (this && this.__extends) || (function () {
23960 var extendStatics = function (d, b) {
23961 extendStatics = Object.setPrototypeOf ||
23962 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
23963 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
23964 return extendStatics(d, b);
23966 return function (d, b) {
23967 extendStatics(d, b);
23968 function __() { this.constructor = d; }
23969 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
23972 Object.defineProperty(exports, "__esModule", { value: true });
23973 var rxjs_1 = require("rxjs");
23974 var operators_1 = require("rxjs/operators");
23975 var vd = require("virtual-dom");
23976 var Component_1 = require("../Component");
23977 var DescriptionState = /** @class */ (function () {
23978 function DescriptionState() {
23980 return DescriptionState;
23982 var RouteState = /** @class */ (function () {
23983 function RouteState() {
23987 var RouteTrack = /** @class */ (function () {
23988 function RouteTrack() {
23989 this.nodeInstructions = [];
23990 this.nodeInstructionsOrdered = [];
23994 var RouteComponent = /** @class */ (function (_super) {
23995 __extends(RouteComponent, _super);
23996 function RouteComponent(name, container, navigator) {
23997 return _super.call(this, name, container, navigator) || this;
23999 RouteComponent.prototype._activate = function () {
24001 var slowedStream$ = this._navigator.stateService.currentState$.pipe(operators_1.filter(function (frame) {
24002 return (frame.id % 2) === 0;
24003 }), operators_1.filter(function (frame) {
24004 return frame.state.nodesAhead < 15;
24005 }), operators_1.distinctUntilChanged(undefined, function (frame) {
24006 return frame.state.lastNode.key;
24008 var routeTrack$ = rxjs_1.combineLatest(this.configuration$.pipe(operators_1.mergeMap(function (conf) {
24009 return rxjs_1.from(conf.paths);
24010 }), operators_1.distinct(function (p) {
24011 return p.sequenceKey;
24012 }), operators_1.mergeMap(function (path) {
24013 return _this._navigator.apiV3.sequenceByKey$([path.sequenceKey]).pipe(operators_1.map(function (sequenceByKey) {
24014 return sequenceByKey[path.sequenceKey];
24016 })), this.configuration$).pipe(operators_1.map(function (_a) {
24017 var sequence = _a[0], conf = _a[1];
24019 var instructionPlaces = [];
24020 for (var _i = 0, _b = conf.paths; _i < _b.length; _i++) {
24022 if (path.sequenceKey === sequence.key) {
24023 var nodeInstructions = [];
24024 var saveKey = false;
24025 for (var _c = 0, _d = sequence.keys; _c < _d.length; _c++) {
24027 if (path.startKey === key) {
24031 var description = null;
24032 for (var _e = 0, _f = path.infoKeys; _e < _f.length; _e++) {
24033 var infoKey = _f[_e];
24034 if (infoKey.key === key) {
24035 description = infoKey.description;
24038 nodeInstructions.push({ description: description, key: key });
24040 if (path.stopKey === key) {
24044 instructionPlaces.push({ nodeInstructions: nodeInstructions, place: i });
24048 return instructionPlaces;
24049 }), operators_1.scan(function (routeTrack, instructionPlaces) {
24050 for (var _i = 0, instructionPlaces_1 = instructionPlaces; _i < instructionPlaces_1.length; _i++) {
24051 var instructionPlace = instructionPlaces_1[_i];
24052 routeTrack.nodeInstructionsOrdered[instructionPlace.place] = instructionPlace.nodeInstructions;
24054 for (var place in routeTrack.nodeInstructionsOrdered) {
24055 if (!routeTrack.nodeInstructionsOrdered.hasOwnProperty(place)) {
24058 var instructionGroup = routeTrack.nodeInstructionsOrdered[place];
24059 for (var _a = 0, instructionGroup_1 = instructionGroup; _a < instructionGroup_1.length; _a++) {
24060 var instruction = instructionGroup_1[_a];
24061 routeTrack.nodeInstructions.push(instruction);
24065 }, new RouteTrack()));
24066 var cacheNode$ = rxjs_1.combineLatest(slowedStream$, routeTrack$, this.configuration$).pipe(operators_1.map(function (_a) {
24067 var frame = _a[0], routeTrack = _a[1], conf = _a[2];
24068 return { conf: conf, frame: frame, routeTrack: routeTrack };
24069 }), operators_1.scan(function (routeState, rtAndFrame) {
24070 if (rtAndFrame.conf.playing === undefined || rtAndFrame.conf.playing) {
24071 routeState.routeTrack = rtAndFrame.routeTrack;
24072 routeState.currentNode = rtAndFrame.frame.state.currentNode;
24073 routeState.lastNode = rtAndFrame.frame.state.lastNode;
24074 routeState.playing = true;
24077 _this._navigator.stateService.cutNodes();
24078 routeState.playing = false;
24081 }, new RouteState()), operators_1.filter(function (routeState) {
24082 return routeState.playing;
24083 }), operators_1.filter(function (routeState) {
24084 for (var _i = 0, _a = routeState.routeTrack.nodeInstructions; _i < _a.length; _i++) {
24085 var nodeInstruction = _a[_i];
24086 if (!nodeInstruction) {
24089 if (nodeInstruction.key === routeState.lastNode.key) {
24094 }), operators_1.distinctUntilChanged(undefined, function (routeState) {
24095 return routeState.lastNode.key;
24096 }), operators_1.mergeMap(function (routeState) {
24098 for (var _i = 0, _a = routeState.routeTrack.nodeInstructions; _i < _a.length; _i++) {
24099 var nodeInstruction = _a[_i];
24100 if (nodeInstruction.key === routeState.lastNode.key) {
24105 var nextInstruction = routeState.routeTrack.nodeInstructions[i + 1];
24106 if (!nextInstruction) {
24107 return rxjs_1.of(null);
24109 return _this._navigator.graphService.cacheNode$(nextInstruction.key);
24111 this._disposable = rxjs_1.combineLatest(cacheNode$, this.configuration$).pipe(operators_1.map(function (_a) {
24112 var node = _a[0], conf = _a[1];
24113 return { conf: conf, node: node };
24114 }), operators_1.filter(function (cAN) {
24115 return cAN.node !== null && cAN.conf.playing;
24116 }), operators_1.pluck("node"))
24117 .subscribe(this._navigator.stateService.appendNode$);
24118 this._disposableDescription = rxjs_1.combineLatest(this._navigator.stateService.currentNode$, routeTrack$, this.configuration$).pipe(operators_1.map(function (_a) {
24119 var node = _a[0], routeTrack = _a[1], conf = _a[2];
24120 if (conf.playing !== undefined && !conf.playing) {
24123 var description = null;
24124 for (var _i = 0, _b = routeTrack.nodeInstructions; _i < _b.length; _i++) {
24125 var nodeInstruction = _b[_i];
24126 if (nodeInstruction.key === node.key) {
24127 description = nodeInstruction.description;
24131 return description;
24132 }), operators_1.scan(function (descriptionState, description) {
24133 if (description !== descriptionState.description && description !== null) {
24134 descriptionState.description = description;
24135 descriptionState.showsLeft = 6;
24138 descriptionState.showsLeft--;
24140 if (description === "quit") {
24141 descriptionState.description = null;
24143 return descriptionState;
24144 }, new DescriptionState()), operators_1.map(function (descriptionState) {
24145 if (descriptionState.showsLeft > 0 && descriptionState.description) {
24146 return { name: _this._name, vnode: _this._getRouteAnnotationNode(descriptionState.description) };
24149 return { name: _this._name, vnode: vd.h("div", []) };
24152 .subscribe(this._container.domRenderer.render$);
24154 RouteComponent.prototype._deactivate = function () {
24155 this._disposable.unsubscribe();
24156 this._disposableDescription.unsubscribe();
24158 RouteComponent.prototype._getDefaultConfiguration = function () {
24161 RouteComponent.prototype.play = function () {
24162 this.configure({ playing: true });
24164 RouteComponent.prototype.stop = function () {
24165 this.configure({ playing: false });
24167 RouteComponent.prototype._getRouteAnnotationNode = function (description) {
24168 return vd.h("div.RouteFrame", {}, [
24169 vd.h("p", { textContent: description }, []),
24172 RouteComponent.componentName = "route";
24173 return RouteComponent;
24174 }(Component_1.Component));
24175 exports.RouteComponent = RouteComponent;
24176 Component_1.ComponentService.register(RouteComponent);
24177 exports.default = RouteComponent;
24179 },{"../Component":275,"rxjs":27,"rxjs/operators":225,"virtual-dom":231}],301:[function(require,module,exports){
24181 var __extends = (this && this.__extends) || (function () {
24182 var extendStatics = function (d, b) {
24183 extendStatics = Object.setPrototypeOf ||
24184 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
24185 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
24186 return extendStatics(d, b);
24188 return function (d, b) {
24189 extendStatics(d, b);
24190 function __() { this.constructor = d; }
24191 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
24194 Object.defineProperty(exports, "__esModule", { value: true });
24195 var rxjs_1 = require("rxjs");
24196 var operators_1 = require("rxjs/operators");
24197 var Component_1 = require("../Component");
24198 var StatsComponent = /** @class */ (function (_super) {
24199 __extends(StatsComponent, _super);
24200 function StatsComponent(name, container, navigator, scheduler) {
24201 var _this = _super.call(this, name, container, navigator) || this;
24202 _this._scheduler = scheduler;
24205 StatsComponent.prototype._activate = function () {
24207 this._sequenceSubscription = this._navigator.stateService.currentNode$.pipe(operators_1.scan(function (keys, node) {
24208 var sKey = node.sequenceKey;
24210 if (!(sKey in keys.reported)) {
24211 keys.report = [sKey];
24212 keys.reported[sKey] = true;
24215 }, { report: [], reported: {} }), operators_1.filter(function (keys) {
24216 return keys.report.length > 0;
24217 }), operators_1.mergeMap(function (keys) {
24218 return _this._navigator.apiV3.sequenceViewAdd$(keys.report).pipe(operators_1.catchError(function (error, caught) {
24219 console.error("Failed to report sequence stats (" + keys.report + ")", error);
24220 return rxjs_1.empty();
24223 .subscribe(function () { });
24224 this._imageSubscription = this._navigator.stateService.currentNode$.pipe(operators_1.map(function (node) {
24226 })).pipe(operators_1.buffer(this._navigator.stateService.currentNode$.pipe(operators_1.debounceTime(5000, this._scheduler))), operators_1.scan(function (keys, newKeys) {
24228 for (var _i = 0, newKeys_1 = newKeys; _i < newKeys_1.length; _i++) {
24229 var key = newKeys_1[_i];
24230 if (!(key in keys.reported)) {
24231 keys.report.push(key);
24232 keys.reported[key] = true;
24236 }, { report: [], reported: {} }), operators_1.filter(function (keys) {
24237 return keys.report.length > 0;
24238 }), operators_1.mergeMap(function (keys) {
24239 return _this._navigator.apiV3.imageViewAdd$(keys.report).pipe(operators_1.catchError(function (error, caught) {
24240 console.error("Failed to report image stats (" + keys.report + ")", error);
24241 return rxjs_1.empty();
24244 .subscribe(function () { });
24246 StatsComponent.prototype._deactivate = function () {
24247 this._sequenceSubscription.unsubscribe();
24248 this._imageSubscription.unsubscribe();
24250 StatsComponent.prototype._getDefaultConfiguration = function () {
24253 StatsComponent.componentName = "stats";
24254 return StatsComponent;
24255 }(Component_1.Component));
24256 exports.StatsComponent = StatsComponent;
24257 Component_1.ComponentService.register(StatsComponent);
24258 exports.default = StatsComponent;
24260 },{"../Component":275,"rxjs":27,"rxjs/operators":225}],302:[function(require,module,exports){
24262 var __extends = (this && this.__extends) || (function () {
24263 var extendStatics = function (d, b) {
24264 extendStatics = Object.setPrototypeOf ||
24265 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
24266 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
24267 return extendStatics(d, b);
24269 return function (d, b) {
24270 extendStatics(d, b);
24271 function __() { this.constructor = d; }
24272 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
24275 Object.defineProperty(exports, "__esModule", { value: true });
24276 var vd = require("virtual-dom");
24277 var rxjs_1 = require("rxjs");
24278 var operators_1 = require("rxjs/operators");
24279 var Component_1 = require("../../Component");
24281 * @class DirectionComponent
24282 * @classdesc Component showing navigation arrows for steps and turns.
24284 var DirectionComponent = /** @class */ (function (_super) {
24285 __extends(DirectionComponent, _super);
24286 function DirectionComponent(name, container, navigator, directionDOMRenderer) {
24287 var _this = _super.call(this, name, container, navigator) || this;
24288 _this._renderer = !!directionDOMRenderer ?
24289 directionDOMRenderer :
24290 new Component_1.DirectionDOMRenderer(_this.defaultConfiguration, { height: container.element.offsetHeight, width: container.element.offsetWidth });
24291 _this._hoveredKeySubject$ = new rxjs_1.Subject();
24292 _this._hoveredKey$ = _this._hoveredKeySubject$.pipe(operators_1.share());
24295 Object.defineProperty(DirectionComponent.prototype, "hoveredKey$", {
24297 * Get hovered key observable.
24299 * @description An observable emitting the key of the node for the direction
24300 * arrow that is being hovered. When the mouse leaves a direction arrow null
24303 * @returns {Observable<string>}
24306 return this._hoveredKey$;
24312 * Set highlight key.
24314 * @description The arrow pointing towards the node corresponding to the
24315 * highlight key will be highlighted.
24317 * @param {string} highlightKey Key of node to be highlighted if existing
24320 DirectionComponent.prototype.setHighlightKey = function (highlightKey) {
24321 this.configure({ highlightKey: highlightKey });
24324 * Set min width of container element.
24326 * @description Set min width of the non transformed container element holding
24327 * the navigation arrows. If the min width is larger than the max width the
24328 * min width value will be used.
24330 * The container element is automatically resized when the resize
24331 * method on the Viewer class is called.
24333 * @param {number} minWidth
24335 DirectionComponent.prototype.setMinWidth = function (minWidth) {
24336 this.configure({ minWidth: minWidth });
24339 * Set max width of container element.
24341 * @description Set max width of the non transformed container element holding
24342 * the navigation arrows. If the min width is larger than the max width the
24343 * min width value will be used.
24345 * The container element is automatically resized when the resize
24346 * method on the Viewer class is called.
24348 * @param {number} minWidth
24350 DirectionComponent.prototype.setMaxWidth = function (maxWidth) {
24351 this.configure({ maxWidth: maxWidth });
24353 DirectionComponent.prototype._activate = function () {
24355 this._configurationSubscription = this._configuration$
24356 .subscribe(function (configuration) {
24357 _this._renderer.setConfiguration(configuration);
24359 this._resizeSubscription = this._container.renderService.size$
24360 .subscribe(function (size) {
24361 _this._renderer.resize(size);
24363 this._nodeSubscription = this._navigator.stateService.currentNode$.pipe(operators_1.tap(function (node) {
24364 _this._container.domRenderer.render$.next({ name: _this._name, vnode: vd.h("div", {}, []) });
24365 _this._renderer.setNode(node);
24366 }), operators_1.withLatestFrom(this._configuration$), operators_1.switchMap(function (_a) {
24367 var node = _a[0], configuration = _a[1];
24368 return rxjs_1.combineLatest(node.spatialEdges$, configuration.distinguishSequence ?
24369 _this._navigator.graphService
24370 .cacheSequence$(node.sequenceKey).pipe(operators_1.catchError(function (error, caught) {
24371 console.error("Failed to cache sequence (" + node.sequenceKey + ")", error);
24372 return rxjs_1.of(null);
24376 .subscribe(function (_a) {
24377 var edgeStatus = _a[0], sequence = _a[1];
24378 _this._renderer.setEdges(edgeStatus, sequence);
24380 this._renderCameraSubscription = this._container.renderService.renderCameraFrame$.pipe(operators_1.tap(function (renderCamera) {
24381 _this._renderer.setRenderCamera(renderCamera);
24382 }), operators_1.map(function () {
24383 return _this._renderer;
24384 }), operators_1.filter(function (renderer) {
24385 return renderer.needsRender;
24386 }), operators_1.map(function (renderer) {
24387 return { name: _this._name, vnode: renderer.render(_this._navigator) };
24389 .subscribe(this._container.domRenderer.render$);
24390 this._hoveredKeySubscription = rxjs_1.combineLatest(this._container.domRenderer.element$, this._container.renderService.renderCamera$, this._container.mouseService.mouseMove$.pipe(operators_1.startWith(null)), this._container.mouseService.mouseUp$.pipe(operators_1.startWith(null))).pipe(operators_1.map(function (_a) {
24391 var element = _a[0];
24392 var elements = element.getElementsByClassName("DirectionsPerspective");
24393 for (var i = 0; i < elements.length; i++) {
24394 var hovered = elements.item(i).querySelector(":hover");
24395 if (hovered != null && hovered.hasAttribute("data-key")) {
24396 return hovered.getAttribute("data-key");
24400 }), operators_1.distinctUntilChanged())
24401 .subscribe(this._hoveredKeySubject$);
24402 this._emitHoveredKeySubscription = this._hoveredKey$
24403 .subscribe(function (key) {
24404 _this.fire(DirectionComponent.hoveredkeychanged, key);
24407 DirectionComponent.prototype._deactivate = function () {
24408 this._configurationSubscription.unsubscribe();
24409 this._emitHoveredKeySubscription.unsubscribe();
24410 this._hoveredKeySubscription.unsubscribe();
24411 this._nodeSubscription.unsubscribe();
24412 this._renderCameraSubscription.unsubscribe();
24414 DirectionComponent.prototype._getDefaultConfiguration = function () {
24416 distinguishSequence: false,
24422 DirectionComponent.componentName = "direction";
24424 * Event fired when the hovered key changes.
24426 * @description Emits the key of the node for the direction
24427 * arrow that is being hovered. When the mouse leaves a
24428 * direction arrow null is emitted.
24430 * @event DirectionComponent#hoveredkeychanged
24431 * @type {string} The hovered key, null if no key is hovered.
24433 DirectionComponent.hoveredkeychanged = "hoveredkeychanged";
24434 return DirectionComponent;
24435 }(Component_1.Component));
24436 exports.DirectionComponent = DirectionComponent;
24437 Component_1.ComponentService.register(DirectionComponent);
24438 exports.default = DirectionComponent;
24441 },{"../../Component":275,"rxjs":27,"rxjs/operators":225,"virtual-dom":231}],303:[function(require,module,exports){
24443 Object.defineProperty(exports, "__esModule", { value: true });
24444 var Geo_1 = require("../../Geo");
24446 * @class DirectionDOMCalculator
24447 * @classdesc Helper class for calculating DOM CSS properties.
24449 var DirectionDOMCalculator = /** @class */ (function () {
24450 function DirectionDOMCalculator(configuration, size) {
24451 this._spatial = new Geo_1.Spatial();
24452 this._minThresholdWidth = 320;
24453 this._maxThresholdWidth = 1480;
24454 this._minThresholdHeight = 240;
24455 this._maxThresholdHeight = 820;
24456 this._configure(configuration);
24457 this._resize(size);
24460 Object.defineProperty(DirectionDOMCalculator.prototype, "minWidth", {
24462 return this._minWidth;
24467 Object.defineProperty(DirectionDOMCalculator.prototype, "maxWidth", {
24469 return this._maxWidth;
24474 Object.defineProperty(DirectionDOMCalculator.prototype, "containerWidth", {
24476 return this._containerWidth;
24481 Object.defineProperty(DirectionDOMCalculator.prototype, "containerWidthCss", {
24483 return this._containerWidthCss;
24488 Object.defineProperty(DirectionDOMCalculator.prototype, "containerMarginCss", {
24490 return this._containerMarginCss;
24495 Object.defineProperty(DirectionDOMCalculator.prototype, "containerLeftCss", {
24497 return this._containerLeftCss;
24502 Object.defineProperty(DirectionDOMCalculator.prototype, "containerHeight", {
24504 return this._containerHeight;
24509 Object.defineProperty(DirectionDOMCalculator.prototype, "containerHeightCss", {
24511 return this._containerHeightCss;
24516 Object.defineProperty(DirectionDOMCalculator.prototype, "containerBottomCss", {
24518 return this._containerBottomCss;
24523 Object.defineProperty(DirectionDOMCalculator.prototype, "stepCircleSize", {
24525 return this._stepCircleSize;
24530 Object.defineProperty(DirectionDOMCalculator.prototype, "stepCircleSizeCss", {
24532 return this._stepCircleSizeCss;
24537 Object.defineProperty(DirectionDOMCalculator.prototype, "stepCircleMarginCss", {
24539 return this._stepCircleMarginCss;
24544 Object.defineProperty(DirectionDOMCalculator.prototype, "turnCircleSize", {
24546 return this._turnCircleSize;
24551 Object.defineProperty(DirectionDOMCalculator.prototype, "turnCircleSizeCss", {
24553 return this._turnCircleSizeCss;
24558 Object.defineProperty(DirectionDOMCalculator.prototype, "outerRadius", {
24560 return this._outerRadius;
24565 Object.defineProperty(DirectionDOMCalculator.prototype, "innerRadius", {
24567 return this._innerRadius;
24572 Object.defineProperty(DirectionDOMCalculator.prototype, "shadowOffset", {
24574 return this._shadowOffset;
24580 * Configures the min and max width values.
24582 * @param {IDirectionConfiguration} configuration Configuration
24583 * with min and max width values.
24585 DirectionDOMCalculator.prototype.configure = function (configuration) {
24586 this._configure(configuration);
24590 * Resizes all properties according to the width and height
24591 * of the size object.
24593 * @param {ISize} size The size of the container element.
24595 DirectionDOMCalculator.prototype.resize = function (size) {
24596 this._resize(size);
24600 * Calculates the coordinates on the unit circle for an angle.
24602 * @param {number} angle Angle in radians.
24603 * @returns {Array<number>} The x and y coordinates on the unit circle.
24605 DirectionDOMCalculator.prototype.angleToCoordinates = function (angle) {
24606 return [Math.cos(angle), Math.sin(angle)];
24609 * Calculates the coordinates on the unit circle for the
24610 * relative angle between the first and second angle.
24612 * @param {number} first Angle in radians.
24613 * @param {number} second Angle in radians.
24614 * @returns {Array<number>} The x and y coordinates on the unit circle
24615 * for the relative angle between the first and second angle.
24617 DirectionDOMCalculator.prototype.relativeAngleToCoordiantes = function (first, second) {
24618 var relativeAngle = this._spatial.wrapAngle(first - second);
24619 return this.angleToCoordinates(relativeAngle);
24621 DirectionDOMCalculator.prototype._configure = function (configuration) {
24622 this._minWidth = configuration.minWidth;
24623 this._maxWidth = this._getMaxWidth(configuration.minWidth, configuration.maxWidth);
24625 DirectionDOMCalculator.prototype._resize = function (size) {
24626 this._elementWidth = size.width;
24627 this._elementHeight = size.height;
24629 DirectionDOMCalculator.prototype._reset = function () {
24630 this._containerWidth = this._getContainerWidth(this._elementWidth, this._elementHeight);
24631 this._containerHeight = this._getContainerHeight(this.containerWidth);
24632 this._stepCircleSize = this._getStepCircleDiameter(this._containerHeight);
24633 this._turnCircleSize = this._getTurnCircleDiameter(this.containerHeight);
24634 this._outerRadius = this._getOuterRadius(this._containerHeight);
24635 this._innerRadius = this._getInnerRadius(this._containerHeight);
24636 this._shadowOffset = 3;
24637 this._containerWidthCss = this._numberToCssPixels(this._containerWidth);
24638 this._containerMarginCss = this._numberToCssPixels(-0.5 * this._containerWidth);
24639 this._containerLeftCss = this._numberToCssPixels(Math.floor(0.5 * this._elementWidth));
24640 this._containerHeightCss = this._numberToCssPixels(this._containerHeight);
24641 this._containerBottomCss = this._numberToCssPixels(Math.floor(-0.08 * this._containerHeight));
24642 this._stepCircleSizeCss = this._numberToCssPixels(this._stepCircleSize);
24643 this._stepCircleMarginCss = this._numberToCssPixels(-0.5 * this._stepCircleSize);
24644 this._turnCircleSizeCss = this._numberToCssPixels(this._turnCircleSize);
24646 DirectionDOMCalculator.prototype._getContainerWidth = function (elementWidth, elementHeight) {
24647 var relativeWidth = (elementWidth - this._minThresholdWidth) / (this._maxThresholdWidth - this._minThresholdWidth);
24648 var relativeHeight = (elementHeight - this._minThresholdHeight) / (this._maxThresholdHeight - this._minThresholdHeight);
24649 var coeff = Math.max(0, Math.min(1, Math.min(relativeWidth, relativeHeight)));
24650 coeff = 0.04 * Math.round(25 * coeff);
24651 return this._minWidth + coeff * (this._maxWidth - this._minWidth);
24653 DirectionDOMCalculator.prototype._getContainerHeight = function (containerWidth) {
24654 return 0.77 * containerWidth;
24656 DirectionDOMCalculator.prototype._getStepCircleDiameter = function (containerHeight) {
24657 return 0.34 * containerHeight;
24659 DirectionDOMCalculator.prototype._getTurnCircleDiameter = function (containerHeight) {
24660 return 0.3 * containerHeight;
24662 DirectionDOMCalculator.prototype._getOuterRadius = function (containerHeight) {
24663 return 0.31 * containerHeight;
24665 DirectionDOMCalculator.prototype._getInnerRadius = function (containerHeight) {
24666 return 0.125 * containerHeight;
24668 DirectionDOMCalculator.prototype._numberToCssPixels = function (value) {
24669 return value + "px";
24671 DirectionDOMCalculator.prototype._getMaxWidth = function (value, minWidth) {
24672 return value > minWidth ? value : minWidth;
24674 return DirectionDOMCalculator;
24676 exports.DirectionDOMCalculator = DirectionDOMCalculator;
24677 exports.default = DirectionDOMCalculator;
24680 },{"../../Geo":278}],304:[function(require,module,exports){
24682 Object.defineProperty(exports, "__esModule", { value: true });
24683 var vd = require("virtual-dom");
24684 var Component_1 = require("../../Component");
24685 var Edge_1 = require("../../Edge");
24686 var Error_1 = require("../../Error");
24687 var Geo_1 = require("../../Geo");
24689 * @class DirectionDOMRenderer
24690 * @classdesc DOM renderer for direction arrows.
24692 var DirectionDOMRenderer = /** @class */ (function () {
24693 function DirectionDOMRenderer(configuration, size) {
24694 this._isEdge = false;
24695 this._spatial = new Geo_1.Spatial();
24696 this._calculator = new Component_1.DirectionDOMCalculator(configuration, size);
24698 this._rotation = { phi: 0, theta: 0 };
24699 this._epsilon = 0.5 * Math.PI / 180;
24700 this._highlightKey = null;
24701 this._distinguishSequence = false;
24702 this._needsRender = false;
24703 this._stepEdges = [];
24704 this._turnEdges = [];
24705 this._panoEdges = [];
24706 this._sequenceEdgeKeys = [];
24707 this._stepDirections = [
24708 Edge_1.EdgeDirection.StepForward,
24709 Edge_1.EdgeDirection.StepBackward,
24710 Edge_1.EdgeDirection.StepLeft,
24711 Edge_1.EdgeDirection.StepRight,
24713 this._turnDirections = [
24714 Edge_1.EdgeDirection.TurnLeft,
24715 Edge_1.EdgeDirection.TurnRight,
24716 Edge_1.EdgeDirection.TurnU,
24718 this._turnNames = {};
24719 this._turnNames[Edge_1.EdgeDirection.TurnLeft] = "TurnLeft";
24720 this._turnNames[Edge_1.EdgeDirection.TurnRight] = "TurnRight";
24721 this._turnNames[Edge_1.EdgeDirection.TurnU] = "TurnAround";
24722 // detects IE 8-11, then Edge 20+.
24723 var isIE = !!document.documentMode;
24724 this._isEdge = !isIE && !!window.StyleMedia;
24726 Object.defineProperty(DirectionDOMRenderer.prototype, "needsRender", {
24728 * Get needs render.
24730 * @returns {boolean} Value indicating whether render should be called.
24733 return this._needsRender;
24739 * Renders virtual DOM elements.
24741 * @description Calling render resets the needs render property.
24743 DirectionDOMRenderer.prototype.render = function (navigator) {
24744 this._needsRender = false;
24745 var rotation = this._rotation;
24748 if (this._node.pano) {
24749 steps = steps.concat(this._createPanoArrows(navigator, rotation));
24752 steps = steps.concat(this._createPerspectiveToPanoArrows(navigator, rotation));
24753 steps = steps.concat(this._createStepArrows(navigator, rotation));
24754 turns = turns.concat(this._createTurnArrows(navigator));
24756 return this._getContainer(steps, turns, rotation);
24758 DirectionDOMRenderer.prototype.setEdges = function (edgeStatus, sequence) {
24759 this._setEdges(edgeStatus, sequence);
24760 this._setNeedsRender();
24763 * Set node for which to show edges.
24765 * @param {Node} node
24767 DirectionDOMRenderer.prototype.setNode = function (node) {
24769 this._clearEdges();
24770 this._setNeedsRender();
24773 * Set the render camera to use for calculating rotations.
24775 * @param {RenderCamera} renderCamera
24777 DirectionDOMRenderer.prototype.setRenderCamera = function (renderCamera) {
24778 var rotation = renderCamera.rotation;
24779 if (Math.abs(rotation.phi - this._rotation.phi) < this._epsilon) {
24782 this._rotation = rotation;
24783 this._setNeedsRender();
24786 * Set configuration values.
24788 * @param {IDirectionConfiguration} configuration
24790 DirectionDOMRenderer.prototype.setConfiguration = function (configuration) {
24791 var needsRender = false;
24792 if (this._highlightKey !== configuration.highlightKey ||
24793 this._distinguishSequence !== configuration.distinguishSequence) {
24794 this._highlightKey = configuration.highlightKey;
24795 this._distinguishSequence = configuration.distinguishSequence;
24796 needsRender = true;
24798 if (this._calculator.minWidth !== configuration.minWidth ||
24799 this._calculator.maxWidth !== configuration.maxWidth) {
24800 this._calculator.configure(configuration);
24801 needsRender = true;
24804 this._setNeedsRender();
24808 * Detect the element's width and height and resize
24809 * elements accordingly.
24811 * @param {ISize} size Size of vßiewer container element.
24813 DirectionDOMRenderer.prototype.resize = function (size) {
24814 this._calculator.resize(size);
24815 this._setNeedsRender();
24817 DirectionDOMRenderer.prototype._setNeedsRender = function () {
24818 if (this._node != null) {
24819 this._needsRender = true;
24822 DirectionDOMRenderer.prototype._clearEdges = function () {
24823 this._stepEdges = [];
24824 this._turnEdges = [];
24825 this._panoEdges = [];
24826 this._sequenceEdgeKeys = [];
24828 DirectionDOMRenderer.prototype._setEdges = function (edgeStatus, sequence) {
24829 this._stepEdges = [];
24830 this._turnEdges = [];
24831 this._panoEdges = [];
24832 this._sequenceEdgeKeys = [];
24833 for (var _i = 0, _a = edgeStatus.edges; _i < _a.length; _i++) {
24835 var direction = edge.data.direction;
24836 if (this._stepDirections.indexOf(direction) > -1) {
24837 this._stepEdges.push(edge);
24840 if (this._turnDirections.indexOf(direction) > -1) {
24841 this._turnEdges.push(edge);
24844 if (edge.data.direction === Edge_1.EdgeDirection.Pano) {
24845 this._panoEdges.push(edge);
24848 if (this._distinguishSequence && sequence != null) {
24849 var edges = this._panoEdges
24850 .concat(this._stepEdges)
24851 .concat(this._turnEdges);
24852 for (var _b = 0, edges_1 = edges; _b < edges_1.length; _b++) {
24853 var edge = edges_1[_b];
24854 var edgeKey = edge.to;
24855 for (var _c = 0, _d = sequence.keys; _c < _d.length; _c++) {
24856 var sequenceKey = _d[_c];
24857 if (sequenceKey === edgeKey) {
24858 this._sequenceEdgeKeys.push(edgeKey);
24865 DirectionDOMRenderer.prototype._createPanoArrows = function (navigator, rotation) {
24867 for (var _i = 0, _a = this._panoEdges; _i < _a.length; _i++) {
24868 var panoEdge = _a[_i];
24869 arrows.push(this._createVNodeByKey(navigator, panoEdge.to, panoEdge.data.worldMotionAzimuth, rotation, this._calculator.outerRadius, "DirectionsArrowPano"));
24871 for (var _b = 0, _c = this._stepEdges; _b < _c.length; _b++) {
24872 var stepEdge = _c[_b];
24873 arrows.push(this._createPanoToPerspectiveArrow(navigator, stepEdge.to, stepEdge.data.worldMotionAzimuth, rotation, stepEdge.data.direction));
24877 DirectionDOMRenderer.prototype._createPanoToPerspectiveArrow = function (navigator, key, azimuth, rotation, direction) {
24878 var threshold = Math.PI / 8;
24879 var relativePhi = rotation.phi;
24880 switch (direction) {
24881 case Edge_1.EdgeDirection.StepBackward:
24882 relativePhi = rotation.phi - Math.PI;
24884 case Edge_1.EdgeDirection.StepLeft:
24885 relativePhi = rotation.phi + Math.PI / 2;
24887 case Edge_1.EdgeDirection.StepRight:
24888 relativePhi = rotation.phi - Math.PI / 2;
24893 if (Math.abs(this._spatial.wrapAngle(azimuth - relativePhi)) < threshold) {
24894 return this._createVNodeByKey(navigator, key, azimuth, rotation, this._calculator.outerRadius, "DirectionsArrowStep");
24896 return this._createVNodeDisabled(key, azimuth, rotation);
24898 DirectionDOMRenderer.prototype._createPerspectiveToPanoArrows = function (navigator, rotation) {
24900 for (var _i = 0, _a = this._panoEdges; _i < _a.length; _i++) {
24901 var panoEdge = _a[_i];
24902 arrows.push(this._createVNodeByKey(navigator, panoEdge.to, panoEdge.data.worldMotionAzimuth, rotation, this._calculator.innerRadius, "DirectionsArrowPano", true));
24906 DirectionDOMRenderer.prototype._createStepArrows = function (navigator, rotation) {
24908 for (var _i = 0, _a = this._stepEdges; _i < _a.length; _i++) {
24909 var stepEdge = _a[_i];
24910 arrows.push(this._createVNodeByDirection(navigator, stepEdge.to, stepEdge.data.worldMotionAzimuth, rotation, stepEdge.data.direction));
24914 DirectionDOMRenderer.prototype._createTurnArrows = function (navigator) {
24916 for (var _i = 0, _a = this._turnEdges; _i < _a.length; _i++) {
24917 var turnEdge = _a[_i];
24918 var direction = turnEdge.data.direction;
24919 var name_1 = this._turnNames[direction];
24920 turns.push(this._createVNodeByTurn(navigator, turnEdge.to, name_1, direction));
24924 DirectionDOMRenderer.prototype._createVNodeByKey = function (navigator, key, azimuth, rotation, offset, className, shiftVertically) {
24925 var onClick = function (e) {
24926 navigator.moveToKey$(key)
24927 .subscribe(undefined, function (error) {
24928 if (!(error instanceof Error_1.AbortMapillaryError)) {
24929 console.error(error);
24933 return this._createVNode(key, azimuth, rotation, offset, className, "DirectionsCircle", onClick, shiftVertically);
24935 DirectionDOMRenderer.prototype._createVNodeByDirection = function (navigator, key, azimuth, rotation, direction) {
24936 var onClick = function (e) {
24937 navigator.moveDir$(direction)
24938 .subscribe(undefined, function (error) {
24939 if (!(error instanceof Error_1.AbortMapillaryError)) {
24940 console.error(error);
24944 return this._createVNode(key, azimuth, rotation, this._calculator.outerRadius, "DirectionsArrowStep", "DirectionsCircle", onClick);
24946 DirectionDOMRenderer.prototype._createVNodeByTurn = function (navigator, key, className, direction) {
24947 var onClick = function (e) {
24948 navigator.moveDir$(direction)
24949 .subscribe(undefined, function (error) {
24950 if (!(error instanceof Error_1.AbortMapillaryError)) {
24951 console.error(error);
24956 height: this._calculator.turnCircleSizeCss,
24957 transform: "rotate(0)",
24958 width: this._calculator.turnCircleSizeCss,
24960 switch (direction) {
24961 case Edge_1.EdgeDirection.TurnLeft:
24962 style.left = "5px";
24965 case Edge_1.EdgeDirection.TurnRight:
24966 style.right = "5px";
24969 case Edge_1.EdgeDirection.TurnU:
24970 style.left = "5px";
24971 style.bottom = "5px";
24976 var circleProperties = {
24983 var circleClassName = "TurnCircle";
24984 if (this._sequenceEdgeKeys.indexOf(key) > -1) {
24985 circleClassName += "Sequence";
24987 if (this._highlightKey === key) {
24988 circleClassName += "Highlight";
24990 var turn = vd.h("div." + className, {}, []);
24991 return vd.h("div." + circleClassName, circleProperties, [turn]);
24993 DirectionDOMRenderer.prototype._createVNodeDisabled = function (key, azimuth, rotation) {
24994 return this._createVNode(key, azimuth, rotation, this._calculator.outerRadius, "DirectionsArrowDisabled", "DirectionsCircleDisabled");
24996 DirectionDOMRenderer.prototype._createVNode = function (key, azimuth, rotation, radius, className, circleClassName, onClick, shiftVertically) {
24997 var translation = this._calculator.angleToCoordinates(azimuth - rotation.phi);
24998 // rotate 90 degrees clockwise and flip over X-axis
24999 var translationX = Math.round(-radius * translation[1] + 0.5 * this._calculator.containerWidth);
25000 var translationY = Math.round(-radius * translation[0] + 0.5 * this._calculator.containerHeight);
25001 var shadowTranslation = this._calculator.relativeAngleToCoordiantes(azimuth, rotation.phi);
25002 var shadowOffset = this._calculator.shadowOffset;
25003 var shadowTranslationX = -shadowOffset * shadowTranslation[1];
25004 var shadowTranslationY = shadowOffset * shadowTranslation[0];
25005 var filter = "drop-shadow(" + shadowTranslationX + "px " + shadowTranslationY + "px 1px rgba(0,0,0,0.8))";
25008 "-webkit-filter": filter,
25012 var chevron = vd.h("div." + className, properties, []);
25013 var azimuthDeg = -this._spatial.radToDeg(azimuth - rotation.phi);
25014 var circleTransform = shiftVertically ?
25015 "translate(" + translationX + "px, " + translationY + "px) rotate(" + azimuthDeg + "deg) translateZ(-0.01px)" :
25016 "translate(" + translationX + "px, " + translationY + "px) rotate(" + azimuthDeg + "deg)";
25017 var circleProperties = {
25018 attributes: { "data-key": key },
25021 height: this._calculator.stepCircleSizeCss,
25022 marginLeft: this._calculator.stepCircleMarginCss,
25023 marginTop: this._calculator.stepCircleMarginCss,
25024 transform: circleTransform,
25025 width: this._calculator.stepCircleSizeCss,
25028 if (this._sequenceEdgeKeys.indexOf(key) > -1) {
25029 circleClassName += "Sequence";
25031 if (this._highlightKey === key) {
25032 circleClassName += "Highlight";
25034 return vd.h("div." + circleClassName, circleProperties, [chevron]);
25036 DirectionDOMRenderer.prototype._getContainer = function (steps, turns, rotation) {
25037 // edge does not handle hover on perspective transforms.
25038 var transform = this._isEdge ?
25040 "perspective(" + this._calculator.containerWidthCss + ") rotateX(60deg)";
25042 oncontextmenu: function (event) { event.preventDefault(); },
25044 bottom: this._calculator.containerBottomCss,
25045 height: this._calculator.containerHeightCss,
25046 left: this._calculator.containerLeftCss,
25047 marginLeft: this._calculator.containerMarginCss,
25048 transform: transform,
25049 width: this._calculator.containerWidthCss,
25052 return vd.h("div.DirectionsPerspective", properties, turns.concat(steps));
25054 return DirectionDOMRenderer;
25056 exports.DirectionDOMRenderer = DirectionDOMRenderer;
25057 exports.default = DirectionDOMRenderer;
25060 },{"../../Component":275,"../../Edge":276,"../../Error":277,"../../Geo":278,"virtual-dom":231}],305:[function(require,module,exports){
25062 var __extends = (this && this.__extends) || (function () {
25063 var extendStatics = function (d, b) {
25064 extendStatics = Object.setPrototypeOf ||
25065 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
25066 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
25067 return extendStatics(d, b);
25069 return function (d, b) {
25070 extendStatics(d, b);
25071 function __() { this.constructor = d; }
25072 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
25075 Object.defineProperty(exports, "__esModule", { value: true });
25076 var rxjs_1 = require("rxjs");
25077 var operators_1 = require("rxjs/operators");
25078 var Component_1 = require("../../Component");
25079 var Render_1 = require("../../Render");
25080 var Tiles_1 = require("../../Tiles");
25081 var Utils_1 = require("../../Utils");
25082 var ImagePlaneComponent = /** @class */ (function (_super) {
25083 __extends(ImagePlaneComponent, _super);
25084 function ImagePlaneComponent(name, container, navigator) {
25085 var _this = _super.call(this, name, container, navigator) || this;
25086 _this._imageTileLoader = new Tiles_1.ImageTileLoader(Utils_1.Urls.tileScheme, Utils_1.Urls.tileDomain, Utils_1.Urls.origin);
25087 _this._roiCalculator = new Tiles_1.RegionOfInterestCalculator();
25088 _this._rendererOperation$ = new rxjs_1.Subject();
25089 _this._rendererCreator$ = new rxjs_1.Subject();
25090 _this._rendererDisposer$ = new rxjs_1.Subject();
25091 _this._renderer$ = _this._rendererOperation$.pipe(operators_1.scan(function (renderer, operation) {
25092 return operation(renderer);
25093 }, null), operators_1.filter(function (renderer) {
25094 return renderer != null;
25095 }), operators_1.distinctUntilChanged(undefined, function (renderer) {
25096 return renderer.frameId;
25098 _this._rendererCreator$.pipe(operators_1.map(function () {
25099 return function (renderer) {
25100 if (renderer != null) {
25101 throw new Error("Multiple image plane states can not be created at the same time");
25103 return new Component_1.ImagePlaneGLRenderer();
25106 .subscribe(_this._rendererOperation$);
25107 _this._rendererDisposer$.pipe(operators_1.map(function () {
25108 return function (renderer) {
25109 renderer.dispose();
25113 .subscribe(_this._rendererOperation$);
25116 ImagePlaneComponent.prototype._activate = function () {
25118 this._rendererSubscription = this._renderer$.pipe(operators_1.map(function (renderer) {
25122 frameId: renderer.frameId,
25123 needsRender: renderer.needsRender,
25124 render: renderer.render.bind(renderer),
25125 stage: Render_1.GLRenderStage.Background,
25128 renderer.clearNeedsRender();
25131 .subscribe(this._container.glRenderer.render$);
25132 this._rendererCreator$.next(null);
25133 this._stateSubscription = this._navigator.stateService.currentState$.pipe(operators_1.map(function (frame) {
25134 return function (renderer) {
25135 renderer.updateFrame(frame);
25139 .subscribe(this._rendererOperation$);
25140 var textureProvider$ = this._navigator.stateService.currentState$.pipe(operators_1.distinctUntilChanged(undefined, function (frame) {
25141 return frame.state.currentNode.key;
25142 }), operators_1.withLatestFrom(this._container.glRenderer.webGLRenderer$, this._container.renderService.size$), operators_1.map(function (_a) {
25143 var frame = _a[0], renderer = _a[1], size = _a[2];
25144 var state = frame.state;
25145 var viewportSize = Math.max(size.width, size.height);
25146 var currentNode = state.currentNode;
25147 var currentTransform = state.currentTransform;
25148 var tileSize = viewportSize > 2048 ? 2048 : viewportSize > 1024 ? 1024 : 512;
25149 return new Tiles_1.TextureProvider(currentNode.key, currentTransform.basicWidth, currentTransform.basicHeight, tileSize, currentNode.image, _this._imageTileLoader, new Tiles_1.ImageTileStore(), renderer);
25150 }), operators_1.publishReplay(1), operators_1.refCount());
25151 this._textureProviderSubscription = textureProvider$.subscribe(function () { });
25152 this._setTextureProviderSubscription = textureProvider$.pipe(operators_1.map(function (provider) {
25153 return function (renderer) {
25154 renderer.setTextureProvider(provider.key, provider);
25158 .subscribe(this._rendererOperation$);
25159 this._setTileSizeSubscription = this._container.renderService.size$.pipe(operators_1.switchMap(function (size) {
25160 return rxjs_1.combineLatest(textureProvider$, rxjs_1.of(size)).pipe(operators_1.first());
25162 .subscribe(function (_a) {
25163 var provider = _a[0], size = _a[1];
25164 var viewportSize = Math.max(size.width, size.height);
25165 var tileSize = viewportSize > 2048 ? 2048 : viewportSize > 1024 ? 1024 : 512;
25166 provider.setTileSize(tileSize);
25168 this._abortTextureProviderSubscription = textureProvider$.pipe(operators_1.pairwise())
25169 .subscribe(function (pair) {
25170 var previous = pair[0];
25173 var roiTrigger$ = rxjs_1.combineLatest(this._container.renderService.renderCameraFrame$, this._container.renderService.size$.pipe(operators_1.debounceTime(250))).pipe(operators_1.map(function (_a) {
25174 var camera = _a[0], size = _a[1];
25176 camera.camera.position.clone(),
25177 camera.camera.lookat.clone(),
25178 camera.zoom.valueOf(),
25179 size.height.valueOf(),
25180 size.width.valueOf()
25182 }), operators_1.pairwise(), operators_1.skipWhile(function (pls) {
25183 return pls[1][2] - pls[0][2] < 0 || pls[1][2] === 0;
25184 }), operators_1.map(function (pls) {
25185 var samePosition = pls[0][0].equals(pls[1][0]);
25186 var sameLookat = pls[0][1].equals(pls[1][1]);
25187 var sameZoom = pls[0][2] === pls[1][2];
25188 var sameHeight = pls[0][3] === pls[1][3];
25189 var sameWidth = pls[0][4] === pls[1][4];
25190 return samePosition && sameLookat && sameZoom && sameHeight && sameWidth;
25191 }), operators_1.distinctUntilChanged(), operators_1.filter(function (stalled) {
25193 }), operators_1.switchMap(function (stalled) {
25194 return _this._container.renderService.renderCameraFrame$.pipe(operators_1.first());
25195 }), operators_1.withLatestFrom(this._container.renderService.size$, this._navigator.stateService.currentTransform$));
25196 this._setRegionOfInterestSubscription = textureProvider$.pipe(operators_1.switchMap(function (provider) {
25197 return roiTrigger$.pipe(operators_1.map(function (_a) {
25198 var camera = _a[0], size = _a[1], transform = _a[2];
25200 _this._roiCalculator.computeRegionOfInterest(camera, size, transform),
25204 }), operators_1.filter(function (args) {
25205 return !args[1].disposed;
25207 .subscribe(function (args) {
25209 var provider = args[1];
25210 provider.setRegionOfInterest(roi);
25212 var hasTexture$ = textureProvider$.pipe(operators_1.switchMap(function (provider) {
25213 return provider.hasTexture$;
25214 }), operators_1.startWith(false), operators_1.publishReplay(1), operators_1.refCount());
25215 this._hasTextureSubscription = hasTexture$.subscribe(function () { });
25216 var nodeImage$ = this._navigator.stateService.currentState$.pipe(operators_1.filter(function (frame) {
25217 return frame.state.nodesAhead === 0;
25218 }), operators_1.map(function (frame) {
25219 return frame.state.currentNode;
25220 }), operators_1.distinctUntilChanged(undefined, function (node) {
25222 }), operators_1.debounceTime(1000), operators_1.withLatestFrom(hasTexture$), operators_1.filter(function (args) {
25224 }), operators_1.map(function (args) {
25226 }), operators_1.filter(function (node) {
25228 Utils_1.Settings.maxImageSize > Utils_1.Settings.basePanoramaSize :
25229 Utils_1.Settings.maxImageSize > Utils_1.Settings.baseImageSize;
25230 }), operators_1.switchMap(function (node) {
25231 var baseImageSize = node.pano ?
25232 Utils_1.Settings.basePanoramaSize :
25233 Utils_1.Settings.baseImageSize;
25234 if (Math.max(node.image.width, node.image.height) > baseImageSize) {
25235 return rxjs_1.empty();
25238 .cacheImage$(Utils_1.Settings.maxImageSize).pipe(operators_1.map(function (n) {
25239 return [n.image, n];
25241 return image$.pipe(operators_1.takeUntil(hasTexture$.pipe(operators_1.filter(function (hasTexture) {
25243 }))), operators_1.catchError(function (error, caught) {
25244 console.error("Failed to fetch high res image (" + node.key + ")", error);
25245 return rxjs_1.empty();
25247 })).pipe(operators_1.publish(), operators_1.refCount());
25248 this._updateBackgroundSubscription = nodeImage$.pipe(operators_1.withLatestFrom(textureProvider$))
25249 .subscribe(function (args) {
25250 if (args[0][1].key !== args[1].key ||
25251 args[1].disposed) {
25254 args[1].updateBackground(args[0][0]);
25256 this._updateTextureImageSubscription = nodeImage$.pipe(operators_1.map(function (imn) {
25257 return function (renderer) {
25258 renderer.updateTextureImage(imn[0], imn[1]);
25262 .subscribe(this._rendererOperation$);
25264 ImagePlaneComponent.prototype._deactivate = function () {
25265 this._rendererDisposer$.next(null);
25266 this._abortTextureProviderSubscription.unsubscribe();
25267 this._hasTextureSubscription.unsubscribe();
25268 this._rendererSubscription.unsubscribe();
25269 this._setRegionOfInterestSubscription.unsubscribe();
25270 this._setTextureProviderSubscription.unsubscribe();
25271 this._setTileSizeSubscription.unsubscribe();
25272 this._stateSubscription.unsubscribe();
25273 this._textureProviderSubscription.unsubscribe();
25274 this._updateBackgroundSubscription.unsubscribe();
25275 this._updateTextureImageSubscription.unsubscribe();
25277 ImagePlaneComponent.prototype._getDefaultConfiguration = function () {
25280 ImagePlaneComponent.componentName = "imagePlane";
25281 return ImagePlaneComponent;
25282 }(Component_1.Component));
25283 exports.ImagePlaneComponent = ImagePlaneComponent;
25284 Component_1.ComponentService.register(ImagePlaneComponent);
25285 exports.default = ImagePlaneComponent;
25287 },{"../../Component":275,"../../Render":281,"../../Tiles":284,"../../Utils":285,"rxjs":27,"rxjs/operators":225}],306:[function(require,module,exports){
25289 Object.defineProperty(exports, "__esModule", { value: true });
25290 var Component_1 = require("../../Component");
25291 var ImagePlaneGLRenderer = /** @class */ (function () {
25292 function ImagePlaneGLRenderer() {
25293 this._factory = new Component_1.MeshFactory();
25294 this._scene = new Component_1.MeshScene();
25296 this._alphaOld = 0;
25297 this._fadeOutSpeed = 0.05;
25298 this._currentKey = null;
25299 this._previousKey = null;
25300 this._providerDisposers = {};
25302 this._needsRender = false;
25304 Object.defineProperty(ImagePlaneGLRenderer.prototype, "frameId", {
25306 return this._frameId;
25311 Object.defineProperty(ImagePlaneGLRenderer.prototype, "needsRender", {
25313 return this._needsRender;
25318 ImagePlaneGLRenderer.prototype.indicateNeedsRender = function () {
25319 this._needsRender = true;
25321 ImagePlaneGLRenderer.prototype.updateFrame = function (frame) {
25322 this._updateFrameId(frame.id);
25323 this._needsRender = this._updateAlpha(frame.state.alpha) || this._needsRender;
25324 this._needsRender = this._updateAlphaOld(frame.state.alpha) || this._needsRender;
25325 this._needsRender = this._updateImagePlanes(frame.state) || this._needsRender;
25327 ImagePlaneGLRenderer.prototype.setTextureProvider = function (key, provider) {
25329 if (key !== this._currentKey) {
25332 var createdSubscription = provider.textureCreated$
25333 .subscribe(function (texture) {
25334 _this._updateTexture(texture);
25336 var updatedSubscription = provider.textureUpdated$
25337 .subscribe(function (updated) {
25338 _this._needsRender = true;
25340 var dispose = function () {
25341 createdSubscription.unsubscribe();
25342 updatedSubscription.unsubscribe();
25343 provider.dispose();
25345 if (key in this._providerDisposers) {
25346 var disposeProvider = this._providerDisposers[key];
25348 delete this._providerDisposers[key];
25350 this._providerDisposers[key] = dispose;
25352 ImagePlaneGLRenderer.prototype._updateTexture = function (texture) {
25353 this._needsRender = true;
25354 for (var _i = 0, _a = this._scene.imagePlanes; _i < _a.length; _i++) {
25355 var plane = _a[_i];
25356 var material = plane.material;
25357 var oldTexture = material.uniforms.projectorTex.value;
25358 material.uniforms.projectorTex.value = null;
25359 oldTexture.dispose();
25360 material.uniforms.projectorTex.value = texture;
25363 ImagePlaneGLRenderer.prototype.updateTextureImage = function (image, node) {
25364 if (this._currentKey !== node.key) {
25367 this._needsRender = true;
25368 for (var _i = 0, _a = this._scene.imagePlanes; _i < _a.length; _i++) {
25369 var plane = _a[_i];
25370 var material = plane.material;
25371 var texture = material.uniforms.projectorTex.value;
25372 texture.image = image;
25373 texture.needsUpdate = true;
25376 ImagePlaneGLRenderer.prototype.render = function (perspectiveCamera, renderer) {
25377 var planeAlpha = this._scene.imagePlanesOld.length ? 1 : this._alpha;
25378 for (var _i = 0, _a = this._scene.imagePlanes; _i < _a.length; _i++) {
25379 var plane = _a[_i];
25380 plane.material.uniforms.opacity.value = planeAlpha;
25382 for (var _b = 0, _c = this._scene.imagePlanesOld; _b < _c.length; _b++) {
25383 var plane = _c[_b];
25384 plane.material.uniforms.opacity.value = this._alphaOld;
25386 renderer.render(this._scene.scene, perspectiveCamera);
25387 renderer.render(this._scene.sceneOld, perspectiveCamera);
25388 for (var _d = 0, _e = this._scene.imagePlanes; _d < _e.length; _d++) {
25389 var plane = _e[_d];
25390 plane.material.uniforms.opacity.value = this._alpha;
25392 renderer.render(this._scene.scene, perspectiveCamera);
25394 ImagePlaneGLRenderer.prototype.clearNeedsRender = function () {
25395 this._needsRender = false;
25397 ImagePlaneGLRenderer.prototype.dispose = function () {
25398 this._scene.clear();
25400 ImagePlaneGLRenderer.prototype._updateFrameId = function (frameId) {
25401 this._frameId = frameId;
25403 ImagePlaneGLRenderer.prototype._updateAlpha = function (alpha) {
25404 if (alpha === this._alpha) {
25407 this._alpha = alpha;
25410 ImagePlaneGLRenderer.prototype._updateAlphaOld = function (alpha) {
25411 if (alpha < 1 || this._alphaOld === 0) {
25414 this._alphaOld = Math.max(0, this._alphaOld - this._fadeOutSpeed);
25417 ImagePlaneGLRenderer.prototype._updateImagePlanes = function (state) {
25418 if (state.currentNode == null || state.currentNode.key === this._currentKey) {
25421 var previousKey = state.previousNode != null ? state.previousNode.key : null;
25422 var currentKey = state.currentNode.key;
25423 if (this._previousKey !== previousKey &&
25424 this._previousKey !== currentKey &&
25425 this._previousKey in this._providerDisposers) {
25426 var disposeProvider = this._providerDisposers[this._previousKey];
25428 delete this._providerDisposers[this._previousKey];
25430 if (previousKey != null) {
25431 if (previousKey !== this._currentKey && previousKey !== this._previousKey) {
25432 var previousMesh = this._factory.createMesh(state.previousNode, state.previousTransform);
25433 this._scene.updateImagePlanes([previousMesh]);
25435 this._previousKey = previousKey;
25437 this._currentKey = currentKey;
25438 var currentMesh = this._factory.createMesh(state.currentNode, state.currentTransform);
25439 this._scene.updateImagePlanes([currentMesh]);
25440 this._alphaOld = 1;
25443 return ImagePlaneGLRenderer;
25445 exports.ImagePlaneGLRenderer = ImagePlaneGLRenderer;
25446 exports.default = ImagePlaneGLRenderer;
25448 },{"../../Component":275}],307:[function(require,module,exports){
25450 Object.defineProperty(exports, "__esModule", { value: true });
25452 (function (CoverState) {
25453 CoverState[CoverState["Hidden"] = 0] = "Hidden";
25454 CoverState[CoverState["Loading"] = 1] = "Loading";
25455 CoverState[CoverState["Visible"] = 2] = "Visible";
25456 })(CoverState = exports.CoverState || (exports.CoverState = {}));
25458 },{}],308:[function(require,module,exports){
25460 Object.defineProperty(exports, "__esModule", { value: true });
25462 * Enumeration for slider mode.
25467 * @description Modes for specifying how transitions
25468 * between nodes are performed in slider mode. Only
25469 * applicable when the slider component determines
25470 * that transitions with motion is possilble. When it
25471 * is not, the stationary mode will be applied.
25474 (function (SliderMode) {
25476 * Transitions with motion.
25478 * @description The slider component moves the
25479 * camera between the node origins.
25481 * In this mode it is not possible to zoom or pan.
25483 * The slider component falls back to stationary
25484 * mode when it determines that the pair of nodes
25485 * does not have a strong enough relation.
25487 SliderMode[SliderMode["Motion"] = 0] = "Motion";
25489 * Stationary transitions.
25491 * @description The camera is stationary.
25493 * In this mode it is possible to zoom and pan.
25495 SliderMode[SliderMode["Stationary"] = 1] = "Stationary";
25496 })(SliderMode = exports.SliderMode || (exports.SliderMode = {}));
25498 },{}],309:[function(require,module,exports){
25500 Object.defineProperty(exports, "__esModule", { value: true });
25501 var ICoverConfiguration_1 = require("./ICoverConfiguration");
25502 exports.CoverState = ICoverConfiguration_1.CoverState;
25503 var ISliderConfiguration_1 = require("./ISliderConfiguration");
25504 exports.SliderMode = ISliderConfiguration_1.SliderMode;
25506 },{"./ICoverConfiguration":307,"./ISliderConfiguration":308}],310:[function(require,module,exports){
25508 var __extends = (this && this.__extends) || (function () {
25509 var extendStatics = function (d, b) {
25510 extendStatics = Object.setPrototypeOf ||
25511 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
25512 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
25513 return extendStatics(d, b);
25515 return function (d, b) {
25516 extendStatics(d, b);
25517 function __() { this.constructor = d; }
25518 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
25521 Object.defineProperty(exports, "__esModule", { value: true });
25522 var operators_1 = require("rxjs/operators");
25523 var Component_1 = require("../../Component");
25524 var Edge_1 = require("../../Edge");
25526 * The `KeyPlayHandler` allows the user to control the play behavior
25527 * using the following key commands:
25529 * `Spacebar`: Start or stop playing.
25530 * `SHIFT` + `D`: Switch direction.
25531 * `<`: Decrease speed.
25532 * `>`: Increase speed.
25536 * var keyboardComponent = viewer.getComponent("keyboard");
25538 * keyboardComponent.keyPlay.disable();
25539 * keyboardComponent.keyPlay.enable();
25541 * var isEnabled = keyboardComponent.keyPlay.isEnabled;
25544 var KeyPlayHandler = /** @class */ (function (_super) {
25545 __extends(KeyPlayHandler, _super);
25546 function KeyPlayHandler() {
25547 return _super !== null && _super.apply(this, arguments) || this;
25549 KeyPlayHandler.prototype._enable = function () {
25551 this._keyDownSubscription = this._container.keyboardService.keyDown$.pipe(operators_1.withLatestFrom(this._navigator.playService.playing$, this._navigator.playService.direction$, this._navigator.playService.speed$, this._navigator.stateService.currentNode$.pipe(operators_1.switchMap(function (node) {
25552 return node.sequenceEdges$;
25554 .subscribe(function (_a) {
25555 var event = _a[0], playing = _a[1], direction = _a[2], speed = _a[3], status = _a[4];
25556 if (event.altKey || event.ctrlKey || event.metaKey) {
25559 switch (event.key) {
25561 if (!event.shiftKey) {
25564 var newDirection = playing ?
25565 null : direction === Edge_1.EdgeDirection.Next ?
25566 Edge_1.EdgeDirection.Prev : direction === Edge_1.EdgeDirection.Prev ?
25567 Edge_1.EdgeDirection.Next : null;
25568 if (newDirection != null) {
25569 _this._navigator.playService.setDirection(newDirection);
25573 if (event.shiftKey) {
25577 _this._navigator.playService.stop();
25580 for (var _i = 0, _b = status.edges; _i < _b.length; _i++) {
25582 if (edge.data.direction === direction) {
25583 _this._navigator.playService.play();
25589 _this._navigator.playService.setSpeed(speed - 0.05);
25592 _this._navigator.playService.setSpeed(speed + 0.05);
25597 event.preventDefault();
25600 KeyPlayHandler.prototype._disable = function () {
25601 this._keyDownSubscription.unsubscribe();
25603 KeyPlayHandler.prototype._getConfiguration = function (enable) {
25604 return { keyZoom: enable };
25606 return KeyPlayHandler;
25607 }(Component_1.HandlerBase));
25608 exports.KeyPlayHandler = KeyPlayHandler;
25609 exports.default = KeyPlayHandler;
25611 },{"../../Component":275,"../../Edge":276,"rxjs/operators":225}],311:[function(require,module,exports){
25613 var __extends = (this && this.__extends) || (function () {
25614 var extendStatics = function (d, b) {
25615 extendStatics = Object.setPrototypeOf ||
25616 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
25617 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
25618 return extendStatics(d, b);
25620 return function (d, b) {
25621 extendStatics(d, b);
25622 function __() { this.constructor = d; }
25623 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
25626 Object.defineProperty(exports, "__esModule", { value: true });
25627 var operators_1 = require("rxjs/operators");
25628 var Component_1 = require("../../Component");
25629 var Edge_1 = require("../../Edge");
25630 var Error_1 = require("../../Error");
25632 * The `KeySequenceNavigationHandler` allows the user to navigate through a sequence using the
25633 * following key commands:
25635 * `ALT` + `Up Arrow`: Navigate to next image in the sequence.
25636 * `ALT` + `Down Arrow`: Navigate to previous image in sequence.
25640 * var keyboardComponent = viewer.getComponent("keyboard");
25642 * keyboardComponent.keySequenceNavigation.disable();
25643 * keyboardComponent.keySequenceNavigation.enable();
25645 * var isEnabled = keyboardComponent.keySequenceNavigation.isEnabled;
25648 var KeySequenceNavigationHandler = /** @class */ (function (_super) {
25649 __extends(KeySequenceNavigationHandler, _super);
25650 function KeySequenceNavigationHandler() {
25651 return _super !== null && _super.apply(this, arguments) || this;
25653 KeySequenceNavigationHandler.prototype._enable = function () {
25655 var sequenceEdges$ = this._navigator.stateService.currentNode$.pipe(operators_1.switchMap(function (node) {
25656 return node.sequenceEdges$;
25658 this._keyDownSubscription = this._container.keyboardService.keyDown$.pipe(operators_1.withLatestFrom(sequenceEdges$))
25659 .subscribe(function (_a) {
25660 var event = _a[0], edgeStatus = _a[1];
25661 var direction = null;
25662 switch (event.keyCode) {
25664 direction = Edge_1.EdgeDirection.Next;
25667 direction = Edge_1.EdgeDirection.Prev;
25672 event.preventDefault();
25673 if (!event.altKey || event.shiftKey || !edgeStatus.cached) {
25676 for (var _i = 0, _b = edgeStatus.edges; _i < _b.length; _i++) {
25678 if (edge.data.direction === direction) {
25679 _this._navigator.moveToKey$(edge.to)
25680 .subscribe(undefined, function (error) {
25681 if (!(error instanceof Error_1.AbortMapillaryError)) {
25682 console.error(error);
25690 KeySequenceNavigationHandler.prototype._disable = function () {
25691 this._keyDownSubscription.unsubscribe();
25693 KeySequenceNavigationHandler.prototype._getConfiguration = function (enable) {
25694 return { keySequenceNavigation: enable };
25696 return KeySequenceNavigationHandler;
25697 }(Component_1.HandlerBase));
25698 exports.KeySequenceNavigationHandler = KeySequenceNavigationHandler;
25699 exports.default = KeySequenceNavigationHandler;
25701 },{"../../Component":275,"../../Edge":276,"../../Error":277,"rxjs/operators":225}],312:[function(require,module,exports){
25703 var __extends = (this && this.__extends) || (function () {
25704 var extendStatics = function (d, b) {
25705 extendStatics = Object.setPrototypeOf ||
25706 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
25707 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
25708 return extendStatics(d, b);
25710 return function (d, b) {
25711 extendStatics(d, b);
25712 function __() { this.constructor = d; }
25713 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
25716 Object.defineProperty(exports, "__esModule", { value: true });
25717 var operators_1 = require("rxjs/operators");
25718 var Component_1 = require("../../Component");
25719 var Edge_1 = require("../../Edge");
25720 var Error_1 = require("../../Error");
25722 * The `KeySpatialNavigationHandler` allows the user to navigate through a sequence using the
25723 * following key commands:
25725 * `Up Arrow`: Step forward.
25726 * `Down Arrow`: Step backward.
25727 * `Left Arrow`: Step to the left.
25728 * `Rigth Arrow`: Step to the right.
25729 * `SHIFT` + `Down Arrow`: Turn around.
25730 * `SHIFT` + `Left Arrow`: Turn to the left.
25731 * `SHIFT` + `Rigth Arrow`: Turn to the right.
25735 * var keyboardComponent = viewer.getComponent("keyboard");
25737 * keyboardComponent.keySpatialNavigation.disable();
25738 * keyboardComponent.keySpatialNavigation.enable();
25740 * var isEnabled = keyboardComponent.keySpatialNavigation.isEnabled;
25743 var KeySpatialNavigationHandler = /** @class */ (function (_super) {
25744 __extends(KeySpatialNavigationHandler, _super);
25746 function KeySpatialNavigationHandler(component, container, navigator, spatial) {
25747 var _this = _super.call(this, component, container, navigator) || this;
25748 _this._spatial = spatial;
25751 KeySpatialNavigationHandler.prototype._enable = function () {
25753 var spatialEdges$ = this._navigator.stateService.currentNode$.pipe(operators_1.switchMap(function (node) {
25754 return node.spatialEdges$;
25756 this._keyDownSubscription = this._container.keyboardService.keyDown$.pipe(operators_1.withLatestFrom(spatialEdges$, this._navigator.stateService.currentState$))
25757 .subscribe(function (_a) {
25758 var event = _a[0], edgeStatus = _a[1], frame = _a[2];
25759 var pano = frame.state.currentNode.pano;
25760 var direction = null;
25761 switch (event.keyCode) {
25763 direction = event.shiftKey && !pano ? Edge_1.EdgeDirection.TurnLeft : Edge_1.EdgeDirection.StepLeft;
25766 direction = event.shiftKey && !pano ? Edge_1.EdgeDirection.Pano : Edge_1.EdgeDirection.StepForward;
25769 direction = event.shiftKey && !pano ? Edge_1.EdgeDirection.TurnRight : Edge_1.EdgeDirection.StepRight;
25772 direction = event.shiftKey && !pano ? Edge_1.EdgeDirection.TurnU : Edge_1.EdgeDirection.StepBackward;
25777 event.preventDefault();
25778 if (event.altKey || !edgeStatus.cached ||
25779 (event.shiftKey && pano)) {
25783 _this._moveDir(direction, edgeStatus);
25787 shifts[Edge_1.EdgeDirection.StepBackward] = Math.PI;
25788 shifts[Edge_1.EdgeDirection.StepForward] = 0;
25789 shifts[Edge_1.EdgeDirection.StepLeft] = Math.PI / 2;
25790 shifts[Edge_1.EdgeDirection.StepRight] = -Math.PI / 2;
25791 var phi = _this._rotationFromCamera(frame.state.camera).phi;
25792 var navigationAngle = _this._spatial.wrapAngle(phi + shifts[direction]);
25793 var threshold = Math.PI / 4;
25794 var edges = edgeStatus.edges.filter(function (e) {
25795 return e.data.direction === Edge_1.EdgeDirection.Pano || e.data.direction === direction;
25797 var smallestAngle = Number.MAX_VALUE;
25799 for (var _i = 0, edges_1 = edges; _i < edges_1.length; _i++) {
25800 var edge = edges_1[_i];
25801 var angle = Math.abs(_this._spatial.wrapAngle(edge.data.worldMotionAzimuth - navigationAngle));
25802 if (angle < Math.min(smallestAngle, threshold)) {
25803 smallestAngle = angle;
25807 if (toKey == null) {
25810 _this._moveToKey(toKey);
25814 KeySpatialNavigationHandler.prototype._disable = function () {
25815 this._keyDownSubscription.unsubscribe();
25817 KeySpatialNavigationHandler.prototype._getConfiguration = function (enable) {
25818 return { keySpatialNavigation: enable };
25820 KeySpatialNavigationHandler.prototype._moveDir = function (direction, edgeStatus) {
25821 for (var _i = 0, _a = edgeStatus.edges; _i < _a.length; _i++) {
25823 if (edge.data.direction === direction) {
25824 this._moveToKey(edge.to);
25829 KeySpatialNavigationHandler.prototype._moveToKey = function (key) {
25830 this._navigator.moveToKey$(key)
25831 .subscribe(undefined, function (error) {
25832 if (!(error instanceof Error_1.AbortMapillaryError)) {
25833 console.error(error);
25837 KeySpatialNavigationHandler.prototype._rotationFromCamera = function (camera) {
25838 var direction = camera.lookat.clone().sub(camera.position);
25839 var upProjection = direction.clone().dot(camera.up);
25840 var planeProjection = direction.clone().sub(camera.up.clone().multiplyScalar(upProjection));
25841 var phi = Math.atan2(planeProjection.y, planeProjection.x);
25842 var theta = Math.PI / 2 - this._spatial.angleToPlane(direction.toArray(), [0, 0, 1]);
25843 return { phi: phi, theta: theta };
25845 return KeySpatialNavigationHandler;
25846 }(Component_1.HandlerBase));
25847 exports.KeySpatialNavigationHandler = KeySpatialNavigationHandler;
25848 exports.default = KeySpatialNavigationHandler;
25850 },{"../../Component":275,"../../Edge":276,"../../Error":277,"rxjs/operators":225}],313:[function(require,module,exports){
25852 var __extends = (this && this.__extends) || (function () {
25853 var extendStatics = function (d, b) {
25854 extendStatics = Object.setPrototypeOf ||
25855 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
25856 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
25857 return extendStatics(d, b);
25859 return function (d, b) {
25860 extendStatics(d, b);
25861 function __() { this.constructor = d; }
25862 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
25865 Object.defineProperty(exports, "__esModule", { value: true });
25866 var operators_1 = require("rxjs/operators");
25867 var Component_1 = require("../../Component");
25869 * The `KeyZoomHandler` allows the user to zoom in and out using the
25870 * following key commands:
25877 * var keyboardComponent = viewer.getComponent("keyboard");
25879 * keyboardComponent.keyZoom.disable();
25880 * keyboardComponent.keyZoom.enable();
25882 * var isEnabled = keyboardComponent.keyZoom.isEnabled;
25885 var KeyZoomHandler = /** @class */ (function (_super) {
25886 __extends(KeyZoomHandler, _super);
25888 function KeyZoomHandler(component, container, navigator, viewportCoords) {
25889 var _this = _super.call(this, component, container, navigator) || this;
25890 _this._viewportCoords = viewportCoords;
25893 KeyZoomHandler.prototype._enable = function () {
25895 this._keyDownSubscription = this._container.keyboardService.keyDown$.pipe(operators_1.withLatestFrom(this._container.renderService.renderCamera$, this._navigator.stateService.currentTransform$))
25896 .subscribe(function (_a) {
25897 var event = _a[0], render = _a[1], transform = _a[2];
25898 if (event.altKey || event.shiftKey || event.ctrlKey || event.metaKey) {
25902 switch (event.key) {
25912 event.preventDefault();
25913 var unprojected = _this._viewportCoords.unprojectFromViewport(0, 0, render.perspective);
25914 var reference = transform.projectBasic(unprojected.toArray());
25915 _this._navigator.stateService.zoomIn(delta, reference);
25918 KeyZoomHandler.prototype._disable = function () {
25919 this._keyDownSubscription.unsubscribe();
25921 KeyZoomHandler.prototype._getConfiguration = function (enable) {
25922 return { keyZoom: enable };
25924 return KeyZoomHandler;
25925 }(Component_1.HandlerBase));
25926 exports.KeyZoomHandler = KeyZoomHandler;
25927 exports.default = KeyZoomHandler;
25929 },{"../../Component":275,"rxjs/operators":225}],314:[function(require,module,exports){
25931 var __extends = (this && this.__extends) || (function () {
25932 var extendStatics = function (d, b) {
25933 extendStatics = Object.setPrototypeOf ||
25934 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
25935 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
25936 return extendStatics(d, b);
25938 return function (d, b) {
25939 extendStatics(d, b);
25940 function __() { this.constructor = d; }
25941 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
25944 Object.defineProperty(exports, "__esModule", { value: true });
25945 var Component_1 = require("../../Component");
25946 var Geo_1 = require("../../Geo");
25948 * @class KeyboardComponent
25950 * @classdesc Component for keyboard event handling.
25952 * To retrive and use the keyboard component
25956 * var viewer = new Mapillary.Viewer(
25961 * var keyboardComponent = viewer.getComponent("keyboard");
25964 var KeyboardComponent = /** @class */ (function (_super) {
25965 __extends(KeyboardComponent, _super);
25967 function KeyboardComponent(name, container, navigator) {
25968 var _this = _super.call(this, name, container, navigator) || this;
25969 _this._keyPlayHandler = new Component_1.KeyPlayHandler(_this, container, navigator);
25970 _this._keySequenceNavigationHandler = new Component_1.KeySequenceNavigationHandler(_this, container, navigator);
25971 _this._keySpatialNavigationHandler = new Component_1.KeySpatialNavigationHandler(_this, container, navigator, new Geo_1.Spatial());
25972 _this._keyZoomHandler = new Component_1.KeyZoomHandler(_this, container, navigator, new Geo_1.ViewportCoords());
25975 Object.defineProperty(KeyboardComponent.prototype, "keyPlay", {
25979 * @returns {KeyPlayHandler} The key play handler.
25982 return this._keyPlayHandler;
25987 Object.defineProperty(KeyboardComponent.prototype, "keySequenceNavigation", {
25989 * Get key sequence navigation.
25991 * @returns {KeySequenceNavigationHandler} The key sequence navigation handler.
25994 return this._keySequenceNavigationHandler;
25999 Object.defineProperty(KeyboardComponent.prototype, "keySpatialNavigation", {
26003 * @returns {KeySpatialNavigationHandler} The spatial handler.
26006 return this._keySpatialNavigationHandler;
26011 Object.defineProperty(KeyboardComponent.prototype, "keyZoom", {
26015 * @returns {KeyZoomHandler} The key zoom handler.
26018 return this._keyZoomHandler;
26023 KeyboardComponent.prototype._activate = function () {
26025 this._configurationSubscription = this._configuration$
26026 .subscribe(function (configuration) {
26027 if (configuration.keyPlay) {
26028 _this._keyPlayHandler.enable();
26031 _this._keyPlayHandler.disable();
26033 if (configuration.keySequenceNavigation) {
26034 _this._keySequenceNavigationHandler.enable();
26037 _this._keySequenceNavigationHandler.disable();
26039 if (configuration.keySpatialNavigation) {
26040 _this._keySpatialNavigationHandler.enable();
26043 _this._keySpatialNavigationHandler.disable();
26045 if (configuration.keyZoom) {
26046 _this._keyZoomHandler.enable();
26049 _this._keyZoomHandler.disable();
26053 KeyboardComponent.prototype._deactivate = function () {
26054 this._configurationSubscription.unsubscribe();
26055 this._keyPlayHandler.disable();
26056 this._keySequenceNavigationHandler.disable();
26057 this._keySpatialNavigationHandler.disable();
26058 this._keyZoomHandler.disable();
26060 KeyboardComponent.prototype._getDefaultConfiguration = function () {
26061 return { keyPlay: true, keySequenceNavigation: true, keySpatialNavigation: true, keyZoom: true };
26063 KeyboardComponent.componentName = "keyboard";
26064 return KeyboardComponent;
26065 }(Component_1.Component));
26066 exports.KeyboardComponent = KeyboardComponent;
26067 Component_1.ComponentService.register(KeyboardComponent);
26068 exports.default = KeyboardComponent;
26070 },{"../../Component":275,"../../Geo":278}],315:[function(require,module,exports){
26072 Object.defineProperty(exports, "__esModule", { value: true });
26073 var MarkerComponent_1 = require("./MarkerComponent");
26074 exports.MarkerComponent = MarkerComponent_1.MarkerComponent;
26075 var SimpleMarker_1 = require("./marker/SimpleMarker");
26076 exports.SimpleMarker = SimpleMarker_1.SimpleMarker;
26077 var CircleMarker_1 = require("./marker/CircleMarker");
26078 exports.CircleMarker = CircleMarker_1.CircleMarker;
26080 },{"./MarkerComponent":316,"./marker/CircleMarker":319,"./marker/SimpleMarker":321}],316:[function(require,module,exports){
26082 var __extends = (this && this.__extends) || (function () {
26083 var extendStatics = function (d, b) {
26084 extendStatics = Object.setPrototypeOf ||
26085 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
26086 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
26087 return extendStatics(d, b);
26089 return function (d, b) {
26090 extendStatics(d, b);
26091 function __() { this.constructor = d; }
26092 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
26095 Object.defineProperty(exports, "__esModule", { value: true });
26096 var rxjs_1 = require("rxjs");
26097 var operators_1 = require("rxjs/operators");
26098 var THREE = require("three");
26099 var when = require("when");
26100 var Component_1 = require("../../Component");
26101 var Render_1 = require("../../Render");
26102 var Graph_1 = require("../../Graph");
26103 var Geo_1 = require("../../Geo");
26105 * @class MarkerComponent
26107 * @classdesc Component for showing and editing 3D marker objects.
26109 * The `add` method is used for adding new markers or replacing
26110 * markers already in the set.
26112 * If a marker already in the set has the same
26113 * id as one of the markers added, the old marker will be removed and
26114 * the added marker will take its place.
26116 * It is not possible to update markers in the set by updating any properties
26117 * directly on the marker object. Markers need to be replaced by
26118 * re-adding them for updates to geographic position or configuration
26121 * Markers added to the marker component can be either interactive
26122 * or non-interactive. Different marker types define their behavior.
26123 * Markers with interaction support can be configured with options
26124 * to respond to dragging inside the viewer and be detected when
26125 * retrieving markers from pixel points with the `getMarkerIdAt` method.
26127 * To retrive and use the marker component
26131 * var viewer = new Mapillary.Viewer(
26135 * { component: { marker: true } });
26137 * var markerComponent = viewer.getComponent("marker");
26140 var MarkerComponent = /** @class */ (function (_super) {
26141 __extends(MarkerComponent, _super);
26143 function MarkerComponent(name, container, navigator) {
26144 var _this = _super.call(this, name, container, navigator) || this;
26145 _this._relativeGroundAltitude = -2;
26146 _this._geoCoords = new Geo_1.GeoCoords();
26147 _this._graphCalculator = new Graph_1.GraphCalculator();
26148 _this._markerScene = new Component_1.MarkerScene();
26149 _this._markerSet = new Component_1.MarkerSet();
26150 _this._viewportCoords = new Geo_1.ViewportCoords();
26154 * Add markers to the marker set or replace markers in the marker set.
26156 * @description If a marker already in the set has the same
26157 * id as one of the markers added, the old marker will be removed
26158 * the added marker will take its place.
26160 * Any marker inside the visible bounding bbox
26161 * will be initialized and placed in the viewer.
26163 * @param {Array<Marker>} markers - Markers to add.
26165 * @example ```markerComponent.add([marker1, marker2]);```
26167 MarkerComponent.prototype.add = function (markers) {
26168 this._markerSet.add(markers);
26171 * Returns the marker in the marker set with the specified id, or
26172 * undefined if the id matches no marker.
26174 * @param {string} markerId - Id of the marker.
26176 * @example ```var marker = markerComponent.get("markerId");```
26179 MarkerComponent.prototype.get = function (markerId) {
26180 return this._markerSet.get(markerId);
26183 * Returns an array of all markers.
26185 * @example ```var markers = markerComponent.getAll();```
26187 MarkerComponent.prototype.getAll = function () {
26188 return this._markerSet.getAll();
26191 * Returns the id of the interactive marker closest to the current camera
26192 * position at the specified point.
26194 * @description Notice that the pixelPoint argument requires x, y
26195 * coordinates from pixel space.
26197 * With this function, you can use the coordinates provided by mouse
26198 * events to get information out of the marker component.
26200 * If no interactive geometry of an interactive marker exist at the pixel
26201 * point, `null` will be returned.
26203 * @param {Array<number>} pixelPoint - Pixel coordinates on the viewer element.
26204 * @returns {string} Id of the interactive marker closest to the camera. If no
26205 * interactive marker exist at the pixel point, `null` will be returned.
26209 * markerComponent.getMarkerIdAt([100, 100])
26210 * .then((markerId) => { console.log(markerId); });
26213 MarkerComponent.prototype.getMarkerIdAt = function (pixelPoint) {
26215 return when.promise(function (resolve, reject) {
26216 _this._container.renderService.renderCamera$.pipe(operators_1.first(), operators_1.map(function (render) {
26217 var viewport = _this._viewportCoords
26218 .canvasToViewport(pixelPoint[0], pixelPoint[1], _this._container.element);
26219 var id = _this._markerScene.intersectObjects(viewport, render.perspective);
26222 .subscribe(function (id) {
26224 }, function (error) {
26230 * Check if a marker exist in the marker set.
26232 * @param {string} markerId - Id of the marker.
26234 * @example ```var markerExists = markerComponent.has("markerId");```
26236 MarkerComponent.prototype.has = function (markerId) {
26237 return this._markerSet.has(markerId);
26240 * Remove markers with the specified ids from the marker set.
26242 * @param {Array<string>} markerIds - Ids for markers to remove.
26244 * @example ```markerComponent.remove(["id-1", "id-2"]);```
26246 MarkerComponent.prototype.remove = function (markerIds) {
26247 this._markerSet.remove(markerIds);
26250 * Remove all markers from the marker set.
26252 * @example ```markerComponent.removeAll();```
26254 MarkerComponent.prototype.removeAll = function () {
26255 this._markerSet.removeAll();
26257 MarkerComponent.prototype._activate = function () {
26259 var groundAltitude$ = this._navigator.stateService.currentState$.pipe(operators_1.map(function (frame) {
26260 return frame.state.camera.position.z + _this._relativeGroundAltitude;
26261 }), operators_1.distinctUntilChanged(function (a1, a2) {
26262 return Math.abs(a1 - a2) < 0.01;
26263 }), operators_1.publishReplay(1), operators_1.refCount());
26264 var geoInitiated$ = rxjs_1.combineLatest(groundAltitude$, this._navigator.stateService.reference$).pipe(operators_1.first(), operators_1.map(function () { }), operators_1.publishReplay(1), operators_1.refCount());
26265 var clampedConfiguration$ = this._configuration$.pipe(operators_1.map(function (configuration) {
26266 return { visibleBBoxSize: Math.max(1, Math.min(200, configuration.visibleBBoxSize)) };
26268 var currentlatLon$ = this._navigator.stateService.currentNode$.pipe(operators_1.map(function (node) { return node.latLon; }), operators_1.publishReplay(1), operators_1.refCount());
26269 var visibleBBox$ = rxjs_1.combineLatest(clampedConfiguration$, currentlatLon$).pipe(operators_1.map(function (_a) {
26270 var configuration = _a[0], latLon = _a[1];
26271 return _this._graphCalculator
26272 .boundingBoxCorners(latLon, configuration.visibleBBoxSize / 2);
26273 }), operators_1.publishReplay(1), operators_1.refCount());
26274 var visibleMarkers$ = rxjs_1.combineLatest(rxjs_1.concat(rxjs_1.of(this._markerSet), this._markerSet.changed$), visibleBBox$).pipe(operators_1.map(function (_a) {
26275 var set = _a[0], bbox = _a[1];
26276 return set.search(bbox);
26278 this._setChangedSubscription = geoInitiated$.pipe(operators_1.switchMap(function () {
26279 return visibleMarkers$.pipe(operators_1.withLatestFrom(_this._navigator.stateService.reference$, groundAltitude$));
26281 .subscribe(function (_a) {
26282 var markers = _a[0], reference = _a[1], alt = _a[2];
26283 var geoCoords = _this._geoCoords;
26284 var markerScene = _this._markerScene;
26285 var sceneMarkers = markerScene.markers;
26286 var markersToRemove = Object.assign({}, sceneMarkers);
26287 for (var _i = 0, markers_1 = markers; _i < markers_1.length; _i++) {
26288 var marker = markers_1[_i];
26289 if (marker.id in sceneMarkers) {
26290 delete markersToRemove[marker.id];
26293 var point3d = geoCoords
26294 .geodeticToEnu(marker.latLon.lat, marker.latLon.lon, reference.alt + alt, reference.lat, reference.lon, reference.alt);
26295 markerScene.add(marker, point3d);
26298 for (var id in markersToRemove) {
26299 if (!markersToRemove.hasOwnProperty(id)) {
26302 markerScene.remove(id);
26305 this._markersUpdatedSubscription = geoInitiated$.pipe(operators_1.switchMap(function () {
26306 return _this._markerSet.updated$.pipe(operators_1.withLatestFrom(visibleBBox$, _this._navigator.stateService.reference$, groundAltitude$));
26308 .subscribe(function (_a) {
26309 var markers = _a[0], _b = _a[1], sw = _b[0], ne = _b[1], reference = _a[2], alt = _a[3];
26310 var geoCoords = _this._geoCoords;
26311 var markerScene = _this._markerScene;
26312 for (var _i = 0, markers_2 = markers; _i < markers_2.length; _i++) {
26313 var marker = markers_2[_i];
26314 var exists = markerScene.has(marker.id);
26315 var visible = marker.latLon.lat > sw.lat &&
26316 marker.latLon.lat < ne.lat &&
26317 marker.latLon.lon > sw.lon &&
26318 marker.latLon.lon < ne.lon;
26320 var point3d = geoCoords
26321 .geodeticToEnu(marker.latLon.lat, marker.latLon.lon, reference.alt + alt, reference.lat, reference.lon, reference.alt);
26322 markerScene.add(marker, point3d);
26324 else if (!visible && exists) {
26325 markerScene.remove(marker.id);
26329 this._referenceSubscription = this._navigator.stateService.reference$.pipe(operators_1.skip(1), operators_1.withLatestFrom(groundAltitude$))
26330 .subscribe(function (_a) {
26331 var reference = _a[0], alt = _a[1];
26332 var geoCoords = _this._geoCoords;
26333 var markerScene = _this._markerScene;
26334 for (var _i = 0, _b = markerScene.getAll(); _i < _b.length; _i++) {
26335 var marker = _b[_i];
26336 var point3d = geoCoords
26337 .geodeticToEnu(marker.latLon.lat, marker.latLon.lon, reference.alt + alt, reference.lat, reference.lon, reference.alt);
26338 markerScene.update(marker.id, point3d);
26341 this._adjustHeightSubscription = groundAltitude$.pipe(operators_1.skip(1), operators_1.withLatestFrom(this._navigator.stateService.reference$, currentlatLon$))
26342 .subscribe(function (_a) {
26343 var alt = _a[0], reference = _a[1], latLon = _a[2];
26344 var geoCoords = _this._geoCoords;
26345 var markerScene = _this._markerScene;
26346 var position = geoCoords
26347 .geodeticToEnu(latLon.lat, latLon.lon, reference.alt + alt, reference.lat, reference.lon, reference.alt);
26348 for (var _i = 0, _b = markerScene.getAll(); _i < _b.length; _i++) {
26349 var marker = _b[_i];
26350 var point3d = geoCoords
26351 .geodeticToEnu(marker.latLon.lat, marker.latLon.lon, reference.alt + alt, reference.lat, reference.lon, reference.alt);
26352 var distanceX = point3d[0] - position[0];
26353 var distanceY = point3d[1] - position[1];
26354 var groundDistance = Math.sqrt(distanceX * distanceX + distanceY * distanceY);
26355 if (groundDistance > 50) {
26358 markerScene.lerpAltitude(marker.id, alt, Math.min(1, Math.max(0, 1.2 - 1.2 * groundDistance / 50)));
26361 this._renderSubscription = this._navigator.stateService.currentState$.pipe(operators_1.map(function (frame) {
26362 var scene = _this._markerScene;
26367 needsRender: scene.needsRender,
26368 render: scene.render.bind(scene),
26369 stage: Render_1.GLRenderStage.Foreground,
26373 .subscribe(this._container.glRenderer.render$);
26374 var hoveredMarkerId$ = rxjs_1.combineLatest(this._container.renderService.renderCamera$, this._container.mouseService.mouseMove$).pipe(operators_1.map(function (_a) {
26375 var render = _a[0], event = _a[1];
26376 var element = _this._container.element;
26377 var _b = _this._viewportCoords.canvasPosition(event, element), canvasX = _b[0], canvasY = _b[1];
26378 var viewport = _this._viewportCoords.canvasToViewport(canvasX, canvasY, element);
26379 var markerId = _this._markerScene.intersectObjects(viewport, render.perspective);
26381 }), operators_1.publishReplay(1), operators_1.refCount());
26382 var draggingStarted$ = this._container.mouseService
26383 .filtered$(this._name, this._container.mouseService.mouseDragStart$).pipe(operators_1.map(function (event) {
26386 var draggingStopped$ = this._container.mouseService
26387 .filtered$(this._name, this._container.mouseService.mouseDragEnd$).pipe(operators_1.map(function (event) {
26390 var filteredDragging$ = rxjs_1.merge(draggingStarted$, draggingStopped$).pipe(operators_1.startWith(false));
26391 this._dragEventSubscription = rxjs_1.merge(draggingStarted$.pipe(operators_1.withLatestFrom(hoveredMarkerId$)), rxjs_1.combineLatest(draggingStopped$, rxjs_1.of(null))).pipe(operators_1.startWith([false, null]), operators_1.pairwise())
26392 .subscribe(function (_a) {
26393 var previous = _a[0], current = _a[1];
26394 var dragging = current[0];
26395 var eventType = dragging ? MarkerComponent.dragstart : MarkerComponent.dragend;
26396 var id = dragging ? current[1] : previous[1];
26397 var marker = _this._markerScene.get(id);
26398 var markerEvent = { marker: marker, target: _this, type: eventType };
26399 _this.fire(eventType, markerEvent);
26401 var mouseDown$ = rxjs_1.merge(this._container.mouseService.mouseDown$.pipe(operators_1.map(function (event) { return true; })), this._container.mouseService.documentMouseUp$.pipe(operators_1.map(function (event) { return false; }))).pipe(operators_1.startWith(false));
26402 this._mouseClaimSubscription = rxjs_1.combineLatest(this._container.mouseService.active$, hoveredMarkerId$.pipe(operators_1.distinctUntilChanged()), mouseDown$, filteredDragging$).pipe(operators_1.map(function (_a) {
26403 var active = _a[0], markerId = _a[1], mouseDown = _a[2], filteredDragging = _a[3];
26404 return (!active && markerId != null && mouseDown) || filteredDragging;
26405 }), operators_1.distinctUntilChanged())
26406 .subscribe(function (claim) {
26408 _this._container.mouseService.claimMouse(_this._name, 1);
26409 _this._container.mouseService.claimWheel(_this._name, 1);
26412 _this._container.mouseService.unclaimMouse(_this._name);
26413 _this._container.mouseService.unclaimWheel(_this._name);
26416 var offset$ = this._container.mouseService
26417 .filtered$(this._name, this._container.mouseService.mouseDragStart$).pipe(operators_1.withLatestFrom(hoveredMarkerId$, this._container.renderService.renderCamera$), operators_1.map(function (_a) {
26418 var e = _a[0], id = _a[1], r = _a[2];
26419 var marker = _this._markerScene.get(id);
26420 var element = _this._container.element;
26421 var _b = _this._viewportCoords.projectToCanvas(marker.geometry.position.toArray(), element, r.perspective), groundCanvasX = _b[0], groundCanvasY = _b[1];
26422 var _c = _this._viewportCoords.canvasPosition(e, element), canvasX = _c[0], canvasY = _c[1];
26423 var offset = [canvasX - groundCanvasX, canvasY - groundCanvasY];
26424 return [marker, offset, r];
26425 }), operators_1.publishReplay(1), operators_1.refCount());
26426 this._updateMarkerSubscription = this._container.mouseService
26427 .filtered$(this._name, this._container.mouseService.mouseDrag$).pipe(operators_1.withLatestFrom(offset$, this._navigator.stateService.reference$, clampedConfiguration$))
26428 .subscribe(function (_a) {
26429 var event = _a[0], _b = _a[1], marker = _b[0], offset = _b[1], render = _b[2], reference = _a[2], configuration = _a[3];
26430 if (!_this._markerScene.has(marker.id)) {
26433 var element = _this._container.element;
26434 var _c = _this._viewportCoords.canvasPosition(event, element), canvasX = _c[0], canvasY = _c[1];
26435 var groundX = canvasX - offset[0];
26436 var groundY = canvasY - offset[1];
26437 var _d = _this._viewportCoords
26438 .canvasToViewport(groundX, groundY, element), viewportX = _d[0], viewportY = _d[1];
26439 var direction = new THREE.Vector3(viewportX, viewportY, 1)
26440 .unproject(render.perspective)
26441 .sub(render.perspective.position)
26443 var distance = Math.min(_this._relativeGroundAltitude / direction.z, configuration.visibleBBoxSize / 2 - 0.1);
26444 if (distance < 0) {
26447 var intersection = direction
26449 .multiplyScalar(distance)
26450 .add(render.perspective.position);
26451 intersection.z = render.perspective.position.z + _this._relativeGroundAltitude;
26452 var _e = _this._geoCoords
26453 .enuToGeodetic(intersection.x, intersection.y, intersection.z, reference.lat, reference.lon, reference.alt), lat = _e[0], lon = _e[1];
26454 _this._markerScene.update(marker.id, intersection.toArray(), { lat: lat, lon: lon });
26455 _this._markerSet.update(marker);
26456 var markerEvent = { marker: marker, target: _this, type: MarkerComponent.changed };
26457 _this.fire(MarkerComponent.changed, markerEvent);
26460 MarkerComponent.prototype._deactivate = function () {
26461 this._adjustHeightSubscription.unsubscribe();
26462 this._dragEventSubscription.unsubscribe();
26463 this._markersUpdatedSubscription.unsubscribe();
26464 this._mouseClaimSubscription.unsubscribe();
26465 this._referenceSubscription.unsubscribe();
26466 this._renderSubscription.unsubscribe();
26467 this._setChangedSubscription.unsubscribe();
26468 this._updateMarkerSubscription.unsubscribe();
26469 this._markerScene.clear();
26471 MarkerComponent.prototype._getDefaultConfiguration = function () {
26472 return { visibleBBoxSize: 100 };
26474 MarkerComponent.componentName = "marker";
26476 * Fired when the position of a marker is changed.
26478 * @type {IMarkerEvent} markerEvent - Marker event data.
26481 * markerComponent.on("changed", function(e) {
26482 * console.log(e.marker.id, e.marker.latLon);
26486 MarkerComponent.changed = "changed";
26488 * Fired when a marker drag interaction starts.
26490 * @type {IMarkerEvent} markerEvent - Marker event data.
26493 * markerComponent.on("dragstart", function(e) {
26494 * console.log(e.marker.id, e.marker.latLon);
26498 MarkerComponent.dragstart = "dragstart";
26500 * Fired when a marker drag interaction ends.
26502 * @type {IMarkerEvent} markerEvent - Marker event data.
26505 * markerComponent.on("dragend", function(e) {
26506 * console.log(e.marker.id, e.marker.latLon);
26510 MarkerComponent.dragend = "dragend";
26511 return MarkerComponent;
26512 }(Component_1.Component));
26513 exports.MarkerComponent = MarkerComponent;
26514 Component_1.ComponentService.register(MarkerComponent);
26515 exports.default = MarkerComponent;
26518 },{"../../Component":275,"../../Geo":278,"../../Graph":279,"../../Render":281,"rxjs":27,"rxjs/operators":225,"three":226,"when":272}],317:[function(require,module,exports){
26520 Object.defineProperty(exports, "__esModule", { value: true });
26521 var THREE = require("three");
26522 var MarkerScene = /** @class */ (function () {
26523 function MarkerScene(scene, raycaster) {
26524 this._needsRender = false;
26525 this._interactiveObjects = [];
26526 this._markers = {};
26527 this._objectMarkers = {};
26528 this._raycaster = !!raycaster ? raycaster : new THREE.Raycaster();
26529 this._scene = !!scene ? scene : new THREE.Scene();
26531 Object.defineProperty(MarkerScene.prototype, "markers", {
26533 return this._markers;
26538 Object.defineProperty(MarkerScene.prototype, "needsRender", {
26540 return this._needsRender;
26545 MarkerScene.prototype.add = function (marker, position) {
26546 if (marker.id in this._markers) {
26547 this._dispose(marker.id);
26549 marker.createGeometry(position);
26550 this._scene.add(marker.geometry);
26551 this._markers[marker.id] = marker;
26552 for (var _i = 0, _a = marker.getInteractiveObjects(); _i < _a.length; _i++) {
26553 var interactiveObject = _a[_i];
26554 this._interactiveObjects.push(interactiveObject);
26555 this._objectMarkers[interactiveObject.uuid] = marker.id;
26557 this._needsRender = true;
26559 MarkerScene.prototype.clear = function () {
26560 for (var id in this._markers) {
26561 if (!this._markers.hasOwnProperty) {
26566 this._needsRender = true;
26568 MarkerScene.prototype.get = function (id) {
26569 return this._markers[id];
26571 MarkerScene.prototype.getAll = function () {
26574 .keys(this._markers)
26575 .map(function (id) { return _this._markers[id]; });
26577 MarkerScene.prototype.has = function (id) {
26578 return id in this._markers;
26580 MarkerScene.prototype.intersectObjects = function (_a, camera) {
26581 var viewportX = _a[0], viewportY = _a[1];
26582 this._raycaster.setFromCamera(new THREE.Vector2(viewportX, viewportY), camera);
26583 var intersects = this._raycaster.intersectObjects(this._interactiveObjects);
26584 for (var _i = 0, intersects_1 = intersects; _i < intersects_1.length; _i++) {
26585 var intersect = intersects_1[_i];
26586 if (intersect.object.uuid in this._objectMarkers) {
26587 return this._objectMarkers[intersect.object.uuid];
26592 MarkerScene.prototype.lerpAltitude = function (id, alt, alpha) {
26593 if (!(id in this._markers)) {
26596 this._markers[id].lerpAltitude(alt, alpha);
26597 this._needsRender = true;
26599 MarkerScene.prototype.remove = function (id) {
26600 if (!(id in this._markers)) {
26604 this._needsRender = true;
26606 MarkerScene.prototype.render = function (perspectiveCamera, renderer) {
26607 renderer.render(this._scene, perspectiveCamera);
26608 this._needsRender = false;
26610 MarkerScene.prototype.update = function (id, position, latLon) {
26611 if (!(id in this._markers)) {
26614 var marker = this._markers[id];
26615 marker.updatePosition(position, latLon);
26616 this._needsRender = true;
26618 MarkerScene.prototype._dispose = function (id) {
26619 var marker = this._markers[id];
26620 this._scene.remove(marker.geometry);
26621 for (var _i = 0, _a = marker.getInteractiveObjects(); _i < _a.length; _i++) {
26622 var interactiveObject = _a[_i];
26623 var index = this._interactiveObjects.indexOf(interactiveObject);
26624 if (index !== -1) {
26625 this._interactiveObjects.splice(index, 1);
26628 console.warn("Object does not exist (" + interactiveObject.id + ") for " + id);
26630 delete this._objectMarkers[interactiveObject.uuid];
26632 marker.disposeGeometry();
26633 delete this._markers[id];
26635 return MarkerScene;
26637 exports.MarkerScene = MarkerScene;
26638 exports.default = MarkerScene;
26640 },{"three":226}],318:[function(require,module,exports){
26642 Object.defineProperty(exports, "__esModule", { value: true });
26643 var rbush = require("rbush");
26644 var rxjs_1 = require("rxjs");
26645 var MarkerSet = /** @class */ (function () {
26646 function MarkerSet() {
26648 this._index = rbush(16, [".lon", ".lat", ".lon", ".lat"]);
26649 this._indexChanged$ = new rxjs_1.Subject();
26650 this._updated$ = new rxjs_1.Subject();
26652 Object.defineProperty(MarkerSet.prototype, "changed$", {
26654 return this._indexChanged$;
26659 Object.defineProperty(MarkerSet.prototype, "updated$", {
26661 return this._updated$;
26666 MarkerSet.prototype.add = function (markers) {
26668 var hash = this._hash;
26669 var index = this._index;
26670 for (var _i = 0, markers_1 = markers; _i < markers_1.length; _i++) {
26671 var marker = markers_1[_i];
26672 var id = marker.id;
26674 index.remove(hash[id]);
26675 updated.push(marker);
26678 lat: marker.latLon.lat,
26679 lon: marker.latLon.lon,
26683 index.insert(item);
26685 if (updated.length > 0) {
26686 this._updated$.next(updated);
26688 if (markers.length > updated.length) {
26689 this._indexChanged$.next(this);
26692 MarkerSet.prototype.has = function (id) {
26693 return id in this._hash;
26695 MarkerSet.prototype.get = function (id) {
26696 return this.has(id) ? this._hash[id].marker : undefined;
26698 MarkerSet.prototype.getAll = function () {
26701 .map(function (indexItem) {
26702 return indexItem.marker;
26705 MarkerSet.prototype.remove = function (ids) {
26706 var hash = this._hash;
26707 var index = this._index;
26708 var changed = false;
26709 for (var _i = 0, ids_1 = ids; _i < ids_1.length; _i++) {
26710 var id = ids_1[_i];
26711 if (!(id in hash)) {
26714 var item = hash[id];
26715 index.remove(item);
26720 this._indexChanged$.next(this);
26723 MarkerSet.prototype.removeAll = function () {
26725 this._index.clear();
26726 this._indexChanged$.next(this);
26728 MarkerSet.prototype.search = function (_a) {
26729 var sw = _a[0], ne = _a[1];
26731 .search({ maxX: ne.lon, maxY: ne.lat, minX: sw.lon, minY: sw.lat })
26732 .map(function (indexItem) {
26733 return indexItem.marker;
26736 MarkerSet.prototype.update = function (marker) {
26737 var hash = this._hash;
26738 var index = this._index;
26739 var id = marker.id;
26740 if (!(id in hash)) {
26743 index.remove(hash[id]);
26745 lat: marker.latLon.lat,
26746 lon: marker.latLon.lon,
26750 index.insert(item);
26754 exports.MarkerSet = MarkerSet;
26755 exports.default = MarkerSet;
26757 },{"rbush":26,"rxjs":27}],319:[function(require,module,exports){
26759 var __extends = (this && this.__extends) || (function () {
26760 var extendStatics = function (d, b) {
26761 extendStatics = Object.setPrototypeOf ||
26762 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
26763 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
26764 return extendStatics(d, b);
26766 return function (d, b) {
26767 extendStatics(d, b);
26768 function __() { this.constructor = d; }
26769 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
26772 Object.defineProperty(exports, "__esModule", { value: true });
26773 var THREE = require("three");
26774 var Component_1 = require("../../../Component");
26776 * @class CircleMarker
26778 * @classdesc Non-interactive marker with a flat circle shape. The circle
26779 * marker can not be configured to be interactive.
26781 * Circle marker properties can not be updated after creation.
26783 * To create and add one `CircleMarker` with default configuration
26784 * and one with configuration use
26788 * var defaultMarker = new Mapillary.MarkerComponent.CircleMarker(
26790 * { lat: 0, lon: 0, });
26792 * var configuredMarker = new Mapillary.MarkerComponent.CircleMarker(
26794 * { lat: 0, lon: 0, },
26801 * markerComponent.add([defaultMarker, configuredMarker]);
26804 var CircleMarker = /** @class */ (function (_super) {
26805 __extends(CircleMarker, _super);
26806 function CircleMarker(id, latLon, options) {
26807 var _this = _super.call(this, id, latLon) || this;
26808 options = !!options ? options : {};
26809 _this._color = options.color != null ? options.color : 0xffffff;
26810 _this._opacity = options.opacity != null ? options.opacity : 0.4;
26811 _this._radius = options.radius != null ? options.radius : 1;
26814 CircleMarker.prototype._createGeometry = function (position) {
26815 var circle = new THREE.Mesh(new THREE.CircleGeometry(this._radius, 16), new THREE.MeshBasicMaterial({
26816 color: this._color,
26817 opacity: this._opacity,
26820 circle.up.fromArray([0, 0, 1]);
26821 circle.renderOrder = -1;
26822 var group = new THREE.Object3D();
26824 group.position.fromArray(position);
26825 this._geometry = group;
26827 CircleMarker.prototype._disposeGeometry = function () {
26828 for (var _i = 0, _a = this._geometry.children; _i < _a.length; _i++) {
26830 mesh.geometry.dispose();
26831 mesh.material.dispose();
26834 CircleMarker.prototype._getInteractiveObjects = function () {
26837 return CircleMarker;
26838 }(Component_1.Marker));
26839 exports.CircleMarker = CircleMarker;
26840 exports.default = CircleMarker;
26842 },{"../../../Component":275,"three":226}],320:[function(require,module,exports){
26844 Object.defineProperty(exports, "__esModule", { value: true });
26848 * @classdesc Represents an abstract marker class that should be extended
26849 * by marker implementations used in the marker component.
26851 var Marker = /** @class */ (function () {
26852 function Marker(id, latLon) {
26854 this._latLon = latLon;
26856 Object.defineProperty(Marker.prototype, "id", {
26859 * @returns {string} The id of the marker.
26867 Object.defineProperty(Marker.prototype, "geometry", {
26874 return this._geometry;
26879 Object.defineProperty(Marker.prototype, "latLon", {
26882 * @returns {ILatLon} The geographic coordinates of the marker.
26885 return this._latLon;
26891 Marker.prototype.createGeometry = function (position) {
26892 if (!!this._geometry) {
26895 this._createGeometry(position);
26896 // update matrix world if raycasting occurs before first render
26897 this._geometry.updateMatrixWorld(true);
26900 Marker.prototype.disposeGeometry = function () {
26901 if (!this._geometry) {
26904 this._disposeGeometry();
26905 this._geometry = undefined;
26908 Marker.prototype.getInteractiveObjects = function () {
26909 if (!this._geometry) {
26912 return this._getInteractiveObjects();
26915 Marker.prototype.lerpAltitude = function (alt, alpha) {
26916 if (!this._geometry) {
26919 this._geometry.position.z = (1 - alpha) * this._geometry.position.z + alpha * alt;
26922 Marker.prototype.updatePosition = function (position, latLon) {
26924 this._latLon.lat = latLon.lat;
26925 this._latLon.lon = latLon.lon;
26927 if (!this._geometry) {
26930 this._geometry.position.fromArray(position);
26931 this._geometry.updateMatrixWorld(true);
26935 exports.Marker = Marker;
26936 exports.default = Marker;
26938 },{}],321:[function(require,module,exports){
26940 var __extends = (this && this.__extends) || (function () {
26941 var extendStatics = function (d, b) {
26942 extendStatics = Object.setPrototypeOf ||
26943 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
26944 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
26945 return extendStatics(d, b);
26947 return function (d, b) {
26948 extendStatics(d, b);
26949 function __() { this.constructor = d; }
26950 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
26953 Object.defineProperty(exports, "__esModule", { value: true });
26954 var THREE = require("three");
26955 var Component_1 = require("../../../Component");
26957 * @class SimpleMarker
26959 * @classdesc Interactive marker with ice cream shape. The sphere
26960 * inside the ice cream can be configured to be interactive.
26962 * Simple marker properties can not be updated after creation.
26964 * To create and add one `SimpleMarker` with default configuration
26965 * (non-interactive) and one interactive with configuration use
26969 * var defaultMarker = new Mapillary.MarkerComponent.SimpleMarker(
26971 * { lat: 0, lon: 0, });
26973 * var interactiveMarker = new Mapillary.MarkerComponent.SimpleMarker(
26975 * { lat: 0, lon: 0, },
26977 * ballColor: "#00f",
26978 * ballOpacity: 0.5,
26980 * interactive: true,
26985 * markerComponent.add([defaultMarker, interactiveMarker]);
26988 var SimpleMarker = /** @class */ (function (_super) {
26989 __extends(SimpleMarker, _super);
26990 function SimpleMarker(id, latLon, options) {
26991 var _this = _super.call(this, id, latLon) || this;
26992 options = !!options ? options : {};
26993 _this._ballColor = options.ballColor != null ? options.ballColor : 0xff0000;
26994 _this._ballOpacity = options.ballOpacity != null ? options.ballOpacity : 0.8;
26995 _this._circleToRayAngle = 2;
26996 _this._color = options.color != null ? options.color : 0xff0000;
26997 _this._interactive = !!options.interactive;
26998 _this._opacity = options.opacity != null ? options.opacity : 0.4;
26999 _this._radius = options.radius != null ? options.radius : 1;
27002 SimpleMarker.prototype._createGeometry = function (position) {
27003 var radius = this._radius;
27004 var cone = new THREE.Mesh(this._markerGeometry(radius, 8, 8), new THREE.MeshBasicMaterial({
27005 color: this._color,
27006 opacity: this._opacity,
27009 cone.renderOrder = 1;
27010 var ball = new THREE.Mesh(new THREE.SphereGeometry(radius / 2, 8, 8), new THREE.MeshBasicMaterial({
27011 color: this._ballColor,
27012 opacity: this._ballOpacity,
27015 ball.position.z = this._markerHeight(radius);
27016 var group = new THREE.Object3D();
27019 group.position.fromArray(position);
27020 this._geometry = group;
27022 SimpleMarker.prototype._disposeGeometry = function () {
27023 for (var _i = 0, _a = this._geometry.children; _i < _a.length; _i++) {
27025 mesh.geometry.dispose();
27026 mesh.material.dispose();
27029 SimpleMarker.prototype._getInteractiveObjects = function () {
27030 return this._interactive ? [this._geometry.children[0]] : [];
27032 SimpleMarker.prototype._markerHeight = function (radius) {
27033 var t = Math.tan(Math.PI - this._circleToRayAngle);
27034 return radius * Math.sqrt(1 + t * t);
27036 SimpleMarker.prototype._markerGeometry = function (radius, widthSegments, heightSegments) {
27037 var geometry = new THREE.Geometry();
27038 widthSegments = Math.max(3, Math.floor(widthSegments) || 8);
27039 heightSegments = Math.max(2, Math.floor(heightSegments) || 6);
27040 var height = this._markerHeight(radius);
27042 for (var y = 0; y <= heightSegments; ++y) {
27043 var verticesRow = [];
27044 for (var x = 0; x <= widthSegments; ++x) {
27045 var u = x / widthSegments * Math.PI * 2;
27046 var v = y / heightSegments * Math.PI;
27048 if (v < this._circleToRayAngle) {
27052 var t = Math.tan(v - this._circleToRayAngle);
27053 r = radius * Math.sqrt(1 + t * t);
27055 var vertex = new THREE.Vector3();
27056 vertex.x = r * Math.cos(u) * Math.sin(v);
27057 vertex.y = r * Math.sin(u) * Math.sin(v);
27058 vertex.z = r * Math.cos(v) + height;
27059 geometry.vertices.push(vertex);
27060 verticesRow.push(geometry.vertices.length - 1);
27062 vertices.push(verticesRow);
27064 for (var y = 0; y < heightSegments; ++y) {
27065 for (var x = 0; x < widthSegments; ++x) {
27066 var v1 = vertices[y][x + 1];
27067 var v2 = vertices[y][x];
27068 var v3 = vertices[y + 1][x];
27069 var v4 = vertices[y + 1][x + 1];
27070 var n1 = geometry.vertices[v1].clone().normalize();
27071 var n2 = geometry.vertices[v2].clone().normalize();
27072 var n3 = geometry.vertices[v3].clone().normalize();
27073 var n4 = geometry.vertices[v4].clone().normalize();
27074 geometry.faces.push(new THREE.Face3(v1, v2, v4, [n1, n2, n4]));
27075 geometry.faces.push(new THREE.Face3(v2, v3, v4, [n2.clone(), n3, n4.clone()]));
27078 geometry.computeFaceNormals();
27079 geometry.boundingSphere = new THREE.Sphere(new THREE.Vector3(), radius + height);
27082 return SimpleMarker;
27083 }(Component_1.Marker));
27084 exports.SimpleMarker = SimpleMarker;
27085 exports.default = SimpleMarker;
27087 },{"../../../Component":275,"three":226}],322:[function(require,module,exports){
27089 var __extends = (this && this.__extends) || (function () {
27090 var extendStatics = function (d, b) {
27091 extendStatics = Object.setPrototypeOf ||
27092 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
27093 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
27094 return extendStatics(d, b);
27096 return function (d, b) {
27097 extendStatics(d, b);
27098 function __() { this.constructor = d; }
27099 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
27102 Object.defineProperty(exports, "__esModule", { value: true });
27103 var rxjs_1 = require("rxjs");
27104 var operators_1 = require("rxjs/operators");
27105 var Component_1 = require("../../Component");
27107 * The `BounceHandler` ensures that the viewer bounces back to the image
27108 * when drag panning outside of the image edge.
27110 var BounceHandler = /** @class */ (function (_super) {
27111 __extends(BounceHandler, _super);
27112 function BounceHandler(component, container, navigator, viewportCoords, spatial) {
27113 var _this = _super.call(this, component, container, navigator) || this;
27114 _this._spatial = spatial;
27115 _this._viewportCoords = viewportCoords;
27118 BounceHandler.prototype._enable = function () {
27120 var inTransition$ = this._navigator.stateService.currentState$.pipe(operators_1.map(function (frame) {
27121 return frame.state.alpha < 1;
27123 this._bounceSubscription = rxjs_1.combineLatest(inTransition$, this._navigator.stateService.inTranslation$, this._container.mouseService.active$, this._container.touchService.active$).pipe(operators_1.map(function (noForce) {
27124 return noForce[0] || noForce[1] || noForce[2] || noForce[3];
27125 }), operators_1.distinctUntilChanged(), operators_1.switchMap(function (noForce) {
27128 rxjs_1.combineLatest(_this._container.renderService.renderCamera$, _this._navigator.stateService.currentTransform$.pipe(operators_1.first()));
27130 .subscribe(function (_a) {
27131 var render = _a[0], transform = _a[1];
27132 if (!transform.hasValidScale && render.camera.focal < 0.1) {
27135 if (render.perspective.aspect === 0 || render.perspective.aspect === Number.POSITIVE_INFINITY) {
27138 var distances = Component_1.ImageBoundary.viewportDistances(transform, render.perspective, _this._viewportCoords);
27139 if (Math.max.apply(Math, distances) < 0.01) {
27142 var horizontalDistance = distances[1] - distances[3];
27143 var verticalDistance = distances[0] - distances[2];
27144 var currentDirection = _this._viewportCoords
27145 .unprojectFromViewport(0, 0, render.perspective)
27146 .sub(render.perspective.position);
27147 var directionPhi = _this._viewportCoords
27148 .unprojectFromViewport(horizontalDistance, 0, render.perspective)
27149 .sub(render.perspective.position);
27150 var directionTheta = _this._viewportCoords
27151 .unprojectFromViewport(0, verticalDistance, render.perspective)
27152 .sub(render.perspective.position);
27153 var phi = (horizontalDistance > 0 ? 1 : -1) * directionPhi.angleTo(currentDirection);
27154 var theta = (verticalDistance > 0 ? 1 : -1) * directionTheta.angleTo(currentDirection);
27155 var threshold = Math.PI / 60;
27157 phi = _this._spatial.clamp(coeff * phi, -threshold, threshold);
27158 theta = _this._spatial.clamp(coeff * theta, -threshold, threshold);
27159 _this._navigator.stateService.rotateUnbounded({ phi: phi, theta: theta });
27162 BounceHandler.prototype._disable = function () {
27163 this._bounceSubscription.unsubscribe();
27165 BounceHandler.prototype._getConfiguration = function () {
27168 return BounceHandler;
27169 }(Component_1.HandlerBase));
27170 exports.BounceHandler = BounceHandler;
27171 exports.default = BounceHandler;
27173 },{"../../Component":275,"rxjs":27,"rxjs/operators":225}],323:[function(require,module,exports){
27175 var __extends = (this && this.__extends) || (function () {
27176 var extendStatics = function (d, b) {
27177 extendStatics = Object.setPrototypeOf ||
27178 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
27179 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
27180 return extendStatics(d, b);
27182 return function (d, b) {
27183 extendStatics(d, b);
27184 function __() { this.constructor = d; }
27185 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
27188 Object.defineProperty(exports, "__esModule", { value: true });
27189 var rxjs_1 = require("rxjs");
27190 var operators_1 = require("rxjs/operators");
27191 var Component_1 = require("../../Component");
27193 * The `DoubleClickZoomHandler` allows the user to zoom the viewer image at a point by double clicking.
27197 * var mouseComponent = viewer.getComponent("mouse");
27199 * mouseComponent.doubleClickZoom.disable();
27200 * mouseComponent.doubleClickZoom.enable();
27202 * var isEnabled = mouseComponent.doubleClickZoom.isEnabled;
27205 var DoubleClickZoomHandler = /** @class */ (function (_super) {
27206 __extends(DoubleClickZoomHandler, _super);
27208 function DoubleClickZoomHandler(component, container, navigator, viewportCoords) {
27209 var _this = _super.call(this, component, container, navigator) || this;
27210 _this._viewportCoords = viewportCoords;
27213 DoubleClickZoomHandler.prototype._enable = function () {
27215 this._zoomSubscription = rxjs_1.merge(this._container.mouseService
27216 .filtered$(this._component.name, this._container.mouseService.dblClick$), this._container.touchService.doubleTap$.pipe(operators_1.map(function (e) {
27217 var touch = e.touches[0];
27218 return { clientX: touch.clientX, clientY: touch.clientY, shiftKey: e.shiftKey };
27219 }))).pipe(operators_1.withLatestFrom(this._container.renderService.renderCamera$, this._navigator.stateService.currentTransform$))
27220 .subscribe(function (_a) {
27221 var event = _a[0], render = _a[1], transform = _a[2];
27222 var element = _this._container.element;
27223 var _b = _this._viewportCoords.canvasPosition(event, element), canvasX = _b[0], canvasY = _b[1];
27224 var unprojected = _this._viewportCoords.unprojectFromCanvas(canvasX, canvasY, element, render.perspective);
27225 var reference = transform.projectBasic(unprojected.toArray());
27226 var delta = !!event.shiftKey ? -1 : 1;
27227 _this._navigator.stateService.zoomIn(delta, reference);
27230 DoubleClickZoomHandler.prototype._disable = function () {
27231 this._zoomSubscription.unsubscribe();
27233 DoubleClickZoomHandler.prototype._getConfiguration = function (enable) {
27234 return { doubleClickZoom: enable };
27236 return DoubleClickZoomHandler;
27237 }(Component_1.HandlerBase));
27238 exports.DoubleClickZoomHandler = DoubleClickZoomHandler;
27239 exports.default = DoubleClickZoomHandler;
27241 },{"../../Component":275,"rxjs":27,"rxjs/operators":225}],324:[function(require,module,exports){
27243 var __extends = (this && this.__extends) || (function () {
27244 var extendStatics = function (d, b) {
27245 extendStatics = Object.setPrototypeOf ||
27246 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
27247 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
27248 return extendStatics(d, b);
27250 return function (d, b) {
27251 extendStatics(d, b);
27252 function __() { this.constructor = d; }
27253 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
27256 Object.defineProperty(exports, "__esModule", { value: true });
27257 var rxjs_1 = require("rxjs");
27258 var operators_1 = require("rxjs/operators");
27259 var Component_1 = require("../../Component");
27261 * The `DragPanHandler` allows the user to pan the viewer image by clicking and dragging the cursor.
27265 * var mouseComponent = viewer.getComponent("mouse");
27267 * mouseComponent.dragPan.disable();
27268 * mouseComponent.dragPan.enable();
27270 * var isEnabled = mouseComponent.dragPan.isEnabled;
27273 var DragPanHandler = /** @class */ (function (_super) {
27274 __extends(DragPanHandler, _super);
27276 function DragPanHandler(component, container, navigator, viewportCoords, spatial) {
27277 var _this = _super.call(this, component, container, navigator) || this;
27278 _this._spatial = spatial;
27279 _this._viewportCoords = viewportCoords;
27282 DragPanHandler.prototype._enable = function () {
27284 var draggingStarted$ = this._container.mouseService
27285 .filtered$(this._component.name, this._container.mouseService.mouseDragStart$).pipe(operators_1.map(function () {
27287 }), operators_1.share());
27288 var draggingStopped$ = this._container.mouseService
27289 .filtered$(this._component.name, this._container.mouseService.mouseDragEnd$).pipe(operators_1.map(function () {
27291 }), operators_1.share());
27292 this._activeMouseSubscription = rxjs_1.merge(draggingStarted$, draggingStopped$)
27293 .subscribe(this._container.mouseService.activate$);
27294 var documentMouseMove$ = rxjs_1.merge(draggingStarted$, draggingStopped$).pipe(operators_1.switchMap(function (dragging) {
27296 _this._container.mouseService.documentMouseMove$ :
27299 this._preventDefaultSubscription = rxjs_1.merge(documentMouseMove$, this._container.touchService.touchMove$)
27300 .subscribe(function (event) {
27301 event.preventDefault(); // prevent selection of content outside the viewer
27303 var touchMovingStarted$ = this._container.touchService.singleTouchDragStart$.pipe(operators_1.map(function () {
27306 var touchMovingStopped$ = this._container.touchService.singleTouchDragEnd$.pipe(operators_1.map(function () {
27309 this._activeTouchSubscription = rxjs_1.merge(touchMovingStarted$, touchMovingStopped$)
27310 .subscribe(this._container.touchService.activate$);
27311 var rotation$ = this._navigator.stateService.currentState$.pipe(operators_1.map(function (frame) {
27312 return frame.state.currentNode.fullPano || frame.state.nodesAhead < 1;
27313 }), operators_1.distinctUntilChanged(), operators_1.switchMap(function (enable) {
27315 return rxjs_1.empty();
27317 var mouseDrag$ = Component_1.MouseOperator.filteredPairwiseMouseDrag$(_this._component.name, _this._container.mouseService);
27318 var singleTouchDrag$ = rxjs_1.merge(_this._container.touchService.singleTouchDragStart$, _this._container.touchService.singleTouchDrag$, _this._container.touchService.singleTouchDragEnd$.pipe(operators_1.map(function () { return null; }))).pipe(operators_1.map(function (event) {
27319 return event != null && event.touches.length > 0 ?
27320 event.touches[0] : null;
27321 }), operators_1.pairwise(), operators_1.filter(function (pair) {
27322 return pair[0] != null && pair[1] != null;
27324 return rxjs_1.merge(mouseDrag$, singleTouchDrag$);
27325 }), operators_1.withLatestFrom(this._container.renderService.renderCamera$, this._navigator.stateService.currentTransform$), operators_1.map(function (_a) {
27326 var events = _a[0], render = _a[1], transform = _a[2];
27327 var previousEvent = events[0];
27328 var event = events[1];
27329 var movementX = event.clientX - previousEvent.clientX;
27330 var movementY = event.clientY - previousEvent.clientY;
27331 var element = _this._container.element;
27332 var _b = _this._viewportCoords.canvasPosition(event, element), canvasX = _b[0], canvasY = _b[1];
27333 var currentDirection = _this._viewportCoords.unprojectFromCanvas(canvasX, canvasY, element, render.perspective)
27334 .sub(render.perspective.position);
27335 var directionX = _this._viewportCoords.unprojectFromCanvas(canvasX - movementX, canvasY, element, render.perspective)
27336 .sub(render.perspective.position);
27337 var directionY = _this._viewportCoords.unprojectFromCanvas(canvasX, canvasY - movementY, element, render.perspective)
27338 .sub(render.perspective.position);
27339 var phi = (movementX > 0 ? 1 : -1) * directionX.angleTo(currentDirection);
27340 var theta = (movementY > 0 ? -1 : 1) * directionY.angleTo(currentDirection);
27341 var distances = Component_1.ImageBoundary.viewportDistances(transform, render.perspective, _this._viewportCoords);
27342 if (distances[0] > 0 && theta < 0) {
27343 theta /= Math.max(1, 2e2 * distances[0]);
27345 if (distances[2] > 0 && theta > 0) {
27346 theta /= Math.max(1, 2e2 * distances[2]);
27348 if (distances[1] > 0 && phi < 0) {
27349 phi /= Math.max(1, 2e2 * distances[1]);
27351 if (distances[3] > 0 && phi > 0) {
27352 phi /= Math.max(1, 2e2 * distances[3]);
27354 return { phi: phi, theta: theta };
27355 }), operators_1.share());
27356 this._rotateWithoutInertiaSubscription = rotation$
27357 .subscribe(function (rotation) {
27358 _this._navigator.stateService.rotateWithoutInertia(rotation);
27360 this._rotateSubscription = rotation$.pipe(operators_1.scan(function (rotationBuffer, rotation) {
27361 _this._drainBuffer(rotationBuffer);
27362 rotationBuffer.push([Date.now(), rotation]);
27363 return rotationBuffer;
27364 }, []), operators_1.sample(rxjs_1.merge(this._container.mouseService.filtered$(this._component.name, this._container.mouseService.mouseDragEnd$), this._container.touchService.singleTouchDragEnd$)), operators_1.map(function (rotationBuffer) {
27365 var drainedBuffer = _this._drainBuffer(rotationBuffer.slice());
27366 var rotation = { phi: 0, theta: 0 };
27367 for (var _i = 0, drainedBuffer_1 = drainedBuffer; _i < drainedBuffer_1.length; _i++) {
27368 var bufferedRotation = drainedBuffer_1[_i];
27369 rotation.phi += bufferedRotation[1].phi;
27370 rotation.theta += bufferedRotation[1].theta;
27372 var count = drainedBuffer.length;
27374 rotation.phi /= count;
27375 rotation.theta /= count;
27377 var threshold = Math.PI / 18;
27378 rotation.phi = _this._spatial.clamp(rotation.phi, -threshold, threshold);
27379 rotation.theta = _this._spatial.clamp(rotation.theta, -threshold, threshold);
27382 .subscribe(function (rotation) {
27383 _this._navigator.stateService.rotate(rotation);
27386 DragPanHandler.prototype._disable = function () {
27387 this._activeMouseSubscription.unsubscribe();
27388 this._activeTouchSubscription.unsubscribe();
27389 this._preventDefaultSubscription.unsubscribe();
27390 this._rotateSubscription.unsubscribe();
27391 this._rotateWithoutInertiaSubscription.unsubscribe();
27392 this._activeMouseSubscription = null;
27393 this._activeTouchSubscription = null;
27394 this._preventDefaultSubscription = null;
27395 this._rotateSubscription = null;
27397 DragPanHandler.prototype._getConfiguration = function (enable) {
27398 return { dragPan: enable };
27400 DragPanHandler.prototype._drainBuffer = function (buffer) {
27402 var now = Date.now();
27403 while (buffer.length > 0 && now - buffer[0][0] > cutoff) {
27408 return DragPanHandler;
27409 }(Component_1.HandlerBase));
27410 exports.DragPanHandler = DragPanHandler;
27411 exports.default = DragPanHandler;
27413 },{"../../Component":275,"rxjs":27,"rxjs/operators":225}],325:[function(require,module,exports){
27415 var __extends = (this && this.__extends) || (function () {
27416 var extendStatics = function (d, b) {
27417 extendStatics = Object.setPrototypeOf ||
27418 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
27419 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
27420 return extendStatics(d, b);
27422 return function (d, b) {
27423 extendStatics(d, b);
27424 function __() { this.constructor = d; }
27425 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
27428 Object.defineProperty(exports, "__esModule", { value: true });
27429 var THREE = require("three");
27430 var rxjs_1 = require("rxjs");
27431 var operators_1 = require("rxjs/operators");
27432 var Component_1 = require("../../Component");
27433 var State_1 = require("../../State");
27434 var EarthControlHandler = /** @class */ (function (_super) {
27435 __extends(EarthControlHandler, _super);
27436 function EarthControlHandler(component, container, navigator, viewportCoords, spatial) {
27437 var _this = _super.call(this, component, container, navigator) || this;
27438 _this._spatial = spatial;
27439 _this._viewportCoords = viewportCoords;
27442 EarthControlHandler.prototype._enable = function () {
27444 var earth$ = this._navigator.stateService.state$.pipe(operators_1.map(function (state) {
27445 return state === State_1.State.Earth;
27446 }), operators_1.share());
27447 this._preventDefaultSubscription = earth$.pipe(operators_1.switchMap(function (earth) {
27449 _this._container.mouseService.mouseWheel$ :
27452 .subscribe(function (event) {
27453 event.preventDefault();
27455 this._truckSubscription = earth$.pipe(operators_1.switchMap(function (earth) {
27457 return rxjs_1.empty();
27459 return Component_1.MouseOperator.filteredPairwiseMouseDrag$(_this._component.name, _this._container.mouseService).pipe(operators_1.filter(function (_a) {
27460 var e1 = _a[0], e2 = _a[1];
27461 return !(e1.ctrlKey && e2.ctrlKey);
27463 }), operators_1.withLatestFrom(this._container.renderService.renderCamera$, this._navigator.stateService.currentTransform$), operators_1.map(function (_a) {
27464 var _b = _a[0], previous = _b[0], current = _b[1], render = _a[1], transform = _a[2];
27465 var planeNormal = [0, 0, 1];
27466 var planePoint = transform.unprojectBasic([0.5, 0.5], 0);
27467 planePoint[2] -= 2;
27468 var currentIntersection = _this._planeIntersection(current, planeNormal, planePoint, render.perspective, _this._container.element);
27469 var previousIntersection = _this._planeIntersection(previous, planeNormal, planePoint, render.perspective, _this._container.element);
27470 if (!currentIntersection || !previousIntersection) {
27473 var direction = new THREE.Vector3()
27474 .subVectors(currentIntersection, previousIntersection)
27475 .multiplyScalar(-1)
27478 }), operators_1.filter(function (direction) {
27479 return !!direction;
27481 .subscribe(function (direction) {
27482 _this._navigator.stateService.truck(direction);
27484 this._orbitSubscription = earth$.pipe(operators_1.switchMap(function (earth) {
27486 return rxjs_1.empty();
27488 return Component_1.MouseOperator.filteredPairwiseMouseDrag$(_this._component.name, _this._container.mouseService).pipe(operators_1.filter(function (_a) {
27489 var e1 = _a[0], e2 = _a[1];
27490 return e1.ctrlKey && e2.ctrlKey;
27492 }), operators_1.map(function (_a) {
27493 var previous = _a[0], current = _a[1];
27494 var _b = _this._eventToViewport(current, _this._container.element), currentX = _b[0], currentY = _b[1];
27495 var _c = _this._eventToViewport(previous, _this._container.element), previousX = _c[0], previousY = _c[1];
27496 var phi = (previousX - currentX) * Math.PI;
27497 var theta = (currentY - previousY) * Math.PI / 2;
27498 return { phi: phi, theta: theta };
27500 .subscribe(function (rotation) {
27501 _this._navigator.stateService.orbit(rotation);
27503 this._dollySubscription = earth$.pipe(operators_1.switchMap(function (earth) {
27505 return rxjs_1.empty();
27507 return _this._container.mouseService
27508 .filteredWheel$(_this._component.name, _this._container.mouseService.mouseWheel$);
27509 }), operators_1.map(function (event) {
27510 var delta = event.deltaY;
27511 if (event.deltaMode === 1) {
27512 delta = 40 * delta;
27514 else if (event.deltaMode === 2) {
27515 delta = 800 * delta;
27517 var canvasSize = _this._viewportCoords.containerToCanvas(_this._container.element);
27518 return -delta / canvasSize[1];
27520 .subscribe(function (delta) {
27521 _this._navigator.stateService.dolly(delta);
27524 EarthControlHandler.prototype._disable = function () {
27525 this._dollySubscription.unsubscribe();
27526 this._orbitSubscription.unsubscribe();
27527 this._preventDefaultSubscription.unsubscribe();
27528 this._truckSubscription.unsubscribe();
27530 EarthControlHandler.prototype._getConfiguration = function () {
27533 EarthControlHandler.prototype._eventToViewport = function (event, element) {
27534 var previousCanvas = this._viewportCoords.canvasPosition(event, element);
27535 return this._viewportCoords.canvasToViewport(previousCanvas[0], previousCanvas[1], element);
27537 EarthControlHandler.prototype._planeIntersection = function (event, planeNormal, planePoint, camera, element) {
27538 var _a = this._viewportCoords.canvasPosition(event, element), canvasX = _a[0], canvasY = _a[1];
27539 var direction = this._viewportCoords
27540 .unprojectFromCanvas(canvasX, canvasY, element, camera)
27541 .sub(camera.position)
27543 if (Math.abs(this._spatial.angleToPlane(direction.toArray(), planeNormal)) < Math.PI / 90) {
27546 var l0 = camera.position.clone();
27547 var n = new THREE.Vector3().fromArray(planeNormal);
27548 var p0 = new THREE.Vector3().fromArray(planePoint);
27549 var d = new THREE.Vector3().subVectors(p0, l0).dot(n) / direction.clone().dot(n);
27550 var intersection = new THREE.Vector3().addVectors(l0, direction.multiplyScalar(d));
27551 if (this._viewportCoords.worldToCamera(intersection.toArray(), camera)[2] > 0) {
27554 return intersection;
27556 return EarthControlHandler;
27557 }(Component_1.HandlerBase));
27558 exports.EarthControlHandler = EarthControlHandler;
27559 exports.default = EarthControlHandler;
27561 },{"../../Component":275,"../../State":282,"rxjs":27,"rxjs/operators":225,"three":226}],326:[function(require,module,exports){
27563 Object.defineProperty(exports, "__esModule", { value: true });
27564 var Geo_1 = require("../../../src/Geo");
27565 function basicBoundaryPoints(pointsPerSide) {
27567 var os = [[0, 0], [1, 0], [1, 1], [0, 1]];
27568 var ds = [[1, 0], [0, 1], [-1, 0], [0, -1]];
27569 for (var side = 0; side < 4; ++side) {
27572 for (var i = 0; i < pointsPerSide; ++i) {
27573 points.push([o[0] + d[0] * i / pointsPerSide,
27574 o[1] + d[1] * i / pointsPerSide]);
27579 function insideViewport(x, y) {
27580 return x >= -1 && x <= 1 && y >= -1 && y <= 1;
27582 function insideBasic(x, y) {
27583 return x >= 0 && x <= 1 && y >= 0 && y <= 1;
27585 function viewportDistances(transform, perspective, viewportCoords) {
27586 var boundaryPointsBasic = basicBoundaryPoints(100);
27587 var boundaryPointsViewport = boundaryPointsBasic
27588 .map(function (basic) {
27589 return viewportCoords.basicToViewportSafe(basic[0], basic[1], transform, perspective);
27591 var visibleBoundaryPoints = [];
27592 var viewportSides = [
27598 var intersections = [false, false, false, false];
27599 for (var i = 0; i < boundaryPointsViewport.length; i++) {
27600 var p1 = boundaryPointsViewport[i];
27601 var p2 = boundaryPointsViewport[(i + 1) % boundaryPointsViewport.length];
27606 if (insideViewport(p1[0], p1[1])) {
27607 visibleBoundaryPoints.push(p1);
27611 var x1 = p1[0], y1 = p1[1];
27612 var x2 = p2[0], y2 = p2[1];
27613 if (insideViewport(x1, y1)) {
27614 if (insideViewport(x2, y2)) {
27615 visibleBoundaryPoints.push(p1);
27618 for (var side = 0; side < 4; side++) {
27619 var s1 = { p1: { x: x1, y: y1 }, p2: { x: x2, y: y2 } };
27620 var s2 = { p1: viewportSides[side], p2: viewportSides[(side + 1) % 4] };
27621 var intersecting = Geo_1.Lines.segmentsIntersect(s1, s2);
27622 if (intersecting) {
27623 var intersection = Geo_1.Lines.segmentIntersection(s1, s2);
27624 visibleBoundaryPoints.push(p1, [intersection.x, intersection.y]);
27625 intersections[side] = true;
27631 var _a = viewportCoords.viewportToBasic(-1, 1, transform, perspective), topLeftBasicX = _a[0], topLeftBasicY = _a[1];
27632 var _b = viewportCoords.viewportToBasic(1, 1, transform, perspective), topRightBasicX = _b[0], topRightBasicY = _b[1];
27633 var _c = viewportCoords.viewportToBasic(1, -1, transform, perspective), bottomRightBasicX = _c[0], bottomRightBasicY = _c[1];
27634 var _d = viewportCoords.viewportToBasic(-1, -1, transform, perspective), bottomLeftBasicX = _d[0], bottomLeftBasicY = _d[1];
27635 if (insideBasic(topLeftBasicX, topLeftBasicY)) {
27636 intersections[3] = intersections[0] = true;
27638 if (insideBasic(topRightBasicX, topRightBasicY)) {
27639 intersections[0] = intersections[1] = true;
27641 if (insideBasic(bottomRightBasicX, bottomRightBasicY)) {
27642 intersections[1] = intersections[2] = true;
27644 if (insideBasic(bottomLeftBasicX, bottomLeftBasicY)) {
27645 intersections[2] = intersections[3] = true;
27647 var maximums = [-1, -1, 1, 1];
27648 for (var _i = 0, visibleBoundaryPoints_1 = visibleBoundaryPoints; _i < visibleBoundaryPoints_1.length; _i++) {
27649 var visibleBoundaryPoint = visibleBoundaryPoints_1[_i];
27650 var x = visibleBoundaryPoint[0];
27651 var y = visibleBoundaryPoint[1];
27652 if (x > maximums[1]) {
27655 if (x < maximums[3]) {
27658 if (y > maximums[0]) {
27661 if (y < maximums[2]) {
27665 var boundary = [1, 1, -1, -1];
27666 var distances = [];
27667 for (var side = 0; side < 4; side++) {
27668 if (intersections[side]) {
27672 distances.push(Math.abs(boundary[side] - maximums[side]));
27676 exports.viewportDistances = viewportDistances;
27678 },{"../../../src/Geo":278}],327:[function(require,module,exports){
27680 var __extends = (this && this.__extends) || (function () {
27681 var extendStatics = function (d, b) {
27682 extendStatics = Object.setPrototypeOf ||
27683 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
27684 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
27685 return extendStatics(d, b);
27687 return function (d, b) {
27688 extendStatics(d, b);
27689 function __() { this.constructor = d; }
27690 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
27693 Object.defineProperty(exports, "__esModule", { value: true });
27694 var Component_1 = require("../../Component");
27695 var Geo_1 = require("../../Geo");
27697 * @class MouseComponent
27699 * @classdesc Component handling mouse and touch events for camera movement.
27701 * To retrive and use the mouse component
27705 * var viewer = new Mapillary.Viewer(
27710 * var mouseComponent = viewer.getComponent("mouse");
27713 var MouseComponent = /** @class */ (function (_super) {
27714 __extends(MouseComponent, _super);
27716 function MouseComponent(name, container, navigator) {
27717 var _this = _super.call(this, name, container, navigator) || this;
27718 var spatial = new Geo_1.Spatial();
27719 var viewportCoords = new Geo_1.ViewportCoords();
27720 _this._bounceHandler = new Component_1.BounceHandler(_this, container, navigator, viewportCoords, spatial);
27721 _this._doubleClickZoomHandler = new Component_1.DoubleClickZoomHandler(_this, container, navigator, viewportCoords);
27722 _this._dragPanHandler = new Component_1.DragPanHandler(_this, container, navigator, viewportCoords, spatial);
27723 _this._earthControlHandler = new Component_1.EarthControlHandler(_this, container, navigator, viewportCoords, spatial);
27724 _this._scrollZoomHandler = new Component_1.ScrollZoomHandler(_this, container, navigator, viewportCoords);
27725 _this._touchZoomHandler = new Component_1.TouchZoomHandler(_this, container, navigator, viewportCoords);
27728 Object.defineProperty(MouseComponent.prototype, "doubleClickZoom", {
27730 * Get double click zoom.
27732 * @returns {DoubleClickZoomHandler} The double click zoom handler.
27735 return this._doubleClickZoomHandler;
27740 Object.defineProperty(MouseComponent.prototype, "dragPan", {
27744 * @returns {DragPanHandler} The drag pan handler.
27747 return this._dragPanHandler;
27752 Object.defineProperty(MouseComponent.prototype, "scrollZoom", {
27756 * @returns {ScrollZoomHandler} The scroll zoom handler.
27759 return this._scrollZoomHandler;
27764 Object.defineProperty(MouseComponent.prototype, "touchZoom", {
27768 * @returns {TouchZoomHandler} The touch zoom handler.
27771 return this._touchZoomHandler;
27776 MouseComponent.prototype._activate = function () {
27778 this._bounceHandler.enable();
27779 this._earthControlHandler.enable();
27780 this._configurationSubscription = this._configuration$
27781 .subscribe(function (configuration) {
27782 if (configuration.doubleClickZoom) {
27783 _this._doubleClickZoomHandler.enable();
27786 _this._doubleClickZoomHandler.disable();
27788 if (configuration.dragPan) {
27789 _this._dragPanHandler.enable();
27792 _this._dragPanHandler.disable();
27794 if (configuration.scrollZoom) {
27795 _this._scrollZoomHandler.enable();
27798 _this._scrollZoomHandler.disable();
27800 if (configuration.touchZoom) {
27801 _this._touchZoomHandler.enable();
27804 _this._touchZoomHandler.disable();
27807 this._container.mouseService.claimMouse(this._name, 0);
27809 MouseComponent.prototype._deactivate = function () {
27810 this._container.mouseService.unclaimMouse(this._name);
27811 this._configurationSubscription.unsubscribe();
27812 this._bounceHandler.disable();
27813 this._doubleClickZoomHandler.disable();
27814 this._dragPanHandler.disable();
27815 this._earthControlHandler.disable();
27816 this._scrollZoomHandler.disable();
27817 this._touchZoomHandler.disable();
27819 MouseComponent.prototype._getDefaultConfiguration = function () {
27820 return { doubleClickZoom: false, dragPan: true, scrollZoom: true, touchZoom: true };
27823 MouseComponent.componentName = "mouse";
27824 return MouseComponent;
27825 }(Component_1.Component));
27826 exports.MouseComponent = MouseComponent;
27827 Component_1.ComponentService.register(MouseComponent);
27828 exports.default = MouseComponent;
27830 },{"../../Component":275,"../../Geo":278}],328:[function(require,module,exports){
27832 var __extends = (this && this.__extends) || (function () {
27833 var extendStatics = function (d, b) {
27834 extendStatics = Object.setPrototypeOf ||
27835 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
27836 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
27837 return extendStatics(d, b);
27839 return function (d, b) {
27840 extendStatics(d, b);
27841 function __() { this.constructor = d; }
27842 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
27845 Object.defineProperty(exports, "__esModule", { value: true });
27846 var operators_1 = require("rxjs/operators");
27847 var Component_1 = require("../../Component");
27849 * The `ScrollZoomHandler` allows the user to zoom the viewer image by scrolling.
27853 * var mouseComponent = viewer.getComponent("mouse");
27855 * mouseComponent.scrollZoom.disable();
27856 * mouseComponent.scrollZoom.enable();
27858 * var isEnabled = mouseComponent.scrollZoom.isEnabled;
27861 var ScrollZoomHandler = /** @class */ (function (_super) {
27862 __extends(ScrollZoomHandler, _super);
27864 function ScrollZoomHandler(component, container, navigator, viewportCoords) {
27865 var _this = _super.call(this, component, container, navigator) || this;
27866 _this._viewportCoords = viewportCoords;
27869 ScrollZoomHandler.prototype._enable = function () {
27871 this._container.mouseService.claimWheel(this._component.name, 0);
27872 this._preventDefaultSubscription = this._container.mouseService.mouseWheel$
27873 .subscribe(function (event) {
27874 event.preventDefault();
27876 this._zoomSubscription = this._container.mouseService
27877 .filteredWheel$(this._component.name, this._container.mouseService.mouseWheel$).pipe(operators_1.withLatestFrom(this._navigator.stateService.currentState$, function (w, f) {
27879 }), operators_1.filter(function (args) {
27880 var state = args[1].state;
27881 return state.currentNode.fullPano || state.nodesAhead < 1;
27882 }), operators_1.map(function (args) {
27884 }), operators_1.withLatestFrom(this._container.renderService.renderCamera$, this._navigator.stateService.currentTransform$, function (w, r, t) {
27887 .subscribe(function (args) {
27888 var event = args[0];
27889 var render = args[1];
27890 var transform = args[2];
27891 var element = _this._container.element;
27892 var _a = _this._viewportCoords.canvasPosition(event, element), canvasX = _a[0], canvasY = _a[1];
27893 var unprojected = _this._viewportCoords.unprojectFromCanvas(canvasX, canvasY, element, render.perspective);
27894 var reference = transform.projectBasic(unprojected.toArray());
27895 var deltaY = event.deltaY;
27896 if (event.deltaMode === 1) {
27897 deltaY = 40 * deltaY;
27899 else if (event.deltaMode === 2) {
27900 deltaY = 800 * deltaY;
27902 var canvasSize = _this._viewportCoords.containerToCanvas(element);
27903 var zoom = -3 * deltaY / canvasSize[1];
27904 _this._navigator.stateService.zoomIn(zoom, reference);
27907 ScrollZoomHandler.prototype._disable = function () {
27908 this._container.mouseService.unclaimWheel(this._component.name);
27909 this._preventDefaultSubscription.unsubscribe();
27910 this._zoomSubscription.unsubscribe();
27911 this._preventDefaultSubscription = null;
27912 this._zoomSubscription = null;
27914 ScrollZoomHandler.prototype._getConfiguration = function (enable) {
27915 return { scrollZoom: enable };
27917 return ScrollZoomHandler;
27918 }(Component_1.HandlerBase));
27919 exports.ScrollZoomHandler = ScrollZoomHandler;
27920 exports.default = ScrollZoomHandler;
27922 },{"../../Component":275,"rxjs/operators":225}],329:[function(require,module,exports){
27924 var __extends = (this && this.__extends) || (function () {
27925 var extendStatics = function (d, b) {
27926 extendStatics = Object.setPrototypeOf ||
27927 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
27928 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
27929 return extendStatics(d, b);
27931 return function (d, b) {
27932 extendStatics(d, b);
27933 function __() { this.constructor = d; }
27934 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
27937 Object.defineProperty(exports, "__esModule", { value: true });
27938 var rxjs_1 = require("rxjs");
27939 var operators_1 = require("rxjs/operators");
27940 var Component_1 = require("../../Component");
27942 * The `TouchZoomHandler` allows the user to zoom the viewer image by pinching on a touchscreen.
27946 * var mouseComponent = viewer.getComponent("mouse");
27948 * mouseComponent.touchZoom.disable();
27949 * mouseComponent.touchZoom.enable();
27951 * var isEnabled = mouseComponent.touchZoom.isEnabled;
27954 var TouchZoomHandler = /** @class */ (function (_super) {
27955 __extends(TouchZoomHandler, _super);
27957 function TouchZoomHandler(component, container, navigator, viewportCoords) {
27958 var _this = _super.call(this, component, container, navigator) || this;
27959 _this._viewportCoords = viewportCoords;
27962 TouchZoomHandler.prototype._enable = function () {
27964 this._preventDefaultSubscription = this._container.touchService.pinch$
27965 .subscribe(function (pinch) {
27966 pinch.originalEvent.preventDefault();
27968 var pinchStarted$ = this._container.touchService.pinchStart$.pipe(operators_1.map(function (event) {
27971 var pinchStopped$ = this._container.touchService.pinchEnd$.pipe(operators_1.map(function (event) {
27974 this._activeSubscription = rxjs_1.merge(pinchStarted$, pinchStopped$)
27975 .subscribe(this._container.touchService.activate$);
27976 this._zoomSubscription = this._container.touchService.pinch$.pipe(operators_1.withLatestFrom(this._navigator.stateService.currentState$), operators_1.filter(function (args) {
27977 var state = args[1].state;
27978 return state.currentNode.fullPano || state.nodesAhead < 1;
27979 }), operators_1.map(function (args) {
27981 }), operators_1.withLatestFrom(this._container.renderService.renderCamera$, this._navigator.stateService.currentTransform$))
27982 .subscribe(function (_a) {
27983 var pinch = _a[0], render = _a[1], transform = _a[2];
27984 var element = _this._container.element;
27985 var _b = _this._viewportCoords.canvasPosition(pinch, element), canvasX = _b[0], canvasY = _b[1];
27986 var unprojected = _this._viewportCoords.unprojectFromCanvas(canvasX, canvasY, element, render.perspective);
27987 var reference = transform.projectBasic(unprojected.toArray());
27988 var _c = _this._viewportCoords.containerToCanvas(element), canvasWidth = _c[0], canvasHeight = _c[1];
27989 var zoom = 3 * pinch.distanceChange / Math.min(canvasWidth, canvasHeight);
27990 _this._navigator.stateService.zoomIn(zoom, reference);
27993 TouchZoomHandler.prototype._disable = function () {
27994 this._activeSubscription.unsubscribe();
27995 this._preventDefaultSubscription.unsubscribe();
27996 this._zoomSubscription.unsubscribe();
27997 this._preventDefaultSubscription = null;
27998 this._zoomSubscription = null;
28000 TouchZoomHandler.prototype._getConfiguration = function (enable) {
28001 return { touchZoom: enable };
28003 return TouchZoomHandler;
28004 }(Component_1.HandlerBase));
28005 exports.TouchZoomHandler = TouchZoomHandler;
28006 exports.default = TouchZoomHandler;
28008 },{"../../Component":275,"rxjs":27,"rxjs/operators":225}],330:[function(require,module,exports){
28010 Object.defineProperty(exports, "__esModule", { value: true });
28011 var Popup_1 = require("./popup/Popup");
28012 exports.Popup = Popup_1.Popup;
28013 var PopupComponent_1 = require("./PopupComponent");
28014 exports.PopupComponent = PopupComponent_1.PopupComponent;
28016 },{"./PopupComponent":331,"./popup/Popup":332}],331:[function(require,module,exports){
28018 var __extends = (this && this.__extends) || (function () {
28019 var extendStatics = function (d, b) {
28020 extendStatics = Object.setPrototypeOf ||
28021 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
28022 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
28023 return extendStatics(d, b);
28025 return function (d, b) {
28026 extendStatics(d, b);
28027 function __() { this.constructor = d; }
28028 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
28031 Object.defineProperty(exports, "__esModule", { value: true });
28032 var rxjs_1 = require("rxjs");
28033 var operators_1 = require("rxjs/operators");
28034 var Component_1 = require("../../Component");
28035 var Utils_1 = require("../../Utils");
28037 * @class PopupComponent
28039 * @classdesc Component for showing HTML popup objects.
28041 * The `add` method is used for adding new popups. Popups are removed by reference.
28043 * It is not possible to update popups in the set by updating any properties
28044 * directly on the popup object. Popups need to be replaced by
28045 * removing them and creating new ones with relevant changed properties and
28046 * adding those instead.
28048 * Popups are only relevant to a single image because they are based on
28049 * 2D basic image coordinates. Popups related to a certain image should
28050 * be removed when the viewer is moved to another node.
28052 * To retrive and use the popup component
28056 * var viewer = new Mapillary.Viewer(
28060 * { component: { popup: true } });
28062 * var popupComponent = viewer.getComponent("popup");
28065 var PopupComponent = /** @class */ (function (_super) {
28066 __extends(PopupComponent, _super);
28068 function PopupComponent(name, container, navigator, dom) {
28069 var _this = _super.call(this, name, container, navigator) || this;
28070 _this._dom = !!dom ? dom : new Utils_1.DOM();
28071 _this._popups = [];
28072 _this._added$ = new rxjs_1.Subject();
28073 _this._popups$ = new rxjs_1.Subject();
28077 * Add popups to the popups set.
28079 * @description Adding a new popup never replaces an old one
28080 * because they are stored by reference. Adding an already
28081 * existing popup has no effect.
28083 * @param {Array<Popup>} popups - Popups to add.
28085 * @example ```popupComponent.add([popup1, popup2]);```
28087 PopupComponent.prototype.add = function (popups) {
28088 for (var _i = 0, popups_1 = popups; _i < popups_1.length; _i++) {
28089 var popup = popups_1[_i];
28090 if (this._popups.indexOf(popup) !== -1) {
28093 this._popups.push(popup);
28094 if (this._activated) {
28095 popup.setParentContainer(this._popupContainer);
28098 this._added$.next(popups);
28099 this._popups$.next(this._popups);
28102 * Returns an array of all popups.
28104 * @example ```var popups = popupComponent.getAll();```
28106 PopupComponent.prototype.getAll = function () {
28107 return this._popups.slice();
28110 * Remove popups based on reference from the popup set.
28112 * @param {Array<Popup>} popups - Popups to remove.
28114 * @example ```popupComponent.remove([popup1, popup2]);```
28116 PopupComponent.prototype.remove = function (popups) {
28117 for (var _i = 0, popups_2 = popups; _i < popups_2.length; _i++) {
28118 var popup = popups_2[_i];
28119 this._remove(popup);
28121 this._popups$.next(this._popups);
28124 * Remove all popups from the popup set.
28126 * @example ```popupComponent.removeAll();```
28128 PopupComponent.prototype.removeAll = function () {
28129 for (var _i = 0, _a = this._popups.slice(); _i < _a.length; _i++) {
28130 var popup = _a[_i];
28131 this._remove(popup);
28133 this._popups$.next(this._popups);
28135 PopupComponent.prototype._activate = function () {
28137 this._popupContainer = this._dom.createElement("div", "mapillary-js-popup-container", this._container.element);
28138 for (var _i = 0, _a = this._popups; _i < _a.length; _i++) {
28139 var popup = _a[_i];
28140 popup.setParentContainer(this._popupContainer);
28142 this._updateAllSubscription = rxjs_1.combineLatest(this._container.renderService.renderCamera$, this._container.renderService.size$, this._navigator.stateService.currentTransform$)
28143 .subscribe(function (_a) {
28144 var renderCamera = _a[0], size = _a[1], transform = _a[2];
28145 for (var _i = 0, _b = _this._popups; _i < _b.length; _i++) {
28146 var popup = _b[_i];
28147 popup.update(renderCamera, size, transform);
28150 var changed$ = this._popups$.pipe(operators_1.startWith(this._popups), operators_1.switchMap(function (popups) {
28151 return rxjs_1.from(popups).pipe(operators_1.mergeMap(function (popup) {
28152 return popup.changed$;
28154 }), operators_1.map(function (popup) {
28157 this._updateAddedChangedSubscription = rxjs_1.merge(this._added$, changed$).pipe(operators_1.withLatestFrom(this._container.renderService.renderCamera$, this._container.renderService.size$, this._navigator.stateService.currentTransform$))
28158 .subscribe(function (_a) {
28159 var popups = _a[0], renderCamera = _a[1], size = _a[2], transform = _a[3];
28160 for (var _i = 0, popups_3 = popups; _i < popups_3.length; _i++) {
28161 var popup = popups_3[_i];
28162 popup.update(renderCamera, size, transform);
28166 PopupComponent.prototype._deactivate = function () {
28167 this._updateAllSubscription.unsubscribe();
28168 this._updateAddedChangedSubscription.unsubscribe();
28169 for (var _i = 0, _a = this._popups; _i < _a.length; _i++) {
28170 var popup = _a[_i];
28173 this._container.element.removeChild(this._popupContainer);
28174 delete this._popupContainer;
28176 PopupComponent.prototype._getDefaultConfiguration = function () {
28179 PopupComponent.prototype._remove = function (popup) {
28180 var index = this._popups.indexOf(popup);
28181 if (index === -1) {
28184 var removed = this._popups.splice(index, 1)[0];
28185 if (this._activated) {
28189 PopupComponent.componentName = "popup";
28190 return PopupComponent;
28191 }(Component_1.Component));
28192 exports.PopupComponent = PopupComponent;
28193 Component_1.ComponentService.register(PopupComponent);
28194 exports.default = PopupComponent;
28196 },{"../../Component":275,"../../Utils":285,"rxjs":27,"rxjs/operators":225}],332:[function(require,module,exports){
28198 Object.defineProperty(exports, "__esModule", { value: true });
28199 var rxjs_1 = require("rxjs");
28200 var Geo_1 = require("../../../Geo");
28201 var Utils_1 = require("../../../Utils");
28202 var Viewer_1 = require("../../../Viewer");
28206 * @classdesc Popup instance for rendering custom HTML content
28207 * on top of images. Popups are based on 2D basic image coordinates
28208 * (see the {@link Viewer} class documentation for more information about coordinate
28209 * systems) and a certain popup is therefore only relevant to a single image.
28210 * Popups related to a certain image should be removed when moving
28211 * to another image.
28213 * A popup must have both its content and its point or rect set to be
28214 * rendered. Popup options can not be updated after creation but the
28215 * basic point or rect as well as its content can be changed by calling
28216 * the appropriate methods.
28218 * To create and add one `Popup` with default configuration
28219 * (tooltip visuals and automatic float) and one with specific options
28224 * var defaultSpan = document.createElement('span');
28225 * defaultSpan.innerHTML = 'hello default';
28227 * var defaultPopup = new Mapillary.PopupComponent.Popup();
28228 * defaultPopup.setDOMContent(defaultSpan);
28229 * defaultPopup.setBasicPoint([0.3, 0.3]);
28231 * var cleanSpan = document.createElement('span');
28232 * cleanSpan.innerHTML = 'hello clean';
28234 * var cleanPopup = new Mapillary.PopupComponent.Popup({
28236 * float: Mapillary.Alignment.Top,
28241 * cleanPopup.setDOMContent(cleanSpan);
28242 * cleanPopup.setBasicPoint([0.6, 0.6]);
28244 * popupComponent.add([defaultPopup, cleanPopup]);
28247 * @description Implementation of API methods and API documentation inspired
28248 * by/used from https://github.com/mapbox/mapbox-gl-js/blob/v0.38.0/src/ui/popup.js
28250 var Popup = /** @class */ (function () {
28251 function Popup(options, viewportCoords, dom) {
28252 this._options = {};
28253 options = !!options ? options : {};
28254 this._options.capturePointer = options.capturePointer === false ?
28255 options.capturePointer : true;
28256 this._options.clean = options.clean;
28257 this._options.float = options.float;
28258 this._options.offset = options.offset;
28259 this._options.opacity = options.opacity;
28260 this._options.position = options.position;
28261 this._dom = !!dom ? dom : new Utils_1.DOM();
28262 this._viewportCoords = !!viewportCoords ? viewportCoords : new Geo_1.ViewportCoords();
28263 this._notifyChanged$ = new rxjs_1.Subject();
28265 Object.defineProperty(Popup.prototype, "changed$", {
28267 * @description Internal observable used by the component to
28268 * render the popup when its position or content has changed.
28272 return this._notifyChanged$;
28278 * @description Internal method used by the component to
28279 * remove all references to the popup.
28282 Popup.prototype.remove = function () {
28283 if (this._content && this._content.parentNode) {
28284 this._content.parentNode.removeChild(this._content);
28286 if (this._container) {
28287 this._container.parentNode.removeChild(this._container);
28288 delete this._container;
28290 if (this._parentContainer) {
28291 delete this._parentContainer;
28295 * Sets a 2D basic image coordinates point to the popup's anchor, and
28296 * moves the popup to it.
28298 * @description Overwrites any previously set point or rect.
28300 * @param {Array<number>} basicPoint - Point in 2D basic image coordinates.
28304 * var popup = new Mapillary.PopupComponent.Popup();
28305 * popup.setText('hello image');
28306 * popup.setBasicPoint([0.3, 0.3]);
28308 * popupComponent.add([popup]);
28311 Popup.prototype.setBasicPoint = function (basicPoint) {
28312 this._point = basicPoint.slice();
28314 this._notifyChanged$.next(this);
28317 * Sets a 2D basic image coordinates rect to the popup's anchor, and
28318 * moves the popup to it.
28320 * @description Overwrites any previously set point or rect.
28322 * @param {Array<number>} basicRect - Rect in 2D basic image
28323 * coordinates ([topLeftX, topLeftY, bottomRightX, bottomRightY]) .
28327 * var popup = new Mapillary.PopupComponent.Popup();
28328 * popup.setText('hello image');
28329 * popup.setBasicRect([0.3, 0.3, 0.5, 0.6]);
28331 * popupComponent.add([popup]);
28334 Popup.prototype.setBasicRect = function (basicRect) {
28335 this._rect = basicRect.slice();
28336 this._point = null;
28337 this._notifyChanged$.next(this);
28340 * Sets the popup's content to the element provided as a DOM node.
28342 * @param {Node} htmlNode - A DOM node to be used as content for the popup.
28346 * var div = document.createElement('div');
28347 * div.innerHTML = 'hello image';
28349 * var popup = new Mapillary.PopupComponent.Popup();
28350 * popup.setDOMContent(div);
28351 * popup.setBasicPoint([0.3, 0.3]);
28353 * popupComponent.add([popup]);
28356 Popup.prototype.setDOMContent = function (htmlNode) {
28357 if (this._content && this._content.parentNode) {
28358 this._content.parentNode.removeChild(this._content);
28360 var className = "mapillaryjs-popup-content" +
28361 (this._options.clean === true ? "-clean" : "") +
28362 (this._options.capturePointer === true ? " mapillaryjs-popup-capture-pointer" : "");
28363 this._content = this._dom.createElement("div", className, this._container);
28364 this._content.appendChild(htmlNode);
28365 this._notifyChanged$.next(this);
28368 * Sets the popup's content to the HTML provided as a string.
28370 * @description This method does not perform HTML filtering or sanitization,
28371 * and must be used only with trusted content. Consider Popup#setText if the
28372 * content is an untrusted text string.
28374 * @param {string} html - A string representing HTML content for the popup.
28378 * var popup = new Mapillary.PopupComponent.Popup();
28379 * popup.setHTML('<div>hello image</div>');
28380 * popup.setBasicPoint([0.3, 0.3]);
28382 * popupComponent.add([popup]);
28385 Popup.prototype.setHTML = function (html) {
28386 var frag = this._dom.document.createDocumentFragment();
28387 var temp = this._dom.createElement("body");
28389 temp.innerHTML = html;
28391 child = temp.firstChild;
28395 frag.appendChild(child);
28397 this.setDOMContent(frag);
28400 * Sets the popup's content to a string of text.
28402 * @description This function creates a Text node in the DOM, so it cannot insert raw HTML.
28403 * Use this method for security against XSS if the popup content is user-provided.
28405 * @param {string} text - Textual content for the popup.
28409 * var popup = new Mapillary.PopupComponent.Popup();
28410 * popup.setText('hello image');
28411 * popup.setBasicPoint([0.3, 0.3]);
28413 * popupComponent.add([popup]);
28416 Popup.prototype.setText = function (text) {
28417 this.setDOMContent(this._dom.document.createTextNode(text));
28420 * @description Internal method for attaching the popup to
28421 * its parent container so that it is rendered in the DOM tree.
28424 Popup.prototype.setParentContainer = function (parentContainer) {
28425 this._parentContainer = parentContainer;
28428 * @description Internal method for updating the rendered
28429 * position of the popup called by the popup component.
28432 Popup.prototype.update = function (renderCamera, size, transform) {
28434 if (!this._parentContainer || !this._content) {
28437 if (!this._point && !this._rect) {
28440 if (!this._container) {
28441 this._container = this._dom.createElement("div", "mapillaryjs-popup", this._parentContainer);
28442 var showTip = this._options.clean !== true &&
28443 this._options.float !== Viewer_1.Alignment.Center;
28445 var tipClassName = "mapillaryjs-popup-tip" +
28446 (this._options.capturePointer === true ? " mapillaryjs-popup-capture-pointer" : "");
28447 this._tip = this._dom.createElement("div", tipClassName, this._container);
28448 this._dom.createElement("div", "mapillaryjs-popup-tip-inner", this._tip);
28450 this._container.appendChild(this._content);
28451 this._parentContainer.appendChild(this._container);
28452 if (this._options.opacity != null) {
28453 this._container.style.opacity = this._options.opacity.toString();
28456 var pointPixel = null;
28457 var position = this._alignmentToPopupAligment(this._options.position);
28458 var float = this._alignmentToPopupAligment(this._options.float);
28459 var classList = this._container.classList;
28460 if (this._point != null) {
28462 this._viewportCoords.basicToCanvasSafe(this._point[0], this._point[1], { offsetHeight: size.height, offsetWidth: size.width }, transform, renderCamera.perspective);
28465 var alignments = ["center", "top", "bottom", "left", "right", "top-left", "top-right", "bottom-left", "bottom-right"];
28466 var appliedPosition = null;
28467 for (var _i = 0, alignments_1 = alignments; _i < alignments_1.length; _i++) {
28468 var alignment = alignments_1[_i];
28469 if (classList.contains("mapillaryjs-popup-float-" + alignment)) {
28470 appliedPosition = alignment;
28474 _a = this._rectToPixel(this._rect, position, appliedPosition, renderCamera, size, transform), pointPixel = _a[0], position = _a[1];
28479 if (pointPixel == null) {
28480 this._container.style.display = "none";
28483 this._container.style.display = "";
28485 var width = this._container.offsetWidth;
28486 var height = this._container.offsetHeight;
28487 var floats = this._pixelToFloats(pointPixel, size, width, height);
28488 float = floats.length === 0 ? "top" : floats.join("-");
28490 var offset = this._normalizeOffset(this._options.offset);
28491 pointPixel = [pointPixel[0] + offset[float][0], pointPixel[1] + offset[float][1]];
28492 pointPixel = [Math.round(pointPixel[0]), Math.round(pointPixel[1])];
28493 var floatTranslate = {
28494 "bottom": "translate(-50%,0)",
28495 "bottom-left": "translate(-100%,0)",
28496 "bottom-right": "translate(0,0)",
28497 "center": "translate(-50%,-50%)",
28498 "left": "translate(-100%,-50%)",
28499 "right": "translate(0,-50%)",
28500 "top": "translate(-50%,-100%)",
28501 "top-left": "translate(-100%,-100%)",
28502 "top-right": "translate(0,-100%)",
28504 for (var key in floatTranslate) {
28505 if (!floatTranslate.hasOwnProperty(key)) {
28508 classList.remove("mapillaryjs-popup-float-" + key);
28510 classList.add("mapillaryjs-popup-float-" + float);
28511 this._container.style.transform = floatTranslate[float] + " translate(" + pointPixel[0] + "px," + pointPixel[1] + "px)";
28513 Popup.prototype._rectToPixel = function (rect, position, appliedPosition, renderCamera, size, transform) {
28515 var width = this._container.offsetWidth;
28516 var height = this._container.offsetHeight;
28517 var floatOffsets = {
28518 "bottom": [0, height / 2],
28519 "bottom-left": [-width / 2, height / 2],
28520 "bottom-right": [width / 2, height / 2],
28521 "left": [-width / 2, 0],
28522 "right": [width / 2, 0],
28523 "top": [0, -height / 2],
28524 "top-left": [-width / 2, -height / 2],
28525 "top-right": [width / 2, -height / 2],
28527 var automaticPositions = ["top", "bottom", "left", "right"];
28528 var largestVisibleArea = [0, null, null];
28529 for (var _i = 0, automaticPositions_1 = automaticPositions; _i < automaticPositions_1.length; _i++) {
28530 var automaticPosition = automaticPositions_1[_i];
28531 var autoPointBasic = this._pointFromRectPosition(rect, automaticPosition);
28532 var autoPointPixel = this._viewportCoords.basicToCanvasSafe(autoPointBasic[0], autoPointBasic[1], { offsetHeight: size.height, offsetWidth: size.width }, transform, renderCamera.perspective);
28533 if (autoPointPixel == null) {
28536 var floatOffset = floatOffsets[automaticPosition];
28537 var offsetedPosition = [autoPointPixel[0] + floatOffset[0], autoPointPixel[1] + floatOffset[1]];
28538 var staticCoeff = appliedPosition != null && appliedPosition === automaticPosition ? 1 : 0.7;
28539 var floats = this._pixelToFloats(offsetedPosition, size, width / staticCoeff, height / (2 * staticCoeff));
28540 if (floats.length === 0 &&
28541 autoPointPixel[0] > 0 &&
28542 autoPointPixel[0] < size.width &&
28543 autoPointPixel[1] > 0 &&
28544 autoPointPixel[1] < size.height) {
28545 return [autoPointPixel, automaticPosition];
28547 var minX = Math.max(offsetedPosition[0] - width / 2, 0);
28548 var maxX = Math.min(offsetedPosition[0] + width / 2, size.width);
28549 var minY = Math.max(offsetedPosition[1] - height / 2, 0);
28550 var maxY = Math.min(offsetedPosition[1] + height / 2, size.height);
28551 var visibleX = Math.max(0, maxX - minX);
28552 var visibleY = Math.max(0, maxY - minY);
28553 var visibleArea = staticCoeff * visibleX * visibleY;
28554 if (visibleArea > largestVisibleArea[0]) {
28555 largestVisibleArea[0] = visibleArea;
28556 largestVisibleArea[1] = autoPointPixel;
28557 largestVisibleArea[2] = automaticPosition;
28560 if (largestVisibleArea[0] > 0) {
28561 return [largestVisibleArea[1], largestVisibleArea[2]];
28564 var pointBasic = this._pointFromRectPosition(rect, position);
28565 var pointPixel = this._viewportCoords.basicToCanvasSafe(pointBasic[0], pointBasic[1], { offsetHeight: size.height, offsetWidth: size.width }, transform, renderCamera.perspective);
28566 return [pointPixel, position != null ? position : "top"];
28568 Popup.prototype._alignmentToPopupAligment = function (float) {
28570 case Viewer_1.Alignment.Bottom:
28572 case Viewer_1.Alignment.BottomLeft:
28573 return "bottom-left";
28574 case Viewer_1.Alignment.BottomRight:
28575 return "bottom-right";
28576 case Viewer_1.Alignment.Center:
28578 case Viewer_1.Alignment.Left:
28580 case Viewer_1.Alignment.Right:
28582 case Viewer_1.Alignment.Top:
28584 case Viewer_1.Alignment.TopLeft:
28586 case Viewer_1.Alignment.TopRight:
28587 return "top-right";
28592 Popup.prototype._normalizeOffset = function (offset) {
28593 if (offset == null) {
28594 return this._normalizeOffset(0);
28596 if (typeof offset === "number") {
28597 // input specifies a radius
28598 var sideOffset = offset;
28599 var sign = sideOffset >= 0 ? 1 : -1;
28600 var cornerOffset = sign * Math.round(Math.sqrt(0.5 * Math.pow(sideOffset, 2)));
28602 "bottom": [0, sideOffset],
28603 "bottom-left": [-cornerOffset, cornerOffset],
28604 "bottom-right": [cornerOffset, cornerOffset],
28606 "left": [-sideOffset, 0],
28607 "right": [sideOffset, 0],
28608 "top": [0, -sideOffset],
28609 "top-left": [-cornerOffset, -cornerOffset],
28610 "top-right": [cornerOffset, -cornerOffset],
28614 // input specifes a value for each position
28616 "bottom": offset.bottom || [0, 0],
28617 "bottom-left": offset.bottomLeft || [0, 0],
28618 "bottom-right": offset.bottomRight || [0, 0],
28619 "center": offset.center || [0, 0],
28620 "left": offset.left || [0, 0],
28621 "right": offset.right || [0, 0],
28622 "top": offset.top || [0, 0],
28623 "top-left": offset.topLeft || [0, 0],
28624 "top-right": offset.topRight || [0, 0],
28628 Popup.prototype._pixelToFloats = function (pointPixel, size, width, height) {
28630 if (pointPixel[1] < height) {
28631 floats.push("bottom");
28633 else if (pointPixel[1] > size.height - height) {
28634 floats.push("top");
28636 if (pointPixel[0] < width / 2) {
28637 floats.push("right");
28639 else if (pointPixel[0] > size.width - width / 2) {
28640 floats.push("left");
28644 Popup.prototype._pointFromRectPosition = function (rect, position) {
28646 var x1 = rect[0] < rect[2] ? rect[2] : rect[2] + 1;
28649 switch (position) {
28651 return [(x0 + x1) / 2, y1];
28652 case "bottom-left":
28654 case "bottom-right":
28657 return [(x0 + x1) / 2, (y0 + y1) / 2];
28659 return [x0, (y0 + y1) / 2];
28661 return [x1, (y0 + y1) / 2];
28663 return [(x0 + x1) / 2, y0];
28669 return [(x0 + x1) / 2, y1];
28674 exports.Popup = Popup;
28675 exports.default = Popup;
28678 },{"../../../Geo":278,"../../../Utils":285,"../../../Viewer":286,"rxjs":27}],333:[function(require,module,exports){
28680 var __extends = (this && this.__extends) || (function () {
28681 var extendStatics = function (d, b) {
28682 extendStatics = Object.setPrototypeOf ||
28683 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
28684 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
28685 return extendStatics(d, b);
28687 return function (d, b) {
28688 extendStatics(d, b);
28689 function __() { this.constructor = d; }
28690 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
28693 Object.defineProperty(exports, "__esModule", { value: true });
28694 var rxjs_1 = require("rxjs");
28695 var operators_1 = require("rxjs/operators");
28696 var Component_1 = require("../../Component");
28697 var Edge_1 = require("../../Edge");
28698 var Graph_1 = require("../../Graph");
28700 * @class SequenceComponent
28701 * @classdesc Component showing navigation arrows for sequence directions
28702 * as well as playing button. Exposes an API to start and stop play.
28704 var SequenceComponent = /** @class */ (function (_super) {
28705 __extends(SequenceComponent, _super);
28706 function SequenceComponent(name, container, navigator, renderer, scheduler) {
28707 var _this = _super.call(this, name, container, navigator) || this;
28708 _this._sequenceDOMRenderer = !!renderer ? renderer : new Component_1.SequenceDOMRenderer(container);
28709 _this._scheduler = scheduler;
28710 _this._containerWidth$ = new rxjs_1.Subject();
28711 _this._hoveredKeySubject$ = new rxjs_1.Subject();
28712 _this._hoveredKey$ = _this._hoveredKeySubject$.pipe(operators_1.share());
28713 _this._navigator.playService.playing$.pipe(operators_1.skip(1), operators_1.withLatestFrom(_this._configuration$))
28714 .subscribe(function (_a) {
28715 var playing = _a[0], configuration = _a[1];
28716 _this.fire(SequenceComponent.playingchanged, playing);
28717 if (playing === configuration.playing) {
28727 _this._navigator.playService.direction$.pipe(operators_1.skip(1), operators_1.withLatestFrom(_this._configuration$))
28728 .subscribe(function (_a) {
28729 var direction = _a[0], configuration = _a[1];
28730 if (direction !== configuration.direction) {
28731 _this.setDirection(direction);
28736 Object.defineProperty(SequenceComponent.prototype, "hoveredKey$", {
28738 * Get hovered key observable.
28740 * @description An observable emitting the key of the node for the direction
28741 * arrow that is being hovered. When the mouse leaves a direction arrow null
28744 * @returns {Observable<string>}
28747 return this._hoveredKey$;
28755 * @fires PlayerComponent#playingchanged
28757 SequenceComponent.prototype.play = function () {
28758 this.configure({ playing: true });
28763 * @fires PlayerComponent#playingchanged
28765 SequenceComponent.prototype.stop = function () {
28766 this.configure({ playing: false });
28769 * Set the direction to follow when playing.
28771 * @param {EdgeDirection} direction - The direction that will be followed when playing.
28773 SequenceComponent.prototype.setDirection = function (direction) {
28774 this.configure({ direction: direction });
28777 * Set highlight key.
28779 * @description The arrow pointing towards the node corresponding to the
28780 * highlight key will be highlighted.
28782 * @param {string} highlightKey Key of node to be highlighted if existing.
28784 SequenceComponent.prototype.setHighlightKey = function (highlightKey) {
28785 this.configure({ highlightKey: highlightKey });
28788 * Set max width of container element.
28790 * @description Set max width of the container element holding
28791 * the sequence navigation elements. If the min width is larger than the
28792 * max width the min width value will be used.
28794 * The container element is automatically resized when the resize
28795 * method on the Viewer class is called.
28797 * @param {number} minWidth
28799 SequenceComponent.prototype.setMaxWidth = function (maxWidth) {
28800 this.configure({ maxWidth: maxWidth });
28803 * Set min width of container element.
28805 * @description Set min width of the container element holding
28806 * the sequence navigation elements. If the min width is larger than the
28807 * max width the min width value will be used.
28809 * The container element is automatically resized when the resize
28810 * method on the Viewer class is called.
28812 * @param {number} minWidth
28814 SequenceComponent.prototype.setMinWidth = function (minWidth) {
28815 this.configure({ minWidth: minWidth });
28818 * Set the value indicating whether the sequence UI elements should be visible.
28820 * @param {boolean} visible
28822 SequenceComponent.prototype.setVisible = function (visible) {
28823 this.configure({ visible: visible });
28825 SequenceComponent.prototype._activate = function () {
28827 this._sequenceDOMRenderer.activate();
28828 var edgeStatus$ = this._navigator.stateService.currentNode$.pipe(operators_1.switchMap(function (node) {
28829 return node.sequenceEdges$;
28830 }), operators_1.publishReplay(1), operators_1.refCount());
28831 var sequence$ = this._navigator.stateService.currentNode$.pipe(operators_1.distinctUntilChanged(undefined, function (node) {
28832 return node.sequenceKey;
28833 }), operators_1.switchMap(function (node) {
28834 return rxjs_1.concat(rxjs_1.of(null), _this._navigator.graphService.cacheSequence$(node.sequenceKey).pipe(operators_1.retry(3), operators_1.catchError(function (e) {
28835 console.error("Failed to cache sequence", e);
28836 return rxjs_1.of(null);
28838 }), operators_1.startWith(null), operators_1.publishReplay(1), operators_1.refCount());
28839 this._sequenceSubscription = sequence$.subscribe();
28840 var rendererKey$ = this._sequenceDOMRenderer.index$.pipe(operators_1.withLatestFrom(sequence$), operators_1.map(function (_a) {
28841 var index = _a[0], sequence = _a[1];
28842 return sequence != null ? sequence.keys[index] : null;
28843 }), operators_1.filter(function (key) {
28845 }), operators_1.distinctUntilChanged(), operators_1.publish(), operators_1.refCount());
28846 this._moveSubscription = rxjs_1.merge(rendererKey$.pipe(operators_1.debounceTime(100, this._scheduler)), rendererKey$.pipe(operators_1.auditTime(400, this._scheduler))).pipe(operators_1.distinctUntilChanged(), operators_1.switchMap(function (key) {
28847 return _this._navigator.moveToKey$(key).pipe(operators_1.catchError(function (e) {
28848 return rxjs_1.empty();
28852 this._setSequenceGraphModeSubscription = this._sequenceDOMRenderer.changingPositionChanged$.pipe(operators_1.filter(function (changing) {
28855 .subscribe(function () {
28856 _this._navigator.graphService.setGraphMode(Graph_1.GraphMode.Sequence);
28858 this._setSpatialGraphModeSubscription = this._sequenceDOMRenderer.changingPositionChanged$.pipe(operators_1.filter(function (changing) {
28861 .subscribe(function () {
28862 _this._navigator.graphService.setGraphMode(Graph_1.GraphMode.Spatial);
28864 this._navigator.graphService.graphMode$.pipe(operators_1.switchMap(function (mode) {
28865 return mode === Graph_1.GraphMode.Spatial ?
28866 _this._navigator.stateService.currentNode$.pipe(operators_1.take(2)) :
28868 }), operators_1.filter(function (node) {
28869 return !node.spatialEdges.cached;
28870 }), operators_1.switchMap(function (node) {
28871 return _this._navigator.graphService.cacheNode$(node.key).pipe(operators_1.catchError(function (e) {
28872 return rxjs_1.empty();
28876 this._stopSubscription = this._sequenceDOMRenderer.changingPositionChanged$.pipe(operators_1.filter(function (changing) {
28879 .subscribe(function () {
28880 _this._navigator.playService.stop();
28882 this._cacheSequenceNodesSubscription = rxjs_1.combineLatest(this._navigator.graphService.graphMode$, this._sequenceDOMRenderer.changingPositionChanged$.pipe(operators_1.startWith(false), operators_1.distinctUntilChanged())).pipe(operators_1.withLatestFrom(this._navigator.stateService.currentNode$), operators_1.switchMap(function (_a) {
28883 var _b = _a[0], mode = _b[0], changing = _b[1], node = _a[1];
28884 return changing && mode === Graph_1.GraphMode.Sequence ?
28885 _this._navigator.graphService.cacheSequenceNodes$(node.sequenceKey, node.key).pipe(operators_1.retry(3), operators_1.catchError(function (error) {
28886 console.error("Failed to cache sequence nodes.", error);
28887 return rxjs_1.empty();
28892 var position$ = sequence$.pipe(operators_1.switchMap(function (sequence) {
28894 return rxjs_1.of({ index: null, max: null });
28896 var firstCurrentKey = true;
28897 return _this._sequenceDOMRenderer.changingPositionChanged$.pipe(operators_1.startWith(false), operators_1.distinctUntilChanged(), operators_1.switchMap(function (changingPosition) {
28898 var skipCount = !changingPosition && firstCurrentKey ? 0 : 1;
28899 firstCurrentKey = false;
28900 return changingPosition ?
28902 _this._navigator.stateService.currentNode$.pipe(operators_1.map(function (node) {
28904 }), operators_1.distinctUntilChanged(), operators_1.skip(skipCount));
28905 }), operators_1.map(function (key) {
28906 var index = sequence.keys.indexOf(key);
28907 if (index === -1) {
28908 return { index: null, max: null };
28910 return { index: index, max: sequence.keys.length - 1 };
28913 this._renderSubscription = rxjs_1.combineLatest(edgeStatus$, this._configuration$, this._containerWidth$, this._sequenceDOMRenderer.changed$.pipe(operators_1.startWith(this._sequenceDOMRenderer)), this._navigator.playService.speed$, position$).pipe(operators_1.map(function (_a) {
28914 var edgeStatus = _a[0], configuration = _a[1], containerWidth = _a[2], renderer = _a[3], speed = _a[4], position = _a[5];
28915 var vNode = _this._sequenceDOMRenderer
28916 .render(edgeStatus, configuration, containerWidth, speed, position.index, position.max, _this, _this._navigator);
28917 return { name: _this._name, vnode: vNode };
28919 .subscribe(this._container.domRenderer.render$);
28920 this._setSpeedSubscription = this._sequenceDOMRenderer.speed$
28921 .subscribe(function (speed) {
28922 _this._navigator.playService.setSpeed(speed);
28924 this._setDirectionSubscription = this._configuration$.pipe(operators_1.map(function (configuration) {
28925 return configuration.direction;
28926 }), operators_1.distinctUntilChanged())
28927 .subscribe(function (direction) {
28928 _this._navigator.playService.setDirection(direction);
28930 this._containerWidthSubscription = rxjs_1.combineLatest(this._container.renderService.size$, this._configuration$.pipe(operators_1.distinctUntilChanged(function (value1, value2) {
28931 return value1[0] === value2[0] && value1[1] === value2[1];
28932 }, function (configuration) {
28933 return [configuration.minWidth, configuration.maxWidth];
28934 }))).pipe(operators_1.map(function (_a) {
28935 var size = _a[0], configuration = _a[1];
28936 return _this._sequenceDOMRenderer.getContainerWidth(size, configuration);
28938 .subscribe(this._containerWidth$);
28939 this._playingSubscription = this._configuration$.pipe(operators_1.map(function (configuration) {
28940 return configuration.playing;
28941 }), operators_1.distinctUntilChanged())
28942 .subscribe(function (playing) {
28944 _this._navigator.playService.play();
28947 _this._navigator.playService.stop();
28950 this._hoveredKeySubscription = this._sequenceDOMRenderer.mouseEnterDirection$.pipe(operators_1.switchMap(function (direction) {
28951 var edgeTo$ = edgeStatus$.pipe(operators_1.map(function (edgeStatus) {
28952 for (var _i = 0, _a = edgeStatus.edges; _i < _a.length; _i++) {
28954 if (edge.data.direction === direction) {
28959 }), operators_1.takeUntil(_this._sequenceDOMRenderer.mouseLeaveDirection$));
28960 return rxjs_1.concat(edgeTo$, rxjs_1.of(null));
28961 }), operators_1.distinctUntilChanged())
28962 .subscribe(this._hoveredKeySubject$);
28963 this._emitHoveredKeySubscription = this._hoveredKey$
28964 .subscribe(function (key) {
28965 _this.fire(SequenceComponent.hoveredkeychanged, key);
28968 SequenceComponent.prototype._deactivate = function () {
28969 this._emitHoveredKeySubscription.unsubscribe();
28970 this._renderSubscription.unsubscribe();
28971 this._playingSubscription.unsubscribe();
28972 this._containerWidthSubscription.unsubscribe();
28973 this._hoveredKeySubscription.unsubscribe();
28974 this._setSpeedSubscription.unsubscribe();
28975 this._setDirectionSubscription.unsubscribe();
28976 this._setSequenceGraphModeSubscription.unsubscribe();
28977 this._setSpatialGraphModeSubscription.unsubscribe();
28978 this._sequenceSubscription.unsubscribe();
28979 this._moveSubscription.unsubscribe();
28980 this._cacheSequenceNodesSubscription.unsubscribe();
28981 this._stopSubscription.unsubscribe();
28982 this._sequenceDOMRenderer.deactivate();
28984 SequenceComponent.prototype._getDefaultConfiguration = function () {
28986 direction: Edge_1.EdgeDirection.Next,
28994 SequenceComponent.componentName = "sequence";
28996 * Event fired when playing starts or stops.
28998 * @event SequenceComponent#playingchanged
28999 * @type {boolean} Indicates whether the player is playing.
29001 SequenceComponent.playingchanged = "playingchanged";
29003 * Event fired when the hovered key changes.
29005 * @description Emits the key of the node for the direction
29006 * arrow that is being hovered. When the mouse leaves a
29007 * direction arrow null is emitted.
29009 * @event SequenceComponent#hoveredkeychanged
29010 * @type {string} The hovered key, null if no key is hovered.
29012 SequenceComponent.hoveredkeychanged = "hoveredkeychanged";
29013 return SequenceComponent;
29014 }(Component_1.Component));
29015 exports.SequenceComponent = SequenceComponent;
29016 Component_1.ComponentService.register(SequenceComponent);
29017 exports.default = SequenceComponent;
29019 },{"../../Component":275,"../../Edge":276,"../../Graph":279,"rxjs":27,"rxjs/operators":225}],334:[function(require,module,exports){
29021 Object.defineProperty(exports, "__esModule", { value: true });
29022 var rxjs_1 = require("rxjs");
29023 var operators_1 = require("rxjs/operators");
29024 var vd = require("virtual-dom");
29025 var Component_1 = require("../../Component");
29026 var Edge_1 = require("../../Edge");
29027 var Error_1 = require("../../Error");
29028 var SequenceDOMRenderer = /** @class */ (function () {
29029 function SequenceDOMRenderer(container) {
29030 this._container = container;
29031 this._minThresholdWidth = 320;
29032 this._maxThresholdWidth = 1480;
29033 this._minThresholdHeight = 240;
29034 this._maxThresholdHeight = 820;
29035 this._stepperDefaultWidth = 108;
29036 this._controlsDefaultWidth = 88;
29037 this._defaultHeight = 30;
29038 this._expandControls = false;
29039 this._mode = Component_1.SequenceMode.Default;
29041 this._changingSpeed = false;
29042 this._index = null;
29043 this._changingPosition = false;
29044 this._mouseEnterDirection$ = new rxjs_1.Subject();
29045 this._mouseLeaveDirection$ = new rxjs_1.Subject();
29046 this._notifyChanged$ = new rxjs_1.Subject();
29047 this._notifyChangingPositionChanged$ = new rxjs_1.Subject();
29048 this._notifySpeedChanged$ = new rxjs_1.Subject();
29049 this._notifyIndexChanged$ = new rxjs_1.Subject();
29051 Object.defineProperty(SequenceDOMRenderer.prototype, "changed$", {
29053 return this._notifyChanged$;
29058 Object.defineProperty(SequenceDOMRenderer.prototype, "changingPositionChanged$", {
29060 return this._notifyChangingPositionChanged$;
29065 Object.defineProperty(SequenceDOMRenderer.prototype, "speed$", {
29067 return this._notifySpeedChanged$;
29072 Object.defineProperty(SequenceDOMRenderer.prototype, "index$", {
29074 return this._notifyIndexChanged$;
29079 Object.defineProperty(SequenceDOMRenderer.prototype, "mouseEnterDirection$", {
29081 return this._mouseEnterDirection$;
29086 Object.defineProperty(SequenceDOMRenderer.prototype, "mouseLeaveDirection$", {
29088 return this._mouseLeaveDirection$;
29093 SequenceDOMRenderer.prototype.activate = function () {
29095 if (!!this._changingSubscription) {
29098 this._changingSubscription = rxjs_1.merge(this._container.mouseService.documentMouseUp$, this._container.touchService.touchEnd$.pipe(operators_1.filter(function (touchEvent) {
29099 return touchEvent.touches.length === 0;
29101 .subscribe(function (event) {
29102 if (_this._changingSpeed) {
29103 _this._changingSpeed = false;
29105 if (_this._changingPosition) {
29106 _this._setChangingPosition(false);
29110 SequenceDOMRenderer.prototype.deactivate = function () {
29111 if (!this._changingSubscription) {
29114 this._changingSpeed = false;
29115 this._changingPosition = false;
29116 this._expandControls = false;
29117 this._mode = Component_1.SequenceMode.Default;
29118 this._changingSubscription.unsubscribe();
29119 this._changingSubscription = null;
29121 SequenceDOMRenderer.prototype.render = function (edgeStatus, configuration, containerWidth, speed, index, max, component, navigator) {
29122 if (configuration.visible === false) {
29123 return vd.h("div.SequenceContainer", {}, []);
29125 var stepper = this._createStepper(edgeStatus, configuration, containerWidth, component, navigator);
29126 var controls = this._createSequenceControls(containerWidth);
29127 var playback = this._createPlaybackControls(containerWidth, speed, component, configuration);
29128 var timeline = this._createTimelineControls(containerWidth, index, max);
29129 return vd.h("div.SequenceContainer", [stepper, controls, playback, timeline]);
29131 SequenceDOMRenderer.prototype.getContainerWidth = function (size, configuration) {
29132 var minWidth = configuration.minWidth;
29133 var maxWidth = configuration.maxWidth;
29134 if (maxWidth < minWidth) {
29135 maxWidth = minWidth;
29137 var relativeWidth = (size.width - this._minThresholdWidth) / (this._maxThresholdWidth - this._minThresholdWidth);
29138 var relativeHeight = (size.height - this._minThresholdHeight) / (this._maxThresholdHeight - this._minThresholdHeight);
29139 var coeff = Math.max(0, Math.min(1, Math.min(relativeWidth, relativeHeight)));
29140 return minWidth + coeff * (maxWidth - minWidth);
29142 SequenceDOMRenderer.prototype._createPositionInput = function (index, max) {
29144 this._index = index;
29145 var onPosition = function (e) {
29146 _this._index = Number(e.target.value);
29147 _this._notifyIndexChanged$.next(_this._index);
29149 var boundingRect = this._container.domContainer.getBoundingClientRect();
29150 var width = Math.max(276, Math.min(410, 5 + 0.8 * boundingRect.width)) - 65;
29151 var onStart = function (e) {
29152 e.stopPropagation();
29153 _this._setChangingPosition(true);
29155 var onMove = function (e) {
29156 if (_this._changingPosition === true) {
29157 e.stopPropagation();
29160 var onKeyDown = function (e) {
29161 if (e.key === "ArrowDown" || e.key === "ArrowLeft" ||
29162 e.key === "ArrowRight" || e.key === "ArrowUp") {
29163 e.preventDefault();
29166 var positionInputProperties = {
29167 max: max != null ? max : 1,
29169 onchange: onPosition,
29170 oninput: onPosition,
29171 onkeydown: onKeyDown,
29172 onmousedown: onStart,
29173 onmousemove: onMove,
29174 ontouchmove: onMove,
29175 ontouchstart: onStart,
29177 width: width + "px",
29180 value: index != null ? index : 0,
29182 var disabled = index == null || max == null || max <= 1;
29184 positionInputProperties.disabled = "true";
29186 var positionInput = vd.h("input.SequencePosition", positionInputProperties, []);
29187 var positionContainerClass = disabled ? ".SequencePositionContainerDisabled" : ".SequencePositionContainer";
29188 return vd.h("div" + positionContainerClass, [positionInput]);
29190 SequenceDOMRenderer.prototype._createSpeedInput = function (speed) {
29192 this._speed = speed;
29193 var onSpeed = function (e) {
29194 _this._speed = Number(e.target.value) / 1000;
29195 _this._notifySpeedChanged$.next(_this._speed);
29197 var boundingRect = this._container.domContainer.getBoundingClientRect();
29198 var width = Math.max(276, Math.min(410, 5 + 0.8 * boundingRect.width)) - 160;
29199 var onStart = function (e) {
29200 _this._changingSpeed = true;
29201 e.stopPropagation();
29203 var onMove = function (e) {
29204 if (_this._changingSpeed === true) {
29205 e.stopPropagation();
29208 var onKeyDown = function (e) {
29209 if (e.key === "ArrowDown" || e.key === "ArrowLeft" ||
29210 e.key === "ArrowRight" || e.key === "ArrowUp") {
29211 e.preventDefault();
29214 var speedInput = vd.h("input.SequenceSpeed", {
29219 onkeydown: onKeyDown,
29220 onmousedown: onStart,
29221 onmousemove: onMove,
29222 ontouchmove: onMove,
29223 ontouchstart: onStart,
29225 width: width + "px",
29228 value: 1000 * speed,
29230 return vd.h("div.SequenceSpeedContainer", [speedInput]);
29232 SequenceDOMRenderer.prototype._createPlaybackControls = function (containerWidth, speed, component, configuration) {
29234 if (this._mode !== Component_1.SequenceMode.Playback) {
29235 return vd.h("div.SequencePlayback", []);
29237 var switchIcon = vd.h("div.SequenceSwitchIcon.SequenceIconVisible", []);
29238 var direction = configuration.direction === Edge_1.EdgeDirection.Next ?
29239 Edge_1.EdgeDirection.Prev : Edge_1.EdgeDirection.Next;
29240 var playing = configuration.playing;
29241 var switchButtonProperties = {
29242 onclick: function () {
29244 component.setDirection(direction);
29248 var switchButtonClassName = configuration.playing ? ".SequenceSwitchButtonDisabled" : ".SequenceSwitchButton";
29249 var switchButton = vd.h("div" + switchButtonClassName, switchButtonProperties, [switchIcon]);
29250 var slowIcon = vd.h("div.SequenceSlowIcon.SequenceIconVisible", []);
29251 var slowContainer = vd.h("div.SequenceSlowContainer", [slowIcon]);
29252 var fastIcon = vd.h("div.SequenceFastIcon.SequenceIconVisible", []);
29253 var fastContainer = vd.h("div.SequenceFastContainer", [fastIcon]);
29254 var closeIcon = vd.h("div.SequenceCloseIcon.SequenceIconVisible", []);
29255 var closeButtonProperties = {
29256 onclick: function () {
29257 _this._mode = Component_1.SequenceMode.Default;
29258 _this._notifyChanged$.next(_this);
29261 var closeButton = vd.h("div.SequenceCloseButton", closeButtonProperties, [closeIcon]);
29262 var speedInput = this._createSpeedInput(speed);
29263 var playbackChildren = [switchButton, slowContainer, speedInput, fastContainer, closeButton];
29264 var top = Math.round(containerWidth / this._stepperDefaultWidth * this._defaultHeight + 10);
29265 var playbackProperties = { style: { top: top + "px" } };
29266 return vd.h("div.SequencePlayback", playbackProperties, playbackChildren);
29268 SequenceDOMRenderer.prototype._createPlayingButton = function (nextKey, prevKey, configuration, component) {
29269 var canPlay = configuration.direction === Edge_1.EdgeDirection.Next && nextKey != null ||
29270 configuration.direction === Edge_1.EdgeDirection.Prev && prevKey != null;
29271 var onclick = configuration.playing ?
29272 function (e) { component.stop(); } :
29273 canPlay ? function (e) { component.play(); } : null;
29274 var buttonProperties = { onclick: onclick };
29275 var iconClass = configuration.playing ?
29277 canPlay ? "Play" : "PlayDisabled";
29278 var iconProperties = { className: iconClass };
29279 if (configuration.direction === Edge_1.EdgeDirection.Prev) {
29280 iconProperties.style = {
29281 transform: "rotate(180deg) translate(50%, 50%)",
29284 var icon = vd.h("div.SequenceComponentIcon", iconProperties, []);
29285 var buttonClass = canPlay ? "SequencePlay" : "SequencePlayDisabled";
29286 return vd.h("div." + buttonClass, buttonProperties, [icon]);
29288 SequenceDOMRenderer.prototype._createSequenceControls = function (containerWidth) {
29290 var borderRadius = Math.round(8 / this._stepperDefaultWidth * containerWidth);
29291 var expanderProperties = {
29292 onclick: function () {
29293 _this._expandControls = !_this._expandControls;
29294 _this._mode = Component_1.SequenceMode.Default;
29295 _this._notifyChanged$.next(_this);
29298 "border-bottom-right-radius": borderRadius + "px",
29299 "border-top-right-radius": borderRadius + "px",
29302 var expanderBar = vd.h("div.SequenceExpanderBar", []);
29303 var expander = vd.h("div.SequenceExpanderButton", expanderProperties, [expanderBar]);
29304 var fastIconClassName = this._mode === Component_1.SequenceMode.Playback ?
29305 ".SequenceFastIconGrey.SequenceIconVisible" : ".SequenceFastIcon";
29306 var fastIcon = vd.h("div" + fastIconClassName, []);
29307 var playbackProperties = {
29308 onclick: function () {
29309 _this._mode = _this._mode === Component_1.SequenceMode.Playback ?
29310 Component_1.SequenceMode.Default :
29311 Component_1.SequenceMode.Playback;
29312 _this._notifyChanged$.next(_this);
29315 var playback = vd.h("div.SequencePlaybackButton", playbackProperties, [fastIcon]);
29316 var timelineIconClassName = this._mode === Component_1.SequenceMode.Timeline ?
29317 ".SequenceTimelineIconGrey.SequenceIconVisible" : ".SequenceTimelineIcon";
29318 var timelineIcon = vd.h("div" + timelineIconClassName, []);
29319 var timelineProperties = {
29320 onclick: function () {
29321 _this._mode = _this._mode === Component_1.SequenceMode.Timeline ?
29322 Component_1.SequenceMode.Default :
29323 Component_1.SequenceMode.Timeline;
29324 _this._notifyChanged$.next(_this);
29327 var timeline = vd.h("div.SequenceTimelineButton", timelineProperties, [timelineIcon]);
29330 height: (this._defaultHeight / this._stepperDefaultWidth * containerWidth) + "px",
29331 transform: "translate(" + (containerWidth / 2 + 2) + "px, 0)",
29332 width: (this._controlsDefaultWidth / this._stepperDefaultWidth * containerWidth) + "px",
29335 var className = ".SequenceControls" +
29336 (this._expandControls ? ".SequenceControlsExpanded" : "");
29337 return vd.h("div" + className, properties, [playback, timeline, expander]);
29339 SequenceDOMRenderer.prototype._createSequenceArrows = function (nextKey, prevKey, containerWidth, configuration, navigator) {
29341 var nextProperties = {
29342 onclick: nextKey != null ?
29344 navigator.moveDir$(Edge_1.EdgeDirection.Next)
29345 .subscribe(undefined, function (error) {
29346 if (!(error instanceof Error_1.AbortMapillaryError)) {
29347 console.error(error);
29352 onmouseenter: function (e) { _this._mouseEnterDirection$.next(Edge_1.EdgeDirection.Next); },
29353 onmouseleave: function (e) { _this._mouseLeaveDirection$.next(Edge_1.EdgeDirection.Next); },
29355 var borderRadius = Math.round(8 / this._stepperDefaultWidth * containerWidth);
29356 var prevProperties = {
29357 onclick: prevKey != null ?
29359 navigator.moveDir$(Edge_1.EdgeDirection.Prev)
29360 .subscribe(undefined, function (error) {
29361 if (!(error instanceof Error_1.AbortMapillaryError)) {
29362 console.error(error);
29367 onmouseenter: function (e) { _this._mouseEnterDirection$.next(Edge_1.EdgeDirection.Prev); },
29368 onmouseleave: function (e) { _this._mouseLeaveDirection$.next(Edge_1.EdgeDirection.Prev); },
29370 "border-bottom-left-radius": borderRadius + "px",
29371 "border-top-left-radius": borderRadius + "px",
29374 var nextClass = this._getStepClassName(Edge_1.EdgeDirection.Next, nextKey, configuration.highlightKey);
29375 var prevClass = this._getStepClassName(Edge_1.EdgeDirection.Prev, prevKey, configuration.highlightKey);
29376 var nextIcon = vd.h("div.SequenceComponentIcon", []);
29377 var prevIcon = vd.h("div.SequenceComponentIcon", []);
29379 vd.h("div." + prevClass, prevProperties, [prevIcon]),
29380 vd.h("div." + nextClass, nextProperties, [nextIcon]),
29383 SequenceDOMRenderer.prototype._createStepper = function (edgeStatus, configuration, containerWidth, component, navigator) {
29384 var nextKey = null;
29385 var prevKey = null;
29386 for (var _i = 0, _a = edgeStatus.edges; _i < _a.length; _i++) {
29388 if (edge.data.direction === Edge_1.EdgeDirection.Next) {
29391 if (edge.data.direction === Edge_1.EdgeDirection.Prev) {
29395 var playingButton = this._createPlayingButton(nextKey, prevKey, configuration, component);
29396 var buttons = this._createSequenceArrows(nextKey, prevKey, containerWidth, configuration, navigator);
29397 buttons.splice(1, 0, playingButton);
29398 var containerProperties = {
29399 oncontextmenu: function (event) { event.preventDefault(); },
29401 height: (this._defaultHeight / this._stepperDefaultWidth * containerWidth) + "px",
29402 width: containerWidth + "px",
29405 return vd.h("div.SequenceStepper", containerProperties, buttons);
29407 SequenceDOMRenderer.prototype._createTimelineControls = function (containerWidth, index, max) {
29409 if (this._mode !== Component_1.SequenceMode.Timeline) {
29410 return vd.h("div.SequenceTimeline", []);
29412 var positionInput = this._createPositionInput(index, max);
29413 var closeIcon = vd.h("div.SequenceCloseIcon.SequenceIconVisible", []);
29414 var closeButtonProperties = {
29415 onclick: function () {
29416 _this._mode = Component_1.SequenceMode.Default;
29417 _this._notifyChanged$.next(_this);
29420 var closeButton = vd.h("div.SequenceCloseButton", closeButtonProperties, [closeIcon]);
29421 var top = Math.round(containerWidth / this._stepperDefaultWidth * this._defaultHeight + 10);
29422 var playbackProperties = { style: { top: top + "px" } };
29423 return vd.h("div.SequenceTimeline", playbackProperties, [positionInput, closeButton]);
29425 SequenceDOMRenderer.prototype._getStepClassName = function (direction, key, highlightKey) {
29426 var className = direction === Edge_1.EdgeDirection.Next ?
29427 "SequenceStepNext" :
29428 "SequenceStepPrev";
29430 className += "Disabled";
29433 if (highlightKey === key) {
29434 className += "Highlight";
29439 SequenceDOMRenderer.prototype._setChangingPosition = function (value) {
29440 this._changingPosition = value;
29441 this._notifyChangingPositionChanged$.next(value);
29443 return SequenceDOMRenderer;
29445 exports.SequenceDOMRenderer = SequenceDOMRenderer;
29446 exports.default = SequenceDOMRenderer;
29448 },{"../../Component":275,"../../Edge":276,"../../Error":277,"rxjs":27,"rxjs/operators":225,"virtual-dom":231}],335:[function(require,module,exports){
29450 Object.defineProperty(exports, "__esModule", { value: true });
29452 (function (SequenceMode) {
29453 SequenceMode[SequenceMode["Default"] = 0] = "Default";
29454 SequenceMode[SequenceMode["Playback"] = 1] = "Playback";
29455 SequenceMode[SequenceMode["Timeline"] = 2] = "Timeline";
29456 })(SequenceMode = exports.SequenceMode || (exports.SequenceMode = {}));
29457 exports.default = SequenceMode;
29459 },{}],336:[function(require,module,exports){
29461 Object.defineProperty(exports, "__esModule", { value: true });
29463 var path = require("path");
29464 var Shaders = /** @class */ (function () {
29465 function Shaders() {
29467 Shaders.equirectangular = {
29468 fragment: "#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n\nuniform sampler2D projectorTex;\nuniform float opacity;\nuniform float phiLength;\nuniform float phiShift;\nuniform float thetaLength;\nuniform float thetaShift;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n vec3 b = normalize(vRstq.xyz);\n float lat = -asin(b.y);\n float lon = atan(b.x, b.z);\n float x = (lon - phiShift) / phiLength + 0.5;\n float y = (lat - thetaShift) / thetaLength + 0.5;\n vec4 baseColor = texture2D(projectorTex, vec2(x, y));\n baseColor.a = opacity;\n gl_FragColor = baseColor;\n}",
29469 vertex: "#ifdef GL_ES\nprecision highp float;\n#endif\n\nuniform mat4 projectorMat;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n vRstq = projectorMat * vec4(position, 1.0);\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}",
29471 Shaders.equirectangularCurtain = {
29472 fragment: "#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n\nuniform sampler2D projectorTex;\nuniform float curtain;\nuniform float opacity;\nuniform float phiLength;\nuniform float phiShift;\nuniform float thetaLength;\nuniform float thetaShift;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n vec3 b = normalize(vRstq.xyz);\n float lat = -asin(b.y);\n float lon = atan(b.x, b.z);\n float x = (lon - phiShift) / phiLength + 0.5;\n float y = (lat - thetaShift) / thetaLength + 0.5;\n\n bool inverted = curtain < 0.5;\n\n float curtainMin = inverted ? curtain + 0.5 : curtain - 0.5;\n float curtainMax = curtain;\n\n bool insideCurtain = inverted ?\n x > curtainMin || x < curtainMax :\n x > curtainMin && x < curtainMax;\n\n vec4 baseColor;\n if (insideCurtain) {\n baseColor = texture2D(projectorTex, vec2(x, y));\n baseColor.a = opacity;\n } else {\n baseColor = vec4(0.0, 0.0, 0.0, 0.0);\n }\n\n gl_FragColor = baseColor;\n}",
29473 vertex: "#ifdef GL_ES\nprecision highp float;\n#endif\n\nuniform mat4 projectorMat;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n vRstq = projectorMat * vec4(position, 1.0);\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}",
29475 Shaders.perspective = {
29476 fragment: "#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n\nuniform sampler2D projectorTex;\nuniform float opacity;\nuniform float focal;\nuniform float k1;\nuniform float k2;\nuniform float scale_x;\nuniform float scale_y;\nuniform float radial_peak;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n float x = vRstq.x / vRstq.z;\n float y = vRstq.y / vRstq.z;\n float r2 = x * x + y * y;\n\n if (radial_peak > 0. && r2 > radial_peak * sqrt(r2)) {\n r2 = radial_peak * radial_peak;\n }\n\n float d = 1.0 + k1 * r2 + k2 * r2 * r2;\n float u = scale_x * focal * d * x + 0.5;\n float v = - scale_y * focal * d * y + 0.5;\n\n vec4 baseColor;\n if (u >= 0. && u <= 1. && v >= 0. && v <= 1.) {\n baseColor = texture2D(projectorTex, vec2(u, v));\n baseColor.a = opacity;\n } else {\n baseColor = vec4(0.0, 0.0, 0.0, 0.0);\n }\n\n gl_FragColor = baseColor;\n}",
29477 vertex: "#ifdef GL_ES\nprecision highp float;\n#endif\n\nuniform mat4 projectorMat;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n vRstq = projectorMat * vec4(position, 1.0);\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}",
29479 Shaders.perspectiveCurtain = {
29480 fragment: "#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n\nuniform sampler2D projectorTex;\nuniform float opacity;\nuniform float focal;\nuniform float k1;\nuniform float k2;\nuniform float scale_x;\nuniform float scale_y;\nuniform float radial_peak;\nuniform float curtain;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n float x = vRstq.x / vRstq.z;\n float y = vRstq.y / vRstq.z;\n float r2 = x * x + y * y;\n\n if (radial_peak > 0. && r2 > radial_peak * sqrt(r2)) {\n r2 = radial_peak * radial_peak;\n }\n\n float d = 1.0 + k1 * r2 + k2 * r2 * r2;\n float u = scale_x * focal * d * x + 0.5;\n float v = - scale_y * focal * d * y + 0.5;\n\n vec4 baseColor;\n if ((u < curtain || curtain >= 1.0) && u >= 0. && u <= 1. && v >= 0. && v <= 1.) {\n baseColor = texture2D(projectorTex, vec2(u, v));\n baseColor.a = opacity;\n } else {\n baseColor = vec4(0.0, 0.0, 0.0, 0.0);\n }\n\n gl_FragColor = baseColor;\n}\n",
29481 vertex: "#ifdef GL_ES\nprecision highp float;\n#endif\n\nuniform mat4 projectorMat;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n vRstq = projectorMat * vec4(position, 1.0);\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}",
29483 Shaders.fisheye = {
29484 fragment: "#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n\nuniform sampler2D projectorTex;\nuniform float opacity;\nuniform float focal;\nuniform float k1;\nuniform float k2;\nuniform float scale_x;\nuniform float scale_y;\nuniform float radial_peak;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n float x = vRstq.x;\n float y = vRstq.y;\n float z = vRstq.z;\n\n float r = sqrt(x * x + y * y);\n float theta = atan(r, z);\n\n if (radial_peak > 0. && theta > radial_peak) {\n theta = radial_peak;\n }\n\n float theta2 = theta * theta;\n float theta_d = theta * (1.0 + theta2 * (k1 + theta2 * k2));\n float s = focal * theta_d / r;\n\n float u = scale_x * s * x + 0.5;\n float v = -scale_y * s * y + 0.5;\n\n vec4 baseColor;\n if (u >= 0. && u <= 1. && v >= 0. && v <= 1.) {\n baseColor = texture2D(projectorTex, vec2(u, v));\n baseColor.a = opacity;\n } else {\n baseColor = vec4(0.0, 0.0, 0.0, 0.0);\n }\n\n gl_FragColor = baseColor;\n}\n",
29485 vertex: "#ifdef GL_ES\nprecision highp float;\n#endif\n\nuniform mat4 projectorMat;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n vRstq = projectorMat * vec4(position, 1.0);\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}",
29487 Shaders.fisheyeCurtain = {
29488 fragment: "#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n\nuniform sampler2D projectorTex;\nuniform float opacity;\nuniform float focal;\nuniform float k1;\nuniform float k2;\nuniform float scale_x;\nuniform float scale_y;\nuniform float radial_peak;\nuniform float curtain;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n float x = vRstq.x;\n float y = vRstq.y;\n float z = vRstq.z;\n\n float r2 = sqrt(x * x + y * y);\n float theta = atan(r2, z);\n\n if (radial_peak > 0. && theta > radial_peak) {\n theta = radial_peak;\n }\n\n float theta2 = theta * theta;\n float theta_d = theta * (1.0 + theta2 * (k1 + theta2 * k2));\n float s = focal * theta_d / r2;\n\n float u = scale_x * s * x + 0.5;\n float v = -scale_y * s * y + 0.5;\n\n vec4 baseColor;\n if ((u < curtain || curtain >= 1.0) && u >= 0. && u <= 1. && v >= 0. && v <= 1.) {\n baseColor = texture2D(projectorTex, vec2(u, v));\n baseColor.a = opacity;\n } else {\n baseColor = vec4(0.0, 0.0, 0.0, 0.0);\n }\n\n gl_FragColor = baseColor;\n}\n",
29489 vertex: "#ifdef GL_ES\nprecision highp float;\n#endif\n\nuniform mat4 projectorMat;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n vRstq = projectorMat * vec4(position, 1.0);\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}",
29491 Shaders.perspectiveDistorted = {
29492 fragment: "#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n\nuniform sampler2D projectorTex;\nuniform float opacity;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n float u = vRstq.x / vRstq.w;\n float v = vRstq.y / vRstq.w;\n\n vec4 baseColor;\n if (u >= 0. && u <= 1. && v >= 0. && v <= 1.) {\n baseColor = texture2D(projectorTex, vec2(u, v));\n baseColor.a = opacity;\n } else {\n baseColor = vec4(0.0, 0.0, 0.0, 0.0);\n }\n\n gl_FragColor = baseColor;\n}\n",
29493 vertex: "#ifdef GL_ES\nprecision highp float;\n#endif\n\nuniform mat4 projectorMat;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n vRstq = projectorMat * vec4(position, 1.0);\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n",
29495 Shaders.perspectiveDistortedCurtain = {
29496 fragment: "#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n\nuniform sampler2D projectorTex;\nuniform float opacity;\nuniform float curtain;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n float u = vRstq.x / vRstq.w;\n float v = vRstq.y / vRstq.w;\n\n vec4 baseColor;\n if ((u < curtain || curtain >= 1.0) && u >= 0. && u <= 1. && v >= 0. && v <= 1.) {\n baseColor = texture2D(projectorTex, vec2(u, v));\n baseColor.a = opacity;\n } else {\n baseColor = vec4(0.0, 0.0, 0.0, 0.0);\n }\n\n gl_FragColor = baseColor;\n}\n",
29497 vertex: "#ifdef GL_ES\nprecision highp float;\n#endif\n\nuniform mat4 projectorMat;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n vRstq = projectorMat * vec4(position, 1.0);\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n",
29501 exports.Shaders = Shaders;
29504 },{"path":23}],337:[function(require,module,exports){
29506 var __extends = (this && this.__extends) || (function () {
29507 var extendStatics = function (d, b) {
29508 extendStatics = Object.setPrototypeOf ||
29509 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
29510 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
29511 return extendStatics(d, b);
29513 return function (d, b) {
29514 extendStatics(d, b);
29515 function __() { this.constructor = d; }
29516 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
29519 Object.defineProperty(exports, "__esModule", { value: true });
29520 var rxjs_1 = require("rxjs");
29521 var operators_1 = require("rxjs/operators");
29522 var Component_1 = require("../../Component");
29523 var Geo_1 = require("../../Geo");
29524 var State_1 = require("../../State");
29525 var Render_1 = require("../../Render");
29526 var Tiles_1 = require("../../Tiles");
29527 var Utils_1 = require("../../Utils");
29529 * @class SliderComponent
29531 * @classdesc Component for comparing pairs of images. Renders
29532 * a slider for adjusting the curtain of the first image.
29534 * Deactivate the sequence, direction and image plane
29535 * components when activating the slider component to avoid
29536 * interfering UI elements.
29538 * To retrive and use the marker component
29542 * var viewer = new Mapillary.Viewer(
29547 * viewer.deactivateComponent("imagePlane");
29548 * viewer.deactivateComponent("direction");
29549 * viewer.deactivateComponent("sequence");
29551 * viewer.activateComponent("slider");
29553 * var sliderComponent = viewer.getComponent("marker");
29556 var SliderComponent = /** @class */ (function (_super) {
29557 __extends(SliderComponent, _super);
29559 function SliderComponent(name, container, navigator, viewportCoords) {
29560 var _this = _super.call(this, name, container, navigator) || this;
29561 _this._viewportCoords = !!viewportCoords ? viewportCoords : new Geo_1.ViewportCoords();
29562 _this._domRenderer = new Component_1.SliderDOMRenderer(container);
29563 _this._imageTileLoader = new Tiles_1.ImageTileLoader(Utils_1.Urls.tileScheme, Utils_1.Urls.tileDomain, Utils_1.Urls.origin);
29564 _this._roiCalculator = new Tiles_1.RegionOfInterestCalculator();
29565 _this._spatial = new Geo_1.Spatial();
29566 _this._glRendererOperation$ = new rxjs_1.Subject();
29567 _this._glRendererCreator$ = new rxjs_1.Subject();
29568 _this._glRendererDisposer$ = new rxjs_1.Subject();
29569 _this._glRenderer$ = _this._glRendererOperation$.pipe(operators_1.scan(function (glRenderer, operation) {
29570 return operation(glRenderer);
29571 }, null), operators_1.filter(function (glRenderer) {
29572 return glRenderer != null;
29573 }), operators_1.distinctUntilChanged(undefined, function (glRenderer) {
29574 return glRenderer.frameId;
29576 _this._glRendererCreator$.pipe(operators_1.map(function () {
29577 return function (glRenderer) {
29578 if (glRenderer != null) {
29579 throw new Error("Multiple slider states can not be created at the same time");
29581 return new Component_1.SliderGLRenderer();
29584 .subscribe(_this._glRendererOperation$);
29585 _this._glRendererDisposer$.pipe(operators_1.map(function () {
29586 return function (glRenderer) {
29587 glRenderer.dispose();
29591 .subscribe(_this._glRendererOperation$);
29595 * Set the initial position.
29597 * @description Configures the intial position of the slider.
29598 * The inital position value will be used when the component
29601 * @param {number} initialPosition - Initial slider position.
29603 SliderComponent.prototype.setInitialPosition = function (initialPosition) {
29604 this.configure({ initialPosition: initialPosition });
29607 * Set the image keys.
29609 * @description Configures the component to show the image
29610 * planes for the supplied image keys.
29612 * @param {ISliderKeys} keys - Slider keys object specifying
29613 * the images to be shown in the foreground and the background.
29615 SliderComponent.prototype.setKeys = function (keys) {
29616 this.configure({ keys: keys });
29619 * Set the slider mode.
29621 * @description Configures the mode for transitions between
29624 * @param {SliderMode} mode - Slider mode to be set.
29626 SliderComponent.prototype.setSliderMode = function (mode) {
29627 this.configure({ mode: mode });
29630 * Set the value controlling if the slider is visible.
29632 * @param {boolean} sliderVisible - Value indicating if
29633 * the slider should be visible or not.
29635 SliderComponent.prototype.setSliderVisible = function (sliderVisible) {
29636 this.configure({ sliderVisible: sliderVisible });
29638 SliderComponent.prototype._activate = function () {
29640 this._modeSubcription = this._domRenderer.mode$
29641 .subscribe(function (mode) {
29642 _this.setSliderMode(mode);
29644 this._glRenderSubscription = this._glRenderer$.pipe(operators_1.map(function (glRenderer) {
29648 frameId: glRenderer.frameId,
29649 needsRender: glRenderer.needsRender,
29650 render: glRenderer.render.bind(glRenderer),
29651 stage: Render_1.GLRenderStage.Background,
29656 .subscribe(this._container.glRenderer.render$);
29657 var position$ = rxjs_1.concat(this.configuration$.pipe(operators_1.map(function (configuration) {
29658 return configuration.initialPosition != null ?
29659 configuration.initialPosition : 1;
29660 }), operators_1.first()), this._domRenderer.position$);
29661 var mode$ = this.configuration$.pipe(operators_1.map(function (configuration) {
29662 return configuration.mode;
29663 }), operators_1.distinctUntilChanged());
29664 var motionless$ = this._navigator.stateService.currentState$.pipe(operators_1.map(function (frame) {
29665 return frame.state.motionless;
29666 }), operators_1.distinctUntilChanged());
29667 var fullPano$ = this._navigator.stateService.currentState$.pipe(operators_1.map(function (frame) {
29668 return frame.state.currentNode.fullPano;
29669 }), operators_1.distinctUntilChanged());
29670 var sliderVisible$ = rxjs_1.combineLatest(this._configuration$.pipe(operators_1.map(function (configuration) {
29671 return configuration.sliderVisible;
29672 })), this._navigator.stateService.currentState$.pipe(operators_1.map(function (frame) {
29673 return !(frame.state.currentNode == null ||
29674 frame.state.previousNode == null ||
29675 (frame.state.currentNode.pano && !frame.state.currentNode.fullPano) ||
29676 (frame.state.previousNode.pano && !frame.state.previousNode.fullPano) ||
29677 (frame.state.currentNode.fullPano && !frame.state.previousNode.fullPano));
29678 }), operators_1.distinctUntilChanged())).pipe(operators_1.map(function (_a) {
29679 var sliderVisible = _a[0], enabledState = _a[1];
29680 return sliderVisible && enabledState;
29681 }), operators_1.distinctUntilChanged());
29682 this._waitSubscription = rxjs_1.combineLatest(mode$, motionless$, fullPano$, sliderVisible$).pipe(operators_1.withLatestFrom(this._navigator.stateService.state$))
29683 .subscribe(function (_a) {
29684 var _b = _a[0], mode = _b[0], motionless = _b[1], fullPano = _b[2], sliderVisible = _b[3], state = _a[1];
29685 var interactive = sliderVisible &&
29686 (motionless || mode === Component_1.SliderMode.Stationary || fullPano);
29687 if (interactive && state !== State_1.State.WaitingInteractively) {
29688 _this._navigator.stateService.waitInteractively();
29690 else if (!interactive && state !== State_1.State.Waiting) {
29691 _this._navigator.stateService.wait();
29694 this._moveSubscription = rxjs_1.combineLatest(position$, mode$, motionless$, fullPano$, sliderVisible$)
29695 .subscribe(function (_a) {
29696 var position = _a[0], mode = _a[1], motionless = _a[2], fullPano = _a[3], sliderVisible = _a[4];
29697 if (motionless || mode === Component_1.SliderMode.Stationary || fullPano) {
29698 _this._navigator.stateService.moveTo(1);
29701 _this._navigator.stateService.moveTo(position);
29704 this._domRenderSubscription = rxjs_1.combineLatest(position$, mode$, motionless$, fullPano$, sliderVisible$, this._container.renderService.size$).pipe(operators_1.map(function (_a) {
29705 var position = _a[0], mode = _a[1], motionless = _a[2], fullPano = _a[3], sliderVisible = _a[4], size = _a[5];
29708 vnode: _this._domRenderer.render(position, mode, motionless, fullPano, sliderVisible),
29711 .subscribe(this._container.domRenderer.render$);
29712 this._glRendererCreator$.next(null);
29713 this._updateCurtainSubscription = rxjs_1.combineLatest(position$, fullPano$, sliderVisible$, this._container.renderService.renderCamera$, this._navigator.stateService.currentTransform$).pipe(operators_1.map(function (_a) {
29714 var position = _a[0], fullPano = _a[1], visible = _a[2], render = _a[3], transform = _a[4];
29716 return visible ? position : 1;
29718 var basicMin = _this._viewportCoords.viewportToBasic(-1.15, 0, transform, render.perspective);
29719 var basicMax = _this._viewportCoords.viewportToBasic(1.15, 0, transform, render.perspective);
29720 var shiftedMax = basicMax[0] < basicMin[0] ? basicMax[0] + 1 : basicMax[0];
29721 var basicPosition = basicMin[0] + position * (shiftedMax - basicMin[0]);
29722 return basicPosition > 1 ? basicPosition - 1 : basicPosition;
29723 }), operators_1.map(function (position) {
29724 return function (glRenderer) {
29725 glRenderer.updateCurtain(position);
29729 .subscribe(this._glRendererOperation$);
29730 this._stateSubscription = rxjs_1.combineLatest(this._navigator.stateService.currentState$, mode$).pipe(operators_1.map(function (_a) {
29731 var frame = _a[0], mode = _a[1];
29732 return function (glRenderer) {
29733 glRenderer.update(frame, mode);
29737 .subscribe(this._glRendererOperation$);
29738 this._setKeysSubscription = this._configuration$.pipe(operators_1.filter(function (configuration) {
29739 return configuration.keys != null;
29740 }), operators_1.switchMap(function (configuration) {
29741 return rxjs_1.zip(rxjs_1.zip(_this._catchCacheNode$(configuration.keys.background), _this._catchCacheNode$(configuration.keys.foreground)).pipe(operators_1.map(function (nodes) {
29742 return { background: nodes[0], foreground: nodes[1] };
29743 })), _this._navigator.stateService.currentState$.pipe(operators_1.first())).pipe(operators_1.map(function (nf) {
29744 return { nodes: nf[0], state: nf[1].state };
29747 .subscribe(function (co) {
29748 if (co.state.currentNode != null &&
29749 co.state.previousNode != null &&
29750 co.state.currentNode.key === co.nodes.foreground.key &&
29751 co.state.previousNode.key === co.nodes.background.key) {
29754 if (co.state.currentNode.key === co.nodes.background.key) {
29755 _this._navigator.stateService.setNodes([co.nodes.foreground]);
29758 if (co.state.currentNode.key === co.nodes.foreground.key &&
29759 co.state.trajectory.length === 1) {
29760 _this._navigator.stateService.prependNodes([co.nodes.background]);
29763 _this._navigator.stateService.setNodes([co.nodes.background]);
29764 _this._navigator.stateService.setNodes([co.nodes.foreground]);
29768 var previousNode$ = this._navigator.stateService.currentState$.pipe(operators_1.map(function (frame) {
29769 return frame.state.previousNode;
29770 }), operators_1.filter(function (node) {
29771 return node != null;
29772 }), operators_1.distinctUntilChanged(undefined, function (node) {
29775 var textureProvider$ = this._navigator.stateService.currentState$.pipe(operators_1.distinctUntilChanged(undefined, function (frame) {
29776 return frame.state.currentNode.key;
29777 }), operators_1.withLatestFrom(this._container.glRenderer.webGLRenderer$, this._container.renderService.size$), operators_1.map(function (_a) {
29778 var frame = _a[0], renderer = _a[1], size = _a[2];
29779 var state = frame.state;
29780 var viewportSize = Math.max(size.width, size.height);
29781 var currentNode = state.currentNode;
29782 var currentTransform = state.currentTransform;
29783 var tileSize = viewportSize > 2048 ? 2048 : viewportSize > 1024 ? 1024 : 512;
29784 return new Tiles_1.TextureProvider(currentNode.key, currentTransform.basicWidth, currentTransform.basicHeight, tileSize, currentNode.image, _this._imageTileLoader, new Tiles_1.ImageTileStore(), renderer);
29785 }), operators_1.publishReplay(1), operators_1.refCount());
29786 this._textureProviderSubscription = textureProvider$.subscribe(function () { });
29787 this._setTextureProviderSubscription = textureProvider$.pipe(operators_1.map(function (provider) {
29788 return function (renderer) {
29789 renderer.setTextureProvider(provider.key, provider);
29793 .subscribe(this._glRendererOperation$);
29794 this._setTileSizeSubscription = this._container.renderService.size$.pipe(operators_1.switchMap(function (size) {
29795 return rxjs_1.combineLatest(textureProvider$, rxjs_1.of(size)).pipe(operators_1.first());
29797 .subscribe(function (_a) {
29798 var provider = _a[0], size = _a[1];
29799 var viewportSize = Math.max(size.width, size.height);
29800 var tileSize = viewportSize > 2048 ? 2048 : viewportSize > 1024 ? 1024 : 512;
29801 provider.setTileSize(tileSize);
29803 this._abortTextureProviderSubscription = textureProvider$.pipe(operators_1.pairwise())
29804 .subscribe(function (pair) {
29805 var previous = pair[0];
29808 var roiTrigger$ = rxjs_1.combineLatest(this._container.renderService.renderCameraFrame$, this._container.renderService.size$.pipe(operators_1.debounceTime(250))).pipe(operators_1.map(function (_a) {
29809 var camera = _a[0], size = _a[1];
29811 camera.camera.position.clone(),
29812 camera.camera.lookat.clone(),
29813 camera.zoom.valueOf(),
29814 size.height.valueOf(),
29815 size.width.valueOf()
29817 }), operators_1.pairwise(), operators_1.skipWhile(function (pls) {
29818 return pls[1][2] - pls[0][2] < 0 || pls[1][2] === 0;
29819 }), operators_1.map(function (pls) {
29820 var samePosition = pls[0][0].equals(pls[1][0]);
29821 var sameLookat = pls[0][1].equals(pls[1][1]);
29822 var sameZoom = pls[0][2] === pls[1][2];
29823 var sameHeight = pls[0][3] === pls[1][3];
29824 var sameWidth = pls[0][4] === pls[1][4];
29825 return samePosition && sameLookat && sameZoom && sameHeight && sameWidth;
29826 }), operators_1.distinctUntilChanged(), operators_1.filter(function (stalled) {
29828 }), operators_1.switchMap(function (stalled) {
29829 return _this._container.renderService.renderCameraFrame$.pipe(operators_1.first());
29830 }), operators_1.withLatestFrom(this._container.renderService.size$, this._navigator.stateService.currentTransform$));
29831 this._setRegionOfInterestSubscription = textureProvider$.pipe(operators_1.switchMap(function (provider) {
29832 return roiTrigger$.pipe(operators_1.map(function (_a) {
29833 var camera = _a[0], size = _a[1], transform = _a[2];
29835 _this._roiCalculator.computeRegionOfInterest(camera, size, transform),
29839 }), operators_1.filter(function (args) {
29840 return !args[1].disposed;
29842 .subscribe(function (args) {
29844 var provider = args[1];
29845 provider.setRegionOfInterest(roi);
29847 var hasTexture$ = textureProvider$.pipe(operators_1.switchMap(function (provider) {
29848 return provider.hasTexture$;
29849 }), operators_1.startWith(false), operators_1.publishReplay(1), operators_1.refCount());
29850 this._hasTextureSubscription = hasTexture$.subscribe(function () { });
29851 var nodeImage$ = this._navigator.stateService.currentState$.pipe(operators_1.filter(function (frame) {
29852 return frame.state.nodesAhead === 0;
29853 }), operators_1.map(function (frame) {
29854 return frame.state.currentNode;
29855 }), operators_1.distinctUntilChanged(undefined, function (node) {
29857 }), operators_1.debounceTime(1000), operators_1.withLatestFrom(hasTexture$), operators_1.filter(function (args) {
29859 }), operators_1.map(function (args) {
29861 }), operators_1.filter(function (node) {
29863 Utils_1.Settings.maxImageSize > Utils_1.Settings.basePanoramaSize :
29864 Utils_1.Settings.maxImageSize > Utils_1.Settings.baseImageSize;
29865 }), operators_1.switchMap(function (node) {
29866 var baseImageSize = node.pano ?
29867 Utils_1.Settings.basePanoramaSize :
29868 Utils_1.Settings.baseImageSize;
29869 if (Math.max(node.image.width, node.image.height) > baseImageSize) {
29870 return rxjs_1.empty();
29873 .cacheImage$(Utils_1.Settings.maxImageSize).pipe(operators_1.map(function (n) {
29874 return [n.image, n];
29876 return image$.pipe(operators_1.takeUntil(hasTexture$.pipe(operators_1.filter(function (hasTexture) {
29878 }))), operators_1.catchError(function (error, caught) {
29879 console.error("Failed to fetch high res image (" + node.key + ")", error);
29880 return rxjs_1.empty();
29882 })).pipe(operators_1.publish(), operators_1.refCount());
29883 this._updateBackgroundSubscription = nodeImage$.pipe(operators_1.withLatestFrom(textureProvider$))
29884 .subscribe(function (args) {
29885 if (args[0][1].key !== args[1].key ||
29886 args[1].disposed) {
29889 args[1].updateBackground(args[0][0]);
29891 this._updateTextureImageSubscription = nodeImage$.pipe(operators_1.map(function (imn) {
29892 return function (renderer) {
29893 renderer.updateTextureImage(imn[0], imn[1]);
29897 .subscribe(this._glRendererOperation$);
29898 var textureProviderPrev$ = this._navigator.stateService.currentState$.pipe(operators_1.filter(function (frame) {
29899 return !!frame.state.previousNode;
29900 }), operators_1.distinctUntilChanged(undefined, function (frame) {
29901 return frame.state.previousNode.key;
29902 }), operators_1.withLatestFrom(this._container.glRenderer.webGLRenderer$, this._container.renderService.size$), operators_1.map(function (_a) {
29903 var frame = _a[0], renderer = _a[1], size = _a[2];
29904 var state = frame.state;
29905 var viewportSize = Math.max(size.width, size.height);
29906 var previousNode = state.previousNode;
29907 var previousTransform = state.previousTransform;
29908 var tileSize = viewportSize > 2048 ? 2048 : viewportSize > 1024 ? 1024 : 512;
29909 return new Tiles_1.TextureProvider(previousNode.key, previousTransform.basicWidth, previousTransform.basicHeight, tileSize, previousNode.image, _this._imageTileLoader, new Tiles_1.ImageTileStore(), renderer);
29910 }), operators_1.publishReplay(1), operators_1.refCount());
29911 this._textureProviderSubscriptionPrev = textureProviderPrev$.subscribe(function () { });
29912 this._setTextureProviderSubscriptionPrev = textureProviderPrev$.pipe(operators_1.map(function (provider) {
29913 return function (renderer) {
29914 renderer.setTextureProviderPrev(provider.key, provider);
29918 .subscribe(this._glRendererOperation$);
29919 this._setTileSizeSubscriptionPrev = this._container.renderService.size$.pipe(operators_1.switchMap(function (size) {
29920 return rxjs_1.combineLatest(textureProviderPrev$, rxjs_1.of(size)).pipe(operators_1.first());
29922 .subscribe(function (_a) {
29923 var provider = _a[0], size = _a[1];
29924 var viewportSize = Math.max(size.width, size.height);
29925 var tileSize = viewportSize > 2048 ? 2048 : viewportSize > 1024 ? 1024 : 512;
29926 provider.setTileSize(tileSize);
29928 this._abortTextureProviderSubscriptionPrev = textureProviderPrev$.pipe(operators_1.pairwise())
29929 .subscribe(function (pair) {
29930 var previous = pair[0];
29933 var roiTriggerPrev$ = rxjs_1.combineLatest(this._container.renderService.renderCameraFrame$, this._container.renderService.size$.pipe(operators_1.debounceTime(250))).pipe(operators_1.map(function (_a) {
29934 var camera = _a[0], size = _a[1];
29936 camera.camera.position.clone(),
29937 camera.camera.lookat.clone(),
29938 camera.zoom.valueOf(),
29939 size.height.valueOf(),
29940 size.width.valueOf()
29942 }), operators_1.pairwise(), operators_1.skipWhile(function (pls) {
29943 return pls[1][2] - pls[0][2] < 0 || pls[1][2] === 0;
29944 }), operators_1.map(function (pls) {
29945 var samePosition = pls[0][0].equals(pls[1][0]);
29946 var sameLookat = pls[0][1].equals(pls[1][1]);
29947 var sameZoom = pls[0][2] === pls[1][2];
29948 var sameHeight = pls[0][3] === pls[1][3];
29949 var sameWidth = pls[0][4] === pls[1][4];
29950 return samePosition && sameLookat && sameZoom && sameHeight && sameWidth;
29951 }), operators_1.distinctUntilChanged(), operators_1.filter(function (stalled) {
29953 }), operators_1.switchMap(function (stalled) {
29954 return _this._container.renderService.renderCameraFrame$.pipe(operators_1.first());
29955 }), operators_1.withLatestFrom(this._container.renderService.size$, this._navigator.stateService.currentTransform$));
29956 this._setRegionOfInterestSubscriptionPrev = textureProviderPrev$.pipe(operators_1.switchMap(function (provider) {
29957 return roiTriggerPrev$.pipe(operators_1.map(function (_a) {
29958 var camera = _a[0], size = _a[1], transform = _a[2];
29960 _this._roiCalculator.computeRegionOfInterest(camera, size, transform),
29964 }), operators_1.filter(function (args) {
29965 return !args[1].disposed;
29966 }), operators_1.withLatestFrom(this._navigator.stateService.currentState$))
29967 .subscribe(function (_a) {
29968 var _b = _a[0], roi = _b[0], provider = _b[1], frame = _a[1];
29969 var shiftedRoi = null;
29970 if (frame.state.previousNode.fullPano) {
29971 if (frame.state.currentNode.fullPano) {
29972 var currentViewingDirection = _this._spatial.viewingDirection(frame.state.currentNode.rotation);
29973 var previousViewingDirection = _this._spatial.viewingDirection(frame.state.previousNode.rotation);
29974 var directionDiff = _this._spatial.angleBetweenVector2(currentViewingDirection.x, currentViewingDirection.y, previousViewingDirection.x, previousViewingDirection.y);
29975 var shift = directionDiff / (2 * Math.PI);
29977 maxX: _this._spatial.wrap(roi.bbox.maxX + shift, 0, 1),
29978 maxY: roi.bbox.maxY,
29979 minX: _this._spatial.wrap(roi.bbox.minX + shift, 0, 1),
29980 minY: roi.bbox.minY,
29984 pixelHeight: roi.pixelHeight,
29985 pixelWidth: roi.pixelWidth,
29989 var currentViewingDirection = _this._spatial.viewingDirection(frame.state.currentNode.rotation);
29990 var previousViewingDirection = _this._spatial.viewingDirection(frame.state.previousNode.rotation);
29991 var directionDiff = _this._spatial.angleBetweenVector2(currentViewingDirection.x, currentViewingDirection.y, previousViewingDirection.x, previousViewingDirection.y);
29992 var shiftX = directionDiff / (2 * Math.PI);
29993 var a1 = _this._spatial.angleToPlane(currentViewingDirection.toArray(), [0, 0, 1]);
29994 var a2 = _this._spatial.angleToPlane(previousViewingDirection.toArray(), [0, 0, 1]);
29995 var shiftY = (a2 - a1) / (2 * Math.PI);
29996 var currentTransform = frame.state.currentTransform;
29997 var size = Math.max(currentTransform.basicWidth, currentTransform.basicHeight);
29998 var hFov = size > 0 ?
29999 2 * Math.atan(0.5 * currentTransform.basicWidth / (size * currentTransform.focal)) :
30001 var vFov = size > 0 ?
30002 2 * Math.atan(0.5 * currentTransform.basicHeight / (size * currentTransform.focal)) :
30004 var spanningWidth = hFov / (2 * Math.PI);
30005 var spanningHeight = vFov / Math.PI;
30006 var basicWidth = (roi.bbox.maxX - roi.bbox.minX) * spanningWidth;
30007 var basicHeight = (roi.bbox.maxY - roi.bbox.minY) * spanningHeight;
30008 var pixelWidth = roi.pixelWidth * spanningWidth;
30009 var pixelHeight = roi.pixelHeight * spanningHeight;
30010 var zoomShiftX = (roi.bbox.minX + roi.bbox.maxX) / 2 - 0.5;
30011 var zoomShiftY = (roi.bbox.minY + roi.bbox.maxY) / 2 - 0.5;
30012 var minX = 0.5 + shiftX + spanningWidth * zoomShiftX - basicWidth / 2;
30013 var maxX = 0.5 + shiftX + spanningWidth * zoomShiftX + basicWidth / 2;
30014 var minY = 0.5 + shiftY + spanningHeight * zoomShiftY - basicHeight / 2;
30015 var maxY = 0.5 + shiftY + spanningHeight * zoomShiftY + basicHeight / 2;
30017 maxX: _this._spatial.wrap(maxX, 0, 1),
30019 minX: _this._spatial.wrap(minX, 0, 1),
30024 pixelHeight: pixelHeight,
30025 pixelWidth: pixelWidth,
30030 var currentBasicAspect = frame.state.currentTransform.basicAspect;
30031 var previousBasicAspect = frame.state.previousTransform.basicAspect;
30032 var _c = _this._getBasicCorners(currentBasicAspect, previousBasicAspect), _d = _c[0], cornerMinX = _d[0], cornerMinY = _d[1], _e = _c[1], cornerMaxX = _e[0], cornerMaxY = _e[1];
30033 var basicWidth = cornerMaxX - cornerMinX;
30034 var basicHeight = cornerMaxY - cornerMinY;
30035 var pixelWidth = roi.pixelWidth / basicWidth;
30036 var pixelHeight = roi.pixelHeight / basicHeight;
30037 var minX = (basicWidth - 1) / (2 * basicWidth) + roi.bbox.minX / basicWidth;
30038 var maxX = (basicWidth - 1) / (2 * basicWidth) + roi.bbox.maxX / basicWidth;
30039 var minY = (basicHeight - 1) / (2 * basicHeight) + roi.bbox.minY / basicHeight;
30040 var maxY = (basicHeight - 1) / (2 * basicHeight) + roi.bbox.maxY / basicHeight;
30047 _this._clipBoundingBox(bbox);
30050 pixelHeight: pixelHeight,
30051 pixelWidth: pixelWidth,
30054 provider.setRegionOfInterest(shiftedRoi);
30056 var hasTexturePrev$ = textureProviderPrev$.pipe(operators_1.switchMap(function (provider) {
30057 return provider.hasTexture$;
30058 }), operators_1.startWith(false), operators_1.publishReplay(1), operators_1.refCount());
30059 this._hasTextureSubscriptionPrev = hasTexturePrev$.subscribe(function () { });
30060 var nodeImagePrev$ = this._navigator.stateService.currentState$.pipe(operators_1.filter(function (frame) {
30061 return frame.state.nodesAhead === 0 && !!frame.state.previousNode;
30062 }), operators_1.map(function (frame) {
30063 return frame.state.previousNode;
30064 }), operators_1.distinctUntilChanged(undefined, function (node) {
30066 }), operators_1.debounceTime(1000), operators_1.withLatestFrom(hasTexturePrev$), operators_1.filter(function (args) {
30068 }), operators_1.map(function (args) {
30070 }), operators_1.filter(function (node) {
30072 Utils_1.Settings.maxImageSize > Utils_1.Settings.basePanoramaSize :
30073 Utils_1.Settings.maxImageSize > Utils_1.Settings.baseImageSize;
30074 }), operators_1.switchMap(function (node) {
30075 var baseImageSize = node.pano ?
30076 Utils_1.Settings.basePanoramaSize :
30077 Utils_1.Settings.baseImageSize;
30078 if (Math.max(node.image.width, node.image.height) > baseImageSize) {
30079 return rxjs_1.empty();
30082 .cacheImage$(Utils_1.Settings.maxImageSize).pipe(operators_1.map(function (n) {
30083 return [n.image, n];
30085 return image$.pipe(operators_1.takeUntil(hasTexturePrev$.pipe(operators_1.filter(function (hasTexture) {
30087 }))), operators_1.catchError(function (error, caught) {
30088 console.error("Failed to fetch high res image (" + node.key + ")", error);
30089 return rxjs_1.empty();
30091 })).pipe(operators_1.publish(), operators_1.refCount());
30092 this._updateBackgroundSubscriptionPrev = nodeImagePrev$.pipe(operators_1.withLatestFrom(textureProviderPrev$))
30093 .subscribe(function (args) {
30094 if (args[0][1].key !== args[1].key ||
30095 args[1].disposed) {
30098 args[1].updateBackground(args[0][0]);
30100 this._updateTextureImageSubscriptionPrev = nodeImagePrev$.pipe(operators_1.map(function (imn) {
30101 return function (renderer) {
30102 renderer.updateTextureImage(imn[0], imn[1]);
30106 .subscribe(this._glRendererOperation$);
30108 SliderComponent.prototype._deactivate = function () {
30110 this._waitSubscription.unsubscribe();
30111 this._navigator.stateService.state$.pipe(operators_1.first())
30112 .subscribe(function (state) {
30113 if (state !== State_1.State.Traversing) {
30114 _this._navigator.stateService.traverse();
30117 this._glRendererDisposer$.next(null);
30118 this._domRenderer.deactivate();
30119 this._modeSubcription.unsubscribe();
30120 this._setKeysSubscription.unsubscribe();
30121 this._stateSubscription.unsubscribe();
30122 this._glRenderSubscription.unsubscribe();
30123 this._domRenderSubscription.unsubscribe();
30124 this._moveSubscription.unsubscribe();
30125 this._updateCurtainSubscription.unsubscribe();
30126 this._textureProviderSubscription.unsubscribe();
30127 this._setTextureProviderSubscription.unsubscribe();
30128 this._setTileSizeSubscription.unsubscribe();
30129 this._abortTextureProviderSubscription.unsubscribe();
30130 this._setRegionOfInterestSubscription.unsubscribe();
30131 this._hasTextureSubscription.unsubscribe();
30132 this._updateBackgroundSubscription.unsubscribe();
30133 this._updateTextureImageSubscription.unsubscribe();
30134 this._textureProviderSubscriptionPrev.unsubscribe();
30135 this._setTextureProviderSubscriptionPrev.unsubscribe();
30136 this._setTileSizeSubscriptionPrev.unsubscribe();
30137 this._abortTextureProviderSubscriptionPrev.unsubscribe();
30138 this._setRegionOfInterestSubscriptionPrev.unsubscribe();
30139 this._hasTextureSubscriptionPrev.unsubscribe();
30140 this._updateBackgroundSubscriptionPrev.unsubscribe();
30141 this._updateTextureImageSubscriptionPrev.unsubscribe();
30142 this.configure({ keys: null });
30144 SliderComponent.prototype._getDefaultConfiguration = function () {
30146 initialPosition: 1,
30147 mode: Component_1.SliderMode.Motion,
30148 sliderVisible: true,
30151 SliderComponent.prototype._catchCacheNode$ = function (key) {
30152 return this._navigator.graphService.cacheNode$(key).pipe(operators_1.catchError(function (error, caught) {
30153 console.error("Failed to cache slider node (" + key + ")", error);
30154 return rxjs_1.empty();
30157 SliderComponent.prototype._getBasicCorners = function (currentAspect, previousAspect) {
30160 if (currentAspect > previousAspect) {
30162 offsetY = 0.5 * currentAspect / previousAspect;
30165 offsetX = 0.5 * previousAspect / currentAspect;
30168 return [[0.5 - offsetX, 0.5 - offsetY], [0.5 + offsetX, 0.5 + offsetY]];
30170 SliderComponent.prototype._clipBoundingBox = function (bbox) {
30171 bbox.minX = Math.max(0, Math.min(1, bbox.minX));
30172 bbox.maxX = Math.max(0, Math.min(1, bbox.maxX));
30173 bbox.minY = Math.max(0, Math.min(1, bbox.minY));
30174 bbox.maxY = Math.max(0, Math.min(1, bbox.maxY));
30176 SliderComponent.componentName = "slider";
30177 return SliderComponent;
30178 }(Component_1.Component));
30179 exports.SliderComponent = SliderComponent;
30180 Component_1.ComponentService.register(SliderComponent);
30181 exports.default = SliderComponent;
30184 },{"../../Component":275,"../../Geo":278,"../../Render":281,"../../State":282,"../../Tiles":284,"../../Utils":285,"rxjs":27,"rxjs/operators":225}],338:[function(require,module,exports){
30186 Object.defineProperty(exports, "__esModule", { value: true });
30187 var rxjs_1 = require("rxjs");
30188 var operators_1 = require("rxjs/operators");
30189 var vd = require("virtual-dom");
30190 var Component_1 = require("../../Component");
30191 var SliderDOMRenderer = /** @class */ (function () {
30192 function SliderDOMRenderer(container) {
30193 this._container = container;
30194 this._interacting = false;
30195 this._notifyModeChanged$ = new rxjs_1.Subject();
30196 this._notifyPositionChanged$ = new rxjs_1.Subject();
30197 this._stopInteractionSubscription = null;
30199 Object.defineProperty(SliderDOMRenderer.prototype, "mode$", {
30201 return this._notifyModeChanged$;
30206 Object.defineProperty(SliderDOMRenderer.prototype, "position$", {
30208 return this._notifyPositionChanged$;
30213 SliderDOMRenderer.prototype.activate = function () {
30215 if (!!this._stopInteractionSubscription) {
30218 this._stopInteractionSubscription = rxjs_1.merge(this._container.mouseService.documentMouseUp$, this._container.touchService.touchEnd$.pipe(operators_1.filter(function (touchEvent) {
30219 return touchEvent.touches.length === 0;
30221 .subscribe(function (event) {
30222 if (_this._interacting) {
30223 _this._interacting = false;
30227 SliderDOMRenderer.prototype.deactivate = function () {
30228 if (!this._stopInteractionSubscription) {
30231 this._interacting = false;
30232 this._stopInteractionSubscription.unsubscribe();
30233 this._stopInteractionSubscription = null;
30235 SliderDOMRenderer.prototype.render = function (position, mode, motionless, pano, visible) {
30238 children.push(vd.h("div.SliderBorder", []));
30239 var modeVisible = !(motionless || pano);
30241 children.push(this._createModeButton(mode));
30243 children.push(this._createPositionInput(position, modeVisible));
30245 var boundingRect = this._container.domContainer.getBoundingClientRect();
30246 var width = Math.max(215, Math.min(400, boundingRect.width - 100));
30247 return vd.h("div.SliderContainer", { style: { width: width + "px" } }, children);
30249 SliderDOMRenderer.prototype._createModeButton = function (mode) {
30252 onclick: function () {
30253 _this._notifyModeChanged$.next(mode === Component_1.SliderMode.Motion ?
30254 Component_1.SliderMode.Stationary :
30255 Component_1.SliderMode.Motion);
30258 var className = mode === Component_1.SliderMode.Stationary ?
30259 "SliderModeButtonPressed" :
30260 "SliderModeButton";
30261 return vd.h("div." + className, properties, [vd.h("div.SliderModeIcon", [])]);
30263 SliderDOMRenderer.prototype._createPositionInput = function (position, modeVisible) {
30265 var onChange = function (e) {
30266 _this._notifyPositionChanged$.next(Number(e.target.value) / 1000);
30268 var onStart = function (e) {
30269 _this._interacting = true;
30270 e.stopPropagation();
30272 var onMove = function (e) {
30273 if (_this._interacting) {
30274 e.stopPropagation();
30277 var onKeyDown = function (e) {
30278 if (e.key === "ArrowDown" || e.key === "ArrowLeft" ||
30279 e.key === "ArrowRight" || e.key === "ArrowUp") {
30280 e.preventDefault();
30283 var boundingRect = this._container.domContainer.getBoundingClientRect();
30284 var width = Math.max(215, Math.min(400, boundingRect.width - 105)) - 68 + (modeVisible ? 0 : 36);
30285 var positionInput = vd.h("input.SliderPosition", {
30288 onchange: onChange,
30290 onkeydown: onKeyDown,
30291 onmousedown: onStart,
30292 onmousemove: onMove,
30293 ontouchmove: onMove,
30294 ontouchstart: onStart,
30296 width: width + "px",
30299 value: 1000 * position,
30301 return vd.h("div.SliderPositionContainer", [positionInput]);
30303 return SliderDOMRenderer;
30305 exports.SliderDOMRenderer = SliderDOMRenderer;
30306 exports.default = SliderDOMRenderer;
30308 },{"../../Component":275,"rxjs":27,"rxjs/operators":225,"virtual-dom":231}],339:[function(require,module,exports){
30310 Object.defineProperty(exports, "__esModule", { value: true });
30311 var Component_1 = require("../../Component");
30312 var Geo_1 = require("../../Geo");
30313 var SliderGLRenderer = /** @class */ (function () {
30314 function SliderGLRenderer() {
30315 this._factory = new Component_1.MeshFactory();
30316 this._scene = new Component_1.MeshScene();
30317 this._spatial = new Geo_1.Spatial();
30318 this._currentKey = null;
30319 this._previousKey = null;
30320 this._disabled = false;
30323 this._needsRender = false;
30325 this._currentProviderDisposers = {};
30326 this._previousProviderDisposers = {};
30328 Object.defineProperty(SliderGLRenderer.prototype, "disabled", {
30330 return this._disabled;
30335 Object.defineProperty(SliderGLRenderer.prototype, "frameId", {
30337 return this._frameId;
30342 Object.defineProperty(SliderGLRenderer.prototype, "needsRender", {
30344 return this._needsRender;
30349 SliderGLRenderer.prototype.setTextureProvider = function (key, provider) {
30350 this._setTextureProvider(key, this._currentKey, provider, this._currentProviderDisposers, this._updateTexture.bind(this));
30352 SliderGLRenderer.prototype.setTextureProviderPrev = function (key, provider) {
30353 this._setTextureProvider(key, this._previousKey, provider, this._previousProviderDisposers, this._updateTexturePrev.bind(this));
30355 SliderGLRenderer.prototype.update = function (frame, mode) {
30356 this._updateFrameId(frame.id);
30357 this._updateImagePlanes(frame.state, mode);
30359 SliderGLRenderer.prototype.updateCurtain = function (curtain) {
30360 if (this._curtain === curtain) {
30363 this._curtain = curtain;
30364 this._updateCurtain();
30365 this._needsRender = true;
30367 SliderGLRenderer.prototype.updateTexture = function (image, node) {
30368 var imagePlanes = node.key === this._currentKey ?
30369 this._scene.imagePlanes :
30370 node.key === this._previousKey ?
30371 this._scene.imagePlanesOld :
30373 if (imagePlanes.length === 0) {
30376 this._needsRender = true;
30377 for (var _i = 0, imagePlanes_1 = imagePlanes; _i < imagePlanes_1.length; _i++) {
30378 var plane = imagePlanes_1[_i];
30379 var material = plane.material;
30380 var texture = material.uniforms.projectorTex.value;
30381 texture.image = image;
30382 texture.needsUpdate = true;
30385 SliderGLRenderer.prototype.updateTextureImage = function (image, node) {
30386 if (this._currentKey !== node.key) {
30389 this._needsRender = true;
30390 for (var _i = 0, _a = this._scene.imagePlanes; _i < _a.length; _i++) {
30391 var plane = _a[_i];
30392 var material = plane.material;
30393 var texture = material.uniforms.projectorTex.value;
30394 texture.image = image;
30395 texture.needsUpdate = true;
30398 SliderGLRenderer.prototype.render = function (perspectiveCamera, renderer) {
30399 if (!this.disabled) {
30400 renderer.render(this._scene.sceneOld, perspectiveCamera);
30402 renderer.render(this._scene.scene, perspectiveCamera);
30403 this._needsRender = false;
30405 SliderGLRenderer.prototype.dispose = function () {
30406 this._scene.clear();
30407 for (var key in this._currentProviderDisposers) {
30408 if (!this._currentProviderDisposers.hasOwnProperty(key)) {
30411 this._currentProviderDisposers[key]();
30413 for (var key in this._previousProviderDisposers) {
30414 if (!this._previousProviderDisposers.hasOwnProperty(key)) {
30417 this._previousProviderDisposers[key]();
30419 this._currentProviderDisposers = {};
30420 this._previousProviderDisposers = {};
30422 SliderGLRenderer.prototype._getBasicCorners = function (currentAspect, previousAspect) {
30425 if (currentAspect > previousAspect) {
30427 offsetY = 0.5 * currentAspect / previousAspect;
30430 offsetX = 0.5 * previousAspect / currentAspect;
30433 return [[0.5 - offsetX, 0.5 - offsetY], [0.5 + offsetX, 0.5 + offsetY]];
30435 SliderGLRenderer.prototype._setDisabled = function (state) {
30436 this._disabled = state.currentNode == null ||
30437 state.previousNode == null ||
30438 (state.currentNode.pano && !state.currentNode.fullPano) ||
30439 (state.previousNode.pano && !state.previousNode.fullPano) ||
30440 (state.currentNode.fullPano && !state.previousNode.fullPano);
30442 SliderGLRenderer.prototype._setTextureProvider = function (key, originalKey, provider, providerDisposers, updateTexture) {
30444 if (key !== originalKey) {
30447 var createdSubscription = provider.textureCreated$
30448 .subscribe(updateTexture);
30449 var updatedSubscription = provider.textureUpdated$
30450 .subscribe(function (updated) {
30451 _this._needsRender = true;
30453 var dispose = function () {
30454 createdSubscription.unsubscribe();
30455 updatedSubscription.unsubscribe();
30456 provider.dispose();
30458 if (key in providerDisposers) {
30459 var disposeProvider = providerDisposers[key];
30461 delete providerDisposers[key];
30463 providerDisposers[key] = dispose;
30465 SliderGLRenderer.prototype._updateCurtain = function () {
30466 for (var _i = 0, _a = this._scene.imagePlanes; _i < _a.length; _i++) {
30467 var plane = _a[_i];
30468 var shaderMaterial = plane.material;
30469 if (!!shaderMaterial.uniforms.curtain) {
30470 shaderMaterial.uniforms.curtain.value = this._curtain;
30474 SliderGLRenderer.prototype._updateFrameId = function (frameId) {
30475 this._frameId = frameId;
30477 SliderGLRenderer.prototype._updateImagePlanes = function (state, mode) {
30478 var currentChanged = state.currentNode != null && this._currentKey !== state.currentNode.key;
30479 var previousChanged = state.previousNode != null && this._previousKey !== state.previousNode.key;
30480 var modeChanged = this._mode !== mode;
30481 if (!(currentChanged || previousChanged || modeChanged)) {
30484 this._setDisabled(state);
30485 this._needsRender = true;
30487 var motionless = state.motionless || mode === Component_1.SliderMode.Stationary || state.currentNode.pano;
30488 if (this.disabled || previousChanged) {
30489 if (this._previousKey in this._previousProviderDisposers) {
30490 this._previousProviderDisposers[this._previousKey]();
30491 delete this._previousProviderDisposers[this._previousKey];
30494 if (this.disabled) {
30495 this._scene.setImagePlanesOld([]);
30498 if (previousChanged || modeChanged) {
30499 var previousNode = state.previousNode;
30500 this._previousKey = previousNode.key;
30501 var elements = state.currentTransform.rt.elements;
30502 var translation = [elements[12], elements[13], elements[14]];
30503 var currentAspect = state.currentTransform.basicAspect;
30504 var previousAspect = state.previousTransform.basicAspect;
30505 var textureScale = currentAspect > previousAspect ?
30506 [1, previousAspect / currentAspect] :
30507 [currentAspect / previousAspect, 1];
30508 var rotation = state.currentNode.rotation;
30509 var width = state.currentNode.width;
30510 var height = state.currentNode.height;
30511 if (previousNode.fullPano) {
30512 rotation = state.previousNode.rotation;
30513 translation = this._spatial
30514 .rotate(this._spatial
30515 .opticalCenter(state.currentNode.rotation, translation)
30516 .toArray(), rotation)
30517 .multiplyScalar(-1)
30519 width = state.previousNode.width;
30520 height = state.previousNode.height;
30522 var transform = new Geo_1.Transform(state.currentNode.orientation, width, height, state.currentNode.focal, state.currentNode.scale, previousNode.gpano, rotation, translation, previousNode.image, textureScale);
30523 var mesh = undefined;
30524 if (previousNode.fullPano) {
30525 mesh = this._factory.createMesh(previousNode, motionless || state.currentNode.fullPano ? transform : state.previousTransform);
30529 var _a = this._getBasicCorners(currentAspect, previousAspect), _b = _a[0], basicX0 = _b[0], basicY0 = _b[1], _c = _a[1], basicX1 = _c[0], basicY1 = _c[1];
30530 mesh = this._factory.createFlatMesh(state.previousNode, transform, basicX0, basicX1, basicY0, basicY1);
30533 mesh = this._factory.createMesh(state.previousNode, state.previousTransform);
30536 this._scene.setImagePlanesOld([mesh]);
30539 if (currentChanged || modeChanged) {
30540 if (this._currentKey in this._currentProviderDisposers) {
30541 this._currentProviderDisposers[this._currentKey]();
30542 delete this._currentProviderDisposers[this._currentKey];
30544 this._currentKey = state.currentNode.key;
30545 var imagePlanes = [];
30546 if (state.currentNode.fullPano) {
30547 imagePlanes.push(this._factory.createCurtainMesh(state.currentNode, state.currentTransform));
30549 else if (state.currentNode.pano && !state.currentNode.fullPano) {
30550 imagePlanes.push(this._factory.createMesh(state.currentNode, state.currentTransform));
30554 imagePlanes.push(this._factory.createDistortedCurtainMesh(state.currentNode, state.currentTransform));
30557 imagePlanes.push(this._factory.createCurtainMesh(state.currentNode, state.currentTransform));
30560 this._scene.setImagePlanes(imagePlanes);
30561 this._updateCurtain();
30564 SliderGLRenderer.prototype._updateTexture = function (texture) {
30565 this._needsRender = true;
30566 for (var _i = 0, _a = this._scene.imagePlanes; _i < _a.length; _i++) {
30567 var plane = _a[_i];
30568 var material = plane.material;
30569 var oldTexture = material.uniforms.projectorTex.value;
30570 material.uniforms.projectorTex.value = null;
30571 oldTexture.dispose();
30572 material.uniforms.projectorTex.value = texture;
30575 SliderGLRenderer.prototype._updateTexturePrev = function (texture) {
30576 this._needsRender = true;
30577 for (var _i = 0, _a = this._scene.imagePlanesOld; _i < _a.length; _i++) {
30578 var plane = _a[_i];
30579 var material = plane.material;
30580 var oldTexture = material.uniforms.projectorTex.value;
30581 material.uniforms.projectorTex.value = null;
30582 oldTexture.dispose();
30583 material.uniforms.projectorTex.value = texture;
30586 return SliderGLRenderer;
30588 exports.SliderGLRenderer = SliderGLRenderer;
30589 exports.default = SliderGLRenderer;
30592 },{"../../Component":275,"../../Geo":278}],340:[function(require,module,exports){
30594 Object.defineProperty(exports, "__esModule", { value: true });
30595 var geohash = require("latlon-geohash");
30596 var rxjs_1 = require("rxjs");
30597 var operators_1 = require("rxjs/operators");
30598 var Error_1 = require("../../Error");
30599 var Utils_1 = require("../../Utils");
30600 var SpatialDataCache = /** @class */ (function () {
30601 function SpatialDataCache(graphService) {
30602 this._graphService = graphService;
30604 this._cacheRequests = {};
30605 this._reconstructions = {};
30606 this._cachingReconstructions$ = {};
30607 this._cachingTiles$ = {};
30609 SpatialDataCache.prototype.cacheReconstructions$ = function (hash) {
30611 if (!this.hasTile(hash)) {
30612 throw new Error("Cannot cache reconstructions of a non-existing tile.");
30614 if (this.hasReconstructions(hash)) {
30615 throw new Error("Cannot cache reconstructions that already exists.");
30617 if (this.isCachingReconstructions(hash)) {
30618 return this._cachingReconstructions$[hash];
30621 if (hash in this._reconstructions) {
30622 var reconstructionKeys = this.getReconstructions(hash)
30623 .map(function (reconstruction) {
30624 return reconstruction.data.key;
30626 for (var _i = 0, _a = this.getTile(hash); _i < _a.length; _i++) {
30628 if (reconstructionKeys.indexOf(node.key) === -1) {
30634 tile.push.apply(tile, this.getTile(hash));
30635 this._reconstructions[hash] = [];
30637 this._cacheRequests[hash] = [];
30638 this._cachingReconstructions$[hash] = rxjs_1.from(tile).pipe(operators_1.mergeMap(function (nodeData) {
30639 return !_this._cacheRequests[hash] ?
30641 rxjs_1.zip(rxjs_1.of(nodeData), _this._getAtomicReconstruction(nodeData.key, _this._cacheRequests[hash]))
30642 .pipe(operators_1.catchError(function (error) {
30643 if (error instanceof Error_1.AbortMapillaryError) {
30644 return rxjs_1.empty();
30646 console.error(error);
30647 return rxjs_1.of([nodeData, null]);
30649 }, 6), operators_1.map(function (_a) {
30650 var nodeData = _a[0], reconstruction = _a[1];
30651 return { data: nodeData, reconstruction: reconstruction };
30652 }), operators_1.filter(function () {
30653 return hash in _this._reconstructions;
30654 }), operators_1.tap(function (data) {
30655 _this._reconstructions[hash].push(data);
30656 }), operators_1.filter(function (data) {
30657 return !!data.reconstruction;
30658 }), operators_1.finalize(function () {
30659 if (hash in _this._cachingReconstructions$) {
30660 delete _this._cachingReconstructions$[hash];
30662 if (hash in _this._cacheRequests) {
30663 delete _this._cacheRequests[hash];
30665 }), operators_1.publish(), operators_1.refCount());
30666 return this._cachingReconstructions$[hash];
30668 SpatialDataCache.prototype.cacheTile$ = function (hash) {
30670 if (hash.length !== 8) {
30671 throw new Error("Hash needs to be level 8.");
30673 if (this.hasTile(hash)) {
30674 throw new Error("Cannot cache tile that already exists.");
30676 if (this.hasTile(hash)) {
30677 return this._cachingTiles$[hash];
30679 var bounds = geohash.bounds(hash);
30680 var sw = { lat: bounds.sw.lat, lon: bounds.sw.lon };
30681 var ne = { lat: bounds.ne.lat, lon: bounds.ne.lon };
30682 this._tiles[hash] = [];
30683 this._cachingTiles$[hash] = this._graphService.cacheBoundingBox$(sw, ne).pipe(operators_1.catchError(function (error) {
30684 console.error(error);
30685 delete _this._tiles[hash];
30686 return rxjs_1.empty();
30687 }), operators_1.map(function (nodes) {
30689 .map(function (n) {
30690 return _this._createNodeData(n);
30692 }), operators_1.filter(function () {
30693 return hash in _this._tiles;
30694 }), operators_1.tap(function (nodeData) {
30696 (_a = _this._tiles[hash]).push.apply(_a, nodeData);
30697 delete _this._cachingTiles$[hash];
30698 }), operators_1.finalize(function () {
30699 if (hash in _this._cachingTiles$) {
30700 delete _this._cachingTiles$[hash];
30702 }), operators_1.publish(), operators_1.refCount());
30703 return this._cachingTiles$[hash];
30705 SpatialDataCache.prototype.isCachingReconstructions = function (hash) {
30706 return hash in this._cachingReconstructions$;
30708 SpatialDataCache.prototype.isCachingTile = function (hash) {
30709 return hash in this._cachingTiles$;
30711 SpatialDataCache.prototype.hasReconstructions = function (hash) {
30712 return !(hash in this._cachingReconstructions$) &&
30713 hash in this._reconstructions &&
30714 this._reconstructions[hash].length === this._tiles[hash].length;
30716 SpatialDataCache.prototype.hasTile = function (hash) {
30717 return !(hash in this._cachingTiles$) && hash in this._tiles;
30719 SpatialDataCache.prototype.getReconstructions = function (hash) {
30720 return hash in this._reconstructions ?
30721 this._reconstructions[hash]
30722 .filter(function (data) {
30723 return !!data.reconstruction;
30727 SpatialDataCache.prototype.getTile = function (hash) {
30728 return hash in this._tiles ? this._tiles[hash] : [];
30730 SpatialDataCache.prototype.uncache = function (keepHashes) {
30731 for (var _i = 0, _a = Object.keys(this._cacheRequests); _i < _a.length; _i++) {
30733 if (!!keepHashes && keepHashes.indexOf(hash) !== -1) {
30736 for (var _b = 0, _c = this._cacheRequests[hash]; _b < _c.length; _b++) {
30737 var request = _c[_b];
30740 delete this._cacheRequests[hash];
30742 for (var _d = 0, _e = Object.keys(this._reconstructions); _d < _e.length; _d++) {
30744 if (!!keepHashes && keepHashes.indexOf(hash) !== -1) {
30747 delete this._reconstructions[hash];
30749 for (var _f = 0, _g = Object.keys(this._tiles); _f < _g.length; _f++) {
30751 if (!!keepHashes && keepHashes.indexOf(hash) !== -1) {
30754 delete this._tiles[hash];
30757 SpatialDataCache.prototype._createNodeData = function (node) {
30760 cameraProjection: node.cameraProjection,
30763 height: node.height,
30767 lat: node.latLon.lat,
30768 lon: node.latLon.lon,
30769 mergeCC: node.mergeCC,
30770 orientation: node.orientation,
30771 originalLat: node.originalLatLon.lat,
30772 originalLon: node.originalLatLon.lon,
30773 rotation: [node.rotation[0], node.rotation[1], node.rotation[2]],
30778 SpatialDataCache.prototype._getAtomicReconstruction = function (key, requests) {
30779 return rxjs_1.Observable.create(function (subscriber) {
30780 var xmlHTTP = new XMLHttpRequest();
30781 xmlHTTP.open("GET", Utils_1.Urls.atomicReconstruction(key), true);
30782 xmlHTTP.responseType = "json";
30783 xmlHTTP.timeout = 15000;
30784 xmlHTTP.onload = function () {
30785 if (!xmlHTTP.response) {
30786 subscriber.error(new Error("Atomic reconstruction does not exist (" + key + ")"));
30789 subscriber.next(xmlHTTP.response);
30790 subscriber.complete();
30793 xmlHTTP.onerror = function () {
30794 subscriber.error(new Error("Failed to get atomic reconstruction (" + key + ")"));
30796 xmlHTTP.ontimeout = function () {
30797 subscriber.error(new Error("Atomic reconstruction request timed out (" + key + ")"));
30799 xmlHTTP.onabort = function () {
30800 subscriber.error(new Error_1.AbortMapillaryError("Atomic reconstruction request was aborted (" + key + ")"));
30802 requests.push(xmlHTTP);
30803 xmlHTTP.send(null);
30806 return SpatialDataCache;
30808 exports.SpatialDataCache = SpatialDataCache;
30809 exports.default = SpatialDataCache;
30811 },{"../../Error":277,"../../Utils":285,"latlon-geohash":21,"rxjs":27,"rxjs/operators":225}],341:[function(require,module,exports){
30813 var __extends = (this && this.__extends) || (function () {
30814 var extendStatics = function (d, b) {
30815 extendStatics = Object.setPrototypeOf ||
30816 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
30817 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
30818 return extendStatics(d, b);
30820 return function (d, b) {
30821 extendStatics(d, b);
30822 function __() { this.constructor = d; }
30823 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
30826 Object.defineProperty(exports, "__esModule", { value: true });
30827 var geohash = require("latlon-geohash");
30828 var rxjs_1 = require("rxjs");
30829 var operators_1 = require("rxjs/operators");
30830 var Component_1 = require("../../Component");
30831 var Geo_1 = require("../../Geo");
30832 var Render_1 = require("../../Render");
30833 var PlayService_1 = require("../../viewer/PlayService");
30834 var State_1 = require("../../state/State");
30835 var SpatialDataComponent = /** @class */ (function (_super) {
30836 __extends(SpatialDataComponent, _super);
30837 function SpatialDataComponent(name, container, navigator) {
30838 var _this = _super.call(this, name, container, navigator) || this;
30839 _this._cache = new Component_1.SpatialDataCache(navigator.graphService);
30840 _this._scene = new Component_1.SpatialDataScene(_this._getDefaultConfiguration());
30841 _this._viewportCoords = new Geo_1.ViewportCoords();
30842 _this._geoCoords = new Geo_1.GeoCoords();
30845 SpatialDataComponent.prototype._activate = function () {
30847 this._earthControlsSubscription = this._configuration$.pipe(operators_1.map(function (configuration) {
30848 return configuration.earthControls;
30849 }), operators_1.distinctUntilChanged(), operators_1.withLatestFrom(this._navigator.stateService.state$))
30850 .subscribe(function (_a) {
30851 var earth = _a[0], state = _a[1];
30852 if (earth && state !== State_1.default.Earth) {
30853 _this._navigator.stateService.earth();
30855 else if (!earth && state === State_1.default.Earth) {
30856 _this._navigator.stateService.traverse();
30859 var direction$ = this._container.renderService.bearing$.pipe(operators_1.map(function (bearing) {
30860 var direction = "";
30861 if (bearing > 292.5 || bearing <= 67.5) {
30864 if (bearing > 112.5 && bearing <= 247.5) {
30867 if (bearing > 22.5 && bearing <= 157.5) {
30870 if (bearing > 202.5 && bearing <= 337.5) {
30874 }), operators_1.distinctUntilChanged(), operators_1.publishReplay(1), operators_1.refCount());
30875 var hash$ = this._navigator.stateService.reference$.pipe(operators_1.tap(function () {
30876 _this._scene.uncache();
30877 }), operators_1.switchMap(function () {
30878 return _this._navigator.stateService.currentNode$.pipe(operators_1.map(function (node) {
30879 return geohash.encode(node.latLon.lat, node.latLon.lon, 8);
30880 }), operators_1.distinctUntilChanged());
30881 }), operators_1.publishReplay(1), operators_1.refCount());
30882 var sequencePlay$ = rxjs_1.combineLatest(this._navigator.playService.playing$, this._navigator.playService.speed$).pipe(operators_1.map(function (_a) {
30883 var playing = _a[0], speed = _a[1];
30884 return playing && speed > PlayService_1.default.sequenceSpeed;
30885 }), operators_1.distinctUntilChanged(), operators_1.publishReplay(1), operators_1.refCount());
30886 this._addSubscription = rxjs_1.combineLatest(this._navigator.stateService.state$.pipe(operators_1.map(function (state) {
30887 return state === State_1.default.Earth;
30888 }), operators_1.distinctUntilChanged()), hash$, sequencePlay$, direction$).pipe(operators_1.distinctUntilChanged(function (_a, _b) {
30889 var e1 = _a[0], h1 = _a[1], s1 = _a[2], d1 = _a[3];
30890 var e2 = _b[0], h2 = _b[1], s2 = _b[2], d2 = _b[3];
30895 return h1 === h2 && s1 === s2;
30897 return h1 === h2 && s1 === s2 && d1 === d2;
30898 }), operators_1.concatMap(function (_a) {
30899 var earth = _a[0], hash = _a[1], sequencePlay = _a[2], direction = _a[3];
30901 return sequencePlay ?
30902 rxjs_1.of([hash]) :
30903 rxjs_1.of(_this._adjacentComponent(hash, 4));
30905 return sequencePlay ?
30906 rxjs_1.of([hash, geohash.neighbours(hash)[direction]]) :
30907 rxjs_1.of(_this._computeTiles(hash, direction));
30908 }), operators_1.switchMap(function (hashes) {
30909 return rxjs_1.from(hashes).pipe(operators_1.mergeMap(function (h) {
30911 if (_this._cache.hasTile(h)) {
30912 tile$ = rxjs_1.of(_this._cache.getTile(h));
30914 else if (_this._cache.isCachingTile(h)) {
30915 tile$ = _this._cache.cacheTile$(h).pipe(operators_1.last(null, {}), operators_1.switchMap(function () {
30916 return rxjs_1.of(_this._cache.getTile(h));
30920 tile$ = _this._cache.cacheTile$(h);
30922 return rxjs_1.combineLatest(rxjs_1.of(h), tile$);
30923 }, 1), operators_1.map(function (_a) {
30927 }), operators_1.concatMap(function (hash) {
30928 var reconstructions$;
30929 if (_this._cache.hasReconstructions(hash)) {
30930 reconstructions$ = rxjs_1.from(_this._cache.getReconstructions(hash));
30932 else if (_this._cache.isCachingReconstructions(hash)) {
30933 reconstructions$ = _this._cache.cacheReconstructions$(hash).pipe(operators_1.last(null, {}), operators_1.switchMap(function () {
30934 return rxjs_1.from(_this._cache.getReconstructions(hash));
30937 else if (_this._cache.hasTile(hash)) {
30938 reconstructions$ = _this._cache.cacheReconstructions$(hash);
30941 reconstructions$ = rxjs_1.empty();
30943 return rxjs_1.combineLatest(rxjs_1.of(hash), reconstructions$);
30944 }), operators_1.withLatestFrom(this._navigator.stateService.reference$), operators_1.tap(function (_a) {
30945 var hash = _a[0][0], reference = _a[1];
30946 if (_this._scene.hasTile(hash)) {
30949 _this._scene.addTile(_this._computeTileBBox(hash, reference), hash);
30950 }), operators_1.filter(function (_a) {
30951 var _b = _a[0], hash = _b[0], data = _b[1];
30952 return !_this._scene.hasReconstruction(data.reconstruction.main_shot, hash);
30953 }), operators_1.map(function (_a) {
30954 var _b = _a[0], hash = _b[0], data = _b[1], reference = _a[1];
30957 _this._createTransform(data.data, reference),
30958 _this._computeOriginalPosition(data.data, reference),
30962 .subscribe(function (_a) {
30963 var data = _a[0], transform = _a[1], position = _a[2], hash = _a[3];
30964 _this._scene.addReconstruction(data.reconstruction, transform, position, !!data.data.mergeCC ? data.data.mergeCC.toString() : "", hash);
30966 this._cameraVisibilitySubscription = this._configuration$.pipe(operators_1.map(function (configuration) {
30967 return configuration.camerasVisible;
30968 }), operators_1.distinctUntilChanged())
30969 .subscribe(function (visible) {
30970 _this._scene.setCameraVisibility(visible);
30972 this._pointVisibilitySubscription = this._configuration$.pipe(operators_1.map(function (configuration) {
30973 return configuration.pointsVisible;
30974 }), operators_1.distinctUntilChanged())
30975 .subscribe(function (visible) {
30976 _this._scene.setPointVisibility(visible);
30978 this._positionVisibilitySubscription = this._configuration$.pipe(operators_1.map(function (configuration) {
30979 return configuration.positionsVisible;
30980 }), operators_1.distinctUntilChanged())
30981 .subscribe(function (visible) {
30982 _this._scene.setPositionVisibility(visible);
30984 this._tileVisibilitySubscription = this._configuration$.pipe(operators_1.map(function (configuration) {
30985 return configuration.tilesVisible;
30986 }), operators_1.distinctUntilChanged())
30987 .subscribe(function (visible) {
30988 _this._scene.setTileVisibility(visible);
30990 this._visualizeConnectedComponentSubscription = this._configuration$.pipe(operators_1.map(function (configuration) {
30991 return configuration.connectedComponents;
30992 }), operators_1.distinctUntilChanged())
30993 .subscribe(function (visualize) {
30994 _this._scene.setConnectedComponentVisualization(visualize);
30996 this._uncacheSubscription = hash$
30997 .subscribe(function (hash) {
30998 var keepHashes = _this._adjacentComponent(hash, 4);
30999 _this._scene.uncache(keepHashes);
31000 _this._cache.uncache(keepHashes);
31002 this._moveSubscription = this._navigator.playService.playing$.pipe(operators_1.switchMap(function (playing) {
31005 _this._container.mouseService.dblClick$;
31006 }), operators_1.withLatestFrom(this._container.renderService.renderCamera$), operators_1.switchMap(function (_a) {
31007 var event = _a[0], render = _a[1];
31008 var element = _this._container.element;
31009 var _b = _this._viewportCoords.canvasPosition(event, element), canvasX = _b[0], canvasY = _b[1];
31010 var viewport = _this._viewportCoords.canvasToViewport(canvasX, canvasY, element);
31011 var key = _this._scene.intersectObjects(viewport, render.perspective);
31013 _this._navigator.moveToKey$(key).pipe(operators_1.catchError(function () {
31014 return rxjs_1.empty();
31019 this._renderSubscription = this._navigator.stateService.currentState$.pipe(operators_1.map(function (frame) {
31020 var scene = _this._scene;
31025 needsRender: scene.needsRender,
31026 render: scene.render.bind(scene),
31027 stage: Render_1.GLRenderStage.Foreground,
31031 .subscribe(this._container.glRenderer.render$);
31033 SpatialDataComponent.prototype._deactivate = function () {
31035 this._cache.uncache();
31036 this._scene.uncache();
31037 this._addSubscription.unsubscribe();
31038 this._cameraVisibilitySubscription.unsubscribe();
31039 this._earthControlsSubscription.unsubscribe();
31040 this._moveSubscription.unsubscribe();
31041 this._pointVisibilitySubscription.unsubscribe();
31042 this._positionVisibilitySubscription.unsubscribe();
31043 this._renderSubscription.unsubscribe();
31044 this._tileVisibilitySubscription.unsubscribe();
31045 this._uncacheSubscription.unsubscribe();
31046 this._visualizeConnectedComponentSubscription.unsubscribe();
31047 this._navigator.stateService.state$.pipe(operators_1.first())
31048 .subscribe(function (state) {
31049 if (state === State_1.default.Earth) {
31050 _this._navigator.stateService.traverse();
31054 SpatialDataComponent.prototype._getDefaultConfiguration = function () {
31055 return { camerasVisible: false, pointsVisible: true, positionsVisible: false, tilesVisible: false };
31057 SpatialDataComponent.prototype._adjacentComponent = function (hash, depth) {
31058 var hashSet = new Set();
31060 this._adjacentComponentRecursive(hashSet, [hash], 0, depth);
31061 return this._setToArray(hashSet);
31063 SpatialDataComponent.prototype._adjacentComponentRecursive = function (hashSet, currentHashes, currentDepth, maxDepth) {
31064 if (currentDepth === maxDepth) {
31067 var neighbours = [];
31068 for (var _i = 0, currentHashes_1 = currentHashes; _i < currentHashes_1.length; _i++) {
31069 var hash = currentHashes_1[_i];
31070 var hashNeighbours = geohash.neighbours(hash);
31071 for (var direction in hashNeighbours) {
31072 if (!hashNeighbours.hasOwnProperty(direction)) {
31075 neighbours.push(hashNeighbours[direction]);
31078 var newHashes = [];
31079 for (var _a = 0, neighbours_1 = neighbours; _a < neighbours_1.length; _a++) {
31080 var neighbour = neighbours_1[_a];
31081 if (!hashSet.has(neighbour)) {
31082 hashSet.add(neighbour);
31083 newHashes.push(neighbour);
31086 this._adjacentComponentRecursive(hashSet, newHashes, currentDepth + 1, maxDepth);
31088 SpatialDataComponent.prototype._computeOriginalPosition = function (data, reference) {
31089 return this._geoCoords.geodeticToEnu(data.originalLat, data.originalLon, data.alt, reference.lat, reference.lon, reference.alt);
31091 SpatialDataComponent.prototype._computeTileBBox = function (hash, reference) {
31092 var bounds = geohash.bounds(hash);
31093 var sw = this._geoCoords.geodeticToEnu(bounds.sw.lat, bounds.sw.lon, 0, reference.lat, reference.lon, reference.alt);
31094 var ne = this._geoCoords.geodeticToEnu(bounds.ne.lat, bounds.ne.lon, 0, reference.lat, reference.lon, reference.alt);
31097 SpatialDataComponent.prototype._createTransform = function (data, reference) {
31098 var translation = Geo_1.Geo.computeTranslation({ alt: data.alt, lat: data.lat, lon: data.lon }, data.rotation, reference);
31099 var transform = new Geo_1.Transform(data.orientation, data.width, data.height, data.focal, data.scale, data.gpano, data.rotation, translation, undefined, undefined, data.k1, data.k2, data.cameraProjection);
31102 SpatialDataComponent.prototype._computeTiles = function (hash, direction) {
31103 var hashSet = new Set();
31104 var directions = ["n", "ne", "e", "se", "s", "sw", "w", "nw"];
31105 this._computeTilesRecursive(hashSet, hash, direction, directions, 0, 2);
31106 return this._setToArray(hashSet);
31108 SpatialDataComponent.prototype._computeTilesRecursive = function (hashSet, currentHash, direction, directions, currentDepth, maxDepth) {
31109 hashSet.add(currentHash);
31110 if (currentDepth === maxDepth) {
31113 var neighbours = geohash.neighbours(currentHash);
31114 var directionIndex = directions.indexOf(direction);
31115 var length = directions.length;
31116 var directionNeighbours = [
31117 neighbours[directions[this._modulo((directionIndex - 1), length)]],
31118 neighbours[direction],
31119 neighbours[directions[this._modulo((directionIndex + 1), length)]],
31121 for (var _i = 0, directionNeighbours_1 = directionNeighbours; _i < directionNeighbours_1.length; _i++) {
31122 var directionNeighbour = directionNeighbours_1[_i];
31123 this._computeTilesRecursive(hashSet, directionNeighbour, direction, directions, currentDepth + 1, maxDepth);
31126 SpatialDataComponent.prototype._modulo = function (a, n) {
31127 return ((a % n) + n) % n;
31129 SpatialDataComponent.prototype._setToArray = function (s) {
31131 s.forEach(function (value) {
31136 SpatialDataComponent.componentName = "spatialData";
31137 return SpatialDataComponent;
31138 }(Component_1.Component));
31139 exports.SpatialDataComponent = SpatialDataComponent;
31140 Component_1.ComponentService.register(SpatialDataComponent);
31141 exports.default = SpatialDataComponent;
31143 },{"../../Component":275,"../../Geo":278,"../../Render":281,"../../state/State":412,"../../viewer/PlayService":441,"latlon-geohash":21,"rxjs":27,"rxjs/operators":225}],342:[function(require,module,exports){
31145 Object.defineProperty(exports, "__esModule", { value: true });
31146 var THREE = require("three");
31147 var SpatialDataScene = /** @class */ (function () {
31148 function SpatialDataScene(configuration, scene, raycaster) {
31149 this._scene = !!scene ? scene : new THREE.Scene();
31150 this._raycaster = !!raycaster ? raycaster : new THREE.Raycaster(undefined, undefined, 0.8);
31151 this._connectedComponentColors = {};
31152 this._needsRender = false;
31153 this._interactiveObjects = [];
31154 this._reconstructions = {};
31156 this._camerasVisible = configuration.camerasVisible;
31157 this._pointsVisible = configuration.pointsVisible;
31158 this._positionsVisible = configuration.positionsVisible;
31159 this._tilesVisible = configuration.tilesVisible;
31160 this._visualizeConnectedComponents = configuration.connectedComponents;
31162 Object.defineProperty(SpatialDataScene.prototype, "needsRender", {
31164 return this._needsRender;
31169 SpatialDataScene.prototype.addReconstruction = function (reconstruction, transform, originalPosition, connectedComponent, hash) {
31170 if (!(hash in this._reconstructions)) {
31171 this._reconstructions[hash] = {
31173 cameras: new THREE.Object3D(),
31174 connectedComponents: {},
31176 points: new THREE.Object3D(),
31177 positions: new THREE.Object3D(),
31179 this._reconstructions[hash].cameras.visible = this._camerasVisible;
31180 this._reconstructions[hash].points.visible = this._pointsVisible;
31181 this._reconstructions[hash].positions.visible = this._positionsVisible;
31182 this._scene.add(this._reconstructions[hash].cameras, this._reconstructions[hash].points, this._reconstructions[hash].positions);
31184 if (!(connectedComponent in this._reconstructions[hash].connectedComponents)) {
31185 this._reconstructions[hash].connectedComponents[connectedComponent] = [];
31187 if (transform.hasValidScale) {
31188 this._reconstructions[hash].points.add(this._createPoints(reconstruction, transform));
31190 var camera = this._createCamera(transform);
31191 this._reconstructions[hash].cameras.add(camera);
31192 for (var _i = 0, _a = camera.children; _i < _a.length; _i++) {
31193 var child = _a[_i];
31194 this._reconstructions[hash].cameraKeys[child.uuid] = reconstruction.main_shot;
31195 this._interactiveObjects.push(child);
31197 this._reconstructions[hash].connectedComponents[connectedComponent].push(camera);
31198 var color = this._getColor(connectedComponent, this._visualizeConnectedComponents);
31199 this._setCameraColor(color, camera);
31200 this._reconstructions[hash].positions.add(this._createPosition(transform, originalPosition));
31201 this._reconstructions[hash].keys.push(reconstruction.main_shot);
31202 this._needsRender = true;
31204 SpatialDataScene.prototype.addTile = function (tileBBox, hash) {
31205 if (this.hasTile(hash)) {
31208 var sw = tileBBox[0];
31209 var ne = tileBBox[1];
31210 var geometry = new THREE.Geometry();
31211 geometry.vertices.push(new THREE.Vector3().fromArray(sw), new THREE.Vector3(sw[0], ne[1], (sw[2] + ne[2]) / 2), new THREE.Vector3().fromArray(ne), new THREE.Vector3(ne[0], sw[1], (sw[2] + ne[2]) / 2), new THREE.Vector3().fromArray(sw));
31212 var tile = new THREE.Line(geometry, new THREE.LineBasicMaterial());
31213 this._tiles[hash] = new THREE.Object3D();
31214 this._tiles[hash].visible = this._tilesVisible;
31215 this._tiles[hash].add(tile);
31216 this._scene.add(this._tiles[hash]);
31217 this._needsRender = true;
31219 SpatialDataScene.prototype.uncache = function (keepHashes) {
31220 for (var _i = 0, _a = Object.keys(this._reconstructions); _i < _a.length; _i++) {
31222 if (!!keepHashes && keepHashes.indexOf(hash) !== -1) {
31225 this._disposeReconstruction(hash);
31227 for (var _b = 0, _c = Object.keys(this._tiles); _b < _c.length; _b++) {
31229 if (!!keepHashes && keepHashes.indexOf(hash) !== -1) {
31232 this._disposeTile(hash);
31234 this._needsRender = true;
31236 SpatialDataScene.prototype.hasReconstruction = function (key, hash) {
31237 return hash in this._reconstructions && this._reconstructions[hash].keys.indexOf(key) !== -1;
31239 SpatialDataScene.prototype.hasTile = function (hash) {
31240 return hash in this._tiles;
31242 SpatialDataScene.prototype.intersectObjects = function (_a, camera) {
31243 var viewportX = _a[0], viewportY = _a[1];
31244 if (!this._camerasVisible) {
31247 this._raycaster.setFromCamera(new THREE.Vector2(viewportX, viewportY), camera);
31248 var intersects = this._raycaster.intersectObjects(this._interactiveObjects);
31249 for (var _i = 0, intersects_1 = intersects; _i < intersects_1.length; _i++) {
31250 var intersect = intersects_1[_i];
31251 for (var hash in this._reconstructions) {
31252 if (!this._reconstructions.hasOwnProperty(hash)) {
31255 if (intersect.object.uuid in this._reconstructions[hash].cameraKeys) {
31256 return this._reconstructions[hash].cameraKeys[intersect.object.uuid];
31262 SpatialDataScene.prototype.setCameraVisibility = function (visible) {
31263 if (visible === this._camerasVisible) {
31266 for (var hash in this._reconstructions) {
31267 if (!this._reconstructions.hasOwnProperty(hash)) {
31270 this._reconstructions[hash].cameras.visible = visible;
31272 this._camerasVisible = visible;
31273 this._needsRender = true;
31275 SpatialDataScene.prototype.setPointVisibility = function (visible) {
31276 if (visible === this._pointsVisible) {
31279 for (var hash in this._reconstructions) {
31280 if (!this._reconstructions.hasOwnProperty(hash)) {
31283 this._reconstructions[hash].points.visible = visible;
31285 this._pointsVisible = visible;
31286 this._needsRender = true;
31288 SpatialDataScene.prototype.setPositionVisibility = function (visible) {
31289 if (visible === this._positionsVisible) {
31292 for (var hash in this._reconstructions) {
31293 if (!this._reconstructions.hasOwnProperty(hash)) {
31296 this._reconstructions[hash].positions.visible = visible;
31298 this._positionsVisible = visible;
31299 this._needsRender = true;
31301 SpatialDataScene.prototype.setTileVisibility = function (visible) {
31302 if (visible === this._tilesVisible) {
31305 for (var hash in this._tiles) {
31306 if (!this._tiles.hasOwnProperty(hash)) {
31309 this._tiles[hash].visible = visible;
31311 this._tilesVisible = visible;
31312 this._needsRender = true;
31314 SpatialDataScene.prototype.setConnectedComponentVisualization = function (visualize) {
31315 if (visualize === this._visualizeConnectedComponents) {
31318 for (var hash in this._reconstructions) {
31319 if (!this._reconstructions.hasOwnProperty(hash)) {
31322 var connectedComponents = this._reconstructions[hash].connectedComponents;
31323 for (var connectedComponent in connectedComponents) {
31324 if (!connectedComponents.hasOwnProperty(connectedComponent)) {
31327 var color = this._getColor(connectedComponent, visualize);
31328 for (var _i = 0, _a = connectedComponents[connectedComponent]; _i < _a.length; _i++) {
31329 var camera = _a[_i];
31330 this._setCameraColor(color, camera);
31334 this._visualizeConnectedComponents = visualize;
31335 this._needsRender = true;
31337 SpatialDataScene.prototype.render = function (perspectiveCamera, renderer) {
31338 renderer.render(this._scene, perspectiveCamera);
31339 this._needsRender = false;
31341 SpatialDataScene.prototype._arrayToFloatArray = function (a, columns) {
31343 var f = new Float32Array(n * columns);
31344 for (var i = 0; i < n; i++) {
31347 f[index + 0] = item[0];
31348 f[index + 1] = item[1];
31349 f[index + 2] = item[2];
31353 SpatialDataScene.prototype._createAxis = function (transform) {
31354 var north = transform.unprojectBasic([0.5, 0], 0.22);
31355 var south = transform.unprojectBasic([0.5, 1], 0.16);
31356 var axis = new THREE.BufferGeometry();
31357 axis.addAttribute("position", new THREE.BufferAttribute(this._arrayToFloatArray([north, south], 3), 3));
31358 return new THREE.Line(axis, new THREE.LineBasicMaterial());
31360 SpatialDataScene.prototype._createCamera = function (transform) {
31361 return !!transform.gpano ?
31362 this._createPanoCamera(transform) :
31363 this._createPrespectiveCamera(transform);
31365 SpatialDataScene.prototype._createDiagonals = function (transform, depth) {
31366 var origin = transform.unprojectBasic([0, 0], 0, true);
31367 var topLeft = transform.unprojectBasic([0, 0], depth, true);
31368 var topRight = transform.unprojectBasic([1, 0], depth, true);
31369 var bottomRight = transform.unprojectBasic([1, 1], depth, true);
31370 var bottomLeft = transform.unprojectBasic([0, 1], depth, true);
31374 origin, bottomRight,
31375 origin, bottomLeft,
31377 var diagonals = new THREE.BufferGeometry();
31378 diagonals.addAttribute("position", new THREE.BufferAttribute(this._arrayToFloatArray(vertices, 3), 3));
31379 return new THREE.LineSegments(diagonals, new THREE.LineBasicMaterial());
31381 SpatialDataScene.prototype._createFrame = function (transform, depth) {
31382 var vertices2d = [];
31383 vertices2d.push.apply(vertices2d, this._subsample([0, 1], [0, 0], 20));
31384 vertices2d.push.apply(vertices2d, this._subsample([0, 0], [1, 0], 20));
31385 vertices2d.push.apply(vertices2d, this._subsample([1, 0], [1, 1], 20));
31386 var vertices3d = vertices2d
31387 .map(function (basic) {
31388 return transform.unprojectBasic(basic, depth, true);
31390 var frame = new THREE.BufferGeometry();
31391 frame.addAttribute("position", new THREE.BufferAttribute(this._arrayToFloatArray(vertices3d, 3), 3));
31392 return new THREE.Line(frame, new THREE.LineBasicMaterial());
31394 SpatialDataScene.prototype._createLatitude = function (basicY, numVertices, transform) {
31395 var positions = new Float32Array((numVertices + 1) * 3);
31396 for (var i = 0; i <= numVertices; i++) {
31397 var position = transform.unprojectBasic([i / numVertices, basicY], 0.16);
31399 positions[index + 0] = position[0];
31400 positions[index + 1] = position[1];
31401 positions[index + 2] = position[2];
31403 var latitude = new THREE.BufferGeometry();
31404 latitude.addAttribute("position", new THREE.BufferAttribute(positions, 3));
31405 return new THREE.Line(latitude, new THREE.LineBasicMaterial());
31407 SpatialDataScene.prototype._createLongitude = function (basicX, numVertices, transform) {
31408 var positions = new Float32Array((numVertices + 1) * 3);
31409 for (var i = 0; i <= numVertices; i++) {
31410 var position = transform.unprojectBasic([basicX, i / numVertices], 0.16);
31412 positions[index + 0] = position[0];
31413 positions[index + 1] = position[1];
31414 positions[index + 2] = position[2];
31416 var latitude = new THREE.BufferGeometry();
31417 latitude.addAttribute("position", new THREE.BufferAttribute(positions, 3));
31418 return new THREE.Line(latitude, new THREE.LineBasicMaterial());
31420 SpatialDataScene.prototype._createPanoCamera = function (transform) {
31421 var camera = new THREE.Object3D();
31422 camera.children.push(this._createAxis(transform));
31423 camera.children.push(this._createLatitude(0.5, 10, transform));
31424 camera.children.push(this._createLongitude(0, 6, transform));
31425 camera.children.push(this._createLongitude(0.25, 6, transform));
31426 camera.children.push(this._createLongitude(0.5, 6, transform));
31427 camera.children.push(this._createLongitude(0.75, 6, transform));
31430 SpatialDataScene.prototype._createPoints = function (reconstruction, transform) {
31431 var srtInverse = new THREE.Matrix4().getInverse(transform.srt);
31432 var points = Object
31433 .keys(reconstruction.points)
31434 .map(function (key) {
31435 return reconstruction.points[key];
31437 var numPoints = points.length;
31438 var positions = new Float32Array(numPoints * 3);
31439 var colors = new Float32Array(numPoints * 3);
31440 for (var i = 0; i < numPoints; i++) {
31442 var coords = points[i].coordinates;
31443 var point = new THREE.Vector3(coords[0], coords[1], coords[2])
31444 .applyMatrix4(srtInverse);
31445 positions[index + 0] = point.x;
31446 positions[index + 1] = point.y;
31447 positions[index + 2] = point.z;
31448 var color = points[i].color;
31449 colors[index + 0] = color[0] / 255.0;
31450 colors[index + 1] = color[1] / 255.0;
31451 colors[index + 2] = color[2] / 255.0;
31453 var geometry = new THREE.BufferGeometry();
31454 geometry.addAttribute("position", new THREE.BufferAttribute(positions, 3));
31455 geometry.addAttribute("color", new THREE.BufferAttribute(colors, 3));
31456 var material = new THREE.PointsMaterial({
31458 vertexColors: THREE.VertexColors,
31460 return new THREE.Points(geometry, material);
31462 SpatialDataScene.prototype._createPosition = function (transform, originalPosition) {
31463 var computedPosition = transform.unprojectBasic([0, 0], 0);
31464 var vertices = [originalPosition, computedPosition];
31465 var geometry = new THREE.BufferGeometry();
31466 geometry.addAttribute("position", new THREE.BufferAttribute(this._arrayToFloatArray(vertices, 3), 3));
31467 return new THREE.Line(geometry, new THREE.LineBasicMaterial({ color: new THREE.Color(1, 0, 0) }));
31469 SpatialDataScene.prototype._createPrespectiveCamera = function (transform) {
31471 var camera = new THREE.Object3D();
31472 camera.children.push(this._createDiagonals(transform, depth));
31473 camera.children.push(this._createFrame(transform, depth));
31476 SpatialDataScene.prototype._disposeCameras = function (hash) {
31477 var tileCameras = this._reconstructions[hash].cameras;
31478 for (var _i = 0, _a = tileCameras.children.slice(); _i < _a.length; _i++) {
31479 var camera = _a[_i];
31480 for (var _b = 0, _c = camera.children; _b < _c.length; _b++) {
31481 var child = _c[_b];
31482 child.geometry.dispose();
31483 child.material.dispose();
31484 var index = this._interactiveObjects.indexOf(child);
31485 if (index !== -1) {
31486 this._interactiveObjects.splice(index, 1);
31489 console.warn("Object does not exist (" + child.id + ") for " + hash);
31492 tileCameras.remove(camera);
31494 this._scene.remove(tileCameras);
31496 SpatialDataScene.prototype._disposePoints = function (hash) {
31497 var tilePoints = this._reconstructions[hash].points;
31498 for (var _i = 0, _a = tilePoints.children.slice(); _i < _a.length; _i++) {
31499 var points = _a[_i];
31500 points.geometry.dispose();
31501 points.material.dispose();
31502 tilePoints.remove(points);
31504 this._scene.remove(tilePoints);
31506 SpatialDataScene.prototype._disposePositions = function (hash) {
31507 var tilePositions = this._reconstructions[hash].positions;
31508 for (var _i = 0, _a = tilePositions.children.slice(); _i < _a.length; _i++) {
31509 var position = _a[_i];
31510 position.geometry.dispose();
31511 position.material.dispose();
31512 tilePositions.remove(position);
31514 this._scene.remove(tilePositions);
31516 SpatialDataScene.prototype._disposeReconstruction = function (hash) {
31517 this._disposeCameras(hash);
31518 this._disposePoints(hash);
31519 this._disposePositions(hash);
31520 delete this._reconstructions[hash];
31522 SpatialDataScene.prototype._disposeTile = function (hash) {
31523 var tile = this._tiles[hash];
31524 for (var _i = 0, _a = tile.children.slice(); _i < _a.length; _i++) {
31526 line.geometry.dispose();
31527 line.material.dispose();
31530 this._scene.remove(tile);
31531 delete this._tiles[hash];
31533 SpatialDataScene.prototype._getColor = function (connectedComponent, visualizeConnectedComponents) {
31534 return visualizeConnectedComponents ?
31535 this._getConnectedComponentColor(connectedComponent) :
31538 SpatialDataScene.prototype._getConnectedComponentColor = function (connectedComponent) {
31539 if (!(connectedComponent in this._connectedComponentColors)) {
31540 this._connectedComponentColors[connectedComponent] = this._randomColor();
31542 return this._connectedComponentColors[connectedComponent];
31544 SpatialDataScene.prototype._interpolate = function (a, b, alpha) {
31545 return a + alpha * (b - a);
31547 SpatialDataScene.prototype._randomColor = function () {
31548 return "hsl(" + Math.floor(360 * Math.random()) + ", 100%, 65%)";
31550 SpatialDataScene.prototype._setCameraColor = function (color, camera) {
31551 for (var _i = 0, _a = camera.children; _i < _a.length; _i++) {
31552 var child = _a[_i];
31553 child.material.color = new THREE.Color(color);
31556 SpatialDataScene.prototype._subsample = function (p1, p2, subsamples) {
31557 if (subsamples < 1) {
31561 for (var i = 0; i <= subsamples + 1; i++) {
31563 for (var j = 0; j < 3; j++) {
31564 p.push(this._interpolate(p1[j], p2[j], i / (subsamples + 1)));
31570 return SpatialDataScene;
31572 exports.SpatialDataScene = SpatialDataScene;
31573 exports.default = SpatialDataScene;
31575 },{"three":226}],343:[function(require,module,exports){
31577 Object.defineProperty(exports, "__esModule", { value: true });
31578 var GeometryTagError_1 = require("./error/GeometryTagError");
31579 exports.GeometryTagError = GeometryTagError_1.GeometryTagError;
31580 var PointGeometry_1 = require("./geometry/PointGeometry");
31581 exports.PointGeometry = PointGeometry_1.PointGeometry;
31582 var RectGeometry_1 = require("./geometry/RectGeometry");
31583 exports.RectGeometry = RectGeometry_1.RectGeometry;
31584 var PolygonGeometry_1 = require("./geometry/PolygonGeometry");
31585 exports.PolygonGeometry = PolygonGeometry_1.PolygonGeometry;
31586 var OutlineTag_1 = require("./tag/OutlineTag");
31587 exports.OutlineTag = OutlineTag_1.OutlineTag;
31588 var SpotTag_1 = require("./tag/SpotTag");
31589 exports.SpotTag = SpotTag_1.SpotTag;
31590 var TagDomain_1 = require("./tag/TagDomain");
31591 exports.TagDomain = TagDomain_1.TagDomain;
31592 var TagComponent_1 = require("./TagComponent");
31593 exports.TagComponent = TagComponent_1.TagComponent;
31594 var TagMode_1 = require("./TagMode");
31595 exports.TagMode = TagMode_1.TagMode;
31597 },{"./TagComponent":344,"./TagMode":347,"./error/GeometryTagError":351,"./geometry/PointGeometry":353,"./geometry/PolygonGeometry":354,"./geometry/RectGeometry":355,"./tag/OutlineTag":367,"./tag/SpotTag":370,"./tag/TagDomain":372}],344:[function(require,module,exports){
31599 var __extends = (this && this.__extends) || (function () {
31600 var extendStatics = function (d, b) {
31601 extendStatics = Object.setPrototypeOf ||
31602 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
31603 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
31604 return extendStatics(d, b);
31606 return function (d, b) {
31607 extendStatics(d, b);
31608 function __() { this.constructor = d; }
31609 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
31612 Object.defineProperty(exports, "__esModule", { value: true });
31613 var rxjs_1 = require("rxjs");
31614 var operators_1 = require("rxjs/operators");
31615 var when = require("when");
31616 var Component_1 = require("../../Component");
31617 var Geo_1 = require("../../Geo");
31618 var Render_1 = require("../../Render");
31620 * @class TagComponent
31622 * @classdesc Component for showing and editing tags with different
31623 * geometries composed from 2D basic image coordinates (see the
31624 * {@link Viewer} class documentation for more information about coordinate
31627 * The `add` method is used for adding new tags or replacing
31628 * tags already in the set. Tags are removed by id.
31630 * If a tag already in the set has the same
31631 * id as one of the tags added, the old tag will be removed and
31632 * the added tag will take its place.
31634 * The tag component mode can be set to either be non interactive or
31635 * to be in creating mode of a certain geometry type.
31637 * The tag properties can be updated at any time and the change will
31638 * be visibile immediately.
31640 * Tags are only relevant to a single image because they are based on
31641 * 2D basic image coordinates. Tags related to a certain image should
31642 * be removed when the viewer is moved to another node.
31644 * To retrive and use the tag component
31648 * var viewer = new Mapillary.Viewer(
31652 * { component: { tag: true } });
31654 * var tagComponent = viewer.getComponent("tag");
31657 var TagComponent = /** @class */ (function (_super) {
31658 __extends(TagComponent, _super);
31660 function TagComponent(name, container, navigator) {
31661 var _this = _super.call(this, name, container, navigator) || this;
31662 _this._tagDomRenderer = new Component_1.TagDOMRenderer();
31663 _this._tagScene = new Component_1.TagScene();
31664 _this._tagSet = new Component_1.TagSet();
31665 _this._tagCreator = new Component_1.TagCreator(_this, navigator);
31666 _this._viewportCoords = new Geo_1.ViewportCoords();
31667 _this._createHandlers = {
31668 "CreatePoint": new Component_1.CreatePointHandler(_this, container, navigator, _this._viewportCoords, _this._tagCreator),
31669 "CreatePolygon": new Component_1.CreatePolygonHandler(_this, container, navigator, _this._viewportCoords, _this._tagCreator),
31670 "CreateRect": new Component_1.CreateRectHandler(_this, container, navigator, _this._viewportCoords, _this._tagCreator),
31671 "CreateRectDrag": new Component_1.CreateRectDragHandler(_this, container, navigator, _this._viewportCoords, _this._tagCreator),
31672 "Default": undefined,
31674 _this._editVertexHandler = new Component_1.EditVertexHandler(_this, container, navigator, _this._viewportCoords, _this._tagSet);
31675 _this._renderTags$ = _this._tagSet.changed$.pipe(operators_1.map(function (tagSet) {
31676 var tags = tagSet.getAll();
31677 // ensure that tags are always rendered in the same order
31678 // to avoid hover tracking problems on first resize.
31679 tags.sort(function (t1, t2) {
31680 var id1 = t1.tag.id;
31681 var id2 = t2.tag.id;
31691 }), operators_1.share());
31692 _this._tagChanged$ = _this._renderTags$.pipe(operators_1.switchMap(function (tags) {
31693 return rxjs_1.from(tags).pipe(operators_1.mergeMap(function (tag) {
31694 return rxjs_1.merge(tag.tag.changed$, tag.tag.geometryChanged$);
31696 }), operators_1.share());
31697 _this._renderTagGLChanged$ = _this._renderTags$.pipe(operators_1.switchMap(function (tags) {
31698 return rxjs_1.from(tags).pipe(operators_1.mergeMap(function (tag) {
31699 return tag.glObjectsChanged$;
31701 }), operators_1.share());
31702 _this._createGeometryChanged$ = _this._tagCreator.tag$.pipe(operators_1.switchMap(function (tag) {
31703 return tag != null ?
31704 tag.geometryChanged$ :
31706 }), operators_1.share());
31707 _this._createGLObjectsChanged$ = _this._tagCreator.tag$.pipe(operators_1.switchMap(function (tag) {
31708 return tag != null ?
31709 tag.glObjectsChanged$ :
31711 }), operators_1.share());
31712 _this._creatingConfiguration$ = _this._configuration$.pipe(operators_1.distinctUntilChanged(function (c1, c2) {
31713 return c1.mode === c2.mode;
31714 }, function (configuration) {
31716 createColor: configuration.createColor,
31717 mode: configuration.mode,
31719 }), operators_1.publishReplay(1), operators_1.refCount());
31720 _this._creatingConfiguration$
31721 .subscribe(function (configuration) {
31722 _this.fire(TagComponent.modechanged, configuration.mode);
31727 * Add tags to the tag set or replace tags in the tag set.
31729 * @description If a tag already in the set has the same
31730 * id as one of the tags added, the old tag will be removed
31731 * the added tag will take its place.
31733 * @param {Array<Tag>} tags - Tags to add.
31735 * @example ```tagComponent.add([tag1, tag2]);```
31737 TagComponent.prototype.add = function (tags) {
31739 if (this._activated) {
31740 this._navigator.stateService.currentTransform$.pipe(operators_1.first())
31741 .subscribe(function (transform) {
31742 _this._tagSet.add(tags, transform);
31743 var renderTags = tags
31744 .map(function (tag) {
31745 return _this._tagSet.get(tag.id);
31747 _this._tagScene.add(renderTags);
31751 this._tagSet.addDeactivated(tags);
31755 * Change the current tag mode.
31757 * @description Change the tag mode to one of the create modes for creating new geometries.
31759 * @param {TagMode} mode - New tag mode.
31761 * @fires TagComponent#modechanged
31763 * @example ```tagComponent.changeMode(Mapillary.TagComponent.TagMode.CreateRect);```
31765 TagComponent.prototype.changeMode = function (mode) {
31766 this.configure({ mode: mode });
31769 * Returns the tag in the tag set with the specified id, or
31770 * undefined if the id matches no tag.
31772 * @param {string} tagId - Id of the tag.
31774 * @example ```var tag = tagComponent.get("tagId");```
31776 TagComponent.prototype.get = function (tagId) {
31777 if (this._activated) {
31778 var renderTag = this._tagSet.get(tagId);
31779 return renderTag !== undefined ? renderTag.tag : undefined;
31782 return this._tagSet.getDeactivated(tagId);
31786 * Returns an array of all tags.
31788 * @example ```var tags = tagComponent.getAll();```
31790 TagComponent.prototype.getAll = function () {
31791 if (this.activated) {
31792 return this._tagSet
31794 .map(function (renderTag) {
31795 return renderTag.tag;
31799 return this._tagSet.getAllDeactivated();
31803 * Returns an array of tag ids for tags that contain the specified point.
31805 * @description The pixel point must lie inside the polygon or rectangle
31806 * of an added tag for the tag id to be returned. Tag ids for
31807 * tags that do not have a fill will also be returned if the point is inside
31808 * the geometry of the tag. Tags with point geometries can not be retrieved.
31810 * No tag ids will be returned for panoramas.
31812 * Notice that the pixelPoint argument requires x, y coordinates from pixel space.
31814 * With this function, you can use the coordinates provided by mouse
31815 * events to get information out of the tag component.
31817 * If no tag at exist the pixel point, an empty array will be returned.
31819 * @param {Array<number>} pixelPoint - Pixel coordinates on the viewer element.
31820 * @returns {Array<string>} Ids of the tags that contain the specified pixel point.
31824 * tagComponent.getTagIdsAt([100, 100])
31825 * .then((tagIds) => { console.log(tagIds); });
31828 TagComponent.prototype.getTagIdsAt = function (pixelPoint) {
31830 return when.promise(function (resolve, reject) {
31831 _this._container.renderService.renderCamera$.pipe(operators_1.first(), operators_1.map(function (render) {
31832 var viewport = _this._viewportCoords
31833 .canvasToViewport(pixelPoint[0], pixelPoint[1], _this._container.element);
31834 var ids = _this._tagScene.intersectObjects(viewport, render.perspective);
31837 .subscribe(function (ids) {
31839 }, function (error) {
31845 * Check if a tag exist in the tag set.
31847 * @param {string} tagId - Id of the tag.
31849 * @example ```var tagExists = tagComponent.has("tagId");```
31851 TagComponent.prototype.has = function (tagId) {
31852 return this._activated ? this._tagSet.has(tagId) : this._tagSet.hasDeactivated(tagId);
31855 * Remove tags with the specified ids from the tag set.
31857 * @param {Array<string>} tagIds - Ids for tags to remove.
31859 * @example ```tagComponent.remove(["id-1", "id-2"]);```
31861 TagComponent.prototype.remove = function (tagIds) {
31862 if (this._activated) {
31863 this._tagSet.remove(tagIds);
31864 this._tagScene.remove(tagIds);
31867 this._tagSet.removeDeactivated(tagIds);
31871 * Remove all tags from the tag set.
31873 * @example ```tagComponent.removeAll();```
31875 TagComponent.prototype.removeAll = function () {
31876 if (this._activated) {
31877 this._tagSet.removeAll();
31878 this._tagScene.removeAll();
31881 this._tagSet.removeAllDeactivated();
31884 TagComponent.prototype._activate = function () {
31886 this._editVertexHandler.enable();
31887 var handlerGeometryCreated$ = rxjs_1.from(Object.keys(this._createHandlers)).pipe(operators_1.map(function (key) {
31888 return _this._createHandlers[key];
31889 }), operators_1.filter(function (handler) {
31891 }), operators_1.mergeMap(function (handler) {
31892 return handler.geometryCreated$;
31893 }), operators_1.share());
31894 this._fireGeometryCreatedSubscription = handlerGeometryCreated$
31895 .subscribe(function (geometry) {
31896 _this.fire(TagComponent.geometrycreated, geometry);
31898 this._fireCreateGeometryEventSubscription = this._tagCreator.tag$.pipe(operators_1.skipWhile(function (tag) {
31899 return tag == null;
31900 }), operators_1.distinctUntilChanged())
31901 .subscribe(function (tag) {
31902 var eventType = tag != null ?
31903 TagComponent.creategeometrystart :
31904 TagComponent.creategeometryend;
31905 _this.fire(eventType, _this);
31907 this._handlerStopCreateSubscription = handlerGeometryCreated$
31908 .subscribe(function () {
31909 _this.changeMode(Component_1.TagMode.Default);
31911 this._handlerEnablerSubscription = this._creatingConfiguration$
31912 .subscribe(function (configuration) {
31913 _this._disableCreateHandlers();
31914 var mode = Component_1.TagMode[configuration.mode];
31915 var handler = _this._createHandlers[mode];
31920 this._fireTagsChangedSubscription = this._renderTags$
31921 .subscribe(function (tags) {
31922 _this.fire(TagComponent.tagschanged, _this);
31924 this._stopCreateSubscription = this._tagCreator.tag$.pipe(operators_1.switchMap(function (tag) {
31925 return tag != null ?
31926 tag.aborted$.pipe(operators_1.map(function (t) { return null; })) :
31929 .subscribe(function () { _this.changeMode(Component_1.TagMode.Default); });
31930 this._setGLCreateTagSubscription = this._tagCreator.tag$
31931 .subscribe(function (tag) {
31932 if (_this._tagScene.hasCreateTag()) {
31933 _this._tagScene.removeCreateTag();
31936 _this._tagScene.addCreateTag(tag);
31939 this._createGLObjectsChangedSubscription = this._createGLObjectsChanged$
31940 .subscribe(function (tag) {
31941 _this._tagScene.updateCreateTagObjects(tag);
31943 this._updateGLObjectsSubscription = this._renderTagGLChanged$
31944 .subscribe(function (tag) {
31945 _this._tagScene.updateObjects(tag);
31947 this._updateTagSceneSubscription = this._tagChanged$
31948 .subscribe(function (tag) {
31949 _this._tagScene.update();
31951 this._domSubscription = rxjs_1.combineLatest(this._renderTags$.pipe(operators_1.startWith([]), operators_1.tap(function (tags) {
31952 _this._container.domRenderer.render$.next({
31954 vnode: _this._tagDomRenderer.clear(),
31956 })), this._container.renderService.renderCamera$, this._container.spriteService.spriteAtlas$, this._container.renderService.size$, this._tagChanged$.pipe(operators_1.startWith(null)), rxjs_1.merge(this._tagCreator.tag$, this._createGeometryChanged$).pipe(operators_1.startWith(null))).pipe(operators_1.map(function (_a) {
31957 var renderTags = _a[0], rc = _a[1], atlas = _a[2], size = _a[3], tag = _a[4], ct = _a[5];
31960 vnode: _this._tagDomRenderer.render(renderTags, ct, atlas, rc.perspective, size),
31963 .subscribe(this._container.domRenderer.render$);
31964 this._glSubscription = this._navigator.stateService.currentState$.pipe(operators_1.map(function (frame) {
31965 var tagScene = _this._tagScene;
31970 needsRender: tagScene.needsRender,
31971 render: tagScene.render.bind(tagScene),
31972 stage: Render_1.GLRenderStage.Foreground,
31976 .subscribe(this._container.glRenderer.render$);
31977 this._navigator.stateService.currentTransform$.pipe(operators_1.first())
31978 .subscribe(function (transform) {
31979 _this._tagSet.activate(transform);
31980 _this._tagScene.add(_this._tagSet.getAll());
31983 TagComponent.prototype._deactivate = function () {
31984 this._editVertexHandler.disable();
31985 this._disableCreateHandlers();
31986 this._tagScene.clear();
31987 this._tagSet.deactivate();
31988 this._tagCreator.delete$.next(null);
31989 this._updateGLObjectsSubscription.unsubscribe();
31990 this._updateTagSceneSubscription.unsubscribe();
31991 this._stopCreateSubscription.unsubscribe();
31992 this._setGLCreateTagSubscription.unsubscribe();
31993 this._createGLObjectsChangedSubscription.unsubscribe();
31994 this._domSubscription.unsubscribe();
31995 this._glSubscription.unsubscribe();
31996 this._fireCreateGeometryEventSubscription.unsubscribe();
31997 this._fireGeometryCreatedSubscription.unsubscribe();
31998 this._fireTagsChangedSubscription.unsubscribe();
31999 this._handlerStopCreateSubscription.unsubscribe();
32000 this._handlerEnablerSubscription.unsubscribe();
32001 this._container.element.classList.remove("component-tag-create");
32003 TagComponent.prototype._getDefaultConfiguration = function () {
32005 createColor: 0xFFFFFF,
32006 mode: Component_1.TagMode.Default,
32009 TagComponent.prototype._disableCreateHandlers = function () {
32010 var createHandlers = this._createHandlers;
32011 for (var key in createHandlers) {
32012 if (!createHandlers.hasOwnProperty(key)) {
32015 var handler = createHandlers[key];
32022 TagComponent.componentName = "tag";
32024 * Event fired when an interaction to create a geometry ends.
32026 * @description A create interaction can by a geometry being created
32027 * or by the creation being aborted.
32029 * @event TagComponent#creategeometryend
32030 * @type {TagComponent} Tag component.
32033 * tagComponent.on("creategeometryend", function(component) {
32034 * console.log(component);
32038 TagComponent.creategeometryend = "creategeometryend";
32040 * Event fired when an interaction to create a geometry starts.
32042 * @description A create interaction starts when the first vertex
32043 * is created in the geometry.
32045 * @event TagComponent#creategeometrystart
32046 * @type {TagComponent} Tag component.
32049 * tagComponent.on("creategeometrystart", function(component) {
32050 * console.log(component);
32054 TagComponent.creategeometrystart = "creategeometrystart";
32056 * Event fired when the create mode is changed.
32058 * @event TagComponent#modechanged
32059 * @type {TagMode} Tag mode
32062 * tagComponent.on("modechanged", function(mode) {
32063 * console.log(mode);
32067 TagComponent.modechanged = "modechanged";
32069 * Event fired when a geometry has been created.
32071 * @event TagComponent#geometrycreated
32072 * @type {Geometry} Created geometry.
32075 * tagComponent.on("geometrycreated", function(geometry) {
32076 * console.log(geometry);
32080 TagComponent.geometrycreated = "geometrycreated";
32082 * Event fired when the tags collection has changed.
32084 * @event TagComponent#tagschanged
32085 * @type {TagComponent} Tag component.
32088 * tagComponent.on("tagschanged", function(component) {
32089 * console.log(component.getAll());
32093 TagComponent.tagschanged = "tagschanged";
32094 return TagComponent;
32095 }(Component_1.Component));
32096 exports.TagComponent = TagComponent;
32097 Component_1.ComponentService.register(TagComponent);
32098 exports.default = TagComponent;
32100 },{"../../Component":275,"../../Geo":278,"../../Render":281,"rxjs":27,"rxjs/operators":225,"when":272}],345:[function(require,module,exports){
32102 Object.defineProperty(exports, "__esModule", { value: true });
32103 var operators_1 = require("rxjs/operators");
32104 var rxjs_1 = require("rxjs");
32105 var Component_1 = require("../../Component");
32106 var TagCreator = /** @class */ (function () {
32107 function TagCreator(component, navigator) {
32108 this._component = component;
32109 this._navigator = navigator;
32110 this._tagOperation$ = new rxjs_1.Subject();
32111 this._createPolygon$ = new rxjs_1.Subject();
32112 this._createRect$ = new rxjs_1.Subject();
32113 this._delete$ = new rxjs_1.Subject();
32114 this._tag$ = this._tagOperation$.pipe(operators_1.scan(function (tag, operation) {
32115 return operation(tag);
32116 }, null), operators_1.share());
32117 this._createRect$.pipe(operators_1.withLatestFrom(this._component.configuration$, this._navigator.stateService.currentTransform$), operators_1.map(function (_a) {
32118 var coord = _a[0], conf = _a[1], transform = _a[2];
32119 return function (tag) {
32120 var geometry = new Component_1.RectGeometry([
32126 return new Component_1.OutlineCreateTag(geometry, { color: conf.createColor }, transform);
32129 .subscribe(this._tagOperation$);
32130 this._createPolygon$.pipe(operators_1.withLatestFrom(this._component.configuration$, this._navigator.stateService.currentTransform$), operators_1.map(function (_a) {
32131 var coord = _a[0], conf = _a[1], transform = _a[2];
32132 return function (tag) {
32133 var geometry = new Component_1.PolygonGeometry([
32134 [coord[0], coord[1]],
32135 [coord[0], coord[1]],
32136 [coord[0], coord[1]],
32138 return new Component_1.OutlineCreateTag(geometry, { color: conf.createColor }, transform);
32141 .subscribe(this._tagOperation$);
32142 this._delete$.pipe(operators_1.map(function () {
32143 return function (tag) {
32147 .subscribe(this._tagOperation$);
32149 Object.defineProperty(TagCreator.prototype, "createRect$", {
32151 return this._createRect$;
32156 Object.defineProperty(TagCreator.prototype, "createPolygon$", {
32158 return this._createPolygon$;
32163 Object.defineProperty(TagCreator.prototype, "delete$", {
32165 return this._delete$;
32170 Object.defineProperty(TagCreator.prototype, "tag$", {
32179 exports.TagCreator = TagCreator;
32180 exports.default = TagCreator;
32182 },{"../../Component":275,"rxjs":27,"rxjs/operators":225}],346:[function(require,module,exports){
32184 Object.defineProperty(exports, "__esModule", { value: true });
32185 var vd = require("virtual-dom");
32186 var TagDOMRenderer = /** @class */ (function () {
32187 function TagDOMRenderer() {
32189 TagDOMRenderer.prototype.render = function (tags, createTag, atlas, camera, size) {
32191 for (var _i = 0, tags_1 = tags; _i < tags_1.length; _i++) {
32192 var tag = tags_1[_i];
32193 vNodes = vNodes.concat(tag.getDOMObjects(atlas, camera, size));
32195 if (createTag != null) {
32196 vNodes = vNodes.concat(createTag.getDOMObjects(camera, size));
32198 return vd.h("div.TagContainer", {}, vNodes);
32200 TagDOMRenderer.prototype.clear = function () {
32201 return vd.h("div", {}, []);
32203 return TagDOMRenderer;
32205 exports.TagDOMRenderer = TagDOMRenderer;
32207 },{"virtual-dom":231}],347:[function(require,module,exports){
32209 Object.defineProperty(exports, "__esModule", { value: true });
32211 * Enumeration for tag modes
32214 * @description Modes for the interaction in the tag component.
32217 (function (TagMode) {
32219 * Disables creating tags.
32221 TagMode[TagMode["Default"] = 0] = "Default";
32223 * Create a point geometry through a click.
32225 TagMode[TagMode["CreatePoint"] = 1] = "CreatePoint";
32227 * Create a polygon geometry through clicks.
32229 TagMode[TagMode["CreatePolygon"] = 2] = "CreatePolygon";
32231 * Create a rect geometry through clicks.
32233 TagMode[TagMode["CreateRect"] = 3] = "CreateRect";
32235 * Create a rect geometry through drag.
32237 * @description Claims the mouse which results in mouse handlers like
32238 * drag pan and scroll zoom becoming inactive.
32240 TagMode[TagMode["CreateRectDrag"] = 4] = "CreateRectDrag";
32241 })(TagMode = exports.TagMode || (exports.TagMode = {}));
32242 exports.default = TagMode;
32244 },{}],348:[function(require,module,exports){
32246 Object.defineProperty(exports, "__esModule", { value: true });
32248 (function (TagOperation) {
32249 TagOperation[TagOperation["None"] = 0] = "None";
32250 TagOperation[TagOperation["Centroid"] = 1] = "Centroid";
32251 TagOperation[TagOperation["Vertex"] = 2] = "Vertex";
32252 })(TagOperation = exports.TagOperation || (exports.TagOperation = {}));
32253 exports.default = TagOperation;
32255 },{}],349:[function(require,module,exports){
32257 Object.defineProperty(exports, "__esModule", { value: true });
32258 var THREE = require("three");
32259 var TagScene = /** @class */ (function () {
32260 function TagScene(scene, raycaster) {
32261 this._createTag = null;
32262 this._needsRender = false;
32263 this._raycaster = !!raycaster ? raycaster : new THREE.Raycaster();
32264 this._scene = !!scene ? scene : new THREE.Scene();
32265 this._objectTags = {};
32266 this._retrievableObjects = [];
32269 Object.defineProperty(TagScene.prototype, "needsRender", {
32271 return this._needsRender;
32276 TagScene.prototype.add = function (tags) {
32277 for (var _i = 0, tags_1 = tags; _i < tags_1.length; _i++) {
32278 var tag = tags_1[_i];
32279 if (tag.tag.id in this._tags) {
32280 this._remove(tag.tag.id);
32284 this._needsRender = true;
32286 TagScene.prototype.addCreateTag = function (tag) {
32287 for (var _i = 0, _a = tag.glObjects; _i < _a.length; _i++) {
32288 var object = _a[_i];
32289 this._scene.add(object);
32291 this._createTag = { tag: tag, objects: tag.glObjects };
32292 this._needsRender = true;
32294 TagScene.prototype.clear = function () {
32295 for (var _i = 0, _a = Object.keys(this._tags); _i < _a.length; _i++) {
32299 this._needsRender = false;
32301 TagScene.prototype.get = function (id) {
32302 return this.has(id) ? this._tags[id].tag : undefined;
32304 TagScene.prototype.has = function (id) {
32305 return id in this._tags;
32307 TagScene.prototype.hasCreateTag = function () {
32308 return this._createTag != null;
32310 TagScene.prototype.intersectObjects = function (_a, camera) {
32311 var viewportX = _a[0], viewportY = _a[1];
32312 this._raycaster.setFromCamera(new THREE.Vector2(viewportX, viewportY), camera);
32313 var intersects = this._raycaster.intersectObjects(this._retrievableObjects);
32314 var intersectedIds = [];
32315 for (var _i = 0, intersects_1 = intersects; _i < intersects_1.length; _i++) {
32316 var intersect = intersects_1[_i];
32317 if (intersect.object.uuid in this._objectTags) {
32318 intersectedIds.push(this._objectTags[intersect.object.uuid]);
32321 return intersectedIds;
32323 TagScene.prototype.remove = function (ids) {
32324 for (var _i = 0, ids_1 = ids; _i < ids_1.length; _i++) {
32325 var id = ids_1[_i];
32328 this._needsRender = true;
32330 TagScene.prototype.removeAll = function () {
32331 for (var _i = 0, _a = Object.keys(this._tags); _i < _a.length; _i++) {
32335 this._needsRender = true;
32337 TagScene.prototype.removeCreateTag = function () {
32338 if (this._createTag == null) {
32341 for (var _i = 0, _a = this._createTag.objects; _i < _a.length; _i++) {
32342 var object = _a[_i];
32343 this._scene.remove(object);
32345 this._createTag.tag.dispose();
32346 this._createTag = null;
32347 this._needsRender = true;
32349 TagScene.prototype.render = function (perspectiveCamera, renderer) {
32350 renderer.render(this._scene, perspectiveCamera);
32351 this._needsRender = false;
32353 TagScene.prototype.update = function () {
32354 this._needsRender = true;
32356 TagScene.prototype.updateCreateTagObjects = function (tag) {
32357 if (this._createTag.tag !== tag) {
32358 throw new Error("Create tags do not have the same reference.");
32360 for (var _i = 0, _a = this._createTag.objects; _i < _a.length; _i++) {
32361 var object = _a[_i];
32362 this._scene.remove(object);
32364 for (var _b = 0, _c = tag.glObjects; _b < _c.length; _b++) {
32365 var object = _c[_b];
32366 this._scene.add(object);
32368 this._createTag.objects = tag.glObjects;
32369 this._needsRender = true;
32371 TagScene.prototype.updateObjects = function (tag) {
32372 var id = tag.tag.id;
32373 if (this._tags[id].tag !== tag) {
32374 throw new Error("Tags do not have the same reference.");
32376 var tagObjects = this._tags[id];
32377 this._removeObjects(tagObjects);
32378 delete this._tags[id];
32380 this._needsRender = true;
32382 TagScene.prototype._add = function (tag) {
32383 var id = tag.tag.id;
32384 var tagObjects = { tag: tag, objects: [], retrievableObjects: [] };
32385 this._tags[id] = tagObjects;
32386 for (var _i = 0, _a = tag.getGLObjects(); _i < _a.length; _i++) {
32387 var object = _a[_i];
32388 tagObjects.objects.push(object);
32389 this._scene.add(object);
32391 for (var _b = 0, _c = tag.getRetrievableObjects(); _b < _c.length; _b++) {
32392 var retrievableObject = _c[_b];
32393 tagObjects.retrievableObjects.push(retrievableObject);
32394 this._retrievableObjects.push(retrievableObject);
32395 this._objectTags[retrievableObject.uuid] = tag.tag.id;
32398 TagScene.prototype._remove = function (id) {
32399 var tagObjects = this._tags[id];
32400 this._removeObjects(tagObjects);
32401 tagObjects.tag.dispose();
32402 delete this._tags[id];
32404 TagScene.prototype._removeObjects = function (tagObjects) {
32405 for (var _i = 0, _a = tagObjects.objects; _i < _a.length; _i++) {
32406 var object = _a[_i];
32407 this._scene.remove(object);
32409 for (var _b = 0, _c = tagObjects.retrievableObjects; _b < _c.length; _b++) {
32410 var retrievableObject = _c[_b];
32411 var index = this._retrievableObjects.indexOf(retrievableObject);
32412 if (index !== -1) {
32413 this._retrievableObjects.splice(index, 1);
32419 exports.TagScene = TagScene;
32420 exports.default = TagScene;
32422 },{"three":226}],350:[function(require,module,exports){
32424 Object.defineProperty(exports, "__esModule", { value: true });
32425 var rxjs_1 = require("rxjs");
32426 var Component_1 = require("../../Component");
32427 var TagSet = /** @class */ (function () {
32428 function TagSet() {
32429 this._active = false;
32431 this._hashDeactivated = {};
32432 this._notifyChanged$ = new rxjs_1.Subject();
32434 Object.defineProperty(TagSet.prototype, "active", {
32436 return this._active;
32441 Object.defineProperty(TagSet.prototype, "changed$", {
32443 return this._notifyChanged$;
32448 TagSet.prototype.activate = function (transform) {
32449 if (this._active) {
32452 for (var id in this._hashDeactivated) {
32453 if (!this._hashDeactivated.hasOwnProperty(id)) {
32456 var tag = this._hashDeactivated[id];
32457 this._add(tag, transform);
32459 this._hashDeactivated = {};
32460 this._active = true;
32461 this._notifyChanged$.next(this);
32463 TagSet.prototype.deactivate = function () {
32464 if (!this._active) {
32467 for (var id in this._hash) {
32468 if (!this._hash.hasOwnProperty(id)) {
32471 this._hashDeactivated[id] = this._hash[id].tag;
32474 this._active = false;
32476 TagSet.prototype.add = function (tags, transform) {
32477 this._assertActivationState(true);
32478 for (var _i = 0, tags_1 = tags; _i < tags_1.length; _i++) {
32479 var tag = tags_1[_i];
32480 this._add(tag, transform);
32482 this._notifyChanged$.next(this);
32484 TagSet.prototype.addDeactivated = function (tags) {
32485 this._assertActivationState(false);
32486 for (var _i = 0, tags_2 = tags; _i < tags_2.length; _i++) {
32487 var tag = tags_2[_i];
32488 if (!(tag instanceof Component_1.OutlineTag || tag instanceof Component_1.SpotTag)) {
32489 throw new Error("Tag type not supported");
32491 this._hashDeactivated[tag.id] = tag;
32494 TagSet.prototype.get = function (id) {
32495 return this.has(id) ? this._hash[id] : undefined;
32497 TagSet.prototype.getAll = function () {
32498 var hash = this._hash;
32499 return Object.keys(hash)
32500 .map(function (id) {
32504 TagSet.prototype.getAllDeactivated = function () {
32505 var hashDeactivated = this._hashDeactivated;
32506 return Object.keys(hashDeactivated)
32507 .map(function (id) {
32508 return hashDeactivated[id];
32511 TagSet.prototype.getDeactivated = function (id) {
32512 return this.hasDeactivated(id) ? this._hashDeactivated[id] : undefined;
32514 TagSet.prototype.has = function (id) {
32515 return id in this._hash;
32517 TagSet.prototype.hasDeactivated = function (id) {
32518 return id in this._hashDeactivated;
32520 TagSet.prototype.remove = function (ids) {
32521 this._assertActivationState(true);
32522 var hash = this._hash;
32523 for (var _i = 0, ids_1 = ids; _i < ids_1.length; _i++) {
32524 var id = ids_1[_i];
32525 if (!(id in hash)) {
32530 this._notifyChanged$.next(this);
32532 TagSet.prototype.removeAll = function () {
32533 this._assertActivationState(true);
32535 this._notifyChanged$.next(this);
32537 TagSet.prototype.removeAllDeactivated = function () {
32538 this._assertActivationState(false);
32539 this._hashDeactivated = {};
32541 TagSet.prototype.removeDeactivated = function (ids) {
32542 this._assertActivationState(false);
32543 var hashDeactivated = this._hashDeactivated;
32544 for (var _i = 0, ids_2 = ids; _i < ids_2.length; _i++) {
32545 var id = ids_2[_i];
32546 if (!(id in hashDeactivated)) {
32549 delete hashDeactivated[id];
32552 TagSet.prototype._add = function (tag, transform) {
32553 if (tag instanceof Component_1.OutlineTag) {
32554 this._hash[tag.id] = new Component_1.OutlineRenderTag(tag, transform);
32556 else if (tag instanceof Component_1.SpotTag) {
32557 this._hash[tag.id] = new Component_1.SpotRenderTag(tag, transform);
32560 throw new Error("Tag type not supported");
32563 TagSet.prototype._assertActivationState = function (should) {
32564 if (should !== this._active) {
32565 throw new Error("Tag set not in correct state for operation.");
32570 exports.TagSet = TagSet;
32571 exports.default = TagSet;
32573 },{"../../Component":275,"rxjs":27}],351:[function(require,module,exports){
32575 var __extends = (this && this.__extends) || (function () {
32576 var extendStatics = function (d, b) {
32577 extendStatics = Object.setPrototypeOf ||
32578 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
32579 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
32580 return extendStatics(d, b);
32582 return function (d, b) {
32583 extendStatics(d, b);
32584 function __() { this.constructor = d; }
32585 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
32588 Object.defineProperty(exports, "__esModule", { value: true });
32589 var Error_1 = require("../../../Error");
32590 var GeometryTagError = /** @class */ (function (_super) {
32591 __extends(GeometryTagError, _super);
32592 function GeometryTagError(message) {
32593 var _this = _super.call(this, message != null ? message : "The provided geometry value is incorrect") || this;
32594 _this.name = "GeometryTagError";
32597 return GeometryTagError;
32598 }(Error_1.MapillaryError));
32599 exports.GeometryTagError = GeometryTagError;
32600 exports.default = Error_1.MapillaryError;
32602 },{"../../../Error":277}],352:[function(require,module,exports){
32604 Object.defineProperty(exports, "__esModule", { value: true });
32605 var rxjs_1 = require("rxjs");
32609 * @classdesc Represents a geometry.
32611 var Geometry = /** @class */ (function () {
32613 * Create a geometry.
32618 function Geometry() {
32619 this._notifyChanged$ = new rxjs_1.Subject();
32621 Object.defineProperty(Geometry.prototype, "changed$", {
32623 * Get changed observable.
32625 * @description Emits the geometry itself every time the geometry
32628 * @returns {Observable<Geometry>} Observable emitting the geometry instance.
32632 return this._notifyChanged$;
32639 exports.Geometry = Geometry;
32640 exports.default = Geometry;
32642 },{"rxjs":27}],353:[function(require,module,exports){
32644 var __extends = (this && this.__extends) || (function () {
32645 var extendStatics = function (d, b) {
32646 extendStatics = Object.setPrototypeOf ||
32647 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
32648 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
32649 return extendStatics(d, b);
32651 return function (d, b) {
32652 extendStatics(d, b);
32653 function __() { this.constructor = d; }
32654 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
32657 Object.defineProperty(exports, "__esModule", { value: true });
32658 var Component_1 = require("../../../Component");
32660 * @class PointGeometry
32662 * @classdesc Represents a point geometry in the 2D basic image coordinate system.
32666 * var basicPoint = [0.5, 0.7];
32667 * var pointGeometry = new Mapillary.TagComponent.PointGeometry(basicPoint);
32670 var PointGeometry = /** @class */ (function (_super) {
32671 __extends(PointGeometry, _super);
32673 * Create a point geometry.
32676 * @param {Array<number>} point - An array representing the basic coordinates of
32679 * @throws {GeometryTagError} Point coordinates must be valid basic coordinates.
32681 function PointGeometry(point) {
32682 var _this = _super.call(this) || this;
32685 if (x < 0 || x > 1 || y < 0 || y > 1) {
32686 throw new Component_1.GeometryTagError("Basic coordinates must be on the interval [0, 1].");
32688 _this._point = point.slice();
32691 Object.defineProperty(PointGeometry.prototype, "point", {
32693 * Get point property.
32694 * @returns {Array<number>} Array representing the basic coordinates of the point.
32697 return this._point;
32703 * Get the 2D basic coordinates for the centroid of the point, i.e. the 2D
32704 * basic coordinates of the point itself.
32706 * @returns {Array<number>} 2D basic coordinates representing the centroid.
32709 PointGeometry.prototype.getCentroid2d = function () {
32710 return this._point.slice();
32713 * Get the 3D world coordinates for the centroid of the point, i.e. the 3D
32714 * world coordinates of the point itself.
32716 * @param {Transform} transform - The transform of the node related to the point.
32717 * @returns {Array<number>} 3D world coordinates representing the centroid.
32720 PointGeometry.prototype.getCentroid3d = function (transform) {
32721 return transform.unprojectBasic(this._point, 200);
32724 * Set the centroid of the point, i.e. the point coordinates.
32726 * @param {Array<number>} value - The new value of the centroid.
32727 * @param {Transform} transform - The transform of the node related to the point.
32730 PointGeometry.prototype.setCentroid2d = function (value, transform) {
32732 Math.max(0, Math.min(1, value[0])),
32733 Math.max(0, Math.min(1, value[1])),
32735 this._point[0] = changed[0];
32736 this._point[1] = changed[1];
32737 this._notifyChanged$.next(this);
32739 return PointGeometry;
32740 }(Component_1.Geometry));
32741 exports.PointGeometry = PointGeometry;
32743 },{"../../../Component":275}],354:[function(require,module,exports){
32745 var __extends = (this && this.__extends) || (function () {
32746 var extendStatics = function (d, b) {
32747 extendStatics = Object.setPrototypeOf ||
32748 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
32749 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
32750 return extendStatics(d, b);
32752 return function (d, b) {
32753 extendStatics(d, b);
32754 function __() { this.constructor = d; }
32755 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
32758 Object.defineProperty(exports, "__esModule", { value: true });
32759 var Component_1 = require("../../../Component");
32761 * @class PolygonGeometry
32763 * @classdesc Represents a polygon geometry in the 2D basic image coordinate system.
32764 * All polygons and holes provided to the constructor needs to be closed.
32768 * var basicPolygon = [[0.5, 0.3], [0.7, 0.3], [0.6, 0.5], [0.5, 0.3]];
32769 * var polygonGeometry = new Mapillary.TagComponent.PolygonGeometry(basicPolygon);
32772 var PolygonGeometry = /** @class */ (function (_super) {
32773 __extends(PolygonGeometry, _super);
32775 * Create a polygon geometry.
32778 * @param {Array<Array<number>>} polygon - Array of polygon vertices. Must be closed.
32779 * @param {Array<Array<Array<number>>>} [holes] - Array of arrays of hole vertices.
32780 * Each array of holes vertices must be closed.
32782 * @throws {GeometryTagError} Polygon coordinates must be valid basic coordinates.
32784 function PolygonGeometry(polygon, holes) {
32785 var _this = _super.call(this) || this;
32786 var polygonLength = polygon.length;
32787 if (polygonLength < 3) {
32788 throw new Component_1.GeometryTagError("A polygon must have three or more positions.");
32790 if (polygon[0][0] !== polygon[polygonLength - 1][0] ||
32791 polygon[0][1] !== polygon[polygonLength - 1][1]) {
32792 throw new Component_1.GeometryTagError("First and last positions must be equivalent.");
32794 _this._polygon = [];
32795 for (var _i = 0, polygon_1 = polygon; _i < polygon_1.length; _i++) {
32796 var vertex = polygon_1[_i];
32797 if (vertex[0] < 0 || vertex[0] > 1 ||
32798 vertex[1] < 0 || vertex[1] > 1) {
32799 throw new Component_1.GeometryTagError("Basic coordinates of polygon must be on the interval [0, 1].");
32801 _this._polygon.push(vertex.slice());
32804 if (holes == null) {
32807 for (var i = 0; i < holes.length; i++) {
32808 var hole = holes[i];
32809 var holeLength = hole.length;
32810 if (holeLength < 3) {
32811 throw new Component_1.GeometryTagError("A polygon hole must have three or more positions.");
32813 if (hole[0][0] !== hole[holeLength - 1][0] ||
32814 hole[0][1] !== hole[holeLength - 1][1]) {
32815 throw new Component_1.GeometryTagError("First and last positions of hole must be equivalent.");
32817 _this._holes.push([]);
32818 for (var _a = 0, hole_1 = hole; _a < hole_1.length; _a++) {
32819 var vertex = hole_1[_a];
32820 if (vertex[0] < 0 || vertex[0] > 1 ||
32821 vertex[1] < 0 || vertex[1] > 1) {
32822 throw new Component_1.GeometryTagError("Basic coordinates of hole must be on the interval [0, 1].");
32824 _this._holes[i].push(vertex.slice());
32829 Object.defineProperty(PolygonGeometry.prototype, "polygon", {
32831 * Get polygon property.
32832 * @returns {Array<Array<number>>} Closed 2d polygon.
32835 return this._polygon;
32840 Object.defineProperty(PolygonGeometry.prototype, "holes", {
32842 * Get holes property.
32843 * @returns {Array<Array<Array<number>>>} Holes of 2d polygon.
32846 return this._holes;
32852 * Add a vertex to the polygon by appending it after the last vertex.
32854 * @param {Array<number>} vertex - Vertex to add.
32857 PolygonGeometry.prototype.addVertex2d = function (vertex) {
32859 Math.max(0, Math.min(1, vertex[0])),
32860 Math.max(0, Math.min(1, vertex[1])),
32862 this._polygon.splice(this._polygon.length - 1, 0, clamped);
32863 this._notifyChanged$.next(this);
32866 * Get the coordinates of a vertex from the polygon representation of the geometry.
32868 * @description The first vertex represents the bottom-left corner with the rest of
32869 * the vertices following in clockwise order.
32871 * @param {number} index - Vertex index.
32872 * @returns {Array<number>} Array representing the 2D basic coordinates of the vertex.
32875 PolygonGeometry.prototype.getVertex2d = function (index) {
32876 return this._polygon[index].slice();
32879 * Remove a vertex from the polygon.
32881 * @param {number} index - The index of the vertex to remove.
32884 PolygonGeometry.prototype.removeVertex2d = function (index) {
32886 index >= this._polygon.length ||
32887 this._polygon.length < 4) {
32888 throw new Component_1.GeometryTagError("Index for removed vertex must be valid.");
32890 if (index > 0 && index < this._polygon.length - 1) {
32891 this._polygon.splice(index, 1);
32894 this._polygon.splice(0, 1);
32895 this._polygon.pop();
32896 var closing = this._polygon[0].slice();
32897 this._polygon.push(closing);
32899 this._notifyChanged$.next(this);
32902 PolygonGeometry.prototype.setVertex2d = function (index, value, transform) {
32904 Math.max(0, Math.min(1, value[0])),
32905 Math.max(0, Math.min(1, value[1])),
32907 if (index === 0 || index === this._polygon.length - 1) {
32908 this._polygon[0] = changed.slice();
32909 this._polygon[this._polygon.length - 1] = changed.slice();
32912 this._polygon[index] = changed.slice();
32914 this._notifyChanged$.next(this);
32917 PolygonGeometry.prototype.setCentroid2d = function (value, transform) {
32918 var xs = this._polygon.map(function (point) { return point[0]; });
32919 var ys = this._polygon.map(function (point) { return point[1]; });
32920 var minX = Math.min.apply(Math, xs);
32921 var maxX = Math.max.apply(Math, xs);
32922 var minY = Math.min.apply(Math, ys);
32923 var maxY = Math.max.apply(Math, ys);
32924 var centroid = this.getCentroid2d();
32925 var minTranslationX = -minX;
32926 var maxTranslationX = 1 - maxX;
32927 var minTranslationY = -minY;
32928 var maxTranslationY = 1 - maxY;
32929 var translationX = Math.max(minTranslationX, Math.min(maxTranslationX, value[0] - centroid[0]));
32930 var translationY = Math.max(minTranslationY, Math.min(maxTranslationY, value[1] - centroid[1]));
32931 for (var _i = 0, _a = this._polygon; _i < _a.length; _i++) {
32932 var point = _a[_i];
32933 point[0] += translationX;
32934 point[1] += translationY;
32936 this._notifyChanged$.next(this);
32939 PolygonGeometry.prototype.getPoints3d = function (transform) {
32940 return this._getPoints3d(this._subsample(this._polygon), transform);
32943 PolygonGeometry.prototype.getVertex3d = function (index, transform) {
32944 return transform.unprojectBasic(this._polygon[index], 200);
32947 PolygonGeometry.prototype.getVertices2d = function () {
32948 return this._polygon.slice();
32951 PolygonGeometry.prototype.getVertices3d = function (transform) {
32952 return this._getPoints3d(this._polygon, transform);
32955 * Get a polygon representation of the 3D coordinates for the vertices of each hole
32956 * of the geometry. Line segments between vertices will possibly be subsampled
32957 * resulting in a larger number of points than the total number of vertices.
32959 * @param {Transform} transform - The transform of the node related to the geometry.
32960 * @returns {Array<Array<Array<number>>>} Array of hole polygons in 3D world coordinates
32961 * representing the vertices of each hole of the geometry.
32964 PolygonGeometry.prototype.getHolePoints3d = function (transform) {
32967 .map(function (hole2d) {
32968 return _this._getPoints3d(_this._subsample(hole2d), transform);
32972 * Get a polygon representation of the 3D coordinates for the vertices of each hole
32975 * @param {Transform} transform - The transform of the node related to the geometry.
32976 * @returns {Array<Array<Array<number>>>} Array of hole polygons in 3D world coordinates
32977 * representing the vertices of each hole of the geometry.
32980 PolygonGeometry.prototype.getHoleVertices3d = function (transform) {
32983 .map(function (hole2d) {
32984 return _this._getPoints3d(hole2d, transform);
32988 PolygonGeometry.prototype.getCentroid2d = function () {
32989 var polygon = this._polygon;
32993 for (var i = 0; i < polygon.length - 1; i++) {
32994 var xi = polygon[i][0];
32995 var yi = polygon[i][1];
32996 var xi1 = polygon[i + 1][0];
32997 var yi1 = polygon[i + 1][1];
32998 var a = xi * yi1 - xi1 * yi;
33000 centroidX += (xi + xi1) * a;
33001 centroidY += (yi + yi1) * a;
33004 centroidX /= 6 * area;
33005 centroidY /= 6 * area;
33006 return [centroidX, centroidY];
33009 PolygonGeometry.prototype.getCentroid3d = function (transform) {
33010 var centroid2d = this.getCentroid2d();
33011 return transform.unprojectBasic(centroid2d, 200);
33014 PolygonGeometry.prototype.get3dDomainTriangles3d = function (transform) {
33016 return this._triangulate(this._project(this._polygon, transform), this.getVertices3d(transform), this._holes
33017 .map(function (hole2d) {
33018 return _this._project(hole2d, transform);
33019 }), this.getHoleVertices3d(transform));
33022 PolygonGeometry.prototype.getTriangles3d = function (transform) {
33024 if (transform.fullPano) {
33025 return this._triangulatePano(this._polygon.slice(), this.holes.slice(), transform);
33027 var points2d = this._project(this._subsample(this._polygon), transform);
33028 var points3d = this.getPoints3d(transform);
33029 var holes2d = this._holes
33030 .map(function (hole) {
33031 return _this._project(_this._subsample(hole), transform);
33033 var holes3d = this.getHolePoints3d(transform);
33034 return this._triangulate(points2d, points3d, holes2d, holes3d);
33037 PolygonGeometry.prototype.getPoleOfInaccessibility2d = function () {
33038 return this._getPoleOfInaccessibility2d(this._polygon.slice());
33041 PolygonGeometry.prototype.getPoleOfInaccessibility3d = function (transform) {
33042 var pole2d = this._getPoleOfInaccessibility2d(this._polygon.slice());
33043 return transform.unprojectBasic(pole2d, 200);
33045 PolygonGeometry.prototype._getPoints3d = function (points2d, transform) {
33047 .map(function (point) {
33048 return transform.unprojectBasic(point, 200);
33051 return PolygonGeometry;
33052 }(Component_1.VertexGeometry));
33053 exports.PolygonGeometry = PolygonGeometry;
33054 exports.default = PolygonGeometry;
33056 },{"../../../Component":275}],355:[function(require,module,exports){
33058 var __extends = (this && this.__extends) || (function () {
33059 var extendStatics = function (d, b) {
33060 extendStatics = Object.setPrototypeOf ||
33061 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
33062 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
33063 return extendStatics(d, b);
33065 return function (d, b) {
33066 extendStatics(d, b);
33067 function __() { this.constructor = d; }
33068 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
33071 Object.defineProperty(exports, "__esModule", { value: true });
33072 var Component_1 = require("../../../Component");
33074 * @class RectGeometry
33076 * @classdesc Represents a rectangle geometry in the 2D basic image coordinate system.
33080 * var basicRect = [0.5, 0.3, 0.7, 0.4];
33081 * var rectGeometry = new Mapillary.TagComponent.RectGeometry(basicRect);
33084 var RectGeometry = /** @class */ (function (_super) {
33085 __extends(RectGeometry, _super);
33087 * Create a rectangle geometry.
33090 * @param {Array<number>} rect - An array representing the top-left and bottom-right
33091 * corners of the rectangle in basic coordinates. Ordered according to [x0, y0, x1, y1].
33093 * @throws {GeometryTagError} Rectangle coordinates must be valid basic coordinates.
33095 function RectGeometry(rect) {
33096 var _this = _super.call(this) || this;
33097 if (rect[1] > rect[3]) {
33098 throw new Component_1.GeometryTagError("Basic Y coordinates values can not be inverted.");
33100 for (var _i = 0, rect_1 = rect; _i < rect_1.length; _i++) {
33101 var coord = rect_1[_i];
33102 if (coord < 0 || coord > 1) {
33103 throw new Component_1.GeometryTagError("Basic coordinates must be on the interval [0, 1].");
33106 _this._anchorIndex = undefined;
33107 _this._rect = rect.slice(0, 4);
33108 _this._inverted = _this._rect[0] > _this._rect[2];
33111 Object.defineProperty(RectGeometry.prototype, "anchorIndex", {
33113 * Get anchor index property.
33115 * @returns {number} Index representing the current anchor property if
33116 * achoring indexing has been initialized. If anchor indexing has not been
33117 * initialized or has been terminated undefined will be returned.
33121 return this._anchorIndex;
33126 Object.defineProperty(RectGeometry.prototype, "inverted", {
33128 * Get inverted property.
33130 * @returns {boolean} Boolean determining whether the rect geometry is
33131 * inverted. For panoramas the rect geometrye may be inverted.
33135 return this._inverted;
33140 Object.defineProperty(RectGeometry.prototype, "rect", {
33142 * Get rect property.
33144 * @returns {Array<number>} Array representing the top-left and bottom-right
33145 * corners of the rectangle in basic coordinates.
33154 * Initialize anchor indexing to enable setting opposite vertex.
33156 * @param {number} [index] - The index of the vertex to use as anchor.
33158 * @throws {Error} If anchor indexing has already been initialized.
33159 * @throws {Error} If index is not valid (0 to 3).
33162 RectGeometry.prototype.initializeAnchorIndexing = function (index) {
33163 if (this._anchorIndex !== undefined) {
33164 throw new Error("Anchor indexing is already initialized.");
33166 if (index < 0 || index > 3) {
33167 throw new Error("Invalid anchor index: " + index + ".");
33169 this._anchorIndex = index === undefined ? 0 : index;
33172 * Terminate anchor indexing to disable setting pposite vertex.
33175 RectGeometry.prototype.terminateAnchorIndexing = function () {
33176 this._anchorIndex = undefined;
33179 * Set the value of the vertex opposite to the anchor in the polygon
33180 * representation of the rectangle.
33182 * @description Setting the opposite vertex may change the anchor index.
33184 * @param {Array<number>} opposite - The new value of the vertex opposite to the anchor.
33185 * @param {Transform} transform - The transform of the node related to the rectangle.
33187 * @throws {Error} When anchor indexing has not been initialized.
33190 RectGeometry.prototype.setOppositeVertex2d = function (opposite, transform) {
33191 if (this._anchorIndex === undefined) {
33192 throw new Error("Anchor indexing needs to be initialized.");
33195 Math.max(0, Math.min(1, opposite[0])),
33196 Math.max(0, Math.min(1, opposite[1])),
33198 var original = this._rect.slice();
33199 var anchor = this._anchorIndex === 0 ? [original[0], original[3]] :
33200 this._anchorIndex === 1 ? [original[0], original[1]] :
33201 this._anchorIndex === 2 ? [original[2], original[1]] :
33202 [original[2], original[3]];
33203 if (transform.fullPano) {
33204 var deltaX = this._anchorIndex < 2 ?
33205 changed[0] - original[2] :
33206 changed[0] - original[0];
33207 if (!this._inverted && this._anchorIndex < 2 && changed[0] < 0.25 && original[2] > 0.75 && deltaX < -0.5) {
33208 // right side passes boundary rightward
33209 this._inverted = true;
33210 this._anchorIndex = anchor[1] > changed[1] ? 0 : 1;
33212 else if (!this._inverted && this._anchorIndex >= 2 && changed[0] < 0.25 && original[2] > 0.75 && deltaX < -0.5) {
33213 // left side passes right side and boundary rightward
33214 this._inverted = true;
33215 this._anchorIndex = anchor[1] > changed[1] ? 0 : 1;
33217 else if (this._inverted && this._anchorIndex >= 2 && changed[0] < 0.25 && original[0] > 0.75 && deltaX < -0.5) {
33218 this._inverted = false;
33219 if (anchor[0] > changed[0]) {
33220 // left side passes boundary rightward
33221 this._anchorIndex = anchor[1] > changed[1] ? 3 : 2;
33224 // left side passes right side and boundary rightward
33225 this._anchorIndex = anchor[1] > changed[1] ? 0 : 1;
33228 else if (!this._inverted && this._anchorIndex >= 2 && changed[0] > 0.75 && original[0] < 0.25 && deltaX > 0.5) {
33229 // left side passes boundary leftward
33230 this._inverted = true;
33231 this._anchorIndex = anchor[1] > changed[1] ? 3 : 2;
33233 else if (!this._inverted && this._anchorIndex < 2 && changed[0] > 0.75 && original[0] < 0.25 && deltaX > 0.5) {
33234 // right side passes left side and boundary leftward
33235 this._inverted = true;
33236 this._anchorIndex = anchor[1] > changed[1] ? 3 : 2;
33238 else if (this._inverted && this._anchorIndex < 2 && changed[0] > 0.75 && original[2] < 0.25 && deltaX > 0.5) {
33239 this._inverted = false;
33240 if (anchor[0] > changed[0]) {
33241 // right side passes boundary leftward
33242 this._anchorIndex = anchor[1] > changed[1] ? 3 : 2;
33245 // right side passes left side and boundary leftward
33246 this._anchorIndex = anchor[1] > changed[1] ? 0 : 1;
33249 else if (this._inverted && this._anchorIndex < 2 && changed[0] > original[0]) {
33250 // inverted and right side passes left side completing a loop
33251 this._inverted = false;
33252 this._anchorIndex = anchor[1] > changed[1] ? 0 : 1;
33254 else if (this._inverted && this._anchorIndex >= 2 && changed[0] < original[2]) {
33255 // inverted and left side passes right side completing a loop
33256 this._inverted = false;
33257 this._anchorIndex = anchor[1] > changed[1] ? 3 : 2;
33259 else if (this._inverted) {
33260 // if still inverted only top and bottom can switch
33261 if (this._anchorIndex < 2) {
33262 this._anchorIndex = anchor[1] > changed[1] ? 0 : 1;
33265 this._anchorIndex = anchor[1] > changed[1] ? 3 : 2;
33269 // if still not inverted treat as non full pano
33270 if (anchor[0] <= changed[0] && anchor[1] > changed[1]) {
33271 this._anchorIndex = 0;
33273 else if (anchor[0] <= changed[0] && anchor[1] <= changed[1]) {
33274 this._anchorIndex = 1;
33276 else if (anchor[0] > changed[0] && anchor[1] <= changed[1]) {
33277 this._anchorIndex = 2;
33280 this._anchorIndex = 3;
33284 if (this._anchorIndex === 0) {
33285 rect[0] = anchor[0];
33286 rect[1] = changed[1];
33287 rect[2] = changed[0];
33288 rect[3] = anchor[1];
33290 else if (this._anchorIndex === 1) {
33291 rect[0] = anchor[0];
33292 rect[1] = anchor[1];
33293 rect[2] = changed[0];
33294 rect[3] = changed[1];
33296 else if (this._anchorIndex === 2) {
33297 rect[0] = changed[0];
33298 rect[1] = anchor[1];
33299 rect[2] = anchor[0];
33300 rect[3] = changed[1];
33303 rect[0] = changed[0];
33304 rect[1] = changed[1];
33305 rect[2] = anchor[0];
33306 rect[3] = anchor[1];
33308 if (!this._inverted && rect[0] > rect[2] ||
33309 this._inverted && rect[0] < rect[2]) {
33310 rect[0] = original[0];
33311 rect[2] = original[2];
33313 if (rect[1] > rect[3]) {
33314 rect[1] = original[1];
33315 rect[3] = original[3];
33317 this._rect[0] = rect[0];
33318 this._rect[1] = rect[1];
33319 this._rect[2] = rect[2];
33320 this._rect[3] = rect[3];
33323 if (anchor[0] <= changed[0] && anchor[1] > changed[1]) {
33324 this._anchorIndex = 0;
33326 else if (anchor[0] <= changed[0] && anchor[1] <= changed[1]) {
33327 this._anchorIndex = 1;
33329 else if (anchor[0] > changed[0] && anchor[1] <= changed[1]) {
33330 this._anchorIndex = 2;
33333 this._anchorIndex = 3;
33336 if (this._anchorIndex === 0) {
33337 rect[0] = anchor[0];
33338 rect[1] = changed[1];
33339 rect[2] = changed[0];
33340 rect[3] = anchor[1];
33342 else if (this._anchorIndex === 1) {
33343 rect[0] = anchor[0];
33344 rect[1] = anchor[1];
33345 rect[2] = changed[0];
33346 rect[3] = changed[1];
33348 else if (this._anchorIndex === 2) {
33349 rect[0] = changed[0];
33350 rect[1] = anchor[1];
33351 rect[2] = anchor[0];
33352 rect[3] = changed[1];
33355 rect[0] = changed[0];
33356 rect[1] = changed[1];
33357 rect[2] = anchor[0];
33358 rect[3] = anchor[1];
33360 if (rect[0] > rect[2]) {
33361 rect[0] = original[0];
33362 rect[2] = original[2];
33364 if (rect[1] > rect[3]) {
33365 rect[1] = original[1];
33366 rect[3] = original[3];
33368 this._rect[0] = rect[0];
33369 this._rect[1] = rect[1];
33370 this._rect[2] = rect[2];
33371 this._rect[3] = rect[3];
33373 this._notifyChanged$.next(this);
33376 * Set the value of a vertex in the polygon representation of the rectangle.
33378 * @description The polygon is defined to have the first vertex at the
33379 * bottom-left corner with the rest of the vertices following in clockwise order.
33381 * @param {number} index - The index of the vertex to be set.
33382 * @param {Array<number>} value - The new value of the vertex.
33383 * @param {Transform} transform - The transform of the node related to the rectangle.
33386 RectGeometry.prototype.setVertex2d = function (index, value, transform) {
33387 var original = this._rect.slice();
33389 Math.max(0, Math.min(1, value[0])),
33390 Math.max(0, Math.min(1, value[1])),
33394 rect[0] = changed[0];
33395 rect[1] = original[1];
33396 rect[2] = original[2];
33397 rect[3] = changed[1];
33399 else if (index === 1) {
33400 rect[0] = changed[0];
33401 rect[1] = changed[1];
33402 rect[2] = original[2];
33403 rect[3] = original[3];
33405 else if (index === 2) {
33406 rect[0] = original[0];
33407 rect[1] = changed[1];
33408 rect[2] = changed[0];
33409 rect[3] = original[3];
33411 else if (index === 3) {
33412 rect[0] = original[0];
33413 rect[1] = original[1];
33414 rect[2] = changed[0];
33415 rect[3] = changed[1];
33417 if (transform.fullPano) {
33418 var passingBoundaryLeftward = index < 2 && changed[0] > 0.75 && original[0] < 0.25 ||
33419 index >= 2 && this._inverted && changed[0] > 0.75 && original[2] < 0.25;
33420 var passingBoundaryRightward = index < 2 && this._inverted && changed[0] < 0.25 && original[0] > 0.75 ||
33421 index >= 2 && changed[0] < 0.25 && original[2] > 0.75;
33422 if (passingBoundaryLeftward || passingBoundaryRightward) {
33423 this._inverted = !this._inverted;
33426 if (rect[0] - original[0] < -0.25) {
33427 rect[0] = original[0];
33429 if (rect[2] - original[2] > 0.25) {
33430 rect[2] = original[2];
33433 if (!this._inverted && rect[0] > rect[2] ||
33434 this._inverted && rect[0] < rect[2]) {
33435 rect[0] = original[0];
33436 rect[2] = original[2];
33440 if (rect[0] > rect[2]) {
33441 rect[0] = original[0];
33442 rect[2] = original[2];
33445 if (rect[1] > rect[3]) {
33446 rect[1] = original[1];
33447 rect[3] = original[3];
33449 this._rect[0] = rect[0];
33450 this._rect[1] = rect[1];
33451 this._rect[2] = rect[2];
33452 this._rect[3] = rect[3];
33453 this._notifyChanged$.next(this);
33456 RectGeometry.prototype.setCentroid2d = function (value, transform) {
33457 var original = this._rect.slice();
33458 var x0 = original[0];
33459 var x1 = this._inverted ? original[2] + 1 : original[2];
33460 var y0 = original[1];
33461 var y1 = original[3];
33462 var centerX = x0 + (x1 - x0) / 2;
33463 var centerY = y0 + (y1 - y0) / 2;
33464 var translationX = 0;
33465 if (transform.gpano != null &&
33466 transform.gpano.CroppedAreaImageWidthPixels === transform.gpano.FullPanoWidthPixels) {
33467 translationX = this._inverted ? value[0] + 1 - centerX : value[0] - centerX;
33470 var minTranslationX = -x0;
33471 var maxTranslationX = 1 - x1;
33472 translationX = Math.max(minTranslationX, Math.min(maxTranslationX, value[0] - centerX));
33474 var minTranslationY = -y0;
33475 var maxTranslationY = 1 - y1;
33476 var translationY = Math.max(minTranslationY, Math.min(maxTranslationY, value[1] - centerY));
33477 this._rect[0] = original[0] + translationX;
33478 this._rect[1] = original[1] + translationY;
33479 this._rect[2] = original[2] + translationX;
33480 this._rect[3] = original[3] + translationY;
33481 if (this._rect[0] < 0) {
33482 this._rect[0] += 1;
33483 this._inverted = !this._inverted;
33485 else if (this._rect[0] > 1) {
33486 this._rect[0] -= 1;
33487 this._inverted = !this._inverted;
33489 if (this._rect[2] < 0) {
33490 this._rect[2] += 1;
33491 this._inverted = !this._inverted;
33493 else if (this._rect[2] > 1) {
33494 this._rect[2] -= 1;
33495 this._inverted = !this._inverted;
33497 this._notifyChanged$.next(this);
33500 * Get the 3D coordinates for the vertices of the rectangle with
33501 * interpolated points along the lines.
33503 * @param {Transform} transform - The transform of the node related to
33505 * @returns {Array<Array<number>>} Polygon array of 3D world coordinates
33506 * representing the rectangle.
33509 RectGeometry.prototype.getPoints3d = function (transform) {
33510 return this._getPoints2d()
33511 .map(function (point) {
33512 return transform.unprojectBasic(point, 200);
33516 * Get the coordinates of a vertex from the polygon representation of the geometry.
33518 * @description The first vertex represents the bottom-left corner with the rest of
33519 * the vertices following in clockwise order. The method shifts the right side
33520 * coordinates of the rectangle by one unit to ensure that the vertices are ordered
33523 * @param {number} index - Vertex index.
33524 * @returns {Array<number>} Array representing the 2D basic coordinates of the vertex.
33527 RectGeometry.prototype.getVertex2d = function (index) {
33528 return this._rectToVertices2d(this._rect)[index];
33531 * Get the coordinates of a vertex from the polygon representation of the geometry.
33533 * @description The first vertex represents the bottom-left corner with the rest of
33534 * the vertices following in clockwise order. The coordinates will not be shifted
33535 * so they may not appear in clockwise order when layed out on the plane.
33537 * @param {number} index - Vertex index.
33538 * @returns {Array<number>} Array representing the 2D basic coordinates of the vertex.
33541 RectGeometry.prototype.getNonAdjustedVertex2d = function (index) {
33542 return this._rectToNonAdjustedVertices2d(this._rect)[index];
33545 * Get a vertex from the polygon representation of the 3D coordinates for the
33546 * vertices of the geometry.
33548 * @description The first vertex represents the bottom-left corner with the rest of
33549 * the vertices following in clockwise order.
33551 * @param {number} index - Vertex index.
33552 * @param {Transform} transform - The transform of the node related to the geometry.
33553 * @returns {Array<Array<number>>} Polygon array of 3D world coordinates representing
33554 * the vertices of the geometry.
33557 RectGeometry.prototype.getVertex3d = function (index, transform) {
33558 return transform.unprojectBasic(this._rectToVertices2d(this._rect)[index], 200);
33561 * Get a polygon representation of the 2D basic coordinates for the vertices of the rectangle.
33563 * @description The first vertex represents the bottom-left corner with the rest of
33564 * the vertices following in clockwise order.
33566 * @returns {Array<Array<number>>} Polygon array of 2D basic coordinates representing
33567 * the rectangle vertices.
33570 RectGeometry.prototype.getVertices2d = function () {
33571 return this._rectToVertices2d(this._rect);
33574 * Get a polygon representation of the 3D coordinates for the vertices of the rectangle.
33576 * @description The first vertex represents the bottom-left corner with the rest of
33577 * the vertices following in clockwise order.
33579 * @param {Transform} transform - The transform of the node related to the rectangle.
33580 * @returns {Array<Array<number>>} Polygon array of 3D world coordinates representing
33581 * the rectangle vertices.
33584 RectGeometry.prototype.getVertices3d = function (transform) {
33585 return this._rectToVertices2d(this._rect)
33586 .map(function (vertex) {
33587 return transform.unprojectBasic(vertex, 200);
33591 RectGeometry.prototype.getCentroid2d = function () {
33592 var rect = this._rect;
33594 var x1 = this._inverted ? rect[2] + 1 : rect[2];
33597 var centroidX = (x0 + x1) / 2;
33598 var centroidY = (y0 + y1) / 2;
33599 return [centroidX, centroidY];
33602 RectGeometry.prototype.getCentroid3d = function (transform) {
33603 var centroid2d = this.getCentroid2d();
33604 return transform.unprojectBasic(centroid2d, 200);
33609 RectGeometry.prototype.getPoleOfInaccessibility2d = function () {
33610 return this._getPoleOfInaccessibility2d(this._rectToVertices2d(this._rect));
33613 RectGeometry.prototype.getPoleOfInaccessibility3d = function (transform) {
33614 var pole2d = this._getPoleOfInaccessibility2d(this._rectToVertices2d(this._rect));
33615 return transform.unprojectBasic(pole2d, 200);
33618 RectGeometry.prototype.getTriangles3d = function (transform) {
33619 return transform.fullPano ?
33621 this._triangulate(this._project(this._getPoints2d(), transform), this.getPoints3d(transform));
33624 * Check if a particular bottom-right value is valid according to the current
33625 * rectangle coordinates.
33627 * @param {Array<number>} bottomRight - The bottom-right coordinates to validate
33628 * @returns {boolean} Value indicating whether the provided bottom-right coordinates
33632 RectGeometry.prototype.validate = function (bottomRight) {
33633 var rect = this._rect;
33634 if (!this._inverted && bottomRight[0] < rect[0] ||
33635 bottomRight[0] - rect[2] > 0.25 ||
33636 bottomRight[1] < rect[1]) {
33642 * Get the 2D coordinates for the vertices of the rectangle with
33643 * interpolated points along the lines.
33645 * @returns {Array<Array<number>>} Polygon array of 2D basic coordinates
33646 * representing the rectangle.
33648 RectGeometry.prototype._getPoints2d = function () {
33649 var vertices2d = this._rectToVertices2d(this._rect);
33650 var sides = vertices2d.length - 1;
33653 for (var i = 0; i < sides; ++i) {
33654 var startX = vertices2d[i][0];
33655 var startY = vertices2d[i][1];
33656 var endX = vertices2d[i + 1][0];
33657 var endY = vertices2d[i + 1][1];
33658 var intervalX = (endX - startX) / (sections - 1);
33659 var intervalY = (endY - startY) / (sections - 1);
33660 for (var j = 0; j < sections; ++j) {
33662 startX + j * intervalX,
33663 startY + j * intervalY,
33665 points2d.push(point);
33671 * Convert the top-left, bottom-right representation of a rectangle to a polygon
33672 * representation of the vertices starting at the bottom-left corner going
33675 * @description The method shifts the right side coordinates of the rectangle
33676 * by one unit to ensure that the vertices are ordered clockwise.
33678 * @param {Array<number>} rect - Top-left, bottom-right representation of a
33680 * @returns {Array<Array<number>>} Polygon representation of the vertices of the
33683 RectGeometry.prototype._rectToVertices2d = function (rect) {
33685 [rect[0], rect[3]],
33686 [rect[0], rect[1]],
33687 [this._inverted ? rect[2] + 1 : rect[2], rect[1]],
33688 [this._inverted ? rect[2] + 1 : rect[2], rect[3]],
33689 [rect[0], rect[3]],
33693 * Convert the top-left, bottom-right representation of a rectangle to a polygon
33694 * representation of the vertices starting at the bottom-left corner going
33697 * @description The first vertex represents the bottom-left corner with the rest of
33698 * the vertices following in clockwise order. The coordinates will not be shifted
33699 * to ensure that the vertices are ordered clockwise when layed out on the plane.
33701 * @param {Array<number>} rect - Top-left, bottom-right representation of a
33703 * @returns {Array<Array<number>>} Polygon representation of the vertices of the
33706 RectGeometry.prototype._rectToNonAdjustedVertices2d = function (rect) {
33708 [rect[0], rect[3]],
33709 [rect[0], rect[1]],
33710 [rect[2], rect[1]],
33711 [rect[2], rect[3]],
33712 [rect[0], rect[3]],
33715 return RectGeometry;
33716 }(Component_1.VertexGeometry));
33717 exports.RectGeometry = RectGeometry;
33718 exports.default = RectGeometry;
33720 },{"../../../Component":275}],356:[function(require,module,exports){
33722 var __extends = (this && this.__extends) || (function () {
33723 var extendStatics = function (d, b) {
33724 extendStatics = Object.setPrototypeOf ||
33725 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
33726 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
33727 return extendStatics(d, b);
33729 return function (d, b) {
33730 extendStatics(d, b);
33731 function __() { this.constructor = d; }
33732 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
33735 Object.defineProperty(exports, "__esModule", { value: true });
33736 var earcut_1 = require("earcut");
33737 var martinez = require("martinez-polygon-clipping");
33738 var polylabel = require("@mapbox/polylabel");
33739 var THREE = require("three");
33740 var Component_1 = require("../../../Component");
33742 * @class VertexGeometry
33744 * @classdesc Represents a vertex geometry.
33746 var VertexGeometry = /** @class */ (function (_super) {
33747 __extends(VertexGeometry, _super);
33749 * Create a vertex geometry.
33754 function VertexGeometry() {
33755 var _this = _super.call(this) || this;
33756 _this._subsampleThreshold = 0.005;
33760 * Finds the polygon pole of inaccessibility, the most distant internal
33761 * point from the polygon outline.
33763 * @param {Array<Array<number>>} points2d - 2d points of outline to triangulate.
33764 * @returns {Array<number>} Point of inaccessibility.
33767 VertexGeometry.prototype._getPoleOfInaccessibility2d = function (points2d) {
33768 var pole2d = polylabel([points2d], 3e-2);
33771 VertexGeometry.prototype._project = function (points2d, transform) {
33772 var camera = this._createCamera(transform.upVector().toArray(), transform.unprojectSfM([0, 0], 0), transform.unprojectSfM([0, 0], 10));
33773 return this._deunproject(points2d, transform, camera);
33775 VertexGeometry.prototype._subsample = function (points2d, threshold) {
33776 if (threshold === void 0) { threshold = this._subsampleThreshold; }
33777 var subsampled = [];
33778 var length = points2d.length;
33779 for (var index = 0; index < length; index++) {
33780 var p1 = points2d[index];
33781 var p2 = points2d[(index + 1) % length];
33782 subsampled.push(p1);
33783 var dist = Math.sqrt(Math.pow((p2[0] - p1[0]), 2) + Math.pow((p2[1] - p1[1]), 2));
33784 var subsamples = Math.floor(dist / threshold);
33785 var coeff = 1 / (subsamples + 1);
33786 for (var i = 1; i <= subsamples; i++) {
33787 var alpha = i * coeff;
33789 (1 - alpha) * p1[0] + alpha * p2[0],
33790 (1 - alpha) * p1[1] + alpha * p2[1],
33792 subsampled.push(subsample);
33798 * Triangulates a 2d polygon and returns the triangle
33799 * representation as a flattened array of 3d points.
33801 * @param {Array<Array<number>>} points2d - 2d points of outline to triangulate.
33802 * @param {Array<Array<number>>} points3d - 3d points of outline corresponding to the 2d points.
33803 * @param {Array<Array<Array<number>>>} [holes2d] - 2d points of holes to triangulate.
33804 * @param {Array<Array<Array<number>>>} [holes3d] - 3d points of holes corresponding to the 2d points.
33805 * @returns {Array<number>} Flattened array of 3d points ordered based on the triangles.
33808 VertexGeometry.prototype._triangulate = function (points2d, points3d, holes2d, holes3d) {
33809 var data = [points2d.slice(0, -1)];
33810 for (var _i = 0, _a = holes2d != null ? holes2d : []; _i < _a.length; _i++) {
33811 var hole2d = _a[_i];
33812 data.push(hole2d.slice(0, -1));
33814 var points = points3d.slice(0, -1);
33815 for (var _b = 0, _c = holes3d != null ? holes3d : []; _b < _c.length; _b++) {
33816 var hole3d = _c[_b];
33817 points = points.concat(hole3d.slice(0, -1));
33819 var flattened = earcut_1.default.flatten(data);
33820 var indices = earcut_1.default(flattened.vertices, flattened.holes, flattened.dimensions);
33821 var triangles = [];
33822 for (var i = 0; i < indices.length; ++i) {
33823 var point = points[indices[i]];
33824 triangles.push(point[0]);
33825 triangles.push(point[1]);
33826 triangles.push(point[2]);
33830 VertexGeometry.prototype._triangulatePano = function (points2d, holes2d, transform) {
33831 var triangles = [];
33832 var epsilon = 1e-9;
33835 for (var x = 0; x < subareasX; x++) {
33836 for (var y = 0; y < subareasY; y++) {
33837 var epsilonX0 = x === 0 ? -epsilon : epsilon;
33838 var epsilonY0 = y === 0 ? -epsilon : epsilon;
33839 var x0 = x / subareasX + epsilonX0;
33840 var y0 = y / subareasY + epsilonY0;
33841 var x1 = (x + 1) / subareasX + epsilon;
33842 var y1 = (y + 1) / subareasY + epsilon;
33851 (2 * x + 1) / (2 * subareasX),
33852 (2 * y + 1) / (2 * subareasY),
33854 triangles.push.apply(triangles, this._triangulateSubarea(points2d, holes2d, bbox2d, lookat2d, transform));
33859 VertexGeometry.prototype._unproject = function (points2d, transform, distance) {
33860 if (distance === void 0) { distance = 200; }
33862 .map(function (point) {
33863 return transform.unprojectBasic(point, distance);
33866 VertexGeometry.prototype._createCamera = function (upVector, position, lookAt) {
33867 var camera = new THREE.Camera();
33868 camera.up.copy(new THREE.Vector3().fromArray(upVector));
33869 camera.position.copy(new THREE.Vector3().fromArray(position));
33870 camera.lookAt(new THREE.Vector3().fromArray(lookAt));
33871 camera.updateMatrix();
33872 camera.updateMatrixWorld(true);
33875 VertexGeometry.prototype._deunproject = function (points2d, transform, camera) {
33877 .map(function (point2d) {
33878 var pointWorld = transform.unprojectBasic(point2d, 10000);
33879 var pointCamera = new THREE.Vector3(pointWorld[0], pointWorld[1], pointWorld[2])
33880 .applyMatrix4(camera.matrixWorldInverse);
33881 return [pointCamera.x / pointCamera.z, pointCamera.y / pointCamera.z];
33884 VertexGeometry.prototype._triangulateSubarea = function (points2d, holes2d, bbox2d, lookat2d, transform) {
33885 var intersections = martinez.intersection([points2d].concat(holes2d), [bbox2d]);
33886 if (!intersections) {
33889 var triangles = [];
33890 var threshold = this._subsampleThreshold;
33891 var camera = this._createCamera(transform.upVector().toArray(), transform.unprojectSfM([0, 0], 0), transform.unprojectBasic(lookat2d, 10));
33892 for (var _i = 0, intersections_1 = intersections; _i < intersections_1.length; _i++) {
33893 var intersection = intersections_1[_i];
33894 var subsampledPolygon2d = this._subsample(intersection[0], threshold);
33895 var polygon2d = this._deunproject(subsampledPolygon2d, transform, camera);
33896 var polygon3d = this._unproject(subsampledPolygon2d, transform);
33897 var polygonHoles2d = [];
33898 var polygonHoles3d = [];
33899 for (var i = 1; i < intersection.length; i++) {
33900 var subsampledHole2d = this._subsample(intersection[i], threshold);
33901 var hole2d = this._deunproject(subsampledHole2d, transform, camera);
33902 var hole3d = this._unproject(subsampledHole2d, transform);
33903 polygonHoles2d.push(hole2d);
33904 polygonHoles3d.push(hole3d);
33906 triangles.push.apply(triangles, this._triangulate(polygon2d, polygon3d, polygonHoles2d, polygonHoles3d));
33910 return VertexGeometry;
33911 }(Component_1.Geometry));
33912 exports.VertexGeometry = VertexGeometry;
33913 exports.default = VertexGeometry;
33915 },{"../../../Component":275,"@mapbox/polylabel":1,"earcut":8,"martinez-polygon-clipping":22,"three":226}],357:[function(require,module,exports){
33917 var __extends = (this && this.__extends) || (function () {
33918 var extendStatics = function (d, b) {
33919 extendStatics = Object.setPrototypeOf ||
33920 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
33921 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
33922 return extendStatics(d, b);
33924 return function (d, b) {
33925 extendStatics(d, b);
33926 function __() { this.constructor = d; }
33927 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
33930 Object.defineProperty(exports, "__esModule", { value: true });
33931 var operators_1 = require("rxjs/operators");
33932 var rxjs_1 = require("rxjs");
33933 var Component_1 = require("../../../Component");
33934 var CreateHandlerBase = /** @class */ (function (_super) {
33935 __extends(CreateHandlerBase, _super);
33936 function CreateHandlerBase(component, container, navigator, viewportCoords, tagCreator) {
33937 var _this = _super.call(this, component, container, navigator, viewportCoords) || this;
33938 _this._tagCreator = tagCreator;
33939 _this._geometryCreated$ = new rxjs_1.Subject();
33942 Object.defineProperty(CreateHandlerBase.prototype, "geometryCreated$", {
33944 return this._geometryCreated$;
33949 CreateHandlerBase.prototype._enable = function () {
33950 this._enableCreate();
33951 this._container.element.classList.add("component-tag-create");
33953 CreateHandlerBase.prototype._disable = function () {
33954 this._container.element.classList.remove("component-tag-create");
33955 this._disableCreate();
33957 CreateHandlerBase.prototype._validateBasic = function (basic) {
33960 return 0 <= x && x <= 1 && 0 <= y && y <= 1;
33962 CreateHandlerBase.prototype._mouseEventToBasic$ = function (mouseEvent$) {
33964 return mouseEvent$.pipe(operators_1.withLatestFrom(this._container.renderService.renderCamera$, this._navigator.stateService.currentTransform$), operators_1.map(function (_a) {
33965 var event = _a[0], camera = _a[1], transform = _a[2];
33966 return _this._mouseEventToBasic(event, _this._container.element, camera, transform);
33969 return CreateHandlerBase;
33970 }(Component_1.TagHandlerBase));
33971 exports.CreateHandlerBase = CreateHandlerBase;
33972 exports.default = CreateHandlerBase;
33974 },{"../../../Component":275,"rxjs":27,"rxjs/operators":225}],358:[function(require,module,exports){
33976 var __extends = (this && this.__extends) || (function () {
33977 var extendStatics = function (d, b) {
33978 extendStatics = Object.setPrototypeOf ||
33979 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
33980 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
33981 return extendStatics(d, b);
33983 return function (d, b) {
33984 extendStatics(d, b);
33985 function __() { this.constructor = d; }
33986 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
33989 Object.defineProperty(exports, "__esModule", { value: true });
33990 var operators_1 = require("rxjs/operators");
33991 var Component_1 = require("../../../Component");
33992 var CreatePointHandler = /** @class */ (function (_super) {
33993 __extends(CreatePointHandler, _super);
33994 function CreatePointHandler() {
33995 return _super !== null && _super.apply(this, arguments) || this;
33997 CreatePointHandler.prototype._enableCreate = function () {
33998 this._container.mouseService.deferPixels(this._name, 4);
33999 this._geometryCreatedSubscription = this._mouseEventToBasic$(this._container.mouseService.proximateClick$).pipe(operators_1.filter(this._validateBasic), operators_1.map(function (basic) {
34000 return new Component_1.PointGeometry(basic);
34002 .subscribe(this._geometryCreated$);
34004 CreatePointHandler.prototype._disableCreate = function () {
34005 this._container.mouseService.undeferPixels(this._name);
34006 this._geometryCreatedSubscription.unsubscribe();
34008 CreatePointHandler.prototype._getNameExtension = function () {
34009 return "create-point";
34011 return CreatePointHandler;
34012 }(Component_1.CreateHandlerBase));
34013 exports.CreatePointHandler = CreatePointHandler;
34014 exports.default = CreatePointHandler;
34016 },{"../../../Component":275,"rxjs/operators":225}],359:[function(require,module,exports){
34018 var __extends = (this && this.__extends) || (function () {
34019 var extendStatics = function (d, b) {
34020 extendStatics = Object.setPrototypeOf ||
34021 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
34022 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
34023 return extendStatics(d, b);
34025 return function (d, b) {
34026 extendStatics(d, b);
34027 function __() { this.constructor = d; }
34028 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
34031 Object.defineProperty(exports, "__esModule", { value: true });
34032 var Component_1 = require("../../../Component");
34033 var CreatePolygonHandler = /** @class */ (function (_super) {
34034 __extends(CreatePolygonHandler, _super);
34035 function CreatePolygonHandler() {
34036 return _super !== null && _super.apply(this, arguments) || this;
34038 CreatePolygonHandler.prototype._addPoint = function (tag, basicPoint) {
34039 tag.addPoint(basicPoint);
34041 Object.defineProperty(CreatePolygonHandler.prototype, "_create$", {
34043 return this._tagCreator.createPolygon$;
34048 CreatePolygonHandler.prototype._getNameExtension = function () {
34049 return "create-polygon";
34051 CreatePolygonHandler.prototype._setVertex2d = function (tag, basicPoint, transform) {
34052 tag.geometry.setVertex2d(tag.geometry.polygon.length - 2, basicPoint, transform);
34054 return CreatePolygonHandler;
34055 }(Component_1.CreateVertexHandler));
34056 exports.CreatePolygonHandler = CreatePolygonHandler;
34057 exports.default = CreatePolygonHandler;
34059 },{"../../../Component":275}],360:[function(require,module,exports){
34061 var __extends = (this && this.__extends) || (function () {
34062 var extendStatics = function (d, b) {
34063 extendStatics = Object.setPrototypeOf ||
34064 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
34065 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
34066 return extendStatics(d, b);
34068 return function (d, b) {
34069 extendStatics(d, b);
34070 function __() { this.constructor = d; }
34071 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
34074 Object.defineProperty(exports, "__esModule", { value: true });
34075 var rxjs_1 = require("rxjs");
34076 var operators_1 = require("rxjs/operators");
34077 var Component_1 = require("../../../Component");
34078 var CreateRectDragHandler = /** @class */ (function (_super) {
34079 __extends(CreateRectDragHandler, _super);
34080 function CreateRectDragHandler() {
34081 return _super !== null && _super.apply(this, arguments) || this;
34083 CreateRectDragHandler.prototype._enableCreate = function () {
34085 this._container.mouseService.claimMouse(this._name, 2);
34086 this._deleteSubscription = this._navigator.stateService.currentTransform$.pipe(operators_1.map(function (transform) { return null; }), operators_1.skip(1))
34087 .subscribe(this._tagCreator.delete$);
34088 this._createSubscription = this._mouseEventToBasic$(this._container.mouseService.filtered$(this._name, this._container.mouseService.mouseDragStart$)).pipe(operators_1.filter(this._validateBasic))
34089 .subscribe(this._tagCreator.createRect$);
34090 this._initializeAnchorIndexingSubscription = this._tagCreator.tag$.pipe(operators_1.filter(function (tag) {
34093 .subscribe(function (tag) {
34094 tag.geometry.initializeAnchorIndexing();
34096 var basicMouse$ = rxjs_1.combineLatest(rxjs_1.merge(this._container.mouseService.filtered$(this._name, this._container.mouseService.mouseMove$), this._container.mouseService.filtered$(this._name, this._container.mouseService.domMouseMove$)), this._container.renderService.renderCamera$).pipe(operators_1.withLatestFrom(this._navigator.stateService.currentTransform$), operators_1.map(function (_a) {
34097 var _b = _a[0], event = _b[0], camera = _b[1], transform = _a[1];
34098 return _this._mouseEventToBasic(event, _this._container.element, camera, transform);
34100 this._setVertexSubscription = this._tagCreator.tag$.pipe(operators_1.switchMap(function (tag) {
34102 rxjs_1.combineLatest(rxjs_1.of(tag), basicMouse$, _this._navigator.stateService.currentTransform$) :
34105 .subscribe(function (_a) {
34106 var tag = _a[0], basicPoint = _a[1], transform = _a[2];
34107 tag.geometry.setOppositeVertex2d(basicPoint, transform);
34109 var basicMouseDragEnd$ = this._container.mouseService.mouseDragEnd$.pipe(operators_1.withLatestFrom(this._mouseEventToBasic$(this._container.mouseService.filtered$(this._name, this._container.mouseService.mouseDrag$)).pipe(operators_1.filter(this._validateBasic)), function (event, basicPoint) {
34111 }), operators_1.share());
34112 this._addPointSubscription = this._tagCreator.tag$.pipe(operators_1.switchMap(function (tag) {
34114 rxjs_1.combineLatest(rxjs_1.of(tag), basicMouseDragEnd$) :
34117 .subscribe(function (_a) {
34118 var tag = _a[0], basicPoint = _a[1];
34119 var rectGeometry = tag.geometry;
34120 if (!rectGeometry.validate(basicPoint)) {
34121 basicPoint = rectGeometry.getNonAdjustedVertex2d(3);
34123 tag.addPoint(basicPoint);
34125 this._geometryCreatedSubscription = this._tagCreator.tag$.pipe(operators_1.switchMap(function (tag) {
34127 tag.created$.pipe(operators_1.map(function (t) {
34132 .subscribe(this._geometryCreated$);
34134 CreateRectDragHandler.prototype._disableCreate = function () {
34135 this._container.mouseService.unclaimMouse(this._name);
34136 this._tagCreator.delete$.next(null);
34137 this._addPointSubscription.unsubscribe();
34138 this._createSubscription.unsubscribe();
34139 this._deleteSubscription.unsubscribe();
34140 this._geometryCreatedSubscription.unsubscribe();
34141 this._initializeAnchorIndexingSubscription.unsubscribe();
34142 this._setVertexSubscription.unsubscribe();
34144 CreateRectDragHandler.prototype._getNameExtension = function () {
34145 return "create-rect-drag";
34147 return CreateRectDragHandler;
34148 }(Component_1.CreateHandlerBase));
34149 exports.CreateRectDragHandler = CreateRectDragHandler;
34150 exports.default = CreateRectDragHandler;
34152 },{"../../../Component":275,"rxjs":27,"rxjs/operators":225}],361:[function(require,module,exports){
34154 var __extends = (this && this.__extends) || (function () {
34155 var extendStatics = function (d, b) {
34156 extendStatics = Object.setPrototypeOf ||
34157 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
34158 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
34159 return extendStatics(d, b);
34161 return function (d, b) {
34162 extendStatics(d, b);
34163 function __() { this.constructor = d; }
34164 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
34167 Object.defineProperty(exports, "__esModule", { value: true });
34168 var operators_1 = require("rxjs/operators");
34169 var Component_1 = require("../../../Component");
34170 var CreateRectHandler = /** @class */ (function (_super) {
34171 __extends(CreateRectHandler, _super);
34172 function CreateRectHandler() {
34173 return _super !== null && _super.apply(this, arguments) || this;
34175 Object.defineProperty(CreateRectHandler.prototype, "_create$", {
34177 return this._tagCreator.createRect$;
34182 CreateRectHandler.prototype._addPoint = function (tag, basicPoint) {
34183 var rectGeometry = tag.geometry;
34184 if (!rectGeometry.validate(basicPoint)) {
34185 basicPoint = rectGeometry.getNonAdjustedVertex2d(3);
34187 tag.addPoint(basicPoint);
34189 CreateRectHandler.prototype._enable = function () {
34190 _super.prototype._enable.call(this);
34191 this._initializeAnchorIndexingSubscription = this._tagCreator.tag$.pipe(operators_1.filter(function (tag) {
34194 .subscribe(function (tag) {
34195 tag.geometry.initializeAnchorIndexing();
34198 CreateRectHandler.prototype._disable = function () {
34199 _super.prototype._disable.call(this);
34200 this._initializeAnchorIndexingSubscription.unsubscribe();
34202 CreateRectHandler.prototype._getNameExtension = function () {
34203 return "create-rect";
34205 CreateRectHandler.prototype._setVertex2d = function (tag, basicPoint, transform) {
34206 tag.geometry.setOppositeVertex2d(basicPoint, transform);
34208 return CreateRectHandler;
34209 }(Component_1.CreateVertexHandler));
34210 exports.CreateRectHandler = CreateRectHandler;
34211 exports.default = CreateRectHandler;
34213 },{"../../../Component":275,"rxjs/operators":225}],362:[function(require,module,exports){
34215 var __extends = (this && this.__extends) || (function () {
34216 var extendStatics = function (d, b) {
34217 extendStatics = Object.setPrototypeOf ||
34218 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
34219 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
34220 return extendStatics(d, b);
34222 return function (d, b) {
34223 extendStatics(d, b);
34224 function __() { this.constructor = d; }
34225 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
34228 Object.defineProperty(exports, "__esModule", { value: true });
34229 var rxjs_1 = require("rxjs");
34230 var operators_1 = require("rxjs/operators");
34231 var Component_1 = require("../../../Component");
34232 var CreateVertexHandler = /** @class */ (function (_super) {
34233 __extends(CreateVertexHandler, _super);
34234 function CreateVertexHandler() {
34235 return _super !== null && _super.apply(this, arguments) || this;
34237 CreateVertexHandler.prototype._enableCreate = function () {
34239 this._container.mouseService.deferPixels(this._name, 4);
34240 var transformChanged$ = this._navigator.stateService.currentTransform$.pipe(operators_1.map(function (transform) { }), operators_1.publishReplay(1), operators_1.refCount());
34241 this._deleteSubscription = transformChanged$.pipe(operators_1.skip(1))
34242 .subscribe(this._tagCreator.delete$);
34243 var basicClick$ = this._mouseEventToBasic$(this._container.mouseService.proximateClick$).pipe(operators_1.share());
34244 this._createSubscription = transformChanged$.pipe(operators_1.switchMap(function () {
34245 return basicClick$.pipe(operators_1.filter(_this._validateBasic), operators_1.take(1));
34247 .subscribe(this._create$);
34248 this._setVertexSubscription = this._tagCreator.tag$.pipe(operators_1.switchMap(function (tag) {
34250 rxjs_1.combineLatest(rxjs_1.of(tag), rxjs_1.merge(_this._container.mouseService.mouseMove$, _this._container.mouseService.domMouseMove$), _this._container.renderService.renderCamera$, _this._navigator.stateService.currentTransform$) :
34253 .subscribe(function (_a) {
34254 var tag = _a[0], event = _a[1], camera = _a[2], transform = _a[3];
34255 var basicPoint = _this._mouseEventToBasic(event, _this._container.element, camera, transform);
34256 _this._setVertex2d(tag, basicPoint, transform);
34258 this._addPointSubscription = this._tagCreator.tag$.pipe(operators_1.switchMap(function (tag) {
34260 rxjs_1.combineLatest(rxjs_1.of(tag), basicClick$) :
34263 .subscribe(function (_a) {
34264 var tag = _a[0], basicPoint = _a[1];
34265 _this._addPoint(tag, basicPoint);
34267 this._geometryCreateSubscription = this._tagCreator.tag$.pipe(operators_1.switchMap(function (tag) {
34269 tag.created$.pipe(operators_1.map(function (t) {
34274 .subscribe(this._geometryCreated$);
34276 CreateVertexHandler.prototype._disableCreate = function () {
34277 this._container.mouseService.undeferPixels(this._name);
34278 this._tagCreator.delete$.next(null);
34279 this._addPointSubscription.unsubscribe();
34280 this._createSubscription.unsubscribe();
34281 this._deleteSubscription.unsubscribe();
34282 this._geometryCreateSubscription.unsubscribe();
34283 this._setVertexSubscription.unsubscribe();
34285 return CreateVertexHandler;
34286 }(Component_1.CreateHandlerBase));
34287 exports.CreateVertexHandler = CreateVertexHandler;
34288 exports.default = CreateVertexHandler;
34290 },{"../../../Component":275,"rxjs":27,"rxjs/operators":225}],363:[function(require,module,exports){
34292 var __extends = (this && this.__extends) || (function () {
34293 var extendStatics = function (d, b) {
34294 extendStatics = Object.setPrototypeOf ||
34295 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
34296 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
34297 return extendStatics(d, b);
34299 return function (d, b) {
34300 extendStatics(d, b);
34301 function __() { this.constructor = d; }
34302 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
34305 Object.defineProperty(exports, "__esModule", { value: true });
34306 var rxjs_1 = require("rxjs");
34307 var operators_1 = require("rxjs/operators");
34308 var Component_1 = require("../../../Component");
34309 var EditVertexHandler = /** @class */ (function (_super) {
34310 __extends(EditVertexHandler, _super);
34311 function EditVertexHandler(component, container, navigator, viewportCoords, tagSet) {
34312 var _this = _super.call(this, component, container, navigator, viewportCoords) || this;
34313 _this._tagSet = tagSet;
34316 EditVertexHandler.prototype._enable = function () {
34318 var interaction$ = this._tagSet.changed$.pipe(operators_1.map(function (tagSet) {
34319 return tagSet.getAll();
34320 }), operators_1.switchMap(function (tags) {
34321 return rxjs_1.from(tags).pipe(operators_1.mergeMap(function (tag) {
34322 return tag.interact$;
34324 }), operators_1.switchMap(function (interaction) {
34325 return rxjs_1.concat(rxjs_1.of(interaction), _this._container.mouseService.documentMouseUp$.pipe(operators_1.map(function () {
34326 return { offsetX: 0, offsetY: 0, operation: Component_1.TagOperation.None, tag: null };
34327 }), operators_1.first()));
34328 }), operators_1.share());
34329 var mouseMove$ = rxjs_1.merge(this._container.mouseService.mouseMove$, this._container.mouseService.domMouseMove$).pipe(operators_1.share());
34330 this._claimMouseSubscription = interaction$.pipe(operators_1.switchMap(function (interaction) {
34331 return !!interaction.tag ? _this._container.mouseService.domMouseDragStart$ : rxjs_1.empty();
34333 .subscribe(function () {
34334 _this._container.mouseService.claimMouse(_this._name, 3);
34336 this._cursorSubscription = interaction$.pipe(operators_1.map(function (interaction) {
34337 return interaction.cursor;
34338 }), operators_1.distinctUntilChanged())
34339 .subscribe(function (cursor) {
34340 var interactionCursors = ["crosshair", "move", "nesw-resize", "nwse-resize"];
34341 for (var _i = 0, interactionCursors_1 = interactionCursors; _i < interactionCursors_1.length; _i++) {
34342 var interactionCursor = interactionCursors_1[_i];
34343 _this._container.element.classList.remove("component-tag-edit-" + interactionCursor);
34346 _this._container.element.classList.add("component-tag-edit-" + cursor);
34349 this._unclaimMouseSubscription = this._container.mouseService
34350 .filtered$(this._name, this._container.mouseService.domMouseDragEnd$)
34351 .subscribe(function (e) {
34352 _this._container.mouseService.unclaimMouse(_this._name);
34354 this._preventDefaultSubscription = interaction$.pipe(operators_1.switchMap(function (interaction) {
34355 return !!interaction.tag ?
34356 _this._container.mouseService.documentMouseMove$ :
34359 .subscribe(function (event) {
34360 event.preventDefault(); // prevent selection of content outside the viewer
34362 this._updateGeometrySubscription = interaction$.pipe(operators_1.switchMap(function (interaction) {
34363 if (interaction.operation === Component_1.TagOperation.None || !interaction.tag) {
34364 return rxjs_1.empty();
34366 var mouseDrag$ = _this._container.mouseService
34367 .filtered$(_this._name, _this._container.mouseService.domMouseDrag$).pipe(operators_1.filter(function (event) {
34368 return _this._viewportCoords.insideElement(event, _this._container.element);
34370 return rxjs_1.combineLatest(mouseDrag$, _this._container.renderService.renderCamera$).pipe(operators_1.withLatestFrom(rxjs_1.of(interaction), _this._navigator.stateService.currentTransform$, function (_a, i, transform) {
34371 var event = _a[0], render = _a[1];
34372 return [event, render, i, transform];
34375 .subscribe(function (_a) {
34376 var mouseEvent = _a[0], renderCamera = _a[1], interaction = _a[2], transform = _a[3];
34377 var basic = _this._mouseEventToBasic(mouseEvent, _this._container.element, renderCamera, transform, interaction.offsetX, interaction.offsetY);
34378 var geometry = interaction.tag.geometry;
34379 if (interaction.operation === Component_1.TagOperation.Centroid) {
34380 geometry.setCentroid2d(basic, transform);
34382 else if (interaction.operation === Component_1.TagOperation.Vertex) {
34383 geometry.setVertex2d(interaction.vertexIndex, basic, transform);
34387 EditVertexHandler.prototype._disable = function () {
34388 this._claimMouseSubscription.unsubscribe();
34389 this._cursorSubscription.unsubscribe();
34390 this._preventDefaultSubscription.unsubscribe();
34391 this._unclaimMouseSubscription.unsubscribe();
34392 this._updateGeometrySubscription.unsubscribe();
34394 EditVertexHandler.prototype._getNameExtension = function () {
34395 return "edit-vertex";
34397 return EditVertexHandler;
34398 }(Component_1.TagHandlerBase));
34399 exports.EditVertexHandler = EditVertexHandler;
34400 exports.default = EditVertexHandler;
34403 },{"../../../Component":275,"rxjs":27,"rxjs/operators":225}],364:[function(require,module,exports){
34405 var __extends = (this && this.__extends) || (function () {
34406 var extendStatics = function (d, b) {
34407 extendStatics = Object.setPrototypeOf ||
34408 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
34409 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
34410 return extendStatics(d, b);
34412 return function (d, b) {
34413 extendStatics(d, b);
34414 function __() { this.constructor = d; }
34415 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
34418 Object.defineProperty(exports, "__esModule", { value: true });
34419 var Component_1 = require("../../../Component");
34420 var TagHandlerBase = /** @class */ (function (_super) {
34421 __extends(TagHandlerBase, _super);
34422 function TagHandlerBase(component, container, navigator, viewportCoords) {
34423 var _this = _super.call(this, component, container, navigator) || this;
34424 _this._name = _this._component.name + "-" + _this._getNameExtension();
34425 _this._viewportCoords = viewportCoords;
34428 TagHandlerBase.prototype._getConfiguration = function (enable) {
34431 TagHandlerBase.prototype._mouseEventToBasic = function (event, element, camera, transform, offsetX, offsetY) {
34432 offsetX = offsetX != null ? offsetX : 0;
34433 offsetY = offsetY != null ? offsetY : 0;
34434 var _a = this._viewportCoords.canvasPosition(event, element), canvasX = _a[0], canvasY = _a[1];
34435 var basic = this._viewportCoords.canvasToBasic(canvasX - offsetX, canvasY - offsetY, element, transform, camera.perspective);
34438 return TagHandlerBase;
34439 }(Component_1.HandlerBase));
34440 exports.TagHandlerBase = TagHandlerBase;
34441 exports.default = TagHandlerBase;
34444 },{"../../../Component":275}],365:[function(require,module,exports){
34446 Object.defineProperty(exports, "__esModule", { value: true });
34447 var operators_1 = require("rxjs/operators");
34448 var THREE = require("three");
34449 var vd = require("virtual-dom");
34450 var rxjs_1 = require("rxjs");
34451 var Component_1 = require("../../../Component");
34452 var Geo_1 = require("../../../Geo");
34453 var OutlineCreateTag = /** @class */ (function () {
34454 function OutlineCreateTag(geometry, options, transform, viewportCoords) {
34456 this._geometry = geometry;
34457 this._options = { color: options.color == null ? 0xFFFFFF : options.color };
34458 this._transform = transform;
34459 this._viewportCoords = !!viewportCoords ? viewportCoords : new Geo_1.ViewportCoords();
34460 this._outline = this._createOutine();
34461 this._glObjects = [this._outline];
34462 this._aborted$ = new rxjs_1.Subject();
34463 this._created$ = new rxjs_1.Subject();
34464 this._glObjectsChanged$ = new rxjs_1.Subject();
34465 this._geometryChangedSubscription = this._geometry.changed$
34466 .subscribe(function (vertexGeometry) {
34467 _this._disposeOutline();
34468 _this._outline = _this._createOutine();
34469 _this._glObjects = [_this._outline];
34470 _this._glObjectsChanged$.next(_this);
34473 Object.defineProperty(OutlineCreateTag.prototype, "geometry", {
34475 return this._geometry;
34480 Object.defineProperty(OutlineCreateTag.prototype, "glObjects", {
34482 return this._glObjects;
34487 Object.defineProperty(OutlineCreateTag.prototype, "aborted$", {
34489 return this._aborted$;
34494 Object.defineProperty(OutlineCreateTag.prototype, "created$", {
34496 return this._created$;
34501 Object.defineProperty(OutlineCreateTag.prototype, "glObjectsChanged$", {
34503 return this._glObjectsChanged$;
34508 Object.defineProperty(OutlineCreateTag.prototype, "geometryChanged$", {
34511 return this._geometry.changed$.pipe(operators_1.map(function (geometry) {
34518 OutlineCreateTag.prototype.dispose = function () {
34519 this._disposeOutline();
34520 this._geometryChangedSubscription.unsubscribe();
34522 OutlineCreateTag.prototype.getDOMObjects = function (camera, size) {
34526 offsetHeight: size.height, offsetWidth: size.width,
34528 var abort = function (e) {
34529 e.stopPropagation();
34530 _this._aborted$.next(_this);
34532 if (this._geometry instanceof Component_1.RectGeometry) {
34533 var anchorIndex = this._geometry.anchorIndex;
34534 var vertexIndex = anchorIndex === undefined ? 1 : anchorIndex;
34535 var _a = this._geometry.getVertex2d(vertexIndex), basicX = _a[0], basicY = _a[1];
34536 var canvasPoint = this._viewportCoords.basicToCanvasSafe(basicX, basicY, container, this._transform, camera);
34537 if (canvasPoint != null) {
34538 var background = this._colorToBackground(this._options.color);
34539 var transform = this._canvasToTransform(canvasPoint);
34540 var pointProperties = {
34541 style: { background: background, transform: transform },
34543 var completerProperties = {
34545 style: { transform: transform },
34547 vNodes.push(vd.h("div.TagInteractor", completerProperties, []));
34548 vNodes.push(vd.h("div.TagVertex", pointProperties, []));
34551 else if (this._geometry instanceof Component_1.PolygonGeometry) {
34552 var polygonGeometry_1 = this._geometry;
34553 var _b = polygonGeometry_1.getVertex2d(0), firstVertexBasicX = _b[0], firstVertexBasicY = _b[1];
34554 var firstVertexCanvas = this._viewportCoords.basicToCanvasSafe(firstVertexBasicX, firstVertexBasicY, container, this._transform, camera);
34555 if (firstVertexCanvas != null) {
34556 var firstOnclick = polygonGeometry_1.polygon.length > 4 ?
34558 e.stopPropagation();
34559 polygonGeometry_1.removeVertex2d(polygonGeometry_1.polygon.length - 2);
34560 _this._created$.next(_this);
34563 var transform = this._canvasToTransform(firstVertexCanvas);
34564 var completerProperties = {
34565 onclick: firstOnclick,
34566 style: { transform: transform },
34568 var firstClass = polygonGeometry_1.polygon.length > 4 ?
34571 vNodes.push(vd.h("div." + firstClass, completerProperties, []));
34573 if (polygonGeometry_1.polygon.length > 3) {
34574 var _c = polygonGeometry_1.getVertex2d(polygonGeometry_1.polygon.length - 3), lastVertexBasicX = _c[0], lastVertexBasicY = _c[1];
34575 var lastVertexCanvas = this._viewportCoords.basicToCanvasSafe(lastVertexBasicX, lastVertexBasicY, container, this._transform, camera);
34576 if (lastVertexCanvas != null) {
34577 var remove = function (e) {
34578 e.stopPropagation();
34579 polygonGeometry_1.removeVertex2d(polygonGeometry_1.polygon.length - 3);
34581 var transform = this._canvasToTransform(lastVertexCanvas);
34582 var completerProperties = {
34584 style: { transform: transform },
34586 vNodes.push(vd.h("div.TagInteractor", completerProperties, []));
34589 var verticesBasic = polygonGeometry_1.polygon.slice();
34590 verticesBasic.splice(-2, 2);
34591 for (var _i = 0, verticesBasic_1 = verticesBasic; _i < verticesBasic_1.length; _i++) {
34592 var vertexBasic = verticesBasic_1[_i];
34593 var vertexCanvas = this._viewportCoords.basicToCanvasSafe(vertexBasic[0], vertexBasic[1], container, this._transform, camera);
34594 if (vertexCanvas != null) {
34595 var background = this._colorToBackground(this._options.color);
34596 var transform = this._canvasToTransform(vertexCanvas);
34597 var pointProperties = {
34599 background: background,
34600 transform: transform,
34603 vNodes.push(vd.h("div.TagVertex", pointProperties, []));
34609 OutlineCreateTag.prototype.addPoint = function (point) {
34610 if (this._geometry instanceof Component_1.RectGeometry) {
34611 var rectGeometry = this._geometry;
34612 if (!rectGeometry.validate(point)) {
34615 this._created$.next(this);
34617 else if (this._geometry instanceof Component_1.PolygonGeometry) {
34618 var polygonGeometry = this._geometry;
34619 polygonGeometry.addVertex2d(point);
34622 OutlineCreateTag.prototype._canvasToTransform = function (canvas) {
34623 var canvasX = Math.round(canvas[0]);
34624 var canvasY = Math.round(canvas[1]);
34625 var transform = "translate(-50%,-50%) translate(" + canvasX + "px," + canvasY + "px)";
34628 OutlineCreateTag.prototype._colorToBackground = function (color) {
34629 return "#" + ("000000" + color.toString(16)).substr(-6);
34631 OutlineCreateTag.prototype._createOutine = function () {
34632 var polygon3d = this._geometry instanceof Component_1.RectGeometry ?
34633 this._geometry.getPoints3d(this._transform) :
34634 this._geometry.getVertices3d(this._transform);
34635 var positions = this._getLinePositions(polygon3d);
34636 var geometry = new THREE.BufferGeometry();
34637 geometry.addAttribute("position", new THREE.BufferAttribute(positions, 3));
34638 var material = new THREE.LineBasicMaterial({
34639 color: this._options.color,
34642 return new THREE.Line(geometry, material);
34644 OutlineCreateTag.prototype._disposeOutline = function () {
34645 if (this._outline == null) {
34648 var line = this._outline;
34649 line.geometry.dispose();
34650 line.material.dispose();
34651 this._outline = null;
34652 this._glObjects = [];
34654 OutlineCreateTag.prototype._getLinePositions = function (polygon3d) {
34655 var length = polygon3d.length;
34656 var positions = new Float32Array(length * 3);
34657 for (var i = 0; i < length; ++i) {
34659 var position = polygon3d[i];
34660 positions[index] = position[0];
34661 positions[index + 1] = position[1];
34662 positions[index + 2] = position[2];
34666 return OutlineCreateTag;
34668 exports.OutlineCreateTag = OutlineCreateTag;
34669 exports.default = OutlineCreateTag;
34672 },{"../../../Component":275,"../../../Geo":278,"rxjs":27,"rxjs/operators":225,"three":226,"virtual-dom":231}],366:[function(require,module,exports){
34674 var __extends = (this && this.__extends) || (function () {
34675 var extendStatics = function (d, b) {
34676 extendStatics = Object.setPrototypeOf ||
34677 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
34678 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
34679 return extendStatics(d, b);
34681 return function (d, b) {
34682 extendStatics(d, b);
34683 function __() { this.constructor = d; }
34684 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
34687 Object.defineProperty(exports, "__esModule", { value: true });
34688 var THREE = require("three");
34689 var vd = require("virtual-dom");
34690 var Component_1 = require("../../../Component");
34692 * @class OutlineRenderTag
34693 * @classdesc Tag visualizing the properties of an OutlineTag.
34695 var OutlineRenderTag = /** @class */ (function (_super) {
34696 __extends(OutlineRenderTag, _super);
34697 function OutlineRenderTag(tag, transform) {
34698 var _this = _super.call(this, tag, transform) || this;
34699 _this._fill = !transform.gpano ?
34700 _this._createFill() :
34701 transform.fullPano &&
34702 tag.domain === Component_1.TagDomain.TwoDimensional &&
34703 tag.geometry instanceof Component_1.PolygonGeometry ?
34704 _this._createFill() :
34706 _this._holes = _this._tag.lineWidth >= 1 ?
34707 _this._createHoles() :
34709 _this._outline = _this._tag.lineWidth >= 1 ?
34710 _this._createOutline() :
34712 _this._geometryChangedSubscription = _this._tag.geometry.changed$
34713 .subscribe(function () {
34714 if (_this._fill != null) {
34715 _this._updateFillGeometry();
34717 if (_this._holes.length > 0) {
34718 _this._updateHoleGeometries();
34720 if (_this._outline != null) {
34721 _this._updateOulineGeometry();
34724 _this._changedSubscription = _this._tag.changed$
34725 .subscribe(function () {
34726 var glObjectsChanged = false;
34727 if (_this._fill != null) {
34728 _this._updateFillMaterial(_this._fill.material);
34730 if (_this._outline == null) {
34731 if (_this._tag.lineWidth >= 1) {
34732 _this._holes = _this._createHoles();
34733 _this._outline = _this._createOutline();
34734 glObjectsChanged = true;
34738 _this._updateHoleMaterials();
34739 _this._updateOutlineMaterial();
34741 if (glObjectsChanged) {
34742 _this._glObjectsChanged$.next(_this);
34747 OutlineRenderTag.prototype.dispose = function () {
34748 this._disposeFill();
34749 this._disposeHoles();
34750 this._disposeOutline();
34751 this._changedSubscription.unsubscribe();
34752 this._geometryChangedSubscription.unsubscribe();
34754 OutlineRenderTag.prototype.getDOMObjects = function (atlas, camera, size) {
34757 var isRect = this._tag.geometry instanceof Component_1.RectGeometry;
34758 var isPerspective = !this._transform.gpano;
34760 offsetHeight: size.height, offsetWidth: size.width,
34762 if (this._tag.icon != null && (isRect || isPerspective)) {
34763 var _a = this._tag.geometry instanceof Component_1.RectGeometry ?
34764 this._tag.geometry.getVertex2d(this._tag.iconIndex) :
34765 this._tag.geometry.getPoleOfInaccessibility2d(), iconBasicX = _a[0], iconBasicY = _a[1];
34766 var iconCanvas = this._viewportCoords.basicToCanvasSafe(iconBasicX, iconBasicY, container, this._transform, camera);
34767 if (iconCanvas != null) {
34768 var interact = function (e) {
34769 _this._interact$.next({ offsetX: 0, offsetY: 0, operation: Component_1.TagOperation.None, tag: _this._tag });
34771 if (atlas.loaded) {
34772 var sprite = atlas.getDOMSprite(this._tag.icon, this._tag.iconFloat);
34773 var iconCanvasX = Math.round(iconCanvas[0]);
34774 var iconCanvasY = Math.round(iconCanvas[1]);
34775 var transform = "translate(" + iconCanvasX + "px," + iconCanvasY + "px)";
34776 var click = function (e) {
34777 e.stopPropagation();
34778 _this._tag.click$.next(_this._tag);
34782 onmousedown: interact,
34783 style: { transform: transform },
34785 vNodes.push(vd.h("div.TagSymbol", properties, [sprite]));
34789 else if (this._tag.text != null && (isRect || isPerspective)) {
34790 var _b = this._tag.geometry instanceof Component_1.RectGeometry ?
34791 this._tag.geometry.getVertex2d(3) :
34792 this._tag.geometry.getPoleOfInaccessibility2d(), textBasicX = _b[0], textBasicY = _b[1];
34793 var textCanvas = this._viewportCoords.basicToCanvasSafe(textBasicX, textBasicY, container, this._transform, camera);
34794 if (textCanvas != null) {
34795 var textCanvasX = Math.round(textCanvas[0]);
34796 var textCanvasY = Math.round(textCanvas[1]);
34797 var transform = this._tag.geometry instanceof Component_1.RectGeometry ?
34798 "translate(" + textCanvasX + "px," + textCanvasY + "px)" :
34799 "translate(-50%, -50%) translate(" + textCanvasX + "px," + textCanvasY + "px)";
34800 var interact = function (e) {
34801 _this._interact$.next({ offsetX: 0, offsetY: 0, operation: Component_1.TagOperation.None, tag: _this._tag });
34804 onmousedown: interact,
34806 color: this._colorToCss(this._tag.textColor),
34807 transform: transform,
34809 textContent: this._tag.text,
34811 vNodes.push(vd.h("span.TagSymbol", properties, []));
34814 if (!this._tag.editable) {
34817 var lineColor = this._colorToCss(this._tag.lineColor);
34818 if (this._tag.geometry instanceof Component_1.RectGeometry) {
34819 var _c = this._tag.geometry.getCentroid2d(), centroidBasicX = _c[0], centroidBasicY = _c[1];
34820 var centroidCanvas = this._viewportCoords.basicToCanvasSafe(centroidBasicX, centroidBasicY, container, this._transform, camera);
34821 if (centroidCanvas != null) {
34822 var interact = this._interact(Component_1.TagOperation.Centroid, "move");
34823 var centroidCanvasX = Math.round(centroidCanvas[0]);
34824 var centroidCanvasY = Math.round(centroidCanvas[1]);
34825 var transform = "translate(-50%, -50%) translate(" + centroidCanvasX + "px," + centroidCanvasY + "px)";
34827 onmousedown: interact,
34828 style: { background: lineColor, transform: transform },
34830 vNodes.push(vd.h("div.TagMover", properties, []));
34833 var vertices2d = this._tag.geometry.getVertices2d();
34834 for (var i = 0; i < vertices2d.length - 1; i++) {
34836 ((this._tag.icon != null && i === this._tag.iconIndex) ||
34837 (this._tag.icon == null && this._tag.text != null && i === 3))) {
34840 var _d = vertices2d[i], vertexBasicX = _d[0], vertexBasicY = _d[1];
34841 var vertexCanvas = this._viewportCoords.basicToCanvasSafe(vertexBasicX, vertexBasicY, container, this._transform, camera);
34842 if (vertexCanvas == null) {
34845 var cursor = isRect ?
34846 i % 2 === 0 ? "nesw-resize" : "nwse-resize" :
34848 var interact = this._interact(Component_1.TagOperation.Vertex, cursor, i);
34849 var vertexCanvasX = Math.round(vertexCanvas[0]);
34850 var vertexCanvasY = Math.round(vertexCanvas[1]);
34851 var transform = "translate(-50%, -50%) translate(" + vertexCanvasX + "px," + vertexCanvasY + "px)";
34853 onmousedown: interact,
34854 style: { background: lineColor, transform: transform, cursor: cursor },
34856 vNodes.push(vd.h("div.TagResizer", properties, []));
34857 if (!this._tag.indicateVertices) {
34860 var pointProperties = {
34861 style: { background: lineColor, transform: transform },
34863 vNodes.push(vd.h("div.TagVertex", pointProperties, []));
34867 OutlineRenderTag.prototype.getGLObjects = function () {
34868 var glObjects = [];
34869 if (this._fill != null) {
34870 glObjects.push(this._fill);
34872 for (var _i = 0, _a = this._holes; _i < _a.length; _i++) {
34874 glObjects.push(hole);
34876 if (this._outline != null) {
34877 glObjects.push(this._outline);
34881 OutlineRenderTag.prototype.getRetrievableObjects = function () {
34882 return this._fill != null ? [this._fill] : [];
34884 OutlineRenderTag.prototype._colorToCss = function (color) {
34885 return "#" + ("000000" + color.toString(16)).substr(-6);
34887 OutlineRenderTag.prototype._createFill = function () {
34888 var triangles = this._getTriangles();
34889 var positions = new Float32Array(triangles);
34890 var geometry = new THREE.BufferGeometry();
34891 geometry.addAttribute("position", new THREE.BufferAttribute(positions, 3));
34892 geometry.computeBoundingSphere();
34893 var material = new THREE.MeshBasicMaterial({ side: THREE.DoubleSide, transparent: true });
34894 this._updateFillMaterial(material);
34895 return new THREE.Mesh(geometry, material);
34897 OutlineRenderTag.prototype._createHoles = function () {
34899 if (this._tag.geometry instanceof Component_1.PolygonGeometry) {
34900 var holes3d = this._getHoles3d();
34901 for (var _i = 0, holes3d_1 = holes3d; _i < holes3d_1.length; _i++) {
34902 var holePoints3d = holes3d_1[_i];
34903 var hole = this._createLine(holePoints3d);
34909 OutlineRenderTag.prototype._createLine = function (points3d) {
34910 var positions = this._getLinePositions(points3d);
34911 var geometry = new THREE.BufferGeometry();
34912 geometry.addAttribute("position", new THREE.BufferAttribute(positions, 3));
34913 geometry.computeBoundingSphere();
34914 var material = new THREE.LineBasicMaterial();
34915 this._updateLineBasicMaterial(material);
34916 var line = new THREE.Line(geometry, material);
34917 line.renderOrder = 1;
34920 OutlineRenderTag.prototype._createOutline = function () {
34921 return this._createLine(this._getPoints3d());
34923 OutlineRenderTag.prototype._disposeFill = function () {
34924 if (this._fill == null) {
34927 this._fill.geometry.dispose();
34928 this._fill.material.dispose();
34931 OutlineRenderTag.prototype._disposeHoles = function () {
34932 for (var _i = 0, _a = this._holes; _i < _a.length; _i++) {
34934 hole.geometry.dispose();
34935 hole.material.dispose();
34939 OutlineRenderTag.prototype._disposeOutline = function () {
34940 if (this._outline == null) {
34943 this._outline.geometry.dispose();
34944 this._outline.material.dispose();
34945 this._outline = null;
34947 OutlineRenderTag.prototype._getLinePositions = function (points3d) {
34948 var length = points3d.length;
34949 var positions = new Float32Array(length * 3);
34950 for (var i = 0; i < length; ++i) {
34952 var position = points3d[i];
34953 positions[index + 0] = position[0];
34954 positions[index + 1] = position[1];
34955 positions[index + 2] = position[2];
34959 OutlineRenderTag.prototype._getHoles3d = function () {
34960 var polygonGeometry = this._tag.geometry;
34961 return this._in3dDomain() ?
34962 polygonGeometry.getHoleVertices3d(this._transform) :
34963 polygonGeometry.getHolePoints3d(this._transform);
34965 OutlineRenderTag.prototype._getPoints3d = function () {
34966 return this._in3dDomain() ?
34967 this._tag.geometry.getVertices3d(this._transform) :
34968 this._tag.geometry.getPoints3d(this._transform);
34970 OutlineRenderTag.prototype._getTriangles = function () {
34971 return this._in3dDomain() ?
34972 this._tag.geometry.get3dDomainTriangles3d(this._transform) :
34973 this._tag.geometry.getTriangles3d(this._transform);
34975 OutlineRenderTag.prototype._in3dDomain = function () {
34976 return this._tag.geometry instanceof Component_1.PolygonGeometry && this._tag.domain === Component_1.TagDomain.ThreeDimensional;
34978 OutlineRenderTag.prototype._interact = function (operation, cursor, vertexIndex) {
34980 return function (e) {
34981 var offsetX = e.offsetX - e.target.offsetWidth / 2;
34982 var offsetY = e.offsetY - e.target.offsetHeight / 2;
34983 _this._interact$.next({
34987 operation: operation,
34989 vertexIndex: vertexIndex,
34993 OutlineRenderTag.prototype._updateFillGeometry = function () {
34994 var triangles = this._getTriangles();
34995 var positions = new Float32Array(triangles);
34996 var geometry = this._fill.geometry;
34997 var attribute = geometry.getAttribute("position");
34998 if (attribute.array.length === positions.length) {
34999 attribute.set(positions);
35000 attribute.needsUpdate = true;
35003 geometry.removeAttribute("position");
35004 geometry.addAttribute("position", new THREE.BufferAttribute(positions, 3));
35006 geometry.computeBoundingSphere();
35008 OutlineRenderTag.prototype._updateFillMaterial = function (material) {
35009 material.color = new THREE.Color(this._tag.fillColor);
35010 material.opacity = this._tag.fillOpacity;
35011 material.needsUpdate = true;
35013 OutlineRenderTag.prototype._updateHoleGeometries = function () {
35014 var holes3d = this._getHoles3d();
35015 if (holes3d.length !== this._holes.length) {
35016 throw new Error("Changing the number of holes is not supported.");
35018 for (var i = 0; i < this._holes.length; i++) {
35019 var holePoints3d = holes3d[i];
35020 var hole = this._holes[i];
35021 this._updateLine(hole, holePoints3d);
35024 OutlineRenderTag.prototype._updateHoleMaterials = function () {
35025 for (var _i = 0, _a = this._holes; _i < _a.length; _i++) {
35027 var material = hole.material;
35028 this._updateLineBasicMaterial(material);
35031 OutlineRenderTag.prototype._updateLine = function (line, points3d) {
35032 var positions = this._getLinePositions(points3d);
35033 var geometry = line.geometry;
35034 var attribute = geometry.getAttribute("position");
35035 attribute.set(positions);
35036 attribute.needsUpdate = true;
35037 geometry.computeBoundingSphere();
35039 OutlineRenderTag.prototype._updateOulineGeometry = function () {
35040 this._updateLine(this._outline, this._getPoints3d());
35042 OutlineRenderTag.prototype._updateOutlineMaterial = function () {
35043 var material = this._outline.material;
35044 this._updateLineBasicMaterial(material);
35046 OutlineRenderTag.prototype._updateLineBasicMaterial = function (material) {
35047 material.color = new THREE.Color(this._tag.lineColor);
35048 material.linewidth = Math.max(this._tag.lineWidth, 1);
35049 material.visible = this._tag.lineWidth >= 1 && this._tag.lineOpacity > 0;
35050 material.opacity = this._tag.lineOpacity;
35051 material.transparent = this._tag.lineOpacity < 1;
35052 material.needsUpdate = true;
35054 return OutlineRenderTag;
35055 }(Component_1.RenderTag));
35056 exports.OutlineRenderTag = OutlineRenderTag;
35059 },{"../../../Component":275,"three":226,"virtual-dom":231}],367:[function(require,module,exports){
35061 var __extends = (this && this.__extends) || (function () {
35062 var extendStatics = function (d, b) {
35063 extendStatics = Object.setPrototypeOf ||
35064 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
35065 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
35066 return extendStatics(d, b);
35068 return function (d, b) {
35069 extendStatics(d, b);
35070 function __() { this.constructor = d; }
35071 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
35074 Object.defineProperty(exports, "__esModule", { value: true });
35075 var rxjs_1 = require("rxjs");
35076 var Component_1 = require("../../../Component");
35077 var Viewer_1 = require("../../../Viewer");
35079 * @class OutlineTag
35081 * @classdesc Tag holding properties for visualizing a geometry outline.
35085 * var geometry = new Mapillary.TagComponent.RectGeometry([0.3, 0.3, 0.5, 0.4]);
35086 * var tag = new Mapillary.TagComponent.OutlineTag(
35089 * { editable: true, lineColor: 0xff0000 });
35091 * tagComponent.add([tag]);
35094 var OutlineTag = /** @class */ (function (_super) {
35095 __extends(OutlineTag, _super);
35097 * Create an outline tag.
35101 * @param {string} id - Unique identifier of the tag.
35102 * @param {VertexGeometry} geometry - Geometry defining vertices of tag.
35103 * @param {IOutlineTagOptions} options - Options defining the visual appearance and
35104 * behavior of the outline tag.
35106 function OutlineTag(id, geometry, options) {
35107 var _this = _super.call(this, id, geometry) || this;
35108 options = !!options ? options : {};
35109 var domain = options.domain != null && geometry instanceof Component_1.PolygonGeometry ?
35110 options.domain : Component_1.TagDomain.TwoDimensional;
35111 var twoDimensionalPolygon = _this._twoDimensionalPolygon(domain, geometry);
35112 _this._domain = domain;
35113 _this._editable = options.editable == null || twoDimensionalPolygon ? false : options.editable;
35114 _this._fillColor = options.fillColor == null ? 0xFFFFFF : options.fillColor;
35115 _this._fillOpacity = options.fillOpacity == null ? 0.0 : options.fillOpacity;
35116 _this._icon = options.icon === undefined ? null : options.icon;
35117 _this._iconFloat = options.iconFloat == null ? Viewer_1.Alignment.Center : options.iconFloat;
35118 _this._iconIndex = options.iconIndex == null ? 3 : options.iconIndex;
35119 _this._indicateVertices = options.indicateVertices == null ? true : options.indicateVertices;
35120 _this._lineColor = options.lineColor == null ? 0xFFFFFF : options.lineColor;
35121 _this._lineOpacity = options.lineOpacity == null ? 1 : options.lineOpacity;
35122 _this._lineWidth = options.lineWidth == null ? 1 : options.lineWidth;
35123 _this._text = options.text === undefined ? null : options.text;
35124 _this._textColor = options.textColor == null ? 0xFFFFFF : options.textColor;
35125 _this._click$ = new rxjs_1.Subject();
35127 .subscribe(function (t) {
35128 _this.fire(OutlineTag.click, _this);
35132 Object.defineProperty(OutlineTag.prototype, "click$", {
35134 * Click observable.
35136 * @description An observable emitting the tag when the icon of the
35137 * tag has been clicked.
35139 * @returns {Observable<Tag>}
35142 return this._click$;
35147 Object.defineProperty(OutlineTag.prototype, "domain", {
35149 * Get domain property.
35151 * @description Readonly property that can only be set in constructor.
35153 * @returns Value indicating the domain of the tag.
35156 return this._domain;
35161 Object.defineProperty(OutlineTag.prototype, "editable", {
35163 * Get editable property.
35164 * @returns {boolean} Value indicating if tag is editable.
35167 return this._editable;
35170 * Set editable property.
35173 * @fires Tag#changed
35175 set: function (value) {
35176 if (this._twoDimensionalPolygon(this._domain, this._geometry)) {
35179 this._editable = value;
35180 this._notifyChanged$.next(this);
35185 Object.defineProperty(OutlineTag.prototype, "fillColor", {
35187 * Get fill color property.
35188 * @returns {number}
35191 return this._fillColor;
35194 * Set fill color property.
35197 * @fires Tag#changed
35199 set: function (value) {
35200 this._fillColor = value;
35201 this._notifyChanged$.next(this);
35206 Object.defineProperty(OutlineTag.prototype, "fillOpacity", {
35208 * Get fill opacity property.
35209 * @returns {number}
35212 return this._fillOpacity;
35215 * Set fill opacity property.
35218 * @fires Tag#changed
35220 set: function (value) {
35221 this._fillOpacity = value;
35222 this._notifyChanged$.next(this);
35227 Object.defineProperty(OutlineTag.prototype, "geometry", {
35230 return this._geometry;
35235 Object.defineProperty(OutlineTag.prototype, "icon", {
35237 * Get icon property.
35238 * @returns {string}
35244 * Set icon property.
35247 * @fires Tag#changed
35249 set: function (value) {
35250 this._icon = value;
35251 this._notifyChanged$.next(this);
35256 Object.defineProperty(OutlineTag.prototype, "iconFloat", {
35258 * Get icon float property.
35259 * @returns {Alignment}
35262 return this._iconFloat;
35265 * Set icon float property.
35266 * @param {Alignment}
35268 * @fires Tag#changed
35270 set: function (value) {
35271 this._iconFloat = value;
35272 this._notifyChanged$.next(this);
35277 Object.defineProperty(OutlineTag.prototype, "iconIndex", {
35279 * Get icon index property.
35280 * @returns {number}
35283 return this._iconIndex;
35286 * Set icon index property.
35289 * @fires Tag#changed
35291 set: function (value) {
35292 this._iconIndex = value;
35293 this._notifyChanged$.next(this);
35298 Object.defineProperty(OutlineTag.prototype, "indicateVertices", {
35300 * Get indicate vertices property.
35301 * @returns {boolean} Value indicating if vertices should be indicated
35302 * when tag is editable.
35305 return this._indicateVertices;
35308 * Set indicate vertices property.
35311 * @fires Tag#changed
35313 set: function (value) {
35314 this._indicateVertices = value;
35315 this._notifyChanged$.next(this);
35320 Object.defineProperty(OutlineTag.prototype, "lineColor", {
35322 * Get line color property.
35323 * @returns {number}
35326 return this._lineColor;
35329 * Set line color property.
35332 * @fires Tag#changed
35334 set: function (value) {
35335 this._lineColor = value;
35336 this._notifyChanged$.next(this);
35341 Object.defineProperty(OutlineTag.prototype, "lineOpacity", {
35343 * Get line opacity property.
35344 * @returns {number}
35347 return this._lineOpacity;
35350 * Set line opacity property.
35353 * @fires Tag#changed
35355 set: function (value) {
35356 this._lineOpacity = value;
35357 this._notifyChanged$.next(this);
35362 Object.defineProperty(OutlineTag.prototype, "lineWidth", {
35364 * Get line width property.
35365 * @returns {number}
35368 return this._lineWidth;
35371 * Set line width property.
35374 * @fires Tag#changed
35376 set: function (value) {
35377 this._lineWidth = value;
35378 this._notifyChanged$.next(this);
35383 Object.defineProperty(OutlineTag.prototype, "text", {
35385 * Get text property.
35386 * @returns {string}
35392 * Set text property.
35395 * @fires Tag#changed
35397 set: function (value) {
35398 this._text = value;
35399 this._notifyChanged$.next(this);
35404 Object.defineProperty(OutlineTag.prototype, "textColor", {
35406 * Get text color property.
35407 * @returns {number}
35410 return this._textColor;
35413 * Set text color property.
35416 * @fires Tag#changed
35418 set: function (value) {
35419 this._textColor = value;
35420 this._notifyChanged$.next(this);
35426 * Set options for tag.
35428 * @description Sets all the option properties provided and keeps
35429 * the rest of the values as is.
35431 * @param {IOutlineTagOptions} options - Outline tag options
35433 * @fires {Tag#changed}
35435 OutlineTag.prototype.setOptions = function (options) {
35436 var twoDimensionalPolygon = this._twoDimensionalPolygon(this._domain, this._geometry);
35437 this._editable = twoDimensionalPolygon || options.editable == null ? this._editable : options.editable;
35438 this._icon = options.icon === undefined ? this._icon : options.icon;
35439 this._iconFloat = options.iconFloat == null ? this._iconFloat : options.iconFloat;
35440 this._iconIndex = options.iconIndex == null ? this._iconIndex : options.iconIndex;
35441 this._indicateVertices = options.indicateVertices == null ? this._indicateVertices : options.indicateVertices;
35442 this._lineColor = options.lineColor == null ? this._lineColor : options.lineColor;
35443 this._lineWidth = options.lineWidth == null ? this._lineWidth : options.lineWidth;
35444 this._fillColor = options.fillColor == null ? this._fillColor : options.fillColor;
35445 this._fillOpacity = options.fillOpacity == null ? this._fillOpacity : options.fillOpacity;
35446 this._text = options.text === undefined ? this._text : options.text;
35447 this._textColor = options.textColor == null ? this._textColor : options.textColor;
35448 this._notifyChanged$.next(this);
35450 OutlineTag.prototype._twoDimensionalPolygon = function (domain, geometry) {
35451 return domain !== Component_1.TagDomain.ThreeDimensional && geometry instanceof Component_1.PolygonGeometry;
35454 * Event fired when the icon of the outline tag is clicked.
35456 * @event OutlineTag#click
35457 * @type {OutlineTag} The tag instance that was clicked.
35459 OutlineTag.click = "click";
35461 }(Component_1.Tag));
35462 exports.OutlineTag = OutlineTag;
35463 exports.default = OutlineTag;
35465 },{"../../../Component":275,"../../../Viewer":286,"rxjs":27}],368:[function(require,module,exports){
35467 Object.defineProperty(exports, "__esModule", { value: true });
35468 var rxjs_1 = require("rxjs");
35469 var Geo_1 = require("../../../Geo");
35470 var RenderTag = /** @class */ (function () {
35471 function RenderTag(tag, transform, viewportCoords) {
35473 this._transform = transform;
35474 this._viewportCoords = !!viewportCoords ? viewportCoords : new Geo_1.ViewportCoords();
35475 this._glObjectsChanged$ = new rxjs_1.Subject();
35476 this._interact$ = new rxjs_1.Subject();
35478 Object.defineProperty(RenderTag.prototype, "glObjectsChanged$", {
35480 return this._glObjectsChanged$;
35485 Object.defineProperty(RenderTag.prototype, "interact$", {
35487 return this._interact$;
35492 Object.defineProperty(RenderTag.prototype, "tag", {
35501 exports.RenderTag = RenderTag;
35502 exports.default = RenderTag;
35504 },{"../../../Geo":278,"rxjs":27}],369:[function(require,module,exports){
35506 var __extends = (this && this.__extends) || (function () {
35507 var extendStatics = function (d, b) {
35508 extendStatics = Object.setPrototypeOf ||
35509 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
35510 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
35511 return extendStatics(d, b);
35513 return function (d, b) {
35514 extendStatics(d, b);
35515 function __() { this.constructor = d; }
35516 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
35519 Object.defineProperty(exports, "__esModule", { value: true });
35520 var vd = require("virtual-dom");
35521 var Component_1 = require("../../../Component");
35522 var Viewer_1 = require("../../../Viewer");
35524 * @class SpotRenderTag
35525 * @classdesc Tag visualizing the properties of a SpotTag.
35527 var SpotRenderTag = /** @class */ (function (_super) {
35528 __extends(SpotRenderTag, _super);
35529 function SpotRenderTag() {
35530 return _super !== null && _super.apply(this, arguments) || this;
35532 SpotRenderTag.prototype.dispose = function () { };
35533 SpotRenderTag.prototype.getDOMObjects = function (atlas, camera, size) {
35535 var tag = this._tag;
35537 offsetHeight: size.height, offsetWidth: size.width,
35540 var _a = tag.geometry.getCentroid2d(), centroidBasicX = _a[0], centroidBasicY = _a[1];
35541 var centroidCanvas = this._viewportCoords.basicToCanvasSafe(centroidBasicX, centroidBasicY, container, this._transform, camera);
35542 if (centroidCanvas != null) {
35543 var interactNone = function (e) {
35544 _this._interact$.next({ offsetX: 0, offsetY: 0, operation: Component_1.TagOperation.None, tag: tag });
35546 var canvasX = Math.round(centroidCanvas[0]);
35547 var canvasY = Math.round(centroidCanvas[1]);
35548 if (tag.icon != null) {
35549 if (atlas.loaded) {
35550 var sprite = atlas.getDOMSprite(tag.icon, Viewer_1.Alignment.Bottom);
35551 var iconTransform = "translate(" + canvasX + "px," + (canvasY + 8) + "px)";
35553 onmousedown: interactNone,
35555 pointerEvents: "all",
35556 transform: iconTransform,
35559 vNodes.push(vd.h("div", properties, [sprite]));
35562 else if (tag.text != null) {
35563 var textTransform = "translate(-50%,0%) translate(" + canvasX + "px," + (canvasY + 8) + "px)";
35565 onmousedown: interactNone,
35567 color: this._colorToCss(tag.textColor),
35568 transform: textTransform,
35570 textContent: tag.text,
35572 vNodes.push(vd.h("span.TagSymbol", properties, []));
35574 var interact = this._interact(Component_1.TagOperation.Centroid, tag, "move");
35575 var background = this._colorToCss(tag.color);
35576 var transform = "translate(-50%,-50%) translate(" + canvasX + "px," + canvasY + "px)";
35577 if (tag.editable) {
35578 var interactorProperties = {
35579 onmousedown: interact,
35581 background: background,
35582 transform: transform,
35585 vNodes.push(vd.h("div.TagSpotInteractor", interactorProperties, []));
35587 var pointProperties = {
35589 background: background,
35590 transform: transform,
35593 vNodes.push(vd.h("div.TagVertex", pointProperties, []));
35597 SpotRenderTag.prototype.getGLObjects = function () { return []; };
35598 SpotRenderTag.prototype.getRetrievableObjects = function () { return []; };
35599 SpotRenderTag.prototype._colorToCss = function (color) {
35600 return "#" + ("000000" + color.toString(16)).substr(-6);
35602 SpotRenderTag.prototype._interact = function (operation, tag, cursor, vertexIndex) {
35604 return function (e) {
35605 var offsetX = e.offsetX - e.target.offsetWidth / 2;
35606 var offsetY = e.offsetY - e.target.offsetHeight / 2;
35607 _this._interact$.next({
35611 operation: operation,
35613 vertexIndex: vertexIndex,
35617 return SpotRenderTag;
35618 }(Component_1.RenderTag));
35619 exports.SpotRenderTag = SpotRenderTag;
35622 },{"../../../Component":275,"../../../Viewer":286,"virtual-dom":231}],370:[function(require,module,exports){
35624 var __extends = (this && this.__extends) || (function () {
35625 var extendStatics = function (d, b) {
35626 extendStatics = Object.setPrototypeOf ||
35627 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
35628 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
35629 return extendStatics(d, b);
35631 return function (d, b) {
35632 extendStatics(d, b);
35633 function __() { this.constructor = d; }
35634 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
35637 Object.defineProperty(exports, "__esModule", { value: true });
35638 var Component_1 = require("../../../Component");
35642 * @classdesc Tag holding properties for visualizing the centroid of a geometry.
35646 * var geometry = new Mapillary.TagComponent.PointGeometry([0.3, 0.3]);
35647 * var tag = new Mapillary.TagComponent.SpotTag(
35650 * { editable: true, color: 0xff0000 });
35652 * tagComponent.add([tag]);
35655 var SpotTag = /** @class */ (function (_super) {
35656 __extends(SpotTag, _super);
35658 * Create a spot tag.
35662 * @param {string} id
35663 * @param {Geometry} geometry
35664 * @param {IOutlineTagOptions} options - Options defining the visual appearance and
35665 * behavior of the spot tag.
35667 function SpotTag(id, geometry, options) {
35668 var _this = _super.call(this, id, geometry) || this;
35669 options = !!options ? options : {};
35670 _this._color = options.color == null ? 0xFFFFFF : options.color;
35671 _this._editable = options.editable == null ? false : options.editable;
35672 _this._icon = options.icon === undefined ? null : options.icon;
35673 _this._text = options.text === undefined ? null : options.text;
35674 _this._textColor = options.textColor == null ? 0xFFFFFF : options.textColor;
35677 Object.defineProperty(SpotTag.prototype, "color", {
35679 * Get color property.
35680 * @returns {number} The color of the spot as a hexagonal number;
35683 return this._color;
35686 * Set color property.
35689 * @fires Tag#changed
35691 set: function (value) {
35692 this._color = value;
35693 this._notifyChanged$.next(this);
35698 Object.defineProperty(SpotTag.prototype, "editable", {
35700 * Get editable property.
35701 * @returns {boolean} Value indicating if tag is editable.
35704 return this._editable;
35707 * Set editable property.
35710 * @fires Tag#changed
35712 set: function (value) {
35713 this._editable = value;
35714 this._notifyChanged$.next(this);
35719 Object.defineProperty(SpotTag.prototype, "icon", {
35721 * Get icon property.
35722 * @returns {string}
35728 * Set icon property.
35731 * @fires Tag#changed
35733 set: function (value) {
35734 this._icon = value;
35735 this._notifyChanged$.next(this);
35740 Object.defineProperty(SpotTag.prototype, "text", {
35742 * Get text property.
35743 * @returns {string}
35749 * Set text property.
35752 * @fires Tag#changed
35754 set: function (value) {
35755 this._text = value;
35756 this._notifyChanged$.next(this);
35761 Object.defineProperty(SpotTag.prototype, "textColor", {
35763 * Get text color property.
35764 * @returns {number}
35767 return this._textColor;
35770 * Set text color property.
35773 * @fires Tag#changed
35775 set: function (value) {
35776 this._textColor = value;
35777 this._notifyChanged$.next(this);
35783 * Set options for tag.
35785 * @description Sets all the option properties provided and keps
35786 * the rest of the values as is.
35788 * @param {ISpotTagOptions} options - Spot tag options
35790 * @fires {Tag#changed}
35792 SpotTag.prototype.setOptions = function (options) {
35793 this._color = options.color == null ? this._color : options.color;
35794 this._editable = options.editable == null ? this._editable : options.editable;
35795 this._icon = options.icon === undefined ? this._icon : options.icon;
35796 this._text = options.text === undefined ? this._text : options.text;
35797 this._textColor = options.textColor == null ? this._textColor : options.textColor;
35798 this._notifyChanged$.next(this);
35801 }(Component_1.Tag));
35802 exports.SpotTag = SpotTag;
35803 exports.default = SpotTag;
35805 },{"../../../Component":275}],371:[function(require,module,exports){
35807 var __extends = (this && this.__extends) || (function () {
35808 var extendStatics = function (d, b) {
35809 extendStatics = Object.setPrototypeOf ||
35810 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
35811 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
35812 return extendStatics(d, b);
35814 return function (d, b) {
35815 extendStatics(d, b);
35816 function __() { this.constructor = d; }
35817 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
35820 Object.defineProperty(exports, "__esModule", { value: true });
35821 var operators_1 = require("rxjs/operators");
35822 var rxjs_1 = require("rxjs");
35823 var Utils_1 = require("../../../Utils");
35827 * @classdesc Abstract class representing the basic functionality of for a tag.
35829 var Tag = /** @class */ (function (_super) {
35830 __extends(Tag, _super);
35835 * @param {string} id
35836 * @param {Geometry} geometry
35838 function Tag(id, geometry) {
35839 var _this = _super.call(this) || this;
35841 _this._geometry = geometry;
35842 _this._notifyChanged$ = new rxjs_1.Subject();
35843 _this._notifyChanged$
35844 .subscribe(function (t) {
35845 _this.fire(Tag.changed, _this);
35847 _this._geometry.changed$
35848 .subscribe(function (g) {
35849 _this.fire(Tag.geometrychanged, _this);
35853 Object.defineProperty(Tag.prototype, "id", {
35856 * @returns {string}
35864 Object.defineProperty(Tag.prototype, "geometry", {
35866 * Get geometry property.
35867 * @returns {Geometry} The geometry of the tag.
35870 return this._geometry;
35875 Object.defineProperty(Tag.prototype, "changed$", {
35877 * Get changed observable.
35878 * @returns {Observable<Tag>}
35882 return this._notifyChanged$;
35887 Object.defineProperty(Tag.prototype, "geometryChanged$", {
35889 * Get geometry changed observable.
35890 * @returns {Observable<Tag>}
35895 return this._geometry.changed$.pipe(operators_1.map(function (geometry) {
35897 }), operators_1.share());
35903 * Event fired when a property related to the visual appearance of the
35906 * @event Tag#changed
35907 * @type {Tag} The tag instance that has changed.
35909 Tag.changed = "changed";
35911 * Event fired when the geometry of the tag has changed.
35913 * @event Tag#geometrychanged
35914 * @type {Tag} The tag instance whose geometry has changed.
35916 Tag.geometrychanged = "geometrychanged";
35918 }(Utils_1.EventEmitter));
35920 exports.default = Tag;
35922 },{"../../../Utils":285,"rxjs":27,"rxjs/operators":225}],372:[function(require,module,exports){
35924 Object.defineProperty(exports, "__esModule", { value: true });
35926 * Enumeration for tag domains.
35929 * @description Defines where lines between two vertices are treated
35932 * Only applicable for polygons. For rectangles lines between
35933 * vertices are always treated as straight in the distorted 2D
35934 * projection and bended in the undistorted 3D space.
35937 (function (TagDomain) {
35939 * Treats lines between two vertices as straight in the
35940 * distorted 2D projection, i.e. on the image. If the image
35941 * is distorted this will result in bended lines when rendered
35942 * in the undistorted 3D space.
35944 TagDomain[TagDomain["TwoDimensional"] = 0] = "TwoDimensional";
35946 * Treats lines as straight in the undistorted 3D space. If the
35947 * image is distorted this will result in bended lines when rendered
35948 * on the distorted 2D projection of the image.
35950 TagDomain[TagDomain["ThreeDimensional"] = 1] = "ThreeDimensional";
35951 })(TagDomain = exports.TagDomain || (exports.TagDomain = {}));
35952 exports.default = TagDomain;
35954 },{}],373:[function(require,module,exports){
35956 Object.defineProperty(exports, "__esModule", { value: true });
35957 var HandlerBase = /** @class */ (function () {
35959 function HandlerBase(component, container, navigator) {
35960 this._component = component;
35961 this._container = container;
35962 this._navigator = navigator;
35963 this._enabled = false;
35965 Object.defineProperty(HandlerBase.prototype, "isEnabled", {
35967 * Returns a Boolean indicating whether the interaction is enabled.
35969 * @returns {boolean} `true` if the interaction is enabled.
35972 return this._enabled;
35978 * Enables the interaction.
35980 * @example ```<component-name>.<handler-name>.enable();```
35982 HandlerBase.prototype.enable = function () {
35983 if (this._enabled || !this._component.activated) {
35987 this._enabled = true;
35988 this._component.configure(this._getConfiguration(true));
35991 * Disables the interaction.
35993 * @example ```<component-name>.<handler-name>.disable();```
35995 HandlerBase.prototype.disable = function () {
35996 if (!this._enabled) {
36000 this._enabled = false;
36001 if (this._component.activated) {
36002 this._component.configure(this._getConfiguration(false));
36005 return HandlerBase;
36007 exports.HandlerBase = HandlerBase;
36008 exports.default = HandlerBase;
36010 },{}],374:[function(require,module,exports){
36012 Object.defineProperty(exports, "__esModule", { value: true });
36013 var THREE = require("three");
36014 var Component_1 = require("../../Component");
36015 var MeshFactory = /** @class */ (function () {
36016 function MeshFactory(imagePlaneDepth, imageSphereRadius) {
36017 this._imagePlaneDepth = imagePlaneDepth != null ? imagePlaneDepth : 200;
36018 this._imageSphereRadius = imageSphereRadius != null ? imageSphereRadius : 200;
36020 MeshFactory.prototype.createMesh = function (node, transform) {
36022 return this._createImageSphere(node, transform);
36024 else if (transform.cameraProjection === "fisheye") {
36025 return this._createImagePlaneFisheye(node, transform);
36028 return this._createImagePlane(node, transform);
36031 MeshFactory.prototype.createFlatMesh = function (node, transform, basicX0, basicX1, basicY0, basicY1) {
36032 var texture = this._createTexture(node.image);
36033 var materialParameters = this._createDistortedPlaneMaterialParameters(transform, texture);
36034 var material = new THREE.ShaderMaterial(materialParameters);
36035 var geometry = this._getFlatImagePlaneGeoFromBasic(transform, basicX0, basicX1, basicY0, basicY1);
36036 return new THREE.Mesh(geometry, material);
36038 MeshFactory.prototype.createCurtainMesh = function (node, transform) {
36039 if (node.pano && !node.fullPano) {
36040 throw new Error("Cropped panoramas cannot have curtain.");
36043 return this._createSphereCurtainMesh(node, transform);
36045 else if (transform.cameraProjection === "fisheye") {
36046 return this._createCurtainMeshFisheye(node, transform);
36049 return this._createCurtainMesh(node, transform);
36052 MeshFactory.prototype.createDistortedCurtainMesh = function (node, transform) {
36054 throw new Error("Cropped panoramas cannot have curtain.");
36056 return this._createDistortedCurtainMesh(node, transform);
36058 MeshFactory.prototype._createCurtainMesh = function (node, transform) {
36059 var texture = this._createTexture(node.image);
36060 var materialParameters = this._createCurtainPlaneMaterialParameters(transform, texture);
36061 var material = new THREE.ShaderMaterial(materialParameters);
36062 var geometry = this._useMesh(transform, node) ?
36063 this._getImagePlaneGeo(transform, node) :
36064 this._getRegularFlatImagePlaneGeo(transform);
36065 return new THREE.Mesh(geometry, material);
36067 MeshFactory.prototype._createCurtainMeshFisheye = function (node, transform) {
36068 var texture = this._createTexture(node.image);
36069 var materialParameters = this._createCurtainPlaneMaterialParametersFisheye(transform, texture);
36070 var material = new THREE.ShaderMaterial(materialParameters);
36071 var geometry = this._useMesh(transform, node) ?
36072 this._getImagePlaneGeoFisheye(transform, node) :
36073 this._getRegularFlatImagePlaneGeo(transform);
36074 return new THREE.Mesh(geometry, material);
36076 MeshFactory.prototype._createDistortedCurtainMesh = function (node, transform) {
36077 var texture = this._createTexture(node.image);
36078 var materialParameters = this._createDistortedCurtainPlaneMaterialParameters(transform, texture);
36079 var material = new THREE.ShaderMaterial(materialParameters);
36080 var geometry = this._getRegularFlatImagePlaneGeo(transform);
36081 return new THREE.Mesh(geometry, material);
36083 MeshFactory.prototype._createSphereCurtainMesh = function (node, transform) {
36084 var texture = this._createTexture(node.image);
36085 var materialParameters = this._createCurtainSphereMaterialParameters(transform, texture);
36086 var material = new THREE.ShaderMaterial(materialParameters);
36087 return this._useMesh(transform, node) ?
36088 new THREE.Mesh(this._getImageSphereGeo(transform, node), material) :
36089 new THREE.Mesh(this._getFlatImageSphereGeo(transform), material);
36091 MeshFactory.prototype._createImageSphere = function (node, transform) {
36092 var texture = this._createTexture(node.image);
36093 var materialParameters = this._createSphereMaterialParameters(transform, texture);
36094 var material = new THREE.ShaderMaterial(materialParameters);
36095 var mesh = this._useMesh(transform, node) ?
36096 new THREE.Mesh(this._getImageSphereGeo(transform, node), material) :
36097 new THREE.Mesh(this._getFlatImageSphereGeo(transform), material);
36100 MeshFactory.prototype._createImagePlane = function (node, transform) {
36101 var texture = this._createTexture(node.image);
36102 var materialParameters = this._createPlaneMaterialParameters(transform, texture);
36103 var material = new THREE.ShaderMaterial(materialParameters);
36104 var geometry = this._useMesh(transform, node) ?
36105 this._getImagePlaneGeo(transform, node) :
36106 this._getRegularFlatImagePlaneGeo(transform);
36107 return new THREE.Mesh(geometry, material);
36109 MeshFactory.prototype._createImagePlaneFisheye = function (node, transform) {
36110 var texture = this._createTexture(node.image);
36111 var materialParameters = this._createPlaneMaterialParametersFisheye(transform, texture);
36112 var material = new THREE.ShaderMaterial(materialParameters);
36113 var geometry = this._useMesh(transform, node) ?
36114 this._getImagePlaneGeoFisheye(transform, node) :
36115 this._getRegularFlatImagePlaneGeoFisheye(transform);
36116 return new THREE.Mesh(geometry, material);
36118 MeshFactory.prototype._createSphereMaterialParameters = function (transform, texture) {
36119 var gpano = transform.gpano;
36120 var halfCroppedWidth = (gpano.FullPanoWidthPixels - gpano.CroppedAreaImageWidthPixels) / 2;
36121 var phiShift = 2 * Math.PI * (gpano.CroppedAreaLeftPixels - halfCroppedWidth) / gpano.FullPanoWidthPixels;
36122 var phiLength = 2 * Math.PI * gpano.CroppedAreaImageWidthPixels / gpano.FullPanoWidthPixels;
36123 var halfCroppedHeight = (gpano.FullPanoHeightPixels - gpano.CroppedAreaImageHeightPixels) / 2;
36124 var thetaShift = Math.PI * (halfCroppedHeight - gpano.CroppedAreaTopPixels) / gpano.FullPanoHeightPixels;
36125 var thetaLength = Math.PI * gpano.CroppedAreaImageHeightPixels / gpano.FullPanoHeightPixels;
36126 var materialParameters = {
36128 fragmentShader: Component_1.Shaders.equirectangular.fragment,
36129 side: THREE.DoubleSide,
36146 value: transform.rt,
36154 value: thetaLength,
36161 vertexShader: Component_1.Shaders.equirectangular.vertex,
36163 return materialParameters;
36165 MeshFactory.prototype._createCurtainSphereMaterialParameters = function (transform, texture) {
36166 var gpano = transform.gpano;
36167 var halfCroppedWidth = (gpano.FullPanoWidthPixels - gpano.CroppedAreaImageWidthPixels) / 2;
36168 var phiShift = 2 * Math.PI * (gpano.CroppedAreaLeftPixels - halfCroppedWidth) / gpano.FullPanoWidthPixels;
36169 var phiLength = 2 * Math.PI * gpano.CroppedAreaImageWidthPixels / gpano.FullPanoWidthPixels;
36170 var halfCroppedHeight = (gpano.FullPanoHeightPixels - gpano.CroppedAreaImageHeightPixels) / 2;
36171 var thetaShift = Math.PI * (halfCroppedHeight - gpano.CroppedAreaTopPixels) / gpano.FullPanoHeightPixels;
36172 var thetaLength = Math.PI * gpano.CroppedAreaImageHeightPixels / gpano.FullPanoHeightPixels;
36173 var materialParameters = {
36175 fragmentShader: Component_1.Shaders.equirectangularCurtain.fragment,
36176 side: THREE.DoubleSide,
36197 value: transform.rt,
36205 value: thetaLength,
36212 vertexShader: Component_1.Shaders.equirectangularCurtain.vertex,
36214 return materialParameters;
36216 MeshFactory.prototype._createPlaneMaterialParameters = function (transform, texture) {
36217 var materialParameters = {
36219 fragmentShader: Component_1.Shaders.perspective.fragment,
36220 side: THREE.DoubleSide,
36225 value: transform.focal,
36229 value: transform.ck1,
36233 value: transform.ck2,
36241 value: transform.basicRt,
36249 value: !!transform.radialPeak ? transform.radialPeak : 0,
36253 value: Math.max(transform.basicHeight, transform.basicWidth) / transform.basicWidth,
36257 value: Math.max(transform.basicWidth, transform.basicHeight) / transform.basicHeight,
36260 vertexShader: Component_1.Shaders.perspective.vertex,
36262 return materialParameters;
36264 MeshFactory.prototype._createPlaneMaterialParametersFisheye = function (transform, texture) {
36265 var materialParameters = {
36267 fragmentShader: Component_1.Shaders.fisheye.fragment,
36268 side: THREE.DoubleSide,
36273 value: transform.focal,
36277 value: transform.ck1,
36281 value: transform.ck2,
36289 value: transform.basicRt,
36297 value: !!transform.radialPeak ? transform.radialPeak : 0,
36301 value: Math.max(transform.basicHeight, transform.basicWidth) / transform.basicWidth,
36305 value: Math.max(transform.basicWidth, transform.basicHeight) / transform.basicHeight,
36308 vertexShader: Component_1.Shaders.fisheye.vertex,
36310 return materialParameters;
36312 MeshFactory.prototype._createCurtainPlaneMaterialParametersFisheye = function (transform, texture) {
36313 var materialParameters = {
36315 fragmentShader: Component_1.Shaders.fisheyeCurtain.fragment,
36316 side: THREE.DoubleSide,
36325 value: transform.focal,
36329 value: transform.ck1,
36333 value: transform.ck2,
36341 value: transform.basicRt,
36349 value: !!transform.radialPeak ? transform.radialPeak : 0,
36353 value: Math.max(transform.basicHeight, transform.basicWidth) / transform.basicWidth,
36357 value: Math.max(transform.basicWidth, transform.basicHeight) / transform.basicHeight,
36360 vertexShader: Component_1.Shaders.fisheyeCurtain.vertex,
36362 return materialParameters;
36364 MeshFactory.prototype._createCurtainPlaneMaterialParameters = function (transform, texture) {
36365 var materialParameters = {
36367 fragmentShader: Component_1.Shaders.perspectiveCurtain.fragment,
36368 side: THREE.DoubleSide,
36377 value: transform.focal,
36381 value: transform.ck1,
36385 value: transform.ck2,
36393 value: transform.basicRt,
36401 value: !!transform.radialPeak ? transform.radialPeak : 0,
36405 value: Math.max(transform.basicHeight, transform.basicWidth) / transform.basicWidth,
36409 value: Math.max(transform.basicWidth, transform.basicHeight) / transform.basicHeight,
36412 vertexShader: Component_1.Shaders.perspectiveCurtain.vertex,
36414 return materialParameters;
36416 MeshFactory.prototype._createDistortedCurtainPlaneMaterialParameters = function (transform, texture) {
36417 var materialParameters = {
36419 fragmentShader: Component_1.Shaders.perspectiveDistortedCurtain.fragment,
36420 side: THREE.DoubleSide,
36433 value: transform.projectorMatrix(),
36440 vertexShader: Component_1.Shaders.perspectiveDistortedCurtain.vertex,
36442 return materialParameters;
36444 MeshFactory.prototype._createDistortedPlaneMaterialParameters = function (transform, texture) {
36445 var materialParameters = {
36447 fragmentShader: Component_1.Shaders.perspectiveDistorted.fragment,
36448 side: THREE.DoubleSide,
36457 value: transform.projectorMatrix(),
36464 vertexShader: Component_1.Shaders.perspectiveDistorted.vertex,
36466 return materialParameters;
36468 MeshFactory.prototype._createTexture = function (image) {
36469 var texture = new THREE.Texture(image);
36470 texture.minFilter = THREE.LinearFilter;
36471 texture.needsUpdate = true;
36474 MeshFactory.prototype._useMesh = function (transform, node) {
36475 return node.mesh.vertices.length && transform.hasValidScale;
36477 MeshFactory.prototype._getImageSphereGeo = function (transform, node) {
36478 var t = new THREE.Matrix4().getInverse(transform.srt);
36479 // push everything at least 5 meters in front of the camera
36480 var minZ = 5.0 * transform.scale;
36481 var maxZ = this._imageSphereRadius * transform.scale;
36482 var vertices = node.mesh.vertices;
36483 var numVertices = vertices.length / 3;
36484 var positions = new Float32Array(vertices.length);
36485 for (var i = 0; i < numVertices; ++i) {
36487 var x = vertices[index + 0];
36488 var y = vertices[index + 1];
36489 var z = vertices[index + 2];
36490 var l = Math.sqrt(x * x + y * y + z * z);
36491 var boundedL = Math.max(minZ, Math.min(l, maxZ));
36492 var factor = boundedL / l;
36493 var p = new THREE.Vector3(x * factor, y * factor, z * factor);
36495 positions[index + 0] = p.x;
36496 positions[index + 1] = p.y;
36497 positions[index + 2] = p.z;
36499 var faces = node.mesh.faces;
36500 var indices = new Uint16Array(faces.length);
36501 for (var i = 0; i < faces.length; ++i) {
36502 indices[i] = faces[i];
36504 var geometry = new THREE.BufferGeometry();
36505 geometry.addAttribute("position", new THREE.BufferAttribute(positions, 3));
36506 geometry.setIndex(new THREE.BufferAttribute(indices, 1));
36509 MeshFactory.prototype._getImagePlaneGeo = function (transform, node) {
36510 var undistortionMarginFactor = 3;
36511 var t = new THREE.Matrix4().getInverse(transform.srt);
36512 // push everything at least 5 meters in front of the camera
36513 var minZ = 5.0 * transform.scale;
36514 var maxZ = this._imagePlaneDepth * transform.scale;
36515 var vertices = node.mesh.vertices;
36516 var numVertices = vertices.length / 3;
36517 var positions = new Float32Array(vertices.length);
36518 for (var i = 0; i < numVertices; ++i) {
36520 var x = vertices[index + 0];
36521 var y = vertices[index + 1];
36522 var z = vertices[index + 2];
36524 x *= undistortionMarginFactor;
36525 y *= undistortionMarginFactor;
36527 var boundedZ = Math.max(minZ, Math.min(z, maxZ));
36528 var factor = boundedZ / z;
36529 var p = new THREE.Vector3(x * factor, y * factor, boundedZ);
36531 positions[index + 0] = p.x;
36532 positions[index + 1] = p.y;
36533 positions[index + 2] = p.z;
36535 var faces = node.mesh.faces;
36536 var indices = new Uint16Array(faces.length);
36537 for (var i = 0; i < faces.length; ++i) {
36538 indices[i] = faces[i];
36540 var geometry = new THREE.BufferGeometry();
36541 geometry.addAttribute("position", new THREE.BufferAttribute(positions, 3));
36542 geometry.setIndex(new THREE.BufferAttribute(indices, 1));
36545 MeshFactory.prototype._getImagePlaneGeoFisheye = function (transform, node) {
36546 var t = new THREE.Matrix4().getInverse(transform.srt);
36547 // push everything at least 5 meters in front of the camera
36548 var minZ = 5.0 * transform.scale;
36549 var maxZ = this._imagePlaneDepth * transform.scale;
36550 var vertices = node.mesh.vertices;
36551 var numVertices = vertices.length / 3;
36552 var positions = new Float32Array(vertices.length);
36553 for (var i = 0; i < numVertices; ++i) {
36555 var x = vertices[index + 0];
36556 var y = vertices[index + 1];
36557 var z = vertices[index + 2];
36558 var l = Math.sqrt(x * x + y * y + z * z);
36559 var boundedL = Math.max(minZ, Math.min(l, maxZ));
36560 var factor = boundedL / l;
36561 var p = new THREE.Vector3(x * factor, y * factor, z * factor);
36563 positions[index + 0] = p.x;
36564 positions[index + 1] = p.y;
36565 positions[index + 2] = p.z;
36567 var faces = node.mesh.faces;
36568 var indices = new Uint16Array(faces.length);
36569 for (var i = 0; i < faces.length; ++i) {
36570 indices[i] = faces[i];
36572 var geometry = new THREE.BufferGeometry();
36573 geometry.addAttribute("position", new THREE.BufferAttribute(positions, 3));
36574 geometry.setIndex(new THREE.BufferAttribute(indices, 1));
36577 MeshFactory.prototype._getFlatImageSphereGeo = function (transform) {
36578 var gpano = transform.gpano;
36579 var phiStart = 2 * Math.PI * gpano.CroppedAreaLeftPixels / gpano.FullPanoWidthPixels;
36580 var phiLength = 2 * Math.PI * gpano.CroppedAreaImageWidthPixels / gpano.FullPanoWidthPixels;
36581 var thetaStart = Math.PI *
36582 (gpano.FullPanoHeightPixels - gpano.CroppedAreaImageHeightPixels - gpano.CroppedAreaTopPixels) /
36583 gpano.FullPanoHeightPixels;
36584 var thetaLength = Math.PI * gpano.CroppedAreaImageHeightPixels / gpano.FullPanoHeightPixels;
36585 var geometry = new THREE.SphereGeometry(this._imageSphereRadius, 20, 40, phiStart - Math.PI / 2, phiLength, thetaStart, thetaLength);
36586 geometry.applyMatrix(new THREE.Matrix4().getInverse(transform.rt));
36589 MeshFactory.prototype._getRegularFlatImagePlaneGeo = function (transform) {
36590 var width = transform.width;
36591 var height = transform.height;
36592 var size = Math.max(width, height);
36593 var dx = width / 2.0 / size;
36594 var dy = height / 2.0 / size;
36595 return this._getFlatImagePlaneGeo(transform, dx, dy);
36597 MeshFactory.prototype._getFlatImagePlaneGeo = function (transform, dx, dy) {
36599 vertices.push(transform.unprojectSfM([-dx, -dy], this._imagePlaneDepth));
36600 vertices.push(transform.unprojectSfM([dx, -dy], this._imagePlaneDepth));
36601 vertices.push(transform.unprojectSfM([dx, dy], this._imagePlaneDepth));
36602 vertices.push(transform.unprojectSfM([-dx, dy], this._imagePlaneDepth));
36603 return this._createFlatGeometry(vertices);
36605 MeshFactory.prototype._getRegularFlatImagePlaneGeoFisheye = function (transform) {
36606 var width = transform.width;
36607 var height = transform.height;
36608 var size = Math.max(width, height);
36609 var dx = width / 2.0 / size;
36610 var dy = height / 2.0 / size;
36611 return this._getFlatImagePlaneGeoFisheye(transform, dx, dy);
36613 MeshFactory.prototype._getFlatImagePlaneGeoFisheye = function (transform, dx, dy) {
36615 vertices.push(transform.unprojectSfM([-dx, -dy], this._imagePlaneDepth));
36616 vertices.push(transform.unprojectSfM([dx, -dy], this._imagePlaneDepth));
36617 vertices.push(transform.unprojectSfM([dx, dy], this._imagePlaneDepth));
36618 vertices.push(transform.unprojectSfM([-dx, dy], this._imagePlaneDepth));
36619 return this._createFlatGeometry(vertices);
36621 MeshFactory.prototype._getFlatImagePlaneGeoFromBasic = function (transform, basicX0, basicX1, basicY0, basicY1) {
36623 vertices.push(transform.unprojectBasic([basicX0, basicY0], this._imagePlaneDepth));
36624 vertices.push(transform.unprojectBasic([basicX1, basicY0], this._imagePlaneDepth));
36625 vertices.push(transform.unprojectBasic([basicX1, basicY1], this._imagePlaneDepth));
36626 vertices.push(transform.unprojectBasic([basicX0, basicY1], this._imagePlaneDepth));
36627 return this._createFlatGeometry(vertices);
36629 MeshFactory.prototype._createFlatGeometry = function (vertices) {
36630 var positions = new Float32Array(12);
36631 for (var i = 0; i < vertices.length; i++) {
36633 positions[index + 0] = vertices[i][0];
36634 positions[index + 1] = vertices[i][1];
36635 positions[index + 2] = vertices[i][2];
36637 var indices = new Uint16Array(6);
36644 var geometry = new THREE.BufferGeometry();
36645 geometry.addAttribute("position", new THREE.BufferAttribute(positions, 3));
36646 geometry.setIndex(new THREE.BufferAttribute(indices, 1));
36649 return MeshFactory;
36651 exports.MeshFactory = MeshFactory;
36652 exports.default = MeshFactory;
36654 },{"../../Component":275,"three":226}],375:[function(require,module,exports){
36656 Object.defineProperty(exports, "__esModule", { value: true });
36657 var THREE = require("three");
36658 var MeshScene = /** @class */ (function () {
36659 function MeshScene() {
36660 this.scene = new THREE.Scene();
36661 this.sceneOld = new THREE.Scene();
36662 this.imagePlanes = [];
36663 this.imagePlanesOld = [];
36665 MeshScene.prototype.updateImagePlanes = function (planes) {
36666 this._dispose(this.imagePlanesOld, this.sceneOld);
36667 for (var _i = 0, _a = this.imagePlanes; _i < _a.length; _i++) {
36668 var plane = _a[_i];
36669 this.scene.remove(plane);
36670 this.sceneOld.add(plane);
36672 for (var _b = 0, planes_1 = planes; _b < planes_1.length; _b++) {
36673 var plane = planes_1[_b];
36674 this.scene.add(plane);
36676 this.imagePlanesOld = this.imagePlanes;
36677 this.imagePlanes = planes;
36679 MeshScene.prototype.addImagePlanes = function (planes) {
36680 for (var _i = 0, planes_2 = planes; _i < planes_2.length; _i++) {
36681 var plane = planes_2[_i];
36682 this.scene.add(plane);
36683 this.imagePlanes.push(plane);
36686 MeshScene.prototype.addImagePlanesOld = function (planes) {
36687 for (var _i = 0, planes_3 = planes; _i < planes_3.length; _i++) {
36688 var plane = planes_3[_i];
36689 this.sceneOld.add(plane);
36690 this.imagePlanesOld.push(plane);
36693 MeshScene.prototype.setImagePlanes = function (planes) {
36695 this.addImagePlanes(planes);
36697 MeshScene.prototype.setImagePlanesOld = function (planes) {
36699 this.addImagePlanesOld(planes);
36701 MeshScene.prototype.clear = function () {
36705 MeshScene.prototype._clear = function () {
36706 this._dispose(this.imagePlanes, this.scene);
36707 this.imagePlanes.length = 0;
36709 MeshScene.prototype._clearOld = function () {
36710 this._dispose(this.imagePlanesOld, this.sceneOld);
36711 this.imagePlanesOld.length = 0;
36713 MeshScene.prototype._dispose = function (planes, scene) {
36714 for (var _i = 0, planes_4 = planes; _i < planes_4.length; _i++) {
36715 var plane = planes_4[_i];
36716 scene.remove(plane);
36717 plane.geometry.dispose();
36718 plane.material.dispose();
36719 var texture = plane.material.uniforms.projectorTex.value;
36720 if (texture != null) {
36727 exports.MeshScene = MeshScene;
36728 exports.default = MeshScene;
36730 },{"three":226}],376:[function(require,module,exports){
36732 Object.defineProperty(exports, "__esModule", { value: true });
36733 var rxjs_1 = require("rxjs");
36734 var operators_1 = require("rxjs/operators");
36735 var MouseOperator = /** @class */ (function () {
36736 function MouseOperator() {
36738 MouseOperator.filteredPairwiseMouseDrag$ = function (name, mouseService) {
36739 return mouseService
36740 .filtered$(name, mouseService.mouseDragStart$).pipe(operators_1.switchMap(function (mouseDragStart) {
36741 var mouseDragging$ = rxjs_1.concat(rxjs_1.of(mouseDragStart), mouseService
36742 .filtered$(name, mouseService.mouseDrag$));
36743 var mouseDragEnd$ = mouseService
36744 .filtered$(name, mouseService.mouseDragEnd$).pipe(operators_1.map(function () {
36747 return rxjs_1.merge(mouseDragging$, mouseDragEnd$).pipe(operators_1.takeWhile(function (e) {
36749 }), operators_1.startWith(null));
36750 }), operators_1.pairwise(), operators_1.filter(function (pair) {
36751 return pair[0] != null && pair[1] != null;
36754 return MouseOperator;
36756 exports.MouseOperator = MouseOperator;
36757 exports.default = MouseOperator;
36759 },{"rxjs":27,"rxjs/operators":225}],377:[function(require,module,exports){
36761 var __extends = (this && this.__extends) || (function () {
36762 var extendStatics = function (d, b) {
36763 extendStatics = Object.setPrototypeOf ||
36764 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
36765 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
36766 return extendStatics(d, b);
36768 return function (d, b) {
36769 extendStatics(d, b);
36770 function __() { this.constructor = d; }
36771 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
36774 Object.defineProperty(exports, "__esModule", { value: true });
36775 var rxjs_1 = require("rxjs");
36776 var operators_1 = require("rxjs/operators");
36777 var vd = require("virtual-dom");
36778 var Component_1 = require("../../Component");
36779 var Geo_1 = require("../../Geo");
36780 var State_1 = require("../../State");
36781 var ZoomComponent = /** @class */ (function (_super) {
36782 __extends(ZoomComponent, _super);
36783 function ZoomComponent(name, container, navigator) {
36784 var _this = _super.call(this, name, container, navigator) || this;
36785 _this._viewportCoords = new Geo_1.ViewportCoords();
36786 _this._zoomDelta$ = new rxjs_1.Subject();
36789 ZoomComponent.prototype._activate = function () {
36791 this._renderSubscription = rxjs_1.combineLatest(this._navigator.stateService.currentState$, this._navigator.stateService.state$).pipe(operators_1.map(function (_a) {
36792 var frame = _a[0], state = _a[1];
36793 return [frame.state.zoom, state];
36794 }), operators_1.map(function (_a) {
36795 var zoom = _a[0], state = _a[1];
36796 var zoomInIcon = vd.h("div.ZoomInIcon", []);
36797 var zoomInButton = zoom >= 3 || state === State_1.State.Waiting ?
36798 vd.h("div.ZoomInButtonDisabled", [zoomInIcon]) :
36799 vd.h("div.ZoomInButton", { onclick: function () { _this._zoomDelta$.next(1); } }, [zoomInIcon]);
36800 var zoomOutIcon = vd.h("div.ZoomOutIcon", []);
36801 var zoomOutButton = zoom <= 0 || state === State_1.State.Waiting ?
36802 vd.h("div.ZoomOutButtonDisabled", [zoomOutIcon]) :
36803 vd.h("div.ZoomOutButton", { onclick: function () { _this._zoomDelta$.next(-1); } }, [zoomOutIcon]);
36806 vnode: vd.h("div.ZoomContainer", { oncontextmenu: function (event) { event.preventDefault(); } }, [zoomInButton, zoomOutButton]),
36809 .subscribe(this._container.domRenderer.render$);
36810 this._zoomSubscription = this._zoomDelta$.pipe(operators_1.withLatestFrom(this._container.renderService.renderCamera$, this._navigator.stateService.currentTransform$))
36811 .subscribe(function (_a) {
36812 var zoomDelta = _a[0], render = _a[1], transform = _a[2];
36813 var unprojected = _this._viewportCoords.unprojectFromViewport(0, 0, render.perspective);
36814 var reference = transform.projectBasic(unprojected.toArray());
36815 _this._navigator.stateService.zoomIn(zoomDelta, reference);
36818 ZoomComponent.prototype._deactivate = function () {
36819 this._renderSubscription.unsubscribe();
36820 this._zoomSubscription.unsubscribe();
36822 ZoomComponent.prototype._getDefaultConfiguration = function () {
36825 ZoomComponent.componentName = "zoom";
36826 return ZoomComponent;
36827 }(Component_1.Component));
36828 exports.ZoomComponent = ZoomComponent;
36829 Component_1.ComponentService.register(ZoomComponent);
36830 exports.default = ZoomComponent;
36832 },{"../../Component":275,"../../Geo":278,"../../State":282,"rxjs":27,"rxjs/operators":225,"virtual-dom":231}],378:[function(require,module,exports){
36834 var __extends = (this && this.__extends) || (function () {
36835 var extendStatics = function (d, b) {
36836 extendStatics = Object.setPrototypeOf ||
36837 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
36838 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
36839 return extendStatics(d, b);
36841 return function (d, b) {
36842 extendStatics(d, b);
36843 function __() { this.constructor = d; }
36844 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
36847 Object.defineProperty(exports, "__esModule", { value: true });
36848 var MapillaryError_1 = require("./MapillaryError");
36850 * @class AbortMapillaryError
36852 * @classdesc Error thrown when a move to request has been
36853 * aborted before completing because of a subsequent request.
36855 var AbortMapillaryError = /** @class */ (function (_super) {
36856 __extends(AbortMapillaryError, _super);
36857 function AbortMapillaryError(message) {
36858 var _this = _super.call(this, message != null ? message : "The request was aborted.") || this;
36859 Object.setPrototypeOf(_this, AbortMapillaryError.prototype);
36860 _this.name = "AbortMapillaryError";
36863 return AbortMapillaryError;
36864 }(MapillaryError_1.MapillaryError));
36865 exports.AbortMapillaryError = AbortMapillaryError;
36866 exports.default = AbortMapillaryError;
36868 },{"./MapillaryError":381}],379:[function(require,module,exports){
36870 var __extends = (this && this.__extends) || (function () {
36871 var extendStatics = function (d, b) {
36872 extendStatics = Object.setPrototypeOf ||
36873 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
36874 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
36875 return extendStatics(d, b);
36877 return function (d, b) {
36878 extendStatics(d, b);
36879 function __() { this.constructor = d; }
36880 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
36883 Object.defineProperty(exports, "__esModule", { value: true });
36884 var MapillaryError_1 = require("./MapillaryError");
36885 var ArgumentMapillaryError = /** @class */ (function (_super) {
36886 __extends(ArgumentMapillaryError, _super);
36887 function ArgumentMapillaryError(message) {
36888 var _this = _super.call(this, message != null ? message : "The argument is not valid.") || this;
36889 Object.setPrototypeOf(_this, ArgumentMapillaryError.prototype);
36890 _this.name = "ArgumentMapillaryError";
36893 return ArgumentMapillaryError;
36894 }(MapillaryError_1.MapillaryError));
36895 exports.ArgumentMapillaryError = ArgumentMapillaryError;
36896 exports.default = ArgumentMapillaryError;
36898 },{"./MapillaryError":381}],380:[function(require,module,exports){
36900 var __extends = (this && this.__extends) || (function () {
36901 var extendStatics = function (d, b) {
36902 extendStatics = Object.setPrototypeOf ||
36903 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
36904 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
36905 return extendStatics(d, b);
36907 return function (d, b) {
36908 extendStatics(d, b);
36909 function __() { this.constructor = d; }
36910 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
36913 Object.defineProperty(exports, "__esModule", { value: true });
36914 var MapillaryError_1 = require("./MapillaryError");
36915 var GraphMapillaryError = /** @class */ (function (_super) {
36916 __extends(GraphMapillaryError, _super);
36917 function GraphMapillaryError(message) {
36918 var _this = _super.call(this, message) || this;
36919 Object.setPrototypeOf(_this, GraphMapillaryError.prototype);
36920 _this.name = "GraphMapillaryError";
36923 return GraphMapillaryError;
36924 }(MapillaryError_1.MapillaryError));
36925 exports.GraphMapillaryError = GraphMapillaryError;
36926 exports.default = GraphMapillaryError;
36928 },{"./MapillaryError":381}],381:[function(require,module,exports){
36930 var __extends = (this && this.__extends) || (function () {
36931 var extendStatics = function (d, b) {
36932 extendStatics = Object.setPrototypeOf ||
36933 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
36934 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
36935 return extendStatics(d, b);
36937 return function (d, b) {
36938 extendStatics(d, b);
36939 function __() { this.constructor = d; }
36940 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
36943 Object.defineProperty(exports, "__esModule", { value: true });
36944 var MapillaryError = /** @class */ (function (_super) {
36945 __extends(MapillaryError, _super);
36946 function MapillaryError(message) {
36947 var _this = _super.call(this, message) || this;
36948 Object.setPrototypeOf(_this, MapillaryError.prototype);
36949 _this.name = "MapillaryError";
36952 return MapillaryError;
36954 exports.MapillaryError = MapillaryError;
36955 exports.default = MapillaryError;
36957 },{}],382:[function(require,module,exports){
36959 Object.defineProperty(exports, "__esModule", { value: true });
36960 var THREE = require("three");
36964 * @classdesc Holds information about a camera.
36966 var Camera = /** @class */ (function () {
36968 * Create a new camera instance.
36969 * @param {Transform} [transform] - Optional transform instance.
36971 function Camera(transform) {
36972 if (transform != null) {
36973 this._position = new THREE.Vector3().fromArray(transform.unprojectSfM([0, 0], 0));
36974 this._lookat = new THREE.Vector3().fromArray(transform.unprojectSfM([0, 0], 10));
36975 this._up = transform.upVector();
36976 this._focal = this._getFocal(transform);
36979 this._position = new THREE.Vector3(0, 0, 0);
36980 this._lookat = new THREE.Vector3(0, 0, 1);
36981 this._up = new THREE.Vector3(0, -1, 0);
36985 Object.defineProperty(Camera.prototype, "position", {
36988 * @returns {THREE.Vector3} The position vector.
36991 return this._position;
36996 Object.defineProperty(Camera.prototype, "lookat", {
36999 * @returns {THREE.Vector3} The lookat vector.
37002 return this._lookat;
37007 Object.defineProperty(Camera.prototype, "up", {
37010 * @returns {THREE.Vector3} The up vector.
37018 Object.defineProperty(Camera.prototype, "focal", {
37021 * @returns {number} The focal length.
37024 return this._focal;
37029 set: function (value) {
37030 this._focal = value;
37036 * Update this camera to the linearly interpolated value of two other cameras.
37038 * @param {Camera} a - First camera.
37039 * @param {Camera} b - Second camera.
37040 * @param {number} alpha - Interpolation value on the interval [0, 1].
37042 Camera.prototype.lerpCameras = function (a, b, alpha) {
37043 this._position.subVectors(b.position, a.position).multiplyScalar(alpha).add(a.position);
37044 this._lookat.subVectors(b.lookat, a.lookat).multiplyScalar(alpha).add(a.lookat);
37045 this._up.subVectors(b.up, a.up).multiplyScalar(alpha).add(a.up);
37046 this._focal = (1 - alpha) * a.focal + alpha * b.focal;
37049 * Copy the properties of another camera to this camera.
37051 * @param {Camera} other - Another camera.
37053 Camera.prototype.copy = function (other) {
37054 this._position.copy(other.position);
37055 this._lookat.copy(other.lookat);
37056 this._up.copy(other.up);
37057 this._focal = other.focal;
37060 * Clone this camera.
37062 * @returns {Camera} A camera with cloned properties equal to this camera.
37064 Camera.prototype.clone = function () {
37065 var camera = new Camera();
37066 camera.position.copy(this._position);
37067 camera.lookat.copy(this._lookat);
37068 camera.up.copy(this._up);
37069 camera.focal = this._focal;
37073 * Determine the distance between this camera and another camera.
37075 * @param {Camera} other - Another camera.
37076 * @returns {number} The distance between the cameras.
37078 Camera.prototype.diff = function (other) {
37079 var pd = this._position.distanceToSquared(other.position);
37080 var ld = this._lookat.distanceToSquared(other.lookat);
37081 var ud = this._up.distanceToSquared(other.up);
37082 var fd = 100 * Math.abs(this._focal - other.focal);
37083 return Math.max(pd, ld, ud, fd);
37086 * Get the focal length based on the transform.
37088 * @description Returns the focal length of the transform if gpano info is not available.
37089 * Returns a focal length corresponding to a vertical fov clamped to [45, 90] degrees based on
37090 * the gpano information if available.
37092 * @returns {number} Focal length.
37094 Camera.prototype._getFocal = function (transform) {
37095 if (transform.gpano == null) {
37096 return transform.focal;
37098 var vFov = Math.PI * transform.gpano.CroppedAreaImageHeightPixels / transform.gpano.FullPanoHeightPixels;
37099 var focal = 0.5 / Math.tan(vFov / 2);
37100 return Math.min(1 / (2 * (Math.sqrt(2) - 1)), Math.max(0.5, focal));
37104 exports.Camera = Camera;
37106 },{"three":226}],383:[function(require,module,exports){
37108 Object.defineProperty(exports, "__esModule", { value: true });
37109 var Geo_1 = require("../Geo");
37110 var geoCoords = new Geo_1.GeoCoords();
37111 var spatial = new Geo_1.Spatial();
37112 function computeTranslation(position, rotation, reference) {
37113 var C = geoCoords.geodeticToEnu(position.lat, position.lon, position.alt, reference.lat, reference.lon, reference.alt);
37114 var RC = spatial.rotate(C, rotation);
37115 var translation = [-RC.x, -RC.y, -RC.z];
37116 return translation;
37118 exports.computeTranslation = computeTranslation;
37120 },{"../Geo":278}],384:[function(require,module,exports){
37122 Object.defineProperty(exports, "__esModule", { value: true });
37126 * @classdesc Converts coordinates between the geodetic (WGS84),
37127 * Earth-Centered, Earth-Fixed (ECEF) and local topocentric
37128 * East, North, Up (ENU) reference frames.
37130 * The WGS84 has latitude (degrees), longitude (degrees) and
37131 * altitude (meters) values.
37133 * The ECEF Z-axis pierces the north pole and the
37134 * XY-axis defines the equatorial plane. The X-axis extends
37135 * from the geocenter to the intersection of the Equator and
37136 * the Greenwich Meridian. All values in meters.
37138 * The WGS84 parameters are:
37142 * f = 1 / 298.257223563
37143 * e = Math.sqrt((a^2 - b^2) / a^2)
37144 * e' = Math.sqrt((a^2 - b^2) / b^2)
37146 * The WGS84 to ECEF conversion is performed using the following:
37148 * X = (N - h) * cos(phi) * cos(lambda)
37149 * Y = (N + h) * cos(phi) * sin(lambda)
37150 * Z = (b^2 * N / a^2 + h) * sin(phi)
37155 * lambda = longitude
37156 * h = height above ellipsoid (altitude)
37157 * N = Radius of curvature (meters)
37158 * = a / Math.sqrt(1 - e^2 * sin(phi)^2)
37160 * The ECEF to WGS84 conversion is performed using the following:
37162 * phi = arctan((Z + e'^2 * b * sin(theta)^3) / (p - e^2 * a * cos(theta)^3))
37163 * lambda = arctan(Y / X)
37164 * h = p / cos(phi) - N
37168 * p = Math.sqrt(X^2 + Y^2)
37169 * theta = arctan(Z * a / p * b)
37171 * In the ENU reference frame the x-axis points to the
37172 * East, the y-axis to the North and the z-axis Up. All values
37175 * The ECEF to ENU conversion is performed using the following:
37177 * | x | | -sin(lambda_r) cos(lambda_r) 0 | | X - X_r |
37178 * | y | = | -sin(phi_r) * cos(lambda_r) -sin(phi_r) * sin(lambda_r) cos(phi_r) | | Y - Y_r |
37179 * | z | | cos(phi_r) * cos(lambda_r) cos(phi_r) * sin(lambda_r) sin(phi_r) | | Z - Z_r |
37183 * phi_r = latitude of reference
37184 * lambda_r = longitude of reference
37185 * X_r, Y_r, Z_r = ECEF coordinates of reference
37187 * The ENU to ECEF conversion is performed by solving the above equation for X, Y, Z.
37189 * WGS84 to ENU and ENU to WGS84 are two step conversions with ECEF calculated in
37190 * the first step for both conversions.
37192 var GeoCoords = /** @class */ (function () {
37193 function GeoCoords() {
37194 this._wgs84a = 6378137.0;
37195 this._wgs84b = 6356752.31424518;
37198 * Convert coordinates from geodetic (WGS84) reference to local topocentric
37201 * @param {number} lat Latitude in degrees.
37202 * @param {number} lon Longitude in degrees.
37203 * @param {number} alt Altitude in meters.
37204 * @param {number} refLat Reference latitude in degrees.
37205 * @param {number} refLon Reference longitude in degrees.
37206 * @param {number} refAlt Reference altitude in meters.
37207 * @returns {Array<number>} The x, y, z local topocentric ENU coordinates.
37209 GeoCoords.prototype.geodeticToEnu = function (lat, lon, alt, refLat, refLon, refAlt) {
37210 var ecef = this.geodeticToEcef(lat, lon, alt);
37211 return this.ecefToEnu(ecef[0], ecef[1], ecef[2], refLat, refLon, refAlt);
37214 * Convert coordinates from local topocentric (ENU) reference to
37215 * geodetic (WGS84) reference.
37217 * @param {number} x Topocentric ENU coordinate in East direction.
37218 * @param {number} y Topocentric ENU coordinate in North direction.
37219 * @param {number} z Topocentric ENU coordinate in Up direction.
37220 * @param {number} refLat Reference latitude in degrees.
37221 * @param {number} refLon Reference longitude in degrees.
37222 * @param {number} refAlt Reference altitude in meters.
37223 * @returns {Array<number>} The latitude and longitude in degrees
37224 * as well as altitude in meters.
37226 GeoCoords.prototype.enuToGeodetic = function (x, y, z, refLat, refLon, refAlt) {
37227 var ecef = this.enuToEcef(x, y, z, refLat, refLon, refAlt);
37228 return this.ecefToGeodetic(ecef[0], ecef[1], ecef[2]);
37231 * Convert coordinates from Earth-Centered, Earth-Fixed (ECEF) reference
37232 * to local topocentric (ENU) reference.
37234 * @param {number} X ECEF X-value.
37235 * @param {number} Y ECEF Y-value.
37236 * @param {number} Z ECEF Z-value.
37237 * @param {number} refLat Reference latitude in degrees.
37238 * @param {number} refLon Reference longitude in degrees.
37239 * @param {number} refAlt Reference altitude in meters.
37240 * @returns {Array<number>} The x, y, z topocentric ENU coordinates in East, North
37241 * and Up directions respectively.
37243 GeoCoords.prototype.ecefToEnu = function (X, Y, Z, refLat, refLon, refAlt) {
37244 var refEcef = this.geodeticToEcef(refLat, refLon, refAlt);
37245 var V = [X - refEcef[0], Y - refEcef[1], Z - refEcef[2]];
37246 refLat = refLat * Math.PI / 180.0;
37247 refLon = refLon * Math.PI / 180.0;
37248 var cosLat = Math.cos(refLat);
37249 var sinLat = Math.sin(refLat);
37250 var cosLon = Math.cos(refLon);
37251 var sinLon = Math.sin(refLon);
37252 var x = -sinLon * V[0] + cosLon * V[1];
37253 var y = -sinLat * cosLon * V[0] - sinLat * sinLon * V[1] + cosLat * V[2];
37254 var z = cosLat * cosLon * V[0] + cosLat * sinLon * V[1] + sinLat * V[2];
37258 * Convert coordinates from local topocentric (ENU) reference
37259 * to Earth-Centered, Earth-Fixed (ECEF) reference.
37261 * @param {number} x Topocentric ENU coordinate in East direction.
37262 * @param {number} y Topocentric ENU coordinate in North direction.
37263 * @param {number} z Topocentric ENU coordinate in Up direction.
37264 * @param {number} refLat Reference latitude in degrees.
37265 * @param {number} refLon Reference longitude in degrees.
37266 * @param {number} refAlt Reference altitude in meters.
37267 * @returns {Array<number>} The X, Y, Z ECEF coordinates.
37269 GeoCoords.prototype.enuToEcef = function (x, y, z, refLat, refLon, refAlt) {
37270 var refEcef = this.geodeticToEcef(refLat, refLon, refAlt);
37271 refLat = refLat * Math.PI / 180.0;
37272 refLon = refLon * Math.PI / 180.0;
37273 var cosLat = Math.cos(refLat);
37274 var sinLat = Math.sin(refLat);
37275 var cosLon = Math.cos(refLon);
37276 var sinLon = Math.sin(refLon);
37277 var X = -sinLon * x - sinLat * cosLon * y + cosLat * cosLon * z + refEcef[0];
37278 var Y = cosLon * x - sinLat * sinLon * y + cosLat * sinLon * z + refEcef[1];
37279 var Z = cosLat * y + sinLat * z + refEcef[2];
37283 * Convert coordinates from geodetic reference (WGS84) to Earth-Centered,
37284 * Earth-Fixed (ECEF) reference.
37286 * @param {number} lat Latitude in degrees.
37287 * @param {number} lon Longitude in degrees.
37288 * @param {number} alt Altitude in meters.
37289 * @returns {Array<number>} The X, Y, Z ECEF coordinates.
37291 GeoCoords.prototype.geodeticToEcef = function (lat, lon, alt) {
37292 var a = this._wgs84a;
37293 var b = this._wgs84b;
37294 lat = lat * Math.PI / 180.0;
37295 lon = lon * Math.PI / 180.0;
37296 var cosLat = Math.cos(lat);
37297 var sinLat = Math.sin(lat);
37298 var cosLon = Math.cos(lon);
37299 var sinLon = Math.sin(lon);
37302 var L = 1.0 / Math.sqrt(a2 * cosLat * cosLat + b2 * sinLat * sinLat);
37303 var nhcl = (a2 * L + alt) * cosLat;
37304 var X = nhcl * cosLon;
37305 var Y = nhcl * sinLon;
37306 var Z = (b2 * L + alt) * sinLat;
37310 * Convert coordinates from Earth-Centered, Earth-Fixed (ECEF) reference
37311 * to geodetic reference (WGS84).
37313 * @param {number} X ECEF X-value.
37314 * @param {number} Y ECEF Y-value.
37315 * @param {number} Z ECEF Z-value.
37316 * @returns {Array<number>} The latitude and longitude in degrees
37317 * as well as altitude in meters.
37319 GeoCoords.prototype.ecefToGeodetic = function (X, Y, Z) {
37320 var a = this._wgs84a;
37321 var b = this._wgs84b;
37324 var a2mb2 = a2 - b2;
37325 var ea = Math.sqrt(a2mb2 / a2);
37326 var eb = Math.sqrt(a2mb2 / b2);
37327 var p = Math.sqrt(X * X + Y * Y);
37328 var theta = Math.atan2(Z * a, p * b);
37329 var sinTheta = Math.sin(theta);
37330 var cosTheta = Math.cos(theta);
37331 var lon = Math.atan2(Y, X);
37332 var lat = Math.atan2(Z + eb * eb * b * sinTheta * sinTheta * sinTheta, p - ea * ea * a * cosTheta * cosTheta * cosTheta);
37333 var sinLat = Math.sin(lat);
37334 var cosLat = Math.cos(lat);
37335 var N = a / Math.sqrt(1 - ea * ea * sinLat * sinLat);
37336 var alt = p / cosLat - N;
37337 return [lat * 180.0 / Math.PI, lon * 180.0 / Math.PI, alt];
37341 exports.GeoCoords = GeoCoords;
37342 exports.default = GeoCoords;
37344 },{}],385:[function(require,module,exports){
37346 Object.defineProperty(exports, "__esModule", { value: true });
37348 return n > 0 ? 1 : n < 0 ? -1 : 0;
37350 function colinearPointOnSegment(p, s) {
37351 return p.x <= Math.max(s.p1.x, s.p2.x) &&
37352 p.x >= Math.min(s.p1.x, s.p2.x) &&
37353 p.y >= Math.max(s.p1.y, s.p2.y) &&
37354 p.y >= Math.min(s.p1.y, s.p2.y);
37356 function parallel(s1, s2) {
37357 var ux = s1.p2.x - s1.p1.x;
37358 var uy = s1.p2.y - s1.p1.y;
37359 var vx = s2.p2.x - s2.p1.x;
37360 var vy = s2.p2.y - s2.p1.y;
37361 var cross = ux * vy - uy * vx;
37362 var u2 = ux * ux + uy * uy;
37363 var v2 = vx * vx + vy * vy;
37364 var epsilon2 = 1e-10;
37365 return cross * cross < epsilon2 * u2 * v2;
37367 function tripletOrientation(p1, p2, p3) {
37368 var orientation = (p2.y - p1.y) * (p3.x - p2.x) -
37369 (p3.y - p2.y) * (p2.x - p1.x);
37370 return sign(orientation);
37372 function segmentsIntersect(s1, s2) {
37373 if (parallel(s1, s2)) {
37376 var o1 = tripletOrientation(s1.p1, s1.p2, s2.p1);
37377 var o2 = tripletOrientation(s1.p1, s1.p2, s2.p2);
37378 var o3 = tripletOrientation(s2.p1, s2.p2, s1.p1);
37379 var o4 = tripletOrientation(s2.p1, s2.p2, s1.p2);
37380 if (o1 !== o2 && o3 !== o4) {
37383 if (o1 === 0 && colinearPointOnSegment(s2.p1, s1)) {
37386 if (o2 === 0 && colinearPointOnSegment(s2.p2, s1)) {
37389 if (o3 === 0 && colinearPointOnSegment(s1.p1, s2)) {
37392 if (o4 === 0 && colinearPointOnSegment(s1.p2, s2)) {
37397 exports.segmentsIntersect = segmentsIntersect;
37398 function segmentIntersection(s1, s2) {
37399 if (parallel(s1, s2)) {
37410 var den = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4);
37411 var xNum = (x1 * y2 - y1 * x2) * (x3 - x4) - (x1 - x2) * (x3 * y4 - y3 * x4);
37412 var yNum = (x1 * y2 - y1 * x2) * (y3 - y4) - (y1 - y2) * (x3 * y4 - y3 * x4);
37413 return { x: xNum / den, y: yNum / den };
37415 exports.segmentIntersection = segmentIntersection;
37417 },{}],386:[function(require,module,exports){
37419 Object.defineProperty(exports, "__esModule", { value: true });
37420 var THREE = require("three");
37424 * @classdesc Provides methods for scalar, vector and matrix calculations.
37426 var Spatial = /** @class */ (function () {
37427 function Spatial() {
37428 this._epsilon = 1e-9;
37431 * Converts azimuthal phi rotation (counter-clockwise with origin on X-axis) to
37432 * bearing (clockwise with origin at north or Y-axis).
37434 * @param {number} phi - Azimuthal phi angle in radians.
37435 * @returns {number} Bearing in radians.
37437 Spatial.prototype.azimuthalToBearing = function (phi) {
37438 return -phi + Math.PI / 2;
37441 * Converts degrees to radians.
37443 * @param {number} deg - Degrees.
37444 * @returns {number} Radians.
37446 Spatial.prototype.degToRad = function (deg) {
37447 return Math.PI * deg / 180;
37450 * Converts radians to degrees.
37452 * @param {number} rad - Radians.
37453 * @returns {number} Degrees.
37455 Spatial.prototype.radToDeg = function (rad) {
37456 return 180 * rad / Math.PI;
37459 * Creates a rotation matrix from an angle-axis vector.
37461 * @param {Array<number>} angleAxis - Angle-axis representation of a rotation.
37462 * @returns {THREE.Matrix4} Rotation matrix.
37464 Spatial.prototype.rotationMatrix = function (angleAxis) {
37465 var axis = new THREE.Vector3(angleAxis[0], angleAxis[1], angleAxis[2]);
37466 var angle = axis.length();
37470 return new THREE.Matrix4().makeRotationAxis(axis, angle);
37473 * Rotates a vector according to a angle-axis rotation vector.
37475 * @param {Array<number>} vector - Vector to rotate.
37476 * @param {Array<number>} angleAxis - Angle-axis representation of a rotation.
37477 * @returns {THREE.Vector3} Rotated vector.
37479 Spatial.prototype.rotate = function (vector, angleAxis) {
37480 var v = new THREE.Vector3(vector[0], vector[1], vector[2]);
37481 var rotationMatrix = this.rotationMatrix(angleAxis);
37482 v.applyMatrix4(rotationMatrix);
37486 * Calculates the optical center from a rotation vector
37487 * on the angle-axis representation and a translation vector
37488 * according to C = -R^T t.
37490 * @param {Array<number>} rotation - Angle-axis representation of a rotation.
37491 * @param {Array<number>} translation - Translation vector.
37492 * @returns {THREE.Vector3} Optical center.
37494 Spatial.prototype.opticalCenter = function (rotation, translation) {
37495 var angleAxis = [-rotation[0], -rotation[1], -rotation[2]];
37496 var vector = [-translation[0], -translation[1], -translation[2]];
37497 return this.rotate(vector, angleAxis);
37500 * Calculates the viewing direction from a rotation vector
37501 * on the angle-axis representation.
37503 * @param {number[]} rotation - Angle-axis representation of a rotation.
37504 * @returns {THREE.Vector3} Viewing direction.
37506 Spatial.prototype.viewingDirection = function (rotation) {
37507 var angleAxis = [-rotation[0], -rotation[1], -rotation[2]];
37508 return this.rotate([0, 0, 1], angleAxis);
37511 * Wrap a number on the interval [min, max].
37513 * @param {number} value - Value to wrap.
37514 * @param {number} min - Lower endpoint of interval.
37515 * @param {number} max - Upper endpoint of interval.
37516 * @returns {number} The wrapped number.
37518 Spatial.prototype.wrap = function (value, min, max) {
37520 throw new Error("Invalid arguments: max must be larger than min.");
37522 var interval = (max - min);
37523 while (value > max || value < min) {
37525 value = value - interval;
37527 else if (value < min) {
37528 value = value + interval;
37534 * Wrap an angle on the interval [-Pi, Pi].
37536 * @param {number} angle - Value to wrap.
37537 * @returns {number} Wrapped angle.
37539 Spatial.prototype.wrapAngle = function (angle) {
37540 return this.wrap(angle, -Math.PI, Math.PI);
37543 * Limit the value to the interval [min, max] by changing the value to
37544 * the nearest available one when it is outside the interval.
37546 * @param {number} value - Value to clamp.
37547 * @param {number} min - Minimum of the interval.
37548 * @param {number} max - Maximum of the interval.
37549 * @returns {number} Clamped value.
37551 Spatial.prototype.clamp = function (value, min, max) {
37561 * Calculates the counter-clockwise angle from the first
37562 * vector (x1, y1)^T to the second (x2, y2)^T.
37564 * @param {number} x1 - X coordinate of first vector.
37565 * @param {number} y1 - Y coordinate of first vector.
37566 * @param {number} x2 - X coordinate of second vector.
37567 * @param {number} y2 - Y coordinate of second vector.
37568 * @returns {number} Counter clockwise angle between the vectors.
37570 Spatial.prototype.angleBetweenVector2 = function (x1, y1, x2, y2) {
37571 var angle = Math.atan2(y2, x2) - Math.atan2(y1, x1);
37572 return this.wrapAngle(angle);
37575 * Calculates the minimum (absolute) angle change for rotation
37576 * from one angle to another on the [-Pi, Pi] interval.
37578 * @param {number} angle1 - Start angle.
37579 * @param {number} angle2 - Destination angle.
37580 * @returns {number} Absolute angle change between angles.
37582 Spatial.prototype.angleDifference = function (angle1, angle2) {
37583 var angle = angle2 - angle1;
37584 return this.wrapAngle(angle);
37587 * Calculates the relative rotation angle between two
37588 * angle-axis vectors.
37590 * @param {number} rotation1 - First angle-axis vector.
37591 * @param {number} rotation2 - Second angle-axis vector.
37592 * @returns {number} Relative rotation angle.
37594 Spatial.prototype.relativeRotationAngle = function (rotation1, rotation2) {
37595 var R1T = this.rotationMatrix([-rotation1[0], -rotation1[1], -rotation1[2]]);
37596 var R2 = this.rotationMatrix(rotation2);
37597 var R = R1T.multiply(R2);
37598 var elements = R.elements;
37599 // from Tr(R) = 1 + 2 * cos(theta)
37600 var tr = elements[0] + elements[5] + elements[10];
37601 var theta = Math.acos(Math.max(Math.min((tr - 1) / 2, 1), -1));
37605 * Calculates the angle from a vector to a plane.
37607 * @param {Array<number>} vector - The vector.
37608 * @param {Array<number>} planeNormal - Normal of the plane.
37609 * @returns {number} Angle from between plane and vector.
37611 Spatial.prototype.angleToPlane = function (vector, planeNormal) {
37612 var v = new THREE.Vector3().fromArray(vector);
37613 var norm = v.length();
37614 if (norm < this._epsilon) {
37617 var projection = v.dot(new THREE.Vector3().fromArray(planeNormal));
37618 return Math.asin(projection / norm);
37621 * Calculates the distance between two coordinates
37622 * (latitude longitude pairs) in meters according to
37623 * the haversine formula.
37625 * @param {number} lat1 - Latitude of the first coordinate in degrees.
37626 * @param {number} lon1 - Longitude of the first coordinate in degrees.
37627 * @param {number} lat2 - Latitude of the second coordinate in degrees.
37628 * @param {number} lon2 - Longitude of the second coordinate in degrees.
37629 * @returns {number} Distance between lat lon positions in meters.
37631 Spatial.prototype.distanceFromLatLon = function (lat1, lon1, lat2, lon2) {
37633 var dLat = this.degToRad(lat2 - lat1);
37634 var dLon = this.degToRad(lon2 - lon1);
37635 var hav = Math.sin(dLat / 2) * Math.sin(dLat / 2) +
37636 Math.cos(this.degToRad(lat1)) * Math.cos(this.degToRad(lat2)) *
37637 Math.sin(dLon / 2) * Math.sin(dLon / 2);
37638 var d = 2 * r * Math.atan2(Math.sqrt(hav), Math.sqrt(1 - hav));
37643 exports.Spatial = Spatial;
37644 exports.default = Spatial;
37646 },{"three":226}],387:[function(require,module,exports){
37648 Object.defineProperty(exports, "__esModule", { value: true });
37649 var THREE = require("three");
37653 * @classdesc Class used for calculating coordinate transformations
37656 var Transform = /** @class */ (function () {
37658 * Create a new transform instance.
37659 * @param {number} orientation - Image orientation.
37660 * @param {number} width - Image height.
37661 * @param {number} height - Image width.
37662 * @param {number} focal - Focal length.
37663 * @param {number} scale - Atomic scale.
37664 * @param {IGPano} gpano - Panorama properties.
37665 * @param {Array<number>} rotation - Rotation vector in three dimensions.
37666 * @param {Array<number>} translation - Translation vector in three dimensions.
37667 * @param {HTMLImageElement} image - Image for fallback size calculations.
37669 function Transform(orientation, width, height, focal, scale, gpano, rotation, translation, image, textureScale, ck1, ck2, cameraProjection) {
37670 this._orientation = this._getValue(orientation, 1);
37671 var imageWidth = image != null ? image.width : 4;
37672 var imageHeight = image != null ? image.height : 3;
37673 var keepOrientation = this._orientation < 5;
37674 this._width = this._getValue(width, keepOrientation ? imageWidth : imageHeight);
37675 this._height = this._getValue(height, keepOrientation ? imageHeight : imageWidth);
37676 this._basicAspect = keepOrientation ?
37677 this._width / this._height :
37678 this._height / this._width;
37679 this._basicWidth = keepOrientation ? width : height;
37680 this._basicHeight = keepOrientation ? height : width;
37681 this._focal = this._getValue(focal, 1);
37682 this._scale = this._getValue(scale, 0);
37683 this._gpano = gpano != null ? gpano : null;
37684 this._rt = this._getRt(rotation, translation);
37685 this._srt = this._getSrt(this._rt, this._scale);
37686 this._basicRt = this._getBasicRt(this._rt, orientation);
37687 this._textureScale = !!textureScale ? textureScale : [1, 1];
37688 this._ck1 = !!ck1 ? ck1 : 0;
37689 this._ck2 = !!ck2 ? ck2 : 0;
37690 this._cameraProjection = !!cameraProjection ?
37693 "equirectangular" :
37695 this._radialPeak = this._getRadialPeak(this._ck1, this._ck2);
37697 Object.defineProperty(Transform.prototype, "ck1", {
37704 Object.defineProperty(Transform.prototype, "ck2", {
37711 Object.defineProperty(Transform.prototype, "cameraProjection", {
37713 return this._cameraProjection;
37718 Object.defineProperty(Transform.prototype, "basicAspect", {
37720 * Get basic aspect.
37721 * @returns {number} The orientation adjusted aspect ratio.
37724 return this._basicAspect;
37729 Object.defineProperty(Transform.prototype, "basicHeight", {
37731 * Get basic height.
37733 * @description Does not fall back to node image height but
37734 * uses original value from API so can be faulty.
37736 * @returns {number} The height of the basic version image
37737 * (adjusted for orientation).
37740 return this._basicHeight;
37745 Object.defineProperty(Transform.prototype, "basicRt", {
37747 return this._basicRt;
37752 Object.defineProperty(Transform.prototype, "basicWidth", {
37756 * @description Does not fall back to node image width but
37757 * uses original value from API so can be faulty.
37759 * @returns {number} The width of the basic version image
37760 * (adjusted for orientation).
37763 return this._basicWidth;
37768 Object.defineProperty(Transform.prototype, "focal", {
37771 * @returns {number} The node focal length.
37774 return this._focal;
37779 Object.defineProperty(Transform.prototype, "fullPano", {
37783 * @returns {boolean} Value indicating whether the node is a complete
37787 return this._gpano != null &&
37788 this._gpano.CroppedAreaLeftPixels === 0 &&
37789 this._gpano.CroppedAreaTopPixels === 0 &&
37790 this._gpano.CroppedAreaImageWidthPixels === this._gpano.FullPanoWidthPixels &&
37791 this._gpano.CroppedAreaImageHeightPixels === this._gpano.FullPanoHeightPixels;
37796 Object.defineProperty(Transform.prototype, "gpano", {
37799 * @returns {number} The node gpano information.
37802 return this._gpano;
37807 Object.defineProperty(Transform.prototype, "height", {
37811 * @description Falls back to the node image height if
37812 * the API data is faulty.
37814 * @returns {number} The orientation adjusted image height.
37817 return this._height;
37822 Object.defineProperty(Transform.prototype, "orientation", {
37825 * @returns {number} The image orientation.
37828 return this._orientation;
37833 Object.defineProperty(Transform.prototype, "rt", {
37836 * @returns {THREE.Matrix4} The extrinsic camera matrix.
37844 Object.defineProperty(Transform.prototype, "srt", {
37847 * @returns {THREE.Matrix4} The scaled extrinsic camera matrix.
37855 Object.defineProperty(Transform.prototype, "scale", {
37858 * @returns {number} The node atomic reconstruction scale.
37861 return this._scale;
37866 Object.defineProperty(Transform.prototype, "hasValidScale", {
37868 * Get has valid scale.
37869 * @returns {boolean} Value indicating if the scale of the transform is valid.
37872 return this._scale > 1e-2 && this._scale < 50;
37877 Object.defineProperty(Transform.prototype, "radialPeak", {
37880 * @returns {number} Value indicating the radius where the radial
37881 * undistortion function peaks.
37884 return this._radialPeak;
37889 Object.defineProperty(Transform.prototype, "width", {
37893 * @description Falls back to the node image width if
37894 * the API data is faulty.
37896 * @returns {number} The orientation adjusted image width.
37899 return this._width;
37905 * Calculate the up vector for the node transform.
37907 * @returns {THREE.Vector3} Normalized and orientation adjusted up vector.
37909 Transform.prototype.upVector = function () {
37910 var rte = this._rt.elements;
37911 switch (this._orientation) {
37913 return new THREE.Vector3(-rte[1], -rte[5], -rte[9]);
37915 return new THREE.Vector3(rte[1], rte[5], rte[9]);
37917 return new THREE.Vector3(-rte[0], -rte[4], -rte[8]);
37919 return new THREE.Vector3(rte[0], rte[4], rte[8]);
37921 return new THREE.Vector3(-rte[1], -rte[5], -rte[9]);
37925 * Calculate projector matrix for projecting 3D points to texture map
37926 * coordinates (u and v).
37928 * @returns {THREE.Matrix4} Projection matrix for 3D point to texture
37929 * map coordinate calculations.
37931 Transform.prototype.projectorMatrix = function () {
37932 var projector = this._normalizedToTextureMatrix();
37933 var f = this._focal;
37934 var projection = new THREE.Matrix4().set(f, 0, 0, 0, 0, f, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0);
37935 projector.multiply(projection);
37936 projector.multiply(this._rt);
37940 * Project 3D world coordinates to basic coordinates.
37942 * @param {Array<number>} point3d - 3D world coordinates.
37943 * @return {Array<number>} 2D basic coordinates.
37945 Transform.prototype.projectBasic = function (point3d) {
37946 var sfm = this.projectSfM(point3d);
37947 return this._sfmToBasic(sfm);
37950 * Unproject basic coordinates to 3D world coordinates.
37952 * @param {Array<number>} basic - 2D basic coordinates.
37953 * @param {Array<number>} distance - Distance to unproject from camera center.
37954 * @param {boolean} [depth] - Treat the distance value as depth from camera center.
37955 * Only applicable for perspective images. Will be
37956 * ignored for panoramas.
37957 * @returns {Array<number>} Unprojected 3D world coordinates.
37959 Transform.prototype.unprojectBasic = function (basic, distance, depth) {
37960 var sfm = this._basicToSfm(basic);
37961 return this.unprojectSfM(sfm, distance, depth);
37964 * Project 3D world coordinates to SfM coordinates.
37966 * @param {Array<number>} point3d - 3D world coordinates.
37967 * @return {Array<number>} 2D SfM coordinates.
37969 Transform.prototype.projectSfM = function (point3d) {
37970 var v = new THREE.Vector4(point3d[0], point3d[1], point3d[2], 1);
37971 v.applyMatrix4(this._rt);
37972 return this._bearingToSfm([v.x, v.y, v.z]);
37975 * Unproject SfM coordinates to a 3D world coordinates.
37977 * @param {Array<number>} sfm - 2D SfM coordinates.
37978 * @param {Array<number>} distance - Distance to unproject from camera center.
37979 * @param {boolean} [depth] - Treat the distance value as depth from camera center.
37980 * Only applicable for perspective images. Will be
37981 * ignored for panoramas.
37982 * @returns {Array<number>} Unprojected 3D world coordinates.
37984 Transform.prototype.unprojectSfM = function (sfm, distance, depth) {
37985 var bearing = this._sfmToBearing(sfm);
37986 var v = depth && !this.gpano ?
37987 new THREE.Vector4(distance * bearing[0] / bearing[2], distance * bearing[1] / bearing[2], distance, 1) :
37988 new THREE.Vector4(distance * bearing[0], distance * bearing[1], distance * bearing[2], 1);
37989 v.applyMatrix4(new THREE.Matrix4().getInverse(this._rt));
37990 return [v.x / v.w, v.y / v.w, v.z / v.w];
37993 * Transform SfM coordinates to bearing vector (3D cartesian
37994 * coordinates on the unit sphere).
37996 * @param {Array<number>} sfm - 2D SfM coordinates.
37997 * @returns {Array<number>} Bearing vector (3D cartesian coordinates
37998 * on the unit sphere).
38000 Transform.prototype._sfmToBearing = function (sfm) {
38001 if (this._fullPano()) {
38002 var lon = sfm[0] * 2 * Math.PI;
38003 var lat = -sfm[1] * 2 * Math.PI;
38004 var x = Math.cos(lat) * Math.sin(lon);
38005 var y = -Math.sin(lat);
38006 var z = Math.cos(lat) * Math.cos(lon);
38009 else if (this._gpano) {
38010 var size = Math.max(this.gpano.CroppedAreaImageWidthPixels, this.gpano.CroppedAreaImageHeightPixels);
38011 var fullPanoPixel = [
38012 sfm[0] * size + this.gpano.CroppedAreaImageWidthPixels / 2 + this.gpano.CroppedAreaLeftPixels,
38013 sfm[1] * size + this.gpano.CroppedAreaImageHeightPixels / 2 + this.gpano.CroppedAreaTopPixels,
38015 var lon = 2 * Math.PI * (fullPanoPixel[0] / this.gpano.FullPanoWidthPixels - 0.5);
38016 var lat = -Math.PI * (fullPanoPixel[1] / this.gpano.FullPanoHeightPixels - 0.5);
38017 var x = Math.cos(lat) * Math.sin(lon);
38018 var y = -Math.sin(lat);
38019 var z = Math.cos(lat) * Math.cos(lon);
38022 else if (this._cameraProjection === "fisheye") {
38023 var _a = [sfm[0] / this._focal, sfm[1] / this._focal], dxn = _a[0], dyn = _a[1];
38024 var dTheta = Math.sqrt(dxn * dxn + dyn * dyn);
38025 var d = this._distortionFromDistortedRadius(dTheta, this._ck1, this._ck2, this._radialPeak);
38026 var theta = dTheta / d;
38027 var z = Math.cos(theta);
38028 var r = Math.sin(theta);
38029 var x = r * dxn / dTheta;
38030 var y = r * dyn / dTheta;
38034 var _b = [sfm[0] / this._focal, sfm[1] / this._focal], dxn = _b[0], dyn = _b[1];
38035 var dr = Math.sqrt(dxn * dxn + dyn * dyn);
38036 var d = this._distortionFromDistortedRadius(dr, this._ck1, this._ck2, this._radialPeak);
38039 var v = new THREE.Vector3(xn, yn, 1);
38041 return [v.x, v.y, v.z];
38044 /** Compute distortion given the distorted radius.
38046 * Solves for d in the equation
38047 * y = d(x, k1, k2) * x
38048 * given the distorted radius, y.
38050 Transform.prototype._distortionFromDistortedRadius = function (distortedRadius, k1, k2, radialPeak) {
38052 for (var i = 0; i < 10; i++) {
38053 var radius = distortedRadius / d;
38054 if (radius > radialPeak) {
38055 radius = radialPeak;
38057 d = 1 + k1 * Math.pow(radius, 2) + k2 * Math.pow(radius, 4);
38062 * Transform bearing vector (3D cartesian coordiantes on the unit sphere) to
38065 * @param {Array<number>} bearing - Bearing vector (3D cartesian coordinates on the
38067 * @returns {Array<number>} 2D SfM coordinates.
38069 Transform.prototype._bearingToSfm = function (bearing) {
38070 if (this._fullPano()) {
38071 var x = bearing[0];
38072 var y = bearing[1];
38073 var z = bearing[2];
38074 var lon = Math.atan2(x, z);
38075 var lat = Math.atan2(-y, Math.sqrt(x * x + z * z));
38076 return [lon / (2 * Math.PI), -lat / (2 * Math.PI)];
38078 else if (this._gpano) {
38079 var x = bearing[0];
38080 var y = bearing[1];
38081 var z = bearing[2];
38082 var lon = Math.atan2(x, z);
38083 var lat = Math.atan2(-y, Math.sqrt(x * x + z * z));
38084 var fullPanoPixel = [
38085 (lon / (2 * Math.PI) + 0.5) * this.gpano.FullPanoWidthPixels,
38086 (-lat / Math.PI + 0.5) * this.gpano.FullPanoHeightPixels,
38088 var size = Math.max(this.gpano.CroppedAreaImageWidthPixels, this.gpano.CroppedAreaImageHeightPixels);
38090 (fullPanoPixel[0] - this.gpano.CroppedAreaLeftPixels - this.gpano.CroppedAreaImageWidthPixels / 2) / size,
38091 (fullPanoPixel[1] - this.gpano.CroppedAreaTopPixels - this.gpano.CroppedAreaImageHeightPixels / 2) / size,
38094 else if (this._cameraProjection === "fisheye") {
38095 if (bearing[2] > 0) {
38096 var x = bearing[0], y = bearing[1], z = bearing[2];
38097 var r = Math.sqrt(x * x + y * y);
38098 var theta = Math.atan2(r, z);
38099 if (theta > this._radialPeak) {
38100 theta = this._radialPeak;
38102 var distortion = 1.0 + Math.pow(theta, 2) * (this._ck1 + Math.pow(theta, 2) * this._ck2);
38103 var s = this._focal * distortion * theta / r;
38104 return [s * x, s * y];
38108 bearing[0] < 0 ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY,
38109 bearing[1] < 0 ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY,
38114 if (bearing[2] > 0) {
38115 var _a = [bearing[0] / bearing[2], bearing[1] / bearing[2]], xn = _a[0], yn = _a[1];
38116 var r2 = xn * xn + yn * yn;
38117 var rp2 = Math.pow(this._radialPeak, 2);
38121 var d = 1 + this._ck1 * r2 + this._ck2 * Math.pow(r2, 2);
38123 this._focal * d * xn,
38124 this._focal * d * yn,
38129 bearing[0] < 0 ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY,
38130 bearing[1] < 0 ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY,
38136 * Convert basic coordinates to SfM coordinates.
38138 * @param {Array<number>} basic - 2D basic coordinates.
38139 * @returns {Array<number>} 2D SfM coordinates.
38141 Transform.prototype._basicToSfm = function (basic) {
38144 switch (this._orientation) {
38146 rotatedX = basic[0];
38147 rotatedY = basic[1];
38150 rotatedX = 1 - basic[0];
38151 rotatedY = 1 - basic[1];
38154 rotatedX = basic[1];
38155 rotatedY = 1 - basic[0];
38158 rotatedX = 1 - basic[1];
38159 rotatedY = basic[0];
38162 rotatedX = basic[0];
38163 rotatedY = basic[1];
38166 var w = this._width;
38167 var h = this._height;
38168 var s = Math.max(w, h);
38169 var sfmX = rotatedX * w / s - w / s / 2;
38170 var sfmY = rotatedY * h / s - h / s / 2;
38171 return [sfmX, sfmY];
38174 * Convert SfM coordinates to basic coordinates.
38176 * @param {Array<number>} sfm - 2D SfM coordinates.
38177 * @returns {Array<number>} 2D basic coordinates.
38179 Transform.prototype._sfmToBasic = function (sfm) {
38180 var w = this._width;
38181 var h = this._height;
38182 var s = Math.max(w, h);
38183 var rotatedX = (sfm[0] + w / s / 2) / w * s;
38184 var rotatedY = (sfm[1] + h / s / 2) / h * s;
38187 switch (this._orientation) {
38193 basicX = 1 - rotatedX;
38194 basicY = 1 - rotatedY;
38197 basicX = 1 - rotatedY;
38202 basicY = 1 - rotatedX;
38209 return [basicX, basicY];
38212 * Determines if the gpano information indicates a full panorama.
38214 * @returns {boolean} Value determining if the gpano information indicates
38217 Transform.prototype._fullPano = function () {
38218 return this.gpano != null &&
38219 this.gpano.CroppedAreaLeftPixels === 0 &&
38220 this.gpano.CroppedAreaTopPixels === 0 &&
38221 this.gpano.CroppedAreaImageWidthPixels === this.gpano.FullPanoWidthPixels &&
38222 this.gpano.CroppedAreaImageHeightPixels === this.gpano.FullPanoHeightPixels;
38225 * Checks a value and returns it if it exists and is larger than 0.
38226 * Fallbacks if it is null.
38228 * @param {number} value - Value to check.
38229 * @param {number} fallback - Value to fall back to.
38230 * @returns {number} The value or its fallback value if it is not defined or negative.
38232 Transform.prototype._getValue = function (value, fallback) {
38233 return value != null && value > 0 ? value : fallback;
38236 * Creates the extrinsic camera matrix [ R | t ].
38238 * @param {Array<number>} rotation - Rotation vector in angle axis representation.
38239 * @param {Array<number>} translation - Translation vector.
38240 * @returns {THREE.Matrix4} Extrisic camera matrix.
38242 Transform.prototype._getRt = function (rotation, translation) {
38243 var axis = new THREE.Vector3(rotation[0], rotation[1], rotation[2]);
38244 var angle = axis.length();
38248 var rt = new THREE.Matrix4();
38249 rt.makeRotationAxis(axis, angle);
38250 rt.setPosition(new THREE.Vector3(translation[0], translation[1], translation[2]));
38254 * Calculates the scaled extrinsic camera matrix scale * [ R | t ].
38256 * @param {THREE.Matrix4} rt - Extrisic camera matrix.
38257 * @param {number} scale - Scale factor.
38258 * @returns {THREE.Matrix4} Scaled extrisic camera matrix.
38260 Transform.prototype._getSrt = function (rt, scale) {
38261 var srt = rt.clone();
38262 var elements = srt.elements;
38263 elements[12] = scale * elements[12];
38264 elements[13] = scale * elements[13];
38265 elements[14] = scale * elements[14];
38266 srt.scale(new THREE.Vector3(scale, scale, scale));
38269 Transform.prototype._getBasicRt = function (rt, orientation) {
38270 var axis = new THREE.Vector3(0, 0, 1);
38272 switch (orientation) {
38277 angle = Math.PI / 2;
38280 angle = 3 * Math.PI / 2;
38285 return new THREE.Matrix4()
38286 .makeRotationAxis(axis, angle)
38289 Transform.prototype._getRadialPeak = function (k1, k2) {
38293 var d = Math.pow(b, 2) - 4 * a * c;
38297 var root1 = (-b - Math.sqrt(d)) / 2 / a;
38298 var root2 = (-b + Math.sqrt(d)) / 2 / a;
38299 var minRoot = Math.min(root1, root2);
38300 var maxRoot = Math.max(root1, root2);
38301 return minRoot > 0 ?
38302 Math.sqrt(minRoot) :
38304 Math.sqrt(maxRoot) :
38308 * Calculate a transformation matrix from normalized coordinates for
38309 * texture map coordinates.
38311 * @returns {THREE.Matrix4} Normalized coordinates to texture map
38312 * coordinates transformation matrix.
38314 Transform.prototype._normalizedToTextureMatrix = function () {
38315 var size = Math.max(this._width, this._height);
38316 var scaleX = this._orientation < 5 ? this._textureScale[0] : this._textureScale[1];
38317 var scaleY = this._orientation < 5 ? this._textureScale[1] : this._textureScale[0];
38318 var w = size / this._width * scaleX;
38319 var h = size / this._height * scaleY;
38320 switch (this._orientation) {
38322 return new THREE.Matrix4().set(w, 0, 0, 0.5, 0, -h, 0, 0.5, 0, 0, 1, 0, 0, 0, 0, 1);
38324 return new THREE.Matrix4().set(-w, 0, 0, 0.5, 0, h, 0, 0.5, 0, 0, 1, 0, 0, 0, 0, 1);
38326 return new THREE.Matrix4().set(0, -h, 0, 0.5, -w, 0, 0, 0.5, 0, 0, 1, 0, 0, 0, 0, 1);
38328 return new THREE.Matrix4().set(0, h, 0, 0.5, w, 0, 0, 0.5, 0, 0, 1, 0, 0, 0, 0, 1);
38330 return new THREE.Matrix4().set(w, 0, 0, 0.5, 0, -h, 0, 0.5, 0, 0, 1, 0, 0, 0, 0, 1);
38335 exports.Transform = Transform;
38337 },{"three":226}],388:[function(require,module,exports){
38339 Object.defineProperty(exports, "__esModule", { value: true });
38340 var THREE = require("three");
38342 * @class ViewportCoords
38344 * @classdesc Provides methods for calculating 2D coordinate conversions
38345 * as well as 3D projection and unprojection.
38347 * Basic coordinates are 2D coordinates on the [0, 1] interval and
38348 * have the origin point, (0, 0), at the top left corner and the
38349 * maximum value, (1, 1), at the bottom right corner of the original
38352 * Viewport coordinates are 2D coordinates on the [-1, 1] interval and
38353 * have the origin point in the center. The bottom left corner point is
38354 * (-1, -1) and the top right corner point is (1, 1).
38356 * Canvas coordiantes are 2D pixel coordinates on the [0, canvasWidth] and
38357 * [0, canvasHeight] intervals. The origin point (0, 0) is in the top left
38358 * corner and the maximum value is (canvasWidth, canvasHeight) is in the
38359 * bottom right corner.
38361 * 3D coordinates are in the topocentric world reference frame.
38363 var ViewportCoords = /** @class */ (function () {
38364 function ViewportCoords() {
38365 this._unprojectDepth = 200;
38368 * Convert basic coordinates to canvas coordinates.
38370 * @description Transform origin and camera position needs to be the
38371 * equal for reliable return value.
38373 * @param {number} basicX - Basic X coordinate.
38374 * @param {number} basicY - Basic Y coordinate.
38375 * @param {HTMLElement} container - The viewer container.
38376 * @param {Transform} transform - Transform of the node to unproject from.
38377 * @param {THREE.Camera} camera - Camera used in rendering.
38378 * @returns {Array<number>} 2D canvas coordinates.
38380 ViewportCoords.prototype.basicToCanvas = function (basicX, basicY, container, transform, camera) {
38381 var point3d = transform.unprojectBasic([basicX, basicY], this._unprojectDepth);
38382 var canvas = this.projectToCanvas(point3d, container, camera);
38386 * Convert basic coordinates to canvas coordinates safely. If 3D point is
38387 * behind camera null will be returned.
38389 * @description Transform origin and camera position needs to be the
38390 * equal for reliable return value.
38392 * @param {number} basicX - Basic X coordinate.
38393 * @param {number} basicY - Basic Y coordinate.
38394 * @param {HTMLElement} container - The viewer container.
38395 * @param {Transform} transform - Transform of the node to unproject from.
38396 * @param {THREE.Camera} camera - Camera used in rendering.
38397 * @returns {Array<number>} 2D canvas coordinates if the basic point represents a 3D point
38398 * in front of the camera, otherwise null.
38400 ViewportCoords.prototype.basicToCanvasSafe = function (basicX, basicY, container, transform, camera) {
38401 var viewport = this.basicToViewportSafe(basicX, basicY, transform, camera);
38402 if (viewport === null) {
38405 var canvas = this.viewportToCanvas(viewport[0], viewport[1], container);
38409 * Convert basic coordinates to viewport coordinates.
38411 * @description Transform origin and camera position needs to be the
38412 * equal for reliable return value.
38414 * @param {number} basicX - Basic X coordinate.
38415 * @param {number} basicY - Basic Y coordinate.
38416 * @param {Transform} transform - Transform of the node to unproject from.
38417 * @param {THREE.Camera} camera - Camera used in rendering.
38418 * @returns {Array<number>} 2D viewport coordinates.
38420 ViewportCoords.prototype.basicToViewport = function (basicX, basicY, transform, camera) {
38421 var point3d = transform.unprojectBasic([basicX, basicY], this._unprojectDepth);
38422 var viewport = this.projectToViewport(point3d, camera);
38426 * Convert basic coordinates to viewport coordinates safely. If 3D point is
38427 * behind camera null will be returned.
38429 * @description Transform origin and camera position needs to be the
38430 * equal for reliable return value.
38432 * @param {number} basicX - Basic X coordinate.
38433 * @param {number} basicY - Basic Y coordinate.
38434 * @param {Transform} transform - Transform of the node to unproject from.
38435 * @param {THREE.Camera} camera - Camera used in rendering.
38436 * @returns {Array<number>} 2D viewport coordinates.
38438 ViewportCoords.prototype.basicToViewportSafe = function (basicX, basicY, transform, camera) {
38439 var point3d = transform.unprojectBasic([basicX, basicY], this._unprojectDepth);
38440 var pointCamera = this.worldToCamera(point3d, camera);
38441 if (pointCamera[2] > 0) {
38444 var viewport = this.projectToViewport(point3d, camera);
38448 * Convert camera 3D coordinates to viewport coordinates.
38450 * @param {number} pointCamera - 3D point in camera coordinate system.
38451 * @param {THREE.Camera} camera - Camera used in rendering.
38452 * @returns {Array<number>} 2D viewport coordinates.
38454 ViewportCoords.prototype.cameraToViewport = function (pointCamera, camera) {
38455 var viewport = new THREE.Vector3().fromArray(pointCamera)
38456 .applyMatrix4(camera.projectionMatrix);
38457 return [viewport.x, viewport.y];
38460 * Get canvas pixel position from event.
38462 * @param {Event} event - Event containing clientX and clientY properties.
38463 * @param {HTMLElement} element - HTML element.
38464 * @returns {Array<number>} 2D canvas coordinates.
38466 ViewportCoords.prototype.canvasPosition = function (event, element) {
38467 var clientRect = element.getBoundingClientRect();
38468 var canvasX = event.clientX - clientRect.left - element.clientLeft;
38469 var canvasY = event.clientY - clientRect.top - element.clientTop;
38470 return [canvasX, canvasY];
38473 * Convert canvas coordinates to basic coordinates.
38475 * @description Transform origin and camera position needs to be the
38476 * equal for reliable return value.
38478 * @param {number} canvasX - Canvas X coordinate.
38479 * @param {number} canvasY - Canvas Y coordinate.
38480 * @param {HTMLElement} container - The viewer container.
38481 * @param {Transform} transform - Transform of the node to unproject from.
38482 * @param {THREE.Camera} camera - Camera used in rendering.
38483 * @returns {Array<number>} 2D basic coordinates.
38485 ViewportCoords.prototype.canvasToBasic = function (canvasX, canvasY, container, transform, camera) {
38486 var point3d = this.unprojectFromCanvas(canvasX, canvasY, container, camera)
38488 var basic = transform.projectBasic(point3d);
38492 * Convert canvas coordinates to viewport coordinates.
38494 * @param {number} canvasX - Canvas X coordinate.
38495 * @param {number} canvasY - Canvas Y coordinate.
38496 * @param {HTMLElement} container - The viewer container.
38497 * @returns {Array<number>} 2D viewport coordinates.
38499 ViewportCoords.prototype.canvasToViewport = function (canvasX, canvasY, container) {
38500 var _a = this.containerToCanvas(container), canvasWidth = _a[0], canvasHeight = _a[1];
38501 var viewportX = 2 * canvasX / canvasWidth - 1;
38502 var viewportY = 1 - 2 * canvasY / canvasHeight;
38503 return [viewportX, viewportY];
38506 * Determines the width and height of the container in canvas coordinates.
38508 * @param {HTMLElement} container - The viewer container.
38509 * @returns {Array<number>} 2D canvas coordinates.
38511 ViewportCoords.prototype.containerToCanvas = function (container) {
38512 return [container.offsetWidth, container.offsetHeight];
38515 * Determine basic distances from image to canvas corners.
38517 * @description Transform origin and camera position needs to be the
38518 * equal for reliable return value.
38520 * Determines the smallest basic distance for every side of the canvas.
38522 * @param {Transform} transform - Transform of the node to unproject from.
38523 * @param {THREE.Camera} camera - Camera used in rendering.
38524 * @returns {Array<number>} Array of basic distances as [top, right, bottom, left].
38526 ViewportCoords.prototype.getBasicDistances = function (transform, camera) {
38527 var topLeftBasic = this.viewportToBasic(-1, 1, transform, camera);
38528 var topRightBasic = this.viewportToBasic(1, 1, transform, camera);
38529 var bottomRightBasic = this.viewportToBasic(1, -1, transform, camera);
38530 var bottomLeftBasic = this.viewportToBasic(-1, -1, transform, camera);
38531 var topBasicDistance = 0;
38532 var rightBasicDistance = 0;
38533 var bottomBasicDistance = 0;
38534 var leftBasicDistance = 0;
38535 if (topLeftBasic[1] < 0 && topRightBasic[1] < 0) {
38536 topBasicDistance = topLeftBasic[1] > topRightBasic[1] ?
38540 if (topRightBasic[0] > 1 && bottomRightBasic[0] > 1) {
38541 rightBasicDistance = topRightBasic[0] < bottomRightBasic[0] ?
38542 topRightBasic[0] - 1 :
38543 bottomRightBasic[0] - 1;
38545 if (bottomRightBasic[1] > 1 && bottomLeftBasic[1] > 1) {
38546 bottomBasicDistance = bottomRightBasic[1] < bottomLeftBasic[1] ?
38547 bottomRightBasic[1] - 1 :
38548 bottomLeftBasic[1] - 1;
38550 if (bottomLeftBasic[0] < 0 && topLeftBasic[0] < 0) {
38551 leftBasicDistance = bottomLeftBasic[0] > topLeftBasic[0] ?
38552 -bottomLeftBasic[0] :
38555 return [topBasicDistance, rightBasicDistance, bottomBasicDistance, leftBasicDistance];
38558 * Determine pixel distances from image to canvas corners.
38560 * @description Transform origin and camera position needs to be the
38561 * equal for reliable return value.
38563 * Determines the smallest pixel distance for every side of the canvas.
38565 * @param {HTMLElement} container - The viewer container.
38566 * @param {Transform} transform - Transform of the node to unproject from.
38567 * @param {THREE.Camera} camera - Camera used in rendering.
38568 * @returns {Array<number>} Array of pixel distances as [top, right, bottom, left].
38570 ViewportCoords.prototype.getPixelDistances = function (container, transform, camera) {
38571 var topLeftBasic = this.viewportToBasic(-1, 1, transform, camera);
38572 var topRightBasic = this.viewportToBasic(1, 1, transform, camera);
38573 var bottomRightBasic = this.viewportToBasic(1, -1, transform, camera);
38574 var bottomLeftBasic = this.viewportToBasic(-1, -1, transform, camera);
38575 var topPixelDistance = 0;
38576 var rightPixelDistance = 0;
38577 var bottomPixelDistance = 0;
38578 var leftPixelDistance = 0;
38579 var _a = this.containerToCanvas(container), canvasWidth = _a[0], canvasHeight = _a[1];
38580 if (topLeftBasic[1] < 0 && topRightBasic[1] < 0) {
38581 var basicX = topLeftBasic[1] > topRightBasic[1] ?
38584 var canvas = this.basicToCanvas(basicX, 0, container, transform, camera);
38585 topPixelDistance = canvas[1] > 0 ? canvas[1] : 0;
38587 if (topRightBasic[0] > 1 && bottomRightBasic[0] > 1) {
38588 var basicY = topRightBasic[0] < bottomRightBasic[0] ?
38590 bottomRightBasic[1];
38591 var canvas = this.basicToCanvas(1, basicY, container, transform, camera);
38592 rightPixelDistance = canvas[0] < canvasWidth ? canvasWidth - canvas[0] : 0;
38594 if (bottomRightBasic[1] > 1 && bottomLeftBasic[1] > 1) {
38595 var basicX = bottomRightBasic[1] < bottomLeftBasic[1] ?
38596 bottomRightBasic[0] :
38597 bottomLeftBasic[0];
38598 var canvas = this.basicToCanvas(basicX, 1, container, transform, camera);
38599 bottomPixelDistance = canvas[1] < canvasHeight ? canvasHeight - canvas[1] : 0;
38601 if (bottomLeftBasic[0] < 0 && topLeftBasic[0] < 0) {
38602 var basicY = bottomLeftBasic[0] > topLeftBasic[0] ?
38603 bottomLeftBasic[1] :
38605 var canvas = this.basicToCanvas(0, basicY, container, transform, camera);
38606 leftPixelDistance = canvas[0] > 0 ? canvas[0] : 0;
38608 return [topPixelDistance, rightPixelDistance, bottomPixelDistance, leftPixelDistance];
38611 * Determine if an event occured inside an element.
38613 * @param {Event} event - Event containing clientX and clientY properties.
38614 * @param {HTMLElement} element - HTML element.
38615 * @returns {boolean} Value indicating if the event occured inside the element or not.
38617 ViewportCoords.prototype.insideElement = function (event, element) {
38618 var clientRect = element.getBoundingClientRect();
38619 var minX = clientRect.left + element.clientLeft;
38620 var maxX = minX + element.clientWidth;
38621 var minY = clientRect.top + element.clientTop;
38622 var maxY = minY + element.clientHeight;
38623 return event.clientX > minX &&
38624 event.clientX < maxX &&
38625 event.clientY > minY &&
38626 event.clientY < maxY;
38629 * Project 3D world coordinates to canvas coordinates.
38631 * @param {Array<number>} point3D - 3D world coordinates.
38632 * @param {HTMLElement} container - The viewer container.
38633 * @param {THREE.Camera} camera - Camera used in rendering.
38634 * @returns {Array<number>} 2D canvas coordinates.
38636 ViewportCoords.prototype.projectToCanvas = function (point3d, container, camera) {
38637 var viewport = this.projectToViewport(point3d, camera);
38638 var canvas = this.viewportToCanvas(viewport[0], viewport[1], container);
38642 * Project 3D world coordinates to viewport coordinates.
38644 * @param {Array<number>} point3D - 3D world coordinates.
38645 * @param {THREE.Camera} camera - Camera used in rendering.
38646 * @returns {Array<number>} 2D viewport coordinates.
38648 ViewportCoords.prototype.projectToViewport = function (point3d, camera) {
38649 var viewport = new THREE.Vector3(point3d[0], point3d[1], point3d[2])
38651 return [viewport.x, viewport.y];
38654 * Uproject canvas coordinates to 3D world coordinates.
38656 * @param {number} canvasX - Canvas X coordinate.
38657 * @param {number} canvasY - Canvas Y coordinate.
38658 * @param {HTMLElement} container - The viewer container.
38659 * @param {THREE.Camera} camera - Camera used in rendering.
38660 * @returns {Array<number>} 3D world coordinates.
38662 ViewportCoords.prototype.unprojectFromCanvas = function (canvasX, canvasY, container, camera) {
38663 var viewport = this.canvasToViewport(canvasX, canvasY, container);
38664 var point3d = this.unprojectFromViewport(viewport[0], viewport[1], camera);
38668 * Unproject viewport coordinates to 3D world coordinates.
38670 * @param {number} viewportX - Viewport X coordinate.
38671 * @param {number} viewportY - Viewport Y coordinate.
38672 * @param {THREE.Camera} camera - Camera used in rendering.
38673 * @returns {Array<number>} 3D world coordinates.
38675 ViewportCoords.prototype.unprojectFromViewport = function (viewportX, viewportY, camera) {
38676 var point3d = new THREE.Vector3(viewportX, viewportY, 1)
38677 .unproject(camera);
38681 * Convert viewport coordinates to basic coordinates.
38683 * @description Transform origin and camera position needs to be the
38684 * equal for reliable return value.
38686 * @param {number} viewportX - Viewport X coordinate.
38687 * @param {number} viewportY - Viewport Y coordinate.
38688 * @param {Transform} transform - Transform of the node to unproject from.
38689 * @param {THREE.Camera} camera - Camera used in rendering.
38690 * @returns {Array<number>} 2D basic coordinates.
38692 ViewportCoords.prototype.viewportToBasic = function (viewportX, viewportY, transform, camera) {
38693 var point3d = new THREE.Vector3(viewportX, viewportY, 1)
38696 var basic = transform.projectBasic(point3d);
38700 * Convert viewport coordinates to canvas coordinates.
38702 * @param {number} viewportX - Viewport X coordinate.
38703 * @param {number} viewportY - Viewport Y coordinate.
38704 * @param {HTMLElement} container - The viewer container.
38705 * @returns {Array<number>} 2D canvas coordinates.
38707 ViewportCoords.prototype.viewportToCanvas = function (viewportX, viewportY, container) {
38708 var _a = this.containerToCanvas(container), canvasWidth = _a[0], canvasHeight = _a[1];
38709 var canvasX = canvasWidth * (viewportX + 1) / 2;
38710 var canvasY = -canvasHeight * (viewportY - 1) / 2;
38711 return [canvasX, canvasY];
38714 * Convert 3D world coordinates to 3D camera coordinates.
38716 * @param {number} point3D - 3D point in world coordinate system.
38717 * @param {THREE.Camera} camera - Camera used in rendering.
38718 * @returns {Array<number>} 3D camera coordinates.
38720 ViewportCoords.prototype.worldToCamera = function (point3d, camera) {
38721 var pointCamera = new THREE.Vector3(point3d[0], point3d[1], point3d[2])
38722 .applyMatrix4(camera.matrixWorldInverse);
38723 return pointCamera.toArray();
38725 return ViewportCoords;
38727 exports.ViewportCoords = ViewportCoords;
38728 exports.default = ViewportCoords;
38731 },{"three":226}],389:[function(require,module,exports){
38733 Object.defineProperty(exports, "__esModule", { value: true });
38737 * @classdesc Represents a class for creating node filters. Implementation and
38738 * definitions based on https://github.com/mapbox/feature-filter.
38740 var FilterCreator = /** @class */ (function () {
38741 function FilterCreator() {
38744 * Create a filter from a filter expression.
38746 * @description The following filters are supported:
38763 * @param {FilterExpression} filter - Comparison, set membership or combinding filter
38765 * @returns {FilterFunction} Function taking a node and returning a boolean that
38766 * indicates whether the node passed the test or not.
38768 FilterCreator.prototype.createFilter = function (filter) {
38769 return new Function("node", "return " + this._compile(filter) + ";");
38771 FilterCreator.prototype._compile = function (filter) {
38772 if (filter == null || filter.length <= 1) {
38775 var operator = filter[0];
38776 var operation = operator === "==" ? this._compileComparisonOp("===", filter[1], filter[2], false) :
38777 operator === "!=" ? this._compileComparisonOp("!==", filter[1], filter[2], false) :
38778 operator === ">" ||
38779 operator === ">=" ||
38780 operator === "<" ||
38781 operator === "<=" ? this._compileComparisonOp(operator, filter[1], filter[2], true) :
38782 operator === "in" ?
38783 this._compileInOp(filter[1], filter.slice(2)) :
38784 operator === "!in" ?
38785 this._compileNegation(this._compileInOp(filter[1], filter.slice(2))) :
38786 operator === "all" ? this._compileLogicalOp(filter.slice(1), "&&") :
38788 return "(" + operation + ")";
38790 FilterCreator.prototype._compare = function (a, b) {
38791 return a < b ? -1 : a > b ? 1 : 0;
38793 FilterCreator.prototype._compileComparisonOp = function (operator, property, value, checkType) {
38794 var left = this._compilePropertyReference(property);
38795 var right = JSON.stringify(value);
38796 return (checkType ? "typeof " + left + "===typeof " + right + "&&" : "") + left + operator + right;
38798 FilterCreator.prototype._compileInOp = function (property, values) {
38799 var compare = this._compare;
38800 var left = JSON.stringify(values.sort(compare));
38801 var right = this._compilePropertyReference(property);
38802 return left + ".indexOf(" + right + ")!==-1";
38804 FilterCreator.prototype._compileLogicalOp = function (filters, operator) {
38805 var compile = this._compile.bind(this);
38806 return filters.map(compile).join(operator);
38808 FilterCreator.prototype._compileNegation = function (expression) {
38809 return "!(" + expression + ")";
38811 FilterCreator.prototype._compilePropertyReference = function (property) {
38812 return "node[" + JSON.stringify(property) + "]";
38814 return FilterCreator;
38816 exports.FilterCreator = FilterCreator;
38817 exports.default = FilterCreator;
38819 },{}],390:[function(require,module,exports){
38821 Object.defineProperty(exports, "__esModule", { value: true });
38822 var rxjs_1 = require("rxjs");
38823 var operators_1 = require("rxjs/operators");
38824 var rbush = require("rbush");
38825 var Edge_1 = require("../Edge");
38826 var Error_1 = require("../Error");
38827 var Graph_1 = require("../Graph");
38831 * @classdesc Represents a graph of nodes with edges.
38833 var Graph = /** @class */ (function () {
38835 * Create a new graph instance.
38837 * @param {APIv3} [apiV3] - API instance for retrieving data.
38838 * @param {rbush.RBush<NodeIndexItem>} [nodeIndex] - Node index for fast spatial retreival.
38839 * @param {GraphCalculator} [graphCalculator] - Instance for graph calculations.
38840 * @param {EdgeCalculator} [edgeCalculator] - Instance for edge calculations.
38841 * @param {FilterCreator} [filterCreator] - Instance for filter creation.
38842 * @param {IGraphConfiguration} [configuration] - Configuration struct.
38844 function Graph(apiV3, nodeIndex, graphCalculator, edgeCalculator, filterCreator, configuration) {
38845 this._apiV3 = apiV3;
38846 this._cachedNodes = {};
38847 this._cachedNodeTiles = {};
38848 this._cachedSequenceNodes = {};
38849 this._cachedSpatialEdges = {};
38850 this._cachedTiles = {};
38851 this._cachingFill$ = {};
38852 this._cachingFull$ = {};
38853 this._cachingSequenceNodes$ = {};
38854 this._cachingSequences$ = {};
38855 this._cachingSpatialArea$ = {};
38856 this._cachingTiles$ = {};
38857 this._changed$ = new rxjs_1.Subject();
38858 this._defaultAlt = 2;
38859 this._edgeCalculator = edgeCalculator != null ? edgeCalculator : new Edge_1.EdgeCalculator();
38860 this._filterCreator = filterCreator != null ? filterCreator : new Graph_1.FilterCreator();
38861 this._filter = this._filterCreator.createFilter(undefined);
38862 this._graphCalculator = graphCalculator != null ? graphCalculator : new Graph_1.GraphCalculator();
38863 this._configuration = configuration != null ?
38867 maxUnusedNodes: 100,
38868 maxUnusedPreStoredNodes: 30,
38869 maxUnusedTiles: 20,
38872 this._nodeIndex = nodeIndex != null ? nodeIndex : rbush(16, [".lat", ".lon", ".lat", ".lon"]);
38873 this._nodeIndexTiles = {};
38874 this._nodeToTile = {};
38875 this._preStored = {};
38876 this._requiredNodeTiles = {};
38877 this._requiredSpatialArea = {};
38878 this._sequences = {};
38879 this._tilePrecision = 7;
38880 this._tileThreshold = 20;
38882 Object.defineProperty(Graph.prototype, "changed$", {
38886 * @returns {Observable<Graph>} Observable emitting
38887 * the graph every time it has changed.
38890 return this._changed$;
38896 * Caches the full node data for all images within a bounding
38899 * @description The node assets are not cached.
38901 * @param {ILatLon} sw - South west corner of bounding box.
38902 * @param {ILatLon} ne - North east corner of bounding box.
38903 * @returns {Observable<Graph>} Observable emitting the full
38904 * nodes in the bounding box.
38906 Graph.prototype.cacheBoundingBox$ = function (sw, ne) {
38908 var cacheTiles$ = this._graphCalculator.encodeHsFromBoundingBox(sw, ne)
38909 .filter(function (h) {
38910 return !(h in _this._cachedTiles);
38912 .map(function (h) {
38913 return h in _this._cachingTiles$ ?
38914 _this._cachingTiles$[h] :
38915 _this._cacheTile$(h);
38917 if (cacheTiles$.length === 0) {
38918 cacheTiles$.push(rxjs_1.of(this));
38920 return rxjs_1.from(cacheTiles$).pipe(operators_1.mergeAll(), operators_1.last(), operators_1.mergeMap(function (graph) {
38921 var nodes = _this._nodeIndex
38928 .map(function (item) {
38931 var fullNodes = [];
38932 var coreNodes = [];
38933 for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
38934 var node = nodes_1[_i];
38936 fullNodes.push(node);
38939 coreNodes.push(node.key);
38942 var coreNodeBatches = [];
38943 var batchSize = 200;
38944 while (coreNodes.length > 0) {
38945 coreNodeBatches.push(coreNodes.splice(0, batchSize));
38947 var fullNodes$ = rxjs_1.of(fullNodes);
38948 var fillNodes$ = coreNodeBatches
38949 .map(function (batch) {
38950 return _this._apiV3.imageByKeyFill$(batch).pipe(operators_1.map(function (imageByKeyFill) {
38951 var filledNodes = [];
38952 for (var fillKey in imageByKeyFill) {
38953 if (!imageByKeyFill.hasOwnProperty(fillKey)) {
38956 if (_this.hasNode(fillKey)) {
38957 var node = _this.getNode(fillKey);
38959 _this._makeFull(node, imageByKeyFill[fillKey]);
38961 filledNodes.push(node);
38964 return filledNodes;
38967 return rxjs_1.merge(fullNodes$, rxjs_1.from(fillNodes$).pipe(operators_1.mergeAll()));
38968 }), operators_1.reduce(function (acc, value) {
38969 return acc.concat(value);
38973 * Retrieve and cache node fill properties.
38975 * @param {string} key - Key of node to fill.
38976 * @returns {Observable<Graph>} Observable emitting the graph
38977 * when the node has been updated.
38978 * @throws {GraphMapillaryError} When the operation is not valid on the
38981 Graph.prototype.cacheFill$ = function (key) {
38983 if (key in this._cachingFull$) {
38984 throw new Error_1.GraphMapillaryError("Cannot fill node while caching full (" + key + ").");
38986 if (!this.hasNode(key)) {
38987 throw new Error_1.GraphMapillaryError("Cannot fill node that does not exist in graph (" + key + ").");
38989 if (key in this._cachingFill$) {
38990 return this._cachingFill$[key];
38992 var node = this.getNode(key);
38994 throw new Error_1.GraphMapillaryError("Cannot fill node that is already full (" + key + ").");
38996 this._cachingFill$[key] = this._apiV3.imageByKeyFill$([key]).pipe(operators_1.tap(function (imageByKeyFill) {
38998 _this._makeFull(node, imageByKeyFill[key]);
39000 delete _this._cachingFill$[key];
39001 }), operators_1.map(function (imageByKeyFill) {
39003 }), operators_1.finalize(function () {
39004 if (key in _this._cachingFill$) {
39005 delete _this._cachingFill$[key];
39007 _this._changed$.next(_this);
39008 }), operators_1.publish(), operators_1.refCount());
39009 return this._cachingFill$[key];
39012 * Retrieve and cache full node properties.
39014 * @param {string} key - Key of node to fill.
39015 * @returns {Observable<Graph>} Observable emitting the graph
39016 * when the node has been updated.
39017 * @throws {GraphMapillaryError} When the operation is not valid on the
39020 Graph.prototype.cacheFull$ = function (key) {
39022 if (key in this._cachingFull$) {
39023 return this._cachingFull$[key];
39025 if (this.hasNode(key)) {
39026 throw new Error_1.GraphMapillaryError("Cannot cache full node that already exist in graph (" + key + ").");
39028 this._cachingFull$[key] = this._apiV3.imageByKeyFull$([key]).pipe(operators_1.tap(function (imageByKeyFull) {
39029 var fn = imageByKeyFull[key];
39030 if (_this.hasNode(key)) {
39031 var node = _this.getNode(key);
39033 _this._makeFull(node, fn);
39037 if (fn.sequence_key == null) {
39038 throw new Error_1.GraphMapillaryError("Node has no sequence key (" + key + ").");
39040 var node = new Graph_1.Node(fn);
39041 _this._makeFull(node, fn);
39042 var h = _this._graphCalculator.encodeH(node.originalLatLon, _this._tilePrecision);
39043 _this._preStore(h, node);
39044 _this._setNode(node);
39045 delete _this._cachingFull$[key];
39047 }), operators_1.map(function (imageByKeyFull) {
39049 }), operators_1.finalize(function () {
39050 if (key in _this._cachingFull$) {
39051 delete _this._cachingFull$[key];
39053 _this._changed$.next(_this);
39054 }), operators_1.publish(), operators_1.refCount());
39055 return this._cachingFull$[key];
39058 * Retrieve and cache a node sequence.
39060 * @param {string} key - Key of node for which to retrieve sequence.
39061 * @returns {Observable<Graph>} Observable emitting the graph
39062 * when the sequence has been retrieved.
39063 * @throws {GraphMapillaryError} When the operation is not valid on the
39066 Graph.prototype.cacheNodeSequence$ = function (key) {
39067 if (!this.hasNode(key)) {
39068 throw new Error_1.GraphMapillaryError("Cannot cache sequence edges of node that does not exist in graph (" + key + ").");
39070 var node = this.getNode(key);
39071 if (node.sequenceKey in this._sequences) {
39072 throw new Error_1.GraphMapillaryError("Sequence already cached (" + key + "), (" + node.sequenceKey + ").");
39074 return this._cacheSequence$(node.sequenceKey);
39077 * Retrieve and cache a sequence.
39079 * @param {string} sequenceKey - Key of sequence to cache.
39080 * @returns {Observable<Graph>} Observable emitting the graph
39081 * when the sequence has been retrieved.
39082 * @throws {GraphMapillaryError} When the operation is not valid on the
39085 Graph.prototype.cacheSequence$ = function (sequenceKey) {
39086 if (sequenceKey in this._sequences) {
39087 throw new Error_1.GraphMapillaryError("Sequence already cached (" + sequenceKey + ")");
39089 return this._cacheSequence$(sequenceKey);
39092 * Cache sequence edges for a node.
39094 * @param {string} key - Key of node.
39095 * @throws {GraphMapillaryError} When the operation is not valid on the
39098 Graph.prototype.cacheSequenceEdges = function (key) {
39099 var node = this.getNode(key);
39100 if (!(node.sequenceKey in this._sequences)) {
39101 throw new Error_1.GraphMapillaryError("Sequence is not cached (" + key + "), (" + node.sequenceKey + ")");
39103 var sequence = this._sequences[node.sequenceKey].sequence;
39104 var edges = this._edgeCalculator.computeSequenceEdges(node, sequence);
39105 node.cacheSequenceEdges(edges);
39108 * Retrieve and cache full nodes for all keys in a sequence.
39110 * @param {string} sequenceKey - Key of sequence.
39111 * @param {string} referenceNodeKey - Key of node to use as reference
39112 * for optimized caching.
39113 * @returns {Observable<Graph>} Observable emitting the graph
39114 * when the nodes of the sequence has been cached.
39116 Graph.prototype.cacheSequenceNodes$ = function (sequenceKey, referenceNodeKey) {
39118 if (!this.hasSequence(sequenceKey)) {
39119 throw new Error_1.GraphMapillaryError("Cannot cache sequence nodes of sequence that does not exist in graph (" + sequenceKey + ").");
39121 if (this.hasSequenceNodes(sequenceKey)) {
39122 throw new Error_1.GraphMapillaryError("Sequence nodes already cached (" + sequenceKey + ").");
39124 var sequence = this.getSequence(sequenceKey);
39125 if (sequence.key in this._cachingSequenceNodes$) {
39126 return this._cachingSequenceNodes$[sequence.key];
39129 var keys = sequence.keys.slice();
39130 var referenceBatchSize = 50;
39131 if (!!referenceNodeKey && keys.length > referenceBatchSize) {
39132 var referenceIndex = keys.indexOf(referenceNodeKey);
39133 var startIndex = Math.max(0, Math.min(referenceIndex - referenceBatchSize / 2, keys.length - referenceBatchSize));
39134 batches.push(keys.splice(startIndex, referenceBatchSize));
39136 var batchSize = 200;
39137 while (keys.length > 0) {
39138 batches.push(keys.splice(0, batchSize));
39140 var batchesToCache = batches.length;
39141 var sequenceNodes$ = rxjs_1.from(batches).pipe(operators_1.mergeMap(function (batch) {
39142 return _this._apiV3.imageByKeyFull$(batch).pipe(operators_1.tap(function (imageByKeyFull) {
39143 for (var fullKey in imageByKeyFull) {
39144 if (!imageByKeyFull.hasOwnProperty(fullKey)) {
39147 var fn = imageByKeyFull[fullKey];
39148 if (_this.hasNode(fullKey)) {
39149 var node = _this.getNode(fn.key);
39151 _this._makeFull(node, fn);
39155 if (fn.sequence_key == null) {
39156 console.warn("Sequence missing, discarding node (" + fn.key + ")");
39158 var node = new Graph_1.Node(fn);
39159 _this._makeFull(node, fn);
39160 var h = _this._graphCalculator.encodeH(node.originalLatLon, _this._tilePrecision);
39161 _this._preStore(h, node);
39162 _this._setNode(node);
39166 }), operators_1.map(function (imageByKeyFull) {
39169 }, 6), operators_1.last(), operators_1.finalize(function () {
39170 delete _this._cachingSequenceNodes$[sequence.key];
39171 if (batchesToCache === 0) {
39172 _this._cachedSequenceNodes[sequence.key] = true;
39174 }), operators_1.publish(), operators_1.refCount());
39175 this._cachingSequenceNodes$[sequence.key] = sequenceNodes$;
39176 return sequenceNodes$;
39179 * Retrieve and cache full nodes for a node spatial area.
39181 * @param {string} key - Key of node for which to retrieve sequence.
39182 * @returns {Observable<Graph>} Observable emitting the graph
39183 * when the nodes in the spatial area has been made full.
39184 * @throws {GraphMapillaryError} When the operation is not valid on the
39187 Graph.prototype.cacheSpatialArea$ = function (key) {
39189 if (!this.hasNode(key)) {
39190 throw new Error_1.GraphMapillaryError("Cannot cache spatial area of node that does not exist in graph (" + key + ").");
39192 if (key in this._cachedSpatialEdges) {
39193 throw new Error_1.GraphMapillaryError("Node already spatially cached (" + key + ").");
39195 if (!(key in this._requiredSpatialArea)) {
39196 throw new Error_1.GraphMapillaryError("Spatial area not determined (" + key + ").");
39198 var spatialArea = this._requiredSpatialArea[key];
39199 if (Object.keys(spatialArea.cacheNodes).length === 0) {
39200 throw new Error_1.GraphMapillaryError("Spatial nodes already cached (" + key + ").");
39202 if (key in this._cachingSpatialArea$) {
39203 return this._cachingSpatialArea$[key];
39206 while (spatialArea.cacheKeys.length > 0) {
39207 batches.push(spatialArea.cacheKeys.splice(0, 200));
39209 var batchesToCache = batches.length;
39210 var spatialNodes$ = [];
39211 var _loop_1 = function (batch) {
39212 var spatialNodeBatch$ = this_1._apiV3.imageByKeyFill$(batch).pipe(operators_1.tap(function (imageByKeyFill) {
39213 for (var fillKey in imageByKeyFill) {
39214 if (!imageByKeyFill.hasOwnProperty(fillKey)) {
39217 var spatialNode = spatialArea.cacheNodes[fillKey];
39218 if (spatialNode.full) {
39219 delete spatialArea.cacheNodes[fillKey];
39222 var fillNode = imageByKeyFill[fillKey];
39223 _this._makeFull(spatialNode, fillNode);
39224 delete spatialArea.cacheNodes[fillKey];
39226 if (--batchesToCache === 0) {
39227 delete _this._cachingSpatialArea$[key];
39229 }), operators_1.map(function (imageByKeyFill) {
39231 }), operators_1.catchError(function (error) {
39232 for (var _i = 0, batch_1 = batch; _i < batch_1.length; _i++) {
39233 var batchKey = batch_1[_i];
39234 if (batchKey in spatialArea.all) {
39235 delete spatialArea.all[batchKey];
39237 if (batchKey in spatialArea.cacheNodes) {
39238 delete spatialArea.cacheNodes[batchKey];
39241 if (--batchesToCache === 0) {
39242 delete _this._cachingSpatialArea$[key];
39245 }), operators_1.finalize(function () {
39246 if (Object.keys(spatialArea.cacheNodes).length === 0) {
39247 _this._changed$.next(_this);
39249 }), operators_1.publish(), operators_1.refCount());
39250 spatialNodes$.push(spatialNodeBatch$);
39253 for (var _i = 0, batches_1 = batches; _i < batches_1.length; _i++) {
39254 var batch = batches_1[_i];
39257 this._cachingSpatialArea$[key] = spatialNodes$;
39258 return spatialNodes$;
39261 * Cache spatial edges for a node.
39263 * @param {string} key - Key of node.
39264 * @throws {GraphMapillaryError} When the operation is not valid on the
39267 Graph.prototype.cacheSpatialEdges = function (key) {
39268 if (key in this._cachedSpatialEdges) {
39269 throw new Error_1.GraphMapillaryError("Spatial edges already cached (" + key + ").");
39271 var node = this.getNode(key);
39272 var sequence = this._sequences[node.sequenceKey].sequence;
39273 var fallbackKeys = [];
39274 var prevKey = sequence.findPrevKey(node.key);
39275 if (prevKey != null) {
39276 fallbackKeys.push(prevKey);
39278 var nextKey = sequence.findNextKey(node.key);
39279 if (nextKey != null) {
39280 fallbackKeys.push(nextKey);
39282 var allSpatialNodes = this._requiredSpatialArea[key].all;
39283 var potentialNodes = [];
39284 var filter = this._filter;
39285 for (var spatialNodeKey in allSpatialNodes) {
39286 if (!allSpatialNodes.hasOwnProperty(spatialNodeKey)) {
39289 var spatialNode = allSpatialNodes[spatialNodeKey];
39290 if (filter(spatialNode)) {
39291 potentialNodes.push(spatialNode);
39294 var potentialEdges = this._edgeCalculator.getPotentialEdges(node, potentialNodes, fallbackKeys);
39295 var edges = this._edgeCalculator.computeStepEdges(node, potentialEdges, prevKey, nextKey);
39296 edges = edges.concat(this._edgeCalculator.computeTurnEdges(node, potentialEdges));
39297 edges = edges.concat(this._edgeCalculator.computePanoEdges(node, potentialEdges));
39298 edges = edges.concat(this._edgeCalculator.computePerspectiveToPanoEdges(node, potentialEdges));
39299 edges = edges.concat(this._edgeCalculator.computeSimilarEdges(node, potentialEdges));
39300 node.cacheSpatialEdges(edges);
39301 this._cachedSpatialEdges[key] = node;
39302 delete this._requiredSpatialArea[key];
39303 delete this._cachedNodeTiles[key];
39306 * Retrieve and cache geohash tiles for a node.
39308 * @param {string} key - Key of node for which to retrieve tiles.
39309 * @returns {Array<Observable<Graph>>} Array of observables emitting
39310 * the graph for each tile required for the node has been cached.
39311 * @throws {GraphMapillaryError} When the operation is not valid on the
39314 Graph.prototype.cacheTiles$ = function (key) {
39316 if (key in this._cachedNodeTiles) {
39317 throw new Error_1.GraphMapillaryError("Tiles already cached (" + key + ").");
39319 if (key in this._cachedSpatialEdges) {
39320 throw new Error_1.GraphMapillaryError("Spatial edges already cached so tiles considered cached (" + key + ").");
39322 if (!(key in this._requiredNodeTiles)) {
39323 throw new Error_1.GraphMapillaryError("Tiles have not been determined (" + key + ").");
39325 var nodeTiles = this._requiredNodeTiles[key];
39326 if (nodeTiles.cache.length === 0 &&
39327 nodeTiles.caching.length === 0) {
39328 throw new Error_1.GraphMapillaryError("Tiles already cached (" + key + ").");
39330 if (!this.hasNode(key)) {
39331 throw new Error_1.GraphMapillaryError("Cannot cache tiles of node that does not exist in graph (" + key + ").");
39333 var hs = nodeTiles.cache.slice();
39334 nodeTiles.caching = this._requiredNodeTiles[key].caching.concat(hs);
39335 nodeTiles.cache = [];
39336 var cacheTiles$ = [];
39337 var _loop_2 = function (h) {
39338 var cacheTile$ = h in this_2._cachingTiles$ ?
39339 this_2._cachingTiles$[h] :
39340 this_2._cacheTile$(h);
39341 cacheTiles$.push(cacheTile$.pipe(operators_1.tap(function (graph) {
39342 var index = nodeTiles.caching.indexOf(h);
39344 nodeTiles.caching.splice(index, 1);
39346 if (nodeTiles.caching.length === 0 &&
39347 nodeTiles.cache.length === 0) {
39348 delete _this._requiredNodeTiles[key];
39349 _this._cachedNodeTiles[key] = true;
39351 }), operators_1.catchError(function (error) {
39352 var index = nodeTiles.caching.indexOf(h);
39354 nodeTiles.caching.splice(index, 1);
39356 if (nodeTiles.caching.length === 0 &&
39357 nodeTiles.cache.length === 0) {
39358 delete _this._requiredNodeTiles[key];
39359 _this._cachedNodeTiles[key] = true;
39362 }), operators_1.finalize(function () {
39363 _this._changed$.next(_this);
39364 }), operators_1.publish(), operators_1.refCount()));
39367 for (var _i = 0, _a = nodeTiles.caching; _i < _a.length; _i++) {
39371 return cacheTiles$;
39374 * Initialize the cache for a node.
39376 * @param {string} key - Key of node.
39377 * @throws {GraphMapillaryError} When the operation is not valid on the
39380 Graph.prototype.initializeCache = function (key) {
39381 if (key in this._cachedNodes) {
39382 throw new Error_1.GraphMapillaryError("Node already in cache (" + key + ").");
39384 var node = this.getNode(key);
39385 node.initializeCache(new Graph_1.NodeCache());
39386 var accessed = new Date().getTime();
39387 this._cachedNodes[key] = { accessed: accessed, node: node };
39388 this._updateCachedTileAccess(key, accessed);
39391 * Get a value indicating if the graph is fill caching a node.
39393 * @param {string} key - Key of node.
39394 * @returns {boolean} Value indicating if the node is being fill cached.
39396 Graph.prototype.isCachingFill = function (key) {
39397 return key in this._cachingFill$;
39400 * Get a value indicating if the graph is fully caching a node.
39402 * @param {string} key - Key of node.
39403 * @returns {boolean} Value indicating if the node is being fully cached.
39405 Graph.prototype.isCachingFull = function (key) {
39406 return key in this._cachingFull$;
39409 * Get a value indicating if the graph is caching a sequence of a node.
39411 * @param {string} key - Key of node.
39412 * @returns {boolean} Value indicating if the sequence of a node is
39415 Graph.prototype.isCachingNodeSequence = function (key) {
39416 var node = this.getNode(key);
39417 return node.sequenceKey in this._cachingSequences$;
39420 * Get a value indicating if the graph is caching a sequence.
39422 * @param {string} sequenceKey - Key of sequence.
39423 * @returns {boolean} Value indicating if the sequence is
39426 Graph.prototype.isCachingSequence = function (sequenceKey) {
39427 return sequenceKey in this._cachingSequences$;
39430 * Get a value indicating if the graph is caching sequence nodes.
39432 * @param {string} sequenceKey - Key of sequence.
39433 * @returns {boolean} Value indicating if the sequence nodes are
39436 Graph.prototype.isCachingSequenceNodes = function (sequenceKey) {
39437 return sequenceKey in this._cachingSequenceNodes$;
39440 * Get a value indicating if the graph is caching the tiles
39441 * required for calculating spatial edges of a node.
39443 * @param {string} key - Key of node.
39444 * @returns {boolean} Value indicating if the tiles of
39445 * a node are being cached.
39447 Graph.prototype.isCachingTiles = function (key) {
39448 return key in this._requiredNodeTiles &&
39449 this._requiredNodeTiles[key].cache.length === 0 &&
39450 this._requiredNodeTiles[key].caching.length > 0;
39453 * Get a value indicating if the cache has been initialized
39456 * @param {string} key - Key of node.
39457 * @returns {boolean} Value indicating if the cache has been
39458 * initialized for a node.
39460 Graph.prototype.hasInitializedCache = function (key) {
39461 return key in this._cachedNodes;
39464 * Get a value indicating if a node exist in the graph.
39466 * @param {string} key - Key of node.
39467 * @returns {boolean} Value indicating if a node exist in the graph.
39469 Graph.prototype.hasNode = function (key) {
39470 var accessed = new Date().getTime();
39471 this._updateCachedNodeAccess(key, accessed);
39472 this._updateCachedTileAccess(key, accessed);
39473 return key in this._nodes;
39476 * Get a value indicating if a node sequence exist in the graph.
39478 * @param {string} key - Key of node.
39479 * @returns {boolean} Value indicating if a node sequence exist
39482 Graph.prototype.hasNodeSequence = function (key) {
39483 var node = this.getNode(key);
39484 var sequenceKey = node.sequenceKey;
39485 var hasNodeSequence = sequenceKey in this._sequences;
39486 if (hasNodeSequence) {
39487 this._sequences[sequenceKey].accessed = new Date().getTime();
39489 return hasNodeSequence;
39492 * Get a value indicating if a sequence exist in the graph.
39494 * @param {string} sequenceKey - Key of sequence.
39495 * @returns {boolean} Value indicating if a sequence exist
39498 Graph.prototype.hasSequence = function (sequenceKey) {
39499 var hasSequence = sequenceKey in this._sequences;
39501 this._sequences[sequenceKey].accessed = new Date().getTime();
39503 return hasSequence;
39506 * Get a value indicating if sequence nodes has been cached in the graph.
39508 * @param {string} sequenceKey - Key of sequence.
39509 * @returns {boolean} Value indicating if a sequence nodes has been
39510 * cached in the graph.
39512 Graph.prototype.hasSequenceNodes = function (sequenceKey) {
39513 return sequenceKey in this._cachedSequenceNodes;
39516 * Get a value indicating if the graph has fully cached
39517 * all nodes in the spatial area of a node.
39519 * @param {string} key - Key of node.
39520 * @returns {boolean} Value indicating if the spatial area
39521 * of a node has been cached.
39523 Graph.prototype.hasSpatialArea = function (key) {
39524 if (!this.hasNode(key)) {
39525 throw new Error_1.GraphMapillaryError("Spatial area nodes cannot be determined if node not in graph (" + key + ").");
39527 if (key in this._cachedSpatialEdges) {
39530 if (key in this._requiredSpatialArea) {
39531 return Object.keys(this._requiredSpatialArea[key].cacheNodes).length === 0;
39533 var node = this.getNode(key);
39534 var bbox = this._graphCalculator.boundingBoxCorners(node.latLon, this._tileThreshold);
39535 var spatialItems = this._nodeIndex.search({
39541 var spatialNodes = {
39546 for (var _i = 0, spatialItems_1 = spatialItems; _i < spatialItems_1.length; _i++) {
39547 var spatialItem = spatialItems_1[_i];
39548 spatialNodes.all[spatialItem.node.key] = spatialItem.node;
39549 if (!spatialItem.node.full) {
39550 spatialNodes.cacheKeys.push(spatialItem.node.key);
39551 spatialNodes.cacheNodes[spatialItem.node.key] = spatialItem.node;
39554 this._requiredSpatialArea[key] = spatialNodes;
39555 return spatialNodes.cacheKeys.length === 0;
39558 * Get a value indicating if the graph has a tiles required
39561 * @param {string} key - Key of node.
39562 * @returns {boolean} Value indicating if the the tiles required
39563 * by a node has been cached.
39565 Graph.prototype.hasTiles = function (key) {
39567 if (key in this._cachedNodeTiles) {
39570 if (key in this._cachedSpatialEdges) {
39573 if (!this.hasNode(key)) {
39574 throw new Error_1.GraphMapillaryError("Node does not exist in graph (" + key + ").");
39576 var nodeTiles = { cache: [], caching: [] };
39577 if (!(key in this._requiredNodeTiles)) {
39578 var node = this.getNode(key);
39579 nodeTiles.cache = this._graphCalculator
39580 .encodeHs(node.latLon, this._tilePrecision, this._tileThreshold)
39581 .filter(function (h) {
39582 return !(h in _this._cachedTiles);
39584 if (nodeTiles.cache.length > 0) {
39585 this._requiredNodeTiles[key] = nodeTiles;
39589 nodeTiles = this._requiredNodeTiles[key];
39591 return nodeTiles.cache.length === 0 && nodeTiles.caching.length === 0;
39596 * @param {string} key - Key of node.
39597 * @returns {Node} Retrieved node.
39599 Graph.prototype.getNode = function (key) {
39600 var accessed = new Date().getTime();
39601 this._updateCachedNodeAccess(key, accessed);
39602 this._updateCachedTileAccess(key, accessed);
39603 return this._nodes[key];
39608 * @param {string} sequenceKey - Key of sequence.
39609 * @returns {Node} Retrieved sequence.
39611 Graph.prototype.getSequence = function (sequenceKey) {
39612 var sequenceAccess = this._sequences[sequenceKey];
39613 sequenceAccess.accessed = new Date().getTime();
39614 return sequenceAccess.sequence;
39617 * Reset all spatial edges of the graph nodes.
39619 Graph.prototype.resetSpatialEdges = function () {
39620 var cachedKeys = Object.keys(this._cachedSpatialEdges);
39621 for (var _i = 0, cachedKeys_1 = cachedKeys; _i < cachedKeys_1.length; _i++) {
39622 var cachedKey = cachedKeys_1[_i];
39623 var node = this._cachedSpatialEdges[cachedKey];
39624 node.resetSpatialEdges();
39625 delete this._cachedSpatialEdges[cachedKey];
39629 * Reset the complete graph but keep the nodes corresponding
39630 * to the supplied keys. All other nodes will be disposed.
39632 * @param {Array<string>} keepKeys - Keys for nodes to keep
39633 * in graph after reset.
39635 Graph.prototype.reset = function (keepKeys) {
39637 for (var _i = 0, keepKeys_1 = keepKeys; _i < keepKeys_1.length; _i++) {
39638 var key = keepKeys_1[_i];
39639 if (!this.hasNode(key)) {
39640 throw new Error("Node does not exist " + key);
39642 var node = this.getNode(key);
39643 node.resetSequenceEdges();
39644 node.resetSpatialEdges();
39647 for (var _a = 0, _b = Object.keys(this._cachedNodes); _a < _b.length; _a++) {
39648 var cachedKey = _b[_a];
39649 if (keepKeys.indexOf(cachedKey) !== -1) {
39652 this._cachedNodes[cachedKey].node.dispose();
39653 delete this._cachedNodes[cachedKey];
39655 this._cachedNodeTiles = {};
39656 this._cachedSpatialEdges = {};
39657 this._cachedTiles = {};
39658 this._cachingFill$ = {};
39659 this._cachingFull$ = {};
39660 this._cachingSequences$ = {};
39661 this._cachingSpatialArea$ = {};
39662 this._cachingTiles$ = {};
39664 this._nodeToTile = {};
39665 this._preStored = {};
39666 for (var _c = 0, nodes_2 = nodes; _c < nodes_2.length; _c++) {
39667 var node = nodes_2[_c];
39668 this._nodes[node.key] = node;
39669 var h = this._graphCalculator.encodeH(node.originalLatLon, this._tilePrecision);
39670 this._preStore(h, node);
39672 this._requiredNodeTiles = {};
39673 this._requiredSpatialArea = {};
39674 this._sequences = {};
39675 this._nodeIndexTiles = {};
39676 this._nodeIndex.clear();
39679 * Set the spatial node filter.
39681 * @param {FilterExpression} filter - Filter expression to be applied
39682 * when calculating spatial edges.
39684 Graph.prototype.setFilter = function (filter) {
39685 this._filter = this._filterCreator.createFilter(filter);
39688 * Uncache the graph according to the graph configuration.
39690 * @description Uncaches unused tiles, unused nodes and
39691 * sequences according to the numbers specified in the
39692 * graph configuration. Sequences does not have a direct
39693 * reference to either tiles or nodes and may be uncached
39694 * even if they are related to the nodes that should be kept.
39696 * @param {Array<string>} keepKeys - Keys of nodes to keep in
39697 * graph unrelated to last access. Tiles related to those keys
39698 * will also be kept in graph.
39699 * @param {string} keepSequenceKey - Optional key of sequence
39700 * for which the belonging nodes should not be disposed or
39701 * removed from the graph. These nodes may still be uncached if
39702 * not specified in keep keys param.
39704 Graph.prototype.uncache = function (keepKeys, keepSequenceKey) {
39705 var keysInUse = {};
39706 this._addNewKeys(keysInUse, this._cachingFull$);
39707 this._addNewKeys(keysInUse, this._cachingFill$);
39708 this._addNewKeys(keysInUse, this._cachingSpatialArea$);
39709 this._addNewKeys(keysInUse, this._requiredNodeTiles);
39710 this._addNewKeys(keysInUse, this._requiredSpatialArea);
39711 for (var _i = 0, keepKeys_2 = keepKeys; _i < keepKeys_2.length; _i++) {
39712 var key = keepKeys_2[_i];
39713 if (key in keysInUse) {
39716 keysInUse[key] = true;
39719 for (var key in keysInUse) {
39720 if (!keysInUse.hasOwnProperty(key)) {
39723 var node = this._nodes[key];
39724 var nodeHs = this._graphCalculator.encodeHs(node.latLon);
39725 for (var _a = 0, nodeHs_1 = nodeHs; _a < nodeHs_1.length; _a++) {
39726 var nodeH = nodeHs_1[_a];
39727 if (!(nodeH in keepHs)) {
39728 keepHs[nodeH] = true;
39732 var potentialHs = [];
39733 for (var h in this._cachedTiles) {
39734 if (!this._cachedTiles.hasOwnProperty(h) || h in keepHs) {
39737 potentialHs.push([h, this._cachedTiles[h]]);
39739 var uncacheHs = potentialHs
39740 .sort(function (h1, h2) {
39741 return h2[1].accessed - h1[1].accessed;
39743 .slice(this._configuration.maxUnusedTiles)
39744 .map(function (h) {
39747 for (var _b = 0, uncacheHs_1 = uncacheHs; _b < uncacheHs_1.length; _b++) {
39748 var uncacheH = uncacheHs_1[_b];
39749 this._uncacheTile(uncacheH, keepSequenceKey);
39751 var potentialPreStored = [];
39752 var nonCachedPreStored = [];
39753 for (var h in this._preStored) {
39754 if (!this._preStored.hasOwnProperty(h) || h in this._cachingTiles$) {
39757 var prestoredNodes = this._preStored[h];
39758 for (var key in prestoredNodes) {
39759 if (!prestoredNodes.hasOwnProperty(key) || key in keysInUse) {
39762 if (prestoredNodes[key].sequenceKey === keepSequenceKey) {
39765 if (key in this._cachedNodes) {
39766 potentialPreStored.push([this._cachedNodes[key], h]);
39769 nonCachedPreStored.push([key, h]);
39773 var uncachePreStored = potentialPreStored
39774 .sort(function (_a, _b) {
39775 var na1 = _a[0], h1 = _a[1];
39776 var na2 = _b[0], h2 = _b[1];
39777 return na2.accessed - na1.accessed;
39779 .slice(this._configuration.maxUnusedPreStoredNodes)
39780 .map(function (_a) {
39781 var na = _a[0], h = _a[1];
39782 return [na.node.key, h];
39784 this._uncachePreStored(nonCachedPreStored);
39785 this._uncachePreStored(uncachePreStored);
39786 var potentialNodes = [];
39787 for (var key in this._cachedNodes) {
39788 if (!this._cachedNodes.hasOwnProperty(key) || key in keysInUse) {
39791 potentialNodes.push(this._cachedNodes[key]);
39793 var uncacheNodes = potentialNodes
39794 .sort(function (n1, n2) {
39795 return n2.accessed - n1.accessed;
39797 .slice(this._configuration.maxUnusedNodes);
39798 for (var _c = 0, uncacheNodes_1 = uncacheNodes; _c < uncacheNodes_1.length; _c++) {
39799 var nodeAccess = uncacheNodes_1[_c];
39800 nodeAccess.node.uncache();
39801 var key = nodeAccess.node.key;
39802 delete this._cachedNodes[key];
39803 if (key in this._cachedNodeTiles) {
39804 delete this._cachedNodeTiles[key];
39806 if (key in this._cachedSpatialEdges) {
39807 delete this._cachedSpatialEdges[key];
39810 var potentialSequences = [];
39811 for (var sequenceKey in this._sequences) {
39812 if (!this._sequences.hasOwnProperty(sequenceKey) ||
39813 sequenceKey in this._cachingSequences$ ||
39814 sequenceKey === keepSequenceKey) {
39817 potentialSequences.push(this._sequences[sequenceKey]);
39819 var uncacheSequences = potentialSequences
39820 .sort(function (s1, s2) {
39821 return s2.accessed - s1.accessed;
39823 .slice(this._configuration.maxSequences);
39824 for (var _d = 0, uncacheSequences_1 = uncacheSequences; _d < uncacheSequences_1.length; _d++) {
39825 var sequenceAccess = uncacheSequences_1[_d];
39826 var sequenceKey = sequenceAccess.sequence.key;
39827 delete this._sequences[sequenceKey];
39828 if (sequenceKey in this._cachedSequenceNodes) {
39829 delete this._cachedSequenceNodes[sequenceKey];
39831 sequenceAccess.sequence.dispose();
39834 Graph.prototype._addNewKeys = function (keys, dict) {
39835 for (var key in dict) {
39836 if (!dict.hasOwnProperty(key) || !this.hasNode(key)) {
39839 if (!(key in keys)) {
39844 Graph.prototype._cacheSequence$ = function (sequenceKey) {
39846 if (sequenceKey in this._cachingSequences$) {
39847 return this._cachingSequences$[sequenceKey];
39849 this._cachingSequences$[sequenceKey] = this._apiV3.sequenceByKey$([sequenceKey]).pipe(operators_1.tap(function (sequenceByKey) {
39850 if (!(sequenceKey in _this._sequences)) {
39851 _this._sequences[sequenceKey] = {
39852 accessed: new Date().getTime(),
39853 sequence: new Graph_1.Sequence(sequenceByKey[sequenceKey]),
39856 delete _this._cachingSequences$[sequenceKey];
39857 }), operators_1.map(function (sequenceByKey) {
39859 }), operators_1.finalize(function () {
39860 if (sequenceKey in _this._cachingSequences$) {
39861 delete _this._cachingSequences$[sequenceKey];
39863 _this._changed$.next(_this);
39864 }), operators_1.publish(), operators_1.refCount());
39865 return this._cachingSequences$[sequenceKey];
39867 Graph.prototype._cacheTile$ = function (h) {
39869 this._cachingTiles$[h] = this._apiV3.imagesByH$([h]).pipe(operators_1.tap(function (imagesByH) {
39870 var coreNodes = imagesByH[h];
39871 if (h in _this._cachedTiles) {
39874 _this._nodeIndexTiles[h] = [];
39875 _this._cachedTiles[h] = { accessed: new Date().getTime(), nodes: [] };
39876 var hCache = _this._cachedTiles[h].nodes;
39877 var preStored = _this._removeFromPreStore(h);
39878 for (var index in coreNodes) {
39879 if (!coreNodes.hasOwnProperty(index)) {
39882 var coreNode = coreNodes[index];
39883 if (coreNode == null) {
39886 if (coreNode.sequence_key == null) {
39887 console.warn("Sequence missing, discarding node (" + coreNode.key + ")");
39890 if (preStored != null && coreNode.key in preStored) {
39891 var preStoredNode = preStored[coreNode.key];
39892 delete preStored[coreNode.key];
39893 hCache.push(preStoredNode);
39894 var preStoredNodeIndexItem = {
39895 lat: preStoredNode.latLon.lat,
39896 lon: preStoredNode.latLon.lon,
39897 node: preStoredNode,
39899 _this._nodeIndex.insert(preStoredNodeIndexItem);
39900 _this._nodeIndexTiles[h].push(preStoredNodeIndexItem);
39901 _this._nodeToTile[preStoredNode.key] = h;
39904 var node = new Graph_1.Node(coreNode);
39906 var nodeIndexItem = {
39907 lat: node.latLon.lat,
39908 lon: node.latLon.lon,
39911 _this._nodeIndex.insert(nodeIndexItem);
39912 _this._nodeIndexTiles[h].push(nodeIndexItem);
39913 _this._nodeToTile[node.key] = h;
39914 _this._setNode(node);
39916 delete _this._cachingTiles$[h];
39917 }), operators_1.map(function (imagesByH) {
39919 }), operators_1.catchError(function (error) {
39920 delete _this._cachingTiles$[h];
39922 }), operators_1.publish(), operators_1.refCount());
39923 return this._cachingTiles$[h];
39925 Graph.prototype._makeFull = function (node, fillNode) {
39926 if (fillNode.calt == null) {
39927 fillNode.calt = this._defaultAlt;
39929 if (fillNode.c_rotation == null) {
39930 fillNode.c_rotation = this._graphCalculator.rotationFromCompass(fillNode.ca, fillNode.orientation);
39932 node.makeFull(fillNode);
39934 Graph.prototype._preStore = function (h, node) {
39935 if (!(h in this._preStored)) {
39936 this._preStored[h] = {};
39938 this._preStored[h][node.key] = node;
39940 Graph.prototype._removeFromPreStore = function (h) {
39941 var preStored = null;
39942 if (h in this._preStored) {
39943 preStored = this._preStored[h];
39944 delete this._preStored[h];
39948 Graph.prototype._setNode = function (node) {
39949 var key = node.key;
39950 if (this.hasNode(key)) {
39951 throw new Error_1.GraphMapillaryError("Node already exist (" + key + ").");
39953 this._nodes[key] = node;
39955 Graph.prototype._uncacheTile = function (h, keepSequenceKey) {
39956 for (var _i = 0, _a = this._cachedTiles[h].nodes; _i < _a.length; _i++) {
39958 var key = node.key;
39959 delete this._nodeToTile[key];
39960 if (key in this._cachedNodes) {
39961 delete this._cachedNodes[key];
39963 if (key in this._cachedNodeTiles) {
39964 delete this._cachedNodeTiles[key];
39966 if (key in this._cachedSpatialEdges) {
39967 delete this._cachedSpatialEdges[key];
39969 if (node.sequenceKey === keepSequenceKey) {
39970 this._preStore(h, node);
39974 delete this._nodes[key];
39975 if (node.sequenceKey in this._cachedSequenceNodes) {
39976 delete this._cachedSequenceNodes[node.sequenceKey];
39981 for (var _b = 0, _c = this._nodeIndexTiles[h]; _b < _c.length; _b++) {
39982 var nodeIndexItem = _c[_b];
39983 this._nodeIndex.remove(nodeIndexItem);
39985 delete this._nodeIndexTiles[h];
39986 delete this._cachedTiles[h];
39988 Graph.prototype._uncachePreStored = function (preStored) {
39990 for (var _i = 0, preStored_1 = preStored; _i < preStored_1.length; _i++) {
39991 var _a = preStored_1[_i], key = _a[0], h = _a[1];
39992 if (key in this._nodes) {
39993 delete this._nodes[key];
39995 if (key in this._cachedNodes) {
39996 delete this._cachedNodes[key];
39998 var node = this._preStored[h][key];
39999 if (node.sequenceKey in this._cachedSequenceNodes) {
40000 delete this._cachedSequenceNodes[node.sequenceKey];
40002 delete this._preStored[h][key];
40006 for (var h in hs) {
40007 if (!hs.hasOwnProperty(h)) {
40010 if (Object.keys(this._preStored[h]).length === 0) {
40011 delete this._preStored[h];
40015 Graph.prototype._updateCachedTileAccess = function (key, accessed) {
40016 if (key in this._nodeToTile) {
40017 this._cachedTiles[this._nodeToTile[key]].accessed = accessed;
40020 Graph.prototype._updateCachedNodeAccess = function (key, accessed) {
40021 if (key in this._cachedNodes) {
40022 this._cachedNodes[key].accessed = accessed;
40027 exports.Graph = Graph;
40028 exports.default = Graph;
40030 },{"../Edge":276,"../Error":277,"../Graph":279,"rbush":26,"rxjs":27,"rxjs/operators":225}],391:[function(require,module,exports){
40032 Object.defineProperty(exports, "__esModule", { value: true });
40033 var geohash = require("latlon-geohash");
40034 var THREE = require("three");
40035 var Error_1 = require("../Error");
40036 var Geo_1 = require("../Geo");
40038 * @class GraphCalculator
40040 * @classdesc Represents a calculator for graph entities.
40042 var GraphCalculator = /** @class */ (function () {
40044 * Create a new graph calculator instance.
40046 * @param {GeoCoords} geoCoords - Geo coords instance.
40048 function GraphCalculator(geoCoords) {
40049 this._geoCoords = geoCoords != null ? geoCoords : new Geo_1.GeoCoords();
40052 * Encode the geohash tile for geodetic coordinates.
40054 * @param {ILatLon} latlon - Latitude and longitude to encode.
40055 * @param {number} precision - Precision of the encoding.
40057 * @returns {string} The geohash tile for the lat, lon and precision.
40059 GraphCalculator.prototype.encodeH = function (latLon, precision) {
40060 if (precision === void 0) { precision = 7; }
40061 return geohash.encode(latLon.lat, latLon.lon, precision);
40064 * Encode the geohash tiles within a threshold from a position
40065 * using Manhattan distance.
40067 * @param {ILatLon} latlon - Latitude and longitude to encode.
40068 * @param {number} precision - Precision of the encoding.
40069 * @param {number} threshold - Threshold of the encoding in meters.
40071 * @returns {string} The geohash tiles reachable within the threshold.
40073 GraphCalculator.prototype.encodeHs = function (latLon, precision, threshold) {
40074 if (precision === void 0) { precision = 7; }
40075 if (threshold === void 0) { threshold = 20; }
40076 var h = geohash.encode(latLon.lat, latLon.lon, precision);
40077 var bounds = geohash.bounds(h);
40078 var ne = bounds.ne;
40079 var sw = bounds.sw;
40080 var neighbours = geohash.neighbours(h);
40081 var bl = [0, 0, 0];
40082 var tr = this._geoCoords.geodeticToEnu(ne.lat, ne.lon, 0, sw.lat, sw.lon, 0);
40083 var position = this._geoCoords.geodeticToEnu(latLon.lat, latLon.lon, 0, sw.lat, sw.lon, 0);
40084 var left = position[0] - bl[0];
40085 var right = tr[0] - position[0];
40086 var bottom = position[1] - bl[1];
40087 var top = tr[1] - position[1];
40088 var l = left < threshold;
40089 var r = right < threshold;
40090 var b = bottom < threshold;
40091 var t = top < threshold;
40094 hs.push(neighbours.n);
40097 hs.push(neighbours.nw);
40100 hs.push(neighbours.w);
40103 hs.push(neighbours.sw);
40106 hs.push(neighbours.s);
40109 hs.push(neighbours.se);
40112 hs.push(neighbours.e);
40115 hs.push(neighbours.ne);
40120 * Encode the minimum set of geohash tiles containing a bounding box.
40122 * @description The current algorithm does expect the bounding box
40123 * to be sufficiently small to be contained in an area with the size
40124 * of maximally four tiles. Up to nine adjacent tiles may be returned.
40125 * The method currently uses the largest side as the threshold leading to
40126 * more tiles being returned than needed in edge cases.
40128 * @param {ILatLon} sw - South west corner of bounding box.
40129 * @param {ILatLon} ne - North east corner of bounding box.
40130 * @param {number} precision - Precision of the encoding.
40132 * @returns {string} The geohash tiles containing the bounding box.
40134 GraphCalculator.prototype.encodeHsFromBoundingBox = function (sw, ne, precision) {
40135 if (precision === void 0) { precision = 7; }
40136 if (ne.lat <= sw.lat || ne.lon <= sw.lon) {
40137 throw new Error_1.GraphMapillaryError("North east needs to be top right of south west");
40139 var centerLat = (sw.lat + ne.lat) / 2;
40140 var centerLon = (sw.lon + ne.lon) / 2;
40141 var enu = this._geoCoords.geodeticToEnu(ne.lat, ne.lon, 0, centerLat, centerLon, 0);
40142 var threshold = Math.max(enu[0], enu[1]);
40143 return this.encodeHs({ lat: centerLat, lon: centerLon }, precision, threshold);
40146 * Get the bounding box corners for a circle with radius of a threshold
40147 * with center in a geodetic position.
40149 * @param {ILatLon} latlon - Latitude and longitude to encode.
40150 * @param {number} threshold - Threshold distance from the position in meters.
40152 * @returns {Array<ILatLon>} The south west and north east corners of the
40155 GraphCalculator.prototype.boundingBoxCorners = function (latLon, threshold) {
40156 var bl = this._geoCoords.enuToGeodetic(-threshold, -threshold, 0, latLon.lat, latLon.lon, 0);
40157 var tr = this._geoCoords.enuToGeodetic(threshold, threshold, 0, latLon.lat, latLon.lon, 0);
40159 { lat: bl[0], lon: bl[1] },
40160 { lat: tr[0], lon: tr[1] },
40164 * Convert a compass angle to an angle axis rotation vector.
40166 * @param {number} compassAngle - The compass angle in degrees.
40167 * @param {number} orientation - The orientation of the original image.
40169 * @returns {Array<number>} Angle axis rotation vector.
40171 GraphCalculator.prototype.rotationFromCompass = function (compassAngle, orientation) {
40175 switch (orientation) {
40194 var rz = new THREE.Matrix4().makeRotationZ(z);
40195 var euler = new THREE.Euler(x, y, compassAngle * Math.PI / 180, "XYZ");
40196 var re = new THREE.Matrix4().makeRotationFromEuler(euler);
40197 var rotation = new THREE.Vector4().setAxisAngleFromRotationMatrix(re.multiply(rz));
40198 return rotation.multiplyScalar(rotation.w).toArray().slice(0, 3);
40200 return GraphCalculator;
40202 exports.GraphCalculator = GraphCalculator;
40203 exports.default = GraphCalculator;
40205 },{"../Error":277,"../Geo":278,"latlon-geohash":21,"three":226}],392:[function(require,module,exports){
40207 Object.defineProperty(exports, "__esModule", { value: true });
40209 * Enumeration for graph modes.
40212 * @description Modes for the retrieval and caching performed
40213 * by the graph service on the graph.
40216 (function (GraphMode) {
40218 * Caching is performed on sequences only and sequence edges are
40219 * calculated. Spatial tiles
40220 * are not retrieved and spatial edges are not calculated when
40221 * caching nodes. Complete sequences are being cached for requested
40222 * nodes within the graph.
40224 GraphMode[GraphMode["Sequence"] = 0] = "Sequence";
40226 * Caching is performed with emphasis on spatial data. Sequence edges
40227 * as well as spatial edges are cached. Sequence data
40228 * is still requested but complete sequences are not being cached
40229 * for requested nodes.
40231 * This is the initial mode of the graph service.
40233 GraphMode[GraphMode["Spatial"] = 1] = "Spatial";
40234 })(GraphMode = exports.GraphMode || (exports.GraphMode = {}));
40235 exports.default = GraphMode;
40237 },{}],393:[function(require,module,exports){
40239 Object.defineProperty(exports, "__esModule", { value: true });
40240 var rxjs_1 = require("rxjs");
40241 var operators_1 = require("rxjs/operators");
40242 var Graph_1 = require("../Graph");
40244 * @class GraphService
40246 * @classdesc Represents a service for graph operations.
40248 var GraphService = /** @class */ (function () {
40250 * Create a new graph service instance.
40252 * @param {Graph} graph - Graph instance to be operated on.
40254 function GraphService(graph, imageLoadingService) {
40255 this._graph$ = rxjs_1.concat(rxjs_1.of(graph), graph.changed$).pipe(operators_1.publishReplay(1), operators_1.refCount());
40256 this._graph$.subscribe(function () { });
40257 this._graphMode = Graph_1.GraphMode.Spatial;
40258 this._graphModeSubject$ = new rxjs_1.Subject();
40259 this._graphMode$ = this._graphModeSubject$.pipe(operators_1.startWith(this._graphMode), operators_1.publishReplay(1), operators_1.refCount());
40260 this._graphMode$.subscribe(function () { });
40261 this._imageLoadingService = imageLoadingService;
40262 this._firstGraphSubjects$ = [];
40263 this._initializeCacheSubscriptions = [];
40264 this._sequenceSubscriptions = [];
40265 this._spatialSubscriptions = [];
40267 Object.defineProperty(GraphService.prototype, "graphMode$", {
40269 * Get graph mode observable.
40271 * @description Emits the current graph mode.
40273 * @returns {Observable<GraphMode>} Observable
40274 * emitting the current graph mode when it changes.
40277 return this._graphMode$;
40283 * Cache full nodes in a bounding box.
40285 * @description When called, the full properties of
40286 * the node are retrieved. The node cache is not initialized
40287 * for any new nodes retrieved and the node assets are not
40288 * retrieved, {@link cacheNode$} needs to be called for caching
40291 * @param {ILatLon} sw - South west corner of bounding box.
40292 * @param {ILatLon} ne - North east corner of bounding box.
40293 * @return {Observable<Array<Node>>} Observable emitting a single item,
40294 * the nodes of the bounding box, when they have all been retrieved.
40295 * @throws {Error} Propagates any IO node caching errors to the caller.
40297 GraphService.prototype.cacheBoundingBox$ = function (sw, ne) {
40298 return this._graph$.pipe(operators_1.first(), operators_1.mergeMap(function (graph) {
40299 return graph.cacheBoundingBox$(sw, ne);
40303 * Cache a node in the graph and retrieve it.
40305 * @description When called, the full properties of
40306 * the node are retrieved and the node cache is initialized.
40307 * After that the node assets are cached and the node
40308 * is emitted to the observable when.
40309 * In parallel to caching the node assets, the sequence and
40310 * spatial edges of the node are cached. For this, the sequence
40311 * of the node and the required tiles and spatial nodes are
40312 * retrieved. The sequence and spatial edges may be set before
40313 * or after the node is returned.
40315 * @param {string} key - Key of the node to cache.
40316 * @return {Observable<Node>} Observable emitting a single item,
40317 * the node, when it has been retrieved and its assets are cached.
40318 * @throws {Error} Propagates any IO node caching errors to the caller.
40320 GraphService.prototype.cacheNode$ = function (key) {
40322 var firstGraphSubject$ = new rxjs_1.Subject();
40323 this._firstGraphSubjects$.push(firstGraphSubject$);
40324 var firstGraph$ = firstGraphSubject$.pipe(operators_1.publishReplay(1), operators_1.refCount());
40325 var node$ = firstGraph$.pipe(operators_1.map(function (graph) {
40326 return graph.getNode(key);
40327 }), operators_1.mergeMap(function (node) {
40328 return node.assetsCached ?
40330 node.cacheAssets$();
40331 }), operators_1.publishReplay(1), operators_1.refCount());
40332 node$.subscribe(function (node) {
40333 _this._imageLoadingService.loadnode$.next(node);
40334 }, function (error) {
40335 console.error("Failed to cache node (" + key + ")", error);
40337 var initializeCacheSubscription = this._graph$.pipe(operators_1.first(), operators_1.mergeMap(function (graph) {
40338 if (graph.isCachingFull(key) || !graph.hasNode(key)) {
40339 return graph.cacheFull$(key);
40341 if (graph.isCachingFill(key) || !graph.getNode(key).full) {
40342 return graph.cacheFill$(key);
40344 return rxjs_1.of(graph);
40345 }), operators_1.tap(function (graph) {
40346 if (!graph.hasInitializedCache(key)) {
40347 graph.initializeCache(key);
40349 }), operators_1.finalize(function () {
40350 if (initializeCacheSubscription == null) {
40353 _this._removeFromArray(initializeCacheSubscription, _this._initializeCacheSubscriptions);
40354 _this._removeFromArray(firstGraphSubject$, _this._firstGraphSubjects$);
40356 .subscribe(function (graph) {
40357 firstGraphSubject$.next(graph);
40358 firstGraphSubject$.complete();
40359 }, function (error) {
40360 firstGraphSubject$.error(error);
40362 if (!initializeCacheSubscription.closed) {
40363 this._initializeCacheSubscriptions.push(initializeCacheSubscription);
40365 var graphSequence$ = firstGraph$.pipe(operators_1.mergeMap(function (graph) {
40366 if (graph.isCachingNodeSequence(key) || !graph.hasNodeSequence(key)) {
40367 return graph.cacheNodeSequence$(key);
40369 return rxjs_1.of(graph);
40370 }), operators_1.publishReplay(1), operators_1.refCount());
40371 var sequenceSubscription = graphSequence$.pipe(operators_1.tap(function (graph) {
40372 if (!graph.getNode(key).sequenceEdges.cached) {
40373 graph.cacheSequenceEdges(key);
40375 }), operators_1.finalize(function () {
40376 if (sequenceSubscription == null) {
40379 _this._removeFromArray(sequenceSubscription, _this._sequenceSubscriptions);
40381 .subscribe(function (graph) { return; }, function (error) {
40382 console.error("Failed to cache sequence edges (" + key + ").", error);
40384 if (!sequenceSubscription.closed) {
40385 this._sequenceSubscriptions.push(sequenceSubscription);
40387 if (this._graphMode === Graph_1.GraphMode.Spatial) {
40388 var spatialSubscription_1 = firstGraph$.pipe(operators_1.expand(function (graph) {
40389 if (graph.hasTiles(key)) {
40390 return rxjs_1.empty();
40392 return rxjs_1.from(graph.cacheTiles$(key)).pipe(operators_1.mergeMap(function (graph$) {
40393 return graph$.pipe(operators_1.mergeMap(function (g) {
40394 if (g.isCachingTiles(key)) {
40395 return rxjs_1.empty();
40397 return rxjs_1.of(g);
40398 }), operators_1.catchError(function (error, caught$) {
40399 console.error("Failed to cache tile data (" + key + ").", error);
40400 return rxjs_1.empty();
40403 }), operators_1.last(), operators_1.mergeMap(function (graph) {
40404 if (graph.hasSpatialArea(key)) {
40405 return rxjs_1.of(graph);
40407 return rxjs_1.from(graph.cacheSpatialArea$(key)).pipe(operators_1.mergeMap(function (graph$) {
40408 return graph$.pipe(operators_1.catchError(function (error, caught$) {
40409 console.error("Failed to cache spatial nodes (" + key + ").", error);
40410 return rxjs_1.empty();
40413 }), operators_1.last(), operators_1.mergeMap(function (graph) {
40414 return graph.hasNodeSequence(key) ?
40416 graph.cacheNodeSequence$(key);
40417 }), operators_1.tap(function (graph) {
40418 if (!graph.getNode(key).spatialEdges.cached) {
40419 graph.cacheSpatialEdges(key);
40421 }), operators_1.finalize(function () {
40422 if (spatialSubscription_1 == null) {
40425 _this._removeFromArray(spatialSubscription_1, _this._spatialSubscriptions);
40427 .subscribe(function (graph) { return; }, function (error) {
40428 console.error("Failed to cache spatial edges (" + key + ").", error);
40430 if (!spatialSubscription_1.closed) {
40431 this._spatialSubscriptions.push(spatialSubscription_1);
40434 return node$.pipe(operators_1.first(function (node) {
40435 return node.assetsCached;
40439 * Cache a sequence in the graph and retrieve it.
40441 * @param {string} sequenceKey - Sequence key.
40442 * @returns {Observable<Sequence>} Observable emitting a single item,
40443 * the sequence, when it has been retrieved and its assets are cached.
40444 * @throws {Error} Propagates any IO node caching errors to the caller.
40446 GraphService.prototype.cacheSequence$ = function (sequenceKey) {
40447 return this._graph$.pipe(operators_1.first(), operators_1.mergeMap(function (graph) {
40448 if (graph.isCachingSequence(sequenceKey) || !graph.hasSequence(sequenceKey)) {
40449 return graph.cacheSequence$(sequenceKey);
40451 return rxjs_1.of(graph);
40452 }), operators_1.map(function (graph) {
40453 return graph.getSequence(sequenceKey);
40457 * Cache a sequence and its nodes in the graph and retrieve the sequence.
40459 * @description Caches a sequence and its assets are cached and
40460 * retrieves all nodes belonging to the sequence. The node assets
40461 * or edges will not be cached.
40463 * @param {string} sequenceKey - Sequence key.
40464 * @param {string} referenceNodeKey - Key of node to use as reference
40465 * for optimized caching.
40466 * @returns {Observable<Sequence>} Observable emitting a single item,
40467 * the sequence, when it has been retrieved, its assets are cached and
40468 * all nodes belonging to the sequence has been retrieved.
40469 * @throws {Error} Propagates any IO node caching errors to the caller.
40471 GraphService.prototype.cacheSequenceNodes$ = function (sequenceKey, referenceNodeKey) {
40472 return this._graph$.pipe(operators_1.first(), operators_1.mergeMap(function (graph) {
40473 if (graph.isCachingSequence(sequenceKey) || !graph.hasSequence(sequenceKey)) {
40474 return graph.cacheSequence$(sequenceKey);
40476 return rxjs_1.of(graph);
40477 }), operators_1.mergeMap(function (graph) {
40478 if (graph.isCachingSequenceNodes(sequenceKey) || !graph.hasSequenceNodes(sequenceKey)) {
40479 return graph.cacheSequenceNodes$(sequenceKey, referenceNodeKey);
40481 return rxjs_1.of(graph);
40482 }), operators_1.map(function (graph) {
40483 return graph.getSequence(sequenceKey);
40487 * Set a spatial edge filter on the graph.
40489 * @description Resets the spatial edges of all cached nodes.
40491 * @param {FilterExpression} filter - Filter expression to be applied.
40492 * @return {Observable<Graph>} Observable emitting a single item,
40493 * the graph, when the spatial edges have been reset.
40495 GraphService.prototype.setFilter$ = function (filter) {
40496 this._resetSubscriptions(this._spatialSubscriptions);
40497 return this._graph$.pipe(operators_1.first(), operators_1.tap(function (graph) {
40498 graph.resetSpatialEdges();
40499 graph.setFilter(filter);
40500 }), operators_1.map(function (graph) {
40505 * Set the graph mode.
40507 * @description If graph mode is set to spatial, caching
40508 * is performed with emphasis on spatial edges. If graph
40509 * mode is set to sequence no tile data is requested and
40510 * no spatial edges are computed.
40512 * When setting graph mode to sequence all spatial
40513 * subscriptions are aborted.
40515 * @param {GraphMode} mode - Graph mode to set.
40517 GraphService.prototype.setGraphMode = function (mode) {
40518 if (this._graphMode === mode) {
40521 if (mode === Graph_1.GraphMode.Sequence) {
40522 this._resetSubscriptions(this._spatialSubscriptions);
40524 this._graphMode = mode;
40525 this._graphModeSubject$.next(this._graphMode);
40530 * @description Resets the graph but keeps the nodes of the
40533 * @param {Array<string>} keepKeys - Keys of nodes to keep in graph.
40534 * @return {Observable<Node>} Observable emitting a single item,
40535 * the graph, when it has been reset.
40537 GraphService.prototype.reset$ = function (keepKeys) {
40538 this._abortSubjects(this._firstGraphSubjects$);
40539 this._resetSubscriptions(this._initializeCacheSubscriptions);
40540 this._resetSubscriptions(this._sequenceSubscriptions);
40541 this._resetSubscriptions(this._spatialSubscriptions);
40542 return this._graph$.pipe(operators_1.first(), operators_1.tap(function (graph) {
40543 graph.reset(keepKeys);
40544 }), operators_1.map(function (graph) {
40549 * Uncache the graph.
40551 * @description Uncaches the graph by removing tiles, nodes and
40552 * sequences. Keeps the nodes of the supplied keys and the tiles
40553 * related to those nodes.
40555 * @param {Array<string>} keepKeys - Keys of nodes to keep in graph.
40556 * @param {string} keepSequenceKey - Optional key of sequence
40557 * for which the belonging nodes should not be disposed or
40558 * removed from the graph. These nodes may still be uncached if
40559 * not specified in keep keys param.
40560 * @return {Observable<Graph>} Observable emitting a single item,
40561 * the graph, when the graph has been uncached.
40563 GraphService.prototype.uncache$ = function (keepKeys, keepSequenceKey) {
40564 return this._graph$.pipe(operators_1.first(), operators_1.tap(function (graph) {
40565 graph.uncache(keepKeys, keepSequenceKey);
40566 }), operators_1.map(function (graph) {
40570 GraphService.prototype._abortSubjects = function (subjects) {
40571 for (var _i = 0, _a = subjects.slice(); _i < _a.length; _i++) {
40572 var subject = _a[_i];
40573 this._removeFromArray(subject, subjects);
40574 subject.error(new Error("Cache node request was aborted."));
40577 GraphService.prototype._removeFromArray = function (object, objects) {
40578 var index = objects.indexOf(object);
40579 if (index !== -1) {
40580 objects.splice(index, 1);
40583 GraphService.prototype._resetSubscriptions = function (subscriptions) {
40584 for (var _i = 0, _a = subscriptions.slice(); _i < _a.length; _i++) {
40585 var subscription = _a[_i];
40586 this._removeFromArray(subscription, subscriptions);
40587 if (!subscription.closed) {
40588 subscription.unsubscribe();
40592 return GraphService;
40594 exports.GraphService = GraphService;
40595 exports.default = GraphService;
40597 },{"../Graph":279,"rxjs":27,"rxjs/operators":225}],394:[function(require,module,exports){
40599 Object.defineProperty(exports, "__esModule", { value: true });
40600 var operators_1 = require("rxjs/operators");
40601 var rxjs_1 = require("rxjs");
40602 var ImageLoadingService = /** @class */ (function () {
40603 function ImageLoadingService() {
40604 this._loadnode$ = new rxjs_1.Subject();
40605 this._loadstatus$ = this._loadnode$.pipe(operators_1.scan(function (_a, node) {
40607 var changed = false;
40608 if (node.loadStatus.total === 0 || node.loadStatus.loaded === node.loadStatus.total) {
40609 if (node.key in nodes) {
40610 delete nodes[node.key];
40615 nodes[node.key] = node.loadStatus;
40618 return [nodes, changed];
40619 }, [{}, false]), operators_1.filter(function (_a) {
40620 var nodes = _a[0], changed = _a[1];
40622 }), operators_1.map(function (_a) {
40625 }), operators_1.publishReplay(1), operators_1.refCount());
40626 this._loadstatus$.subscribe(function () { });
40628 Object.defineProperty(ImageLoadingService.prototype, "loadnode$", {
40630 return this._loadnode$;
40635 Object.defineProperty(ImageLoadingService.prototype, "loadstatus$", {
40637 return this._loadstatus$;
40642 return ImageLoadingService;
40644 exports.ImageLoadingService = ImageLoadingService;
40646 },{"rxjs":27,"rxjs/operators":225}],395:[function(require,module,exports){
40648 Object.defineProperty(exports, "__esModule", { value: true });
40649 var Pbf = require("pbf");
40650 var MeshReader = /** @class */ (function () {
40651 function MeshReader() {
40653 MeshReader.read = function (buffer) {
40654 var pbf = new Pbf(buffer);
40655 return pbf.readFields(MeshReader._readMeshField, { faces: [], vertices: [] });
40657 MeshReader._readMeshField = function (tag, mesh, pbf) {
40659 mesh.vertices.push(pbf.readFloat());
40661 else if (tag === 2) {
40662 mesh.faces.push(pbf.readVarint());
40667 exports.MeshReader = MeshReader;
40669 },{"pbf":24}],396:[function(require,module,exports){
40671 Object.defineProperty(exports, "__esModule", { value: true });
40672 var operators_1 = require("rxjs/operators");
40676 * @classdesc Represents a node in the navigation graph.
40678 * Explanation of position and bearing properties:
40680 * When images are uploaded they will have GPS information in the EXIF, this is what
40681 * is called `originalLatLon` {@link Node.originalLatLon}.
40683 * When Structure from Motions has been run for a node a `computedLatLon` that
40684 * differs from the `originalLatLon` will be created. It is different because
40685 * GPS positions are not very exact and SfM aligns the camera positions according
40686 * to the 3D reconstruction {@link Node.computedLatLon}.
40688 * At last there exist a `latLon` property which evaluates to
40689 * the `computedLatLon` from SfM if it exists but falls back
40690 * to the `originalLatLon` from the EXIF GPS otherwise {@link Node.latLon}.
40692 * Everything that is done in in the Viewer is based on the SfM positions,
40693 * i.e. `computedLatLon`. That is why the smooth transitions go in the right
40694 * direction (nd not in strange directions because of bad GPS).
40696 * E.g. when placing a marker in the Viewer it is relative to the SfM
40697 * position i.e. the `computedLatLon`.
40699 * The same concept as above also applies to the compass angle (or bearing) properties
40700 * `originalCa`, `computedCa` and `ca`.
40702 var Node = /** @class */ (function () {
40704 * Create a new node instance.
40706 * @description Nodes are always created internally by the library.
40707 * Nodes can not be added to the library through any API method.
40709 * @param {ICoreNode} coreNode - Raw core node data.
40712 function Node(core) {
40713 this._cache = null;
40717 Object.defineProperty(Node.prototype, "assetsCached", {
40719 * Get assets cached.
40721 * @description The assets that need to be cached for this property
40722 * to report true are the following: fill properties, image and mesh.
40723 * The library ensures that the current node will always have the
40726 * @returns {boolean} Value indicating whether all assets have been
40732 return this._core != null &&
40733 this._fill != null &&
40734 this._cache != null &&
40735 this._cache.image != null &&
40736 this._cache.mesh != null;
40741 Object.defineProperty(Node.prototype, "alt", {
40745 * @description If SfM has not been run the computed altitude is
40746 * set to a default value of two meters.
40748 * @returns {number} Altitude, in meters.
40751 return this._fill.calt;
40756 Object.defineProperty(Node.prototype, "ca", {
40760 * @description If the SfM computed compass angle exists it will
40761 * be returned, otherwise the original EXIF compass angle.
40763 * @returns {number} Compass angle, measured in degrees
40764 * clockwise with respect to north.
40767 return this._fill.cca != null ? this._fill.cca : this._fill.ca;
40772 Object.defineProperty(Node.prototype, "cameraProjection", {
40774 * Get cameraProjection.
40776 * @description Will be undefined if SfM has not been run.
40778 * @returns {number} The camera projection of the image.
40781 return this._fill.camera_projection_type;
40786 Object.defineProperty(Node.prototype, "capturedAt", {
40790 * @returns {number} Timestamp when the image was captured.
40793 return this._fill.captured_at;
40798 Object.defineProperty(Node.prototype, "cameraUuid", {
40802 * @description Will be undefined if the camera uuid was not
40803 * recorded in the image exif information.
40805 * @returns {string} Universally unique id for camera used
40806 * when capturing image.
40809 return this._fill.captured_with_camera_uuid;
40814 Object.defineProperty(Node.prototype, "ck1", {
40818 * @description Will not be set if SfM has not been run.
40820 * @returns {number} SfM computed radial distortion parameter
40824 return this._fill.ck1;
40829 Object.defineProperty(Node.prototype, "ck2", {
40833 * @description Will not be set if SfM has not been run.
40835 * @returns {number} SfM computed radial distortion parameter
40839 return this._fill.ck2;
40844 Object.defineProperty(Node.prototype, "computedCA", {
40848 * @description Will not be set if SfM has not been run.
40850 * @returns {number} SfM computed compass angle, measured
40851 * in degrees clockwise with respect to north.
40854 return this._fill.cca;
40859 Object.defineProperty(Node.prototype, "computedLatLon", {
40861 * Get computedLatLon.
40863 * @description Will not be set if SfM has not been run.
40865 * @returns {ILatLon} SfM computed latitude longitude in WGS84 datum,
40866 * measured in degrees.
40869 return this._core.cl;
40874 Object.defineProperty(Node.prototype, "focal", {
40878 * @description Will not be set if SfM has not been run.
40880 * @returns {number} SfM computed focal length.
40883 return this._fill.cfocal;
40888 Object.defineProperty(Node.prototype, "full", {
40892 * @description The library ensures that the current node will
40895 * @returns {boolean} Value indicating whether the node has all
40896 * properties filled.
40901 return this._fill != null;
40906 Object.defineProperty(Node.prototype, "fullPano", {
40910 * @returns {boolean} Value indicating whether the node is a complete
40914 return this._fill.gpano != null &&
40915 this._fill.gpano.CroppedAreaLeftPixels === 0 &&
40916 this._fill.gpano.CroppedAreaTopPixels === 0 &&
40917 this._fill.gpano.CroppedAreaImageWidthPixels === this._fill.gpano.FullPanoWidthPixels &&
40918 this._fill.gpano.CroppedAreaImageHeightPixels === this._fill.gpano.FullPanoHeightPixels;
40923 Object.defineProperty(Node.prototype, "gpano", {
40927 * @description Will not be set for non panoramic images.
40929 * @returns {IGPano} Panorama information for panorama images.
40932 return this._fill.gpano;
40937 Object.defineProperty(Node.prototype, "height", {
40941 * @returns {number} Height of original image, not adjusted
40945 return this._fill.height;
40950 Object.defineProperty(Node.prototype, "image", {
40954 * @description The image will always be set on the current node.
40956 * @returns {HTMLImageElement} Cached image element of the node.
40959 return this._cache.image;
40964 Object.defineProperty(Node.prototype, "image$", {
40968 * @returns {Observable<HTMLImageElement>} Observable emitting
40969 * the cached image when it is updated.
40974 return this._cache.image$;
40979 Object.defineProperty(Node.prototype, "key", {
40983 * @returns {string} Unique key of the node.
40986 return this._core.key;
40991 Object.defineProperty(Node.prototype, "latLon", {
40995 * @description If the SfM computed latitude longitude exist
40996 * it will be returned, otherwise the original EXIF latitude
40999 * @returns {ILatLon} Latitude longitude in WGS84 datum,
41000 * measured in degrees.
41003 return this._core.cl != null ? this._core.cl : this._core.l;
41008 Object.defineProperty(Node.prototype, "loadStatus", {
41012 * @returns {ILoadStatus} Value indicating the load status
41013 * of the mesh and image.
41016 return this._cache.loadStatus;
41021 Object.defineProperty(Node.prototype, "merged", {
41025 * @returns {boolean} Value indicating whether SfM has been
41026 * run on the node and the node has been merged into a
41027 * connected component.
41030 return this._fill != null &&
41031 this._fill.merge_version != null &&
41032 this._fill.merge_version > 0;
41037 Object.defineProperty(Node.prototype, "mergeCC", {
41041 * @description Will not be set if SfM has not yet been run on
41044 * @returns {number} SfM connected component key to which
41048 return this._fill.merge_cc;
41053 Object.defineProperty(Node.prototype, "mergeVersion", {
41055 * Get mergeVersion.
41057 * @returns {number} Version for which SfM was run and image was merged.
41060 return this._fill.merge_version;
41065 Object.defineProperty(Node.prototype, "mesh", {
41069 * @description The mesh will always be set on the current node.
41071 * @returns {IMesh} SfM triangulated mesh of reconstructed
41072 * atomic 3D points.
41075 return this._cache.mesh;
41080 Object.defineProperty(Node.prototype, "organizationKey", {
41082 * Get organizationKey.
41084 * @returns {string} Unique key of the organization to which
41085 * the node belongs. If the node does not belong to an
41086 * organization the organization key will be undefined.
41089 return this._fill.organization_key;
41094 Object.defineProperty(Node.prototype, "orientation", {
41098 * @returns {number} EXIF orientation of original image.
41101 return this._fill.orientation;
41106 Object.defineProperty(Node.prototype, "originalCA", {
41110 * @returns {number} Original EXIF compass angle, measured in
41114 return this._fill.ca;
41119 Object.defineProperty(Node.prototype, "originalLatLon", {
41121 * Get originalLatLon.
41123 * @returns {ILatLon} Original EXIF latitude longitude in
41124 * WGS84 datum, measured in degrees.
41127 return this._core.l;
41132 Object.defineProperty(Node.prototype, "pano", {
41136 * @returns {boolean} Value indicating whether the node is a panorama.
41137 * It could be a cropped or full panorama.
41140 return this._fill.gpano != null &&
41141 this._fill.gpano.FullPanoWidthPixels != null;
41146 Object.defineProperty(Node.prototype, "private", {
41150 * @returns {boolean} Value specifying if image is accessible to
41151 * organization members only or to everyone.
41154 return this._fill.private;
41159 Object.defineProperty(Node.prototype, "projectKey", {
41163 * @returns {string} Unique key of the project to which
41164 * the node belongs. If the node does not belong to a
41165 * project the project key will be undefined.
41167 * @deprecated This property will be deprecated in favor
41168 * of the organization key and private properties.
41171 return this._fill.project != null ?
41172 this._fill.project.key :
41178 Object.defineProperty(Node.prototype, "rotation", {
41182 * @description Will not be set if SfM has not been run.
41184 * @returns {Array<number>} Rotation vector in angle axis representation.
41187 return this._fill.c_rotation;
41192 Object.defineProperty(Node.prototype, "scale", {
41196 * @description Will not be set if SfM has not been run.
41198 * @returns {number} Scale of atomic reconstruction.
41201 return this._fill.atomic_scale;
41206 Object.defineProperty(Node.prototype, "sequenceKey", {
41210 * @returns {string} Unique key of the sequence to which
41211 * the node belongs.
41214 return this._core.sequence_key;
41219 Object.defineProperty(Node.prototype, "sequenceEdges", {
41221 * Get sequenceEdges.
41223 * @returns {IEdgeStatus} Value describing the status of the
41227 return this._cache.sequenceEdges;
41232 Object.defineProperty(Node.prototype, "sequenceEdges$", {
41234 * Get sequenceEdges$.
41236 * @description Internal observable, should not be used as an API.
41238 * @returns {Observable<IEdgeStatus>} Observable emitting
41239 * values describing the status of the sequence edges.
41244 return this._cache.sequenceEdges$;
41249 Object.defineProperty(Node.prototype, "spatialEdges", {
41251 * Get spatialEdges.
41253 * @returns {IEdgeStatus} Value describing the status of the
41257 return this._cache.spatialEdges;
41262 Object.defineProperty(Node.prototype, "spatialEdges$", {
41264 * Get spatialEdges$.
41266 * @description Internal observable, should not be used as an API.
41268 * @returns {Observable<IEdgeStatus>} Observable emitting
41269 * values describing the status of the spatial edges.
41274 return this._cache.spatialEdges$;
41279 Object.defineProperty(Node.prototype, "userKey", {
41283 * @returns {string} Unique key of the user who uploaded
41287 return this._fill.user.key;
41292 Object.defineProperty(Node.prototype, "username", {
41296 * @returns {string} Username of the user who uploaded
41300 return this._fill.user.username;
41305 Object.defineProperty(Node.prototype, "width", {
41309 * @returns {number} Width of original image, not
41310 * adjusted for orientation.
41313 return this._fill.width;
41319 * Cache the image and mesh assets.
41321 * @description The assets are always cached internally by the
41322 * library prior to setting a node as the current node.
41324 * @returns {Observable<Node>} Observable emitting this node whenever the
41325 * load status has changed and when the mesh or image has been fully loaded.
41329 Node.prototype.cacheAssets$ = function () {
41331 return this._cache.cacheAssets$(this.key, this.pano, this.merged).pipe(operators_1.map(function () {
41336 * Cache the image asset.
41338 * @description Use for caching a differently sized image than
41339 * the one currently held by the node.
41341 * @returns {Observable<Node>} Observable emitting this node whenever the
41342 * load status has changed and when the mesh or image has been fully loaded.
41346 Node.prototype.cacheImage$ = function (imageSize) {
41348 return this._cache.cacheImage$(this.key, imageSize).pipe(operators_1.map(function () {
41353 * Cache the sequence edges.
41355 * @description The sequence edges are cached asynchronously
41356 * internally by the library.
41358 * @param {Array<IEdge>} edges - Sequence edges to cache.
41361 Node.prototype.cacheSequenceEdges = function (edges) {
41362 this._cache.cacheSequenceEdges(edges);
41365 * Cache the spatial edges.
41367 * @description The spatial edges are cached asynchronously
41368 * internally by the library.
41370 * @param {Array<IEdge>} edges - Spatial edges to cache.
41373 Node.prototype.cacheSpatialEdges = function (edges) {
41374 this._cache.cacheSpatialEdges(edges);
41377 * Dispose the node.
41379 * @description Disposes all cached assets.
41382 Node.prototype.dispose = function () {
41383 if (this._cache != null) {
41384 this._cache.dispose();
41385 this._cache = null;
41391 * Initialize the node cache.
41393 * @description The node cache is initialized internally by
41396 * @param {NodeCache} cache - The node cache to set as cache.
41399 Node.prototype.initializeCache = function (cache) {
41400 if (this._cache != null) {
41401 throw new Error("Node cache already initialized (" + this.key + ").");
41403 this._cache = cache;
41406 * Fill the node with all properties.
41408 * @description The node is filled internally by
41411 * @param {IFillNode} fill - The fill node struct.
41414 Node.prototype.makeFull = function (fill) {
41415 if (fill == null) {
41416 throw new Error("Fill can not be null.");
41421 * Reset the sequence edges.
41425 Node.prototype.resetSequenceEdges = function () {
41426 this._cache.resetSequenceEdges();
41429 * Reset the spatial edges.
41433 Node.prototype.resetSpatialEdges = function () {
41434 this._cache.resetSpatialEdges();
41437 * Clears the image and mesh assets, aborts
41438 * any outstanding requests and resets edges.
41442 Node.prototype.uncache = function () {
41443 if (this._cache == null) {
41446 this._cache.dispose();
41447 this._cache = null;
41451 exports.Node = Node;
41452 exports.default = Node;
41454 },{"rxjs/operators":225}],397:[function(require,module,exports){
41455 (function (Buffer){
41457 Object.defineProperty(exports, "__esModule", { value: true });
41458 var rxjs_1 = require("rxjs");
41459 var operators_1 = require("rxjs/operators");
41460 var Graph_1 = require("../Graph");
41461 var Utils_1 = require("../Utils");
41465 * @classdesc Represents the cached properties of a node.
41467 var NodeCache = /** @class */ (function () {
41469 * Create a new node cache instance.
41471 function NodeCache() {
41472 this._disposed = false;
41473 this._image = null;
41474 this._loadStatus = { loaded: 0, total: 0 };
41476 this._sequenceEdges = { cached: false, edges: [] };
41477 this._spatialEdges = { cached: false, edges: [] };
41478 this._imageChanged$ = new rxjs_1.Subject();
41479 this._image$ = this._imageChanged$.pipe(operators_1.startWith(null), operators_1.publishReplay(1), operators_1.refCount());
41480 this._iamgeSubscription = this._image$.subscribe();
41481 this._sequenceEdgesChanged$ = new rxjs_1.Subject();
41482 this._sequenceEdges$ = this._sequenceEdgesChanged$.pipe(operators_1.startWith(this._sequenceEdges), operators_1.publishReplay(1), operators_1.refCount());
41483 this._sequenceEdgesSubscription = this._sequenceEdges$.subscribe(function () { });
41484 this._spatialEdgesChanged$ = new rxjs_1.Subject();
41485 this._spatialEdges$ = this._spatialEdgesChanged$.pipe(operators_1.startWith(this._spatialEdges), operators_1.publishReplay(1), operators_1.refCount());
41486 this._spatialEdgesSubscription = this._spatialEdges$.subscribe(function () { });
41487 this._cachingAssets$ = null;
41489 Object.defineProperty(NodeCache.prototype, "image", {
41493 * @description Will not be set when assets have not been cached
41494 * or when the object has been disposed.
41496 * @returns {HTMLImageElement} Cached image element of the node.
41499 return this._image;
41504 Object.defineProperty(NodeCache.prototype, "image$", {
41508 * @returns {Observable<HTMLImageElement>} Observable emitting
41509 * the cached image when it is updated.
41512 return this._image$;
41517 Object.defineProperty(NodeCache.prototype, "loadStatus", {
41521 * @returns {ILoadStatus} Value indicating the load status
41522 * of the mesh and image.
41525 return this._loadStatus;
41530 Object.defineProperty(NodeCache.prototype, "mesh", {
41534 * @description Will not be set when assets have not been cached
41535 * or when the object has been disposed.
41537 * @returns {IMesh} SfM triangulated mesh of reconstructed
41538 * atomic 3D points.
41546 Object.defineProperty(NodeCache.prototype, "sequenceEdges", {
41548 * Get sequenceEdges.
41550 * @returns {IEdgeStatus} Value describing the status of the
41554 return this._sequenceEdges;
41559 Object.defineProperty(NodeCache.prototype, "sequenceEdges$", {
41561 * Get sequenceEdges$.
41563 * @returns {Observable<IEdgeStatus>} Observable emitting
41564 * values describing the status of the sequence edges.
41567 return this._sequenceEdges$;
41572 Object.defineProperty(NodeCache.prototype, "spatialEdges", {
41574 * Get spatialEdges.
41576 * @returns {IEdgeStatus} Value describing the status of the
41580 return this._spatialEdges;
41585 Object.defineProperty(NodeCache.prototype, "spatialEdges$", {
41587 * Get spatialEdges$.
41589 * @returns {Observable<IEdgeStatus>} Observable emitting
41590 * values describing the status of the spatial edges.
41593 return this._spatialEdges$;
41599 * Cache the image and mesh assets.
41601 * @param {string} key - Key of the node to cache.
41602 * @param {boolean} pano - Value indicating whether node is a panorama.
41603 * @param {boolean} merged - Value indicating whether node is merged.
41604 * @returns {Observable<NodeCache>} Observable emitting this node
41605 * cache whenever the load status has changed and when the mesh or image
41606 * has been fully loaded.
41608 NodeCache.prototype.cacheAssets$ = function (key, pano, merged) {
41610 if (this._cachingAssets$ != null) {
41611 return this._cachingAssets$;
41613 var imageSize = pano ?
41614 Utils_1.Settings.basePanoramaSize :
41615 Utils_1.Settings.baseImageSize;
41616 this._cachingAssets$ = rxjs_1.combineLatest(this._cacheImage$(key, imageSize), this._cacheMesh$(key, merged)).pipe(operators_1.map(function (_a) {
41617 var imageStatus = _a[0], meshStatus = _a[1];
41618 _this._loadStatus.loaded = 0;
41619 _this._loadStatus.total = 0;
41621 _this._mesh = meshStatus.object;
41622 _this._loadStatus.loaded += meshStatus.loaded.loaded;
41623 _this._loadStatus.total += meshStatus.loaded.total;
41626 _this._image = imageStatus.object;
41627 _this._loadStatus.loaded += imageStatus.loaded.loaded;
41628 _this._loadStatus.total += imageStatus.loaded.total;
41631 }), operators_1.finalize(function () {
41632 _this._cachingAssets$ = null;
41633 }), operators_1.publishReplay(1), operators_1.refCount());
41634 this._cachingAssets$.pipe(operators_1.first(function (nodeCache) {
41635 return !!nodeCache._image;
41637 .subscribe(function (nodeCache) {
41638 _this._imageChanged$.next(_this._image);
41639 }, function (error) { });
41640 return this._cachingAssets$;
41643 * Cache an image with a higher resolution than the current one.
41645 * @param {string} key - Key of the node to cache.
41646 * @param {ImageSize} imageSize - The size to cache.
41647 * @returns {Observable<NodeCache>} Observable emitting a single item,
41648 * the node cache, when the image has been cached. If supplied image
41649 * size is not larger than the current image size the node cache is
41650 * returned immediately.
41652 NodeCache.prototype.cacheImage$ = function (key, imageSize) {
41654 if (this._image != null && imageSize <= Math.max(this._image.width, this._image.height)) {
41655 return rxjs_1.of(this);
41657 var cacheImage$ = this._cacheImage$(key, imageSize).pipe(operators_1.first(function (status) {
41658 return status.object != null;
41659 }), operators_1.tap(function (status) {
41660 _this._disposeImage();
41661 _this._image = status.object;
41662 }), operators_1.map(function (imageStatus) {
41664 }), operators_1.publishReplay(1), operators_1.refCount());
41666 .subscribe(function (nodeCache) {
41667 _this._imageChanged$.next(_this._image);
41668 }, function (error) { });
41669 return cacheImage$;
41672 * Cache the sequence edges.
41674 * @param {Array<IEdge>} edges - Sequence edges to cache.
41676 NodeCache.prototype.cacheSequenceEdges = function (edges) {
41677 this._sequenceEdges = { cached: true, edges: edges };
41678 this._sequenceEdgesChanged$.next(this._sequenceEdges);
41681 * Cache the spatial edges.
41683 * @param {Array<IEdge>} edges - Spatial edges to cache.
41685 NodeCache.prototype.cacheSpatialEdges = function (edges) {
41686 this._spatialEdges = { cached: true, edges: edges };
41687 this._spatialEdgesChanged$.next(this._spatialEdges);
41690 * Dispose the node cache.
41692 * @description Disposes all cached assets and unsubscribes to
41695 NodeCache.prototype.dispose = function () {
41696 this._iamgeSubscription.unsubscribe();
41697 this._sequenceEdgesSubscription.unsubscribe();
41698 this._spatialEdgesSubscription.unsubscribe();
41699 this._disposeImage();
41701 this._loadStatus.loaded = 0;
41702 this._loadStatus.total = 0;
41703 this._sequenceEdges = { cached: false, edges: [] };
41704 this._spatialEdges = { cached: false, edges: [] };
41705 this._imageChanged$.next(null);
41706 this._sequenceEdgesChanged$.next(this._sequenceEdges);
41707 this._spatialEdgesChanged$.next(this._spatialEdges);
41708 this._disposed = true;
41709 if (this._imageRequest != null) {
41710 this._imageRequest.abort();
41712 if (this._meshRequest != null) {
41713 this._meshRequest.abort();
41717 * Reset the sequence edges.
41719 NodeCache.prototype.resetSequenceEdges = function () {
41720 this._sequenceEdges = { cached: false, edges: [] };
41721 this._sequenceEdgesChanged$.next(this._sequenceEdges);
41724 * Reset the spatial edges.
41726 NodeCache.prototype.resetSpatialEdges = function () {
41727 this._spatialEdges = { cached: false, edges: [] };
41728 this._spatialEdgesChanged$.next(this._spatialEdges);
41733 * @param {string} key - Key of the node to cache.
41734 * @param {boolean} pano - Value indicating whether node is a panorama.
41735 * @returns {Observable<ILoadStatusObject<HTMLImageElement>>} Observable
41736 * emitting a load status object every time the load status changes
41737 * and completes when the image is fully loaded.
41739 NodeCache.prototype._cacheImage$ = function (key, imageSize) {
41741 return rxjs_1.Observable.create(function (subscriber) {
41742 var xmlHTTP = new XMLHttpRequest();
41743 xmlHTTP.open("GET", Utils_1.Urls.thumbnail(key, imageSize, Utils_1.Urls.origin), true);
41744 xmlHTTP.responseType = "arraybuffer";
41745 xmlHTTP.timeout = 15000;
41746 xmlHTTP.onload = function (pe) {
41747 if (xmlHTTP.status !== 200) {
41748 _this._imageRequest = null;
41749 subscriber.error(new Error("Failed to fetch image (" + key + "). Status: " + xmlHTTP.status + ", " + xmlHTTP.statusText));
41752 var image = new Image();
41753 image.crossOrigin = "Anonymous";
41754 image.onload = function (e) {
41755 _this._imageRequest = null;
41756 if (_this._disposed) {
41757 window.URL.revokeObjectURL(image.src);
41758 subscriber.error(new Error("Image load was aborted (" + key + ")"));
41761 subscriber.next({ loaded: { loaded: pe.loaded, total: pe.total }, object: image });
41762 subscriber.complete();
41764 image.onerror = function (error) {
41765 _this._imageRequest = null;
41766 subscriber.error(new Error("Failed to load image (" + key + ")"));
41768 var blob = new Blob([xmlHTTP.response]);
41769 image.src = window.URL.createObjectURL(blob);
41771 xmlHTTP.onprogress = function (pe) {
41772 if (_this._disposed) {
41775 subscriber.next({ loaded: { loaded: pe.loaded, total: pe.total }, object: null });
41777 xmlHTTP.onerror = function (error) {
41778 _this._imageRequest = null;
41779 subscriber.error(new Error("Failed to fetch image (" + key + ")"));
41781 xmlHTTP.ontimeout = function (e) {
41782 _this._imageRequest = null;
41783 subscriber.error(new Error("Image request timed out (" + key + ")"));
41785 xmlHTTP.onabort = function (event) {
41786 _this._imageRequest = null;
41787 subscriber.error(new Error("Image request was aborted (" + key + ")"));
41789 _this._imageRequest = xmlHTTP;
41790 xmlHTTP.send(null);
41796 * @param {string} key - Key of the node to cache.
41797 * @param {boolean} merged - Value indicating whether node is merged.
41798 * @returns {Observable<ILoadStatusObject<IMesh>>} Observable emitting
41799 * a load status object every time the load status changes and completes
41800 * when the mesh is fully loaded.
41802 NodeCache.prototype._cacheMesh$ = function (key, merged) {
41804 return rxjs_1.Observable.create(function (subscriber) {
41806 subscriber.next(_this._createEmptyMeshLoadStatus());
41807 subscriber.complete();
41810 var xmlHTTP = new XMLHttpRequest();
41811 xmlHTTP.open("GET", Utils_1.Urls.protoMesh(key), true);
41812 xmlHTTP.responseType = "arraybuffer";
41813 xmlHTTP.timeout = 15000;
41814 xmlHTTP.onload = function (pe) {
41815 _this._meshRequest = null;
41816 if (_this._disposed) {
41819 var mesh = xmlHTTP.status === 200 ?
41820 Graph_1.MeshReader.read(new Buffer(xmlHTTP.response)) :
41821 { faces: [], vertices: [] };
41822 subscriber.next({ loaded: { loaded: pe.loaded, total: pe.total }, object: mesh });
41823 subscriber.complete();
41825 xmlHTTP.onprogress = function (pe) {
41826 if (_this._disposed) {
41829 subscriber.next({ loaded: { loaded: pe.loaded, total: pe.total }, object: null });
41831 xmlHTTP.onerror = function (e) {
41832 _this._meshRequest = null;
41833 console.error("Failed to cache mesh (" + key + ")");
41834 subscriber.next(_this._createEmptyMeshLoadStatus());
41835 subscriber.complete();
41837 xmlHTTP.ontimeout = function (e) {
41838 _this._meshRequest = null;
41839 console.error("Mesh request timed out (" + key + ")");
41840 subscriber.next(_this._createEmptyMeshLoadStatus());
41841 subscriber.complete();
41843 xmlHTTP.onabort = function (e) {
41844 _this._meshRequest = null;
41845 subscriber.error(new Error("Mesh request was aborted (" + key + ")"));
41847 _this._meshRequest = xmlHTTP;
41848 xmlHTTP.send(null);
41852 * Create a load status object with an empty mesh.
41854 * @returns {ILoadStatusObject<IMesh>} Load status object
41857 NodeCache.prototype._createEmptyMeshLoadStatus = function () {
41859 loaded: { loaded: 0, total: 0 },
41860 object: { faces: [], vertices: [] },
41863 NodeCache.prototype._disposeImage = function () {
41864 if (this._image != null) {
41865 window.URL.revokeObjectURL(this._image.src);
41867 this._image = null;
41871 exports.NodeCache = NodeCache;
41872 exports.default = NodeCache;
41874 }).call(this,require("buffer").Buffer)
41876 },{"../Graph":279,"../Utils":285,"buffer":7,"rxjs":27,"rxjs/operators":225}],398:[function(require,module,exports){
41878 Object.defineProperty(exports, "__esModule", { value: true });
41882 * @classdesc Represents a sequence of ordered nodes.
41884 var Sequence = /** @class */ (function () {
41886 * Create a new sequene instance.
41888 * @param {ISequence} sequence - Raw sequence data.
41890 function Sequence(sequence) {
41891 this._key = sequence.key;
41892 this._keys = sequence.keys;
41894 Object.defineProperty(Sequence.prototype, "key", {
41898 * @returns {string} Unique sequence key.
41906 Object.defineProperty(Sequence.prototype, "keys", {
41910 * @returns {Array<string>} Array of ordered node keys in the sequence.
41919 * Dispose the sequence.
41921 * @description Disposes all cached assets.
41923 Sequence.prototype.dispose = function () {
41928 * Find the next node key in the sequence with respect to
41929 * the provided node key.
41931 * @param {string} key - Reference node key.
41932 * @returns {string} Next key in sequence if it exists, null otherwise.
41934 Sequence.prototype.findNextKey = function (key) {
41935 var i = this._keys.indexOf(key);
41936 if ((i + 1) >= this._keys.length || i === -1) {
41940 return this._keys[i + 1];
41944 * Find the previous node key in the sequence with respect to
41945 * the provided node key.
41947 * @param {string} key - Reference node key.
41948 * @returns {string} Previous key in sequence if it exists, null otherwise.
41950 Sequence.prototype.findPrevKey = function (key) {
41951 var i = this._keys.indexOf(key);
41952 if (i === 0 || i === -1) {
41956 return this._keys[i - 1];
41961 exports.Sequence = Sequence;
41962 exports.default = Sequence;
41964 },{}],399:[function(require,module,exports){
41966 Object.defineProperty(exports, "__esModule", { value: true });
41967 var THREE = require("three");
41968 var Edge_1 = require("../../Edge");
41969 var Error_1 = require("../../Error");
41970 var Geo_1 = require("../../Geo");
41972 * @class EdgeCalculator
41974 * @classdesc Represents a class for calculating node edges.
41976 var EdgeCalculator = /** @class */ (function () {
41978 * Create a new edge calculator instance.
41980 * @param {EdgeCalculatorSettings} settings - Settings struct.
41981 * @param {EdgeCalculatorDirections} directions - Directions struct.
41982 * @param {EdgeCalculatorCoefficients} coefficients - Coefficients struct.
41984 function EdgeCalculator(settings, directions, coefficients) {
41985 this._spatial = new Geo_1.Spatial();
41986 this._geoCoords = new Geo_1.GeoCoords();
41987 this._settings = settings != null ? settings : new Edge_1.EdgeCalculatorSettings();
41988 this._directions = directions != null ? directions : new Edge_1.EdgeCalculatorDirections();
41989 this._coefficients = coefficients != null ? coefficients : new Edge_1.EdgeCalculatorCoefficients();
41992 * Returns the potential edges to destination nodes for a set
41993 * of nodes with respect to a source node.
41995 * @param {Node} node - Source node.
41996 * @param {Array<Node>} nodes - Potential destination nodes.
41997 * @param {Array<string>} fallbackKeys - Keys for destination nodes that should
41998 * be returned even if they do not meet the criteria for a potential edge.
41999 * @throws {ArgumentMapillaryError} If node is not full.
42001 EdgeCalculator.prototype.getPotentialEdges = function (node, potentialNodes, fallbackKeys) {
42003 throw new Error_1.ArgumentMapillaryError("Node has to be full.");
42005 if (!node.merged) {
42008 var currentDirection = this._spatial.viewingDirection(node.rotation);
42009 var currentVerticalDirection = this._spatial.angleToPlane(currentDirection.toArray(), [0, 0, 1]);
42010 var potentialEdges = [];
42011 for (var _i = 0, potentialNodes_1 = potentialNodes; _i < potentialNodes_1.length; _i++) {
42012 var potential = potentialNodes_1[_i];
42013 if (!potential.merged ||
42014 potential.key === node.key) {
42017 var enu = this._geoCoords.geodeticToEnu(potential.latLon.lat, potential.latLon.lon, potential.alt, node.latLon.lat, node.latLon.lon, node.alt);
42018 var motion = new THREE.Vector3(enu[0], enu[1], enu[2]);
42019 var distance = motion.length();
42020 if (distance > this._settings.maxDistance &&
42021 fallbackKeys.indexOf(potential.key) < 0) {
42024 var motionChange = this._spatial.angleBetweenVector2(currentDirection.x, currentDirection.y, motion.x, motion.y);
42025 var verticalMotion = this._spatial.angleToPlane(motion.toArray(), [0, 0, 1]);
42026 var direction = this._spatial.viewingDirection(potential.rotation);
42027 var directionChange = this._spatial.angleBetweenVector2(currentDirection.x, currentDirection.y, direction.x, direction.y);
42028 var verticalDirection = this._spatial.angleToPlane(direction.toArray(), [0, 0, 1]);
42029 var verticalDirectionChange = verticalDirection - currentVerticalDirection;
42030 var rotation = this._spatial.relativeRotationAngle(node.rotation, potential.rotation);
42031 var worldMotionAzimuth = this._spatial.angleBetweenVector2(1, 0, motion.x, motion.y);
42032 var sameSequence = potential.sequenceKey != null &&
42033 node.sequenceKey != null &&
42034 potential.sequenceKey === node.sequenceKey;
42035 var sameMergeCC = (potential.mergeCC == null && node.mergeCC == null) ||
42036 potential.mergeCC === node.mergeCC;
42037 var sameUser = potential.userKey === node.userKey;
42038 var potentialEdge = {
42039 capturedAt: potential.capturedAt,
42040 croppedPano: potential.pano && !potential.fullPano,
42041 directionChange: directionChange,
42042 distance: distance,
42043 fullPano: potential.fullPano,
42044 key: potential.key,
42045 motionChange: motionChange,
42046 rotation: rotation,
42047 sameMergeCC: sameMergeCC,
42048 sameSequence: sameSequence,
42049 sameUser: sameUser,
42050 sequenceKey: potential.sequenceKey,
42051 verticalDirectionChange: verticalDirectionChange,
42052 verticalMotion: verticalMotion,
42053 worldMotionAzimuth: worldMotionAzimuth,
42055 potentialEdges.push(potentialEdge);
42057 return potentialEdges;
42060 * Computes the sequence edges for a node.
42062 * @param {Node} node - Source node.
42063 * @throws {ArgumentMapillaryError} If node is not full.
42065 EdgeCalculator.prototype.computeSequenceEdges = function (node, sequence) {
42067 throw new Error_1.ArgumentMapillaryError("Node has to be full.");
42069 if (node.sequenceKey !== sequence.key) {
42070 throw new Error_1.ArgumentMapillaryError("Node and sequence does not correspond.");
42073 var nextKey = sequence.findNextKey(node.key);
42074 if (nextKey != null) {
42077 direction: Edge_1.EdgeDirection.Next,
42078 worldMotionAzimuth: Number.NaN,
42084 var prevKey = sequence.findPrevKey(node.key);
42085 if (prevKey != null) {
42088 direction: Edge_1.EdgeDirection.Prev,
42089 worldMotionAzimuth: Number.NaN,
42098 * Computes the similar edges for a node.
42100 * @description Similar edges for perspective images and cropped panoramas
42101 * look roughly in the same direction and are positioned closed to the node.
42102 * Similar edges for full panoramas only target other full panoramas.
42104 * @param {Node} node - Source node.
42105 * @param {Array<IPotentialEdge>} potentialEdges - Potential edges.
42106 * @throws {ArgumentMapillaryError} If node is not full.
42108 EdgeCalculator.prototype.computeSimilarEdges = function (node, potentialEdges) {
42111 throw new Error_1.ArgumentMapillaryError("Node has to be full.");
42113 var nodeFullPano = node.fullPano;
42114 var sequenceGroups = {};
42115 for (var _i = 0, potentialEdges_1 = potentialEdges; _i < potentialEdges_1.length; _i++) {
42116 var potentialEdge = potentialEdges_1[_i];
42117 if (potentialEdge.sequenceKey == null) {
42120 if (potentialEdge.sameSequence) {
42123 if (nodeFullPano) {
42124 if (!potentialEdge.fullPano) {
42129 if (!potentialEdge.fullPano &&
42130 Math.abs(potentialEdge.directionChange) > this._settings.similarMaxDirectionChange) {
42134 if (potentialEdge.distance > this._settings.similarMaxDistance) {
42137 if (potentialEdge.sameUser &&
42138 Math.abs(potentialEdge.capturedAt - node.capturedAt) <
42139 this._settings.similarMinTimeDifference) {
42142 if (sequenceGroups[potentialEdge.sequenceKey] == null) {
42143 sequenceGroups[potentialEdge.sequenceKey] = [];
42145 sequenceGroups[potentialEdge.sequenceKey].push(potentialEdge);
42147 var similarEdges = [];
42148 var calculateScore = node.fullPano ?
42149 function (potentialEdge) {
42150 return potentialEdge.distance;
42152 function (potentialEdge) {
42153 return _this._coefficients.similarDistance * potentialEdge.distance +
42154 _this._coefficients.similarRotation * potentialEdge.rotation;
42156 for (var sequenceKey in sequenceGroups) {
42157 if (!sequenceGroups.hasOwnProperty(sequenceKey)) {
42160 var lowestScore = Number.MAX_VALUE;
42161 var similarEdge = null;
42162 for (var _a = 0, _b = sequenceGroups[sequenceKey]; _a < _b.length; _a++) {
42163 var potentialEdge = _b[_a];
42164 var score = calculateScore(potentialEdge);
42165 if (score < lowestScore) {
42166 lowestScore = score;
42167 similarEdge = potentialEdge;
42170 if (similarEdge == null) {
42173 similarEdges.push(similarEdge);
42175 return similarEdges
42176 .map(function (potentialEdge) {
42179 direction: Edge_1.EdgeDirection.Similar,
42180 worldMotionAzimuth: potentialEdge.worldMotionAzimuth,
42183 to: potentialEdge.key,
42188 * Computes the step edges for a perspective node.
42190 * @description Step edge targets can only be other perspective nodes.
42191 * Returns an empty array for cropped and full panoramas.
42193 * @param {Node} node - Source node.
42194 * @param {Array<IPotentialEdge>} potentialEdges - Potential edges.
42195 * @param {string} prevKey - Key of previous node in sequence.
42196 * @param {string} prevKey - Key of next node in sequence.
42197 * @throws {ArgumentMapillaryError} If node is not full.
42199 EdgeCalculator.prototype.computeStepEdges = function (node, potentialEdges, prevKey, nextKey) {
42201 throw new Error_1.ArgumentMapillaryError("Node has to be full.");
42207 for (var k in this._directions.steps) {
42208 if (!this._directions.steps.hasOwnProperty(k)) {
42211 var step = this._directions.steps[k];
42212 var lowestScore = Number.MAX_VALUE;
42214 var fallback = null;
42215 for (var _i = 0, potentialEdges_2 = potentialEdges; _i < potentialEdges_2.length; _i++) {
42216 var potential = potentialEdges_2[_i];
42217 if (potential.croppedPano || potential.fullPano) {
42220 if (Math.abs(potential.directionChange) > this._settings.stepMaxDirectionChange) {
42223 var motionDifference = this._spatial.angleDifference(step.motionChange, potential.motionChange);
42224 var directionMotionDifference = this._spatial.angleDifference(potential.directionChange, motionDifference);
42225 var drift = Math.max(Math.abs(motionDifference), Math.abs(directionMotionDifference));
42226 if (Math.abs(drift) > this._settings.stepMaxDrift) {
42229 var potentialKey = potential.key;
42230 if (step.useFallback && (potentialKey === prevKey || potentialKey === nextKey)) {
42231 fallback = potential;
42233 if (potential.distance > this._settings.stepMaxDistance) {
42236 motionDifference = Math.sqrt(motionDifference * motionDifference +
42237 potential.verticalMotion * potential.verticalMotion);
42238 var score = this._coefficients.stepPreferredDistance *
42239 Math.abs(potential.distance - this._settings.stepPreferredDistance) /
42240 this._settings.stepMaxDistance +
42241 this._coefficients.stepMotion * motionDifference / this._settings.stepMaxDrift +
42242 this._coefficients.stepRotation * potential.rotation / this._settings.stepMaxDirectionChange +
42243 this._coefficients.stepSequencePenalty * (potential.sameSequence ? 0 : 1) +
42244 this._coefficients.stepMergeCCPenalty * (potential.sameMergeCC ? 0 : 1);
42245 if (score < lowestScore) {
42246 lowestScore = score;
42250 edge = edge == null ? fallback : edge;
42251 if (edge != null) {
42254 direction: step.direction,
42255 worldMotionAzimuth: edge.worldMotionAzimuth,
42265 * Computes the turn edges for a perspective node.
42267 * @description Turn edge targets can only be other perspective images.
42268 * Returns an empty array for cropped and full panoramas.
42270 * @param {Node} node - Source node.
42271 * @param {Array<IPotentialEdge>} potentialEdges - Potential edges.
42272 * @throws {ArgumentMapillaryError} If node is not full.
42274 EdgeCalculator.prototype.computeTurnEdges = function (node, potentialEdges) {
42276 throw new Error_1.ArgumentMapillaryError("Node has to be full.");
42282 for (var k in this._directions.turns) {
42283 if (!this._directions.turns.hasOwnProperty(k)) {
42286 var turn = this._directions.turns[k];
42287 var lowestScore = Number.MAX_VALUE;
42289 for (var _i = 0, potentialEdges_3 = potentialEdges; _i < potentialEdges_3.length; _i++) {
42290 var potential = potentialEdges_3[_i];
42291 if (potential.croppedPano || potential.fullPano) {
42294 if (potential.distance > this._settings.turnMaxDistance) {
42297 var rig = turn.direction !== Edge_1.EdgeDirection.TurnU &&
42298 potential.distance < this._settings.turnMaxRigDistance &&
42299 Math.abs(potential.directionChange) > this._settings.turnMinRigDirectionChange;
42300 var directionDifference = this._spatial.angleDifference(turn.directionChange, potential.directionChange);
42301 var score = void 0;
42303 potential.directionChange * turn.directionChange > 0 &&
42304 Math.abs(potential.directionChange) < Math.abs(turn.directionChange)) {
42305 score = -Math.PI / 2 + Math.abs(potential.directionChange);
42308 if (Math.abs(directionDifference) > this._settings.turnMaxDirectionChange) {
42311 var motionDifference = turn.motionChange ?
42312 this._spatial.angleDifference(turn.motionChange, potential.motionChange) : 0;
42313 motionDifference = Math.sqrt(motionDifference * motionDifference +
42314 potential.verticalMotion * potential.verticalMotion);
42316 this._coefficients.turnDistance * potential.distance /
42317 this._settings.turnMaxDistance +
42318 this._coefficients.turnMotion * motionDifference / Math.PI +
42319 this._coefficients.turnSequencePenalty * (potential.sameSequence ? 0 : 1) +
42320 this._coefficients.turnMergeCCPenalty * (potential.sameMergeCC ? 0 : 1);
42322 if (score < lowestScore) {
42323 lowestScore = score;
42327 if (edge != null) {
42330 direction: turn.direction,
42331 worldMotionAzimuth: edge.worldMotionAzimuth,
42341 * Computes the pano edges for a perspective node.
42343 * @description Perspective to pano edge targets can only be
42344 * full pano nodes. Returns an empty array for cropped and full panoramas.
42346 * @param {Node} node - Source node.
42347 * @param {Array<IPotentialEdge>} potentialEdges - Potential edges.
42348 * @throws {ArgumentMapillaryError} If node is not full.
42350 EdgeCalculator.prototype.computePerspectiveToPanoEdges = function (node, potentialEdges) {
42352 throw new Error_1.ArgumentMapillaryError("Node has to be full.");
42357 var lowestScore = Number.MAX_VALUE;
42359 for (var _i = 0, potentialEdges_4 = potentialEdges; _i < potentialEdges_4.length; _i++) {
42360 var potential = potentialEdges_4[_i];
42361 if (!potential.fullPano) {
42364 var score = this._coefficients.panoPreferredDistance *
42365 Math.abs(potential.distance - this._settings.panoPreferredDistance) /
42366 this._settings.panoMaxDistance +
42367 this._coefficients.panoMotion * Math.abs(potential.motionChange) / Math.PI +
42368 this._coefficients.panoMergeCCPenalty * (potential.sameMergeCC ? 0 : 1);
42369 if (score < lowestScore) {
42370 lowestScore = score;
42374 if (edge == null) {
42380 direction: Edge_1.EdgeDirection.Pano,
42381 worldMotionAzimuth: edge.worldMotionAzimuth,
42389 * Computes the full pano and step edges for a full pano node.
42391 * @description Pano to pano edge targets can only be
42392 * full pano nodes. Pano to step edge targets can only be perspective
42394 * Returns an empty array for cropped panoramas and perspective nodes.
42396 * @param {Node} node - Source node.
42397 * @param {Array<IPotentialEdge>} potentialEdges - Potential edges.
42398 * @throws {ArgumentMapillaryError} If node is not full.
42400 EdgeCalculator.prototype.computePanoEdges = function (node, potentialEdges) {
42402 throw new Error_1.ArgumentMapillaryError("Node has to be full.");
42404 if (!node.fullPano) {
42407 var panoEdges = [];
42408 var potentialPanos = [];
42409 var potentialSteps = [];
42410 for (var _i = 0, potentialEdges_5 = potentialEdges; _i < potentialEdges_5.length; _i++) {
42411 var potential = potentialEdges_5[_i];
42412 if (potential.distance > this._settings.panoMaxDistance) {
42415 if (potential.fullPano) {
42416 if (potential.distance < this._settings.panoMinDistance) {
42419 potentialPanos.push(potential);
42422 if (potential.croppedPano) {
42425 for (var k in this._directions.panos) {
42426 if (!this._directions.panos.hasOwnProperty(k)) {
42429 var pano = this._directions.panos[k];
42430 var turn = this._spatial.angleDifference(potential.directionChange, potential.motionChange);
42431 var turnChange = this._spatial.angleDifference(pano.directionChange, turn);
42432 if (Math.abs(turnChange) > this._settings.panoMaxStepTurnChange) {
42435 potentialSteps.push([pano.direction, potential]);
42436 // break if step direction found
42441 var maxRotationDifference = Math.PI / this._settings.panoMaxItems;
42442 var occupiedAngles = [];
42443 var stepAngles = [];
42444 for (var index = 0; index < this._settings.panoMaxItems; index++) {
42445 var rotation = index / this._settings.panoMaxItems * 2 * Math.PI;
42446 var lowestScore = Number.MAX_VALUE;
42448 for (var _a = 0, potentialPanos_1 = potentialPanos; _a < potentialPanos_1.length; _a++) {
42449 var potential = potentialPanos_1[_a];
42450 var motionDifference = this._spatial.angleDifference(rotation, potential.motionChange);
42451 if (Math.abs(motionDifference) > maxRotationDifference) {
42454 var occupiedDifference = Number.MAX_VALUE;
42455 for (var _b = 0, occupiedAngles_1 = occupiedAngles; _b < occupiedAngles_1.length; _b++) {
42456 var occupiedAngle = occupiedAngles_1[_b];
42457 var difference = Math.abs(this._spatial.angleDifference(occupiedAngle, potential.motionChange));
42458 if (difference < occupiedDifference) {
42459 occupiedDifference = difference;
42462 if (occupiedDifference <= maxRotationDifference) {
42465 var score = this._coefficients.panoPreferredDistance *
42466 Math.abs(potential.distance - this._settings.panoPreferredDistance) /
42467 this._settings.panoMaxDistance +
42468 this._coefficients.panoMotion * Math.abs(motionDifference) / maxRotationDifference +
42469 this._coefficients.panoSequencePenalty * (potential.sameSequence ? 0 : 1) +
42470 this._coefficients.panoMergeCCPenalty * (potential.sameMergeCC ? 0 : 1);
42471 if (score < lowestScore) {
42472 lowestScore = score;
42476 if (edge != null) {
42477 occupiedAngles.push(edge.motionChange);
42480 direction: Edge_1.EdgeDirection.Pano,
42481 worldMotionAzimuth: edge.worldMotionAzimuth,
42488 stepAngles.push(rotation);
42491 var occupiedStepAngles = {};
42492 occupiedStepAngles[Edge_1.EdgeDirection.Pano] = occupiedAngles;
42493 occupiedStepAngles[Edge_1.EdgeDirection.StepForward] = [];
42494 occupiedStepAngles[Edge_1.EdgeDirection.StepLeft] = [];
42495 occupiedStepAngles[Edge_1.EdgeDirection.StepBackward] = [];
42496 occupiedStepAngles[Edge_1.EdgeDirection.StepRight] = [];
42497 for (var _c = 0, stepAngles_1 = stepAngles; _c < stepAngles_1.length; _c++) {
42498 var stepAngle = stepAngles_1[_c];
42499 var occupations = [];
42500 for (var k in this._directions.panos) {
42501 if (!this._directions.panos.hasOwnProperty(k)) {
42504 var pano = this._directions.panos[k];
42505 var allOccupiedAngles = occupiedStepAngles[Edge_1.EdgeDirection.Pano]
42506 .concat(occupiedStepAngles[pano.direction])
42507 .concat(occupiedStepAngles[pano.prev])
42508 .concat(occupiedStepAngles[pano.next]);
42509 var lowestScore = Number.MAX_VALUE;
42511 for (var _d = 0, potentialSteps_1 = potentialSteps; _d < potentialSteps_1.length; _d++) {
42512 var potential = potentialSteps_1[_d];
42513 if (potential[0] !== pano.direction) {
42516 var motionChange = this._spatial.angleDifference(stepAngle, potential[1].motionChange);
42517 if (Math.abs(motionChange) > maxRotationDifference) {
42520 var minOccupiedDifference = Number.MAX_VALUE;
42521 for (var _e = 0, allOccupiedAngles_1 = allOccupiedAngles; _e < allOccupiedAngles_1.length; _e++) {
42522 var occupiedAngle = allOccupiedAngles_1[_e];
42523 var occupiedDifference = Math.abs(this._spatial.angleDifference(occupiedAngle, potential[1].motionChange));
42524 if (occupiedDifference < minOccupiedDifference) {
42525 minOccupiedDifference = occupiedDifference;
42528 if (minOccupiedDifference <= maxRotationDifference) {
42531 var score = this._coefficients.panoPreferredDistance *
42532 Math.abs(potential[1].distance - this._settings.panoPreferredDistance) /
42533 this._settings.panoMaxDistance +
42534 this._coefficients.panoMotion * Math.abs(motionChange) / maxRotationDifference +
42535 this._coefficients.panoMergeCCPenalty * (potential[1].sameMergeCC ? 0 : 1);
42536 if (score < lowestScore) {
42537 lowestScore = score;
42541 if (edge != null) {
42542 occupations.push(edge);
42545 direction: edge[0],
42546 worldMotionAzimuth: edge[1].worldMotionAzimuth,
42553 for (var _f = 0, occupations_1 = occupations; _f < occupations_1.length; _f++) {
42554 var occupation = occupations_1[_f];
42555 occupiedStepAngles[occupation[0]].push(occupation[1].motionChange);
42560 return EdgeCalculator;
42562 exports.EdgeCalculator = EdgeCalculator;
42563 exports.default = EdgeCalculator;
42565 },{"../../Edge":276,"../../Error":277,"../../Geo":278,"three":226}],400:[function(require,module,exports){
42567 Object.defineProperty(exports, "__esModule", { value: true });
42568 var EdgeCalculatorCoefficients = /** @class */ (function () {
42569 function EdgeCalculatorCoefficients() {
42570 this.panoPreferredDistance = 2;
42571 this.panoMotion = 2;
42572 this.panoSequencePenalty = 1;
42573 this.panoMergeCCPenalty = 4;
42574 this.stepPreferredDistance = 4;
42575 this.stepMotion = 3;
42576 this.stepRotation = 4;
42577 this.stepSequencePenalty = 2;
42578 this.stepMergeCCPenalty = 6;
42579 this.similarDistance = 2;
42580 this.similarRotation = 3;
42581 this.turnDistance = 4;
42582 this.turnMotion = 2;
42583 this.turnSequencePenalty = 1;
42584 this.turnMergeCCPenalty = 4;
42586 return EdgeCalculatorCoefficients;
42588 exports.EdgeCalculatorCoefficients = EdgeCalculatorCoefficients;
42589 exports.default = EdgeCalculatorCoefficients;
42591 },{}],401:[function(require,module,exports){
42593 Object.defineProperty(exports, "__esModule", { value: true });
42594 var Edge_1 = require("../../Edge");
42595 var EdgeCalculatorDirections = /** @class */ (function () {
42596 function EdgeCalculatorDirections() {
42600 this.steps[Edge_1.EdgeDirection.StepForward] = {
42601 direction: Edge_1.EdgeDirection.StepForward,
42605 this.steps[Edge_1.EdgeDirection.StepBackward] = {
42606 direction: Edge_1.EdgeDirection.StepBackward,
42607 motionChange: Math.PI,
42610 this.steps[Edge_1.EdgeDirection.StepLeft] = {
42611 direction: Edge_1.EdgeDirection.StepLeft,
42612 motionChange: Math.PI / 2,
42613 useFallback: false,
42615 this.steps[Edge_1.EdgeDirection.StepRight] = {
42616 direction: Edge_1.EdgeDirection.StepRight,
42617 motionChange: -Math.PI / 2,
42618 useFallback: false,
42620 this.turns[Edge_1.EdgeDirection.TurnLeft] = {
42621 direction: Edge_1.EdgeDirection.TurnLeft,
42622 directionChange: Math.PI / 2,
42623 motionChange: Math.PI / 4,
42625 this.turns[Edge_1.EdgeDirection.TurnRight] = {
42626 direction: Edge_1.EdgeDirection.TurnRight,
42627 directionChange: -Math.PI / 2,
42628 motionChange: -Math.PI / 4,
42630 this.turns[Edge_1.EdgeDirection.TurnU] = {
42631 direction: Edge_1.EdgeDirection.TurnU,
42632 directionChange: Math.PI,
42633 motionChange: null,
42635 this.panos[Edge_1.EdgeDirection.StepForward] = {
42636 direction: Edge_1.EdgeDirection.StepForward,
42637 directionChange: 0,
42638 next: Edge_1.EdgeDirection.StepLeft,
42639 prev: Edge_1.EdgeDirection.StepRight,
42641 this.panos[Edge_1.EdgeDirection.StepBackward] = {
42642 direction: Edge_1.EdgeDirection.StepBackward,
42643 directionChange: Math.PI,
42644 next: Edge_1.EdgeDirection.StepRight,
42645 prev: Edge_1.EdgeDirection.StepLeft,
42647 this.panos[Edge_1.EdgeDirection.StepLeft] = {
42648 direction: Edge_1.EdgeDirection.StepLeft,
42649 directionChange: Math.PI / 2,
42650 next: Edge_1.EdgeDirection.StepBackward,
42651 prev: Edge_1.EdgeDirection.StepForward,
42653 this.panos[Edge_1.EdgeDirection.StepRight] = {
42654 direction: Edge_1.EdgeDirection.StepRight,
42655 directionChange: -Math.PI / 2,
42656 next: Edge_1.EdgeDirection.StepForward,
42657 prev: Edge_1.EdgeDirection.StepBackward,
42660 return EdgeCalculatorDirections;
42662 exports.EdgeCalculatorDirections = EdgeCalculatorDirections;
42664 },{"../../Edge":276}],402:[function(require,module,exports){
42666 Object.defineProperty(exports, "__esModule", { value: true });
42667 var EdgeCalculatorSettings = /** @class */ (function () {
42668 function EdgeCalculatorSettings() {
42669 this.panoMinDistance = 0.1;
42670 this.panoMaxDistance = 20;
42671 this.panoPreferredDistance = 5;
42672 this.panoMaxItems = 4;
42673 this.panoMaxStepTurnChange = Math.PI / 8;
42674 this.rotationMaxDistance = this.turnMaxRigDistance;
42675 this.rotationMaxDirectionChange = Math.PI / 6;
42676 this.rotationMaxVerticalDirectionChange = Math.PI / 8;
42677 this.similarMaxDirectionChange = Math.PI / 8;
42678 this.similarMaxDistance = 12;
42679 this.similarMinTimeDifference = 12 * 3600 * 1000;
42680 this.stepMaxDistance = 20;
42681 this.stepMaxDirectionChange = Math.PI / 6;
42682 this.stepMaxDrift = Math.PI / 6;
42683 this.stepPreferredDistance = 4;
42684 this.turnMaxDistance = 15;
42685 this.turnMaxDirectionChange = 2 * Math.PI / 9;
42686 this.turnMaxRigDistance = 0.65;
42687 this.turnMinRigDirectionChange = Math.PI / 6;
42689 Object.defineProperty(EdgeCalculatorSettings.prototype, "maxDistance", {
42691 return Math.max(this.panoMaxDistance, this.similarMaxDistance, this.stepMaxDistance, this.turnMaxDistance);
42696 return EdgeCalculatorSettings;
42698 exports.EdgeCalculatorSettings = EdgeCalculatorSettings;
42699 exports.default = EdgeCalculatorSettings;
42701 },{}],403:[function(require,module,exports){
42703 Object.defineProperty(exports, "__esModule", { value: true });
42705 * Enumeration for edge directions
42708 * @description Directions for edges in node graph describing
42709 * sequence, spatial and node type relations between nodes.
42712 (function (EdgeDirection) {
42714 * Next node in the sequence.
42716 EdgeDirection[EdgeDirection["Next"] = 0] = "Next";
42718 * Previous node in the sequence.
42720 EdgeDirection[EdgeDirection["Prev"] = 1] = "Prev";
42722 * Step to the left keeping viewing direction.
42724 EdgeDirection[EdgeDirection["StepLeft"] = 2] = "StepLeft";
42726 * Step to the right keeping viewing direction.
42728 EdgeDirection[EdgeDirection["StepRight"] = 3] = "StepRight";
42730 * Step forward keeping viewing direction.
42732 EdgeDirection[EdgeDirection["StepForward"] = 4] = "StepForward";
42734 * Step backward keeping viewing direction.
42736 EdgeDirection[EdgeDirection["StepBackward"] = 5] = "StepBackward";
42738 * Turn 90 degrees counter clockwise.
42740 EdgeDirection[EdgeDirection["TurnLeft"] = 6] = "TurnLeft";
42742 * Turn 90 degrees clockwise.
42744 EdgeDirection[EdgeDirection["TurnRight"] = 7] = "TurnRight";
42746 * Turn 180 degrees.
42748 EdgeDirection[EdgeDirection["TurnU"] = 8] = "TurnU";
42750 * Panorama in general direction.
42752 EdgeDirection[EdgeDirection["Pano"] = 9] = "Pano";
42754 * Looking in roughly the same direction at rougly the same position.
42756 EdgeDirection[EdgeDirection["Similar"] = 10] = "Similar";
42757 })(EdgeDirection = exports.EdgeDirection || (exports.EdgeDirection = {}));
42759 },{}],404:[function(require,module,exports){
42761 Object.defineProperty(exports, "__esModule", { value: true });
42762 var rxjs_1 = require("rxjs");
42763 var operators_1 = require("rxjs/operators");
42764 var vd = require("virtual-dom");
42765 var rxjs_2 = require("rxjs");
42766 var Render_1 = require("../Render");
42767 var DOMRenderer = /** @class */ (function () {
42768 function DOMRenderer(element, renderService, currentFrame$) {
42769 this._adaptiveOperation$ = new rxjs_2.Subject();
42770 this._render$ = new rxjs_2.Subject();
42771 this._renderAdaptive$ = new rxjs_2.Subject();
42772 this._renderService = renderService;
42773 this._currentFrame$ = currentFrame$;
42774 var rootNode = vd.create(vd.h("div.domRenderer", []));
42775 element.appendChild(rootNode);
42776 this._offset$ = this._adaptiveOperation$.pipe(operators_1.scan(function (adaptive, operation) {
42777 return operation(adaptive);
42779 elementHeight: element.offsetHeight,
42780 elementWidth: element.offsetWidth,
42782 renderMode: Render_1.RenderMode.Fill,
42783 }), operators_1.filter(function (adaptive) {
42784 return adaptive.imageAspect > 0 && adaptive.elementWidth > 0 && adaptive.elementHeight > 0;
42785 }), operators_1.map(function (adaptive) {
42786 var elementAspect = adaptive.elementWidth / adaptive.elementHeight;
42787 var ratio = adaptive.imageAspect / elementAspect;
42788 var verticalOffset = 0;
42789 var horizontalOffset = 0;
42790 if (adaptive.renderMode === Render_1.RenderMode.Letterbox) {
42791 if (adaptive.imageAspect > elementAspect) {
42792 verticalOffset = adaptive.elementHeight * (1 - 1 / ratio) / 2;
42795 horizontalOffset = adaptive.elementWidth * (1 - ratio) / 2;
42799 if (adaptive.imageAspect > elementAspect) {
42800 horizontalOffset = -adaptive.elementWidth * (ratio - 1) / 2;
42803 verticalOffset = -adaptive.elementHeight * (1 / ratio - 1) / 2;
42807 bottom: verticalOffset,
42808 left: horizontalOffset,
42809 right: horizontalOffset,
42810 top: verticalOffset,
42813 this._currentFrame$.pipe(operators_1.filter(function (frame) {
42814 return frame.state.currentNode != null;
42815 }), operators_1.distinctUntilChanged(function (k1, k2) {
42817 }, function (frame) {
42818 return frame.state.currentNode.key;
42819 }), operators_1.map(function (frame) {
42820 return frame.state.currentTransform.basicAspect;
42821 }), operators_1.map(function (aspect) {
42822 return function (adaptive) {
42823 adaptive.imageAspect = aspect;
42827 .subscribe(this._adaptiveOperation$);
42828 rxjs_1.combineLatest(this._renderAdaptive$.pipe(operators_1.scan(function (vNodeHashes, vNodeHash) {
42829 if (vNodeHash.vnode == null) {
42830 delete vNodeHashes[vNodeHash.name];
42833 vNodeHashes[vNodeHash.name] = vNodeHash.vnode;
42835 return vNodeHashes;
42836 }, {})), this._offset$).pipe(operators_1.map(function (vo) {
42838 var hashes = vo[0];
42839 for (var name_1 in hashes) {
42840 if (!hashes.hasOwnProperty(name_1)) {
42843 vNodes.push(hashes[name_1]);
42845 var offset = vo[1];
42848 bottom: offset.bottom + "px",
42849 left: offset.left + "px",
42850 "pointer-events": "none",
42851 position: "absolute",
42852 right: offset.right + "px",
42853 top: offset.top + "px",
42857 name: "adaptiveDomRenderer",
42858 vnode: vd.h("div.adaptiveDomRenderer", properties, vNodes),
42861 .subscribe(this._render$);
42862 this._vNode$ = this._render$.pipe(operators_1.scan(function (vNodeHashes, vNodeHash) {
42863 if (vNodeHash.vnode == null) {
42864 delete vNodeHashes[vNodeHash.name];
42867 vNodeHashes[vNodeHash.name] = vNodeHash.vnode;
42869 return vNodeHashes;
42870 }, {}), operators_1.map(function (hashes) {
42872 for (var name_2 in hashes) {
42873 if (!hashes.hasOwnProperty(name_2)) {
42876 vNodes.push(hashes[name_2]);
42878 return vd.h("div.domRenderer", vNodes);
42880 this._vPatch$ = this._vNode$.pipe(operators_1.scan(function (nodePatch, vNode) {
42881 nodePatch.vpatch = vd.diff(nodePatch.vnode, vNode);
42882 nodePatch.vnode = vNode;
42884 }, { vnode: vd.h("div.domRenderer", []), vpatch: null }), operators_1.pluck("vpatch"));
42885 this._element$ = this._vPatch$.pipe(operators_1.scan(function (oldElement, vPatch) {
42886 return vd.patch(oldElement, vPatch);
42887 }, rootNode), operators_1.publishReplay(1), operators_1.refCount());
42888 this._element$.subscribe(function () { });
42889 this._renderService.size$.pipe(operators_1.map(function (size) {
42890 return function (adaptive) {
42891 adaptive.elementWidth = size.width;
42892 adaptive.elementHeight = size.height;
42896 .subscribe(this._adaptiveOperation$);
42897 this._renderService.renderMode$.pipe(operators_1.map(function (renderMode) {
42898 return function (adaptive) {
42899 adaptive.renderMode = renderMode;
42903 .subscribe(this._adaptiveOperation$);
42905 Object.defineProperty(DOMRenderer.prototype, "element$", {
42907 return this._element$;
42912 Object.defineProperty(DOMRenderer.prototype, "render$", {
42914 return this._render$;
42919 Object.defineProperty(DOMRenderer.prototype, "renderAdaptive$", {
42921 return this._renderAdaptive$;
42926 DOMRenderer.prototype.clear = function (name) {
42927 this._renderAdaptive$.next({ name: name, vnode: null });
42928 this._render$.next({ name: name, vnode: null });
42930 return DOMRenderer;
42932 exports.DOMRenderer = DOMRenderer;
42933 exports.default = DOMRenderer;
42936 },{"../Render":281,"rxjs":27,"rxjs/operators":225,"virtual-dom":231}],405:[function(require,module,exports){
42938 Object.defineProperty(exports, "__esModule", { value: true });
42940 (function (GLRenderStage) {
42941 GLRenderStage[GLRenderStage["Background"] = 0] = "Background";
42942 GLRenderStage[GLRenderStage["Foreground"] = 1] = "Foreground";
42943 })(GLRenderStage = exports.GLRenderStage || (exports.GLRenderStage = {}));
42944 exports.default = GLRenderStage;
42946 },{}],406:[function(require,module,exports){
42948 Object.defineProperty(exports, "__esModule", { value: true });
42949 var rxjs_1 = require("rxjs");
42950 var operators_1 = require("rxjs/operators");
42951 var THREE = require("three");
42952 var Render_1 = require("../Render");
42953 var Utils_1 = require("../Utils");
42954 var GLRenderer = /** @class */ (function () {
42955 function GLRenderer(canvasContainer, renderService, dom) {
42957 this._renderFrame$ = new rxjs_1.Subject();
42958 this._renderCameraOperation$ = new rxjs_1.Subject();
42959 this._render$ = new rxjs_1.Subject();
42960 this._clear$ = new rxjs_1.Subject();
42961 this._renderOperation$ = new rxjs_1.Subject();
42962 this._rendererOperation$ = new rxjs_1.Subject();
42963 this._eraserOperation$ = new rxjs_1.Subject();
42964 this._renderService = renderService;
42965 this._dom = !!dom ? dom : new Utils_1.DOM();
42966 this._renderer$ = this._rendererOperation$.pipe(operators_1.scan(function (renderer, operation) {
42967 return operation(renderer);
42968 }, { needsRender: false, renderer: null }), operators_1.filter(function (renderer) {
42969 return !!renderer.renderer;
42971 this._renderCollection$ = this._renderOperation$.pipe(operators_1.scan(function (hashes, operation) {
42972 return operation(hashes);
42973 }, {}), operators_1.share());
42974 this._renderCamera$ = this._renderCameraOperation$.pipe(operators_1.scan(function (rc, operation) {
42975 return operation(rc);
42976 }, { frameId: -1, needsRender: false, perspective: null }));
42977 this._eraser$ = this._eraserOperation$.pipe(operators_1.startWith(function (eraser) {
42979 }), operators_1.scan(function (eraser, operation) {
42980 return operation(eraser);
42981 }, { needsRender: false }));
42982 rxjs_1.combineLatest(this._renderer$, this._renderCollection$, this._renderCamera$, this._eraser$).pipe(operators_1.map(function (_a) {
42983 var renderer = _a[0], hashes = _a[1], rc = _a[2], eraser = _a[3];
42984 var renders = Object.keys(hashes)
42985 .map(function (key) {
42986 return hashes[key];
42988 return { camera: rc, eraser: eraser, renderer: renderer, renders: renders };
42989 }), operators_1.filter(function (co) {
42990 var needsRender = co.renderer.needsRender ||
42991 co.camera.needsRender ||
42992 co.eraser.needsRender;
42993 var frameId = co.camera.frameId;
42994 for (var _i = 0, _a = co.renders; _i < _a.length; _i++) {
42995 var render = _a[_i];
42996 if (render.frameId !== frameId) {
42999 needsRender = needsRender || render.needsRender;
43001 return needsRender;
43002 }), operators_1.distinctUntilChanged(function (n1, n2) {
43005 return co.eraser.needsRender ? -1 : co.camera.frameId;
43007 .subscribe(function (co) {
43008 co.renderer.needsRender = false;
43009 co.camera.needsRender = false;
43010 co.eraser.needsRender = false;
43011 var perspectiveCamera = co.camera.perspective;
43012 var backgroundRenders = [];
43013 var foregroundRenders = [];
43014 for (var _i = 0, _a = co.renders; _i < _a.length; _i++) {
43015 var render = _a[_i];
43016 if (render.stage === Render_1.GLRenderStage.Background) {
43017 backgroundRenders.push(render.render);
43019 else if (render.stage === Render_1.GLRenderStage.Foreground) {
43020 foregroundRenders.push(render.render);
43023 var renderer = co.renderer.renderer;
43025 for (var _b = 0, backgroundRenders_1 = backgroundRenders; _b < backgroundRenders_1.length; _b++) {
43026 var render = backgroundRenders_1[_b];
43027 render(perspectiveCamera, renderer);
43029 renderer.clearDepth();
43030 for (var _c = 0, foregroundRenders_1 = foregroundRenders; _c < foregroundRenders_1.length; _c++) {
43031 var render = foregroundRenders_1[_c];
43032 render(perspectiveCamera, renderer);
43035 this._renderFrame$.pipe(operators_1.map(function (rc) {
43036 return function (irc) {
43037 irc.frameId = rc.frameId;
43038 irc.perspective = rc.perspective;
43039 if (rc.changed === true) {
43040 irc.needsRender = true;
43045 .subscribe(this._renderCameraOperation$);
43046 this._renderFrameSubscribe();
43047 var renderHash$ = this._render$.pipe(operators_1.map(function (hash) {
43048 return function (hashes) {
43049 hashes[hash.name] = hash.render;
43053 var clearHash$ = this._clear$.pipe(operators_1.map(function (name) {
43054 return function (hashes) {
43055 delete hashes[name];
43059 rxjs_1.merge(renderHash$, clearHash$)
43060 .subscribe(this._renderOperation$);
43061 this._webGLRenderer$ = this._render$.pipe(operators_1.first(), operators_1.map(function (hash) {
43062 var canvas = _this._dom.createElement("canvas", "mapillary-js-canvas");
43063 canvas.style.position = "absolute";
43064 canvas.setAttribute("tabindex", "0");
43065 canvasContainer.appendChild(canvas);
43066 var element = renderService.element;
43067 var webGLRenderer = new THREE.WebGLRenderer({ canvas: canvas });
43068 webGLRenderer.setPixelRatio(window.devicePixelRatio);
43069 webGLRenderer.setSize(element.offsetWidth, element.offsetHeight);
43070 webGLRenderer.setClearColor(new THREE.Color(0x202020), 1.0);
43071 webGLRenderer.autoClear = false;
43072 return webGLRenderer;
43073 }), operators_1.publishReplay(1), operators_1.refCount());
43074 this._webGLRenderer$.subscribe(function () { });
43075 var createRenderer$ = this._webGLRenderer$.pipe(operators_1.first(), operators_1.map(function (webGLRenderer) {
43076 return function (renderer) {
43077 renderer.needsRender = true;
43078 renderer.renderer = webGLRenderer;
43082 var resizeRenderer$ = this._renderService.size$.pipe(operators_1.map(function (size) {
43083 return function (renderer) {
43084 if (renderer.renderer == null) {
43087 renderer.renderer.setSize(size.width, size.height);
43088 renderer.needsRender = true;
43092 var clearRenderer$ = this._clear$.pipe(operators_1.map(function (name) {
43093 return function (renderer) {
43094 if (renderer.renderer == null) {
43097 renderer.needsRender = true;
43101 rxjs_1.merge(createRenderer$, resizeRenderer$, clearRenderer$)
43102 .subscribe(this._rendererOperation$);
43103 var renderCollectionEmpty$ = this._renderCollection$.pipe(operators_1.filter(function (hashes) {
43104 return Object.keys(hashes).length === 0;
43105 }), operators_1.share());
43106 renderCollectionEmpty$
43107 .subscribe(function (hashes) {
43108 if (_this._renderFrameSubscription == null) {
43111 _this._renderFrameSubscription.unsubscribe();
43112 _this._renderFrameSubscription = null;
43113 _this._renderFrameSubscribe();
43115 renderCollectionEmpty$.pipe(operators_1.map(function (hashes) {
43116 return function (eraser) {
43117 eraser.needsRender = true;
43121 .subscribe(this._eraserOperation$);
43123 Object.defineProperty(GLRenderer.prototype, "render$", {
43125 return this._render$;
43130 Object.defineProperty(GLRenderer.prototype, "webGLRenderer$", {
43132 return this._webGLRenderer$;
43137 GLRenderer.prototype.clear = function (name) {
43138 this._clear$.next(name);
43140 GLRenderer.prototype._renderFrameSubscribe = function () {
43142 this._render$.pipe(operators_1.first(), operators_1.map(function (renderHash) {
43143 return function (irc) {
43144 irc.needsRender = true;
43148 .subscribe(function (operation) {
43149 _this._renderCameraOperation$.next(operation);
43151 this._renderFrameSubscription = this._render$.pipe(operators_1.first(), operators_1.mergeMap(function (hash) {
43152 return _this._renderService.renderCameraFrame$;
43154 .subscribe(this._renderFrame$);
43158 exports.GLRenderer = GLRenderer;
43159 exports.default = GLRenderer;
43162 },{"../Render":281,"../Utils":285,"rxjs":27,"rxjs/operators":225,"three":226}],407:[function(require,module,exports){
43164 Object.defineProperty(exports, "__esModule", { value: true });
43165 var THREE = require("three");
43166 var Geo_1 = require("../Geo");
43167 var Render_1 = require("../Render");
43168 var State_1 = require("../State");
43169 var RenderCamera = /** @class */ (function () {
43170 function RenderCamera(elementWidth, elementHeight, renderMode) {
43171 this._spatial = new Geo_1.Spatial();
43172 this._viewportCoords = new Geo_1.ViewportCoords();
43173 this._initialFov = 50;
43175 this._renderMode = renderMode;
43177 this._frameId = -1;
43178 this._changed = false;
43179 this._changedForFrame = -1;
43180 this._currentNodeId = null;
43181 this._previousNodeId = null;
43182 this._currentPano = false;
43183 this._previousPano = false;
43184 this._state = null;
43185 this._currentProjectedPoints = [];
43186 this._previousProjectedPoints = [];
43187 this._currentFov = this._initialFov;
43188 this._previousFov = this._initialFov;
43189 this._camera = new Geo_1.Camera();
43190 this._perspective = new THREE.PerspectiveCamera(this._initialFov, this._computeAspect(elementWidth, elementHeight), 0.16, 10000);
43191 this._perspective.matrixAutoUpdate = false;
43192 this._rotation = { phi: 0, theta: 0 };
43194 Object.defineProperty(RenderCamera.prototype, "alpha", {
43196 return this._alpha;
43201 Object.defineProperty(RenderCamera.prototype, "camera", {
43203 return this._camera;
43208 Object.defineProperty(RenderCamera.prototype, "changed", {
43210 return this._frameId === this._changedForFrame;
43215 Object.defineProperty(RenderCamera.prototype, "frameId", {
43217 return this._frameId;
43222 Object.defineProperty(RenderCamera.prototype, "perspective", {
43224 return this._perspective;
43229 Object.defineProperty(RenderCamera.prototype, "renderMode", {
43231 return this._renderMode;
43236 Object.defineProperty(RenderCamera.prototype, "rotation", {
43238 return this._rotation;
43243 Object.defineProperty(RenderCamera.prototype, "zoom", {
43250 RenderCamera.prototype.setFrame = function (frame) {
43251 var state = frame.state;
43252 if (state.state !== this._state) {
43253 this._state = state.state;
43254 this._changed = true;
43256 var currentNodeId = state.currentNode.key;
43257 var previousNodeId = !!state.previousNode ? state.previousNode.key : null;
43258 if (currentNodeId !== this._currentNodeId) {
43259 this._currentNodeId = currentNodeId;
43260 this._currentPano = !!state.currentTransform.gpano;
43261 this._currentProjectedPoints = this._computeProjectedPoints(state.currentTransform);
43262 this._changed = true;
43264 if (previousNodeId !== this._previousNodeId) {
43265 this._previousNodeId = previousNodeId;
43266 this._previousPano = !!state.previousTransform.gpano;
43267 this._previousProjectedPoints = this._computeProjectedPoints(state.previousTransform);
43268 this._changed = true;
43270 var zoom = state.zoom;
43271 if (zoom !== this._zoom) {
43273 this._changed = true;
43275 if (this._changed) {
43276 this._currentFov = this._computeCurrentFov();
43277 this._previousFov = this._computePreviousFov();
43279 var alpha = state.alpha;
43280 if (this._changed || alpha !== this._alpha) {
43281 this._alpha = alpha;
43282 this._perspective.fov = this._state === State_1.State.Earth ?
43284 this._interpolateFov(this._currentFov, this._previousFov, this._alpha);
43285 this._changed = true;
43287 var camera = state.camera;
43288 if (this._camera.diff(camera) > 1e-9) {
43289 this._camera.copy(camera);
43290 this._rotation = this._computeRotation(camera);
43291 this._perspective.up.copy(camera.up);
43292 this._perspective.position.copy(camera.position);
43293 this._perspective.lookAt(camera.lookat);
43294 this._perspective.updateMatrix();
43295 this._perspective.updateMatrixWorld(false);
43296 this._changed = true;
43298 if (this._changed) {
43299 this._perspective.updateProjectionMatrix();
43301 this._setFrameId(frame.id);
43303 RenderCamera.prototype.setRenderMode = function (renderMode) {
43304 this._renderMode = renderMode;
43305 this._perspective.fov = this._computeFov();
43306 this._perspective.updateProjectionMatrix();
43307 this._changed = true;
43309 RenderCamera.prototype.setSize = function (size) {
43310 this._perspective.aspect = this._computeAspect(size.width, size.height);
43311 this._perspective.fov = this._computeFov();
43312 this._perspective.updateProjectionMatrix();
43313 this._changed = true;
43315 RenderCamera.prototype._computeAspect = function (elementWidth, elementHeight) {
43316 return elementWidth === 0 ? 0 : elementWidth / elementHeight;
43318 RenderCamera.prototype._computeCurrentFov = function () {
43319 if (!this._currentNodeId) {
43320 return this._initialFov;
43322 return this._currentPano ?
43323 this._yToFov(1, this._zoom) :
43324 this._computeVerticalFov(this._currentProjectedPoints, this._renderMode, this._zoom, this.perspective.aspect);
43326 RenderCamera.prototype._computeFov = function () {
43327 this._currentFov = this._computeCurrentFov();
43328 this._previousFov = this._computePreviousFov();
43329 return this._interpolateFov(this._currentFov, this._previousFov, this._alpha);
43331 RenderCamera.prototype._computePreviousFov = function () {
43332 if (!this._currentNodeId) {
43333 return this._initialFov;
43335 return !this._previousNodeId ?
43337 this._previousPano ?
43338 this._yToFov(1, this._zoom) :
43339 this._computeVerticalFov(this._previousProjectedPoints, this._renderMode, this._zoom, this.perspective.aspect);
43341 RenderCamera.prototype._computeProjectedPoints = function (transform) {
43343 var os = [[0.5, 0], [1, 0]];
43344 var ds = [[0.5, 0], [0, 0.5]];
43345 var pointsPerSide = 100;
43346 var basicPoints = [];
43347 for (var side = 0; side < os.length; ++side) {
43350 for (var i = 0; i <= pointsPerSide; ++i) {
43351 basicPoints.push([o[0] + d[0] * i / pointsPerSide,
43352 o[1] + d[1] * i / pointsPerSide]);
43355 var camera = new THREE.Camera();
43356 camera.up.copy(transform.upVector());
43357 camera.position.copy(new THREE.Vector3().fromArray(transform.unprojectSfM([0, 0], 0)));
43358 camera.lookAt(new THREE.Vector3().fromArray(transform.unprojectSfM([0, 0], 10)));
43359 camera.updateMatrix();
43360 camera.updateMatrixWorld(true);
43361 var projectedPoints = basicPoints
43362 .map(function (basicPoint) {
43363 var worldPoint = transform.unprojectBasic(basicPoint, 10000);
43364 var cameraPoint = _this._viewportCoords.worldToCamera(worldPoint, camera);
43366 Math.abs(cameraPoint[0] / cameraPoint[2]),
43367 Math.abs(cameraPoint[1] / cameraPoint[2]),
43370 return projectedPoints;
43372 RenderCamera.prototype._computeRequiredVerticalFov = function (projectedPoint, zoom, aspect) {
43373 var maxY = Math.max(projectedPoint[0] / aspect, projectedPoint[1]);
43374 return this._yToFov(maxY, zoom);
43376 RenderCamera.prototype._computeRotation = function (camera) {
43377 var direction = camera.lookat.clone().sub(camera.position);
43378 var up = camera.up.clone();
43379 var upProjection = direction.clone().dot(up);
43380 var planeProjection = direction.clone().sub(up.clone().multiplyScalar(upProjection));
43381 var phi = Math.atan2(planeProjection.y, planeProjection.x);
43382 var theta = Math.PI / 2 - this._spatial.angleToPlane(direction.toArray(), [0, 0, 1]);
43383 return { phi: phi, theta: theta };
43385 RenderCamera.prototype._computeVerticalFov = function (projectedPoints, renderMode, zoom, aspect) {
43387 var fovs = projectedPoints
43388 .map(function (projectedPoint) {
43389 return _this._computeRequiredVerticalFov(projectedPoint, zoom, aspect);
43391 var fov = renderMode === Render_1.RenderMode.Fill ?
43392 Math.min.apply(Math, fovs) * 0.995 : Math.max.apply(Math, fovs);
43395 RenderCamera.prototype._yToFov = function (y, zoom) {
43396 return 2 * Math.atan(y / Math.pow(2, zoom)) * 180 / Math.PI;
43398 RenderCamera.prototype._interpolateFov = function (v1, v2, alpha) {
43399 return alpha * v1 + (1 - alpha) * v2;
43401 RenderCamera.prototype._setFrameId = function (frameId) {
43402 this._frameId = frameId;
43403 if (this._changed) {
43404 this._changed = false;
43405 this._changedForFrame = frameId;
43408 return RenderCamera;
43410 exports.RenderCamera = RenderCamera;
43411 exports.default = RenderCamera;
43413 },{"../Geo":278,"../Render":281,"../State":282,"three":226}],408:[function(require,module,exports){
43415 Object.defineProperty(exports, "__esModule", { value: true });
43417 * Enumeration for render mode
43420 * @description Modes for specifying how rendering is done
43421 * in the viewer. All modes preserves the original aspect
43422 * ratio of the images.
43425 (function (RenderMode) {
43427 * Displays all content within the viewer.
43429 * @description Black bars shown on both
43430 * sides of the content. Bars are shown
43431 * either below and above or to the left
43432 * and right of the content depending on
43433 * the aspect ratio relation between the
43434 * image and the viewer.
43436 RenderMode[RenderMode["Letterbox"] = 0] = "Letterbox";
43438 * Fills the viewer by cropping content.
43440 * @description Cropping is done either
43441 * in horizontal or vertical direction
43442 * depending on the aspect ratio relation
43443 * between the image and the viewer.
43445 RenderMode[RenderMode["Fill"] = 1] = "Fill";
43446 })(RenderMode = exports.RenderMode || (exports.RenderMode = {}));
43447 exports.default = RenderMode;
43449 },{}],409:[function(require,module,exports){
43451 Object.defineProperty(exports, "__esModule", { value: true });
43452 var operators_1 = require("rxjs/operators");
43453 var rxjs_1 = require("rxjs");
43454 var Geo_1 = require("../Geo");
43455 var Render_1 = require("../Render");
43456 var RenderService = /** @class */ (function () {
43457 function RenderService(element, currentFrame$, renderMode, renderCamera) {
43459 this._element = element;
43460 this._currentFrame$ = currentFrame$;
43461 this._spatial = new Geo_1.Spatial();
43462 renderMode = renderMode != null ? renderMode : Render_1.RenderMode.Fill;
43463 this._resize$ = new rxjs_1.Subject();
43464 this._renderCameraOperation$ = new rxjs_1.Subject();
43466 new rxjs_1.BehaviorSubject({
43467 height: this._element.offsetHeight,
43468 width: this._element.offsetWidth,
43470 this._resize$.pipe(operators_1.map(function () {
43471 return { height: _this._element.offsetHeight, width: _this._element.offsetWidth };
43473 .subscribe(this._size$);
43474 this._renderMode$ = new rxjs_1.BehaviorSubject(renderMode);
43475 this._renderCameraHolder$ = this._renderCameraOperation$.pipe(operators_1.startWith(function (rc) {
43477 }), operators_1.scan(function (rc, operation) {
43478 return operation(rc);
43479 }, !!renderCamera ? renderCamera : new Render_1.RenderCamera(this._element.offsetWidth, this._element.offsetHeight, renderMode)), operators_1.publishReplay(1), operators_1.refCount());
43480 this._renderCameraFrame$ = this._currentFrame$.pipe(operators_1.withLatestFrom(this._renderCameraHolder$), operators_1.tap(function (_a) {
43481 var frame = _a[0], rc = _a[1];
43482 rc.setFrame(frame);
43483 }), operators_1.map(function (args) {
43485 }), operators_1.publishReplay(1), operators_1.refCount());
43486 this._renderCamera$ = this._renderCameraFrame$.pipe(operators_1.filter(function (rc) {
43488 }), operators_1.publishReplay(1), operators_1.refCount());
43489 this._bearing$ = this._renderCamera$.pipe(operators_1.map(function (rc) {
43490 var bearing = _this._spatial.radToDeg(_this._spatial.azimuthalToBearing(rc.rotation.phi));
43491 return _this._spatial.wrap(bearing, 0, 360);
43492 }), operators_1.publishReplay(1), operators_1.refCount());
43493 this._size$.pipe(operators_1.skip(1), operators_1.map(function (size) {
43494 return function (rc) {
43499 .subscribe(this._renderCameraOperation$);
43500 this._renderMode$.pipe(operators_1.skip(1), operators_1.map(function (rm) {
43501 return function (rc) {
43502 rc.setRenderMode(rm);
43506 .subscribe(this._renderCameraOperation$);
43507 this._bearing$.subscribe(function () { });
43508 this._renderCameraHolder$.subscribe(function () { });
43509 this._size$.subscribe(function () { });
43510 this._renderMode$.subscribe(function () { });
43511 this._renderCamera$.subscribe(function () { });
43512 this._renderCameraFrame$.subscribe(function () { });
43514 Object.defineProperty(RenderService.prototype, "bearing$", {
43516 return this._bearing$;
43521 Object.defineProperty(RenderService.prototype, "element", {
43523 return this._element;
43528 Object.defineProperty(RenderService.prototype, "resize$", {
43530 return this._resize$;
43535 Object.defineProperty(RenderService.prototype, "size$", {
43537 return this._size$;
43542 Object.defineProperty(RenderService.prototype, "renderMode$", {
43544 return this._renderMode$;
43549 Object.defineProperty(RenderService.prototype, "renderCameraFrame$", {
43551 return this._renderCameraFrame$;
43556 Object.defineProperty(RenderService.prototype, "renderCamera$", {
43558 return this._renderCamera$;
43563 return RenderService;
43565 exports.RenderService = RenderService;
43566 exports.default = RenderService;
43569 },{"../Geo":278,"../Render":281,"rxjs":27,"rxjs/operators":225}],410:[function(require,module,exports){
43571 Object.defineProperty(exports, "__esModule", { value: true });
43572 var FrameGenerator = /** @class */ (function () {
43573 function FrameGenerator(root) {
43574 if (root.requestAnimationFrame) {
43575 this._cancelAnimationFrame = root.cancelAnimationFrame.bind(root);
43576 this._requestAnimationFrame = root.requestAnimationFrame.bind(root);
43578 else if (root.mozRequestAnimationFrame) {
43579 this._cancelAnimationFrame = root.mozCancelAnimationFrame.bind(root);
43580 this._requestAnimationFrame = root.mozRequestAnimationFrame.bind(root);
43582 else if (root.webkitRequestAnimationFrame) {
43583 this._cancelAnimationFrame = root.webkitCancelAnimationFrame.bind(root);
43584 this._requestAnimationFrame = root.webkitRequestAnimationFrame.bind(root);
43586 else if (root.msRequestAnimationFrame) {
43587 this._cancelAnimationFrame = root.msCancelAnimationFrame.bind(root);
43588 this._requestAnimationFrame = root.msRequestAnimationFrame.bind(root);
43590 else if (root.oRequestAnimationFrame) {
43591 this._cancelAnimationFrame = root.oCancelAnimationFrame.bind(root);
43592 this._requestAnimationFrame = root.oRequestAnimationFrame.bind(root);
43595 this._cancelAnimationFrame = root.clearTimeout.bind(root);
43596 this._requestAnimationFrame = function (cb) { return root.setTimeout(cb, 1000 / 60); };
43599 Object.defineProperty(FrameGenerator.prototype, "cancelAnimationFrame", {
43601 return this._cancelAnimationFrame;
43606 Object.defineProperty(FrameGenerator.prototype, "requestAnimationFrame", {
43608 return this._requestAnimationFrame;
43613 return FrameGenerator;
43615 exports.FrameGenerator = FrameGenerator;
43616 exports.default = FrameGenerator;
43618 },{}],411:[function(require,module,exports){
43620 Object.defineProperty(exports, "__esModule", { value: true });
43621 var RotationDelta = /** @class */ (function () {
43622 function RotationDelta(phi, theta) {
43624 this._theta = theta;
43626 Object.defineProperty(RotationDelta.prototype, "phi", {
43630 set: function (value) {
43636 Object.defineProperty(RotationDelta.prototype, "theta", {
43638 return this._theta;
43640 set: function (value) {
43641 this._theta = value;
43646 Object.defineProperty(RotationDelta.prototype, "isZero", {
43648 return this._phi === 0 && this._theta === 0;
43653 RotationDelta.prototype.copy = function (delta) {
43654 this._phi = delta.phi;
43655 this._theta = delta.theta;
43657 RotationDelta.prototype.lerp = function (other, alpha) {
43658 this._phi = (1 - alpha) * this._phi + alpha * other.phi;
43659 this._theta = (1 - alpha) * this._theta + alpha * other.theta;
43661 RotationDelta.prototype.multiply = function (value) {
43662 this._phi *= value;
43663 this._theta *= value;
43665 RotationDelta.prototype.threshold = function (value) {
43666 this._phi = Math.abs(this._phi) > value ? this._phi : 0;
43667 this._theta = Math.abs(this._theta) > value ? this._theta : 0;
43669 RotationDelta.prototype.lengthSquared = function () {
43670 return this._phi * this._phi + this._theta * this._theta;
43672 RotationDelta.prototype.reset = function () {
43676 return RotationDelta;
43678 exports.RotationDelta = RotationDelta;
43679 exports.default = RotationDelta;
43681 },{}],412:[function(require,module,exports){
43683 Object.defineProperty(exports, "__esModule", { value: true });
43685 (function (State) {
43686 State[State["Earth"] = 0] = "Earth";
43687 State[State["Traversing"] = 1] = "Traversing";
43688 State[State["Waiting"] = 2] = "Waiting";
43689 State[State["WaitingInteractively"] = 3] = "WaitingInteractively";
43690 })(State = exports.State || (exports.State = {}));
43691 exports.default = State;
43693 },{}],413:[function(require,module,exports){
43695 Object.defineProperty(exports, "__esModule", { value: true });
43696 var State_1 = require("../State");
43697 var Geo_1 = require("../Geo");
43698 var StateContext = /** @class */ (function () {
43699 function StateContext(transitionMode) {
43700 this._state = new State_1.TraversingState({
43702 camera: new Geo_1.Camera(),
43704 reference: { alt: 0, lat: 0, lon: 0 },
43706 transitionMode: transitionMode == null ? State_1.TransitionMode.Default : transitionMode,
43710 StateContext.prototype.earth = function () {
43711 this._state = this._state.earth();
43713 StateContext.prototype.traverse = function () {
43714 this._state = this._state.traverse();
43716 StateContext.prototype.wait = function () {
43717 this._state = this._state.wait();
43719 StateContext.prototype.waitInteractively = function () {
43720 this._state = this._state.waitInteractively();
43722 Object.defineProperty(StateContext.prototype, "state", {
43724 if (this._state instanceof State_1.EarthState) {
43725 return State_1.State.Earth;
43727 else if (this._state instanceof State_1.TraversingState) {
43728 return State_1.State.Traversing;
43730 else if (this._state instanceof State_1.WaitingState) {
43731 return State_1.State.Waiting;
43733 else if (this._state instanceof State_1.InteractiveWaitingState) {
43734 return State_1.State.WaitingInteractively;
43736 throw new Error("Invalid state");
43741 Object.defineProperty(StateContext.prototype, "reference", {
43743 return this._state.reference;
43748 Object.defineProperty(StateContext.prototype, "alpha", {
43750 return this._state.alpha;
43755 Object.defineProperty(StateContext.prototype, "camera", {
43757 return this._state.camera;
43762 Object.defineProperty(StateContext.prototype, "zoom", {
43764 return this._state.zoom;
43769 Object.defineProperty(StateContext.prototype, "currentNode", {
43771 return this._state.currentNode;
43776 Object.defineProperty(StateContext.prototype, "previousNode", {
43778 return this._state.previousNode;
43783 Object.defineProperty(StateContext.prototype, "currentCamera", {
43785 return this._state.currentCamera;
43790 Object.defineProperty(StateContext.prototype, "currentTransform", {
43792 return this._state.currentTransform;
43797 Object.defineProperty(StateContext.prototype, "previousTransform", {
43799 return this._state.previousTransform;
43804 Object.defineProperty(StateContext.prototype, "trajectory", {
43806 return this._state.trajectory;
43811 Object.defineProperty(StateContext.prototype, "currentIndex", {
43813 return this._state.currentIndex;
43818 Object.defineProperty(StateContext.prototype, "lastNode", {
43820 return this._state.trajectory[this._state.trajectory.length - 1];
43825 Object.defineProperty(StateContext.prototype, "nodesAhead", {
43827 return this._state.trajectory.length - 1 - this._state.currentIndex;
43832 Object.defineProperty(StateContext.prototype, "motionless", {
43834 return this._state.motionless;
43839 StateContext.prototype.getCenter = function () {
43840 return this._state.getCenter();
43842 StateContext.prototype.setCenter = function (center) {
43843 this._state.setCenter(center);
43845 StateContext.prototype.setZoom = function (zoom) {
43846 this._state.setZoom(zoom);
43848 StateContext.prototype.update = function (fps) {
43849 this._state.update(fps);
43851 StateContext.prototype.append = function (nodes) {
43852 this._state.append(nodes);
43854 StateContext.prototype.prepend = function (nodes) {
43855 this._state.prepend(nodes);
43857 StateContext.prototype.remove = function (n) {
43858 this._state.remove(n);
43860 StateContext.prototype.clear = function () {
43861 this._state.clear();
43863 StateContext.prototype.clearPrior = function () {
43864 this._state.clearPrior();
43866 StateContext.prototype.cut = function () {
43869 StateContext.prototype.set = function (nodes) {
43870 this._state.set(nodes);
43872 StateContext.prototype.rotate = function (delta) {
43873 this._state.rotate(delta);
43875 StateContext.prototype.rotateUnbounded = function (delta) {
43876 this._state.rotateUnbounded(delta);
43878 StateContext.prototype.rotateWithoutInertia = function (delta) {
43879 this._state.rotateWithoutInertia(delta);
43881 StateContext.prototype.rotateBasic = function (basicRotation) {
43882 this._state.rotateBasic(basicRotation);
43884 StateContext.prototype.rotateBasicUnbounded = function (basicRotation) {
43885 this._state.rotateBasicUnbounded(basicRotation);
43887 StateContext.prototype.rotateBasicWithoutInertia = function (basicRotation) {
43888 this._state.rotateBasicWithoutInertia(basicRotation);
43890 StateContext.prototype.rotateToBasic = function (basic) {
43891 this._state.rotateToBasic(basic);
43893 StateContext.prototype.move = function (delta) {
43894 this._state.move(delta);
43896 StateContext.prototype.moveTo = function (delta) {
43897 this._state.moveTo(delta);
43899 StateContext.prototype.zoomIn = function (delta, reference) {
43900 this._state.zoomIn(delta, reference);
43902 StateContext.prototype.setSpeed = function (speed) {
43903 this._state.setSpeed(speed);
43905 StateContext.prototype.setTransitionMode = function (mode) {
43906 this._state.setTransitionMode(mode);
43908 StateContext.prototype.dolly = function (delta) {
43909 this._state.dolly(delta);
43911 StateContext.prototype.orbit = function (rotation) {
43912 this._state.orbit(rotation);
43914 StateContext.prototype.truck = function (direction) {
43915 this._state.truck(direction);
43917 return StateContext;
43919 exports.StateContext = StateContext;
43921 },{"../Geo":278,"../State":282}],414:[function(require,module,exports){
43923 Object.defineProperty(exports, "__esModule", { value: true });
43924 var rxjs_1 = require("rxjs");
43925 var operators_1 = require("rxjs/operators");
43926 var State_1 = require("../State");
43927 var StateService = /** @class */ (function () {
43928 function StateService(transitionMode) {
43930 this._appendNode$ = new rxjs_1.Subject();
43931 this._start$ = new rxjs_1.Subject();
43932 this._frame$ = new rxjs_1.Subject();
43933 this._fpsSampleRate = 30;
43934 this._contextOperation$ = new rxjs_1.BehaviorSubject(function (context) {
43937 this._context$ = this._contextOperation$.pipe(operators_1.scan(function (context, operation) {
43938 return operation(context);
43939 }, new State_1.StateContext(transitionMode)), operators_1.publishReplay(1), operators_1.refCount());
43940 this._state$ = this._context$.pipe(operators_1.map(function (context) {
43941 return context.state;
43942 }), operators_1.distinctUntilChanged(), operators_1.publishReplay(1), operators_1.refCount());
43943 this._fps$ = this._start$.pipe(operators_1.switchMap(function () {
43944 return _this._frame$.pipe(operators_1.bufferCount(1, _this._fpsSampleRate), operators_1.map(function (frameIds) {
43945 return new Date().getTime();
43946 }), operators_1.pairwise(), operators_1.map(function (times) {
43947 return Math.max(20, 1000 * _this._fpsSampleRate / (times[1] - times[0]));
43948 }), operators_1.startWith(60));
43949 }), operators_1.share());
43950 this._currentState$ = this._frame$.pipe(operators_1.withLatestFrom(this._fps$, this._context$, function (frameId, fps, context) {
43951 return [frameId, fps, context];
43952 }), operators_1.filter(function (fc) {
43953 return fc[2].currentNode != null;
43954 }), operators_1.tap(function (fc) {
43955 fc[2].update(fc[1]);
43956 }), operators_1.map(function (fc) {
43957 return { fps: fc[1], id: fc[0], state: fc[2] };
43958 }), operators_1.share());
43959 this._lastState$ = this._currentState$.pipe(operators_1.publishReplay(1), operators_1.refCount());
43960 var nodeChanged$ = this._currentState$.pipe(operators_1.distinctUntilChanged(undefined, function (f) {
43961 return f.state.currentNode.key;
43962 }), operators_1.publishReplay(1), operators_1.refCount());
43963 var nodeChangedSubject$ = new rxjs_1.Subject();
43965 .subscribe(nodeChangedSubject$);
43966 this._currentKey$ = new rxjs_1.BehaviorSubject(null);
43967 nodeChangedSubject$.pipe(operators_1.map(function (f) {
43968 return f.state.currentNode.key;
43970 .subscribe(this._currentKey$);
43971 this._currentNode$ = nodeChangedSubject$.pipe(operators_1.map(function (f) {
43972 return f.state.currentNode;
43973 }), operators_1.publishReplay(1), operators_1.refCount());
43974 this._currentCamera$ = nodeChangedSubject$.pipe(operators_1.map(function (f) {
43975 return f.state.currentCamera;
43976 }), operators_1.publishReplay(1), operators_1.refCount());
43977 this._currentTransform$ = nodeChangedSubject$.pipe(operators_1.map(function (f) {
43978 return f.state.currentTransform;
43979 }), operators_1.publishReplay(1), operators_1.refCount());
43980 this._reference$ = nodeChangedSubject$.pipe(operators_1.map(function (f) {
43981 return f.state.reference;
43982 }), operators_1.distinctUntilChanged(function (r1, r2) {
43983 return r1.lat === r2.lat && r1.lon === r2.lon;
43984 }, function (reference) {
43985 return { lat: reference.lat, lon: reference.lon };
43986 }), operators_1.publishReplay(1), operators_1.refCount());
43987 this._currentNodeExternal$ = nodeChanged$.pipe(operators_1.map(function (f) {
43988 return f.state.currentNode;
43989 }), operators_1.publishReplay(1), operators_1.refCount());
43990 this._appendNode$.pipe(operators_1.map(function (node) {
43991 return function (context) {
43992 context.append([node]);
43996 .subscribe(this._contextOperation$);
43997 this._inMotionOperation$ = new rxjs_1.Subject();
43998 nodeChanged$.pipe(operators_1.map(function (frame) {
44001 .subscribe(this._inMotionOperation$);
44002 this._inMotionOperation$.pipe(operators_1.distinctUntilChanged(), operators_1.filter(function (moving) {
44004 }), operators_1.switchMap(function (moving) {
44005 return _this._currentState$.pipe(operators_1.filter(function (frame) {
44006 return frame.state.nodesAhead === 0;
44007 }), operators_1.map(function (frame) {
44008 return [frame.state.camera.clone(), frame.state.zoom];
44009 }), operators_1.pairwise(), operators_1.map(function (pair) {
44010 var c1 = pair[0][0];
44011 var c2 = pair[1][0];
44012 var z1 = pair[0][1];
44013 var z2 = pair[1][1];
44014 return c1.diff(c2) > 1e-5 || Math.abs(z1 - z2) > 1e-5;
44015 }), operators_1.first(function (changed) {
44019 .subscribe(this._inMotionOperation$);
44020 this._inMotion$ = this._inMotionOperation$.pipe(operators_1.distinctUntilChanged(), operators_1.publishReplay(1), operators_1.refCount());
44021 this._inTranslationOperation$ = new rxjs_1.Subject();
44022 nodeChanged$.pipe(operators_1.map(function (frame) {
44025 .subscribe(this._inTranslationOperation$);
44026 this._inTranslationOperation$.pipe(operators_1.distinctUntilChanged(), operators_1.filter(function (inTranslation) {
44027 return inTranslation;
44028 }), operators_1.switchMap(function (inTranslation) {
44029 return _this._currentState$.pipe(operators_1.filter(function (frame) {
44030 return frame.state.nodesAhead === 0;
44031 }), operators_1.map(function (frame) {
44032 return frame.state.camera.position.clone();
44033 }), operators_1.pairwise(), operators_1.map(function (pair) {
44034 return pair[0].distanceToSquared(pair[1]) !== 0;
44035 }), operators_1.first(function (changed) {
44039 .subscribe(this._inTranslationOperation$);
44040 this._inTranslation$ = this._inTranslationOperation$.pipe(operators_1.distinctUntilChanged(), operators_1.publishReplay(1), operators_1.refCount());
44041 this._state$.subscribe(function () { });
44042 this._currentNode$.subscribe(function () { });
44043 this._currentCamera$.subscribe(function () { });
44044 this._currentTransform$.subscribe(function () { });
44045 this._reference$.subscribe(function () { });
44046 this._currentNodeExternal$.subscribe(function () { });
44047 this._lastState$.subscribe(function () { });
44048 this._inMotion$.subscribe(function () { });
44049 this._inTranslation$.subscribe(function () { });
44050 this._frameId = null;
44051 this._frameGenerator = new State_1.FrameGenerator(window);
44053 Object.defineProperty(StateService.prototype, "currentState$", {
44055 return this._currentState$;
44060 Object.defineProperty(StateService.prototype, "currentNode$", {
44062 return this._currentNode$;
44067 Object.defineProperty(StateService.prototype, "currentKey$", {
44069 return this._currentKey$;
44074 Object.defineProperty(StateService.prototype, "currentNodeExternal$", {
44076 return this._currentNodeExternal$;
44081 Object.defineProperty(StateService.prototype, "currentCamera$", {
44083 return this._currentCamera$;
44088 Object.defineProperty(StateService.prototype, "currentTransform$", {
44090 return this._currentTransform$;
44095 Object.defineProperty(StateService.prototype, "state$", {
44097 return this._state$;
44102 Object.defineProperty(StateService.prototype, "reference$", {
44104 return this._reference$;
44109 Object.defineProperty(StateService.prototype, "inMotion$", {
44111 return this._inMotion$;
44116 Object.defineProperty(StateService.prototype, "inTranslation$", {
44118 return this._inTranslation$;
44123 Object.defineProperty(StateService.prototype, "appendNode$", {
44125 return this._appendNode$;
44130 StateService.prototype.earth = function () {
44131 this._inMotionOperation$.next(true);
44132 this._invokeContextOperation(function (context) { context.earth(); });
44134 StateService.prototype.traverse = function () {
44135 this._inMotionOperation$.next(true);
44136 this._invokeContextOperation(function (context) { context.traverse(); });
44138 StateService.prototype.wait = function () {
44139 this._invokeContextOperation(function (context) { context.wait(); });
44141 StateService.prototype.waitInteractively = function () {
44142 this._invokeContextOperation(function (context) { context.waitInteractively(); });
44144 StateService.prototype.appendNodes = function (nodes) {
44145 this._invokeContextOperation(function (context) { context.append(nodes); });
44147 StateService.prototype.prependNodes = function (nodes) {
44148 this._invokeContextOperation(function (context) { context.prepend(nodes); });
44150 StateService.prototype.removeNodes = function (n) {
44151 this._invokeContextOperation(function (context) { context.remove(n); });
44153 StateService.prototype.clearNodes = function () {
44154 this._invokeContextOperation(function (context) { context.clear(); });
44156 StateService.prototype.clearPriorNodes = function () {
44157 this._invokeContextOperation(function (context) { context.clearPrior(); });
44159 StateService.prototype.cutNodes = function () {
44160 this._invokeContextOperation(function (context) { context.cut(); });
44162 StateService.prototype.setNodes = function (nodes) {
44163 this._invokeContextOperation(function (context) { context.set(nodes); });
44165 StateService.prototype.rotate = function (delta) {
44166 this._inMotionOperation$.next(true);
44167 this._invokeContextOperation(function (context) { context.rotate(delta); });
44169 StateService.prototype.rotateUnbounded = function (delta) {
44170 this._inMotionOperation$.next(true);
44171 this._invokeContextOperation(function (context) { context.rotateUnbounded(delta); });
44173 StateService.prototype.rotateWithoutInertia = function (delta) {
44174 this._inMotionOperation$.next(true);
44175 this._invokeContextOperation(function (context) { context.rotateWithoutInertia(delta); });
44177 StateService.prototype.rotateBasic = function (basicRotation) {
44178 this._inMotionOperation$.next(true);
44179 this._invokeContextOperation(function (context) { context.rotateBasic(basicRotation); });
44181 StateService.prototype.rotateBasicUnbounded = function (basicRotation) {
44182 this._inMotionOperation$.next(true);
44183 this._invokeContextOperation(function (context) { context.rotateBasicUnbounded(basicRotation); });
44185 StateService.prototype.rotateBasicWithoutInertia = function (basicRotation) {
44186 this._inMotionOperation$.next(true);
44187 this._invokeContextOperation(function (context) { context.rotateBasicWithoutInertia(basicRotation); });
44189 StateService.prototype.rotateToBasic = function (basic) {
44190 this._inMotionOperation$.next(true);
44191 this._invokeContextOperation(function (context) { context.rotateToBasic(basic); });
44193 StateService.prototype.move = function (delta) {
44194 this._inMotionOperation$.next(true);
44195 this._invokeContextOperation(function (context) { context.move(delta); });
44197 StateService.prototype.moveTo = function (position) {
44198 this._inMotionOperation$.next(true);
44199 this._invokeContextOperation(function (context) { context.moveTo(position); });
44201 StateService.prototype.dolly = function (delta) {
44202 this._inMotionOperation$.next(true);
44203 this._invokeContextOperation(function (context) { context.dolly(delta); });
44205 StateService.prototype.orbit = function (rotation) {
44206 this._inMotionOperation$.next(true);
44207 this._invokeContextOperation(function (context) { context.orbit(rotation); });
44209 StateService.prototype.truck = function (direction) {
44210 this._inMotionOperation$.next(true);
44211 this._invokeContextOperation(function (context) { context.truck(direction); });
44214 * Change zoom level while keeping the reference point position approximately static.
44216 * @parameter {number} delta - Change in zoom level.
44217 * @parameter {Array<number>} reference - Reference point in basic coordinates.
44219 StateService.prototype.zoomIn = function (delta, reference) {
44220 this._inMotionOperation$.next(true);
44221 this._invokeContextOperation(function (context) { context.zoomIn(delta, reference); });
44223 StateService.prototype.getCenter = function () {
44224 return this._lastState$.pipe(operators_1.first(), operators_1.map(function (frame) {
44225 return frame.state.getCenter();
44228 StateService.prototype.getZoom = function () {
44229 return this._lastState$.pipe(operators_1.first(), operators_1.map(function (frame) {
44230 return frame.state.zoom;
44233 StateService.prototype.setCenter = function (center) {
44234 this._inMotionOperation$.next(true);
44235 this._invokeContextOperation(function (context) { context.setCenter(center); });
44237 StateService.prototype.setSpeed = function (speed) {
44238 this._invokeContextOperation(function (context) { context.setSpeed(speed); });
44240 StateService.prototype.setTransitionMode = function (mode) {
44241 this._invokeContextOperation(function (context) { context.setTransitionMode(mode); });
44243 StateService.prototype.setZoom = function (zoom) {
44244 this._inMotionOperation$.next(true);
44245 this._invokeContextOperation(function (context) { context.setZoom(zoom); });
44247 StateService.prototype.start = function () {
44248 if (this._frameId == null) {
44249 this._start$.next(null);
44250 this._frameId = this._frameGenerator.requestAnimationFrame(this._frame.bind(this));
44251 this._frame$.next(this._frameId);
44254 StateService.prototype.stop = function () {
44255 if (this._frameId != null) {
44256 this._frameGenerator.cancelAnimationFrame(this._frameId);
44257 this._frameId = null;
44260 StateService.prototype._invokeContextOperation = function (action) {
44261 this._contextOperation$
44262 .next(function (context) {
44267 StateService.prototype._frame = function (time) {
44268 this._frameId = this._frameGenerator.requestAnimationFrame(this._frame.bind(this));
44269 this._frame$.next(this._frameId);
44271 return StateService;
44273 exports.StateService = StateService;
44275 },{"../State":282,"rxjs":27,"rxjs/operators":225}],415:[function(require,module,exports){
44277 Object.defineProperty(exports, "__esModule", { value: true });
44279 * Enumeration for transition mode
44282 * @description Modes for specifying how transitions
44283 * between nodes are performed.
44285 var TransitionMode;
44286 (function (TransitionMode) {
44288 * Default transitions.
44290 * @description The viewer dynamically determines
44291 * whether transitions should be performed with or
44292 * without motion and blending for each transition
44293 * based on the underlying data.
44295 TransitionMode[TransitionMode["Default"] = 0] = "Default";
44297 * Instantaneous transitions.
44299 * @description All transitions are performed
44300 * without motion or blending.
44302 TransitionMode[TransitionMode["Instantaneous"] = 1] = "Instantaneous";
44303 })(TransitionMode = exports.TransitionMode || (exports.TransitionMode = {}));
44304 exports.default = TransitionMode;
44306 },{}],416:[function(require,module,exports){
44308 var __extends = (this && this.__extends) || (function () {
44309 var extendStatics = function (d, b) {
44310 extendStatics = Object.setPrototypeOf ||
44311 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
44312 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
44313 return extendStatics(d, b);
44315 return function (d, b) {
44316 extendStatics(d, b);
44317 function __() { this.constructor = d; }
44318 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
44321 Object.defineProperty(exports, "__esModule", { value: true });
44322 var THREE = require("three");
44323 var State_1 = require("../../State");
44324 var EarthState = /** @class */ (function (_super) {
44325 __extends(EarthState, _super);
44326 function EarthState(state) {
44327 var _this = _super.call(this, state) || this;
44328 var viewingDirection = _this._camera.lookat
44330 .sub(_this._camera.position)
44332 _this._camera.lookat.copy(_this._camera.position);
44333 _this._camera.position.z = state.camera.position.z + 20;
44334 _this._camera.position.x = state.camera.position.x - 16 * viewingDirection.x;
44335 _this._camera.position.y = state.camera.position.y - 16 * viewingDirection.y;
44336 _this._camera.up.set(0, 0, 1);
44339 EarthState.prototype.traverse = function () {
44340 return new State_1.TraversingState(this);
44342 EarthState.prototype.wait = function () {
44343 return new State_1.WaitingState(this);
44345 EarthState.prototype.waitInteractively = function () {
44346 return new State_1.InteractiveWaitingState(this);
44348 EarthState.prototype.dolly = function (delta) {
44349 var camera = this._camera;
44350 var offset = new THREE.Vector3()
44351 .copy(camera.position)
44352 .sub(camera.lookat);
44353 var length = offset.length();
44354 var scaled = length * Math.pow(2, -delta);
44355 var clipped = Math.max(1, Math.min(scaled, 1000));
44356 offset.normalize();
44357 offset.multiplyScalar(clipped);
44358 camera.position.copy(camera.lookat).add(offset);
44360 EarthState.prototype.orbit = function (rotation) {
44361 var camera = this._camera;
44362 var q = new THREE.Quaternion().setFromUnitVectors(camera.up, new THREE.Vector3(0, 0, 1));
44363 var qInverse = q.clone().inverse();
44364 var offset = new THREE.Vector3();
44365 offset.copy(camera.position).sub(camera.lookat);
44366 offset.applyQuaternion(q);
44367 var length = offset.length();
44368 var phi = Math.atan2(offset.y, offset.x);
44369 phi += rotation.phi;
44370 var theta = Math.atan2(Math.sqrt(offset.x * offset.x + offset.y * offset.y), offset.z);
44371 theta += rotation.theta;
44372 theta = Math.max(0.1, Math.min(Math.PI - 0.1, theta));
44373 offset.x = Math.sin(theta) * Math.cos(phi);
44374 offset.y = Math.sin(theta) * Math.sin(phi);
44375 offset.z = Math.cos(theta);
44376 offset.applyQuaternion(qInverse);
44377 camera.position.copy(camera.lookat).add(offset.multiplyScalar(length));
44379 EarthState.prototype.truck = function (direction) {
44380 this._camera.position.add(new THREE.Vector3().fromArray(direction));
44381 this._camera.lookat.add(new THREE.Vector3().fromArray(direction));
44383 EarthState.prototype.update = function () { };
44385 }(State_1.StateBase));
44386 exports.EarthState = EarthState;
44387 exports.default = EarthState;
44390 },{"../../State":282,"three":226}],417:[function(require,module,exports){
44392 var __extends = (this && this.__extends) || (function () {
44393 var extendStatics = function (d, b) {
44394 extendStatics = Object.setPrototypeOf ||
44395 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
44396 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
44397 return extendStatics(d, b);
44399 return function (d, b) {
44400 extendStatics(d, b);
44401 function __() { this.constructor = d; }
44402 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
44405 Object.defineProperty(exports, "__esModule", { value: true });
44406 var THREE = require("three");
44407 var State_1 = require("../../State");
44408 var InteractiveStateBase = /** @class */ (function (_super) {
44409 __extends(InteractiveStateBase, _super);
44410 function InteractiveStateBase(state) {
44411 var _this = _super.call(this, state) || this;
44412 _this._animationSpeed = 1 / 40;
44413 _this._rotationDelta = new State_1.RotationDelta(0, 0);
44414 _this._requestedRotationDelta = null;
44415 _this._basicRotation = [0, 0];
44416 _this._requestedBasicRotation = null;
44417 _this._requestedBasicRotationUnbounded = null;
44418 _this._rotationAcceleration = 0.86;
44419 _this._rotationIncreaseAlpha = 0.97;
44420 _this._rotationDecreaseAlpha = 0.9;
44421 _this._rotationThreshold = 1e-3;
44422 _this._unboundedRotationAlpha = 0.8;
44423 _this._desiredZoom = state.zoom;
44424 _this._minZoom = 0;
44425 _this._maxZoom = 3;
44426 _this._lookatDepth = 10;
44427 _this._desiredLookat = null;
44428 _this._desiredCenter = null;
44431 InteractiveStateBase.prototype.rotate = function (rotationDelta) {
44432 if (this._currentNode == null) {
44435 this._desiredZoom = this._zoom;
44436 this._desiredLookat = null;
44437 this._requestedBasicRotation = null;
44438 if (this._requestedRotationDelta != null) {
44439 this._requestedRotationDelta.phi = this._requestedRotationDelta.phi + rotationDelta.phi;
44440 this._requestedRotationDelta.theta = this._requestedRotationDelta.theta + rotationDelta.theta;
44443 this._requestedRotationDelta = new State_1.RotationDelta(rotationDelta.phi, rotationDelta.theta);
44446 InteractiveStateBase.prototype.rotateUnbounded = function (delta) {
44447 if (this._currentNode == null) {
44450 this._requestedBasicRotation = null;
44451 this._requestedRotationDelta = null;
44452 this._applyRotation(delta, this._currentCamera);
44453 this._applyRotation(delta, this._previousCamera);
44454 if (!this._desiredLookat) {
44457 var q = new THREE.Quaternion().setFromUnitVectors(this._currentCamera.up, new THREE.Vector3(0, 0, 1));
44458 var qInverse = q.clone().inverse();
44459 var offset = new THREE.Vector3()
44460 .copy(this._desiredLookat)
44461 .sub(this._camera.position)
44462 .applyQuaternion(q);
44463 var length = offset.length();
44464 var phi = Math.atan2(offset.y, offset.x);
44466 var theta = Math.atan2(Math.sqrt(offset.x * offset.x + offset.y * offset.y), offset.z);
44467 theta += delta.theta;
44468 theta = Math.max(0.1, Math.min(Math.PI - 0.1, theta));
44469 offset.x = Math.sin(theta) * Math.cos(phi);
44470 offset.y = Math.sin(theta) * Math.sin(phi);
44471 offset.z = Math.cos(theta);
44472 offset.applyQuaternion(qInverse);
44473 this._desiredLookat
44474 .copy(this._camera.position)
44475 .add(offset.multiplyScalar(length));
44477 InteractiveStateBase.prototype.rotateWithoutInertia = function (rotationDelta) {
44478 if (this._currentNode == null) {
44481 this._desiredZoom = this._zoom;
44482 this._desiredLookat = null;
44483 this._requestedBasicRotation = null;
44484 this._requestedRotationDelta = null;
44485 var threshold = Math.PI / (10 * Math.pow(2, this._zoom));
44487 phi: this._spatial.clamp(rotationDelta.phi, -threshold, threshold),
44488 theta: this._spatial.clamp(rotationDelta.theta, -threshold, threshold),
44490 this._applyRotation(delta, this._currentCamera);
44491 this._applyRotation(delta, this._previousCamera);
44493 InteractiveStateBase.prototype.rotateBasic = function (basicRotation) {
44494 if (this._currentNode == null) {
44497 this._desiredZoom = this._zoom;
44498 this._desiredLookat = null;
44499 this._requestedRotationDelta = null;
44500 if (this._requestedBasicRotation != null) {
44501 this._requestedBasicRotation[0] += basicRotation[0];
44502 this._requestedBasicRotation[1] += basicRotation[1];
44503 var threshold = 0.05 / Math.pow(2, this._zoom);
44504 this._requestedBasicRotation[0] =
44505 this._spatial.clamp(this._requestedBasicRotation[0], -threshold, threshold);
44506 this._requestedBasicRotation[1] =
44507 this._spatial.clamp(this._requestedBasicRotation[1], -threshold, threshold);
44510 this._requestedBasicRotation = basicRotation.slice();
44513 InteractiveStateBase.prototype.rotateBasicUnbounded = function (basicRotation) {
44514 if (this._currentNode == null) {
44517 if (this._requestedBasicRotationUnbounded != null) {
44518 this._requestedBasicRotationUnbounded[0] += basicRotation[0];
44519 this._requestedBasicRotationUnbounded[1] += basicRotation[1];
44522 this._requestedBasicRotationUnbounded = basicRotation.slice();
44525 InteractiveStateBase.prototype.rotateBasicWithoutInertia = function (basic) {
44526 if (this._currentNode == null) {
44529 this._desiredZoom = this._zoom;
44530 this._desiredLookat = null;
44531 this._requestedRotationDelta = null;
44532 this._requestedBasicRotation = null;
44533 var threshold = 0.05 / Math.pow(2, this._zoom);
44534 var basicRotation = basic.slice();
44535 basicRotation[0] = this._spatial.clamp(basicRotation[0], -threshold, threshold);
44536 basicRotation[1] = this._spatial.clamp(basicRotation[1], -threshold, threshold);
44537 this._applyRotationBasic(basicRotation);
44539 InteractiveStateBase.prototype.rotateToBasic = function (basic) {
44540 if (this._currentNode == null) {
44543 this._desiredZoom = this._zoom;
44544 this._desiredLookat = null;
44545 basic[0] = this._spatial.clamp(basic[0], 0, 1);
44546 basic[1] = this._spatial.clamp(basic[1], 0, 1);
44547 var lookat = this.currentTransform.unprojectBasic(basic, this._lookatDepth);
44548 this._currentCamera.lookat.fromArray(lookat);
44550 InteractiveStateBase.prototype.zoomIn = function (delta, reference) {
44551 if (this._currentNode == null) {
44554 this._desiredZoom = Math.max(this._minZoom, Math.min(this._maxZoom, this._desiredZoom + delta));
44555 var currentCenter = this.currentTransform.projectBasic(this._currentCamera.lookat.toArray());
44556 var currentCenterX = currentCenter[0];
44557 var currentCenterY = currentCenter[1];
44558 var zoom0 = Math.pow(2, this._zoom);
44559 var zoom1 = Math.pow(2, this._desiredZoom);
44560 var refX = reference[0];
44561 var refY = reference[1];
44562 if (this.currentTransform.gpano != null &&
44563 this.currentTransform.gpano.CroppedAreaImageWidthPixels === this.currentTransform.gpano.FullPanoWidthPixels) {
44564 if (refX - currentCenterX > 0.5) {
44567 else if (currentCenterX - refX > 0.5) {
44571 var newCenterX = refX - zoom0 / zoom1 * (refX - currentCenterX);
44572 var newCenterY = refY - zoom0 / zoom1 * (refY - currentCenterY);
44573 var gpano = this.currentTransform.gpano;
44574 if (this._currentNode.fullPano) {
44575 newCenterX = this._spatial.wrap(newCenterX + this._basicRotation[0], 0, 1);
44576 newCenterY = this._spatial.clamp(newCenterY + this._basicRotation[1], 0.05, 0.95);
44578 else if (gpano != null &&
44579 this.currentTransform.gpano.CroppedAreaImageWidthPixels === this.currentTransform.gpano.FullPanoWidthPixels) {
44580 newCenterX = this._spatial.wrap(newCenterX + this._basicRotation[0], 0, 1);
44581 newCenterY = this._spatial.clamp(newCenterY + this._basicRotation[1], 0, 1);
44584 newCenterX = this._spatial.clamp(newCenterX, 0, 1);
44585 newCenterY = this._spatial.clamp(newCenterY, 0, 1);
44587 this._desiredLookat = new THREE.Vector3()
44588 .fromArray(this.currentTransform.unprojectBasic([newCenterX, newCenterY], this._lookatDepth));
44590 InteractiveStateBase.prototype.setCenter = function (center) {
44591 this._desiredLookat = null;
44592 this._requestedRotationDelta = null;
44593 this._requestedBasicRotation = null;
44594 this._desiredZoom = this._zoom;
44596 this._spatial.clamp(center[0], 0, 1),
44597 this._spatial.clamp(center[1], 0, 1),
44599 if (this._currentNode == null) {
44600 this._desiredCenter = clamped;
44603 this._desiredCenter = null;
44604 var currentLookat = new THREE.Vector3()
44605 .fromArray(this.currentTransform.unprojectBasic(clamped, this._lookatDepth));
44606 var previousTransform = this.previousTransform != null ?
44607 this.previousTransform :
44608 this.currentTransform;
44609 var previousLookat = new THREE.Vector3()
44610 .fromArray(previousTransform.unprojectBasic(clamped, this._lookatDepth));
44611 this._currentCamera.lookat.copy(currentLookat);
44612 this._previousCamera.lookat.copy(previousLookat);
44614 InteractiveStateBase.prototype.setZoom = function (zoom) {
44615 this._desiredLookat = null;
44616 this._requestedRotationDelta = null;
44617 this._requestedBasicRotation = null;
44618 this._zoom = this._spatial.clamp(zoom, this._minZoom, this._maxZoom);
44619 this._desiredZoom = this._zoom;
44621 InteractiveStateBase.prototype._applyRotation = function (delta, camera) {
44622 if (camera == null) {
44625 var q = new THREE.Quaternion().setFromUnitVectors(camera.up, new THREE.Vector3(0, 0, 1));
44626 var qInverse = q.clone().inverse();
44627 var offset = new THREE.Vector3();
44628 offset.copy(camera.lookat).sub(camera.position);
44629 offset.applyQuaternion(q);
44630 var length = offset.length();
44631 var phi = Math.atan2(offset.y, offset.x);
44633 var theta = Math.atan2(Math.sqrt(offset.x * offset.x + offset.y * offset.y), offset.z);
44634 theta += delta.theta;
44635 theta = Math.max(0.1, Math.min(Math.PI - 0.1, theta));
44636 offset.x = Math.sin(theta) * Math.cos(phi);
44637 offset.y = Math.sin(theta) * Math.sin(phi);
44638 offset.z = Math.cos(theta);
44639 offset.applyQuaternion(qInverse);
44640 camera.lookat.copy(camera.position).add(offset.multiplyScalar(length));
44642 InteractiveStateBase.prototype._applyRotationBasic = function (basicRotation) {
44643 var currentNode = this._currentNode;
44644 var previousNode = this._previousNode != null ?
44645 this.previousNode :
44647 var currentCamera = this._currentCamera;
44648 var previousCamera = this._previousCamera;
44649 var currentTransform = this.currentTransform;
44650 var previousTransform = this.previousTransform != null ?
44651 this.previousTransform :
44652 this.currentTransform;
44653 var currentBasic = currentTransform.projectBasic(currentCamera.lookat.toArray());
44654 var previousBasic = previousTransform.projectBasic(previousCamera.lookat.toArray());
44655 var currentGPano = currentTransform.gpano;
44656 var previousGPano = previousTransform.gpano;
44657 if (currentNode.fullPano) {
44658 currentBasic[0] = this._spatial.wrap(currentBasic[0] + basicRotation[0], 0, 1);
44659 currentBasic[1] = this._spatial.clamp(currentBasic[1] + basicRotation[1], 0.05, 0.95);
44661 else if (currentGPano != null &&
44662 currentTransform.gpano.CroppedAreaImageWidthPixels === currentTransform.gpano.FullPanoWidthPixels) {
44663 currentBasic[0] = this._spatial.wrap(currentBasic[0] + basicRotation[0], 0, 1);
44664 currentBasic[1] = this._spatial.clamp(currentBasic[1] + basicRotation[1], 0, 1);
44667 currentBasic[0] = this._spatial.clamp(currentBasic[0] + basicRotation[0], 0, 1);
44668 currentBasic[1] = this._spatial.clamp(currentBasic[1] + basicRotation[1], 0, 1);
44670 if (previousNode.fullPano) {
44671 previousBasic[0] = this._spatial.wrap(previousBasic[0] + basicRotation[0], 0, 1);
44672 previousBasic[1] = this._spatial.clamp(previousBasic[1] + basicRotation[1], 0.05, 0.95);
44674 else if (previousGPano != null &&
44675 previousTransform.gpano.CroppedAreaImageWidthPixels === previousTransform.gpano.FullPanoWidthPixels) {
44676 previousBasic[0] = this._spatial.wrap(previousBasic[0] + basicRotation[0], 0, 1);
44677 previousBasic[1] = this._spatial.clamp(previousBasic[1] + basicRotation[1], 0, 1);
44680 previousBasic[0] = this._spatial.clamp(previousBasic[0] + basicRotation[0], 0, 1);
44681 previousBasic[1] = this._spatial.clamp(currentBasic[1] + basicRotation[1], 0, 1);
44683 var currentLookat = currentTransform.unprojectBasic(currentBasic, this._lookatDepth);
44684 currentCamera.lookat.fromArray(currentLookat);
44685 var previousLookat = previousTransform.unprojectBasic(previousBasic, this._lookatDepth);
44686 previousCamera.lookat.fromArray(previousLookat);
44688 InteractiveStateBase.prototype._updateZoom = function (animationSpeed) {
44689 var diff = this._desiredZoom - this._zoom;
44690 var sign = diff > 0 ? 1 : diff < 0 ? -1 : 0;
44694 else if (Math.abs(diff) < 2e-3) {
44695 this._zoom = this._desiredZoom;
44696 if (this._desiredLookat != null) {
44697 this._desiredLookat = null;
44701 this._zoom += sign * Math.max(Math.abs(5 * animationSpeed * diff), 2e-3);
44704 InteractiveStateBase.prototype._updateLookat = function (animationSpeed) {
44705 if (this._desiredLookat === null) {
44708 var diff = this._desiredLookat.distanceToSquared(this._currentCamera.lookat);
44709 if (Math.abs(diff) < 1e-6) {
44710 this._currentCamera.lookat.copy(this._desiredLookat);
44711 this._desiredLookat = null;
44714 this._currentCamera.lookat.lerp(this._desiredLookat, 5 * animationSpeed);
44717 InteractiveStateBase.prototype._updateRotation = function () {
44718 if (this._requestedRotationDelta != null) {
44719 var length_1 = this._rotationDelta.lengthSquared();
44720 var requestedLength = this._requestedRotationDelta.lengthSquared();
44721 if (requestedLength > length_1) {
44722 this._rotationDelta.lerp(this._requestedRotationDelta, this._rotationIncreaseAlpha);
44725 this._rotationDelta.lerp(this._requestedRotationDelta, this._rotationDecreaseAlpha);
44727 this._requestedRotationDelta = null;
44730 if (this._rotationDelta.isZero) {
44733 this._rotationDelta.multiply(this._rotationAcceleration);
44734 this._rotationDelta.threshold(this._rotationThreshold);
44736 InteractiveStateBase.prototype._updateRotationBasic = function () {
44737 if (this._requestedBasicRotation != null) {
44738 var x = this._basicRotation[0];
44739 var y = this._basicRotation[1];
44740 var reqX = this._requestedBasicRotation[0];
44741 var reqY = this._requestedBasicRotation[1];
44742 if (Math.abs(reqX) > Math.abs(x)) {
44743 this._basicRotation[0] = (1 - this._rotationIncreaseAlpha) * x + this._rotationIncreaseAlpha * reqX;
44746 this._basicRotation[0] = (1 - this._rotationDecreaseAlpha) * x + this._rotationDecreaseAlpha * reqX;
44748 if (Math.abs(reqY) > Math.abs(y)) {
44749 this._basicRotation[1] = (1 - this._rotationIncreaseAlpha) * y + this._rotationIncreaseAlpha * reqY;
44752 this._basicRotation[1] = (1 - this._rotationDecreaseAlpha) * y + this._rotationDecreaseAlpha * reqY;
44754 this._requestedBasicRotation = null;
44757 if (this._requestedBasicRotationUnbounded != null) {
44758 var reqX = this._requestedBasicRotationUnbounded[0];
44759 var reqY = this._requestedBasicRotationUnbounded[1];
44760 if (Math.abs(reqX) > 0) {
44761 this._basicRotation[0] = (1 - this._unboundedRotationAlpha) * this._basicRotation[0] + this._unboundedRotationAlpha * reqX;
44763 if (Math.abs(reqY) > 0) {
44764 this._basicRotation[1] = (1 - this._unboundedRotationAlpha) * this._basicRotation[1] + this._unboundedRotationAlpha * reqY;
44766 if (this._desiredLookat != null) {
44767 var desiredBasicLookat = this.currentTransform.projectBasic(this._desiredLookat.toArray());
44768 desiredBasicLookat[0] += reqX;
44769 desiredBasicLookat[1] += reqY;
44770 this._desiredLookat = new THREE.Vector3()
44771 .fromArray(this.currentTransform.unprojectBasic(desiredBasicLookat, this._lookatDepth));
44773 this._requestedBasicRotationUnbounded = null;
44775 if (this._basicRotation[0] === 0 && this._basicRotation[1] === 0) {
44778 this._basicRotation[0] = this._rotationAcceleration * this._basicRotation[0];
44779 this._basicRotation[1] = this._rotationAcceleration * this._basicRotation[1];
44780 if (Math.abs(this._basicRotation[0]) < this._rotationThreshold / Math.pow(2, this._zoom) &&
44781 Math.abs(this._basicRotation[1]) < this._rotationThreshold / Math.pow(2, this._zoom)) {
44782 this._basicRotation = [0, 0];
44785 InteractiveStateBase.prototype._clearRotation = function () {
44786 if (this._currentNode.fullPano) {
44789 if (this._requestedRotationDelta != null) {
44790 this._requestedRotationDelta = null;
44792 if (!this._rotationDelta.isZero) {
44793 this._rotationDelta.reset();
44795 if (this._requestedBasicRotation != null) {
44796 this._requestedBasicRotation = null;
44798 if (this._basicRotation[0] > 0 || this._basicRotation[1] > 0) {
44799 this._basicRotation = [0, 0];
44802 InteractiveStateBase.prototype._setDesiredCenter = function () {
44803 if (this._desiredCenter == null) {
44806 var lookatDirection = new THREE.Vector3()
44807 .fromArray(this.currentTransform.unprojectBasic(this._desiredCenter, this._lookatDepth))
44808 .sub(this._currentCamera.position);
44809 this._currentCamera.lookat.copy(this._currentCamera.position.clone().add(lookatDirection));
44810 this._previousCamera.lookat.copy(this._previousCamera.position.clone().add(lookatDirection));
44811 this._desiredCenter = null;
44813 InteractiveStateBase.prototype._setDesiredZoom = function () {
44814 this._desiredZoom =
44815 this._currentNode.fullPano || this._previousNode == null ?
44818 return InteractiveStateBase;
44819 }(State_1.StateBase));
44820 exports.InteractiveStateBase = InteractiveStateBase;
44821 exports.default = InteractiveStateBase;
44824 },{"../../State":282,"three":226}],418:[function(require,module,exports){
44826 var __extends = (this && this.__extends) || (function () {
44827 var extendStatics = function (d, b) {
44828 extendStatics = Object.setPrototypeOf ||
44829 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
44830 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
44831 return extendStatics(d, b);
44833 return function (d, b) {
44834 extendStatics(d, b);
44835 function __() { this.constructor = d; }
44836 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
44839 Object.defineProperty(exports, "__esModule", { value: true });
44840 var State_1 = require("../../State");
44841 var InteractiveWaitingState = /** @class */ (function (_super) {
44842 __extends(InteractiveWaitingState, _super);
44843 function InteractiveWaitingState(state) {
44844 var _this = _super.call(this, state) || this;
44845 _this._adjustCameras();
44846 _this._motionless = _this._motionlessTransition();
44849 InteractiveWaitingState.prototype.traverse = function () {
44850 return new State_1.TraversingState(this);
44852 InteractiveWaitingState.prototype.wait = function () {
44853 return new State_1.WaitingState(this);
44855 InteractiveWaitingState.prototype.prepend = function (nodes) {
44856 _super.prototype.prepend.call(this, nodes);
44857 this._motionless = this._motionlessTransition();
44859 InteractiveWaitingState.prototype.set = function (nodes) {
44860 _super.prototype.set.call(this, nodes);
44861 this._motionless = this._motionlessTransition();
44863 InteractiveWaitingState.prototype.move = function (delta) {
44864 this._alpha = Math.max(0, Math.min(1, this._alpha + delta));
44866 InteractiveWaitingState.prototype.moveTo = function (position) {
44867 this._alpha = Math.max(0, Math.min(1, position));
44869 InteractiveWaitingState.prototype.update = function (fps) {
44870 this._updateRotation();
44871 if (!this._rotationDelta.isZero) {
44872 this._applyRotation(this._rotationDelta, this._previousCamera);
44873 this._applyRotation(this._rotationDelta, this._currentCamera);
44875 this._updateRotationBasic();
44876 if (this._basicRotation[0] !== 0 || this._basicRotation[1] !== 0) {
44877 this._applyRotationBasic(this._basicRotation);
44879 var animationSpeed = this._animationSpeed * (60 / fps);
44880 this._updateZoom(animationSpeed);
44881 this._updateLookat(animationSpeed);
44882 this._camera.lerpCameras(this._previousCamera, this._currentCamera, this.alpha);
44884 InteractiveWaitingState.prototype._getAlpha = function () {
44885 return this._motionless ? Math.round(this._alpha) : this._alpha;
44887 InteractiveWaitingState.prototype._setCurrentCamera = function () {
44888 _super.prototype._setCurrentCamera.call(this);
44889 this._adjustCameras();
44891 InteractiveWaitingState.prototype._adjustCameras = function () {
44892 if (this._previousNode == null) {
44895 if (this._currentNode.fullPano) {
44896 var lookat = this._camera.lookat.clone().sub(this._camera.position);
44897 this._currentCamera.lookat.copy(lookat.clone().add(this._currentCamera.position));
44899 if (this._previousNode.fullPano) {
44900 var lookat = this._currentCamera.lookat.clone().sub(this._currentCamera.position);
44901 this._previousCamera.lookat.copy(lookat.clone().add(this._previousCamera.position));
44904 return InteractiveWaitingState;
44905 }(State_1.InteractiveStateBase));
44906 exports.InteractiveWaitingState = InteractiveWaitingState;
44907 exports.default = InteractiveWaitingState;
44909 },{"../../State":282}],419:[function(require,module,exports){
44911 Object.defineProperty(exports, "__esModule", { value: true });
44912 var Error_1 = require("../../Error");
44913 var Geo_1 = require("../../Geo");
44914 var State_1 = require("../../State");
44915 var StateBase = /** @class */ (function () {
44916 function StateBase(state) {
44917 this._spatial = new Geo_1.Spatial();
44918 this._geoCoords = new Geo_1.GeoCoords();
44919 this._referenceThreshold = 0.01;
44920 this._transitionMode = state.transitionMode;
44921 this._reference = state.reference;
44922 this._alpha = state.alpha;
44923 this._camera = state.camera.clone();
44924 this._zoom = state.zoom;
44925 this._currentIndex = state.currentIndex;
44926 this._trajectory = state.trajectory.slice();
44927 this._trajectoryTransforms = [];
44928 this._trajectoryCameras = [];
44929 for (var _i = 0, _a = this._trajectory; _i < _a.length; _i++) {
44931 var translation = this._nodeToTranslation(node, this._reference);
44932 var transform = new Geo_1.Transform(node.orientation, node.width, node.height, node.focal, node.scale, node.gpano, node.rotation, translation, node.image, undefined, node.ck1, node.ck2, node.cameraProjection);
44933 this._trajectoryTransforms.push(transform);
44934 this._trajectoryCameras.push(new Geo_1.Camera(transform));
44936 this._currentNode = this._trajectory.length > 0 ?
44937 this._trajectory[this._currentIndex] :
44939 this._previousNode = this._trajectory.length > 1 && this.currentIndex > 0 ?
44940 this._trajectory[this._currentIndex - 1] :
44942 this._currentCamera = this._trajectoryCameras.length > 0 ?
44943 this._trajectoryCameras[this._currentIndex].clone() :
44944 new Geo_1.Camera();
44945 this._previousCamera = this._trajectoryCameras.length > 1 && this.currentIndex > 0 ?
44946 this._trajectoryCameras[this._currentIndex - 1].clone() :
44947 this._currentCamera.clone();
44949 Object.defineProperty(StateBase.prototype, "reference", {
44951 return this._reference;
44956 Object.defineProperty(StateBase.prototype, "alpha", {
44958 return this._getAlpha();
44963 Object.defineProperty(StateBase.prototype, "camera", {
44965 return this._camera;
44970 Object.defineProperty(StateBase.prototype, "zoom", {
44977 Object.defineProperty(StateBase.prototype, "trajectory", {
44979 return this._trajectory;
44984 Object.defineProperty(StateBase.prototype, "currentIndex", {
44986 return this._currentIndex;
44991 Object.defineProperty(StateBase.prototype, "currentNode", {
44993 return this._currentNode;
44998 Object.defineProperty(StateBase.prototype, "previousNode", {
45000 return this._previousNode;
45005 Object.defineProperty(StateBase.prototype, "currentCamera", {
45007 return this._currentCamera;
45012 Object.defineProperty(StateBase.prototype, "currentTransform", {
45014 return this._trajectoryTransforms.length > 0 ?
45015 this._trajectoryTransforms[this.currentIndex] : null;
45020 Object.defineProperty(StateBase.prototype, "previousTransform", {
45022 return this._trajectoryTransforms.length > 1 && this.currentIndex > 0 ?
45023 this._trajectoryTransforms[this.currentIndex - 1] : null;
45028 Object.defineProperty(StateBase.prototype, "motionless", {
45030 return this._motionless;
45035 Object.defineProperty(StateBase.prototype, "transitionMode", {
45037 return this._transitionMode;
45042 StateBase.prototype.earth = function () { throw new Error("Not implemented"); };
45043 StateBase.prototype.traverse = function () { throw new Error("Not implemented"); };
45044 StateBase.prototype.wait = function () { throw new Error("Not implemented"); };
45045 StateBase.prototype.waitInteractively = function () { throw new Error("Not implemented"); };
45046 StateBase.prototype.move = function (delta) { };
45047 StateBase.prototype.moveTo = function (position) { };
45048 StateBase.prototype.rotate = function (delta) { };
45049 StateBase.prototype.rotateUnbounded = function (delta) { };
45050 StateBase.prototype.rotateWithoutInertia = function (delta) { };
45051 StateBase.prototype.rotateBasic = function (basicRotation) { };
45052 StateBase.prototype.rotateBasicUnbounded = function (basicRotation) { };
45053 StateBase.prototype.rotateBasicWithoutInertia = function (basicRotation) { };
45054 StateBase.prototype.rotateToBasic = function (basic) { };
45055 StateBase.prototype.setSpeed = function (speed) { };
45056 StateBase.prototype.zoomIn = function (delta, reference) { };
45057 StateBase.prototype.update = function (fps) { };
45058 StateBase.prototype.setCenter = function (center) { };
45059 StateBase.prototype.setZoom = function (zoom) { };
45060 StateBase.prototype.dolly = function (delta) { };
45061 StateBase.prototype.orbit = function (rotation) { };
45062 StateBase.prototype.truck = function (direction) { };
45063 StateBase.prototype.append = function (nodes) {
45064 if (nodes.length < 1) {
45065 throw Error("Trajectory can not be empty");
45067 if (this._currentIndex < 0) {
45071 this._trajectory = this._trajectory.concat(nodes);
45072 this._appendToTrajectories(nodes);
45075 StateBase.prototype.prepend = function (nodes) {
45076 if (nodes.length < 1) {
45077 throw Error("Trajectory can not be empty");
45079 this._trajectory = nodes.slice().concat(this._trajectory);
45080 this._currentIndex += nodes.length;
45081 this._setCurrentNode();
45082 var referenceReset = this._setReference(this._currentNode);
45083 if (referenceReset) {
45084 this._setTrajectories();
45087 this._prependToTrajectories(nodes);
45089 this._setCurrentCamera();
45091 StateBase.prototype.remove = function (n) {
45093 throw Error("n must be a positive integer");
45095 if (this._currentIndex - 1 < n) {
45096 throw Error("Current and previous nodes can not be removed");
45098 for (var i = 0; i < n; i++) {
45099 this._trajectory.shift();
45100 this._trajectoryTransforms.shift();
45101 this._trajectoryCameras.shift();
45102 this._currentIndex--;
45104 this._setCurrentNode();
45106 StateBase.prototype.clearPrior = function () {
45107 if (this._currentIndex > 0) {
45108 this.remove(this._currentIndex - 1);
45111 StateBase.prototype.clear = function () {
45113 if (this._currentIndex > 0) {
45114 this.remove(this._currentIndex - 1);
45117 StateBase.prototype.cut = function () {
45118 while (this._trajectory.length - 1 > this._currentIndex) {
45119 this._trajectory.pop();
45120 this._trajectoryTransforms.pop();
45121 this._trajectoryCameras.pop();
45124 StateBase.prototype.set = function (nodes) {
45125 this._setTrajectory(nodes);
45126 this._setCurrentNode();
45127 this._setReference(this._currentNode);
45128 this._setTrajectories();
45129 this._setCurrentCamera();
45131 StateBase.prototype.getCenter = function () {
45132 return this._currentNode != null ?
45133 this.currentTransform.projectBasic(this._camera.lookat.toArray()) :
45136 StateBase.prototype.setTransitionMode = function (mode) {
45137 this._transitionMode = mode;
45139 StateBase.prototype._getAlpha = function () { return 1; };
45140 StateBase.prototype._setCurrent = function () {
45141 this._setCurrentNode();
45142 var referenceReset = this._setReference(this._currentNode);
45143 if (referenceReset) {
45144 this._setTrajectories();
45146 this._setCurrentCamera();
45148 StateBase.prototype._setCurrentCamera = function () {
45149 this._currentCamera = this._trajectoryCameras[this._currentIndex].clone();
45150 this._previousCamera = this._currentIndex > 0 ?
45151 this._trajectoryCameras[this._currentIndex - 1].clone() :
45152 this._currentCamera.clone();
45154 StateBase.prototype._motionlessTransition = function () {
45155 var nodesSet = this._currentNode != null && this._previousNode != null;
45156 return nodesSet && (this._transitionMode === State_1.TransitionMode.Instantaneous || !(this._currentNode.merged &&
45157 this._previousNode.merged &&
45158 this._withinOriginalDistance() &&
45159 this._sameConnectedComponent()));
45161 StateBase.prototype._setReference = function (node) {
45162 // do not reset reference if node is within threshold distance
45163 if (Math.abs(node.latLon.lat - this.reference.lat) < this._referenceThreshold &&
45164 Math.abs(node.latLon.lon - this.reference.lon) < this._referenceThreshold) {
45167 // do not reset reference if previous node exist and transition is with motion
45168 if (this._previousNode != null && !this._motionlessTransition()) {
45171 this._reference.lat = node.latLon.lat;
45172 this._reference.lon = node.latLon.lon;
45173 this._reference.alt = node.alt;
45176 StateBase.prototype._setCurrentNode = function () {
45177 this._currentNode = this._trajectory.length > 0 ?
45178 this._trajectory[this._currentIndex] :
45180 this._previousNode = this._currentIndex > 0 ?
45181 this._trajectory[this._currentIndex - 1] :
45184 StateBase.prototype._setTrajectory = function (nodes) {
45185 if (nodes.length < 1) {
45186 throw new Error_1.ArgumentMapillaryError("Trajectory can not be empty");
45188 if (this._currentNode != null) {
45189 this._trajectory = [this._currentNode].concat(nodes);
45190 this._currentIndex = 1;
45193 this._trajectory = nodes.slice();
45194 this._currentIndex = 0;
45197 StateBase.prototype._setTrajectories = function () {
45198 this._trajectoryTransforms.length = 0;
45199 this._trajectoryCameras.length = 0;
45200 this._appendToTrajectories(this._trajectory);
45202 StateBase.prototype._appendToTrajectories = function (nodes) {
45203 for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
45204 var node = nodes_1[_i];
45205 if (!node.assetsCached) {
45206 throw new Error_1.ArgumentMapillaryError("Assets must be cached when node is added to trajectory");
45208 var translation = this._nodeToTranslation(node, this.reference);
45209 var transform = new Geo_1.Transform(node.orientation, node.width, node.height, node.focal, node.scale, node.gpano, node.rotation, translation, node.image, undefined, node.ck1, node.ck2, node.cameraProjection);
45210 this._trajectoryTransforms.push(transform);
45211 this._trajectoryCameras.push(new Geo_1.Camera(transform));
45214 StateBase.prototype._prependToTrajectories = function (nodes) {
45215 for (var _i = 0, _a = nodes.reverse(); _i < _a.length; _i++) {
45217 if (!node.assetsCached) {
45218 throw new Error_1.ArgumentMapillaryError("Assets must be cached when added to trajectory");
45220 var translation = this._nodeToTranslation(node, this.reference);
45221 var transform = new Geo_1.Transform(node.orientation, node.width, node.height, node.focal, node.scale, node.gpano, node.rotation, translation, node.image, undefined, node.ck1, node.ck2, node.cameraProjection);
45222 this._trajectoryTransforms.unshift(transform);
45223 this._trajectoryCameras.unshift(new Geo_1.Camera(transform));
45226 StateBase.prototype._nodeToTranslation = function (node, reference) {
45227 return Geo_1.Geo.computeTranslation({ alt: node.alt, lat: node.latLon.lat, lon: node.latLon.lon }, node.rotation, reference);
45229 StateBase.prototype._sameConnectedComponent = function () {
45230 var current = this._currentNode;
45231 var previous = this._previousNode;
45232 return !!current && !!previous &&
45233 current.mergeCC === previous.mergeCC;
45235 StateBase.prototype._withinOriginalDistance = function () {
45236 var current = this._currentNode;
45237 var previous = this._previousNode;
45238 if (!current || !previous) {
45241 // 50 km/h moves 28m in 2s
45242 var distance = this._spatial.distanceFromLatLon(current.originalLatLon.lat, current.originalLatLon.lon, previous.originalLatLon.lat, previous.originalLatLon.lon);
45243 return distance < 25;
45247 exports.StateBase = StateBase;
45249 },{"../../Error":277,"../../Geo":278,"../../State":282}],420:[function(require,module,exports){
45251 var __extends = (this && this.__extends) || (function () {
45252 var extendStatics = function (d, b) {
45253 extendStatics = Object.setPrototypeOf ||
45254 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
45255 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
45256 return extendStatics(d, b);
45258 return function (d, b) {
45259 extendStatics(d, b);
45260 function __() { this.constructor = d; }
45261 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
45264 Object.defineProperty(exports, "__esModule", { value: true });
45265 var UnitBezier = require("@mapbox/unitbezier");
45266 var State_1 = require("../../State");
45267 var TraversingState = /** @class */ (function (_super) {
45268 __extends(TraversingState, _super);
45269 function TraversingState(state) {
45270 var _this = _super.call(this, state) || this;
45271 _this._adjustCameras();
45272 _this._motionless = _this._motionlessTransition();
45273 _this._baseAlpha = _this._alpha;
45274 _this._speedCoefficient = 1;
45275 _this._unitBezier = new UnitBezier(0.74, 0.67, 0.38, 0.96);
45276 _this._useBezier = false;
45279 TraversingState.prototype.earth = function () {
45280 return new State_1.EarthState(this);
45282 TraversingState.prototype.wait = function () {
45283 return new State_1.WaitingState(this);
45285 TraversingState.prototype.waitInteractively = function () {
45286 return new State_1.InteractiveWaitingState(this);
45288 TraversingState.prototype.append = function (nodes) {
45289 var emptyTrajectory = this._trajectory.length === 0;
45290 if (emptyTrajectory) {
45291 this._resetTransition();
45293 _super.prototype.append.call(this, nodes);
45294 if (emptyTrajectory) {
45295 this._setDesiredCenter();
45296 this._setDesiredZoom();
45299 TraversingState.prototype.prepend = function (nodes) {
45300 var emptyTrajectory = this._trajectory.length === 0;
45301 if (emptyTrajectory) {
45302 this._resetTransition();
45304 _super.prototype.prepend.call(this, nodes);
45305 if (emptyTrajectory) {
45306 this._setDesiredCenter();
45307 this._setDesiredZoom();
45310 TraversingState.prototype.set = function (nodes) {
45311 _super.prototype.set.call(this, nodes);
45312 this._desiredLookat = null;
45313 this._resetTransition();
45314 this._clearRotation();
45315 this._setDesiredCenter();
45316 this._setDesiredZoom();
45317 if (this._trajectory.length < 3) {
45318 this._useBezier = true;
45321 TraversingState.prototype.setSpeed = function (speed) {
45322 this._speedCoefficient = this._spatial.clamp(speed, 0, 10);
45324 TraversingState.prototype.update = function (fps) {
45325 if (this._alpha === 1 && this._currentIndex + this._alpha < this._trajectory.length) {
45326 this._currentIndex += 1;
45327 this._useBezier = this._trajectory.length < 3 &&
45328 this._currentIndex + 1 === this._trajectory.length;
45329 this._setCurrent();
45330 this._resetTransition();
45331 this._clearRotation();
45332 this._desiredZoom = this._currentNode.fullPano ? this._zoom : 0;
45333 this._desiredLookat = null;
45335 var animationSpeed = this._animationSpeed * (60 / fps);
45336 this._baseAlpha = Math.min(1, this._baseAlpha + this._speedCoefficient * animationSpeed);
45337 if (this._useBezier) {
45338 this._alpha = this._unitBezier.solve(this._baseAlpha);
45341 this._alpha = this._baseAlpha;
45343 this._updateRotation();
45344 if (!this._rotationDelta.isZero) {
45345 this._applyRotation(this._rotationDelta, this._previousCamera);
45346 this._applyRotation(this._rotationDelta, this._currentCamera);
45348 this._updateRotationBasic();
45349 if (this._basicRotation[0] !== 0 || this._basicRotation[1] !== 0) {
45350 this._applyRotationBasic(this._basicRotation);
45352 this._updateZoom(animationSpeed);
45353 this._updateLookat(animationSpeed);
45354 this._camera.lerpCameras(this._previousCamera, this._currentCamera, this.alpha);
45356 TraversingState.prototype._getAlpha = function () {
45357 return this._motionless ? Math.ceil(this._alpha) : this._alpha;
45359 TraversingState.prototype._setCurrentCamera = function () {
45360 _super.prototype._setCurrentCamera.call(this);
45361 this._adjustCameras();
45363 TraversingState.prototype._adjustCameras = function () {
45364 if (this._previousNode == null) {
45367 var lookat = this._camera.lookat.clone().sub(this._camera.position);
45368 this._previousCamera.lookat.copy(lookat.clone().add(this._previousCamera.position));
45369 if (this._currentNode.fullPano) {
45370 this._currentCamera.lookat.copy(lookat.clone().add(this._currentCamera.position));
45373 TraversingState.prototype._resetTransition = function () {
45375 this._baseAlpha = 0;
45376 this._motionless = this._motionlessTransition();
45378 return TraversingState;
45379 }(State_1.InteractiveStateBase));
45380 exports.TraversingState = TraversingState;
45381 exports.default = TraversingState;
45383 },{"../../State":282,"@mapbox/unitbezier":2}],421:[function(require,module,exports){
45385 var __extends = (this && this.__extends) || (function () {
45386 var extendStatics = function (d, b) {
45387 extendStatics = Object.setPrototypeOf ||
45388 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
45389 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
45390 return extendStatics(d, b);
45392 return function (d, b) {
45393 extendStatics(d, b);
45394 function __() { this.constructor = d; }
45395 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
45398 Object.defineProperty(exports, "__esModule", { value: true });
45399 var State_1 = require("../../State");
45400 var WaitingState = /** @class */ (function (_super) {
45401 __extends(WaitingState, _super);
45402 function WaitingState(state) {
45403 var _this = _super.call(this, state) || this;
45405 _this._adjustCameras();
45406 _this._motionless = _this._motionlessTransition();
45409 WaitingState.prototype.traverse = function () {
45410 return new State_1.TraversingState(this);
45412 WaitingState.prototype.waitInteractively = function () {
45413 return new State_1.InteractiveWaitingState(this);
45415 WaitingState.prototype.prepend = function (nodes) {
45416 _super.prototype.prepend.call(this, nodes);
45417 this._motionless = this._motionlessTransition();
45419 WaitingState.prototype.set = function (nodes) {
45420 _super.prototype.set.call(this, nodes);
45421 this._motionless = this._motionlessTransition();
45423 WaitingState.prototype.move = function (delta) {
45424 this._alpha = Math.max(0, Math.min(1, this._alpha + delta));
45426 WaitingState.prototype.moveTo = function (position) {
45427 this._alpha = Math.max(0, Math.min(1, position));
45429 WaitingState.prototype.update = function (fps) {
45430 this._camera.lerpCameras(this._previousCamera, this._currentCamera, this.alpha);
45432 WaitingState.prototype._getAlpha = function () {
45433 return this._motionless ? Math.round(this._alpha) : this._alpha;
45435 WaitingState.prototype._setCurrentCamera = function () {
45436 _super.prototype._setCurrentCamera.call(this);
45437 this._adjustCameras();
45439 WaitingState.prototype._adjustCameras = function () {
45440 if (this._previousNode == null) {
45443 if (this._currentNode.fullPano) {
45444 var lookat = this._camera.lookat.clone().sub(this._camera.position);
45445 this._currentCamera.lookat.copy(lookat.clone().add(this._currentCamera.position));
45447 if (this._previousNode.fullPano) {
45448 var lookat = this._currentCamera.lookat.clone().sub(this._currentCamera.position);
45449 this._previousCamera.lookat.copy(lookat.clone().add(this._previousCamera.position));
45452 return WaitingState;
45453 }(State_1.StateBase));
45454 exports.WaitingState = WaitingState;
45455 exports.default = WaitingState;
45457 },{"../../State":282}],422:[function(require,module,exports){
45459 Object.defineProperty(exports, "__esModule", { value: true });
45460 var rxjs_1 = require("rxjs");
45462 * @class ImageTileLoader
45464 * @classdesc Represents a loader of image tiles.
45466 var ImageTileLoader = /** @class */ (function () {
45468 * Create a new node image tile loader instance.
45470 * @param {string} scheme - The URI scheme.
45471 * @param {string} host - The URI host.
45472 * @param {string} [origin] - The origin query param.
45474 function ImageTileLoader(scheme, host, origin) {
45475 this._scheme = scheme;
45477 this._origin = origin != null ? "?origin=" + origin : "";
45480 * Retrieve an image tile.
45482 * @description Retrieve an image tile by specifying the area
45483 * as well as the scaled size.
45485 * @param {string} identifier - The identifier of the image.
45486 * @param {number} x - The top left x pixel coordinate for the tile
45487 * in the original image.
45488 * @param {number} y - The top left y pixel coordinate for the tile
45489 * in the original image.
45490 * @param {number} w - The pixel width of the tile in the original image.
45491 * @param {number} h - The pixel height of the tile in the original image.
45492 * @param {number} scaledW - The scaled width of the returned tile.
45493 * @param {number} scaledH - The scaled height of the returned tile.
45495 ImageTileLoader.prototype.getTile = function (identifier, x, y, w, h, scaledW, scaledH) {
45496 var characteristics = "/" + identifier + "/" + x + "," + y + "," + w + "," + h + "/" + scaledW + "," + scaledH + "/0/default.jpg";
45497 var url = this._scheme +
45502 var xmlHTTP = null;
45503 return [rxjs_1.Observable.create(function (subscriber) {
45504 xmlHTTP = new XMLHttpRequest();
45505 xmlHTTP.open("GET", url, true);
45506 xmlHTTP.responseType = "arraybuffer";
45507 xmlHTTP.timeout = 15000;
45508 xmlHTTP.onload = function (event) {
45509 if (xmlHTTP.status !== 200) {
45510 subscriber.error(new Error("Failed to fetch tile (" + identifier + ": " + x + "," + y + "," + w + "," + h + "). " +
45511 ("Status: " + xmlHTTP.status + ", " + xmlHTTP.statusText)));
45514 var image = new Image();
45515 image.crossOrigin = "Anonymous";
45516 image.onload = function (e) {
45517 subscriber.next(image);
45518 subscriber.complete();
45520 image.onerror = function (error) {
45521 subscriber.error(new Error("Failed to load tile image (" + identifier + ": " + x + "," + y + "," + w + "," + h + ")"));
45523 var blob = new Blob([xmlHTTP.response]);
45524 image.src = window.URL.createObjectURL(blob);
45526 xmlHTTP.onerror = function (error) {
45527 subscriber.error(new Error("Failed to fetch tile (" + identifier + ": " + x + "," + y + "," + w + "," + h + ")"));
45529 xmlHTTP.ontimeout = function (error) {
45530 subscriber.error(new Error("Tile request timed out (" + identifier + ": " + x + "," + y + "," + w + "," + h + ")"));
45532 xmlHTTP.onabort = function (event) {
45533 subscriber.error(new Error("Tile request was aborted (" + identifier + ": " + x + "," + y + "," + w + "," + h + ")"));
45535 xmlHTTP.send(null);
45538 if (xmlHTTP != null) {
45544 return ImageTileLoader;
45546 exports.ImageTileLoader = ImageTileLoader;
45547 exports.default = ImageTileLoader;
45549 },{"rxjs":27}],423:[function(require,module,exports){
45551 Object.defineProperty(exports, "__esModule", { value: true });
45553 * @class ImageTileStore
45555 * @classdesc Represents a store for image tiles.
45557 var ImageTileStore = /** @class */ (function () {
45559 * Create a new node image tile store instance.
45561 function ImageTileStore() {
45565 * Add an image tile to the store.
45567 * @param {HTMLImageElement} image - The image tile.
45568 * @param {string} key - The identifier for the tile.
45569 * @param {number} level - The level of the tile.
45571 ImageTileStore.prototype.addImage = function (image, key, level) {
45572 if (!(level in this._images)) {
45573 this._images[level] = {};
45575 this._images[level][key] = image;
45578 * Dispose the store.
45580 * @description Disposes all cached assets.
45582 ImageTileStore.prototype.dispose = function () {
45583 for (var _i = 0, _a = Object.keys(this._images); _i < _a.length; _i++) {
45584 var level = _a[_i];
45585 var levelImages = this._images[level];
45586 for (var _b = 0, _c = Object.keys(levelImages); _b < _c.length; _b++) {
45588 window.URL.revokeObjectURL(levelImages[key].src);
45589 delete levelImages[key];
45591 delete this._images[level];
45595 * Get an image tile from the store.
45597 * @param {string} key - The identifier for the tile.
45598 * @param {number} level - The level of the tile.
45600 ImageTileStore.prototype.getImage = function (key, level) {
45601 return this._images[level][key];
45604 * Check if an image tile exist in the store.
45606 * @param {string} key - The identifier for the tile.
45607 * @param {number} level - The level of the tile.
45609 ImageTileStore.prototype.hasImage = function (key, level) {
45610 return level in this._images && key in this._images[level];
45612 return ImageTileStore;
45614 exports.ImageTileStore = ImageTileStore;
45615 exports.default = ImageTileStore;
45617 },{}],424:[function(require,module,exports){
45619 Object.defineProperty(exports, "__esModule", { value: true });
45620 var Geo_1 = require("../Geo");
45622 * @class RegionOfInterestCalculator
45624 * @classdesc Represents a calculator for regions of interest.
45626 var RegionOfInterestCalculator = /** @class */ (function () {
45627 function RegionOfInterestCalculator() {
45628 this._viewportCoords = new Geo_1.ViewportCoords();
45631 * Compute a region of interest based on the current render camera
45632 * and the viewport size.
45634 * @param {RenderCamera} renderCamera - Render camera used for unprojections.
45635 * @param {ISize} size - Viewport size in pixels.
45636 * @param {Transform} transform - Transform used for projections.
45638 * @returns {IRegionOfInterest} A region of interest.
45640 RegionOfInterestCalculator.prototype.computeRegionOfInterest = function (renderCamera, size, transform) {
45641 var viewportBoundaryPoints = this._viewportBoundaryPoints(4);
45642 var bbox = this._viewportPointsBoundingBox(viewportBoundaryPoints, renderCamera, transform);
45643 this._clipBoundingBox(bbox);
45644 var viewportPixelWidth = 2 / size.width;
45645 var viewportPixelHeight = 2 / size.height;
45646 var centralViewportPixel = [
45647 [-0.5 * viewportPixelWidth, 0.5 * viewportPixelHeight],
45648 [0.5 * viewportPixelWidth, 0.5 * viewportPixelHeight],
45649 [0.5 * viewportPixelWidth, -0.5 * viewportPixelHeight],
45650 [-0.5 * viewportPixelWidth, -0.5 * viewportPixelHeight],
45652 var cpbox = this._viewportPointsBoundingBox(centralViewportPixel, renderCamera, transform);
45655 pixelHeight: cpbox.maxY - cpbox.minY,
45656 pixelWidth: cpbox.maxX - cpbox.minX + (cpbox.minX < cpbox.maxX ? 0 : 1),
45659 RegionOfInterestCalculator.prototype._viewportBoundaryPoints = function (pointsPerSide) {
45661 var os = [[-1, 1], [1, 1], [1, -1], [-1, -1]];
45662 var ds = [[2, 0], [0, -2], [-2, 0], [0, 2]];
45663 for (var side = 0; side < 4; ++side) {
45666 for (var i = 0; i < pointsPerSide; ++i) {
45667 points.push([o[0] + d[0] * i / pointsPerSide,
45668 o[1] + d[1] * i / pointsPerSide]);
45673 RegionOfInterestCalculator.prototype._viewportPointsBoundingBox = function (viewportPoints, renderCamera, transform) {
45675 var basicPoints = viewportPoints
45676 .map(function (point) {
45677 return _this._viewportCoords
45678 .viewportToBasic(point[0], point[1], transform, renderCamera.perspective);
45680 if (transform.gpano != null) {
45681 return this._boundingBoxPano(basicPoints);
45684 return this._boundingBox(basicPoints);
45687 RegionOfInterestCalculator.prototype._boundingBox = function (points) {
45689 maxX: Number.NEGATIVE_INFINITY,
45690 maxY: Number.NEGATIVE_INFINITY,
45691 minX: Number.POSITIVE_INFINITY,
45692 minY: Number.POSITIVE_INFINITY,
45694 for (var i = 0; i < points.length; ++i) {
45695 bbox.minX = Math.min(bbox.minX, points[i][0]);
45696 bbox.maxX = Math.max(bbox.maxX, points[i][0]);
45697 bbox.minY = Math.min(bbox.minY, points[i][1]);
45698 bbox.maxY = Math.max(bbox.maxY, points[i][1]);
45702 RegionOfInterestCalculator.prototype._boundingBoxPano = function (points) {
45706 for (var i = 0; i < points.length; ++i) {
45707 xs.push(points[i][0]);
45708 ys.push(points[i][1]);
45710 xs.sort(function (a, b) { return _this._sign(a - b); });
45711 ys.sort(function (a, b) { return _this._sign(a - b); });
45712 var intervalX = this._intervalPano(xs);
45714 maxX: intervalX[1],
45715 maxY: ys[ys.length - 1],
45716 minX: intervalX[0],
45721 * Find the max interval between consecutive numbers.
45722 * Assumes numbers are between 0 and 1, sorted and that
45723 * x is equivalent to x + 1.
45725 RegionOfInterestCalculator.prototype._intervalPano = function (xs) {
45728 for (var i = 0; i < xs.length - 1; ++i) {
45729 var dx = xs[i + 1] - xs[i];
45735 var loopdx = xs[0] + 1 - xs[xs.length - 1];
45736 if (loopdx > maxdx) {
45737 return [xs[0], xs[xs.length - 1]];
45740 return [xs[maxi + 1], xs[maxi]];
45743 RegionOfInterestCalculator.prototype._clipBoundingBox = function (bbox) {
45744 bbox.minX = Math.max(0, Math.min(1, bbox.minX));
45745 bbox.maxX = Math.max(0, Math.min(1, bbox.maxX));
45746 bbox.minY = Math.max(0, Math.min(1, bbox.minY));
45747 bbox.maxY = Math.max(0, Math.min(1, bbox.maxY));
45749 RegionOfInterestCalculator.prototype._sign = function (n) {
45750 return n > 0 ? 1 : n < 0 ? -1 : 0;
45752 return RegionOfInterestCalculator;
45754 exports.RegionOfInterestCalculator = RegionOfInterestCalculator;
45755 exports.default = RegionOfInterestCalculator;
45757 },{"../Geo":278}],425:[function(require,module,exports){
45759 Object.defineProperty(exports, "__esModule", { value: true });
45760 var operators_1 = require("rxjs/operators");
45761 var THREE = require("three");
45762 var rxjs_1 = require("rxjs");
45764 * @class TextureProvider
45766 * @classdesc Represents a provider of textures.
45768 var TextureProvider = /** @class */ (function () {
45770 * Create a new node texture provider instance.
45772 * @param {string} key - The identifier of the image for which to request tiles.
45773 * @param {number} width - The full width of the original image.
45774 * @param {number} height - The full height of the original image.
45775 * @param {number} tileSize - The size used when requesting tiles.
45776 * @param {HTMLImageElement} background - Image to use as background.
45777 * @param {ImageTileLoader} imageTileLoader - Loader for retrieving tiles.
45778 * @param {ImageTileStore} imageTileStore - Store for saving tiles.
45779 * @param {THREE.WebGLRenderer} renderer - Renderer used for rendering tiles to texture.
45781 function TextureProvider(key, width, height, tileSize, background, imageTileLoader, imageTileStore, renderer) {
45782 this._disposed = false;
45784 if (width <= 0 || height <= 0) {
45785 console.warn("Original image size (" + width + ", " + height + ") is invalid (" + key + "). Tiles will not be loaded.");
45787 this._width = width;
45788 this._height = height;
45789 this._maxLevel = Math.ceil(Math.log(Math.max(height, width)) / Math.log(2));
45790 this._currentLevel = -1;
45791 this._tileSize = tileSize;
45792 this._updated$ = new rxjs_1.Subject();
45793 this._createdSubject$ = new rxjs_1.Subject();
45794 this._created$ = this._createdSubject$.pipe(operators_1.publishReplay(1), operators_1.refCount());
45795 this._createdSubscription = this._created$.subscribe(function () { });
45796 this._hasSubject$ = new rxjs_1.Subject();
45797 this._has$ = this._hasSubject$.pipe(operators_1.startWith(false), operators_1.publishReplay(1), operators_1.refCount());
45798 this._hasSubscription = this._has$.subscribe(function () { });
45799 this._abortFunctions = [];
45800 this._tileSubscriptions = {};
45801 this._renderedCurrentLevelTiles = {};
45802 this._renderedTiles = {};
45803 this._background = background;
45804 this._camera = null;
45805 this._imageTileLoader = imageTileLoader;
45806 this._imageTileStore = imageTileStore;
45807 this._renderer = renderer;
45808 this._renderTarget = null;
45811 Object.defineProperty(TextureProvider.prototype, "disposed", {
45815 * @returns {boolean} Value indicating whether provider has
45819 return this._disposed;
45824 Object.defineProperty(TextureProvider.prototype, "hasTexture$", {
45828 * @returns {Observable<boolean>} Observable emitting
45829 * values indicating when the existance of a texture
45838 Object.defineProperty(TextureProvider.prototype, "key", {
45842 * @returns {boolean} The identifier of the image for
45843 * which to render textures.
45851 Object.defineProperty(TextureProvider.prototype, "textureUpdated$", {
45853 * Get textureUpdated$.
45855 * @returns {Observable<boolean>} Observable emitting
45856 * values when an existing texture has been updated.
45859 return this._updated$;
45864 Object.defineProperty(TextureProvider.prototype, "textureCreated$", {
45866 * Get textureCreated$.
45868 * @returns {Observable<boolean>} Observable emitting
45869 * values when a new texture has been created.
45872 return this._created$;
45878 * Abort all outstanding image tile requests.
45880 TextureProvider.prototype.abort = function () {
45881 for (var key in this._tileSubscriptions) {
45882 if (!this._tileSubscriptions.hasOwnProperty(key)) {
45885 this._tileSubscriptions[key].unsubscribe();
45887 this._tileSubscriptions = {};
45888 for (var _i = 0, _a = this._abortFunctions; _i < _a.length; _i++) {
45889 var abort = _a[_i];
45892 this._abortFunctions = [];
45895 * Dispose the provider.
45897 * @description Disposes all cached assets and
45898 * aborts all outstanding image tile requests.
45900 TextureProvider.prototype.dispose = function () {
45901 if (this._disposed) {
45902 console.warn("Texture already disposed (" + this._key + ")");
45906 if (this._renderTarget != null) {
45907 this._renderTarget.dispose();
45908 this._renderTarget = null;
45910 this._imageTileStore.dispose();
45911 this._imageTileStore = null;
45912 this._background = null;
45913 this._camera = null;
45914 this._imageTileLoader = null;
45915 this._renderer = null;
45917 this._createdSubscription.unsubscribe();
45918 this._hasSubscription.unsubscribe();
45919 this._disposed = true;
45922 * Set the region of interest.
45924 * @description When the region of interest is set the
45925 * the tile level is determined and tiles for the region
45926 * are fetched from the store or the loader and renderedLevel
45929 * @param {IRegionOfInterest} roi - Spatial edges to cache.
45931 TextureProvider.prototype.setRegionOfInterest = function (roi) {
45932 if (this._width <= 0 || this._height <= 0) {
45936 var width = 1 / this._roi.pixelWidth;
45937 var height = 1 / this._roi.pixelHeight;
45938 var size = Math.max(height, width);
45939 var currentLevel = Math.max(0, Math.min(this._maxLevel, Math.ceil(Math.log(size) / Math.log(2))));
45940 if (currentLevel !== this._currentLevel) {
45942 this._currentLevel = currentLevel;
45943 if (!(this._currentLevel in this._renderedTiles)) {
45944 this._renderedTiles[this._currentLevel] = [];
45946 this._renderedCurrentLevelTiles = {};
45947 for (var _i = 0, _a = this._renderedTiles[this._currentLevel]; _i < _a.length; _i++) {
45949 this._renderedCurrentLevelTiles[this._tileKey(this._tileSize, tile)] = true;
45952 var topLeft = this._getTileCoords([this._roi.bbox.minX, this._roi.bbox.minY]);
45953 var bottomRight = this._getTileCoords([this._roi.bbox.maxX, this._roi.bbox.maxY]);
45954 var tiles = this._getTiles(topLeft, bottomRight);
45955 if (this._camera == null) {
45956 this._camera = new THREE.OrthographicCamera(-this._width / 2, this._width / 2, this._height / 2, -this._height / 2, -1, 1);
45957 this._camera.position.z = 1;
45958 var gl = this._renderer.getContext();
45959 var maxTextureSize = gl.getParameter(gl.MAX_TEXTURE_SIZE);
45960 var backgroundSize = Math.max(this._width, this._height);
45961 var scale = maxTextureSize > backgroundSize ? 1 : maxTextureSize / backgroundSize;
45962 var targetWidth = Math.floor(scale * this._width);
45963 var targetHeight = Math.floor(scale * this._height);
45964 this._renderTarget = new THREE.WebGLRenderTarget(targetWidth, targetHeight, {
45965 depthBuffer: false,
45966 format: THREE.RGBFormat,
45967 magFilter: THREE.LinearFilter,
45968 minFilter: THREE.LinearFilter,
45969 stencilBuffer: false,
45971 this._renderToTarget(0, 0, this._width, this._height, this._background);
45972 this._createdSubject$.next(this._renderTarget.texture);
45973 this._hasSubject$.next(true);
45975 this._fetchTiles(tiles);
45977 TextureProvider.prototype.setTileSize = function (tileSize) {
45978 this._tileSize = tileSize;
45981 * Update the image used as background for the texture.
45983 * @param {HTMLImageElement} background - The background image.
45985 TextureProvider.prototype.updateBackground = function (background) {
45986 this._background = background;
45989 * Retrieve an image tile.
45991 * @description Retrieve an image tile and render it to the
45992 * texture. Add the tile to the store and emit to the updated
45995 * @param {Array<number>} tile - The tile coordinates.
45996 * @param {number} level - The tile level.
45997 * @param {number} x - The top left x pixel coordinate of the tile.
45998 * @param {number} y - The top left y pixel coordinate of the tile.
45999 * @param {number} w - The pixel width of the tile.
46000 * @param {number} h - The pixel height of the tile.
46001 * @param {number} scaledW - The scaled width of the returned tile.
46002 * @param {number} scaledH - The scaled height of the returned tile.
46004 TextureProvider.prototype._fetchTile = function (tile, level, x, y, w, h, scaledX, scaledY) {
46006 var getTile = this._imageTileLoader.getTile(this._key, x, y, w, h, scaledX, scaledY);
46007 var tile$ = getTile[0];
46008 var abort = getTile[1];
46009 this._abortFunctions.push(abort);
46010 var tileKey = this._tileKey(this._tileSize, tile);
46011 var subscription = tile$
46012 .subscribe(function (image) {
46013 _this._renderToTarget(x, y, w, h, image);
46014 _this._removeFromDictionary(tileKey, _this._tileSubscriptions);
46015 _this._removeFromArray(abort, _this._abortFunctions);
46016 _this._setTileRendered(tile, _this._currentLevel);
46017 _this._imageTileStore.addImage(image, tileKey, level);
46018 _this._updated$.next(true);
46019 }, function (error) {
46020 _this._removeFromDictionary(tileKey, _this._tileSubscriptions);
46021 _this._removeFromArray(abort, _this._abortFunctions);
46022 console.error(error);
46024 if (!subscription.closed) {
46025 this._tileSubscriptions[tileKey] = subscription;
46029 * Retrieve image tiles.
46031 * @description Retrieve a image tiles and render them to the
46032 * texture. Retrieve from store if it exists, otherwise Retrieve
46035 * @param {Array<Array<number>>} tiles - Array of tile coordinates to
46038 TextureProvider.prototype._fetchTiles = function (tiles) {
46039 var tileSize = this._tileSize * Math.pow(2, this._maxLevel - this._currentLevel);
46040 for (var _i = 0, tiles_1 = tiles; _i < tiles_1.length; _i++) {
46041 var tile = tiles_1[_i];
46042 var tileKey = this._tileKey(this._tileSize, tile);
46043 if (tileKey in this._renderedCurrentLevelTiles ||
46044 tileKey in this._tileSubscriptions) {
46047 var tileX = tileSize * tile[0];
46048 var tileY = tileSize * tile[1];
46049 var tileWidth = tileX + tileSize > this._width ? this._width - tileX : tileSize;
46050 var tileHeight = tileY + tileSize > this._height ? this._height - tileY : tileSize;
46051 if (this._imageTileStore.hasImage(tileKey, this._currentLevel)) {
46052 this._renderToTarget(tileX, tileY, tileWidth, tileHeight, this._imageTileStore.getImage(tileKey, this._currentLevel));
46053 this._setTileRendered(tile, this._currentLevel);
46054 this._updated$.next(true);
46057 var scaledX = Math.floor(tileWidth / tileSize * this._tileSize);
46058 var scaledY = Math.floor(tileHeight / tileSize * this._tileSize);
46059 this._fetchTile(tile, this._currentLevel, tileX, tileY, tileWidth, tileHeight, scaledX, scaledY);
46063 * Get tile coordinates for a point using the current level.
46065 * @param {Array<number>} point - Point in basic coordinates.
46067 * @returns {Array<number>} x and y tile coodinates.
46069 TextureProvider.prototype._getTileCoords = function (point) {
46070 var tileSize = this._tileSize * Math.pow(2, this._maxLevel - this._currentLevel);
46071 var maxX = Math.ceil(this._width / tileSize) - 1;
46072 var maxY = Math.ceil(this._height / tileSize) - 1;
46074 Math.min(Math.floor(this._width * point[0] / tileSize), maxX),
46075 Math.min(Math.floor(this._height * point[1] / tileSize), maxY),
46079 * Get tile coordinates for all tiles contained in a bounding
46082 * @param {Array<number>} topLeft - Top left tile coordinate of bounding box.
46083 * @param {Array<number>} bottomRight - Bottom right tile coordinate of bounding box.
46085 * @returns {Array<Array<number>>} Array of x, y tile coodinates.
46087 TextureProvider.prototype._getTiles = function (topLeft, bottomRight) {
46089 if (topLeft[0] > bottomRight[0]) {
46090 var tileSize = this._tileSize * Math.pow(2, this._maxLevel - this._currentLevel);
46091 var maxX = Math.ceil(this._width / tileSize) - 1;
46092 for (var x = topLeft[0]; x <= maxX; x++) {
46095 for (var x = 0; x <= bottomRight[0]; x++) {
46100 for (var x = topLeft[0]; x <= bottomRight[0]; x++) {
46105 for (var _i = 0, xs_1 = xs; _i < xs_1.length; _i++) {
46107 for (var y = topLeft[1]; y <= bottomRight[1]; y++) {
46108 tiles.push([x, y]);
46114 * Remove an item from an array if it exists in array.
46116 * @param {T} item - Item to remove.
46117 * @param {Array<T>} array - Array from which item should be removed.
46119 TextureProvider.prototype._removeFromArray = function (item, array) {
46120 var index = array.indexOf(item);
46121 if (index !== -1) {
46122 array.splice(index, 1);
46126 * Remove an item from a dictionary.
46128 * @param {string} key - Key of the item to remove.
46129 * @param {Object} dict - Dictionary from which item should be removed.
46131 TextureProvider.prototype._removeFromDictionary = function (key, dict) {
46137 * Render an image tile to the target texture.
46139 * @param {number} x - The top left x pixel coordinate of the tile.
46140 * @param {number} y - The top left y pixel coordinate of the tile.
46141 * @param {number} w - The pixel width of the tile.
46142 * @param {number} h - The pixel height of the tile.
46143 * @param {HTMLImageElement} background - The image tile to render.
46145 TextureProvider.prototype._renderToTarget = function (x, y, w, h, image) {
46146 var texture = new THREE.Texture(image);
46147 texture.minFilter = THREE.LinearFilter;
46148 texture.needsUpdate = true;
46149 var geometry = new THREE.PlaneGeometry(w, h);
46150 var material = new THREE.MeshBasicMaterial({ map: texture, side: THREE.FrontSide });
46151 var mesh = new THREE.Mesh(geometry, material);
46152 mesh.position.x = -this._width / 2 + x + w / 2;
46153 mesh.position.y = this._height / 2 - y - h / 2;
46154 var scene = new THREE.Scene();
46156 this._renderer.render(scene, this._camera, this._renderTarget);
46157 this._renderer.setRenderTarget(undefined);
46158 scene.remove(mesh);
46159 geometry.dispose();
46160 material.dispose();
46164 * Mark a tile as rendered.
46166 * @description Clears tiles marked as rendered in other
46167 * levels of the tile pyramid if they were rendered on
46168 * top of or below the tile.
46170 * @param {Arrary<number>} tile - The tile coordinates.
46171 * @param {number} level - Tile level of the tile coordinates.
46173 TextureProvider.prototype._setTileRendered = function (tile, level) {
46174 var otherLevels = Object.keys(this._renderedTiles)
46175 .map(function (key) {
46176 return parseInt(key, 10);
46178 .filter(function (renderedLevel) {
46179 return renderedLevel !== level;
46181 for (var _i = 0, otherLevels_1 = otherLevels; _i < otherLevels_1.length; _i++) {
46182 var otherLevel = otherLevels_1[_i];
46183 var scale = Math.pow(2, otherLevel - level);
46184 if (otherLevel < level) {
46185 var x = Math.floor(scale * tile[0]);
46186 var y = Math.floor(scale * tile[1]);
46187 for (var _a = 0, _b = this._renderedTiles[otherLevel].slice(); _a < _b.length; _a++) {
46188 var otherTile = _b[_a];
46189 if (otherTile[0] === x && otherTile[1] === y) {
46190 var index = this._renderedTiles[otherLevel].indexOf(otherTile);
46191 this._renderedTiles[otherLevel].splice(index, 1);
46196 var startX = scale * tile[0];
46197 var endX = startX + scale - 1;
46198 var startY = scale * tile[1];
46199 var endY = startY + scale - 1;
46200 for (var _c = 0, _d = this._renderedTiles[otherLevel].slice(); _c < _d.length; _c++) {
46201 var otherTile = _d[_c];
46202 if (otherTile[0] >= startX && otherTile[0] <= endX &&
46203 otherTile[1] >= startY && otherTile[1] <= endY) {
46204 var index = this._renderedTiles[otherLevel].indexOf(otherTile);
46205 this._renderedTiles[otherLevel].splice(index, 1);
46209 if (this._renderedTiles[otherLevel].length === 0) {
46210 delete this._renderedTiles[otherLevel];
46213 this._renderedTiles[level].push(tile);
46214 this._renderedCurrentLevelTiles[this._tileKey(this._tileSize, tile)] = true;
46217 * Create a tile key from a tile coordinates.
46219 * @description Tile keys are used as a hash for
46220 * storing the tile in a dictionary.
46222 * @param {number} tileSize - The tile size.
46223 * @param {Arrary<number>} tile - The tile coordinates.
46225 TextureProvider.prototype._tileKey = function (tileSize, tile) {
46226 return tileSize + "-" + tile[0] + "-" + tile[1];
46228 return TextureProvider;
46230 exports.TextureProvider = TextureProvider;
46231 exports.default = TextureProvider;
46233 },{"rxjs":27,"rxjs/operators":225,"three":226}],426:[function(require,module,exports){
46235 Object.defineProperty(exports, "__esModule", { value: true });
46236 var DOM = /** @class */ (function () {
46237 function DOM(doc) {
46238 this._document = !!doc ? doc : document;
46240 Object.defineProperty(DOM.prototype, "document", {
46242 return this._document;
46247 DOM.prototype.createElement = function (tagName, className, container) {
46248 var element = this._document.createElement(tagName);
46250 element.className = className;
46253 container.appendChild(element);
46260 exports.default = DOM;
46262 },{}],427:[function(require,module,exports){
46264 Object.defineProperty(exports, "__esModule", { value: true });
46265 var EventEmitter = /** @class */ (function () {
46266 function EventEmitter() {
46270 * Subscribe to an event by its name.
46271 * @param {string }eventType - The name of the event to subscribe to.
46272 * @param {any} fn - The handler called when the event occurs.
46274 EventEmitter.prototype.on = function (eventType, fn) {
46275 this._events[eventType] = this._events[eventType] || [];
46276 this._events[eventType].push(fn);
46280 * Unsubscribe from an event by its name.
46281 * @param {string} eventType - The name of the event to subscribe to.
46282 * @param {any} fn - The handler to remove.
46284 EventEmitter.prototype.off = function (eventType, fn) {
46289 if (!this._listens(eventType)) {
46290 var idx = this._events[eventType].indexOf(fn);
46292 this._events[eventType].splice(idx, 1);
46294 if (this._events[eventType].length) {
46295 delete this._events[eventType];
46299 delete this._events[eventType];
46303 EventEmitter.prototype.fire = function (eventType, data) {
46304 if (!this._listens(eventType)) {
46307 for (var _i = 0, _a = this._events[eventType]; _i < _a.length; _i++) {
46309 fn.call(this, data);
46313 EventEmitter.prototype._listens = function (eventType) {
46314 return !!(this._events && this._events[eventType]);
46316 return EventEmitter;
46318 exports.EventEmitter = EventEmitter;
46319 exports.default = EventEmitter;
46321 },{}],428:[function(require,module,exports){
46323 Object.defineProperty(exports, "__esModule", { value: true });
46324 var Viewer_1 = require("../Viewer");
46325 var Settings = /** @class */ (function () {
46326 function Settings() {
46328 Settings.setOptions = function (options) {
46329 Settings._baseImageSize = options.baseImageSize != null ?
46330 options.baseImageSize :
46331 Viewer_1.ImageSize.Size640;
46332 Settings._basePanoramaSize = options.basePanoramaSize != null ?
46333 options.basePanoramaSize :
46334 Viewer_1.ImageSize.Size2048;
46335 Settings._maxImageSize = options.maxImageSize != null ?
46336 options.maxImageSize :
46337 Viewer_1.ImageSize.Size2048;
46339 Object.defineProperty(Settings, "baseImageSize", {
46341 return Settings._baseImageSize;
46346 Object.defineProperty(Settings, "basePanoramaSize", {
46348 return Settings._basePanoramaSize;
46353 Object.defineProperty(Settings, "maxImageSize", {
46355 return Settings._maxImageSize;
46362 exports.Settings = Settings;
46363 exports.default = Settings;
46365 },{"../Viewer":286}],429:[function(require,module,exports){
46367 Object.defineProperty(exports, "__esModule", { value: true });
46368 function isBrowser() {
46369 return typeof window !== "undefined" && typeof document !== "undefined";
46371 exports.isBrowser = isBrowser;
46372 function isArraySupported() {
46373 return !!(Array.prototype &&
46374 Array.prototype.filter &&
46375 Array.prototype.indexOf &&
46376 Array.prototype.map &&
46377 Array.prototype.reverse);
46379 exports.isArraySupported = isArraySupported;
46380 function isFunctionSupported() {
46381 return !!(Function.prototype && Function.prototype.bind);
46383 exports.isFunctionSupported = isFunctionSupported;
46384 function isJSONSupported() {
46385 return "JSON" in window && "parse" in JSON && "stringify" in JSON;
46387 exports.isJSONSupported = isJSONSupported;
46388 function isObjectSupported() {
46389 return !!(Object.keys &&
46392 exports.isObjectSupported = isObjectSupported;
46393 function isBlobSupported() {
46394 return "Blob" in window && "URL" in window;
46396 exports.isBlobSupported = isBlobSupported;
46397 var isWebGLSupportedCache = undefined;
46398 function isWebGLSupportedCached() {
46399 if (isWebGLSupportedCache === undefined) {
46400 isWebGLSupportedCache = isWebGLSupported();
46402 return isWebGLSupportedCache;
46404 exports.isWebGLSupportedCached = isWebGLSupportedCached;
46405 function isWebGLSupported() {
46406 var webGLContextAttributes = {
46410 failIfMajorPerformanceCaveat: false,
46411 premultipliedAlpha: true,
46412 preserveDrawingBuffer: false,
46415 var canvas = document.createElement("canvas");
46416 var context = canvas.getContext("webgl", webGLContextAttributes) ||
46417 canvas.getContext("experimental-webgl", webGLContextAttributes);
46421 var requiredExtensions = [
46422 "OES_standard_derivatives",
46424 var supportedExtensions = context.getSupportedExtensions();
46425 for (var _i = 0, requiredExtensions_1 = requiredExtensions; _i < requiredExtensions_1.length; _i++) {
46426 var requiredExtension = requiredExtensions_1[_i];
46427 if (supportedExtensions.indexOf(requiredExtension) === -1) {
46433 exports.isWebGLSupported = isWebGLSupported;
46435 },{}],430:[function(require,module,exports){
46437 Object.defineProperty(exports, "__esModule", { value: true });
46438 var Urls = /** @class */ (function () {
46441 Object.defineProperty(Urls, "explore", {
46443 return Urls._scheme + "://" + Urls._exploreHost;
46448 Object.defineProperty(Urls, "origin", {
46450 return Urls._origin;
46455 Object.defineProperty(Urls, "tileScheme", {
46457 return Urls._scheme;
46462 Object.defineProperty(Urls, "tileDomain", {
46464 return Urls._imageTileHost;
46469 Urls.atomicReconstruction = function (key) {
46470 return Urls._scheme + "://" + Urls._atomicReconstructionHost + "/" + key + "/sfm/v1.0/atomic_reconstruction.json";
46472 Urls.exporeImage = function (key) {
46473 return Urls._scheme + "://" + Urls._exploreHost + "/app/?pKey=" + key + "&focus=photo";
46475 Urls.exporeUser = function (username) {
46476 return Urls._scheme + "://" + Urls._exploreHost + "/app/user/" + username;
46478 Urls.falcorModel = function (clientId) {
46479 return Urls._scheme + "://" + Urls._apiHost + "/v3/model.json?client_id=" + clientId;
46481 Urls.protoMesh = function (key) {
46482 return Urls._scheme + "://" + Urls._meshHost + "/v2/mesh/" + key;
46484 Urls.thumbnail = function (key, size, origin) {
46485 var query = !!origin ? "?origin=" + origin : "";
46486 return Urls._scheme + "://" + Urls._imageHost + "/" + key + "/thumb-" + size + ".jpg" + query;
46488 Urls.setOptions = function (options) {
46492 if (!!options.apiHost) {
46493 Urls._apiHost = options.apiHost;
46495 if (!!options.atomicReconstructionHost) {
46496 Urls._atomicReconstructionHost = options.atomicReconstructionHost;
46498 if (!!options.exploreHost) {
46499 Urls._exploreHost = options.exploreHost;
46501 if (!!options.imageHost) {
46502 Urls._imageHost = options.imageHost;
46504 if (!!options.imageTileHost) {
46505 Urls._imageTileHost = options.imageTileHost;
46507 if (!!options.meshHost) {
46508 Urls._meshHost = options.meshHost;
46510 if (!!options.scheme) {
46511 Urls._scheme = options.scheme;
46514 Urls._apiHost = "a.mapillary.com";
46515 Urls._atomicReconstructionHost = "d3necqxnn15whe.cloudfront.net";
46516 Urls._exploreHost = "www.mapillary.com";
46517 Urls._imageHost = "d1cuyjsrcm0gby.cloudfront.net";
46518 Urls._imageTileHost = "d2qb1440i7l50o.cloudfront.net";
46519 Urls._meshHost = "d1brzeo354iq2l.cloudfront.net";
46520 Urls._origin = "mapillary.webgl";
46521 Urls._scheme = "https";
46524 exports.Urls = Urls;
46525 exports.default = Urls;
46527 },{}],431:[function(require,module,exports){
46529 Object.defineProperty(exports, "__esModule", { value: true });
46531 * Enumeration for alignments
46536 (function (Alignment) {
46540 Alignment[Alignment["Bottom"] = 0] = "Bottom";
46542 * Align to bottom left
46544 Alignment[Alignment["BottomLeft"] = 1] = "BottomLeft";
46546 * Align to bottom right
46548 Alignment[Alignment["BottomRight"] = 2] = "BottomRight";
46552 Alignment[Alignment["Center"] = 3] = "Center";
46556 Alignment[Alignment["Left"] = 4] = "Left";
46560 Alignment[Alignment["Right"] = 5] = "Right";
46564 Alignment[Alignment["Top"] = 6] = "Top";
46566 * Align to top left
46568 Alignment[Alignment["TopLeft"] = 7] = "TopLeft";
46570 * Align to top right
46572 Alignment[Alignment["TopRight"] = 8] = "TopRight";
46573 })(Alignment = exports.Alignment || (exports.Alignment = {}));
46574 exports.default = Alignment;
46576 },{}],432:[function(require,module,exports){
46578 Object.defineProperty(exports, "__esModule", { value: true });
46579 var rxjs_1 = require("rxjs");
46580 var operators_1 = require("rxjs/operators");
46581 var Graph_1 = require("../Graph");
46582 var CacheService = /** @class */ (function () {
46583 function CacheService(graphService, stateService) {
46584 this._graphService = graphService;
46585 this._stateService = stateService;
46586 this._started = false;
46588 Object.defineProperty(CacheService.prototype, "started", {
46590 return this._started;
46595 CacheService.prototype.start = function () {
46597 if (this._started) {
46600 this._uncacheSubscription = this._stateService.currentState$.pipe(operators_1.distinctUntilChanged(undefined, function (frame) {
46601 return frame.state.currentNode.key;
46602 }), operators_1.map(function (frame) {
46603 var trajectory = frame.state.trajectory;
46604 var trajectoryKeys = trajectory
46605 .map(function (n) {
46608 var sequenceKey = trajectory[trajectory.length - 1].sequenceKey;
46609 return [trajectoryKeys, sequenceKey];
46610 }), operators_1.bufferCount(1, 5), operators_1.withLatestFrom(this._graphService.graphMode$), operators_1.switchMap(function (_a) {
46611 var keepBuffer = _a[0], graphMode = _a[1];
46612 var keepKeys = keepBuffer[0][0];
46613 var keepSequenceKey = graphMode === Graph_1.GraphMode.Sequence ?
46614 keepBuffer[0][1] : undefined;
46615 return _this._graphService.uncache$(keepKeys, keepSequenceKey);
46617 .subscribe(function () { });
46618 this._cacheNodeSubscription = this._graphService.graphMode$.pipe(operators_1.skip(1), operators_1.withLatestFrom(this._stateService.currentState$), operators_1.switchMap(function (_a) {
46619 var mode = _a[0], frame = _a[1];
46620 return mode === Graph_1.GraphMode.Sequence ?
46621 _this._keyToEdges(frame.state.currentNode.key, function (node) {
46622 return node.sequenceEdges$;
46624 rxjs_1.from(frame.state.trajectory
46625 .map(function (node) {
46628 .slice(frame.state.currentIndex)).pipe(operators_1.mergeMap(function (key) {
46629 return _this._keyToEdges(key, function (node) {
46630 return node.spatialEdges$;
46634 .subscribe(function () { });
46635 this._started = true;
46637 CacheService.prototype.stop = function () {
46638 if (!this._started) {
46641 this._uncacheSubscription.unsubscribe();
46642 this._uncacheSubscription = null;
46643 this._cacheNodeSubscription.unsubscribe();
46644 this._cacheNodeSubscription = null;
46645 this._started = false;
46647 CacheService.prototype._keyToEdges = function (key, nodeToEdgeMap) {
46648 return this._graphService.cacheNode$(key).pipe(operators_1.switchMap(nodeToEdgeMap), operators_1.first(function (status) {
46649 return status.cached;
46650 }), operators_1.timeout(15000), operators_1.catchError(function (error) {
46651 console.error("Failed to cache edges (" + key + ").", error);
46652 return rxjs_1.empty();
46655 return CacheService;
46657 exports.CacheService = CacheService;
46658 exports.default = CacheService;
46660 },{"../Graph":279,"rxjs":27,"rxjs/operators":225}],433:[function(require,module,exports){
46662 Object.defineProperty(exports, "__esModule", { value: true });
46663 var operators_1 = require("rxjs/operators");
46664 var Component_1 = require("../Component");
46665 var ComponentController = /** @class */ (function () {
46666 function ComponentController(container, navigator, observer, key, options, componentService) {
46668 this._container = container;
46669 this._observer = observer;
46670 this._navigator = navigator;
46671 this._options = options != null ? options : {};
46673 this._navigable = key == null;
46674 this._componentService = !!componentService ?
46676 new Component_1.ComponentService(this._container, this._navigator);
46677 this._coverComponent = this._componentService.getCover();
46678 this._initializeComponents();
46680 this._initilizeCoverComponent();
46681 this._subscribeCoverComponent();
46684 this._navigator.movedToKey$.pipe(operators_1.first(function (k) {
46687 .subscribe(function (k) {
46689 _this._componentService.deactivateCover();
46690 _this._coverComponent.configure({ key: _this._key, state: Component_1.CoverState.Hidden });
46691 _this._subscribeCoverComponent();
46692 _this._navigator.stateService.start();
46693 _this._navigator.cacheService.start();
46694 _this._observer.startEmit();
46698 Object.defineProperty(ComponentController.prototype, "navigable", {
46700 return this._navigable;
46705 ComponentController.prototype.get = function (name) {
46706 return this._componentService.get(name);
46708 ComponentController.prototype.activate = function (name) {
46709 this._componentService.activate(name);
46711 ComponentController.prototype.activateCover = function () {
46712 this._coverComponent.configure({ state: Component_1.CoverState.Visible });
46714 ComponentController.prototype.deactivate = function (name) {
46715 this._componentService.deactivate(name);
46717 ComponentController.prototype.deactivateCover = function () {
46718 this._coverComponent.configure({ state: Component_1.CoverState.Loading });
46720 ComponentController.prototype._initializeComponents = function () {
46721 var options = this._options;
46722 this._uFalse(options.background, "background");
46723 this._uFalse(options.debug, "debug");
46724 this._uFalse(options.image, "image");
46725 this._uFalse(options.marker, "marker");
46726 this._uFalse(options.navigation, "navigation");
46727 this._uFalse(options.popup, "popup");
46728 this._uFalse(options.route, "route");
46729 this._uFalse(options.slider, "slider");
46730 this._uFalse(options.spatialData, "spatialData");
46731 this._uFalse(options.tag, "tag");
46732 this._uTrue(options.attribution, "attribution");
46733 this._uTrue(options.bearing, "bearing");
46734 this._uTrue(options.cache, "cache");
46735 this._uTrue(options.direction, "direction");
46736 this._uTrue(options.imagePlane, "imagePlane");
46737 this._uTrue(options.keyboard, "keyboard");
46738 this._uTrue(options.loading, "loading");
46739 this._uTrue(options.mouse, "mouse");
46740 this._uTrue(options.sequence, "sequence");
46741 this._uTrue(options.stats, "stats");
46742 this._uTrue(options.zoom, "zoom");
46744 ComponentController.prototype._initilizeCoverComponent = function () {
46745 var options = this._options;
46746 this._coverComponent.configure({ key: this._key });
46747 if (options.cover === undefined || options.cover) {
46748 this.activateCover();
46751 this.deactivateCover();
46754 ComponentController.prototype._setNavigable = function (navigable) {
46755 if (this._navigable === navigable) {
46758 this._navigable = navigable;
46759 this._observer.navigable$.next(navigable);
46761 ComponentController.prototype._subscribeCoverComponent = function () {
46763 this._coverComponent.configuration$.pipe(operators_1.distinctUntilChanged(undefined, function (c) {
46766 .subscribe(function (conf) {
46767 if (conf.state === Component_1.CoverState.Loading) {
46768 _this._navigator.stateService.currentKey$.pipe(operators_1.first(), operators_1.switchMap(function (key) {
46769 var keyChanged = key == null || key !== conf.key;
46771 _this._setNavigable(false);
46773 return keyChanged ?
46774 _this._navigator.moveToKey$(conf.key) :
46775 _this._navigator.stateService.currentNode$.pipe(operators_1.first());
46777 .subscribe(function () {
46778 _this._navigator.stateService.start();
46779 _this._navigator.cacheService.start();
46780 _this._observer.startEmit();
46781 _this._coverComponent.configure({ state: Component_1.CoverState.Hidden });
46782 _this._componentService.deactivateCover();
46783 _this._setNavigable(true);
46784 }, function (error) {
46785 console.error("Failed to deactivate cover.", error);
46786 _this._coverComponent.configure({ state: Component_1.CoverState.Visible });
46789 else if (conf.state === Component_1.CoverState.Visible) {
46790 _this._observer.stopEmit();
46791 _this._navigator.stateService.stop();
46792 _this._navigator.cacheService.stop();
46793 _this._navigator.playService.stop();
46794 _this._componentService.activateCover();
46795 _this._setNavigable(conf.key == null);
46799 ComponentController.prototype._uFalse = function (option, name) {
46800 if (option === undefined) {
46801 this._componentService.deactivate(name);
46804 if (typeof option === "boolean") {
46806 this._componentService.activate(name);
46809 this._componentService.deactivate(name);
46813 this._componentService.configure(name, option);
46814 this._componentService.activate(name);
46816 ComponentController.prototype._uTrue = function (option, name) {
46817 if (option === undefined) {
46818 this._componentService.activate(name);
46821 if (typeof option === "boolean") {
46823 this._componentService.activate(name);
46826 this._componentService.deactivate(name);
46830 this._componentService.configure(name, option);
46831 this._componentService.activate(name);
46833 return ComponentController;
46835 exports.ComponentController = ComponentController;
46837 },{"../Component":275,"rxjs/operators":225}],434:[function(require,module,exports){
46839 Object.defineProperty(exports, "__esModule", { value: true });
46840 var Render_1 = require("../Render");
46841 var Utils_1 = require("../Utils");
46842 var Viewer_1 = require("../Viewer");
46843 var Container = /** @class */ (function () {
46844 function Container(id, stateService, options, dom) {
46846 this._dom = !!dom ? dom : new Utils_1.DOM();
46847 this._container = this._dom.document.getElementById(id);
46848 if (!this._container) {
46849 throw new Error("Container '" + id + "' not found.");
46851 this._container.classList.add("mapillary-js");
46852 this._canvasContainer = this._dom.createElement("div", "mapillary-js-interactive", this._container);
46853 this._domContainer = this._dom.createElement("div", "mapillary-js-dom", this._container);
46854 this.renderService = new Render_1.RenderService(this._container, stateService.currentState$, options.renderMode);
46855 this.glRenderer = new Render_1.GLRenderer(this._canvasContainer, this.renderService, this._dom);
46856 this.domRenderer = new Render_1.DOMRenderer(this._domContainer, this.renderService, stateService.currentState$);
46857 this.keyboardService = new Viewer_1.KeyboardService(this._canvasContainer);
46858 this.mouseService = new Viewer_1.MouseService(this._container, this._canvasContainer, this._domContainer, document);
46859 this.touchService = new Viewer_1.TouchService(this._canvasContainer, this._domContainer);
46860 this.spriteService = new Viewer_1.SpriteService(options.sprite);
46862 Object.defineProperty(Container.prototype, "element", {
46864 return this._container;
46869 Object.defineProperty(Container.prototype, "canvasContainer", {
46871 return this._canvasContainer;
46876 Object.defineProperty(Container.prototype, "domContainer", {
46878 return this._domContainer;
46885 exports.Container = Container;
46886 exports.default = Container;
46888 },{"../Render":281,"../Utils":285,"../Viewer":286}],435:[function(require,module,exports){
46890 Object.defineProperty(exports, "__esModule", { value: true });
46892 * Enumeration for image sizes
46895 * @description Image sizes in pixels for the long side of the image.
46898 (function (ImageSize) {
46900 * 320 pixels image size
46902 ImageSize[ImageSize["Size320"] = 320] = "Size320";
46904 * 640 pixels image size
46906 ImageSize[ImageSize["Size640"] = 640] = "Size640";
46908 * 1024 pixels image size
46910 ImageSize[ImageSize["Size1024"] = 1024] = "Size1024";
46912 * 2048 pixels image size
46914 ImageSize[ImageSize["Size2048"] = 2048] = "Size2048";
46915 })(ImageSize = exports.ImageSize || (exports.ImageSize = {}));
46917 },{}],436:[function(require,module,exports){
46919 Object.defineProperty(exports, "__esModule", { value: true });
46920 var rxjs_1 = require("rxjs");
46921 var KeyboardService = /** @class */ (function () {
46922 function KeyboardService(canvasContainer) {
46923 this._keyDown$ = rxjs_1.fromEvent(canvasContainer, "keydown");
46924 this._keyUp$ = rxjs_1.fromEvent(canvasContainer, "keyup");
46926 Object.defineProperty(KeyboardService.prototype, "keyDown$", {
46928 return this._keyDown$;
46933 Object.defineProperty(KeyboardService.prototype, "keyUp$", {
46935 return this._keyUp$;
46940 return KeyboardService;
46942 exports.KeyboardService = KeyboardService;
46943 exports.default = KeyboardService;
46945 },{"rxjs":27}],437:[function(require,module,exports){
46947 Object.defineProperty(exports, "__esModule", { value: true });
46948 var operators_1 = require("rxjs/operators");
46949 var rxjs_1 = require("rxjs");
46950 var LoadingService = /** @class */ (function () {
46951 function LoadingService() {
46952 this._loadersSubject$ = new rxjs_1.Subject();
46953 this._loaders$ = this._loadersSubject$.pipe(operators_1.scan(function (loaders, loader) {
46954 if (loader.task !== undefined) {
46955 loaders[loader.task] = loader.loading;
46958 }, {}), operators_1.startWith({}), operators_1.publishReplay(1), operators_1.refCount());
46960 Object.defineProperty(LoadingService.prototype, "loading$", {
46962 return this._loaders$.pipe(operators_1.map(function (loaders) {
46963 for (var key in loaders) {
46964 if (!loaders.hasOwnProperty(key)) {
46967 if (loaders[key]) {
46972 }), operators_1.debounceTime(100), operators_1.distinctUntilChanged());
46977 LoadingService.prototype.taskLoading$ = function (task) {
46978 return this._loaders$.pipe(operators_1.map(function (loaders) {
46979 return !!loaders[task];
46980 }), operators_1.debounceTime(100), operators_1.distinctUntilChanged());
46982 LoadingService.prototype.startLoading = function (task) {
46983 this._loadersSubject$.next({ loading: true, task: task });
46985 LoadingService.prototype.stopLoading = function (task) {
46986 this._loadersSubject$.next({ loading: false, task: task });
46988 return LoadingService;
46990 exports.LoadingService = LoadingService;
46991 exports.default = LoadingService;
46993 },{"rxjs":27,"rxjs/operators":225}],438:[function(require,module,exports){
46995 Object.defineProperty(exports, "__esModule", { value: true });
46996 var rxjs_1 = require("rxjs");
46997 var operators_1 = require("rxjs/operators");
46998 var MouseService = /** @class */ (function () {
46999 function MouseService(container, canvasContainer, domContainer, doc) {
47001 this._activeSubject$ = new rxjs_1.BehaviorSubject(false);
47002 this._active$ = this._activeSubject$.pipe(operators_1.distinctUntilChanged(), operators_1.publishReplay(1), operators_1.refCount());
47003 this._claimMouse$ = new rxjs_1.Subject();
47004 this._claimWheel$ = new rxjs_1.Subject();
47005 this._deferPixelClaims$ = new rxjs_1.Subject();
47006 this._deferPixels$ = this._deferPixelClaims$.pipe(operators_1.scan(function (claims, claim) {
47007 if (claim.deferPixels == null) {
47008 delete claims[claim.name];
47011 claims[claim.name] = claim.deferPixels;
47014 }, {}), operators_1.map(function (claims) {
47015 var deferPixelMax = -1;
47016 for (var key in claims) {
47017 if (!claims.hasOwnProperty(key)) {
47020 var deferPixels = claims[key];
47021 if (deferPixels > deferPixelMax) {
47022 deferPixelMax = deferPixels;
47025 return deferPixelMax;
47026 }), operators_1.startWith(-1), operators_1.publishReplay(1), operators_1.refCount());
47027 this._deferPixels$.subscribe(function () { });
47028 this._documentMouseMove$ = rxjs_1.fromEvent(doc, "mousemove");
47029 this._documentMouseUp$ = rxjs_1.fromEvent(doc, "mouseup");
47030 this._mouseDown$ = rxjs_1.fromEvent(canvasContainer, "mousedown");
47031 this._mouseLeave$ = rxjs_1.fromEvent(canvasContainer, "mouseleave");
47032 this._mouseMove$ = rxjs_1.fromEvent(canvasContainer, "mousemove");
47033 this._mouseUp$ = rxjs_1.fromEvent(canvasContainer, "mouseup");
47034 this._mouseOut$ = rxjs_1.fromEvent(canvasContainer, "mouseout");
47035 this._mouseOver$ = rxjs_1.fromEvent(canvasContainer, "mouseover");
47036 this._domMouseDown$ = rxjs_1.fromEvent(domContainer, "mousedown");
47037 this._domMouseMove$ = rxjs_1.fromEvent(domContainer, "mousemove");
47038 this._click$ = rxjs_1.fromEvent(canvasContainer, "click");
47039 this._contextMenu$ = rxjs_1.fromEvent(canvasContainer, "contextmenu");
47040 this._dblClick$ = rxjs_1.merge(rxjs_1.fromEvent(container, "click"), rxjs_1.fromEvent(canvasContainer, "dblclick")).pipe(operators_1.bufferCount(3, 1), operators_1.filter(function (events) {
47041 var event1 = events[0];
47042 var event2 = events[1];
47043 var event3 = events[2];
47044 return event1.type === "click" &&
47045 event2.type === "click" &&
47046 event3.type === "dblclick" &&
47047 event1.target.parentNode === canvasContainer &&
47048 event2.target.parentNode === canvasContainer;
47049 }), operators_1.map(function (events) {
47051 }), operators_1.share());
47052 rxjs_1.merge(this._domMouseDown$, this._domMouseMove$, this._dblClick$, this._contextMenu$)
47053 .subscribe(function (event) {
47054 event.preventDefault();
47056 this._mouseWheel$ = rxjs_1.merge(rxjs_1.fromEvent(canvasContainer, "wheel"), rxjs_1.fromEvent(domContainer, "wheel")).pipe(operators_1.share());
47057 this._consistentContextMenu$ = rxjs_1.merge(this._mouseDown$, this._mouseMove$, this._mouseOut$, this._mouseUp$, this._contextMenu$).pipe(operators_1.bufferCount(3, 1), operators_1.filter(function (events) {
47058 // fire context menu on mouse up both on mac and windows
47059 return events[0].type === "mousedown" &&
47060 events[1].type === "contextmenu" &&
47061 events[2].type === "mouseup";
47062 }), operators_1.map(function (events) {
47064 }), operators_1.share());
47065 var dragStop$ = rxjs_1.merge(rxjs_1.fromEvent(window, "blur"), this._documentMouseUp$.pipe(operators_1.filter(function (e) {
47066 return e.button === 0;
47067 }))).pipe(operators_1.share());
47068 var mouseDragInitiate$ = this._createMouseDragInitiate$(this._mouseDown$, dragStop$, true).pipe(operators_1.share());
47069 this._mouseDragStart$ = this._createMouseDragStart$(mouseDragInitiate$).pipe(operators_1.share());
47070 this._mouseDrag$ = this._createMouseDrag$(mouseDragInitiate$, dragStop$).pipe(operators_1.share());
47071 this._mouseDragEnd$ = this._createMouseDragEnd$(this._mouseDragStart$, dragStop$).pipe(operators_1.share());
47072 var domMouseDragInitiate$ = this._createMouseDragInitiate$(this._domMouseDown$, dragStop$, false).pipe(operators_1.share());
47073 this._domMouseDragStart$ = this._createMouseDragStart$(domMouseDragInitiate$).pipe(operators_1.share());
47074 this._domMouseDrag$ = this._createMouseDrag$(domMouseDragInitiate$, dragStop$).pipe(operators_1.share());
47075 this._domMouseDragEnd$ = this._createMouseDragEnd$(this._domMouseDragStart$, dragStop$).pipe(operators_1.share());
47076 this._proximateClick$ = this._mouseDown$.pipe(operators_1.switchMap(function (mouseDown) {
47077 return _this._click$.pipe(operators_1.takeUntil(_this._createDeferredMouseMove$(mouseDown, _this._documentMouseMove$)), operators_1.take(1));
47078 }), operators_1.share());
47079 this._staticClick$ = this._mouseDown$.pipe(operators_1.switchMap(function (e) {
47080 return _this._click$.pipe(operators_1.takeUntil(_this._documentMouseMove$), operators_1.take(1));
47081 }), operators_1.share());
47082 this._mouseDragStart$.subscribe();
47083 this._mouseDrag$.subscribe();
47084 this._mouseDragEnd$.subscribe();
47085 this._domMouseDragStart$.subscribe();
47086 this._domMouseDrag$.subscribe();
47087 this._domMouseDragEnd$.subscribe();
47088 this._staticClick$.subscribe();
47089 this._mouseOwner$ = this._createOwner$(this._claimMouse$).pipe(operators_1.publishReplay(1), operators_1.refCount());
47090 this._wheelOwner$ = this._createOwner$(this._claimWheel$).pipe(operators_1.publishReplay(1), operators_1.refCount());
47091 this._mouseOwner$.subscribe(function () { });
47092 this._wheelOwner$.subscribe(function () { });
47094 Object.defineProperty(MouseService.prototype, "active$", {
47096 return this._active$;
47101 Object.defineProperty(MouseService.prototype, "activate$", {
47103 return this._activeSubject$;
47108 Object.defineProperty(MouseService.prototype, "documentMouseMove$", {
47110 return this._documentMouseMove$;
47115 Object.defineProperty(MouseService.prototype, "documentMouseUp$", {
47117 return this._documentMouseUp$;
47122 Object.defineProperty(MouseService.prototype, "domMouseDragStart$", {
47124 return this._domMouseDragStart$;
47129 Object.defineProperty(MouseService.prototype, "domMouseDrag$", {
47131 return this._domMouseDrag$;
47136 Object.defineProperty(MouseService.prototype, "domMouseDragEnd$", {
47138 return this._domMouseDragEnd$;
47143 Object.defineProperty(MouseService.prototype, "domMouseDown$", {
47145 return this._domMouseDown$;
47150 Object.defineProperty(MouseService.prototype, "domMouseMove$", {
47152 return this._domMouseMove$;
47157 Object.defineProperty(MouseService.prototype, "mouseOwner$", {
47159 return this._mouseOwner$;
47164 Object.defineProperty(MouseService.prototype, "mouseDown$", {
47166 return this._mouseDown$;
47171 Object.defineProperty(MouseService.prototype, "mouseMove$", {
47173 return this._mouseMove$;
47178 Object.defineProperty(MouseService.prototype, "mouseLeave$", {
47180 return this._mouseLeave$;
47185 Object.defineProperty(MouseService.prototype, "mouseOut$", {
47187 return this._mouseOut$;
47192 Object.defineProperty(MouseService.prototype, "mouseOver$", {
47194 return this._mouseOver$;
47199 Object.defineProperty(MouseService.prototype, "mouseUp$", {
47201 return this._mouseUp$;
47206 Object.defineProperty(MouseService.prototype, "click$", {
47208 return this._click$;
47213 Object.defineProperty(MouseService.prototype, "dblClick$", {
47215 return this._dblClick$;
47220 Object.defineProperty(MouseService.prototype, "contextMenu$", {
47222 return this._consistentContextMenu$;
47227 Object.defineProperty(MouseService.prototype, "mouseWheel$", {
47229 return this._mouseWheel$;
47234 Object.defineProperty(MouseService.prototype, "mouseDragStart$", {
47236 return this._mouseDragStart$;
47241 Object.defineProperty(MouseService.prototype, "mouseDrag$", {
47243 return this._mouseDrag$;
47248 Object.defineProperty(MouseService.prototype, "mouseDragEnd$", {
47250 return this._mouseDragEnd$;
47255 Object.defineProperty(MouseService.prototype, "proximateClick$", {
47257 return this._proximateClick$;
47262 Object.defineProperty(MouseService.prototype, "staticClick$", {
47264 return this._staticClick$;
47269 MouseService.prototype.claimMouse = function (name, zindex) {
47270 this._claimMouse$.next({ name: name, zindex: zindex });
47272 MouseService.prototype.unclaimMouse = function (name) {
47273 this._claimMouse$.next({ name: name, zindex: null });
47275 MouseService.prototype.deferPixels = function (name, deferPixels) {
47276 this._deferPixelClaims$.next({ name: name, deferPixels: deferPixels });
47278 MouseService.prototype.undeferPixels = function (name) {
47279 this._deferPixelClaims$.next({ name: name, deferPixels: null });
47281 MouseService.prototype.claimWheel = function (name, zindex) {
47282 this._claimWheel$.next({ name: name, zindex: zindex });
47284 MouseService.prototype.unclaimWheel = function (name) {
47285 this._claimWheel$.next({ name: name, zindex: null });
47287 MouseService.prototype.filtered$ = function (name, observable$) {
47288 return this._filtered(name, observable$, this._mouseOwner$);
47290 MouseService.prototype.filteredWheel$ = function (name, observable$) {
47291 return this._filtered(name, observable$, this._wheelOwner$);
47293 MouseService.prototype._createDeferredMouseMove$ = function (origin, mouseMove$) {
47294 return mouseMove$.pipe(operators_1.map(function (mouseMove) {
47295 var deltaX = mouseMove.clientX - origin.clientX;
47296 var deltaY = mouseMove.clientY - origin.clientY;
47297 return [mouseMove, Math.sqrt(deltaX * deltaX + deltaY * deltaY)];
47298 }), operators_1.withLatestFrom(this._deferPixels$), operators_1.filter(function (_a) {
47299 var _b = _a[0], mouseMove = _b[0], delta = _b[1], deferPixels = _a[1];
47300 return delta > deferPixels;
47301 }), operators_1.map(function (_a) {
47302 var _b = _a[0], mouseMove = _b[0], delta = _b[1], deferPixels = _a[1];
47306 MouseService.prototype._createMouseDrag$ = function (mouseDragStartInitiate$, stop$) {
47308 return mouseDragStartInitiate$.pipe(operators_1.map(function (_a) {
47309 var mouseDown = _a[0], mouseMove = _a[1];
47311 }), operators_1.switchMap(function (mouseMove) {
47312 return rxjs_1.concat(rxjs_1.of(mouseMove), _this._documentMouseMove$).pipe(operators_1.takeUntil(stop$));
47315 MouseService.prototype._createMouseDragEnd$ = function (mouseDragStart$, stop$) {
47316 return mouseDragStart$.pipe(operators_1.switchMap(function (event) {
47317 return stop$.pipe(operators_1.first());
47320 MouseService.prototype._createMouseDragStart$ = function (mouseDragStartInitiate$) {
47321 return mouseDragStartInitiate$.pipe(operators_1.map(function (_a) {
47322 var mouseDown = _a[0], mouseMove = _a[1];
47326 MouseService.prototype._createMouseDragInitiate$ = function (mouseDown$, stop$, defer) {
47328 return mouseDown$.pipe(operators_1.filter(function (mouseDown) {
47329 return mouseDown.button === 0;
47330 }), operators_1.switchMap(function (mouseDown) {
47331 return rxjs_1.combineLatest(rxjs_1.of(mouseDown), defer ?
47332 _this._createDeferredMouseMove$(mouseDown, _this._documentMouseMove$) :
47333 _this._documentMouseMove$).pipe(operators_1.takeUntil(stop$), operators_1.take(1));
47336 MouseService.prototype._createOwner$ = function (claim$) {
47337 return claim$.pipe(operators_1.scan(function (claims, claim) {
47338 if (claim.zindex == null) {
47339 delete claims[claim.name];
47342 claims[claim.name] = claim.zindex;
47345 }, {}), operators_1.map(function (claims) {
47347 var zIndexMax = -1;
47348 for (var name_1 in claims) {
47349 if (!claims.hasOwnProperty(name_1)) {
47352 if (claims[name_1] > zIndexMax) {
47353 zIndexMax = claims[name_1];
47358 }), operators_1.startWith(null));
47360 MouseService.prototype._filtered = function (name, observable$, owner$) {
47361 return observable$.pipe(operators_1.withLatestFrom(owner$), operators_1.filter(function (_a) {
47362 var item = _a[0], owner = _a[1];
47363 return owner === name;
47364 }), operators_1.map(function (_a) {
47365 var item = _a[0], owner = _a[1];
47369 return MouseService;
47371 exports.MouseService = MouseService;
47372 exports.default = MouseService;
47374 },{"rxjs":27,"rxjs/operators":225}],439:[function(require,module,exports){
47376 Object.defineProperty(exports, "__esModule", { value: true });
47377 var rxjs_1 = require("rxjs");
47378 var operators_1 = require("rxjs/operators");
47379 var API_1 = require("../API");
47380 var Graph_1 = require("../Graph");
47381 var Edge_1 = require("../Edge");
47382 var Error_1 = require("../Error");
47383 var State_1 = require("../State");
47384 var Viewer_1 = require("../Viewer");
47385 var Navigator = /** @class */ (function () {
47386 function Navigator(clientId, options, token, apiV3, graphService, imageLoadingService, loadingService, stateService, cacheService, playService) {
47387 this._apiV3 = apiV3 != null ? apiV3 : new API_1.APIv3(clientId, token);
47388 this._imageLoadingService = imageLoadingService != null ? imageLoadingService : new Graph_1.ImageLoadingService();
47389 this._graphService = graphService != null ?
47391 new Graph_1.GraphService(new Graph_1.Graph(this.apiV3), this._imageLoadingService);
47392 this._loadingService = loadingService != null ? loadingService : new Viewer_1.LoadingService();
47393 this._loadingName = "navigator";
47394 this._stateService = stateService != null ? stateService : new State_1.StateService(options.transitionMode);
47395 this._cacheService = cacheService != null ?
47397 new Viewer_1.CacheService(this._graphService, this._stateService);
47398 this._playService = playService != null ?
47400 new Viewer_1.PlayService(this._graphService, this._stateService);
47401 this._keyRequested$ = new rxjs_1.BehaviorSubject(null);
47402 this._movedToKey$ = new rxjs_1.BehaviorSubject(null);
47403 this._request$ = null;
47404 this._requestSubscription = null;
47405 this._nodeRequestSubscription = null;
47407 Object.defineProperty(Navigator.prototype, "apiV3", {
47409 return this._apiV3;
47414 Object.defineProperty(Navigator.prototype, "cacheService", {
47416 return this._cacheService;
47421 Object.defineProperty(Navigator.prototype, "graphService", {
47423 return this._graphService;
47428 Object.defineProperty(Navigator.prototype, "imageLoadingService", {
47430 return this._imageLoadingService;
47435 Object.defineProperty(Navigator.prototype, "loadingService", {
47437 return this._loadingService;
47442 Object.defineProperty(Navigator.prototype, "movedToKey$", {
47444 return this._movedToKey$;
47449 Object.defineProperty(Navigator.prototype, "playService", {
47451 return this._playService;
47456 Object.defineProperty(Navigator.prototype, "stateService", {
47458 return this._stateService;
47463 Navigator.prototype.moveToKey$ = function (key) {
47464 this._abortRequest("to key " + key);
47465 this._loadingService.startLoading(this._loadingName);
47466 var node$ = this._moveToKey$(key);
47467 return this._makeRequest$(node$);
47469 Navigator.prototype.moveDir$ = function (direction) {
47471 this._abortRequest("in dir " + Edge_1.EdgeDirection[direction]);
47472 this._loadingService.startLoading(this._loadingName);
47473 var node$ = this.stateService.currentNode$.pipe(operators_1.first(), operators_1.mergeMap(function (node) {
47474 return ([Edge_1.EdgeDirection.Next, Edge_1.EdgeDirection.Prev].indexOf(direction) > -1 ?
47475 node.sequenceEdges$ :
47476 node.spatialEdges$).pipe(operators_1.first(), operators_1.map(function (status) {
47477 for (var _i = 0, _a = status.edges; _i < _a.length; _i++) {
47479 if (edge.data.direction === direction) {
47485 }), operators_1.mergeMap(function (directionKey) {
47486 if (directionKey == null) {
47487 _this._loadingService.stopLoading(_this._loadingName);
47488 return rxjs_1.throwError(new Error("Direction (" + direction + ") does not exist for current node."));
47490 return _this._moveToKey$(directionKey);
47492 return this._makeRequest$(node$);
47494 Navigator.prototype.moveCloseTo$ = function (lat, lon) {
47496 this._abortRequest("to lat " + lat + ", lon " + lon);
47497 this._loadingService.startLoading(this._loadingName);
47498 var node$ = this.apiV3.imageCloseTo$(lat, lon).pipe(operators_1.mergeMap(function (fullNode) {
47499 if (fullNode == null) {
47500 _this._loadingService.stopLoading(_this._loadingName);
47501 return rxjs_1.throwError(new Error("No image found close to lat " + lat + ", lon " + lon + "."));
47503 return _this._moveToKey$(fullNode.key);
47505 return this._makeRequest$(node$);
47507 Navigator.prototype.setFilter$ = function (filter) {
47509 this._stateService.clearNodes();
47510 return this._movedToKey$.pipe(operators_1.first(), operators_1.mergeMap(function (key) {
47512 return _this._trajectoryKeys$().pipe(operators_1.mergeMap(function (keys) {
47513 return _this._graphService.setFilter$(filter).pipe(operators_1.mergeMap(function () {
47514 return _this._cacheKeys$(keys);
47516 }), operators_1.last());
47518 return _this._keyRequested$.pipe(operators_1.first(), operators_1.mergeMap(function (requestedKey) {
47519 if (requestedKey != null) {
47520 return _this._graphService.setFilter$(filter).pipe(operators_1.mergeMap(function () {
47521 return _this._graphService.cacheNode$(requestedKey);
47524 return _this._graphService.setFilter$(filter).pipe(operators_1.map(function () {
47528 }), operators_1.map(function (node) {
47532 Navigator.prototype.setToken$ = function (token) {
47534 this._abortRequest("to set token");
47535 this._stateService.clearNodes();
47536 return this._movedToKey$.pipe(operators_1.first(), operators_1.tap(function (key) {
47537 _this._apiV3.setToken(token);
47538 }), operators_1.mergeMap(function (key) {
47539 return key == null ?
47540 _this._graphService.reset$([]) :
47541 _this._trajectoryKeys$().pipe(operators_1.mergeMap(function (keys) {
47542 return _this._graphService.reset$(keys).pipe(operators_1.mergeMap(function () {
47543 return _this._cacheKeys$(keys);
47545 }), operators_1.last(), operators_1.map(function (node) {
47550 Navigator.prototype._cacheKeys$ = function (keys) {
47552 var cacheNodes$ = keys
47553 .map(function (key) {
47554 return _this._graphService.cacheNode$(key);
47556 return rxjs_1.from(cacheNodes$).pipe(operators_1.mergeAll());
47558 Navigator.prototype._abortRequest = function (reason) {
47559 if (this._requestSubscription != null) {
47560 this._requestSubscription.unsubscribe();
47561 this._requestSubscription = null;
47563 if (this._nodeRequestSubscription != null) {
47564 this._nodeRequestSubscription.unsubscribe();
47565 this._nodeRequestSubscription = null;
47567 if (this._request$ != null) {
47568 if (!(this._request$.isStopped || this._request$.hasError)) {
47569 this._request$.error(new Error_1.AbortMapillaryError("Request aborted by a subsequent request " + reason + "."));
47571 this._request$ = null;
47574 Navigator.prototype._makeRequest$ = function (node$) {
47576 var request$ = new rxjs_1.ReplaySubject(1);
47577 this._requestSubscription = request$
47578 .subscribe(undefined, function () { });
47579 this._request$ = request$;
47580 this._nodeRequestSubscription = node$
47581 .subscribe(function (node) {
47582 _this._request$ = null;
47583 request$.next(node);
47584 request$.complete();
47585 }, function (error) {
47586 _this._request$ = null;
47587 request$.error(error);
47591 Navigator.prototype._moveToKey$ = function (key) {
47593 this._keyRequested$.next(key);
47594 return this._graphService.cacheNode$(key).pipe(operators_1.tap(function (node) {
47595 _this._stateService.setNodes([node]);
47596 _this._movedToKey$.next(node.key);
47597 }), operators_1.finalize(function () {
47598 _this._loadingService.stopLoading(_this._loadingName);
47601 Navigator.prototype._trajectoryKeys$ = function () {
47602 return this._stateService.currentState$.pipe(operators_1.first(), operators_1.map(function (frame) {
47603 return frame.state.trajectory
47604 .map(function (node) {
47611 exports.Navigator = Navigator;
47612 exports.default = Navigator;
47614 },{"../API":274,"../Edge":276,"../Error":277,"../Graph":279,"../State":282,"../Viewer":286,"rxjs":27,"rxjs/operators":225}],440:[function(require,module,exports){
47616 Object.defineProperty(exports, "__esModule", { value: true });
47617 var rxjs_1 = require("rxjs");
47618 var operators_1 = require("rxjs/operators");
47619 var Viewer_1 = require("../Viewer");
47620 var Observer = /** @class */ (function () {
47621 function Observer(eventEmitter, navigator, container) {
47623 this._container = container;
47624 this._eventEmitter = eventEmitter;
47625 this._navigator = navigator;
47626 this._projection = new Viewer_1.Projection();
47627 this._started = false;
47628 this._navigable$ = new rxjs_1.Subject();
47629 // navigable and loading should always emit, also when cover is activated.
47631 .subscribe(function (navigable) {
47632 _this._eventEmitter.fire(Viewer_1.Viewer.navigablechanged, navigable);
47634 this._navigator.loadingService.loading$
47635 .subscribe(function (loading) {
47636 _this._eventEmitter.fire(Viewer_1.Viewer.loadingchanged, loading);
47639 Object.defineProperty(Observer.prototype, "started", {
47641 return this._started;
47646 Object.defineProperty(Observer.prototype, "navigable$", {
47648 return this._navigable$;
47653 Observer.prototype.projectBasic$ = function (basicPoint) {
47655 return rxjs_1.combineLatest(this._container.renderService.renderCamera$, this._navigator.stateService.currentTransform$).pipe(operators_1.first(), operators_1.map(function (_a) {
47656 var render = _a[0], transform = _a[1];
47657 var canvasPoint = _this._projection.basicToCanvas(basicPoint, _this._container.element, render, transform);
47658 return [Math.round(canvasPoint[0]), Math.round(canvasPoint[1])];
47661 Observer.prototype.startEmit = function () {
47663 if (this._started) {
47666 this._started = true;
47667 this._currentNodeSubscription = this._navigator.stateService.currentNodeExternal$
47668 .subscribe(function (node) {
47669 _this._eventEmitter.fire(Viewer_1.Viewer.nodechanged, node);
47671 this._sequenceEdgesSubscription = this._navigator.stateService.currentNodeExternal$.pipe(operators_1.switchMap(function (node) {
47672 return node.sequenceEdges$;
47674 .subscribe(function (status) {
47675 _this._eventEmitter.fire(Viewer_1.Viewer.sequenceedgeschanged, status);
47677 this._spatialEdgesSubscription = this._navigator.stateService.currentNodeExternal$.pipe(operators_1.switchMap(function (node) {
47678 return node.spatialEdges$;
47680 .subscribe(function (status) {
47681 _this._eventEmitter.fire(Viewer_1.Viewer.spatialedgeschanged, status);
47683 this._moveSubscription = rxjs_1.combineLatest(this._navigator.stateService.inMotion$, this._container.mouseService.active$, this._container.touchService.active$).pipe(operators_1.map(function (values) {
47684 return values[0] || values[1] || values[2];
47685 }), operators_1.distinctUntilChanged())
47686 .subscribe(function (started) {
47688 _this._eventEmitter.fire(Viewer_1.Viewer.movestart, null);
47691 _this._eventEmitter.fire(Viewer_1.Viewer.moveend, null);
47694 this._bearingSubscription = this._container.renderService.bearing$.pipe(operators_1.auditTime(100), operators_1.distinctUntilChanged(function (b1, b2) {
47695 return Math.abs(b2 - b1) < 1;
47697 .subscribe(function (bearing) {
47698 _this._eventEmitter.fire(Viewer_1.Viewer.bearingchanged, bearing);
47700 var mouseMove$ = this._container.mouseService.active$.pipe(operators_1.switchMap(function (active) {
47703 _this._container.mouseService.mouseMove$;
47705 this._viewerMouseEventSubscription = rxjs_1.merge(this._mapMouseEvent$(Viewer_1.Viewer.click, this._container.mouseService.staticClick$), this._mapMouseEvent$(Viewer_1.Viewer.contextmenu, this._container.mouseService.contextMenu$), this._mapMouseEvent$(Viewer_1.Viewer.dblclick, this._container.mouseService.dblClick$), this._mapMouseEvent$(Viewer_1.Viewer.mousedown, this._container.mouseService.mouseDown$), this._mapMouseEvent$(Viewer_1.Viewer.mousemove, mouseMove$), this._mapMouseEvent$(Viewer_1.Viewer.mouseout, this._container.mouseService.mouseOut$), this._mapMouseEvent$(Viewer_1.Viewer.mouseover, this._container.mouseService.mouseOver$), this._mapMouseEvent$(Viewer_1.Viewer.mouseup, this._container.mouseService.mouseUp$)).pipe(operators_1.withLatestFrom(this._container.renderService.renderCamera$, this._navigator.stateService.reference$, this._navigator.stateService.currentTransform$), operators_1.map(function (_a) {
47706 var _b = _a[0], type = _b[0], event = _b[1], render = _a[1], reference = _a[2], transform = _a[3];
47707 var unprojection = _this._projection.eventToUnprojection(event, _this._container.element, render, reference, transform);
47709 basicPoint: unprojection.basicPoint,
47710 latLon: unprojection.latLon,
47711 originalEvent: event,
47712 pixelPoint: unprojection.pixelPoint,
47713 target: _this._eventEmitter,
47717 .subscribe(function (event) {
47718 _this._eventEmitter.fire(event.type, event);
47721 Observer.prototype.stopEmit = function () {
47722 if (!this.started) {
47725 this._started = false;
47726 this._bearingSubscription.unsubscribe();
47727 this._currentNodeSubscription.unsubscribe();
47728 this._moveSubscription.unsubscribe();
47729 this._sequenceEdgesSubscription.unsubscribe();
47730 this._spatialEdgesSubscription.unsubscribe();
47731 this._viewerMouseEventSubscription.unsubscribe();
47732 this._bearingSubscription = null;
47733 this._currentNodeSubscription = null;
47734 this._moveSubscription = null;
47735 this._sequenceEdgesSubscription = null;
47736 this._spatialEdgesSubscription = null;
47737 this._viewerMouseEventSubscription = null;
47739 Observer.prototype.unproject$ = function (canvasPoint) {
47741 return rxjs_1.combineLatest(this._container.renderService.renderCamera$, this._navigator.stateService.reference$, this._navigator.stateService.currentTransform$).pipe(operators_1.first(), operators_1.map(function (_a) {
47742 var render = _a[0], reference = _a[1], transform = _a[2];
47743 var unprojection = _this._projection.canvasToUnprojection(canvasPoint, _this._container.element, render, reference, transform);
47744 return unprojection.latLon;
47747 Observer.prototype.unprojectBasic$ = function (canvasPoint) {
47749 return rxjs_1.combineLatest(this._container.renderService.renderCamera$, this._navigator.stateService.currentTransform$).pipe(operators_1.first(), operators_1.map(function (_a) {
47750 var render = _a[0], transform = _a[1];
47751 return _this._projection.canvasToBasic(canvasPoint, _this._container.element, render, transform);
47754 Observer.prototype._mapMouseEvent$ = function (type, mouseEvent$) {
47755 return mouseEvent$.pipe(operators_1.map(function (event) {
47756 return [type, event];
47761 exports.Observer = Observer;
47762 exports.default = Observer;
47764 },{"../Viewer":286,"rxjs":27,"rxjs/operators":225}],441:[function(require,module,exports){
47766 Object.defineProperty(exports, "__esModule", { value: true });
47767 var rxjs_1 = require("rxjs");
47768 var operators_1 = require("rxjs/operators");
47769 var Edge_1 = require("../Edge");
47770 var Graph_1 = require("../Graph");
47771 var PlayService = /** @class */ (function () {
47772 function PlayService(graphService, stateService, graphCalculator) {
47773 this._graphService = graphService;
47774 this._stateService = stateService;
47775 this._graphCalculator = !!graphCalculator ? graphCalculator : new Graph_1.GraphCalculator();
47776 this._directionSubject$ = new rxjs_1.Subject();
47777 this._direction$ = this._directionSubject$.pipe(operators_1.startWith(Edge_1.EdgeDirection.Next), operators_1.publishReplay(1), operators_1.refCount());
47778 this._direction$.subscribe();
47779 this._playing = false;
47780 this._playingSubject$ = new rxjs_1.Subject();
47781 this._playing$ = this._playingSubject$.pipe(operators_1.startWith(this._playing), operators_1.publishReplay(1), operators_1.refCount());
47782 this._playing$.subscribe();
47784 this._speedSubject$ = new rxjs_1.Subject();
47785 this._speed$ = this._speedSubject$.pipe(operators_1.startWith(this._speed), operators_1.publishReplay(1), operators_1.refCount());
47786 this._speed$.subscribe();
47787 this._nodesAhead = this._mapNodesAhead(this._mapSpeed(this._speed));
47788 this._bridging$ = null;
47790 Object.defineProperty(PlayService.prototype, "playing", {
47792 return this._playing;
47797 Object.defineProperty(PlayService.prototype, "direction$", {
47799 return this._direction$;
47804 Object.defineProperty(PlayService.prototype, "playing$", {
47806 return this._playing$;
47811 Object.defineProperty(PlayService.prototype, "speed$", {
47813 return this._speed$;
47818 PlayService.prototype.play = function () {
47820 if (this._playing) {
47823 this._stateService.cutNodes();
47824 var stateSpeed = this._setSpeed(this._speed);
47825 this._stateService.setSpeed(stateSpeed);
47826 this._graphModeSubscription = this._speed$.pipe(operators_1.map(function (speed) {
47827 return speed > PlayService.sequenceSpeed ? Graph_1.GraphMode.Sequence : Graph_1.GraphMode.Spatial;
47828 }), operators_1.distinctUntilChanged())
47829 .subscribe(function (mode) {
47830 _this._graphService.setGraphMode(mode);
47832 this._cacheSubscription = rxjs_1.combineLatest(this._stateService.currentNode$.pipe(operators_1.map(function (node) {
47833 return [node.sequenceKey, node.key];
47834 }), operators_1.distinctUntilChanged(undefined, function (_a) {
47835 var sequenceKey = _a[0], nodeKey = _a[1];
47836 return sequenceKey;
47837 })), this._graphService.graphMode$, this._direction$).pipe(operators_1.switchMap(function (_a) {
47838 var _b = _a[0], sequenceKey = _b[0], nodeKey = _b[1], mode = _a[1], direction = _a[2];
47839 if (direction !== Edge_1.EdgeDirection.Next && direction !== Edge_1.EdgeDirection.Prev) {
47840 return rxjs_1.of([undefined, direction]);
47842 var sequence$ = (mode === Graph_1.GraphMode.Sequence ?
47843 _this._graphService.cacheSequenceNodes$(sequenceKey, nodeKey) :
47844 _this._graphService.cacheSequence$(sequenceKey)).pipe(operators_1.retry(3), operators_1.catchError(function (error) {
47845 console.error(error);
47846 return rxjs_1.of(undefined);
47848 return rxjs_1.combineLatest(sequence$, rxjs_1.of(direction));
47849 }), operators_1.switchMap(function (_a) {
47850 var sequence = _a[0], direction = _a[1];
47851 if (sequence === undefined) {
47852 return rxjs_1.empty();
47854 var sequenceKeys = sequence.keys.slice();
47855 if (direction === Edge_1.EdgeDirection.Prev) {
47856 sequenceKeys.reverse();
47858 return _this._stateService.currentState$.pipe(operators_1.map(function (frame) {
47859 return [frame.state.trajectory[frame.state.trajectory.length - 1].key, frame.state.nodesAhead];
47860 }), operators_1.scan(function (_a, _b) {
47861 var lastRequestKey = _a[0], previousRequestKeys = _a[1];
47862 var lastTrajectoryKey = _b[0], nodesAhead = _b[1];
47863 if (lastRequestKey === undefined) {
47864 lastRequestKey = lastTrajectoryKey;
47866 var lastIndex = sequenceKeys.length - 1;
47867 if (nodesAhead >= _this._nodesAhead || sequenceKeys[lastIndex] === lastRequestKey) {
47868 return [lastRequestKey, []];
47870 var current = sequenceKeys.indexOf(lastTrajectoryKey);
47871 var start = sequenceKeys.indexOf(lastRequestKey) + 1;
47872 var end = Math.min(lastIndex, current + _this._nodesAhead - nodesAhead) + 1;
47873 if (end <= start) {
47874 return [lastRequestKey, []];
47876 return [sequenceKeys[end - 1], sequenceKeys.slice(start, end)];
47877 }, [undefined, []]), operators_1.mergeMap(function (_a) {
47878 var lastRequestKey = _a[0], newRequestKeys = _a[1];
47879 return rxjs_1.from(newRequestKeys);
47881 }), operators_1.mergeMap(function (key) {
47882 return _this._graphService.cacheNode$(key).pipe(operators_1.catchError(function () {
47883 return rxjs_1.empty();
47887 this._playingSubscription = this._stateService.currentState$.pipe(operators_1.filter(function (frame) {
47888 return frame.state.nodesAhead < _this._nodesAhead;
47889 }), operators_1.distinctUntilChanged(undefined, function (frame) {
47890 return frame.state.lastNode.key;
47891 }), operators_1.map(function (frame) {
47892 var lastNode = frame.state.lastNode;
47893 var trajectory = frame.state.trajectory;
47894 var increasingTime = undefined;
47895 for (var i = trajectory.length - 2; i >= 0; i--) {
47896 var node = trajectory[i];
47897 if (node.sequenceKey !== lastNode.sequenceKey) {
47900 if (node.capturedAt !== lastNode.capturedAt) {
47901 increasingTime = node.capturedAt < lastNode.capturedAt;
47905 return [frame.state.lastNode, increasingTime];
47906 }), operators_1.withLatestFrom(this._direction$), operators_1.switchMap(function (_a) {
47907 var _b = _a[0], node = _b[0], increasingTime = _b[1], direction = _a[1];
47908 return rxjs_1.zip(([Edge_1.EdgeDirection.Next, Edge_1.EdgeDirection.Prev].indexOf(direction) > -1 ?
47909 node.sequenceEdges$ :
47910 node.spatialEdges$).pipe(operators_1.first(function (status) {
47911 return status.cached;
47912 }), operators_1.timeout(15000)), rxjs_1.of(direction)).pipe(operators_1.map(function (_a) {
47913 var s = _a[0], d = _a[1];
47914 for (var _i = 0, _b = s.edges; _i < _b.length; _i++) {
47916 if (edge.data.direction === d) {
47921 }), operators_1.switchMap(function (key) {
47922 return key != null ?
47923 _this._graphService.cacheNode$(key) :
47924 _this._bridge$(node, increasingTime).pipe(operators_1.filter(function (n) {
47929 .subscribe(function (node) {
47930 _this._stateService.appendNodes([node]);
47931 }, function (error) {
47932 console.error(error);
47935 this._clearSubscription = this._stateService.currentNode$.pipe(operators_1.bufferCount(1, 10))
47936 .subscribe(function (nodes) {
47937 _this._stateService.clearPriorNodes();
47939 this._setPlaying(true);
47940 var currentLastNodes$ = this._stateService.currentState$.pipe(operators_1.map(function (frame) {
47941 return frame.state;
47942 }), operators_1.distinctUntilChanged(function (_a, _b) {
47943 var kc1 = _a[0], kl1 = _a[1];
47944 var kc2 = _b[0], kl2 = _b[1];
47945 return kc1 === kc2 && kl1 === kl2;
47946 }, function (state) {
47947 return [state.currentNode.key, state.lastNode.key];
47948 }), operators_1.filter(function (state) {
47949 return state.currentNode.key === state.lastNode.key &&
47950 state.currentIndex === state.trajectory.length - 1;
47951 }), operators_1.map(function (state) {
47952 return state.currentNode;
47954 this._stopSubscription = rxjs_1.combineLatest(currentLastNodes$, this._direction$).pipe(operators_1.switchMap(function (_a) {
47955 var node = _a[0], direction = _a[1];
47956 var edgeStatus$ = ([Edge_1.EdgeDirection.Next, Edge_1.EdgeDirection.Prev].indexOf(direction) > -1 ?
47957 node.sequenceEdges$ :
47958 node.spatialEdges$).pipe(operators_1.first(function (status) {
47959 return status.cached;
47960 }), operators_1.timeout(15000), operators_1.catchError(function (error) {
47961 console.error(error);
47962 return rxjs_1.of({ cached: false, edges: [] });
47964 return rxjs_1.combineLatest(rxjs_1.of(direction), edgeStatus$).pipe(operators_1.map(function (_a) {
47965 var d = _a[0], es = _a[1];
47966 for (var _i = 0, _b = es.edges; _i < _b.length; _i++) {
47968 if (edge.data.direction === d) {
47974 }), operators_1.mergeMap(function (hasEdge) {
47975 if (hasEdge || !_this._bridging$) {
47976 return rxjs_1.of(hasEdge);
47978 return _this._bridging$.pipe(operators_1.map(function (node) {
47979 return node != null;
47980 }), operators_1.catchError(function (error) {
47981 console.error(error);
47982 return rxjs_1.of(false);
47984 }), operators_1.first(function (hasEdge) {
47987 .subscribe(undefined, undefined, function () { _this.stop(); });
47988 if (this._stopSubscription.closed) {
47989 this._stopSubscription = null;
47992 PlayService.prototype.setDirection = function (direction) {
47993 this._directionSubject$.next(direction);
47995 PlayService.prototype.setSpeed = function (speed) {
47996 speed = Math.max(0, Math.min(1, speed));
47997 if (speed === this._speed) {
48000 var stateSpeed = this._setSpeed(speed);
48001 if (this._playing) {
48002 this._stateService.setSpeed(stateSpeed);
48004 this._speedSubject$.next(this._speed);
48006 PlayService.prototype.stop = function () {
48007 if (!this._playing) {
48010 if (!!this._stopSubscription) {
48011 if (!this._stopSubscription.closed) {
48012 this._stopSubscription.unsubscribe();
48014 this._stopSubscription = null;
48016 this._graphModeSubscription.unsubscribe();
48017 this._graphModeSubscription = null;
48018 this._cacheSubscription.unsubscribe();
48019 this._cacheSubscription = null;
48020 this._playingSubscription.unsubscribe();
48021 this._playingSubscription = null;
48022 this._clearSubscription.unsubscribe();
48023 this._clearSubscription = null;
48024 this._stateService.setSpeed(1);
48025 this._stateService.cutNodes();
48026 this._graphService.setGraphMode(Graph_1.GraphMode.Spatial);
48027 this._setPlaying(false);
48029 PlayService.prototype._bridge$ = function (node, increasingTime) {
48031 if (increasingTime === undefined) {
48032 return rxjs_1.of(null);
48034 var boundingBox = this._graphCalculator.boundingBoxCorners(node.latLon, 25);
48035 this._bridging$ = this._graphService.cacheBoundingBox$(boundingBox[0], boundingBox[1]).pipe(operators_1.mergeMap(function (nodes) {
48036 var nextNode = null;
48037 for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
48038 var n = nodes_1[_i];
48039 if (n.sequenceKey === node.sequenceKey ||
48041 n.cameraUuid !== node.cameraUuid ||
48042 n.capturedAt === node.capturedAt ||
48043 n.capturedAt > node.capturedAt !== increasingTime) {
48046 var delta = Math.abs(n.capturedAt - node.capturedAt);
48047 if (delta > 15000) {
48050 if (!nextNode || delta < Math.abs(nextNode.capturedAt - node.capturedAt)) {
48054 return !!nextNode ?
48055 _this._graphService.cacheNode$(nextNode.key) :
48057 }), operators_1.finalize(function () {
48058 _this._bridging$ = null;
48059 }), operators_1.publish(), operators_1.refCount());
48060 return this._bridging$;
48062 PlayService.prototype._mapSpeed = function (speed) {
48063 var x = 2 * speed - 1;
48064 return Math.pow(10, x) - 0.2 * x;
48066 PlayService.prototype._mapNodesAhead = function (stateSpeed) {
48067 return Math.round(Math.max(10, Math.min(50, 8 + 6 * stateSpeed)));
48069 PlayService.prototype._setPlaying = function (playing) {
48070 this._playing = playing;
48071 this._playingSubject$.next(playing);
48073 PlayService.prototype._setSpeed = function (speed) {
48074 this._speed = speed;
48075 var stateSpeed = this._mapSpeed(this._speed);
48076 this._nodesAhead = this._mapNodesAhead(stateSpeed);
48079 PlayService.sequenceSpeed = 0.54;
48080 return PlayService;
48082 exports.PlayService = PlayService;
48083 exports.default = PlayService;
48085 },{"../Edge":276,"../Graph":279,"rxjs":27,"rxjs/operators":225}],442:[function(require,module,exports){
48087 Object.defineProperty(exports, "__esModule", { value: true });
48088 var THREE = require("three");
48089 var Geo_1 = require("../Geo");
48090 var Projection = /** @class */ (function () {
48091 function Projection(geoCoords, viewportCoords) {
48092 this._geoCoords = !!geoCoords ? geoCoords : new Geo_1.GeoCoords();
48093 this._viewportCoords = !!viewportCoords ? viewportCoords : new Geo_1.ViewportCoords();
48095 Projection.prototype.basicToCanvas = function (basicPoint, container, render, transform) {
48096 return this._viewportCoords
48097 .basicToCanvas(basicPoint[0], basicPoint[1], container, transform, render.perspective);
48099 Projection.prototype.canvasToBasic = function (canvasPoint, container, render, transform) {
48100 var basicPoint = this._viewportCoords
48101 .canvasToBasic(canvasPoint[0], canvasPoint[1], container, transform, render.perspective);
48102 if (basicPoint[0] < 0 || basicPoint[0] > 1 || basicPoint[1] < 0 || basicPoint[1] > 1) {
48107 Projection.prototype.eventToUnprojection = function (event, container, render, reference, transform) {
48108 var pixelPoint = this._viewportCoords.canvasPosition(event, container);
48109 return this.canvasToUnprojection(pixelPoint, container, render, reference, transform);
48111 Projection.prototype.canvasToUnprojection = function (canvasPoint, container, render, reference, transform) {
48112 var canvasX = canvasPoint[0];
48113 var canvasY = canvasPoint[1];
48114 var _a = this._viewportCoords.canvasToViewport(canvasX, canvasY, container), viewportX = _a[0], viewportY = _a[1];
48115 var point3d = new THREE.Vector3(viewportX, viewportY, 1)
48116 .unproject(render.perspective);
48117 var basicPoint = transform.projectBasic(point3d.toArray());
48118 if (basicPoint[0] < 0 || basicPoint[0] > 1 || basicPoint[1] < 0 || basicPoint[1] > 1) {
48121 var direction3d = point3d.clone().sub(render.camera.position).normalize();
48122 var dist = -2 / direction3d.z;
48124 if (dist > 0 && dist < 100 && !!basicPoint) {
48125 var point = direction3d.clone().multiplyScalar(dist).add(render.camera.position);
48126 var latLonArray = this._geoCoords
48127 .enuToGeodetic(point.x, point.y, point.z, reference.lat, reference.lon, reference.alt)
48129 latLon = { lat: latLonArray[0], lon: latLonArray[1] };
48131 var unprojection = {
48132 basicPoint: basicPoint,
48134 pixelPoint: [canvasX, canvasY],
48136 return unprojection;
48140 exports.Projection = Projection;
48141 exports.default = Projection;
48143 },{"../Geo":278,"three":226}],443:[function(require,module,exports){
48145 Object.defineProperty(exports, "__esModule", { value: true });
48146 var operators_1 = require("rxjs/operators");
48147 var THREE = require("three");
48148 var vd = require("virtual-dom");
48149 var rxjs_1 = require("rxjs");
48150 var Viewer_1 = require("../Viewer");
48151 var SpriteAtlas = /** @class */ (function () {
48152 function SpriteAtlas() {
48154 Object.defineProperty(SpriteAtlas.prototype, "json", {
48155 set: function (value) {
48156 this._json = value;
48161 Object.defineProperty(SpriteAtlas.prototype, "image", {
48162 set: function (value) {
48163 this._image = value;
48164 this._texture = new THREE.Texture(this._image);
48165 this._texture.minFilter = THREE.NearestFilter;
48170 Object.defineProperty(SpriteAtlas.prototype, "loaded", {
48172 return !!(this._image && this._json);
48177 SpriteAtlas.prototype.getGLSprite = function (name) {
48178 if (!this.loaded) {
48179 throw new Error("Sprites cannot be retrieved before the atlas is loaded.");
48181 var definition = this._json[name];
48183 console.warn("Sprite with key" + name + "does not exist in sprite definition.");
48184 return new THREE.Object3D();
48186 var texture = this._texture.clone();
48187 texture.needsUpdate = true;
48188 var width = this._image.width;
48189 var height = this._image.height;
48190 texture.offset.x = definition.x / width;
48191 texture.offset.y = (height - definition.y - definition.height) / height;
48192 texture.repeat.x = definition.width / width;
48193 texture.repeat.y = definition.height / height;
48194 var material = new THREE.SpriteMaterial({ map: texture });
48195 return new THREE.Sprite(material);
48197 SpriteAtlas.prototype.getDOMSprite = function (name, float) {
48198 if (!this.loaded) {
48199 throw new Error("Sprites cannot be retrieved before the atlas is loaded.");
48201 if (float == null) {
48202 float = Viewer_1.Alignment.Center;
48204 var definition = this._json[name];
48206 console.warn("Sprite with key" + name + "does not exist in sprite definition.");
48207 return vd.h("div", {}, []);
48209 var clipTop = definition.y;
48210 var clipRigth = definition.x + definition.width;
48211 var clipBottom = definition.y + definition.height;
48212 var clipLeft = definition.x;
48213 var left = -definition.x;
48214 var top = -definition.y;
48215 var height = this._image.height;
48216 var width = this._image.width;
48218 case Viewer_1.Alignment.Bottom:
48219 case Viewer_1.Alignment.Center:
48220 case Viewer_1.Alignment.Top:
48221 left -= definition.width / 2;
48223 case Viewer_1.Alignment.BottomLeft:
48224 case Viewer_1.Alignment.Left:
48225 case Viewer_1.Alignment.TopLeft:
48226 left -= definition.width;
48228 case Viewer_1.Alignment.BottomRight:
48229 case Viewer_1.Alignment.Right:
48230 case Viewer_1.Alignment.TopRight:
48235 case Viewer_1.Alignment.Center:
48236 case Viewer_1.Alignment.Left:
48237 case Viewer_1.Alignment.Right:
48238 top -= definition.height / 2;
48240 case Viewer_1.Alignment.Top:
48241 case Viewer_1.Alignment.TopLeft:
48242 case Viewer_1.Alignment.TopRight:
48243 top -= definition.height;
48245 case Viewer_1.Alignment.Bottom:
48246 case Viewer_1.Alignment.BottomLeft:
48247 case Viewer_1.Alignment.BottomRight:
48251 var pixelRatioInverse = 1 / definition.pixelRatio;
48252 clipTop *= pixelRatioInverse;
48253 clipRigth *= pixelRatioInverse;
48254 clipBottom *= pixelRatioInverse;
48255 clipLeft *= pixelRatioInverse;
48256 left *= pixelRatioInverse;
48257 top *= pixelRatioInverse;
48258 height *= pixelRatioInverse;
48259 width *= pixelRatioInverse;
48261 src: this._image.src,
48263 clip: "rect(" + clipTop + "px, " + clipRigth + "px, " + clipBottom + "px, " + clipLeft + "px)",
48264 height: height + "px",
48266 position: "absolute",
48268 width: width + "px",
48271 return vd.h("img", properties, []);
48273 return SpriteAtlas;
48275 var SpriteService = /** @class */ (function () {
48276 function SpriteService(sprite) {
48278 this._retina = window.devicePixelRatio > 1;
48279 this._spriteAtlasOperation$ = new rxjs_1.Subject();
48280 this._spriteAtlas$ = this._spriteAtlasOperation$.pipe(operators_1.startWith(function (atlas) {
48282 }), operators_1.scan(function (atlas, operation) {
48283 return operation(atlas);
48284 }, new SpriteAtlas()), operators_1.publishReplay(1), operators_1.refCount());
48285 this._spriteAtlas$.subscribe(function () { });
48286 if (sprite == null) {
48289 var format = this._retina ? "@2x" : "";
48290 var imageXmlHTTP = new XMLHttpRequest();
48291 imageXmlHTTP.open("GET", sprite + format + ".png", true);
48292 imageXmlHTTP.responseType = "arraybuffer";
48293 imageXmlHTTP.onload = function () {
48294 var image = new Image();
48295 image.onload = function () {
48296 _this._spriteAtlasOperation$.next(function (atlas) {
48297 atlas.image = image;
48301 var blob = new Blob([imageXmlHTTP.response]);
48302 image.src = window.URL.createObjectURL(blob);
48304 imageXmlHTTP.onerror = function (error) {
48305 console.error(new Error("Failed to fetch sprite sheet (" + sprite + format + ".png)"));
48307 imageXmlHTTP.send();
48308 var jsonXmlHTTP = new XMLHttpRequest();
48309 jsonXmlHTTP.open("GET", sprite + format + ".json", true);
48310 jsonXmlHTTP.responseType = "text";
48311 jsonXmlHTTP.onload = function () {
48312 var json = JSON.parse(jsonXmlHTTP.response);
48313 _this._spriteAtlasOperation$.next(function (atlas) {
48318 jsonXmlHTTP.onerror = function (error) {
48319 console.error(new Error("Failed to fetch sheet (" + sprite + format + ".json)"));
48321 jsonXmlHTTP.send();
48323 Object.defineProperty(SpriteService.prototype, "spriteAtlas$", {
48325 return this._spriteAtlas$;
48330 return SpriteService;
48332 exports.SpriteService = SpriteService;
48333 exports.default = SpriteService;
48336 },{"../Viewer":286,"rxjs":27,"rxjs/operators":225,"three":226,"virtual-dom":231}],444:[function(require,module,exports){
48338 Object.defineProperty(exports, "__esModule", { value: true });
48339 var rxjs_1 = require("rxjs");
48340 var operators_1 = require("rxjs/operators");
48341 var TouchService = /** @class */ (function () {
48342 function TouchService(canvasContainer, domContainer) {
48344 this._activeSubject$ = new rxjs_1.BehaviorSubject(false);
48345 this._active$ = this._activeSubject$.pipe(operators_1.distinctUntilChanged(), operators_1.publishReplay(1), operators_1.refCount());
48346 rxjs_1.fromEvent(domContainer, "touchmove")
48347 .subscribe(function (event) {
48348 event.preventDefault();
48350 this._touchStart$ = rxjs_1.fromEvent(canvasContainer, "touchstart");
48351 this._touchMove$ = rxjs_1.fromEvent(canvasContainer, "touchmove");
48352 this._touchEnd$ = rxjs_1.fromEvent(canvasContainer, "touchend");
48353 this._touchCancel$ = rxjs_1.fromEvent(canvasContainer, "touchcancel");
48354 var tapStart$ = this._touchStart$.pipe(operators_1.filter(function (te) {
48355 return te.touches.length === 1 && te.targetTouches.length === 1;
48356 }), operators_1.share());
48357 this._doubleTap$ = tapStart$.pipe(operators_1.bufferWhen(function () {
48358 return tapStart$.pipe(operators_1.first(), operators_1.switchMap(function (event) {
48359 return rxjs_1.merge(rxjs_1.timer(300), tapStart$).pipe(operators_1.take(1));
48361 }), operators_1.filter(function (events) {
48362 return events.length === 2;
48363 }), operators_1.map(function (events) {
48364 return events[events.length - 1];
48365 }), operators_1.share());
48367 .subscribe(function (event) {
48368 event.preventDefault();
48370 this._singleTouchMove$ = this._touchMove$.pipe(operators_1.filter(function (te) {
48371 return te.touches.length === 1 && te.targetTouches.length === 1;
48372 }), operators_1.share());
48373 var singleTouchStart$ = rxjs_1.merge(this._touchStart$, this._touchEnd$, this._touchCancel$).pipe(operators_1.filter(function (te) {
48374 return te.touches.length === 1 && te.targetTouches.length === 1;
48376 var multipleTouchStart$ = rxjs_1.merge(this._touchStart$, this._touchEnd$, this._touchCancel$).pipe(operators_1.filter(function (te) {
48377 return te.touches.length >= 1;
48379 var touchStop$ = rxjs_1.merge(this._touchEnd$, this._touchCancel$).pipe(operators_1.filter(function (te) {
48380 return te.touches.length === 0;
48382 this._singleTouchDragStart$ = singleTouchStart$.pipe(operators_1.mergeMap(function (e) {
48383 return _this._singleTouchMove$.pipe(operators_1.takeUntil(rxjs_1.merge(touchStop$, multipleTouchStart$)), operators_1.take(1));
48385 this._singleTouchDragEnd$ = singleTouchStart$.pipe(operators_1.mergeMap(function (e) {
48386 return rxjs_1.merge(touchStop$, multipleTouchStart$).pipe(operators_1.first());
48388 this._singleTouchDrag$ = singleTouchStart$.pipe(operators_1.switchMap(function (te) {
48389 return _this._singleTouchMove$.pipe(operators_1.skip(1), operators_1.takeUntil(rxjs_1.merge(multipleTouchStart$, touchStop$)));
48391 var touchesChanged$ = rxjs_1.merge(this._touchStart$, this._touchEnd$, this._touchCancel$);
48392 this._pinchStart$ = touchesChanged$.pipe(operators_1.filter(function (te) {
48393 return te.touches.length === 2 && te.targetTouches.length === 2;
48395 this._pinchEnd$ = touchesChanged$.pipe(operators_1.filter(function (te) {
48396 return te.touches.length !== 2 || te.targetTouches.length !== 2;
48398 this._pinchOperation$ = new rxjs_1.Subject();
48399 this._pinch$ = this._pinchOperation$.pipe(operators_1.scan(function (pinch, operation) {
48400 return operation(pinch);
48410 originalEvent: null,
48418 this._touchMove$.pipe(operators_1.filter(function (te) {
48419 return te.touches.length === 2 && te.targetTouches.length === 2;
48420 }), operators_1.map(function (te) {
48421 return function (previous) {
48422 var touch1 = te.touches[0];
48423 var touch2 = te.touches[1];
48424 var minX = Math.min(touch1.clientX, touch2.clientX);
48425 var maxX = Math.max(touch1.clientX, touch2.clientX);
48426 var minY = Math.min(touch1.clientY, touch2.clientY);
48427 var maxY = Math.max(touch1.clientY, touch2.clientY);
48428 var centerClientX = minX + (maxX - minX) / 2;
48429 var centerClientY = minY + (maxY - minY) / 2;
48430 var centerPageX = centerClientX + touch1.pageX - touch1.clientX;
48431 var centerPageY = centerClientY + touch1.pageY - touch1.clientY;
48432 var centerScreenX = centerClientX + touch1.screenX - touch1.clientX;
48433 var centerScreenY = centerClientY + touch1.screenY - touch1.clientY;
48434 var distanceX = Math.abs(touch1.clientX - touch2.clientX);
48435 var distanceY = Math.abs(touch1.clientY - touch2.clientY);
48436 var distance = Math.sqrt(distanceX * distanceX + distanceY * distanceY);
48437 var distanceChange = distance - previous.distance;
48438 var changeX = distanceX - previous.distanceX;
48439 var changeY = distanceY - previous.distanceY;
48443 clientX: centerClientX,
48444 clientY: centerClientY,
48445 distance: distance,
48446 distanceChange: distanceChange,
48447 distanceX: distanceX,
48448 distanceY: distanceY,
48450 pageX: centerPageX,
48451 pageY: centerPageY,
48452 screenX: centerScreenX,
48453 screenY: centerScreenY,
48460 .subscribe(this._pinchOperation$);
48461 this._pinchChange$ = this._pinchStart$.pipe(operators_1.switchMap(function (te) {
48462 return _this._pinch$.pipe(operators_1.skip(1), operators_1.takeUntil(_this._pinchEnd$));
48465 Object.defineProperty(TouchService.prototype, "active$", {
48467 return this._active$;
48472 Object.defineProperty(TouchService.prototype, "activate$", {
48474 return this._activeSubject$;
48479 Object.defineProperty(TouchService.prototype, "doubleTap$", {
48481 return this._doubleTap$;
48486 Object.defineProperty(TouchService.prototype, "touchStart$", {
48488 return this._touchStart$;
48493 Object.defineProperty(TouchService.prototype, "touchMove$", {
48495 return this._touchMove$;
48500 Object.defineProperty(TouchService.prototype, "touchEnd$", {
48502 return this._touchEnd$;
48507 Object.defineProperty(TouchService.prototype, "touchCancel$", {
48509 return this._touchCancel$;
48514 Object.defineProperty(TouchService.prototype, "singleTouchDragStart$", {
48516 return this._singleTouchDragStart$;
48521 Object.defineProperty(TouchService.prototype, "singleTouchDrag$", {
48523 return this._singleTouchDrag$;
48528 Object.defineProperty(TouchService.prototype, "singleTouchDragEnd$", {
48530 return this._singleTouchDragEnd$;
48535 Object.defineProperty(TouchService.prototype, "pinch$", {
48537 return this._pinchChange$;
48542 Object.defineProperty(TouchService.prototype, "pinchStart$", {
48544 return this._pinchStart$;
48549 Object.defineProperty(TouchService.prototype, "pinchEnd$", {
48551 return this._pinchEnd$;
48556 return TouchService;
48558 exports.TouchService = TouchService;
48560 },{"rxjs":27,"rxjs/operators":225}],445:[function(require,module,exports){
48562 var __extends = (this && this.__extends) || (function () {
48563 var extendStatics = function (d, b) {
48564 extendStatics = Object.setPrototypeOf ||
48565 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
48566 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
48567 return extendStatics(d, b);
48569 return function (d, b) {
48570 extendStatics(d, b);
48571 function __() { this.constructor = d; }
48572 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
48575 Object.defineProperty(exports, "__esModule", { value: true });
48576 var rxjs_1 = require("rxjs");
48577 var operators_1 = require("rxjs/operators");
48578 var when = require("when");
48579 var Viewer_1 = require("../Viewer");
48580 var Utils_1 = require("../Utils");
48584 * @classdesc The Viewer object represents the navigable image viewer.
48585 * Create a Viewer by specifying a container, client ID, image key and
48586 * other options. The viewer exposes methods and events for programmatic
48589 * In the case of asynchronous methods, MapillaryJS returns promises to
48590 * the results. Notifications are always emitted through JavaScript events.
48592 * The viewer works with a few different coordinate systems.
48594 * Container pixel coordinates
48596 * Pixel coordinates are coordinates on the viewer container. The origin is
48597 * in the top left corner of the container. The axes are
48598 * directed according to the following for a viewer container with a width
48599 * of 640 pixels and height of 480 pixels.
48603 * +------------------------>
48608 * (0, 480) (640, 480)
48611 * Basic image coordinates
48613 * Basic image coordinates represents points in the original image adjusted for
48614 * orientation. They range from 0 to 1 on both axes. The origin is in the top left
48615 * corner of the image and the axes are directed
48616 * according to the following for all image types.
48620 * +------------------------>
48628 * For every camera viewing direction it is possible to convert between these
48629 * two coordinate systems for the current node. The image can be panned and
48630 * zoomed independently of the size of the viewer container resulting in
48631 * different conversion results for different viewing directions.
48633 var Viewer = /** @class */ (function (_super) {
48634 __extends(Viewer, _super);
48636 * Create a new viewer instance.
48638 * @description It is possible to initialize the viewer with or
48641 * When you want to show a specific image in the viewer from
48642 * the start you should initialize it with a key.
48644 * When you do not know the first image key at implementation
48645 * time, e.g. in a map-viewer application you should initialize
48646 * the viewer without a key and call `moveToKey` instead.
48648 * When initializing with a key the viewer is bound to that key
48649 * until the node for that key has been successfully loaded.
48650 * Also, a cover with the image of the key will be shown.
48651 * If the data for that key can not be loaded because the key is
48652 * faulty or other errors occur it is not possible to navigate
48653 * to another key because the viewer is not navigable. The viewer
48654 * becomes navigable when the data for the key has been loaded and
48655 * the image is shown in the viewer. This way of initializing
48656 * the viewer is mostly for embedding in blog posts and similar
48657 * where one wants to show a specific image initially.
48659 * If the viewer is initialized without a key (with null or
48660 * undefined) it is not bound to any particular key and it is
48661 * possible to move to any key with `viewer.moveToKey("<my-image-key>")`.
48662 * If the first move to a key fails it is possible to move to another
48663 * key. The viewer will show a black background until a move
48664 * succeeds. This way of intitializing is suited for a map-viewer
48665 * application when the initial key is not known at implementation
48668 * @param {string} id - Required `id` of a DOM element which will
48669 * be transformed into the viewer.
48670 * @param {string} clientId - Required `Mapillary API ClientID`. Can
48671 * be obtained from https://www.mapillary.com/app/settings/developers.
48672 * @param {string} key - Optional `image-key` to start from. The key
48673 * can be any Mapillary image. If a key is provided the viewer is
48674 * bound to that key until it has been fully loaded. If null is provided
48675 * no image is loaded at viewer initialization and the viewer is not
48676 * bound to any particular key. Any image can then be navigated to
48677 * with e.g. `viewer.moveToKey("<my-image-key>")`.
48678 * @param {IViewerOptions} options - Optional configuration object
48679 * specifing Viewer's and the components' initial setup.
48680 * @param {string} token - Optional bearer token for API requests of
48681 * protected resources.
48685 * var viewer = new Mapillary.Viewer("<element-id>", "<client-id>", "<image-key>");
48688 function Viewer(id, clientId, key, options, token) {
48689 var _this = _super.call(this) || this;
48690 options = options != null ? options : {};
48691 Utils_1.Settings.setOptions(options);
48692 Utils_1.Urls.setOptions(options.url);
48693 _this._navigator = new Viewer_1.Navigator(clientId, options, token);
48694 _this._container = new Viewer_1.Container(id, _this._navigator.stateService, options);
48695 _this._observer = new Viewer_1.Observer(_this, _this._navigator, _this._container);
48696 _this._componentController = new Viewer_1.ComponentController(_this._container, _this._navigator, _this._observer, key, options.component);
48699 Object.defineProperty(Viewer.prototype, "isNavigable", {
48701 * Return a boolean indicating if the viewer is in a navigable state.
48703 * @description The navigable state indicates if the viewer supports
48704 * moving, i.e. calling the {@link moveToKey}, {@link moveDir`}
48705 * and {@link moveCloseTo} methods or changing the authentication state,
48706 * i.e. calling {@link setAuthToken}. The viewer will not be in a navigable
48707 * state if the cover is activated and the viewer has been supplied a key.
48708 * When the cover is deactivated or the viewer is activated without being
48709 * supplied a key it will be navigable.
48711 * @returns {boolean} Boolean indicating whether the viewer is navigable.
48714 return this._componentController.navigable;
48720 * Activate a component.
48722 * @param {string} name - Name of the component which will become active.
48726 * viewer.activateComponent("marker");
48729 Viewer.prototype.activateComponent = function (name) {
48730 this._componentController.activate(name);
48733 * Activate the cover (deactivates all other components).
48735 Viewer.prototype.activateCover = function () {
48736 this._componentController.activateCover();
48739 * Deactivate a component.
48741 * @param {string} name - Name of component which become inactive.
48745 * viewer.deactivateComponent("mouse");
48748 Viewer.prototype.deactivateComponent = function (name) {
48749 this._componentController.deactivate(name);
48752 * Deactivate the cover (activates all components marked as active).
48754 Viewer.prototype.deactivateCover = function () {
48755 this._componentController.deactivateCover();
48758 * Get the bearing of the current viewer camera.
48760 * @description The bearing depends on how the camera
48761 * is currently rotated and does not correspond
48762 * to the compass angle of the current node if the view
48765 * Bearing is measured in degrees clockwise with respect to
48768 * @returns {Promise<number>} Promise to the bearing
48769 * of the current viewer camera.
48773 * viewer.getBearing().then((b) => { console.log(b); });
48776 Viewer.prototype.getBearing = function () {
48778 return when.promise(function (resolve, reject) {
48779 _this._container.renderService.bearing$.pipe(operators_1.first())
48780 .subscribe(function (bearing) {
48782 }, function (error) {
48788 * Get the basic coordinates of the current image that is
48789 * at the center of the viewport.
48791 * @description Basic coordinates are 2D coordinates on the [0, 1] interval
48792 * and have the origin point, (0, 0), at the top left corner and the
48793 * maximum value, (1, 1), at the bottom right corner of the original
48796 * @returns {Promise<number[]>} Promise to the basic coordinates
48797 * of the current image at the center for the viewport.
48801 * viewer.getCenter().then((c) => { console.log(c); });
48804 Viewer.prototype.getCenter = function () {
48806 return when.promise(function (resolve, reject) {
48807 _this._navigator.stateService.getCenter()
48808 .subscribe(function (center) {
48810 }, function (error) {
48818 * @param {string} name - Name of component.
48819 * @returns {Component} The requested component.
48823 * var mouseComponent = viewer.getComponent("mouse");
48826 Viewer.prototype.getComponent = function (name) {
48827 return this._componentController.get(name);
48830 * Returns the viewer's containing HTML element.
48832 * @returns {HTMLElement} The viewer's container.
48834 Viewer.prototype.getContainer = function () {
48835 return this._container.element;
48838 * Get the image's current zoom level.
48840 * @returns {Promise<number>} Promise to the viewers's current
48845 * viewer.getZoom().then((z) => { console.log(z); });
48848 Viewer.prototype.getZoom = function () {
48850 return when.promise(function (resolve, reject) {
48851 _this._navigator.stateService.getZoom()
48852 .subscribe(function (zoom) {
48854 }, function (error) {
48860 * Move close to given latitude and longitude.
48862 * @description Because the method propagates IO errors, these potential errors
48863 * need to be handled by the method caller (see example).
48865 * @param {Number} lat - Latitude, in degrees.
48866 * @param {Number} lon - Longitude, in degrees.
48867 * @returns {Promise<Node>} Promise to the node that was navigated to.
48868 * @throws {Error} If no nodes exist close to provided latitude
48870 * @throws {Error} Propagates any IO errors to the caller.
48871 * @throws {Error} When viewer is not navigable.
48872 * @throws {AbortMapillaryError} When a subsequent move request is made
48873 * before the move close to call has completed.
48877 * viewer.moveCloseTo(0, 0).then(
48878 * (n) => { console.log(n); },
48879 * (e) => { console.error(e); });
48882 Viewer.prototype.moveCloseTo = function (lat, lon) {
48883 var moveCloseTo$ = this.isNavigable ?
48884 this._navigator.moveCloseTo$(lat, lon) :
48885 rxjs_1.throwError(new Error("Calling moveCloseTo is not supported when viewer is not navigable."));
48886 return when.promise(function (resolve, reject) {
48887 moveCloseTo$.subscribe(function (node) {
48889 }, function (error) {
48895 * Navigate in a given direction.
48897 * @description This method has to be called through EdgeDirection enumeration as in the example.
48899 * @param {EdgeDirection} dir - Direction in which which to move.
48900 * @returns {Promise<Node>} Promise to the node that was navigated to.
48901 * @throws {Error} If the current node does not have the edge direction
48902 * or the edges has not yet been cached.
48903 * @throws {Error} Propagates any IO errors to the caller.
48904 * @throws {Error} When viewer is not navigable.
48905 * @throws {AbortMapillaryError} When a subsequent move request is made
48906 * before the move dir call has completed.
48910 * viewer.moveDir(Mapillary.EdgeDirection.Next).then(
48911 * (n) => { console.log(n); },
48912 * (e) => { console.error(e); });
48915 Viewer.prototype.moveDir = function (dir) {
48916 var moveDir$ = this.isNavigable ?
48917 this._navigator.moveDir$(dir) :
48918 rxjs_1.throwError(new Error("Calling moveDir is not supported when viewer is not navigable."));
48919 return when.promise(function (resolve, reject) {
48920 moveDir$.subscribe(function (node) {
48922 }, function (error) {
48928 * Navigate to a given image key.
48930 * @param {string} key - A valid Mapillary image key.
48931 * @returns {Promise<Node>} Promise to the node that was navigated to.
48932 * @throws {Error} Propagates any IO errors to the caller.
48933 * @throws {Error} When viewer is not navigable.
48934 * @throws {AbortMapillaryError} When a subsequent move request is made
48935 * before the move to key call has completed.
48939 * viewer.moveToKey("<my key>").then(
48940 * (n) => { console.log(n); },
48941 * (e) => { console.error(e); });
48944 Viewer.prototype.moveToKey = function (key) {
48945 var moveToKey$ = this.isNavigable ?
48946 this._navigator.moveToKey$(key) :
48947 rxjs_1.throwError(new Error("Calling moveToKey is not supported when viewer is not navigable."));
48948 return when.promise(function (resolve, reject) {
48949 moveToKey$.subscribe(function (node) {
48951 }, function (error) {
48957 * Project basic image coordinates for the current node to canvas pixel
48960 * @description The basic image coordinates may not always correspond to a
48961 * pixel point that lies in the visible area of the viewer container.
48963 * @param {Array<number>} basicPoint - Basic images coordinates to project.
48964 * @returns {Promise<Array<number>>} Promise to the pixel coordinates corresponding
48965 * to the basic image point.
48969 * viewer.projectFromBasic([0.3, 0.7])
48970 * .then((pixelPoint) => { console.log(pixelPoint); });
48973 Viewer.prototype.projectFromBasic = function (basicPoint) {
48975 return when.promise(function (resolve, reject) {
48976 _this._observer.projectBasic$(basicPoint)
48977 .subscribe(function (pixelPoint) {
48978 resolve(pixelPoint);
48979 }, function (error) {
48985 * Detect the viewer's new width and height and resize it.
48987 * @description The components will also detect the viewer's
48988 * new size and resize their rendered elements if needed.
48995 Viewer.prototype.resize = function () {
48996 this._container.renderService.resize$.next(null);
48999 * Set a bearer token for authenticated API requests of
49000 * protected resources.
49002 * @description When the supplied token is null or undefined,
49003 * any previously set bearer token will be cleared and the
49004 * viewer will make unauthenticated requests.
49006 * Calling setAuthToken aborts all outstanding move requests.
49007 * The promises of those move requests will be rejected with a
49008 * {@link AbortMapillaryError} the rejections need to be caught.
49010 * Calling setAuthToken also resets the complete viewer cache
49011 * so it should not be called repeatedly.
49013 * @param {string} [token] token - Bearer token.
49014 * @returns {Promise<void>} Promise that resolves after token
49017 * @throws {Error} When viewer is not navigable.
49021 * viewer.setAuthToken("<my token>")
49022 * .then(() => { console.log("token set"); });
49025 Viewer.prototype.setAuthToken = function (token) {
49026 var setToken$ = this.isNavigable ?
49027 this._navigator.setToken$(token) :
49028 rxjs_1.throwError(new Error("Calling setAuthToken is not supported when viewer is not navigable."));
49029 return when.promise(function (resolve, reject) {
49031 .subscribe(function () {
49032 resolve(undefined);
49033 }, function (error) {
49039 * Set the basic coordinates of the current image to be in the
49040 * center of the viewport.
49042 * @description Basic coordinates are 2D coordinates on the [0, 1] interval
49043 * and has the origin point, (0, 0), at the top left corner and the
49044 * maximum value, (1, 1), at the bottom right corner of the original
49047 * @param {number[]} The basic coordinates of the current
49048 * image to be at the center for the viewport.
49052 * viewer.setCenter([0.5, 0.5]);
49055 Viewer.prototype.setCenter = function (center) {
49056 this._navigator.stateService.setCenter(center);
49059 * Set the filter selecting nodes to use when calculating
49060 * the spatial edges.
49062 * @description The following filter types are supported:
49066 * `["==", key, value]` equality: `node[key] = value`
49068 * `["!=", key, value]` inequality: `node[key] ≠value`
49070 * `["<", key, value]` less than: `node[key] < value`
49072 * `["<=", key, value]` less than or equal: `node[key] ≤ value`
49074 * `[">", key, value]` greater than: `node[key] > value`
49076 * `[">=", key, value]` greater than or equal: `node[key] ≥ value`
49080 * `["in", key, v0, ..., vn]` set inclusion: `node[key] ∈ {v0, ..., vn}`
49082 * `["!in", key, v0, ..., vn]` set exclusion: `node[key] ∉ {v0, ..., vn}`
49086 * `["all", f0, ..., fn]` logical `AND`: `f0 ∧ ... ∧ fn`
49088 * A key must be a string that identifies a property name of a
49089 * simple {@link Node} property. A value must be a string, number, or
49090 * boolean. Strictly-typed comparisons are used. The values
49091 * `f0, ..., fn` of the combining filter must be filter expressions.
49093 * Clear the filter by setting it to null or empty array.
49095 * @param {FilterExpression} filter - The filter expression.
49096 * @returns {Promise<void>} Promise that resolves after filter is applied.
49100 * viewer.setFilter(["==", "sequenceKey", "<my sequence key>"]);
49103 Viewer.prototype.setFilter = function (filter) {
49105 return when.promise(function (resolve, reject) {
49106 _this._navigator.setFilter$(filter)
49107 .subscribe(function () {
49108 resolve(undefined);
49109 }, function (error) {
49115 * Set the viewer's render mode.
49117 * @param {RenderMode} renderMode - Render mode.
49121 * viewer.setRenderMode(Mapillary.RenderMode.Letterbox);
49124 Viewer.prototype.setRenderMode = function (renderMode) {
49125 this._container.renderService.renderMode$.next(renderMode);
49128 * Set the viewer's transition mode.
49130 * @param {TransitionMode} transitionMode - Transition mode.
49134 * viewer.setTransitionMode(Mapillary.TransitionMode.Instantaneous);
49137 Viewer.prototype.setTransitionMode = function (transitionMode) {
49138 this._navigator.stateService.setTransitionMode(transitionMode);
49141 * Set the image's current zoom level.
49143 * @description Possible zoom level values are on the [0, 3] interval.
49144 * Zero means zooming out to fit the image to the view whereas three
49145 * shows the highest level of detail.
49147 * @param {number} The image's current zoom level.
49151 * viewer.setZoom(2);
49154 Viewer.prototype.setZoom = function (zoom) {
49155 this._navigator.stateService.setZoom(zoom);
49158 * Unproject canvas pixel coordinates to an ILatLon representing geographical
49161 * @description The pixel point may not always correspond to geographical
49162 * coordinates. In the case of no correspondence the returned value will
49165 * @param {Array<number>} pixelPoint - Pixel coordinates to unproject.
49166 * @returns {Promise<ILatLon>} Promise to the latLon corresponding to the pixel point.
49170 * viewer.unproject([100, 100])
49171 * .then((latLon) => { console.log(latLon); });
49174 Viewer.prototype.unproject = function (pixelPoint) {
49176 return when.promise(function (resolve, reject) {
49177 _this._observer.unproject$(pixelPoint)
49178 .subscribe(function (latLon) {
49180 }, function (error) {
49186 * Unproject canvas pixel coordinates to basic image coordinates for the
49189 * @description The pixel point may not always correspond to basic image
49190 * coordinates. In the case of no correspondence the returned value will
49193 * @param {Array<number>} pixelPoint - Pixel coordinates to unproject.
49194 * @returns {Promise<ILatLon>} Promise to the basic coordinates corresponding
49195 * to the pixel point.
49199 * viewer.unprojectToBasic([100, 100])
49200 * .then((basicPoint) => { console.log(basicPoint); });
49203 Viewer.prototype.unprojectToBasic = function (pixelPoint) {
49205 return when.promise(function (resolve, reject) {
49206 _this._observer.unprojectBasic$(pixelPoint)
49207 .subscribe(function (basicPoint) {
49208 resolve(basicPoint);
49209 }, function (error) {
49215 * Fired when the viewing direction of the camera changes.
49217 * @description Related to the computed compass angle
49218 * ({@link Node.computedCa}) from SfM, not the original EXIF compass
49222 * @type {number} bearing - Value indicating the current bearing
49223 * measured in degrees clockwise with respect to north.
49225 Viewer.bearingchanged = "bearingchanged";
49227 * Fired when a pointing device (usually a mouse) is pressed and released at
49228 * the same point in the viewer.
49230 * @type {IViewerMouseEvent} event - Viewer mouse event data.
49232 Viewer.click = "click";
49234 * Fired when the right button of the mouse is clicked within the viewer.
49236 * @type {IViewerMouseEvent} event - Viewer mouse event data.
49238 Viewer.contextmenu = "contextmenu";
49240 * Fired when a pointing device (usually a mouse) is clicked twice at
49241 * the same point in the viewer.
49243 * @type {IViewerMouseEvent} event - Viewer mouse event data.
49245 Viewer.dblclick = "dblclick";
49247 * Fired when the viewer is loading more data.
49249 * @type {boolean} loading - Boolean indicating whether the viewer is loading.
49251 Viewer.loadingchanged = "loadingchanged";
49253 * Fired when a pointing device (usually a mouse) is pressed within the viewer.
49255 * @type {IViewerMouseEvent} event - Viewer mouse event data.
49257 Viewer.mousedown = "mousedown";
49259 * Fired when a pointing device (usually a mouse) is moved within the viewer.
49260 * @description Will not fire when the mouse is actively used, e.g. for drag pan.
49262 * @type {IViewerMouseEvent} event - Viewer mouse event data.
49264 Viewer.mousemove = "mousemove";
49266 * Fired when a pointing device (usually a mouse) leaves the viewer's canvas.
49268 * @type {IViewerMouseEvent} event - Viewer mouse event data.
49270 Viewer.mouseout = "mouseout";
49272 * Fired when a pointing device (usually a mouse) is moved onto the viewer's canvas.
49274 * @type {IViewerMouseEvent} event - Viewer mouse event data.
49276 Viewer.mouseover = "mouseover";
49278 * Fired when a pointing device (usually a mouse) is released within the viewer.
49280 * @type {IViewerMouseEvent} event - Viewer mouse event data.
49282 Viewer.mouseup = "mouseup";
49284 * Fired when the viewer motion stops and it is in a fixed
49285 * position with a fixed point of view.
49288 Viewer.moveend = "moveend";
49290 * Fired when the motion from one view to another start,
49291 * either by changing the position (e.g. when changing node) or
49292 * when changing point of view (e.g. by interaction such as pan and zoom).
49295 Viewer.movestart = "movestart";
49297 * Fired when the navigable state of the viewer changes.
49299 * @description The navigable state indicates if the viewer supports
49300 * moving, i.e. calling the `moveToKey`, `moveDir` and `moveCloseTo`
49301 * methods. The viewer will not be in a navigable state if the cover
49302 * is activated and the viewer has been supplied a key. When the cover
49303 * is deactivated or activated without being supplied a key it will
49307 * @type {boolean} navigable - Boolean indicating whether the viewer is navigable.
49309 Viewer.navigablechanged = "navigablechanged";
49311 * Fired every time the viewer navigates to a new node.
49313 * @type {Node} node - Current node.
49315 Viewer.nodechanged = "nodechanged";
49317 * Fired every time the sequence edges of the current node changes.
49319 * @type {IEdgeStatus} status - The edge status object.
49321 Viewer.sequenceedgeschanged = "sequenceedgeschanged";
49323 * Fired every time the spatial edges of the current node changes.
49325 * @type {IEdgeStatus} status - The edge status object.
49327 Viewer.spatialedgeschanged = "spatialedgeschanged";
49329 }(Utils_1.EventEmitter));
49330 exports.Viewer = Viewer;
49332 },{"../Utils":285,"../Viewer":286,"rxjs":27,"rxjs/operators":225,"when":272}]},{},[280])(280)
49334 //# sourceMappingURL=mapillary.js.map