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 exports.byteLength = byteLength
5 exports.toByteArray = toByteArray
6 exports.fromByteArray = fromByteArray
10 var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
12 var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
13 for (var i = 0, len = code.length; i < len; ++i) {
15 revLookup[code.charCodeAt(i)] = i
18 revLookup['-'.charCodeAt(0)] = 62
19 revLookup['_'.charCodeAt(0)] = 63
21 function placeHoldersCount (b64) {
24 throw new Error('Invalid string. Length must be a multiple of 4')
27 // the number of equal signs (place holders)
28 // if there are two placeholders, than the two characters before it
30 // if there is only one, then the three characters before it represent 2 bytes
31 // this is just a cheap hack to not do indexOf twice
32 return b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0
35 function byteLength (b64) {
36 // base64 is 4/3 + up to two characters of the original data
37 return b64.length * 3 / 4 - placeHoldersCount(b64)
40 function toByteArray (b64) {
41 var i, j, l, tmp, placeHolders, arr
43 placeHolders = placeHoldersCount(b64)
45 arr = new Arr(len * 3 / 4 - placeHolders)
47 // if there are placeholders, only get up to the last complete 4 chars
48 l = placeHolders > 0 ? len - 4 : len
52 for (i = 0, j = 0; i < l; i += 4, j += 3) {
53 tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)]
54 arr[L++] = (tmp >> 16) & 0xFF
55 arr[L++] = (tmp >> 8) & 0xFF
59 if (placeHolders === 2) {
60 tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4)
62 } else if (placeHolders === 1) {
63 tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2)
64 arr[L++] = (tmp >> 8) & 0xFF
71 function tripletToBase64 (num) {
72 return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F]
75 function encodeChunk (uint8, start, end) {
78 for (var i = start; i < end; i += 3) {
79 tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2])
80 output.push(tripletToBase64(tmp))
82 return output.join('')
85 function fromByteArray (uint8) {
87 var len = uint8.length
88 var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
91 var maxChunkLength = 16383 // must be multiple of 3
93 // go through the array every three bytes, we'll deal with trailing stuff later
94 for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
95 parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))
98 // pad the end with zeros, but make sure to not forget the extra bytes
99 if (extraBytes === 1) {
101 output += lookup[tmp >> 2]
102 output += lookup[(tmp << 4) & 0x3F]
104 } else if (extraBytes === 2) {
105 tmp = (uint8[len - 2] << 8) + (uint8[len - 1])
106 output += lookup[tmp >> 10]
107 output += lookup[(tmp >> 4) & 0x3F]
108 output += lookup[(tmp << 2) & 0x3F]
114 return parts.join('')
117 },{}],2:[function(require,module,exports){
119 },{}],3:[function(require,module,exports){
121 * Cross-Browser Split 1.1.1
122 * Copyright 2007-2012 Steven Levithan <stevenlevithan.com>
123 * Available under the MIT License
124 * ECMAScript compliant, uniform cross-browser split method
128 * Splits a string into an array of strings using a regex or string separator. Matches of the
129 * separator are not included in the result array. However, if `separator` is a regex that contains
130 * capturing groups, backreferences are spliced into the result each time `separator` is matched.
131 * Fixes browser bugs compared to the native `String.prototype.split` and can be used reliably
133 * @param {String} str String to split.
134 * @param {RegExp|String} separator Regex or string to use for separating the string.
135 * @param {Number} [limit] Maximum number of items to include in the result array.
136 * @returns {Array} Array of substrings.
140 * split('a b c d', ' ');
141 * // -> ['a', 'b', 'c', 'd']
144 * split('a b c d', ' ', 2);
147 * // Backreferences in result array
148 * split('..word1 word2..', /([a-z]+)(\d+)/i);
149 * // -> ['..', 'word', '1', ' ', 'word', '2', '..']
151 module.exports = (function split(undef) {
153 var nativeSplit = String.prototype.split,
154 compliantExecNpcg = /()??/.exec("")[1] === undef,
155 // NPCG: nonparticipating capturing group
158 self = function(str, separator, limit) {
159 // If `separator` is not a regex, use `nativeSplit`
160 if (Object.prototype.toString.call(separator) !== "[object RegExp]") {
161 return nativeSplit.call(str, separator, limit);
164 flags = (separator.ignoreCase ? "i" : "") + (separator.multiline ? "m" : "") + (separator.extended ? "x" : "") + // Proposed for ES6
165 (separator.sticky ? "y" : ""),
168 // Make `global` and avoid `lastIndex` issues by working with a copy
169 separator = new RegExp(separator.source, flags + "g"),
170 separator2, match, lastIndex, lastLength;
171 str += ""; // Type-convert
172 if (!compliantExecNpcg) {
173 // Doesn't need flags gy, but they don't hurt
174 separator2 = new RegExp("^" + separator.source + "$(?!\\s)", flags);
176 /* Values for `limit`, per the spec:
177 * If undefined: 4294967295 // Math.pow(2, 32) - 1
178 * If 0, Infinity, or NaN: 0
179 * If positive number: limit = Math.floor(limit); if (limit > 4294967295) limit -= 4294967296;
180 * If negative number: 4294967296 - Math.floor(Math.abs(limit))
181 * If other: Type-convert, then use the above rules
183 limit = limit === undef ? -1 >>> 0 : // Math.pow(2, 32) - 1
184 limit >>> 0; // ToUint32(limit)
185 while (match = separator.exec(str)) {
186 // `separator.lastIndex` is not reliable cross-browser
187 lastIndex = match.index + match[0].length;
188 if (lastIndex > lastLastIndex) {
189 output.push(str.slice(lastLastIndex, match.index));
190 // Fix browsers whose `exec` methods don't consistently return `undefined` for
191 // nonparticipating capturing groups
192 if (!compliantExecNpcg && match.length > 1) {
193 match[0].replace(separator2, function() {
194 for (var i = 1; i < arguments.length - 2; i++) {
195 if (arguments[i] === undef) {
201 if (match.length > 1 && match.index < str.length) {
202 Array.prototype.push.apply(output, match.slice(1));
204 lastLength = match[0].length;
205 lastLastIndex = lastIndex;
206 if (output.length >= limit) {
210 if (separator.lastIndex === match.index) {
211 separator.lastIndex++; // Avoid an infinite loop
214 if (lastLastIndex === str.length) {
215 if (lastLength || !separator.test("")) {
219 output.push(str.slice(lastLastIndex));
221 return output.length > limit ? output.slice(0, limit) : output;
227 },{}],4:[function(require,module,exports){
228 // shim for using process in browser
229 var process = module.exports = {};
231 // cached from whatever global is present so that test runners that stub it
232 // don't break things. But we need to wrap it in a try catch in case it is
233 // wrapped in strict mode code which doesn't define any globals. It's inside a
234 // function because try/catches deoptimize in certain engines.
236 var cachedSetTimeout;
237 var cachedClearTimeout;
239 function defaultSetTimout() {
240 throw new Error('setTimeout has not been defined');
242 function defaultClearTimeout () {
243 throw new Error('clearTimeout has not been defined');
247 if (typeof setTimeout === 'function') {
248 cachedSetTimeout = setTimeout;
250 cachedSetTimeout = defaultSetTimout;
253 cachedSetTimeout = defaultSetTimout;
256 if (typeof clearTimeout === 'function') {
257 cachedClearTimeout = clearTimeout;
259 cachedClearTimeout = defaultClearTimeout;
262 cachedClearTimeout = defaultClearTimeout;
265 function runTimeout(fun) {
266 if (cachedSetTimeout === setTimeout) {
267 //normal enviroments in sane situations
268 return setTimeout(fun, 0);
270 // if setTimeout wasn't available but was latter defined
271 if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
272 cachedSetTimeout = setTimeout;
273 return setTimeout(fun, 0);
276 // when when somebody has screwed with setTimeout but no I.E. maddness
277 return cachedSetTimeout(fun, 0);
280 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
281 return cachedSetTimeout.call(null, fun, 0);
283 // 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
284 return cachedSetTimeout.call(this, fun, 0);
290 function runClearTimeout(marker) {
291 if (cachedClearTimeout === clearTimeout) {
292 //normal enviroments in sane situations
293 return clearTimeout(marker);
295 // if clearTimeout wasn't available but was latter defined
296 if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
297 cachedClearTimeout = clearTimeout;
298 return clearTimeout(marker);
301 // when when somebody has screwed with setTimeout but no I.E. maddness
302 return cachedClearTimeout(marker);
305 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
306 return cachedClearTimeout.call(null, marker);
308 // 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.
309 // Some versions of I.E. have different rules for clearTimeout vs setTimeout
310 return cachedClearTimeout.call(this, marker);
318 var draining = false;
322 function cleanUpNextTick() {
323 if (!draining || !currentQueue) {
327 if (currentQueue.length) {
328 queue = currentQueue.concat(queue);
337 function drainQueue() {
341 var timeout = runTimeout(cleanUpNextTick);
344 var len = queue.length;
346 currentQueue = queue;
348 while (++queueIndex < len) {
350 currentQueue[queueIndex].run();
358 runClearTimeout(timeout);
361 process.nextTick = function (fun) {
362 var args = new Array(arguments.length - 1);
363 if (arguments.length > 1) {
364 for (var i = 1; i < arguments.length; i++) {
365 args[i - 1] = arguments[i];
368 queue.push(new Item(fun, args));
369 if (queue.length === 1 && !draining) {
370 runTimeout(drainQueue);
374 // v8 likes predictible objects
375 function Item(fun, array) {
379 Item.prototype.run = function () {
380 this.fun.apply(null, this.array);
382 process.title = 'browser';
383 process.browser = true;
386 process.version = ''; // empty string to avoid regexp issues
387 process.versions = {};
392 process.addListener = noop;
395 process.removeListener = noop;
396 process.removeAllListeners = noop;
399 process.binding = function (name) {
400 throw new Error('process.binding is not supported');
403 process.cwd = function () { return '/' };
404 process.chdir = function (dir) {
405 throw new Error('process.chdir is not supported');
407 process.umask = function() { return 0; };
409 },{}],5:[function(require,module,exports){
412 * The buffer module from node.js, for the browser.
414 * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
417 /* eslint-disable no-proto */
421 var base64 = require('base64-js')
422 var ieee754 = require('ieee754')
423 var isArray = require('isarray')
425 exports.Buffer = Buffer
426 exports.SlowBuffer = SlowBuffer
427 exports.INSPECT_MAX_BYTES = 50
430 * If `Buffer.TYPED_ARRAY_SUPPORT`:
431 * === true Use Uint8Array implementation (fastest)
432 * === false Use Object implementation (most compatible, even IE6)
434 * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
435 * Opera 11.6+, iOS 4.2+.
437 * Due to various browser bugs, sometimes the Object implementation will be used even
438 * when the browser supports typed arrays.
442 * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
443 * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
445 * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
447 * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
448 * incorrect length in some situations.
450 * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
451 * get the Object implementation, which is slower but behaves correctly.
453 Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
454 ? global.TYPED_ARRAY_SUPPORT
455 : typedArraySupport()
458 * Export kMaxLength after typed array support is determined.
460 exports.kMaxLength = kMaxLength()
462 function typedArraySupport () {
464 var arr = new Uint8Array(1)
465 arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
466 return arr.foo() === 42 && // typed array instances can be augmented
467 typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
468 arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
474 function kMaxLength () {
475 return Buffer.TYPED_ARRAY_SUPPORT
480 function createBuffer (that, length) {
481 if (kMaxLength() < length) {
482 throw new RangeError('Invalid typed array length')
484 if (Buffer.TYPED_ARRAY_SUPPORT) {
485 // Return an augmented `Uint8Array` instance, for best performance
486 that = new Uint8Array(length)
487 that.__proto__ = Buffer.prototype
489 // Fallback: Return an object instance of the Buffer class
491 that = new Buffer(length)
500 * The Buffer constructor returns instances of `Uint8Array` that have their
501 * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
502 * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
503 * and the `Uint8Array` methods. Square bracket notation works as expected -- it
504 * returns a single octet.
506 * The `Uint8Array` prototype remains unmodified.
509 function Buffer (arg, encodingOrOffset, length) {
510 if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {
511 return new Buffer(arg, encodingOrOffset, length)
515 if (typeof arg === 'number') {
516 if (typeof encodingOrOffset === 'string') {
518 'If encoding is specified then the first argument must be a string'
521 return allocUnsafe(this, arg)
523 return from(this, arg, encodingOrOffset, length)
526 Buffer.poolSize = 8192 // not used by this implementation
528 // TODO: Legacy, not needed anymore. Remove in next major version.
529 Buffer._augment = function (arr) {
530 arr.__proto__ = Buffer.prototype
534 function from (that, value, encodingOrOffset, length) {
535 if (typeof value === 'number') {
536 throw new TypeError('"value" argument must not be a number')
539 if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
540 return fromArrayBuffer(that, value, encodingOrOffset, length)
543 if (typeof value === 'string') {
544 return fromString(that, value, encodingOrOffset)
547 return fromObject(that, value)
551 * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
552 * if value is a number.
553 * Buffer.from(str[, encoding])
555 * Buffer.from(buffer)
556 * Buffer.from(arrayBuffer[, byteOffset[, length]])
558 Buffer.from = function (value, encodingOrOffset, length) {
559 return from(null, value, encodingOrOffset, length)
562 if (Buffer.TYPED_ARRAY_SUPPORT) {
563 Buffer.prototype.__proto__ = Uint8Array.prototype
564 Buffer.__proto__ = Uint8Array
565 if (typeof Symbol !== 'undefined' && Symbol.species &&
566 Buffer[Symbol.species] === Buffer) {
567 // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
568 Object.defineProperty(Buffer, Symbol.species, {
575 function assertSize (size) {
576 if (typeof size !== 'number') {
577 throw new TypeError('"size" argument must be a number')
578 } else if (size < 0) {
579 throw new RangeError('"size" argument must not be negative')
583 function alloc (that, size, fill, encoding) {
586 return createBuffer(that, size)
588 if (fill !== undefined) {
589 // Only pay attention to encoding if it's a string. This
590 // prevents accidentally sending in a number that would
591 // be interpretted as a start offset.
592 return typeof encoding === 'string'
593 ? createBuffer(that, size).fill(fill, encoding)
594 : createBuffer(that, size).fill(fill)
596 return createBuffer(that, size)
600 * Creates a new filled Buffer instance.
601 * alloc(size[, fill[, encoding]])
603 Buffer.alloc = function (size, fill, encoding) {
604 return alloc(null, size, fill, encoding)
607 function allocUnsafe (that, size) {
609 that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)
610 if (!Buffer.TYPED_ARRAY_SUPPORT) {
611 for (var i = 0; i < size; ++i) {
619 * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
621 Buffer.allocUnsafe = function (size) {
622 return allocUnsafe(null, size)
625 * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
627 Buffer.allocUnsafeSlow = function (size) {
628 return allocUnsafe(null, size)
631 function fromString (that, string, encoding) {
632 if (typeof encoding !== 'string' || encoding === '') {
636 if (!Buffer.isEncoding(encoding)) {
637 throw new TypeError('"encoding" must be a valid string encoding')
640 var length = byteLength(string, encoding) | 0
641 that = createBuffer(that, length)
643 var actual = that.write(string, encoding)
645 if (actual !== length) {
646 // Writing a hex string, for example, that contains invalid characters will
647 // cause everything after the first invalid character to be ignored. (e.g.
648 // 'abxxcd' will be treated as 'ab')
649 that = that.slice(0, actual)
655 function fromArrayLike (that, array) {
656 var length = array.length < 0 ? 0 : checked(array.length) | 0
657 that = createBuffer(that, length)
658 for (var i = 0; i < length; i += 1) {
659 that[i] = array[i] & 255
664 function fromArrayBuffer (that, array, byteOffset, length) {
665 array.byteLength // this throws if `array` is not a valid ArrayBuffer
667 if (byteOffset < 0 || array.byteLength < byteOffset) {
668 throw new RangeError('\'offset\' is out of bounds')
671 if (array.byteLength < byteOffset + (length || 0)) {
672 throw new RangeError('\'length\' is out of bounds')
675 if (byteOffset === undefined && length === undefined) {
676 array = new Uint8Array(array)
677 } else if (length === undefined) {
678 array = new Uint8Array(array, byteOffset)
680 array = new Uint8Array(array, byteOffset, length)
683 if (Buffer.TYPED_ARRAY_SUPPORT) {
684 // Return an augmented `Uint8Array` instance, for best performance
686 that.__proto__ = Buffer.prototype
688 // Fallback: Return an object instance of the Buffer class
689 that = fromArrayLike(that, array)
694 function fromObject (that, obj) {
695 if (Buffer.isBuffer(obj)) {
696 var len = checked(obj.length) | 0
697 that = createBuffer(that, len)
699 if (that.length === 0) {
703 obj.copy(that, 0, 0, len)
708 if ((typeof ArrayBuffer !== 'undefined' &&
709 obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
710 if (typeof obj.length !== 'number' || isnan(obj.length)) {
711 return createBuffer(that, 0)
713 return fromArrayLike(that, obj)
716 if (obj.type === 'Buffer' && isArray(obj.data)) {
717 return fromArrayLike(that, obj.data)
721 throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
724 function checked (length) {
725 // Note: cannot use `length < kMaxLength()` here because that fails when
726 // length is NaN (which is otherwise coerced to zero.)
727 if (length >= kMaxLength()) {
728 throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
729 'size: 0x' + kMaxLength().toString(16) + ' bytes')
734 function SlowBuffer (length) {
735 if (+length != length) { // eslint-disable-line eqeqeq
738 return Buffer.alloc(+length)
741 Buffer.isBuffer = function isBuffer (b) {
742 return !!(b != null && b._isBuffer)
745 Buffer.compare = function compare (a, b) {
746 if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
747 throw new TypeError('Arguments must be Buffers')
750 if (a === b) return 0
755 for (var i = 0, len = Math.min(x, y); i < len; ++i) {
768 Buffer.isEncoding = function isEncoding (encoding) {
769 switch (String(encoding).toLowerCase()) {
787 Buffer.concat = function concat (list, length) {
788 if (!isArray(list)) {
789 throw new TypeError('"list" argument must be an Array of Buffers')
792 if (list.length === 0) {
793 return Buffer.alloc(0)
797 if (length === undefined) {
799 for (i = 0; i < list.length; ++i) {
800 length += list[i].length
804 var buffer = Buffer.allocUnsafe(length)
806 for (i = 0; i < list.length; ++i) {
808 if (!Buffer.isBuffer(buf)) {
809 throw new TypeError('"list" argument must be an Array of Buffers')
811 buf.copy(buffer, pos)
817 function byteLength (string, encoding) {
818 if (Buffer.isBuffer(string)) {
821 if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
822 (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
823 return string.byteLength
825 if (typeof string !== 'string') {
829 var len = string.length
830 if (len === 0) return 0
832 // Use a for loop to avoid recursion
833 var loweredCase = false
843 return utf8ToBytes(string).length
852 return base64ToBytes(string).length
854 if (loweredCase) return utf8ToBytes(string).length // assume utf8
855 encoding = ('' + encoding).toLowerCase()
860 Buffer.byteLength = byteLength
862 function slowToString (encoding, start, end) {
863 var loweredCase = false
865 // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
866 // property of a typed array.
868 // This behaves neither like String nor Uint8Array in that we set start/end
869 // to their upper/lower bounds if the value passed is out of range.
870 // undefined is handled specially as per ECMA-262 6th Edition,
871 // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
872 if (start === undefined || start < 0) {
875 // Return early if start > this.length. Done here to prevent potential uint32
876 // coercion fail below.
877 if (start > this.length) {
881 if (end === undefined || end > this.length) {
889 // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
897 if (!encoding) encoding = 'utf8'
902 return hexSlice(this, start, end)
906 return utf8Slice(this, start, end)
909 return asciiSlice(this, start, end)
913 return latin1Slice(this, start, end)
916 return base64Slice(this, start, end)
922 return utf16leSlice(this, start, end)
925 if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
926 encoding = (encoding + '').toLowerCase()
932 // The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect
934 Buffer.prototype._isBuffer = true
936 function swap (b, n, m) {
942 Buffer.prototype.swap16 = function swap16 () {
943 var len = this.length
945 throw new RangeError('Buffer size must be a multiple of 16-bits')
947 for (var i = 0; i < len; i += 2) {
953 Buffer.prototype.swap32 = function swap32 () {
954 var len = this.length
956 throw new RangeError('Buffer size must be a multiple of 32-bits')
958 for (var i = 0; i < len; i += 4) {
960 swap(this, i + 1, i + 2)
965 Buffer.prototype.swap64 = function swap64 () {
966 var len = this.length
968 throw new RangeError('Buffer size must be a multiple of 64-bits')
970 for (var i = 0; i < len; i += 8) {
972 swap(this, i + 1, i + 6)
973 swap(this, i + 2, i + 5)
974 swap(this, i + 3, i + 4)
979 Buffer.prototype.toString = function toString () {
980 var length = this.length | 0
981 if (length === 0) return ''
982 if (arguments.length === 0) return utf8Slice(this, 0, length)
983 return slowToString.apply(this, arguments)
986 Buffer.prototype.equals = function equals (b) {
987 if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
988 if (this === b) return true
989 return Buffer.compare(this, b) === 0
992 Buffer.prototype.inspect = function inspect () {
994 var max = exports.INSPECT_MAX_BYTES
995 if (this.length > 0) {
996 str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
997 if (this.length > max) str += ' ... '
999 return '<Buffer ' + str + '>'
1002 Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
1003 if (!Buffer.isBuffer(target)) {
1004 throw new TypeError('Argument must be a Buffer')
1007 if (start === undefined) {
1010 if (end === undefined) {
1011 end = target ? target.length : 0
1013 if (thisStart === undefined) {
1016 if (thisEnd === undefined) {
1017 thisEnd = this.length
1020 if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
1021 throw new RangeError('out of range index')
1024 if (thisStart >= thisEnd && start >= end) {
1027 if (thisStart >= thisEnd) {
1039 if (this === target) return 0
1041 var x = thisEnd - thisStart
1043 var len = Math.min(x, y)
1045 var thisCopy = this.slice(thisStart, thisEnd)
1046 var targetCopy = target.slice(start, end)
1048 for (var i = 0; i < len; ++i) {
1049 if (thisCopy[i] !== targetCopy[i]) {
1056 if (x < y) return -1
1061 // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
1062 // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
1065 // - buffer - a Buffer to search
1066 // - val - a string, Buffer, or number
1067 // - byteOffset - an index into `buffer`; will be clamped to an int32
1068 // - encoding - an optional encoding, relevant is val is a string
1069 // - dir - true for indexOf, false for lastIndexOf
1070 function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
1071 // Empty buffer means no match
1072 if (buffer.length === 0) return -1
1074 // Normalize byteOffset
1075 if (typeof byteOffset === 'string') {
1076 encoding = byteOffset
1078 } else if (byteOffset > 0x7fffffff) {
1079 byteOffset = 0x7fffffff
1080 } else if (byteOffset < -0x80000000) {
1081 byteOffset = -0x80000000
1083 byteOffset = +byteOffset // Coerce to Number.
1084 if (isNaN(byteOffset)) {
1085 // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
1086 byteOffset = dir ? 0 : (buffer.length - 1)
1089 // Normalize byteOffset: negative offsets start from the end of the buffer
1090 if (byteOffset < 0) byteOffset = buffer.length + byteOffset
1091 if (byteOffset >= buffer.length) {
1093 else byteOffset = buffer.length - 1
1094 } else if (byteOffset < 0) {
1095 if (dir) byteOffset = 0
1100 if (typeof val === 'string') {
1101 val = Buffer.from(val, encoding)
1104 // Finally, search either indexOf (if dir is true) or lastIndexOf
1105 if (Buffer.isBuffer(val)) {
1106 // Special case: looking for empty string/buffer always fails
1107 if (val.length === 0) {
1110 return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
1111 } else if (typeof val === 'number') {
1112 val = val & 0xFF // Search for a byte value [0-255]
1113 if (Buffer.TYPED_ARRAY_SUPPORT &&
1114 typeof Uint8Array.prototype.indexOf === 'function') {
1116 return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
1118 return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
1121 return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
1124 throw new TypeError('val must be string, number or Buffer')
1127 function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
1129 var arrLength = arr.length
1130 var valLength = val.length
1132 if (encoding !== undefined) {
1133 encoding = String(encoding).toLowerCase()
1134 if (encoding === 'ucs2' || encoding === 'ucs-2' ||
1135 encoding === 'utf16le' || encoding === 'utf-16le') {
1136 if (arr.length < 2 || val.length < 2) {
1146 function read (buf, i) {
1147 if (indexSize === 1) {
1150 return buf.readUInt16BE(i * indexSize)
1157 for (i = byteOffset; i < arrLength; i++) {
1158 if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
1159 if (foundIndex === -1) foundIndex = i
1160 if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
1162 if (foundIndex !== -1) i -= i - foundIndex
1167 if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
1168 for (i = byteOffset; i >= 0; i--) {
1170 for (var j = 0; j < valLength; j++) {
1171 if (read(arr, i + j) !== read(val, j)) {
1183 Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
1184 return this.indexOf(val, byteOffset, encoding) !== -1
1187 Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
1188 return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
1191 Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
1192 return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
1195 function hexWrite (buf, string, offset, length) {
1196 offset = Number(offset) || 0
1197 var remaining = buf.length - offset
1201 length = Number(length)
1202 if (length > remaining) {
1207 // must be an even number of digits
1208 var strLen = string.length
1209 if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
1211 if (length > strLen / 2) {
1214 for (var i = 0; i < length; ++i) {
1215 var parsed = parseInt(string.substr(i * 2, 2), 16)
1216 if (isNaN(parsed)) return i
1217 buf[offset + i] = parsed
1222 function utf8Write (buf, string, offset, length) {
1223 return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
1226 function asciiWrite (buf, string, offset, length) {
1227 return blitBuffer(asciiToBytes(string), buf, offset, length)
1230 function latin1Write (buf, string, offset, length) {
1231 return asciiWrite(buf, string, offset, length)
1234 function base64Write (buf, string, offset, length) {
1235 return blitBuffer(base64ToBytes(string), buf, offset, length)
1238 function ucs2Write (buf, string, offset, length) {
1239 return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
1242 Buffer.prototype.write = function write (string, offset, length, encoding) {
1243 // Buffer#write(string)
1244 if (offset === undefined) {
1246 length = this.length
1248 // Buffer#write(string, encoding)
1249 } else if (length === undefined && typeof offset === 'string') {
1251 length = this.length
1253 // Buffer#write(string, offset[, length][, encoding])
1254 } else if (isFinite(offset)) {
1256 if (isFinite(length)) {
1258 if (encoding === undefined) encoding = 'utf8'
1263 // legacy write(string, encoding, offset, length) - remove in v0.13
1266 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
1270 var remaining = this.length - offset
1271 if (length === undefined || length > remaining) length = remaining
1273 if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
1274 throw new RangeError('Attempt to write outside buffer bounds')
1277 if (!encoding) encoding = 'utf8'
1279 var loweredCase = false
1283 return hexWrite(this, string, offset, length)
1287 return utf8Write(this, string, offset, length)
1290 return asciiWrite(this, string, offset, length)
1294 return latin1Write(this, string, offset, length)
1297 // Warning: maxLength not taken into account in base64Write
1298 return base64Write(this, string, offset, length)
1304 return ucs2Write(this, string, offset, length)
1307 if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
1308 encoding = ('' + encoding).toLowerCase()
1314 Buffer.prototype.toJSON = function toJSON () {
1317 data: Array.prototype.slice.call(this._arr || this, 0)
1321 function base64Slice (buf, start, end) {
1322 if (start === 0 && end === buf.length) {
1323 return base64.fromByteArray(buf)
1325 return base64.fromByteArray(buf.slice(start, end))
1329 function utf8Slice (buf, start, end) {
1330 end = Math.min(buf.length, end)
1335 var firstByte = buf[i]
1336 var codePoint = null
1337 var bytesPerSequence = (firstByte > 0xEF) ? 4
1338 : (firstByte > 0xDF) ? 3
1339 : (firstByte > 0xBF) ? 2
1342 if (i + bytesPerSequence <= end) {
1343 var secondByte, thirdByte, fourthByte, tempCodePoint
1345 switch (bytesPerSequence) {
1347 if (firstByte < 0x80) {
1348 codePoint = firstByte
1352 secondByte = buf[i + 1]
1353 if ((secondByte & 0xC0) === 0x80) {
1354 tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
1355 if (tempCodePoint > 0x7F) {
1356 codePoint = tempCodePoint
1361 secondByte = buf[i + 1]
1362 thirdByte = buf[i + 2]
1363 if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
1364 tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
1365 if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
1366 codePoint = tempCodePoint
1371 secondByte = buf[i + 1]
1372 thirdByte = buf[i + 2]
1373 fourthByte = buf[i + 3]
1374 if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
1375 tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
1376 if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
1377 codePoint = tempCodePoint
1383 if (codePoint === null) {
1384 // we did not generate a valid codePoint so insert a
1385 // replacement char (U+FFFD) and advance only 1 byte
1387 bytesPerSequence = 1
1388 } else if (codePoint > 0xFFFF) {
1389 // encode to utf16 (surrogate pair dance)
1390 codePoint -= 0x10000
1391 res.push(codePoint >>> 10 & 0x3FF | 0xD800)
1392 codePoint = 0xDC00 | codePoint & 0x3FF
1396 i += bytesPerSequence
1399 return decodeCodePointsArray(res)
1402 // Based on http://stackoverflow.com/a/22747272/680742, the browser with
1403 // the lowest limit is Chrome, with 0x10000 args.
1404 // We go 1 magnitude less, for safety
1405 var MAX_ARGUMENTS_LENGTH = 0x1000
1407 function decodeCodePointsArray (codePoints) {
1408 var len = codePoints.length
1409 if (len <= MAX_ARGUMENTS_LENGTH) {
1410 return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
1413 // Decode in chunks to avoid "call stack size exceeded".
1417 res += String.fromCharCode.apply(
1419 codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
1425 function asciiSlice (buf, start, end) {
1427 end = Math.min(buf.length, end)
1429 for (var i = start; i < end; ++i) {
1430 ret += String.fromCharCode(buf[i] & 0x7F)
1435 function latin1Slice (buf, start, end) {
1437 end = Math.min(buf.length, end)
1439 for (var i = start; i < end; ++i) {
1440 ret += String.fromCharCode(buf[i])
1445 function hexSlice (buf, start, end) {
1446 var len = buf.length
1448 if (!start || start < 0) start = 0
1449 if (!end || end < 0 || end > len) end = len
1452 for (var i = start; i < end; ++i) {
1453 out += toHex(buf[i])
1458 function utf16leSlice (buf, start, end) {
1459 var bytes = buf.slice(start, end)
1461 for (var i = 0; i < bytes.length; i += 2) {
1462 res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
1467 Buffer.prototype.slice = function slice (start, end) {
1468 var len = this.length
1470 end = end === undefined ? len : ~~end
1474 if (start < 0) start = 0
1475 } else if (start > len) {
1481 if (end < 0) end = 0
1482 } else if (end > len) {
1486 if (end < start) end = start
1489 if (Buffer.TYPED_ARRAY_SUPPORT) {
1490 newBuf = this.subarray(start, end)
1491 newBuf.__proto__ = Buffer.prototype
1493 var sliceLen = end - start
1494 newBuf = new Buffer(sliceLen, undefined)
1495 for (var i = 0; i < sliceLen; ++i) {
1496 newBuf[i] = this[i + start]
1504 * Need to make sure that buffer isn't trying to write out of bounds.
1506 function checkOffset (offset, ext, length) {
1507 if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
1508 if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
1511 Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
1513 byteLength = byteLength | 0
1514 if (!noAssert) checkOffset(offset, byteLength, this.length)
1516 var val = this[offset]
1519 while (++i < byteLength && (mul *= 0x100)) {
1520 val += this[offset + i] * mul
1526 Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
1528 byteLength = byteLength | 0
1530 checkOffset(offset, byteLength, this.length)
1533 var val = this[offset + --byteLength]
1535 while (byteLength > 0 && (mul *= 0x100)) {
1536 val += this[offset + --byteLength] * mul
1542 Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
1543 if (!noAssert) checkOffset(offset, 1, this.length)
1547 Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
1548 if (!noAssert) checkOffset(offset, 2, this.length)
1549 return this[offset] | (this[offset + 1] << 8)
1552 Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
1553 if (!noAssert) checkOffset(offset, 2, this.length)
1554 return (this[offset] << 8) | this[offset + 1]
1557 Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
1558 if (!noAssert) checkOffset(offset, 4, this.length)
1560 return ((this[offset]) |
1561 (this[offset + 1] << 8) |
1562 (this[offset + 2] << 16)) +
1563 (this[offset + 3] * 0x1000000)
1566 Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
1567 if (!noAssert) checkOffset(offset, 4, this.length)
1569 return (this[offset] * 0x1000000) +
1570 ((this[offset + 1] << 16) |
1571 (this[offset + 2] << 8) |
1575 Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
1577 byteLength = byteLength | 0
1578 if (!noAssert) checkOffset(offset, byteLength, this.length)
1580 var val = this[offset]
1583 while (++i < byteLength && (mul *= 0x100)) {
1584 val += this[offset + i] * mul
1588 if (val >= mul) val -= Math.pow(2, 8 * byteLength)
1593 Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
1595 byteLength = byteLength | 0
1596 if (!noAssert) checkOffset(offset, byteLength, this.length)
1600 var val = this[offset + --i]
1601 while (i > 0 && (mul *= 0x100)) {
1602 val += this[offset + --i] * mul
1606 if (val >= mul) val -= Math.pow(2, 8 * byteLength)
1611 Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
1612 if (!noAssert) checkOffset(offset, 1, this.length)
1613 if (!(this[offset] & 0x80)) return (this[offset])
1614 return ((0xff - this[offset] + 1) * -1)
1617 Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
1618 if (!noAssert) checkOffset(offset, 2, this.length)
1619 var val = this[offset] | (this[offset + 1] << 8)
1620 return (val & 0x8000) ? val | 0xFFFF0000 : val
1623 Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
1624 if (!noAssert) checkOffset(offset, 2, this.length)
1625 var val = this[offset + 1] | (this[offset] << 8)
1626 return (val & 0x8000) ? val | 0xFFFF0000 : val
1629 Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
1630 if (!noAssert) checkOffset(offset, 4, this.length)
1632 return (this[offset]) |
1633 (this[offset + 1] << 8) |
1634 (this[offset + 2] << 16) |
1635 (this[offset + 3] << 24)
1638 Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
1639 if (!noAssert) checkOffset(offset, 4, this.length)
1641 return (this[offset] << 24) |
1642 (this[offset + 1] << 16) |
1643 (this[offset + 2] << 8) |
1647 Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
1648 if (!noAssert) checkOffset(offset, 4, this.length)
1649 return ieee754.read(this, offset, true, 23, 4)
1652 Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
1653 if (!noAssert) checkOffset(offset, 4, this.length)
1654 return ieee754.read(this, offset, false, 23, 4)
1657 Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
1658 if (!noAssert) checkOffset(offset, 8, this.length)
1659 return ieee754.read(this, offset, true, 52, 8)
1662 Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
1663 if (!noAssert) checkOffset(offset, 8, this.length)
1664 return ieee754.read(this, offset, false, 52, 8)
1667 function checkInt (buf, value, offset, ext, max, min) {
1668 if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
1669 if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
1670 if (offset + ext > buf.length) throw new RangeError('Index out of range')
1673 Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
1676 byteLength = byteLength | 0
1678 var maxBytes = Math.pow(2, 8 * byteLength) - 1
1679 checkInt(this, value, offset, byteLength, maxBytes, 0)
1684 this[offset] = value & 0xFF
1685 while (++i < byteLength && (mul *= 0x100)) {
1686 this[offset + i] = (value / mul) & 0xFF
1689 return offset + byteLength
1692 Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
1695 byteLength = byteLength | 0
1697 var maxBytes = Math.pow(2, 8 * byteLength) - 1
1698 checkInt(this, value, offset, byteLength, maxBytes, 0)
1701 var i = byteLength - 1
1703 this[offset + i] = value & 0xFF
1704 while (--i >= 0 && (mul *= 0x100)) {
1705 this[offset + i] = (value / mul) & 0xFF
1708 return offset + byteLength
1711 Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
1714 if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
1715 if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
1716 this[offset] = (value & 0xff)
1720 function objectWriteUInt16 (buf, value, offset, littleEndian) {
1721 if (value < 0) value = 0xffff + value + 1
1722 for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
1723 buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
1724 (littleEndian ? i : 1 - i) * 8
1728 Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
1731 if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
1732 if (Buffer.TYPED_ARRAY_SUPPORT) {
1733 this[offset] = (value & 0xff)
1734 this[offset + 1] = (value >>> 8)
1736 objectWriteUInt16(this, value, offset, true)
1741 Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
1744 if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
1745 if (Buffer.TYPED_ARRAY_SUPPORT) {
1746 this[offset] = (value >>> 8)
1747 this[offset + 1] = (value & 0xff)
1749 objectWriteUInt16(this, value, offset, false)
1754 function objectWriteUInt32 (buf, value, offset, littleEndian) {
1755 if (value < 0) value = 0xffffffff + value + 1
1756 for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
1757 buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
1761 Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
1764 if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
1765 if (Buffer.TYPED_ARRAY_SUPPORT) {
1766 this[offset + 3] = (value >>> 24)
1767 this[offset + 2] = (value >>> 16)
1768 this[offset + 1] = (value >>> 8)
1769 this[offset] = (value & 0xff)
1771 objectWriteUInt32(this, value, offset, true)
1776 Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
1779 if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
1780 if (Buffer.TYPED_ARRAY_SUPPORT) {
1781 this[offset] = (value >>> 24)
1782 this[offset + 1] = (value >>> 16)
1783 this[offset + 2] = (value >>> 8)
1784 this[offset + 3] = (value & 0xff)
1786 objectWriteUInt32(this, value, offset, false)
1791 Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
1795 var limit = Math.pow(2, 8 * byteLength - 1)
1797 checkInt(this, value, offset, byteLength, limit - 1, -limit)
1803 this[offset] = value & 0xFF
1804 while (++i < byteLength && (mul *= 0x100)) {
1805 if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
1808 this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
1811 return offset + byteLength
1814 Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
1818 var limit = Math.pow(2, 8 * byteLength - 1)
1820 checkInt(this, value, offset, byteLength, limit - 1, -limit)
1823 var i = byteLength - 1
1826 this[offset + i] = value & 0xFF
1827 while (--i >= 0 && (mul *= 0x100)) {
1828 if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
1831 this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
1834 return offset + byteLength
1837 Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
1840 if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
1841 if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
1842 if (value < 0) value = 0xff + value + 1
1843 this[offset] = (value & 0xff)
1847 Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
1850 if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
1851 if (Buffer.TYPED_ARRAY_SUPPORT) {
1852 this[offset] = (value & 0xff)
1853 this[offset + 1] = (value >>> 8)
1855 objectWriteUInt16(this, value, offset, true)
1860 Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
1863 if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
1864 if (Buffer.TYPED_ARRAY_SUPPORT) {
1865 this[offset] = (value >>> 8)
1866 this[offset + 1] = (value & 0xff)
1868 objectWriteUInt16(this, value, offset, false)
1873 Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
1876 if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
1877 if (Buffer.TYPED_ARRAY_SUPPORT) {
1878 this[offset] = (value & 0xff)
1879 this[offset + 1] = (value >>> 8)
1880 this[offset + 2] = (value >>> 16)
1881 this[offset + 3] = (value >>> 24)
1883 objectWriteUInt32(this, value, offset, true)
1888 Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
1891 if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
1892 if (value < 0) value = 0xffffffff + value + 1
1893 if (Buffer.TYPED_ARRAY_SUPPORT) {
1894 this[offset] = (value >>> 24)
1895 this[offset + 1] = (value >>> 16)
1896 this[offset + 2] = (value >>> 8)
1897 this[offset + 3] = (value & 0xff)
1899 objectWriteUInt32(this, value, offset, false)
1904 function checkIEEE754 (buf, value, offset, ext, max, min) {
1905 if (offset + ext > buf.length) throw new RangeError('Index out of range')
1906 if (offset < 0) throw new RangeError('Index out of range')
1909 function writeFloat (buf, value, offset, littleEndian, noAssert) {
1911 checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
1913 ieee754.write(buf, value, offset, littleEndian, 23, 4)
1917 Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
1918 return writeFloat(this, value, offset, true, noAssert)
1921 Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
1922 return writeFloat(this, value, offset, false, noAssert)
1925 function writeDouble (buf, value, offset, littleEndian, noAssert) {
1927 checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
1929 ieee754.write(buf, value, offset, littleEndian, 52, 8)
1933 Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
1934 return writeDouble(this, value, offset, true, noAssert)
1937 Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
1938 return writeDouble(this, value, offset, false, noAssert)
1941 // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
1942 Buffer.prototype.copy = function copy (target, targetStart, start, end) {
1943 if (!start) start = 0
1944 if (!end && end !== 0) end = this.length
1945 if (targetStart >= target.length) targetStart = target.length
1946 if (!targetStart) targetStart = 0
1947 if (end > 0 && end < start) end = start
1949 // Copy 0 bytes; we're done
1950 if (end === start) return 0
1951 if (target.length === 0 || this.length === 0) return 0
1953 // Fatal error conditions
1954 if (targetStart < 0) {
1955 throw new RangeError('targetStart out of bounds')
1957 if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
1958 if (end < 0) throw new RangeError('sourceEnd out of bounds')
1961 if (end > this.length) end = this.length
1962 if (target.length - targetStart < end - start) {
1963 end = target.length - targetStart + start
1966 var len = end - start
1969 if (this === target && start < targetStart && targetStart < end) {
1970 // descending copy from end
1971 for (i = len - 1; i >= 0; --i) {
1972 target[i + targetStart] = this[i + start]
1974 } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
1975 // ascending copy from start
1976 for (i = 0; i < len; ++i) {
1977 target[i + targetStart] = this[i + start]
1980 Uint8Array.prototype.set.call(
1982 this.subarray(start, start + len),
1991 // buffer.fill(number[, offset[, end]])
1992 // buffer.fill(buffer[, offset[, end]])
1993 // buffer.fill(string[, offset[, end]][, encoding])
1994 Buffer.prototype.fill = function fill (val, start, end, encoding) {
1995 // Handle string cases:
1996 if (typeof val === 'string') {
1997 if (typeof start === 'string') {
2001 } else if (typeof end === 'string') {
2005 if (val.length === 1) {
2006 var code = val.charCodeAt(0)
2011 if (encoding !== undefined && typeof encoding !== 'string') {
2012 throw new TypeError('encoding must be a string')
2014 if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
2015 throw new TypeError('Unknown encoding: ' + encoding)
2017 } else if (typeof val === 'number') {
2021 // Invalid ranges are not set to a default, so can range check early.
2022 if (start < 0 || this.length < start || this.length < end) {
2023 throw new RangeError('Out of range index')
2031 end = end === undefined ? this.length : end >>> 0
2036 if (typeof val === 'number') {
2037 for (i = start; i < end; ++i) {
2041 var bytes = Buffer.isBuffer(val)
2043 : utf8ToBytes(new Buffer(val, encoding).toString())
2044 var len = bytes.length
2045 for (i = 0; i < end - start; ++i) {
2046 this[i + start] = bytes[i % len]
2056 var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
2058 function base64clean (str) {
2059 // Node strips out invalid characters like \n and \t from the string, base64-js does not
2060 str = stringtrim(str).replace(INVALID_BASE64_RE, '')
2061 // Node converts strings with length < 2 to ''
2062 if (str.length < 2) return ''
2063 // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
2064 while (str.length % 4 !== 0) {
2070 function stringtrim (str) {
2071 if (str.trim) return str.trim()
2072 return str.replace(/^\s+|\s+$/g, '')
2075 function toHex (n) {
2076 if (n < 16) return '0' + n.toString(16)
2077 return n.toString(16)
2080 function utf8ToBytes (string, units) {
2081 units = units || Infinity
2083 var length = string.length
2084 var leadSurrogate = null
2087 for (var i = 0; i < length; ++i) {
2088 codePoint = string.charCodeAt(i)
2090 // is surrogate component
2091 if (codePoint > 0xD7FF && codePoint < 0xE000) {
2092 // last char was a lead
2093 if (!leadSurrogate) {
2095 if (codePoint > 0xDBFF) {
2097 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
2099 } else if (i + 1 === length) {
2101 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
2106 leadSurrogate = codePoint
2112 if (codePoint < 0xDC00) {
2113 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
2114 leadSurrogate = codePoint
2118 // valid surrogate pair
2119 codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
2120 } else if (leadSurrogate) {
2121 // valid bmp char, but last char was a lead
2122 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
2125 leadSurrogate = null
2128 if (codePoint < 0x80) {
2129 if ((units -= 1) < 0) break
2130 bytes.push(codePoint)
2131 } else if (codePoint < 0x800) {
2132 if ((units -= 2) < 0) break
2134 codePoint >> 0x6 | 0xC0,
2135 codePoint & 0x3F | 0x80
2137 } else if (codePoint < 0x10000) {
2138 if ((units -= 3) < 0) break
2140 codePoint >> 0xC | 0xE0,
2141 codePoint >> 0x6 & 0x3F | 0x80,
2142 codePoint & 0x3F | 0x80
2144 } else if (codePoint < 0x110000) {
2145 if ((units -= 4) < 0) break
2147 codePoint >> 0x12 | 0xF0,
2148 codePoint >> 0xC & 0x3F | 0x80,
2149 codePoint >> 0x6 & 0x3F | 0x80,
2150 codePoint & 0x3F | 0x80
2153 throw new Error('Invalid code point')
2160 function asciiToBytes (str) {
2162 for (var i = 0; i < str.length; ++i) {
2163 // Node's code seems to be doing this and not & 0x7F..
2164 byteArray.push(str.charCodeAt(i) & 0xFF)
2169 function utf16leToBytes (str, units) {
2172 for (var i = 0; i < str.length; ++i) {
2173 if ((units -= 2) < 0) break
2175 c = str.charCodeAt(i)
2185 function base64ToBytes (str) {
2186 return base64.toByteArray(base64clean(str))
2189 function blitBuffer (src, dst, offset, length) {
2190 for (var i = 0; i < length; ++i) {
2191 if ((i + offset >= dst.length) || (i >= src.length)) break
2192 dst[i + offset] = src[i]
2197 function isnan (val) {
2198 return val !== val // eslint-disable-line no-self-compare
2201 }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
2203 },{"base64-js":1,"ieee754":15,"isarray":19}],6:[function(require,module,exports){
2206 module.exports = earcut;
2208 function earcut(data, holeIndices, dim) {
2212 var hasHoles = holeIndices && holeIndices.length,
2213 outerLen = hasHoles ? holeIndices[0] * dim : data.length,
2214 outerNode = linkedList(data, 0, outerLen, dim, true),
2217 if (!outerNode) return triangles;
2219 var minX, minY, maxX, maxY, x, y, size;
2221 if (hasHoles) outerNode = eliminateHoles(data, holeIndices, outerNode, dim);
2223 // if the shape is not too simple, we'll use z-order curve hash later; calculate polygon bbox
2224 if (data.length > 80 * dim) {
2225 minX = maxX = data[0];
2226 minY = maxY = data[1];
2228 for (var i = dim; i < outerLen; i += dim) {
2231 if (x < minX) minX = x;
2232 if (y < minY) minY = y;
2233 if (x > maxX) maxX = x;
2234 if (y > maxY) maxY = y;
2237 // minX, minY and size are later used to transform coords into integers for z-order calculation
2238 size = Math.max(maxX - minX, maxY - minY);
2241 earcutLinked(outerNode, triangles, dim, minX, minY, size);
2246 // create a circular doubly linked list from polygon points in the specified winding order
2247 function linkedList(data, start, end, dim, clockwise) {
2250 if (clockwise === (signedArea(data, start, end, dim) > 0)) {
2251 for (i = start; i < end; i += dim) last = insertNode(i, data[i], data[i + 1], last);
2253 for (i = end - dim; i >= start; i -= dim) last = insertNode(i, data[i], data[i + 1], last);
2256 if (last && equals(last, last.next)) {
2264 // eliminate colinear or duplicate points
2265 function filterPoints(start, end) {
2266 if (!start) return start;
2267 if (!end) end = start;
2274 if (!p.steiner && (equals(p, p.next) || area(p.prev, p, p.next) === 0)) {
2277 if (p === p.next) return null;
2283 } while (again || p !== end);
2288 // main ear slicing loop which triangulates a polygon (given as a linked list)
2289 function earcutLinked(ear, triangles, dim, minX, minY, size, pass) {
2292 // interlink polygon nodes in z-order
2293 if (!pass && size) indexCurve(ear, minX, minY, size);
2298 // iterate through ears, slicing them one by one
2299 while (ear.prev !== ear.next) {
2303 if (size ? isEarHashed(ear, minX, minY, size) : isEar(ear)) {
2304 // cut off the triangle
2305 triangles.push(prev.i / dim);
2306 triangles.push(ear.i / dim);
2307 triangles.push(next.i / dim);
2311 // skipping the next vertice leads to less sliver triangles
2320 // if we looped through the whole remaining polygon and can't find any more ears
2322 // try filtering points and slicing again
2324 earcutLinked(filterPoints(ear), triangles, dim, minX, minY, size, 1);
2326 // if this didn't work, try curing all small self-intersections locally
2327 } else if (pass === 1) {
2328 ear = cureLocalIntersections(ear, triangles, dim);
2329 earcutLinked(ear, triangles, dim, minX, minY, size, 2);
2331 // as a last resort, try splitting the remaining polygon into two
2332 } else if (pass === 2) {
2333 splitEarcut(ear, triangles, dim, minX, minY, size);
2341 // check whether a polygon node forms a valid ear with adjacent nodes
2342 function isEar(ear) {
2347 if (area(a, b, c) >= 0) return false; // reflex, can't be an ear
2349 // now make sure we don't have other points inside the potential ear
2350 var p = ear.next.next;
2352 while (p !== ear.prev) {
2353 if (pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) &&
2354 area(p.prev, p, p.next) >= 0) return false;
2361 function isEarHashed(ear, minX, minY, size) {
2366 if (area(a, b, c) >= 0) return false; // reflex, can't be an ear
2368 // triangle bbox; min & max are calculated like this for speed
2369 var minTX = a.x < b.x ? (a.x < c.x ? a.x : c.x) : (b.x < c.x ? b.x : c.x),
2370 minTY = a.y < b.y ? (a.y < c.y ? a.y : c.y) : (b.y < c.y ? b.y : c.y),
2371 maxTX = a.x > b.x ? (a.x > c.x ? a.x : c.x) : (b.x > c.x ? b.x : c.x),
2372 maxTY = a.y > b.y ? (a.y > c.y ? a.y : c.y) : (b.y > c.y ? b.y : c.y);
2374 // z-order range for the current triangle bbox;
2375 var minZ = zOrder(minTX, minTY, minX, minY, size),
2376 maxZ = zOrder(maxTX, maxTY, minX, minY, size);
2378 // first look for points inside the triangle in increasing z-order
2381 while (p && p.z <= maxZ) {
2382 if (p !== ear.prev && p !== ear.next &&
2383 pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) &&
2384 area(p.prev, p, p.next) >= 0) return false;
2388 // then look for points in decreasing z-order
2391 while (p && p.z >= minZ) {
2392 if (p !== ear.prev && p !== ear.next &&
2393 pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) &&
2394 area(p.prev, p, p.next) >= 0) return false;
2401 // go through all polygon nodes and cure small local self-intersections
2402 function cureLocalIntersections(start, triangles, dim) {
2408 if (!equals(a, b) && intersects(a, p, p.next, b) && locallyInside(a, b) && locallyInside(b, a)) {
2410 triangles.push(a.i / dim);
2411 triangles.push(p.i / dim);
2412 triangles.push(b.i / dim);
2414 // remove two nodes involved
2421 } while (p !== start);
2426 // try splitting polygon into two and triangulate them independently
2427 function splitEarcut(start, triangles, dim, minX, minY, size) {
2428 // look for a valid diagonal that divides the polygon into two
2431 var b = a.next.next;
2432 while (b !== a.prev) {
2433 if (a.i !== b.i && isValidDiagonal(a, b)) {
2434 // split the polygon in two by the diagonal
2435 var c = splitPolygon(a, b);
2437 // filter colinear points around the cuts
2438 a = filterPoints(a, a.next);
2439 c = filterPoints(c, c.next);
2441 // run earcut on each half
2442 earcutLinked(a, triangles, dim, minX, minY, size);
2443 earcutLinked(c, triangles, dim, minX, minY, size);
2449 } while (a !== start);
2452 // link every hole into the outer loop, producing a single-ring polygon without holes
2453 function eliminateHoles(data, holeIndices, outerNode, dim) {
2455 i, len, start, end, list;
2457 for (i = 0, len = holeIndices.length; i < len; i++) {
2458 start = holeIndices[i] * dim;
2459 end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;
2460 list = linkedList(data, start, end, dim, false);
2461 if (list === list.next) list.steiner = true;
2462 queue.push(getLeftmost(list));
2465 queue.sort(compareX);
2467 // process holes from left to right
2468 for (i = 0; i < queue.length; i++) {
2469 eliminateHole(queue[i], outerNode);
2470 outerNode = filterPoints(outerNode, outerNode.next);
2476 function compareX(a, b) {
2480 // find a bridge between vertices that connects hole with an outer ring and and link it
2481 function eliminateHole(hole, outerNode) {
2482 outerNode = findHoleBridge(hole, outerNode);
2484 var b = splitPolygon(outerNode, hole);
2485 filterPoints(b, b.next);
2489 // David Eberly's algorithm for finding a bridge between hole and outer polygon
2490 function findHoleBridge(hole, outerNode) {
2497 // find a segment intersected by a ray from the hole's leftmost point to the left;
2498 // segment's endpoint with lesser x will be potential connection point
2500 if (hy <= p.y && hy >= p.next.y) {
2501 var x = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y);
2502 if (x <= hx && x > qx) {
2505 if (hy === p.y) return p;
2506 if (hy === p.next.y) return p.next;
2508 m = p.x < p.next.x ? p : p.next;
2512 } while (p !== outerNode);
2514 if (!m) return null;
2516 if (hx === qx) return m.prev; // hole touches outer segment; pick lower endpoint
2518 // look for points inside the triangle of hole point, segment intersection and endpoint;
2519 // if there are no points found, we have a valid connection;
2520 // otherwise choose the point of the minimum angle with the ray as connection point
2530 while (p !== stop) {
2531 if (hx >= p.x && p.x >= mx &&
2532 pointInTriangle(hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p.x, p.y)) {
2534 tan = Math.abs(hy - p.y) / (hx - p.x); // tangential
2536 if ((tan < tanMin || (tan === tanMin && p.x > m.x)) && locallyInside(p, hole)) {
2548 // interlink polygon nodes in z-order
2549 function indexCurve(start, minX, minY, size) {
2552 if (p.z === null) p.z = zOrder(p.x, p.y, minX, minY, size);
2556 } while (p !== start);
2558 p.prevZ.nextZ = null;
2564 // Simon Tatham's linked list merge sort algorithm
2565 // http://www.chiark.greenend.org.uk/~sgtatham/algorithms/listsort.html
2566 function sortLinked(list) {
2567 var i, p, q, e, tail, numMerges, pSize, qSize,
2580 for (i = 0; i < inSize; i++) {
2588 while (pSize > 0 || (qSize > 0 && q)) {
2594 } else if (qSize === 0 || !q) {
2598 } else if (p.z <= q.z) {
2608 if (tail) tail.nextZ = e;
2621 } while (numMerges > 1);
2626 // z-order of a point given coords and size of the data bounding box
2627 function zOrder(x, y, minX, minY, size) {
2628 // coords are transformed into non-negative 15-bit integer range
2629 x = 32767 * (x - minX) / size;
2630 y = 32767 * (y - minY) / size;
2632 x = (x | (x << 8)) & 0x00FF00FF;
2633 x = (x | (x << 4)) & 0x0F0F0F0F;
2634 x = (x | (x << 2)) & 0x33333333;
2635 x = (x | (x << 1)) & 0x55555555;
2637 y = (y | (y << 8)) & 0x00FF00FF;
2638 y = (y | (y << 4)) & 0x0F0F0F0F;
2639 y = (y | (y << 2)) & 0x33333333;
2640 y = (y | (y << 1)) & 0x55555555;
2642 return x | (y << 1);
2645 // find the leftmost node of a polygon ring
2646 function getLeftmost(start) {
2650 if (p.x < leftmost.x) leftmost = p;
2652 } while (p !== start);
2657 // check if a point lies within a convex triangle
2658 function pointInTriangle(ax, ay, bx, by, cx, cy, px, py) {
2659 return (cx - px) * (ay - py) - (ax - px) * (cy - py) >= 0 &&
2660 (ax - px) * (by - py) - (bx - px) * (ay - py) >= 0 &&
2661 (bx - px) * (cy - py) - (cx - px) * (by - py) >= 0;
2664 // check if a diagonal between two polygon nodes is valid (lies in polygon interior)
2665 function isValidDiagonal(a, b) {
2666 return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) &&
2667 locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b);
2670 // signed area of a triangle
2671 function area(p, q, r) {
2672 return (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);
2675 // check if two points are equal
2676 function equals(p1, p2) {
2677 return p1.x === p2.x && p1.y === p2.y;
2680 // check if two segments intersect
2681 function intersects(p1, q1, p2, q2) {
2682 if ((equals(p1, q1) && equals(p2, q2)) ||
2683 (equals(p1, q2) && equals(p2, q1))) return true;
2684 return area(p1, q1, p2) > 0 !== area(p1, q1, q2) > 0 &&
2685 area(p2, q2, p1) > 0 !== area(p2, q2, q1) > 0;
2688 // check if a polygon diagonal intersects any polygon segments
2689 function intersectsPolygon(a, b) {
2692 if (p.i !== a.i && p.next.i !== a.i && p.i !== b.i && p.next.i !== b.i &&
2693 intersects(p, p.next, a, b)) return true;
2700 // check if a polygon diagonal is locally inside the polygon
2701 function locallyInside(a, b) {
2702 return area(a.prev, a, a.next) < 0 ?
2703 area(a, b, a.next) >= 0 && area(a, a.prev, b) >= 0 :
2704 area(a, b, a.prev) < 0 || area(a, a.next, b) < 0;
2707 // check if the middle point of a polygon diagonal is inside the polygon
2708 function middleInside(a, b) {
2711 px = (a.x + b.x) / 2,
2712 py = (a.y + b.y) / 2;
2714 if (((p.y > py) !== (p.next.y > py)) && (px < (p.next.x - p.x) * (py - p.y) / (p.next.y - p.y) + p.x))
2722 // link two polygon vertices with a bridge; if the vertices belong to the same ring, it splits polygon into two;
2723 // if one belongs to the outer ring and another to a hole, it merges it into a single ring
2724 function splitPolygon(a, b) {
2725 var a2 = new Node(a.i, a.x, a.y),
2726 b2 = new Node(b.i, b.x, b.y),
2745 // create a node and optionally link it with previous one (in a circular doubly linked list)
2746 function insertNode(i, x, y, last) {
2747 var p = new Node(i, x, y);
2762 function removeNode(p) {
2763 p.next.prev = p.prev;
2764 p.prev.next = p.next;
2766 if (p.prevZ) p.prevZ.nextZ = p.nextZ;
2767 if (p.nextZ) p.nextZ.prevZ = p.prevZ;
2770 function Node(i, x, y) {
2771 // vertice index in coordinates array
2774 // vertex coordinates
2778 // previous and next vertice nodes in a polygon ring
2782 // z-order curve value
2785 // previous and next nodes in z-order
2789 // indicates whether this is a steiner point
2790 this.steiner = false;
2793 // return a percentage difference between the polygon area and its triangulation area;
2794 // used to verify correctness of triangulation
2795 earcut.deviation = function (data, holeIndices, dim, triangles) {
2796 var hasHoles = holeIndices && holeIndices.length;
2797 var outerLen = hasHoles ? holeIndices[0] * dim : data.length;
2799 var polygonArea = Math.abs(signedArea(data, 0, outerLen, dim));
2801 for (var i = 0, len = holeIndices.length; i < len; i++) {
2802 var start = holeIndices[i] * dim;
2803 var end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;
2804 polygonArea -= Math.abs(signedArea(data, start, end, dim));
2808 var trianglesArea = 0;
2809 for (i = 0; i < triangles.length; i += 3) {
2810 var a = triangles[i] * dim;
2811 var b = triangles[i + 1] * dim;
2812 var c = triangles[i + 2] * dim;
2813 trianglesArea += Math.abs(
2814 (data[a] - data[c]) * (data[b + 1] - data[a + 1]) -
2815 (data[a] - data[b]) * (data[c + 1] - data[a + 1]));
2818 return polygonArea === 0 && trianglesArea === 0 ? 0 :
2819 Math.abs((trianglesArea - polygonArea) / polygonArea);
2822 function signedArea(data, start, end, dim) {
2824 for (var i = start, j = end - dim; i < end; i += dim) {
2825 sum += (data[j] - data[i]) * (data[i + 1] + data[j + 1]);
2831 // turn a polygon in a multi-dimensional array form (e.g. as in GeoJSON) into a form Earcut accepts
2832 earcut.flatten = function (data) {
2833 var dim = data[0][0].length,
2834 result = {vertices: [], holes: [], dimensions: dim},
2837 for (var i = 0; i < data.length; i++) {
2838 for (var j = 0; j < data[i].length; j++) {
2839 for (var d = 0; d < dim; d++) result.vertices.push(data[i][j][d]);
2842 holeIndex += data[i - 1].length;
2843 result.holes.push(holeIndex);
2849 },{}],7:[function(require,module,exports){
2852 var OneVersionConstraint = require('individual/one-version');
2854 var MY_VERSION = '7';
2855 OneVersionConstraint('ev-store', MY_VERSION);
2857 var hashKey = '__EV_STORE_KEY@' + MY_VERSION;
2859 module.exports = EvStore;
2861 function EvStore(elem) {
2862 var hash = elem[hashKey];
2865 hash = elem[hashKey] = {};
2871 },{"individual/one-version":17}],8:[function(require,module,exports){
2873 var request = require('./request');
2874 var buildQueryObject = require('./buildQueryObject');
2875 var isArray = Array.isArray;
2877 function simpleExtend(obj, obj2) {
2879 for (prop in obj2) {
2880 obj[prop] = obj2[prop];
2885 function XMLHttpSource(jsongUrl, config) {
2886 this._jsongUrl = jsongUrl;
2887 if (typeof config === 'number') {
2893 this._config = simpleExtend({
2899 XMLHttpSource.prototype = {
2900 // because javascript
2901 constructor: XMLHttpSource,
2903 * buildQueryObject helper
2905 buildQueryObject: buildQueryObject,
2908 * @inheritDoc DataSource#get
2910 get: function httpSourceGet(pathSet) {
2912 var queryObject = this.buildQueryObject(this._jsongUrl, method, {
2916 var config = simpleExtend(queryObject, this._config);
2917 // pass context for onBeforeRequest callback
2919 return request(method, config, context);
2923 * @inheritDoc DataSource#set
2925 set: function httpSourceSet(jsongEnv) {
2926 var method = 'POST';
2927 var queryObject = this.buildQueryObject(this._jsongUrl, method, {
2928 jsonGraph: jsongEnv,
2931 var config = simpleExtend(queryObject, this._config);
2932 config.headers["Content-Type"] = "application/x-www-form-urlencoded";
2934 // pass context for onBeforeRequest callback
2936 return request(method, config, context);
2941 * @inheritDoc DataSource#call
2943 call: function httpSourceCall(callPath, args, pathSuffix, paths) {
2944 // arguments defaults
2946 pathSuffix = pathSuffix || [];
2947 paths = paths || [];
2949 var method = 'POST';
2951 queryData.push('method=call');
2952 queryData.push('callPath=' + encodeURIComponent(JSON.stringify(callPath)));
2953 queryData.push('arguments=' + encodeURIComponent(JSON.stringify(args)));
2954 queryData.push('pathSuffixes=' + encodeURIComponent(JSON.stringify(pathSuffix)));
2955 queryData.push('paths=' + encodeURIComponent(JSON.stringify(paths)));
2957 var queryObject = this.buildQueryObject(this._jsongUrl, method, queryData.join('&'));
2958 var config = simpleExtend(queryObject, this._config);
2959 config.headers["Content-Type"] = "application/x-www-form-urlencoded";
2961 // pass context for onBeforeRequest callback
2963 return request(method, config, context);
2967 XMLHttpSource.XMLHttpSource = XMLHttpSource;
2968 XMLHttpSource['default'] = XMLHttpSource;
2970 module.exports = XMLHttpSource;
2972 },{"./buildQueryObject":9,"./request":12}],9:[function(require,module,exports){
2974 module.exports = function buildQueryObject(url, method, queryData) {
2977 var data = {url: url};
2978 var isQueryParamUrl = url.indexOf('?') !== -1;
2979 var startUrl = (isQueryParamUrl) ? '&' : '?';
2981 if (typeof queryData === 'string') {
2982 qData.push(queryData);
2985 keys = Object.keys(queryData);
2986 keys.forEach(function (k) {
2987 var value = (typeof queryData[k] === 'object') ? JSON.stringify(queryData[k]) : queryData[k];
2988 qData.push(k + '=' + encodeURIComponent(value));
2992 if (method === 'GET') {
2993 data.url += startUrl + qData.join('&');
2995 data.data = qData.join('&');
3001 },{}],10:[function(require,module,exports){
3004 // Get CORS support even for older IE
3005 module.exports = function getCORSRequest() {
3006 var xhr = new global.XMLHttpRequest();
3007 if ('withCredentials' in xhr) {
3009 } else if (!!global.XDomainRequest) {
3010 return new XDomainRequest();
3012 throw new Error('CORS is not supported by your browser');
3016 }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
3018 },{}],11:[function(require,module,exports){
3021 module.exports = function getXMLHttpRequest() {
3025 if (global.XMLHttpRequest) {
3026 return new global.XMLHttpRequest();
3029 progIds = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0'];
3030 for (i = 0; i < 3; i++) {
3032 progId = progIds[i];
3033 if (new global.ActiveXObject(progId)) {
3038 return new global.ActiveXObject(progId);
3040 throw new Error('XMLHttpRequest is not supported by your browser');
3045 }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
3047 },{}],12:[function(require,module,exports){
3049 var getXMLHttpRequest = require('./getXMLHttpRequest');
3050 var getCORSRequest = require('./getCORSRequest');
3051 var hasOwnProp = Object.prototype.hasOwnProperty;
3053 var noop = function() {};
3055 function Observable() {}
3057 Observable.create = function(subscribe) {
3058 var o = new Observable();
3060 o.subscribe = function(onNext, onError, onCompleted) {
3065 if (typeof onNext === 'function') {
3068 onError: (onError || noop),
3069 onCompleted: (onCompleted || noop)
3075 disposable = subscribe(observer);
3077 if (typeof disposable === 'function') {
3089 function request(method, options, context) {
3090 return Observable.create(function requestObserver(observer) {
3093 method: method || 'GET',
3097 responseType: 'json'
3106 for (prop in options) {
3107 if (hasOwnProp.call(options, prop)) {
3108 config[prop] = options[prop];
3112 // Add request with Headers
3113 if (!config.crossDomain && !config.headers['X-Requested-With']) {
3114 config.headers['X-Requested-With'] = 'XMLHttpRequest';
3117 // allow the user to mutate the config open
3118 if (context.onBeforeRequest != null) {
3119 context.onBeforeRequest(config);
3124 xhr = config.crossDomain ? getCORSRequest() : getXMLHttpRequest();
3126 observer.onError(err);
3129 // Takes the url and opens the connection
3131 xhr.open(config.method, config.url, config.async, config.user, config.password);
3133 xhr.open(config.method, config.url, config.async);
3136 // Sets timeout information
3137 xhr.timeout = config.timeout;
3139 // Anything but explicit false results in true.
3140 xhr.withCredentials = config.withCredentials !== false;
3142 // Fills the request headers
3143 headers = config.headers;
3144 for (header in headers) {
3145 if (hasOwnProp.call(headers, header)) {
3146 xhr.setRequestHeader(header, headers[header]);
3150 if (config.responseType) {
3152 xhr.responseType = config.responseType;
3154 // WebKit added support for the json responseType value on 09/03/2013
3155 // https://bugs.webkit.org/show_bug.cgi?id=73648. Versions of Safari prior to 7 are
3156 // known to throw when setting the value "json" as the response type. Other older
3157 // browsers implementing the responseType
3159 // The json response type can be ignored if not supported, because JSON payloads are
3160 // parsed on the client-side regardless.
3161 if (config.responseType !== 'json') {
3167 xhr.onreadystatechange = function onreadystatechange(e) {
3169 if (xhr.readyState === 4) {
3172 onXhrLoad(observer, xhr, e);
3178 xhr.ontimeout = function ontimeout(e) {
3181 onXhrError(observer, xhr, 'timeout error', e);
3186 xhr.send(config.data);
3189 observer.onError(e);
3192 return function dispose() {
3193 // Doesn't work in IE9
3194 if (!isDone && xhr.readyState !== 4) {
3203 * General handling of ultimate failure (after appropriate retries)
3205 function _handleXhrError(observer, textStatus, errorThrown) {
3206 // IE9: cross-domain request may be considered errors
3208 errorThrown = new Error(textStatus);
3211 observer.onError(errorThrown);
3214 function onXhrLoad(observer, xhr, e) {
3219 // If there's no observer, the request has been (or is being) cancelled.
3220 if (xhr && observer) {
3221 responseType = xhr.responseType;
3222 // responseText is the old-school way of retrieving response (supported by IE8 & 9)
3223 // response/responseType properties were introduced in XHR Level2 spec (supported by IE10)
3224 responseData = ('response' in xhr) ? xhr.response : xhr.responseText;
3226 // normalize IE9 bug (http://bugs.jquery.com/ticket/1450)
3227 var status = (xhr.status === 1223) ? 204 : xhr.status;
3229 if (status >= 200 && status <= 399) {
3231 if (responseType !== 'json') {
3232 responseData = JSON.parse(responseData || '');
3234 if (typeof responseData === 'string') {
3235 responseData = JSON.parse(responseData || '');
3238 _handleXhrError(observer, 'invalid json', e);
3240 observer.onNext(responseData);
3241 observer.onCompleted();
3244 } else if (status === 401 || status === 403 || status === 407) {
3246 return _handleXhrError(observer, responseData);
3248 } else if (status === 410) {
3250 return _handleXhrError(observer, responseData);
3252 } else if (status === 408 || status === 504) {
3254 return _handleXhrError(observer, responseData);
3258 return _handleXhrError(observer, responseData || ('Response code ' + status));
3264 function onXhrError(observer, xhr, status, e) {
3265 _handleXhrError(observer, status || xhr.statusText || 'request error', e);
3268 module.exports = request;
3270 },{"./getCORSRequest":10,"./getXMLHttpRequest":11}],13:[function(require,module,exports){
3272 !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(){
3273 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);
3274 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(){
3275 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(){
3276 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)});
3277 }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
3279 },{}],14:[function(require,module,exports){
3281 var topLevel = typeof global !== 'undefined' ? global :
3282 typeof window !== 'undefined' ? window : {}
3283 var minDoc = require('min-document');
3285 if (typeof document !== 'undefined') {
3286 module.exports = document;
3288 var doccy = topLevel['__GLOBAL_DOCUMENT_CACHE@4'];
3291 doccy = topLevel['__GLOBAL_DOCUMENT_CACHE@4'] = minDoc;
3294 module.exports = doccy;
3297 }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
3299 },{"min-document":2}],15:[function(require,module,exports){
3300 exports.read = function (buffer, offset, isLE, mLen, nBytes) {
3302 var eLen = nBytes * 8 - mLen - 1
3303 var eMax = (1 << eLen) - 1
3304 var eBias = eMax >> 1
3306 var i = isLE ? (nBytes - 1) : 0
3307 var d = isLE ? -1 : 1
3308 var s = buffer[offset + i]
3312 e = s & ((1 << (-nBits)) - 1)
3315 for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {}
3317 m = e & ((1 << (-nBits)) - 1)
3320 for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {}
3324 } else if (e === eMax) {
3325 return m ? NaN : ((s ? -1 : 1) * Infinity)
3327 m = m + Math.pow(2, mLen)
3330 return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
3333 exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
3335 var eLen = nBytes * 8 - mLen - 1
3336 var eMax = (1 << eLen) - 1
3337 var eBias = eMax >> 1
3338 var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
3339 var i = isLE ? 0 : (nBytes - 1)
3340 var d = isLE ? 1 : -1
3341 var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
3343 value = Math.abs(value)
3345 if (isNaN(value) || value === Infinity) {
3346 m = isNaN(value) ? 1 : 0
3349 e = Math.floor(Math.log(value) / Math.LN2)
3350 if (value * (c = Math.pow(2, -e)) < 1) {
3354 if (e + eBias >= 1) {
3357 value += rt * Math.pow(2, 1 - eBias)
3359 if (value * c >= 2) {
3364 if (e + eBias >= eMax) {
3367 } else if (e + eBias >= 1) {
3368 m = (value * c - 1) * Math.pow(2, mLen)
3371 m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
3376 for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
3380 for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
3382 buffer[offset + i - d] |= s * 128
3385 },{}],16:[function(require,module,exports){
3389 /*global window, global*/
3391 var root = typeof window !== 'undefined' ?
3392 window : typeof global !== 'undefined' ?
3395 module.exports = Individual;
3397 function Individual(key, value) {
3407 }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
3409 },{}],17:[function(require,module,exports){
3412 var Individual = require('./index.js');
3414 module.exports = OneVersion;
3416 function OneVersion(moduleName, version, defaultValue) {
3417 var key = '__INDIVIDUAL_ONE_VERSION_' + moduleName;
3418 var enforceKey = key + '_ENFORCE_SINGLETON';
3420 var versionValue = Individual(enforceKey, version);
3422 if (versionValue !== version) {
3423 throw new Error('Can only have one copy of ' +
3424 moduleName + '.\n' +
3425 'You already have version ' + versionValue +
3427 'This means you cannot install version ' + version);
3430 return Individual(key, defaultValue);
3433 },{"./index.js":16}],18:[function(require,module,exports){
3436 module.exports = function isObject(x) {
3437 return typeof x === "object" && x !== null;
3440 },{}],19:[function(require,module,exports){
3441 var toString = {}.toString;
3443 module.exports = Array.isArray || function (arr) {
3444 return toString.call(arr) == '[object Array]';
3447 },{}],20:[function(require,module,exports){
3448 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
3449 /* Geohash encoding/decoding and associated functions (c) Chris Veness 2014-2016 / MIT Licence */
3450 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
3456 * Geohash encode, decode, bounds, neighbours.
3462 /* (Geohash-specific) Base32 map */
3463 Geohash.base32 = '0123456789bcdefghjkmnpqrstuvwxyz';
3466 * Encodes latitude/longitude to geohash, either to specified precision or to automatically
3467 * evaluated precision.
3469 * @param {number} lat - Latitude in degrees.
3470 * @param {number} lon - Longitude in degrees.
3471 * @param {number} [precision] - Number of characters in resulting geohash.
3472 * @returns {string} Geohash of supplied latitude/longitude.
3473 * @throws Invalid geohash.
3476 * var geohash = Geohash.encode(52.205, 0.119, 7); // geohash: 'u120fxw'
3478 Geohash.encode = function(lat, lon, precision) {
3480 if (typeof precision == 'undefined') {
3481 // refine geohash until it matches precision of supplied lat/lon
3482 for (var p=1; p<=12; p++) {
3483 var hash = Geohash.encode(lat, lon, p);
3484 var posn = Geohash.decode(hash);
3485 if (posn.lat==lat && posn.lon==lon) return hash;
3487 precision = 12; // set to maximum
3492 precision = Number(precision);
3494 if (isNaN(lat) || isNaN(lon) || isNaN(precision)) throw new Error('Invalid geohash');
3496 var idx = 0; // index into base32 map
3497 var bit = 0; // each char holds 5 bits
3501 var latMin = -90, latMax = 90;
3502 var lonMin = -180, lonMax = 180;
3504 while (geohash.length < precision) {
3506 // bisect E-W longitude
3507 var lonMid = (lonMin + lonMax) / 2;
3508 if (lon >= lonMid) {
3516 // bisect N-S latitude
3517 var latMid = (latMin + latMax) / 2;
3518 if (lat >= latMid) {
3529 // 5 bits gives us a character: append it and start over
3530 geohash += Geohash.base32.charAt(idx);
3541 * Decode geohash to latitude/longitude (location is approximate centre of geohash cell,
3542 * to reasonable precision).
3544 * @param {string} geohash - Geohash string to be converted to latitude/longitude.
3545 * @returns {{lat:number, lon:number}} (Center of) geohashed location.
3546 * @throws Invalid geohash.
3549 * var latlon = Geohash.decode('u120fxw'); // latlon: { lat: 52.205, lon: 0.1188 }
3551 Geohash.decode = function(geohash) {
3553 var bounds = Geohash.bounds(geohash); // <-- the hard work
3554 // now just determine the centre of the cell...
3556 var latMin = bounds.sw.lat, lonMin = bounds.sw.lon;
3557 var latMax = bounds.ne.lat, lonMax = bounds.ne.lon;
3560 var lat = (latMin + latMax)/2;
3561 var lon = (lonMin + lonMax)/2;
3563 // round to close to centre without excessive precision: ⌊2-log10(Δ°)⌋ decimal places
3564 lat = lat.toFixed(Math.floor(2-Math.log(latMax-latMin)/Math.LN10));
3565 lon = lon.toFixed(Math.floor(2-Math.log(lonMax-lonMin)/Math.LN10));
3567 return { lat: Number(lat), lon: Number(lon) };
3572 * Returns SW/NE latitude/longitude bounds of specified geohash.
3574 * @param {string} geohash - Cell that bounds are required of.
3575 * @returns {{sw: {lat: number, lon: number}, ne: {lat: number, lon: number}}}
3576 * @throws Invalid geohash.
3578 Geohash.bounds = function(geohash) {
3579 if (geohash.length === 0) throw new Error('Invalid geohash');
3581 geohash = geohash.toLowerCase();
3584 var latMin = -90, latMax = 90;
3585 var lonMin = -180, lonMax = 180;
3587 for (var i=0; i<geohash.length; i++) {
3588 var chr = geohash.charAt(i);
3589 var idx = Geohash.base32.indexOf(chr);
3590 if (idx == -1) throw new Error('Invalid geohash');
3592 for (var n=4; n>=0; n--) {
3593 var bitN = idx >> n & 1;
3596 var lonMid = (lonMin+lonMax) / 2;
3604 var latMid = (latMin+latMax) / 2;
3616 sw: { lat: latMin, lon: lonMin },
3617 ne: { lat: latMax, lon: lonMax },
3625 * Determines adjacent cell in given direction.
3627 * @param geohash - Cell to which adjacent cell is required.
3628 * @param direction - Direction from geohash (N/S/E/W).
3629 * @returns {string} Geocode of adjacent cell.
3630 * @throws Invalid geohash.
3632 Geohash.adjacent = function(geohash, direction) {
3633 // based on github.com/davetroy/geohash-js
3635 geohash = geohash.toLowerCase();
3636 direction = direction.toLowerCase();
3638 if (geohash.length === 0) throw new Error('Invalid geohash');
3639 if ('nsew'.indexOf(direction) == -1) throw new Error('Invalid direction');
3642 n: [ 'p0r21436x8zb9dcf5h7kjnmqesgutwvy', 'bc01fg45238967deuvhjyznpkmstqrwx' ],
3643 s: [ '14365h7k9dcfesgujnmqp0r2twvyx8zb', '238967debc01fg45kmstqrwxuvhjyznp' ],
3644 e: [ 'bc01fg45238967deuvhjyznpkmstqrwx', 'p0r21436x8zb9dcf5h7kjnmqesgutwvy' ],
3645 w: [ '238967debc01fg45kmstqrwxuvhjyznp', '14365h7k9dcfesgujnmqp0r2twvyx8zb' ],
3648 n: [ 'prxz', 'bcfguvyz' ],
3649 s: [ '028b', '0145hjnp' ],
3650 e: [ 'bcfguvyz', 'prxz' ],
3651 w: [ '0145hjnp', '028b' ],
3654 var lastCh = geohash.slice(-1); // last character of hash
3655 var parent = geohash.slice(0, -1); // hash without last character
3657 var type = geohash.length % 2;
3659 // check for edge-cases which don't share common prefix
3660 if (border[direction][type].indexOf(lastCh) != -1 && parent !== '') {
3661 parent = Geohash.adjacent(parent, direction);
3664 // append letter for direction to parent
3665 return parent + Geohash.base32.charAt(neighbour[direction][type].indexOf(lastCh));
3670 * Returns all 8 adjacent cells to specified geohash.
3672 * @param {string} geohash - Geohash neighbours are required of.
3673 * @returns {{n,ne,e,se,s,sw,w,nw: string}}
3674 * @throws Invalid geohash.
3676 Geohash.neighbours = function(geohash) {
3678 'n': Geohash.adjacent(geohash, 'n'),
3679 'ne': Geohash.adjacent(Geohash.adjacent(geohash, 'n'), 'e'),
3680 'e': Geohash.adjacent(geohash, 'e'),
3681 'se': Geohash.adjacent(Geohash.adjacent(geohash, 's'), 'e'),
3682 's': Geohash.adjacent(geohash, 's'),
3683 'sw': Geohash.adjacent(Geohash.adjacent(geohash, 's'), 'w'),
3684 'w': Geohash.adjacent(geohash, 'w'),
3685 'nw': Geohash.adjacent(Geohash.adjacent(geohash, 'n'), 'w'),
3690 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
3691 if (typeof module != 'undefined' && module.exports) module.exports = Geohash; // CommonJS, node.js
3693 },{}],21:[function(require,module,exports){
3694 (function (process){
3695 // Copyright Joyent, Inc. and other Node contributors.
3697 // Permission is hereby granted, free of charge, to any person obtaining a
3698 // copy of this software and associated documentation files (the
3699 // "Software"), to deal in the Software without restriction, including
3700 // without limitation the rights to use, copy, modify, merge, publish,
3701 // distribute, sublicense, and/or sell copies of the Software, and to permit
3702 // persons to whom the Software is furnished to do so, subject to the
3703 // following conditions:
3705 // The above copyright notice and this permission notice shall be included
3706 // in all copies or substantial portions of the Software.
3708 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
3709 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
3710 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
3711 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
3712 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
3713 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
3714 // USE OR OTHER DEALINGS IN THE SOFTWARE.
3716 // resolves . and .. elements in a path array with directory names there
3717 // must be no slashes, empty elements, or device names (c:\) in the array
3718 // (so also no leading and trailing slashes - it does not distinguish
3719 // relative and absolute paths)
3720 function normalizeArray(parts, allowAboveRoot) {
3721 // if the path tries to go above the root, `up` ends up > 0
3723 for (var i = parts.length - 1; i >= 0; i--) {
3724 var last = parts[i];
3727 } else if (last === '..') {
3736 // if the path is allowed to go above the root, restore leading ..s
3737 if (allowAboveRoot) {
3739 parts.unshift('..');
3746 // Split a filename into [root, dir, basename, ext], unix version
3747 // 'root' is just a slash, or nothing.
3749 /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
3750 var splitPath = function(filename) {
3751 return splitPathRe.exec(filename).slice(1);
3754 // path.resolve([from ...], to)
3756 exports.resolve = function() {
3757 var resolvedPath = '',
3758 resolvedAbsolute = false;
3760 for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
3761 var path = (i >= 0) ? arguments[i] : process.cwd();
3763 // Skip empty and invalid entries
3764 if (typeof path !== 'string') {
3765 throw new TypeError('Arguments to path.resolve must be strings');
3770 resolvedPath = path + '/' + resolvedPath;
3771 resolvedAbsolute = path.charAt(0) === '/';
3774 // At this point the path should be resolved to a full absolute path, but
3775 // handle relative paths to be safe (might happen when process.cwd() fails)
3777 // Normalize the path
3778 resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {
3780 }), !resolvedAbsolute).join('/');
3782 return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
3785 // path.normalize(path)
3787 exports.normalize = function(path) {
3788 var isAbsolute = exports.isAbsolute(path),
3789 trailingSlash = substr(path, -1) === '/';
3791 // Normalize the path
3792 path = normalizeArray(filter(path.split('/'), function(p) {
3794 }), !isAbsolute).join('/');
3796 if (!path && !isAbsolute) {
3799 if (path && trailingSlash) {
3803 return (isAbsolute ? '/' : '') + path;
3807 exports.isAbsolute = function(path) {
3808 return path.charAt(0) === '/';
3812 exports.join = function() {
3813 var paths = Array.prototype.slice.call(arguments, 0);
3814 return exports.normalize(filter(paths, function(p, index) {
3815 if (typeof p !== 'string') {
3816 throw new TypeError('Arguments to path.join must be strings');
3823 // path.relative(from, to)
3825 exports.relative = function(from, to) {
3826 from = exports.resolve(from).substr(1);
3827 to = exports.resolve(to).substr(1);
3829 function trim(arr) {
3831 for (; start < arr.length; start++) {
3832 if (arr[start] !== '') break;
3835 var end = arr.length - 1;
3836 for (; end >= 0; end--) {
3837 if (arr[end] !== '') break;
3840 if (start > end) return [];
3841 return arr.slice(start, end - start + 1);
3844 var fromParts = trim(from.split('/'));
3845 var toParts = trim(to.split('/'));
3847 var length = Math.min(fromParts.length, toParts.length);
3848 var samePartsLength = length;
3849 for (var i = 0; i < length; i++) {
3850 if (fromParts[i] !== toParts[i]) {
3851 samePartsLength = i;
3856 var outputParts = [];
3857 for (var i = samePartsLength; i < fromParts.length; i++) {
3858 outputParts.push('..');
3861 outputParts = outputParts.concat(toParts.slice(samePartsLength));
3863 return outputParts.join('/');
3867 exports.delimiter = ':';
3869 exports.dirname = function(path) {
3870 var result = splitPath(path),
3874 if (!root && !dir) {
3875 // No dirname whatsoever
3880 // It has a dirname, strip trailing slash
3881 dir = dir.substr(0, dir.length - 1);
3888 exports.basename = function(path, ext) {
3889 var f = splitPath(path)[2];
3890 // TODO: make this comparison case-insensitive on windows?
3891 if (ext && f.substr(-1 * ext.length) === ext) {
3892 f = f.substr(0, f.length - ext.length);
3898 exports.extname = function(path) {
3899 return splitPath(path)[3];
3902 function filter (xs, f) {
3903 if (xs.filter) return xs.filter(f);
3905 for (var i = 0; i < xs.length; i++) {
3906 if (f(xs[i], i, xs)) res.push(xs[i]);
3911 // String.prototype.substr - negative index don't work in IE8
3912 var substr = 'ab'.substr(-1) === 'b'
3913 ? function (str, start, len) { return str.substr(start, len) }
3914 : function (str, start, len) {
3915 if (start < 0) start = str.length + start;
3916 return str.substr(start, len);
3920 }).call(this,require('_process'))
3922 },{"_process":4}],22:[function(require,module,exports){
3925 module.exports = Pbf;
3927 var ieee754 = require('ieee754');
3930 this.buf = ArrayBuffer.isView(buf) ? buf : new Uint8Array(buf || 0);
3933 this.length = this.buf.length;
3936 Pbf.Varint = 0; // varint: int32, int64, uint32, uint64, sint32, sint64, bool, enum
3937 Pbf.Fixed64 = 1; // 64-bit: double, fixed64, sfixed64
3938 Pbf.Bytes = 2; // length-delimited: string, bytes, embedded messages, packed repeated fields
3939 Pbf.Fixed32 = 5; // 32-bit: float, fixed32, sfixed32
3941 var SHIFT_LEFT_32 = (1 << 16) * (1 << 16),
3942 SHIFT_RIGHT_32 = 1 / SHIFT_LEFT_32;
3946 destroy: function() {
3950 // === READING =================================================================
3952 readFields: function(readField, result, end) {
3953 end = end || this.length;
3955 while (this.pos < end) {
3956 var val = this.readVarint(),
3958 startPos = this.pos;
3960 this.type = val & 0x7;
3961 readField(tag, result, this);
3963 if (this.pos === startPos) this.skip(val);
3968 readMessage: function(readField, result) {
3969 return this.readFields(readField, result, this.readVarint() + this.pos);
3972 readFixed32: function() {
3973 var val = readUInt32(this.buf, this.pos);
3978 readSFixed32: function() {
3979 var val = readInt32(this.buf, this.pos);
3984 // 64-bit int handling is based on github.com/dpw/node-buffer-more-ints (MIT-licensed)
3986 readFixed64: function() {
3987 var val = readUInt32(this.buf, this.pos) + readUInt32(this.buf, this.pos + 4) * SHIFT_LEFT_32;
3992 readSFixed64: function() {
3993 var val = readUInt32(this.buf, this.pos) + readInt32(this.buf, this.pos + 4) * SHIFT_LEFT_32;
3998 readFloat: function() {
3999 var val = ieee754.read(this.buf, this.pos, true, 23, 4);
4004 readDouble: function() {
4005 var val = ieee754.read(this.buf, this.pos, true, 52, 8);
4010 readVarint: function(isSigned) {
4014 b = buf[this.pos++]; val = b & 0x7f; if (b < 0x80) return val;
4015 b = buf[this.pos++]; val |= (b & 0x7f) << 7; if (b < 0x80) return val;
4016 b = buf[this.pos++]; val |= (b & 0x7f) << 14; if (b < 0x80) return val;
4017 b = buf[this.pos++]; val |= (b & 0x7f) << 21; if (b < 0x80) return val;
4018 b = buf[this.pos]; val |= (b & 0x0f) << 28;
4020 return readVarintRemainder(val, isSigned, this);
4023 readVarint64: function() { // for compatibility with v2.0.1
4024 return this.readVarint(true);
4027 readSVarint: function() {
4028 var num = this.readVarint();
4029 return num % 2 === 1 ? (num + 1) / -2 : num / 2; // zigzag encoding
4032 readBoolean: function() {
4033 return Boolean(this.readVarint());
4036 readString: function() {
4037 var end = this.readVarint() + this.pos,
4038 str = readUtf8(this.buf, this.pos, end);
4043 readBytes: function() {
4044 var end = this.readVarint() + this.pos,
4045 buffer = this.buf.subarray(this.pos, end);
4050 // verbose for performance reasons; doesn't affect gzipped size
4052 readPackedVarint: function(arr, isSigned) {
4053 var end = readPackedEnd(this);
4055 while (this.pos < end) arr.push(this.readVarint(isSigned));
4058 readPackedSVarint: function(arr) {
4059 var end = readPackedEnd(this);
4061 while (this.pos < end) arr.push(this.readSVarint());
4064 readPackedBoolean: function(arr) {
4065 var end = readPackedEnd(this);
4067 while (this.pos < end) arr.push(this.readBoolean());
4070 readPackedFloat: function(arr) {
4071 var end = readPackedEnd(this);
4073 while (this.pos < end) arr.push(this.readFloat());
4076 readPackedDouble: function(arr) {
4077 var end = readPackedEnd(this);
4079 while (this.pos < end) arr.push(this.readDouble());
4082 readPackedFixed32: function(arr) {
4083 var end = readPackedEnd(this);
4085 while (this.pos < end) arr.push(this.readFixed32());
4088 readPackedSFixed32: function(arr) {
4089 var end = readPackedEnd(this);
4091 while (this.pos < end) arr.push(this.readSFixed32());
4094 readPackedFixed64: function(arr) {
4095 var end = readPackedEnd(this);
4097 while (this.pos < end) arr.push(this.readFixed64());
4100 readPackedSFixed64: function(arr) {
4101 var end = readPackedEnd(this);
4103 while (this.pos < end) arr.push(this.readSFixed64());
4107 skip: function(val) {
4108 var type = val & 0x7;
4109 if (type === Pbf.Varint) while (this.buf[this.pos++] > 0x7f) {}
4110 else if (type === Pbf.Bytes) this.pos = this.readVarint() + this.pos;
4111 else if (type === Pbf.Fixed32) this.pos += 4;
4112 else if (type === Pbf.Fixed64) this.pos += 8;
4113 else throw new Error('Unimplemented type: ' + type);
4116 // === WRITING =================================================================
4118 writeTag: function(tag, type) {
4119 this.writeVarint((tag << 3) | type);
4122 realloc: function(min) {
4123 var length = this.length || 16;
4125 while (length < this.pos + min) length *= 2;
4127 if (length !== this.length) {
4128 var buf = new Uint8Array(length);
4131 this.length = length;
4135 finish: function() {
4136 this.length = this.pos;
4138 return this.buf.subarray(0, this.length);
4141 writeFixed32: function(val) {
4143 writeInt32(this.buf, val, this.pos);
4147 writeSFixed32: function(val) {
4149 writeInt32(this.buf, val, this.pos);
4153 writeFixed64: function(val) {
4155 writeInt32(this.buf, val & -1, this.pos);
4156 writeInt32(this.buf, Math.floor(val * SHIFT_RIGHT_32), this.pos + 4);
4160 writeSFixed64: function(val) {
4162 writeInt32(this.buf, val & -1, this.pos);
4163 writeInt32(this.buf, Math.floor(val * SHIFT_RIGHT_32), this.pos + 4);
4167 writeVarint: function(val) {
4170 if (val > 0xfffffff || val < 0) {
4171 writeBigVarint(val, this);
4177 this.buf[this.pos++] = val & 0x7f | (val > 0x7f ? 0x80 : 0); if (val <= 0x7f) return;
4178 this.buf[this.pos++] = ((val >>>= 7) & 0x7f) | (val > 0x7f ? 0x80 : 0); if (val <= 0x7f) return;
4179 this.buf[this.pos++] = ((val >>>= 7) & 0x7f) | (val > 0x7f ? 0x80 : 0); if (val <= 0x7f) return;
4180 this.buf[this.pos++] = (val >>> 7) & 0x7f;
4183 writeSVarint: function(val) {
4184 this.writeVarint(val < 0 ? -val * 2 - 1 : val * 2);
4187 writeBoolean: function(val) {
4188 this.writeVarint(Boolean(val));
4191 writeString: function(str) {
4193 this.realloc(str.length * 4);
4195 this.pos++; // reserve 1 byte for short string length
4197 var startPos = this.pos;
4198 // write the string directly to the buffer and see how much was written
4199 this.pos = writeUtf8(this.buf, str, this.pos);
4200 var len = this.pos - startPos;
4202 if (len >= 0x80) makeRoomForExtraLength(startPos, len, this);
4204 // finally, write the message length in the reserved place and restore the position
4205 this.pos = startPos - 1;
4206 this.writeVarint(len);
4210 writeFloat: function(val) {
4212 ieee754.write(this.buf, val, this.pos, true, 23, 4);
4216 writeDouble: function(val) {
4218 ieee754.write(this.buf, val, this.pos, true, 52, 8);
4222 writeBytes: function(buffer) {
4223 var len = buffer.length;
4224 this.writeVarint(len);
4226 for (var i = 0; i < len; i++) this.buf[this.pos++] = buffer[i];
4229 writeRawMessage: function(fn, obj) {
4230 this.pos++; // reserve 1 byte for short message length
4232 // write the message directly to the buffer and see how much was written
4233 var startPos = this.pos;
4235 var len = this.pos - startPos;
4237 if (len >= 0x80) makeRoomForExtraLength(startPos, len, this);
4239 // finally, write the message length in the reserved place and restore the position
4240 this.pos = startPos - 1;
4241 this.writeVarint(len);
4245 writeMessage: function(tag, fn, obj) {
4246 this.writeTag(tag, Pbf.Bytes);
4247 this.writeRawMessage(fn, obj);
4250 writePackedVarint: function(tag, arr) { this.writeMessage(tag, writePackedVarint, arr); },
4251 writePackedSVarint: function(tag, arr) { this.writeMessage(tag, writePackedSVarint, arr); },
4252 writePackedBoolean: function(tag, arr) { this.writeMessage(tag, writePackedBoolean, arr); },
4253 writePackedFloat: function(tag, arr) { this.writeMessage(tag, writePackedFloat, arr); },
4254 writePackedDouble: function(tag, arr) { this.writeMessage(tag, writePackedDouble, arr); },
4255 writePackedFixed32: function(tag, arr) { this.writeMessage(tag, writePackedFixed32, arr); },
4256 writePackedSFixed32: function(tag, arr) { this.writeMessage(tag, writePackedSFixed32, arr); },
4257 writePackedFixed64: function(tag, arr) { this.writeMessage(tag, writePackedFixed64, arr); },
4258 writePackedSFixed64: function(tag, arr) { this.writeMessage(tag, writePackedSFixed64, arr); },
4260 writeBytesField: function(tag, buffer) {
4261 this.writeTag(tag, Pbf.Bytes);
4262 this.writeBytes(buffer);
4264 writeFixed32Field: function(tag, val) {
4265 this.writeTag(tag, Pbf.Fixed32);
4266 this.writeFixed32(val);
4268 writeSFixed32Field: function(tag, val) {
4269 this.writeTag(tag, Pbf.Fixed32);
4270 this.writeSFixed32(val);
4272 writeFixed64Field: function(tag, val) {
4273 this.writeTag(tag, Pbf.Fixed64);
4274 this.writeFixed64(val);
4276 writeSFixed64Field: function(tag, val) {
4277 this.writeTag(tag, Pbf.Fixed64);
4278 this.writeSFixed64(val);
4280 writeVarintField: function(tag, val) {
4281 this.writeTag(tag, Pbf.Varint);
4282 this.writeVarint(val);
4284 writeSVarintField: function(tag, val) {
4285 this.writeTag(tag, Pbf.Varint);
4286 this.writeSVarint(val);
4288 writeStringField: function(tag, str) {
4289 this.writeTag(tag, Pbf.Bytes);
4290 this.writeString(str);
4292 writeFloatField: function(tag, val) {
4293 this.writeTag(tag, Pbf.Fixed32);
4294 this.writeFloat(val);
4296 writeDoubleField: function(tag, val) {
4297 this.writeTag(tag, Pbf.Fixed64);
4298 this.writeDouble(val);
4300 writeBooleanField: function(tag, val) {
4301 this.writeVarintField(tag, Boolean(val));
4305 function readVarintRemainder(l, s, p) {
4309 b = buf[p.pos++]; h = (b & 0x70) >> 4; if (b < 0x80) return toNum(l, h, s);
4310 b = buf[p.pos++]; h |= (b & 0x7f) << 3; if (b < 0x80) return toNum(l, h, s);
4311 b = buf[p.pos++]; h |= (b & 0x7f) << 10; if (b < 0x80) return toNum(l, h, s);
4312 b = buf[p.pos++]; h |= (b & 0x7f) << 17; if (b < 0x80) return toNum(l, h, s);
4313 b = buf[p.pos++]; h |= (b & 0x7f) << 24; if (b < 0x80) return toNum(l, h, s);
4314 b = buf[p.pos++]; h |= (b & 0x01) << 31; if (b < 0x80) return toNum(l, h, s);
4316 throw new Error('Expected varint not more than 10 bytes');
4319 function readPackedEnd(pbf) {
4320 return pbf.type === Pbf.Bytes ?
4321 pbf.readVarint() + pbf.pos : pbf.pos + 1;
4324 function toNum(low, high, isSigned) {
4326 return high * 0x100000000 + (low >>> 0);
4329 return ((high >>> 0) * 0x100000000) + (low >>> 0);
4332 function writeBigVarint(val, pbf) {
4336 low = (val % 0x100000000) | 0;
4337 high = (val / 0x100000000) | 0;
4339 low = ~(-val % 0x100000000);
4340 high = ~(-val / 0x100000000);
4342 if (low ^ 0xffffffff) {
4343 low = (low + 1) | 0;
4346 high = (high + 1) | 0;
4350 if (val >= 0x10000000000000000 || val < -0x10000000000000000) {
4351 throw new Error('Given varint doesn\'t fit into 10 bytes');
4356 writeBigVarintLow(low, high, pbf);
4357 writeBigVarintHigh(high, pbf);
4360 function writeBigVarintLow(low, high, pbf) {
4361 pbf.buf[pbf.pos++] = low & 0x7f | 0x80; low >>>= 7;
4362 pbf.buf[pbf.pos++] = low & 0x7f | 0x80; low >>>= 7;
4363 pbf.buf[pbf.pos++] = low & 0x7f | 0x80; low >>>= 7;
4364 pbf.buf[pbf.pos++] = low & 0x7f | 0x80; low >>>= 7;
4365 pbf.buf[pbf.pos] = low & 0x7f;
4368 function writeBigVarintHigh(high, pbf) {
4369 var lsb = (high & 0x07) << 4;
4371 pbf.buf[pbf.pos++] |= lsb | ((high >>>= 3) ? 0x80 : 0); if (!high) return;
4372 pbf.buf[pbf.pos++] = high & 0x7f | ((high >>>= 7) ? 0x80 : 0); if (!high) return;
4373 pbf.buf[pbf.pos++] = high & 0x7f | ((high >>>= 7) ? 0x80 : 0); if (!high) return;
4374 pbf.buf[pbf.pos++] = high & 0x7f | ((high >>>= 7) ? 0x80 : 0); if (!high) return;
4375 pbf.buf[pbf.pos++] = high & 0x7f | ((high >>>= 7) ? 0x80 : 0); if (!high) return;
4376 pbf.buf[pbf.pos++] = high & 0x7f;
4379 function makeRoomForExtraLength(startPos, len, pbf) {
4382 len <= 0x1fffff ? 2 :
4383 len <= 0xfffffff ? 3 : Math.ceil(Math.log(len) / (Math.LN2 * 7));
4385 // if 1 byte isn't enough for encoding message length, shift the data to the right
4386 pbf.realloc(extraLen);
4387 for (var i = pbf.pos - 1; i >= startPos; i--) pbf.buf[i + extraLen] = pbf.buf[i];
4390 function writePackedVarint(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeVarint(arr[i]); }
4391 function writePackedSVarint(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeSVarint(arr[i]); }
4392 function writePackedFloat(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeFloat(arr[i]); }
4393 function writePackedDouble(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeDouble(arr[i]); }
4394 function writePackedBoolean(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeBoolean(arr[i]); }
4395 function writePackedFixed32(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeFixed32(arr[i]); }
4396 function writePackedSFixed32(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeSFixed32(arr[i]); }
4397 function writePackedFixed64(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeFixed64(arr[i]); }
4398 function writePackedSFixed64(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeSFixed64(arr[i]); }
4400 // Buffer code below from https://github.com/feross/buffer, MIT-licensed
4402 function readUInt32(buf, pos) {
4403 return ((buf[pos]) |
4404 (buf[pos + 1] << 8) |
4405 (buf[pos + 2] << 16)) +
4406 (buf[pos + 3] * 0x1000000);
4409 function writeInt32(buf, val, pos) {
4411 buf[pos + 1] = (val >>> 8);
4412 buf[pos + 2] = (val >>> 16);
4413 buf[pos + 3] = (val >>> 24);
4416 function readInt32(buf, pos) {
4417 return ((buf[pos]) |
4418 (buf[pos + 1] << 8) |
4419 (buf[pos + 2] << 16)) +
4420 (buf[pos + 3] << 24);
4423 function readUtf8(buf, pos, end) {
4429 var c = null; // codepoint
4430 var bytesPerSequence =
4435 if (i + bytesPerSequence > end) break;
4439 if (bytesPerSequence === 1) {
4443 } else if (bytesPerSequence === 2) {
4445 if ((b1 & 0xC0) === 0x80) {
4446 c = (b0 & 0x1F) << 0x6 | (b1 & 0x3F);
4451 } else if (bytesPerSequence === 3) {
4454 if ((b1 & 0xC0) === 0x80 && (b2 & 0xC0) === 0x80) {
4455 c = (b0 & 0xF) << 0xC | (b1 & 0x3F) << 0x6 | (b2 & 0x3F);
4456 if (c <= 0x7FF || (c >= 0xD800 && c <= 0xDFFF)) {
4460 } else if (bytesPerSequence === 4) {
4464 if ((b1 & 0xC0) === 0x80 && (b2 & 0xC0) === 0x80 && (b3 & 0xC0) === 0x80) {
4465 c = (b0 & 0xF) << 0x12 | (b1 & 0x3F) << 0xC | (b2 & 0x3F) << 0x6 | (b3 & 0x3F);
4466 if (c <= 0xFFFF || c >= 0x110000) {
4474 bytesPerSequence = 1;
4476 } else if (c > 0xFFFF) {
4478 str += String.fromCharCode(c >>> 10 & 0x3FF | 0xD800);
4479 c = 0xDC00 | c & 0x3FF;
4482 str += String.fromCharCode(c);
4483 i += bytesPerSequence;
4489 function writeUtf8(buf, str, pos) {
4490 for (var i = 0, c, lead; i < str.length; i++) {
4491 c = str.charCodeAt(i); // code point
4493 if (c > 0xD7FF && c < 0xE000) {
4502 c = lead - 0xD800 << 10 | c - 0xDC00 | 0x10000;
4506 if (c > 0xDBFF || (i + 1 === str.length)) {
4526 buf[pos++] = c >> 0x6 | 0xC0;
4529 buf[pos++] = c >> 0xC | 0xE0;
4531 buf[pos++] = c >> 0x12 | 0xF0;
4532 buf[pos++] = c >> 0xC & 0x3F | 0x80;
4534 buf[pos++] = c >> 0x6 & 0x3F | 0x80;
4536 buf[pos++] = c & 0x3F | 0x80;
4542 },{"ieee754":15}],23:[function(require,module,exports){
4545 module.exports = partialSort;
4547 // Floyd-Rivest selection algorithm:
4548 // Rearrange items so that all items in the [left, k] range are smaller than all items in (k, right];
4549 // The k-th element will have the (k - left + 1)th smallest value in [left, right]
4551 function partialSort(arr, k, left, right, compare) {
4553 right = right || (arr.length - 1);
4554 compare = compare || defaultCompare;
4556 while (right > left) {
4557 if (right - left > 600) {
4558 var n = right - left + 1;
4559 var m = k - left + 1;
4560 var z = Math.log(n);
4561 var s = 0.5 * Math.exp(2 * z / 3);
4562 var sd = 0.5 * Math.sqrt(z * s * (n - s) / n) * (m - n / 2 < 0 ? -1 : 1);
4563 var newLeft = Math.max(left, Math.floor(k - m * s / n + sd));
4564 var newRight = Math.min(right, Math.floor(k + (n - m) * s / n + sd));
4565 partialSort(arr, k, newLeft, newRight, compare);
4573 if (compare(arr[right], t) > 0) swap(arr, left, right);
4579 while (compare(arr[i], t) < 0) i++;
4580 while (compare(arr[j], t) > 0) j--;
4583 if (compare(arr[left], t) === 0) swap(arr, left, j);
4586 swap(arr, j, right);
4589 if (j <= k) left = j + 1;
4590 if (k <= j) right = j - 1;
4594 function swap(arr, i, j) {
4600 function defaultCompare(a, b) {
4601 return a < b ? -1 : a > b ? 1 : 0;
4604 },{}],24:[function(require,module,exports){
4607 module.exports = rbush;
4609 var quickselect = require('quickselect');
4611 function rbush(maxEntries, format) {
4612 if (!(this instanceof rbush)) return new rbush(maxEntries, format);
4614 // max entries in a node is 9 by default; min node fill is 40% for best performance
4615 this._maxEntries = Math.max(4, maxEntries || 9);
4616 this._minEntries = Math.max(2, Math.ceil(this._maxEntries * 0.4));
4619 this._initFormat(format);
4628 return this._all(this.data, []);
4631 search: function (bbox) {
4633 var node = this.data,
4635 toBBox = this.toBBox;
4637 if (!intersects(bbox, node)) return result;
4639 var nodesToSearch = [],
4640 i, len, child, childBBox;
4643 for (i = 0, len = node.children.length; i < len; i++) {
4645 child = node.children[i];
4646 childBBox = node.leaf ? toBBox(child) : child;
4648 if (intersects(bbox, childBBox)) {
4649 if (node.leaf) result.push(child);
4650 else if (contains(bbox, childBBox)) this._all(child, result);
4651 else nodesToSearch.push(child);
4654 node = nodesToSearch.pop();
4660 collides: function (bbox) {
4662 var node = this.data,
4663 toBBox = this.toBBox;
4665 if (!intersects(bbox, node)) return false;
4667 var nodesToSearch = [],
4668 i, len, child, childBBox;
4671 for (i = 0, len = node.children.length; i < len; i++) {
4673 child = node.children[i];
4674 childBBox = node.leaf ? toBBox(child) : child;
4676 if (intersects(bbox, childBBox)) {
4677 if (node.leaf || contains(bbox, childBBox)) return true;
4678 nodesToSearch.push(child);
4681 node = nodesToSearch.pop();
4687 load: function (data) {
4688 if (!(data && data.length)) return this;
4690 if (data.length < this._minEntries) {
4691 for (var i = 0, len = data.length; i < len; i++) {
4692 this.insert(data[i]);
4697 // recursively build the tree with the given data from stratch using OMT algorithm
4698 var node = this._build(data.slice(), 0, data.length - 1, 0);
4700 if (!this.data.children.length) {
4701 // save as is if tree is empty
4704 } else if (this.data.height === node.height) {
4705 // split root if trees have the same height
4706 this._splitRoot(this.data, node);
4709 if (this.data.height < node.height) {
4710 // swap trees if inserted one is bigger
4711 var tmpNode = this.data;
4716 // insert the small tree into the large tree at appropriate level
4717 this._insert(node, this.data.height - node.height - 1, true);
4723 insert: function (item) {
4724 if (item) this._insert(item, this.data.height - 1);
4728 clear: function () {
4729 this.data = createNode([]);
4733 remove: function (item, equalsFn) {
4734 if (!item) return this;
4736 var node = this.data,
4737 bbox = this.toBBox(item),
4740 i, parent, index, goingUp;
4742 // depth-first iterative tree traversal
4743 while (node || path.length) {
4745 if (!node) { // go up
4747 parent = path[path.length - 1];
4752 if (node.leaf) { // check current node
4753 index = findItem(item, node.children, equalsFn);
4756 // item found, remove the item and condense tree upwards
4757 node.children.splice(index, 1);
4759 this._condense(path);
4764 if (!goingUp && !node.leaf && contains(node, bbox)) { // go down
4769 node = node.children[0];
4771 } else if (parent) { // go right
4773 node = parent.children[i];
4776 } else node = null; // nothing found
4782 toBBox: function (item) { return item; },
4784 compareMinX: compareNodeMinX,
4785 compareMinY: compareNodeMinY,
4787 toJSON: function () { return this.data; },
4789 fromJSON: function (data) {
4794 _all: function (node, result) {
4795 var nodesToSearch = [];
4797 if (node.leaf) result.push.apply(result, node.children);
4798 else nodesToSearch.push.apply(nodesToSearch, node.children);
4800 node = nodesToSearch.pop();
4805 _build: function (items, left, right, height) {
4807 var N = right - left + 1,
4808 M = this._maxEntries,
4812 // reached leaf level; return leaf
4813 node = createNode(items.slice(left, right + 1));
4814 calcBBox(node, this.toBBox);
4819 // target height of the bulk-loaded tree
4820 height = Math.ceil(Math.log(N) / Math.log(M));
4822 // target number of root entries to maximize storage utilization
4823 M = Math.ceil(N / Math.pow(M, height - 1));
4826 node = createNode([]);
4828 node.height = height;
4830 // split the items into M mostly square tiles
4832 var N2 = Math.ceil(N / M),
4833 N1 = N2 * Math.ceil(Math.sqrt(M)),
4834 i, j, right2, right3;
4836 multiSelect(items, left, right, N1, this.compareMinX);
4838 for (i = left; i <= right; i += N1) {
4840 right2 = Math.min(i + N1 - 1, right);
4842 multiSelect(items, i, right2, N2, this.compareMinY);
4844 for (j = i; j <= right2; j += N2) {
4846 right3 = Math.min(j + N2 - 1, right2);
4848 // pack each entry recursively
4849 node.children.push(this._build(items, j, right3, height - 1));
4853 calcBBox(node, this.toBBox);
4858 _chooseSubtree: function (bbox, node, level, path) {
4860 var i, len, child, targetNode, area, enlargement, minArea, minEnlargement;
4865 if (node.leaf || path.length - 1 === level) break;
4867 minArea = minEnlargement = Infinity;
4869 for (i = 0, len = node.children.length; i < len; i++) {
4870 child = node.children[i];
4871 area = bboxArea(child);
4872 enlargement = enlargedArea(bbox, child) - area;
4874 // choose entry with the least area enlargement
4875 if (enlargement < minEnlargement) {
4876 minEnlargement = enlargement;
4877 minArea = area < minArea ? area : minArea;
4880 } else if (enlargement === minEnlargement) {
4881 // otherwise choose one with the smallest area
4882 if (area < minArea) {
4889 node = targetNode || node.children[0];
4895 _insert: function (item, level, isNode) {
4897 var toBBox = this.toBBox,
4898 bbox = isNode ? item : toBBox(item),
4901 // find the best node for accommodating the item, saving all nodes along the path too
4902 var node = this._chooseSubtree(bbox, this.data, level, insertPath);
4904 // put the item into the node
4905 node.children.push(item);
4908 // split on node overflow; propagate upwards if necessary
4909 while (level >= 0) {
4910 if (insertPath[level].children.length > this._maxEntries) {
4911 this._split(insertPath, level);
4916 // adjust bboxes along the insertion path
4917 this._adjustParentBBoxes(bbox, insertPath, level);
4920 // split overflowed node into two
4921 _split: function (insertPath, level) {
4923 var node = insertPath[level],
4924 M = node.children.length,
4925 m = this._minEntries;
4927 this._chooseSplitAxis(node, m, M);
4929 var splitIndex = this._chooseSplitIndex(node, m, M);
4931 var newNode = createNode(node.children.splice(splitIndex, node.children.length - splitIndex));
4932 newNode.height = node.height;
4933 newNode.leaf = node.leaf;
4935 calcBBox(node, this.toBBox);
4936 calcBBox(newNode, this.toBBox);
4938 if (level) insertPath[level - 1].children.push(newNode);
4939 else this._splitRoot(node, newNode);
4942 _splitRoot: function (node, newNode) {
4944 this.data = createNode([node, newNode]);
4945 this.data.height = node.height + 1;
4946 this.data.leaf = false;
4947 calcBBox(this.data, this.toBBox);
4950 _chooseSplitIndex: function (node, m, M) {
4952 var i, bbox1, bbox2, overlap, area, minOverlap, minArea, index;
4954 minOverlap = minArea = Infinity;
4956 for (i = m; i <= M - m; i++) {
4957 bbox1 = distBBox(node, 0, i, this.toBBox);
4958 bbox2 = distBBox(node, i, M, this.toBBox);
4960 overlap = intersectionArea(bbox1, bbox2);
4961 area = bboxArea(bbox1) + bboxArea(bbox2);
4963 // choose distribution with minimum overlap
4964 if (overlap < minOverlap) {
4965 minOverlap = overlap;
4968 minArea = area < minArea ? area : minArea;
4970 } else if (overlap === minOverlap) {
4971 // otherwise choose distribution with minimum area
4972 if (area < minArea) {
4982 // sorts node children by the best axis for split
4983 _chooseSplitAxis: function (node, m, M) {
4985 var compareMinX = node.leaf ? this.compareMinX : compareNodeMinX,
4986 compareMinY = node.leaf ? this.compareMinY : compareNodeMinY,
4987 xMargin = this._allDistMargin(node, m, M, compareMinX),
4988 yMargin = this._allDistMargin(node, m, M, compareMinY);
4990 // if total distributions margin value is minimal for x, sort by minX,
4991 // otherwise it's already sorted by minY
4992 if (xMargin < yMargin) node.children.sort(compareMinX);
4995 // total margin of all possible split distributions where each node is at least m full
4996 _allDistMargin: function (node, m, M, compare) {
4998 node.children.sort(compare);
5000 var toBBox = this.toBBox,
5001 leftBBox = distBBox(node, 0, m, toBBox),
5002 rightBBox = distBBox(node, M - m, M, toBBox),
5003 margin = bboxMargin(leftBBox) + bboxMargin(rightBBox),
5006 for (i = m; i < M - m; i++) {
5007 child = node.children[i];
5008 extend(leftBBox, node.leaf ? toBBox(child) : child);
5009 margin += bboxMargin(leftBBox);
5012 for (i = M - m - 1; i >= m; i--) {
5013 child = node.children[i];
5014 extend(rightBBox, node.leaf ? toBBox(child) : child);
5015 margin += bboxMargin(rightBBox);
5021 _adjustParentBBoxes: function (bbox, path, level) {
5022 // adjust bboxes along the given tree path
5023 for (var i = level; i >= 0; i--) {
5024 extend(path[i], bbox);
5028 _condense: function (path) {
5029 // go through the path, removing empty nodes and updating bboxes
5030 for (var i = path.length - 1, siblings; i >= 0; i--) {
5031 if (path[i].children.length === 0) {
5033 siblings = path[i - 1].children;
5034 siblings.splice(siblings.indexOf(path[i]), 1);
5036 } else this.clear();
5038 } else calcBBox(path[i], this.toBBox);
5042 _initFormat: function (format) {
5043 // data format (minX, minY, maxX, maxY accessors)
5045 // uses eval-type function compilation instead of just accepting a toBBox function
5046 // because the algorithms are very sensitive to sorting functions performance,
5047 // so they should be dead simple and without inner calls
5049 var compareArr = ['return a', ' - b', ';'];
5051 this.compareMinX = new Function('a', 'b', compareArr.join(format[0]));
5052 this.compareMinY = new Function('a', 'b', compareArr.join(format[1]));
5054 this.toBBox = new Function('a',
5055 'return {minX: a' + format[0] +
5056 ', minY: a' + format[1] +
5057 ', maxX: a' + format[2] +
5058 ', maxY: a' + format[3] + '};');
5062 function findItem(item, items, equalsFn) {
5063 if (!equalsFn) return items.indexOf(item);
5065 for (var i = 0; i < items.length; i++) {
5066 if (equalsFn(item, items[i])) return i;
5071 // calculate node's bbox from bboxes of its children
5072 function calcBBox(node, toBBox) {
5073 distBBox(node, 0, node.children.length, toBBox, node);
5076 // min bounding rectangle of node children from k to p-1
5077 function distBBox(node, k, p, toBBox, destNode) {
5078 if (!destNode) destNode = createNode(null);
5079 destNode.minX = Infinity;
5080 destNode.minY = Infinity;
5081 destNode.maxX = -Infinity;
5082 destNode.maxY = -Infinity;
5084 for (var i = k, child; i < p; i++) {
5085 child = node.children[i];
5086 extend(destNode, node.leaf ? toBBox(child) : child);
5092 function extend(a, b) {
5093 a.minX = Math.min(a.minX, b.minX);
5094 a.minY = Math.min(a.minY, b.minY);
5095 a.maxX = Math.max(a.maxX, b.maxX);
5096 a.maxY = Math.max(a.maxY, b.maxY);
5100 function compareNodeMinX(a, b) { return a.minX - b.minX; }
5101 function compareNodeMinY(a, b) { return a.minY - b.minY; }
5103 function bboxArea(a) { return (a.maxX - a.minX) * (a.maxY - a.minY); }
5104 function bboxMargin(a) { return (a.maxX - a.minX) + (a.maxY - a.minY); }
5106 function enlargedArea(a, b) {
5107 return (Math.max(b.maxX, a.maxX) - Math.min(b.minX, a.minX)) *
5108 (Math.max(b.maxY, a.maxY) - Math.min(b.minY, a.minY));
5111 function intersectionArea(a, b) {
5112 var minX = Math.max(a.minX, b.minX),
5113 minY = Math.max(a.minY, b.minY),
5114 maxX = Math.min(a.maxX, b.maxX),
5115 maxY = Math.min(a.maxY, b.maxY);
5117 return Math.max(0, maxX - minX) *
5118 Math.max(0, maxY - minY);
5121 function contains(a, b) {
5122 return a.minX <= b.minX &&
5128 function intersects(a, b) {
5129 return b.minX <= a.maxX &&
5135 function createNode(children) {
5147 // sort an array so that items come in groups of n unsorted items, with groups sorted between each other;
5148 // combines selection algorithm with binary divide & conquer approach
5150 function multiSelect(arr, left, right, n, compare) {
5151 var stack = [left, right],
5154 while (stack.length) {
5155 right = stack.pop();
5158 if (right - left <= n) continue;
5160 mid = left + Math.ceil((right - left) / n / 2) * n;
5161 quickselect(arr, mid, left, right, compare);
5163 stack.push(left, mid, mid, right);
5167 },{"quickselect":23}],25:[function(require,module,exports){
5169 var __extends = (this && this.__extends) || function (d, b) {
5170 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
5171 function __() { this.constructor = d; }
5172 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
5174 var Subject_1 = require('./Subject');
5175 var ObjectUnsubscribedError_1 = require('./util/ObjectUnsubscribedError');
5177 * @class BehaviorSubject<T>
5179 var BehaviorSubject = (function (_super) {
5180 __extends(BehaviorSubject, _super);
5181 function BehaviorSubject(_value) {
5183 this._value = _value;
5185 Object.defineProperty(BehaviorSubject.prototype, "value", {
5187 return this.getValue();
5192 BehaviorSubject.prototype._subscribe = function (subscriber) {
5193 var subscription = _super.prototype._subscribe.call(this, subscriber);
5194 if (subscription && !subscription.closed) {
5195 subscriber.next(this._value);
5197 return subscription;
5199 BehaviorSubject.prototype.getValue = function () {
5200 if (this.hasError) {
5201 throw this.thrownError;
5203 else if (this.closed) {
5204 throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError();
5210 BehaviorSubject.prototype.next = function (value) {
5211 _super.prototype.next.call(this, this._value = value);
5213 return BehaviorSubject;
5214 }(Subject_1.Subject));
5215 exports.BehaviorSubject = BehaviorSubject;
5217 },{"./Subject":33,"./util/ObjectUnsubscribedError":145}],26:[function(require,module,exports){
5219 var __extends = (this && this.__extends) || function (d, b) {
5220 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
5221 function __() { this.constructor = d; }
5222 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
5224 var Subscriber_1 = require('./Subscriber');
5226 * We need this JSDoc comment for affecting ESDoc.
5228 * @extends {Ignored}
5230 var InnerSubscriber = (function (_super) {
5231 __extends(InnerSubscriber, _super);
5232 function InnerSubscriber(parent, outerValue, outerIndex) {
5234 this.parent = parent;
5235 this.outerValue = outerValue;
5236 this.outerIndex = outerIndex;
5239 InnerSubscriber.prototype._next = function (value) {
5240 this.parent.notifyNext(this.outerValue, value, this.outerIndex, this.index++, this);
5242 InnerSubscriber.prototype._error = function (error) {
5243 this.parent.notifyError(error, this);
5246 InnerSubscriber.prototype._complete = function () {
5247 this.parent.notifyComplete(this);
5250 return InnerSubscriber;
5251 }(Subscriber_1.Subscriber));
5252 exports.InnerSubscriber = InnerSubscriber;
5254 },{"./Subscriber":35}],27:[function(require,module,exports){
5256 var Observable_1 = require('./Observable');
5258 * Represents a push-based event or value that an {@link Observable} can emit.
5259 * This class is particularly useful for operators that manage notifications,
5260 * like {@link materialize}, {@link dematerialize}, {@link observeOn}, and
5261 * others. Besides wrapping the actual delivered value, it also annotates it
5262 * with metadata of, for instance, what type of push message it is (`next`,
5263 * `error`, or `complete`).
5265 * @see {@link materialize}
5266 * @see {@link dematerialize}
5267 * @see {@link observeOn}
5269 * @class Notification<T>
5271 var Notification = (function () {
5272 function Notification(kind, value, exception) {
5275 this.exception = exception;
5276 this.hasValue = kind === 'N';
5279 * Delivers to the given `observer` the value wrapped by this Notification.
5280 * @param {Observer} observer
5283 Notification.prototype.observe = function (observer) {
5284 switch (this.kind) {
5286 return observer.next && observer.next(this.value);
5288 return observer.error && observer.error(this.exception);
5290 return observer.complete && observer.complete();
5294 * Given some {@link Observer} callbacks, deliver the value represented by the
5295 * current Notification to the correctly corresponding callback.
5296 * @param {function(value: T): void} next An Observer `next` callback.
5297 * @param {function(err: any): void} [error] An Observer `error` callback.
5298 * @param {function(): void} [complete] An Observer `complete` callback.
5301 Notification.prototype.do = function (next, error, complete) {
5302 var kind = this.kind;
5305 return next && next(this.value);
5307 return error && error(this.exception);
5309 return complete && complete();
5313 * Takes an Observer or its individual callback functions, and calls `observe`
5314 * or `do` methods accordingly.
5315 * @param {Observer|function(value: T): void} nextOrObserver An Observer or
5316 * the `next` callback.
5317 * @param {function(err: any): void} [error] An Observer `error` callback.
5318 * @param {function(): void} [complete] An Observer `complete` callback.
5321 Notification.prototype.accept = function (nextOrObserver, error, complete) {
5322 if (nextOrObserver && typeof nextOrObserver.next === 'function') {
5323 return this.observe(nextOrObserver);
5326 return this.do(nextOrObserver, error, complete);
5330 * Returns a simple Observable that just delivers the notification represented
5331 * by this Notification instance.
5334 Notification.prototype.toObservable = function () {
5335 var kind = this.kind;
5338 return Observable_1.Observable.of(this.value);
5340 return Observable_1.Observable.throw(this.exception);
5342 return Observable_1.Observable.empty();
5344 throw new Error('unexpected notification kind value');
5347 * A shortcut to create a Notification instance of the type `next` from a
5349 * @param {T} value The `next` value.
5350 * @return {Notification<T>} The "next" Notification representing the
5353 Notification.createNext = function (value) {
5354 if (typeof value !== 'undefined') {
5355 return new Notification('N', value);
5357 return this.undefinedValueNotification;
5360 * A shortcut to create a Notification instance of the type `error` from a
5362 * @param {any} [err] The `error` exception.
5363 * @return {Notification<T>} The "error" Notification representing the
5366 Notification.createError = function (err) {
5367 return new Notification('E', undefined, err);
5370 * A shortcut to create a Notification instance of the type `complete`.
5371 * @return {Notification<any>} The valueless "complete" Notification.
5373 Notification.createComplete = function () {
5374 return this.completeNotification;
5376 Notification.completeNotification = new Notification('C');
5377 Notification.undefinedValueNotification = new Notification('N', undefined);
5378 return Notification;
5380 exports.Notification = Notification;
5382 },{"./Observable":28}],28:[function(require,module,exports){
5384 var root_1 = require('./util/root');
5385 var toSubscriber_1 = require('./util/toSubscriber');
5386 var observable_1 = require('./symbol/observable');
5388 * A representation of any set of values over any amount of time. This the most basic building block
5391 * @class Observable<T>
5393 var Observable = (function () {
5396 * @param {Function} subscribe the function that is called when the Observable is
5397 * initially subscribed to. This function is given a Subscriber, to which new values
5398 * can be `next`ed, or an `error` method can be called to raise an error, or
5399 * `complete` can be called to notify of a successful completion.
5401 function Observable(subscribe) {
5402 this._isScalar = false;
5404 this._subscribe = subscribe;
5408 * Creates a new Observable, with this Observable as the source, and the passed
5409 * operator defined as the new observable's operator.
5411 * @param {Operator} operator the operator defining the operation to take on the observable
5412 * @return {Observable} a new observable with the Operator applied
5414 Observable.prototype.lift = function (operator) {
5415 var observable = new Observable();
5416 observable.source = this;
5417 observable.operator = operator;
5421 * Registers handlers for handling emitted values, error and completions from the observable, and
5422 * executes the observable's subscriber function, which will take action to set up the underlying data stream
5424 * @param {PartialObserver|Function} observerOrNext (optional) either an observer defining all functions to be called,
5425 * or the first of three possible handlers, which is the handler for each value emitted from the observable.
5426 * @param {Function} error (optional) a handler for a terminal event resulting from an error. If no error handler is provided,
5427 * the error will be thrown as unhandled
5428 * @param {Function} complete (optional) a handler for a terminal event resulting from successful completion.
5429 * @return {ISubscription} a subscription reference to the registered handlers
5431 Observable.prototype.subscribe = function (observerOrNext, error, complete) {
5432 var operator = this.operator;
5433 var sink = toSubscriber_1.toSubscriber(observerOrNext, error, complete);
5435 operator.call(sink, this);
5438 sink.add(this._subscribe(sink));
5440 if (sink.syncErrorThrowable) {
5441 sink.syncErrorThrowable = false;
5442 if (sink.syncErrorThrown) {
5443 throw sink.syncErrorValue;
5450 * @param {Function} next a handler for each value emitted by the observable
5451 * @param {PromiseConstructor} [PromiseCtor] a constructor function used to instantiate the Promise
5452 * @return {Promise} a promise that either resolves on observable completion or
5453 * rejects with the handled error
5455 Observable.prototype.forEach = function (next, PromiseCtor) {
5458 if (root_1.root.Rx && root_1.root.Rx.config && root_1.root.Rx.config.Promise) {
5459 PromiseCtor = root_1.root.Rx.config.Promise;
5461 else if (root_1.root.Promise) {
5462 PromiseCtor = root_1.root.Promise;
5466 throw new Error('no Promise impl found');
5468 return new PromiseCtor(function (resolve, reject) {
5469 var subscription = _this.subscribe(function (value) {
5471 // if there is a subscription, then we can surmise
5472 // the next handling is asynchronous. Any errors thrown
5473 // need to be rejected explicitly and unsubscribe must be
5480 subscription.unsubscribe();
5484 // if there is NO subscription, then we're getting a nexted
5485 // value synchronously during subscription. We can just call it.
5486 // If it errors, Observable's `subscribe` will ensure the
5487 // unsubscription logic is called, then synchronously rethrow the error.
5488 // After that, Promise will trap the error and send it
5489 // down the rejection path.
5492 }, reject, resolve);
5495 Observable.prototype._subscribe = function (subscriber) {
5496 return this.source.subscribe(subscriber);
5499 * An interop point defined by the es7-observable spec https://github.com/zenparsing/es-observable
5500 * @method Symbol.observable
5501 * @return {Observable} this instance of the observable
5503 Observable.prototype[observable_1.$$observable] = function () {
5506 // HACK: Since TypeScript inherits static properties too, we have to
5507 // fight against TypeScript here so Subject can have a different static create signature
5509 * Creates a new cold Observable by calling the Observable constructor
5513 * @param {Function} subscribe? the subscriber function to be passed to the Observable constructor
5514 * @return {Observable} a new cold observable
5516 Observable.create = function (subscribe) {
5517 return new Observable(subscribe);
5521 exports.Observable = Observable;
5523 },{"./symbol/observable":141,"./util/root":153,"./util/toSubscriber":155}],29:[function(require,module,exports){
5527 next: function (value) { },
5528 error: function (err) { throw err; },
5529 complete: function () { }
5532 },{}],30:[function(require,module,exports){
5534 var __extends = (this && this.__extends) || function (d, b) {
5535 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
5536 function __() { this.constructor = d; }
5537 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
5539 var Subscriber_1 = require('./Subscriber');
5541 * We need this JSDoc comment for affecting ESDoc.
5543 * @extends {Ignored}
5545 var OuterSubscriber = (function (_super) {
5546 __extends(OuterSubscriber, _super);
5547 function OuterSubscriber() {
5548 _super.apply(this, arguments);
5550 OuterSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
5551 this.destination.next(innerValue);
5553 OuterSubscriber.prototype.notifyError = function (error, innerSub) {
5554 this.destination.error(error);
5556 OuterSubscriber.prototype.notifyComplete = function (innerSub) {
5557 this.destination.complete();
5559 return OuterSubscriber;
5560 }(Subscriber_1.Subscriber));
5561 exports.OuterSubscriber = OuterSubscriber;
5563 },{"./Subscriber":35}],31:[function(require,module,exports){
5565 var __extends = (this && this.__extends) || function (d, b) {
5566 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
5567 function __() { this.constructor = d; }
5568 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
5570 var Subject_1 = require('./Subject');
5571 var queue_1 = require('./scheduler/queue');
5572 var observeOn_1 = require('./operator/observeOn');
5574 * @class ReplaySubject<T>
5576 var ReplaySubject = (function (_super) {
5577 __extends(ReplaySubject, _super);
5578 function ReplaySubject(bufferSize, windowTime, scheduler) {
5579 if (bufferSize === void 0) { bufferSize = Number.POSITIVE_INFINITY; }
5580 if (windowTime === void 0) { windowTime = Number.POSITIVE_INFINITY; }
5582 this.scheduler = scheduler;
5584 this._bufferSize = bufferSize < 1 ? 1 : bufferSize;
5585 this._windowTime = windowTime < 1 ? 1 : windowTime;
5587 ReplaySubject.prototype.next = function (value) {
5588 var now = this._getNow();
5589 this._events.push(new ReplayEvent(now, value));
5590 this._trimBufferThenGetEvents();
5591 _super.prototype.next.call(this, value);
5593 ReplaySubject.prototype._subscribe = function (subscriber) {
5594 var _events = this._trimBufferThenGetEvents();
5595 var scheduler = this.scheduler;
5597 subscriber.add(subscriber = new observeOn_1.ObserveOnSubscriber(subscriber, scheduler));
5599 var len = _events.length;
5600 for (var i = 0; i < len && !subscriber.closed; i++) {
5601 subscriber.next(_events[i].value);
5603 return _super.prototype._subscribe.call(this, subscriber);
5605 ReplaySubject.prototype._getNow = function () {
5606 return (this.scheduler || queue_1.queue).now();
5608 ReplaySubject.prototype._trimBufferThenGetEvents = function () {
5609 var now = this._getNow();
5610 var _bufferSize = this._bufferSize;
5611 var _windowTime = this._windowTime;
5612 var _events = this._events;
5613 var eventsCount = _events.length;
5614 var spliceCount = 0;
5615 // Trim events that fall out of the time window.
5616 // Start at the front of the list. Break early once
5617 // we encounter an event that falls within the window.
5618 while (spliceCount < eventsCount) {
5619 if ((now - _events[spliceCount].time) < _windowTime) {
5624 if (eventsCount > _bufferSize) {
5625 spliceCount = Math.max(spliceCount, eventsCount - _bufferSize);
5627 if (spliceCount > 0) {
5628 _events.splice(0, spliceCount);
5632 return ReplaySubject;
5633 }(Subject_1.Subject));
5634 exports.ReplaySubject = ReplaySubject;
5635 var ReplayEvent = (function () {
5636 function ReplayEvent(time, value) {
5643 },{"./Subject":33,"./operator/observeOn":118,"./scheduler/queue":139}],32:[function(require,module,exports){
5646 * An execution context and a data structure to order tasks and schedule their
5647 * execution. Provides a notion of (potentially virtual) time, through the
5648 * `now()` getter method.
5650 * Each unit of work in a Scheduler is called an {@link Action}.
5655 * schedule(work, delay?, state?): Subscription;
5661 var Scheduler = (function () {
5662 function Scheduler(SchedulerAction, now) {
5663 if (now === void 0) { now = Scheduler.now; }
5664 this.SchedulerAction = SchedulerAction;
5668 * Schedules a function, `work`, for execution. May happen at some point in
5669 * the future, according to the `delay` parameter, if specified. May be passed
5670 * some context object, `state`, which will be passed to the `work` function.
5672 * The given arguments will be processed an stored as an Action object in a
5675 * @param {function(state: ?T): ?Subscription} work A function representing a
5676 * task, or some unit of work to be executed by the Scheduler.
5677 * @param {number} [delay] Time to wait before executing the work, where the
5678 * time unit is implicit and defined by the Scheduler itself.
5679 * @param {T} [state] Some contextual data that the `work` function uses when
5680 * called by the Scheduler.
5681 * @return {Subscription} A subscription in order to be able to unsubscribe
5682 * the scheduled work.
5684 Scheduler.prototype.schedule = function (work, delay, state) {
5685 if (delay === void 0) { delay = 0; }
5686 return new this.SchedulerAction(this, work).schedule(state, delay);
5688 Scheduler.now = Date.now ? Date.now : function () { return +new Date(); };
5691 exports.Scheduler = Scheduler;
5693 },{}],33:[function(require,module,exports){
5695 var __extends = (this && this.__extends) || function (d, b) {
5696 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
5697 function __() { this.constructor = d; }
5698 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
5700 var Observable_1 = require('./Observable');
5701 var Subscriber_1 = require('./Subscriber');
5702 var Subscription_1 = require('./Subscription');
5703 var ObjectUnsubscribedError_1 = require('./util/ObjectUnsubscribedError');
5704 var SubjectSubscription_1 = require('./SubjectSubscription');
5705 var rxSubscriber_1 = require('./symbol/rxSubscriber');
5707 * @class SubjectSubscriber<T>
5709 var SubjectSubscriber = (function (_super) {
5710 __extends(SubjectSubscriber, _super);
5711 function SubjectSubscriber(destination) {
5712 _super.call(this, destination);
5713 this.destination = destination;
5715 return SubjectSubscriber;
5716 }(Subscriber_1.Subscriber));
5717 exports.SubjectSubscriber = SubjectSubscriber;
5721 var Subject = (function (_super) {
5722 __extends(Subject, _super);
5723 function Subject() {
5725 this.observers = [];
5726 this.closed = false;
5727 this.isStopped = false;
5728 this.hasError = false;
5729 this.thrownError = null;
5731 Subject.prototype[rxSubscriber_1.$$rxSubscriber] = function () {
5732 return new SubjectSubscriber(this);
5734 Subject.prototype.lift = function (operator) {
5735 var subject = new AnonymousSubject(this, this);
5736 subject.operator = operator;
5739 Subject.prototype.next = function (value) {
5741 throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError();
5743 if (!this.isStopped) {
5744 var observers = this.observers;
5745 var len = observers.length;
5746 var copy = observers.slice();
5747 for (var i = 0; i < len; i++) {
5748 copy[i].next(value);
5752 Subject.prototype.error = function (err) {
5754 throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError();
5756 this.hasError = true;
5757 this.thrownError = err;
5758 this.isStopped = true;
5759 var observers = this.observers;
5760 var len = observers.length;
5761 var copy = observers.slice();
5762 for (var i = 0; i < len; i++) {
5765 this.observers.length = 0;
5767 Subject.prototype.complete = function () {
5769 throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError();
5771 this.isStopped = true;
5772 var observers = this.observers;
5773 var len = observers.length;
5774 var copy = observers.slice();
5775 for (var i = 0; i < len; i++) {
5778 this.observers.length = 0;
5780 Subject.prototype.unsubscribe = function () {
5781 this.isStopped = true;
5783 this.observers = null;
5785 Subject.prototype._subscribe = function (subscriber) {
5787 throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError();
5789 else if (this.hasError) {
5790 subscriber.error(this.thrownError);
5791 return Subscription_1.Subscription.EMPTY;
5793 else if (this.isStopped) {
5794 subscriber.complete();
5795 return Subscription_1.Subscription.EMPTY;
5798 this.observers.push(subscriber);
5799 return new SubjectSubscription_1.SubjectSubscription(this, subscriber);
5802 Subject.prototype.asObservable = function () {
5803 var observable = new Observable_1.Observable();
5804 observable.source = this;
5807 Subject.create = function (destination, source) {
5808 return new AnonymousSubject(destination, source);
5811 }(Observable_1.Observable));
5812 exports.Subject = Subject;
5814 * @class AnonymousSubject<T>
5816 var AnonymousSubject = (function (_super) {
5817 __extends(AnonymousSubject, _super);
5818 function AnonymousSubject(destination, source) {
5820 this.destination = destination;
5821 this.source = source;
5823 AnonymousSubject.prototype.next = function (value) {
5824 var destination = this.destination;
5825 if (destination && destination.next) {
5826 destination.next(value);
5829 AnonymousSubject.prototype.error = function (err) {
5830 var destination = this.destination;
5831 if (destination && destination.error) {
5832 this.destination.error(err);
5835 AnonymousSubject.prototype.complete = function () {
5836 var destination = this.destination;
5837 if (destination && destination.complete) {
5838 this.destination.complete();
5841 AnonymousSubject.prototype._subscribe = function (subscriber) {
5842 var source = this.source;
5844 return this.source.subscribe(subscriber);
5847 return Subscription_1.Subscription.EMPTY;
5850 return AnonymousSubject;
5852 exports.AnonymousSubject = AnonymousSubject;
5854 },{"./Observable":28,"./SubjectSubscription":34,"./Subscriber":35,"./Subscription":36,"./symbol/rxSubscriber":142,"./util/ObjectUnsubscribedError":145}],34:[function(require,module,exports){
5856 var __extends = (this && this.__extends) || function (d, b) {
5857 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
5858 function __() { this.constructor = d; }
5859 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
5861 var Subscription_1 = require('./Subscription');
5863 * We need this JSDoc comment for affecting ESDoc.
5865 * @extends {Ignored}
5867 var SubjectSubscription = (function (_super) {
5868 __extends(SubjectSubscription, _super);
5869 function SubjectSubscription(subject, subscriber) {
5871 this.subject = subject;
5872 this.subscriber = subscriber;
5873 this.closed = false;
5875 SubjectSubscription.prototype.unsubscribe = function () {
5880 var subject = this.subject;
5881 var observers = subject.observers;
5882 this.subject = null;
5883 if (!observers || observers.length === 0 || subject.isStopped || subject.closed) {
5886 var subscriberIndex = observers.indexOf(this.subscriber);
5887 if (subscriberIndex !== -1) {
5888 observers.splice(subscriberIndex, 1);
5891 return SubjectSubscription;
5892 }(Subscription_1.Subscription));
5893 exports.SubjectSubscription = SubjectSubscription;
5895 },{"./Subscription":36}],35:[function(require,module,exports){
5897 var __extends = (this && this.__extends) || function (d, b) {
5898 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
5899 function __() { this.constructor = d; }
5900 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
5902 var isFunction_1 = require('./util/isFunction');
5903 var Subscription_1 = require('./Subscription');
5904 var Observer_1 = require('./Observer');
5905 var rxSubscriber_1 = require('./symbol/rxSubscriber');
5907 * Implements the {@link Observer} interface and extends the
5908 * {@link Subscription} class. While the {@link Observer} is the public API for
5909 * consuming the values of an {@link Observable}, all Observers get converted to
5910 * a Subscriber, in order to provide Subscription-like capabilities such as
5911 * `unsubscribe`. Subscriber is a common type in RxJS, and crucial for
5912 * implementing operators, but it is rarely used as a public API.
5914 * @class Subscriber<T>
5916 var Subscriber = (function (_super) {
5917 __extends(Subscriber, _super);
5919 * @param {Observer|function(value: T): void} [destinationOrNext] A partially
5920 * defined Observer or a `next` callback function.
5921 * @param {function(e: ?any): void} [error] The `error` callback of an
5923 * @param {function(): void} [complete] The `complete` callback of an
5926 function Subscriber(destinationOrNext, error, complete) {
5928 this.syncErrorValue = null;
5929 this.syncErrorThrown = false;
5930 this.syncErrorThrowable = false;
5931 this.isStopped = false;
5932 switch (arguments.length) {
5934 this.destination = Observer_1.empty;
5937 if (!destinationOrNext) {
5938 this.destination = Observer_1.empty;
5941 if (typeof destinationOrNext === 'object') {
5942 if (destinationOrNext instanceof Subscriber) {
5943 this.destination = destinationOrNext;
5944 this.destination.add(this);
5947 this.syncErrorThrowable = true;
5948 this.destination = new SafeSubscriber(this, destinationOrNext);
5953 this.syncErrorThrowable = true;
5954 this.destination = new SafeSubscriber(this, destinationOrNext, error, complete);
5958 Subscriber.prototype[rxSubscriber_1.$$rxSubscriber] = function () { return this; };
5960 * A static factory for a Subscriber, given a (potentially partial) definition
5962 * @param {function(x: ?T): void} [next] The `next` callback of an Observer.
5963 * @param {function(e: ?any): void} [error] The `error` callback of an
5965 * @param {function(): void} [complete] The `complete` callback of an
5967 * @return {Subscriber<T>} A Subscriber wrapping the (partially defined)
5968 * Observer represented by the given arguments.
5970 Subscriber.create = function (next, error, complete) {
5971 var subscriber = new Subscriber(next, error, complete);
5972 subscriber.syncErrorThrowable = false;
5976 * The {@link Observer} callback to receive notifications of type `next` from
5977 * the Observable, with a value. The Observable may call this method 0 or more
5979 * @param {T} [value] The `next` value.
5982 Subscriber.prototype.next = function (value) {
5983 if (!this.isStopped) {
5988 * The {@link Observer} callback to receive notifications of type `error` from
5989 * the Observable, with an attached {@link Error}. Notifies the Observer that
5990 * the Observable has experienced an error condition.
5991 * @param {any} [err] The `error` exception.
5994 Subscriber.prototype.error = function (err) {
5995 if (!this.isStopped) {
5996 this.isStopped = true;
6001 * The {@link Observer} callback to receive a valueless notification of type
6002 * `complete` from the Observable. Notifies the Observer that the Observable
6003 * has finished sending push-based notifications.
6006 Subscriber.prototype.complete = function () {
6007 if (!this.isStopped) {
6008 this.isStopped = true;
6012 Subscriber.prototype.unsubscribe = function () {
6016 this.isStopped = true;
6017 _super.prototype.unsubscribe.call(this);
6019 Subscriber.prototype._next = function (value) {
6020 this.destination.next(value);
6022 Subscriber.prototype._error = function (err) {
6023 this.destination.error(err);
6026 Subscriber.prototype._complete = function () {
6027 this.destination.complete();
6031 }(Subscription_1.Subscription));
6032 exports.Subscriber = Subscriber;
6034 * We need this JSDoc comment for affecting ESDoc.
6036 * @extends {Ignored}
6038 var SafeSubscriber = (function (_super) {
6039 __extends(SafeSubscriber, _super);
6040 function SafeSubscriber(_parent, observerOrNext, error, complete) {
6042 this._parent = _parent;
6045 if (isFunction_1.isFunction(observerOrNext)) {
6046 next = observerOrNext;
6048 else if (observerOrNext) {
6049 context = observerOrNext;
6050 next = observerOrNext.next;
6051 error = observerOrNext.error;
6052 complete = observerOrNext.complete;
6053 if (isFunction_1.isFunction(context.unsubscribe)) {
6054 this.add(context.unsubscribe.bind(context));
6056 context.unsubscribe = this.unsubscribe.bind(this);
6058 this._context = context;
6060 this._error = error;
6061 this._complete = complete;
6063 SafeSubscriber.prototype.next = function (value) {
6064 if (!this.isStopped && this._next) {
6065 var _parent = this._parent;
6066 if (!_parent.syncErrorThrowable) {
6067 this.__tryOrUnsub(this._next, value);
6069 else if (this.__tryOrSetError(_parent, this._next, value)) {
6074 SafeSubscriber.prototype.error = function (err) {
6075 if (!this.isStopped) {
6076 var _parent = this._parent;
6078 if (!_parent.syncErrorThrowable) {
6079 this.__tryOrUnsub(this._error, err);
6083 this.__tryOrSetError(_parent, this._error, err);
6087 else if (!_parent.syncErrorThrowable) {
6092 _parent.syncErrorValue = err;
6093 _parent.syncErrorThrown = true;
6098 SafeSubscriber.prototype.complete = function () {
6099 if (!this.isStopped) {
6100 var _parent = this._parent;
6101 if (this._complete) {
6102 if (!_parent.syncErrorThrowable) {
6103 this.__tryOrUnsub(this._complete);
6107 this.__tryOrSetError(_parent, this._complete);
6116 SafeSubscriber.prototype.__tryOrUnsub = function (fn, value) {
6118 fn.call(this._context, value);
6125 SafeSubscriber.prototype.__tryOrSetError = function (parent, fn, value) {
6127 fn.call(this._context, value);
6130 parent.syncErrorValue = err;
6131 parent.syncErrorThrown = true;
6136 SafeSubscriber.prototype._unsubscribe = function () {
6137 var _parent = this._parent;
6138 this._context = null;
6139 this._parent = null;
6140 _parent.unsubscribe();
6142 return SafeSubscriber;
6145 },{"./Observer":29,"./Subscription":36,"./symbol/rxSubscriber":142,"./util/isFunction":149}],36:[function(require,module,exports){
6147 var isArray_1 = require('./util/isArray');
6148 var isObject_1 = require('./util/isObject');
6149 var isFunction_1 = require('./util/isFunction');
6150 var tryCatch_1 = require('./util/tryCatch');
6151 var errorObject_1 = require('./util/errorObject');
6152 var UnsubscriptionError_1 = require('./util/UnsubscriptionError');
6154 * Represents a disposable resource, such as the execution of an Observable. A
6155 * Subscription has one important method, `unsubscribe`, that takes no argument
6156 * and just disposes the resource held by the subscription.
6158 * Additionally, subscriptions may be grouped together through the `add()`
6159 * method, which will attach a child Subscription to the current Subscription.
6160 * When a Subscription is unsubscribed, all its children (and its grandchildren)
6161 * will be unsubscribed as well.
6163 * @class Subscription
6165 var Subscription = (function () {
6167 * @param {function(): void} [unsubscribe] A function describing how to
6168 * perform the disposal of resources when the `unsubscribe` method is called.
6170 function Subscription(unsubscribe) {
6172 * A flag to indicate whether this Subscription has already been unsubscribed.
6175 this.closed = false;
6177 this._unsubscribe = unsubscribe;
6181 * Disposes the resources held by the subscription. May, for instance, cancel
6182 * an ongoing Observable execution or cancel any other type of work that
6183 * started when the Subscription was created.
6186 Subscription.prototype.unsubscribe = function () {
6187 var hasErrors = false;
6193 var _a = this, _unsubscribe = _a._unsubscribe, _subscriptions = _a._subscriptions;
6194 this._subscriptions = null;
6195 if (isFunction_1.isFunction(_unsubscribe)) {
6196 var trial = tryCatch_1.tryCatch(_unsubscribe).call(this);
6197 if (trial === errorObject_1.errorObject) {
6199 (errors = errors || []).push(errorObject_1.errorObject.e);
6202 if (isArray_1.isArray(_subscriptions)) {
6204 var len = _subscriptions.length;
6205 while (++index < len) {
6206 var sub = _subscriptions[index];
6207 if (isObject_1.isObject(sub)) {
6208 var trial = tryCatch_1.tryCatch(sub.unsubscribe).call(sub);
6209 if (trial === errorObject_1.errorObject) {
6211 errors = errors || [];
6212 var err = errorObject_1.errorObject.e;
6213 if (err instanceof UnsubscriptionError_1.UnsubscriptionError) {
6214 errors = errors.concat(err.errors);
6224 throw new UnsubscriptionError_1.UnsubscriptionError(errors);
6228 * Adds a tear down to be called during the unsubscribe() of this
6231 * If the tear down being added is a subscription that is already
6232 * unsubscribed, is the same reference `add` is being called on, or is
6233 * `Subscription.EMPTY`, it will not be added.
6235 * If this subscription is already in an `closed` state, the passed
6236 * tear down logic will be executed immediately.
6238 * @param {TeardownLogic} teardown The additional logic to execute on
6240 * @return {Subscription} Returns the Subscription used or created to be
6241 * added to the inner subscriptions list. This Subscription can be used with
6242 * `remove()` to remove the passed teardown logic from the inner subscriptions
6245 Subscription.prototype.add = function (teardown) {
6246 if (!teardown || (teardown === Subscription.EMPTY)) {
6247 return Subscription.EMPTY;
6249 if (teardown === this) {
6253 switch (typeof teardown) {
6255 sub = new Subscription(teardown);
6257 if (sub.closed || typeof sub.unsubscribe !== 'function') {
6260 else if (this.closed) {
6264 (this._subscriptions || (this._subscriptions = [])).push(sub);
6268 throw new Error('unrecognized teardown ' + teardown + ' added to Subscription.');
6273 * Removes a Subscription from the internal list of subscriptions that will
6274 * unsubscribe during the unsubscribe process of this Subscription.
6275 * @param {Subscription} subscription The subscription to remove.
6278 Subscription.prototype.remove = function (subscription) {
6279 // HACK: This might be redundant because of the logic in `add()`
6280 if (subscription == null || (subscription === this) || (subscription === Subscription.EMPTY)) {
6283 var subscriptions = this._subscriptions;
6284 if (subscriptions) {
6285 var subscriptionIndex = subscriptions.indexOf(subscription);
6286 if (subscriptionIndex !== -1) {
6287 subscriptions.splice(subscriptionIndex, 1);
6291 Subscription.EMPTY = (function (empty) {
6292 empty.closed = true;
6294 }(new Subscription()));
6295 return Subscription;
6297 exports.Subscription = Subscription;
6299 },{"./util/UnsubscriptionError":146,"./util/errorObject":147,"./util/isArray":148,"./util/isFunction":149,"./util/isObject":150,"./util/tryCatch":156}],37:[function(require,module,exports){
6301 var Observable_1 = require('../../Observable');
6302 var combineLatest_1 = require('../../observable/combineLatest');
6303 Observable_1.Observable.combineLatest = combineLatest_1.combineLatest;
6305 },{"../../Observable":28,"../../observable/combineLatest":90}],38:[function(require,module,exports){
6307 var Observable_1 = require('../../Observable');
6308 var defer_1 = require('../../observable/defer');
6309 Observable_1.Observable.defer = defer_1.defer;
6311 },{"../../Observable":28,"../../observable/defer":91}],39:[function(require,module,exports){
6313 var Observable_1 = require('../../Observable');
6314 var empty_1 = require('../../observable/empty');
6315 Observable_1.Observable.empty = empty_1.empty;
6317 },{"../../Observable":28,"../../observable/empty":92}],40:[function(require,module,exports){
6319 var Observable_1 = require('../../Observable');
6320 var from_1 = require('../../observable/from');
6321 Observable_1.Observable.from = from_1.from;
6323 },{"../../Observable":28,"../../observable/from":93}],41:[function(require,module,exports){
6325 var Observable_1 = require('../../Observable');
6326 var fromEvent_1 = require('../../observable/fromEvent');
6327 Observable_1.Observable.fromEvent = fromEvent_1.fromEvent;
6329 },{"../../Observable":28,"../../observable/fromEvent":94}],42:[function(require,module,exports){
6331 var Observable_1 = require('../../Observable');
6332 var fromPromise_1 = require('../../observable/fromPromise');
6333 Observable_1.Observable.fromPromise = fromPromise_1.fromPromise;
6335 },{"../../Observable":28,"../../observable/fromPromise":95}],43:[function(require,module,exports){
6337 var Observable_1 = require('../../Observable');
6338 var merge_1 = require('../../observable/merge');
6339 Observable_1.Observable.merge = merge_1.merge;
6341 },{"../../Observable":28,"../../observable/merge":96}],44:[function(require,module,exports){
6343 var Observable_1 = require('../../Observable');
6344 var of_1 = require('../../observable/of');
6345 Observable_1.Observable.of = of_1.of;
6347 },{"../../Observable":28,"../../observable/of":97}],45:[function(require,module,exports){
6349 var Observable_1 = require('../../Observable');
6350 var throw_1 = require('../../observable/throw');
6351 Observable_1.Observable.throw = throw_1._throw;
6353 },{"../../Observable":28,"../../observable/throw":98}],46:[function(require,module,exports){
6355 var Observable_1 = require('../../Observable');
6356 var zip_1 = require('../../observable/zip');
6357 Observable_1.Observable.zip = zip_1.zip;
6359 },{"../../Observable":28,"../../observable/zip":99}],47:[function(require,module,exports){
6361 var Observable_1 = require('../../Observable');
6362 var buffer_1 = require('../../operator/buffer');
6363 Observable_1.Observable.prototype.buffer = buffer_1.buffer;
6365 },{"../../Observable":28,"../../operator/buffer":100}],48:[function(require,module,exports){
6367 var Observable_1 = require('../../Observable');
6368 var catch_1 = require('../../operator/catch');
6369 Observable_1.Observable.prototype.catch = catch_1._catch;
6370 Observable_1.Observable.prototype._catch = catch_1._catch;
6372 },{"../../Observable":28,"../../operator/catch":101}],49:[function(require,module,exports){
6374 var Observable_1 = require('../../Observable');
6375 var combineLatest_1 = require('../../operator/combineLatest');
6376 Observable_1.Observable.prototype.combineLatest = combineLatest_1.combineLatest;
6378 },{"../../Observable":28,"../../operator/combineLatest":102}],50:[function(require,module,exports){
6380 var Observable_1 = require('../../Observable');
6381 var concat_1 = require('../../operator/concat');
6382 Observable_1.Observable.prototype.concat = concat_1.concat;
6384 },{"../../Observable":28,"../../operator/concat":103}],51:[function(require,module,exports){
6386 var Observable_1 = require('../../Observable');
6387 var debounceTime_1 = require('../../operator/debounceTime');
6388 Observable_1.Observable.prototype.debounceTime = debounceTime_1.debounceTime;
6390 },{"../../Observable":28,"../../operator/debounceTime":104}],52:[function(require,module,exports){
6392 var Observable_1 = require('../../Observable');
6393 var distinct_1 = require('../../operator/distinct');
6394 Observable_1.Observable.prototype.distinct = distinct_1.distinct;
6396 },{"../../Observable":28,"../../operator/distinct":105}],53:[function(require,module,exports){
6398 var Observable_1 = require('../../Observable');
6399 var distinctUntilChanged_1 = require('../../operator/distinctUntilChanged');
6400 Observable_1.Observable.prototype.distinctUntilChanged = distinctUntilChanged_1.distinctUntilChanged;
6402 },{"../../Observable":28,"../../operator/distinctUntilChanged":106}],54:[function(require,module,exports){
6404 var Observable_1 = require('../../Observable');
6405 var do_1 = require('../../operator/do');
6406 Observable_1.Observable.prototype.do = do_1._do;
6407 Observable_1.Observable.prototype._do = do_1._do;
6409 },{"../../Observable":28,"../../operator/do":107}],55:[function(require,module,exports){
6411 var Observable_1 = require('../../Observable');
6412 var expand_1 = require('../../operator/expand');
6413 Observable_1.Observable.prototype.expand = expand_1.expand;
6415 },{"../../Observable":28,"../../operator/expand":108}],56:[function(require,module,exports){
6417 var Observable_1 = require('../../Observable');
6418 var filter_1 = require('../../operator/filter');
6419 Observable_1.Observable.prototype.filter = filter_1.filter;
6421 },{"../../Observable":28,"../../operator/filter":109}],57:[function(require,module,exports){
6423 var Observable_1 = require('../../Observable');
6424 var finally_1 = require('../../operator/finally');
6425 Observable_1.Observable.prototype.finally = finally_1._finally;
6426 Observable_1.Observable.prototype._finally = finally_1._finally;
6428 },{"../../Observable":28,"../../operator/finally":110}],58:[function(require,module,exports){
6430 var Observable_1 = require('../../Observable');
6431 var first_1 = require('../../operator/first');
6432 Observable_1.Observable.prototype.first = first_1.first;
6434 },{"../../Observable":28,"../../operator/first":111}],59:[function(require,module,exports){
6436 var Observable_1 = require('../../Observable');
6437 var last_1 = require('../../operator/last');
6438 Observable_1.Observable.prototype.last = last_1.last;
6440 },{"../../Observable":28,"../../operator/last":112}],60:[function(require,module,exports){
6442 var Observable_1 = require('../../Observable');
6443 var map_1 = require('../../operator/map');
6444 Observable_1.Observable.prototype.map = map_1.map;
6446 },{"../../Observable":28,"../../operator/map":113}],61:[function(require,module,exports){
6448 var Observable_1 = require('../../Observable');
6449 var merge_1 = require('../../operator/merge');
6450 Observable_1.Observable.prototype.merge = merge_1.merge;
6452 },{"../../Observable":28,"../../operator/merge":114}],62:[function(require,module,exports){
6454 var Observable_1 = require('../../Observable');
6455 var mergeAll_1 = require('../../operator/mergeAll');
6456 Observable_1.Observable.prototype.mergeAll = mergeAll_1.mergeAll;
6458 },{"../../Observable":28,"../../operator/mergeAll":115}],63:[function(require,module,exports){
6460 var Observable_1 = require('../../Observable');
6461 var mergeMap_1 = require('../../operator/mergeMap');
6462 Observable_1.Observable.prototype.mergeMap = mergeMap_1.mergeMap;
6463 Observable_1.Observable.prototype.flatMap = mergeMap_1.mergeMap;
6465 },{"../../Observable":28,"../../operator/mergeMap":116}],64:[function(require,module,exports){
6467 var Observable_1 = require('../../Observable');
6468 var pairwise_1 = require('../../operator/pairwise');
6469 Observable_1.Observable.prototype.pairwise = pairwise_1.pairwise;
6471 },{"../../Observable":28,"../../operator/pairwise":119}],65:[function(require,module,exports){
6473 var Observable_1 = require('../../Observable');
6474 var pluck_1 = require('../../operator/pluck');
6475 Observable_1.Observable.prototype.pluck = pluck_1.pluck;
6477 },{"../../Observable":28,"../../operator/pluck":120}],66:[function(require,module,exports){
6479 var Observable_1 = require('../../Observable');
6480 var publish_1 = require('../../operator/publish');
6481 Observable_1.Observable.prototype.publish = publish_1.publish;
6483 },{"../../Observable":28,"../../operator/publish":121}],67:[function(require,module,exports){
6485 var Observable_1 = require('../../Observable');
6486 var publishReplay_1 = require('../../operator/publishReplay');
6487 Observable_1.Observable.prototype.publishReplay = publishReplay_1.publishReplay;
6489 },{"../../Observable":28,"../../operator/publishReplay":122}],68:[function(require,module,exports){
6491 var Observable_1 = require('../../Observable');
6492 var scan_1 = require('../../operator/scan');
6493 Observable_1.Observable.prototype.scan = scan_1.scan;
6495 },{"../../Observable":28,"../../operator/scan":123}],69:[function(require,module,exports){
6497 var Observable_1 = require('../../Observable');
6498 var share_1 = require('../../operator/share');
6499 Observable_1.Observable.prototype.share = share_1.share;
6501 },{"../../Observable":28,"../../operator/share":124}],70:[function(require,module,exports){
6503 var Observable_1 = require('../../Observable');
6504 var skip_1 = require('../../operator/skip');
6505 Observable_1.Observable.prototype.skip = skip_1.skip;
6507 },{"../../Observable":28,"../../operator/skip":125}],71:[function(require,module,exports){
6509 var Observable_1 = require('../../Observable');
6510 var skipUntil_1 = require('../../operator/skipUntil');
6511 Observable_1.Observable.prototype.skipUntil = skipUntil_1.skipUntil;
6513 },{"../../Observable":28,"../../operator/skipUntil":126}],72:[function(require,module,exports){
6515 var Observable_1 = require('../../Observable');
6516 var startWith_1 = require('../../operator/startWith');
6517 Observable_1.Observable.prototype.startWith = startWith_1.startWith;
6519 },{"../../Observable":28,"../../operator/startWith":127}],73:[function(require,module,exports){
6521 var Observable_1 = require('../../Observable');
6522 var switchMap_1 = require('../../operator/switchMap');
6523 Observable_1.Observable.prototype.switchMap = switchMap_1.switchMap;
6525 },{"../../Observable":28,"../../operator/switchMap":128}],74:[function(require,module,exports){
6527 var Observable_1 = require('../../Observable');
6528 var take_1 = require('../../operator/take');
6529 Observable_1.Observable.prototype.take = take_1.take;
6531 },{"../../Observable":28,"../../operator/take":129}],75:[function(require,module,exports){
6533 var Observable_1 = require('../../Observable');
6534 var takeUntil_1 = require('../../operator/takeUntil');
6535 Observable_1.Observable.prototype.takeUntil = takeUntil_1.takeUntil;
6537 },{"../../Observable":28,"../../operator/takeUntil":130}],76:[function(require,module,exports){
6539 var Observable_1 = require('../../Observable');
6540 var withLatestFrom_1 = require('../../operator/withLatestFrom');
6541 Observable_1.Observable.prototype.withLatestFrom = withLatestFrom_1.withLatestFrom;
6543 },{"../../Observable":28,"../../operator/withLatestFrom":131}],77:[function(require,module,exports){
6545 var Observable_1 = require('../../Observable');
6546 var zip_1 = require('../../operator/zip');
6547 Observable_1.Observable.prototype.zip = zip_1.zipProto;
6549 },{"../../Observable":28,"../../operator/zip":132}],78:[function(require,module,exports){
6551 var __extends = (this && this.__extends) || function (d, b) {
6552 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
6553 function __() { this.constructor = d; }
6554 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
6556 var Observable_1 = require('../Observable');
6557 var ScalarObservable_1 = require('./ScalarObservable');
6558 var EmptyObservable_1 = require('./EmptyObservable');
6560 * We need this JSDoc comment for affecting ESDoc.
6561 * @extends {Ignored}
6564 var ArrayLikeObservable = (function (_super) {
6565 __extends(ArrayLikeObservable, _super);
6566 function ArrayLikeObservable(arrayLike, scheduler) {
6568 this.arrayLike = arrayLike;
6569 this.scheduler = scheduler;
6570 if (!scheduler && arrayLike.length === 1) {
6571 this._isScalar = true;
6572 this.value = arrayLike[0];
6575 ArrayLikeObservable.create = function (arrayLike, scheduler) {
6576 var length = arrayLike.length;
6578 return new EmptyObservable_1.EmptyObservable();
6580 else if (length === 1) {
6581 return new ScalarObservable_1.ScalarObservable(arrayLike[0], scheduler);
6584 return new ArrayLikeObservable(arrayLike, scheduler);
6587 ArrayLikeObservable.dispatch = function (state) {
6588 var arrayLike = state.arrayLike, index = state.index, length = state.length, subscriber = state.subscriber;
6589 if (subscriber.closed) {
6592 if (index >= length) {
6593 subscriber.complete();
6596 subscriber.next(arrayLike[index]);
6597 state.index = index + 1;
6598 this.schedule(state);
6600 ArrayLikeObservable.prototype._subscribe = function (subscriber) {
6602 var _a = this, arrayLike = _a.arrayLike, scheduler = _a.scheduler;
6603 var length = arrayLike.length;
6605 return scheduler.schedule(ArrayLikeObservable.dispatch, 0, {
6606 arrayLike: arrayLike, index: index, length: length, subscriber: subscriber
6610 for (var i = 0; i < length && !subscriber.closed; i++) {
6611 subscriber.next(arrayLike[i]);
6613 subscriber.complete();
6616 return ArrayLikeObservable;
6617 }(Observable_1.Observable));
6618 exports.ArrayLikeObservable = ArrayLikeObservable;
6620 },{"../Observable":28,"./EmptyObservable":82,"./ScalarObservable":89}],79:[function(require,module,exports){
6622 var __extends = (this && this.__extends) || function (d, b) {
6623 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
6624 function __() { this.constructor = d; }
6625 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
6627 var Observable_1 = require('../Observable');
6628 var ScalarObservable_1 = require('./ScalarObservable');
6629 var EmptyObservable_1 = require('./EmptyObservable');
6630 var isScheduler_1 = require('../util/isScheduler');
6632 * We need this JSDoc comment for affecting ESDoc.
6633 * @extends {Ignored}
6636 var ArrayObservable = (function (_super) {
6637 __extends(ArrayObservable, _super);
6638 function ArrayObservable(array, scheduler) {
6641 this.scheduler = scheduler;
6642 if (!scheduler && array.length === 1) {
6643 this._isScalar = true;
6644 this.value = array[0];
6647 ArrayObservable.create = function (array, scheduler) {
6648 return new ArrayObservable(array, scheduler);
6651 * Creates an Observable that emits some values you specify as arguments,
6652 * immediately one after the other, and then emits a complete notification.
6654 * <span class="informal">Emits the arguments you provide, then completes.
6657 * <img src="./img/of.png" width="100%">
6659 * This static operator is useful for creating a simple Observable that only
6660 * emits the arguments given, and the complete notification thereafter. It can
6661 * be used for composing with other Observables, such as with {@link concat}.
6662 * By default, it uses a `null` Scheduler, which means the `next`
6663 * notifications are sent synchronously, although with a different Scheduler
6664 * it is possible to determine when those notifications will be delivered.
6666 * @example <caption>Emit 10, 20, 30, then 'a', 'b', 'c', then start ticking every second.</caption>
6667 * var numbers = Rx.Observable.of(10, 20, 30);
6668 * var letters = Rx.Observable.of('a', 'b', 'c');
6669 * var interval = Rx.Observable.interval(1000);
6670 * var result = numbers.concat(letters).concat(interval);
6671 * result.subscribe(x => console.log(x));
6673 * @see {@link create}
6674 * @see {@link empty}
6675 * @see {@link never}
6676 * @see {@link throw}
6678 * @param {...T} values Arguments that represent `next` values to be emitted.
6679 * @param {Scheduler} [scheduler] A {@link Scheduler} to use for scheduling
6680 * the emissions of the `next` notifications.
6681 * @return {Observable<T>} An Observable that emits each given input value.
6686 ArrayObservable.of = function () {
6688 for (var _i = 0; _i < arguments.length; _i++) {
6689 array[_i - 0] = arguments[_i];
6691 var scheduler = array[array.length - 1];
6692 if (isScheduler_1.isScheduler(scheduler)) {
6698 var len = array.length;
6700 return new ArrayObservable(array, scheduler);
6702 else if (len === 1) {
6703 return new ScalarObservable_1.ScalarObservable(array[0], scheduler);
6706 return new EmptyObservable_1.EmptyObservable(scheduler);
6709 ArrayObservable.dispatch = function (state) {
6710 var array = state.array, index = state.index, count = state.count, subscriber = state.subscriber;
6711 if (index >= count) {
6712 subscriber.complete();
6715 subscriber.next(array[index]);
6716 if (subscriber.closed) {
6719 state.index = index + 1;
6720 this.schedule(state);
6722 ArrayObservable.prototype._subscribe = function (subscriber) {
6724 var array = this.array;
6725 var count = array.length;
6726 var scheduler = this.scheduler;
6728 return scheduler.schedule(ArrayObservable.dispatch, 0, {
6729 array: array, index: index, count: count, subscriber: subscriber
6733 for (var i = 0; i < count && !subscriber.closed; i++) {
6734 subscriber.next(array[i]);
6736 subscriber.complete();
6739 return ArrayObservable;
6740 }(Observable_1.Observable));
6741 exports.ArrayObservable = ArrayObservable;
6743 },{"../Observable":28,"../util/isScheduler":152,"./EmptyObservable":82,"./ScalarObservable":89}],80:[function(require,module,exports){
6745 var __extends = (this && this.__extends) || function (d, b) {
6746 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
6747 function __() { this.constructor = d; }
6748 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
6750 var Subject_1 = require('../Subject');
6751 var Observable_1 = require('../Observable');
6752 var Subscriber_1 = require('../Subscriber');
6753 var Subscription_1 = require('../Subscription');
6755 * @class ConnectableObservable<T>
6757 var ConnectableObservable = (function (_super) {
6758 __extends(ConnectableObservable, _super);
6759 function ConnectableObservable(source, subjectFactory) {
6761 this.source = source;
6762 this.subjectFactory = subjectFactory;
6765 ConnectableObservable.prototype._subscribe = function (subscriber) {
6766 return this.getSubject().subscribe(subscriber);
6768 ConnectableObservable.prototype.getSubject = function () {
6769 var subject = this._subject;
6770 if (!subject || subject.isStopped) {
6771 this._subject = this.subjectFactory();
6773 return this._subject;
6775 ConnectableObservable.prototype.connect = function () {
6776 var connection = this._connection;
6778 connection = this._connection = new Subscription_1.Subscription();
6779 connection.add(this.source
6780 .subscribe(new ConnectableSubscriber(this.getSubject(), this)));
6781 if (connection.closed) {
6782 this._connection = null;
6783 connection = Subscription_1.Subscription.EMPTY;
6786 this._connection = connection;
6791 ConnectableObservable.prototype.refCount = function () {
6792 return this.lift(new RefCountOperator(this));
6794 return ConnectableObservable;
6795 }(Observable_1.Observable));
6796 exports.ConnectableObservable = ConnectableObservable;
6797 var ConnectableSubscriber = (function (_super) {
6798 __extends(ConnectableSubscriber, _super);
6799 function ConnectableSubscriber(destination, connectable) {
6800 _super.call(this, destination);
6801 this.connectable = connectable;
6803 ConnectableSubscriber.prototype._error = function (err) {
6804 this._unsubscribe();
6805 _super.prototype._error.call(this, err);
6807 ConnectableSubscriber.prototype._complete = function () {
6808 this._unsubscribe();
6809 _super.prototype._complete.call(this);
6811 ConnectableSubscriber.prototype._unsubscribe = function () {
6812 var connectable = this.connectable;
6814 this.connectable = null;
6815 var connection = connectable._connection;
6816 connectable._refCount = 0;
6817 connectable._subject = null;
6818 connectable._connection = null;
6820 connection.unsubscribe();
6824 return ConnectableSubscriber;
6825 }(Subject_1.SubjectSubscriber));
6826 var RefCountOperator = (function () {
6827 function RefCountOperator(connectable) {
6828 this.connectable = connectable;
6830 RefCountOperator.prototype.call = function (subscriber, source) {
6831 var connectable = this.connectable;
6832 connectable._refCount++;
6833 var refCounter = new RefCountSubscriber(subscriber, connectable);
6834 var subscription = source._subscribe(refCounter);
6835 if (!refCounter.closed) {
6836 refCounter.connection = connectable.connect();
6838 return subscription;
6840 return RefCountOperator;
6842 var RefCountSubscriber = (function (_super) {
6843 __extends(RefCountSubscriber, _super);
6844 function RefCountSubscriber(destination, connectable) {
6845 _super.call(this, destination);
6846 this.connectable = connectable;
6848 RefCountSubscriber.prototype._unsubscribe = function () {
6849 var connectable = this.connectable;
6851 this.connection = null;
6854 this.connectable = null;
6855 var refCount = connectable._refCount;
6856 if (refCount <= 0) {
6857 this.connection = null;
6860 connectable._refCount = refCount - 1;
6862 this.connection = null;
6866 // Compare the local RefCountSubscriber's connection Subscription to the
6867 // connection Subscription on the shared ConnectableObservable. In cases
6868 // where the ConnectableObservable source synchronously emits values, and
6869 // the RefCountSubscriber's dowstream Observers synchronously unsubscribe,
6870 // execution continues to here before the RefCountOperator has a chance to
6871 // supply the RefCountSubscriber with the shared connection Subscription.
6874 // Observable.range(0, 10)
6880 // In order to account for this case, RefCountSubscriber should only dispose
6881 // the ConnectableObservable's shared connection Subscription if the
6882 // connection Subscription exists, *and* either:
6883 // a. RefCountSubscriber doesn't have a reference to the shared connection
6884 // Subscription yet, or,
6885 // b. RefCountSubscriber's connection Subscription reference is identical
6886 // to the shared connection Subscription
6888 var connection = this.connection;
6889 var sharedConnection = connectable._connection;
6890 this.connection = null;
6891 if (sharedConnection && (!connection || sharedConnection === connection)) {
6892 sharedConnection.unsubscribe();
6895 return RefCountSubscriber;
6896 }(Subscriber_1.Subscriber));
6898 },{"../Observable":28,"../Subject":33,"../Subscriber":35,"../Subscription":36}],81:[function(require,module,exports){
6900 var __extends = (this && this.__extends) || function (d, b) {
6901 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
6902 function __() { this.constructor = d; }
6903 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
6905 var Observable_1 = require('../Observable');
6906 var subscribeToResult_1 = require('../util/subscribeToResult');
6907 var OuterSubscriber_1 = require('../OuterSubscriber');
6909 * We need this JSDoc comment for affecting ESDoc.
6910 * @extends {Ignored}
6913 var DeferObservable = (function (_super) {
6914 __extends(DeferObservable, _super);
6915 function DeferObservable(observableFactory) {
6917 this.observableFactory = observableFactory;
6920 * Creates an Observable that, on subscribe, calls an Observable factory to
6921 * make an Observable for each new Observer.
6923 * <span class="informal">Creates the Observable lazily, that is, only when it
6927 * <img src="./img/defer.png" width="100%">
6929 * `defer` allows you to create the Observable only when the Observer
6930 * subscribes, and create a fresh Observable for each Observer. It waits until
6931 * an Observer subscribes to it, and then it generates an Observable,
6932 * typically with an Observable factory function. It does this afresh for each
6933 * subscriber, so although each subscriber may think it is subscribing to the
6934 * same Observable, in fact each subscriber gets its own individual
6937 * @example <caption>Subscribe to either an Observable of clicks or an Observable of interval, at random</caption>
6938 * var clicksOrInterval = Rx.Observable.defer(function () {
6939 * if (Math.random() > 0.5) {
6940 * return Rx.Observable.fromEvent(document, 'click');
6942 * return Rx.Observable.interval(1000);
6945 * clicksOrInterval.subscribe(x => console.log(x));
6947 * @see {@link create}
6949 * @param {function(): Observable|Promise} observableFactory The Observable
6950 * factory function to invoke for each Observer that subscribes to the output
6951 * Observable. May also return a Promise, which will be converted on the fly
6953 * @return {Observable} An Observable whose Observers' subscriptions trigger
6954 * an invocation of the given Observable factory function.
6959 DeferObservable.create = function (observableFactory) {
6960 return new DeferObservable(observableFactory);
6962 DeferObservable.prototype._subscribe = function (subscriber) {
6963 return new DeferSubscriber(subscriber, this.observableFactory);
6965 return DeferObservable;
6966 }(Observable_1.Observable));
6967 exports.DeferObservable = DeferObservable;
6968 var DeferSubscriber = (function (_super) {
6969 __extends(DeferSubscriber, _super);
6970 function DeferSubscriber(destination, factory) {
6971 _super.call(this, destination);
6972 this.factory = factory;
6975 DeferSubscriber.prototype.tryDefer = function () {
6977 this._callFactory();
6983 DeferSubscriber.prototype._callFactory = function () {
6984 var result = this.factory();
6986 this.add(subscribeToResult_1.subscribeToResult(this, result));
6989 return DeferSubscriber;
6990 }(OuterSubscriber_1.OuterSubscriber));
6992 },{"../Observable":28,"../OuterSubscriber":30,"../util/subscribeToResult":154}],82:[function(require,module,exports){
6994 var __extends = (this && this.__extends) || function (d, b) {
6995 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
6996 function __() { this.constructor = d; }
6997 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
6999 var Observable_1 = require('../Observable');
7001 * We need this JSDoc comment for affecting ESDoc.
7002 * @extends {Ignored}
7005 var EmptyObservable = (function (_super) {
7006 __extends(EmptyObservable, _super);
7007 function EmptyObservable(scheduler) {
7009 this.scheduler = scheduler;
7012 * Creates an Observable that emits no items to the Observer and immediately
7013 * emits a complete notification.
7015 * <span class="informal">Just emits 'complete', and nothing else.
7018 * <img src="./img/empty.png" width="100%">
7020 * This static operator is useful for creating a simple Observable that only
7021 * emits the complete notification. It can be used for composing with other
7022 * Observables, such as in a {@link mergeMap}.
7024 * @example <caption>Emit the number 7, then complete.</caption>
7025 * var result = Rx.Observable.empty().startWith(7);
7026 * result.subscribe(x => console.log(x));
7028 * @example <caption>Map and flatten only odd numbers to the sequence 'a', 'b', 'c'</caption>
7029 * var interval = Rx.Observable.interval(1000);
7030 * var result = interval.mergeMap(x =>
7031 * x % 2 === 1 ? Rx.Observable.of('a', 'b', 'c') : Rx.Observable.empty()
7033 * result.subscribe(x => console.log(x));
7035 * @see {@link create}
7036 * @see {@link never}
7038 * @see {@link throw}
7040 * @param {Scheduler} [scheduler] A {@link Scheduler} to use for scheduling
7041 * the emission of the complete notification.
7042 * @return {Observable} An "empty" Observable: emits only the complete
7048 EmptyObservable.create = function (scheduler) {
7049 return new EmptyObservable(scheduler);
7051 EmptyObservable.dispatch = function (arg) {
7052 var subscriber = arg.subscriber;
7053 subscriber.complete();
7055 EmptyObservable.prototype._subscribe = function (subscriber) {
7056 var scheduler = this.scheduler;
7058 return scheduler.schedule(EmptyObservable.dispatch, 0, { subscriber: subscriber });
7061 subscriber.complete();
7064 return EmptyObservable;
7065 }(Observable_1.Observable));
7066 exports.EmptyObservable = EmptyObservable;
7068 },{"../Observable":28}],83:[function(require,module,exports){
7070 var __extends = (this && this.__extends) || function (d, b) {
7071 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
7072 function __() { this.constructor = d; }
7073 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
7075 var Observable_1 = require('../Observable');
7077 * We need this JSDoc comment for affecting ESDoc.
7078 * @extends {Ignored}
7081 var ErrorObservable = (function (_super) {
7082 __extends(ErrorObservable, _super);
7083 function ErrorObservable(error, scheduler) {
7086 this.scheduler = scheduler;
7089 * Creates an Observable that emits no items to the Observer and immediately
7090 * emits an error notification.
7092 * <span class="informal">Just emits 'error', and nothing else.
7095 * <img src="./img/throw.png" width="100%">
7097 * This static operator is useful for creating a simple Observable that only
7098 * emits the error notification. It can be used for composing with other
7099 * Observables, such as in a {@link mergeMap}.
7101 * @example <caption>Emit the number 7, then emit an error.</caption>
7102 * var result = Rx.Observable.throw(new Error('oops!')).startWith(7);
7103 * result.subscribe(x => console.log(x), e => console.error(e));
7105 * @example <caption>Map and flattens numbers to the sequence 'a', 'b', 'c', but throw an error for 13</caption>
7106 * var interval = Rx.Observable.interval(1000);
7107 * var result = interval.mergeMap(x =>
7109 * Rx.Observable.throw('Thirteens are bad') :
7110 * Rx.Observable.of('a', 'b', 'c')
7112 * result.subscribe(x => console.log(x), e => console.error(e));
7114 * @see {@link create}
7115 * @see {@link empty}
7116 * @see {@link never}
7119 * @param {any} error The particular Error to pass to the error notification.
7120 * @param {Scheduler} [scheduler] A {@link Scheduler} to use for scheduling
7121 * the emission of the error notification.
7122 * @return {Observable} An error Observable: emits only the error notification
7123 * using the given error argument.
7128 ErrorObservable.create = function (error, scheduler) {
7129 return new ErrorObservable(error, scheduler);
7131 ErrorObservable.dispatch = function (arg) {
7132 var error = arg.error, subscriber = arg.subscriber;
7133 subscriber.error(error);
7135 ErrorObservable.prototype._subscribe = function (subscriber) {
7136 var error = this.error;
7137 var scheduler = this.scheduler;
7139 return scheduler.schedule(ErrorObservable.dispatch, 0, {
7140 error: error, subscriber: subscriber
7144 subscriber.error(error);
7147 return ErrorObservable;
7148 }(Observable_1.Observable));
7149 exports.ErrorObservable = ErrorObservable;
7151 },{"../Observable":28}],84:[function(require,module,exports){
7153 var __extends = (this && this.__extends) || function (d, b) {
7154 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
7155 function __() { this.constructor = d; }
7156 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
7158 var Observable_1 = require('../Observable');
7159 var tryCatch_1 = require('../util/tryCatch');
7160 var isFunction_1 = require('../util/isFunction');
7161 var errorObject_1 = require('../util/errorObject');
7162 var Subscription_1 = require('../Subscription');
7163 function isNodeStyleEventEmmitter(sourceObj) {
7164 return !!sourceObj && typeof sourceObj.addListener === 'function' && typeof sourceObj.removeListener === 'function';
7166 function isJQueryStyleEventEmitter(sourceObj) {
7167 return !!sourceObj && typeof sourceObj.on === 'function' && typeof sourceObj.off === 'function';
7169 function isNodeList(sourceObj) {
7170 return !!sourceObj && sourceObj.toString() === '[object NodeList]';
7172 function isHTMLCollection(sourceObj) {
7173 return !!sourceObj && sourceObj.toString() === '[object HTMLCollection]';
7175 function isEventTarget(sourceObj) {
7176 return !!sourceObj && typeof sourceObj.addEventListener === 'function' && typeof sourceObj.removeEventListener === 'function';
7179 * We need this JSDoc comment for affecting ESDoc.
7180 * @extends {Ignored}
7183 var FromEventObservable = (function (_super) {
7184 __extends(FromEventObservable, _super);
7185 function FromEventObservable(sourceObj, eventName, selector, options) {
7187 this.sourceObj = sourceObj;
7188 this.eventName = eventName;
7189 this.selector = selector;
7190 this.options = options;
7192 /* tslint:enable:max-line-length */
7194 * Creates an Observable that emits events of a specific type coming from the
7195 * given event target.
7197 * <span class="informal">Creates an Observable from DOM events, or Node
7198 * EventEmitter events or others.</span>
7200 * <img src="./img/fromEvent.png" width="100%">
7202 * Creates an Observable by attaching an event listener to an "event target",
7203 * which may be an object with `addEventListener` and `removeEventListener`,
7204 * a Node.js EventEmitter, a jQuery style EventEmitter, a NodeList from the
7205 * DOM, or an HTMLCollection from the DOM. The event handler is attached when
7206 * the output Observable is subscribed, and removed when the Subscription is
7209 * @example <caption>Emits clicks happening on the DOM document</caption>
7210 * var clicks = Rx.Observable.fromEvent(document, 'click');
7211 * clicks.subscribe(x => console.log(x));
7214 * @see {@link fromEventPattern}
7216 * @param {EventTargetLike} target The DOMElement, event target, Node.js
7217 * EventEmitter, NodeList or HTMLCollection to attach the event handler to.
7218 * @param {string} eventName The event name of interest, being emitted by the
7220 * @parm {EventListenerOptions} [options] Options to pass through to addEventListener
7221 * @param {SelectorMethodSignature<T>} [selector] An optional function to
7222 * post-process results. It takes the arguments from the event handler and
7223 * should return a single value.
7224 * @return {Observable<T>}
7229 FromEventObservable.create = function (target, eventName, options, selector) {
7230 if (isFunction_1.isFunction(options)) {
7232 options = undefined;
7234 return new FromEventObservable(target, eventName, selector, options);
7236 FromEventObservable.setupSubscription = function (sourceObj, eventName, handler, subscriber, options) {
7238 if (isNodeList(sourceObj) || isHTMLCollection(sourceObj)) {
7239 for (var i = 0, len = sourceObj.length; i < len; i++) {
7240 FromEventObservable.setupSubscription(sourceObj[i], eventName, handler, subscriber, options);
7243 else if (isEventTarget(sourceObj)) {
7244 var source_1 = sourceObj;
7245 sourceObj.addEventListener(eventName, handler, options);
7246 unsubscribe = function () { return source_1.removeEventListener(eventName, handler); };
7248 else if (isJQueryStyleEventEmitter(sourceObj)) {
7249 var source_2 = sourceObj;
7250 sourceObj.on(eventName, handler);
7251 unsubscribe = function () { return source_2.off(eventName, handler); };
7253 else if (isNodeStyleEventEmmitter(sourceObj)) {
7254 var source_3 = sourceObj;
7255 sourceObj.addListener(eventName, handler);
7256 unsubscribe = function () { return source_3.removeListener(eventName, handler); };
7258 subscriber.add(new Subscription_1.Subscription(unsubscribe));
7260 FromEventObservable.prototype._subscribe = function (subscriber) {
7261 var sourceObj = this.sourceObj;
7262 var eventName = this.eventName;
7263 var options = this.options;
7264 var selector = this.selector;
7265 var handler = selector ? function () {
7267 for (var _i = 0; _i < arguments.length; _i++) {
7268 args[_i - 0] = arguments[_i];
7270 var result = tryCatch_1.tryCatch(selector).apply(void 0, args);
7271 if (result === errorObject_1.errorObject) {
7272 subscriber.error(errorObject_1.errorObject.e);
7275 subscriber.next(result);
7277 } : function (e) { return subscriber.next(e); };
7278 FromEventObservable.setupSubscription(sourceObj, eventName, handler, subscriber, options);
7280 return FromEventObservable;
7281 }(Observable_1.Observable));
7282 exports.FromEventObservable = FromEventObservable;
7284 },{"../Observable":28,"../Subscription":36,"../util/errorObject":147,"../util/isFunction":149,"../util/tryCatch":156}],85:[function(require,module,exports){
7286 var __extends = (this && this.__extends) || function (d, b) {
7287 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
7288 function __() { this.constructor = d; }
7289 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
7291 var isArray_1 = require('../util/isArray');
7292 var isPromise_1 = require('../util/isPromise');
7293 var PromiseObservable_1 = require('./PromiseObservable');
7294 var IteratorObservable_1 = require('./IteratorObservable');
7295 var ArrayObservable_1 = require('./ArrayObservable');
7296 var ArrayLikeObservable_1 = require('./ArrayLikeObservable');
7297 var iterator_1 = require('../symbol/iterator');
7298 var Observable_1 = require('../Observable');
7299 var observeOn_1 = require('../operator/observeOn');
7300 var observable_1 = require('../symbol/observable');
7301 var isArrayLike = (function (x) { return x && typeof x.length === 'number'; });
7303 * We need this JSDoc comment for affecting ESDoc.
7304 * @extends {Ignored}
7307 var FromObservable = (function (_super) {
7308 __extends(FromObservable, _super);
7309 function FromObservable(ish, scheduler) {
7310 _super.call(this, null);
7312 this.scheduler = scheduler;
7315 * Creates an Observable from an Array, an array-like object, a Promise, an
7316 * iterable object, or an Observable-like object.
7318 * <span class="informal">Converts almost anything to an Observable.</span>
7320 * <img src="./img/from.png" width="100%">
7322 * Convert various other objects and data types into Observables. `from`
7323 * converts a Promise or an array-like or an
7324 * [iterable](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#iterable)
7325 * object into an Observable that emits the items in that promise or array or
7326 * iterable. A String, in this context, is treated as an array of characters.
7327 * Observable-like objects (contains a function named with the ES2015 Symbol
7328 * for Observable) can also be converted through this operator.
7330 * @example <caption>Converts an array to an Observable</caption>
7331 * var array = [10, 20, 30];
7332 * var result = Rx.Observable.from(array);
7333 * result.subscribe(x => console.log(x));
7335 * @example <caption>Convert an infinite iterable (from a generator) to an Observable</caption>
7336 * function* generateDoubles(seed) {
7340 * i = 2 * i; // double it
7344 * var iterator = generateDoubles(3);
7345 * var result = Rx.Observable.from(iterator).take(10);
7346 * result.subscribe(x => console.log(x));
7348 * @see {@link create}
7349 * @see {@link fromEvent}
7350 * @see {@link fromEventPattern}
7351 * @see {@link fromPromise}
7353 * @param {ObservableInput<T>} ish A subscribable object, a Promise, an
7354 * Observable-like, an Array, an iterable or an array-like object to be
7356 * @param {Scheduler} [scheduler] The scheduler on which to schedule the
7357 * emissions of values.
7358 * @return {Observable<T>} The Observable whose values are originally from the
7359 * input object that was converted.
7364 FromObservable.create = function (ish, scheduler) {
7366 if (typeof ish[observable_1.$$observable] === 'function') {
7367 if (ish instanceof Observable_1.Observable && !scheduler) {
7370 return new FromObservable(ish, scheduler);
7372 else if (isArray_1.isArray(ish)) {
7373 return new ArrayObservable_1.ArrayObservable(ish, scheduler);
7375 else if (isPromise_1.isPromise(ish)) {
7376 return new PromiseObservable_1.PromiseObservable(ish, scheduler);
7378 else if (typeof ish[iterator_1.$$iterator] === 'function' || typeof ish === 'string') {
7379 return new IteratorObservable_1.IteratorObservable(ish, scheduler);
7381 else if (isArrayLike(ish)) {
7382 return new ArrayLikeObservable_1.ArrayLikeObservable(ish, scheduler);
7385 throw new TypeError((ish !== null && typeof ish || ish) + ' is not observable');
7387 FromObservable.prototype._subscribe = function (subscriber) {
7389 var scheduler = this.scheduler;
7390 if (scheduler == null) {
7391 return ish[observable_1.$$observable]().subscribe(subscriber);
7394 return ish[observable_1.$$observable]().subscribe(new observeOn_1.ObserveOnSubscriber(subscriber, scheduler, 0));
7397 return FromObservable;
7398 }(Observable_1.Observable));
7399 exports.FromObservable = FromObservable;
7401 },{"../Observable":28,"../operator/observeOn":118,"../symbol/iterator":140,"../symbol/observable":141,"../util/isArray":148,"../util/isPromise":151,"./ArrayLikeObservable":78,"./ArrayObservable":79,"./IteratorObservable":86,"./PromiseObservable":88}],86:[function(require,module,exports){
7403 var __extends = (this && this.__extends) || function (d, b) {
7404 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
7405 function __() { this.constructor = d; }
7406 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
7408 var root_1 = require('../util/root');
7409 var Observable_1 = require('../Observable');
7410 var iterator_1 = require('../symbol/iterator');
7412 * We need this JSDoc comment for affecting ESDoc.
7413 * @extends {Ignored}
7416 var IteratorObservable = (function (_super) {
7417 __extends(IteratorObservable, _super);
7418 function IteratorObservable(iterator, scheduler) {
7420 this.scheduler = scheduler;
7421 if (iterator == null) {
7422 throw new Error('iterator cannot be null.');
7424 this.iterator = getIterator(iterator);
7426 IteratorObservable.create = function (iterator, scheduler) {
7427 return new IteratorObservable(iterator, scheduler);
7429 IteratorObservable.dispatch = function (state) {
7430 var index = state.index, hasError = state.hasError, iterator = state.iterator, subscriber = state.subscriber;
7432 subscriber.error(state.error);
7435 var result = iterator.next();
7437 subscriber.complete();
7440 subscriber.next(result.value);
7441 state.index = index + 1;
7442 if (subscriber.closed) {
7445 this.schedule(state);
7447 IteratorObservable.prototype._subscribe = function (subscriber) {
7449 var _a = this, iterator = _a.iterator, scheduler = _a.scheduler;
7451 return scheduler.schedule(IteratorObservable.dispatch, 0, {
7452 index: index, iterator: iterator, subscriber: subscriber
7457 var result = iterator.next();
7459 subscriber.complete();
7463 subscriber.next(result.value);
7465 if (subscriber.closed) {
7471 return IteratorObservable;
7472 }(Observable_1.Observable));
7473 exports.IteratorObservable = IteratorObservable;
7474 var StringIterator = (function () {
7475 function StringIterator(str, idx, len) {
7476 if (idx === void 0) { idx = 0; }
7477 if (len === void 0) { len = str.length; }
7482 StringIterator.prototype[iterator_1.$$iterator] = function () { return (this); };
7483 StringIterator.prototype.next = function () {
7484 return this.idx < this.len ? {
7486 value: this.str.charAt(this.idx++)
7492 return StringIterator;
7494 var ArrayIterator = (function () {
7495 function ArrayIterator(arr, idx, len) {
7496 if (idx === void 0) { idx = 0; }
7497 if (len === void 0) { len = toLength(arr); }
7502 ArrayIterator.prototype[iterator_1.$$iterator] = function () { return this; };
7503 ArrayIterator.prototype.next = function () {
7504 return this.idx < this.len ? {
7506 value: this.arr[this.idx++]
7512 return ArrayIterator;
7514 function getIterator(obj) {
7515 var i = obj[iterator_1.$$iterator];
7516 if (!i && typeof obj === 'string') {
7517 return new StringIterator(obj);
7519 if (!i && obj.length !== undefined) {
7520 return new ArrayIterator(obj);
7523 throw new TypeError('object is not iterable');
7525 return obj[iterator_1.$$iterator]();
7527 var maxSafeInteger = Math.pow(2, 53) - 1;
7528 function toLength(o) {
7529 var len = +o.length;
7533 if (len === 0 || !numberIsFinite(len)) {
7536 len = sign(len) * Math.floor(Math.abs(len));
7540 if (len > maxSafeInteger) {
7541 return maxSafeInteger;
7545 function numberIsFinite(value) {
7546 return typeof value === 'number' && root_1.root.isFinite(value);
7548 function sign(value) {
7549 var valueAsNumber = +value;
7550 if (valueAsNumber === 0) {
7551 return valueAsNumber;
7553 if (isNaN(valueAsNumber)) {
7554 return valueAsNumber;
7556 return valueAsNumber < 0 ? -1 : 1;
7559 },{"../Observable":28,"../symbol/iterator":140,"../util/root":153}],87:[function(require,module,exports){
7561 var __extends = (this && this.__extends) || function (d, b) {
7562 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
7563 function __() { this.constructor = d; }
7564 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
7566 var Observable_1 = require('../Observable');
7567 var ConnectableObservable_1 = require('../observable/ConnectableObservable');
7568 var MulticastObservable = (function (_super) {
7569 __extends(MulticastObservable, _super);
7570 function MulticastObservable(source, subjectFactory, selector) {
7572 this.source = source;
7573 this.subjectFactory = subjectFactory;
7574 this.selector = selector;
7576 MulticastObservable.prototype._subscribe = function (subscriber) {
7577 var _a = this, selector = _a.selector, source = _a.source;
7578 var connectable = new ConnectableObservable_1.ConnectableObservable(source, this.subjectFactory);
7579 var subscription = selector(connectable).subscribe(subscriber);
7580 subscription.add(connectable.connect());
7581 return subscription;
7583 return MulticastObservable;
7584 }(Observable_1.Observable));
7585 exports.MulticastObservable = MulticastObservable;
7587 },{"../Observable":28,"../observable/ConnectableObservable":80}],88:[function(require,module,exports){
7589 var __extends = (this && this.__extends) || function (d, b) {
7590 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
7591 function __() { this.constructor = d; }
7592 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
7594 var root_1 = require('../util/root');
7595 var Observable_1 = require('../Observable');
7597 * We need this JSDoc comment for affecting ESDoc.
7598 * @extends {Ignored}
7601 var PromiseObservable = (function (_super) {
7602 __extends(PromiseObservable, _super);
7603 function PromiseObservable(promise, scheduler) {
7605 this.promise = promise;
7606 this.scheduler = scheduler;
7609 * Converts a Promise to an Observable.
7611 * <span class="informal">Returns an Observable that just emits the Promise's
7612 * resolved value, then completes.</span>
7614 * Converts an ES2015 Promise or a Promises/A+ spec compliant Promise to an
7615 * Observable. If the Promise resolves with a value, the output Observable
7616 * emits that resolved value as a `next`, and then completes. If the Promise
7617 * is rejected, then the output Observable emits the corresponding Error.
7619 * @example <caption>Convert the Promise returned by Fetch to an Observable</caption>
7620 * var result = Rx.Observable.fromPromise(fetch('http://myserver.com/'));
7621 * result.subscribe(x => console.log(x), e => console.error(e));
7623 * @see {@link bindCallback}
7626 * @param {Promise<T>} promise The promise to be converted.
7627 * @param {Scheduler} [scheduler] An optional Scheduler to use for scheduling
7628 * the delivery of the resolved value (or the rejection).
7629 * @return {Observable<T>} An Observable which wraps the Promise.
7634 PromiseObservable.create = function (promise, scheduler) {
7635 return new PromiseObservable(promise, scheduler);
7637 PromiseObservable.prototype._subscribe = function (subscriber) {
7639 var promise = this.promise;
7640 var scheduler = this.scheduler;
7641 if (scheduler == null) {
7642 if (this._isScalar) {
7643 if (!subscriber.closed) {
7644 subscriber.next(this.value);
7645 subscriber.complete();
7649 promise.then(function (value) {
7650 _this.value = value;
7651 _this._isScalar = true;
7652 if (!subscriber.closed) {
7653 subscriber.next(value);
7654 subscriber.complete();
7657 if (!subscriber.closed) {
7658 subscriber.error(err);
7661 .then(null, function (err) {
7662 // escape the promise trap, throw unhandled errors
7663 root_1.root.setTimeout(function () { throw err; });
7668 if (this._isScalar) {
7669 if (!subscriber.closed) {
7670 return scheduler.schedule(dispatchNext, 0, { value: this.value, subscriber: subscriber });
7674 promise.then(function (value) {
7675 _this.value = value;
7676 _this._isScalar = true;
7677 if (!subscriber.closed) {
7678 subscriber.add(scheduler.schedule(dispatchNext, 0, { value: value, subscriber: subscriber }));
7681 if (!subscriber.closed) {
7682 subscriber.add(scheduler.schedule(dispatchError, 0, { err: err, subscriber: subscriber }));
7685 .then(null, function (err) {
7686 // escape the promise trap, throw unhandled errors
7687 root_1.root.setTimeout(function () { throw err; });
7692 return PromiseObservable;
7693 }(Observable_1.Observable));
7694 exports.PromiseObservable = PromiseObservable;
7695 function dispatchNext(arg) {
7696 var value = arg.value, subscriber = arg.subscriber;
7697 if (!subscriber.closed) {
7698 subscriber.next(value);
7699 subscriber.complete();
7702 function dispatchError(arg) {
7703 var err = arg.err, subscriber = arg.subscriber;
7704 if (!subscriber.closed) {
7705 subscriber.error(err);
7709 },{"../Observable":28,"../util/root":153}],89:[function(require,module,exports){
7711 var __extends = (this && this.__extends) || function (d, b) {
7712 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
7713 function __() { this.constructor = d; }
7714 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
7716 var Observable_1 = require('../Observable');
7718 * We need this JSDoc comment for affecting ESDoc.
7719 * @extends {Ignored}
7722 var ScalarObservable = (function (_super) {
7723 __extends(ScalarObservable, _super);
7724 function ScalarObservable(value, scheduler) {
7727 this.scheduler = scheduler;
7728 this._isScalar = true;
7730 this._isScalar = false;
7733 ScalarObservable.create = function (value, scheduler) {
7734 return new ScalarObservable(value, scheduler);
7736 ScalarObservable.dispatch = function (state) {
7737 var done = state.done, value = state.value, subscriber = state.subscriber;
7739 subscriber.complete();
7742 subscriber.next(value);
7743 if (subscriber.closed) {
7747 this.schedule(state);
7749 ScalarObservable.prototype._subscribe = function (subscriber) {
7750 var value = this.value;
7751 var scheduler = this.scheduler;
7753 return scheduler.schedule(ScalarObservable.dispatch, 0, {
7754 done: false, value: value, subscriber: subscriber
7758 subscriber.next(value);
7759 if (!subscriber.closed) {
7760 subscriber.complete();
7764 return ScalarObservable;
7765 }(Observable_1.Observable));
7766 exports.ScalarObservable = ScalarObservable;
7768 },{"../Observable":28}],90:[function(require,module,exports){
7770 var isScheduler_1 = require('../util/isScheduler');
7771 var isArray_1 = require('../util/isArray');
7772 var ArrayObservable_1 = require('./ArrayObservable');
7773 var combineLatest_1 = require('../operator/combineLatest');
7774 /* tslint:enable:max-line-length */
7776 * Combines multiple Observables to create an Observable whose values are
7777 * calculated from the latest values of each of its input Observables.
7779 * <span class="informal">Whenever any input Observable emits a value, it
7780 * computes a formula using the latest values from all the inputs, then emits
7781 * the output of that formula.</span>
7783 * <img src="./img/combineLatest.png" width="100%">
7785 * `combineLatest` combines the values from all the Observables passed as
7786 * arguments. This is done by subscribing to each Observable, in order, and
7787 * collecting an array of each of the most recent values any time any of the
7788 * input Observables emits, then either taking that array and passing it as
7789 * arguments to an optional `project` function and emitting the return value of
7790 * that, or just emitting the array of recent values directly if there is no
7791 * `project` function.
7793 * @example <caption>Dynamically calculate the Body-Mass Index from an Observable of weight and one for height</caption>
7794 * var weight = Rx.Observable.of(70, 72, 76, 79, 75);
7795 * var height = Rx.Observable.of(1.76, 1.77, 1.78);
7796 * var bmi = Rx.Observable.combineLatest(weight, height, (w, h) => w / (h * h));
7797 * bmi.subscribe(x => console.log('BMI is ' + x));
7799 * @see {@link combineAll}
7800 * @see {@link merge}
7801 * @see {@link withLatestFrom}
7803 * @param {Observable} observable1 An input Observable to combine with the
7804 * source Observable.
7805 * @param {Observable} observable2 An input Observable to combine with the
7806 * source Observable. More than one input Observables may be given as argument.
7807 * @param {function} [project] An optional function to project the values from
7808 * the combined latest values into a new value on the output Observable.
7809 * @param {Scheduler} [scheduler=null] The Scheduler to use for subscribing to
7810 * each input Observable.
7811 * @return {Observable} An Observable of projected values from the most recent
7812 * values from each input Observable, or an array of the most recent values from
7813 * each input Observable.
7815 * @name combineLatest
7818 function combineLatest() {
7819 var observables = [];
7820 for (var _i = 0; _i < arguments.length; _i++) {
7821 observables[_i - 0] = arguments[_i];
7824 var scheduler = null;
7825 if (isScheduler_1.isScheduler(observables[observables.length - 1])) {
7826 scheduler = observables.pop();
7828 if (typeof observables[observables.length - 1] === 'function') {
7829 project = observables.pop();
7831 // if the first and only other argument besides the resultSelector is an array
7832 // assume it's been called with `combineLatest([obs1, obs2, obs3], project)`
7833 if (observables.length === 1 && isArray_1.isArray(observables[0])) {
7834 observables = observables[0];
7836 return new ArrayObservable_1.ArrayObservable(observables, scheduler).lift(new combineLatest_1.CombineLatestOperator(project));
7838 exports.combineLatest = combineLatest;
7840 },{"../operator/combineLatest":102,"../util/isArray":148,"../util/isScheduler":152,"./ArrayObservable":79}],91:[function(require,module,exports){
7842 var DeferObservable_1 = require('./DeferObservable');
7843 exports.defer = DeferObservable_1.DeferObservable.create;
7845 },{"./DeferObservable":81}],92:[function(require,module,exports){
7847 var EmptyObservable_1 = require('./EmptyObservable');
7848 exports.empty = EmptyObservable_1.EmptyObservable.create;
7850 },{"./EmptyObservable":82}],93:[function(require,module,exports){
7852 var FromObservable_1 = require('./FromObservable');
7853 exports.from = FromObservable_1.FromObservable.create;
7855 },{"./FromObservable":85}],94:[function(require,module,exports){
7857 var FromEventObservable_1 = require('./FromEventObservable');
7858 exports.fromEvent = FromEventObservable_1.FromEventObservable.create;
7860 },{"./FromEventObservable":84}],95:[function(require,module,exports){
7862 var PromiseObservable_1 = require('./PromiseObservable');
7863 exports.fromPromise = PromiseObservable_1.PromiseObservable.create;
7865 },{"./PromiseObservable":88}],96:[function(require,module,exports){
7867 var merge_1 = require('../operator/merge');
7868 exports.merge = merge_1.mergeStatic;
7870 },{"../operator/merge":114}],97:[function(require,module,exports){
7872 var ArrayObservable_1 = require('./ArrayObservable');
7873 exports.of = ArrayObservable_1.ArrayObservable.of;
7875 },{"./ArrayObservable":79}],98:[function(require,module,exports){
7877 var ErrorObservable_1 = require('./ErrorObservable');
7878 exports._throw = ErrorObservable_1.ErrorObservable.create;
7880 },{"./ErrorObservable":83}],99:[function(require,module,exports){
7882 var zip_1 = require('../operator/zip');
7883 exports.zip = zip_1.zipStatic;
7885 },{"../operator/zip":132}],100:[function(require,module,exports){
7887 var __extends = (this && this.__extends) || function (d, b) {
7888 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
7889 function __() { this.constructor = d; }
7890 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
7892 var OuterSubscriber_1 = require('../OuterSubscriber');
7893 var subscribeToResult_1 = require('../util/subscribeToResult');
7895 * Buffers the source Observable values until `closingNotifier` emits.
7897 * <span class="informal">Collects values from the past as an array, and emits
7898 * that array only when another Observable emits.</span>
7900 * <img src="./img/buffer.png" width="100%">
7902 * Buffers the incoming Observable values until the given `closingNotifier`
7903 * Observable emits a value, at which point it emits the buffer on the output
7904 * Observable and starts a new buffer internally, awaiting the next time
7905 * `closingNotifier` emits.
7907 * @example <caption>On every click, emit array of most recent interval events</caption>
7908 * var clicks = Rx.Observable.fromEvent(document, 'click');
7909 * var interval = Rx.Observable.interval(1000);
7910 * var buffered = interval.buffer(clicks);
7911 * buffered.subscribe(x => console.log(x));
7913 * @see {@link bufferCount}
7914 * @see {@link bufferTime}
7915 * @see {@link bufferToggle}
7916 * @see {@link bufferWhen}
7917 * @see {@link window}
7919 * @param {Observable<any>} closingNotifier An Observable that signals the
7920 * buffer to be emitted on the output Observable.
7921 * @return {Observable<T[]>} An Observable of buffers, which are arrays of
7926 function buffer(closingNotifier) {
7927 return this.lift(new BufferOperator(closingNotifier));
7929 exports.buffer = buffer;
7930 var BufferOperator = (function () {
7931 function BufferOperator(closingNotifier) {
7932 this.closingNotifier = closingNotifier;
7934 BufferOperator.prototype.call = function (subscriber, source) {
7935 return source._subscribe(new BufferSubscriber(subscriber, this.closingNotifier));
7937 return BufferOperator;
7940 * We need this JSDoc comment for affecting ESDoc.
7942 * @extends {Ignored}
7944 var BufferSubscriber = (function (_super) {
7945 __extends(BufferSubscriber, _super);
7946 function BufferSubscriber(destination, closingNotifier) {
7947 _super.call(this, destination);
7949 this.add(subscribeToResult_1.subscribeToResult(this, closingNotifier));
7951 BufferSubscriber.prototype._next = function (value) {
7952 this.buffer.push(value);
7954 BufferSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
7955 var buffer = this.buffer;
7957 this.destination.next(buffer);
7959 return BufferSubscriber;
7960 }(OuterSubscriber_1.OuterSubscriber));
7962 },{"../OuterSubscriber":30,"../util/subscribeToResult":154}],101:[function(require,module,exports){
7964 var __extends = (this && this.__extends) || function (d, b) {
7965 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
7966 function __() { this.constructor = d; }
7967 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
7969 var OuterSubscriber_1 = require('../OuterSubscriber');
7970 var subscribeToResult_1 = require('../util/subscribeToResult');
7972 * Catches errors on the observable to be handled by returning a new observable or throwing an error.
7973 * @param {function} selector a function that takes as arguments `err`, which is the error, and `caught`, which
7974 * is the source observable, in case you'd like to "retry" that observable by returning it again. Whatever observable
7975 * is returned by the `selector` will be used to continue the observable chain.
7976 * @return {Observable} an observable that originates from either the source or the observable returned by the
7977 * catch `selector` function.
7981 function _catch(selector) {
7982 var operator = new CatchOperator(selector);
7983 var caught = this.lift(operator);
7984 return (operator.caught = caught);
7986 exports._catch = _catch;
7987 var CatchOperator = (function () {
7988 function CatchOperator(selector) {
7989 this.selector = selector;
7991 CatchOperator.prototype.call = function (subscriber, source) {
7992 return source._subscribe(new CatchSubscriber(subscriber, this.selector, this.caught));
7994 return CatchOperator;
7997 * We need this JSDoc comment for affecting ESDoc.
7999 * @extends {Ignored}
8001 var CatchSubscriber = (function (_super) {
8002 __extends(CatchSubscriber, _super);
8003 function CatchSubscriber(destination, selector, caught) {
8004 _super.call(this, destination);
8005 this.selector = selector;
8006 this.caught = caught;
8008 // NOTE: overriding `error` instead of `_error` because we don't want
8009 // to have this flag this subscriber as `isStopped`.
8010 CatchSubscriber.prototype.error = function (err) {
8011 if (!this.isStopped) {
8012 var result = void 0;
8014 result = this.selector(err, this.caught);
8017 this.destination.error(err);
8021 this.destination.remove(this);
8022 subscribeToResult_1.subscribeToResult(this, result);
8025 return CatchSubscriber;
8026 }(OuterSubscriber_1.OuterSubscriber));
8028 },{"../OuterSubscriber":30,"../util/subscribeToResult":154}],102:[function(require,module,exports){
8030 var __extends = (this && this.__extends) || function (d, b) {
8031 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
8032 function __() { this.constructor = d; }
8033 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
8035 var ArrayObservable_1 = require('../observable/ArrayObservable');
8036 var isArray_1 = require('../util/isArray');
8037 var OuterSubscriber_1 = require('../OuterSubscriber');
8038 var subscribeToResult_1 = require('../util/subscribeToResult');
8041 * Combines multiple Observables to create an Observable whose values are
8042 * calculated from the latest values of each of its input Observables.
8044 * <span class="informal">Whenever any input Observable emits a value, it
8045 * computes a formula using the latest values from all the inputs, then emits
8046 * the output of that formula.</span>
8048 * <img src="./img/combineLatest.png" width="100%">
8050 * `combineLatest` combines the values from this Observable with values from
8051 * Observables passed as arguments. This is done by subscribing to each
8052 * Observable, in order, and collecting an array of each of the most recent
8053 * values any time any of the input Observables emits, then either taking that
8054 * array and passing it as arguments to an optional `project` function and
8055 * emitting the return value of that, or just emitting the array of recent
8056 * values directly if there is no `project` function.
8058 * @example <caption>Dynamically calculate the Body-Mass Index from an Observable of weight and one for height</caption>
8059 * var weight = Rx.Observable.of(70, 72, 76, 79, 75);
8060 * var height = Rx.Observable.of(1.76, 1.77, 1.78);
8061 * var bmi = weight.combineLatest(height, (w, h) => w / (h * h));
8062 * bmi.subscribe(x => console.log('BMI is ' + x));
8064 * @see {@link combineAll}
8065 * @see {@link merge}
8066 * @see {@link withLatestFrom}
8068 * @param {Observable} other An input Observable to combine with the source
8069 * Observable. More than one input Observables may be given as argument.
8070 * @param {function} [project] An optional function to project the values from
8071 * the combined latest values into a new value on the output Observable.
8072 * @return {Observable} An Observable of projected values from the most recent
8073 * values from each input Observable, or an array of the most recent values from
8074 * each input Observable.
8075 * @method combineLatest
8078 function combineLatest() {
8079 var observables = [];
8080 for (var _i = 0; _i < arguments.length; _i++) {
8081 observables[_i - 0] = arguments[_i];
8084 if (typeof observables[observables.length - 1] === 'function') {
8085 project = observables.pop();
8087 // if the first and only other argument besides the resultSelector is an array
8088 // assume it's been called with `combineLatest([obs1, obs2, obs3], project)`
8089 if (observables.length === 1 && isArray_1.isArray(observables[0])) {
8090 observables = observables[0];
8092 observables.unshift(this);
8093 return new ArrayObservable_1.ArrayObservable(observables).lift(new CombineLatestOperator(project));
8095 exports.combineLatest = combineLatest;
8096 /* tslint:enable:max-line-length */
8097 var CombineLatestOperator = (function () {
8098 function CombineLatestOperator(project) {
8099 this.project = project;
8101 CombineLatestOperator.prototype.call = function (subscriber, source) {
8102 return source._subscribe(new CombineLatestSubscriber(subscriber, this.project));
8104 return CombineLatestOperator;
8106 exports.CombineLatestOperator = CombineLatestOperator;
8108 * We need this JSDoc comment for affecting ESDoc.
8110 * @extends {Ignored}
8112 var CombineLatestSubscriber = (function (_super) {
8113 __extends(CombineLatestSubscriber, _super);
8114 function CombineLatestSubscriber(destination, project) {
8115 _super.call(this, destination);
8116 this.project = project;
8119 this.observables = [];
8121 CombineLatestSubscriber.prototype._next = function (observable) {
8122 this.values.push(none);
8123 this.observables.push(observable);
8125 CombineLatestSubscriber.prototype._complete = function () {
8126 var observables = this.observables;
8127 var len = observables.length;
8129 this.destination.complete();
8133 this.toRespond = len;
8134 for (var i = 0; i < len; i++) {
8135 var observable = observables[i];
8136 this.add(subscribeToResult_1.subscribeToResult(this, observable, observable, i));
8140 CombineLatestSubscriber.prototype.notifyComplete = function (unused) {
8141 if ((this.active -= 1) === 0) {
8142 this.destination.complete();
8145 CombineLatestSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
8146 var values = this.values;
8147 var oldVal = values[outerIndex];
8148 var toRespond = !this.toRespond
8150 : oldVal === none ? --this.toRespond : this.toRespond;
8151 values[outerIndex] = innerValue;
8152 if (toRespond === 0) {
8154 this._tryProject(values);
8157 this.destination.next(values.slice());
8161 CombineLatestSubscriber.prototype._tryProject = function (values) {
8164 result = this.project.apply(this, values);
8167 this.destination.error(err);
8170 this.destination.next(result);
8172 return CombineLatestSubscriber;
8173 }(OuterSubscriber_1.OuterSubscriber));
8174 exports.CombineLatestSubscriber = CombineLatestSubscriber;
8176 },{"../OuterSubscriber":30,"../observable/ArrayObservable":79,"../util/isArray":148,"../util/subscribeToResult":154}],103:[function(require,module,exports){
8178 var isScheduler_1 = require('../util/isScheduler');
8179 var ArrayObservable_1 = require('../observable/ArrayObservable');
8180 var mergeAll_1 = require('./mergeAll');
8182 * Creates an output Observable which sequentially emits all values from every
8183 * given input Observable after the current Observable.
8185 * <span class="informal">Concatenates multiple Observables together by
8186 * sequentially emitting their values, one Observable after the other.</span>
8188 * <img src="./img/concat.png" width="100%">
8190 * Joins this Observable with multiple other Observables by subscribing to them
8191 * one at a time, starting with the source, and merging their results into the
8192 * output Observable. Will wait for each Observable to complete before moving
8195 * @example <caption>Concatenate a timer counting from 0 to 3 with a synchronous sequence from 1 to 10</caption>
8196 * var timer = Rx.Observable.interval(1000).take(4);
8197 * var sequence = Rx.Observable.range(1, 10);
8198 * var result = timer.concat(sequence);
8199 * result.subscribe(x => console.log(x));
8201 * @example <caption>Concatenate 3 Observables</caption>
8202 * var timer1 = Rx.Observable.interval(1000).take(10);
8203 * var timer2 = Rx.Observable.interval(2000).take(6);
8204 * var timer3 = Rx.Observable.interval(500).take(10);
8205 * var result = timer1.concat(timer2, timer3);
8206 * result.subscribe(x => console.log(x));
8208 * @see {@link concatAll}
8209 * @see {@link concatMap}
8210 * @see {@link concatMapTo}
8212 * @param {Observable} other An input Observable to concatenate after the source
8213 * Observable. More than one input Observables may be given as argument.
8214 * @param {Scheduler} [scheduler=null] An optional Scheduler to schedule each
8215 * Observable subscription on.
8216 * @return {Observable} All values of each passed Observable merged into a
8217 * single Observable, in order, in serial fashion.
8222 var observables = [];
8223 for (var _i = 0; _i < arguments.length; _i++) {
8224 observables[_i - 0] = arguments[_i];
8226 return concatStatic.apply(void 0, [this].concat(observables));
8228 exports.concat = concat;
8229 /* tslint:enable:max-line-length */
8231 * Creates an output Observable which sequentially emits all values from every
8232 * given input Observable after the current Observable.
8234 * <span class="informal">Concatenates multiple Observables together by
8235 * sequentially emitting their values, one Observable after the other.</span>
8237 * <img src="./img/concat.png" width="100%">
8239 * Joins multiple Observables together by subscribing to them one at a time and
8240 * merging their results into the output Observable. Will wait for each
8241 * Observable to complete before moving on to the next.
8243 * @example <caption>Concatenate a timer counting from 0 to 3 with a synchronous sequence from 1 to 10</caption>
8244 * var timer = Rx.Observable.interval(1000).take(4);
8245 * var sequence = Rx.Observable.range(1, 10);
8246 * var result = Rx.Observable.concat(timer, sequence);
8247 * result.subscribe(x => console.log(x));
8249 * @example <caption>Concatenate 3 Observables</caption>
8250 * var timer1 = Rx.Observable.interval(1000).take(10);
8251 * var timer2 = Rx.Observable.interval(2000).take(6);
8252 * var timer3 = Rx.Observable.interval(500).take(10);
8253 * var result = Rx.Observable.concat(timer1, timer2, timer3);
8254 * result.subscribe(x => console.log(x));
8256 * @see {@link concatAll}
8257 * @see {@link concatMap}
8258 * @see {@link concatMapTo}
8260 * @param {Observable} input1 An input Observable to concatenate with others.
8261 * @param {Observable} input2 An input Observable to concatenate with others.
8262 * More than one input Observables may be given as argument.
8263 * @param {Scheduler} [scheduler=null] An optional Scheduler to schedule each
8264 * Observable subscription on.
8265 * @return {Observable} All values of each passed Observable merged into a
8266 * single Observable, in order, in serial fashion.
8271 function concatStatic() {
8272 var observables = [];
8273 for (var _i = 0; _i < arguments.length; _i++) {
8274 observables[_i - 0] = arguments[_i];
8276 var scheduler = null;
8277 var args = observables;
8278 if (isScheduler_1.isScheduler(args[observables.length - 1])) {
8279 scheduler = args.pop();
8281 return new ArrayObservable_1.ArrayObservable(observables, scheduler).lift(new mergeAll_1.MergeAllOperator(1));
8283 exports.concatStatic = concatStatic;
8285 },{"../observable/ArrayObservable":79,"../util/isScheduler":152,"./mergeAll":115}],104:[function(require,module,exports){
8287 var __extends = (this && this.__extends) || function (d, b) {
8288 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
8289 function __() { this.constructor = d; }
8290 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
8292 var Subscriber_1 = require('../Subscriber');
8293 var async_1 = require('../scheduler/async');
8295 * Emits a value from the source Observable only after a particular time span
8296 * has passed without another source emission.
8298 * <span class="informal">It's like {@link delay}, but passes only the most
8299 * recent value from each burst of emissions.</span>
8301 * <img src="./img/debounceTime.png" width="100%">
8303 * `debounceTime` delays values emitted by the source Observable, but drops
8304 * previous pending delayed emissions if a new value arrives on the source
8305 * Observable. This operator keeps track of the most recent value from the
8306 * source Observable, and emits that only when `dueTime` enough time has passed
8307 * without any other value appearing on the source Observable. If a new value
8308 * appears before `dueTime` silence occurs, the previous value will be dropped
8309 * and will not be emitted on the output Observable.
8311 * This is a rate-limiting operator, because it is impossible for more than one
8312 * value to be emitted in any time window of duration `dueTime`, but it is also
8313 * a delay-like operator since output emissions do not occur at the same time as
8314 * they did on the source Observable. Optionally takes a {@link Scheduler} for
8317 * @example <caption>Emit the most recent click after a burst of clicks</caption>
8318 * var clicks = Rx.Observable.fromEvent(document, 'click');
8319 * var result = clicks.debounceTime(1000);
8320 * result.subscribe(x => console.log(x));
8322 * @see {@link auditTime}
8323 * @see {@link debounce}
8324 * @see {@link delay}
8325 * @see {@link sampleTime}
8326 * @see {@link throttleTime}
8328 * @param {number} dueTime The timeout duration in milliseconds (or the time
8329 * unit determined internally by the optional `scheduler`) for the window of
8330 * time required to wait for emission silence before emitting the most recent
8332 * @param {Scheduler} [scheduler=async] The {@link Scheduler} to use for
8333 * managing the timers that handle the timeout for each value.
8334 * @return {Observable} An Observable that delays the emissions of the source
8335 * Observable by the specified `dueTime`, and may drop some values if they occur
8337 * @method debounceTime
8340 function debounceTime(dueTime, scheduler) {
8341 if (scheduler === void 0) { scheduler = async_1.async; }
8342 return this.lift(new DebounceTimeOperator(dueTime, scheduler));
8344 exports.debounceTime = debounceTime;
8345 var DebounceTimeOperator = (function () {
8346 function DebounceTimeOperator(dueTime, scheduler) {
8347 this.dueTime = dueTime;
8348 this.scheduler = scheduler;
8350 DebounceTimeOperator.prototype.call = function (subscriber, source) {
8351 return source._subscribe(new DebounceTimeSubscriber(subscriber, this.dueTime, this.scheduler));
8353 return DebounceTimeOperator;
8356 * We need this JSDoc comment for affecting ESDoc.
8358 * @extends {Ignored}
8360 var DebounceTimeSubscriber = (function (_super) {
8361 __extends(DebounceTimeSubscriber, _super);
8362 function DebounceTimeSubscriber(destination, dueTime, scheduler) {
8363 _super.call(this, destination);
8364 this.dueTime = dueTime;
8365 this.scheduler = scheduler;
8366 this.debouncedSubscription = null;
8367 this.lastValue = null;
8368 this.hasValue = false;
8370 DebounceTimeSubscriber.prototype._next = function (value) {
8371 this.clearDebounce();
8372 this.lastValue = value;
8373 this.hasValue = true;
8374 this.add(this.debouncedSubscription = this.scheduler.schedule(dispatchNext, this.dueTime, this));
8376 DebounceTimeSubscriber.prototype._complete = function () {
8377 this.debouncedNext();
8378 this.destination.complete();
8380 DebounceTimeSubscriber.prototype.debouncedNext = function () {
8381 this.clearDebounce();
8382 if (this.hasValue) {
8383 this.destination.next(this.lastValue);
8384 this.lastValue = null;
8385 this.hasValue = false;
8388 DebounceTimeSubscriber.prototype.clearDebounce = function () {
8389 var debouncedSubscription = this.debouncedSubscription;
8390 if (debouncedSubscription !== null) {
8391 this.remove(debouncedSubscription);
8392 debouncedSubscription.unsubscribe();
8393 this.debouncedSubscription = null;
8396 return DebounceTimeSubscriber;
8397 }(Subscriber_1.Subscriber));
8398 function dispatchNext(subscriber) {
8399 subscriber.debouncedNext();
8402 },{"../Subscriber":35,"../scheduler/async":138}],105:[function(require,module,exports){
8404 var __extends = (this && this.__extends) || function (d, b) {
8405 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
8406 function __() { this.constructor = d; }
8407 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
8409 var OuterSubscriber_1 = require('../OuterSubscriber');
8410 var subscribeToResult_1 = require('../util/subscribeToResult');
8412 * Returns an Observable that emits all items emitted by the source Observable that are distinct by comparison from previous items.
8413 * If a comparator function is provided, then it will be called for each item to test for whether or not that value should be emitted.
8414 * If a comparator function is not provided, an equality check is used by default.
8415 * As the internal HashSet of this operator grows larger and larger, care should be taken in the domain of inputs this operator may see.
8416 * An optional parameter is also provided such that an Observable can be provided to queue the internal HashSet to flush the values it holds.
8417 * @param {function} [compare] optional comparison function called to test if an item is distinct from previous items in the source.
8418 * @param {Observable} [flushes] optional Observable for flushing the internal HashSet of the operator.
8419 * @return {Observable} an Observable that emits items from the source Observable with distinct values.
8423 function distinct(compare, flushes) {
8424 return this.lift(new DistinctOperator(compare, flushes));
8426 exports.distinct = distinct;
8427 var DistinctOperator = (function () {
8428 function DistinctOperator(compare, flushes) {
8429 this.compare = compare;
8430 this.flushes = flushes;
8432 DistinctOperator.prototype.call = function (subscriber, source) {
8433 return source._subscribe(new DistinctSubscriber(subscriber, this.compare, this.flushes));
8435 return DistinctOperator;
8438 * We need this JSDoc comment for affecting ESDoc.
8440 * @extends {Ignored}
8442 var DistinctSubscriber = (function (_super) {
8443 __extends(DistinctSubscriber, _super);
8444 function DistinctSubscriber(destination, compare, flushes) {
8445 _super.call(this, destination);
8447 if (typeof compare === 'function') {
8448 this.compare = compare;
8451 this.add(subscribeToResult_1.subscribeToResult(this, flushes));
8454 DistinctSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
8455 this.values.length = 0;
8457 DistinctSubscriber.prototype.notifyError = function (error, innerSub) {
8460 DistinctSubscriber.prototype._next = function (value) {
8462 var values = this.values;
8463 var len = values.length;
8465 for (var i = 0; i < len; i++) {
8466 if (this.compare(values[i], value)) {
8473 this.destination.error(err);
8476 this.values.push(value);
8477 this.destination.next(value);
8479 DistinctSubscriber.prototype.compare = function (x, y) {
8482 return DistinctSubscriber;
8483 }(OuterSubscriber_1.OuterSubscriber));
8484 exports.DistinctSubscriber = DistinctSubscriber;
8486 },{"../OuterSubscriber":30,"../util/subscribeToResult":154}],106:[function(require,module,exports){
8488 var __extends = (this && this.__extends) || function (d, b) {
8489 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
8490 function __() { this.constructor = d; }
8491 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
8493 var Subscriber_1 = require('../Subscriber');
8494 var tryCatch_1 = require('../util/tryCatch');
8495 var errorObject_1 = require('../util/errorObject');
8497 * Returns an Observable that emits all items emitted by the source Observable that are distinct by comparison from the previous item.
8498 * If a comparator function is provided, then it will be called for each item to test for whether or not that value should be emitted.
8499 * If a comparator function is not provided, an equality check is used by default.
8500 * @param {function} [compare] optional comparison function called to test if an item is distinct from the previous item in the source.
8501 * @return {Observable} an Observable that emits items from the source Observable with distinct values.
8502 * @method distinctUntilChanged
8505 function distinctUntilChanged(compare, keySelector) {
8506 return this.lift(new DistinctUntilChangedOperator(compare, keySelector));
8508 exports.distinctUntilChanged = distinctUntilChanged;
8509 var DistinctUntilChangedOperator = (function () {
8510 function DistinctUntilChangedOperator(compare, keySelector) {
8511 this.compare = compare;
8512 this.keySelector = keySelector;
8514 DistinctUntilChangedOperator.prototype.call = function (subscriber, source) {
8515 return source._subscribe(new DistinctUntilChangedSubscriber(subscriber, this.compare, this.keySelector));
8517 return DistinctUntilChangedOperator;
8520 * We need this JSDoc comment for affecting ESDoc.
8522 * @extends {Ignored}
8524 var DistinctUntilChangedSubscriber = (function (_super) {
8525 __extends(DistinctUntilChangedSubscriber, _super);
8526 function DistinctUntilChangedSubscriber(destination, compare, keySelector) {
8527 _super.call(this, destination);
8528 this.keySelector = keySelector;
8529 this.hasKey = false;
8530 if (typeof compare === 'function') {
8531 this.compare = compare;
8534 DistinctUntilChangedSubscriber.prototype.compare = function (x, y) {
8537 DistinctUntilChangedSubscriber.prototype._next = function (value) {
8538 var keySelector = this.keySelector;
8541 key = tryCatch_1.tryCatch(this.keySelector)(value);
8542 if (key === errorObject_1.errorObject) {
8543 return this.destination.error(errorObject_1.errorObject.e);
8548 result = tryCatch_1.tryCatch(this.compare)(this.key, key);
8549 if (result === errorObject_1.errorObject) {
8550 return this.destination.error(errorObject_1.errorObject.e);
8556 if (Boolean(result) === false) {
8558 this.destination.next(value);
8561 return DistinctUntilChangedSubscriber;
8562 }(Subscriber_1.Subscriber));
8564 },{"../Subscriber":35,"../util/errorObject":147,"../util/tryCatch":156}],107:[function(require,module,exports){
8566 var __extends = (this && this.__extends) || function (d, b) {
8567 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
8568 function __() { this.constructor = d; }
8569 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
8571 var Subscriber_1 = require('../Subscriber');
8573 * Perform a side effect for every emission on the source Observable, but return
8574 * an Observable that is identical to the source.
8576 * <span class="informal">Intercepts each emission on the source and runs a
8577 * function, but returns an output which is identical to the source.</span>
8579 * <img src="./img/do.png" width="100%">
8581 * Returns a mirrored Observable of the source Observable, but modified so that
8582 * the provided Observer is called to perform a side effect for every value,
8583 * error, and completion emitted by the source. Any errors that are thrown in
8584 * the aforementioned Observer or handlers are safely sent down the error path
8585 * of the output Observable.
8587 * This operator is useful for debugging your Observables for the correct values
8588 * or performing other side effects.
8590 * Note: this is different to a `subscribe` on the Observable. If the Observable
8591 * returned by `do` is not subscribed, the side effects specified by the
8592 * Observer will never happen. `do` therefore simply spies on existing
8593 * execution, it does not trigger an execution to happen like `subscribe` does.
8595 * @example <caption>Map every every click to the clientX position of that click, while also logging the click event</caption>
8596 * var clicks = Rx.Observable.fromEvent(document, 'click');
8597 * var positions = clicks
8598 * .do(ev => console.log(ev))
8599 * .map(ev => ev.clientX);
8600 * positions.subscribe(x => console.log(x));
8603 * @see {@link subscribe}
8605 * @param {Observer|function} [nextOrObserver] A normal Observer object or a
8606 * callback for `next`.
8607 * @param {function} [error] Callback for errors in the source.
8608 * @param {function} [complete] Callback for the completion of the source.
8609 * @return {Observable} An Observable identical to the source, but runs the
8610 * specified Observer or callback(s) for each item.
8615 function _do(nextOrObserver, error, complete) {
8616 return this.lift(new DoOperator(nextOrObserver, error, complete));
8619 var DoOperator = (function () {
8620 function DoOperator(nextOrObserver, error, complete) {
8621 this.nextOrObserver = nextOrObserver;
8623 this.complete = complete;
8625 DoOperator.prototype.call = function (subscriber, source) {
8626 return source._subscribe(new DoSubscriber(subscriber, this.nextOrObserver, this.error, this.complete));
8631 * We need this JSDoc comment for affecting ESDoc.
8633 * @extends {Ignored}
8635 var DoSubscriber = (function (_super) {
8636 __extends(DoSubscriber, _super);
8637 function DoSubscriber(destination, nextOrObserver, error, complete) {
8638 _super.call(this, destination);
8639 var safeSubscriber = new Subscriber_1.Subscriber(nextOrObserver, error, complete);
8640 safeSubscriber.syncErrorThrowable = true;
8641 this.add(safeSubscriber);
8642 this.safeSubscriber = safeSubscriber;
8644 DoSubscriber.prototype._next = function (value) {
8645 var safeSubscriber = this.safeSubscriber;
8646 safeSubscriber.next(value);
8647 if (safeSubscriber.syncErrorThrown) {
8648 this.destination.error(safeSubscriber.syncErrorValue);
8651 this.destination.next(value);
8654 DoSubscriber.prototype._error = function (err) {
8655 var safeSubscriber = this.safeSubscriber;
8656 safeSubscriber.error(err);
8657 if (safeSubscriber.syncErrorThrown) {
8658 this.destination.error(safeSubscriber.syncErrorValue);
8661 this.destination.error(err);
8664 DoSubscriber.prototype._complete = function () {
8665 var safeSubscriber = this.safeSubscriber;
8666 safeSubscriber.complete();
8667 if (safeSubscriber.syncErrorThrown) {
8668 this.destination.error(safeSubscriber.syncErrorValue);
8671 this.destination.complete();
8674 return DoSubscriber;
8675 }(Subscriber_1.Subscriber));
8677 },{"../Subscriber":35}],108:[function(require,module,exports){
8679 var __extends = (this && this.__extends) || function (d, b) {
8680 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
8681 function __() { this.constructor = d; }
8682 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
8684 var tryCatch_1 = require('../util/tryCatch');
8685 var errorObject_1 = require('../util/errorObject');
8686 var OuterSubscriber_1 = require('../OuterSubscriber');
8687 var subscribeToResult_1 = require('../util/subscribeToResult');
8689 * Recursively projects each source value to an Observable which is merged in
8690 * the output Observable.
8692 * <span class="informal">It's similar to {@link mergeMap}, but applies the
8693 * projection function to every source value as well as every output value.
8694 * It's recursive.</span>
8696 * <img src="./img/expand.png" width="100%">
8698 * Returns an Observable that emits items based on applying a function that you
8699 * supply to each item emitted by the source Observable, where that function
8700 * returns an Observable, and then merging those resulting Observables and
8701 * emitting the results of this merger. *Expand* will re-emit on the output
8702 * Observable every source value. Then, each output value is given to the
8703 * `project` function which returns an inner Observable to be merged on the
8704 * output Observable. Those output values resulting from the projection are also
8705 * given to the `project` function to produce new output values. This is how
8706 * *expand* behaves recursively.
8708 * @example <caption>Start emitting the powers of two on every click, at most 10 of them</caption>
8709 * var clicks = Rx.Observable.fromEvent(document, 'click');
8710 * var powersOfTwo = clicks
8712 * .expand(x => Rx.Observable.of(2 * x).delay(1000))
8714 * powersOfTwo.subscribe(x => console.log(x));
8716 * @see {@link mergeMap}
8717 * @see {@link mergeScan}
8719 * @param {function(value: T, index: number) => Observable} project A function
8720 * that, when applied to an item emitted by the source or the output Observable,
8721 * returns an Observable.
8722 * @param {number} [concurrent=Number.POSITIVE_INFINITY] Maximum number of input
8723 * Observables being subscribed to concurrently.
8724 * @param {Scheduler} [scheduler=null] The Scheduler to use for subscribing to
8725 * each projected inner Observable.
8726 * @return {Observable} An Observable that emits the source values and also
8727 * result of applying the projection function to each value emitted on the
8728 * output Observable and and merging the results of the Observables obtained
8729 * from this transformation.
8733 function expand(project, concurrent, scheduler) {
8734 if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
8735 if (scheduler === void 0) { scheduler = undefined; }
8736 concurrent = (concurrent || 0) < 1 ? Number.POSITIVE_INFINITY : concurrent;
8737 return this.lift(new ExpandOperator(project, concurrent, scheduler));
8739 exports.expand = expand;
8740 var ExpandOperator = (function () {
8741 function ExpandOperator(project, concurrent, scheduler) {
8742 this.project = project;
8743 this.concurrent = concurrent;
8744 this.scheduler = scheduler;
8746 ExpandOperator.prototype.call = function (subscriber, source) {
8747 return source._subscribe(new ExpandSubscriber(subscriber, this.project, this.concurrent, this.scheduler));
8749 return ExpandOperator;
8751 exports.ExpandOperator = ExpandOperator;
8753 * We need this JSDoc comment for affecting ESDoc.
8755 * @extends {Ignored}
8757 var ExpandSubscriber = (function (_super) {
8758 __extends(ExpandSubscriber, _super);
8759 function ExpandSubscriber(destination, project, concurrent, scheduler) {
8760 _super.call(this, destination);
8761 this.project = project;
8762 this.concurrent = concurrent;
8763 this.scheduler = scheduler;
8766 this.hasCompleted = false;
8767 if (concurrent < Number.POSITIVE_INFINITY) {
8771 ExpandSubscriber.dispatch = function (arg) {
8772 var subscriber = arg.subscriber, result = arg.result, value = arg.value, index = arg.index;
8773 subscriber.subscribeToProjection(result, value, index);
8775 ExpandSubscriber.prototype._next = function (value) {
8776 var destination = this.destination;
8777 if (destination.closed) {
8781 var index = this.index++;
8782 if (this.active < this.concurrent) {
8783 destination.next(value);
8784 var result = tryCatch_1.tryCatch(this.project)(value, index);
8785 if (result === errorObject_1.errorObject) {
8786 destination.error(errorObject_1.errorObject.e);
8788 else if (!this.scheduler) {
8789 this.subscribeToProjection(result, value, index);
8792 var state = { subscriber: this, result: result, value: value, index: index };
8793 this.add(this.scheduler.schedule(ExpandSubscriber.dispatch, 0, state));
8797 this.buffer.push(value);
8800 ExpandSubscriber.prototype.subscribeToProjection = function (result, value, index) {
8802 this.add(subscribeToResult_1.subscribeToResult(this, result, value, index));
8804 ExpandSubscriber.prototype._complete = function () {
8805 this.hasCompleted = true;
8806 if (this.hasCompleted && this.active === 0) {
8807 this.destination.complete();
8810 ExpandSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
8811 this._next(innerValue);
8813 ExpandSubscriber.prototype.notifyComplete = function (innerSub) {
8814 var buffer = this.buffer;
8815 this.remove(innerSub);
8817 if (buffer && buffer.length > 0) {
8818 this._next(buffer.shift());
8820 if (this.hasCompleted && this.active === 0) {
8821 this.destination.complete();
8824 return ExpandSubscriber;
8825 }(OuterSubscriber_1.OuterSubscriber));
8826 exports.ExpandSubscriber = ExpandSubscriber;
8828 },{"../OuterSubscriber":30,"../util/errorObject":147,"../util/subscribeToResult":154,"../util/tryCatch":156}],109:[function(require,module,exports){
8830 var __extends = (this && this.__extends) || function (d, b) {
8831 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
8832 function __() { this.constructor = d; }
8833 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
8835 var Subscriber_1 = require('../Subscriber');
8837 * Filter items emitted by the source Observable by only emitting those that
8838 * satisfy a specified predicate.
8840 * <span class="informal">Like
8841 * [Array.prototype.filter()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter),
8842 * it only emits a value from the source if it passes a criterion function.</span>
8844 * <img src="./img/filter.png" width="100%">
8846 * Similar to the well-known `Array.prototype.filter` method, this operator
8847 * takes values from the source Observable, passes them through a `predicate`
8848 * function and only emits those values that yielded `true`.
8850 * @example <caption>Emit only click events whose target was a DIV element</caption>
8851 * var clicks = Rx.Observable.fromEvent(document, 'click');
8852 * var clicksOnDivs = clicks.filter(ev => ev.target.tagName === 'DIV');
8853 * clicksOnDivs.subscribe(x => console.log(x));
8855 * @see {@link distinct}
8856 * @see {@link distinctKey}
8857 * @see {@link distinctUntilChanged}
8858 * @see {@link distinctUntilKeyChanged}
8859 * @see {@link ignoreElements}
8860 * @see {@link partition}
8863 * @param {function(value: T, index: number): boolean} predicate A function that
8864 * evaluates each value emitted by the source Observable. If it returns `true`,
8865 * the value is emitted, if `false` the value is not passed to the output
8866 * Observable. The `index` parameter is the number `i` for the i-th source
8867 * emission that has happened since the subscription, starting from the number
8869 * @param {any} [thisArg] An optional argument to determine the value of `this`
8870 * in the `predicate` function.
8871 * @return {Observable} An Observable of values from the source that were
8872 * allowed by the `predicate` function.
8876 function filter(predicate, thisArg) {
8877 return this.lift(new FilterOperator(predicate, thisArg));
8879 exports.filter = filter;
8880 var FilterOperator = (function () {
8881 function FilterOperator(predicate, thisArg) {
8882 this.predicate = predicate;
8883 this.thisArg = thisArg;
8885 FilterOperator.prototype.call = function (subscriber, source) {
8886 return source._subscribe(new FilterSubscriber(subscriber, this.predicate, this.thisArg));
8888 return FilterOperator;
8891 * We need this JSDoc comment for affecting ESDoc.
8893 * @extends {Ignored}
8895 var FilterSubscriber = (function (_super) {
8896 __extends(FilterSubscriber, _super);
8897 function FilterSubscriber(destination, predicate, thisArg) {
8898 _super.call(this, destination);
8899 this.predicate = predicate;
8900 this.thisArg = thisArg;
8902 this.predicate = predicate;
8904 // the try catch block below is left specifically for
8905 // optimization and perf reasons. a tryCatcher is not necessary here.
8906 FilterSubscriber.prototype._next = function (value) {
8909 result = this.predicate.call(this.thisArg, value, this.count++);
8912 this.destination.error(err);
8916 this.destination.next(value);
8919 return FilterSubscriber;
8920 }(Subscriber_1.Subscriber));
8922 },{"../Subscriber":35}],110:[function(require,module,exports){
8924 var __extends = (this && this.__extends) || function (d, b) {
8925 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
8926 function __() { this.constructor = d; }
8927 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
8929 var Subscriber_1 = require('../Subscriber');
8930 var Subscription_1 = require('../Subscription');
8932 * Returns an Observable that mirrors the source Observable, but will call a specified function when
8933 * the source terminates on complete or error.
8934 * @param {function} callback function to be called when source terminates.
8935 * @return {Observable} an Observable that mirrors the source, but will call the specified function on termination.
8939 function _finally(callback) {
8940 return this.lift(new FinallyOperator(callback));
8942 exports._finally = _finally;
8943 var FinallyOperator = (function () {
8944 function FinallyOperator(callback) {
8945 this.callback = callback;
8947 FinallyOperator.prototype.call = function (subscriber, source) {
8948 return source._subscribe(new FinallySubscriber(subscriber, this.callback));
8950 return FinallyOperator;
8953 * We need this JSDoc comment for affecting ESDoc.
8955 * @extends {Ignored}
8957 var FinallySubscriber = (function (_super) {
8958 __extends(FinallySubscriber, _super);
8959 function FinallySubscriber(destination, callback) {
8960 _super.call(this, destination);
8961 this.add(new Subscription_1.Subscription(callback));
8963 return FinallySubscriber;
8964 }(Subscriber_1.Subscriber));
8966 },{"../Subscriber":35,"../Subscription":36}],111:[function(require,module,exports){
8968 var __extends = (this && this.__extends) || function (d, b) {
8969 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
8970 function __() { this.constructor = d; }
8971 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
8973 var Subscriber_1 = require('../Subscriber');
8974 var EmptyError_1 = require('../util/EmptyError');
8976 * Emits only the first value (or the first value that meets some condition)
8977 * emitted by the source Observable.
8979 * <span class="informal">Emits only the first value. Or emits only the first
8980 * value that passes some test.</span>
8982 * <img src="./img/first.png" width="100%">
8984 * If called with no arguments, `first` emits the first value of the source
8985 * Observable, then completes. If called with a `predicate` function, `first`
8986 * emits the first value of the source that matches the specified condition. It
8987 * may also take a `resultSelector` function to produce the output value from
8988 * the input value, and a `defaultValue` to emit in case the source completes
8989 * before it is able to emit a valid value. Throws an error if `defaultValue`
8990 * was not provided and a matching element is not found.
8992 * @example <caption>Emit only the first click that happens on the DOM</caption>
8993 * var clicks = Rx.Observable.fromEvent(document, 'click');
8994 * var result = clicks.first();
8995 * result.subscribe(x => console.log(x));
8997 * @example <caption>Emits the first click that happens on a DIV</caption>
8998 * var clicks = Rx.Observable.fromEvent(document, 'click');
8999 * var result = clicks.first(ev => ev.target.tagName === 'DIV');
9000 * result.subscribe(x => console.log(x));
9002 * @see {@link filter}
9006 * @throws {EmptyError} Delivers an EmptyError to the Observer's `error`
9007 * callback if the Observable completes before any `next` notification was sent.
9009 * @param {function(value: T, index: number, source: Observable<T>): boolean} [predicate]
9010 * An optional function called with each item to test for condition matching.
9011 * @param {function(value: T, index: number): R} [resultSelector] A function to
9012 * produce the value on the output Observable based on the values
9013 * and the indices of the source Observable. The arguments passed to this
9015 * - `value`: the value that was emitted on the source.
9016 * - `index`: the "index" of the value from the source.
9017 * @param {R} [defaultValue] The default value emitted in case no valid value
9018 * was found on the source.
9019 * @return {Observable<T|R>} an Observable of the first item that matches the
9024 function first(predicate, resultSelector, defaultValue) {
9025 return this.lift(new FirstOperator(predicate, resultSelector, defaultValue, this));
9027 exports.first = first;
9028 var FirstOperator = (function () {
9029 function FirstOperator(predicate, resultSelector, defaultValue, source) {
9030 this.predicate = predicate;
9031 this.resultSelector = resultSelector;
9032 this.defaultValue = defaultValue;
9033 this.source = source;
9035 FirstOperator.prototype.call = function (observer, source) {
9036 return source._subscribe(new FirstSubscriber(observer, this.predicate, this.resultSelector, this.defaultValue, this.source));
9038 return FirstOperator;
9041 * We need this JSDoc comment for affecting ESDoc.
9043 * @extends {Ignored}
9045 var FirstSubscriber = (function (_super) {
9046 __extends(FirstSubscriber, _super);
9047 function FirstSubscriber(destination, predicate, resultSelector, defaultValue, source) {
9048 _super.call(this, destination);
9049 this.predicate = predicate;
9050 this.resultSelector = resultSelector;
9051 this.defaultValue = defaultValue;
9052 this.source = source;
9054 this.hasCompleted = false;
9056 FirstSubscriber.prototype._next = function (value) {
9057 var index = this.index++;
9058 if (this.predicate) {
9059 this._tryPredicate(value, index);
9062 this._emit(value, index);
9065 FirstSubscriber.prototype._tryPredicate = function (value, index) {
9068 result = this.predicate(value, index, this.source);
9071 this.destination.error(err);
9075 this._emit(value, index);
9078 FirstSubscriber.prototype._emit = function (value, index) {
9079 if (this.resultSelector) {
9080 this._tryResultSelector(value, index);
9083 this._emitFinal(value);
9085 FirstSubscriber.prototype._tryResultSelector = function (value, index) {
9088 result = this.resultSelector(value, index);
9091 this.destination.error(err);
9094 this._emitFinal(result);
9096 FirstSubscriber.prototype._emitFinal = function (value) {
9097 var destination = this.destination;
9098 destination.next(value);
9099 destination.complete();
9100 this.hasCompleted = true;
9102 FirstSubscriber.prototype._complete = function () {
9103 var destination = this.destination;
9104 if (!this.hasCompleted && typeof this.defaultValue !== 'undefined') {
9105 destination.next(this.defaultValue);
9106 destination.complete();
9108 else if (!this.hasCompleted) {
9109 destination.error(new EmptyError_1.EmptyError);
9112 return FirstSubscriber;
9113 }(Subscriber_1.Subscriber));
9115 },{"../Subscriber":35,"../util/EmptyError":144}],112:[function(require,module,exports){
9117 var __extends = (this && this.__extends) || function (d, b) {
9118 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
9119 function __() { this.constructor = d; }
9120 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
9122 var Subscriber_1 = require('../Subscriber');
9123 var EmptyError_1 = require('../util/EmptyError');
9125 * Returns an Observable that emits only the last item emitted by the source Observable.
9126 * It optionally takes a predicate function as a parameter, in which case, rather than emitting
9127 * the last item from the source Observable, the resulting Observable will emit the last item
9128 * from the source Observable that satisfies the predicate.
9130 * <img src="./img/last.png" width="100%">
9132 * @throws {EmptyError} Delivers an EmptyError to the Observer's `error`
9133 * callback if the Observable completes before any `next` notification was sent.
9134 * @param {function} predicate - the condition any source emitted item has to satisfy.
9135 * @return {Observable} an Observable that emits only the last item satisfying the given condition
9136 * from the source, or an NoSuchElementException if no such items are emitted.
9137 * @throws - Throws if no items that match the predicate are emitted by the source Observable.
9141 function last(predicate, resultSelector, defaultValue) {
9142 return this.lift(new LastOperator(predicate, resultSelector, defaultValue, this));
9144 exports.last = last;
9145 var LastOperator = (function () {
9146 function LastOperator(predicate, resultSelector, defaultValue, source) {
9147 this.predicate = predicate;
9148 this.resultSelector = resultSelector;
9149 this.defaultValue = defaultValue;
9150 this.source = source;
9152 LastOperator.prototype.call = function (observer, source) {
9153 return source._subscribe(new LastSubscriber(observer, this.predicate, this.resultSelector, this.defaultValue, this.source));
9155 return LastOperator;
9158 * We need this JSDoc comment for affecting ESDoc.
9160 * @extends {Ignored}
9162 var LastSubscriber = (function (_super) {
9163 __extends(LastSubscriber, _super);
9164 function LastSubscriber(destination, predicate, resultSelector, defaultValue, source) {
9165 _super.call(this, destination);
9166 this.predicate = predicate;
9167 this.resultSelector = resultSelector;
9168 this.defaultValue = defaultValue;
9169 this.source = source;
9170 this.hasValue = false;
9172 if (typeof defaultValue !== 'undefined') {
9173 this.lastValue = defaultValue;
9174 this.hasValue = true;
9177 LastSubscriber.prototype._next = function (value) {
9178 var index = this.index++;
9179 if (this.predicate) {
9180 this._tryPredicate(value, index);
9183 if (this.resultSelector) {
9184 this._tryResultSelector(value, index);
9187 this.lastValue = value;
9188 this.hasValue = true;
9191 LastSubscriber.prototype._tryPredicate = function (value, index) {
9194 result = this.predicate(value, index, this.source);
9197 this.destination.error(err);
9201 if (this.resultSelector) {
9202 this._tryResultSelector(value, index);
9205 this.lastValue = value;
9206 this.hasValue = true;
9209 LastSubscriber.prototype._tryResultSelector = function (value, index) {
9212 result = this.resultSelector(value, index);
9215 this.destination.error(err);
9218 this.lastValue = result;
9219 this.hasValue = true;
9221 LastSubscriber.prototype._complete = function () {
9222 var destination = this.destination;
9223 if (this.hasValue) {
9224 destination.next(this.lastValue);
9225 destination.complete();
9228 destination.error(new EmptyError_1.EmptyError);
9231 return LastSubscriber;
9232 }(Subscriber_1.Subscriber));
9234 },{"../Subscriber":35,"../util/EmptyError":144}],113:[function(require,module,exports){
9236 var __extends = (this && this.__extends) || function (d, b) {
9237 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
9238 function __() { this.constructor = d; }
9239 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
9241 var Subscriber_1 = require('../Subscriber');
9243 * Applies a given `project` function to each value emitted by the source
9244 * Observable, and emits the resulting values as an Observable.
9246 * <span class="informal">Like [Array.prototype.map()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map),
9247 * it passes each source value through a transformation function to get
9248 * corresponding output values.</span>
9250 * <img src="./img/map.png" width="100%">
9252 * Similar to the well known `Array.prototype.map` function, this operator
9253 * applies a projection to each value and emits that projection in the output
9256 * @example <caption>Map every every click to the clientX position of that click</caption>
9257 * var clicks = Rx.Observable.fromEvent(document, 'click');
9258 * var positions = clicks.map(ev => ev.clientX);
9259 * positions.subscribe(x => console.log(x));
9261 * @see {@link mapTo}
9262 * @see {@link pluck}
9264 * @param {function(value: T, index: number): R} project The function to apply
9265 * to each `value` emitted by the source Observable. The `index` parameter is
9266 * the number `i` for the i-th emission that has happened since the
9267 * subscription, starting from the number `0`.
9268 * @param {any} [thisArg] An optional argument to define what `this` is in the
9269 * `project` function.
9270 * @return {Observable<R>} An Observable that emits the values from the source
9271 * Observable transformed by the given `project` function.
9275 function map(project, thisArg) {
9276 if (typeof project !== 'function') {
9277 throw new TypeError('argument is not a function. Are you looking for `mapTo()`?');
9279 return this.lift(new MapOperator(project, thisArg));
9282 var MapOperator = (function () {
9283 function MapOperator(project, thisArg) {
9284 this.project = project;
9285 this.thisArg = thisArg;
9287 MapOperator.prototype.call = function (subscriber, source) {
9288 return source._subscribe(new MapSubscriber(subscriber, this.project, this.thisArg));
9292 exports.MapOperator = MapOperator;
9294 * We need this JSDoc comment for affecting ESDoc.
9296 * @extends {Ignored}
9298 var MapSubscriber = (function (_super) {
9299 __extends(MapSubscriber, _super);
9300 function MapSubscriber(destination, project, thisArg) {
9301 _super.call(this, destination);
9302 this.project = project;
9304 this.thisArg = thisArg || this;
9306 // NOTE: This looks unoptimized, but it's actually purposefully NOT
9307 // using try/catch optimizations.
9308 MapSubscriber.prototype._next = function (value) {
9311 result = this.project.call(this.thisArg, value, this.count++);
9314 this.destination.error(err);
9317 this.destination.next(result);
9319 return MapSubscriber;
9320 }(Subscriber_1.Subscriber));
9322 },{"../Subscriber":35}],114:[function(require,module,exports){
9324 var ArrayObservable_1 = require('../observable/ArrayObservable');
9325 var mergeAll_1 = require('./mergeAll');
9326 var isScheduler_1 = require('../util/isScheduler');
9328 * Creates an output Observable which concurrently emits all values from every
9329 * given input Observable.
9331 * <span class="informal">Flattens multiple Observables together by blending
9332 * their values into one Observable.</span>
9334 * <img src="./img/merge.png" width="100%">
9336 * `merge` subscribes to each given input Observable (either the source or an
9337 * Observable given as argument), and simply forwards (without doing any
9338 * transformation) all the values from all the input Observables to the output
9339 * Observable. The output Observable only completes once all input Observables
9340 * have completed. Any error delivered by an input Observable will be immediately
9341 * emitted on the output Observable.
9343 * @example <caption>Merge together two Observables: 1s interval and clicks</caption>
9344 * var clicks = Rx.Observable.fromEvent(document, 'click');
9345 * var timer = Rx.Observable.interval(1000);
9346 * var clicksOrTimer = clicks.merge(timer);
9347 * clicksOrTimer.subscribe(x => console.log(x));
9349 * @example <caption>Merge together 3 Observables, but only 2 run concurrently</caption>
9350 * var timer1 = Rx.Observable.interval(1000).take(10);
9351 * var timer2 = Rx.Observable.interval(2000).take(6);
9352 * var timer3 = Rx.Observable.interval(500).take(10);
9353 * var concurrent = 2; // the argument
9354 * var merged = timer1.merge(timer2, timer3, concurrent);
9355 * merged.subscribe(x => console.log(x));
9357 * @see {@link mergeAll}
9358 * @see {@link mergeMap}
9359 * @see {@link mergeMapTo}
9360 * @see {@link mergeScan}
9362 * @param {Observable} other An input Observable to merge with the source
9363 * Observable. More than one input Observables may be given as argument.
9364 * @param {number} [concurrent=Number.POSITIVE_INFINITY] Maximum number of input
9365 * Observables being subscribed to concurrently.
9366 * @param {Scheduler} [scheduler=null] The Scheduler to use for managing
9367 * concurrency of input Observables.
9368 * @return {Observable} an Observable that emits items that are the result of
9369 * every input Observable.
9374 var observables = [];
9375 for (var _i = 0; _i < arguments.length; _i++) {
9376 observables[_i - 0] = arguments[_i];
9378 observables.unshift(this);
9379 return mergeStatic.apply(this, observables);
9381 exports.merge = merge;
9382 /* tslint:enable:max-line-length */
9384 * Creates an output Observable which concurrently emits all values from every
9385 * given input Observable.
9387 * <span class="informal">Flattens multiple Observables together by blending
9388 * their values into one Observable.</span>
9390 * <img src="./img/merge.png" width="100%">
9392 * `merge` subscribes to each given input Observable (as arguments), and simply
9393 * forwards (without doing any transformation) all the values from all the input
9394 * Observables to the output Observable. The output Observable only completes
9395 * once all input Observables have completed. Any error delivered by an input
9396 * Observable will be immediately emitted on the output Observable.
9398 * @example <caption>Merge together two Observables: 1s interval and clicks</caption>
9399 * var clicks = Rx.Observable.fromEvent(document, 'click');
9400 * var timer = Rx.Observable.interval(1000);
9401 * var clicksOrTimer = Rx.Observable.merge(clicks, timer);
9402 * clicksOrTimer.subscribe(x => console.log(x));
9404 * @example <caption>Merge together 3 Observables, but only 2 run concurrently</caption>
9405 * var timer1 = Rx.Observable.interval(1000).take(10);
9406 * var timer2 = Rx.Observable.interval(2000).take(6);
9407 * var timer3 = Rx.Observable.interval(500).take(10);
9408 * var concurrent = 2; // the argument
9409 * var merged = Rx.Observable.merge(timer1, timer2, timer3, concurrent);
9410 * merged.subscribe(x => console.log(x));
9412 * @see {@link mergeAll}
9413 * @see {@link mergeMap}
9414 * @see {@link mergeMapTo}
9415 * @see {@link mergeScan}
9417 * @param {Observable} input1 An input Observable to merge with others.
9418 * @param {Observable} input2 An input Observable to merge with others.
9419 * @param {number} [concurrent=Number.POSITIVE_INFINITY] Maximum number of input
9420 * Observables being subscribed to concurrently.
9421 * @param {Scheduler} [scheduler=null] The Scheduler to use for managing
9422 * concurrency of input Observables.
9423 * @return {Observable} an Observable that emits items that are the result of
9424 * every input Observable.
9429 function mergeStatic() {
9430 var observables = [];
9431 for (var _i = 0; _i < arguments.length; _i++) {
9432 observables[_i - 0] = arguments[_i];
9434 var concurrent = Number.POSITIVE_INFINITY;
9435 var scheduler = null;
9436 var last = observables[observables.length - 1];
9437 if (isScheduler_1.isScheduler(last)) {
9438 scheduler = observables.pop();
9439 if (observables.length > 1 && typeof observables[observables.length - 1] === 'number') {
9440 concurrent = observables.pop();
9443 else if (typeof last === 'number') {
9444 concurrent = observables.pop();
9446 if (observables.length === 1) {
9447 return observables[0];
9449 return new ArrayObservable_1.ArrayObservable(observables, scheduler).lift(new mergeAll_1.MergeAllOperator(concurrent));
9451 exports.mergeStatic = mergeStatic;
9453 },{"../observable/ArrayObservable":79,"../util/isScheduler":152,"./mergeAll":115}],115:[function(require,module,exports){
9455 var __extends = (this && this.__extends) || function (d, b) {
9456 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
9457 function __() { this.constructor = d; }
9458 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
9460 var OuterSubscriber_1 = require('../OuterSubscriber');
9461 var subscribeToResult_1 = require('../util/subscribeToResult');
9463 * Converts a higher-order Observable into a first-order Observable which
9464 * concurrently delivers all values that are emitted on the inner Observables.
9466 * <span class="informal">Flattens an Observable-of-Observables.</span>
9468 * <img src="./img/mergeAll.png" width="100%">
9470 * `mergeAll` subscribes to an Observable that emits Observables, also known as
9471 * a higher-order Observable. Each time it observes one of these emitted inner
9472 * Observables, it subscribes to that and delivers all the values from the
9473 * inner Observable on the output Observable. The output Observable only
9474 * completes once all inner Observables have completed. Any error delivered by
9475 * a inner Observable will be immediately emitted on the output Observable.
9477 * @example <caption>Spawn a new interval Observable for each click event, and blend their outputs as one Observable</caption>
9478 * var clicks = Rx.Observable.fromEvent(document, 'click');
9479 * var higherOrder = clicks.map((ev) => Rx.Observable.interval(1000));
9480 * var firstOrder = higherOrder.mergeAll();
9481 * firstOrder.subscribe(x => console.log(x));
9483 * @example <caption>Count from 0 to 9 every second for each click, but only allow 2 concurrent timers</caption>
9484 * var clicks = Rx.Observable.fromEvent(document, 'click');
9485 * var higherOrder = clicks.map((ev) => Rx.Observable.interval(1000).take(10));
9486 * var firstOrder = higherOrder.mergeAll(2);
9487 * firstOrder.subscribe(x => console.log(x));
9489 * @see {@link combineAll}
9490 * @see {@link concatAll}
9491 * @see {@link exhaust}
9492 * @see {@link merge}
9493 * @see {@link mergeMap}
9494 * @see {@link mergeMapTo}
9495 * @see {@link mergeScan}
9496 * @see {@link switch}
9497 * @see {@link zipAll}
9499 * @param {number} [concurrent=Number.POSITIVE_INFINITY] Maximum number of inner
9500 * Observables being subscribed to concurrently.
9501 * @return {Observable} An Observable that emits values coming from all the
9502 * inner Observables emitted by the source Observable.
9506 function mergeAll(concurrent) {
9507 if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
9508 return this.lift(new MergeAllOperator(concurrent));
9510 exports.mergeAll = mergeAll;
9511 var MergeAllOperator = (function () {
9512 function MergeAllOperator(concurrent) {
9513 this.concurrent = concurrent;
9515 MergeAllOperator.prototype.call = function (observer, source) {
9516 return source._subscribe(new MergeAllSubscriber(observer, this.concurrent));
9518 return MergeAllOperator;
9520 exports.MergeAllOperator = MergeAllOperator;
9522 * We need this JSDoc comment for affecting ESDoc.
9524 * @extends {Ignored}
9526 var MergeAllSubscriber = (function (_super) {
9527 __extends(MergeAllSubscriber, _super);
9528 function MergeAllSubscriber(destination, concurrent) {
9529 _super.call(this, destination);
9530 this.concurrent = concurrent;
9531 this.hasCompleted = false;
9535 MergeAllSubscriber.prototype._next = function (observable) {
9536 if (this.active < this.concurrent) {
9538 this.add(subscribeToResult_1.subscribeToResult(this, observable));
9541 this.buffer.push(observable);
9544 MergeAllSubscriber.prototype._complete = function () {
9545 this.hasCompleted = true;
9546 if (this.active === 0 && this.buffer.length === 0) {
9547 this.destination.complete();
9550 MergeAllSubscriber.prototype.notifyComplete = function (innerSub) {
9551 var buffer = this.buffer;
9552 this.remove(innerSub);
9554 if (buffer.length > 0) {
9555 this._next(buffer.shift());
9557 else if (this.active === 0 && this.hasCompleted) {
9558 this.destination.complete();
9561 return MergeAllSubscriber;
9562 }(OuterSubscriber_1.OuterSubscriber));
9563 exports.MergeAllSubscriber = MergeAllSubscriber;
9565 },{"../OuterSubscriber":30,"../util/subscribeToResult":154}],116:[function(require,module,exports){
9567 var __extends = (this && this.__extends) || function (d, b) {
9568 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
9569 function __() { this.constructor = d; }
9570 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
9572 var subscribeToResult_1 = require('../util/subscribeToResult');
9573 var OuterSubscriber_1 = require('../OuterSubscriber');
9575 * Projects each source value to an Observable which is merged in the output
9578 * <span class="informal">Maps each value to an Observable, then flattens all of
9579 * these inner Observables using {@link mergeAll}.</span>
9581 * <img src="./img/mergeMap.png" width="100%">
9583 * Returns an Observable that emits items based on applying a function that you
9584 * supply to each item emitted by the source Observable, where that function
9585 * returns an Observable, and then merging those resulting Observables and
9586 * emitting the results of this merger.
9588 * @example <caption>Map and flatten each letter to an Observable ticking every 1 second</caption>
9589 * var letters = Rx.Observable.of('a', 'b', 'c');
9590 * var result = letters.mergeMap(x =>
9591 * Rx.Observable.interval(1000).map(i => x+i)
9593 * result.subscribe(x => console.log(x));
9595 * @see {@link concatMap}
9596 * @see {@link exhaustMap}
9597 * @see {@link merge}
9598 * @see {@link mergeAll}
9599 * @see {@link mergeMapTo}
9600 * @see {@link mergeScan}
9601 * @see {@link switchMap}
9603 * @param {function(value: T, ?index: number): Observable} project A function
9604 * that, when applied to an item emitted by the source Observable, returns an
9606 * @param {function(outerValue: T, innerValue: I, outerIndex: number, innerIndex: number): any} [resultSelector]
9607 * A function to produce the value on the output Observable based on the values
9608 * and the indices of the source (outer) emission and the inner Observable
9609 * emission. The arguments passed to this function are:
9610 * - `outerValue`: the value that came from the source
9611 * - `innerValue`: the value that came from the projected Observable
9612 * - `outerIndex`: the "index" of the value that came from the source
9613 * - `innerIndex`: the "index" of the value from the projected Observable
9614 * @param {number} [concurrent=Number.POSITIVE_INFINITY] Maximum number of input
9615 * Observables being subscribed to concurrently.
9616 * @return {Observable} An Observable that emits the result of applying the
9617 * projection function (and the optional `resultSelector`) to each item emitted
9618 * by the source Observable and merging the results of the Observables obtained
9619 * from this transformation.
9623 function mergeMap(project, resultSelector, concurrent) {
9624 if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
9625 if (typeof resultSelector === 'number') {
9626 concurrent = resultSelector;
9627 resultSelector = null;
9629 return this.lift(new MergeMapOperator(project, resultSelector, concurrent));
9631 exports.mergeMap = mergeMap;
9632 var MergeMapOperator = (function () {
9633 function MergeMapOperator(project, resultSelector, concurrent) {
9634 if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
9635 this.project = project;
9636 this.resultSelector = resultSelector;
9637 this.concurrent = concurrent;
9639 MergeMapOperator.prototype.call = function (observer, source) {
9640 return source._subscribe(new MergeMapSubscriber(observer, this.project, this.resultSelector, this.concurrent));
9642 return MergeMapOperator;
9644 exports.MergeMapOperator = MergeMapOperator;
9646 * We need this JSDoc comment for affecting ESDoc.
9648 * @extends {Ignored}
9650 var MergeMapSubscriber = (function (_super) {
9651 __extends(MergeMapSubscriber, _super);
9652 function MergeMapSubscriber(destination, project, resultSelector, concurrent) {
9653 if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
9654 _super.call(this, destination);
9655 this.project = project;
9656 this.resultSelector = resultSelector;
9657 this.concurrent = concurrent;
9658 this.hasCompleted = false;
9663 MergeMapSubscriber.prototype._next = function (value) {
9664 if (this.active < this.concurrent) {
9665 this._tryNext(value);
9668 this.buffer.push(value);
9671 MergeMapSubscriber.prototype._tryNext = function (value) {
9673 var index = this.index++;
9675 result = this.project(value, index);
9678 this.destination.error(err);
9682 this._innerSub(result, value, index);
9684 MergeMapSubscriber.prototype._innerSub = function (ish, value, index) {
9685 this.add(subscribeToResult_1.subscribeToResult(this, ish, value, index));
9687 MergeMapSubscriber.prototype._complete = function () {
9688 this.hasCompleted = true;
9689 if (this.active === 0 && this.buffer.length === 0) {
9690 this.destination.complete();
9693 MergeMapSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
9694 if (this.resultSelector) {
9695 this._notifyResultSelector(outerValue, innerValue, outerIndex, innerIndex);
9698 this.destination.next(innerValue);
9701 MergeMapSubscriber.prototype._notifyResultSelector = function (outerValue, innerValue, outerIndex, innerIndex) {
9704 result = this.resultSelector(outerValue, innerValue, outerIndex, innerIndex);
9707 this.destination.error(err);
9710 this.destination.next(result);
9712 MergeMapSubscriber.prototype.notifyComplete = function (innerSub) {
9713 var buffer = this.buffer;
9714 this.remove(innerSub);
9716 if (buffer.length > 0) {
9717 this._next(buffer.shift());
9719 else if (this.active === 0 && this.hasCompleted) {
9720 this.destination.complete();
9723 return MergeMapSubscriber;
9724 }(OuterSubscriber_1.OuterSubscriber));
9725 exports.MergeMapSubscriber = MergeMapSubscriber;
9727 },{"../OuterSubscriber":30,"../util/subscribeToResult":154}],117:[function(require,module,exports){
9729 var MulticastObservable_1 = require('../observable/MulticastObservable');
9730 var ConnectableObservable_1 = require('../observable/ConnectableObservable');
9732 * Returns an Observable that emits the results of invoking a specified selector on items
9733 * emitted by a ConnectableObservable that shares a single subscription to the underlying stream.
9735 * <img src="./img/multicast.png" width="100%">
9737 * @param {Function|Subject} Factory function to create an intermediate subject through
9738 * which the source sequence's elements will be multicast to the selector function
9739 * or Subject to push source elements into.
9740 * @param {Function} Optional selector function that can use the multicasted source stream
9741 * as many times as needed, without causing multiple subscriptions to the source stream.
9742 * Subscribers to the given source will receive all notifications of the source from the
9743 * time of the subscription forward.
9744 * @return {Observable} an Observable that emits the results of invoking the selector
9745 * on the items emitted by a `ConnectableObservable` that shares a single subscription to
9746 * the underlying stream.
9750 function multicast(subjectOrSubjectFactory, selector) {
9752 if (typeof subjectOrSubjectFactory === 'function') {
9753 subjectFactory = subjectOrSubjectFactory;
9756 subjectFactory = function subjectFactory() {
9757 return subjectOrSubjectFactory;
9761 new ConnectableObservable_1.ConnectableObservable(this, subjectFactory) :
9762 new MulticastObservable_1.MulticastObservable(this, subjectFactory, selector);
9764 exports.multicast = multicast;
9766 },{"../observable/ConnectableObservable":80,"../observable/MulticastObservable":87}],118:[function(require,module,exports){
9768 var __extends = (this && this.__extends) || function (d, b) {
9769 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
9770 function __() { this.constructor = d; }
9771 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
9773 var Subscriber_1 = require('../Subscriber');
9774 var Notification_1 = require('../Notification');
9776 * @see {@link Notification}
9780 * @return {Observable<R>|WebSocketSubject<T>|Observable<T>}
9784 function observeOn(scheduler, delay) {
9785 if (delay === void 0) { delay = 0; }
9786 return this.lift(new ObserveOnOperator(scheduler, delay));
9788 exports.observeOn = observeOn;
9789 var ObserveOnOperator = (function () {
9790 function ObserveOnOperator(scheduler, delay) {
9791 if (delay === void 0) { delay = 0; }
9792 this.scheduler = scheduler;
9795 ObserveOnOperator.prototype.call = function (subscriber, source) {
9796 return source._subscribe(new ObserveOnSubscriber(subscriber, this.scheduler, this.delay));
9798 return ObserveOnOperator;
9800 exports.ObserveOnOperator = ObserveOnOperator;
9802 * We need this JSDoc comment for affecting ESDoc.
9804 * @extends {Ignored}
9806 var ObserveOnSubscriber = (function (_super) {
9807 __extends(ObserveOnSubscriber, _super);
9808 function ObserveOnSubscriber(destination, scheduler, delay) {
9809 if (delay === void 0) { delay = 0; }
9810 _super.call(this, destination);
9811 this.scheduler = scheduler;
9814 ObserveOnSubscriber.dispatch = function (arg) {
9815 var notification = arg.notification, destination = arg.destination;
9816 notification.observe(destination);
9818 ObserveOnSubscriber.prototype.scheduleMessage = function (notification) {
9819 this.add(this.scheduler.schedule(ObserveOnSubscriber.dispatch, this.delay, new ObserveOnMessage(notification, this.destination)));
9821 ObserveOnSubscriber.prototype._next = function (value) {
9822 this.scheduleMessage(Notification_1.Notification.createNext(value));
9824 ObserveOnSubscriber.prototype._error = function (err) {
9825 this.scheduleMessage(Notification_1.Notification.createError(err));
9827 ObserveOnSubscriber.prototype._complete = function () {
9828 this.scheduleMessage(Notification_1.Notification.createComplete());
9830 return ObserveOnSubscriber;
9831 }(Subscriber_1.Subscriber));
9832 exports.ObserveOnSubscriber = ObserveOnSubscriber;
9833 var ObserveOnMessage = (function () {
9834 function ObserveOnMessage(notification, destination) {
9835 this.notification = notification;
9836 this.destination = destination;
9838 return ObserveOnMessage;
9840 exports.ObserveOnMessage = ObserveOnMessage;
9842 },{"../Notification":27,"../Subscriber":35}],119:[function(require,module,exports){
9844 var __extends = (this && this.__extends) || function (d, b) {
9845 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
9846 function __() { this.constructor = d; }
9847 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
9849 var Subscriber_1 = require('../Subscriber');
9851 * Groups pairs of consecutive emissions together and emits them as an array of
9854 * <span class="informal">Puts the current value and previous value together as
9855 * an array, and emits that.</span>
9857 * <img src="./img/pairwise.png" width="100%">
9859 * The Nth emission from the source Observable will cause the output Observable
9860 * to emit an array [(N-1)th, Nth] of the previous and the current value, as a
9861 * pair. For this reason, `pairwise` emits on the second and subsequent
9862 * emissions from the source Observable, but not on the first emission, because
9863 * there is no previous value in that case.
9865 * @example <caption>On every click (starting from the second), emit the relative distance to the previous click</caption>
9866 * var clicks = Rx.Observable.fromEvent(document, 'click');
9867 * var pairs = clicks.pairwise();
9868 * var distance = pairs.map(pair => {
9869 * var x0 = pair[0].clientX;
9870 * var y0 = pair[0].clientY;
9871 * var x1 = pair[1].clientX;
9872 * var y1 = pair[1].clientY;
9873 * return Math.sqrt(Math.pow(x0 - x1, 2) + Math.pow(y0 - y1, 2));
9875 * distance.subscribe(x => console.log(x));
9877 * @see {@link buffer}
9878 * @see {@link bufferCount}
9880 * @return {Observable<Array<T>>} An Observable of pairs (as arrays) of
9881 * consecutive values from the source Observable.
9885 function pairwise() {
9886 return this.lift(new PairwiseOperator());
9888 exports.pairwise = pairwise;
9889 var PairwiseOperator = (function () {
9890 function PairwiseOperator() {
9892 PairwiseOperator.prototype.call = function (subscriber, source) {
9893 return source._subscribe(new PairwiseSubscriber(subscriber));
9895 return PairwiseOperator;
9898 * We need this JSDoc comment for affecting ESDoc.
9900 * @extends {Ignored}
9902 var PairwiseSubscriber = (function (_super) {
9903 __extends(PairwiseSubscriber, _super);
9904 function PairwiseSubscriber(destination) {
9905 _super.call(this, destination);
9906 this.hasPrev = false;
9908 PairwiseSubscriber.prototype._next = function (value) {
9910 this.destination.next([this.prev, value]);
9913 this.hasPrev = true;
9917 return PairwiseSubscriber;
9918 }(Subscriber_1.Subscriber));
9920 },{"../Subscriber":35}],120:[function(require,module,exports){
9922 var map_1 = require('./map');
9924 * Maps each source value (an object) to its specified nested property.
9926 * <span class="informal">Like {@link map}, but meant only for picking one of
9927 * the nested properties of every emitted object.</span>
9929 * <img src="./img/pluck.png" width="100%">
9931 * Given a list of strings describing a path to an object property, retrieves
9932 * the value of a specified nested property from all values in the source
9933 * Observable. If a property can't be resolved, it will return `undefined` for
9936 * @example <caption>Map every every click to the tagName of the clicked target element</caption>
9937 * var clicks = Rx.Observable.fromEvent(document, 'click');
9938 * var tagNames = clicks.pluck('target', 'tagName');
9939 * tagNames.subscribe(x => console.log(x));
9943 * @param {...string} properties The nested properties to pluck from each source
9944 * value (an object).
9945 * @return {Observable} Returns a new Observable of property values from the
9951 var properties = [];
9952 for (var _i = 0; _i < arguments.length; _i++) {
9953 properties[_i - 0] = arguments[_i];
9955 var length = properties.length;
9957 throw new Error('list of properties cannot be empty.');
9959 return map_1.map.call(this, plucker(properties, length));
9961 exports.pluck = pluck;
9962 function plucker(props, length) {
9963 var mapper = function (x) {
9964 var currentProp = x;
9965 for (var i = 0; i < length; i++) {
9966 var p = currentProp[props[i]];
9967 if (typeof p !== 'undefined') {
9979 },{"./map":113}],121:[function(require,module,exports){
9981 var Subject_1 = require('../Subject');
9982 var multicast_1 = require('./multicast');
9984 * Returns a ConnectableObservable, which is a variety of Observable that waits until its connect method is called
9985 * before it begins emitting items to those Observers that have subscribed to it.
9987 * <img src="./img/publish.png" width="100%">
9989 * @param {Function} Optional selector function which can use the multicasted source sequence as many times as needed,
9990 * without causing multiple subscriptions to the source sequence.
9991 * Subscribers to the given source will receive all notifications of the source from the time of the subscription on.
9992 * @return a ConnectableObservable that upon connection causes the source Observable to emit items to its Observers.
9996 function publish(selector) {
9997 return selector ? multicast_1.multicast.call(this, function () { return new Subject_1.Subject(); }, selector) :
9998 multicast_1.multicast.call(this, new Subject_1.Subject());
10000 exports.publish = publish;
10002 },{"../Subject":33,"./multicast":117}],122:[function(require,module,exports){
10004 var ReplaySubject_1 = require('../ReplaySubject');
10005 var multicast_1 = require('./multicast');
10007 * @param bufferSize
10008 * @param windowTime
10010 * @return {ConnectableObservable<T>}
10011 * @method publishReplay
10012 * @owner Observable
10014 function publishReplay(bufferSize, windowTime, scheduler) {
10015 if (bufferSize === void 0) { bufferSize = Number.POSITIVE_INFINITY; }
10016 if (windowTime === void 0) { windowTime = Number.POSITIVE_INFINITY; }
10017 return multicast_1.multicast.call(this, new ReplaySubject_1.ReplaySubject(bufferSize, windowTime, scheduler));
10019 exports.publishReplay = publishReplay;
10021 },{"../ReplaySubject":31,"./multicast":117}],123:[function(require,module,exports){
10023 var __extends = (this && this.__extends) || function (d, b) {
10024 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
10025 function __() { this.constructor = d; }
10026 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
10028 var Subscriber_1 = require('../Subscriber');
10030 * Applies an accumulator function over the source Observable, and returns each
10031 * intermediate result, with an optional seed value.
10033 * <span class="informal">It's like {@link reduce}, but emits the current
10034 * accumulation whenever the source emits a value.</span>
10036 * <img src="./img/scan.png" width="100%">
10038 * Combines together all values emitted on the source, using an accumulator
10039 * function that knows how to join a new source value into the accumulation from
10040 * the past. Is similar to {@link reduce}, but emits the intermediate
10043 * Returns an Observable that applies a specified `accumulator` function to each
10044 * item emitted by the source Observable. If a `seed` value is specified, then
10045 * that value will be used as the initial value for the accumulator. If no seed
10046 * value is specified, the first item of the source is used as the seed.
10048 * @example <caption>Count the number of click events</caption>
10049 * var clicks = Rx.Observable.fromEvent(document, 'click');
10050 * var ones = clicks.mapTo(1);
10052 * var count = ones.scan((acc, one) => acc + one, seed);
10053 * count.subscribe(x => console.log(x));
10055 * @see {@link expand}
10056 * @see {@link mergeScan}
10057 * @see {@link reduce}
10059 * @param {function(acc: R, value: T, index: number): R} accumulator
10060 * The accumulator function called on each source value.
10061 * @param {T|R} [seed] The initial accumulation value.
10062 * @return {Observable<R>} An observable of the accumulated values.
10064 * @owner Observable
10066 function scan(accumulator, seed) {
10067 return this.lift(new ScanOperator(accumulator, seed));
10069 exports.scan = scan;
10070 var ScanOperator = (function () {
10071 function ScanOperator(accumulator, seed) {
10072 this.accumulator = accumulator;
10075 ScanOperator.prototype.call = function (subscriber, source) {
10076 return source._subscribe(new ScanSubscriber(subscriber, this.accumulator, this.seed));
10078 return ScanOperator;
10081 * We need this JSDoc comment for affecting ESDoc.
10083 * @extends {Ignored}
10085 var ScanSubscriber = (function (_super) {
10086 __extends(ScanSubscriber, _super);
10087 function ScanSubscriber(destination, accumulator, seed) {
10088 _super.call(this, destination);
10089 this.accumulator = accumulator;
10091 this.accumulatorSet = false;
10093 this.accumulatorSet = typeof seed !== 'undefined';
10095 Object.defineProperty(ScanSubscriber.prototype, "seed", {
10099 set: function (value) {
10100 this.accumulatorSet = true;
10101 this._seed = value;
10106 ScanSubscriber.prototype._next = function (value) {
10107 if (!this.accumulatorSet) {
10109 this.destination.next(value);
10112 return this._tryNext(value);
10115 ScanSubscriber.prototype._tryNext = function (value) {
10116 var index = this.index++;
10119 result = this.accumulator(this.seed, value, index);
10122 this.destination.error(err);
10124 this.seed = result;
10125 this.destination.next(result);
10127 return ScanSubscriber;
10128 }(Subscriber_1.Subscriber));
10130 },{"../Subscriber":35}],124:[function(require,module,exports){
10132 var multicast_1 = require('./multicast');
10133 var Subject_1 = require('../Subject');
10134 function shareSubjectFactory() {
10135 return new Subject_1.Subject();
10138 * Returns a new Observable that multicasts (shares) the original Observable. As long as there is at least one
10139 * Subscriber this Observable will be subscribed and emitting data. When all subscribers have unsubscribed it will
10140 * unsubscribe from the source Observable. Because the Observable is multicasting it makes the stream `hot`.
10141 * This is an alias for .publish().refCount().
10143 * <img src="./img/share.png" width="100%">
10145 * @return {Observable<T>} an Observable that upon connection causes the source Observable to emit items to its Observers
10147 * @owner Observable
10150 return multicast_1.multicast.call(this, shareSubjectFactory).refCount();
10152 exports.share = share;
10155 },{"../Subject":33,"./multicast":117}],125:[function(require,module,exports){
10157 var __extends = (this && this.__extends) || function (d, b) {
10158 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
10159 function __() { this.constructor = d; }
10160 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
10162 var Subscriber_1 = require('../Subscriber');
10164 * Returns an Observable that skips `n` items emitted by an Observable.
10166 * <img src="./img/skip.png" width="100%">
10168 * @param {Number} the `n` of times, items emitted by source Observable should be skipped.
10169 * @return {Observable} an Observable that skips values emitted by the source Observable.
10172 * @owner Observable
10174 function skip(total) {
10175 return this.lift(new SkipOperator(total));
10177 exports.skip = skip;
10178 var SkipOperator = (function () {
10179 function SkipOperator(total) {
10180 this.total = total;
10182 SkipOperator.prototype.call = function (subscriber, source) {
10183 return source._subscribe(new SkipSubscriber(subscriber, this.total));
10185 return SkipOperator;
10188 * We need this JSDoc comment for affecting ESDoc.
10190 * @extends {Ignored}
10192 var SkipSubscriber = (function (_super) {
10193 __extends(SkipSubscriber, _super);
10194 function SkipSubscriber(destination, total) {
10195 _super.call(this, destination);
10196 this.total = total;
10199 SkipSubscriber.prototype._next = function (x) {
10200 if (++this.count > this.total) {
10201 this.destination.next(x);
10204 return SkipSubscriber;
10205 }(Subscriber_1.Subscriber));
10207 },{"../Subscriber":35}],126:[function(require,module,exports){
10209 var __extends = (this && this.__extends) || function (d, b) {
10210 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
10211 function __() { this.constructor = d; }
10212 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
10214 var OuterSubscriber_1 = require('../OuterSubscriber');
10215 var subscribeToResult_1 = require('../util/subscribeToResult');
10217 * Returns an Observable that skips items emitted by the source Observable until a second Observable emits an item.
10219 * <img src="./img/skipUntil.png" width="100%">
10221 * @param {Observable} the second Observable that has to emit an item before the source Observable's elements begin to
10222 * be mirrored by the resulting Observable.
10223 * @return {Observable<T>} an Observable that skips items from the source Observable until the second Observable emits
10224 * an item, then emits the remaining items.
10225 * @method skipUntil
10226 * @owner Observable
10228 function skipUntil(notifier) {
10229 return this.lift(new SkipUntilOperator(notifier));
10231 exports.skipUntil = skipUntil;
10232 var SkipUntilOperator = (function () {
10233 function SkipUntilOperator(notifier) {
10234 this.notifier = notifier;
10236 SkipUntilOperator.prototype.call = function (subscriber, source) {
10237 return source._subscribe(new SkipUntilSubscriber(subscriber, this.notifier));
10239 return SkipUntilOperator;
10242 * We need this JSDoc comment for affecting ESDoc.
10244 * @extends {Ignored}
10246 var SkipUntilSubscriber = (function (_super) {
10247 __extends(SkipUntilSubscriber, _super);
10248 function SkipUntilSubscriber(destination, notifier) {
10249 _super.call(this, destination);
10250 this.hasValue = false;
10251 this.isInnerStopped = false;
10252 this.add(subscribeToResult_1.subscribeToResult(this, notifier));
10254 SkipUntilSubscriber.prototype._next = function (value) {
10255 if (this.hasValue) {
10256 _super.prototype._next.call(this, value);
10259 SkipUntilSubscriber.prototype._complete = function () {
10260 if (this.isInnerStopped) {
10261 _super.prototype._complete.call(this);
10264 this.unsubscribe();
10267 SkipUntilSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
10268 this.hasValue = true;
10270 SkipUntilSubscriber.prototype.notifyComplete = function () {
10271 this.isInnerStopped = true;
10272 if (this.isStopped) {
10273 _super.prototype._complete.call(this);
10276 return SkipUntilSubscriber;
10277 }(OuterSubscriber_1.OuterSubscriber));
10279 },{"../OuterSubscriber":30,"../util/subscribeToResult":154}],127:[function(require,module,exports){
10281 var ArrayObservable_1 = require('../observable/ArrayObservable');
10282 var ScalarObservable_1 = require('../observable/ScalarObservable');
10283 var EmptyObservable_1 = require('../observable/EmptyObservable');
10284 var concat_1 = require('./concat');
10285 var isScheduler_1 = require('../util/isScheduler');
10287 * Returns an Observable that emits the items in a specified Iterable before it begins to emit items emitted by the
10288 * source Observable.
10290 * <img src="./img/startWith.png" width="100%">
10292 * @param {Values} an Iterable that contains the items you want the modified Observable to emit first.
10293 * @return {Observable} an Observable that emits the items in the specified Iterable and then emits the items
10294 * emitted by the source Observable.
10295 * @method startWith
10296 * @owner Observable
10298 function startWith() {
10300 for (var _i = 0; _i < arguments.length; _i++) {
10301 array[_i - 0] = arguments[_i];
10303 var scheduler = array[array.length - 1];
10304 if (isScheduler_1.isScheduler(scheduler)) {
10310 var len = array.length;
10312 return concat_1.concatStatic(new ScalarObservable_1.ScalarObservable(array[0], scheduler), this);
10314 else if (len > 1) {
10315 return concat_1.concatStatic(new ArrayObservable_1.ArrayObservable(array, scheduler), this);
10318 return concat_1.concatStatic(new EmptyObservable_1.EmptyObservable(scheduler), this);
10321 exports.startWith = startWith;
10323 },{"../observable/ArrayObservable":79,"../observable/EmptyObservable":82,"../observable/ScalarObservable":89,"../util/isScheduler":152,"./concat":103}],128:[function(require,module,exports){
10325 var __extends = (this && this.__extends) || function (d, b) {
10326 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
10327 function __() { this.constructor = d; }
10328 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
10330 var OuterSubscriber_1 = require('../OuterSubscriber');
10331 var subscribeToResult_1 = require('../util/subscribeToResult');
10333 * Projects each source value to an Observable which is merged in the output
10334 * Observable, emitting values only from the most recently projected Observable.
10336 * <span class="informal">Maps each value to an Observable, then flattens all of
10337 * these inner Observables using {@link switch}.</span>
10339 * <img src="./img/switchMap.png" width="100%">
10341 * Returns an Observable that emits items based on applying a function that you
10342 * supply to each item emitted by the source Observable, where that function
10343 * returns an (so-called "inner") Observable. Each time it observes one of these
10344 * inner Observables, the output Observable begins emitting the items emitted by
10345 * that inner Observable. When a new inner Observable is emitted, `switchMap`
10346 * stops emitting items from the earlier-emitted inner Observable and begins
10347 * emitting items from the new one. It continues to behave like this for
10348 * subsequent inner Observables.
10350 * @example <caption>Rerun an interval Observable on every click event</caption>
10351 * var clicks = Rx.Observable.fromEvent(document, 'click');
10352 * var result = clicks.switchMap((ev) => Rx.Observable.interval(1000));
10353 * result.subscribe(x => console.log(x));
10355 * @see {@link concatMap}
10356 * @see {@link exhaustMap}
10357 * @see {@link mergeMap}
10358 * @see {@link switch}
10359 * @see {@link switchMapTo}
10361 * @param {function(value: T, ?index: number): Observable} project A function
10362 * that, when applied to an item emitted by the source Observable, returns an
10364 * @param {function(outerValue: T, innerValue: I, outerIndex: number, innerIndex: number): any} [resultSelector]
10365 * A function to produce the value on the output Observable based on the values
10366 * and the indices of the source (outer) emission and the inner Observable
10367 * emission. The arguments passed to this function are:
10368 * - `outerValue`: the value that came from the source
10369 * - `innerValue`: the value that came from the projected Observable
10370 * - `outerIndex`: the "index" of the value that came from the source
10371 * - `innerIndex`: the "index" of the value from the projected Observable
10372 * @return {Observable} An Observable that emits the result of applying the
10373 * projection function (and the optional `resultSelector`) to each item emitted
10374 * by the source Observable and taking only the values from the most recently
10375 * projected inner Observable.
10376 * @method switchMap
10377 * @owner Observable
10379 function switchMap(project, resultSelector) {
10380 return this.lift(new SwitchMapOperator(project, resultSelector));
10382 exports.switchMap = switchMap;
10383 var SwitchMapOperator = (function () {
10384 function SwitchMapOperator(project, resultSelector) {
10385 this.project = project;
10386 this.resultSelector = resultSelector;
10388 SwitchMapOperator.prototype.call = function (subscriber, source) {
10389 return source._subscribe(new SwitchMapSubscriber(subscriber, this.project, this.resultSelector));
10391 return SwitchMapOperator;
10394 * We need this JSDoc comment for affecting ESDoc.
10396 * @extends {Ignored}
10398 var SwitchMapSubscriber = (function (_super) {
10399 __extends(SwitchMapSubscriber, _super);
10400 function SwitchMapSubscriber(destination, project, resultSelector) {
10401 _super.call(this, destination);
10402 this.project = project;
10403 this.resultSelector = resultSelector;
10406 SwitchMapSubscriber.prototype._next = function (value) {
10408 var index = this.index++;
10410 result = this.project(value, index);
10413 this.destination.error(error);
10416 this._innerSub(result, value, index);
10418 SwitchMapSubscriber.prototype._innerSub = function (result, value, index) {
10419 var innerSubscription = this.innerSubscription;
10420 if (innerSubscription) {
10421 innerSubscription.unsubscribe();
10423 this.add(this.innerSubscription = subscribeToResult_1.subscribeToResult(this, result, value, index));
10425 SwitchMapSubscriber.prototype._complete = function () {
10426 var innerSubscription = this.innerSubscription;
10427 if (!innerSubscription || innerSubscription.closed) {
10428 _super.prototype._complete.call(this);
10431 SwitchMapSubscriber.prototype._unsubscribe = function () {
10432 this.innerSubscription = null;
10434 SwitchMapSubscriber.prototype.notifyComplete = function (innerSub) {
10435 this.remove(innerSub);
10436 this.innerSubscription = null;
10437 if (this.isStopped) {
10438 _super.prototype._complete.call(this);
10441 SwitchMapSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
10442 if (this.resultSelector) {
10443 this._tryNotifyNext(outerValue, innerValue, outerIndex, innerIndex);
10446 this.destination.next(innerValue);
10449 SwitchMapSubscriber.prototype._tryNotifyNext = function (outerValue, innerValue, outerIndex, innerIndex) {
10452 result = this.resultSelector(outerValue, innerValue, outerIndex, innerIndex);
10455 this.destination.error(err);
10458 this.destination.next(result);
10460 return SwitchMapSubscriber;
10461 }(OuterSubscriber_1.OuterSubscriber));
10463 },{"../OuterSubscriber":30,"../util/subscribeToResult":154}],129:[function(require,module,exports){
10465 var __extends = (this && this.__extends) || function (d, b) {
10466 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
10467 function __() { this.constructor = d; }
10468 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
10470 var Subscriber_1 = require('../Subscriber');
10471 var ArgumentOutOfRangeError_1 = require('../util/ArgumentOutOfRangeError');
10472 var EmptyObservable_1 = require('../observable/EmptyObservable');
10474 * Emits only the first `count` values emitted by the source Observable.
10476 * <span class="informal">Takes the first `count` values from the source, then
10477 * completes.</span>
10479 * <img src="./img/take.png" width="100%">
10481 * `take` returns an Observable that emits only the first `count` values emitted
10482 * by the source Observable. If the source emits fewer than `count` values then
10483 * all of its values are emitted. After that, it completes, regardless if the
10484 * source completes.
10486 * @example <caption>Take the first 5 seconds of an infinite 1-second interval Observable</caption>
10487 * var interval = Rx.Observable.interval(1000);
10488 * var five = interval.take(5);
10489 * five.subscribe(x => console.log(x));
10491 * @see {@link takeLast}
10492 * @see {@link takeUntil}
10493 * @see {@link takeWhile}
10494 * @see {@link skip}
10496 * @throws {ArgumentOutOfRangeError} When using `take(i)`, it delivers an
10497 * ArgumentOutOrRangeError to the Observer's `error` callback if `i < 0`.
10499 * @param {number} count The maximum number of `next` values to emit.
10500 * @return {Observable<T>} An Observable that emits only the first `count`
10501 * values emitted by the source Observable, or all of the values from the source
10502 * if the source emits fewer than `count` values.
10504 * @owner Observable
10506 function take(count) {
10508 return new EmptyObservable_1.EmptyObservable();
10511 return this.lift(new TakeOperator(count));
10514 exports.take = take;
10515 var TakeOperator = (function () {
10516 function TakeOperator(total) {
10517 this.total = total;
10518 if (this.total < 0) {
10519 throw new ArgumentOutOfRangeError_1.ArgumentOutOfRangeError;
10522 TakeOperator.prototype.call = function (subscriber, source) {
10523 return source._subscribe(new TakeSubscriber(subscriber, this.total));
10525 return TakeOperator;
10528 * We need this JSDoc comment for affecting ESDoc.
10530 * @extends {Ignored}
10532 var TakeSubscriber = (function (_super) {
10533 __extends(TakeSubscriber, _super);
10534 function TakeSubscriber(destination, total) {
10535 _super.call(this, destination);
10536 this.total = total;
10539 TakeSubscriber.prototype._next = function (value) {
10540 var total = this.total;
10541 if (++this.count <= total) {
10542 this.destination.next(value);
10543 if (this.count === total) {
10544 this.destination.complete();
10545 this.unsubscribe();
10549 return TakeSubscriber;
10550 }(Subscriber_1.Subscriber));
10552 },{"../Subscriber":35,"../observable/EmptyObservable":82,"../util/ArgumentOutOfRangeError":143}],130:[function(require,module,exports){
10554 var __extends = (this && this.__extends) || function (d, b) {
10555 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
10556 function __() { this.constructor = d; }
10557 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
10559 var OuterSubscriber_1 = require('../OuterSubscriber');
10560 var subscribeToResult_1 = require('../util/subscribeToResult');
10562 * Emits the values emitted by the source Observable until a `notifier`
10563 * Observable emits a value.
10565 * <span class="informal">Lets values pass until a second Observable,
10566 * `notifier`, emits something. Then, it completes.</span>
10568 * <img src="./img/takeUntil.png" width="100%">
10570 * `takeUntil` subscribes and begins mirroring the source Observable. It also
10571 * monitors a second Observable, `notifier` that you provide. If the `notifier`
10572 * emits a value or a complete notification, the output Observable stops
10573 * mirroring the source Observable and completes.
10575 * @example <caption>Tick every second until the first click happens</caption>
10576 * var interval = Rx.Observable.interval(1000);
10577 * var clicks = Rx.Observable.fromEvent(document, 'click');
10578 * var result = interval.takeUntil(clicks);
10579 * result.subscribe(x => console.log(x));
10581 * @see {@link take}
10582 * @see {@link takeLast}
10583 * @see {@link takeWhile}
10584 * @see {@link skip}
10586 * @param {Observable} notifier The Observable whose first emitted value will
10587 * cause the output Observable of `takeUntil` to stop emitting values from the
10588 * source Observable.
10589 * @return {Observable<T>} An Observable that emits the values from the source
10590 * Observable until such time as `notifier` emits its first value.
10591 * @method takeUntil
10592 * @owner Observable
10594 function takeUntil(notifier) {
10595 return this.lift(new TakeUntilOperator(notifier));
10597 exports.takeUntil = takeUntil;
10598 var TakeUntilOperator = (function () {
10599 function TakeUntilOperator(notifier) {
10600 this.notifier = notifier;
10602 TakeUntilOperator.prototype.call = function (subscriber, source) {
10603 return source._subscribe(new TakeUntilSubscriber(subscriber, this.notifier));
10605 return TakeUntilOperator;
10608 * We need this JSDoc comment for affecting ESDoc.
10610 * @extends {Ignored}
10612 var TakeUntilSubscriber = (function (_super) {
10613 __extends(TakeUntilSubscriber, _super);
10614 function TakeUntilSubscriber(destination, notifier) {
10615 _super.call(this, destination);
10616 this.notifier = notifier;
10617 this.add(subscribeToResult_1.subscribeToResult(this, notifier));
10619 TakeUntilSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
10622 TakeUntilSubscriber.prototype.notifyComplete = function () {
10625 return TakeUntilSubscriber;
10626 }(OuterSubscriber_1.OuterSubscriber));
10628 },{"../OuterSubscriber":30,"../util/subscribeToResult":154}],131:[function(require,module,exports){
10630 var __extends = (this && this.__extends) || function (d, b) {
10631 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
10632 function __() { this.constructor = d; }
10633 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
10635 var OuterSubscriber_1 = require('../OuterSubscriber');
10636 var subscribeToResult_1 = require('../util/subscribeToResult');
10638 * Combines the source Observable with other Observables to create an Observable
10639 * whose values are calculated from the latest values of each, only when the
10642 * <span class="informal">Whenever the source Observable emits a value, it
10643 * computes a formula using that value plus the latest values from other input
10644 * Observables, then emits the output of that formula.</span>
10646 * <img src="./img/withLatestFrom.png" width="100%">
10648 * `withLatestFrom` combines each value from the source Observable (the
10649 * instance) with the latest values from the other input Observables only when
10650 * the source emits a value, optionally using a `project` function to determine
10651 * the value to be emitted on the output Observable. All input Observables must
10652 * emit at least one value before the output Observable will emit a value.
10654 * @example <caption>On every click event, emit an array with the latest timer event plus the click event</caption>
10655 * var clicks = Rx.Observable.fromEvent(document, 'click');
10656 * var timer = Rx.Observable.interval(1000);
10657 * var result = clicks.withLatestFrom(timer);
10658 * result.subscribe(x => console.log(x));
10660 * @see {@link combineLatest}
10662 * @param {Observable} other An input Observable to combine with the source
10663 * Observable. More than one input Observables may be given as argument.
10664 * @param {Function} [project] Projection function for combining values
10665 * together. Receives all values in order of the Observables passed, where the
10666 * first parameter is a value from the source Observable. (e.g.
10667 * `a.withLatestFrom(b, c, (a1, b1, c1) => a1 + b1 + c1)`). If this is not
10668 * passed, arrays will be emitted on the output Observable.
10669 * @return {Observable} An Observable of projected values from the most recent
10670 * values from each input Observable, or an array of the most recent values from
10671 * each input Observable.
10672 * @method withLatestFrom
10673 * @owner Observable
10675 function withLatestFrom() {
10677 for (var _i = 0; _i < arguments.length; _i++) {
10678 args[_i - 0] = arguments[_i];
10681 if (typeof args[args.length - 1] === 'function') {
10682 project = args.pop();
10684 var observables = args;
10685 return this.lift(new WithLatestFromOperator(observables, project));
10687 exports.withLatestFrom = withLatestFrom;
10688 /* tslint:enable:max-line-length */
10689 var WithLatestFromOperator = (function () {
10690 function WithLatestFromOperator(observables, project) {
10691 this.observables = observables;
10692 this.project = project;
10694 WithLatestFromOperator.prototype.call = function (subscriber, source) {
10695 return source._subscribe(new WithLatestFromSubscriber(subscriber, this.observables, this.project));
10697 return WithLatestFromOperator;
10700 * We need this JSDoc comment for affecting ESDoc.
10702 * @extends {Ignored}
10704 var WithLatestFromSubscriber = (function (_super) {
10705 __extends(WithLatestFromSubscriber, _super);
10706 function WithLatestFromSubscriber(destination, observables, project) {
10707 _super.call(this, destination);
10708 this.observables = observables;
10709 this.project = project;
10710 this.toRespond = [];
10711 var len = observables.length;
10712 this.values = new Array(len);
10713 for (var i = 0; i < len; i++) {
10714 this.toRespond.push(i);
10716 for (var i = 0; i < len; i++) {
10717 var observable = observables[i];
10718 this.add(subscribeToResult_1.subscribeToResult(this, observable, observable, i));
10721 WithLatestFromSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
10722 this.values[outerIndex] = innerValue;
10723 var toRespond = this.toRespond;
10724 if (toRespond.length > 0) {
10725 var found = toRespond.indexOf(outerIndex);
10726 if (found !== -1) {
10727 toRespond.splice(found, 1);
10731 WithLatestFromSubscriber.prototype.notifyComplete = function () {
10734 WithLatestFromSubscriber.prototype._next = function (value) {
10735 if (this.toRespond.length === 0) {
10736 var args = [value].concat(this.values);
10737 if (this.project) {
10738 this._tryProject(args);
10741 this.destination.next(args);
10745 WithLatestFromSubscriber.prototype._tryProject = function (args) {
10748 result = this.project.apply(this, args);
10751 this.destination.error(err);
10754 this.destination.next(result);
10756 return WithLatestFromSubscriber;
10757 }(OuterSubscriber_1.OuterSubscriber));
10759 },{"../OuterSubscriber":30,"../util/subscribeToResult":154}],132:[function(require,module,exports){
10761 var __extends = (this && this.__extends) || function (d, b) {
10762 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
10763 function __() { this.constructor = d; }
10764 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
10766 var ArrayObservable_1 = require('../observable/ArrayObservable');
10767 var isArray_1 = require('../util/isArray');
10768 var Subscriber_1 = require('../Subscriber');
10769 var OuterSubscriber_1 = require('../OuterSubscriber');
10770 var subscribeToResult_1 = require('../util/subscribeToResult');
10771 var iterator_1 = require('../symbol/iterator');
10773 * @param observables
10774 * @return {Observable<R>}
10776 * @owner Observable
10778 function zipProto() {
10779 var observables = [];
10780 for (var _i = 0; _i < arguments.length; _i++) {
10781 observables[_i - 0] = arguments[_i];
10783 observables.unshift(this);
10784 return zipStatic.apply(this, observables);
10786 exports.zipProto = zipProto;
10787 /* tslint:enable:max-line-length */
10789 * @param observables
10790 * @return {Observable<R>}
10793 * @owner Observable
10795 function zipStatic() {
10796 var observables = [];
10797 for (var _i = 0; _i < arguments.length; _i++) {
10798 observables[_i - 0] = arguments[_i];
10800 var project = observables[observables.length - 1];
10801 if (typeof project === 'function') {
10804 return new ArrayObservable_1.ArrayObservable(observables).lift(new ZipOperator(project));
10806 exports.zipStatic = zipStatic;
10807 var ZipOperator = (function () {
10808 function ZipOperator(project) {
10809 this.project = project;
10811 ZipOperator.prototype.call = function (subscriber, source) {
10812 return source._subscribe(new ZipSubscriber(subscriber, this.project));
10814 return ZipOperator;
10816 exports.ZipOperator = ZipOperator;
10818 * We need this JSDoc comment for affecting ESDoc.
10820 * @extends {Ignored}
10822 var ZipSubscriber = (function (_super) {
10823 __extends(ZipSubscriber, _super);
10824 function ZipSubscriber(destination, project, values) {
10825 if (values === void 0) { values = Object.create(null); }
10826 _super.call(this, destination);
10828 this.iterators = [];
10830 this.project = (typeof project === 'function') ? project : null;
10831 this.values = values;
10833 ZipSubscriber.prototype._next = function (value) {
10834 var iterators = this.iterators;
10835 var index = this.index++;
10836 if (isArray_1.isArray(value)) {
10837 iterators.push(new StaticArrayIterator(value));
10839 else if (typeof value[iterator_1.$$iterator] === 'function') {
10840 iterators.push(new StaticIterator(value[iterator_1.$$iterator]()));
10843 iterators.push(new ZipBufferIterator(this.destination, this, value, index));
10846 ZipSubscriber.prototype._complete = function () {
10847 var iterators = this.iterators;
10848 var len = iterators.length;
10850 for (var i = 0; i < len; i++) {
10851 var iterator = iterators[i];
10852 if (iterator.stillUnsubscribed) {
10853 this.add(iterator.subscribe(iterator, i));
10856 this.active--; // not an observable
10860 ZipSubscriber.prototype.notifyInactive = function () {
10862 if (this.active === 0) {
10863 this.destination.complete();
10866 ZipSubscriber.prototype.checkIterators = function () {
10867 var iterators = this.iterators;
10868 var len = iterators.length;
10869 var destination = this.destination;
10870 // abort if not all of them have values
10871 for (var i = 0; i < len; i++) {
10872 var iterator = iterators[i];
10873 if (typeof iterator.hasValue === 'function' && !iterator.hasValue()) {
10877 var shouldComplete = false;
10879 for (var i = 0; i < len; i++) {
10880 var iterator = iterators[i];
10881 var result = iterator.next();
10882 // check to see if it's completed now that you've gotten
10884 if (iterator.hasCompleted()) {
10885 shouldComplete = true;
10888 destination.complete();
10891 args.push(result.value);
10893 if (this.project) {
10894 this._tryProject(args);
10897 destination.next(args);
10899 if (shouldComplete) {
10900 destination.complete();
10903 ZipSubscriber.prototype._tryProject = function (args) {
10906 result = this.project.apply(this, args);
10909 this.destination.error(err);
10912 this.destination.next(result);
10914 return ZipSubscriber;
10915 }(Subscriber_1.Subscriber));
10916 exports.ZipSubscriber = ZipSubscriber;
10917 var StaticIterator = (function () {
10918 function StaticIterator(iterator) {
10919 this.iterator = iterator;
10920 this.nextResult = iterator.next();
10922 StaticIterator.prototype.hasValue = function () {
10925 StaticIterator.prototype.next = function () {
10926 var result = this.nextResult;
10927 this.nextResult = this.iterator.next();
10930 StaticIterator.prototype.hasCompleted = function () {
10931 var nextResult = this.nextResult;
10932 return nextResult && nextResult.done;
10934 return StaticIterator;
10936 var StaticArrayIterator = (function () {
10937 function StaticArrayIterator(array) {
10938 this.array = array;
10941 this.length = array.length;
10943 StaticArrayIterator.prototype[iterator_1.$$iterator] = function () {
10946 StaticArrayIterator.prototype.next = function (value) {
10947 var i = this.index++;
10948 var array = this.array;
10949 return i < this.length ? { value: array[i], done: false } : { value: null, done: true };
10951 StaticArrayIterator.prototype.hasValue = function () {
10952 return this.array.length > this.index;
10954 StaticArrayIterator.prototype.hasCompleted = function () {
10955 return this.array.length === this.index;
10957 return StaticArrayIterator;
10960 * We need this JSDoc comment for affecting ESDoc.
10962 * @extends {Ignored}
10964 var ZipBufferIterator = (function (_super) {
10965 __extends(ZipBufferIterator, _super);
10966 function ZipBufferIterator(destination, parent, observable, index) {
10967 _super.call(this, destination);
10968 this.parent = parent;
10969 this.observable = observable;
10970 this.index = index;
10971 this.stillUnsubscribed = true;
10973 this.isComplete = false;
10975 ZipBufferIterator.prototype[iterator_1.$$iterator] = function () {
10978 // NOTE: there is actually a name collision here with Subscriber.next and Iterator.next
10979 // this is legit because `next()` will never be called by a subscription in this case.
10980 ZipBufferIterator.prototype.next = function () {
10981 var buffer = this.buffer;
10982 if (buffer.length === 0 && this.isComplete) {
10983 return { value: null, done: true };
10986 return { value: buffer.shift(), done: false };
10989 ZipBufferIterator.prototype.hasValue = function () {
10990 return this.buffer.length > 0;
10992 ZipBufferIterator.prototype.hasCompleted = function () {
10993 return this.buffer.length === 0 && this.isComplete;
10995 ZipBufferIterator.prototype.notifyComplete = function () {
10996 if (this.buffer.length > 0) {
10997 this.isComplete = true;
10998 this.parent.notifyInactive();
11001 this.destination.complete();
11004 ZipBufferIterator.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
11005 this.buffer.push(innerValue);
11006 this.parent.checkIterators();
11008 ZipBufferIterator.prototype.subscribe = function (value, index) {
11009 return subscribeToResult_1.subscribeToResult(this, this.observable, this, index);
11011 return ZipBufferIterator;
11012 }(OuterSubscriber_1.OuterSubscriber));
11014 },{"../OuterSubscriber":30,"../Subscriber":35,"../observable/ArrayObservable":79,"../symbol/iterator":140,"../util/isArray":148,"../util/subscribeToResult":154}],133:[function(require,module,exports){
11016 var __extends = (this && this.__extends) || function (d, b) {
11017 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
11018 function __() { this.constructor = d; }
11019 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
11021 var Subscription_1 = require('../Subscription');
11023 * A unit of work to be executed in a {@link Scheduler}. An action is typically
11024 * created from within a Scheduler and an RxJS user does not need to concern
11025 * themselves about creating and manipulating an Action.
11028 * class Action<T> extends Subscription {
11029 * new (scheduler: Scheduler, work: (state?: T) => void);
11030 * schedule(state?: T, delay: number = 0): Subscription;
11036 var Action = (function (_super) {
11037 __extends(Action, _super);
11038 function Action(scheduler, work) {
11042 * Schedules this action on its parent Scheduler for execution. May be passed
11043 * some context object, `state`. May happen at some point in the future,
11044 * according to the `delay` parameter, if specified.
11045 * @param {T} [state] Some contextual data that the `work` function uses when
11046 * called by the Scheduler.
11047 * @param {number} [delay] Time to wait before executing the work, where the
11048 * time unit is implicit and defined by the Scheduler.
11051 Action.prototype.schedule = function (state, delay) {
11052 if (delay === void 0) { delay = 0; }
11056 }(Subscription_1.Subscription));
11057 exports.Action = Action;
11059 },{"../Subscription":36}],134:[function(require,module,exports){
11061 var __extends = (this && this.__extends) || function (d, b) {
11062 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
11063 function __() { this.constructor = d; }
11064 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
11066 var root_1 = require('../util/root');
11067 var Action_1 = require('./Action');
11069 * We need this JSDoc comment for affecting ESDoc.
11071 * @extends {Ignored}
11073 var AsyncAction = (function (_super) {
11074 __extends(AsyncAction, _super);
11075 function AsyncAction(scheduler, work) {
11076 _super.call(this, scheduler, work);
11077 this.scheduler = scheduler;
11079 this.pending = false;
11081 AsyncAction.prototype.schedule = function (state, delay) {
11082 if (delay === void 0) { delay = 0; }
11086 // Always replace the current state with the new state.
11087 this.state = state;
11088 // Set the pending flag indicating that this action has been scheduled, or
11089 // has recursively rescheduled itself.
11090 this.pending = true;
11092 var scheduler = this.scheduler;
11094 // Important implementation note:
11096 // Actions only execute once by default, unless rescheduled from within the
11097 // scheduled callback. This allows us to implement single and repeat
11098 // actions via the same code path, without adding API surface area, as well
11099 // as mimic traditional recursion but across asynchronous boundaries.
11101 // However, JS runtimes and timers distinguish between intervals achieved by
11102 // serial `setTimeout` calls vs. a single `setInterval` call. An interval of
11103 // serial `setTimeout` calls can be individually delayed, which delays
11104 // scheduling the next `setTimeout`, and so on. `setInterval` attempts to
11105 // guarantee the interval callback will be invoked more precisely to the
11106 // interval period, regardless of load.
11108 // Therefore, we use `setInterval` to schedule single and repeat actions.
11109 // If the action reschedules itself with the same delay, the interval is not
11110 // canceled. If the action doesn't reschedule, or reschedules with a
11111 // different delay, the interval will be canceled after scheduled callback
11115 this.id = this.recycleAsyncId(scheduler, id, delay);
11117 this.delay = delay;
11118 // If this action has already an async Id, don't request a new one.
11119 this.id = this.id || this.requestAsyncId(scheduler, this.id, delay);
11122 AsyncAction.prototype.requestAsyncId = function (scheduler, id, delay) {
11123 if (delay === void 0) { delay = 0; }
11124 return root_1.root.setInterval(scheduler.flush.bind(scheduler, this), delay);
11126 AsyncAction.prototype.recycleAsyncId = function (scheduler, id, delay) {
11127 if (delay === void 0) { delay = 0; }
11128 // If this action is rescheduled with the same delay time, don't clear the interval id.
11129 if (delay !== null && this.delay === delay) {
11132 // Otherwise, if the action's delay time is different from the current delay,
11133 // clear the interval id
11134 return root_1.root.clearInterval(id) && undefined || undefined;
11137 * Immediately executes this action and the `work` it contains.
11140 AsyncAction.prototype.execute = function (state, delay) {
11142 return new Error('executing a cancelled action');
11144 this.pending = false;
11145 var error = this._execute(state, delay);
11149 else if (this.pending === false && this.id != null) {
11150 // Dequeue if the action didn't reschedule itself. Don't call
11151 // unsubscribe(), because the action could reschedule later.
11154 // scheduler.schedule(function doWork(counter) {
11155 // /* ... I'm a busy worker bee ... */
11156 // var originalAction = this;
11157 // /* wait 100ms before rescheduling the action */
11158 // setTimeout(function () {
11159 // originalAction.schedule(counter + 1);
11163 this.id = this.recycleAsyncId(this.scheduler, this.id, null);
11166 AsyncAction.prototype._execute = function (state, delay) {
11167 var errored = false;
11168 var errorValue = undefined;
11174 errorValue = !!e && e || new Error(e);
11177 this.unsubscribe();
11181 AsyncAction.prototype._unsubscribe = function () {
11183 var scheduler = this.scheduler;
11184 var actions = scheduler.actions;
11185 var index = actions.indexOf(this);
11189 this.pending = false;
11190 this.scheduler = null;
11191 if (index !== -1) {
11192 actions.splice(index, 1);
11195 this.id = this.recycleAsyncId(scheduler, id, null);
11198 return AsyncAction;
11199 }(Action_1.Action));
11200 exports.AsyncAction = AsyncAction;
11202 },{"../util/root":153,"./Action":133}],135:[function(require,module,exports){
11204 var __extends = (this && this.__extends) || function (d, b) {
11205 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
11206 function __() { this.constructor = d; }
11207 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
11209 var Scheduler_1 = require('../Scheduler');
11210 var AsyncScheduler = (function (_super) {
11211 __extends(AsyncScheduler, _super);
11212 function AsyncScheduler() {
11213 _super.apply(this, arguments);
11216 * A flag to indicate whether the Scheduler is currently executing a batch of
11220 this.active = false;
11222 * An internal ID used to track the latest asynchronous task such as those
11223 * coming from `setTimeout`, `setInterval`, `requestAnimationFrame`, and
11227 this.scheduled = undefined;
11229 AsyncScheduler.prototype.flush = function (action) {
11230 var actions = this.actions;
11232 actions.push(action);
11236 this.active = true;
11238 if (error = action.execute(action.state, action.delay)) {
11241 } while (action = actions.shift()); // exhaust the scheduler queue
11242 this.active = false;
11244 while (action = actions.shift()) {
11245 action.unsubscribe();
11250 return AsyncScheduler;
11251 }(Scheduler_1.Scheduler));
11252 exports.AsyncScheduler = AsyncScheduler;
11254 },{"../Scheduler":32}],136:[function(require,module,exports){
11256 var __extends = (this && this.__extends) || function (d, b) {
11257 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
11258 function __() { this.constructor = d; }
11259 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
11261 var AsyncAction_1 = require('./AsyncAction');
11263 * We need this JSDoc comment for affecting ESDoc.
11265 * @extends {Ignored}
11267 var QueueAction = (function (_super) {
11268 __extends(QueueAction, _super);
11269 function QueueAction(scheduler, work) {
11270 _super.call(this, scheduler, work);
11271 this.scheduler = scheduler;
11274 QueueAction.prototype.schedule = function (state, delay) {
11275 if (delay === void 0) { delay = 0; }
11277 return _super.prototype.schedule.call(this, state, delay);
11279 this.delay = delay;
11280 this.state = state;
11281 this.scheduler.flush(this);
11284 QueueAction.prototype.execute = function (state, delay) {
11285 return (delay > 0 || this.closed) ?
11286 _super.prototype.execute.call(this, state, delay) :
11287 this._execute(state, delay);
11289 QueueAction.prototype.requestAsyncId = function (scheduler, id, delay) {
11290 if (delay === void 0) { delay = 0; }
11291 // If delay is greater than 0, enqueue as an async action.
11292 if (delay !== null && delay > 0) {
11293 return _super.prototype.requestAsyncId.call(this, scheduler, id, delay);
11295 // Otherwise flush the scheduler starting with this action.
11296 return scheduler.flush(this);
11298 return QueueAction;
11299 }(AsyncAction_1.AsyncAction));
11300 exports.QueueAction = QueueAction;
11302 },{"./AsyncAction":134}],137:[function(require,module,exports){
11304 var __extends = (this && this.__extends) || function (d, b) {
11305 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
11306 function __() { this.constructor = d; }
11307 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
11309 var AsyncScheduler_1 = require('./AsyncScheduler');
11310 var QueueScheduler = (function (_super) {
11311 __extends(QueueScheduler, _super);
11312 function QueueScheduler() {
11313 _super.apply(this, arguments);
11315 return QueueScheduler;
11316 }(AsyncScheduler_1.AsyncScheduler));
11317 exports.QueueScheduler = QueueScheduler;
11319 },{"./AsyncScheduler":135}],138:[function(require,module,exports){
11321 var AsyncAction_1 = require('./AsyncAction');
11322 var AsyncScheduler_1 = require('./AsyncScheduler');
11323 exports.async = new AsyncScheduler_1.AsyncScheduler(AsyncAction_1.AsyncAction);
11325 },{"./AsyncAction":134,"./AsyncScheduler":135}],139:[function(require,module,exports){
11327 var QueueAction_1 = require('./QueueAction');
11328 var QueueScheduler_1 = require('./QueueScheduler');
11329 exports.queue = new QueueScheduler_1.QueueScheduler(QueueAction_1.QueueAction);
11331 },{"./QueueAction":136,"./QueueScheduler":137}],140:[function(require,module,exports){
11333 var root_1 = require('../util/root');
11334 var Symbol = root_1.root.Symbol;
11335 if (typeof Symbol === 'function') {
11336 if (Symbol.iterator) {
11337 exports.$$iterator = Symbol.iterator;
11339 else if (typeof Symbol.for === 'function') {
11340 exports.$$iterator = Symbol.for('iterator');
11344 if (root_1.root.Set && typeof new root_1.root.Set()['@@iterator'] === 'function') {
11345 // Bug for mozilla version
11346 exports.$$iterator = '@@iterator';
11348 else if (root_1.root.Map) {
11349 // es6-shim specific logic
11350 var keys = Object.getOwnPropertyNames(root_1.root.Map.prototype);
11351 for (var i = 0; i < keys.length; ++i) {
11353 if (key !== 'entries' && key !== 'size' && root_1.root.Map.prototype[key] === root_1.root.Map.prototype['entries']) {
11354 exports.$$iterator = key;
11360 exports.$$iterator = '@@iterator';
11364 },{"../util/root":153}],141:[function(require,module,exports){
11366 var root_1 = require('../util/root');
11367 function getSymbolObservable(context) {
11369 var Symbol = context.Symbol;
11370 if (typeof Symbol === 'function') {
11371 if (Symbol.observable) {
11372 $$observable = Symbol.observable;
11375 $$observable = Symbol('observable');
11376 Symbol.observable = $$observable;
11380 $$observable = '@@observable';
11382 return $$observable;
11384 exports.getSymbolObservable = getSymbolObservable;
11385 exports.$$observable = getSymbolObservable(root_1.root);
11387 },{"../util/root":153}],142:[function(require,module,exports){
11389 var root_1 = require('../util/root');
11390 var Symbol = root_1.root.Symbol;
11391 exports.$$rxSubscriber = (typeof Symbol === 'function' && typeof Symbol.for === 'function') ?
11392 Symbol.for('rxSubscriber') : '@@rxSubscriber';
11394 },{"../util/root":153}],143:[function(require,module,exports){
11396 var __extends = (this && this.__extends) || function (d, b) {
11397 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
11398 function __() { this.constructor = d; }
11399 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
11402 * An error thrown when an element was queried at a certain index of an
11403 * Observable, but no such index or position exists in that sequence.
11405 * @see {@link elementAt}
11406 * @see {@link take}
11407 * @see {@link takeLast}
11409 * @class ArgumentOutOfRangeError
11411 var ArgumentOutOfRangeError = (function (_super) {
11412 __extends(ArgumentOutOfRangeError, _super);
11413 function ArgumentOutOfRangeError() {
11414 var err = _super.call(this, 'argument out of range');
11415 this.name = err.name = 'ArgumentOutOfRangeError';
11416 this.stack = err.stack;
11417 this.message = err.message;
11419 return ArgumentOutOfRangeError;
11421 exports.ArgumentOutOfRangeError = ArgumentOutOfRangeError;
11423 },{}],144:[function(require,module,exports){
11425 var __extends = (this && this.__extends) || function (d, b) {
11426 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
11427 function __() { this.constructor = d; }
11428 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
11431 * An error thrown when an Observable or a sequence was queried but has no
11434 * @see {@link first}
11435 * @see {@link last}
11436 * @see {@link single}
11438 * @class EmptyError
11440 var EmptyError = (function (_super) {
11441 __extends(EmptyError, _super);
11442 function EmptyError() {
11443 var err = _super.call(this, 'no elements in sequence');
11444 this.name = err.name = 'EmptyError';
11445 this.stack = err.stack;
11446 this.message = err.message;
11450 exports.EmptyError = EmptyError;
11452 },{}],145:[function(require,module,exports){
11454 var __extends = (this && this.__extends) || function (d, b) {
11455 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
11456 function __() { this.constructor = d; }
11457 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
11460 * An error thrown when an action is invalid because the object has been
11463 * @see {@link Subject}
11464 * @see {@link BehaviorSubject}
11466 * @class ObjectUnsubscribedError
11468 var ObjectUnsubscribedError = (function (_super) {
11469 __extends(ObjectUnsubscribedError, _super);
11470 function ObjectUnsubscribedError() {
11471 var err = _super.call(this, 'object unsubscribed');
11472 this.name = err.name = 'ObjectUnsubscribedError';
11473 this.stack = err.stack;
11474 this.message = err.message;
11476 return ObjectUnsubscribedError;
11478 exports.ObjectUnsubscribedError = ObjectUnsubscribedError;
11480 },{}],146:[function(require,module,exports){
11482 var __extends = (this && this.__extends) || function (d, b) {
11483 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
11484 function __() { this.constructor = d; }
11485 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
11488 * An error thrown when one or more errors have occurred during the
11489 * `unsubscribe` of a {@link Subscription}.
11491 var UnsubscriptionError = (function (_super) {
11492 __extends(UnsubscriptionError, _super);
11493 function UnsubscriptionError(errors) {
11495 this.errors = errors;
11496 var err = Error.call(this, errors ?
11497 errors.length + " errors occurred during unsubscription:\n " + errors.map(function (err, i) { return ((i + 1) + ") " + err.toString()); }).join('\n ') : '');
11498 this.name = err.name = 'UnsubscriptionError';
11499 this.stack = err.stack;
11500 this.message = err.message;
11502 return UnsubscriptionError;
11504 exports.UnsubscriptionError = UnsubscriptionError;
11506 },{}],147:[function(require,module,exports){
11508 // typeof any so that it we don't have to cast when comparing a result to the error object
11509 exports.errorObject = { e: {} };
11511 },{}],148:[function(require,module,exports){
11513 exports.isArray = Array.isArray || (function (x) { return x && typeof x.length === 'number'; });
11515 },{}],149:[function(require,module,exports){
11517 function isFunction(x) {
11518 return typeof x === 'function';
11520 exports.isFunction = isFunction;
11522 },{}],150:[function(require,module,exports){
11524 function isObject(x) {
11525 return x != null && typeof x === 'object';
11527 exports.isObject = isObject;
11529 },{}],151:[function(require,module,exports){
11531 function isPromise(value) {
11532 return value && typeof value.subscribe !== 'function' && typeof value.then === 'function';
11534 exports.isPromise = isPromise;
11536 },{}],152:[function(require,module,exports){
11538 function isScheduler(value) {
11539 return value && typeof value.schedule === 'function';
11541 exports.isScheduler = isScheduler;
11543 },{}],153:[function(require,module,exports){
11544 (function (global){
11546 var objectTypes = {
11554 exports.root = (objectTypes[typeof self] && self) || (objectTypes[typeof window] && window);
11555 var freeGlobal = objectTypes[typeof global] && global;
11556 if (freeGlobal && (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal)) {
11557 exports.root = freeGlobal;
11560 }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
11562 },{}],154:[function(require,module,exports){
11564 var root_1 = require('./root');
11565 var isArray_1 = require('./isArray');
11566 var isPromise_1 = require('./isPromise');
11567 var Observable_1 = require('../Observable');
11568 var iterator_1 = require('../symbol/iterator');
11569 var InnerSubscriber_1 = require('../InnerSubscriber');
11570 var observable_1 = require('../symbol/observable');
11571 function subscribeToResult(outerSubscriber, result, outerValue, outerIndex) {
11572 var destination = new InnerSubscriber_1.InnerSubscriber(outerSubscriber, outerValue, outerIndex);
11573 if (destination.closed) {
11576 if (result instanceof Observable_1.Observable) {
11577 if (result._isScalar) {
11578 destination.next(result.value);
11579 destination.complete();
11583 return result.subscribe(destination);
11586 if (isArray_1.isArray(result)) {
11587 for (var i = 0, len = result.length; i < len && !destination.closed; i++) {
11588 destination.next(result[i]);
11590 if (!destination.closed) {
11591 destination.complete();
11594 else if (isPromise_1.isPromise(result)) {
11595 result.then(function (value) {
11596 if (!destination.closed) {
11597 destination.next(value);
11598 destination.complete();
11600 }, function (err) { return destination.error(err); })
11601 .then(null, function (err) {
11602 // Escaping the Promise trap: globally throw unhandled errors
11603 root_1.root.setTimeout(function () { throw err; });
11605 return destination;
11607 else if (typeof result[iterator_1.$$iterator] === 'function') {
11608 var iterator = result[iterator_1.$$iterator]();
11610 var item = iterator.next();
11612 destination.complete();
11615 destination.next(item.value);
11616 if (destination.closed) {
11621 else if (typeof result[observable_1.$$observable] === 'function') {
11622 var obs = result[observable_1.$$observable]();
11623 if (typeof obs.subscribe !== 'function') {
11624 destination.error(new Error('invalid observable'));
11627 return obs.subscribe(new InnerSubscriber_1.InnerSubscriber(outerSubscriber, outerValue, outerIndex));
11631 destination.error(new TypeError('unknown type returned'));
11635 exports.subscribeToResult = subscribeToResult;
11637 },{"../InnerSubscriber":26,"../Observable":28,"../symbol/iterator":140,"../symbol/observable":141,"./isArray":148,"./isPromise":151,"./root":153}],155:[function(require,module,exports){
11639 var Subscriber_1 = require('../Subscriber');
11640 var rxSubscriber_1 = require('../symbol/rxSubscriber');
11641 function toSubscriber(nextOrObserver, error, complete) {
11642 if (nextOrObserver) {
11643 if (nextOrObserver instanceof Subscriber_1.Subscriber) {
11644 return nextOrObserver;
11646 if (nextOrObserver[rxSubscriber_1.$$rxSubscriber]) {
11647 return nextOrObserver[rxSubscriber_1.$$rxSubscriber]();
11650 if (!nextOrObserver && !error && !complete) {
11651 return new Subscriber_1.Subscriber();
11653 return new Subscriber_1.Subscriber(nextOrObserver, error, complete);
11655 exports.toSubscriber = toSubscriber;
11657 },{"../Subscriber":35,"../symbol/rxSubscriber":142}],156:[function(require,module,exports){
11659 var errorObject_1 = require('./errorObject');
11660 var tryCatchTarget;
11661 function tryCatcher() {
11663 return tryCatchTarget.apply(this, arguments);
11666 errorObject_1.errorObject.e = e;
11667 return errorObject_1.errorObject;
11670 function tryCatch(fn) {
11671 tryCatchTarget = fn;
11674 exports.tryCatch = tryCatch;
11677 },{"./errorObject":147}],157:[function(require,module,exports){
11678 // threejs.org/license
11679 (function(l,sa){"object"===typeof exports&&"undefined"!==typeof module?sa(exports):"function"===typeof define&&define.amd?define(["exports"],sa):sa(l.THREE=l.THREE||{})})(this,function(l){function sa(){}function B(a,b){this.x=a||0;this.y=b||0}function da(a,b,c,d,e,f,g,h,k,m){Object.defineProperty(this,"id",{value:ee++});this.uuid=T.generateUUID();this.sourceFile=this.name="";this.image=void 0!==a?a:da.DEFAULT_IMAGE;this.mipmaps=[];this.mapping=void 0!==b?b:da.DEFAULT_MAPPING;this.wrapS=void 0!==c?
11680 c:1001;this.wrapT=void 0!==d?d:1001;this.magFilter=void 0!==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 B(0,0);this.repeat=new B(1,1);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 ga(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=void 0!==d?d:1}function Db(a,b,c){this.uuid=T.generateUUID();
11681 this.width=a;this.height=b;this.scissor=new ga(0,0,a,b);this.scissorTest=!1;this.viewport=new ga(0,0,a,b);c=c||{};void 0===c.minFilter&&(c.minFilter=1006);this.texture=new da(void 0,void 0,c.wrapS,c.wrapT,c.magFilter,c.minFilter,c.format,c.type,c.anisotropy,c.encoding);this.depthBuffer=void 0!==c.depthBuffer?c.depthBuffer:!0;this.stencilBuffer=void 0!==c.stencilBuffer?c.stencilBuffer:!0;this.depthTexture=void 0!==c.depthTexture?c.depthTexture:null}function Eb(a,b,c){Db.call(this,a,b,c);this.activeMipMapLevel=
11682 this.activeCubeFace=0}function ba(a,b,c,d){this._x=a||0;this._y=b||0;this._z=c||0;this._w=void 0!==d?d:1}function q(a,b,c){this.x=a||0;this.y=b||0;this.z=c||0}function J(){this.elements=new Float32Array([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 Xa(a,b,c,d,e,f,g,h,k,m){a=void 0!==a?a:[];da.call(this,a,void 0!==b?b:301,c,d,e,f,g,h,k,m);this.flipY=!1}function Fb(a,b,c){var d=a[0];if(0>=
11683 d||0<d)return a;var e=b*c,f=fe[e];void 0===f&&(f=new Float32Array(e),fe[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 ge(a,b){var c=he[b];void 0===c&&(c=new Int32Array(b),he[b]=c);for(var d=0;d!==b;++d)c[d]=a.allocTextureUnit();return c}function Ie(a,b){a.uniform1f(this.addr,b)}function Je(a,b){a.uniform1i(this.addr,b)}function Ke(a,b){void 0===b.x?a.uniform2fv(this.addr,b):a.uniform2f(this.addr,b.x,b.y)}function Le(a,b){void 0!==b.x?a.uniform3f(this.addr,
11684 b.x,b.y,b.z):void 0!==b.r?a.uniform3f(this.addr,b.r,b.g,b.b):a.uniform3fv(this.addr,b)}function Me(a,b){void 0===b.x?a.uniform4fv(this.addr,b):a.uniform4f(this.addr,b.x,b.y,b.z,b.w)}function Ne(a,b){a.uniformMatrix2fv(this.addr,!1,b.elements||b)}function Oe(a,b){a.uniformMatrix3fv(this.addr,!1,b.elements||b)}function Pe(a,b){a.uniformMatrix4fv(this.addr,!1,b.elements||b)}function Qe(a,b,c){var d=c.allocTextureUnit();a.uniform1i(this.addr,d);c.setTexture2D(b||ie,d)}function Re(a,b,c){var d=c.allocTextureUnit();
11685 a.uniform1i(this.addr,d);c.setTextureCube(b||je,d)}function ke(a,b){a.uniform2iv(this.addr,b)}function le(a,b){a.uniform3iv(this.addr,b)}function me(a,b){a.uniform4iv(this.addr,b)}function Se(a){switch(a){case 5126:return Ie;case 35664:return Ke;case 35665:return Le;case 35666:return Me;case 35674:return Ne;case 35675:return Oe;case 35676:return Pe;case 35678:return Qe;case 35680:return Re;case 5124:case 35670:return Je;case 35667:case 35671:return ke;case 35668:case 35672:return le;case 35669:case 35673:return me}}
11686 function Te(a,b){a.uniform1fv(this.addr,b)}function Ue(a,b){a.uniform1iv(this.addr,b)}function Ve(a,b){a.uniform2fv(this.addr,Fb(b,this.size,2))}function We(a,b){a.uniform3fv(this.addr,Fb(b,this.size,3))}function Xe(a,b){a.uniform4fv(this.addr,Fb(b,this.size,4))}function Ye(a,b){a.uniformMatrix2fv(this.addr,!1,Fb(b,this.size,4))}function Ze(a,b){a.uniformMatrix3fv(this.addr,!1,Fb(b,this.size,9))}function $e(a,b){a.uniformMatrix4fv(this.addr,!1,Fb(b,this.size,16))}function af(a,b,c){var d=b.length,
11687 e=ge(c,d);a.uniform1iv(this.addr,e);for(a=0;a!==d;++a)c.setTexture2D(b[a]||ie,e[a])}function bf(a,b,c){var d=b.length,e=ge(c,d);a.uniform1iv(this.addr,e);for(a=0;a!==d;++a)c.setTextureCube(b[a]||je,e[a])}function cf(a){switch(a){case 5126:return Te;case 35664:return Ve;case 35665:return We;case 35666:return Xe;case 35674:return Ye;case 35675:return Ze;case 35676:return $e;case 35678:return af;case 35680:return bf;case 5124:case 35670:return Ue;case 35667:case 35671:return ke;case 35668:case 35672:return le;
11688 case 35669:case 35673:return me}}function df(a,b,c){this.id=a;this.addr=c;this.setValue=Se(b.type)}function ef(a,b,c){this.id=a;this.addr=c;this.size=b.size;this.setValue=cf(b.type)}function ne(a){this.id=a;this.seq=[];this.map={}}function Ya(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(zd.lastIndex=0;;){var m=zd.exec(h),w=zd.lastIndex,
11689 n=m[1],p=m[3];"]"===m[2]&&(n|=0);if(void 0===p||"["===p&&w+2===k){h=g;e=void 0===p?new df(n,e,f):new ef(n,e,f);h.seq.push(e);h.map[e.id]=e;break}else p=g.map[n],void 0===p&&(p=new ne(n),n=g,g=p,n.seq.push(g),n.map[g.id]=g),g=p}}}function O(a,b,c){return void 0===b&&void 0===c?this.set(a):this.setRGB(a,b,c)}function mc(a,b){this.min=void 0!==a?a:new B(Infinity,Infinity);this.max=void 0!==b?b:new B(-Infinity,-Infinity)}function ff(a,b){var c,d,e,f,g,h,k,m,w,n,p=a.context,r=a.state,x,l,D,u,v,I;this.render=
11690 function(y,E,H){if(0!==b.length){y=new q;var F=H.w/H.z,M=.5*H.z,ca=.5*H.w,K=16/H.w,ja=new B(K*F,K),Aa=new q(1,1,0),eb=new B(1,1),Ka=new mc;Ka.min.set(H.x,H.y);Ka.max.set(H.x+(H.z-16),H.y+(H.w-16));if(void 0===u){var K=new Float32Array([-1,-1,0,0,1,-1,1,0,1,1,1,1,-1,1,0,1]),N=new Uint16Array([0,1,2,0,2,3]);x=p.createBuffer();l=p.createBuffer();p.bindBuffer(p.ARRAY_BUFFER,x);p.bufferData(p.ARRAY_BUFFER,K,p.STATIC_DRAW);p.bindBuffer(p.ELEMENT_ARRAY_BUFFER,l);p.bufferData(p.ELEMENT_ARRAY_BUFFER,N,p.STATIC_DRAW);
11691 v=p.createTexture();I=p.createTexture();r.bindTexture(p.TEXTURE_2D,v);p.texImage2D(p.TEXTURE_2D,0,p.RGB,16,16,0,p.RGB,p.UNSIGNED_BYTE,null);p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_S,p.CLAMP_TO_EDGE);p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_T,p.CLAMP_TO_EDGE);p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MAG_FILTER,p.NEAREST);p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MIN_FILTER,p.NEAREST);r.bindTexture(p.TEXTURE_2D,I);p.texImage2D(p.TEXTURE_2D,0,p.RGBA,16,16,0,p.RGBA,p.UNSIGNED_BYTE,null);p.texParameteri(p.TEXTURE_2D,
11692 p.TEXTURE_WRAP_S,p.CLAMP_TO_EDGE);p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_T,p.CLAMP_TO_EDGE);p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MAG_FILTER,p.NEAREST);p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MIN_FILTER,p.NEAREST);var K=D={vertexShader:"uniform lowp int renderType;\nuniform vec3 screenPosition;\nuniform vec2 scale;\nuniform float rotation;\nuniform sampler2D occlusionMap;\nattribute vec2 position;\nattribute vec2 uv;\nvarying vec2 vUV;\nvarying float vVisibility;\nvoid main() {\nvUV = uv;\nvec2 pos = position;\nif ( renderType == 2 ) {\nvec4 visibility = texture2D( occlusionMap, vec2( 0.1, 0.1 ) );\nvisibility += texture2D( occlusionMap, vec2( 0.5, 0.1 ) );\nvisibility += texture2D( occlusionMap, vec2( 0.9, 0.1 ) );\nvisibility += texture2D( occlusionMap, vec2( 0.9, 0.5 ) );\nvisibility += texture2D( occlusionMap, vec2( 0.9, 0.9 ) );\nvisibility += texture2D( occlusionMap, vec2( 0.5, 0.9 ) );\nvisibility += texture2D( occlusionMap, vec2( 0.1, 0.9 ) );\nvisibility += texture2D( occlusionMap, vec2( 0.1, 0.5 ) );\nvisibility += texture2D( occlusionMap, vec2( 0.5, 0.5 ) );\nvVisibility = visibility.r / 9.0;\nvVisibility *= 1.0 - visibility.g / 9.0;\nvVisibility *= visibility.b / 9.0;\nvVisibility *= 1.0 - visibility.a / 9.0;\npos.x = cos( rotation ) * position.x - sin( rotation ) * position.y;\npos.y = sin( rotation ) * position.x + cos( rotation ) * position.y;\n}\ngl_Position = vec4( ( pos * scale + screenPosition.xy ).xy, screenPosition.z, 1.0 );\n}",
11693 fragmentShader:"uniform lowp int renderType;\nuniform sampler2D map;\nuniform float opacity;\nuniform vec3 color;\nvarying vec2 vUV;\nvarying float vVisibility;\nvoid main() {\nif ( renderType == 0 ) {\ngl_FragColor = vec4( 1.0, 0.0, 1.0, 0.0 );\n} else if ( renderType == 1 ) {\ngl_FragColor = texture2D( map, vUV );\n} else {\nvec4 texture = texture2D( map, vUV );\ntexture.a *= opacity * vVisibility;\ngl_FragColor = texture;\ngl_FragColor.rgb *= color;\n}\n}"},N=p.createProgram(),P=p.createShader(p.FRAGMENT_SHADER),
11694 R=p.createShader(p.VERTEX_SHADER),S="precision "+a.getPrecision()+" float;\n";p.shaderSource(P,S+K.fragmentShader);p.shaderSource(R,S+K.vertexShader);p.compileShader(P);p.compileShader(R);p.attachShader(N,P);p.attachShader(N,R);p.linkProgram(N);u=N;w=p.getAttribLocation(u,"position");n=p.getAttribLocation(u,"uv");c=p.getUniformLocation(u,"renderType");d=p.getUniformLocation(u,"map");e=p.getUniformLocation(u,"occlusionMap");f=p.getUniformLocation(u,"opacity");g=p.getUniformLocation(u,"color");h=p.getUniformLocation(u,
11695 "scale");k=p.getUniformLocation(u,"rotation");m=p.getUniformLocation(u,"screenPosition")}p.useProgram(u);r.initAttributes();r.enableAttribute(w);r.enableAttribute(n);r.disableUnusedAttributes();p.uniform1i(e,0);p.uniform1i(d,1);p.bindBuffer(p.ARRAY_BUFFER,x);p.vertexAttribPointer(w,2,p.FLOAT,!1,16,0);p.vertexAttribPointer(n,2,p.FLOAT,!1,16,8);p.bindBuffer(p.ELEMENT_ARRAY_BUFFER,l);r.disable(p.CULL_FACE);r.setDepthWrite(!1);N=0;for(P=b.length;N<P;N++)if(K=16/H.w,ja.set(K*F,K),R=b[N],y.set(R.matrixWorld.elements[12],
11696 R.matrixWorld.elements[13],R.matrixWorld.elements[14]),y.applyMatrix4(E.matrixWorldInverse),y.applyProjection(E.projectionMatrix),Aa.copy(y),eb.x=H.x+Aa.x*M+M-8,eb.y=H.y+Aa.y*ca+ca-8,!0===Ka.containsPoint(eb)){r.activeTexture(p.TEXTURE0);r.bindTexture(p.TEXTURE_2D,null);r.activeTexture(p.TEXTURE1);r.bindTexture(p.TEXTURE_2D,v);p.copyTexImage2D(p.TEXTURE_2D,0,p.RGB,eb.x,eb.y,16,16,0);p.uniform1i(c,0);p.uniform2f(h,ja.x,ja.y);p.uniform3f(m,Aa.x,Aa.y,Aa.z);r.disable(p.BLEND);r.enable(p.DEPTH_TEST);p.drawElements(p.TRIANGLES,
11697 6,p.UNSIGNED_SHORT,0);r.activeTexture(p.TEXTURE0);r.bindTexture(p.TEXTURE_2D,I);p.copyTexImage2D(p.TEXTURE_2D,0,p.RGBA,eb.x,eb.y,16,16,0);p.uniform1i(c,1);r.disable(p.DEPTH_TEST);r.activeTexture(p.TEXTURE1);r.bindTexture(p.TEXTURE_2D,v);p.drawElements(p.TRIANGLES,6,p.UNSIGNED_SHORT,0);R.positionScreen.copy(Aa);R.customUpdateCallback?R.customUpdateCallback(R):R.updateLensFlares();p.uniform1i(c,2);r.enable(p.BLEND);for(var S=0,gf=R.lensFlares.length;S<gf;S++){var V=R.lensFlares[S];.001<V.opacity&&.001<
11698 V.scale&&(Aa.x=V.x,Aa.y=V.y,Aa.z=V.z,K=V.size*V.scale/H.w,ja.x=K*F,ja.y=K,p.uniform3f(m,Aa.x,Aa.y,Aa.z),p.uniform2f(h,ja.x,ja.y),p.uniform1f(k,V.rotation),p.uniform1f(f,V.opacity),p.uniform3f(g,V.color.r,V.color.g,V.color.b),r.setBlending(V.blending,V.blendEquation,V.blendSrc,V.blendDst),a.setTexture2D(V.texture,1),p.drawElements(p.TRIANGLES,6,p.UNSIGNED_SHORT,0))}}r.enable(p.CULL_FACE);r.enable(p.DEPTH_TEST);r.setDepthWrite(!0);a.resetGLState()}}}function hf(a,b){var c,d,e,f,g,h,k,m,w,n,p,r,x,l,
11699 D,u,v;function I(a,b){return a.renderOrder!==b.renderOrder?a.renderOrder-b.renderOrder:a.z!==b.z?b.z-a.z:b.id-a.id}var y=a.context,E=a.state,H,F,M,ca,K=new q,ja=new ba,Aa=new q;this.render=function(q,Ka){if(0!==b.length){if(void 0===M){var N=new Float32Array([-.5,-.5,0,0,.5,-.5,1,0,.5,.5,1,1,-.5,.5,0,1]),P=new Uint16Array([0,1,2,0,2,3]);H=y.createBuffer();F=y.createBuffer();y.bindBuffer(y.ARRAY_BUFFER,H);y.bufferData(y.ARRAY_BUFFER,N,y.STATIC_DRAW);y.bindBuffer(y.ELEMENT_ARRAY_BUFFER,F);y.bufferData(y.ELEMENT_ARRAY_BUFFER,
11700 P,y.STATIC_DRAW);var N=y.createProgram(),P=y.createShader(y.VERTEX_SHADER),R=y.createShader(y.FRAGMENT_SHADER);y.shaderSource(P,["precision "+a.getPrecision()+" float;","uniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform float rotation;\nuniform vec2 scale;\nuniform vec2 uvOffset;\nuniform vec2 uvScale;\nattribute vec2 position;\nattribute vec2 uv;\nvarying vec2 vUV;\nvoid main() {\nvUV = uvOffset + uv * uvScale;\nvec2 alignedPosition = position * scale;\nvec2 rotatedPosition;\nrotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\nrotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\nvec4 finalPosition;\nfinalPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\nfinalPosition.xy += rotatedPosition;\nfinalPosition = projectionMatrix * finalPosition;\ngl_Position = finalPosition;\n}"].join("\n"));
11701 y.shaderSource(R,["precision "+a.getPrecision()+" float;","uniform vec3 color;\nuniform sampler2D map;\nuniform float opacity;\nuniform int fogType;\nuniform vec3 fogColor;\nuniform float fogDensity;\nuniform float fogNear;\nuniform float fogFar;\nuniform float alphaTest;\nvarying vec2 vUV;\nvoid main() {\nvec4 texture = texture2D( map, vUV );\nif ( texture.a < alphaTest ) discard;\ngl_FragColor = vec4( color * texture.xyz, texture.a * opacity );\nif ( fogType > 0 ) {\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat fogFactor = 0.0;\nif ( fogType == 1 ) {\nfogFactor = smoothstep( fogNear, fogFar, depth );\n} else {\nconst float LOG2 = 1.442695;\nfogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n}\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n}\n}"].join("\n"));
11702 y.compileShader(P);y.compileShader(R);y.attachShader(N,P);y.attachShader(N,R);y.linkProgram(N);M=N;u=y.getAttribLocation(M,"position");v=y.getAttribLocation(M,"uv");c=y.getUniformLocation(M,"uvOffset");d=y.getUniformLocation(M,"uvScale");e=y.getUniformLocation(M,"rotation");f=y.getUniformLocation(M,"scale");g=y.getUniformLocation(M,"color");h=y.getUniformLocation(M,"map");k=y.getUniformLocation(M,"opacity");m=y.getUniformLocation(M,"modelViewMatrix");w=y.getUniformLocation(M,"projectionMatrix");n=
11703 y.getUniformLocation(M,"fogType");p=y.getUniformLocation(M,"fogDensity");r=y.getUniformLocation(M,"fogNear");x=y.getUniformLocation(M,"fogFar");l=y.getUniformLocation(M,"fogColor");D=y.getUniformLocation(M,"alphaTest");N=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");N.width=8;N.height=8;P=N.getContext("2d");P.fillStyle="white";P.fillRect(0,0,8,8);ca=new da(N);ca.needsUpdate=!0}y.useProgram(M);E.initAttributes();E.enableAttribute(u);E.enableAttribute(v);E.disableUnusedAttributes();
11704 E.disable(y.CULL_FACE);E.enable(y.BLEND);y.bindBuffer(y.ARRAY_BUFFER,H);y.vertexAttribPointer(u,2,y.FLOAT,!1,16,0);y.vertexAttribPointer(v,2,y.FLOAT,!1,16,8);y.bindBuffer(y.ELEMENT_ARRAY_BUFFER,F);y.uniformMatrix4fv(w,!1,Ka.projectionMatrix.elements);E.activeTexture(y.TEXTURE0);y.uniform1i(h,0);P=N=0;(R=q.fog)?(y.uniform3f(l,R.color.r,R.color.g,R.color.b),R&&R.isFog?(y.uniform1f(r,R.near),y.uniform1f(x,R.far),y.uniform1i(n,1),P=N=1):R&&R.isFogExp2&&(y.uniform1f(p,R.density),y.uniform1i(n,2),P=N=2)):
11705 (y.uniform1i(n,0),P=N=0);for(var R=0,S=b.length;R<S;R++){var B=b[R];B.modelViewMatrix.multiplyMatrices(Ka.matrixWorldInverse,B.matrixWorld);B.z=-B.modelViewMatrix.elements[14]}b.sort(I);for(var V=[],R=0,S=b.length;R<S;R++){var B=b[R],ta=B.material;!1!==ta.visible&&(y.uniform1f(D,ta.alphaTest),y.uniformMatrix4fv(m,!1,B.modelViewMatrix.elements),B.matrixWorld.decompose(K,ja,Aa),V[0]=Aa.x,V[1]=Aa.y,B=0,q.fog&&ta.fog&&(B=P),N!==B&&(y.uniform1i(n,B),N=B),null!==ta.map?(y.uniform2f(c,ta.map.offset.x,ta.map.offset.y),
11706 y.uniform2f(d,ta.map.repeat.x,ta.map.repeat.y)):(y.uniform2f(c,0,0),y.uniform2f(d,1,1)),y.uniform1f(k,ta.opacity),y.uniform3f(g,ta.color.r,ta.color.g,ta.color.b),y.uniform1f(e,ta.rotation),y.uniform2fv(f,V),E.setBlending(ta.blending,ta.blendEquation,ta.blendSrc,ta.blendDst),E.setDepthTest(ta.depthTest),E.setDepthWrite(ta.depthWrite),ta.map?a.setTexture2D(ta.map,0):a.setTexture2D(ca,0),y.drawElements(y.TRIANGLES,6,y.UNSIGNED_SHORT,0))}E.enable(y.CULL_FACE);a.resetGLState()}}}function U(){Object.defineProperty(this,
11707 "id",{value:oe++});this.uuid=T.generateUUID();this.name="";this.type="Material";this.lights=this.fog=!0;this.blending=1;this.side=0;this.shading=2;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.colorWrite=!0;this.precision=null;this.polygonOffset=
11708 !1;this.alphaTest=this.polygonOffsetUnits=this.polygonOffsetFactor=0;this.premultipliedAlpha=!1;this.overdraw=0;this._needsUpdate=this.visible=!0}function Fa(a){U.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=
11709 this.morphTargets=this.skinning=this.clipping=this.lights=this.fog=!1;this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1};this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv2:[0,0]};this.index0AttributeName=void 0;void 0!==a&&(void 0!==a.attributes&&console.error("THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead."),this.setValues(a))}function Za(a){U.call(this);this.type="MeshDepthMaterial";this.depthPacking=3200;this.morphTargets=
11710 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 Ba(a,b){this.min=void 0!==a?a:new q(Infinity,Infinity,Infinity);this.max=void 0!==b?b:new q(-Infinity,-Infinity,-Infinity)}function Ca(a,b){this.center=void 0!==a?a:new q;this.radius=void 0!==b?b:0}function Ia(){this.elements=new Float32Array([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.")}
11711 function va(a,b){this.normal=void 0!==a?a:new q(1,0,0);this.constant=void 0!==b?b:0}function nc(a,b,c,d,e,f){this.planes=[void 0!==a?a:new va,void 0!==b?b:new va,void 0!==c?c:new va,void 0!==d?d:new va,void 0!==e?e:new va,void 0!==f?f:new va]}function pe(a,b,c,d){function e(b,c,d,e){var f=b.geometry,g;g=D;var h=b.customDepthMaterial;d&&(g=u,h=b.customDistanceMaterial);h?g=h:(h=!1,c.morphTargets&&(f&&f.isBufferGeometry?h=f.morphAttributes&&f.morphAttributes.position&&0<f.morphAttributes.position.length:
11712 f&&f.isGeometry&&(h=f.morphTargets&&0<f.morphTargets.length)),b=b.isSkinnedMesh&&c.skinning,f=0,h&&(f|=1),b&&(f|=2),g=g[f]);a.localClippingEnabled&&!0===c.clipShadows&&0!==c.clippingPlanes.length&&(f=g.uuid,h=c.uuid,b=v[f],void 0===b&&(b={},v[f]=b),f=b[h],void 0===f&&(f=g.clone(),b[h]=f),g=f);g.visible=c.visible;g.wireframe=c.wireframe;h=c.side;ja.renderSingleSided&&2==h&&(h=0);ja.renderReverseSided&&(0===h?h=1:1===h&&(h=0));g.side=h;g.clipShadows=c.clipShadows;g.clippingPlanes=c.clippingPlanes;g.wireframeLinewidth=
11713 c.wireframeLinewidth;g.linewidth=c.linewidth;d&&void 0!==g.uniforms.lightPos&&g.uniforms.lightPos.value.copy(e);return g}function f(a,b,c){if(!1!==a.visible){0!==(a.layers.mask&b.layers.mask)&&(a.isMesh||a.isLine||a.isPoints)&&a.castShadow&&(!1===a.frustumCulled||!0===k.intersectsObject(a))&&!0===a.material.visible&&(a.modelViewMatrix.multiplyMatrices(c.matrixWorldInverse,a.matrixWorld),l.push(a));a=a.children;for(var d=0,e=a.length;d<e;d++)f(a[d],b,c)}}var g=a.context,h=a.state,k=new nc,m=new J,
11714 w=b.shadows,n=new B,p=new B(d.maxTextureSize,d.maxTextureSize),r=new q,x=new q,l=[],D=Array(4),u=Array(4),v={},I=[new q(1,0,0),new q(-1,0,0),new q(0,0,1),new q(0,0,-1),new q(0,1,0),new q(0,-1,0)],y=[new q(0,1,0),new q(0,1,0),new q(0,1,0),new q(0,1,0),new q(0,0,1),new q(0,0,-1)],E=[new ga,new ga,new ga,new ga,new ga,new ga];b=new Za;b.depthPacking=3201;b.clipping=!0;d=Gb.distanceRGBA;for(var H=La.clone(d.uniforms),F=0;4!==F;++F){var M=0!==(F&1),ca=0!==(F&2),K=b.clone();K.morphTargets=M;K.skinning=
11715 ca;D[F]=K;M=new Fa({defines:{USE_SHADOWMAP:""},uniforms:H,vertexShader:d.vertexShader,fragmentShader:d.fragmentShader,morphTargets:M,skinning:ca,clipping:!0});u[F]=M}var ja=this;this.enabled=!1;this.autoUpdate=!0;this.needsUpdate=!1;this.type=1;this.renderSingleSided=this.renderReverseSided=!0;this.render=function(b,d){if(!1!==ja.enabled&&(!1!==ja.autoUpdate||!1!==ja.needsUpdate)&&0!==w.length){h.clearColor(1,1,1,1);h.disable(g.BLEND);h.setDepthTest(!0);h.setScissorTest(!1);for(var v,u,q=0,D=w.length;q<
11716 D;q++){var H=w[q],F=H.shadow;if(void 0===F)console.warn("THREE.WebGLShadowMap:",H,"has no shadow.");else{var M=F.camera;n.copy(F.mapSize);n.min(p);if(H&&H.isPointLight){v=6;u=!0;var K=n.x,ca=n.y;E[0].set(2*K,ca,K,ca);E[1].set(0,ca,K,ca);E[2].set(3*K,ca,K,ca);E[3].set(K,ca,K,ca);E[4].set(3*K,0,K,ca);E[5].set(K,0,K,ca);n.x*=4;n.y*=2}else v=1,u=!1;null===F.map&&(F.map=new Db(n.x,n.y,{minFilter:1003,magFilter:1003,format:1023}),M.updateProjectionMatrix());F&&F.isSpotLightShadow&&F.update(H);K=F.map;F=
11717 F.matrix;x.setFromMatrixPosition(H.matrixWorld);M.position.copy(x);a.setRenderTarget(K);a.clear();for(K=0;K<v;K++){u?(r.copy(M.position),r.add(I[K]),M.up.copy(y[K]),M.lookAt(r),h.viewport(E[K])):(r.setFromMatrixPosition(H.target.matrixWorld),M.lookAt(r));M.updateMatrixWorld();M.matrixWorldInverse.getInverse(M.matrixWorld);F.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1);F.multiply(M.projectionMatrix);F.multiply(M.matrixWorldInverse);m.multiplyMatrices(M.projectionMatrix,M.matrixWorldInverse);k.setFromMatrix(m);
11718 l.length=0;f(b,d,M);for(var ca=0,B=l.length;ca<B;ca++){var C=l[ca],z=c.update(C),G=C.material;if(G&&G.isMultiMaterial)for(var $a=z.groups,G=G.materials,Ad=0,Da=$a.length;Ad<Da;Ad++){var Ra=$a[Ad],Pa=G[Ra.materialIndex];!0===Pa.visible&&(Pa=e(C,Pa,u,x),a.renderBufferDirect(M,null,z,Pa,C,Ra))}else Pa=e(C,G,u,x),a.renderBufferDirect(M,null,z,Pa,C,null)}}}}v=a.getClearColor();u=a.getClearAlpha();a.setClearColor(v,u);ja.needsUpdate=!1}}}function ab(a,b){this.origin=void 0!==a?a:new q;this.direction=void 0!==
11719 b?b:new q}function bb(a,b,c,d){this._x=a||0;this._y=b||0;this._z=c||0;this._order=d||bb.DefaultOrder}function Yc(){this.mask=1}function z(){Object.defineProperty(this,"id",{value:qe++});this.uuid=T.generateUUID();this.name="";this.type="Object3D";this.parent=null;this.children=[];this.up=z.DefaultUp.clone();var a=new q,b=new bb,c=new ba,d=new q(1,1,1);b.onChange(function(){c.setFromEuler(b,!1)});c.onChange(function(){b.setFromQuaternion(c,void 0,!1)});Object.defineProperties(this,{position:{enumerable:!0,
11720 value:a},rotation:{enumerable:!0,value:b},quaternion:{enumerable:!0,value:c},scale:{enumerable:!0,value:d},modelViewMatrix:{value:new J},normalMatrix:{value:new Ia}});this.matrix=new J;this.matrixWorld=new J;this.matrixAutoUpdate=z.DefaultMatrixAutoUpdate;this.matrixWorldNeedsUpdate=!1;this.layers=new Yc;this.visible=!0;this.receiveShadow=this.castShadow=!1;this.frustumCulled=!0;this.renderOrder=0;this.userData={};this.onBeforeRender=function(){};this.onAfterRender=function(){}}function gb(a,b){this.start=
11721 void 0!==a?a:new q;this.end=void 0!==b?b:new q}function wa(a,b,c){this.a=void 0!==a?a:new q;this.b=void 0!==b?b:new q;this.c=void 0!==c?c:new q}function ea(a,b,c,d,e,f){this.a=a;this.b=b;this.c=c;this.normal=d&&d.isVector3?d:new q;this.vertexNormals=Array.isArray(d)?d:[];this.color=e&&e.isColor?e:new O;this.vertexColors=Array.isArray(e)?e:[];this.materialIndex=void 0!==f?f:0}function Ma(a){U.call(this);this.type="MeshBasicMaterial";this.color=new O(16777215);this.aoMap=this.map=null;this.aoMapIntensity=
11722 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=this.morphTargets=this.skinning=!1;this.setValues(a)}function C(a,b,c){if(Array.isArray(a))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.uuid=T.generateUUID();this.array=a;this.itemSize=b;this.count=void 0!==a?a.length/b:0;this.normalized=!0===c;
11723 this.dynamic=!1;this.updateRange={offset:0,count:-1};this.version=0}function Zc(a,b){return new C(new Uint16Array(a),b)}function $c(a,b){return new C(new Uint32Array(a),b)}function ha(a,b){return new C(new Float32Array(a),b)}function Q(){Object.defineProperty(this,"id",{value:ad++});this.uuid=T.generateUUID();this.name="";this.type="Geometry";this.vertices=[];this.colors=[];this.faces=[];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphNormals=[];this.skinWeights=[];this.skinIndices=[];this.lineDistances=
11724 [];this.boundingSphere=this.boundingBox=null;this.groupsNeedUpdate=this.lineDistancesNeedUpdate=this.colorsNeedUpdate=this.normalsNeedUpdate=this.uvsNeedUpdate=this.verticesNeedUpdate=this.elementsNeedUpdate=!1}function re(){Object.defineProperty(this,"id",{value:ad++});this.uuid=T.generateUUID();this.name="";this.type="DirectGeometry";this.indices=[];this.vertices=[];this.normals=[];this.colors=[];this.uvs=[];this.uvs2=[];this.groups=[];this.morphTargets={};this.skinWeights=[];this.skinIndices=[];
11725 this.boundingSphere=this.boundingBox=null;this.groupsNeedUpdate=this.uvsNeedUpdate=this.colorsNeedUpdate=this.normalsNeedUpdate=this.verticesNeedUpdate=!1}function G(){Object.defineProperty(this,"id",{value:ad++});this.uuid=T.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}}function ya(a,b){z.call(this);this.type="Mesh";this.geometry=void 0!==
11726 a?a:new G;this.material=void 0!==b?b:new Ma({color:16777215*Math.random()});this.drawMode=0;this.updateMorphTargets()}function hb(a,b,c,d,e,f){function g(a,b,c,d,e,f,g,k,m,B,C){var Ka=f/m,N=g/B,P=f/2,R=g/2,S=k/2;g=m+1;for(var z=B+1,V=f=0,G=new q,L=0;L<z;L++)for(var O=L*N-R,J=0;J<g;J++)G[a]=(J*Ka-P)*d,G[b]=O*e,G[c]=S,n[l]=G.x,n[l+1]=G.y,n[l+2]=G.z,G[a]=0,G[b]=0,G[c]=0<k?1:-1,p[l]=G.x,p[l+1]=G.y,p[l+2]=G.z,r[t]=J/m,r[t+1]=1-L/B,l+=3,t+=2,f+=1;for(L=0;L<B;L++)for(J=0;J<m;J++)a=u+J+g*(L+1),b=u+(J+1)+
11727 g*(L+1),c=u+(J+1)+g*L,w[D]=u+J+g*L,w[D+1]=a,w[D+2]=c,w[D+3]=a,w[D+4]=b,w[D+5]=c,D+=6,V+=6;h.addGroup(v,V,C);v+=V;u+=f}G.call(this);this.type="BoxBufferGeometry";this.parameters={width:a,height:b,depth:c,widthSegments:d,heightSegments:e,depthSegments:f};var h=this;d=Math.floor(d)||1;e=Math.floor(e)||1;f=Math.floor(f)||1;var k=function(a,b,c){return a=0+(a+1)*(b+1)*2+(a+1)*(c+1)*2+(c+1)*(b+1)*2}(d,e,f),m=function(a,b,c){a=0+a*b*2+a*c*2+c*b*2;return 6*a}(d,e,f),w=new (65535<m?Uint32Array:Uint16Array)(m),
11728 n=new Float32Array(3*k),p=new Float32Array(3*k),r=new Float32Array(2*k),l=0,t=0,D=0,u=0,v=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(new C(w,1));this.addAttribute("position",new C(n,3));this.addAttribute("normal",new C(p,3));this.addAttribute("uv",new C(r,2))}function ib(a,b,c,d){G.call(this);this.type="PlaneBufferGeometry";this.parameters=
11729 {width:a,height:b,widthSegments:c,heightSegments:d};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=b/d;b=new Float32Array(g*h*3);a=new Float32Array(g*h*3);for(var w=new Float32Array(g*h*2),n=0,p=0,r=0;r<h;r++)for(var l=r*m-f,t=0;t<g;t++)b[n]=t*k-e,b[n+1]=-l,a[n+2]=1,w[p]=t/c,w[p+1]=1-r/d,n+=3,p+=2;n=0;e=new (65535<b.length/3?Uint32Array:Uint16Array)(c*d*6);for(r=0;r<d;r++)for(t=0;t<c;t++)f=t+g*(r+1),h=t+1+g*(r+1),k=t+1+g*r,e[n]=t+g*r,e[n+1]=f,e[n+2]=k,e[n+3]=f,e[n+4]=
11730 h,e[n+5]=k,n+=6;this.setIndex(new C(e,1));this.addAttribute("position",new C(b,3));this.addAttribute("normal",new C(a,3));this.addAttribute("uv",new C(w,2))}function Z(){z.call(this);this.type="Camera";this.matrixWorldInverse=new J;this.projectionMatrix=new J}function Ea(a,b,c,d){Z.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;this.focus=10;this.aspect=void 0!==b?b:1;this.view=null;this.filmGauge=35;this.filmOffset=
11731 0;this.updateProjectionMatrix()}function Hb(a,b,c,d,e,f){Z.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 jf(a,b,c){var d,e,f;return{setMode:function(a){d=a},setIndex:function(c){c.array instanceof Uint32Array&&b.get("OES_element_index_uint")?(e=a.UNSIGNED_INT,f=4):(e=a.UNSIGNED_SHORT,f=2)},render:function(b,h){a.drawElements(d,h,e,b*f);
11732 c.calls++;c.vertices+=h;d===a.TRIANGLES&&(c.faces+=h/3)},renderInstances:function(g,h,k){var m=b.get("ANGLE_instanced_arrays");null===m?console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays."):(m.drawElementsInstancedANGLE(d,k,e,h*f,g.maxInstancedCount),c.calls++,c.vertices+=k*g.maxInstancedCount,d===a.TRIANGLES&&(c.faces+=g.maxInstancedCount*k/3))}}}function kf(a,b,c){var d;return{setMode:function(a){d=a},render:function(b,
11733 f){a.drawArrays(d,b,f);c.calls++;c.vertices+=f;d===a.TRIANGLES&&(c.faces+=f/3)},renderInstances:function(e){var f=b.get("ANGLE_instanced_arrays");if(null===f)console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");else{var g=e.attributes.position,g=g&&g.isInterleavedBufferAttribute?g.data.count:g.count;f.drawArraysInstancedANGLE(d,0,g,e.maxInstancedCount);c.calls++;c.vertices+=g*e.maxInstancedCount;d===a.TRIANGLES&&
11734 (c.faces+=e.maxInstancedCount*g/3)}}}}function lf(){var a={};return{get:function(b){if(void 0!==a[b.id])return a[b.id];var c;switch(b.type){case "DirectionalLight":c={direction:new q,color:new O,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new B};break;case "SpotLight":c={position:new q,direction:new q,color:new O,distance:0,coneCos:0,penumbraCos:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new B};break;case "PointLight":c={position:new q,color:new O,distance:0,decay:0,shadow:!1,
11735 shadowBias:0,shadowRadius:1,shadowMapSize:new B};break;case "HemisphereLight":c={direction:new q,skyColor:new O,groundColor:new O}}return a[b.id]=c}}}function mf(a){a=a.split("\n");for(var b=0;b<a.length;b++)a[b]=b+1+": "+a[b];return a.join("\n")}function se(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.");""!==a.getShaderInfoLog(d)&&console.warn("THREE.WebGLShader: gl.getShaderInfoLog()",
11736 b===a.VERTEX_SHADER?"vertex":"fragment",a.getShaderInfoLog(d),mf(c));return d}function te(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: "+a);}}function Bd(a,b){var c=te(b);return"vec4 "+a+"( vec4 value ) { return "+
11737 c[0]+"ToLinear"+c[1]+"; }"}function nf(a,b){var c=te(b);return"vec4 "+a+"( vec4 value ) { return LinearTo"+c[0]+c[1]+"; }"}function of(a,b){var c;switch(b){case 1:c="Linear";break;case 2:c="Reinhard";break;case 3:c="Uncharted2";break;case 4:c="OptimizedCineon";break;default:throw Error("unsupported toneMapping: "+b);}return"vec3 "+a+"( vec3 color ) { return "+c+"ToneMapping( color ); }"}function pf(a,b,c){a=a||{};return[a.derivatives||b.envMapCubeUV||b.bumpMap||b.normalMap||b.flatShading?"#extension GL_OES_standard_derivatives : enable":
11738 "",(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(oc).join("\n")}function qf(a){var b=[],c;for(c in a){var d=a[c];!1!==d&&b.push("#define "+c+" "+d)}return b.join("\n")}function oc(a){return""!==a}function ue(a,b){return a.replace(/NUM_DIR_LIGHTS/g,
11739 b.numDirLights).replace(/NUM_SPOT_LIGHTS/g,b.numSpotLights).replace(/NUM_POINT_LIGHTS/g,b.numPointLights).replace(/NUM_HEMI_LIGHTS/g,b.numHemiLights)}function Cd(a){return a.replace(/#include +<([\w\d.]+)>/g,function(a,c){var d=X[c];if(void 0===d)throw Error("Can not resolve #include <"+c+">");return Cd(d)})}function ve(a){return a.replace(/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+
11740 " ]");return a})}function rf(a,b,c,d){var e=a.context,f=c.extensions,g=c.defines,h=c.__webglShader.vertexShader,k=c.__webglShader.fragmentShader,m="SHADOWMAP_TYPE_BASIC";1===d.shadowMapType?m="SHADOWMAP_TYPE_PCF":2===d.shadowMapType&&(m="SHADOWMAP_TYPE_PCF_SOFT");var w="ENVMAP_TYPE_CUBE",n="ENVMAP_MODE_REFLECTION",p="ENVMAP_BLENDING_MULTIPLY";if(d.envMap){switch(c.envMap.mapping){case 301:case 302:w="ENVMAP_TYPE_CUBE";break;case 306:case 307:w="ENVMAP_TYPE_CUBE_UV";break;case 303:case 304:w="ENVMAP_TYPE_EQUIREC";
11741 break;case 305:w="ENVMAP_TYPE_SPHERE"}switch(c.envMap.mapping){case 302:case 304:n="ENVMAP_MODE_REFRACTION"}switch(c.combine){case 0:p="ENVMAP_BLENDING_MULTIPLY";break;case 1:p="ENVMAP_BLENDING_MIX";break;case 2:p="ENVMAP_BLENDING_ADD"}}var r=0<a.gammaFactor?a.gammaFactor:1,f=pf(f,d,a.extensions),l=qf(g),t=e.createProgram();c.isRawShaderMaterial?(g=[l,"\n"].filter(oc).join("\n"),m=[f,l,"\n"].filter(oc).join("\n")):(g=["precision "+d.precision+" float;","precision "+d.precision+" int;","#define SHADER_NAME "+
11742 c.__webglShader.name,l,d.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+r,"#define MAX_BONES "+d.maxBones,d.map?"#define USE_MAP":"",d.envMap?"#define USE_ENVMAP":"",d.envMap?"#define "+n:"",d.lightMap?"#define USE_LIGHTMAP":"",d.aoMap?"#define USE_AOMAP":"",d.emissiveMap?"#define USE_EMISSIVEMAP":"",d.bumpMap?"#define USE_BUMPMAP":"",d.normalMap?"#define USE_NORMALMAP":"",d.displacementMap&&d.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",d.specularMap?"#define USE_SPECULARMAP":
11743 "",d.roughnessMap?"#define USE_ROUGHNESSMAP":"",d.metalnessMap?"#define USE_METALNESSMAP":"",d.alphaMap?"#define USE_ALPHAMAP":"",d.vertexColors?"#define USE_COLOR":"",d.flatShading?"#define FLAT_SHADED":"",d.skinning?"#define USE_SKINNING":"",d.useVertexTexture?"#define BONE_TEXTURE":"",d.morphTargets?"#define USE_MORPHTARGETS":"",d.morphNormals&&!1===d.flatShading?"#define USE_MORPHNORMALS":"",d.doubleSided?"#define DOUBLE_SIDED":"",d.flipSided?"#define FLIP_SIDED":"","#define NUM_CLIPPING_PLANES "+
11744 d.numClippingPlanes,d.shadowMapEnabled?"#define USE_SHADOWMAP":"",d.shadowMapEnabled?"#define "+m:"",d.sizeAttenuation?"#define USE_SIZEATTENUATION":"",d.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",d.logarithmicDepthBuffer&&a.extensions.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;",
11745 "attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_COLOR","\tattribute vec3 color;","#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;",
11746 "\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(oc).join("\n"),m=[f,"precision "+d.precision+" float;","precision "+d.precision+" int;","#define SHADER_NAME "+c.__webglShader.name,l,d.alphaTest?"#define ALPHATEST "+d.alphaTest:"","#define GAMMA_FACTOR "+r,d.useFog&&d.fog?"#define USE_FOG":"",d.useFog&&d.fogExp?"#define FOG_EXP2":"",d.map?"#define USE_MAP":
11747 "",d.envMap?"#define USE_ENVMAP":"",d.envMap?"#define "+w:"",d.envMap?"#define "+n:"",d.envMap?"#define "+p:"",d.lightMap?"#define USE_LIGHTMAP":"",d.aoMap?"#define USE_AOMAP":"",d.emissiveMap?"#define USE_EMISSIVEMAP":"",d.bumpMap?"#define USE_BUMPMAP":"",d.normalMap?"#define USE_NORMALMAP":"",d.specularMap?"#define USE_SPECULARMAP":"",d.roughnessMap?"#define USE_ROUGHNESSMAP":"",d.metalnessMap?"#define USE_METALNESSMAP":"",d.alphaMap?"#define USE_ALPHAMAP":"",d.vertexColors?"#define USE_COLOR":
11748 "",d.flatShading?"#define FLAT_SHADED":"",d.doubleSided?"#define DOUBLE_SIDED":"",d.flipSided?"#define FLIP_SIDED":"","#define NUM_CLIPPING_PLANES "+d.numClippingPlanes,"#define UNION_CLIPPING_PLANES "+(d.numClippingPlanes-d.numClipIntersection),d.shadowMapEnabled?"#define USE_SHADOWMAP":"",d.shadowMapEnabled?"#define "+m:"",d.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",d.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",d.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",d.logarithmicDepthBuffer&&
11749 a.extensions.get("EXT_frag_depth")?"#define USE_LOGDEPTHBUF_EXT":"",d.envMap&&a.extensions.get("EXT_shader_texture_lod")?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;",0!==d.toneMapping?"#define TONE_MAPPING":"",0!==d.toneMapping?X.tonemapping_pars_fragment:"",0!==d.toneMapping?of("toneMapping",d.toneMapping):"",d.outputEncoding||d.mapEncoding||d.envMapEncoding||d.emissiveMapEncoding?X.encodings_pars_fragment:"",d.mapEncoding?Bd("mapTexelToLinear",d.mapEncoding):
11750 "",d.envMapEncoding?Bd("envMapTexelToLinear",d.envMapEncoding):"",d.emissiveMapEncoding?Bd("emissiveMapTexelToLinear",d.emissiveMapEncoding):"",d.outputEncoding?nf("linearToOutputTexel",d.outputEncoding):"",d.depthPacking?"#define DEPTH_PACKING "+c.depthPacking:"","\n"].filter(oc).join("\n"));h=Cd(h,d);h=ue(h,d);k=Cd(k,d);k=ue(k,d);c.isShaderMaterial||(h=ve(h),k=ve(k));k=m+k;h=se(e,e.VERTEX_SHADER,g+h);k=se(e,e.FRAGMENT_SHADER,k);e.attachShader(t,h);e.attachShader(t,k);void 0!==c.index0AttributeName?
11751 e.bindAttribLocation(t,0,c.index0AttributeName):!0===d.morphTargets&&e.bindAttribLocation(t,0,"position");e.linkProgram(t);d=e.getProgramInfoLog(t);w=e.getShaderInfoLog(h);n=e.getShaderInfoLog(k);r=p=!0;if(!1===e.getProgramParameter(t,e.LINK_STATUS))p=!1,console.error("THREE.WebGLProgram: shader error: ",e.getError(),"gl.VALIDATE_STATUS",e.getProgramParameter(t,e.VALIDATE_STATUS),"gl.getProgramInfoLog",d,w,n);else if(""!==d)console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",d);else if(""===
11752 w||""===n)r=!1;r&&(this.diagnostics={runnable:p,material:c,programLog:d,vertexShader:{log:w,prefix:g},fragmentShader:{log:n,prefix:m}});e.deleteShader(h);e.deleteShader(k);var q;this.getUniforms=function(){void 0===q&&(q=new Ya(e,t,a));return q};var u;this.getAttributes=function(){if(void 0===u){for(var a={},b=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES),c=0;c<b;c++){var d=e.getActiveAttrib(t,c).name;a[d]=e.getAttribLocation(t,d)}u=a}return u};this.destroy=function(){e.deleteProgram(t);this.program=
11753 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.id=sf++;this.code=b;this.usedTimes=1;this.program=t;this.vertexShader=h;this.fragmentShader=k;return this}function tf(a,b){function c(a,b){var c;a?a&&a.isTexture?c=a.encoding:a&&a.isWebGLRenderTarget&&(console.warn("THREE.WebGLPrograms.getTextureEncodingFromMap: don't use render targets as textures. Use their .texture property instead."),
11754 c=a.texture.encoding):c=3E3;3E3===c&&b&&(c=3007);return c}var d=[],e={MeshDepthMaterial:"depth",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points"},f="precision supportsVertexTextures map mapEncoding envMap envMapMode envMapEncoding lightMap aoMap emissiveMap emissiveMapEncoding bumpMap normalMap displacementMap specularMap roughnessMap metalnessMap alphaMap combine vertexColors fog useFog fogExp flatShading sizeAttenuation logarithmicDepthBuffer skinning maxBones useVertexTexture morphTargets morphNormals maxMorphTargets maxMorphNormals premultipliedAlpha numDirLights numPointLights numSpotLights numHemiLights shadowMapEnabled shadowMapType toneMapping physicallyCorrectLights alphaTest doubleSided flipSided numClippingPlanes numClipIntersection depthPacking".split(" ");
11755 this.getParameters=function(d,f,k,m,w,n){var p=e[d.type],r;b.floatVertexTextures&&n&&n.skeleton&&n.skeleton.useVertexTexture?r=1024:(r=Math.floor((b.maxVertexUniforms-20)/4),void 0!==n&&n&&n.isSkinnedMesh&&(r=Math.min(n.skeleton.bones.length,r),r<n.skeleton.bones.length&&console.warn("WebGLRenderer: too many bones - "+n.skeleton.bones.length+", this GPU supports just "+r+" (try OpenGL instead of ANGLE)")));var l=a.getPrecision();null!==d.precision&&(l=b.getMaxPrecision(d.precision),l!==d.precision&&
11756 console.warn("THREE.WebGLProgram.getParameters:",d.precision,"not supported, using",l,"instead."));var t=a.getCurrentRenderTarget();return{shaderID:p,precision:l,supportsVertexTextures:b.vertexTextures,outputEncoding:c(t?t.texture:null,a.gammaOutput),map:!!d.map,mapEncoding:c(d.map,a.gammaInput),envMap:!!d.envMap,envMapMode:d.envMap&&d.envMap.mapping,envMapEncoding:c(d.envMap,a.gammaInput),envMapCubeUV:!!d.envMap&&(306===d.envMap.mapping||307===d.envMap.mapping),lightMap:!!d.lightMap,aoMap:!!d.aoMap,
11757 emissiveMap:!!d.emissiveMap,emissiveMapEncoding:c(d.emissiveMap,a.gammaInput),bumpMap:!!d.bumpMap,normalMap:!!d.normalMap,displacementMap:!!d.displacementMap,roughnessMap:!!d.roughnessMap,metalnessMap:!!d.metalnessMap,specularMap:!!d.specularMap,alphaMap:!!d.alphaMap,combine:d.combine,vertexColors:d.vertexColors,fog:!!k,useFog:d.fog,fogExp:k&&k.isFogExp2,flatShading:1===d.shading,sizeAttenuation:d.sizeAttenuation,logarithmicDepthBuffer:b.logarithmicDepthBuffer,skinning:d.skinning,maxBones:r,useVertexTexture:b.floatVertexTextures&&
11758 n&&n.skeleton&&n.skeleton.useVertexTexture,morphTargets:d.morphTargets,morphNormals:d.morphNormals,maxMorphTargets:a.maxMorphTargets,maxMorphNormals:a.maxMorphNormals,numDirLights:f.directional.length,numPointLights:f.point.length,numSpotLights:f.spot.length,numHemiLights:f.hemi.length,numClippingPlanes:m,numClipIntersection:w,shadowMapEnabled:a.shadowMap.enabled&&n.receiveShadow&&0<f.shadows.length,shadowMapType:a.shadowMap.type,toneMapping:a.toneMapping,physicallyCorrectLights:a.physicallyCorrectLights,
11759 premultipliedAlpha:d.premultipliedAlpha,alphaTest:d.alphaTest,doubleSided:2===d.side,flipSided:1===d.side,depthPacking:void 0!==d.depthPacking?d.depthPacking:!1}};this.getProgramCode=function(a,b){var c=[];b.shaderID?c.push(b.shaderID):(c.push(a.fragmentShader),c.push(a.vertexShader));if(void 0!==a.defines)for(var d in a.defines)c.push(d),c.push(a.defines[d]);for(d=0;d<f.length;d++)c.push(b[f[d]]);return c.join()};this.acquireProgram=function(b,c,e){for(var f,w=0,n=d.length;w<n;w++){var p=d[w];if(p.code===
11760 e){f=p;++f.usedTimes;break}}void 0===f&&(f=new rf(a,e,b,c),d.push(f));return f};this.releaseProgram=function(a){if(0===--a.usedTimes){var b=d.indexOf(a);d[b]=d[d.length-1];d.pop();a.destroy()}};this.programs=d}function uf(a,b,c){function d(a){var h=a.target;a=f[h.id];null!==a.index&&e(a.index);var k=a.attributes,m;for(m in k)e(k[m]);h.removeEventListener("dispose",d);delete f[h.id];m=b.get(h);m.wireframe&&e(m.wireframe);b["delete"](h);h=b.get(a);h.wireframe&&e(h.wireframe);b["delete"](a);c.memory.geometries--}
11761 function e(c){var d;d=c.isInterleavedBufferAttribute?b.get(c.data).__webglBuffer:b.get(c).__webglBuffer;void 0!==d&&(a.deleteBuffer(d),c.isInterleavedBufferAttribute?b["delete"](c.data):b["delete"](c))}var f={};return{get:function(a){var b=a.geometry;if(void 0!==f[b.id])return f[b.id];b.addEventListener("dispose",d);var e;b.isBufferGeometry?e=b:b.isGeometry&&(void 0===b._bufferGeometry&&(b._bufferGeometry=(new G).setFromObject(a)),e=b._bufferGeometry);f[b.id]=e;c.memory.geometries++;return e}}}function vf(a,
11762 b,c){function d(c,d){var e=c.isInterleavedBufferAttribute?c.data:c,k=b.get(e);void 0===k.__webglBuffer?(k.__webglBuffer=a.createBuffer(),a.bindBuffer(d,k.__webglBuffer),a.bufferData(d,e.array,e.dynamic?a.DYNAMIC_DRAW:a.STATIC_DRAW),k.version=e.version):k.version!==e.version&&(a.bindBuffer(d,k.__webglBuffer),!1===e.dynamic?a.bufferData(d,e.array,a.STATIC_DRAW):-1===e.updateRange.count?a.bufferSubData(d,0,e.array):0===e.updateRange.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."):
11763 (a.bufferSubData(d,e.updateRange.offset*e.array.BYTES_PER_ELEMENT,e.array.subarray(e.updateRange.offset,e.updateRange.offset+e.updateRange.count)),e.updateRange.count=0),k.version=e.version)}var e=new uf(a,b,c);return{getAttributeBuffer:function(a){return a.isInterleavedBufferAttribute?b.get(a.data).__webglBuffer:b.get(a).__webglBuffer},getWireframeAttribute:function(c){var e=b.get(c);if(void 0!==e.wireframe)return e.wireframe;var h=[],k=c.index,m=c.attributes;c=m.position;if(null!==k)for(var k=k.array,
11764 m=0,w=k.length;m<w;m+=3){var n=k[m+0],p=k[m+1],r=k[m+2];h.push(n,p,p,r,r,n)}else for(k=m.position.array,m=0,w=k.length/3-1;m<w;m+=3)n=m+0,p=m+1,r=m+2,h.push(n,p,p,r,r,n);h=new C(new (65535<c.count?Uint32Array:Uint16Array)(h),1);d(h,a.ELEMENT_ARRAY_BUFFER);return e.wireframe=h},update:function(b){var c=e.get(b);b.geometry.isGeometry&&c.updateFromObject(b);b=c.index;var h=c.attributes;null!==b&&d(b,a.ELEMENT_ARRAY_BUFFER);for(var k in h)d(h[k],a.ARRAY_BUFFER);b=c.morphAttributes;for(k in b)for(var h=
11765 b[k],m=0,w=h.length;m<w;m++)d(h[m],a.ARRAY_BUFFER);return c}}}function wf(a,b,c,d,e,f,g){function h(a,b){if(a.width>b||a.height>b){var c=b/Math.max(a.width,a.height),d=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");d.width=Math.floor(a.width*c);d.height=Math.floor(a.height*c);d.getContext("2d").drawImage(a,0,0,a.width,a.height,0,0,d.width,d.height);console.warn("THREE.WebGLRenderer: image is too big ("+a.width+"x"+a.height+"). Resized to "+d.width+"x"+d.height,a);return d}return a}
11766 function k(a){return T.isPowerOfTwo(a.width)&&T.isPowerOfTwo(a.height)}function m(b){return 1003===b||1004===b||1005===b?a.NEAREST:a.LINEAR}function w(b){b=b.target;b.removeEventListener("dispose",w);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["delete"](b)}q.textures--}function n(b){b=b.target;b.removeEventListener("dispose",n);var c=d.get(b),e=d.get(b.texture);if(b){void 0!==
11767 e.__webglTexture&&a.deleteTexture(e.__webglTexture);b.depthTexture&&b.depthTexture.dispose();if(b&&b.isWebGLRenderTargetCube)for(e=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["delete"](b.texture);d["delete"](b)}q.textures--}function p(b,g){var m=d.get(b);if(0<b.version&&m.__version!==b.version){var p=b.image;
11768 if(void 0===p)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined",b);else if(!1===p.complete)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete",b);else{void 0===m.__webglInit&&(m.__webglInit=!0,b.addEventListener("dispose",w),m.__webglTexture=a.createTexture(),q.textures++);c.activeTexture(a.TEXTURE0+g);c.bindTexture(a.TEXTURE_2D,m.__webglTexture);a.pixelStorei(a.UNPACK_FLIP_Y_WEBGL,b.flipY);a.pixelStorei(a.UNPACK_PREMULTIPLY_ALPHA_WEBGL,
11769 b.premultiplyAlpha);a.pixelStorei(a.UNPACK_ALIGNMENT,b.unpackAlignment);var n=h(b.image,e.maxTextureSize);if((1001!==b.wrapS||1001!==b.wrapT||1003!==b.minFilter&&1006!==b.minFilter)&&!1===k(n))if(p=n,p instanceof HTMLImageElement||p instanceof HTMLCanvasElement){var l=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");l.width=T.nearestPowerOfTwo(p.width);l.height=T.nearestPowerOfTwo(p.height);l.getContext("2d").drawImage(p,0,0,l.width,l.height);console.warn("THREE.WebGLRenderer: image is not power of two ("+
11770 p.width+"x"+p.height+"). Resized to "+l.width+"x"+l.height,p);n=l}else n=p;var p=k(n),l=f(b.format),x=f(b.type);r(a.TEXTURE_2D,b,p);var t=b.mipmaps;if(b&&b.isDepthTexture){t=a.DEPTH_COMPONENT;if(1015===b.type){if(!u)throw Error("Float Depth Texture only supported in WebGL2.0");t=a.DEPTH_COMPONENT32F}else u&&(t=a.DEPTH_COMPONENT16);1027===b.format&&(t=a.DEPTH_STENCIL);c.texImage2D(a.TEXTURE_2D,0,t,n.width,n.height,0,l,x,null)}else if(b&&b.isDataTexture)if(0<t.length&&p){for(var K=0,ja=t.length;K<ja;K++)n=
11771 t[K],c.texImage2D(a.TEXTURE_2D,K,l,n.width,n.height,0,l,x,n.data);b.generateMipmaps=!1}else c.texImage2D(a.TEXTURE_2D,0,l,n.width,n.height,0,l,x,n.data);else if(b&&b.isCompressedTexture)for(K=0,ja=t.length;K<ja;K++)n=t[K],1023!==b.format&&1022!==b.format?-1<c.getCompressedTextureFormats().indexOf(l)?c.compressedTexImage2D(a.TEXTURE_2D,K,l,n.width,n.height,0,n.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):c.texImage2D(a.TEXTURE_2D,
11772 K,l,n.width,n.height,0,l,x,n.data);else if(0<t.length&&p){K=0;for(ja=t.length;K<ja;K++)n=t[K],c.texImage2D(a.TEXTURE_2D,K,l,l,x,n);b.generateMipmaps=!1}else c.texImage2D(a.TEXTURE_2D,0,l,l,x,n);b.generateMipmaps&&p&&a.generateMipmap(a.TEXTURE_2D);m.__version=b.version;if(b.onUpdate)b.onUpdate(b);return}}c.activeTexture(a.TEXTURE0+g);c.bindTexture(a.TEXTURE_2D,m.__webglTexture)}function r(c,g,h){h?(a.texParameteri(c,a.TEXTURE_WRAP_S,f(g.wrapS)),a.texParameteri(c,a.TEXTURE_WRAP_T,f(g.wrapT)),a.texParameteri(c,
11773 a.TEXTURE_MAG_FILTER,f(g.magFilter)),a.texParameteri(c,a.TEXTURE_MIN_FILTER,f(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.",g),a.texParameteri(c,a.TEXTURE_MAG_FILTER,m(g.magFilter)),a.texParameteri(c,a.TEXTURE_MIN_FILTER,m(g.minFilter)),1003!==g.minFilter&&
11774 1006!==g.minFilter&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.",g));!(h=b.get("EXT_texture_filter_anisotropic"))||1015===g.type&&null===b.get("OES_texture_float_linear")||1016===g.type&&null===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=
11775 g.anisotropy)}function l(b,e,g,h){var k=f(e.texture.format),m=f(e.texture.type);c.texImage2D(h,0,k,e.width,e.height,0,k,m,null);a.bindFramebuffer(a.FRAMEBUFFER,b);a.framebufferTexture2D(a.FRAMEBUFFER,g,h,d.get(e.texture).__webglTexture,0);a.bindFramebuffer(a.FRAMEBUFFER,null)}function t(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,
11776 b)):c.depthBuffer&&c.stencilBuffer?(a.renderbufferStorage(a.RENDERBUFFER,a.DEPTH_STENCIL,c.width,c.height),a.framebufferRenderbuffer(a.FRAMEBUFFER,a.DEPTH_STENCIL_ATTACHMENT,a.RENDERBUFFER,b)):a.renderbufferStorage(a.RENDERBUFFER,a.RGBA4,c.width,c.height);a.bindRenderbuffer(a.RENDERBUFFER,null)}var q=g.memory,u="undefined"!==typeof WebGL2RenderingContext&&a instanceof WebGL2RenderingContext;this.setTexture2D=p;this.setTextureCube=function(b,g){var m=d.get(b);if(6===b.image.length)if(0<b.version&&
11777 m.__version!==b.version){m.__image__webglTextureCube||(b.addEventListener("dispose",w),m.__image__webglTextureCube=a.createTexture(),q.textures++);c.activeTexture(a.TEXTURE0+g);c.bindTexture(a.TEXTURE_CUBE_MAP,m.__image__webglTextureCube);a.pixelStorei(a.UNPACK_FLIP_Y_WEBGL,b.flipY);for(var p=b&&b.isCompressedTexture,n=b.image[0]&&b.image[0].isDataTexture,l=[],x=0;6>x;x++)l[x]=p||n?n?b.image[x].image:b.image[x]:h(b.image[x],e.maxCubemapSize);var t=k(l[0]),u=f(b.format),ja=f(b.type);r(a.TEXTURE_CUBE_MAP,
11778 b,t);for(x=0;6>x;x++)if(p)for(var B,C=l[x].mipmaps,z=0,N=C.length;z<N;z++)B=C[z],1023!==b.format&&1022!==b.format?-1<c.getCompressedTextureFormats().indexOf(u)?c.compressedTexImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+x,z,u,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+x,z,u,B.width,B.height,0,u,ja,B.data);else n?c.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+x,0,u,l[x].width,
11779 l[x].height,0,u,ja,l[x].data):c.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+x,0,u,u,ja,l[x]);b.generateMipmaps&&t&&a.generateMipmap(a.TEXTURE_CUBE_MAP);m.__version=b.version;if(b.onUpdate)b.onUpdate(b)}else c.activeTexture(a.TEXTURE0+g),c.bindTexture(a.TEXTURE_CUBE_MAP,m.__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",
11780 n);f.__webglTexture=a.createTexture();q.textures++;var g=b&&b.isWebGLRenderTargetCube,h=k(b);if(g){e.__webglFramebuffer=[];for(var m=0;6>m;m++)e.__webglFramebuffer[m]=a.createFramebuffer()}else e.__webglFramebuffer=a.createFramebuffer();if(g){c.bindTexture(a.TEXTURE_CUBE_MAP,f.__webglTexture);r(a.TEXTURE_CUBE_MAP,b.texture,h);for(m=0;6>m;m++)l(e.__webglFramebuffer[m],b,a.COLOR_ATTACHMENT0,a.TEXTURE_CUBE_MAP_POSITIVE_X+m);b.texture.generateMipmaps&&h&&a.generateMipmap(a.TEXTURE_CUBE_MAP);c.bindTexture(a.TEXTURE_CUBE_MAP,
11781 null)}else c.bindTexture(a.TEXTURE_2D,f.__webglTexture),r(a.TEXTURE_2D,b.texture,h),l(e.__webglFramebuffer,b,a.COLOR_ATTACHMENT0,a.TEXTURE_2D),b.texture.generateMipmaps&&h&&a.generateMipmap(a.TEXTURE_2D),c.bindTexture(a.TEXTURE_2D,null);if(b.depthBuffer){e=d.get(b);f=b&&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,
11782 e.__webglFramebuffer);if(!b.depthTexture||!b.depthTexture.isDepthTexture)throw Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");d.get(b.depthTexture).__webglTexture&&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);p(b.depthTexture,0);e=d.get(b.depthTexture).__webglTexture;if(1026===b.depthTexture.format)a.framebufferTexture2D(a.FRAMEBUFFER,
11783 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");}else if(f)for(e.__webglDepthbuffer=[],f=0;6>f;f++)a.bindFramebuffer(a.FRAMEBUFFER,e.__webglFramebuffer[f]),e.__webglDepthbuffer[f]=a.createRenderbuffer(),t(e.__webglDepthbuffer[f],b);else a.bindFramebuffer(a.FRAMEBUFFER,e.__webglFramebuffer),e.__webglDepthbuffer=a.createRenderbuffer(),t(e.__webglDepthbuffer,
11784 b);a.bindFramebuffer(a.FRAMEBUFFER,null)}};this.updateRenderTargetMipmap=function(b){var e=b.texture;e.generateMipmaps&&k(b)&&1003!==e.minFilter&&1006!==e.minFilter&&(b=b&&b.isWebGLRenderTargetCube?a.TEXTURE_CUBE_MAP:a.TEXTURE_2D,e=d.get(e).__webglTexture,c.bindTexture(b,e),a.generateMipmap(b),c.bindTexture(b,null))}}function xf(){var a={};return{get:function(b){b=b.uuid;var c=a[b];void 0===c&&(c={},a[b]=c);return c},"delete":function(b){delete a[b.uuid]},clear:function(){a={}}}}function yf(a,b,c){function d(b,
11785 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 e(b){!0!==E[b]&&(a.enable(b),E[b]=!0)}function f(b){!1!==E[b]&&(a.disable(b),E[b]=!1)}function g(b,d,g,h,k,m,p,n){0!==b?e(a.BLEND):f(a.BLEND);if(b!==F||n!==G)2===b?n?(a.blendEquationSeparate(a.FUNC_ADD,a.FUNC_ADD),a.blendFuncSeparate(a.ONE,a.ONE,
11786 a.ONE,a.ONE)):(a.blendEquation(a.FUNC_ADD),a.blendFunc(a.SRC_ALPHA,a.ONE)):3===b?n?(a.blendEquationSeparate(a.FUNC_ADD,a.FUNC_ADD),a.blendFuncSeparate(a.ZERO,a.ZERO,a.ONE_MINUS_SRC_COLOR,a.ONE_MINUS_SRC_ALPHA)):(a.blendEquation(a.FUNC_ADD),a.blendFunc(a.ZERO,a.ONE_MINUS_SRC_COLOR)):4===b?n?(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)):n?(a.blendEquationSeparate(a.FUNC_ADD,a.FUNC_ADD),
11787 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,a.ONE_MINUS_SRC_ALPHA,a.ONE,a.ONE_MINUS_SRC_ALPHA)),F=b,G=n;if(5===b){k=k||d;m=m||g;p=p||h;if(d!==M||k!==B)a.blendEquationSeparate(c(d),c(k)),M=d,B=k;if(g!==ca||h!==K||m!==C||p!==z)a.blendFuncSeparate(c(g),c(h),c(m),c(p)),ca=g,K=h,C=m,z=p}else z=C=B=K=ca=M=null}function h(a){t.setFunc(a)}function k(b){N!==b&&(b?a.frontFace(a.CW):a.frontFace(a.CCW),
11788 N=b)}function m(b){0!==b?(e(a.CULL_FACE),b!==P&&(1===b?a.cullFace(a.BACK):2===b?a.cullFace(a.FRONT):a.cullFace(a.FRONT_AND_BACK))):f(a.CULL_FACE);P=b}function w(b){void 0===b&&(b=a.TEXTURE0+O-1);L!==b&&(a.activeTexture(b),L=b)}function n(a,b,c,d){l.setClear(a,b,c,d)}function p(a){t.setClear(a)}function r(a){q.setClear(a)}var l=new function(){var b=!1,c=new ga,d=null,e=new ga;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){c.set(b,
11789 d,f,g);!1===e.equals(c)&&(a.clearColor(b,d,f,g),e.copy(c))},reset:function(){b=!1;d=null;e.set(0,0,0,1)}}},t=new function(){var b=!1,c=null,d=null,g=null;return{setTest:function(b){b?e(a.DEPTH_TEST):f(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);
11790 break;case 6:a.depthFunc(a.GREATER);break;case 7:a.depthFunc(a.NOTEQUAL);break;default:a.depthFunc(a.LEQUAL)}else a.depthFunc(a.LEQUAL);d=b}},setLocked:function(a){b=a},setClear:function(b){g!==b&&(a.clearDepth(b),g=b)},reset:function(){b=!1;g=d=c=null}}},q=new function(){var b=!1,c=null,d=null,g=null,h=null,k=null,m=null,p=null,n=null;return{setTest:function(b){b?e(a.STENCIL_TEST):f(a.STENCIL_TEST)},setMask:function(d){c===d||b||(a.stencilMask(d),c=d)},setFunc:function(b,c,e){if(d!==b||g!==c||h!==
11791 e)a.stencilFunc(b,c,e),d=b,g=c,h=e},setOp:function(b,c,d){if(k!==b||m!==c||p!==d)a.stencilOp(b,c,d),k=b,m=c,p=d},setLocked:function(a){b=a},setClear:function(b){n!==b&&(a.clearStencil(b),n=b)},reset:function(){b=!1;n=p=m=k=h=g=d=c=null}}},u=a.getParameter(a.MAX_VERTEX_ATTRIBS),v=new Uint8Array(u),I=new Uint8Array(u),y=new Uint8Array(u),E={},H=null,F=null,M=null,ca=null,K=null,B=null,C=null,z=null,G=!1,N=null,P=null,R=null,S=null,J=null,V=null,O=a.getParameter(a.MAX_TEXTURE_IMAGE_UNITS),L=null,Q={},
11792 T=new ga,U=new ga,fb={};fb[a.TEXTURE_2D]=d(a.TEXTURE_2D,a.TEXTURE_2D,1);fb[a.TEXTURE_CUBE_MAP]=d(a.TEXTURE_CUBE_MAP,a.TEXTURE_CUBE_MAP_POSITIVE_X,6);return{buffers:{color:l,depth:t,stencil:q},init:function(){n(0,0,0,1);p(1);r(0);e(a.DEPTH_TEST);h(3);k(!1);m(1);e(a.CULL_FACE);e(a.BLEND);g(1)},initAttributes:function(){for(var a=0,b=v.length;a<b;a++)v[a]=0},enableAttribute:function(c){v[c]=1;0===I[c]&&(a.enableVertexAttribArray(c),I[c]=1);0!==y[c]&&(b.get("ANGLE_instanced_arrays").vertexAttribDivisorANGLE(c,
11793 0),y[c]=0)},enableAttributeAndDivisor:function(b,c,d){v[b]=1;0===I[b]&&(a.enableVertexAttribArray(b),I[b]=1);y[b]!==c&&(d.vertexAttribDivisorANGLE(b,c),y[b]=c)},disableUnusedAttributes:function(){for(var b=0,c=I.length;b!==c;++b)I[b]!==v[b]&&(a.disableVertexAttribArray(b),I[b]=0)},enable:e,disable:f,getCompressedTextureFormats:function(){if(null===H&&(H=[],b.get("WEBGL_compressed_texture_pvrtc")||b.get("WEBGL_compressed_texture_s3tc")||b.get("WEBGL_compressed_texture_etc1")))for(var c=a.getParameter(a.COMPRESSED_TEXTURE_FORMATS),
11794 d=0;d<c.length;d++)H.push(c[d]);return H},setBlending:g,setColorWrite:function(a){l.setMask(a)},setDepthTest:function(a){t.setTest(a)},setDepthWrite:function(a){t.setMask(a)},setDepthFunc:h,setStencilTest:function(a){q.setTest(a)},setStencilWrite:function(a){q.setMask(a)},setStencilFunc:function(a,b,c){q.setFunc(a,b,c)},setStencilOp:function(a,b,c){q.setOp(a,b,c)},setFlipSided:k,setCullFace:m,setLineWidth:function(b){b!==R&&(a.lineWidth(b),R=b)},setPolygonOffset:function(b,c,d){if(b){if(e(a.POLYGON_OFFSET_FILL),
11795 S!==c||J!==d)a.polygonOffset(c,d),S=c,J=d}else f(a.POLYGON_OFFSET_FILL)},getScissorTest:function(){return V},setScissorTest:function(b){(V=b)?e(a.SCISSOR_TEST):f(a.SCISSOR_TEST)},activeTexture:w,bindTexture:function(b,c){null===L&&w();var d=Q[L];void 0===d&&(d={type:void 0,texture:void 0},Q[L]=d);if(d.type!==b||d.texture!==c)a.bindTexture(b,c||fb[b]),d.type=b,d.texture=c},compressedTexImage2D:function(){try{a.compressedTexImage2D.apply(a,arguments)}catch(b){console.error(b)}},texImage2D:function(){try{a.texImage2D.apply(a,
11796 arguments)}catch(b){console.error(b)}},clearColor:n,clearDepth:p,clearStencil:r,scissor:function(b){!1===T.equals(b)&&(a.scissor(b.x,b.y,b.z,b.w),T.copy(b))},viewport:function(b){!1===U.equals(b)&&(a.viewport(b.x,b.y,b.z,b.w),U.copy(b))},reset:function(){for(var b=0;b<I.length;b++)1===I[b]&&(a.disableVertexAttribArray(b),I[b]=0);E={};L=H=null;Q={};P=N=F=null;l.reset();t.reset();q.reset()}}}function zf(a,b,c){function d(b){if("highp"===b){if(0<a.getShaderPrecisionFormat(a.VERTEX_SHADER,a.HIGH_FLOAT).precision&&
11797 0<a.getShaderPrecisionFormat(a.FRAGMENT_SHADER,a.HIGH_FLOAT).precision)return"highp";b="mediump"}return"mediump"===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=void 0!==c.precision?c.precision:"highp",g=d(f);g!==f&&(console.warn("THREE.WebGLRenderer:",f,"not supported, using",g,"instead."),f=g);c=!0===c.logarithmicDepthBuffer&&!!b.get("EXT_frag_depth");var g=a.getParameter(a.MAX_TEXTURE_IMAGE_UNITS),
11798 h=a.getParameter(a.MAX_VERTEX_TEXTURE_IMAGE_UNITS),k=a.getParameter(a.MAX_TEXTURE_SIZE),m=a.getParameter(a.MAX_CUBE_MAP_TEXTURE_SIZE),w=a.getParameter(a.MAX_VERTEX_ATTRIBS),n=a.getParameter(a.MAX_VERTEX_UNIFORM_VECTORS),p=a.getParameter(a.MAX_VARYING_VECTORS),r=a.getParameter(a.MAX_FRAGMENT_UNIFORM_VECTORS),l=0<h,t=!!b.get("OES_texture_float");return{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):
11799 0},getMaxPrecision:d,precision:f,logarithmicDepthBuffer:c,maxTextures:g,maxVertexTextures:h,maxTextureSize:k,maxCubemapSize:m,maxAttributes:w,maxVertexUniforms:n,maxVaryings:p,maxFragmentUniforms:r,vertexTextures:l,floatFragmentTextures:t,floatVertexTextures:l&&t}}function Af(a){var b={};return{get:function(c){if(void 0!==b[c])return b[c];var d;switch(c){case "WEBGL_depth_texture":d=a.getExtension("WEBGL_depth_texture")||a.getExtension("MOZ_WEBGL_depth_texture")||a.getExtension("WEBKIT_WEBGL_depth_texture");
11800 break;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")||
11801 a.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;case "WEBGL_compressed_texture_etc1":d=a.getExtension("WEBGL_compressed_texture_etc1");break;default:d=a.getExtension(c)}null===d&&console.warn("THREE.WebGLRenderer: "+c+" extension not supported.");return b[c]=d}}}function Bf(){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;
11802 k.getNormalMatrix(b);if(null===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 va,k=new Ia,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=
11803 !1;a()};this.setState=function(c,h,k,r,l,t){if(!f||null===c||0===c.length||g&&!k)g?b(null):a();else{k=g?0:e;var q=4*k,u=l.clippingState||null;m.value=u;u=b(c,r,q,t);for(c=0;c!==q;++c)u[c]=d[c];l.clippingState=u;this.numIntersection=h?this.numPlanes:0;this.numPlanes+=k}}}function Dd(a){function b(a,b,c,d){!0===M&&(a*=d,b*=d,c*=d);Y.clearColor(a,b,c,d)}function c(){Y.init();Y.scissor(X.copy(ha).multiplyScalar(Qa));Y.viewport($a.copy(fa).multiplyScalar(Qa));b(Da.r,Da.g,Da.b,Ra)}function d(){W=Q=null;
11804 U="";L=-1;Y.reset()}function e(a){a.preventDefault();d();c();ea.clear()}function f(a){a=a.target;a.removeEventListener("dispose",f);g(a);ea["delete"](a)}function g(a){var b=ea.get(a).program;a.program=void 0;void 0!==b&&va.releaseProgram(b)}function h(a,b){return Math.abs(b[0])-Math.abs(a[0])}function k(a,b){return a.object.renderOrder!==b.object.renderOrder?a.object.renderOrder-b.object.renderOrder:a.material.program&&b.material.program&&a.material.program!==b.material.program?a.material.program.id-
11805 b.material.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 m(a,b){return a.object.renderOrder!==b.object.renderOrder?a.object.renderOrder-b.object.renderOrder:a.z!==b.z?b.z-a.z:a.id-b.id}function w(a,b,c,d,e){var f;c.transparent?(d=z,f=++Ka):(d=B,f=++C);f=d[f];void 0!==f?(f.id=a.id,f.object=a,f.geometry=b,f.material=c,f.z=Z.z,f.group=e):(f={id:a.id,object:a,geometry:b,material:c,z:Z.z,group:e},d.push(f))}function n(a){if(!oa.intersectsSphere(a))return!1;
11806 var b=ba.numPlanes;if(0===b)return!0;var c=S.clippingPlanes,d=a.center;a=-a.radius;var e=0;do if(c[e].distanceToPoint(d)<a)return!1;while(++e!==b);return!0}function p(a,b){if(!1!==a.visible){if(0!==(a.layers.mask&b.layers.mask))if(a.isLight)K.push(a);else if(a.isSprite){var c;(c=!1===a.frustumCulled)||(na.center.set(0,0,0),na.radius=.7071067811865476,na.applyMatrix4(a.matrixWorld),c=!0===n(na));c&&P.push(a)}else if(a.isLensFlare)R.push(a);else if(a.isImmediateRenderObject)!0===S.sortObjects&&(Z.setFromMatrixPosition(a.matrixWorld),
11807 Z.applyProjection(ra)),w(a,null,a.material,Z.z,null);else if(a.isMesh||a.isLine||a.isPoints)if(a.isSkinnedMesh&&a.skeleton.update(),(c=!1===a.frustumCulled)||(c=a.geometry,null===c.boundingSphere&&c.computeBoundingSphere(),na.copy(c.boundingSphere).applyMatrix4(a.matrixWorld),c=!0===n(na)),c){var d=a.material;if(!0===d.visible)if(!0===S.sortObjects&&(Z.setFromMatrixPosition(a.matrixWorld),Z.applyProjection(ra)),c=qa.update(a),d.isMultiMaterial)for(var e=c.groups,f=d.materials,d=0,g=e.length;d<g;d++){var h=
11808 e[d],k=f[h.materialIndex];!0===k.visible&&w(a,c,k,Z.z,h)}else w(a,c,d,Z.z,null)}c=a.children;d=0;for(g=c.length;d<g;d++)p(c[d],b)}}function r(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;h.modelViewMatrix.multiplyMatrices(c.matrixWorldInverse,h.matrixWorld);h.normalMatrix.getNormalMatrix(h.modelViewMatrix);h.onBeforeRender(S,b,c,k,m,g);if(h.isImmediateRenderObject){l(m);var p=t(c,b.fog,m,h);U="";h.render(function(a){S.renderBufferImmediate(a,
11809 p,m)})}else S.renderBufferDirect(c,b.fog,k,m,h,g);h.onAfterRender(S,b,c,k,m,g)}}function l(a){2===a.side?Y.disable(A.CULL_FACE):Y.enable(A.CULL_FACE);Y.setFlipSided(1===a.side);!0===a.transparent?Y.setBlending(a.blending,a.blendEquation,a.blendSrc,a.blendDst,a.blendEquationAlpha,a.blendSrcAlpha,a.blendDstAlpha,a.premultipliedAlpha):Y.setBlending(0);Y.setDepthFunc(a.depthFunc);Y.setDepthTest(a.depthTest);Y.setDepthWrite(a.depthWrite);Y.setColorWrite(a.colorWrite);Y.setPolygonOffset(a.polygonOffset,
11810 a.polygonOffsetFactor,a.polygonOffsetUnits)}function t(a,b,c,d){da=0;var e=ea.get(c);pa&&(sa||a!==W)&&ba.setState(c.clippingPlanes,c.clipIntersection,c.clipShadows,a,e,a===W&&c.id===L);!1===c.needsUpdate&&(void 0===e.program?c.needsUpdate=!0:c.fog&&e.fog!==b?c.needsUpdate=!0:c.lights&&e.lightsHash!==aa.hash?c.needsUpdate=!0:void 0===e.numClippingPlanes||e.numClippingPlanes===ba.numPlanes&&e.numIntersection===ba.numIntersection||(c.needsUpdate=!0));if(c.needsUpdate){a:{var h=ea.get(c),k=va.getParameters(c,
11811 aa,b,ba.numPlanes,ba.numIntersection,d),m=va.getProgramCode(c,k),p=h.program,n=!0;if(void 0===p)c.addEventListener("dispose",f);else if(p.code!==m)g(c);else if(void 0!==k.shaderID)break a;else n=!1;n&&(k.shaderID?(p=Gb[k.shaderID],h.__webglShader={name:c.type,uniforms:La.clone(p.uniforms),vertexShader:p.vertexShader,fragmentShader:p.fragmentShader}):h.__webglShader={name:c.type,uniforms:c.uniforms,vertexShader:c.vertexShader,fragmentShader:c.fragmentShader},c.__webglShader=h.__webglShader,p=va.acquireProgram(c,
11812 k,m),h.program=p,c.program=p);k=p.getAttributes();if(c.morphTargets)for(m=c.numSupportedMorphTargets=0;m<S.maxMorphTargets;m++)0<=k["morphTarget"+m]&&c.numSupportedMorphTargets++;if(c.morphNormals)for(m=c.numSupportedMorphNormals=0;m<S.maxMorphNormals;m++)0<=k["morphNormal"+m]&&c.numSupportedMorphNormals++;k=h.__webglShader.uniforms;if(!c.isShaderMaterial&&!c.isRawShaderMaterial||!0===c.clipping)h.numClippingPlanes=ba.numPlanes,h.numIntersection=ba.numIntersection,k.clippingPlanes=ba.uniform;h.fog=
11813 b;h.lightsHash=aa.hash;c.lights&&(k.ambientLightColor.value=aa.ambient,k.directionalLights.value=aa.directional,k.spotLights.value=aa.spot,k.pointLights.value=aa.point,k.hemisphereLights.value=aa.hemi,k.directionalShadowMap.value=aa.directionalShadowMap,k.directionalShadowMatrix.value=aa.directionalShadowMatrix,k.spotShadowMap.value=aa.spotShadowMap,k.spotShadowMatrix.value=aa.spotShadowMatrix,k.pointShadowMap.value=aa.pointShadowMap,k.pointShadowMatrix.value=aa.pointShadowMatrix);m=h.program.getUniforms();
11814 k=Ya.seqWithValue(m.seq,k);h.uniformsList=k}c.needsUpdate=!1}var w=!1,n=p=!1,h=e.program,k=h.getUniforms(),m=e.__webglShader.uniforms;h.id!==Q&&(A.useProgram(h.program),Q=h.id,n=p=w=!0);c.id!==L&&(L=c.id,p=!0);if(w||a!==W){k.set(A,a,"projectionMatrix");ia.logarithmicDepthBuffer&&k.setValue(A,"logDepthBufFC",2/(Math.log(a.far+1)/Math.LN2));a!==W&&(W=a,n=p=!0);if(c.isShaderMaterial||c.isMeshPhongMaterial||c.isMeshStandardMaterial||c.envMap)w=k.map.cameraPosition,void 0!==w&&w.setValue(A,Z.setFromMatrixPosition(a.matrixWorld));
11815 (c.isMeshPhongMaterial||c.isMeshLambertMaterial||c.isMeshBasicMaterial||c.isMeshStandardMaterial||c.isShaderMaterial||c.skinning)&&k.setValue(A,"viewMatrix",a.matrixWorldInverse);k.set(A,S,"toneMappingExposure");k.set(A,S,"toneMappingWhitePoint")}c.skinning&&(k.setOptional(A,d,"bindMatrix"),k.setOptional(A,d,"bindMatrixInverse"),a=d.skeleton)&&(ia.floatVertexTextures&&a.useVertexTexture?(k.set(A,a,"boneTexture"),k.set(A,a,"boneTextureWidth"),k.set(A,a,"boneTextureHeight")):k.setOptional(A,a,"boneMatrices"));
11816 if(p){c.lights&&(a=n,m.ambientLightColor.needsUpdate=a,m.directionalLights.needsUpdate=a,m.pointLights.needsUpdate=a,m.spotLights.needsUpdate=a,m.hemisphereLights.needsUpdate=a);b&&c.fog&&(m.fogColor.value=b.color,b.isFog?(m.fogNear.value=b.near,m.fogFar.value=b.far):b.isFogExp2&&(m.fogDensity.value=b.density));if(c.isMeshBasicMaterial||c.isMeshLambertMaterial||c.isMeshPhongMaterial||c.isMeshStandardMaterial||c.isMeshDepthMaterial){m.opacity.value=c.opacity;m.diffuse.value=c.color;c.emissive&&m.emissive.value.copy(c.emissive).multiplyScalar(c.emissiveIntensity);
11817 m.map.value=c.map;m.specularMap.value=c.specularMap;m.alphaMap.value=c.alphaMap;c.aoMap&&(m.aoMap.value=c.aoMap,m.aoMapIntensity.value=c.aoMapIntensity);var r;c.map?r=c.map:c.specularMap?r=c.specularMap:c.displacementMap?r=c.displacementMap:c.normalMap?r=c.normalMap:c.bumpMap?r=c.bumpMap:c.roughnessMap?r=c.roughnessMap:c.metalnessMap?r=c.metalnessMap:c.alphaMap?r=c.alphaMap:c.emissiveMap&&(r=c.emissiveMap);void 0!==r&&(r.isWebGLRenderTarget&&(r=r.texture),b=r.offset,r=r.repeat,m.offsetRepeat.value.set(b.x,
11818 b.y,r.x,r.y));m.envMap.value=c.envMap;m.flipEnvMap.value=c.envMap&&c.envMap.isCubeTexture?-1:1;m.reflectivity.value=c.reflectivity;m.refractionRatio.value=c.refractionRatio}c.isLineBasicMaterial?(m.diffuse.value=c.color,m.opacity.value=c.opacity):c.isLineDashedMaterial?(m.diffuse.value=c.color,m.opacity.value=c.opacity,m.dashSize.value=c.dashSize,m.totalSize.value=c.dashSize+c.gapSize,m.scale.value=c.scale):c.isPointsMaterial?(m.diffuse.value=c.color,m.opacity.value=c.opacity,m.size.value=c.size*
11819 Qa,m.scale.value=.5*pc,m.map.value=c.map,null!==c.map&&(r=c.map.offset,c=c.map.repeat,m.offsetRepeat.value.set(r.x,r.y,c.x,c.y))):c.isMeshLambertMaterial?(c.lightMap&&(m.lightMap.value=c.lightMap,m.lightMapIntensity.value=c.lightMapIntensity),c.emissiveMap&&(m.emissiveMap.value=c.emissiveMap)):c.isMeshPhongMaterial?(m.specular.value=c.specular,m.shininess.value=Math.max(c.shininess,1E-4),c.lightMap&&(m.lightMap.value=c.lightMap,m.lightMapIntensity.value=c.lightMapIntensity),c.emissiveMap&&(m.emissiveMap.value=
11820 c.emissiveMap),c.bumpMap&&(m.bumpMap.value=c.bumpMap,m.bumpScale.value=c.bumpScale),c.normalMap&&(m.normalMap.value=c.normalMap,m.normalScale.value.copy(c.normalScale)),c.displacementMap&&(m.displacementMap.value=c.displacementMap,m.displacementScale.value=c.displacementScale,m.displacementBias.value=c.displacementBias)):c.isMeshPhysicalMaterial?(m.clearCoat.value=c.clearCoat,m.clearCoatRoughness.value=c.clearCoatRoughness,D(m,c)):c.isMeshStandardMaterial?D(m,c):c.isMeshDepthMaterial?c.displacementMap&&
11821 (m.displacementMap.value=c.displacementMap,m.displacementScale.value=c.displacementScale,m.displacementBias.value=c.displacementBias):c.isMeshNormalMaterial&&(m.opacity.value=c.opacity);Ya.upload(A,e.uniformsList,m,S)}k.set(A,d,"modelViewMatrix");k.set(A,d,"normalMatrix");k.setValue(A,"modelMatrix",d.matrixWorld);return h}function D(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);
11822 b.lightMap&&(a.lightMap.value=b.lightMap,a.lightMapIntensity.value=b.lightMapIntensity);b.emissiveMap&&(a.emissiveMap.value=b.emissiveMap);b.bumpMap&&(a.bumpMap.value=b.bumpMap,a.bumpScale.value=b.bumpScale);b.normalMap&&(a.normalMap.value=b.normalMap,a.normalScale.value.copy(b.normalScale));b.displacementMap&&(a.displacementMap.value=b.displacementMap,a.displacementScale.value=b.displacementScale,a.displacementBias.value=b.displacementBias);b.envMap&&(a.envMapIntensity.value=b.envMapIntensity)}function u(a){var b;
11823 if(1E3===a)return A.REPEAT;if(1001===a)return A.CLAMP_TO_EDGE;if(1002===a)return A.MIRRORED_REPEAT;if(1003===a)return A.NEAREST;if(1004===a)return A.NEAREST_MIPMAP_NEAREST;if(1005===a)return A.NEAREST_MIPMAP_LINEAR;if(1006===a)return A.LINEAR;if(1007===a)return A.LINEAR_MIPMAP_NEAREST;if(1008===a)return A.LINEAR_MIPMAP_LINEAR;if(1009===a)return A.UNSIGNED_BYTE;if(1017===a)return A.UNSIGNED_SHORT_4_4_4_4;if(1018===a)return A.UNSIGNED_SHORT_5_5_5_1;if(1019===a)return A.UNSIGNED_SHORT_5_6_5;if(1010===
11824 a)return A.BYTE;if(1011===a)return A.SHORT;if(1012===a)return A.UNSIGNED_SHORT;if(1013===a)return A.INT;if(1014===a)return A.UNSIGNED_INT;if(1015===a)return A.FLOAT;if(1016===a&&(b=ka.get("OES_texture_half_float"),null!==b))return b.HALF_FLOAT_OES;if(1021===a)return A.ALPHA;if(1022===a)return A.RGB;if(1023===a)return A.RGBA;if(1024===a)return A.LUMINANCE;if(1025===a)return A.LUMINANCE_ALPHA;if(1026===a)return A.DEPTH_COMPONENT;if(1027===a)return A.DEPTH_STENCIL;if(100===a)return A.FUNC_ADD;if(101===
11825 a)return A.FUNC_SUBTRACT;if(102===a)return A.FUNC_REVERSE_SUBTRACT;if(200===a)return A.ZERO;if(201===a)return A.ONE;if(202===a)return A.SRC_COLOR;if(203===a)return A.ONE_MINUS_SRC_COLOR;if(204===a)return A.SRC_ALPHA;if(205===a)return A.ONE_MINUS_SRC_ALPHA;if(206===a)return A.DST_ALPHA;if(207===a)return A.ONE_MINUS_DST_ALPHA;if(208===a)return A.DST_COLOR;if(209===a)return A.ONE_MINUS_DST_COLOR;if(210===a)return A.SRC_ALPHA_SATURATE;if(2001===a||2002===a||2003===a||2004===a)if(b=ka.get("WEBGL_compressed_texture_s3tc"),
11826 null!==b){if(2001===a)return b.COMPRESSED_RGB_S3TC_DXT1_EXT;if(2002===a)return b.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(2003===a)return b.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(2004===a)return b.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(2100===a||2101===a||2102===a||2103===a)if(b=ka.get("WEBGL_compressed_texture_pvrtc"),null!==b){if(2100===a)return b.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(2101===a)return b.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(2102===a)return b.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(2103===a)return b.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(2151===
11827 a&&(b=ka.get("WEBGL_compressed_texture_etc1"),null!==b))return b.COMPRESSED_RGB_ETC1_WEBGL;if(103===a||104===a)if(b=ka.get("EXT_blend_minmax"),null!==b){if(103===a)return b.MIN_EXT;if(104===a)return b.MAX_EXT}return 1020===a&&(b=ka.get("WEBGL_depth_texture"),null!==b)?b.UNSIGNED_INT_24_8_WEBGL:0}console.log("THREE.WebGLRenderer","82");a=a||{};var v=void 0!==a.canvas?a.canvas:document.createElementNS("http://www.w3.org/1999/xhtml","canvas"),I=void 0!==a.context?a.context:null,y=void 0!==a.alpha?a.alpha:
11828 !1,E=void 0!==a.depth?a.depth:!0,H=void 0!==a.stencil?a.stencil:!0,F=void 0!==a.antialias?a.antialias:!1,M=void 0!==a.premultipliedAlpha?a.premultipliedAlpha:!0,ca=void 0!==a.preserveDrawingBuffer?a.preserveDrawingBuffer:!1,K=[],B=[],C=-1,z=[],Ka=-1,N=new Float32Array(8),P=[],R=[];this.domElement=v;this.context=null;this.sortObjects=this.autoClearStencil=this.autoClearDepth=this.autoClearColor=this.autoClear=!0;this.clippingPlanes=[];this.localClippingEnabled=!1;this.gammaFactor=2;this.physicallyCorrectLights=
11829 this.gammaOutput=this.gammaInput=!1;this.toneMappingWhitePoint=this.toneMappingExposure=this.toneMapping=1;this.maxMorphTargets=8;this.maxMorphNormals=4;var S=this,Q=null,V=null,T=null,L=-1,U="",W=null,X=new ga,fb=null,$a=new ga,da=0,Da=new O(0),Ra=0,Pa=v.width,pc=v.height,Qa=1,ha=new ga(0,0,Pa,pc),la=!1,fa=new ga(0,0,Pa,pc),oa=new nc,ba=new Bf,pa=!1,sa=!1,na=new Ca,ra=new J,Z=new q,aa={hash:"",ambient:[0,0,0],directional:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadowMap:[],
11830 spotShadowMatrix:[],point:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],shadows:[]},ma={calls:0,vertices:0,faces:0,points:0};this.info={render:ma,memory:{geometries:0,textures:0},programs:null};var A;try{y={alpha:y,depth:E,stencil:H,antialias:F,premultipliedAlpha:M,preserveDrawingBuffer:ca};A=I||v.getContext("webgl",y)||v.getContext("experimental-webgl",y);if(null===A){if(null!==v.getContext("webgl"))throw"Error creating WebGL context with your selected attributes.";throw"Error creating WebGL context.";
11831 }void 0===A.getShaderPrecisionFormat&&(A.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}});v.addEventListener("webglcontextlost",e,!1)}catch(Cf){console.error("THREE.WebGLRenderer: "+Cf)}var ka=new Af(A);ka.get("WEBGL_depth_texture");ka.get("OES_texture_float");ka.get("OES_texture_float_linear");ka.get("OES_texture_half_float");ka.get("OES_texture_half_float_linear");ka.get("OES_standard_derivatives");ka.get("ANGLE_instanced_arrays");ka.get("OES_element_index_uint")&&
11832 (G.MaxIndex=4294967296);var ia=new zf(A,ka,a),Y=new yf(A,ka,u),ea=new xf,ua=new wf(A,ka,Y,ea,ia,u,this.info),qa=new vf(A,ea,this.info),va=new tf(this,ia),za=new lf;this.info.programs=va.programs;var Ga=new kf(A,ka,ma),Ha=new jf(A,ka,ma),Ia=new Hb(-1,1,1,-1,0,1),wa=new Ea,Ba=new ya(new ib(2,2),new Ma({depthTest:!1,depthWrite:!1,fog:!1}));a=Gb.cube;var xa=new ya(new hb(5,5,5),new Fa({uniforms:a.uniforms,vertexShader:a.vertexShader,fragmentShader:a.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1}));
11833 c();this.context=A;this.capabilities=ia;this.extensions=ka;this.properties=ea;this.state=Y;var Ja=new pe(this,aa,qa,ia);this.shadowMap=Ja;var Na=new hf(this,P),Oa=new ff(this,R);this.getContext=function(){return A};this.getContextAttributes=function(){return A.getContextAttributes()};this.forceContextLoss=function(){ka.get("WEBGL_lose_context").loseContext()};this.getMaxAnisotropy=function(){return ia.getMaxAnisotropy()};this.getPrecision=function(){return ia.precision};this.getPixelRatio=function(){return Qa};
11834 this.setPixelRatio=function(a){void 0!==a&&(Qa=a,this.setSize(fa.z,fa.w,!1))};this.getSize=function(){return{width:Pa,height:pc}};this.setSize=function(a,b,c){Pa=a;pc=b;v.width=a*Qa;v.height=b*Qa;!1!==c&&(v.style.width=a+"px",v.style.height=b+"px");this.setViewport(0,0,a,b)};this.setViewport=function(a,b,c,d){Y.viewport(fa.set(a,b,c,d))};this.setScissor=function(a,b,c,d){Y.scissor(ha.set(a,b,c,d))};this.setScissorTest=function(a){Y.setScissorTest(la=a)};this.getClearColor=function(){return Da};this.setClearColor=
11835 function(a,c){Da.set(a);Ra=void 0!==c?c:1;b(Da.r,Da.g,Da.b,Ra)};this.getClearAlpha=function(){return Ra};this.setClearAlpha=function(a){Ra=a;b(Da.r,Da.g,Da.b,Ra)};this.clear=function(a,b,c){var d=0;if(void 0===a||a)d|=A.COLOR_BUFFER_BIT;if(void 0===b||b)d|=A.DEPTH_BUFFER_BIT;if(void 0===c||c)d|=A.STENCIL_BUFFER_BIT;A.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,
11836 b,c,d){this.setRenderTarget(a);this.clear(b,c,d)};this.resetGLState=d;this.dispose=function(){z=[];Ka=-1;B=[];C=-1;v.removeEventListener("webglcontextlost",e,!1)};this.renderBufferImmediate=function(a,b,c){Y.initAttributes();var d=ea.get(a);a.hasPositions&&!d.position&&(d.position=A.createBuffer());a.hasNormals&&!d.normal&&(d.normal=A.createBuffer());a.hasUvs&&!d.uv&&(d.uv=A.createBuffer());a.hasColors&&!d.color&&(d.color=A.createBuffer());b=b.getAttributes();a.hasPositions&&(A.bindBuffer(A.ARRAY_BUFFER,
11837 d.position),A.bufferData(A.ARRAY_BUFFER,a.positionArray,A.DYNAMIC_DRAW),Y.enableAttribute(b.position),A.vertexAttribPointer(b.position,3,A.FLOAT,!1,0,0));if(a.hasNormals){A.bindBuffer(A.ARRAY_BUFFER,d.normal);if(!c.isMeshPhongMaterial&&!c.isMeshStandardMaterial&&1===c.shading)for(var e=0,f=3*a.count;e<f;e+=9){var g=a.normalArray,h=(g[e+0]+g[e+3]+g[e+6])/3,k=(g[e+1]+g[e+4]+g[e+7])/3,m=(g[e+2]+g[e+5]+g[e+8])/3;g[e+0]=h;g[e+1]=k;g[e+2]=m;g[e+3]=h;g[e+4]=k;g[e+5]=m;g[e+6]=h;g[e+7]=k;g[e+8]=m}A.bufferData(A.ARRAY_BUFFER,
11838 a.normalArray,A.DYNAMIC_DRAW);Y.enableAttribute(b.normal);A.vertexAttribPointer(b.normal,3,A.FLOAT,!1,0,0)}a.hasUvs&&c.map&&(A.bindBuffer(A.ARRAY_BUFFER,d.uv),A.bufferData(A.ARRAY_BUFFER,a.uvArray,A.DYNAMIC_DRAW),Y.enableAttribute(b.uv),A.vertexAttribPointer(b.uv,2,A.FLOAT,!1,0,0));a.hasColors&&0!==c.vertexColors&&(A.bindBuffer(A.ARRAY_BUFFER,d.color),A.bufferData(A.ARRAY_BUFFER,a.colorArray,A.DYNAMIC_DRAW),Y.enableAttribute(b.color),A.vertexAttribPointer(b.color,3,A.FLOAT,!1,0,0));Y.disableUnusedAttributes();
11839 A.drawArrays(A.TRIANGLES,0,a.count);a.count=0};this.renderBufferDirect=function(a,b,c,d,e,f){l(d);var g=t(a,b,d,e),k=!1;a=c.id+"_"+g.id+"_"+d.wireframe;a!==U&&(U=a,k=!0);b=e.morphTargetInfluences;if(void 0!==b){var m=[];a=0;for(var p=b.length;a<p;a++)k=b[a],m.push([k,a]);m.sort(h);8<m.length&&(m.length=8);var n=c.morphAttributes;a=0;for(p=m.length;a<p;a++)k=m[a],N[a]=k[0],0!==k[0]?(b=k[1],!0===d.morphTargets&&n.position&&c.addAttribute("morphTarget"+a,n.position[b]),!0===d.morphNormals&&n.normal&&
11840 c.addAttribute("morphNormal"+a,n.normal[b])):(!0===d.morphTargets&&c.removeAttribute("morphTarget"+a),!0===d.morphNormals&&c.removeAttribute("morphNormal"+a));a=m.length;for(b=N.length;a<b;a++)N[a]=0;g.getUniforms().setValue(A,"morphTargetInfluences",N);k=!0}b=c.index;p=c.attributes.position;m=1;!0===d.wireframe&&(b=qa.getWireframeAttribute(c),m=2);null!==b?(a=Ha,a.setIndex(b)):a=Ga;if(k){a:{var k=void 0,w;if(c&&c.isInstancedBufferGeometry&&(w=ka.get("ANGLE_instanced_arrays"),null===w)){console.error("THREE.WebGLRenderer.setupVertexAttributes: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");
11841 break a}void 0===k&&(k=0);Y.initAttributes();var n=c.attributes,g=g.getAttributes(),r=d.defaultAttributeValues,v;for(v in g){var q=g[v];if(0<=q){var u=n[v];if(void 0!==u){var y=A.FLOAT,D=u.array,H=u.normalized;D instanceof Float32Array?y=A.FLOAT:D instanceof Float64Array?console.warn("Unsupported data buffer format: Float64Array"):D instanceof Uint16Array?y=A.UNSIGNED_SHORT:D instanceof Int16Array?y=A.SHORT:D instanceof Uint32Array?y=A.UNSIGNED_INT:D instanceof Int32Array?y=A.INT:D instanceof Int8Array?
11842 y=A.BYTE:D instanceof Uint8Array&&(y=A.UNSIGNED_BYTE);var D=u.itemSize,F=qa.getAttributeBuffer(u);if(u.isInterleavedBufferAttribute){var I=u.data,E=I.stride,u=u.offset;I&&I.isInstancedInterleavedBuffer?(Y.enableAttributeAndDivisor(q,I.meshPerAttribute,w),void 0===c.maxInstancedCount&&(c.maxInstancedCount=I.meshPerAttribute*I.count)):Y.enableAttribute(q);A.bindBuffer(A.ARRAY_BUFFER,F);A.vertexAttribPointer(q,D,y,H,E*I.array.BYTES_PER_ELEMENT,(k*E+u)*I.array.BYTES_PER_ELEMENT)}else u.isInstancedBufferAttribute?
11843 (Y.enableAttributeAndDivisor(q,u.meshPerAttribute,w),void 0===c.maxInstancedCount&&(c.maxInstancedCount=u.meshPerAttribute*u.count)):Y.enableAttribute(q),A.bindBuffer(A.ARRAY_BUFFER,F),A.vertexAttribPointer(q,D,y,H,0,k*D*u.array.BYTES_PER_ELEMENT)}else if(void 0!==r&&(y=r[v],void 0!==y))switch(y.length){case 2:A.vertexAttrib2fv(q,y);break;case 3:A.vertexAttrib3fv(q,y);break;case 4:A.vertexAttrib4fv(q,y);break;default:A.vertexAttrib1fv(q,y)}}}Y.disableUnusedAttributes()}null!==b&&A.bindBuffer(A.ELEMENT_ARRAY_BUFFER,
11844 qa.getAttributeBuffer(b))}w=0;null!==b?w=b.count:void 0!==p&&(w=p.count);b=c.drawRange.start*m;p=null!==f?f.start*m:0;v=Math.max(b,p);f=Math.max(0,Math.min(w,b+c.drawRange.count*m,p+(null!==f?f.count*m:Infinity))-1-v+1);if(0!==f){if(e.isMesh)if(!0===d.wireframe)Y.setLineWidth(d.wireframeLinewidth*(null===V?Qa:1)),a.setMode(A.LINES);else switch(e.drawMode){case 0:a.setMode(A.TRIANGLES);break;case 1:a.setMode(A.TRIANGLE_STRIP);break;case 2:a.setMode(A.TRIANGLE_FAN)}else e.isLine?(d=d.linewidth,void 0===
11845 d&&(d=1),Y.setLineWidth(d*(null===V?Qa:1)),e.isLineSegments?a.setMode(A.LINES):a.setMode(A.LINE_STRIP)):e.isPoints&&a.setMode(A.POINTS);c&&c.isInstancedBufferGeometry?0<c.maxInstancedCount&&a.renderInstances(c,v,f):a.render(v,f)}};this.render=function(a,c,d,e){if(void 0!==c&&!0!==c.isCamera)console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");else{U="";L=-1;W=null;!0===a.autoUpdate&&a.updateMatrixWorld();null===c.parent&&c.updateMatrixWorld();c.matrixWorldInverse.getInverse(c.matrixWorld);
11846 ra.multiplyMatrices(c.projectionMatrix,c.matrixWorldInverse);oa.setFromMatrix(ra);K.length=0;Ka=C=-1;P.length=0;R.length=0;sa=this.localClippingEnabled;pa=ba.init(this.clippingPlanes,sa,c);p(a,c);B.length=C+1;z.length=Ka+1;!0===S.sortObjects&&(B.sort(k),z.sort(m));pa&&ba.beginShadows();for(var f=K,g=0,h=0,n=f.length;h<n;h++){var w=f[h];w.castShadow&&(aa.shadows[g++]=w)}aa.shadows.length=g;Ja.render(a,c);for(var f=K,l=w=0,x=0,t,v,q,u,y=c.matrixWorldInverse,D=0,H=0,F=0,I=0,g=0,h=f.length;g<h;g++)if(n=
11847 f[g],t=n.color,v=n.intensity,q=n.distance,u=n.shadow&&n.shadow.map?n.shadow.map.texture:null,n.isAmbientLight)w+=t.r*v,l+=t.g*v,x+=t.b*v;else if(n.isDirectionalLight){var E=za.get(n);E.color.copy(n.color).multiplyScalar(n.intensity);E.direction.setFromMatrixPosition(n.matrixWorld);Z.setFromMatrixPosition(n.target.matrixWorld);E.direction.sub(Z);E.direction.transformDirection(y);if(E.shadow=n.castShadow)E.shadowBias=n.shadow.bias,E.shadowRadius=n.shadow.radius,E.shadowMapSize=n.shadow.mapSize;aa.directionalShadowMap[D]=
11848 u;aa.directionalShadowMatrix[D]=n.shadow.matrix;aa.directional[D++]=E}else if(n.isSpotLight){E=za.get(n);E.position.setFromMatrixPosition(n.matrixWorld);E.position.applyMatrix4(y);E.color.copy(t).multiplyScalar(v);E.distance=q;E.direction.setFromMatrixPosition(n.matrixWorld);Z.setFromMatrixPosition(n.target.matrixWorld);E.direction.sub(Z);E.direction.transformDirection(y);E.coneCos=Math.cos(n.angle);E.penumbraCos=Math.cos(n.angle*(1-n.penumbra));E.decay=0===n.distance?0:n.decay;if(E.shadow=n.castShadow)E.shadowBias=
11849 n.shadow.bias,E.shadowRadius=n.shadow.radius,E.shadowMapSize=n.shadow.mapSize;aa.spotShadowMap[F]=u;aa.spotShadowMatrix[F]=n.shadow.matrix;aa.spot[F++]=E}else if(n.isPointLight){E=za.get(n);E.position.setFromMatrixPosition(n.matrixWorld);E.position.applyMatrix4(y);E.color.copy(n.color).multiplyScalar(n.intensity);E.distance=n.distance;E.decay=0===n.distance?0:n.decay;if(E.shadow=n.castShadow)E.shadowBias=n.shadow.bias,E.shadowRadius=n.shadow.radius,E.shadowMapSize=n.shadow.mapSize;aa.pointShadowMap[H]=
11850 u;void 0===aa.pointShadowMatrix[H]&&(aa.pointShadowMatrix[H]=new J);Z.setFromMatrixPosition(n.matrixWorld).negate();aa.pointShadowMatrix[H].identity().setPosition(Z);aa.point[H++]=E}else n.isHemisphereLight&&(E=za.get(n),E.direction.setFromMatrixPosition(n.matrixWorld),E.direction.transformDirection(y),E.direction.normalize(),E.skyColor.copy(n.color).multiplyScalar(v),E.groundColor.copy(n.groundColor).multiplyScalar(v),aa.hemi[I++]=E);aa.ambient[0]=w;aa.ambient[1]=l;aa.ambient[2]=x;aa.directional.length=
11851 D;aa.spot.length=F;aa.point.length=H;aa.hemi.length=I;aa.hash=D+","+H+","+F+","+I+","+aa.shadows.length;pa&&ba.endShadows();ma.calls=0;ma.vertices=0;ma.faces=0;ma.points=0;void 0===d&&(d=null);this.setRenderTarget(d);f=a.background;null===f?b(Da.r,Da.g,Da.b,Ra):f&&f.isColor&&(b(f.r,f.g,f.b,1),e=!0);(this.autoClear||e)&&this.clear(this.autoClearColor,this.autoClearDepth,this.autoClearStencil);f&&f.isCubeTexture?(wa.projectionMatrix.copy(c.projectionMatrix),wa.matrixWorld.extractRotation(c.matrixWorld),
11852 wa.matrixWorldInverse.getInverse(wa.matrixWorld),xa.material.uniforms.tCube.value=f,xa.modelViewMatrix.multiplyMatrices(wa.matrixWorldInverse,xa.matrixWorld),qa.update(xa),S.renderBufferDirect(wa,null,xa.geometry,xa.material,xa,null)):f&&f.isTexture&&(Ba.material.map=f,qa.update(Ba),S.renderBufferDirect(Ia,null,Ba.geometry,Ba.material,Ba,null));a.overrideMaterial?(e=a.overrideMaterial,r(B,a,c,e),r(z,a,c,e)):(Y.setBlending(0),r(B,a,c),r(z,a,c));Na.render(a,c);Oa.render(a,c,$a);d&&ua.updateRenderTargetMipmap(d);
11853 Y.setDepthTest(!0);Y.setDepthWrite(!0);Y.setColorWrite(!0)}};this.setFaceCulling=function(a,b){Y.setCullFace(a);Y.setFlipSided(0===b)};this.allocTextureUnit=function(){var a=da;a>=ia.maxTextures&&console.warn("WebGLRenderer: trying to use "+a+" texture units while this GPU supports only "+ia.maxTextures);da+=1;return a};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."),
11854 a=!0),b=b.texture);ua.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);ua.setTexture2D(b,c)}}();this.setTextureCube=function(){var a=!1;return function(b,c){b&&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)&&
11855 6===b.image.length?ua.setTextureCube(b,c):ua.setTextureCubeDynamic(b,c)}}();this.getCurrentRenderTarget=function(){return V};this.setRenderTarget=function(a){(V=a)&&void 0===ea.get(a).__webglFramebuffer&&ua.setupRenderTarget(a);var b=a&&a.isWebGLRenderTargetCube,c;a?(c=ea.get(a),c=b?c.__webglFramebuffer[a.activeCubeFace]:c.__webglFramebuffer,X.copy(a.scissor),fb=a.scissorTest,$a.copy(a.viewport)):(c=null,X.copy(ha).multiplyScalar(Qa),fb=la,$a.copy(fa).multiplyScalar(Qa));T!==c&&(A.bindFramebuffer(A.FRAMEBUFFER,
11856 c),T=c);Y.scissor(X);Y.setScissorTest(fb);Y.viewport($a);b&&(b=ea.get(a.texture),A.framebufferTexture2D(A.FRAMEBUFFER,A.COLOR_ATTACHMENT0,A.TEXTURE_CUBE_MAP_POSITIVE_X+a.activeCubeFace,b.__webglTexture,a.activeMipMapLevel))};this.readRenderTargetPixels=function(a,b,c,d,e,f){if(!1===(a&&a.isWebGLRenderTarget))console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");else{var g=ea.get(a).__webglFramebuffer;if(g){var h=!1;g!==T&&(A.bindFramebuffer(A.FRAMEBUFFER,
11857 g),h=!0);try{var k=a.texture,m=k.format,n=k.type;1023!==m&&u(m)!==A.getParameter(A.IMPLEMENTATION_COLOR_READ_FORMAT)?console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format."):1009===n||u(n)===A.getParameter(A.IMPLEMENTATION_COLOR_READ_TYPE)||1015===n&&(ka.get("OES_texture_float")||ka.get("WEBGL_color_buffer_float"))||1016===n&&ka.get("EXT_color_buffer_half_float")?A.checkFramebufferStatus(A.FRAMEBUFFER)===A.FRAMEBUFFER_COMPLETE?0<=b&&
11858 b<=a.width-d&&0<=c&&c<=a.height-e&&A.readPixels(b,c,d,e,u(m),u(n),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&&A.bindFramebuffer(A.FRAMEBUFFER,T)}}}}}function Ib(a,b){this.name="";this.color=new O(a);this.density=void 0!==b?b:2.5E-4}function Jb(a,b,c){this.name="";this.color=
11859 new O(a);this.near=void 0!==b?b:1;this.far=void 0!==c?c:1E3}function jb(){z.call(this);this.type="Scene";this.overrideMaterial=this.fog=this.background=null;this.autoUpdate=!0}function Ed(a,b,c,d,e){z.call(this);this.lensFlares=[];this.positionScreen=new q;this.customUpdateCallback=void 0;void 0!==a&&this.add(a,b,c,d,e)}function kb(a){U.call(this);this.type="SpriteMaterial";this.color=new O(16777215);this.map=null;this.rotation=0;this.lights=this.fog=!1;this.setValues(a)}function qc(a){z.call(this);
11860 this.type="Sprite";this.material=void 0!==a?a:new kb}function rc(){z.call(this);this.type="LOD";Object.defineProperties(this,{levels:{enumerable:!0,value:[]}})}function lb(a,b,c,d,e,f,g,h,k,m,w,n){da.call(this,null,f,g,h,k,m,d,e,w,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 bd(a,b,c){this.useVertexTexture=void 0!==c?c:!0;this.identityMatrix=new J;a=a||[];this.bones=a.slice(0);
11861 this.useVertexTexture?(a=Math.sqrt(4*this.bones.length),a=T.nextPowerOfTwo(Math.ceil(a)),this.boneTextureHeight=this.boneTextureWidth=a=Math.max(a,4),this.boneMatrices=new Float32Array(this.boneTextureWidth*this.boneTextureHeight*4),this.boneTexture=new lb(this.boneMatrices,this.boneTextureWidth,this.boneTextureHeight,1023,1015)):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 bonInverses is the wrong length."),
11862 this.boneInverses=[],b=0,a=this.bones.length;b<a;b++)this.boneInverses.push(new J)}function cd(a){z.call(this);this.type="Bone";this.skin=a}function dd(a,b,c){ya.call(this,a,b);this.type="SkinnedMesh";this.bindMode="attached";this.bindMatrix=new J;this.bindMatrixInverse=new J;a=[];if(this.geometry&&void 0!==this.geometry.bones){for(var d,e=0,f=this.geometry.bones.length;e<f;++e)d=this.geometry.bones[e],b=new cd(this),a.push(b),b.name=d.name,b.position.fromArray(d.pos),b.quaternion.fromArray(d.rotq),
11863 void 0!==d.scl&&b.scale.fromArray(d.scl);e=0;for(f=this.geometry.bones.length;e<f;++e)d=this.geometry.bones[e],-1!==d.parent&&null!==d.parent&&void 0!==a[d.parent]?a[d.parent].add(a[e]):this.add(a[e])}this.normalizeSkinWeights();this.updateMatrixWorld(!0);this.bind(new bd(a,void 0,c),this.matrixWorld)}function oa(a){U.call(this);this.type="LineBasicMaterial";this.color=new O(16777215);this.linewidth=1;this.linejoin=this.linecap="round";this.lights=!1;this.setValues(a)}function Ta(a,b,c){if(1===c)return console.warn("THREE.Line: parameter THREE.LinePieces no longer supported. Created THREE.LineSegments instead."),
11864 new la(a,b);z.call(this);this.type="Line";this.geometry=void 0!==a?a:new G;this.material=void 0!==b?b:new oa({color:16777215*Math.random()})}function la(a,b){Ta.call(this,a,b);this.type="LineSegments"}function xa(a){U.call(this);this.type="PointsMaterial";this.color=new O(16777215);this.map=null;this.size=1;this.sizeAttenuation=!0;this.lights=!1;this.setValues(a)}function Kb(a,b){z.call(this);this.type="Points";this.geometry=void 0!==a?a:new G;this.material=void 0!==b?b:new xa({color:16777215*Math.random()})}
11865 function sc(){z.call(this);this.type="Group"}function ed(a,b,c,d,e,f,g,h,k){function m(){requestAnimationFrame(m);a.readyState>=a.HAVE_CURRENT_DATA&&(w.needsUpdate=!0)}da.call(this,a,b,c,d,e,f,g,h,k);this.generateMipmaps=!1;var w=this;m()}function Lb(a,b,c,d,e,f,g,h,k,m,w,n){da.call(this,null,f,g,h,k,m,d,e,w,n);this.image={width:b,height:c};this.mipmaps=a;this.generateMipmaps=this.flipY=!1}function fd(a,b,c,d,e,f,g,h,k){da.call(this,a,b,c,d,e,f,g,h,k);this.needsUpdate=!0}function tc(a,b,c,d,e,f,g,
11866 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");da.call(this,null,d,e,f,g,h,m,c,k);this.image={width:a,height:b};this.type=void 0!==c?c:1012;this.magFilter=void 0!==g?g:1003;this.minFilter=void 0!==h?h:1003;this.generateMipmaps=this.flipY=!1}function Mb(a){function b(a,b){return a-b}G.call(this);var c=[0,0],d={},e=["a","b","c"];if(a&&a.isGeometry){var f=a.vertices,g=a.faces,h=0,k=new Uint32Array(6*g.length);
11867 a=0;for(var m=g.length;a<m;a++)for(var w=g[a],n=0;3>n;n++){c[0]=w[e[n]];c[1]=w[e[(n+1)%3]];c.sort(b);var p=c.toString();void 0===d[p]&&(k[2*h]=c[0],k[2*h+1]=c[1],d[p]=!0,h++)}c=new Float32Array(6*h);a=0;for(m=h;a<m;a++)for(n=0;2>n;n++)d=f[k[2*a+n]],h=6*a+3*n,c[h+0]=d.x,c[h+1]=d.y,c[h+2]=d.z;this.addAttribute("position",new C(c,3))}else if(a&&a.isBufferGeometry){if(null!==a.index){m=a.index.array;f=a.attributes.position;e=a.groups;h=0;0===e.length&&a.addGroup(0,m.length);k=new Uint32Array(2*m.length);
11868 g=0;for(w=e.length;g<w;++g){a=e[g];n=a.start;p=a.count;a=n;for(var r=n+p;a<r;a+=3)for(n=0;3>n;n++)c[0]=m[a+n],c[1]=m[a+(n+1)%3],c.sort(b),p=c.toString(),void 0===d[p]&&(k[2*h]=c[0],k[2*h+1]=c[1],d[p]=!0,h++)}c=new Float32Array(6*h);a=0;for(m=h;a<m;a++)for(n=0;2>n;n++)h=6*a+3*n,d=k[2*a+n],c[h+0]=f.getX(d),c[h+1]=f.getY(d),c[h+2]=f.getZ(d)}else for(f=a.attributes.position.array,h=f.length/3,k=h/3,c=new Float32Array(6*h),a=0,m=k;a<m;a++)for(n=0;3>n;n++)h=18*a+6*n,k=9*a+3*n,c[h+0]=f[k],c[h+1]=f[k+1],
11869 c[h+2]=f[k+2],d=9*a+(n+1)%3*3,c[h+3]=f[d],c[h+4]=f[d+1],c[h+5]=f[d+2];this.addAttribute("position",new C(c,3))}}function Nb(a,b,c){G.call(this);this.type="ParametricBufferGeometry";this.parameters={func:a,slices:b,stacks:c};var d=[],e=[],f,g,h,k,m,w=b+1;for(f=0;f<=c;f++)for(m=f/c,g=0;g<=b;g++)k=g/b,h=a(k,m),d.push(h.x,h.y,h.z),e.push(k,m);a=[];var n;for(f=0;f<c;f++)for(g=0;g<b;g++)h=f*w+g,k=f*w+g+1,m=(f+1)*w+g+1,n=(f+1)*w+g,a.push(h,k,n),a.push(k,m,n);this.setIndex((65535<a.length?$c:Zc)(a,1));this.addAttribute("position",
11870 ha(d,3));this.addAttribute("uv",ha(e,2));this.computeVertexNormals()}function uc(a,b,c){Q.call(this);this.type="ParametricGeometry";this.parameters={func:a,slices:b,stacks:c};this.fromBufferGeometry(new Nb(a,b,c));this.mergeVertices()}function ua(a,b,c,d){function e(a){h.push(a.x,a.y,a.z)}function f(b,c){var d=3*b;c.x=a[d+0];c.y=a[d+1];c.z=a[d+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)}G.call(this);this.type="PolyhedronBufferGeometry";this.parameters=
11871 {vertices:a,indices:b,radius:c,detail:d};c=c||1;var h=[],k=[];(function(a){for(var c=new q,d=new q,g=new q,h=0;h<b.length;h+=3){f(b[h+0],c);f(b[h+1],d);f(b[h+2],g);var k=c,l=d,D=g,u=Math.pow(2,a),v=[],I,y;for(I=0;I<=u;I++){v[I]=[];var E=k.clone().lerp(D,I/u),H=l.clone().lerp(D,I/u),F=u-I;for(y=0;y<=F;y++)v[I][y]=0===y&&I===u?E:E.clone().lerp(H,y/F)}for(I=0;I<u;I++)for(y=0;y<2*(u-I)-1;y++)k=Math.floor(y/2),0===y%2?(e(v[I][k+1]),e(v[I+1][k]),e(v[I][k])):(e(v[I][k+1]),e(v[I+1][k+1]),e(v[I+1][k]))}})(d||
11872 0);(function(a){for(var b=new q,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 q,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));for(var a=new q,b=new q,c=new q,d=new q,e=new B,f=new B,l=new B,D=0,u=0;D<h.length;D+=9,u+=6){a.set(h[D+0],h[D+1],h[D+2]);b.set(h[D+3],h[D+4],h[D+5]);c.set(h[D+6],h[D+
11873 7],h[D+8]);e.set(k[u+0],k[u+1]);f.set(k[u+2],k[u+3]);l.set(k[u+4],k[u+5]);d.copy(a).add(b).add(c).divideScalar(3);var v=Math.atan2(d.z,-d.x);g(e,u+0,a,v);g(f,u+2,b,v);g(l,u+4,c,v)}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",ha(h,3));this.addAttribute("normal",ha(h.slice(),3));this.addAttribute("uv",ha(k,2));this.normalizeNormals();this.boundingSphere=new Ca(new q,
11874 c)}function Ob(a,b){ua.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 vc(a,b){Q.call(this);this.type="TetrahedronGeometry";this.parameters={radius:a,detail:b};this.fromBufferGeometry(new Ob(a,b));this.mergeVertices()}function Pb(a,b){ua.call(this,[1,0,0,-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=
11875 {radius:a,detail:b}}function wc(a,b){Q.call(this);this.type="OctahedronGeometry";this.parameters={radius:a,detail:b};this.fromBufferGeometry(new Pb(a,b));this.mergeVertices()}function Qb(a,b){var c=(1+Math.sqrt(5))/2;ua.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,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=
11876 {radius:a,detail:b}}function xc(a,b){Q.call(this);this.type="IcosahedronGeometry";this.parameters={radius:a,detail:b};this.fromBufferGeometry(new Qb(a,b));this.mergeVertices()}function Rb(a,b){var c=(1+Math.sqrt(5))/2,d=1/c;ua.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,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,
11877 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 yc(a,b){Q.call(this);this.type="DodecahedronGeometry";this.parameters={radius:a,detail:b};this.fromBufferGeometry(new Rb(a,b));this.mergeVertices()}function zc(a,b,c,d){Q.call(this);this.type="PolyhedronGeometry";this.parameters={vertices:a,indices:b,radius:c,detail:d};
11878 this.fromBufferGeometry(new ua(a,b,c,d));this.mergeVertices()}function Sb(a,b,c,d,e){function f(e){var f=a.getPointAt(e/b),m=g.normals[e];e=g.binormals[e];for(n=0;n<=d;n++){var w=n/d*Math.PI*2,l=Math.sin(w),w=-Math.cos(w);k.x=w*m.x+l*e.x;k.y=w*m.y+l*e.y;k.z=w*m.z+l*e.z;k.normalize();r.push(k.x,k.y,k.z);h.x=f.x+c*k.x;h.y=f.y+c*k.y;h.z=f.z+c*k.z;p.push(h.x,h.y,h.z)}}G.call(this);this.type="TubeBufferGeometry";this.parameters={path:a,tubularSegments:b,radius:c,radialSegments:d,closed:e};b=b||64;c=c||
11879 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 q,k=new q,m=new B,w,n,p=[],r=[],l=[],t=[];for(w=0;w<b;w++)f(w);f(!1===e?b:0);for(w=0;w<=b;w++)for(n=0;n<=d;n++)m.x=w/b,m.y=n/d,l.push(m.x,m.y);(function(){for(n=1;n<=b;n++)for(w=1;w<=d;w++){var a=(d+1)*n+(w-1),c=(d+1)*n+w,e=(d+1)*(n-1)+w;t.push((d+1)*(n-1)+(w-1),a,e);t.push(a,c,e)}})();this.setIndex((65535<t.length?$c:Zc)(t,1));this.addAttribute("position",ha(p,3));
11880 this.addAttribute("normal",ha(r,3));this.addAttribute("uv",ha(l,2))}function Ac(a,b,c,d,e,f){Q.call(this);this.type="TubeGeometry";this.parameters={path:a,tubularSegments:b,radius:c,radialSegments:d,closed:e};void 0!==f&&console.warn("THREE.TubeGeometry: taper has been removed.");a=new Sb(a,b,c,d,e);this.tangents=a.tangents;this.normals=a.normals;this.binormals=a.binormals;this.fromBufferGeometry(a);this.mergeVertices()}function Tb(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);
11881 e.x=d*(2+c)*.5*Math.cos(a);e.y=d*(2+c)*f*.5;e.z=d*Math.sin(b)*.5}G.call(this);this.type="TorusKnotBufferGeometry";this.parameters={radius:a,tube:b,tubularSegments:c,radialSegments:d,p:e,q:f};a=a||100;b=b||40;c=Math.floor(c)||64;d=Math.floor(d)||8;e=e||2;f=f||3;var h=(d+1)*(c+1),k=d*c*6,k=new C(new (65535<k?Uint32Array:Uint16Array)(k),1),m=new C(new Float32Array(3*h),3),w=new C(new Float32Array(3*h),3),h=new C(new Float32Array(2*h),2),n,p,r=0,l=0,t=new q,D=new q,u=new B,v=new q,I=new q,y=new q,E=new q,
11882 H=new q;for(n=0;n<=c;++n)for(p=n/c*e*Math.PI*2,g(p,e,f,a,v),g(p+.01,e,f,a,I),E.subVectors(I,v),H.addVectors(I,v),y.crossVectors(E,H),H.crossVectors(y,E),y.normalize(),H.normalize(),p=0;p<=d;++p){var F=p/d*Math.PI*2,M=-b*Math.cos(F),F=b*Math.sin(F);t.x=v.x+(M*H.x+F*y.x);t.y=v.y+(M*H.y+F*y.y);t.z=v.z+(M*H.z+F*y.z);m.setXYZ(r,t.x,t.y,t.z);D.subVectors(t,v).normalize();w.setXYZ(r,D.x,D.y,D.z);u.x=n/c;u.y=p/d;h.setXY(r,u.x,u.y);r++}for(p=1;p<=c;p++)for(n=1;n<=d;n++)a=(d+1)*p+(n-1),b=(d+1)*p+n,e=(d+1)*
11883 (p-1)+n,k.setX(l,(d+1)*(p-1)+(n-1)),l++,k.setX(l,a),l++,k.setX(l,e),l++,k.setX(l,a),l++,k.setX(l,b),l++,k.setX(l,e),l++;this.setIndex(k);this.addAttribute("position",m);this.addAttribute("normal",w);this.addAttribute("uv",h)}function Bc(a,b,c,d,e,f,g){Q.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 Tb(a,
11884 b,c,d,e,f));this.mergeVertices()}function Ub(a,b,c,d,e){G.call(this);this.type="TorusBufferGeometry";this.parameters={radius:a,tube:b,radialSegments:c,tubularSegments:d,arc:e};a=a||100;b=b||40;c=Math.floor(c)||8;d=Math.floor(d)||6;e=e||2*Math.PI;var f=(c+1)*(d+1),g=c*d*6,g=new (65535<g?Uint32Array:Uint16Array)(g),h=new Float32Array(3*f),k=new Float32Array(3*f),f=new Float32Array(2*f),m=0,w=0,n=0,p=new q,r=new q,l=new q,t,D;for(t=0;t<=c;t++)for(D=0;D<=d;D++){var u=D/d*e,v=t/c*Math.PI*2;r.x=(a+b*Math.cos(v))*
11885 Math.cos(u);r.y=(a+b*Math.cos(v))*Math.sin(u);r.z=b*Math.sin(v);h[m]=r.x;h[m+1]=r.y;h[m+2]=r.z;p.x=a*Math.cos(u);p.y=a*Math.sin(u);l.subVectors(r,p).normalize();k[m]=l.x;k[m+1]=l.y;k[m+2]=l.z;f[w]=D/d;f[w+1]=t/c;m+=3;w+=2}for(t=1;t<=c;t++)for(D=1;D<=d;D++)a=(d+1)*(t-1)+D-1,b=(d+1)*(t-1)+D,e=(d+1)*t+D,g[n]=(d+1)*t+D-1,g[n+1]=a,g[n+2]=e,g[n+3]=a,g[n+4]=b,g[n+5]=e,n+=6;this.setIndex(new C(g,1));this.addAttribute("position",new C(h,3));this.addAttribute("normal",new C(k,3));this.addAttribute("uv",new C(f,
11886 2))}function Cc(a,b,c,d,e){Q.call(this);this.type="TorusGeometry";this.parameters={radius:a,tube:b,radialSegments:c,tubularSegments:d,arc:e};this.fromBufferGeometry(new Ub(a,b,c,d,e))}function za(a,b){"undefined"!==typeof a&&(Q.call(this),this.type="ExtrudeGeometry",a=Array.isArray(a)?a:[a],this.addShapeList(a,b),this.computeFaceNormals())}function Dc(a,b){b=b||{};var c=b.font;if(!1===(c&&c.isFont))return console.error("THREE.TextGeometry: font parameter is not an instance of THREE.Font."),new Q;
11887 c=c.generateShapes(a,b.size,b.curveSegments);b.amount=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);za.call(this,c,b);this.type="TextGeometry"}function mb(a,b,c,d,e,f,g){G.call(this);this.type="SphereBufferGeometry";this.parameters={radius:a,widthSegments:b,heightSegments:c,phiStart:d,phiLength:e,thetaStart:f,thetaLength:g};a=a||50;b=Math.max(3,Math.floor(b)||8);c=Math.max(2,Math.floor(c)||
11888 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;for(var h=f+g,k=(b+1)*(c+1),m=new C(new Float32Array(3*k),3),w=new C(new Float32Array(3*k),3),k=new C(new Float32Array(2*k),2),n=0,p=[],l=new q,x=0;x<=c;x++){for(var t=[],D=x/c,u=0;u<=b;u++){var v=u/b,I=-a*Math.cos(d+v*e)*Math.sin(f+D*g),y=a*Math.cos(f+D*g),E=a*Math.sin(d+v*e)*Math.sin(f+D*g);l.set(I,y,E).normalize();m.setXYZ(n,I,y,E);w.setXYZ(n,l.x,l.y,l.z);k.setXY(n,v,1-D);t.push(n);n++}p.push(t)}d=[];for(x=0;x<
11889 c;x++)for(u=0;u<b;u++)e=p[x][u+1],g=p[x][u],n=p[x+1][u],l=p[x+1][u+1],(0!==x||0<f)&&d.push(e,g,l),(x!==c-1||h<Math.PI)&&d.push(g,n,l);this.setIndex(new (65535<m.count?$c:Zc)(d,1));this.addAttribute("position",m);this.addAttribute("normal",w);this.addAttribute("uv",k);this.boundingSphere=new Ca(new q,a)}function Vb(a,b,c,d,e,f,g){Q.call(this);this.type="SphereGeometry";this.parameters={radius:a,widthSegments:b,heightSegments:c,phiStart:d,phiLength:e,thetaStart:f,thetaLength:g};this.fromBufferGeometry(new mb(a,
11890 b,c,d,e,f,g))}function Wb(a,b,c,d,e,f){G.call(this);this.type="RingBufferGeometry";this.parameters={innerRadius:a,outerRadius:b,thetaSegments:c,phiSegments:d,thetaStart:e,thetaLength:f};a=a||20;b=b||50;e=void 0!==e?e:0;f=void 0!==f?f:2*Math.PI;c=void 0!==c?Math.max(3,c):8;d=void 0!==d?Math.max(1,d):1;var g=(c+1)*(d+1),h=c*d*6,h=new C(new (65535<h?Uint32Array:Uint16Array)(h),1),k=new C(new Float32Array(3*g),3),m=new C(new Float32Array(3*g),3),g=new C(new Float32Array(2*g),2),w=0,n=0,p,l=a,x=(b-a)/
11891 d,t=new q,D=new B,u;for(a=0;a<=d;a++){for(u=0;u<=c;u++)p=e+u/c*f,t.x=l*Math.cos(p),t.y=l*Math.sin(p),k.setXYZ(w,t.x,t.y,t.z),m.setXYZ(w,0,0,1),D.x=(t.x/b+1)/2,D.y=(t.y/b+1)/2,g.setXY(w,D.x,D.y),w++;l+=x}for(a=0;a<d;a++)for(b=a*(c+1),u=0;u<c;u++)e=p=u+b,f=p+c+1,w=p+c+2,p+=1,h.setX(n,e),n++,h.setX(n,f),n++,h.setX(n,w),n++,h.setX(n,e),n++,h.setX(n,w),n++,h.setX(n,p),n++;this.setIndex(h);this.addAttribute("position",k);this.addAttribute("normal",m);this.addAttribute("uv",g)}function Ec(a,b,c,d,e,f){Q.call(this);
11892 this.type="RingGeometry";this.parameters={innerRadius:a,outerRadius:b,thetaSegments:c,phiSegments:d,thetaStart:e,thetaLength:f};this.fromBufferGeometry(new Wb(a,b,c,d,e,f))}function Fc(a,b,c,d){Q.call(this);this.type="PlaneGeometry";this.parameters={width:a,height:b,widthSegments:c,heightSegments:d};this.fromBufferGeometry(new ib(a,b,c,d))}function Xb(a,b,c,d){G.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||
11893 2*Math.PI;d=T.clamp(d,0,2*Math.PI);for(var e=(b+1)*a.length,f=b*a.length*6,g=new C(new (65535<f?Uint32Array:Uint16Array)(f),1),h=new C(new Float32Array(3*e),3),k=new C(new Float32Array(2*e),2),m=0,w=0,n=1/b,p=new q,l=new B,e=0;e<=b;e++)for(var f=c+e*n*d,x=Math.sin(f),t=Math.cos(f),f=0;f<=a.length-1;f++)p.x=a[f].x*x,p.y=a[f].y,p.z=a[f].x*t,h.setXYZ(m,p.x,p.y,p.z),l.x=e/b,l.y=f/(a.length-1),k.setXY(m,l.x,l.y),m++;for(e=0;e<b;e++)for(f=0;f<a.length-1;f++)c=f+e*a.length,m=c+a.length,n=c+a.length+1,p=
11894 c+1,g.setX(w,c),w++,g.setX(w,m),w++,g.setX(w,p),w++,g.setX(w,m),w++,g.setX(w,n),w++,g.setX(w,p),w++;this.setIndex(g);this.addAttribute("position",h);this.addAttribute("uv",k);this.computeVertexNormals();if(d===2*Math.PI)for(d=this.attributes.normal.array,g=new q,h=new q,k=new q,c=b*a.length*3,f=e=0;e<a.length;e++,f+=3)g.x=d[f+0],g.y=d[f+1],g.z=d[f+2],h.x=d[c+f+0],h.y=d[c+f+1],h.z=d[c+f+2],k.addVectors(g,h).normalize(),d[f+0]=d[c+f+0]=k.x,d[f+1]=d[c+f+1]=k.y,d[f+2]=d[c+f+2]=k.z}function Gc(a,b,c,d){Q.call(this);
11895 this.type="LatheGeometry";this.parameters={points:a,segments:b,phiStart:c,phiLength:d};this.fromBufferGeometry(new Xb(a,b,c,d));this.mergeVertices()}function cb(a,b){Q.call(this);this.type="ShapeGeometry";!1===Array.isArray(a)&&(a=[a]);this.addShapeList(a,b);this.computeFaceNormals()}function Yb(a,b){function c(a,b){return a-b}G.call(this);var d=Math.cos(T.DEG2RAD*(void 0!==b?b:1)),e=[0,0],f={},g=["a","b","c"],h;a&&a.isBufferGeometry?(h=new Q,h.fromBufferGeometry(a)):h=a.clone();h.mergeVertices();
11896 h.computeFaceNormals();var k=h.vertices;h=h.faces;for(var m=0,w=h.length;m<w;m++)for(var n=h[m],p=0;3>p;p++){e[0]=n[g[p]];e[1]=n[g[(p+1)%3]];e.sort(c);var l=e.toString();void 0===f[l]?f[l]={vert1:e[0],vert2:e[1],face1:m,face2:void 0}:f[l].face2=m}e=[];for(l in f)if(g=f[l],void 0===g.face2||h[g.face1].normal.dot(h[g.face2].normal)<=d)m=k[g.vert1],e.push(m.x),e.push(m.y),e.push(m.z),m=k[g.vert2],e.push(m.x),e.push(m.y),e.push(m.z);this.addAttribute("position",new C(new Float32Array(e),3))}function Ua(a,
11897 b,c,d,e,f,g,h){function k(c){var e,f,k,n=new B,p=new q,l=0,w=!0===c?a:b,I=!0===c?1:-1;f=u;for(e=1;e<=d;e++)x.setXYZ(u,0,y*I,0),t.setXYZ(u,0,I,0),n.x=.5,n.y=.5,D.setXY(u,n.x,n.y),u++;k=u;for(e=0;e<=d;e++){var z=e/d*h+g,C=Math.cos(z),z=Math.sin(z);p.x=w*z;p.y=y*I;p.z=w*C;x.setXYZ(u,p.x,p.y,p.z);t.setXYZ(u,0,I,0);n.x=.5*C+.5;n.y=.5*z*I+.5;D.setXY(u,n.x,n.y);u++}for(e=0;e<d;e++)n=f+e,p=k+e,!0===c?(r.setX(v,p),v++,r.setX(v,p+1)):(r.setX(v,p+1),v++,r.setX(v,p)),v++,r.setX(v,n),v++,l+=3;m.addGroup(E,l,!0===
11898 c?1:2);E+=l}G.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:20;b=void 0!==b?b:20;c=void 0!==c?c:100;d=Math.floor(d)||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 l=0;!1===f&&(0<a&&l++,0<b&&l++);var n=function(){var a=(d+1)*(e+1);!1===f&&(a+=(d+1)*l+d*l);return a}(),p=function(){var a=d*e*6;!1===f&&(a+=d*l*3);
11899 return a}(),r=new C(new (65535<p?Uint32Array:Uint16Array)(p),1),x=new C(new Float32Array(3*n),3),t=new C(new Float32Array(3*n),3),D=new C(new Float32Array(2*n),2),u=0,v=0,I=[],y=c/2,E=0;(function(){var f,k,n=new q,p=new q,l=0,w=(b-a)/c;for(k=0;k<=e;k++){var B=[],z=k/e,C=z*(b-a)+a;for(f=0;f<=d;f++){var N=f/d,P=N*h+g,R=Math.sin(P),P=Math.cos(P);p.x=C*R;p.y=-z*c+y;p.z=C*P;x.setXYZ(u,p.x,p.y,p.z);n.set(R,w,P).normalize();t.setXYZ(u,n.x,n.y,n.z);D.setXY(u,N,1-z);B.push(u);u++}I.push(B)}for(f=0;f<d;f++)for(k=
11900 0;k<e;k++)n=I[k+1][f],p=I[k+1][f+1],w=I[k][f+1],r.setX(v,I[k][f]),v++,r.setX(v,n),v++,r.setX(v,w),v++,r.setX(v,n),v++,r.setX(v,p),v++,r.setX(v,w),v++,l+=6;m.addGroup(E,l,0);E+=l})();!1===f&&(0<a&&k(!0),0<b&&k(!1));this.setIndex(r);this.addAttribute("position",x);this.addAttribute("normal",t);this.addAttribute("uv",D)}function nb(a,b,c,d,e,f,g,h){Q.call(this);this.type="CylinderGeometry";this.parameters={radiusTop:a,radiusBottom:b,height:c,radialSegments:d,heightSegments:e,openEnded:f,thetaStart:g,
11901 thetaLength:h};this.fromBufferGeometry(new Ua(a,b,c,d,e,f,g,h));this.mergeVertices()}function Hc(a,b,c,d,e,f,g){nb.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 Ic(a,b,c,d,e,f,g){Ua.call(this,0,a,b,c,d,e,f,g);this.type="ConeBufferGeometry";this.parameters={radius:a,height:b,radialSegments:c,heightSegments:d,openEnded:e,thetaStart:f,thetaLength:g}}function Zb(a,b,c,d){G.call(this);
11902 this.type="CircleBufferGeometry";this.parameters={radius:a,segments:b,thetaStart:c,thetaLength:d};a=a||50;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=b+2,f=new Float32Array(3*e),g=new Float32Array(3*e),e=new Float32Array(2*e);g[2]=1;e[0]=.5;e[1]=.5;for(var h=0,k=3,m=2;h<=b;h++,k+=3,m+=2){var l=c+h/b*d;f[k]=a*Math.cos(l);f[k+1]=a*Math.sin(l);g[k+2]=1;e[m]=(f[k]/a+1)/2;e[m+1]=(f[k+1]/a+1)/2}c=[];for(k=1;k<=b;k++)c.push(k,k+1,0);this.setIndex(new C(new Uint16Array(c),
11903 1));this.addAttribute("position",new C(f,3));this.addAttribute("normal",new C(g,3));this.addAttribute("uv",new C(e,2));this.boundingSphere=new Ca(new q,a)}function Jc(a,b,c,d){Q.call(this);this.type="CircleGeometry";this.parameters={radius:a,segments:b,thetaStart:c,thetaLength:d};this.fromBufferGeometry(new Zb(a,b,c,d))}function ob(a,b,c,d,e,f){Q.call(this);this.type="BoxGeometry";this.parameters={width:a,height:b,depth:c,widthSegments:d,heightSegments:e,depthSegments:f};this.fromBufferGeometry(new hb(a,
11904 b,c,d,e,f));this.mergeVertices()}function $b(){Fa.call(this,{uniforms:La.merge([W.lights,{opacity:{value:1}}]),vertexShader:X.shadow_vert,fragmentShader:X.shadow_frag});this.transparent=this.lights=!0;Object.defineProperties(this,{opacity:{enumerable:!0,get:function(){return this.uniforms.opacity.value},set:function(a){this.uniforms.opacity.value=a}}})}function ac(a){Fa.call(this,a);this.type="RawShaderMaterial"}function Kc(a){this.uuid=T.generateUUID();this.type="MultiMaterial";this.materials=a instanceof
11905 Array?a:[];this.visible=!0}function Oa(a){U.call(this);this.defines={STANDARD:""};this.type="MeshStandardMaterial";this.color=new O(16777215);this.metalness=this.roughness=.5;this.lightMap=this.map=null;this.lightMapIntensity=1;this.aoMap=null;this.aoMapIntensity=1;this.emissive=new O(0);this.emissiveIntensity=1;this.bumpMap=this.emissiveMap=null;this.bumpScale=1;this.normalMap=null;this.normalScale=new B(1,1);this.displacementMap=null;this.displacementScale=1;this.displacementBias=0;this.envMap=
11906 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 pb(a){Oa.call(this);this.defines={PHYSICAL:""};this.type="MeshPhysicalMaterial";this.reflectivity=.5;this.clearCoatRoughness=this.clearCoat=0;this.setValues(a)}function db(a){U.call(this);this.type="MeshPhongMaterial";this.color=
11907 new O(16777215);this.specular=new O(1118481);this.shininess=30;this.lightMap=this.map=null;this.lightMapIntensity=1;this.aoMap=null;this.aoMapIntensity=1;this.emissive=new O(0);this.emissiveIntensity=1;this.bumpMap=this.emissiveMap=null;this.bumpScale=1;this.normalMap=null;this.normalScale=new B(1,1);this.displacementMap=null;this.displacementScale=1;this.displacementBias=0;this.envMap=this.alphaMap=this.specularMap=null;this.combine=0;this.reflectivity=1;this.refractionRatio=.98;this.wireframe=!1;
11908 this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.morphNormals=this.morphTargets=this.skinning=!1;this.setValues(a)}function qb(a){U.call(this,a);this.type="MeshNormalMaterial";this.wireframe=!1;this.wireframeLinewidth=1;this.morphTargets=this.lights=this.fog=!1;this.setValues(a)}function rb(a){U.call(this);this.type="MeshLambertMaterial";this.color=new O(16777215);this.lightMap=this.map=null;this.lightMapIntensity=1;this.aoMap=null;this.aoMapIntensity=1;this.emissive=
11909 new O(0);this.emissiveIntensity=1;this.envMap=this.alphaMap=this.specularMap=this.emissiveMap=null;this.combine=0;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 sb(a){U.call(this);this.type="LineDashedMaterial";this.color=new O(16777215);this.scale=this.linewidth=1;this.dashSize=3;this.gapSize=1;this.lights=!1;this.setValues(a)}
11910 function Fd(a,b,c){var d=this,e=!1,f=0,g=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,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)}}function Ja(a){this.manager=void 0!==a?a:Ga}function we(a){this.manager=void 0!==a?a:Ga;this._parser=null}function Gd(a){this.manager=
11911 void 0!==a?a:Ga;this._parser=null}function Lc(a){this.manager=void 0!==a?a:Ga}function Hd(a){this.manager=void 0!==a?a:Ga}function gd(a){this.manager=void 0!==a?a:Ga}function pa(a,b){z.call(this);this.type="Light";this.color=new O(a);this.intensity=void 0!==b?b:1;this.receiveShadow=void 0}function hd(a,b,c){pa.call(this,a,c);this.type="HemisphereLight";this.castShadow=void 0;this.position.copy(z.DefaultUp);this.updateMatrix();this.groundColor=new O(b)}function tb(a){this.camera=a;this.bias=0;this.radius=
11912 1;this.mapSize=new B(512,512);this.map=null;this.matrix=new J}function id(){tb.call(this,new Ea(50,1,.5,500))}function jd(a,b,c,d,e,f){pa.call(this,a,b);this.type="SpotLight";this.position.copy(z.DefaultUp);this.updateMatrix();this.target=new z;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=
11913 new id}function kd(a,b,c,d){pa.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 tb(new Ea(90,1,.5,500))}function ld(a){tb.call(this,new Hb(-5,5,5,-5,.5,500))}function md(a,b){pa.call(this,a,b);this.type="DirectionalLight";this.position.copy(z.DefaultUp);this.updateMatrix();this.target=new z;this.shadow=new ld}
11914 function nd(a,b){pa.call(this,a,b);this.type="AmbientLight";this.castShadow=void 0}function qa(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 od(a,b,c,d){qa.call(this,a,b,c,d);this._offsetNext=this._weightNext=this._offsetPrev=this._weightPrev=-0}function Mc(a,b,c,d){qa.call(this,a,b,c,d)}function pd(a,b,c,d){qa.call(this,a,b,c,d)}function ub(a,b,c,d){if(void 0===a)throw Error("track name is undefined");
11915 if(void 0===b||0===b.length)throw Error("no keyframes in track named "+a);this.name=a;this.times=ma.convertArray(b,this.TimeBufferType);this.values=ma.convertArray(c,this.ValueBufferType);this.setInterpolation(d||this.DefaultInterpolation);this.validate();this.optimize()}function bc(a,b,c,d){ub.call(this,a,b,c,d)}function qd(a,b,c,d){qa.call(this,a,b,c,d)}function Nc(a,b,c,d){ub.call(this,a,b,c,d)}function cc(a,b,c,d){ub.call(this,a,b,c,d)}function rd(a,b,c,d){ub.call(this,a,b,c,d)}function sd(a,
11916 b,c){ub.call(this,a,b,c)}function td(a,b,c,d){ub.call(this,a,b,c,d)}function vb(a,b,c,d){ub.apply(this,arguments)}function Ha(a,b,c){this.name=a;this.tracks=c;this.duration=void 0!==b?b:-1;this.uuid=T.generateUUID();0>this.duration&&this.resetDuration();this.optimize()}function ud(a){this.manager=void 0!==a?a:Ga;this.textures={}}function Id(a){this.manager=void 0!==a?a:Ga}function wb(){this.onLoadStart=function(){};this.onLoadProgress=function(){};this.onLoadComplete=function(){}}function Jd(a){"boolean"===
11917 typeof a&&(console.warn("THREE.JSONLoader: showStatus parameter has been removed from constructor."),a=void 0);this.manager=void 0!==a?a:Ga;this.withCredentials=!1}function xe(a){this.manager=void 0!==a?a:Ga;this.texturePath=""}function ia(){}function Sa(a,b){this.v1=a;this.v2=b}function Oc(){this.curves=[];this.autoClose=!1}function Va(a,b,c,d,e,f,g,h){this.aX=a;this.aY=b;this.xRadius=c;this.yRadius=d;this.aStartAngle=e;this.aEndAngle=f;this.aClockwise=g;this.aRotation=h||0}function xb(a){this.points=
11918 void 0===a?[]:a}function yb(a,b,c,d){this.v0=a;this.v1=b;this.v2=c;this.v3=d}function zb(a,b,c){this.v0=a;this.v1=b;this.v2=c}function Ab(){Pc.apply(this,arguments);this.holes=[]}function Pc(a){Oc.call(this);this.currentPoint=new B;a&&this.fromPoints(a)}function Kd(){this.subPaths=[];this.currentPath=null}function Ld(a){this.data=a}function ye(a){this.manager=void 0!==a?a:Ga}function Md(){void 0===Nd&&(Nd=new (window.AudioContext||window.webkitAudioContext));return Nd}function Od(a){this.manager=
11919 void 0!==a?a:Ga}function ze(){this.type="StereoCamera";this.aspect=1;this.eyeSep=.064;this.cameraL=new Ea;this.cameraL.layers.enable(1);this.cameraL.matrixAutoUpdate=!1;this.cameraR=new Ea;this.cameraR.layers.enable(2);this.cameraR.matrixAutoUpdate=!1}function vd(a,b,c){z.call(this);this.type="CubeCamera";var d=new Ea(90,1,a,b);d.up.set(0,-1,0);d.lookAt(new q(1,0,0));this.add(d);var e=new Ea(90,1,a,b);e.up.set(0,-1,0);e.lookAt(new q(-1,0,0));this.add(e);var f=new Ea(90,1,a,b);f.up.set(0,0,1);f.lookAt(new q(0,
11920 1,0));this.add(f);var g=new Ea(90,1,a,b);g.up.set(0,0,-1);g.lookAt(new q(0,-1,0));this.add(g);var h=new Ea(90,1,a,b);h.up.set(0,-1,0);h.lookAt(new q(0,0,1));this.add(h);var k=new Ea(90,1,a,b);k.up.set(0,-1,0);k.lookAt(new q(0,0,-1));this.add(k);this.renderTarget=new Eb(c,c,{format:1022,magFilter:1006,minFilter:1006});this.updateCubeMap=function(a,b){null===this.parent&&this.updateMatrixWorld();var c=this.renderTarget,p=c.texture.generateMipmaps;c.texture.generateMipmaps=!1;c.activeCubeFace=0;a.render(b,
11921 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=p;c.activeCubeFace=5;a.render(b,k,c);a.setRenderTarget(null)}}function Pd(){z.call(this);this.type="AudioListener";this.context=Md();this.gain=this.context.createGain();this.gain.connect(this.context.destination);this.filter=null}function dc(a){z.call(this);this.type="Audio";this.context=a.context;this.source=this.context.createBufferSource();
11922 this.source.onended=this.onEnded.bind(this);this.gain=this.context.createGain();this.gain.connect(a.getInput());this.autoplay=!1;this.startTime=0;this.playbackRate=1;this.isPlaying=!1;this.hasPlaybackControl=!0;this.sourceType="empty";this.filters=[]}function Qd(a){dc.call(this,a);this.panner=this.context.createPanner();this.panner.connect(this.gain)}function Rd(a,b){this.analyser=a.context.createAnalyser();this.analyser.fftSize=void 0!==b?b:2048;this.data=new Uint8Array(this.analyser.frequencyBinCount);
11923 a.getOutput().connect(this.analyser)}function wd(a,b,c){this.binding=a;this.valueSize=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 fa(a,b,c){this.path=b;this.parsedPath=c||fa.parseTrackName(b);this.node=fa.findNode(a,this.parsedPath.nodeName)||a;this.rootNode=a}function Sd(a){this.uuid=T.generateUUID();
11924 this._objects=Array.prototype.slice.call(arguments);this.nCachedObjects_=0;var b={};this._indicesByUUID=b;for(var c=0,d=arguments.length;c!==d;++c)b[arguments[c].uuid]=c;this._paths=[];this._parsedPaths=[];this._bindings=[];this._bindingsIndicesByPath={};var e=this;this.stats={objects:{get total(){return e._objects.length},get inUse(){return this.total-e.nCachedObjects_}},get bindingsPerObject(){return e._bindings.length}}}function Td(a,b,c){this._mixer=a;this._clip=b;this._localRoot=c||null;a=b.tracks;
11925 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;this.paused=!1;this.enabled=
11926 !0;this.clampWhenFinished=!1;this.zeroSlopeAtEnd=this.zeroSlopeAtStart=!0}function Ud(a){this._root=a;this._initMemoryManager();this.time=this._accuIndex=0;this.timeScale=1}function Ae(a,b){"string"===typeof a&&(console.warn("THREE.Uniform: Type parameter is no longer needed."),a=b);this.value=a}function Bb(){G.call(this);this.type="InstancedBufferGeometry";this.maxInstancedCount=void 0}function Vd(a,b,c,d){this.uuid=T.generateUUID();this.data=a;this.itemSize=b;this.offset=c;this.normalized=!0===
11927 d}function ec(a,b){this.uuid=T.generateUUID();this.array=a;this.stride=b;this.count=void 0!==a?a.length/b:0;this.dynamic=!1;this.updateRange={offset:0,count:-1};this.version=0}function fc(a,b,c){ec.call(this,a,b);this.meshPerAttribute=c||1}function gc(a,b,c){C.call(this,a,b);this.meshPerAttribute=c||1}function Wd(a,b,c,d){this.ray=new ab(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.");
11928 return this.Points}}})}function Be(a,b){return a.distance-b.distance}function Xd(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++)Xd(a[d],b,c,!0)}}function Yd(a){this.autoStart=void 0!==a?a:!0;this.elapsedTime=this.oldTime=this.startTime=0;this.running=!1}function Zd(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 na(a,b){ya.call(this,a,b);this.animationsMap={};this.animationsList=[];var c=this.geometry.morphTargets.length;
11929 this.createAnimation("__default",0,c-1,c/1);this.setAnimationWeight("__default",1)}function Qc(a){z.call(this);this.material=a;this.render=function(a){}}function Rc(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 G;b=new ha(6*b,3);c.addAttribute("position",b);la.call(this,c,new oa({color:a,linewidth:d}));this.matrixAutoUpdate=!1;this.update()}
11930 function hc(a){z.call(this);this.light=a;this.light.updateMatrixWorld();this.matrix=a.matrixWorld;this.matrixAutoUpdate=!1;a=new G;for(var 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],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 ha(b,3));b=new oa({fog:!1});this.cone=new la(a,b);this.add(this.cone);this.update()}function ic(a){this.bones=this.getBoneList(a);for(var b=new Q,
11931 c=0;c<this.bones.length;c++){var d=this.bones[c];d.parent&&d.parent.isBone&&(b.vertices.push(new q),b.vertices.push(new q),b.colors.push(new O(0,0,1)),b.colors.push(new O(0,1,0)))}b.dynamic=!0;c=new oa({vertexColors:2,depthTest:!1,depthWrite:!1,transparent:!0});la.call(this,b,c);this.root=a;this.matrix=a.matrixWorld;this.matrixAutoUpdate=!1;this.update()}function jc(a,b){this.light=a;this.light.updateMatrixWorld();var c=new mb(b,4,2),d=new Ma({wireframe:!0,fog:!1});d.color.copy(this.light.color).multiplyScalar(this.light.intensity);
11932 ya.call(this,c,d);this.matrix=this.light.matrixWorld;this.matrixAutoUpdate=!1}function kc(a,b){z.call(this);this.light=a;this.light.updateMatrixWorld();this.matrix=a.matrixWorld;this.matrixAutoUpdate=!1;this.colors=[new O,new O];var c=new Vb(b,4,2);c.rotateX(-Math.PI/2);for(var d=0;8>d;d++)c.faces[d].color=this.colors[4>d?0:1];d=new Ma({vertexColors:1,wireframe:!0});this.lightSphere=new ya(c,d);this.add(this.lightSphere);this.update()}function Sc(a,b,c,d){b=b||1;c=new O(void 0!==c?c:4473924);d=new O(void 0!==
11933 d?d:8947848);for(var e=b/2,f=2*a/b,g=[],h=[],k=0,m=0,l=-a;k<=b;k++,l+=f){g.push(-a,0,l,a,0,l);g.push(l,0,-a,l,0,a);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}a=new G;a.addAttribute("position",new ha(g,3));a.addAttribute("color",new ha(h,3));g=new oa({vertexColors:2});la.call(this,a,g)}function Tc(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)&&c.isGeometry?b=c.faces.length:console.warn("THREE.FaceNormalsHelper: only THREE.Geometry is supported. Use THREE.VertexNormalsHelper, instead.");
11934 c=new G;b=new ha(6*b,3);c.addAttribute("position",b);la.call(this,c,new oa({color:a,linewidth:d}));this.matrixAutoUpdate=!1;this.update()}function lc(a,b){z.call(this);this.light=a;this.light.updateMatrixWorld();this.matrix=a.matrixWorld;this.matrixAutoUpdate=!1;void 0===b&&(b=1);var c=new G;c.addAttribute("position",new ha([-b,b,0,b,b,0,b,-b,0,-b,-b,0,-b,b,0],3));var d=new oa({fog:!1});this.add(new Ta(c,d));c=new G;c.addAttribute("position",new ha([0,0,0,0,0,1],3));this.add(new Ta(c,d));this.update()}
11935 function Uc(a){function b(a,b,d){c(a,d);c(b,d)}function c(a,b){d.vertices.push(new q);d.colors.push(new O(b));void 0===f[a]&&(f[a]=[]);f[a].push(d.vertices.length-1)}var d=new Q,e=new oa({color:16777215,vertexColors:1}),f={};b("n1","n2",16755200);b("n2","n4",16755200);b("n4","n3",16755200);b("n3","n1",16755200);b("f1","f2",16755200);b("f2","f4",16755200);b("f4","f3",16755200);b("f3","f1",16755200);b("n1","f1",16755200);b("n2","f2",16755200);b("n3","f3",16755200);b("n4","f4",16755200);b("p","n1",16711680);
11936 b("p","n2",16711680);b("p","n3",16711680);b("p","n4",16711680);b("u1","u2",43775);b("u2","u3",43775);b("u3","u1",43775);b("c","t",16777215);b("p","c",3355443);b("cn1","cn2",3355443);b("cn3","cn4",3355443);b("cf1","cf2",3355443);b("cf3","cf4",3355443);la.call(this,d,e);this.camera=a;this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix();this.matrix=a.matrixWorld;this.matrixAutoUpdate=!1;this.pointMap=f;this.update()}function Vc(a,b){var c=void 0!==b?b:8947848;this.object=a;this.box=
11937 new Ba;ya.call(this,new ob(1,1,1),new Ma({color:c,wireframe:!0}))}function Wc(a,b){void 0===b&&(b=16776960);var c=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]),d=new Float32Array(24),e=new G;e.setIndex(new C(c,1));e.addAttribute("position",new C(d,3));la.call(this,e,new oa({color:b}));void 0!==a&&this.update(a)}function Cb(a,b,c,d,e,f){z.call(this);void 0===d&&(d=16776960);void 0===c&&(c=1);void 0===e&&(e=.2*c);void 0===f&&(f=.2*e);this.position.copy(b);this.line=new Ta(Ce,new oa({color:d}));
11938 this.line.matrixAutoUpdate=!1;this.add(this.line);this.cone=new ya(De,new Ma({color:d}));this.cone.matrixAutoUpdate=!1;this.add(this.cone);this.setDirection(a);this.setLength(c,e,f)}function xd(a){a=a||1;var b=new Float32Array([0,0,0,a,0,0,0,0,0,0,a,0,0,0,0,0,0,a]),c=new Float32Array([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1]);a=new G;a.addAttribute("position",new C(b,3));a.addAttribute("color",new C(c,3));b=new oa({vertexColors:2});la.call(this,a,b)}function Ee(a){console.warn("THREE.ClosedSplineCurve3 has been deprecated. Please use THREE.CatmullRomCurve3.");
11939 $d.call(this,a);this.type="catmullrom";this.closed=!0}function yd(a,b,c,d,e,f){Va.call(this,a,b,c,c,d,e,f)}void 0===Number.EPSILON&&(Number.EPSILON=Math.pow(2,-52));void 0===Math.sign&&(Math.sign=function(a){return 0>a?-1:0<a?1:+a});void 0===Function.prototype.name&&Object.defineProperty(Function.prototype,"name",{get:function(){return this.toString().match(/^\s*function\s*(\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");
11940 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,e)&&(b[e]=d[e])}return b}}();Object.assign(sa.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)?!0:!1},
11941 removeEventListener:function(a,b){if(void 0!==this._listeners){var c=this._listeners[a];if(void 0!==c){var d=c.indexOf(b);-1!==d&&c.splice(d,1)}}},dispatchEvent:function(a){if(void 0!==this._listeners){var b=this._listeners[a.type];if(void 0!==b){a.target=this;var c=[],d,e=b.length;for(d=0;d<e;d++)c[d]=b[d];for(d=0;d<e;d++)c[d].call(this,a)}}}});var Fe={NoBlending:0,NormalBlending:1,AdditiveBlending:2,SubtractiveBlending:3,MultiplyBlending:4,CustomBlending:5},Ge={UVMapping:300,CubeReflectionMapping:301,
11942 CubeRefractionMapping:302,EquirectangularReflectionMapping:303,EquirectangularRefractionMapping:304,SphericalReflectionMapping:305,CubeUVReflectionMapping:306,CubeUVRefractionMapping:307},ae={RepeatWrapping:1E3,ClampToEdgeWrapping:1001,MirroredRepeatWrapping:1002},be={NearestFilter:1003,NearestMipMapNearestFilter:1004,NearestMipMapLinearFilter:1005,LinearFilter:1006,LinearMipMapNearestFilter:1007,LinearMipMapLinearFilter:1008},T={DEG2RAD:Math.PI/180,RAD2DEG:180/Math.PI,generateUUID:function(){var a=
11943 "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),b=Array(36),c=0,d;return function(){for(var e=0;36>e;e++)8===e||13===e||18===e||23===e?b[e]="-":14===e?b[e]="4":(2>=c&&(c=33554432+16777216*Math.random()|0),d=c&15,c>>=4,b[e]=a[19===e?d&3|8:d]);return b.join("")}}(),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,
11944 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;a=(a-b)/(c-b);return a*a*a*(a*(6*a-15)+10)},random16:function(){console.warn("THREE.Math.random16() has been deprecated. Use Math.random() instead.");return Math.random()},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*
11945 T.DEG2RAD},radToDeg:function(a){return a*T.RAD2DEG},isPowerOfTwo:function(a){return 0===(a&a-1)&&0!==a},nearestPowerOfTwo:function(a){return Math.pow(2,Math.round(Math.log(a)/Math.LN2))},nextPowerOfTwo:function(a){a--;a|=a>>1;a|=a>>2;a|=a>>4;a|=a>>8;a|=a>>16;a++;return a}};B.prototype={constructor:B,isVector2:!0,get width(){return this.x},set width(a){this.x=a},get height(){return this.y},set height(a){this.y=a},set:function(a,b){this.x=a;this.y=b;return this},setScalar:function(a){this.y=this.x=
11946 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: "+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!==
11947 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},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."),
11948 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*=a.y;return this},multiplyScalar:function(a){isFinite(a)?(this.x*=a,this.y*=a):this.y=this.x=0;return this},divide:function(a){this.x/=a.x;this.y/=a.y;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,
11949 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,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,b;return function(c,d){void 0===a&&(a=new B,b=new B);a.set(c,c);b.set(d,d);return this.clamp(a,b)}}(),clampLength:function(a,b){var c=this.length();return this.multiplyScalar(Math.max(a,Math.min(b,c))/c)},floor:function(){this.x=Math.floor(this.x);this.y=
11950 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=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},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.x*
11951 this.x+this.y*this.y)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)},normalize:function(){return this.divideScalar(this.length())},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},distanceToManhattan:function(a){return Math.abs(this.x-a.x)+Math.abs(this.y-a.y)},setLength:function(a){return this.multiplyScalar(a/
11952 this.length())},lerp:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(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},fromAttribute:function(a,b,c){void 0===c&&(c=0);b=b*a.itemSize+c;this.x=a.array[b];this.y=a.array[b+
11953 1];return this},rotateAround:function(a,b){var c=Math.cos(b),d=Math.sin(b),e=this.x-a.x,f=this.y-a.y;this.x=e*c-f*d+a.x;this.y=e*d+f*c+a.y;return this}};da.DEFAULT_IMAGE=void 0;da.DEFAULT_MAPPING=300;da.prototype={constructor:da,isTexture:!0,set needsUpdate(a){!0===a&&this.version++},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.image=a.image;this.mipmaps=a.mipmaps.slice(0);this.mapping=a.mapping;this.wrapS=a.wrapS;this.wrapT=a.wrapT;this.magFilter=a.magFilter;this.minFilter=
11954 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.generateMipmaps=a.generateMipmaps;this.premultiplyAlpha=a.premultiplyAlpha;this.flipY=a.flipY;this.unpackAlignment=a.unpackAlignment;this.encoding=a.encoding;return this},toJSON:function(a){if(void 0!==a.textures[this.uuid])return a.textures[this.uuid];var b={metadata:{version:4.4,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,mapping:this.mapping,
11955 repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],wrap:[this.wrapS,this.wrapT],minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY};if(void 0!==this.image){var c=this.image;void 0===c.uuid&&(c.uuid=T.generateUUID());if(void 0===a.images[c.uuid]){var d=a.images,e=c.uuid,f=c.uuid,g;void 0!==c.toDataURL?g=c:(g=document.createElementNS("http://www.w3.org/1999/xhtml","canvas"),g.width=c.width,g.height=c.height,g.getContext("2d").drawImage(c,
11956 0,0,c.width,c.height));g=2048<g.width||2048<g.height?g.toDataURL("image/jpeg",.6):g.toDataURL("image/png");d[e]={uuid:f,url:g}}b.image=c.uuid}return a.textures[this.uuid]=b},dispose:function(){this.dispatchEvent({type:"dispose"})},transformUv:function(a){if(300===this.mapping){a.multiply(this.repeat);a.add(this.offset);if(0>a.x||1<a.x)switch(this.wrapS){case 1E3:a.x-=Math.floor(a.x);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>
11957 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.assign(da.prototype,sa.prototype);var ee=0;ga.prototype={constructor:ga,isVector4:!0,set:function(a,b,c,d){this.x=a;this.y=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;
11958 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;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,
11959 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+=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},
11960 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-=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){isFinite(a)?
11961 (this.x*=a,this.y*=a,this.z*=a,this.w*=a):this.w=this.z=this.y=this.x=0;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/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=
11962 0):(this.x=a.x/b,this.y=a.y/b,this.z=a.z/b);return this},setAxisAngleFromRotationMatrix:function(a){var b,c,d;a=a.elements;var e=a[0];d=a[4];var f=a[8],g=a[1],h=a[5],k=a[9];c=a[2];b=a[6];var m=a[10];if(.01>Math.abs(d-g)&&.01>Math.abs(f-c)&&.01>Math.abs(k-b)){if(.1>Math.abs(d+g)&&.1>Math.abs(f+c)&&.1>Math.abs(k+b)&&.1>Math.abs(e+h+m-3))return this.set(1,0,0,0),this;a=Math.PI;e=(e+1)/2;h=(h+1)/2;m=(m+1)/2;d=(d+g)/4;f=(f+c)/4;k=(k+b)/4;e>h&&e>m?.01>e?(b=0,d=c=.707106781):(b=Math.sqrt(e),c=d/b,d=f/b):
11963 h>m?.01>h?(b=.707106781,c=0,d=.707106781):(c=Math.sqrt(h),b=d/c,d=k/c):.01>m?(c=b=.707106781,d=0):(d=Math.sqrt(m),b=f/d,c=k/d);this.set(b,c,d,a);return this}a=Math.sqrt((b-k)*(b-k)+(f-c)*(f-c)+(g-d)*(g-d));.001>Math.abs(a)&&(a=1);this.x=(b-k)/a;this.y=(f-c)/a;this.z=(g-d)/a;this.w=Math.acos((e+h+m-1)/2);return this},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);this.w=Math.min(this.w,a.w);return this},max:function(a){this.x=Math.max(this.x,a.x);
11964 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 ga,b=new ga);a.set(c,c,c,c);b.set(d,d,d,d);return this.clamp(a,b)}}(),floor:function(){this.x=Math.floor(this.x);this.y=Math.floor(this.y);
11965 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);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);
11966 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*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)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)},
11967 normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.multiplyScalar(a/this.length())},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,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=
11968 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},fromAttribute:function(a,b,c){void 0===c&&(c=0);b=b*a.itemSize+c;this.x=a.array[b];this.y=a.array[b+1];this.z=a.array[b+2];this.w=a.array[b+3];return this}};Object.assign(Db.prototype,sa.prototype,{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,
11969 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();this.depthBuffer=a.depthBuffer;this.stencilBuffer=a.stencilBuffer;this.depthTexture=a.depthTexture;return this},dispose:function(){this.dispatchEvent({type:"dispose"})}});Eb.prototype=Object.create(Db.prototype);Eb.prototype.constructor=Eb;Eb.prototype.isWebGLRenderTargetCube=!0;ba.prototype={constructor:ba,get x(){return this._x},
11970 set x(a){this._x=a;this.onChangeCallback()},get y(){return this._y},set y(a){this._y=a;this.onChangeCallback()},get z(){return this._z},set z(a){this._z=a;this.onChangeCallback()},get w(){return this._w},set w(a){this._w=a;this.onChangeCallback()},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();
11971 return this},setFromEuler:function(a,b){if(!1===(a&&a.isEuler))throw Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");var c=Math.cos(a._x/2),d=Math.cos(a._y/2),e=Math.cos(a._z/2),f=Math.sin(a._x/2),g=Math.sin(a._y/2),h=Math.sin(a._z/2),k=a.order;"XYZ"===k?(this._x=f*d*e+c*g*h,this._y=c*g*e-f*d*h,this._z=c*d*h+f*g*e,this._w=c*d*e-f*g*h):"YXZ"===k?(this._x=f*d*e+c*g*h,this._y=c*g*e-f*d*h,this._z=c*d*h-f*g*e,this._w=c*d*e+f*g*h):"ZXY"===k?(this._x=
11972 f*d*e-c*g*h,this._y=c*g*e+f*d*h,this._z=c*d*h+f*g*e,this._w=c*d*e-f*g*h):"ZYX"===k?(this._x=f*d*e-c*g*h,this._y=c*g*e+f*d*h,this._z=c*d*h-f*g*e,this._w=c*d*e+f*g*h):"YZX"===k?(this._x=f*d*e+c*g*h,this._y=c*g*e+f*d*h,this._z=c*d*h-f*g*e,this._w=c*d*e-f*g*h):"XZY"===k&&(this._x=f*d*e-c*g*h,this._y=c*g*e-f*d*h,this._z=c*d*h+f*g*e,this._w=c*d*e+f*g*h);if(!1!==b)this.onChangeCallback();return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c);this._x=a.x*d;this._y=a.y*d;this._z=a.z*d;this._w=
11973 Math.cos(c);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],m=c+f+b;0<m?(c=.5/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+
11974 h)/c,this._y=(g+k)/c,this._z=.25*c);this.onChangeCallback();return this},setFromUnitVectors:function(){var a,b;return function(c,d){void 0===a&&(a=new q);b=c.dot(d)+1;1E-6>b?(b=0,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()}}(),inverse:function(){return this.conjugate().normalize()},conjugate:function(){this._x*=-1;this._y*=-1;this._z*=-1;this.onChangeCallback();return this},dot:function(a){return this._x*
11975 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."),
11976 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,f=a._w,g=b._x,h=b._y,k=b._z,m=b._w;this._x=c*m+f*g+d*k-e*h;this._y=d*m+f*h+e*g-c*k;this._z=e*m+f*k+c*h-d*g;this._w=f*m-c*g-d*h-e*k;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;
11977 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;var h=Math.sqrt(1-g*g);if(.001>Math.abs(h))return this._w=.5*(f+this._w),this._x=.5*(c+this._x),this._y=.5*(d+this._y),this._z=.5*(e+this._z),this;var k=Math.atan2(h,g),g=Math.sin((1-b)*k)/h,h=Math.sin(b*k)/h;this._w=f*g+this._w*h;this._x=c*g+this._x*h;this._y=d*g+this._y*h;this._z=e*g+this._z*h;this.onChangeCallback();return this},equals:function(a){return a._x===
11978 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(ba,{slerp:function(a,b,c,d){return c.copy(a).slerp(b,d)},slerpFlat:function(a,
11979 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 l=e[f+1],n=e[f+2];e=e[f+3];if(c!==e||h!==d||k!==l||m!==n){f=1-g;var p=h*d+k*l+m*n+c*e,r=0<=p?1:-1,x=1-p*p;x>Number.EPSILON&&(x=Math.sqrt(x),p=Math.atan2(x,p*r),f=Math.sin(f*p)/x,g=Math.sin(g*p)/x);r*=g;h=h*f+d*r;k=k*f+l*r;m=m*f+n*r;c=c*f+e*r;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}});q.prototype={constructor:q,isVector3:!0,set:function(a,b,c){this.x=a;this.y=b;this.z=c;return this},
11980 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,
11981 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+=
11982 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."),
11983 this.multiplyVectors(a,b);this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){isFinite(a)?(this.x*=a,this.y*=a,this.z*=a):this.z=this.y=this.x=0;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;return function(b){!1===(b&&b.isEuler)&&console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order.");void 0===a&&(a=new ba);return this.applyQuaternion(a.setFromEuler(b))}}(),
11984 applyAxisAngle:function(){var a;return function(b,c){void 0===a&&(a=new ba);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;this.x=a[0]*b+a[4]*c+a[8]*d+a[12];this.y=a[1]*b+a[5]*c+a[9]*d+a[13];this.z=a[2]*b+a[6]*c+a[10]*d+a[14];return this},applyProjection:function(a){var b=
11985 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,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;return function(b){void 0===a&&(a=new J);
11986 a.multiplyMatrices(b.projectionMatrix,a.getInverse(b.matrixWorld));return this.applyProjection(a)}}(),unproject:function(){var a;return function(b){void 0===a&&(a=new J);a.multiplyMatrices(b.matrixWorld,a.getInverse(b.projectionMatrix));return this.applyProjection(a)}}(),transformDirection:function(a){var b=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/=
11987 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,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,b;return function(c,
11988 d){void 0===a&&(a=new q,b=new q);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.multiplyScalar(Math.max(a,Math.min(b,c))/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=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},
11989 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*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)},lengthManhattan:function(){return Math.abs(this.x)+
11990 Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.multiplyScalar(a/this.length())},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,b,c){return this.subVectors(b,a).multiplyScalar(c).add(a)},cross:function(a,b){if(void 0!==b)return console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(a,
11991 b);var c=this.x,d=this.y,e=this.z;this.x=d*a.z-e*a.y;this.y=e*a.x-c*a.z;this.z=c*a.y-d*a.x;return this},crossVectors:function(a,b){var c=a.x,d=a.y,e=a.z,f=b.x,g=b.y,h=b.z;this.x=d*h-e*g;this.y=e*f-c*h;this.z=c*g-d*f;return this},projectOnVector:function(a){var b=a.dot(this)/a.lengthSq();return this.copy(a).multiplyScalar(b)},projectOnPlane:function(){var a;return function(b){void 0===a&&(a=new q);a.copy(this).projectOnVector(b);return this.sub(a)}}(),reflect:function(){var a;return function(b){void 0===
11992 a&&(a=new q);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(T.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},distanceToManhattan:function(a){return Math.abs(this.x-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;
11993 this.x=b*Math.sin(a.theta);this.y=Math.cos(a.phi)*a.radius;this.z=b*Math.cos(a.theta);return this},setFromMatrixPosition:function(a){return this.setFromMatrixColumn(a,3)},setFromMatrixScale:function(a){var b=this.setFromMatrixColumn(a,0).length(),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){if("number"===typeof a){console.warn("THREE.Vector3: setFromMatrixColumn now expects ( matrix, index ).");
11994 var c=a;a=b;b=c}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},fromAttribute:function(a,b,c){void 0===c&&(c=0);b=b*a.itemSize+c;this.x=a.array[b];this.y=a.array[b+1];this.z=a.array[b+2];return this}};J.prototype={constructor:J,isMatrix4:!0,
11995 set:function(a,b,c,d,e,f,g,h,k,m,l,n,p,r,x,t){var q=this.elements;q[0]=a;q[4]=b;q[8]=c;q[12]=d;q[1]=e;q[5]=f;q[9]=g;q[13]=h;q[2]=k;q[6]=m;q[10]=l;q[14]=n;q[3]=p;q[7]=r;q[11]=x;q[15]=t;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 J).fromArray(this.elements)},copy:function(a){this.elements.set(a.elements);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,
11996 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,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;return function(b){void 0===a&&(a=new q);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[4]=d[4]*f;c[5]=d[5]*f;c[6]=d[6]*
11997 f;c[8]=d[8]*b;c[9]=d[9]*b;c[10]=d[10]*b;return this}}(),makeRotationFromEuler:function(a){!1===(a&&a.isEuler)&&console.error("THREE.Matrix: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");var b=this.elements,c=a.x,d=a.y,e=a.z,f=Math.cos(c),c=Math.sin(c),g=Math.cos(d),d=Math.sin(d),h=Math.cos(e),e=Math.sin(e);if("XYZ"===a.order){a=f*h;var k=f*e,m=c*h,l=c*e;b[0]=g*h;b[4]=-g*e;b[8]=d;b[1]=k+m*d;b[5]=a-l*d;b[9]=-c*g;b[2]=l-a*d;b[6]=m+k*d;b[10]=f*g}else"YXZ"===
11998 a.order?(a=g*h,k=g*e,m=d*h,l=d*e,b[0]=a+l*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]=l+a*c,b[10]=f*g):"ZXY"===a.order?(a=g*h,k=g*e,m=d*h,l=d*e,b[0]=a-l*c,b[4]=-f*e,b[8]=m+k*c,b[1]=k+m*c,b[5]=f*h,b[9]=l-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,l=c*e,b[0]=g*h,b[4]=m*d-k,b[8]=a*d+l,b[1]=g*e,b[5]=l*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,l=c*d,b[0]=g*h,b[4]=l-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*
11999 e+m,b[10]=a-l*e):"XZY"===a.order&&(a=f*g,k=f*d,m=c*g,l=c*d,b[0]=g*h,b[4]=-e,b[8]=d*h,b[1]=a*e+l,b[5]=f*h,b[9]=k*e-m,b[2]=m*e-k,b[6]=c*h,b[10]=l*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(a){var b=this.elements,c=a.x,d=a.y,e=a.z,f=a.w,g=c+c,h=d+d,k=e+e;a=c*g;var m=c*h,c=c*k,l=d*h,d=d*k,e=e*k,g=f*g,h=f*h,f=f*k;b[0]=1-(l+e);b[4]=m-f;b[8]=c+h;b[1]=m+f;b[5]=1-(a+e);b[9]=d-g;b[2]=c-h;b[6]=d+g;b[10]=1-(a+l);b[3]=0;b[7]=0;b[11]=0;b[12]=0;b[13]=
12000 0;b[14]=0;b[15]=1;return this},lookAt:function(){var a,b,c;return function(d,e,f){void 0===a&&(a=new q,b=new q,c=new q);var g=this.elements;c.subVectors(d,e).normalize();0===c.lengthSq()&&(c.z=1);a.crossVectors(f,c).normalize();0===a.lengthSq()&&(c.z+=1E-4,a.crossVectors(f,c).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!==b?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),
12001 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,e=this.elements,f=c[0],g=c[4],h=c[8],k=c[12],m=c[1],l=c[5],n=c[9],p=c[13],r=c[2],x=c[6],t=c[10],q=c[14],u=c[3],v=c[7],I=c[11],c=c[15],y=d[0],E=d[4],H=d[8],F=d[12],M=d[1],B=d[5],K=d[9],z=d[13],C=d[2],G=d[6],J=d[10],N=d[14],P=d[3],R=d[7],S=d[11],d=d[15];e[0]=f*y+g*M+h*C+k*P;e[4]=f*E+g*B+h*G+k*R;e[8]=f*H+g*K+h*J+k*S;e[12]=
12002 f*F+g*z+h*N+k*d;e[1]=m*y+l*M+n*C+p*P;e[5]=m*E+l*B+n*G+p*R;e[9]=m*H+l*K+n*J+p*S;e[13]=m*F+l*z+n*N+p*d;e[2]=r*y+x*M+t*C+q*P;e[6]=r*E+x*B+t*G+q*R;e[10]=r*H+x*K+t*J+q*S;e[14]=r*F+x*z+t*N+q*d;e[3]=u*y+v*M+I*C+c*P;e[7]=u*E+v*B+I*G+c*R;e[11]=u*H+v*K+I*J+c*S;e[15]=u*F+v*z+I*N+c*d;return this},multiplyToArray:function(a,b,c){var d=this.elements;this.multiplyMatrices(a,b);c[0]=d[0];c[1]=d[1];c[2]=d[2];c[3]=d[3];c[4]=d[4];c[5]=d[5];c[6]=d[6];c[7]=d[7];c[8]=d[8];c[9]=d[9];c[10]=d[10];c[11]=d[11];c[12]=d[12];
12003 c[13]=d[13];c[14]=d[14];c[15]=d[15];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]*=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},applyToVector3Array:function(){var a;return function(b,c,d){void 0===a&&(a=new q);void 0===c&&(c=0);void 0===d&&(d=b.length);for(var e=0;e<d;e+=3,c+=3)a.fromArray(b,c),a.applyMatrix4(this),a.toArray(b,c);return b}}(),applyToBuffer:function(){var a;return function(b,
12004 c,d){void 0===a&&(a=new q);void 0===c&&(c=0);void 0===d&&(d=b.length/b.itemSize);for(var e=0;e<d;e++,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],l=a[6],n=a[10],p=a[14];return a[3]*(+e*h*l-d*k*l-e*g*n+c*k*n+d*g*p-c*h*p)+a[7]*(+b*h*p-b*k*n+e*f*n-d*f*p+d*k*m-e*h*m)+a[11]*(+b*k*l-b*g*p-e*f*l+c*f*p+e*g*m-c*k*m)+a[15]*(-d*g*m-b*h*l+b*g*n+
12005 d*f*l-c*f*n+c*h*m)},transpose:function(){var a=this.elements,b;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},flattenToArrayOffset:function(a,b){console.warn("THREE.Matrix3: .flattenToArrayOffset is deprecated - just use .toArray instead.");return this.toArray(a,b)},getPosition:function(){var a;return function(){void 0===a&&(a=new q);console.warn("THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead.");
12006 return a.setFromMatrixColumn(this,3)}}(),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,e=d[0],f=d[1],g=d[2],h=d[3],k=d[4],m=d[5],l=d[6],n=d[7],p=d[8],r=d[9],x=d[10],t=d[11],q=d[12],u=d[13],v=d[14],d=d[15],I=r*v*n-u*x*n+u*l*t-m*v*t-r*l*d+m*x*d,y=q*x*n-p*v*n-q*l*t+k*v*t+p*l*d-k*x*d,E=p*u*n-q*r*n+q*m*t-k*u*t-p*m*d+k*r*d,H=q*r*l-p*u*l-q*m*x+k*u*x+p*m*v-k*r*v,F=e*I+f*y+g*E+h*H;if(0===F){if(!0===b)throw Error("THREE.Matrix4.getInverse(): can't invert matrix, determinant is 0");
12007 console.warn("THREE.Matrix4.getInverse(): can't invert matrix, determinant is 0");return this.identity()}F=1/F;c[0]=I*F;c[1]=(u*x*h-r*v*h-u*g*t+f*v*t+r*g*d-f*x*d)*F;c[2]=(m*v*h-u*l*h+u*g*n-f*v*n-m*g*d+f*l*d)*F;c[3]=(r*l*h-m*x*h-r*g*n+f*x*n+m*g*t-f*l*t)*F;c[4]=y*F;c[5]=(p*v*h-q*x*h+q*g*t-e*v*t-p*g*d+e*x*d)*F;c[6]=(q*l*h-k*v*h-q*g*n+e*v*n+k*g*d-e*l*d)*F;c[7]=(k*x*h-p*l*h+p*g*n-e*x*n-k*g*t+e*l*t)*F;c[8]=E*F;c[9]=(q*r*h-p*u*h-q*f*t+e*u*t+p*f*d-e*r*d)*F;c[10]=(k*u*h-q*m*h+q*f*n-e*u*n-k*f*d+e*m*d)*F;c[11]=
12008 (p*m*h-k*r*h-p*f*n+e*r*n+k*f*t-e*m*t)*F;c[12]=H*F;c[13]=(p*u*g-q*r*g+q*f*x-e*u*x-p*f*v+e*r*v)*F;c[14]=(q*m*g-k*u*g-q*f*l+e*u*l+k*f*v-e*m*v)*F;c[15]=(k*r*g-p*m*g+p*f*l-e*r*l-k*f*x+e*m*x)*F;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],
12009 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=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=
12010 Math.cos(b),d=Math.sin(b),e=1-c,f=a.x,g=a.y,h=a.z,k=e*f,m=e*g;this.set(k*f+c,k*g-d*h,k*h+d*g,0,k*g+d*h,m*g+c,m*h-d*f,0,k*h-d*g,m*h+d*f,e*h*h+c,0,0,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},compose:function(a,b,c){this.makeRotationFromQuaternion(b);this.scale(c);this.setPosition(a);return this},decompose:function(){var a,b;return function(c,d,e){void 0===a&&(a=new q,b=new J);var f=this.elements,g=a.set(f[0],f[1],f[2]).length(),h=a.set(f[4],
12011 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.elements.set(this.elements);c=1/g;var f=1/h,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);e.x=g;e.y=h;e.z=k;return this}}(),makeFrustum:function(a,b,c,d,e,f){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/(d-c);
12012 g[9]=(d+c)/(d-c);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},makePerspective:function(a,b,c,d){a=c*Math.tan(T.DEG2RAD*a*.5);var e=-a;return this.makeFrustum(e*b,a*b,e,a,c,d)},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]=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=
12013 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];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}};Xa.prototype=Object.create(da.prototype);
12014 Xa.prototype.constructor=Xa;Xa.prototype.isCubeTexture=!0;Object.defineProperty(Xa.prototype,"images",{get:function(){return this.image},set:function(a){this.image=a}});var ie=new da,je=new Xa,fe=[],he=[];ne.prototype.setValue=function(a,b){for(var c=this.seq,d=0,e=c.length;d!==e;++d){var f=c[d];f.setValue(a,b[f.id])}};var zd=/([\w\d_]+)(\])?(\[|\.)?/g;Ya.prototype.setValue=function(a,b,c){b=this.map[b];void 0!==b&&b.setValue(a,c,this.renderer)};Ya.prototype.set=function(a,b,c){var d=this.map[c];
12015 void 0!==d&&d.setValue(a,b[c],this.renderer)};Ya.prototype.setOptional=function(a,b,c){b=b[c];void 0!==b&&this.setValue(a,c,b)};Ya.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)}};Ya.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 La={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=
12016 {},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}},X={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",
12017 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",
12018 begin_vertex:"\nvec3 transformed = vec3( position );\n",beginnormal_vertex:"\nvec3 objectNormal = vec3( normal );\n",bsdfs:"bool testLightInRange( const in float lightDistance, const in float cutoffDistance ) {\n\treturn any( bvec2( cutoffDistance == 0.0, lightDistance < cutoffDistance ) );\n}\nfloat punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\t\tif( decayExponent > 0.0 ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\t\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\t\tfloat maxDistanceCutoffFactor = pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\t\treturn distanceFalloff * maxDistanceCutoffFactor;\n#else\n\t\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n#endif\n\t\t}\n\t\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}\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",
12019 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 = dFdx( surf_pos );\n\t\tvec3 vSigmaY = dFdy( surf_pos );\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\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif\n",
12020 clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; ++ i ) {\n\t\tvec4 plane = clippingPlanes[ i ];\n\t\tif ( dot( vViewPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t\t\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; ++ i ) {\n\t\t\tvec4 plane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vViewPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\tif ( clipped ) discard;\n\t\n\t#endif\n#endif\n",
12021 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",
12022 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 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}\n",
12023 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(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",
12024 defaultnormal_vertex:"#ifdef FLIP_SIDED\n\tobjectNormal = -objectNormal;\n#endif\nvec3 transformedNormal = normalMatrix * objectNormal;\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 += normal * ( texture2D( displacementMap, uv ).x * displacementScale + displacementBias );\n#endif\n",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif\n",
12025 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 return value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n return vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n return vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n return 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 return 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 return vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n float maxComponent = max( max( value.r, value.g ), value.b );\n float fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n return vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n return vec4( value.xyz * value.w * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n float maxRGB = max( value.x, max( value.g, value.b ) );\n float M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n M = ceil( M * 255.0 ) / 255.0;\n return vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n return vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n float maxRGB = max( value.x, max( value.g, value.b ) );\n float D = max( maxRange / maxRGB, 1.0 );\n D = min( floor( D ) / 255.0, 1.0 );\n return 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 vec3 Xp_Y_XYZp = value.rgb * cLogLuvM;\n Xp_Y_XYZp = max(Xp_Y_XYZp, vec3(1e-6, 1e-6, 1e-6));\n vec4 vResult;\n vResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n float Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n vResult.w = fract(Le);\n vResult.z = (Le - (floor(vResult.w*255.0))/255.0)/255.0;\n return 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 float Le = value.z * 255.0 + value.w;\n vec3 Xp_Y_XYZp;\n Xp_Y_XYZp.y = exp2((Le - 127.0) / 2.0);\n Xp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n Xp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n vec3 vRGB = Xp_Y_XYZp.rgb * cLogLuvInverseM;\n return vec4( max(vRGB, 0.0), 1.0 );\n}\n",
12026 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, flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\tvec2 sampleUV;\n\t\tsampleUV.y = saturate( flipNormal * reflectVec.y * 0.5 + 0.5 );\n\t\tsampleUV.x = atan( flipNormal * reflectVec.z, flipNormal * reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\tvec4 envColor = texture2D( envMap, sampleUV );\n\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\tvec3 reflectView = flipNormal * 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",
12027 envmap_pars_fragment:"#if defined( USE_ENVMAP ) || defined( PHYSICAL )\n\tuniform float reflectivity;\n\tuniform float envMapIntenstiy;\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\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",
12028 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_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",
12029 fog_fragment:"#ifdef USE_FOG\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tfloat depth = gl_FragDepthEXT / gl_FragCoord.w;\n\t#else\n\t\tfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n\t#endif\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * depth * depth * LOG2 ) );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, depth );\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\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",
12030 lightmap_fragment:"#ifdef USE_LIGHTMAP\n\treflectedLight.indirectDiffuse += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n#endif\n",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\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\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\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\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",
12031 lights_pars:"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};\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\tif ( testLightInRange( lightDistance, pointLight.distance ) ) {\n\t\t\tdirectLight.color = pointLight.color;\n\t\t\tdirectLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.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_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 ( all( bvec2( angleCos > spotLight.coneCos, testLightInRange( lightDistance, spotLight.distance ) ) ) ) {\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_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#if defined( USE_ENVMAP ) && defined( PHYSICAL )\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\t#include <normal_flip>\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = flipNormal * 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 = flipNormal * vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( 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\t#include <normal_flip>\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 = flipNormal * 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 = flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\tvec4 envMapColor = textureCubeUV(queryReflectVec, BlinnExponentToGGXRoughness(blinnShininessExponent));\n\t\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\t\tvec2 sampleUV;\n\t\t\tsampleUV.y = saturate( flipNormal * reflectVec.y * 0.5 + 0.5 );\n\t\t\tsampleUV.x = atan( flipNormal * reflectVec.z, flipNormal * 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 = flipNormal * 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",
12032 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\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\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",
12033 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",
12034 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}\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_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",
12035 lights_template:"\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\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 ] ) : 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\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\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 defined( RE_IndirectDiffuse )\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\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 ( NUM_HEMI_LIGHTS > 0 )\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\t#if defined( USE_ENVMAP ) && defined( PHYSICAL ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t \tirradiance += getLightProbeIndirectIrradiance( geometry, 8 );\n\t#endif\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tvec3 radiance = getLightProbeIndirectRadiance( geometry, Material_BlinnShininessExponent( material ), 8 );\n\t#ifndef STANDARD\n\t\tvec3 clearCoatRadiance = getLightProbeIndirectRadiance( geometry, Material_ClearCoat_BlinnShininessExponent( material ), 8 );\n\t#else\n\t\tvec3 clearCoatRadiance = vec3( 0.0 );\n\t#endif\n\t\t\n\tRE_IndirectSpecular( radiance, clearCoatRadiance, geometry, material, reflectedLight );\n#endif\n",
12036 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",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\tgl_Position.z = log2(max( EPSILON, gl_Position.w + 1.0 )) * logDepthBufFC;\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t#else\n\t\tgl_Position.z = (gl_Position.z - 1.0) * gl_Position.w;\n\t#endif\n#endif\n",
12037 map_fragment:"#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif\n",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n",map_particle_fragment:"#ifdef USE_MAP\n\tvec4 mapTexel = texture2D( map, vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y ) * offsetRepeat.zw + offsetRepeat.xy );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n",map_particle_pars_fragment:"#ifdef USE_MAP\n\tuniform vec4 offsetRepeat;\n\tuniform sampler2D map;\n#endif\n",
12038 metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.r;\n#endif\n",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",
12039 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",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",
12040 normal_flip:"#ifdef DOUBLE_SIDED\n\tfloat flipNormal = ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n#else\n\tfloat flipNormal = 1.0;\n#endif\n",normal_fragment:"#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 ) * flipNormal;\n#endif\n#ifdef USE_NORMALMAP\n\tnormal = perturbNormal2Arb( -vViewPosition, normal );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n#endif\n",
12041 normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm ) {\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\t\tvec3 S = normalize( q0 * st1.t - q1 * st0.t );\n\t\tvec3 T = normalize( -q0 * st1.s + q1 * st0.s );\n\t\tvec3 N = normalize( surf_norm );\n\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\tmapN.xy = normalScale * mapN.xy;\n\t\tmat3 tsn = mat3( S, T, N );\n\t\treturn normalize( tsn * mapN );\n\t}\n#endif\n",
12042 packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n return normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n return 1.0 - 2.0 * rgb.xyz;\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 return ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n return linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n return (( near + viewZ ) * far ) / (( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n return ( near * far ) / ( ( far - near ) * invClipZ - far );\n}\n",
12043 premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif\n",project_vertex:"#ifdef USE_SKINNING\n\tvec4 mvPosition = modelViewMatrix * skinned;\n#else\n\tvec4 mvPosition = modelViewMatrix * vec4( transformed, 1.0 );\n#endif\ngl_Position = projectionMatrix * mvPosition;\n",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.r;\n#endif\n",
12044 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\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\treturn (\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\treturn (\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\treturn texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn 1.0;\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 ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\tfloat dp = ( length( lightToPosition ) - shadowBias ) / 1000.0;\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",
12045 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",
12046 shadowmap_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\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\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\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n#endif\n",
12047 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\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\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\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 ] ) : 1.0;\n\t}\n\t#endif\n\t#endif\n\treturn shadow;\n}\n",
12048 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 boneTextureWidth;\n\t\tuniform int boneTextureHeight;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureWidth ) );\n\t\t\tfloat y = floor( j / float( boneTextureWidth ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureWidth );\n\t\t\tfloat dy = 1.0 / float( boneTextureHeight );\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",
12049 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\tskinned = bindMatrixInverse * skinned;\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",
12050 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:"#define saturate(a) clamp( a, 0.0, 1.0 )\nuniform float toneMappingExposure;\nuniform float toneMappingWhitePoint;\nvec3 LinearToneMapping( vec3 color ) {\n return toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n color *= toneMappingExposure;\n return 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 color *= toneMappingExposure;\n return saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n color *= toneMappingExposure;\n color = max( vec3( 0.0 ), color - 0.004 );\n return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\n",
12051 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 vec4 offsetRepeat;\n#endif\n",
12052 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 = uv * offsetRepeat.zw + offsetRepeat.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",
12053 uv2_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = uv2;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( PHONG ) || defined( PHYSICAL ) || defined( LAMBERT ) || defined ( USE_SHADOWMAP )\n\t#ifdef USE_SKINNING\n\t\tvec4 worldPosition = modelMatrix * skinned;\n\t#else\n\t\tvec4 worldPosition = modelMatrix * vec4( transformed, 1.0 );\n\t#endif\n#endif\n",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldPosition;\n#include <common>\nvoid main() {\n\tgl_FragColor = textureCube( tCube, vec3( tFlip * vWorldPosition.x, vWorldPosition.yz ) );\n\tgl_FragColor.a *= opacity;\n}\n",
12054 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}\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( gl_FragCoord.z ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( gl_FragCoord.z );\n\t#endif\n}\n",
12055 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#include <begin_vertex>\n\t#include <displacementmap_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}\n",
12056 distanceRGBA_frag:"uniform vec3 lightPos;\nvarying vec4 vWorldPosition;\n#include <common>\n#include <packing>\n#include <clipping_planes_pars_fragment>\nvoid main () {\n\t#include <clipping_planes_fragment>\n\tgl_FragColor = packDepthToRGBA( length( vWorldPosition.xyz - lightPos.xyz ) / 1000.0 );\n}\n",distanceRGBA_vert:"varying vec4 vWorldPosition;\n#include <common>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <skinbase_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition;\n}\n",
12057 equirect_frag:"uniform sampler2D tEquirect;\nuniform float tFlip;\nvarying vec3 vWorldPosition;\n#include <common>\nvoid main() {\n\tvec3 direction = normalize( vWorldPosition );\n\tvec2 sampleUV;\n\tsampleUV.y = saturate( tFlip * direction.y * -0.5 + 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",
12058 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",
12059 linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <color_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}\n",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 <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;\n\treflectedLight.directDiffuse = vec3( 0.0 );\n\treflectedLight.directSpecular = vec3( 0.0 );\n\treflectedLight.indirectDiffuse = diffuseColor.rgb;\n\treflectedLight.indirectSpecular = vec3( 0.0 );\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <normal_flip>\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",
12060 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 <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}\n",
12061 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 <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>\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 <normal_flip>\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",
12062 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>\n#include <color_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}\n",
12063 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 <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 <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars>\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_flip>\n\t#include <normal_fragment>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_template>\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 <premultiplied_alpha_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}\n",
12064 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 <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 <displacementmap_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\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n}\n",
12065 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\nuniform float envMapIntensity;\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <packing>\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 <fog_pars_fragment>\n#include <bsdfs>\n#include <cube_uv_reflection_fragment>\n#include <lights_pars>\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 <specularmap_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_flip>\n\t#include <normal_fragment>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_template>\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 <premultiplied_alpha_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}\n",
12066 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 <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <specularmap_pars_fragment>\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 <displacementmap_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\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n}\n",
12067 normal_frag:"uniform float opacity;\nvarying vec3 vNormal;\n#include <common>\n#include <packing>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tgl_FragColor = vec4( packNormalToRGB( vNormal ), opacity );\n\t#include <logdepthbuf_fragment>\n}\n",normal_vert:"varying vec3 vNormal;\n#include <common>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\tvNormal = normalize( normalMatrix * normal );\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n}\n",
12068 points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <fog_pars_fragment>\n#include <shadowmap_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",
12069 points_vert:"uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <shadowmap_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 <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 <shadowmap_vertex>\n}\n",
12070 shadow_frag:"uniform float opacity;\n#include <common>\n#include <packing>\n#include <bsdfs>\n#include <lights_pars>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\tgl_FragColor = vec4( 0.0, 0.0, 0.0, opacity * ( 1.0 - getShadowMask() ) );\n}\n",shadow_vert:"#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}\n"};O.prototype={constructor:O,
12071 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,
12072 c,d){b=T.euclideanModulo(b,1);c=T.clamp(c,0,1);d=T.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=
12073 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)){var d=parseFloat(c[1])/
12074 360,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=He[a],void 0!==
12075 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);var c=0<b?1/b:1;this.r=Math.pow(a.r,c);this.g=Math.pow(a.g,c);this.b=Math.pow(a.b,c);return this},convertGammaToLinear:function(){var a=
12076 this.r,b=this.g,c=this.b;this.r=a*a;this.g=b*b;this.b=c*c;return this},convertLinearToGamma:function(){this.r=Math.sqrt(this.r);this.g=Math.sqrt(this.g);this.b=Math.sqrt(this.b);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){a=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):
12077 k/(2-e-f);switch(e){case b:g=(c-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(a,b,c){var d=this.getHSL();d.h+=a;d.s+=b;d.l+=c;this.setHSL(d.h,d.s,d.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+=
12078 a;this.g+=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=
12079 0);this.r=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 He={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,
12080 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,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,
12081 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,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,
12082 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,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,
12083 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,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,
12084 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},W={common:{diffuse:{value:new O(15658734)},opacity:{value:1},map:{value:null},offsetRepeat:{value:new ga(0,0,1,1)},specularMap:{value:null},alphaMap:{value:null},envMap:{value:null},flipEnvMap:{value:-1},
12085 reflectivity:{value:1},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},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 B(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},
12086 fog:{fogDensity:{value:2.5E-4},fogNear:{value:1},fogFar:{value:2E3},fogColor:{value:new O(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:[]},
12087 spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{},shadow:{},shadowBias:{},shadowRadius:{},shadowMapSize:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}}},points:{diffuse:{value:new O(15658734)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},offsetRepeat:{value:new ga(0,0,1,1)}}},Gb={basic:{uniforms:La.merge([W.common,W.aomap,W.fog]),vertexShader:X.meshbasic_vert,
12088 fragmentShader:X.meshbasic_frag},lambert:{uniforms:La.merge([W.common,W.aomap,W.lightmap,W.emissivemap,W.fog,W.lights,{emissive:{value:new O(0)}}]),vertexShader:X.meshlambert_vert,fragmentShader:X.meshlambert_frag},phong:{uniforms:La.merge([W.common,W.aomap,W.lightmap,W.emissivemap,W.bumpmap,W.normalmap,W.displacementmap,W.fog,W.lights,{emissive:{value:new O(0)},specular:{value:new O(1118481)},shininess:{value:30}}]),vertexShader:X.meshphong_vert,fragmentShader:X.meshphong_frag},standard:{uniforms:La.merge([W.common,
12089 W.aomap,W.lightmap,W.emissivemap,W.bumpmap,W.normalmap,W.displacementmap,W.roughnessmap,W.metalnessmap,W.fog,W.lights,{emissive:{value:new O(0)},roughness:{value:.5},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:X.meshphysical_vert,fragmentShader:X.meshphysical_frag},points:{uniforms:La.merge([W.points,W.fog]),vertexShader:X.points_vert,fragmentShader:X.points_frag},dashed:{uniforms:La.merge([W.common,W.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:X.linedashed_vert,
12090 fragmentShader:X.linedashed_frag},depth:{uniforms:La.merge([W.common,W.displacementmap]),vertexShader:X.depth_vert,fragmentShader:X.depth_frag},normal:{uniforms:{opacity:{value:1}},vertexShader:X.normal_vert,fragmentShader:X.normal_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:X.cube_vert,fragmentShader:X.cube_frag},equirect:{uniforms:{tEquirect:{value:null},tFlip:{value:-1}},vertexShader:X.equirect_vert,fragmentShader:X.equirect_frag},distanceRGBA:{uniforms:{lightPos:{value:new q}},
12091 vertexShader:X.distanceRGBA_vert,fragmentShader:X.distanceRGBA_frag}};Gb.physical={uniforms:La.merge([Gb.standard.uniforms,{clearCoat:{value:0},clearCoatRoughness:{value:0}}]),vertexShader:X.meshphysical_vert,fragmentShader:X.meshphysical_frag};mc.prototype={constructor:mc,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 B;return function(b,
12092 c){var d=a.copy(c).multiplyScalar(.5);this.min.copy(b).sub(d);this.max.copy(b).add(d);return this}}(),clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.min.copy(a.min);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){a=a||new B;return this.isEmpty()?a.set(0,0):a.addVectors(this.min,this.max).multiplyScalar(.5)},
12093 getSize:function(a){a=a||new B;return this.isEmpty()?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&&
12094 this.min.y<=a.min.y&&a.max.y<=this.max.y?!0:!1},getParameter:function(a,b){return(b||new 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){return(b||new B).copy(a).clamp(this.min,this.max)},distanceToPoint:function(){var a=new B;return function(b){return a.copy(b).clamp(this.min,this.max).sub(b).length()}}(),intersect:function(a){this.min.max(a.min);
12095 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)}};U.prototype={constructor:U,isMaterial:!0,get needsUpdate(){return this._needsUpdate},set needsUpdate(a){!0===a&&this.update();this._needsUpdate=a},setValues:function(a){if(void 0!==a)for(var b in a){var c=a[b];if(void 0===c)console.warn("THREE.Material: '"+
12096 b+"' parameter is undefined.");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=a[c];delete d.metadata;b.push(d)}return b}var c=void 0===a;c&&(a={textures:{},images:{}});var d={metadata:{version:4.4,type:"Material",generator:"Material.toJSON"}};d.uuid=this.uuid;d.type=this.type;
12097 ""!==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());this.specular&&this.specular.isColor&&(d.specular=this.specular.getHex());void 0!==this.shininess&&(d.shininess=this.shininess);this.map&&this.map.isTexture&&(d.map=this.map.toJSON(a).uuid);this.alphaMap&&this.alphaMap.isTexture&&
12098 (d.alphaMap=this.alphaMap.toJSON(a).uuid);this.lightMap&&this.lightMap.isTexture&&(d.lightMap=this.lightMap.toJSON(a).uuid);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.normalScale=this.normalScale.toArray());this.displacementMap&&this.displacementMap.isTexture&&(d.displacementMap=this.displacementMap.toJSON(a).uuid,d.displacementScale=this.displacementScale,
12099 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&&(d.envMap=this.envMap.toJSON(a).uuid,d.reflectivity=
12100 this.reflectivity);void 0!==this.size&&(d.size=this.size);void 0!==this.sizeAttenuation&&(d.sizeAttenuation=this.sizeAttenuation);1!==this.blending&&(d.blending=this.blending);2!==this.shading&&(d.shading=this.shading);0!==this.side&&(d.side=this.side);0!==this.vertexColors&&(d.vertexColors=this.vertexColors);1>this.opacity&&(d.opacity=this.opacity);!0===this.transparent&&(d.transparent=this.transparent);d.depthFunc=this.depthFunc;d.depthTest=this.depthTest;d.depthWrite=this.depthWrite;0<this.alphaTest&&
12101 (d.alphaTest=this.alphaTest);!0===this.premultipliedAlpha&&(d.premultipliedAlpha=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);d.skinning=this.skinning;d.morphTargets=this.morphTargets;c&&(c=b(a.textures),a=b(a.images),0<c.length&&(d.textures=
12102 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.shading=a.shading;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=a.blendDstAlpha;this.blendEquationAlpha=a.blendEquationAlpha;
12103 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.alphaTest=a.alphaTest;this.premultipliedAlpha=a.premultipliedAlpha;this.overdraw=a.overdraw;this.visible=a.visible;this.clipShadows=a.clipShadows;this.clipIntersection=a.clipIntersection;a=a.clippingPlanes;var b=null;if(null!==a)for(var c=
12104 a.length,b=Array(c),d=0;d!==c;++d)b[d]=a[d].clone();this.clippingPlanes=b;return this},update:function(){this.dispatchEvent({type:"update"})},dispose:function(){this.dispatchEvent({type:"dispose"})}};Object.assign(U.prototype,sa.prototype);var oe=0;Fa.prototype=Object.create(U.prototype);Fa.prototype.constructor=Fa;Fa.prototype.isShaderMaterial=!0;Fa.prototype.copy=function(a){U.prototype.copy.call(this,a);this.fragmentShader=a.fragmentShader;this.vertexShader=a.vertexShader;this.uniforms=La.clone(a.uniforms);
12105 this.defines=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;this.morphNormals=a.morphNormals;this.extensions=a.extensions;return this};Fa.prototype.toJSON=function(a){a=U.prototype.toJSON.call(this,a);a.uniforms=this.uniforms;a.vertexShader=this.vertexShader;a.fragmentShader=this.fragmentShader;return a};Za.prototype=Object.create(U.prototype);Za.prototype.constructor=
12106 Za;Za.prototype.isMeshDepthMaterial=!0;Za.prototype.copy=function(a){U.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};Ba.prototype={constructor:Ba,isBox3:!0,set:function(a,b){this.min.copy(a);
12107 this.max.copy(b);return this},setFromArray:function(a){for(var b=Infinity,c=Infinity,d=Infinity,e=-Infinity,f=-Infinity,g=-Infinity,h=0,k=a.length;h<k;h+=3){var m=a[h],l=a[h+1],n=a[h+2];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);this.max.set(e,f,g)},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 q;return function(b,c){var d=a.copy(c).multiplyScalar(.5);
12108 this.min.copy(b).sub(d);this.max.copy(b).add(d);return this}}(),setFromObject:function(){var a=new q;return function(b){var c=this;b.updateMatrixWorld(!0);this.makeEmpty();b.traverse(function(b){var e=b.geometry;if(void 0!==e)if(e&&e.isGeometry)for(var e=e.vertices,f=0,g=e.length;f<g;f++)a.copy(e[f]),a.applyMatrix4(b.matrixWorld),c.expandByPoint(a);else if(e&&e.isBufferGeometry&&(g=e.attributes.position,void 0!==g)){var h;g&&g.isInterleavedBufferAttribute?(e=g.data.array,f=g.offset,h=g.data.stride):
12109 (e=g.array,f=0,h=3);for(g=e.length;f<g;f+=h)a.fromArray(e,f),a.applyMatrix4(b.matrixWorld),c.expandByPoint(a)}});return this}}(),clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.min.copy(a.min);this.max.copy(a.max);return this},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){a=a||new q;
12110 return this.isEmpty()?a.set(0,0,0):a.addVectors(this.min,this.max).multiplyScalar(.5)},getSize:function(a){a=a||new q;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},containsPoint:function(a){return a.x<this.min.x||a.x>this.max.x||a.y<this.min.y||a.y>this.max.y||
12111 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&&a.max.z<=this.max.z?!0:!1},getParameter:function(a,b){return(b||new q).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||
12112 a.min.z>this.max.z?!1:!0},intersectsSphere:function(){var a;return function(b){void 0===a&&(a=new q);this.clampPoint(b.center,a);return a.distanceToSquared(b.center)<=b.radius*b.radius}}(),intersectsPlane:function(a){var b,c;0<a.normal.x?(b=a.normal.x*this.min.x,c=a.normal.x*this.max.x):(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*
12113 this.max.z):(b+=a.normal.z*this.max.z,c+=a.normal.z*this.min.z);return b<=a.constant&&c>=a.constant},clampPoint:function(a,b){return(b||new q).copy(a).clamp(this.min,this.max)},distanceToPoint:function(){var a=new q;return function(b){return a.copy(b).clamp(this.min,this.max).sub(b).length()}}(),getBoundingSphere:function(){var a=new q;return function(b){b=b||new Ca;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);
12114 this.isEmpty()&&this.makeEmpty();return this},union:function(a){this.min.min(a.min);this.max.max(a.max);return this},applyMatrix4:function(){var a=[new q,new q,new q,new q,new q,new q,new q,new q];return function(b){if(this.isEmpty())return this;a[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(b);a[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(b);a[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(b);a[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(b);a[4].set(this.max.x,
12115 this.min.y,this.min.z).applyMatrix4(b);a[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(b);a[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(b);a[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(b);this.setFromPoints(a);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)}};Ca.prototype={constructor:Ca,set:function(a,b){this.center.copy(a);this.radius=b;return this},setFromPoints:function(){var a=
12116 new Ba;return function(b,c){var d=this.center;void 0!==c?d.copy(c):a.setFromPoints(b).getCenter(d);for(var e=0,f=0,g=b.length;f<g;f++)e=Math.max(e,d.distanceToSquared(b[f]));this.radius=Math.sqrt(e);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)-
12117 this.radius},intersectsSphere:function(a){var b=this.radius+a.radius;return a.center.distanceToSquared(this.center)<=b*b},intersectsBox:function(a){return a.intersectsSphere(this)},intersectsPlane:function(a){return Math.abs(this.center.dot(a.normal)-a.constant)<=this.radius},clampPoint:function(a,b){var c=this.center.distanceToSquared(a),d=b||new q;d.copy(a);c>this.radius*this.radius&&(d.sub(this.center).normalize(),d.multiplyScalar(this.radius).add(this.center));return d},getBoundingBox:function(a){a=
12118 a||new Ba;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}};Ia.prototype={constructor:Ia,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,
12119 0,0,0,1,0,0,0,1);return this},clone:function(){return(new this.constructor).fromArray(this.elements)},copy:function(a){a=a.elements;this.set(a[0],a[3],a[6],a[1],a[4],a[7],a[2],a[5],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},applyToVector3Array:function(){var a;return function(b,c,d){void 0===a&&(a=new q);void 0===c&&(c=0);void 0===d&&(d=b.length);for(var e=0;e<d;e+=3,c+=3)a.fromArray(b,c),a.applyMatrix3(this),a.toArray(b,
12120 c);return b}}(),applyToBuffer:function(){var a;return function(b,c,d){void 0===a&&(a=new q);void 0===c&&(c=0);void 0===d&&(d=b.length/b.itemSize);for(var e=0;e<d;e++,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}}(),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]*=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],
12121 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,d=this.elements,e=c[0],f=c[1],g=c[2],h=c[3],k=c[4],m=c[5],l=c[6],n=c[7],c=c[8],p=c*k-m*n,r=m*l-c*h,q=n*h-k*l,t=e*p+f*r+g*q;if(0===t){if(!0===b)throw Error("THREE.Matrix3.getInverse(): can't invert matrix, determinant is 0");console.warn("THREE.Matrix3.getInverse(): can't invert matrix, determinant is 0");return this.identity()}t=
12122 1/t;d[0]=p*t;d[1]=(g*n-c*f)*t;d[2]=(m*f-g*k)*t;d[3]=r*t;d[4]=(c*e-g*l)*t;d[5]=(g*h-m*e)*t;d[6]=q*t;d[7]=(f*l-n*e)*t;d[8]=(k*e-f*h)*t;return this},transpose:function(){var a,b=this.elements;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},flattenToArrayOffset:function(a,b){console.warn("THREE.Matrix3: .flattenToArrayOffset is deprecated - just use .toArray instead.");return this.toArray(a,b)},getNormalMatrix:function(a){return this.setFromMatrix4(a).getInverse(this).transpose()},
12123 transposeIntoArray:function(a){var b=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},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];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}};va.prototype={constructor:va,set:function(a,b){this.normal.copy(a);
12124 this.constant=b;return this},setComponents:function(a,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 q,b=new q;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);
12125 this.constant=a.constant;return this},normalize:function(){var a=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){return this.orthoPoint(a,b).sub(a).negate()},orthoPoint:function(a,b){var c=this.distanceToPoint(a);return(b||
12126 new q).copy(this.normal).multiplyScalar(c)},intersectLine:function(){var a=new q;return function(b,c){var d=c||new q,e=b.delta(a),f=this.normal.dot(e);if(0===f){if(0===this.distanceToPoint(b.start))return d.copy(b.start)}else return f=-(b.start.dot(this.normal)+this.constant)/f,0>f||1<f?void 0:d.copy(e).multiplyScalar(f).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)},
12127 intersectsSphere:function(a){return a.intersectsPlane(this)},coplanarPoint:function(a){return(a||new q).copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:function(){var a=new q,b=new Ia;return function(c,d){var e=this.coplanarPoint(a).applyMatrix4(c),f=d||b.getNormalMatrix(c),f=this.normal.applyMatrix3(f).normalize();this.constant=-e.dot(f);return this}}(),translate:function(a){this.constant-=a.dot(this.normal);return this},equals:function(a){return a.normal.equals(this.normal)&&a.constant===
12128 this.constant}};nc.prototype={constructor:nc,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],h=c[5],k=c[6],m=c[7],l=c[8],n=c[9],p=c[10],r=c[11],q=c[12],t=c[13],D=c[14],c=c[15];
12129 b[0].setComponents(f-a,m-g,r-l,c-q).normalize();b[1].setComponents(f+a,m+g,r+l,c+q).normalize();b[2].setComponents(f+d,m+h,r+n,c+t).normalize();b[3].setComponents(f-d,m-h,r-n,c-t).normalize();b[4].setComponents(f-e,m-k,r-p,c-D).normalize();b[5].setComponents(f+e,m+k,r+p,c+D).normalize();return this},intersectsObject:function(){var a=new Ca;return function(b){var c=b.geometry;null===c.boundingSphere&&c.computeBoundingSphere();a.copy(c.boundingSphere).applyMatrix4(b.matrixWorld);return this.intersectsSphere(a)}}(),
12130 intersectsSprite:function(){var a=new Ca;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 q,b=new q;return function(c){for(var d=this.planes,e=0;6>e;e++){var f=d[e];a.x=0<f.normal.x?c.min.x:c.max.x;b.x=0<f.normal.x?c.max.x:c.min.x;a.y=0<f.normal.y?
12131 c.min.y:c.max.y;b.y=0<f.normal.y?c.max.y:c.min.y;a.z=0<f.normal.z?c.min.z:c.max.z;b.z=0<f.normal.z?c.max.z:c.min.z;var g=f.distanceToPoint(a),f=f.distanceToPoint(b);if(0>g&&0>f)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}};ab.prototype={constructor:ab,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);
12132 this.direction.copy(a.direction);return this},at:function(a,b){return(b||new q).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 q;return function(b){this.origin.copy(this.at(b,a));return this}}(),closestPointToPoint:function(a,b){var c=b||new q;c.subVectors(a,this.origin);var d=c.dot(this.direction);return 0>d?c.copy(this.origin):c.copy(this.direction).multiplyScalar(d).add(this.origin)},
12133 distanceToPoint:function(a){return Math.sqrt(this.distanceSqToPoint(a))},distanceSqToPoint:function(){var a=new q;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 q,b=new q,c=new q;return function(d,e,f,g){a.copy(d).add(e).multiplyScalar(.5);b.copy(e).sub(d).normalize();c.copy(this.origin).sub(a);
12134 var h=.5*d.distanceTo(e),k=-this.direction.dot(b),m=c.dot(this.direction),l=-c.dot(b),n=c.lengthSq(),p=Math.abs(1-k*k),r;0<p?(d=k*l-m,e=k*m-l,r=h*p,0<=d?e>=-r?e<=r?(h=1/p,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<=-r?(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<=r?(d=0,e=Math.min(Math.max(-h,-l),h),k=e*(e+2*l)+n):(d=Math.max(0,-(k*h+m)),e=0<d?h:Math.min(Math.max(-h,
12135 -l),h),k=-d*d+e*(e+2*l)+n)):(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 q;return function(b,c){a.subVectors(b.center,this.origin);var d=a.dot(this.direction),e=a.dot(a)-d*d,f=b.radius*b.radius;if(e>f)return null;f=Math.sqrt(f-e);e=d-f;d+=f;return 0>e&&0>d?null:0>e?this.at(d,c):this.at(e,c)}}(),intersectsSphere:function(a){return this.distanceToPoint(a.center)<=
12136 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){var c=this.distanceToPlane(a);return null===c?null:this.at(c,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,b){var c,d,e,f,g;d=1/this.direction.x;f=1/this.direction.y;g=1/this.direction.z;
12137 var h=this.origin;0<=d?(c=(a.min.x-h.x)*d,d*=a.max.x-h.x):(c=(a.max.x-h.x)*d,d*=a.min.x-h.x);0<=f?(e=(a.min.y-h.y)*f,f*=a.max.y-h.y):(e=(a.max.y-h.y)*f,f*=a.min.y-h.y);if(c>f||e>d)return null;if(e>c||c!==c)c=e;if(f<d||d!==d)d=f;0<=g?(e=(a.min.z-h.z)*g,g*=a.max.z-h.z):(e=(a.max.z-h.z)*g,g*=a.min.z-h.z);if(c>g||e>d)return null;if(e>c||c!==c)c=e;if(g<d||d!==d)d=g;return 0>d?null:this.at(0<=c?c:d,b)},intersectsBox:function(){var a=new q;return function(b){return null!==this.intersectBox(b,a)}}(),intersectTriangle:function(){var a=
12138 new q,b=new q,c=new q,d=new q;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)}}(),applyMatrix4:function(a){this.direction.add(this.origin).applyMatrix4(a);this.origin.applyMatrix4(a);
12139 this.direction.sub(this.origin);this.direction.normalize();return this},equals:function(a){return a.origin.equals(this.origin)&&a.direction.equals(this.direction)}};bb.RotationOrders="XYZ YZX ZXY XZY YXZ ZYX".split(" ");bb.DefaultOrder="XYZ";bb.prototype={constructor:bb,isEuler:!0,get x(){return this._x},set x(a){this._x=a;this.onChangeCallback()},get y(){return this._y},set y(a){this._y=a;this.onChangeCallback()},get z(){return this._z},set z(a){this._z=a;this.onChangeCallback()},get order(){return this._order},
12140 set order(a){this._order=a;this.onChangeCallback()},set:function(a,b,c,d){this._x=a;this._y=b;this._z=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=T.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||
12141 this._order;"XYZ"===b?(this._y=Math.asin(d(g,-1,1)),.99999>Math.abs(g)?(this._x=Math.atan2(-m,e),this._z=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>
12142 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"===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();
12143 return this},setFromQuaternion:function(){var a;return function(b,c,d){void 0===a&&(a=new J);a.makeRotationFromQuaternion(b);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 ba;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];
12144 this._z=a[2];void 0!==a[3]&&(this._order=a[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._order;return a},toVector3:function(a){return a?a.set(this._x,this._y,this._z):new q(this._x,this._y,this._z)},onChange:function(a){this.onChangeCallback=a;return this},onChangeCallback:function(){}};Yc.prototype={constructor:Yc,set:function(a){this.mask=1<<a},enable:function(a){this.mask|=1<<a},toggle:function(a){this.mask^=
12145 1<<a},disable:function(a){this.mask&=~(1<<a)},test:function(a){return 0!==(this.mask&a.mask)}};z.DefaultUp=new q(0,1,0);z.DefaultMatrixAutoUpdate=!0;Object.assign(z.prototype,sa.prototype,{isObject3D:!0,applyMatrix:function(a){this.matrix.multiplyMatrices(a,this.matrix);this.matrix.decompose(this.position,this.quaternion,this.scale)},setRotationFromAxisAngle:function(a,b){this.quaternion.setFromAxisAngle(a,b)},setRotationFromEuler:function(a){this.quaternion.setFromEuler(a,!0)},setRotationFromMatrix:function(a){this.quaternion.setFromRotationMatrix(a)},
12146 setRotationFromQuaternion:function(a){this.quaternion.copy(a)},rotateOnAxis:function(){var a=new ba;return function(b,c){a.setFromAxisAngle(b,c);this.quaternion.multiply(a);return this}}(),rotateX:function(){var a=new q(1,0,0);return function(b){return this.rotateOnAxis(a,b)}}(),rotateY:function(){var a=new q(0,1,0);return function(b){return this.rotateOnAxis(a,b)}}(),rotateZ:function(){var a=new q(0,0,1);return function(b){return this.rotateOnAxis(a,b)}}(),translateOnAxis:function(){var a=new q;
12147 return function(b,c){a.copy(b).applyQuaternion(this.quaternion);this.position.add(a.multiplyScalar(c));return this}}(),translateX:function(){var a=new q(1,0,0);return function(b){return this.translateOnAxis(a,b)}}(),translateY:function(){var a=new q(0,1,0);return function(b){return this.translateOnAxis(a,b)}}(),translateZ:function(){var a=new q(0,0,1);return function(b){return this.translateOnAxis(a,b)}}(),localToWorld:function(a){return a.applyMatrix4(this.matrixWorld)},worldToLocal:function(){var a=
12148 new J;return function(b){return b.applyMatrix4(a.getInverse(this.matrixWorld))}}(),lookAt:function(){var a=new J;return function(b){a.lookAt(b,this.position,this.up);this.quaternion.setFromRotationMatrix(a)}}(),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"}),
12149 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]);b=this.children.indexOf(a);-1!==b&&(a.parent=null,a.dispatchEvent({type:"removed"}),this.children.splice(b,1))},getObjectById:function(a){return this.getObjectByProperty("id",a)},getObjectByName:function(a){return this.getObjectByProperty("name",a)},getObjectByProperty:function(a,b){if(this[a]===
12150 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){a=a||new q;this.updateMatrixWorld(!0);return a.setFromMatrixPosition(this.matrixWorld)},getWorldQuaternion:function(){var a=new q,b=new q;return function(c){c=c||new ba;this.updateMatrixWorld(!0);this.matrixWorld.decompose(a,c,b);return c}}(),getWorldRotation:function(){var a=new ba;return function(b){b=b||new bb;this.getWorldQuaternion(a);
12151 return b.setFromQuaternion(a,this.rotation.order,!1)}}(),getWorldScale:function(){var a=new q,b=new ba;return function(c){c=c||new q;this.updateMatrixWorld(!0);this.matrixWorld.decompose(a,b,c);return c}}(),getWorldDirection:function(){var a=new ba;return function(b){b=b||new q;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);
12152 for(var b=this.children,c=0,d=b.length;c<d;c++)b[c].traverseVisible(a)}},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){!0===this.matrixAutoUpdate&&this.updateMatrix();if(!0===this.matrixWorldNeedsUpdate||!0===a)null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,
12153 this.matrix),this.matrixWorldNeedsUpdate=!1,a=!0;for(var b=this.children,c=0,d=b.length;c<d;c++)b[c].updateMatrixWorld(a)},toJSON:function(a){function b(a){var b=[],c;for(c in a){var d=a[c];delete d.metadata;b.push(d)}return b}var c=void 0===a||""===a,d={};c&&(a={geometries:{},materials:{},textures:{},images:{}},d.metadata={version:4.4,type:"Object",generator:"Object3D.toJSON"});var e={};e.uuid=this.uuid;e.type=this.type;""!==this.name&&(e.name=this.name);"{}"!==JSON.stringify(this.userData)&&(e.userData=
12154 this.userData);!0===this.castShadow&&(e.castShadow=!0);!0===this.receiveShadow&&(e.receiveShadow=!0);!1===this.visible&&(e.visible=!1);e.matrix=this.matrix.toArray();void 0!==this.geometry&&(void 0===a.geometries[this.geometry.uuid]&&(a.geometries[this.geometry.uuid]=this.geometry.toJSON(a)),e.geometry=this.geometry.uuid);void 0!==this.material&&(void 0===a.materials[this.material.uuid]&&(a.materials[this.material.uuid]=this.material.toJSON(a)),e.material=this.material.uuid);if(0<this.children.length){e.children=
12155 [];for(var f=0;f<this.children.length;f++)e.children.push(this.children[f].toJSON(a).object)}if(c){var c=b(a.geometries),f=b(a.materials),g=b(a.textures);a=b(a.images);0<c.length&&(d.geometries=c);0<f.length&&(d.materials=f);0<g.length&&(d.textures=g);0<a.length&&(d.images=a)}d.object=e;return d},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);
12156 this.matrix.copy(a.matrix);this.matrixWorld.copy(a.matrixWorld);this.matrixAutoUpdate=a.matrixAutoUpdate;this.matrixWorldNeedsUpdate=a.matrixWorldNeedsUpdate;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(var c=0;c<a.children.length;c++)this.add(a.children[c].clone());return this}});var qe=0;gb.prototype={constructor:gb,set:function(a,
12157 b){this.start.copy(a);this.end.copy(b);return this},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.start.copy(a.start);this.end.copy(a.end);return this},getCenter:function(a){return(a||new q).addVectors(this.start,this.end).multiplyScalar(.5)},delta:function(a){return(a||new q).subVectors(this.end,this.start)},distanceSq:function(){return this.start.distanceToSquared(this.end)},distance:function(){return this.start.distanceTo(this.end)},at:function(a,b){var c=b||new q;
12158 return this.delta(c).multiplyScalar(a).add(this.start)},closestPointToPointParameter:function(){var a=new q,b=new q;return function(c,d){a.subVectors(c,this.start);b.subVectors(this.end,this.start);var e=b.dot(b),e=b.dot(a)/e;d&&(e=T.clamp(e,0,1));return e}}(),closestPointToPoint:function(a,b,c){a=this.closestPointToPointParameter(a,b);c=c||new q;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)&&
12159 a.end.equals(this.end)}};wa.normal=function(){var a=new q;return function(b,c,d,e){e=e||new q;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)}}();wa.barycoordFromPoint=function(){var a=new q,b=new q,c=new q;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;h=h||new q;if(0===m)return h.set(-2,-1,-1);m=1/m;k=(k*f-e*g)*m;d=(d*g-
12160 e*f)*m;return h.set(1-k-d,d,k)}}();wa.containsPoint=function(){var a=new q;return function(b,c,d,e){b=wa.barycoordFromPoint(b,c,d,e,a);return 0<=b.x&&0<=b.y&&1>=b.x+b.y}}();wa.prototype={constructor:wa,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);
12161 return this},area:function(){var a=new q,b=new q;return function(){a.subVectors(this.c,this.b);b.subVectors(this.a,this.b);return.5*a.cross(b).length()}}(),midpoint:function(a){return(a||new q).addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},normal:function(a){return wa.normal(this.a,this.b,this.c,a)},plane:function(a){return(a||new va).setFromCoplanarPoints(this.a,this.b,this.c)},barycoordFromPoint:function(a,b){return wa.barycoordFromPoint(a,this.a,this.b,this.c,b)},containsPoint:function(a){return wa.containsPoint(a,
12162 this.a,this.b,this.c)},closestPointToPoint:function(){var a,b,c,d;return function(e,f){void 0===a&&(a=new va,b=[new gb,new gb,new gb],c=new q,d=new q);var g=f||new q,h=Infinity;a.setFromCoplanarPoints(this.a,this.b,this.c);a.projectPoint(e,c);if(!0===this.containsPoint(c))g.copy(c);else{b[0].set(this.a,this.b);b[1].set(this.b,this.c);b[2].set(this.c,this.a);for(var k=0;k<b.length;k++){b[k].closestPointToPoint(c,!0,d);var m=c.distanceToSquared(d);m<h&&(h=m,g.copy(d))}}return g}}(),equals:function(a){return a.a.equals(this.a)&&
12163 a.b.equals(this.b)&&a.c.equals(this.c)}};ea.prototype={constructor:ea,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}};Ma.prototype=Object.create(U.prototype);Ma.prototype.constructor=
12164 Ma;Ma.prototype.isMeshBasicMaterial=!0;Ma.prototype.copy=function(a){U.prototype.copy.call(this,a);this.color.copy(a.color);this.map=a.map;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=
12165 a.wireframeLinejoin;this.skinning=a.skinning;this.morphTargets=a.morphTargets;return this};C.prototype={constructor:C,isBufferAttribute:!0,set needsUpdate(a){!0===a&&this.version++},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},setDynamic:function(a){this.dynamic=a;return this},copy:function(a){this.array=new a.array.constructor(a.array);this.itemSize=a.itemSize;this.count=
12166 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<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 O);b[c++]=f.r;b[c++]=f.g;b[c++]=f.b}return this},copyIndicesArray:function(a){for(var b=
12167 this.array,c=0,d=0,e=a.length;d<e;d++){var f=a[d];b[c++]=f.a;b[c++]=f.b;b[c++]=f.c}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",d),f=new B);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",
12168 d),f=new q);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 ga);b[c++]=f.x;b[c++]=f.y;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*
12169 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+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]=
12170 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},clone:function(){return(new this.constructor).copy(this)}};Object.assign(Q.prototype,sa.prototype,{isGeometry:!0,applyMatrix:function(a){for(var b=(new Ia).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<
12171 f;e++)a.vertexNormals[e].applyMatrix3(b).normalize()}null!==this.boundingBox&&this.computeBoundingBox();null!==this.boundingSphere&&this.computeBoundingSphere();this.normalsNeedUpdate=this.verticesNeedUpdate=!0;return this},rotateX:function(){var a;return function(b){void 0===a&&(a=new J);a.makeRotationX(b);this.applyMatrix(a);return this}}(),rotateY:function(){var a;return function(b){void 0===a&&(a=new J);a.makeRotationY(b);this.applyMatrix(a);return this}}(),rotateZ:function(){var a;return function(b){void 0===
12172 a&&(a=new J);a.makeRotationZ(b);this.applyMatrix(a);return this}}(),translate:function(){var a;return function(b,c,d){void 0===a&&(a=new J);a.makeTranslation(b,c,d);this.applyMatrix(a);return this}}(),scale:function(){var a;return function(b,c,d){void 0===a&&(a=new J);a.makeScale(b,c,d);this.applyMatrix(a);return this}}(),lookAt:function(){var a;return function(b){void 0===a&&(a=new z);a.lookAt(b);a.updateMatrix();this.applyMatrix(a.matrix)}}(),fromBufferGeometry:function(a){function b(a,b,d,e){var f=
12173 void 0!==g?[l[a].clone(),l[b].clone(),l[d].clone()]:[],r=void 0!==h?[c.colors[a].clone(),c.colors[b].clone(),c.colors[d].clone()]:[];e=new ea(a,b,d,f,r,e);c.faces.push(e);void 0!==k&&c.faceVertexUvs[0].push([n[a].clone(),n[b].clone(),n[d].clone()]);void 0!==m&&c.faceVertexUvs[1].push([p[a].clone(),p[b].clone(),p[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!==
12174 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=[],p=[],r=e=0;e<f.length;e+=3,r+=2)c.vertices.push(new q(f[e],f[e+1],f[e+2])),void 0!==g&&l.push(new q(g[e],g[e+1],g[e+2])),void 0!==h&&c.colors.push(new O(h[e],h[e+1],h[e+2])),void 0!==k&&n.push(new B(k[r],k[r+1])),void 0!==m&&p.push(new B(m[r],m[r+1]));if(void 0!==d)if(f=a.groups,0<f.length)for(e=0;e<f.length;e++)for(var x=f[e],t=x.start,D=x.count,r=t,t=t+D;r<t;r+=3)b(d[r],d[r+1],d[r+
12175 2],x.materialIndex);else 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&&(this.boundingSphere=a.boundingSphere.clone());return this},center:function(){this.computeBoundingBox();var a=this.boundingBox.getCenter().negate();this.translate(a.x,a.y,a.z);return a},normalize:function(){this.computeBoundingSphere();var a=this.boundingSphere.center,b=this.boundingSphere.radius,
12176 b=0===b?1:1/b,c=new J;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 q,b=new q,c=0,d=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,c,d;d=Array(this.vertices.length);b=0;for(c=this.vertices.length;b<c;b++)d[b]=new q;if(a){var e,
12177 f,g,h=new q,k=new q;a=0;for(b=this.faces.length;a<b;a++)c=this.faces[a],e=this.vertices[c.a],f=this.vertices[c.b],g=this.vertices[c.c],h.subVectors(g,f),k.subVectors(e,f),h.cross(k),d[c.a].add(h),d[c.b].add(h),d[c.c].add(h)}else for(this.computeFaceNormals(),a=0,b=this.faces.length;a<b;a++)c=this.faces[a],d[c.a].add(c.normal),d[c.b].add(c.normal),d[c.c].add(c.normal);b=0;for(c=this.vertices.length;b<c;b++)d[b].normalize();a=0;for(b=this.faces.length;a<b;a++)c=this.faces[a],e=c.vertexNormals,3===e.length?
12178 (e[0].copy(d[c.a]),e[1].copy(d[c.b]),e[2].copy(d[c.c])):(e[0]=d[c.a].clone(),e[1]=d[c.b].clone(),e[2]=d[c.c].clone());0<this.faces.length&&(this.normalsNeedUpdate=!0)},computeFlatVertexNormals:function(){var a,b,c;this.computeFaceNormals();a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];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=
12179 !0)},computeMorphNormals:function(){var a,b,c,d,e;c=0;for(d=this.faces.length;c<d;c++)for(e=this.faces[c],e.__originalFaceNormal?e.__originalFaceNormal.copy(e.normal):e.__originalFaceNormal=e.normal.clone(),e.__originalVertexNormals||(e.__originalVertexNormals=[]),a=0,b=e.vertexNormals.length;a<b;a++)e.__originalVertexNormals[a]?e.__originalVertexNormals[a].copy(e.vertexNormals[a]):e.__originalVertexNormals[a]=e.vertexNormals[a].clone();var f=new Q;f.faces=this.faces;a=0;for(b=this.morphTargets.length;a<
12180 b;a++){if(!this.morphNormals[a]){this.morphNormals[a]={};this.morphNormals[a].faceNormals=[];this.morphNormals[a].vertexNormals=[];e=this.morphNormals[a].faceNormals;var g=this.morphNormals[a].vertexNormals,h,k;c=0;for(d=this.faces.length;c<d;c++)h=new q,k={a:new q,b:new q,c:new q},e.push(h),g.push(k)}g=this.morphNormals[a];f.vertices=this.morphTargets[a].vertices;f.computeFaceNormals();f.computeVertexNormals();c=0;for(d=this.faces.length;c<d;c++)e=this.faces[c],h=g.faceNormals[c],k=g.vertexNormals[c],
12181 h.copy(e.normal),k.a.copy(e.vertexNormals[0]),k.b.copy(e.vertexNormals[1]),k.c.copy(e.vertexNormals[2])}c=0;for(d=this.faces.length;c<d;c++)e=this.faces[c],e.normal=e.__originalFaceNormal,e.vertexNormals=e.__originalVertexNormals},computeTangents:function(){console.warn("THREE.Geometry: .computeTangents() has been removed.")},computeLineDistances:function(){for(var a=0,b=this.vertices,c=0,d=b.length;c<d;c++)0<c&&(a+=b[c].distanceTo(b[c-1])),this.lineDistances[c]=a},computeBoundingBox:function(){null===
12182 this.boundingBox&&(this.boundingBox=new Ba);this.boundingBox.setFromPoints(this.vertices)},computeBoundingSphere:function(){null===this.boundingSphere&&(this.boundingSphere=new Ca);this.boundingSphere.setFromPoints(this.vertices)},merge:function(a,b,c){if(!1===(a&&a.isGeometry))console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",a);else{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],n=this.colors,
12183 p=a.colors;void 0===c&&(c=0);void 0!==b&&(d=(new Ia).getNormalMatrix(b));a=0;for(var r=g.length;a<r;a++){var q=g[a].clone();void 0!==b&&q.applyMatrix4(b);f.push(q)}a=0;for(r=p.length;a<r;a++)n.push(p[a].clone());a=0;for(r=k.length;a<r;a++){var g=k[a],t=g.vertexNormals,p=g.vertexColors,n=new ea(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=t.length;b<f;b++)q=t[b].clone(),void 0!==d&&q.applyMatrix3(d).normalize(),n.vertexNormals.push(q);n.color.copy(g.color);
12184 b=0;for(f=p.length;b<f;b++)q=p[b],n.vertexColors.push(q.clone());n.materialIndex=g.materialIndex+c;h.push(n)}a=0;for(r=l.length;a<r;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)}}},mergeMesh:function(a){!1===(a&&a.isMesh)?console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",a):(a.matrixAutoUpdate&&a.updateMatrix(),this.merge(a.geometry,a.matrix))},mergeVertices:function(){var a={},b=[],c=[],d,e=Math.pow(10,4),f,g;f=0;for(g=this.vertices.length;f<
12185 g;f++)d=this.vertices[f],d=Math.round(d.x*e)+"_"+Math.round(d.y*e)+"_"+Math.round(d.z*e),void 0===a[d]?(a[d]=f,b.push(this.vertices[f]),c[f]=b.length-1):c[f]=c[a[d]];a=[];f=0;for(g=this.faces.length;f<g;f++)for(e=this.faces[f],e.a=c[e.a],e.b=c[e.b],e.c=c[e.c],e=[e.a,e.b,e.c],d=0;3>d;d++)if(e[d]===e[(d+1)%3]){a.push(f);break}for(f=a.length-1;0<=f;f--)for(e=a[f],this.faces.splice(e,1),c=0,g=this.faceVertexUvs.length;c<g;c++)this.faceVertexUvs[c].splice(e,1);f=this.vertices.length-b.length;this.vertices=
12186 b;return f},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&&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()+
12187 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=a.x.toString()+a.y.toString();if(void 0!==r[b])return r[b];r[b]=p.length/2;p.push(a.x,a.y);return r[b]}var e={metadata:{version:4.4,type:"Geometry",generator:"Geometry.toJSON"}};e.uuid=this.uuid;e.type=this.type;""!==this.name&&(e.name=this.name);if(void 0!==
12188 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)}var h=[],k=[],m={},l=[],n={},p=[],r={};for(g=0;g<this.faces.length;g++){var q=this.faces[g],t=void 0!==this.faceVertexUvs[0][g],D=0<q.normal.length(),u=0<q.vertexNormals.length,v=1!==q.color.r||1!==q.color.g||1!==q.color.b,I=0<q.vertexColors.length,y=0,y=a(y,0,0),y=a(y,1,!0),y=a(y,2,!1),y=a(y,3,t),y=a(y,4,D),y=a(y,5,u),y=a(y,6,
12189 v),y=a(y,7,I);h.push(y);h.push(q.a,q.b,q.c);h.push(q.materialIndex);t&&(t=this.faceVertexUvs[0][g],h.push(d(t[0]),d(t[1]),d(t[2])));D&&h.push(b(q.normal));u&&(D=q.vertexNormals,h.push(b(D[0]),b(D[1]),b(D[2])));v&&h.push(c(q.color));I&&(q=q.vertexColors,h.push(c(q[0]),c(q[1]),c(q[2])))}e.data={};e.data.vertices=f;e.data.normals=k;0<l.length&&(e.data.colors=l);0<p.length&&(e.data.uvs=[p]);e.data.faces=h;return e},clone:function(){return(new Q).copy(this)},copy:function(a){this.vertices=[];this.faces=
12190 [];this.faceVertexUvs=[[]];this.colors=[];for(var b=a.vertices,c=0,d=b.length;c<d;c++)this.vertices.push(b[c].clone());b=a.colors;c=0;for(d=b.length;c<d;c++)this.colors.push(b[c].clone());b=a.faces;c=0;for(d=b.length;c<d;c++)this.faces.push(b[c].clone());c=0;for(d=a.faceVertexUvs.length;c<d;c++){b=a.faceVertexUvs[c];void 0===this.faceVertexUvs[c]&&(this.faceVertexUvs[c]=[]);for(var e=0,f=b.length;e<f;e++){for(var g=b[e],h=[],k=0,m=g.length;k<m;k++)h.push(g[k].clone());this.faceVertexUvs[c].push(h)}}return this},
12191 dispose:function(){this.dispatchEvent({type:"dispose"})}});var ad=0;Object.assign(re.prototype,sa.prototype,{computeBoundingBox:Q.prototype.computeBoundingBox,computeBoundingSphere:Q.prototype.computeBoundingSphere,computeFaceNormals:function(){console.warn("THREE.DirectGeometry: computeFaceNormals() is not a method of this type of geometry.")},computeVertexNormals:function(){console.warn("THREE.DirectGeometry: computeVertexNormals() is not a method of this type of geometry.")},computeGroups:function(a){var b,
12192 c=[],d;a=a.faces;for(var e=0;e<a.length;e++){var f=a[e];f.materialIndex!==d&&(d=f.materialIndex,void 0!==b&&(b.count=3*e-b.start,c.push(b)),b={start:3*e,materialIndex:d})}void 0!==b&&(b.count=3*e-b.start,c.push(b));this.groups=c},fromGeometry:function(a){var b=a.faces,c=a.vertices,d=a.faceVertexUvs,e=d[0]&&0<d[0].length,f=d[1]&&0<d[1].length,g=a.morphTargets,h=g.length,k;if(0<h){k=[];for(var m=0;m<h;m++)k[m]=[];this.morphTargets.position=k}var l=a.morphNormals,n=l.length,p;if(0<n){p=[];for(m=0;m<
12193 n;m++)p[m]=[];this.morphTargets.normal=p}for(var r=a.skinIndices,q=a.skinWeights,t=r.length===c.length,D=q.length===c.length,m=0;m<b.length;m++){var u=b[m];this.vertices.push(c[u.a],c[u.b],c[u.c]);var v=u.vertexNormals;3===v.length?this.normals.push(v[0],v[1],v[2]):(v=u.normal,this.normals.push(v,v,v));v=u.vertexColors;3===v.length?this.colors.push(v[0],v[1],v[2]):(v=u.color,this.colors.push(v,v,v));!0===e&&(v=d[0][m],void 0!==v?this.uvs.push(v[0],v[1],v[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",
12194 m),this.uvs.push(new B,new B,new B)));!0===f&&(v=d[1][m],void 0!==v?this.uvs2.push(v[0],v[1],v[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",m),this.uvs2.push(new B,new B,new B)));for(v=0;v<h;v++){var I=g[v].vertices;k[v].push(I[u.a],I[u.b],I[u.c])}for(v=0;v<n;v++)I=l[v].vertexNormals[m],p[v].push(I.a,I.b,I.c);t&&this.skinIndices.push(r[u.a],r[u.b],r[u.c]);D&&this.skinWeights.push(q[u.a],q[u.b],q[u.c])}this.computeGroups(a);this.verticesNeedUpdate=a.verticesNeedUpdate;
12195 this.normalsNeedUpdate=a.normalsNeedUpdate;this.colorsNeedUpdate=a.colorsNeedUpdate;this.uvsNeedUpdate=a.uvsNeedUpdate;this.groupsNeedUpdate=a.groupsNeedUpdate;return this},dispose:function(){this.dispatchEvent({type:"dispose"})}});Object.assign(G.prototype,sa.prototype,{isBufferGeometry:!0,getIndex:function(){return this.index},setIndex:function(a){this.index=a},addAttribute:function(a,b,c){if(!1===(b&&b.isBufferAttribute)&&!1===(b&&b.isInterleavedBufferAttribute))console.warn("THREE.BufferGeometry: .addAttribute() now expects ( name, attribute )."),
12196 this.addAttribute(a,new C(b,c));else if("index"===a)console.warn("THREE.BufferGeometry.addAttribute: Use .setIndex() for index attribute."),this.setIndex(b);else return this.attributes[a]=b,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=
12197 b},applyMatrix:function(a){var b=this.attributes.position;void 0!==b&&(a.applyToVector3Array(b.array),b.needsUpdate=!0);b=this.attributes.normal;void 0!==b&&((new Ia).getNormalMatrix(a).applyToVector3Array(b.array),b.needsUpdate=!0);null!==this.boundingBox&&this.computeBoundingBox();null!==this.boundingSphere&&this.computeBoundingSphere();return this},rotateX:function(){var a;return function(b){void 0===a&&(a=new J);a.makeRotationX(b);this.applyMatrix(a);return this}}(),rotateY:function(){var a;return function(b){void 0===
12198 a&&(a=new J);a.makeRotationY(b);this.applyMatrix(a);return this}}(),rotateZ:function(){var a;return function(b){void 0===a&&(a=new J);a.makeRotationZ(b);this.applyMatrix(a);return this}}(),translate:function(){var a;return function(b,c,d){void 0===a&&(a=new J);a.makeTranslation(b,c,d);this.applyMatrix(a);return this}}(),scale:function(){var a;return function(b,c,d){void 0===a&&(a=new J);a.makeScale(b,c,d);this.applyMatrix(a);return this}}(),lookAt:function(){var a;return function(b){void 0===a&&(a=
12199 new z);a.lookAt(b);a.updateMatrix();this.applyMatrix(a.matrix)}}(),center:function(){this.computeBoundingBox();var a=this.boundingBox.getCenter().negate();this.translate(a.x,a.y,a.z);return a},setFromObject:function(a){var b=a.geometry;if(a&&a.isPoints||a&&a.isLine){a=new ha(3*b.vertices.length,3);var c=new ha(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&&
12200 (a=new ha(b.lineDistances.length,1),this.addAttribute("lineDistance",a.copyArray(b.lineDistances)));null!==b.boundingSphere&&(this.boundingSphere=b.boundingSphere.clone());null!==b.boundingBox&&(this.boundingBox=b.boundingBox.clone())}else a&&a.isMesh&&b&&b.isGeometry&&this.fromGeometry(b);return this},updateFromObject:function(a){var b=a.geometry;if(a&&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=
12201 b.verticesNeedUpdate;c.normalsNeedUpdate=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),
12202 c.needsUpdate=!0),b.normalsNeedUpdate=!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=
12203 b.groups,b.groupsNeedUpdate=!1);return this},fromGeometry:function(a){a.__directGeometry=(new re).fromGeometry(a);return this.fromDirectGeometry(a.__directGeometry)},fromDirectGeometry:function(a){var b=new Float32Array(3*a.vertices.length);this.addAttribute("position",(new C(b,3)).copyVector3sArray(a.vertices));0<a.normals.length&&(b=new Float32Array(3*a.normals.length),this.addAttribute("normal",(new C(b,3)).copyVector3sArray(a.normals)));0<a.colors.length&&(b=new Float32Array(3*a.colors.length),
12204 this.addAttribute("color",(new C(b,3)).copyColorsArray(a.colors)));0<a.uvs.length&&(b=new Float32Array(2*a.uvs.length),this.addAttribute("uv",(new C(b,2)).copyVector2sArray(a.uvs)));0<a.uvs2.length&&(b=new Float32Array(2*a.uvs2.length),this.addAttribute("uv2",(new C(b,2)).copyVector2sArray(a.uvs2)));0<a.indices.length&&(b=new (65535<a.vertices.length?Uint32Array:Uint16Array)(3*a.indices.length),this.setIndex((new C(b,1)).copyIndicesArray(a.indices)));this.groups=a.groups;for(var c in a.morphTargets){for(var b=
12205 [],d=a.morphTargets[c],e=0,f=d.length;e<f;e++){var g=d[e],h=new ha(3*g.length,3);b.push(h.copyVector3sArray(g))}this.morphAttributes[c]=b}0<a.skinIndices.length&&(c=new ha(4*a.skinIndices.length,4),this.addAttribute("skinIndex",c.copyVector4sArray(a.skinIndices)));0<a.skinWeights.length&&(c=new ha(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=
12206 a.boundingBox.clone());return this},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new Ba);var a=this.attributes.position.array;void 0!==a?this.boundingBox.setFromArray(a):this.boundingBox.makeEmpty();(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=
12207 new Ba,b=new q;return function(){null===this.boundingSphere&&(this.boundingSphere=new Ca);var c=this.attributes.position;if(c){var c=c.array,d=this.boundingSphere.center;a.setFromArray(c);a.getCenter(d);for(var e=0,f=0,g=c.length;f<g;f+=3)b.fromArray(c,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.',
12208 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",new C(new Float32Array(d.length),3));else for(var e=b.normal.array,f=0,g=e.length;f<g;f++)e[f]=0;var e=b.normal.array,h,k,m,l=new q,n=new q,p=new q,r=new q,x=new q;if(a){a=a.array;0===c.length&&this.addGroup(0,a.length);for(var t=0,D=c.length;t<D;++t)for(f=c[t],g=f.start,h=f.count,f=g,g+=h;f<
12209 g;f+=3)h=3*a[f+0],k=3*a[f+1],m=3*a[f+2],l.fromArray(d,h),n.fromArray(d,k),p.fromArray(d,m),r.subVectors(p,n),x.subVectors(l,n),r.cross(x),e[h]+=r.x,e[h+1]+=r.y,e[h+2]+=r.z,e[k]+=r.x,e[k+1]+=r.y,e[k+2]+=r.z,e[m]+=r.x,e[m+1]+=r.y,e[m+2]+=r.z}else for(f=0,g=d.length;f<g;f+=9)l.fromArray(d,f),n.fromArray(d,f+3),p.fromArray(d,f+6),r.subVectors(p,n),x.subVectors(l,n),r.cross(x),e[f]=r.x,e[f+1]=r.y,e[f+2]=r.z,e[f+3]=r.x,e[f+4]=r.y,e[f+5]=r.z,e[f+6]=r.x,e[f+7]=r.y,e[f+8]=r.z;this.normalizeNormals();b.normal.needsUpdate=
12210 !0}},merge:function(a,b){if(!1===(a&&a.isBufferGeometry))console.error("THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.",a);else{void 0===b&&(b=0);var c=this.attributes,d;for(d in c)if(void 0!==a.attributes[d])for(var e=c[d].array,f=a.attributes[d],g=f.array,h=0,f=f.itemSize*b;h<g.length;h++,f++)e[f]=g[h];return this}},normalizeNormals:function(){for(var a=this.attributes.normal.array,b,c,d,e=0,f=a.length;e<f;e+=3)b=a[e],c=a[e+1],d=a[e+2],b=1/Math.sqrt(b*b+c*c+d*d),
12211 a[e]*=b,a[e+1]*=b,a[e+2]*=b},toNonIndexed:function(){if(null===this.index)return console.warn("THREE.BufferGeometry.toNonIndexed(): Geometry is already non-indexed."),this;var a=new G,b=this.index.array,c=this.attributes,d;for(d in c){for(var e=c[d],f=e.array,e=e.itemSize,g=new f.constructor(b.length*e),h,k=0,m=0,l=b.length;m<l;m++){h=b[m]*e;for(var n=0;n<e;n++)g[k++]=f[h++]}a.addAttribute(d,new C(g,e))}return a},toJSON:function(){var a={metadata:{version:4.4,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};
12212 a.uuid=this.uuid;a.type=this.type;""!==this.name&&(a.name=this.name);if(void 0!==this.parameters){var b=this.parameters,c;for(c in b)void 0!==b[c]&&(a[c]=b[c]);return a}a.data={attributes:{}};var d=this.index;null!==d&&(b=Array.prototype.slice.call(d.array),a.data.index={type:d.array.constructor.name,array:b});d=this.attributes;for(c in d){var e=d[c],b=Array.prototype.slice.call(e.array);a.data.attributes[c]={itemSize:e.itemSize,type:e.array.constructor.name,array:b,normalized:e.normalized}}c=this.groups;
12213 0<c.length&&(a.data.groups=JSON.parse(JSON.stringify(c)));c=this.boundingSphere;null!==c&&(a.data.boundingSphere={center:c.center.toArray(),radius:c.radius});return a},clone:function(){return(new G).copy(this)},copy:function(a){var b=a.index;null!==b&&this.setIndex(b.clone());var b=a.attributes,c;for(c in b)this.addAttribute(c,b[c].clone());a=a.groups;c=0;for(b=a.length;c<b;c++){var d=a[c];this.addGroup(d.start,d.count,d.materialIndex)}return this},dispose:function(){this.dispatchEvent({type:"dispose"})}});
12214 G.MaxIndex=65535;ya.prototype=Object.assign(Object.create(z.prototype),{constructor:ya,isMesh:!0,setDrawMode:function(a){this.drawMode=a},copy:function(a){z.prototype.copy.call(this,a);this.drawMode=a.drawMode;return this},updateMorphTargets:function(){var a=this.geometry.morphTargets;if(void 0!==a&&0<a.length){this.morphTargetInfluences=[];this.morphTargetDictionary={};for(var b=0,c=a.length;b<c;b++)this.morphTargetInfluences.push(0),this.morphTargetDictionary[a[b].name]=b}},raycast:function(){function a(a,
12215 b,c,d,e,f,g){wa.barycoordFromPoint(a,b,c,d,t);e.multiplyScalar(t.x);f.multiplyScalar(t.y);g.multiplyScalar(t.z);e.add(f).add(g);return e.clone()}function b(a,b,c,d,e,f,g){var h=a.material;if(null===(1===h.side?c.intersectTriangle(f,e,d,!0,g):c.intersectTriangle(d,e,f,2!==h.side,g)))return null;u.copy(g);u.applyMatrix4(a.matrixWorld);c=b.ray.origin.distanceTo(u);return c<b.near||c>b.far?null:{distance:c,point:u.clone(),object:a}}function c(c,d,e,f,m,l,n,w){g.fromArray(f,3*l);h.fromArray(f,3*n);k.fromArray(f,
12216 3*w);if(c=b(c,d,e,g,h,k,D))m&&(p.fromArray(m,2*l),r.fromArray(m,2*n),x.fromArray(m,2*w),c.uv=a(D,g,h,k,p,r,x)),c.face=new ea(l,n,w,wa.normal(g,h,k)),c.faceIndex=l;return c}var d=new J,e=new ab,f=new Ca,g=new q,h=new q,k=new q,m=new q,l=new q,n=new q,p=new B,r=new B,x=new B,t=new q,D=new q,u=new q;return function(q,t){var u=this.geometry,E=this.material,H=this.matrixWorld;if(void 0!==E&&(null===u.boundingSphere&&u.computeBoundingSphere(),f.copy(u.boundingSphere),f.applyMatrix4(H),!1!==q.ray.intersectsSphere(f)&&
12217 (d.getInverse(H),e.copy(q.ray).applyMatrix4(d),null===u.boundingBox||!1!==e.intersectsBox(u.boundingBox)))){var F,M;if(u&&u.isBufferGeometry){var B,K,E=u.index,H=u.attributes,u=H.position.array;void 0!==H.uv&&(F=H.uv.array);if(null!==E)for(var H=E.array,z=0,C=H.length;z<C;z+=3){if(E=H[z],B=H[z+1],K=H[z+2],M=c(this,q,e,u,F,E,B,K))M.faceIndex=Math.floor(z/3),t.push(M)}else for(z=0,C=u.length;z<C;z+=9)if(E=z/3,B=E+1,K=E+2,M=c(this,q,e,u,F,E,B,K))M.index=E,t.push(M)}else if(u&&u.isGeometry){var G,J,H=
12218 E&&E.isMultiMaterial,z=!0===H?E.materials:null,C=u.vertices;B=u.faces;K=u.faceVertexUvs[0];0<K.length&&(F=K);for(var N=0,P=B.length;N<P;N++){var R=B[N];M=!0===H?z[R.materialIndex]:E;if(void 0!==M){K=C[R.a];G=C[R.b];J=C[R.c];if(!0===M.morphTargets){M=u.morphTargets;var S=this.morphTargetInfluences;g.set(0,0,0);h.set(0,0,0);k.set(0,0,0);for(var Q=0,V=M.length;Q<V;Q++){var O=S[Q];if(0!==O){var L=M[Q].vertices;g.addScaledVector(m.subVectors(L[R.a],K),O);h.addScaledVector(l.subVectors(L[R.b],G),O);k.addScaledVector(n.subVectors(L[R.c],
12219 J),O)}}g.add(K);h.add(G);k.add(J);K=g;G=h;J=k}if(M=b(this,q,e,K,G,J,D))F&&(S=F[N],p.copy(S[0]),r.copy(S[1]),x.copy(S[2]),M.uv=a(D,K,G,J,p,r,x)),M.face=R,M.faceIndex=N,t.push(M)}}}}}}(),clone:function(){return(new this.constructor(this.geometry,this.material)).copy(this)}});hb.prototype=Object.create(G.prototype);hb.prototype.constructor=hb;ib.prototype=Object.create(G.prototype);ib.prototype.constructor=ib;Z.prototype=Object.create(z.prototype);Z.prototype.constructor=Z;Z.prototype.isCamera=!0;Z.prototype.getWorldDirection=
12220 function(){var a=new ba;return function(b){b=b||new q;this.getWorldQuaternion(a);return b.set(0,0,-1).applyQuaternion(a)}}();Z.prototype.lookAt=function(){var a=new J;return function(b){a.lookAt(this.position,b,this.up);this.quaternion.setFromRotationMatrix(a)}}();Z.prototype.clone=function(){return(new this.constructor).copy(this)};Z.prototype.copy=function(a){z.prototype.copy.call(this,a);this.matrixWorldInverse.copy(a.matrixWorldInverse);this.projectionMatrix.copy(a.projectionMatrix);return this};
12221 Ea.prototype=Object.assign(Object.create(Z.prototype),{constructor:Ea,isPerspectiveCamera:!0,copy:function(a){Z.prototype.copy.call(this,a);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()/a;this.fov=2*T.RAD2DEG*Math.atan(a);this.updateProjectionMatrix()},getFocalLength:function(){var a=
12222 Math.tan(.5*T.DEG2RAD*this.fov);return.5*this.getFilmHeight()/a},getEffectiveFOV:function(){return 2*T.RAD2DEG*Math.atan(Math.tan(.5*T.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;this.view={fullWidth:a,fullHeight:b,offsetX:c,offsetY:d,width:e,height:f};this.updateProjectionMatrix()},clearViewOffset:function(){this.view=
12223 null;this.updateProjectionMatrix()},updateProjectionMatrix:function(){var a=this.near,b=a*Math.tan(.5*T.DEG2RAD*this.fov)/this.zoom,c=2*b,d=this.aspect*c,e=-.5*d,f=this.view;if(null!==f)var g=f.fullWidth,h=f.fullHeight,e=e+f.offsetX*d/g,b=b-f.offsetY*c/h,d=f.width/g*d,c=f.height/h*c;f=this.filmOffset;0!==f&&(e+=a*f/this.getFilmWidth());this.projectionMatrix.makeFrustum(e,e+d,b-c,b,a,this.far)},toJSON:function(a){a=z.prototype.toJSON.call(this,a);a.object.fov=this.fov;a.object.zoom=this.zoom;a.object.near=
12224 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=this.filmOffset;return a}});Hb.prototype=Object.assign(Object.create(Z.prototype),{constructor:Hb,isOrthographicCamera:!0,copy:function(a){Z.prototype.copy.call(this,a);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=
12225 null===a.view?null:Object.assign({},a.view);return this},setViewOffset:function(a,b,c,d,e,f){this.view={fullWidth:a,fullHeight:b,offsetX:c,offsetY:d,width:e,height:f};this.updateProjectionMatrix()},clearViewOffset:function(){this.view=null;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=c+a,a=d+b,b=d-b;if(null!==this.view)var c=this.zoom/
12226 (this.view.width/this.view.fullWidth),b=this.zoom/(this.view.height/this.view.fullHeight),f=(this.right-this.left)/this.view.width,d=(this.top-this.bottom)/this.view.height,e=e+this.view.offsetX/c*f,c=e+this.view.width/c*f,a=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=z.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=
12227 this.bottom;a.object.near=this.near;a.object.far=this.far;null!==this.view&&(a.object.view=Object.assign({},this.view));return a}});var sf=0;Ib.prototype.isFogExp2=!0;Ib.prototype.clone=function(){return new Ib(this.color.getHex(),this.density)};Ib.prototype.toJSON=function(a){return{type:"FogExp2",color:this.color.getHex(),density:this.density}};Jb.prototype.isFog=!0;Jb.prototype.clone=function(){return new Jb(this.color.getHex(),this.near,this.far)};Jb.prototype.toJSON=function(a){return{type:"Fog",
12228 color:this.color.getHex(),near:this.near,far:this.far}};jb.prototype=Object.create(z.prototype);jb.prototype.constructor=jb;jb.prototype.copy=function(a,b){z.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};jb.prototype.toJSON=function(a){var b=z.prototype.toJSON.call(this,
12229 a);null!==this.background&&(b.object.background=this.background.toJSON(a));null!==this.fog&&(b.object.fog=this.fog.toJSON());return b};Ed.prototype=Object.assign(Object.create(z.prototype),{constructor:Ed,isLensFlare:!0,copy:function(a){z.prototype.copy.call(this,a);this.positionScreen.copy(a.positionScreen);this.customUpdateCallback=a.customUpdateCallback;for(var b=0,c=a.lensFlares.length;b<c;b++)this.lensFlares.push(a.lensFlares[b]);return this},add:function(a,b,c,d,e,f){void 0===b&&(b=-1);void 0===
12230 c&&(c=0);void 0===f&&(f=1);void 0===e&&(e=new O(16777215));void 0===d&&(d=1);c=Math.min(c,Math.max(0,c));this.lensFlares.push({texture:a,size:b,distance:c,x:0,y:0,z:0,scale:1,rotation:0,opacity:f,color:e,blending:d})},updateLensFlares:function(){var a,b=this.lensFlares.length,c,d=2*-this.positionScreen.x,e=2*-this.positionScreen.y;for(a=0;a<b;a++)c=this.lensFlares[a],c.x=this.positionScreen.x+d*c.distance,c.y=this.positionScreen.y+e*c.distance,c.wantedRotation=c.x*Math.PI*.25,c.rotation+=.25*(c.wantedRotation-
12231 c.rotation)}});kb.prototype=Object.create(U.prototype);kb.prototype.constructor=kb;kb.prototype.copy=function(a){U.prototype.copy.call(this,a);this.color.copy(a.color);this.map=a.map;this.rotation=a.rotation;return this};qc.prototype=Object.assign(Object.create(z.prototype),{constructor:qc,isSprite:!0,raycast:function(){var a=new q;return function(b,c){a.setFromMatrixPosition(this.matrixWorld);var d=b.ray.distanceSqToPoint(a);d>this.scale.x*this.scale.y/4||c.push({distance:Math.sqrt(d),point:this.position,
12232 face:null,object:this})}}(),clone:function(){return(new this.constructor(this.material)).copy(this)}});rc.prototype=Object.assign(Object.create(z.prototype),{constructor:rc,copy:function(a){z.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=
12233 this.levels,c=1,d=b.length;c<d&&!(a<b[c].distance);c++);return b[c-1].object},raycast:function(){var a=new q;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 q,b=new q;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-
12234 1].object.visible=!1,d[e].object.visible=!0;else break;for(;e<f;e++)d[e].object.visible=!1}}}(),toJSON:function(a){a=z.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}});lb.prototype=Object.create(da.prototype);lb.prototype.constructor=lb;lb.prototype.isDataTexture=!0;Object.assign(bd.prototype,{calculateInverses:function(){this.boneInverses=[];for(var a=0,b=this.bones.length;a<
12235 b;a++){var c=new J;this.bones[a]&&c.getInverse(this.bones[a].matrixWorld);this.boneInverses.push(c)}},pose:function(){for(var a,b=0,c=this.bones.length;b<c;b++)(a=this.bones[b])&&a.matrixWorld.getInverse(this.boneInverses[b]);b=0;for(c=this.bones.length;b<c;b++)if(a=this.bones[b])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 J;return function(){for(var b=
12236 0,c=this.bones.length;b<c;b++)a.multiplyMatrices(this.bones[b]?this.bones[b].matrixWorld:this.identityMatrix,this.boneInverses[b]),a.toArray(this.boneMatrices,16*b);this.useVertexTexture&&(this.boneTexture.needsUpdate=!0)}}(),clone:function(){return new bd(this.bones,this.boneInverses,this.useVertexTexture)}});cd.prototype=Object.assign(Object.create(z.prototype),{constructor:cd,isBone:!0,copy:function(a){z.prototype.copy.call(this,a);this.skin=a.skin;return this}});dd.prototype=Object.assign(Object.create(ya.prototype),
12237 {constructor:dd,isSkinnedMesh:!0,bind:function(a,b){this.skeleton=a;void 0===b&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),b=this.matrixWorld);this.bindMatrix.copy(b);this.bindMatrixInverse.getInverse(b)},pose:function(){this.skeleton.pose()},normalizeSkinWeights:function(){if(this.geometry&&this.geometry.isGeometry)for(var a=0;a<this.geometry.skinWeights.length;a++){var b=this.geometry.skinWeights[a],c=1/b.lengthManhattan();Infinity!==c?b.multiplyScalar(c):b.set(1,0,0,0)}else if(this.geometry&&
12238 this.geometry.isBufferGeometry)for(var b=new ga,d=this.geometry.attributes.skinWeight,a=0;a<d.count;a++)b.x=d.getX(a),b.y=d.getY(a),b.z=d.getZ(a),b.w=d.getW(a),c=1/b.lengthManhattan(),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){ya.prototype.updateMatrixWorld.call(this,!0);"attached"===this.bindMode?this.bindMatrixInverse.getInverse(this.matrixWorld):"detached"===this.bindMode?this.bindMatrixInverse.getInverse(this.bindMatrix):console.warn("THREE.SkinnedMesh unrecognized bindMode: "+
12239 this.bindMode)},clone:function(){return(new this.constructor(this.geometry,this.material,this.skeleton.useVertexTexture)).copy(this)}});oa.prototype=Object.create(U.prototype);oa.prototype.constructor=oa;oa.prototype.isLineBasicMaterial=!0;oa.prototype.copy=function(a){U.prototype.copy.call(this,a);this.color.copy(a.color);this.linewidth=a.linewidth;this.linecap=a.linecap;this.linejoin=a.linejoin;return this};Ta.prototype=Object.assign(Object.create(z.prototype),{constructor:Ta,isLine:!0,raycast:function(){var a=
12240 new J,b=new ab,c=new Ca;return function(d,e){var f=d.linePrecision,f=f*f,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 q,m=new q,h=new q,l=new q,n=this&&this.isLineSegments?2:1;if(g&&g.isBufferGeometry){var p=g.index,r=g.attributes.position.array;if(null!==p)for(var p=p.array,g=0,x=p.length-1;g<x;g+=n){var t=p[g+1];k.fromArray(r,
12241 3*p[g]);m.fromArray(r,3*t);t=b.distanceSqToSegment(k,m,l,h);t>f||(l.applyMatrix4(this.matrixWorld),t=d.ray.origin.distanceTo(l),t<d.near||t>d.far||e.push({distance:t,point:h.clone().applyMatrix4(this.matrixWorld),index:g,face:null,faceIndex:null,object:this}))}else for(g=0,x=r.length/3-1;g<x;g+=n)k.fromArray(r,3*g),m.fromArray(r,3*g+3),t=b.distanceSqToSegment(k,m,l,h),t>f||(l.applyMatrix4(this.matrixWorld),t=d.ray.origin.distanceTo(l),t<d.near||t>d.far||e.push({distance:t,point:h.clone().applyMatrix4(this.matrixWorld),
12242 index:g,face:null,faceIndex:null,object:this}))}else if(g&&g.isGeometry)for(k=g.vertices,m=k.length,g=0;g<m-1;g+=n)t=b.distanceSqToSegment(k[g],k[g+1],l,h),t>f||(l.applyMatrix4(this.matrixWorld),t=d.ray.origin.distanceTo(l),t<d.near||t>d.far||e.push({distance:t,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)}});la.prototype=Object.assign(Object.create(Ta.prototype),
12243 {constructor:la,isLineSegments:!0});xa.prototype=Object.create(U.prototype);xa.prototype.constructor=xa;xa.prototype.isPointsMaterial=!0;xa.prototype.copy=function(a){U.prototype.copy.call(this,a);this.color.copy(a.color);this.map=a.map;this.size=a.size;this.sizeAttenuation=a.sizeAttenuation;return this};Kb.prototype=Object.assign(Object.create(z.prototype),{constructor:Kb,isPoints:!0,raycast:function(){var a=new J,b=new ab,c=new Ca;return function(d,e){function f(a,c){var f=b.distanceSqToPoint(a);
12244 if(f<l){var h=b.closestPointToPoint(a);h.applyMatrix4(k);var m=d.ray.origin.distanceTo(h);m<d.near||m>d.far||e.push({distance:m,distanceToRay:Math.sqrt(f),point:h.clone(),index:c,face:null,object:g})}}var g=this,h=this.geometry,k=this.matrixWorld,m=d.params.Points.threshold;null===h.boundingSphere&&h.computeBoundingSphere();c.copy(h.boundingSphere);c.applyMatrix4(k);if(!1!==d.ray.intersectsSphere(c)){a.getInverse(k);b.copy(d.ray).applyMatrix4(a);var m=m/((this.scale.x+this.scale.y+this.scale.z)/3),
12245 l=m*m,m=new q;if(h&&h.isBufferGeometry){var n=h.index,h=h.attributes.position.array;if(null!==n)for(var p=n.array,n=0,r=p.length;n<r;n++){var x=p[n];m.fromArray(h,3*x);f(m,x)}else for(n=0,p=h.length/3;n<p;n++)m.fromArray(h,3*n),f(m,n)}else for(m=h.vertices,n=0,p=m.length;n<p;n++)f(m[n],n)}}}(),clone:function(){return(new this.constructor(this.geometry,this.material)).copy(this)}});sc.prototype=Object.assign(Object.create(z.prototype),{constructor:sc});ed.prototype=Object.create(da.prototype);ed.prototype.constructor=
12246 ed;Lb.prototype=Object.create(da.prototype);Lb.prototype.constructor=Lb;Lb.prototype.isCompressedTexture=!0;fd.prototype=Object.create(da.prototype);fd.prototype.constructor=fd;tc.prototype=Object.create(da.prototype);tc.prototype.constructor=tc;tc.prototype.isDepthTexture=!0;Mb.prototype=Object.create(G.prototype);Mb.prototype.constructor=Mb;Nb.prototype=Object.create(G.prototype);Nb.prototype.constructor=Nb;uc.prototype=Object.create(Q.prototype);uc.prototype.constructor=uc;ua.prototype=Object.create(G.prototype);
12247 ua.prototype.constructor=ua;Ob.prototype=Object.create(ua.prototype);Ob.prototype.constructor=Ob;vc.prototype=Object.create(Q.prototype);vc.prototype.constructor=vc;Pb.prototype=Object.create(ua.prototype);Pb.prototype.constructor=Pb;wc.prototype=Object.create(Q.prototype);wc.prototype.constructor=wc;Qb.prototype=Object.create(ua.prototype);Qb.prototype.constructor=Qb;xc.prototype=Object.create(Q.prototype);xc.prototype.constructor=xc;Rb.prototype=Object.create(ua.prototype);Rb.prototype.constructor=
12248 Rb;yc.prototype=Object.create(Q.prototype);yc.prototype.constructor=yc;zc.prototype=Object.create(Q.prototype);zc.prototype.constructor=zc;Sb.prototype=Object.create(G.prototype);Sb.prototype.constructor=Sb;Ac.prototype=Object.create(Q.prototype);Ac.prototype.constructor=Ac;Tb.prototype=Object.create(G.prototype);Tb.prototype.constructor=Tb;Bc.prototype=Object.create(Q.prototype);Bc.prototype.constructor=Bc;Ub.prototype=Object.create(G.prototype);Ub.prototype.constructor=Ub;Cc.prototype=Object.create(Q.prototype);
12249 Cc.prototype.constructor=Cc;var ra={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-a[e].x*a[d].y;return.5*c},triangulate:function(){return function(a,b){var c=a.length;if(3>c)return null;var d=[],e=[],f=[],g,h,k;if(0<ra.area(a))for(h=0;h<c;h++)e[h]=h;else for(h=0;h<c;h++)e[h]=c-1-h;var m=2*c;for(h=c-1;2<c;){if(0>=m--){console.warn("THREE.ShapeUtils: Unable to triangulate polygon! in triangulate()");break}g=h;c<=g&&(g=0);h=g+1;c<=h&&(h=0);k=h+1;c<=k&&(k=0);var l;a:{var n,
12250 p,r,q,t,D,u,v;n=a[e[g]].x;p=a[e[g]].y;r=a[e[h]].x;q=a[e[h]].y;t=a[e[k]].x;D=a[e[k]].y;if(0>=(r-n)*(D-p)-(q-p)*(t-n))l=!1;else{var I,y,E,H,F,M,B,z,C,G;I=t-r;y=D-q;E=n-t;H=p-D;F=r-n;M=q-p;for(l=0;l<c;l++)if(u=a[e[l]].x,v=a[e[l]].y,!(u===n&&v===p||u===r&&v===q||u===t&&v===D)&&(B=u-n,z=v-p,C=u-r,G=v-q,u-=t,v-=D,C=I*G-y*C,B=F*z-M*B,z=E*v-H*u,C>=-Number.EPSILON&&z>=-Number.EPSILON&&B>=-Number.EPSILON)){l=!1;break a}l=!0}}if(l){d.push([a[e[g]],a[e[h]],a[e[k]]]);f.push([e[g],e[h],e[k]]);g=h;for(k=h+1;k<c;g++,
12251 k++)e[g]=e[k];c--;m=2*c}}return b?f:d}}(),triangulateShape:function(a,b){function c(a){var b=a.length;2<b&&a[b-1].equals(a[0])&&a.pop()}function d(a,b,c){return a.x!==b.x?a.x<b.x?a.x<=c.x&&c.x<=b.x:b.x<=c.x&&c.x<=a.x:a.y<b.y?a.y<=c.y&&c.y<=b.y:b.y<=c.y&&c.y<=a.y}function e(a,b,c,e,f){var g=b.x-a.x,h=b.y-a.y,k=e.x-c.x,m=e.y-c.y,l=a.x-c.x,n=a.y-c.y,p=h*k-g*m,q=h*l-g*n;if(Math.abs(p)>Number.EPSILON){if(0<p){if(0>q||q>p)return[];k=m*l-k*n;if(0>k||k>p)return[]}else{if(0<q||q<p)return[];k=m*l-k*n;if(0<
12252 k||k<p)return[]}if(0===k)return!f||0!==q&&q!==p?[a]:[];if(k===p)return!f||0!==q&&q!==p?[b]:[];if(0===q)return[c];if(q===p)return[e];f=k/p;return[{x:a.x+f*g,y:a.y+f*h}]}if(0!==q||m*l!==k*n)return[];h=0===g&&0===h;k=0===k&&0===m;if(h&&k)return a.x!==c.x||a.y!==c.y?[]:[a];if(h)return d(c,e,a)?[a]:[];if(k)return d(a,b,c)?[c]:[];0!==g?(a.x<b.x?(g=a,k=a.x,h=b,a=b.x):(g=b,k=b.x,h=a,a=a.x),c.x<e.x?(b=c,p=c.x,m=e,c=e.x):(b=e,p=e.x,m=c,c=c.x)):(a.y<b.y?(g=a,k=a.y,h=b,a=b.y):(g=b,k=b.y,h=a,a=a.y),c.y<e.y?(b=
12253 c,p=c.y,m=e,c=e.y):(b=e,p=e.y,m=c,c=c.y));return k<=p?a<p?[]:a===p?f?[]:[b]:a<=c?[b,h]:[b,m]:k>c?[]:k===c?f?[]:[g]:a<=c?[g,h]:[g,m]}function f(a,b,c,d){var e=b.x-a.x,f=b.y-a.y;b=c.x-a.x;c=c.y-a.y;var g=d.x-a.x;d=d.y-a.y;a=e*c-f*b;e=e*d-f*g;return Math.abs(a)>Number.EPSILON?(b=g*c-d*b,0<a?0<=e&&0<=b:0<=e||0<=b):0<e}c(a);b.forEach(c);var g,h,k,m,l,n={};k=a.concat();g=0;for(h=b.length;g<h;g++)Array.prototype.push.apply(k,b[g]);g=0;for(h=k.length;g<h;g++)l=k[g].x+":"+k[g].y,void 0!==n[l]&&console.warn("THREE.ShapeUtils: Duplicate point",
12254 l,g),n[l]=g;g=function(a,b){function c(a,b){var d=h.length-1,e=a-1;0>e&&(e=d);var g=a+1;g>d&&(g=0);d=f(h[a],h[e],h[g],k[b]);if(!d)return!1;d=k.length-1;e=b-1;0>e&&(e=d);g=b+1;g>d&&(g=0);return(d=f(k[b],k[e],k[g],h[a]))?!0:!1}function d(a,b){var c,f;for(c=0;c<h.length;c++)if(f=c+1,f%=h.length,f=e(a,b,h[c],h[f],!0),0<f.length)return!0;return!1}function g(a,c){var d,f,h,k;for(d=0;d<m.length;d++)for(f=b[m[d]],h=0;h<f.length;h++)if(k=h+1,k%=f.length,k=e(a,c,f[h],f[k],!0),0<k.length)return!0;return!1}var h=
12255 a.concat(),k,m=[],l,n,p,q,w,B=[],z,C,G,J=0;for(l=b.length;J<l;J++)m.push(J);z=0;for(var N=2*m.length;0<m.length;){N--;if(0>N){console.log("Infinite Loop! Holes left:"+m.length+", Probably Hole outside Shape!");break}for(n=z;n<h.length;n++){p=h[n];l=-1;for(J=0;J<m.length;J++)if(q=m[J],w=p.x+":"+p.y+":"+q,void 0===B[w]){k=b[q];for(C=0;C<k.length;C++)if(q=k[C],c(n,C)&&!d(p,q)&&!g(p,q)){l=C;m.splice(J,1);z=h.slice(0,n+1);q=h.slice(n);C=k.slice(l);G=k.slice(0,l+1);h=z.concat(C).concat(G).concat(q);z=n;
12256 break}if(0<=l)break;B[w]=!0}if(0<=l)break}}return h}(a,b);var p=ra.triangulate(g,!1);g=0;for(h=p.length;g<h;g++)for(m=p[g],k=0;3>k;k++)l=m[k].x+":"+m[k].y,l=n[l],void 0!==l&&(m[k]=l);return p.concat()},isClockWise:function(a){return 0>ra.area(a)},b2:function(){return function(a,b,c,d){var e=1-a;return e*e*b+2*(1-a)*a*c+a*a*d}}(),b3:function(){return function(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}}()};za.prototype=Object.create(Q.prototype);za.prototype.constructor=
12257 za;za.prototype.addShapeList=function(a,b){for(var c=a.length,d=0;d<c;d++)this.addShape(a[d],b)};za.prototype.addShape=function(a,b){function c(a,b,c){b||console.error("THREE.ExtrudeGeometry: vec does not exist");return b.clone().multiplyScalar(c).add(a)}function d(a,b,c){var d,e,f;e=a.x-b.x;f=a.y-b.y;d=c.x-a.x;var g=c.y-a.y,h=e*e+f*f;if(Math.abs(e*g-f*d)>Number.EPSILON){var k=Math.sqrt(h),m=Math.sqrt(d*d+g*g),h=b.x-f/k;b=b.y+e/k;g=((c.x-g/m-h)*g-(c.y+d/m-b)*d)/(e*g-f*d);d=h+e*g-a.x;e=b+f*g-a.y;f=
12258 d*d+e*e;if(2>=f)return new B(d,e);f=Math.sqrt(f/2)}else a=!1,e>Number.EPSILON?d>Number.EPSILON&&(a=!0):e<-Number.EPSILON?d<-Number.EPSILON&&(a=!0):Math.sign(f)===Math.sign(g)&&(a=!0),a?(d=-f,f=Math.sqrt(h)):(d=e,e=f,f=Math.sqrt(h/2));return new B(d/f,e/f)}function e(a,b){var c,d;for(L=a.length;0<=--L;){c=L;d=L-1;0>d&&(d=a.length-1);var e,f=r+2*l;for(e=0;e<f;e++){var g=T*e,h=T*(e+1),k=b+c+g,g=b+d+g,m=b+d+h,h=b+c+h,k=k+K,g=g+K,m=m+K,h=h+K;C.faces.push(new ea(k,g,h,null,null,1));C.faces.push(new ea(g,
12259 m,h,null,null,1));k=u.generateSideWallUV(C,k,g,m,h);C.faceVertexUvs[0].push([k[0],k[1],k[3]]);C.faceVertexUvs[0].push([k[1],k[2],k[3]])}}}function f(a,b,c){C.vertices.push(new q(a,b,c))}function g(a,b,c){a+=K;b+=K;c+=K;C.faces.push(new ea(a,b,c,null,null,0));a=u.generateTopUV(C,a,b,c);C.faceVertexUvs[0].push(a)}var h=void 0!==b.amount?b.amount:100,k=void 0!==b.bevelThickness?b.bevelThickness:6,m=void 0!==b.bevelSize?b.bevelSize:k-2,l=void 0!==b.bevelSegments?b.bevelSegments:3,n=void 0!==b.bevelEnabled?
12260 b.bevelEnabled:!0,p=void 0!==b.curveSegments?b.curveSegments:12,r=void 0!==b.steps?b.steps:1,x=b.extrudePath,t,D=!1,u=void 0!==b.UVGenerator?b.UVGenerator:za.WorldUVGenerator,v,I,y,E;x&&(t=x.getSpacedPoints(r),D=!0,n=!1,v=void 0!==b.frames?b.frames:x.computeFrenetFrames(r,!1),I=new q,y=new q,E=new q);n||(m=k=l=0);var H,F,z,C=this,K=this.vertices.length,x=a.extractPoints(p),p=x.shape,G=x.holes;if(x=!ra.isClockWise(p)){p=p.reverse();F=0;for(z=G.length;F<z;F++)H=G[F],ra.isClockWise(H)&&(G[F]=H.reverse());
12261 x=!1}var J=ra.triangulateShape(p,G),Q=p;F=0;for(z=G.length;F<z;F++)H=G[F],p=p.concat(H);var O,N,P,R,S,T=p.length,V,U=J.length,x=[],L=0;P=Q.length;O=P-1;for(N=L+1;L<P;L++,O++,N++)O===P&&(O=0),N===P&&(N=0),x[L]=d(Q[L],Q[O],Q[N]);var W=[],X,Z=x.concat();F=0;for(z=G.length;F<z;F++){H=G[F];X=[];L=0;P=H.length;O=P-1;for(N=L+1;L<P;L++,O++,N++)O===P&&(O=0),N===P&&(N=0),X[L]=d(H[L],H[O],H[N]);W.push(X);Z=Z.concat(X)}for(O=0;O<l;O++){P=O/l;R=k*Math.cos(P*Math.PI/2);N=m*Math.sin(P*Math.PI/2);L=0;for(P=Q.length;L<
12262 P;L++)S=c(Q[L],x[L],N),f(S.x,S.y,-R);F=0;for(z=G.length;F<z;F++)for(H=G[F],X=W[F],L=0,P=H.length;L<P;L++)S=c(H[L],X[L],N),f(S.x,S.y,-R)}N=m;for(L=0;L<T;L++)S=n?c(p[L],Z[L],N):p[L],D?(y.copy(v.normals[0]).multiplyScalar(S.x),I.copy(v.binormals[0]).multiplyScalar(S.y),E.copy(t[0]).add(y).add(I),f(E.x,E.y,E.z)):f(S.x,S.y,0);for(P=1;P<=r;P++)for(L=0;L<T;L++)S=n?c(p[L],Z[L],N):p[L],D?(y.copy(v.normals[P]).multiplyScalar(S.x),I.copy(v.binormals[P]).multiplyScalar(S.y),E.copy(t[P]).add(y).add(I),f(E.x,E.y,
12263 E.z)):f(S.x,S.y,h/r*P);for(O=l-1;0<=O;O--){P=O/l;R=k*Math.cos(P*Math.PI/2);N=m*Math.sin(P*Math.PI/2);L=0;for(P=Q.length;L<P;L++)S=c(Q[L],x[L],N),f(S.x,S.y,h+R);F=0;for(z=G.length;F<z;F++)for(H=G[F],X=W[F],L=0,P=H.length;L<P;L++)S=c(H[L],X[L],N),D?f(S.x,S.y+t[r-1].y,t[r-1].x+R):f(S.x,S.y,h+R)}(function(){if(n){var a=0*T;for(L=0;L<U;L++)V=J[L],g(V[2]+a,V[1]+a,V[0]+a);a=T*(r+2*l);for(L=0;L<U;L++)V=J[L],g(V[0]+a,V[1]+a,V[2]+a)}else{for(L=0;L<U;L++)V=J[L],g(V[2],V[1],V[0]);for(L=0;L<U;L++)V=J[L],g(V[0]+
12264 T*r,V[1]+T*r,V[2]+T*r)}})();(function(){var a=0;e(Q,a);a+=Q.length;F=0;for(z=G.length;F<z;F++)H=G[F],e(H,a),a+=H.length})()};za.WorldUVGenerator={generateTopUV:function(a,b,c,d){a=a.vertices;b=a[b];c=a[c];d=a[d];return[new B(b.x,b.y),new B(c.x,c.y),new B(d.x,d.y)]},generateSideWallUV:function(a,b,c,d,e){a=a.vertices;b=a[b];c=a[c];d=a[d];e=a[e];return.01>Math.abs(b.y-c.y)?[new B(b.x,1-b.z),new B(c.x,1-c.z),new B(d.x,1-d.z),new B(e.x,1-e.z)]:[new B(b.y,1-b.z),new B(c.y,1-c.z),new B(d.y,1-d.z),new B(e.y,
12265 1-e.z)]}};Dc.prototype=Object.create(za.prototype);Dc.prototype.constructor=Dc;mb.prototype=Object.create(G.prototype);mb.prototype.constructor=mb;Vb.prototype=Object.create(Q.prototype);Vb.prototype.constructor=Vb;Wb.prototype=Object.create(G.prototype);Wb.prototype.constructor=Wb;Ec.prototype=Object.create(Q.prototype);Ec.prototype.constructor=Ec;Fc.prototype=Object.create(Q.prototype);Fc.prototype.constructor=Fc;Xb.prototype=Object.create(G.prototype);Xb.prototype.constructor=Xb;Gc.prototype=Object.create(Q.prototype);
12266 Gc.prototype.constructor=Gc;cb.prototype=Object.create(Q.prototype);cb.prototype.constructor=cb;cb.prototype.addShapeList=function(a,b){for(var c=0,d=a.length;c<d;c++)this.addShape(a[c],b);return this};cb.prototype.addShape=function(a,b){void 0===b&&(b={});var c=b.material,d=void 0===b.UVGenerator?za.WorldUVGenerator:b.UVGenerator,e,f,g,h=this.vertices.length;e=a.extractPoints(void 0!==b.curveSegments?b.curveSegments:12);var k=e.shape,m=e.holes;if(!ra.isClockWise(k))for(k=k.reverse(),e=0,f=m.length;e<
12267 f;e++)g=m[e],ra.isClockWise(g)&&(m[e]=g.reverse());var l=ra.triangulateShape(k,m);e=0;for(f=m.length;e<f;e++)g=m[e],k=k.concat(g);m=k.length;f=l.length;for(e=0;e<m;e++)g=k[e],this.vertices.push(new q(g.x,g.y,0));for(e=0;e<f;e++)m=l[e],k=m[0]+h,g=m[1]+h,m=m[2]+h,this.faces.push(new ea(k,g,m,null,null,c)),this.faceVertexUvs[0].push(d.generateTopUV(this,k,g,m))};Yb.prototype=Object.create(G.prototype);Yb.prototype.constructor=Yb;Ua.prototype=Object.create(G.prototype);Ua.prototype.constructor=Ua;nb.prototype=
12268 Object.create(Q.prototype);nb.prototype.constructor=nb;Hc.prototype=Object.create(nb.prototype);Hc.prototype.constructor=Hc;Ic.prototype=Object.create(Ua.prototype);Ic.prototype.constructor=Ic;Zb.prototype=Object.create(G.prototype);Zb.prototype.constructor=Zb;Jc.prototype=Object.create(Q.prototype);Jc.prototype.constructor=Jc;ob.prototype=Object.create(Q.prototype);ob.prototype.constructor=ob;var Na=Object.freeze({WireframeGeometry:Mb,ParametricGeometry:uc,ParametricBufferGeometry:Nb,TetrahedronGeometry:vc,
12269 TetrahedronBufferGeometry:Ob,OctahedronGeometry:wc,OctahedronBufferGeometry:Pb,IcosahedronGeometry:xc,IcosahedronBufferGeometry:Qb,DodecahedronGeometry:yc,DodecahedronBufferGeometry:Rb,PolyhedronGeometry:zc,PolyhedronBufferGeometry:ua,TubeGeometry:Ac,TubeBufferGeometry:Sb,TorusKnotGeometry:Bc,TorusKnotBufferGeometry:Tb,TorusGeometry:Cc,TorusBufferGeometry:Ub,TextGeometry:Dc,SphereBufferGeometry:mb,SphereGeometry:Vb,RingGeometry:Ec,RingBufferGeometry:Wb,PlaneBufferGeometry:ib,PlaneGeometry:Fc,LatheGeometry:Gc,
12270 LatheBufferGeometry:Xb,ShapeGeometry:cb,ExtrudeGeometry:za,EdgesGeometry:Yb,ConeGeometry:Hc,ConeBufferGeometry:Ic,CylinderGeometry:nb,CylinderBufferGeometry:Ua,CircleBufferGeometry:Zb,CircleGeometry:Jc,BoxBufferGeometry:hb,BoxGeometry:ob});$b.prototype=Object.create(Fa.prototype);$b.prototype.constructor=$b;$b.prototype.isShadowMaterial=!0;ac.prototype=Object.create(Fa.prototype);ac.prototype.constructor=ac;ac.prototype.isRawShaderMaterial=!0;Kc.prototype={constructor:Kc,isMultiMaterial:!0,toJSON:function(a){for(var b=
12271 {metadata:{version:4.2,type:"material",generator:"MaterialExporter"},uuid:this.uuid,type:this.type,materials:[]},c=this.materials,d=0,e=c.length;d<e;d++){var f=c[d].toJSON(a);delete f.metadata;b.materials.push(f)}b.visible=this.visible;return b},clone:function(){for(var a=new this.constructor,b=0;b<this.materials.length;b++)a.materials.push(this.materials[b].clone());a.visible=this.visible;return a}};Oa.prototype=Object.create(U.prototype);Oa.prototype.constructor=Oa;Oa.prototype.isMeshStandardMaterial=
12272 !0;Oa.prototype.copy=function(a){U.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=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.normalScale.copy(a.normalScale);
12273 this.displacementMap=a.displacementMap;this.displacementScale=a.displacementScale;this.displacementBias=a.displacementBias;this.roughnessMap=a.roughnessMap;this.metalnessMap=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=
12274 a.morphTargets;this.morphNormals=a.morphNormals;return this};pb.prototype=Object.create(Oa.prototype);pb.prototype.constructor=pb;pb.prototype.isMeshPhysicalMaterial=!0;pb.prototype.copy=function(a){Oa.prototype.copy.call(this,a);this.defines={PHYSICAL:""};this.reflectivity=a.reflectivity;this.clearCoat=a.clearCoat;this.clearCoatRoughness=a.clearCoatRoughness;return this};db.prototype=Object.create(U.prototype);db.prototype.constructor=db;db.prototype.isMeshPhongMaterial=!0;db.prototype.copy=function(a){U.prototype.copy.call(this,
12275 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=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.normalScale.copy(a.normalScale);this.displacementMap=a.displacementMap;this.displacementScale=
12276 a.displacementScale;this.displacementBias=a.displacementBias;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};qb.prototype=
12277 Object.create(U.prototype);qb.prototype.constructor=qb;qb.prototype.isMeshNormalMaterial=!0;qb.prototype.copy=function(a){U.prototype.copy.call(this,a);this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;return this};rb.prototype=Object.create(U.prototype);rb.prototype.constructor=rb;rb.prototype.isMeshLambertMaterial=!0;rb.prototype.copy=function(a){U.prototype.copy.call(this,a);this.color.copy(a.color);this.map=a.map;this.lightMap=a.lightMap;this.lightMapIntensity=a.lightMapIntensity;
12278 this.aoMap=a.aoMap;this.aoMapIntensity=a.aoMapIntensity;this.emissive.copy(a.emissive);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=
12279 a.skinning;this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;return this};sb.prototype=Object.create(U.prototype);sb.prototype.constructor=sb;sb.prototype.isLineDashedMaterial=!0;sb.prototype.copy=function(a){U.prototype.copy.call(this,a);this.color.copy(a.color);this.linewidth=a.linewidth;this.scale=a.scale;this.dashSize=a.dashSize;this.gapSize=a.gapSize;return this};var Df=Object.freeze({ShadowMaterial:$b,SpriteMaterial:kb,RawShaderMaterial:ac,ShaderMaterial:Fa,PointsMaterial:xa,
12280 MultiMaterial:Kc,MeshPhysicalMaterial:pb,MeshStandardMaterial:Oa,MeshPhongMaterial:db,MeshNormalMaterial:qb,MeshLambertMaterial:rb,MeshDepthMaterial:Za,MeshBasicMaterial:Ma,LineDashedMaterial:sb,LineBasicMaterial:oa,Material:U}),ce={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={}}},Ga=new Fd;Object.assign(Ja.prototype,{load:function(a,b,c,d){void 0===
12281 a&&(a="");void 0!==this.path&&(a=this.path+a);var e=this,f=ce.get(a);if(void 0!==f)return e.manager.itemStart(a),setTimeout(function(){b&&b(f);e.manager.itemEnd(a)},0),f;var g=a.match(/^data:(.*?)(;base64)?,(.*)$/);if(g){var h=g[1],k=!!g[2],g=g[3],g=window.decodeURIComponent(g);k&&(g=window.atob(g));try{var m,l=(this.responseType||"").toLowerCase();switch(l){case "arraybuffer":case "blob":m=new ArrayBuffer(g.length);for(var n=new Uint8Array(m),k=0;k<g.length;k++)n[k]=g.charCodeAt(k);"blob"===l&&(m=
12282 new Blob([m],{type:h}));break;case "document":m=(new DOMParser).parseFromString(g,h);break;case "json":m=JSON.parse(g);break;default:m=g}window.setTimeout(function(){b&&b(m);e.manager.itemEnd(a)},0)}catch(q){window.setTimeout(function(){d&&d(q);e.manager.itemError(a)},0)}}else{var p=new XMLHttpRequest;p.open("GET",a,!0);p.addEventListener("load",function(c){var f=c.target.response;ce.add(a,f);200===this.status?(b&&b(f),e.manager.itemEnd(a)):0===this.status?(console.warn("THREE.XHRLoader: HTTP Status 0 received."),
12283 b&&b(f),e.manager.itemEnd(a)):(d&&d(c),e.manager.itemError(a))},!1);void 0!==c&&p.addEventListener("progress",function(a){c(a)},!1);p.addEventListener("error",function(b){d&&d(b);e.manager.itemError(a)},!1);void 0!==this.responseType&&(p.responseType=this.responseType);void 0!==this.withCredentials&&(p.withCredentials=this.withCredentials);p.overrideMimeType&&p.overrideMimeType("text/plain");p.send(null)}e.manager.itemStart(a);return p},setPath:function(a){this.path=a;return this},setResponseType:function(a){this.responseType=
12284 a;return this},setWithCredentials:function(a){this.withCredentials=a;return this}});Object.assign(we.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 Lb;h.image=g;var k=new Ja(this.manager);k.setPath(this.path);k.setResponseType("arraybuffer");if(Array.isArray(a))for(var m=
12285 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=a;
12286 return this}});Object.assign(Gd.prototype,{load:function(a,b,c,d){var e=this,f=new lb,g=new Ja(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?
12287 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(Lc.prototype,{load:function(a,b,c,d){var e=this,f=document.createElementNS("http://www.w3.org/1999/xhtml","img");f.onload=function(){f.onload=null;URL.revokeObjectURL(f.src);b&&b(f);e.manager.itemEnd(a)};f.onerror=d;if(0===a.indexOf("data:"))f.src=a;else{var g=new Ja;g.setPath(this.path);
12288 g.setResponseType("blob");g.setWithCredentials(this.withCredentials);g.load(a,function(a){f.src=URL.createObjectURL(a)},c,d)}e.manager.itemStart(a);return f},setCrossOrigin:function(a){this.crossOrigin=a;return this},setWithCredentials:function(a){this.withCredentials=a;return this},setPath:function(a){this.path=a;return this}});Object.assign(Hd.prototype,{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 Xa,g=new Lc(this.manager);
12289 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=a;return this}});Object.assign(gd.prototype,{load:function(a,b,c,d){var e=new da,f=new Lc(this.manager);f.setCrossOrigin(this.crossOrigin);f.setWithCredentials(this.withCredentials);f.setPath(this.path);f.load(a,function(c){var d=0<a.search(/\.(jpg|jpeg)$/)||0===a.search(/^data\:image\/jpeg/);e.format=d?1022:
12290 1023;e.image=c;e.needsUpdate=!0;void 0!==b&&b(e)},c,d);return e},setCrossOrigin:function(a){this.crossOrigin=a;return this},setWithCredentials:function(a){this.withCredentials=a;return this},setPath:function(a){this.path=a;return this}});pa.prototype=Object.assign(Object.create(z.prototype),{constructor:pa,isLight:!0,copy:function(a){z.prototype.copy.call(this,a);this.color.copy(a.color);this.intensity=a.intensity;return this},toJSON:function(a){a=z.prototype.toJSON.call(this,a);a.object.color=this.color.getHex();
12291 a.object.intensity=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}});hd.prototype=Object.assign(Object.create(pa.prototype),{constructor:hd,isHemisphereLight:!0,copy:function(a){pa.prototype.copy.call(this,
12292 a);this.groundColor.copy(a.groundColor);return this}});Object.assign(tb.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;
12293 return a}});id.prototype=Object.assign(Object.create(tb.prototype),{constructor:id,isSpotLightShadow:!0,update:function(a){var b=2*T.RAD2DEG*a.angle,c=this.mapSize.width/this.mapSize.height;a=a.distance||500;var d=this.camera;if(b!==d.fov||c!==d.aspect||a!==d.far)d.fov=b,d.aspect=c,d.far=a,d.updateProjectionMatrix()}});jd.prototype=Object.assign(Object.create(pa.prototype),{constructor:jd,isSpotLight:!0,copy:function(a){pa.prototype.copy.call(this,a);this.distance=a.distance;this.angle=a.angle;this.penumbra=
12294 a.penumbra;this.decay=a.decay;this.target=a.target.clone();this.shadow=a.shadow.clone();return this}});kd.prototype=Object.assign(Object.create(pa.prototype),{constructor:kd,isPointLight:!0,copy:function(a){pa.prototype.copy.call(this,a);this.distance=a.distance;this.decay=a.decay;this.shadow=a.shadow.clone();return this}});ld.prototype=Object.assign(Object.create(tb.prototype),{constructor:ld});md.prototype=Object.assign(Object.create(pa.prototype),{constructor:md,isDirectionalLight:!0,copy:function(a){pa.prototype.copy.call(this,
12295 a);this.target=a.target.clone();this.shadow=a.shadow.clone();return this}});nd.prototype=Object.assign(Object.create(pa.prototype),{constructor:nd,isAmbientLight:!0});var ma={arraySlice:function(a,b,c){return ma.isTypedArray(a)?new a.constructor(a.subarray(b,c)):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=
12296 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=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],
12297 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++];while(void 0!==f)}}}};qa.prototype={constructor:qa,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&&
12298 (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=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||
12299 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]=c[a+e];return b},interpolate_:function(a,b,c,d){throw Error("call to abstract method");},intervalChanged_:function(a,b,c){}};Object.assign(qa.prototype,{beforeStart_:qa.prototype.copySampleValue_,afterEnd_:qa.prototype.copySampleValue_});od.prototype=Object.assign(Object.create(qa.prototype),{constructor:od,DefaultSettings_:{endingStart:2400,endingEnd:2400},
12300 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=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,
12301 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,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}});Mc.prototype=Object.assign(Object.create(qa.prototype),{constructor:Mc,interpolate_:function(a,b,c,d){var e=this.resultBuffer,f=this.sampleValues,g=this.valueSize;
12302 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}});pd.prototype=Object.assign(Object.create(qa.prototype),{constructor:pd,interpolate_:function(a,b,c,d){return this.copySampleValue_(a-1)}});var Wa;Wa={TimeBufferType:Float32Array,ValueBufferType:Float32Array,DefaultInterpolation:2301,InterpolantFactoryMethodDiscrete:function(a){return new pd(this.times,this.values,this.getValueSize(),a)},InterpolantFactoryMethodLinear:function(a){return new Mc(this.times,this.values,
12303 this.getValueSize(),a)},InterpolantFactoryMethodSmooth:function(a){return new od(this.times,this.values,this.getValueSize(),a)},setInterpolation:function(a){var b;switch(a){case 2300: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+" keyframe track named "+this.name;if(void 0===this.createInterpolant)if(a!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);
12304 else throw Error(b);console.warn(b)}else this.createInterpolant=b},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/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=
12305 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),d=this.getValueSize(),this.times=ma.arraySlice(c,e,f),this.values=ma.arraySlice(this.values,e*d,f*d);return this},validate:function(){var a=!0,b=this.getValueSize();0!==b-Math.floor(b)&&(console.error("invalid value size in track",this),a=!1);var c=this.times,b=this.values,d=c.length;0===d&&(console.error("track is empty",
12306 this),a=!1);for(var e=null,f=0;f!==d;f++){var g=c[f];if("number"===typeof g&&isNaN(g)){console.error("time is not a valid number",this,f,g);a=!1;break}if(null!==e&&e>g){console.error("out of order keys",this,f,g,e);a=!1;break}e=g}if(void 0!==b&&ma.isTypedArray(b))for(f=0,c=b.length;f!==c;++f)if(d=b[f],isNaN(d)){console.error("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,
12307 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 for(var m=g*c,l=m-c,n=m+c,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]=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=ma.arraySlice(a,0,e),this.values=ma.arraySlice(b,0,e*c));return this}};bc.prototype=Object.assign(Object.create(Wa),{constructor:bc,ValueTypeName:"vector"});
12308 qd.prototype=Object.assign(Object.create(qa.prototype),{constructor:qd,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)ba.slerpFlat(e,0,f,a-g,f,a,b);return e}});Nc.prototype=Object.assign(Object.create(Wa),{constructor:Nc,ValueTypeName:"quaternion",DefaultInterpolation:2301,InterpolantFactoryMethodLinear:function(a){return new qd(this.times,this.values,this.getValueSize(),a)},InterpolantFactoryMethodSmooth:void 0});
12309 cc.prototype=Object.assign(Object.create(Wa),{constructor:cc,ValueTypeName:"number"});rd.prototype=Object.assign(Object.create(Wa),{constructor:rd,ValueTypeName:"string",ValueBufferType:Array,DefaultInterpolation:2300,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0});sd.prototype=Object.assign(Object.create(Wa),{constructor:sd,ValueTypeName:"bool",ValueBufferType:Array,DefaultInterpolation:2300,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0});
12310 td.prototype=Object.assign(Object.create(Wa),{constructor:td,ValueTypeName:"color"});vb.prototype=Wa;Wa.constructor=vb;Object.assign(vb,{parse:function(a){if(void 0===a.type)throw Error("track type undefined, can not parse");var b=vb._getTrackTypeForValueTypeName(a.type);if(void 0===a.times){var c=[],d=[];ma.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)},toJSON:function(a){var b=a.constructor;if(void 0!==b.toJSON)b=
12311 b.toJSON(a);else{var b={name:a.name,times:ma.convertArray(a.times,Array),values:ma.convertArray(a.values,Array)},c=a.getInterpolation();c!==a.DefaultInterpolation&&(b.interpolation=c)}b.type=a.ValueTypeName;return b},_getTrackTypeForValueTypeName:function(a){switch(a.toLowerCase()){case "scalar":case "double":case "float":case "number":case "integer":return cc;case "vector":case "vector2":case "vector3":case "vector4":return bc;case "color":return td;case "quaternion":return Nc;case "bool":case "boolean":return sd;
12312 case "string":return rd}throw Error("Unsupported typeName: "+a);}});Ha.prototype={constructor:Ha,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=a},trim:function(){for(var a=0;a<this.tracks.length;a++)this.tracks[a].trim(0,this.duration);return this},optimize:function(){for(var a=0;a<this.tracks.length;a++)this.tracks[a].optimize();return this}};Object.assign(Ha,{parse:function(a){for(var b=[],c=a.tracks,
12313 d=1/(a.fps||1),e=0,f=c.length;e!==f;++e)b.push(vb.parse(c[e]).scale(d));return new Ha(a.name,a.duration,b)},toJSON:function(a){var b=[],c=a.tracks;a={name:a.name,duration:a.duration,tracks:b};for(var d=0,e=c.length;d!==e;++d)b.push(vb.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=ma.getKeyframeOrder(h),h=ma.sortedArray(h,1,m),k=ma.sortedArray(k,1,m);d||0!==h[0]||(h.push(e),
12314 k.push(k[0]));f.push((new cc(".morphTargetInfluences["+b[g].name+"]",h,k)).scale(1/c))}return new Ha(a,-1,f)},findByName:function(a,b){var c=a;Array.isArray(a)||(c=a.geometry&&a.geometry.animations||a.animations);for(var d=0;d<c.length;d++)if(c[d].name===b)return c[d];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(Ha.CreateFromMorphTargetSequence(m,
12315 d[m],b,c));return a},parseAnimation:function(a,b){if(!a)return console.error(" no animation in JSONLoader data"),null;for(var c=function(a,b,c,d,e){if(0!==c.length){var f=[],g=[];ma.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,h=a.hierarchy||[],k=0;k<h.length;k++){var m=h[k].keys;if(m&&0!==m.length)if(m[0].morphTargets){for(var f={},l=0;l<m.length;l++)if(m[l].morphTargets)for(var n=0;n<m[l].morphTargets.length;n++)f[m[l].morphTargets[n]]=
12316 -1;for(var p in f){for(var q=[],x=[],n=0;n!==m[l].morphTargets.length;++n){var t=m[l];q.push(t.time);x.push(t.morphTarget===p?1:0)}d.push(new cc(".morphTargetInfluence["+p+"]",q,x))}f=f.length*(g||1)}else l=".bones["+b[k].name+"]",c(bc,l+".position",m,"pos",d),c(Nc,l+".quaternion",m,"rot",d),c(bc,l+".scale",m,"scl",d)}return 0===d.length?null:new Ha(e,f,d)}});Object.assign(ud.prototype,{load:function(a,b,c,d){var e=this;(new Ja(e.manager)).load(a,function(a){b(e.parse(JSON.parse(a)))},c,d)},setTextures:function(a){this.textures=
12317 a},parse:function(a){function b(a){void 0===c[a]&&console.warn("THREE.MaterialLoader: Undefined texture",a);return c[a]}var c=this.textures,d=new Df[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);
12318 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.shading&&(d.shading=a.shading);void 0!==a.blending&&(d.blending=a.blending);void 0!==a.side&&(d.side=a.side);void 0!==a.opacity&&(d.opacity=a.opacity);void 0!==a.transparent&&(d.transparent=a.transparent);void 0!==a.alphaTest&&(d.alphaTest=
12319 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=a.wireframeLinejoin);void 0!==a.skinning&&(d.skinning=a.skinning);void 0!==a.morphTargets&&(d.morphTargets=
12320 a.morphTargets);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);void 0!==a.normalMap&&(d.normalMap=b(a.normalMap));if(void 0!==a.normalScale){var e=a.normalScale;!1===Array.isArray(e)&&(e=[e,e]);d.normalScale=(new B).fromArray(e)}void 0!==a.displacementMap&&(d.displacementMap=
12321 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!==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));
12322 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!==a.aoMapIntensity&&(d.aoMapIntensity=a.aoMapIntensity);if(void 0!==a.materials)for(var e=0,f=a.materials.length;e<f;e++)d.materials.push(this.parse(a.materials[e]));return d}});Object.assign(Id.prototype,{load:function(a,b,c,d){var e=this;(new Ja(e.manager)).load(a,function(a){b(e.parse(JSON.parse(a)))},
12323 c,d)},parse:function(a){var b=new G,c=a.data.index,d={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:Uint8ClampedArray,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};void 0!==c&&(c=new d[c.type](c.array),b.setIndex(new C(c,1)));var e=a.data.attributes,f;for(f in e){var g=e[f],c=new d[g.type](g.array);b.addAttribute(f,new C(c,g.itemSize,g.normalized))}d=a.data.groups||a.data.drawcalls||a.data.offsets;
12324 if(void 0!==d)for(f=0,c=d.length;f!==c;++f)e=d[f],b.addGroup(e.start,e.count,e.materialIndex);a=a.data.boundingSphere;void 0!==a&&(d=new q,void 0!==a.center&&d.fromArray(a.center),b.boundingSphere=new Ca(d,a.radius));return b}});wb.prototype={constructor:wb,crossOrigin:void 0,extractUrlBase:function(a){a=a.split("/");if(1===a.length)return"./";a.pop();return a.join("/")+"/"},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,
12325 b,c;return function(d,e,f){function g(a,c,d,g,k){a=e+a;var l=wb.Handlers.get(a);null!==l?a=l.load(a):(b.setCrossOrigin(f),a=b.load(a));void 0!==c&&(a.repeat.fromArray(c),1!==c[0]&&(a.wrapS=1E3),1!==c[1]&&(a.wrapT=1E3));void 0!==d&&a.offset.fromArray(d);void 0!==g&&("repeat"===g[0]&&(a.wrapS=1E3),"mirror"===g[0]&&(a.wrapS=1002),"repeat"===g[1]&&(a.wrapT=1E3),"mirror"===g[1]&&(a.wrapT=1002));void 0!==k&&(a.anisotropy=k);c=T.generateUUID();h[c]=a;return c}void 0===a&&(a=new O);void 0===b&&(b=new gd);
12326 void 0===c&&(c=new ud);var h={},k={uuid:T.generateUUID(),type:"MeshLambertMaterial"},m;for(m in d){var l=d[m];switch(m){case "DbgColor":case "DbgIndex":case "opticalDensity":case "illumination":break;case "DbgName":k.name=l;break;case "blending":k.blending=Fe[l];break;case "colorAmbient":case "mapAmbient":console.warn("THREE.Loader.createMaterial:",m,"is no longer supported.");break;case "colorDiffuse":k.color=a.fromArray(l).getHex();break;case "colorSpecular":k.specular=a.fromArray(l).getHex();break;
12327 case "colorEmissive":k.emissive=a.fromArray(l).getHex();break;case "specularCoef":k.shininess=l;break;case "shading":"basic"===l.toLowerCase()&&(k.type="MeshBasicMaterial");"phong"===l.toLowerCase()&&(k.type="MeshPhongMaterial");"standard"===l.toLowerCase()&&(k.type="MeshStandardMaterial");break;case "mapDiffuse":k.map=g(l,d.mapDiffuseRepeat,d.mapDiffuseOffset,d.mapDiffuseWrap,d.mapDiffuseAnisotropy);break;case "mapDiffuseRepeat":case "mapDiffuseOffset":case "mapDiffuseWrap":case "mapDiffuseAnisotropy":break;
12328 case "mapEmissive":k.emissiveMap=g(l,d.mapEmissiveRepeat,d.mapEmissiveOffset,d.mapEmissiveWrap,d.mapEmissiveAnisotropy);break;case "mapEmissiveRepeat":case "mapEmissiveOffset":case "mapEmissiveWrap":case "mapEmissiveAnisotropy":break;case "mapLight":k.lightMap=g(l,d.mapLightRepeat,d.mapLightOffset,d.mapLightWrap,d.mapLightAnisotropy);break;case "mapLightRepeat":case "mapLightOffset":case "mapLightWrap":case "mapLightAnisotropy":break;case "mapAO":k.aoMap=g(l,d.mapAORepeat,d.mapAOOffset,d.mapAOWrap,
12329 d.mapAOAnisotropy);break;case "mapAORepeat":case "mapAOOffset":case "mapAOWrap":case "mapAOAnisotropy":break;case "mapBump":k.bumpMap=g(l,d.mapBumpRepeat,d.mapBumpOffset,d.mapBumpWrap,d.mapBumpAnisotropy);break;case "mapBumpScale":k.bumpScale=l;break;case "mapBumpRepeat":case "mapBumpOffset":case "mapBumpWrap":case "mapBumpAnisotropy":break;case "mapNormal":k.normalMap=g(l,d.mapNormalRepeat,d.mapNormalOffset,d.mapNormalWrap,d.mapNormalAnisotropy);break;case "mapNormalFactor":k.normalScale=[l,l];break;
12330 case "mapNormalRepeat":case "mapNormalOffset":case "mapNormalWrap":case "mapNormalAnisotropy":break;case "mapSpecular":k.specularMap=g(l,d.mapSpecularRepeat,d.mapSpecularOffset,d.mapSpecularWrap,d.mapSpecularAnisotropy);break;case "mapSpecularRepeat":case "mapSpecularOffset":case "mapSpecularWrap":case "mapSpecularAnisotropy":break;case "mapMetalness":k.metalnessMap=g(l,d.mapMetalnessRepeat,d.mapMetalnessOffset,d.mapMetalnessWrap,d.mapMetalnessAnisotropy);break;case "mapMetalnessRepeat":case "mapMetalnessOffset":case "mapMetalnessWrap":case "mapMetalnessAnisotropy":break;
12331 case "mapRoughness":k.roughnessMap=g(l,d.mapRoughnessRepeat,d.mapRoughnessOffset,d.mapRoughnessWrap,d.mapRoughnessAnisotropy);break;case "mapRoughnessRepeat":case "mapRoughnessOffset":case "mapRoughnessWrap":case "mapRoughnessAnisotropy":break;case "mapAlpha":k.alphaMap=g(l,d.mapAlphaRepeat,d.mapAlphaOffset,d.mapAlphaWrap,d.mapAlphaAnisotropy);break;case "mapAlphaRepeat":case "mapAlphaOffset":case "mapAlphaWrap":case "mapAlphaAnisotropy":break;case "flipSided":k.side=1;break;case "doubleSided":k.side=
12332 2;break;case "transparency":console.warn("THREE.Loader.createMaterial: transparency has been renamed to opacity");k.opacity=l;break;case "depthTest":case "depthWrite":case "colorWrite":case "opacity":case "reflectivity":case "transparent":case "visible":case "wireframe":k[m]=l;break;case "vertexColors":!0===l&&(k.vertexColors=2);"face"===l&&(k.vertexColors=1);break;default:console.error("THREE.Loader.createMaterial: Unsupported",m,l)}}"MeshBasicMaterial"===k.type&&delete k.emissive;"MeshPhongMaterial"!==
12333 k.type&&delete k.specular;1>k.opacity&&(k.transparent=!0);c.setTextures(h);return c.parse(k)}}()};wb.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(Jd.prototype,{load:function(a,b,c,d){var e=this,f=this.texturePath&&"string"===typeof this.texturePath?this.texturePath:wb.prototype.extractUrlBase(a),g=new Ja(this.manager);g.setWithCredentials(this.withCredentials);
12334 g.load(a,function(c){c=JSON.parse(c);var d=c.metadata;if(void 0!==d&&(d=d.type,void 0!==d)){if("object"===d.toLowerCase()){console.error("THREE.JSONLoader: "+a+" should be loaded with THREE.ObjectLoader instead.");return}if("scene"===d.toLowerCase()){console.error("THREE.JSONLoader: "+a+" should be loaded with THREE.SceneLoader instead.");return}}c=e.parse(c,f);b(c.geometry,c.materials)},c,d)},setTexturePath:function(a){this.texturePath=a},parse:function(a,b){var c=new Q,d=void 0!==a.scale?1/a.scale:
12335 1;(function(b){var d,g,h,k,l,w,n,p,r,x,t,D,u,v=a.faces;w=a.vertices;var z=a.normals,y=a.colors,E=0;if(void 0!==a.uvs){for(d=0;d<a.uvs.length;d++)a.uvs[d].length&&E++;for(d=0;d<E;d++)c.faceVertexUvs[d]=[]}k=0;for(l=w.length;k<l;)d=new q,d.x=w[k++]*b,d.y=w[k++]*b,d.z=w[k++]*b,c.vertices.push(d);k=0;for(l=v.length;k<l;)if(b=v[k++],r=b&1,h=b&2,d=b&8,n=b&16,x=b&32,w=b&64,b&=128,r){r=new ea;r.a=v[k];r.b=v[k+1];r.c=v[k+3];t=new ea;t.a=v[k+1];t.b=v[k+2];t.c=v[k+3];k+=4;h&&(h=v[k++],r.materialIndex=h,t.materialIndex=
12336 h);h=c.faces.length;if(d)for(d=0;d<E;d++)for(D=a.uvs[d],c.faceVertexUvs[d][h]=[],c.faceVertexUvs[d][h+1]=[],g=0;4>g;g++)p=v[k++],u=D[2*p],p=D[2*p+1],u=new B(u,p),2!==g&&c.faceVertexUvs[d][h].push(u),0!==g&&c.faceVertexUvs[d][h+1].push(u);n&&(n=3*v[k++],r.normal.set(z[n++],z[n++],z[n]),t.normal.copy(r.normal));if(x)for(d=0;4>d;d++)n=3*v[k++],x=new q(z[n++],z[n++],z[n]),2!==d&&r.vertexNormals.push(x),0!==d&&t.vertexNormals.push(x);w&&(w=v[k++],w=y[w],r.color.setHex(w),t.color.setHex(w));if(b)for(d=
12337 0;4>d;d++)w=v[k++],w=y[w],2!==d&&r.vertexColors.push(new O(w)),0!==d&&t.vertexColors.push(new O(w));c.faces.push(r);c.faces.push(t)}else{r=new ea;r.a=v[k++];r.b=v[k++];r.c=v[k++];h&&(h=v[k++],r.materialIndex=h);h=c.faces.length;if(d)for(d=0;d<E;d++)for(D=a.uvs[d],c.faceVertexUvs[d][h]=[],g=0;3>g;g++)p=v[k++],u=D[2*p],p=D[2*p+1],u=new B(u,p),c.faceVertexUvs[d][h].push(u);n&&(n=3*v[k++],r.normal.set(z[n++],z[n++],z[n]));if(x)for(d=0;3>d;d++)n=3*v[k++],x=new q(z[n++],z[n++],z[n]),r.vertexNormals.push(x);
12338 w&&(w=v[k++],r.color.setHex(y[w]));if(b)for(d=0;3>d;d++)w=v[k++],r.vertexColors.push(new O(y[w]));c.faces.push(r)}})(d);(function(){var b=void 0!==a.influencesPerVertex?a.influencesPerVertex:2;if(a.skinWeights)for(var d=0,g=a.skinWeights.length;d<g;d+=b)c.skinWeights.push(new ga(a.skinWeights[d],1<b?a.skinWeights[d+1]:0,2<b?a.skinWeights[d+2]:0,3<b?a.skinWeights[d+3]:0));if(a.skinIndices)for(d=0,g=a.skinIndices.length;d<g;d+=b)c.skinIndices.push(new ga(a.skinIndices[d],1<b?a.skinIndices[d+1]:0,2<
12339 b?a.skinIndices[d+2]:0,3<b?a.skinIndices[d+3]:0));c.bones=a.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.")})();(function(b){if(void 0!==a.morphTargets)for(var d=0,g=a.morphTargets.length;d<g;d++){c.morphTargets[d]={};c.morphTargets[d].name=a.morphTargets[d].name;
12340 c.morphTargets[d].vertices=[];for(var h=c.morphTargets[d].vertices,k=a.morphTargets[d].vertices,l=0,w=k.length;l<w;l+=3){var n=new q;n.x=k[l]*b;n.y=k[l+1]*b;n.z=k[l+2]*b;h.push(n)}}if(void 0!==a.morphColors&&0<a.morphColors.length)for(console.warn('THREE.JSONLoader: "morphColors" no longer supported. Using them as face colors.'),b=c.faces,h=a.morphColors[0].colors,d=0,g=b.length;d<g;d++)b[d].color.fromArray(h,3*d)})(d);(function(){var b=[],d=[];void 0!==a.animation&&d.push(a.animation);void 0!==a.animations&&
12341 (a.animations.length?d=d.concat(a.animations):d.push(a.animations));for(var g=0;g<d.length;g++){var h=Ha.parseAnimation(d[g],c.bones);h&&b.push(h)}c.morphTargets&&(d=Ha.CreateClipsFromMorphTargetSequences(c.morphTargets,10),b=b.concat(d));0<b.length&&(c.animations=b)})();c.computeFaceNormals();c.computeBoundingSphere();if(void 0===a.materials||0===a.materials.length)return{geometry:c};d=wb.prototype.initMaterials(a.materials,b,this.crossOrigin);return{geometry:c,materials:d}}});Object.assign(xe.prototype,
12342 {load:function(a,b,c,d){""===this.texturePath&&(this.texturePath=a.substring(0,a.lastIndexOf("/")+1));var e=this;(new Ja(e.manager)).load(a,function(a){e.parse(JSON.parse(a),b)},c,d)},setTexturePath:function(a){this.texturePath=a},setCrossOrigin:function(a){this.crossOrigin=a},parse:function(a,b){var c=this.parseGeometries(a.geometries),d=this.parseImages(a.images,function(){void 0!==b&&b(e)}),d=this.parseTextures(a.textures,d),d=this.parseMaterials(a.materials,d),e=this.parseObject(a.object,c,d);
12343 a.animations&&(e.animations=this.parseAnimations(a.animations));void 0!==a.images&&0!==a.images.length||void 0===b||b(e);return e},parseGeometries:function(a){var b={};if(void 0!==a)for(var c=new Jd,d=new Id,e=0,f=a.length;e<f;e++){var g,h=a[e];switch(h.type){case "PlaneGeometry":case "PlaneBufferGeometry":g=new Na[h.type](h.width,h.height,h.widthSegments,h.heightSegments);break;case "BoxGeometry":case "BoxBufferGeometry":case "CubeGeometry":g=new Na[h.type](h.width,h.height,h.depth,h.widthSegments,
12344 h.heightSegments,h.depthSegments);break;case "CircleGeometry":case "CircleBufferGeometry":g=new Na[h.type](h.radius,h.segments,h.thetaStart,h.thetaLength);break;case "CylinderGeometry":case "CylinderBufferGeometry":g=new Na[h.type](h.radiusTop,h.radiusBottom,h.height,h.radialSegments,h.heightSegments,h.openEnded,h.thetaStart,h.thetaLength);break;case "ConeGeometry":case "ConeBufferGeometry":g=new Na[h.type](h.radius,h.height,h.radialSegments,h.heightSegments,h.openEnded,h.thetaStart,h.thetaLength);
12345 break;case "SphereGeometry":case "SphereBufferGeometry":g=new Na[h.type](h.radius,h.widthSegments,h.heightSegments,h.phiStart,h.phiLength,h.thetaStart,h.thetaLength);break;case "DodecahedronGeometry":case "IcosahedronGeometry":case "OctahedronGeometry":case "TetrahedronGeometry":g=new Na[h.type](h.radius,h.detail);break;case "RingGeometry":case "RingBufferGeometry":g=new Na[h.type](h.innerRadius,h.outerRadius,h.thetaSegments,h.phiSegments,h.thetaStart,h.thetaLength);break;case "TorusGeometry":case "TorusBufferGeometry":g=
12346 new Na[h.type](h.radius,h.tube,h.radialSegments,h.tubularSegments,h.arc);break;case "TorusKnotGeometry":case "TorusKnotBufferGeometry":g=new Na[h.type](h.radius,h.tube,h.tubularSegments,h.radialSegments,h.p,h.q);break;case "LatheGeometry":case "LatheBufferGeometry":g=new Na[h.type](h.points,h.segments,h.phiStart,h.phiLength);break;case "BufferGeometry":g=d.parse(h);break;case "Geometry":g=c.parse(h.data,this.texturePath).geometry;break;default:console.warn('THREE.ObjectLoader: Unsupported geometry type "'+
12347 h.type+'"');continue}g.uuid=h.uuid;void 0!==h.name&&(g.name=h.name);b[h.uuid]=g}return b},parseMaterials:function(a,b){var c={};if(void 0!==a){var d=new ud;d.setTextures(b);for(var e=0,f=a.length;e<f;e++){var g=d.parse(a[e]);c[g.uuid]=g}}return c},parseAnimations:function(a){for(var b=[],c=0;c<a.length;c++){var d=Ha.parse(a[c]);b.push(d)}return b},parseImages:function(a,b){function c(a){d.manager.itemStart(a);return g.load(a,function(){d.manager.itemEnd(a)},void 0,function(){d.manager.itemError(a)})}
12348 var d=this,e={};if(void 0!==a&&0<a.length){var f=new Fd(b),g=new Lc(f);g.setCrossOrigin(this.crossOrigin);for(var f=0,h=a.length;f<h;f++){var k=a[f],l=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(k.url)?k.url:d.texturePath+k.url;e[k.uuid]=c(l)}}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.",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&&
12349 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=new da(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,Ge));void 0!==g.offset&&h.offset.fromArray(g.offset);void 0!==g.repeat&&h.repeat.fromArray(g.repeat);void 0!==g.wrap&&(h.wrapS=c(g.wrap[0],ae),h.wrapT=c(g.wrap[1],ae));void 0!==g.minFilter&&(h.minFilter=c(g.minFilter,be));
12350 void 0!==g.magFilter&&(h.magFilter=c(g.magFilter,be));void 0!==g.anisotropy&&(h.anisotropy=g.anisotropy);void 0!==g.flipY&&(h.flipY=g.flipY);d[g.uuid]=h}return d},parseObject:function(){var a=new J;return function(b,c,d){function e(a){void 0===c[a]&&console.warn("THREE.ObjectLoader: Undefined geometry",a);return c[a]}function f(a){if(void 0!==a)return void 0===d[a]&&console.warn("THREE.ObjectLoader: Undefined material",a),d[a]}var g;switch(b.type){case "Scene":g=new jb;void 0!==b.background&&Number.isInteger(b.background)&&
12351 (g.background=new O(b.background));void 0!==b.fog&&("Fog"===b.fog.type?g.fog=new Jb(b.fog.color,b.fog.near,b.fog.far):"FogExp2"===b.fog.type&&(g.fog=new Ib(b.fog.color,b.fog.density)));break;case "PerspectiveCamera":g=new Ea(b.fov,b.aspect,b.near,b.far);void 0!==b.focus&&(g.focus=b.focus);void 0!==b.zoom&&(g.zoom=b.zoom);void 0!==b.filmGauge&&(g.filmGauge=b.filmGauge);void 0!==b.filmOffset&&(g.filmOffset=b.filmOffset);void 0!==b.view&&(g.view=Object.assign({},b.view));break;case "OrthographicCamera":g=
12352 new Hb(b.left,b.right,b.top,b.bottom,b.near,b.far);break;case "AmbientLight":g=new nd(b.color,b.intensity);break;case "DirectionalLight":g=new md(b.color,b.intensity);break;case "PointLight":g=new kd(b.color,b.intensity,b.distance,b.decay);break;case "SpotLight":g=new jd(b.color,b.intensity,b.distance,b.angle,b.penumbra,b.decay);break;case "HemisphereLight":g=new hd(b.color,b.groundColor,b.intensity);break;case "Mesh":g=e(b.geometry);var h=f(b.material);g=g.bones&&0<g.bones.length?new dd(g,h):new ya(g,
12353 h);break;case "LOD":g=new rc;break;case "Line":g=new Ta(e(b.geometry),f(b.material),b.mode);break;case "LineSegments":g=new la(e(b.geometry),f(b.material));break;case "PointCloud":case "Points":g=new Kb(e(b.geometry),f(b.material));break;case "Sprite":g=new qc(f(b.material));break;case "Group":g=new sc;break;default:g=new z}g.uuid=b.uuid;void 0!==b.name&&(g.name=b.name);void 0!==b.matrix?(a.fromArray(b.matrix),a.decompose(g.position,g.quaternion,g.scale)):(void 0!==b.position&&g.position.fromArray(b.position),
12354 void 0!==b.rotation&&g.rotation.fromArray(b.rotation),void 0!==b.quaternion&&g.quaternion.fromArray(b.quaternion),void 0!==b.scale&&g.scale.fromArray(b.scale));void 0!==b.castShadow&&(g.castShadow=b.castShadow);void 0!==b.receiveShadow&&(g.receiveShadow=b.receiveShadow);b.shadow&&(void 0!==b.shadow.bias&&(g.shadow.bias=b.shadow.bias),void 0!==b.shadow.radius&&(g.shadow.radius=b.shadow.radius),void 0!==b.shadow.mapSize&&g.shadow.mapSize.fromArray(b.shadow.mapSize),void 0!==b.shadow.camera&&(g.shadow.camera=
12355 this.parseObject(b.shadow.camera)));void 0!==b.visible&&(g.visible=b.visible);void 0!==b.userData&&(g.userData=b.userData);if(void 0!==b.children)for(var k in b.children)g.add(this.parseObject(b.children[k],c,d));if("LOD"===b.type)for(b=b.levels,h=0;h<b.length;h++){var l=b[h];k=g.getObjectByProperty("uuid",l.object);void 0!==k&&g.addLevel(k,l.distance)}return g}}()});ia.prototype={constructor:ia,getPoint:function(a){console.warn("THREE.Curve: Warning, getPoint() not implemented!");return null},getPointAt:function(a){a=
12356 this.getUtoTmapping(a);return this.getPoint(a)},getPoints:function(a){a||(a=5);for(var b=[],c=0;c<=a;c++)b.push(this.getPoint(c/a));return b},getSpacedPoints:function(a){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){a||(a=this.__arcLengthDivisions?this.__arcLengthDivisions:200);if(this.cacheArcLengths&&this.cacheArcLengths.length===a+1&&!this.needsUpdate)return this.cacheArcLengths;
12357 this.needsUpdate=!1;var b=[],c,d=this.getPoint(0),e,f=0;b.push(0);for(e=1;e<=a;e++)c=this.getPoint(e/a),f+=c.distanceTo(d),b.push(f),d=c;return this.cacheArcLengths=b},updateArcLengths:function(){this.needsUpdate=!0;this.getLengths()},getUtoTmapping:function(a,b){var c=this.getLengths(),d,e=c.length,f;f=b?b:a*c[e-1];for(var g=0,h=e-1,k;g<=h;)if(d=Math.floor(g+(h-g)/2),k=c[d]-f,0>k)g=d+1;else if(0<k)h=d-1;else{h=d;break}d=h;if(c[d]===f)return d/(e-1);g=c[d];return(d+(f-g)/(c[d+1]-g))/(e-1)},getTangent:function(a){var b=
12358 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 q,d=[],e=[],f=[],g=new q,h=new J,k,l;for(k=0;k<=a;k++)l=k/a,d[k]=this.getTangentAt(l),d[k].normalize();e[0]=new q;f[0]=new q;k=Number.MAX_VALUE;l=Math.abs(d[0].x);var w=Math.abs(d[0].y),n=Math.abs(d[0].z);l<=k&&(k=l,c.set(1,0,0));w<=k&&(k=w,c.set(0,1,0));n<=k&&c.set(0,0,1);
12359 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(T.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(T.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],c*k)),
12360 f[k].crossVectors(d[k],e[k]);return{tangents:d,normals:e,binormals:f}}};ia.create=function(a,b){a.prototype=Object.create(ia.prototype);a.prototype.constructor=a;a.prototype.getPoint=b;return a};Sa.prototype=Object.create(ia.prototype);Sa.prototype.constructor=Sa;Sa.prototype.isLineCurve=!0;Sa.prototype.getPoint=function(a){if(1===a)return this.v2.clone();var b=this.v2.clone().sub(this.v1);b.multiplyScalar(a).add(this.v1);return b};Sa.prototype.getPointAt=function(a){return this.getPoint(a)};Sa.prototype.getTangent=
12361 function(a){return this.v2.clone().sub(this.v1).normalize()};Oc.prototype=Object.assign(Object.create(ia.prototype),{constructor:Oc,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 Sa(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},
12362 getLength:function(){var a=this.getCurveLengths();return a[a.length-1]},updateArcLengths:function(){this.needsUpdate=!0;this.cacheLengths=null;this.getLengths()},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){a||(a=40);for(var b=[],c=0;c<=a;c++)b.push(this.getPoint(c/a));this.autoClose&&
12363 b.push(b[0]);return b},getPoints:function(a){a=a||12;for(var b=[],c,d=0,e=this.curves;d<e.length;d++)for(var f=e[d],f=f.getPoints(f&&f.isEllipseCurve?2*a:f&&f.isLineCurve?1:f&&f.isSplineCurve?a*f.points.length:a),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},createPointsGeometry:function(a){a=this.getPoints(a);return this.createGeometry(a)},createSpacedPointsGeometry:function(a){a=this.getSpacedPoints(a);
12364 return this.createGeometry(a)},createGeometry:function(a){for(var b=new Q,c=0,d=a.length;c<d;c++){var e=a[c];b.vertices.push(new q(e.x,e.y,e.z||0))}return b}});Va.prototype=Object.create(ia.prototype);Va.prototype.constructor=Va;Va.prototype.isEllipseCurve=!0;Va.prototype.getPoint=function(a){for(var b=2*Math.PI,c=this.aEndAngle-this.aStartAngle,d=Math.abs(c)<Number.EPSILON;0>c;)c+=b;for(;c>b;)c-=b;c<Number.EPSILON&&(c=d?0:b);!0!==this.aClockwise||d||(c=c===b?-b:c-b);b=this.aStartAngle+a*c;a=this.aX+
12365 this.xRadius*Math.cos(b);var e=this.aY+this.yRadius*Math.sin(b);0!==this.aRotation&&(b=Math.cos(this.aRotation),c=Math.sin(this.aRotation),d=a-this.aX,e-=this.aY,a=d*b-e*c+this.aX,e=d*c+e*b+this.aY);return new B(a,e)};var Xc={tangentQuadraticBezier:function(a,b,c,d){return 2*(1-a)*(c-b)+2*a*(d-c)},tangentCubicBezier:function(a,b,c,d,e){return-3*b*(1-a)*(1-a)+3*c*(1-a)*(1-a)-6*a*c*(1-a)+6*a*d*(1-a)-3*a*a*d+3*a*a*e},tangentSpline:function(a,b,c,d,e){return 6*a*a-6*a+(3*a*a-4*a+1)+(-6*a*a+6*a)+(3*a*
12366 a-2*a)},interpolate:function(a,b,c,d,e){a=.5*(c-a);d=.5*(d-b);var f=e*e;return(2*b-2*c+a+d)*e*f+(-3*b+3*c-2*a-d)*f+a*e+b}};xb.prototype=Object.create(ia.prototype);xb.prototype.constructor=xb;xb.prototype.isSplineCurve=!0;xb.prototype.getPoint=function(a){var b=this.points;a*=b.length-1;var c=Math.floor(a);a-=c;var d=b[0===c?c:c-1],e=b[c],f=b[c>b.length-2?b.length-1:c+1],b=b[c>b.length-3?b.length-1:c+2],c=Xc.interpolate;return new B(c(d.x,e.x,f.x,b.x,a),c(d.y,e.y,f.y,b.y,a))};yb.prototype=Object.create(ia.prototype);
12367 yb.prototype.constructor=yb;yb.prototype.getPoint=function(a){var b=ra.b3;return new B(b(a,this.v0.x,this.v1.x,this.v2.x,this.v3.x),b(a,this.v0.y,this.v1.y,this.v2.y,this.v3.y))};yb.prototype.getTangent=function(a){var b=Xc.tangentCubicBezier;return(new B(b(a,this.v0.x,this.v1.x,this.v2.x,this.v3.x),b(a,this.v0.y,this.v1.y,this.v2.y,this.v3.y))).normalize()};zb.prototype=Object.create(ia.prototype);zb.prototype.constructor=zb;zb.prototype.getPoint=function(a){var b=ra.b2;return new B(b(a,this.v0.x,
12368 this.v1.x,this.v2.x),b(a,this.v0.y,this.v1.y,this.v2.y))};zb.prototype.getTangent=function(a){var b=Xc.tangentQuadraticBezier;return(new B(b(a,this.v0.x,this.v1.x,this.v2.x),b(a,this.v0.y,this.v1.y,this.v2.y))).normalize()};var de=Object.assign(Object.create(Oc.prototype),{fromPoints:function(a){this.moveTo(a[0].x,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 Sa(this.currentPoint.clone(),new B(a,b));
12369 this.curves.push(c);this.currentPoint.set(a,b)},quadraticCurveTo:function(a,b,c,d){a=new zb(this.currentPoint.clone(),new B(a,b),new B(c,d));this.curves.push(a);this.currentPoint.set(c,d)},bezierCurveTo:function(a,b,c,d,e,f){a=new yb(this.currentPoint.clone(),new B(a,b),new B(c,d),new B(e,f));this.curves.push(a);this.currentPoint.set(e,f)},splineThru:function(a){var b=[this.currentPoint.clone()].concat(a),b=new xb(b);this.curves.push(b);this.currentPoint.copy(a[a.length-1])},arc:function(a,b,c,d,
12370 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 Va(a,b,c,d,e,f,g,h);0<this.curves.length&&(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)}});Ab.prototype=Object.assign(Object.create(de),
12371 {constructor:Ab,getPointsHoles:function(a){for(var b=[],c=0,d=this.holes.length;c<d;c++)b[c]=this.holes[c].getPoints(a);return b},extractAllPoints:function(a){return{shape:this.getPoints(a),holes:this.getPointsHoles(a)}},extractPoints:function(a){return this.extractAllPoints(a)}});Pc.prototype=de;de.constructor=Pc;Kd.prototype={moveTo:function(a,b){this.currentPath=new Pc;this.subPaths.push(this.currentPath);this.currentPath.moveTo(a,b)},lineTo:function(a,b){this.currentPath.lineTo(a,b)},quadraticCurveTo:function(a,
12372 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 Ab;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,l=h.y-g.y;if(Math.abs(l)>Number.EPSILON){if(0>l&&(g=b[f],k=-k,h=b[e],l=-l),!(a.y<g.y||a.y>h.y))if(a.y===
12373 g.y){if(a.x===g.x)return!0}else{e=l*(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=ra.isClockWise,f=this.subPaths;if(0===f.length)return[];if(!0===b)return c(f);var g,h,k,l=[];if(1===f.length)return h=f[0],k=new Ab,k.curves=h.curves,l.push(k),l;var q=!e(f[0].getPoints()),q=a?!q:q;k=[];var n=[],p=[],r=0,x;n[r]=void 0;p[r]=[];for(var t=0,D=f.length;t<D;t++)h=f[t],x=h.getPoints(),g=e(x),(g=a?!g:g)?(!q&&n[r]&&r++,
12374 n[r]={s:new Ab,p:x},n[r].s.curves=h.curves,q&&r++,p[r]=[]):p[r].push({h:h,p:x[0]});if(!n[0])return c(f);if(1<n.length){t=!1;h=[];e=0;for(f=n.length;e<f;e++)k[e]=[];e=0;for(f=n.length;e<f;e++)for(g=p[e],q=0;q<g.length;q++){r=g[q];x=!0;for(D=0;D<n.length;D++)d(r.p,n[D].p)&&(e!==D&&h.push({froms:e,tos:D,hole:q}),x?(x=!1,k[D].push(r)):t=!0);x&&k[e].push(r)}0<h.length&&(t||(p=k))}t=0;for(e=n.length;t<e;t++)for(k=n[t].s,l.push(k),h=p[t],f=0,g=h.length;f<g;f++)k.holes.push(h[f].h);return l}};Object.assign(Ld.prototype,
12375 {isFont:!0,generateShapes:function(a,b,c){void 0===b&&(b=100);void 0===c&&(c=4);var d=this.data;a=String(a).split("");var e=b/d.resolution,f=0;b=[];for(var g=0;g<a.length;g++){var h;h=e;var k=f,l=d.glyphs[a[g]]||d.glyphs["?"];if(l){var q=new Kd,n=[],p=ra.b2,r=ra.b3,x,t,D,u,v,z,y,E;if(l.o)for(var B=l._cachedOutline||(l._cachedOutline=l.o.split(" ")),C=0,G=B.length;C<G;)switch(B[C++]){case "m":x=B[C++]*h+k;t=B[C++]*h;q.moveTo(x,t);break;case "l":x=B[C++]*h+k;t=B[C++]*h;q.lineTo(x,t);break;case "q":x=
12376 B[C++]*h+k;t=B[C++]*h;v=B[C++]*h+k;z=B[C++]*h;q.quadraticCurveTo(v,z,x,t);if(u=n[n.length-1]){D=u.x;u=u.y;for(var J=1;J<=c;J++){var K=J/c;p(K,D,v,x);p(K,u,z,t)}}break;case "b":if(x=B[C++]*h+k,t=B[C++]*h,v=B[C++]*h+k,z=B[C++]*h,y=B[C++]*h+k,E=B[C++]*h,q.bezierCurveTo(v,z,y,E,x,t),u=n[n.length-1])for(D=u.x,u=u.y,J=1;J<=c;J++)K=J/c,r(K,D,v,y,x),r(K,u,z,E,t)}h={offset:l.ha*h,path:q}}else h=void 0;f+=h.offset;b.push(h.path)}c=[];d=0;for(a=b.length;d<a;d++)Array.prototype.push.apply(c,b[d].toShapes());
12377 return c}});Object.assign(ye.prototype,{load:function(a,b,c,d){var e=this;(new Ja(this.manager)).load(a,function(a){var c;try{c=JSON.parse(a)}catch(d){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 Ld(a)}});var Nd;Object.assign(Od.prototype,{load:function(a,b,c,d){var e=new Ja(this.manager);e.setResponseType("arraybuffer");e.load(a,function(a){Md().decodeAudioData(a,
12378 function(a){b(a)})},c,d)}});Object.assign(ze.prototype,{update:function(){var a,b,c,d,e,f,g,h=new J,k=new J;return function(l){if(a!==this||b!==l.focus||c!==l.fov||d!==l.aspect*this.aspect||e!==l.near||f!==l.far||g!==l.zoom){a=this;b=l.focus;c=l.fov;d=l.aspect*this.aspect;e=l.near;f=l.far;g=l.zoom;var q=l.projectionMatrix.clone(),n=this.eyeSep/2,p=n*e/b,r=e*Math.tan(T.DEG2RAD*c*.5)/g,x;k.elements[12]=-n;h.elements[12]=n;n=-r*d+p;x=r*d+p;q.elements[0]=2*e/(x-n);q.elements[8]=(x+n)/(x-n);this.cameraL.projectionMatrix.copy(q);
12379 n=-r*d-p;x=r*d-p;q.elements[0]=2*e/(x-n);q.elements[8]=(x+n)/(x-n);this.cameraR.projectionMatrix.copy(q)}this.cameraL.matrixWorld.copy(l.matrixWorld).multiply(k);this.cameraR.matrixWorld.copy(l.matrixWorld).multiply(h)}}()});vd.prototype=Object.create(z.prototype);vd.prototype.constructor=vd;Pd.prototype=Object.assign(Object.create(z.prototype),{constructor:Pd,getInput:function(){return this.gain},removeFilter:function(){null!==this.filter&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),
12380 this.gain.connect(this.context.destination),this.filter=null)},getFilter:function(){return this.filter},setFilter:function(a){null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination);this.filter=a;this.gain.connect(this.filter);this.filter.connect(this.context.destination)},getMasterVolume:function(){return this.gain.gain.value},setMasterVolume:function(a){this.gain.gain.value=a},updateMatrixWorld:function(){var a=
12381 new q,b=new ba,c=new q,d=new q;return function(e){z.prototype.updateMatrixWorld.call(this,e);e=this.context.listener;var f=this.up;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,f.x,f.y,f.z)}}()});dc.prototype=Object.assign(Object.create(z.prototype),{constructor:dc,getOutput:function(){return this.gain},setNodeSource:function(a){this.hasPlaybackControl=!1;this.sourceType="audioNode";this.source=a;this.connect();return this},
12382 setBuffer:function(a){this.source.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.source.buffer;a.loop=this.source.loop;a.onended=this.source.onended;a.start(0,this.startTime);a.playbackRate.value=this.playbackRate;this.isPlaying=
12383 !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 this.source.stop(),this.startTime=this.context.currentTime,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(),this.startTime=0,this.isPlaying=!1,this},connect:function(){if(0<this.filters.length){this.source.connect(this.filters[0]);
12384 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]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this},
12385 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.");else return this.playbackRate=a,!0===this.isPlaying&&(this.source.playbackRate.value=this.playbackRate),
12386 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.source.loop},setLoop:function(a){!1===this.hasPlaybackControl?console.warn("THREE.Audio: this Audio has no playback control."):this.source.loop=a},getVolume:function(){return this.gain.gain.value},setVolume:function(a){this.gain.gain.value=a;return this}});Qd.prototype=Object.assign(Object.create(dc.prototype),
12387 {constructor:Qd,getOutput:function(){return this.panner},getRefDistance:function(){return this.panner.refDistance},setRefDistance:function(a){this.panner.refDistance=a},getRolloffFactor:function(){return this.panner.rolloffFactor},setRolloffFactor:function(a){this.panner.rolloffFactor=a},getDistanceModel:function(){return this.panner.distanceModel},setDistanceModel:function(a){this.panner.distanceModel=a},getMaxDistance:function(){return this.panner.maxDistance},setMaxDistance:function(a){this.panner.maxDistance=
12388 a},updateMatrixWorld:function(){var a=new q;return function(b){z.prototype.updateMatrixWorld.call(this,b);a.setFromMatrixPosition(this.matrixWorld);this.panner.setPosition(a.x,a.y,a.z)}}()});Object.assign(Rd.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}});wd.prototype={constructor:wd,accumulate:function(a,b){var c=this.buffer,d=
12389 this.valueSize,e=a*d+d,f=this.cumulativeWeight;if(0===f){for(f=0;f!==d;++f)c[e+f]=c[f];f=b}else f+=b,this._mixBufferRegion(c,e,0,b/f,d);this.cumulativeWeight=f},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);for(var d=b,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,c);for(var d=
12390 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,e){ba.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}}};fa.prototype={constructor:fa,getValue:function(a,b){this.bind();this.getValue(a,b)},setValue:function(a,b){this.bind();this.setValue(a,b)},bind:function(){var a=
12391 this.node,b=this.parsedPath,c=b.objectName,d=b.propertyName,e=b.propertyIndex;a||(this.node=a=fa.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(" can not bind to material as node does not have a material",this);return}if(!a.material.materials){console.error(" can not bind to material.materials as node.material does not have a materials array",
12392 this);return}a=a.material.materials;break;case "bones":if(!a.skeleton){console.error(" 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(" can not bind to objectName of node, undefined",this);return}a=a[c]}if(void 0!==f){if(void 0===a[f]){console.error(" trying to bind to objectIndex of objectName, but is undefined:",this,a);return}a=a[f]}}f=a[d];if(void 0===f)console.error(" trying to update property for track: "+
12393 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(" can not bind to morphTargetInfluences becasuse node does not have a geometry",this);return}if(!a.geometry.morphTargets){console.error(" can not bind to morphTargetInfluences becasuse node does not have a geometry.morphTargets",
12394 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):void 0!==f.length?(c=this.BindingType.EntireArray,this.resolvedProperty=f):this.propertyName=d;this.getValue=this.GetterByBindingType[c];this.setValue=this.SetterByBindingTypeAndVersioning[c][b]}}else console.error(" trying to update node for track: "+
12395 this.path+" but it wasn't found.")},unbind:function(){this.node=null;this.getValue=this._getValue_unbound;this.setValue=this._setValue_unbound}};Object.assign(fa.prototype,{_getValue_unavailable:function(){},_setValue_unavailable:function(){},_getValue_unbound:fa.prototype.getValue,_setValue_unbound:fa.prototype.setValue,BindingType:{Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},Versioning:{None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},GetterByBindingType:[function(a,b){a[b]=this.node[this.propertyName]},
12396 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.node[this.propertyName]=a[b]},function(a,b){this.node[this.propertyName]=a[b];this.targetObject.needsUpdate=!0},function(a,b){this.node[this.propertyName]=a[b];this.targetObject.matrixWorldNeedsUpdate=!0}],[function(a,b){for(var c=this.resolvedProperty,
12397 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,b){this.resolvedProperty[this.propertyIndex]=a[b];
12398 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}]]});fa.Composite=function(a,b,c){c=c||fa.parseTrackName(b);this._targetGroup=a;this._bindings=a.subscribe_(b,c)};fa.Composite.prototype={constructor:fa.Composite,getValue:function(a,b){this.bind();var c=this._bindings[this._targetGroup.nCachedObjects_];
12399 void 0!==c&&c.getValue(a,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()}};fa.create=function(a,b,c){return a&&a.isAnimationObjectGroup?new fa.Composite(a,b,c):new fa(a,b,c)};fa.parseTrackName=function(a){var b=
12400 /^((?:\w+[\/:])*)(\w+)?(?:\.(\w+)(?:\[(.+)\])?)?\.(\w+)(?:\[(.+)\])?$/.exec(a);if(!b)throw Error("cannot parse trackName at all: "+a);b={nodeName:b[2],objectName:b[3],objectIndex:b[4],propertyName:b[5],propertyIndex:b[6]};if(null===b.propertyName||0===b.propertyName.length)throw Error("can not parse propertyName from trackName: "+a);return b};fa.findNode=function(a,b){if(!b||""===b||"root"===b||"."===b||-1===b||b===a.name||b===a.uuid)return a;if(a.skeleton){var c=function(a){for(var c=0;c<a.bones.length;c++){var d=
12401 a.bones[c];if(d.name===b)return d}return null}(a.skeleton);if(c)return c}if(a.children){var d=function(a){for(var c=0;c<a.length;c++){var g=a[c];if(g.name===b||g.uuid===b||(g=d(g.children)))return g}return null};if(c=d(a.children))return c}return null};Sd.prototype={constructor:Sd,isAnimationObjectGroup:!0,add:function(a){for(var b=this._objects,c=b.length,d=this.nCachedObjects_,e=this._indicesByUUID,f=this._paths,g=this._parsedPaths,h=this._bindings,k=h.length,l=0,q=arguments.length;l!==q;++l){var n=
12402 arguments[l],p=n.uuid,r=e[p];if(void 0===r){r=c++;e[p]=r;b.push(n);for(var p=0,x=k;p!==x;++p)h[p].push(new fa(n,f[p],g[p]))}else if(r<d){var t=b[r],D=--d,x=b[D];e[x.uuid]=r;b[r]=x;e[p]=D;b[D]=n;p=0;for(x=k;p!==x;++p){var u=h[p],v=u[r];u[r]=u[D];void 0===v&&(v=new fa(n,f[p],g[p]));u[D]=v}}else b[r]!==t&&console.error("Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes...")}this.nCachedObjects_=d},remove:function(a){for(var b=this._objects,
12403 c=this.nCachedObjects_,d=this._indicesByUUID,e=this._bindings,f=e.length,g=0,h=arguments.length;g!==h;++g){var k=arguments[g],l=k.uuid,q=d[l];if(void 0!==q&&q>=c){var n=c++,p=b[n];d[p.uuid]=q;b[q]=p;d[l]=n;b[n]=k;k=0;for(l=f;k!==l;++k){var p=e[k],r=p[q];p[q]=p[n];p[n]=r}}}this.nCachedObjects_=c},uncache:function(a){for(var b=this._objects,c=b.length,d=this.nCachedObjects_,e=this._indicesByUUID,f=this._bindings,g=f.length,h=0,k=arguments.length;h!==k;++h){var l=arguments[h].uuid,q=e[l];if(void 0!==
12404 q)if(delete e[l],q<d){var l=--d,n=b[l],p=--c,r=b[p];e[n.uuid]=q;b[q]=n;e[r.uuid]=l;b[l]=r;b.pop();n=0;for(r=g;n!==r;++n){var x=f[n],t=x[p];x[q]=x[l];x[l]=t;x.pop()}}else for(p=--c,r=b[p],e[r.uuid]=q,b[q]=r,b.pop(),n=0,r=g;n!==r;++n)x=f[n],x[q]=x[p],x.pop()}this.nCachedObjects_=d},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_,l=Array(h.length),d=e.length;c[a]=
12405 d;f.push(a);g.push(b);e.push(l);c=k;for(d=h.length;c!==d;++c)l[c]=new fa(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()}}};Td.prototype={constructor:Td,play:function(){this._mixer._activateAction(this);return this},stop:function(){this._mixer._deactivateAction(this);return this.reset()},reset:function(){this.paused=
12406 !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;this._effectiveWeight=this.enabled?
12407 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;null!==a&&(this._weightInterpolant=
12408 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,0,a)},warp:function(a,
12409 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||
12410 this._mixer._root},_update:function(a,b,c,d){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;for(var e=this._propertyBindings,f=0,g=b.length;f!==g;++f)b[f].evaluate(c),e[f].accumulate(d,a)}},_updateWeight:function(a){var b=0;if(this.enabled){var b=this.weight,c=this._weightInterpolant;if(null!==c){var d=c.evaluate(a)[0],b=b*d;a>c.parameterPositions[1]&&
12411 (this.stopFading(),0===d&&(this.enabled=!1))}}return this._effectiveWeight=b},_updateTimeScale:function(a){var b=0;if(!this.paused){var b=this.timeScale,c=this._timeScaleInterpolant;if(null!==c){var d=c.evaluate(a)[0],b=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;if(0===a)return b;var c=this._clip.duration,d=this.loop,e=this._loopCount;if(2200===d)a:{if(-1===e&&(this.loopCount=
12412 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{d=2202===d;-1===e&&(0<=a?(e=0,this._setEndings(!0,0===this.repetitions,d)):this._setEndings(0===this.repetitions,!0,d));if(b>=c||0>b){var f=Math.floor(b/c),b=b-c*f,e=e+Math.abs(f),g=this.repetitions-e;0>g?(this.clampWhenFinished?this.paused=!0:this.enabled=!1,b=0<a?c:0,this._mixer.dispatchEvent({type:"finished",
12413 action:this,direction:0<a?1:-1})):(0===g?(a=0>a,this._setEndings(a,!a,d)):this._setEndings(!1,!1,d),this._loopCount=e,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:f}))}if(d&&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:2400:2402)},_scheduleFading:function(a,b,c){var d=this._mixer,e=d.time,
12414 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}};Object.assign(Ud.prototype,sa.prototype,{clipAction:function(a,b){var c=b||this._root,d=c.uuid,e="string"===typeof a?Ha.findByName(c,a):a,c=null!==e?e.uuid:a,f=this._actionsByClip[c],g=null;if(void 0!==f){g=f.actionByRoot[d];if(void 0!==g)return g;g=f.knownActions[0];null===e&&(e=g._clip)}if(null===e)return null;e=new Td(this,
12415 e,b);this._bindAction(e,g);this._addInactiveAction(e,c,d);return e},existingAction:function(a,b){var c=b||this._root,d=c.uuid,c="string"===typeof a?Ha.findByName(c,a):a,c=this._actionsByClip[c?c.uuid:a];return void 0!==c?c.actionByRoot[d]||null:null},stopAllAction:function(){for(var a=this._actions,b=this._nActiveActions,c=this._bindings,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*=
12416 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){var h=b[g];h.enabled&&h._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,d=c[a];if(void 0!==d){for(var d=d.knownActions,e=0,f=d.length;e!==f;++e){var g=d[e];this._deactivateAction(g);var h=g._cacheIndex,
12417 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,c;for(c in b){var d=b[c].actionByRoot[a];void 0!==d&&(this._deactivateAction(d),this._removeInactiveAction(d))}c=this._bindingsByRootAndName[a];if(void 0!==c)for(var e in c)a=c[e],a.restoreOriginalState(),this._removeInactiveBinding(a)},uncacheAction:function(a,b){var c=this.existingAction(a,b);
12418 null!==c&&(this._deactivateAction(c),this._removeInactiveAction(c))}});Object.assign(Ud.prototype,{_bindAction:function(a,b){var c=a._localRoot||this._root,d=a._clip.tracks,e=d.length,f=a._propertyBindings,g=a._interpolants,h=c.uuid,k=this._bindingsByRootAndName,l=k[h];void 0===l&&(l={},k[h]=l);for(k=0;k!==e;++k){var q=d[k],n=q.name,p=l[n];if(void 0===p){p=f[k];if(void 0!==p){null===p._cacheIndex&&(++p.referenceCount,this._addInactiveBinding(p,h,n));continue}p=new wd(fa.create(c,n,b&&b._propertyBindings[k].binding.parsedPath),
12419 q.ValueTypeName,q.getValueSize());++p.referenceCount;this._addInactiveBinding(p,h,n)}f[k]=p;g[k].resultBuffer=p.buffer}},_activateAction:function(a){if(!this._isActiveAction(a)){if(null===a._cacheIndex){var b=(a._localRoot||this._root).uuid,c=a._clip.uuid,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)}},
12420 _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=[];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},
12421 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}}}},_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=
12422 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;var c=a._clip.uuid,d=this._actionsByClip,e=d[c],f=e.knownActions,g=f[f.length-1],h=a._byClipCacheIndex;g._byClipCacheIndex=h;f[h]=g;f.pop();a._byClipCacheIndex=null;delete e.actionByRoot[(b._localRoot||this._root).uuid];0===f.length&&delete d[c];this._removeInactiveBindingsForAction(a)},
12423 _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,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,
12424 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,e=this._bindingsByRootAndName,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=
12425 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++,c=a[b];void 0===c&&(c=new Mc(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=
12426 d;b[d]=a;e.__cacheIndex=c;b[c]=e},_controlInterpolantsResultBuffer:new Float32Array(1)});Bb.prototype=Object.create(G.prototype);Bb.prototype.constructor=Bb;Bb.prototype.isInstancedBufferGeometry=!0;Bb.prototype.addGroup=function(a,b,c){this.groups.push({start:a,count:b,materialIndex:c})};Bb.prototype.copy=function(a){var b=a.index;null!==b&&this.setIndex(b.clone());var b=a.attributes,c;for(c in b)this.addAttribute(c,b[c].clone());a=a.groups;c=0;for(b=a.length;c<b;c++){var d=a[c];this.addGroup(d.start,
12427 d.count,d.materialIndex)}return this};Vd.prototype={constructor:Vd,isInterleavedBufferAttribute:!0,get count(){return this.data.count},get array(){return this.data.array},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},
12428 getX:function(a){return this.data.array[a*this.data.stride+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+
12429 1]=c;this.data.array[a+2]=d;return this},setXYZW:function(a,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}};ec.prototype={constructor:ec,isInterleavedBuffer:!0,set needsUpdate(a){!0===a&&this.version++},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},setDynamic:function(a){this.dynamic=
12430 a;return this},copy:function(a){this.array=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)}};fc.prototype=Object.create(ec.prototype);fc.prototype.constructor=fc;fc.prototype.isInstancedInterleavedBuffer=
12431 !0;fc.prototype.copy=function(a){ec.prototype.copy.call(this,a);this.meshPerAttribute=a.meshPerAttribute;return this};gc.prototype=Object.create(C.prototype);gc.prototype.constructor=gc;gc.prototype.isInstancedBufferAttribute=!0;gc.prototype.copy=function(a){C.prototype.copy.call(this,a);this.meshPerAttribute=a.meshPerAttribute;return this};Wd.prototype={constructor:Wd,linePrecision:1,set:function(a,b){this.ray.set(a,b)},setFromCamera:function(a,b){b&&b.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(b.matrixWorld),
12432 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){var c=[];Xd(a,this,c,b);c.sort(Be);return c},intersectObjects:function(a,b){var c=[];if(!1===Array.isArray(a))return console.warn("THREE.Raycaster.intersectObjects: objects is not an Array."),
12433 c;for(var d=0,e=a.length;d<e;d++)Xd(a[d],this,c,b);c.sort(Be);return c}};Yd.prototype={constructor:Yd,start:function(){this.oldTime=this.startTime=(performance||Date).now();this.elapsedTime=0;this.running=!0},stop:function(){this.getElapsedTime();this.running=!1},getElapsedTime:function(){this.getDelta();return this.elapsedTime},getDelta:function(){var a=0;this.autoStart&&!this.running&&this.start();if(this.running){var b=(performance||Date).now(),a=(b-this.oldTime)/1E3;this.oldTime=b;this.elapsedTime+=
12434 a}return a}};Zd.prototype={constructor:Zd,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-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(T.clamp(a.y/this.radius,
12435 -1,1)));return this}};na.prototype=Object.create(ya.prototype);na.prototype.constructor=na;na.prototype.createAnimation=function(a,b,c,d){b={start:b,end:c,length:c-b+1,fps:d,duration:(c-b)/d,lastFrame:0,currentFrame:0,active:!1,time:0,direction:1,weight:1,directionBackwards:!1,mirroredLoop:!1};this.animationsMap[a]=b;this.animationsList.push(b)};na.prototype.autoCreateAnimations=function(a){for(var b=/([a-z]+)_?(\d+)/i,c,d={},e=this.geometry,f=0,g=e.morphTargets.length;f<g;f++){var h=e.morphTargets[f].name.match(b);
12436 if(h&&1<h.length){var k=h[1];d[k]||(d[k]={start:Infinity,end:-Infinity});h=d[k];f<h.start&&(h.start=f);f>h.end&&(h.end=f);c||(c=k)}}for(k in d)h=d[k],this.createAnimation(k,h.start,h.end,a);this.firstAnimation=c};na.prototype.setAnimationDirectionForward=function(a){if(a=this.animationsMap[a])a.direction=1,a.directionBackwards=!1};na.prototype.setAnimationDirectionBackward=function(a){if(a=this.animationsMap[a])a.direction=-1,a.directionBackwards=!0};na.prototype.setAnimationFPS=function(a,b){var c=
12437 this.animationsMap[a];c&&(c.fps=b,c.duration=(c.end-c.start)/c.fps)};na.prototype.setAnimationDuration=function(a,b){var c=this.animationsMap[a];c&&(c.duration=b,c.fps=(c.end-c.start)/c.duration)};na.prototype.setAnimationWeight=function(a,b){var c=this.animationsMap[a];c&&(c.weight=b)};na.prototype.setAnimationTime=function(a,b){var c=this.animationsMap[a];c&&(c.time=b)};na.prototype.getAnimationTime=function(a){var b=0;if(a=this.animationsMap[a])b=a.time;return b};na.prototype.getAnimationDuration=
12438 function(a){var b=-1;if(a=this.animationsMap[a])b=a.duration;return b};na.prototype.playAnimation=function(a){var b=this.animationsMap[a];b?(b.time=0,b.active=!0):console.warn("THREE.MorphBlendMesh: animation["+a+"] undefined in .playAnimation()")};na.prototype.stopAnimation=function(a){if(a=this.animationsMap[a])a.active=!1};na.prototype.update=function(a){for(var b=0,c=this.animationsList.length;b<c;b++){var d=this.animationsList[b];if(d.active){var e=d.duration/d.length;d.time+=d.direction*a;if(d.mirroredLoop){if(d.time>
12439 d.duration||0>d.time)d.direction*=-1,d.time>d.duration&&(d.time=d.duration,d.directionBackwards=!0),0>d.time&&(d.time=0,d.directionBackwards=!1)}else d.time%=d.duration,0>d.time&&(d.time+=d.duration);var f=d.start+T.clamp(Math.floor(d.time/e),0,d.length-1),g=d.weight;f!==d.currentFrame&&(this.morphTargetInfluences[d.lastFrame]=0,this.morphTargetInfluences[d.currentFrame]=1*g,this.morphTargetInfluences[f]=0,d.lastFrame=d.currentFrame,d.currentFrame=f);e=d.time%e/e;d.directionBackwards&&(e=1-e);d.currentFrame!==
12440 d.lastFrame?(this.morphTargetInfluences[d.currentFrame]=e*g,this.morphTargetInfluences[d.lastFrame]=(1-e)*g):this.morphTargetInfluences[d.currentFrame]=g}}};Qc.prototype=Object.create(z.prototype);Qc.prototype.constructor=Qc;Qc.prototype.isImmediateRenderObject=!0;Rc.prototype=Object.create(la.prototype);Rc.prototype.constructor=Rc;Rc.prototype.update=function(){var a=new q,b=new q,c=new Ia;return function(){var d=["a","b","c"];this.object.updateMatrixWorld(!0);c.getNormalMatrix(this.object.matrixWorld);
12441 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,q=k.length;l<q;l++)for(var n=k[l],p=0,r=n.vertexNormals.length;p<r;p++){var x=n.vertexNormals[p];a.copy(h[n[d[p]]]).applyMatrix4(e);b.copy(x).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=g.attributes.position,h=g.attributes.normal,p=g=0,r=d.count;p<
12442 r;p++)a.set(d.getX(p),d.getY(p),d.getZ(p)).applyMatrix4(e),b.set(h.getX(p),h.getY(p),h.getZ(p)),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;return this}}();hc.prototype=Object.create(z.prototype);hc.prototype.constructor=hc;hc.prototype.dispose=function(){this.cone.geometry.dispose();this.cone.material.dispose()};hc.prototype.update=function(){var a=new q,b=new q;return function(){var c=this.light.distance?
12443 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));this.cone.material.color.copy(this.light.color).multiplyScalar(this.light.intensity)}}();ic.prototype=Object.create(la.prototype);ic.prototype.constructor=ic;ic.prototype.getBoneList=function(a){var b=[];a&&a.isBone&&b.push(a);for(var c=0;c<a.children.length;c++)b.push.apply(b,this.getBoneList(a.children[c]));
12444 return b};ic.prototype.update=function(){for(var a=this.geometry,b=(new J).getInverse(this.root.matrixWorld),c=new J,d=0,e=0;e<this.bones.length;e++){var f=this.bones[e];f.parent&&f.parent.isBone&&(c.multiplyMatrices(b,f.matrixWorld),a.vertices[d].setFromMatrixPosition(c),c.multiplyMatrices(b,f.parent.matrixWorld),a.vertices[d+1].setFromMatrixPosition(c),d+=2)}a.verticesNeedUpdate=!0;a.computeBoundingSphere()};jc.prototype=Object.create(ya.prototype);jc.prototype.constructor=jc;jc.prototype.dispose=
12445 function(){this.geometry.dispose();this.material.dispose()};jc.prototype.update=function(){this.material.color.copy(this.light.color).multiplyScalar(this.light.intensity)};kc.prototype=Object.create(z.prototype);kc.prototype.constructor=kc;kc.prototype.dispose=function(){this.lightSphere.geometry.dispose();this.lightSphere.material.dispose()};kc.prototype.update=function(){var a=new q;return function(){this.colors[0].copy(this.light.color).multiplyScalar(this.light.intensity);this.colors[1].copy(this.light.groundColor).multiplyScalar(this.light.intensity);
12446 this.lightSphere.lookAt(a.setFromMatrixPosition(this.light.matrixWorld).negate());this.lightSphere.geometry.colorsNeedUpdate=!0}}();Sc.prototype=Object.create(la.prototype);Sc.prototype.constructor=Sc;Sc.prototype.setColors=function(){console.error("THREE.GridHelper: setColors() has been deprecated, pass them in the constructor instead.")};Tc.prototype=Object.create(la.prototype);Tc.prototype.constructor=Tc;Tc.prototype.update=function(){var a=new q,b=new q,c=new Ia;return function(){this.object.updateMatrixWorld(!0);
12447 c.getNormalMatrix(this.object.matrixWorld);for(var d=this.object.matrixWorld,e=this.geometry.attributes.position,f=this.object.geometry,g=f.vertices,f=f.faces,h=0,k=0,l=f.length;k<l;k++){var q=f[k],n=q.normal;a.copy(g[q.a]).add(g[q.b]).add(g[q.c]).divideScalar(3).applyMatrix4(d);b.copy(n).applyMatrix3(c).normalize().multiplyScalar(this.size).add(a);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;return this}}();lc.prototype=Object.create(z.prototype);lc.prototype.constructor=
12448 lc;lc.prototype.dispose=function(){var a=this.children[0],b=this.children[1];a.geometry.dispose();a.material.dispose();b.geometry.dispose();b.material.dispose()};lc.prototype.update=function(){var a=new q,b=new q,c=new q;return function(){a.setFromMatrixPosition(this.light.matrixWorld);b.setFromMatrixPosition(this.light.target.matrixWorld);c.subVectors(b,a);var d=this.children[0],e=this.children[1];d.lookAt(c);d.material.color.copy(this.light.color).multiplyScalar(this.light.intensity);e.lookAt(c);
12449 e.scale.z=c.length()}}();Uc.prototype=Object.create(la.prototype);Uc.prototype.constructor=Uc;Uc.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=0,h=a.length;g<h;g++)b.vertices[a[g]].copy(d)}var b,c,d=new q,e=new Z;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",
12450 -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",0,1,-1);b.verticesNeedUpdate=!0}}();Vc.prototype=Object.create(ya.prototype);Vc.prototype.constructor=Vc;Vc.prototype.update=function(){this.box.setFromObject(this.object);this.box.getSize(this.scale);this.box.getCenter(this.position)};Wc.prototype=Object.create(la.prototype);Wc.prototype.constructor=Wc;Wc.prototype.update=
12451 function(){var a=new Ba;return function(b){b&&b.isBox3?a.copy(b):a.setFromObject(b);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]=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()}}}();var Ce=new G;Ce.addAttribute("position",new ha([0,
12452 0,0,0,1,0],3));var De=new Ua(0,.5,1,5,1);De.translate(0,-.5,0);Cb.prototype=Object.create(z.prototype);Cb.prototype.constructor=Cb;Cb.prototype.setDirection=function(){var a=new q,b;return function(c){.99999<c.y?this.quaternion.set(0,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))}}();Cb.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();
12453 this.cone.scale.set(c,b,c);this.cone.position.y=a;this.cone.updateMatrix()};Cb.prototype.setColor=function(a){this.line.material.color.copy(a);this.cone.material.color.copy(a)};xd.prototype=Object.create(la.prototype);xd.prototype.constructor=xd;var $d=function(){function a(){}var b=new q,c=new a,d=new a,e=new a;a.prototype.init=function(a,b,c,d){this.c0=a;this.c1=c;this.c2=-3*a+3*b-2*c-d;this.c3=2*a-2*b+c+d};a.prototype.initNonuniformCatmullRom=function(a,b,c,d,e,l,n){this.init(b,c,((b-a)/e-(c-a)/
12454 (e+l)+(c-b)/l)*l,((c-b)/l-(d-b)/(l+n)+(d-c)/n)*l)};a.prototype.initCatmullRom=function(a,b,c,d,e){this.init(b,c,e*(c-a),e*(d-b))};a.prototype.calc=function(a){var b=a*a;return this.c0+this.c1*a+this.c2*b+this.c3*b*a};return ia.create(function(a){this.points=a||[];this.closed=!1},function(a){var g=this.points,h,k;k=g.length;2>k&&console.log("duh, you need at least 2 points");a*=k-(this.closed?0:1);h=Math.floor(a);a-=h;this.closed?h+=0<h?0:(Math.floor(Math.abs(h)/g.length)+1)*g.length:0===a&&h===k-
12455 1&&(h=k-2,a=1);var l,w,n;this.closed||0<h?l=g[(h-1)%k]:(b.subVectors(g[0],g[1]).add(g[0]),l=b);w=g[h%k];n=g[(h+1)%k];this.closed||h+2<k?g=g[(h+2)%k]:(b.subVectors(g[k-1],g[k-2]).add(g[k-1]),g=b);if(void 0===this.type||"centripetal"===this.type||"chordal"===this.type){var p="chordal"===this.type?.5:.25;k=Math.pow(l.distanceToSquared(w),p);h=Math.pow(w.distanceToSquared(n),p);p=Math.pow(n.distanceToSquared(g),p);1E-4>h&&(h=1);1E-4>k&&(k=h);1E-4>p&&(p=h);c.initNonuniformCatmullRom(l.x,w.x,n.x,g.x,k,
12456 h,p);d.initNonuniformCatmullRom(l.y,w.y,n.y,g.y,k,h,p);e.initNonuniformCatmullRom(l.z,w.z,n.z,g.z,k,h,p)}else"catmullrom"===this.type&&(k=void 0!==this.tension?this.tension:.5,c.initCatmullRom(l.x,w.x,n.x,g.x,k),d.initCatmullRom(l.y,w.y,n.y,g.y,k),e.initCatmullRom(l.z,w.z,n.z,g.z,k));return new q(c.calc(a),d.calc(a),e.calc(a))})}();Ee.prototype=Object.create($d.prototype);var Ef=ia.create(function(a){console.warn("THREE.SplineCurve3 will be deprecated. Please use THREE.CatmullRomCurve3");this.points=
12457 void 0===a?[]:a},function(a){var b=this.points;a*=b.length-1;var c=Math.floor(a);a-=c;var d=b[0==c?c:c-1],e=b[c],f=b[c>b.length-2?b.length-1:c+1],b=b[c>b.length-3?b.length-1:c+2],c=Xc.interpolate;return new q(c(d.x,e.x,f.x,b.x,a),c(d.y,e.y,f.y,b.y,a),c(d.z,e.z,f.z,b.z,a))}),Ff=ia.create(function(a,b,c,d){this.v0=a;this.v1=b;this.v2=c;this.v3=d},function(a){var b=ra.b3;return new q(b(a,this.v0.x,this.v1.x,this.v2.x,this.v3.x),b(a,this.v0.y,this.v1.y,this.v2.y,this.v3.y),b(a,this.v0.z,this.v1.z,this.v2.z,
12458 this.v3.z))}),Gf=ia.create(function(a,b,c){this.v0=a;this.v1=b;this.v2=c},function(a){var b=ra.b2;return new q(b(a,this.v0.x,this.v1.x,this.v2.x),b(a,this.v0.y,this.v1.y,this.v2.y),b(a,this.v0.z,this.v1.z,this.v2.z))}),Hf=ia.create(function(a,b){this.v1=a;this.v2=b},function(a){if(1===a)return this.v2.clone();var b=new q;b.subVectors(this.v2,this.v1);b.multiplyScalar(a);b.add(this.v1);return b});yd.prototype=Object.create(Va.prototype);yd.prototype.constructor=yd;Object.assign(mc.prototype,{center:function(a){console.warn("THREE.Box2: .center() has been renamed to .getCenter().");
12459 return this.getCenter(a)},empty:function(){console.warn("THREE.Box2: .empty() has been renamed to .isEmpty().");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(Ba.prototype,{center:function(a){console.warn("THREE.Box3: .center() has been renamed to .getCenter().");
12460 return this.getCenter(a)},empty:function(){console.warn("THREE.Box3: .empty() has been renamed to .isEmpty().");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().");
12461 return this.getSize(a)}});Object.assign(gb.prototype,{center:function(a){console.warn("THREE.Line3: .center() has been renamed to .getCenter().");return this.getCenter(a)}});Object.assign(Ia.prototype,{multiplyVector3:function(a){console.warn("THREE.Matrix3: .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead.");return a.applyMatrix3(this)},multiplyVector3Array:function(a){console.warn("THREE.Matrix3: .multiplyVector3Array() has been renamed. Use matrix.applyToVector3Array( array ) instead.");
12462 return this.applyToVector3Array(a)}});Object.assign(J.prototype,{extractPosition:function(a){console.warn("THREE.Matrix4: .extractPosition() has been renamed to .copyPosition().");return this.copyPosition(a)},setRotationFromQuaternion:function(a){console.warn("THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion().");return this.makeRotationFromQuaternion(a)},multiplyVector3:function(a){console.warn("THREE.Matrix4: .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) or vector.applyProjection( matrix ) instead.");
12463 return a.applyProjection(this)},multiplyVector4:function(a){console.warn("THREE.Matrix4: .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead.");return a.applyMatrix4(this)},multiplyVector3Array:function(a){console.warn("THREE.Matrix4: .multiplyVector3Array() has been renamed. Use matrix.applyToVector3Array( array ) instead.");return this.applyToVector3Array(a)},rotateAxis:function(a){console.warn("THREE.Matrix4: .rotateAxis() has been removed. Use Vector3.transformDirection( matrix ) instead.");
12464 a.transformDirection(this)},crossVector:function(a){console.warn("THREE.Matrix4: .crossVector() has been removed. Use vector.applyMatrix4( matrix ) instead.");return a.applyMatrix4(this)},translate:function(a){console.error("THREE.Matrix4: .translate() has been removed.")},rotateX:function(a){console.error("THREE.Matrix4: .rotateX() has been removed.")},rotateY:function(a){console.error("THREE.Matrix4: .rotateY() has been removed.")},rotateZ:function(a){console.error("THREE.Matrix4: .rotateZ() has been removed.")},
12465 rotateByAxis:function(a,b){console.error("THREE.Matrix4: .rotateByAxis() has been removed.")}});Object.assign(va.prototype,{isIntersectionLine:function(a){console.warn("THREE.Plane: .isIntersectionLine() has been renamed to .intersectsLine().");return this.intersectsLine(a)}});Object.assign(ba.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(ab.prototype,
12466 {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)},isIntersectionSphere:function(a){console.warn("THREE.Ray: .isIntersectionSphere() has been renamed to .intersectsSphere().");return this.intersectsSphere(a)}});Object.assign(Ab.prototype,{extrude:function(a){console.warn("THREE.Shape: .extrude() has been removed. Use ExtrudeGeometry() instead.");
12467 return new za(this,a)},makeGeometry:function(a){console.warn("THREE.Shape: .makeGeometry() has been removed. Use ShapeGeometry() instead.");return new cb(this,a)}});Object.assign(q.prototype,{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.")},
12468 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().");return this.setFromMatrixScale(a)},getColumnFromMatrix:function(a,b){console.warn("THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn().");return this.setFromMatrixColumn(b,
12469 a)}});Object.assign(z.prototype,{getChildByName:function(a){console.warn("THREE.Object3D: .getChildByName() has been renamed to .getObjectByName().");return this.getObjectByName(a)},renderDepth:function(a){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)}});Object.defineProperties(z.prototype,
12470 {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(a){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")}}});
12471 Object.defineProperties(rc.prototype,{objects:{get:function(){console.warn("THREE.LOD: .objects has been renamed to .levels.");return this.levels}}});Ea.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(pa.prototype,{onlyShadow:{set:function(a){console.warn("THREE.Light: .onlyShadow has been removed.")}},shadowCameraFov:{set:function(a){console.warn("THREE.Light: .shadowCameraFov is now .shadow.camera.fov.");
12472 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.");
12473 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(a){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.");
12474 this.shadow.bias=a}},shadowDarkness:{set:function(a){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(C.prototype,{length:{get:function(){console.warn("THREE.BufferAttribute: .length has been deprecated. Please use .count.");
12475 return this.array.length}}});Object.assign(G.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)},clearDrawCalls:function(){console.warn("THREE.BufferGeometry: .clearDrawCalls() is now .clearGroups().");
12476 this.clearGroups()},computeTangents:function(){console.warn("THREE.BufferGeometry: .computeTangents() has been removed.")},computeOffsets:function(){console.warn("THREE.BufferGeometry: .computeOffsets() has been removed.")}});Object.defineProperties(G.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.");return this.groups}}});
12477 Object.defineProperties(U.prototype,{wrapAround:{get:function(){console.warn("THREE."+this.type+": .wrapAround has been removed.")},set:function(a){console.warn("THREE."+this.type+": .wrapAround has been removed.")}},wrapRGB:{get:function(){console.warn("THREE."+this.type+": .wrapRGB has been removed.");return new O}}});Object.defineProperties(db.prototype,{metal:{get:function(){console.warn("THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead.");return!1},set:function(a){console.warn("THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead")}}});
12478 Object.defineProperties(Fa.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}}});sa.prototype=Object.assign(Object.create({constructor:sa,apply:function(a){console.warn("THREE.EventDispatcher: .apply is deprecated, just inherit or Object.assign the prototype to mix-in.");
12479 Object.assign(a,this)}}),sa.prototype);Object.defineProperties(Ae.prototype,{dynamic:{set:function(a){console.warn("THREE.Uniform: .dynamic has been removed. Use object.onBeforeRender() instead.")}},onUpdate:{value:function(){console.warn("THREE.Uniform: .onUpdate() has been removed. Use object.onBeforeRender() instead.");return this}}});Object.assign(Dd.prototype,{supportsFloatTextures:function(){console.warn("THREE.WebGLRenderer: .supportsFloatTextures() is now .extensions.get( 'OES_texture_float' ).");
12480 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' ).");
12481 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(){return this.capabilities.vertexTextures},
12482 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.")},
12483 addPostPlugin:function(){console.warn("THREE.WebGLRenderer: .addPostPlugin() has been removed.")},updateShadowMap:function(){console.warn("THREE.WebGLRenderer: .updateShadowMap() has been removed.")}});Object.defineProperties(Dd.prototype,{shadowMapEnabled:{get:function(){return this.shadowMap.enabled},set:function(a){console.warn("THREE.WebGLRenderer: .shadowMapEnabled is now .shadowMap.enabled.");this.shadowMap.enabled=a}},shadowMapType:{get:function(){return this.shadowMap.type},set:function(a){console.warn("THREE.WebGLRenderer: .shadowMapType is now .shadowMap.type.");
12484 this.shadowMap.type=a}},shadowMapCullFace:{get:function(){return this.shadowMap.cullFace},set:function(a){console.warn("THREE.WebGLRenderer: .shadowMapCullFace is now .shadowMap.cullFace.");this.shadowMap.cullFace=a}}});Object.defineProperties(pe.prototype,{cullFace:{get:function(){return this.renderReverseSided?2:1},set:function(a){a=1!==a;console.warn("WebGLRenderer: .shadowMap.cullFace is deprecated. Set .shadowMap.renderReverseSided to "+a+".");this.renderReverseSided=a}}});Object.defineProperties(Db.prototype,
12485 {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.");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.");
12486 return this.texture.magFilter},set:function(a){console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter.");this.texture.magFilter=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.");
12487 return this.texture.anisotropy},set:function(a){console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy.");this.texture.anisotropy=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},
12488 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.");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.");
12489 this.texture.type=a}},generateMipmaps:{get:function(){console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps.");return this.texture.generateMipmaps},set:function(a){console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps.");this.texture.generateMipmaps=a}}});Object.assign(dc.prototype,{load:function(a){console.warn("THREE.Audio: .load has been deprecated. Please use THREE.AudioLoader.");var b=this;(new Od).load(a,function(a){b.setBuffer(a)});
12490 return this}});Object.assign(Rd.prototype,{getData:function(a){console.warn("THREE.AudioAnalyser: .getData() is now .getFrequencyData().");return this.getFrequencyData()}});l.WebGLRenderTargetCube=Eb;l.WebGLRenderTarget=Db;l.WebGLRenderer=Dd;l.ShaderLib=Gb;l.UniformsLib=W;l.UniformsUtils=La;l.ShaderChunk=X;l.FogExp2=Ib;l.Fog=Jb;l.Scene=jb;l.LensFlare=Ed;l.Sprite=qc;l.LOD=rc;l.SkinnedMesh=dd;l.Skeleton=bd;l.Bone=cd;l.Mesh=ya;l.LineSegments=la;l.Line=Ta;l.Points=Kb;l.Group=sc;l.VideoTexture=ed;l.DataTexture=
12491 lb;l.CompressedTexture=Lb;l.CubeTexture=Xa;l.CanvasTexture=fd;l.DepthTexture=tc;l.TextureIdCount=function(){return ee++};l.Texture=da;l.MaterialIdCount=function(){return oe++};l.CompressedTextureLoader=we;l.BinaryTextureLoader=Gd;l.DataTextureLoader=Gd;l.CubeTextureLoader=Hd;l.TextureLoader=gd;l.ObjectLoader=xe;l.MaterialLoader=ud;l.BufferGeometryLoader=Id;l.DefaultLoadingManager=Ga;l.LoadingManager=Fd;l.JSONLoader=Jd;l.ImageLoader=Lc;l.FontLoader=ye;l.XHRLoader=Ja;l.Loader=wb;l.Cache=ce;l.AudioLoader=
12492 Od;l.SpotLightShadow=id;l.SpotLight=jd;l.PointLight=kd;l.HemisphereLight=hd;l.DirectionalLightShadow=ld;l.DirectionalLight=md;l.AmbientLight=nd;l.LightShadow=tb;l.Light=pa;l.StereoCamera=ze;l.PerspectiveCamera=Ea;l.OrthographicCamera=Hb;l.CubeCamera=vd;l.Camera=Z;l.AudioListener=Pd;l.PositionalAudio=Qd;l.getAudioContext=Md;l.AudioAnalyser=Rd;l.Audio=dc;l.VectorKeyframeTrack=bc;l.StringKeyframeTrack=rd;l.QuaternionKeyframeTrack=Nc;l.NumberKeyframeTrack=cc;l.ColorKeyframeTrack=td;l.BooleanKeyframeTrack=
12493 sd;l.PropertyMixer=wd;l.PropertyBinding=fa;l.KeyframeTrack=vb;l.AnimationUtils=ma;l.AnimationObjectGroup=Sd;l.AnimationMixer=Ud;l.AnimationClip=Ha;l.Uniform=Ae;l.InstancedBufferGeometry=Bb;l.BufferGeometry=G;l.GeometryIdCount=function(){return ad++};l.Geometry=Q;l.InterleavedBufferAttribute=Vd;l.InstancedInterleavedBuffer=fc;l.InterleavedBuffer=ec;l.InstancedBufferAttribute=gc;l.DynamicBufferAttribute=function(a,b){console.warn("THREE.DynamicBufferAttribute has been removed. Use new THREE.BufferAttribute().setDynamic( true ) instead.");
12494 return(new C(a,b)).setDynamic(!0)};l.Float64Attribute=function(a,b){return new C(new Float64Array(a),b)};l.Float32Attribute=ha;l.Uint32Attribute=$c;l.Int32Attribute=function(a,b){return new C(new Int32Array(a),b)};l.Uint16Attribute=Zc;l.Int16Attribute=function(a,b){return new C(new Int16Array(a),b)};l.Uint8ClampedAttribute=function(a,b){return new C(new Uint8ClampedArray(a),b)};l.Uint8Attribute=function(a,b){return new C(new Uint8Array(a),b)};l.Int8Attribute=function(a,b){return new C(new Int8Array(a),
12495 b)};l.BufferAttribute=C;l.Face3=ea;l.Object3DIdCount=function(){return qe++};l.Object3D=z;l.Raycaster=Wd;l.Layers=Yc;l.EventDispatcher=sa;l.Clock=Yd;l.QuaternionLinearInterpolant=qd;l.LinearInterpolant=Mc;l.DiscreteInterpolant=pd;l.CubicInterpolant=od;l.Interpolant=qa;l.Triangle=wa;l.Spline=function(a){function b(a,b,c,d,e,f,g){a=.5*(c-a);d=.5*(d-b);return(2*(b-c)+a+d)*g+(-3*(b-c)-2*a-d)*f+a*e+b}this.points=a;var c=[],d={x:0,y:0,z:0},e,f,g,h,k,l,w,n,p;this.initFromArray=function(a){this.points=[];
12496 for(var b=0;b<a.length;b++)this.points[b]={x:a[b][0],y:a[b][1],z:a[b][2]}};this.getPoint=function(a){e=(this.points.length-1)*a;f=Math.floor(e);g=e-f;c[0]=0===f?f:f-1;c[1]=f;c[2]=f>this.points.length-2?this.points.length-1:f+1;c[3]=f>this.points.length-3?this.points.length-1:f+2;l=this.points[c[0]];w=this.points[c[1]];n=this.points[c[2]];p=this.points[c[3]];h=g*g;k=g*h;d.x=b(l.x,w.x,n.x,p.x,g,h,k);d.y=b(l.y,w.y,n.y,p.y,g,h,k);d.z=b(l.z,w.z,n.z,p.z,g,h,k);return d};this.getControlPointsArray=function(){var a,
12497 b,c=this.points.length,d=[];for(a=0;a<c;a++)b=this.points[a],d[a]=[b.x,b.y,b.z];return d};this.getLength=function(a){var b,c,d,e=0,f=new q,g=new q,h=[],k=0;h[0]=0;a||(a=100);c=this.points.length*a;f.copy(this.points[0]);for(a=1;a<c;a++)b=a/c,d=this.getPoint(b),g.copy(d),k+=g.distanceTo(f),f.copy(d),b*=this.points.length-1,b=Math.floor(b),b!==e&&(h[b]=k,e=b);h[h.length]=k;return{chunks:h,total:k}};this.reparametrizeByArcLength=function(a){var b,c,d,e,f,g,h=[],k=new q,l=this.getLength();h.push(k.copy(this.points[0]).clone());
12498 for(b=1;b<this.points.length;b++){c=l.chunks[b]-l.chunks[b-1];g=Math.ceil(a*c/l.total);e=(b-1)/(this.points.length-1);f=b/(this.points.length-1);for(c=1;c<g-1;c++)d=e+1/g*c*(f-e),d=this.getPoint(d),h.push(k.copy(d).clone());h.push(k.copy(this.points[b]).clone())}this.points=h}};l.Math=T;l.Spherical=Zd;l.Plane=va;l.Frustum=nc;l.Sphere=Ca;l.Ray=ab;l.Matrix4=J;l.Matrix3=Ia;l.Box3=Ba;l.Box2=mc;l.Line3=gb;l.Euler=bb;l.Vector4=ga;l.Vector3=q;l.Vector2=B;l.Quaternion=ba;l.ColorKeywords=He;l.Color=O;l.MorphBlendMesh=
12499 na;l.ImmediateRenderObject=Qc;l.VertexNormalsHelper=Rc;l.SpotLightHelper=hc;l.SkeletonHelper=ic;l.PointLightHelper=jc;l.HemisphereLightHelper=kc;l.GridHelper=Sc;l.FaceNormalsHelper=Tc;l.DirectionalLightHelper=lc;l.CameraHelper=Uc;l.BoundingBoxHelper=Vc;l.BoxHelper=Wc;l.ArrowHelper=Cb;l.AxisHelper=xd;l.ClosedSplineCurve3=Ee;l.CatmullRomCurve3=$d;l.SplineCurve3=Ef;l.CubicBezierCurve3=Ff;l.QuadraticBezierCurve3=Gf;l.LineCurve3=Hf;l.ArcCurve=yd;l.EllipseCurve=Va;l.SplineCurve=xb;l.CubicBezierCurve=yb;
12500 l.QuadraticBezierCurve=zb;l.LineCurve=Sa;l.Shape=Ab;l.ShapePath=Kd;l.Path=Pc;l.Font=Ld;l.CurvePath=Oc;l.Curve=ia;l.ShapeUtils=ra;l.SceneUtils={createMultiMaterialObject:function(a,b){for(var c=new sc,d=0,e=b.length;d<e;d++)c.add(new ya(a,b[d]));return c},detach:function(a,b,c){a.applyMatrix(b.matrixWorld);b.remove(a);c.add(a)},attach:function(a,b,c){var d=new J;d.getInverse(c.matrixWorld);a.applyMatrix(d);b.remove(a);c.add(a)}};l.CurveUtils=Xc;l.WireframeGeometry=Mb;l.ParametricGeometry=uc;l.ParametricBufferGeometry=
12501 Nb;l.TetrahedronGeometry=vc;l.TetrahedronBufferGeometry=Ob;l.OctahedronGeometry=wc;l.OctahedronBufferGeometry=Pb;l.IcosahedronGeometry=xc;l.IcosahedronBufferGeometry=Qb;l.DodecahedronGeometry=yc;l.DodecahedronBufferGeometry=Rb;l.PolyhedronGeometry=zc;l.PolyhedronBufferGeometry=ua;l.TubeGeometry=Ac;l.TubeBufferGeometry=Sb;l.TorusKnotGeometry=Bc;l.TorusKnotBufferGeometry=Tb;l.TorusGeometry=Cc;l.TorusBufferGeometry=Ub;l.TextGeometry=Dc;l.SphereBufferGeometry=mb;l.SphereGeometry=Vb;l.RingGeometry=Ec;
12502 l.RingBufferGeometry=Wb;l.PlaneBufferGeometry=ib;l.PlaneGeometry=Fc;l.LatheGeometry=Gc;l.LatheBufferGeometry=Xb;l.ShapeGeometry=cb;l.ExtrudeGeometry=za;l.EdgesGeometry=Yb;l.ConeGeometry=Hc;l.ConeBufferGeometry=Ic;l.CylinderGeometry=nb;l.CylinderBufferGeometry=Ua;l.CircleBufferGeometry=Zb;l.CircleGeometry=Jc;l.BoxBufferGeometry=hb;l.BoxGeometry=ob;l.ShadowMaterial=$b;l.SpriteMaterial=kb;l.RawShaderMaterial=ac;l.ShaderMaterial=Fa;l.PointsMaterial=xa;l.MultiMaterial=Kc;l.MeshPhysicalMaterial=pb;l.MeshStandardMaterial=
12503 Oa;l.MeshPhongMaterial=db;l.MeshNormalMaterial=qb;l.MeshLambertMaterial=rb;l.MeshDepthMaterial=Za;l.MeshBasicMaterial=Ma;l.LineDashedMaterial=sb;l.LineBasicMaterial=oa;l.Material=U;l.REVISION="82";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=2;l.NoColors=0;
12504 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.BlendingMode=Fe;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=
12505 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=
12506 305;l.CubeUVReflectionMapping=306;l.CubeUVRefractionMapping=307;l.TextureMapping=Ge;l.RepeatWrapping=1E3;l.ClampToEdgeWrapping=1001;l.MirroredRepeatWrapping=1002;l.TextureWrapping=ae;l.NearestFilter=1003;l.NearestMipMapNearestFilter=1004;l.NearestMipMapLinearFilter=1005;l.LinearFilter=1006;l.LinearMipMapNearestFilter=1007;l.LinearMipMapLinearFilter=1008;l.TextureFilter=be;l.UnsignedByteType=1009;l.ByteType=1010;l.ShortType=1011;l.UnsignedShortType=1012;l.IntType=1013;l.UnsignedIntType=1014;l.FloatType=
12507 1015;l.HalfFloatType=1016;l.UnsignedShort4444Type=1017;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=2001;l.RGBA_S3TC_DXT1_Format=2002;l.RGBA_S3TC_DXT3_Format=2003;l.RGBA_S3TC_DXT5_Format=2004;l.RGB_PVRTC_4BPPV1_Format=2100;l.RGB_PVRTC_2BPPV1_Format=2101;l.RGBA_PVRTC_4BPPV1_Format=
12508 2102;l.RGBA_PVRTC_2BPPV1_Format=2103;l.RGB_ETC1_Format=2151;l.LoopOnce=2200;l.LoopRepeat=2201;l.LoopPingPong=2202;l.InterpolateDiscrete=2300;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;
12509 l.BasicDepthPacking=3200;l.RGBADepthPacking=3201;l.CubeGeometry=ob;l.Face4=function(a,b,c,d,e,f,g){console.warn("THREE.Face4 has been removed. A THREE.Face3 will be created instead.");return new ea(a,b,c,e,f,g)};l.LineStrip=0;l.LinePieces=1;l.MeshFaceMaterial=Kc;l.PointCloud=function(a,b){console.warn("THREE.PointCloud has been renamed to THREE.Points.");return new Kb(a,b)};l.Particle=qc;l.ParticleSystem=function(a,b){console.warn("THREE.ParticleSystem has been renamed to THREE.Points.");return new Kb(a,
12510 b)};l.PointCloudMaterial=function(a){console.warn("THREE.PointCloudMaterial has been renamed to THREE.PointsMaterial.");return new xa(a)};l.ParticleBasicMaterial=function(a){console.warn("THREE.ParticleBasicMaterial has been renamed to THREE.PointsMaterial.");return new xa(a)};l.ParticleSystemMaterial=function(a){console.warn("THREE.ParticleSystemMaterial has been renamed to THREE.PointsMaterial.");return new xa(a)};l.Vertex=function(a,b,c){console.warn("THREE.Vertex has been removed. Use THREE.Vector3 instead.");
12511 return new q(a,b,c)};l.EdgesHelper=function(a,b){console.warn("THREE.EdgesHelper has been removed. Use THREE.EdgesGeometry instead.");return new la(new Yb(a.geometry),new oa({color:void 0!==b?b:16777215}))};l.WireframeHelper=function(a,b){console.warn("THREE.WireframeHelper has been removed. Use THREE.WireframeGeometry instead.");return new la(new Mb(a.geometry),new oa({color:void 0!==b?b:16777215}))};l.GeometryUtils={merge:function(a,b,c){console.warn("THREE.GeometryUtils: .merge() has been moved to Geometry. Use geometry.merge( geometry2, matrix, materialIndexOffset ) instead.");
12512 var d;b.isMesh&&(b.matrixAutoUpdate&&b.updateMatrix(),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.");return a.center()}};l.ImageUtils={crossOrigin:void 0,loadTexture:function(a,b,c,d){console.warn("THREE.ImageUtils.loadTexture has been deprecated. Use THREE.TextureLoader() instead.");var e=new gd;e.setCrossOrigin(this.crossOrigin);a=e.load(a,c,void 0,d);b&&(a.mapping=b);return a},
12513 loadTextureCube:function(a,b,c,d){console.warn("THREE.ImageUtils.loadTextureCube has been deprecated. Use THREE.CubeTextureLoader() instead.");var e=new Hd;e.setCrossOrigin(this.crossOrigin);a=e.load(a,c,void 0,d);b&&(a.mapping=b);return a},loadCompressedTexture:function(){console.error("THREE.ImageUtils.loadCompressedTexture has been removed. Use THREE.DDSLoader instead.")},loadCompressedTextureCube:function(){console.error("THREE.ImageUtils.loadCompressedTextureCube has been removed. Use THREE.DDSLoader instead.")}};
12514 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(a,b){console.error("THREE.Projector: .pickingRay() is now raycaster.setFromCamera().")}};l.CanvasRenderer=function(){console.error("THREE.CanvasRenderer has been moved to /examples/js/renderers/CanvasRenderer.js");
12515 this.domElement=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");this.clear=function(){};this.render=function(){};this.setClearColor=function(){};this.setSize=function(){}};Object.defineProperty(l,"__esModule",{value:!0});Object.defineProperty(l,"AudioContext",{get:function(){return l.getAudioContext()}})});
12517 },{}],158:[function(require,module,exports){
12518 // Underscore.js 1.8.3
12519 // http://underscorejs.org
12520 // (c) 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
12521 // Underscore may be freely distributed under the MIT license.
12528 // Establish the root object, `window` in the browser, or `exports` on the server.
12531 // Save the previous value of the `_` variable.
12532 var previousUnderscore = root._;
12534 // Save bytes in the minified (but not gzipped) version:
12535 var ArrayProto = Array.prototype, ObjProto = Object.prototype, FuncProto = Function.prototype;
12537 // Create quick reference variables for speed access to core prototypes.
12539 push = ArrayProto.push,
12540 slice = ArrayProto.slice,
12541 toString = ObjProto.toString,
12542 hasOwnProperty = ObjProto.hasOwnProperty;
12544 // All **ECMAScript 5** native function implementations that we hope to use
12545 // are declared here.
12547 nativeIsArray = Array.isArray,
12548 nativeKeys = Object.keys,
12549 nativeBind = FuncProto.bind,
12550 nativeCreate = Object.create;
12552 // Naked function reference for surrogate-prototype-swapping.
12553 var Ctor = function(){};
12555 // Create a safe reference to the Underscore object for use below.
12556 var _ = function(obj) {
12557 if (obj instanceof _) return obj;
12558 if (!(this instanceof _)) return new _(obj);
12559 this._wrapped = obj;
12562 // Export the Underscore object for **Node.js**, with
12563 // backwards-compatibility for the old `require()` API. If we're in
12564 // the browser, add `_` as a global object.
12565 if (typeof exports !== 'undefined') {
12566 if (typeof module !== 'undefined' && module.exports) {
12567 exports = module.exports = _;
12574 // Current version.
12575 _.VERSION = '1.8.3';
12577 // Internal function that returns an efficient (for current engines) version
12578 // of the passed-in callback, to be repeatedly applied in other Underscore
12580 var optimizeCb = function(func, context, argCount) {
12581 if (context === void 0) return func;
12582 switch (argCount == null ? 3 : argCount) {
12583 case 1: return function(value) {
12584 return func.call(context, value);
12586 case 2: return function(value, other) {
12587 return func.call(context, value, other);
12589 case 3: return function(value, index, collection) {
12590 return func.call(context, value, index, collection);
12592 case 4: return function(accumulator, value, index, collection) {
12593 return func.call(context, accumulator, value, index, collection);
12596 return function() {
12597 return func.apply(context, arguments);
12601 // A mostly-internal function to generate callbacks that can be applied
12602 // to each element in a collection, returning the desired result — either
12603 // identity, an arbitrary callback, a property matcher, or a property accessor.
12604 var cb = function(value, context, argCount) {
12605 if (value == null) return _.identity;
12606 if (_.isFunction(value)) return optimizeCb(value, context, argCount);
12607 if (_.isObject(value)) return _.matcher(value);
12608 return _.property(value);
12610 _.iteratee = function(value, context) {
12611 return cb(value, context, Infinity);
12614 // An internal function for creating assigner functions.
12615 var createAssigner = function(keysFunc, undefinedOnly) {
12616 return function(obj) {
12617 var length = arguments.length;
12618 if (length < 2 || obj == null) return obj;
12619 for (var index = 1; index < length; index++) {
12620 var source = arguments[index],
12621 keys = keysFunc(source),
12623 for (var i = 0; i < l; i++) {
12625 if (!undefinedOnly || obj[key] === void 0) obj[key] = source[key];
12632 // An internal function for creating a new object that inherits from another.
12633 var baseCreate = function(prototype) {
12634 if (!_.isObject(prototype)) return {};
12635 if (nativeCreate) return nativeCreate(prototype);
12636 Ctor.prototype = prototype;
12637 var result = new Ctor;
12638 Ctor.prototype = null;
12642 var property = function(key) {
12643 return function(obj) {
12644 return obj == null ? void 0 : obj[key];
12648 // Helper for collection methods to determine whether a collection
12649 // should be iterated as an array or as an object
12650 // Related: http://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength
12651 // Avoids a very nasty iOS 8 JIT bug on ARM-64. #2094
12652 var MAX_ARRAY_INDEX = Math.pow(2, 53) - 1;
12653 var getLength = property('length');
12654 var isArrayLike = function(collection) {
12655 var length = getLength(collection);
12656 return typeof length == 'number' && length >= 0 && length <= MAX_ARRAY_INDEX;
12659 // Collection Functions
12660 // --------------------
12662 // The cornerstone, an `each` implementation, aka `forEach`.
12663 // Handles raw objects in addition to array-likes. Treats all
12664 // sparse array-likes as if they were dense.
12665 _.each = _.forEach = function(obj, iteratee, context) {
12666 iteratee = optimizeCb(iteratee, context);
12668 if (isArrayLike(obj)) {
12669 for (i = 0, length = obj.length; i < length; i++) {
12670 iteratee(obj[i], i, obj);
12673 var keys = _.keys(obj);
12674 for (i = 0, length = keys.length; i < length; i++) {
12675 iteratee(obj[keys[i]], keys[i], obj);
12681 // Return the results of applying the iteratee to each element.
12682 _.map = _.collect = function(obj, iteratee, context) {
12683 iteratee = cb(iteratee, context);
12684 var keys = !isArrayLike(obj) && _.keys(obj),
12685 length = (keys || obj).length,
12686 results = Array(length);
12687 for (var index = 0; index < length; index++) {
12688 var currentKey = keys ? keys[index] : index;
12689 results[index] = iteratee(obj[currentKey], currentKey, obj);
12694 // Create a reducing function iterating left or right.
12695 function createReduce(dir) {
12696 // Optimized iterator function as using arguments.length
12697 // in the main function will deoptimize the, see #1991.
12698 function iterator(obj, iteratee, memo, keys, index, length) {
12699 for (; index >= 0 && index < length; index += dir) {
12700 var currentKey = keys ? keys[index] : index;
12701 memo = iteratee(memo, obj[currentKey], currentKey, obj);
12706 return function(obj, iteratee, memo, context) {
12707 iteratee = optimizeCb(iteratee, context, 4);
12708 var keys = !isArrayLike(obj) && _.keys(obj),
12709 length = (keys || obj).length,
12710 index = dir > 0 ? 0 : length - 1;
12711 // Determine the initial value if none is provided.
12712 if (arguments.length < 3) {
12713 memo = obj[keys ? keys[index] : index];
12716 return iterator(obj, iteratee, memo, keys, index, length);
12720 // **Reduce** builds up a single result from a list of values, aka `inject`,
12722 _.reduce = _.foldl = _.inject = createReduce(1);
12724 // The right-associative version of reduce, also known as `foldr`.
12725 _.reduceRight = _.foldr = createReduce(-1);
12727 // Return the first value which passes a truth test. Aliased as `detect`.
12728 _.find = _.detect = function(obj, predicate, context) {
12730 if (isArrayLike(obj)) {
12731 key = _.findIndex(obj, predicate, context);
12733 key = _.findKey(obj, predicate, context);
12735 if (key !== void 0 && key !== -1) return obj[key];
12738 // Return all the elements that pass a truth test.
12739 // Aliased as `select`.
12740 _.filter = _.select = function(obj, predicate, context) {
12742 predicate = cb(predicate, context);
12743 _.each(obj, function(value, index, list) {
12744 if (predicate(value, index, list)) results.push(value);
12749 // Return all the elements for which a truth test fails.
12750 _.reject = function(obj, predicate, context) {
12751 return _.filter(obj, _.negate(cb(predicate)), context);
12754 // Determine whether all of the elements match a truth test.
12755 // Aliased as `all`.
12756 _.every = _.all = function(obj, predicate, context) {
12757 predicate = cb(predicate, context);
12758 var keys = !isArrayLike(obj) && _.keys(obj),
12759 length = (keys || obj).length;
12760 for (var index = 0; index < length; index++) {
12761 var currentKey = keys ? keys[index] : index;
12762 if (!predicate(obj[currentKey], currentKey, obj)) return false;
12767 // Determine if at least one element in the object matches a truth test.
12768 // Aliased as `any`.
12769 _.some = _.any = function(obj, predicate, context) {
12770 predicate = cb(predicate, context);
12771 var keys = !isArrayLike(obj) && _.keys(obj),
12772 length = (keys || obj).length;
12773 for (var index = 0; index < length; index++) {
12774 var currentKey = keys ? keys[index] : index;
12775 if (predicate(obj[currentKey], currentKey, obj)) return true;
12780 // Determine if the array or object contains a given item (using `===`).
12781 // Aliased as `includes` and `include`.
12782 _.contains = _.includes = _.include = function(obj, item, fromIndex, guard) {
12783 if (!isArrayLike(obj)) obj = _.values(obj);
12784 if (typeof fromIndex != 'number' || guard) fromIndex = 0;
12785 return _.indexOf(obj, item, fromIndex) >= 0;
12788 // Invoke a method (with arguments) on every item in a collection.
12789 _.invoke = function(obj, method) {
12790 var args = slice.call(arguments, 2);
12791 var isFunc = _.isFunction(method);
12792 return _.map(obj, function(value) {
12793 var func = isFunc ? method : value[method];
12794 return func == null ? func : func.apply(value, args);
12798 // Convenience version of a common use case of `map`: fetching a property.
12799 _.pluck = function(obj, key) {
12800 return _.map(obj, _.property(key));
12803 // Convenience version of a common use case of `filter`: selecting only objects
12804 // containing specific `key:value` pairs.
12805 _.where = function(obj, attrs) {
12806 return _.filter(obj, _.matcher(attrs));
12809 // Convenience version of a common use case of `find`: getting the first object
12810 // containing specific `key:value` pairs.
12811 _.findWhere = function(obj, attrs) {
12812 return _.find(obj, _.matcher(attrs));
12815 // Return the maximum element (or element-based computation).
12816 _.max = function(obj, iteratee, context) {
12817 var result = -Infinity, lastComputed = -Infinity,
12819 if (iteratee == null && obj != null) {
12820 obj = isArrayLike(obj) ? obj : _.values(obj);
12821 for (var i = 0, length = obj.length; i < length; i++) {
12823 if (value > result) {
12828 iteratee = cb(iteratee, context);
12829 _.each(obj, function(value, index, list) {
12830 computed = iteratee(value, index, list);
12831 if (computed > lastComputed || computed === -Infinity && result === -Infinity) {
12833 lastComputed = computed;
12840 // Return the minimum element (or element-based computation).
12841 _.min = function(obj, iteratee, context) {
12842 var result = Infinity, lastComputed = Infinity,
12844 if (iteratee == null && obj != null) {
12845 obj = isArrayLike(obj) ? obj : _.values(obj);
12846 for (var i = 0, length = obj.length; i < length; i++) {
12848 if (value < result) {
12853 iteratee = cb(iteratee, context);
12854 _.each(obj, function(value, index, list) {
12855 computed = iteratee(value, index, list);
12856 if (computed < lastComputed || computed === Infinity && result === Infinity) {
12858 lastComputed = computed;
12865 // Shuffle a collection, using the modern version of the
12866 // [Fisher-Yates shuffle](http://en.wikipedia.org/wiki/Fisher–Yates_shuffle).
12867 _.shuffle = function(obj) {
12868 var set = isArrayLike(obj) ? obj : _.values(obj);
12869 var length = set.length;
12870 var shuffled = Array(length);
12871 for (var index = 0, rand; index < length; index++) {
12872 rand = _.random(0, index);
12873 if (rand !== index) shuffled[index] = shuffled[rand];
12874 shuffled[rand] = set[index];
12879 // Sample **n** random values from a collection.
12880 // If **n** is not specified, returns a single random element.
12881 // The internal `guard` argument allows it to work with `map`.
12882 _.sample = function(obj, n, guard) {
12883 if (n == null || guard) {
12884 if (!isArrayLike(obj)) obj = _.values(obj);
12885 return obj[_.random(obj.length - 1)];
12887 return _.shuffle(obj).slice(0, Math.max(0, n));
12890 // Sort the object's values by a criterion produced by an iteratee.
12891 _.sortBy = function(obj, iteratee, context) {
12892 iteratee = cb(iteratee, context);
12893 return _.pluck(_.map(obj, function(value, index, list) {
12897 criteria: iteratee(value, index, list)
12899 }).sort(function(left, right) {
12900 var a = left.criteria;
12901 var b = right.criteria;
12903 if (a > b || a === void 0) return 1;
12904 if (a < b || b === void 0) return -1;
12906 return left.index - right.index;
12910 // An internal function used for aggregate "group by" operations.
12911 var group = function(behavior) {
12912 return function(obj, iteratee, context) {
12914 iteratee = cb(iteratee, context);
12915 _.each(obj, function(value, index) {
12916 var key = iteratee(value, index, obj);
12917 behavior(result, value, key);
12923 // Groups the object's values by a criterion. Pass either a string attribute
12924 // to group by, or a function that returns the criterion.
12925 _.groupBy = group(function(result, value, key) {
12926 if (_.has(result, key)) result[key].push(value); else result[key] = [value];
12929 // Indexes the object's values by a criterion, similar to `groupBy`, but for
12930 // when you know that your index values will be unique.
12931 _.indexBy = group(function(result, value, key) {
12932 result[key] = value;
12935 // Counts instances of an object that group by a certain criterion. Pass
12936 // either a string attribute to count by, or a function that returns the
12938 _.countBy = group(function(result, value, key) {
12939 if (_.has(result, key)) result[key]++; else result[key] = 1;
12942 // Safely create a real, live array from anything iterable.
12943 _.toArray = function(obj) {
12944 if (!obj) return [];
12945 if (_.isArray(obj)) return slice.call(obj);
12946 if (isArrayLike(obj)) return _.map(obj, _.identity);
12947 return _.values(obj);
12950 // Return the number of elements in an object.
12951 _.size = function(obj) {
12952 if (obj == null) return 0;
12953 return isArrayLike(obj) ? obj.length : _.keys(obj).length;
12956 // Split a collection into two arrays: one whose elements all satisfy the given
12957 // predicate, and one whose elements all do not satisfy the predicate.
12958 _.partition = function(obj, predicate, context) {
12959 predicate = cb(predicate, context);
12960 var pass = [], fail = [];
12961 _.each(obj, function(value, key, obj) {
12962 (predicate(value, key, obj) ? pass : fail).push(value);
12964 return [pass, fail];
12970 // Get the first element of an array. Passing **n** will return the first N
12971 // values in the array. Aliased as `head` and `take`. The **guard** check
12972 // allows it to work with `_.map`.
12973 _.first = _.head = _.take = function(array, n, guard) {
12974 if (array == null) return void 0;
12975 if (n == null || guard) return array[0];
12976 return _.initial(array, array.length - n);
12979 // Returns everything but the last entry of the array. Especially useful on
12980 // the arguments object. Passing **n** will return all the values in
12981 // the array, excluding the last N.
12982 _.initial = function(array, n, guard) {
12983 return slice.call(array, 0, Math.max(0, array.length - (n == null || guard ? 1 : n)));
12986 // Get the last element of an array. Passing **n** will return the last N
12987 // values in the array.
12988 _.last = function(array, n, guard) {
12989 if (array == null) return void 0;
12990 if (n == null || guard) return array[array.length - 1];
12991 return _.rest(array, Math.max(0, array.length - n));
12994 // Returns everything but the first entry of the array. Aliased as `tail` and `drop`.
12995 // Especially useful on the arguments object. Passing an **n** will return
12996 // the rest N values in the array.
12997 _.rest = _.tail = _.drop = function(array, n, guard) {
12998 return slice.call(array, n == null || guard ? 1 : n);
13001 // Trim out all falsy values from an array.
13002 _.compact = function(array) {
13003 return _.filter(array, _.identity);
13006 // Internal implementation of a recursive `flatten` function.
13007 var flatten = function(input, shallow, strict, startIndex) {
13008 var output = [], idx = 0;
13009 for (var i = startIndex || 0, length = getLength(input); i < length; i++) {
13010 var value = input[i];
13011 if (isArrayLike(value) && (_.isArray(value) || _.isArguments(value))) {
13012 //flatten current level of array or arguments object
13013 if (!shallow) value = flatten(value, shallow, strict);
13014 var j = 0, len = value.length;
13015 output.length += len;
13017 output[idx++] = value[j++];
13019 } else if (!strict) {
13020 output[idx++] = value;
13026 // Flatten out an array, either recursively (by default), or just one level.
13027 _.flatten = function(array, shallow) {
13028 return flatten(array, shallow, false);
13031 // Return a version of the array that does not contain the specified value(s).
13032 _.without = function(array) {
13033 return _.difference(array, slice.call(arguments, 1));
13036 // Produce a duplicate-free version of the array. If the array has already
13037 // been sorted, you have the option of using a faster algorithm.
13038 // Aliased as `unique`.
13039 _.uniq = _.unique = function(array, isSorted, iteratee, context) {
13040 if (!_.isBoolean(isSorted)) {
13041 context = iteratee;
13042 iteratee = isSorted;
13045 if (iteratee != null) iteratee = cb(iteratee, context);
13048 for (var i = 0, length = getLength(array); i < length; i++) {
13049 var value = array[i],
13050 computed = iteratee ? iteratee(value, i, array) : value;
13052 if (!i || seen !== computed) result.push(value);
13054 } else if (iteratee) {
13055 if (!_.contains(seen, computed)) {
13056 seen.push(computed);
13057 result.push(value);
13059 } else if (!_.contains(result, value)) {
13060 result.push(value);
13066 // Produce an array that contains the union: each distinct element from all of
13067 // the passed-in arrays.
13068 _.union = function() {
13069 return _.uniq(flatten(arguments, true, true));
13072 // Produce an array that contains every item shared between all the
13073 // passed-in arrays.
13074 _.intersection = function(array) {
13076 var argsLength = arguments.length;
13077 for (var i = 0, length = getLength(array); i < length; i++) {
13078 var item = array[i];
13079 if (_.contains(result, item)) continue;
13080 for (var j = 1; j < argsLength; j++) {
13081 if (!_.contains(arguments[j], item)) break;
13083 if (j === argsLength) result.push(item);
13088 // Take the difference between one array and a number of other arrays.
13089 // Only the elements present in just the first array will remain.
13090 _.difference = function(array) {
13091 var rest = flatten(arguments, true, true, 1);
13092 return _.filter(array, function(value){
13093 return !_.contains(rest, value);
13097 // Zip together multiple lists into a single array -- elements that share
13098 // an index go together.
13099 _.zip = function() {
13100 return _.unzip(arguments);
13103 // Complement of _.zip. Unzip accepts an array of arrays and groups
13104 // each array's elements on shared indices
13105 _.unzip = function(array) {
13106 var length = array && _.max(array, getLength).length || 0;
13107 var result = Array(length);
13109 for (var index = 0; index < length; index++) {
13110 result[index] = _.pluck(array, index);
13115 // Converts lists into objects. Pass either a single array of `[key, value]`
13116 // pairs, or two parallel arrays of the same length -- one of keys, and one of
13117 // the corresponding values.
13118 _.object = function(list, values) {
13120 for (var i = 0, length = getLength(list); i < length; i++) {
13122 result[list[i]] = values[i];
13124 result[list[i][0]] = list[i][1];
13130 // Generator function to create the findIndex and findLastIndex functions
13131 function createPredicateIndexFinder(dir) {
13132 return function(array, predicate, context) {
13133 predicate = cb(predicate, context);
13134 var length = getLength(array);
13135 var index = dir > 0 ? 0 : length - 1;
13136 for (; index >= 0 && index < length; index += dir) {
13137 if (predicate(array[index], index, array)) return index;
13143 // Returns the first index on an array-like that passes a predicate test
13144 _.findIndex = createPredicateIndexFinder(1);
13145 _.findLastIndex = createPredicateIndexFinder(-1);
13147 // Use a comparator function to figure out the smallest index at which
13148 // an object should be inserted so as to maintain order. Uses binary search.
13149 _.sortedIndex = function(array, obj, iteratee, context) {
13150 iteratee = cb(iteratee, context, 1);
13151 var value = iteratee(obj);
13152 var low = 0, high = getLength(array);
13153 while (low < high) {
13154 var mid = Math.floor((low + high) / 2);
13155 if (iteratee(array[mid]) < value) low = mid + 1; else high = mid;
13160 // Generator function to create the indexOf and lastIndexOf functions
13161 function createIndexFinder(dir, predicateFind, sortedIndex) {
13162 return function(array, item, idx) {
13163 var i = 0, length = getLength(array);
13164 if (typeof idx == 'number') {
13166 i = idx >= 0 ? idx : Math.max(idx + length, i);
13168 length = idx >= 0 ? Math.min(idx + 1, length) : idx + length + 1;
13170 } else if (sortedIndex && idx && length) {
13171 idx = sortedIndex(array, item);
13172 return array[idx] === item ? idx : -1;
13174 if (item !== item) {
13175 idx = predicateFind(slice.call(array, i, length), _.isNaN);
13176 return idx >= 0 ? idx + i : -1;
13178 for (idx = dir > 0 ? i : length - 1; idx >= 0 && idx < length; idx += dir) {
13179 if (array[idx] === item) return idx;
13185 // Return the position of the first occurrence of an item in an array,
13186 // or -1 if the item is not included in the array.
13187 // If the array is large and already in sort order, pass `true`
13188 // for **isSorted** to use binary search.
13189 _.indexOf = createIndexFinder(1, _.findIndex, _.sortedIndex);
13190 _.lastIndexOf = createIndexFinder(-1, _.findLastIndex);
13192 // Generate an integer Array containing an arithmetic progression. A port of
13193 // the native Python `range()` function. See
13194 // [the Python documentation](http://docs.python.org/library/functions.html#range).
13195 _.range = function(start, stop, step) {
13196 if (stop == null) {
13202 var length = Math.max(Math.ceil((stop - start) / step), 0);
13203 var range = Array(length);
13205 for (var idx = 0; idx < length; idx++, start += step) {
13206 range[idx] = start;
13212 // Function (ahem) Functions
13213 // ------------------
13215 // Determines whether to execute a function as a constructor
13216 // or a normal function with the provided arguments
13217 var executeBound = function(sourceFunc, boundFunc, context, callingContext, args) {
13218 if (!(callingContext instanceof boundFunc)) return sourceFunc.apply(context, args);
13219 var self = baseCreate(sourceFunc.prototype);
13220 var result = sourceFunc.apply(self, args);
13221 if (_.isObject(result)) return result;
13225 // Create a function bound to a given object (assigning `this`, and arguments,
13226 // optionally). Delegates to **ECMAScript 5**'s native `Function.bind` if
13228 _.bind = function(func, context) {
13229 if (nativeBind && func.bind === nativeBind) return nativeBind.apply(func, slice.call(arguments, 1));
13230 if (!_.isFunction(func)) throw new TypeError('Bind must be called on a function');
13231 var args = slice.call(arguments, 2);
13232 var bound = function() {
13233 return executeBound(func, bound, context, this, args.concat(slice.call(arguments)));
13238 // Partially apply a function by creating a version that has had some of its
13239 // arguments pre-filled, without changing its dynamic `this` context. _ acts
13240 // as a placeholder, allowing any combination of arguments to be pre-filled.
13241 _.partial = function(func) {
13242 var boundArgs = slice.call(arguments, 1);
13243 var bound = function() {
13244 var position = 0, length = boundArgs.length;
13245 var args = Array(length);
13246 for (var i = 0; i < length; i++) {
13247 args[i] = boundArgs[i] === _ ? arguments[position++] : boundArgs[i];
13249 while (position < arguments.length) args.push(arguments[position++]);
13250 return executeBound(func, bound, this, this, args);
13255 // Bind a number of an object's methods to that object. Remaining arguments
13256 // are the method names to be bound. Useful for ensuring that all callbacks
13257 // defined on an object belong to it.
13258 _.bindAll = function(obj) {
13259 var i, length = arguments.length, key;
13260 if (length <= 1) throw new Error('bindAll must be passed function names');
13261 for (i = 1; i < length; i++) {
13262 key = arguments[i];
13263 obj[key] = _.bind(obj[key], obj);
13268 // Memoize an expensive function by storing its results.
13269 _.memoize = function(func, hasher) {
13270 var memoize = function(key) {
13271 var cache = memoize.cache;
13272 var address = '' + (hasher ? hasher.apply(this, arguments) : key);
13273 if (!_.has(cache, address)) cache[address] = func.apply(this, arguments);
13274 return cache[address];
13276 memoize.cache = {};
13280 // Delays a function for the given number of milliseconds, and then calls
13281 // it with the arguments supplied.
13282 _.delay = function(func, wait) {
13283 var args = slice.call(arguments, 2);
13284 return setTimeout(function(){
13285 return func.apply(null, args);
13289 // Defers a function, scheduling it to run after the current call stack has
13291 _.defer = _.partial(_.delay, _, 1);
13293 // Returns a function, that, when invoked, will only be triggered at most once
13294 // during a given window of time. Normally, the throttled function will run
13295 // as much as it can, without ever going more than once per `wait` duration;
13296 // but if you'd like to disable the execution on the leading edge, pass
13297 // `{leading: false}`. To disable execution on the trailing edge, ditto.
13298 _.throttle = function(func, wait, options) {
13299 var context, args, result;
13300 var timeout = null;
13302 if (!options) options = {};
13303 var later = function() {
13304 previous = options.leading === false ? 0 : _.now();
13306 result = func.apply(context, args);
13307 if (!timeout) context = args = null;
13309 return function() {
13311 if (!previous && options.leading === false) previous = now;
13312 var remaining = wait - (now - previous);
13315 if (remaining <= 0 || remaining > wait) {
13317 clearTimeout(timeout);
13321 result = func.apply(context, args);
13322 if (!timeout) context = args = null;
13323 } else if (!timeout && options.trailing !== false) {
13324 timeout = setTimeout(later, remaining);
13330 // Returns a function, that, as long as it continues to be invoked, will not
13331 // be triggered. The function will be called after it stops being called for
13332 // N milliseconds. If `immediate` is passed, trigger the function on the
13333 // leading edge, instead of the trailing.
13334 _.debounce = function(func, wait, immediate) {
13335 var timeout, args, context, timestamp, result;
13337 var later = function() {
13338 var last = _.now() - timestamp;
13340 if (last < wait && last >= 0) {
13341 timeout = setTimeout(later, wait - last);
13345 result = func.apply(context, args);
13346 if (!timeout) context = args = null;
13351 return function() {
13354 timestamp = _.now();
13355 var callNow = immediate && !timeout;
13356 if (!timeout) timeout = setTimeout(later, wait);
13358 result = func.apply(context, args);
13359 context = args = null;
13366 // Returns the first function passed as an argument to the second,
13367 // allowing you to adjust arguments, run code before and after, and
13368 // conditionally execute the original function.
13369 _.wrap = function(func, wrapper) {
13370 return _.partial(wrapper, func);
13373 // Returns a negated version of the passed-in predicate.
13374 _.negate = function(predicate) {
13375 return function() {
13376 return !predicate.apply(this, arguments);
13380 // Returns a function that is the composition of a list of functions, each
13381 // consuming the return value of the function that follows.
13382 _.compose = function() {
13383 var args = arguments;
13384 var start = args.length - 1;
13385 return function() {
13387 var result = args[start].apply(this, arguments);
13388 while (i--) result = args[i].call(this, result);
13393 // Returns a function that will only be executed on and after the Nth call.
13394 _.after = function(times, func) {
13395 return function() {
13397 return func.apply(this, arguments);
13402 // Returns a function that will only be executed up to (but not including) the Nth call.
13403 _.before = function(times, func) {
13405 return function() {
13407 memo = func.apply(this, arguments);
13409 if (times <= 1) func = null;
13414 // Returns a function that will be executed at most one time, no matter how
13415 // often you call it. Useful for lazy initialization.
13416 _.once = _.partial(_.before, 2);
13418 // Object Functions
13419 // ----------------
13421 // Keys in IE < 9 that won't be iterated by `for key in ...` and thus missed.
13422 var hasEnumBug = !{toString: null}.propertyIsEnumerable('toString');
13423 var nonEnumerableProps = ['valueOf', 'isPrototypeOf', 'toString',
13424 'propertyIsEnumerable', 'hasOwnProperty', 'toLocaleString'];
13426 function collectNonEnumProps(obj, keys) {
13427 var nonEnumIdx = nonEnumerableProps.length;
13428 var constructor = obj.constructor;
13429 var proto = (_.isFunction(constructor) && constructor.prototype) || ObjProto;
13431 // Constructor is a special case.
13432 var prop = 'constructor';
13433 if (_.has(obj, prop) && !_.contains(keys, prop)) keys.push(prop);
13435 while (nonEnumIdx--) {
13436 prop = nonEnumerableProps[nonEnumIdx];
13437 if (prop in obj && obj[prop] !== proto[prop] && !_.contains(keys, prop)) {
13443 // Retrieve the names of an object's own properties.
13444 // Delegates to **ECMAScript 5**'s native `Object.keys`
13445 _.keys = function(obj) {
13446 if (!_.isObject(obj)) return [];
13447 if (nativeKeys) return nativeKeys(obj);
13449 for (var key in obj) if (_.has(obj, key)) keys.push(key);
13451 if (hasEnumBug) collectNonEnumProps(obj, keys);
13455 // Retrieve all the property names of an object.
13456 _.allKeys = function(obj) {
13457 if (!_.isObject(obj)) return [];
13459 for (var key in obj) keys.push(key);
13461 if (hasEnumBug) collectNonEnumProps(obj, keys);
13465 // Retrieve the values of an object's properties.
13466 _.values = function(obj) {
13467 var keys = _.keys(obj);
13468 var length = keys.length;
13469 var values = Array(length);
13470 for (var i = 0; i < length; i++) {
13471 values[i] = obj[keys[i]];
13476 // Returns the results of applying the iteratee to each element of the object
13477 // In contrast to _.map it returns an object
13478 _.mapObject = function(obj, iteratee, context) {
13479 iteratee = cb(iteratee, context);
13480 var keys = _.keys(obj),
13481 length = keys.length,
13484 for (var index = 0; index < length; index++) {
13485 currentKey = keys[index];
13486 results[currentKey] = iteratee(obj[currentKey], currentKey, obj);
13491 // Convert an object into a list of `[key, value]` pairs.
13492 _.pairs = function(obj) {
13493 var keys = _.keys(obj);
13494 var length = keys.length;
13495 var pairs = Array(length);
13496 for (var i = 0; i < length; i++) {
13497 pairs[i] = [keys[i], obj[keys[i]]];
13502 // Invert the keys and values of an object. The values must be serializable.
13503 _.invert = function(obj) {
13505 var keys = _.keys(obj);
13506 for (var i = 0, length = keys.length; i < length; i++) {
13507 result[obj[keys[i]]] = keys[i];
13512 // Return a sorted list of the function names available on the object.
13513 // Aliased as `methods`
13514 _.functions = _.methods = function(obj) {
13516 for (var key in obj) {
13517 if (_.isFunction(obj[key])) names.push(key);
13519 return names.sort();
13522 // Extend a given object with all the properties in passed-in object(s).
13523 _.extend = createAssigner(_.allKeys);
13525 // Assigns a given object with all the own properties in the passed-in object(s)
13526 // (https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/assign)
13527 _.extendOwn = _.assign = createAssigner(_.keys);
13529 // Returns the first key on an object that passes a predicate test
13530 _.findKey = function(obj, predicate, context) {
13531 predicate = cb(predicate, context);
13532 var keys = _.keys(obj), key;
13533 for (var i = 0, length = keys.length; i < length; i++) {
13535 if (predicate(obj[key], key, obj)) return key;
13539 // Return a copy of the object only containing the whitelisted properties.
13540 _.pick = function(object, oiteratee, context) {
13541 var result = {}, obj = object, iteratee, keys;
13542 if (obj == null) return result;
13543 if (_.isFunction(oiteratee)) {
13544 keys = _.allKeys(obj);
13545 iteratee = optimizeCb(oiteratee, context);
13547 keys = flatten(arguments, false, false, 1);
13548 iteratee = function(value, key, obj) { return key in obj; };
13551 for (var i = 0, length = keys.length; i < length; i++) {
13553 var value = obj[key];
13554 if (iteratee(value, key, obj)) result[key] = value;
13559 // Return a copy of the object without the blacklisted properties.
13560 _.omit = function(obj, iteratee, context) {
13561 if (_.isFunction(iteratee)) {
13562 iteratee = _.negate(iteratee);
13564 var keys = _.map(flatten(arguments, false, false, 1), String);
13565 iteratee = function(value, key) {
13566 return !_.contains(keys, key);
13569 return _.pick(obj, iteratee, context);
13572 // Fill in a given object with default properties.
13573 _.defaults = createAssigner(_.allKeys, true);
13575 // Creates an object that inherits from the given prototype object.
13576 // If additional properties are provided then they will be added to the
13578 _.create = function(prototype, props) {
13579 var result = baseCreate(prototype);
13580 if (props) _.extendOwn(result, props);
13584 // Create a (shallow-cloned) duplicate of an object.
13585 _.clone = function(obj) {
13586 if (!_.isObject(obj)) return obj;
13587 return _.isArray(obj) ? obj.slice() : _.extend({}, obj);
13590 // Invokes interceptor with the obj, and then returns obj.
13591 // The primary purpose of this method is to "tap into" a method chain, in
13592 // order to perform operations on intermediate results within the chain.
13593 _.tap = function(obj, interceptor) {
13598 // Returns whether an object has a given set of `key:value` pairs.
13599 _.isMatch = function(object, attrs) {
13600 var keys = _.keys(attrs), length = keys.length;
13601 if (object == null) return !length;
13602 var obj = Object(object);
13603 for (var i = 0; i < length; i++) {
13605 if (attrs[key] !== obj[key] || !(key in obj)) return false;
13611 // Internal recursive comparison function for `isEqual`.
13612 var eq = function(a, b, aStack, bStack) {
13613 // Identical objects are equal. `0 === -0`, but they aren't identical.
13614 // See the [Harmony `egal` proposal](http://wiki.ecmascript.org/doku.php?id=harmony:egal).
13615 if (a === b) return a !== 0 || 1 / a === 1 / b;
13616 // A strict comparison is necessary because `null == undefined`.
13617 if (a == null || b == null) return a === b;
13618 // Unwrap any wrapped objects.
13619 if (a instanceof _) a = a._wrapped;
13620 if (b instanceof _) b = b._wrapped;
13621 // Compare `[[Class]]` names.
13622 var className = toString.call(a);
13623 if (className !== toString.call(b)) return false;
13624 switch (className) {
13625 // Strings, numbers, regular expressions, dates, and booleans are compared by value.
13626 case '[object RegExp]':
13627 // RegExps are coerced to strings for comparison (Note: '' + /a/i === '/a/i')
13628 case '[object String]':
13629 // Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is
13630 // equivalent to `new String("5")`.
13631 return '' + a === '' + b;
13632 case '[object Number]':
13633 // `NaN`s are equivalent, but non-reflexive.
13634 // Object(NaN) is equivalent to NaN
13635 if (+a !== +a) return +b !== +b;
13636 // An `egal` comparison is performed for other numeric values.
13637 return +a === 0 ? 1 / +a === 1 / b : +a === +b;
13638 case '[object Date]':
13639 case '[object Boolean]':
13640 // Coerce dates and booleans to numeric primitive values. Dates are compared by their
13641 // millisecond representations. Note that invalid dates with millisecond representations
13642 // of `NaN` are not equivalent.
13646 var areArrays = className === '[object Array]';
13648 if (typeof a != 'object' || typeof b != 'object') return false;
13650 // Objects with different constructors are not equivalent, but `Object`s or `Array`s
13651 // from different frames are.
13652 var aCtor = a.constructor, bCtor = b.constructor;
13653 if (aCtor !== bCtor && !(_.isFunction(aCtor) && aCtor instanceof aCtor &&
13654 _.isFunction(bCtor) && bCtor instanceof bCtor)
13655 && ('constructor' in a && 'constructor' in b)) {
13659 // Assume equality for cyclic structures. The algorithm for detecting cyclic
13660 // structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`.
13662 // Initializing stack of traversed objects.
13663 // It's done here since we only need them for objects and arrays comparison.
13664 aStack = aStack || [];
13665 bStack = bStack || [];
13666 var length = aStack.length;
13668 // Linear search. Performance is inversely proportional to the number of
13669 // unique nested structures.
13670 if (aStack[length] === a) return bStack[length] === b;
13673 // Add the first object to the stack of traversed objects.
13677 // Recursively compare objects and arrays.
13679 // Compare array lengths to determine if a deep comparison is necessary.
13681 if (length !== b.length) return false;
13682 // Deep compare the contents, ignoring non-numeric properties.
13684 if (!eq(a[length], b[length], aStack, bStack)) return false;
13687 // Deep compare objects.
13688 var keys = _.keys(a), key;
13689 length = keys.length;
13690 // Ensure that both objects contain the same number of properties before comparing deep equality.
13691 if (_.keys(b).length !== length) return false;
13693 // Deep compare each member
13694 key = keys[length];
13695 if (!(_.has(b, key) && eq(a[key], b[key], aStack, bStack))) return false;
13698 // Remove the first object from the stack of traversed objects.
13704 // Perform a deep comparison to check if two objects are equal.
13705 _.isEqual = function(a, b) {
13709 // Is a given array, string, or object empty?
13710 // An "empty" object has no enumerable own-properties.
13711 _.isEmpty = function(obj) {
13712 if (obj == null) return true;
13713 if (isArrayLike(obj) && (_.isArray(obj) || _.isString(obj) || _.isArguments(obj))) return obj.length === 0;
13714 return _.keys(obj).length === 0;
13717 // Is a given value a DOM element?
13718 _.isElement = function(obj) {
13719 return !!(obj && obj.nodeType === 1);
13722 // Is a given value an array?
13723 // Delegates to ECMA5's native Array.isArray
13724 _.isArray = nativeIsArray || function(obj) {
13725 return toString.call(obj) === '[object Array]';
13728 // Is a given variable an object?
13729 _.isObject = function(obj) {
13730 var type = typeof obj;
13731 return type === 'function' || type === 'object' && !!obj;
13734 // Add some isType methods: isArguments, isFunction, isString, isNumber, isDate, isRegExp, isError.
13735 _.each(['Arguments', 'Function', 'String', 'Number', 'Date', 'RegExp', 'Error'], function(name) {
13736 _['is' + name] = function(obj) {
13737 return toString.call(obj) === '[object ' + name + ']';
13741 // Define a fallback version of the method in browsers (ahem, IE < 9), where
13742 // there isn't any inspectable "Arguments" type.
13743 if (!_.isArguments(arguments)) {
13744 _.isArguments = function(obj) {
13745 return _.has(obj, 'callee');
13749 // Optimize `isFunction` if appropriate. Work around some typeof bugs in old v8,
13750 // IE 11 (#1621), and in Safari 8 (#1929).
13751 if (typeof /./ != 'function' && typeof Int8Array != 'object') {
13752 _.isFunction = function(obj) {
13753 return typeof obj == 'function' || false;
13757 // Is a given object a finite number?
13758 _.isFinite = function(obj) {
13759 return isFinite(obj) && !isNaN(parseFloat(obj));
13762 // Is the given value `NaN`? (NaN is the only number which does not equal itself).
13763 _.isNaN = function(obj) {
13764 return _.isNumber(obj) && obj !== +obj;
13767 // Is a given value a boolean?
13768 _.isBoolean = function(obj) {
13769 return obj === true || obj === false || toString.call(obj) === '[object Boolean]';
13772 // Is a given value equal to null?
13773 _.isNull = function(obj) {
13774 return obj === null;
13777 // Is a given variable undefined?
13778 _.isUndefined = function(obj) {
13779 return obj === void 0;
13782 // Shortcut function for checking if an object has a given property directly
13783 // on itself (in other words, not on a prototype).
13784 _.has = function(obj, key) {
13785 return obj != null && hasOwnProperty.call(obj, key);
13788 // Utility Functions
13789 // -----------------
13791 // Run Underscore.js in *noConflict* mode, returning the `_` variable to its
13792 // previous owner. Returns a reference to the Underscore object.
13793 _.noConflict = function() {
13794 root._ = previousUnderscore;
13798 // Keep the identity function around for default iteratees.
13799 _.identity = function(value) {
13803 // Predicate-generating functions. Often useful outside of Underscore.
13804 _.constant = function(value) {
13805 return function() {
13810 _.noop = function(){};
13812 _.property = property;
13814 // Generates a function for a given object that returns a given property.
13815 _.propertyOf = function(obj) {
13816 return obj == null ? function(){} : function(key) {
13821 // Returns a predicate for checking whether an object has a given set of
13822 // `key:value` pairs.
13823 _.matcher = _.matches = function(attrs) {
13824 attrs = _.extendOwn({}, attrs);
13825 return function(obj) {
13826 return _.isMatch(obj, attrs);
13830 // Run a function **n** times.
13831 _.times = function(n, iteratee, context) {
13832 var accum = Array(Math.max(0, n));
13833 iteratee = optimizeCb(iteratee, context, 1);
13834 for (var i = 0; i < n; i++) accum[i] = iteratee(i);
13838 // Return a random integer between min and max (inclusive).
13839 _.random = function(min, max) {
13844 return min + Math.floor(Math.random() * (max - min + 1));
13847 // A (possibly faster) way to get the current timestamp as an integer.
13848 _.now = Date.now || function() {
13849 return new Date().getTime();
13852 // List of HTML entities for escaping.
13861 var unescapeMap = _.invert(escapeMap);
13863 // Functions for escaping and unescaping strings to/from HTML interpolation.
13864 var createEscaper = function(map) {
13865 var escaper = function(match) {
13868 // Regexes for identifying a key that needs to be escaped
13869 var source = '(?:' + _.keys(map).join('|') + ')';
13870 var testRegexp = RegExp(source);
13871 var replaceRegexp = RegExp(source, 'g');
13872 return function(string) {
13873 string = string == null ? '' : '' + string;
13874 return testRegexp.test(string) ? string.replace(replaceRegexp, escaper) : string;
13877 _.escape = createEscaper(escapeMap);
13878 _.unescape = createEscaper(unescapeMap);
13880 // If the value of the named `property` is a function then invoke it with the
13881 // `object` as context; otherwise, return it.
13882 _.result = function(object, property, fallback) {
13883 var value = object == null ? void 0 : object[property];
13884 if (value === void 0) {
13887 return _.isFunction(value) ? value.call(object) : value;
13890 // Generate a unique integer id (unique within the entire client session).
13891 // Useful for temporary DOM ids.
13893 _.uniqueId = function(prefix) {
13894 var id = ++idCounter + '';
13895 return prefix ? prefix + id : id;
13898 // By default, Underscore uses ERB-style template delimiters, change the
13899 // following template settings to use alternative delimiters.
13900 _.templateSettings = {
13901 evaluate : /<%([\s\S]+?)%>/g,
13902 interpolate : /<%=([\s\S]+?)%>/g,
13903 escape : /<%-([\s\S]+?)%>/g
13906 // When customizing `templateSettings`, if you don't want to define an
13907 // interpolation, evaluation or escaping regex, we need one that is
13908 // guaranteed not to match.
13909 var noMatch = /(.)^/;
13911 // Certain characters need to be escaped so that they can be put into a
13922 var escaper = /\\|'|\r|\n|\u2028|\u2029/g;
13924 var escapeChar = function(match) {
13925 return '\\' + escapes[match];
13928 // JavaScript micro-templating, similar to John Resig's implementation.
13929 // Underscore templating handles arbitrary delimiters, preserves whitespace,
13930 // and correctly escapes quotes within interpolated code.
13931 // NB: `oldSettings` only exists for backwards compatibility.
13932 _.template = function(text, settings, oldSettings) {
13933 if (!settings && oldSettings) settings = oldSettings;
13934 settings = _.defaults({}, settings, _.templateSettings);
13936 // Combine delimiters into one regular expression via alternation.
13937 var matcher = RegExp([
13938 (settings.escape || noMatch).source,
13939 (settings.interpolate || noMatch).source,
13940 (settings.evaluate || noMatch).source
13941 ].join('|') + '|$', 'g');
13943 // Compile the template source, escaping string literals appropriately.
13945 var source = "__p+='";
13946 text.replace(matcher, function(match, escape, interpolate, evaluate, offset) {
13947 source += text.slice(index, offset).replace(escaper, escapeChar);
13948 index = offset + match.length;
13951 source += "'+\n((__t=(" + escape + "))==null?'':_.escape(__t))+\n'";
13952 } else if (interpolate) {
13953 source += "'+\n((__t=(" + interpolate + "))==null?'':__t)+\n'";
13954 } else if (evaluate) {
13955 source += "';\n" + evaluate + "\n__p+='";
13958 // Adobe VMs need the match returned to produce the correct offest.
13963 // If a variable is not specified, place data values in local scope.
13964 if (!settings.variable) source = 'with(obj||{}){\n' + source + '}\n';
13966 source = "var __t,__p='',__j=Array.prototype.join," +
13967 "print=function(){__p+=__j.call(arguments,'');};\n" +
13968 source + 'return __p;\n';
13971 var render = new Function(settings.variable || 'obj', '_', source);
13977 var template = function(data) {
13978 return render.call(this, data, _);
13981 // Provide the compiled source as a convenience for precompilation.
13982 var argument = settings.variable || 'obj';
13983 template.source = 'function(' + argument + '){\n' + source + '}';
13988 // Add a "chain" function. Start chaining a wrapped Underscore object.
13989 _.chain = function(obj) {
13990 var instance = _(obj);
13991 instance._chain = true;
13997 // If Underscore is called as a function, it returns a wrapped object that
13998 // can be used OO-style. This wrapper holds altered versions of all the
13999 // underscore functions. Wrapped objects may be chained.
14001 // Helper function to continue chaining intermediate results.
14002 var result = function(instance, obj) {
14003 return instance._chain ? _(obj).chain() : obj;
14006 // Add your own custom functions to the Underscore object.
14007 _.mixin = function(obj) {
14008 _.each(_.functions(obj), function(name) {
14009 var func = _[name] = obj[name];
14010 _.prototype[name] = function() {
14011 var args = [this._wrapped];
14012 push.apply(args, arguments);
14013 return result(this, func.apply(_, args));
14018 // Add all of the Underscore functions to the wrapper object.
14021 // Add all mutator Array functions to the wrapper.
14022 _.each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(name) {
14023 var method = ArrayProto[name];
14024 _.prototype[name] = function() {
14025 var obj = this._wrapped;
14026 method.apply(obj, arguments);
14027 if ((name === 'shift' || name === 'splice') && obj.length === 0) delete obj[0];
14028 return result(this, obj);
14032 // Add all accessor Array functions to the wrapper.
14033 _.each(['concat', 'join', 'slice'], function(name) {
14034 var method = ArrayProto[name];
14035 _.prototype[name] = function() {
14036 return result(this, method.apply(this._wrapped, arguments));
14040 // Extracts the result from a wrapped and chained object.
14041 _.prototype.value = function() {
14042 return this._wrapped;
14045 // Provide unwrapping proxy for some methods used in engine operations
14046 // such as arithmetic and JSON stringification.
14047 _.prototype.valueOf = _.prototype.toJSON = _.prototype.value;
14049 _.prototype.toString = function() {
14050 return '' + this._wrapped;
14053 // AMD registration happens at the end for compatibility with AMD loaders
14054 // that may not enforce next-turn semantics on modules. Even though general
14055 // practice for AMD registration is to be anonymous, underscore registers
14056 // as a named module because, like jQuery, it is a base library that is
14057 // popular enough to be bundled in a third party lib, but not be part of
14058 // an AMD load request. Those cases could generate an error when an
14059 // anonymous define() is called outside of a loader request.
14060 if (typeof define === 'function' && define.amd) {
14061 define('underscore', [], function() {
14067 },{}],159:[function(require,module,exports){
14069 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
14071 * Redistribution and use in source and binary forms, with or without
14072 * modification, are permitted provided that the following conditions
14074 * 1. Redistributions of source code must retain the above copyright
14075 * notice, this list of conditions and the following disclaimer.
14076 * 2. Redistributions in binary form must reproduce the above copyright
14077 * notice, this list of conditions and the following disclaimer in the
14078 * documentation and/or other materials provided with the distribution.
14080 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14081 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
14082 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
14083 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
14084 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
14085 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
14086 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
14087 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
14088 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
14089 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
14090 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14092 * Ported from Webkit
14093 * http://svn.webkit.org/repository/webkit/trunk/Source/WebCore/platform/graphics/UnitBezier.h
14096 module.exports = UnitBezier;
14098 function UnitBezier(p1x, p1y, p2x, p2y) {
14099 // Calculate the polynomial coefficients, implicit first and last control points are (0,0) and (1,1).
14100 this.cx = 3.0 * p1x;
14101 this.bx = 3.0 * (p2x - p1x) - this.cx;
14102 this.ax = 1.0 - this.cx - this.bx;
14104 this.cy = 3.0 * p1y;
14105 this.by = 3.0 * (p2y - p1y) - this.cy;
14106 this.ay = 1.0 - this.cy - this.by;
14114 UnitBezier.prototype.sampleCurveX = function(t) {
14115 // `ax t^3 + bx t^2 + cx t' expanded using Horner's rule.
14116 return ((this.ax * t + this.bx) * t + this.cx) * t;
14119 UnitBezier.prototype.sampleCurveY = function(t) {
14120 return ((this.ay * t + this.by) * t + this.cy) * t;
14123 UnitBezier.prototype.sampleCurveDerivativeX = function(t) {
14124 return (3.0 * this.ax * t + 2.0 * this.bx) * t + this.cx;
14127 UnitBezier.prototype.solveCurveX = function(x, epsilon) {
14128 if (typeof epsilon === 'undefined') epsilon = 1e-6;
14130 var t0, t1, t2, x2, i;
14132 // First try a few iterations of Newton's method -- normally very fast.
14133 for (t2 = x, i = 0; i < 8; i++) {
14135 x2 = this.sampleCurveX(t2) - x;
14136 if (Math.abs(x2) < epsilon) return t2;
14138 var d2 = this.sampleCurveDerivativeX(t2);
14139 if (Math.abs(d2) < 1e-6) break;
14144 // Fall back to the bisection method for reliability.
14149 if (t2 < t0) return t0;
14150 if (t2 > t1) return t1;
14154 x2 = this.sampleCurveX(t2);
14155 if (Math.abs(x2 - x) < epsilon) return t2;
14163 t2 = (t1 - t0) * 0.5 + t0;
14170 UnitBezier.prototype.solve = function(x, epsilon) {
14171 return this.sampleCurveY(this.solveCurveX(x, epsilon));
14174 },{}],160:[function(require,module,exports){
14175 var createElement = require("./vdom/create-element.js")
14177 module.exports = createElement
14179 },{"./vdom/create-element.js":166}],161:[function(require,module,exports){
14180 var diff = require("./vtree/diff.js")
14182 module.exports = diff
14184 },{"./vtree/diff.js":186}],162:[function(require,module,exports){
14185 var h = require("./virtual-hyperscript/index.js")
14189 },{"./virtual-hyperscript/index.js":173}],163:[function(require,module,exports){
14190 var diff = require("./diff.js")
14191 var patch = require("./patch.js")
14192 var h = require("./h.js")
14193 var create = require("./create-element.js")
14194 var VNode = require('./vnode/vnode.js')
14195 var VText = require('./vnode/vtext.js')
14206 },{"./create-element.js":160,"./diff.js":161,"./h.js":162,"./patch.js":164,"./vnode/vnode.js":182,"./vnode/vtext.js":184}],164:[function(require,module,exports){
14207 var patch = require("./vdom/patch.js")
14209 module.exports = patch
14211 },{"./vdom/patch.js":169}],165:[function(require,module,exports){
14212 var isObject = require("is-object")
14213 var isHook = require("../vnode/is-vhook.js")
14215 module.exports = applyProperties
14217 function applyProperties(node, props, previous) {
14218 for (var propName in props) {
14219 var propValue = props[propName]
14221 if (propValue === undefined) {
14222 removeProperty(node, propName, propValue, previous);
14223 } else if (isHook(propValue)) {
14224 removeProperty(node, propName, propValue, previous)
14225 if (propValue.hook) {
14226 propValue.hook(node,
14228 previous ? previous[propName] : undefined)
14231 if (isObject(propValue)) {
14232 patchObject(node, props, previous, propName, propValue);
14234 node[propName] = propValue
14240 function removeProperty(node, propName, propValue, previous) {
14242 var previousValue = previous[propName]
14244 if (!isHook(previousValue)) {
14245 if (propName === "attributes") {
14246 for (var attrName in previousValue) {
14247 node.removeAttribute(attrName)
14249 } else if (propName === "style") {
14250 for (var i in previousValue) {
14253 } else if (typeof previousValue === "string") {
14254 node[propName] = ""
14256 node[propName] = null
14258 } else if (previousValue.unhook) {
14259 previousValue.unhook(node, propName, propValue)
14264 function patchObject(node, props, previous, propName, propValue) {
14265 var previousValue = previous ? previous[propName] : undefined
14268 if (propName === "attributes") {
14269 for (var attrName in propValue) {
14270 var attrValue = propValue[attrName]
14272 if (attrValue === undefined) {
14273 node.removeAttribute(attrName)
14275 node.setAttribute(attrName, attrValue)
14282 if(previousValue && isObject(previousValue) &&
14283 getPrototype(previousValue) !== getPrototype(propValue)) {
14284 node[propName] = propValue
14288 if (!isObject(node[propName])) {
14289 node[propName] = {}
14292 var replacer = propName === "style" ? "" : undefined
14294 for (var k in propValue) {
14295 var value = propValue[k]
14296 node[propName][k] = (value === undefined) ? replacer : value
14300 function getPrototype(value) {
14301 if (Object.getPrototypeOf) {
14302 return Object.getPrototypeOf(value)
14303 } else if (value.__proto__) {
14304 return value.__proto__
14305 } else if (value.constructor) {
14306 return value.constructor.prototype
14310 },{"../vnode/is-vhook.js":177,"is-object":18}],166:[function(require,module,exports){
14311 var document = require("global/document")
14313 var applyProperties = require("./apply-properties")
14315 var isVNode = require("../vnode/is-vnode.js")
14316 var isVText = require("../vnode/is-vtext.js")
14317 var isWidget = require("../vnode/is-widget.js")
14318 var handleThunk = require("../vnode/handle-thunk.js")
14320 module.exports = createElement
14322 function createElement(vnode, opts) {
14323 var doc = opts ? opts.document || document : document
14324 var warn = opts ? opts.warn : null
14326 vnode = handleThunk(vnode).a
14328 if (isWidget(vnode)) {
14329 return vnode.init()
14330 } else if (isVText(vnode)) {
14331 return doc.createTextNode(vnode.text)
14332 } else if (!isVNode(vnode)) {
14334 warn("Item is not a valid virtual dom node", vnode)
14339 var node = (vnode.namespace === null) ?
14340 doc.createElement(vnode.tagName) :
14341 doc.createElementNS(vnode.namespace, vnode.tagName)
14343 var props = vnode.properties
14344 applyProperties(node, props)
14346 var children = vnode.children
14348 for (var i = 0; i < children.length; i++) {
14349 var childNode = createElement(children[i], opts)
14351 node.appendChild(childNode)
14358 },{"../vnode/handle-thunk.js":175,"../vnode/is-vnode.js":178,"../vnode/is-vtext.js":179,"../vnode/is-widget.js":180,"./apply-properties":165,"global/document":14}],167:[function(require,module,exports){
14359 // Maps a virtual DOM tree onto a real DOM tree in an efficient manner.
14360 // We don't want to read all of the DOM nodes in the tree so we use
14361 // the in-order tree indexing to eliminate recursion down certain branches.
14362 // We only recurse into a DOM node if we know that it contains a child of
14367 module.exports = domIndex
14369 function domIndex(rootNode, tree, indices, nodes) {
14370 if (!indices || indices.length === 0) {
14373 indices.sort(ascending)
14374 return recurse(rootNode, tree, indices, nodes, 0)
14378 function recurse(rootNode, tree, indices, nodes, rootIndex) {
14379 nodes = nodes || {}
14383 if (indexInRange(indices, rootIndex, rootIndex)) {
14384 nodes[rootIndex] = rootNode
14387 var vChildren = tree.children
14391 var childNodes = rootNode.childNodes
14393 for (var i = 0; i < tree.children.length; i++) {
14396 var vChild = vChildren[i] || noChild
14397 var nextIndex = rootIndex + (vChild.count || 0)
14399 // skip recursion down the tree if there are no nodes down here
14400 if (indexInRange(indices, rootIndex, nextIndex)) {
14401 recurse(childNodes[i], vChild, indices, nodes, rootIndex)
14404 rootIndex = nextIndex
14412 // Binary search for an index in the interval [left, right]
14413 function indexInRange(indices, left, right) {
14414 if (indices.length === 0) {
14419 var maxIndex = indices.length - 1
14423 while (minIndex <= maxIndex) {
14424 currentIndex = ((maxIndex + minIndex) / 2) >> 0
14425 currentItem = indices[currentIndex]
14427 if (minIndex === maxIndex) {
14428 return currentItem >= left && currentItem <= right
14429 } else if (currentItem < left) {
14430 minIndex = currentIndex + 1
14431 } else if (currentItem > right) {
14432 maxIndex = currentIndex - 1
14441 function ascending(a, b) {
14442 return a > b ? 1 : -1
14445 },{}],168:[function(require,module,exports){
14446 var applyProperties = require("./apply-properties")
14448 var isWidget = require("../vnode/is-widget.js")
14449 var VPatch = require("../vnode/vpatch.js")
14451 var updateWidget = require("./update-widget")
14453 module.exports = applyPatch
14455 function applyPatch(vpatch, domNode, renderOptions) {
14456 var type = vpatch.type
14457 var vNode = vpatch.vNode
14458 var patch = vpatch.patch
14461 case VPatch.REMOVE:
14462 return removeNode(domNode, vNode)
14463 case VPatch.INSERT:
14464 return insertNode(domNode, patch, renderOptions)
14466 return stringPatch(domNode, vNode, patch, renderOptions)
14467 case VPatch.WIDGET:
14468 return widgetPatch(domNode, vNode, patch, renderOptions)
14470 return vNodePatch(domNode, vNode, patch, renderOptions)
14472 reorderChildren(domNode, patch)
14475 applyProperties(domNode, patch, vNode.properties)
14478 return replaceRoot(domNode,
14479 renderOptions.patch(domNode, patch, renderOptions))
14485 function removeNode(domNode, vNode) {
14486 var parentNode = domNode.parentNode
14489 parentNode.removeChild(domNode)
14492 destroyWidget(domNode, vNode);
14497 function insertNode(parentNode, vNode, renderOptions) {
14498 var newNode = renderOptions.render(vNode, renderOptions)
14501 parentNode.appendChild(newNode)
14507 function stringPatch(domNode, leftVNode, vText, renderOptions) {
14510 if (domNode.nodeType === 3) {
14511 domNode.replaceData(0, domNode.length, vText.text)
14514 var parentNode = domNode.parentNode
14515 newNode = renderOptions.render(vText, renderOptions)
14517 if (parentNode && newNode !== domNode) {
14518 parentNode.replaceChild(newNode, domNode)
14525 function widgetPatch(domNode, leftVNode, widget, renderOptions) {
14526 var updating = updateWidget(leftVNode, widget)
14530 newNode = widget.update(leftVNode, domNode) || domNode
14532 newNode = renderOptions.render(widget, renderOptions)
14535 var parentNode = domNode.parentNode
14537 if (parentNode && newNode !== domNode) {
14538 parentNode.replaceChild(newNode, domNode)
14542 destroyWidget(domNode, leftVNode)
14548 function vNodePatch(domNode, leftVNode, vNode, renderOptions) {
14549 var parentNode = domNode.parentNode
14550 var newNode = renderOptions.render(vNode, renderOptions)
14552 if (parentNode && newNode !== domNode) {
14553 parentNode.replaceChild(newNode, domNode)
14559 function destroyWidget(domNode, w) {
14560 if (typeof w.destroy === "function" && isWidget(w)) {
14565 function reorderChildren(domNode, moves) {
14566 var childNodes = domNode.childNodes
14572 for (var i = 0; i < moves.removes.length; i++) {
14573 remove = moves.removes[i]
14574 node = childNodes[remove.from]
14576 keyMap[remove.key] = node
14578 domNode.removeChild(node)
14581 var length = childNodes.length
14582 for (var j = 0; j < moves.inserts.length; j++) {
14583 insert = moves.inserts[j]
14584 node = keyMap[insert.key]
14585 // this is the weirdest bug i've ever seen in webkit
14586 domNode.insertBefore(node, insert.to >= length++ ? null : childNodes[insert.to])
14590 function replaceRoot(oldRoot, newRoot) {
14591 if (oldRoot && newRoot && oldRoot !== newRoot && oldRoot.parentNode) {
14592 oldRoot.parentNode.replaceChild(newRoot, oldRoot)
14598 },{"../vnode/is-widget.js":180,"../vnode/vpatch.js":183,"./apply-properties":165,"./update-widget":170}],169:[function(require,module,exports){
14599 var document = require("global/document")
14600 var isArray = require("x-is-array")
14602 var render = require("./create-element")
14603 var domIndex = require("./dom-index")
14604 var patchOp = require("./patch-op")
14605 module.exports = patch
14607 function patch(rootNode, patches, renderOptions) {
14608 renderOptions = renderOptions || {}
14609 renderOptions.patch = renderOptions.patch && renderOptions.patch !== patch
14610 ? renderOptions.patch
14612 renderOptions.render = renderOptions.render || render
14614 return renderOptions.patch(rootNode, patches, renderOptions)
14617 function patchRecursive(rootNode, patches, renderOptions) {
14618 var indices = patchIndices(patches)
14620 if (indices.length === 0) {
14624 var index = domIndex(rootNode, patches.a, indices)
14625 var ownerDocument = rootNode.ownerDocument
14627 if (!renderOptions.document && ownerDocument !== document) {
14628 renderOptions.document = ownerDocument
14631 for (var i = 0; i < indices.length; i++) {
14632 var nodeIndex = indices[i]
14633 rootNode = applyPatch(rootNode,
14635 patches[nodeIndex],
14642 function applyPatch(rootNode, domNode, patchList, renderOptions) {
14649 if (isArray(patchList)) {
14650 for (var i = 0; i < patchList.length; i++) {
14651 newNode = patchOp(patchList[i], domNode, renderOptions)
14653 if (domNode === rootNode) {
14658 newNode = patchOp(patchList, domNode, renderOptions)
14660 if (domNode === rootNode) {
14668 function patchIndices(patches) {
14671 for (var key in patches) {
14673 indices.push(Number(key))
14680 },{"./create-element":166,"./dom-index":167,"./patch-op":168,"global/document":14,"x-is-array":205}],170:[function(require,module,exports){
14681 var isWidget = require("../vnode/is-widget.js")
14683 module.exports = updateWidget
14685 function updateWidget(a, b) {
14686 if (isWidget(a) && isWidget(b)) {
14687 if ("name" in a && "name" in b) {
14688 return a.id === b.id
14690 return a.init === b.init
14697 },{"../vnode/is-widget.js":180}],171:[function(require,module,exports){
14700 var EvStore = require('ev-store');
14702 module.exports = EvHook;
14704 function EvHook(value) {
14705 if (!(this instanceof EvHook)) {
14706 return new EvHook(value);
14709 this.value = value;
14712 EvHook.prototype.hook = function (node, propertyName) {
14713 var es = EvStore(node);
14714 var propName = propertyName.substr(3);
14716 es[propName] = this.value;
14719 EvHook.prototype.unhook = function(node, propertyName) {
14720 var es = EvStore(node);
14721 var propName = propertyName.substr(3);
14723 es[propName] = undefined;
14726 },{"ev-store":7}],172:[function(require,module,exports){
14729 module.exports = SoftSetHook;
14731 function SoftSetHook(value) {
14732 if (!(this instanceof SoftSetHook)) {
14733 return new SoftSetHook(value);
14736 this.value = value;
14739 SoftSetHook.prototype.hook = function (node, propertyName) {
14740 if (node[propertyName] !== this.value) {
14741 node[propertyName] = this.value;
14745 },{}],173:[function(require,module,exports){
14748 var isArray = require('x-is-array');
14750 var VNode = require('../vnode/vnode.js');
14751 var VText = require('../vnode/vtext.js');
14752 var isVNode = require('../vnode/is-vnode');
14753 var isVText = require('../vnode/is-vtext');
14754 var isWidget = require('../vnode/is-widget');
14755 var isHook = require('../vnode/is-vhook');
14756 var isVThunk = require('../vnode/is-thunk');
14758 var parseTag = require('./parse-tag.js');
14759 var softSetHook = require('./hooks/soft-set-hook.js');
14760 var evHook = require('./hooks/ev-hook.js');
14762 module.exports = h;
14764 function h(tagName, properties, children) {
14765 var childNodes = [];
14766 var tag, props, key, namespace;
14768 if (!children && isChildren(properties)) {
14769 children = properties;
14773 props = props || properties || {};
14774 tag = parseTag(tagName, props);
14777 if (props.hasOwnProperty('key')) {
14779 props.key = undefined;
14782 // support namespace
14783 if (props.hasOwnProperty('namespace')) {
14784 namespace = props.namespace;
14785 props.namespace = undefined;
14789 if (tag === 'INPUT' &&
14791 props.hasOwnProperty('value') &&
14792 props.value !== undefined &&
14793 !isHook(props.value)
14795 props.value = softSetHook(props.value);
14798 transformProperties(props);
14800 if (children !== undefined && children !== null) {
14801 addChild(children, childNodes, tag, props);
14805 return new VNode(tag, props, childNodes, key, namespace);
14808 function addChild(c, childNodes, tag, props) {
14809 if (typeof c === 'string') {
14810 childNodes.push(new VText(c));
14811 } else if (typeof c === 'number') {
14812 childNodes.push(new VText(String(c)));
14813 } else if (isChild(c)) {
14814 childNodes.push(c);
14815 } else if (isArray(c)) {
14816 for (var i = 0; i < c.length; i++) {
14817 addChild(c[i], childNodes, tag, props);
14819 } else if (c === null || c === undefined) {
14822 throw UnexpectedVirtualElement({
14832 function transformProperties(props) {
14833 for (var propName in props) {
14834 if (props.hasOwnProperty(propName)) {
14835 var value = props[propName];
14837 if (isHook(value)) {
14841 if (propName.substr(0, 3) === 'ev-') {
14842 // add ev-foo support
14843 props[propName] = evHook(value);
14849 function isChild(x) {
14850 return isVNode(x) || isVText(x) || isWidget(x) || isVThunk(x);
14853 function isChildren(x) {
14854 return typeof x === 'string' || isArray(x) || isChild(x);
14857 function UnexpectedVirtualElement(data) {
14858 var err = new Error();
14860 err.type = 'virtual-hyperscript.unexpected.virtual-element';
14861 err.message = 'Unexpected virtual child passed to h().\n' +
14862 'Expected a VNode / Vthunk / VWidget / string but:\n' +
14864 errorString(data.foreignObject) +
14866 'The parent vnode is:\n' +
14867 errorString(data.parentVnode)
14869 'Suggested fix: change your `h(..., [ ... ])` callsite.';
14870 err.foreignObject = data.foreignObject;
14871 err.parentVnode = data.parentVnode;
14876 function errorString(obj) {
14878 return JSON.stringify(obj, null, ' ');
14880 return String(obj);
14884 },{"../vnode/is-thunk":176,"../vnode/is-vhook":177,"../vnode/is-vnode":178,"../vnode/is-vtext":179,"../vnode/is-widget":180,"../vnode/vnode.js":182,"../vnode/vtext.js":184,"./hooks/ev-hook.js":171,"./hooks/soft-set-hook.js":172,"./parse-tag.js":174,"x-is-array":205}],174:[function(require,module,exports){
14887 var split = require('browser-split');
14889 var classIdSplit = /([\.#]?[a-zA-Z0-9\u007F-\uFFFF_:-]+)/;
14890 var notClassId = /^\.|#/;
14892 module.exports = parseTag;
14894 function parseTag(tag, props) {
14899 var noId = !(props.hasOwnProperty('id'));
14901 var tagParts = split(tag, classIdSplit);
14902 var tagName = null;
14904 if (notClassId.test(tagParts[1])) {
14908 var classes, part, type, i;
14910 for (i = 0; i < tagParts.length; i++) {
14911 part = tagParts[i];
14917 type = part.charAt(0);
14921 } else if (type === '.') {
14922 classes = classes || [];
14923 classes.push(part.substring(1, part.length));
14924 } else if (type === '#' && noId) {
14925 props.id = part.substring(1, part.length);
14930 if (props.className) {
14931 classes.push(props.className);
14934 props.className = classes.join(' ');
14937 return props.namespace ? tagName : tagName.toUpperCase();
14940 },{"browser-split":3}],175:[function(require,module,exports){
14941 var isVNode = require("./is-vnode")
14942 var isVText = require("./is-vtext")
14943 var isWidget = require("./is-widget")
14944 var isThunk = require("./is-thunk")
14946 module.exports = handleThunk
14948 function handleThunk(a, b) {
14953 renderedB = renderThunk(b, a)
14957 renderedA = renderThunk(a, null)
14966 function renderThunk(thunk, previous) {
14967 var renderedThunk = thunk.vnode
14969 if (!renderedThunk) {
14970 renderedThunk = thunk.vnode = thunk.render(previous)
14973 if (!(isVNode(renderedThunk) ||
14974 isVText(renderedThunk) ||
14975 isWidget(renderedThunk))) {
14976 throw new Error("thunk did not return a valid node");
14979 return renderedThunk
14982 },{"./is-thunk":176,"./is-vnode":178,"./is-vtext":179,"./is-widget":180}],176:[function(require,module,exports){
14983 module.exports = isThunk
14985 function isThunk(t) {
14986 return t && t.type === "Thunk"
14989 },{}],177:[function(require,module,exports){
14990 module.exports = isHook
14992 function isHook(hook) {
14994 (typeof hook.hook === "function" && !hook.hasOwnProperty("hook") ||
14995 typeof hook.unhook === "function" && !hook.hasOwnProperty("unhook"))
14998 },{}],178:[function(require,module,exports){
14999 var version = require("./version")
15001 module.exports = isVirtualNode
15003 function isVirtualNode(x) {
15004 return x && x.type === "VirtualNode" && x.version === version
15007 },{"./version":181}],179:[function(require,module,exports){
15008 var version = require("./version")
15010 module.exports = isVirtualText
15012 function isVirtualText(x) {
15013 return x && x.type === "VirtualText" && x.version === version
15016 },{"./version":181}],180:[function(require,module,exports){
15017 module.exports = isWidget
15019 function isWidget(w) {
15020 return w && w.type === "Widget"
15023 },{}],181:[function(require,module,exports){
15024 module.exports = "2"
15026 },{}],182:[function(require,module,exports){
15027 var version = require("./version")
15028 var isVNode = require("./is-vnode")
15029 var isWidget = require("./is-widget")
15030 var isThunk = require("./is-thunk")
15031 var isVHook = require("./is-vhook")
15033 module.exports = VirtualNode
15035 var noProperties = {}
15036 var noChildren = []
15038 function VirtualNode(tagName, properties, children, key, namespace) {
15039 this.tagName = tagName
15040 this.properties = properties || noProperties
15041 this.children = children || noChildren
15042 this.key = key != null ? String(key) : undefined
15043 this.namespace = (typeof namespace === "string") ? namespace : null
15045 var count = (children && children.length) || 0
15046 var descendants = 0
15047 var hasWidgets = false
15048 var hasThunks = false
15049 var descendantHooks = false
15052 for (var propName in properties) {
15053 if (properties.hasOwnProperty(propName)) {
15054 var property = properties[propName]
15055 if (isVHook(property) && property.unhook) {
15060 hooks[propName] = property
15065 for (var i = 0; i < count; i++) {
15066 var child = children[i]
15067 if (isVNode(child)) {
15068 descendants += child.count || 0
15070 if (!hasWidgets && child.hasWidgets) {
15074 if (!hasThunks && child.hasThunks) {
15078 if (!descendantHooks && (child.hooks || child.descendantHooks)) {
15079 descendantHooks = true
15081 } else if (!hasWidgets && isWidget(child)) {
15082 if (typeof child.destroy === "function") {
15085 } else if (!hasThunks && isThunk(child)) {
15090 this.count = count + descendants
15091 this.hasWidgets = hasWidgets
15092 this.hasThunks = hasThunks
15094 this.descendantHooks = descendantHooks
15097 VirtualNode.prototype.version = version
15098 VirtualNode.prototype.type = "VirtualNode"
15100 },{"./is-thunk":176,"./is-vhook":177,"./is-vnode":178,"./is-widget":180,"./version":181}],183:[function(require,module,exports){
15101 var version = require("./version")
15103 VirtualPatch.NONE = 0
15104 VirtualPatch.VTEXT = 1
15105 VirtualPatch.VNODE = 2
15106 VirtualPatch.WIDGET = 3
15107 VirtualPatch.PROPS = 4
15108 VirtualPatch.ORDER = 5
15109 VirtualPatch.INSERT = 6
15110 VirtualPatch.REMOVE = 7
15111 VirtualPatch.THUNK = 8
15113 module.exports = VirtualPatch
15115 function VirtualPatch(type, vNode, patch) {
15116 this.type = Number(type)
15121 VirtualPatch.prototype.version = version
15122 VirtualPatch.prototype.type = "VirtualPatch"
15124 },{"./version":181}],184:[function(require,module,exports){
15125 var version = require("./version")
15127 module.exports = VirtualText
15129 function VirtualText(text) {
15130 this.text = String(text)
15133 VirtualText.prototype.version = version
15134 VirtualText.prototype.type = "VirtualText"
15136 },{"./version":181}],185:[function(require,module,exports){
15137 var isObject = require("is-object")
15138 var isHook = require("../vnode/is-vhook")
15140 module.exports = diffProps
15142 function diffProps(a, b) {
15145 for (var aKey in a) {
15146 if (!(aKey in b)) {
15148 diff[aKey] = undefined
15151 var aValue = a[aKey]
15152 var bValue = b[aKey]
15154 if (aValue === bValue) {
15156 } else if (isObject(aValue) && isObject(bValue)) {
15157 if (getPrototype(bValue) !== getPrototype(aValue)) {
15159 diff[aKey] = bValue
15160 } else if (isHook(bValue)) {
15162 diff[aKey] = bValue
15164 var objectDiff = diffProps(aValue, bValue)
15167 diff[aKey] = objectDiff
15172 diff[aKey] = bValue
15176 for (var bKey in b) {
15177 if (!(bKey in a)) {
15179 diff[bKey] = b[bKey]
15186 function getPrototype(value) {
15187 if (Object.getPrototypeOf) {
15188 return Object.getPrototypeOf(value)
15189 } else if (value.__proto__) {
15190 return value.__proto__
15191 } else if (value.constructor) {
15192 return value.constructor.prototype
15196 },{"../vnode/is-vhook":177,"is-object":18}],186:[function(require,module,exports){
15197 var isArray = require("x-is-array")
15199 var VPatch = require("../vnode/vpatch")
15200 var isVNode = require("../vnode/is-vnode")
15201 var isVText = require("../vnode/is-vtext")
15202 var isWidget = require("../vnode/is-widget")
15203 var isThunk = require("../vnode/is-thunk")
15204 var handleThunk = require("../vnode/handle-thunk")
15206 var diffProps = require("./diff-props")
15208 module.exports = diff
15210 function diff(a, b) {
15211 var patch = { a: a }
15212 walk(a, b, patch, 0)
15216 function walk(a, b, patch, index) {
15221 var apply = patch[index]
15222 var applyClear = false
15224 if (isThunk(a) || isThunk(b)) {
15225 thunks(a, b, patch, index)
15226 } else if (b == null) {
15228 // If a is a widget we will add a remove patch for it
15229 // Otherwise any child widgets/hooks must be destroyed.
15230 // This prevents adding two remove patches for a widget.
15231 if (!isWidget(a)) {
15232 clearState(a, patch, index)
15233 apply = patch[index]
15236 apply = appendPatch(apply, new VPatch(VPatch.REMOVE, a, b))
15237 } else if (isVNode(b)) {
15239 if (a.tagName === b.tagName &&
15240 a.namespace === b.namespace &&
15242 var propsPatch = diffProps(a.properties, b.properties)
15244 apply = appendPatch(apply,
15245 new VPatch(VPatch.PROPS, a, propsPatch))
15247 apply = diffChildren(a, b, patch, apply, index)
15249 apply = appendPatch(apply, new VPatch(VPatch.VNODE, a, b))
15253 apply = appendPatch(apply, new VPatch(VPatch.VNODE, a, b))
15256 } else if (isVText(b)) {
15258 apply = appendPatch(apply, new VPatch(VPatch.VTEXT, a, b))
15260 } else if (a.text !== b.text) {
15261 apply = appendPatch(apply, new VPatch(VPatch.VTEXT, a, b))
15263 } else if (isWidget(b)) {
15264 if (!isWidget(a)) {
15268 apply = appendPatch(apply, new VPatch(VPatch.WIDGET, a, b))
15272 patch[index] = apply
15276 clearState(a, patch, index)
15280 function diffChildren(a, b, patch, apply, index) {
15281 var aChildren = a.children
15282 var orderedSet = reorder(aChildren, b.children)
15283 var bChildren = orderedSet.children
15285 var aLen = aChildren.length
15286 var bLen = bChildren.length
15287 var len = aLen > bLen ? aLen : bLen
15289 for (var i = 0; i < len; i++) {
15290 var leftNode = aChildren[i]
15291 var rightNode = bChildren[i]
15296 // Excess nodes in b need to be added
15297 apply = appendPatch(apply,
15298 new VPatch(VPatch.INSERT, null, rightNode))
15301 walk(leftNode, rightNode, patch, index)
15304 if (isVNode(leftNode) && leftNode.count) {
15305 index += leftNode.count
15309 if (orderedSet.moves) {
15310 // Reorder nodes last
15311 apply = appendPatch(apply, new VPatch(
15321 function clearState(vNode, patch, index) {
15322 // TODO: Make this a single walk, not two
15323 unhook(vNode, patch, index)
15324 destroyWidgets(vNode, patch, index)
15327 // Patch records for all destroyed widgets must be added because we need
15328 // a DOM node reference for the destroy function
15329 function destroyWidgets(vNode, patch, index) {
15330 if (isWidget(vNode)) {
15331 if (typeof vNode.destroy === "function") {
15332 patch[index] = appendPatch(
15334 new VPatch(VPatch.REMOVE, vNode, null)
15337 } else if (isVNode(vNode) && (vNode.hasWidgets || vNode.hasThunks)) {
15338 var children = vNode.children
15339 var len = children.length
15340 for (var i = 0; i < len; i++) {
15341 var child = children[i]
15344 destroyWidgets(child, patch, index)
15346 if (isVNode(child) && child.count) {
15347 index += child.count
15350 } else if (isThunk(vNode)) {
15351 thunks(vNode, null, patch, index)
15355 // Create a sub-patch for thunks
15356 function thunks(a, b, patch, index) {
15357 var nodes = handleThunk(a, b)
15358 var thunkPatch = diff(nodes.a, nodes.b)
15359 if (hasPatches(thunkPatch)) {
15360 patch[index] = new VPatch(VPatch.THUNK, null, thunkPatch)
15364 function hasPatches(patch) {
15365 for (var index in patch) {
15366 if (index !== "a") {
15374 // Execute hooks when two nodes are identical
15375 function unhook(vNode, patch, index) {
15376 if (isVNode(vNode)) {
15378 patch[index] = appendPatch(
15383 undefinedKeys(vNode.hooks)
15388 if (vNode.descendantHooks || vNode.hasThunks) {
15389 var children = vNode.children
15390 var len = children.length
15391 for (var i = 0; i < len; i++) {
15392 var child = children[i]
15395 unhook(child, patch, index)
15397 if (isVNode(child) && child.count) {
15398 index += child.count
15402 } else if (isThunk(vNode)) {
15403 thunks(vNode, null, patch, index)
15407 function undefinedKeys(obj) {
15410 for (var key in obj) {
15411 result[key] = undefined
15417 // List diff, naive left to right reordering
15418 function reorder(aChildren, bChildren) {
15419 // O(M) time, O(M) memory
15420 var bChildIndex = keyIndex(bChildren)
15421 var bKeys = bChildIndex.keys
15422 var bFree = bChildIndex.free
15424 if (bFree.length === bChildren.length) {
15426 children: bChildren,
15431 // O(N) time, O(N) memory
15432 var aChildIndex = keyIndex(aChildren)
15433 var aKeys = aChildIndex.keys
15434 var aFree = aChildIndex.free
15436 if (aFree.length === aChildren.length) {
15438 children: bChildren,
15443 // O(MAX(N, M)) memory
15444 var newChildren = []
15447 var freeCount = bFree.length
15448 var deletedItems = 0
15450 // Iterate through a and match a node in b
15452 for (var i = 0 ; i < aChildren.length; i++) {
15453 var aItem = aChildren[i]
15457 if (bKeys.hasOwnProperty(aItem.key)) {
15458 // Match up the old keys
15459 itemIndex = bKeys[aItem.key]
15460 newChildren.push(bChildren[itemIndex])
15463 // Remove old keyed items
15464 itemIndex = i - deletedItems++
15465 newChildren.push(null)
15468 // Match the item in a with the next free item in b
15469 if (freeIndex < freeCount) {
15470 itemIndex = bFree[freeIndex++]
15471 newChildren.push(bChildren[itemIndex])
15473 // There are no free items in b to match with
15474 // the free items in a, so the extra free nodes
15476 itemIndex = i - deletedItems++
15477 newChildren.push(null)
15482 var lastFreeIndex = freeIndex >= bFree.length ?
15486 // Iterate through b and append any new keys
15488 for (var j = 0; j < bChildren.length; j++) {
15489 var newItem = bChildren[j]
15492 if (!aKeys.hasOwnProperty(newItem.key)) {
15493 // Add any new keyed items
15494 // We are adding new items to the end and then sorting them
15495 // in place. In future we should insert new items in place.
15496 newChildren.push(newItem)
15498 } else if (j >= lastFreeIndex) {
15499 // Add any leftover non-keyed items
15500 newChildren.push(newItem)
15504 var simulate = newChildren.slice()
15505 var simulateIndex = 0
15510 for (var k = 0; k < bChildren.length;) {
15511 var wantedItem = bChildren[k]
15512 simulateItem = simulate[simulateIndex]
15515 while (simulateItem === null && simulate.length) {
15516 removes.push(remove(simulate, simulateIndex, null))
15517 simulateItem = simulate[simulateIndex]
15520 if (!simulateItem || simulateItem.key !== wantedItem.key) {
15521 // if we need a key in this position...
15522 if (wantedItem.key) {
15523 if (simulateItem && simulateItem.key) {
15524 // if an insert doesn't put this key in place, it needs to move
15525 if (bKeys[simulateItem.key] !== k + 1) {
15526 removes.push(remove(simulate, simulateIndex, simulateItem.key))
15527 simulateItem = simulate[simulateIndex]
15528 // if the remove didn't put the wanted item in place, we need to insert it
15529 if (!simulateItem || simulateItem.key !== wantedItem.key) {
15530 inserts.push({key: wantedItem.key, to: k})
15532 // items are matching, so skip ahead
15538 inserts.push({key: wantedItem.key, to: k})
15542 inserts.push({key: wantedItem.key, to: k})
15546 // a key in simulate has no matching wanted key, remove it
15547 else if (simulateItem && simulateItem.key) {
15548 removes.push(remove(simulate, simulateIndex, simulateItem.key))
15557 // remove all the remaining nodes from simulate
15558 while(simulateIndex < simulate.length) {
15559 simulateItem = simulate[simulateIndex]
15560 removes.push(remove(simulate, simulateIndex, simulateItem && simulateItem.key))
15563 // If the only moves we have are deletes then we can just
15564 // let the delete patch remove these items.
15565 if (removes.length === deletedItems && !inserts.length) {
15567 children: newChildren,
15573 children: newChildren,
15581 function remove(arr, index, key) {
15582 arr.splice(index, 1)
15590 function keyIndex(children) {
15593 var length = children.length
15595 for (var i = 0; i < length; i++) {
15596 var child = children[i]
15599 keys[child.key] = i
15606 keys: keys, // A hash of key name to index
15607 free: free // An array of unkeyed item indices
15611 function appendPatch(apply, patch) {
15613 if (isArray(apply)) {
15616 apply = [apply, patch]
15625 },{"../vnode/handle-thunk":175,"../vnode/is-thunk":176,"../vnode/is-vnode":178,"../vnode/is-vtext":179,"../vnode/is-widget":180,"../vnode/vpatch":183,"./diff-props":185,"x-is-array":205}],187:[function(require,module,exports){
15626 /** @license MIT License (c) copyright 2010-2014 original author or authors */
15627 /** @author Brian Cavalier */
15628 /** @author John Hann */
15630 (function(define) { 'use strict';
15631 define(function (require) {
15633 var makePromise = require('./makePromise');
15634 var Scheduler = require('./Scheduler');
15635 var async = require('./env').asap;
15637 return makePromise({
15638 scheduler: new Scheduler(async)
15642 })(typeof define === 'function' && define.amd ? define : function (factory) { module.exports = factory(require); });
15644 },{"./Scheduler":188,"./env":200,"./makePromise":202}],188:[function(require,module,exports){
15645 /** @license MIT License (c) copyright 2010-2014 original author or authors */
15646 /** @author Brian Cavalier */
15647 /** @author John Hann */
15649 (function(define) { 'use strict';
15650 define(function() {
15652 // Credit to Twisol (https://github.com/Twisol) for suggesting
15653 // this type of extensible queue + trampoline approach for next-tick conflation.
15656 * Async task scheduler
15657 * @param {function} async function to schedule a single async function
15660 function Scheduler(async) {
15661 this._async = async;
15662 this._running = false;
15664 this._queue = this;
15665 this._queueLen = 0;
15666 this._afterQueue = {};
15667 this._afterQueueLen = 0;
15670 this.drain = function() {
15677 * @param {{ run:function }} task
15679 Scheduler.prototype.enqueue = function(task) {
15680 this._queue[this._queueLen++] = task;
15685 * Enqueue a task to run after the main task queue
15686 * @param {{ run:function }} task
15688 Scheduler.prototype.afterQueue = function(task) {
15689 this._afterQueue[this._afterQueueLen++] = task;
15693 Scheduler.prototype.run = function() {
15694 if (!this._running) {
15695 this._running = true;
15696 this._async(this.drain);
15701 * Drain the handler queue entirely, and then the after queue
15703 Scheduler.prototype._drain = function() {
15705 for (; i < this._queueLen; ++i) {
15706 this._queue[i].run();
15707 this._queue[i] = void 0;
15710 this._queueLen = 0;
15711 this._running = false;
15713 for (i = 0; i < this._afterQueueLen; ++i) {
15714 this._afterQueue[i].run();
15715 this._afterQueue[i] = void 0;
15718 this._afterQueueLen = 0;
15724 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); }));
15726 },{}],189:[function(require,module,exports){
15727 /** @license MIT License (c) copyright 2010-2014 original author or authors */
15728 /** @author Brian Cavalier */
15729 /** @author John Hann */
15731 (function(define) { 'use strict';
15732 define(function() {
15735 * Custom error type for promises rejected by promise.timeout
15736 * @param {string} message
15739 function TimeoutError (message) {
15741 this.message = message;
15742 this.name = TimeoutError.name;
15743 if (typeof Error.captureStackTrace === 'function') {
15744 Error.captureStackTrace(this, TimeoutError);
15748 TimeoutError.prototype = Object.create(Error.prototype);
15749 TimeoutError.prototype.constructor = TimeoutError;
15751 return TimeoutError;
15753 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); }));
15754 },{}],190:[function(require,module,exports){
15755 /** @license MIT License (c) copyright 2010-2014 original author or authors */
15756 /** @author Brian Cavalier */
15757 /** @author John Hann */
15759 (function(define) { 'use strict';
15760 define(function() {
15762 makeApply.tryCatchResolve = tryCatchResolve;
15766 function makeApply(Promise, call) {
15767 if(arguments.length < 2) {
15768 call = tryCatchResolve;
15773 function apply(f, thisArg, args) {
15774 var p = Promise._defer();
15775 var l = args.length;
15776 var params = new Array(l);
15777 callAndResolve({ f:f, thisArg:thisArg, args:args, params:params, i:l-1, call:call }, p._handler);
15782 function callAndResolve(c, h) {
15784 return call(c.f, c.thisArg, c.params, h);
15787 var handler = Promise._handler(c.args[c.i]);
15788 handler.fold(callAndResolveNext, c, void 0, h);
15791 function callAndResolveNext(c, x, h) {
15794 callAndResolve(c, h);
15798 function tryCatchResolve(f, thisArg, args, resolver) {
15800 resolver.resolve(f.apply(thisArg, args));
15802 resolver.reject(e);
15807 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); }));
15811 },{}],191:[function(require,module,exports){
15812 /** @license MIT License (c) copyright 2010-2014 original author or authors */
15813 /** @author Brian Cavalier */
15814 /** @author John Hann */
15816 (function(define) { 'use strict';
15817 define(function(require) {
15819 var state = require('../state');
15820 var applier = require('../apply');
15822 return function array(Promise) {
15824 var applyFold = applier(Promise);
15825 var toPromise = Promise.resolve;
15826 var all = Promise.all;
15828 var ar = Array.prototype.reduce;
15829 var arr = Array.prototype.reduceRight;
15830 var slice = Array.prototype.slice;
15832 // Additional array combinators
15835 Promise.some = some;
15836 Promise.settle = settle;
15839 Promise.filter = filter;
15840 Promise.reduce = reduce;
15841 Promise.reduceRight = reduceRight;
15844 * When this promise fulfills with an array, do
15845 * onFulfilled.apply(void 0, array)
15846 * @param {function} onFulfilled function to apply
15847 * @returns {Promise} promise for the result of applying onFulfilled
15849 Promise.prototype.spread = function(onFulfilled) {
15850 return this.then(all).then(function(array) {
15851 return onFulfilled.apply(this, array);
15858 * One-winner competitive race.
15859 * Return a promise that will fulfill when one of the promises
15860 * in the input array fulfills, or will reject when all promises
15862 * @param {array} promises
15863 * @returns {Promise} promise for the first fulfilled value
15865 function any(promises) {
15866 var p = Promise._defer();
15867 var resolver = p._handler;
15868 var l = promises.length>>>0;
15873 for (var h, x, i = 0; i < l; ++i) {
15875 if(x === void 0 && !(i in promises)) {
15880 h = Promise._handler(x);
15881 if(h.state() > 0) {
15882 resolver.become(h);
15883 Promise._visitRemaining(promises, i, h);
15886 h.visit(resolver, handleFulfill, handleReject);
15890 if(pending === 0) {
15891 resolver.reject(new RangeError('any(): array must not be empty'));
15896 function handleFulfill(x) {
15897 /*jshint validthis:true*/
15899 this.resolve(x); // this === resolver
15902 function handleReject(e) {
15903 /*jshint validthis:true*/
15904 if(this.resolved) { // this === resolver
15909 if(--pending === 0) {
15910 this.reject(errors);
15916 * N-winner competitive race
15917 * Return a promise that will fulfill when n input promises have
15918 * fulfilled, or will reject when it becomes impossible for n
15919 * input promises to fulfill (ie when promises.length - n + 1
15921 * @param {array} promises
15922 * @param {number} n
15923 * @returns {Promise} promise for the earliest n fulfillment values
15927 function some(promises, n) {
15928 /*jshint maxcomplexity:7*/
15929 var p = Promise._defer();
15930 var resolver = p._handler;
15935 var l = promises.length>>>0;
15938 var x, i; // reused in both for() loops
15940 // First pass: count actual array items
15941 for(i=0; i<l; ++i) {
15943 if(x === void 0 && !(i in promises)) {
15949 // Compute actual goals
15950 n = Math.max(n, 0);
15951 nReject = (nFulfill - n + 1);
15952 nFulfill = Math.min(n, nFulfill);
15955 resolver.reject(new RangeError('some(): array must contain at least '
15956 + n + ' item(s), but had ' + nFulfill));
15957 } else if(nFulfill === 0) {
15958 resolver.resolve(results);
15961 // Second pass: observe each array item, make progress toward goals
15962 for(i=0; i<l; ++i) {
15964 if(x === void 0 && !(i in promises)) {
15968 Promise._handler(x).visit(resolver, fulfill, reject, resolver.notify);
15973 function fulfill(x) {
15974 /*jshint validthis:true*/
15975 if(this.resolved) { // this === resolver
15980 if(--nFulfill === 0) {
15982 this.resolve(results);
15986 function reject(e) {
15987 /*jshint validthis:true*/
15988 if(this.resolved) { // this === resolver
15993 if(--nReject === 0) {
15995 this.reject(errors);
16001 * Apply f to the value of each promise in a list of promises
16002 * and return a new list containing the results.
16003 * @param {array} promises
16004 * @param {function(x:*, index:Number):*} f mapping function
16005 * @returns {Promise}
16007 function map(promises, f) {
16008 return Promise._traverse(f, promises);
16012 * Filter the provided array of promises using the provided predicate. Input may
16013 * contain promises and values
16014 * @param {Array} promises array of promises and values
16015 * @param {function(x:*, index:Number):boolean} predicate filtering predicate.
16016 * Must return truthy (or promise for truthy) for items to retain.
16017 * @returns {Promise} promise that will fulfill with an array containing all items
16018 * for which predicate returned truthy.
16020 function filter(promises, predicate) {
16021 var a = slice.call(promises);
16022 return Promise._traverse(predicate, a).then(function(keep) {
16023 return filterSync(a, keep);
16027 function filterSync(promises, keep) {
16028 // Safe because we know all promises have fulfilled if we've made it this far
16029 var l = keep.length;
16030 var filtered = new Array(l);
16031 for(var i=0, j=0; i<l; ++i) {
16033 filtered[j++] = Promise._handler(promises[i]).value;
16036 filtered.length = j;
16042 * Return a promise that will always fulfill with an array containing
16043 * the outcome states of all input promises. The returned promise
16044 * will never reject.
16045 * @param {Array} promises
16046 * @returns {Promise} promise for array of settled state descriptors
16048 function settle(promises) {
16049 return all(promises.map(settleOne));
16052 function settleOne(p) {
16053 var h = Promise._handler(p);
16054 if(h.state() === 0) {
16055 return toPromise(p).then(state.fulfilled, state.rejected);
16059 return state.inspect(h);
16063 * Traditional reduce function, similar to `Array.prototype.reduce()`, but
16064 * input may contain promises and/or values, and reduceFunc
16065 * may return either a value or a promise, *and* initialValue may
16066 * be a promise for the starting value.
16067 * @param {Array|Promise} promises array or promise for an array of anything,
16068 * may contain a mix of promises and values.
16069 * @param {function(accumulated:*, x:*, index:Number):*} f reduce function
16070 * @returns {Promise} that will resolve to the final reduced value
16072 function reduce(promises, f /*, initialValue */) {
16073 return arguments.length > 2 ? ar.call(promises, liftCombine(f), arguments[2])
16074 : ar.call(promises, liftCombine(f));
16078 * Traditional reduce function, similar to `Array.prototype.reduceRight()`, but
16079 * input may contain promises and/or values, and reduceFunc
16080 * may return either a value or a promise, *and* initialValue may
16081 * be a promise for the starting value.
16082 * @param {Array|Promise} promises array or promise for an array of anything,
16083 * may contain a mix of promises and values.
16084 * @param {function(accumulated:*, x:*, index:Number):*} f reduce function
16085 * @returns {Promise} that will resolve to the final reduced value
16087 function reduceRight(promises, f /*, initialValue */) {
16088 return arguments.length > 2 ? arr.call(promises, liftCombine(f), arguments[2])
16089 : arr.call(promises, liftCombine(f));
16092 function liftCombine(f) {
16093 return function(z, x, i) {
16094 return applyFold(f, void 0, [z,x,i]);
16100 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(require); }));
16102 },{"../apply":190,"../state":203}],192:[function(require,module,exports){
16103 /** @license MIT License (c) copyright 2010-2014 original author or authors */
16104 /** @author Brian Cavalier */
16105 /** @author John Hann */
16107 (function(define) { 'use strict';
16108 define(function() {
16110 return function flow(Promise) {
16112 var resolve = Promise.resolve;
16113 var reject = Promise.reject;
16114 var origCatch = Promise.prototype['catch'];
16117 * Handle the ultimate fulfillment value or rejection reason, and assume
16118 * responsibility for all errors. If an error propagates out of result
16119 * or handleFatalError, it will be rethrown to the host, resulting in a
16120 * loud stack track on most platforms and a crash on some.
16121 * @param {function?} onResult
16122 * @param {function?} onError
16123 * @returns {undefined}
16125 Promise.prototype.done = function(onResult, onError) {
16126 this._handler.visit(this._handler.receiver, onResult, onError);
16130 * Add Error-type and predicate matching to catch. Examples:
16131 * promise.catch(TypeError, handleTypeError)
16132 * .catch(predicate, handleMatchedErrors)
16133 * .catch(handleRemainingErrors)
16134 * @param onRejected
16137 Promise.prototype['catch'] = Promise.prototype.otherwise = function(onRejected) {
16138 if (arguments.length < 2) {
16139 return origCatch.call(this, onRejected);
16142 if(typeof onRejected !== 'function') {
16143 return this.ensure(rejectInvalidPredicate);
16146 return origCatch.call(this, createCatchFilter(arguments[1], onRejected));
16150 * Wraps the provided catch handler, so that it will only be called
16151 * if the predicate evaluates truthy
16152 * @param {?function} handler
16153 * @param {function} predicate
16154 * @returns {function} conditional catch handler
16156 function createCatchFilter(handler, predicate) {
16157 return function(e) {
16158 return evaluatePredicate(e, predicate)
16159 ? handler.call(this, e)
16165 * Ensures that onFulfilledOrRejected will be called regardless of whether
16166 * this promise is fulfilled or rejected. onFulfilledOrRejected WILL NOT
16167 * receive the promises' value or reason. Any returned value will be disregarded.
16168 * onFulfilledOrRejected may throw or return a rejected promise to signal
16169 * an additional error.
16170 * @param {function} handler handler to be called regardless of
16171 * fulfillment or rejection
16172 * @returns {Promise}
16174 Promise.prototype['finally'] = Promise.prototype.ensure = function(handler) {
16175 if(typeof handler !== 'function') {
16179 return this.then(function(x) {
16180 return runSideEffect(handler, this, identity, x);
16182 return runSideEffect(handler, this, reject, e);
16186 function runSideEffect (handler, thisArg, propagate, value) {
16187 var result = handler.call(thisArg);
16188 return maybeThenable(result)
16189 ? propagateValue(result, propagate, value)
16190 : propagate(value);
16193 function propagateValue (result, propagate, x) {
16194 return resolve(result).then(function () {
16195 return propagate(x);
16200 * Recover from a failure by returning a defaultValue. If defaultValue
16201 * is a promise, it's fulfillment value will be used. If defaultValue is
16202 * a promise that rejects, the returned promise will reject with the
16204 * @param {*} defaultValue
16205 * @returns {Promise} new promise
16207 Promise.prototype['else'] = Promise.prototype.orElse = function(defaultValue) {
16208 return this.then(void 0, function() {
16209 return defaultValue;
16214 * Shortcut for .then(function() { return value; })
16216 * @return {Promise} a promise that:
16217 * - is fulfilled if value is not a promise, or
16218 * - if value is a promise, will fulfill with its value, or reject
16221 Promise.prototype['yield'] = function(value) {
16222 return this.then(function() {
16228 * Runs a side effect when this promise fulfills, without changing the
16229 * fulfillment value.
16230 * @param {function} onFulfilledSideEffect
16231 * @returns {Promise}
16233 Promise.prototype.tap = function(onFulfilledSideEffect) {
16234 return this.then(onFulfilledSideEffect)['yield'](this);
16240 function rejectInvalidPredicate() {
16241 throw new TypeError('catch predicate must be a function');
16244 function evaluatePredicate(e, predicate) {
16245 return isError(predicate) ? e instanceof predicate : predicate(e);
16248 function isError(predicate) {
16249 return predicate === Error
16250 || (predicate != null && predicate.prototype instanceof Error);
16253 function maybeThenable(x) {
16254 return (typeof x === 'object' || typeof x === 'function') && x !== null;
16257 function identity(x) {
16262 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); }));
16264 },{}],193:[function(require,module,exports){
16265 /** @license MIT License (c) copyright 2010-2014 original author or authors */
16266 /** @author Brian Cavalier */
16267 /** @author John Hann */
16268 /** @author Jeff Escalante */
16270 (function(define) { 'use strict';
16271 define(function() {
16273 return function fold(Promise) {
16275 Promise.prototype.fold = function(f, z) {
16276 var promise = this._beget();
16278 this._handler.fold(function(z, x, to) {
16279 Promise._handler(z).fold(function(x, z, to) {
16280 to.resolve(f.call(this, z, x));
16282 }, z, promise._handler.receiver, promise._handler);
16291 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); }));
16293 },{}],194:[function(require,module,exports){
16294 /** @license MIT License (c) copyright 2010-2014 original author or authors */
16295 /** @author Brian Cavalier */
16296 /** @author John Hann */
16298 (function(define) { 'use strict';
16299 define(function(require) {
16301 var inspect = require('../state').inspect;
16303 return function inspection(Promise) {
16305 Promise.prototype.inspect = function() {
16306 return inspect(Promise._handler(this));
16313 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(require); }));
16315 },{"../state":203}],195:[function(require,module,exports){
16316 /** @license MIT License (c) copyright 2010-2014 original author or authors */
16317 /** @author Brian Cavalier */
16318 /** @author John Hann */
16320 (function(define) { 'use strict';
16321 define(function() {
16323 return function generate(Promise) {
16325 var resolve = Promise.resolve;
16327 Promise.iterate = iterate;
16328 Promise.unfold = unfold;
16333 * @deprecated Use github.com/cujojs/most streams and most.iterate
16334 * Generate a (potentially infinite) stream of promised values:
16335 * x, f(x), f(f(x)), etc. until condition(x) returns true
16336 * @param {function} f function to generate a new x from the previous x
16337 * @param {function} condition function that, given the current x, returns
16338 * truthy when the iterate should stop
16339 * @param {function} handler function to handle the value produced by f
16340 * @param {*|Promise} x starting value, may be a promise
16341 * @return {Promise} the result of the last call to f before
16342 * condition returns true
16344 function iterate(f, condition, handler, x) {
16345 return unfold(function(x) {
16347 }, condition, handler, x);
16351 * @deprecated Use github.com/cujojs/most streams and most.unfold
16352 * Generate a (potentially infinite) stream of promised values
16353 * by applying handler(generator(seed)) iteratively until
16354 * condition(seed) returns true.
16355 * @param {function} unspool function that generates a [value, newSeed]
16357 * @param {function} condition function that, given the current seed, returns
16358 * truthy when the unfold should stop
16359 * @param {function} handler function to handle the value produced by unspool
16360 * @param x {*|Promise} starting value, may be a promise
16361 * @return {Promise} the result of the last value produced by unspool before
16362 * condition returns true
16364 function unfold(unspool, condition, handler, x) {
16365 return resolve(x).then(function(seed) {
16366 return resolve(condition(seed)).then(function(done) {
16367 return done ? seed : resolve(unspool(seed)).spread(next);
16371 function next(item, newSeed) {
16372 return resolve(handler(item)).then(function() {
16373 return unfold(unspool, condition, handler, newSeed);
16380 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); }));
16382 },{}],196:[function(require,module,exports){
16383 /** @license MIT License (c) copyright 2010-2014 original author or authors */
16384 /** @author Brian Cavalier */
16385 /** @author John Hann */
16387 (function(define) { 'use strict';
16388 define(function() {
16390 return function progress(Promise) {
16394 * Register a progress handler for this promise
16395 * @param {function} onProgress
16396 * @returns {Promise}
16398 Promise.prototype.progress = function(onProgress) {
16399 return this.then(void 0, void 0, onProgress);
16406 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); }));
16408 },{}],197:[function(require,module,exports){
16409 /** @license MIT License (c) copyright 2010-2014 original author or authors */
16410 /** @author Brian Cavalier */
16411 /** @author John Hann */
16413 (function(define) { 'use strict';
16414 define(function(require) {
16416 var env = require('../env');
16417 var TimeoutError = require('../TimeoutError');
16419 function setTimeout(f, ms, x, y) {
16420 return env.setTimer(function() {
16425 return function timed(Promise) {
16427 * Return a new promise whose fulfillment value is revealed only
16428 * after ms milliseconds
16429 * @param {number} ms milliseconds
16430 * @returns {Promise}
16432 Promise.prototype.delay = function(ms) {
16433 var p = this._beget();
16434 this._handler.fold(handleDelay, ms, void 0, p._handler);
16438 function handleDelay(ms, x, h) {
16439 setTimeout(resolveDelay, ms, x, h);
16442 function resolveDelay(x, h) {
16447 * Return a new promise that rejects after ms milliseconds unless
16448 * this promise fulfills earlier, in which case the returned promise
16449 * fulfills with the same value.
16450 * @param {number} ms milliseconds
16451 * @param {Error|*=} reason optional rejection reason to use, defaults
16452 * to a TimeoutError if not provided
16453 * @returns {Promise}
16455 Promise.prototype.timeout = function(ms, reason) {
16456 var p = this._beget();
16457 var h = p._handler;
16459 var t = setTimeout(onTimeout, ms, reason, p._handler);
16461 this._handler.visit(h,
16462 function onFulfill(x) {
16464 this.resolve(x); // this = h
16466 function onReject(x) {
16468 this.reject(x); // this = h
16475 function onTimeout(reason, h, ms) {
16476 var e = typeof reason === 'undefined'
16477 ? new TimeoutError('timed out after ' + ms + 'ms')
16486 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(require); }));
16488 },{"../TimeoutError":189,"../env":200}],198:[function(require,module,exports){
16489 /** @license MIT License (c) copyright 2010-2014 original author or authors */
16490 /** @author Brian Cavalier */
16491 /** @author John Hann */
16493 (function(define) { 'use strict';
16494 define(function(require) {
16496 var setTimer = require('../env').setTimer;
16497 var format = require('../format');
16499 return function unhandledRejection(Promise) {
16501 var logError = noop;
16502 var logInfo = noop;
16505 if(typeof console !== 'undefined') {
16506 // Alias console to prevent things like uglify's drop_console option from
16507 // removing console.log/error. Unhandled rejections fall into the same
16508 // category as uncaught exceptions, and build tools shouldn't silence them.
16509 localConsole = console;
16510 logError = typeof localConsole.error !== 'undefined'
16511 ? function (e) { localConsole.error(e); }
16512 : function (e) { localConsole.log(e); };
16514 logInfo = typeof localConsole.info !== 'undefined'
16515 ? function (e) { localConsole.info(e); }
16516 : function (e) { localConsole.log(e); };
16519 Promise.onPotentiallyUnhandledRejection = function(rejection) {
16520 enqueue(report, rejection);
16523 Promise.onPotentiallyUnhandledRejectionHandled = function(rejection) {
16524 enqueue(unreport, rejection);
16527 Promise.onFatalRejection = function(rejection) {
16528 enqueue(throwit, rejection.value);
16533 var running = null;
16535 function report(r) {
16538 logError('Potentially unhandled rejection [' + r.id + '] ' + format.formatError(r.value));
16542 function unreport(r) {
16543 var i = reported.indexOf(r);
16545 reported.splice(i, 1);
16546 logInfo('Handled previous rejection [' + r.id + '] ' + format.formatObject(r.value));
16550 function enqueue(f, x) {
16552 if(running === null) {
16553 running = setTimer(flush, 0);
16559 while(tasks.length > 0) {
16560 tasks.shift()(tasks.shift());
16567 function throwit(e) {
16574 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(require); }));
16576 },{"../env":200,"../format":201}],199:[function(require,module,exports){
16577 /** @license MIT License (c) copyright 2010-2014 original author or authors */
16578 /** @author Brian Cavalier */
16579 /** @author John Hann */
16581 (function(define) { 'use strict';
16582 define(function() {
16584 return function addWith(Promise) {
16586 * Returns a promise whose handlers will be called with `this` set to
16587 * the supplied receiver. Subsequent promises derived from the
16588 * returned promise will also have their handlers called with receiver
16589 * as `this`. Calling `with` with undefined or no arguments will return
16590 * a promise whose handlers will again be called in the usual Promises/A+
16591 * way (no `this`) thus safely undoing any previous `with` in the
16594 * WARNING: Promises returned from `with`/`withThis` are NOT Promises/A+
16595 * compliant, specifically violating 2.2.5 (http://promisesaplus.com/#point-41)
16597 * @param {object} receiver `this` value for all handlers attached to
16598 * the returned promise.
16599 * @returns {Promise}
16601 Promise.prototype['with'] = Promise.prototype.withThis = function(receiver) {
16602 var p = this._beget();
16603 var child = p._handler;
16604 child.receiver = receiver;
16605 this._handler.chain(child, receiver);
16613 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); }));
16616 },{}],200:[function(require,module,exports){
16617 (function (process){
16618 /** @license MIT License (c) copyright 2010-2014 original author or authors */
16619 /** @author Brian Cavalier */
16620 /** @author John Hann */
16622 /*global process,document,setTimeout,clearTimeout,MutationObserver,WebKitMutationObserver*/
16623 (function(define) { 'use strict';
16624 define(function(require) {
16625 /*jshint maxcomplexity:6*/
16627 // Sniff "best" async scheduling option
16628 // Prefer process.nextTick or MutationObserver, then check for
16629 // setTimeout, and finally vertx, since its the only env that doesn't
16633 var capturedSetTimeout = typeof setTimeout !== 'undefined' && setTimeout;
16636 var setTimer = function(f, ms) { return setTimeout(f, ms); };
16637 var clearTimer = function(t) { return clearTimeout(t); };
16638 var asap = function (f) { return capturedSetTimeout(f, 0); };
16640 // Detect specific env
16641 if (isNode()) { // Node
16642 asap = function (f) { return process.nextTick(f); };
16644 } else if (MutationObs = hasMutationObserver()) { // Modern browser
16645 asap = initMutationObserver(MutationObs);
16647 } else if (!capturedSetTimeout) { // vert.x
16648 var vertxRequire = require;
16649 var vertx = vertxRequire('vertx');
16650 setTimer = function (f, ms) { return vertx.setTimer(ms, f); };
16651 clearTimer = vertx.cancelTimer;
16652 asap = vertx.runOnLoop || vertx.runOnContext;
16656 setTimer: setTimer,
16657 clearTimer: clearTimer,
16661 function isNode () {
16662 return typeof process !== 'undefined' &&
16663 Object.prototype.toString.call(process) === '[object process]';
16666 function hasMutationObserver () {
16667 return (typeof MutationObserver === 'function' && MutationObserver) ||
16668 (typeof WebKitMutationObserver === 'function' && WebKitMutationObserver);
16671 function initMutationObserver(MutationObserver) {
16673 var node = document.createTextNode('');
16674 var o = new MutationObserver(run);
16675 o.observe(node, { characterData: true });
16679 scheduled = void 0;
16684 return function (f) {
16686 node.data = (i ^= 1);
16690 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(require); }));
16692 }).call(this,require('_process'))
16694 },{"_process":4}],201:[function(require,module,exports){
16695 /** @license MIT License (c) copyright 2010-2014 original author or authors */
16696 /** @author Brian Cavalier */
16697 /** @author John Hann */
16699 (function(define) { 'use strict';
16700 define(function() {
16703 formatError: formatError,
16704 formatObject: formatObject,
16705 tryStringify: tryStringify
16709 * Format an error into a string. If e is an Error and has a stack property,
16710 * it's returned. Otherwise, e is formatted using formatObject, with a
16711 * warning added about e not being a proper Error.
16713 * @returns {String} formatted string, suitable for output to developers
16715 function formatError(e) {
16716 var s = typeof e === 'object' && e !== null && (e.stack || e.message) ? e.stack || e.message : formatObject(e);
16717 return e instanceof Error ? s : s + ' (WARNING: non-Error used)';
16721 * Format an object, detecting "plain" objects and running them through
16722 * JSON.stringify if possible.
16723 * @param {Object} o
16724 * @returns {string}
16726 function formatObject(o) {
16728 if(s === '[object Object]' && typeof JSON !== 'undefined') {
16729 s = tryStringify(o, s);
16735 * Try to return the result of JSON.stringify(x). If that fails, return
16738 * @param {*} defaultValue
16739 * @returns {String|*} JSON.stringify(x) or defaultValue
16741 function tryStringify(x, defaultValue) {
16743 return JSON.stringify(x);
16745 return defaultValue;
16750 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); }));
16752 },{}],202:[function(require,module,exports){
16753 (function (process){
16754 /** @license MIT License (c) copyright 2010-2014 original author or authors */
16755 /** @author Brian Cavalier */
16756 /** @author John Hann */
16758 (function(define) { 'use strict';
16759 define(function() {
16761 return function makePromise(environment) {
16763 var tasks = environment.scheduler;
16764 var emitRejection = initEmitRejection();
16766 var objectCreate = Object.create ||
16768 function Child() {}
16769 Child.prototype = proto;
16770 return new Child();
16774 * Create a promise whose fate is determined by resolver
16776 * @returns {Promise} promise
16779 function Promise(resolver, handler) {
16780 this._handler = resolver === Handler ? handler : init(resolver);
16784 * Run the supplied resolver
16786 * @returns {Pending}
16788 function init(resolver) {
16789 var handler = new Pending();
16792 resolver(promiseResolve, promiseReject, promiseNotify);
16800 * Transition from pre-resolution state to post-resolution state, notifying
16801 * all listeners of the ultimate fulfillment or rejection
16802 * @param {*} x resolution value
16804 function promiseResolve (x) {
16805 handler.resolve(x);
16808 * Reject this promise with reason, which will be used verbatim
16809 * @param {Error|*} reason rejection reason, strongly suggested
16810 * to be an Error type
16812 function promiseReject (reason) {
16813 handler.reject(reason);
16818 * Issue a progress event, notifying all progress listeners
16819 * @param {*} x progress event payload to pass to all listeners
16821 function promiseNotify (x) {
16828 Promise.resolve = resolve;
16829 Promise.reject = reject;
16830 Promise.never = never;
16832 Promise._defer = defer;
16833 Promise._handler = getHandler;
16836 * Returns a trusted promise. If x is already a trusted promise, it is
16837 * returned, otherwise returns a new trusted Promise which follows x.
16839 * @return {Promise} promise
16841 function resolve(x) {
16842 return isPromise(x) ? x
16843 : new Promise(Handler, new Async(getHandler(x)));
16847 * Return a reject promise with x as its reason (x is used verbatim)
16849 * @returns {Promise} rejected promise
16851 function reject(x) {
16852 return new Promise(Handler, new Async(new Rejected(x)));
16856 * Return a promise that remains pending forever
16857 * @returns {Promise} forever-pending promise.
16860 return foreverPendingPromise; // Should be frozen
16864 * Creates an internal {promise, resolver} pair
16866 * @returns {Promise}
16869 return new Promise(Handler, new Pending());
16872 // Transformation and flow control
16875 * Transform this promise's fulfillment value, returning a new Promise
16876 * for the transformed result. If the promise cannot be fulfilled, onRejected
16877 * is called with the reason. onProgress *may* be called with updates toward
16878 * this promise's fulfillment.
16879 * @param {function=} onFulfilled fulfillment handler
16880 * @param {function=} onRejected rejection handler
16881 * @param {function=} onProgress @deprecated progress handler
16882 * @return {Promise} new promise
16884 Promise.prototype.then = function(onFulfilled, onRejected, onProgress) {
16885 var parent = this._handler;
16886 var state = parent.join().state();
16888 if ((typeof onFulfilled !== 'function' && state > 0) ||
16889 (typeof onRejected !== 'function' && state < 0)) {
16890 // Short circuit: value will not change, simply share handler
16891 return new this.constructor(Handler, parent);
16894 var p = this._beget();
16895 var child = p._handler;
16897 parent.chain(child, parent.receiver, onFulfilled, onRejected, onProgress);
16903 * If this promise cannot be fulfilled due to an error, call onRejected to
16904 * handle the error. Shortcut for .then(undefined, onRejected)
16905 * @param {function?} onRejected
16906 * @return {Promise}
16908 Promise.prototype['catch'] = function(onRejected) {
16909 return this.then(void 0, onRejected);
16913 * Creates a new, pending promise of the same type as this promise
16915 * @returns {Promise}
16917 Promise.prototype._beget = function() {
16918 return begetFrom(this._handler, this.constructor);
16921 function begetFrom(parent, Promise) {
16922 var child = new Pending(parent.receiver, parent.join().context);
16923 return new Promise(Handler, child);
16926 // Array combinators
16929 Promise.race = race;
16930 Promise._traverse = traverse;
16933 * Return a promise that will fulfill when all promises in the
16934 * input array have fulfilled, or will reject when one of the
16935 * promises rejects.
16936 * @param {array} promises array of promises
16937 * @returns {Promise} promise for array of fulfillment values
16939 function all(promises) {
16940 return traverseWith(snd, null, promises);
16944 * Array<Promise<X>> -> Promise<Array<f(X)>>
16946 * @param {function} f function to apply to each promise's value
16947 * @param {Array} promises array of promises
16948 * @returns {Promise} promise for transformed values
16950 function traverse(f, promises) {
16951 return traverseWith(tryCatch2, f, promises);
16954 function traverseWith(tryMap, f, promises) {
16955 var handler = typeof f === 'function' ? mapAt : settleAt;
16957 var resolver = new Pending();
16958 var pending = promises.length >>> 0;
16959 var results = new Array(pending);
16961 for (var i = 0, x; i < promises.length && !resolver.resolved; ++i) {
16964 if (x === void 0 && !(i in promises)) {
16969 traverseAt(promises, handler, i, x, resolver);
16972 if(pending === 0) {
16973 resolver.become(new Fulfilled(results));
16976 return new Promise(Handler, resolver);
16978 function mapAt(i, x, resolver) {
16979 if(!resolver.resolved) {
16980 traverseAt(promises, settleAt, i, tryMap(f, x, i), resolver);
16984 function settleAt(i, x, resolver) {
16986 if(--pending === 0) {
16987 resolver.become(new Fulfilled(results));
16992 function traverseAt(promises, handler, i, x, resolver) {
16993 if (maybeThenable(x)) {
16994 var h = getHandlerMaybeThenable(x);
16998 h.fold(handler, i, void 0, resolver);
16999 } else if (s > 0) {
17000 handler(i, h.value, resolver);
17002 resolver.become(h);
17003 visitRemaining(promises, i+1, h);
17006 handler(i, x, resolver);
17010 Promise._visitRemaining = visitRemaining;
17011 function visitRemaining(promises, start, handler) {
17012 for(var i=start; i<promises.length; ++i) {
17013 markAsHandled(getHandler(promises[i]), handler);
17017 function markAsHandled(h, handler) {
17018 if(h === handler) {
17024 h.visit(h, void 0, h._unreport);
17031 * Fulfill-reject competitive race. Return a promise that will settle
17032 * to the same state as the earliest input promise to settle.
17034 * WARNING: The ES6 Promise spec requires that race()ing an empty array
17035 * must return a promise that is pending forever. This implementation
17036 * returns a singleton forever-pending promise, the same singleton that is
17037 * returned by Promise.never(), thus can be checked with ===
17039 * @param {array} promises array of promises to race
17040 * @returns {Promise} if input is non-empty, a promise that will settle
17041 * to the same outcome as the earliest input promise to settle. if empty
17042 * is empty, returns a promise that will never settle.
17044 function race(promises) {
17045 if(typeof promises !== 'object' || promises === null) {
17046 return reject(new TypeError('non-iterable passed to race()'));
17049 // Sigh, race([]) is untestable unless we return *something*
17050 // that is recognizable without calling .then() on it.
17051 return promises.length === 0 ? never()
17052 : promises.length === 1 ? resolve(promises[0])
17053 : runRace(promises);
17056 function runRace(promises) {
17057 var resolver = new Pending();
17059 for(i=0; i<promises.length; ++i) {
17061 if (x === void 0 && !(i in promises)) {
17066 if(h.state() !== 0) {
17067 resolver.become(h);
17068 visitRemaining(promises, i+1, h);
17071 h.visit(resolver, resolver.resolve, resolver.reject);
17074 return new Promise(Handler, resolver);
17077 // Promise internals
17078 // Below this, everything is @private
17081 * Get an appropriate handler for x, without checking for cycles
17083 * @returns {object} handler
17085 function getHandler(x) {
17087 return x._handler.join();
17089 return maybeThenable(x) ? getHandlerUntrusted(x) : new Fulfilled(x);
17093 * Get a handler for thenable x.
17094 * NOTE: You must only call this if maybeThenable(x) == true
17095 * @param {object|function|Promise} x
17096 * @returns {object} handler
17098 function getHandlerMaybeThenable(x) {
17099 return isPromise(x) ? x._handler.join() : getHandlerUntrusted(x);
17103 * Get a handler for potentially untrusted thenable x
17105 * @returns {object} handler
17107 function getHandlerUntrusted(x) {
17109 var untrustedThen = x.then;
17110 return typeof untrustedThen === 'function'
17111 ? new Thenable(untrustedThen, x)
17112 : new Fulfilled(x);
17114 return new Rejected(e);
17119 * Handler for a promise that is pending forever
17122 function Handler() {}
17124 Handler.prototype.when
17125 = Handler.prototype.become
17126 = Handler.prototype.notify // deprecated
17127 = Handler.prototype.fail
17128 = Handler.prototype._unreport
17129 = Handler.prototype._report
17132 Handler.prototype._state = 0;
17134 Handler.prototype.state = function() {
17135 return this._state;
17139 * Recursively collapse handler chain to find the handler
17140 * nearest to the fully resolved value.
17141 * @returns {object} handler nearest the fully resolved value
17143 Handler.prototype.join = function() {
17145 while(h.handler !== void 0) {
17151 Handler.prototype.chain = function(to, receiver, fulfilled, rejected, progress) {
17154 receiver: receiver,
17155 fulfilled: fulfilled,
17156 rejected: rejected,
17161 Handler.prototype.visit = function(receiver, fulfilled, rejected, progress) {
17162 this.chain(failIfRejected, receiver, fulfilled, rejected, progress);
17165 Handler.prototype.fold = function(f, z, c, to) {
17166 this.when(new Fold(f, z, c, to));
17170 * Handler that invokes fail() on any handler it becomes
17173 function FailIfRejected() {}
17175 inherit(Handler, FailIfRejected);
17177 FailIfRejected.prototype.become = function(h) {
17181 var failIfRejected = new FailIfRejected();
17184 * Handler that manages a queue of consumers waiting on a pending promise
17187 function Pending(receiver, inheritedContext) {
17188 Promise.createContext(this, inheritedContext);
17190 this.consumers = void 0;
17191 this.receiver = receiver;
17192 this.handler = void 0;
17193 this.resolved = false;
17196 inherit(Handler, Pending);
17198 Pending.prototype._state = 0;
17200 Pending.prototype.resolve = function(x) {
17201 this.become(getHandler(x));
17204 Pending.prototype.reject = function(x) {
17205 if(this.resolved) {
17209 this.become(new Rejected(x));
17212 Pending.prototype.join = function() {
17213 if (!this.resolved) {
17219 while (h.handler !== void 0) {
17222 return this.handler = cycle();
17229 Pending.prototype.run = function() {
17230 var q = this.consumers;
17231 var handler = this.handler;
17232 this.handler = this.handler.join();
17233 this.consumers = void 0;
17235 for (var i = 0; i < q.length; ++i) {
17236 handler.when(q[i]);
17240 Pending.prototype.become = function(handler) {
17241 if(this.resolved) {
17245 this.resolved = true;
17246 this.handler = handler;
17247 if(this.consumers !== void 0) {
17248 tasks.enqueue(this);
17251 if(this.context !== void 0) {
17252 handler._report(this.context);
17256 Pending.prototype.when = function(continuation) {
17257 if(this.resolved) {
17258 tasks.enqueue(new ContinuationTask(continuation, this.handler));
17260 if(this.consumers === void 0) {
17261 this.consumers = [continuation];
17263 this.consumers.push(continuation);
17271 Pending.prototype.notify = function(x) {
17272 if(!this.resolved) {
17273 tasks.enqueue(new ProgressTask(x, this));
17277 Pending.prototype.fail = function(context) {
17278 var c = typeof context === 'undefined' ? this.context : context;
17279 this.resolved && this.handler.join().fail(c);
17282 Pending.prototype._report = function(context) {
17283 this.resolved && this.handler.join()._report(context);
17286 Pending.prototype._unreport = function() {
17287 this.resolved && this.handler.join()._unreport();
17291 * Wrap another handler and force it into a future stack
17292 * @param {object} handler
17295 function Async(handler) {
17296 this.handler = handler;
17299 inherit(Handler, Async);
17301 Async.prototype.when = function(continuation) {
17302 tasks.enqueue(new ContinuationTask(continuation, this));
17305 Async.prototype._report = function(context) {
17306 this.join()._report(context);
17309 Async.prototype._unreport = function() {
17310 this.join()._unreport();
17314 * Handler that wraps an untrusted thenable and assimilates it in a future stack
17315 * @param {function} then
17316 * @param {{then: function}} thenable
17319 function Thenable(then, thenable) {
17320 Pending.call(this);
17321 tasks.enqueue(new AssimilateTask(then, thenable, this));
17324 inherit(Pending, Thenable);
17327 * Handler for a fulfilled promise
17328 * @param {*} x fulfillment value
17331 function Fulfilled(x) {
17332 Promise.createContext(this);
17336 inherit(Handler, Fulfilled);
17338 Fulfilled.prototype._state = 1;
17340 Fulfilled.prototype.fold = function(f, z, c, to) {
17341 runContinuation3(f, z, this, c, to);
17344 Fulfilled.prototype.when = function(cont) {
17345 runContinuation1(cont.fulfilled, this, cont.receiver, cont.resolver);
17351 * Handler for a rejected promise
17352 * @param {*} x rejection reason
17355 function Rejected(x) {
17356 Promise.createContext(this);
17358 this.id = ++errorId;
17360 this.handled = false;
17361 this.reported = false;
17366 inherit(Handler, Rejected);
17368 Rejected.prototype._state = -1;
17370 Rejected.prototype.fold = function(f, z, c, to) {
17374 Rejected.prototype.when = function(cont) {
17375 if(typeof cont.rejected === 'function') {
17378 runContinuation1(cont.rejected, this, cont.receiver, cont.resolver);
17381 Rejected.prototype._report = function(context) {
17382 tasks.afterQueue(new ReportTask(this, context));
17385 Rejected.prototype._unreport = function() {
17389 this.handled = true;
17390 tasks.afterQueue(new UnreportTask(this));
17393 Rejected.prototype.fail = function(context) {
17394 this.reported = true;
17395 emitRejection('unhandledRejection', this);
17396 Promise.onFatalRejection(this, context === void 0 ? this.context : context);
17399 function ReportTask(rejection, context) {
17400 this.rejection = rejection;
17401 this.context = context;
17404 ReportTask.prototype.run = function() {
17405 if(!this.rejection.handled && !this.rejection.reported) {
17406 this.rejection.reported = true;
17407 emitRejection('unhandledRejection', this.rejection) ||
17408 Promise.onPotentiallyUnhandledRejection(this.rejection, this.context);
17412 function UnreportTask(rejection) {
17413 this.rejection = rejection;
17416 UnreportTask.prototype.run = function() {
17417 if(this.rejection.reported) {
17418 emitRejection('rejectionHandled', this.rejection) ||
17419 Promise.onPotentiallyUnhandledRejectionHandled(this.rejection);
17423 // Unhandled rejection hooks
17424 // By default, everything is a noop
17426 Promise.createContext
17427 = Promise.enterContext
17428 = Promise.exitContext
17429 = Promise.onPotentiallyUnhandledRejection
17430 = Promise.onPotentiallyUnhandledRejectionHandled
17431 = Promise.onFatalRejection
17434 // Errors and singletons
17436 var foreverPendingHandler = new Handler();
17437 var foreverPendingPromise = new Promise(Handler, foreverPendingHandler);
17440 return new Rejected(new TypeError('Promise cycle'));
17446 * Run a single consumer
17449 function ContinuationTask(continuation, handler) {
17450 this.continuation = continuation;
17451 this.handler = handler;
17454 ContinuationTask.prototype.run = function() {
17455 this.handler.join().when(this.continuation);
17459 * Run a queue of progress handlers
17462 function ProgressTask(value, handler) {
17463 this.handler = handler;
17464 this.value = value;
17467 ProgressTask.prototype.run = function() {
17468 var q = this.handler.consumers;
17473 for (var c, i = 0; i < q.length; ++i) {
17475 runNotify(c.progress, this.value, this.handler, c.receiver, c.resolver);
17480 * Assimilate a thenable, sending it's value to resolver
17481 * @param {function} then
17482 * @param {object|function} thenable
17483 * @param {object} resolver
17486 function AssimilateTask(then, thenable, resolver) {
17488 this.thenable = thenable;
17489 this.resolver = resolver;
17492 AssimilateTask.prototype.run = function() {
17493 var h = this.resolver;
17494 tryAssimilate(this._then, this.thenable, _resolve, _reject, _notify);
17496 function _resolve(x) { h.resolve(x); }
17497 function _reject(x) { h.reject(x); }
17498 function _notify(x) { h.notify(x); }
17501 function tryAssimilate(then, thenable, resolve, reject, notify) {
17503 then.call(thenable, resolve, reject, notify);
17510 * Fold a handler value with z
17513 function Fold(f, z, c, to) {
17514 this.f = f; this.z = z; this.c = c; this.to = to;
17515 this.resolver = failIfRejected;
17516 this.receiver = this;
17519 Fold.prototype.fulfilled = function(x) {
17520 this.f.call(this.c, this.z, x, this.to);
17523 Fold.prototype.rejected = function(x) {
17527 Fold.prototype.progress = function(x) {
17535 * @returns {boolean} true iff x is a trusted Promise
17537 function isPromise(x) {
17538 return x instanceof Promise;
17542 * Test just enough to rule out primitives, in order to take faster
17543 * paths in some code
17545 * @returns {boolean} false iff x is guaranteed *not* to be a thenable
17547 function maybeThenable(x) {
17548 return (typeof x === 'object' || typeof x === 'function') && x !== null;
17551 function runContinuation1(f, h, receiver, next) {
17552 if(typeof f !== 'function') {
17553 return next.become(h);
17556 Promise.enterContext(h);
17557 tryCatchReject(f, h.value, receiver, next);
17558 Promise.exitContext();
17561 function runContinuation3(f, x, h, receiver, next) {
17562 if(typeof f !== 'function') {
17563 return next.become(h);
17566 Promise.enterContext(h);
17567 tryCatchReject3(f, x, h.value, receiver, next);
17568 Promise.exitContext();
17574 function runNotify(f, x, h, receiver, next) {
17575 if(typeof f !== 'function') {
17576 return next.notify(x);
17579 Promise.enterContext(h);
17580 tryCatchReturn(f, x, receiver, next);
17581 Promise.exitContext();
17584 function tryCatch2(f, a, b) {
17593 * Return f.call(thisArg, x), or if it throws return a rejected promise for
17594 * the thrown exception
17596 function tryCatchReject(f, x, thisArg, next) {
17598 next.become(getHandler(f.call(thisArg, x)));
17600 next.become(new Rejected(e));
17605 * Same as above, but includes the extra argument parameter.
17607 function tryCatchReject3(f, x, y, thisArg, next) {
17609 f.call(thisArg, x, y, next);
17611 next.become(new Rejected(e));
17617 * Return f.call(thisArg, x), or if it throws, *return* the exception
17619 function tryCatchReturn(f, x, thisArg, next) {
17621 next.notify(f.call(thisArg, x));
17627 function inherit(Parent, Child) {
17628 Child.prototype = objectCreate(Parent.prototype);
17629 Child.prototype.constructor = Child;
17632 function snd(x, y) {
17638 function initEmitRejection() {
17639 /*global process, self, CustomEvent*/
17640 if(typeof process !== 'undefined' && process !== null
17641 && typeof process.emit === 'function') {
17642 // Returning falsy here means to call the default
17643 // onPotentiallyUnhandledRejection API. This is safe even in
17644 // browserify since process.emit always returns falsy in browserify:
17645 // https://github.com/defunctzombie/node-process/blob/master/browser.js#L40-L46
17646 return function(type, rejection) {
17647 return type === 'unhandledRejection'
17648 ? process.emit(type, rejection.value, rejection)
17649 : process.emit(type, rejection);
17651 } else if(typeof self !== 'undefined' && typeof CustomEvent === 'function') {
17652 return (function(noop, self, CustomEvent) {
17653 var hasCustomEvent = false;
17655 var ev = new CustomEvent('unhandledRejection');
17656 hasCustomEvent = ev instanceof CustomEvent;
17659 return !hasCustomEvent ? noop : function(type, rejection) {
17660 var ev = new CustomEvent(type, {
17662 reason: rejection.value,
17669 return !self.dispatchEvent(ev);
17671 }(noop, self, CustomEvent));
17680 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); }));
17682 }).call(this,require('_process'))
17684 },{"_process":4}],203:[function(require,module,exports){
17685 /** @license MIT License (c) copyright 2010-2014 original author or authors */
17686 /** @author Brian Cavalier */
17687 /** @author John Hann */
17689 (function(define) { 'use strict';
17690 define(function() {
17693 pending: toPendingState,
17694 fulfilled: toFulfilledState,
17695 rejected: toRejectedState,
17699 function toPendingState() {
17700 return { state: 'pending' };
17703 function toRejectedState(e) {
17704 return { state: 'rejected', reason: e };
17707 function toFulfilledState(x) {
17708 return { state: 'fulfilled', value: x };
17711 function inspect(handler) {
17712 var state = handler.state();
17713 return state === 0 ? toPendingState()
17714 : state > 0 ? toFulfilledState(handler.value)
17715 : toRejectedState(handler.value);
17719 }(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); }));
17721 },{}],204:[function(require,module,exports){
17722 /** @license MIT License (c) copyright 2010-2014 original author or authors */
17725 * Promises/A+ and when() implementation
17726 * when is part of the cujoJS family of libraries (http://cujojs.com/)
17727 * @author Brian Cavalier
17728 * @author John Hann
17730 (function(define) { 'use strict';
17731 define(function (require) {
17733 var timed = require('./lib/decorators/timed');
17734 var array = require('./lib/decorators/array');
17735 var flow = require('./lib/decorators/flow');
17736 var fold = require('./lib/decorators/fold');
17737 var inspect = require('./lib/decorators/inspect');
17738 var generate = require('./lib/decorators/iterate');
17739 var progress = require('./lib/decorators/progress');
17740 var withThis = require('./lib/decorators/with');
17741 var unhandledRejection = require('./lib/decorators/unhandledRejection');
17742 var TimeoutError = require('./lib/TimeoutError');
17744 var Promise = [array, flow, fold, generate, progress,
17745 inspect, withThis, timed, unhandledRejection]
17746 .reduce(function(Promise, feature) {
17747 return feature(Promise);
17748 }, require('./lib/Promise'));
17750 var apply = require('./lib/apply')(Promise);
17754 when.promise = promise; // Create a pending promise
17755 when.resolve = Promise.resolve; // Create a resolved promise
17756 when.reject = Promise.reject; // Create a rejected promise
17758 when.lift = lift; // lift a function to return promises
17759 when['try'] = attempt; // call a function and return a promise
17760 when.attempt = attempt; // alias for when.try
17762 when.iterate = Promise.iterate; // DEPRECATED (use cujojs/most streams) Generate a stream of promises
17763 when.unfold = Promise.unfold; // DEPRECATED (use cujojs/most streams) Generate a stream of promises
17765 when.join = join; // Join 2 or more promises
17767 when.all = all; // Resolve a list of promises
17768 when.settle = settle; // Settle a list of promises
17770 when.any = lift(Promise.any); // One-winner race
17771 when.some = lift(Promise.some); // Multi-winner race
17772 when.race = lift(Promise.race); // First-to-settle race
17774 when.map = map; // Array.map() for promises
17775 when.filter = filter; // Array.filter() for promises
17776 when.reduce = lift(Promise.reduce); // Array.reduce() for promises
17777 when.reduceRight = lift(Promise.reduceRight); // Array.reduceRight() for promises
17779 when.isPromiseLike = isPromiseLike; // Is something promise-like, aka thenable
17781 when.Promise = Promise; // Promise constructor
17782 when.defer = defer; // Create a {promise, resolve, reject} tuple
17786 when.TimeoutError = TimeoutError;
17789 * Get a trusted promise for x, or by transforming x with onFulfilled
17792 * @param {function?} onFulfilled callback to be called when x is
17793 * successfully fulfilled. If promiseOrValue is an immediate value, callback
17794 * will be invoked immediately.
17795 * @param {function?} onRejected callback to be called when x is
17797 * @param {function?} onProgress callback to be called when progress updates
17798 * are issued for x. @deprecated
17799 * @returns {Promise} a new promise that will fulfill with the return
17800 * value of callback or errback or the completion value of promiseOrValue if
17801 * callback and/or errback is not supplied.
17803 function when(x, onFulfilled, onRejected, onProgress) {
17804 var p = Promise.resolve(x);
17805 if (arguments.length < 2) {
17809 return p.then(onFulfilled, onRejected, onProgress);
17813 * Creates a new promise whose fate is determined by resolver.
17814 * @param {function} resolver function(resolve, reject, notify)
17815 * @returns {Promise} promise whose fate is determine by resolver
17817 function promise(resolver) {
17818 return new Promise(resolver);
17822 * Lift the supplied function, creating a version of f that returns
17823 * promises, and accepts promises as arguments.
17824 * @param {function} f
17825 * @returns {Function} version of f that returns promises
17828 return function() {
17829 for(var i=0, l=arguments.length, a=new Array(l); i<l; ++i) {
17830 a[i] = arguments[i];
17832 return apply(f, this, a);
17837 * Call f in a future turn, with the supplied args, and return a promise
17839 * @param {function} f
17840 * @returns {Promise}
17842 function attempt(f /*, args... */) {
17843 /*jshint validthis:true */
17844 for(var i=0, l=arguments.length-1, a=new Array(l); i<l; ++i) {
17845 a[i] = arguments[i+1];
17847 return apply(f, this, a);
17851 * Creates a {promise, resolver} pair, either or both of which
17852 * may be given out safely to consumers.
17853 * @return {{promise: Promise, resolve: function, reject: function, notify: function}}
17856 return new Deferred();
17859 function Deferred() {
17860 var p = Promise._defer();
17862 function resolve(x) { p._handler.resolve(x); }
17863 function reject(x) { p._handler.reject(x); }
17864 function notify(x) { p._handler.notify(x); }
17867 this.resolve = resolve;
17868 this.reject = reject;
17869 this.notify = notify;
17870 this.resolver = { resolve: resolve, reject: reject, notify: notify };
17874 * Determines if x is promise-like, i.e. a thenable object
17875 * NOTE: Will return true for *any thenable object*, and isn't truly
17876 * safe, since it may attempt to access the `then` property of x (i.e.
17877 * clever/malicious getters may do weird things)
17878 * @param {*} x anything
17879 * @returns {boolean} true if x is promise-like
17881 function isPromiseLike(x) {
17882 return x && typeof x.then === 'function';
17886 * Return a promise that will resolve only once all the supplied arguments
17887 * have resolved. The resolution value of the returned promise will be an array
17888 * containing the resolution values of each of the arguments.
17889 * @param {...*} arguments may be a mix of promises and values
17890 * @returns {Promise}
17892 function join(/* ...promises */) {
17893 return Promise.all(arguments);
17897 * Return a promise that will fulfill once all input promises have
17898 * fulfilled, or reject when any one input promise rejects.
17899 * @param {array|Promise} promises array (or promise for an array) of promises
17900 * @returns {Promise}
17902 function all(promises) {
17903 return when(promises, Promise.all);
17907 * Return a promise that will always fulfill with an array containing
17908 * the outcome states of all input promises. The returned promise
17909 * will only reject if `promises` itself is a rejected promise.
17910 * @param {array|Promise} promises array (or promise for an array) of promises
17911 * @returns {Promise} promise for array of settled state descriptors
17913 function settle(promises) {
17914 return when(promises, Promise.settle);
17918 * Promise-aware array map function, similar to `Array.prototype.map()`,
17919 * but input array may contain promises or values.
17920 * @param {Array|Promise} promises array of anything, may contain promises and values
17921 * @param {function(x:*, index:Number):*} mapFunc map function which may
17922 * return a promise or value
17923 * @returns {Promise} promise that will fulfill with an array of mapped values
17924 * or reject if any input promise rejects.
17926 function map(promises, mapFunc) {
17927 return when(promises, function(promises) {
17928 return Promise.map(promises, mapFunc);
17933 * Filter the provided array of promises using the provided predicate. Input may
17934 * contain promises and values
17935 * @param {Array|Promise} promises array of promises and values
17936 * @param {function(x:*, index:Number):boolean} predicate filtering predicate.
17937 * Must return truthy (or promise for truthy) for items to retain.
17938 * @returns {Promise} promise that will fulfill with an array containing all items
17939 * for which predicate returned truthy.
17941 function filter(promises, predicate) {
17942 return when(promises, function(promises) {
17943 return Promise.filter(promises, predicate);
17949 })(typeof define === 'function' && define.amd ? define : function (factory) { module.exports = factory(require); });
17951 },{"./lib/Promise":187,"./lib/TimeoutError":189,"./lib/apply":190,"./lib/decorators/array":191,"./lib/decorators/flow":192,"./lib/decorators/fold":193,"./lib/decorators/inspect":194,"./lib/decorators/iterate":195,"./lib/decorators/progress":196,"./lib/decorators/timed":197,"./lib/decorators/unhandledRejection":198,"./lib/decorators/with":199}],205:[function(require,module,exports){
17952 var nativeIsArray = Array.isArray
17953 var toString = Object.prototype.toString
17955 module.exports = nativeIsArray || isArray
17957 function isArray(obj) {
17958 return toString.call(obj) === "[object Array]"
17961 },{}],206:[function(require,module,exports){
17963 var APIv3_1 = require("./api/APIv3");
17964 exports.APIv3 = APIv3_1.APIv3;
17966 },{"./api/APIv3":217}],207:[function(require,module,exports){
17968 var Component_1 = require("./component/Component");
17969 exports.Component = Component_1.Component;
17970 var ComponentService_1 = require("./component/ComponentService");
17971 exports.ComponentService = ComponentService_1.ComponentService;
17972 var AttributionComponent_1 = require("./component/AttributionComponent");
17973 exports.AttributionComponent = AttributionComponent_1.AttributionComponent;
17974 var BackgroundComponent_1 = require("./component/BackgroundComponent");
17975 exports.BackgroundComponent = BackgroundComponent_1.BackgroundComponent;
17976 var BearingComponent_1 = require("./component/BearingComponent");
17977 exports.BearingComponent = BearingComponent_1.BearingComponent;
17978 var CacheComponent_1 = require("./component/CacheComponent");
17979 exports.CacheComponent = CacheComponent_1.CacheComponent;
17980 var CoverComponent_1 = require("./component/CoverComponent");
17981 exports.CoverComponent = CoverComponent_1.CoverComponent;
17982 var DebugComponent_1 = require("./component/DebugComponent");
17983 exports.DebugComponent = DebugComponent_1.DebugComponent;
17984 var DirectionComponent_1 = require("./component/direction/DirectionComponent");
17985 exports.DirectionComponent = DirectionComponent_1.DirectionComponent;
17986 var DirectionDOMCalculator_1 = require("./component/direction/DirectionDOMCalculator");
17987 exports.DirectionDOMCalculator = DirectionDOMCalculator_1.DirectionDOMCalculator;
17988 var DirectionDOMRenderer_1 = require("./component/direction/DirectionDOMRenderer");
17989 exports.DirectionDOMRenderer = DirectionDOMRenderer_1.DirectionDOMRenderer;
17990 var ImageComponent_1 = require("./component/ImageComponent");
17991 exports.ImageComponent = ImageComponent_1.ImageComponent;
17992 var KeyboardComponent_1 = require("./component/KeyboardComponent");
17993 exports.KeyboardComponent = KeyboardComponent_1.KeyboardComponent;
17994 var LoadingComponent_1 = require("./component/LoadingComponent");
17995 exports.LoadingComponent = LoadingComponent_1.LoadingComponent;
17996 var Marker_1 = require("./component/marker/Marker");
17997 exports.Marker = Marker_1.Marker;
17998 var MarkerComponent_1 = require("./component/marker/MarkerComponent");
17999 exports.MarkerComponent = MarkerComponent_1.MarkerComponent;
18000 var MouseComponent_1 = require("./component/MouseComponent");
18001 exports.MouseComponent = MouseComponent_1.MouseComponent;
18002 var NavigationComponent_1 = require("./component/NavigationComponent");
18003 exports.NavigationComponent = NavigationComponent_1.NavigationComponent;
18004 var RouteComponent_1 = require("./component/RouteComponent");
18005 exports.RouteComponent = RouteComponent_1.RouteComponent;
18006 var SequenceComponent_1 = require("./component/sequence/SequenceComponent");
18007 exports.SequenceComponent = SequenceComponent_1.SequenceComponent;
18008 var SequenceDOMRenderer_1 = require("./component/sequence/SequenceDOMRenderer");
18009 exports.SequenceDOMRenderer = SequenceDOMRenderer_1.SequenceDOMRenderer;
18010 var SequenceDOMInteraction_1 = require("./component/sequence/SequenceDOMInteraction");
18011 exports.SequenceDOMInteraction = SequenceDOMInteraction_1.SequenceDOMInteraction;
18012 var ImagePlaneComponent_1 = require("./component/imageplane/ImagePlaneComponent");
18013 exports.ImagePlaneComponent = ImagePlaneComponent_1.ImagePlaneComponent;
18014 var ImagePlaneFactory_1 = require("./component/imageplane/ImagePlaneFactory");
18015 exports.ImagePlaneFactory = ImagePlaneFactory_1.ImagePlaneFactory;
18016 var ImagePlaneGLRenderer_1 = require("./component/imageplane/ImagePlaneGLRenderer");
18017 exports.ImagePlaneGLRenderer = ImagePlaneGLRenderer_1.ImagePlaneGLRenderer;
18018 var ImagePlaneScene_1 = require("./component/imageplane/ImagePlaneScene");
18019 exports.ImagePlaneScene = ImagePlaneScene_1.ImagePlaneScene;
18020 var ImagePlaneShaders_1 = require("./component/imageplane/ImagePlaneShaders");
18021 exports.ImagePlaneShaders = ImagePlaneShaders_1.ImagePlaneShaders;
18022 var SimpleMarker_1 = require("./component/marker/SimpleMarker");
18023 exports.SimpleMarker = SimpleMarker_1.SimpleMarker;
18024 var SliderComponent_1 = require("./component/imageplane/SliderComponent");
18025 exports.SliderComponent = SliderComponent_1.SliderComponent;
18026 var StatsComponent_1 = require("./component/StatsComponent");
18027 exports.StatsComponent = StatsComponent_1.StatsComponent;
18028 var Tag_1 = require("./component/tag/tag/Tag");
18029 exports.Tag = Tag_1.Tag;
18030 var Alignment_1 = require("./component/tag/tag/Alignment");
18031 exports.Alignment = Alignment_1.Alignment;
18032 var OutlineTag_1 = require("./component/tag/tag/OutlineTag");
18033 exports.OutlineTag = OutlineTag_1.OutlineTag;
18034 var RenderTag_1 = require("./component/tag/tag/RenderTag");
18035 exports.RenderTag = RenderTag_1.RenderTag;
18036 var OutlineRenderTag_1 = require("./component/tag/tag/OutlineRenderTag");
18037 exports.OutlineRenderTag = OutlineRenderTag_1.OutlineRenderTag;
18038 var OutlineCreateTag_1 = require("./component/tag/tag/OutlineCreateTag");
18039 exports.OutlineCreateTag = OutlineCreateTag_1.OutlineCreateTag;
18040 var SpotTag_1 = require("./component/tag/tag/SpotTag");
18041 exports.SpotTag = SpotTag_1.SpotTag;
18042 var SpotRenderTag_1 = require("./component/tag/tag/SpotRenderTag");
18043 exports.SpotRenderTag = SpotRenderTag_1.SpotRenderTag;
18044 var TagComponent_1 = require("./component/tag/TagComponent");
18045 exports.TagComponent = TagComponent_1.TagComponent;
18046 var TagCreator_1 = require("./component/tag/TagCreator");
18047 exports.TagCreator = TagCreator_1.TagCreator;
18048 var TagDOMRenderer_1 = require("./component/tag/TagDOMRenderer");
18049 exports.TagDOMRenderer = TagDOMRenderer_1.TagDOMRenderer;
18050 var TagGLRenderer_1 = require("./component/tag/TagGLRenderer");
18051 exports.TagGLRenderer = TagGLRenderer_1.TagGLRenderer;
18052 var TagOperation_1 = require("./component/tag/TagOperation");
18053 exports.TagOperation = TagOperation_1.TagOperation;
18054 var TagSet_1 = require("./component/tag/TagSet");
18055 exports.TagSet = TagSet_1.TagSet;
18056 var Geometry_1 = require("./component/tag/geometry/Geometry");
18057 exports.Geometry = Geometry_1.Geometry;
18058 var VertexGeometry_1 = require("./component/tag/geometry/VertexGeometry");
18059 exports.VertexGeometry = VertexGeometry_1.VertexGeometry;
18060 var RectGeometry_1 = require("./component/tag/geometry/RectGeometry");
18061 exports.RectGeometry = RectGeometry_1.RectGeometry;
18062 var PointGeometry_1 = require("./component/tag/geometry/PointGeometry");
18063 exports.PointGeometry = PointGeometry_1.PointGeometry;
18064 var PolygonGeometry_1 = require("./component/tag/geometry/PolygonGeometry");
18065 exports.PolygonGeometry = PolygonGeometry_1.PolygonGeometry;
18066 var GeometryTagError_1 = require("./component/tag/error/GeometryTagError");
18067 exports.GeometryTagError = GeometryTagError_1.GeometryTagError;
18069 },{"./component/AttributionComponent":218,"./component/BackgroundComponent":219,"./component/BearingComponent":220,"./component/CacheComponent":221,"./component/Component":222,"./component/ComponentService":223,"./component/CoverComponent":224,"./component/DebugComponent":225,"./component/ImageComponent":226,"./component/KeyboardComponent":227,"./component/LoadingComponent":228,"./component/MouseComponent":229,"./component/NavigationComponent":230,"./component/RouteComponent":231,"./component/StatsComponent":232,"./component/direction/DirectionComponent":233,"./component/direction/DirectionDOMCalculator":234,"./component/direction/DirectionDOMRenderer":235,"./component/imageplane/ImagePlaneComponent":236,"./component/imageplane/ImagePlaneFactory":237,"./component/imageplane/ImagePlaneGLRenderer":238,"./component/imageplane/ImagePlaneScene":239,"./component/imageplane/ImagePlaneShaders":240,"./component/imageplane/SliderComponent":241,"./component/marker/Marker":242,"./component/marker/MarkerComponent":243,"./component/marker/SimpleMarker":244,"./component/sequence/SequenceComponent":245,"./component/sequence/SequenceDOMInteraction":246,"./component/sequence/SequenceDOMRenderer":247,"./component/tag/TagComponent":249,"./component/tag/TagCreator":250,"./component/tag/TagDOMRenderer":251,"./component/tag/TagGLRenderer":252,"./component/tag/TagOperation":253,"./component/tag/TagSet":254,"./component/tag/error/GeometryTagError":255,"./component/tag/geometry/Geometry":256,"./component/tag/geometry/PointGeometry":257,"./component/tag/geometry/PolygonGeometry":258,"./component/tag/geometry/RectGeometry":259,"./component/tag/geometry/VertexGeometry":260,"./component/tag/tag/Alignment":261,"./component/tag/tag/OutlineCreateTag":262,"./component/tag/tag/OutlineRenderTag":263,"./component/tag/tag/OutlineTag":264,"./component/tag/tag/RenderTag":265,"./component/tag/tag/SpotRenderTag":266,"./component/tag/tag/SpotTag":267,"./component/tag/tag/Tag":268}],208:[function(require,module,exports){
18071 var EdgeDirection_1 = require("./graph/edge/EdgeDirection");
18072 exports.EdgeDirection = EdgeDirection_1.EdgeDirection;
18073 var EdgeCalculatorSettings_1 = require("./graph/edge/EdgeCalculatorSettings");
18074 exports.EdgeCalculatorSettings = EdgeCalculatorSettings_1.EdgeCalculatorSettings;
18075 var EdgeCalculatorDirections_1 = require("./graph/edge/EdgeCalculatorDirections");
18076 exports.EdgeCalculatorDirections = EdgeCalculatorDirections_1.EdgeCalculatorDirections;
18077 var EdgeCalculatorCoefficients_1 = require("./graph/edge/EdgeCalculatorCoefficients");
18078 exports.EdgeCalculatorCoefficients = EdgeCalculatorCoefficients_1.EdgeCalculatorCoefficients;
18079 var EdgeCalculator_1 = require("./graph/edge/EdgeCalculator");
18080 exports.EdgeCalculator = EdgeCalculator_1.EdgeCalculator;
18082 },{"./graph/edge/EdgeCalculator":289,"./graph/edge/EdgeCalculatorCoefficients":290,"./graph/edge/EdgeCalculatorDirections":291,"./graph/edge/EdgeCalculatorSettings":292,"./graph/edge/EdgeDirection":293}],209:[function(require,module,exports){
18084 var MapillaryError_1 = require("./error/MapillaryError");
18085 exports.MapillaryError = MapillaryError_1.MapillaryError;
18086 var ArgumentMapillaryError_1 = require("./error/ArgumentMapillaryError");
18087 exports.ArgumentMapillaryError = ArgumentMapillaryError_1.ArgumentMapillaryError;
18088 var GraphMapillaryError_1 = require("./error/GraphMapillaryError");
18089 exports.GraphMapillaryError = GraphMapillaryError_1.GraphMapillaryError;
18090 var MoveTypeMapillaryError_1 = require("./error/MoveTypeMapillaryError");
18091 exports.MoveTypeMapillaryError = MoveTypeMapillaryError_1.MoveTypeMapillaryError;
18092 var NotImplementedMapillaryError_1 = require("./error/NotImplementedMapillaryError");
18093 exports.NotImplementedMapillaryError = NotImplementedMapillaryError_1.NotImplementedMapillaryError;
18094 var ParameterMapillaryError_1 = require("./error/ParameterMapillaryError");
18095 exports.ParameterMapillaryError = ParameterMapillaryError_1.ParameterMapillaryError;
18096 var InitializationMapillaryError_1 = require("./error/InitializationMapillaryError");
18097 exports.InitializationMapillaryError = InitializationMapillaryError_1.InitializationMapillaryError;
18099 },{"./error/ArgumentMapillaryError":269,"./error/GraphMapillaryError":270,"./error/InitializationMapillaryError":271,"./error/MapillaryError":272,"./error/MoveTypeMapillaryError":273,"./error/NotImplementedMapillaryError":274,"./error/ParameterMapillaryError":275}],210:[function(require,module,exports){
18101 var Camera_1 = require("./geo/Camera");
18102 exports.Camera = Camera_1.Camera;
18103 var GeoCoords_1 = require("./geo/GeoCoords");
18104 exports.GeoCoords = GeoCoords_1.GeoCoords;
18105 var Spatial_1 = require("./geo/Spatial");
18106 exports.Spatial = Spatial_1.Spatial;
18107 var Transform_1 = require("./geo/Transform");
18108 exports.Transform = Transform_1.Transform;
18110 },{"./geo/Camera":276,"./geo/GeoCoords":277,"./geo/Spatial":278,"./geo/Transform":279}],211:[function(require,module,exports){
18112 var Graph_1 = require("./graph/Graph");
18113 exports.Graph = Graph_1.Graph;
18114 var GraphCalculator_1 = require("./graph/GraphCalculator");
18115 exports.GraphCalculator = GraphCalculator_1.GraphCalculator;
18116 var GraphService_1 = require("./graph/GraphService");
18117 exports.GraphService = GraphService_1.GraphService;
18118 var ImageLoader_1 = require("./graph/ImageLoader");
18119 exports.ImageLoader = ImageLoader_1.ImageLoader;
18120 var ImageLoadingService_1 = require("./graph/ImageLoadingService");
18121 exports.ImageLoadingService = ImageLoadingService_1.ImageLoadingService;
18122 var MeshReader_1 = require("./graph/MeshReader");
18123 exports.MeshReader = MeshReader_1.MeshReader;
18124 var Node_1 = require("./graph/Node");
18125 exports.Node = Node_1.Node;
18126 var NodeCache_1 = require("./graph/NodeCache");
18127 exports.NodeCache = NodeCache_1.NodeCache;
18128 var Sequence_1 = require("./graph/Sequence");
18129 exports.Sequence = Sequence_1.Sequence;
18131 },{"./graph/Graph":280,"./graph/GraphCalculator":281,"./graph/GraphService":282,"./graph/ImageLoader":283,"./graph/ImageLoadingService":284,"./graph/MeshReader":285,"./graph/Node":286,"./graph/NodeCache":287,"./graph/Sequence":288}],212:[function(require,module,exports){
18133 * MapillaryJS is a WebGL JavaScript library for exploring street level imagery
18137 var Edge_1 = require("./Edge");
18138 exports.EdgeDirection = Edge_1.EdgeDirection;
18139 var Render_1 = require("./Render");
18140 exports.RenderMode = Render_1.RenderMode;
18141 var Viewer_1 = require("./Viewer");
18142 exports.ImageSize = Viewer_1.ImageSize;
18143 exports.Viewer = Viewer_1.Viewer;
18144 var TagComponent = require("./component/tag/Tag");
18145 exports.TagComponent = TagComponent;
18147 },{"./Edge":208,"./Render":213,"./Viewer":216,"./component/tag/Tag":248}],213:[function(require,module,exports){
18149 var DOMRenderer_1 = require("./render/DOMRenderer");
18150 exports.DOMRenderer = DOMRenderer_1.DOMRenderer;
18151 var GLRenderer_1 = require("./render/GLRenderer");
18152 exports.GLRenderer = GLRenderer_1.GLRenderer;
18153 var GLRenderStage_1 = require("./render/GLRenderStage");
18154 exports.GLRenderStage = GLRenderStage_1.GLRenderStage;
18155 var RenderCamera_1 = require("./render/RenderCamera");
18156 exports.RenderCamera = RenderCamera_1.RenderCamera;
18157 var RenderMode_1 = require("./render/RenderMode");
18158 exports.RenderMode = RenderMode_1.RenderMode;
18159 var RenderService_1 = require("./render/RenderService");
18160 exports.RenderService = RenderService_1.RenderService;
18162 },{"./render/DOMRenderer":294,"./render/GLRenderStage":295,"./render/GLRenderer":296,"./render/RenderCamera":297,"./render/RenderMode":298,"./render/RenderService":299}],214:[function(require,module,exports){
18164 var FrameGenerator_1 = require("./state/FrameGenerator");
18165 exports.FrameGenerator = FrameGenerator_1.FrameGenerator;
18166 var StateService_1 = require("./state/StateService");
18167 exports.StateService = StateService_1.StateService;
18168 var StateContext_1 = require("./state/StateContext");
18169 exports.StateContext = StateContext_1.StateContext;
18170 var State_1 = require("./state/State");
18171 exports.State = State_1.State;
18172 var StateBase_1 = require("./state/states/StateBase");
18173 exports.StateBase = StateBase_1.StateBase;
18174 var TraversingState_1 = require("./state/states/TraversingState");
18175 exports.TraversingState = TraversingState_1.TraversingState;
18176 var WaitingState_1 = require("./state/states/WaitingState");
18177 exports.WaitingState = WaitingState_1.WaitingState;
18179 },{"./state/FrameGenerator":300,"./state/State":301,"./state/StateContext":302,"./state/StateService":303,"./state/states/StateBase":304,"./state/states/TraversingState":305,"./state/states/WaitingState":306}],215:[function(require,module,exports){
18181 var EventEmitter_1 = require("./utils/EventEmitter");
18182 exports.EventEmitter = EventEmitter_1.EventEmitter;
18183 var Settings_1 = require("./utils/Settings");
18184 exports.Settings = Settings_1.Settings;
18185 var Urls_1 = require("./utils/Urls");
18186 exports.Urls = Urls_1.Urls;
18188 },{"./utils/EventEmitter":307,"./utils/Settings":308,"./utils/Urls":309}],216:[function(require,module,exports){
18190 var Container_1 = require("./viewer/Container");
18191 exports.Container = Container_1.Container;
18192 var EventLauncher_1 = require("./viewer/EventLauncher");
18193 exports.EventLauncher = EventLauncher_1.EventLauncher;
18194 var ImageSize_1 = require("./viewer/ImageSize");
18195 exports.ImageSize = ImageSize_1.ImageSize;
18196 var LoadingService_1 = require("./viewer/LoadingService");
18197 exports.LoadingService = LoadingService_1.LoadingService;
18198 var MouseService_1 = require("./viewer/MouseService");
18199 exports.MouseService = MouseService_1.MouseService;
18200 var Navigator_1 = require("./viewer/Navigator");
18201 exports.Navigator = Navigator_1.Navigator;
18202 var ComponentController_1 = require("./viewer/ComponentController");
18203 exports.ComponentController = ComponentController_1.ComponentController;
18204 var SpriteAlignment_1 = require("./viewer/SpriteAlignment");
18205 exports.SpriteAlignment = SpriteAlignment_1.SpriteAlignment;
18206 var SpriteService_1 = require("./viewer/SpriteService");
18207 exports.SpriteService = SpriteService_1.SpriteService;
18208 var TouchService_1 = require("./viewer/TouchService");
18209 exports.TouchService = TouchService_1.TouchService;
18210 exports.TouchMove = TouchService_1.TouchMove;
18211 var Viewer_1 = require("./viewer/Viewer");
18212 exports.Viewer = Viewer_1.Viewer;
18214 },{"./viewer/ComponentController":310,"./viewer/Container":311,"./viewer/EventLauncher":312,"./viewer/ImageSize":313,"./viewer/LoadingService":314,"./viewer/MouseService":315,"./viewer/Navigator":316,"./viewer/SpriteAlignment":317,"./viewer/SpriteService":318,"./viewer/TouchService":319,"./viewer/Viewer":320}],217:[function(require,module,exports){
18215 /// <reference path="../../typings/index.d.ts" />
18217 var falcor = require("falcor");
18218 var HttpDataSource = require("falcor-http-datasource");
18219 var Observable_1 = require("rxjs/Observable");
18220 require("rxjs/add/observable/defer");
18221 require("rxjs/add/observable/fromPromise");
18222 require("rxjs/add/operator/catch");
18223 require("rxjs/add/operator/map");
18224 var Utils_1 = require("../Utils");
18225 var APIv3 = (function () {
18226 function APIv3(clientId, model) {
18227 this._clientId = clientId;
18228 this._model = model != null ?
18231 source: new HttpDataSource(Utils_1.Urls.falcorModel(clientId), {
18233 withCredentials: false,
18236 this._pageCount = 999;
18237 this._pathImageByKey = "imageByKey";
18238 this._pathImageCloseTo = "imageCloseTo";
18239 this._pathImagesByH = "imagesByH";
18240 this._pathImageViewAdd = "imageViewAdd";
18241 this._pathSequenceByKey = "sequenceByKey";
18242 this._pathSequenceViewAdd = "sequenceViewAdd";
18243 this._propertiesCore = [
18248 this._propertiesFill = [
18252 this._propertiesKey = [
18255 this._propertiesSequence = [
18258 this._propertiesSpatial = [
18272 this._propertiesUser = [
18277 APIv3.prototype.imageByKeyFill$ = function (keys) {
18278 return this._catchInvalidateGet$(this._wrapPromise$(this._model.get([
18279 this._pathImageByKey,
18281 this._propertiesKey.concat(this._propertiesFill).concat(this._propertiesSpatial),
18282 this._propertiesKey.concat(this._propertiesUser)]))
18283 .map(function (value) {
18284 return value.json.imageByKey;
18285 }), this._pathImageByKey, keys);
18287 APIv3.prototype.imageByKeyFull$ = function (keys) {
18288 return this._catchInvalidateGet$(this._wrapPromise$(this._model.get([
18289 this._pathImageByKey,
18291 this._propertiesKey.concat(this._propertiesCore).concat(this._propertiesFill).concat(this._propertiesSpatial),
18292 this._propertiesKey.concat(this._propertiesUser)]))
18293 .map(function (value) {
18294 return value.json.imageByKey;
18295 }), this._pathImageByKey, keys);
18297 APIv3.prototype.imageCloseTo$ = function (lat, lon) {
18298 var lonLat = lon + ":" + lat;
18299 return this._catchInvalidateGet$(this._wrapPromise$(this._model.get([
18300 this._pathImageCloseTo,
18302 this._propertiesKey.concat(this._propertiesCore).concat(this._propertiesFill).concat(this._propertiesSpatial),
18303 this._propertiesKey.concat(this._propertiesUser)]))
18304 .map(function (value) {
18305 return value != null ? value.json.imageCloseTo[lonLat] : null;
18306 }), this._pathImageCloseTo, [lonLat]);
18308 APIv3.prototype.imagesByH$ = function (hs) {
18310 return this._catchInvalidateGet$(this._wrapPromise$(this._model.get([
18311 this._pathImagesByH,
18313 { from: 0, to: this._pageCount },
18314 this._propertiesKey.concat(this._propertiesCore),
18315 this._propertiesKey]))
18316 .map(function (value) {
18317 if (value == null) {
18318 value = { json: { imagesByH: {} } };
18319 for (var _i = 0, hs_1 = hs; _i < hs_1.length; _i++) {
18321 value.json.imagesByH[h] = {};
18322 for (var i = 0; i <= _this._pageCount; i++) {
18323 value.json.imagesByH[h][i] = null;
18327 return value.json.imagesByH;
18328 }), this._pathImagesByH, hs);
18330 APIv3.prototype.imageViewAdd$ = function (keys) {
18331 return this._catchInvalidateCall$(this._wrapPromise$(this._model.call([this._pathImageViewAdd], [keys])), this._pathImageViewAdd, keys);
18333 APIv3.prototype.invalidateImageByKey = function (keys) {
18334 this._invalidateGet(this._pathImageByKey, keys);
18336 APIv3.prototype.invalidateImagesByH = function (hs) {
18337 this._invalidateGet(this._pathImagesByH, hs);
18339 APIv3.prototype.invalidateSequenceByKey = function (sKeys) {
18340 this._invalidateGet(this._pathSequenceByKey, sKeys);
18342 APIv3.prototype.sequenceByKey$ = function (sequenceKeys) {
18343 return this._catchInvalidateGet$(this._wrapPromise$(this._model.get([
18344 this._pathSequenceByKey,
18346 this._propertiesKey.concat(this._propertiesSequence)]))
18347 .map(function (value) {
18348 return value.json.sequenceByKey;
18349 }), this._pathSequenceByKey, sequenceKeys);
18351 APIv3.prototype.sequenceViewAdd$ = function (sequenceKeys) {
18352 return this._catchInvalidateCall$(this._wrapPromise$(this._model.call([this._pathSequenceViewAdd], [sequenceKeys])), this._pathSequenceViewAdd, sequenceKeys);
18354 Object.defineProperty(APIv3.prototype, "clientId", {
18356 return this._clientId;
18361 APIv3.prototype._catchInvalidateGet$ = function (observable, path, paths) {
18364 .catch(function (error) {
18365 _this._invalidateGet(path, paths);
18369 APIv3.prototype._catchInvalidateCall$ = function (observable, path, paths) {
18372 .catch(function (error) {
18373 _this._invalidateCall(path, paths);
18377 APIv3.prototype._invalidateGet = function (path, paths) {
18378 this._model.invalidate([path, paths]);
18380 APIv3.prototype._invalidateCall = function (path, paths) {
18381 this._model.invalidate([path], [paths]);
18383 APIv3.prototype._wrapPromise$ = function (promise) {
18384 return Observable_1.Observable.defer(function () { return Observable_1.Observable.fromPromise(promise); });
18388 exports.APIv3 = APIv3;
18389 Object.defineProperty(exports, "__esModule", { value: true });
18390 exports.default = APIv3;
18392 },{"../Utils":215,"falcor":13,"falcor-http-datasource":8,"rxjs/Observable":28,"rxjs/add/observable/defer":38,"rxjs/add/observable/fromPromise":42,"rxjs/add/operator/catch":48,"rxjs/add/operator/map":60}],218:[function(require,module,exports){
18393 /// <reference path="../../typings/index.d.ts" />
18395 var __extends = (this && this.__extends) || function (d, b) {
18396 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
18397 function __() { this.constructor = d; }
18398 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
18400 var vd = require("virtual-dom");
18401 var Component_1 = require("../Component");
18402 var AttributionComponent = (function (_super) {
18403 __extends(AttributionComponent, _super);
18404 function AttributionComponent(name, container, navigator) {
18405 _super.call(this, name, container, navigator);
18407 AttributionComponent.prototype._activate = function () {
18409 this._disposable = this._navigator.stateService.currentNode$
18410 .map(function (node) {
18411 return { name: _this._name, vnode: _this._getAttributionNode(node.username, node.key) };
18413 .subscribe(this._container.domRenderer.render$);
18415 AttributionComponent.prototype._deactivate = function () {
18416 this._disposable.unsubscribe();
18418 AttributionComponent.prototype._getDefaultConfiguration = function () {
18421 AttributionComponent.prototype._getAttributionNode = function (username, photoId) {
18422 return vd.h("div.Attribution", {}, [
18423 vd.h("a", { href: "https://www.mapillary.com/app/user/" + username,
18425 textContent: "@" + username,
18427 vd.h("span", { textContent: "|" }, []),
18428 vd.h("a", { href: "https://www.mapillary.com/app/?pKey=" + photoId + "&focus=photo",
18430 textContent: "mapillary.com",
18434 AttributionComponent.componentName = "attribution";
18435 return AttributionComponent;
18436 }(Component_1.Component));
18437 exports.AttributionComponent = AttributionComponent;
18438 Component_1.ComponentService.register(AttributionComponent);
18439 Object.defineProperty(exports, "__esModule", { value: true });
18440 exports.default = AttributionComponent;
18442 },{"../Component":207,"virtual-dom":163}],219:[function(require,module,exports){
18443 /// <reference path="../../typings/index.d.ts" />
18445 var __extends = (this && this.__extends) || function (d, b) {
18446 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
18447 function __() { this.constructor = d; }
18448 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
18450 var vd = require("virtual-dom");
18451 var Component_1 = require("../Component");
18452 var BackgroundComponent = (function (_super) {
18453 __extends(BackgroundComponent, _super);
18454 function BackgroundComponent(name, container, navigator) {
18455 _super.call(this, name, container, navigator);
18457 BackgroundComponent.prototype._activate = function () {
18458 this._container.domRenderer.render$
18459 .next({ name: this._name, vnode: this._getBackgroundNode("The viewer can't display the given photo.") });
18461 BackgroundComponent.prototype._deactivate = function () {
18464 BackgroundComponent.prototype._getDefaultConfiguration = function () {
18467 BackgroundComponent.prototype._getBackgroundNode = function (notice) {
18468 // todo: add condition for when to display the DOM node
18469 return vd.h("div.BackgroundWrapper", {}, [
18470 vd.h("p", { textContent: notice }, []),
18473 BackgroundComponent.componentName = "background";
18474 return BackgroundComponent;
18475 }(Component_1.Component));
18476 exports.BackgroundComponent = BackgroundComponent;
18477 Component_1.ComponentService.register(BackgroundComponent);
18478 Object.defineProperty(exports, "__esModule", { value: true });
18479 exports.default = BackgroundComponent;
18481 },{"../Component":207,"virtual-dom":163}],220:[function(require,module,exports){
18482 /// <reference path="../../typings/index.d.ts" />
18484 var __extends = (this && this.__extends) || function (d, b) {
18485 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
18486 function __() { this.constructor = d; }
18487 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
18489 var vd = require("virtual-dom");
18490 var Component_1 = require("../Component");
18491 var BearingComponent = (function (_super) {
18492 __extends(BearingComponent, _super);
18493 function BearingComponent(name, container, navigator) {
18494 _super.call(this, name, container, navigator);
18496 BearingComponent.prototype._activate = function () {
18498 this._renderSubscription = this._navigator.stateService.currentNode$
18499 .map(function (node) {
18500 return node.fullPano;
18502 .map(function (pano) {
18505 vnode: pano ? vd.h("div.BearingIndicator", {}, []) : vd.h("div", {}, []),
18508 .subscribe(this._container.domRenderer.render$);
18510 BearingComponent.prototype._deactivate = function () {
18511 this._renderSubscription.unsubscribe();
18513 BearingComponent.prototype._getDefaultConfiguration = function () {
18516 BearingComponent.componentName = "bearing";
18517 return BearingComponent;
18518 }(Component_1.Component));
18519 exports.BearingComponent = BearingComponent;
18520 Component_1.ComponentService.register(BearingComponent);
18521 Object.defineProperty(exports, "__esModule", { value: true });
18522 exports.default = BearingComponent;
18524 },{"../Component":207,"virtual-dom":163}],221:[function(require,module,exports){
18526 var __extends = (this && this.__extends) || function (d, b) {
18527 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
18528 function __() { this.constructor = d; }
18529 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
18531 var Observable_1 = require("rxjs/Observable");
18532 require("rxjs/add/observable/combineLatest");
18533 require("rxjs/add/observable/merge");
18534 require("rxjs/add/observable/of");
18535 require("rxjs/add/observable/zip");
18536 require("rxjs/add/operator/distinct");
18537 require("rxjs/add/operator/expand");
18538 require("rxjs/add/operator/map");
18539 require("rxjs/add/operator/mergeAll");
18540 require("rxjs/add/operator/skip");
18541 require("rxjs/add/operator/switchMap");
18542 var Edge_1 = require("../Edge");
18543 var Component_1 = require("../Component");
18544 var CacheComponent = (function (_super) {
18545 __extends(CacheComponent, _super);
18546 function CacheComponent(name, container, navigator) {
18547 _super.call(this, name, container, navigator);
18550 * Set the cache depth.
18552 * Configures the cache depth. The cache depth can be different for
18553 * different edge direction types.
18555 * @param {ICacheDepth} depth - Cache depth structure.
18557 CacheComponent.prototype.setDepth = function (depth) {
18558 this.configure({ depth: depth });
18560 CacheComponent.prototype._activate = function () {
18562 this._cacheSubscription = Observable_1.Observable
18563 .combineLatest(this._navigator.stateService.currentNode$, this._configuration$)
18564 .switchMap(function (nc) {
18566 var configuration = nc[1];
18567 var depth = configuration.depth;
18568 var sequenceDepth = Math.max(0, Math.min(4, depth.sequence));
18569 var panoDepth = Math.max(0, Math.min(2, depth.pano));
18570 var stepDepth = node.pano ? 0 : Math.max(0, Math.min(3, depth.step));
18571 var turnDepth = node.pano ? 0 : Math.max(0, Math.min(1, depth.turn));
18572 var next$ = _this._cache$(node, Edge_1.EdgeDirection.Next, sequenceDepth);
18573 var prev$ = _this._cache$(node, Edge_1.EdgeDirection.Prev, sequenceDepth);
18574 var pano$ = _this._cache$(node, Edge_1.EdgeDirection.Pano, panoDepth);
18575 var forward$ = _this._cache$(node, Edge_1.EdgeDirection.StepForward, stepDepth);
18576 var backward$ = _this._cache$(node, Edge_1.EdgeDirection.StepBackward, stepDepth);
18577 var left$ = _this._cache$(node, Edge_1.EdgeDirection.StepLeft, stepDepth);
18578 var right$ = _this._cache$(node, Edge_1.EdgeDirection.StepRight, stepDepth);
18579 var turnLeft$ = _this._cache$(node, Edge_1.EdgeDirection.TurnLeft, turnDepth);
18580 var turnRight$ = _this._cache$(node, Edge_1.EdgeDirection.TurnRight, turnDepth);
18581 var turnU$ = _this._cache$(node, Edge_1.EdgeDirection.TurnU, turnDepth);
18582 return Observable_1.Observable
18583 .merge(next$, prev$, forward$, backward$, left$, right$, pano$, turnLeft$, turnRight$, turnU$);
18585 .subscribe(function (n) { return; }, function (e) { console.error(e); });
18587 CacheComponent.prototype._deactivate = function () {
18588 this._cacheSubscription.unsubscribe();
18590 CacheComponent.prototype._getDefaultConfiguration = function () {
18591 return { depth: { pano: 1, sequence: 2, step: 1, turn: 0 } };
18593 CacheComponent.prototype._cache$ = function (node, direction, depth) {
18595 return Observable_1.Observable
18596 .zip(this._nodeToEdges$(node, direction), Observable_1.Observable.of(depth))
18597 .expand(function (ed) {
18600 var edgesDepths$ = [];
18602 for (var _i = 0, es_1 = es; _i < es_1.length; _i++) {
18603 var edge = es_1[_i];
18604 if (edge.data.direction === direction) {
18605 edgesDepths$.push(Observable_1.Observable
18606 .zip(_this._navigator.graphService.cacheNode$(edge.to)
18607 .mergeMap(function (n) {
18608 return _this._nodeToEdges$(n, direction);
18609 }), Observable_1.Observable.of(d - 1)));
18613 return Observable_1.Observable
18614 .from(edgesDepths$)
18619 CacheComponent.prototype._nodeToEdges$ = function (node, direction) {
18620 return ([Edge_1.EdgeDirection.Next, Edge_1.EdgeDirection.Prev].indexOf(direction) > -1 ?
18621 node.sequenceEdges$ :
18622 node.spatialEdges$)
18623 .first(function (status) {
18624 return status.cached;
18626 .map(function (status) {
18627 return status.edges;
18630 CacheComponent.componentName = "cache";
18631 return CacheComponent;
18632 }(Component_1.Component));
18633 exports.CacheComponent = CacheComponent;
18634 Component_1.ComponentService.register(CacheComponent);
18635 Object.defineProperty(exports, "__esModule", { value: true });
18636 exports.default = CacheComponent;
18638 },{"../Component":207,"../Edge":208,"rxjs/Observable":28,"rxjs/add/observable/combineLatest":37,"rxjs/add/observable/merge":43,"rxjs/add/observable/of":44,"rxjs/add/observable/zip":46,"rxjs/add/operator/distinct":52,"rxjs/add/operator/expand":55,"rxjs/add/operator/map":60,"rxjs/add/operator/mergeAll":62,"rxjs/add/operator/skip":70,"rxjs/add/operator/switchMap":73}],222:[function(require,module,exports){
18640 var __extends = (this && this.__extends) || function (d, b) {
18641 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
18642 function __() { this.constructor = d; }
18643 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
18645 var BehaviorSubject_1 = require("rxjs/BehaviorSubject");
18646 var Subject_1 = require("rxjs/Subject");
18647 require("rxjs/add/operator/publishReplay");
18648 require("rxjs/add/operator/scan");
18649 require("rxjs/add/operator/startWith");
18650 var Utils_1 = require("../Utils");
18651 var Component = (function (_super) {
18652 __extends(Component, _super);
18653 function Component(name, container, navigator) {
18655 this._activated$ = new BehaviorSubject_1.BehaviorSubject(false);
18656 this._configurationSubject$ = new Subject_1.Subject();
18657 this._activated = false;
18658 this._container = container;
18660 this._navigator = navigator;
18661 this._configuration$ =
18662 this._configurationSubject$
18663 .startWith(this.defaultConfiguration)
18664 .scan(function (conf, newConf) {
18665 for (var key in newConf) {
18666 if (newConf.hasOwnProperty(key)) {
18667 conf[key] = newConf[key];
18674 this._configuration$.subscribe();
18676 Object.defineProperty(Component.prototype, "activated", {
18678 return this._activated;
18683 Object.defineProperty(Component.prototype, "activated$", {
18685 return this._activated$;
18690 Object.defineProperty(Component.prototype, "defaultConfiguration", {
18692 * Get default configuration.
18694 * @returns {TConfiguration} Default configuration for component.
18697 return this._getDefaultConfiguration();
18702 Object.defineProperty(Component.prototype, "configuration$", {
18704 return this._configuration$;
18709 Component.prototype.activate = function (conf) {
18710 if (this._activated) {
18713 if (conf !== undefined) {
18714 this._configurationSubject$.next(conf);
18717 this._activated = true;
18718 this._activated$.next(true);
18721 Component.prototype.configure = function (conf) {
18722 this._configurationSubject$.next(conf);
18724 Component.prototype.deactivate = function () {
18725 if (!this._activated) {
18728 this._deactivate();
18729 this._container.domRenderer.clear(this._name);
18730 this._container.glRenderer.clear(this._name);
18731 this._activated = false;
18732 this._activated$.next(false);
18736 * Detect the viewer's new width and height and resize the component's
18737 * rendered elements accordingly if applicable.
18739 Component.prototype.resize = function () { return; };
18741 * Component name. Used when interacting with component through the Viewer's API.
18743 Component.componentName = "not_worthy";
18745 }(Utils_1.EventEmitter));
18746 exports.Component = Component;
18747 Object.defineProperty(exports, "__esModule", { value: true });
18748 exports.default = Component;
18750 },{"../Utils":215,"rxjs/BehaviorSubject":25,"rxjs/Subject":33,"rxjs/add/operator/publishReplay":67,"rxjs/add/operator/scan":68,"rxjs/add/operator/startWith":72}],223:[function(require,module,exports){
18751 /// <reference path="../../typings/index.d.ts" />
18753 var _ = require("underscore");
18754 var Error_1 = require("../Error");
18755 var ComponentService = (function () {
18756 function ComponentService(container, navigator) {
18757 this._components = {};
18758 this._container = container;
18759 this._navigator = navigator;
18760 for (var _i = 0, _a = _.values(ComponentService.registeredComponents); _i < _a.length; _i++) {
18761 var component = _a[_i];
18762 this._components[component.componentName] = {
18764 component: new component(component.componentName, container, navigator),
18767 this._coverComponent = new ComponentService.registeredCoverComponent("cover", container, navigator);
18768 this._coverComponent.activate();
18769 this._coverActivated = true;
18771 ComponentService.register = function (component) {
18772 if (ComponentService.registeredComponents[component.componentName] === undefined) {
18773 ComponentService.registeredComponents[component.componentName] = component;
18776 ComponentService.registerCover = function (coverComponent) {
18777 ComponentService.registeredCoverComponent = coverComponent;
18779 ComponentService.prototype.activateCover = function () {
18780 if (this._coverActivated) {
18783 this._coverActivated = true;
18784 for (var _i = 0, _a = _.values(this._components); _i < _a.length; _i++) {
18785 var component = _a[_i];
18786 if (component.active) {
18787 component.component.deactivate();
18792 ComponentService.prototype.deactivateCover = function () {
18793 if (!this._coverActivated) {
18796 this._coverActivated = false;
18797 for (var _i = 0, _a = _.values(this._components); _i < _a.length; _i++) {
18798 var component = _a[_i];
18799 if (component.active) {
18800 component.component.activate();
18805 ComponentService.prototype.activate = function (name) {
18806 this._checkName(name);
18807 this._components[name].active = true;
18808 if (!this._coverActivated) {
18809 this.get(name).activate();
18812 ComponentService.prototype.configure = function (name, conf) {
18813 this._checkName(name);
18814 this.get(name).configure(conf);
18816 ComponentService.prototype.deactivate = function (name) {
18817 this._checkName(name);
18818 this._components[name].active = false;
18819 if (!this._coverActivated) {
18820 this.get(name).deactivate();
18823 ComponentService.prototype.resize = function () {
18824 for (var _i = 0, _a = _.values(this._components); _i < _a.length; _i++) {
18825 var component = _a[_i];
18826 component.component.resize();
18829 ComponentService.prototype.get = function (name) {
18830 return this._components[name].component;
18832 ComponentService.prototype.getCover = function () {
18833 return this._coverComponent;
18835 ComponentService.prototype._checkName = function (name) {
18836 if (!(name in this._components)) {
18837 throw new Error_1.ParameterMapillaryError("Component does not exist: " + name);
18840 ComponentService.registeredComponents = {};
18841 return ComponentService;
18843 exports.ComponentService = ComponentService;
18844 Object.defineProperty(exports, "__esModule", { value: true });
18845 exports.default = ComponentService;
18847 },{"../Error":209,"underscore":158}],224:[function(require,module,exports){
18848 /// <reference path="../../typings/index.d.ts" />
18850 var __extends = (this && this.__extends) || function (d, b) {
18851 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
18852 function __() { this.constructor = d; }
18853 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
18855 var vd = require("virtual-dom");
18856 require("rxjs/add/operator/filter");
18857 require("rxjs/add/operator/map");
18858 require("rxjs/add/operator/withLatestFrom");
18859 var Component_1 = require("../Component");
18860 var CoverComponent = (function (_super) {
18861 __extends(CoverComponent, _super);
18862 function CoverComponent(name, container, navigator) {
18863 _super.call(this, name, container, navigator);
18865 CoverComponent.prototype._activate = function () {
18867 this._keyDisposable = this._navigator.stateService.currentNode$
18868 .withLatestFrom(this._configuration$, function (node, configuration) {
18869 return [node, configuration];
18871 .filter(function (nc) {
18872 return nc[0].key !== nc[1].key;
18874 .map(function (nc) { return nc[0]; })
18875 .map(function (node) {
18876 return { key: node.key, src: node.image.src };
18878 .subscribe(this._configurationSubject$);
18879 this._disposable = this._configuration$
18880 .map(function (conf) {
18882 return { name: _this._name, vnode: vd.h("div", []) };
18884 if (!conf.visible) {
18885 return { name: _this._name, vnode: vd.h("div.Cover.CoverDone", [_this._getCoverBackgroundVNode(conf)]) };
18887 return { name: _this._name, vnode: _this._getCoverButtonVNode(conf) };
18889 .subscribe(this._container.domRenderer.render$);
18891 CoverComponent.prototype._deactivate = function () {
18892 this._disposable.unsubscribe();
18893 this._keyDisposable.unsubscribe();
18895 CoverComponent.prototype._getDefaultConfiguration = function () {
18896 return { "loading": false, "visible": true };
18898 CoverComponent.prototype._getCoverButtonVNode = function (conf) {
18900 var cover = conf.loading ? "div.Cover.CoverLoading" : "div.Cover";
18901 return vd.h(cover, [
18902 this._getCoverBackgroundVNode(conf),
18903 vd.h("button.CoverButton", { onclick: function () { _this.configure({ loading: true }); } }, ["Explore"]),
18904 vd.h("a.CoverLogo", { href: "https://www.mapillary.com", target: "_blank" }, []),
18907 CoverComponent.prototype._getCoverBackgroundVNode = function (conf) {
18908 var url = conf.src != null ?
18909 "url(" + conf.src + ")" :
18910 "url(https://d1cuyjsrcm0gby.cloudfront.net/" + conf.key + "/thumb-640.jpg)";
18911 var properties = { style: { backgroundImage: url } };
18913 if (conf.loading) {
18914 children.push(vd.h("div.Spinner", {}, []));
18916 children.push(vd.h("div.CoverBackgroundGradient", {}, []));
18917 return vd.h("div.CoverBackground", properties, children);
18919 CoverComponent.componentName = "cover";
18920 return CoverComponent;
18921 }(Component_1.Component));
18922 exports.CoverComponent = CoverComponent;
18923 Component_1.ComponentService.registerCover(CoverComponent);
18924 Object.defineProperty(exports, "__esModule", { value: true });
18925 exports.default = CoverComponent;
18927 },{"../Component":207,"rxjs/add/operator/filter":56,"rxjs/add/operator/map":60,"rxjs/add/operator/withLatestFrom":76,"virtual-dom":163}],225:[function(require,module,exports){
18928 /// <reference path="../../typings/index.d.ts" />
18930 var __extends = (this && this.__extends) || function (d, b) {
18931 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
18932 function __() { this.constructor = d; }
18933 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
18935 var _ = require("underscore");
18936 var vd = require("virtual-dom");
18937 var BehaviorSubject_1 = require("rxjs/BehaviorSubject");
18938 require("rxjs/add/operator/combineLatest");
18939 var Component_1 = require("../Component");
18940 var DebugComponent = (function (_super) {
18941 __extends(DebugComponent, _super);
18942 function DebugComponent(name, container, navigator) {
18943 _super.call(this, name, container, navigator);
18944 this._open$ = new BehaviorSubject_1.BehaviorSubject(false);
18945 this._displaying = false;
18947 DebugComponent.prototype._activate = function () {
18949 this._disposable = this._navigator.stateService.currentState$
18950 .combineLatest(this._open$, this._navigator.imageLoadingService.loadstatus$, function (frame, open, loadStatus) {
18951 return { name: _this._name, vnode: _this._getDebugVNode(open, _this._getDebugInfo(frame, loadStatus)) };
18953 .subscribe(this._container.domRenderer.render$);
18955 DebugComponent.prototype._deactivate = function () {
18956 this._disposable.unsubscribe();
18958 DebugComponent.prototype._getDefaultConfiguration = function () {
18961 DebugComponent.prototype._getDebugInfo = function (frame, loadStatus) {
18963 ret.push(vd.h("h2", "Node"));
18964 if (frame.state.currentNode) {
18965 ret.push(vd.h("p", "currentNode: " + frame.state.currentNode.key));
18967 if (frame.state.previousNode) {
18968 ret.push(vd.h("p", "previousNode: " + frame.state.previousNode.key));
18970 ret.push(vd.h("h2", "Loading"));
18974 for (var _i = 0, _a = _.values(loadStatus); _i < _a.length; _i++) {
18975 var loadStat = _a[_i];
18976 total += loadStat.loaded;
18977 if (loadStat.loaded !== loadStat.total) {
18984 ret.push(vd.h("p", "Loaded Images: " + loaded));
18985 ret.push(vd.h("p", "Loading Images: " + loading));
18986 ret.push(vd.h("p", "Total bytes loaded: " + total));
18987 ret.push(vd.h("h2", "Camera"));
18988 ret.push(vd.h("p", "camera.position.x: " + frame.state.camera.position.x));
18989 ret.push(vd.h("p", "camera.position.y: " + frame.state.camera.position.y));
18990 ret.push(vd.h("p", "camera.position.z: " + frame.state.camera.position.z));
18991 ret.push(vd.h("p", "camera.lookat.x: " + frame.state.camera.lookat.x));
18992 ret.push(vd.h("p", "camera.lookat.y: " + frame.state.camera.lookat.y));
18993 ret.push(vd.h("p", "camera.lookat.z: " + frame.state.camera.lookat.z));
18994 ret.push(vd.h("p", "camera.up.x: " + frame.state.camera.up.x));
18995 ret.push(vd.h("p", "camera.up.y: " + frame.state.camera.up.y));
18996 ret.push(vd.h("p", "camera.up.z: " + frame.state.camera.up.z));
18999 DebugComponent.prototype._getDebugVNode = function (open, info) {
19001 return vd.h("div.Debug", {}, [
19002 vd.h("h2", {}, ["Debug"]),
19003 this._getDebugVNodeButton(open),
19004 vd.h("pre", {}, info),
19008 return this._getDebugVNodeButton(open);
19011 DebugComponent.prototype._getDebugVNodeButton = function (open) {
19012 var buttonText = open ? "Disable Debug" : "D";
19013 var buttonCssClass = open ? "" : ".DebugButtonFixed";
19015 return vd.h("button.DebugButton" + buttonCssClass, { onclick: this._closeDebugElement.bind(this) }, [buttonText]);
19018 return vd.h("button.DebugButton" + buttonCssClass, { onclick: this._openDebugElement.bind(this) }, [buttonText]);
19021 DebugComponent.prototype._closeDebugElement = function (open) {
19022 this._open$.next(false);
19024 DebugComponent.prototype._openDebugElement = function () {
19025 this._open$.next(true);
19027 DebugComponent.componentName = "debug";
19028 return DebugComponent;
19029 }(Component_1.Component));
19030 exports.DebugComponent = DebugComponent;
19031 Component_1.ComponentService.register(DebugComponent);
19032 Object.defineProperty(exports, "__esModule", { value: true });
19033 exports.default = DebugComponent;
19035 },{"../Component":207,"rxjs/BehaviorSubject":25,"rxjs/add/operator/combineLatest":49,"underscore":158,"virtual-dom":163}],226:[function(require,module,exports){
19036 /// <reference path="../../typings/index.d.ts" />
19038 var __extends = (this && this.__extends) || function (d, b) {
19039 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
19040 function __() { this.constructor = d; }
19041 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
19043 var vd = require("virtual-dom");
19044 require("rxjs/add/operator/combineLatest");
19045 var Component_1 = require("../Component");
19046 var ImageComponent = (function (_super) {
19047 __extends(ImageComponent, _super);
19048 function ImageComponent(name, container, navigator) {
19049 _super.call(this, name, container, navigator);
19050 this._canvasId = container.id + "-" + this._name;
19052 ImageComponent.prototype._activate = function () {
19054 this.drawSubscription = this._container.domRenderer.element$
19055 .combineLatest(this._navigator.stateService.currentNode$, function (element, node) {
19056 var canvas = document.getElementById(_this._canvasId);
19057 return { canvas: canvas, node: node };
19059 .subscribe(function (canvasNode) {
19060 var canvas = canvasNode.canvas;
19061 var node = canvasNode.node;
19062 if (!node || !canvas) {
19065 var adaptableDomRenderer = canvas.parentElement;
19066 var width = adaptableDomRenderer.offsetWidth;
19067 var height = adaptableDomRenderer.offsetHeight;
19068 canvas.width = width;
19069 canvas.height = height;
19070 var ctx = canvas.getContext("2d");
19071 ctx.drawImage(node.image, 0, 0, width, height);
19073 this._container.domRenderer.renderAdaptive$.next({ name: this._name, vnode: vd.h("canvas#" + this._canvasId, []) });
19075 ImageComponent.prototype._deactivate = function () {
19076 this.drawSubscription.unsubscribe();
19078 ImageComponent.prototype._getDefaultConfiguration = function () {
19081 ImageComponent.componentName = "image";
19082 return ImageComponent;
19083 }(Component_1.Component));
19084 exports.ImageComponent = ImageComponent;
19085 Component_1.ComponentService.register(ImageComponent);
19086 Object.defineProperty(exports, "__esModule", { value: true });
19087 exports.default = ImageComponent;
19089 },{"../Component":207,"rxjs/add/operator/combineLatest":49,"virtual-dom":163}],227:[function(require,module,exports){
19091 var __extends = (this && this.__extends) || function (d, b) {
19092 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
19093 function __() { this.constructor = d; }
19094 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
19096 var Observable_1 = require("rxjs/Observable");
19097 require("rxjs/add/observable/fromEvent");
19098 require("rxjs/add/operator/withLatestFrom");
19099 var Edge_1 = require("../Edge");
19100 var Component_1 = require("../Component");
19101 var Geo_1 = require("../Geo");
19102 var KeyboardComponent = (function (_super) {
19103 __extends(KeyboardComponent, _super);
19104 function KeyboardComponent(name, container, navigator) {
19105 _super.call(this, name, container, navigator);
19106 this._spatial = new Geo_1.Spatial();
19107 this._perspectiveDirections = [
19108 Edge_1.EdgeDirection.StepForward,
19109 Edge_1.EdgeDirection.StepBackward,
19110 Edge_1.EdgeDirection.StepLeft,
19111 Edge_1.EdgeDirection.StepRight,
19112 Edge_1.EdgeDirection.TurnLeft,
19113 Edge_1.EdgeDirection.TurnRight,
19114 Edge_1.EdgeDirection.TurnU,
19117 KeyboardComponent.prototype._activate = function () {
19119 var sequenceEdges$ = this._navigator.stateService.currentNode$
19120 .switchMap(function (node) {
19121 return node.sequenceEdges$;
19123 var spatialEdges$ = this._navigator.stateService.currentNode$
19124 .switchMap(function (node) {
19125 return node.spatialEdges$;
19127 this._disposable = Observable_1.Observable
19128 .fromEvent(document, "keydown")
19129 .withLatestFrom(this._navigator.stateService.currentState$, sequenceEdges$, spatialEdges$, function (event, frame, sequenceEdges, spatialEdges) {
19130 return { event: event, frame: frame, sequenceEdges: sequenceEdges, spatialEdges: spatialEdges };
19132 .subscribe(function (kf) {
19133 if (!kf.frame.state.currentNode.pano) {
19134 _this._navigatePerspective(kf.event, kf.sequenceEdges, kf.spatialEdges);
19137 _this._navigatePanorama(kf.event, kf.sequenceEdges, kf.spatialEdges, kf.frame.state.camera);
19141 KeyboardComponent.prototype._deactivate = function () {
19142 this._disposable.unsubscribe();
19144 KeyboardComponent.prototype._getDefaultConfiguration = function () {
19147 KeyboardComponent.prototype._navigatePanorama = function (event, sequenceEdges, spatialEdges, camera) {
19148 var navigationAngle = 0;
19149 var stepDirection = null;
19150 var sequenceDirection = null;
19151 var phi = this._rotationFromCamera(camera).phi;
19152 switch (event.keyCode) {
19154 if (event.shiftKey || event.altKey) {
19157 navigationAngle = Math.PI / 2 + phi;
19158 stepDirection = Edge_1.EdgeDirection.StepLeft;
19161 if (event.shiftKey) {
19164 if (event.altKey) {
19165 sequenceDirection = Edge_1.EdgeDirection.Next;
19168 navigationAngle = phi;
19169 stepDirection = Edge_1.EdgeDirection.StepForward;
19172 if (event.shiftKey || event.altKey) {
19175 navigationAngle = -Math.PI / 2 + phi;
19176 stepDirection = Edge_1.EdgeDirection.StepRight;
19179 if (event.shiftKey) {
19182 if (event.altKey) {
19183 sequenceDirection = Edge_1.EdgeDirection.Prev;
19186 navigationAngle = Math.PI + phi;
19187 stepDirection = Edge_1.EdgeDirection.StepBackward;
19192 event.preventDefault();
19193 if (sequenceDirection != null) {
19194 this._moveInDir(sequenceDirection, sequenceEdges);
19197 if (stepDirection == null || !spatialEdges.cached) {
19200 navigationAngle = this._spatial.wrapAngle(navigationAngle);
19201 var threshold = Math.PI / 4;
19202 var edges = spatialEdges.edges.filter(function (e) {
19203 return e.data.direction === Edge_1.EdgeDirection.Pano ||
19204 e.data.direction === stepDirection;
19206 var smallestAngle = Number.MAX_VALUE;
19208 for (var _i = 0, edges_1 = edges; _i < edges_1.length; _i++) {
19209 var edge = edges_1[_i];
19210 var angle = Math.abs(this._spatial.wrapAngle(edge.data.worldMotionAzimuth - navigationAngle));
19211 if (angle < Math.min(smallestAngle, threshold)) {
19212 smallestAngle = angle;
19216 if (toKey == null) {
19219 this._navigator.moveToKey$(toKey)
19220 .subscribe(function (n) { return; }, function (e) { console.error(e); });
19222 KeyboardComponent.prototype._rotationFromCamera = function (camera) {
19223 var direction = camera.lookat.clone().sub(camera.position);
19224 var upProjection = direction.clone().dot(camera.up);
19225 var planeProjection = direction.clone().sub(camera.up.clone().multiplyScalar(upProjection));
19226 var phi = Math.atan2(planeProjection.y, planeProjection.x);
19227 var theta = Math.PI / 2 - this._spatial.angleToPlane(direction.toArray(), [0, 0, 1]);
19228 return { phi: phi, theta: theta };
19230 KeyboardComponent.prototype._navigatePerspective = function (event, sequenceEdges, spatialEdges) {
19231 var direction = null;
19232 var sequenceDirection = null;
19233 switch (event.keyCode) {
19235 if (event.altKey) {
19238 direction = event.shiftKey ? Edge_1.EdgeDirection.TurnLeft : Edge_1.EdgeDirection.StepLeft;
19241 if (event.altKey) {
19242 sequenceDirection = Edge_1.EdgeDirection.Next;
19245 direction = event.shiftKey ? Edge_1.EdgeDirection.Pano : Edge_1.EdgeDirection.StepForward;
19248 if (event.altKey) {
19251 direction = event.shiftKey ? Edge_1.EdgeDirection.TurnRight : Edge_1.EdgeDirection.StepRight;
19254 if (event.altKey) {
19255 sequenceDirection = Edge_1.EdgeDirection.Prev;
19258 direction = event.shiftKey ? Edge_1.EdgeDirection.TurnU : Edge_1.EdgeDirection.StepBackward;
19263 event.preventDefault();
19264 if (sequenceDirection != null) {
19265 this._moveInDir(sequenceDirection, sequenceEdges);
19268 this._moveInDir(direction, spatialEdges);
19270 KeyboardComponent.prototype._moveInDir = function (direction, edgeStatus) {
19271 if (!edgeStatus.cached) {
19274 for (var _i = 0, _a = edgeStatus.edges; _i < _a.length; _i++) {
19276 if (edge.data.direction === direction) {
19277 this._navigator.moveToKey$(edge.to)
19278 .subscribe(function (n) { return; }, function (e) { console.error(e); });
19283 KeyboardComponent.componentName = "keyboard";
19284 return KeyboardComponent;
19285 }(Component_1.Component));
19286 exports.KeyboardComponent = KeyboardComponent;
19287 Component_1.ComponentService.register(KeyboardComponent);
19288 Object.defineProperty(exports, "__esModule", { value: true });
19289 exports.default = KeyboardComponent;
19291 },{"../Component":207,"../Edge":208,"../Geo":210,"rxjs/Observable":28,"rxjs/add/observable/fromEvent":41,"rxjs/add/operator/withLatestFrom":76}],228:[function(require,module,exports){
19292 /// <reference path="../../typings/index.d.ts" />
19294 var __extends = (this && this.__extends) || function (d, b) {
19295 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
19296 function __() { this.constructor = d; }
19297 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
19299 var _ = require("underscore");
19300 var vd = require("virtual-dom");
19301 require("rxjs/add/operator/combineLatest");
19302 var Component_1 = require("../Component");
19303 var LoadingComponent = (function (_super) {
19304 __extends(LoadingComponent, _super);
19305 function LoadingComponent(name, container, navigator) {
19306 _super.call(this, name, container, navigator);
19308 LoadingComponent.prototype._activate = function () {
19310 this._loadingSubscription = this._navigator.loadingService.loading$
19311 .combineLatest(this._navigator.imageLoadingService.loadstatus$, function (loading, loadStatus) {
19313 return { name: "loading", vnode: _this._getBarVNode(100) };
19317 for (var _i = 0, _a = _.values(loadStatus); _i < _a.length; _i++) {
19318 var loadStat = _a[_i];
19319 if (loadStat.loaded !== loadStat.total) {
19320 loaded += loadStat.loaded;
19321 total += loadStat.total;
19324 var percentage = 100;
19326 percentage = (loaded / total) * 100;
19328 return { name: _this._name, vnode: _this._getBarVNode(percentage) };
19330 .subscribe(this._container.domRenderer.render$);
19332 LoadingComponent.prototype._deactivate = function () {
19333 this._loadingSubscription.unsubscribe();
19335 LoadingComponent.prototype._getDefaultConfiguration = function () {
19338 LoadingComponent.prototype._getBarVNode = function (percentage) {
19339 var loadingBarStyle = {};
19340 var loadingContainerStyle = {};
19341 if (percentage !== 100) {
19342 loadingBarStyle.width = percentage.toFixed(0) + "%";
19343 loadingBarStyle.opacity = "1";
19346 loadingBarStyle.width = "100%";
19347 loadingBarStyle.opacity = "0";
19349 return vd.h("div.Loading", { style: loadingContainerStyle }, [vd.h("div.LoadingBar", { style: loadingBarStyle }, [])]);
19351 LoadingComponent.componentName = "loading";
19352 return LoadingComponent;
19353 }(Component_1.Component));
19354 exports.LoadingComponent = LoadingComponent;
19355 Component_1.ComponentService.register(LoadingComponent);
19356 Object.defineProperty(exports, "__esModule", { value: true });
19357 exports.default = LoadingComponent;
19359 },{"../Component":207,"rxjs/add/operator/combineLatest":49,"underscore":158,"virtual-dom":163}],229:[function(require,module,exports){
19360 /// <reference path="../../typings/index.d.ts" />
19362 var __extends = (this && this.__extends) || function (d, b) {
19363 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
19364 function __() { this.constructor = d; }
19365 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
19367 var THREE = require("three");
19368 var vd = require("virtual-dom");
19369 var Observable_1 = require("rxjs/Observable");
19370 require("rxjs/add/observable/merge");
19371 require("rxjs/add/operator/filter");
19372 require("rxjs/add/operator/map");
19373 require("rxjs/add/operator/withLatestFrom");
19374 var Component_1 = require("../Component");
19375 var Geo_1 = require("../Geo");
19377 * @class MouseComponent
19378 * @classdesc Component handling mouse and touch events for camera movement.
19380 var MouseComponent = (function (_super) {
19381 __extends(MouseComponent, _super);
19382 function MouseComponent(name, container, navigator) {
19383 _super.call(this, name, container, navigator);
19384 this._spatial = new Geo_1.Spatial();
19386 MouseComponent.prototype._activate = function () {
19388 var draggingStarted$ = this._container.mouseService
19389 .filtered$(this._name, this._container.mouseService.mouseDragStart$)
19390 .map(function (event) {
19393 var draggingStopped$ = this._container.mouseService
19394 .filtered$(this._name, this._container.mouseService.mouseDragEnd$)
19395 .map(function (event) {
19398 var dragging$ = Observable_1.Observable
19399 .merge(draggingStarted$, draggingStopped$)
19402 this._activeSubscription = dragging$
19403 .subscribe(this._container.mouseService.activate$);
19404 this._cursorSubscription = dragging$
19405 .map(function (dragging) {
19406 var className = dragging ? "MouseContainerGrabbing" : "MouseContainerGrab";
19407 var vNode = vd.h("div." + className, {}, []);
19408 return { name: _this._name, vnode: vNode };
19410 .subscribe(this._container.domRenderer.render$);
19411 var mouseMovement$ = this._container.mouseService
19412 .filtered$(this._name, this._container.mouseService.mouseDrag$)
19413 .map(function (e) {
19415 clientX: e.clientX,
19416 clientY: e.clientY,
19417 movementX: e.movementX,
19418 movementY: e.movementY,
19421 var touchMovement$ = this._container.touchService.singleTouchMove$
19422 .map(function (touch) {
19424 clientX: touch.clientX,
19425 clientY: touch.clientY,
19426 movementX: touch.movementX,
19427 movementY: touch.movementY,
19430 this._movementSubscription = Observable_1.Observable
19431 .merge(mouseMovement$, touchMovement$)
19432 .withLatestFrom(this._navigator.stateService.currentState$, function (m, f) {
19435 .filter(function (args) {
19436 var state = args[1].state;
19437 return state.currentNode.fullPano || state.nodesAhead < 1;
19439 .map(function (args) {
19442 .withLatestFrom(this._container.renderService.renderCamera$, this._navigator.stateService.currentTransform$, this._navigator.stateService.currentCamera$, function (m, r, t, c) {
19443 return [m, r, t, c];
19445 .map(function (args) {
19446 var movement = args[0];
19447 var render = args[1];
19448 var transform = args[2];
19449 var camera = args[3].clone();
19450 var element = _this._container.element;
19451 var offsetWidth = element.offsetWidth;
19452 var offsetHeight = element.offsetHeight;
19453 var clientRect = element.getBoundingClientRect();
19454 var canvasX = movement.clientX - clientRect.left;
19455 var canvasY = movement.clientY - clientRect.top;
19456 var currentDirection = _this._unproject(canvasX, canvasY, offsetWidth, offsetHeight, render.perspective)
19457 .sub(render.perspective.position);
19458 var directionX = _this._unproject(canvasX - movement.movementX, canvasY, offsetWidth, offsetHeight, render.perspective)
19459 .sub(render.perspective.position);
19460 var directionY = _this._unproject(canvasX, canvasY - movement.movementY, offsetWidth, offsetHeight, render.perspective)
19461 .sub(render.perspective.position);
19462 var deltaPhi = (movement.movementX > 0 ? 1 : -1) * directionX.angleTo(currentDirection);
19463 var deltaTheta = (movement.movementY > 0 ? -1 : 1) * directionY.angleTo(currentDirection);
19464 var upQuaternion = new THREE.Quaternion().setFromUnitVectors(camera.up, new THREE.Vector3(0, 0, 1));
19465 var upQuaternionInverse = upQuaternion.clone().inverse();
19466 var offset = new THREE.Vector3();
19467 offset.copy(camera.lookat).sub(camera.position);
19468 offset.applyQuaternion(upQuaternion);
19469 var length = offset.length();
19470 var phi = Math.atan2(offset.y, offset.x);
19472 var theta = Math.atan2(Math.sqrt(offset.x * offset.x + offset.y * offset.y), offset.z);
19473 theta += deltaTheta;
19474 theta = Math.max(0.01, Math.min(Math.PI - 0.01, theta));
19475 offset.x = Math.sin(theta) * Math.cos(phi);
19476 offset.y = Math.sin(theta) * Math.sin(phi);
19477 offset.z = Math.cos(theta);
19478 offset.applyQuaternion(upQuaternionInverse);
19479 var lookat = new THREE.Vector3().copy(camera.position).add(offset.multiplyScalar(length));
19480 var basic = transform.projectBasic(lookat.toArray());
19481 var original = transform.projectBasic(camera.lookat.toArray());
19482 var x = basic[0] - original[0];
19483 var y = basic[1] - original[1];
19484 if (Math.abs(x) > 1) {
19487 else if (x > 0.5) {
19490 else if (x < -0.5) {
19495 .subscribe(function (basicRotation) {
19496 _this._navigator.stateService.rotateBasic(basicRotation);
19498 this._mouseWheelSubscription = this._container.mouseService
19499 .filtered$(this._name, this._container.mouseService.mouseWheel$)
19500 .withLatestFrom(this._navigator.stateService.currentState$, function (w, f) {
19503 .filter(function (args) {
19504 var state = args[1].state;
19505 return state.currentNode.fullPano || state.nodesAhead < 1;
19507 .map(function (args) {
19510 .withLatestFrom(this._container.renderService.renderCamera$, this._navigator.stateService.currentTransform$, function (w, r, t) {
19513 .subscribe(function (args) {
19514 var event = args[0];
19515 var render = args[1];
19516 var transform = args[2];
19517 var element = _this._container.element;
19518 var offsetWidth = element.offsetWidth;
19519 var offsetHeight = element.offsetHeight;
19520 var clientRect = element.getBoundingClientRect();
19521 var canvasX = event.clientX - clientRect.left;
19522 var canvasY = event.clientY - clientRect.top;
19523 var unprojected = _this._unproject(canvasX, canvasY, offsetWidth, offsetHeight, render.perspective);
19524 var reference = transform.projectBasic(unprojected.toArray());
19525 var deltaY = event.deltaY;
19526 if (event.deltaMode === 1) {
19527 deltaY = 40 * deltaY;
19529 else if (event.deltaMode === 2) {
19530 deltaY = 800 * deltaY;
19532 var zoom = -3 * deltaY / offsetHeight;
19533 _this._navigator.stateService.zoomIn(zoom, reference);
19535 this._pinchSubscription = this._container.touchService.pinch$
19536 .withLatestFrom(this._navigator.stateService.currentState$, function (p, f) {
19539 .filter(function (args) {
19540 var state = args[1].state;
19541 return state.currentNode.fullPano || state.nodesAhead < 1;
19543 .map(function (args) {
19546 .withLatestFrom(this._container.renderService.renderCamera$, this._navigator.stateService.currentTransform$, function (p, r, t) {
19549 .subscribe(function (args) {
19550 var pinch = args[0];
19551 var render = args[1];
19552 var transform = args[2];
19553 var element = _this._container.element;
19554 var offsetWidth = element.offsetWidth;
19555 var offsetHeight = element.offsetHeight;
19556 var clientRect = element.getBoundingClientRect();
19557 var unprojected = _this._unproject(pinch.centerClientX - clientRect.left, pinch.centerClientY - clientRect.top, offsetWidth, offsetHeight, render.perspective);
19558 var reference = transform.projectBasic(unprojected.toArray());
19559 var zoom = 3 * pinch.distanceChange / Math.min(offsetHeight, offsetWidth);
19560 _this._navigator.stateService.zoomIn(zoom, reference);
19562 this._container.mouseService.claimMouse(this._name, 0);
19564 MouseComponent.prototype._deactivate = function () {
19565 this._container.mouseService.unclaimMouse(this._name);
19566 this._activeSubscription.unsubscribe();
19567 this._cursorSubscription.unsubscribe();
19568 this._movementSubscription.unsubscribe();
19569 this._mouseWheelSubscription.unsubscribe();
19570 this._pinchSubscription.unsubscribe();
19572 MouseComponent.prototype._getDefaultConfiguration = function () {
19575 MouseComponent.prototype._unproject = function (canvasX, canvasY, offsetWidth, offsetHeight, perspectiveCamera) {
19576 var projectedX = 2 * canvasX / offsetWidth - 1;
19577 var projectedY = 1 - 2 * canvasY / offsetHeight;
19578 return new THREE.Vector3(projectedX, projectedY, 1).unproject(perspectiveCamera);
19581 MouseComponent.componentName = "mouse";
19582 return MouseComponent;
19583 }(Component_1.Component));
19584 exports.MouseComponent = MouseComponent;
19585 Component_1.ComponentService.register(MouseComponent);
19586 Object.defineProperty(exports, "__esModule", { value: true });
19587 exports.default = MouseComponent;
19589 },{"../Component":207,"../Geo":210,"rxjs/Observable":28,"rxjs/add/observable/merge":43,"rxjs/add/operator/filter":56,"rxjs/add/operator/map":60,"rxjs/add/operator/withLatestFrom":76,"three":157,"virtual-dom":163}],230:[function(require,module,exports){
19590 /// <reference path="../../typings/index.d.ts" />
19592 var __extends = (this && this.__extends) || function (d, b) {
19593 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
19594 function __() { this.constructor = d; }
19595 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
19597 var vd = require("virtual-dom");
19598 var Observable_1 = require("rxjs/Observable");
19599 require("rxjs/add/operator/map");
19600 require("rxjs/add/operator/first");
19601 var Edge_1 = require("../Edge");
19602 var Component_1 = require("../Component");
19603 var NavigationComponent = (function (_super) {
19604 __extends(NavigationComponent, _super);
19605 function NavigationComponent(name, container, navigator) {
19606 _super.call(this, name, container, navigator);
19607 this._dirNames = {};
19608 this._dirNames[Edge_1.EdgeDirection.StepForward] = "Forward";
19609 this._dirNames[Edge_1.EdgeDirection.StepBackward] = "Backward";
19610 this._dirNames[Edge_1.EdgeDirection.StepLeft] = "Left";
19611 this._dirNames[Edge_1.EdgeDirection.StepRight] = "Right";
19612 this._dirNames[Edge_1.EdgeDirection.TurnLeft] = "Turnleft";
19613 this._dirNames[Edge_1.EdgeDirection.TurnRight] = "Turnright";
19614 this._dirNames[Edge_1.EdgeDirection.TurnU] = "Turnaround";
19616 NavigationComponent.prototype._activate = function () {
19618 this._renderSubscription = this._navigator.stateService.currentNode$
19619 .switchMap(function (node) {
19621 Observable_1.Observable.of([]) :
19622 Observable_1.Observable.combineLatest(node.sequenceEdges$, node.spatialEdges$, function (seq, spa) {
19623 return seq.edges.concat(spa.edges);
19626 .map(function (edges) {
19628 for (var _i = 0, edges_1 = edges; _i < edges_1.length; _i++) {
19629 var edge = edges_1[_i];
19630 var direction = edge.data.direction;
19631 var name_1 = _this._dirNames[direction];
19632 if (name_1 == null) {
19635 btns.push(_this._createVNode(direction, name_1));
19637 return { name: _this._name, vnode: vd.h("div.NavigationComponent", btns) };
19639 .subscribe(this._container.domRenderer.render$);
19641 NavigationComponent.prototype._deactivate = function () {
19642 this._renderSubscription.unsubscribe();
19644 NavigationComponent.prototype._getDefaultConfiguration = function () {
19647 NavigationComponent.prototype._createVNode = function (direction, name) {
19649 return vd.h("span.Direction.Direction" + name, {
19650 onclick: function (ev) {
19651 _this._navigator.moveDir$(direction)
19652 .subscribe(function (node) { return; }, function (error) { console.error(error); });
19656 NavigationComponent.componentName = "navigation";
19657 return NavigationComponent;
19658 }(Component_1.Component));
19659 exports.NavigationComponent = NavigationComponent;
19660 Component_1.ComponentService.register(NavigationComponent);
19661 Object.defineProperty(exports, "__esModule", { value: true });
19662 exports.default = NavigationComponent;
19664 },{"../Component":207,"../Edge":208,"rxjs/Observable":28,"rxjs/add/operator/first":58,"rxjs/add/operator/map":60,"virtual-dom":163}],231:[function(require,module,exports){
19665 /// <reference path="../../typings/index.d.ts" />
19667 var __extends = (this && this.__extends) || function (d, b) {
19668 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
19669 function __() { this.constructor = d; }
19670 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
19672 var _ = require("underscore");
19673 var vd = require("virtual-dom");
19674 var Observable_1 = require("rxjs/Observable");
19675 require("rxjs/add/observable/fromPromise");
19676 require("rxjs/add/observable/of");
19677 require("rxjs/add/operator/combineLatest");
19678 require("rxjs/add/operator/distinct");
19679 require("rxjs/add/operator/distinctUntilChanged");
19680 require("rxjs/add/operator/filter");
19681 require("rxjs/add/operator/map");
19682 require("rxjs/add/operator/mergeMap");
19683 require("rxjs/add/operator/pluck");
19684 require("rxjs/add/operator/scan");
19685 var Component_1 = require("../Component");
19686 var DescriptionState = (function () {
19687 function DescriptionState() {
19689 return DescriptionState;
19691 var RouteState = (function () {
19692 function RouteState() {
19696 var RouteTrack = (function () {
19697 function RouteTrack() {
19698 this.nodeInstructions = [];
19699 this.nodeInstructionsOrdered = [];
19703 var RouteComponent = (function (_super) {
19704 __extends(RouteComponent, _super);
19705 function RouteComponent(name, container, navigator) {
19706 _super.call(this, name, container, navigator);
19708 RouteComponent.prototype._activate = function () {
19710 var _slowedStream$;
19711 _slowedStream$ = this._navigator.stateService.currentState$.filter(function (frame) {
19712 return (frame.id % 2) === 0;
19713 }).filter(function (frame) {
19714 return frame.state.nodesAhead < 15;
19715 }).distinctUntilChanged(undefined, function (frame) {
19716 return frame.state.lastNode.key;
19719 _routeTrack$ = this.configuration$.mergeMap(function (conf) {
19720 return Observable_1.Observable.from(conf.paths);
19721 }).distinct(function (p1, p2) {
19722 return p1.sequenceKey === p2.sequenceKey;
19723 }).mergeMap(function (path) {
19724 return _this._navigator.apiV3.sequenceByKey$([path.sequenceKey])
19725 .map(function (sequenceByKey) {
19726 return sequenceByKey[path.sequenceKey];
19728 }).combineLatest(this.configuration$, function (sequence, conf) {
19730 var instructionPlaces = [];
19731 for (var _i = 0, _a = conf.paths; _i < _a.length; _i++) {
19733 if (path.sequenceKey === sequence.key) {
19734 var nodeInstructions = [];
19735 var saveKey = false;
19736 for (var _b = 0, _c = sequence.keys; _b < _c.length; _b++) {
19738 if (path.startKey === key) {
19742 var description = null;
19743 for (var _d = 0, _e = path.infoKeys; _d < _e.length; _d++) {
19744 var infoKey = _e[_d];
19745 if (infoKey.key === key) {
19746 description = infoKey.description;
19749 nodeInstructions.push({ description: description, key: key });
19751 if (path.stopKey === key) {
19755 instructionPlaces.push({ nodeInstructions: nodeInstructions, place: i });
19759 return instructionPlaces;
19760 }).scan(function (routeTrack, instructionPlaces) {
19761 for (var _i = 0, instructionPlaces_1 = instructionPlaces; _i < instructionPlaces_1.length; _i++) {
19762 var instructionPlace = instructionPlaces_1[_i];
19763 routeTrack.nodeInstructionsOrdered[instructionPlace.place] = instructionPlace.nodeInstructions;
19765 routeTrack.nodeInstructions = _.flatten(routeTrack.nodeInstructionsOrdered);
19767 }, new RouteTrack());
19768 this._disposable = _slowedStream$
19769 .combineLatest(_routeTrack$, this.configuration$, function (frame, routeTrack, conf) {
19770 return { conf: conf, frame: frame, routeTrack: routeTrack };
19771 }).scan(function (routeState, rtAndFrame) {
19772 if (rtAndFrame.conf.playing === undefined || rtAndFrame.conf.playing) {
19773 routeState.routeTrack = rtAndFrame.routeTrack;
19774 routeState.currentNode = rtAndFrame.frame.state.currentNode;
19775 routeState.lastNode = rtAndFrame.frame.state.lastNode;
19776 routeState.playing = true;
19779 _this._navigator.stateService.cutNodes();
19780 routeState.playing = false;
19783 }, new RouteState())
19784 .filter(function (routeState) {
19785 return routeState.playing;
19786 }).filter(function (routeState) {
19787 for (var _i = 0, _a = routeState.routeTrack.nodeInstructions; _i < _a.length; _i++) {
19788 var nodeInstruction = _a[_i];
19789 if (!nodeInstruction) {
19792 if (nodeInstruction.key === routeState.lastNode.key) {
19797 }).distinctUntilChanged(undefined, function (routeState) {
19798 return routeState.lastNode.key;
19799 }).mergeMap(function (routeState) {
19801 for (var _i = 0, _a = routeState.routeTrack.nodeInstructions; _i < _a.length; _i++) {
19802 var nodeInstruction = _a[_i];
19803 if (nodeInstruction.key === routeState.lastNode.key) {
19808 var nextInstruction = routeState.routeTrack.nodeInstructions[i + 1];
19809 if (!nextInstruction) {
19810 return Observable_1.Observable.of(null);
19812 return _this._navigator.graphService.cacheNode$(nextInstruction.key);
19813 }).combineLatest(this.configuration$, function (node, conf) {
19814 return { conf: conf, node: node };
19815 }).filter(function (cAN) {
19816 return cAN.node !== null && cAN.conf.playing;
19817 }).pluck("node").subscribe(this._navigator.stateService.appendNode$);
19818 this._disposableDescription = this._navigator.stateService.currentNode$
19819 .combineLatest(_routeTrack$, this.configuration$, function (node, routeTrack, conf) {
19820 if (conf.playing !== undefined && !conf.playing) {
19823 var description = null;
19824 for (var _i = 0, _a = routeTrack.nodeInstructions; _i < _a.length; _i++) {
19825 var nodeInstruction = _a[_i];
19826 if (nodeInstruction.key === node.key) {
19827 description = nodeInstruction.description;
19831 return description;
19832 }).scan(function (descriptionState, description) {
19833 if (description !== descriptionState.description && description !== null) {
19834 descriptionState.description = description;
19835 descriptionState.showsLeft = 6;
19838 descriptionState.showsLeft--;
19840 if (description === "quit") {
19841 descriptionState.description = null;
19843 return descriptionState;
19844 }, new DescriptionState()).map(function (descriptionState) {
19845 if (descriptionState.showsLeft > 0 && descriptionState.description) {
19846 return { name: _this._name, vnode: _this._getRouteAnnotationNode(descriptionState.description) };
19849 return { name: _this._name, vnode: vd.h("div", []) };
19851 }).subscribe(this._container.domRenderer.render$);
19853 RouteComponent.prototype._deactivate = function () {
19854 this._disposable.unsubscribe();
19855 this._disposableDescription.unsubscribe();
19857 RouteComponent.prototype._getDefaultConfiguration = function () {
19860 RouteComponent.prototype.play = function () {
19861 this.configure({ playing: true });
19863 RouteComponent.prototype.stop = function () {
19864 this.configure({ playing: false });
19866 RouteComponent.prototype._getRouteAnnotationNode = function (description) {
19867 return vd.h("div.RouteFrame", {}, [
19868 vd.h("p", { textContent: description }, []),
19871 RouteComponent.componentName = "route";
19872 return RouteComponent;
19873 }(Component_1.Component));
19874 exports.RouteComponent = RouteComponent;
19875 Component_1.ComponentService.register(RouteComponent);
19876 Object.defineProperty(exports, "__esModule", { value: true });
19877 exports.default = RouteComponent;
19879 },{"../Component":207,"rxjs/Observable":28,"rxjs/add/observable/fromPromise":42,"rxjs/add/observable/of":44,"rxjs/add/operator/combineLatest":49,"rxjs/add/operator/distinct":52,"rxjs/add/operator/distinctUntilChanged":53,"rxjs/add/operator/filter":56,"rxjs/add/operator/map":60,"rxjs/add/operator/mergeMap":63,"rxjs/add/operator/pluck":65,"rxjs/add/operator/scan":68,"underscore":158,"virtual-dom":163}],232:[function(require,module,exports){
19881 var __extends = (this && this.__extends) || function (d, b) {
19882 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
19883 function __() { this.constructor = d; }
19884 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
19886 var Observable_1 = require("rxjs/Observable");
19887 require("rxjs/add/operator/buffer");
19888 require("rxjs/add/operator/debounceTime");
19889 require("rxjs/add/operator/filter");
19890 require("rxjs/add/operator/map");
19891 require("rxjs/add/operator/scan");
19892 var Component_1 = require("../Component");
19893 var StatsComponent = (function (_super) {
19894 __extends(StatsComponent, _super);
19895 function StatsComponent(name, container, navigator) {
19896 _super.call(this, name, container, navigator);
19898 StatsComponent.prototype._activate = function () {
19900 this._sequenceSubscription = this._navigator.stateService.currentNode$
19901 .scan(function (keys, node) {
19902 var sKey = node.sequenceKey;
19904 if (!(sKey in keys.reported)) {
19905 keys.report = [sKey];
19906 keys.reported[sKey] = true;
19909 }, { report: [], reported: {} })
19910 .filter(function (keys) {
19911 return keys.report.length > 0;
19913 .mergeMap(function (keys) {
19914 return _this._navigator.apiV3.sequenceViewAdd$(keys.report)
19915 .catch(function (error, caught) {
19916 console.error("Failed to report sequence stats (" + keys.report + ")", error);
19917 return Observable_1.Observable.empty();
19921 this._imageSubscription = this._navigator.stateService.currentNode$
19922 .map(function (node) {
19925 .buffer(this._navigator.stateService.currentNode$.debounceTime(5000))
19926 .scan(function (keys, newKeys) {
19928 for (var _i = 0, newKeys_1 = newKeys; _i < newKeys_1.length; _i++) {
19929 var key = newKeys_1[_i];
19930 if (!(key in keys.reported)) {
19931 keys.report.push(key);
19932 keys.reported[key] = true;
19936 }, { report: [], reported: {} })
19937 .filter(function (keys) {
19938 return keys.report.length > 0;
19940 .mergeMap(function (keys) {
19941 return _this._navigator.apiV3.imageViewAdd$(keys.report)
19942 .catch(function (error, caught) {
19943 console.error("Failed to report image stats (" + keys.report + ")", error);
19944 return Observable_1.Observable.empty();
19949 StatsComponent.prototype._deactivate = function () {
19950 this._sequenceSubscription.unsubscribe();
19951 this._imageSubscription.unsubscribe();
19953 StatsComponent.prototype._getDefaultConfiguration = function () {
19956 StatsComponent.componentName = "stats";
19957 return StatsComponent;
19958 }(Component_1.Component));
19959 exports.StatsComponent = StatsComponent;
19960 Component_1.ComponentService.register(StatsComponent);
19961 Object.defineProperty(exports, "__esModule", { value: true });
19962 exports.default = StatsComponent;
19964 },{"../Component":207,"rxjs/Observable":28,"rxjs/add/operator/buffer":47,"rxjs/add/operator/debounceTime":51,"rxjs/add/operator/filter":56,"rxjs/add/operator/map":60,"rxjs/add/operator/scan":68}],233:[function(require,module,exports){
19965 /// <reference path="../../../typings/index.d.ts" />
19967 var __extends = (this && this.__extends) || function (d, b) {
19968 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
19969 function __() { this.constructor = d; }
19970 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
19972 var vd = require("virtual-dom");
19973 var Observable_1 = require("rxjs/Observable");
19974 var Subject_1 = require("rxjs/Subject");
19975 require("rxjs/add/observable/combineLatest");
19976 require("rxjs/add/operator/do");
19977 require("rxjs/add/operator/distinctUntilChanged");
19978 require("rxjs/add/operator/filter");
19979 require("rxjs/add/operator/map");
19980 require("rxjs/add/operator/share");
19981 var Component_1 = require("../../Component");
19983 * @class DirectionComponent
19984 * @classdesc Component showing navigation arrows for steps and turns.
19986 var DirectionComponent = (function (_super) {
19987 __extends(DirectionComponent, _super);
19988 function DirectionComponent(name, container, navigator) {
19989 _super.call(this, name, container, navigator);
19990 this._renderer = new Component_1.DirectionDOMRenderer(this.defaultConfiguration, container.element);
19991 this._hoveredKeySubject$ = new Subject_1.Subject();
19992 this._hoveredKey$ = this._hoveredKeySubject$.share();
19994 Object.defineProperty(DirectionComponent.prototype, "hoveredKey$", {
19996 * Get hovered key observable.
19998 * @description An observable emitting the key of the node for the direction
19999 * arrow that is being hovered. When the mouse leaves a direction arrow null
20002 * @returns {Observable<string>}
20005 return this._hoveredKey$;
20011 * Set highlight key.
20013 * @description The arrow pointing towards the node corresponding to the
20014 * highlight key will be highlighted.
20016 * @param {string} highlightKey Key of node to be highlighted if existing
20019 DirectionComponent.prototype.setHighlightKey = function (highlightKey) {
20020 this.configure({ highlightKey: highlightKey });
20023 * Set min width of container element.
20025 * @description Set min width of the non transformed container element holding
20026 * the navigation arrows. If the min width is larger than the max width the
20027 * min width value will be used.
20029 * The container element is automatically resized when the resize
20030 * method on the Viewer class is called.
20032 * @param {number} minWidth
20034 DirectionComponent.prototype.setMinWidth = function (minWidth) {
20035 this.configure({ minWidth: minWidth });
20038 * Set max width of container element.
20040 * @description Set max width of the non transformed container element holding
20041 * the navigation arrows. If the min width is larger than the max width the
20042 * min width value will be used.
20044 * The container element is automatically resized when the resize
20045 * method on the Viewer class is called.
20047 * @param {number} minWidth
20049 DirectionComponent.prototype.setMaxWidth = function (maxWidth) {
20050 this.configure({ maxWidth: maxWidth });
20053 DirectionComponent.prototype.resize = function () {
20054 this._renderer.resize(this._container.element);
20056 DirectionComponent.prototype._activate = function () {
20058 this._configurationSubscription = this._configuration$
20059 .subscribe(function (configuration) {
20060 _this._renderer.setConfiguration(configuration);
20062 this._nodeSubscription = this._navigator.stateService.currentNode$
20063 .do(function (node) {
20064 _this._container.domRenderer.render$.next({ name: _this._name, vnode: vd.h("div", {}, []) });
20065 _this._renderer.setNode(node);
20067 .withLatestFrom(this._configuration$)
20068 .switchMap(function (nc) {
20070 var configuration = nc[1];
20071 return node.spatialEdges$
20072 .withLatestFrom(configuration.distinguishSequence ?
20073 _this._navigator.graphService
20074 .cacheSequence$(node.sequenceKey)
20075 .catch(function (error, caught) {
20076 console.error("Failed to cache sequence (" + node.sequenceKey + ")", error);
20077 return Observable_1.Observable.empty();
20079 Observable_1.Observable.of(null));
20081 .subscribe(function (es) {
20082 _this._renderer.setEdges(es[0], es[1]);
20084 this._renderCameraSubscription = this._container.renderService.renderCameraFrame$
20085 .do(function (renderCamera) {
20086 _this._renderer.setRenderCamera(renderCamera);
20088 .map(function (renderCamera) {
20089 return _this._renderer;
20091 .filter(function (renderer) {
20092 return renderer.needsRender;
20094 .map(function (renderer) {
20095 return { name: _this._name, vnode: renderer.render(_this._navigator) };
20097 .subscribe(this._container.domRenderer.render$);
20098 this._hoveredKeySubscription = Observable_1.Observable
20100 this._container.domRenderer.element$,
20101 this._container.renderService.renderCamera$,
20102 this._container.mouseService.mouseMove$.startWith(null),
20103 this._container.mouseService.mouseUp$.startWith(null),
20104 ], function (e, rc, mm, mu) {
20107 .map(function (element) {
20108 var elements = element.getElementsByClassName("DirectionsPerspective");
20109 for (var i = 0; i < elements.length; i++) {
20110 var hovered = elements.item(i).querySelector(":hover");
20111 if (hovered != null && hovered.hasAttribute("data-key")) {
20112 return hovered.getAttribute("data-key");
20117 .distinctUntilChanged()
20118 .subscribe(this._hoveredKeySubject$);
20120 DirectionComponent.prototype._deactivate = function () {
20121 this._configurationSubscription.unsubscribe();
20122 this._nodeSubscription.unsubscribe();
20123 this._renderCameraSubscription.unsubscribe();
20124 this._hoveredKeySubscription.unsubscribe();
20126 DirectionComponent.prototype._getDefaultConfiguration = function () {
20128 distinguishSequence: false,
20134 DirectionComponent.componentName = "direction";
20135 return DirectionComponent;
20136 }(Component_1.Component));
20137 exports.DirectionComponent = DirectionComponent;
20138 Component_1.ComponentService.register(DirectionComponent);
20139 Object.defineProperty(exports, "__esModule", { value: true });
20140 exports.default = DirectionComponent;
20142 },{"../../Component":207,"rxjs/Observable":28,"rxjs/Subject":33,"rxjs/add/observable/combineLatest":37,"rxjs/add/operator/distinctUntilChanged":53,"rxjs/add/operator/do":54,"rxjs/add/operator/filter":56,"rxjs/add/operator/map":60,"rxjs/add/operator/share":69,"virtual-dom":163}],234:[function(require,module,exports){
20144 var Geo_1 = require("../../Geo");
20146 * @class DirectionDOMCalculator
20147 * @classdesc Helper class for calculating DOM CSS properties.
20149 var DirectionDOMCalculator = (function () {
20150 function DirectionDOMCalculator(configuration, element) {
20151 this._spatial = new Geo_1.Spatial();
20152 this._minThresholdWidth = 320;
20153 this._maxThresholdWidth = 1480;
20154 this._minThresholdHeight = 240;
20155 this._maxThresholdHeight = 820;
20156 this._configure(configuration);
20157 this._resize(element);
20160 Object.defineProperty(DirectionDOMCalculator.prototype, "minWidth", {
20162 return this._minWidth;
20167 Object.defineProperty(DirectionDOMCalculator.prototype, "maxWidth", {
20169 return this._maxWidth;
20174 Object.defineProperty(DirectionDOMCalculator.prototype, "containerWidth", {
20176 return this._containerWidth;
20181 Object.defineProperty(DirectionDOMCalculator.prototype, "containerWidthCss", {
20183 return this._containerWidthCss;
20188 Object.defineProperty(DirectionDOMCalculator.prototype, "containerMarginCss", {
20190 return this._containerMarginCss;
20195 Object.defineProperty(DirectionDOMCalculator.prototype, "containerLeftCss", {
20197 return this._containerLeftCss;
20202 Object.defineProperty(DirectionDOMCalculator.prototype, "containerHeight", {
20204 return this._containerHeight;
20209 Object.defineProperty(DirectionDOMCalculator.prototype, "containerHeightCss", {
20211 return this._containerHeightCss;
20216 Object.defineProperty(DirectionDOMCalculator.prototype, "containerBottomCss", {
20218 return this._containerBottomCss;
20223 Object.defineProperty(DirectionDOMCalculator.prototype, "stepCircleSize", {
20225 return this._stepCircleSize;
20230 Object.defineProperty(DirectionDOMCalculator.prototype, "stepCircleSizeCss", {
20232 return this._stepCircleSizeCss;
20237 Object.defineProperty(DirectionDOMCalculator.prototype, "stepCircleMarginCss", {
20239 return this._stepCircleMarginCss;
20244 Object.defineProperty(DirectionDOMCalculator.prototype, "turnCircleSize", {
20246 return this._turnCircleSize;
20251 Object.defineProperty(DirectionDOMCalculator.prototype, "turnCircleSizeCss", {
20253 return this._turnCircleSizeCss;
20258 Object.defineProperty(DirectionDOMCalculator.prototype, "outerRadius", {
20260 return this._outerRadius;
20265 Object.defineProperty(DirectionDOMCalculator.prototype, "innerRadius", {
20267 return this._innerRadius;
20272 Object.defineProperty(DirectionDOMCalculator.prototype, "shadowOffset", {
20274 return this._shadowOffset;
20280 * Configures the min and max width values.
20282 * @param {IDirectionConfiguration} configuration Configuration
20283 * with min and max width values.
20285 DirectionDOMCalculator.prototype.configure = function (configuration) {
20286 this._configure(configuration);
20290 * Resizes all properties according to the width and height
20293 * @param {HTMLElement} element The container element from which to extract
20294 * the width and height.
20296 DirectionDOMCalculator.prototype.resize = function (element) {
20297 this._resize(element);
20301 * Calculates the coordinates on the unit circle for an angle.
20303 * @param {number} angle Angle in radians.
20304 * @returns {Array<number>} The x and y coordinates on the unit circle.
20306 DirectionDOMCalculator.prototype.angleToCoordinates = function (angle) {
20307 return [Math.cos(angle), Math.sin(angle)];
20310 * Calculates the coordinates on the unit circle for the
20311 * relative angle between the first and second angle.
20313 * @param {number} first Angle in radians.
20314 * @param {number} second Angle in radians.
20315 * @returns {Array<number>} The x and y coordinates on the unit circle
20316 * for the relative angle between the first and second angle.
20318 DirectionDOMCalculator.prototype.relativeAngleToCoordiantes = function (first, second) {
20319 var relativeAngle = this._spatial.wrapAngle(first - second);
20320 return this.angleToCoordinates(relativeAngle);
20322 DirectionDOMCalculator.prototype._configure = function (configuration) {
20323 this._minWidth = configuration.minWidth;
20324 this._maxWidth = this._getMaxWidth(configuration.minWidth, configuration.maxWidth);
20326 DirectionDOMCalculator.prototype._resize = function (element) {
20327 this._elementWidth = element.offsetWidth;
20328 this._elementHeight = element.offsetHeight;
20330 DirectionDOMCalculator.prototype._reset = function () {
20331 this._containerWidth = this._getContainerWidth(this._elementWidth, this._elementHeight);
20332 this._containerHeight = this._getContainerHeight(this.containerWidth);
20333 this._stepCircleSize = this._getStepCircleDiameter(this._containerHeight);
20334 this._turnCircleSize = this._getTurnCircleDiameter(this.containerHeight);
20335 this._outerRadius = this._getOuterRadius(this._containerHeight);
20336 this._innerRadius = this._getInnerRadius(this._containerHeight);
20337 this._shadowOffset = 3;
20338 this._containerWidthCss = this._numberToCssPixels(this._containerWidth);
20339 this._containerMarginCss = this._numberToCssPixels(-0.5 * this._containerWidth);
20340 this._containerLeftCss = this._numberToCssPixels(Math.floor(0.5 * this._elementWidth));
20341 this._containerHeightCss = this._numberToCssPixels(this._containerHeight);
20342 this._containerBottomCss = this._numberToCssPixels(Math.floor(-0.08 * this._containerHeight));
20343 this._stepCircleSizeCss = this._numberToCssPixels(this._stepCircleSize);
20344 this._stepCircleMarginCss = this._numberToCssPixels(-0.5 * this._stepCircleSize);
20345 this._turnCircleSizeCss = this._numberToCssPixels(this._turnCircleSize);
20347 DirectionDOMCalculator.prototype._getContainerWidth = function (elementWidth, elementHeight) {
20348 var relativeWidth = (elementWidth - this._minThresholdWidth) / (this._maxThresholdWidth - this._minThresholdWidth);
20349 var relativeHeight = (elementHeight - this._minThresholdHeight) / (this._maxThresholdHeight - this._minThresholdHeight);
20350 var coeff = Math.max(0, Math.min(1, Math.min(relativeWidth, relativeHeight)));
20351 coeff = 0.04 * Math.round(25 * coeff);
20352 return this._minWidth + coeff * (this._maxWidth - this._minWidth);
20354 DirectionDOMCalculator.prototype._getContainerHeight = function (containerWidth) {
20355 return 0.77 * containerWidth;
20357 DirectionDOMCalculator.prototype._getStepCircleDiameter = function (containerHeight) {
20358 return 0.34 * containerHeight;
20360 DirectionDOMCalculator.prototype._getTurnCircleDiameter = function (containerHeight) {
20361 return 0.3 * containerHeight;
20363 DirectionDOMCalculator.prototype._getOuterRadius = function (containerHeight) {
20364 return 0.31 * containerHeight;
20366 DirectionDOMCalculator.prototype._getInnerRadius = function (containerHeight) {
20367 return 0.125 * containerHeight;
20369 DirectionDOMCalculator.prototype._numberToCssPixels = function (value) {
20370 return value + "px";
20372 DirectionDOMCalculator.prototype._getMaxWidth = function (value, minWidth) {
20373 return value > minWidth ? value : minWidth;
20375 return DirectionDOMCalculator;
20377 exports.DirectionDOMCalculator = DirectionDOMCalculator;
20378 Object.defineProperty(exports, "__esModule", { value: true });
20379 exports.default = DirectionDOMCalculator;
20381 },{"../../Geo":210}],235:[function(require,module,exports){
20382 /// <reference path="../../../typings/index.d.ts" />
20384 var vd = require("virtual-dom");
20385 var Component_1 = require("../../Component");
20386 var Edge_1 = require("../../Edge");
20387 var Geo_1 = require("../../Geo");
20389 * @class DirectionDOMRenderer
20390 * @classdesc DOM renderer for direction arrows.
20392 var DirectionDOMRenderer = (function () {
20393 function DirectionDOMRenderer(configuration, element) {
20394 this._isEdge = false;
20395 this._spatial = new Geo_1.Spatial();
20396 this._calculator = new Component_1.DirectionDOMCalculator(configuration, element);
20398 this._rotation = { phi: 0, theta: 0 };
20399 this._epsilon = 0.5 * Math.PI / 180;
20400 this._highlightKey = null;
20401 this._distinguishSequence = false;
20402 this._needsRender = false;
20403 this._stepEdges = [];
20404 this._turnEdges = [];
20405 this._panoEdges = [];
20406 this._sequenceEdgeKeys = [];
20407 this._stepDirections = [
20408 Edge_1.EdgeDirection.StepForward,
20409 Edge_1.EdgeDirection.StepBackward,
20410 Edge_1.EdgeDirection.StepLeft,
20411 Edge_1.EdgeDirection.StepRight,
20413 this._turnDirections = [
20414 Edge_1.EdgeDirection.TurnLeft,
20415 Edge_1.EdgeDirection.TurnRight,
20416 Edge_1.EdgeDirection.TurnU,
20418 this._turnNames = {};
20419 this._turnNames[Edge_1.EdgeDirection.TurnLeft] = "TurnLeft";
20420 this._turnNames[Edge_1.EdgeDirection.TurnRight] = "TurnRight";
20421 this._turnNames[Edge_1.EdgeDirection.TurnU] = "TurnAround";
20422 // detects IE 8-11, then Edge 20+.
20423 var isIE = !!document.documentMode;
20424 this._isEdge = !isIE && !!window.StyleMedia;
20426 Object.defineProperty(DirectionDOMRenderer.prototype, "needsRender", {
20428 * Get needs render.
20430 * @returns {boolean} Value indicating whether render should be called.
20433 return this._needsRender;
20439 * Renders virtual DOM elements.
20441 * @description Calling render resets the needs render property.
20443 DirectionDOMRenderer.prototype.render = function (navigator) {
20444 this._needsRender = false;
20445 var rotation = this._rotation;
20448 if (this._node.pano) {
20449 steps = steps.concat(this._createPanoArrows(navigator, rotation));
20452 steps = steps.concat(this._createPerspectiveToPanoArrows(navigator, rotation));
20453 steps = steps.concat(this._createStepArrows(navigator, rotation));
20454 turns = turns.concat(this._createTurnArrows(navigator));
20456 return this._getContainer(steps, turns, rotation);
20458 DirectionDOMRenderer.prototype.setEdges = function (edgeStatus, sequence) {
20459 this._setEdges(edgeStatus, sequence);
20460 this._setNeedsRender();
20463 * Set node for which to show edges.
20465 * @param {Node} node
20467 DirectionDOMRenderer.prototype.setNode = function (node) {
20469 this._clearEdges();
20470 this._setNeedsRender();
20473 * Set the render camera to use for calculating rotations.
20475 * @param {RenderCamera} renderCamera
20477 DirectionDOMRenderer.prototype.setRenderCamera = function (renderCamera) {
20478 var camera = renderCamera.camera;
20479 var direction = this._directionFromCamera(camera);
20480 var rotation = this._getRotation(direction, camera.up);
20481 if (Math.abs(rotation.phi - this._rotation.phi) < this._epsilon) {
20484 this._rotation = rotation;
20485 this._setNeedsRender();
20488 * Set configuration values.
20490 * @param {IDirectionConfiguration} configuration
20492 DirectionDOMRenderer.prototype.setConfiguration = function (configuration) {
20493 var needsRender = false;
20494 if (this._highlightKey !== configuration.highlightKey ||
20495 this._distinguishSequence !== configuration.distinguishSequence) {
20496 this._highlightKey = configuration.highlightKey;
20497 this._distinguishSequence = configuration.distinguishSequence;
20498 needsRender = true;
20500 if (this._calculator.minWidth !== configuration.minWidth ||
20501 this._calculator.maxWidth !== configuration.maxWidth) {
20502 this._calculator.configure(configuration);
20503 needsRender = true;
20506 this._setNeedsRender();
20510 * Detect the element's width and height and resize
20511 * elements accordingly.
20513 * @param {HTMLElement} element Viewer container element.
20515 DirectionDOMRenderer.prototype.resize = function (element) {
20516 this._calculator.resize(element);
20517 this._setNeedsRender();
20519 DirectionDOMRenderer.prototype._setNeedsRender = function () {
20520 if (this._node != null) {
20521 this._needsRender = true;
20524 DirectionDOMRenderer.prototype._clearEdges = function () {
20525 this._stepEdges = [];
20526 this._turnEdges = [];
20527 this._panoEdges = [];
20528 this._sequenceEdgeKeys = [];
20530 DirectionDOMRenderer.prototype._setEdges = function (edgeStatus, sequence) {
20531 this._stepEdges = [];
20532 this._turnEdges = [];
20533 this._panoEdges = [];
20534 this._sequenceEdgeKeys = [];
20535 for (var _i = 0, _a = edgeStatus.edges; _i < _a.length; _i++) {
20537 var direction = edge.data.direction;
20538 if (this._stepDirections.indexOf(direction) > -1) {
20539 this._stepEdges.push(edge);
20542 if (this._turnDirections.indexOf(direction) > -1) {
20543 this._turnEdges.push(edge);
20546 if (edge.data.direction === Edge_1.EdgeDirection.Pano) {
20547 this._panoEdges.push(edge);
20550 if (this._distinguishSequence && sequence != null) {
20551 var edges = this._panoEdges
20552 .concat(this._stepEdges)
20553 .concat(this._turnEdges);
20554 for (var _b = 0, edges_1 = edges; _b < edges_1.length; _b++) {
20555 var edge = edges_1[_b];
20556 var edgeKey = edge.to;
20557 for (var _c = 0, _d = sequence.keys; _c < _d.length; _c++) {
20558 var sequenceKey = _d[_c];
20559 if (sequenceKey === edgeKey) {
20560 this._sequenceEdgeKeys.push(edgeKey);
20567 DirectionDOMRenderer.prototype._directionFromCamera = function (camera) {
20568 return camera.lookat.clone().sub(camera.position);
20570 DirectionDOMRenderer.prototype._getRotation = function (direction, up) {
20571 var upProjection = direction.clone().dot(up);
20572 var planeProjection = direction.clone().sub(up.clone().multiplyScalar(upProjection));
20573 var phi = Math.atan2(planeProjection.y, planeProjection.x);
20574 var theta = Math.PI / 2 - this._spatial.angleToPlane(direction.toArray(), [0, 0, 1]);
20575 return { phi: phi, theta: theta };
20577 DirectionDOMRenderer.prototype._createPanoArrows = function (navigator, rotation) {
20579 for (var _i = 0, _a = this._panoEdges; _i < _a.length; _i++) {
20580 var panoEdge = _a[_i];
20581 arrows.push(this._createVNodeByKey(navigator, panoEdge.to, panoEdge.data.worldMotionAzimuth, rotation, this._calculator.outerRadius, "DirectionsArrowPano"));
20583 for (var _b = 0, _c = this._stepEdges; _b < _c.length; _b++) {
20584 var stepEdge = _c[_b];
20585 arrows.push(this._createPanoToPerspectiveArrow(navigator, stepEdge.to, stepEdge.data.worldMotionAzimuth, rotation, stepEdge.data.direction));
20589 DirectionDOMRenderer.prototype._createPanoToPerspectiveArrow = function (navigator, key, azimuth, rotation, direction) {
20590 var threshold = Math.PI / 8;
20591 var relativePhi = rotation.phi;
20592 switch (direction) {
20593 case Edge_1.EdgeDirection.StepBackward:
20594 relativePhi = rotation.phi - Math.PI;
20596 case Edge_1.EdgeDirection.StepLeft:
20597 relativePhi = rotation.phi + Math.PI / 2;
20599 case Edge_1.EdgeDirection.StepRight:
20600 relativePhi = rotation.phi - Math.PI / 2;
20605 if (Math.abs(this._spatial.wrapAngle(azimuth - relativePhi)) < threshold) {
20606 return this._createVNodeByKey(navigator, key, azimuth, rotation, this._calculator.outerRadius, "DirectionsArrowStep");
20608 return this._createVNodeDisabled(key, azimuth, rotation);
20610 DirectionDOMRenderer.prototype._createPerspectiveToPanoArrows = function (navigator, rotation) {
20612 for (var _i = 0, _a = this._panoEdges; _i < _a.length; _i++) {
20613 var panoEdge = _a[_i];
20614 arrows.push(this._createVNodeByKey(navigator, panoEdge.to, panoEdge.data.worldMotionAzimuth, rotation, this._calculator.innerRadius, "DirectionsArrowPano", true));
20618 DirectionDOMRenderer.prototype._createStepArrows = function (navigator, rotation) {
20620 for (var _i = 0, _a = this._stepEdges; _i < _a.length; _i++) {
20621 var stepEdge = _a[_i];
20622 arrows.push(this._createVNodeByDirection(navigator, stepEdge.to, stepEdge.data.worldMotionAzimuth, rotation, stepEdge.data.direction));
20626 DirectionDOMRenderer.prototype._createTurnArrows = function (navigator) {
20628 for (var _i = 0, _a = this._turnEdges; _i < _a.length; _i++) {
20629 var turnEdge = _a[_i];
20630 var direction = turnEdge.data.direction;
20631 var name_1 = this._turnNames[direction];
20632 turns.push(this._createVNodeByTurn(navigator, turnEdge.to, name_1, direction));
20636 DirectionDOMRenderer.prototype._createVNodeByKey = function (navigator, key, azimuth, rotation, offset, className, shiftVertically) {
20637 var onClick = function (e) {
20638 navigator.moveToKey$(key)
20639 .subscribe(function (node) { return; }, function (error) { console.error(error); });
20641 return this._createVNode(key, azimuth, rotation, offset, className, "DirectionsCircle", onClick, shiftVertically);
20643 DirectionDOMRenderer.prototype._createVNodeByDirection = function (navigator, key, azimuth, rotation, direction) {
20644 var onClick = function (e) {
20645 navigator.moveDir$(direction)
20646 .subscribe(function (node) { return; }, function (error) { console.error(error); });
20648 return this._createVNode(key, azimuth, rotation, this._calculator.outerRadius, "DirectionsArrowStep", "DirectionsCircle", onClick);
20650 DirectionDOMRenderer.prototype._createVNodeByTurn = function (navigator, key, className, direction) {
20651 var onClick = function (e) {
20652 navigator.moveDir$(direction)
20653 .subscribe(function (node) { return; }, function (error) { console.error(error); });
20656 height: this._calculator.turnCircleSizeCss,
20657 transform: "rotate(0)",
20658 width: this._calculator.turnCircleSizeCss,
20660 switch (direction) {
20661 case Edge_1.EdgeDirection.TurnLeft:
20662 style.left = "5px";
20665 case Edge_1.EdgeDirection.TurnRight:
20666 style.right = "5px";
20669 case Edge_1.EdgeDirection.TurnU:
20670 style.left = "5px";
20671 style.bottom = "5px";
20676 var circleProperties = {
20683 var circleClassName = "TurnCircle";
20684 if (this._sequenceEdgeKeys.indexOf(key) > -1) {
20685 circleClassName += "Sequence";
20687 if (this._highlightKey === key) {
20688 circleClassName += "Highlight";
20690 var turn = vd.h("div." + className, {}, []);
20691 return vd.h("div." + circleClassName, circleProperties, [turn]);
20693 DirectionDOMRenderer.prototype._createVNodeDisabled = function (key, azimuth, rotation) {
20694 return this._createVNode(key, azimuth, rotation, this._calculator.outerRadius, "DirectionsArrowDisabled", "DirectionsCircleDisabled");
20696 DirectionDOMRenderer.prototype._createVNode = function (key, azimuth, rotation, radius, className, circleClassName, onClick, shiftVertically) {
20697 var translation = this._calculator.angleToCoordinates(azimuth - rotation.phi);
20698 // rotate 90 degrees clockwise and flip over X-axis
20699 var translationX = Math.round(-radius * translation[1] + 0.5 * this._calculator.containerWidth);
20700 var translationY = Math.round(-radius * translation[0] + 0.5 * this._calculator.containerHeight);
20701 var shadowTranslation = this._calculator.relativeAngleToCoordiantes(azimuth, rotation.phi);
20702 var shadowOffset = this._calculator.shadowOffset;
20703 var shadowTranslationX = -shadowOffset * shadowTranslation[1];
20704 var shadowTranslationY = shadowOffset * shadowTranslation[0];
20705 var filter = "drop-shadow(" + shadowTranslationX + "px " + shadowTranslationY + "px 1px rgba(0,0,0,0.8))";
20708 "-webkit-filter": filter,
20712 var chevron = vd.h("div." + className, properties, []);
20713 var azimuthDeg = -this._spatial.radToDeg(azimuth - rotation.phi);
20714 var circleTransform = shiftVertically ?
20715 "translate(" + translationX + "px, " + translationY + "px) rotate(" + azimuthDeg + "deg) translateZ(-0.01px)" :
20716 "translate(" + translationX + "px, " + translationY + "px) rotate(" + azimuthDeg + "deg)";
20717 var circleProperties = {
20718 attributes: { "data-key": key },
20721 height: this._calculator.stepCircleSizeCss,
20722 marginLeft: this._calculator.stepCircleMarginCss,
20723 marginTop: this._calculator.stepCircleMarginCss,
20724 transform: circleTransform,
20725 width: this._calculator.stepCircleSizeCss,
20728 if (this._sequenceEdgeKeys.indexOf(key) > -1) {
20729 circleClassName += "Sequence";
20731 if (this._highlightKey === key) {
20732 circleClassName += "Highlight";
20734 return vd.h("div." + circleClassName, circleProperties, [chevron]);
20736 DirectionDOMRenderer.prototype._getContainer = function (steps, turns, rotation) {
20737 // edge does not handle hover on perspective transforms.
20738 var transform = this._isEdge ?
20740 "perspective(" + this._calculator.containerWidthCss + ") rotateX(60deg)";
20741 var perspectiveStyle = {
20742 bottom: this._calculator.containerBottomCss,
20743 height: this._calculator.containerHeightCss,
20744 left: this._calculator.containerLeftCss,
20745 marginLeft: this._calculator.containerMarginCss,
20746 transform: transform,
20747 width: this._calculator.containerWidthCss,
20749 return vd.h("div.DirectionsPerspective", { style: perspectiveStyle }, turns.concat(steps));
20751 return DirectionDOMRenderer;
20753 exports.DirectionDOMRenderer = DirectionDOMRenderer;
20754 Object.defineProperty(exports, "__esModule", { value: true });
20755 exports.default = DirectionDOMRenderer;
20757 },{"../../Component":207,"../../Edge":208,"../../Geo":210,"virtual-dom":163}],236:[function(require,module,exports){
20759 var __extends = (this && this.__extends) || function (d, b) {
20760 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
20761 function __() { this.constructor = d; }
20762 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
20764 var Observable_1 = require("rxjs/Observable");
20765 var Subject_1 = require("rxjs/Subject");
20766 require("rxjs/add/observable/combineLatest");
20767 require("rxjs/add/observable/of");
20768 require("rxjs/add/operator/debounceTime");
20769 require("rxjs/add/operator/distinctUntilChanged");
20770 require("rxjs/add/operator/filter");
20771 require("rxjs/add/operator/map");
20772 require("rxjs/add/operator/scan");
20773 require("rxjs/add/operator/switchMap");
20774 require("rxjs/add/operator/withLatestFrom");
20775 var Component_1 = require("../../Component");
20776 var Render_1 = require("../../Render");
20777 var Graph_1 = require("../../Graph");
20778 var Utils_1 = require("../../Utils");
20779 var ImagePlaneComponent = (function (_super) {
20780 __extends(ImagePlaneComponent, _super);
20781 function ImagePlaneComponent(name, container, navigator) {
20782 _super.call(this, name, container, navigator);
20783 this._rendererOperation$ = new Subject_1.Subject();
20784 this._rendererCreator$ = new Subject_1.Subject();
20785 this._rendererDisposer$ = new Subject_1.Subject();
20786 this._renderer$ = this._rendererOperation$
20787 .scan(function (renderer, operation) {
20788 return operation(renderer);
20790 .filter(function (renderer) {
20791 return renderer != null;
20793 .distinctUntilChanged(undefined, function (renderer) {
20794 return renderer.frameId;
20796 this._rendererCreator$
20798 return function (renderer) {
20799 if (renderer != null) {
20800 throw new Error("Multiple image plane states can not be created at the same time");
20802 return new Component_1.ImagePlaneGLRenderer();
20805 .subscribe(this._rendererOperation$);
20806 this._rendererDisposer$
20808 return function (renderer) {
20809 renderer.dispose();
20813 .subscribe(this._rendererOperation$);
20815 ImagePlaneComponent.prototype._activate = function () {
20817 this._rendererSubscription = this._renderer$
20818 .map(function (renderer) {
20822 frameId: renderer.frameId,
20823 needsRender: renderer.needsRender,
20824 render: renderer.render.bind(renderer),
20825 stage: Render_1.GLRenderStage.Background,
20828 renderer.clearNeedsRender();
20831 .subscribe(this._container.glRenderer.render$);
20832 this._rendererCreator$.next(null);
20833 this._stateSubscription = this._navigator.stateService.currentState$
20834 .map(function (frame) {
20835 return function (renderer) {
20836 renderer.updateFrame(frame);
20840 .subscribe(this._rendererOperation$);
20841 this._nodeSubscription = Observable_1.Observable
20842 .combineLatest(this._navigator.stateService.currentNode$, this._configuration$)
20843 .debounceTime(1000)
20844 .withLatestFrom(this._navigator.stateService.currentTransform$, function (nc, t) {
20845 return [nc[0], nc[1], t];
20847 .map(function (params) {
20848 var node = params[0];
20849 var configuration = params[1];
20850 var transform = params[2];
20851 var imageSize = Utils_1.Settings.maxImageSize;
20853 if (configuration.maxPanoramaResolution === "high") {
20854 imageSize = Math.max(imageSize, Math.min(4096, Math.max(transform.width, transform.height)));
20856 else if (configuration.maxPanoramaResolution === "full") {
20857 imageSize = Math.max(imageSize, transform.width, transform.height);
20860 return [node, imageSize];
20862 .filter(function (params) {
20863 var node = params[0];
20864 var imageSize = params[1];
20866 imageSize > Utils_1.Settings.basePanoramaSize :
20867 imageSize > Utils_1.Settings.baseImageSize;
20869 .switchMap(function (params) {
20870 var node = params[0];
20871 var imageSize = params[1];
20872 var image$ = node.pano && imageSize > Utils_1.Settings.maxImageSize ?
20873 Graph_1.ImageLoader.loadDynamic(node.key, imageSize) :
20874 Graph_1.ImageLoader.loadThumbnail(node.key, imageSize);
20876 .filter(function (statusObject) {
20877 return statusObject.object != null;
20880 .map(function (statusObject) {
20881 return statusObject.object;
20883 .zip(Observable_1.Observable.of(node), function (i, n) {
20886 .catch(function (error, caught) {
20887 console.error("Failed to fetch high res image (" + node.key + ")", error);
20888 return Observable_1.Observable.empty();
20891 .map(function (imn) {
20892 return function (renderer) {
20893 renderer.updateTexture(imn[0], imn[1]);
20897 .subscribe(this._rendererOperation$);
20899 ImagePlaneComponent.prototype._deactivate = function () {
20900 this._rendererDisposer$.next(null);
20901 this._rendererSubscription.unsubscribe();
20902 this._stateSubscription.unsubscribe();
20903 this._nodeSubscription.unsubscribe();
20905 ImagePlaneComponent.prototype._getDefaultConfiguration = function () {
20906 return { maxPanoramaResolution: "auto" };
20908 ImagePlaneComponent.componentName = "imagePlane";
20909 return ImagePlaneComponent;
20910 }(Component_1.Component));
20911 exports.ImagePlaneComponent = ImagePlaneComponent;
20912 Component_1.ComponentService.register(ImagePlaneComponent);
20913 Object.defineProperty(exports, "__esModule", { value: true });
20914 exports.default = ImagePlaneComponent;
20916 },{"../../Component":207,"../../Graph":211,"../../Render":213,"../../Utils":215,"rxjs/Observable":28,"rxjs/Subject":33,"rxjs/add/observable/combineLatest":37,"rxjs/add/observable/of":44,"rxjs/add/operator/debounceTime":51,"rxjs/add/operator/distinctUntilChanged":53,"rxjs/add/operator/filter":56,"rxjs/add/operator/map":60,"rxjs/add/operator/scan":68,"rxjs/add/operator/switchMap":73,"rxjs/add/operator/withLatestFrom":76}],237:[function(require,module,exports){
20917 /// <reference path="../../../typings/index.d.ts" />
20919 var THREE = require("three");
20920 var Component_1 = require("../../Component");
20921 var ImagePlaneFactory = (function () {
20922 function ImagePlaneFactory(imagePlaneDepth, imageSphereRadius) {
20923 this._imagePlaneDepth = imagePlaneDepth != null ? imagePlaneDepth : 200;
20924 this._imageSphereRadius = imageSphereRadius != null ? imageSphereRadius : 200;
20926 ImagePlaneFactory.prototype.createMesh = function (node, transform) {
20927 var mesh = node.pano ?
20928 this._createImageSphere(node, transform) :
20929 this._createImagePlane(node, transform);
20932 ImagePlaneFactory.prototype._createImageSphere = function (node, transform) {
20933 var texture = this._createTexture(node.image);
20934 var materialParameters = this._createSphereMaterialParameters(transform, texture);
20935 var material = new THREE.ShaderMaterial(materialParameters);
20936 var mesh = this._useMesh(transform, node) ?
20937 new THREE.Mesh(this._getImageSphereGeo(transform, node), material) :
20938 new THREE.Mesh(this._getFlatImageSphereGeo(transform), material);
20941 ImagePlaneFactory.prototype._createImagePlane = function (node, transform) {
20942 var texture = this._createTexture(node.image);
20943 var materialParameters = this._createPlaneMaterialParameters(transform, texture);
20944 var material = new THREE.ShaderMaterial(materialParameters);
20945 var geometry = this._useMesh(transform, node) ?
20946 this._getImagePlaneGeo(transform, node) :
20947 this._getFlatImagePlaneGeo(transform);
20948 return new THREE.Mesh(geometry, material);
20950 ImagePlaneFactory.prototype._createSphereMaterialParameters = function (transform, texture) {
20951 var gpano = transform.gpano;
20952 var halfCroppedWidth = (gpano.FullPanoWidthPixels - gpano.CroppedAreaImageWidthPixels) / 2;
20953 var phiShift = 2 * Math.PI * (gpano.CroppedAreaLeftPixels - halfCroppedWidth) / gpano.FullPanoWidthPixels;
20954 var phiLength = 2 * Math.PI * gpano.CroppedAreaImageWidthPixels / gpano.FullPanoWidthPixels;
20955 var halfCroppedHeight = (gpano.FullPanoHeightPixels - gpano.CroppedAreaImageHeightPixels) / 2;
20956 var thetaShift = Math.PI * (halfCroppedHeight - gpano.CroppedAreaTopPixels) / gpano.FullPanoHeightPixels;
20957 var thetaLength = Math.PI * gpano.CroppedAreaImageHeightPixels / gpano.FullPanoHeightPixels;
20958 var materialParameters = {
20960 fragmentShader: Component_1.ImagePlaneShaders.equirectangular.fragment,
20961 side: THREE.DoubleSide,
20978 value: transform.rt,
20986 value: thetaLength,
20993 vertexShader: Component_1.ImagePlaneShaders.equirectangular.vertex,
20995 return materialParameters;
20997 ImagePlaneFactory.prototype._createPlaneMaterialParameters = function (transform, texture) {
20998 var materialParameters = {
21000 fragmentShader: Component_1.ImagePlaneShaders.perspective.fragment,
21001 side: THREE.DoubleSide,
21006 value: new THREE.Vector4(0, 0, 1, 1),
21014 value: transform.projectorMatrix(),
21021 vertexShader: Component_1.ImagePlaneShaders.perspective.vertex,
21023 return materialParameters;
21025 ImagePlaneFactory.prototype._createTexture = function (image) {
21026 var texture = new THREE.Texture(image);
21027 texture.minFilter = THREE.LinearFilter;
21028 texture.needsUpdate = true;
21031 ImagePlaneFactory.prototype._useMesh = function (transform, node) {
21032 return node.mesh.vertices.length &&
21033 transform.scale > 1e-2 &&
21034 transform.scale < 50;
21036 ImagePlaneFactory.prototype._getImageSphereGeo = function (transform, node) {
21037 var t = new THREE.Matrix4().getInverse(transform.srt);
21038 // push everything at least 5 meters in front of the camera
21039 var minZ = 5.0 * transform.scale;
21040 var maxZ = this._imageSphereRadius * transform.scale;
21041 var vertices = node.mesh.vertices;
21042 var numVertices = vertices.length / 3;
21043 var positions = new Float32Array(vertices.length);
21044 for (var i = 0; i < numVertices; ++i) {
21046 var x = vertices[index + 0];
21047 var y = vertices[index + 1];
21048 var z = vertices[index + 2];
21049 var l = Math.sqrt(x * x + y * y + z * z);
21050 var boundedL = Math.max(minZ, Math.min(l, maxZ));
21051 var factor = boundedL / l;
21052 var p = new THREE.Vector3(x * factor, y * factor, z * factor);
21054 positions[index + 0] = p.x;
21055 positions[index + 1] = p.y;
21056 positions[index + 2] = p.z;
21058 var faces = node.mesh.faces;
21059 var indices = new Uint16Array(faces.length);
21060 for (var i = 0; i < faces.length; ++i) {
21061 indices[i] = faces[i];
21063 var geometry = new THREE.BufferGeometry();
21064 geometry.addAttribute("position", new THREE.BufferAttribute(positions, 3));
21065 geometry.setIndex(new THREE.BufferAttribute(indices, 1));
21068 ImagePlaneFactory.prototype._getImagePlaneGeo = function (transform, node) {
21069 var t = new THREE.Matrix4().getInverse(transform.srt);
21070 // push everything at least 5 meters in front of the camera
21071 var minZ = 5.0 * transform.scale;
21072 var maxZ = this._imagePlaneDepth * transform.scale;
21073 var vertices = node.mesh.vertices;
21074 var numVertices = vertices.length / 3;
21075 var positions = new Float32Array(vertices.length);
21076 for (var i = 0; i < numVertices; ++i) {
21078 var x = vertices[index + 0];
21079 var y = vertices[index + 1];
21080 var z = vertices[index + 2];
21081 var boundedZ = Math.max(minZ, Math.min(z, maxZ));
21082 var factor = boundedZ / z;
21083 var p = new THREE.Vector3(x * factor, y * factor, boundedZ);
21085 positions[index + 0] = p.x;
21086 positions[index + 1] = p.y;
21087 positions[index + 2] = p.z;
21089 var faces = node.mesh.faces;
21090 var indices = new Uint16Array(faces.length);
21091 for (var i = 0; i < faces.length; ++i) {
21092 indices[i] = faces[i];
21094 var geometry = new THREE.BufferGeometry();
21095 geometry.addAttribute("position", new THREE.BufferAttribute(positions, 3));
21096 geometry.setIndex(new THREE.BufferAttribute(indices, 1));
21099 ImagePlaneFactory.prototype._getFlatImageSphereGeo = function (transform) {
21100 var gpano = transform.gpano;
21101 var phiStart = 2 * Math.PI * gpano.CroppedAreaLeftPixels / gpano.FullPanoWidthPixels;
21102 var phiLength = 2 * Math.PI * gpano.CroppedAreaImageWidthPixels / gpano.FullPanoWidthPixels;
21103 var thetaStart = Math.PI *
21104 (gpano.FullPanoHeightPixels - gpano.CroppedAreaImageHeightPixels - gpano.CroppedAreaTopPixels) /
21105 gpano.FullPanoHeightPixels;
21106 var thetaLength = Math.PI * gpano.CroppedAreaImageHeightPixels / gpano.FullPanoHeightPixels;
21107 var geometry = new THREE.SphereGeometry(this._imageSphereRadius, 20, 40, phiStart - Math.PI / 2, phiLength, thetaStart, thetaLength);
21108 geometry.applyMatrix(new THREE.Matrix4().getInverse(transform.rt));
21111 ImagePlaneFactory.prototype._getFlatImagePlaneGeo = function (transform) {
21112 var width = transform.width;
21113 var height = transform.height;
21114 var size = Math.max(width, height);
21115 var dx = width / 2.0 / size;
21116 var dy = height / 2.0 / size;
21118 vertices.push(transform.unprojectSfM([-dx, -dy], this._imagePlaneDepth));
21119 vertices.push(transform.unprojectSfM([dx, -dy], this._imagePlaneDepth));
21120 vertices.push(transform.unprojectSfM([dx, dy], this._imagePlaneDepth));
21121 vertices.push(transform.unprojectSfM([-dx, dy], this._imagePlaneDepth));
21122 var positions = new Float32Array(12);
21123 for (var i = 0; i < vertices.length; i++) {
21125 positions[index + 0] = vertices[i][0];
21126 positions[index + 1] = vertices[i][1];
21127 positions[index + 2] = vertices[i][2];
21129 var indices = new Uint16Array(6);
21136 var geometry = new THREE.BufferGeometry();
21137 geometry.addAttribute("position", new THREE.BufferAttribute(positions, 3));
21138 geometry.setIndex(new THREE.BufferAttribute(indices, 1));
21141 return ImagePlaneFactory;
21143 exports.ImagePlaneFactory = ImagePlaneFactory;
21144 Object.defineProperty(exports, "__esModule", { value: true });
21145 exports.default = ImagePlaneFactory;
21147 },{"../../Component":207,"three":157}],238:[function(require,module,exports){
21148 /// <reference path="../../../typings/index.d.ts" />
21150 var Component_1 = require("../../Component");
21151 var Geo_1 = require("../../Geo");
21152 var ImagePlaneGLRenderer = (function () {
21153 function ImagePlaneGLRenderer() {
21154 this._imagePlaneFactory = new Component_1.ImagePlaneFactory();
21155 this._imagePlaneScene = new Component_1.ImagePlaneScene();
21157 this._alphaOld = 0;
21158 this._fadeOutSpeed = 0.05;
21159 this._lastCamera = new Geo_1.Camera();
21160 this._epsilon = 0.000001;
21161 this._currentKey = null;
21162 this._previousKey = null;
21164 this._needsRender = false;
21166 Object.defineProperty(ImagePlaneGLRenderer.prototype, "frameId", {
21168 return this._frameId;
21173 Object.defineProperty(ImagePlaneGLRenderer.prototype, "needsRender", {
21175 return this._needsRender;
21180 ImagePlaneGLRenderer.prototype.updateFrame = function (frame) {
21181 this._updateFrameId(frame.id);
21182 this._needsRender = this._updateAlpha(frame.state.alpha) || this._needsRender;
21183 this._needsRender = this._updateAlphaOld(frame.state.alpha) || this._needsRender;
21184 this._needsRender = this._updateImagePlanes(frame.state) || this._needsRender;
21186 ImagePlaneGLRenderer.prototype.updateTexture = function (image, node) {
21187 if (this._currentKey !== node.key) {
21190 this._needsRender = true;
21191 for (var _i = 0, _a = this._imagePlaneScene.imagePlanes; _i < _a.length; _i++) {
21192 var plane = _a[_i];
21193 var material = plane.material;
21194 var texture = material.uniforms.projectorTex.value;
21195 texture.image = image;
21196 texture.needsUpdate = true;
21199 ImagePlaneGLRenderer.prototype.render = function (perspectiveCamera, renderer) {
21200 var planeAlpha = this._imagePlaneScene.imagePlanesOld.length ? 1 : this._alpha;
21201 for (var _i = 0, _a = this._imagePlaneScene.imagePlanes; _i < _a.length; _i++) {
21202 var plane = _a[_i];
21203 plane.material.uniforms.opacity.value = planeAlpha;
21205 for (var _b = 0, _c = this._imagePlaneScene.imagePlanesOld; _b < _c.length; _b++) {
21206 var plane = _c[_b];
21207 plane.material.uniforms.opacity.value = this._alphaOld;
21209 renderer.render(this._imagePlaneScene.scene, perspectiveCamera);
21210 renderer.render(this._imagePlaneScene.sceneOld, perspectiveCamera);
21211 for (var _d = 0, _e = this._imagePlaneScene.imagePlanes; _d < _e.length; _d++) {
21212 var plane = _e[_d];
21213 plane.material.uniforms.opacity.value = this._alpha;
21215 renderer.render(this._imagePlaneScene.scene, perspectiveCamera);
21217 ImagePlaneGLRenderer.prototype.clearNeedsRender = function () {
21218 this._needsRender = false;
21220 ImagePlaneGLRenderer.prototype.dispose = function () {
21221 this._imagePlaneScene.clear();
21223 ImagePlaneGLRenderer.prototype._updateFrameId = function (frameId) {
21224 this._frameId = frameId;
21226 ImagePlaneGLRenderer.prototype._updateAlpha = function (alpha) {
21227 if (alpha === this._alpha) {
21230 this._alpha = alpha;
21233 ImagePlaneGLRenderer.prototype._updateAlphaOld = function (alpha) {
21234 if (alpha < 1 || this._alphaOld === 0) {
21237 this._alphaOld = Math.max(0, this._alphaOld - this._fadeOutSpeed);
21240 ImagePlaneGLRenderer.prototype._updateImagePlanes = function (state) {
21241 if (state.currentNode == null || state.currentNode.key === this._currentKey) {
21244 this._previousKey = state.previousNode != null ? state.previousNode.key : null;
21245 if (this._previousKey != null) {
21246 if (this._previousKey !== this._currentKey) {
21247 var previousMesh = this._imagePlaneFactory.createMesh(state.previousNode, state.previousTransform);
21248 this._imagePlaneScene.updateImagePlanes([previousMesh]);
21251 this._currentKey = state.currentNode.key;
21252 var currentMesh = this._imagePlaneFactory.createMesh(state.currentNode, state.currentTransform);
21253 this._imagePlaneScene.updateImagePlanes([currentMesh]);
21254 this._alphaOld = 1;
21257 return ImagePlaneGLRenderer;
21259 exports.ImagePlaneGLRenderer = ImagePlaneGLRenderer;
21260 Object.defineProperty(exports, "__esModule", { value: true });
21261 exports.default = ImagePlaneGLRenderer;
21263 },{"../../Component":207,"../../Geo":210}],239:[function(require,module,exports){
21264 /// <reference path="../../../typings/index.d.ts" />
21266 var THREE = require("three");
21267 var ImagePlaneScene = (function () {
21268 function ImagePlaneScene() {
21269 this.scene = new THREE.Scene();
21270 this.sceneOld = new THREE.Scene();
21271 this.imagePlanes = [];
21272 this.imagePlanesOld = [];
21274 ImagePlaneScene.prototype.updateImagePlanes = function (planes) {
21275 this._dispose(this.imagePlanesOld, this.sceneOld);
21276 for (var _i = 0, _a = this.imagePlanes; _i < _a.length; _i++) {
21277 var plane = _a[_i];
21278 this.scene.remove(plane);
21279 this.sceneOld.add(plane);
21281 for (var _b = 0, planes_1 = planes; _b < planes_1.length; _b++) {
21282 var plane = planes_1[_b];
21283 this.scene.add(plane);
21285 this.imagePlanesOld = this.imagePlanes;
21286 this.imagePlanes = planes;
21288 ImagePlaneScene.prototype.addImagePlanes = function (planes) {
21289 for (var _i = 0, planes_2 = planes; _i < planes_2.length; _i++) {
21290 var plane = planes_2[_i];
21291 this.scene.add(plane);
21292 this.imagePlanes.push(plane);
21295 ImagePlaneScene.prototype.addImagePlanesOld = function (planes) {
21296 for (var _i = 0, planes_3 = planes; _i < planes_3.length; _i++) {
21297 var plane = planes_3[_i];
21298 this.sceneOld.add(plane);
21299 this.imagePlanesOld.push(plane);
21302 ImagePlaneScene.prototype.setImagePlanes = function (planes) {
21304 this.addImagePlanes(planes);
21306 ImagePlaneScene.prototype.setImagePlanesOld = function (planes) {
21308 this.addImagePlanesOld(planes);
21310 ImagePlaneScene.prototype.clear = function () {
21314 ImagePlaneScene.prototype._clear = function () {
21315 this._dispose(this.imagePlanes, this.scene);
21316 this.imagePlanes.length = 0;
21318 ImagePlaneScene.prototype._clearOld = function () {
21319 this._dispose(this.imagePlanesOld, this.sceneOld);
21320 this.imagePlanesOld.length = 0;
21322 ImagePlaneScene.prototype._dispose = function (planes, scene) {
21323 for (var _i = 0, planes_4 = planes; _i < planes_4.length; _i++) {
21324 var plane = planes_4[_i];
21325 scene.remove(plane);
21326 plane.geometry.dispose();
21327 plane.material.dispose();
21328 var texture = plane.material.uniforms.projectorTex.value;
21329 if (texture != null) {
21334 return ImagePlaneScene;
21336 exports.ImagePlaneScene = ImagePlaneScene;
21337 Object.defineProperty(exports, "__esModule", { value: true });
21338 exports.default = ImagePlaneScene;
21340 },{"three":157}],240:[function(require,module,exports){
21341 /// <reference path="../../../typings/index.d.ts" />
21344 var path = require("path");
21345 var ImagePlaneShaders = (function () {
21346 function ImagePlaneShaders() {
21348 ImagePlaneShaders.equirectangular = {
21349 fragment: "#ifdef GL_ES\nprecision highp 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}",
21350 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}",
21352 ImagePlaneShaders.perspective = {
21353 fragment: "#ifdef GL_ES\nprecision highp float;\n#endif\n\nuniform sampler2D projectorTex;\nuniform float opacity;\nuniform vec4 bbox;\n\nvarying vec4 vRstq;\n\nvoid main()\n{\n float x = vRstq.x / vRstq.w;\n float y = vRstq.y / vRstq.w;\n\n vec4 baseColor;\n if (x > bbox[0] && y > bbox[1] && x < bbox[2] && y < bbox[3]) {\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}",
21354 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}",
21356 return ImagePlaneShaders;
21358 exports.ImagePlaneShaders = ImagePlaneShaders;
21360 },{"path":21}],241:[function(require,module,exports){
21361 /// <reference path="../../../typings/index.d.ts" />
21363 var __extends = (this && this.__extends) || function (d, b) {
21364 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
21365 function __() { this.constructor = d; }
21366 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
21368 var vd = require("virtual-dom");
21369 var Observable_1 = require("rxjs/Observable");
21370 var Subject_1 = require("rxjs/Subject");
21371 require("rxjs/add/observable/combineLatest");
21372 require("rxjs/add/observable/fromEvent");
21373 require("rxjs/add/observable/of");
21374 require("rxjs/add/observable/zip");
21375 require("rxjs/add/operator/distinctUntilChanged");
21376 require("rxjs/add/operator/filter");
21377 require("rxjs/add/operator/first");
21378 require("rxjs/add/operator/map");
21379 require("rxjs/add/operator/merge");
21380 require("rxjs/add/operator/mergeMap");
21381 require("rxjs/add/operator/scan");
21382 require("rxjs/add/operator/switchMap");
21383 require("rxjs/add/operator/withLatestFrom");
21384 require("rxjs/add/operator/zip");
21385 var Graph_1 = require("../../Graph");
21386 var State_1 = require("../../State");
21387 var Render_1 = require("../../Render");
21388 var Utils_1 = require("../../Utils");
21389 var Component_1 = require("../../Component");
21390 var SliderState = (function () {
21391 function SliderState() {
21392 this._imagePlaneFactory = new Component_1.ImagePlaneFactory();
21393 this._imagePlaneScene = new Component_1.ImagePlaneScene();
21394 this._currentKey = null;
21395 this._previousKey = null;
21396 this._currentPano = false;
21398 this._glNeedsRender = false;
21399 this._domNeedsRender = true;
21400 this._motionless = false;
21403 Object.defineProperty(SliderState.prototype, "frameId", {
21405 return this._frameId;
21410 Object.defineProperty(SliderState.prototype, "curtain", {
21412 return this._curtain;
21417 Object.defineProperty(SliderState.prototype, "glNeedsRender", {
21419 return this._glNeedsRender;
21424 Object.defineProperty(SliderState.prototype, "domNeedsRender", {
21426 return this._domNeedsRender;
21431 Object.defineProperty(SliderState.prototype, "sliderVisible", {
21433 return this._sliderVisible;
21435 set: function (value) {
21436 this._sliderVisible = value;
21437 this._domNeedsRender = true;
21442 Object.defineProperty(SliderState.prototype, "disabled", {
21444 return this._currentKey == null ||
21445 this._previousKey == null ||
21446 this._motionless ||
21452 SliderState.prototype.update = function (frame) {
21453 this._updateFrameId(frame.id);
21454 var needsRender = this._updateImagePlanes(frame.state);
21455 needsRender = this._updateCurtain(frame.state.alpha) || needsRender;
21456 this._glNeedsRender = needsRender || this._glNeedsRender;
21457 this._domNeedsRender = needsRender || this._domNeedsRender;
21459 SliderState.prototype.updateTexture = function (image, node) {
21460 var imagePlanes = node.key === this._currentKey ?
21461 this._imagePlaneScene.imagePlanes :
21462 node.key === this._previousKey ?
21463 this._imagePlaneScene.imagePlanesOld :
21465 if (imagePlanes.length === 0) {
21468 this._glNeedsRender = true;
21469 for (var _i = 0, imagePlanes_1 = imagePlanes; _i < imagePlanes_1.length; _i++) {
21470 var plane = imagePlanes_1[_i];
21471 var material = plane.material;
21472 var texture = material.uniforms.projectorTex.value;
21473 texture.image = image;
21474 texture.needsUpdate = true;
21477 SliderState.prototype.render = function (perspectiveCamera, renderer) {
21478 if (!this.disabled) {
21479 renderer.render(this._imagePlaneScene.sceneOld, perspectiveCamera);
21481 renderer.render(this._imagePlaneScene.scene, perspectiveCamera);
21483 SliderState.prototype.dispose = function () {
21484 this._imagePlaneScene.clear();
21486 SliderState.prototype.clearGLNeedsRender = function () {
21487 this._glNeedsRender = false;
21489 SliderState.prototype.clearDomNeedsRender = function () {
21490 this._domNeedsRender = false;
21492 SliderState.prototype._updateFrameId = function (frameId) {
21493 this._frameId = frameId;
21495 SliderState.prototype._updateImagePlanes = function (state) {
21496 if (state.currentNode == null) {
21499 var needsRender = false;
21500 if (state.previousNode != null && this._previousKey !== state.previousNode.key) {
21501 needsRender = true;
21502 this._previousKey = state.previousNode.key;
21503 this._motionless = state.motionless;
21504 this._imagePlaneScene.setImagePlanesOld([
21505 this._imagePlaneFactory.createMesh(state.previousNode, state.previousTransform),
21508 if (this._currentKey !== state.currentNode.key) {
21509 needsRender = true;
21510 this._currentKey = state.currentNode.key;
21511 this._currentPano = state.currentNode.pano;
21512 this._motionless = state.motionless;
21513 this._imagePlaneScene.setImagePlanes([
21514 this._imagePlaneFactory.createMesh(state.currentNode, state.currentTransform),
21516 if (!this.disabled) {
21517 this._updateBbox();
21520 return needsRender;
21522 SliderState.prototype._updateCurtain = function (alpha) {
21523 if (this.disabled ||
21524 Math.abs(this._curtain - alpha) < 0.001) {
21527 this._curtain = alpha;
21528 this._updateBbox();
21531 SliderState.prototype._updateBbox = function () {
21532 for (var _i = 0, _a = this._imagePlaneScene.imagePlanes; _i < _a.length; _i++) {
21533 var plane = _a[_i];
21534 var shaderMaterial = plane.material;
21535 var bbox = shaderMaterial.uniforms.bbox.value;
21536 bbox.z = this._curtain;
21539 return SliderState;
21541 var SliderComponent = (function (_super) {
21542 __extends(SliderComponent, _super);
21544 * Create a new slider component instance.
21545 * @class SliderComponent
21547 function SliderComponent(name, container, navigator) {
21548 _super.call(this, name, container, navigator);
21549 this._sliderStateOperation$ = new Subject_1.Subject();
21550 this._sliderStateCreator$ = new Subject_1.Subject();
21551 this._sliderStateDisposer$ = new Subject_1.Subject();
21552 this._sliderState$ = this._sliderStateOperation$
21553 .scan(function (sliderState, operation) {
21554 return operation(sliderState);
21556 .filter(function (sliderState) {
21557 return sliderState != null;
21559 .distinctUntilChanged(undefined, function (sliderState) {
21560 return sliderState.frameId;
21562 this._sliderStateCreator$
21564 return function (sliderState) {
21565 if (sliderState != null) {
21566 throw new Error("Multiple slider states can not be created at the same time");
21568 return new SliderState();
21571 .subscribe(this._sliderStateOperation$);
21572 this._sliderStateDisposer$
21574 return function (sliderState) {
21575 sliderState.dispose();
21579 .subscribe(this._sliderStateOperation$);
21582 * Set the image keys.
21584 * Configures the component to show the image planes for the supplied image keys.
21586 * @param {keys} ISliderKeys - Slider keys object specifying the images to be shown in the foreground and the background.
21588 SliderComponent.prototype.setKeys = function (keys) {
21589 this.configure({ keys: keys });
21592 * Set the initial position.
21594 * Configures the intial position of the slider. The inital position value will be used when the component is activated.
21596 * @param {number} initialPosition - Initial slider position.
21598 SliderComponent.prototype.setInitialPosition = function (initialPosition) {
21599 this.configure({ initialPosition: initialPosition });
21602 * Set the value controlling if the slider is visible.
21604 * @param {boolean} sliderVisible - Value indicating if the slider should be visible or not.
21606 SliderComponent.prototype.setSliderVisible = function (sliderVisible) {
21607 this.configure({ sliderVisible: sliderVisible });
21609 SliderComponent.prototype._activate = function () {
21611 this._container.mouseService.preventDefaultMouseDown$.next(false);
21612 this._container.touchService.preventDefaultTouchMove$.next(false);
21613 Observable_1.Observable
21614 .combineLatest(this._navigator.stateService.state$, this._configuration$)
21616 .subscribe(function (stateConfig) {
21617 if (stateConfig[0] === State_1.State.Traversing) {
21618 _this._navigator.stateService.wait();
21619 var position = stateConfig[1].initialPosition;
21620 _this._navigator.stateService.moveTo(position != null ? position : 1);
21623 this._glRenderSubscription = this._sliderState$
21624 .map(function (sliderState) {
21628 frameId: sliderState.frameId,
21629 needsRender: sliderState.glNeedsRender,
21630 render: sliderState.render.bind(sliderState),
21631 stage: Render_1.GLRenderStage.Background,
21634 sliderState.clearGLNeedsRender();
21637 .subscribe(this._container.glRenderer.render$);
21638 this._domRenderSubscription = this._sliderState$
21639 .filter(function (sliderState) {
21640 return sliderState.domNeedsRender;
21642 .map(function (sliderState) {
21643 var sliderInput = vd.h("input.SliderControl", {
21647 value: 1000 * sliderState.curtain,
21649 var vNode = sliderState.disabled || !sliderState.sliderVisible ?
21651 vd.h("div.SliderWrapper", {}, [sliderInput]);
21656 sliderState.clearDomNeedsRender();
21659 .subscribe(this._container.domRenderer.render$);
21660 this._elementSubscription = this._container.domRenderer.element$
21661 .map(function (e) {
21662 var nodeList = e.getElementsByClassName("SliderControl");
21663 var slider = nodeList.length > 0 ? nodeList[0] : null;
21666 .filter(function (input) {
21667 return input != null;
21669 .switchMap(function (input) {
21670 return Observable_1.Observable.fromEvent(input, "input");
21672 .map(function (e) {
21673 return Number(e.target.value) / 1000;
21675 .subscribe(function (curtain) {
21676 _this._navigator.stateService.moveTo(curtain);
21678 this._sliderStateCreator$.next(null);
21679 this._stateSubscription = this._navigator.stateService.currentState$
21680 .map(function (frame) {
21681 return function (sliderState) {
21682 sliderState.update(frame);
21683 return sliderState;
21686 .subscribe(this._sliderStateOperation$);
21687 this._setSliderVisibleSubscription = this._configuration$
21688 .map(function (configuration) {
21689 return configuration.sliderVisible == null || configuration.sliderVisible;
21691 .distinctUntilChanged()
21692 .map(function (sliderVisible) {
21693 return function (sliderState) {
21694 sliderState.sliderVisible = sliderVisible;
21695 return sliderState;
21698 .subscribe(this._sliderStateOperation$);
21699 this._setKeysSubscription = this._configuration$
21700 .filter(function (configuration) {
21701 return configuration.keys != null;
21703 .switchMap(function (configuration) {
21704 return Observable_1.Observable
21705 .zip(_this._catchCacheNode$(configuration.keys.background), _this._catchCacheNode$(configuration.keys.foreground))
21706 .map(function (nodes) {
21707 return { background: nodes[0], foreground: nodes[1] };
21709 .zip(_this._navigator.stateService.currentState$.first())
21710 .map(function (nf) {
21711 return { nodes: nf[0], state: nf[1].state };
21714 .subscribe(function (co) {
21715 if (co.state.currentNode != null &&
21716 co.state.previousNode != null &&
21717 co.state.currentNode.key === co.nodes.foreground.key &&
21718 co.state.previousNode.key === co.nodes.background.key) {
21721 if (co.state.currentNode.key === co.nodes.background.key) {
21722 _this._navigator.stateService.setNodes([co.nodes.foreground]);
21725 if (co.state.currentNode.key === co.nodes.foreground.key &&
21726 co.state.trajectory.length === 1) {
21727 _this._navigator.stateService.prependNodes([co.nodes.background]);
21730 _this._navigator.stateService.setNodes([co.nodes.background]);
21731 _this._navigator.stateService.setNodes([co.nodes.foreground]);
21735 var previousNode$ = this._navigator.stateService.currentState$
21736 .map(function (frame) {
21737 return frame.state.previousNode;
21739 .filter(function (node) {
21740 return node != null;
21742 .distinctUntilChanged(undefined, function (node) {
21745 this._nodeSubscription = Observable_1.Observable
21746 .merge(previousNode$, this._navigator.stateService.currentNode$)
21747 .filter(function (node) {
21749 Utils_1.Settings.maxImageSize > Utils_1.Settings.basePanoramaSize :
21750 Utils_1.Settings.maxImageSize > Utils_1.Settings.baseImageSize;
21752 .mergeMap(function (node) {
21753 return Graph_1.ImageLoader.loadThumbnail(node.key, Utils_1.Settings.maxImageSize)
21754 .filter(function (statusObject) {
21755 return statusObject.object != null;
21758 .map(function (statusObject) {
21759 return statusObject.object;
21761 .zip(Observable_1.Observable.of(node), function (t, n) {
21764 .catch(function (error, caught) {
21765 console.error("Failed to fetch high res slider image (" + node.key + ")", error);
21766 return Observable_1.Observable.empty();
21769 .map(function (imn) {
21770 return function (sliderState) {
21771 sliderState.updateTexture(imn[0], imn[1]);
21772 return sliderState;
21775 .subscribe(this._sliderStateOperation$);
21777 SliderComponent.prototype._deactivate = function () {
21779 this._container.mouseService.preventDefaultMouseDown$.next(true);
21780 this._container.touchService.preventDefaultTouchMove$.next(true);
21781 this._navigator.stateService.state$
21783 .subscribe(function (state) {
21784 if (state === State_1.State.Waiting) {
21785 _this._navigator.stateService.traverse();
21788 this._sliderStateDisposer$.next(null);
21789 this._setKeysSubscription.unsubscribe();
21790 this._setSliderVisibleSubscription.unsubscribe();
21791 this._elementSubscription.unsubscribe();
21792 this._stateSubscription.unsubscribe();
21793 this._glRenderSubscription.unsubscribe();
21794 this._domRenderSubscription.unsubscribe();
21795 this._nodeSubscription.unsubscribe();
21796 this.configure({ keys: null });
21798 SliderComponent.prototype._getDefaultConfiguration = function () {
21801 SliderComponent.prototype._catchCacheNode$ = function (key) {
21802 return this._navigator.graphService.cacheNode$(key)
21803 .catch(function (error, caught) {
21804 console.log("Failed to cache slider node (" + key + ")", error);
21805 return Observable_1.Observable.empty();
21808 SliderComponent.componentName = "slider";
21809 return SliderComponent;
21810 }(Component_1.Component));
21811 exports.SliderComponent = SliderComponent;
21812 Component_1.ComponentService.register(SliderComponent);
21813 Object.defineProperty(exports, "__esModule", { value: true });
21814 exports.default = SliderComponent;
21816 },{"../../Component":207,"../../Graph":211,"../../Render":213,"../../State":214,"../../Utils":215,"rxjs/Observable":28,"rxjs/Subject":33,"rxjs/add/observable/combineLatest":37,"rxjs/add/observable/fromEvent":41,"rxjs/add/observable/of":44,"rxjs/add/observable/zip":46,"rxjs/add/operator/distinctUntilChanged":53,"rxjs/add/operator/filter":56,"rxjs/add/operator/first":58,"rxjs/add/operator/map":60,"rxjs/add/operator/merge":61,"rxjs/add/operator/mergeMap":63,"rxjs/add/operator/scan":68,"rxjs/add/operator/switchMap":73,"rxjs/add/operator/withLatestFrom":76,"rxjs/add/operator/zip":77,"virtual-dom":163}],242:[function(require,module,exports){
21818 var Marker = (function () {
21819 function Marker(latLonAlt, markerOptions) {
21820 this.visibleInKeys = [];
21821 this._id = markerOptions.id;
21822 this._latLonAlt = latLonAlt;
21823 this._markerOptions = markerOptions;
21824 this._type = markerOptions.type;
21826 Object.defineProperty(Marker.prototype, "id", {
21833 Object.defineProperty(Marker.prototype, "type", {
21840 Object.defineProperty(Marker.prototype, "latLonAlt", {
21842 return this._latLonAlt;
21849 exports.Marker = Marker;
21850 Object.defineProperty(exports, "__esModule", { value: true });
21851 exports.default = Marker;
21853 },{}],243:[function(require,module,exports){
21854 /// <reference path="../../../typings/index.d.ts" />
21856 var __extends = (this && this.__extends) || function (d, b) {
21857 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
21858 function __() { this.constructor = d; }
21859 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
21861 var _ = require("underscore");
21862 var THREE = require("three");
21863 var rbush = require("rbush");
21864 var Observable_1 = require("rxjs/Observable");
21865 var Subject_1 = require("rxjs/Subject");
21866 require("rxjs/add/observable/combineLatest");
21867 require("rxjs/add/operator/distinctUntilChanged");
21868 require("rxjs/add/operator/filter");
21869 require("rxjs/add/operator/map");
21870 require("rxjs/add/operator/publishReplay");
21871 require("rxjs/add/operator/scan");
21872 require("rxjs/add/operator/switchMap");
21873 var Component_1 = require("../../Component");
21874 var Render_1 = require("../../Render");
21875 var Geo_1 = require("../../Geo");
21876 var MarkerSet = (function () {
21877 function MarkerSet() {
21878 this._create$ = new Subject_1.Subject();
21879 this._remove$ = new Subject_1.Subject();
21880 this._update$ = new Subject_1.Subject();
21881 // markers list stream is the result of applying marker updates.
21882 this._markers$ = this._update$
21883 .scan(function (markers, operation) {
21884 return operation(markers);
21885 }, { hash: {}, spatial: rbush(16, [".lon", ".lat", ".lon", ".lat"]) })
21886 .map(function (markers) {
21887 return markers.spatial;
21891 // creation stream generate creation updates from given markers.
21893 .map(function (marker) {
21894 return function (markers) {
21895 if (markers.hash[marker.id]) {
21896 markers.spatial.remove(markers.hash[marker.id]);
21900 lat: marker.latLonAlt.lat,
21901 lon: marker.latLonAlt.lon,
21904 markers.spatial.insert(rbushObj);
21905 markers.hash[marker.id] = rbushObj;
21909 .subscribe(this._update$);
21910 // remove stream generates remove updates from given markers
21912 .map(function (id) {
21913 return function (markers) {
21914 var rbushObj = markers.hash[id];
21915 markers.spatial.remove(rbushObj);
21916 delete markers.hash[id];
21920 .subscribe(this._update$);
21922 MarkerSet.prototype.addMarker = function (marker) {
21923 this._create$.next(marker);
21925 MarkerSet.prototype.removeMarker = function (id) {
21926 this._remove$.next(id);
21928 Object.defineProperty(MarkerSet.prototype, "markers$", {
21930 return this._markers$;
21937 exports.MarkerSet = MarkerSet;
21938 var MarkerComponent = (function (_super) {
21939 __extends(MarkerComponent, _super);
21940 function MarkerComponent(name, container, navigator) {
21941 _super.call(this, name, container, navigator);
21943 MarkerComponent.prototype._activate = function () {
21945 this._scene = new THREE.Scene();
21946 this._markerSet = new MarkerSet();
21947 this._markerObjects = {};
21948 this._disposable = Observable_1.Observable
21950 this._navigator.stateService.currentState$,
21951 this._markerSet.markers$,
21952 ], function (frame, markers) {
21953 return { frame: frame, markers: markers };
21955 .distinctUntilChanged(undefined, function (args) {
21956 return args.frame.id;
21958 .map(function (args) {
21959 return _this._renderHash(args);
21961 .subscribe(this._container.glRenderer.render$);
21963 MarkerComponent.prototype._deactivate = function () {
21965 this._disposeScene();
21966 this._disposable.unsubscribe();
21968 MarkerComponent.prototype._getDefaultConfiguration = function () {
21971 MarkerComponent.prototype.createMarker = function (latLonAlt, markerOptions) {
21972 if (markerOptions.type === "marker") {
21973 return new Component_1.SimpleMarker(latLonAlt, markerOptions);
21977 MarkerComponent.prototype.addMarker = function (marker) {
21978 this._markerSet.addMarker(marker);
21980 Object.defineProperty(MarkerComponent.prototype, "markers$", {
21982 return this._markerSet.markers$;
21987 MarkerComponent.prototype.removeMarker = function (id) {
21988 this._markerSet.removeMarker(id);
21990 MarkerComponent.prototype._renderHash = function (args) {
21991 // determine if render is needed while updating scene
21992 // specific properies.
21993 var needsRender = this._updateScene(args);
21994 // return render hash with render function and
21995 // render in foreground.
21999 frameId: args.frame.id,
22000 needsRender: needsRender,
22001 render: this._render.bind(this),
22002 stage: Render_1.GLRenderStage.Foreground,
22006 MarkerComponent.prototype._updateScene = function (args) {
22009 !args.frame.state.currentNode) {
22012 var needRender = false;
22013 var oldObjects = this._markerObjects;
22014 var node = args.frame.state.currentNode;
22015 this._markerObjects = {};
22016 var boxWidth = 0.001;
22017 var minLon = node.latLon.lon - boxWidth / 2;
22018 var minLat = node.latLon.lat - boxWidth / 2;
22019 var maxLon = node.latLon.lon + boxWidth / 2;
22020 var maxLat = node.latLon.lat + boxWidth / 2;
22021 var markers = _.map(args.markers.search({ maxX: maxLon, maxY: maxLat, minX: minLon, minY: minLat }), function (item) {
22022 return item.marker;
22023 }).filter(function (marker) {
22024 return marker.visibleInKeys.length === 0 || _.contains(marker.visibleInKeys, node.key);
22026 for (var _i = 0, markers_1 = markers; _i < markers_1.length; _i++) {
22027 var marker = markers_1[_i];
22028 if (marker.id in oldObjects) {
22029 this._markerObjects[marker.id] = oldObjects[marker.id];
22030 delete oldObjects[marker.id];
22033 var reference = args.frame.state.reference;
22034 var p = (new Geo_1.GeoCoords).geodeticToEnu(marker.latLonAlt.lat, marker.latLonAlt.lon, marker.latLonAlt.alt, reference.lat, reference.lon, reference.alt);
22035 var o = marker.createGeometry();
22036 o.position.set(p[0], p[1], p[2]);
22037 this._scene.add(o);
22038 this._markerObjects[marker.id] = o;
22042 for (var i in oldObjects) {
22043 if (oldObjects.hasOwnProperty(i)) {
22044 this._disposeObject(oldObjects[i]);
22050 MarkerComponent.prototype._render = function (perspectiveCamera, renderer) {
22051 renderer.render(this._scene, perspectiveCamera);
22053 MarkerComponent.prototype._disposeObject = function (object) {
22054 this._scene.remove(object);
22055 for (var i = 0; i < object.children.length; ++i) {
22056 var c = object.children[i];
22057 c.geometry.dispose();
22058 c.material.dispose();
22061 MarkerComponent.prototype._disposeScene = function () {
22062 for (var i in this._markerObjects) {
22063 if (this._markerObjects.hasOwnProperty(i)) {
22064 this._disposeObject(this._markerObjects[i]);
22067 this._markerObjects = {};
22069 MarkerComponent.componentName = "marker";
22070 return MarkerComponent;
22071 }(Component_1.Component));
22072 exports.MarkerComponent = MarkerComponent;
22073 Component_1.ComponentService.register(MarkerComponent);
22074 Object.defineProperty(exports, "__esModule", { value: true });
22075 exports.default = MarkerComponent;
22077 },{"../../Component":207,"../../Geo":210,"../../Render":213,"rbush":24,"rxjs/Observable":28,"rxjs/Subject":33,"rxjs/add/observable/combineLatest":37,"rxjs/add/operator/distinctUntilChanged":53,"rxjs/add/operator/filter":56,"rxjs/add/operator/map":60,"rxjs/add/operator/publishReplay":67,"rxjs/add/operator/scan":68,"rxjs/add/operator/switchMap":73,"three":157,"underscore":158}],244:[function(require,module,exports){
22079 var __extends = (this && this.__extends) || function (d, b) {
22080 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
22081 function __() { this.constructor = d; }
22082 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
22084 var THREE = require("three");
22085 var Component_1 = require("../../Component");
22086 var SimpleMarker = (function (_super) {
22087 __extends(SimpleMarker, _super);
22088 function SimpleMarker(latLonAlt, markerOptions) {
22089 _super.call(this, latLonAlt, markerOptions);
22090 this._circleToRayAngle = 2.0;
22091 this._simpleMarkerStyle = markerOptions.style;
22093 SimpleMarker.prototype.createGeometry = function () {
22095 var cone = new THREE.Mesh(this._markerGeometry(radius, 16, 8), new THREE.MeshBasicMaterial({
22096 color: this._stringToRBG(this._simpleMarkerStyle.color),
22098 opacity: this._simpleMarkerStyle.opacity,
22099 shading: THREE.SmoothShading,
22102 var ball = new THREE.Mesh(new THREE.SphereGeometry(radius / 2, 16, 8), new THREE.MeshBasicMaterial({
22103 color: this._stringToRBG(this._simpleMarkerStyle.ballColor),
22105 opacity: this._simpleMarkerStyle.ballOpacity,
22106 shading: THREE.SmoothShading,
22109 ball.position.z = this._markerHeight(radius);
22110 var group = new THREE.Object3D();
22115 SimpleMarker.prototype._markerHeight = function (radius) {
22116 var t = Math.tan(Math.PI - this._circleToRayAngle);
22117 return radius * Math.sqrt(1 + t * t);
22119 SimpleMarker.prototype._markerGeometry = function (radius, widthSegments, heightSegments) {
22120 var geometry = new THREE.Geometry();
22121 widthSegments = Math.max(3, Math.floor(widthSegments) || 8);
22122 heightSegments = Math.max(2, Math.floor(heightSegments) || 6);
22123 var height = this._markerHeight(radius);
22125 for (var y = 0; y <= heightSegments; ++y) {
22126 var verticesRow = [];
22127 for (var x = 0; x <= widthSegments; ++x) {
22128 var u = x / widthSegments * Math.PI * 2;
22129 var v = y / heightSegments * Math.PI;
22131 if (v < this._circleToRayAngle) {
22135 var t = Math.tan(v - this._circleToRayAngle);
22136 r = radius * Math.sqrt(1 + t * t);
22138 var vertex = new THREE.Vector3();
22139 vertex.x = r * Math.cos(u) * Math.sin(v);
22140 vertex.y = r * Math.sin(u) * Math.sin(v);
22141 vertex.z = r * Math.cos(v) + height;
22142 geometry.vertices.push(vertex);
22143 verticesRow.push(geometry.vertices.length - 1);
22145 vertices.push(verticesRow);
22147 for (var y = 0; y < heightSegments; ++y) {
22148 for (var x = 0; x < widthSegments; ++x) {
22149 var v1 = vertices[y][x + 1];
22150 var v2 = vertices[y][x];
22151 var v3 = vertices[y + 1][x];
22152 var v4 = vertices[y + 1][x + 1];
22153 var n1 = geometry.vertices[v1].clone().normalize();
22154 var n2 = geometry.vertices[v2].clone().normalize();
22155 var n3 = geometry.vertices[v3].clone().normalize();
22156 var n4 = geometry.vertices[v4].clone().normalize();
22157 geometry.faces.push(new THREE.Face3(v1, v2, v4, [n1, n2, n4]));
22158 geometry.faces.push(new THREE.Face3(v2, v3, v4, [n2.clone(), n3, n4.clone()]));
22161 geometry.computeFaceNormals();
22162 geometry.boundingSphere = new THREE.Sphere(new THREE.Vector3(), radius + height);
22165 SimpleMarker.prototype._stringToRBG = function (str) {
22167 for (var i = 0; i < str.length; i++) {
22168 ret = str.charCodeAt(i) + ((ret << 5) - ret);
22172 return SimpleMarker;
22173 }(Component_1.Marker));
22174 exports.SimpleMarker = SimpleMarker;
22175 Object.defineProperty(exports, "__esModule", { value: true });
22176 exports.default = SimpleMarker;
22178 },{"../../Component":207,"three":157}],245:[function(require,module,exports){
22179 /// <reference path="../../../typings/index.d.ts" />
22181 var __extends = (this && this.__extends) || function (d, b) {
22182 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
22183 function __() { this.constructor = d; }
22184 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
22186 var Observable_1 = require("rxjs/Observable");
22187 var Subject_1 = require("rxjs/Subject");
22188 require("rxjs/add/observable/combineLatest");
22189 require("rxjs/add/observable/of");
22190 require("rxjs/add/operator/concat");
22191 require("rxjs/add/operator/distinctUntilChanged");
22192 require("rxjs/add/operator/filter");
22193 require("rxjs/add/operator/finally");
22194 require("rxjs/add/operator/first");
22195 require("rxjs/add/operator/map");
22196 require("rxjs/add/operator/publishReplay");
22197 require("rxjs/add/operator/scan");
22198 require("rxjs/add/operator/share");
22199 require("rxjs/add/operator/switchMap");
22200 require("rxjs/add/operator/takeUntil");
22201 require("rxjs/add/operator/withLatestFrom");
22202 var Component_1 = require("../../Component");
22203 var Edge_1 = require("../../Edge");
22205 * @class SequenceComponent
22206 * @classdesc Component showing navigation arrows for sequence directions
22207 * as well as playing button. Exposes an API to start and stop play.
22209 var SequenceComponent = (function (_super) {
22210 __extends(SequenceComponent, _super);
22211 function SequenceComponent(name, container, navigator) {
22212 _super.call(this, name, container, navigator);
22213 this._nodesAhead = 5;
22214 this._configurationOperation$ = new Subject_1.Subject();
22215 this._sequenceDOMRenderer = new Component_1.SequenceDOMRenderer(container.element);
22216 this._sequenceDOMInteraction = new Component_1.SequenceDOMInteraction();
22217 this._containerWidth$ = new Subject_1.Subject();
22218 this._hoveredKeySubject$ = new Subject_1.Subject();
22219 this._hoveredKey$ = this._hoveredKeySubject$.share();
22220 this._edgeStatus$ = this._navigator.stateService.currentNode$
22221 .switchMap(function (node) {
22222 return node.sequenceEdges$;
22227 Object.defineProperty(SequenceComponent.prototype, "hoveredKey$", {
22229 * Get hovered key observable.
22231 * @description An observable emitting the key of the node for the direction
22232 * arrow that is being hovered. When the mouse leaves a direction arrow null
22235 * @returns {Observable<string>}
22238 return this._hoveredKey$;
22246 * @fires PlayerComponent#playingchanged
22248 SequenceComponent.prototype.play = function () {
22249 this.configure({ playing: true });
22254 * @fires PlayerComponent#playingchanged
22256 SequenceComponent.prototype.stop = function () {
22257 this.configure({ playing: false });
22260 * Set the direction to follow when playing.
22262 * @param {EdgeDirection} direction - The direction that will be followed when playing.
22264 SequenceComponent.prototype.setDirection = function (direction) {
22265 this.configure({ direction: direction });
22268 * Set highlight key.
22270 * @description The arrow pointing towards the node corresponding to the
22271 * highlight key will be highlighted.
22273 * @param {string} highlightKey Key of node to be highlighted if existing.
22275 SequenceComponent.prototype.setHighlightKey = function (highlightKey) {
22276 this.configure({ highlightKey: highlightKey });
22279 * Set max width of container element.
22281 * @description Set max width of the container element holding
22282 * the sequence navigation elements. If the min width is larger than the
22283 * max width the min width value will be used.
22285 * The container element is automatically resized when the resize
22286 * method on the Viewer class is called.
22288 * @param {number} minWidth
22290 SequenceComponent.prototype.setMaxWidth = function (maxWidth) {
22291 this.configure({ maxWidth: maxWidth });
22294 * Set min width of container element.
22296 * @description Set min width of the container element holding
22297 * the sequence navigation elements. If the min width is larger than the
22298 * max width the min width value will be used.
22300 * The container element is automatically resized when the resize
22301 * method on the Viewer class is called.
22303 * @param {number} minWidth
22305 SequenceComponent.prototype.setMinWidth = function (minWidth) {
22306 this.configure({ minWidth: minWidth });
22309 * Set the value indicating whether the sequence UI elements should be visible.
22311 * @param {boolean} visible
22313 SequenceComponent.prototype.setVisible = function (visible) {
22314 this.configure({ visible: visible });
22317 SequenceComponent.prototype.resize = function () {
22319 this._configuration$
22321 .map(function (configuration) {
22322 return _this._sequenceDOMRenderer.getContainerWidth(_this._container.element, configuration);
22324 .subscribe(function (containerWidth) {
22325 _this._containerWidth$.next(containerWidth);
22328 SequenceComponent.prototype._activate = function () {
22330 this._renderSubscription = Observable_1.Observable
22331 .combineLatest(this._edgeStatus$, this._configuration$, this._containerWidth$)
22332 .map(function (ec) {
22333 var edgeStatus = ec[0];
22334 var configuration = ec[1];
22335 var containerWidth = ec[2];
22336 var vNode = _this._sequenceDOMRenderer
22337 .render(edgeStatus, configuration, containerWidth, _this, _this._sequenceDOMInteraction, _this._navigator);
22338 return { name: _this._name, vnode: vNode };
22340 .subscribe(this._container.domRenderer.render$);
22341 this._containerWidthSubscription = this._configuration$
22342 .distinctUntilChanged(function (value1, value2) {
22343 return value1[0] === value2[0] && value1[1] === value2[1];
22344 }, function (configuration) {
22345 return [configuration.minWidth, configuration.maxWidth];
22347 .map(function (configuration) {
22348 return _this._sequenceDOMRenderer.getContainerWidth(_this._container.element, configuration);
22350 .subscribe(this._containerWidth$);
22351 this._configurationSubscription = this._configurationOperation$
22352 .scan(function (configuration, operation) {
22353 return operation(configuration);
22354 }, { playing: false })
22355 .finally(function () {
22356 if (_this._playingSubscription != null) {
22357 _this._navigator.stateService.cutNodes();
22362 this._configuration$
22363 .map(function (newConfiguration) {
22364 return function (configuration) {
22365 if (newConfiguration.playing !== configuration.playing) {
22366 _this._navigator.stateService.cutNodes();
22367 if (newConfiguration.playing) {
22374 configuration.playing = newConfiguration.playing;
22375 return configuration;
22378 .subscribe(this._configurationOperation$);
22379 this._stopSubscription = this._configuration$
22380 .switchMap(function (configuration) {
22381 var edgeStatus$ = configuration.playing ?
22382 _this._edgeStatus$ :
22383 Observable_1.Observable.empty();
22384 var edgeDirection$ = Observable_1.Observable
22385 .of(configuration.direction);
22386 return Observable_1.Observable
22387 .combineLatest(edgeStatus$, edgeDirection$);
22389 .map(function (ne) {
22390 var edgeStatus = ne[0];
22391 var direction = ne[1];
22392 if (!edgeStatus.cached) {
22395 for (var _i = 0, _a = edgeStatus.edges; _i < _a.length; _i++) {
22397 if (edge.data.direction === direction) {
22403 .filter(function (hasEdge) {
22406 .map(function (hasEdge) {
22407 return { playing: false };
22409 .subscribe(this._configurationSubject$);
22410 this._hoveredKeySubscription = this._sequenceDOMInteraction.mouseEnterDirection$
22411 .switchMap(function (direction) {
22412 return _this._edgeStatus$
22413 .map(function (edgeStatus) {
22414 for (var _i = 0, _a = edgeStatus.edges; _i < _a.length; _i++) {
22416 if (edge.data.direction === direction) {
22422 .takeUntil(_this._sequenceDOMInteraction.mouseLeaveDirection$)
22423 .concat(Observable_1.Observable.of(null));
22425 .distinctUntilChanged()
22426 .subscribe(this._hoveredKeySubject$);
22428 SequenceComponent.prototype._deactivate = function () {
22429 this._stopSubscription.unsubscribe();
22430 this._renderSubscription.unsubscribe();
22431 this._configurationSubscription.unsubscribe();
22432 this._containerWidthSubscription.unsubscribe();
22433 this._hoveredKeySubscription.unsubscribe();
22436 SequenceComponent.prototype._getDefaultConfiguration = function () {
22438 direction: Edge_1.EdgeDirection.Next,
22445 SequenceComponent.prototype._play = function () {
22447 this._playingSubscription = this._navigator.stateService.currentState$
22448 .filter(function (frame) {
22449 return frame.state.nodesAhead < _this._nodesAhead;
22451 .map(function (frame) {
22452 return frame.state.lastNode;
22454 .distinctUntilChanged(undefined, function (lastNode) {
22455 return lastNode.key;
22457 .withLatestFrom(this._configuration$, function (lastNode, configuration) {
22458 return [lastNode, configuration.direction];
22460 .switchMap(function (nd) {
22461 return ([Edge_1.EdgeDirection.Next, Edge_1.EdgeDirection.Prev].indexOf(nd[1]) > -1 ?
22462 nd[0].sequenceEdges$ :
22463 nd[0].spatialEdges$)
22464 .filter(function (status) {
22465 return status.cached;
22467 .zip(Observable_1.Observable.of(nd[1]), function (status, direction) {
22468 return [status, direction];
22471 .map(function (ed) {
22472 var direction = ed[1];
22473 for (var _i = 0, _a = ed[0].edges; _i < _a.length; _i++) {
22475 if (edge.data.direction === direction) {
22481 .filter(function (key) {
22482 return key != null;
22484 .switchMap(function (key) {
22485 return _this._navigator.graphService.cacheNode$(key);
22487 .subscribe(function (node) {
22488 _this._navigator.stateService.appendNodes([node]);
22489 }, function (error) {
22490 console.error(error);
22493 this.fire(SequenceComponent.playingchanged, true);
22495 SequenceComponent.prototype._stop = function () {
22496 this._playingSubscription.unsubscribe();
22497 this._playingSubscription = null;
22498 this.fire(SequenceComponent.playingchanged, false);
22501 SequenceComponent.componentName = "sequence";
22503 * Event fired when playing starts or stops.
22505 * @event PlayerComponent#playingchanged
22506 * @type {boolean} Indicates whether the player is playing.
22508 SequenceComponent.playingchanged = "playingchanged";
22509 return SequenceComponent;
22510 }(Component_1.Component));
22511 exports.SequenceComponent = SequenceComponent;
22512 Component_1.ComponentService.register(SequenceComponent);
22513 Object.defineProperty(exports, "__esModule", { value: true });
22514 exports.default = SequenceComponent;
22516 },{"../../Component":207,"../../Edge":208,"rxjs/Observable":28,"rxjs/Subject":33,"rxjs/add/observable/combineLatest":37,"rxjs/add/observable/of":44,"rxjs/add/operator/concat":50,"rxjs/add/operator/distinctUntilChanged":53,"rxjs/add/operator/filter":56,"rxjs/add/operator/finally":57,"rxjs/add/operator/first":58,"rxjs/add/operator/map":60,"rxjs/add/operator/publishReplay":67,"rxjs/add/operator/scan":68,"rxjs/add/operator/share":69,"rxjs/add/operator/switchMap":73,"rxjs/add/operator/takeUntil":75,"rxjs/add/operator/withLatestFrom":76}],246:[function(require,module,exports){
22518 var Subject_1 = require("rxjs/Subject");
22519 var SequenceDOMInteraction = (function () {
22520 function SequenceDOMInteraction() {
22521 this._mouseEnterDirection$ = new Subject_1.Subject();
22522 this._mouseLeaveDirection$ = new Subject_1.Subject();
22524 Object.defineProperty(SequenceDOMInteraction.prototype, "mouseEnterDirection$", {
22526 return this._mouseEnterDirection$;
22531 Object.defineProperty(SequenceDOMInteraction.prototype, "mouseLeaveDirection$", {
22533 return this._mouseLeaveDirection$;
22538 return SequenceDOMInteraction;
22540 exports.SequenceDOMInteraction = SequenceDOMInteraction;
22541 Object.defineProperty(exports, "__esModule", { value: true });
22542 exports.default = SequenceDOMInteraction;
22544 },{"rxjs/Subject":33}],247:[function(require,module,exports){
22545 /// <reference path="../../../typings/index.d.ts" />
22547 var vd = require("virtual-dom");
22548 var Edge_1 = require("../../Edge");
22549 var SequenceDOMRenderer = (function () {
22550 function SequenceDOMRenderer(element) {
22551 this._minThresholdWidth = 320;
22552 this._maxThresholdWidth = 1480;
22553 this._minThresholdHeight = 240;
22554 this._maxThresholdHeight = 820;
22556 SequenceDOMRenderer.prototype.render = function (edgeStatus, configuration, containerWidth, component, interaction, navigator) {
22557 if (configuration.visible === false) {
22558 return vd.h("div.SequenceContainer", {}, []);
22560 var nextKey = null;
22561 var prevKey = null;
22562 for (var _i = 0, _a = edgeStatus.edges; _i < _a.length; _i++) {
22564 if (edge.data.direction === Edge_1.EdgeDirection.Next) {
22567 if (edge.data.direction === Edge_1.EdgeDirection.Prev) {
22571 var playingButton = this._createPlayingButton(nextKey, prevKey, configuration, component);
22572 var arrows = this._createSequenceArrows(nextKey, prevKey, configuration, interaction, navigator);
22573 var containerProperties = {
22574 style: { height: (0.27 * containerWidth) + "px", width: containerWidth + "px" },
22576 return vd.h("div.SequenceContainer", containerProperties, arrows.concat([playingButton]));
22578 SequenceDOMRenderer.prototype.getContainerWidth = function (element, configuration) {
22579 var elementWidth = element.offsetWidth;
22580 var elementHeight = element.offsetHeight;
22581 var minWidth = configuration.minWidth;
22582 var maxWidth = configuration.maxWidth;
22583 if (maxWidth < minWidth) {
22584 maxWidth = minWidth;
22586 var relativeWidth = (elementWidth - this._minThresholdWidth) / (this._maxThresholdWidth - this._minThresholdWidth);
22587 var relativeHeight = (elementHeight - this._minThresholdHeight) / (this._maxThresholdHeight - this._minThresholdHeight);
22588 var coeff = Math.max(0, Math.min(1, Math.min(relativeWidth, relativeHeight)));
22589 return minWidth + coeff * (maxWidth - minWidth);
22591 SequenceDOMRenderer.prototype._createPlayingButton = function (nextKey, prevKey, configuration, component) {
22592 var canPlay = configuration.direction === Edge_1.EdgeDirection.Next && nextKey != null ||
22593 configuration.direction === Edge_1.EdgeDirection.Prev && prevKey != null;
22594 var onclick = configuration.playing ?
22595 function (e) { component.stop(); } :
22596 canPlay ? function (e) { component.play(); } : null;
22597 var buttonProperties = {
22601 var iconClass = configuration.playing ?
22603 canPlay ? "Play" : "PlayDisabled";
22604 var icon = vd.h("div.SequenceComponentIcon", { className: iconClass }, []);
22605 var buttonClass = canPlay ? "SequencePlay" : "SequencePlayDisabled";
22606 return vd.h("div." + buttonClass, buttonProperties, [icon]);
22608 SequenceDOMRenderer.prototype._createSequenceArrows = function (nextKey, prevKey, configuration, interaction, navigator) {
22609 var nextProperties = {
22610 onclick: nextKey != null ?
22612 navigator.moveDir$(Edge_1.EdgeDirection.Next)
22613 .subscribe(function (node) { return; }, function (error) { console.error(error); });
22616 onmouseenter: function (e) { interaction.mouseEnterDirection$.next(Edge_1.EdgeDirection.Next); },
22617 onmouseleave: function (e) { interaction.mouseLeaveDirection$.next(Edge_1.EdgeDirection.Next); },
22620 var prevProperties = {
22621 onclick: prevKey != null ?
22623 navigator.moveDir$(Edge_1.EdgeDirection.Prev)
22624 .subscribe(function (node) { return; }, function (error) { console.error(error); });
22627 onmouseenter: function (e) { interaction.mouseEnterDirection$.next(Edge_1.EdgeDirection.Prev); },
22628 onmouseleave: function (e) { interaction.mouseLeaveDirection$.next(Edge_1.EdgeDirection.Prev); },
22631 var nextClass = this._getStepClassName(Edge_1.EdgeDirection.Next, nextKey, configuration.highlightKey);
22632 var prevClass = this._getStepClassName(Edge_1.EdgeDirection.Prev, prevKey, configuration.highlightKey);
22633 var nextIcon = vd.h("div.SequenceComponentIcon", []);
22634 var prevIcon = vd.h("div.SequenceComponentIcon", []);
22636 vd.h("div." + nextClass, nextProperties, [nextIcon]),
22637 vd.h("div." + prevClass, prevProperties, [prevIcon]),
22640 SequenceDOMRenderer.prototype._getStepClassName = function (direction, key, highlightKey) {
22641 var className = direction === Edge_1.EdgeDirection.Next ?
22642 "SequenceStepNext" :
22643 "SequenceStepPrev";
22645 className += "Disabled";
22648 if (highlightKey === key) {
22649 className += "Highlight";
22654 return SequenceDOMRenderer;
22656 exports.SequenceDOMRenderer = SequenceDOMRenderer;
22657 Object.defineProperty(exports, "__esModule", { value: true });
22658 exports.default = SequenceDOMRenderer;
22660 },{"../../Edge":208,"virtual-dom":163}],248:[function(require,module,exports){
22662 var GeometryTagError_1 = require("./error/GeometryTagError");
22663 exports.GeometryTagError = GeometryTagError_1.GeometryTagError;
22664 var PointGeometry_1 = require("./geometry/PointGeometry");
22665 exports.PointGeometry = PointGeometry_1.PointGeometry;
22666 var RectGeometry_1 = require("./geometry/RectGeometry");
22667 exports.RectGeometry = RectGeometry_1.RectGeometry;
22668 var PolygonGeometry_1 = require("./geometry/PolygonGeometry");
22669 exports.PolygonGeometry = PolygonGeometry_1.PolygonGeometry;
22670 var OutlineTag_1 = require("./tag/OutlineTag");
22671 exports.OutlineTag = OutlineTag_1.OutlineTag;
22672 var SpotTag_1 = require("./tag/SpotTag");
22673 exports.SpotTag = SpotTag_1.SpotTag;
22674 var Alignment_1 = require("./tag/Alignment");
22675 exports.Alignment = Alignment_1.Alignment;
22676 var TagComponent_1 = require("./TagComponent");
22677 exports.TagComponent = TagComponent_1.TagComponent;
22679 },{"./TagComponent":249,"./error/GeometryTagError":255,"./geometry/PointGeometry":257,"./geometry/PolygonGeometry":258,"./geometry/RectGeometry":259,"./tag/Alignment":261,"./tag/OutlineTag":264,"./tag/SpotTag":267}],249:[function(require,module,exports){
22680 /// <reference path="../../../typings/index.d.ts" />
22682 var __extends = (this && this.__extends) || function (d, b) {
22683 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
22684 function __() { this.constructor = d; }
22685 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
22687 var THREE = require("three");
22688 var Observable_1 = require("rxjs/Observable");
22689 var Subject_1 = require("rxjs/Subject");
22690 require("rxjs/add/observable/combineLatest");
22691 require("rxjs/add/observable/empty");
22692 require("rxjs/add/observable/from");
22693 require("rxjs/add/observable/merge");
22694 require("rxjs/add/observable/of");
22695 require("rxjs/add/operator/combineLatest");
22696 require("rxjs/add/operator/concat");
22697 require("rxjs/add/operator/distinctUntilChanged");
22698 require("rxjs/add/operator/do");
22699 require("rxjs/add/operator/filter");
22700 require("rxjs/add/operator/map");
22701 require("rxjs/add/operator/merge");
22702 require("rxjs/add/operator/mergeMap");
22703 require("rxjs/add/operator/publishReplay");
22704 require("rxjs/add/operator/scan");
22705 require("rxjs/add/operator/share");
22706 require("rxjs/add/operator/skip");
22707 require("rxjs/add/operator/skipUntil");
22708 require("rxjs/add/operator/startWith");
22709 require("rxjs/add/operator/switchMap");
22710 require("rxjs/add/operator/take");
22711 require("rxjs/add/operator/takeUntil");
22712 require("rxjs/add/operator/withLatestFrom");
22713 var Component_1 = require("../../Component");
22714 var Render_1 = require("../../Render");
22716 * @class TagComponent
22717 * @classdesc Component for showing and editing tags with different geometries.
22719 var TagComponent = (function (_super) {
22720 __extends(TagComponent, _super);
22721 function TagComponent(name, container, navigator) {
22723 _super.call(this, name, container, navigator);
22724 this._tagDomRenderer = new Component_1.TagDOMRenderer();
22725 this._tagSet = new Component_1.TagSet();
22726 this._tagCreator = new Component_1.TagCreator();
22727 this._tagGlRendererOperation$ = new Subject_1.Subject();
22728 this._tagGlRenderer$ = this._tagGlRendererOperation$
22729 .startWith(function (renderer) {
22732 .scan(function (renderer, operation) {
22733 return operation(renderer);
22734 }, new Component_1.TagGLRenderer());
22735 this._tags$ = this._tagSet.tagData$
22736 .map(function (tagData) {
22738 // ensure that tags are always rendered in the same order
22739 // to avoid hover tracking problems on first resize.
22740 for (var _i = 0, _a = Object.keys(tagData).sort(); _i < _a.length; _i++) {
22742 tags.push(tagData[key]);
22747 this._renderTags$ = this.tags$
22748 .withLatestFrom(this._navigator.stateService.currentTransform$)
22749 .map(function (args) {
22750 var tags = args[0];
22751 var transform = args[1];
22752 var renderTags = tags
22753 .map(function (tag) {
22754 if (tag instanceof Component_1.OutlineTag) {
22755 return new Component_1.OutlineRenderTag(tag, transform);
22757 else if (tag instanceof Component_1.SpotTag) {
22758 return new Component_1.SpotRenderTag(tag, transform);
22760 throw new Error("Tag type not supported");
22765 this._tagChanged$ = this._tags$
22766 .switchMap(function (tags) {
22767 return Observable_1.Observable
22769 .mergeMap(function (tag) {
22770 return Observable_1.Observable
22771 .merge(tag.changed$, tag.geometryChanged$);
22775 this._renderTagGLChanged$ = this._renderTags$
22776 .switchMap(function (tags) {
22777 return Observable_1.Observable
22779 .mergeMap(function (tag) {
22780 return tag.glObjectsChanged$;
22784 this._tagInterationInitiated$ = this._renderTags$
22785 .switchMap(function (tags) {
22786 return Observable_1.Observable
22788 .mergeMap(function (tag) {
22789 return tag.interact$
22790 .map(function (interaction) {
22791 return interaction.tag.id;
22796 this._tagInteractionAbort$ = Observable_1.Observable
22797 .merge(this._container.mouseService.mouseUp$, this._container.mouseService.mouseLeave$)
22798 .map(function (e) {
22802 this._activeTag$ = this._renderTags$
22803 .switchMap(function (tags) {
22804 return Observable_1.Observable
22806 .mergeMap(function (tag) {
22807 return tag.interact$;
22810 .merge(this._tagInteractionAbort$
22812 return { offsetX: 0, offsetY: 0, operation: Component_1.TagOperation.None, tag: null };
22815 this._createGeometryChanged$ = this._tagCreator.tag$
22816 .switchMap(function (tag) {
22817 return tag != null ?
22818 tag.geometryChanged$ :
22819 Observable_1.Observable.empty();
22822 this._tagCreated$ = this._tagCreator.tag$
22823 .switchMap(function (tag) {
22824 return tag != null ?
22826 Observable_1.Observable.empty();
22829 this._vertexGeometryCreated$ = this._tagCreated$
22830 .map(function (tag) {
22831 return tag.geometry;
22834 this._pointGeometryCreated$ = new Subject_1.Subject();
22835 this._geometryCreated$ = Observable_1.Observable
22836 .merge(this._vertexGeometryCreated$, this._pointGeometryCreated$)
22838 this._basicClick$ = this._container.mouseService.staticClick$
22839 .withLatestFrom(this._container.renderService.renderCamera$, this._navigator.stateService.currentTransform$, function (event, renderCamera, transform) {
22840 return [event, renderCamera, transform];
22842 .map(function (ert) {
22843 var event = ert[0];
22844 var camera = ert[1];
22845 var transform = ert[2];
22846 var basic = _this._mouseEventToBasic(event, _this._container.element, camera, transform);
22850 this._validBasicClick$ = this._basicClick$
22851 .filter(function (basic) {
22854 return 0 <= x && x <= 1 && 0 <= y && y <= 1;
22857 this._creatingConfiguration$ = this._configuration$
22858 .distinctUntilChanged(function (c1, c2) {
22859 return c1.creating === c2.creating && c1.createType === c2.createType;
22860 }, function (configuration) {
22862 createColor: configuration.createColor,
22863 createType: configuration.createType,
22864 creating: configuration.creating,
22869 this._creating$ = this._creatingConfiguration$
22870 .map(function (configuration) {
22871 return configuration.creating;
22876 .subscribe(function (creating) {
22877 _this.fire(TagComponent.creatingchanged, creating);
22880 Object.defineProperty(TagComponent.prototype, "tags$", {
22882 * Get tags observable.
22884 * @description An observable emitting every time the items in the
22885 * tag array changes.
22887 * @returns {Observable<Tag[]>}
22890 return this._tags$;
22895 Object.defineProperty(TagComponent.prototype, "geometryCreated$", {
22897 * Get geometry created observable.
22899 * @description An observable emitting every time a geometry
22900 * has been created.
22902 * @returns {Observable<Geometry>}
22905 return this._geometryCreated$;
22911 * Set the tags to display.
22913 * @param {Tag[]} tags - The tags.
22915 TagComponent.prototype.setTags = function (tags) {
22916 this._tagSet.set$.next(tags);
22919 * Configure the component to enter create mode for
22920 * creating a geometry of a certain type.
22922 * @description Supported geometry types are: rect
22924 * @param {string} geometryType - String specifying the geometry type.
22926 TagComponent.prototype.startCreate = function (geometryType) {
22927 this.configure({ createType: geometryType, creating: true });
22930 * Configure the component to leave create mode.
22932 * @description A non completed geometry will be removed.
22934 TagComponent.prototype.stopCreate = function () {
22935 this.configure({ createType: null, creating: false });
22937 TagComponent.prototype._activate = function () {
22939 this._geometryCreatedEventSubscription = this._geometryCreated$
22940 .subscribe(function (geometry) {
22941 _this.fire(TagComponent.geometrycreated, geometry);
22943 this._tagsChangedEventSubscription = this._tags$
22944 .subscribe(function (tags) {
22945 _this.fire(TagComponent.tagschanged, tags);
22947 var nodeChanged$ = this.configuration$
22948 .switchMap(function (configuration) {
22949 return configuration.creating ?
22950 _this._navigator.stateService.currentNode$
22953 .map(function (n) { return null; }) :
22954 Observable_1.Observable.empty();
22956 var tagAborted$ = this._tagCreator.tag$
22957 .switchMap(function (tag) {
22958 return tag != null ?
22960 .map(function (t) { return null; }) :
22961 Observable_1.Observable.empty();
22963 var tagCreated$ = this._tagCreated$
22964 .map(function (t) { return null; });
22965 var pointGeometryCreated$ = this._pointGeometryCreated$
22966 .map(function (p) { return null; });
22967 this._stopCreateSubscription = Observable_1.Observable
22968 .merge(nodeChanged$, tagAborted$, tagCreated$, pointGeometryCreated$)
22969 .subscribe(function () { _this.stopCreate(); });
22970 this._creatorConfigurationSubscription = this._configuration$
22971 .subscribe(this._tagCreator.configuration$);
22972 this._createSubscription = this._creatingConfiguration$
22973 .switchMap(function (configuration) {
22974 return configuration.creating &&
22975 configuration.createType === "rect" ||
22976 configuration.createType === "polygon" ?
22977 _this._validBasicClick$.take(1) :
22978 Observable_1.Observable.empty();
22980 .subscribe(this._tagCreator.create$);
22981 this._createPointSubscription = this._creatingConfiguration$
22982 .switchMap(function (configuration) {
22983 return configuration.creating &&
22984 configuration.createType === "point" ?
22985 _this._validBasicClick$.take(1) :
22986 Observable_1.Observable.empty();
22988 .map(function (basic) {
22989 return new Component_1.PointGeometry(basic);
22991 .subscribe(this._pointGeometryCreated$);
22992 this._setCreateVertexSubscription = Observable_1.Observable
22993 .combineLatest(this._container.mouseService.mouseMove$, this._tagCreator.tag$, this._container.renderService.renderCamera$)
22994 .filter(function (etr) {
22995 return etr[1] != null;
22997 .withLatestFrom(this._navigator.stateService.currentTransform$, function (etr, transform) {
22998 return [etr[0], etr[1], etr[2], transform];
23000 .subscribe(function (etrt) {
23001 var event = etrt[0];
23003 var camera = etrt[2];
23004 var transform = etrt[3];
23005 var basic = _this._mouseEventToBasic(event, _this._container.element, camera, transform);
23006 if (tag.geometry instanceof Component_1.RectGeometry) {
23007 tag.geometry.setVertex2d(3, basic, transform);
23009 else if (tag.geometry instanceof Component_1.PolygonGeometry) {
23010 tag.geometry.setVertex2d(tag.geometry.polygon.length - 2, basic, transform);
23013 this._addPointSubscription = this._creatingConfiguration$
23014 .switchMap(function (configuration) {
23015 var createType = configuration.createType;
23016 return configuration.creating &&
23017 (createType === "rect" || createType === "polygon") ?
23018 _this._basicClick$.skipUntil(_this._validBasicClick$).skip(1) :
23019 Observable_1.Observable.empty();
23021 .withLatestFrom(this._tagCreator.tag$, function (basic, tag) {
23022 return [basic, tag];
23024 .subscribe(function (bt) {
23027 tag.addPoint(basic);
23029 this._deleteCreatedSubscription = this._creating$
23030 .subscribe(function (creating) {
23031 _this._tagCreator.delete$.next(null);
23033 this._setGLCreateTagSubscription = Observable_1.Observable
23034 .merge(this._tagCreator.tag$, this._createGeometryChanged$)
23035 .withLatestFrom(this._navigator.stateService.currentTransform$, function (tag, transform) {
23036 return [tag, transform];
23038 .map(function (tt) {
23039 return function (renderer) {
23041 var transform = tt[1];
23043 renderer.removeCreateTag();
23046 renderer.setCreateTag(tag, transform);
23051 .subscribe(this._tagGlRendererOperation$);
23052 this._claimMouseSubscription = this._tagInterationInitiated$
23053 .switchMap(function (id) {
23054 return _this._container.mouseService.mouseMove$
23055 .takeUntil(_this._tagInteractionAbort$)
23058 .subscribe(function (e) {
23059 _this._container.mouseService.claimMouse(_this._name, 1);
23061 this._mouseDragSubscription = this._activeTag$
23062 .withLatestFrom(this._container.mouseService.mouseMove$, function (a, e) {
23065 .switchMap(function (args) {
23066 var activeTag = args[0];
23067 var mouseMove = args[1];
23068 if (activeTag.operation === Component_1.TagOperation.None) {
23069 return Observable_1.Observable.empty();
23071 var mouseDrag$ = Observable_1.Observable
23073 .concat(_this._container.mouseService.filtered$(_this._name, _this._container.mouseService.mouseDrag$));
23074 return Observable_1.Observable
23075 .combineLatest(mouseDrag$, _this._container.renderService.renderCamera$)
23076 .withLatestFrom(Observable_1.Observable.of(activeTag), _this._navigator.stateService.currentTransform$, function (ec, a, t) {
23077 return [ec[0], ec[1], a, t];
23080 .subscribe(function (args) {
23081 var mouseEvent = args[0];
23082 var renderCamera = args[1];
23083 var activeTag = args[2];
23084 var transform = args[3];
23085 if (activeTag.operation === Component_1.TagOperation.None) {
23088 var basic = _this._mouseEventToBasic(mouseEvent, _this._container.element, renderCamera, transform, activeTag.offsetX, activeTag.offsetY);
23089 if (activeTag.operation === Component_1.TagOperation.Centroid) {
23090 activeTag.tag.geometry.setCentroid2d(basic, transform);
23092 else if (activeTag.operation === Component_1.TagOperation.Vertex) {
23093 var vertexGeometry = activeTag.tag.geometry;
23094 vertexGeometry.setVertex2d(activeTag.vertexIndex, basic, transform);
23097 this._unclaimMouseSubscription = this._container.mouseService
23098 .filtered$(this._name, this._container.mouseService.mouseDragEnd$)
23099 .subscribe(function (e) {
23100 _this._container.mouseService.unclaimMouse(_this._name);
23102 this._setTagsSubscription = this._renderTags$
23103 .map(function (tags) {
23104 return function (renderer) {
23105 renderer.setTags(tags);
23109 .subscribe(this._tagGlRendererOperation$);
23110 this._updateGLTagSubscription = this._renderTagGLChanged$
23111 .map(function (tag) {
23112 return function (renderer) {
23113 renderer.updateTag(tag);
23117 .subscribe(this._tagGlRendererOperation$);
23118 this._setNeedsRenderSubscription = this._tagChanged$
23119 .map(function (tag) {
23120 return function (renderer) {
23121 renderer.setNeedsRender();
23125 .subscribe(this._tagGlRendererOperation$);
23126 this._domSubscription = this._renderTags$
23128 .do(function (tags) {
23129 _this._container.domRenderer.render$.next({
23131 vnode: _this._tagDomRenderer.clear(),
23134 .combineLatest(this._container.renderService.renderCamera$, this._container.spriteService.spriteAtlas$, this._tagChanged$.startWith(null), this._tagCreator.tag$.merge(this._createGeometryChanged$).startWith(null), this._configuration$, function (renderTags, rc, atlas, tag, ct, c) {
23135 return [rc, atlas, renderTags, tag, ct, c];
23137 .withLatestFrom(this._navigator.stateService.currentTransform$, function (args, transform) {
23138 return [args[0], args[1], args[2], args[3], args[4], args[5], transform];
23140 .map(function (args) {
23143 vnode: _this._tagDomRenderer.render(args[2], args[4], args[1], args[0].perspective, args[6], args[5]),
23146 .subscribe(this._container.domRenderer.render$);
23147 this._glSubscription = this._navigator.stateService.currentState$
23148 .withLatestFrom(this._tagGlRenderer$, function (frame, renderer) {
23149 return [frame, renderer];
23151 .map(function (fr) {
23153 var renderer = fr[1];
23158 needsRender: renderer.needsRender,
23159 render: renderer.render.bind(renderer),
23160 stage: Render_1.GLRenderStage.Foreground,
23164 .subscribe(this._container.glRenderer.render$);
23166 TagComponent.prototype._deactivate = function () {
23167 this._tagGlRendererOperation$
23168 .next(function (renderer) {
23169 renderer.dispose();
23172 this._tagSet.set$.next([]);
23173 this._tagCreator.delete$.next(null);
23174 this._claimMouseSubscription.unsubscribe();
23175 this._mouseDragSubscription.unsubscribe();
23176 this._unclaimMouseSubscription.unsubscribe();
23177 this._setTagsSubscription.unsubscribe();
23178 this._updateGLTagSubscription.unsubscribe();
23179 this._setNeedsRenderSubscription.unsubscribe();
23180 this._stopCreateSubscription.unsubscribe();
23181 this._creatorConfigurationSubscription.unsubscribe();
23182 this._createSubscription.unsubscribe();
23183 this._createPointSubscription.unsubscribe();
23184 this._setCreateVertexSubscription.unsubscribe();
23185 this._addPointSubscription.unsubscribe();
23186 this._deleteCreatedSubscription.unsubscribe();
23187 this._setGLCreateTagSubscription.unsubscribe();
23188 this._domSubscription.unsubscribe();
23189 this._glSubscription.unsubscribe();
23190 this._geometryCreatedEventSubscription.unsubscribe();
23191 this._tagsChangedEventSubscription.unsubscribe();
23193 TagComponent.prototype._getDefaultConfiguration = function () {
23195 createColor: 0xFFFFFF,
23199 TagComponent.prototype._mouseEventToBasic = function (event, element, camera, transform, offsetX, offsetY) {
23200 offsetX = offsetX != null ? offsetX : 0;
23201 offsetY = offsetY != null ? offsetY : 0;
23202 var clientRect = element.getBoundingClientRect();
23203 var canvasX = event.clientX - clientRect.left - offsetX;
23204 var canvasY = event.clientY - clientRect.top - offsetY;
23205 var projectedX = 2 * canvasX / element.offsetWidth - 1;
23206 var projectedY = 1 - 2 * canvasY / element.offsetHeight;
23207 var unprojected = new THREE.Vector3(projectedX, projectedY, 1).unproject(camera.perspective);
23208 var basic = transform.projectBasic(unprojected.toArray());
23212 TagComponent.componentName = "tag";
23214 * Event fired when creation starts and stops.
23216 * @event TagComponent#creatingchanged
23217 * @type {boolean} Indicates whether the component is creating a tag.
23219 TagComponent.creatingchanged = "creatingchanged";
23221 * Event fired when a geometry has been created.
23223 * @event TagComponent#geometrycreated
23224 * @type {Geometry} Created geometry.
23226 TagComponent.geometrycreated = "geometrycreated";
23228 * Event fired when the tags collection has changed.
23230 * @event TagComponent#tagschanged
23231 * @type {Array<Tag>} Current array of tags.
23233 TagComponent.tagschanged = "tagschanged";
23234 return TagComponent;
23235 }(Component_1.Component));
23236 exports.TagComponent = TagComponent;
23237 Component_1.ComponentService.register(TagComponent);
23238 Object.defineProperty(exports, "__esModule", { value: true });
23239 exports.default = TagComponent;
23241 },{"../../Component":207,"../../Render":213,"rxjs/Observable":28,"rxjs/Subject":33,"rxjs/add/observable/combineLatest":37,"rxjs/add/observable/empty":39,"rxjs/add/observable/from":40,"rxjs/add/observable/merge":43,"rxjs/add/observable/of":44,"rxjs/add/operator/combineLatest":49,"rxjs/add/operator/concat":50,"rxjs/add/operator/distinctUntilChanged":53,"rxjs/add/operator/do":54,"rxjs/add/operator/filter":56,"rxjs/add/operator/map":60,"rxjs/add/operator/merge":61,"rxjs/add/operator/mergeMap":63,"rxjs/add/operator/publishReplay":67,"rxjs/add/operator/scan":68,"rxjs/add/operator/share":69,"rxjs/add/operator/skip":70,"rxjs/add/operator/skipUntil":71,"rxjs/add/operator/startWith":72,"rxjs/add/operator/switchMap":73,"rxjs/add/operator/take":74,"rxjs/add/operator/takeUntil":75,"rxjs/add/operator/withLatestFrom":76,"three":157}],250:[function(require,module,exports){
23243 var Subject_1 = require("rxjs/Subject");
23244 require("rxjs/add/operator/map");
23245 require("rxjs/add/operator/scan");
23246 require("rxjs/add/operator/share");
23247 require("rxjs/add/operator/withLatestFrom");
23248 var Component_1 = require("../../Component");
23249 var TagCreator = (function () {
23250 function TagCreator() {
23251 this._tagOperation$ = new Subject_1.Subject();
23252 this._create$ = new Subject_1.Subject();
23253 this._delete$ = new Subject_1.Subject();
23254 this._configuration$ = new Subject_1.Subject();
23255 this._tag$ = this._tagOperation$
23256 .scan(function (tag, operation) {
23257 return operation(tag);
23261 .withLatestFrom(this._configuration$, function (coordinate, type) {
23262 return [coordinate, type];
23264 .map(function (ct) {
23265 return function (tag) {
23266 var coordinate = ct[0];
23267 var configuration = ct[1];
23268 if (configuration.createType === "rect") {
23269 var geometry = new Component_1.RectGeometry([
23275 return new Component_1.OutlineCreateTag(geometry, { color: configuration.createColor });
23277 else if (configuration.createType === "polygon") {
23278 var geometry = new Component_1.PolygonGeometry([
23279 [coordinate[0], coordinate[1]],
23280 [coordinate[0], coordinate[1]],
23281 [coordinate[0], coordinate[1]],
23283 return new Component_1.OutlineCreateTag(geometry, { color: configuration.createColor });
23288 .subscribe(this._tagOperation$);
23291 return function (tag) {
23295 .subscribe(this._tagOperation$);
23297 Object.defineProperty(TagCreator.prototype, "create$", {
23299 return this._create$;
23304 Object.defineProperty(TagCreator.prototype, "delete$", {
23306 return this._delete$;
23311 Object.defineProperty(TagCreator.prototype, "configuration$", {
23313 return this._configuration$;
23318 Object.defineProperty(TagCreator.prototype, "tag$", {
23327 exports.TagCreator = TagCreator;
23328 Object.defineProperty(exports, "__esModule", { value: true });
23329 exports.default = TagCreator;
23331 },{"../../Component":207,"rxjs/Subject":33,"rxjs/add/operator/map":60,"rxjs/add/operator/scan":68,"rxjs/add/operator/share":69,"rxjs/add/operator/withLatestFrom":76}],251:[function(require,module,exports){
23332 /// <reference path="../../../typings/index.d.ts" />
23334 var THREE = require("three");
23335 var vd = require("virtual-dom");
23336 var TagDOMRenderer = (function () {
23337 function TagDOMRenderer() {
23339 TagDOMRenderer.prototype.render = function (tags, createTag, atlas, camera, transform, configuration) {
23340 var matrixWorldInverse = new THREE.Matrix4().getInverse(camera.matrixWorld);
23341 var projectionMatrix = camera.projectionMatrix;
23343 for (var _i = 0, tags_1 = tags; _i < tags_1.length; _i++) {
23344 var tag = tags_1[_i];
23345 vNodes = vNodes.concat(tag.getDOMObjects(atlas, matrixWorldInverse, projectionMatrix));
23347 if (createTag != null) {
23348 vNodes = vNodes.concat(createTag.getDOMObjects(transform, matrixWorldInverse, projectionMatrix));
23352 "pointer-events": configuration.creating ? "all" : "none",
23355 return vd.h("div.TagContainer", properties, vNodes);
23357 TagDOMRenderer.prototype.clear = function () {
23358 return vd.h("div", {}, []);
23360 return TagDOMRenderer;
23362 exports.TagDOMRenderer = TagDOMRenderer;
23364 },{"three":157,"virtual-dom":163}],252:[function(require,module,exports){
23365 /// <reference path="../../../typings/index.d.ts" />
23367 var THREE = require("three");
23368 var TagGLRenderer = (function () {
23369 function TagGLRenderer() {
23370 this._scene = new THREE.Scene();
23372 this._createTag = null;
23373 this._needsRender = false;
23375 Object.defineProperty(TagGLRenderer.prototype, "needsRender", {
23377 return this._needsRender;
23382 TagGLRenderer.prototype.render = function (perspectiveCamera, renderer) {
23383 renderer.render(this._scene, perspectiveCamera);
23384 this._needsRender = false;
23386 TagGLRenderer.prototype.setCreateTag = function (tag, transform) {
23387 this._disposeCreateTag();
23388 this._addCreateTag(tag, transform);
23389 this._needsRender = true;
23391 TagGLRenderer.prototype.removeCreateTag = function () {
23392 this._disposeCreateTag();
23393 this._needsRender = true;
23395 TagGLRenderer.prototype.setTags = function (tags) {
23396 this._disposeTags();
23397 for (var _i = 0, tags_1 = tags; _i < tags_1.length; _i++) {
23398 var tag = tags_1[_i];
23401 this._needsRender = true;
23403 TagGLRenderer.prototype.updateTag = function (tag) {
23404 for (var _i = 0, _a = this._tags[tag.tag.id][1]; _i < _a.length; _i++) {
23405 var object3d = _a[_i];
23406 this._scene.remove(object3d);
23410 TagGLRenderer.prototype.setNeedsRender = function () {
23411 this._needsRender = true;
23413 TagGLRenderer.prototype.dispose = function () {
23414 this._disposeTags();
23415 this._disposeCreateTag();
23416 this._needsRender = false;
23418 TagGLRenderer.prototype._addTag = function (tag) {
23419 var objects = tag.glObjects;
23420 this._tags[tag.tag.id] = [tag, []];
23421 for (var _i = 0, objects_1 = objects; _i < objects_1.length; _i++) {
23422 var object = objects_1[_i];
23423 this._tags[tag.tag.id][1].push(object);
23424 this._scene.add(object);
23427 TagGLRenderer.prototype._addCreateTag = function (tag, transform) {
23428 var object = tag.getGLObject(transform);
23429 this._createTag = object;
23430 this._scene.add(object);
23432 TagGLRenderer.prototype._disposeTags = function () {
23433 for (var _i = 0, _a = Object.keys(this._tags); _i < _a.length; _i++) {
23435 for (var _b = 0, _c = this._tags[id][1]; _b < _c.length; _b++) {
23436 var object = _c[_b];
23437 this._scene.remove(object);
23439 this._tags[id][0].dispose();
23440 delete this._tags[id];
23443 TagGLRenderer.prototype._disposeCreateTag = function () {
23444 if (this._createTag == null) {
23447 var mesh = this._createTag;
23448 this._scene.remove(mesh);
23449 mesh.geometry.dispose();
23450 mesh.material.dispose();
23451 this._createTag = null;
23453 return TagGLRenderer;
23455 exports.TagGLRenderer = TagGLRenderer;
23457 },{"three":157}],253:[function(require,module,exports){
23459 (function (TagOperation) {
23460 TagOperation[TagOperation["None"] = 0] = "None";
23461 TagOperation[TagOperation["Centroid"] = 1] = "Centroid";
23462 TagOperation[TagOperation["Vertex"] = 2] = "Vertex";
23463 })(exports.TagOperation || (exports.TagOperation = {}));
23464 var TagOperation = exports.TagOperation;
23465 Object.defineProperty(exports, "__esModule", { value: true });
23466 exports.default = TagOperation;
23468 },{}],254:[function(require,module,exports){
23470 var Subject_1 = require("rxjs/Subject");
23471 require("rxjs/add/operator/map");
23472 require("rxjs/add/operator/scan");
23473 require("rxjs/add/operator/share");
23474 var TagSet = (function () {
23475 function TagSet() {
23476 this._tagDataOperation$ = new Subject_1.Subject();
23477 this._set$ = new Subject_1.Subject();
23478 this._tagData$ = this._tagDataOperation$
23479 .scan(function (tagData, operation) {
23480 return operation(tagData);
23484 .map(function (tags) {
23485 return function (tagData) {
23486 for (var _i = 0, _a = Object.keys(tagData); _i < _a.length; _i++) {
23488 delete tagData[key];
23490 for (var _b = 0, tags_1 = tags; _b < tags_1.length; _b++) {
23491 var tag = tags_1[_b];
23492 tagData[tag.id] = tag;
23497 .subscribe(this._tagDataOperation$);
23499 Object.defineProperty(TagSet.prototype, "tagData$", {
23501 return this._tagData$;
23506 Object.defineProperty(TagSet.prototype, "set$", {
23515 exports.TagSet = TagSet;
23516 Object.defineProperty(exports, "__esModule", { value: true });
23517 exports.default = TagSet;
23519 },{"rxjs/Subject":33,"rxjs/add/operator/map":60,"rxjs/add/operator/scan":68,"rxjs/add/operator/share":69}],255:[function(require,module,exports){
23521 var __extends = (this && this.__extends) || function (d, b) {
23522 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
23523 function __() { this.constructor = d; }
23524 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
23526 var Error_1 = require("../../../Error");
23527 var GeometryTagError = (function (_super) {
23528 __extends(GeometryTagError, _super);
23529 function GeometryTagError(message) {
23531 this.name = "GeometryTagError";
23532 this.message = message != null ? message : "The provided geometry value is incorrect";
23534 return GeometryTagError;
23535 }(Error_1.MapillaryError));
23536 exports.GeometryTagError = GeometryTagError;
23537 Object.defineProperty(exports, "__esModule", { value: true });
23538 exports.default = Error_1.MapillaryError;
23540 },{"../../../Error":209}],256:[function(require,module,exports){
23542 var Subject_1 = require("rxjs/Subject");
23546 * @classdesc Represents a geometry.
23548 var Geometry = (function () {
23550 * Create a geometry.
23554 function Geometry() {
23555 this._notifyChanged$ = new Subject_1.Subject();
23557 Object.defineProperty(Geometry.prototype, "changed$", {
23559 * Get changed observable.
23561 * @description Emits the geometry itself every time the geometry
23564 * @returns {Observable<Geometry>} Observable emitting the geometry instance.
23567 return this._notifyChanged$;
23574 exports.Geometry = Geometry;
23575 Object.defineProperty(exports, "__esModule", { value: true });
23576 exports.default = Geometry;
23578 },{"rxjs/Subject":33}],257:[function(require,module,exports){
23580 var __extends = (this && this.__extends) || function (d, b) {
23581 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
23582 function __() { this.constructor = d; }
23583 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
23585 var Component_1 = require("../../../Component");
23587 * @class PointGeometry
23588 * @classdesc Represents a point geometry in the basic coordinate system.
23590 var PointGeometry = (function (_super) {
23591 __extends(PointGeometry, _super);
23593 * Create a point geometry.
23596 * @param {Array<number>} point - An array representing the basic coordinates of
23599 * @throws {GeometryTagError} Point coordinates must be valid basic coordinates.
23601 function PointGeometry(point) {
23605 if (x < 0 || x > 1 || y < 0 || y > 1) {
23606 throw new Component_1.GeometryTagError("Basic coordinates must be on the interval [0, 1].");
23608 this._point = point.slice();
23610 Object.defineProperty(PointGeometry.prototype, "point", {
23612 * Get point property.
23613 * @returns {Array<number>} Array representing the basic coordinates of the point.
23616 return this._point;
23622 * Get the 3D world coordinates for the centroid of the point, i.e. the 3D
23623 * world coordinates of the point itself.
23625 * @param {Transform} transform - The transform of the node related to the point.
23626 * @returns {Array<number>} 3D world coordinates representing the centroid.
23628 PointGeometry.prototype.getCentroid3d = function (transform) {
23629 return transform.unprojectBasic(this._point, 200);
23632 * Set the centroid of the point, i.e. the point coordinates.
23634 * @param {Array<number>} value - The new value of the centroid.
23635 * @param {Transform} transform - The transform of the node related to the point.
23637 PointGeometry.prototype.setCentroid2d = function (value, transform) {
23639 Math.max(0, Math.min(1, value[0])),
23640 Math.max(0, Math.min(1, value[1])),
23642 this._point[0] = changed[0];
23643 this._point[1] = changed[1];
23644 this._notifyChanged$.next(this);
23646 return PointGeometry;
23647 }(Component_1.Geometry));
23648 exports.PointGeometry = PointGeometry;
23650 },{"../../../Component":207}],258:[function(require,module,exports){
23652 var __extends = (this && this.__extends) || function (d, b) {
23653 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
23654 function __() { this.constructor = d; }
23655 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
23657 var Component_1 = require("../../../Component");
23659 * @class PolygonGeometry
23660 * @classdesc Represents a polygon geometry in the basic coordinate system.
23662 var PolygonGeometry = (function (_super) {
23663 __extends(PolygonGeometry, _super);
23665 * Create a polygon geometry.
23668 * @param {Array<Array<number>>} polygon - Array of polygon vertices. Must be closed.
23669 * @param {Array<Array<Array<number>>>} [holes] - Array of arrays of hole vertices.
23670 * Each array of holes vertices must be closed.
23672 * @throws {GeometryTagError} Polygon coordinates must be valid basic coordinates.
23674 function PolygonGeometry(polygon, holes) {
23676 var polygonLength = polygon.length;
23677 if (polygonLength < 3) {
23678 throw new Component_1.GeometryTagError("A polygon must have three or more positions.");
23680 if (polygon[0][0] !== polygon[polygonLength - 1][0] ||
23681 polygon[0][1] !== polygon[polygonLength - 1][1]) {
23682 throw new Component_1.GeometryTagError("First and last positions must be equivalent.");
23684 this._polygon = [];
23685 for (var _i = 0, polygon_1 = polygon; _i < polygon_1.length; _i++) {
23686 var vertex = polygon_1[_i];
23687 if (vertex[0] < 0 || vertex[0] > 1 ||
23688 vertex[1] < 0 || vertex[1] > 1) {
23689 throw new Component_1.GeometryTagError("Basic coordinates of polygon must be on the interval [0, 1].");
23691 this._polygon.push(vertex.slice());
23694 if (holes == null) {
23697 for (var i = 0; i < holes.length; i++) {
23698 var hole = holes[i];
23699 var holeLength = hole.length;
23700 if (holeLength < 3) {
23701 throw new Component_1.GeometryTagError("A polygon hole must have three or more positions.");
23703 if (hole[0][0] !== hole[holeLength - 1][0] ||
23704 hole[0][1] !== hole[holeLength - 1][1]) {
23705 throw new Component_1.GeometryTagError("First and last positions of hole must be equivalent.");
23707 this._holes.push([]);
23708 for (var _a = 0, hole_1 = hole; _a < hole_1.length; _a++) {
23709 var vertex = hole_1[_a];
23710 if (vertex[0] < 0 || vertex[0] > 1 ||
23711 vertex[1] < 0 || vertex[1] > 1) {
23712 throw new Component_1.GeometryTagError("Basic coordinates of hole must be on the interval [0, 1].");
23714 this._holes[i].push(vertex.slice());
23718 Object.defineProperty(PolygonGeometry.prototype, "polygon", {
23720 * Get polygon property.
23721 * @returns {Array<Array<number>>} Closed 2d polygon.
23724 return this._polygon;
23729 Object.defineProperty(PolygonGeometry.prototype, "holes", {
23731 * Get holes property.
23732 * @returns {Array<Array<Array<number>>>} Holes of 2d polygon.
23735 return this._holes;
23741 * Add a vertex to the polygon by appending it after the last vertex.
23743 * @param {Array<number>} vertex - Vertex to add.
23745 PolygonGeometry.prototype.addVertex2d = function (vertex) {
23747 Math.max(0, Math.min(1, vertex[0])),
23748 Math.max(0, Math.min(1, vertex[1])),
23750 this._polygon.splice(this._polygon.length - 1, 0, clamped);
23751 this._notifyChanged$.next(this);
23754 * Remove a vertex from the polygon.
23756 * @param {number} index - The index of the vertex to remove.
23758 PolygonGeometry.prototype.removeVertex2d = function (index) {
23760 index >= this._polygon.length ||
23761 this._polygon.length < 4) {
23762 throw new Component_1.GeometryTagError("Index for removed vertex must be valid.");
23764 if (index > 0 && index < this._polygon.length - 1) {
23765 this._polygon.splice(index, 1);
23768 this._polygon.splice(0, 1);
23769 this._polygon.pop();
23770 var closing = this._polygon[0].slice();
23771 this._polygon.push(closing);
23773 this._notifyChanged$.next(this);
23776 PolygonGeometry.prototype.setVertex2d = function (index, value, transform) {
23778 Math.max(0, Math.min(1, value[0])),
23779 Math.max(0, Math.min(1, value[1])),
23781 if (index === 0 || index === this._polygon.length - 1) {
23782 this._polygon[0] = changed.slice();
23783 this._polygon[this._polygon.length - 1] = changed.slice();
23786 this._polygon[index] = changed.slice();
23788 this._notifyChanged$.next(this);
23791 PolygonGeometry.prototype.setCentroid2d = function (value, transform) {
23792 var xs = this._polygon.map(function (point) { return point[0]; });
23793 var ys = this._polygon.map(function (point) { return point[1]; });
23794 var minX = Math.min.apply(Math, xs);
23795 var maxX = Math.max.apply(Math, xs);
23796 var minY = Math.min.apply(Math, ys);
23797 var maxY = Math.max.apply(Math, ys);
23798 var centroid = this._getCentroid2d();
23799 var minTranslationX = -minX;
23800 var maxTranslationX = 1 - maxX;
23801 var minTranslationY = -minY;
23802 var maxTranslationY = 1 - maxY;
23803 var translationX = Math.max(minTranslationX, Math.min(maxTranslationX, value[0] - centroid[0]));
23804 var translationY = Math.max(minTranslationY, Math.min(maxTranslationY, value[1] - centroid[1]));
23805 for (var _i = 0, _a = this._polygon; _i < _a.length; _i++) {
23806 var point = _a[_i];
23807 point[0] += translationX;
23808 point[1] += translationY;
23810 this._notifyChanged$.next(this);
23813 PolygonGeometry.prototype.getPoints3d = function (transform) {
23814 return this.getVertices3d(transform);
23817 PolygonGeometry.prototype.getVertex3d = function (index, transform) {
23818 return transform.unprojectBasic(this._polygon[index], 200);
23821 PolygonGeometry.prototype.getVertices3d = function (transform) {
23822 return this._polygon
23823 .map(function (point) {
23824 return transform.unprojectBasic(point, 200);
23828 * Get a polygon representation of the 3D coordinates for the vertices of each hole
23831 * @param {Transform} transform - The transform of the node related to the geometry.
23832 * @returns {Array<Array<Array<number>>>} Array of hole polygons in 3D world coordinates
23833 * representing the vertices of each hole of the geometry.
23835 PolygonGeometry.prototype.getHoleVertices3d = function (transform) {
23837 for (var _i = 0, _a = this._holes; _i < _a.length; _i++) {
23840 .map(function (point) {
23841 return transform.unprojectBasic(point, 200);
23843 holes3d.push(hole3d);
23848 PolygonGeometry.prototype.getCentroid3d = function (transform) {
23849 var centroid2d = this._getCentroid2d();
23850 return transform.unprojectBasic(centroid2d, 200);
23853 PolygonGeometry.prototype.getTriangles3d = function (transform) {
23854 return this._triangulate(this._polygon, this.getPoints3d(transform), this._holes, this.getHoleVertices3d(transform));
23856 PolygonGeometry.prototype._getCentroid2d = function () {
23857 var polygon = this._polygon;
23861 for (var i = 0; i < polygon.length - 1; i++) {
23862 var xi = polygon[i][0];
23863 var yi = polygon[i][1];
23864 var xi1 = polygon[i + 1][0];
23865 var yi1 = polygon[i + 1][1];
23866 var a = xi * yi1 - xi1 * yi;
23868 centroidX += (xi + xi1) * a;
23869 centroidY += (yi + yi1) * a;
23872 centroidX /= 6 * area;
23873 centroidY /= 6 * area;
23874 return [centroidX, centroidY];
23876 return PolygonGeometry;
23877 }(Component_1.VertexGeometry));
23878 exports.PolygonGeometry = PolygonGeometry;
23879 Object.defineProperty(exports, "__esModule", { value: true });
23880 exports.default = PolygonGeometry;
23882 },{"../../../Component":207}],259:[function(require,module,exports){
23884 var __extends = (this && this.__extends) || function (d, b) {
23885 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
23886 function __() { this.constructor = d; }
23887 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
23889 var Component_1 = require("../../../Component");
23891 * @class RectGeometry
23892 * @classdesc Represents a rectangle geometry in the basic coordinate system.
23894 var RectGeometry = (function (_super) {
23895 __extends(RectGeometry, _super);
23897 * Create a rectangle geometry.
23900 * @param {Array<number>} rect - An array representing the top-left and bottom-right
23901 * corners of the rectangle in basic coordinates. Ordered according to [x0, y0, x1, y1].
23903 * @throws {GeometryTagError} Rectangle coordinates must be valid basic coordinates.
23905 function RectGeometry(rect) {
23907 if (rect[1] > rect[3]) {
23908 throw new Component_1.GeometryTagError("Basic Y coordinates values can not be inverted.");
23910 for (var _i = 0, rect_1 = rect; _i < rect_1.length; _i++) {
23911 var coord = rect_1[_i];
23912 if (coord < 0 || coord > 1) {
23913 throw new Component_1.GeometryTagError("Basic coordinates must be on the interval [0, 1].");
23916 this._rect = rect.slice(0, 4);
23917 if (this._rect[0] > this._rect[2]) {
23918 this._inverted = true;
23921 Object.defineProperty(RectGeometry.prototype, "rect", {
23923 * Get rect property.
23924 * @returns {Array<number>} Array representing the top-left and bottom-right
23925 * corners of the rectangle in basic coordinates.
23934 * Set the value of a vertex in the polygon representation of the rectangle.
23936 * @description The polygon is defined to have the first vertex at the
23937 * bottom-left corner with the rest of the vertices following in clockwise order.
23939 * @param {number} index - The index of the vertex to be set.
23940 * @param {Array<number>} value - The new value of the vertex.
23941 * @param {Transform} transform - The transform of the node related to the rectangle.
23943 RectGeometry.prototype.setVertex2d = function (index, value, transform) {
23944 var original = this._rect.slice();
23946 Math.max(0, Math.min(1, value[0])),
23947 Math.max(0, Math.min(1, value[1])),
23951 rect[0] = changed[0];
23952 rect[1] = original[1];
23953 rect[2] = original[2];
23954 rect[3] = changed[1];
23956 else if (index === 1) {
23957 rect[0] = changed[0];
23958 rect[1] = changed[1];
23959 rect[2] = original[2];
23960 rect[3] = original[3];
23962 else if (index === 2) {
23963 rect[0] = original[0];
23964 rect[1] = changed[1];
23965 rect[2] = changed[0];
23966 rect[3] = original[3];
23968 else if (index === 3) {
23969 rect[0] = original[0];
23970 rect[1] = original[1];
23971 rect[2] = changed[0];
23972 rect[3] = changed[1];
23974 if (transform.gpano) {
23975 var passingBoundaryLeft = index < 2 && changed[0] > 0.75 && original[0] < 0.25 ||
23976 index >= 2 && this._inverted && changed[0] > 0.75 && original[2] < 0.25;
23977 var passingBoundaryRight = index < 2 && this._inverted && changed[0] < 0.25 && original[0] > 0.75 ||
23978 index >= 2 && changed[0] < 0.25 && original[2] > 0.75;
23979 if (passingBoundaryLeft || passingBoundaryRight) {
23980 this._inverted = !this._inverted;
23983 if (rect[0] - original[0] < -0.25) {
23984 rect[0] = original[0];
23986 if (rect[2] - original[2] > 0.25) {
23987 rect[2] = original[2];
23990 if (!this._inverted && rect[0] > rect[2] ||
23991 this._inverted && rect[0] < rect[2]) {
23992 rect[0] = original[0];
23993 rect[2] = original[2];
23997 if (rect[0] > rect[2]) {
23998 rect[0] = original[0];
23999 rect[2] = original[2];
24002 if (rect[1] > rect[3]) {
24003 rect[1] = original[1];
24004 rect[3] = original[3];
24006 this._rect[0] = rect[0];
24007 this._rect[1] = rect[1];
24008 this._rect[2] = rect[2];
24009 this._rect[3] = rect[3];
24010 this._notifyChanged$.next(this);
24013 RectGeometry.prototype.setCentroid2d = function (value, transform) {
24014 var original = this._rect.slice();
24015 var x0 = original[0];
24016 var x1 = this._inverted ? original[2] + 1 : original[2];
24017 var y0 = original[1];
24018 var y1 = original[3];
24019 var centerX = x0 + (x1 - x0) / 2;
24020 var centerY = y0 + (y1 - y0) / 2;
24021 var translationX = 0;
24022 if (transform.gpano != null &&
24023 transform.gpano.CroppedAreaImageWidthPixels === transform.gpano.FullPanoWidthPixels) {
24024 translationX = this._inverted ? value[0] + 1 - centerX : value[0] - centerX;
24027 var minTranslationX = -x0;
24028 var maxTranslationX = 1 - x1;
24029 translationX = Math.max(minTranslationX, Math.min(maxTranslationX, value[0] - centerX));
24031 var minTranslationY = -y0;
24032 var maxTranslationY = 1 - y1;
24033 var translationY = Math.max(minTranslationY, Math.min(maxTranslationY, value[1] - centerY));
24034 this._rect[0] = original[0] + translationX;
24035 this._rect[1] = original[1] + translationY;
24036 this._rect[2] = original[2] + translationX;
24037 this._rect[3] = original[3] + translationY;
24038 if (this._rect[0] < 0) {
24039 this._rect[0] += 1;
24040 this._inverted = !this._inverted;
24042 else if (this._rect[0] > 1) {
24043 this._rect[0] -= 1;
24044 this._inverted = !this._inverted;
24046 if (this._rect[2] < 0) {
24047 this._rect[2] += 1;
24048 this._inverted = !this._inverted;
24050 else if (this._rect[2] > 1) {
24051 this._rect[2] -= 1;
24052 this._inverted = !this._inverted;
24054 this._notifyChanged$.next(this);
24057 * Get the 3D coordinates for the vertices of the rectangle with
24058 * interpolated points along the lines.
24060 * @param {Transform} transform - The transform of the node related to
24062 * @returns {Array<Array<number>>} Polygon array of 3D world coordinates
24063 * representing the rectangle.
24065 RectGeometry.prototype.getPoints3d = function (transform) {
24066 return this._getPoints2d(transform)
24067 .map(function (point) {
24068 return transform.unprojectBasic(point, 200);
24072 * Get a vertex from the polygon representation of the 3D coordinates for the
24073 * vertices of the geometry.
24075 * @description The first vertex represents the bottom-left corner with the rest of
24076 * the vertices following in clockwise order.
24078 * @param {number} index - Vertex index.
24079 * @param {Transform} transform - The transform of the node related to the geometry.
24080 * @returns {Array<Array<number>>} Polygon array of 3D world coordinates representing
24081 * the vertices of the geometry.
24083 RectGeometry.prototype.getVertex3d = function (index, transform) {
24084 return transform.unprojectBasic(this._rectToVertices2d(this._rect)[index], 200);
24087 * Get a polygon representation of the 3D coordinates for the vertices of the rectangle.
24089 * @description The first vertex represents the bottom-left corner with the rest of
24090 * the vertices following in clockwise order.
24092 * @param {Transform} transform - The transform of the node related to the rectangle.
24093 * @returns {Array<Array<number>>} Polygon array of 3D world coordinates representing
24094 * the rectangle vertices.
24096 RectGeometry.prototype.getVertices3d = function (transform) {
24097 return this._rectToVertices2d(this._rect)
24098 .map(function (vertex) {
24099 return transform.unprojectBasic(vertex, 200);
24103 RectGeometry.prototype.getCentroid3d = function (transform) {
24104 var rect = this._rect;
24106 var x1 = this._inverted ? rect[2] + 1 : rect[2];
24109 var centroidX = x0 + (x1 - x0) / 2;
24110 var centroidY = y0 + (y1 - y0) / 2;
24111 return transform.unprojectBasic([centroidX, centroidY], 200);
24114 RectGeometry.prototype.getTriangles3d = function (transform) {
24115 return this._triangulate(this._rectToVertices2d(this._rect), this.getVertices3d(transform));
24118 * Check if a particular bottom-right value is valid according to the current
24119 * rectangle coordinates.
24121 * @param {Array<number>} bottomRight - The bottom-right coordinates to validate
24122 * @returns {boolean} Value indicating whether the provided bottom-right coordinates
24125 RectGeometry.prototype.validate = function (bottomRight) {
24126 var rect = this._rect;
24127 if (!this._inverted && bottomRight[0] < rect[0] ||
24128 bottomRight[0] - rect[2] > 0.25 ||
24129 bottomRight[1] < rect[1]) {
24135 * Get the 2D coordinates for the vertices of the rectangle with
24136 * interpolated points along the lines.
24138 * @param {Transform} transform - The transform of the node related to
24140 * @returns {Array<Array<number>>} Polygon array of 2D basic coordinates
24141 * representing the rectangle.
24143 RectGeometry.prototype._getPoints2d = function (transform) {
24144 var vertices2d = this._rectToVertices2d(this._rect);
24145 var sides = vertices2d.length - 1;
24148 for (var i = 0; i < sides; ++i) {
24149 var startX = vertices2d[i][0];
24150 var startY = vertices2d[i][1];
24151 var endX = vertices2d[i + 1][0];
24152 var endY = vertices2d[i + 1][1];
24153 var intervalX = (endX - startX) / (sections - 1);
24154 var intervalY = (endY - startY) / (sections - 1);
24155 for (var j = 0; j < sections; ++j) {
24157 startX + j * intervalX,
24158 startY + j * intervalY,
24160 points2d.push(point);
24166 * Convert the top-left, bottom-right representation of a rectangle to a polygon
24167 * representation of the vertices starting at the bottom-right corner going
24170 * @param {Array<number>} rect - Top-left, bottom-right representation of a
24172 * @returns {Array<Array<number>>} Polygon representation of the vertices of the
24175 RectGeometry.prototype._rectToVertices2d = function (rect) {
24177 [rect[0], rect[3]],
24178 [rect[0], rect[1]],
24179 [this._inverted ? rect[2] + 1 : rect[2], rect[1]],
24180 [this._inverted ? rect[2] + 1 : rect[2], rect[3]],
24181 [rect[0], rect[3]],
24184 return RectGeometry;
24185 }(Component_1.VertexGeometry));
24186 exports.RectGeometry = RectGeometry;
24187 Object.defineProperty(exports, "__esModule", { value: true });
24188 exports.default = RectGeometry;
24190 },{"../../../Component":207}],260:[function(require,module,exports){
24191 /// <reference path="../../../../typings/index.d.ts" />
24193 var __extends = (this && this.__extends) || function (d, b) {
24194 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
24195 function __() { this.constructor = d; }
24196 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
24198 var earcut = require("earcut");
24199 var Component_1 = require("../../../Component");
24201 * @class VertexGeometry
24203 * @classdesc Represents a vertex geometry.
24205 var VertexGeometry = (function (_super) {
24206 __extends(VertexGeometry, _super);
24208 * Create a vertex geometry.
24212 function VertexGeometry() {
24216 * Triangulates a 2d polygon and returns the triangle
24217 * representation as a flattened array of 3d points.
24219 * @param {Array<Array<number>>} points2d - 2d points of outline to triangulate.
24220 * @param {Array<Array<number>>} points3d - 3d points of outline corresponding to the 2d points.
24221 * @param {Array<Array<Array<number>>>} [holes2d] - 2d points of holes to triangulate.
24222 * @param {Array<Array<Array<number>>>} [holes3d] - 3d points of holes corresponding to the 2d points.
24223 * @returns {Array<number>} Flattened array of 3d points ordered based on the triangles.
24225 VertexGeometry.prototype._triangulate = function (points2d, points3d, holes2d, holes3d) {
24226 var data = [points2d.slice(0, -1)];
24227 for (var _i = 0, _a = holes2d != null ? holes2d : []; _i < _a.length; _i++) {
24228 var hole2d = _a[_i];
24229 data.push(hole2d.slice(0, -1));
24231 var points = points3d.slice(0, -1);
24232 for (var _b = 0, _c = holes3d != null ? holes3d : []; _b < _c.length; _b++) {
24233 var hole3d = _c[_b];
24234 points = points.concat(hole3d.slice(0, -1));
24236 var flattened = earcut.flatten(data);
24237 var indices = earcut(flattened.vertices, flattened.holes, flattened.dimensions);
24238 var triangles = [];
24239 for (var i = 0; i < indices.length; ++i) {
24240 var point = points[indices[i]];
24241 triangles.push(point[0]);
24242 triangles.push(point[1]);
24243 triangles.push(point[2]);
24247 return VertexGeometry;
24248 }(Component_1.Geometry));
24249 exports.VertexGeometry = VertexGeometry;
24250 Object.defineProperty(exports, "__esModule", { value: true });
24251 exports.default = VertexGeometry;
24253 },{"../../../Component":207,"earcut":6}],261:[function(require,module,exports){
24255 (function (Alignment) {
24256 Alignment[Alignment["Center"] = 0] = "Center";
24257 Alignment[Alignment["Outer"] = 1] = "Outer";
24258 })(exports.Alignment || (exports.Alignment = {}));
24259 var Alignment = exports.Alignment;
24260 Object.defineProperty(exports, "__esModule", { value: true });
24261 exports.default = Alignment;
24263 },{}],262:[function(require,module,exports){
24264 /// <reference path="../../../../typings/index.d.ts" />
24266 var THREE = require("three");
24267 var vd = require("virtual-dom");
24268 var Subject_1 = require("rxjs/Subject");
24269 var Component_1 = require("../../../Component");
24270 var OutlineCreateTag = (function () {
24271 function OutlineCreateTag(geometry, options) {
24272 this._geometry = geometry;
24273 this._options = { color: options.color == null ? 0xFFFFFF : options.color };
24274 this._created$ = new Subject_1.Subject();
24275 this._aborted$ = new Subject_1.Subject();
24277 Object.defineProperty(OutlineCreateTag.prototype, "geometry", {
24279 return this._geometry;
24284 Object.defineProperty(OutlineCreateTag.prototype, "created$", {
24286 return this._created$;
24291 Object.defineProperty(OutlineCreateTag.prototype, "aborted$", {
24293 return this._aborted$;
24298 Object.defineProperty(OutlineCreateTag.prototype, "geometryChanged$", {
24301 return this._geometry.changed$
24302 .map(function (geometry) {
24309 OutlineCreateTag.prototype.getGLObject = function (transform) {
24310 var polygon3d = this._geometry.getPoints3d(transform);
24311 var positions = this._getPositions(polygon3d);
24312 var geometry = new THREE.BufferGeometry();
24313 geometry.addAttribute("position", new THREE.BufferAttribute(positions, 3));
24314 var material = new THREE.LineBasicMaterial({
24315 color: this._options.color,
24318 return new THREE.Line(geometry, material);
24320 OutlineCreateTag.prototype.getDOMObjects = function (transform, matrixWorldInverse, projectionMatrix) {
24323 var abort = function (e) {
24324 e.stopPropagation();
24325 _this._aborted$.next(_this);
24327 if (this._geometry instanceof Component_1.RectGeometry) {
24328 var topLeftPoint3d = this._geometry.getVertex3d(1, transform);
24329 var topLeftCameraSpace = this._convertToCameraSpace(topLeftPoint3d, matrixWorldInverse);
24330 if (topLeftCameraSpace.z < 0) {
24331 var centerCanvas = this._projectToCanvas(topLeftCameraSpace, projectionMatrix);
24332 var centerCss = centerCanvas.map(function (coord) { return (100 * coord) + "%"; });
24333 var pointProperties = {
24335 background: "#" + ("000000" + this._options.color.toString(16)).substr(-6),
24336 left: centerCss[0],
24337 position: "absolute",
24341 var completerProperties = {
24343 style: { left: centerCss[0], position: "absolute", top: centerCss[1] },
24345 vNodes.push(vd.h("div.TagInteractor", completerProperties, []));
24346 vNodes.push(vd.h("div.TagVertex", pointProperties, []));
24349 else if (this._geometry instanceof Component_1.PolygonGeometry) {
24350 var polygonGeometry_1 = this._geometry;
24351 var firstVertex3d = this._geometry.getVertex3d(0, transform);
24352 var firstCameraSpace = this._convertToCameraSpace(firstVertex3d, matrixWorldInverse);
24353 if (firstCameraSpace.z < 0) {
24354 var centerCanvas = this._projectToCanvas(firstCameraSpace, projectionMatrix);
24355 var centerCss = centerCanvas.map(function (coord) { return (100 * coord) + "%"; });
24356 var firstOnclick = polygonGeometry_1.polygon.length > 4 ?
24358 e.stopPropagation();
24359 polygonGeometry_1.removeVertex2d(polygonGeometry_1.polygon.length - 2);
24360 _this._created$.next(_this);
24363 var completerProperties = {
24364 onclick: firstOnclick,
24365 style: { left: centerCss[0], position: "absolute", top: centerCss[1] },
24367 var firstClass = polygonGeometry_1.polygon.length > 4 ?
24370 vNodes.push(vd.h("div." + firstClass, completerProperties, []));
24372 if (polygonGeometry_1.polygon.length > 3) {
24373 var lastVertex3d = this._geometry.getVertex3d(polygonGeometry_1.polygon.length - 3, transform);
24374 var lastCameraSpace = this._convertToCameraSpace(lastVertex3d, matrixWorldInverse);
24375 if (lastCameraSpace.z < 0) {
24376 var centerCanvas = this._projectToCanvas(lastCameraSpace, projectionMatrix);
24377 var centerCss = centerCanvas.map(function (coord) { return (100 * coord) + "%"; });
24378 var remove = function (e) {
24379 e.stopPropagation();
24380 polygonGeometry_1.removeVertex2d(polygonGeometry_1.polygon.length - 3);
24382 var completerProperties = {
24384 style: { left: centerCss[0], position: "absolute", top: centerCss[1] },
24386 vNodes.push(vd.h("div.TagInteractor", completerProperties, []));
24389 var vertices3d = this._geometry.getVertices3d(transform);
24390 vertices3d.splice(-2, 2);
24391 for (var _i = 0, vertices3d_1 = vertices3d; _i < vertices3d_1.length; _i++) {
24392 var vertex = vertices3d_1[_i];
24393 var vertexCameraSpace = this._convertToCameraSpace(vertex, matrixWorldInverse);
24394 if (vertexCameraSpace.z < 0) {
24395 var centerCanvas = this._projectToCanvas(vertexCameraSpace, projectionMatrix);
24396 var centerCss = centerCanvas.map(function (coord) { return (100 * coord) + "%"; });
24397 var pointProperties = {
24399 background: "#" + ("000000" + this._options.color.toString(16)).substr(-6),
24400 left: centerCss[0],
24401 position: "absolute",
24405 vNodes.push(vd.h("div.TagVertex", pointProperties, []));
24411 OutlineCreateTag.prototype.addPoint = function (point) {
24412 if (this._geometry instanceof Component_1.RectGeometry) {
24413 var rectGeometry = this._geometry;
24414 if (!rectGeometry.validate(point)) {
24417 this._created$.next(this);
24419 else if (this._geometry instanceof Component_1.PolygonGeometry) {
24420 var polygonGeometry = this._geometry;
24421 polygonGeometry.addVertex2d(point);
24424 OutlineCreateTag.prototype._getPositions = function (polygon3d) {
24425 var length = polygon3d.length;
24426 var positions = new Float32Array(length * 3);
24427 for (var i = 0; i < length; ++i) {
24429 var position = polygon3d[i];
24430 positions[index] = position[0];
24431 positions[index + 1] = position[1];
24432 positions[index + 2] = position[2];
24436 OutlineCreateTag.prototype._projectToCanvas = function (point, projectionMatrix) {
24437 var projected = new THREE.Vector3(point.x, point.y, point.z)
24438 .applyProjection(projectionMatrix);
24439 return [(projected.x + 1) / 2, (-projected.y + 1) / 2];
24441 OutlineCreateTag.prototype._convertToCameraSpace = function (point, matrixWorldInverse) {
24442 return new THREE.Vector3(point[0], point[1], point[2]).applyMatrix4(matrixWorldInverse);
24444 return OutlineCreateTag;
24446 exports.OutlineCreateTag = OutlineCreateTag;
24447 Object.defineProperty(exports, "__esModule", { value: true });
24448 exports.default = OutlineCreateTag;
24450 },{"../../../Component":207,"rxjs/Subject":33,"three":157,"virtual-dom":163}],263:[function(require,module,exports){
24451 /// <reference path="../../../../typings/index.d.ts" />
24453 var __extends = (this && this.__extends) || function (d, b) {
24454 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
24455 function __() { this.constructor = d; }
24456 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
24458 var THREE = require("three");
24459 var vd = require("virtual-dom");
24460 var Component_1 = require("../../../Component");
24461 var Viewer_1 = require("../../../Viewer");
24463 * @class OutlineRenderTag
24464 * @classdesc Tag visualizing the properties of an OutlineTag.
24466 var OutlineRenderTag = (function (_super) {
24467 __extends(OutlineRenderTag, _super);
24468 function OutlineRenderTag(tag, transform) {
24470 _super.call(this, tag, transform);
24471 this._fill = this._tag.fillOpacity > 0 && !transform.gpano ?
24472 this._createFill() :
24474 this._holes = this._tag.lineWidth >= 1 ?
24475 this._createHoles() :
24477 this._outline = this._tag.lineWidth >= 1 ?
24478 this._createOutline() :
24480 this._glObjects = this._createGLObjects();
24481 this._tag.geometry.changed$
24482 .subscribe(function (geometry) {
24483 if (_this._fill != null) {
24484 _this._updateFillGeometry();
24486 if (_this._holes.length > 0) {
24487 _this._updateHoleGeometries();
24489 if (_this._outline != null) {
24490 _this._updateOulineGeometry();
24494 .subscribe(function (changedTag) {
24495 var glObjectsChanged = false;
24496 if (_this._fill == null) {
24497 if (_this._tag.fillOpacity > 0 && !_this._transform.gpano) {
24498 _this._fill = _this._createFill();
24499 glObjectsChanged = true;
24503 _this._updateFillMaterial();
24505 if (_this._outline == null) {
24506 if (_this._tag.lineWidth > 0) {
24507 _this._holes = _this._createHoles();
24508 _this._outline = _this._createOutline();
24509 glObjectsChanged = true;
24513 _this._updateHoleMaterials();
24514 _this._updateOutlineMaterial();
24516 if (glObjectsChanged) {
24517 _this._glObjects = _this._createGLObjects();
24518 _this._glObjectsChanged$.next(_this);
24522 OutlineRenderTag.prototype.dispose = function () {
24523 this._disposeFill();
24524 this._disposeHoles();
24525 this._disposeOutline();
24527 OutlineRenderTag.prototype.getDOMObjects = function (atlas, matrixWorldInverse, projectionMatrix) {
24530 if (this._tag.geometry instanceof Component_1.RectGeometry) {
24531 if (this._tag.icon != null) {
24532 var iconVertex = this._tag.geometry.getVertex3d(this._tag.iconIndex, this._transform);
24533 var iconCameraSpace = this._convertToCameraSpace(iconVertex, matrixWorldInverse);
24534 if (iconCameraSpace.z < 0) {
24535 var interact = function (e) {
24536 _this._interact$.next({ offsetX: 0, offsetY: 0, operation: Component_1.TagOperation.None, tag: _this._tag });
24538 if (atlas.loaded) {
24539 var spriteAlignments = this._getSpriteAlignment(this._tag.iconIndex, this._tag.iconAlignment);
24540 var sprite = atlas.getDOMSprite(this._tag.icon, spriteAlignments[0], spriteAlignments[1]);
24541 var click = function (e) {
24542 e.stopPropagation();
24543 _this._tag.click$.next(_this._tag);
24545 var iconCanvas = this._projectToCanvas(iconCameraSpace, projectionMatrix);
24546 var iconCss = iconCanvas.map(function (coord) { return (100 * coord) + "%"; });
24549 onmousedown: interact,
24552 pointerEvents: "all",
24553 position: "absolute",
24557 vNodes.push(vd.h("div.TagSymbol", properties, [sprite]));
24561 else if (this._tag.text != null) {
24562 var textVertex = this._tag.geometry.getVertex3d(3, this._transform);
24563 var textCameraSpace = this._convertToCameraSpace(textVertex, matrixWorldInverse);
24564 if (textCameraSpace.z < 0) {
24565 var interact = function (e) {
24566 _this._interact$.next({ offsetX: 0, offsetY: 0, operation: Component_1.TagOperation.None, tag: _this._tag });
24568 var labelCanvas = this._projectToCanvas(textCameraSpace, projectionMatrix);
24569 var labelCss = labelCanvas.map(function (coord) { return (100 * coord) + "%"; });
24571 onmousedown: interact,
24573 color: "#" + ("000000" + this._tag.textColor.toString(16)).substr(-6),
24575 pointerEvents: "all",
24576 position: "absolute",
24579 textContent: this._tag.text,
24581 vNodes.push(vd.h("span.TagSymbol", properties, []));
24585 if (!this._tag.editable) {
24588 var lineColor = "#" + ("000000" + this._tag.lineColor.toString(16)).substr(-6);
24589 if (this._tag.geometry instanceof Component_1.RectGeometry) {
24590 var centroid3d = this._tag.geometry.getCentroid3d(this._transform);
24591 var centroidCameraSpace = this._convertToCameraSpace(centroid3d, matrixWorldInverse);
24592 if (centroidCameraSpace.z < 0) {
24593 var interact = this._interact(Component_1.TagOperation.Centroid);
24594 var centerCanvas = this._projectToCanvas(centroidCameraSpace, projectionMatrix);
24595 var centerCss = centerCanvas.map(function (coord) { return (100 * coord) + "%"; });
24597 onmousedown: interact,
24598 style: { background: lineColor, left: centerCss[0], position: "absolute", top: centerCss[1] },
24600 vNodes.push(vd.h("div.TagMover", properties, []));
24603 var vertices3d = this._tag.geometry.getVertices3d(this._transform);
24604 for (var i = 0; i < vertices3d.length - 1; i++) {
24605 var isRectGeometry = this._tag.geometry instanceof Component_1.RectGeometry;
24606 if (isRectGeometry &&
24607 ((this._tag.icon != null && i === this._tag.iconIndex) ||
24608 (this._tag.icon == null && this._tag.text != null && i === 3))) {
24611 var vertexCameraSpace = this._convertToCameraSpace(vertices3d[i], matrixWorldInverse);
24612 if (vertexCameraSpace.z > 0) {
24615 var interact = this._interact(Component_1.TagOperation.Vertex, i);
24616 var vertexCanvas = this._projectToCanvas(vertexCameraSpace, projectionMatrix);
24617 var vertexCss = vertexCanvas.map(function (coord) { return (100 * coord) + "%"; });
24619 onmousedown: interact,
24621 background: lineColor,
24622 left: vertexCss[0],
24623 position: "absolute",
24627 if (isRectGeometry) {
24628 properties.style.cursor = i % 2 === 0 ? "nesw-resize" : "nwse-resize";
24630 vNodes.push(vd.h("div.TagResizer", properties, []));
24631 if (!this._tag.indicateVertices) {
24634 var pointProperties = {
24636 background: lineColor,
24637 left: vertexCss[0],
24638 position: "absolute",
24642 vNodes.push(vd.h("div.TagVertex", pointProperties, []));
24646 OutlineRenderTag.prototype._createFill = function () {
24647 var triangles = this._tag.geometry.getTriangles3d(this._transform);
24648 var positions = new Float32Array(triangles);
24649 var geometry = new THREE.BufferGeometry();
24650 geometry.addAttribute("position", new THREE.BufferAttribute(positions, 3));
24651 geometry.computeBoundingSphere();
24652 var material = new THREE.MeshBasicMaterial({
24653 color: this._tag.fillColor,
24654 opacity: this._tag.fillOpacity,
24655 side: THREE.DoubleSide,
24658 return new THREE.Mesh(geometry, material);
24660 OutlineRenderTag.prototype._createGLObjects = function () {
24661 var glObjects = [];
24662 if (this._fill != null) {
24663 glObjects.push(this._fill);
24665 for (var _i = 0, _a = this._holes; _i < _a.length; _i++) {
24667 glObjects.push(hole);
24669 if (this._outline != null) {
24670 glObjects.push(this._outline);
24674 OutlineRenderTag.prototype._createHoles = function () {
24676 if (this._tag.geometry instanceof Component_1.PolygonGeometry) {
24677 var polygonGeometry = this._tag.geometry;
24678 var holes3d = polygonGeometry.getHoleVertices3d(this._transform);
24679 for (var _i = 0, holes3d_1 = holes3d; _i < holes3d_1.length; _i++) {
24680 var holePoints3d = holes3d_1[_i];
24681 var hole = this._createLine(holePoints3d);
24687 OutlineRenderTag.prototype._createLine = function (points3d) {
24688 var positions = this._getLinePositions(points3d);
24689 var geometry = new THREE.BufferGeometry();
24690 geometry.addAttribute("position", new THREE.BufferAttribute(positions, 3));
24691 geometry.computeBoundingSphere();
24692 var material = new THREE.LineBasicMaterial({
24693 color: this._tag.lineColor,
24694 linewidth: this._tag.lineWidth,
24696 return new THREE.Line(geometry, material);
24698 OutlineRenderTag.prototype._createOutline = function () {
24699 var points3d = this._tag.geometry.getPoints3d(this._transform);
24700 return this._createLine(points3d);
24702 OutlineRenderTag.prototype._disposeFill = function () {
24703 if (this._fill == null) {
24706 this._fill.geometry.dispose();
24707 this._fill.material.dispose();
24710 OutlineRenderTag.prototype._disposeHoles = function () {
24711 for (var _i = 0, _a = this._holes; _i < _a.length; _i++) {
24713 hole.geometry.dispose();
24714 hole.material.dispose();
24718 OutlineRenderTag.prototype._disposeOutline = function () {
24719 if (this._outline == null) {
24722 this._outline.geometry.dispose();
24723 this._outline.material.dispose();
24724 this._outline = null;
24726 OutlineRenderTag.prototype._getLinePositions = function (points3d) {
24727 var length = points3d.length;
24728 var positions = new Float32Array(length * 3);
24729 for (var i = 0; i < length; ++i) {
24731 var position = points3d[i];
24732 positions[index + 0] = position[0];
24733 positions[index + 1] = position[1];
24734 positions[index + 2] = position[2];
24738 OutlineRenderTag.prototype._getSpriteAlignment = function (index, alignment) {
24739 var horizontalAlignment = Viewer_1.SpriteAlignment.Center;
24740 var verticalAlignment = Viewer_1.SpriteAlignment.Center;
24741 if (alignment === Component_1.Alignment.Outer) {
24744 horizontalAlignment = Viewer_1.SpriteAlignment.End;
24745 verticalAlignment = Viewer_1.SpriteAlignment.Start;
24748 horizontalAlignment = Viewer_1.SpriteAlignment.End;
24749 verticalAlignment = Viewer_1.SpriteAlignment.End;
24752 horizontalAlignment = Viewer_1.SpriteAlignment.Start;
24753 verticalAlignment = Viewer_1.SpriteAlignment.End;
24756 horizontalAlignment = Viewer_1.SpriteAlignment.Start;
24757 verticalAlignment = Viewer_1.SpriteAlignment.Start;
24763 return [horizontalAlignment, verticalAlignment];
24765 OutlineRenderTag.prototype._interact = function (operation, vertexIndex) {
24767 return function (e) {
24768 var offsetX = e.offsetX - e.target.offsetWidth / 2;
24769 var offsetY = e.offsetY - e.target.offsetHeight / 2;
24770 _this._interact$.next({
24773 operation: operation,
24775 vertexIndex: vertexIndex,
24779 OutlineRenderTag.prototype._updateFillGeometry = function () {
24780 var triangles = this._tag.geometry.getTriangles3d(this._transform);
24781 var positions = new Float32Array(triangles);
24782 var geometry = this._fill.geometry;
24783 var attribute = geometry.getAttribute("position");
24784 if (attribute.array.length === positions.length) {
24785 attribute.set(positions);
24786 attribute.needsUpdate = true;
24789 geometry.removeAttribute("position");
24790 geometry.addAttribute("position", new THREE.BufferAttribute(positions, 3));
24792 geometry.computeBoundingSphere();
24794 OutlineRenderTag.prototype._updateFillMaterial = function () {
24795 var material = this._fill.material;
24796 material.color = new THREE.Color(this._tag.fillColor);
24797 material.opacity = this._tag.fillOpacity;
24798 material.needsUpdate = true;
24800 OutlineRenderTag.prototype._updateHoleGeometries = function () {
24801 var polygonGeometry = this._tag.geometry;
24802 var holes3d = polygonGeometry.getHoleVertices3d(this._transform);
24803 if (holes3d.length !== this._holes.length) {
24804 throw new Error("Changing the number of holes is not supported.");
24806 for (var i = 0; i < this._holes.length; i++) {
24807 var holePoints3d = holes3d[i];
24808 var hole = this._holes[i];
24809 this._updateLine(hole, holePoints3d);
24812 OutlineRenderTag.prototype._updateHoleMaterials = function () {
24813 for (var _i = 0, _a = this._holes; _i < _a.length; _i++) {
24815 var material = hole.material;
24816 this._updateLineBasicMaterial(material);
24819 OutlineRenderTag.prototype._updateLine = function (line, points3d) {
24820 var positions = this._getLinePositions(points3d);
24821 var geometry = line.geometry;
24822 var attribute = geometry.getAttribute("position");
24823 attribute.set(positions);
24824 attribute.needsUpdate = true;
24825 geometry.computeBoundingSphere();
24827 OutlineRenderTag.prototype._updateOulineGeometry = function () {
24828 var points3d = this._tag.geometry.getPoints3d(this._transform);
24829 this._updateLine(this._outline, points3d);
24831 OutlineRenderTag.prototype._updateOutlineMaterial = function () {
24832 var material = this._outline.material;
24833 this._updateLineBasicMaterial(material);
24835 OutlineRenderTag.prototype._updateLineBasicMaterial = function (material) {
24836 material.color = new THREE.Color(this._tag.lineColor);
24837 material.linewidth = Math.max(this._tag.lineWidth, 1);
24838 material.opacity = this._tag.lineWidth >= 1 ? 1 : 0;
24839 material.transparent = this._tag.lineWidth <= 0;
24840 material.needsUpdate = true;
24842 return OutlineRenderTag;
24843 }(Component_1.RenderTag));
24844 exports.OutlineRenderTag = OutlineRenderTag;
24846 },{"../../../Component":207,"../../../Viewer":216,"three":157,"virtual-dom":163}],264:[function(require,module,exports){
24848 var __extends = (this && this.__extends) || function (d, b) {
24849 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
24850 function __() { this.constructor = d; }
24851 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
24853 var Subject_1 = require("rxjs/Subject");
24854 var Component_1 = require("../../../Component");
24856 * @class OutlineTag
24857 * @classdesc Tag holding properties for visualizing a geometry outline.
24859 var OutlineTag = (function (_super) {
24860 __extends(OutlineTag, _super);
24862 * Create an outline tag.
24866 * @param {string} id
24867 * @param {Geometry} geometry
24868 * @param {IOutlineTagOptions} options - Options defining the visual appearance and
24869 * behavior of the outline tag.
24871 function OutlineTag(id, geometry, options) {
24873 _super.call(this, id, geometry);
24874 this._editable = options.editable == null ? false : options.editable;
24875 this._fillColor = options.fillColor == null ? 0xFFFFFF : options.fillColor;
24876 this._fillOpacity = options.fillOpacity == null ? 0.0 : options.fillOpacity;
24877 this._icon = options.icon === undefined ? null : options.icon;
24878 this._iconAlignment = options.iconAlignment == null ? Component_1.Alignment.Outer : options.iconAlignment;
24879 this._iconIndex = options.iconIndex == null ? 3 : options.iconIndex;
24880 this._indicateVertices = options.indicateVertices == null ? true : options.indicateVertices;
24881 this._lineColor = options.lineColor == null ? 0xFFFFFF : options.lineColor;
24882 this._lineWidth = options.lineWidth == null ? 1 : options.lineWidth;
24883 this._text = options.text === undefined ? null : options.text;
24884 this._textColor = options.textColor == null ? 0xFFFFFF : options.textColor;
24885 this._click$ = new Subject_1.Subject();
24887 .subscribe(function (t) {
24888 _this.fire(OutlineTag.click, _this);
24891 Object.defineProperty(OutlineTag.prototype, "click$", {
24893 * Click observable.
24895 * @description An observable emitting the tag when the icon of the
24896 * tag has been clicked.
24898 * @returns {Observable<Tag>}
24901 return this._click$;
24906 Object.defineProperty(OutlineTag.prototype, "editable", {
24908 * Get editable property.
24909 * @returns {boolean} Value indicating if tag is editable.
24912 return this._editable;
24915 * Set editable property.
24918 * @fires Tag#changed
24920 set: function (value) {
24921 this._editable = value;
24922 this._notifyChanged$.next(this);
24927 Object.defineProperty(OutlineTag.prototype, "fillColor", {
24929 * Get fill color property.
24930 * @returns {number}
24933 return this._fillColor;
24936 * Set fill color property.
24939 * @fires Tag#changed
24941 set: function (value) {
24942 this._fillColor = value;
24943 this._notifyChanged$.next(this);
24948 Object.defineProperty(OutlineTag.prototype, "fillOpacity", {
24950 * Get fill opacity property.
24951 * @returns {number}
24954 return this._fillOpacity;
24957 * Set fill opacity property.
24960 * @fires Tag#changed
24962 set: function (value) {
24963 this._fillOpacity = value;
24964 this._notifyChanged$.next(this);
24969 Object.defineProperty(OutlineTag.prototype, "geometry", {
24971 return this._geometry;
24976 Object.defineProperty(OutlineTag.prototype, "icon", {
24978 * Get icon property.
24979 * @returns {string}
24985 * Set icon property.
24988 * @fires Tag#changed
24990 set: function (value) {
24991 this._icon = value;
24992 this._notifyChanged$.next(this);
24997 Object.defineProperty(OutlineTag.prototype, "iconAlignment", {
24999 * Get icon alignment property.
25000 * @returns {Alignment}
25003 return this._iconAlignment;
25006 * Set icon alignment property.
25007 * @param {Alignment}
25009 * @fires Tag#changed
25011 set: function (value) {
25012 this._iconAlignment = value;
25013 this._notifyChanged$.next(this);
25018 Object.defineProperty(OutlineTag.prototype, "iconIndex", {
25020 * Get icon index property.
25021 * @returns {number}
25024 return this._iconIndex;
25027 * Set icon index property.
25030 * @fires Tag#changed
25032 set: function (value) {
25033 this._iconIndex = value;
25034 this._notifyChanged$.next(this);
25039 Object.defineProperty(OutlineTag.prototype, "indicateVertices", {
25041 * Get indicate vertices property.
25042 * @returns {boolean} Value indicating if vertices should be indicated
25043 * when tag is editable.
25046 return this._indicateVertices;
25049 * Set indicate vertices property.
25052 * @fires Tag#changed
25054 set: function (value) {
25055 this._indicateVertices = value;
25056 this._notifyChanged$.next(this);
25061 Object.defineProperty(OutlineTag.prototype, "lineColor", {
25063 * Get line color property.
25064 * @returns {number}
25067 return this._lineColor;
25070 * Set line color property.
25073 * @fires Tag#changed
25075 set: function (value) {
25076 this._lineColor = value;
25077 this._notifyChanged$.next(this);
25082 Object.defineProperty(OutlineTag.prototype, "lineWidth", {
25084 * Get line width property.
25085 * @returns {number}
25088 return this._lineWidth;
25091 * Set line width property.
25094 * @fires Tag#changed
25096 set: function (value) {
25097 this._lineWidth = value;
25098 this._notifyChanged$.next(this);
25103 Object.defineProperty(OutlineTag.prototype, "text", {
25105 * Get text property.
25106 * @returns {string}
25112 * Set text property.
25115 * @fires Tag#changed
25117 set: function (value) {
25118 this._text = value;
25119 this._notifyChanged$.next(this);
25124 Object.defineProperty(OutlineTag.prototype, "textColor", {
25126 * Get text color property.
25127 * @returns {number}
25130 return this._textColor;
25133 * Set text color property.
25136 * @fires Tag#changed
25138 set: function (value) {
25139 this._textColor = value;
25140 this._notifyChanged$.next(this);
25146 * Set options for tag.
25148 * @description Sets all the option properties provided and keps
25149 * the rest of the values as is.
25151 * @param {IOutlineTagOptions} options - Outline tag options
25153 * @fires {Tag#changed}
25155 OutlineTag.prototype.setOptions = function (options) {
25156 this._editable = options.editable == null ? this._editable : options.editable;
25157 this._icon = options.icon === undefined ? this._icon : options.icon;
25158 this._iconAlignment = options.iconAlignment == null ? this._iconAlignment : options.iconAlignment;
25159 this._iconIndex = options.iconIndex == null ? this._iconIndex : options.iconIndex;
25160 this._indicateVertices = options.indicateVertices == null ? this._indicateVertices : options.indicateVertices;
25161 this._lineColor = options.lineColor == null ? this._lineColor : options.lineColor;
25162 this._lineWidth = options.lineWidth == null ? this._lineWidth : options.lineWidth;
25163 this._fillColor = options.fillColor == null ? this._fillColor : options.fillColor;
25164 this._fillOpacity = options.fillOpacity == null ? this._fillOpacity : options.fillOpacity;
25165 this._text = options.text === undefined ? this._text : options.text;
25166 this._textColor = options.textColor == null ? this._textColor : options.textColor;
25167 this._notifyChanged$.next(this);
25170 * Event fired when the icon of the outline tag is clicked.
25172 * @event OutlineTag#click
25173 * @type {OutlineTag} The tag instance that was clicked.
25175 OutlineTag.click = "click";
25177 }(Component_1.Tag));
25178 exports.OutlineTag = OutlineTag;
25179 Object.defineProperty(exports, "__esModule", { value: true });
25180 exports.default = OutlineTag;
25182 },{"../../../Component":207,"rxjs/Subject":33}],265:[function(require,module,exports){
25183 /// <reference path="../../../../typings/index.d.ts" />
25185 var THREE = require("three");
25186 var Subject_1 = require("rxjs/Subject");
25187 var RenderTag = (function () {
25188 function RenderTag(tag, transform) {
25190 this._transform = transform;
25191 this._glObjects = [];
25192 this._glObjectsChanged$ = new Subject_1.Subject();
25193 this._interact$ = new Subject_1.Subject();
25195 Object.defineProperty(RenderTag.prototype, "glObjects", {
25197 * Get the GL objects for rendering of the tag.
25198 * @return {Array<Object3D>}
25201 return this._glObjects;
25206 Object.defineProperty(RenderTag.prototype, "glObjectsChanged$", {
25208 return this._glObjectsChanged$;
25213 Object.defineProperty(RenderTag.prototype, "interact$", {
25215 return this._interact$;
25220 Object.defineProperty(RenderTag.prototype, "tag", {
25227 RenderTag.prototype._projectToCanvas = function (point3d, projectionMatrix) {
25228 var projected = new THREE.Vector3(point3d.x, point3d.y, point3d.z)
25229 .applyProjection(projectionMatrix);
25230 return [(projected.x + 1) / 2, (-projected.y + 1) / 2];
25232 RenderTag.prototype._convertToCameraSpace = function (point3d, matrixWorldInverse) {
25233 return new THREE.Vector3(point3d[0], point3d[1], point3d[2]).applyMatrix4(matrixWorldInverse);
25237 exports.RenderTag = RenderTag;
25238 Object.defineProperty(exports, "__esModule", { value: true });
25239 exports.default = RenderTag;
25241 },{"rxjs/Subject":33,"three":157}],266:[function(require,module,exports){
25242 /// <reference path="../../../../typings/index.d.ts" />
25244 var __extends = (this && this.__extends) || function (d, b) {
25245 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
25246 function __() { this.constructor = d; }
25247 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
25249 var vd = require("virtual-dom");
25250 var Component_1 = require("../../../Component");
25251 var Viewer_1 = require("../../../Viewer");
25253 * @class SpotRenderTag
25254 * @classdesc Tag visualizing the properties of a SpotTag.
25256 var SpotRenderTag = (function (_super) {
25257 __extends(SpotRenderTag, _super);
25258 function SpotRenderTag() {
25259 _super.apply(this, arguments);
25261 SpotRenderTag.prototype.dispose = function () { return; };
25262 SpotRenderTag.prototype.getDOMObjects = function (atlas, matrixWorldInverse, projectionMatrix) {
25265 var centroid3d = this._tag.geometry.getCentroid3d(this._transform);
25266 var centroidCameraSpace = this._convertToCameraSpace(centroid3d, matrixWorldInverse);
25267 if (centroidCameraSpace.z < 0) {
25268 var centroidCanvas = this._projectToCanvas(centroidCameraSpace, projectionMatrix);
25269 var centroidCss = centroidCanvas.map(function (coord) { return (100 * coord) + "%"; });
25270 var interactNone = function (e) {
25271 _this._interact$.next({ offsetX: 0, offsetY: 0, operation: Component_1.TagOperation.None, tag: _this._tag });
25273 if (this._tag.icon != null) {
25274 if (atlas.loaded) {
25275 var sprite = atlas.getDOMSprite(this._tag.icon, Viewer_1.SpriteAlignment.Center, Viewer_1.SpriteAlignment.End);
25277 onmousedown: interactNone,
25279 bottom: 100 * (1 - centroidCanvas[1]) + "%",
25280 left: centroidCss[0],
25281 pointerEvents: "all",
25282 position: "absolute",
25283 transform: "translate(0px, -8px)",
25286 vNodes.push(vd.h("div", properties, [sprite]));
25289 else if (this._tag.text != null) {
25291 onmousedown: interactNone,
25293 bottom: 100 * (1 - centroidCanvas[1]) + "%",
25294 color: "#" + ("000000" + this._tag.textColor.toString(16)).substr(-6),
25295 left: centroidCss[0],
25296 pointerEvents: "all",
25297 position: "absolute",
25298 transform: "translate(-50%, -7px)",
25300 textContent: this._tag.text,
25302 vNodes.push(vd.h("span.TagSymbol", properties, []));
25304 var interact = this._interact(Component_1.TagOperation.Centroid);
25305 var background = "#" + ("000000" + this._tag.color.toString(16)).substr(-6);
25306 if (this._tag.editable) {
25307 var interactorProperties = {
25308 onmousedown: interact,
25310 background: background,
25311 left: centroidCss[0],
25312 pointerEvents: "all",
25313 position: "absolute",
25314 top: centroidCss[1],
25317 vNodes.push(vd.h("div.TagSpotInteractor", interactorProperties, []));
25319 var pointProperties = {
25321 background: background,
25322 left: centroidCss[0],
25323 position: "absolute",
25324 top: centroidCss[1],
25327 vNodes.push(vd.h("div.TagVertex", pointProperties, []));
25331 SpotRenderTag.prototype._interact = function (operation, vertexIndex) {
25333 return function (e) {
25334 var offsetX = e.offsetX - e.target.offsetWidth / 2;
25335 var offsetY = e.offsetY - e.target.offsetHeight / 2;
25336 _this._interact$.next({
25339 operation: operation,
25341 vertexIndex: vertexIndex,
25345 return SpotRenderTag;
25346 }(Component_1.RenderTag));
25347 exports.SpotRenderTag = SpotRenderTag;
25349 },{"../../../Component":207,"../../../Viewer":216,"virtual-dom":163}],267:[function(require,module,exports){
25351 var __extends = (this && this.__extends) || function (d, b) {
25352 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
25353 function __() { this.constructor = d; }
25354 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
25356 var Component_1 = require("../../../Component");
25359 * @classdesc Tag holding properties for visualizing the centroid of a geometry.
25361 var SpotTag = (function (_super) {
25362 __extends(SpotTag, _super);
25364 * Create a spot tag.
25368 * @param {string} id
25369 * @param {Geometry} geometry
25370 * @param {IOutlineTagOptions} options - Options defining the visual appearance and
25371 * behavior of the spot tag.
25373 function SpotTag(id, geometry, options) {
25374 _super.call(this, id, geometry);
25375 this._color = options.color == null ? 0xFFFFFF : options.color;
25376 this._editable = options.editable == null ? false : options.editable;
25377 this._icon = options.icon === undefined ? null : options.icon;
25378 this._text = options.text === undefined ? null : options.text;
25379 this._textColor = options.textColor == null ? 0xFFFFFF : options.textColor;
25381 Object.defineProperty(SpotTag.prototype, "color", {
25383 * Get color property.
25384 * @returns {number} The color of the spot as a hexagonal number;
25387 return this._color;
25390 * Set color property.
25393 * @fires Tag#changed
25395 set: function (value) {
25396 this._color = value;
25397 this._notifyChanged$.next(this);
25402 Object.defineProperty(SpotTag.prototype, "editable", {
25404 * Get editable property.
25405 * @returns {boolean} Value indicating if tag is editable.
25408 return this._editable;
25411 * Set editable property.
25414 * @fires Tag#changed
25416 set: function (value) {
25417 this._editable = value;
25418 this._notifyChanged$.next(this);
25423 Object.defineProperty(SpotTag.prototype, "icon", {
25425 * Get icon property.
25426 * @returns {string}
25432 * Set icon property.
25435 * @fires Tag#changed
25437 set: function (value) {
25438 this._icon = value;
25439 this._notifyChanged$.next(this);
25444 Object.defineProperty(SpotTag.prototype, "text", {
25446 * Get text property.
25447 * @returns {string}
25453 * Set text property.
25456 * @fires Tag#changed
25458 set: function (value) {
25459 this._text = value;
25460 this._notifyChanged$.next(this);
25465 Object.defineProperty(SpotTag.prototype, "textColor", {
25467 * Get text color property.
25468 * @returns {number}
25471 return this._textColor;
25474 * Set text color property.
25477 * @fires Tag#changed
25479 set: function (value) {
25480 this._textColor = value;
25481 this._notifyChanged$.next(this);
25487 * Set options for tag.
25489 * @description Sets all the option properties provided and keps
25490 * the rest of the values as is.
25492 * @param {ISpotTagOptions} options - Spot tag options
25494 * @fires {Tag#changed}
25496 SpotTag.prototype.setOptions = function (options) {
25497 this._color = options.color == null ? this._color : options.color;
25498 this._editable = options.editable == null ? this._editable : options.editable;
25499 this._icon = options.icon === undefined ? this._icon : options.icon;
25500 this._text = options.text === undefined ? this._text : options.text;
25501 this._textColor = options.textColor == null ? this._textColor : options.textColor;
25502 this._notifyChanged$.next(this);
25505 }(Component_1.Tag));
25506 exports.SpotTag = SpotTag;
25507 Object.defineProperty(exports, "__esModule", { value: true });
25508 exports.default = SpotTag;
25510 },{"../../../Component":207}],268:[function(require,module,exports){
25512 var __extends = (this && this.__extends) || function (d, b) {
25513 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
25514 function __() { this.constructor = d; }
25515 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
25517 var Subject_1 = require("rxjs/Subject");
25518 require("rxjs/add/operator/map");
25519 require("rxjs/add/operator/share");
25520 var Utils_1 = require("../../../Utils");
25524 * @classdesc Abstract class representing the basic functionality of for a tag.
25526 var Tag = (function (_super) {
25527 __extends(Tag, _super);
25532 * @param {string} id
25533 * @param {Geometry} geometry
25535 function Tag(id, geometry) {
25539 this._geometry = geometry;
25540 this._notifyChanged$ = new Subject_1.Subject();
25541 this._notifyChanged$
25542 .subscribe(function (t) {
25543 _this.fire(Tag.changed, _this);
25545 this._geometry.changed$
25546 .subscribe(function (g) {
25547 _this.fire(Tag.geometrychanged, _this);
25550 Object.defineProperty(Tag.prototype, "id", {
25553 * @returns {string}
25561 Object.defineProperty(Tag.prototype, "geometry", {
25563 * Get geometry property.
25564 * @returns {Geometry}
25567 return this._geometry;
25572 Object.defineProperty(Tag.prototype, "changed$", {
25574 * Get changed observable.
25575 * @returns {Observable<Tag>}
25578 return this._notifyChanged$;
25583 Object.defineProperty(Tag.prototype, "geometryChanged$", {
25585 * Get geometry changed observable.
25586 * @returns {Observable<Tag>}
25590 return this._geometry.changed$
25591 .map(function (geometry) {
25600 * Event fired when a property related to the visual appearance of the
25603 * @event Tag#changed
25604 * @type {Tag} The tag instance that has changed.
25606 Tag.changed = "changed";
25608 * Event fired when the geometry of the tag has changed.
25610 * @event Tag#geometrychanged
25611 * @type {Tag} The tag instance whose geometry has changed.
25613 Tag.geometrychanged = "geometrychanged";
25615 }(Utils_1.EventEmitter));
25617 Object.defineProperty(exports, "__esModule", { value: true });
25618 exports.default = Tag;
25620 },{"../../../Utils":215,"rxjs/Subject":33,"rxjs/add/operator/map":60,"rxjs/add/operator/share":69}],269:[function(require,module,exports){
25622 var __extends = (this && this.__extends) || function (d, b) {
25623 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
25624 function __() { this.constructor = d; }
25625 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
25627 var MapillaryError_1 = require("./MapillaryError");
25628 var ArgumentMapillaryError = (function (_super) {
25629 __extends(ArgumentMapillaryError, _super);
25630 function ArgumentMapillaryError(message) {
25632 this.name = "ArgumentMapillaryError";
25633 this.message = message != null ? message : "The argument is not valid.";
25635 return ArgumentMapillaryError;
25636 }(MapillaryError_1.MapillaryError));
25637 exports.ArgumentMapillaryError = ArgumentMapillaryError;
25638 Object.defineProperty(exports, "__esModule", { value: true });
25639 exports.default = ArgumentMapillaryError;
25641 },{"./MapillaryError":272}],270:[function(require,module,exports){
25643 var __extends = (this && this.__extends) || function (d, b) {
25644 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
25645 function __() { this.constructor = d; }
25646 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
25648 var MapillaryError_1 = require("./MapillaryError");
25649 var GraphMapillaryError = (function (_super) {
25650 __extends(GraphMapillaryError, _super);
25651 function GraphMapillaryError(message) {
25653 this.name = "GraphMapillaryError";
25654 this.message = message;
25656 return GraphMapillaryError;
25657 }(MapillaryError_1.MapillaryError));
25658 exports.GraphMapillaryError = GraphMapillaryError;
25659 Object.defineProperty(exports, "__esModule", { value: true });
25660 exports.default = GraphMapillaryError;
25662 },{"./MapillaryError":272}],271:[function(require,module,exports){
25664 var __extends = (this && this.__extends) || function (d, b) {
25665 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
25666 function __() { this.constructor = d; }
25667 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
25669 var MapillaryError_1 = require("./MapillaryError");
25670 var InitializationMapillaryError = (function (_super) {
25671 __extends(InitializationMapillaryError, _super);
25672 function InitializationMapillaryError() {
25674 this.name = "InitializationMapillaryError";
25675 this.message = "Could not initialize";
25677 return InitializationMapillaryError;
25678 }(MapillaryError_1.MapillaryError));
25679 exports.InitializationMapillaryError = InitializationMapillaryError;
25680 Object.defineProperty(exports, "__esModule", { value: true });
25681 exports.default = InitializationMapillaryError;
25683 },{"./MapillaryError":272}],272:[function(require,module,exports){
25685 var __extends = (this && this.__extends) || function (d, b) {
25686 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
25687 function __() { this.constructor = d; }
25688 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
25690 var MapillaryError = (function (_super) {
25691 __extends(MapillaryError, _super);
25692 function MapillaryError() {
25694 // fixme ERROR have not loaded correct props
25695 // this.stack = (new Error()).stack;
25697 return MapillaryError;
25699 exports.MapillaryError = MapillaryError;
25700 Object.defineProperty(exports, "__esModule", { value: true });
25701 exports.default = MapillaryError;
25703 },{}],273:[function(require,module,exports){
25705 var __extends = (this && this.__extends) || function (d, b) {
25706 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
25707 function __() { this.constructor = d; }
25708 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
25710 var MapillaryError_1 = require("./MapillaryError");
25711 var MoveTypeMapillaryError = (function (_super) {
25712 __extends(MoveTypeMapillaryError, _super);
25713 function MoveTypeMapillaryError() {
25715 this.name = "MoveTypeMapillaryError";
25716 this.message = "The type of ui you use does not support this move";
25718 return MoveTypeMapillaryError;
25719 }(MapillaryError_1.MapillaryError));
25720 exports.MoveTypeMapillaryError = MoveTypeMapillaryError;
25721 Object.defineProperty(exports, "__esModule", { value: true });
25722 exports.default = MoveTypeMapillaryError;
25724 },{"./MapillaryError":272}],274:[function(require,module,exports){
25726 var __extends = (this && this.__extends) || function (d, b) {
25727 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
25728 function __() { this.constructor = d; }
25729 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
25731 var MapillaryError_1 = require("./MapillaryError");
25732 var NotImplementedMapillaryError = (function (_super) {
25733 __extends(NotImplementedMapillaryError, _super);
25734 function NotImplementedMapillaryError() {
25736 this.name = "NotImplementedMapillaryError";
25737 this.message = "This function has not yet been implemented";
25739 return NotImplementedMapillaryError;
25740 }(MapillaryError_1.MapillaryError));
25741 exports.NotImplementedMapillaryError = NotImplementedMapillaryError;
25742 Object.defineProperty(exports, "__esModule", { value: true });
25743 exports.default = NotImplementedMapillaryError;
25745 },{"./MapillaryError":272}],275:[function(require,module,exports){
25747 var __extends = (this && this.__extends) || function (d, b) {
25748 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
25749 function __() { this.constructor = d; }
25750 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
25752 var MapillaryError_1 = require("./MapillaryError");
25753 var ParameterMapillaryError = (function (_super) {
25754 __extends(ParameterMapillaryError, _super);
25755 function ParameterMapillaryError(message) {
25757 this.name = "ParameterMapillaryError";
25758 this.message = message != null ? message : "The function was not called with correct parameters";
25760 return ParameterMapillaryError;
25761 }(MapillaryError_1.MapillaryError));
25762 exports.ParameterMapillaryError = ParameterMapillaryError;
25763 Object.defineProperty(exports, "__esModule", { value: true });
25764 exports.default = ParameterMapillaryError;
25766 },{"./MapillaryError":272}],276:[function(require,module,exports){
25767 /// <reference path="../../typings/index.d.ts" />
25769 var THREE = require("three");
25773 * @classdesc Holds information about a camera.
25775 var Camera = (function () {
25777 * Create a new camera instance.
25778 * @param {Transform} [transform] - Optional transform instance.
25780 function Camera(transform) {
25781 if (transform != null) {
25782 this._position = new THREE.Vector3().fromArray(transform.unprojectSfM([0, 0], 0));
25783 this._lookat = new THREE.Vector3().fromArray(transform.unprojectSfM([0, 0], 10));
25784 this._up = transform.upVector();
25785 this._focal = this._getFocal(transform);
25788 this._position = new THREE.Vector3(0, 0, 0);
25789 this._lookat = new THREE.Vector3(0, 0, 1);
25790 this._up = new THREE.Vector3(0, -1, 0);
25794 Object.defineProperty(Camera.prototype, "position", {
25797 * @returns {THREE.Vector3} The position vector.
25800 return this._position;
25805 Object.defineProperty(Camera.prototype, "lookat", {
25808 * @returns {THREE.Vector3} The lookat vector.
25811 return this._lookat;
25816 Object.defineProperty(Camera.prototype, "up", {
25819 * @returns {THREE.Vector3} The up vector.
25827 Object.defineProperty(Camera.prototype, "focal", {
25830 * @returns {number} The focal length.
25833 return this._focal;
25838 set: function (value) {
25839 this._focal = value;
25845 * Update this camera to the linearly interpolated value of two other cameras.
25847 * @param {Camera} a - First camera.
25848 * @param {Camera} b - Second camera.
25849 * @param {number} alpha - Interpolation value on the interval [0, 1].
25851 Camera.prototype.lerpCameras = function (a, b, alpha) {
25852 this._position.subVectors(b.position, a.position).multiplyScalar(alpha).add(a.position);
25853 this._lookat.subVectors(b.lookat, a.lookat).multiplyScalar(alpha).add(a.lookat);
25854 this._up.subVectors(b.up, a.up).multiplyScalar(alpha).add(a.up);
25855 this._focal = (1 - alpha) * a.focal + alpha * b.focal;
25858 * Copy the properties of another camera to this camera.
25860 * @param {Camera} other - Another camera.
25862 Camera.prototype.copy = function (other) {
25863 this._position.copy(other.position);
25864 this._lookat.copy(other.lookat);
25865 this._up.copy(other.up);
25866 this._focal = other.focal;
25869 * Clone this camera.
25871 * @returns {Camera} A camera with cloned properties equal to this camera.
25873 Camera.prototype.clone = function () {
25874 var camera = new Camera();
25875 camera.position.copy(this._position);
25876 camera.lookat.copy(this._lookat);
25877 camera.up.copy(this._up);
25878 camera.focal = this._focal;
25882 * Determine the distance between this camera and another camera.
25884 * @param {Camera} other - Another camera.
25885 * @returns {number} The distance between the cameras.
25887 Camera.prototype.diff = function (other) {
25888 var pd = this._position.distanceToSquared(other.position);
25889 var ld = this._lookat.distanceToSquared(other.lookat);
25890 var ud = this._up.distanceToSquared(other.up);
25891 var fd = 100 * Math.abs(this._focal - other.focal);
25892 return Math.max(pd, ld, ud, fd);
25895 * Get the focal length based on the transform.
25897 * @description Returns 0.5 focal length if transform has gpano
25900 * @returns {number} Focal length.
25902 Camera.prototype._getFocal = function (transform) {
25903 return transform.gpano == null ? transform.focal : 0.5;
25907 exports.Camera = Camera;
25909 },{"three":157}],277:[function(require,module,exports){
25914 * @classdesc Converts coordinates between the geodetic (WGS84),
25915 * Earth-Centered, Earth-Fixed (ECEF) and local topocentric
25916 * East, North, Up (ENU) reference frames.
25918 * The WGS84 has latitude (degrees), longitude (degrees) and
25919 * altitude (meters) values.
25921 * The ECEF Z-axis pierces the north pole and the
25922 * XY-axis defines the equatorial plane. The X-axis extends
25923 * from the geocenter to the intersection of the Equator and
25924 * the Greenwich Meridian. All values in meters.
25926 * The WGS84 parameters are:
25930 * f = 1 / 298.257223563
25931 * e = Math.sqrt((a^2 - b^2) / a^2)
25932 * e' = Math.sqrt((a^2 - b^2) / b^2)
25934 * The WGS84 to ECEF conversion is performed using the following:
25936 * X = (N - h) * cos(phi) * cos(lambda)
25937 * Y = (N + h) * cos(phi) * sin(lambda)
25938 * Z = (b^2 * N / a^2 + h) * sin(phi)
25943 * lambda = longitude
25944 * h = height above ellipsoid (altitude)
25945 * N = Radius of curvature (meters)
25946 * = a / Math.sqrt(1 - e^2 * sin(phi)^2)
25948 * The ECEF to WGS84 conversion is performed using the following:
25950 * phi = arctan((Z + e'^2 * b * sin(theta)^3) / (p - e^2 * a * cos(theta)^3))
25951 * lambda = arctan(Y / X)
25952 * h = p / cos(phi) - N
25956 * p = Math.sqrt(X^2 + Y^2)
25957 * theta = arctan(Z * a / p * b)
25959 * In the ENU reference frame the x-axis points to the
25960 * East, the y-axis to the North and the z-axis Up. All values
25963 * The ECEF to ENU conversion is performed using the following:
25965 * | x | | -sin(lambda_r) cos(lambda_r) 0 | | X - X_r |
25966 * | y | = | -sin(phi_r) * cos(lambda_r) -sin(phi_r) * sin(lambda_r) cos(phi_r) | | Y - Y_r |
25967 * | z | | cos(phi_r) * cos(lambda_r) cos(phi_r) * sin(lambda_r) sin(phi_r) | | Z - Z_r |
25971 * phi_r = latitude of reference
25972 * lambda_r = longitude of reference
25973 * X_r, Y_r, Z_r = ECEF coordinates of reference
25975 * The ENU to ECEF conversion is performed by solving the above equation for X, Y, Z.
25977 * WGS84 to ENU and ENU to WGS84 are two step conversions with ECEF calculated in
25978 * the first step for both conversions.
25980 var GeoCoords = (function () {
25981 function GeoCoords() {
25982 this._wgs84a = 6378137.0;
25983 this._wgs84b = 6356752.31424518;
25986 * Convert coordinates from geodetic (WGS84) reference to local topocentric
25989 * @param {number} lat Latitude in degrees.
25990 * @param {number} lon Longitude in degrees.
25991 * @param {number} alt Altitude in meters.
25992 * @param {number} refLat Reference latitude in degrees.
25993 * @param {number} refLon Reference longitude in degrees.
25994 * @param {number} refAlt Reference altitude in meters.
25995 * @returns {Array<number>} The x, y, z local topocentric ENU coordinates.
25997 GeoCoords.prototype.geodeticToEnu = function (lat, lon, alt, refLat, refLon, refAlt) {
25998 var ecef = this.geodeticToEcef(lat, lon, alt);
25999 return this.ecefToEnu(ecef[0], ecef[1], ecef[2], refLat, refLon, refAlt);
26002 * Convert coordinates from local topocentric (ENU) reference to
26003 * geodetic (WGS84) reference.
26005 * @param {number} x Topocentric ENU coordinate in East direction.
26006 * @param {number} y Topocentric ENU coordinate in North direction.
26007 * @param {number} z Topocentric ENU coordinate in Up direction.
26008 * @param {number} refLat Reference latitude in degrees.
26009 * @param {number} refLon Reference longitude in degrees.
26010 * @param {number} refAlt Reference altitude in meters.
26011 * @returns {Array<number>} The latitude and longitude in degrees
26012 * as well as altitude in meters.
26014 GeoCoords.prototype.enuToGeodetic = function (x, y, z, refLat, refLon, refAlt) {
26015 var ecef = this.enuToEcef(x, y, z, refLat, refLon, refAlt);
26016 return this.ecefToGeodetic(ecef[0], ecef[1], ecef[2]);
26019 * Convert coordinates from Earth-Centered, Earth-Fixed (ECEF) reference
26020 * to local topocentric (ENU) reference.
26022 * @param {number} X ECEF X-value.
26023 * @param {number} Y ECEF Y-value.
26024 * @param {number} Z ECEF Z-value.
26025 * @param {number} refLat Reference latitude in degrees.
26026 * @param {number} refLon Reference longitude in degrees.
26027 * @param {number} refAlt Reference altitude in meters.
26028 * @returns {Array<number>} The x, y, z topocentric ENU coordinates in East, North
26029 * and Up directions respectively.
26031 GeoCoords.prototype.ecefToEnu = function (X, Y, Z, refLat, refLon, refAlt) {
26032 var refEcef = this.geodeticToEcef(refLat, refLon, refAlt);
26033 var V = [X - refEcef[0], Y - refEcef[1], Z - refEcef[2]];
26034 refLat = refLat * Math.PI / 180.0;
26035 refLon = refLon * Math.PI / 180.0;
26036 var cosLat = Math.cos(refLat);
26037 var sinLat = Math.sin(refLat);
26038 var cosLon = Math.cos(refLon);
26039 var sinLon = Math.sin(refLon);
26040 var x = -sinLon * V[0] + cosLon * V[1];
26041 var y = -sinLat * cosLon * V[0] - sinLat * sinLon * V[1] + cosLat * V[2];
26042 var z = cosLat * cosLon * V[0] + cosLat * sinLon * V[1] + sinLat * V[2];
26046 * Convert coordinates from local topocentric (ENU) reference
26047 * to Earth-Centered, Earth-Fixed (ECEF) reference.
26049 * @param {number} x Topocentric ENU coordinate in East direction.
26050 * @param {number} y Topocentric ENU coordinate in North direction.
26051 * @param {number} z Topocentric ENU coordinate in Up direction.
26052 * @param {number} refLat Reference latitude in degrees.
26053 * @param {number} refLon Reference longitude in degrees.
26054 * @param {number} refAlt Reference altitude in meters.
26055 * @returns {Array<number>} The X, Y, Z ECEF coordinates.
26057 GeoCoords.prototype.enuToEcef = function (x, y, z, refLat, refLon, refAlt) {
26058 var refEcef = this.geodeticToEcef(refLat, refLon, refAlt);
26059 refLat = refLat * Math.PI / 180.0;
26060 refLon = refLon * Math.PI / 180.0;
26061 var cosLat = Math.cos(refLat);
26062 var sinLat = Math.sin(refLat);
26063 var cosLon = Math.cos(refLon);
26064 var sinLon = Math.sin(refLon);
26065 var X = -sinLon * x - sinLat * cosLon * y + cosLat * cosLon * z + refEcef[0];
26066 var Y = cosLon * x - sinLat * sinLon * y + cosLat * sinLon * z + refEcef[1];
26067 var Z = cosLat * y + sinLat * z + refEcef[2];
26071 * Convert coordinates from geodetic reference (WGS84) to Earth-Centered,
26072 * Earth-Fixed (ECEF) reference.
26074 * @param {number} lat Latitude in degrees.
26075 * @param {number} lon Longitude in degrees.
26076 * @param {number} alt Altitude in meters.
26077 * @returns {Array<number>} The X, Y, Z ECEF coordinates.
26079 GeoCoords.prototype.geodeticToEcef = function (lat, lon, alt) {
26080 var a = this._wgs84a;
26081 var b = this._wgs84b;
26082 lat = lat * Math.PI / 180.0;
26083 lon = lon * Math.PI / 180.0;
26084 var cosLat = Math.cos(lat);
26085 var sinLat = Math.sin(lat);
26086 var cosLon = Math.cos(lon);
26087 var sinLon = Math.sin(lon);
26090 var L = 1.0 / Math.sqrt(a2 * cosLat * cosLat + b2 * sinLat * sinLat);
26091 var nhcl = (a2 * L + alt) * cosLat;
26092 var X = nhcl * cosLon;
26093 var Y = nhcl * sinLon;
26094 var Z = (b2 * L + alt) * sinLat;
26098 * Convert coordinates from Earth-Centered, Earth-Fixed (ECEF) reference
26099 * to geodetic reference (WGS84).
26101 * @param {number} X ECEF X-value.
26102 * @param {number} Y ECEF Y-value.
26103 * @param {number} Z ECEF Z-value.
26104 * @returns {Array<number>} The latitude and longitude in degrees
26105 * as well as altitude in meters.
26107 GeoCoords.prototype.ecefToGeodetic = function (X, Y, Z) {
26108 var a = this._wgs84a;
26109 var b = this._wgs84b;
26112 var a2mb2 = a2 - b2;
26113 var ea = Math.sqrt(a2mb2 / a2);
26114 var eb = Math.sqrt(a2mb2 / b2);
26115 var p = Math.sqrt(X * X + Y * Y);
26116 var theta = Math.atan2(Z * a, p * b);
26117 var sinTheta = Math.sin(theta);
26118 var cosTheta = Math.cos(theta);
26119 var lon = Math.atan2(Y, X);
26120 var lat = Math.atan2(Z + eb * eb * b * sinTheta * sinTheta * sinTheta, p - ea * ea * a * cosTheta * cosTheta * cosTheta);
26121 var sinLat = Math.sin(lat);
26122 var cosLat = Math.cos(lat);
26123 var N = a / Math.sqrt(1 - ea * ea * sinLat * sinLat);
26124 var alt = p / cosLat - N;
26125 return [lat * 180.0 / Math.PI, lon * 180.0 / Math.PI, alt];
26129 exports.GeoCoords = GeoCoords;
26130 Object.defineProperty(exports, "__esModule", { value: true });
26131 exports.default = GeoCoords;
26133 },{}],278:[function(require,module,exports){
26134 /// <reference path="../../typings/index.d.ts" />
26136 var THREE = require("three");
26140 * @classdesc Provides methods for scalar, vector and matrix calculations.
26142 var Spatial = (function () {
26143 function Spatial() {
26144 this._epsilon = 1e-9;
26147 * Converts degrees to radians.
26149 * @param {number} deg Degrees.
26151 Spatial.prototype.degToRad = function (deg) {
26152 return Math.PI * deg / 180;
26155 * Converts radians to degrees.
26157 * @param {number} rad Radians.
26159 Spatial.prototype.radToDeg = function (rad) {
26160 return 180 * rad / Math.PI;
26163 * Creates a rotation matrix from an angle-axis vector.
26165 * @param {Array<number>} angleAxis Angle-axis representation of a rotation.
26167 Spatial.prototype.rotationMatrix = function (angleAxis) {
26168 var axis = new THREE.Vector3(angleAxis[0], angleAxis[1], angleAxis[2]);
26169 var angle = axis.length();
26171 return new THREE.Matrix4().makeRotationAxis(axis, angle);
26174 * Rotates a vector according to a angle-axis rotation vector.
26176 * @param {Array<number>} vector Vector to rotate.
26177 * @param {Array<number>} angleAxis Angle-axis representation of a rotation.
26179 Spatial.prototype.rotate = function (vector, angleAxis) {
26180 var v = new THREE.Vector3(vector[0], vector[1], vector[2]);
26181 var rotationMatrix = this.rotationMatrix(angleAxis);
26182 v.applyMatrix4(rotationMatrix);
26186 * Calculates the optical center from a rotation vector
26187 * on the angle-axis representation and a translation vector
26188 * according to C = -R^T t.
26190 * @param {Array<number>} rotation Angle-axis representation of a rotation.
26191 * @param {Array<number>} translation Translation vector.
26193 Spatial.prototype.opticalCenter = function (rotation, translation) {
26194 var angleAxis = [-rotation[0], -rotation[1], -rotation[2]];
26195 var vector = [-translation[0], -translation[1], -translation[2]];
26196 return this.rotate(vector, angleAxis);
26199 * Calculates the viewing direction from a rotation vector
26200 * on the angle-axis representation.
26202 * @param {number[]} rotation Angle-axis representation of a rotation.
26204 Spatial.prototype.viewingDirection = function (rotation) {
26205 var angleAxis = [-rotation[0], -rotation[1], -rotation[2]];
26206 return this.rotate([0, 0, 1], angleAxis);
26209 * Wrap a number on the interval [min, max].
26211 * @param {number} value Value to wrap.
26212 * @param {number} min Lower endpoint of interval.
26213 * @param {number} max Upper endpoint of interval.
26215 * @returs {number} The wrapped number.
26217 Spatial.prototype.wrap = function (value, min, max) {
26219 throw new Error("Invalid arguments: max must be larger than min.");
26221 var interval = (max - min);
26222 while (value > max || value < min) {
26224 value = value - interval;
26226 else if (value < min) {
26227 value = value + interval;
26233 * Wrap an angle on the interval [-Pi, Pi].
26235 * @param {number} angle Value to wrap.
26237 * @returs {number} The wrapped angle.
26239 Spatial.prototype.wrapAngle = function (angle) {
26240 return this.wrap(angle, -Math.PI, Math.PI);
26243 * Limit the value to the interval [min, max] by changing the value to
26244 * the nearest available one when it is outside the interval.
26246 * @param {number} value Value to clamp.
26247 * @param {number} min Minimum of the interval.
26248 * @param {number} max Maximum of the interval.
26250 * @returns {number} The clamped value.
26252 Spatial.prototype.clamp = function (value, min, max) {
26262 * Calculates the counter-clockwise angle from the first
26263 * vector (x1, y1)^T to the second (x2, y2)^T.
26265 * @param {number} x1 X-value of first vector.
26266 * @param {number} y1 Y-value of first vector.
26267 * @param {number} x2 X-value of second vector.
26268 * @param {number} y2 Y-value of second vector.
26270 Spatial.prototype.angleBetweenVector2 = function (x1, y1, x2, y2) {
26271 var angle = Math.atan2(y2, x2) - Math.atan2(y1, x1);
26272 return this.wrapAngle(angle);
26275 * Calculates the minimum (absolute) angle change for rotation
26276 * from one angle to another on the [-Pi, Pi] interval.
26278 * @param {number} angle1 The origin angle.
26279 * @param {number} angle2 The destination angle.
26281 Spatial.prototype.angleDifference = function (angle1, angle2) {
26282 var angle = angle2 - angle1;
26283 return this.wrapAngle(angle);
26286 * Calculates the relative rotation angle between two
26287 * angle-axis vectors.
26289 * @param {number} rotation1 First angle-axis vector.
26290 * @param {number} rotation2 Second angle-axis vector.
26292 Spatial.prototype.relativeRotationAngle = function (rotation1, rotation2) {
26293 var R1T = this.rotationMatrix([-rotation1[0], -rotation1[1], -rotation1[2]]);
26294 var R2 = this.rotationMatrix(rotation2);
26295 var R = R1T.multiply(R2);
26296 var elements = R.elements;
26297 // from Tr(R) = 1 + 2*cos(theta)
26298 var theta = Math.acos((elements[0] + elements[5] + elements[10] - 1) / 2);
26302 * Calculates the angle from a vector to a plane.
26304 * @param {Array<number>} vector The vector.
26305 * @param {Array<number>} planeNormal Normal of the plane.
26307 Spatial.prototype.angleToPlane = function (vector, planeNormal) {
26308 var v = new THREE.Vector3().fromArray(vector);
26309 var norm = v.length();
26310 if (norm < this._epsilon) {
26313 var projection = v.dot(new THREE.Vector3().fromArray(planeNormal));
26314 return Math.asin(projection / norm);
26317 * Calculates the distance between two coordinates
26318 * (latitude longitude pairs) in meters according to
26319 * the haversine formula.
26321 * @param {number} lat1 The latitude of the first coordinate.
26322 * @param {number} lon1 The longitude of the first coordinate.
26323 * @param {number} lat2 The latitude of the second coordinate.
26324 * @param {number} lon2 The longitude of the second coordinate.
26326 Spatial.prototype.distanceFromLatLon = function (lat1, lon1, lat2, lon2) {
26328 var dLat = this.degToRad(lat2 - lat1);
26329 var dLon = this.degToRad(lon2 - lon1);
26330 var hav = Math.sin(dLat / 2) * Math.sin(dLat / 2) +
26331 Math.cos(lat1) * Math.cos(lat2) *
26332 Math.sin(dLon / 2) * Math.sin(dLon / 2);
26333 var d = 2 * r * Math.atan2(Math.sqrt(hav), Math.sqrt(1 - hav));
26338 exports.Spatial = Spatial;
26339 Object.defineProperty(exports, "__esModule", { value: true });
26340 exports.default = Spatial;
26342 },{"three":157}],279:[function(require,module,exports){
26343 /// <reference path="../../typings/index.d.ts" />
26345 var THREE = require("three");
26349 * @classdesc Class used for calculating coordinate transformations
26352 var Transform = (function () {
26354 * Create a new transform instance.
26355 * @param {Node} apiNavImIm - Node properties.
26356 * @param {HTMLImageElement} image - Node image.
26357 * @param {Array<number>} translation - Node translation vector in three dimensions.
26359 function Transform(node, image, translation) {
26360 this._orientation = this._getValue(node.orientation, 1);
26361 var imageWidth = image != null ? image.width : 4;
26362 var imageHeight = image != null ? image.height : 3;
26363 var keepOrientation = this._orientation < 5;
26364 this._width = this._getValue(node.width, keepOrientation ? imageWidth : imageHeight);
26365 this._height = this._getValue(node.height, keepOrientation ? imageHeight : imageWidth);
26366 this._basicAspect = keepOrientation ?
26367 this._width / this._height :
26368 this._height / this._width;
26369 this._focal = this._getValue(node.focal, 1);
26370 this._scale = this._getValue(node.scale, 0);
26371 this._gpano = node.gpano != null ? node.gpano : null;
26372 this._rt = this._getRt(node.rotation, translation);
26373 this._srt = this._getSrt(this._rt, this._scale);
26375 Object.defineProperty(Transform.prototype, "basicAspect", {
26377 * Get basic aspect.
26378 * @returns {number} The orientation adjusted aspect ratio.
26381 return this._basicAspect;
26386 Object.defineProperty(Transform.prototype, "focal", {
26389 * @returns {number} The node focal length.
26392 return this._focal;
26397 Object.defineProperty(Transform.prototype, "gpano", {
26400 * @returns {number} The node gpano information.
26403 return this._gpano;
26408 Object.defineProperty(Transform.prototype, "height", {
26411 * @returns {number} The orientation adjusted image height.
26414 return this._height;
26419 Object.defineProperty(Transform.prototype, "orientation", {
26422 * @returns {number} The image orientation.
26425 return this._orientation;
26430 Object.defineProperty(Transform.prototype, "rt", {
26433 * @returns {THREE.Matrix4} The extrinsic camera matrix.
26441 Object.defineProperty(Transform.prototype, "srt", {
26444 * @returns {THREE.Matrix4} The scaled extrinsic camera matrix.
26452 Object.defineProperty(Transform.prototype, "scale", {
26455 * @returns {number} The node atomic reconstruction scale.
26458 return this._scale;
26463 Object.defineProperty(Transform.prototype, "width", {
26466 * @returns {number} The orientation adjusted image width.
26469 return this._width;
26475 * Calculate the up vector for the node transform.
26477 * @returns {THREE.Vector3} Normalized and orientation adjusted up vector.
26479 Transform.prototype.upVector = function () {
26480 var rte = this._rt.elements;
26481 switch (this._orientation) {
26483 return new THREE.Vector3(-rte[1], -rte[5], -rte[9]);
26485 return new THREE.Vector3(rte[1], rte[5], rte[9]);
26487 return new THREE.Vector3(-rte[0], -rte[4], -rte[8]);
26489 return new THREE.Vector3(rte[0], rte[4], rte[8]);
26491 return new THREE.Vector3(-rte[1], -rte[5], -rte[9]);
26495 * Calculate projector matrix for projecting 3D points to texture map
26496 * coordinates (u and v).
26498 * @returns {THREE.Matrix4} Projection matrix for 3D point to texture
26499 * map coordinate calculations.
26501 Transform.prototype.projectorMatrix = function () {
26502 var projector = this._normalizedToTextureMatrix();
26503 var f = this._focal;
26504 var projection = new THREE.Matrix4().set(f, 0, 0, 0, 0, f, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0);
26505 projector.multiply(projection);
26506 projector.multiply(this._rt);
26510 * Project 3D world coordinates to basic coordinates.
26512 * @param {Array<number>} point3d - 3D world coordinates.
26513 * @return {Array<number>} 2D basic coordinates.
26515 Transform.prototype.projectBasic = function (point3d) {
26516 var sfm = this.projectSfM(point3d);
26517 return this._sfmToBasic(sfm);
26520 * Unproject basic coordinates to 3D world coordinates.
26522 * @param {Array<number>} basic - 2D basic coordinates.
26523 * @param {Array<number>} distance - Depth to unproject from camera center.
26524 * @returns {Array<number>} Unprojected 3D world coordinates.
26526 Transform.prototype.unprojectBasic = function (basic, distance) {
26527 var sfm = this._basicToSfm(basic);
26528 return this.unprojectSfM(sfm, distance);
26531 * Project 3D world coordinates to SfM coordinates.
26533 * @param {Array<number>} point3d - 3D world coordinates.
26534 * @return {Array<number>} 2D SfM coordinates.
26536 Transform.prototype.projectSfM = function (point3d) {
26537 var v = new THREE.Vector4(point3d[0], point3d[1], point3d[2], 1);
26538 v.applyMatrix4(this._rt);
26539 return this._bearingToSfm([v.x, v.y, v.z]);
26542 * Unproject SfM coordinates to a 3D world coordinates.
26544 * @param {Array<number>} sfm - 2D SfM coordinates.
26545 * @param {Array<number>} distance - Depth to unproject from camera center.
26546 * @returns {Array<number>} Unprojected 3D world coordinates.
26548 Transform.prototype.unprojectSfM = function (sfm, distance) {
26549 var bearing = this._sfmToBearing(sfm);
26550 var v = new THREE.Vector4(distance * bearing[0], distance * bearing[1], distance * bearing[2], 1);
26551 v.applyMatrix4(new THREE.Matrix4().getInverse(this._rt));
26552 return [v.x / v.w, v.y / v.w, v.z / v.w];
26555 * Transform SfM coordinates to bearing vector (3D cartesian
26556 * coordinates on the unit sphere).
26558 * @param {Array<number>} sfm - 2D SfM coordinates.
26559 * @returns {Array<number>} Bearing vector (3D cartesian coordinates
26560 * on the unit sphere).
26562 Transform.prototype._sfmToBearing = function (sfm) {
26563 if (this._fullPano()) {
26564 var lon = sfm[0] * 2 * Math.PI;
26565 var lat = -sfm[1] * 2 * Math.PI;
26566 var x = Math.cos(lat) * Math.sin(lon);
26567 var y = -Math.sin(lat);
26568 var z = Math.cos(lat) * Math.cos(lon);
26571 else if (this._gpano) {
26572 var size = Math.max(this.gpano.CroppedAreaImageWidthPixels, this.gpano.CroppedAreaImageHeightPixels);
26573 var fullPanoPixel = [
26574 sfm[0] * size + this.gpano.CroppedAreaImageWidthPixels / 2 + this.gpano.CroppedAreaLeftPixels,
26575 sfm[1] * size + this.gpano.CroppedAreaImageHeightPixels / 2 + this.gpano.CroppedAreaTopPixels,
26577 var lon = 2 * Math.PI * (fullPanoPixel[0] / this.gpano.FullPanoWidthPixels - 0.5);
26578 var lat = -Math.PI * (fullPanoPixel[1] / this.gpano.FullPanoHeightPixels - 0.5);
26579 var x = Math.cos(lat) * Math.sin(lon);
26580 var y = -Math.sin(lat);
26581 var z = Math.cos(lat) * Math.cos(lon);
26585 var v = new THREE.Vector3(sfm[0], sfm[1], this._focal);
26587 return [v.x, v.y, v.z];
26591 * Transform bearing vector (3D cartesian coordiantes on the unit sphere) to
26594 * @param {Array<number>} bearing - Bearing vector (3D cartesian coordinates on the
26596 * @returns {Array<number>} 2D SfM coordinates.
26598 Transform.prototype._bearingToSfm = function (bearing) {
26599 if (this._fullPano()) {
26600 var x = bearing[0];
26601 var y = bearing[1];
26602 var z = bearing[2];
26603 var lon = Math.atan2(x, z);
26604 var lat = Math.atan2(-y, Math.sqrt(x * x + z * z));
26605 return [lon / (2 * Math.PI), -lat / (2 * Math.PI)];
26607 else if (this._gpano) {
26608 var x = bearing[0];
26609 var y = bearing[1];
26610 var z = bearing[2];
26611 var lon = Math.atan2(x, z);
26612 var lat = Math.atan2(-y, Math.sqrt(x * x + z * z));
26613 var fullPanoPixel = [
26614 (lon / (2 * Math.PI) + 0.5) * this.gpano.FullPanoWidthPixels,
26615 (-lat / Math.PI + 0.5) * this.gpano.FullPanoHeightPixels,
26617 var size = Math.max(this.gpano.CroppedAreaImageWidthPixels, this.gpano.CroppedAreaImageHeightPixels);
26619 (fullPanoPixel[0] - this.gpano.CroppedAreaLeftPixels - this.gpano.CroppedAreaImageWidthPixels / 2) / size,
26620 (fullPanoPixel[1] - this.gpano.CroppedAreaTopPixels - this.gpano.CroppedAreaImageHeightPixels / 2) / size,
26625 bearing[0] * this._focal / bearing[2],
26626 bearing[1] * this._focal / bearing[2],
26631 * Convert basic coordinates to SfM coordinates.
26633 * @param {Array<number>} basic - 2D basic coordinates.
26634 * @returns {Array<number>} 2D SfM coordinates.
26636 Transform.prototype._basicToSfm = function (basic) {
26639 switch (this._orientation) {
26641 rotatedX = basic[0];
26642 rotatedY = basic[1];
26645 rotatedX = 1 - basic[0];
26646 rotatedY = 1 - basic[1];
26649 rotatedX = basic[1];
26650 rotatedY = 1 - basic[0];
26653 rotatedX = 1 - basic[1];
26654 rotatedY = basic[0];
26657 rotatedX = basic[0];
26658 rotatedY = basic[1];
26661 var w = this._width;
26662 var h = this._height;
26663 var s = Math.max(w, h);
26664 var sfmX = rotatedX * w / s - w / s / 2;
26665 var sfmY = rotatedY * h / s - h / s / 2;
26666 return [sfmX, sfmY];
26669 * Convert SfM coordinates to basic coordinates.
26671 * @param {Array<number>} sfm - 2D SfM coordinates.
26672 * @returns {Array<number>} 2D basic coordinates.
26674 Transform.prototype._sfmToBasic = function (sfm) {
26675 var w = this._width;
26676 var h = this._height;
26677 var s = Math.max(w, h);
26678 var rotatedX = (sfm[0] + w / s / 2) / w * s;
26679 var rotatedY = (sfm[1] + h / s / 2) / h * s;
26682 switch (this._orientation) {
26688 basicX = 1 - rotatedX;
26689 basicY = 1 - rotatedY;
26692 basicX = 1 - rotatedY;
26697 basicY = 1 - rotatedX;
26704 return [basicX, basicY];
26707 * Determines if the gpano information indicates a full panorama.
26709 * @returns {boolean} Value determining if the gpano information indicates
26712 Transform.prototype._fullPano = function () {
26713 return this.gpano != null &&
26714 this.gpano.CroppedAreaLeftPixels === 0 &&
26715 this.gpano.CroppedAreaTopPixels === 0 &&
26716 this.gpano.CroppedAreaImageWidthPixels === this.gpano.FullPanoWidthPixels &&
26717 this.gpano.CroppedAreaImageHeightPixels === this.gpano.FullPanoHeightPixels;
26720 * Checks a value and returns it if it exists and is larger than 0.
26721 * Fallbacks if it is null.
26723 * @param {number} value - Value to check.
26724 * @param {number} fallback - Value to fall back to.
26725 * @returns {number} The value or its fallback value if it is not defined or negative.
26727 Transform.prototype._getValue = function (value, fallback) {
26728 return value != null && value > 0 ? value : fallback;
26731 * Creates the extrinsic camera matrix [ R | t ].
26733 * @param {Array<number>} rotation - Rotation vector in angle axis representation.
26734 * @param {Array<number>} translation - Translation vector.
26735 * @returns {THREE.Matrix4} Extrisic camera matrix.
26737 Transform.prototype._getRt = function (rotation, translation) {
26738 var axis = new THREE.Vector3(rotation[0], rotation[1], rotation[2]);
26739 var angle = axis.length();
26741 var rt = new THREE.Matrix4();
26742 rt.makeRotationAxis(axis, angle);
26743 rt.setPosition(new THREE.Vector3(translation[0], translation[1], translation[2]));
26747 * Calculates the scaled extrinsic camera matrix scale * [ R | t ].
26749 * @param {THREE.Matrix4} rt - Extrisic camera matrix.
26750 * @param {number} scale - Scale factor.
26751 * @returns {THREE.Matrix4} Scaled extrisic camera matrix.
26753 Transform.prototype._getSrt = function (rt, scale) {
26754 var srt = rt.clone();
26755 var elements = srt.elements;
26756 elements[12] = scale * elements[12];
26757 elements[13] = scale * elements[13];
26758 elements[14] = scale * elements[14];
26759 srt.scale(new THREE.Vector3(scale, scale, scale));
26763 * Calculate a transformation matrix from normalized coordinates for
26764 * texture map coordinates.
26766 * @returns {THREE.Matrix4} Normalized coordinates to texture map
26767 * coordinates transformation matrix.
26769 Transform.prototype._normalizedToTextureMatrix = function () {
26770 var size = Math.max(this._width, this._height);
26771 var w = size / this._width;
26772 var h = size / this._height;
26773 switch (this._orientation) {
26775 return new THREE.Matrix4().set(w, 0, 0, 0.5, 0, -h, 0, 0.5, 0, 0, 1, 0, 0, 0, 0, 1);
26777 return new THREE.Matrix4().set(-w, 0, 0, 0.5, 0, h, 0, 0.5, 0, 0, 1, 0, 0, 0, 0, 1);
26779 return new THREE.Matrix4().set(0, -h, 0, 0.5, -w, 0, 0, 0.5, 0, 0, 1, 0, 0, 0, 0, 1);
26781 return new THREE.Matrix4().set(0, h, 0, 0.5, w, 0, 0, 0.5, 0, 0, 1, 0, 0, 0, 0, 1);
26783 return new THREE.Matrix4().set(w, 0, 0, 0.5, 0, -h, 0, 0.5, 0, 0, 1, 0, 0, 0, 0, 1);
26788 exports.Transform = Transform;
26790 },{"three":157}],280:[function(require,module,exports){
26791 /// <reference path="../../typings/index.d.ts" />
26793 var Subject_1 = require("rxjs/Subject");
26794 require("rxjs/add/observable/from");
26795 require("rxjs/add/operator/catch");
26796 require("rxjs/add/operator/do");
26797 require("rxjs/add/operator/finally");
26798 require("rxjs/add/operator/map");
26799 require("rxjs/add/operator/publish");
26800 var rbush = require("rbush");
26801 var Edge_1 = require("../Edge");
26802 var Error_1 = require("../Error");
26803 var Graph_1 = require("../Graph");
26807 * @classdesc Represents a graph of nodes with edges.
26809 var Graph = (function () {
26811 * Create a new graph instance.
26813 * @param {APIv3} [apiV3] - API instance for retrieving data.
26814 * @param {rbush.RBush<NodeIndexItem>} [nodeIndex] - Node index for fast spatial retreival.
26815 * @param {GraphCalculator} [graphCalculator] - Instance for graph calculations.
26816 * @param {EdgeCalculator} [edgeCalculator] - Instance for edge calculations.
26818 function Graph(apiV3, nodeIndex, graphCalculator, edgeCalculator) {
26819 this._apiV3 = apiV3;
26820 this._cachedNodes = {};
26821 this._cachedNodeTiles = {};
26822 this._cachedSpatialEdges = {};
26823 this._cachedTiles = {};
26824 this._cachingFill$ = {};
26825 this._cachingFull$ = {};
26826 this._cachingSequences$ = {};
26827 this._cachingSpatialArea$ = {};
26828 this._cachingTiles$ = {};
26829 this._changed$ = new Subject_1.Subject();
26830 this._defaultAlt = 2;
26831 this._edgeCalculator = edgeCalculator != null ? edgeCalculator : new Edge_1.EdgeCalculator();
26832 this._graphCalculator = graphCalculator != null ? graphCalculator : new Graph_1.GraphCalculator();
26834 this._nodeIndex = nodeIndex != null ? nodeIndex : rbush(16, [".lon", ".lat", ".lon", ".lat"]);
26835 this._preStored = {};
26836 this._requiredNodeTiles = {};
26837 this._requiredSpatialArea = {};
26838 this._sequences = {};
26839 this._tilePrecision = 7;
26840 this._tileThreshold = 20;
26842 Object.defineProperty(Graph.prototype, "changed$", {
26846 * @returns {Observable<Graph>} Observable emitting
26847 * the graph every time it has changed.
26850 return this._changed$;
26856 * Retrieve and cache node fill properties.
26858 * @param {string} key - Key of node to fill.
26859 * @returns {Observable<Graph>} Observable emitting the graph
26860 * when the node has been updated.
26861 * @throws {GraphMapillaryError} When the operation is not valid on the
26864 Graph.prototype.cacheFill$ = function (key) {
26866 if (key in this._cachingFull$) {
26867 throw new Error_1.GraphMapillaryError("Cannot fill node while caching full (" + key + ").");
26869 if (!this.hasNode(key)) {
26870 throw new Error_1.GraphMapillaryError("Cannot fill node that does not exist in graph (" + key + ").");
26872 if (key in this._cachingFill$) {
26873 return this._cachingFill$[key];
26875 var node = this.getNode(key);
26877 throw new Error_1.GraphMapillaryError("Cannot fill node that is already full (" + key + ").");
26879 this._cachingFill$[key] = this._apiV3.imageByKeyFill$([key])
26880 .do(function (imageByKeyFill) {
26882 _this._makeFull(node, imageByKeyFill[key]);
26884 delete _this._cachingFill$[key];
26886 .map(function (imageByKeyFill) {
26889 .finally(function () {
26890 if (key in _this._cachingFill$) {
26891 delete _this._cachingFill$[key];
26893 _this._changed$.next(_this);
26897 return this._cachingFill$[key];
26900 * Retrieve and cache full node properties.
26902 * @param {string} key - Key of node to fill.
26903 * @returns {Observable<Graph>} Observable emitting the graph
26904 * when the node has been updated.
26905 * @throws {GraphMapillaryError} When the operation is not valid on the
26908 Graph.prototype.cacheFull$ = function (key) {
26910 if (key in this._cachingFull$) {
26911 return this._cachingFull$[key];
26913 if (this.hasNode(key)) {
26914 throw new Error_1.GraphMapillaryError("Cannot cache full node that already exist in graph (" + key + ").");
26916 this._cachingFull$[key] = this._apiV3.imageByKeyFull$([key])
26917 .do(function (imageByKeyFull) {
26918 var fn = imageByKeyFull[key];
26919 if (_this.hasNode(key)) {
26920 var node = _this.getNode(key);
26922 _this._makeFull(node, fn);
26926 if (fn.sequence == null || fn.sequence.key == null) {
26927 throw new Error_1.GraphMapillaryError("Node has no sequence (" + key + ").");
26929 var node = new Graph_1.Node(fn);
26930 _this._makeFull(node, fn);
26931 var h = _this._graphCalculator.encodeH(node.originalLatLon, _this._tilePrecision);
26932 _this._preStore(h, node);
26933 _this._setNode(node);
26934 delete _this._cachingFull$[key];
26937 .map(function (imageByKeyFull) {
26940 .finally(function () {
26941 if (key in _this._cachingFull$) {
26942 delete _this._cachingFull$[key];
26944 _this._changed$.next(_this);
26948 return this._cachingFull$[key];
26951 * Retrieve and cache a node sequence.
26953 * @param {string} key - Key of node for which to retrieve sequence.
26954 * @returns {Observable<Graph>} Observable emitting the graph
26955 * when the sequence has been retrieved.
26956 * @throws {GraphMapillaryError} When the operation is not valid on the
26959 Graph.prototype.cacheNodeSequence$ = function (key) {
26960 if (!this.hasNode(key)) {
26961 throw new Error_1.GraphMapillaryError("Cannot cache sequence edges of node that does not exist in graph (" + key + ").");
26963 var node = this.getNode(key);
26964 if (node.sequenceKey in this._sequences) {
26965 throw new Error_1.GraphMapillaryError("Sequence already cached (" + key + "), (" + node.sequenceKey + ").");
26967 return this._cacheSequence$(node.sequenceKey);
26970 * Retrieve and cache a sequence.
26972 * @param {string} sequenceKey - Key of sequence to cache.
26973 * @returns {Observable<Graph>} Observable emitting the graph
26974 * when the sequence has been retrieved.
26975 * @throws {GraphMapillaryError} When the operation is not valid on the
26978 Graph.prototype.cacheSequence$ = function (sequenceKey) {
26979 if (sequenceKey in this._sequences) {
26980 throw new Error_1.GraphMapillaryError("Sequence already cached (" + sequenceKey + ")");
26982 return this._cacheSequence$(sequenceKey);
26985 * Cache sequence edges for a node.
26987 * @param {string} key - Key of node.
26988 * @throws {GraphMapillaryError} When the operation is not valid on the
26991 Graph.prototype.cacheSequenceEdges = function (key) {
26992 var node = this.getNode(key);
26993 if (!(node.sequenceKey in this._sequences)) {
26994 throw new Error_1.GraphMapillaryError("Sequence is not cached (" + key + "), (" + node.sequenceKey + ")");
26996 var sequence = this._sequences[node.sequenceKey];
26997 var edges = this._edgeCalculator.computeSequenceEdges(node, sequence);
26998 node.cacheSequenceEdges(edges);
27001 * Retrieve and cache full nodes for a node spatial area.
27003 * @param {string} key - Key of node for which to retrieve sequence.
27004 * @returns {Observable<Graph>} Observable emitting the graph
27005 * when the nodes in the spatial area has been made full.
27006 * @throws {GraphMapillaryError} When the operation is not valid on the
27009 Graph.prototype.cacheSpatialArea$ = function (key) {
27011 if (!this.hasNode(key)) {
27012 throw new Error_1.GraphMapillaryError("Cannot cache spatial area of node that does not exist in graph (" + key + ").");
27014 if (key in this._cachedSpatialEdges) {
27015 throw new Error_1.GraphMapillaryError("Node already spatially cached (" + key + ").");
27017 if (!(key in this._requiredSpatialArea)) {
27018 throw new Error_1.GraphMapillaryError("Spatial area not determined (" + key + ").");
27020 var spatialArea = this._requiredSpatialArea[key];
27021 if (Object.keys(spatialArea.cacheNodes).length === 0) {
27022 throw new Error_1.GraphMapillaryError("Spatial nodes already cached (" + key + ").");
27024 if (key in this._cachingSpatialArea$) {
27025 return this._cachingSpatialArea$[key];
27028 while (spatialArea.cacheKeys.length > 0) {
27029 batches.push(spatialArea.cacheKeys.splice(0, 200));
27031 var batchesToCache = batches.length;
27032 var spatialNodes$ = [];
27033 var _loop_1 = function(batch) {
27034 var spatialNodeBatch$ = this_1._apiV3.imageByKeyFill$(batch)
27035 .do(function (imageByKeyFill) {
27036 for (var fillKey in imageByKeyFill) {
27037 if (!imageByKeyFill.hasOwnProperty(fillKey)) {
27040 var spatialNode = spatialArea.cacheNodes[fillKey];
27041 if (spatialNode.full) {
27042 delete spatialArea.cacheNodes[fillKey];
27045 var fillNode = imageByKeyFill[fillKey];
27046 _this._makeFull(spatialNode, fillNode);
27047 delete spatialArea.cacheNodes[fillKey];
27049 if (--batchesToCache === 0) {
27050 delete _this._cachingSpatialArea$[key];
27053 .map(function (imageByKeyFill) {
27056 .catch(function (error) {
27057 for (var _i = 0, batch_1 = batch; _i < batch_1.length; _i++) {
27058 var batchKey = batch_1[_i];
27059 if (batchKey in spatialArea.all) {
27060 delete spatialArea.all[batchKey];
27062 if (batchKey in spatialArea.cacheNodes) {
27063 delete spatialArea.cacheNodes[batchKey];
27066 if (--batchesToCache === 0) {
27067 delete _this._cachingSpatialArea$[key];
27071 .finally(function () {
27072 if (Object.keys(spatialArea.cacheNodes).length === 0) {
27073 _this._changed$.next(_this);
27078 spatialNodes$.push(spatialNodeBatch$);
27081 for (var _i = 0, batches_1 = batches; _i < batches_1.length; _i++) {
27082 var batch = batches_1[_i];
27085 this._cachingSpatialArea$[key] = spatialNodes$;
27086 return spatialNodes$;
27089 * Cache spatial edges for a node.
27091 * @param {string} key - Key of node.
27092 * @throws {GraphMapillaryError} When the operation is not valid on the
27095 Graph.prototype.cacheSpatialEdges = function (key) {
27096 if (key in this._cachedSpatialEdges) {
27097 throw new Error_1.GraphMapillaryError("Spatial edges already cached (" + key + ").");
27099 var node = this.getNode(key);
27100 var sequence = this._sequences[node.sequenceKey];
27101 var fallbackKeys = [];
27102 var nextKey = sequence.findNextKey(node.key);
27103 var prevKey = sequence.findPrevKey(node.key);
27104 var allSpatialNodes = this._requiredSpatialArea[key].all;
27105 var potentialNodes = [];
27106 for (var spatialNodeKey in allSpatialNodes) {
27107 if (!allSpatialNodes.hasOwnProperty(spatialNodeKey)) {
27110 potentialNodes.push(allSpatialNodes[spatialNodeKey]);
27112 var potentialEdges = this._edgeCalculator.getPotentialEdges(node, potentialNodes, fallbackKeys);
27113 var edges = this._edgeCalculator.computeStepEdges(node, potentialEdges, prevKey, nextKey);
27114 edges = edges.concat(this._edgeCalculator.computeTurnEdges(node, potentialEdges));
27115 edges = edges.concat(this._edgeCalculator.computePanoEdges(node, potentialEdges));
27116 edges = edges.concat(this._edgeCalculator.computePerspectiveToPanoEdges(node, potentialEdges));
27117 edges = edges.concat(this._edgeCalculator.computeSimilarEdges(node, potentialEdges));
27118 node.cacheSpatialEdges(edges);
27119 this._cachedSpatialEdges[key] = node;
27120 delete this._requiredSpatialArea[key];
27123 * Retrieve and cache geohash tiles for a node.
27125 * @param {string} key - Key of node for which to retrieve tiles.
27126 * @returns {Observable<Graph>} Observable emitting the graph
27127 * when the tiles required for the node has been cached.
27128 * @throws {GraphMapillaryError} When the operation is not valid on the
27131 Graph.prototype.cacheTiles$ = function (key) {
27133 if (key in this._cachedNodeTiles) {
27134 throw new Error_1.GraphMapillaryError("Tiles already cached (" + key + ").");
27136 if (!(key in this._requiredNodeTiles)) {
27137 throw new Error_1.GraphMapillaryError("Tiles have not been determined (" + key + ").");
27139 var nodeTiles = this._requiredNodeTiles[key];
27140 if (nodeTiles.cache.length === 0 &&
27141 nodeTiles.caching.length === 0) {
27142 throw new Error_1.GraphMapillaryError("Tiles already cached (" + key + ").");
27144 if (!this.hasNode(key)) {
27145 throw new Error_1.GraphMapillaryError("Cannot cache tiles of node that does not exist in graph (" + key + ").");
27147 var hs = nodeTiles.cache.slice();
27148 nodeTiles.caching = this._requiredNodeTiles[key].caching.concat(hs);
27149 nodeTiles.cache = [];
27150 var cacheTiles$ = [];
27151 var _loop_2 = function(h) {
27152 var cacheTile$ = null;
27153 if (h in this_2._cachingTiles$) {
27154 cacheTile$ = this_2._cachingTiles$[h];
27157 cacheTile$ = this_2._apiV3.imagesByH$([h])
27158 .do(function (imagesByH) {
27159 var coreNodes = imagesByH[h];
27160 if (h in _this._cachedTiles) {
27163 _this._cachedTiles[h] = [];
27164 var hCache = _this._cachedTiles[h];
27165 var preStored = _this._removeFromPreStore(h);
27166 for (var index in coreNodes) {
27167 if (!coreNodes.hasOwnProperty(index)) {
27170 var coreNode = coreNodes[index];
27171 if (coreNode == null) {
27174 if (coreNode.sequence == null ||
27175 coreNode.sequence.key == null) {
27176 console.warn("Sequence missing, discarding (" + coreNode.key + ")");
27179 if (preStored != null && coreNode.key in preStored) {
27180 var node_1 = preStored[coreNode.key];
27181 delete preStored[coreNode.key];
27182 hCache.push(node_1);
27183 _this._nodeIndex.insert({ lat: node_1.latLon.lat, lon: node_1.latLon.lon, node: node_1 });
27186 var node = new Graph_1.Node(coreNode);
27188 _this._nodeIndex.insert({ lat: node.latLon.lat, lon: node.latLon.lon, node: node });
27189 _this._setNode(node);
27191 delete _this._cachingTiles$[h];
27193 .map(function (imagesByH) {
27196 .catch(function (error) {
27197 delete _this._cachingTiles$[h];
27202 this_2._cachingTiles$[h] = cacheTile$;
27204 cacheTiles$.push(cacheTile$
27205 .do(function (graph) {
27206 var index = nodeTiles.caching.indexOf(h);
27208 nodeTiles.caching.splice(index, 1);
27210 if (nodeTiles.caching.length === 0 &&
27211 nodeTiles.cache.length === 0) {
27212 delete _this._requiredNodeTiles[key];
27213 _this._cachedNodeTiles[key] = true;
27216 .catch(function (error) {
27217 var index = nodeTiles.caching.indexOf(h);
27219 nodeTiles.caching.splice(index, 1);
27221 if (nodeTiles.caching.length === 0 &&
27222 nodeTiles.cache.length === 0) {
27223 delete _this._requiredNodeTiles[key];
27224 _this._cachedNodeTiles[key] = true;
27228 .finally(function () {
27229 _this._changed$.next(_this);
27235 for (var _i = 0, _a = nodeTiles.caching; _i < _a.length; _i++) {
27239 return cacheTiles$;
27242 * Initialize the cache for a node.
27244 * @param {string} key - Key of node.
27245 * @throws {GraphMapillaryError} When the operation is not valid on the
27248 Graph.prototype.initializeCache = function (key) {
27249 if (key in this._cachedNodes) {
27250 throw new Error_1.GraphMapillaryError("Node already in cache (" + key + ").");
27252 var node = this.getNode(key);
27253 node.initializeCache(new Graph_1.NodeCache());
27254 this._cachedNodes[key] = node;
27257 * Get a value indicating if the graph is fill caching a node.
27259 * @param {string} key - Key of node.
27260 * @returns {boolean} Value indicating if the node is being fill cached.
27262 Graph.prototype.isCachingFill = function (key) {
27263 return key in this._cachingFill$;
27266 * Get a value indicating if the graph is fully caching a node.
27268 * @param {string} key - Key of node.
27269 * @returns {boolean} Value indicating if the node is being fully cached.
27271 Graph.prototype.isCachingFull = function (key) {
27272 return key in this._cachingFull$;
27275 * Get a value indicating if the graph is caching a sequence of a node.
27277 * @param {string} key - Key of node.
27278 * @returns {boolean} Value indicating if the sequence of a node is
27281 Graph.prototype.isCachingNodeSequence = function (key) {
27282 var node = this.getNode(key);
27283 return node.sequenceKey in this._cachingSequences$;
27286 * Get a value indicating if the graph is caching a sequence.
27288 * @param {string} sequenceKey - Key of sequence.
27289 * @returns {boolean} Value indicating if the sequence is
27292 Graph.prototype.isCachingSequence = function (sequenceKey) {
27293 return sequenceKey in this._cachingSequences$;
27296 * Get a value indicating if the graph is caching the tiles
27297 * required for calculating spatial edges of a node.
27299 * @param {string} key - Key of node.
27300 * @returns {boolean} Value indicating if the tiles of
27301 * a node are being cached.
27303 Graph.prototype.isCachingTiles = function (key) {
27304 return key in this._requiredNodeTiles &&
27305 this._requiredNodeTiles[key].cache.length === 0 &&
27306 this._requiredNodeTiles[key].caching.length > 0;
27309 * Get a value indicating if the cache has been initialized
27312 * @param {string} key - Key of node.
27313 * @returns {boolean} Value indicating if the cache has been
27314 * initialized for a node.
27316 Graph.prototype.hasInitializedCache = function (key) {
27317 return key in this._cachedNodes;
27320 * Get a value indicating if a node exist in the graph.
27322 * @param {string} key - Key of node.
27323 * @returns {boolean} Value indicating if a node exist in the graph.
27325 Graph.prototype.hasNode = function (key) {
27326 return key in this._nodes;
27329 * Get a value indicating if a node sequence exist in the graph.
27331 * @param {string} key - Key of node.
27332 * @returns {boolean} Value indicating if a node sequence exist
27335 Graph.prototype.hasNodeSequence = function (key) {
27336 var node = this.getNode(key);
27337 return node.sequenceKey in this._sequences;
27340 * Get a value indicating if a sequence exist in the graph.
27342 * @param {string} sequenceKey - Key of sequence.
27343 * @returns {boolean} Value indicating if a sequence exist
27346 Graph.prototype.hasSequence = function (sequenceKey) {
27347 return sequenceKey in this._sequences;
27350 * Get a value indicating if the graph has fully cached
27351 * all nodes in the spatial area of a node.
27353 * @param {string} key - Key of node.
27354 * @returns {boolean} Value indicating if the spatial area
27355 * of a node has been cached.
27357 Graph.prototype.hasSpatialArea = function (key) {
27358 if (!this.hasNode(key)) {
27359 throw new Error_1.GraphMapillaryError("Spatial area nodes cannot be determined if node not in graph (" + key + ").");
27361 if (key in this._cachedSpatialEdges) {
27364 if (key in this._requiredSpatialArea) {
27365 return Object.keys(this._requiredSpatialArea[key].cacheNodes).length === 0;
27367 var node = this.getNode(key);
27368 var bbox = this._graphCalculator.boundingBoxCorners(node.latLon, this._tileThreshold);
27369 var spatialItems = this._nodeIndex.search({
27375 var spatialNodes = {
27380 for (var _i = 0, spatialItems_1 = spatialItems; _i < spatialItems_1.length; _i++) {
27381 var spatialItem = spatialItems_1[_i];
27382 spatialNodes.all[spatialItem.node.key] = spatialItem.node;
27383 if (!spatialItem.node.full) {
27384 spatialNodes.cacheKeys.push(spatialItem.node.key);
27385 spatialNodes.cacheNodes[spatialItem.node.key] = spatialItem.node;
27388 this._requiredSpatialArea[key] = spatialNodes;
27389 return spatialNodes.cacheKeys.length === 0;
27392 * Get a value indicating if the graph has a tiles required
27395 * @param {string} key - Key of node.
27396 * @returns {boolean} Value indicating if the the tiles required
27397 * by a node has been cached.
27399 Graph.prototype.hasTiles = function (key) {
27401 if (key in this._cachedNodeTiles) {
27404 if (!this.hasNode(key)) {
27405 throw new Error_1.GraphMapillaryError("Node does not exist in graph (" + key + ").");
27407 if (!(key in this._requiredNodeTiles)) {
27408 var node = this.getNode(key);
27409 var cache = this._graphCalculator
27410 .encodeHs(node.latLon, this._tilePrecision, this._tileThreshold)
27411 .filter(function (h) {
27412 return !(h in _this._cachedTiles);
27414 this._requiredNodeTiles[key] = {
27419 return this._requiredNodeTiles[key].cache.length === 0 &&
27420 this._requiredNodeTiles[key].caching.length === 0;
27425 * @param {string} key - Key of node.
27426 * @returns {Node} Retrieved node.
27428 Graph.prototype.getNode = function (key) {
27429 return this._nodes[key];
27434 * @param {string} sequenceKey - Key of sequence.
27435 * @returns {Node} Retrieved sequence.
27437 Graph.prototype.getSequence = function (sequenceKey) {
27438 return this._sequences[sequenceKey];
27441 * Reset all spatial edges of the graph nodes.
27443 Graph.prototype.reset = function () {
27444 var spatialNodeKeys = Object.keys(this._requiredSpatialArea);
27445 for (var _i = 0, spatialNodeKeys_1 = spatialNodeKeys; _i < spatialNodeKeys_1.length; _i++) {
27446 var spatialNodeKey = spatialNodeKeys_1[_i];
27447 delete this._requiredSpatialArea[spatialNodeKey];
27449 var cachedKeys = Object.keys(this._cachedSpatialEdges);
27450 for (var _a = 0, cachedKeys_1 = cachedKeys; _a < cachedKeys_1.length; _a++) {
27451 var cachedKey = cachedKeys_1[_a];
27452 var node = this._cachedSpatialEdges[cachedKey];
27453 node.resetSpatialEdges();
27454 delete this._cachedSpatialEdges[cachedKey];
27457 Graph.prototype._cacheSequence$ = function (sequenceKey) {
27459 if (sequenceKey in this._cachingSequences$) {
27460 return this._cachingSequences$[sequenceKey];
27462 this._cachingSequences$[sequenceKey] = this._apiV3.sequenceByKey$([sequenceKey])
27463 .do(function (sequenceByKey) {
27464 if (!(sequenceKey in _this._sequences)) {
27465 _this._sequences[sequenceKey] = new Graph_1.Sequence(sequenceByKey[sequenceKey]);
27467 delete _this._cachingSequences$[sequenceKey];
27469 .map(function (sequenceByKey) {
27472 .finally(function () {
27473 if (sequenceKey in _this._cachingSequences$) {
27474 delete _this._cachingSequences$[sequenceKey];
27476 _this._changed$.next(_this);
27480 return this._cachingSequences$[sequenceKey];
27482 Graph.prototype._makeFull = function (node, fillNode) {
27483 if (fillNode.calt == null) {
27484 fillNode.calt = this._defaultAlt;
27486 if (fillNode.c_rotation == null) {
27487 fillNode.c_rotation = this._graphCalculator.rotationFromCompass(fillNode.ca, fillNode.orientation);
27489 node.makeFull(fillNode);
27491 Graph.prototype._preStore = function (h, node) {
27492 if (!(h in this._preStored)) {
27493 this._preStored[h] = {};
27495 this._preStored[h][node.key] = node;
27497 Graph.prototype._removeFromPreStore = function (h) {
27498 var preStored = null;
27499 if (h in this._preStored) {
27500 preStored = this._preStored[h];
27501 delete this._preStored[h];
27505 Graph.prototype._setNode = function (node) {
27506 var key = node.key;
27507 if (this.hasNode(key)) {
27508 throw new Error_1.GraphMapillaryError("Node already exist (" + key + ").");
27510 this._nodes[key] = node;
27514 exports.Graph = Graph;
27515 Object.defineProperty(exports, "__esModule", { value: true });
27516 exports.default = Graph;
27518 },{"../Edge":208,"../Error":209,"../Graph":211,"rbush":24,"rxjs/Subject":33,"rxjs/add/observable/from":40,"rxjs/add/operator/catch":48,"rxjs/add/operator/do":54,"rxjs/add/operator/finally":57,"rxjs/add/operator/map":60,"rxjs/add/operator/publish":66}],281:[function(require,module,exports){
27519 /// <reference path="../../typings/index.d.ts" />
27521 var geohash = require("latlon-geohash");
27522 var THREE = require("three");
27523 var Geo_1 = require("../Geo");
27524 var GeoHashDirections = (function () {
27525 function GeoHashDirections() {
27527 GeoHashDirections.n = "n";
27528 GeoHashDirections.nw = "nw";
27529 GeoHashDirections.w = "w";
27530 GeoHashDirections.sw = "sw";
27531 GeoHashDirections.s = "s";
27532 GeoHashDirections.se = "se";
27533 GeoHashDirections.e = "e";
27534 GeoHashDirections.ne = "ne";
27535 return GeoHashDirections;
27537 var GraphCalculator = (function () {
27538 function GraphCalculator(geoCoords) {
27539 this._geoCoords = geoCoords != null ? geoCoords : new Geo_1.GeoCoords();
27541 GraphCalculator.prototype.encodeH = function (latLon, precision) {
27542 if (precision === void 0) { precision = 7; }
27543 return geohash.encode(latLon.lat, latLon.lon, precision);
27545 GraphCalculator.prototype.encodeHs = function (latLon, precision, threshold) {
27546 if (precision === void 0) { precision = 7; }
27547 if (threshold === void 0) { threshold = 20; }
27548 var h = geohash.encode(latLon.lat, latLon.lon, precision);
27549 var bounds = geohash.bounds(h);
27550 var ne = bounds.ne;
27551 var sw = bounds.sw;
27552 var neighbours = geohash.neighbours(h);
27553 var bl = [0, 0, 0];
27554 var tr = this._geoCoords.geodeticToEnu(ne.lat, ne.lon, 0, sw.lat, sw.lon, 0);
27555 var position = this._geoCoords.geodeticToEnu(latLon.lat, latLon.lon, 0, sw.lat, sw.lon, 0);
27556 var left = position[0] - bl[0];
27557 var right = tr[0] - position[0];
27558 var bottom = position[1] - bl[1];
27559 var top = tr[1] - position[1];
27560 var l = left < threshold;
27561 var r = right < threshold;
27562 var b = bottom < threshold;
27563 var t = top < threshold;
27566 hs.push(neighbours[GeoHashDirections.n]);
27569 hs.push(neighbours[GeoHashDirections.nw]);
27572 hs.push(neighbours[GeoHashDirections.w]);
27575 hs.push(neighbours[GeoHashDirections.sw]);
27578 hs.push(neighbours[GeoHashDirections.s]);
27581 hs.push(neighbours[GeoHashDirections.se]);
27584 hs.push(neighbours[GeoHashDirections.e]);
27587 hs.push(neighbours[GeoHashDirections.ne]);
27591 GraphCalculator.prototype.boundingBoxCorners = function (latLon, threshold) {
27592 var bl = this._geoCoords.enuToGeodetic(-threshold, -threshold, 0, latLon.lat, latLon.lon, 0);
27593 var tr = this._geoCoords.enuToGeodetic(threshold, threshold, 0, latLon.lat, latLon.lon, 0);
27595 { lat: bl[0], lon: bl[1] },
27596 { lat: tr[0], lon: tr[1] },
27599 GraphCalculator.prototype.rotationFromCompass = function (compassAngle, orientation) {
27603 switch (orientation) {
27622 var rz = new THREE.Matrix4().makeRotationZ(z);
27623 var euler = new THREE.Euler(x, y, compassAngle * Math.PI / 180, "XYZ");
27624 var re = new THREE.Matrix4().makeRotationFromEuler(euler);
27625 var rotation = new THREE.Vector4().setAxisAngleFromRotationMatrix(re.multiply(rz));
27626 return rotation.multiplyScalar(rotation.w).toArray().slice(0, 3);
27628 return GraphCalculator;
27630 exports.GraphCalculator = GraphCalculator;
27631 Object.defineProperty(exports, "__esModule", { value: true });
27632 exports.default = GraphCalculator;
27634 },{"../Geo":210,"latlon-geohash":20,"three":157}],282:[function(require,module,exports){
27636 var Observable_1 = require("rxjs/Observable");
27637 require("rxjs/add/operator/catch");
27638 require("rxjs/add/operator/concat");
27639 require("rxjs/add/operator/do");
27640 require("rxjs/add/operator/expand");
27641 require("rxjs/add/operator/finally");
27642 require("rxjs/add/operator/first");
27643 require("rxjs/add/operator/last");
27644 require("rxjs/add/operator/map");
27645 require("rxjs/add/operator/mergeMap");
27646 require("rxjs/add/operator/publishReplay");
27648 * @class GraphService
27650 * @classdesc Represents a service for graph operations.
27652 var GraphService = (function () {
27654 * Create a new graph service instance.
27656 * @param {Graph} graph - Graph instance to be operated on.
27658 function GraphService(graph, imageLoadingService) {
27659 this._graph$ = Observable_1.Observable
27661 .concat(graph.changed$)
27664 this._graph$.subscribe();
27665 this._imageLoadingService = imageLoadingService;
27666 this._spatialSubscriptions = [];
27669 * Cache a node in the graph and retrieve it.
27671 * @description When called, the full properties of
27672 * the node are retrieved and the node cache is initialized.
27673 * After that the node assets are cached and the node
27674 * is emitted to the observable when.
27675 * In parallel to caching the node assets, the sequence and
27676 * spatial edges of the node are cached. For this, the sequence
27677 * of the node and the required tiles and spatial nodes are
27678 * retrieved. The sequence and spatial edges may be set before
27679 * or after the node is returned.
27681 * @param {string} key - Key of the node to cache.
27682 * @return {Observable<Node>} Observable emitting a single item,
27683 * the node, when it has been retrieved and its assets are cached.
27684 * @throws {Error} Propagates any IO node caching errors to the caller.
27686 GraphService.prototype.cacheNode$ = function (key) {
27688 var firstGraph$ = this._graph$
27690 .mergeMap(function (graph) {
27691 if (graph.isCachingFull(key) || !graph.hasNode(key)) {
27692 return graph.cacheFull$(key);
27694 if (graph.isCachingFill(key) || !graph.getNode(key).full) {
27695 return graph.cacheFill$(key);
27697 return Observable_1.Observable.of(graph);
27699 .do(function (graph) {
27700 if (!graph.hasInitializedCache(key)) {
27701 graph.initializeCache(key);
27706 var node$ = firstGraph$
27707 .map(function (graph) {
27708 return graph.getNode(key);
27710 .mergeMap(function (node) {
27711 return node.assetsCached ?
27712 Observable_1.Observable.of(node) :
27713 node.cacheAssets$();
27717 node$.subscribe(function (node) {
27718 _this._imageLoadingService.loadnode$.next(node);
27719 }, function (error) {
27720 console.error("Failed to cache node (" + key + ")", error);
27723 .mergeMap(function (graph) {
27724 if (graph.isCachingNodeSequence(key) || !graph.hasNodeSequence(key)) {
27725 return graph.cacheNodeSequence$(key);
27727 return Observable_1.Observable.of(graph);
27729 .do(function (graph) {
27730 if (!graph.getNode(key).sequenceEdges.cached) {
27731 graph.cacheSequenceEdges(key);
27734 .subscribe(function (graph) { return; }, function (error) {
27735 console.error("Failed to cache sequence edges (" + key + ").", error);
27737 var spatialSubscription = firstGraph$
27738 .expand(function (graph) {
27739 if (graph.hasTiles(key)) {
27740 return Observable_1.Observable.empty();
27742 return Observable_1.Observable
27743 .from(graph.cacheTiles$(key))
27744 .mergeMap(function (graph$) {
27746 .mergeMap(function (g) {
27747 if (g.isCachingTiles(key)) {
27748 return Observable_1.Observable.empty();
27750 return Observable_1.Observable.of(g);
27752 .catch(function (error, caught$) {
27753 console.error("Failed to cache tile data (" + key + ").", error);
27754 return Observable_1.Observable.empty();
27759 .mergeMap(function (graph) {
27760 if (graph.hasSpatialArea(key)) {
27761 return Observable_1.Observable.of(graph);
27763 return Observable_1.Observable
27764 .from(graph.cacheSpatialArea$(key))
27765 .mergeMap(function (graph$) {
27767 .catch(function (error, caught$) {
27768 console.error("Failed to cache spatial nodes (" + key + ").", error);
27769 return Observable_1.Observable.empty();
27774 .mergeMap(function (graph) {
27775 return graph.hasNodeSequence(key) ?
27776 Observable_1.Observable.of(graph) :
27777 graph.cacheNodeSequence$(key);
27779 .do(function (graph) {
27780 if (!graph.getNode(key).spatialEdges.cached) {
27781 graph.cacheSpatialEdges(key);
27784 .finally(function () {
27785 if (spatialSubscription == null) {
27788 _this._removeSpatialSubscription(spatialSubscription);
27790 .subscribe(function (graph) { return; }, function (error) {
27791 console.error("Failed to cache spatial edges (" + key + ").", error);
27793 if (!spatialSubscription.closed) {
27794 this._spatialSubscriptions.push(spatialSubscription);
27797 .first(function (node) {
27798 return node.assetsCached;
27802 * Cache a sequence in the graph and retrieve it.
27804 * @param {string} sequenceKey - Sequence key.
27805 * @returns {Observable<Sequence>} Observable emitting a single item,
27806 * the sequence, when it has been retrieved and its assets are cached.
27807 * @throws {Error} Propagates any IO node caching errors to the caller.
27809 GraphService.prototype.cacheSequence$ = function (sequenceKey) {
27810 return this._graph$
27812 .mergeMap(function (graph) {
27813 if (graph.isCachingSequence(sequenceKey) || !graph.hasSequence(sequenceKey)) {
27814 return graph.cacheSequence$(sequenceKey);
27816 return Observable_1.Observable.of(graph);
27818 .map(function (graph) {
27819 return graph.getSequence(sequenceKey);
27823 * Reset the spatial edges of all cached nodes and recaches the
27824 * spatial edges of the provided node.
27826 * @param {string} key - Key of the node to cache edges for after reset.
27827 * @returns {Observable<Sequence>} Observable emitting a single item,
27828 * the node, when it has been retrieved and its assets are cached after
27829 * the spatial reset.
27830 * @throws {Error} Propagates any IO node caching errors to the caller.
27832 GraphService.prototype.reset$ = function (key) {
27834 this._resetSpatialSubscriptions();
27835 return this._graph$
27837 .do(function (graph) {
27840 .mergeMap(function (graph) {
27841 return _this.cacheNode$(key);
27844 GraphService.prototype._removeSpatialSubscription = function (spatialSubscription) {
27845 var index = this._spatialSubscriptions.indexOf(spatialSubscription);
27847 this._spatialSubscriptions.splice(index, 1);
27850 GraphService.prototype._resetSpatialSubscriptions = function () {
27851 for (var _i = 0, _a = this._spatialSubscriptions; _i < _a.length; _i++) {
27852 var subscription = _a[_i];
27853 if (!subscription.closed) {
27854 subscription.unsubscribe();
27857 this._spatialSubscriptions = [];
27859 return GraphService;
27861 exports.GraphService = GraphService;
27862 Object.defineProperty(exports, "__esModule", { value: true });
27863 exports.default = GraphService;
27865 },{"rxjs/Observable":28,"rxjs/add/operator/catch":48,"rxjs/add/operator/concat":50,"rxjs/add/operator/do":54,"rxjs/add/operator/expand":55,"rxjs/add/operator/finally":57,"rxjs/add/operator/first":58,"rxjs/add/operator/last":59,"rxjs/add/operator/map":60,"rxjs/add/operator/mergeMap":63,"rxjs/add/operator/publishReplay":67}],283:[function(require,module,exports){
27867 var Observable_1 = require("rxjs/Observable");
27868 var Utils_1 = require("../Utils");
27869 var ImageLoader = (function () {
27870 function ImageLoader() {
27872 ImageLoader.loadThumbnail = function (key, imageSize) {
27873 return this._load(key, imageSize, Utils_1.Urls.thumbnail);
27875 ImageLoader.loadDynamic = function (key, imageSize) {
27876 return this._load(key, imageSize, Utils_1.Urls.dynamicImage);
27878 ImageLoader._load = function (key, size, getUrl) {
27879 return Observable_1.Observable.create(function (subscriber) {
27880 var image = new Image();
27881 image.crossOrigin = "Anonymous";
27882 var xmlHTTP = new XMLHttpRequest();
27883 xmlHTTP.open("GET", getUrl(key, size), true);
27884 xmlHTTP.responseType = "arraybuffer";
27885 xmlHTTP.onload = function (pe) {
27886 if (xmlHTTP.status !== 200) {
27887 subscriber.error(new Error("Failed to fetch image (" + key + "). Status: " + xmlHTTP.status + ", " + xmlHTTP.statusText));
27890 image.onload = function (e) {
27891 subscriber.next({ loaded: { loaded: pe.loaded, total: pe.total }, object: image });
27892 subscriber.complete();
27894 image.onerror = function (error) {
27895 subscriber.error(new Error("Failed to load image (" + key + ")"));
27897 var blob = new Blob([xmlHTTP.response]);
27898 image.src = window.URL.createObjectURL(blob);
27900 xmlHTTP.onprogress = function (pe) {
27901 subscriber.next({ loaded: { loaded: pe.loaded, total: pe.total }, object: null });
27903 xmlHTTP.onerror = function (error) {
27904 subscriber.error(new Error("Failed to fetch image (" + key + ")"));
27906 xmlHTTP.send(null);
27909 return ImageLoader;
27911 exports.ImageLoader = ImageLoader;
27912 Object.defineProperty(exports, "__esModule", { value: true });
27913 exports.default = ImageLoader;
27915 },{"../Utils":215,"rxjs/Observable":28}],284:[function(require,module,exports){
27916 /// <reference path="../../typings/index.d.ts" />
27918 var Subject_1 = require("rxjs/Subject");
27919 var ImageLoadingService = (function () {
27920 function ImageLoadingService() {
27921 this._loadnode$ = new Subject_1.Subject();
27922 this._loadstatus$ = this._loadnode$
27923 .scan(function (nodes, node) {
27924 nodes[node.key] = node.loadStatus;
27929 this._loadstatus$.subscribe();
27931 Object.defineProperty(ImageLoadingService.prototype, "loadnode$", {
27933 return this._loadnode$;
27938 Object.defineProperty(ImageLoadingService.prototype, "loadstatus$", {
27940 return this._loadstatus$;
27945 return ImageLoadingService;
27947 exports.ImageLoadingService = ImageLoadingService;
27949 },{"rxjs/Subject":33}],285:[function(require,module,exports){
27950 /// <reference path="../../typings/index.d.ts" />
27952 var Pbf = require("pbf");
27953 var MeshReader = (function () {
27954 function MeshReader() {
27956 MeshReader.read = function (buffer) {
27957 var pbf = new Pbf(buffer);
27958 return pbf.readFields(MeshReader._readMeshField, { faces: [], vertices: [] });
27960 MeshReader._readMeshField = function (tag, mesh, pbf) {
27962 mesh.vertices.push(pbf.readFloat());
27964 else if (tag === 2) {
27965 mesh.faces.push(pbf.readVarint());
27970 exports.MeshReader = MeshReader;
27972 },{"pbf":22}],286:[function(require,module,exports){
27974 require("rxjs/add/observable/combineLatest");
27975 require("rxjs/add/operator/map");
27979 * @classdesc Represents a node in the navigation graph.
27981 var Node = (function () {
27983 * Create a new node instance.
27985 * @param {ICoreNode} coreNode - Raw core node data.
27987 function Node(core) {
27988 this._cache = null;
27992 Object.defineProperty(Node.prototype, "assetsCached", {
27994 * Get assets cached.
27996 * @description The assets that need to be cached for this property
27997 * to report true are the following: fill properties, image and mesh.
27998 * The library ensures that the current node will always have the
28001 * @returns {boolean} Value indicating whether all assets have been
28005 return this._core != null &&
28006 this._fill != null &&
28007 this._cache != null &&
28008 this._cache.image != null &&
28009 this._cache.mesh != null;
28014 Object.defineProperty(Node.prototype, "alt", {
28018 * @description If SfM has not been run the computed altitude is
28019 * set to a default value of two meters.
28021 * @returns {number} Altitude, in meters.
28024 return this._fill.calt;
28029 Object.defineProperty(Node.prototype, "ca", {
28033 * @description If the SfM computed compass angle exists it will
28034 * be returned, otherwise the original EXIF compass angle.
28036 * @returns {number} Compass angle, measured in degrees.
28039 return this._fill.cca != null ? this._fill.cca : this._fill.ca;
28044 Object.defineProperty(Node.prototype, "capturedAt", {
28048 * @returns {number} Timestamp when the image was captured.
28051 return this._fill.captured_at;
28056 Object.defineProperty(Node.prototype, "computedCA", {
28060 * @description Will not be set if SfM has not been run.
28062 * @returns {number} SfM computed compass angle, measured in degrees.
28065 return this._fill.cca;
28070 Object.defineProperty(Node.prototype, "computedLatLon", {
28072 * Get computedLatLon.
28074 * @description Will not be set if SfM has not been run.
28076 * @returns {ILatLon} SfM computed latitude longitude in WGS84 datum,
28077 * measured in degrees.
28080 return this._core.cl;
28085 Object.defineProperty(Node.prototype, "focal", {
28089 * @description Will not be set if SfM has not been run.
28091 * @returns {number} SfM computed focal length.
28094 return this._fill.cfocal;
28099 Object.defineProperty(Node.prototype, "full", {
28103 * @description The library ensures that the current node will
28106 * @returns {boolean} Value indicating whether the node has all
28107 * properties filled.
28110 return this._fill != null;
28115 Object.defineProperty(Node.prototype, "fullPano", {
28119 * @returns {boolean} Value indicating whether the node is a complete
28123 return this._fill.gpano != null &&
28124 this._fill.gpano.CroppedAreaLeftPixels === 0 &&
28125 this._fill.gpano.CroppedAreaTopPixels === 0 &&
28126 this._fill.gpano.CroppedAreaImageWidthPixels === this._fill.gpano.FullPanoWidthPixels &&
28127 this._fill.gpano.CroppedAreaImageHeightPixels === this._fill.gpano.FullPanoHeightPixels;
28132 Object.defineProperty(Node.prototype, "gpano", {
28136 * @description Will not be set for non panoramic images.
28138 * @returns {IGPano} Panorama information for panorama images.
28141 return this._fill.gpano;
28146 Object.defineProperty(Node.prototype, "height", {
28150 * @returns {number} Height of original image, not adjusted
28154 return this._fill.height;
28159 Object.defineProperty(Node.prototype, "image", {
28163 * @description The image will always be set on the current node.
28165 * @returns {HTMLImageElement} Cached image element of the node.
28168 return this._cache.image;
28173 Object.defineProperty(Node.prototype, "key", {
28177 * @returns {string} Unique key of the node.
28180 return this._core.key;
28185 Object.defineProperty(Node.prototype, "latLon", {
28189 * @description If the SfM computed latitude longitude exist
28190 * it will be returned, otherwise the original EXIF latitude
28193 * @returns {ILatLon} Latitude longitude in WGS84 datum,
28194 * measured in degrees.
28197 return this._core.cl != null ? this._core.cl : this._core.l;
28202 Object.defineProperty(Node.prototype, "loadStatus", {
28206 * @returns {ILoadStatus} Value indicating the load status
28207 * of the mesh and image.
28210 return this._cache.loadStatus;
28215 Object.defineProperty(Node.prototype, "merged", {
28219 * @returns {boolean} Value indicating whether SfM has been
28220 * run on the node and the node has been merged into a
28221 * connected component.
28224 return this._fill != null &&
28225 this._fill.merge_version != null &&
28226 this._fill.merge_version > 0;
28231 Object.defineProperty(Node.prototype, "mergeCC", {
28235 * @description Will not be set if SfM has not yet been run on
28238 * @returns {number} SfM connected component key to which
28242 return this._fill.merge_cc;
28247 Object.defineProperty(Node.prototype, "mergeVersion", {
28249 * Get mergeVersion.
28251 * @returns {number} Version for which SfM was run and image was merged.
28254 return this._fill.merge_version;
28259 Object.defineProperty(Node.prototype, "mesh", {
28263 * @description The mesh will always be set on the current node.
28265 * @returns {IMesh} SfM triangulated mesh of reconstructed
28266 * atomic 3D points.
28269 return this._cache.mesh;
28274 Object.defineProperty(Node.prototype, "orientation", {
28278 * @returns {number} EXIF orientation of original image.
28281 return this._fill.orientation;
28286 Object.defineProperty(Node.prototype, "originalCA", {
28290 * @returns {number} Original EXIF compass angle, measured in
28294 return this._fill.ca;
28299 Object.defineProperty(Node.prototype, "originalLatLon", {
28301 * Get originalLatLon.
28303 * @returns {ILatLon} Original EXIF latitude longitude in
28304 * WGS84 datum, measured in degrees.
28307 return this._core.l;
28312 Object.defineProperty(Node.prototype, "pano", {
28316 * @returns {boolean} Value indicating whether the node is a panorama.
28317 * It could be a cropped or full panorama.
28320 return this._fill.gpano != null &&
28321 this._fill.gpano.FullPanoWidthPixels != null;
28326 Object.defineProperty(Node.prototype, "rotation", {
28330 * @description Will not be set if SfM has not been run.
28332 * @returns {Array<number>} Rotation vector in angle axis representation.
28335 return this._fill.c_rotation;
28340 Object.defineProperty(Node.prototype, "scale", {
28344 * @description Will not be set if SfM has not been run.
28346 * @returns {number} Scale of atomic reconstruction.
28349 return this._fill.atomic_scale;
28354 Object.defineProperty(Node.prototype, "sequenceKey", {
28358 * @returns {string} Unique key of the sequence to which
28359 * the node belongs.
28362 return this._core.sequence.key;
28367 Object.defineProperty(Node.prototype, "sequenceEdges", {
28369 * Get sequenceEdges.
28371 * @returns {IEdgeStatus} Value describing the status of the
28375 return this._cache.sequenceEdges;
28380 Object.defineProperty(Node.prototype, "sequenceEdges$", {
28382 * Get sequenceEdges$.
28384 * @returns {Observable<IEdgeStatus>} Observable emitting
28385 * values describing the status of the sequence edges.
28388 return this._cache.sequenceEdges$;
28393 Object.defineProperty(Node.prototype, "spatialEdges", {
28395 * Get spatialEdges.
28397 * @returns {IEdgeStatus} Value describing the status of the
28401 return this._cache.spatialEdges;
28406 Object.defineProperty(Node.prototype, "spatialEdges$", {
28408 * Get spatialEdges$.
28410 * @returns {Observable<IEdgeStatus>} Observable emitting
28411 * values describing the status of the spatial edges.
28414 return this._cache.spatialEdges$;
28419 Object.defineProperty(Node.prototype, "userKey", {
28423 * @returns {string} Unique key of the user who uploaded
28427 return this._fill.user.key;
28432 Object.defineProperty(Node.prototype, "username", {
28436 * @returns {string} Username of the user who uploaded
28440 return this._fill.user.username;
28445 Object.defineProperty(Node.prototype, "width", {
28449 * @returns {number} Width of original image, not
28450 * adjusted for orientation.
28453 return this._fill.width;
28459 * Cache the image and mesh assets.
28461 * @description The assets are always cached internally by the
28462 * library prior to setting a node as the current node.
28464 * @returns {Observable<Node>} Observable emitting this node whenever the
28465 * load status has changed and when the mesh or image has been fully loaded.
28467 Node.prototype.cacheAssets$ = function () {
28469 return this._cache.cacheAssets$(this.key, this.pano, this.merged)
28470 .map(function (cache) {
28475 * Cache the sequence edges.
28477 * @description The sequence edges are cached asynchronously
28478 * internally by the library.
28480 * @param {Array<IEdge>} edges - Sequence edges to cache.
28482 Node.prototype.cacheSequenceEdges = function (edges) {
28483 this._cache.cacheSequenceEdges(edges);
28486 * Cache the spatial edges.
28488 * @description The spatial edges are cached asynchronously
28489 * internally by the library.
28491 * @param {Array<IEdge>} edges - Spatial edges to cache.
28493 Node.prototype.cacheSpatialEdges = function (edges) {
28494 this._cache.cacheSpatialEdges(edges);
28497 * Dispose the node.
28499 * @description Disposes all cached assets.
28501 Node.prototype.dispose = function () {
28502 if (this._cache != null) {
28503 this._cache.dispose();
28504 this._cache = null;
28510 * Initialize the node cache.
28512 * @description The node cache is initialized internally by
28515 * @param {NodeCache} cache - The node cache to set as cache.
28517 Node.prototype.initializeCache = function (cache) {
28518 if (this._cache != null) {
28519 throw new Error("Node cache already initialized (" + this.key + ").");
28521 this._cache = cache;
28524 * Fill the node with all properties.
28526 * @description The node is filled internally by
28529 * @param {IFillNode} fill - The fill node struct.
28531 Node.prototype.makeFull = function (fill) {
28532 if (fill == null) {
28533 throw new Error("Fill can not be null.");
28538 * Reset the spatial edges.
28540 Node.prototype.resetSpatialEdges = function () {
28541 this._cache.resetSpatialEdges();
28545 exports.Node = Node;
28546 Object.defineProperty(exports, "__esModule", { value: true });
28547 exports.default = Node;
28549 },{"rxjs/add/observable/combineLatest":37,"rxjs/add/operator/map":60}],287:[function(require,module,exports){
28550 (function (Buffer){
28552 var Subject_1 = require("rxjs/Subject");
28553 var Observable_1 = require("rxjs/Observable");
28554 require("rxjs/add/observable/combineLatest");
28555 require("rxjs/add/operator/publishReplay");
28556 var Graph_1 = require("../Graph");
28557 var Utils_1 = require("../Utils");
28561 * @classdesc Represents the cached properties of a node.
28563 var NodeCache = (function () {
28565 * Create a new node cache instance.
28567 function NodeCache() {
28568 this._image = null;
28569 this._loadStatus = { loaded: 0, total: 0 };
28571 this._sequenceEdges = { cached: false, edges: [] };
28572 this._spatialEdges = { cached: false, edges: [] };
28573 this._sequenceEdgesChanged$ = new Subject_1.Subject();
28574 this._sequenceEdges$ = this._sequenceEdgesChanged$
28575 .startWith(this._sequenceEdges)
28578 this._sequenceEdgesSubscription = this._sequenceEdges$.subscribe();
28579 this._spatialEdgesChanged$ = new Subject_1.Subject();
28580 this._spatialEdges$ = this._spatialEdgesChanged$
28581 .startWith(this._spatialEdges)
28584 this._spatialEdgesSubscription = this._spatialEdges$.subscribe();
28585 this._cachingAssets$ = null;
28587 Object.defineProperty(NodeCache.prototype, "image", {
28591 * @description Will not be set when assets have not been cached
28592 * or when the object has been disposed.
28594 * @returns {HTMLImageElement} Cached image element of the node.
28597 return this._image;
28602 Object.defineProperty(NodeCache.prototype, "loadStatus", {
28606 * @returns {ILoadStatus} Value indicating the load status
28607 * of the mesh and image.
28610 return this._loadStatus;
28615 Object.defineProperty(NodeCache.prototype, "mesh", {
28619 * @description Will not be set when assets have not been cached
28620 * or when the object has been disposed.
28622 * @returns {IMesh} SfM triangulated mesh of reconstructed
28623 * atomic 3D points.
28631 Object.defineProperty(NodeCache.prototype, "sequenceEdges", {
28633 * Get sequenceEdges.
28635 * @returns {IEdgeStatus} Value describing the status of the
28639 return this._sequenceEdges;
28644 Object.defineProperty(NodeCache.prototype, "sequenceEdges$", {
28646 * Get sequenceEdges$.
28648 * @returns {Observable<IEdgeStatus>} Observable emitting
28649 * values describing the status of the sequence edges.
28652 return this._sequenceEdges$;
28657 Object.defineProperty(NodeCache.prototype, "spatialEdges", {
28659 * Get spatialEdges.
28661 * @returns {IEdgeStatus} Value describing the status of the
28665 return this._spatialEdges;
28670 Object.defineProperty(NodeCache.prototype, "spatialEdges$", {
28672 * Get spatialEdges$.
28674 * @returns {Observable<IEdgeStatus>} Observable emitting
28675 * values describing the status of the spatial edges.
28678 return this._spatialEdges$;
28684 * Cache the image and mesh assets.
28686 * @param {string} key - Key of the node to cache.
28687 * @param {boolean} pano - Value indicating whether node is a panorama.
28688 * @param {boolean} merged - Value indicating whether node is merged.
28689 * @returns {Observable<Node>} Observable emitting this node whenever the
28690 * load status has changed and when the mesh or image has been fully loaded.
28692 NodeCache.prototype.cacheAssets$ = function (key, pano, merged) {
28694 if (this._cachingAssets$ != null) {
28695 return this._cachingAssets$;
28697 this._cachingAssets$ = Observable_1.Observable
28698 .combineLatest(this._cacheImage(key, pano), this._cacheMesh(key, merged), function (imageStatus, meshStatus) {
28699 _this._loadStatus.loaded = 0;
28700 _this._loadStatus.total = 0;
28702 _this._mesh = meshStatus.object;
28703 _this._loadStatus.loaded += meshStatus.loaded.loaded;
28704 _this._loadStatus.total += meshStatus.loaded.total;
28707 _this._image = imageStatus.object;
28708 _this._loadStatus.loaded += imageStatus.loaded.loaded;
28709 _this._loadStatus.total += imageStatus.loaded.total;
28713 .finally(function () {
28714 _this._cachingAssets$ = null;
28718 return this._cachingAssets$;
28721 * Cache the sequence edges.
28723 * @param {Array<IEdge>} edges - Sequence edges to cache.
28725 NodeCache.prototype.cacheSequenceEdges = function (edges) {
28726 this._sequenceEdges = { cached: true, edges: edges };
28727 this._sequenceEdgesChanged$.next(this._sequenceEdges);
28730 * Cache the spatial edges.
28732 * @param {Array<IEdge>} edges - Spatial edges to cache.
28734 NodeCache.prototype.cacheSpatialEdges = function (edges) {
28735 this._spatialEdges = { cached: true, edges: edges };
28736 this._spatialEdgesChanged$.next(this._spatialEdges);
28739 * Dispose the node cache.
28741 * @description Disposes all cached assets and unsubscribes to
28744 NodeCache.prototype.dispose = function () {
28745 this._sequenceEdgesSubscription.unsubscribe();
28746 this._spatialEdgesSubscription.unsubscribe();
28747 this._image = null;
28749 this._loadStatus = { loaded: 0, total: 0 };
28750 this._sequenceEdges = { cached: false, edges: [] };
28751 this._spatialEdges = { cached: false, edges: [] };
28752 this._sequenceEdgesChanged$.next(this._sequenceEdges);
28753 this._spatialEdgesChanged$.next(this._spatialEdges);
28756 * Reset the spatial edges.
28758 NodeCache.prototype.resetSpatialEdges = function () {
28759 this._spatialEdges = { cached: false, edges: [] };
28760 this._spatialEdgesChanged$.next(this._spatialEdges);
28765 * @param {string} key - Key of the node to cache.
28766 * @param {boolean} pano - Value indicating whether node is a panorama.
28767 * @returns {Observable<ILoadStatusObject<HTMLImageElement>>} Observable
28768 * emitting a load status object every time the load status changes
28769 * and completes when the image is fully loaded.
28771 NodeCache.prototype._cacheImage = function (key, pano) {
28772 var imageSize = pano ?
28773 Utils_1.Settings.basePanoramaSize :
28774 Utils_1.Settings.baseImageSize;
28775 return Graph_1.ImageLoader.loadThumbnail(key, imageSize);
28780 * @param {string} key - Key of the node to cache.
28781 * @param {boolean} merged - Value indicating whether node is merged.
28782 * @returns {Observable<ILoadStatusObject<IMesh>>} Observable emitting
28783 * a load status object every time the load status changes and completes
28784 * when the mesh is fully loaded.
28786 NodeCache.prototype._cacheMesh = function (key, merged) {
28788 return Observable_1.Observable.create(function (subscriber) {
28790 subscriber.next(_this._createEmptyMeshLoadStatus());
28791 subscriber.complete();
28794 var xmlHTTP = new XMLHttpRequest();
28795 xmlHTTP.open("GET", Utils_1.Urls.protoMesh(key), true);
28796 xmlHTTP.responseType = "arraybuffer";
28797 xmlHTTP.onload = function (pe) {
28798 var mesh = xmlHTTP.status === 200 ?
28799 Graph_1.MeshReader.read(new Buffer(xmlHTTP.response)) :
28800 { faces: [], vertices: [] };
28801 subscriber.next({ loaded: { loaded: pe.loaded, total: pe.total }, object: mesh });
28802 subscriber.complete();
28804 xmlHTTP.onprogress = function (pe) {
28805 subscriber.next({ loaded: { loaded: pe.loaded, total: pe.total }, object: null });
28807 xmlHTTP.onerror = function (e) {
28808 console.error("Failed to cache mesh (" + key + ")");
28809 subscriber.next(_this._createEmptyMeshLoadStatus());
28810 subscriber.complete();
28812 xmlHTTP.send(null);
28816 * Create a load status object with an empty mesh.
28818 * @returns {ILoadStatusObject<IMesh>} Load status object
28821 NodeCache.prototype._createEmptyMeshLoadStatus = function () {
28823 loaded: { loaded: 0, total: 0 },
28824 object: { faces: [], vertices: [] },
28829 exports.NodeCache = NodeCache;
28830 Object.defineProperty(exports, "__esModule", { value: true });
28831 exports.default = NodeCache;
28833 }).call(this,require("buffer").Buffer)
28835 },{"../Graph":211,"../Utils":215,"buffer":5,"rxjs/Observable":28,"rxjs/Subject":33,"rxjs/add/observable/combineLatest":37,"rxjs/add/operator/publishReplay":67}],288:[function(require,module,exports){
28836 /// <reference path="../../typings/index.d.ts" />
28838 var _ = require("underscore");
28842 * @classdesc Represents a sequence of ordered nodes.
28844 var Sequence = (function () {
28846 * Create a new sequene instance.
28848 * @param {ISequence} sequence - Raw sequence data.
28850 function Sequence(sequence) {
28851 this._key = sequence.key;
28852 this._keys = sequence.keys;
28854 Object.defineProperty(Sequence.prototype, "key", {
28858 * @returns {string} Unique sequence key.
28866 Object.defineProperty(Sequence.prototype, "keys", {
28870 * @returns {Array<string>} Array of ordered node keys in the sequence.
28879 * Find the next node key in the sequence with respect to
28880 * the provided node key.
28882 * @param {string} key - Reference node key.
28883 * @returns {string} Next key in sequence if it exists, null otherwise.
28885 Sequence.prototype.findNextKey = function (key) {
28886 var i = _.indexOf(this._keys, key);
28887 if ((i + 1) >= this._keys.length || i === -1) {
28891 return this._keys[i + 1];
28895 * Find the previous node key in the sequence with respect to
28896 * the provided node key.
28898 * @param {string} key - Reference node key.
28899 * @returns {string} Previous key in sequence if it exists, null otherwise.
28901 Sequence.prototype.findPrevKey = function (key) {
28902 var i = _.indexOf(this._keys, key);
28903 if (i === 0 || i === -1) {
28907 return this._keys[i - 1];
28912 exports.Sequence = Sequence;
28913 Object.defineProperty(exports, "__esModule", { value: true });
28914 exports.default = Sequence;
28916 },{"underscore":158}],289:[function(require,module,exports){
28917 /// <reference path="../../../typings/index.d.ts" />
28919 var THREE = require("three");
28920 var Edge_1 = require("../../Edge");
28921 var Error_1 = require("../../Error");
28922 var Geo_1 = require("../../Geo");
28924 * @class EdgeCalculator
28926 * @classdesc Represents a class for calculating node edges.
28928 var EdgeCalculator = (function () {
28930 * Create a new edge calculator instance.
28932 * @param {EdgeCalculatorSettings} settings - Settings struct.
28933 * @param {EdgeCalculatorDirections} directions - Directions struct.
28934 * @param {EdgeCalculatorCoefficients} coefficients - Coefficients struct.
28936 function EdgeCalculator(settings, directions, coefficients) {
28937 this._spatial = new Geo_1.Spatial();
28938 this._geoCoords = new Geo_1.GeoCoords();
28939 this._settings = settings != null ? settings : new Edge_1.EdgeCalculatorSettings();
28940 this._directions = directions != null ? directions : new Edge_1.EdgeCalculatorDirections();
28941 this._coefficients = coefficients != null ? coefficients : new Edge_1.EdgeCalculatorCoefficients();
28944 * Returns the potential edges to destination nodes for a set
28945 * of nodes with respect to a source node.
28947 * @param {Node} node - Source node.
28948 * @param {Array<Node>} nodes - Potential destination nodes.
28949 * @param {Array<string>} fallbackKeys - Keys for destination nodes that should
28950 * be returned even if they do not meet the criteria for a potential edge.
28951 * @throws {ArgumentMapillaryError} If node is not full.
28953 EdgeCalculator.prototype.getPotentialEdges = function (node, potentialNodes, fallbackKeys) {
28955 throw new Error_1.ArgumentMapillaryError("Node has to be full.");
28957 if (!node.merged) {
28960 var currentDirection = this._spatial.viewingDirection(node.rotation);
28961 var currentVerticalDirection = this._spatial.angleToPlane(currentDirection.toArray(), [0, 0, 1]);
28962 var potentialEdges = [];
28963 for (var _i = 0, potentialNodes_1 = potentialNodes; _i < potentialNodes_1.length; _i++) {
28964 var potential = potentialNodes_1[_i];
28965 if (!potential.merged ||
28966 potential.key === node.key) {
28969 var enu = this._geoCoords.geodeticToEnu(potential.latLon.lat, potential.latLon.lon, potential.alt, node.latLon.lat, node.latLon.lon, node.alt);
28970 var motion = new THREE.Vector3(enu[0], enu[1], enu[2]);
28971 var distance = motion.length();
28972 if (distance > this._settings.maxDistance &&
28973 fallbackKeys.indexOf(potential.key) < 0) {
28976 var motionChange = this._spatial.angleBetweenVector2(currentDirection.x, currentDirection.y, motion.x, motion.y);
28977 var verticalMotion = this._spatial.angleToPlane(motion.toArray(), [0, 0, 1]);
28978 var direction = this._spatial.viewingDirection(potential.rotation);
28979 var directionChange = this._spatial.angleBetweenVector2(currentDirection.x, currentDirection.y, direction.x, direction.y);
28980 var verticalDirection = this._spatial.angleToPlane(direction.toArray(), [0, 0, 1]);
28981 var verticalDirectionChange = verticalDirection - currentVerticalDirection;
28982 var rotation = this._spatial.relativeRotationAngle(node.rotation, potential.rotation);
28983 var worldMotionAzimuth = this._spatial.angleBetweenVector2(1, 0, motion.x, motion.y);
28984 var sameSequence = potential.sequenceKey != null &&
28985 node.sequenceKey != null &&
28986 potential.sequenceKey === node.sequenceKey;
28987 var sameMergeCC = (potential.mergeCC == null && node.mergeCC == null) ||
28988 potential.mergeCC === node.mergeCC;
28989 var sameUser = potential.userKey === node.userKey;
28990 var potentialEdge = {
28991 capturedAt: potential.capturedAt,
28992 directionChange: directionChange,
28993 distance: distance,
28994 fullPano: potential.fullPano,
28995 key: potential.key,
28996 motionChange: motionChange,
28997 rotation: rotation,
28998 sameMergeCC: sameMergeCC,
28999 sameSequence: sameSequence,
29000 sameUser: sameUser,
29001 sequenceKey: potential.sequenceKey,
29002 verticalDirectionChange: verticalDirectionChange,
29003 verticalMotion: verticalMotion,
29004 worldMotionAzimuth: worldMotionAzimuth,
29006 potentialEdges.push(potentialEdge);
29008 return potentialEdges;
29011 * Computes the sequence edges for a node.
29013 * @param {Node} node - Source node.
29014 * @throws {ArgumentMapillaryError} If node is not full.
29016 EdgeCalculator.prototype.computeSequenceEdges = function (node, sequence) {
29018 throw new Error_1.ArgumentMapillaryError("Node has to be full.");
29020 if (node.sequenceKey !== sequence.key) {
29021 throw new Error_1.ArgumentMapillaryError("Node and sequence does not correspond.");
29024 var nextKey = sequence.findNextKey(node.key);
29025 if (nextKey != null) {
29028 direction: Edge_1.EdgeDirection.Next,
29029 worldMotionAzimuth: Number.NaN,
29035 var prevKey = sequence.findPrevKey(node.key);
29036 if (prevKey != null) {
29039 direction: Edge_1.EdgeDirection.Prev,
29040 worldMotionAzimuth: Number.NaN,
29049 * Computes the similar edges for a node.
29051 * @description Similar edges for perspective images and cropped panoramas
29052 * look roughly in the same direction and are positioned closed to the node.
29053 * Similar edges for full panoramas only target other full panoramas.
29055 * @param {Node} node - Source node.
29056 * @param {Array<IPotentialEdge>} potentialEdges - Potential edges.
29057 * @throws {ArgumentMapillaryError} If node is not full.
29059 EdgeCalculator.prototype.computeSimilarEdges = function (node, potentialEdges) {
29062 throw new Error_1.ArgumentMapillaryError("Node has to be full.");
29064 var nodeFullPano = node.fullPano;
29065 var sequenceGroups = {};
29066 for (var _i = 0, potentialEdges_1 = potentialEdges; _i < potentialEdges_1.length; _i++) {
29067 var potentialEdge = potentialEdges_1[_i];
29068 if (potentialEdge.sequenceKey == null) {
29071 if (potentialEdge.sameSequence ||
29072 !potentialEdge.sameMergeCC) {
29075 if (nodeFullPano) {
29076 if (!potentialEdge.fullPano) {
29081 if (!potentialEdge.fullPano &&
29082 Math.abs(potentialEdge.directionChange) > this._settings.similarMaxDirectionChange) {
29086 if (potentialEdge.distance > this._settings.similarMaxDistance) {
29089 if (potentialEdge.sameUser &&
29090 Math.abs(potentialEdge.capturedAt - node.capturedAt) <
29091 this._settings.similarMinTimeDifference) {
29094 if (sequenceGroups[potentialEdge.sequenceKey] == null) {
29095 sequenceGroups[potentialEdge.sequenceKey] = [];
29097 sequenceGroups[potentialEdge.sequenceKey].push(potentialEdge);
29099 var similarEdges = [];
29100 var calculateScore = node.fullPano ?
29101 function (potentialEdge) {
29102 return potentialEdge.distance;
29104 function (potentialEdge) {
29105 return _this._coefficients.similarDistance * potentialEdge.distance +
29106 _this._coefficients.similarRotation * potentialEdge.rotation;
29108 for (var sequenceKey in sequenceGroups) {
29109 if (!sequenceGroups.hasOwnProperty(sequenceKey)) {
29112 var lowestScore = Number.MAX_VALUE;
29113 var similarEdge = null;
29114 for (var _a = 0, _b = sequenceGroups[sequenceKey]; _a < _b.length; _a++) {
29115 var potentialEdge = _b[_a];
29116 var score = calculateScore(potentialEdge);
29117 if (score < lowestScore) {
29118 lowestScore = score;
29119 similarEdge = potentialEdge;
29122 if (similarEdge == null) {
29125 similarEdges.push(similarEdge);
29127 return similarEdges
29128 .map(function (potentialEdge) {
29131 direction: Edge_1.EdgeDirection.Similar,
29132 worldMotionAzimuth: potentialEdge.worldMotionAzimuth,
29135 to: potentialEdge.key,
29140 * Computes the step edges for a perspective node.
29142 * @param {Node} node - Source node.
29143 * @param {Array<IPotentialEdge>} potentialEdges - Potential edges.
29144 * @param {string} prevKey - Key of previous node in sequence.
29145 * @param {string} prevKey - Key of next node in sequence.
29146 * @throws {ArgumentMapillaryError} If node is not full.
29148 EdgeCalculator.prototype.computeStepEdges = function (node, potentialEdges, prevKey, nextKey) {
29150 throw new Error_1.ArgumentMapillaryError("Node has to be full.");
29153 if (node.fullPano) {
29156 for (var k in this._directions.steps) {
29157 if (!this._directions.steps.hasOwnProperty(k)) {
29160 var step = this._directions.steps[k];
29161 var lowestScore = Number.MAX_VALUE;
29163 var fallback = null;
29164 for (var _i = 0, potentialEdges_2 = potentialEdges; _i < potentialEdges_2.length; _i++) {
29165 var potential = potentialEdges_2[_i];
29166 if (potential.fullPano) {
29169 if (Math.abs(potential.directionChange) > this._settings.stepMaxDirectionChange) {
29172 var motionDifference = this._spatial.angleDifference(step.motionChange, potential.motionChange);
29173 var directionMotionDifference = this._spatial.angleDifference(potential.directionChange, motionDifference);
29174 var drift = Math.max(Math.abs(motionDifference), Math.abs(directionMotionDifference));
29175 if (Math.abs(drift) > this._settings.stepMaxDrift) {
29178 var potentialKey = potential.key;
29179 if (step.useFallback && (potentialKey === prevKey || potentialKey === nextKey)) {
29180 fallback = potential;
29182 if (potential.distance > this._settings.stepMaxDistance) {
29185 motionDifference = Math.sqrt(motionDifference * motionDifference +
29186 potential.verticalMotion * potential.verticalMotion);
29187 var score = this._coefficients.stepPreferredDistance *
29188 Math.abs(potential.distance - this._settings.stepPreferredDistance) /
29189 this._settings.stepMaxDistance +
29190 this._coefficients.stepMotion * motionDifference / this._settings.stepMaxDrift +
29191 this._coefficients.stepRotation * potential.rotation / this._settings.stepMaxDirectionChange +
29192 this._coefficients.stepSequencePenalty * (potential.sameSequence ? 0 : 1) +
29193 this._coefficients.stepMergeCCPenalty * (potential.sameMergeCC ? 0 : 1);
29194 if (score < lowestScore) {
29195 lowestScore = score;
29199 edge = edge == null ? fallback : edge;
29200 if (edge != null) {
29203 direction: step.direction,
29204 worldMotionAzimuth: edge.worldMotionAzimuth,
29214 * Computes the turn edges for a perspective node.
29216 * @param {Node} node - Source node.
29217 * @param {Array<IPotentialEdge>} potentialEdges - Potential edges.
29218 * @throws {ArgumentMapillaryError} If node is not full.
29220 EdgeCalculator.prototype.computeTurnEdges = function (node, potentialEdges) {
29222 throw new Error_1.ArgumentMapillaryError("Node has to be full.");
29225 if (node.fullPano) {
29228 for (var k in this._directions.turns) {
29229 if (!this._directions.turns.hasOwnProperty(k)) {
29232 var turn = this._directions.turns[k];
29233 var lowestScore = Number.MAX_VALUE;
29235 for (var _i = 0, potentialEdges_3 = potentialEdges; _i < potentialEdges_3.length; _i++) {
29236 var potential = potentialEdges_3[_i];
29237 if (potential.fullPano) {
29240 if (potential.distance > this._settings.turnMaxDistance) {
29243 var rig = turn.direction !== Edge_1.EdgeDirection.TurnU &&
29244 potential.distance < this._settings.turnMaxRigDistance &&
29245 Math.abs(potential.directionChange) > this._settings.turnMinRigDirectionChange;
29246 var directionDifference = this._spatial.angleDifference(turn.directionChange, potential.directionChange);
29247 var score = void 0;
29249 potential.directionChange * turn.directionChange > 0 &&
29250 Math.abs(potential.directionChange) < Math.abs(turn.directionChange)) {
29251 score = -Math.PI / 2 + Math.abs(potential.directionChange);
29254 if (Math.abs(directionDifference) > this._settings.turnMaxDirectionChange) {
29257 var motionDifference = turn.motionChange ?
29258 this._spatial.angleDifference(turn.motionChange, potential.motionChange) : 0;
29259 motionDifference = Math.sqrt(motionDifference * motionDifference +
29260 potential.verticalMotion * potential.verticalMotion);
29262 this._coefficients.turnDistance * potential.distance /
29263 this._settings.turnMaxDistance +
29264 this._coefficients.turnMotion * motionDifference / Math.PI +
29265 this._coefficients.turnSequencePenalty * (potential.sameSequence ? 0 : 1) +
29266 this._coefficients.turnMergeCCPenalty * (potential.sameMergeCC ? 0 : 1);
29268 if (score < lowestScore) {
29269 lowestScore = score;
29273 if (edge != null) {
29276 direction: turn.direction,
29277 worldMotionAzimuth: edge.worldMotionAzimuth,
29287 * Computes the pano edges for a perspective node.
29289 * @param {Node} node - Source node.
29290 * @param {Array<IPotentialEdge>} potentialEdges - Potential edges.
29291 * @throws {ArgumentMapillaryError} If node is not full.
29293 EdgeCalculator.prototype.computePerspectiveToPanoEdges = function (node, potentialEdges) {
29295 throw new Error_1.ArgumentMapillaryError("Node has to be full.");
29297 if (node.fullPano) {
29300 var lowestScore = Number.MAX_VALUE;
29302 for (var _i = 0, potentialEdges_4 = potentialEdges; _i < potentialEdges_4.length; _i++) {
29303 var potential = potentialEdges_4[_i];
29304 if (!potential.fullPano) {
29307 var score = this._coefficients.panoPreferredDistance *
29308 Math.abs(potential.distance - this._settings.panoPreferredDistance) /
29309 this._settings.panoMaxDistance +
29310 this._coefficients.panoMotion * Math.abs(potential.motionChange) / Math.PI +
29311 this._coefficients.panoMergeCCPenalty * (potential.sameMergeCC ? 0 : 1);
29312 if (score < lowestScore) {
29313 lowestScore = score;
29317 if (edge == null) {
29323 direction: Edge_1.EdgeDirection.Pano,
29324 worldMotionAzimuth: edge.worldMotionAzimuth,
29332 * Computes the pano and step edges for a pano node.
29334 * @param {Node} node - Source node.
29335 * @param {Array<IPotentialEdge>} potentialEdges - Potential edges.
29336 * @throws {ArgumentMapillaryError} If node is not full.
29338 EdgeCalculator.prototype.computePanoEdges = function (node, potentialEdges) {
29340 throw new Error_1.ArgumentMapillaryError("Node has to be full.");
29342 if (!node.fullPano) {
29345 var panoEdges = [];
29346 var potentialPanos = [];
29347 var potentialSteps = [];
29348 for (var _i = 0, potentialEdges_5 = potentialEdges; _i < potentialEdges_5.length; _i++) {
29349 var potential = potentialEdges_5[_i];
29350 if (potential.distance > this._settings.panoMaxDistance) {
29353 if (potential.fullPano) {
29354 if (potential.distance < this._settings.panoMinDistance) {
29357 potentialPanos.push(potential);
29360 for (var k in this._directions.panos) {
29361 if (!this._directions.panos.hasOwnProperty(k)) {
29364 var pano = this._directions.panos[k];
29365 var turn = this._spatial.angleDifference(potential.directionChange, potential.motionChange);
29366 var turnChange = this._spatial.angleDifference(pano.directionChange, turn);
29367 if (Math.abs(turnChange) > this._settings.panoMaxStepTurnChange) {
29370 potentialSteps.push([pano.direction, potential]);
29371 // break if step direction found
29376 var maxRotationDifference = Math.PI / this._settings.panoMaxItems;
29377 var occupiedAngles = [];
29378 var stepAngles = [];
29379 for (var index = 0; index < this._settings.panoMaxItems; index++) {
29380 var rotation = index / this._settings.panoMaxItems * 2 * Math.PI;
29381 var lowestScore = Number.MAX_VALUE;
29383 for (var _a = 0, potentialPanos_1 = potentialPanos; _a < potentialPanos_1.length; _a++) {
29384 var potential = potentialPanos_1[_a];
29385 var motionDifference = this._spatial.angleDifference(rotation, potential.motionChange);
29386 if (Math.abs(motionDifference) > maxRotationDifference) {
29389 var occupiedDifference = Number.MAX_VALUE;
29390 for (var _b = 0, occupiedAngles_1 = occupiedAngles; _b < occupiedAngles_1.length; _b++) {
29391 var occupiedAngle = occupiedAngles_1[_b];
29392 var difference = Math.abs(this._spatial.angleDifference(occupiedAngle, potential.motionChange));
29393 if (difference < occupiedDifference) {
29394 occupiedDifference = difference;
29397 if (occupiedDifference <= maxRotationDifference) {
29400 var score = this._coefficients.panoPreferredDistance *
29401 Math.abs(potential.distance - this._settings.panoPreferredDistance) /
29402 this._settings.panoMaxDistance +
29403 this._coefficients.panoMotion * Math.abs(motionDifference) / maxRotationDifference +
29404 this._coefficients.panoSequencePenalty * (potential.sameSequence ? 0 : 1) +
29405 this._coefficients.panoMergeCCPenalty * (potential.sameMergeCC ? 0 : 1);
29406 if (score < lowestScore) {
29407 lowestScore = score;
29411 if (edge != null) {
29412 occupiedAngles.push(edge.motionChange);
29415 direction: Edge_1.EdgeDirection.Pano,
29416 worldMotionAzimuth: edge.worldMotionAzimuth,
29423 stepAngles.push(rotation);
29426 var occupiedStepAngles = {};
29427 occupiedStepAngles[Edge_1.EdgeDirection.Pano] = occupiedAngles;
29428 occupiedStepAngles[Edge_1.EdgeDirection.StepForward] = [];
29429 occupiedStepAngles[Edge_1.EdgeDirection.StepLeft] = [];
29430 occupiedStepAngles[Edge_1.EdgeDirection.StepBackward] = [];
29431 occupiedStepAngles[Edge_1.EdgeDirection.StepRight] = [];
29432 for (var _c = 0, stepAngles_1 = stepAngles; _c < stepAngles_1.length; _c++) {
29433 var stepAngle = stepAngles_1[_c];
29434 var occupations = [];
29435 for (var k in this._directions.panos) {
29436 if (!this._directions.panos.hasOwnProperty(k)) {
29439 var pano = this._directions.panos[k];
29440 var allOccupiedAngles = occupiedStepAngles[Edge_1.EdgeDirection.Pano]
29441 .concat(occupiedStepAngles[pano.direction])
29442 .concat(occupiedStepAngles[pano.prev])
29443 .concat(occupiedStepAngles[pano.next]);
29444 var lowestScore = Number.MAX_VALUE;
29446 for (var _d = 0, potentialSteps_1 = potentialSteps; _d < potentialSteps_1.length; _d++) {
29447 var potential = potentialSteps_1[_d];
29448 if (potential[0] !== pano.direction) {
29451 var motionChange = this._spatial.angleDifference(stepAngle, potential[1].motionChange);
29452 if (Math.abs(motionChange) > maxRotationDifference) {
29455 var minOccupiedDifference = Number.MAX_VALUE;
29456 for (var _e = 0, allOccupiedAngles_1 = allOccupiedAngles; _e < allOccupiedAngles_1.length; _e++) {
29457 var occupiedAngle = allOccupiedAngles_1[_e];
29458 var occupiedDifference = Math.abs(this._spatial.angleDifference(occupiedAngle, potential[1].motionChange));
29459 if (occupiedDifference < minOccupiedDifference) {
29460 minOccupiedDifference = occupiedDifference;
29463 if (minOccupiedDifference <= maxRotationDifference) {
29466 var score = this._coefficients.panoPreferredDistance *
29467 Math.abs(potential[1].distance - this._settings.panoPreferredDistance) /
29468 this._settings.panoMaxDistance +
29469 this._coefficients.panoMotion * Math.abs(motionChange) / maxRotationDifference +
29470 this._coefficients.panoMergeCCPenalty * (potential[1].sameMergeCC ? 0 : 1);
29471 if (score < lowestScore) {
29472 lowestScore = score;
29476 if (edge != null) {
29477 occupations.push(edge);
29480 direction: edge[0],
29481 worldMotionAzimuth: edge[1].worldMotionAzimuth,
29488 for (var _f = 0, occupations_1 = occupations; _f < occupations_1.length; _f++) {
29489 var occupation = occupations_1[_f];
29490 occupiedStepAngles[occupation[0]].push(occupation[1].motionChange);
29495 return EdgeCalculator;
29497 exports.EdgeCalculator = EdgeCalculator;
29498 Object.defineProperty(exports, "__esModule", { value: true });
29499 exports.default = EdgeCalculator;
29501 },{"../../Edge":208,"../../Error":209,"../../Geo":210,"three":157}],290:[function(require,module,exports){
29503 var EdgeCalculatorCoefficients = (function () {
29504 function EdgeCalculatorCoefficients() {
29505 this.panoPreferredDistance = 2;
29506 this.panoMotion = 2;
29507 this.panoSequencePenalty = 1;
29508 this.panoMergeCCPenalty = 4;
29509 this.stepPreferredDistance = 4;
29510 this.stepMotion = 3;
29511 this.stepRotation = 4;
29512 this.stepSequencePenalty = 2;
29513 this.stepMergeCCPenalty = 6;
29514 this.similarDistance = 2;
29515 this.similarRotation = 3;
29516 this.turnDistance = 4;
29517 this.turnMotion = 2;
29518 this.turnSequencePenalty = 1;
29519 this.turnMergeCCPenalty = 4;
29521 return EdgeCalculatorCoefficients;
29523 exports.EdgeCalculatorCoefficients = EdgeCalculatorCoefficients;
29524 Object.defineProperty(exports, "__esModule", { value: true });
29525 exports.default = EdgeCalculatorCoefficients;
29527 },{}],291:[function(require,module,exports){
29529 var Edge_1 = require("../../Edge");
29530 var EdgeCalculatorDirections = (function () {
29531 function EdgeCalculatorDirections() {
29535 this.steps[Edge_1.EdgeDirection.StepForward] = {
29536 direction: Edge_1.EdgeDirection.StepForward,
29540 this.steps[Edge_1.EdgeDirection.StepBackward] = {
29541 direction: Edge_1.EdgeDirection.StepBackward,
29542 motionChange: Math.PI,
29545 this.steps[Edge_1.EdgeDirection.StepLeft] = {
29546 direction: Edge_1.EdgeDirection.StepLeft,
29547 motionChange: Math.PI / 2,
29548 useFallback: false,
29550 this.steps[Edge_1.EdgeDirection.StepRight] = {
29551 direction: Edge_1.EdgeDirection.StepRight,
29552 motionChange: -Math.PI / 2,
29553 useFallback: false,
29555 this.turns[Edge_1.EdgeDirection.TurnLeft] = {
29556 direction: Edge_1.EdgeDirection.TurnLeft,
29557 directionChange: Math.PI / 2,
29558 motionChange: Math.PI / 4,
29560 this.turns[Edge_1.EdgeDirection.TurnRight] = {
29561 direction: Edge_1.EdgeDirection.TurnRight,
29562 directionChange: -Math.PI / 2,
29563 motionChange: -Math.PI / 4,
29565 this.turns[Edge_1.EdgeDirection.TurnU] = {
29566 direction: Edge_1.EdgeDirection.TurnU,
29567 directionChange: Math.PI,
29568 motionChange: null,
29570 this.panos[Edge_1.EdgeDirection.StepForward] = {
29571 direction: Edge_1.EdgeDirection.StepForward,
29572 directionChange: 0,
29573 next: Edge_1.EdgeDirection.StepLeft,
29574 prev: Edge_1.EdgeDirection.StepRight,
29576 this.panos[Edge_1.EdgeDirection.StepBackward] = {
29577 direction: Edge_1.EdgeDirection.StepBackward,
29578 directionChange: Math.PI,
29579 next: Edge_1.EdgeDirection.StepRight,
29580 prev: Edge_1.EdgeDirection.StepLeft,
29582 this.panos[Edge_1.EdgeDirection.StepLeft] = {
29583 direction: Edge_1.EdgeDirection.StepLeft,
29584 directionChange: Math.PI / 2,
29585 next: Edge_1.EdgeDirection.StepBackward,
29586 prev: Edge_1.EdgeDirection.StepForward,
29588 this.panos[Edge_1.EdgeDirection.StepRight] = {
29589 direction: Edge_1.EdgeDirection.StepRight,
29590 directionChange: -Math.PI / 2,
29591 next: Edge_1.EdgeDirection.StepForward,
29592 prev: Edge_1.EdgeDirection.StepBackward,
29595 return EdgeCalculatorDirections;
29597 exports.EdgeCalculatorDirections = EdgeCalculatorDirections;
29599 },{"../../Edge":208}],292:[function(require,module,exports){
29601 var EdgeCalculatorSettings = (function () {
29602 function EdgeCalculatorSettings() {
29603 this.panoMinDistance = 0.1;
29604 this.panoMaxDistance = 20;
29605 this.panoPreferredDistance = 5;
29606 this.panoMaxItems = 4;
29607 this.panoMaxStepTurnChange = Math.PI / 8;
29608 this.rotationMaxDistance = this.turnMaxRigDistance;
29609 this.rotationMaxDirectionChange = Math.PI / 6;
29610 this.rotationMaxVerticalDirectionChange = Math.PI / 8;
29611 this.similarMaxDirectionChange = Math.PI / 8;
29612 this.similarMaxDistance = 12;
29613 this.similarMinTimeDifference = 12 * 3600 * 1000;
29614 this.stepMaxDistance = 20;
29615 this.stepMaxDirectionChange = Math.PI / 6;
29616 this.stepMaxDrift = Math.PI / 6;
29617 this.stepPreferredDistance = 4;
29618 this.turnMaxDistance = 15;
29619 this.turnMaxDirectionChange = 2 * Math.PI / 9;
29620 this.turnMaxRigDistance = 0.65;
29621 this.turnMinRigDirectionChange = Math.PI / 6;
29623 Object.defineProperty(EdgeCalculatorSettings.prototype, "maxDistance", {
29625 return Math.max(this.panoMaxDistance, this.similarMaxDistance, this.stepMaxDistance, this.turnMaxDistance);
29630 return EdgeCalculatorSettings;
29632 exports.EdgeCalculatorSettings = EdgeCalculatorSettings;
29633 Object.defineProperty(exports, "__esModule", { value: true });
29634 exports.default = EdgeCalculatorSettings;
29636 },{}],293:[function(require,module,exports){
29639 * Enumeration for edge directions
29642 * @description Directions for edges in node graph describing
29643 * sequence, spatial and node type relations between nodes.
29645 (function (EdgeDirection) {
29647 * Next node in the sequence.
29649 EdgeDirection[EdgeDirection["Next"] = 0] = "Next";
29651 * Previous node in the sequence.
29653 EdgeDirection[EdgeDirection["Prev"] = 1] = "Prev";
29655 * Step to the left keeping viewing direction.
29657 EdgeDirection[EdgeDirection["StepLeft"] = 2] = "StepLeft";
29659 * Step to the right keeping viewing direction.
29661 EdgeDirection[EdgeDirection["StepRight"] = 3] = "StepRight";
29663 * Step forward keeping viewing direction.
29665 EdgeDirection[EdgeDirection["StepForward"] = 4] = "StepForward";
29667 * Step backward keeping viewing direction.
29669 EdgeDirection[EdgeDirection["StepBackward"] = 5] = "StepBackward";
29671 * Turn 90 degrees counter clockwise.
29673 EdgeDirection[EdgeDirection["TurnLeft"] = 6] = "TurnLeft";
29675 * Turn 90 degrees clockwise.
29677 EdgeDirection[EdgeDirection["TurnRight"] = 7] = "TurnRight";
29679 * Turn 180 degrees.
29681 EdgeDirection[EdgeDirection["TurnU"] = 8] = "TurnU";
29683 * Panorama in general direction.
29685 EdgeDirection[EdgeDirection["Pano"] = 9] = "Pano";
29687 * Looking in roughly the same direction at rougly the same position.
29689 EdgeDirection[EdgeDirection["Similar"] = 10] = "Similar";
29690 })(exports.EdgeDirection || (exports.EdgeDirection = {}));
29691 var EdgeDirection = exports.EdgeDirection;
29694 },{}],294:[function(require,module,exports){
29695 /// <reference path="../../typings/index.d.ts" />
29697 var _ = require("underscore");
29698 var vd = require("virtual-dom");
29699 var Subject_1 = require("rxjs/Subject");
29700 require("rxjs/add/operator/combineLatest");
29701 require("rxjs/add/operator/distinctUntilChanged");
29702 require("rxjs/add/operator/filter");
29703 require("rxjs/add/operator/map");
29704 require("rxjs/add/operator/pluck");
29705 require("rxjs/add/operator/scan");
29706 var Render_1 = require("../Render");
29707 var DOMRenderer = (function () {
29708 function DOMRenderer(element, renderService, currentFrame$) {
29709 this._adaptiveOperation$ = new Subject_1.Subject();
29710 this._render$ = new Subject_1.Subject();
29711 this._renderAdaptive$ = new Subject_1.Subject();
29712 this._renderService = renderService;
29713 this._currentFrame$ = currentFrame$;
29714 var rootNode = vd.create(vd.h("div.domRenderer", []));
29715 element.appendChild(rootNode);
29716 this._offset$ = this._adaptiveOperation$
29717 .scan(function (adaptive, operation) {
29718 return operation(adaptive);
29720 elementHeight: element.offsetHeight,
29721 elementWidth: element.offsetWidth,
29723 renderMode: Render_1.RenderMode.Fill,
29725 .filter(function (adaptive) {
29726 return adaptive.imageAspect > 0 && adaptive.elementWidth > 0 && adaptive.elementHeight > 0;
29728 .map(function (adaptive) {
29729 var elementAspect = adaptive.elementWidth / adaptive.elementHeight;
29730 var ratio = adaptive.imageAspect / elementAspect;
29731 var verticalOffset = 0;
29732 var horizontalOffset = 0;
29733 if (adaptive.renderMode === Render_1.RenderMode.Letterbox) {
29734 if (adaptive.imageAspect > elementAspect) {
29735 verticalOffset = adaptive.elementHeight * (1 - 1 / ratio) / 2;
29738 horizontalOffset = adaptive.elementWidth * (1 - ratio) / 2;
29742 if (adaptive.imageAspect > elementAspect) {
29743 horizontalOffset = -adaptive.elementWidth * (ratio - 1) / 2;
29746 verticalOffset = -adaptive.elementHeight * (1 / ratio - 1) / 2;
29750 bottom: verticalOffset,
29751 left: horizontalOffset,
29752 right: horizontalOffset,
29753 top: verticalOffset,
29756 this._currentFrame$
29757 .filter(function (frame) {
29758 return frame.state.currentNode != null;
29760 .distinctUntilChanged(function (k1, k2) {
29762 }, function (frame) {
29763 return frame.state.currentNode.key;
29765 .map(function (frame) {
29766 return frame.state.currentTransform.basicAspect;
29768 .map(function (aspect) {
29769 return function (adaptive) {
29770 adaptive.imageAspect = aspect;
29774 .subscribe(this._adaptiveOperation$);
29775 this._renderAdaptive$
29776 .scan(function (vNodeHashes, vNodeHash) {
29777 if (vNodeHash.vnode == null) {
29778 delete vNodeHashes[vNodeHash.name];
29781 vNodeHashes[vNodeHash.name] = vNodeHash.vnode;
29783 return vNodeHashes;
29785 .combineLatest(this._offset$)
29786 .map(function (vo) {
29787 var vNodes = _.values(vo[0]);
29788 var offset = vo[1];
29791 bottom: offset.bottom + "px",
29792 left: offset.left + "px",
29793 position: "absolute",
29794 right: offset.right + "px",
29795 top: offset.top + "px",
29800 name: "adaptiveDomRenderer",
29801 vnode: vd.h("div.adaptiveDomRenderer", properties, vNodes),
29804 .subscribe(this._render$);
29805 this._vNode$ = this._render$
29806 .scan(function (vNodeHashes, vNodeHash) {
29807 if (vNodeHash.vnode == null) {
29808 delete vNodeHashes[vNodeHash.name];
29811 vNodeHashes[vNodeHash.name] = vNodeHash.vnode;
29813 return vNodeHashes;
29815 .map(function (vNodeHashes) {
29816 var vNodes = _.values(vNodeHashes);
29817 return vd.h("div.domRenderer", vNodes);
29819 this._vPatch$ = this._vNode$
29820 .scan(function (nodePatch, vNode) {
29821 nodePatch.vpatch = vd.diff(nodePatch.vnode, vNode);
29822 nodePatch.vnode = vNode;
29824 }, { vnode: vd.h("div.domRenderer", []), vpatch: null })
29826 this._element$ = this._vPatch$
29827 .scan(function (oldElement, vPatch) {
29828 return vd.patch(oldElement, vPatch);
29832 this._element$.subscribe();
29833 this._renderService.size$
29834 .map(function (size) {
29835 return function (adaptive) {
29836 adaptive.elementWidth = size.width;
29837 adaptive.elementHeight = size.height;
29841 .subscribe(this._adaptiveOperation$);
29842 this._renderService.renderMode$
29843 .map(function (renderMode) {
29844 return function (adaptive) {
29845 adaptive.renderMode = renderMode;
29849 .subscribe(this._adaptiveOperation$);
29851 Object.defineProperty(DOMRenderer.prototype, "element$", {
29853 return this._element$;
29858 Object.defineProperty(DOMRenderer.prototype, "render$", {
29860 return this._render$;
29865 Object.defineProperty(DOMRenderer.prototype, "renderAdaptive$", {
29867 return this._renderAdaptive$;
29872 DOMRenderer.prototype.clear = function (name) {
29873 this._renderAdaptive$.next({ name: name, vnode: null });
29874 this._render$.next({ name: name, vnode: null });
29876 return DOMRenderer;
29878 exports.DOMRenderer = DOMRenderer;
29879 Object.defineProperty(exports, "__esModule", { value: true });
29880 exports.default = DOMRenderer;
29882 },{"../Render":213,"rxjs/Subject":33,"rxjs/add/operator/combineLatest":49,"rxjs/add/operator/distinctUntilChanged":53,"rxjs/add/operator/filter":56,"rxjs/add/operator/map":60,"rxjs/add/operator/pluck":65,"rxjs/add/operator/scan":68,"underscore":158,"virtual-dom":163}],295:[function(require,module,exports){
29884 (function (GLRenderStage) {
29885 GLRenderStage[GLRenderStage["Background"] = 0] = "Background";
29886 GLRenderStage[GLRenderStage["Foreground"] = 1] = "Foreground";
29887 })(exports.GLRenderStage || (exports.GLRenderStage = {}));
29888 var GLRenderStage = exports.GLRenderStage;
29889 Object.defineProperty(exports, "__esModule", { value: true });
29890 exports.default = GLRenderStage;
29892 },{}],296:[function(require,module,exports){
29893 /// <reference path="../../typings/index.d.ts" />
29895 var THREE = require("three");
29896 var Observable_1 = require("rxjs/Observable");
29897 var Subject_1 = require("rxjs/Subject");
29898 require("rxjs/add/observable/combineLatest");
29899 require("rxjs/add/operator/distinctUntilChanged");
29900 require("rxjs/add/operator/filter");
29901 require("rxjs/add/operator/first");
29902 require("rxjs/add/operator/map");
29903 require("rxjs/add/operator/merge");
29904 require("rxjs/add/operator/mergeMap");
29905 require("rxjs/add/operator/scan");
29906 require("rxjs/add/operator/share");
29907 require("rxjs/add/operator/startWith");
29908 var Render_1 = require("../Render");
29909 var GLRenderer = (function () {
29910 function GLRenderer(renderService) {
29912 this._renderFrame$ = new Subject_1.Subject();
29913 this._renderCameraOperation$ = new Subject_1.Subject();
29914 this._render$ = new Subject_1.Subject();
29915 this._clear$ = new Subject_1.Subject();
29916 this._renderOperation$ = new Subject_1.Subject();
29917 this._rendererOperation$ = new Subject_1.Subject();
29918 this._eraserOperation$ = new Subject_1.Subject();
29919 this._renderService = renderService;
29920 this._renderer$ = this._rendererOperation$
29921 .scan(function (renderer, operation) {
29922 return operation(renderer);
29923 }, { needsRender: false, renderer: null });
29924 this._renderCollection$ = this._renderOperation$
29925 .scan(function (hashes, operation) {
29926 return operation(hashes);
29929 this._renderCamera$ = this._renderCameraOperation$
29930 .scan(function (rc, operation) {
29931 return operation(rc);
29932 }, { frameId: -1, needsRender: false, perspective: null });
29933 this._eraser$ = this._eraserOperation$
29934 .startWith(function (eraser) {
29937 .scan(function (eraser, operation) {
29938 return operation(eraser);
29939 }, { needsRender: false });
29940 Observable_1.Observable
29941 .combineLatest([this._renderer$, this._renderCollection$, this._renderCamera$, this._eraser$], function (renderer, hashes, rc, eraser) {
29942 var renders = Object.keys(hashes)
29943 .map(function (key) {
29944 return hashes[key];
29946 return { camera: rc, eraser: eraser, renderer: renderer, renders: renders };
29948 .filter(function (co) {
29949 var needsRender = co.renderer.needsRender ||
29950 co.camera.needsRender ||
29951 co.eraser.needsRender;
29952 var frameId = co.camera.frameId;
29953 for (var _i = 0, _a = co.renders; _i < _a.length; _i++) {
29954 var render = _a[_i];
29955 if (render.frameId !== frameId) {
29958 needsRender = needsRender || render.needsRender;
29960 return needsRender;
29962 .distinctUntilChanged(function (n1, n2) {
29965 return co.eraser.needsRender ? -1 : co.camera.frameId;
29967 .subscribe(function (co) {
29968 co.renderer.needsRender = false;
29969 co.camera.needsRender = false;
29970 co.eraser.needsRender = false;
29971 var perspectiveCamera = co.camera.perspective;
29972 var backgroundRenders = [];
29973 var foregroundRenders = [];
29974 for (var _i = 0, _a = co.renders; _i < _a.length; _i++) {
29975 var render = _a[_i];
29976 if (render.stage === Render_1.GLRenderStage.Background) {
29977 backgroundRenders.push(render.render);
29979 else if (render.stage === Render_1.GLRenderStage.Foreground) {
29980 foregroundRenders.push(render.render);
29983 var renderer = co.renderer.renderer;
29984 renderer.autoClear = false;
29986 for (var _b = 0, backgroundRenders_1 = backgroundRenders; _b < backgroundRenders_1.length; _b++) {
29987 var render = backgroundRenders_1[_b];
29988 render(perspectiveCamera, renderer);
29990 renderer.clearDepth();
29991 for (var _c = 0, foregroundRenders_1 = foregroundRenders; _c < foregroundRenders_1.length; _c++) {
29992 var render = foregroundRenders_1[_c];
29993 render(perspectiveCamera, renderer);
29997 .map(function (rc) {
29998 return function (irc) {
29999 irc.frameId = rc.frameId;
30000 irc.perspective = rc.perspective;
30001 if (rc.changed === true) {
30002 irc.needsRender = true;
30007 .subscribe(this._renderCameraOperation$);
30008 this._renderFrameSubscribe();
30009 var renderHash$ = this._render$
30010 .map(function (hash) {
30011 return function (hashes) {
30012 hashes[hash.name] = hash.render;
30016 var clearHash$ = this._clear$
30017 .map(function (name) {
30018 return function (hashes) {
30019 delete hashes[name];
30023 Observable_1.Observable
30024 .merge(renderHash$, clearHash$)
30025 .subscribe(this._renderOperation$);
30026 var createRenderer$ = this._render$
30028 .map(function (hash) {
30029 return function (renderer) {
30030 var webGLRenderer = new THREE.WebGLRenderer();
30031 var element = renderService.element;
30032 webGLRenderer.setSize(element.offsetWidth, element.offsetHeight);
30033 webGLRenderer.setClearColor(new THREE.Color(0x202020), 1.0);
30034 webGLRenderer.sortObjects = false;
30035 webGLRenderer.domElement.style.width = "100%";
30036 webGLRenderer.domElement.style.height = "100%";
30037 element.appendChild(webGLRenderer.domElement);
30038 renderer.needsRender = true;
30039 renderer.renderer = webGLRenderer;
30043 var resizeRenderer$ = this._renderService.size$
30044 .map(function (size) {
30045 return function (renderer) {
30046 if (renderer.renderer == null) {
30049 renderer.renderer.setSize(size.width, size.height);
30050 renderer.needsRender = true;
30054 var clearRenderer$ = this._clear$
30055 .map(function (name) {
30056 return function (renderer) {
30057 if (renderer.renderer == null) {
30060 renderer.needsRender = true;
30064 Observable_1.Observable
30065 .merge(createRenderer$, resizeRenderer$, clearRenderer$)
30066 .subscribe(this._rendererOperation$);
30067 var renderCollectionEmpty$ = this._renderCollection$
30068 .filter(function (hashes) {
30069 return Object.keys(hashes).length === 0;
30072 renderCollectionEmpty$
30073 .subscribe(function (hashes) {
30074 if (_this._renderFrameSubscription == null) {
30077 _this._renderFrameSubscription.unsubscribe();
30078 _this._renderFrameSubscription = null;
30079 _this._renderFrameSubscribe();
30081 renderCollectionEmpty$
30082 .map(function (hashes) {
30083 return function (eraser) {
30084 eraser.needsRender = true;
30088 .subscribe(this._eraserOperation$);
30090 Object.defineProperty(GLRenderer.prototype, "render$", {
30092 return this._render$;
30097 GLRenderer.prototype.clear = function (name) {
30098 this._clear$.next(name);
30100 GLRenderer.prototype._renderFrameSubscribe = function () {
30104 .map(function (renderHash) {
30105 return function (irc) {
30106 irc.needsRender = true;
30110 .subscribe(function (operation) {
30111 _this._renderCameraOperation$.next(operation);
30113 this._renderFrameSubscription = this._render$
30115 .mergeMap(function (hash) {
30116 return _this._renderService.renderCameraFrame$;
30118 .subscribe(this._renderFrame$);
30122 exports.GLRenderer = GLRenderer;
30123 Object.defineProperty(exports, "__esModule", { value: true });
30124 exports.default = GLRenderer;
30126 },{"../Render":213,"rxjs/Observable":28,"rxjs/Subject":33,"rxjs/add/observable/combineLatest":37,"rxjs/add/operator/distinctUntilChanged":53,"rxjs/add/operator/filter":56,"rxjs/add/operator/first":58,"rxjs/add/operator/map":60,"rxjs/add/operator/merge":61,"rxjs/add/operator/mergeMap":63,"rxjs/add/operator/scan":68,"rxjs/add/operator/share":69,"rxjs/add/operator/startWith":72,"three":157}],297:[function(require,module,exports){
30127 /// <reference path="../../typings/index.d.ts" />
30129 var THREE = require("three");
30130 var Geo_1 = require("../Geo");
30131 var Render_1 = require("../Render");
30132 var RenderCamera = (function () {
30133 function RenderCamera(perspectiveCameraAspect, renderMode) {
30136 this._frameId = -1;
30137 this._changed = false;
30138 this._changedForFrame = -1;
30139 this.currentAspect = 1;
30140 this.currentPano = false;
30141 this.previousAspect = 1;
30142 this.previousPano = false;
30143 this.renderMode = renderMode;
30144 this._camera = new Geo_1.Camera();
30145 this._perspective = new THREE.PerspectiveCamera(50, perspectiveCameraAspect, 0.4, 10000);
30147 Object.defineProperty(RenderCamera.prototype, "perspective", {
30149 return this._perspective;
30154 Object.defineProperty(RenderCamera.prototype, "camera", {
30156 return this._camera;
30161 Object.defineProperty(RenderCamera.prototype, "changed", {
30163 return this.frameId === this._changedForFrame;
30168 Object.defineProperty(RenderCamera.prototype, "frameId", {
30170 return this._frameId;
30172 set: function (value) {
30173 this._frameId = value;
30174 if (this._changed) {
30175 this._changed = false;
30176 this._changedForFrame = value;
30182 RenderCamera.prototype.updateProjection = function () {
30183 var currentAspect = this._getAspect(this.currentAspect, this.currentPano, this.perspective.aspect);
30184 var previousAspect = this._getAspect(this.previousAspect, this.previousPano, this.perspective.aspect);
30185 var aspect = (1 - this.alpha) * previousAspect + this.alpha * currentAspect;
30186 var verticalFov = this._getVerticalFov(aspect, this._camera.focal, this.zoom);
30187 this._perspective.fov = verticalFov;
30188 this._perspective.updateProjectionMatrix();
30189 this._changed = true;
30191 RenderCamera.prototype.updatePerspective = function (camera) {
30192 this._perspective.up.copy(camera.up);
30193 this._perspective.position.copy(camera.position);
30194 this._perspective.lookAt(camera.lookat);
30195 this._changed = true;
30197 RenderCamera.prototype._getVerticalFov = function (aspect, focal, zoom) {
30198 return 2 * Math.atan(0.5 / (Math.pow(2, zoom) * aspect * focal)) * 180 / Math.PI;
30200 RenderCamera.prototype._getAspect = function (nodeAspect, pano, perspectiveCameraAspect) {
30204 var coeff = Math.max(1, 1 / nodeAspect);
30205 var usePerspective = this.renderMode === Render_1.RenderMode.Letterbox ?
30206 nodeAspect > perspectiveCameraAspect :
30207 nodeAspect < perspectiveCameraAspect;
30208 var aspect = usePerspective ?
30209 coeff * perspectiveCameraAspect :
30210 coeff * nodeAspect;
30213 return RenderCamera;
30215 exports.RenderCamera = RenderCamera;
30216 Object.defineProperty(exports, "__esModule", { value: true });
30217 exports.default = RenderCamera;
30219 },{"../Geo":210,"../Render":213,"three":157}],298:[function(require,module,exports){
30222 * Enumeration for render mode
30225 * @description Modes for specifying how rendering is done
30226 * in the viewer. All modes preserves the original aspect
30227 * ratio of the images.
30229 (function (RenderMode) {
30231 * Displays all content within the viewer.
30233 * @description Black bars shown on both
30234 * sides of the content. Bars are shown
30235 * either below and above or to the left
30236 * and right of the content depending on
30237 * the aspect ratio relation between the
30238 * image and the viewer.
30240 RenderMode[RenderMode["Letterbox"] = 0] = "Letterbox";
30242 * Fills the viewer by cropping content.
30244 * @description Cropping is done either
30245 * in horizontal or vertical direction
30246 * depending on the aspect ratio relation
30247 * between the image and the viewer.
30249 RenderMode[RenderMode["Fill"] = 1] = "Fill";
30250 })(exports.RenderMode || (exports.RenderMode = {}));
30251 var RenderMode = exports.RenderMode;
30252 Object.defineProperty(exports, "__esModule", { value: true });
30253 exports.default = RenderMode;
30255 },{}],299:[function(require,module,exports){
30256 /// <reference path="../../typings/index.d.ts" />
30258 var Subject_1 = require("rxjs/Subject");
30259 var BehaviorSubject_1 = require("rxjs/BehaviorSubject");
30260 require("rxjs/add/observable/combineLatest");
30261 require("rxjs/add/operator/do");
30262 require("rxjs/add/operator/filter");
30263 require("rxjs/add/operator/map");
30264 require("rxjs/add/operator/publishReplay");
30265 require("rxjs/add/operator/scan");
30266 require("rxjs/add/operator/skip");
30267 require("rxjs/add/operator/startWith");
30268 require("rxjs/add/operator/withLatestFrom");
30269 var Render_1 = require("../Render");
30270 var RenderService = (function () {
30271 function RenderService(element, currentFrame$, renderMode) {
30273 this._element = element;
30274 this._currentFrame$ = currentFrame$;
30275 renderMode = renderMode != null ? renderMode : Render_1.RenderMode.Fill;
30276 this._resize$ = new Subject_1.Subject();
30277 this._renderCameraOperation$ = new Subject_1.Subject();
30279 new BehaviorSubject_1.BehaviorSubject({
30280 height: this._element.offsetHeight,
30281 width: this._element.offsetWidth,
30285 return { height: _this._element.offsetHeight, width: _this._element.offsetWidth };
30287 .subscribe(this._size$);
30288 this._renderMode$ = new BehaviorSubject_1.BehaviorSubject(renderMode);
30289 this._renderCameraHolder$ = this._renderCameraOperation$
30290 .startWith(function (rc) {
30293 .scan(function (rc, operation) {
30294 return operation(rc);
30295 }, new Render_1.RenderCamera(this._element.offsetWidth / this._element.offsetHeight, renderMode))
30298 this._renderCameraFrame$ = this._currentFrame$
30299 .withLatestFrom(this._renderCameraHolder$, function (frame, renderCamera) {
30300 return [frame, renderCamera];
30302 .do(function (args) {
30303 var frame = args[0];
30305 var camera = frame.state.camera;
30306 if (rc.alpha !== frame.state.alpha ||
30307 rc.zoom !== frame.state.zoom ||
30308 rc.camera.diff(camera) > 1e-5) {
30309 var currentTransform = frame.state.currentTransform;
30310 var previousTransform = frame.state.previousTransform != null ?
30311 frame.state.previousTransform :
30312 frame.state.currentTransform;
30313 var previousNode = frame.state.previousNode != null ?
30314 frame.state.previousNode :
30315 frame.state.currentNode;
30316 rc.currentAspect = currentTransform.basicAspect;
30317 rc.currentPano = frame.state.currentNode.pano;
30318 rc.previousAspect = previousTransform.basicAspect;
30319 rc.previousPano = previousNode.pano;
30320 rc.alpha = frame.state.alpha;
30321 rc.zoom = frame.state.zoom;
30322 rc.camera.copy(camera);
30323 rc.updatePerspective(camera);
30324 rc.updateProjection();
30326 rc.frameId = frame.id;
30328 .map(function (args) {
30333 this._renderCamera$ = this._renderCameraFrame$
30334 .filter(function (rc) {
30341 .map(function (size) {
30342 return function (rc) {
30343 rc.perspective.aspect = size.width / size.height;
30344 rc.updateProjection();
30348 .subscribe(this._renderCameraOperation$);
30351 .map(function (rm) {
30352 return function (rc) {
30353 rc.renderMode = rm;
30354 rc.updateProjection();
30358 .subscribe(this._renderCameraOperation$);
30359 this._renderCameraHolder$.subscribe();
30360 this._size$.subscribe();
30361 this._renderMode$.subscribe();
30363 Object.defineProperty(RenderService.prototype, "element", {
30365 return this._element;
30370 Object.defineProperty(RenderService.prototype, "resize$", {
30372 return this._resize$;
30377 Object.defineProperty(RenderService.prototype, "size$", {
30379 return this._size$;
30384 Object.defineProperty(RenderService.prototype, "renderMode$", {
30386 return this._renderMode$;
30391 Object.defineProperty(RenderService.prototype, "renderCameraFrame$", {
30393 return this._renderCameraFrame$;
30398 Object.defineProperty(RenderService.prototype, "renderCamera$", {
30400 return this._renderCamera$;
30405 return RenderService;
30407 exports.RenderService = RenderService;
30408 Object.defineProperty(exports, "__esModule", { value: true });
30409 exports.default = RenderService;
30411 },{"../Render":213,"rxjs/BehaviorSubject":25,"rxjs/Subject":33,"rxjs/add/observable/combineLatest":37,"rxjs/add/operator/do":54,"rxjs/add/operator/filter":56,"rxjs/add/operator/map":60,"rxjs/add/operator/publishReplay":67,"rxjs/add/operator/scan":68,"rxjs/add/operator/skip":70,"rxjs/add/operator/startWith":72,"rxjs/add/operator/withLatestFrom":76}],300:[function(require,module,exports){
30412 /// <reference path="../../typings/index.d.ts" />
30414 var FrameGenerator = (function () {
30415 function FrameGenerator() {
30416 if (window.requestAnimationFrame) {
30417 this._requestAnimationFrame = window.requestAnimationFrame;
30418 this._cancelAnimationFrame = window.cancelAnimationFrame;
30420 else if (window.mozRequestAnimationFrame) {
30421 this._requestAnimationFrame = window.mozRequestAnimationFrame;
30422 this._cancelAnimationFrame = window.mozCancelAnimationFrame;
30424 else if (window.webkitRequestAnimationFrame) {
30425 this._requestAnimationFrame = window.webkitRequestAnimationFrame;
30426 this._cancelAnimationFrame = window.webkitCancelAnimationFrame;
30428 else if (window.msRequestAnimationFrame) {
30429 this._requestAnimationFrame = window.msRequestAnimationFrame;
30430 this._cancelAnimationFrame = window.msCancelRequestAnimationFrame;
30432 else if (window.oRequestAnimationFrame) {
30433 this._requestAnimationFrame = window.oRequestAnimationFrame;
30434 this._cancelAnimationFrame = window.oCancelAnimationFrame;
30437 this._requestAnimationFrame = function (callback) {
30438 return window.setTimeout(callback, 1000 / 60);
30440 this._cancelAnimationFrame = window.clearTimeout;
30443 FrameGenerator.prototype.requestAnimationFrame = function (callback) {
30444 return this._requestAnimationFrame.call(window, callback);
30446 FrameGenerator.prototype.cancelAnimationFrame = function (id) {
30447 this._cancelAnimationFrame.call(window, id);
30449 return FrameGenerator;
30451 exports.FrameGenerator = FrameGenerator;
30453 },{}],301:[function(require,module,exports){
30455 (function (State) {
30456 State[State["Traversing"] = 0] = "Traversing";
30457 State[State["Waiting"] = 1] = "Waiting";
30458 })(exports.State || (exports.State = {}));
30459 var State = exports.State;
30460 Object.defineProperty(exports, "__esModule", { value: true });
30461 exports.default = State;
30463 },{}],302:[function(require,module,exports){
30465 var State_1 = require("../State");
30466 var Geo_1 = require("../Geo");
30467 var StateContext = (function () {
30468 function StateContext() {
30469 this._state = new State_1.TraversingState({
30471 camera: new Geo_1.Camera(),
30473 reference: { alt: 0, lat: 0, lon: 0 },
30478 StateContext.prototype.traverse = function () {
30479 this._state = this._state.traverse();
30481 StateContext.prototype.wait = function () {
30482 this._state = this._state.wait();
30484 Object.defineProperty(StateContext.prototype, "state", {
30486 if (this._state instanceof State_1.TraversingState) {
30487 return State_1.State.Traversing;
30489 else if (this._state instanceof State_1.WaitingState) {
30490 return State_1.State.Waiting;
30492 throw new Error("Invalid state");
30497 Object.defineProperty(StateContext.prototype, "reference", {
30499 return this._state.reference;
30504 Object.defineProperty(StateContext.prototype, "alpha", {
30506 return this._state.alpha;
30511 Object.defineProperty(StateContext.prototype, "camera", {
30513 return this._state.camera;
30518 Object.defineProperty(StateContext.prototype, "zoom", {
30520 return this._state.zoom;
30525 Object.defineProperty(StateContext.prototype, "currentNode", {
30527 return this._state.currentNode;
30532 Object.defineProperty(StateContext.prototype, "previousNode", {
30534 return this._state.previousNode;
30539 Object.defineProperty(StateContext.prototype, "currentCamera", {
30541 return this._state.currentCamera;
30546 Object.defineProperty(StateContext.prototype, "currentTransform", {
30548 return this._state.currentTransform;
30553 Object.defineProperty(StateContext.prototype, "previousTransform", {
30555 return this._state.previousTransform;
30560 Object.defineProperty(StateContext.prototype, "trajectory", {
30562 return this._state.trajectory;
30567 Object.defineProperty(StateContext.prototype, "currentIndex", {
30569 return this._state.currentIndex;
30574 Object.defineProperty(StateContext.prototype, "lastNode", {
30576 return this._state.trajectory[this._state.trajectory.length - 1];
30581 Object.defineProperty(StateContext.prototype, "nodesAhead", {
30583 return this._state.trajectory.length - 1 - this._state.currentIndex;
30588 Object.defineProperty(StateContext.prototype, "motionless", {
30590 return this._state.motionless;
30595 StateContext.prototype.getCenter = function () {
30596 return this._state.getCenter();
30598 StateContext.prototype.setCenter = function (center) {
30599 this._state.setCenter(center);
30601 StateContext.prototype.setZoom = function (zoom) {
30602 this._state.setZoom(zoom);
30604 StateContext.prototype.update = function (fps) {
30605 this._state.update(fps);
30607 StateContext.prototype.append = function (nodes) {
30608 this._state.append(nodes);
30610 StateContext.prototype.prepend = function (nodes) {
30611 this._state.prepend(nodes);
30613 StateContext.prototype.remove = function (n) {
30614 this._state.remove(n);
30616 StateContext.prototype.cut = function () {
30619 StateContext.prototype.set = function (nodes) {
30620 this._state.set(nodes);
30622 StateContext.prototype.rotate = function (delta) {
30623 this._state.rotate(delta);
30625 StateContext.prototype.rotateBasic = function (basicRotation) {
30626 this._state.rotateBasic(basicRotation);
30628 StateContext.prototype.rotateToBasic = function (basic) {
30629 this._state.rotateToBasic(basic);
30631 StateContext.prototype.move = function (delta) {
30632 this._state.move(delta);
30634 StateContext.prototype.moveTo = function (delta) {
30635 this._state.moveTo(delta);
30637 StateContext.prototype.zoomIn = function (delta, reference) {
30638 this._state.zoomIn(delta, reference);
30640 return StateContext;
30642 exports.StateContext = StateContext;
30644 },{"../Geo":210,"../State":214}],303:[function(require,module,exports){
30646 var BehaviorSubject_1 = require("rxjs/BehaviorSubject");
30647 var Subject_1 = require("rxjs/Subject");
30648 require("rxjs/add/operator/distinctUntilChanged");
30649 require("rxjs/add/operator/do");
30650 require("rxjs/add/operator/filter");
30651 require("rxjs/add/operator/first");
30652 require("rxjs/add/operator/map");
30653 require("rxjs/add/operator/pairwise");
30654 require("rxjs/add/operator/publishReplay");
30655 require("rxjs/add/operator/scan");
30656 require("rxjs/add/operator/startWith");
30657 require("rxjs/add/operator/switchMap");
30658 require("rxjs/add/operator/withLatestFrom");
30659 var State_1 = require("../State");
30660 var StateService = (function () {
30661 function StateService() {
30663 this._appendNode$ = new Subject_1.Subject();
30664 this._start$ = new Subject_1.Subject();
30665 this._frame$ = new Subject_1.Subject();
30666 this._fpsSampleRate = 30;
30667 this._contextOperation$ = new BehaviorSubject_1.BehaviorSubject(function (context) {
30670 this._context$ = this._contextOperation$
30671 .scan(function (context, operation) {
30672 return operation(context);
30673 }, new State_1.StateContext())
30676 this._state$ = this._context$
30677 .map(function (context) {
30678 return context.state;
30680 .distinctUntilChanged()
30683 this._fps$ = this._start$
30684 .switchMap(function () {
30685 return _this._frame$
30686 .filter(function (frameId) {
30687 return frameId % _this._fpsSampleRate === 0;
30689 .map(function (frameId) {
30690 return new Date().getTime();
30693 .map(function (times) {
30694 return Math.max(20, 1000 * _this._fpsSampleRate / (times[1] - times[0]));
30699 this._currentState$ = this._frame$
30700 .withLatestFrom(this._fps$, this._context$, function (frameId, fps, context) {
30701 return [frameId, fps, context];
30703 .filter(function (fc) {
30704 return fc[2].currentNode != null;
30706 .do(function (fc) {
30707 fc[2].update(fc[1]);
30709 .map(function (fc) {
30710 return { fps: fc[1], id: fc[0], state: fc[2] };
30713 this._lastState$ = this._currentState$
30716 var nodeChanged$ = this._currentState$
30717 .distinctUntilChanged(undefined, function (f) {
30718 return f.state.currentNode.key;
30722 var nodeChangedSubject$ = new Subject_1.Subject();
30723 nodeChanged$.subscribe(nodeChangedSubject$);
30724 this._currentNode$ = nodeChangedSubject$
30725 .map(function (f) {
30726 return f.state.currentNode;
30730 this._currentCamera$ = nodeChangedSubject$
30731 .map(function (f) {
30732 return f.state.currentCamera;
30736 this._currentTransform$ = nodeChangedSubject$
30737 .map(function (f) {
30738 return f.state.currentTransform;
30742 this._reference$ = nodeChangedSubject$
30743 .map(function (f) {
30744 return f.state.reference;
30746 .distinctUntilChanged(function (r1, r2) {
30747 return r1.lat === r2.lat && r1.lon === r2.lon;
30748 }, function (reference) {
30749 return { lat: reference.lat, lon: reference.lon };
30753 this._currentNodeExternal$ = nodeChanged$
30754 .map(function (f) {
30755 return f.state.currentNode;
30760 .map(function (node) {
30761 return function (context) {
30762 context.append([node]);
30766 .subscribe(this._contextOperation$);
30767 this._movingOperation$ = new Subject_1.Subject();
30769 .map(function (frame) {
30772 .subscribe(this._movingOperation$);
30773 this._movingOperation$
30774 .distinctUntilChanged()
30775 .filter(function (moving) {
30778 .switchMap(function (moving) {
30779 return _this._currentState$
30780 .filter(function (frame) {
30781 return frame.state.nodesAhead === 0;
30783 .map(function (frame) {
30784 return [frame.state.camera.clone(), frame.state.zoom];
30787 .map(function (pair) {
30788 var c1 = pair[0][0];
30789 var c2 = pair[1][0];
30790 var z1 = pair[0][1];
30791 var z2 = pair[1][1];
30792 return c1.diff(c2) > 1e-5 || Math.abs(z1 - z2) > 1e-5;
30794 .first(function (changed) {
30798 .subscribe(this._movingOperation$);
30799 this._moving$ = this._movingOperation$
30800 .distinctUntilChanged()
30802 this._state$.subscribe();
30803 this._currentNode$.subscribe();
30804 this._currentCamera$.subscribe();
30805 this._currentTransform$.subscribe();
30806 this._reference$.subscribe();
30807 this._currentNodeExternal$.subscribe();
30808 this._lastState$.subscribe();
30809 this._frameId = null;
30810 this._frameGenerator = new State_1.FrameGenerator();
30812 Object.defineProperty(StateService.prototype, "currentState$", {
30814 return this._currentState$;
30819 Object.defineProperty(StateService.prototype, "currentNode$", {
30821 return this._currentNode$;
30826 Object.defineProperty(StateService.prototype, "currentNodeExternal$", {
30828 return this._currentNodeExternal$;
30833 Object.defineProperty(StateService.prototype, "currentCamera$", {
30835 return this._currentCamera$;
30840 Object.defineProperty(StateService.prototype, "currentTransform$", {
30842 return this._currentTransform$;
30847 Object.defineProperty(StateService.prototype, "state$", {
30849 return this._state$;
30854 Object.defineProperty(StateService.prototype, "reference$", {
30856 return this._reference$;
30861 Object.defineProperty(StateService.prototype, "moving$", {
30863 return this._moving$;
30868 Object.defineProperty(StateService.prototype, "appendNode$", {
30870 return this._appendNode$;
30875 StateService.prototype.traverse = function () {
30876 this._movingOperation$.next(true);
30877 this._invokeContextOperation(function (context) { context.traverse(); });
30879 StateService.prototype.wait = function () {
30880 this._invokeContextOperation(function (context) { context.wait(); });
30882 StateService.prototype.appendNodes = function (nodes) {
30883 this._invokeContextOperation(function (context) { context.append(nodes); });
30885 StateService.prototype.prependNodes = function (nodes) {
30886 this._invokeContextOperation(function (context) { context.prepend(nodes); });
30888 StateService.prototype.removeNodes = function (n) {
30889 this._invokeContextOperation(function (context) { context.remove(n); });
30891 StateService.prototype.cutNodes = function () {
30892 this._invokeContextOperation(function (context) { context.cut(); });
30894 StateService.prototype.setNodes = function (nodes) {
30895 this._invokeContextOperation(function (context) { context.set(nodes); });
30897 StateService.prototype.rotate = function (delta) {
30898 this._movingOperation$.next(true);
30899 this._invokeContextOperation(function (context) { context.rotate(delta); });
30901 StateService.prototype.rotateBasic = function (basicRotation) {
30902 this._movingOperation$.next(true);
30903 this._invokeContextOperation(function (context) { context.rotateBasic(basicRotation); });
30905 StateService.prototype.rotateToBasic = function (basic) {
30906 this._movingOperation$.next(true);
30907 this._invokeContextOperation(function (context) { context.rotateToBasic(basic); });
30909 StateService.prototype.move = function (delta) {
30910 this._movingOperation$.next(true);
30911 this._invokeContextOperation(function (context) { context.move(delta); });
30913 StateService.prototype.moveTo = function (position) {
30914 this._movingOperation$.next(true);
30915 this._invokeContextOperation(function (context) { context.moveTo(position); });
30918 * Change zoom level while keeping the reference point position approximately static.
30920 * @parameter {number} delta - Change in zoom level.
30921 * @parameter {Array<number>} reference - Reference point in basic coordinates.
30923 StateService.prototype.zoomIn = function (delta, reference) {
30924 this._movingOperation$.next(true);
30925 this._invokeContextOperation(function (context) { context.zoomIn(delta, reference); });
30927 StateService.prototype.getCenter = function () {
30928 return this._lastState$
30930 .map(function (frame) {
30931 return frame.state.getCenter();
30934 StateService.prototype.getZoom = function () {
30935 return this._lastState$
30937 .map(function (frame) {
30938 return frame.state.zoom;
30941 StateService.prototype.setCenter = function (center) {
30942 this._movingOperation$.next(true);
30943 this._invokeContextOperation(function (context) { context.setCenter(center); });
30945 StateService.prototype.setZoom = function (zoom) {
30946 this._movingOperation$.next(true);
30947 this._invokeContextOperation(function (context) { context.setZoom(zoom); });
30949 StateService.prototype.start = function () {
30950 if (this._frameId == null) {
30951 this._start$.next(null);
30952 this._frameId = this._frameGenerator.requestAnimationFrame(this._frame.bind(this));
30953 this._frame$.next(this._frameId);
30956 StateService.prototype.stop = function () {
30957 if (this._frameId != null) {
30958 this._frameGenerator.cancelAnimationFrame(this._frameId);
30959 this._frameId = null;
30962 StateService.prototype._invokeContextOperation = function (action) {
30963 this._contextOperation$
30964 .next(function (context) {
30969 StateService.prototype._frame = function (time) {
30970 this._frameId = this._frameGenerator.requestAnimationFrame(this._frame.bind(this));
30971 this._frame$.next(this._frameId);
30973 return StateService;
30975 exports.StateService = StateService;
30977 },{"../State":214,"rxjs/BehaviorSubject":25,"rxjs/Subject":33,"rxjs/add/operator/distinctUntilChanged":53,"rxjs/add/operator/do":54,"rxjs/add/operator/filter":56,"rxjs/add/operator/first":58,"rxjs/add/operator/map":60,"rxjs/add/operator/pairwise":64,"rxjs/add/operator/publishReplay":67,"rxjs/add/operator/scan":68,"rxjs/add/operator/startWith":72,"rxjs/add/operator/switchMap":73,"rxjs/add/operator/withLatestFrom":76}],304:[function(require,module,exports){
30978 /// <reference path="../../../typings/index.d.ts" />
30980 var Error_1 = require("../../Error");
30981 var Geo_1 = require("../../Geo");
30982 var StateBase = (function () {
30983 function StateBase(state) {
30984 this._spatial = new Geo_1.Spatial();
30985 this._geoCoords = new Geo_1.GeoCoords();
30986 this._referenceThreshold = 0.01;
30987 this._reference = state.reference;
30988 this._alpha = state.alpha;
30989 this._camera = state.camera.clone();
30990 this._zoom = state.zoom;
30991 this._currentIndex = state.currentIndex;
30992 this._trajectory = state.trajectory.slice();
30993 this._trajectoryTransforms = [];
30994 this._trajectoryCameras = [];
30995 for (var _i = 0, _a = this._trajectory; _i < _a.length; _i++) {
30997 var translation = this._nodeToTranslation(node);
30998 var transform = new Geo_1.Transform(node, node.image, translation);
30999 this._trajectoryTransforms.push(transform);
31000 this._trajectoryCameras.push(new Geo_1.Camera(transform));
31002 this._currentNode = this._trajectory.length > 0 ?
31003 this._trajectory[this._currentIndex] :
31005 this._previousNode = this._trajectory.length > 1 && this.currentIndex > 0 ?
31006 this._trajectory[this._currentIndex - 1] :
31008 this._currentCamera = this._trajectoryCameras.length > 0 ?
31009 this._trajectoryCameras[this._currentIndex].clone() :
31010 new Geo_1.Camera();
31011 this._previousCamera = this._trajectoryCameras.length > 1 && this.currentIndex > 0 ?
31012 this._trajectoryCameras[this._currentIndex - 1].clone() :
31013 this._currentCamera.clone();
31015 Object.defineProperty(StateBase.prototype, "reference", {
31017 return this._reference;
31022 Object.defineProperty(StateBase.prototype, "alpha", {
31024 return this._getAlpha();
31029 Object.defineProperty(StateBase.prototype, "camera", {
31031 return this._camera;
31036 Object.defineProperty(StateBase.prototype, "zoom", {
31043 Object.defineProperty(StateBase.prototype, "trajectory", {
31045 return this._trajectory;
31050 Object.defineProperty(StateBase.prototype, "currentIndex", {
31052 return this._currentIndex;
31057 Object.defineProperty(StateBase.prototype, "currentNode", {
31059 return this._currentNode;
31064 Object.defineProperty(StateBase.prototype, "previousNode", {
31066 return this._previousNode;
31071 Object.defineProperty(StateBase.prototype, "currentCamera", {
31073 return this._currentCamera;
31078 Object.defineProperty(StateBase.prototype, "currentTransform", {
31080 return this._trajectoryTransforms.length > 0 ?
31081 this._trajectoryTransforms[this.currentIndex] : null;
31086 Object.defineProperty(StateBase.prototype, "previousTransform", {
31088 return this._trajectoryTransforms.length > 1 && this.currentIndex > 0 ?
31089 this._trajectoryTransforms[this.currentIndex - 1] : null;
31094 Object.defineProperty(StateBase.prototype, "motionless", {
31096 return this._motionless;
31101 StateBase.prototype.append = function (nodes) {
31102 if (nodes.length < 1) {
31103 throw Error("Trajectory can not be empty");
31105 if (this._currentIndex < 0) {
31109 this._trajectory = this._trajectory.concat(nodes);
31110 this._appendToTrajectories(nodes);
31113 StateBase.prototype.prepend = function (nodes) {
31114 if (nodes.length < 1) {
31115 throw Error("Trajectory can not be empty");
31117 this._trajectory = nodes.slice().concat(this._trajectory);
31118 this._currentIndex += nodes.length;
31119 this._setCurrentNode();
31120 var referenceReset = this._setReference(this._currentNode);
31121 if (referenceReset) {
31122 this._setTrajectories();
31125 this._prependToTrajectories(nodes);
31127 this._setCurrentCamera();
31129 StateBase.prototype.remove = function (n) {
31131 throw Error("n must be a positive integer");
31133 var length = this._trajectory.length;
31134 if (length - (this._currentIndex + 1) < n) {
31135 throw Error("Current node can not be removed");
31137 for (var i = 0; i < n; i++) {
31138 this._trajectory.pop();
31139 this._trajectoryTransforms.pop();
31140 this._trajectoryCameras.pop();
31143 StateBase.prototype.cut = function () {
31144 while (this._trajectory.length - 1 > this._currentIndex) {
31145 this._trajectory.pop();
31146 this._trajectoryTransforms.pop();
31147 this._trajectoryCameras.pop();
31150 StateBase.prototype.set = function (nodes) {
31151 this._setTrajectory(nodes);
31152 this._setCurrentNode();
31153 this._setReference(this._currentNode);
31154 this._setTrajectories();
31155 this._setCurrentCamera();
31157 StateBase.prototype.getCenter = function () {
31158 return this._currentNode != null ?
31159 this.currentTransform.projectBasic(this._camera.lookat.toArray()) :
31162 StateBase.prototype._setCurrent = function () {
31163 this._setCurrentNode();
31164 var referenceReset = this._setReference(this._currentNode);
31165 if (referenceReset) {
31166 this._setTrajectories();
31168 this._setCurrentCamera();
31170 StateBase.prototype._setCurrentCamera = function () {
31171 this._currentCamera = this._trajectoryCameras[this._currentIndex].clone();
31172 this._previousCamera = this._currentIndex > 0 ?
31173 this._trajectoryCameras[this._currentIndex - 1].clone() :
31174 this._currentCamera.clone();
31176 StateBase.prototype._motionlessTransition = function () {
31177 var nodesSet = this._currentNode != null && this._previousNode != null;
31178 return nodesSet && !(this._currentNode.merged &&
31179 this._previousNode.merged &&
31180 this._withinOriginalDistance() &&
31181 this._sameConnectedComponent());
31183 StateBase.prototype._setReference = function (node) {
31184 // do not reset reference if node is within threshold distance
31185 if (Math.abs(node.latLon.lat - this.reference.lat) < this._referenceThreshold &&
31186 Math.abs(node.latLon.lon - this.reference.lon) < this._referenceThreshold) {
31189 // do not reset reference if previous node exist and transition is with motion
31190 if (this._previousNode != null && !this._motionlessTransition()) {
31193 this._reference.lat = node.latLon.lat;
31194 this._reference.lon = node.latLon.lon;
31195 this._reference.alt = node.alt;
31198 StateBase.prototype._setCurrentNode = function () {
31199 this._currentNode = this._trajectory.length > 0 ?
31200 this._trajectory[this._currentIndex] :
31202 this._previousNode = this._currentIndex > 0 ?
31203 this._trajectory[this._currentIndex - 1] :
31206 StateBase.prototype._setTrajectory = function (nodes) {
31207 if (nodes.length < 1) {
31208 throw new Error_1.ParameterMapillaryError("Trajectory can not be empty");
31210 if (this._currentNode != null) {
31211 this._trajectory = [this._currentNode].concat(nodes);
31212 this._currentIndex = 1;
31215 this._trajectory = nodes.slice();
31216 this._currentIndex = 0;
31219 StateBase.prototype._setTrajectories = function () {
31220 this._trajectoryTransforms.length = 0;
31221 this._trajectoryCameras.length = 0;
31222 this._appendToTrajectories(this._trajectory);
31224 StateBase.prototype._appendToTrajectories = function (nodes) {
31225 for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
31226 var node = nodes_1[_i];
31227 if (!node.assetsCached) {
31228 throw new Error_1.ParameterMapillaryError("Assets must be cached when node is added to trajectory");
31230 var translation = this._nodeToTranslation(node);
31231 var transform = new Geo_1.Transform(node, node.image, translation);
31232 this._trajectoryTransforms.push(transform);
31233 this._trajectoryCameras.push(new Geo_1.Camera(transform));
31236 StateBase.prototype._prependToTrajectories = function (nodes) {
31237 for (var _i = 0, _a = nodes.reverse(); _i < _a.length; _i++) {
31239 if (!node.assetsCached) {
31240 throw new Error_1.ParameterMapillaryError("Node must be loaded when added to trajectory");
31242 var translation = this._nodeToTranslation(node);
31243 var transform = new Geo_1.Transform(node, node.image, translation);
31244 this._trajectoryTransforms.unshift(transform);
31245 this._trajectoryCameras.unshift(new Geo_1.Camera(transform));
31248 StateBase.prototype._nodeToTranslation = function (node) {
31249 var C = this._geoCoords.geodeticToEnu(node.latLon.lat, node.latLon.lon, node.alt, this._reference.lat, this._reference.lon, this._reference.alt);
31250 var RC = this._spatial.rotate(C, node.rotation);
31251 return [-RC.x, -RC.y, -RC.z];
31253 StateBase.prototype._sameConnectedComponent = function () {
31254 var current = this._currentNode;
31255 var previous = this._previousNode;
31257 !current.mergeCC ||
31259 !previous.mergeCC) {
31262 return current.mergeCC === previous.mergeCC;
31264 StateBase.prototype._withinOriginalDistance = function () {
31265 var current = this._currentNode;
31266 var previous = this._previousNode;
31267 if (!current || !previous) {
31270 // 50 km/h moves 28m in 2s
31271 var distance = this._spatial.distanceFromLatLon(current.originalLatLon.lat, current.originalLatLon.lon, previous.originalLatLon.lat, previous.originalLatLon.lon);
31272 return distance < 25;
31276 exports.StateBase = StateBase;
31278 },{"../../Error":209,"../../Geo":210}],305:[function(require,module,exports){
31279 /// <reference path="../../../typings/index.d.ts" />
31281 var __extends = (this && this.__extends) || function (d, b) {
31282 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
31283 function __() { this.constructor = d; }
31284 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
31286 var THREE = require("three");
31287 var UnitBezier = require("unitbezier");
31288 var State_1 = require("../../State");
31289 var RotationDelta = (function () {
31290 function RotationDelta(phi, theta) {
31292 this._theta = theta;
31294 Object.defineProperty(RotationDelta.prototype, "phi", {
31298 set: function (value) {
31304 Object.defineProperty(RotationDelta.prototype, "theta", {
31306 return this._theta;
31308 set: function (value) {
31309 this._theta = value;
31314 Object.defineProperty(RotationDelta.prototype, "isZero", {
31316 return this._phi === 0 && this._theta === 0;
31321 RotationDelta.prototype.copy = function (delta) {
31322 this._phi = delta.phi;
31323 this._theta = delta.theta;
31325 RotationDelta.prototype.lerp = function (other, alpha) {
31326 this._phi = (1 - alpha) * this._phi + alpha * other.phi;
31327 this._theta = (1 - alpha) * this._theta + alpha * other.theta;
31329 RotationDelta.prototype.multiply = function (value) {
31330 this._phi *= value;
31331 this._theta *= value;
31333 RotationDelta.prototype.threshold = function (value) {
31334 this._phi = Math.abs(this._phi) > value ? this._phi : 0;
31335 this._theta = Math.abs(this._theta) > value ? this._theta : 0;
31337 RotationDelta.prototype.lengthSquared = function () {
31338 return this._phi * this._phi + this._theta * this._theta;
31340 RotationDelta.prototype.reset = function () {
31344 return RotationDelta;
31346 var TraversingState = (function (_super) {
31347 __extends(TraversingState, _super);
31348 function TraversingState(state) {
31349 _super.call(this, state);
31350 this._motionless = this._motionlessTransition();
31351 this._baseAlpha = this._alpha;
31352 this._animationSpeed = 0.025;
31353 this._unitBezier = new UnitBezier(0.74, 0.67, 0.38, 0.96);
31354 this._useBezier = false;
31355 this._rotationDelta = new RotationDelta(0, 0);
31356 this._requestedRotationDelta = null;
31357 this._basicRotation = [0, 0];
31358 this._requestedBasicRotation = null;
31359 this._rotationAcceleration = 0.86;
31360 this._rotationIncreaseAlpha = 0.97;
31361 this._rotationDecreaseAlpha = 0.9;
31362 this._rotationThreshold = 0.001;
31363 this._desiredZoom = state.zoom;
31366 this._lookatDepth = 10;
31367 this._desiredLookat = null;
31368 this._desiredCenter = null;
31370 TraversingState.prototype.traverse = function () {
31371 throw new Error("Not implemented");
31373 TraversingState.prototype.wait = function () {
31374 return new State_1.WaitingState(this);
31376 TraversingState.prototype.append = function (nodes) {
31377 var emptyTrajectory = this._trajectory.length === 0;
31378 if (emptyTrajectory) {
31379 this._resetTransition();
31381 _super.prototype.append.call(this, nodes);
31382 if (emptyTrajectory) {
31383 this._setDesiredCenter();
31384 this._setDesiredZoom();
31387 TraversingState.prototype.prepend = function (nodes) {
31388 var emptyTrajectory = this._trajectory.length === 0;
31389 if (emptyTrajectory) {
31390 this._resetTransition();
31392 _super.prototype.prepend.call(this, nodes);
31393 if (emptyTrajectory) {
31394 this._setDesiredCenter();
31395 this._setDesiredZoom();
31398 TraversingState.prototype.set = function (nodes) {
31399 _super.prototype.set.call(this, nodes);
31400 this._desiredLookat = null;
31401 this._resetTransition();
31402 this._clearRotation();
31403 this._setDesiredCenter();
31404 this._setDesiredZoom();
31405 if (this._trajectory.length < 3) {
31406 this._useBezier = true;
31409 TraversingState.prototype.move = function (delta) {
31410 throw new Error("Not implemented");
31412 TraversingState.prototype.moveTo = function (delta) {
31413 throw new Error("Not implemented");
31415 TraversingState.prototype.rotate = function (rotationDelta) {
31416 if (this._currentNode == null) {
31419 this._desiredZoom = this._zoom;
31420 this._desiredLookat = null;
31421 this._requestedBasicRotation = null;
31422 if (this._requestedRotationDelta != null) {
31423 this._requestedRotationDelta.phi = this._requestedRotationDelta.phi + rotationDelta.phi;
31424 this._requestedRotationDelta.theta = this._requestedRotationDelta.theta + rotationDelta.theta;
31427 this._requestedRotationDelta = new RotationDelta(rotationDelta.phi, rotationDelta.theta);
31430 TraversingState.prototype.rotateBasic = function (basicRotation) {
31431 if (this._currentNode == null) {
31434 this._desiredZoom = this._zoom;
31435 this._desiredLookat = null;
31436 this._requestedRotationDelta = null;
31437 if (this._requestedBasicRotation != null) {
31438 this._requestedBasicRotation[0] += basicRotation[0];
31439 this._requestedBasicRotation[1] += basicRotation[1];
31442 this._requestedBasicRotation = basicRotation.slice();
31445 TraversingState.prototype.rotateToBasic = function (basic) {
31446 if (this._currentNode == null) {
31449 this._desiredZoom = this._zoom;
31450 this._desiredLookat = null;
31451 basic[0] = this._spatial.clamp(basic[0], 0, 1);
31452 basic[1] = this._spatial.clamp(basic[1], 0, 1);
31453 var lookat = this.currentTransform.unprojectBasic(basic, this._lookatDepth);
31454 this._currentCamera.lookat.fromArray(lookat);
31456 TraversingState.prototype.zoomIn = function (delta, reference) {
31457 if (this._currentNode == null) {
31460 this._desiredZoom = Math.max(this._minZoom, Math.min(this._maxZoom, this._desiredZoom + delta));
31461 var currentCenter = this.currentTransform.projectBasic(this._currentCamera.lookat.toArray());
31462 var currentCenterX = currentCenter[0];
31463 var currentCenterY = currentCenter[1];
31464 var zoom0 = Math.pow(2, this._zoom);
31465 var zoom1 = Math.pow(2, this._desiredZoom);
31466 var refX = reference[0];
31467 var refY = reference[1];
31468 if (this.currentTransform.gpano != null &&
31469 this.currentTransform.gpano.CroppedAreaImageWidthPixels === this.currentTransform.gpano.FullPanoWidthPixels) {
31470 if (refX - currentCenterX > 0.5) {
31473 else if (currentCenterX - refX > 0.5) {
31477 var newCenterX = refX - zoom0 / zoom1 * (refX - currentCenterX);
31478 var newCenterY = refY - zoom0 / zoom1 * (refY - currentCenterY);
31479 var gpano = this.currentTransform.gpano;
31480 if (this._currentNode.fullPano) {
31481 newCenterX = this._spatial.wrap(newCenterX + this._basicRotation[0], 0, 1);
31482 newCenterY = this._spatial.clamp(newCenterY + this._basicRotation[1], 0.05, 0.95);
31484 else if (gpano != null &&
31485 this.currentTransform.gpano.CroppedAreaImageWidthPixels === this.currentTransform.gpano.FullPanoWidthPixels) {
31486 newCenterX = this._spatial.wrap(newCenterX + this._basicRotation[0], 0, 1);
31487 newCenterY = this._spatial.clamp(newCenterY + this._basicRotation[1], 0, 1);
31490 newCenterX = this._spatial.clamp(newCenterX, 0, 1);
31491 newCenterY = this._spatial.clamp(newCenterY, 0, 1);
31493 this._desiredLookat = new THREE.Vector3()
31494 .fromArray(this.currentTransform.unprojectBasic([newCenterX, newCenterY], this._lookatDepth));
31496 TraversingState.prototype.setCenter = function (center) {
31497 this._desiredLookat = null;
31498 this._requestedRotationDelta = null;
31499 this._requestedBasicRotation = null;
31500 this._desiredZoom = this._zoom;
31502 this._spatial.clamp(center[0], 0, 1),
31503 this._spatial.clamp(center[1], 0, 1),
31505 if (this._currentNode == null) {
31506 this._desiredCenter = clamped;
31509 this._desiredCenter = null;
31510 var currentLookat = new THREE.Vector3()
31511 .fromArray(this.currentTransform.unprojectBasic(clamped, this._lookatDepth));
31512 var previousTransform = this.previousTransform != null ?
31513 this.previousTransform :
31514 this.currentTransform;
31515 var previousLookat = new THREE.Vector3()
31516 .fromArray(previousTransform.unprojectBasic(clamped, this._lookatDepth));
31517 this._currentCamera.lookat.copy(currentLookat);
31518 this._previousCamera.lookat.copy(previousLookat);
31520 TraversingState.prototype.setZoom = function (zoom) {
31521 this._desiredLookat = null;
31522 this._requestedRotationDelta = null;
31523 this._requestedBasicRotation = null;
31524 this._zoom = this._spatial.clamp(zoom, this._minZoom, this._maxZoom);
31525 this._desiredZoom = this._zoom;
31527 TraversingState.prototype.update = function (fps) {
31528 if (this._alpha === 1 && this._currentIndex + this._alpha < this._trajectory.length) {
31529 this._currentIndex += 1;
31530 this._useBezier = this._trajectory.length < 3 &&
31531 this._currentIndex + 1 === this._trajectory.length;
31532 this._setCurrent();
31533 this._resetTransition();
31534 this._clearRotation();
31535 this._desiredZoom = this._currentNode.fullPano ? this._zoom : 0;
31536 this._desiredLookat = null;
31538 var animationSpeed = this._animationSpeed * (60 / fps);
31539 this._baseAlpha = Math.min(1, this._baseAlpha + animationSpeed);
31540 if (this._useBezier) {
31541 this._alpha = this._unitBezier.solve(this._baseAlpha);
31544 this._alpha = this._baseAlpha;
31546 this._updateRotation();
31547 if (!this._rotationDelta.isZero) {
31548 this._applyRotation(this._previousCamera);
31549 this._applyRotation(this._currentCamera);
31551 this._updateRotationBasic();
31552 if (this._basicRotation[0] !== 0 || this._basicRotation[1] !== 0) {
31553 this._applyRotationBasic();
31555 this._updateZoom(animationSpeed);
31556 this._updateLookat(animationSpeed);
31557 this._camera.lerpCameras(this._previousCamera, this._currentCamera, this.alpha);
31559 TraversingState.prototype._getAlpha = function () {
31560 return this._motionless ? Math.ceil(this._alpha) : this._alpha;
31562 TraversingState.prototype._setCurrentCamera = function () {
31563 _super.prototype._setCurrentCamera.call(this);
31564 if (this._previousNode != null) {
31565 var lookat = this._camera.lookat.clone().sub(this._camera.position);
31566 this._previousCamera.lookat.copy(lookat.clone().add(this._previousCamera.position));
31567 if (this._currentNode.fullPano) {
31568 this._currentCamera.lookat.copy(lookat.clone().add(this._currentCamera.position));
31572 TraversingState.prototype._resetTransition = function () {
31574 this._baseAlpha = 0;
31575 this._motionless = this._motionlessTransition();
31577 TraversingState.prototype._applyRotation = function (camera) {
31578 if (camera == null) {
31581 var q = new THREE.Quaternion().setFromUnitVectors(camera.up, new THREE.Vector3(0, 0, 1));
31582 var qInverse = q.clone().inverse();
31583 var offset = new THREE.Vector3();
31584 offset.copy(camera.lookat).sub(camera.position);
31585 offset.applyQuaternion(q);
31586 var length = offset.length();
31587 var phi = Math.atan2(offset.y, offset.x);
31588 phi += this._rotationDelta.phi;
31589 var theta = Math.atan2(Math.sqrt(offset.x * offset.x + offset.y * offset.y), offset.z);
31590 theta += this._rotationDelta.theta;
31591 theta = Math.max(0.1, Math.min(Math.PI - 0.1, theta));
31592 offset.x = Math.sin(theta) * Math.cos(phi);
31593 offset.y = Math.sin(theta) * Math.sin(phi);
31594 offset.z = Math.cos(theta);
31595 offset.applyQuaternion(qInverse);
31596 camera.lookat.copy(camera.position).add(offset.multiplyScalar(length));
31598 TraversingState.prototype._applyRotationBasic = function () {
31599 var currentNode = this._currentNode;
31600 var previousNode = this._previousNode != null ?
31601 this.previousNode :
31603 var currentCamera = this._currentCamera;
31604 var previousCamera = this._previousCamera;
31605 var currentTransform = this.currentTransform;
31606 var previousTransform = this.previousTransform != null ?
31607 this.previousTransform :
31608 this.currentTransform;
31609 var currentBasic = currentTransform.projectBasic(currentCamera.lookat.toArray());
31610 var previousBasic = previousTransform.projectBasic(previousCamera.lookat.toArray());
31611 var currentGPano = currentTransform.gpano;
31612 var previousGPano = previousTransform.gpano;
31613 if (currentNode.fullPano) {
31614 currentBasic[0] = this._spatial.wrap(currentBasic[0] + this._basicRotation[0], 0, 1);
31615 currentBasic[1] = this._spatial.clamp(currentBasic[1] + this._basicRotation[1], 0.05, 0.95);
31617 else if (currentGPano != null &&
31618 currentTransform.gpano.CroppedAreaImageWidthPixels === currentTransform.gpano.FullPanoWidthPixels) {
31619 currentBasic[0] = this._spatial.wrap(currentBasic[0] + this._basicRotation[0], 0, 1);
31620 currentBasic[1] = this._spatial.clamp(currentBasic[1] + this._basicRotation[1], 0, 1);
31623 currentBasic[0] = this._spatial.clamp(currentBasic[0] + this._basicRotation[0], 0, 1);
31624 currentBasic[1] = this._spatial.clamp(currentBasic[1] + this._basicRotation[1], 0, 1);
31626 if (previousNode.fullPano) {
31627 previousBasic[0] = this._spatial.wrap(previousBasic[0] + this._basicRotation[0], 0, 1);
31628 previousBasic[1] = this._spatial.clamp(previousBasic[1] + this._basicRotation[1], 0.05, 0.95);
31630 else if (previousGPano != null &&
31631 previousTransform.gpano.CroppedAreaImageWidthPixels === previousTransform.gpano.FullPanoWidthPixels) {
31632 previousBasic[0] = this._spatial.wrap(previousBasic[0] + this._basicRotation[0], 0, 1);
31633 previousBasic[1] = this._spatial.clamp(previousBasic[1] + this._basicRotation[1], 0, 1);
31636 previousBasic[0] = this._spatial.clamp(previousBasic[0] + this._basicRotation[0], 0, 1);
31637 previousBasic[1] = this._spatial.clamp(currentBasic[1] + this._basicRotation[1], 0, 1);
31639 var currentLookat = currentTransform.unprojectBasic(currentBasic, this._lookatDepth);
31640 currentCamera.lookat.fromArray(currentLookat);
31641 var previousLookat = previousTransform.unprojectBasic(previousBasic, this._lookatDepth);
31642 previousCamera.lookat.fromArray(previousLookat);
31644 TraversingState.prototype._updateZoom = function (animationSpeed) {
31645 var diff = this._desiredZoom - this._zoom;
31649 else if (Math.abs(diff) < 0.0001) {
31650 this._zoom = this._desiredZoom;
31653 this._zoom += 5 * animationSpeed * diff;
31656 TraversingState.prototype._updateLookat = function (animationSpeed) {
31657 if (this._desiredLookat === null) {
31660 var diff = this._desiredLookat.distanceToSquared(this._currentCamera.lookat);
31661 if (Math.abs(diff) < 0.00001) {
31662 this._currentCamera.lookat.copy(this._desiredLookat);
31663 this._desiredLookat = null;
31666 this._currentCamera.lookat.lerp(this._desiredLookat, 5 * animationSpeed);
31669 TraversingState.prototype._updateRotation = function () {
31670 if (this._requestedRotationDelta != null) {
31671 var length_1 = this._rotationDelta.lengthSquared();
31672 var requestedLength = this._requestedRotationDelta.lengthSquared();
31673 if (requestedLength > length_1) {
31674 this._rotationDelta.lerp(this._requestedRotationDelta, this._rotationIncreaseAlpha);
31677 this._rotationDelta.lerp(this._requestedRotationDelta, this._rotationDecreaseAlpha);
31679 this._requestedRotationDelta = null;
31682 if (this._rotationDelta.isZero) {
31685 this._rotationDelta.multiply(this._rotationAcceleration);
31686 this._rotationDelta.threshold(this._rotationThreshold);
31688 TraversingState.prototype._updateRotationBasic = function () {
31689 if (this._requestedBasicRotation != null) {
31690 var x = this._basicRotation[0];
31691 var y = this._basicRotation[1];
31692 var lengthSquared = x * x + y * y;
31693 var reqX = this._requestedBasicRotation[0];
31694 var reqY = this._requestedBasicRotation[1];
31695 var reqLengthSquared = reqX * reqX + reqY * reqY;
31696 if (reqLengthSquared > lengthSquared) {
31697 this._basicRotation[0] = (1 - this._rotationIncreaseAlpha) * x + this._rotationIncreaseAlpha * reqX;
31698 this._basicRotation[1] = (1 - this._rotationIncreaseAlpha) * y + this._rotationIncreaseAlpha * reqY;
31701 this._basicRotation[0] = (1 - this._rotationDecreaseAlpha) * x + this._rotationDecreaseAlpha * reqX;
31702 this._basicRotation[1] = (1 - this._rotationDecreaseAlpha) * y + this._rotationDecreaseAlpha * reqY;
31704 this._requestedBasicRotation = null;
31707 if (this._basicRotation[0] === 0 && this._basicRotation[1] === 0) {
31710 this._basicRotation[0] = this._rotationAcceleration * this._basicRotation[0];
31711 this._basicRotation[1] = this._rotationAcceleration * this._basicRotation[1];
31712 if (Math.abs(this._basicRotation[0]) < this._rotationThreshold / Math.pow(2, this._zoom) &&
31713 Math.abs(this._basicRotation[1]) < this._rotationThreshold / Math.pow(2, this._zoom)) {
31714 this._basicRotation = [0, 0];
31717 TraversingState.prototype._clearRotation = function () {
31718 if (this._currentNode.fullPano) {
31721 if (this._requestedRotationDelta != null) {
31722 this._requestedRotationDelta = null;
31724 if (!this._rotationDelta.isZero) {
31725 this._rotationDelta.reset();
31727 if (this._requestedBasicRotation != null) {
31728 this._requestedBasicRotation = null;
31730 if (this._basicRotation[0] > 0 || this._basicRotation[1] > 0) {
31731 this._basicRotation = [0, 0];
31734 TraversingState.prototype._setDesiredCenter = function () {
31735 if (this._desiredCenter == null) {
31738 var lookatDirection = new THREE.Vector3()
31739 .fromArray(this.currentTransform.unprojectBasic(this._desiredCenter, this._lookatDepth))
31740 .sub(this._currentCamera.position);
31741 this._currentCamera.lookat.copy(this._currentCamera.position.clone().add(lookatDirection));
31742 this._previousCamera.lookat.copy(this._previousCamera.position.clone().add(lookatDirection));
31743 this._desiredCenter = null;
31745 TraversingState.prototype._setDesiredZoom = function () {
31746 this._desiredZoom =
31747 this._currentNode.fullPano || this._previousNode == null ?
31750 return TraversingState;
31751 }(State_1.StateBase));
31752 exports.TraversingState = TraversingState;
31754 },{"../../State":214,"three":157,"unitbezier":159}],306:[function(require,module,exports){
31756 var __extends = (this && this.__extends) || function (d, b) {
31757 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
31758 function __() { this.constructor = d; }
31759 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
31761 var State_1 = require("../../State");
31762 var WaitingState = (function (_super) {
31763 __extends(WaitingState, _super);
31764 function WaitingState(state) {
31765 _super.call(this, state);
31766 this._motionless = this._motionlessTransition();
31768 WaitingState.prototype.traverse = function () {
31769 return new State_1.TraversingState(this);
31771 WaitingState.prototype.wait = function () {
31772 throw new Error("Not implemented");
31774 WaitingState.prototype.prepend = function (nodes) {
31775 _super.prototype.prepend.call(this, nodes);
31776 this._motionless = this._motionlessTransition();
31778 WaitingState.prototype.set = function (nodes) {
31779 _super.prototype.set.call(this, nodes);
31780 this._motionless = this._motionlessTransition();
31782 WaitingState.prototype.rotate = function (delta) { return; };
31783 WaitingState.prototype.rotateBasic = function (basicRotation) { return; };
31784 WaitingState.prototype.rotateToBasic = function (basic) { return; };
31785 WaitingState.prototype.zoomIn = function (delta, reference) { return; };
31786 WaitingState.prototype.move = function (delta) {
31787 this._alpha = Math.max(0, Math.min(1, this._alpha + delta));
31789 WaitingState.prototype.moveTo = function (position) {
31790 this._alpha = Math.max(0, Math.min(1, position));
31792 WaitingState.prototype.update = function (fps) {
31793 this._camera.lerpCameras(this._previousCamera, this._currentCamera, this.alpha);
31795 WaitingState.prototype.setCenter = function (center) { return; };
31796 WaitingState.prototype.setZoom = function (zoom) { return; };
31797 WaitingState.prototype._getAlpha = function () {
31798 return this._motionless ? Math.ceil(this._alpha) : this._alpha;
31801 WaitingState.prototype._setCurrentCamera = function () {
31802 _super.prototype._setCurrentCamera.call(this);
31803 if (this._previousNode != null) {
31804 var lookat = this._camera.lookat.clone().sub(this._camera.position);
31805 if (this._previousNode.pano) {
31806 var lookat_1 = this._camera.lookat.clone().sub(this._camera.position);
31807 this._currentCamera.lookat.copy(lookat_1.clone().add(this._currentCamera.position));
31809 if (this._currentNode.pano) {
31810 this._currentCamera.lookat.copy(lookat.clone().add(this._currentCamera.position));
31814 return WaitingState;
31815 }(State_1.StateBase));
31816 exports.WaitingState = WaitingState;
31818 },{"../../State":214}],307:[function(require,module,exports){
31820 var EventEmitter = (function () {
31821 function EventEmitter() {
31825 * Subscribe to an event by its name.
31826 * @param {string }eventType - The name of the event to subscribe to.
31827 * @param {any} fn - The handler called when the event occurs.
31829 EventEmitter.prototype.on = function (eventType, fn) {
31830 this._events[eventType] = this._events[eventType] || [];
31831 this._events[eventType].push(fn);
31835 * Unsubscribe from an event by its name.
31836 * @param {string} eventType - The name of the event to subscribe to.
31837 * @param {any} fn - The handler to remove.
31839 EventEmitter.prototype.off = function (eventType, fn) {
31844 if (!this._listens(eventType)) {
31845 var idx = this._events[eventType].indexOf(fn);
31847 this._events[eventType].splice(idx, 1);
31849 if (this._events[eventType].length) {
31850 delete this._events[eventType];
31854 delete this._events[eventType];
31858 EventEmitter.prototype.fire = function (eventType, data) {
31859 if (!this._listens(eventType)) {
31862 for (var _i = 0, _a = this._events[eventType]; _i < _a.length; _i++) {
31864 fn.call(this, data);
31868 EventEmitter.prototype._listens = function (eventType) {
31869 return !!(this._events && this._events[eventType]);
31871 return EventEmitter;
31873 exports.EventEmitter = EventEmitter;
31874 Object.defineProperty(exports, "__esModule", { value: true });
31875 exports.default = EventEmitter;
31877 },{}],308:[function(require,module,exports){
31879 var Viewer_1 = require("../Viewer");
31880 var Settings = (function () {
31881 function Settings() {
31883 Settings.setOptions = function (options) {
31884 Settings._baseImageSize = options.baseImageSize != null ?
31885 options.baseImageSize :
31886 Viewer_1.ImageSize.Size640;
31887 Settings._basePanoramaSize = options.basePanoramaSize != null ?
31888 options.basePanoramaSize :
31889 Viewer_1.ImageSize.Size2048;
31890 Settings._maxImageSize = options.maxImageSize != null ?
31891 options.maxImageSize :
31892 Viewer_1.ImageSize.Size2048;
31894 Object.defineProperty(Settings, "baseImageSize", {
31896 return Settings._baseImageSize;
31901 Object.defineProperty(Settings, "basePanoramaSize", {
31903 return Settings._basePanoramaSize;
31908 Object.defineProperty(Settings, "maxImageSize", {
31910 return Settings._maxImageSize;
31917 exports.Settings = Settings;
31918 Object.defineProperty(exports, "__esModule", { value: true });
31919 exports.default = Settings;
31921 },{"../Viewer":216}],309:[function(require,module,exports){
31923 var Urls = (function () {
31926 Urls.dynamicImage = function (key, size) {
31927 return "https://d2qb1440i7l50o.cloudfront.net/" + key + "/full/!" + size + "," + size + "/0/default.jpg?origin=mapillary.webgl";
31929 Urls.thumbnail = function (key, size) {
31930 return "https://d1cuyjsrcm0gby.cloudfront.net/" + key + "/thumb-" + size + ".jpg?origin=mapillary.webgl";
31932 Urls.falcorModel = function (clientId) {
31933 return "https://a.mapillary.com/v3/model.json?client_id=" + clientId;
31935 Urls.protoMesh = function (key) {
31936 return "https://d1brzeo354iq2l.cloudfront.net/v2/mesh/" + key;
31940 exports.Urls = Urls;
31941 Object.defineProperty(exports, "__esModule", { value: true });
31942 exports.default = Urls;
31944 },{}],310:[function(require,module,exports){
31946 var Component_1 = require("../Component");
31947 var ComponentController = (function () {
31948 function ComponentController(container, navigator, key, options) {
31950 this._container = container;
31951 this._navigator = navigator;
31952 this._options = options != null ? options : {};
31954 this._componentService = new Component_1.ComponentService(this._container, this._navigator);
31955 this._coverComponent = this._componentService.getCover();
31956 this._initializeComponents();
31958 this._initilizeCoverComponent();
31959 this._subscribeCoverComponent();
31962 this._navigator.movedToKey$
31964 .subscribe(function (movedToKey) {
31965 _this._key = movedToKey;
31966 _this._componentService.deactivateCover();
31967 _this._coverComponent.configure({ key: _this._key, loading: false, visible: false });
31968 _this._subscribeCoverComponent();
31969 _this._navigator.stateService.start();
31973 ComponentController.prototype.get = function (name) {
31974 return this._componentService.get(name);
31976 ComponentController.prototype.activate = function (name) {
31977 this._componentService.activate(name);
31979 ComponentController.prototype.activateCover = function () {
31980 this._coverComponent.configure({ loading: false, visible: true });
31982 ComponentController.prototype.deactivate = function (name) {
31983 this._componentService.deactivate(name);
31985 ComponentController.prototype.deactivateCover = function () {
31986 this._coverComponent.configure({ loading: true, visible: true });
31988 ComponentController.prototype.resize = function () {
31989 this._componentService.resize();
31991 ComponentController.prototype._initializeComponents = function () {
31992 var options = this._options;
31993 this._uFalse(options.background, "background");
31994 this._uFalse(options.debug, "debug");
31995 this._uFalse(options.image, "image");
31996 this._uFalse(options.marker, "marker");
31997 this._uFalse(options.navigation, "navigation");
31998 this._uFalse(options.route, "route");
31999 this._uFalse(options.slider, "slider");
32000 this._uFalse(options.stats, "stats");
32001 this._uFalse(options.tag, "tag");
32002 this._uTrue(options.attribution, "attribution");
32003 this._uTrue(options.bearing, "bearing");
32004 this._uTrue(options.cache, "cache");
32005 this._uTrue(options.direction, "direction");
32006 this._uTrue(options.imagePlane, "imagePlane");
32007 this._uTrue(options.keyboard, "keyboard");
32008 this._uTrue(options.loading, "loading");
32009 this._uTrue(options.mouse, "mouse");
32010 this._uTrue(options.sequence, "sequence");
32012 ComponentController.prototype._initilizeCoverComponent = function () {
32013 var options = this._options;
32014 this._coverComponent.configure({ key: this._key });
32015 if (options.cover === undefined || options.cover) {
32016 this.activateCover();
32019 this.deactivateCover();
32022 ComponentController.prototype._subscribeCoverComponent = function () {
32024 this._coverComponent.configuration$.subscribe(function (conf) {
32025 if (conf.loading) {
32026 _this._navigator.moveToKey$(conf.key)
32027 .subscribe(function (node) {
32028 _this._navigator.stateService.start();
32029 _this._coverComponent.configure({ loading: false, visible: false });
32030 _this._componentService.deactivateCover();
32031 }, function (error) {
32032 console.error("Failed to deactivate cover.", error);
32033 _this._coverComponent.configure({ loading: false, visible: true });
32036 else if (conf.visible) {
32037 _this._navigator.stateService.stop();
32038 _this._componentService.activateCover();
32042 ComponentController.prototype._uFalse = function (option, name) {
32043 if (option === undefined) {
32044 this._componentService.deactivate(name);
32047 if (typeof option === "boolean") {
32049 this._componentService.activate(name);
32052 this._componentService.deactivate(name);
32056 this._componentService.configure(name, option);
32057 this._componentService.activate(name);
32059 ComponentController.prototype._uTrue = function (option, name) {
32060 if (option === undefined) {
32061 this._componentService.activate(name);
32064 if (typeof option === "boolean") {
32066 this._componentService.activate(name);
32069 this._componentService.deactivate(name);
32073 this._componentService.configure(name, option);
32074 this._componentService.activate(name);
32076 return ComponentController;
32078 exports.ComponentController = ComponentController;
32080 },{"../Component":207}],311:[function(require,module,exports){
32082 var Render_1 = require("../Render");
32083 var Viewer_1 = require("../Viewer");
32084 var Container = (function () {
32085 function Container(id, stateService, options) {
32087 this.element = document.getElementById(id);
32088 this.element.classList.add("mapillary-js");
32089 this.renderService = new Render_1.RenderService(this.element, stateService.currentState$, options.renderMode);
32090 this.glRenderer = new Render_1.GLRenderer(this.renderService);
32091 this.domRenderer = new Render_1.DOMRenderer(this.element, this.renderService, stateService.currentState$);
32092 this.mouseService = new Viewer_1.MouseService(this.element);
32093 this.touchService = new Viewer_1.TouchService(this.element);
32094 this.spriteService = new Viewer_1.SpriteService(options.sprite);
32098 exports.Container = Container;
32099 Object.defineProperty(exports, "__esModule", { value: true });
32100 exports.default = Container;
32102 },{"../Render":213,"../Viewer":216}],312:[function(require,module,exports){
32104 var Observable_1 = require("rxjs/Observable");
32105 require("rxjs/add/observable/combineLatest");
32106 require("rxjs/add/operator/distinctUntilChanged");
32107 require("rxjs/add/operator/map");
32108 var Viewer_1 = require("../Viewer");
32109 var EventLauncher = (function () {
32110 function EventLauncher(eventEmitter, navigator, container) {
32112 this._container = container;
32113 this._eventEmitter = eventEmitter;
32114 this._navigator = navigator;
32115 this._loadingSubscription = this._navigator.loadingService.loading$
32116 .subscribe(function (loading) {
32117 _this._eventEmitter.fire(Viewer_1.Viewer.loadingchanged, loading);
32119 this._currentNodeSubscription = this._navigator.stateService.currentNodeExternal$
32120 .subscribe(function (node) {
32121 _this._eventEmitter.fire(Viewer_1.Viewer.nodechanged, node);
32123 this._sequenceEdgesSubscription = this._navigator.stateService.currentNodeExternal$
32124 .switchMap(function (node) {
32125 return node.sequenceEdges$;
32127 .subscribe(function (status) {
32128 _this._eventEmitter.fire(Viewer_1.Viewer.sequenceedgeschanged, status);
32130 this._spatialEdgesSubscription = this._navigator.stateService.currentNodeExternal$
32131 .switchMap(function (node) {
32132 return node.spatialEdges$;
32134 .subscribe(function (status) {
32135 _this._eventEmitter.fire(Viewer_1.Viewer.spatialedgeschanged, status);
32137 Observable_1.Observable
32138 .combineLatest(this._navigator.stateService.moving$, this._container.mouseService.active$)
32139 .map(function (values) {
32140 return values[0] || values[1];
32142 .distinctUntilChanged()
32143 .subscribe(function (started) {
32145 _this._eventEmitter.fire(Viewer_1.Viewer.movestart, null);
32148 _this._eventEmitter.fire(Viewer_1.Viewer.moveend, null);
32152 EventLauncher.prototype.dispose = function () {
32153 this._loadingSubscription.unsubscribe();
32154 this._currentNodeSubscription.unsubscribe();
32156 return EventLauncher;
32158 exports.EventLauncher = EventLauncher;
32159 Object.defineProperty(exports, "__esModule", { value: true });
32160 exports.default = EventLauncher;
32162 },{"../Viewer":216,"rxjs/Observable":28,"rxjs/add/observable/combineLatest":37,"rxjs/add/operator/distinctUntilChanged":53,"rxjs/add/operator/map":60}],313:[function(require,module,exports){
32165 * Enumeration for image sizes
32168 * @description Image sizes in pixels for the long side of the image.
32170 (function (ImageSize) {
32172 * 320 pixels image size
32174 ImageSize[ImageSize["Size320"] = 320] = "Size320";
32176 * 640 pixels image size
32178 ImageSize[ImageSize["Size640"] = 640] = "Size640";
32180 * 1024 pixels image size
32182 ImageSize[ImageSize["Size1024"] = 1024] = "Size1024";
32184 * 2048 pixels image size
32186 ImageSize[ImageSize["Size2048"] = 2048] = "Size2048";
32187 })(exports.ImageSize || (exports.ImageSize = {}));
32188 var ImageSize = exports.ImageSize;
32190 },{}],314:[function(require,module,exports){
32191 /// <reference path="../../typings/index.d.ts" />
32193 var _ = require("underscore");
32194 var Subject_1 = require("rxjs/Subject");
32195 require("rxjs/add/operator/debounceTime");
32196 require("rxjs/add/operator/distinctUntilChanged");
32197 require("rxjs/add/operator/map");
32198 require("rxjs/add/operator/publishReplay");
32199 require("rxjs/add/operator/scan");
32200 require("rxjs/add/operator/startWith");
32201 var LoadingService = (function () {
32202 function LoadingService() {
32203 this._loadersSubject$ = new Subject_1.Subject();
32204 this._loaders$ = this._loadersSubject$
32205 .scan(function (loaders, loader) {
32206 if (loader.task !== undefined) {
32207 loaders[loader.task] = loader.loading;
32215 Object.defineProperty(LoadingService.prototype, "loading$", {
32217 return this._loaders$
32218 .map(function (loaders) {
32219 return _.reduce(loaders, function (loader, acc) {
32220 return (loader || acc);
32224 .distinctUntilChanged();
32229 LoadingService.prototype.taskLoading$ = function (task) {
32230 return this._loaders$
32231 .map(function (loaders) {
32232 return !!loaders[task];
32235 .distinctUntilChanged();
32237 LoadingService.prototype.startLoading = function (task) {
32238 this._loadersSubject$.next({ loading: true, task: task });
32240 LoadingService.prototype.stopLoading = function (task) {
32241 this._loadersSubject$.next({ loading: false, task: task });
32243 return LoadingService;
32245 exports.LoadingService = LoadingService;
32246 Object.defineProperty(exports, "__esModule", { value: true });
32247 exports.default = LoadingService;
32249 },{"rxjs/Subject":33,"rxjs/add/operator/debounceTime":51,"rxjs/add/operator/distinctUntilChanged":53,"rxjs/add/operator/map":60,"rxjs/add/operator/publishReplay":67,"rxjs/add/operator/scan":68,"rxjs/add/operator/startWith":72,"underscore":158}],315:[function(require,module,exports){
32250 /// <reference path="../../typings/index.d.ts" />
32252 var BehaviorSubject_1 = require("rxjs/BehaviorSubject");
32253 var Observable_1 = require("rxjs/Observable");
32254 var Subject_1 = require("rxjs/Subject");
32255 require("rxjs/add/observable/fromEvent");
32256 require("rxjs/add/operator/distinctUntilChanged");
32257 require("rxjs/add/operator/filter");
32258 require("rxjs/add/operator/map");
32259 require("rxjs/add/operator/merge");
32260 require("rxjs/add/operator/mergeMap");
32261 require("rxjs/add/operator/publishReplay");
32262 require("rxjs/add/operator/scan");
32263 require("rxjs/add/operator/switchMap");
32264 require("rxjs/add/operator/withLatestFrom");
32265 var MouseService = (function () {
32266 function MouseService(element) {
32268 this._element = element;
32269 this._activeSubject$ = new BehaviorSubject_1.BehaviorSubject(false);
32270 this._active$ = this._activeSubject$
32271 .distinctUntilChanged()
32274 this._preventMouseDownOperation$ = new Subject_1.Subject();
32275 this._preventMouseDown$ = new Subject_1.Subject();
32276 this._mouseMoveOperation$ = new Subject_1.Subject();
32277 this._claimMouse$ = new Subject_1.Subject();
32278 this._mouseDown$ = Observable_1.Observable.fromEvent(element, "mousedown");
32279 this._mouseLeave$ = Observable_1.Observable.fromEvent(element, "mouseleave");
32280 this._mouseUp$ = Observable_1.Observable.fromEvent(element, "mouseup");
32281 this._mouseOver$ = Observable_1.Observable.fromEvent(element, "mouseover");
32282 this._click$ = Observable_1.Observable.fromEvent(element, "click");
32283 this._mouseWheel$ = Observable_1.Observable.fromEvent(element, "wheel");
32285 .subscribe(function (event) {
32286 event.preventDefault();
32288 this._preventMouseDownOperation$
32289 .scan(function (prevent, operation) {
32290 return operation(prevent);
32293 this._preventMouseDown$
32294 .map(function (prevent) {
32295 return function (previous) {
32299 .subscribe(this._preventMouseDownOperation$);
32301 .map(function (e) {
32302 return function (prevent) {
32304 e.preventDefault();
32309 .subscribe(this._preventMouseDownOperation$);
32310 this._mouseMove$ = this._mouseMoveOperation$
32311 .scan(function (e, operation) {
32312 return operation(e);
32314 Observable_1.Observable
32315 .fromEvent(element, "mousemove")
32316 .map(function (e) {
32317 return function (previous) {
32318 if (previous == null) {
32321 if (e.movementX == null) {
32322 e.movementX = e.clientX - previous.clientX;
32324 if (e.movementY == null) {
32325 e.movementY = e.clientY - previous.clientY;
32330 .subscribe(this._mouseMoveOperation$);
32331 var dragStop$ = Observable_1.Observable
32332 .merge(this._mouseLeave$, this._mouseUp$);
32333 this._mouseDragStart$ = this._mouseDown$
32334 .mergeMap(function (e) {
32335 return _this._mouseMove$
32336 .takeUntil(dragStop$)
32339 this._mouseDrag$ = this._mouseDown$
32340 .mergeMap(function (e) {
32341 return _this._mouseMove$
32343 .takeUntil(dragStop$);
32345 this._mouseDragEnd$ = this._mouseDragStart$
32346 .mergeMap(function (e) {
32347 return dragStop$.first();
32349 this._staticClick$ = this._mouseDown$
32350 .switchMap(function (e) {
32351 return _this._click$
32352 .takeUntil(_this._mouseMove$)
32355 this._mouseOwner$ = this._claimMouse$
32356 .scan(function (claims, mouseClaim) {
32357 if (mouseClaim.zindex == null) {
32358 delete claims[mouseClaim.name];
32361 claims[mouseClaim.name] = mouseClaim.zindex;
32365 .map(function (claims) {
32368 for (var name_1 in claims) {
32369 if (claims.hasOwnProperty(name_1)) {
32370 if (claims[name_1] > curZ) {
32371 curZ = claims[name_1];
32381 Object.defineProperty(MouseService.prototype, "active$", {
32383 return this._active$;
32388 Object.defineProperty(MouseService.prototype, "activate$", {
32390 return this._activeSubject$;
32395 Object.defineProperty(MouseService.prototype, "mouseOwner$", {
32397 return this._mouseOwner$;
32402 Object.defineProperty(MouseService.prototype, "mouseDown$", {
32404 return this._mouseDown$;
32409 Object.defineProperty(MouseService.prototype, "mouseMove$", {
32411 return this._mouseMove$;
32416 Object.defineProperty(MouseService.prototype, "mouseLeave$", {
32418 return this._mouseLeave$;
32423 Object.defineProperty(MouseService.prototype, "mouseUp$", {
32425 return this._mouseUp$;
32430 Object.defineProperty(MouseService.prototype, "click$", {
32432 return this._click$;
32437 Object.defineProperty(MouseService.prototype, "mouseWheel$", {
32439 return this._mouseWheel$;
32444 Object.defineProperty(MouseService.prototype, "mouseDragStart$", {
32446 return this._mouseDragStart$;
32451 Object.defineProperty(MouseService.prototype, "mouseDrag$", {
32453 return this._mouseDrag$;
32458 Object.defineProperty(MouseService.prototype, "mouseDragEnd$", {
32460 return this._mouseDragEnd$;
32465 Object.defineProperty(MouseService.prototype, "staticClick$", {
32467 return this._staticClick$;
32472 Object.defineProperty(MouseService.prototype, "preventDefaultMouseDown$", {
32474 return this._preventMouseDown$;
32479 MouseService.prototype.claimMouse = function (name, zindex) {
32480 this._claimMouse$.next({ name: name, zindex: zindex });
32482 MouseService.prototype.unclaimMouse = function (name) {
32483 this._claimMouse$.next({ name: name, zindex: null });
32485 MouseService.prototype.filtered$ = function (name, observable$) {
32487 .withLatestFrom(this.mouseOwner$, function (event, owner) {
32488 return [event, owner];
32490 .filter(function (eo) {
32491 return eo[1] === name;
32493 .map(function (eo) {
32497 return MouseService;
32499 exports.MouseService = MouseService;
32500 Object.defineProperty(exports, "__esModule", { value: true });
32501 exports.default = MouseService;
32503 },{"rxjs/BehaviorSubject":25,"rxjs/Observable":28,"rxjs/Subject":33,"rxjs/add/observable/fromEvent":41,"rxjs/add/operator/distinctUntilChanged":53,"rxjs/add/operator/filter":56,"rxjs/add/operator/map":60,"rxjs/add/operator/merge":61,"rxjs/add/operator/mergeMap":63,"rxjs/add/operator/publishReplay":67,"rxjs/add/operator/scan":68,"rxjs/add/operator/switchMap":73,"rxjs/add/operator/withLatestFrom":76}],316:[function(require,module,exports){
32504 /// <reference path="../../typings/index.d.ts" />
32506 var BehaviorSubject_1 = require("rxjs/BehaviorSubject");
32507 var Observable_1 = require("rxjs/Observable");
32508 var Subject_1 = require("rxjs/Subject");
32509 require("rxjs/add/observable/throw");
32510 require("rxjs/add/operator/do");
32511 require("rxjs/add/operator/finally");
32512 require("rxjs/add/operator/first");
32513 require("rxjs/add/operator/map");
32514 require("rxjs/add/operator/mergeMap");
32515 var API_1 = require("../API");
32516 var Graph_1 = require("../Graph");
32517 var Edge_1 = require("../Edge");
32518 var State_1 = require("../State");
32519 var Viewer_1 = require("../Viewer");
32520 var Navigator = (function () {
32521 function Navigator(clientId, apiV3, graphService, imageLoadingService, loadingService, stateService) {
32522 this._apiV3 = apiV3 != null ? apiV3 : new API_1.APIv3(clientId);
32523 this._imageLoadingService = imageLoadingService != null ? imageLoadingService : new Graph_1.ImageLoadingService();
32524 this._graphService = graphService != null ?
32526 new Graph_1.GraphService(new Graph_1.Graph(this.apiV3), this._imageLoadingService);
32527 this._loadingService = loadingService != null ? loadingService : new Viewer_1.LoadingService();
32528 this._loadingName = "navigator";
32529 this._stateService = stateService != null ? stateService : new State_1.StateService();
32530 this._keyRequested$ = new BehaviorSubject_1.BehaviorSubject(null);
32531 this._movedToKey$ = new Subject_1.Subject();
32532 this._dirRequested$ = new BehaviorSubject_1.BehaviorSubject(null);
32533 this._latLonRequested$ = new BehaviorSubject_1.BehaviorSubject(null);
32535 Object.defineProperty(Navigator.prototype, "apiV3", {
32537 return this._apiV3;
32542 Object.defineProperty(Navigator.prototype, "graphService", {
32544 return this._graphService;
32549 Object.defineProperty(Navigator.prototype, "imageLoadingService", {
32551 return this._imageLoadingService;
32556 Object.defineProperty(Navigator.prototype, "keyRequested$", {
32558 return this._keyRequested$;
32563 Object.defineProperty(Navigator.prototype, "loadingService", {
32565 return this._loadingService;
32570 Object.defineProperty(Navigator.prototype, "movedToKey$", {
32572 return this._movedToKey$;
32577 Object.defineProperty(Navigator.prototype, "stateService", {
32579 return this._stateService;
32584 Navigator.prototype.moveToKey$ = function (key) {
32586 this.loadingService.startLoading(this._loadingName);
32587 this._keyRequested$.next(key);
32588 return this._graphService.cacheNode$(key)
32589 .do(function (node) {
32590 _this.stateService.setNodes([node]);
32591 _this._movedToKey$.next(node.key);
32593 .finally(function () {
32594 _this.loadingService.stopLoading(_this._loadingName);
32597 Navigator.prototype.moveDir$ = function (direction) {
32599 this.loadingService.startLoading(this._loadingName);
32600 this._dirRequested$.next(direction);
32601 return this.stateService.currentNode$
32603 .mergeMap(function (node) {
32604 return ([Edge_1.EdgeDirection.Next, Edge_1.EdgeDirection.Prev].indexOf(direction) > -1 ?
32605 node.sequenceEdges$ :
32606 node.spatialEdges$)
32608 .map(function (status) {
32609 for (var _i = 0, _a = status.edges; _i < _a.length; _i++) {
32611 if (edge.data.direction === direction) {
32618 .mergeMap(function (directionKey) {
32619 if (directionKey == null) {
32620 _this.loadingService.stopLoading(_this._loadingName);
32621 return Observable_1.Observable
32622 .throw(new Error("Direction (" + direction + ") does not exist for current node."));
32624 return _this.moveToKey$(directionKey);
32627 Navigator.prototype.moveCloseTo$ = function (lat, lon) {
32629 this.loadingService.startLoading(this._loadingName);
32630 this._latLonRequested$.next({ lat: lat, lon: lon });
32631 return this.apiV3.imageCloseTo$(lat, lon)
32632 .mergeMap(function (fullNode) {
32633 if (fullNode == null) {
32634 _this.loadingService.stopLoading(_this._loadingName);
32635 return Observable_1.Observable
32636 .throw(new Error("No image found close to lat " + lat + ", lon " + lon + "."));
32638 return _this.moveToKey$(fullNode.key);
32643 exports.Navigator = Navigator;
32644 Object.defineProperty(exports, "__esModule", { value: true });
32645 exports.default = Navigator;
32647 },{"../API":206,"../Edge":208,"../Graph":211,"../State":214,"../Viewer":216,"rxjs/BehaviorSubject":25,"rxjs/Observable":28,"rxjs/Subject":33,"rxjs/add/observable/throw":45,"rxjs/add/operator/do":54,"rxjs/add/operator/finally":57,"rxjs/add/operator/first":58,"rxjs/add/operator/map":60,"rxjs/add/operator/mergeMap":63}],317:[function(require,module,exports){
32649 (function (SpriteAlignment) {
32650 SpriteAlignment[SpriteAlignment["Center"] = 0] = "Center";
32651 SpriteAlignment[SpriteAlignment["Start"] = 1] = "Start";
32652 SpriteAlignment[SpriteAlignment["End"] = 2] = "End";
32653 })(exports.SpriteAlignment || (exports.SpriteAlignment = {}));
32654 var SpriteAlignment = exports.SpriteAlignment;
32655 Object.defineProperty(exports, "__esModule", { value: true });
32656 exports.default = SpriteAlignment;
32658 },{}],318:[function(require,module,exports){
32659 /// <reference path="../../typings/index.d.ts" />
32661 var THREE = require("three");
32662 var vd = require("virtual-dom");
32663 var Subject_1 = require("rxjs/Subject");
32664 require("rxjs/add/operator/publishReplay");
32665 require("rxjs/add/operator/scan");
32666 require("rxjs/add/operator/startWith");
32667 var Viewer_1 = require("../Viewer");
32668 var SpriteAtlas = (function () {
32669 function SpriteAtlas() {
32671 Object.defineProperty(SpriteAtlas.prototype, "json", {
32672 set: function (value) {
32673 this._json = value;
32678 Object.defineProperty(SpriteAtlas.prototype, "image", {
32679 set: function (value) {
32680 this._image = value;
32681 this._texture = new THREE.Texture(this._image);
32682 this._texture.minFilter = THREE.NearestFilter;
32687 Object.defineProperty(SpriteAtlas.prototype, "loaded", {
32689 return !!(this._image && this._json);
32694 SpriteAtlas.prototype.getGLSprite = function (name) {
32695 if (!this.loaded) {
32696 throw new Error("Sprites cannot be retrieved before the atlas is loaded.");
32698 var definition = this._json[name];
32700 console.warn("Sprite with key" + name + "does not exist in sprite definition.");
32701 return new THREE.Object3D();
32703 var texture = this._texture.clone();
32704 texture.needsUpdate = true;
32705 var width = this._image.width;
32706 var height = this._image.height;
32707 texture.offset.x = definition.x / width;
32708 texture.offset.y = (height - definition.y - definition.height) / height;
32709 texture.repeat.x = definition.width / width;
32710 texture.repeat.y = definition.height / height;
32711 var material = new THREE.SpriteMaterial({ map: texture });
32712 return new THREE.Sprite(material);
32714 SpriteAtlas.prototype.getDOMSprite = function (name, horizontalAlign, verticalAlign) {
32715 if (!this.loaded) {
32716 throw new Error("Sprites cannot be retrieved before the atlas is loaded.");
32718 if (horizontalAlign == null) {
32719 horizontalAlign = Viewer_1.SpriteAlignment.Start;
32721 if (verticalAlign == null) {
32722 verticalAlign = Viewer_1.SpriteAlignment.Start;
32724 var definition = this._json[name];
32726 console.warn("Sprite with key" + name + "does not exist in sprite definition.");
32727 return vd.h("div", {}, []);
32729 var clipTop = definition.y;
32730 var clipRigth = definition.x + definition.width;
32731 var clipBottom = definition.y + definition.height;
32732 var clipLeft = definition.x;
32733 var left = -definition.x;
32734 var top = -definition.y;
32735 var height = this._image.height;
32736 var width = this._image.width;
32737 switch (horizontalAlign) {
32738 case Viewer_1.SpriteAlignment.Center:
32739 left -= definition.width / 2;
32741 case Viewer_1.SpriteAlignment.End:
32742 left -= definition.width;
32744 case Viewer_1.SpriteAlignment.Start:
32749 switch (verticalAlign) {
32750 case Viewer_1.SpriteAlignment.Center:
32751 top -= definition.height / 2;
32753 case Viewer_1.SpriteAlignment.End:
32754 top -= definition.height;
32756 case Viewer_1.SpriteAlignment.Start:
32761 var pixelRatioInverse = 1 / definition.pixelRatio;
32762 clipTop *= pixelRatioInverse;
32763 clipRigth *= pixelRatioInverse;
32764 clipBottom *= pixelRatioInverse;
32765 clipLeft *= pixelRatioInverse;
32766 left *= pixelRatioInverse;
32767 top *= pixelRatioInverse;
32768 height *= pixelRatioInverse;
32769 width *= pixelRatioInverse;
32771 src: this._image.src,
32773 clip: "rect(" + clipTop + "px, " + clipRigth + "px, " + clipBottom + "px, " + clipLeft + "px)",
32774 height: height + "px",
32776 position: "absolute",
32778 width: width + "px",
32781 return vd.h("img", properties, []);
32783 return SpriteAtlas;
32785 var SpriteService = (function () {
32786 function SpriteService(sprite) {
32788 this._retina = window.devicePixelRatio > 1;
32789 this._spriteAtlasOperation$ = new Subject_1.Subject();
32790 this._spriteAtlas$ = this._spriteAtlasOperation$
32791 .startWith(function (atlas) {
32794 .scan(function (atlas, operation) {
32795 return operation(atlas);
32796 }, new SpriteAtlas())
32799 this._spriteAtlas$.subscribe();
32800 if (sprite == null) {
32803 var format = this._retina ? "@2x" : "";
32804 var imageXmlHTTP = new XMLHttpRequest();
32805 imageXmlHTTP.open("GET", sprite + format + ".png", true);
32806 imageXmlHTTP.responseType = "arraybuffer";
32807 imageXmlHTTP.onload = function () {
32808 var image = new Image();
32809 image.onload = function () {
32810 _this._spriteAtlasOperation$.next(function (atlas) {
32811 atlas.image = image;
32815 var blob = new Blob([imageXmlHTTP.response]);
32816 image.src = window.URL.createObjectURL(blob);
32818 imageXmlHTTP.onerror = function (error) {
32819 console.error(new Error("Failed to fetch sprite sheet (" + sprite + format + ".png)"));
32821 imageXmlHTTP.send();
32822 var jsonXmlHTTP = new XMLHttpRequest();
32823 jsonXmlHTTP.open("GET", sprite + format + ".json", true);
32824 jsonXmlHTTP.responseType = "text";
32825 jsonXmlHTTP.onload = function () {
32826 var json = JSON.parse(jsonXmlHTTP.response);
32827 _this._spriteAtlasOperation$.next(function (atlas) {
32832 jsonXmlHTTP.onerror = function (error) {
32833 console.error(new Error("Failed to fetch sheet (" + sprite + format + ".json)"));
32835 jsonXmlHTTP.send();
32837 Object.defineProperty(SpriteService.prototype, "spriteAtlas$", {
32839 return this._spriteAtlas$;
32844 return SpriteService;
32846 exports.SpriteService = SpriteService;
32847 Object.defineProperty(exports, "__esModule", { value: true });
32848 exports.default = SpriteService;
32850 },{"../Viewer":216,"rxjs/Subject":33,"rxjs/add/operator/publishReplay":67,"rxjs/add/operator/scan":68,"rxjs/add/operator/startWith":72,"three":157,"virtual-dom":163}],319:[function(require,module,exports){
32851 /// <reference path="../../typings/index.d.ts" />
32853 var Observable_1 = require("rxjs/Observable");
32854 var Subject_1 = require("rxjs/Subject");
32855 require("rxjs/add/operator/filter");
32856 require("rxjs/add/operator/map");
32857 require("rxjs/add/operator/merge");
32858 require("rxjs/add/operator/scan");
32859 require("rxjs/add/operator/switchMap");
32860 var TouchMove = (function () {
32861 function TouchMove(touch) {
32862 this.movementX = 0;
32863 this.movementY = 0;
32864 if (touch == null) {
32867 this.identifier = touch.identifier;
32868 this.clientX = touch.clientX;
32869 this.clientY = touch.clientY;
32870 this.pageX = touch.pageX;
32871 this.pageY = touch.pageY;
32872 this.screenX = touch.screenX;
32873 this.screenY = touch.screenY;
32874 this.target = touch.target;
32878 exports.TouchMove = TouchMove;
32879 var TouchService = (function () {
32880 function TouchService(element) {
32882 this._element = element;
32883 this._touchStart$ = Observable_1.Observable.fromEvent(element, "touchstart");
32884 this._touchMove$ = Observable_1.Observable.fromEvent(element, "touchmove");
32885 this._touchEnd$ = Observable_1.Observable.fromEvent(element, "touchend");
32886 this._touchCancel$ = Observable_1.Observable.fromEvent(element, "touchcancel");
32887 this._preventTouchMoveOperation$ = new Subject_1.Subject();
32888 this._preventTouchMove$ = new Subject_1.Subject();
32889 this._preventTouchMoveOperation$
32890 .scan(function (prevent, operation) {
32891 return operation(prevent);
32894 this._preventTouchMove$
32895 .map(function (prevent) {
32896 return function (previous) {
32900 .subscribe(this._preventTouchMoveOperation$);
32902 .map(function (te) {
32903 return function (prevent) {
32905 te.preventDefault();
32910 .subscribe(this._preventTouchMoveOperation$);
32911 this._singleTouchMoveOperation$ = new Subject_1.Subject();
32912 this._singleTouchMove$ = this._singleTouchMoveOperation$
32913 .scan(function (touch, operation) {
32914 return operation(touch);
32915 }, new TouchMove());
32917 .filter(function (te) {
32918 return te.touches.length === 1 && te.targetTouches.length === 1;
32920 .map(function (te) {
32921 return function (previous) {
32922 var touch = te.touches[0];
32923 var current = new TouchMove(touch);
32924 current.movementX = touch.pageX - previous.pageX;
32925 current.movementY = touch.pageY - previous.pageY;
32929 .subscribe(this._singleTouchMoveOperation$);
32930 var singleTouchStart$ = Observable_1.Observable
32931 .merge(this._touchStart$, this._touchEnd$, this._touchCancel$)
32932 .filter(function (te) {
32933 return te.touches.length === 1 && te.targetTouches.length === 1;
32935 var multipleTouchStart$ = Observable_1.Observable
32936 .merge(this._touchStart$, this._touchEnd$, this._touchCancel$)
32937 .filter(function (te) {
32938 return te.touches.length >= 1;
32940 var touchStop$ = Observable_1.Observable
32941 .merge(this._touchEnd$, this._touchCancel$)
32942 .filter(function (te) {
32943 return te.touches.length === 0;
32945 this._singleTouch$ = singleTouchStart$
32946 .switchMap(function (te) {
32947 return _this._singleTouchMove$
32949 .takeUntil(Observable_1.Observable
32950 .merge(multipleTouchStart$, touchStop$));
32952 var touchesChanged$ = Observable_1.Observable
32953 .merge(this._touchStart$, this._touchEnd$, this._touchCancel$);
32954 var pinchStart$ = touchesChanged$
32955 .filter(function (te) {
32956 return te.touches.length === 2 && te.targetTouches.length === 2;
32958 var pinchStop$ = touchesChanged$
32959 .filter(function (te) {
32960 return te.touches.length !== 2 || te.targetTouches.length !== 2;
32962 this._pinchOperation$ = new Subject_1.Subject();
32963 this._pinch$ = this._pinchOperation$
32964 .scan(function (pinch, operation) {
32965 return operation(pinch);
32983 .filter(function (te) {
32984 return te.touches.length === 2 && te.targetTouches.length === 2;
32986 .map(function (te) {
32987 return function (previous) {
32988 var touch1 = te.touches[0];
32989 var touch2 = te.touches[1];
32990 var minX = Math.min(touch1.clientX, touch2.clientX);
32991 var maxX = Math.max(touch1.clientX, touch2.clientX);
32992 var minY = Math.min(touch1.clientY, touch2.clientY);
32993 var maxY = Math.max(touch1.clientY, touch2.clientY);
32994 var centerClientX = minX + (maxX - minX) / 2;
32995 var centerClientY = minY + (maxY - minY) / 2;
32996 var centerPageX = centerClientX + touch1.pageX - touch1.clientX;
32997 var centerPageY = centerClientY + touch1.pageY - touch1.clientY;
32998 var centerScreenX = centerClientX + touch1.screenX - touch1.clientX;
32999 var centerScreenY = centerClientY + touch1.screenY - touch1.clientY;
33000 var distanceX = Math.abs(touch1.clientX - touch2.clientX);
33001 var distanceY = Math.abs(touch1.clientY - touch2.clientY);
33002 var distance = Math.sqrt(distanceX * distanceX + distanceY * distanceY);
33003 var distanceChange = distance - previous.distance;
33004 var changeX = distanceX - previous.distanceX;
33005 var changeY = distanceY - previous.distanceY;
33007 centerClientX: centerClientX,
33008 centerClientY: centerClientY,
33009 centerPageX: centerPageX,
33010 centerPageY: centerPageY,
33011 centerScreenX: centerScreenX,
33012 centerScreenY: centerScreenY,
33015 distance: distance,
33016 distanceChange: distanceChange,
33017 distanceX: distanceX,
33018 distanceY: distanceY,
33025 .subscribe(this._pinchOperation$);
33026 this._pinchChange$ = pinchStart$
33027 .switchMap(function (te) {
33028 return _this._pinch$
33030 .takeUntil(pinchStop$);
33033 Object.defineProperty(TouchService.prototype, "touchStart$", {
33035 return this._touchStart$;
33040 Object.defineProperty(TouchService.prototype, "touchMove$", {
33042 return this._touchMove$;
33047 Object.defineProperty(TouchService.prototype, "touchEnd$", {
33049 return this._touchEnd$;
33054 Object.defineProperty(TouchService.prototype, "touchCancel$", {
33056 return this._touchCancel$;
33061 Object.defineProperty(TouchService.prototype, "singleTouchMove$", {
33063 return this._singleTouch$;
33068 Object.defineProperty(TouchService.prototype, "pinch$", {
33070 return this._pinchChange$;
33075 Object.defineProperty(TouchService.prototype, "preventDefaultTouchMove$", {
33077 return this._preventTouchMove$;
33082 return TouchService;
33084 exports.TouchService = TouchService;
33086 },{"rxjs/Observable":28,"rxjs/Subject":33,"rxjs/add/operator/filter":56,"rxjs/add/operator/map":60,"rxjs/add/operator/merge":61,"rxjs/add/operator/scan":68,"rxjs/add/operator/switchMap":73}],320:[function(require,module,exports){
33087 /// <reference path="../../typings/index.d.ts" />
33089 var __extends = (this && this.__extends) || function (d, b) {
33090 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
33091 function __() { this.constructor = d; }
33092 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
33094 var when = require("when");
33095 var Viewer_1 = require("../Viewer");
33096 var Utils_1 = require("../Utils");
33100 * @classdesc The Viewer object represents the navigable photo viewer.
33101 * Create a Viewer by specifying a container, client ID, photo key and
33102 * other options. The viewer exposes methods and events for programmatic
33105 var Viewer = (function (_super) {
33106 __extends(Viewer, _super);
33108 * Create a new viewer instance.
33110 * @param {string} id - required `id` of an DOM element which will
33111 * be transformed into the viewer.
33112 * @param {string} clientId - required `Mapillary API ClientID`, can
33113 * be obtained from https://www.mapillary.com/app/settings/developers.
33114 * @param {string} key - optional `photoId` to start from, can be any
33115 * Mapillary photo, if null no image is loaded.
33116 * @param {IViewerOptions} options - optional configuration object
33117 * specifing Viewer's initial setup.
33119 function Viewer(id, clientId, key, options) {
33121 options = options != null ? options : {};
33122 Utils_1.Settings.setOptions(options);
33123 this._navigator = new Viewer_1.Navigator(clientId);
33124 this._container = new Viewer_1.Container(id, this._navigator.stateService, options);
33125 this._eventLauncher = new Viewer_1.EventLauncher(this, this._navigator, this._container);
33126 this._componentController = new Viewer_1.ComponentController(this._container, this._navigator, key, options.component);
33129 * Navigate to a given photo key.
33131 * @param {string} key - A valid Mapillary photo key.
33132 * @returns {Promise<Node>} Promise to the node that was navigated to.
33133 * @throws {Error} Propagates any IO errors to the caller.
33135 Viewer.prototype.moveToKey = function (key) {
33137 return when.promise(function (resolve, reject) {
33138 _this._navigator.moveToKey$(key).subscribe(function (node) {
33140 }, function (error) {
33146 * Navigate in a given direction.
33148 * @description This method has to be called through EdgeDirection enumeration as in the example.
33150 * @param {EdgeDirection} dir - Direction in which which to move.
33151 * @returns {Promise<Node>} Promise to the node that was navigated to.
33152 * @throws {Error} If the current node does not have the edge direction
33153 * or the edges has not yet been cached.
33154 * @throws {Error} Propagates any IO errors to the caller.
33156 * @example `viewer.moveDir(Mapillary.EdgeDirection.Next);`
33158 Viewer.prototype.moveDir = function (dir) {
33160 return when.promise(function (resolve, reject) {
33161 _this._navigator.moveDir$(dir).subscribe(function (node) {
33163 }, function (error) {
33169 * Move close to given latitude and longitude.
33171 * @param {Number} lat - Latitude, in degrees.
33172 * @param {Number} lon - Longitude, in degrees.
33173 * @returns {Promise<Node>} Promise to the node that was navigated to.
33174 * @throws {Error} If no nodes exist close to provided latitude
33176 * @throws {Error} Propagates any IO errors to the caller.
33178 Viewer.prototype.moveCloseTo = function (lat, lon) {
33180 return when.promise(function (resolve, reject) {
33181 _this._navigator.moveCloseTo$(lat, lon).subscribe(function (node) {
33183 }, function (error) {
33189 * Detect the viewer's new width and height and resize it.
33191 * @description The components will also detect the viewer's
33192 * new size and resize their rendered elements if needed.
33194 Viewer.prototype.resize = function () {
33195 this._container.renderService.resize$.next(null);
33196 this._componentController.resize();
33199 * Set the viewer's render mode.
33201 * @param {RenderMode} renderMode - Render mode.
33203 * @example `viewer.setRenderMode(Mapillary.RenderMode.Letterbox);`
33205 Viewer.prototype.setRenderMode = function (renderMode) {
33206 this._container.renderService.renderMode$.next(renderMode);
33209 * Activate a component.
33211 * @param {string} name - Name of the component which will become active.
33213 Viewer.prototype.activateComponent = function (name) {
33214 this._componentController.activate(name);
33217 * Deactivate a component.
33219 * @param {string} name - Name of component which become inactive.
33221 Viewer.prototype.deactivateComponent = function (name) {
33222 this._componentController.deactivate(name);
33227 * @param {string} name - Name of component.
33228 * @returns {Component} The requested component.
33230 Viewer.prototype.getComponent = function (name) {
33231 return this._componentController.get(name);
33234 * Activate the cover (deactivates all other components).
33236 Viewer.prototype.activateCover = function () {
33237 this._componentController.activateCover();
33240 * Deactivate the cover (activates all components marked as active).
33242 Viewer.prototype.deactivateCover = function () {
33243 this._componentController.deactivateCover();
33246 * Get the basic coordinates of the current photo that is
33247 * at the center of the viewport.
33249 * @description Basic coordinates are on the [0, 1] interval and
33250 * has the origin point, [0, 0], at the top left corner and the
33251 * maximum value, [1, 1], at the bottom right corner of the original
33254 * @returns {Promise<number[]>} Promise to the basic coordinates
33255 * of the current photo at the center for the viewport.
33257 Viewer.prototype.getCenter = function () {
33259 return when.promise(function (resolve, reject) {
33260 _this._navigator.stateService.getCenter()
33261 .subscribe(function (center) {
33263 }, function (error) {
33269 * Get the photo's current zoom level.
33271 * @returns {Promise<number>} Promise to the viewers's current
33274 Viewer.prototype.getZoom = function () {
33276 return when.promise(function (resolve, reject) {
33277 _this._navigator.stateService.getZoom()
33278 .subscribe(function (zoom) {
33280 }, function (error) {
33286 * Set the basic coordinates of the current photo to be in the
33287 * center of the viewport.
33289 * @description Basic coordinates are on the [0, 1] interval and
33290 * has the origin point, [0, 0], at the top left corner and the
33291 * maximum value, [1, 1], at the bottom right corner of the original
33294 * @param {number[]} The basic coordinates of the current
33295 * photo to be at the center for the viewport.
33297 Viewer.prototype.setCenter = function (center) {
33298 this._navigator.stateService.setCenter(center);
33301 * Set the photo's current zoom level.
33303 * @description Possible zoom level values are on the [0, 3] interval.
33304 * Zero means zooming out to fit the photo to the view whereas three
33305 * shows the highest level of detail.
33307 * @param {number} The photo's current zoom level.
33309 Viewer.prototype.setZoom = function (zoom) {
33310 this._navigator.stateService.setZoom(zoom);
33313 * Fired when the viewer is loading more data.
33315 * @type {boolean} loading - Value indicating whether the viewer is loading.
33317 Viewer.loadingchanged = "loadingchanged";
33319 * Fired when the viewer starts transitioning from one view to another,
33320 * either by changing the node or by interaction such as pan and zoom.
33323 Viewer.movestart = "movestart";
33325 * Fired when the viewer finishes transitioning and is in a fixed
33326 * position with a fixed point of view.
33329 Viewer.moveend = "moveend";
33331 * Fired every time the viewer navigates to a new node.
33333 * @type {Node} node - Current node.
33335 Viewer.nodechanged = "nodechanged";
33337 * Fired every time the sequence edges of the current node changes.
33339 * @type {IEdgeStatus} status - The edge status object.
33341 Viewer.sequenceedgeschanged = "sequenceedgeschanged";
33343 * Fired every time the spatial edges of the current node changes.
33345 * @type {IEdgeStatus} status - The edge status object.
33347 Viewer.spatialedgeschanged = "spatialedgeschanged";
33349 }(Utils_1.EventEmitter));
33350 exports.Viewer = Viewer;
33352 },{"../Utils":215,"../Viewer":216,"when":204}]},{},[212])(212)
33354 //# sourceMappingURL=mapillary.js.map