(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i 0) { throw new Error('Invalid string. Length must be a multiple of 4'); } // Trim off extra bytes after placeholder bytes are found // See: https://github.com/beatgammit/base64-js/issues/42 var validLen = b64.indexOf('='); if (validLen === -1) validLen = len; var placeHoldersLen = validLen === len ? 0 : 4 - validLen % 4; return [validLen, placeHoldersLen]; } // base64 is 4/3 + up to two characters of the original data function byteLength(b64) { var lens = getLens(b64); var validLen = lens[0]; var placeHoldersLen = lens[1]; return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen; } function _byteLength(b64, validLen, placeHoldersLen) { return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen; } function toByteArray(b64) { var tmp; var lens = getLens(b64); var validLen = lens[0]; var placeHoldersLen = lens[1]; var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen)); var curByte = 0; // if there are placeholders, only get up to the last complete 4 chars var len = placeHoldersLen > 0 ? validLen - 4 : validLen; var i; for (i = 0; i < len; i += 4) { tmp = revLookup[b64.charCodeAt(i)] << 18 | revLookup[b64.charCodeAt(i + 1)] << 12 | revLookup[b64.charCodeAt(i + 2)] << 6 | revLookup[b64.charCodeAt(i + 3)]; arr[curByte++] = tmp >> 16 & 0xFF; arr[curByte++] = tmp >> 8 & 0xFF; arr[curByte++] = tmp & 0xFF; } if (placeHoldersLen === 2) { tmp = revLookup[b64.charCodeAt(i)] << 2 | revLookup[b64.charCodeAt(i + 1)] >> 4; arr[curByte++] = tmp & 0xFF; } if (placeHoldersLen === 1) { tmp = revLookup[b64.charCodeAt(i)] << 10 | revLookup[b64.charCodeAt(i + 1)] << 4 | revLookup[b64.charCodeAt(i + 2)] >> 2; arr[curByte++] = tmp >> 8 & 0xFF; arr[curByte++] = tmp & 0xFF; } return arr; } function tripletToBase64(num) { return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F]; } function encodeChunk(uint8, start, end) { var tmp; var output = []; for (var i = start; i < end; i += 3) { tmp = (uint8[i] << 16 & 0xFF0000) + (uint8[i + 1] << 8 & 0xFF00) + (uint8[i + 2] & 0xFF); output.push(tripletToBase64(tmp)); } return output.join(''); } function fromByteArray(uint8) { var tmp; var len = uint8.length; var extraBytes = len % 3; // if we have 1 byte left, pad 2 bytes var parts = []; var maxChunkLength = 16383; // must be multiple of 3 // go through the array every three bytes, we'll deal with trailing stuff later for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { parts.push(encodeChunk(uint8, i, i + maxChunkLength > len2 ? len2 : i + maxChunkLength)); } // pad the end with zeros, but make sure to not forget the extra bytes if (extraBytes === 1) { tmp = uint8[len - 1]; parts.push(lookup[tmp >> 2] + lookup[tmp << 4 & 0x3F] + '=='); } else if (extraBytes === 2) { tmp = (uint8[len - 2] << 8) + uint8[len - 1]; parts.push(lookup[tmp >> 10] + lookup[tmp >> 4 & 0x3F] + lookup[tmp << 2 & 0x3F] + '='); } return parts.join(''); } },{}],2:[function(require,module,exports){ "use strict"; },{}],3:[function(require,module,exports){ (function (Buffer){(function (){ /*! * The buffer module from node.js, for the browser. * * @author Feross Aboukhadijeh * @license MIT */ /* eslint-disable no-proto */ 'use strict'; function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } var base64 = require('base64-js'); var ieee754 = require('ieee754'); exports.Buffer = Buffer; exports.SlowBuffer = SlowBuffer; exports.INSPECT_MAX_BYTES = 50; var K_MAX_LENGTH = 0x7fffffff; exports.kMaxLength = K_MAX_LENGTH; /** * If `Buffer.TYPED_ARRAY_SUPPORT`: * === true Use Uint8Array implementation (fastest) * === false Print warning and recommend using `buffer` v4.x which has an Object * implementation (most compatible, even IE6) * * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, * Opera 11.6+, iOS 4.2+. * * We report that the browser does not support typed arrays if the are not subclassable * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array` * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support * for __proto__ and has a buggy typed array implementation. */ Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport(); if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' && typeof console.error === 'function') { console.error('This browser lacks typed array (Uint8Array) support which is required by ' + '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.'); } function typedArraySupport() { // Can typed array instances can be augmented? try { var arr = new Uint8Array(1); arr.__proto__ = { __proto__: Uint8Array.prototype, foo: function foo() { return 42; } }; return arr.foo() === 42; } catch (e) { return false; } } Object.defineProperty(Buffer.prototype, 'parent', { enumerable: true, get: function get() { if (!Buffer.isBuffer(this)) return undefined; return this.buffer; } }); Object.defineProperty(Buffer.prototype, 'offset', { enumerable: true, get: function get() { if (!Buffer.isBuffer(this)) return undefined; return this.byteOffset; } }); function createBuffer(length) { if (length > K_MAX_LENGTH) { throw new RangeError('The value "' + length + '" is invalid for option "size"'); } // Return an augmented `Uint8Array` instance var buf = new Uint8Array(length); buf.__proto__ = Buffer.prototype; return buf; } /** * The Buffer constructor returns instances of `Uint8Array` that have their * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of * `Uint8Array`, so the returned instances will have all the node `Buffer` methods * and the `Uint8Array` methods. Square bracket notation works as expected -- it * returns a single octet. * * The `Uint8Array` prototype remains unmodified. */ function Buffer(arg, encodingOrOffset, length) { // Common case. if (typeof arg === 'number') { if (typeof encodingOrOffset === 'string') { throw new TypeError('The "string" argument must be of type string. Received type number'); } return allocUnsafe(arg); } return from(arg, encodingOrOffset, length); } // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97 if (typeof Symbol !== 'undefined' && Symbol.species != null && Buffer[Symbol.species] === Buffer) { Object.defineProperty(Buffer, Symbol.species, { value: null, configurable: true, enumerable: false, writable: false }); } Buffer.poolSize = 8192; // not used by this implementation function from(value, encodingOrOffset, length) { if (typeof value === 'string') { return fromString(value, encodingOrOffset); } if (ArrayBuffer.isView(value)) { return fromArrayLike(value); } if (value == null) { throw TypeError('The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' + 'or Array-like Object. Received type ' + _typeof(value)); } if (isInstance(value, ArrayBuffer) || value && isInstance(value.buffer, ArrayBuffer)) { return fromArrayBuffer(value, encodingOrOffset, length); } if (typeof value === 'number') { throw new TypeError('The "value" argument must not be of type number. Received type number'); } var valueOf = value.valueOf && value.valueOf(); if (valueOf != null && valueOf !== value) { return Buffer.from(valueOf, encodingOrOffset, length); } var b = fromObject(value); if (b) return b; if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null && typeof value[Symbol.toPrimitive] === 'function') { return Buffer.from(value[Symbol.toPrimitive]('string'), encodingOrOffset, length); } throw new TypeError('The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' + 'or Array-like Object. Received type ' + _typeof(value)); } /** * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError * if value is a number. * Buffer.from(str[, encoding]) * Buffer.from(array) * Buffer.from(buffer) * Buffer.from(arrayBuffer[, byteOffset[, length]]) **/ Buffer.from = function (value, encodingOrOffset, length) { return from(value, encodingOrOffset, length); }; // Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug: // https://github.com/feross/buffer/pull/148 Buffer.prototype.__proto__ = Uint8Array.prototype; Buffer.__proto__ = Uint8Array; function assertSize(size) { if (typeof size !== 'number') { throw new TypeError('"size" argument must be of type number'); } else if (size < 0) { throw new RangeError('The value "' + size + '" is invalid for option "size"'); } } function alloc(size, fill, encoding) { assertSize(size); if (size <= 0) { return createBuffer(size); } if (fill !== undefined) { // Only pay attention to encoding if it's a string. This // prevents accidentally sending in a number that would // be interpretted as a start offset. return typeof encoding === 'string' ? createBuffer(size).fill(fill, encoding) : createBuffer(size).fill(fill); } return createBuffer(size); } /** * Creates a new filled Buffer instance. * alloc(size[, fill[, encoding]]) **/ Buffer.alloc = function (size, fill, encoding) { return alloc(size, fill, encoding); }; function allocUnsafe(size) { assertSize(size); return createBuffer(size < 0 ? 0 : checked(size) | 0); } /** * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance. * */ Buffer.allocUnsafe = function (size) { return allocUnsafe(size); }; /** * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. */ Buffer.allocUnsafeSlow = function (size) { return allocUnsafe(size); }; function fromString(string, encoding) { if (typeof encoding !== 'string' || encoding === '') { encoding = 'utf8'; } if (!Buffer.isEncoding(encoding)) { throw new TypeError('Unknown encoding: ' + encoding); } var length = byteLength(string, encoding) | 0; var buf = createBuffer(length); var actual = buf.write(string, encoding); if (actual !== length) { // Writing a hex string, for example, that contains invalid characters will // cause everything after the first invalid character to be ignored. (e.g. // 'abxxcd' will be treated as 'ab') buf = buf.slice(0, actual); } return buf; } function fromArrayLike(array) { var length = array.length < 0 ? 0 : checked(array.length) | 0; var buf = createBuffer(length); for (var i = 0; i < length; i += 1) { buf[i] = array[i] & 255; } return buf; } function fromArrayBuffer(array, byteOffset, length) { if (byteOffset < 0 || array.byteLength < byteOffset) { throw new RangeError('"offset" is outside of buffer bounds'); } if (array.byteLength < byteOffset + (length || 0)) { throw new RangeError('"length" is outside of buffer bounds'); } var buf; if (byteOffset === undefined && length === undefined) { buf = new Uint8Array(array); } else if (length === undefined) { buf = new Uint8Array(array, byteOffset); } else { buf = new Uint8Array(array, byteOffset, length); } // Return an augmented `Uint8Array` instance buf.__proto__ = Buffer.prototype; return buf; } function fromObject(obj) { if (Buffer.isBuffer(obj)) { var len = checked(obj.length) | 0; var buf = createBuffer(len); if (buf.length === 0) { return buf; } obj.copy(buf, 0, 0, len); return buf; } if (obj.length !== undefined) { if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) { return createBuffer(0); } return fromArrayLike(obj); } if (obj.type === 'Buffer' && Array.isArray(obj.data)) { return fromArrayLike(obj.data); } } function checked(length) { // Note: cannot use `length < K_MAX_LENGTH` here because that fails when // length is NaN (which is otherwise coerced to zero.) if (length >= K_MAX_LENGTH) { throw new RangeError('Attempt to allocate Buffer larger than maximum ' + 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes'); } return length | 0; } function SlowBuffer(length) { if (+length != length) { // eslint-disable-line eqeqeq length = 0; } return Buffer.alloc(+length); } Buffer.isBuffer = function isBuffer(b) { return b != null && b._isBuffer === true && b !== Buffer.prototype; // so Buffer.isBuffer(Buffer.prototype) will be false }; Buffer.compare = function compare(a, b) { if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength); if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength); if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'); } if (a === b) return 0; var x = a.length; var y = b.length; for (var i = 0, len = Math.min(x, y); i < len; ++i) { if (a[i] !== b[i]) { x = a[i]; y = b[i]; break; } } if (x < y) return -1; if (y < x) return 1; return 0; }; Buffer.isEncoding = function isEncoding(encoding) { switch (String(encoding).toLowerCase()) { case 'hex': case 'utf8': case 'utf-8': case 'ascii': case 'latin1': case 'binary': case 'base64': case 'ucs2': case 'ucs-2': case 'utf16le': case 'utf-16le': return true; default: return false; } }; Buffer.concat = function concat(list, length) { if (!Array.isArray(list)) { throw new TypeError('"list" argument must be an Array of Buffers'); } if (list.length === 0) { return Buffer.alloc(0); } var i; if (length === undefined) { length = 0; for (i = 0; i < list.length; ++i) { length += list[i].length; } } var buffer = Buffer.allocUnsafe(length); var pos = 0; for (i = 0; i < list.length; ++i) { var buf = list[i]; if (isInstance(buf, Uint8Array)) { buf = Buffer.from(buf); } if (!Buffer.isBuffer(buf)) { throw new TypeError('"list" argument must be an Array of Buffers'); } buf.copy(buffer, pos); pos += buf.length; } return buffer; }; function byteLength(string, encoding) { if (Buffer.isBuffer(string)) { return string.length; } if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) { return string.byteLength; } if (typeof string !== 'string') { throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' + 'Received type ' + _typeof(string)); } var len = string.length; var mustMatch = arguments.length > 2 && arguments[2] === true; if (!mustMatch && len === 0) return 0; // Use a for loop to avoid recursion var loweredCase = false; for (;;) { switch (encoding) { case 'ascii': case 'latin1': case 'binary': return len; case 'utf8': case 'utf-8': return utf8ToBytes(string).length; case 'ucs2': case 'ucs-2': case 'utf16le': case 'utf-16le': return len * 2; case 'hex': return len >>> 1; case 'base64': return base64ToBytes(string).length; default: if (loweredCase) { return mustMatch ? -1 : utf8ToBytes(string).length; // assume utf8 } encoding = ('' + encoding).toLowerCase(); loweredCase = true; } } } Buffer.byteLength = byteLength; function slowToString(encoding, start, end) { var loweredCase = false; // No need to verify that "this.length <= MAX_UINT32" since it's a read-only // property of a typed array. // This behaves neither like String nor Uint8Array in that we set start/end // to their upper/lower bounds if the value passed is out of range. // undefined is handled specially as per ECMA-262 6th Edition, // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization. if (start === undefined || start < 0) { start = 0; } // Return early if start > this.length. Done here to prevent potential uint32 // coercion fail below. if (start > this.length) { return ''; } if (end === undefined || end > this.length) { end = this.length; } if (end <= 0) { return ''; } // Force coersion to uint32. This will also coerce falsey/NaN values to 0. end >>>= 0; start >>>= 0; if (end <= start) { return ''; } if (!encoding) encoding = 'utf8'; while (true) { switch (encoding) { case 'hex': return hexSlice(this, start, end); case 'utf8': case 'utf-8': return utf8Slice(this, start, end); case 'ascii': return asciiSlice(this, start, end); case 'latin1': case 'binary': return latin1Slice(this, start, end); case 'base64': return base64Slice(this, start, end); case 'ucs2': case 'ucs-2': case 'utf16le': case 'utf-16le': return utf16leSlice(this, start, end); default: if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding); encoding = (encoding + '').toLowerCase(); loweredCase = true; } } } // This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package) // to detect a Buffer instance. It's not possible to use `instanceof Buffer` // reliably in a browserify context because there could be multiple different // copies of the 'buffer' package in use. This method works even for Buffer // instances that were created from another copy of the `buffer` package. // See: https://github.com/feross/buffer/issues/154 Buffer.prototype._isBuffer = true; function swap(b, n, m) { var i = b[n]; b[n] = b[m]; b[m] = i; } Buffer.prototype.swap16 = function swap16() { var len = this.length; if (len % 2 !== 0) { throw new RangeError('Buffer size must be a multiple of 16-bits'); } for (var i = 0; i < len; i += 2) { swap(this, i, i + 1); } return this; }; Buffer.prototype.swap32 = function swap32() { var len = this.length; if (len % 4 !== 0) { throw new RangeError('Buffer size must be a multiple of 32-bits'); } for (var i = 0; i < len; i += 4) { swap(this, i, i + 3); swap(this, i + 1, i + 2); } return this; }; Buffer.prototype.swap64 = function swap64() { var len = this.length; if (len % 8 !== 0) { throw new RangeError('Buffer size must be a multiple of 64-bits'); } for (var i = 0; i < len; i += 8) { swap(this, i, i + 7); swap(this, i + 1, i + 6); swap(this, i + 2, i + 5); swap(this, i + 3, i + 4); } return this; }; Buffer.prototype.toString = function toString() { var length = this.length; if (length === 0) return ''; if (arguments.length === 0) return utf8Slice(this, 0, length); return slowToString.apply(this, arguments); }; Buffer.prototype.toLocaleString = Buffer.prototype.toString; Buffer.prototype.equals = function equals(b) { if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer'); if (this === b) return true; return Buffer.compare(this, b) === 0; }; Buffer.prototype.inspect = function inspect() { var str = ''; var max = exports.INSPECT_MAX_BYTES; str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim(); if (this.length > max) str += ' ... '; return ''; }; Buffer.prototype.compare = function compare(target, start, end, thisStart, thisEnd) { if (isInstance(target, Uint8Array)) { target = Buffer.from(target, target.offset, target.byteLength); } if (!Buffer.isBuffer(target)) { throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. ' + 'Received type ' + _typeof(target)); } if (start === undefined) { start = 0; } if (end === undefined) { end = target ? target.length : 0; } if (thisStart === undefined) { thisStart = 0; } if (thisEnd === undefined) { thisEnd = this.length; } if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) { throw new RangeError('out of range index'); } if (thisStart >= thisEnd && start >= end) { return 0; } if (thisStart >= thisEnd) { return -1; } if (start >= end) { return 1; } start >>>= 0; end >>>= 0; thisStart >>>= 0; thisEnd >>>= 0; if (this === target) return 0; var x = thisEnd - thisStart; var y = end - start; var len = Math.min(x, y); var thisCopy = this.slice(thisStart, thisEnd); var targetCopy = target.slice(start, end); for (var i = 0; i < len; ++i) { if (thisCopy[i] !== targetCopy[i]) { x = thisCopy[i]; y = targetCopy[i]; break; } } if (x < y) return -1; if (y < x) return 1; return 0; }; // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`, // OR the last index of `val` in `buffer` at offset <= `byteOffset`. // // Arguments: // - buffer - a Buffer to search // - val - a string, Buffer, or number // - byteOffset - an index into `buffer`; will be clamped to an int32 // - encoding - an optional encoding, relevant is val is a string // - dir - true for indexOf, false for lastIndexOf function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) { // Empty buffer means no match if (buffer.length === 0) return -1; // Normalize byteOffset if (typeof byteOffset === 'string') { encoding = byteOffset; byteOffset = 0; } else if (byteOffset > 0x7fffffff) { byteOffset = 0x7fffffff; } else if (byteOffset < -0x80000000) { byteOffset = -0x80000000; } byteOffset = +byteOffset; // Coerce to Number. if (numberIsNaN(byteOffset)) { // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer byteOffset = dir ? 0 : buffer.length - 1; } // Normalize byteOffset: negative offsets start from the end of the buffer if (byteOffset < 0) byteOffset = buffer.length + byteOffset; if (byteOffset >= buffer.length) { if (dir) return -1;else byteOffset = buffer.length - 1; } else if (byteOffset < 0) { if (dir) byteOffset = 0;else return -1; } // Normalize val if (typeof val === 'string') { val = Buffer.from(val, encoding); } // Finally, search either indexOf (if dir is true) or lastIndexOf if (Buffer.isBuffer(val)) { // Special case: looking for empty string/buffer always fails if (val.length === 0) { return -1; } return arrayIndexOf(buffer, val, byteOffset, encoding, dir); } else if (typeof val === 'number') { val = val & 0xFF; // Search for a byte value [0-255] if (typeof Uint8Array.prototype.indexOf === 'function') { if (dir) { return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset); } else { return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset); } } return arrayIndexOf(buffer, [val], byteOffset, encoding, dir); } throw new TypeError('val must be string, number or Buffer'); } function arrayIndexOf(arr, val, byteOffset, encoding, dir) { var indexSize = 1; var arrLength = arr.length; var valLength = val.length; if (encoding !== undefined) { encoding = String(encoding).toLowerCase(); if (encoding === 'ucs2' || encoding === 'ucs-2' || encoding === 'utf16le' || encoding === 'utf-16le') { if (arr.length < 2 || val.length < 2) { return -1; } indexSize = 2; arrLength /= 2; valLength /= 2; byteOffset /= 2; } } function read(buf, i) { if (indexSize === 1) { return buf[i]; } else { return buf.readUInt16BE(i * indexSize); } } var i; if (dir) { var foundIndex = -1; for (i = byteOffset; i < arrLength; i++) { if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) { if (foundIndex === -1) foundIndex = i; if (i - foundIndex + 1 === valLength) return foundIndex * indexSize; } else { if (foundIndex !== -1) i -= i - foundIndex; foundIndex = -1; } } } else { if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength; for (i = byteOffset; i >= 0; i--) { var found = true; for (var j = 0; j < valLength; j++) { if (read(arr, i + j) !== read(val, j)) { found = false; break; } } if (found) return i; } } return -1; } Buffer.prototype.includes = function includes(val, byteOffset, encoding) { return this.indexOf(val, byteOffset, encoding) !== -1; }; Buffer.prototype.indexOf = function indexOf(val, byteOffset, encoding) { return bidirectionalIndexOf(this, val, byteOffset, encoding, true); }; Buffer.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) { return bidirectionalIndexOf(this, val, byteOffset, encoding, false); }; function hexWrite(buf, string, offset, length) { offset = Number(offset) || 0; var remaining = buf.length - offset; if (!length) { length = remaining; } else { length = Number(length); if (length > remaining) { length = remaining; } } var strLen = string.length; if (length > strLen / 2) { length = strLen / 2; } for (var i = 0; i < length; ++i) { var parsed = parseInt(string.substr(i * 2, 2), 16); if (numberIsNaN(parsed)) return i; buf[offset + i] = parsed; } return i; } function utf8Write(buf, string, offset, length) { return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length); } function asciiWrite(buf, string, offset, length) { return blitBuffer(asciiToBytes(string), buf, offset, length); } function latin1Write(buf, string, offset, length) { return asciiWrite(buf, string, offset, length); } function base64Write(buf, string, offset, length) { return blitBuffer(base64ToBytes(string), buf, offset, length); } function ucs2Write(buf, string, offset, length) { return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length); } Buffer.prototype.write = function write(string, offset, length, encoding) { // Buffer#write(string) if (offset === undefined) { encoding = 'utf8'; length = this.length; offset = 0; // Buffer#write(string, encoding) } else if (length === undefined && typeof offset === 'string') { encoding = offset; length = this.length; offset = 0; // Buffer#write(string, offset[, length][, encoding]) } else if (isFinite(offset)) { offset = offset >>> 0; if (isFinite(length)) { length = length >>> 0; if (encoding === undefined) encoding = 'utf8'; } else { encoding = length; length = undefined; } } else { throw new Error('Buffer.write(string, encoding, offset[, length]) is no longer supported'); } var remaining = this.length - offset; if (length === undefined || length > remaining) length = remaining; if (string.length > 0 && (length < 0 || offset < 0) || offset > this.length) { throw new RangeError('Attempt to write outside buffer bounds'); } if (!encoding) encoding = 'utf8'; var loweredCase = false; for (;;) { switch (encoding) { case 'hex': return hexWrite(this, string, offset, length); case 'utf8': case 'utf-8': return utf8Write(this, string, offset, length); case 'ascii': return asciiWrite(this, string, offset, length); case 'latin1': case 'binary': return latin1Write(this, string, offset, length); case 'base64': // Warning: maxLength not taken into account in base64Write return base64Write(this, string, offset, length); case 'ucs2': case 'ucs-2': case 'utf16le': case 'utf-16le': return ucs2Write(this, string, offset, length); default: if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding); encoding = ('' + encoding).toLowerCase(); loweredCase = true; } } }; Buffer.prototype.toJSON = function toJSON() { return { type: 'Buffer', data: Array.prototype.slice.call(this._arr || this, 0) }; }; function base64Slice(buf, start, end) { if (start === 0 && end === buf.length) { return base64.fromByteArray(buf); } else { return base64.fromByteArray(buf.slice(start, end)); } } function utf8Slice(buf, start, end) { end = Math.min(buf.length, end); var res = []; var i = start; while (i < end) { var firstByte = buf[i]; var codePoint = null; var bytesPerSequence = firstByte > 0xEF ? 4 : firstByte > 0xDF ? 3 : firstByte > 0xBF ? 2 : 1; if (i + bytesPerSequence <= end) { var secondByte, thirdByte, fourthByte, tempCodePoint; switch (bytesPerSequence) { case 1: if (firstByte < 0x80) { codePoint = firstByte; } break; case 2: secondByte = buf[i + 1]; if ((secondByte & 0xC0) === 0x80) { tempCodePoint = (firstByte & 0x1F) << 0x6 | secondByte & 0x3F; if (tempCodePoint > 0x7F) { codePoint = tempCodePoint; } } break; case 3: secondByte = buf[i + 1]; thirdByte = buf[i + 2]; if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) { tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | thirdByte & 0x3F; if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) { codePoint = tempCodePoint; } } break; case 4: secondByte = buf[i + 1]; thirdByte = buf[i + 2]; fourthByte = buf[i + 3]; if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) { tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | fourthByte & 0x3F; if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) { codePoint = tempCodePoint; } } } } if (codePoint === null) { // we did not generate a valid codePoint so insert a // replacement char (U+FFFD) and advance only 1 byte codePoint = 0xFFFD; bytesPerSequence = 1; } else if (codePoint > 0xFFFF) { // encode to utf16 (surrogate pair dance) codePoint -= 0x10000; res.push(codePoint >>> 10 & 0x3FF | 0xD800); codePoint = 0xDC00 | codePoint & 0x3FF; } res.push(codePoint); i += bytesPerSequence; } return decodeCodePointsArray(res); } // Based on http://stackoverflow.com/a/22747272/680742, the browser with // the lowest limit is Chrome, with 0x10000 args. // We go 1 magnitude less, for safety var MAX_ARGUMENTS_LENGTH = 0x1000; function decodeCodePointsArray(codePoints) { var len = codePoints.length; if (len <= MAX_ARGUMENTS_LENGTH) { return String.fromCharCode.apply(String, codePoints); // avoid extra slice() } // Decode in chunks to avoid "call stack size exceeded". var res = ''; var i = 0; while (i < len) { res += String.fromCharCode.apply(String, codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)); } return res; } function asciiSlice(buf, start, end) { var ret = ''; end = Math.min(buf.length, end); for (var i = start; i < end; ++i) { ret += String.fromCharCode(buf[i] & 0x7F); } return ret; } function latin1Slice(buf, start, end) { var ret = ''; end = Math.min(buf.length, end); for (var i = start; i < end; ++i) { ret += String.fromCharCode(buf[i]); } return ret; } function hexSlice(buf, start, end) { var len = buf.length; if (!start || start < 0) start = 0; if (!end || end < 0 || end > len) end = len; var out = ''; for (var i = start; i < end; ++i) { out += toHex(buf[i]); } return out; } function utf16leSlice(buf, start, end) { var bytes = buf.slice(start, end); var res = ''; for (var i = 0; i < bytes.length; i += 2) { res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256); } return res; } Buffer.prototype.slice = function slice(start, end) { var len = this.length; start = ~~start; end = end === undefined ? len : ~~end; if (start < 0) { start += len; if (start < 0) start = 0; } else if (start > len) { start = len; } if (end < 0) { end += len; if (end < 0) end = 0; } else if (end > len) { end = len; } if (end < start) end = start; var newBuf = this.subarray(start, end); // Return an augmented `Uint8Array` instance newBuf.__proto__ = Buffer.prototype; return newBuf; }; /* * Need to make sure that buffer isn't trying to write out of bounds. */ function checkOffset(offset, ext, length) { if (offset % 1 !== 0 || offset < 0) throw new RangeError('offset is not uint'); if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length'); } Buffer.prototype.readUIntLE = function readUIntLE(offset, byteLength, noAssert) { offset = offset >>> 0; byteLength = byteLength >>> 0; if (!noAssert) checkOffset(offset, byteLength, this.length); var val = this[offset]; var mul = 1; var i = 0; while (++i < byteLength && (mul *= 0x100)) { val += this[offset + i] * mul; } return val; }; Buffer.prototype.readUIntBE = function readUIntBE(offset, byteLength, noAssert) { offset = offset >>> 0; byteLength = byteLength >>> 0; if (!noAssert) { checkOffset(offset, byteLength, this.length); } var val = this[offset + --byteLength]; var mul = 1; while (byteLength > 0 && (mul *= 0x100)) { val += this[offset + --byteLength] * mul; } return val; }; Buffer.prototype.readUInt8 = function readUInt8(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 1, this.length); return this[offset]; }; Buffer.prototype.readUInt16LE = function readUInt16LE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 2, this.length); return this[offset] | this[offset + 1] << 8; }; Buffer.prototype.readUInt16BE = function readUInt16BE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 2, this.length); return this[offset] << 8 | this[offset + 1]; }; Buffer.prototype.readUInt32LE = function readUInt32LE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 4, this.length); return (this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16) + this[offset + 3] * 0x1000000; }; Buffer.prototype.readUInt32BE = function readUInt32BE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 4, this.length); return this[offset] * 0x1000000 + (this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]); }; Buffer.prototype.readIntLE = function readIntLE(offset, byteLength, noAssert) { offset = offset >>> 0; byteLength = byteLength >>> 0; if (!noAssert) checkOffset(offset, byteLength, this.length); var val = this[offset]; var mul = 1; var i = 0; while (++i < byteLength && (mul *= 0x100)) { val += this[offset + i] * mul; } mul *= 0x80; if (val >= mul) val -= Math.pow(2, 8 * byteLength); return val; }; Buffer.prototype.readIntBE = function readIntBE(offset, byteLength, noAssert) { offset = offset >>> 0; byteLength = byteLength >>> 0; if (!noAssert) checkOffset(offset, byteLength, this.length); var i = byteLength; var mul = 1; var val = this[offset + --i]; while (i > 0 && (mul *= 0x100)) { val += this[offset + --i] * mul; } mul *= 0x80; if (val >= mul) val -= Math.pow(2, 8 * byteLength); return val; }; Buffer.prototype.readInt8 = function readInt8(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 1, this.length); if (!(this[offset] & 0x80)) return this[offset]; return (0xff - this[offset] + 1) * -1; }; Buffer.prototype.readInt16LE = function readInt16LE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 2, this.length); var val = this[offset] | this[offset + 1] << 8; return val & 0x8000 ? val | 0xFFFF0000 : val; }; Buffer.prototype.readInt16BE = function readInt16BE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 2, this.length); var val = this[offset + 1] | this[offset] << 8; return val & 0x8000 ? val | 0xFFFF0000 : val; }; Buffer.prototype.readInt32LE = function readInt32LE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 4, this.length); return this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16 | this[offset + 3] << 24; }; Buffer.prototype.readInt32BE = function readInt32BE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 4, this.length); return this[offset] << 24 | this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]; }; Buffer.prototype.readFloatLE = function readFloatLE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 4, this.length); return ieee754.read(this, offset, true, 23, 4); }; Buffer.prototype.readFloatBE = function readFloatBE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 4, this.length); return ieee754.read(this, offset, false, 23, 4); }; Buffer.prototype.readDoubleLE = function readDoubleLE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 8, this.length); return ieee754.read(this, offset, true, 52, 8); }; Buffer.prototype.readDoubleBE = function readDoubleBE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 8, this.length); return ieee754.read(this, offset, false, 52, 8); }; function checkInt(buf, value, offset, ext, max, min) { if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance'); if (value > max || value < min) throw new RangeError('"value" argument is out of bounds'); if (offset + ext > buf.length) throw new RangeError('Index out of range'); } Buffer.prototype.writeUIntLE = function writeUIntLE(value, offset, byteLength, noAssert) { value = +value; offset = offset >>> 0; byteLength = byteLength >>> 0; if (!noAssert) { var maxBytes = Math.pow(2, 8 * byteLength) - 1; checkInt(this, value, offset, byteLength, maxBytes, 0); } var mul = 1; var i = 0; this[offset] = value & 0xFF; while (++i < byteLength && (mul *= 0x100)) { this[offset + i] = value / mul & 0xFF; } return offset + byteLength; }; Buffer.prototype.writeUIntBE = function writeUIntBE(value, offset, byteLength, noAssert) { value = +value; offset = offset >>> 0; byteLength = byteLength >>> 0; if (!noAssert) { var maxBytes = Math.pow(2, 8 * byteLength) - 1; checkInt(this, value, offset, byteLength, maxBytes, 0); } var i = byteLength - 1; var mul = 1; this[offset + i] = value & 0xFF; while (--i >= 0 && (mul *= 0x100)) { this[offset + i] = value / mul & 0xFF; } return offset + byteLength; }; Buffer.prototype.writeUInt8 = function writeUInt8(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0); this[offset] = value & 0xff; return offset + 1; }; Buffer.prototype.writeUInt16LE = function writeUInt16LE(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0); this[offset] = value & 0xff; this[offset + 1] = value >>> 8; return offset + 2; }; Buffer.prototype.writeUInt16BE = function writeUInt16BE(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0); this[offset] = value >>> 8; this[offset + 1] = value & 0xff; return offset + 2; }; Buffer.prototype.writeUInt32LE = function writeUInt32LE(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0); this[offset + 3] = value >>> 24; this[offset + 2] = value >>> 16; this[offset + 1] = value >>> 8; this[offset] = value & 0xff; return offset + 4; }; Buffer.prototype.writeUInt32BE = function writeUInt32BE(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0); this[offset] = value >>> 24; this[offset + 1] = value >>> 16; this[offset + 2] = value >>> 8; this[offset + 3] = value & 0xff; return offset + 4; }; Buffer.prototype.writeIntLE = function writeIntLE(value, offset, byteLength, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) { var limit = Math.pow(2, 8 * byteLength - 1); checkInt(this, value, offset, byteLength, limit - 1, -limit); } var i = 0; var mul = 1; var sub = 0; this[offset] = value & 0xFF; while (++i < byteLength && (mul *= 0x100)) { if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) { sub = 1; } this[offset + i] = (value / mul >> 0) - sub & 0xFF; } return offset + byteLength; }; Buffer.prototype.writeIntBE = function writeIntBE(value, offset, byteLength, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) { var limit = Math.pow(2, 8 * byteLength - 1); checkInt(this, value, offset, byteLength, limit - 1, -limit); } var i = byteLength - 1; var mul = 1; var sub = 0; this[offset + i] = value & 0xFF; while (--i >= 0 && (mul *= 0x100)) { if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) { sub = 1; } this[offset + i] = (value / mul >> 0) - sub & 0xFF; } return offset + byteLength; }; Buffer.prototype.writeInt8 = function writeInt8(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80); if (value < 0) value = 0xff + value + 1; this[offset] = value & 0xff; return offset + 1; }; Buffer.prototype.writeInt16LE = function writeInt16LE(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000); this[offset] = value & 0xff; this[offset + 1] = value >>> 8; return offset + 2; }; Buffer.prototype.writeInt16BE = function writeInt16BE(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000); this[offset] = value >>> 8; this[offset + 1] = value & 0xff; return offset + 2; }; Buffer.prototype.writeInt32LE = function writeInt32LE(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000); this[offset] = value & 0xff; this[offset + 1] = value >>> 8; this[offset + 2] = value >>> 16; this[offset + 3] = value >>> 24; return offset + 4; }; Buffer.prototype.writeInt32BE = function writeInt32BE(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000); if (value < 0) value = 0xffffffff + value + 1; this[offset] = value >>> 24; this[offset + 1] = value >>> 16; this[offset + 2] = value >>> 8; this[offset + 3] = value & 0xff; return offset + 4; }; function checkIEEE754(buf, value, offset, ext, max, min) { if (offset + ext > buf.length) throw new RangeError('Index out of range'); if (offset < 0) throw new RangeError('Index out of range'); } function writeFloat(buf, value, offset, littleEndian, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) { checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38); } ieee754.write(buf, value, offset, littleEndian, 23, 4); return offset + 4; } Buffer.prototype.writeFloatLE = function writeFloatLE(value, offset, noAssert) { return writeFloat(this, value, offset, true, noAssert); }; Buffer.prototype.writeFloatBE = function writeFloatBE(value, offset, noAssert) { return writeFloat(this, value, offset, false, noAssert); }; function writeDouble(buf, value, offset, littleEndian, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) { checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308); } ieee754.write(buf, value, offset, littleEndian, 52, 8); return offset + 8; } Buffer.prototype.writeDoubleLE = function writeDoubleLE(value, offset, noAssert) { return writeDouble(this, value, offset, true, noAssert); }; Buffer.prototype.writeDoubleBE = function writeDoubleBE(value, offset, noAssert) { return writeDouble(this, value, offset, false, noAssert); }; // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) Buffer.prototype.copy = function copy(target, targetStart, start, end) { if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer'); if (!start) start = 0; if (!end && end !== 0) end = this.length; if (targetStart >= target.length) targetStart = target.length; if (!targetStart) targetStart = 0; if (end > 0 && end < start) end = start; // Copy 0 bytes; we're done if (end === start) return 0; if (target.length === 0 || this.length === 0) return 0; // Fatal error conditions if (targetStart < 0) { throw new RangeError('targetStart out of bounds'); } if (start < 0 || start >= this.length) throw new RangeError('Index out of range'); if (end < 0) throw new RangeError('sourceEnd out of bounds'); // Are we oob? if (end > this.length) end = this.length; if (target.length - targetStart < end - start) { end = target.length - targetStart + start; } var len = end - start; if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') { // Use built-in when available, missing from IE11 this.copyWithin(targetStart, start, end); } else if (this === target && start < targetStart && targetStart < end) { // descending copy from end for (var i = len - 1; i >= 0; --i) { target[i + targetStart] = this[i + start]; } } else { Uint8Array.prototype.set.call(target, this.subarray(start, end), targetStart); } return len; }; // Usage: // buffer.fill(number[, offset[, end]]) // buffer.fill(buffer[, offset[, end]]) // buffer.fill(string[, offset[, end]][, encoding]) Buffer.prototype.fill = function fill(val, start, end, encoding) { // Handle string cases: if (typeof val === 'string') { if (typeof start === 'string') { encoding = start; start = 0; end = this.length; } else if (typeof end === 'string') { encoding = end; end = this.length; } if (encoding !== undefined && typeof encoding !== 'string') { throw new TypeError('encoding must be a string'); } if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) { throw new TypeError('Unknown encoding: ' + encoding); } if (val.length === 1) { var code = val.charCodeAt(0); if (encoding === 'utf8' && code < 128 || encoding === 'latin1') { // Fast path: If `val` fits into a single byte, use that numeric value. val = code; } } } else if (typeof val === 'number') { val = val & 255; } // Invalid ranges are not set to a default, so can range check early. if (start < 0 || this.length < start || this.length < end) { throw new RangeError('Out of range index'); } if (end <= start) { return this; } start = start >>> 0; end = end === undefined ? this.length : end >>> 0; if (!val) val = 0; var i; if (typeof val === 'number') { for (i = start; i < end; ++i) { this[i] = val; } } else { var bytes = Buffer.isBuffer(val) ? val : Buffer.from(val, encoding); var len = bytes.length; if (len === 0) { throw new TypeError('The value "' + val + '" is invalid for argument "value"'); } for (i = 0; i < end - start; ++i) { this[i + start] = bytes[i % len]; } } return this; }; // HELPER FUNCTIONS // ================ var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g; function base64clean(str) { // Node takes equal signs as end of the Base64 encoding str = str.split('=')[0]; // Node strips out invalid characters like \n and \t from the string, base64-js does not str = str.trim().replace(INVALID_BASE64_RE, ''); // Node converts strings with length < 2 to '' if (str.length < 2) return ''; // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not while (str.length % 4 !== 0) { str = str + '='; } return str; } function toHex(n) { if (n < 16) return '0' + n.toString(16); return n.toString(16); } function utf8ToBytes(string, units) { units = units || Infinity; var codePoint; var length = string.length; var leadSurrogate = null; var bytes = []; for (var i = 0; i < length; ++i) { codePoint = string.charCodeAt(i); // is surrogate component if (codePoint > 0xD7FF && codePoint < 0xE000) { // last char was a lead if (!leadSurrogate) { // no lead yet if (codePoint > 0xDBFF) { // unexpected trail if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD); continue; } else if (i + 1 === length) { // unpaired lead if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD); continue; } // valid lead leadSurrogate = codePoint; continue; } // 2 leads in a row if (codePoint < 0xDC00) { if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD); leadSurrogate = codePoint; continue; } // valid surrogate pair codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000; } else if (leadSurrogate) { // valid bmp char, but last char was a lead if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD); } leadSurrogate = null; // encode utf8 if (codePoint < 0x80) { if ((units -= 1) < 0) break; bytes.push(codePoint); } else if (codePoint < 0x800) { if ((units -= 2) < 0) break; bytes.push(codePoint >> 0x6 | 0xC0, codePoint & 0x3F | 0x80); } else if (codePoint < 0x10000) { if ((units -= 3) < 0) break; bytes.push(codePoint >> 0xC | 0xE0, codePoint >> 0x6 & 0x3F | 0x80, codePoint & 0x3F | 0x80); } else if (codePoint < 0x110000) { if ((units -= 4) < 0) break; bytes.push(codePoint >> 0x12 | 0xF0, codePoint >> 0xC & 0x3F | 0x80, codePoint >> 0x6 & 0x3F | 0x80, codePoint & 0x3F | 0x80); } else { throw new Error('Invalid code point'); } } return bytes; } function asciiToBytes(str) { var byteArray = []; for (var i = 0; i < str.length; ++i) { // Node's code seems to be doing this and not & 0x7F.. byteArray.push(str.charCodeAt(i) & 0xFF); } return byteArray; } function utf16leToBytes(str, units) { var c, hi, lo; var byteArray = []; for (var i = 0; i < str.length; ++i) { if ((units -= 2) < 0) break; c = str.charCodeAt(i); hi = c >> 8; lo = c % 256; byteArray.push(lo); byteArray.push(hi); } return byteArray; } function base64ToBytes(str) { return base64.toByteArray(base64clean(str)); } function blitBuffer(src, dst, offset, length) { for (var i = 0; i < length; ++i) { if (i + offset >= dst.length || i >= src.length) break; dst[i + offset] = src[i]; } return i; } // ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass // the `instanceof` check but they should be treated as of that type. // See: https://github.com/feross/buffer/issues/166 function isInstance(obj, type) { return obj instanceof type || obj != null && obj.constructor != null && obj.constructor.name != null && obj.constructor.name === type.name; } function numberIsNaN(obj) { // For IE11 support return obj !== obj; // eslint-disable-line no-self-compare } }).call(this)}).call(this,require("buffer").Buffer) },{"base64-js":1,"buffer":3,"ieee754":4}],4:[function(require,module,exports){ "use strict"; /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */ exports.read = function (buffer, offset, isLE, mLen, nBytes) { var e, m; var eLen = nBytes * 8 - mLen - 1; var eMax = (1 << eLen) - 1; var eBias = eMax >> 1; var nBits = -7; var i = isLE ? nBytes - 1 : 0; var d = isLE ? -1 : 1; var s = buffer[offset + i]; i += d; e = s & (1 << -nBits) - 1; s >>= -nBits; nBits += eLen; for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {} m = e & (1 << -nBits) - 1; e >>= -nBits; nBits += mLen; for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {} if (e === 0) { e = 1 - eBias; } else if (e === eMax) { return m ? NaN : (s ? -1 : 1) * Infinity; } else { m = m + Math.pow(2, mLen); e = e - eBias; } return (s ? -1 : 1) * m * Math.pow(2, e - mLen); }; exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { var e, m, c; var eLen = nBytes * 8 - mLen - 1; var eMax = (1 << eLen) - 1; var eBias = eMax >> 1; var rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0; var i = isLE ? 0 : nBytes - 1; var d = isLE ? 1 : -1; var s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0; value = Math.abs(value); if (isNaN(value) || value === Infinity) { m = isNaN(value) ? 1 : 0; e = eMax; } else { e = Math.floor(Math.log(value) / Math.LN2); if (value * (c = Math.pow(2, -e)) < 1) { e--; c *= 2; } if (e + eBias >= 1) { value += rt / c; } else { value += rt * Math.pow(2, 1 - eBias); } if (value * c >= 2) { e++; c /= 2; } if (e + eBias >= eMax) { m = 0; e = eMax; } else if (e + eBias >= 1) { m = (value * c - 1) * Math.pow(2, mLen); e = e + eBias; } else { m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen); e = 0; } } for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {} e = e << mLen | m; eLen += mLen; for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {} buffer[offset + i - d] |= s * 128; }; },{}],5:[function(require,module,exports){ (function (process){(function (){ // 'path' module extracted from Node.js v8.11.1 (only the posix part) // transplited with Babel // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to permit // persons to whom the Software is furnished to do so, subject to the // following conditions: // // The above copyright notice and this permission notice shall be included // in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. 'use strict'; function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } function assertPath(path) { if (typeof path !== 'string') { throw new TypeError('Path must be a string. Received ' + JSON.stringify(path)); } } // Resolves . and .. elements in a path with directory names function normalizeStringPosix(path, allowAboveRoot) { var res = ''; var lastSegmentLength = 0; var lastSlash = -1; var dots = 0; var code; for (var i = 0; i <= path.length; ++i) { if (i < path.length) code = path.charCodeAt(i);else if (code === 47 /*/*/) break;else code = 47 /*/*/; if (code === 47 /*/*/) { if (lastSlash === i - 1 || dots === 1) { // NOOP } else if (lastSlash !== i - 1 && dots === 2) { if (res.length < 2 || lastSegmentLength !== 2 || res.charCodeAt(res.length - 1) !== 46 /*.*/ || res.charCodeAt(res.length - 2) !== 46 /*.*/) { if (res.length > 2) { var lastSlashIndex = res.lastIndexOf('/'); if (lastSlashIndex !== res.length - 1) { if (lastSlashIndex === -1) { res = ''; lastSegmentLength = 0; } else { res = res.slice(0, lastSlashIndex); lastSegmentLength = res.length - 1 - res.lastIndexOf('/'); } lastSlash = i; dots = 0; continue; } } else if (res.length === 2 || res.length === 1) { res = ''; lastSegmentLength = 0; lastSlash = i; dots = 0; continue; } } if (allowAboveRoot) { if (res.length > 0) res += '/..';else res = '..'; lastSegmentLength = 2; } } else { if (res.length > 0) res += '/' + path.slice(lastSlash + 1, i);else res = path.slice(lastSlash + 1, i); lastSegmentLength = i - lastSlash - 1; } lastSlash = i; dots = 0; } else if (code === 46 /*.*/ && dots !== -1) { ++dots; } else { dots = -1; } } return res; } function _format(sep, pathObject) { var dir = pathObject.dir || pathObject.root; var base = pathObject.base || (pathObject.name || '') + (pathObject.ext || ''); if (!dir) { return base; } if (dir === pathObject.root) { return dir + base; } return dir + sep + base; } var posix = { // path.resolve([from ...], to) resolve: function resolve() { var resolvedPath = ''; var resolvedAbsolute = false; var cwd; for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) { var path; if (i >= 0) path = arguments[i];else { if (cwd === undefined) cwd = process.cwd(); path = cwd; } assertPath(path); // Skip empty entries if (path.length === 0) { continue; } resolvedPath = path + '/' + resolvedPath; resolvedAbsolute = path.charCodeAt(0) === 47 /*/*/; } // At this point the path should be resolved to a full absolute path, but // handle relative paths to be safe (might happen when process.cwd() fails) // Normalize the path resolvedPath = normalizeStringPosix(resolvedPath, !resolvedAbsolute); if (resolvedAbsolute) { if (resolvedPath.length > 0) return '/' + resolvedPath;else return '/'; } else if (resolvedPath.length > 0) { return resolvedPath; } else { return '.'; } }, normalize: function normalize(path) { assertPath(path); if (path.length === 0) return '.'; var isAbsolute = path.charCodeAt(0) === 47 /*/*/; var trailingSeparator = path.charCodeAt(path.length - 1) === 47 /*/*/; // Normalize the path path = normalizeStringPosix(path, !isAbsolute); if (path.length === 0 && !isAbsolute) path = '.'; if (path.length > 0 && trailingSeparator) path += '/'; if (isAbsolute) return '/' + path; return path; }, isAbsolute: function isAbsolute(path) { assertPath(path); return path.length > 0 && path.charCodeAt(0) === 47 /*/*/; }, join: function join() { if (arguments.length === 0) return '.'; var joined; for (var i = 0; i < arguments.length; ++i) { var arg = arguments[i]; assertPath(arg); if (arg.length > 0) { if (joined === undefined) joined = arg;else joined += '/' + arg; } } if (joined === undefined) return '.'; return posix.normalize(joined); }, relative: function relative(from, to) { assertPath(from); assertPath(to); if (from === to) return ''; from = posix.resolve(from); to = posix.resolve(to); if (from === to) return ''; // Trim any leading backslashes var fromStart = 1; for (; fromStart < from.length; ++fromStart) { if (from.charCodeAt(fromStart) !== 47 /*/*/) break; } var fromEnd = from.length; var fromLen = fromEnd - fromStart; // Trim any leading backslashes var toStart = 1; for (; toStart < to.length; ++toStart) { if (to.charCodeAt(toStart) !== 47 /*/*/) break; } var toEnd = to.length; var toLen = toEnd - toStart; // Compare paths to find the longest common path from root var length = fromLen < toLen ? fromLen : toLen; var lastCommonSep = -1; var i = 0; for (; i <= length; ++i) { if (i === length) { if (toLen > length) { if (to.charCodeAt(toStart + i) === 47 /*/*/) { // We get here if `from` is the exact base path for `to`. // For example: from='/foo/bar'; to='/foo/bar/baz' return to.slice(toStart + i + 1); } else if (i === 0) { // We get here if `from` is the root // For example: from='/'; to='/foo' return to.slice(toStart + i); } } else if (fromLen > length) { if (from.charCodeAt(fromStart + i) === 47 /*/*/) { // We get here if `to` is the exact base path for `from`. // For example: from='/foo/bar/baz'; to='/foo/bar' lastCommonSep = i; } else if (i === 0) { // We get here if `to` is the root. // For example: from='/foo'; to='/' lastCommonSep = 0; } } break; } var fromCode = from.charCodeAt(fromStart + i); var toCode = to.charCodeAt(toStart + i); if (fromCode !== toCode) break;else if (fromCode === 47 /*/*/) lastCommonSep = i; } var out = ''; // Generate the relative path based on the path difference between `to` // and `from` for (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) { if (i === fromEnd || from.charCodeAt(i) === 47 /*/*/) { if (out.length === 0) out += '..';else out += '/..'; } } // Lastly, append the rest of the destination (`to`) path that comes after // the common path parts if (out.length > 0) return out + to.slice(toStart + lastCommonSep);else { toStart += lastCommonSep; if (to.charCodeAt(toStart) === 47 /*/*/) ++toStart; return to.slice(toStart); } }, _makeLong: function _makeLong(path) { return path; }, dirname: function dirname(path) { assertPath(path); if (path.length === 0) return '.'; var code = path.charCodeAt(0); var hasRoot = code === 47 /*/*/; var end = -1; var matchedSlash = true; for (var i = path.length - 1; i >= 1; --i) { code = path.charCodeAt(i); if (code === 47 /*/*/) { if (!matchedSlash) { end = i; break; } } else { // We saw the first non-path separator matchedSlash = false; } } if (end === -1) return hasRoot ? '/' : '.'; if (hasRoot && end === 1) return '//'; return path.slice(0, end); }, basename: function basename(path, ext) { if (ext !== undefined && typeof ext !== 'string') throw new TypeError('"ext" argument must be a string'); assertPath(path); var start = 0; var end = -1; var matchedSlash = true; var i; if (ext !== undefined && ext.length > 0 && ext.length <= path.length) { if (ext.length === path.length && ext === path) return ''; var extIdx = ext.length - 1; var firstNonSlashEnd = -1; for (i = path.length - 1; i >= 0; --i) { var code = path.charCodeAt(i); if (code === 47 /*/*/) { // If we reached a path separator that was not part of a set of path // separators at the end of the string, stop now if (!matchedSlash) { start = i + 1; break; } } else { if (firstNonSlashEnd === -1) { // We saw the first non-path separator, remember this index in case // we need it if the extension ends up not matching matchedSlash = false; firstNonSlashEnd = i + 1; } if (extIdx >= 0) { // Try to match the explicit extension if (code === ext.charCodeAt(extIdx)) { if (--extIdx === -1) { // We matched the extension, so mark this as the end of our path // component end = i; } } else { // Extension does not match, so our result is the entire path // component extIdx = -1; end = firstNonSlashEnd; } } } } if (start === end) end = firstNonSlashEnd;else if (end === -1) end = path.length; return path.slice(start, end); } else { for (i = path.length - 1; i >= 0; --i) { if (path.charCodeAt(i) === 47 /*/*/) { // If we reached a path separator that was not part of a set of path // separators at the end of the string, stop now if (!matchedSlash) { start = i + 1; break; } } else if (end === -1) { // We saw the first non-path separator, mark this as the end of our // path component matchedSlash = false; end = i + 1; } } if (end === -1) return ''; return path.slice(start, end); } }, extname: function extname(path) { assertPath(path); var startDot = -1; var startPart = 0; var end = -1; var matchedSlash = true; // Track the state of characters (if any) we see before our first dot and // after any path separator we find var preDotState = 0; for (var i = path.length - 1; i >= 0; --i) { var code = path.charCodeAt(i); if (code === 47 /*/*/) { // If we reached a path separator that was not part of a set of path // separators at the end of the string, stop now if (!matchedSlash) { startPart = i + 1; break; } continue; } if (end === -1) { // We saw the first non-path separator, mark this as the end of our // extension matchedSlash = false; end = i + 1; } if (code === 46 /*.*/) { // If this is our first dot, mark it as the start of our extension if (startDot === -1) startDot = i;else if (preDotState !== 1) preDotState = 1; } else if (startDot !== -1) { // We saw a non-dot and non-path separator before our dot, so we should // have a good chance at having a non-empty extension preDotState = -1; } } if (startDot === -1 || end === -1 || // We saw a non-dot character immediately before the dot preDotState === 0 || // The (right-most) trimmed path component is exactly '..' preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) { return ''; } return path.slice(startDot, end); }, format: function format(pathObject) { if (pathObject === null || _typeof(pathObject) !== 'object') { throw new TypeError('The "pathObject" argument must be of type Object. Received type ' + _typeof(pathObject)); } return _format('/', pathObject); }, parse: function parse(path) { assertPath(path); var ret = { root: '', dir: '', base: '', ext: '', name: '' }; if (path.length === 0) return ret; var code = path.charCodeAt(0); var isAbsolute = code === 47 /*/*/; var start; if (isAbsolute) { ret.root = '/'; start = 1; } else { start = 0; } var startDot = -1; var startPart = 0; var end = -1; var matchedSlash = true; var i = path.length - 1; // Track the state of characters (if any) we see before our first dot and // after any path separator we find var preDotState = 0; // Get non-dir info for (; i >= start; --i) { code = path.charCodeAt(i); if (code === 47 /*/*/) { // If we reached a path separator that was not part of a set of path // separators at the end of the string, stop now if (!matchedSlash) { startPart = i + 1; break; } continue; } if (end === -1) { // We saw the first non-path separator, mark this as the end of our // extension matchedSlash = false; end = i + 1; } if (code === 46 /*.*/) { // If this is our first dot, mark it as the start of our extension if (startDot === -1) startDot = i;else if (preDotState !== 1) preDotState = 1; } else if (startDot !== -1) { // We saw a non-dot and non-path separator before our dot, so we should // have a good chance at having a non-empty extension preDotState = -1; } } if (startDot === -1 || end === -1 || // We saw a non-dot character immediately before the dot preDotState === 0 || // The (right-most) trimmed path component is exactly '..' preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) { if (end !== -1) { if (startPart === 0 && isAbsolute) ret.base = ret.name = path.slice(1, end);else ret.base = ret.name = path.slice(startPart, end); } } else { if (startPart === 0 && isAbsolute) { ret.name = path.slice(1, startDot); ret.base = path.slice(1, end); } else { ret.name = path.slice(startPart, startDot); ret.base = path.slice(startPart, end); } ret.ext = path.slice(startDot, end); } if (startPart > 0) ret.dir = path.slice(0, startPart - 1);else if (isAbsolute) ret.dir = '/'; return ret; }, sep: '/', delimiter: ':', win32: null, posix: null }; posix.posix = posix; module.exports = posix; }).call(this)}).call(this,require('_process')) },{"_process":6}],6:[function(require,module,exports){ "use strict"; // shim for using process in browser var process = module.exports = {}; // cached from whatever global is present so that test runners that stub it // don't break things. But we need to wrap it in a try catch in case it is // wrapped in strict mode code which doesn't define any globals. It's inside a // function because try/catches deoptimize in certain engines. var cachedSetTimeout; var cachedClearTimeout; function defaultSetTimout() { throw new Error('setTimeout has not been defined'); } function defaultClearTimeout() { throw new Error('clearTimeout has not been defined'); } (function () { try { if (typeof setTimeout === 'function') { cachedSetTimeout = setTimeout; } else { cachedSetTimeout = defaultSetTimout; } } catch (e) { cachedSetTimeout = defaultSetTimout; } try { if (typeof clearTimeout === 'function') { cachedClearTimeout = clearTimeout; } else { cachedClearTimeout = defaultClearTimeout; } } catch (e) { cachedClearTimeout = defaultClearTimeout; } })(); function runTimeout(fun) { if (cachedSetTimeout === setTimeout) { //normal enviroments in sane situations return setTimeout(fun, 0); } // if setTimeout wasn't available but was latter defined if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { cachedSetTimeout = setTimeout; return setTimeout(fun, 0); } try { // when when somebody has screwed with setTimeout but no I.E. maddness return cachedSetTimeout(fun, 0); } catch (e) { try { // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally return cachedSetTimeout.call(null, fun, 0); } catch (e) { // 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 return cachedSetTimeout.call(this, fun, 0); } } } function runClearTimeout(marker) { if (cachedClearTimeout === clearTimeout) { //normal enviroments in sane situations return clearTimeout(marker); } // if clearTimeout wasn't available but was latter defined if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { cachedClearTimeout = clearTimeout; return clearTimeout(marker); } try { // when when somebody has screwed with setTimeout but no I.E. maddness return cachedClearTimeout(marker); } catch (e) { try { // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally return cachedClearTimeout.call(null, marker); } catch (e) { // 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. // Some versions of I.E. have different rules for clearTimeout vs setTimeout return cachedClearTimeout.call(this, marker); } } } var queue = []; var draining = false; var currentQueue; var queueIndex = -1; function cleanUpNextTick() { if (!draining || !currentQueue) { return; } draining = false; if (currentQueue.length) { queue = currentQueue.concat(queue); } else { queueIndex = -1; } if (queue.length) { drainQueue(); } } function drainQueue() { if (draining) { return; } var timeout = runTimeout(cleanUpNextTick); draining = true; var len = queue.length; while (len) { currentQueue = queue; queue = []; while (++queueIndex < len) { if (currentQueue) { currentQueue[queueIndex].run(); } } queueIndex = -1; len = queue.length; } currentQueue = null; draining = false; runClearTimeout(timeout); } process.nextTick = function (fun) { var args = new Array(arguments.length - 1); if (arguments.length > 1) { for (var i = 1; i < arguments.length; i++) { args[i - 1] = arguments[i]; } } queue.push(new Item(fun, args)); if (queue.length === 1 && !draining) { runTimeout(drainQueue); } }; // v8 likes predictible objects function Item(fun, array) { this.fun = fun; this.array = array; } Item.prototype.run = function () { this.fun.apply(null, this.array); }; process.title = 'browser'; process.browser = true; process.env = {}; process.argv = []; process.version = ''; // empty string to avoid regexp issues process.versions = {}; function noop() {} process.on = noop; process.addListener = noop; process.once = noop; process.off = noop; process.removeListener = noop; process.removeAllListeners = noop; process.emit = noop; process.prependListener = noop; process.prependOnceListener = noop; process.listeners = function (name) { return []; }; process.binding = function (name) { throw new Error('process.binding is not supported'); }; process.cwd = function () { return '/'; }; process.chdir = function (dir) { throw new Error('process.chdir is not supported'); }; process.umask = function () { return 0; }; },{}],7:[function(require,module,exports){ (function (process){(function (){ 'use strict'; if (process.env.NODE_ENV === 'production') { module.exports = require('./svg-injector.cjs.production.js'); } else { module.exports = require('./svg-injector.cjs.development.js'); } }).call(this)}).call(this,require('_process')) },{"./svg-injector.cjs.development.js":8,"./svg-injector.cjs.production.js":9,"_process":6}],8:[function(require,module,exports){ 'use strict'; var tslib = require('tslib'); var contentType = require('content-type'); var cache = new Map(); var cloneSvg = function cloneSvg(sourceSvg) { return sourceSvg.cloneNode(true); }; var isLocal = function isLocal() { return window.location.protocol === 'file:'; }; var makeAjaxRequest = function makeAjaxRequest(url, httpRequestWithCredentials, callback) { var httpRequest = new XMLHttpRequest(); httpRequest.onreadystatechange = function () { try { if (!/\.svg/i.test(url) && httpRequest.readyState === 2) { var contentType$1 = httpRequest.getResponseHeader('Content-Type'); if (!contentType$1) { throw new Error('Content type not found'); } var type = contentType.parse(contentType$1).type; if (!(type === 'image/svg+xml' || type === 'text/plain')) { throw new Error("Invalid content type: ".concat(type)); } } if (httpRequest.readyState === 4) { if (httpRequest.status === 404 || httpRequest.responseXML === null) { throw new Error(isLocal() ? 'Note: SVG injection ajax calls do not work locally without ' + 'adjusting security settings in your browser. Or consider ' + 'using a local webserver.' : 'Unable to load SVG file: ' + url); } if (httpRequest.status === 200 || isLocal() && httpRequest.status === 0) { callback(null, httpRequest); } else { throw new Error('There was a problem injecting the SVG: ' + httpRequest.status + ' ' + httpRequest.statusText); } } } catch (error) { httpRequest.abort(); if (error instanceof Error) { callback(error, httpRequest); } else { throw error; } } }; httpRequest.open('GET', url); httpRequest.withCredentials = httpRequestWithCredentials; if (httpRequest.overrideMimeType) { httpRequest.overrideMimeType('text/xml'); } httpRequest.send(); }; var requestQueue = {}; var queueRequest = function queueRequest(url, callback) { requestQueue[url] = requestQueue[url] || []; requestQueue[url].push(callback); }; var processRequestQueue = function processRequestQueue(url) { var _loop_1 = function _loop_1(i, len) { setTimeout(function () { if (Array.isArray(requestQueue[url])) { var cacheValue = cache.get(url); var callback = requestQueue[url][i]; if (cacheValue instanceof SVGSVGElement) { callback(null, cloneSvg(cacheValue)); } if (cacheValue instanceof Error) { callback(cacheValue); } if (i === requestQueue[url].length - 1) { delete requestQueue[url]; } } }, 0); }; for (var i = 0, len = requestQueue[url].length; i < len; i++) { _loop_1(i); } }; var loadSvgCached = function loadSvgCached(url, httpRequestWithCredentials, callback) { if (cache.has(url)) { var cacheValue = cache.get(url); if (cacheValue === undefined) { queueRequest(url, callback); return; } if (cacheValue instanceof SVGSVGElement) { callback(null, cloneSvg(cacheValue)); return; } } cache.set(url, undefined); queueRequest(url, callback); makeAjaxRequest(url, httpRequestWithCredentials, function (error, httpRequest) { var _a; if (error) { cache.set(url, error); } else if (((_a = httpRequest.responseXML) === null || _a === void 0 ? void 0 : _a.documentElement) instanceof SVGSVGElement) { cache.set(url, httpRequest.responseXML.documentElement); } processRequestQueue(url); }); }; var loadSvgUncached = function loadSvgUncached(url, httpRequestWithCredentials, callback) { makeAjaxRequest(url, httpRequestWithCredentials, function (error, httpRequest) { var _a; if (error) { callback(error); } else if (((_a = httpRequest.responseXML) === null || _a === void 0 ? void 0 : _a.documentElement) instanceof SVGSVGElement) { callback(null, httpRequest.responseXML.documentElement); } }); }; var idCounter = 0; var uniqueId = function uniqueId() { return ++idCounter; }; var injectedElements = []; var ranScripts = {}; var svgNamespace = 'http://www.w3.org/2000/svg'; var xlinkNamespace = 'http://www.w3.org/1999/xlink'; var injectElement = function injectElement(el, evalScripts, renumerateIRIElements, cacheRequests, httpRequestWithCredentials, beforeEach, callback) { var elUrl = el.getAttribute('data-src') || el.getAttribute('src'); if (!elUrl) { callback(new Error('Invalid data-src or src attribute')); return; } if (injectedElements.indexOf(el) !== -1) { injectedElements.splice(injectedElements.indexOf(el), 1); el = null; return; } injectedElements.push(el); el.setAttribute('src', ''); var loadSvg = cacheRequests ? loadSvgCached : loadSvgUncached; loadSvg(elUrl, httpRequestWithCredentials, function (error, svg) { if (!svg) { injectedElements.splice(injectedElements.indexOf(el), 1); el = null; callback(error); return; } var elId = el.getAttribute('id'); if (elId) { svg.setAttribute('id', elId); } var elTitle = el.getAttribute('title'); if (elTitle) { svg.setAttribute('title', elTitle); } var elWidth = el.getAttribute('width'); if (elWidth) { svg.setAttribute('width', elWidth); } var elHeight = el.getAttribute('height'); if (elHeight) { svg.setAttribute('height', elHeight); } var mergedClasses = Array.from(new Set(tslib.__spreadArray(tslib.__spreadArray(tslib.__spreadArray([], (svg.getAttribute('class') || '').split(' '), true), ['injected-svg'], false), (el.getAttribute('class') || '').split(' '), true))).join(' ').trim(); svg.setAttribute('class', mergedClasses); var elStyle = el.getAttribute('style'); if (elStyle) { svg.setAttribute('style', elStyle); } svg.setAttribute('data-src', elUrl); var elData = [].filter.call(el.attributes, function (at) { return /^data-\w[\w-]*$/.test(at.name); }); Array.prototype.forEach.call(elData, function (dataAttr) { if (dataAttr.name && dataAttr.value) { svg.setAttribute(dataAttr.name, dataAttr.value); } }); if (renumerateIRIElements) { var iriElementsAndProperties_1 = { clipPath: ['clip-path'], 'color-profile': ['color-profile'], cursor: ['cursor'], filter: ['filter'], linearGradient: ['fill', 'stroke'], marker: ['marker', 'marker-start', 'marker-mid', 'marker-end'], mask: ['mask'], path: [], pattern: ['fill', 'stroke'], radialGradient: ['fill', 'stroke'] }; var element_1; var elements_1; var properties_1; var currentId_1; var newId_1; Object.keys(iriElementsAndProperties_1).forEach(function (key) { element_1 = key; properties_1 = iriElementsAndProperties_1[key]; elements_1 = svg.querySelectorAll(element_1 + '[id]'); var _loop_1 = function _loop_1(a, elementsLen) { currentId_1 = elements_1[a].id; newId_1 = currentId_1 + '-' + uniqueId(); var referencingElements; Array.prototype.forEach.call(properties_1, function (property) { referencingElements = svg.querySelectorAll('[' + property + '*="' + currentId_1 + '"]'); for (var b = 0, referencingElementLen = referencingElements.length; b < referencingElementLen; b++) { var attrValue = referencingElements[b].getAttribute(property); if (attrValue && !attrValue.match(new RegExp('url\\("?#' + currentId_1 + '"?\\)'))) { continue; } referencingElements[b].setAttribute(property, 'url(#' + newId_1 + ')'); } }); var allLinks = svg.querySelectorAll('[*|href]'); var links = []; for (var c = 0, allLinksLen = allLinks.length; c < allLinksLen; c++) { var href = allLinks[c].getAttributeNS(xlinkNamespace, 'href'); if (href && href.toString() === '#' + elements_1[a].id) { links.push(allLinks[c]); } } for (var d = 0, linksLen = links.length; d < linksLen; d++) { links[d].setAttributeNS(xlinkNamespace, 'href', '#' + newId_1); } elements_1[a].id = newId_1; }; for (var a = 0, elementsLen = elements_1.length; a < elementsLen; a++) { _loop_1(a); } }); } svg.removeAttribute('xmlns:a'); var scripts = svg.querySelectorAll('script'); var scriptsToEval = []; var script; var scriptType; for (var i = 0, scriptsLen = scripts.length; i < scriptsLen; i++) { scriptType = scripts[i].getAttribute('type'); if (!scriptType || scriptType === 'application/ecmascript' || scriptType === 'application/javascript' || scriptType === 'text/javascript') { script = scripts[i].innerText || scripts[i].textContent; if (script) { scriptsToEval.push(script); } svg.removeChild(scripts[i]); } } if (scriptsToEval.length > 0 && (evalScripts === 'always' || evalScripts === 'once' && !ranScripts[elUrl])) { for (var l = 0, scriptsToEvalLen = scriptsToEval.length; l < scriptsToEvalLen; l++) { new Function(scriptsToEval[l])(window); } ranScripts[elUrl] = true; } var styleTags = svg.querySelectorAll('style'); Array.prototype.forEach.call(styleTags, function (styleTag) { styleTag.textContent += ''; }); svg.setAttribute('xmlns', svgNamespace); svg.setAttribute('xmlns:xlink', xlinkNamespace); beforeEach(svg); if (!el.parentNode) { injectedElements.splice(injectedElements.indexOf(el), 1); el = null; callback(new Error('Parent node is null')); return; } el.parentNode.replaceChild(svg, el); injectedElements.splice(injectedElements.indexOf(el), 1); el = null; callback(null, svg); }); }; var SVGInjector = function SVGInjector(elements, _a) { var _b = _a === void 0 ? {} : _a, _c = _b.afterAll, afterAll = _c === void 0 ? function () { return undefined; } : _c, _d = _b.afterEach, afterEach = _d === void 0 ? function () { return undefined; } : _d, _e = _b.beforeEach, beforeEach = _e === void 0 ? function () { return undefined; } : _e, _f = _b.cacheRequests, cacheRequests = _f === void 0 ? true : _f, _g = _b.evalScripts, evalScripts = _g === void 0 ? 'never' : _g, _h = _b.httpRequestWithCredentials, httpRequestWithCredentials = _h === void 0 ? false : _h, _j = _b.renumerateIRIElements, renumerateIRIElements = _j === void 0 ? true : _j; if (elements && 'length' in elements) { var elementsLoaded_1 = 0; for (var i = 0, j = elements.length; i < j; i++) { injectElement(elements[i], evalScripts, renumerateIRIElements, cacheRequests, httpRequestWithCredentials, beforeEach, function (error, svg) { afterEach(error, svg); if (elements && 'length' in elements && elements.length === ++elementsLoaded_1) { afterAll(elementsLoaded_1); } }); } } else if (elements) { injectElement(elements, evalScripts, renumerateIRIElements, cacheRequests, httpRequestWithCredentials, beforeEach, function (error, svg) { afterEach(error, svg); afterAll(1); elements = null; }); } else { afterAll(0); } }; exports.SVGInjector = SVGInjector; },{"content-type":74,"tslib":84}],9:[function(require,module,exports){ "use strict"; var tslib = require("tslib"), contentType = require("content-type"), cache = new Map(), cloneSvg = function cloneSvg(e) { return e.cloneNode(!0); }, isLocal = function isLocal() { return "file:" === window.location.protocol; }, makeAjaxRequest = function makeAjaxRequest(e, t, r) { var n = new XMLHttpRequest(); n.onreadystatechange = function () { try { if (!/\.svg/i.test(e) && 2 === n.readyState) { var t = n.getResponseHeader("Content-Type"); if (!t) throw new Error("Content type not found"); var i = contentType.parse(t).type; if ("image/svg+xml" !== i && "text/plain" !== i) throw new Error("Invalid content type: ".concat(i)); } if (4 === n.readyState) { if (404 === n.status || null === n.responseXML) throw new Error(isLocal() ? "Note: SVG injection ajax calls do not work locally without adjusting security settings in your browser. Or consider using a local webserver." : "Unable to load SVG file: " + e); if (!(200 === n.status || isLocal() && 0 === n.status)) throw new Error("There was a problem injecting the SVG: " + n.status + " " + n.statusText); r(null, n); } } catch (e) { if (n.abort(), !(e instanceof Error)) throw e; r(e, n); } }, n.open("GET", e), n.withCredentials = t, n.overrideMimeType && n.overrideMimeType("text/xml"), n.send(); }, requestQueue = {}, queueRequest = function queueRequest(e, t) { requestQueue[e] = requestQueue[e] || [], requestQueue[e].push(t); }, processRequestQueue = function processRequestQueue(e) { for (var t = function t(_t, r) { setTimeout(function () { if (Array.isArray(requestQueue[e])) { var r = cache.get(e), n = requestQueue[e][_t]; r instanceof SVGSVGElement && n(null, cloneSvg(r)), r instanceof Error && n(r), _t === requestQueue[e].length - 1 && delete requestQueue[e]; } }, 0); }, r = 0, n = requestQueue[e].length; r < n; r++) t(r); }, loadSvgCached = function loadSvgCached(e, t, r) { if (cache.has(e)) { var n = cache.get(e); if (void 0 === n) return void queueRequest(e, r); if (n instanceof SVGSVGElement) return void r(null, cloneSvg(n)); } cache.set(e, void 0), queueRequest(e, r), makeAjaxRequest(e, t, function (t, r) { var n; t ? cache.set(e, t) : (null === (n = r.responseXML) || void 0 === n ? void 0 : n.documentElement) instanceof SVGSVGElement && cache.set(e, r.responseXML.documentElement), processRequestQueue(e); }); }, loadSvgUncached = function loadSvgUncached(e, t, r) { makeAjaxRequest(e, t, function (e, t) { var n; e ? r(e) : (null === (n = t.responseXML) || void 0 === n ? void 0 : n.documentElement) instanceof SVGSVGElement && r(null, t.responseXML.documentElement); }); }, idCounter = 0, uniqueId = function uniqueId() { return ++idCounter; }, injectedElements = [], ranScripts = {}, svgNamespace = "http://www.w3.org/2000/svg", xlinkNamespace = "http://www.w3.org/1999/xlink", injectElement = function injectElement(e, t, r, n, i, a, o) { var l = e.getAttribute("data-src") || e.getAttribute("src"); if (l) { if (-1 !== injectedElements.indexOf(e)) return injectedElements.splice(injectedElements.indexOf(e), 1), void (e = null); injectedElements.push(e), e.setAttribute("src", ""), (n ? loadSvgCached : loadSvgUncached)(l, i, function (n, i) { if (!i) return injectedElements.splice(injectedElements.indexOf(e), 1), e = null, void o(n); var s = e.getAttribute("id"); s && i.setAttribute("id", s); var u = e.getAttribute("title"); u && i.setAttribute("title", u); var c = e.getAttribute("width"); c && i.setAttribute("width", c); var d = e.getAttribute("height"); d && i.setAttribute("height", d); var f = Array.from(new Set(tslib.__spreadArray(tslib.__spreadArray(tslib.__spreadArray([], (i.getAttribute("class") || "").split(" "), !0), ["injected-svg"], !1), (e.getAttribute("class") || "").split(" "), !0))).join(" ").trim(); i.setAttribute("class", f); var p = e.getAttribute("style"); p && i.setAttribute("style", p), i.setAttribute("data-src", l); var v = [].filter.call(e.attributes, function (e) { return /^data-\w[\w-]*$/.test(e.name); }); if (Array.prototype.forEach.call(v, function (e) { e.name && e.value && i.setAttribute(e.name, e.value); }), r) { var h, m, g, A, b = { clipPath: ["clip-path"], "color-profile": ["color-profile"], cursor: ["cursor"], filter: ["filter"], linearGradient: ["fill", "stroke"], marker: ["marker", "marker-start", "marker-mid", "marker-end"], mask: ["mask"], path: [], pattern: ["fill", "stroke"], radialGradient: ["fill", "stroke"] }; Object.keys(b).forEach(function (e) { m = b[e]; for (var t = function t(e, _t2) { var r; A = (g = h[e].id) + "-" + uniqueId(), Array.prototype.forEach.call(m, function (e) { for (var t = 0, n = (r = i.querySelectorAll("[" + e + '*="' + g + '"]')).length; t < n; t++) { var a = r[t].getAttribute(e); a && !a.match(new RegExp('url\\("?#' + g + '"?\\)')) || r[t].setAttribute(e, "url(#" + A + ")"); } }); for (var n = i.querySelectorAll("[*|href]"), a = [], o = 0, l = n.length; o < l; o++) { var s = n[o].getAttributeNS(xlinkNamespace, "href"); s && s.toString() === "#" + h[e].id && a.push(n[o]); } for (var u = 0, c = a.length; u < c; u++) a[u].setAttributeNS(xlinkNamespace, "href", "#" + A); h[e].id = A; }, r = 0, n = (h = i.querySelectorAll(e + "[id]")).length; r < n; r++) t(r); }); } i.removeAttribute("xmlns:a"); for (var w, y, E = i.querySelectorAll("script"), S = [], q = 0, j = E.length; q < j; q++) (y = E[q].getAttribute("type")) && "application/ecmascript" !== y && "application/javascript" !== y && "text/javascript" !== y || ((w = E[q].innerText || E[q].textContent) && S.push(w), i.removeChild(E[q])); if (S.length > 0 && ("always" === t || "once" === t && !ranScripts[l])) { for (var x = 0, k = S.length; x < k; x++) new Function(S[x])(window); ranScripts[l] = !0; } var G = i.querySelectorAll("style"); if (Array.prototype.forEach.call(G, function (e) { e.textContent += ""; }), i.setAttribute("xmlns", svgNamespace), i.setAttribute("xmlns:xlink", xlinkNamespace), a(i), !e.parentNode) return injectedElements.splice(injectedElements.indexOf(e), 1), e = null, void o(new Error("Parent node is null")); e.parentNode.replaceChild(i, e), injectedElements.splice(injectedElements.indexOf(e), 1), e = null, o(null, i); }); } else o(new Error("Invalid data-src or src attribute")); }, SVGInjector = function SVGInjector(e, t) { var r = void 0 === t ? {} : t, n = r.afterAll, i = void 0 === n ? function () {} : n, a = r.afterEach, o = void 0 === a ? function () {} : a, l = r.beforeEach, s = void 0 === l ? function () {} : l, u = r.cacheRequests, c = void 0 === u || u, d = r.evalScripts, f = void 0 === d ? "never" : d, p = r.httpRequestWithCredentials, v = void 0 !== p && p, h = r.renumerateIRIElements, m = void 0 === h || h; if (e && "length" in e) for (var g = 0, A = 0, b = e.length; A < b; A++) injectElement(e[A], f, m, c, v, s, function (t, r) { o(t, r), e && "length" in e && e.length === ++g && i(g); });else e ? injectElement(e, f, m, c, v, s, function (t, r) { o(t, r), i(1), e = null; }) : i(0); }; exports.SVGInjector = SVGInjector; },{"content-type":74,"tslib":84}],10:[function(require,module,exports){ (function (process){(function (){ "use strict";function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o;}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o;},_typeof(o);}!function(t,e){"object"==(typeof exports==="undefined"?"undefined":_typeof(exports))&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).turf={});}(void 0,function(t){"use strict";var e=6371008.8,n={centimeters:637100880,centimetres:637100880,degrees:57.22891354143274,feet:20902260.511392,inches:39.37*e,kilometers:6371.0088,kilometres:6371.0088,meters:e,metres:e,miles:3958.761333810546,millimeters:6371008800,millimetres:6371008800,nauticalmiles:e/1852,radians:1,yards:6967335.223679999},r={centimeters:100,centimetres:100,degrees:1/111325,feet:3.28084,inches:39.37,kilometers:.001,kilometres:.001,meters:1,metres:1,miles:1/1609.344,millimeters:1e3,millimetres:1e3,nauticalmiles:1/1852,radians:1/e,yards:1.0936133},i={acres:247105e-9,centimeters:1e4,centimetres:1e4,feet:10.763910417,hectares:1e-4,inches:1550.003100006,kilometers:1e-6,kilometres:1e-6,meters:1,metres:1,miles:386e-9,millimeters:1e6,millimetres:1e6,yards:1.195990046};function o(t,e,n){void 0===n&&(n={});var r={type:"Feature"};return(0===n.id||n.id)&&(r.id=n.id),n.bbox&&(r.bbox=n.bbox),r.properties=e||{},r.geometry=t,r;}function s(t,e,n){switch(t){case"Point":return a(e).geometry;case"LineString":return h(e).geometry;case"Polygon":return l(e).geometry;case"MultiPoint":return d(e).geometry;case"MultiLineString":return g(e).geometry;case"MultiPolygon":return y(e).geometry;default:throw new Error(t+" is invalid");}}function a(t,e,n){if(void 0===n&&(n={}),!t)throw new Error("coordinates is required");if(!Array.isArray(t))throw new Error("coordinates must be an Array");if(t.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!C(t[0])||!C(t[1]))throw new Error("coordinates must contain numbers");return o({type:"Point",coordinates:t},e,n);}function u(t,e,n){return void 0===n&&(n={}),f(t.map(function(t){return a(t,e);}),n);}function l(t,e,n){void 0===n&&(n={});for(var r=0,i=t;r=0))throw new Error("precision must be a positive number");var n=Math.pow(10,e||0);return Math.round(t*n)/n;}function m(t,e){void 0===e&&(e="kilometers");var r=n[e];if(!r)throw new Error(e+" units is invalid");return t*r;}function x(t,e){void 0===e&&(e="kilometers");var r=n[e];if(!r)throw new Error(e+" units is invalid");return t/r;}function E(t,e){return w(x(t,e));}function b(t){var e=t%360;return e<0&&(e+=360),e;}function w(t){return 180*(t%(2*Math.PI))/Math.PI;}function I(t){return t%360*Math.PI/180;}function N(t,e,n){if(void 0===e&&(e="kilometers"),void 0===n&&(n="kilometers"),!(t>=0))throw new Error("length must be a positive number");return m(x(t,e),n);}function S(t,e,n){if(void 0===e&&(e="meters"),void 0===n&&(n="kilometers"),!(t>=0))throw new Error("area must be a positive number");var r=i[e];if(!r)throw new Error("invalid original units");var o=i[n];if(!o)throw new Error("invalid final units");return t/r*o;}function C(t){return!isNaN(t)&&null!==t&&!Array.isArray(t);}function P(t){return!!t&&t.constructor===Object;}function M(t){if(!t)throw new Error("bbox is required");if(!Array.isArray(t))throw new Error("bbox must be an Array");if(4!==t.length&&6!==t.length)throw new Error("bbox must be an Array of 4 or 6 numbers");t.forEach(function(t){if(!C(t))throw new Error("bbox must only contain numbers");});}function L(t){if(!t)throw new Error("id is required");if(-1===["string","number"].indexOf(_typeof(t)))throw new Error("id must be a number or a string");}var O=Object.freeze({__proto__:null,earthRadius:e,factors:n,unitsFactors:r,areaFactors:i,feature:o,geometry:s,point:a,points:u,polygon:l,polygons:c,lineString:h,lineStrings:p,featureCollection:f,multiLineString:g,multiPoint:d,multiPolygon:y,geometryCollection:v,round:_,radiansToLength:m,lengthToRadians:x,lengthToDegrees:E,bearingToAzimuth:b,radiansToDegrees:w,degreesToRadians:I,convertLength:N,convertArea:S,isNumber:C,isObject:P,validateBBox:M,validateId:L});function R(t,e,n){if(null!==t)for(var r,i,o,s,a,u,l,c,h=0,p=0,f=t.type,g="FeatureCollection"===f,d="Feature"===f,y=g?t.features.length:1,v=0;va||f>u||g>l)return s=o,a=n,u=f,l=g,void(i=0);var d=h([s,o],t.properties);if(!1===e(d,n,r,g,i))return!1;i++,s=o;})&&void 0;}}});}function V(t,e,n){var r=n,i=!1;return U(t,function(t,o,s,a,u){r=!1===i&&void 0===n?t:e(r,t,o,s,a,u),i=!0;}),r;}function X(t,e){if(!t)throw new Error("geojson is required");z(t,function(t,n,r){if(null!==t.geometry){var i=t.geometry.type,o=t.geometry.coordinates;switch(i){case"LineString":if(!1===e(t,n,r,0,0))return!1;break;case"Polygon":for(var s=0;st[0]&&(e[0]=t[0]),e[1]>t[1]&&(e[1]=t[1]),e[2]=2&&!Array.isArray(t[0])&&!Array.isArray(t[1]))return t;throw new Error("coord must be GeoJSON Point or an Array of numbers");}function Q(t){if(Array.isArray(t))return t;if("Feature"===t.type){if(null!==t.geometry)return t.geometry.coordinates;}else if(t.coordinates)return t.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array");}function $(t){if(t.length>1&&C(t[0])&&C(t[1]))return!0;if(Array.isArray(t[0])&&t[0].length)return $(t[0]);throw new Error("coordinates must only contain numbers");}function tt(t,e,n){if(!e||!n)throw new Error("type and name required");if(!t||t.type!==e)throw new Error("Invalid input to "+n+": must be a "+e+", given "+t.type);}function et(t,e,n){if(!t)throw new Error("No feature passed");if(!n)throw new Error(".featureOf() requires a name");if(!t||"Feature"!==t.type||!t.geometry)throw new Error("Invalid input to "+n+", Feature with geometry required");if(!t.geometry||t.geometry.type!==e)throw new Error("Invalid input to "+n+": must be a "+e+", given "+t.geometry.type);}function nt(t,e,n){if(!t)throw new Error("No featureCollection passed");if(!n)throw new Error(".collectionOf() requires a name");if(!t||"FeatureCollection"!==t.type)throw new Error("Invalid input to "+n+", FeatureCollection required");for(var r=0,i=t.features;r * v. 1.2.0 * https://github.com/RaumZeit/MarchingSquares.js * * MarchingSquaresJS is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * MarchingSquaresJS is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * As additional permission under GNU Affero General Public License version 3 * section 7, third-party projects (personal or commercial) may distribute, * include, or link against UNMODIFIED VERSIONS of MarchingSquaresJS without the * requirement that said third-party project for that reason alone becomes * subject to any requirement of the GNU Affero General Public License version 3. * Any modifications to MarchingSquaresJS, however, must be shared with the public * and made available. * * In summary this: * - allows you to use MarchingSquaresJS at no cost * - allows you to use MarchingSquaresJS for both personal and commercial purposes * - allows you to distribute UNMODIFIED VERSIONS of MarchingSquaresJS under any * license as long as this license notice is included * - enables you to keep the source code of your program that uses MarchingSquaresJS * undisclosed * - forces you to share any modifications you have made to MarchingSquaresJS, * e.g. bug-fixes * * You should have received a copy of the GNU Affero General Public License * along with MarchingSquaresJS. If not, see . */function ft(t,e,n){n=n||{};for(var r=Object.keys(ht),i=0;i=0&&y>=0&&y=0;h--)if(Math.abs(e[h][0][0]-l)<=r&&Math.abs(e[h][0][1]-c)<=r){for(var p=a.path.length-2;p>=0;--p)e[h].unshift(a.path[p]);u=!0;break;}u||(e[n++]=a.path);}var f;});}),e;}(function(t,e){for(var n=t.length-1,r=t[0].length-1,i={rows:n,cols:r,cells:[]},o=0;o=e?8:0,a|=l>=e?4:0,a|=c>=e?2:0;var p,f,g,d,y=!1;if(5===(a|=h>=e?1:0)||10===a){var v=(u+l+c+h)/4;5===a&&vn;){if(r-n>600){var o=r-n+1,s=e-n+1,a=Math.log(o),u=.5*Math.exp(2*a/3),l=.5*Math.sqrt(a*u*(o-u)/o)*(s-o/2<0?-1:1);bt(t,e,Math.max(n,Math.floor(e-s*u/o+l)),Math.min(r,Math.floor(e+(o-s)*u/o+l)),i);}var c=t[e],h=n,p=r;for(wt(t,n,e),i(t[r],c)>0&&wt(t,n,r);h0;)p--;}0===i(t[n],c)?wt(t,n,p):wt(t,++p,r),p<=e&&(n=p+1),e<=p&&(r=p-1);}}function wt(t,e,n){var r=t[e];t[e]=t[n],t[n]=r;}function It(t,e){return te?1:0;}mt["default"]=xt;var Nt=Ct,St=Ct;function Ct(t,e){if(!(this instanceof Ct))return new Ct(t,e);this._maxEntries=Math.max(4,t||9),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),e&&this._initFormat(e),this.clear();}function Pt(t,e,n){if(!n)return e.indexOf(t);for(var r=0;r=t.minX&&e.maxY>=t.minY;}function Gt(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};}function qt(t,e,n,r,i){for(var o,s=[e,n];s.length;)(n=s.pop())-(e=s.pop())<=r||(o=e+Math.ceil((n-e)/r/2)*r,mt(t,o,e,n,i),s.push(e,o,o,n));}function Bt(t){var e={exports:{}};return t(e,e.exports),e.exports;}Ct.prototype={all:function all(){return this._all(this.data,[]);},search:function search(t){var e=this.data,n=[],r=this.toBBox;if(!kt(t,e))return n;for(var i,o,s,a,u=[];e;){for(i=0,o=e.children.length;i=0&&o[e].children.length>this._maxEntries;)this._split(o,e),e--;this._adjustParentBBoxes(i,o,e);},_split:function _split(t,e){var n=t[e],r=n.children.length,i=this._minEntries;this._chooseSplitAxis(n,i,r);var o=this._chooseSplitIndex(n,i,r),s=Gt(n.children.splice(o,n.children.length-o));s.height=n.height,s.leaf=n.leaf,Mt(n,this.toBBox),Mt(s,this.toBBox),e?t[e-1].children.push(s):this._splitRoot(n,s);},_splitRoot:function _splitRoot(t,e){this.data=Gt([t,e]),this.data.height=t.height+1,this.data.leaf=!1,Mt(this.data,this.toBBox);},_chooseSplitIndex:function _chooseSplitIndex(t,e,n){var r,i,o,s,a,u,l,c,h,p,f,g,d,y;for(u=l=1/0,r=e;r<=n-e;r++)i=Lt(t,0,r,this.toBBox),o=Lt(t,r,n,this.toBBox),h=i,p=o,f=void 0,g=void 0,d=void 0,y=void 0,f=Math.max(h.minX,p.minX),g=Math.max(h.minY,p.minY),d=Math.min(h.maxX,p.maxX),y=Math.min(h.maxY,p.maxY),s=Math.max(0,d-f)*Math.max(0,y-g),a=At(i)+At(o),s=e;i--)o=t.children[i],Ot(u,t.leaf?s(o):o),l+=Dt(u);return l;},_adjustParentBBoxes:function _adjustParentBBoxes(t,e,n){for(var r=n;r>=0;r--)Ot(e[r],t);},_condense:function _condense(t){for(var e,n=t.length-1;n>=0;n--)0===t[n].children.length?n>0?(e=t[n-1].children).splice(e.indexOf(t[n]),1):this.clear():Mt(t[n],this.toBBox);},_initFormat:function _initFormat(t){var e=["return a"," - b",";"];this.compareMinX=new Function("a","b",e.join(t[0])),this.compareMinY=new Function("a","b",e.join(t[1])),this.toBBox=new Function("a","return {minX: a"+t[0]+", minY: a"+t[1]+", maxX: a"+t[2]+", maxY: a"+t[3]+"};");}},Nt["default"]=St;var zt=function zt(t,e,n){var r=t*e,i=jt*t,o=i-(i-t),s=t-o,a=jt*e,u=a-(a-e),l=e-u,c=s*l-(r-o*u-s*u-o*l);if(n)return n[0]=c,n[1]=r,n;return[c,r];},jt=+(Math.pow(2,27)+1);var Ut=function Ut(t,e){var n=0|t.length,r=0|e.length;if(1===n&&1===r)return function(t,e){var n=t+e,r=n-t,i=t-(n-r)+(e-r);if(i)return[i,n];return[n];}(t[0],e[0]);var i,o,s=new Array(n+r),a=0,u=0,l=0,c=Math.abs,h=t[u],p=c(h),f=e[l],g=c(f);p=r?(i=h,(u+=1)=r?(i=h,(u+=1)>1;return["sum(",n(t.slice(0,e)),",",n(t.slice(e)),")"].join("");}function r(t){if(2===t.length)return[["sum(prod(",t[0][0],",",t[1][1],"),prod(-",t[0][1],",",t[1][0],"))"].join("")];for(var i=[],o=0;o0){if(s<=0)return a;r=i+s;}else{if(!(i<0))return a;if(s>=0)return a;r=-(i+s);}var u=33306690738754716e-32*r;return a>=u||a<=-u?a:o(t,e,n);},function(t,e,n,r){var i=t[0]-r[0],o=e[0]-r[0],a=n[0]-r[0],u=t[1]-r[1],l=e[1]-r[1],c=n[1]-r[1],h=t[2]-r[2],p=e[2]-r[2],f=n[2]-r[2],g=o*c,d=a*l,y=a*u,v=i*c,_=i*l,m=o*u,x=h*(g-d)+p*(y-v)+f*(_-m),E=7771561172376103e-31*((Math.abs(g)+Math.abs(d))*Math.abs(h)+(Math.abs(y)+Math.abs(v))*Math.abs(p)+(Math.abs(_)+Math.abs(m))*Math.abs(f));return x>E||-x>E?x:s(t,e,n,r);}];function u(t){var e=a[t.length];return e||(e=a[t.length]=i(t.length)),e.apply(void 0,t);}!function(){for(;a.length<=5;)a.push(i(a.length));for(var e=[],n=["slow"],r=0;r<=5;++r)e.push("a"+r),n.push("o"+r);var o=["function getOrientation(",e.join(),"){switch(arguments.length){case 0:case 1:return 0;"];for(r=2;r<=5;++r)o.push("case ",r,":return o",r,"(",e.slice(0,r).join(),");");o.push("}var s=new Array(arguments.length);for(var i=0;i1&&Jt(t[o[l-2]],t[o[l-1]],u)<=0;)l-=1,o.pop();for(o.push(a),l=s.length;l>1&&Jt(t[s[l-2]],t[s[l-1]],u)>=0;)l-=1,s.pop();s.push(a);}n=new Array(s.length+o.length-2);for(var c=0,h=(r=0,o.length);r0;--p)n[c++]=s[p];return n;},Jt=Ht[3];var Zt=Qt,Kt=Qt;function Qt(t,e){if(!(this instanceof Qt))return new Qt(t,e);if(this.data=t||[],this.length=this.data.length,this.compare=e||$t,this.length>0)for(var n=(this.length>>1)-1;n>=0;n--)this._down(n);}function $t(t,e){return te?1:0;}Qt.prototype={push:function push(t){this.data.push(t),this.length++,this._up(this.length-1);},pop:function pop(){if(0!==this.length){var t=this.data[0];return this.length--,this.length>0&&(this.data[0]=this.data[this.length],this._down(0)),this.data.pop(),t;}},peek:function peek(){return this.data[0];},_up:function _up(t){for(var e=this.data,n=this.compare,r=e[t];t>0;){var i=t-1>>1,o=e[i];if(n(r,o)>=0)break;e[t]=o,t=i;}e[t]=r;},_down:function _down(t){for(var e=this.data,n=this.compare,r=this.length>>1,i=e[t];t=0)break;e[t]=a,t=o;}e[t]=i;}},Zt["default"]=Kt;var te=function te(t,e){for(var n=t[0],r=t[1],i=!1,o=0,s=e.length-1;or!=c>r&&n<(l-a)*(r-u)/(c-u)+a&&(i=!i);}return i;},ee=Ht[3],ne=ie,re=ie;function ie(t,e,n){e=Math.max(0,void 0===e?2:e),n=n||0;for(var r,i=function(t){for(var e=t[0],n=t[0],r=t[0],i=t[0],o=0;or[0]&&(r=s),s[1]i[1]&&(i=s);}var a=[e,n,r,i],u=a.slice();for(o=0;oo||a.push({node:c,dist:h});}for(;a.length&&!a.peek().node.children;){var p=a.pop(),f=p.node,g=fe(f,e,n),d=fe(f,r,i);if(p.dist=e.minX&&t[0]<=e.maxX&&t[1]>=e.minY&&t[1]<=e.maxY;}function le(t,e,n){for(var r,i,o,s,a=Math.min(t[0],e[0]),u=Math.min(t[1],e[1]),l=Math.max(t[0],e[0]),c=Math.max(t[1],e[1]),h=n.search({minX:a,minY:u,maxX:l,maxY:c}),p=0;p0!=ee(r,i,s)>0&&ee(o,s,r)>0!=ee(o,s,i)>0)return!1;return!0;}function ce(t){var e=t.p,n=t.next.p;return t.minX=Math.min(e[0],n[0]),t.minY=Math.min(e[1],n[1]),t.maxX=Math.max(e[0],n[0]),t.maxY=Math.max(e[1],n[1]),t;}function he(t,e){var n={p:t,prev:null,next:null,minX:0,minY:0,maxX:0,maxY:0};return e?(n.next=e.next,n.prev=e,e.next.prev=n,e.next=n):(n.prev=n,n.next=n),n;}function pe(t,e){var n=t[0]-e[0],r=t[1]-e[1];return n*n+r*r;}function fe(t,e,n){var r=e[0],i=e[1],o=n[0]-r,s=n[1]-i;if(0!==o||0!==s){var a=((t[0]-r)*o+(t[1]-i)*s)/(o*o+s*s);a>1?(r=n[0],i=n[1]):a>0&&(r+=o*a,i+=s*a);}return(o=t[0]-r)*o+(s=t[1]-i)*s;}function ge(t,e,n,r,i,o,s,a){var u,l,c,h,p=n-t,f=r-e,g=s-i,d=a-o,y=t-i,v=e-o,_=p*p+f*f,m=p*g+f*d,x=g*g+d*d,E=p*y+f*v,b=g*y+d*v,w=_*x-m*m,I=w,N=w;0===w?(l=0,I=1,h=b,N=x):(h=_*b-m*E,(l=m*b-x*E)<0?(l=0,h=b,N=x):l>I&&(l=I,h=b+m,N=x)),h<0?(h=0,-E<0?l=0:-E>_?l=I:(l=-E,I=_)):h>N&&(h=N,-E+m<0?l=0:-E+m>_?l=I:(l=-E+m,I=_));var S=(1-(c=0===h?0:h/N))*i+c*s-((1-(u=0===l?0:l/I))*t+u*n),C=(1-c)*o+c*a-((1-u)*e+u*r);return S*S+C*C;}function de(t,e){void 0===e&&(e={}),e.concavity=e.concavity||1/0;var n=[];if(R(t,function(t){n.push([t[0],t[1]]);}),!n.length)return null;var r=ne(n,e.concavity);return r.length>3?l([r]):null;}function ye(t,e,n){if(void 0===n&&(n={}),!t)throw new Error("point is required");if(!e)throw new Error("polygon is required");var r=K(t),i=rt(e),o=i.type,s=e.bbox,a=i.coordinates;if(s&&!1===function(t,e){return e[0]<=t[0]&&e[1]<=t[1]&&e[2]>=t[0]&&e[3]>=t[1];}(r,s))return!1;"Polygon"===o&&(a=[a]);for(var u=!1,l=0;lt[1]!=l>t[1]&&t[0]<(u-s)*(t[1]-a)/(l-a)+s&&(r=!r);}return r;}function _e(t,e){var n=[];return F(t,function(t){var r=!1;if("Point"===t.geometry.type)q(e,function(e){ye(t,e)&&(r=!0);}),r&&n.push(t);else{if("MultiPoint"!==t.geometry.type)throw new Error("Input geometry must be a Point or MultiPoint");var i=[];q(e,function(e){R(t,function(t){ye(t,e)&&(r=!0,i.push(t));});}),r&&n.push(d(i));}}),f(n);}function me(t,e,n){void 0===n&&(n={});var r=K(t),i=K(e),o=I(i[1]-r[1]),s=I(i[0]-r[0]),a=I(r[1]),u=I(i[1]),l=Math.pow(Math.sin(o/2),2)+Math.pow(Math.sin(s/2),2)*Math.cos(a)*Math.cos(u);return m(2*Math.atan2(Math.sqrt(l),Math.sqrt(1-l)),n.units);}function xe(t,e){var n=!1;return f(function(t){if(t.length<3)return[];t.sort(be);var e,n,r,i,o,s,a=t.length-1,u=t[a].x,l=t[0].x,c=t[a].y,h=c,p=1e-12;for(;a--;)t[a].yh&&(h=t[a].y);var f,g=l-u,d=h-c,y=g>d?g:d,v=.5*(l+u),_=.5*(h+c),m=[new Ee({__sentinel:!0,x:v-20*y,y:_-y},{__sentinel:!0,x:v,y:_+20*y},{__sentinel:!0,x:v+20*y,y:_-y})],x=[],E=[];a=t.length;for(;a--;){for(E.length=0,f=m.length;f--;)(g=t[a].x-m[f].x)>0&&g*g>m[f].r?(x.push(m[f]),m.splice(f,1)):g*g+(d=t[a].y-m[f].y)*d>m[f].r||(E.push(m[f].a,m[f].b,m[f].b,m[f].c,m[f].c,m[f].a),m.splice(f,1));for(we(E),f=E.length;f;)n=E[--f],e=E[--f],r=t[a],i=n.x-e.x,o=n.y-e.y,s=2*(i*(r.y-n.y)-o*(r.x-n.x)),Math.abs(s)>p&&m.push(new Ee(e,n,r));}Array.prototype.push.apply(x,m),a=x.length;for(;a--;)(x[a].a.__sentinel||x[a].b.__sentinel||x[a].c.__sentinel)&&x.splice(a,1);return x;}(t.features.map(function(t){var r={x:t.geometry.coordinates[0],y:t.geometry.coordinates[1]};return e?r.z=t.properties[e]:3===t.geometry.coordinates.length&&(n=!0,r.z=t.geometry.coordinates[2]),r;})).map(function(t){var e=[t.a.x,t.a.y],r=[t.b.x,t.b.y],i=[t.c.x,t.c.y],o={};return n?(e.push(t.a.z),r.push(t.b.z),i.push(t.c.z)):o={a:t.a.z,b:t.b.z,c:t.c.z},l([[e,r,i,e]],o);}));}ne["default"]=re;var Ee=function Ee(t,e,n){this.a=t,this.b=e,this.c=n;var r,i,o=e.x-t.x,s=e.y-t.y,a=n.x-t.x,u=n.y-t.y,l=o*(t.x+e.x)+s*(t.y+e.y),c=a*(t.x+n.x)+u*(t.y+n.y),h=2*(o*(n.y-e.y)-s*(n.x-e.x));this.x=(u*l-s*c)/h,this.y=(o*c-a*l)/h,r=this.x-t.x,i=this.y-t.y,this.r=r*r+i*i;};function be(t,e){return e.x-t.x;}function we(t){var e,n,r,i,o,s=t.length;t:for(;s;)for(n=t[--s],e=t[--s],r=s;r;)if(o=t[--r],e===(i=t[--r])&&n===o||e===o&&n===i){t.splice(s,2),t.splice(r,2),s-=2;continue t;}}function Ie(t){if(!t)throw new Error("geojson is required");switch(t.type){case"Feature":return Ne(t);case"FeatureCollection":return function(t){var e={type:"FeatureCollection"};return Object.keys(t).forEach(function(n){switch(n){case"type":case"features":return;default:e[n]=t[n];}}),e.features=t.features.map(function(t){return Ne(t);}),e;}(t);case"Point":case"LineString":case"Polygon":case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"GeometryCollection":return Ce(t);default:throw new Error("unknown GeoJSON type");}}function Ne(t){var e={type:"Feature"};return Object.keys(t).forEach(function(n){switch(n){case"type":case"properties":case"geometry":return;default:e[n]=t[n];}}),e.properties=Se(t.properties),e.geometry=Ce(t.geometry),e;}function Se(t){var e={};return t?(Object.keys(t).forEach(function(n){var r=t[n];"object"==_typeof(r)?null===r?e[n]=null:Array.isArray(r)?e[n]=r.map(function(t){return t;}):e[n]=Se(r):e[n]=r;}),e):e;}function Ce(t){var e={type:t.type};return t.bbox&&(e.bbox=t.bbox),"GeometryCollection"===t.type?(e.geometries=t.geometries.map(function(t){return Ce(t);}),e):(e.coordinates=Pe(t.coordinates),e);}function Pe(t){var e=t;return"object"!=_typeof(e[0])?e.slice():e.map(function(t){return Pe(t);});}function Me(t,e){if(void 0===e&&(e={}),!P(e=e||{}))throw new Error("options is invalid");var n=e.mutate;if("FeatureCollection"!==it(t))throw new Error("geojson must be a FeatureCollection");if(!t.features.length)throw new Error("geojson is empty");!1!==n&&void 0!==n||(t=Ie(t));var r=[],i=Y(t,function(t,e){var n=function(t,e){var n,r=t.geometry.coordinates,i=e.geometry.coordinates,o=Le(r[0]),s=Le(r[r.length-1]),a=Le(i[0]),u=Le(i[i.length-1]);if(o===u)n=i.concat(r.slice(1));else if(a===s)n=r.concat(i.slice(1));else if(o===a)n=r.slice(1).reverse().concat(i);else{if(s!==u)return null;n=r.concat(i.reverse().slice(1));}return h(n);}(t,e);return n||(r.push(t),e);});return i&&r.push(i),r.length?1===r.length?r[0]:g(r.map(function(t){return t.coordinates;})):null;}function Le(t){return t[0].toString()+","+t[1].toString();}function Oe(t){return t;}function Re(t,e){var n=function(t){if(null==t)return Oe;var e,n,r=t.scale[0],i=t.scale[1],o=t.translate[0],s=t.translate[1];return function(t,a){a||(e=n=0);var u=2,l=t.length,c=new Array(l);for(c[0]=(e+=t[0])*r+o,c[1]=(n+=t[1])*i+s;u1)for(var o,a,u=1,l=s(i[0]);ul&&(a=i[0],i[0]=i[u],i[u]=a,l=o);return i;}).filter(function(t){return t.length>0;})};}var De=Object.prototype.hasOwnProperty;function Fe(t,e,n,r,i,o){3===arguments.length&&(r=o=Array,i=null);for(var s=new r(t=1<=t)throw new Error("full hashmap");c=s[l=l+1&u];}return s[l]=r,a[l]=o,o;}function h(r,o){for(var l=e(r)&u,c=s[l],h=0;c!=i;){if(n(c,r))return a[l];if(++h>=t)throw new Error("full hashmap");c=s[l=l+1&u];}return s[l]=r,a[l]=o,o;}function p(r,o){for(var l=e(r)&u,c=s[l],h=0;c!=i;){if(n(c,r))return a[l];if(++h>=t)break;c=s[l=l+1&u];}return o;}function f(){for(var t=[],e=0,n=s.length;e>7^Be[2]^Be[3]);}function je(t){var e,n,r,i,o=t.coordinates,s=t.lines,a=t.rings,u=function(){for(var t=Fe(1.4*o.length,E,b,Int32Array,-1,Int32Array),e=new Int32Array(o.length),n=0,r=o.length;n=0){var o=h[n];i===e&&o===r||i===r&&o===e||(++f,p[n]=1);}else c[n]=e,h[n]=r;}}function E(t){return ze(o[t]);}function b(t,e){return ke(o[t],o[e]);}l=c=h=null;var w,I=function(t,e,n,r,i){3===arguments.length&&(r=Array,i=null);for(var o=new r(t=1<=t)throw new Error("full hashset");u=o[a=a+1&s];}return o[a]=r,!0;}function l(r){for(var a=e(r)&s,u=o[a],l=0;u!=i;){if(n(u,r))return!0;if(++l>=t)break;u=o[a=a+1&s];}return!1;}function c(){for(var t=[],e=0,n=o.length;e>1);er&&(r=o),si&&(i=s);}function u(t){t.forEach(a);}function l(t){t.forEach(u);}for(var c in t)o(t[c]);return r>=e&&i>=n?[e,n,r,i]:void 0;}(t=Xe(t)),r=e>0&&n&&function(t,e,n){var r=e[0],i=e[1],o=e[2],s=e[3],a=o-r?(n-1)/(o-r):1,u=s-i?(n-1)/(s-i):1;function l(t){return[Math.round((t[0]-r)*a),Math.round((t[1]-i)*u)];}function c(t,e){for(var n,o,s,l,c,h=-1,p=0,f=t.length,g=new Array(f);++h2&&rn(n[i-3],n[i-1],n[i-2])&&n.splice(n.length-2,1));}if(n.push(e[e.length-1]),i=n.length,nn(e[0],e[e.length-1])&&i<4)throw new Error("invalid polygon");return rn(n[i-3],n[i-1],n[i-2])&&n.splice(n.length-2,1),n;}function nn(t,e){return t[0]===e[0]&&t[1]===e[1];}function rn(t,e,n){var r=n[0],i=n[1],o=t[0],s=t[1],a=e[0],u=e[1],l=a-o,c=u-s;return 0===(r-o)*c-(i-s)*l&&(Math.abs(l)>=Math.abs(c)?l>0?o<=r&&r<=a:a<=r&&r<=o:c>0?s<=i&&i<=u:u<=i&&i<=s);}function on(t,e,n){var r=e.x,i=e.y,o=n.x-r,s=n.y-i;if(0!==o||0!==s){var a=((t.x-r)*o+(t.y-i)*s)/(o*o+s*s);a>1?(r=n.x,i=n.y):a>0&&(r+=o*a,i+=s*a);}return(o=t.x-r)*o+(s=t.y-i)*s;}function sn(t,e,n,r,i){for(var o,s=r,a=e+1;as&&(o=a,s=u);}s>r&&(o-e>1&&sn(t,e,o,r,i),i.push(t[o]),n-o>1&&sn(t,o,n,r,i));}function an(t,e){var n=t.length-1,r=[t[0]];return sn(t,0,n,e,r),r.push(t[n]),r;}function un(t,e,n){if(t.length<=2)return t;var r=void 0!==e?e*e:1;return t=an(t=n?t:function(t,e){for(var n,r,i,o,s,a=t[0],u=[a],l=1,c=t.length;le&&(u.push(n),a=n);return a!==n&&u.push(n),u;}(t,r),r);}function ln(t,e,n){return un(t.map(function(t){return{x:t[0],y:t[1],z:t[2]};}),e,n).map(function(t){return t.z?[t.x,t.y,t.z]:[t.x,t.y];});}function cn(t,e,n){return t.map(function(t){var r=t.map(function(t){return{x:t[0],y:t[1]};});if(r.length<4)throw new Error("invalid polygon");for(var i=un(r,e,n).map(function(t){return[t.x,t.y];});!hn(i);)i=un(r,e-=.01*e,n).map(function(t){return[t.x,t.y];});return i[i.length-1][0]===i[0][0]&&i[i.length-1][1]===i[0][1]||i.push(i[0]),i;});}function hn(t){return!(t.length<3)&&!(3===t.length&&t[2][0]===t[0][0]&&t[2][1]===t[0][1]);}var pn=function(){function t(t){this.points=t.points||[],this.duration=t.duration||1e4,this.sharpness=t.sharpness||.85,this.centers=[],this.controls=[],this.stepLength=t.stepLength||60,this.length=this.points.length,this.delay=0;for(var e=0;et&&(e.push(r),n=i);}return e;},t.prototype.vector=function(t){var e=this.pos(t+10),n=this.pos(t-10);return{angle:180*Math.atan2(e.y-n.y,e.x-n.x)/3.14,speed:Math.sqrt((n.x-e.x)*(n.x-e.x)+(n.y-e.y)*(n.y-e.y)+(n.z-e.z)*(n.z-e.z))};},t.prototype.pos=function(t){var e=t-this.delay;e<0&&(e=0),e>this.duration&&(e=this.duration-1);var n=e/this.duration;if(n>=1)return this.points[this.length-1];var r=Math.floor((this.points.length-1)*n);return function(t,e,n,r,i){var o=function(t){var e=t*t;return[e*t,3*e*(1-t),3*t*(1-t)*(1-t),(1-t)*(1-t)*(1-t)];}(t);return{x:i.x*o[0]+r.x*o[1]+n.x*o[2]+e.x*o[3],y:i.y*o[0]+r.y*o[1]+n.y*o[2]+e.y*o[3],z:i.z*o[0]+r.z*o[1]+n.z*o[2]+e.z*o[3]};}((this.length-1)*n-r,this.points[r],this.controls[r][1],this.controls[r+1][0],this.points[r+1]);},t;}();function fn(t,e){void 0===e&&(e={});for(var n=e.resolution||1e4,r=e.sharpness||.85,i=[],o=rt(t).coordinates.map(function(t){return{x:t[0],y:t[1]};}),s=new pn({duration:n,points:o,sharpness:r}),a=function a(t){var e=s.pos(t);Math.floor(t/100)%2==0&&i.push([e.x,e.y]);},u=0;u=me(t.slice(0,2),[e,i])){var o=(n+i)/2;return[e,o-(r-e)/2,r,o+(r-e)/2];}var s=(e+r)/2;return[s-(i-n)/2,n,s+(i-n)/2,i];}function vn(t,e,n,r){void 0===r&&(r={});var i=K(t),o=I(i[0]),s=I(i[1]),u=I(n),l=x(e,r.units),c=Math.asin(Math.sin(s)*Math.cos(l)+Math.cos(s)*Math.sin(l)*Math.cos(u));return a([w(o+Math.atan2(Math.sin(u)*Math.sin(l)*Math.cos(s),Math.cos(l)-Math.sin(s)*Math.sin(c))),w(c)],r.properties);}function _n(t,e,n){void 0===n&&(n={});for(var r=n.steps||64,i=n.properties?n.properties:!Array.isArray(t)&&"Feature"===t.type&&t.properties?t.properties:{},o=[],s=0;s80*n){r=o=t[0],i=s=t[1];for(var g=n;go&&(o=a),u>s&&(s=u);l=0!==(l=Math.max(o-r,s-i))?1/l:0;}return Pn(p,f,n,r,i,l),f;}function Sn(t,e,n,r,i){var o,s;if(i===Hn(t,e,n,r)>0)for(o=e;o=e;o-=r)s=Vn(o,t[o],t[o+1],s);return s&&Bn(s,s.next)&&(Xn(s),s=s.next),s;}function Cn(t,e){if(!t)return t;e||(e=t);var n,r=t;do{if(n=!1,r.steiner||!Bn(r,r.next)&&0!==qn(r.prev,r,r.next))r=r.next;else{if(Xn(r),(r=e=r.prev)===r.next)break;n=!0;}}while(n||r!==e);return e;}function Pn(t,e,n,r,i,o,s){if(t){!s&&o&&function(t,e,n,r){var i=t;do{null===i.z&&(i.z=Dn(i.x,i.y,e,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;}while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,function(t){var e,n,r,i,o,s,a,u,l=1;do{for(n=t,t=null,o=null,s=0;n;){for(s++,r=n,a=0,e=0;e0||u>0&&r;)0!==a&&(0===u||!r||n.z<=r.z)?(i=n,n=n.nextZ,a--):(i=r,r=r.nextZ,u--),o?o.nextZ=i:t=i,i.prevZ=o,o=i;n=r;}o.nextZ=null,l*=2;}while(s>1);}(i);}(t,r,i,o);for(var a,u,l=t;t.prev!==t.next;)if(a=t.prev,u=t.next,o?Ln(t,r,i,o):Mn(t))e.push(a.i/n),e.push(t.i/n),e.push(u.i/n),Xn(t),t=u.next,l=u.next;else if((t=u)===l){s?1===s?Pn(t=On(t,e,n),e,n,r,i,o,2):2===s&&Rn(t,e,n,r,i,o):Pn(Cn(t),e,n,r,i,o,1);break;}}}function Mn(t){var e=t.prev,n=t,r=t.next;if(qn(e,n,r)>=0)return!1;for(var i=t.next.next;i!==t.prev;){if(kn(e.x,e.y,n.x,n.y,r.x,r.y,i.x,i.y)&&qn(i.prev,i,i.next)>=0)return!1;i=i.next;}return!0;}function Ln(t,e,n,r){var i=t.prev,o=t,s=t.next;if(qn(i,o,s)>=0)return!1;for(var a=i.xo.x?i.x>s.x?i.x:s.x:o.x>s.x?o.x:s.x,c=i.y>o.y?i.y>s.y?i.y:s.y:o.y>s.y?o.y:s.y,h=Dn(a,u,e,n,r),p=Dn(l,c,e,n,r),f=t.prevZ,g=t.nextZ;f&&f.z>=h&&g&&g.z<=p;){if(f!==t.prev&&f!==t.next&&kn(i.x,i.y,o.x,o.y,s.x,s.y,f.x,f.y)&&qn(f.prev,f,f.next)>=0)return!1;if(f=f.prevZ,g!==t.prev&&g!==t.next&&kn(i.x,i.y,o.x,o.y,s.x,s.y,g.x,g.y)&&qn(g.prev,g,g.next)>=0)return!1;g=g.nextZ;}for(;f&&f.z>=h;){if(f!==t.prev&&f!==t.next&&kn(i.x,i.y,o.x,o.y,s.x,s.y,f.x,f.y)&&qn(f.prev,f,f.next)>=0)return!1;f=f.prevZ;}for(;g&&g.z<=p;){if(g!==t.prev&&g!==t.next&&kn(i.x,i.y,o.x,o.y,s.x,s.y,g.x,g.y)&&qn(g.prev,g,g.next)>=0)return!1;g=g.nextZ;}return!0;}function On(t,e,n){var r=t;do{var i=r.prev,o=r.next.next;!Bn(i,o)&&zn(i,r,r.next,o)&&jn(i,o)&&jn(o,i)&&(e.push(i.i/n),e.push(r.i/n),e.push(o.i/n),Xn(r),Xn(r.next),r=t=o),r=r.next;}while(r!==t);return r;}function Rn(t,e,n,r,i,o){var s=t;do{for(var a=s.next.next;a!==s.prev;){if(s.i!==a.i&&Gn(s,a)){var u=Un(s,a);return s=Cn(s,s.next),u=Cn(u,u.next),Pn(s,e,n,r,i,o),void Pn(u,e,n,r,i,o);}a=a.next;}s=s.next;}while(s!==t);}function Tn(t,e){return t.x-e.x;}function An(t,e){if(e=function(t,e){var n,r=e,i=t.x,o=t.y,s=-1/0;do{if(o<=r.y&&o>=r.next.y&&r.next.y!==r.y){var a=r.x+(o-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(a<=i&&a>s){if(s=a,a===i){if(o===r.y)return r;if(o===r.next.y)return r.next;}n=r.x=r.x&&r.x>=c&&i!==r.x&&kn(on.x)&&jn(r,t)&&(n=r,p=u),r=r.next;return n;}(t,e)){var n=Un(e,t);Cn(n,n.next);}}function Dn(t,e,n,r,i){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-n)*i)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-r)*i)|e<<8))|e<<4))|e<<2))|e<<1))<<1;}function Fn(t){var e=t,n=t;do{e.x=0&&(t-s)*(r-a)-(n-s)*(e-a)>=0&&(n-s)*(o-a)-(i-s)*(r-a)>=0;}function Gn(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==e.i&&n.next.i!==e.i&&zn(n,n.next,t,e))return!0;n=n.next;}while(n!==t);return!1;}(t,e)&&jn(t,e)&&jn(e,t)&&function(t,e){var n=t,r=!1,i=(t.x+e.x)/2,o=(t.y+e.y)/2;do{n.y>o!=n.next.y>o&&n.next.y!==n.y&&i<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next;}while(n!==t);return r;}(t,e);}function qn(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y);}function Bn(t,e){return t.x===e.x&&t.y===e.y;}function zn(t,e,n,r){return!!(Bn(t,e)&&Bn(n,r)||Bn(t,r)&&Bn(n,e))||qn(t,e,n)>0!=qn(t,e,r)>0&&qn(n,r,t)>0!=qn(n,r,e)>0;}function jn(t,e){return qn(t.prev,t,t.next)<0?qn(t,e,t.next)>=0&&qn(t,t.prev,e)>=0:qn(t,e,t.prev)<0||qn(t,t.next,e)<0;}function Un(t,e){var n=new Yn(t.i,t.x,t.y),r=new Yn(e.i,e.x,e.y),i=t.next,o=e.prev;return t.next=e,e.prev=t,n.next=i,i.prev=n,r.next=n,n.prev=r,o.next=r,r.prev=o,r;}function Vn(t,e,n,r){var i=new Yn(t,e,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i;}function Xn(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ);}function Yn(t,e,n){this.i=t,this.x=e,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1;}function Hn(t,e,n,r){for(var i=0,o=e,s=n-r;o0&&(r+=t[i-1].length,n.holes.push(r));}return n;}(t),n=wn(e.vertices,e.holes,2),r=[],i=[];n.forEach(function(t,r){var o=n[r];i.push([e.vertices[2*o],e.vertices[2*o+1]]);});for(var o=0;oi?n:i,r>o?r:o];}(t,r),n.push(i),r;}),n;})(n,t.properties).forEach(function(t){t.id=e.length,e.push(t);});});}}(t,e);}),f(e);}Nn.deviation=function(t,e,n,r){var i=e&&e.length,o=i?e[0]*n:t.length,s=Math.abs(Hn(t,0,o,n));if(i)for(var a=0,u=e.length;a0&&(r+=t[i-1].length,n.holes.push(r));}return n;},wn["default"]=In;var Kn=Bt(function(t,e){function n(t,e,n){void 0===n&&(n={});var r={type:"Feature"};return(0===n.id||n.id)&&(r.id=n.id),n.bbox&&(r.bbox=n.bbox),r.properties=e||{},r.geometry=t,r;}function r(t,e,r){if(void 0===r&&(r={}),!t)throw new Error("coordinates is required");if(!Array.isArray(t))throw new Error("coordinates must be an Array");if(t.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!f(t[0])||!f(t[1]))throw new Error("coordinates must contain numbers");return n({type:"Point",coordinates:t},e,r);}function i(t,e,r){void 0===r&&(r={});for(var i=0,o=t;i=0))throw new Error("precision must be a positive number");var n=Math.pow(10,e||0);return Math.round(t*n)/n;},e.radiansToLength=c,e.lengthToRadians=h,e.lengthToDegrees=function(t,e){return p(h(t,e));},e.bearingToAzimuth=function(t){var e=t%360;return e<0&&(e+=360),e;},e.radiansToDegrees=p,e.degreesToRadians=function(t){return t%360*Math.PI/180;},e.convertLength=function(t,e,n){if(void 0===e&&(e="kilometers"),void 0===n&&(n="kilometers"),!(t>=0))throw new Error("length must be a positive number");return c(h(t,e),n);},e.convertArea=function(t,n,r){if(void 0===n&&(n="meters"),void 0===r&&(r="kilometers"),!(t>=0))throw new Error("area must be a positive number");var i=e.areaFactors[n];if(!i)throw new Error("invalid original units");var o=e.areaFactors[r];if(!o)throw new Error("invalid final units");return t/i*o;},e.isNumber=f,e.isObject=function(t){return!!t&&t.constructor===Object;},e.validateBBox=function(t){if(!t)throw new Error("bbox is required");if(!Array.isArray(t))throw new Error("bbox must be an Array");if(4!==t.length&&6!==t.length)throw new Error("bbox must be an Array of 4 or 6 numbers");t.forEach(function(t){if(!f(t))throw new Error("bbox must only contain numbers");});},e.validateId=function(t){if(!t)throw new Error("id is required");if(-1===["string","number"].indexOf(_typeof(t)))throw new Error("id must be a number or a string");};});function Qn(t,e,n){if(null!==t)for(var r,i,o,s,a,u,l,c,h=0,p=0,f=t.type,g="FeatureCollection"===f,d="Feature"===f,y=g?t.features.length:1,v=0;va||p>u||f>l)return s=o,a=n,u=p,l=f,void(i=0);var g=Kn.lineString([s,o],t.properties);if(!1===e(g,n,r,f,i))return!1;i++,s=o;})&&void 0;}}});}function ir(t,e){if(!t)throw new Error("geojson is required");nr(t,function(t,n,r){if(null!==t.geometry){var i=t.geometry.type,o=t.geometry.coordinates;switch(i){case"LineString":if(!1===e(t,n,r,0,0))return!1;break;case"Polygon":for(var s=0;st[0]&&(e[0]=t[0]),e[1]>t[1]&&(e[1]=t[1]),e[2] line1 must only contain 2 coordinates");if(2!==r.length)throw new Error(" line2 must only contain 2 coordinates");var i=n[0][0],o=n[0][1],s=n[1][0],u=n[1][1],l=r[0][0],c=r[0][1],h=r[1][0],p=r[1][1],f=(p-c)*(s-i)-(h-l)*(u-o),g=(h-l)*(o-c)-(p-c)*(i-l),d=(s-i)*(o-c)-(u-o)*(i-l);if(0===f)return null;var y=g/f,v=d/f;return y>=0&&y<=1&&v>=0&&v<=1?a([i+y*(s-i),o+y*(u-o)]):null;}function Tr(t,e,n){void 0===n&&(n={});var r=a([1/0,1/0],{dist:1/0}),i=0;return z(t,function(t){for(var o=Q(t),s=0;s0&&((v=y.features[0]).properties.dist=me(e,v,n),v.properties.location=i+me(u,v,n)),u.properties.dist180?-360:i[0]-o[0]>180?360:0,N(function(t,n,r){var i=r=void 0===r?e:Number(r),o=t[1]*Math.PI/180,s=n[1]*Math.PI/180,a=s-o,u=Math.abs(n[0]-t[0])*Math.PI/180;u>Math.PI&&(u-=2*Math.PI);var l=Math.log(Math.tan(s/2+Math.PI/4)/Math.tan(o/2+Math.PI/4)),c=Math.abs(l)>1e-11?a/l:Math.cos(o);return Math.sqrt(a*a+c*c*u*u)*i;}(i,o),"meters",r.units);}function Dr(t,e,n){if(void 0===n&&(n={}),n.method||(n.method="geodesic"),n.units||(n.units="kilometers"),!t)throw new Error("pt is required");if(Array.isArray(t)?t=a(t):"Point"===t.type?t=o(t):et(t,"Point","point"),!e)throw new Error("line is required");Array.isArray(e)?e=h(e):"LineString"===e.type?e=o(e):et(e,"LineString","line");var r=1/0,i=t.geometry.coordinates;return U(e,function(t){var e=t.geometry.coordinates[0],o=t.geometry.coordinates[1],s=function(t,e,n,r){var i=[n[0]-e[0],n[1]-e[1]],o=Fr([t[0]-e[0],t[1]-e[1]],i);if(o<=0)return kr(t,e,{method:r.method,units:"degrees"});var s=Fr(i,i);if(s<=o)return kr(t,n,{method:r.method,units:"degrees"});var a=o/s,u=[e[0]+a*i[0],e[1]+a*i[1]];return kr(t,u,{method:r.method,units:"degrees"});}(i,e,o,n);s=0&&l<=1&&(p.onLine1=!0),c>=0&&c<=1&&(p.onLine2=!0),!(!p.onLine1||!p.onLine2)&&[p.x,p.y]);}function qr(t){for(var e=function(t){if("FeatureCollection"!==t.type)return"Feature"!==t.type?f([o(t)]):f([t]);return t;}(t),n=xn(e),r=!1,i=0;!r&&i0){e+=Math.abs(Vr(t[0]));for(var n=1;n2){for(s=0;s=c&&p===i.length-1);p++){if(c>e&&0===o.length){if(!(s=e-c))return o.push(i[p]),h(o);a=mn(i[p],i[p-1])-180,u=vn(i[p],s,a,r),o.push(u.geometry.coordinates);}if(c>=n)return(s=n-c)?(a=mn(i[p],i[p-1])-180,u=vn(i[p],s,a,r),o.push(u.geometry.coordinates),h(o)):(o.push(i[p]),h(o));if(c>=e&&o.push(i[p]),p===i.length-1)return h(o);c+=me(i[p],i[p+1],r);}if(ci)return!1;}else if(0!==f)return!1;return r?"start"===r?Math.abs(h)>=Math.abs(p)?h>0?a0?u=Math.abs(p)?h>0?a<=o&&o0?u<=s&&s=Math.abs(p)?h>0?a0?u=Math.abs(p)?h>0?a<=o&&o<=l:l<=o&&o<=a:p>0?u<=s&&s<=c:c<=s&&s<=u;}function Zr(t,e){var n=rt(t),r=rt(e),i=n.type,o=r.type;switch(i){case"Point":switch(o){case"MultiPoint":return function(t,e){var n,r=!1;for(n=0;ne[0])&&!(t[2]e[1])&&!(t[3] is required");if("number"!=typeof n)throw new Error(" must be a number");if("number"!=typeof r)throw new Error(" must be a number");!1!==i&&void 0!==i||(t=JSON.parse(JSON.stringify(t)));var o=Math.pow(10,n);return R(t,function(t){!function(t,e,n){t.length>n&&t.splice(n,t.length);for(var r=0;r=1||u<=0||l>=1||l<=0))){var d=g,y=!o[d];y&&(o[d]=!0),e?i.push(e(g,t,n,c,h,u,s,a,p,f,l,y)):i.push(g);}}function d(t,e){var n,i,o,s,a=r[t][e],u=r[t][e+1];return a[0]p[e.isect].coord?-1:1;});for(u=[];b.length>0;){var C=b.pop(),P=C.isect,M=C.parent,L=C.winding,O=u.length,R=[p[P].coord],T=P;if(p[P].ringAndEdge1Walkable)var A=p[P].ringAndEdge1,D=p[P].nxtIsectAlongRingAndEdge1;else A=p[P].ringAndEdge2,D=p[P].nxtIsectAlongRingAndEdge2;for(;!ci(p[P].coord,p[D].coord);){R.push(p[D].coord);var F=void 0;for(r=0;r1)for(e=0;e=0==e;}function li(t){for(var e=0,n=0;n1&&n.push(h(l)),f(n);}function xi(t,e){if(!e.features.length)throw new Error("lines must contain features");if(1===e.features.length)return e.features[0];var n,r=1/0;return F(e,function(e){var i=Tr(e,t).properties.dist;ic&&f.push(vn(t,e,c,i).geometry.coordinates),h(f,u);}function wi(t){var e=t%360;return e<0&&(e+=360),e;}function Ii(t,e){void 0===e&&(e={});var n=rt(t);switch(e.properties||"Feature"!==t.type||(e.properties=t.properties),n.type){case"Polygon":return Ni(n,e);case"MultiPolygon":return function(t,e){void 0===e&&(e={});var n=rt(t).coordinates,r=e.properties?e.properties:"Feature"===t.type?t.properties:{},i=[];return n.forEach(function(t){i.push(Si(t,r));}),f(i);}(n,e);default:throw new Error("invalid poly");}}function Ni(t,e){return void 0===e&&(e={}),Si(rt(t).coordinates,e.properties?e.properties:"Feature"===t.type?t.properties:{});}function Si(t,e){return t.length>1?g(t,e):h(t[0],e);}function Ci(t,e){var n,r,i;void 0===e&&(e={});var o=e.properties,s=null===(n=e.autoComplete)||void 0===n||n,a=null===(r=e.orderCoords)||void 0===r||r;switch(null!==(i=e.mutate)&&void 0!==i&&i||(t=Ie(t)),t.type){case"FeatureCollection":var u=[];return t.features.forEach(function(t){u.push(Q(Pi(t,{},s,a)));}),y(u,o);default:return Pi(t,o,s,a);}}function Pi(t,e,n,r){e=e||("Feature"===t.type?t.properties:{});var i=rt(t),o=i.coordinates,s=i.type;if(!o.length)throw new Error("line must contain coordinates");switch(s){case"LineString":return n&&(o=Mi(o)),l([o],e);case"MultiLineString":var a=[],u=0;return o.forEach(function(t){if(n&&(t=Mi(t)),r){var e=function(t){var e=t[0],n=t[1],r=t[2],i=t[3];return Math.abs(e-r)*Math.abs(n-i);}(Z(h(t)));e>u?(a.unshift(t),u=e):a.push(t);}else a.push(t);}),l(a,e);default:throw new Error("geometry type "+s+" is not supported");}}function Mi(t){var e=t[0],n=e[0],r=e[1],i=t[t.length-1],o=i[0],s=i[1];return n===o&&r===s||t.push(e),t;}function Li(t,e){var n,r,i,o,s,a,u;for(r=1;r<=8;r*=2){for(n=[],o=!(Ri(i=t[t.length-1],e)&r),s=0;se[2]&&(n|=2),t[1]e[3]&&(n|=8),n;}function Ti(t,e){for(var n=[],r=0,i=t;r0&&(o[0][0]===o[o.length-1][0]&&o[0][1]===o[o.length-1][1]||o.push(o[0]),o.length>=4&&n.push(o));}return n;}vi.prototype.interpolate=function(t){var e=Math.sin((1-t)*this.g)/Math.sin(this.g),n=Math.sin(t*this.g)/Math.sin(this.g),r=e*Math.cos(this.start.y)*Math.cos(this.start.x)+n*Math.cos(this.end.y)*Math.cos(this.end.x),i=e*Math.cos(this.start.y)*Math.sin(this.start.x)+n*Math.cos(this.end.y)*Math.sin(this.end.x),o=e*Math.sin(this.start.y)+n*Math.sin(this.end.y),s=fi*Math.atan2(o,Math.sqrt(Math.pow(r,2)+Math.pow(i,2)));return[fi*Math.atan2(i,r),s];},vi.prototype.Arc=function(t,e){var n=[];if(!t||t<=2)n.push([this.start.lon,this.start.lat]),n.push([this.end.lon,this.end.lat]);else for(var r=1/(t-1),i=0;ip&&(d>c&&gc&&du&&(u=y);}var v=[];if(a&&u0&&Math.abs(x-n[m-1][0])>p){var E=parseFloat(n[m-1][0]),b=parseFloat(n[m-1][1]),w=parseFloat(n[m][0]),I=parseFloat(n[m][1]);if(E>-180&&E-180&&n[m-1][0]c&&E<180&&-180===w&&m+1c&&n[m-1][0]<180){_.push([180,n[m][1]]),m++,_.push([n[m][0],n[m][1]]);continue;}if(Ec){var N=E;E=w,w=N;var S=b;b=I,I=S;}if(E>c&&w=180&&Ec?180:-180,P]),(_=[]).push([n[m-1][0]>c?-180:180,P]),v.push(_);}else _=[],v.push(_);_.push([x,n[m][1]]);}else _.push([n[m][0],n[m][1]]);}}else{var M=[];v.push(M);for(var L=0;L=0;a--)if(l[a]!=c[a])return!1;for(a=l.length-1;a>=0;a--)if(u=l[a],!n(t[u],o[u],s))return!1;return _typeof(t)==_typeof(o);}(t,o,s));};function r(t){return null==t;}function i(t){return!(!t||"object"!=_typeof(t)||"number"!=typeof t.length)&&"function"==typeof t.copy&&"function"==typeof t.slice&&!(t.length>0&&"number"!=typeof t[0]);}});function ki(t,e,n){if(void 0===n&&(n={}),!P(n=n||{}))throw new Error("options is invalid");var r,i=n.tolerance||0,o=[],s=Mr(),a=Zn(t);return s.load(a),U(e,function(t){var e=!1;t&&(F(s.search(t),function(n){if(!1===e){var o=Q(t).sort(),s=Q(n).sort();Fi(o,s)||(0===i?Wr(o[0],n)&&Wr(o[1],n):Tr(n,o[0]).properties.dist<=i&&Tr(n,o[1]).properties.dist<=i)?(e=!0,r=r?Gi(r,t):t):(0===i?Wr(s[0],t)&&Wr(s[1],t):Tr(t,s[0]).properties.dist<=i&&Tr(t,s[1]).properties.dist<=i)&&(r=r?Gi(r,n):n);}}),!1===e&&r&&(o.push(r),r=void 0));}),r&&o.push(r),f(o);}function Gi(t,e){var n=Q(e),r=Q(t),i=r[0],o=r[r.length-1],s=t.geometry.coordinates;return Fi(n[0],i)?s.unshift(n[1]):Fi(n[0],o)?s.push(n[1]):Fi(n[1],i)?s.unshift(n[0]):Fi(n[1],o)&&s.push(n[0]),t;}function qi(t){var e=t%360;return e<0&&(e+=360),e;}function Bi(t,e,n){var r;return void 0===n&&(n={}),(r=n["final"]?zi(K(e),K(t)):zi(K(t),K(e)))>180?-(360-r):r;}function zi(t,e){var n=I(t[1]),r=I(e[1]),i=I(e[0]-t[0]);i>Math.PI&&(i-=2*Math.PI),i<-Math.PI&&(i+=2*Math.PI);var o=Math.log(Math.tan(r/2+Math.PI/4)/Math.tan(n/2+Math.PI/4));return(w(Math.atan2(i,o))+360)%360;}function ji(t,n,r,i){void 0===i&&(i={});var o=n<0,s=N(Math.abs(n),i.units,"meters");o&&(s=-Math.abs(s));var u=K(t),l=function(t,n,r,i){i=void 0===i?e:Number(i);var o=n/i,s=t[0]*Math.PI/180,a=I(t[1]),u=I(r),l=o*Math.cos(u),c=a+l;Math.abs(c)>Math.PI/2&&(c=c>0?Math.PI-c:-Math.PI-c);var h=Math.log(Math.tan(c/2+Math.PI/4)/Math.tan(a/2+Math.PI/4)),p=Math.abs(h)>1e-11?l/h:Math.cos(a),f=o*Math.sin(u)/p;return[(180*(s+f)/Math.PI+540)%360-180,180*c/Math.PI];}(u,s,r);return l[0]+=l[0]-u[0]>180?-360:u[0]-l[0]>180?360:0,a(l,i.properties);}function Ui(t,e,n,r,i,o){for(var s=0;s0?Xi(e,a,i)<0||(i=a):n>0&&r<=0&&(Vi(e,a,o)||(o=a)),n=r;}return[i,o];}function Vi(t,e,n){return Xi(t,e,n)>0;}function Xi(t,e,n){return(e[0]-t[0])*(n[1]-t[1])-(n[0]-t[0])*(e[1]-t[1]);}function Yi(t){for(var e,n,r=Q(t),i=0,o=1;o0;}function Hi(t,e){switch("Feature"===t.type?t.geometry.type:t.type){case"GeometryCollection":return q(t,function(t){Hi(t,e);}),t;case"LineString":return Wi(Q(t),e),t;case"Polygon":return Ji(Q(t),e),t;case"MultiLineString":return Q(t).forEach(function(t){Wi(t,e);}),t;case"MultiPolygon":return Q(t).forEach(function(t){Ji(t,e);}),t;case"Point":case"MultiPoint":return t;}}function Wi(t,e){Yi(t)===e&&t.reverse();}function Ji(t,e){Yi(t[0])!==e&&t[0].reverse();for(var n=1;n * v. 1.2.0 * https://github.com/RaumZeit/MarchingSquares.js * * MarchingSquaresJS is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * MarchingSquaresJS is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * As additional permission under GNU Affero General Public License version 3 * section 7, third-party projects (personal or commercial) may distribute, * include, or link against UNMODIFIED VERSIONS of MarchingSquaresJS without the * requirement that said third-party project for that reason alone becomes * subject to any requirement of the GNU Affero General Public License version 3. * Any modifications to MarchingSquaresJS, however, must be shared with the public * and made available. * * In summary this: * - allows you to use MarchingSquaresJS at no cost * - allows you to use MarchingSquaresJS for both personal and commercial purposes * - allows you to distribute UNMODIFIED VERSIONS of MarchingSquaresJS under any * license as long as this license notice is included * - enables you to keep the source code of your program that uses MarchingSquaresJS * undisclosed * - forces you to share any modifications you have made to MarchingSquaresJS, * e.g. bug-fixes * * You should have received a copy of the GNU Affero General Public License * along with MarchingSquaresJS. If not, see . */(t,r),s=[],a=0;as?128:64,l|=hs?32:16,l|=ps?8:4;var g=+(l|=fs?2:1),d=0;if(17===l||18===l||33===l||34===l||38===l||68===l||72===l||98===l||102===l||132===l||136===l||137===l||152===l||153===l){var y=(c+h+p+f)/4;d=y>s?2:y0?(l=156,d=4):l=152:33===l?d>0?(l=139,d=4):l=137:72===l?d>0?(l=99,d=4):l=98:132===l&&(d>0?(l=39,d=4):l=38);}if(0!=l&&170!=l){var v,_,m,x,E,b,w,I;v=_=m=x=E=b=w=I=.5;var N=[];1===l?(m=1-Vo(e,p,f),I=1-Vo(e,c,f),N.push(Go[l])):169===l?(m=Vo(s,f,p),I=Vo(s,f,c),N.push(Go[l])):4===l?(b=1-Vo(e,h,p),x=Vo(e,f,p),N.push(Fo[l])):166===l?(b=Vo(s,p,h),x=1-Vo(s,p,f),N.push(Fo[l])):16===l?(E=Vo(e,p,h),_=Vo(e,c,h),N.push(Do[l])):154===l?(E=1-Vo(s,h,p),_=1-Vo(s,h,c),N.push(Do[l])):64===l?(w=Vo(e,f,c),v=1-Vo(e,h,c),N.push(Bo[l])):106===l?(w=1-Vo(s,c,f),v=Vo(s,c,h),N.push(Bo[l])):168===l?(x=Vo(s,f,p),m=Vo(e,f,p),I=Vo(e,f,c),w=Vo(s,f,c),N.push(ko[l]),N.push(Go[l])):2===l?(x=1-Vo(e,p,f),m=1-Vo(s,p,f),I=1-Vo(s,c,f),w=1-Vo(e,c,f),N.push(ko[l]),N.push(Go[l])):162===l?(E=Vo(s,p,h),b=Vo(e,p,h),x=1-Vo(e,p,f),m=1-Vo(s,p,f),N.push(ko[l]),N.push(Go[l])):8===l?(E=1-Vo(e,h,p),b=1-Vo(s,h,p),x=Vo(s,f,p),m=Vo(e,f,p),N.push(Do[l]),N.push(Fo[l])):138===l?(E=1-Vo(e,h,p),b=1-Vo(s,h,p),v=1-Vo(s,h,c),_=1-Vo(e,h,c),N.push(Do[l]),N.push(Fo[l])):32===l?(E=Vo(s,p,h),b=Vo(e,p,h),v=Vo(e,c,h),_=Vo(s,c,h),N.push(Do[l]),N.push(Fo[l])):42===l?(I=1-Vo(s,c,f),w=1-Vo(e,c,f),v=Vo(e,c,h),_=Vo(s,c,h),N.push(qo[l]),N.push(Bo[l])):128===l&&(I=Vo(e,f,c),w=Vo(s,f,c),v=1-Vo(s,h,c),_=1-Vo(e,h,c),N.push(qo[l]),N.push(Bo[l])),5===l?(b=1-Vo(e,h,p),I=1-Vo(e,c,f),N.push(Fo[l])):165===l?(b=Vo(s,p,h),I=Vo(s,f,c),N.push(Fo[l])):20===l?(x=Vo(e,f,p),_=Vo(e,c,h),N.push(ko[l])):150===l?(x=1-Vo(s,p,f),_=1-Vo(s,h,c),N.push(ko[l])):80===l?(E=Vo(e,p,h),w=Vo(e,f,c),N.push(Do[l])):90===l?(E=1-Vo(s,h,p),w=1-Vo(s,c,f),N.push(Do[l])):65===l?(m=1-Vo(e,p,f),v=1-Vo(e,h,c),N.push(Go[l])):105===l?(m=Vo(s,f,p),v=Vo(s,c,h),N.push(Go[l])):160===l?(E=Vo(s,p,h),b=Vo(e,p,h),I=Vo(e,f,c),w=Vo(s,f,c),N.push(Do[l]),N.push(Fo[l])):10===l?(E=1-Vo(e,h,p),b=1-Vo(s,h,p),I=1-Vo(s,c,f),w=1-Vo(e,c,f),N.push(Do[l]),N.push(Fo[l])):130===l?(x=1-Vo(e,p,f),m=1-Vo(s,p,f),v=1-Vo(s,h,c),_=1-Vo(e,h,c),N.push(ko[l]),N.push(Go[l])):40===l?(x=Vo(s,f,p),m=Vo(e,f,p),v=Vo(e,c,h),_=Vo(s,c,h),N.push(ko[l]),N.push(Go[l])):101===l?(b=Vo(s,p,h),v=Vo(s,c,h),N.push(Fo[l])):69===l?(b=1-Vo(e,h,p),v=1-Vo(e,h,c),N.push(Fo[l])):149===l?(I=Vo(s,f,c),_=1-Vo(s,h,c),N.push(qo[l])):21===l?(I=1-Vo(e,c,f),_=Vo(e,c,h),N.push(qo[l])):86===l?(x=1-Vo(s,p,f),w=1-Vo(s,c,f),N.push(ko[l])):84===l?(x=Vo(e,f,p),w=Vo(e,f,c),N.push(ko[l])):89===l?(E=1-Vo(s,h,p),m=Vo(s,f,p),N.push(Go[l])):81===l?(E=Vo(e,p,h),m=1-Vo(e,p,f),N.push(Go[l])):96===l?(E=Vo(s,p,h),b=Vo(e,p,h),w=Vo(e,f,c),v=Vo(s,c,h),N.push(Do[l]),N.push(Fo[l])):74===l?(E=1-Vo(e,h,p),b=1-Vo(s,h,p),w=1-Vo(s,c,f),v=1-Vo(e,h,c),N.push(Do[l]),N.push(Fo[l])):24===l?(E=1-Vo(s,h,p),x=Vo(s,f,p),m=Vo(e,f,p),_=Vo(e,c,h),N.push(Do[l]),N.push(Go[l])):146===l?(E=Vo(e,p,h),x=1-Vo(e,p,f),m=1-Vo(s,p,f),_=1-Vo(s,h,c),N.push(Do[l]),N.push(Go[l])):6===l?(b=1-Vo(e,h,p),x=1-Vo(s,p,f),I=1-Vo(s,c,f),w=1-Vo(e,c,f),N.push(Fo[l]),N.push(ko[l])):164===l?(b=Vo(s,p,h),x=Vo(e,f,p),I=Vo(e,f,c),w=Vo(s,f,c),N.push(Fo[l]),N.push(ko[l])):129===l?(m=1-Vo(e,p,f),I=Vo(s,f,c),v=1-Vo(s,h,c),_=1-Vo(e,h,c),N.push(Go[l]),N.push(qo[l])):41===l?(m=Vo(s,f,p),I=1-Vo(e,c,f),v=Vo(e,c,h),_=Vo(s,c,h),N.push(Go[l]),N.push(qo[l])):66===l?(x=1-Vo(e,p,f),m=1-Vo(s,p,f),w=1-Vo(s,c,f),v=1-Vo(e,h,c),N.push(ko[l]),N.push(Go[l])):104===l?(x=Vo(s,f,p),m=Vo(e,f,p),w=Vo(e,f,c),v=Vo(s,c,h),N.push(Go[l]),N.push(zo[l])):144===l?(E=Vo(e,p,h),I=Vo(e,f,c),w=Vo(s,f,c),_=1-Vo(s,h,c),N.push(Do[l]),N.push(Bo[l])):26===l?(E=1-Vo(s,h,p),I=1-Vo(s,c,f),w=1-Vo(e,c,f),_=Vo(e,c,h),N.push(Do[l]),N.push(Bo[l])):36===l?(b=Vo(s,p,h),x=Vo(e,f,p),v=Vo(e,c,h),_=Vo(s,c,h),N.push(Fo[l]),N.push(ko[l])):134===l?(b=1-Vo(e,h,p),x=1-Vo(s,p,f),v=1-Vo(s,h,c),_=1-Vo(e,h,c),N.push(Fo[l]),N.push(ko[l])):9===l?(E=1-Vo(e,h,p),b=1-Vo(s,h,p),m=Vo(s,f,p),I=1-Vo(e,c,f),N.push(Do[l]),N.push(Fo[l])):161===l?(E=Vo(s,p,h),b=Vo(e,p,h),m=1-Vo(e,p,f),I=Vo(s,f,c),N.push(Do[l]),N.push(Fo[l])):37===l?(b=Vo(s,p,h),I=1-Vo(e,c,f),v=Vo(e,c,h),_=Vo(s,c,h),N.push(Fo[l]),N.push(qo[l])):133===l?(b=1-Vo(e,h,p),I=Vo(s,f,c),v=1-Vo(s,h,c),_=1-Vo(e,h,c),N.push(Fo[l]),N.push(qo[l])):148===l?(x=Vo(e,f,p),I=Vo(e,f,c),w=Vo(s,f,c),_=1-Vo(s,h,c),N.push(ko[l]),N.push(Bo[l])):22===l?(x=1-Vo(s,p,f),I=1-Vo(s,c,f),w=1-Vo(e,c,f),_=Vo(e,c,h),N.push(ko[l]),N.push(Bo[l])):82===l?(E=Vo(e,p,h),x=1-Vo(e,p,f),m=1-Vo(s,p,f),w=1-Vo(s,c,f),N.push(Do[l]),N.push(Go[l])):88===l?(E=1-Vo(s,h,p),x=Vo(s,f,p),m=Vo(e,f,p),w=Vo(e,f,c),N.push(Do[l]),N.push(Go[l])):73===l?(E=1-Vo(e,h,p),b=1-Vo(s,h,p),m=Vo(s,f,p),v=1-Vo(e,h,c),N.push(Do[l]),N.push(Fo[l])):97===l?(E=Vo(s,p,h),b=Vo(e,p,h),m=1-Vo(e,p,f),v=Vo(s,c,h),N.push(Do[l]),N.push(Fo[l])):145===l?(E=Vo(e,p,h),m=1-Vo(e,p,f),I=Vo(s,f,c),_=1-Vo(s,h,c),N.push(Do[l]),N.push(qo[l])):25===l?(E=1-Vo(s,h,p),m=Vo(s,f,p),I=1-Vo(e,c,f),_=Vo(e,c,h),N.push(Do[l]),N.push(qo[l])):70===l?(b=1-Vo(e,h,p),x=1-Vo(s,p,f),w=1-Vo(s,c,f),v=1-Vo(e,h,c),N.push(Fo[l]),N.push(ko[l])):100===l?(b=Vo(s,p,h),x=Vo(e,f,p),w=Vo(e,f,c),v=Vo(s,c,h),N.push(Fo[l]),N.push(ko[l])):34===l?(0===d?(E=1-Vo(e,h,p),b=1-Vo(s,h,p),x=Vo(s,f,p),m=Vo(e,f,p),I=Vo(e,f,c),w=Vo(s,f,c),v=1-Vo(s,h,c),_=1-Vo(e,h,c)):(E=Vo(s,p,h),b=Vo(e,p,h),x=1-Vo(e,p,f),m=1-Vo(s,p,f),I=1-Vo(s,c,f),w=1-Vo(e,c,f),v=Vo(e,c,h),_=Vo(s,c,h)),N.push(Do[l]),N.push(Fo[l]),N.push(qo[l]),N.push(Bo[l])):35===l?(4===d?(E=1-Vo(e,h,p),b=1-Vo(s,h,p),x=Vo(s,f,p),m=Vo(e,f,p),I=Vo(e,f,c),w=Vo(s,f,c),v=1-Vo(s,h,c),_=1-Vo(e,h,c)):(E=Vo(s,p,h),b=Vo(e,p,h),x=1-Vo(e,p,f),m=1-Vo(s,p,f),I=1-Vo(s,c,f),w=1-Vo(e,c,f),v=Vo(e,c,h),_=Vo(s,c,h)),N.push(Do[l]),N.push(Fo[l]),N.push(Go[l]),N.push(Bo[l])):136===l?(0===d?(E=Vo(s,p,h),b=Vo(e,p,h),x=1-Vo(e,p,f),m=1-Vo(s,p,f),I=1-Vo(s,c,f),w=1-Vo(e,c,f),v=Vo(e,c,h),_=Vo(s,c,h)):(E=1-Vo(e,h,p),b=1-Vo(s,h,p),x=Vo(s,f,p),m=Vo(e,f,p),I=Vo(e,f,c),w=Vo(s,f,c),v=1-Vo(s,h,c),_=1-Vo(e,h,c)),N.push(Do[l]),N.push(Fo[l]),N.push(qo[l]),N.push(Bo[l])):153===l?(0===d?(E=Vo(e,p,h),m=1-Vo(e,p,f),I=1-Vo(e,c,f),_=Vo(e,c,h)):(E=1-Vo(s,h,p),m=Vo(s,f,p),I=Vo(s,f,c),_=1-Vo(s,h,c)),N.push(Do[l]),N.push(Go[l])):102===l?(0===d?(b=1-Vo(e,h,p),x=Vo(e,f,p),w=Vo(e,f,c),v=1-Vo(e,h,c)):(b=Vo(s,p,h),x=1-Vo(s,p,f),w=1-Vo(s,c,f),v=Vo(s,c,h)),N.push(Fo[l]),N.push(Bo[l])):155===l?(4===d?(E=Vo(e,p,h),m=1-Vo(e,p,f),I=1-Vo(e,c,f),_=Vo(e,c,h)):(E=1-Vo(s,h,p),m=Vo(s,f,p),I=Vo(s,f,c),_=1-Vo(s,h,c)),N.push(Do[l]),N.push(qo[l])):103===l?(4===d?(b=1-Vo(e,h,p),x=Vo(e,f,p),w=Vo(e,f,c),v=1-Vo(e,h,c)):(b=Vo(s,p,h),x=1-Vo(s,p,f),w=1-Vo(s,c,f),v=Vo(s,c,h)),N.push(Fo[l]),N.push(ko[l])):152===l?(0===d?(E=Vo(e,p,h),x=1-Vo(e,p,f),m=1-Vo(s,p,f),I=1-Vo(s,c,f),w=1-Vo(e,c,f),_=Vo(e,c,h)):(E=1-Vo(s,h,p),x=Vo(s,f,p),m=Vo(e,f,p),I=Vo(e,f,c),w=Vo(s,f,c),_=1-Vo(s,h,c)),N.push(Do[l]),N.push(ko[l]),N.push(Go[l])):156===l?(4===d?(E=Vo(e,p,h),x=1-Vo(e,p,f),m=1-Vo(s,p,f),I=1-Vo(s,c,f),w=1-Vo(e,c,f),_=Vo(e,c,h)):(E=1-Vo(s,h,p),x=Vo(s,f,p),m=Vo(e,f,p),I=Vo(e,f,c),w=Vo(s,f,c),_=1-Vo(s,h,c)),N.push(Do[l]),N.push(Go[l]),N.push(Bo[l])):137===l?(0===d?(E=Vo(s,p,h),b=Vo(e,p,h),m=1-Vo(e,p,f),I=1-Vo(e,c,f),v=Vo(e,c,h),_=Vo(s,c,h)):(E=1-Vo(e,h,p),b=1-Vo(s,h,p),m=Vo(s,f,p),I=Vo(s,f,c),v=1-Vo(s,h,c),_=1-Vo(e,h,c)),N.push(Do[l]),N.push(Fo[l]),N.push(Go[l])):139===l?(4===d?(E=Vo(s,p,h),b=Vo(e,p,h),m=1-Vo(e,p,f),I=1-Vo(e,c,f),v=Vo(e,c,h),_=Vo(s,c,h)):(E=1-Vo(e,h,p),b=1-Vo(s,h,p),m=Vo(s,f,p),I=Vo(s,f,c),v=1-Vo(s,h,c),_=1-Vo(e,h,c)),N.push(Do[l]),N.push(Fo[l]),N.push(qo[l])):98===l?(0===d?(E=1-Vo(e,h,p),b=1-Vo(s,h,p),x=Vo(s,f,p),m=Vo(e,f,p),w=Vo(e,f,c),v=1-Vo(e,h,c)):(E=Vo(s,p,h),b=Vo(e,p,h),x=1-Vo(e,p,f),m=1-Vo(s,p,f),w=1-Vo(s,c,f),v=Vo(s,c,h)),N.push(Do[l]),N.push(Fo[l]),N.push(Bo[l])):99===l?(4===d?(E=1-Vo(e,h,p),b=1-Vo(s,h,p),x=Vo(s,f,p),m=Vo(e,f,p),w=Vo(e,f,c),v=1-Vo(e,h,c)):(E=Vo(s,p,h),b=Vo(e,p,h),x=1-Vo(e,p,f),m=1-Vo(s,p,f),w=1-Vo(s,c,f),v=Vo(s,c,h)),N.push(Do[l]),N.push(Fo[l]),N.push(Go[l])):38===l?(0===d?(b=1-Vo(e,h,p),x=Vo(e,f,p),I=Vo(e,f,c),w=Vo(s,f,c),v=1-Vo(s,h,c),_=1-Vo(e,h,c)):(b=Vo(s,p,h),x=1-Vo(s,p,f),I=1-Vo(s,c,f),w=1-Vo(e,c,f),v=Vo(e,c,h),_=Vo(s,c,h)),N.push(Fo[l]),N.push(qo[l]),N.push(Bo[l])):39===l?(4===d?(b=1-Vo(e,h,p),x=Vo(e,f,p),I=Vo(e,f,c),w=Vo(s,f,c),v=1-Vo(s,h,c),_=1-Vo(e,h,c)):(b=Vo(s,p,h),x=1-Vo(s,p,f),I=1-Vo(s,c,f),w=1-Vo(e,c,f),v=Vo(e,c,h),_=Vo(s,c,h)),N.push(Fo[l]),N.push(ko[l]),N.push(Bo[l])):85===l&&(E=1,b=0,x=1,m=0,I=0,w=1,v=0,_=1),(v<0||v>1||_<0||_>1||E<0||E>1||x<0||x>1||I<0||I>1||w<0||w>1)&&console.log("MarchingSquaresJS-isoBands: "+l+" "+g+" "+c+","+h+","+p+","+f+" "+d+" "+v+" "+_+" "+E+" "+b+" "+x+" "+m+" "+I+" "+w),o.cells[a][u]={cval:l,cval_real:g,flipped:d,topleft:v,topright:_,righttop:E,rightbottom:b,bottomright:x,bottomleft:m,leftbottom:I,lefttop:w,edges:N};}}}}return o;}(t,e,n);return Qi.polygons?(Qi.verbose&&console.log("MarchingSquaresJS-isoBands: returning single polygons for each grid cell"),u=function(t){var e=[],n=0;return t.cells.forEach(function(t,r){t.forEach(function(t,i){if(void 0!==t){var o=Uo[t.cval](t);"object"==_typeof(o)&&Xo(o)?"object"==_typeof(o[0])&&Xo(o[0])?"object"==_typeof(o[0][0])&&Xo(o[0][0])?o.forEach(function(t){t.forEach(function(t){t[0]+=i,t[1]+=r;}),e[n++]=t;}):(o.forEach(function(t){t[0]+=i,t[1]+=r;}),e[n++]=o):console.log("MarchingSquaresJS-isoBands: bandcell polygon with malformed coordinates"):console.log("MarchingSquaresJS-isoBands: bandcell polygon with null coordinates");}});}),e;}(l)):(Qi.verbose&&console.log("MarchingSquaresJS-isoBands: returning polygon paths for entire data grid"),u=function(t){for(var e=[],n=t.rows,r=t.cols,i=[],o=0;o0){var a=Ho(t.cells[o][s]),u=null,l=s,c=o;null!==a&&i.push([a.p[0]+l,a.p[1]+c]);do{if(null===(u=Wo(t.cells[c][l],a.x,a.y,a.o)))break;if(i.push([u.p[0]+l,u.p[1]+c]),l+=u.x,a=u,(c+=u.y)<0||c>=n||l<0||l>=r||void 0===t.cells[c][l]){var h=Yo(t,l-=u.x,c-=u.y,u.x,u.y,u.o);if(null===h)break;h.path.forEach(function(t){i.push(t);}),l=h.i,c=h.j,a=h;}}while(void 0!==t.cells[c][l]&&t.cells[c][l].edges.length>0);e.push(i),i=[],t.cells[o][s].edges.length>0&&s--;}return e;}(l)),"function"==typeof Qi.successCallback&&Qi.successCallback(u),u;}var to=64,eo=16,no=[],ro=[],io=[],oo=[],so=[],ao=[],uo=[],lo=[],co=[],ho=[],po=[],fo=[],go=[],yo=[],vo=[],_o=[],mo=[],xo=[],Eo=[],bo=[],wo=[],Io=[],No=[],So=[];uo[85]=ho[85]=-1,lo[85]=po[85]=0,co[85]=fo[85]=1,Eo[85]=Io[85]=1,bo[85]=No[85]=0,wo[85]=So[85]=1,no[85]=oo[85]=0,ro[85]=so[85]=-1,io[85]=vo[85]=0,_o[85]=go[85]=0,mo[85]=yo[85]=1,ao[85]=xo[85]=1,Io[1]=Io[169]=0,No[1]=No[169]=-1,So[1]=So[169]=0,go[1]=go[169]=-1,yo[1]=yo[169]=0,vo[1]=vo[169]=0,ho[4]=ho[166]=0,po[4]=po[166]=-1,fo[4]=fo[166]=1,_o[4]=_o[166]=1,mo[4]=mo[166]=0,xo[4]=xo[166]=0,uo[16]=uo[154]=0,lo[16]=lo[154]=1,co[16]=co[154]=1,oo[16]=oo[154]=1,so[16]=so[154]=0,ao[16]=ao[154]=1,Eo[64]=Eo[106]=0,bo[64]=bo[106]=1,wo[64]=wo[106]=0,no[64]=no[106]=-1,ro[64]=ro[106]=0,io[64]=io[106]=1,Eo[2]=Eo[168]=0,bo[2]=bo[168]=-1,wo[2]=wo[168]=1,Io[2]=Io[168]=0,No[2]=No[168]=-1,So[2]=So[168]=0,go[2]=go[168]=-1,yo[2]=yo[168]=0,vo[2]=vo[168]=0,_o[2]=_o[168]=-1,mo[2]=mo[168]=0,xo[2]=xo[168]=1,uo[8]=uo[162]=0,lo[8]=lo[162]=-1,co[8]=co[162]=0,ho[8]=ho[162]=0,po[8]=po[162]=-1,fo[8]=fo[162]=1,go[8]=go[162]=1,yo[8]=yo[162]=0,vo[8]=vo[162]=1,_o[8]=_o[162]=1,mo[8]=mo[162]=0,xo[8]=xo[162]=0,uo[32]=uo[138]=0,lo[32]=lo[138]=1,co[32]=co[138]=1,ho[32]=ho[138]=0,po[32]=po[138]=1,fo[32]=fo[138]=0,no[32]=no[138]=1,ro[32]=ro[138]=0,io[32]=io[138]=0,oo[32]=oo[138]=1,so[32]=so[138]=0,ao[32]=ao[138]=1,Io[128]=Io[42]=0,No[128]=No[42]=1,So[128]=So[42]=1,Eo[128]=Eo[42]=0,bo[128]=bo[42]=1,wo[128]=wo[42]=0,no[128]=no[42]=-1,ro[128]=ro[42]=0,io[128]=io[42]=1,oo[128]=oo[42]=-1,so[128]=so[42]=0,ao[128]=ao[42]=0,ho[5]=ho[165]=-1,po[5]=po[165]=0,fo[5]=fo[165]=0,Io[5]=Io[165]=1,No[5]=No[165]=0,So[5]=So[165]=0,_o[20]=_o[150]=0,mo[20]=mo[150]=1,xo[20]=xo[150]=1,oo[20]=oo[150]=0,so[20]=so[150]=-1,ao[20]=ao[150]=1,uo[80]=uo[90]=-1,lo[80]=lo[90]=0,co[80]=co[90]=1,Eo[80]=Eo[90]=1,bo[80]=bo[90]=0,wo[80]=wo[90]=1,go[65]=go[105]=0,yo[65]=yo[105]=1,vo[65]=vo[105]=0,no[65]=no[105]=0,ro[65]=ro[105]=-1,io[65]=io[105]=0,uo[160]=uo[10]=-1,lo[160]=lo[10]=0,co[160]=co[10]=1,ho[160]=ho[10]=-1,po[160]=po[10]=0,fo[160]=fo[10]=0,Io[160]=Io[10]=1,No[160]=No[10]=0,So[160]=So[10]=0,Eo[160]=Eo[10]=1,bo[160]=bo[10]=0,wo[160]=wo[10]=1,_o[130]=_o[40]=0,mo[130]=mo[40]=1,xo[130]=xo[40]=1,go[130]=go[40]=0,yo[130]=yo[40]=1,vo[130]=vo[40]=0,no[130]=no[40]=0,ro[130]=ro[40]=-1,io[130]=io[40]=0,oo[130]=oo[40]=0,so[130]=so[40]=-1,ao[130]=ao[40]=1,ho[37]=ho[133]=0,po[37]=po[133]=1,fo[37]=fo[133]=1,Io[37]=Io[133]=0,No[37]=No[133]=1,So[37]=So[133]=0,no[37]=no[133]=-1,ro[37]=ro[133]=0,io[37]=io[133]=0,oo[37]=oo[133]=1,so[37]=so[133]=0,ao[37]=ao[133]=0,_o[148]=_o[22]=-1,mo[148]=mo[22]=0,xo[148]=xo[22]=0,Io[148]=Io[22]=0,No[148]=No[22]=-1,So[148]=So[22]=1,Eo[148]=Eo[22]=0,bo[148]=bo[22]=1,wo[148]=wo[22]=1,oo[148]=oo[22]=-1,so[148]=so[22]=0,ao[148]=ao[22]=1,uo[82]=uo[88]=0,lo[82]=lo[88]=-1,co[82]=co[88]=1,_o[82]=_o[88]=1,mo[82]=mo[88]=0,xo[82]=xo[88]=1,go[82]=go[88]=-1,yo[82]=yo[88]=0,vo[82]=vo[88]=1,Eo[82]=Eo[88]=0,bo[82]=bo[88]=-1,wo[82]=wo[88]=0,uo[73]=uo[97]=0,lo[73]=lo[97]=1,co[73]=co[97]=0,ho[73]=ho[97]=0,po[73]=po[97]=-1,fo[73]=fo[97]=0,go[73]=go[97]=1,yo[73]=yo[97]=0,vo[73]=vo[97]=0,no[73]=no[97]=1,ro[73]=ro[97]=0,io[73]=io[97]=1,uo[145]=uo[25]=0,lo[145]=lo[25]=-1,co[145]=co[25]=0,go[145]=go[25]=1,yo[145]=yo[25]=0,vo[145]=vo[25]=1,Io[145]=Io[25]=0,No[145]=No[25]=1,So[145]=So[25]=1,oo[145]=oo[25]=-1,so[145]=so[25]=0,ao[145]=ao[25]=0,ho[70]=ho[100]=0,po[70]=po[100]=1,fo[70]=fo[100]=0,_o[70]=_o[100]=-1,mo[70]=mo[100]=0,xo[70]=xo[100]=1,Eo[70]=Eo[100]=0,bo[70]=bo[100]=-1,wo[70]=wo[100]=1,no[70]=no[100]=1,ro[70]=ro[100]=0,io[70]=io[100]=0,ho[101]=ho[69]=0,po[101]=po[69]=1,fo[101]=fo[69]=0,no[101]=no[69]=1,ro[101]=ro[69]=0,io[101]=io[69]=0,Io[149]=Io[21]=0,No[149]=No[21]=1,So[149]=So[21]=1,oo[149]=oo[21]=-1,so[149]=so[21]=0,ao[149]=ao[21]=0,_o[86]=_o[84]=-1,mo[86]=mo[84]=0,xo[86]=xo[84]=1,Eo[86]=Eo[84]=0,bo[86]=bo[84]=-1,wo[86]=wo[84]=1,uo[89]=uo[81]=0,lo[89]=lo[81]=-1,co[89]=co[81]=0,go[89]=go[81]=1,yo[89]=yo[81]=0,vo[89]=vo[81]=1,uo[96]=uo[74]=0,lo[96]=lo[74]=1,co[96]=co[74]=0,ho[96]=ho[74]=-1,po[96]=po[74]=0,fo[96]=fo[74]=1,Eo[96]=Eo[74]=1,bo[96]=bo[74]=0,wo[96]=wo[74]=0,no[96]=no[74]=1,ro[96]=ro[74]=0,io[96]=io[74]=1,uo[24]=uo[146]=0,lo[24]=lo[146]=-1,co[24]=co[146]=1,_o[24]=_o[146]=1,mo[24]=mo[146]=0,xo[24]=xo[146]=1,go[24]=go[146]=0,yo[24]=yo[146]=1,vo[24]=vo[146]=1,oo[24]=oo[146]=0,so[24]=so[146]=-1,ao[24]=ao[146]=0,ho[6]=ho[164]=-1,po[6]=po[164]=0,fo[6]=fo[164]=1,_o[6]=_o[164]=-1,mo[6]=mo[164]=0,xo[6]=xo[164]=0,Io[6]=Io[164]=0,No[6]=No[164]=-1,So[6]=So[164]=1,Eo[6]=Eo[164]=1,bo[6]=bo[164]=0,wo[6]=wo[164]=0,go[129]=go[41]=0,yo[129]=yo[41]=1,vo[129]=vo[41]=1,Io[129]=Io[41]=0,No[129]=No[41]=1,So[129]=So[41]=0,no[129]=no[41]=-1,ro[129]=ro[41]=0,io[129]=io[41]=0,oo[129]=oo[41]=0,so[129]=so[41]=-1,ao[129]=ao[41]=0,_o[66]=_o[104]=0,mo[66]=mo[104]=1,xo[66]=xo[104]=0,go[66]=go[104]=-1,yo[66]=yo[104]=0,vo[66]=vo[104]=1,Eo[66]=Eo[104]=0,bo[66]=bo[104]=-1,wo[66]=wo[104]=0,no[66]=no[104]=0,ro[66]=ro[104]=-1,io[66]=io[104]=1,uo[144]=uo[26]=-1,lo[144]=lo[26]=0,co[144]=co[26]=0,Io[144]=Io[26]=1,No[144]=No[26]=0,So[144]=So[26]=1,Eo[144]=Eo[26]=0,bo[144]=bo[26]=1,wo[144]=wo[26]=1,oo[144]=oo[26]=-1,so[144]=so[26]=0,ao[144]=ao[26]=1,ho[36]=ho[134]=0,po[36]=po[134]=1,fo[36]=fo[134]=1,_o[36]=_o[134]=0,mo[36]=mo[134]=1,xo[36]=xo[134]=0,no[36]=no[134]=0,ro[36]=ro[134]=-1,io[36]=io[134]=1,oo[36]=oo[134]=1,so[36]=so[134]=0,ao[36]=ao[134]=0,uo[9]=uo[161]=-1,lo[9]=lo[161]=0,co[9]=co[161]=0,ho[9]=ho[161]=0,po[9]=po[161]=-1,fo[9]=fo[161]=0,go[9]=go[161]=1,yo[9]=yo[161]=0,vo[9]=vo[161]=0,Io[9]=Io[161]=1,No[9]=No[161]=0,So[9]=So[161]=1,uo[136]=0,lo[136]=1,co[136]=1,ho[136]=0,po[136]=1,fo[136]=0,_o[136]=-1,mo[136]=0,xo[136]=1,go[136]=-1,yo[136]=0,vo[136]=0,Io[136]=0,No[136]=-1,So[136]=0,Eo[136]=0,bo[136]=-1,wo[136]=1,no[136]=1,ro[136]=0,io[136]=0,oo[136]=1,so[136]=0,ao[136]=1,uo[34]=0,lo[34]=-1,co[34]=0,ho[34]=0,po[34]=-1,fo[34]=1,_o[34]=1,mo[34]=0,xo[34]=0,go[34]=1,yo[34]=0,vo[34]=1,Io[34]=0,No[34]=1,So[34]=1,Eo[34]=0,bo[34]=1,wo[34]=0,no[34]=-1,ro[34]=0,io[34]=1,oo[34]=-1,so[34]=0,ao[34]=0,uo[35]=0,lo[35]=1,co[35]=1,ho[35]=0,po[35]=-1,fo[35]=1,_o[35]=1,mo[35]=0,xo[35]=0,go[35]=-1,yo[35]=0,vo[35]=0,Io[35]=0,No[35]=-1,So[35]=0,Eo[35]=0,bo[35]=1,wo[35]=0,no[35]=-1,ro[35]=0,io[35]=1,oo[35]=1,so[35]=0,ao[35]=1,uo[153]=0,lo[153]=1,co[153]=1,go[153]=-1,yo[153]=0,vo[153]=0,Io[153]=0,No[153]=-1,So[153]=0,oo[153]=1,so[153]=0,ao[153]=1,ho[102]=0,po[102]=-1,fo[102]=1,_o[102]=1,mo[102]=0,xo[102]=0,Eo[102]=0,bo[102]=1,wo[102]=0,no[102]=-1,ro[102]=0,io[102]=1,uo[155]=0,lo[155]=-1,co[155]=0,go[155]=1,yo[155]=0,vo[155]=1,Io[155]=0,No[155]=1,So[155]=1,oo[155]=-1,so[155]=0,ao[155]=0,ho[103]=0,po[103]=1,fo[103]=0,_o[103]=-1,mo[103]=0,xo[103]=1,Eo[103]=0,bo[103]=-1,wo[103]=1,no[103]=1,ro[103]=0,io[103]=0,uo[152]=0,lo[152]=1,co[152]=1,_o[152]=-1,mo[152]=0,xo[152]=1,go[152]=-1,yo[152]=0,vo[152]=0,Io[152]=0,No[152]=-1,So[152]=0,Eo[152]=0,bo[152]=-1,wo[152]=1,oo[152]=1,so[152]=0,ao[152]=1,uo[156]=0,lo[156]=-1,co[156]=1,_o[156]=1,mo[156]=0,xo[156]=1,go[156]=-1,yo[156]=0,vo[156]=0,Io[156]=0,No[156]=-1,So[156]=0,Eo[156]=0,bo[156]=1,wo[156]=1,oo[156]=-1,so[156]=0,ao[156]=1,uo[137]=0,lo[137]=1,co[137]=1,ho[137]=0,po[137]=1,fo[137]=0,go[137]=-1,yo[137]=0,vo[137]=0,Io[137]=0,No[137]=-1,So[137]=0,no[137]=1,ro[137]=0,io[137]=0,oo[137]=1,so[137]=0,ao[137]=1,uo[139]=0,lo[139]=1,co[139]=1,ho[139]=0,po[139]=-1,fo[139]=0,go[139]=1,yo[139]=0,vo[139]=0,Io[139]=0,No[139]=1,So[139]=0,no[139]=-1,ro[139]=0,io[139]=0,oo[139]=1,so[139]=0,ao[139]=1,uo[98]=0,lo[98]=-1,co[98]=0,ho[98]=0,po[98]=-1,fo[98]=1,_o[98]=1,mo[98]=0,xo[98]=0,go[98]=1,yo[98]=0,vo[98]=1,Eo[98]=0,bo[98]=1,wo[98]=0,no[98]=-1,ro[98]=0,io[98]=1,uo[99]=0,lo[99]=1,co[99]=0,ho[99]=0,po[99]=-1,fo[99]=1,_o[99]=1,mo[99]=0,xo[99]=0,go[99]=-1,yo[99]=0,vo[99]=1,Eo[99]=0,bo[99]=-1,wo[99]=0,no[99]=1,ro[99]=0,io[99]=1,ho[38]=0,po[38]=-1,fo[38]=1,_o[38]=1,mo[38]=0,xo[38]=0,Io[38]=0,No[38]=1,So[38]=1,Eo[38]=0,bo[38]=1,wo[38]=0,no[38]=-1,ro[38]=0,io[38]=1,oo[38]=-1,so[38]=0,ao[38]=0,ho[39]=0,po[39]=1,fo[39]=1,_o[39]=-1,mo[39]=0,xo[39]=0,Io[39]=0,No[39]=-1,So[39]=1,Eo[39]=0,bo[39]=1,wo[39]=0,no[39]=-1,ro[39]=0,io[39]=1,oo[39]=1,so[39]=0,ao[39]=0;var Co=function Co(t){return[[t.bottomleft,0],[0,0],[0,t.leftbottom]];},Po=function Po(t){return[[1,t.rightbottom],[1,0],[t.bottomright,0]];},Mo=function Mo(t){return[[t.topright,1],[1,1],[1,t.righttop]];},Lo=function Lo(t){return[[0,t.lefttop],[0,1],[t.topleft,1]];},Oo=function Oo(t){return[[t.bottomright,0],[t.bottomleft,0],[0,t.leftbottom],[0,t.lefttop]];},Ro=function Ro(t){return[[t.bottomright,0],[t.bottomleft,0],[1,t.righttop],[1,t.rightbottom]];},To=function To(t){return[[1,t.righttop],[1,t.rightbottom],[t.topleft,1],[t.topright,1]];},Ao=function Ao(t){return[[0,t.leftbottom],[0,t.lefttop],[t.topleft,1],[t.topright,1]];},Do=[],Fo=[],ko=[],Go=[],qo=[],Bo=[],zo=[],jo=[];Go[1]=qo[1]=18,Go[169]=qo[169]=18,ko[4]=Fo[4]=12,ko[166]=Fo[166]=12,Do[16]=jo[16]=4,Do[154]=jo[154]=4,Bo[64]=zo[64]=22,Bo[106]=zo[106]=22,ko[2]=Bo[2]=17,Go[2]=qo[2]=18,ko[168]=Bo[168]=17,Go[168]=qo[168]=18,Do[8]=Go[8]=9,Fo[8]=ko[8]=12,Do[162]=Go[162]=9,Fo[162]=ko[162]=12,Do[32]=jo[32]=4,Fo[32]=zo[32]=1,Do[138]=jo[138]=4,Fo[138]=zo[138]=1,qo[128]=jo[128]=21,Bo[128]=zo[128]=22,qo[42]=jo[42]=21,Bo[42]=zo[42]=22,Fo[5]=qo[5]=14,Fo[165]=qo[165]=14,ko[20]=jo[20]=6,ko[150]=jo[150]=6,Do[80]=Bo[80]=11,Do[90]=Bo[90]=11,Go[65]=zo[65]=3,Go[105]=zo[105]=3,Do[160]=Bo[160]=11,Fo[160]=qo[160]=14,Do[10]=Bo[10]=11,Fo[10]=qo[10]=14,ko[130]=jo[130]=6,Go[130]=zo[130]=3,ko[40]=jo[40]=6,Go[40]=zo[40]=3,Fo[101]=zo[101]=1,Fo[69]=zo[69]=1,qo[149]=jo[149]=21,qo[21]=jo[21]=21,ko[86]=Bo[86]=17,ko[84]=Bo[84]=17,Do[89]=Go[89]=9,Do[81]=Go[81]=9,Do[96]=zo[96]=0,Fo[96]=Bo[96]=15,Do[74]=zo[74]=0,Fo[74]=Bo[74]=15,Do[24]=ko[24]=8,Go[24]=jo[24]=7,Do[146]=ko[146]=8,Go[146]=jo[146]=7,Fo[6]=Bo[6]=15,ko[6]=qo[6]=16,Fo[164]=Bo[164]=15,ko[164]=qo[164]=16,Go[129]=jo[129]=7,qo[129]=zo[129]=20,Go[41]=jo[41]=7,qo[41]=zo[41]=20,ko[66]=zo[66]=2,Go[66]=Bo[66]=19,ko[104]=zo[104]=2,Go[104]=Bo[104]=19,Do[144]=qo[144]=10,Bo[144]=jo[144]=23,Do[26]=qo[26]=10,Bo[26]=jo[26]=23,Fo[36]=jo[36]=5,ko[36]=zo[36]=2,Fo[134]=jo[134]=5,ko[134]=zo[134]=2,Do[9]=qo[9]=10,Fo[9]=Go[9]=13,Do[161]=qo[161]=10,Fo[161]=Go[161]=13,Fo[37]=jo[37]=5,qo[37]=zo[37]=20,Fo[133]=jo[133]=5,qo[133]=zo[133]=20,ko[148]=qo[148]=16,Bo[148]=jo[148]=23,ko[22]=qo[22]=16,Bo[22]=jo[22]=23,Do[82]=ko[82]=8,Go[82]=Bo[82]=19,Do[88]=ko[88]=8,Go[88]=Bo[88]=19,Do[73]=zo[73]=0,Fo[73]=Go[73]=13,Do[97]=zo[97]=0,Fo[97]=Go[97]=13,Do[145]=Go[145]=9,qo[145]=jo[145]=21,Do[25]=Go[25]=9,qo[25]=jo[25]=21,Fo[70]=zo[70]=1,ko[70]=Bo[70]=17,Fo[100]=zo[100]=1,ko[100]=Bo[100]=17,Do[34]=Go[34]=9,Fo[34]=ko[34]=12,qo[34]=jo[34]=21,Bo[34]=zo[34]=22,Do[136]=jo[136]=4,Fo[136]=zo[136]=1,ko[136]=Bo[136]=17,Go[136]=qo[136]=18,Do[35]=jo[35]=4,Fo[35]=ko[35]=12,Go[35]=qo[35]=18,Bo[35]=zo[35]=22,Do[153]=jo[153]=4,Go[153]=qo[153]=18,Fo[102]=ko[102]=12,Bo[102]=zo[102]=22,Do[155]=Go[155]=9,qo[155]=jo[155]=23,Fo[103]=zo[103]=1,ko[103]=Bo[103]=17,Do[152]=jo[152]=4,ko[152]=Bo[152]=17,Go[152]=qo[152]=18,Do[156]=ko[156]=8,Go[156]=qo[156]=18,Bo[156]=jo[156]=23,Do[137]=jo[137]=4,Fo[137]=zo[137]=1,Go[137]=qo[137]=18,Do[139]=jo[139]=4,Fo[139]=Go[139]=13,qo[139]=zo[139]=20,Do[98]=Go[98]=9,Fo[98]=ko[98]=12,Bo[98]=zo[98]=22,Do[99]=zo[99]=0,Fo[99]=ko[99]=12,Go[99]=Bo[99]=19,Fo[38]=ko[38]=12,qo[38]=jo[38]=21,Bo[38]=zo[38]=22,Fo[39]=jo[39]=5,ko[39]=qo[39]=16,Bo[39]=zo[39]=22;var Uo=[];function Vo(t,e,n){return(t-e)/(n-e);}function Xo(t){return t.constructor.toString().indexOf("Array")>-1;}function Yo(t,e,n,r,i,o){for(var s=t.cells[n][e],a=s.cval_real,u=e+r,l=n+i,c=[],h=!1;!h;){if(void 0===t.cells[l]||void 0===t.cells[l][u]){if(l-=i,u-=r,a=(s=t.cells[l][u]).cval_real,-1===i){if(0===o){if(1&a)c.push([u,l]),r=-1,i=0,o=0;else{if(!(4&a)){c.push([u+s.bottomright,l]),r=0,i=1,o=1,h=!0;break;}c.push([u+1,l]),r=1,i=0,o=0;}}else{if(!(1&a)){if(4&a){c.push([u+s.bottomright,l]),r=0,i=1,o=1,h=!0;break;}c.push([u+s.bottomleft,l]),r=0,i=1,o=0,h=!0;break;}c.push([u,l]),r=-1,i=0,o=0;}}else if(1===i){if(0===o){if(!(a&eo)){if(a&to){c.push([u+s.topleft,l+1]),r=0,i=-1,o=0,h=!0;break;}c.push([u+s.topright,l+1]),r=0,i=-1,o=1,h=!0;break;}c.push([u+1,l+1]),r=1,i=0,o=1;}else c.push([u+1,l+1]),r=1,i=0,o=1;}else if(-1===r){if(0===o){if(!(a&to)){if(1&a){c.push([u,l+s.leftbottom]),r=1,i=0,o=0,h=!0;break;}c.push([u,l+s.lefttop]),r=1,i=0,o=1,h=!0;break;}c.push([u,l+1]),r=0,i=1,o=0;}else{if(!(a&to)){console.log("MarchingSquaresJS-isoBands: wtf");break;}c.push([u,l+1]),r=0,i=1,o=0;}}else{if(1!==r){console.log("MarchingSquaresJS-isoBands: we came from nowhere!");break;}if(0===o){if(!(4&a)){c.push([u+1,l+s.rightbottom]),r=-1,i=0,o=0,h=!0;break;}c.push([u+1,l]),r=0,i=-1,o=1;}else{if(!(4&a)){if(a&eo){c.push([u+1,l+s.righttop]),r=-1,i=0,o=1;break;}c.push([u+1,l+s.rightbottom]),r=-1,i=0,o=0,h=!0;break;}c.push([u+1,l]),r=0,i=-1,o=1;}}}else if(a=(s=t.cells[l][u]).cval_real,-1===r){if(0===o){if(void 0!==t.cells[l-1]&&void 0!==t.cells[l-1][u])r=0,i=-1,o=1;else{if(!(1&a)){c.push([u+s.bottomright,l]),r=0,i=1,o=1,h=!0;break;}c.push([u,l]);}}else{if(!(a&to)){console.log("MarchingSquaresJS-isoBands: found entry from top at "+u+","+l);break;}console.log("MarchingSquaresJS-isoBands: proceeding in x-direction!");}}else if(1===r){if(0===o){console.log("MarchingSquaresJS-isoBands: wtf");break;}if(void 0!==t.cells[l+1]&&void 0!==t.cells[l+1][u])r=0,i=1,o=0;else{if(!(a&eo)){c.push([u+s.topleft,l+1]),r=0,i=-1,o=0,h=!0;break;}c.push([u+1,l+1]),r=1,i=0,o=1;}}else if(-1===i){if(1!==o){console.log("MarchingSquaresJS-isoBands: wtf");break;}if(void 0!==t.cells[l][u+1])r=1,i=0,o=1;else{if(!(4&a)){c.push([u+1,l+s.righttop]),r=-1,i=0,o=1,h=!0;break;}c.push([u+1,l]),r=0,i=-1,o=1;}}else{if(1!==i){console.log("MarchingSquaresJS-isoBands: where did we came from???");break;}if(0!==o){console.log("MarchingSquaresJS-isoBands: wtf");break;}if(void 0!==t.cells[l][u-1])r=-1,i=0,o=0;else{if(!(a&to)){c.push([u,l+s.leftbottom]),r=1,i=0,o=0,h=!0;break;}c.push([u,l+1]),r=0,i=1,o=0;}}if(l+=i,(u+=r)===e&&l===n)break;}return{path:c,i:u,j:l,x:r,y:i,o:o};}function Ho(t){if(t.edges.length>0){var e=t.edges[t.edges.length-1],n=t.cval_real;switch(e){case 0:return n&eo?{p:[1,t.righttop],x:-1,y:0,o:1}:{p:[t.topleft,1],x:0,y:-1,o:0};case 1:return 4&n?{p:[t.topleft,1],x:0,y:-1,o:0}:{p:[1,t.rightbottom],x:-1,y:0,o:0};case 2:return 4&n?{p:[t.bottomright,0],x:0,y:1,o:1}:{p:[t.topleft,1],x:0,y:-1,o:0};case 3:return 1&n?{p:[t.topleft,1],x:0,y:-1,o:0}:{p:[t.bottomleft,0],x:0,y:1,o:0};case 4:return n&eo?{p:[1,t.righttop],x:-1,y:0,o:1}:{p:[t.topright,1],x:0,y:-1,o:1};case 5:return 4&n?{p:[t.topright,1],x:0,y:-1,o:1}:{p:[1,t.rightbottom],x:-1,y:0,o:0};case 6:return 4&n?{p:[t.bottomright,0],x:0,y:1,o:1}:{p:[t.topright,1],x:0,y:-1,o:1};case 7:return 1&n?{p:[t.topright,1],x:0,y:-1,o:1}:{p:[t.bottomleft,0],x:0,y:1,o:0};case 8:return 4&n?{p:[t.bottomright,0],x:0,y:1,o:1}:{p:[1,t.righttop],x:-1,y:0,o:1};case 9:return 1&n?{p:[1,t.righttop],x:-1,y:0,o:1}:{p:[t.bottomleft,0],x:0,y:1,o:0};case 10:return 1&n?{p:[0,t.leftbottom],x:1,y:0,o:0}:{p:[1,t.righttop],x:-1,y:0,o:1};case 11:return n&to?{p:[1,t.righttop],x:-1,y:0,o:1}:{p:[0,t.lefttop],x:1,y:0,o:1};case 12:return 4&n?{p:[t.bottomright,0],x:0,y:1,o:1}:{p:[1,t.rightbottom],x:-1,y:0,o:0};case 13:return 1&n?{p:[1,t.rightbottom],x:-1,y:0,o:0}:{p:[t.bottomleft,0],x:0,y:1,o:0};case 14:return 1&n?{p:[0,t.leftbottom],x:1,y:0,o:0}:{p:[1,t.rightbottom],x:-1,y:0,o:0};case 15:return n&to?{p:[1,t.rightbottom],x:-1,y:0,o:0}:{p:[0,t.lefttop],x:1,y:0,o:1};case 16:return 4&n?{p:[t.bottomright,0],x:0,y:1,o:1}:{p:[0,t.leftbottom],x:1,y:0,o:0};case 17:return n&to?{p:[t.bottomright,0],x:0,y:1,o:1}:{p:[0,t.lefttop],x:1,y:0,o:1};case 18:return 1&n?{p:[0,t.leftbottom],x:1,y:0,o:0}:{p:[t.bottomleft,0],x:0,y:1,o:0};case 19:return n&to?{p:[t.bottomleft,0],x:0,y:1,o:0}:{p:[0,t.lefttop],x:1,y:0,o:1};case 20:return n&to?{p:[t.topleft,1],x:0,y:-1,o:0}:{p:[0,t.leftbottom],x:1,y:0,o:0};case 21:return n&eo?{p:[0,t.leftbottom],x:1,y:0,o:0}:{p:[t.topright,1],x:0,y:-1,o:1};case 22:return n&to?{p:[t.topleft,1],x:0,y:-1,o:0}:{p:[0,t.lefttop],x:1,y:0,o:1};case 23:return n&eo?{p:[0,t.lefttop],x:1,y:0,o:1}:{p:[t.topright,1],x:0,y:-1,o:1};default:console.log("MarchingSquaresJS-isoBands: edge index out of range!"),console.log(t);}}return null;}function Wo(t,e,n,r){var i,o,s,a,u,l=t.cval;switch(e){case-1:switch(r){case 0:i=Fo[l],s=ho[l],a=po[l],u=fo[l];break;default:i=Do[l],s=uo[l],a=lo[l],u=co[l];}break;case 1:switch(r){case 0:i=qo[l],s=Io[l],a=No[l],u=So[l];break;default:i=Bo[l],s=Eo[l],a=bo[l],u=wo[l];}break;default:switch(n){case-1:switch(r){case 0:i=zo[l],s=no[l],a=ro[l],u=io[l];break;default:i=jo[l],s=oo[l],a=so[l],u=ao[l];}break;case 1:switch(r){case 0:i=Go[l],s=go[l],a=yo[l],u=vo[l];break;default:i=ko[l],s=_o[l],a=mo[l],u=xo[l];}}}if(o=t.edges.indexOf(i),void 0===t.edges[o])return null;switch(function(t,e){delete t.edges[e];for(var n=e+1;n0){var a=r[e-1],u=is(n,a);!1!==u&&(a[1]=u,n[0]=u),s.push(a[0]),e===o.length-2&&(s.push(n[0]),s.push(n[1]));}2===o.length&&(s.push(n[0]),s.push(n[1]));}var l,c,h,p,f,g,d,y;}),h(s,t.properties);}function ss(t,e,n){var r=e[0]-t[0],i=e[1]-t[1],o=n[0]-e[0];return function(t){return(t>0)-(t<0)||+t;}(r*(n[1]-e[1])-o*i);}function as(t,e){return e.geometry.coordinates[0].every(function(e){return ye(a(e),t);});}Uo[1]=Uo[169]=Co,Uo[4]=Uo[166]=Po,Uo[16]=Uo[154]=Mo,Uo[64]=Uo[106]=Lo,Uo[168]=Uo[2]=Oo,Uo[162]=Uo[8]=Ro,Uo[138]=Uo[32]=To,Uo[42]=Uo[128]=Ao,Uo[5]=Uo[165]=function(t){return[[0,0],[0,t.leftbottom],[1,t.rightbottom],[1,0]];},Uo[20]=Uo[150]=function(t){return[[1,0],[t.bottomright,0],[t.topright,1],[1,1]];},Uo[80]=Uo[90]=function(t){return[[1,1],[1,t.righttop],[0,t.lefttop],[0,1]];},Uo[65]=Uo[105]=function(t){return[[t.bottomleft,0],[0,0],[0,1],[t.topleft,1]];},Uo[160]=Uo[10]=function(t){return[[1,t.righttop],[1,t.rightbottom],[0,t.leftbottom],[0,t.lefttop]];},Uo[130]=Uo[40]=function(t){return[[t.topleft,1],[t.topright,1],[t.bottomright,0],[t.bottomleft,0]];},Uo[85]=function(){return[[0,0],[0,1],[1,1],[1,0]];},Uo[101]=Uo[69]=function(t){return[[1,t.rightbottom],[1,0],[0,0],[0,1],[t.topleft,1]];},Uo[149]=Uo[21]=function(t){return[[t.topright,1],[1,1],[1,0],[0,0],[0,t.leftbottom]];},Uo[86]=Uo[84]=function(t){return[[1,0],[t.bottomright,0],[0,t.lefttop],[0,1],[1,1]];},Uo[89]=Uo[81]=function(t){return[[1,1],[1,t.righttop],[t.bottomleft,0],[0,0],[0,1]];},Uo[96]=Uo[74]=function(t){return[[1,t.righttop],[1,t.rightbottom],[0,t.lefttop],[0,1],[t.topleft,1]];},Uo[24]=Uo[146]=function(t){return[[1,1],[1,t.righttop],[t.bottomright,0],[t.bottomleft,0],[t.topright,1]];},Uo[6]=Uo[164]=function(t){return[[1,t.rightbottom],[1,0],[t.bottomright,0],[0,t.leftbottom],[0,t.lefttop]];},Uo[129]=Uo[41]=function(t){return[[t.topright,1],[t.bottomleft,0],[0,0],[0,t.leftbottom],[t.topleft,1]];},Uo[66]=Uo[104]=function(t){return[[t.bottomright,0],[t.bottomleft,0],[0,t.lefttop],[0,1],[t.topleft,1]];},Uo[144]=Uo[26]=function(t){return[[1,1],[1,t.righttop],[0,t.leftbottom],[0,t.lefttop],[t.topright,1]];},Uo[36]=Uo[134]=function(t){return[[1,t.rightbottom],[1,0],[t.bottomright,0],[t.topleft,1],[t.topright,1]];},Uo[9]=Uo[161]=function(t){return[[1,t.righttop],[1,t.rightbottom],[t.bottomleft,0],[0,0],[0,t.leftbottom]];},Uo[37]=Uo[133]=function(t){return[[1,t.rightbottom],[1,0],[0,0],[0,t.leftbottom],[t.topleft,1],[t.topright,1]];},Uo[148]=Uo[22]=function(t){return[[1,1],[1,0],[t.bottomright,0],[0,t.leftbottom],[0,t.lefttop],[t.topright,1]];},Uo[82]=Uo[88]=function(t){return[[1,1],[1,t.righttop],[t.bottomright,0],[t.bottomleft,0],[0,t.lefttop],[0,1]];},Uo[73]=Uo[97]=function(t){return[[1,t.righttop],[1,t.rightbottom],[t.bottomleft,0],[0,0],[0,1],[t.topleft,1]];},Uo[145]=Uo[25]=function(t){return[[1,1],[1,t.righttop],[t.bottomleft,0],[0,0],[0,t.leftbottom],[t.topright,1]];},Uo[70]=Uo[100]=function(t){return[[1,t.rightbottom],[1,0],[t.bottomright,0],[0,t.lefttop],[0,1],[t.topleft,1]];},Uo[34]=function(t){return[Ao(t),Ro(t)];},Uo[35]=function(t){return[[1,t.righttop],[1,t.rightbottom],[t.bottomright,0],[t.bottomleft,0],[0,t.leftbottom],[0,t.lefttop],[t.topleft,1],[t.topright,1]];},Uo[136]=function(t){return[To(t),Oo(t)];},Uo[153]=function(t){return[Mo(t),Co(t)];},Uo[102]=function(t){return[Po(t),Lo(t)];},Uo[155]=function(t){return[[1,1],[1,t.righttop],[t.bottomleft,0],[0,0],[0,t.leftbottom],[t.topright,1]];},Uo[103]=function(t){return[[1,t.rightbottom],[1,0],[t.bottomright,0],[0,t.lefttop],[0,1],[t.topleft,1]];},Uo[152]=function(t){return[Mo(t),Oo(t)];},Uo[156]=function(t){return[[1,1],[1,t.righttop],[t.bottomright,0],[t.bottomleft,0],[0,t.leftbottom],[0,t.lefttop],[t.topright,1]];},Uo[137]=function(t){return[To(t),Co(t)];},Uo[139]=function(t){return[[1,t.righttop],[1,t.rightbottom],[t.bottomleft,0],[0,0],[0,t.leftbottom],[t.topleft,1],[t.topright,1]];},Uo[98]=function(t){return[Ro(t),Lo(t)];},Uo[99]=function(t){return[[1,t.righttop],[1,t.rightbottom],[t.bottomright,0],[t.bottomleft,0],[0,t.lefttop],[0,1],[t.topleft,1]];},Uo[38]=function(t){return[Po(t),Ao(t)];},Uo[39]=function(t){return[[1,t.rightbottom],[1,0],[t.bottomright,0],[0,t.leftbottom],[0,t.lefttop],[t.topleft,1],[t.topright,1]];};var us=function(){function t(e){this.id=t.buildId(e),this.coordinates=e,this.innerEdges=[],this.outerEdges=[],this.outerEdgesSorted=!1;}return t.buildId=function(t){return t.join(",");},t.prototype.removeInnerEdge=function(t){this.innerEdges=this.innerEdges.filter(function(e){return e.from.id!==t.from.id;});},t.prototype.removeOuterEdge=function(t){this.outerEdges=this.outerEdges.filter(function(e){return e.to.id!==t.to.id;});},t.prototype.addOuterEdge=function(t){this.outerEdges.push(t),this.outerEdgesSorted=!1;},t.prototype.sortOuterEdges=function(){var t=this;this.outerEdgesSorted||(this.outerEdges.sort(function(e,n){var r=e.to,i=n.to;if(r.coordinates[0]-t.coordinates[0]>=0&&i.coordinates[0]-t.coordinates[0]<0)return 1;if(r.coordinates[0]-t.coordinates[0]<0&&i.coordinates[0]-t.coordinates[0]>=0)return-1;if(r.coordinates[0]-t.coordinates[0]==0&&i.coordinates[0]-t.coordinates[0]==0)return r.coordinates[1]-t.coordinates[1]>=0||i.coordinates[1]-t.coordinates[1]>=0?r.coordinates[1]-i.coordinates[1]:i.coordinates[1]-r.coordinates[1];var o=ss(t.coordinates,r.coordinates,i.coordinates);return o<0?1:o>0?-1:Math.pow(r.coordinates[0]-t.coordinates[0],2)+Math.pow(r.coordinates[1]-t.coordinates[1],2)-(Math.pow(i.coordinates[0]-t.coordinates[0],2)+Math.pow(i.coordinates[1]-t.coordinates[1],2));}),this.outerEdgesSorted=!0);},t.prototype.getOuterEdges=function(){return this.sortOuterEdges(),this.outerEdges;},t.prototype.getOuterEdge=function(t){return this.sortOuterEdges(),this.outerEdges[t];},t.prototype.addInnerEdge=function(t){this.innerEdges.push(t);},t;}(),ls=function(){function t(t,e){this.from=t,this.to=e,this.next=void 0,this.label=void 0,this.symetric=void 0,this.ring=void 0,this.from.addOuterEdge(this),this.to.addInnerEdge(this);}return t.prototype.getSymetric=function(){return this.symetric||(this.symetric=new t(this.to,this.from),this.symetric.symetric=this),this.symetric;},t.prototype.deleteEdge=function(){this.from.removeOuterEdge(this),this.to.removeInnerEdge(this);},t.prototype.isEqual=function(t){return this.from.id===t.from.id&&this.to.id===t.to.id;},t.prototype.toString=function(){return"Edge { "+this.from.id+" -> "+this.to.id+" }";},t.prototype.toLineString=function(){return h([this.from.coordinates,this.to.coordinates]);},t.prototype.compareTo=function(t){return ss(t.from.coordinates,t.to.coordinates,this.to.coordinates);},t;}(),cs=function(){function t(){this.edges=[],this.polygon=void 0,this.envelope=void 0;}return t.prototype.push=function(t){this.edges.push(t),this.polygon=this.envelope=void 0;},t.prototype.get=function(t){return this.edges[t];},Object.defineProperty(t.prototype,"length",{get:function get(){return this.edges.length;},enumerable:!0,configurable:!0}),t.prototype.forEach=function(t){this.edges.forEach(t);},t.prototype.map=function(t){return this.edges.map(t);},t.prototype.some=function(t){return this.edges.some(t);},t.prototype.isValid=function(){return!0;},t.prototype.isHole=function(){var t=this,e=this.edges.reduce(function(e,n,r){return n.from.coordinates[1]>t.edges[e].from.coordinates[1]&&(e=r),e;},0),n=(0===e?this.length:e)-1,r=(e+1)%this.length,i=ss(this.edges[n].from.coordinates,this.edges[e].from.coordinates,this.edges[r].from.coordinates);return 0===i?this.edges[n].from.coordinates[0]>this.edges[r].from.coordinates[0]:i>0;},t.prototype.toMultiPoint=function(){return d(this.edges.map(function(t){return t.from.coordinates;}));},t.prototype.toPolygon=function(){if(this.polygon)return this.polygon;var t=this.edges.map(function(t){return t.from.coordinates;});return t.push(this.edges[0].from.coordinates),this.polygon=l([t]);},t.prototype.getEnvelope=function(){return this.envelope?this.envelope:this.envelope=dn(this.toPolygon());},t.findEdgeRingContaining=function(t,e){var n,r,i=t.getEnvelope();return e.forEach(function(e){var o,s,u,l,c,h,p=e.getEnvelope();if((r&&(n=r.getEnvelope()),s=i,u=(o=p).geometry.coordinates[0].map(function(t){return t[0];}),l=o.geometry.coordinates[0].map(function(t){return t[1];}),c=s.geometry.coordinates[0].map(function(t){return t[0];}),h=s.geometry.coordinates[0].map(function(t){return t[1];}),Math.max.apply(null,u)!==Math.max.apply(null,c)||Math.max.apply(null,l)!==Math.max.apply(null,h)||Math.min.apply(null,u)!==Math.min.apply(null,c)||Math.min.apply(null,l)!==Math.min.apply(null,h))&&as(p,i)){for(var f=t.map(function(t){return t.from.coordinates;}),g=void 0,d=function d(t){e.some(function(e){return n=t,r=e.from.coordinates,n[0]===r[0]&&n[1]===r[1];var n,r;})||(g=t);},y=0,v=f;y=0;--o){var s=i[o],a=s.symetric,u=void 0,l=void 0;s.label===e&&(u=s),a.label===e&&(l=a),u&&l&&(l&&(r=l),u&&(r&&(r.next=u,r=void 0),n||(n=u)));}r&&(r.next=n);},t.prototype._findLabeledEdgeRings=function(){var t=[],e=0;return this.edges.forEach(function(n){if(!(n.label>=0)){t.push(n);var r=n;do{r.label=e,r=r.next;}while(!n.isEqual(r));e++;}}),t;},t.prototype.getEdgeRings=function(){var t=this;this._computeNextCWEdges(),this.edges.forEach(function(t){t.label=void 0;}),this._findLabeledEdgeRings().forEach(function(e){t._findIntersectionNodes(e).forEach(function(n){t._computeNextCCWEdges(n,e.label);});});var e=[];return this.edges.forEach(function(n){n.ring||e.push(t._findEdgeRing(n));}),e;},t.prototype._findIntersectionNodes=function(t){var e=[],n=t,r=function r(){var r=0;n.from.getOuterEdges().forEach(function(e){e.label===t.label&&++r;}),r>1&&e.push(n.from),n=n.next;};do{r();}while(!t.isEqual(n));return e;},t.prototype._findEdgeRing=function(t){var e=t,n=new cs();do{n.push(e),e.ring=n,e=e.next;}while(!t.isEqual(e));return n;},t.prototype.removeNode=function(t){var e=this;t.getOuterEdges().forEach(function(t){return e.removeEdge(t);}),t.innerEdges.forEach(function(t){return e.removeEdge(t);}),delete this.nodes[t.id];},t.prototype.removeEdge=function(t){this.edges=this.edges.filter(function(e){return!e.isEqual(t);}),t.deleteEdge();},t;}();function ps(t,e){var n=!0;return z(t,function(t){z(e,function(e){if(!1===n)return!1;n=function(t,e){switch(t.type){case"Point":switch(e.type){case"Point":return n=t.coordinates,r=e.coordinates,!(n[0]===r[0]&&n[1]===r[1]);case"LineString":return!fs(e,t);case"Polygon":return!ye(t,e);}break;case"LineString":switch(e.type){case"Point":return!fs(t,e);case"LineString":return!function(t,e){if(Or(t,e).features.length>0)return!0;return!1;}(t,e);case"Polygon":return!gs(e,t);}break;case"Polygon":switch(e.type){case"Point":return!ye(e,t);case"LineString":return!gs(t,e);case"Polygon":return!function(t,e){for(var n=0,r=t.coordinates[0];n0)return!0;return!1;}(e,t);}}var n,r;return!1;}(t.geometry,e.geometry);});}),n;}function fs(t,e){for(var n=0;n0;}function ds(t,e,n){var r=n[0]-t[0],i=n[1]-t[1],o=e[0]-t[0],s=e[1]-t[1];return 0==r*s-i*o&&(Math.abs(o)>=Math.abs(s)?o>0?t[0]<=n[0]&&n[0]<=e[0]:e[0]<=n[0]&&n[0]<=t[0]:s>0?t[1]<=n[1]&&n[1]<=e[1]:e[1]<=n[1]&&n[1]<=t[1]);}function ys(t,e){return!(t[0]>e[0])&&!(t[2]e[1])&&!(t[3]0;}function Es(t,e){for(var n=!1,r=!1,i=t.coordinates.length,o=0;o=Math.abs(a)?s>0?t[0]<=n[0]&&n[0]<=e[0]:e[0]<=n[0]&&n[0]<=t[0]:a>0?t[1]<=n[1]&&n[1]<=e[1]:e[1]<=n[1]&&n[1]<=t[1]:Math.abs(s)>=Math.abs(a)?s>0?t[0]0?t[1]=0&&(n=[].concat(t.slice(r,t.length),t.slice(1,r+1))),n;},ws.prototype.comparePath=function(t,e){var n=this;return t.every(function(t,e){return n.compareCoord(t,this[e]);},e);},ws.prototype.comparePolygon=function(t,e){if(this.compareLine(t.coordinates[0],e.coordinates[0],1,!0)){var n=t.coordinates.slice(1,t.coordinates.length),r=e.coordinates.slice(1,e.coordinates.length),i=this;return n.every(function(t){return this.some(function(e){return i.compareLine(t,e,1,!0);});},r);}return!1;},ws.prototype.compareFeature=function(t,e){return!(t.id!==e.id||!this.objectComparator(t.properties,e.properties)||!this.compareBBox(t,e))&&this.compare(t.geometry,e.geometry);},ws.prototype.compareBBox=function(t,e){return!!(!t.bbox&&!e.bbox||t.bbox&&e.bbox&&this.compareCoord(t.bbox,e.bbox));},ws.prototype.removePseudo=function(t){return t;};var Cs=ws;function Ps(t,e){var n=!1;return z(t,function(t){z(e,function(e){if(!0===n)return!0;n=!ps(t.geometry,e.geometry);});}),n;}var Ms=Bt(function(t){function e(t,e,n,r){this.dataset=[],this.epsilon=1,this.minPts=2,this.distance=this._euclideanDistance,this.clusters=[],this.noise=[],this._visited=[],this._assigned=[],this._datasetLength=0,this._init(t,e,n,r);}e.prototype.run=function(t,e,n,r){this._init(t,e,n,r);for(var i=0;i=this.minPts&&(e=this._mergeArrays(e,i));}1!==this._assigned[r]&&this._addToCluster(r,t);}},e.prototype._addToCluster=function(t,e){this.clusters[e].push(t),this._assigned[t]=1;},e.prototype._regionQuery=function(t){for(var e=[],n=0;n0){for(u=0;u=0);return t;},e.prototype.assign=function(){for(var t,e=!1,n=this.dataset.length,r=0;ri&&(n=r):e=this.minPts)return n;}},n.prototype._regionQuery=function(t,e){e=e||this.epsilon;for(var n=[],r=0,i=this.dataset.length;r0;r.length0;){var a=t[Math.floor(Math.random()*o)],u=s?a.join("_"):""+a;n[u]||(n[u]=!0,r.push(a));}if(r.length0,s=t[Math.floor(Math.random()*i)];o&&s.join("_");for(r.push(s);r.length0,f=[];if(n)i="kmrand"==n?Gs(t,e):"kmpp"==n?qs(t,e):n;else for(var g={};i.length0;){var u=s.pop();if(u===n)return Vs(u);u.closed=!0;for(var l=t.neighbors(u),c=0,h=l.length;c0)){if(o/=p,p<0){if(o0){if(o>h)return;o>c&&(c=o);}if(o=r-u,p||!(o<0)){if(o/=p,p<0){if(o>h)return;o>c&&(c=o);}else if(p>0){if(o0)){if(o/=f,f<0){if(o0){if(o>h)return;o>c&&(c=o);}if(o=i-l,f||!(o<0)){if(o/=f,f<0){if(o>h)return;o>c&&(c=o);}else if(f>0){if(o0||h<1)||(c>0&&(t[0]=[u+c*p,l+c*f]),h<1&&(t[1]=[u+h*p,l+h*f]),!0);}}}}}function ua(t,e,n,r,i){var o=t[1];if(o)return!0;var s,a,u=t[0],l=t.left,c=t.right,h=l[0],p=l[1],f=c[0],g=c[1],d=(h+f)/2,y=(p+g)/2;if(g===p){if(d=r)return;if(h>f){if(u){if(u[1]>=i)return;}else u=[d,n];o=[d,i];}else{if(u){if(u[1]1){if(h>f){if(u){if(u[1]>=i)return;}else u=[(n-a)/s,n];o=[(i-a)/s,i];}else{if(u){if(u[1]=r)return;}else u=[e,s*e+a];o=[r,s*r+a];}else{if(u){if(u[0]0&&(this.content[0]=e,this.bubbleUp(0)),t;},remove:function remove(t){var e=this.content.indexOf(t),n=this.content.pop();e!==this.content.length-1&&(this.content[e]=n,this.scoreFunction(n)0;){var n=(t+1>>1)-1,r=this.content[n];if(!(this.scoreFunction(e)=-La)){var f=u*u+l*l,g=c*c+h*h,d=(h*f-l*g)/p,y=(u*g-c*f)/p,v=fa.pop()||new ga();v.arc=t,v.site=i,v.x=d+s,v.y=(v.cy=y+a)+Math.sqrt(d*d+y*y),t.circle=v;for(var _=null,m=Ca._;m;)if(v.yMa)a=a.L;else{if(!((i=o-Ia(a,s))>Ma)){r>-Ma?(e=a.P,n=a):i>-Ma?(e=a,n=a.N):e=n=a;break;}if(!a.R){e=a;break;}a=a.R;}!function(t){Sa[t.index]={site:t,halfedges:[]};}(t);var u=ma(t);if(Na.insert(e,u),e||n){if(e===n)return ya(e),n=ma(e.site),Na.insert(u,n),u.edge=n.edge=ia(e.site,u.site),da(e),void da(n);if(n){ya(e),ya(n);var l=e.site,c=l[0],h=l[1],p=t[0]-c,f=t[1]-h,g=n.site,d=g[0]-c,y=g[1]-h,v=2*(p*y-f*d),_=p*p+f*f,m=d*d+y*y,x=[(y*_-f*m)/v+c,(p*m-d*_)/v+h];sa(n.edge,l,g,x),u.edge=ia(l,t,null,x),n.edge=ia(t,g,null,x),da(e),da(n);}else u.edge=ia(e.site,u.site);}}function wa(t,e){var n=t.site,r=n[0],i=n[1],o=i-e;if(!o)return r;var s=t.P;if(!s)return-1/0;var a=(n=s.site)[0],u=n[1],l=u-e;if(!l)return a;var c=a-r,h=1/o-1/l,p=c/l;return h?(-p+Math.sqrt(p*p-2*h*(c*c/(-2*l)-u+l/2+i-o/2)))/h+r:(r+a)/2;}function Ia(t,e){var n=t.N;if(n)return wa(n,e);var r=t.site;return r[1]===e?r[0]:1/0;}var Na,Sa,Ca,Pa,Ma=1e-6,La=1e-12;function Oa(t,e){return e[1]-t[1]||e[0]-t[0];}function Ra(t,e){var n,r,i,o=t.sort(Oa).pop();for(Pa=[],Sa=new Array(t.length),Na=new $s(),Ca=new $s();;)if(i=pa,o&&(!i||o[1]Ma||Math.abs(i[0][1]-i[1][1])>Ma)||delete Pa[o];}(s,a,u,l),function(t,e,n,r){var i,o,s,a,u,l,c,h,p,f,g,d,y=Sa.length,v=!0;for(i=0;iMa||Math.abs(d-p)>Ma)&&(u.splice(a,0,Pa.push(oa(s,f,Math.abs(g-t)Ma?[t,Math.abs(h-t)Ma?[Math.abs(p-r)Ma?[n,Math.abs(h-n)Ma?[Math.abs(p-e)=-270&&(d=-d),g<-180&&g>=-360&&(y=-y),"degrees"===o){var v=d*Math.cos(h)+y*Math.sin(h),_=y*Math.cos(h)-d*Math.sin(h);d=v,y=_;}p.push([d+c[0],y+c[1]]);}return p.push(p[0]),"degrees"===o?l([p],u):$o(l([p],u),s,{pivot:a});}function Da(t){var e=t*Math.PI/180;return Math.tan(e);}function Fa(t,e){void 0===e&&(e={});var n=0,r=0,i=0;return q(t,function(t,o,s){var a=e.weight?null==s?void 0:s[e.weight]:void 0;if(!C(a=null==a?1:a))throw new Error("weight value must be a number for feature index "+o);(a=Number(a))>0&&R(t,function(t){n+=t[0]*a,r+=t[1]*a,i+=a;});}),a([n/i,r/i],e.properties,e);}function ka(t,e,n,r,i){var o=r.tolerance||.001,s=0,u=0,l=0,c=0;if(F(n,function(e){var n,r=null===(n=e.properties)||void 0===n?void 0:n.weight,i=null==r?1:r;if(!C(i=Number(i)))throw new Error("weight value must be a number");if(i>0){c+=1;var o=i*me(e,t);0===o&&(o=1);var a=i/o;s+=e.geometry.coordinates[0]*a,u+=e.geometry.coordinates[1]*a,l+=a;}}),c<1)throw new Error("no features to measure");var h=s/l,p=u/l;return 1===c||0===i||Math.abs(h-e[0])n&&(n=u,r=o,e.push([]));var l=o-r,c=t.coordinates[u][l+1],h=i[0],p=i[1],f=c[0],g=c[1];e[u].push([.75*h+.25*f,.75*p+.25*g]),e[u].push([.25*h+.75*f,.25*p+.75*g]);},!0),e.forEach(function(t){t.push(t[0]);});}function Ba(t,e){var n=0,r=0,i=0;R(t,function(o,s,a,u,l){u>i&&(i=u,r=s,e.push([[]])),l>n&&(n=l,r=s,e[u].push([]));var c=s-r,h=t.coordinates[u][l][c+1],p=o[0],f=o[1],g=h[0],d=h[1];e[u][l].push([.75*p+.25*g,.75*f+.25*d]),e[u][l].push([.25*p+.75*g,.25*f+.75*d]);},!0),e.forEach(function(t){t.forEach(function(t){t.push(t[0]);});});}function za(t,e,n){void 0===n&&(n=2);var r=K(t),i=K(e),o=r[0]-i[0],s=r[1]-i[1];return 1===n?Math.abs(o)+Math.abs(s):Math.pow(Math.pow(o,n)+Math.pow(s,n),1/n);}function ja(t,e){var n=(e=e||{}).threshold||1e4,r=e.p||2,i=e.binary||!1,o=e.alpha||-1,s=e.standardization||!1,a=[];F(t,function(t){a.push(En(t));});for(var u=[],l=0;l0?1:0;}(t[0]))*e,n*Math.log(Math.tan(.25*Math.PI+.5*t[1]*e))];return i[0]>r&&(i[0]=r),i[0]<-r&&(i[0]=-r),i[1]>r&&(i[1]=r),i[1]<-r&&(i[1]=-r),i;}function Wa(t){var e=180/Math.PI,n=6378137;return[t[0]*e/n,(.5*Math.PI-2*Math.atan(Math.exp(-t[1]/n)))*e];}Ra.prototype={constructor:Ra,polygons:function polygons(){var t=this.edges;return this.cells.map(function(e){var n=e.halfedges.map(function(n){return ca(e,t[n]);});return n.data=e.site.data,n;});},triangles:function triangles(){var t=[],e=this.edges;return this.cells.forEach(function(n,r){if(o=(i=n.halfedges).length)for(var i,o,s,a,u,l,c=n.site,h=-1,p=e[i[o-1]],f=p.left===c?p.right:p.left;++h=a)return null;var u=t-i.site[0],l=e-i.site[1],c=u*u+l*l;do{i=o.cells[r=s],s=null,i.halfedges.forEach(function(n){var r=o.edges[n],a=r.left;if(a!==i.site&&a||(a=r.right)){var u=t-a[0],l=e-a[1],h=u*u+l*l;h0?t+n[e-1]:t;}),o.forEach(function(t){t=2*t*Math.PI/o[o.length-1];var n=Math.random();i.push([n*(e.max_radial_length||10)*Math.sin(t),n*(e.max_radial_length||10)*Math.cos(t)]);}),i[i.length-1]=i[0],i=i.map((r=Ka(e.bbox),function(t){return[t[0]+r[0],t[1]+r[1]];})),n.push(l([i]));},i=0;i * @license MIT * @preserve */function fu(t,e){return t>e?1:t0))break;if(null===e.right)break;if(n(t,e.right.key)>0){a=e.right;if(e.right=a.left,a.left=e,null===(e=a).right)break;}i.right=e,i=e,e=e.right;}}return i.right=e.left,o.left=e.right,e.left=r.right,e.right=r.left,e;}function du(t,e,n,r){var i=new pu(t,e);if(null===n)return i.left=i.right=null,i;var o=r(t,(n=gu(t,n,r)).key);return o<0?(i.left=n.left,i.right=n,n.left=null):o>=0&&(i.right=n.right,i.left=n,n.right=null),i;}function yu(t,e,n){var r=null,i=null;if(e){var o=n((e=gu(t,e,n)).key,t);0===o?(r=e.left,i=e.right):o<0?(i=e.right,e.right=null,r=e):(r=e.left,e.left=null,i=e);}return{left:r,right:i};}function vu(t,e,n,r,i){if(t){r(e+(n?"└── ":"├── ")+i(t)+"\n");var o=e+(n?" ":"│ ");t.left&&vu(t.left,o,!1,r,i),t.right&&vu(t.right,o,!0,r,i);}}var _u=function(){function t(t){void 0===t&&(t=fu),this._root=null,this._size=0,this._comparator=t;}return t.prototype.insert=function(t,e){return this._size++,this._root=du(t,e,this._root,this._comparator);},t.prototype.add=function(t,e){var n=new pu(t,e);null===this._root&&(n.left=n.right=null,this._size++,this._root=n);var r=this._comparator,i=gu(t,this._root,r),o=r(t,i.key);return 0===o?this._root=i:(o<0?(n.left=i.left,n.right=i,i.left=null):o>0&&(n.right=i.right,n.left=i,i.right=null),this._size++,this._root=n),this._root;},t.prototype.remove=function(t){this._root=this._remove(t,this._root,this._comparator);},t.prototype._remove=function(t,e,n){var r;return null===e?null:0===n(t,(e=gu(t,e,n)).key)?(null===e.left?r=e.right:(r=gu(t,e.left,n)).right=e.right,this._size--,r):e;},t.prototype.pop=function(){var t=this._root;if(t){for(;t.left;)t=t.left;return this._root=gu(t.key,this._root,this._comparator),this._root=this._remove(t.key,this._root,this._comparator),{key:t.key,data:t.data};}return null;},t.prototype.findStatic=function(t){for(var e=this._root,n=this._comparator;e;){var r=n(t,e.key);if(0===r)return e;e=r<0?e.left:e.right;}return null;},t.prototype.find=function(t){return this._root&&(this._root=gu(t,this._root,this._comparator),0!==this._comparator(t,this._root.key))?null:this._root;},t.prototype.contains=function(t){for(var e=this._root,n=this._comparator;e;){var r=n(t,e.key);if(0===r)return!0;e=r<0?e.left:e.right;}return!1;},t.prototype.forEach=function(t,e){for(var n=this._root,r=[],i=!1;!i;)null!==n?(r.push(n),n=n.left):0!==r.length?(n=r.pop(),t.call(e,n),n=n.right):i=!0;return this;},t.prototype.range=function(t,e,n,r){for(var i=[],o=this._comparator,s=this._root;0!==i.length||s;)if(s)i.push(s),s=s.left;else{if(o((s=i.pop()).key,e)>0)break;if(o(s.key,t)>=0&&n.call(r,s))return this;s=s.right;}return this;},t.prototype.keys=function(){var t=[];return this.forEach(function(e){var n=e.key;return t.push(n);}),t;},t.prototype.values=function(){var t=[];return this.forEach(function(e){var n=e.data;return t.push(n);}),t;},t.prototype.min=function(){return this._root?this.minNode(this._root).key:null;},t.prototype.max=function(){return this._root?this.maxNode(this._root).key:null;},t.prototype.minNode=function(t){if(void 0===t&&(t=this._root),t)for(;t.left;)t=t.left;return t;},t.prototype.maxNode=function(t){if(void 0===t&&(t=this._root),t)for(;t.right;)t=t.right;return t;},t.prototype.at=function(t){for(var e=this._root,n=!1,r=0,i=[];!n;)if(e)i.push(e),e=e.left;else if(i.length>0){if(e=i.pop(),r===t)return e;r++,e=e.right;}else n=!0;return null;},t.prototype.next=function(t){var e=this._root,n=null;if(t.right){for(n=t.right;n.left;)n=n.left;return n;}for(var r=this._comparator;e;){var i=r(t.key,e.key);if(0===i)break;i<0?(n=e,e=e.left):e=e.right;}return n;},t.prototype.prev=function(t){var e=this._root,n=null;if(null!==t.left){for(n=t.left;n.right;)n=n.right;return n;}for(var r=this._comparator;e;){var i=r(t.key,e.key);if(0===i)break;i<0?e=e.left:(n=e,e=e.right);}return n;},t.prototype.clear=function(){return this._root=null,this._size=0,this;},t.prototype.toList=function(){return function(t){var e=t,n=[],r=!1,i=new pu(null,null),o=i;for(;!r;)e?(n.push(e),e=e.left):n.length>0?e=(e=o=o.next=n.pop()).right:r=!0;return o.next=null,i.next;}(this._root);},t.prototype.load=function(t,e,n){void 0===e&&(e=[]),void 0===n&&(n=!1);var r=t.length,i=this._comparator;if(n&&Eu(t,e,0,r-1,i),null===this._root)this._root=mu(t,e,0,r),this._size=r;else{var o=function(t,e,n){var r=new pu(null,null),i=r,o=t,s=e;for(;null!==o&&null!==s;)n(o.key,s.key)<0?(i.next=o,o=o.next):(i.next=s,s=s.next),i=i.next;null!==o?i.next=o:null!==s&&(i.next=s);return r.next;}(this.toList(),function(t,e){for(var n=new pu(null,null),r=n,i=0;i0){var o=n+Math.floor(i/2),s=t[o],a=e[o],u=new pu(s,a);return u.left=mu(t,e,n,o),u.right=mu(t,e,o+1,r),u;}return null;}function xu(t,e,n){var r=n-e;if(r>0){var i=e+Math.floor(r/2),o=xu(t,e,i),s=t.head;return s.left=o,t.head=t.head.next,s.right=xu(t,i+1,n),s;}return null;}function Eu(t,e,n,r,i){if(!(n>=r)){for(var o=t[n+r>>1],s=n-1,a=r+1;;){do{s++;}while(i(t[s],o)<0);do{a--;}while(i(t[a],o)>0);if(s>=a)break;var u=t[s];t[s]=t[a],t[a]=u,u=e[s],e[s]=e[a],e[a]=u;}Eu(t,e,n,a,i),Eu(t,e,a+1,r,i);}}function bu(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function");}function wu(t,e){for(var n=0;ne.x?1:t.ye.y?1:0;}}]),Iu(t,[{key:"link",value:function value(t){if(t.point===this.point)throw new Error("Tried to link already linked events");for(var e=t.point.events,n=0,r=e.length;n=0&&u>=0?sl?-1:0:o<0&&u<0?sl?1:0:uo?1:0;};}}]),t;}(),zu=0,ju=function(){function t(e,n,r,i){bu(this,t),this.id=++zu,this.leftSE=e,e.segment=this,e.otherSE=n,this.rightSE=n,n.segment=this,n.otherSE=e,this.rings=r,this.windings=i;}return Iu(t,null,[{key:"compare",value:function value(t,e){var n=t.leftSE.point.x,r=e.leftSE.point.x,i=t.rightSE.point.x,o=e.rightSE.point.x;if(os&&a>u)return-1;var c=t.comparePoint(e.leftSE.point);if(c<0)return 1;if(c>0)return-1;var h=e.comparePoint(t.rightSE.point);return 0!==h?h:-1;}if(n>r){if(sa&&s>l)return 1;var p=e.comparePoint(t.leftSE.point);if(0!==p)return p;var f=t.comparePoint(e.rightSE.point);return f<0?1:f>0?-1:1;}if(sa)return 1;if(io){var d=t.comparePoint(e.rightSE.point);if(d<0)return 1;if(d>0)return-1;}if(i!==o){var y=u-s,v=i-n,_=l-a,m=o-r;if(y>v&&_m)return-1;}return i>o?1:il?1:t.ide.id?1:0;}}]),Iu(t,[{key:"replaceRightSE",value:function value(t){this.rightSE=t,this.rightSE.segment=this,this.rightSE.otherSE=this.leftSE,this.leftSE.otherSE=this.rightSE;}},{key:"bbox",value:function value(){var t=this.leftSE.point.y,e=this.rightSE.point.y;return{ll:{x:this.leftSE.point.x,y:te?t:e}};}},{key:"vector",value:function value(){return{x:this.rightSE.point.x-this.leftSE.point.x,y:this.rightSE.point.y-this.leftSE.point.y};}},{key:"isAnEndpoint",value:function value(t){return t.x===this.leftSE.point.x&&t.y===this.leftSE.point.y||t.x===this.rightSE.point.x&&t.y===this.rightSE.point.y;}},{key:"comparePoint",value:function value(t){if(this.isAnEndpoint(t))return 0;var e=this.leftSE.point,n=this.rightSE.point,r=this.vector();if(e.x===n.x)return t.x===e.x?0:t.x0&&a.swapEvents(),Bu.comparePoints(this.leftSE.point,this.rightSE.point)>0&&this.swapEvents(),r&&(i.checkForConsuming(),o.checkForConsuming()),n;}},{key:"swapEvents",value:function value(){var t=this.rightSE;this.rightSE=this.leftSE,this.leftSE=t,this.leftSE.isLeft=!0,this.rightSE.isLeft=!1;for(var e=0,n=this.windings.length;e0){var o=n;n=r,r=o;}if(n.prev===r){var s=n;n=r,r=s;}for(var a=0,u=r.rings.length;a0))throw new Error("Tried to create degenerate segment at [".concat(e.x,", ").concat(e.y,"]"));i=n,o=e,s=-1;}return new t(new Bu(i,!0),new Bu(o,!1),[r],[s]);}}]),t;}(),Uu=function(){function t(e,n,r){if(bu(this,t),!Array.isArray(e)||0===e.length)throw new Error("Input geometry is not a valid Polygon or MultiPolygon");if(this.poly=n,this.isExterior=r,this.segments=[],"number"!=typeof e[0][0]||"number"!=typeof e[0][1])throw new Error("Input geometry is not a valid Polygon or MultiPolygon");var i=Ru.round(e[0][0],e[0][1]);this.bbox={ll:{x:i.x,y:i.y},ur:{x:i.x,y:i.y}};for(var o=i,s=1,a=e.length;sthis.bbox.ur.x&&(this.bbox.ur.x=u.x),u.y>this.bbox.ur.y&&(this.bbox.ur.y=u.y),o=u);}i.x===o.x&&i.y===o.y||this.segments.push(ju.fromRing(o,i,this));}return Iu(t,[{key:"getSweepEvents",value:function value(){for(var t=[],e=0,n=this.segments.length;ethis.bbox.ur.x&&(this.bbox.ur.x=o.bbox.ur.x),o.bbox.ur.y>this.bbox.ur.y&&(this.bbox.ur.y=o.bbox.ur.y),this.interiorRings.push(o);}this.multiPoly=n;}return Iu(t,[{key:"getSweepEvents",value:function value(){for(var t=this.exteriorRing.getSweepEvents(),e=0,n=this.interiorRings.length;ethis.bbox.ur.x&&(this.bbox.ur.x=o.bbox.ur.x),o.bbox.ur.y>this.bbox.ur.y&&(this.bbox.ur.y=o.bbox.ur.y),this.polys.push(o);}this.isSubject=n;}return Iu(t,[{key:"getSweepEvents",value:function value(){for(var t=[],e=0,n=this.polys.length;e0&&(t=r);}for(var i=t.segment.prevInResult(),o=i?i.prevInResult():null;;){if(!i)return null;if(!o)return i.ringOut;if(o.ringOut!==i.ringOut)return o.ringOut.enclosingRing()!==i.ringOut?i.ringOut:i.ringOut.enclosingRing();i=o.prevInResult(),o=i?i.prevInResult():null;}}}]),t;}(),Hu=function(){function t(e){bu(this,t),this.exteriorRing=e,e.poly=this,this.interiorRings=[];}return Iu(t,[{key:"addInterior",value:function value(t){this.interiorRings.push(t),t.poly=this;}},{key:"getGeom",value:function value(){var t=[this.exteriorRing.getGeom()];if(null===t[0])return null;for(var e=0,n=this.interiorRings.length;e1&&void 0!==arguments[1]?arguments[1]:ju.compare;bu(this,t),this.queue=e,this.tree=new _u(n),this.segments=[];}return Iu(t,[{key:"process",value:function value(t){var e=t.segment,n=[];if(t.consumedBy)return t.isLeft?this.queue.remove(t.otherSE):this.tree.remove(e),n;var r=t.isLeft?this.tree.insert(e):this.tree.find(e);if(!r)throw new Error("Unable to find segment #".concat(e.id," ")+"[".concat(e.leftSE.point.x,", ").concat(e.leftSE.point.y,"] -> ")+"[".concat(e.rightSE.point.x,", ").concat(e.rightSE.point.y,"] ")+"in SweepLine tree. Please submit a bug report.");for(var i=r,o=r,s=void 0,a=void 0;void 0===s;)null===(i=this.tree.prev(i))?s=null:void 0===i.key.consumedBy&&(s=i.key);for(;void 0===a;)null===(o=this.tree.next(o))?a=null:void 0===o.key.consumedBy&&(a=o.key);if(t.isLeft){var u=null;if(s){var l=s.getIntersection(e);if(null!==l&&(e.isAnEndpoint(l)||(u=l),!s.isAnEndpoint(l)))for(var c=this._splitSafely(s,l),h=0,p=c.length;h0?(this.tree.remove(e),n.push(t)):(this.segments.push(e),e.prev=s);}else{if(s&&a){var b=s.getIntersection(a);if(null!==b){if(!s.isAnEndpoint(b))for(var w=this._splitSafely(s,b),I=0,N=w.length;IZu)throw new Error("Infinite loop when putting segment endpoints in a priority queue (queue size too big). Please file a bug report.");for(var m=new Ju(f),x=f.size,E=f.pop();E;){var b=E.key;if(f.size===x){var w=b.segment;throw new Error("Unable to pop() ".concat(b.isLeft?"left":"right"," SweepEvent ")+"[".concat(b.point.x,", ").concat(b.point.y,"] from segment #").concat(w.id," ")+"[".concat(w.leftSE.point.x,", ").concat(w.leftSE.point.y,"] -> ")+"[".concat(w.rightSE.point.x,", ").concat(w.rightSE.point.y,"] from queue. ")+"Please file a bug report.");}if(f.size>Zu)throw new Error("Infinite loop when passing sweep line over endpoints (queue size too big). Please file a bug report.");if(m.segments.length>Ku)throw new Error("Infinite loop when passing sweep line over endpoints (too many sweep line segments). Please file a bug report.");for(var I=m.process(b),N=0,S=I.length;N1?e-1:0),r=1;r1?e-1:0),r=1;r1?e-1:0),r=1;r1?e-1:0),r=1;re.x?1:this.ye.y?1:0;},ul.prototype.clone=function(){},ul.prototype.copy=function(){return new ul(this);},ul.prototype.toString=function(){return"("+this.x+", "+this.y+", "+this.z+")";},ul.prototype.distance3D=function(t){var e=this.x-t.x,n=this.y-t.y,r=this.z-t.z;return Math.sqrt(e*e+n*n+r*r);},ul.prototype.distance=function(t){var e=this.x-t.x,n=this.y-t.y;return Math.sqrt(e*e+n*n);},ul.prototype.hashCode=function(){var t=17;return t=37*(t=37*t+ul.hashCode(this.x))+ul.hashCode(this.y);},ul.prototype.setCoordinate=function(t){this.x=t.x,this.y=t.y,this.z=t.z;},ul.prototype.interfaces_=function(){return[il,ol,al];},ul.prototype.getClass=function(){return ul;},ul.hashCode=function(){if(1===arguments.length){var t=arguments[0],e=nl.doubleToLongBits(t);return Math.trunc((e^e)>>>32);}},ll.DimensionalComparator.get=function(){return cl;},ll.serialVersionUID.get=function(){return 0x5cbf2c235c7e5800;},ll.NULL_ORDINATE.get=function(){return nl.NaN;},ll.X.get=function(){return 0;},ll.Y.get=function(){return 1;},ll.Z.get=function(){return 2;},Object.defineProperties(ul,ll);var cl=function cl(t){if(this._dimensionsToTest=2,0===arguments.length);else if(1===arguments.length){var e=arguments[0];if(2!==e&&3!==e)throw new el("only 2 or 3 dimensions may be specified");this._dimensionsToTest=e;}};cl.prototype.compare=function(t,e){var n=t,r=e,i=cl.compare(n.x,r.x);if(0!==i)return i;var o=cl.compare(n.y,r.y);return 0!==o?o:this._dimensionsToTest<=2?0:cl.compare(n.z,r.z);},cl.prototype.interfaces_=function(){return[sl];},cl.prototype.getClass=function(){return cl;},cl.compare=function(t,e){return te?1:nl.isNaN(t)?nl.isNaN(e)?0:-1:nl.isNaN(e)?1:0;};var hl=function hl(){};hl.prototype.create=function(){},hl.prototype.interfaces_=function(){return[];},hl.prototype.getClass=function(){return hl;};var pl=function pl(){},fl={INTERIOR:{configurable:!0},BOUNDARY:{configurable:!0},EXTERIOR:{configurable:!0},NONE:{configurable:!0}};pl.prototype.interfaces_=function(){return[];},pl.prototype.getClass=function(){return pl;},pl.toLocationSymbol=function(t){switch(t){case pl.EXTERIOR:return"e";case pl.BOUNDARY:return"b";case pl.INTERIOR:return"i";case pl.NONE:return"-";}throw new el("Unknown location value: "+t);},fl.INTERIOR.get=function(){return 0;},fl.BOUNDARY.get=function(){return 1;},fl.EXTERIOR.get=function(){return 2;},fl.NONE.get=function(){return-1;},Object.defineProperties(pl,fl);var gl=function gl(t,e){return t.interfaces_&&t.interfaces_().indexOf(e)>-1;},dl=function dl(){},yl={LOG_10:{configurable:!0}};dl.prototype.interfaces_=function(){return[];},dl.prototype.getClass=function(){return dl;},dl.log10=function(t){var e=Math.log(t);return nl.isInfinite(e)||nl.isNaN(e)?e:e/dl.LOG_10;},dl.min=function(t,e,n,r){var i=t;return en?n:t;}if(Number.isInteger(arguments[2])&&Number.isInteger(arguments[0])&&Number.isInteger(arguments[1])){var r=arguments[0],i=arguments[1],o=arguments[2];return ro?o:r;}},dl.wrap=function(t,e){return t<0?e- -t%e:t%e;},dl.max=function(){if(3===arguments.length){var t=arguments[0],e=arguments[1],n=arguments[2],r=t;return e>r&&(r=e),n>r&&(r=n),r;}if(4===arguments.length){var i=arguments[0],o=arguments[1],s=arguments[2],a=arguments[3],u=i;return o>u&&(u=o),s>u&&(u=s),a>u&&(u=a),u;}},dl.average=function(t,e){return(t+e)/2;},yl.LOG_10.get=function(){return Math.log(10);},Object.defineProperties(dl,yl);var vl=function vl(t){this.str=t;};vl.prototype.append=function(t){this.str+=t;},vl.prototype.setCharAt=function(t,e){this.str=this.str.substr(0,t)+e+this.str.substr(t+1);},vl.prototype.toString=function(t){return this.str;};var _l=function _l(t){this.value=t;};_l.prototype.intValue=function(){return this.value;},_l.prototype.compareTo=function(t){return this.valuet?1:0;},_l.isNaN=function(t){return Number.isNaN(t);};var ml=function ml(){};ml.isWhitespace=function(t){return t<=32&&t>=0||127===t;},ml.toUpperCase=function(t){return t.toUpperCase();};var xl=function t(){if(this._hi=0,this._lo=0,0===arguments.length)this.init(0);else if(1===arguments.length){if("number"==typeof arguments[0]){var e=arguments[0];this.init(e);}else if(arguments[0]instanceof t){var n=arguments[0];this.init(n);}else if("string"==typeof arguments[0]){var r=arguments[0];t.call(this,t.parse(r));}}else if(2===arguments.length){var i=arguments[0],o=arguments[1];this.init(i,o);}},El={PI:{configurable:!0},TWO_PI:{configurable:!0},PI_2:{configurable:!0},E:{configurable:!0},NaN:{configurable:!0},EPS:{configurable:!0},SPLIT:{configurable:!0},MAX_PRINT_DIGITS:{configurable:!0},TEN:{configurable:!0},ONE:{configurable:!0},SCI_NOT_EXPONENT_CHAR:{configurable:!0},SCI_NOT_ZERO:{configurable:!0}};xl.prototype.le=function(t){return(this._hi9?(c=!0,h="9"):h="0"+l,s.append(h),n=n.subtract(xl.valueOf(l)).multiply(xl.TEN),c&&n.selfAdd(xl.TEN);var p=!0,f=xl.magnitude(n._hi);if(f<0&&Math.abs(f)>=a-u&&(p=!1),!p)break;}return e[0]=r,s.toString();},xl.prototype.sqr=function(){return this.multiply(this);},xl.prototype.doubleValue=function(){return this._hi+this._lo;},xl.prototype.subtract=function(){if(arguments[0]instanceof xl){var t=arguments[0];return this.add(t.negate());}if("number"==typeof arguments[0]){var e=arguments[0];return this.add(-e);}},xl.prototype.equals=function(){if(1===arguments.length){var t=arguments[0];return this._hi===t._hi&&this._lo===t._lo;}},xl.prototype.isZero=function(){return 0===this._hi&&0===this._lo;},xl.prototype.selfSubtract=function(){if(arguments[0]instanceof xl){var t=arguments[0];return this.isNaN()?this:this.selfAdd(-t._hi,-t._lo);}if("number"==typeof arguments[0]){var e=arguments[0];return this.isNaN()?this:this.selfAdd(-e,0);}},xl.prototype.getSpecialNumberString=function(){return this.isZero()?"0.0":this.isNaN()?"NaN ":null;},xl.prototype.min=function(t){return this.le(t)?this:t;},xl.prototype.selfDivide=function(){if(1===arguments.length){if(arguments[0]instanceof xl){var t=arguments[0];return this.selfDivide(t._hi,t._lo);}if("number"==typeof arguments[0]){var e=arguments[0];return this.selfDivide(e,0);}}else if(2===arguments.length){var n=arguments[0],r=arguments[1],i=null,o=null,s=null,a=null,u=null,l=null,c=null,h=null;return u=this._hi/n,h=(i=(l=xl.SPLIT*u)-(i=l-u))*(s=(h=xl.SPLIT*n)-(s=h-n))-(c=u*n)+i*(a=n-s)+(o=u-i)*s+o*a,h=u+(l=(this._hi-c-h+this._lo-u*r)/n),this._hi=h,this._lo=u-h+l,this;}},xl.prototype.dump=function(){return"DD<"+this._hi+", "+this._lo+">";},xl.prototype.divide=function(){if(arguments[0]instanceof xl){var t=arguments[0],e=null,n=null,r=null,i=null,o=null,s=null,a=null,u=null;n=(o=this._hi/t._hi)-(e=(s=xl.SPLIT*o)-(e=s-o)),u=e*(r=(u=xl.SPLIT*t._hi)-(r=u-t._hi))-(a=o*t._hi)+e*(i=t._hi-r)+n*r+n*i;var l=u=o+(s=(this._hi-a-u+this._lo-o*t._lo)/t._hi),c=o-u+s;return new xl(l,c);}if("number"==typeof arguments[0]){var h=arguments[0];return nl.isNaN(h)?xl.createNaN():xl.copy(this).selfDivide(h,0);}},xl.prototype.ge=function(t){return(this._hi>t._hi||this._hi===t._hi)&&this._lo>=t._lo;},xl.prototype.pow=function(t){if(0===t)return xl.valueOf(1);var e=new xl(this),n=xl.valueOf(1),r=Math.abs(t);if(r>1)for(;r>0;)r%2==1&&n.selfMultiply(e),(r/=2)>0&&(e=e.sqr());else n=e;return t<0?n.reciprocal():n;},xl.prototype.ceil=function(){if(this.isNaN())return xl.NaN;var t=Math.ceil(this._hi),e=0;return t===this._hi&&(e=Math.ceil(this._lo)),new xl(t,e);},xl.prototype.compareTo=function(t){var e=t;return this._hie._hi?1:this._loe._lo?1:0;},xl.prototype.rint=function(){return this.isNaN()?this:this.add(.5).floor();},xl.prototype.setValue=function(){if(arguments[0]instanceof xl){var t=arguments[0];return this.init(t),this;}if("number"==typeof arguments[0]){var e=arguments[0];return this.init(e),this;}},xl.prototype.max=function(t){return this.ge(t)?this:t;},xl.prototype.sqrt=function(){if(this.isZero())return xl.valueOf(0);if(this.isNegative())return xl.NaN;var t=1/Math.sqrt(this._hi),e=this._hi*t,n=xl.valueOf(e),r=this.subtract(n.sqr())._hi*(.5*t);return n.add(r);},xl.prototype.selfAdd=function(){if(1===arguments.length){if(arguments[0]instanceof xl){var t=arguments[0];return this.selfAdd(t._hi,t._lo);}if("number"==typeof arguments[0]){var e=arguments[0],n=null,r=null,i=null,o=null,s=null,a=null;return o=(i=this._hi+e)-(s=i-this._hi),r=(a=(o=e-s+(this._hi-o))+this._lo)+(i-(n=i+a)),this._hi=n+r,this._lo=r+(n-this._hi),this;}}else if(2===arguments.length){var u=arguments[0],l=arguments[1],c=null,h=null,p=null,f=null,g=null,d=null,y=null;f=this._hi+u,h=this._lo+l,g=f-(d=f-this._hi),p=h-(y=h-this._lo);var v=(c=f+(d=(g=u-d+(this._hi-g))+h))+(d=(p=l-y+(this._lo-p))+(d+(f-c))),_=d+(c-v);return this._hi=v,this._lo=_,this;}},xl.prototype.selfMultiply=function(){if(1===arguments.length){if(arguments[0]instanceof xl){var t=arguments[0];return this.selfMultiply(t._hi,t._lo);}if("number"==typeof arguments[0]){var e=arguments[0];return this.selfMultiply(e,0);}}else if(2===arguments.length){var n=arguments[0],r=arguments[1],i=null,o=null,s=null,a=null,u=null,l=null;i=(u=xl.SPLIT*this._hi)-this._hi,l=xl.SPLIT*n,i=u-i,o=this._hi-i,s=l-n;var c=(u=this._hi*n)+(l=i*(s=l-s)-u+i*(a=n-s)+o*s+o*a+(this._hi*r+this._lo*n)),h=l+(i=u-c);return this._hi=c,this._lo=h,this;}},xl.prototype.selfSqr=function(){return this.selfMultiply(this);},xl.prototype.floor=function(){if(this.isNaN())return xl.NaN;var t=Math.floor(this._hi),e=0;return t===this._hi&&(e=Math.floor(this._lo)),new xl(t,e);},xl.prototype.negate=function(){return this.isNaN()?this:new xl(-this._hi,-this._lo);},xl.prototype.clone=function(){},xl.prototype.multiply=function(){if(arguments[0]instanceof xl){var t=arguments[0];return t.isNaN()?xl.createNaN():xl.copy(this).selfMultiply(t);}if("number"==typeof arguments[0]){var e=arguments[0];return nl.isNaN(e)?xl.createNaN():xl.copy(this).selfMultiply(e,0);}},xl.prototype.isNaN=function(){return nl.isNaN(this._hi);},xl.prototype.intValue=function(){return Math.trunc(this._hi);},xl.prototype.toString=function(){var t=xl.magnitude(this._hi);return t>=-3&&t<=20?this.toStandardNotation():this.toSciNotation();},xl.prototype.toStandardNotation=function(){var t=this.getSpecialNumberString();if(null!==t)return t;var e=new Array(1).fill(null),n=this.extractSignificantDigits(!0,e),r=e[0]+1,i=n;if("."===n.charAt(0))i="0"+n;else if(r<0)i="0."+xl.stringOfChar("0",-r)+n;else if(-1===n.indexOf(".")){var o=r-n.length;i=n+xl.stringOfChar("0",o)+".0";}return this.isNegative()?"-"+i:i;},xl.prototype.reciprocal=function(){var t,e,n,r,i=null,o=null,s=null,a=null;t=(n=1/this._hi)-(i=(s=xl.SPLIT*n)-(i=s-n)),o=(a=xl.SPLIT*this._hi)-this._hi;var u=n+(s=(1-(r=n*this._hi)-(a=i*(o=a-o)-r+i*(e=this._hi-o)+t*o+t*e)-n*this._lo)/this._hi);return new xl(u,n-u+s);},xl.prototype.toSciNotation=function(){if(this.isZero())return xl.SCI_NOT_ZERO;var t=this.getSpecialNumberString();if(null!==t)return t;var e=new Array(1).fill(null),n=this.extractSignificantDigits(!1,e),r=xl.SCI_NOT_EXPONENT_CHAR+e[0];if("0"===n.charAt(0))throw new Error("Found leading zero: "+n);var i="";n.length>1&&(i=n.substring(1));var o=n.charAt(0)+"."+i;return this.isNegative()?"-"+o+r:o+r;},xl.prototype.abs=function(){return this.isNaN()?xl.NaN:this.isNegative()?this.negate():new xl(this);},xl.prototype.isPositive=function(){return(this._hi>0||0===this._hi)&&this._lo>0;},xl.prototype.lt=function(t){return(this._hit._hi||this._hi===t._hi)&&this._lo>t._lo;},xl.prototype.isNegative=function(){return(this._hi<0||0===this._hi)&&this._lo<0;},xl.prototype.trunc=function(){return this.isNaN()?xl.NaN:this.isPositive()?this.floor():this.ceil();},xl.prototype.signum=function(){return this._hi>0?1:this._hi<0?-1:this._lo>0?1:this._lo<0?-1:0;},xl.prototype.interfaces_=function(){return[al,il,ol];},xl.prototype.getClass=function(){return xl;},xl.sqr=function(t){return xl.valueOf(t).selfMultiply(t);},xl.valueOf=function(){if("string"==typeof arguments[0]){var t=arguments[0];return xl.parse(t);}if("number"==typeof arguments[0]){var e=arguments[0];return new xl(e);}},xl.sqrt=function(t){return xl.valueOf(t).sqrt();},xl.parse=function(t){for(var e=0,n=t.length;ml.isWhitespace(t.charAt(e));)e++;var r=!1;if(e=n);){var l=t.charAt(e);if(e++,ml.isDigit(l)){var c=l-"0";o.selfMultiply(xl.TEN),o.selfAdd(c),s++;}else{if("."!==l){if("e"===l||"E"===l){var h=t.substring(e);try{u=_l.parseInt(h);}catch(e){throw e instanceof Error?new Error("Invalid exponent "+h+" in string "+t):e;}break;}throw new Error("Unexpected character '"+l+"' at position "+e+" in string "+t);}a=s;}}var p=o,f=s-a-u;if(0===f)p=o;else if(f>0){var g=xl.TEN.pow(f);p=o.divide(g);}else if(f<0){var d=xl.TEN.pow(-f);p=o.multiply(d);}return r?p.negate():p;},xl.createNaN=function(){return new xl(nl.NaN,nl.NaN);},xl.copy=function(t){return new xl(t);},xl.magnitude=function(t){var e=Math.abs(t),n=Math.log(e)/Math.log(10),r=Math.trunc(Math.floor(n));return 10*Math.pow(10,r)<=e&&(r+=1),r;},xl.stringOfChar=function(t,e){for(var n=new vl(),r=0;r0){if(o<=0)return bl.signum(s);r=i+o;}else{if(!(i<0))return bl.signum(s);if(o>=0)return bl.signum(s);r=-i-o;}var a=bl.DP_SAFE_EPSILON*r;return s>=a||-s>=a?bl.signum(s):2;},bl.signum=function(t){return t>0?1:t<0?-1:0;},wl.DP_SAFE_EPSILON.get=function(){return 1e-15;},Object.defineProperties(bl,wl);var Il=function Il(){},Nl={X:{configurable:!0},Y:{configurable:!0},Z:{configurable:!0},M:{configurable:!0}};Nl.X.get=function(){return 0;},Nl.Y.get=function(){return 1;},Nl.Z.get=function(){return 2;},Nl.M.get=function(){return 3;},Il.prototype.setOrdinate=function(t,e,n){},Il.prototype.size=function(){},Il.prototype.getOrdinate=function(t,e){},Il.prototype.getCoordinate=function(){},Il.prototype.getCoordinateCopy=function(t){},Il.prototype.getDimension=function(){},Il.prototype.getX=function(t){},Il.prototype.clone=function(){},Il.prototype.expandEnvelope=function(t){},Il.prototype.copy=function(){},Il.prototype.getY=function(t){},Il.prototype.toCoordinateArray=function(){},Il.prototype.interfaces_=function(){return[ol];},Il.prototype.getClass=function(){return Il;},Object.defineProperties(Il,Nl);var Sl=function Sl(){},Cl=function(t){function e(){t.call(this,"Projective point not representable on the Cartesian plane.");}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.interfaces_=function(){return[];},e.prototype.getClass=function(){return e;},e;}(Sl),Pl=function Pl(){};Pl.arraycopy=function(t,e,n,r,i){for(var o=0,s=e;st._minx?this._minx:t._minx,n=this._miny>t._miny?this._miny:t._miny,r=this._maxx=this._minx&&e.getMaxX()<=this._maxx&&e.getMinY()>=this._miny&&e.getMaxY()<=this._maxy;}}else if(2===arguments.length){var n=arguments[0],r=arguments[1];return!this.isNull()&&n>=this._minx&&n<=this._maxx&&r>=this._miny&&r<=this._maxy;}},Ll.prototype.intersects=function(){if(1===arguments.length){if(arguments[0]instanceof Ll){var t=arguments[0];return!this.isNull()&&!t.isNull()&&!(t._minx>this._maxx||t._maxxthis._maxy||t._maxythis._maxx||nthis._maxy||rthis._maxx&&(this._maxx=e._maxx),e._minythis._maxy&&(this._maxy=e._maxy));}}else if(2===arguments.length){var n=arguments[0],r=arguments[1];this.isNull()?(this._minx=n,this._maxx=n,this._miny=r,this._maxy=r):(nthis._maxx&&(this._maxx=n),rthis._maxy&&(this._maxy=r));}},Ll.prototype.minExtent=function(){if(this.isNull())return 0;var t=this.getWidth(),e=this.getHeight();return te._minx?1:this._minye._miny?1:this._maxxe._maxx?1:this._maxye._maxy?1:0;},Ll.prototype.translate=function(t,e){if(this.isNull())return null;this.init(this.getMinX()+t,this.getMaxX()+t,this.getMinY()+e,this.getMaxY()+e);},Ll.prototype.toString=function(){return"Env["+this._minx+" : "+this._maxx+", "+this._miny+" : "+this._maxy+"]";},Ll.prototype.setToNull=function(){this._minx=0,this._maxx=-1,this._miny=0,this._maxy=-1;},Ll.prototype.getHeight=function(){return this.isNull()?0:this._maxy-this._miny;},Ll.prototype.maxExtent=function(){if(this.isNull())return 0;var t=this.getWidth(),e=this.getHeight();return t>e?t:e;},Ll.prototype.expandBy=function(){if(1===arguments.length){var t=arguments[0];this.expandBy(t,t);}else if(2===arguments.length){var e=arguments[0],n=arguments[1];if(this.isNull())return null;this._minx-=e,this._maxx+=e,this._miny-=n,this._maxy+=n,(this._minx>this._maxx||this._miny>this._maxy)&&this.setToNull();}},Ll.prototype.contains=function(){if(1===arguments.length){if(arguments[0]instanceof Ll){var t=arguments[0];return this.covers(t);}if(arguments[0]instanceof ul){var e=arguments[0];return this.covers(e);}}else if(2===arguments.length){var n=arguments[0],r=arguments[1];return this.covers(n,r);}},Ll.prototype.centre=function(){return this.isNull()?null:new ul((this.getMinX()+this.getMaxX())/2,(this.getMinY()+this.getMaxY())/2);},Ll.prototype.init=function(){if(0===arguments.length)this.setToNull();else if(1===arguments.length){if(arguments[0]instanceof ul){var t=arguments[0];this.init(t.x,t.x,t.y,t.y);}else if(arguments[0]instanceof Ll){var e=arguments[0];this._minx=e._minx,this._maxx=e._maxx,this._miny=e._miny,this._maxy=e._maxy;}}else if(2===arguments.length){var n=arguments[0],r=arguments[1];this.init(n.x,r.x,n.y,r.y);}else if(4===arguments.length){var i=arguments[0],o=arguments[1],s=arguments[2],a=arguments[3];it._maxx&&(e=this._minx-t._maxx);var n=0;return this._maxyt._maxy&&(n=this._miny-t._maxy),0===e?n:0===n?e:Math.sqrt(e*e+n*n);},Ll.prototype.hashCode=function(){var t=17;return t=37*(t=37*(t=37*(t=37*t+ul.hashCode(this._minx))+ul.hashCode(this._maxx))+ul.hashCode(this._miny))+ul.hashCode(this._maxy);},Ll.prototype.interfaces_=function(){return[il,al];},Ll.prototype.getClass=function(){return Ll;},Ll.intersects=function(){if(3===arguments.length){var t=arguments[0],e=arguments[1],n=arguments[2];return n.x>=(t.xe.x?t.x:e.x)&&n.y>=(t.ye.y?t.y:e.y);}if(4===arguments.length){var r=arguments[0],i=arguments[1],o=arguments[2],s=arguments[3],a=Math.min(o.x,s.x),u=Math.max(o.x,s.x),l=Math.min(r.x,i.x),c=Math.max(r.x,i.x);return!(l>u)&&!(cu)&&!(cn?(this._intLineIndex[t][0]=0,this._intLineIndex[t][1]=1):(this._intLineIndex[t][0]=1,this._intLineIndex[t][1]=0);}},Bl.prototype.isProper=function(){return this.hasIntersection()&&this._isProper;},Bl.prototype.setPrecisionModel=function(t){this._precisionModel=t;},Bl.prototype.isInteriorIntersection=function(){var t=this;if(0===arguments.length)return!!this.isInteriorIntersection(0)||!!this.isInteriorIntersection(1);if(1===arguments.length){for(var e=arguments[0],n=0;ni?r:i;else{var s=Math.abs(t.x-e.x),a=Math.abs(t.y-e.y);0!==(o=r>i?s:a)||t.equals(e)||(o=Math.max(s,a));}return ql.isTrue(!(0===o&&!t.equals(e)),"Bad distance calculation"),o;},Bl.nonRobustComputeEdgeDistance=function(t,e,n){var r=t.x-e.x,i=t.y-e.y,o=Math.sqrt(r*r+i*i);return ql.isTrue(!(0===o&&!t.equals(e)),"Invalid distance calculation"),o;},zl.DONT_INTERSECT.get=function(){return 0;},zl.DO_INTERSECT.get=function(){return 1;},zl.COLLINEAR.get=function(){return 2;},zl.NO_INTERSECTION.get=function(){return 0;},zl.POINT_INTERSECTION.get=function(){return 1;},zl.COLLINEAR_INTERSECTION.get=function(){return 2;},Object.defineProperties(Bl,zl);var jl=function(t){function e(){t.apply(this,arguments);}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.isInSegmentEnvelopes=function(t){var e=new Ll(this._inputLines[0][0],this._inputLines[0][1]),n=new Ll(this._inputLines[1][0],this._inputLines[1][1]);return e.contains(t)&&n.contains(t);},e.prototype.computeIntersection=function(){if(3!==arguments.length)return t.prototype.computeIntersection.apply(this,arguments);var e=arguments[0],n=arguments[1],r=arguments[2];if(this._isProper=!1,Ll.intersects(n,r,e)&&0===Xl.orientationIndex(n,r,e)&&0===Xl.orientationIndex(r,n,e))return this._isProper=!0,(e.equals(n)||e.equals(r))&&(this._isProper=!1),this._result=t.POINT_INTERSECTION,null;this._result=t.NO_INTERSECTION;},e.prototype.normalizeToMinimum=function(t,e,n,r,i){i.x=this.smallestInAbsValue(t.x,e.x,n.x,r.x),i.y=this.smallestInAbsValue(t.y,e.y,n.y,r.y),t.x-=i.x,t.y-=i.y,e.x-=i.x,e.y-=i.y,n.x-=i.x,n.y-=i.y,r.x-=i.x,r.y-=i.y;},e.prototype.safeHCoordinateIntersection=function(t,n,r,i){var o=null;try{o=Ml.intersection(t,n,r,i);}catch(s){if(!(s instanceof Cl))throw s;o=e.nearestEndpoint(t,n,r,i);}return o;},e.prototype.intersection=function(t,n,r,i){var o=this.intersectionWithNormalization(t,n,r,i);return this.isInSegmentEnvelopes(o)||(o=new ul(e.nearestEndpoint(t,n,r,i))),null!==this._precisionModel&&this._precisionModel.makePrecise(o),o;},e.prototype.smallestInAbsValue=function(t,e,n,r){var i=t,o=Math.abs(i);return Math.abs(e)1e-4&&Pl.out.println("Distance = "+i.distance(o));},e.prototype.intersectionWithNormalization=function(t,e,n,r){var i=new ul(t),o=new ul(e),s=new ul(n),a=new ul(r),u=new ul();this.normalizeToEnvCentre(i,o,s,a,u);var l=this.safeHCoordinateIntersection(i,o,s,a);return l.x+=u.x,l.y+=u.y,l;},e.prototype.computeCollinearIntersection=function(e,n,r,i){var o=Ll.intersects(e,n,r),s=Ll.intersects(e,n,i),a=Ll.intersects(r,i,e),u=Ll.intersects(r,i,n);return o&&s?(this._intPt[0]=r,this._intPt[1]=i,t.COLLINEAR_INTERSECTION):a&&u?(this._intPt[0]=e,this._intPt[1]=n,t.COLLINEAR_INTERSECTION):o&&a?(this._intPt[0]=r,this._intPt[1]=e,!r.equals(e)||s||u?t.COLLINEAR_INTERSECTION:t.POINT_INTERSECTION):o&&u?(this._intPt[0]=r,this._intPt[1]=n,!r.equals(n)||s||a?t.COLLINEAR_INTERSECTION:t.POINT_INTERSECTION):s&&a?(this._intPt[0]=i,this._intPt[1]=e,!i.equals(e)||o||u?t.COLLINEAR_INTERSECTION:t.POINT_INTERSECTION):s&&u?(this._intPt[0]=i,this._intPt[1]=n,!i.equals(n)||o||a?t.COLLINEAR_INTERSECTION:t.POINT_INTERSECTION):t.NO_INTERSECTION;},e.prototype.normalizeToEnvCentre=function(t,e,n,r,i){var o=t.xe.x?t.x:e.x,u=t.y>e.y?t.y:e.y,l=n.xr.x?n.x:r.x,p=n.y>r.y?n.y:r.y,f=((o>l?o:l)+(ac?s:c)+(u0&&s>0||o<0&&s<0)return t.NO_INTERSECTION;var a=Xl.orientationIndex(r,i,e),u=Xl.orientationIndex(r,i,n);return a>0&&u>0||a<0&&u<0?t.NO_INTERSECTION:0===o&&0===s&&0===a&&0===u?this.computeCollinearIntersection(e,n,r,i):(0===o||0===s||0===a||0===u?(this._isProper=!1,e.equals2D(r)||e.equals2D(i)?this._intPt[0]=e:n.equals2D(r)||n.equals2D(i)?this._intPt[0]=n:0===o?this._intPt[0]=new ul(r):0===s?this._intPt[0]=new ul(i):0===a?this._intPt[0]=new ul(e):0===u&&(this._intPt[0]=new ul(n))):(this._isProper=!0,this._intPt[0]=this.intersection(e,n,r,i)),t.POINT_INTERSECTION);},e.prototype.interfaces_=function(){return[];},e.prototype.getClass=function(){return e;},e.nearestEndpoint=function(t,e,n,r){var i=t,o=Xl.distancePointLine(t,n,r),s=Xl.distancePointLine(e,n,r);return s0?n>0?-i:i:n>0?i:-i;if(0===e||0===n)return r>0?t>0?i:-i:t>0?-i:i;if(e>0?r>0?e<=r||(i=-i,o=t,t=n,n=o,o=e,e=r,r=o):e<=-r?(i=-i,n=-n,r=-r):(o=t,t=-n,n=o,o=e,e=-r,r=o):r>0?-e<=r?(i=-i,t=-t,e=-e):(o=-t,t=n,n=o,o=-e,e=r,r=o):e>=r?(t=-t,e=-e,n=-n,r=-r):(i=-i,o=-t,t=-n,n=o,o=-e,e=-r,r=o),t>0){if(!(n>0))return i;if(!(t<=n))return i;}else{if(n>0)return-i;if(!(t>=n))return-i;i=-i,t=-t,n=-n;}for(;;){if((r-=(s=Math.floor(n/t))*e)<0)return-i;if(r>e)return i;if(t>(n-=s*t)+n){if(er+r)return-i;n=t-n,r=e-r,i=-i;}if(0===r)return 0===n?0:-i;if(0===n)return i;if((e-=(s=Math.floor(t/n))*r)<0)return i;if(e>r)return-i;if(n>(t-=s*n)+t){if(re+e)return i;t=n-t,e=r-e,i=-i;}if(0===e)return 0===t?0:i;if(0===t)return-i;}};var Vl=function Vl(){this._p=null,this._crossingCount=0,this._isPointOnSegment=!1;var t=arguments[0];this._p=t;};Vl.prototype.countSegment=function(t,e){if(t.xr&&(n=e.x,r=t.x),this._p.x>=n&&this._p.x<=r&&(this._isPointOnSegment=!0),null;}if(t.y>this._p.y&&e.y<=this._p.y||e.y>this._p.y&&t.y<=this._p.y){var i=t.x-this._p.x,o=t.y-this._p.y,s=e.x-this._p.x,a=e.y-this._p.y,u=Ul.signOfDet2x2(i,o,s,a);if(0===u)return this._isPointOnSegment=!0,null;a0&&this._crossingCount++;}},Vl.prototype.isPointInPolygon=function(){return this.getLocation()!==pl.EXTERIOR;},Vl.prototype.getLocation=function(){return this._isPointOnSegment?pl.BOUNDARY:this._crossingCount%2==1?pl.INTERIOR:pl.EXTERIOR;},Vl.prototype.isOnSegment=function(){return this._isPointOnSegment;},Vl.prototype.interfaces_=function(){return[];},Vl.prototype.getClass=function(){return Vl;},Vl.locatePointInRing=function(){if(arguments[0]instanceof ul&&gl(arguments[1],Il)){for(var t=arguments[0],e=arguments[1],n=new Vl(t),r=new ul(),i=new ul(),o=1;o1||a<0||a>1)&&(i=!0);}}else i=!0;return i?dl.min(Xl.distancePointLine(t,n,r),Xl.distancePointLine(e,n,r),Xl.distancePointLine(n,t,e),Xl.distancePointLine(r,t,e)):0;},Xl.isPointInRing=function(t,e){return Xl.locatePointInRing(t,e)!==pl.EXTERIOR;},Xl.computeLength=function(t){var e=t.size();if(e<=1)return 0;var n=0,r=new ul();t.getCoordinate(0,r);for(var i=r.x,o=r.y,s=1;sn.y&&(n=o,r=i);}var s=r;do{(s-=1)<0&&(s=e);}while(t[s].equals2D(n)&&s!==r);var a=r;do{a=(a+1)%e;}while(t[a].equals2D(n)&&a!==r);var u=t[s],l=t[a];if(u.equals2D(n)||l.equals2D(n)||u.equals2D(l))return!1;var c=Xl.computeOrientation(u,n,l),h=!1;return h=0===c?u.x>l.x:c>0,h;},Xl.locatePointInRing=function(t,e){return Vl.locatePointInRing(t,e);},Xl.distancePointLinePerpendicular=function(t,e,n){var r=(n.x-e.x)*(n.x-e.x)+(n.y-e.y)*(n.y-e.y),i=((e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y))/r;return Math.abs(i)*Math.sqrt(r);},Xl.computeOrientation=function(t,e,n){return Xl.orientationIndex(t,e,n);},Xl.distancePointLine=function(){if(2===arguments.length){var t=arguments[0],e=arguments[1];if(0===e.length)throw new el("Line array must contain at least one vertex");for(var n=t.distance(e[0]),r=0;r=1)return o.distance(a);var c=((s.y-o.y)*(a.x-s.x)-(s.x-o.x)*(a.y-s.y))/u;return Math.abs(c)*Math.sqrt(u);}},Xl.isOnLine=function(t,e){for(var n=new jl(),r=1;r0;},ec.prototype.interfaces_=function(){return[Ql];},ec.prototype.getClass=function(){return ec;};var nc=function nc(){};nc.prototype.isInBoundary=function(t){return t>1;},nc.prototype.interfaces_=function(){return[Ql];},nc.prototype.getClass=function(){return nc;};var rc=function rc(){};rc.prototype.isInBoundary=function(t){return 1===t;},rc.prototype.interfaces_=function(){return[Ql];},rc.prototype.getClass=function(){return rc;};var ic=function ic(){};function oc(t){this.message=t||"";}ic.prototype.add=function(){},ic.prototype.addAll=function(){},ic.prototype.isEmpty=function(){},ic.prototype.iterator=function(){},ic.prototype.size=function(){},ic.prototype.toArray=function(){},ic.prototype.remove=function(){},oc.prototype=new Error(),oc.prototype.name="IndexOutOfBoundsException";var sc=function sc(){};sc.prototype.hasNext=function(){},sc.prototype.next=function(){},sc.prototype.remove=function(){};var ac=function(t){function e(){t.apply(this,arguments);}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(){},e.prototype.set=function(){},e.prototype.isEmpty=function(){},e;}(ic);function uc(t){this.message=t||"";}uc.prototype=new Error(),uc.prototype.name="NoSuchElementException";var lc=function(t){function e(){t.call(this),this.array_=[],arguments[0]instanceof ic&&this.addAll(arguments[0]);}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.ensureCapacity=function(){},e.prototype.interfaces_=function(){return[t,ic];},e.prototype.add=function(t){return 1===arguments.length?this.array_.push(t):this.array_.splice(arguments[0],arguments[1]),!0;},e.prototype.clear=function(){this.array_=[];},e.prototype.addAll=function(t){for(var e=t.iterator();e.hasNext();)this.add(e.next());return!0;},e.prototype.set=function(t,e){var n=this.array_[t];return this.array_[t]=e,n;},e.prototype.iterator=function(){return new cc(this);},e.prototype.get=function(t){if(t<0||t>=this.size())throw new oc();return this.array_[t];},e.prototype.isEmpty=function(){return 0===this.array_.length;},e.prototype.size=function(){return this.array_.length;},e.prototype.toArray=function(){for(var t=[],e=0,n=this.array_.length;e=1){var a=this.get(this.size()-1);if(a.equals2D(o))return null;}t.prototype.add.call(this,o);}else if(arguments[0]instanceof Object&&"boolean"==typeof arguments[1]){var u=arguments[0],l=arguments[1];return this.add(u,l),!0;}}else if(3===arguments.length){if("boolean"==typeof arguments[2]&&arguments[0]instanceof Array&&"boolean"==typeof arguments[1]){var c=arguments[0],h=arguments[1],p=arguments[2];if(p)for(var f=0;f=0;g--)e.add(c[g],h);return!0;}if("boolean"==typeof arguments[2]&&Number.isInteger(arguments[0])&&arguments[1]instanceof ul){var d=arguments[0],y=arguments[1],v=arguments[2];if(!v){var _=this.size();if(_>0){if(d>0){var m=this.get(d-1);if(m.equals2D(y))return null;}if(d<_){var x=this.get(d);if(x.equals2D(y))return null;}}}t.prototype.add.call(this,d,y);}}else if(4===arguments.length){var E=arguments[0],b=arguments[1],w=arguments[2],I=arguments[3],N=1;w>I&&(N=-1);for(var S=w;S!==I;S+=N)e.add(E[S],b);return!0;}},e.prototype.closeRing=function(){this.size()>0&&this.add(new ul(this.get(0)),!1);},e.prototype.interfaces_=function(){return[];},e.prototype.getClass=function(){return e;},Object.defineProperties(e,n),e;}(lc),pc=function pc(){},fc={ForwardComparator:{configurable:!0},BidirectionalComparator:{configurable:!0},coordArrayType:{configurable:!0}};fc.ForwardComparator.get=function(){return gc;},fc.BidirectionalComparator.get=function(){return dc;},fc.coordArrayType.get=function(){return new Array(0).fill(null);},pc.prototype.interfaces_=function(){return[];},pc.prototype.getClass=function(){return pc;},pc.isRing=function(t){return!(t.length<4)&&!!t[0].equals2D(t[t.length-1]);},pc.ptNotInList=function(t,e){for(var n=0;n=t?e:[];},pc.indexOf=function(t,e){for(var n=0;n0)&&(e=t[n]);return e;},pc.extract=function(t,e,n){e=dl.clamp(e,0,t.length);var r=(n=dl.clamp(n,-1,t.length))-e+1;n<0&&(r=0),e>=t.length&&(r=0),nr.length)return 1;if(0===n.length)return 0;var i=pc.compare(n,r);return pc.isEqualReversed(n,r)?0:i;},dc.prototype.OLDcompare=function(t,e){var n=t,r=e;if(n.lengthr.length)return 1;if(0===n.length)return 0;for(var i=pc.increasingDirection(n),o=pc.increasingDirection(r),s=i>0?0:n.length-1,a=o>0?0:n.length-1,u=0;u0))return e.value;e=e.right;}}return null;},Cc.prototype.put=function(t,e){if(null===this.root_)return this.root_={key:t,value:e,left:null,right:null,parent:null,color:0,getValue:function getValue(){return this.value;},getKey:function getKey(){return this.key;}},this.size_=1,null;var n,r,i=this.root_;do{if(n=i,(r=t.compareTo(i.key))<0)i=i.left;else{if(!(r>0)){var o=i.value;return i.value=e,o;}i=i.right;}}while(null!==i);var s={key:t,left:null,right:null,value:e,parent:n,color:0,getValue:function getValue(){return this.value;},getKey:function getKey(){return this.key;}};return r<0?n.left=s:n.right=s,this.fixAfterInsertion(s),this.size_++,null;},Cc.prototype.fixAfterInsertion=function(t){var e=this;for(t.color=1;null!=t&&t!==this.root_&&1===t.parent.color;)if(wc(t)===Nc(wc(wc(t)))){var n=Sc(wc(wc(t)));1===bc(n)?(Ic(wc(t),0),Ic(n,0),Ic(wc(wc(t)),1),t=wc(wc(t))):(t===Sc(wc(t))&&(t=wc(t),e.rotateLeft(t)),Ic(wc(t),0),Ic(wc(wc(t)),1),e.rotateRight(wc(wc(t))));}else{var r=Nc(wc(wc(t)));1===bc(r)?(Ic(wc(t),0),Ic(r,0),Ic(wc(wc(t)),1),t=wc(wc(t))):(t===Nc(wc(t))&&(t=wc(t),e.rotateRight(t)),Ic(wc(t),0),Ic(wc(wc(t)),1),e.rotateLeft(wc(wc(t))));}this.root_.color=0;},Cc.prototype.values=function(){var t=new lc(),e=this.getFirstEntry();if(null!==e)for(t.add(e.value);null!==(e=Cc.successor(e));)t.add(e.value);return t;},Cc.prototype.entrySet=function(){var t=new xc(),e=this.getFirstEntry();if(null!==e)for(t.add(e);null!==(e=Cc.successor(e));)t.add(e);return t;},Cc.prototype.rotateLeft=function(t){if(null!=t){var e=t.right;t.right=e.left,null!=e.left&&(e.left.parent=t),e.parent=t.parent,null===t.parent?this.root_=e:t.parent.left===t?t.parent.left=e:t.parent.right=e,e.left=t,t.parent=e;}},Cc.prototype.rotateRight=function(t){if(null!=t){var e=t.left;t.left=e.right,null!=e.right&&(e.right.parent=t),e.parent=t.parent,null===t.parent?this.root_=e:t.parent.right===t?t.parent.right=e:t.parent.left=e,e.right=t,t.parent=e;}},Cc.prototype.getFirstEntry=function(){var t=this.root_;if(null!=t)for(;null!=t.left;)t=t.left;return t;},Cc.successor=function(t){if(null===t)return null;if(null!==t.right){for(var e=t.right;null!==e.left;)e=e.left;return e;}for(var n=t.parent,r=t;null!==n&&r===n.right;)r=n,n=n.parent;return n;},Cc.prototype.size=function(){return this.size_;};var Pc=function Pc(){};function Mc(){}function Lc(){this.array_=[],arguments[0]instanceof ic&&this.addAll(arguments[0]);}Pc.prototype.interfaces_=function(){return[];},Pc.prototype.getClass=function(){return Pc;},Mc.prototype=new mc(),Lc.prototype=new Mc(),Lc.prototype.contains=function(t){for(var e=0,n=this.array_.length;e=0;){var s=i.substring(0,o);r.add(s),o=(i=i.substring(o+n)).indexOf(e);}i.length>0&&r.add(i);for(var a=new Array(r.size()).fill(null),u=0;u0)for(var o=i;o0&&r.append(" ");for(var o=0;o0&&r.append(","),r.append(Hc.toString(t.getOrdinate(i,o)));}return r.append(")"),r.toString();}},Jc.ensureValidRing=function(t,e){var n=e.size();return 0===n?e:n<=3?Jc.createClosedRing(t,e,4):e.getOrdinate(0,Il.X)===e.getOrdinate(n-1,Il.X)&&e.getOrdinate(0,Il.Y)===e.getOrdinate(n-1,Il.Y)?e:Jc.createClosedRing(t,e,n+1);},Jc.createClosedRing=function(t,e,n){var r=t.create(n,e.getDimension()),i=e.size();Jc.copy(e,0,r,0,i);for(var o=i;o0&&Jc.reverse(t._points),null;}},e.prototype.getCoordinate=function(){return this.isEmpty()?null:this._points.getCoordinate(0);},e.prototype.getBoundaryDimension=function(){return this.isClosed()?Tc.FALSE:0;},e.prototype.isClosed=function(){return!this.isEmpty()&&this.getCoordinateN(0).equals2D(this.getCoordinateN(this.getNumPoints()-1));},e.prototype.getEndPoint=function(){return this.isEmpty()?null:this.getPointN(this.getNumPoints()-1);},e.prototype.getDimension=function(){return 1;},e.prototype.getLength=function(){return Xl.computeLength(this._points);},e.prototype.getNumPoints=function(){return this._points.size();},e.prototype.reverse=function(){var t=this._points.copy();return Jc.reverse(t),this.getFactory().createLineString(t);},e.prototype.compareToSameClass=function(){var t=this;if(1===arguments.length){for(var e=arguments[0],n=e,r=0,i=0;r= 2)");this._points=t;},e.prototype.isCoordinate=function(t){for(var e=0;e=1&&this.getCoordinateSequence().size()= 4)");},e.prototype.getGeometryType=function(){return"LinearRing";},e.prototype.copy=function(){return new e(this._points.copy(),this._factory);},e.prototype.interfaces_=function(){return[];},e.prototype.getClass=function(){return e;},n.MINIMUM_VALID_SIZE.get=function(){return 4;},n.serialVersionUID.get=function(){return-0x3b229e262367a600;},Object.defineProperties(e,n),e;}(Zc),rh=function(t){function e(){t.apply(this,arguments);}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={serialVersionUID:{configurable:!0}};return e.prototype.getSortIndex=function(){return Wl.SORTINDEX_MULTIPOLYGON;},e.prototype.equalsExact=function(){if(2===arguments.length){var e=arguments[0],n=arguments[1];return!!this.isEquivalentClass(e)&&t.prototype.equalsExact.call(this,e,n);}return t.prototype.equalsExact.apply(this,arguments);},e.prototype.getBoundaryDimension=function(){return 1;},e.prototype.getDimension=function(){return 2;},e.prototype.reverse=function(){for(var t=this._geometries.length,e=new Array(t).fill(null),n=0;n0?e.createPoint(n[0]):e.createPoint():t;},ah.prototype.interfaces_=function(){return[ih.GeometryEditorOperation];},ah.prototype.getClass=function(){return ah;};var uh=function uh(){};uh.prototype.edit=function(t,e){return t instanceof nh?e.createLinearRing(this.edit(t.getCoordinateSequence(),t)):t instanceof Zc?e.createLineString(this.edit(t.getCoordinateSequence(),t)):t instanceof Qc?e.createPoint(this.edit(t.getCoordinateSequence(),t)):t;},uh.prototype.interfaces_=function(){return[ih.GeometryEditorOperation];},uh.prototype.getClass=function(){return uh;};var lh=function lh(){var t=this;if(this._dimension=3,this._coordinates=null,1===arguments.length){if(arguments[0]instanceof Array)this._coordinates=arguments[0],this._dimension=3;else if(Number.isInteger(arguments[0])){var e=arguments[0];this._coordinates=new Array(e).fill(null);for(var n=0;n0){var t=new vl(17*this._coordinates.length);t.append("("),t.append(this._coordinates[0]);for(var e=1;e3&&(r=3),r<2?new lh(n):new lh(n,r);}},hh.prototype.interfaces_=function(){return[hl,al];},hh.prototype.getClass=function(){return hh;},hh.instance=function(){return hh.instanceObject;},ph.serialVersionUID.get=function(){return-0x38e49fa6cf6f2e00;},ph.instanceObject.get=function(){return new hh();},Object.defineProperties(hh,ph);var fh=function(t){function e(){t.call(this),this.map_=new Map();}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t){return this.map_.get(t)||null;},e.prototype.put=function(t,e){return this.map_.set(t,e),e;},e.prototype.values=function(){for(var t=new lc(),e=this.map_.values(),n=e.next();!n.done;)t.add(n.value),n=e.next();return t;},e.prototype.entrySet=function(){var t=new xc();return this.map_.entries().forEach(function(e){return t.add(e);}),t;},e.prototype.size=function(){return this.map_.size();},e;}(yc),gh=function t(){if(this._modelType=null,this._scale=null,0===arguments.length)this._modelType=t.FLOATING;else if(1===arguments.length)if(arguments[0]instanceof yh){var e=arguments[0];this._modelType=e,e===t.FIXED&&this.setScale(1);}else if("number"==typeof arguments[0]){var n=arguments[0];this._modelType=t.FIXED,this.setScale(n);}else if(arguments[0]instanceof t){var r=arguments[0];this._modelType=r._modelType,this._scale=r._scale;}},dh={serialVersionUID:{configurable:!0},maximumPreciseValue:{configurable:!0}};gh.prototype.equals=function(t){if(!(t instanceof gh))return!1;var e=t;return this._modelType===e._modelType&&this._scale===e._scale;},gh.prototype.compareTo=function(t){var e=t,n=this.getMaximumSignificantDigits(),r=e.getMaximumSignificantDigits();return new _l(n).compareTo(new _l(r));},gh.prototype.getScale=function(){return this._scale;},gh.prototype.isFloating=function(){return this._modelType===gh.FLOATING||this._modelType===gh.FLOATING_SINGLE;},gh.prototype.getType=function(){return this._modelType;},gh.prototype.toString=function(){var t="UNKNOWN";return this._modelType===gh.FLOATING?t="Floating":this._modelType===gh.FLOATING_SINGLE?t="Floating-Single":this._modelType===gh.FIXED&&(t="Fixed (Scale="+this.getScale()+")"),t;},gh.prototype.makePrecise=function(){if("number"==typeof arguments[0]){var t=arguments[0];if(nl.isNaN(t))return t;if(this._modelType===gh.FLOATING_SINGLE){return t;}return this._modelType===gh.FIXED?Math.round(t*this._scale)/this._scale:t;}if(arguments[0]instanceof ul){var e=arguments[0];if(this._modelType===gh.FLOATING)return null;e.x=this.makePrecise(e.x),e.y=this.makePrecise(e.y);}},gh.prototype.getMaximumSignificantDigits=function(){var t=16;return this._modelType===gh.FLOATING?t=16:this._modelType===gh.FLOATING_SINGLE?t=6:this._modelType===gh.FIXED&&(t=1+Math.trunc(Math.ceil(Math.log(this.getScale())/Math.log(10)))),t;},gh.prototype.setScale=function(t){this._scale=Math.abs(t);},gh.prototype.interfaces_=function(){return[al,il];},gh.prototype.getClass=function(){return gh;},gh.mostPrecise=function(t,e){return t.compareTo(e)>=0?t:e;},dh.serialVersionUID.get=function(){return 0x6bee6404e9a25c00;},dh.maximumPreciseValue.get=function(){return 9007199254740992;},Object.defineProperties(gh,dh);var yh=function t(e){this._name=e||null,t.nameToTypeMap.put(e,this);},vh={serialVersionUID:{configurable:!0},nameToTypeMap:{configurable:!0}};yh.prototype.readResolve=function(){return yh.nameToTypeMap.get(this._name);},yh.prototype.toString=function(){return this._name;},yh.prototype.interfaces_=function(){return[al];},yh.prototype.getClass=function(){return yh;},vh.serialVersionUID.get=function(){return-552860263173159e4;},vh.nameToTypeMap.get=function(){return new fh();},Object.defineProperties(yh,vh),gh.Type=yh,gh.FIXED=new yh("FIXED"),gh.FLOATING=new yh("FLOATING"),gh.FLOATING_SINGLE=new yh("FLOATING SINGLE");var _h=function t(){this._precisionModel=new gh(),this._SRID=0,this._coordinateSequenceFactory=t.getDefaultCoordinateSequenceFactory(),0===arguments.length||(1===arguments.length?gl(arguments[0],hl)?this._coordinateSequenceFactory=arguments[0]:arguments[0]instanceof gh&&(this._precisionModel=arguments[0]):2===arguments.length?(this._precisionModel=arguments[0],this._SRID=arguments[1]):3===arguments.length&&(this._precisionModel=arguments[0],this._SRID=arguments[1],this._coordinateSequenceFactory=arguments[2]));},mh={serialVersionUID:{configurable:!0}};_h.prototype.toGeometry=function(t){return t.isNull()?this.createPoint(null):t.getMinX()===t.getMaxX()&&t.getMinY()===t.getMaxY()?this.createPoint(new ul(t.getMinX(),t.getMinY())):t.getMinX()===t.getMaxX()||t.getMinY()===t.getMaxY()?this.createLineString([new ul(t.getMinX(),t.getMinY()),new ul(t.getMaxX(),t.getMaxY())]):this.createPolygon(this.createLinearRing([new ul(t.getMinX(),t.getMinY()),new ul(t.getMinX(),t.getMaxY()),new ul(t.getMaxX(),t.getMaxY()),new ul(t.getMaxX(),t.getMinY()),new ul(t.getMinX(),t.getMinY())]),null);},_h.prototype.createLineString=function(t){return t?t instanceof Array?new Zc(this.getCoordinateSequenceFactory().create(t),this):gl(t,Il)?new Zc(t,this):void 0:new Zc(this.getCoordinateSequenceFactory().create([]),this);},_h.prototype.createMultiLineString=function(){if(0===arguments.length)return new Gc(null,this);if(1===arguments.length){var t=arguments[0];return new Gc(t,this);}},_h.prototype.buildGeometry=function(t){for(var e=null,n=!1,r=!1,i=t.iterator();i.hasNext();){var o=i.next(),s=o.getClass();null===e&&(e=s),s!==e&&(n=!0),o.isGeometryCollectionOrDerived()&&(r=!0);}if(null===e)return this.createGeometryCollection();if(n||r)return this.createGeometryCollection(_h.toGeometryArray(t));var a=t.iterator().next();if(t.size()>1){if(a instanceof th)return this.createMultiPolygon(_h.toPolygonArray(t));if(a instanceof Zc)return this.createMultiLineString(_h.toLineStringArray(t));if(a instanceof Qc)return this.createMultiPoint(_h.toPointArray(t));ql.shouldNeverReachHere("Unhandled class: "+a.getClass().getName());}return a;},_h.prototype.createMultiPointFromCoords=function(t){return this.createMultiPoint(null!==t?this.getCoordinateSequenceFactory().create(t):null);},_h.prototype.createPoint=function(){if(0===arguments.length)return this.createPoint(this.getCoordinateSequenceFactory().create([]));if(1===arguments.length){if(arguments[0]instanceof ul){var t=arguments[0];return this.createPoint(null!==t?this.getCoordinateSequenceFactory().create([t]):null);}if(gl(arguments[0],Il)){var e=arguments[0];return new Qc(e,this);}}},_h.prototype.getCoordinateSequenceFactory=function(){return this._coordinateSequenceFactory;},_h.prototype.createPolygon=function(){if(0===arguments.length)return new th(null,null,this);if(1===arguments.length){if(gl(arguments[0],Il)){var t=arguments[0];return this.createPolygon(this.createLinearRing(t));}if(arguments[0]instanceof Array){var e=arguments[0];return this.createPolygon(this.createLinearRing(e));}if(arguments[0]instanceof nh){var n=arguments[0];return this.createPolygon(n,null);}}else if(2===arguments.length){var r=arguments[0],i=arguments[1];return new th(r,i,this);}},_h.prototype.getSRID=function(){return this._SRID;},_h.prototype.createGeometryCollection=function(){if(0===arguments.length)return new kc(null,this);if(1===arguments.length){var t=arguments[0];return new kc(t,this);}},_h.prototype.createGeometry=function(t){return new ih(this).edit(t,{edit:function edit(){if(2===arguments.length){var t=arguments[0];return this._coordinateSequenceFactory.create(t);}}});},_h.prototype.getPrecisionModel=function(){return this._precisionModel;},_h.prototype.createLinearRing=function(){if(0===arguments.length)return this.createLinearRing(this.getCoordinateSequenceFactory().create([]));if(1===arguments.length){if(arguments[0]instanceof Array){var t=arguments[0];return this.createLinearRing(null!==t?this.getCoordinateSequenceFactory().create(t):null);}if(gl(arguments[0],Il)){var e=arguments[0];return new nh(e,this);}}},_h.prototype.createMultiPolygon=function(){if(0===arguments.length)return new rh(null,this);if(1===arguments.length){var t=arguments[0];return new rh(t,this);}},_h.prototype.createMultiPoint=function(){var t=this;if(0===arguments.length)return new eh(null,this);if(1===arguments.length){if(arguments[0]instanceof Array){var e=arguments[0];return new eh(e,this);}if(arguments[0]instanceof Array){var n=arguments[0];return this.createMultiPoint(null!==n?this.getCoordinateSequenceFactory().create(n):null);}if(gl(arguments[0],Il)){var r=arguments[0];if(null===r)return this.createMultiPoint(new Array(0).fill(null));for(var i=new Array(r.size()).fill(null),o=0;o=this.size())throw new Error();return this.array_[t];},Mh.prototype.push=function(t){return this.array_.push(t),t;},Mh.prototype.pop=function(t){if(0===this.array_.length)throw new Ph();return this.array_.pop();},Mh.prototype.peek=function(){if(0===this.array_.length)throw new Ph();return this.array_[this.array_.length-1];},Mh.prototype.empty=function(){return 0===this.array_.length;},Mh.prototype.isEmpty=function(){return this.empty();},Mh.prototype.search=function(t){return this.array_.indexOf(t);},Mh.prototype.size=function(){return this.array_.length;},Mh.prototype.toArray=function(){for(var t=[],e=0,n=this.array_.length;e0&&this._minIndexthis._minCoord.y&&n.y>this._minCoord.y&&r===Xl.CLOCKWISE)&&(i=!0),i&&(this._minIndex=this._minIndex-1);},Lh.prototype.getRightmostSideOfSegment=function(t,e){var n=t.getEdge().getCoordinates();if(e<0||e+1>=n.length)return-1;if(n[e].y===n[e+1].y)return-1;var r=Sh.LEFT;return n[e].ye._minCoord.x)&&(e._minDe=t,e._minIndex=r,e._minCoord=n[r]);},Lh.prototype.findRightmostEdgeAtNode=function(){var t=this._minDe.getNode().getEdges();this._minDe=t.getRightmostEdge(),this._minDe.isForward()||(this._minDe=this._minDe.getSym(),this._minIndex=this._minDe.getEdge().getCoordinates().length-1);},Lh.prototype.findEdge=function(t){for(var e=t.iterator();e.hasNext();){var n=e.next();n.isForward()&&this.checkForRightmostCoordinate(n);}ql.isTrue(0!==this._minIndex||this._minCoord.equals(this._minDe.getCoordinate()),"inconsistency in rightmost processing"),0===this._minIndex?this.findRightmostEdgeAtNode():this.findRightmostEdgeAtVertex(),this._orientedDe=this._minDe,this.getRightmostSide(this._minDe,this._minIndex)===Sh.LEFT&&(this._orientedDe=this._minDe.getSym());},Lh.prototype.interfaces_=function(){return[];},Lh.prototype.getClass=function(){return Lh;};var Oh=function(t){function e(n,r){t.call(this,e.msgWithCoord(n,r)),this.pt=r?new ul(r):null,this.name="TopologyException";}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.getCoordinate=function(){return this.pt;},e.prototype.interfaces_=function(){return[];},e.prototype.getClass=function(){return e;},e.msgWithCoord=function(t,e){return e?t:t+" [ "+e+" ]";},e;}(kl),Rh=function Rh(){this.array_=[];};Rh.prototype.addLast=function(t){this.array_.push(t);},Rh.prototype.removeFirst=function(){return this.array_.shift();},Rh.prototype.isEmpty=function(){return 0===this.array_.length;};var Th=function Th(){this._finder=null,this._dirEdgeList=new lc(),this._nodes=new lc(),this._rightMostCoord=null,this._env=null,this._finder=new Lh();};Th.prototype.clearVisitedEdges=function(){for(var t=this._dirEdgeList.iterator();t.hasNext();){t.next().setVisited(!1);}},Th.prototype.getRightmostCoordinate=function(){return this._rightMostCoord;},Th.prototype.computeNodeDepth=function(t){for(var e=null,n=t.getEdges().iterator();n.hasNext();){var r=n.next();if(r.isVisited()||r.getSym().isVisited()){e=r;break;}}if(null===e)throw new Oh("unable to find edge to compute depths at "+t.getCoordinate());t.getEdges().computeDepths(e);for(var i=t.getEdges().iterator();i.hasNext();){var o=i.next();o.setVisited(!0),this.copySymDepths(o);}},Th.prototype.computeDepth=function(t){this.clearVisitedEdges();var e=this._finder.getEdge();e.setEdgeDepths(Sh.RIGHT,t),this.copySymDepths(e),this.computeDepths(e);},Th.prototype.create=function(t){this.addReachable(t),this._finder.findEdge(this._dirEdgeList),this._rightMostCoord=this._finder.getCoordinate();},Th.prototype.findResultEdges=function(){for(var t=this._dirEdgeList.iterator();t.hasNext();){var e=t.next();e.getDepth(Sh.RIGHT)>=1&&e.getDepth(Sh.LEFT)<=0&&!e.isInteriorAreaEdge()&&e.setInResult(!0);}},Th.prototype.computeDepths=function(t){var e=new xc(),n=new Rh(),r=t.getNode();for(n.addLast(r),e.add(r),t.setVisited(!0);!n.isEmpty();){var i=n.removeFirst();e.add(i),this.computeNodeDepth(i);for(var o=i.getEdges().iterator();o.hasNext();){var s=o.next().getSym();if(!s.isVisited()){var a=s.getNode();e.contains(a)||(n.addLast(a),e.add(a));}}}},Th.prototype.compareTo=function(t){var e=t;return this._rightMostCoord.xe._rightMostCoord.x?1:0;},Th.prototype.getEnvelope=function(){if(null===this._env){for(var t=new Ll(),e=this._dirEdgeList.iterator();e.hasNext();)for(var n=e.next().getEdge().getCoordinates(),r=0;rthis.location.length){var e=new Array(3).fill(null);e[Sh.ON]=this.location[Sh.ON],e[Sh.LEFT]=pl.NONE,e[Sh.RIGHT]=pl.NONE,this.location=e;}for(var n=0;n1&&t.append(pl.toLocationSymbol(this.location[Sh.LEFT])),t.append(pl.toLocationSymbol(this.location[Sh.ON])),this.location.length>1&&t.append(pl.toLocationSymbol(this.location[Sh.RIGHT])),t.toString();},Ah.prototype.setLocations=function(t,e,n){this.location[Sh.ON]=t,this.location[Sh.LEFT]=e,this.location[Sh.RIGHT]=n;},Ah.prototype.get=function(t){return t1;},Ah.prototype.isAnyNull=function(){for(var t=0;tt._maxNodeDegree&&(t._maxNodeDegree=n),e=t.getNext(e);}while(e!==this._startDe);this._maxNodeDegree*=2;},Fh.prototype.addPoints=function(t,e,n){var r=t.getCoordinates();if(e){var i=1;n&&(i=0);for(var o=i;o=0;a--)this._pts.add(r[a]);}},Fh.prototype.isHole=function(){return this._isHole;},Fh.prototype.setInResult=function(){var t=this._startDe;do{t.getEdge().setInResult(!0),t=t.getNext();}while(t!==this._startDe);},Fh.prototype.containsPoint=function(t){var e=this.getLinearRing();if(!e.getEnvelopeInternal().contains(t))return!1;if(!Xl.isPointInRing(t,e.getCoordinates()))return!1;for(var n=this._holes.iterator();n.hasNext();){if(n.next().containsPoint(t))return!1;}return!0;},Fh.prototype.addHole=function(t){this._holes.add(t);},Fh.prototype.isShell=function(){return null===this._shell;},Fh.prototype.getLabel=function(){return this._label;},Fh.prototype.getEdges=function(){return this._edges;},Fh.prototype.getMaxNodeDegree=function(){return this._maxNodeDegree<0&&this.computeMaxNodeDegree(),this._maxNodeDegree;},Fh.prototype.getShell=function(){return this._shell;},Fh.prototype.mergeLabel=function(){if(1===arguments.length){var t=arguments[0];this.mergeLabel(t,0),this.mergeLabel(t,1);}else if(2===arguments.length){var e=arguments[0],n=arguments[1],r=e.getLocation(n,Sh.RIGHT);if(r===pl.NONE)return null;if(this._label.getLocation(n)===pl.NONE)return this._label.setLocation(n,r),null;}},Fh.prototype.setShell=function(t){this._shell=t,null!==t&&t.addHole(this);},Fh.prototype.toPolygon=function(t){for(var e=new Array(this._holes.size()).fill(null),n=0;n=2,"found partial label"),this.computeIM(t);},qh.prototype.isInResult=function(){return this._isInResult;},qh.prototype.isVisited=function(){return this._isVisited;},qh.prototype.interfaces_=function(){return[];},qh.prototype.getClass=function(){return qh;};var Bh=function(t){function e(){t.call(this),this._coord=null,this._edges=null;var e=arguments[0],n=arguments[1];this._coord=e,this._edges=n,this._label=new Dh(0,pl.NONE);}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.isIncidentEdgeInResult=function(){for(var t=this.getEdges().getEdges().iterator();t.hasNext();){if(t.next().getEdge().isInResult())return!0;}return!1;},e.prototype.isIsolated=function(){return 1===this._label.getGeometryCount();},e.prototype.getCoordinate=function(){return this._coord;},e.prototype.print=function(t){t.println("node "+this._coord+" lbl: "+this._label);},e.prototype.computeIM=function(t){},e.prototype.computeMergedLocation=function(t,e){var n=pl.NONE;if(n=this._label.getLocation(e),!t.isNull(e)){var r=t.getLocation(e);n!==pl.BOUNDARY&&(n=r);}return n;},e.prototype.setLabel=function(){if(2!==arguments.length)return t.prototype.setLabel.apply(this,arguments);var e=arguments[0],n=arguments[1];null===this._label?this._label=new Dh(e,n):this._label.setLocation(e,n);},e.prototype.getEdges=function(){return this._edges;},e.prototype.mergeLabel=function(){var t=this;if(arguments[0]instanceof e){var n=arguments[0];this.mergeLabel(n._label);}else if(arguments[0]instanceof Dh)for(var r=arguments[0],i=0;i<2;i++){var o=t.computeMergedLocation(r,i),s=t._label.getLocation(i);s===pl.NONE&&t._label.setLocation(i,o);}},e.prototype.add=function(t){this._edges.insert(t),t.setNode(this);},e.prototype.setLabelBoundary=function(t){if(null===this._label)return null;var e=pl.NONE;null!==this._label&&(e=this._label.getLocation(t));var n=null;switch(e){case pl.BOUNDARY:n=pl.INTERIOR;break;case pl.INTERIOR:default:n=pl.BOUNDARY;}this._label.setLocation(t,n);},e.prototype.interfaces_=function(){return[];},e.prototype.getClass=function(){return e;},e;}(qh),zh=function zh(){this.nodeMap=new Cc(),this.nodeFact=null;var t=arguments[0];this.nodeFact=t;};zh.prototype.find=function(t){return this.nodeMap.get(t);},zh.prototype.addNode=function(){if(arguments[0]instanceof ul){var t=arguments[0],e=this.nodeMap.get(t);return null===e&&(e=this.nodeFact.createNode(t),this.nodeMap.put(t,e)),e;}if(arguments[0]instanceof Bh){var n=arguments[0],r=this.nodeMap.get(n.getCoordinate());return null===r?(this.nodeMap.put(n.getCoordinate(),n),n):(r.mergeLabel(n),r);}},zh.prototype.print=function(t){for(var e=this.iterator();e.hasNext();){e.next().print(t);}},zh.prototype.iterator=function(){return this.nodeMap.values().iterator();},zh.prototype.values=function(){return this.nodeMap.values();},zh.prototype.getBoundaryNodes=function(t){for(var e=new lc(),n=this.iterator();n.hasNext();){var r=n.next();r.getLabel().getLocation(t)===pl.BOUNDARY&&e.add(r);}return e;},zh.prototype.add=function(t){var e=t.getCoordinate();this.addNode(e).add(t);},zh.prototype.interfaces_=function(){return[];},zh.prototype.getClass=function(){return zh;};var jh=function jh(){},Uh={NE:{configurable:!0},NW:{configurable:!0},SW:{configurable:!0},SE:{configurable:!0}};jh.prototype.interfaces_=function(){return[];},jh.prototype.getClass=function(){return jh;},jh.isNorthern=function(t){return t===jh.NE||t===jh.NW;},jh.isOpposite=function(t,e){return t!==e&&2===(t-e+4)%4;},jh.commonHalfPlane=function(t,e){if(t===e)return t;if(2===(t-e+4)%4)return-1;var n=te?t:e)?3:n;},jh.isInHalfPlane=function(t,e){return e===jh.SE?t===jh.SE||t===jh.SW:t===e||t===e+1;},jh.quadrant=function(){if("number"==typeof arguments[0]&&"number"==typeof arguments[1]){var t=arguments[0],e=arguments[1];if(0===t&&0===e)throw new el("Cannot compute the quadrant for point ( "+t+", "+e+" )");return t>=0?e>=0?jh.NE:jh.SE:e>=0?jh.NW:jh.SW;}if(arguments[0]instanceof ul&&arguments[1]instanceof ul){var n=arguments[0],r=arguments[1];if(r.x===n.x&&r.y===n.y)throw new el("Cannot compute the quadrant for two identical points "+n);return r.x>=n.x?r.y>=n.y?jh.NE:jh.SE:r.y>=n.y?jh.NW:jh.SW;}},Uh.NE.get=function(){return 0;},Uh.NW.get=function(){return 1;},Uh.SW.get=function(){return 2;},Uh.SE.get=function(){return 3;},Object.defineProperties(jh,Uh);var Vh=function Vh(){if(this._edge=null,this._label=null,this._node=null,this._p0=null,this._p1=null,this._dx=null,this._dy=null,this._quadrant=null,1===arguments.length){var t=arguments[0];this._edge=t;}else if(3===arguments.length){var e=arguments[0],n=arguments[1],r=arguments[2],i=null;this._edge=e,this.init(n,r),this._label=i;}else if(4===arguments.length){var o=arguments[0],s=arguments[1],a=arguments[2],u=arguments[3];this._edge=o,this.init(s,a),this._label=u;}};Vh.prototype.compareDirection=function(t){return this._dx===t._dx&&this._dy===t._dy?0:this._quadrant>t._quadrant?1:this._quadrant2){o.linkDirectedEdgesForMinimalEdgeRings();var s=o.buildMinimalRings(),a=this.findShell(s);null!==a?(this.placePolygonHoles(a,s),e.add(a)):n.addAll(s);}else r.add(o);}return r;},Wh.prototype.containsPoint=function(t){for(var e=this._shellList.iterator();e.hasNext();){if(e.next().containsPoint(t))return!0;}return!1;},Wh.prototype.buildMaximalEdgeRings=function(t){for(var e=new lc(),n=t.iterator();n.hasNext();){var r=n.next();if(r.isInResult()&&r.getLabel().isArea()&&null===r.getEdgeRing()){var i=new Gh(r,this._geometryFactory);e.add(i),i.setInResult();}}return e;},Wh.prototype.placePolygonHoles=function(t,e){for(var n=e.iterator();n.hasNext();){var r=n.next();r.isHole()&&r.setShell(t);}},Wh.prototype.getPolygons=function(){return this.computePolygons(this._shellList);},Wh.prototype.findEdgeRingContaining=function(t,e){for(var n=t.getLinearRing(),r=n.getEnvelopeInternal(),i=n.getCoordinateN(0),o=null,s=null,a=e.iterator();a.hasNext();){var u=a.next(),l=u.getLinearRing(),c=l.getEnvelopeInternal();null!==o&&(s=o.getLinearRing().getEnvelopeInternal());var h=!1;c.contains(r)&&Xl.isPointInRing(i,l.getCoordinates())&&(h=!0),h&&(null===o||s.contains(c))&&(o=u);}return o;},Wh.prototype.findShell=function(t){for(var e=0,n=null,r=t.iterator();r.hasNext();){var i=r.next();i.isHole()||(n=i,e++);}return ql.isTrue(e<=1,"found two shells in MinimalEdgeRing list"),n;},Wh.prototype.add=function(){if(1===arguments.length){var t=arguments[0];this.add(t.getEdgeEnds(),t.getNodes());}else if(2===arguments.length){var e=arguments[0],n=arguments[1];Hh.linkResultDirectedEdges(n);var r=this.buildMaximalEdgeRings(e),i=new lc(),o=this.buildMinimalEdgeRings(r,this._shellList,i);this.sortShellsAndHoles(o,this._shellList,i),this.placeFreeHoles(this._shellList,i);}},Wh.prototype.interfaces_=function(){return[];},Wh.prototype.getClass=function(){return Wh;};var Jh=function Jh(){};Jh.prototype.getBounds=function(){},Jh.prototype.interfaces_=function(){return[];},Jh.prototype.getClass=function(){return Jh;};var Zh=function Zh(){this._bounds=null,this._item=null;var t=arguments[0],e=arguments[1];this._bounds=t,this._item=e;};Zh.prototype.getItem=function(){return this._item;},Zh.prototype.getBounds=function(){return this._bounds;},Zh.prototype.interfaces_=function(){return[Jh,al];},Zh.prototype.getClass=function(){return Zh;};var Kh=function Kh(){this._size=null,this._items=null,this._size=0,this._items=new lc(),this._items.add(null);};Kh.prototype.poll=function(){if(this.isEmpty())return null;var t=this._items.get(1);return this._items.set(1,this._items.get(this._size)),this._size-=1,this.reorder(1),t;},Kh.prototype.size=function(){return this._size;},Kh.prototype.reorder=function(t){for(var e=this,n=null,r=this._items.get(t);2*t<=this._size&&((n=2*t)!==e._size&&e._items.get(n+1).compareTo(e._items.get(n))<0&&n++,e._items.get(n).compareTo(r)<0);t=n)e._items.set(t,e._items.get(n));this._items.set(t,r);},Kh.prototype.clear=function(){this._size=0,this._items.clear();},Kh.prototype.isEmpty=function(){return 0===this._size;},Kh.prototype.add=function(t){this._items.add(null),this._size+=1;var e=this._size;for(this._items.set(0,t);t.compareTo(this._items.get(Math.trunc(e/2)))<0;e/=2)this._items.set(e,this._items.get(Math.trunc(e/2)));this._items.set(e,t);},Kh.prototype.interfaces_=function(){return[];},Kh.prototype.getClass=function(){return Kh;};var Qh=function Qh(){};Qh.prototype.visitItem=function(t){},Qh.prototype.interfaces_=function(){return[];},Qh.prototype.getClass=function(){return Qh;};var $h=function $h(){};$h.prototype.insert=function(t,e){},$h.prototype.remove=function(t,e){},$h.prototype.query=function(){},$h.prototype.interfaces_=function(){return[];},$h.prototype.getClass=function(){return $h;};var tp=function tp(){if(this._childBoundables=new lc(),this._bounds=null,this._level=null,0===arguments.length);else if(1===arguments.length){var t=arguments[0];this._level=t;}},ep={serialVersionUID:{configurable:!0}};tp.prototype.getLevel=function(){return this._level;},tp.prototype.size=function(){return this._childBoundables.size();},tp.prototype.getChildBoundables=function(){return this._childBoundables;},tp.prototype.addChildBoundable=function(t){ql.isTrue(null===this._bounds),this._childBoundables.add(t);},tp.prototype.isEmpty=function(){return this._childBoundables.isEmpty();},tp.prototype.getBounds=function(){return null===this._bounds&&(this._bounds=this.computeBounds()),this._bounds;},tp.prototype.interfaces_=function(){return[Jh,al];},tp.prototype.getClass=function(){return tp;},ep.serialVersionUID.get=function(){return 0x5a1e55ec41369800;},Object.defineProperties(tp,ep);var np=function np(){};np.reverseOrder=function(){return{compare:function compare(t,e){return e.compareTo(t);}};},np.min=function(t){return np.sort(t),t.get(0);},np.sort=function(t,e){var n=t.toArray();e?Rc.sort(n,e):Rc.sort(n);for(var r=t.iterator(),i=0,o=n.length;irp.area(this._boundable2)?(this.expand(this._boundable1,this._boundable2,t,e),null):(this.expand(this._boundable2,this._boundable1,t,e),null);if(n)return this.expand(this._boundable1,this._boundable2,t,e),null;if(r)return this.expand(this._boundable2,this._boundable1,t,e),null;throw new el("neither boundable is composite");},rp.prototype.isLeaves=function(){return!(rp.isComposite(this._boundable1)||rp.isComposite(this._boundable2));},rp.prototype.compareTo=function(t){var e=t;return this._distancee._distance?1:0;},rp.prototype.expand=function(t,e,n,r){for(var i=t.getChildBoundables().iterator();i.hasNext();){var o=i.next(),s=new rp(o,e,this._itemDistance);s.getDistance()1,"Node capacity must be greater than 1"),this._nodeCapacity=n;}},op={IntersectsOp:{configurable:!0},serialVersionUID:{configurable:!0},DEFAULT_NODE_CAPACITY:{configurable:!0}};ip.prototype.getNodeCapacity=function(){return this._nodeCapacity;},ip.prototype.lastNode=function(t){return t.get(t.size()-1);},ip.prototype.size=function(){var t=this;if(0===arguments.length)return this.isEmpty()?0:(this.build(),this.size(this._root));if(1===arguments.length){for(var e=arguments[0],n=0,r=e.getChildBoundables().iterator();r.hasNext();){var i=r.next();i instanceof tp?n+=t.size(i):i instanceof Zh&&(n+=1);}return n;}},ip.prototype.removeItem=function(t,e){for(var n=null,r=t.getChildBoundables().iterator();r.hasNext();){var i=r.next();i instanceof Zh&&i.getItem()===e&&(n=i);}return null!==n&&(t.getChildBoundables().remove(n),!0);},ip.prototype.itemsTree=function(){var t=this;if(0===arguments.length){this.build();var e=this.itemsTree(this._root);return null===e?new lc():e;}if(1===arguments.length){for(var n=arguments[0],r=new lc(),i=n.getChildBoundables().iterator();i.hasNext();){var o=i.next();if(o instanceof tp){var s=t.itemsTree(o);null!==s&&r.add(s);}else o instanceof Zh?r.add(o.getItem()):ql.shouldNeverReachHere();}return r.size()<=0?null:r;}},ip.prototype.insert=function(t,e){ql.isTrue(!this._built,"Cannot insert items into an STR packed R-tree after it has been built."),this._itemBoundables.add(new Zh(t,e));},ip.prototype.boundablesAtLevel=function(){var t=this;if(1===arguments.length){var e=arguments[0],n=new lc();return this.boundablesAtLevel(e,this._root,n),n;}if(3===arguments.length){var r=arguments[0],i=arguments[1],o=arguments[2];if(ql.isTrue(r>-2),i.getLevel()===r)return o.add(i),null;for(var s=i.getChildBoundables().iterator();s.hasNext();){var a=s.next();a instanceof tp?t.boundablesAtLevel(r,a,o):(ql.isTrue(a instanceof Zh),-1===r&&o.add(a));}return null;}},ip.prototype.query=function(){var t=this;if(1===arguments.length){var e=arguments[0];this.build();var n=new lc();return this.isEmpty()||this.getIntersectsOp().intersects(this._root.getBounds(),e)&&this.query(e,this._root,n),n;}if(2===arguments.length){var r=arguments[0],i=arguments[1];if(this.build(),this.isEmpty())return null;this.getIntersectsOp().intersects(this._root.getBounds(),r)&&this.query(r,this._root,i);}else if(3===arguments.length)if(gl(arguments[2],Qh)&&arguments[0]instanceof Object&&arguments[1]instanceof tp)for(var o=arguments[0],s=arguments[1],a=arguments[2],u=s.getChildBoundables(),l=0;ln&&(n=o);}}return n+1;}},ip.prototype.createParentBoundables=function(t,e){var n=this;ql.isTrue(!t.isEmpty());var r=new lc();r.add(this.createNode(e));var i=new lc(t);np.sort(i,this.getComparator());for(var o=i.iterator();o.hasNext();){var s=o.next();n.lastNode(r).getChildBoundables().size()===n.getNodeCapacity()&&r.add(n.createNode(e)),n.lastNode(r).addChildBoundable(s);}return r;},ip.prototype.isEmpty=function(){return this._built?this._root.isEmpty():this._itemBoundables.isEmpty();},ip.prototype.interfaces_=function(){return[al];},ip.prototype.getClass=function(){return ip;},ip.compareDoubles=function(t,e){return t>e?1:t0);for(var n=new lc(),r=0;r0;){var p=h.poll(),f=p.getDistance();if(f>=l)break;p.isLeaves()?(l=f,c=p):p.expandToQueue(h,l);}return[c.getBoundable(0).getItem(),c.getBoundable(1).getItem()];}}else if(3===arguments.length){var g=arguments[0],d=arguments[1],y=arguments[2],v=new Zh(g,d),_=new rp(this.getRoot(),v,y);return this.nearestNeighbour(_)[0];}},e.prototype.interfaces_=function(){return[$h,al];},e.prototype.getClass=function(){return e;},e.centreX=function(t){return e.avg(t.getMinX(),t.getMaxX());},e.avg=function(t,e){return(t+e)/2;},e.centreY=function(t){return e.avg(t.getMinY(),t.getMaxY());},n.STRtreeNode.get=function(){return lp;},n.serialVersionUID.get=function(){return 0x39920f7d5f261e0;},n.xComparator.get=function(){return{interfaces_:function interfaces_(){return[sl];},compare:function compare(n,r){return t.compareDoubles(e.centreX(n.getBounds()),e.centreX(r.getBounds()));}};},n.yComparator.get=function(){return{interfaces_:function interfaces_(){return[sl];},compare:function compare(n,r){return t.compareDoubles(e.centreY(n.getBounds()),e.centreY(r.getBounds()));}};},n.intersectsOp.get=function(){return{interfaces_:function interfaces_(){return[t.IntersectsOp];},intersects:function intersects(t,e){return t.intersects(e);}};},n.DEFAULT_NODE_CAPACITY.get=function(){return 10;},Object.defineProperties(e,n),e;}(ip),lp=function(t){function e(){var e=arguments[0];t.call(this,e);}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.computeBounds=function(){for(var t=null,e=this.getChildBoundables().iterator();e.hasNext();){var n=e.next();null===t?t=new Ll(n.getBounds()):t.expandToInclude(n.getBounds());}return t;},e.prototype.interfaces_=function(){return[];},e.prototype.getClass=function(){return e;},e;}(tp),cp=function cp(){};cp.prototype.interfaces_=function(){return[];},cp.prototype.getClass=function(){return cp;},cp.relativeSign=function(t,e){return te?1:0;},cp.compare=function(t,e,n){if(e.equals2D(n))return 0;var r=cp.relativeSign(e.x,n.x),i=cp.relativeSign(e.y,n.y);switch(t){case 0:return cp.compareValue(r,i);case 1:return cp.compareValue(i,r);case 2:return cp.compareValue(i,-r);case 3:return cp.compareValue(-r,i);case 4:return cp.compareValue(-r,-i);case 5:return cp.compareValue(-i,-r);case 6:return cp.compareValue(-i,r);case 7:return cp.compareValue(r,-i);}return ql.shouldNeverReachHere("invalid octant value"),0;},cp.compareValue=function(t,e){return t<0?-1:t>0?1:e<0?-1:e>0?1:0;};var hp=function hp(){this._segString=null,this.coord=null,this.segmentIndex=null,this._segmentOctant=null,this._isInterior=null;var t=arguments[0],e=arguments[1],n=arguments[2],r=arguments[3];this._segString=t,this.coord=new ul(e),this.segmentIndex=n,this._segmentOctant=r,this._isInterior=!e.equals2D(t.getCoordinate(n));};hp.prototype.getCoordinate=function(){return this.coord;},hp.prototype.print=function(t){t.print(this.coord),t.print(" seg # = "+this.segmentIndex);},hp.prototype.compareTo=function(t){var e=t;return this.segmentIndexe.segmentIndex?1:this.coord.equals2D(e.coord)?0:cp.compare(this._segmentOctant,this.coord,e.coord);},hp.prototype.isEndPoint=function(t){return 0===this.segmentIndex&&!this._isInterior||this.segmentIndex===t;},hp.prototype.isInterior=function(){return this._isInterior;},hp.prototype.interfaces_=function(){return[il];},hp.prototype.getClass=function(){return hp;};var pp=function pp(){this._nodeMap=new Cc(),this._edge=null;var t=arguments[0];this._edge=t;};pp.prototype.getSplitCoordinates=function(){var t=new hc();this.addEndpoints();for(var e=this.iterator(),n=e.next();e.hasNext();){var r=e.next();this.addEdgeCoordinates(n,r,t),n=r;}return t.toCoordinateArray();},pp.prototype.addCollapsedNodes=function(){var t=new lc();this.findCollapsesFromInsertedNodes(t),this.findCollapsesFromExistingVertices(t);for(var e=t.iterator();e.hasNext();){var n=e.next().intValue();this.add(this._edge.getCoordinate(n),n);}},pp.prototype.print=function(t){t.println("Intersections:");for(var e=this.iterator();e.hasNext();){e.next().print(t);}},pp.prototype.findCollapsesFromExistingVertices=function(t){for(var e=0;e=0?e>=0?n>=r?0:1:n>=r?7:6:e>=0?n>=r?3:2:n>=r?4:5;}if(arguments[0]instanceof ul&&arguments[1]instanceof ul){var i=arguments[0],o=arguments[1],s=o.x-i.x,a=o.y-i.y;if(0===s&&0===a)throw new el("Cannot compute the octant for two identical points "+i);return fp.octant(s,a);}};var gp=function gp(){};gp.prototype.getCoordinates=function(){},gp.prototype.size=function(){},gp.prototype.getCoordinate=function(t){},gp.prototype.isClosed=function(){},gp.prototype.setData=function(t){},gp.prototype.getData=function(){},gp.prototype.interfaces_=function(){return[];},gp.prototype.getClass=function(){return gp;};var dp=function dp(){};dp.prototype.addIntersection=function(t,e){},dp.prototype.interfaces_=function(){return[gp];},dp.prototype.getClass=function(){return dp;};var yp=function yp(){this._nodeList=new pp(this),this._pts=null,this._data=null;var t=arguments[0],e=arguments[1];this._pts=t,this._data=e;};yp.prototype.getCoordinates=function(){return this._pts;},yp.prototype.size=function(){return this._pts.length;},yp.prototype.getCoordinate=function(t){return this._pts[t];},yp.prototype.isClosed=function(){return this._pts[0].equals(this._pts[this._pts.length-1]);},yp.prototype.getSegmentOctant=function(t){return t===this._pts.length-1?-1:this.safeOctant(this.getCoordinate(t),this.getCoordinate(t+1));},yp.prototype.setData=function(t){this._data=t;},yp.prototype.safeOctant=function(t,e){return t.equals2D(e)?0:fp.octant(t,e);},yp.prototype.getData=function(){return this._data;},yp.prototype.addIntersection=function(){if(2===arguments.length){var t=arguments[0],e=arguments[1];this.addIntersectionNode(t,e);}else if(4===arguments.length){var n=arguments[0],r=arguments[1],i=arguments[3],o=new ul(n.getIntersection(i));this.addIntersection(o,r);}},yp.prototype.toString=function(){return Fl.toLineString(new lh(this._pts));},yp.prototype.getNodeList=function(){return this._nodeList;},yp.prototype.addIntersectionNode=function(t,e){var n=e,r=n+1;if(r=0&&n>=0||e<=0&&n<=0?Math.max(e,n):0;}if(arguments[0]instanceof ul){var r=arguments[0];return Xl.orientationIndex(this.p0,this.p1,r);}},vp.prototype.toGeometry=function(t){return t.createLineString([this.p0,this.p1]);},vp.prototype.isVertical=function(){return this.p0.x===this.p1.x;},vp.prototype.equals=function(t){if(!(t instanceof vp))return!1;var e=t;return this.p0.equals(e.p0)&&this.p1.equals(e.p1);},vp.prototype.intersection=function(t){var e=new jl();return e.computeIntersection(this.p0,this.p1,t.p0,t.p1),e.hasIntersection()?e.getIntersection(0):null;},vp.prototype.project=function(){if(arguments[0]instanceof ul){var t=arguments[0];if(t.equals(this.p0)||t.equals(this.p1))return new ul(t);var e=this.projectionFactor(t),n=new ul();return n.x=this.p0.x+e*(this.p1.x-this.p0.x),n.y=this.p0.y+e*(this.p1.y-this.p0.y),n;}if(arguments[0]instanceof vp){var r=arguments[0],i=this.projectionFactor(r.p0),o=this.projectionFactor(r.p1);if(i>=1&&o>=1)return null;if(i<=0&&o<=0)return null;var s=this.project(r.p0);i<0&&(s=this.p0),i>1&&(s=this.p1);var a=this.project(r.p1);return o<0&&(a=this.p0),o>1&&(a=this.p1),new vp(s,a);}},vp.prototype.normalize=function(){this.p1.compareTo(this.p0)<0&&this.reverse();},vp.prototype.angle=function(){return Math.atan2(this.p1.y-this.p0.y,this.p1.x-this.p0.x);},vp.prototype.getCoordinate=function(t){return 0===t?this.p0:this.p1;},vp.prototype.distancePerpendicular=function(t){return Xl.distancePointLinePerpendicular(t,this.p0,this.p1);},vp.prototype.minY=function(){return Math.min(this.p0.y,this.p1.y);},vp.prototype.midPoint=function(){return vp.midPoint(this.p0,this.p1);},vp.prototype.projectionFactor=function(t){if(t.equals(this.p0))return 0;if(t.equals(this.p1))return 1;var e=this.p1.x-this.p0.x,n=this.p1.y-this.p0.y,r=e*e+n*n;return r<=0?nl.NaN:((t.x-this.p0.x)*e+(t.y-this.p0.y)*n)/r;},vp.prototype.closestPoints=function(t){var e=this.intersection(t);if(null!==e)return[e,e];var n=new Array(2).fill(null),r=nl.MAX_VALUE,i=null,o=this.closestPoint(t.p0);r=o.distance(t.p0),n[0]=o,n[1]=t.p0;var s=this.closestPoint(t.p1);(i=s.distance(t.p1))0&&e<1?this.project(t):this.p0.distance(t)1||nl.isNaN(e))&&(e=1),e;},vp.prototype.toString=function(){return"LINESTRING( "+this.p0.x+" "+this.p0.y+", "+this.p1.x+" "+this.p1.y+")";},vp.prototype.isHorizontal=function(){return this.p0.y===this.p1.y;},vp.prototype.distance=function(){if(arguments[0]instanceof vp){var t=arguments[0];return Xl.distanceLineLine(this.p0,this.p1,t.p0,t.p1);}if(arguments[0]instanceof ul){var e=arguments[0];return Xl.distancePointLine(e,this.p0,this.p1);}},vp.prototype.pointAlong=function(t){var e=new ul();return e.x=this.p0.x+t*(this.p1.x-this.p0.x),e.y=this.p0.y+t*(this.p1.y-this.p0.y),e;},vp.prototype.hashCode=function(){var t=nl.doubleToLongBits(this.p0.x);t^=31*nl.doubleToLongBits(this.p0.y);var e=Math.trunc(t)^Math.trunc(t>>32),n=nl.doubleToLongBits(this.p1.x);return n^=31*nl.doubleToLongBits(this.p1.y),e^(Math.trunc(n)^Math.trunc(n>>32));},vp.prototype.interfaces_=function(){return[il,al];},vp.prototype.getClass=function(){return vp;},vp.midPoint=function(t,e){return new ul((t.x+e.x)/2,(t.y+e.y)/2);},_p.serialVersionUID.get=function(){return 0x2d2172135f411c00;},Object.defineProperties(vp,_p);var mp=function mp(){this.tempEnv1=new Ll(),this.tempEnv2=new Ll(),this._overlapSeg1=new vp(),this._overlapSeg2=new vp();};mp.prototype.overlap=function(){if(2===arguments.length);else if(4===arguments.length){var t=arguments[0],e=arguments[1],n=arguments[2],r=arguments[3];t.getLineSegment(e,this._overlapSeg1),n.getLineSegment(r,this._overlapSeg2),this.overlap(this._overlapSeg1,this._overlapSeg2);}},mp.prototype.interfaces_=function(){return[];},mp.prototype.getClass=function(){return mp;};var xp=function xp(){this._pts=null,this._start=null,this._end=null,this._env=null,this._context=null,this._id=null;var t=arguments[0],e=arguments[1],n=arguments[2],r=arguments[3];this._pts=t,this._start=e,this._end=n,this._context=r;};xp.prototype.getLineSegment=function(t,e){e.p0=this._pts[t],e.p1=this._pts[t+1];},xp.prototype.computeSelect=function(t,e,n,r){var i=this._pts[e],o=this._pts[n];if(r.tempEnv1.init(i,o),n-e==1)return r.select(this,e),null;if(!t.intersects(r.tempEnv1))return null;var s=Math.trunc((e+n)/2);e=t.length-1)return t.length-1;for(var r=jh.quadrant(t[n],t[n+1]),i=e+1;ir.getId()&&(r.computeOverlaps(o,e),t._nOverlaps++),t._segInt.isDone())return null;}},e.prototype.interfaces_=function(){return[];},e.prototype.getClass=function(){return e;},n.SegmentOverlapAction.get=function(){return Np;},Object.defineProperties(e,n),e;}(wp),Np=function(t){function e(){t.call(this),this._si=null;var e=arguments[0];this._si=e;}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.overlap=function(){if(4!==arguments.length)return t.prototype.overlap.apply(this,arguments);var e=arguments[0],n=arguments[1],r=arguments[2],i=arguments[3],o=e.getContext(),s=r.getContext();this._si.processIntersections(o,n,s,i);},e.prototype.interfaces_=function(){return[];},e.prototype.getClass=function(){return e;},e;}(mp),Sp=function t(){if(this._quadrantSegments=t.DEFAULT_QUADRANT_SEGMENTS,this._endCapStyle=t.CAP_ROUND,this._joinStyle=t.JOIN_ROUND,this._mitreLimit=t.DEFAULT_MITRE_LIMIT,this._isSingleSided=!1,this._simplifyFactor=t.DEFAULT_SIMPLIFY_FACTOR,0===arguments.length);else if(1===arguments.length){var e=arguments[0];this.setQuadrantSegments(e);}else if(2===arguments.length){var n=arguments[0],r=arguments[1];this.setQuadrantSegments(n),this.setEndCapStyle(r);}else if(4===arguments.length){var i=arguments[0],o=arguments[1],s=arguments[2],a=arguments[3];this.setQuadrantSegments(i),this.setEndCapStyle(o),this.setJoinStyle(s),this.setMitreLimit(a);}},Cp={CAP_ROUND:{configurable:!0},CAP_FLAT:{configurable:!0},CAP_SQUARE:{configurable:!0},JOIN_ROUND:{configurable:!0},JOIN_MITRE:{configurable:!0},JOIN_BEVEL:{configurable:!0},DEFAULT_QUADRANT_SEGMENTS:{configurable:!0},DEFAULT_MITRE_LIMIT:{configurable:!0},DEFAULT_SIMPLIFY_FACTOR:{configurable:!0}};Sp.prototype.getEndCapStyle=function(){return this._endCapStyle;},Sp.prototype.isSingleSided=function(){return this._isSingleSided;},Sp.prototype.setQuadrantSegments=function(t){this._quadrantSegments=t,0===this._quadrantSegments&&(this._joinStyle=Sp.JOIN_BEVEL),this._quadrantSegments<0&&(this._joinStyle=Sp.JOIN_MITRE,this._mitreLimit=Math.abs(this._quadrantSegments)),t<=0&&(this._quadrantSegments=1),this._joinStyle!==Sp.JOIN_ROUND&&(this._quadrantSegments=Sp.DEFAULT_QUADRANT_SEGMENTS);},Sp.prototype.getJoinStyle=function(){return this._joinStyle;},Sp.prototype.setJoinStyle=function(t){this._joinStyle=t;},Sp.prototype.setSimplifyFactor=function(t){this._simplifyFactor=t<0?0:t;},Sp.prototype.getSimplifyFactor=function(){return this._simplifyFactor;},Sp.prototype.getQuadrantSegments=function(){return this._quadrantSegments;},Sp.prototype.setEndCapStyle=function(t){this._endCapStyle=t;},Sp.prototype.getMitreLimit=function(){return this._mitreLimit;},Sp.prototype.setMitreLimit=function(t){this._mitreLimit=t;},Sp.prototype.setSingleSided=function(t){this._isSingleSided=t;},Sp.prototype.interfaces_=function(){return[];},Sp.prototype.getClass=function(){return Sp;},Sp.bufferDistanceError=function(t){var e=Math.PI/2/t;return 1-Math.cos(e/2);},Cp.CAP_ROUND.get=function(){return 1;},Cp.CAP_FLAT.get=function(){return 2;},Cp.CAP_SQUARE.get=function(){return 3;},Cp.JOIN_ROUND.get=function(){return 1;},Cp.JOIN_MITRE.get=function(){return 2;},Cp.JOIN_BEVEL.get=function(){return 3;},Cp.DEFAULT_QUADRANT_SEGMENTS.get=function(){return 8;},Cp.DEFAULT_MITRE_LIMIT.get=function(){return 5;},Cp.DEFAULT_SIMPLIFY_FACTOR.get=function(){return .01;},Object.defineProperties(Sp,Cp);var Pp=function Pp(t){this._distanceTol=null,this._isDeleted=null,this._angleOrientation=Xl.COUNTERCLOCKWISE,this._inputLine=t||null;},Mp={INIT:{configurable:!0},DELETE:{configurable:!0},KEEP:{configurable:!0},NUM_PTS_TO_CHECK:{configurable:!0}};Pp.prototype.isDeletable=function(t,e,n,r){var i=this._inputLine[t],o=this._inputLine[e],s=this._inputLine[n];return!!this.isConcave(i,o,s)&&!!this.isShallow(i,o,s,r)&&this.isShallowSampled(i,o,t,n,r);},Pp.prototype.deleteShallowConcavities=function(){for(var t=this,e=1,n=this.findNextNonDeletedIndex(e),r=this.findNextNonDeletedIndex(n),i=!1;r=0;r--)this.addPt(t[r]);},Lp.prototype.isRedundant=function(t){if(this._ptList.size()<1)return!1;var e=this._ptList.get(this._ptList.size()-1);return t.distance(e)Math.PI;)t-=Rp.PI_TIMES_2;for(;t<=-Math.PI;)t+=Rp.PI_TIMES_2;return t;},Rp.angle=function(){if(1===arguments.length){var t=arguments[0];return Math.atan2(t.y,t.x);}if(2===arguments.length){var e=arguments[0],n=arguments[1],r=n.x-e.x,i=n.y-e.y;return Math.atan2(i,r);}},Rp.isAcute=function(t,e,n){var r=t.x-e.x,i=t.y-e.y;return r*(n.x-e.x)+i*(n.y-e.y)>0;},Rp.isObtuse=function(t,e,n){var r=t.x-e.x,i=t.y-e.y;return r*(n.x-e.x)+i*(n.y-e.y)<0;},Rp.interiorAngle=function(t,e,n){var r=Rp.angle(e,t),i=Rp.angle(e,n);return Math.abs(i-r);},Rp.normalizePositive=function(t){if(t<0){for(;t<0;)t+=Rp.PI_TIMES_2;t>=Rp.PI_TIMES_2&&(t=0);}else{for(;t>=Rp.PI_TIMES_2;)t-=Rp.PI_TIMES_2;t<0&&(t=0);}return t;},Rp.angleBetween=function(t,e,n){var r=Rp.angle(e,t),i=Rp.angle(e,n);return Rp.diff(r,i);},Rp.diff=function(t,e){var n=null;return(n=tMath.PI&&(n=2*Math.PI-n),n;},Rp.toRadians=function(t){return t*Math.PI/180;},Rp.getTurn=function(t,e){var n=Math.sin(e-t);return n>0?Rp.COUNTERCLOCKWISE:n<0?Rp.CLOCKWISE:Rp.NONE;},Rp.angleBetweenOriented=function(t,e,n){var r=Rp.angle(e,t),i=Rp.angle(e,n)-r;return i<=-Math.PI?i+Rp.PI_TIMES_2:i>Math.PI?i-Rp.PI_TIMES_2:i;},Tp.PI_TIMES_2.get=function(){return 2*Math.PI;},Tp.PI_OVER_2.get=function(){return Math.PI/2;},Tp.PI_OVER_4.get=function(){return Math.PI/4;},Tp.COUNTERCLOCKWISE.get=function(){return Xl.COUNTERCLOCKWISE;},Tp.CLOCKWISE.get=function(){return Xl.CLOCKWISE;},Tp.NONE.get=function(){return Xl.COLLINEAR;},Object.defineProperties(Rp,Tp);var Ap=function t(){this._maxCurveSegmentError=0,this._filletAngleQuantum=null,this._closingSegLengthFactor=1,this._segList=null,this._distance=0,this._precisionModel=null,this._bufParams=null,this._li=null,this._s0=null,this._s1=null,this._s2=null,this._seg0=new vp(),this._seg1=new vp(),this._offset0=new vp(),this._offset1=new vp(),this._side=0,this._hasNarrowConcaveAngle=!1;var e=arguments[0],n=arguments[1],r=arguments[2];this._precisionModel=e,this._bufParams=n,this._li=new jl(),this._filletAngleQuantum=Math.PI/2/n.getQuadrantSegments(),n.getQuadrantSegments()>=8&&n.getJoinStyle()===Sp.JOIN_ROUND&&(this._closingSegLengthFactor=t.MAX_CLOSING_SEG_LEN_FACTOR),this.init(r);},Dp={OFFSET_SEGMENT_SEPARATION_FACTOR:{configurable:!0},INSIDE_TURN_VERTEX_SNAP_DISTANCE_FACTOR:{configurable:!0},CURVE_VERTEX_SNAP_DISTANCE_FACTOR:{configurable:!0},MAX_CLOSING_SEG_LEN_FACTOR:{configurable:!0}};Ap.prototype.addNextSegment=function(t,e){if(this._s0=this._s1,this._s1=this._s2,this._s2=t,this._seg0.setCoordinates(this._s0,this._s1),this.computeOffsetSegment(this._seg0,this._side,this._distance,this._offset0),this._seg1.setCoordinates(this._s1,this._s2),this.computeOffsetSegment(this._seg1,this._side,this._distance,this._offset1),this._s1.equals(this._s2))return null;var n=Xl.computeOrientation(this._s0,this._s1,this._s2),r=n===Xl.CLOCKWISE&&this._side===Sh.LEFT||n===Xl.COUNTERCLOCKWISE&&this._side===Sh.RIGHT;0===n?this.addCollinear(e):r?this.addOutsideTurn(n,e):this.addInsideTurn(n,e);},Ap.prototype.addLineEndCap=function(t,e){var n=new vp(t,e),r=new vp();this.computeOffsetSegment(n,Sh.LEFT,this._distance,r);var i=new vp();this.computeOffsetSegment(n,Sh.RIGHT,this._distance,i);var o=e.x-t.x,s=e.y-t.y,a=Math.atan2(s,o);switch(this._bufParams.getEndCapStyle()){case Sp.CAP_ROUND:this._segList.addPt(r.p1),this.addFilletArc(e,a+Math.PI/2,a-Math.PI/2,Xl.CLOCKWISE,this._distance),this._segList.addPt(i.p1);break;case Sp.CAP_FLAT:this._segList.addPt(r.p1),this._segList.addPt(i.p1);break;case Sp.CAP_SQUARE:var u=new ul();u.x=Math.abs(this._distance)*Math.cos(a),u.y=Math.abs(this._distance)*Math.sin(a);var l=new ul(r.p1.x+u.x,r.p1.y+u.y),c=new ul(i.p1.x+u.x,i.p1.y+u.y);this._segList.addPt(l),this._segList.addPt(c);}},Ap.prototype.getCoordinates=function(){return this._segList.getCoordinates();},Ap.prototype.addMitreJoin=function(t,e,n,r){var i=!0,o=null;try{o=Ml.intersection(e.p0,e.p1,n.p0,n.p1),(r<=0?1:o.distance(t)/Math.abs(r))>this._bufParams.getMitreLimit()&&(i=!1);}catch(t){if(!(t instanceof Cl))throw t;o=new ul(0,0),i=!1;}i?this._segList.addPt(o):this.addLimitedMitreJoin(e,n,r,this._bufParams.getMitreLimit());},Ap.prototype.addFilletCorner=function(t,e,n,r,i){var o=e.x-t.x,s=e.y-t.y,a=Math.atan2(s,o),u=n.x-t.x,l=n.y-t.y,c=Math.atan2(l,u);r===Xl.CLOCKWISE?a<=c&&(a+=2*Math.PI):a>=c&&(a-=2*Math.PI),this._segList.addPt(e),this.addFilletArc(t,a,c,r,i),this._segList.addPt(n);},Ap.prototype.addOutsideTurn=function(t,e){if(this._offset0.p1.distance(this._offset1.p0)0){var n=new ul((this._closingSegLengthFactor*this._offset0.p1.x+this._s1.x)/(this._closingSegLengthFactor+1),(this._closingSegLengthFactor*this._offset0.p1.y+this._s1.y)/(this._closingSegLengthFactor+1));this._segList.addPt(n);var r=new ul((this._closingSegLengthFactor*this._offset1.p0.x+this._s1.x)/(this._closingSegLengthFactor+1),(this._closingSegLengthFactor*this._offset1.p0.y+this._s1.y)/(this._closingSegLengthFactor+1));this._segList.addPt(r);}else this._segList.addPt(this._s1);this._segList.addPt(this._offset1.p0);}},Ap.prototype.createCircle=function(t){var e=new ul(t.x+this._distance,t.y);this._segList.addPt(e),this.addFilletArc(t,0,2*Math.PI,-1,this._distance),this._segList.closeRing();},Ap.prototype.addBevelJoin=function(t,e){this._segList.addPt(t.p1),this._segList.addPt(e.p0);},Ap.prototype.init=function(t){this._distance=t,this._maxCurveSegmentError=t*(1-Math.cos(this._filletAngleQuantum/2)),this._segList=new Lp(),this._segList.setPrecisionModel(this._precisionModel),this._segList.setMinimumVertexDistance(t*Ap.CURVE_VERTEX_SNAP_DISTANCE_FACTOR);},Ap.prototype.addCollinear=function(t){this._li.computeIntersection(this._s0,this._s1,this._s1,this._s2),this._li.getIntersectionNum()>=2&&(this._bufParams.getJoinStyle()===Sp.JOIN_BEVEL||this._bufParams.getJoinStyle()===Sp.JOIN_MITRE?(t&&this._segList.addPt(this._offset0.p1),this._segList.addPt(this._offset1.p0)):this.addFilletCorner(this._s1,this._offset0.p1,this._offset1.p0,Xl.CLOCKWISE,this._distance));},Ap.prototype.closeRing=function(){this._segList.closeRing();},Ap.prototype.hasNarrowConcaveAngle=function(){return this._hasNarrowConcaveAngle;},Ap.prototype.interfaces_=function(){return[];},Ap.prototype.getClass=function(){return Ap;},Dp.OFFSET_SEGMENT_SEPARATION_FACTOR.get=function(){return .001;},Dp.INSIDE_TURN_VERTEX_SNAP_DISTANCE_FACTOR.get=function(){return .001;},Dp.CURVE_VERTEX_SNAP_DISTANCE_FACTOR.get=function(){return 1e-6;},Dp.MAX_CLOSING_SEG_LEN_FACTOR.get=function(){return 80;},Object.defineProperties(Ap,Dp);var Fp=function Fp(){this._distance=0,this._precisionModel=null,this._bufParams=null;var t=arguments[0],e=arguments[1];this._precisionModel=t,this._bufParams=e;};Fp.prototype.getOffsetCurve=function(t,e){if(this._distance=e,0===e)return null;var n=e<0,r=Math.abs(e),i=this.getSegGen(r);t.length<=1?this.computePointCurve(t[0],i):this.computeOffsetCurve(t,n,i);var o=i.getCoordinates();return n&&pc.reverse(o),o;},Fp.prototype.computeSingleSidedBufferCurve=function(t,e,n){var r=this.simplifyTolerance(this._distance);if(e){n.addSegments(t,!0);var i=Pp.simplify(t,-r),o=i.length-1;n.initSideSegments(i[o],i[o-1],Sh.LEFT),n.addFirstSegment();for(var s=o-2;s>=0;s--)n.addNextSegment(i[s],!0);}else{n.addSegments(t,!1);var a=Pp.simplify(t,r),u=a.length-1;n.initSideSegments(a[0],a[1],Sh.LEFT),n.addFirstSegment();for(var l=2;l<=u;l++)n.addNextSegment(a[l],!0);}n.addLastSegment(),n.closeRing();},Fp.prototype.computeRingBufferCurve=function(t,e,n){var r=this.simplifyTolerance(this._distance);e===Sh.RIGHT&&(r=-r);var i=Pp.simplify(t,r),o=i.length-1;n.initSideSegments(i[o-1],i[0],e);for(var s=1;s<=o;s++){var a=1!==s;n.addNextSegment(i[s],a);}n.closeRing();},Fp.prototype.computeLineBufferCurve=function(t,e){var n=this.simplifyTolerance(this._distance),r=Pp.simplify(t,n),i=r.length-1;e.initSideSegments(r[0],r[1],Sh.LEFT);for(var o=2;o<=i;o++)e.addNextSegment(r[o],!0);e.addLastSegment(),e.addLineEndCap(r[i-1],r[i]);var s=Pp.simplify(t,-n),a=s.length-1;e.initSideSegments(s[a],s[a-1],Sh.LEFT);for(var u=a-2;u>=0;u--)e.addNextSegment(s[u],!0);e.addLastSegment(),e.addLineEndCap(s[1],s[0]),e.closeRing();},Fp.prototype.computePointCurve=function(t,e){switch(this._bufParams.getEndCapStyle()){case Sp.CAP_ROUND:e.createCircle(t);break;case Sp.CAP_SQUARE:e.createSquare(t);}},Fp.prototype.getLineCurve=function(t,e){if(this._distance=e,e<0&&!this._bufParams.isSingleSided())return null;if(0===e)return null;var n=Math.abs(e),r=this.getSegGen(n);if(t.length<=1)this.computePointCurve(t[0],r);else if(this._bufParams.isSingleSided()){var i=e<0;this.computeSingleSidedBufferCurve(t,i,r);}else this.computeLineBufferCurve(t,r);return r.getCoordinates();},Fp.prototype.getBufferParameters=function(){return this._bufParams;},Fp.prototype.simplifyTolerance=function(t){return t*this._bufParams.getSimplifyFactor();},Fp.prototype.getRingCurve=function(t,e,n){if(this._distance=n,t.length<=2)return this.getLineCurve(t,n);if(0===n)return Fp.copyCoordinates(t);var r=this.getSegGen(n);return this.computeRingBufferCurve(t,e,r),r.getCoordinates();},Fp.prototype.computeOffsetCurve=function(t,e,n){var r=this.simplifyTolerance(this._distance);if(e){var i=Pp.simplify(t,-r),o=i.length-1;n.initSideSegments(i[o],i[o-1],Sh.LEFT),n.addFirstSegment();for(var s=o-2;s>=0;s--)n.addNextSegment(i[s],!0);}else{var a=Pp.simplify(t,r),u=a.length-1;n.initSideSegments(a[0],a[1],Sh.LEFT),n.addFirstSegment();for(var l=2;l<=u;l++)n.addNextSegment(a[l],!0);}n.addLastSegment();},Fp.prototype.getSegGen=function(t){return new Ap(this._precisionModel,this._bufParams,t);},Fp.prototype.interfaces_=function(){return[];},Fp.prototype.getClass=function(){return Fp;},Fp.copyCoordinates=function(t){for(var e=new Array(t.length).fill(null),n=0;no.getMaxY()||t.findStabbedSegments(e,i.getDirectedEdges(),n);}return n;}if(3===arguments.length)if(gl(arguments[2],ac)&&arguments[0]instanceof ul&&arguments[1]instanceof Xh)for(var s=arguments[0],a=arguments[1],u=arguments[2],l=a.getEdge().getCoordinates(),c=0;ct._seg.p1.y&&t._seg.reverse();var h=Math.max(t._seg.p0.x,t._seg.p1.x);if(!(ht._seg.p1.y||Xl.computeOrientation(t._seg.p0,t._seg.p1,s)===Xl.RIGHT)){var p=a.getDepth(Sh.LEFT);t._seg.p0.equals(l[c])||(p=a.getDepth(Sh.RIGHT));var f=new qp(t._seg,p);u.add(f);}}else if(gl(arguments[2],ac)&&arguments[0]instanceof ul&&gl(arguments[1],ac))for(var g=arguments[0],d=arguments[1],y=arguments[2],v=d.iterator();v.hasNext();){var _=v.next();_.isForward()&&t.findStabbedSegments(g,_,y);}},kp.prototype.getDepth=function(t){var e=this.findStabbedSegments(t);return 0===e.size()?0:np.min(e)._leftDepth;},kp.prototype.interfaces_=function(){return[];},kp.prototype.getClass=function(){return kp;},Gp.DepthSegment.get=function(){return qp;},Object.defineProperties(kp,Gp);var qp=function qp(){this._upwardSeg=null,this._leftDepth=null;var t=arguments[0],e=arguments[1];this._upwardSeg=new vp(t),this._leftDepth=e;};qp.prototype.compareTo=function(t){var e=t;if(this._upwardSeg.minX()>=e._upwardSeg.maxX())return 1;if(this._upwardSeg.maxX()<=e._upwardSeg.minX())return-1;var n=this._upwardSeg.orientationIndex(e._upwardSeg);return 0!==n||0!==(n=-1*e._upwardSeg.orientationIndex(this._upwardSeg))?n:this._upwardSeg.compareTo(e._upwardSeg);},qp.prototype.compareX=function(t,e){var n=t.p0.compareTo(e.p0);return 0!==n?n:t.p1.compareTo(e.p1);},qp.prototype.toString=function(){return this._upwardSeg.toString();},qp.prototype.interfaces_=function(){return[il];},qp.prototype.getClass=function(){return qp;};var Bp=function Bp(t,e,n){this.p0=t||null,this.p1=e||null,this.p2=n||null;};Bp.prototype.area=function(){return Bp.area(this.p0,this.p1,this.p2);},Bp.prototype.signedArea=function(){return Bp.signedArea(this.p0,this.p1,this.p2);},Bp.prototype.interpolateZ=function(t){if(null===t)throw new el("Supplied point is null.");return Bp.interpolateZ(t,this.p0,this.p1,this.p2);},Bp.prototype.longestSideLength=function(){return Bp.longestSideLength(this.p0,this.p1,this.p2);},Bp.prototype.isAcute=function(){return Bp.isAcute(this.p0,this.p1,this.p2);},Bp.prototype.circumcentre=function(){return Bp.circumcentre(this.p0,this.p1,this.p2);},Bp.prototype.area3D=function(){return Bp.area3D(this.p0,this.p1,this.p2);},Bp.prototype.centroid=function(){return Bp.centroid(this.p0,this.p1,this.p2);},Bp.prototype.inCentre=function(){return Bp.inCentre(this.p0,this.p1,this.p2);},Bp.prototype.interfaces_=function(){return[];},Bp.prototype.getClass=function(){return Bp;},Bp.area=function(t,e,n){return Math.abs(((n.x-t.x)*(e.y-t.y)-(e.x-t.x)*(n.y-t.y))/2);},Bp.signedArea=function(t,e,n){return((n.x-t.x)*(e.y-t.y)-(e.x-t.x)*(n.y-t.y))/2;},Bp.det=function(t,e,n,r){return t*r-e*n;},Bp.interpolateZ=function(t,e,n,r){var i=e.x,o=e.y,s=n.x-i,a=r.x-i,u=n.y-o,l=r.y-o,c=s*l-a*u,h=t.x-i,p=t.y-o,f=(l*h-a*p)/c,g=(-u*h+s*p)/c;return e.z+f*(n.z-e.z)+g*(r.z-e.z);},Bp.longestSideLength=function(t,e,n){var r=t.distance(e),i=e.distance(n),o=n.distance(t),s=r;return i>s&&(s=i),o>s&&(s=o),s;},Bp.isAcute=function(t,e,n){return!!Rp.isAcute(t,e,n)&&!!Rp.isAcute(e,n,t)&&!!Rp.isAcute(n,t,e);},Bp.circumcentre=function(t,e,n){var r=n.x,i=n.y,o=t.x-r,s=t.y-i,a=e.x-r,u=e.y-i,l=2*Bp.det(o,s,a,u),c=Bp.det(s,o*o+s*s,u,a*a+u*u),h=Bp.det(o,o*o+s*s,a,a*a+u*u);return new ul(r-c/l,i+h/l);},Bp.perpendicularBisector=function(t,e){var n=e.x-t.x,r=e.y-t.y,i=new Ml(t.x+n/2,t.y+r/2,1),o=new Ml(t.x-r+n/2,t.y+n+r/2,1);return new Ml(i,o);},Bp.angleBisector=function(t,e,n){var r=e.distance(t),i=r/(r+e.distance(n)),o=n.x-t.x,s=n.y-t.y;return new ul(t.x+i*o,t.y+i*s);},Bp.area3D=function(t,e,n){var r=e.x-t.x,i=e.y-t.y,o=e.z-t.z,s=n.x-t.x,a=n.y-t.y,u=n.z-t.z,l=i*u-o*a,c=o*s-r*u,h=r*a-i*s,p=l*l+c*c+h*h,f=Math.sqrt(p)/2;return f;},Bp.centroid=function(t,e,n){var r=(t.x+e.x+n.x)/3,i=(t.y+e.y+n.y)/3;return new ul(r,i);},Bp.inCentre=function(t,e,n){var r=e.distance(n),i=t.distance(n),o=t.distance(e),s=r+i+o,a=(r*t.x+i*e.x+o*n.x)/s,u=(r*t.y+i*e.y+o*n.y)/s;return new ul(a,u);};var zp=function zp(){this._inputGeom=null,this._distance=null,this._curveBuilder=null,this._curveList=new lc();var t=arguments[0],e=arguments[1],n=arguments[2];this._inputGeom=t,this._distance=e,this._curveBuilder=n;};zp.prototype.addPoint=function(t){if(this._distance<=0)return null;var e=t.getCoordinates(),n=this._curveBuilder.getLineCurve(e,this._distance);this.addCurve(n,pl.EXTERIOR,pl.INTERIOR);},zp.prototype.addPolygon=function(t){var e=this,n=this._distance,r=Sh.LEFT;this._distance<0&&(n=-this._distance,r=Sh.RIGHT);var i=t.getExteriorRing(),o=pc.removeRepeatedPoints(i.getCoordinates());if(this._distance<0&&this.isErodedCompletely(i,this._distance))return null;if(this._distance<=0&&o.length<3)return null;this.addPolygonRing(o,n,r,pl.EXTERIOR,pl.INTERIOR);for(var s=0;s0&&e.isErodedCompletely(a,-e._distance)||e.addPolygonRing(u,n,Sh.opposite(r),pl.INTERIOR,pl.EXTERIOR);}},zp.prototype.isTriangleErodedCompletely=function(t,e){var n=new Bp(t[0],t[1],t[2]),r=n.inCentre();return Xl.distancePointLine(r,n.p0,n.p1)=nh.MINIMUM_VALID_SIZE&&Xl.isCCW(t)&&(o=i,s=r,n=Sh.opposite(n));var a=this._curveBuilder.getRingCurve(t,n,e);this.addCurve(a,o,s);},zp.prototype.add=function(t){if(t.isEmpty())return null;t instanceof th?this.addPolygon(t):t instanceof Zc?this.addLineString(t):t instanceof Qc?this.addPoint(t):(t instanceof eh||t instanceof Gc||t instanceof rh||t instanceof kc)&&this.addCollection(t);},zp.prototype.isErodedCompletely=function(t,e){var n=t.getCoordinates();if(n.length<4)return e<0;if(4===n.length)return this.isTriangleErodedCompletely(n,e);var r=t.getEnvelopeInternal(),i=Math.min(r.getHeight(),r.getWidth());return e<0&&2*Math.abs(e)>i;},zp.prototype.addCollection=function(t){for(var e=0;e=this._max)throw new uc();var t=this._parent.getGeometryN(this._index++);return t instanceof kc?(this._subcollectionIterator=new Up(t),this._subcollectionIterator.next()):t;},Up.prototype.remove=function(){throw new Error(this.getClass().getName());},Up.prototype.hasNext=function(){if(this._atStart)return!0;if(null!==this._subcollectionIterator){if(this._subcollectionIterator.hasNext())return!0;this._subcollectionIterator=null;}return!(this._index>=this._max);},Up.prototype.interfaces_=function(){return[sc];},Up.prototype.getClass=function(){return Up;},Up.isAtomic=function(t){return!(t instanceof kc);};var Vp=function Vp(){this._geom=null;var t=arguments[0];this._geom=t;};Vp.prototype.locate=function(t){return Vp.locate(t,this._geom);},Vp.prototype.interfaces_=function(){return[jp];},Vp.prototype.getClass=function(){return Vp;},Vp.isPointInRing=function(t,e){return!!e.getEnvelopeInternal().intersects(t)&&Xl.isPointInRing(t,e.getCoordinates());},Vp.containsPointInPolygon=function(t,e){if(e.isEmpty())return!1;var n=e.getExteriorRing();if(!Vp.isPointInRing(t,n))return!1;for(var r=0;r=0;n--){var r=this._edgeList.get(n),i=r.getSym();null===e&&(e=i),null!==t&&i.setNext(t),t=r;}e.setNext(t);},e.prototype.computeDepths=function(){var t=this;if(1===arguments.length){var e=arguments[0],n=this.findIndex(e),r=e.getDepth(Sh.LEFT),i=e.getDepth(Sh.RIGHT),o=this.computeDepths(n+1,this._edgeList.size(),r),s=this.computeDepths(0,n,o);if(s!==i)throw new Oh("depth mismatch at "+e.getCoordinate());}else if(3===arguments.length){for(var a=arguments[0],u=arguments[1],l=arguments[2],c=l,h=a;h=0;o--){var s=e._resultAreaEdgeList.get(o),a=s.getSym();switch(null===n&&s.getEdgeRing()===t&&(n=s),i){case e._SCANNING_FOR_INCOMING:if(a.getEdgeRing()!==t)continue;r=a,i=e._LINKING_TO_OUTGOING;break;case e._LINKING_TO_OUTGOING:if(s.getEdgeRing()!==t)continue;r.setNextMin(s),i=e._SCANNING_FOR_INCOMING;}}i===this._LINKING_TO_OUTGOING&&(ql.isTrue(null!==n,"found null for first outgoing dirEdge"),ql.isTrue(n.getEdgeRing()===t,"unable to link last incoming dirEdge"),r.setNextMin(n));},e.prototype.getOutgoingDegree=function(){if(0===arguments.length){for(var t=0,e=this.iterator();e.hasNext();){var n=e.next();n.isInResult()&&t++;}return t;}if(1===arguments.length){for(var r=arguments[0],i=0,o=this.iterator();o.hasNext();){var s=o.next();s.getEdgeRing()===r&&i++;}return i;}},e.prototype.getLabel=function(){return this._label;},e.prototype.findCoveredLineEdges=function(){for(var t=pl.NONE,e=this.iterator();e.hasNext();){var n=e.next(),r=n.getSym();if(!n.isLineEdge()){if(n.isInResult()){t=pl.INTERIOR;break;}if(r.isInResult()){t=pl.EXTERIOR;break;}}}if(t===pl.NONE)return null;for(var i=t,o=this.iterator();o.hasNext();){var s=o.next(),a=s.getSym();s.isLineEdge()?s.getEdge().setCovered(i===pl.INTERIOR):(s.isInResult()&&(i=pl.EXTERIOR),a.isInResult()&&(i=pl.INTERIOR));}},e.prototype.computeLabelling=function(e){t.prototype.computeLabelling.call(this,e),this._label=new Dh(pl.NONE);for(var n=this.iterator();n.hasNext();)for(var r=n.next().getEdge().getLabel(),i=0;i<2;i++){var o=r.getLocation(i);o!==pl.INTERIOR&&o!==pl.BOUNDARY||this._label.setLocation(i,pl.INTERIOR);}},e.prototype.interfaces_=function(){return[];},e.prototype.getClass=function(){return e;},e;}(Xp),Hp=function(t){function e(){t.apply(this,arguments);}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.createNode=function(t){return new Bh(t,new Yp());},e.prototype.interfaces_=function(){return[];},e.prototype.getClass=function(){return e;},e;}(Yh),Wp=function t(){this._pts=null,this._orientation=null;var e=arguments[0];this._pts=e,this._orientation=t.orientation(e);};Wp.prototype.compareTo=function(t){var e=t;return Wp.compareOriented(this._pts,this._orientation,e._pts,e._orientation);},Wp.prototype.interfaces_=function(){return[il];},Wp.prototype.getClass=function(){return Wp;},Wp.orientation=function(t){return 1===pc.increasingDirection(t);},Wp.compareOriented=function(t,e,n,r){for(var i=e?1:-1,o=r?1:-1,s=e?t.length:-1,a=r?n.length:-1,u=e?0:t.length-1,l=r?0:n.length-1;;){var c=t[u].compareTo(n[l]);if(0!==c)return c;var h=(u+=i)===s,p=(l+=o)===a;if(h&&!p)return-1;if(!h&&p)return 1;if(h&&p)return 0;}};var Jp=function Jp(){this._edges=new lc(),this._ocaMap=new Cc();};Jp.prototype.print=function(t){t.print("MULTILINESTRING ( ");for(var e=0;e0&&t.print(","),t.print("(");for(var r=n.getCoordinates(),i=0;i0&&t.print(","),t.print(r[i].x+" "+r[i].y);t.println(")");}t.print(") ");},Jp.prototype.addAll=function(t){for(var e=t.iterator();e.hasNext();)this.add(e.next());},Jp.prototype.findEdgeIndex=function(t){for(var e=0;e0||!e.coord.equals2D(r);i||n--;var o=new Array(n).fill(null),s=0;o[s++]=new ul(t.coord);for(var a=t.segmentIndex+1;a<=e.segmentIndex;a++)o[s++]=this.edge.pts[a];return i&&(o[s]=e.coord),new of(o,new Dh(this.edge._label));},$p.prototype.add=function(t,e,n){var r=new Qp(t,e,n),i=this._nodeMap.get(r);return null!==i?i:(this._nodeMap.put(r,r),r);},$p.prototype.isIntersection=function(t){for(var e=this.iterator();e.hasNext();){if(e.next().coord.equals(t))return!0;}return!1;},$p.prototype.interfaces_=function(){return[];},$p.prototype.getClass=function(){return $p;};var tf=function tf(){};tf.prototype.getChainStartIndices=function(t){var e=0,n=new lc();n.add(new _l(e));do{var r=this.findChainEnd(t,e);n.add(new _l(r)),e=r;}while(en?e:n;},ef.prototype.getMinX=function(t){var e=this.pts[this.startIndex[t]].x,n=this.pts[this.startIndex[t+1]].x;return en&&(i=1),t._depth[e][r]=i;}}},nf.prototype.getDelta=function(t){return this._depth[t][Sh.RIGHT]-this._depth[t][Sh.LEFT];},nf.prototype.getLocation=function(t,e){return this._depth[t][e]<=0?pl.EXTERIOR:pl.INTERIOR;},nf.prototype.toString=function(){return"A: "+this._depth[0][1]+","+this._depth[0][2]+" B: "+this._depth[1][1]+","+this._depth[1][2];},nf.prototype.add=function(){var t=this;if(1===arguments.length)for(var e=arguments[0],n=0;n<2;n++)for(var r=1;r<3;r++){var i=e.getLocation(n,r);i!==pl.EXTERIOR&&i!==pl.INTERIOR||(t.isNull(n,r)?t._depth[n][r]=nf.depthAtLocation(i):t._depth[n][r]+=nf.depthAtLocation(i));}else if(3===arguments.length){var o=arguments[0],s=arguments[1],a=arguments[2];a===pl.INTERIOR&&this._depth[o][s]++;}},nf.prototype.interfaces_=function(){return[];},nf.prototype.getClass=function(){return nf;},nf.depthAtLocation=function(t){return t===pl.EXTERIOR?0:t===pl.INTERIOR?1:nf.NULL_VALUE;},rf.NULL_VALUE.get=function(){return-1;},Object.defineProperties(nf,rf);var of=function(t){function e(){if(t.call(this),this.pts=null,this._env=null,this.eiList=new $p(this),this._name=null,this._mce=null,this._isIsolated=!0,this._depth=new nf(),this._depthDelta=0,1===arguments.length){var n=arguments[0];e.call(this,n,null);}else if(2===arguments.length){var r=arguments[0],i=arguments[1];this.pts=r,this._label=i;}}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.getDepth=function(){return this._depth;},e.prototype.getCollapsedEdge=function(){var t=new Array(2).fill(null);return t[0]=this.pts[0],t[1]=this.pts[1],new e(t,Dh.toLineLabel(this._label));},e.prototype.isIsolated=function(){return this._isIsolated;},e.prototype.getCoordinates=function(){return this.pts;},e.prototype.setIsolated=function(t){this._isIsolated=t;},e.prototype.setName=function(t){this._name=t;},e.prototype.equals=function(t){if(!(t instanceof e))return!1;var n=t;if(this.pts.length!==n.pts.length)return!1;for(var r=!0,i=!0,o=this.pts.length,s=0;s0?this.pts[0]:null;if(1===arguments.length){var t=arguments[0];return this.pts[t];}},e.prototype.print=function(t){t.print("edge "+this._name+": "),t.print("LINESTRING (");for(var e=0;e0&&t.print(","),t.print(this.pts[e].x+" "+this.pts[e].y);t.print(") "+this._label+" "+this._depthDelta);},e.prototype.computeIM=function(t){e.updateIM(this._label,t);},e.prototype.isCollapsed=function(){return!!this._label.isArea()&&3===this.pts.length&&!!this.pts[0].equals(this.pts[2]);},e.prototype.isClosed=function(){return this.pts[0].equals(this.pts[this.pts.length-1]);},e.prototype.getMaximumSegmentIndex=function(){return this.pts.length-1;},e.prototype.getDepthDelta=function(){return this._depthDelta;},e.prototype.getNumPoints=function(){return this.pts.length;},e.prototype.printReverse=function(t){t.print("edge "+this._name+": ");for(var e=this.pts.length-1;e>=0;e--)t.print(this.pts[e]+" ");t.println("");},e.prototype.getMonotoneChainEdge=function(){return null===this._mce&&(this._mce=new ef(this)),this._mce;},e.prototype.getEnvelope=function(){if(null===this._env){this._env=new Ll();for(var t=0;t0&&t.append(","),t.append(this.pts[e].x+" "+this.pts[e].y);return t.append(") "+this._label+" "+this._depthDelta),t.toString();},e.prototype.isPointwiseEqual=function(t){if(this.pts.length!==t.pts.length)return!1;for(var e=0;er||this._maxyo;if(s)return!1;var a=this.intersectsToleranceSquare(t,e);return ql.isTrue(!(s&&a),"Found bad envelope test"),a;},cf.prototype.initCorners=function(t){var e=.5;this._minx=t.x-e,this._maxx=t.x+e,this._miny=t.y-e,this._maxy=t.y+e,this._corner[0]=new ul(this._maxx,this._maxy),this._corner[1]=new ul(this._minx,this._maxy),this._corner[2]=new ul(this._minx,this._miny),this._corner[3]=new ul(this._maxx,this._miny);},cf.prototype.intersects=function(t,e){return 1===this._scaleFactor?this.intersectsScaled(t,e):(this.copyScaled(t,this._p0Scaled),this.copyScaled(e,this._p1Scaled),this.intersectsScaled(this._p0Scaled,this._p1Scaled));},cf.prototype.scale=function(t){return Math.round(t*this._scaleFactor);},cf.prototype.getCoordinate=function(){return this._originalPt;},cf.prototype.copyScaled=function(t,e){e.x=this.scale(t.x),e.y=this.scale(t.y);},cf.prototype.getSafeEnvelope=function(){if(null===this._safeEnv){var t=cf.SAFE_ENV_EXPANSION_FACTOR/this._scaleFactor;this._safeEnv=new Ll(this._originalPt.x-t,this._originalPt.x+t,this._originalPt.y-t,this._originalPt.y+t);}return this._safeEnv;},cf.prototype.intersectsPixelClosure=function(t,e){return this._li.computeIntersection(t,e,this._corner[0],this._corner[1]),!!this._li.hasIntersection()||(this._li.computeIntersection(t,e,this._corner[1],this._corner[2]),!!this._li.hasIntersection()||(this._li.computeIntersection(t,e,this._corner[2],this._corner[3]),!!this._li.hasIntersection()||(this._li.computeIntersection(t,e,this._corner[3],this._corner[0]),!!this._li.hasIntersection())));},cf.prototype.intersectsToleranceSquare=function(t,e){var n=!1,r=!1;return this._li.computeIntersection(t,e,this._corner[0],this._corner[1]),!!this._li.isProper()||(this._li.computeIntersection(t,e,this._corner[1],this._corner[2]),!!this._li.isProper()||(this._li.hasIntersection()&&(n=!0),this._li.computeIntersection(t,e,this._corner[2],this._corner[3]),!!this._li.isProper()||(this._li.hasIntersection()&&(r=!0),this._li.computeIntersection(t,e,this._corner[3],this._corner[0]),!!this._li.isProper()||!(!n||!r)||!!t.equals(this._pt)||!!e.equals(this._pt))));},cf.prototype.addSnappedNode=function(t,e){var n=t.getCoordinate(e),r=t.getCoordinate(e+1);return!!this.intersects(n,r)&&(t.addIntersection(this.getCoordinate(),e),!0);},cf.prototype.interfaces_=function(){return[];},cf.prototype.getClass=function(){return cf;},hf.SAFE_ENV_EXPANSION_FACTOR.get=function(){return .75;},Object.defineProperties(cf,hf);var pf=function pf(){this.tempEnv1=new Ll(),this.selectedSegment=new vp();};pf.prototype.select=function(){if(1===arguments.length);else if(2===arguments.length){var t=arguments[0],e=arguments[1];t.getLineSegment(e,this.selectedSegment),this.select(this.selectedSegment);}},pf.prototype.interfaces_=function(){return[];},pf.prototype.getClass=function(){return pf;};var ff=function ff(){this._index=null;var t=arguments[0];this._index=t;},gf={HotPixelSnapAction:{configurable:!0}};ff.prototype.snap=function(){if(1===arguments.length){var t=arguments[0];return this.snap(t,null,-1);}if(3===arguments.length){var e=arguments[0],n=arguments[1],r=arguments[2],i=e.getSafeEnvelope(),o=new df(e,n,r);return this._index.query(i,{interfaces_:function interfaces_(){return[Qh];},visitItem:function visitItem(t){t.select(i,o);}}),o.isNodeAdded();}},ff.prototype.interfaces_=function(){return[];},ff.prototype.getClass=function(){return ff;},gf.HotPixelSnapAction.get=function(){return df;},Object.defineProperties(ff,gf);var df=function(t){function e(){t.call(this),this._hotPixel=null,this._parentEdge=null,this._hotPixelVertexIndex=null,this._isNodeAdded=!1;var e=arguments[0],n=arguments[1],r=arguments[2];this._hotPixel=e,this._parentEdge=n,this._hotPixelVertexIndex=r;}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.isNodeAdded=function(){return this._isNodeAdded;},e.prototype.select=function(){if(2!==arguments.length)return t.prototype.select.apply(this,arguments);var e=arguments[0],n=arguments[1],r=e.getContext();if(null!==this._parentEdge&&r===this._parentEdge&&n===this._hotPixelVertexIndex)return null;this._isNodeAdded=this._hotPixel.addSnappedNode(r,n);},e.prototype.interfaces_=function(){return[];},e.prototype.getClass=function(){return e;},e;}(pf),yf=function yf(){this._li=null,this._interiorIntersections=null;var t=arguments[0];this._li=t,this._interiorIntersections=new lc();};yf.prototype.processIntersections=function(t,e,n,r){if(t===n&&e===r)return null;var i=t.getCoordinates()[e],o=t.getCoordinates()[e+1],s=n.getCoordinates()[r],a=n.getCoordinates()[r+1];if(this._li.computeIntersection(i,o,s,a),this._li.hasIntersection()&&this._li.isInteriorIntersection()){for(var u=0;u=0;e--){try{t.bufferReducedPrecision(e);}catch(e){if(!(e instanceof Oh))throw e;t._saveException=e;}if(null!==t._resultGeometry)return null;}throw this._saveException;}if(1===arguments.length){var n=arguments[0],r=_f.precisionScaleFactor(this._argGeom,this._distance,n),i=new gh(r);this.bufferFixedPrecision(i);}},_f.prototype.computeGeometry=function(){if(this.bufferOriginalPrecision(),null!==this._resultGeometry)return null;var t=this._argGeom.getFactory().getPrecisionModel();t.getType()===gh.FIXED?this.bufferFixedPrecision(t):this.bufferReducedPrecision();},_f.prototype.setQuadrantSegments=function(t){this._bufParams.setQuadrantSegments(t);},_f.prototype.bufferOriginalPrecision=function(){try{var t=new sf(this._bufParams);this._resultGeometry=t.buffer(this._argGeom,this._distance);}catch(t){if(!(t instanceof kl))throw t;this._saveException=t;}},_f.prototype.getResultGeometry=function(t){return this._distance=t,this.computeGeometry(),this._resultGeometry;},_f.prototype.setEndCapStyle=function(t){this._bufParams.setEndCapStyle(t);},_f.prototype.interfaces_=function(){return[];},_f.prototype.getClass=function(){return _f;},_f.bufferOp=function(){if(2===arguments.length){var t=arguments[0],e=arguments[1],n=new _f(t),r=n.getResultGeometry(e);return r;}if(3===arguments.length){if(Number.isInteger(arguments[2])&&arguments[0]instanceof Wl&&"number"==typeof arguments[1]){var i=arguments[0],o=arguments[1],s=arguments[2],a=new _f(i);a.setQuadrantSegments(s);var u=a.getResultGeometry(o);return u;}if(arguments[2]instanceof Sp&&arguments[0]instanceof Wl&&"number"==typeof arguments[1]){var l=arguments[0],c=arguments[1],h=arguments[2],p=new _f(l,h),f=p.getResultGeometry(c);return f;}}else if(4===arguments.length){var g=arguments[0],d=arguments[1],y=arguments[2],v=arguments[3],_=new _f(g);_.setQuadrantSegments(y),_.setEndCapStyle(v);var m=_.getResultGeometry(d);return m;}},_f.precisionScaleFactor=function(t,e,n){var r=t.getEnvelopeInternal(),i=dl.max(Math.abs(r.getMaxX()),Math.abs(r.getMaxY()),Math.abs(r.getMinX()),Math.abs(r.getMinY()))+2*(e>0?e:0),o=n-Math.trunc(Math.log(i)/Math.log(10)+1);return Math.pow(10,o);},mf.CAP_ROUND.get=function(){return Sp.CAP_ROUND;},mf.CAP_BUTT.get=function(){return Sp.CAP_FLAT;},mf.CAP_FLAT.get=function(){return Sp.CAP_FLAT;},mf.CAP_SQUARE.get=function(){return Sp.CAP_SQUARE;},mf.MAX_PRECISION_DIGITS.get=function(){return 12;},Object.defineProperties(_f,mf);var xf=function xf(){this._pt=[new ul(),new ul()],this._distance=nl.NaN,this._isNull=!0;};xf.prototype.getCoordinates=function(){return this._pt;},xf.prototype.getCoordinate=function(t){return this._pt[t];},xf.prototype.setMinimum=function(){if(1===arguments.length){var t=arguments[0];this.setMinimum(t._pt[0],t._pt[1]);}else if(2===arguments.length){var e=arguments[0],n=arguments[1];if(this._isNull)return this.initialize(e,n),null;var r=e.distance(n);rthis._distance&&this.initialize(e,n,r);}},xf.prototype.interfaces_=function(){return[];},xf.prototype.getClass=function(){return xf;};var Ef=function Ef(){};Ef.prototype.interfaces_=function(){return[];},Ef.prototype.getClass=function(){return Ef;},Ef.computeDistance=function(){if(arguments[2]instanceof xf&&arguments[0]instanceof Zc&&arguments[1]instanceof ul)for(var t=arguments[0],e=arguments[1],n=arguments[2],r=t.getCoordinates(),i=new vp(),o=0;o0||this._isIn?pl.INTERIOR:pl.EXTERIOR);},Pf.prototype.interfaces_=function(){return[];},Pf.prototype.getClass=function(){return Pf;};var Mf=function t(){if(this._component=null,this._segIndex=null,this._pt=null,2===arguments.length){var e=arguments[0],n=arguments[1];t.call(this,e,t.INSIDE_AREA,n);}else if(3===arguments.length){var r=arguments[0],i=arguments[1],o=arguments[2];this._component=r,this._segIndex=i,this._pt=o;}},Lf={INSIDE_AREA:{configurable:!0}};Mf.prototype.isInsideArea=function(){return this._segIndex===Mf.INSIDE_AREA;},Mf.prototype.getCoordinate=function(){return this._pt;},Mf.prototype.getGeometryComponent=function(){return this._component;},Mf.prototype.getSegmentIndex=function(){return this._segIndex;},Mf.prototype.interfaces_=function(){return[];},Mf.prototype.getClass=function(){return Mf;},Lf.INSIDE_AREA.get=function(){return-1;},Object.defineProperties(Mf,Lf);var Of=function Of(t){this._pts=t||null;};Of.prototype.filter=function(t){t instanceof Qc&&this._pts.add(t);},Of.prototype.interfaces_=function(){return[Dc];},Of.prototype.getClass=function(){return Of;},Of.getPoints=function(){if(1===arguments.length){var t=arguments[0];return t instanceof Qc?np.singletonList(t):Of.getPoints(t,new lc());}if(2===arguments.length){var e=arguments[0],n=arguments[1];return e instanceof Qc?n.add(e):e instanceof kc&&e.apply(new Of(n)),n;}};var Rf=function Rf(){this._locations=null;var t=arguments[0];this._locations=t;};Rf.prototype.filter=function(t){(t instanceof Qc||t instanceof Zc||t instanceof th)&&this._locations.add(new Mf(t,0,t.getCoordinate()));},Rf.prototype.interfaces_=function(){return[Dc];},Rf.prototype.getClass=function(){return Rf;},Rf.getLocations=function(t){var e=new lc();return t.apply(new Rf(e)),e;};var Tf=function Tf(){if(this._geom=null,this._terminateDistance=0,this._ptLocator=new Pf(),this._minDistanceLocation=null,this._minDistance=nl.MAX_VALUE,2===arguments.length){var t=arguments[0],e=arguments[1];this._geom=[t,e],this._terminateDistance=0;}else if(3===arguments.length){var n=arguments[0],r=arguments[1],i=arguments[2];this._geom=new Array(2).fill(null),this._geom[0]=n,this._geom[1]=r,this._terminateDistance=i;}};Tf.prototype.computeContainmentDistance=function(){var t=this;if(0===arguments.length){var e=new Array(2).fill(null);if(this.computeContainmentDistance(0,e),this._minDistance<=this._terminateDistance)return null;this.computeContainmentDistance(1,e);}else if(2===arguments.length){var n=arguments[0],r=arguments[1],i=1-n,o=Sf.getPolygons(this._geom[n]);if(o.size()>0){var s=Rf.getLocations(this._geom[i]);if(this.computeContainmentDistance(s,o,r),this._minDistance<=this._terminateDistance)return this._minDistanceLocation[i]=r[0],this._minDistanceLocation[n]=r[1],null;}}else if(3===arguments.length)if(arguments[2]instanceof Array&&gl(arguments[0],ac)&&gl(arguments[1],ac)){for(var a=arguments[0],u=arguments[1],l=arguments[2],c=0;cthis._minDistance)return null;for(var i=e.getCoordinates(),o=n.getCoordinate(),s=0;sthis._minDistance)return null;for(var f=c.getCoordinates(),g=h.getCoordinates(),d=0;dthis._distance&&this.initialize(e,n,r);}},Af.prototype.interfaces_=function(){return[];},Af.prototype.getClass=function(){return Af;};var Df=function Df(){};Df.prototype.interfaces_=function(){return[];},Df.prototype.getClass=function(){return Df;},Df.computeDistance=function(){if(arguments[2]instanceof Af&&arguments[0]instanceof Zc&&arguments[1]instanceof ul)for(var t=arguments[0],e=arguments[1],n=arguments[2],r=new vp(),i=t.getCoordinates(),o=0;o1||t<=0)throw new el("Fraction is not in range (0.0 - 1.0]");this._densifyFrac=t;},Ff.prototype.compute=function(t,e){this.computeOrientedDistance(t,e,this._ptDist),this.computeOrientedDistance(e,t,this._ptDist);},Ff.prototype.distance=function(){return this.compute(this._g0,this._g1),this._ptDist.getDistance();},Ff.prototype.computeOrientedDistance=function(t,e,n){var r=new Gf(e);if(t.apply(r),n.setMaximum(r.getMaxPointDistance()),this._densifyFrac>0){var i=new qf(e,this._densifyFrac);t.apply(i),n.setMaximum(i.getMaxPointDistance());}},Ff.prototype.orientedDistance=function(){return this.computeOrientedDistance(this._g0,this._g1,this._ptDist),this._ptDist.getDistance();},Ff.prototype.interfaces_=function(){return[];},Ff.prototype.getClass=function(){return Ff;},Ff.distance=function(){if(2===arguments.length){var t=arguments[0],e=arguments[1],n=new Ff(t,e);return n.distance();}if(3===arguments.length){var r=arguments[0],i=arguments[1],o=arguments[2],s=new Ff(r,i);return s.setDensifyFraction(o),s.distance();}},kf.MaxPointDistanceFilter.get=function(){return Gf;},kf.MaxDensifiedByFractionDistanceFilter.get=function(){return qf;},Object.defineProperties(Ff,kf);var Gf=function Gf(){this._maxPtDist=new Af(),this._minPtDist=new Af(),this._euclideanDist=new Df(),this._geom=null;var t=arguments[0];this._geom=t;};Gf.prototype.filter=function(t){this._minPtDist.initialize(),Df.computeDistance(this._geom,t,this._minPtDist),this._maxPtDist.setMaximum(this._minPtDist);},Gf.prototype.getMaxPointDistance=function(){return this._maxPtDist;},Gf.prototype.interfaces_=function(){return[Kl];},Gf.prototype.getClass=function(){return Gf;};var qf=function qf(){this._maxPtDist=new Af(),this._minPtDist=new Af(),this._geom=null,this._numSubSegs=0;var t=arguments[0],e=arguments[1];this._geom=t,this._numSubSegs=Math.trunc(Math.round(1/e));};qf.prototype.filter=function(t,e){var n=this;if(0===e)return null;for(var r=t.getCoordinate(e-1),i=t.getCoordinate(e),o=(i.x-r.x)/this._numSubSegs,s=(i.y-r.y)/this._numSubSegs,a=0;an){this._isValid=!1;var i=r.getCoordinates();this._errorLocation=i[1],this._errorIndicator=t.getFactory().createLineString(i),this._errMsg="Distance between buffer curve and input is too large ("+this._maxDistanceFound+" at "+Fl.toLineString(i[0],i[1])+")";}},Bf.prototype.isValid=function(){var t=Math.abs(this._bufDistance),e=Bf.MAX_DISTANCE_DIFF_FRAC*t;return this._minValidDistance=t-e,this._maxValidDistance=t+e,!(!this._input.isEmpty()&&!this._result.isEmpty())||(this._bufDistance>0?this.checkPositiveValid():this.checkNegativeValid(),Bf.VERBOSE&&Pl.out.println("Min Dist= "+this._minDistanceFound+" err= "+(1-this._minDistanceFound/this._bufDistance)+" Max Dist= "+this._maxDistanceFound+" err= "+(this._maxDistanceFound/this._bufDistance-1)),this._isValid);},Bf.prototype.checkNegativeValid=function(){if(!(this._input instanceof th||this._input instanceof rh||this._input instanceof kc))return null;var t=this.getPolygonLines(this._input);if(this.checkMinimumDistance(t,this._result,this._minValidDistance),!this._isValid)return null;this.checkMaximumDistance(t,this._result,this._maxValidDistance);},Bf.prototype.getErrorIndicator=function(){return this._errorIndicator;},Bf.prototype.checkMinimumDistance=function(t,e,n){var r=new Tf(t,e,n);if(this._minDistanceFound=r.distance(),this._minDistanceFound0&&t>e&&(this._isValid=!1,this._errorMsg="Area of positive buffer is smaller than input",this._errorIndicator=this._result),this._distance<0&&t=2||this._distance>0?null:(this._result.isEmpty()||(this._isValid=!1,this._errorMsg="Result is non-empty",this._errorIndicator=this._result),void this.report("ExpectedEmpty"));},jf.prototype.report=function(t){if(!jf.VERBOSE)return null;Pl.out.println("Check "+t+": "+(this._isValid?"passed":"FAILED"));},jf.prototype.getErrorMessage=function(){return this._errorMsg;},jf.prototype.interfaces_=function(){return[];},jf.prototype.getClass=function(){return jf;},jf.isValidMsg=function(t,e,n){var r=new jf(t,e,n);return r.isValid()?null:r.getErrorMessage();},jf.isValid=function(t,e,n){return!!new jf(t,e,n).isValid();},Uf.VERBOSE.get=function(){return!1;},Uf.MAX_ENV_DIFF_FRAC.get=function(){return .012;},Object.defineProperties(jf,Uf);var Vf=function Vf(){this._pts=null,this._data=null;var t=arguments[0],e=arguments[1];this._pts=t,this._data=e;};Vf.prototype.getCoordinates=function(){return this._pts;},Vf.prototype.size=function(){return this._pts.length;},Vf.prototype.getCoordinate=function(t){return this._pts[t];},Vf.prototype.isClosed=function(){return this._pts[0].equals(this._pts[this._pts.length-1]);},Vf.prototype.getSegmentOctant=function(t){return t===this._pts.length-1?-1:fp.octant(this.getCoordinate(t),this.getCoordinate(t+1));},Vf.prototype.setData=function(t){this._data=t;},Vf.prototype.getData=function(){return this._data;},Vf.prototype.toString=function(){return Fl.toLineString(new lh(this._pts));},Vf.prototype.interfaces_=function(){return[gp];},Vf.prototype.getClass=function(){return Vf;};var Xf=function Xf(){this._findAllIntersections=!1,this._isCheckEndSegmentsOnly=!1,this._li=null,this._interiorIntersection=null,this._intSegments=null,this._intersections=new lc(),this._intersectionCount=0,this._keepIntersections=!0;var t=arguments[0];this._li=t,this._interiorIntersection=null;};Xf.prototype.getInteriorIntersection=function(){return this._interiorIntersection;},Xf.prototype.setCheckEndSegmentsOnly=function(t){this._isCheckEndSegmentsOnly=t;},Xf.prototype.getIntersectionSegments=function(){return this._intSegments;},Xf.prototype.count=function(){return this._intersectionCount;},Xf.prototype.getIntersections=function(){return this._intersections;},Xf.prototype.setFindAllIntersections=function(t){this._findAllIntersections=t;},Xf.prototype.setKeepIntersections=function(t){this._keepIntersections=t;},Xf.prototype.processIntersections=function(t,e,n,r){if(!this._findAllIntersections&&this.hasIntersection())return null;if(t===n&&e===r)return null;if(this._isCheckEndSegmentsOnly&&!(this.isEndSegment(t,e)||this.isEndSegment(n,r)))return null;var i=t.getCoordinates()[e],o=t.getCoordinates()[e+1],s=n.getCoordinates()[r],a=n.getCoordinates()[r+1];this._li.computeIntersection(i,o,s,a),this._li.hasIntersection()&&this._li.isInteriorIntersection()&&(this._intSegments=new Array(4).fill(null),this._intSegments[0]=i,this._intSegments[1]=o,this._intSegments[2]=s,this._intSegments[3]=a,this._interiorIntersection=this._li.getIntersection(0),this._keepIntersections&&this._intersections.add(this._interiorIntersection),this._intersectionCount++);},Xf.prototype.isEndSegment=function(t,e){return 0===e||e>=t.size()-2;},Xf.prototype.hasIntersection=function(){return null!==this._interiorIntersection;},Xf.prototype.isDone=function(){return!this._findAllIntersections&&null!==this._interiorIntersection;},Xf.prototype.interfaces_=function(){return[Zp];},Xf.prototype.getClass=function(){return Xf;},Xf.createAllIntersectionsFinder=function(t){var e=new Xf(t);return e.setFindAllIntersections(!0),e;},Xf.createAnyIntersectionFinder=function(t){return new Xf(t);},Xf.createIntersectionCounter=function(t){var e=new Xf(t);return e.setFindAllIntersections(!0),e.setKeepIntersections(!1),e;};var Yf=function Yf(){this._li=new jl(),this._segStrings=null,this._findAllIntersections=!1,this._segInt=null,this._isValid=!0;var t=arguments[0];this._segStrings=t;};Yf.prototype.execute=function(){if(null!==this._segInt)return null;this.checkInteriorIntersections();},Yf.prototype.getIntersections=function(){return this._segInt.getIntersections();},Yf.prototype.isValid=function(){return this.execute(),this._isValid;},Yf.prototype.setFindAllIntersections=function(t){this._findAllIntersections=t;},Yf.prototype.checkInteriorIntersections=function(){this._isValid=!0,this._segInt=new Xf(this._li),this._segInt.setFindAllIntersections(this._findAllIntersections);var t=new Ip();if(t.setSegmentIntersector(this._segInt),t.computeNodes(this._segStrings),this._segInt.hasIntersection())return this._isValid=!1,null;},Yf.prototype.checkValid=function(){if(this.execute(),!this._isValid)throw new Oh(this.getErrorMessage(),this._segInt.getInteriorIntersection());},Yf.prototype.getErrorMessage=function(){if(this._isValid)return"no intersections found";var t=this._segInt.getIntersectionSegments();return"found non-noded intersection between "+Fl.toLineString(t[0],t[1])+" and "+Fl.toLineString(t[2],t[3]);},Yf.prototype.interfaces_=function(){return[];},Yf.prototype.getClass=function(){return Yf;},Yf.computeIntersections=function(t){var e=new Yf(t);return e.setFindAllIntersections(!0),e.isValid(),e.getIntersections();};var Hf=function t(){this._nv=null;var e=arguments[0];this._nv=new Yf(t.toSegmentStrings(e));};Hf.prototype.checkValid=function(){this._nv.checkValid();},Hf.prototype.interfaces_=function(){return[];},Hf.prototype.getClass=function(){return Hf;},Hf.toSegmentStrings=function(t){for(var e=new lc(),n=t.iterator();n.hasNext();){var r=n.next();e.add(new Vf(r.getCoordinates(),r));}return e;},Hf.checkValid=function(t){new Hf(t).checkValid();};var Wf=function Wf(t){this._mapOp=t;};Wf.prototype.map=function(t){for(var e=new lc(),n=0;n0&&r<4&&!this._preserveType?this._factory.createLineString(n):this._factory.createLinearRing(n);},Kf.prototype.interfaces_=function(){return[];},Kf.prototype.getClass=function(){return Kf;};var Qf=function t(){if(this._snapTolerance=0,this._srcPts=null,this._seg=new vp(),this._allowSnappingToSourceVertices=!1,this._isClosed=!1,arguments[0]instanceof Zc&&"number"==typeof arguments[1]){var e=arguments[0],n=arguments[1];t.call(this,e.getCoordinates(),n);}else if(arguments[0]instanceof Array&&"number"==typeof arguments[1]){var r=arguments[0],i=arguments[1];this._srcPts=r,this._isClosed=t.isClosed(r),this._snapTolerance=i;}};Qf.prototype.snapVertices=function(t,e){for(var n=this._isClosed?t.size()-1:t.size(),r=0;r=0&&t.add(o+1,new ul(i),!1);}},Qf.prototype.findSegmentIndexToSnap=function(t,e){for(var n=this,r=nl.MAX_VALUE,i=-1,o=0;oe&&(e=r);}return e;}if(2===arguments.length){var i=arguments[0],o=arguments[1];return Math.min($f.computeOverlaySnapTolerance(i),$f.computeOverlaySnapTolerance(o));}},$f.computeSizeBasedSnapTolerance=function(t){var e=t.getEnvelopeInternal();return Math.min(e.getHeight(),e.getWidth())*$f.SNAP_PRECISION_FACTOR;},$f.snapToSelf=function(t,e,n){return new $f(t).snapToSelf(e,n);},tg.SNAP_PRECISION_FACTOR.get=function(){return 1e-9;},Object.defineProperties($f,tg);var eg=function(t){function e(e,n,r){t.call(this),this._snapTolerance=e||null,this._snapPts=n||null,this._isSelfSnap=void 0!==r&&r;}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.snapLine=function(t,e){var n=new Qf(t,this._snapTolerance);return n.setAllowSnappingToSourceVertices(this._isSelfSnap),n.snapTo(e);},e.prototype.transformCoordinates=function(t,e){var n=t.toCoordinateArray(),r=this.snapLine(n,this._snapPts);return this._factory.getCoordinateSequenceFactory().create(r);},e.prototype.interfaces_=function(){return[];},e.prototype.getClass=function(){return e;},e;}(Kf),ng=function ng(){this._isFirst=!0,this._commonMantissaBitsCount=53,this._commonBits=0,this._commonSignExp=null;};ng.prototype.getCommon=function(){return nl.longBitsToDouble(this._commonBits);},ng.prototype.add=function(t){var e=nl.doubleToLongBits(t);return this._isFirst?(this._commonBits=e,this._commonSignExp=ng.signExpBits(this._commonBits),this._isFirst=!1,null):ng.signExpBits(e)!==this._commonSignExp?(this._commonBits=0,null):(this._commonMantissaBitsCount=ng.numCommonMostSigMantissaBits(this._commonBits,e),void(this._commonBits=ng.zeroLowerBits(this._commonBits,64-(12+this._commonMantissaBitsCount))));},ng.prototype.toString=function(){if(1===arguments.length){var t=arguments[0],e=nl.longBitsToDouble(t),n=nl.toBinaryString(t),r="0000000000000000000000000000000000000000000000000000000000000000"+n,i=r.substring(r.length-64),o=i.substring(0,1)+" "+i.substring(1,12)+"(exp) "+i.substring(12)+" [ "+e+" ]";return o;}},ng.prototype.interfaces_=function(){return[];},ng.prototype.getClass=function(){return ng;},ng.getBit=function(t,e){return 0!=(t&1<>52;},ng.zeroLowerBits=function(t,e){return t&~((1<=0;r--){if(ng.getBit(t,r)!==ng.getBit(e,r))return n;n++;}return 52;};var rg=function rg(){this._commonCoord=null,this._ccFilter=new og();},ig={CommonCoordinateFilter:{configurable:!0},Translater:{configurable:!0}};rg.prototype.addCommonBits=function(t){var e=new sg(this._commonCoord);t.apply(e),t.geometryChanged();},rg.prototype.removeCommonBits=function(t){if(0===this._commonCoord.x&&0===this._commonCoord.y)return t;var e=new ul(this._commonCoord);e.x=-e.x,e.y=-e.y;var n=new sg(e);return t.apply(n),t.geometryChanged(),t;},rg.prototype.getCommonCoordinate=function(){return this._commonCoord;},rg.prototype.add=function(t){t.apply(this._ccFilter),this._commonCoord=this._ccFilter.getCommonCoordinate();},rg.prototype.interfaces_=function(){return[];},rg.prototype.getClass=function(){return rg;},ig.CommonCoordinateFilter.get=function(){return og;},ig.Translater.get=function(){return sg;},Object.defineProperties(rg,ig);var og=function og(){this._commonBitsX=new ng(),this._commonBitsY=new ng();};og.prototype.filter=function(t){this._commonBitsX.add(t.x),this._commonBitsY.add(t.y);},og.prototype.getCommonCoordinate=function(){return new ul(this._commonBitsX.getCommon(),this._commonBitsY.getCommon());},og.prototype.interfaces_=function(){return[Kl];},og.prototype.getClass=function(){return og;};var sg=function sg(){this.trans=null;var t=arguments[0];this.trans=t;};sg.prototype.filter=function(t,e){var n=t.getOrdinate(e,0)+this.trans.x,r=t.getOrdinate(e,1)+this.trans.y;t.setOrdinate(e,0,n),t.setOrdinate(e,1,r);},sg.prototype.isDone=function(){return!1;},sg.prototype.isGeometryChanged=function(){return!0;},sg.prototype.interfaces_=function(){return[Fc];},sg.prototype.getClass=function(){return sg;};var ag=function ag(t,e){this._geom=new Array(2).fill(null),this._snapTolerance=null,this._cbr=null,this._geom[0]=t,this._geom[1]=e,this.computeSnapTolerance();};ag.prototype.selfSnap=function(t){return new $f(t).snapTo(t,this._snapTolerance);},ag.prototype.removeCommonBits=function(t){this._cbr=new rg(),this._cbr.add(t[0]),this._cbr.add(t[1]);var e=new Array(2).fill(null);return e[0]=this._cbr.removeCommonBits(t[0].copy()),e[1]=this._cbr.removeCommonBits(t[1].copy()),e;},ag.prototype.prepareResult=function(t){return this._cbr.addCommonBits(t),t;},ag.prototype.getResultGeometry=function(t){var e=this.snap(this._geom),n=Mg.overlayOp(e[0],e[1],t);return this.prepareResult(n);},ag.prototype.checkValid=function(t){t.isValid()||Pl.out.println("Snapped geometry is invalid");},ag.prototype.computeSnapTolerance=function(){this._snapTolerance=$f.computeOverlaySnapTolerance(this._geom[0],this._geom[1]);},ag.prototype.snap=function(t){var e=this.removeCommonBits(t);return $f.snap(e[0],e[1],this._snapTolerance);},ag.prototype.interfaces_=function(){return[];},ag.prototype.getClass=function(){return ag;},ag.overlayOp=function(t,e,n){return new ag(t,e).getResultGeometry(n);},ag.union=function(t,e){return ag.overlayOp(t,e,Mg.UNION);},ag.intersection=function(t,e){return ag.overlayOp(t,e,Mg.INTERSECTION);},ag.symDifference=function(t,e){return ag.overlayOp(t,e,Mg.SYMDIFFERENCE);},ag.difference=function(t,e){return ag.overlayOp(t,e,Mg.DIFFERENCE);};var ug=function ug(t,e){this._geom=new Array(2).fill(null),this._geom[0]=t,this._geom[1]=e;};ug.prototype.getResultGeometry=function(t){var e=null,n=!1,r=null;try{e=Mg.overlayOp(this._geom[0],this._geom[1],t);n=!0;}catch(t){if(!(t instanceof kl))throw t;r=t;}if(!n)try{e=ag.overlayOp(this._geom[0],this._geom[1],t);}catch(t){throw t instanceof kl?r:t;}return e;},ug.prototype.interfaces_=function(){return[];},ug.prototype.getClass=function(){return ug;},ug.overlayOp=function(t,e,n){return new ug(t,e).getResultGeometry(n);},ug.union=function(t,e){return ug.overlayOp(t,e,Mg.UNION);},ug.intersection=function(t,e){return ug.overlayOp(t,e,Mg.INTERSECTION);},ug.symDifference=function(t,e){return ug.overlayOp(t,e,Mg.SYMDIFFERENCE);},ug.difference=function(t,e){return ug.overlayOp(t,e,Mg.DIFFERENCE);};var lg=function lg(){this.mce=null,this.chainIndex=null;var t=arguments[0],e=arguments[1];this.mce=t,this.chainIndex=e;};lg.prototype.computeIntersections=function(t,e){this.mce.computeIntersectsForChain(this.chainIndex,t.mce,t.chainIndex,e);},lg.prototype.interfaces_=function(){return[];},lg.prototype.getClass=function(){return lg;};var cg=function t(){if(this._label=null,this._xValue=null,this._eventType=null,this._insertEvent=null,this._deleteEventIndex=null,this._obj=null,2===arguments.length){var e=arguments[0],n=arguments[1];this._eventType=t.DELETE,this._xValue=e,this._insertEvent=n;}else if(3===arguments.length){var r=arguments[0],i=arguments[1],o=arguments[2];this._eventType=t.INSERT,this._label=r,this._xValue=i,this._obj=o;}},hg={INSERT:{configurable:!0},DELETE:{configurable:!0}};cg.prototype.isDelete=function(){return this._eventType===cg.DELETE;},cg.prototype.setDeleteEventIndex=function(t){this._deleteEventIndex=t;},cg.prototype.getObject=function(){return this._obj;},cg.prototype.compareTo=function(t){var e=t;return this._xValuee._xValue?1:this._eventTypee._eventType?1:0;},cg.prototype.getInsertEvent=function(){return this._insertEvent;},cg.prototype.isInsert=function(){return this._eventType===cg.INSERT;},cg.prototype.isSameLabel=function(t){return null!==this._label&&this._label===t._label;},cg.prototype.getDeleteEventIndex=function(){return this._deleteEventIndex;},cg.prototype.interfaces_=function(){return[il];},cg.prototype.getClass=function(){return cg;},hg.INSERT.get=function(){return 1;},hg.DELETE.get=function(){return 2;},Object.defineProperties(cg,hg);var pg=function pg(){};pg.prototype.interfaces_=function(){return[];},pg.prototype.getClass=function(){return pg;};var fg=function fg(){this._hasIntersection=!1,this._hasProper=!1,this._hasProperInterior=!1,this._properIntersectionPoint=null,this._li=null,this._includeProper=null,this._recordIsolated=null,this._isSelfIntersection=null,this._numIntersections=0,this.numTests=0,this._bdyNodes=null,this._isDone=!1,this._isDoneWhenProperInt=!1;var t=arguments[0],e=arguments[1],n=arguments[2];this._li=t,this._includeProper=e,this._recordIsolated=n;};fg.prototype.isTrivialIntersection=function(t,e,n,r){if(t===n&&1===this._li.getIntersectionNum()){if(fg.isAdjacentSegments(e,r))return!0;if(t.isClosed()){var i=t.getNumPoints()-1;if(0===e&&r===i||0===r&&e===i)return!0;}}return!1;},fg.prototype.getProperIntersectionPoint=function(){return this._properIntersectionPoint;},fg.prototype.setIsDoneIfProperInt=function(t){this._isDoneWhenProperInt=t;},fg.prototype.hasProperInteriorIntersection=function(){return this._hasProperInterior;},fg.prototype.isBoundaryPointInternal=function(t,e){for(var n=e.iterator();n.hasNext();){var r=n.next().getCoordinate();if(t.isIntersection(r))return!0;}return!1;},fg.prototype.hasProperIntersection=function(){return this._hasProper;},fg.prototype.hasIntersection=function(){return this._hasIntersection;},fg.prototype.isDone=function(){return this._isDone;},fg.prototype.isBoundaryPoint=function(t,e){return null!==e&&(!!this.isBoundaryPointInternal(t,e[0])||!!this.isBoundaryPointInternal(t,e[1]));},fg.prototype.setBoundaryNodes=function(t,e){this._bdyNodes=new Array(2).fill(null),this._bdyNodes[0]=t,this._bdyNodes[1]=e;},fg.prototype.addIntersections=function(t,e,n,r){if(t===n&&e===r)return null;this.numTests++;var i=t.getCoordinates()[e],o=t.getCoordinates()[e+1],s=n.getCoordinates()[r],a=n.getCoordinates()[r+1];this._li.computeIntersection(i,o,s,a),this._li.hasIntersection()&&(this._recordIsolated&&(t.setIsolated(!1),n.setIsolated(!1)),this._numIntersections++,this.isTrivialIntersection(t,e,n,r)||(this._hasIntersection=!0,!this._includeProper&&this._li.isProper()||(t.addIntersections(this._li,e,0),n.addIntersections(this._li,r,1)),this._li.isProper()&&(this._properIntersectionPoint=this._li.getIntersection(0).copy(),this._hasProper=!0,this._isDoneWhenProperInt&&(this._isDone=!0),this.isBoundaryPoint(this._li,this._bdyNodes)||(this._hasProperInterior=!0))));},fg.prototype.interfaces_=function(){return[];},fg.prototype.getClass=function(){return fg;},fg.isAdjacentSegments=function(t,e){return 1===Math.abs(t-e);};var gg=function(t){function e(){t.call(this),this.events=new lc(),this.nOverlaps=null;}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.prepareEvents=function(){np.sort(this.events);for(var t=0;te||this._maxo?1:0;},vg.prototype.interfaces_=function(){return[sl];},vg.prototype.getClass=function(){return vg;};var _g=function(t){function e(){t.call(this),this._item=null;var e=arguments[0],n=arguments[1],r=arguments[2];this._min=e,this._max=n,this._item=r;}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.query=function(t,e,n){if(!this.intersects(t,e))return null;n.visitItem(this._item);},e.prototype.interfaces_=function(){return[];},e.prototype.getClass=function(){return e;},e;}(dg),mg=function(t){function e(){t.call(this),this._node1=null,this._node2=null;var e=arguments[0],n=arguments[1];this._node1=e,this._node2=n,this.buildExtent(this._node1,this._node2);}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.buildExtent=function(t,e){this._min=Math.min(t._min,e._min),this._max=Math.max(t._max,e._max);},e.prototype.query=function(t,e,n){if(!this.intersects(t,e))return null;null!==this._node1&&this._node1.query(t,e,n),null!==this._node2&&this._node2.query(t,e,n);},e.prototype.interfaces_=function(){return[];},e.prototype.getClass=function(){return e;},e;}(dg),xg=function xg(){this._leaves=new lc(),this._root=null,this._level=0;};xg.prototype.buildTree=function(){np.sort(this._leaves,new dg.NodeComparator());for(var t=this._leaves,e=null,n=new lc();;){if(this.buildLevel(t,n),1===n.size())return n.get(0);e=t,t=n,n=e;}},xg.prototype.insert=function(t,e,n){if(null!==this._root)throw new Error("Index cannot be added to once it has been queried");this._leaves.add(new _g(t,e,n));},xg.prototype.query=function(t,e,n){this.init(),this._root.query(t,e,n);},xg.prototype.buildRoot=function(){if(null!==this._root)return null;this._root=this.buildTree();},xg.prototype.printNode=function(t){Pl.out.println(Fl.toLineString(new ul(t._min,this._level),new ul(t._max,this._level)));},xg.prototype.init=function(){if(null!==this._root)return null;this.buildRoot();},xg.prototype.buildLevel=function(t,e){this._level++,e.clear();for(var n=0;n=2,"found LineString with single point"),this.insertBoundaryPoint(this._argIndex,e[0]),this.insertBoundaryPoint(this._argIndex,e[e.length-1]);},e.prototype.getInvalidPoint=function(){return this._invalidPoint;},e.prototype.getBoundaryPoints=function(){for(var t=this.getBoundaryNodes(),e=new Array(t.size()).fill(null),n=0,r=t.iterator();r.hasNext();){var i=r.next();e[n++]=i.getCoordinate().copy();}return e;},e.prototype.getBoundaryNodes=function(){return null===this._boundaryNodes&&(this._boundaryNodes=this._nodes.getBoundaryNodes(this._argIndex)),this._boundaryNodes;},e.prototype.addSelfIntersectionNode=function(t,e,n){if(this.isBoundaryNode(t,e))return null;n===pl.BOUNDARY&&this._useBoundaryDeterminationRule?this.insertBoundaryPoint(t,e):this.insertPoint(t,e,n);},e.prototype.addPolygonRing=function(t,e,n){if(t.isEmpty())return null;var r=pc.removeRepeatedPoints(t.getCoordinates());if(r.length<4)return this._hasTooFewPoints=!0,this._invalidPoint=r[0],null;var i=e,o=n;Xl.isCCW(r)&&(i=n,o=e);var s=new of(r,new Dh(this._argIndex,pl.BOUNDARY,i,o));this._lineEdgeMap.put(t,s),this.insertEdge(s),this.insertPoint(this._argIndex,r[0],pl.BOUNDARY);},e.prototype.insertPoint=function(t,e,n){var r=this._nodes.addNode(e),i=r.getLabel();null===i?r._label=new Dh(t,n):i.setLocation(t,n);},e.prototype.createEdgeSetIntersector=function(){return new gg();},e.prototype.addSelfIntersectionNodes=function(t){for(var e=this._edges.iterator();e.hasNext();)for(var n=e.next(),r=n.getLabel().getLocation(t),i=n.eiList.iterator();i.hasNext();){var o=i.next();this.addSelfIntersectionNode(t,o.coord,r);}},e.prototype.add=function(){if(1!==arguments.length)return t.prototype.add.apply(this,arguments);var e=arguments[0];if(e.isEmpty())return null;if(e instanceof rh&&(this._useBoundaryDeterminationRule=!1),e instanceof th)this.addPolygon(e);else if(e instanceof Zc)this.addLineString(e);else if(e instanceof Qc)this.addPoint(e);else if(e instanceof eh)this.addCollection(e);else if(e instanceof Gc)this.addCollection(e);else if(e instanceof rh)this.addCollection(e);else{if(!(e instanceof kc))throw new Error(e.getClass().getName());this.addCollection(e);}},e.prototype.addCollection=function(t){for(var e=0;e50?(null===this._areaPtLocator&&(this._areaPtLocator=new bg(this._parentGeom)),this._areaPtLocator.locate(t)):this._ptLocator.locate(t,this._parentGeom);},e.prototype.findEdge=function(){if(1===arguments.length){var e=arguments[0];return this._lineEdgeMap.get(e);}return t.prototype.findEdge.apply(this,arguments);},e.prototype.interfaces_=function(){return[];},e.prototype.getClass=function(){return e;},e.determineBoundary=function(t,e){return t.isInBoundary(e)?pl.BOUNDARY:pl.INTERIOR;},e;}(Hh),Cg=function Cg(){if(this._li=new jl(),this._resultPrecisionModel=null,this._arg=null,1===arguments.length){var t=arguments[0];this.setComputationPrecision(t.getPrecisionModel()),this._arg=new Array(1).fill(null),this._arg[0]=new Sg(0,t);}else if(2===arguments.length){var e=arguments[0],n=arguments[1],r=Ql.OGC_SFS_BOUNDARY_RULE;e.getPrecisionModel().compareTo(n.getPrecisionModel())>=0?this.setComputationPrecision(e.getPrecisionModel()):this.setComputationPrecision(n.getPrecisionModel()),this._arg=new Array(2).fill(null),this._arg[0]=new Sg(0,e,r),this._arg[1]=new Sg(1,n,r);}else if(3===arguments.length){var i=arguments[0],o=arguments[1],s=arguments[2];i.getPrecisionModel().compareTo(o.getPrecisionModel())>=0?this.setComputationPrecision(i.getPrecisionModel()):this.setComputationPrecision(o.getPrecisionModel()),this._arg=new Array(2).fill(null),this._arg[0]=new Sg(0,i,s),this._arg[1]=new Sg(1,o,s);}};Cg.prototype.getArgGeometry=function(t){return this._arg[t].getGeometry();},Cg.prototype.setComputationPrecision=function(t){this._resultPrecisionModel=t,this._li.setPrecisionModel(this._resultPrecisionModel);},Cg.prototype.interfaces_=function(){return[];},Cg.prototype.getClass=function(){return Cg;};var Pg=function Pg(){};Pg.prototype.interfaces_=function(){return[];},Pg.prototype.getClass=function(){return Pg;},Pg.map=function(){if(arguments[0]instanceof Wl&&gl(arguments[1],Pg.MapOp)){for(var t=arguments[0],e=arguments[1],n=new lc(),r=0;r=t.size()?null:t.get(e);},Fg.union=function(t){return new Fg(t).union();},kg.STRTREE_NODE_CAPACITY.get=function(){return 4;},Object.defineProperties(Fg,kg);var Gg=function Gg(){};function qg(){return new Bg();}function Bg(){this.reset();}Gg.prototype.interfaces_=function(){return[];},Gg.prototype.getClass=function(){return Gg;},Gg.union=function(t,e){if(t.isEmpty()||e.isEmpty()){if(t.isEmpty()&&e.isEmpty())return Mg.createEmptyResult(Mg.UNION,t,e,t.getFactory());if(t.isEmpty())return e.copy();if(e.isEmpty())return t.copy();}return t.checkNotGeometryCollection(t),t.checkNotGeometryCollection(e),ug.overlayOp(t,e,Mg.UNION);},Bg.prototype={constructor:Bg,reset:function reset(){this.s=this.t=0;},add:function add(t){jg(zg,t,this.t),jg(this,zg.s,this.s),this.s?this.t+=zg.t:this.s=zg.t;},valueOf:function valueOf(){return this.s;}};var zg=new Bg();function jg(t,e,n){var r=t.s=e+n,i=r-e,o=r-i;t.t=e-o+(n-i);}var Ug=1e-6,Vg=Math.PI,Xg=Vg/2,Yg=Vg/4,Hg=2*Vg,Wg=180/Vg,Jg=Vg/180,Zg=Math.abs,Kg=Math.atan,Qg=Math.atan2,$g=Math.cos,td=Math.sin,ed=Math.sqrt;function nd(t){return t>1?0:t<-1?Vg:Math.acos(t);}function rd(t){return t>1?Xg:t<-1?-Xg:Math.asin(t);}function id(){}function od(t,e){t&&ad.hasOwnProperty(t.type)&&ad[t.type](t,e);}var sd={Feature:function Feature(t,e){od(t.geometry,e);},FeatureCollection:function FeatureCollection(t,e){for(var n=t.features,r=-1,i=n.length;++rVg?t-Hg:t<-Vg?t+Hg:t,e];}function md(t){return function(e,n){return[(e+=t)>Vg?e-Hg:e<-Vg?e+Hg:e,n];};}function xd(t){var e=md(t);return e.invert=md(-t),e;}function Ed(t,e){var n=$g(t),r=td(t),i=$g(e),o=td(e);function s(t,e){var s=$g(e),a=$g(t)*s,u=td(t)*s,l=td(e),c=l*n+a*r;return[Qg(u*i-c*o,a*n-l*r),rd(c*i+u*o)];}return s.invert=function(t,e){var s=$g(e),a=$g(t)*s,u=td(t)*s,l=td(e),c=l*i-u*o;return[Qg(u*i+l*o,a*n+c*r),rd(c*n-a*r)];},s;}function bd(t,e){(e=hd(e))[0]-=t,yd(e);var n=nd(-e[1]);return((-e[2]<0?-n:n)+Hg-Ug)%Hg;}function wd(){var t,e=[];return{point:function point(e,n){t.push([e,n]);},lineStart:function lineStart(){e.push(t=[]);},lineEnd:id,rejoin:function rejoin(){e.length>1&&e.push(e.pop().concat(e.shift()));},result:function result(){var n=e;return e=[],t=null,n;}};}function Id(t,e){return Zg(t[0]-e[0])=0;--o)i.point((c=l[o])[0],c[1]);else r(p.x,p.p.x,-1,i);p=p.p;}l=(p=p.o).z,f=!f;}while(!p.v);i.lineEnd();}}}function Cd(t){if(e=t.length){for(var e,n,r=0,i=t[0];++re?1:t>=e?0:NaN;}_d.invert=_d;var Md,Ld;1===(Md=Pd).length&&(Ld=Md,Md=function Md(t,e){return Pd(Ld(t),e);});function Od(t){for(var e,n,r,i=t.length,o=-1,s=0;++o=0;)for(e=(r=t[i]).length;--e>=0;)n[--s]=r[e];return n;}var Rd=1e9,Td=-Rd;function Ad(t,e,n,r){function i(i,o){return t<=i&&i<=n&&e<=o&&o<=r;}function o(i,o,a,l){var c=0,h=0;if(null==i||(c=s(i,a))!==(h=s(o,a))||u(i,o)<0^a>0)do{l.point(0===c||3===c?t:n,c>1?r:e);}while((c=(c+a+4)%4)!==h);else l.point(o[0],o[1]);}function s(r,i){return Zg(r[0]-t)0?0:3:Zg(r[0]-n)0?2:1:Zg(r[1]-e)0?1:0:i>0?3:2;}function a(t,e){return u(t.x,e.x);}function u(t,e){var n=s(t,1),r=s(e,1);return n!==r?n-r:0===n?e[1]-t[1]:1===n?t[0]-e[0]:2===n?t[1]-e[1]:e[0]-t[0];}return function(s){var u,l,c,h,p,f,g,d,y,v,_,m=s,x=wd(),E={point:b,lineStart:function lineStart(){E.point=w,l&&l.push(c=[]);v=!0,y=!1,g=d=NaN;},lineEnd:function lineEnd(){u&&(w(h,p),f&&y&&x.rejoin(),u.push(x.result()));E.point=b,y&&m.lineEnd();},polygonStart:function polygonStart(){m=x,u=[],l=[],_=!0;},polygonEnd:function polygonEnd(){var e=function(){for(var e=0,n=0,i=l.length;nr&&(p-o)*(r-s)>(f-s)*(t-o)&&++e:f<=r&&(p-o)*(r-s)<(f-s)*(t-o)&&--e;return e;}(),n=_&&e,i=(u=Od(u)).length;(n||i)&&(s.polygonStart(),n&&(s.lineStart(),o(null,null,1,s),s.lineEnd()),i&&Sd(u,a,e,o,s),s.polygonEnd());m=s,u=l=c=null;}};function b(t,e){i(t,e)&&m.point(t,e);}function w(o,s){var a=i(o,s);if(l&&c.push([o,s]),v)h=o,p=s,f=a,v=!1,a&&(m.lineStart(),m.point(o,s));else if(a&&y)m.point(o,s);else{var u=[g=Math.max(Td,Math.min(Rd,g)),d=Math.max(Td,Math.min(Rd,d))],x=[o=Math.max(Td,Math.min(Rd,o)),s=Math.max(Td,Math.min(Rd,s))];!function(t,e,n,r,i,o){var s,a=t[0],u=t[1],l=0,c=1,h=e[0]-a,p=e[1]-u;if(s=n-a,h||!(s>0)){if(s/=h,h<0){if(s0){if(s>c)return;s>l&&(l=s);}if(s=i-a,h||!(s<0)){if(s/=h,h<0){if(s>c)return;s>l&&(l=s);}else if(h>0){if(s0)){if(s/=p,p<0){if(s0){if(s>c)return;s>l&&(l=s);}if(s=o-u,p||!(s<0)){if(s/=p,p<0){if(s>c)return;s>l&&(l=s);}else if(p>0){if(s0&&(t[0]=a+l*h,t[1]=u+l*p),c<1&&(e[0]=a+c*h,e[1]=u+c*p),!0;}}}}}(u,x,t,e,n,r)?a&&(m.lineStart(),m.point(o,s),_=!1):(y||(m.lineStart(),m.point(u[0],u[1])),m.point(x[0],x[1]),a||m.lineEnd(),_=!1);}g=o,d=s,y=a;}return E;};}var Dd=qg();qg();function Fd(t){return t;}qg(),qg();var kd=1/0,Gd=kd,qd=-kd,Bd=qd,zd={point:function point(t,e){tqd&&(qd=t);eBd&&(Bd=e);},lineStart:id,lineEnd:id,polygonStart:id,polygonEnd:id,result:function result(){var t=[[kd,Gd],[qd,Bd]];return qd=Bd=-(Gd=kd=1/0),t;}};qg();function jd(t,e,n,r){return function(i,o){var s,a,u,l=e(o),c=i.invert(r[0],r[1]),h=wd(),p=e(h),f=!1,g={point:d,lineStart:v,lineEnd:_,polygonStart:function polygonStart(){g.point=m,g.lineStart=x,g.lineEnd=E,a=[],s=[];},polygonEnd:function polygonEnd(){g.point=d,g.lineStart=v,g.lineEnd=_,a=Od(a);var t=function(t,e){var n=e[0],r=e[1],i=[td(n),-$g(n),0],o=0,s=0;Dd.reset();for(var a=0,u=t.length;a=0?1:-1,I=w*b,N=I>Vg,S=g*x;if(Dd.add(Qg(S*w*td(I),d*E+S*$g(I))),o+=N?b+w*Hg:b,N^p>=n^_>=n){var C=fd(hd(h),hd(v));yd(C);var P=fd(i,C);yd(P);var M=(N^b>=0?-1:1)*rd(P[2]);(r>M||r===M&&(C[0]||C[1]))&&(s+=N^b>=0?1:-1);}}return(o<-1e-6||o0){for(f||(o.polygonStart(),f=!0),o.lineStart(),t=0;t1&&2&i&&l.push(l.pop().concat(l.shift())),a.push(l.filter(Ud));}return g;};}function Ud(t){return t.length>1;}function Vd(t,e){return((t=t.x)[0]<0?t[1]-Xg-Ug:Xg-t[1])-((e=e.x)[0]<0?e[1]-Xg-Ug:Xg-e[1]);}var Xd=jd(function(){return!0;},function(t){var e,n=NaN,r=NaN,i=NaN;return{lineStart:function lineStart(){t.lineStart(),e=1;},point:function point(o,s){var a=o>0?Vg:-Vg,u=Zg(o-n);Zg(u-Vg)0?Xg:-Xg),t.point(i,r),t.lineEnd(),t.lineStart(),t.point(a,r),t.point(o,r),e=0):i!==a&&u>=Vg&&(Zg(n-i)Ug?Kg((td(e)*(o=$g(r))*td(n)-td(r)*(i=$g(e))*td(t))/(i*o*s)):(e+r)/2;}(n,r,o,s),t.point(i,r),t.lineEnd(),t.lineStart(),t.point(a,r),e=0),t.point(n=o,r=s),i=a;},lineEnd:function lineEnd(){t.lineEnd(),n=r=NaN;},clean:function clean(){return 2-e;}};},function(t,e,n,r){var i;if(null==t)i=n*Xg,r.point(-Vg,i),r.point(0,i),r.point(Vg,i),r.point(Vg,0),r.point(Vg,-i),r.point(0,-i),r.point(-Vg,-i),r.point(-Vg,0),r.point(-Vg,i);else if(Zg(t[0]-e[0])>Ug){var o=t[0]0,i=Zg(n)>Ug;function o(t,e){return $g(t)*$g(e)>n;}function s(t,e,r){var i=[1,0,0],o=fd(hd(t),hd(e)),s=pd(o,o),a=o[0],u=s-a*a;if(!u)return!r&&t;var l=n*s/u,c=-n*a/u,h=fd(i,o),p=dd(i,l);gd(p,dd(o,c));var f=h,g=pd(p,f),d=pd(f,f),y=g*g-d*(pd(p,p)-1);if(!(y<0)){var v=ed(y),_=dd(f,(-g-v)/d);if(gd(_,p),_=cd(_),!r)return _;var m,x=t[0],E=e[0],b=t[1],w=e[1];E0^_[1]<(Zg(_[0]-x)Vg^(x<=_[0]&&_[0]<=E)){var S=dd(f,(-g+v)/d);return gd(S,p),[_,cd(S)];}}}function a(e,n){var i=r?t:Vg-t,o=0;return e<-i?o|=1:e>i&&(o|=2),n<-i?o|=4:n>i&&(o|=8),o;}return jd(o,function(t){var e,n,u,l,c;return{lineStart:function lineStart(){l=u=!1,c=1;},point:function point(h,p){var f,g=[h,p],d=o(h,p),y=r?d?0:a(h,p):d?a(h+(h<0?Vg:-Vg),p):0;if(!e&&(l=u=d)&&t.lineStart(),d!==u&&(!(f=s(e,g))||Id(e,f)||Id(g,f))&&(g[0]+=Ug,g[1]+=Ug,d=o(g[0],g[1])),d!==u)c=0,d?(t.lineStart(),f=s(g,e),t.point(f[0],f[1])):(f=s(e,g),t.point(f[0],f[1]),t.lineEnd()),e=f;else if(i&&e&&r^d){var v;y&n||!(v=s(g,e,!0))||(c=0,r?(t.lineStart(),t.point(v[0][0],v[0][1]),t.point(v[1][0],v[1][1]),t.lineEnd()):(t.point(v[1][0],v[1][1]),t.lineEnd(),t.lineStart(),t.point(v[0][0],v[0][1])));}!d||e&&Id(e,g)||t.point(g[0],g[1]),e=g,u=d,n=y;},lineEnd:function lineEnd(){u&&t.lineEnd(),e=null;},clean:function clean(){return c|(l&&u)<<1;}};},function(n,r,i,o){!function(t,e,n,r,i,o){if(n){var s=$g(e),a=td(e),u=r*n;null==i?(i=e+r*Hg,o=e-u/2):(i=bd(s,i),o=bd(s,o),(r>0?io)&&(i+=r*Hg));for(var l,c=i;r>0?c>o:c4*e&&d--){var x=s+p,E=a+f,b=u+g,w=ed(x*x+E*E+b*b),I=rd(b/=w),N=Zg(Zg(b)-1)e||Zg((v*M+_*L)/m-.5)>.3||s*p+a*f+u*g2?t[2]%360*Jg:0,P()):[y*Wg,v*Wg,_*Wg];},N.precision=function(t){return arguments.length?(I=Kd(C,w=t*t),M()):ed(w);},N.fitExtent=function(t,e){return Jd(N,t,e);},N.fitSize=function(t,e){return function(t,e,n){return Jd(t,[[0,0],e],n);}(N,t,e);},function(){return e=t.apply(this,arguments),N.invert=e.invert&&S,P();};}(function(){return t;})();}var ty=function(t){return function(e,n){var r=$g(e),i=$g(n),o=t(r*i);return[o*i*td(e),o*td(n)];};}(function(t){return(t=nd(t))&&t/td(t);});function ey(){return $d(ty).scale(79.4188).clipAngle(179.999);}function ny(t,n,r,i){var s=t.properties||{},a="Feature"===t.type?t.geometry:t;if("GeometryCollection"===a.type){var u=[];return q(t,function(t){var e=ny(t,n,r,i);e&&u.push(e);}),f(u);}var l=function(t){var n=xn(t).geometry.coordinates,r=[-n[0],-n[1]];return ey().rotate(r).scale(e);}(a),c={type:a.type,coordinates:iy(a.coordinates,l)},h=new Ih().read(c),p=m(x(n,r),"meters"),g=_f.bufferOp(h,p,i);if(!ry((g=new Nh().write(g)).coordinates))return o({type:g.type,coordinates:oy(g.coordinates,l)},s);}function ry(t){return Array.isArray(t[0])?ry(t[0]):isNaN(t[0]);}function iy(t,e){return"object"!=_typeof(t[0])?e(t):t.map(function(t){return iy(t,e);});}function oy(t,e){return"object"!=_typeof(t[0])?e.invert(t):t.map(function(t){return oy(t,e);});}function sy(t,e,n){void 0===n&&(n={});var r=rt(t),i=rt(e),o=$u.intersection(r.coordinates,i.coordinates);return 0===o.length?null:1===o.length?l(o[0],n.properties):y(o,n.properties);}function ay(t,e,n){void 0===n&&(n={});var r=JSON.stringify(n.properties||{}),i=t[0],o=t[1],s=t[2],a=t[3],u=(o+a)/2,l=(i+s)/2,c=2*e/me([i,u],[s,u],n)*(s-i),h=2*e/me([l,o],[l,a],n)*(a-o),p=c/2,g=2*p,d=Math.sqrt(3)/2*h,y=s-i,v=a-o,_=3/4*g,m=d,x=(y-g)/(g-p/2),E=Math.floor(x),b=(E*_-p/2-y)/2-p/2+_/2,w=Math.floor((v-d)/d),I=(v-w*d)/2,N=w*d-v>d/2;N&&(I-=d/4);for(var S=[],C=[],P=0;P<6;P++){var M=2*Math.PI/6*P;S.push(Math.cos(M)),C.push(Math.sin(M));}for(var L=[],O=0;O<=E;O++)for(var R=0;R<=w;R++){var T=O%2==1;if((0!==R||!T)&&(0!==R||!N)){var A=O*_+i-b,D=R*m+o+I;if(T&&(D-=d/2),!0===n.triangles)ly([A,D],c/2,h/2,JSON.parse(r),S,C).forEach(function(t){n.mask?sy(n.mask,t)&&L.push(t):L.push(t);});else{var F=uy([A,D],c/2,h/2,JSON.parse(r),S,C);n.mask?sy(n.mask,F)&&L.push(F):L.push(F);}}}return f(L);}function uy(t,e,n,r,i,o){for(var s=[],a=0;a<6;a++){var u=t[0]+e*i[a],c=t[1]+n*o[a];s.push([u,c]);}return s.push(s[0].slice()),l([s],r);}function ly(t,e,n,r,i,o){for(var s=[],a=0;a<6;a++){var u=[];u.push(t),u.push([t[0]+e*i[a],t[1]+n*o[a]]),u.push([t[0]+e*i[(a+1)%6],t[1]+n*o[(a+1)%6]]),u.push(t),s.push(l([u],r));}return s;}function cy(t){return y(t);}function hy(t){return l(t&&t.geometry.coordinates||[[[180,90],[-180,90],[-180,-90],[180,-90],[180,90]]]);}function py(t,e,n){return void 0===n&&(n={}),function(t,e,n,r){void 0===r&&(r={});for(var i=[],o=t[0],s=t[1],a=t[2],u=t[3],c=e/me([o,s],[a,s],r)*(a-o),h=n/me([o,s],[o,u],r)*(u-s),p=a-o,g=u-s,d=Math.floor(p/c),y=Math.floor(g/h),v=(g-y*h)/2,_=o+(p-d*c)/2,m=0;m=i&&o===r.length-1);o++){if(i>=e){var s=e-i;if(s){var u=mn(r[o],r[o-1])-180;return vn(r[o],s,u,n);}return a(r[o]);}i+=me(r[o],r[o+1],n);}return a(r[r.length-1]);},t.angle=function(t,e,n,r){if(void 0===r&&(r={}),!P(r))throw new Error("options is invalid");if(!t)throw new Error("startPoint is required");if(!e)throw new Error("midPoint is required");if(!n)throw new Error("endPoint is required");var i=t,o=e,s=n,a=b(!0!==r.mercator?mn(i,o):Bi(i,o)),u=b(!0!==r.mercator?mn(s,o):Bi(s,o)),l=Math.abs(a-u);return!0===r.explementary?360-l:l;},t.applyFilter=uu,t.area=jr,t.areaFactors=i,t.bbox=Z,t.bboxClip=function(t,e){var n=rt(t),r=n.type,i="Feature"===t.type?t.properties:{},o=n.coordinates;switch(r){case"LineString":case"MultiLineString":var s=[];return"LineString"===r&&(o=[o]),o.forEach(function(t){!function(t,e,n){var r,i,o,s,a,u=t.length,l=Ri(t[0],e),c=[];for(n||(n=[]),r=1;r0)for(var n=0;n0;},t.booleanParallel=function(t,e){if(!t)throw new Error("line1 is required");if(!e)throw new Error("line2 is required");if("LineString"!==Us(t,"line1"))throw new Error("line1 must be a LineString");if("LineString"!==Us(e,"line2"))throw new Error("line2 must be a LineString");for(var n=Zn(tn(t)).features,r=Zn(tn(e)).features,i=0;in&&(e.numberOfClusters=n),!0!==e.mutate&&(t=Ie(t));var r=G(t),i=r.slice(0,e.numberOfClusters),o=zs(r,e.numberOfClusters,i),s={};return o.centroids.forEach(function(t,e){s[e]=t;}),F(t,function(t,e){var n=o.idxs[e];t.properties.cluster=n,t.properties.centroid=s[n];}),t;},t.collect=function(t,e,n,r){var i=Nt(6),o=e.features.map(function(t){var e;return{minX:t.geometry.coordinates[0],minY:t.geometry.coordinates[1],maxX:t.geometry.coordinates[0],maxY:t.geometry.coordinates[1],property:null===(e=t.properties)||void 0===e?void 0:e[n]};});return i.load(o),t.features.forEach(function(t){t.properties||(t.properties={});var e=Z(t),n=i.search({minX:e[0],minY:e[1],maxX:e[2],maxY:e[3]}),o=[];n.forEach(function(e){ye([e.minX,e.minY],t)&&o.push(e.property);}),t.properties[r]=o;}),t;},t.collectionOf=nt,t.combine=function(t){var e={MultiPoint:{coordinates:[],properties:[]},MultiLineString:{coordinates:[],properties:[]},MultiPolygon:{coordinates:[],properties:[]}};return F(t,function(t){var n,r,i,o;switch(null===(o=t.geometry)||void 0===o?void 0:o.type){case"Point":e.MultiPoint.coordinates.push(t.geometry.coordinates),e.MultiPoint.properties.push(t.properties);break;case"MultiPoint":(n=e.MultiPoint.coordinates).push.apply(n,t.geometry.coordinates),e.MultiPoint.properties.push(t.properties);break;case"LineString":e.MultiLineString.coordinates.push(t.geometry.coordinates),e.MultiLineString.properties.push(t.properties);break;case"MultiLineString":(r=e.MultiLineString.coordinates).push.apply(r,t.geometry.coordinates),e.MultiLineString.properties.push(t.properties);break;case"Polygon":e.MultiPolygon.coordinates.push(t.geometry.coordinates),e.MultiPolygon.properties.push(t.properties);break;case"MultiPolygon":(i=e.MultiPolygon.coordinates).push.apply(i,t.geometry.coordinates),e.MultiPolygon.properties.push(t.properties);}}),f(Object.keys(e).filter(function(t){return e[t].coordinates.length;}).sort().map(function(t){return o({type:t,coordinates:e[t].coordinates},{collectedProperties:e[t].properties});}));},t.concave=function(t,e){void 0===e&&(e={});var n=e.maxEdge||1/0,r=xe(function(t){var e=[],n={};return F(t,function(t){if(t.geometry){var r=t.geometry.coordinates.join("-");Object.prototype.hasOwnProperty.call(n,r)||(e.push(t),n[r]=!0);}}),f(e);}(t));if(r.features=r.features.filter(function(t){var r=t.geometry.coordinates[0][0],i=t.geometry.coordinates[0][1],o=t.geometry.coordinates[0][2],s=me(r,i,e),a=me(i,o,e),u=me(r,o,e);return s<=n&&a<=n&&u<=n;}),r.features.length<1)return null;var i=$e(r);return 1===i.coordinates.length&&(i.coordinates=i.coordinates[0],i.type="Polygon"),o(i);},t.containsNumber=$,t.convertArea=S,t.convertDistance=N,t.convertLength=N,t.convex=de,t.coordAll=G,t.coordEach=R,t.coordReduce=T,t.createBins=au,t.degrees2radians=I,t.degreesToRadians=I,t.destination=vn,t.difference=function(t,e){var n=rt(t),r=rt(e),i=t.properties||{},o=$u.difference(n.coordinates,r.coordinates);return 0===o.length?null:1===o.length?l(o[0],i):y(o,i);},t.dissolve=function(t,e){if(!P(e=e||{}))throw new Error("options is invalid");var n=e.propertyName;nt(t,"Polygon","dissolve");var r=[];if(!e.propertyName)return ni(y($u.union.apply(null,t.features.map(function(t){return t.geometry.coordinates;}))));var i={};F(t,function(t){Object.prototype.hasOwnProperty.call(i,t.properties[n])||(i[t.properties[n]]=[]),i[t.properties[n]].push(t);});for(var o=Object.keys(i),s=0;s0&&(s=l(o).geometry),qa(s,a),o=a.slice(0);n.push(l(o,i));break;case"MultiPolygon":o=[[[]]];for(var c=0;c0&&(s=y(o).geometry),Ba(s,a),o=a.slice(0);n.push(y(o,i));break;default:throw new Error("geometry is invalid, must be Polygon or MultiPolygon");}}),f(n);},t.polygonTangents=function(t,e){var n,r,i,o,s=Q(t),u=Q(e),l=Z(e),c=0,h=null;switch(s[0]>l[0]&&s[0]l[1]&&s[1] is required");if("boolean"!=typeof n)throw new Error(" must be a boolean");if("boolean"!=typeof r)throw new Error(" must be a boolean");!1===r&&(t=Ie(t));var i=[];switch(t.type){case"GeometryCollection":return q(t,function(t){Hi(t,n);}),t;case"FeatureCollection":return F(t,function(t){F(Hi(t,n),function(t){i.push(t);});}),f(i);}return Hi(t,n);},t.rhumbBearing=Bi,t.rhumbDestination=ji,t.rhumbDistance=Ar,t.round=_,t.sample=function(t,e){if(!t)throw new Error("featurecollection is required");if(null==e)throw new Error("num is required");if("number"!=typeof e)throw new Error("num must be a number");return f(function(t,e){var n,r,i=t.slice(0),o=t.length,s=o-e;for(;o-->s;)n=i[r=Math.floor((o+1)*Math.random())],i[r]=i[o],i[o]=n;return i.slice(s);}(t.features,e));},t.sector=function(t,e,n,r,i){if(!P(i=i||{}))throw new Error("options is invalid");var o=i.properties;if(!t)throw new Error("center is required");if(null==n)throw new Error("bearing1 is required");if(null==r)throw new Error("bearing2 is required");if(!e)throw new Error("radius is required");if("object"!=_typeof(i))throw new Error("options must be an object");if(qi(n)===qi(r))return _n(t,e,i);var s=Q(t),a=bi(t,e,n,r,i),u=[[s]];return R(a,function(t){u[0].push(t);}),u[0].push(s),l(u,o);},t.segmentEach=U,t.segmentReduce=V,t.shortestPath=function(t,e,n){if(!P(n=n||{}))throw new Error("options is invalid");var r=n.resolution,i=n.minDistance,s=n.obstacles||f([]);if(!t)throw new Error("start is required");if(!e)throw new Error("end is required");if(r&&!C(r)||r<=0)throw new Error("options.resolution must be a number, greater than 0");if(i)throw new Error("options.minDistance is not yet implemented");var u=K(t),l=K(e);switch(t=a(u),e=a(l),it(s)){case"FeatureCollection":if(0===s.features.length)return h([u,l]);break;case"Polygon":s=f([o(rt(s))]);break;default:throw new Error("invalid obstacles");}var c=s;c.features.push(t),c.features.push(e);var p=Z(ts(gn(Z(c)),1.15));r||(r=me([p[0],p[1]],[p[2],p[1]],n)/100),c.features.pop(),c.features.pop();for(var g=p[0],d=p[1],y=p[2],v=p[3],_=r/me([g,d],[y,d],n)*(y-g),m=r/me([g,d],[g,v],n)*(v-d),x=y-g,E=v-d,b=Math.floor(x/_),w=Math.floor(E/m),I=(x-b*_)/2,N=[],S=[],M=[],L=[],O=1/0,R=1/0,T=v-(E-w*m)/2,A=0;T>=d;){for(var D=[],F=[],k=g+I,G=0;k<=y;){var q=a([k,T]),B=Js(q,s);D.push(B?0:1),F.push(k+"|"+T);var z=me(q,t);!B&&z arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); } function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); } function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } Object.defineProperty(exports, "__esModule", { value: true }); exports.regexpCode = exports.getEsmExportName = exports.getProperty = exports.safeStringify = exports.stringify = exports.strConcat = exports.addCodeArg = exports.str = exports._ = exports.nil = exports._Code = exports.Name = exports.IDENTIFIER = exports._CodeOrName = void 0; var _CodeOrName = /*#__PURE__*/_createClass(function _CodeOrName() { _classCallCheck(this, _CodeOrName); }); exports._CodeOrName = _CodeOrName; exports.IDENTIFIER = /^[a-z$_][a-z$_0-9]*$/i; var Name = /*#__PURE__*/function (_CodeOrName2) { _inherits(Name, _CodeOrName2); var _super = _createSuper(Name); function Name(s) { var _this; _classCallCheck(this, Name); _this = _super.call(this); if (!exports.IDENTIFIER.test(s)) throw new Error("CodeGen: name must be a valid identifier"); _this.str = s; return _this; } _createClass(Name, [{ key: "toString", value: function toString() { return this.str; } }, { key: "emptyStr", value: function emptyStr() { return false; } }, { key: "names", get: function get() { return _defineProperty({}, this.str, 1); } }]); return Name; }(_CodeOrName); exports.Name = Name; var _Code = /*#__PURE__*/function (_CodeOrName3) { _inherits(_Code, _CodeOrName3); var _super2 = _createSuper(_Code); function _Code(code) { var _this2; _classCallCheck(this, _Code); _this2 = _super2.call(this); _this2._items = typeof code === "string" ? [code] : code; return _this2; } _createClass(_Code, [{ key: "toString", value: function toString() { return this.str; } }, { key: "emptyStr", value: function emptyStr() { if (this._items.length > 1) return false; var item = this._items[0]; return item === "" || item === '""'; } }, { key: "str", get: function get() { var _a; return (_a = this._str) !== null && _a !== void 0 ? _a : this._str = this._items.reduce(function (s, c) { return "".concat(s).concat(c); }, ""); } }, { key: "names", get: function get() { var _a; return (_a = this._names) !== null && _a !== void 0 ? _a : this._names = this._items.reduce(function (names, c) { if (c instanceof Name) names[c.str] = (names[c.str] || 0) + 1; return names; }, {}); } }]); return _Code; }(_CodeOrName); exports._Code = _Code; exports.nil = new _Code(""); function _(strs) { var code = [strs[0]]; var i = 0; for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { args[_key - 1] = arguments[_key]; } while (i < args.length) { addCodeArg(code, args[i]); code.push(strs[++i]); } return new _Code(code); } exports._ = _; var plus = new _Code("+"); function str(strs) { var expr = [safeStringify(strs[0])]; var i = 0; for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { args[_key2 - 1] = arguments[_key2]; } while (i < args.length) { expr.push(plus); addCodeArg(expr, args[i]); expr.push(plus, safeStringify(strs[++i])); } optimize(expr); return new _Code(expr); } exports.str = str; function addCodeArg(code, arg) { if (arg instanceof _Code) code.push.apply(code, _toConsumableArray(arg._items));else if (arg instanceof Name) code.push(arg);else code.push(interpolate(arg)); } exports.addCodeArg = addCodeArg; function optimize(expr) { var i = 1; while (i < expr.length - 1) { if (expr[i] === plus) { var res = mergeExprItems(expr[i - 1], expr[i + 1]); if (res !== undefined) { expr.splice(i - 1, 3, res); continue; } expr[i++] = "+"; } i++; } } function mergeExprItems(a, b) { if (b === '""') return a; if (a === '""') return b; if (typeof a == "string") { if (b instanceof Name || a[a.length - 1] !== '"') return; if (typeof b != "string") return "".concat(a.slice(0, -1)).concat(b, "\""); if (b[0] === '"') return a.slice(0, -1) + b.slice(1); return; } if (typeof b == "string" && b[0] === '"' && !(a instanceof Name)) return "\"".concat(a).concat(b.slice(1)); return; } function strConcat(c1, c2) { return c2.emptyStr() ? c1 : c1.emptyStr() ? c2 : str(_templateObject || (_templateObject = _taggedTemplateLiteral(["", "", ""])), c1, c2); } exports.strConcat = strConcat; // TODO do not allow arrays here function interpolate(x) { return typeof x == "number" || typeof x == "boolean" || x === null ? x : safeStringify(Array.isArray(x) ? x.join(",") : x); } function stringify(x) { return new _Code(safeStringify(x)); } exports.stringify = stringify; function safeStringify(x) { return JSON.stringify(x).replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029"); } exports.safeStringify = safeStringify; function getProperty(key) { return typeof key == "string" && exports.IDENTIFIER.test(key) ? new _Code(".".concat(key)) : _(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["[", "]"])), key); } exports.getProperty = getProperty; //Does best effort to format the name properly function getEsmExportName(key) { if (typeof key == "string" && exports.IDENTIFIER.test(key)) { return new _Code("".concat(key)); } throw new Error("CodeGen: invalid export name: ".concat(key, ", use explicit $id name mapping")); } exports.getEsmExportName = getEsmExportName; function regexpCode(rx) { return new _Code(rx.toString()); } exports.regexpCode = regexpCode; },{}],13:[function(require,module,exports){ "use strict"; var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6; function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } } function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get.bind(); } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); } function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; } function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); } function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); } function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } Object.defineProperty(exports, "__esModule", { value: true }); exports.or = exports.and = exports.not = exports.CodeGen = exports.operators = exports.varKinds = exports.ValueScopeName = exports.ValueScope = exports.Scope = exports.Name = exports.regexpCode = exports.stringify = exports.getProperty = exports.nil = exports.strConcat = exports.str = exports._ = void 0; var code_1 = require("./code"); var scope_1 = require("./scope"); var code_2 = require("./code"); Object.defineProperty(exports, "_", { enumerable: true, get: function get() { return code_2._; } }); Object.defineProperty(exports, "str", { enumerable: true, get: function get() { return code_2.str; } }); Object.defineProperty(exports, "strConcat", { enumerable: true, get: function get() { return code_2.strConcat; } }); Object.defineProperty(exports, "nil", { enumerable: true, get: function get() { return code_2.nil; } }); Object.defineProperty(exports, "getProperty", { enumerable: true, get: function get() { return code_2.getProperty; } }); Object.defineProperty(exports, "stringify", { enumerable: true, get: function get() { return code_2.stringify; } }); Object.defineProperty(exports, "regexpCode", { enumerable: true, get: function get() { return code_2.regexpCode; } }); Object.defineProperty(exports, "Name", { enumerable: true, get: function get() { return code_2.Name; } }); var scope_2 = require("./scope"); Object.defineProperty(exports, "Scope", { enumerable: true, get: function get() { return scope_2.Scope; } }); Object.defineProperty(exports, "ValueScope", { enumerable: true, get: function get() { return scope_2.ValueScope; } }); Object.defineProperty(exports, "ValueScopeName", { enumerable: true, get: function get() { return scope_2.ValueScopeName; } }); Object.defineProperty(exports, "varKinds", { enumerable: true, get: function get() { return scope_2.varKinds; } }); exports.operators = { GT: new code_1._Code(">"), GTE: new code_1._Code(">="), LT: new code_1._Code("<"), LTE: new code_1._Code("<="), EQ: new code_1._Code("==="), NEQ: new code_1._Code("!=="), NOT: new code_1._Code("!"), OR: new code_1._Code("||"), AND: new code_1._Code("&&"), ADD: new code_1._Code("+") }; var Node = /*#__PURE__*/function () { function Node() { _classCallCheck(this, Node); } _createClass(Node, [{ key: "optimizeNodes", value: function optimizeNodes() { return this; } }, { key: "optimizeNames", value: function optimizeNames(_names, _constants) { return this; } }]); return Node; }(); var Def = /*#__PURE__*/function (_Node) { _inherits(Def, _Node); var _super = _createSuper(Def); function Def(varKind, name, rhs) { var _this; _classCallCheck(this, Def); _this = _super.call(this); _this.varKind = varKind; _this.name = name; _this.rhs = rhs; return _this; } _createClass(Def, [{ key: "render", value: function render(_ref) { var es5 = _ref.es5, _n = _ref._n; var varKind = es5 ? scope_1.varKinds["var"] : this.varKind; var rhs = this.rhs === undefined ? "" : " = ".concat(this.rhs); return "".concat(varKind, " ").concat(this.name).concat(rhs, ";") + _n; } }, { key: "optimizeNames", value: function optimizeNames(names, constants) { if (!names[this.name.str]) return; if (this.rhs) this.rhs = optimizeExpr(this.rhs, names, constants); return this; } }, { key: "names", get: function get() { return this.rhs instanceof code_1._CodeOrName ? this.rhs.names : {}; } }]); return Def; }(Node); var Assign = /*#__PURE__*/function (_Node2) { _inherits(Assign, _Node2); var _super2 = _createSuper(Assign); function Assign(lhs, rhs, sideEffects) { var _this2; _classCallCheck(this, Assign); _this2 = _super2.call(this); _this2.lhs = lhs; _this2.rhs = rhs; _this2.sideEffects = sideEffects; return _this2; } _createClass(Assign, [{ key: "render", value: function render(_ref2) { var _n = _ref2._n; return "".concat(this.lhs, " = ").concat(this.rhs, ";") + _n; } }, { key: "optimizeNames", value: function optimizeNames(names, constants) { if (this.lhs instanceof code_1.Name && !names[this.lhs.str] && !this.sideEffects) return; this.rhs = optimizeExpr(this.rhs, names, constants); return this; } }, { key: "names", get: function get() { var names = this.lhs instanceof code_1.Name ? {} : _objectSpread({}, this.lhs.names); return addExprNames(names, this.rhs); } }]); return Assign; }(Node); var AssignOp = /*#__PURE__*/function (_Assign) { _inherits(AssignOp, _Assign); var _super3 = _createSuper(AssignOp); function AssignOp(lhs, op, rhs, sideEffects) { var _this3; _classCallCheck(this, AssignOp); _this3 = _super3.call(this, lhs, rhs, sideEffects); _this3.op = op; return _this3; } _createClass(AssignOp, [{ key: "render", value: function render(_ref3) { var _n = _ref3._n; return "".concat(this.lhs, " ").concat(this.op, "= ").concat(this.rhs, ";") + _n; } }]); return AssignOp; }(Assign); var Label = /*#__PURE__*/function (_Node3) { _inherits(Label, _Node3); var _super4 = _createSuper(Label); function Label(label) { var _this4; _classCallCheck(this, Label); _this4 = _super4.call(this); _this4.label = label; _this4.names = {}; return _this4; } _createClass(Label, [{ key: "render", value: function render(_ref4) { var _n = _ref4._n; return "".concat(this.label, ":") + _n; } }]); return Label; }(Node); var Break = /*#__PURE__*/function (_Node4) { _inherits(Break, _Node4); var _super5 = _createSuper(Break); function Break(label) { var _this5; _classCallCheck(this, Break); _this5 = _super5.call(this); _this5.label = label; _this5.names = {}; return _this5; } _createClass(Break, [{ key: "render", value: function render(_ref5) { var _n = _ref5._n; var label = this.label ? " ".concat(this.label) : ""; return "break".concat(label, ";") + _n; } }]); return Break; }(Node); var Throw = /*#__PURE__*/function (_Node5) { _inherits(Throw, _Node5); var _super6 = _createSuper(Throw); function Throw(error) { var _this6; _classCallCheck(this, Throw); _this6 = _super6.call(this); _this6.error = error; return _this6; } _createClass(Throw, [{ key: "render", value: function render(_ref6) { var _n = _ref6._n; return "throw ".concat(this.error, ";") + _n; } }, { key: "names", get: function get() { return this.error.names; } }]); return Throw; }(Node); var AnyCode = /*#__PURE__*/function (_Node6) { _inherits(AnyCode, _Node6); var _super7 = _createSuper(AnyCode); function AnyCode(code) { var _this7; _classCallCheck(this, AnyCode); _this7 = _super7.call(this); _this7.code = code; return _this7; } _createClass(AnyCode, [{ key: "render", value: function render(_ref7) { var _n = _ref7._n; return "".concat(this.code, ";") + _n; } }, { key: "optimizeNodes", value: function optimizeNodes() { return "".concat(this.code) ? this : undefined; } }, { key: "optimizeNames", value: function optimizeNames(names, constants) { this.code = optimizeExpr(this.code, names, constants); return this; } }, { key: "names", get: function get() { return this.code instanceof code_1._CodeOrName ? this.code.names : {}; } }]); return AnyCode; }(Node); var ParentNode = /*#__PURE__*/function (_Node7) { _inherits(ParentNode, _Node7); var _super8 = _createSuper(ParentNode); function ParentNode() { var _this8; var nodes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; _classCallCheck(this, ParentNode); _this8 = _super8.call(this); _this8.nodes = nodes; return _this8; } _createClass(ParentNode, [{ key: "render", value: function render(opts) { return this.nodes.reduce(function (code, n) { return code + n.render(opts); }, ""); } }, { key: "optimizeNodes", value: function optimizeNodes() { var nodes = this.nodes; var i = nodes.length; while (i--) { var n = nodes[i].optimizeNodes(); if (Array.isArray(n)) nodes.splice.apply(nodes, [i, 1].concat(_toConsumableArray(n)));else if (n) nodes[i] = n;else nodes.splice(i, 1); } return nodes.length > 0 ? this : undefined; } }, { key: "optimizeNames", value: function optimizeNames(names, constants) { var nodes = this.nodes; var i = nodes.length; while (i--) { // iterating backwards improves 1-pass optimization var n = nodes[i]; if (n.optimizeNames(names, constants)) continue; subtractNames(names, n.names); nodes.splice(i, 1); } return nodes.length > 0 ? this : undefined; } }, { key: "names", get: function get() { return this.nodes.reduce(function (names, n) { return addNames(names, n.names); }, {}); } }]); return ParentNode; }(Node); var BlockNode = /*#__PURE__*/function (_ParentNode) { _inherits(BlockNode, _ParentNode); var _super9 = _createSuper(BlockNode); function BlockNode() { _classCallCheck(this, BlockNode); return _super9.apply(this, arguments); } _createClass(BlockNode, [{ key: "render", value: function render(opts) { return "{" + opts._n + _get(_getPrototypeOf(BlockNode.prototype), "render", this).call(this, opts) + "}" + opts._n; } }]); return BlockNode; }(ParentNode); var Root = /*#__PURE__*/function (_ParentNode2) { _inherits(Root, _ParentNode2); var _super10 = _createSuper(Root); function Root() { _classCallCheck(this, Root); return _super10.apply(this, arguments); } return _createClass(Root); }(ParentNode); var Else = /*#__PURE__*/function (_BlockNode) { _inherits(Else, _BlockNode); var _super11 = _createSuper(Else); function Else() { _classCallCheck(this, Else); return _super11.apply(this, arguments); } return _createClass(Else); }(BlockNode); Else.kind = "else"; var If = /*#__PURE__*/function (_BlockNode2) { _inherits(If, _BlockNode2); var _super12 = _createSuper(If); function If(condition, nodes) { var _this9; _classCallCheck(this, If); _this9 = _super12.call(this, nodes); _this9.condition = condition; return _this9; } _createClass(If, [{ key: "render", value: function render(opts) { var code = "if(".concat(this.condition, ")") + _get(_getPrototypeOf(If.prototype), "render", this).call(this, opts); if (this["else"]) code += "else " + this["else"].render(opts); return code; } }, { key: "optimizeNodes", value: function optimizeNodes() { _get(_getPrototypeOf(If.prototype), "optimizeNodes", this).call(this); var cond = this.condition; if (cond === true) return this.nodes; // else is ignored here var e = this["else"]; if (e) { var ns = e.optimizeNodes(); e = this["else"] = Array.isArray(ns) ? new Else(ns) : ns; } if (e) { if (cond === false) return e instanceof If ? e : e.nodes; if (this.nodes.length) return this; return new If(not(cond), e instanceof If ? [e] : e.nodes); } if (cond === false || !this.nodes.length) return undefined; return this; } }, { key: "optimizeNames", value: function optimizeNames(names, constants) { var _a; this["else"] = (_a = this["else"]) === null || _a === void 0 ? void 0 : _a.optimizeNames(names, constants); if (!(_get(_getPrototypeOf(If.prototype), "optimizeNames", this).call(this, names, constants) || this["else"])) return; this.condition = optimizeExpr(this.condition, names, constants); return this; } }, { key: "names", get: function get() { var names = _get(_getPrototypeOf(If.prototype), "names", this); addExprNames(names, this.condition); if (this["else"]) addNames(names, this["else"].names); return names; } }]); return If; }(BlockNode); If.kind = "if"; var For = /*#__PURE__*/function (_BlockNode3) { _inherits(For, _BlockNode3); var _super13 = _createSuper(For); function For() { _classCallCheck(this, For); return _super13.apply(this, arguments); } return _createClass(For); }(BlockNode); For.kind = "for"; var ForLoop = /*#__PURE__*/function (_For) { _inherits(ForLoop, _For); var _super14 = _createSuper(ForLoop); function ForLoop(iteration) { var _this10; _classCallCheck(this, ForLoop); _this10 = _super14.call(this); _this10.iteration = iteration; return _this10; } _createClass(ForLoop, [{ key: "render", value: function render(opts) { return "for(".concat(this.iteration, ")") + _get(_getPrototypeOf(ForLoop.prototype), "render", this).call(this, opts); } }, { key: "optimizeNames", value: function optimizeNames(names, constants) { if (!_get(_getPrototypeOf(ForLoop.prototype), "optimizeNames", this).call(this, names, constants)) return; this.iteration = optimizeExpr(this.iteration, names, constants); return this; } }, { key: "names", get: function get() { return addNames(_get(_getPrototypeOf(ForLoop.prototype), "names", this), this.iteration.names); } }]); return ForLoop; }(For); var ForRange = /*#__PURE__*/function (_For2) { _inherits(ForRange, _For2); var _super15 = _createSuper(ForRange); function ForRange(varKind, name, from, to) { var _this11; _classCallCheck(this, ForRange); _this11 = _super15.call(this); _this11.varKind = varKind; _this11.name = name; _this11.from = from; _this11.to = to; return _this11; } _createClass(ForRange, [{ key: "render", value: function render(opts) { var varKind = opts.es5 ? scope_1.varKinds["var"] : this.varKind; var name = this.name, from = this.from, to = this.to; return "for(".concat(varKind, " ").concat(name, "=").concat(from, "; ").concat(name, "<").concat(to, "; ").concat(name, "++)") + _get(_getPrototypeOf(ForRange.prototype), "render", this).call(this, opts); } }, { key: "names", get: function get() { var names = addExprNames(_get(_getPrototypeOf(ForRange.prototype), "names", this), this.from); return addExprNames(names, this.to); } }]); return ForRange; }(For); var ForIter = /*#__PURE__*/function (_For3) { _inherits(ForIter, _For3); var _super16 = _createSuper(ForIter); function ForIter(loop, varKind, name, iterable) { var _this12; _classCallCheck(this, ForIter); _this12 = _super16.call(this); _this12.loop = loop; _this12.varKind = varKind; _this12.name = name; _this12.iterable = iterable; return _this12; } _createClass(ForIter, [{ key: "render", value: function render(opts) { return "for(".concat(this.varKind, " ").concat(this.name, " ").concat(this.loop, " ").concat(this.iterable, ")") + _get(_getPrototypeOf(ForIter.prototype), "render", this).call(this, opts); } }, { key: "optimizeNames", value: function optimizeNames(names, constants) { if (!_get(_getPrototypeOf(ForIter.prototype), "optimizeNames", this).call(this, names, constants)) return; this.iterable = optimizeExpr(this.iterable, names, constants); return this; } }, { key: "names", get: function get() { return addNames(_get(_getPrototypeOf(ForIter.prototype), "names", this), this.iterable.names); } }]); return ForIter; }(For); var Func = /*#__PURE__*/function (_BlockNode4) { _inherits(Func, _BlockNode4); var _super17 = _createSuper(Func); function Func(name, args, async) { var _this13; _classCallCheck(this, Func); _this13 = _super17.call(this); _this13.name = name; _this13.args = args; _this13.async = async; return _this13; } _createClass(Func, [{ key: "render", value: function render(opts) { var _async = this.async ? "async " : ""; return "".concat(_async, "function ").concat(this.name, "(").concat(this.args, ")") + _get(_getPrototypeOf(Func.prototype), "render", this).call(this, opts); } }]); return Func; }(BlockNode); Func.kind = "func"; var Return = /*#__PURE__*/function (_ParentNode3) { _inherits(Return, _ParentNode3); var _super18 = _createSuper(Return); function Return() { _classCallCheck(this, Return); return _super18.apply(this, arguments); } _createClass(Return, [{ key: "render", value: function render(opts) { return "return " + _get(_getPrototypeOf(Return.prototype), "render", this).call(this, opts); } }]); return Return; }(ParentNode); Return.kind = "return"; var Try = /*#__PURE__*/function (_BlockNode5) { _inherits(Try, _BlockNode5); var _super19 = _createSuper(Try); function Try() { _classCallCheck(this, Try); return _super19.apply(this, arguments); } _createClass(Try, [{ key: "render", value: function render(opts) { var code = "try" + _get(_getPrototypeOf(Try.prototype), "render", this).call(this, opts); if (this["catch"]) code += this["catch"].render(opts); if (this["finally"]) code += this["finally"].render(opts); return code; } }, { key: "optimizeNodes", value: function optimizeNodes() { var _a, _b; _get(_getPrototypeOf(Try.prototype), "optimizeNodes", this).call(this); (_a = this["catch"]) === null || _a === void 0 ? void 0 : _a.optimizeNodes(); (_b = this["finally"]) === null || _b === void 0 ? void 0 : _b.optimizeNodes(); return this; } }, { key: "optimizeNames", value: function optimizeNames(names, constants) { var _a, _b; _get(_getPrototypeOf(Try.prototype), "optimizeNames", this).call(this, names, constants); (_a = this["catch"]) === null || _a === void 0 ? void 0 : _a.optimizeNames(names, constants); (_b = this["finally"]) === null || _b === void 0 ? void 0 : _b.optimizeNames(names, constants); return this; } }, { key: "names", get: function get() { var names = _get(_getPrototypeOf(Try.prototype), "names", this); if (this["catch"]) addNames(names, this["catch"].names); if (this["finally"]) addNames(names, this["finally"].names); return names; } }]); return Try; }(BlockNode); var Catch = /*#__PURE__*/function (_BlockNode6) { _inherits(Catch, _BlockNode6); var _super20 = _createSuper(Catch); function Catch(error) { var _this14; _classCallCheck(this, Catch); _this14 = _super20.call(this); _this14.error = error; return _this14; } _createClass(Catch, [{ key: "render", value: function render(opts) { return "catch(".concat(this.error, ")") + _get(_getPrototypeOf(Catch.prototype), "render", this).call(this, opts); } }]); return Catch; }(BlockNode); Catch.kind = "catch"; var Finally = /*#__PURE__*/function (_BlockNode7) { _inherits(Finally, _BlockNode7); var _super21 = _createSuper(Finally); function Finally() { _classCallCheck(this, Finally); return _super21.apply(this, arguments); } _createClass(Finally, [{ key: "render", value: function render(opts) { return "finally" + _get(_getPrototypeOf(Finally.prototype), "render", this).call(this, opts); } }]); return Finally; }(BlockNode); Finally.kind = "finally"; var CodeGen = /*#__PURE__*/function () { function CodeGen(extScope) { var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; _classCallCheck(this, CodeGen); this._values = {}; this._blockStarts = []; this._constants = {}; this.opts = _objectSpread(_objectSpread({}, opts), {}, { _n: opts.lines ? "\n" : "" }); this._extScope = extScope; this._scope = new scope_1.Scope({ parent: extScope }); this._nodes = [new Root()]; } _createClass(CodeGen, [{ key: "toString", value: function toString() { return this._root.render(this.opts); } // returns unique name in the internal scope }, { key: "name", value: function name(prefix) { return this._scope.name(prefix); } // reserves unique name in the external scope }, { key: "scopeName", value: function scopeName(prefix) { return this._extScope.name(prefix); } // reserves unique name in the external scope and assigns value to it }, { key: "scopeValue", value: function scopeValue(prefixOrName, value) { var name = this._extScope.value(prefixOrName, value); var vs = this._values[name.prefix] || (this._values[name.prefix] = new Set()); vs.add(name); return name; } }, { key: "getScopeValue", value: function getScopeValue(prefix, keyOrRef) { return this._extScope.getValue(prefix, keyOrRef); } // return code that assigns values in the external scope to the names that are used internally // (same names that were returned by gen.scopeName or gen.scopeValue) }, { key: "scopeRefs", value: function scopeRefs(scopeName) { return this._extScope.scopeRefs(scopeName, this._values); } }, { key: "scopeCode", value: function scopeCode() { return this._extScope.scopeCode(this._values); } }, { key: "_def", value: function _def(varKind, nameOrPrefix, rhs, constant) { var name = this._scope.toName(nameOrPrefix); if (rhs !== undefined && constant) this._constants[name.str] = rhs; this._leafNode(new Def(varKind, name, rhs)); return name; } // `const` declaration (`var` in es5 mode) }, { key: "const", value: function _const(nameOrPrefix, rhs, _constant) { return this._def(scope_1.varKinds["const"], nameOrPrefix, rhs, _constant); } // `let` declaration with optional assignment (`var` in es5 mode) }, { key: "let", value: function _let(nameOrPrefix, rhs, _constant) { return this._def(scope_1.varKinds["let"], nameOrPrefix, rhs, _constant); } // `var` declaration with optional assignment }, { key: "var", value: function _var(nameOrPrefix, rhs, _constant) { return this._def(scope_1.varKinds["var"], nameOrPrefix, rhs, _constant); } // assignment code }, { key: "assign", value: function assign(lhs, rhs, sideEffects) { return this._leafNode(new Assign(lhs, rhs, sideEffects)); } // `+=` code }, { key: "add", value: function add(lhs, rhs) { return this._leafNode(new AssignOp(lhs, exports.operators.ADD, rhs)); } // appends passed SafeExpr to code or executes Block }, { key: "code", value: function code(c) { if (typeof c == "function") c();else if (c !== code_1.nil) this._leafNode(new AnyCode(c)); return this; } // returns code for object literal for the passed argument list of key-value pairs }, { key: "object", value: function object() { var code = ["{"]; for (var _len = arguments.length, keyValues = new Array(_len), _key = 0; _key < _len; _key++) { keyValues[_key] = arguments[_key]; } for (var _i = 0, _keyValues = keyValues; _i < _keyValues.length; _i++) { var _keyValues$_i = _slicedToArray(_keyValues[_i], 2), key = _keyValues$_i[0], value = _keyValues$_i[1]; if (code.length > 1) code.push(","); code.push(key); if (key !== value || this.opts.es5) { code.push(":"); (0, code_1.addCodeArg)(code, value); } } code.push("}"); return new code_1._Code(code); } // `if` clause (or statement if `thenBody` and, optionally, `elseBody` are passed) }, { key: "if", value: function _if(condition, thenBody, elseBody) { this._blockNode(new If(condition)); if (thenBody && elseBody) { this.code(thenBody)["else"]().code(elseBody).endIf(); } else if (thenBody) { this.code(thenBody).endIf(); } else if (elseBody) { throw new Error('CodeGen: "else" body without "then" body'); } return this; } // `else if` clause - invalid without `if` or after `else` clauses }, { key: "elseIf", value: function elseIf(condition) { return this._elseNode(new If(condition)); } // `else` clause - only valid after `if` or `else if` clauses }, { key: "else", value: function _else() { return this._elseNode(new Else()); } // end `if` statement (needed if gen.if was used only with condition) }, { key: "endIf", value: function endIf() { return this._endBlockNode(If, Else); } }, { key: "_for", value: function _for(node, forBody) { this._blockNode(node); if (forBody) this.code(forBody).endFor(); return this; } // a generic `for` clause (or statement if `forBody` is passed) }, { key: "for", value: function _for(iteration, forBody) { return this._for(new ForLoop(iteration), forBody); } // `for` statement for a range of values }, { key: "forRange", value: function forRange(nameOrPrefix, from, to, forBody) { var varKind = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : this.opts.es5 ? scope_1.varKinds["var"] : scope_1.varKinds["let"]; var name = this._scope.toName(nameOrPrefix); return this._for(new ForRange(varKind, name, from, to), function () { return forBody(name); }); } // `for-of` statement (in es5 mode replace with a normal for loop) }, { key: "forOf", value: function forOf(nameOrPrefix, iterable, forBody) { var _this15 = this; var varKind = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : scope_1.varKinds["const"]; var name = this._scope.toName(nameOrPrefix); if (this.opts.es5) { var arr = iterable instanceof code_1.Name ? iterable : this["var"]("_arr", iterable); return this.forRange("_i", 0, (0, code_1._)(_templateObject || (_templateObject = _taggedTemplateLiteral(["", ".length"])), arr), function (i) { _this15["var"](name, (0, code_1._)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["", "[", "]"])), arr, i)); forBody(name); }); } return this._for(new ForIter("of", varKind, name, iterable), function () { return forBody(name); }); } // `for-in` statement. // With option `ownProperties` replaced with a `for-of` loop for object keys }, { key: "forIn", value: function forIn(nameOrPrefix, obj, forBody) { var varKind = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : this.opts.es5 ? scope_1.varKinds["var"] : scope_1.varKinds["const"]; if (this.opts.ownProperties) { return this.forOf(nameOrPrefix, (0, code_1._)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["Object.keys(", ")"])), obj), forBody); } var name = this._scope.toName(nameOrPrefix); return this._for(new ForIter("in", varKind, name, obj), function () { return forBody(name); }); } // end `for` loop }, { key: "endFor", value: function endFor() { return this._endBlockNode(For); } // `label` statement }, { key: "label", value: function label(_label) { return this._leafNode(new Label(_label)); } // `break` statement }, { key: "break", value: function _break(label) { return this._leafNode(new Break(label)); } // `return` statement }, { key: "return", value: function _return(value) { var node = new Return(); this._blockNode(node); this.code(value); if (node.nodes.length !== 1) throw new Error('CodeGen: "return" should have one node'); return this._endBlockNode(Return); } // `try` statement }, { key: "try", value: function _try(tryBody, catchCode, finallyCode) { if (!catchCode && !finallyCode) throw new Error('CodeGen: "try" without "catch" and "finally"'); var node = new Try(); this._blockNode(node); this.code(tryBody); if (catchCode) { var error = this.name("e"); this._currNode = node["catch"] = new Catch(error); catchCode(error); } if (finallyCode) { this._currNode = node["finally"] = new Finally(); this.code(finallyCode); } return this._endBlockNode(Catch, Finally); } // `throw` statement }, { key: "throw", value: function _throw(error) { return this._leafNode(new Throw(error)); } // start self-balancing block }, { key: "block", value: function block(body, nodeCount) { this._blockStarts.push(this._nodes.length); if (body) this.code(body).endBlock(nodeCount); return this; } // end the current self-balancing block }, { key: "endBlock", value: function endBlock(nodeCount) { var len = this._blockStarts.pop(); if (len === undefined) throw new Error("CodeGen: not in self-balancing block"); var toClose = this._nodes.length - len; if (toClose < 0 || nodeCount !== undefined && toClose !== nodeCount) { throw new Error("CodeGen: wrong number of nodes: ".concat(toClose, " vs ").concat(nodeCount, " expected")); } this._nodes.length = len; return this; } // `function` heading (or definition if funcBody is passed) }, { key: "func", value: function func(name) { var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : code_1.nil; var async = arguments.length > 2 ? arguments[2] : undefined; var funcBody = arguments.length > 3 ? arguments[3] : undefined; this._blockNode(new Func(name, args, async)); if (funcBody) this.code(funcBody).endFunc(); return this; } // end function definition }, { key: "endFunc", value: function endFunc() { return this._endBlockNode(Func); } }, { key: "optimize", value: function optimize() { var n = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1; while (n-- > 0) { this._root.optimizeNodes(); this._root.optimizeNames(this._root.names, this._constants); } } }, { key: "_leafNode", value: function _leafNode(node) { this._currNode.nodes.push(node); return this; } }, { key: "_blockNode", value: function _blockNode(node) { this._currNode.nodes.push(node); this._nodes.push(node); } }, { key: "_endBlockNode", value: function _endBlockNode(N1, N2) { var n = this._currNode; if (n instanceof N1 || N2 && n instanceof N2) { this._nodes.pop(); return this; } throw new Error("CodeGen: not in block \"".concat(N2 ? "".concat(N1.kind, "/").concat(N2.kind) : N1.kind, "\"")); } }, { key: "_elseNode", value: function _elseNode(node) { var n = this._currNode; if (!(n instanceof If)) { throw new Error('CodeGen: "else" without "if"'); } this._currNode = n["else"] = node; return this; } }, { key: "_root", get: function get() { return this._nodes[0]; } }, { key: "_currNode", get: function get() { var ns = this._nodes; return ns[ns.length - 1]; }, set: function set(node) { var ns = this._nodes; ns[ns.length - 1] = node; } }]); return CodeGen; }(); exports.CodeGen = CodeGen; function addNames(names, from) { for (var n in from) names[n] = (names[n] || 0) + (from[n] || 0); return names; } function addExprNames(names, from) { return from instanceof code_1._CodeOrName ? addNames(names, from.names) : names; } function optimizeExpr(expr, names, constants) { if (expr instanceof code_1.Name) return replaceName(expr); if (!canOptimize(expr)) return expr; return new code_1._Code(expr._items.reduce(function (items, c) { if (c instanceof code_1.Name) c = replaceName(c); if (c instanceof code_1._Code) items.push.apply(items, _toConsumableArray(c._items));else items.push(c); return items; }, [])); function replaceName(n) { var c = constants[n.str]; if (c === undefined || names[n.str] !== 1) return n; delete names[n.str]; return c; } function canOptimize(e) { return e instanceof code_1._Code && e._items.some(function (c) { return c instanceof code_1.Name && names[c.str] === 1 && constants[c.str] !== undefined; }); } } function subtractNames(names, from) { for (var n in from) names[n] = (names[n] || 0) - (from[n] || 0); } function not(x) { return typeof x == "boolean" || typeof x == "number" || x === null ? !x : (0, code_1._)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["!", ""])), par(x)); } exports.not = not; var andCode = mappend(exports.operators.AND); // boolean AND (&&) expression with the passed arguments function and() { for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { args[_key2] = arguments[_key2]; } return args.reduce(andCode); } exports.and = and; var orCode = mappend(exports.operators.OR); // boolean OR (||) expression with the passed arguments function or() { for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { args[_key3] = arguments[_key3]; } return args.reduce(orCode); } exports.or = or; function mappend(op) { return function (x, y) { return x === code_1.nil ? y : y === code_1.nil ? x : (0, code_1._)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["", " ", " ", ""])), par(x), op, par(y)); }; } function par(x) { return x instanceof code_1.Name ? x : (0, code_1._)(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["(", ")"])), x); } },{"./code":12,"./scope":14}],14:[function(require,module,exports){ "use strict"; function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5; function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); } function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); } function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); } function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); } function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct.bind(); } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); } function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } function _isNativeFunction(fn) { try { return Function.toString.call(fn).indexOf("[native code]") !== -1; } catch (e) { return typeof fn === "function"; } } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } Object.defineProperty(exports, "__esModule", { value: true }); exports.ValueScope = exports.ValueScopeName = exports.Scope = exports.varKinds = exports.UsedValueState = void 0; var code_1 = require("./code"); var ValueError = /*#__PURE__*/function (_Error) { _inherits(ValueError, _Error); var _super = _createSuper(ValueError); function ValueError(name) { var _this; _classCallCheck(this, ValueError); _this = _super.call(this, "CodeGen: \"code\" for ".concat(name, " not defined")); _this.value = name.value; return _this; } return _createClass(ValueError); }( /*#__PURE__*/_wrapNativeSuper(Error)); var UsedValueState; (function (UsedValueState) { UsedValueState[UsedValueState["Started"] = 0] = "Started"; UsedValueState[UsedValueState["Completed"] = 1] = "Completed"; })(UsedValueState = exports.UsedValueState || (exports.UsedValueState = {})); exports.varKinds = { "const": new code_1.Name("const"), "let": new code_1.Name("let"), "var": new code_1.Name("var") }; var Scope = /*#__PURE__*/function () { function Scope() { var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, prefixes = _ref.prefixes, parent = _ref.parent; _classCallCheck(this, Scope); this._names = {}; this._prefixes = prefixes; this._parent = parent; } _createClass(Scope, [{ key: "toName", value: function toName(nameOrPrefix) { return nameOrPrefix instanceof code_1.Name ? nameOrPrefix : this.name(nameOrPrefix); } }, { key: "name", value: function name(prefix) { return new code_1.Name(this._newName(prefix)); } }, { key: "_newName", value: function _newName(prefix) { var ng = this._names[prefix] || this._nameGroup(prefix); return "".concat(prefix).concat(ng.index++); } }, { key: "_nameGroup", value: function _nameGroup(prefix) { var _a, _b; if (((_b = (_a = this._parent) === null || _a === void 0 ? void 0 : _a._prefixes) === null || _b === void 0 ? void 0 : _b.has(prefix)) || this._prefixes && !this._prefixes.has(prefix)) { throw new Error("CodeGen: prefix \"".concat(prefix, "\" is not allowed in this scope")); } return this._names[prefix] = { prefix: prefix, index: 0 }; } }]); return Scope; }(); exports.Scope = Scope; var ValueScopeName = /*#__PURE__*/function (_code_1$Name) { _inherits(ValueScopeName, _code_1$Name); var _super2 = _createSuper(ValueScopeName); function ValueScopeName(prefix, nameStr) { var _this2; _classCallCheck(this, ValueScopeName); _this2 = _super2.call(this, nameStr); _this2.prefix = prefix; return _this2; } _createClass(ValueScopeName, [{ key: "setValue", value: function setValue(value, _ref2) { var property = _ref2.property, itemIndex = _ref2.itemIndex; this.value = value; this.scopePath = (0, code_1._)(_templateObject || (_templateObject = _taggedTemplateLiteral([".", "[", "]"])), new code_1.Name(property), itemIndex); } }]); return ValueScopeName; }(code_1.Name); exports.ValueScopeName = ValueScopeName; var line = (0, code_1._)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n"], ["\\n"]))); var ValueScope = /*#__PURE__*/function (_Scope) { _inherits(ValueScope, _Scope); var _super3 = _createSuper(ValueScope); function ValueScope(opts) { var _this3; _classCallCheck(this, ValueScope); _this3 = _super3.call(this, opts); _this3._values = {}; _this3._scope = opts.scope; _this3.opts = _objectSpread(_objectSpread({}, opts), {}, { _n: opts.lines ? line : code_1.nil }); return _this3; } _createClass(ValueScope, [{ key: "get", value: function get() { return this._scope; } }, { key: "name", value: function name(prefix) { return new ValueScopeName(prefix, this._newName(prefix)); } }, { key: "value", value: function value(nameOrPrefix, _value) { var _a; if (_value.ref === undefined) throw new Error("CodeGen: ref must be passed in value"); var name = this.toName(nameOrPrefix); var prefix = name.prefix; var valueKey = (_a = _value.key) !== null && _a !== void 0 ? _a : _value.ref; var vs = this._values[prefix]; if (vs) { var _name = vs.get(valueKey); if (_name) return _name; } else { vs = this._values[prefix] = new Map(); } vs.set(valueKey, name); var s = this._scope[prefix] || (this._scope[prefix] = []); var itemIndex = s.length; s[itemIndex] = _value.ref; name.setValue(_value, { property: prefix, itemIndex: itemIndex }); return name; } }, { key: "getValue", value: function getValue(prefix, keyOrRef) { var vs = this._values[prefix]; if (!vs) return; return vs.get(keyOrRef); } }, { key: "scopeRefs", value: function scopeRefs(scopeName) { var values = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this._values; return this._reduceValues(values, function (name) { if (name.scopePath === undefined) throw new Error("CodeGen: name \"".concat(name, "\" has no value")); return (0, code_1._)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["", "", ""])), scopeName, name.scopePath); }); } }, { key: "scopeCode", value: function scopeCode() { var values = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this._values; var usedValues = arguments.length > 1 ? arguments[1] : undefined; var getCode = arguments.length > 2 ? arguments[2] : undefined; return this._reduceValues(values, function (name) { if (name.value === undefined) throw new Error("CodeGen: name \"".concat(name, "\" has no value")); return name.value.code; }, usedValues, getCode); } }, { key: "_reduceValues", value: function _reduceValues(values, valueCode) { var _this4 = this; var usedValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; var getCode = arguments.length > 3 ? arguments[3] : undefined; var code = code_1.nil; var _loop = function _loop() { var vs = values[prefix]; if (!vs) return 1; // continue var nameSet = usedValues[prefix] = usedValues[prefix] || new Map(); vs.forEach(function (name) { if (nameSet.has(name)) return; nameSet.set(name, UsedValueState.Started); var c = valueCode(name); if (c) { var def = _this4.opts.es5 ? exports.varKinds["var"] : exports.varKinds["const"]; code = (0, code_1._)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["", "", " ", " = ", ";", ""])), code, def, name, c, _this4.opts._n); } else if (c = getCode === null || getCode === void 0 ? void 0 : getCode(name)) { code = (0, code_1._)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["", "", "", ""])), code, c, _this4.opts._n); } else { throw new ValueError(name); } nameSet.set(name, UsedValueState.Completed); }); }; for (var prefix in values) { if (_loop()) continue; } return code; } }]); return ValueScope; }(Scope); exports.ValueScope = ValueScope; },{"./code":12}],15:[function(require,module,exports){ "use strict"; var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17, _templateObject18, _templateObject19, _templateObject20, _templateObject21, _templateObject22, _templateObject23, _templateObject24, _templateObject25; function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } Object.defineProperty(exports, "__esModule", { value: true }); exports.extendErrors = exports.resetErrorsCount = exports.reportExtraError = exports.reportError = exports.keyword$DataError = exports.keywordError = void 0; var codegen_1 = require("./codegen"); var util_1 = require("./util"); var names_1 = require("./names"); exports.keywordError = { message: function message(_ref) { var keyword = _ref.keyword; return (0, codegen_1.str)(_templateObject || (_templateObject = _taggedTemplateLiteral(["must pass \"", "\" keyword validation"])), keyword); } }; exports.keyword$DataError = { message: function message(_ref2) { var keyword = _ref2.keyword, schemaType = _ref2.schemaType; return schemaType ? (0, codegen_1.str)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\"", "\" keyword must be ", " ($data)"])), keyword, schemaType) : (0, codegen_1.str)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\"", "\" keyword is invalid ($data)"])), keyword); } }; function reportError(cxt) { var error = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : exports.keywordError; var errorPaths = arguments.length > 2 ? arguments[2] : undefined; var overrideAllErrors = arguments.length > 3 ? arguments[3] : undefined; var it = cxt.it; var gen = it.gen, compositeRule = it.compositeRule, allErrors = it.allErrors; var errObj = errorObjectCode(cxt, error, errorPaths); if (overrideAllErrors !== null && overrideAllErrors !== void 0 ? overrideAllErrors : compositeRule || allErrors) { addError(gen, errObj); } else { returnErrors(it, (0, codegen_1._)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["[", "]"])), errObj)); } } exports.reportError = reportError; function reportExtraError(cxt) { var error = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : exports.keywordError; var errorPaths = arguments.length > 2 ? arguments[2] : undefined; var it = cxt.it; var gen = it.gen, compositeRule = it.compositeRule, allErrors = it.allErrors; var errObj = errorObjectCode(cxt, error, errorPaths); addError(gen, errObj); if (!(compositeRule || allErrors)) { returnErrors(it, names_1["default"].vErrors); } } exports.reportExtraError = reportExtraError; function resetErrorsCount(gen, errsCount) { gen.assign(names_1["default"].errors, errsCount); gen["if"]((0, codegen_1._)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["", " !== null"])), names_1["default"].vErrors), function () { return gen["if"](errsCount, function () { return gen.assign((0, codegen_1._)(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["", ".length"])), names_1["default"].vErrors), errsCount); }, function () { return gen.assign(names_1["default"].vErrors, null); }); }); } exports.resetErrorsCount = resetErrorsCount; function extendErrors(_ref3) { var gen = _ref3.gen, keyword = _ref3.keyword, schemaValue = _ref3.schemaValue, data = _ref3.data, errsCount = _ref3.errsCount, it = _ref3.it; /* istanbul ignore if */ if (errsCount === undefined) throw new Error("ajv implementation error"); var err = gen.name("err"); gen.forRange("i", errsCount, names_1["default"].errors, function (i) { gen["const"](err, (0, codegen_1._)(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["", "[", "]"])), names_1["default"].vErrors, i)); gen["if"]((0, codegen_1._)(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["", ".instancePath === undefined"])), err), function () { return gen.assign((0, codegen_1._)(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["", ".instancePath"])), err), (0, codegen_1.strConcat)(names_1["default"].instancePath, it.errorPath)); }); gen.assign((0, codegen_1._)(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["", ".schemaPath"])), err), (0, codegen_1.str)(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["", "/", ""])), it.errSchemaPath, keyword)); if (it.opts.verbose) { gen.assign((0, codegen_1._)(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["", ".schema"])), err), schemaValue); gen.assign((0, codegen_1._)(_templateObject13 || (_templateObject13 = _taggedTemplateLiteral(["", ".data"])), err), data); } }); } exports.extendErrors = extendErrors; function addError(gen, errObj) { var err = gen["const"]("err", errObj); gen["if"]((0, codegen_1._)(_templateObject14 || (_templateObject14 = _taggedTemplateLiteral(["", " === null"])), names_1["default"].vErrors), function () { return gen.assign(names_1["default"].vErrors, (0, codegen_1._)(_templateObject15 || (_templateObject15 = _taggedTemplateLiteral(["[", "]"])), err)); }, (0, codegen_1._)(_templateObject16 || (_templateObject16 = _taggedTemplateLiteral(["", ".push(", ")"])), names_1["default"].vErrors, err)); gen.code((0, codegen_1._)(_templateObject17 || (_templateObject17 = _taggedTemplateLiteral(["", "++"])), names_1["default"].errors)); } function returnErrors(it, errs) { var gen = it.gen, validateName = it.validateName, schemaEnv = it.schemaEnv; if (schemaEnv.$async) { gen["throw"]((0, codegen_1._)(_templateObject18 || (_templateObject18 = _taggedTemplateLiteral(["new ", "(", ")"])), it.ValidationError, errs)); } else { gen.assign((0, codegen_1._)(_templateObject19 || (_templateObject19 = _taggedTemplateLiteral(["", ".errors"])), validateName), errs); gen["return"](false); } } var E = { keyword: new codegen_1.Name("keyword"), schemaPath: new codegen_1.Name("schemaPath"), params: new codegen_1.Name("params"), propertyName: new codegen_1.Name("propertyName"), message: new codegen_1.Name("message"), schema: new codegen_1.Name("schema"), parentSchema: new codegen_1.Name("parentSchema") }; function errorObjectCode(cxt, error, errorPaths) { var createErrors = cxt.it.createErrors; if (createErrors === false) return (0, codegen_1._)(_templateObject20 || (_templateObject20 = _taggedTemplateLiteral(["{}"]))); return errorObject(cxt, error, errorPaths); } function errorObject(cxt, error) { var errorPaths = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; var gen = cxt.gen, it = cxt.it; var keyValues = [errorInstancePath(it, errorPaths), errorSchemaPath(cxt, errorPaths)]; extraErrorProps(cxt, error, keyValues); return gen.object.apply(gen, keyValues); } function errorInstancePath(_ref4, _ref5) { var errorPath = _ref4.errorPath; var instancePath = _ref5.instancePath; var instPath = instancePath ? (0, codegen_1.str)(_templateObject21 || (_templateObject21 = _taggedTemplateLiteral(["", "", ""])), errorPath, (0, util_1.getErrorPath)(instancePath, util_1.Type.Str)) : errorPath; return [names_1["default"].instancePath, (0, codegen_1.strConcat)(names_1["default"].instancePath, instPath)]; } function errorSchemaPath(_ref6, _ref7) { var keyword = _ref6.keyword, errSchemaPath = _ref6.it.errSchemaPath; var schemaPath = _ref7.schemaPath, parentSchema = _ref7.parentSchema; var schPath = parentSchema ? errSchemaPath : (0, codegen_1.str)(_templateObject22 || (_templateObject22 = _taggedTemplateLiteral(["", "/", ""])), errSchemaPath, keyword); if (schemaPath) { schPath = (0, codegen_1.str)(_templateObject23 || (_templateObject23 = _taggedTemplateLiteral(["", "", ""])), schPath, (0, util_1.getErrorPath)(schemaPath, util_1.Type.Str)); } return [E.schemaPath, schPath]; } function extraErrorProps(cxt, _ref8, keyValues) { var params = _ref8.params, message = _ref8.message; var keyword = cxt.keyword, data = cxt.data, schemaValue = cxt.schemaValue, it = cxt.it; var opts = it.opts, propertyName = it.propertyName, topSchemaRef = it.topSchemaRef, schemaPath = it.schemaPath; keyValues.push([E.keyword, keyword], [E.params, typeof params == "function" ? params(cxt) : params || (0, codegen_1._)(_templateObject24 || (_templateObject24 = _taggedTemplateLiteral(["{}"])))]); if (opts.messages) { keyValues.push([E.message, typeof message == "function" ? message(cxt) : message]); } if (opts.verbose) { keyValues.push([E.schema, schemaValue], [E.parentSchema, (0, codegen_1._)(_templateObject25 || (_templateObject25 = _taggedTemplateLiteral(["", "", ""])), topSchemaRef, schemaPath)], [names_1["default"].data, data]); } if (propertyName) keyValues.push([E.propertyName, propertyName]); } },{"./codegen":13,"./names":17,"./util":21}],16:[function(require,module,exports){ "use strict"; var _templateObject, _templateObject2; function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); } function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } Object.defineProperty(exports, "__esModule", { value: true }); exports.resolveSchema = exports.getCompilingSchema = exports.resolveRef = exports.compileSchema = exports.SchemaEnv = void 0; var codegen_1 = require("./codegen"); var validation_error_1 = require("../runtime/validation_error"); var names_1 = require("./names"); var resolve_1 = require("./resolve"); var util_1 = require("./util"); var validate_1 = require("./validate"); var SchemaEnv = /*#__PURE__*/_createClass(function SchemaEnv(env) { _classCallCheck(this, SchemaEnv); var _a; this.refs = {}; this.dynamicAnchors = {}; var schema; if (_typeof(env.schema) == "object") schema = env.schema; this.schema = env.schema; this.schemaId = env.schemaId; this.root = env.root || this; this.baseId = (_a = env.baseId) !== null && _a !== void 0 ? _a : (0, resolve_1.normalizeId)(schema === null || schema === void 0 ? void 0 : schema[env.schemaId || "$id"]); this.schemaPath = env.schemaPath; this.localRefs = env.localRefs; this.meta = env.meta; this.$async = schema === null || schema === void 0 ? void 0 : schema.$async; this.refs = {}; }); exports.SchemaEnv = SchemaEnv; // let codeSize = 0 // let nodeCount = 0 // Compiles schema in SchemaEnv function compileSchema(sch) { // TODO refactor - remove compilations var _sch = getCompilingSchema.call(this, sch); if (_sch) return _sch; var rootId = (0, resolve_1.getFullPath)(this.opts.uriResolver, sch.root.baseId); // TODO if getFullPath removed 1 tests fails var _this$opts$code = this.opts.code, es5 = _this$opts$code.es5, lines = _this$opts$code.lines; var ownProperties = this.opts.ownProperties; var gen = new codegen_1.CodeGen(this.scope, { es5: es5, lines: lines, ownProperties: ownProperties }); var _ValidationError; if (sch.$async) { _ValidationError = gen.scopeValue("Error", { ref: validation_error_1["default"], code: (0, codegen_1._)(_templateObject || (_templateObject = _taggedTemplateLiteral(["require(\"ajv/dist/runtime/validation_error\").default"]))) }); } var validateName = gen.scopeName("validate"); sch.validateName = validateName; var schemaCxt = { gen: gen, allErrors: this.opts.allErrors, data: names_1["default"].data, parentData: names_1["default"].parentData, parentDataProperty: names_1["default"].parentDataProperty, dataNames: [names_1["default"].data], dataPathArr: [codegen_1.nil], dataLevel: 0, dataTypes: [], definedProperties: new Set(), topSchemaRef: gen.scopeValue("schema", this.opts.code.source === true ? { ref: sch.schema, code: (0, codegen_1.stringify)(sch.schema) } : { ref: sch.schema }), validateName: validateName, ValidationError: _ValidationError, schema: sch.schema, schemaEnv: sch, rootId: rootId, baseId: sch.baseId || rootId, schemaPath: codegen_1.nil, errSchemaPath: sch.schemaPath || (this.opts.jtd ? "" : "#"), errorPath: (0, codegen_1._)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\"\""]))), opts: this.opts, self: this }; var sourceCode; try { this._compilations.add(sch); (0, validate_1.validateFunctionCode)(schemaCxt); gen.optimize(this.opts.code.optimize); // gen.optimize(1) var validateCode = gen.toString(); sourceCode = "".concat(gen.scopeRefs(names_1["default"].scope), "return ").concat(validateCode); // console.log((codeSize += sourceCode.length), (nodeCount += gen.nodeCount)) if (this.opts.code.process) sourceCode = this.opts.code.process(sourceCode, sch); // console.log("\n\n\n *** \n", sourceCode) var makeValidate = new Function("".concat(names_1["default"].self), "".concat(names_1["default"].scope), sourceCode); var validate = makeValidate(this, this.scope.get()); this.scope.value(validateName, { ref: validate }); validate.errors = null; validate.schema = sch.schema; validate.schemaEnv = sch; if (sch.$async) validate.$async = true; if (this.opts.code.source === true) { validate.source = { validateName: validateName, validateCode: validateCode, scopeValues: gen._values }; } if (this.opts.unevaluated) { var props = schemaCxt.props, items = schemaCxt.items; validate.evaluated = { props: props instanceof codegen_1.Name ? undefined : props, items: items instanceof codegen_1.Name ? undefined : items, dynamicProps: props instanceof codegen_1.Name, dynamicItems: items instanceof codegen_1.Name }; if (validate.source) validate.source.evaluated = (0, codegen_1.stringify)(validate.evaluated); } sch.validate = validate; return sch; } catch (e) { delete sch.validate; delete sch.validateName; if (sourceCode) this.logger.error("Error compiling schema, function code:", sourceCode); // console.log("\n\n\n *** \n", sourceCode, this.opts) throw e; } finally { this._compilations["delete"](sch); } } exports.compileSchema = compileSchema; function resolveRef(root, baseId, ref) { var _a; ref = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, ref); var schOrFunc = root.refs[ref]; if (schOrFunc) return schOrFunc; var _sch = resolve.call(this, root, ref); if (_sch === undefined) { var schema = (_a = root.localRefs) === null || _a === void 0 ? void 0 : _a[ref]; // TODO maybe localRefs should hold SchemaEnv var schemaId = this.opts.schemaId; if (schema) _sch = new SchemaEnv({ schema: schema, schemaId: schemaId, root: root, baseId: baseId }); } if (_sch === undefined) return; return root.refs[ref] = inlineOrCompile.call(this, _sch); } exports.resolveRef = resolveRef; function inlineOrCompile(sch) { if ((0, resolve_1.inlineRef)(sch.schema, this.opts.inlineRefs)) return sch.schema; return sch.validate ? sch : compileSchema.call(this, sch); } // Index of schema compilation in the currently compiled list function getCompilingSchema(schEnv) { var _iterator = _createForOfIteratorHelper(this._compilations), _step; try { for (_iterator.s(); !(_step = _iterator.n()).done;) { var sch = _step.value; if (sameSchemaEnv(sch, schEnv)) return sch; } } catch (err) { _iterator.e(err); } finally { _iterator.f(); } } exports.getCompilingSchema = getCompilingSchema; function sameSchemaEnv(s1, s2) { return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId; } // resolve and compile the references ($ref) // TODO returns AnySchemaObject (if the schema can be inlined) or validation function function resolve(root, // information about the root schema for the current schema ref // reference to resolve ) { var sch; while (typeof (sch = this.refs[ref]) == "string") ref = sch; return sch || this.schemas[ref] || resolveSchema.call(this, root, ref); } // Resolve schema, its root and baseId function resolveSchema(root, // root object with properties schema, refs TODO below SchemaEnv is assigned to it ref // reference to resolve ) { var p = this.opts.uriResolver.parse(ref); var refPath = (0, resolve_1._getFullPath)(this.opts.uriResolver, p); var baseId = (0, resolve_1.getFullPath)(this.opts.uriResolver, root.baseId, undefined); // TODO `Object.keys(root.schema).length > 0` should not be needed - but removing breaks 2 tests if (Object.keys(root.schema).length > 0 && refPath === baseId) { return getJsonPointer.call(this, p, root); } var id = (0, resolve_1.normalizeId)(refPath); var schOrRef = this.refs[id] || this.schemas[id]; if (typeof schOrRef == "string") { var sch = resolveSchema.call(this, root, schOrRef); if (_typeof(sch === null || sch === void 0 ? void 0 : sch.schema) !== "object") return; return getJsonPointer.call(this, p, sch); } if (_typeof(schOrRef === null || schOrRef === void 0 ? void 0 : schOrRef.schema) !== "object") return; if (!schOrRef.validate) compileSchema.call(this, schOrRef); if (id === (0, resolve_1.normalizeId)(ref)) { var schema = schOrRef.schema; var schemaId = this.opts.schemaId; var schId = schema[schemaId]; if (schId) baseId = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, schId); return new SchemaEnv({ schema: schema, schemaId: schemaId, root: root, baseId: baseId }); } return getJsonPointer.call(this, p, schOrRef); } exports.resolveSchema = resolveSchema; var PREVENT_SCOPE_CHANGE = new Set(["properties", "patternProperties", "enum", "dependencies", "definitions"]); function getJsonPointer(parsedRef, _ref) { var baseId = _ref.baseId, schema = _ref.schema, root = _ref.root; var _a; if (((_a = parsedRef.fragment) === null || _a === void 0 ? void 0 : _a[0]) !== "/") return; var _iterator2 = _createForOfIteratorHelper(parsedRef.fragment.slice(1).split("/")), _step2; try { for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { var part = _step2.value; if (typeof schema === "boolean") return; var partSchema = schema[(0, util_1.unescapeFragment)(part)]; if (partSchema === undefined) return; schema = partSchema; // TODO PREVENT_SCOPE_CHANGE could be defined in keyword def? var schId = _typeof(schema) === "object" && schema[this.opts.schemaId]; if (!PREVENT_SCOPE_CHANGE.has(part) && schId) { baseId = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, schId); } } } catch (err) { _iterator2.e(err); } finally { _iterator2.f(); } var env; if (typeof schema != "boolean" && schema.$ref && !(0, util_1.schemaHasRulesButRef)(schema, this.RULES)) { var $ref = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, schema.$ref); env = resolveSchema.call(this, root, $ref); } // even though resolution failed we need to return SchemaEnv to throw exception // so that compileAsync loads missing schema. var schemaId = this.opts.schemaId; env = env || new SchemaEnv({ schema: schema, schemaId: schemaId, root: root, baseId: baseId }); if (env.schema !== env.root.schema) return env; return undefined; } },{"../runtime/validation_error":35,"./codegen":13,"./names":17,"./resolve":19,"./util":21,"./validate":26}],17:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var codegen_1 = require("./codegen"); var names = { // validation function arguments data: new codegen_1.Name("data"), // args passed from referencing schema valCxt: new codegen_1.Name("valCxt"), instancePath: new codegen_1.Name("instancePath"), parentData: new codegen_1.Name("parentData"), parentDataProperty: new codegen_1.Name("parentDataProperty"), rootData: new codegen_1.Name("rootData"), dynamicAnchors: new codegen_1.Name("dynamicAnchors"), // function scoped variables vErrors: new codegen_1.Name("vErrors"), errors: new codegen_1.Name("errors"), "this": new codegen_1.Name("this"), // "globals" self: new codegen_1.Name("self"), scope: new codegen_1.Name("scope"), // JTD serialize/parse name for JSON string and position json: new codegen_1.Name("json"), jsonPos: new codegen_1.Name("jsonPos"), jsonLen: new codegen_1.Name("jsonLen"), jsonPart: new codegen_1.Name("jsonPart") }; exports["default"] = names; },{"./codegen":13}],18:[function(require,module,exports){ "use strict"; function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); } function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); } function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); } function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); } function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct.bind(); } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); } function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } function _isNativeFunction(fn) { try { return Function.toString.call(fn).indexOf("[native code]") !== -1; } catch (e) { return typeof fn === "function"; } } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } Object.defineProperty(exports, "__esModule", { value: true }); var resolve_1 = require("./resolve"); var MissingRefError = /*#__PURE__*/function (_Error) { _inherits(MissingRefError, _Error); var _super = _createSuper(MissingRefError); function MissingRefError(resolver, baseId, ref, msg) { var _this; _classCallCheck(this, MissingRefError); _this = _super.call(this, msg || "can't resolve reference ".concat(ref, " from id ").concat(baseId)); _this.missingRef = (0, resolve_1.resolveUrl)(resolver, baseId, ref); _this.missingSchema = (0, resolve_1.normalizeId)((0, resolve_1.getFullPath)(resolver, _this.missingRef)); return _this; } return _createClass(MissingRefError); }( /*#__PURE__*/_wrapNativeSuper(Error)); exports["default"] = MissingRefError; },{"./resolve":19}],19:[function(require,module,exports){ "use strict"; function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } Object.defineProperty(exports, "__esModule", { value: true }); exports.getSchemaRefs = exports.resolveUrl = exports.normalizeId = exports._getFullPath = exports.getFullPath = exports.inlineRef = void 0; var util_1 = require("./util"); var equal = require("fast-deep-equal"); var traverse = require("json-schema-traverse"); // TODO refactor to use keyword definitions var SIMPLE_INLINED = new Set(["type", "format", "pattern", "maxLength", "minLength", "maxProperties", "minProperties", "maxItems", "minItems", "maximum", "minimum", "uniqueItems", "multipleOf", "required", "enum", "const"]); function inlineRef(schema) { var limit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; if (typeof schema == "boolean") return true; if (limit === true) return !hasRef(schema); if (!limit) return false; return countKeys(schema) <= limit; } exports.inlineRef = inlineRef; var REF_KEYWORDS = new Set(["$ref", "$recursiveRef", "$recursiveAnchor", "$dynamicRef", "$dynamicAnchor"]); function hasRef(schema) { for (var key in schema) { if (REF_KEYWORDS.has(key)) return true; var sch = schema[key]; if (Array.isArray(sch) && sch.some(hasRef)) return true; if (_typeof(sch) == "object" && hasRef(sch)) return true; } return false; } function countKeys(schema) { var count = 0; for (var key in schema) { if (key === "$ref") return Infinity; count++; if (SIMPLE_INLINED.has(key)) continue; if (_typeof(schema[key]) == "object") { (0, util_1.eachItem)(schema[key], function (sch) { return count += countKeys(sch); }); } if (count === Infinity) return Infinity; } return count; } function getFullPath(resolver) { var id = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ""; var normalize = arguments.length > 2 ? arguments[2] : undefined; if (normalize !== false) id = normalizeId(id); var p = resolver.parse(id); return _getFullPath(resolver, p); } exports.getFullPath = getFullPath; function _getFullPath(resolver, p) { var serialized = resolver.serialize(p); return serialized.split("#")[0] + "#"; } exports._getFullPath = _getFullPath; var TRAILING_SLASH_HASH = /#\/?$/; function normalizeId(id) { return id ? id.replace(TRAILING_SLASH_HASH, "") : ""; } exports.normalizeId = normalizeId; function resolveUrl(resolver, baseId, id) { id = normalizeId(id); return resolver.resolve(baseId, id); } exports.resolveUrl = resolveUrl; var ANCHOR = /^[a-z_][-a-z0-9._]*$/i; function getSchemaRefs(schema, baseId) { var _this = this; if (typeof schema == "boolean") return {}; var _this$opts = this.opts, schemaId = _this$opts.schemaId, uriResolver = _this$opts.uriResolver; var schId = normalizeId(schema[schemaId] || baseId); var baseIds = { "": schId }; var pathPrefix = getFullPath(uriResolver, schId, false); var localRefs = {}; var schemaRefs = new Set(); traverse(schema, { allKeys: true }, function (sch, jsonPtr, _, parentJsonPtr) { if (parentJsonPtr === undefined) return; var fullPath = pathPrefix + jsonPtr; var baseId = baseIds[parentJsonPtr]; if (typeof sch[schemaId] == "string") baseId = addRef.call(_this, sch[schemaId]); addAnchor.call(_this, sch.$anchor); addAnchor.call(_this, sch.$dynamicAnchor); baseIds[jsonPtr] = baseId; function addRef(ref) { // eslint-disable-next-line @typescript-eslint/unbound-method var _resolve = this.opts.uriResolver.resolve; ref = normalizeId(baseId ? _resolve(baseId, ref) : ref); if (schemaRefs.has(ref)) throw ambiguos(ref); schemaRefs.add(ref); var schOrRef = this.refs[ref]; if (typeof schOrRef == "string") schOrRef = this.refs[schOrRef]; if (_typeof(schOrRef) == "object") { checkAmbiguosRef(sch, schOrRef.schema, ref); } else if (ref !== normalizeId(fullPath)) { if (ref[0] === "#") { checkAmbiguosRef(sch, localRefs[ref], ref); localRefs[ref] = sch; } else { this.refs[ref] = fullPath; } } return ref; } function addAnchor(anchor) { if (typeof anchor == "string") { if (!ANCHOR.test(anchor)) throw new Error("invalid anchor \"".concat(anchor, "\"")); addRef.call(this, "#".concat(anchor)); } } }); return localRefs; function checkAmbiguosRef(sch1, sch2, ref) { if (sch2 !== undefined && !equal(sch1, sch2)) throw ambiguos(ref); } function ambiguos(ref) { return new Error("reference \"".concat(ref, "\" resolves to more than one schema")); } } exports.getSchemaRefs = getSchemaRefs; },{"./util":21,"fast-deep-equal":75,"json-schema-traverse":78}],20:[function(require,module,exports){ "use strict"; function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); } function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } Object.defineProperty(exports, "__esModule", { value: true }); exports.getRules = exports.isJSONType = void 0; var _jsonTypes = ["string", "number", "integer", "boolean", "null", "object", "array"]; var jsonTypes = new Set(_jsonTypes); function isJSONType(x) { return typeof x == "string" && jsonTypes.has(x); } exports.isJSONType = isJSONType; function getRules() { var groups = { number: { type: "number", rules: [] }, string: { type: "string", rules: [] }, array: { type: "array", rules: [] }, object: { type: "object", rules: [] } }; return { types: _objectSpread(_objectSpread({}, groups), {}, { integer: true, "boolean": true, "null": true }), rules: [{ rules: [] }, groups.number, groups.string, groups.array, groups.object], post: { rules: [] }, all: {}, keywords: {} }; } exports.getRules = getRules; },{}],21:[function(require,module,exports){ "use strict"; function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17, _templateObject18; function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); } function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } Object.defineProperty(exports, "__esModule", { value: true }); exports.checkStrictMode = exports.getErrorPath = exports.Type = exports.useFunc = exports.setEvaluated = exports.evaluatedPropsToName = exports.mergeEvaluated = exports.eachItem = exports.unescapeJsonPointer = exports.escapeJsonPointer = exports.escapeFragment = exports.unescapeFragment = exports.schemaRefOrVal = exports.schemaHasRulesButRef = exports.schemaHasRules = exports.checkUnknownRules = exports.alwaysValidSchema = exports.toHash = void 0; var codegen_1 = require("./codegen"); var code_1 = require("./codegen/code"); // TODO refactor to use Set function toHash(arr) { var hash = {}; var _iterator = _createForOfIteratorHelper(arr), _step; try { for (_iterator.s(); !(_step = _iterator.n()).done;) { var item = _step.value; hash[item] = true; } } catch (err) { _iterator.e(err); } finally { _iterator.f(); } return hash; } exports.toHash = toHash; function alwaysValidSchema(it, schema) { if (typeof schema == "boolean") return schema; if (Object.keys(schema).length === 0) return true; checkUnknownRules(it, schema); return !schemaHasRules(schema, it.self.RULES.all); } exports.alwaysValidSchema = alwaysValidSchema; function checkUnknownRules(it) { var schema = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : it.schema; var opts = it.opts, self = it.self; if (!opts.strictSchema) return; if (typeof schema === "boolean") return; var rules = self.RULES.keywords; for (var key in schema) { if (!rules[key]) checkStrictMode(it, "unknown keyword: \"".concat(key, "\"")); } } exports.checkUnknownRules = checkUnknownRules; function schemaHasRules(schema, rules) { if (typeof schema == "boolean") return !schema; for (var key in schema) if (rules[key]) return true; return false; } exports.schemaHasRules = schemaHasRules; function schemaHasRulesButRef(schema, RULES) { if (typeof schema == "boolean") return !schema; for (var key in schema) if (key !== "$ref" && RULES.all[key]) return true; return false; } exports.schemaHasRulesButRef = schemaHasRulesButRef; function schemaRefOrVal(_ref, schema, keyword, $data) { var topSchemaRef = _ref.topSchemaRef, schemaPath = _ref.schemaPath; if (!$data) { if (typeof schema == "number" || typeof schema == "boolean") return schema; if (typeof schema == "string") return (0, codegen_1._)(_templateObject || (_templateObject = _taggedTemplateLiteral(["", ""])), schema); } return (0, codegen_1._)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["", "", "", ""])), topSchemaRef, schemaPath, (0, codegen_1.getProperty)(keyword)); } exports.schemaRefOrVal = schemaRefOrVal; function unescapeFragment(str) { return unescapeJsonPointer(decodeURIComponent(str)); } exports.unescapeFragment = unescapeFragment; function escapeFragment(str) { return encodeURIComponent(escapeJsonPointer(str)); } exports.escapeFragment = escapeFragment; function escapeJsonPointer(str) { if (typeof str == "number") return "".concat(str); return str.replace(/~/g, "~0").replace(/\//g, "~1"); } exports.escapeJsonPointer = escapeJsonPointer; function unescapeJsonPointer(str) { return str.replace(/~1/g, "/").replace(/~0/g, "~"); } exports.unescapeJsonPointer = unescapeJsonPointer; function eachItem(xs, f) { if (Array.isArray(xs)) { var _iterator2 = _createForOfIteratorHelper(xs), _step2; try { for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { var x = _step2.value; f(x); } } catch (err) { _iterator2.e(err); } finally { _iterator2.f(); } } else { f(xs); } } exports.eachItem = eachItem; function makeMergeEvaluated(_ref2) { var mergeNames = _ref2.mergeNames, mergeToName = _ref2.mergeToName, mergeValues = _ref2.mergeValues, resultToName = _ref2.resultToName; return function (gen, from, to, toName) { var res = to === undefined ? from : to instanceof codegen_1.Name ? (from instanceof codegen_1.Name ? mergeNames(gen, from, to) : mergeToName(gen, from, to), to) : from instanceof codegen_1.Name ? (mergeToName(gen, to, from), from) : mergeValues(from, to); return toName === codegen_1.Name && !(res instanceof codegen_1.Name) ? resultToName(gen, res) : res; }; } exports.mergeEvaluated = { props: makeMergeEvaluated({ mergeNames: function mergeNames(gen, from, to) { return gen["if"]((0, codegen_1._)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["", " !== true && ", " !== undefined"])), to, from), function () { gen["if"]((0, codegen_1._)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["", " === true"])), from), function () { return gen.assign(to, true); }, function () { return gen.assign(to, (0, codegen_1._)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["", " || {}"])), to)).code((0, codegen_1._)(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["Object.assign(", ", ", ")"])), to, from)); }); }); }, mergeToName: function mergeToName(gen, from, to) { return gen["if"]((0, codegen_1._)(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["", " !== true"])), to), function () { if (from === true) { gen.assign(to, true); } else { gen.assign(to, (0, codegen_1._)(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["", " || {}"])), to)); setEvaluated(gen, to, from); } }); }, mergeValues: function mergeValues(from, to) { return from === true ? true : _objectSpread(_objectSpread({}, from), to); }, resultToName: evaluatedPropsToName }), items: makeMergeEvaluated({ mergeNames: function mergeNames(gen, from, to) { return gen["if"]((0, codegen_1._)(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["", " !== true && ", " !== undefined"])), to, from), function () { return gen.assign(to, (0, codegen_1._)(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["", " === true ? true : ", " > ", " ? ", " : ", ""])), from, to, from, to, from)); }); }, mergeToName: function mergeToName(gen, from, to) { return gen["if"]((0, codegen_1._)(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["", " !== true"])), to), function () { return gen.assign(to, from === true ? true : (0, codegen_1._)(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["", " > ", " ? ", " : ", ""])), to, from, to, from)); }); }, mergeValues: function mergeValues(from, to) { return from === true ? true : Math.max(from, to); }, resultToName: function resultToName(gen, items) { return gen["var"]("items", items); } }) }; function evaluatedPropsToName(gen, ps) { if (ps === true) return gen["var"]("props", true); var props = gen["var"]("props", (0, codegen_1._)(_templateObject13 || (_templateObject13 = _taggedTemplateLiteral(["{}"])))); if (ps !== undefined) setEvaluated(gen, props, ps); return props; } exports.evaluatedPropsToName = evaluatedPropsToName; function setEvaluated(gen, props, ps) { Object.keys(ps).forEach(function (p) { return gen.assign((0, codegen_1._)(_templateObject14 || (_templateObject14 = _taggedTemplateLiteral(["", "", ""])), props, (0, codegen_1.getProperty)(p)), true); }); } exports.setEvaluated = setEvaluated; var snippets = {}; function useFunc(gen, f) { return gen.scopeValue("func", { ref: f, code: snippets[f.code] || (snippets[f.code] = new code_1._Code(f.code)) }); } exports.useFunc = useFunc; var Type; (function (Type) { Type[Type["Num"] = 0] = "Num"; Type[Type["Str"] = 1] = "Str"; })(Type = exports.Type || (exports.Type = {})); function getErrorPath(dataProp, dataPropType, jsPropertySyntax) { // let path if (dataProp instanceof codegen_1.Name) { var isNumber = dataPropType === Type.Num; return jsPropertySyntax ? isNumber ? (0, codegen_1._)(_templateObject15 || (_templateObject15 = _taggedTemplateLiteral(["\"[\" + ", " + \"]\""])), dataProp) : (0, codegen_1._)(_templateObject16 || (_templateObject16 = _taggedTemplateLiteral(["\"['\" + ", " + \"']\""])), dataProp) : isNumber ? (0, codegen_1._)(_templateObject17 || (_templateObject17 = _taggedTemplateLiteral(["\"/\" + ", ""])), dataProp) : (0, codegen_1._)(_templateObject18 || (_templateObject18 = _taggedTemplateLiteral(["\"/\" + ", ".replace(/~/g, \"~0\").replace(/\\//g, \"~1\")"], ["\"/\" + ", ".replace(/~/g, \"~0\").replace(/\\\\//g, \"~1\")"])), dataProp); // TODO maybe use global escapePointer } return jsPropertySyntax ? (0, codegen_1.getProperty)(dataProp).toString() : "/" + escapeJsonPointer(dataProp); } exports.getErrorPath = getErrorPath; function checkStrictMode(it, msg) { var mode = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : it.opts.strictSchema; if (!mode) return; msg = "strict mode: ".concat(msg); if (mode === true) throw new Error(msg); it.self.logger.warn(msg); } exports.checkStrictMode = checkStrictMode; },{"./codegen":13,"./codegen/code":12}],22:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.shouldUseRule = exports.shouldUseGroup = exports.schemaHasRulesForType = void 0; function schemaHasRulesForType(_ref, type) { var schema = _ref.schema, self = _ref.self; var group = self.RULES.types[type]; return group && group !== true && shouldUseGroup(schema, group); } exports.schemaHasRulesForType = schemaHasRulesForType; function shouldUseGroup(schema, group) { return group.rules.some(function (rule) { return shouldUseRule(schema, rule); }); } exports.shouldUseGroup = shouldUseGroup; function shouldUseRule(schema, rule) { var _a; return schema[rule.keyword] !== undefined || ((_a = rule.definition["implements"]) === null || _a === void 0 ? void 0 : _a.some(function (kwd) { return schema[kwd] !== undefined; })); } exports.shouldUseRule = shouldUseRule; },{}],23:[function(require,module,exports){ "use strict"; var _templateObject; function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } Object.defineProperty(exports, "__esModule", { value: true }); exports.boolOrEmptySchema = exports.topBoolOrEmptySchema = void 0; var errors_1 = require("../errors"); var codegen_1 = require("../codegen"); var names_1 = require("../names"); var boolError = { message: "boolean schema is false" }; function topBoolOrEmptySchema(it) { var gen = it.gen, schema = it.schema, validateName = it.validateName; if (schema === false) { falseSchemaError(it, false); } else if (_typeof(schema) == "object" && schema.$async === true) { gen["return"](names_1["default"].data); } else { gen.assign((0, codegen_1._)(_templateObject || (_templateObject = _taggedTemplateLiteral(["", ".errors"])), validateName), null); gen["return"](true); } } exports.topBoolOrEmptySchema = topBoolOrEmptySchema; function boolOrEmptySchema(it, valid) { var gen = it.gen, schema = it.schema; if (schema === false) { gen["var"](valid, false); // TODO var falseSchemaError(it); } else { gen["var"](valid, true); // TODO var } } exports.boolOrEmptySchema = boolOrEmptySchema; function falseSchemaError(it, overrideAllErrors) { var gen = it.gen, data = it.data; // TODO maybe some other interface should be used for non-keyword validation errors... var cxt = { gen: gen, keyword: "false schema", data: data, schema: false, schemaCode: false, schemaValue: false, params: {}, it: it }; (0, errors_1.reportError)(cxt, boolError, undefined, overrideAllErrors); } },{"../codegen":13,"../errors":15,"../names":17}],24:[function(require,module,exports){ "use strict"; var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17, _templateObject18, _templateObject19, _templateObject20, _templateObject21, _templateObject22, _templateObject23, _templateObject24, _templateObject25, _templateObject26, _templateObject27, _templateObject28, _templateObject29, _templateObject30, _templateObject31, _templateObject32, _templateObject33; function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } Object.defineProperty(exports, "__esModule", { value: true }); exports.reportTypeError = exports.checkDataTypes = exports.checkDataType = exports.coerceAndCheckDataType = exports.getJSONTypes = exports.getSchemaTypes = exports.DataType = void 0; var rules_1 = require("../rules"); var applicability_1 = require("./applicability"); var errors_1 = require("../errors"); var codegen_1 = require("../codegen"); var util_1 = require("../util"); var DataType; (function (DataType) { DataType[DataType["Correct"] = 0] = "Correct"; DataType[DataType["Wrong"] = 1] = "Wrong"; })(DataType = exports.DataType || (exports.DataType = {})); function getSchemaTypes(schema) { var types = getJSONTypes(schema.type); var hasNull = types.includes("null"); if (hasNull) { if (schema.nullable === false) throw new Error("type: null contradicts nullable: false"); } else { if (!types.length && schema.nullable !== undefined) { throw new Error('"nullable" cannot be used without "type"'); } if (schema.nullable === true) types.push("null"); } return types; } exports.getSchemaTypes = getSchemaTypes; function getJSONTypes(ts) { var types = Array.isArray(ts) ? ts : ts ? [ts] : []; if (types.every(rules_1.isJSONType)) return types; throw new Error("type must be JSONType or JSONType[]: " + types.join(",")); } exports.getJSONTypes = getJSONTypes; function coerceAndCheckDataType(it, types) { var gen = it.gen, data = it.data, opts = it.opts; var coerceTo = coerceToTypes(types, opts.coerceTypes); var checkTypes = types.length > 0 && !(coerceTo.length === 0 && types.length === 1 && (0, applicability_1.schemaHasRulesForType)(it, types[0])); if (checkTypes) { var wrongType = checkDataTypes(types, data, opts.strictNumbers, DataType.Wrong); gen["if"](wrongType, function () { if (coerceTo.length) coerceData(it, types, coerceTo);else reportTypeError(it); }); } return checkTypes; } exports.coerceAndCheckDataType = coerceAndCheckDataType; var COERCIBLE = new Set(["string", "number", "integer", "boolean", "null"]); function coerceToTypes(types, coerceTypes) { return coerceTypes ? types.filter(function (t) { return COERCIBLE.has(t) || coerceTypes === "array" && t === "array"; }) : []; } function coerceData(it, types, coerceTo) { var gen = it.gen, data = it.data, opts = it.opts; var dataType = gen["let"]("dataType", (0, codegen_1._)(_templateObject || (_templateObject = _taggedTemplateLiteral(["typeof ", ""])), data)); var coerced = gen["let"]("coerced", (0, codegen_1._)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["undefined"])))); if (opts.coerceTypes === "array") { gen["if"]((0, codegen_1._)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["", " == 'object' && Array.isArray(", ") && ", ".length == 1"])), dataType, data, data), function () { return gen.assign(data, (0, codegen_1._)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["", "[0]"])), data)).assign(dataType, (0, codegen_1._)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["typeof ", ""])), data))["if"](checkDataTypes(types, data, opts.strictNumbers), function () { return gen.assign(coerced, data); }); }); } gen["if"]((0, codegen_1._)(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["", " !== undefined"])), coerced)); var _iterator = _createForOfIteratorHelper(coerceTo), _step; try { for (_iterator.s(); !(_step = _iterator.n()).done;) { var t = _step.value; if (COERCIBLE.has(t) || t === "array" && opts.coerceTypes === "array") { coerceSpecificType(t); } } } catch (err) { _iterator.e(err); } finally { _iterator.f(); } gen["else"](); reportTypeError(it); gen.endIf(); gen["if"]((0, codegen_1._)(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["", " !== undefined"])), coerced), function () { gen.assign(data, coerced); assignParentData(it, coerced); }); function coerceSpecificType(t) { switch (t) { case "string": gen.elseIf((0, codegen_1._)(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["", " == \"number\" || ", " == \"boolean\""])), dataType, dataType)).assign(coerced, (0, codegen_1._)(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\"\" + ", ""])), data)).elseIf((0, codegen_1._)(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["", " === null"])), data)).assign(coerced, (0, codegen_1._)(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["\"\""])))); return; case "number": gen.elseIf((0, codegen_1._)(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["", " == \"boolean\" || ", " === null\n || (", " == \"string\" && ", " && ", " == +", ")"])), dataType, data, dataType, data, data, data)).assign(coerced, (0, codegen_1._)(_templateObject13 || (_templateObject13 = _taggedTemplateLiteral(["+", ""])), data)); return; case "integer": gen.elseIf((0, codegen_1._)(_templateObject14 || (_templateObject14 = _taggedTemplateLiteral(["", " === \"boolean\" || ", " === null\n || (", " === \"string\" && ", " && ", " == +", " && !(", " % 1))"])), dataType, data, dataType, data, data, data, data)).assign(coerced, (0, codegen_1._)(_templateObject15 || (_templateObject15 = _taggedTemplateLiteral(["+", ""])), data)); return; case "boolean": gen.elseIf((0, codegen_1._)(_templateObject16 || (_templateObject16 = _taggedTemplateLiteral(["", " === \"false\" || ", " === 0 || ", " === null"])), data, data, data)).assign(coerced, false).elseIf((0, codegen_1._)(_templateObject17 || (_templateObject17 = _taggedTemplateLiteral(["", " === \"true\" || ", " === 1"])), data, data)).assign(coerced, true); return; case "null": gen.elseIf((0, codegen_1._)(_templateObject18 || (_templateObject18 = _taggedTemplateLiteral(["", " === \"\" || ", " === 0 || ", " === false"])), data, data, data)); gen.assign(coerced, null); return; case "array": gen.elseIf((0, codegen_1._)(_templateObject19 || (_templateObject19 = _taggedTemplateLiteral(["", " === \"string\" || ", " === \"number\"\n || ", " === \"boolean\" || ", " === null"])), dataType, dataType, dataType, data)).assign(coerced, (0, codegen_1._)(_templateObject20 || (_templateObject20 = _taggedTemplateLiteral(["[", "]"])), data)); } } } function assignParentData(_ref, expr) { var gen = _ref.gen, parentData = _ref.parentData, parentDataProperty = _ref.parentDataProperty; // TODO use gen.property gen["if"]((0, codegen_1._)(_templateObject21 || (_templateObject21 = _taggedTemplateLiteral(["", " !== undefined"])), parentData), function () { return gen.assign((0, codegen_1._)(_templateObject22 || (_templateObject22 = _taggedTemplateLiteral(["", "[", "]"])), parentData, parentDataProperty), expr); }); } function checkDataType(dataType, data, strictNums) { var correct = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : DataType.Correct; var EQ = correct === DataType.Correct ? codegen_1.operators.EQ : codegen_1.operators.NEQ; var cond; switch (dataType) { case "null": return (0, codegen_1._)(_templateObject23 || (_templateObject23 = _taggedTemplateLiteral(["", " ", " null"])), data, EQ); case "array": cond = (0, codegen_1._)(_templateObject24 || (_templateObject24 = _taggedTemplateLiteral(["Array.isArray(", ")"])), data); break; case "object": cond = (0, codegen_1._)(_templateObject25 || (_templateObject25 = _taggedTemplateLiteral(["", " && typeof ", " == \"object\" && !Array.isArray(", ")"])), data, data, data); break; case "integer": cond = numCond((0, codegen_1._)(_templateObject26 || (_templateObject26 = _taggedTemplateLiteral(["!(", " % 1) && !isNaN(", ")"])), data, data)); break; case "number": cond = numCond(); break; default: return (0, codegen_1._)(_templateObject27 || (_templateObject27 = _taggedTemplateLiteral(["typeof ", " ", " ", ""])), data, EQ, dataType); } return correct === DataType.Correct ? cond : (0, codegen_1.not)(cond); function numCond() { var _cond = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : codegen_1.nil; return (0, codegen_1.and)((0, codegen_1._)(_templateObject28 || (_templateObject28 = _taggedTemplateLiteral(["typeof ", " == \"number\""])), data), _cond, strictNums ? (0, codegen_1._)(_templateObject29 || (_templateObject29 = _taggedTemplateLiteral(["isFinite(", ")"])), data) : codegen_1.nil); } } exports.checkDataType = checkDataType; function checkDataTypes(dataTypes, data, strictNums, correct) { if (dataTypes.length === 1) { return checkDataType(dataTypes[0], data, strictNums, correct); } var cond; var types = (0, util_1.toHash)(dataTypes); if (types.array && types.object) { var notObj = (0, codegen_1._)(_templateObject30 || (_templateObject30 = _taggedTemplateLiteral(["typeof ", " != \"object\""])), data); cond = types["null"] ? notObj : (0, codegen_1._)(_templateObject31 || (_templateObject31 = _taggedTemplateLiteral(["!", " || ", ""])), data, notObj); delete types["null"]; delete types.array; delete types.object; } else { cond = codegen_1.nil; } if (types.number) delete types.integer; for (var t in types) cond = (0, codegen_1.and)(cond, checkDataType(t, data, strictNums, correct)); return cond; } exports.checkDataTypes = checkDataTypes; var typeError = { message: function message(_ref2) { var schema = _ref2.schema; return "must be ".concat(schema); }, params: function params(_ref3) { var schema = _ref3.schema, schemaValue = _ref3.schemaValue; return typeof schema == "string" ? (0, codegen_1._)(_templateObject32 || (_templateObject32 = _taggedTemplateLiteral(["{type: ", "}"])), schema) : (0, codegen_1._)(_templateObject33 || (_templateObject33 = _taggedTemplateLiteral(["{type: ", "}"])), schemaValue); } }; function reportTypeError(it) { var cxt = getTypeErrorContext(it); (0, errors_1.reportError)(cxt, typeError); } exports.reportTypeError = reportTypeError; function getTypeErrorContext(it) { var gen = it.gen, data = it.data, schema = it.schema; var schemaCode = (0, util_1.schemaRefOrVal)(it, schema, "type"); return { gen: gen, keyword: "type", data: data, schema: schema.type, schemaCode: schemaCode, schemaValue: schemaCode, parentSchema: schema, params: {}, it: it }; } },{"../codegen":13,"../errors":15,"../rules":20,"../util":21,"./applicability":22}],25:[function(require,module,exports){ "use strict"; var _templateObject, _templateObject2, _templateObject3, _templateObject4; function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } Object.defineProperty(exports, "__esModule", { value: true }); exports.assignDefaults = void 0; var codegen_1 = require("../codegen"); var util_1 = require("../util"); function assignDefaults(it, ty) { var _it$schema = it.schema, properties = _it$schema.properties, items = _it$schema.items; if (ty === "object" && properties) { for (var key in properties) { assignDefault(it, key, properties[key]["default"]); } } else if (ty === "array" && Array.isArray(items)) { items.forEach(function (sch, i) { return assignDefault(it, i, sch["default"]); }); } } exports.assignDefaults = assignDefaults; function assignDefault(it, prop, defaultValue) { var gen = it.gen, compositeRule = it.compositeRule, data = it.data, opts = it.opts; if (defaultValue === undefined) return; var childData = (0, codegen_1._)(_templateObject || (_templateObject = _taggedTemplateLiteral(["", "", ""])), data, (0, codegen_1.getProperty)(prop)); if (compositeRule) { (0, util_1.checkStrictMode)(it, "default is ignored for: ".concat(childData)); return; } var condition = (0, codegen_1._)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["", " === undefined"])), childData); if (opts.useDefaults === "empty") { condition = (0, codegen_1._)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["", " || ", " === null || ", " === \"\""])), condition, childData, childData); } // `${childData} === undefined` + // (opts.useDefaults === "empty" ? ` || ${childData} === null || ${childData} === ""` : "") gen["if"](condition, (0, codegen_1._)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["", " = ", ""])), childData, (0, codegen_1.stringify)(defaultValue))); } },{"../codegen":13,"../util":21}],26:[function(require,module,exports){ "use strict"; var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17, _templateObject18, _templateObject19, _templateObject20, _templateObject21, _templateObject22, _templateObject23, _templateObject24, _templateObject25, _templateObject26, _templateObject27, _templateObject28, _templateObject29, _templateObject30, _templateObject31, _templateObject32, _templateObject33, _templateObject34, _templateObject35, _templateObject36, _templateObject37, _templateObject38, _templateObject39; function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); } function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } Object.defineProperty(exports, "__esModule", { value: true }); exports.getData = exports.KeywordCxt = exports.validateFunctionCode = void 0; var boolSchema_1 = require("./boolSchema"); var dataType_1 = require("./dataType"); var applicability_1 = require("./applicability"); var dataType_2 = require("./dataType"); var defaults_1 = require("./defaults"); var keyword_1 = require("./keyword"); var subschema_1 = require("./subschema"); var codegen_1 = require("../codegen"); var names_1 = require("../names"); var resolve_1 = require("../resolve"); var util_1 = require("../util"); var errors_1 = require("../errors"); // schema compilation - generates validation function, subschemaCode (below) is used for subschemas function validateFunctionCode(it) { if (isSchemaObj(it)) { checkKeywords(it); if (schemaCxtHasRules(it)) { topSchemaObjCode(it); return; } } validateFunction(it, function () { return (0, boolSchema_1.topBoolOrEmptySchema)(it); }); } exports.validateFunctionCode = validateFunctionCode; function validateFunction(_ref, body) { var gen = _ref.gen, validateName = _ref.validateName, schema = _ref.schema, schemaEnv = _ref.schemaEnv, opts = _ref.opts; if (opts.code.es5) { gen.func(validateName, (0, codegen_1._)(_templateObject || (_templateObject = _taggedTemplateLiteral(["", ", ", ""])), names_1["default"].data, names_1["default"].valCxt), schemaEnv.$async, function () { gen.code((0, codegen_1._)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\"use strict\"; ", ""])), funcSourceUrl(schema, opts))); destructureValCxtES5(gen, opts); gen.code(body); }); } else { gen.func(validateName, (0, codegen_1._)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["", ", ", ""])), names_1["default"].data, destructureValCxt(opts)), schemaEnv.$async, function () { return gen.code(funcSourceUrl(schema, opts)).code(body); }); } } function destructureValCxt(opts) { return (0, codegen_1._)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["{", "=\"\", ", ", ", ", ", "=", "", "}={}"])), names_1["default"].instancePath, names_1["default"].parentData, names_1["default"].parentDataProperty, names_1["default"].rootData, names_1["default"].data, opts.dynamicRef ? (0, codegen_1._)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral([", ", "={}"])), names_1["default"].dynamicAnchors) : codegen_1.nil); } function destructureValCxtES5(gen, opts) { gen["if"](names_1["default"].valCxt, function () { gen["var"](names_1["default"].instancePath, (0, codegen_1._)(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["", ".", ""])), names_1["default"].valCxt, names_1["default"].instancePath)); gen["var"](names_1["default"].parentData, (0, codegen_1._)(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["", ".", ""])), names_1["default"].valCxt, names_1["default"].parentData)); gen["var"](names_1["default"].parentDataProperty, (0, codegen_1._)(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["", ".", ""])), names_1["default"].valCxt, names_1["default"].parentDataProperty)); gen["var"](names_1["default"].rootData, (0, codegen_1._)(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["", ".", ""])), names_1["default"].valCxt, names_1["default"].rootData)); if (opts.dynamicRef) gen["var"](names_1["default"].dynamicAnchors, (0, codegen_1._)(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["", ".", ""])), names_1["default"].valCxt, names_1["default"].dynamicAnchors)); }, function () { gen["var"](names_1["default"].instancePath, (0, codegen_1._)(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["\"\""])))); gen["var"](names_1["default"].parentData, (0, codegen_1._)(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["undefined"])))); gen["var"](names_1["default"].parentDataProperty, (0, codegen_1._)(_templateObject13 || (_templateObject13 = _taggedTemplateLiteral(["undefined"])))); gen["var"](names_1["default"].rootData, names_1["default"].data); if (opts.dynamicRef) gen["var"](names_1["default"].dynamicAnchors, (0, codegen_1._)(_templateObject14 || (_templateObject14 = _taggedTemplateLiteral(["{}"])))); }); } function topSchemaObjCode(it) { var schema = it.schema, opts = it.opts, gen = it.gen; validateFunction(it, function () { if (opts.$comment && schema.$comment) commentKeyword(it); checkNoDefault(it); gen["let"](names_1["default"].vErrors, null); gen["let"](names_1["default"].errors, 0); if (opts.unevaluated) resetEvaluated(it); typeAndKeywords(it); returnResults(it); }); return; } function resetEvaluated(it) { // TODO maybe some hook to execute it in the end to check whether props/items are Name, as in assignEvaluated var gen = it.gen, validateName = it.validateName; it.evaluated = gen["const"]("evaluated", (0, codegen_1._)(_templateObject15 || (_templateObject15 = _taggedTemplateLiteral(["", ".evaluated"])), validateName)); gen["if"]((0, codegen_1._)(_templateObject16 || (_templateObject16 = _taggedTemplateLiteral(["", ".dynamicProps"])), it.evaluated), function () { return gen.assign((0, codegen_1._)(_templateObject17 || (_templateObject17 = _taggedTemplateLiteral(["", ".props"])), it.evaluated), (0, codegen_1._)(_templateObject18 || (_templateObject18 = _taggedTemplateLiteral(["undefined"])))); }); gen["if"]((0, codegen_1._)(_templateObject19 || (_templateObject19 = _taggedTemplateLiteral(["", ".dynamicItems"])), it.evaluated), function () { return gen.assign((0, codegen_1._)(_templateObject20 || (_templateObject20 = _taggedTemplateLiteral(["", ".items"])), it.evaluated), (0, codegen_1._)(_templateObject21 || (_templateObject21 = _taggedTemplateLiteral(["undefined"])))); }); } function funcSourceUrl(schema, opts) { var schId = _typeof(schema) == "object" && schema[opts.schemaId]; return schId && (opts.code.source || opts.code.process) ? (0, codegen_1._)(_templateObject22 || (_templateObject22 = _taggedTemplateLiteral(["/*# sourceURL=", " */"])), schId) : codegen_1.nil; } // schema compilation - this function is used recursively to generate code for sub-schemas function subschemaCode(it, valid) { if (isSchemaObj(it)) { checkKeywords(it); if (schemaCxtHasRules(it)) { subSchemaObjCode(it, valid); return; } } (0, boolSchema_1.boolOrEmptySchema)(it, valid); } function schemaCxtHasRules(_ref2) { var schema = _ref2.schema, self = _ref2.self; if (typeof schema == "boolean") return !schema; for (var key in schema) if (self.RULES.all[key]) return true; return false; } function isSchemaObj(it) { return typeof it.schema != "boolean"; } function subSchemaObjCode(it, valid) { var schema = it.schema, gen = it.gen, opts = it.opts; if (opts.$comment && schema.$comment) commentKeyword(it); updateContext(it); checkAsyncSchema(it); var errsCount = gen["const"]("_errs", names_1["default"].errors); typeAndKeywords(it, errsCount); // TODO var gen["var"](valid, (0, codegen_1._)(_templateObject23 || (_templateObject23 = _taggedTemplateLiteral(["", " === ", ""])), errsCount, names_1["default"].errors)); } function checkKeywords(it) { (0, util_1.checkUnknownRules)(it); checkRefsAndKeywords(it); } function typeAndKeywords(it, errsCount) { if (it.opts.jtd) return schemaKeywords(it, [], false, errsCount); var types = (0, dataType_1.getSchemaTypes)(it.schema); var checkedTypes = (0, dataType_1.coerceAndCheckDataType)(it, types); schemaKeywords(it, types, !checkedTypes, errsCount); } function checkRefsAndKeywords(it) { var schema = it.schema, errSchemaPath = it.errSchemaPath, opts = it.opts, self = it.self; if (schema.$ref && opts.ignoreKeywordsWithRef && (0, util_1.schemaHasRulesButRef)(schema, self.RULES)) { self.logger.warn("$ref: keywords ignored in schema at path \"".concat(errSchemaPath, "\"")); } } function checkNoDefault(it) { var schema = it.schema, opts = it.opts; if (schema["default"] !== undefined && opts.useDefaults && opts.strictSchema) { (0, util_1.checkStrictMode)(it, "default is ignored in the schema root"); } } function updateContext(it) { var schId = it.schema[it.opts.schemaId]; if (schId) it.baseId = (0, resolve_1.resolveUrl)(it.opts.uriResolver, it.baseId, schId); } function checkAsyncSchema(it) { if (it.schema.$async && !it.schemaEnv.$async) throw new Error("async schema in sync schema"); } function commentKeyword(_ref3) { var gen = _ref3.gen, schemaEnv = _ref3.schemaEnv, schema = _ref3.schema, errSchemaPath = _ref3.errSchemaPath, opts = _ref3.opts; var msg = schema.$comment; if (opts.$comment === true) { gen.code((0, codegen_1._)(_templateObject24 || (_templateObject24 = _taggedTemplateLiteral(["", ".logger.log(", ")"])), names_1["default"].self, msg)); } else if (typeof opts.$comment == "function") { var schemaPath = (0, codegen_1.str)(_templateObject25 || (_templateObject25 = _taggedTemplateLiteral(["", "/$comment"])), errSchemaPath); var rootName = gen.scopeValue("root", { ref: schemaEnv.root }); gen.code((0, codegen_1._)(_templateObject26 || (_templateObject26 = _taggedTemplateLiteral(["", ".opts.$comment(", ", ", ", ", ".schema)"])), names_1["default"].self, msg, schemaPath, rootName)); } } function returnResults(it) { var gen = it.gen, schemaEnv = it.schemaEnv, validateName = it.validateName, ValidationError = it.ValidationError, opts = it.opts; if (schemaEnv.$async) { // TODO assign unevaluated gen["if"]((0, codegen_1._)(_templateObject27 || (_templateObject27 = _taggedTemplateLiteral(["", " === 0"])), names_1["default"].errors), function () { return gen["return"](names_1["default"].data); }, function () { return gen["throw"]((0, codegen_1._)(_templateObject28 || (_templateObject28 = _taggedTemplateLiteral(["new ", "(", ")"])), ValidationError, names_1["default"].vErrors)); }); } else { gen.assign((0, codegen_1._)(_templateObject29 || (_templateObject29 = _taggedTemplateLiteral(["", ".errors"])), validateName), names_1["default"].vErrors); if (opts.unevaluated) assignEvaluated(it); gen["return"]((0, codegen_1._)(_templateObject30 || (_templateObject30 = _taggedTemplateLiteral(["", " === 0"])), names_1["default"].errors)); } } function assignEvaluated(_ref4) { var gen = _ref4.gen, evaluated = _ref4.evaluated, props = _ref4.props, items = _ref4.items; if (props instanceof codegen_1.Name) gen.assign((0, codegen_1._)(_templateObject31 || (_templateObject31 = _taggedTemplateLiteral(["", ".props"])), evaluated), props); if (items instanceof codegen_1.Name) gen.assign((0, codegen_1._)(_templateObject32 || (_templateObject32 = _taggedTemplateLiteral(["", ".items"])), evaluated), items); } function schemaKeywords(it, types, typeErrors, errsCount) { var gen = it.gen, schema = it.schema, data = it.data, allErrors = it.allErrors, opts = it.opts, self = it.self; var RULES = self.RULES; if (schema.$ref && (opts.ignoreKeywordsWithRef || !(0, util_1.schemaHasRulesButRef)(schema, RULES))) { gen.block(function () { return keywordCode(it, "$ref", RULES.all.$ref.definition); }); // TODO typecast return; } if (!opts.jtd) checkStrictTypes(it, types); gen.block(function () { var _iterator = _createForOfIteratorHelper(RULES.rules), _step; try { for (_iterator.s(); !(_step = _iterator.n()).done;) { var group = _step.value; groupKeywords(group); } } catch (err) { _iterator.e(err); } finally { _iterator.f(); } groupKeywords(RULES.post); }); function groupKeywords(group) { if (!(0, applicability_1.shouldUseGroup)(schema, group)) return; if (group.type) { gen["if"]((0, dataType_2.checkDataType)(group.type, data, opts.strictNumbers)); iterateKeywords(it, group); if (types.length === 1 && types[0] === group.type && typeErrors) { gen["else"](); (0, dataType_2.reportTypeError)(it); } gen.endIf(); } else { iterateKeywords(it, group); } // TODO make it "ok" call? if (!allErrors) gen["if"]((0, codegen_1._)(_templateObject33 || (_templateObject33 = _taggedTemplateLiteral(["", " === ", ""])), names_1["default"].errors, errsCount || 0)); } } function iterateKeywords(it, group) { var gen = it.gen, schema = it.schema, useDefaults = it.opts.useDefaults; if (useDefaults) (0, defaults_1.assignDefaults)(it, group.type); gen.block(function () { var _iterator2 = _createForOfIteratorHelper(group.rules), _step2; try { for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { var rule = _step2.value; if ((0, applicability_1.shouldUseRule)(schema, rule)) { keywordCode(it, rule.keyword, rule.definition, group.type); } } } catch (err) { _iterator2.e(err); } finally { _iterator2.f(); } }); } function checkStrictTypes(it, types) { if (it.schemaEnv.meta || !it.opts.strictTypes) return; checkContextTypes(it, types); if (!it.opts.allowUnionTypes) checkMultipleTypes(it, types); checkKeywordTypes(it, it.dataTypes); } function checkContextTypes(it, types) { if (!types.length) return; if (!it.dataTypes.length) { it.dataTypes = types; return; } types.forEach(function (t) { if (!includesType(it.dataTypes, t)) { strictTypesError(it, "type \"".concat(t, "\" not allowed by context \"").concat(it.dataTypes.join(","), "\"")); } }); narrowSchemaTypes(it, types); } function checkMultipleTypes(it, ts) { if (ts.length > 1 && !(ts.length === 2 && ts.includes("null"))) { strictTypesError(it, "use allowUnionTypes to allow union type keyword"); } } function checkKeywordTypes(it, ts) { var rules = it.self.RULES.all; for (var keyword in rules) { var rule = rules[keyword]; if (_typeof(rule) == "object" && (0, applicability_1.shouldUseRule)(it.schema, rule)) { var type = rule.definition.type; if (type.length && !type.some(function (t) { return hasApplicableType(ts, t); })) { strictTypesError(it, "missing type \"".concat(type.join(","), "\" for keyword \"").concat(keyword, "\"")); } } } } function hasApplicableType(schTs, kwdT) { return schTs.includes(kwdT) || kwdT === "number" && schTs.includes("integer"); } function includesType(ts, t) { return ts.includes(t) || t === "integer" && ts.includes("number"); } function narrowSchemaTypes(it, withTypes) { var ts = []; var _iterator3 = _createForOfIteratorHelper(it.dataTypes), _step3; try { for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) { var t = _step3.value; if (includesType(withTypes, t)) ts.push(t);else if (withTypes.includes("integer") && t === "number") ts.push("integer"); } } catch (err) { _iterator3.e(err); } finally { _iterator3.f(); } it.dataTypes = ts; } function strictTypesError(it, msg) { var schemaPath = it.schemaEnv.baseId + it.errSchemaPath; msg += " at \"".concat(schemaPath, "\" (strictTypes)"); (0, util_1.checkStrictMode)(it, msg, it.opts.strictTypes); } var KeywordCxt = /*#__PURE__*/function () { function KeywordCxt(it, def, keyword) { _classCallCheck(this, KeywordCxt); (0, keyword_1.validateKeywordUsage)(it, def, keyword); this.gen = it.gen; this.allErrors = it.allErrors; this.keyword = keyword; this.data = it.data; this.schema = it.schema[keyword]; this.$data = def.$data && it.opts.$data && this.schema && this.schema.$data; this.schemaValue = (0, util_1.schemaRefOrVal)(it, this.schema, keyword, this.$data); this.schemaType = def.schemaType; this.parentSchema = it.schema; this.params = {}; this.it = it; this.def = def; if (this.$data) { this.schemaCode = it.gen["const"]("vSchema", getData(this.$data, it)); } else { this.schemaCode = this.schemaValue; if (!(0, keyword_1.validSchemaType)(this.schema, def.schemaType, def.allowUndefined)) { throw new Error("".concat(keyword, " value must be ").concat(JSON.stringify(def.schemaType))); } } if ("code" in def ? def.trackErrors : def.errors !== false) { this.errsCount = it.gen["const"]("_errs", names_1["default"].errors); } } _createClass(KeywordCxt, [{ key: "result", value: function result(condition, successAction, failAction) { this.failResult((0, codegen_1.not)(condition), successAction, failAction); } }, { key: "failResult", value: function failResult(condition, successAction, failAction) { this.gen["if"](condition); if (failAction) failAction();else this.error(); if (successAction) { this.gen["else"](); successAction(); if (this.allErrors) this.gen.endIf(); } else { if (this.allErrors) this.gen.endIf();else this.gen["else"](); } } }, { key: "pass", value: function pass(condition, failAction) { this.failResult((0, codegen_1.not)(condition), undefined, failAction); } }, { key: "fail", value: function fail(condition) { if (condition === undefined) { this.error(); if (!this.allErrors) this.gen["if"](false); // this branch will be removed by gen.optimize return; } this.gen["if"](condition); this.error(); if (this.allErrors) this.gen.endIf();else this.gen["else"](); } }, { key: "fail$data", value: function fail$data(condition) { if (!this.$data) return this.fail(condition); var schemaCode = this.schemaCode; this.fail((0, codegen_1._)(_templateObject34 || (_templateObject34 = _taggedTemplateLiteral(["", " !== undefined && (", ")"])), schemaCode, (0, codegen_1.or)(this.invalid$data(), condition))); } }, { key: "error", value: function error(append, errorParams, errorPaths) { if (errorParams) { this.setParams(errorParams); this._error(append, errorPaths); this.setParams({}); return; } this._error(append, errorPaths); } }, { key: "_error", value: function _error(append, errorPaths) { ; (append ? errors_1.reportExtraError : errors_1.reportError)(this, this.def.error, errorPaths); } }, { key: "$dataError", value: function $dataError() { (0, errors_1.reportError)(this, this.def.$dataError || errors_1.keyword$DataError); } }, { key: "reset", value: function reset() { if (this.errsCount === undefined) throw new Error('add "trackErrors" to keyword definition'); (0, errors_1.resetErrorsCount)(this.gen, this.errsCount); } }, { key: "ok", value: function ok(cond) { if (!this.allErrors) this.gen["if"](cond); } }, { key: "setParams", value: function setParams(obj, assign) { if (assign) Object.assign(this.params, obj);else this.params = obj; } }, { key: "block$data", value: function block$data(valid, codeBlock) { var _this = this; var $dataValid = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : codegen_1.nil; this.gen.block(function () { _this.check$data(valid, $dataValid); codeBlock(); }); } }, { key: "check$data", value: function check$data() { var valid = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : codegen_1.nil; var $dataValid = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : codegen_1.nil; if (!this.$data) return; var gen = this.gen, schemaCode = this.schemaCode, schemaType = this.schemaType, def = this.def; gen["if"]((0, codegen_1.or)((0, codegen_1._)(_templateObject35 || (_templateObject35 = _taggedTemplateLiteral(["", " === undefined"])), schemaCode), $dataValid)); if (valid !== codegen_1.nil) gen.assign(valid, true); if (schemaType.length || def.validateSchema) { gen.elseIf(this.invalid$data()); this.$dataError(); if (valid !== codegen_1.nil) gen.assign(valid, false); } gen["else"](); } }, { key: "invalid$data", value: function invalid$data() { var gen = this.gen, schemaCode = this.schemaCode, schemaType = this.schemaType, def = this.def, it = this.it; return (0, codegen_1.or)(wrong$DataType(), invalid$DataSchema()); function wrong$DataType() { if (schemaType.length) { /* istanbul ignore if */ if (!(schemaCode instanceof codegen_1.Name)) throw new Error("ajv implementation error"); var st = Array.isArray(schemaType) ? schemaType : [schemaType]; return (0, codegen_1._)(_templateObject36 || (_templateObject36 = _taggedTemplateLiteral(["", ""])), (0, dataType_2.checkDataTypes)(st, schemaCode, it.opts.strictNumbers, dataType_2.DataType.Wrong)); } return codegen_1.nil; } function invalid$DataSchema() { if (def.validateSchema) { var validateSchemaRef = gen.scopeValue("validate$data", { ref: def.validateSchema }); // TODO value.code for standalone return (0, codegen_1._)(_templateObject37 || (_templateObject37 = _taggedTemplateLiteral(["!", "(", ")"])), validateSchemaRef, schemaCode); } return codegen_1.nil; } } }, { key: "subschema", value: function subschema(appl, valid) { var subschema = (0, subschema_1.getSubschema)(this.it, appl); (0, subschema_1.extendSubschemaData)(subschema, this.it, appl); (0, subschema_1.extendSubschemaMode)(subschema, appl); var nextContext = _objectSpread(_objectSpread(_objectSpread({}, this.it), subschema), {}, { items: undefined, props: undefined }); subschemaCode(nextContext, valid); return nextContext; } }, { key: "mergeEvaluated", value: function mergeEvaluated(schemaCxt, toName) { var it = this.it, gen = this.gen; if (!it.opts.unevaluated) return; if (it.props !== true && schemaCxt.props !== undefined) { it.props = util_1.mergeEvaluated.props(gen, schemaCxt.props, it.props, toName); } if (it.items !== true && schemaCxt.items !== undefined) { it.items = util_1.mergeEvaluated.items(gen, schemaCxt.items, it.items, toName); } } }, { key: "mergeValidEvaluated", value: function mergeValidEvaluated(schemaCxt, valid) { var _this2 = this; var it = this.it, gen = this.gen; if (it.opts.unevaluated && (it.props !== true || it.items !== true)) { gen["if"](valid, function () { return _this2.mergeEvaluated(schemaCxt, codegen_1.Name); }); return true; } } }]); return KeywordCxt; }(); exports.KeywordCxt = KeywordCxt; function keywordCode(it, keyword, def, ruleType) { var cxt = new KeywordCxt(it, def, keyword); if ("code" in def) { def.code(cxt, ruleType); } else if (cxt.$data && def.validate) { (0, keyword_1.funcKeywordCode)(cxt, def); } else if ("macro" in def) { (0, keyword_1.macroKeywordCode)(cxt, def); } else if (def.compile || def.validate) { (0, keyword_1.funcKeywordCode)(cxt, def); } } var JSON_POINTER = /^\/(?:[^~]|~0|~1)*$/; var RELATIVE_JSON_POINTER = /^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/; function getData($data, _ref5) { var dataLevel = _ref5.dataLevel, dataNames = _ref5.dataNames, dataPathArr = _ref5.dataPathArr; var jsonPointer; var data; if ($data === "") return names_1["default"].rootData; if ($data[0] === "/") { if (!JSON_POINTER.test($data)) throw new Error("Invalid JSON-pointer: ".concat($data)); jsonPointer = $data; data = names_1["default"].rootData; } else { var matches = RELATIVE_JSON_POINTER.exec($data); if (!matches) throw new Error("Invalid JSON-pointer: ".concat($data)); var up = +matches[1]; jsonPointer = matches[2]; if (jsonPointer === "#") { if (up >= dataLevel) throw new Error(errorMsg("property/index", up)); return dataPathArr[dataLevel - up]; } if (up > dataLevel) throw new Error(errorMsg("data", up)); data = dataNames[dataLevel - up]; if (!jsonPointer) return data; } var expr = data; var segments = jsonPointer.split("/"); var _iterator4 = _createForOfIteratorHelper(segments), _step4; try { for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) { var segment = _step4.value; if (segment) { data = (0, codegen_1._)(_templateObject38 || (_templateObject38 = _taggedTemplateLiteral(["", "", ""])), data, (0, codegen_1.getProperty)((0, util_1.unescapeJsonPointer)(segment))); expr = (0, codegen_1._)(_templateObject39 || (_templateObject39 = _taggedTemplateLiteral(["", " && ", ""])), expr, data); } } } catch (err) { _iterator4.e(err); } finally { _iterator4.f(); } return expr; function errorMsg(pointerType, up) { return "Cannot access ".concat(pointerType, " ").concat(up, " levels up, current level is ").concat(dataLevel); } } exports.getData = getData; },{"../codegen":13,"../errors":15,"../names":17,"../resolve":19,"../util":21,"./applicability":22,"./boolSchema":23,"./dataType":24,"./defaults":25,"./keyword":27,"./subschema":28}],27:[function(require,module,exports){ "use strict"; var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10; function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } Object.defineProperty(exports, "__esModule", { value: true }); exports.validateKeywordUsage = exports.validSchemaType = exports.funcKeywordCode = exports.macroKeywordCode = void 0; var codegen_1 = require("../codegen"); var names_1 = require("../names"); var code_1 = require("../../vocabularies/code"); var errors_1 = require("../errors"); function macroKeywordCode(cxt, def) { var gen = cxt.gen, keyword = cxt.keyword, schema = cxt.schema, parentSchema = cxt.parentSchema, it = cxt.it; var macroSchema = def.macro.call(it.self, schema, parentSchema, it); var schemaRef = useKeyword(gen, keyword, macroSchema); if (it.opts.validateSchema !== false) it.self.validateSchema(macroSchema, true); var valid = gen.name("valid"); cxt.subschema({ schema: macroSchema, schemaPath: codegen_1.nil, errSchemaPath: "".concat(it.errSchemaPath, "/").concat(keyword), topSchemaRef: schemaRef, compositeRule: true }, valid); cxt.pass(valid, function () { return cxt.error(true); }); } exports.macroKeywordCode = macroKeywordCode; function funcKeywordCode(cxt, def) { var _a; var gen = cxt.gen, keyword = cxt.keyword, schema = cxt.schema, parentSchema = cxt.parentSchema, $data = cxt.$data, it = cxt.it; checkAsyncKeyword(it, def); var validate = !$data && def.compile ? def.compile.call(it.self, schema, parentSchema, it) : def.validate; var validateRef = useKeyword(gen, keyword, validate); var valid = gen["let"]("valid"); cxt.block$data(valid, validateKeyword); cxt.ok((_a = def.valid) !== null && _a !== void 0 ? _a : valid); function validateKeyword() { if (def.errors === false) { assignValid(); if (def.modifying) modifyData(cxt); reportErrs(function () { return cxt.error(); }); } else { var ruleErrs = def.async ? validateAsync() : validateSync(); if (def.modifying) modifyData(cxt); reportErrs(function () { return addErrs(cxt, ruleErrs); }); } } function validateAsync() { var ruleErrs = gen["let"]("ruleErrs", null); gen["try"](function () { return assignValid((0, codegen_1._)(_templateObject || (_templateObject = _taggedTemplateLiteral(["await "])))); }, function (e) { return gen.assign(valid, false)["if"]((0, codegen_1._)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["", " instanceof ", ""])), e, it.ValidationError), function () { return gen.assign(ruleErrs, (0, codegen_1._)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["", ".errors"])), e)); }, function () { return gen["throw"](e); }); }); return ruleErrs; } function validateSync() { var validateErrs = (0, codegen_1._)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["", ".errors"])), validateRef); gen.assign(validateErrs, null); assignValid(codegen_1.nil); return validateErrs; } function assignValid() { var _await = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : def.async ? (0, codegen_1._)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["await "]))) : codegen_1.nil; var passCxt = it.opts.passContext ? names_1["default"]["this"] : names_1["default"].self; var passSchema = !("compile" in def && !$data || def.schema === false); gen.assign(valid, (0, codegen_1._)(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["", "", ""])), _await, (0, code_1.callValidateCode)(cxt, validateRef, passCxt, passSchema)), def.modifying); } function reportErrs(errors) { var _a; gen["if"]((0, codegen_1.not)((_a = def.valid) !== null && _a !== void 0 ? _a : valid), errors); } } exports.funcKeywordCode = funcKeywordCode; function modifyData(cxt) { var gen = cxt.gen, data = cxt.data, it = cxt.it; gen["if"](it.parentData, function () { return gen.assign(data, (0, codegen_1._)(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["", "[", "]"])), it.parentData, it.parentDataProperty)); }); } function addErrs(cxt, errs) { var gen = cxt.gen; gen["if"]((0, codegen_1._)(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["Array.isArray(", ")"])), errs), function () { gen.assign(names_1["default"].vErrors, (0, codegen_1._)(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["", " === null ? ", " : ", ".concat(", ")"])), names_1["default"].vErrors, errs, names_1["default"].vErrors, errs)).assign(names_1["default"].errors, (0, codegen_1._)(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["", ".length"])), names_1["default"].vErrors)); (0, errors_1.extendErrors)(cxt); }, function () { return cxt.error(); }); } function checkAsyncKeyword(_ref, def) { var schemaEnv = _ref.schemaEnv; if (def.async && !schemaEnv.$async) throw new Error("async keyword in sync schema"); } function useKeyword(gen, keyword, result) { if (result === undefined) throw new Error("keyword \"".concat(keyword, "\" failed to compile")); return gen.scopeValue("keyword", typeof result == "function" ? { ref: result } : { ref: result, code: (0, codegen_1.stringify)(result) }); } function validSchemaType(schema, schemaType) { var allowUndefined = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; // TODO add tests return !schemaType.length || schemaType.some(function (st) { return st === "array" ? Array.isArray(schema) : st === "object" ? schema && _typeof(schema) == "object" && !Array.isArray(schema) : _typeof(schema) == st || allowUndefined && typeof schema == "undefined"; }); } exports.validSchemaType = validSchemaType; function validateKeywordUsage(_ref2, def, keyword) { var schema = _ref2.schema, opts = _ref2.opts, self = _ref2.self, errSchemaPath = _ref2.errSchemaPath; /* istanbul ignore if */ if (Array.isArray(def.keyword) ? !def.keyword.includes(keyword) : def.keyword !== keyword) { throw new Error("ajv implementation error"); } var deps = def.dependencies; if (deps === null || deps === void 0 ? void 0 : deps.some(function (kwd) { return !Object.prototype.hasOwnProperty.call(schema, kwd); })) { throw new Error("parent schema must have dependencies of ".concat(keyword, ": ").concat(deps.join(","))); } if (def.validateSchema) { var valid = def.validateSchema(schema[keyword]); if (!valid) { var msg = "keyword \"".concat(keyword, "\" value is invalid at path \"").concat(errSchemaPath, "\": ") + self.errorsText(def.validateSchema.errors); if (opts.validateSchema === "log") self.logger.error(msg);else throw new Error(msg); } } } exports.validateKeywordUsage = validateKeywordUsage; },{"../../vocabularies/code":53,"../codegen":13,"../errors":15,"../names":17}],28:[function(require,module,exports){ "use strict"; var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5; function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } Object.defineProperty(exports, "__esModule", { value: true }); exports.extendSubschemaMode = exports.extendSubschemaData = exports.getSubschema = void 0; var codegen_1 = require("../codegen"); var util_1 = require("../util"); function getSubschema(it, _ref) { var keyword = _ref.keyword, schemaProp = _ref.schemaProp, schema = _ref.schema, schemaPath = _ref.schemaPath, errSchemaPath = _ref.errSchemaPath, topSchemaRef = _ref.topSchemaRef; if (keyword !== undefined && schema !== undefined) { throw new Error('both "keyword" and "schema" passed, only one allowed'); } if (keyword !== undefined) { var sch = it.schema[keyword]; return schemaProp === undefined ? { schema: sch, schemaPath: (0, codegen_1._)(_templateObject || (_templateObject = _taggedTemplateLiteral(["", "", ""])), it.schemaPath, (0, codegen_1.getProperty)(keyword)), errSchemaPath: "".concat(it.errSchemaPath, "/").concat(keyword) } : { schema: sch[schemaProp], schemaPath: (0, codegen_1._)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["", "", "", ""])), it.schemaPath, (0, codegen_1.getProperty)(keyword), (0, codegen_1.getProperty)(schemaProp)), errSchemaPath: "".concat(it.errSchemaPath, "/").concat(keyword, "/").concat((0, util_1.escapeFragment)(schemaProp)) }; } if (schema !== undefined) { if (schemaPath === undefined || errSchemaPath === undefined || topSchemaRef === undefined) { throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"'); } return { schema: schema, schemaPath: schemaPath, topSchemaRef: topSchemaRef, errSchemaPath: errSchemaPath }; } throw new Error('either "keyword" or "schema" must be passed'); } exports.getSubschema = getSubschema; function extendSubschemaData(subschema, it, _ref2) { var dataProp = _ref2.dataProp, dpType = _ref2.dataPropType, data = _ref2.data, dataTypes = _ref2.dataTypes, propertyName = _ref2.propertyName; if (data !== undefined && dataProp !== undefined) { throw new Error('both "data" and "dataProp" passed, only one allowed'); } var gen = it.gen; if (dataProp !== undefined) { var errorPath = it.errorPath, dataPathArr = it.dataPathArr, opts = it.opts; var nextData = gen["let"]("data", (0, codegen_1._)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["", "", ""])), it.data, (0, codegen_1.getProperty)(dataProp)), true); dataContextProps(nextData); subschema.errorPath = (0, codegen_1.str)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["", "", ""])), errorPath, (0, util_1.getErrorPath)(dataProp, dpType, opts.jsPropertySyntax)); subschema.parentDataProperty = (0, codegen_1._)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["", ""])), dataProp); subschema.dataPathArr = [].concat(_toConsumableArray(dataPathArr), [subschema.parentDataProperty]); } if (data !== undefined) { var _nextData2 = data instanceof codegen_1.Name ? data : gen["let"]("data", data, true); // replaceable if used once? dataContextProps(_nextData2); if (propertyName !== undefined) subschema.propertyName = propertyName; // TODO something is possibly wrong here with not changing parentDataProperty and not appending dataPathArr } if (dataTypes) subschema.dataTypes = dataTypes; function dataContextProps(_nextData) { subschema.data = _nextData; subschema.dataLevel = it.dataLevel + 1; subschema.dataTypes = []; it.definedProperties = new Set(); subschema.parentData = it.data; subschema.dataNames = [].concat(_toConsumableArray(it.dataNames), [_nextData]); } } exports.extendSubschemaData = extendSubschemaData; function extendSubschemaMode(subschema, _ref3) { var jtdDiscriminator = _ref3.jtdDiscriminator, jtdMetadata = _ref3.jtdMetadata, compositeRule = _ref3.compositeRule, createErrors = _ref3.createErrors, allErrors = _ref3.allErrors; if (compositeRule !== undefined) subschema.compositeRule = compositeRule; if (createErrors !== undefined) subschema.createErrors = createErrors; if (allErrors !== undefined) subschema.allErrors = allErrors; subschema.jtdDiscriminator = jtdDiscriminator; // not inherited subschema.jtdMetadata = jtdMetadata; // not inherited } exports.extendSubschemaMode = extendSubschemaMode; },{"../codegen":13,"../util":21}],29:[function(require,module,exports){ "use strict"; function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; } function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); } function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } Object.defineProperty(exports, "__esModule", { value: true }); exports.CodeGen = exports.Name = exports.nil = exports.stringify = exports.str = exports._ = exports.KeywordCxt = void 0; var validate_1 = require("./compile/validate"); Object.defineProperty(exports, "KeywordCxt", { enumerable: true, get: function get() { return validate_1.KeywordCxt; } }); var codegen_1 = require("./compile/codegen"); Object.defineProperty(exports, "_", { enumerable: true, get: function get() { return codegen_1._; } }); Object.defineProperty(exports, "str", { enumerable: true, get: function get() { return codegen_1.str; } }); Object.defineProperty(exports, "stringify", { enumerable: true, get: function get() { return codegen_1.stringify; } }); Object.defineProperty(exports, "nil", { enumerable: true, get: function get() { return codegen_1.nil; } }); Object.defineProperty(exports, "Name", { enumerable: true, get: function get() { return codegen_1.Name; } }); Object.defineProperty(exports, "CodeGen", { enumerable: true, get: function get() { return codegen_1.CodeGen; } }); var validation_error_1 = require("./runtime/validation_error"); var ref_error_1 = require("./compile/ref_error"); var rules_1 = require("./compile/rules"); var compile_1 = require("./compile"); var codegen_2 = require("./compile/codegen"); var resolve_1 = require("./compile/resolve"); var dataType_1 = require("./compile/validate/dataType"); var util_1 = require("./compile/util"); var $dataRefSchema = require("./refs/data.json"); var uri_1 = require("./runtime/uri"); var defaultRegExp = function defaultRegExp(str, flags) { return new RegExp(str, flags); }; defaultRegExp.code = "new RegExp"; var META_IGNORE_OPTIONS = ["removeAdditional", "useDefaults", "coerceTypes"]; var EXT_SCOPE_NAMES = new Set(["validate", "serialize", "parse", "wrapper", "root", "schema", "keyword", "pattern", "formats", "validate$data", "func", "obj", "Error"]); var removedOptions = { errorDataPath: "", format: "`validateFormats: false` can be used instead.", nullable: '"nullable" keyword is supported by default.', jsonPointers: "Deprecated jsPropertySyntax can be used instead.", extendRefs: "Deprecated ignoreKeywordsWithRef can be used instead.", missingRefs: "Pass empty schema with $id that should be ignored to ajv.addSchema.", processCode: "Use option `code: {process: (code, schemaEnv: object) => string}`", sourceCode: "Use option `code: {source: true}`", strictDefaults: "It is default now, see option `strict`.", strictKeywords: "It is default now, see option `strict`.", uniqueItems: '"uniqueItems" keyword is always validated.', unknownFormats: "Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).", cache: "Map is used as cache, schema object as key.", serialize: "Map is used as cache, schema object as key.", ajvErrors: "It is default now." }; var deprecatedOptions = { ignoreKeywordsWithRef: "", jsPropertySyntax: "", unicode: '"minLength"/"maxLength" account for unicode characters by default.' }; var MAX_EXPRESSION = 200; // eslint-disable-next-line complexity function requiredOptions(o) { var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0; var s = o.strict; var _optz = (_a = o.code) === null || _a === void 0 ? void 0 : _a.optimize; var optimize = _optz === true || _optz === undefined ? 1 : _optz || 0; var regExp = (_c = (_b = o.code) === null || _b === void 0 ? void 0 : _b.regExp) !== null && _c !== void 0 ? _c : defaultRegExp; var uriResolver = (_d = o.uriResolver) !== null && _d !== void 0 ? _d : uri_1["default"]; return { strictSchema: (_f = (_e = o.strictSchema) !== null && _e !== void 0 ? _e : s) !== null && _f !== void 0 ? _f : true, strictNumbers: (_h = (_g = o.strictNumbers) !== null && _g !== void 0 ? _g : s) !== null && _h !== void 0 ? _h : true, strictTypes: (_k = (_j = o.strictTypes) !== null && _j !== void 0 ? _j : s) !== null && _k !== void 0 ? _k : "log", strictTuples: (_m = (_l = o.strictTuples) !== null && _l !== void 0 ? _l : s) !== null && _m !== void 0 ? _m : "log", strictRequired: (_p = (_o = o.strictRequired) !== null && _o !== void 0 ? _o : s) !== null && _p !== void 0 ? _p : false, code: o.code ? _objectSpread(_objectSpread({}, o.code), {}, { optimize: optimize, regExp: regExp }) : { optimize: optimize, regExp: regExp }, loopRequired: (_q = o.loopRequired) !== null && _q !== void 0 ? _q : MAX_EXPRESSION, loopEnum: (_r = o.loopEnum) !== null && _r !== void 0 ? _r : MAX_EXPRESSION, meta: (_s = o.meta) !== null && _s !== void 0 ? _s : true, messages: (_t = o.messages) !== null && _t !== void 0 ? _t : true, inlineRefs: (_u = o.inlineRefs) !== null && _u !== void 0 ? _u : true, schemaId: (_v = o.schemaId) !== null && _v !== void 0 ? _v : "$id", addUsedSchema: (_w = o.addUsedSchema) !== null && _w !== void 0 ? _w : true, validateSchema: (_x = o.validateSchema) !== null && _x !== void 0 ? _x : true, validateFormats: (_y = o.validateFormats) !== null && _y !== void 0 ? _y : true, unicodeRegExp: (_z = o.unicodeRegExp) !== null && _z !== void 0 ? _z : true, int32range: (_0 = o.int32range) !== null && _0 !== void 0 ? _0 : true, uriResolver: uriResolver }; } var Ajv = /*#__PURE__*/function () { function Ajv() { var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; _classCallCheck(this, Ajv); this.schemas = {}; this.refs = {}; this.formats = {}; this._compilations = new Set(); this._loading = {}; this._cache = new Map(); opts = this.opts = _objectSpread(_objectSpread({}, opts), requiredOptions(opts)); var _this$opts$code = this.opts.code, es5 = _this$opts$code.es5, lines = _this$opts$code.lines; this.scope = new codegen_2.ValueScope({ scope: {}, prefixes: EXT_SCOPE_NAMES, es5: es5, lines: lines }); this.logger = getLogger(opts.logger); var formatOpt = opts.validateFormats; opts.validateFormats = false; this.RULES = (0, rules_1.getRules)(); checkOptions.call(this, removedOptions, opts, "NOT SUPPORTED"); checkOptions.call(this, deprecatedOptions, opts, "DEPRECATED", "warn"); this._metaOpts = getMetaSchemaOptions.call(this); if (opts.formats) addInitialFormats.call(this); this._addVocabularies(); this._addDefaultMetaSchema(); if (opts.keywords) addInitialKeywords.call(this, opts.keywords); if (_typeof(opts.meta) == "object") this.addMetaSchema(opts.meta); addInitialSchemas.call(this); opts.validateFormats = formatOpt; } _createClass(Ajv, [{ key: "_addVocabularies", value: function _addVocabularies() { this.addKeyword("$async"); } }, { key: "_addDefaultMetaSchema", value: function _addDefaultMetaSchema() { var _this$opts = this.opts, $data = _this$opts.$data, meta = _this$opts.meta, schemaId = _this$opts.schemaId; var _dataRefSchema = $dataRefSchema; if (schemaId === "id") { _dataRefSchema = _objectSpread({}, $dataRefSchema); _dataRefSchema.id = _dataRefSchema.$id; delete _dataRefSchema.$id; } if (meta && $data) this.addMetaSchema(_dataRefSchema, _dataRefSchema[schemaId], false); } }, { key: "defaultMeta", value: function defaultMeta() { var _this$opts2 = this.opts, meta = _this$opts2.meta, schemaId = _this$opts2.schemaId; return this.opts.defaultMeta = _typeof(meta) == "object" ? meta[schemaId] || meta : undefined; } }, { key: "validate", value: function validate(schemaKeyRef, // key, ref or schema object data // to be validated ) { var v; if (typeof schemaKeyRef == "string") { v = this.getSchema(schemaKeyRef); if (!v) throw new Error("no schema with key or ref \"".concat(schemaKeyRef, "\"")); } else { v = this.compile(schemaKeyRef); } var valid = v(data); if (!("$async" in v)) this.errors = v.errors; return valid; } }, { key: "compile", value: function compile(schema, _meta) { var sch = this._addSchema(schema, _meta); return sch.validate || this._compileSchemaEnv(sch); } }, { key: "compileAsync", value: function compileAsync(schema, meta) { if (typeof this.opts.loadSchema != "function") { throw new Error("options.loadSchema should be a function"); } var loadSchema = this.opts.loadSchema; return runCompileAsync.call(this, schema, meta); function runCompileAsync(_x2, _x3) { return _runCompileAsync.apply(this, arguments); } function _runCompileAsync() { _runCompileAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_schema, _meta) { var sch; return _regeneratorRuntime().wrap(function _callee$(_context) { while (1) switch (_context.prev = _context.next) { case 0: _context.next = 2; return loadMetaSchema.call(this, _schema.$schema); case 2: sch = this._addSchema(_schema, _meta); return _context.abrupt("return", sch.validate || _compileAsync.call(this, sch)); case 4: case "end": return _context.stop(); } }, _callee, this); })); return _runCompileAsync.apply(this, arguments); } function loadMetaSchema(_x4) { return _loadMetaSchema.apply(this, arguments); } function _loadMetaSchema() { _loadMetaSchema = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2($ref) { return _regeneratorRuntime().wrap(function _callee2$(_context2) { while (1) switch (_context2.prev = _context2.next) { case 0: if (!($ref && !this.getSchema($ref))) { _context2.next = 3; break; } _context2.next = 3; return runCompileAsync.call(this, { $ref: $ref }, true); case 3: case "end": return _context2.stop(); } }, _callee2, this); })); return _loadMetaSchema.apply(this, arguments); } function _compileAsync(_x5) { return _compileAsync2.apply(this, arguments); } function _compileAsync2() { _compileAsync2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(sch) { return _regeneratorRuntime().wrap(function _callee3$(_context3) { while (1) switch (_context3.prev = _context3.next) { case 0: _context3.prev = 0; return _context3.abrupt("return", this._compileSchemaEnv(sch)); case 4: _context3.prev = 4; _context3.t0 = _context3["catch"](0); if (_context3.t0 instanceof ref_error_1["default"]) { _context3.next = 8; break; } throw _context3.t0; case 8: checkLoaded.call(this, _context3.t0); _context3.next = 11; return loadMissingSchema.call(this, _context3.t0.missingSchema); case 11: return _context3.abrupt("return", _compileAsync.call(this, sch)); case 12: case "end": return _context3.stop(); } }, _callee3, this, [[0, 4]]); })); return _compileAsync2.apply(this, arguments); } function checkLoaded(_ref) { var ref = _ref.missingSchema, missingRef = _ref.missingRef; if (this.refs[ref]) { throw new Error("AnySchema ".concat(ref, " is loaded but ").concat(missingRef, " cannot be resolved")); } } function loadMissingSchema(_x6) { return _loadMissingSchema.apply(this, arguments); } function _loadMissingSchema() { _loadMissingSchema = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(ref) { var _schema; return _regeneratorRuntime().wrap(function _callee4$(_context4) { while (1) switch (_context4.prev = _context4.next) { case 0: _context4.next = 2; return _loadSchema.call(this, ref); case 2: _schema = _context4.sent; if (this.refs[ref]) { _context4.next = 6; break; } _context4.next = 6; return loadMetaSchema.call(this, _schema.$schema); case 6: if (!this.refs[ref]) this.addSchema(_schema, ref, meta); case 7: case "end": return _context4.stop(); } }, _callee4, this); })); return _loadMissingSchema.apply(this, arguments); } function _loadSchema(_x7) { return _loadSchema2.apply(this, arguments); } function _loadSchema2() { _loadSchema2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(ref) { var p; return _regeneratorRuntime().wrap(function _callee5$(_context5) { while (1) switch (_context5.prev = _context5.next) { case 0: p = this._loading[ref]; if (!p) { _context5.next = 3; break; } return _context5.abrupt("return", p); case 3: _context5.prev = 3; _context5.next = 6; return this._loading[ref] = loadSchema(ref); case 6: return _context5.abrupt("return", _context5.sent); case 7: _context5.prev = 7; delete this._loading[ref]; return _context5.finish(7); case 10: case "end": return _context5.stop(); } }, _callee5, this, [[3,, 7, 10]]); })); return _loadSchema2.apply(this, arguments); } } // Adds schema to the instance }, { key: "addSchema", value: function addSchema(schema, // If array is passed, `key` will be ignored key, // Optional schema key. Can be passed to `validate` method instead of schema object or id/ref. One schema per instance can have empty `id` and `key`. _meta) { var _validateSchema = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : this.opts.validateSchema; if (Array.isArray(schema)) { var _iterator = _createForOfIteratorHelper(schema), _step; try { for (_iterator.s(); !(_step = _iterator.n()).done;) { var sch = _step.value; this.addSchema(sch, undefined, _meta, _validateSchema); } } catch (err) { _iterator.e(err); } finally { _iterator.f(); } return this; } var id; if (_typeof(schema) === "object") { var schemaId = this.opts.schemaId; id = schema[schemaId]; if (id !== undefined && typeof id != "string") { throw new Error("schema ".concat(schemaId, " must be string")); } } key = (0, resolve_1.normalizeId)(key || id); this._checkUnique(key); this.schemas[key] = this._addSchema(schema, _meta, key, _validateSchema, true); return this; } // Add schema that will be used to validate other schemas // options in META_IGNORE_OPTIONS are alway set to false }, { key: "addMetaSchema", value: function addMetaSchema(schema, key) { var _validateSchema = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.opts.validateSchema; this.addSchema(schema, key, true, _validateSchema); return this; } // Validate schema against its meta-schema }, { key: "validateSchema", value: function validateSchema(schema, throwOrLogError) { if (typeof schema == "boolean") return true; var $schema; $schema = schema.$schema; if ($schema !== undefined && typeof $schema != "string") { throw new Error("$schema must be a string"); } $schema = $schema || this.opts.defaultMeta || this.defaultMeta(); if (!$schema) { this.logger.warn("meta-schema not available"); this.errors = null; return true; } var valid = this.validate($schema, schema); if (!valid && throwOrLogError) { var message = "schema is invalid: " + this.errorsText(); if (this.opts.validateSchema === "log") this.logger.error(message);else throw new Error(message); } return valid; } // Get compiled schema by `key` or `ref`. // (`key` that was passed to `addSchema` or full schema reference - `schema.$id` or resolved id) }, { key: "getSchema", value: function getSchema(keyRef) { var sch; while (typeof (sch = getSchEnv.call(this, keyRef)) == "string") keyRef = sch; if (sch === undefined) { var schemaId = this.opts.schemaId; var root = new compile_1.SchemaEnv({ schema: {}, schemaId: schemaId }); sch = compile_1.resolveSchema.call(this, root, keyRef); if (!sch) return; this.refs[keyRef] = sch; } return sch.validate || this._compileSchemaEnv(sch); } // Remove cached schema(s). // If no parameter is passed all schemas but meta-schemas are removed. // If RegExp is passed all schemas with key/id matching pattern but meta-schemas are removed. // Even if schema is referenced by other schemas it still can be removed as other schemas have local references. }, { key: "removeSchema", value: function removeSchema(schemaKeyRef) { if (schemaKeyRef instanceof RegExp) { this._removeAllSchemas(this.schemas, schemaKeyRef); this._removeAllSchemas(this.refs, schemaKeyRef); return this; } switch (_typeof(schemaKeyRef)) { case "undefined": this._removeAllSchemas(this.schemas); this._removeAllSchemas(this.refs); this._cache.clear(); return this; case "string": { var sch = getSchEnv.call(this, schemaKeyRef); if (_typeof(sch) == "object") this._cache["delete"](sch.schema); delete this.schemas[schemaKeyRef]; delete this.refs[schemaKeyRef]; return this; } case "object": { var cacheKey = schemaKeyRef; this._cache["delete"](cacheKey); var id = schemaKeyRef[this.opts.schemaId]; if (id) { id = (0, resolve_1.normalizeId)(id); delete this.schemas[id]; delete this.refs[id]; } return this; } default: throw new Error("ajv.removeSchema: invalid parameter"); } } // add "vocabulary" - a collection of keywords }, { key: "addVocabulary", value: function addVocabulary(definitions) { var _iterator2 = _createForOfIteratorHelper(definitions), _step2; try { for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { var def = _step2.value; this.addKeyword(def); } } catch (err) { _iterator2.e(err); } finally { _iterator2.f(); } return this; } }, { key: "addKeyword", value: function addKeyword(kwdOrDef, def // deprecated ) { var _this = this; var keyword; if (typeof kwdOrDef == "string") { keyword = kwdOrDef; if (_typeof(def) == "object") { this.logger.warn("these parameters are deprecated, see docs for addKeyword"); def.keyword = keyword; } } else if (_typeof(kwdOrDef) == "object" && def === undefined) { def = kwdOrDef; keyword = def.keyword; if (Array.isArray(keyword) && !keyword.length) { throw new Error("addKeywords: keyword must be string or non-empty array"); } } else { throw new Error("invalid addKeywords parameters"); } checkKeyword.call(this, keyword, def); if (!def) { (0, util_1.eachItem)(keyword, function (kwd) { return addRule.call(_this, kwd); }); return this; } keywordMetaschema.call(this, def); var definition = _objectSpread(_objectSpread({}, def), {}, { type: (0, dataType_1.getJSONTypes)(def.type), schemaType: (0, dataType_1.getJSONTypes)(def.schemaType) }); (0, util_1.eachItem)(keyword, definition.type.length === 0 ? function (k) { return addRule.call(_this, k, definition); } : function (k) { return definition.type.forEach(function (t) { return addRule.call(_this, k, definition, t); }); }); return this; } }, { key: "getKeyword", value: function getKeyword(keyword) { var rule = this.RULES.all[keyword]; return _typeof(rule) == "object" ? rule.definition : !!rule; } // Remove keyword }, { key: "removeKeyword", value: function removeKeyword(keyword) { // TODO return type should be Ajv var RULES = this.RULES; delete RULES.keywords[keyword]; delete RULES.all[keyword]; var _iterator3 = _createForOfIteratorHelper(RULES.rules), _step3; try { for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) { var group = _step3.value; var i = group.rules.findIndex(function (rule) { return rule.keyword === keyword; }); if (i >= 0) group.rules.splice(i, 1); } } catch (err) { _iterator3.e(err); } finally { _iterator3.f(); } return this; } // Add format }, { key: "addFormat", value: function addFormat(name, format) { if (typeof format == "string") format = new RegExp(format); this.formats[name] = format; return this; } }, { key: "errorsText", value: function errorsText() { var errors = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.errors; var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, _ref2$separator = _ref2.separator, separator = _ref2$separator === void 0 ? ", " : _ref2$separator, _ref2$dataVar = _ref2.dataVar, dataVar = _ref2$dataVar === void 0 ? "data" : _ref2$dataVar; if (!errors || errors.length === 0) return "No errors"; return errors.map(function (e) { return "".concat(dataVar).concat(e.instancePath, " ").concat(e.message); }).reduce(function (text, msg) { return text + separator + msg; }); } }, { key: "$dataMetaSchema", value: function $dataMetaSchema(metaSchema, keywordsJsonPointers) { var rules = this.RULES.all; metaSchema = JSON.parse(JSON.stringify(metaSchema)); var _iterator4 = _createForOfIteratorHelper(keywordsJsonPointers), _step4; try { for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) { var jsonPointer = _step4.value; var segments = jsonPointer.split("/").slice(1); // first segment is an empty string var keywords = metaSchema; var _iterator5 = _createForOfIteratorHelper(segments), _step5; try { for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) { var seg = _step5.value; keywords = keywords[seg]; } } catch (err) { _iterator5.e(err); } finally { _iterator5.f(); } for (var key in rules) { var rule = rules[key]; if (_typeof(rule) != "object") continue; var $data = rule.definition.$data; var schema = keywords[key]; if ($data && schema) keywords[key] = schemaOrData(schema); } } } catch (err) { _iterator4.e(err); } finally { _iterator4.f(); } return metaSchema; } }, { key: "_removeAllSchemas", value: function _removeAllSchemas(schemas, regex) { for (var keyRef in schemas) { var sch = schemas[keyRef]; if (!regex || regex.test(keyRef)) { if (typeof sch == "string") { delete schemas[keyRef]; } else if (sch && !sch.meta) { this._cache["delete"](sch.schema); delete schemas[keyRef]; } } } } }, { key: "_addSchema", value: function _addSchema(schema, meta, baseId) { var validateSchema = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : this.opts.validateSchema; var addSchema = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : this.opts.addUsedSchema; var id; var schemaId = this.opts.schemaId; if (_typeof(schema) == "object") { id = schema[schemaId]; } else { if (this.opts.jtd) throw new Error("schema must be object");else if (typeof schema != "boolean") throw new Error("schema must be object or boolean"); } var sch = this._cache.get(schema); if (sch !== undefined) return sch; baseId = (0, resolve_1.normalizeId)(id || baseId); var localRefs = resolve_1.getSchemaRefs.call(this, schema, baseId); sch = new compile_1.SchemaEnv({ schema: schema, schemaId: schemaId, meta: meta, baseId: baseId, localRefs: localRefs }); this._cache.set(sch.schema, sch); if (addSchema && !baseId.startsWith("#")) { // TODO atm it is allowed to overwrite schemas without id (instead of not adding them) if (baseId) this._checkUnique(baseId); this.refs[baseId] = sch; } if (validateSchema) this.validateSchema(schema, true); return sch; } }, { key: "_checkUnique", value: function _checkUnique(id) { if (this.schemas[id] || this.refs[id]) { throw new Error("schema with key or id \"".concat(id, "\" already exists")); } } }, { key: "_compileSchemaEnv", value: function _compileSchemaEnv(sch) { if (sch.meta) this._compileMetaSchema(sch);else compile_1.compileSchema.call(this, sch); /* istanbul ignore if */ if (!sch.validate) throw new Error("ajv implementation error"); return sch.validate; } }, { key: "_compileMetaSchema", value: function _compileMetaSchema(sch) { var currentOpts = this.opts; this.opts = this._metaOpts; try { compile_1.compileSchema.call(this, sch); } finally { this.opts = currentOpts; } } }]); return Ajv; }(); exports["default"] = Ajv; Ajv.ValidationError = validation_error_1["default"]; Ajv.MissingRefError = ref_error_1["default"]; function checkOptions(checkOpts, options, msg) { var log = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "error"; for (var key in checkOpts) { var opt = key; if (opt in options) this.logger[log]("".concat(msg, ": option ").concat(key, ". ").concat(checkOpts[opt])); } } function getSchEnv(keyRef) { keyRef = (0, resolve_1.normalizeId)(keyRef); // TODO tests fail without this line return this.schemas[keyRef] || this.refs[keyRef]; } function addInitialSchemas() { var optsSchemas = this.opts.schemas; if (!optsSchemas) return; if (Array.isArray(optsSchemas)) this.addSchema(optsSchemas);else for (var key in optsSchemas) this.addSchema(optsSchemas[key], key); } function addInitialFormats() { for (var name in this.opts.formats) { var format = this.opts.formats[name]; if (format) this.addFormat(name, format); } } function addInitialKeywords(defs) { if (Array.isArray(defs)) { this.addVocabulary(defs); return; } this.logger.warn("keywords option as map is deprecated, pass array"); for (var keyword in defs) { var def = defs[keyword]; if (!def.keyword) def.keyword = keyword; this.addKeyword(def); } } function getMetaSchemaOptions() { var metaOpts = _objectSpread({}, this.opts); var _iterator6 = _createForOfIteratorHelper(META_IGNORE_OPTIONS), _step6; try { for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) { var opt = _step6.value; delete metaOpts[opt]; } } catch (err) { _iterator6.e(err); } finally { _iterator6.f(); } return metaOpts; } var noLogs = { log: function log() {}, warn: function warn() {}, error: function error() {} }; function getLogger(logger) { if (logger === false) return noLogs; if (logger === undefined) return console; if (logger.log && logger.warn && logger.error) return logger; throw new Error("logger must implement log, warn and error methods"); } var KEYWORD_NAME = /^[a-z_$][a-z0-9_$:-]*$/i; function checkKeyword(keyword, def) { var RULES = this.RULES; (0, util_1.eachItem)(keyword, function (kwd) { if (RULES.keywords[kwd]) throw new Error("Keyword ".concat(kwd, " is already defined")); if (!KEYWORD_NAME.test(kwd)) throw new Error("Keyword ".concat(kwd, " has invalid name")); }); if (!def) return; if (def.$data && !("code" in def || "validate" in def)) { throw new Error('$data keyword must have "code" or "validate" function'); } } function addRule(keyword, definition, dataType) { var _this2 = this; var _a; var post = definition === null || definition === void 0 ? void 0 : definition.post; if (dataType && post) throw new Error('keyword with "post" flag cannot have "type"'); var RULES = this.RULES; var ruleGroup = post ? RULES.post : RULES.rules.find(function (_ref3) { var t = _ref3.type; return t === dataType; }); if (!ruleGroup) { ruleGroup = { type: dataType, rules: [] }; RULES.rules.push(ruleGroup); } RULES.keywords[keyword] = true; if (!definition) return; var rule = { keyword: keyword, definition: _objectSpread(_objectSpread({}, definition), {}, { type: (0, dataType_1.getJSONTypes)(definition.type), schemaType: (0, dataType_1.getJSONTypes)(definition.schemaType) }) }; if (definition.before) addBeforeRule.call(this, ruleGroup, rule, definition.before);else ruleGroup.rules.push(rule); RULES.all[keyword] = rule; (_a = definition["implements"]) === null || _a === void 0 ? void 0 : _a.forEach(function (kwd) { return _this2.addKeyword(kwd); }); } function addBeforeRule(ruleGroup, rule, before) { var i = ruleGroup.rules.findIndex(function (_rule) { return _rule.keyword === before; }); if (i >= 0) { ruleGroup.rules.splice(i, 0, rule); } else { ruleGroup.rules.push(rule); this.logger.warn("rule ".concat(before, " is not defined")); } } function keywordMetaschema(def) { var metaSchema = def.metaSchema; if (metaSchema === undefined) return; if (def.$data && this.opts.$data) metaSchema = schemaOrData(metaSchema); def.validateSchema = this.compile(metaSchema, true); } var $dataRef = { $ref: "https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#" }; function schemaOrData(schema) { return { anyOf: [schema, $dataRef] }; } },{"./compile":16,"./compile/codegen":13,"./compile/ref_error":18,"./compile/resolve":19,"./compile/rules":20,"./compile/util":21,"./compile/validate":26,"./compile/validate/dataType":24,"./refs/data.json":30,"./runtime/uri":34,"./runtime/validation_error":35}],30:[function(require,module,exports){ module.exports={ "$id": "https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#", "description": "Meta-schema for $data reference (JSON AnySchema extension proposal)", "type": "object", "required": ["$data"], "properties": { "$data": { "type": "string", "anyOf": [{"format": "relative-json-pointer"}, {"format": "json-pointer"}] } }, "additionalProperties": false } },{}],31:[function(require,module,exports){ module.exports={ "$schema": "http://json-schema.org/draft-07/schema#", "$id": "http://json-schema.org/draft-07/schema#", "title": "Core schema meta-schema", "definitions": { "schemaArray": { "type": "array", "minItems": 1, "items": {"$ref": "#"} }, "nonNegativeInteger": { "type": "integer", "minimum": 0 }, "nonNegativeIntegerDefault0": { "allOf": [{"$ref": "#/definitions/nonNegativeInteger"}, {"default": 0}] }, "simpleTypes": { "enum": ["array", "boolean", "integer", "null", "number", "object", "string"] }, "stringArray": { "type": "array", "items": {"type": "string"}, "uniqueItems": true, "default": [] } }, "type": ["object", "boolean"], "properties": { "$id": { "type": "string", "format": "uri-reference" }, "$schema": { "type": "string", "format": "uri" }, "$ref": { "type": "string", "format": "uri-reference" }, "$comment": { "type": "string" }, "title": { "type": "string" }, "description": { "type": "string" }, "default": true, "readOnly": { "type": "boolean", "default": false }, "examples": { "type": "array", "items": true }, "multipleOf": { "type": "number", "exclusiveMinimum": 0 }, "maximum": { "type": "number" }, "exclusiveMaximum": { "type": "number" }, "minimum": { "type": "number" }, "exclusiveMinimum": { "type": "number" }, "maxLength": {"$ref": "#/definitions/nonNegativeInteger"}, "minLength": {"$ref": "#/definitions/nonNegativeIntegerDefault0"}, "pattern": { "type": "string", "format": "regex" }, "additionalItems": {"$ref": "#"}, "items": { "anyOf": [{"$ref": "#"}, {"$ref": "#/definitions/schemaArray"}], "default": true }, "maxItems": {"$ref": "#/definitions/nonNegativeInteger"}, "minItems": {"$ref": "#/definitions/nonNegativeIntegerDefault0"}, "uniqueItems": { "type": "boolean", "default": false }, "contains": {"$ref": "#"}, "maxProperties": {"$ref": "#/definitions/nonNegativeInteger"}, "minProperties": {"$ref": "#/definitions/nonNegativeIntegerDefault0"}, "required": {"$ref": "#/definitions/stringArray"}, "additionalProperties": {"$ref": "#"}, "definitions": { "type": "object", "additionalProperties": {"$ref": "#"}, "default": {} }, "properties": { "type": "object", "additionalProperties": {"$ref": "#"}, "default": {} }, "patternProperties": { "type": "object", "additionalProperties": {"$ref": "#"}, "propertyNames": {"format": "regex"}, "default": {} }, "dependencies": { "type": "object", "additionalProperties": { "anyOf": [{"$ref": "#"}, {"$ref": "#/definitions/stringArray"}] } }, "propertyNames": {"$ref": "#"}, "const": true, "enum": { "type": "array", "items": true, "minItems": 1, "uniqueItems": true }, "type": { "anyOf": [ {"$ref": "#/definitions/simpleTypes"}, { "type": "array", "items": {"$ref": "#/definitions/simpleTypes"}, "minItems": 1, "uniqueItems": true } ] }, "format": {"type": "string"}, "contentMediaType": {"type": "string"}, "contentEncoding": {"type": "string"}, "if": {"$ref": "#"}, "then": {"$ref": "#"}, "else": {"$ref": "#"}, "allOf": {"$ref": "#/definitions/schemaArray"}, "anyOf": {"$ref": "#/definitions/schemaArray"}, "oneOf": {"$ref": "#/definitions/schemaArray"}, "not": {"$ref": "#"} }, "default": true } },{}],32:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); // https://github.com/ajv-validator/ajv/issues/889 var equal = require("fast-deep-equal"); equal.code = 'require("ajv/dist/runtime/equal").default'; exports["default"] = equal; },{"fast-deep-equal":75}],33:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); // https://mathiasbynens.be/notes/javascript-encoding // https://github.com/bestiejs/punycode.js - punycode.ucs2.decode function ucs2length(str) { var len = str.length; var length = 0; var pos = 0; var value; while (pos < len) { length++; value = str.charCodeAt(pos++); if (value >= 0xd800 && value <= 0xdbff && pos < len) { // high surrogate, and there is a next character value = str.charCodeAt(pos); if ((value & 0xfc00) === 0xdc00) pos++; // low surrogate } } return length; } exports["default"] = ucs2length; ucs2length.code = 'require("ajv/dist/runtime/ucs2length").default'; },{}],34:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var uri = require("uri-js"); uri.code = 'require("ajv/dist/runtime/uri").default'; exports["default"] = uri; },{"uri-js":85}],35:[function(require,module,exports){ "use strict"; function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); } function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); } function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); } function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); } function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct.bind(); } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); } function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } function _isNativeFunction(fn) { try { return Function.toString.call(fn).indexOf("[native code]") !== -1; } catch (e) { return typeof fn === "function"; } } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } Object.defineProperty(exports, "__esModule", { value: true }); var ValidationError = /*#__PURE__*/function (_Error) { _inherits(ValidationError, _Error); var _super = _createSuper(ValidationError); function ValidationError(errors) { var _this; _classCallCheck(this, ValidationError); _this = _super.call(this, "validation failed"); _this.errors = errors; _this.ajv = _this.validation = true; return _this; } return _createClass(ValidationError); }( /*#__PURE__*/_wrapNativeSuper(Error)); exports["default"] = ValidationError; },{}],36:[function(require,module,exports){ "use strict"; var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5; function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } Object.defineProperty(exports, "__esModule", { value: true }); exports.validateAdditionalItems = void 0; var codegen_1 = require("../../compile/codegen"); var util_1 = require("../../compile/util"); var error = { message: function message(_ref) { var len = _ref.params.len; return (0, codegen_1.str)(_templateObject || (_templateObject = _taggedTemplateLiteral(["must NOT have more than ", " items"])), len); }, params: function params(_ref2) { var len = _ref2.params.len; return (0, codegen_1._)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["{limit: ", "}"])), len); } }; var def = { keyword: "additionalItems", type: "array", schemaType: ["boolean", "object"], before: "uniqueItems", error: error, code: function code(cxt) { var parentSchema = cxt.parentSchema, it = cxt.it; var items = parentSchema.items; if (!Array.isArray(items)) { (0, util_1.checkStrictMode)(it, '"additionalItems" is ignored when "items" is not an array of schemas'); return; } validateAdditionalItems(cxt, items); } }; function validateAdditionalItems(cxt, items) { var gen = cxt.gen, schema = cxt.schema, data = cxt.data, keyword = cxt.keyword, it = cxt.it; it.items = true; var len = gen["const"]("len", (0, codegen_1._)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["", ".length"])), data)); if (schema === false) { cxt.setParams({ len: items.length }); cxt.pass((0, codegen_1._)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["", " <= ", ""])), len, items.length)); } else if (_typeof(schema) == "object" && !(0, util_1.alwaysValidSchema)(it, schema)) { var valid = gen["var"]("valid", (0, codegen_1._)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["", " <= ", ""])), len, items.length)); // TODO var gen["if"]((0, codegen_1.not)(valid), function () { return validateItems(valid); }); cxt.ok(valid); } function validateItems(valid) { gen.forRange("i", items.length, len, function (i) { cxt.subschema({ keyword: keyword, dataProp: i, dataPropType: util_1.Type.Num }, valid); if (!it.allErrors) gen["if"]((0, codegen_1.not)(valid), function () { return gen["break"](); }); }); } } exports.validateAdditionalItems = validateAdditionalItems; exports["default"] = def; },{"../../compile/codegen":13,"../../compile/util":21}],37:[function(require,module,exports){ "use strict"; var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5; function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } Object.defineProperty(exports, "__esModule", { value: true }); var code_1 = require("../code"); var codegen_1 = require("../../compile/codegen"); var names_1 = require("../../compile/names"); var util_1 = require("../../compile/util"); var error = { message: "must NOT have additional properties", params: function params(_ref) { var _params = _ref.params; return (0, codegen_1._)(_templateObject || (_templateObject = _taggedTemplateLiteral(["{additionalProperty: ", "}"])), _params.additionalProperty); } }; var def = { keyword: "additionalProperties", type: ["object"], schemaType: ["boolean", "object"], allowUndefined: true, trackErrors: true, error: error, code: function code(cxt) { var gen = cxt.gen, schema = cxt.schema, parentSchema = cxt.parentSchema, data = cxt.data, errsCount = cxt.errsCount, it = cxt.it; /* istanbul ignore if */ if (!errsCount) throw new Error("ajv implementation error"); var allErrors = it.allErrors, opts = it.opts; it.props = true; if (opts.removeAdditional !== "all" && (0, util_1.alwaysValidSchema)(it, schema)) return; var props = (0, code_1.allSchemaProperties)(parentSchema.properties); var patProps = (0, code_1.allSchemaProperties)(parentSchema.patternProperties); checkAdditionalProperties(); cxt.ok((0, codegen_1._)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["", " === ", ""])), errsCount, names_1["default"].errors)); function checkAdditionalProperties() { gen.forIn("key", data, function (key) { if (!props.length && !patProps.length) additionalPropertyCode(key);else gen["if"](isAdditional(key), function () { return additionalPropertyCode(key); }); }); } function isAdditional(key) { var definedProp; if (props.length > 8) { // TODO maybe an option instead of hard-coded 8? var propsSchema = (0, util_1.schemaRefOrVal)(it, parentSchema.properties, "properties"); definedProp = (0, code_1.isOwnProperty)(gen, propsSchema, key); } else if (props.length) { definedProp = (0, codegen_1.or).apply(void 0, _toConsumableArray(props.map(function (p) { return (0, codegen_1._)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["", " === ", ""])), key, p); }))); } else { definedProp = codegen_1.nil; } if (patProps.length) { definedProp = (0, codegen_1.or).apply(void 0, [definedProp].concat(_toConsumableArray(patProps.map(function (p) { return (0, codegen_1._)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["", ".test(", ")"])), (0, code_1.usePattern)(cxt, p), key); })))); } return (0, codegen_1.not)(definedProp); } function deleteAdditional(key) { gen.code((0, codegen_1._)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["delete ", "[", "]"])), data, key)); } function additionalPropertyCode(key) { if (opts.removeAdditional === "all" || opts.removeAdditional && schema === false) { deleteAdditional(key); return; } if (schema === false) { cxt.setParams({ additionalProperty: key }); cxt.error(); if (!allErrors) gen["break"](); return; } if (_typeof(schema) == "object" && !(0, util_1.alwaysValidSchema)(it, schema)) { var valid = gen.name("valid"); if (opts.removeAdditional === "failing") { applyAdditionalSchema(key, valid, false); gen["if"]((0, codegen_1.not)(valid), function () { cxt.reset(); deleteAdditional(key); }); } else { applyAdditionalSchema(key, valid); if (!allErrors) gen["if"]((0, codegen_1.not)(valid), function () { return gen["break"](); }); } } } function applyAdditionalSchema(key, valid, errors) { var subschema = { keyword: "additionalProperties", dataProp: key, dataPropType: util_1.Type.Str }; if (errors === false) { Object.assign(subschema, { compositeRule: true, createErrors: false, allErrors: false }); } cxt.subschema(subschema, valid); } } }; exports["default"] = def; },{"../../compile/codegen":13,"../../compile/names":17,"../../compile/util":21,"../code":53}],38:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var util_1 = require("../../compile/util"); var def = { keyword: "allOf", schemaType: "array", code: function code(cxt) { var gen = cxt.gen, schema = cxt.schema, it = cxt.it; /* istanbul ignore if */ if (!Array.isArray(schema)) throw new Error("ajv implementation error"); var valid = gen.name("valid"); schema.forEach(function (sch, i) { if ((0, util_1.alwaysValidSchema)(it, sch)) return; var schCxt = cxt.subschema({ keyword: "allOf", schemaProp: i }, valid); cxt.ok(valid); cxt.mergeEvaluated(schCxt); }); } }; exports["default"] = def; },{"../../compile/util":21}],39:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var code_1 = require("../code"); var def = { keyword: "anyOf", schemaType: "array", trackErrors: true, code: code_1.validateUnion, error: { message: "must match a schema in anyOf" } }; exports["default"] = def; },{"../code":53}],40:[function(require,module,exports){ "use strict"; var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12; function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } Object.defineProperty(exports, "__esModule", { value: true }); var codegen_1 = require("../../compile/codegen"); var util_1 = require("../../compile/util"); var error = { message: function message(_ref) { var _ref$params = _ref.params, min = _ref$params.min, max = _ref$params.max; return max === undefined ? (0, codegen_1.str)(_templateObject || (_templateObject = _taggedTemplateLiteral(["must contain at least ", " valid item(s)"])), min) : (0, codegen_1.str)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["must contain at least ", " and no more than ", " valid item(s)"])), min, max); }, params: function params(_ref2) { var _ref2$params = _ref2.params, min = _ref2$params.min, max = _ref2$params.max; return max === undefined ? (0, codegen_1._)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["{minContains: ", "}"])), min) : (0, codegen_1._)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["{minContains: ", ", maxContains: ", "}"])), min, max); } }; var def = { keyword: "contains", type: "array", schemaType: ["object", "boolean"], before: "uniqueItems", trackErrors: true, error: error, code: function code(cxt) { var gen = cxt.gen, schema = cxt.schema, parentSchema = cxt.parentSchema, data = cxt.data, it = cxt.it; var min; var max; var minContains = parentSchema.minContains, maxContains = parentSchema.maxContains; if (it.opts.next) { min = minContains === undefined ? 1 : minContains; max = maxContains; } else { min = 1; } var len = gen["const"]("len", (0, codegen_1._)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["", ".length"])), data)); cxt.setParams({ min: min, max: max }); if (max === undefined && min === 0) { (0, util_1.checkStrictMode)(it, "\"minContains\" == 0 without \"maxContains\": \"contains\" keyword ignored"); return; } if (max !== undefined && min > max) { (0, util_1.checkStrictMode)(it, "\"minContains\" > \"maxContains\" is always invalid"); cxt.fail(); return; } if ((0, util_1.alwaysValidSchema)(it, schema)) { var cond = (0, codegen_1._)(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["", " >= ", ""])), len, min); if (max !== undefined) cond = (0, codegen_1._)(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["", " && ", " <= ", ""])), cond, len, max); cxt.pass(cond); return; } it.items = true; var valid = gen.name("valid"); if (max === undefined && min === 1) { validateItems(valid, function () { return gen["if"](valid, function () { return gen["break"](); }); }); } else if (min === 0) { gen["let"](valid, true); if (max !== undefined) gen["if"]((0, codegen_1._)(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["", ".length > 0"])), data), validateItemsWithCount); } else { gen["let"](valid, false); validateItemsWithCount(); } cxt.result(valid, function () { return cxt.reset(); }); function validateItemsWithCount() { var schValid = gen.name("_valid"); var count = gen["let"]("count", 0); validateItems(schValid, function () { return gen["if"](schValid, function () { return checkLimits(count); }); }); } function validateItems(_valid, block) { gen.forRange("i", 0, len, function (i) { cxt.subschema({ keyword: "contains", dataProp: i, dataPropType: util_1.Type.Num, compositeRule: true }, _valid); block(); }); } function checkLimits(count) { gen.code((0, codegen_1._)(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["", "++"])), count)); if (max === undefined) { gen["if"]((0, codegen_1._)(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["", " >= ", ""])), count, min), function () { return gen.assign(valid, true)["break"](); }); } else { gen["if"]((0, codegen_1._)(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["", " > ", ""])), count, max), function () { return gen.assign(valid, false)["break"](); }); if (min === 1) gen.assign(valid, true);else gen["if"]((0, codegen_1._)(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["", " >= ", ""])), count, min), function () { return gen.assign(valid, true); }); } } } }; exports["default"] = def; },{"../../compile/codegen":13,"../../compile/util":21}],41:[function(require,module,exports){ "use strict"; var _templateObject, _templateObject2, _templateObject3; function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; } function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } } function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } Object.defineProperty(exports, "__esModule", { value: true }); exports.validateSchemaDeps = exports.validatePropertyDeps = exports.error = void 0; var codegen_1 = require("../../compile/codegen"); var util_1 = require("../../compile/util"); var code_1 = require("../code"); exports.error = { message: function message(_ref) { var _ref$params = _ref.params, property = _ref$params.property, depsCount = _ref$params.depsCount, deps = _ref$params.deps; var property_ies = depsCount === 1 ? "property" : "properties"; return (0, codegen_1.str)(_templateObject || (_templateObject = _taggedTemplateLiteral(["must have ", " ", " when property ", " is present"])), property_ies, deps, property); }, params: function params(_ref2) { var _ref2$params = _ref2.params, property = _ref2$params.property, depsCount = _ref2$params.depsCount, deps = _ref2$params.deps, missingProperty = _ref2$params.missingProperty; return (0, codegen_1._)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["{property: ", ",\n missingProperty: ", ",\n depsCount: ", ",\n deps: ", "}"])), property, missingProperty, depsCount, deps); } // TODO change to reference }; var def = { keyword: "dependencies", type: "object", schemaType: "object", error: exports.error, code: function code(cxt) { var _splitDependencies = splitDependencies(cxt), _splitDependencies2 = _slicedToArray(_splitDependencies, 2), propDeps = _splitDependencies2[0], schDeps = _splitDependencies2[1]; validatePropertyDeps(cxt, propDeps); validateSchemaDeps(cxt, schDeps); } }; function splitDependencies(_ref3) { var schema = _ref3.schema; var propertyDeps = {}; var schemaDeps = {}; for (var key in schema) { if (key === "__proto__") continue; var deps = Array.isArray(schema[key]) ? propertyDeps : schemaDeps; deps[key] = schema[key]; } return [propertyDeps, schemaDeps]; } function validatePropertyDeps(cxt) { var propertyDeps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : cxt.schema; var gen = cxt.gen, data = cxt.data, it = cxt.it; if (Object.keys(propertyDeps).length === 0) return; var missing = gen["let"]("missing"); var _loop = function _loop() { var deps = propertyDeps[prop]; if (deps.length === 0) return 1; // continue var hasProperty = (0, code_1.propertyInData)(gen, data, prop, it.opts.ownProperties); cxt.setParams({ property: prop, depsCount: deps.length, deps: deps.join(", ") }); if (it.allErrors) { gen["if"](hasProperty, function () { var _iterator = _createForOfIteratorHelper(deps), _step; try { for (_iterator.s(); !(_step = _iterator.n()).done;) { var depProp = _step.value; (0, code_1.checkReportMissingProp)(cxt, depProp); } } catch (err) { _iterator.e(err); } finally { _iterator.f(); } }); } else { gen["if"]((0, codegen_1._)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["", " && (", ")"])), hasProperty, (0, code_1.checkMissingProp)(cxt, deps, missing))); (0, code_1.reportMissingProp)(cxt, missing); gen["else"](); } }; for (var prop in propertyDeps) { if (_loop()) continue; } } exports.validatePropertyDeps = validatePropertyDeps; function validateSchemaDeps(cxt) { var schemaDeps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : cxt.schema; var gen = cxt.gen, data = cxt.data, keyword = cxt.keyword, it = cxt.it; var valid = gen.name("valid"); var _loop2 = function _loop2(prop) { if ((0, util_1.alwaysValidSchema)(it, schemaDeps[prop])) return 1; // continue gen["if"]((0, code_1.propertyInData)(gen, data, prop, it.opts.ownProperties), function () { var schCxt = cxt.subschema({ keyword: keyword, schemaProp: prop }, valid); cxt.mergeValidEvaluated(schCxt, valid); }, function () { return gen["var"](valid, true); } // TODO var ); cxt.ok(valid); }; for (var prop in schemaDeps) { if (_loop2(prop)) continue; } } exports.validateSchemaDeps = validateSchemaDeps; exports["default"] = def; },{"../../compile/codegen":13,"../../compile/util":21,"../code":53}],42:[function(require,module,exports){ "use strict"; var _templateObject, _templateObject2, _templateObject3; function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } Object.defineProperty(exports, "__esModule", { value: true }); var codegen_1 = require("../../compile/codegen"); var util_1 = require("../../compile/util"); var error = { message: function message(_ref) { var params = _ref.params; return (0, codegen_1.str)(_templateObject || (_templateObject = _taggedTemplateLiteral(["must match \"", "\" schema"])), params.ifClause); }, params: function params(_ref2) { var _params = _ref2.params; return (0, codegen_1._)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["{failingKeyword: ", "}"])), _params.ifClause); } }; var def = { keyword: "if", schemaType: ["object", "boolean"], trackErrors: true, error: error, code: function code(cxt) { var gen = cxt.gen, parentSchema = cxt.parentSchema, it = cxt.it; if (parentSchema.then === undefined && parentSchema["else"] === undefined) { (0, util_1.checkStrictMode)(it, '"if" without "then" and "else" is ignored'); } var hasThen = hasSchema(it, "then"); var hasElse = hasSchema(it, "else"); if (!hasThen && !hasElse) return; var valid = gen["let"]("valid", true); var schValid = gen.name("_valid"); validateIf(); cxt.reset(); if (hasThen && hasElse) { var ifClause = gen["let"]("ifClause"); cxt.setParams({ ifClause: ifClause }); gen["if"](schValid, validateClause("then", ifClause), validateClause("else", ifClause)); } else if (hasThen) { gen["if"](schValid, validateClause("then")); } else { gen["if"]((0, codegen_1.not)(schValid), validateClause("else")); } cxt.pass(valid, function () { return cxt.error(true); }); function validateIf() { var schCxt = cxt.subschema({ keyword: "if", compositeRule: true, createErrors: false, allErrors: false }, schValid); cxt.mergeEvaluated(schCxt); } function validateClause(keyword, ifClause) { return function () { var schCxt = cxt.subschema({ keyword: keyword }, schValid); gen.assign(valid, schValid); cxt.mergeValidEvaluated(schCxt, valid); if (ifClause) gen.assign(ifClause, (0, codegen_1._)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["", ""])), keyword));else cxt.setParams({ ifClause: keyword }); }; } } }; function hasSchema(it, keyword) { var schema = it.schema[keyword]; return schema !== undefined && !(0, util_1.alwaysValidSchema)(it, schema); } exports["default"] = def; },{"../../compile/codegen":13,"../../compile/util":21}],43:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var additionalItems_1 = require("./additionalItems"); var prefixItems_1 = require("./prefixItems"); var items_1 = require("./items"); var items2020_1 = require("./items2020"); var contains_1 = require("./contains"); var dependencies_1 = require("./dependencies"); var propertyNames_1 = require("./propertyNames"); var additionalProperties_1 = require("./additionalProperties"); var properties_1 = require("./properties"); var patternProperties_1 = require("./patternProperties"); var not_1 = require("./not"); var anyOf_1 = require("./anyOf"); var oneOf_1 = require("./oneOf"); var allOf_1 = require("./allOf"); var if_1 = require("./if"); var thenElse_1 = require("./thenElse"); function getApplicator() { var draft2020 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; var applicator = [ // any not_1["default"], anyOf_1["default"], oneOf_1["default"], allOf_1["default"], if_1["default"], thenElse_1["default"], // object propertyNames_1["default"], additionalProperties_1["default"], dependencies_1["default"], properties_1["default"], patternProperties_1["default"]]; // array if (draft2020) applicator.push(prefixItems_1["default"], items2020_1["default"]);else applicator.push(additionalItems_1["default"], items_1["default"]); applicator.push(contains_1["default"]); return applicator; } exports["default"] = getApplicator; },{"./additionalItems":36,"./additionalProperties":37,"./allOf":38,"./anyOf":39,"./contains":40,"./dependencies":41,"./if":42,"./items":44,"./items2020":45,"./not":46,"./oneOf":47,"./patternProperties":48,"./prefixItems":49,"./properties":50,"./propertyNames":51,"./thenElse":52}],44:[function(require,module,exports){ "use strict"; var _templateObject, _templateObject2; function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } Object.defineProperty(exports, "__esModule", { value: true }); exports.validateTuple = void 0; var codegen_1 = require("../../compile/codegen"); var util_1 = require("../../compile/util"); var code_1 = require("../code"); var def = { keyword: "items", type: "array", schemaType: ["object", "array", "boolean"], before: "uniqueItems", code: function code(cxt) { var schema = cxt.schema, it = cxt.it; if (Array.isArray(schema)) return validateTuple(cxt, "additionalItems", schema); it.items = true; if ((0, util_1.alwaysValidSchema)(it, schema)) return; cxt.ok((0, code_1.validateArray)(cxt)); } }; function validateTuple(cxt, extraItems) { var schArr = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : cxt.schema; var gen = cxt.gen, parentSchema = cxt.parentSchema, data = cxt.data, keyword = cxt.keyword, it = cxt.it; checkStrictTuple(parentSchema); if (it.opts.unevaluated && schArr.length && it.items !== true) { it.items = util_1.mergeEvaluated.items(gen, schArr.length, it.items); } var valid = gen.name("valid"); var len = gen["const"]("len", (0, codegen_1._)(_templateObject || (_templateObject = _taggedTemplateLiteral(["", ".length"])), data)); schArr.forEach(function (sch, i) { if ((0, util_1.alwaysValidSchema)(it, sch)) return; gen["if"]((0, codegen_1._)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["", " > ", ""])), len, i), function () { return cxt.subschema({ keyword: keyword, schemaProp: i, dataProp: i }, valid); }); cxt.ok(valid); }); function checkStrictTuple(sch) { var opts = it.opts, errSchemaPath = it.errSchemaPath; var l = schArr.length; var fullTuple = l === sch.minItems && (l === sch.maxItems || sch[extraItems] === false); if (opts.strictTuples && !fullTuple) { var msg = "\"".concat(keyword, "\" is ").concat(l, "-tuple, but minItems or maxItems/").concat(extraItems, " are not specified or different at path \"").concat(errSchemaPath, "\""); (0, util_1.checkStrictMode)(it, msg, opts.strictTuples); } } } exports.validateTuple = validateTuple; exports["default"] = def; },{"../../compile/codegen":13,"../../compile/util":21,"../code":53}],45:[function(require,module,exports){ "use strict"; var _templateObject, _templateObject2; function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } Object.defineProperty(exports, "__esModule", { value: true }); var codegen_1 = require("../../compile/codegen"); var util_1 = require("../../compile/util"); var code_1 = require("../code"); var additionalItems_1 = require("./additionalItems"); var error = { message: function message(_ref) { var len = _ref.params.len; return (0, codegen_1.str)(_templateObject || (_templateObject = _taggedTemplateLiteral(["must NOT have more than ", " items"])), len); }, params: function params(_ref2) { var len = _ref2.params.len; return (0, codegen_1._)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["{limit: ", "}"])), len); } }; var def = { keyword: "items", type: "array", schemaType: ["object", "boolean"], before: "uniqueItems", error: error, code: function code(cxt) { var schema = cxt.schema, parentSchema = cxt.parentSchema, it = cxt.it; var prefixItems = parentSchema.prefixItems; it.items = true; if ((0, util_1.alwaysValidSchema)(it, schema)) return; if (prefixItems) (0, additionalItems_1.validateAdditionalItems)(cxt, prefixItems);else cxt.ok((0, code_1.validateArray)(cxt)); } }; exports["default"] = def; },{"../../compile/codegen":13,"../../compile/util":21,"../code":53,"./additionalItems":36}],46:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var util_1 = require("../../compile/util"); var def = { keyword: "not", schemaType: ["object", "boolean"], trackErrors: true, code: function code(cxt) { var gen = cxt.gen, schema = cxt.schema, it = cxt.it; if ((0, util_1.alwaysValidSchema)(it, schema)) { cxt.fail(); return; } var valid = gen.name("valid"); cxt.subschema({ keyword: "not", compositeRule: true, createErrors: false, allErrors: false }, valid); cxt.failResult(valid, function () { return cxt.reset(); }, function () { return cxt.error(); }); }, error: { message: "must NOT be valid" } }; exports["default"] = def; },{"../../compile/util":21}],47:[function(require,module,exports){ "use strict"; var _templateObject, _templateObject2, _templateObject3; function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } Object.defineProperty(exports, "__esModule", { value: true }); var codegen_1 = require("../../compile/codegen"); var util_1 = require("../../compile/util"); var error = { message: "must match exactly one schema in oneOf", params: function params(_ref) { var _params = _ref.params; return (0, codegen_1._)(_templateObject || (_templateObject = _taggedTemplateLiteral(["{passingSchemas: ", "}"])), _params.passing); } }; var def = { keyword: "oneOf", schemaType: "array", trackErrors: true, error: error, code: function code(cxt) { var gen = cxt.gen, schema = cxt.schema, parentSchema = cxt.parentSchema, it = cxt.it; /* istanbul ignore if */ if (!Array.isArray(schema)) throw new Error("ajv implementation error"); if (it.opts.discriminator && parentSchema.discriminator) return; var schArr = schema; var valid = gen["let"]("valid", false); var passing = gen["let"]("passing", null); var schValid = gen.name("_valid"); cxt.setParams({ passing: passing }); // TODO possibly fail straight away (with warning or exception) if there are two empty always valid schemas gen.block(validateOneOf); cxt.result(valid, function () { return cxt.reset(); }, function () { return cxt.error(true); }); function validateOneOf() { schArr.forEach(function (sch, i) { var schCxt; if ((0, util_1.alwaysValidSchema)(it, sch)) { gen["var"](schValid, true); } else { schCxt = cxt.subschema({ keyword: "oneOf", schemaProp: i, compositeRule: true }, schValid); } if (i > 0) { gen["if"]((0, codegen_1._)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["", " && ", ""])), schValid, valid)).assign(valid, false).assign(passing, (0, codegen_1._)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["[", ", ", "]"])), passing, i))["else"](); } gen["if"](schValid, function () { gen.assign(valid, true); gen.assign(passing, i); if (schCxt) cxt.mergeEvaluated(schCxt, codegen_1.Name); }); }); } } }; exports["default"] = def; },{"../../compile/codegen":13,"../../compile/util":21}],48:[function(require,module,exports){ "use strict"; var _templateObject, _templateObject2; function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } Object.defineProperty(exports, "__esModule", { value: true }); var code_1 = require("../code"); var codegen_1 = require("../../compile/codegen"); var util_1 = require("../../compile/util"); var util_2 = require("../../compile/util"); var def = { keyword: "patternProperties", type: "object", schemaType: "object", code: function code(cxt) { var gen = cxt.gen, schema = cxt.schema, data = cxt.data, parentSchema = cxt.parentSchema, it = cxt.it; var opts = it.opts; var patterns = (0, code_1.allSchemaProperties)(schema); var alwaysValidPatterns = patterns.filter(function (p) { return (0, util_1.alwaysValidSchema)(it, schema[p]); }); if (patterns.length === 0 || alwaysValidPatterns.length === patterns.length && (!it.opts.unevaluated || it.props === true)) { return; } var checkProperties = opts.strictSchema && !opts.allowMatchingProperties && parentSchema.properties; var valid = gen.name("valid"); if (it.props !== true && !(it.props instanceof codegen_1.Name)) { it.props = (0, util_2.evaluatedPropsToName)(gen, it.props); } var props = it.props; validatePatternProperties(); function validatePatternProperties() { var _iterator = _createForOfIteratorHelper(patterns), _step; try { for (_iterator.s(); !(_step = _iterator.n()).done;) { var pat = _step.value; if (checkProperties) checkMatchingProperties(pat); if (it.allErrors) { validateProperties(pat); } else { gen["var"](valid, true); // TODO var validateProperties(pat); gen["if"](valid); } } } catch (err) { _iterator.e(err); } finally { _iterator.f(); } } function checkMatchingProperties(pat) { for (var prop in checkProperties) { if (new RegExp(pat).test(prop)) { (0, util_1.checkStrictMode)(it, "property ".concat(prop, " matches pattern ").concat(pat, " (use allowMatchingProperties)")); } } } function validateProperties(pat) { gen.forIn("key", data, function (key) { gen["if"]((0, codegen_1._)(_templateObject || (_templateObject = _taggedTemplateLiteral(["", ".test(", ")"])), (0, code_1.usePattern)(cxt, pat), key), function () { var alwaysValid = alwaysValidPatterns.includes(pat); if (!alwaysValid) { cxt.subschema({ keyword: "patternProperties", schemaProp: pat, dataProp: key, dataPropType: util_2.Type.Str }, valid); } if (it.opts.unevaluated && props !== true) { gen.assign((0, codegen_1._)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["", "[", "]"])), props, key), true); } else if (!alwaysValid && !it.allErrors) { // can short-circuit if `unevaluatedProperties` is not supported (opts.next === false) // or if all properties were evaluated (props === true) gen["if"]((0, codegen_1.not)(valid), function () { return gen["break"](); }); } }); }); } } }; exports["default"] = def; },{"../../compile/codegen":13,"../../compile/util":21,"../code":53}],49:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var items_1 = require("./items"); var def = { keyword: "prefixItems", type: "array", schemaType: ["array"], before: "uniqueItems", code: function code(cxt) { return (0, items_1.validateTuple)(cxt, "items"); } }; exports["default"] = def; },{"./items":44}],50:[function(require,module,exports){ "use strict"; function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } Object.defineProperty(exports, "__esModule", { value: true }); var validate_1 = require("../../compile/validate"); var code_1 = require("../code"); var util_1 = require("../../compile/util"); var additionalProperties_1 = require("./additionalProperties"); var def = { keyword: "properties", type: "object", schemaType: "object", code: function code(cxt) { var gen = cxt.gen, schema = cxt.schema, parentSchema = cxt.parentSchema, data = cxt.data, it = cxt.it; if (it.opts.removeAdditional === "all" && parentSchema.additionalProperties === undefined) { additionalProperties_1["default"].code(new validate_1.KeywordCxt(it, additionalProperties_1["default"], "additionalProperties")); } var allProps = (0, code_1.allSchemaProperties)(schema); var _iterator = _createForOfIteratorHelper(allProps), _step; try { for (_iterator.s(); !(_step = _iterator.n()).done;) { var prop = _step.value; it.definedProperties.add(prop); } } catch (err) { _iterator.e(err); } finally { _iterator.f(); } if (it.opts.unevaluated && allProps.length && it.props !== true) { it.props = util_1.mergeEvaluated.props(gen, (0, util_1.toHash)(allProps), it.props); } var properties = allProps.filter(function (p) { return !(0, util_1.alwaysValidSchema)(it, schema[p]); }); if (properties.length === 0) return; var valid = gen.name("valid"); var _iterator2 = _createForOfIteratorHelper(properties), _step2; try { for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { var _prop = _step2.value; if (hasDefault(_prop)) { applyPropertySchema(_prop); } else { gen["if"]((0, code_1.propertyInData)(gen, data, _prop, it.opts.ownProperties)); applyPropertySchema(_prop); if (!it.allErrors) gen["else"]()["var"](valid, true); gen.endIf(); } cxt.it.definedProperties.add(_prop); cxt.ok(valid); } } catch (err) { _iterator2.e(err); } finally { _iterator2.f(); } function hasDefault(prop) { return it.opts.useDefaults && !it.compositeRule && schema[prop]["default"] !== undefined; } function applyPropertySchema(prop) { cxt.subschema({ keyword: "properties", schemaProp: prop, dataProp: prop }, valid); } } }; exports["default"] = def; },{"../../compile/util":21,"../../compile/validate":26,"../code":53,"./additionalProperties":37}],51:[function(require,module,exports){ "use strict"; var _templateObject; function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } Object.defineProperty(exports, "__esModule", { value: true }); var codegen_1 = require("../../compile/codegen"); var util_1 = require("../../compile/util"); var error = { message: "property name must be valid", params: function params(_ref) { var _params = _ref.params; return (0, codegen_1._)(_templateObject || (_templateObject = _taggedTemplateLiteral(["{propertyName: ", "}"])), _params.propertyName); } }; var def = { keyword: "propertyNames", type: "object", schemaType: ["object", "boolean"], error: error, code: function code(cxt) { var gen = cxt.gen, schema = cxt.schema, data = cxt.data, it = cxt.it; if ((0, util_1.alwaysValidSchema)(it, schema)) return; var valid = gen.name("valid"); gen.forIn("key", data, function (key) { cxt.setParams({ propertyName: key }); cxt.subschema({ keyword: "propertyNames", data: key, dataTypes: ["string"], propertyName: key, compositeRule: true }, valid); gen["if"]((0, codegen_1.not)(valid), function () { cxt.error(true); if (!it.allErrors) gen["break"](); }); }); cxt.ok(valid); } }; exports["default"] = def; },{"../../compile/codegen":13,"../../compile/util":21}],52:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var util_1 = require("../../compile/util"); var def = { keyword: ["then", "else"], schemaType: ["object", "boolean"], code: function code(_ref) { var keyword = _ref.keyword, parentSchema = _ref.parentSchema, it = _ref.it; if (parentSchema["if"] === undefined) (0, util_1.checkStrictMode)(it, "\"".concat(keyword, "\" without \"if\" is ignored")); } }; exports["default"] = def; },{"../../compile/util":21}],53:[function(require,module,exports){ "use strict"; var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15; function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } Object.defineProperty(exports, "__esModule", { value: true }); exports.validateUnion = exports.validateArray = exports.usePattern = exports.callValidateCode = exports.schemaProperties = exports.allSchemaProperties = exports.noPropertyInData = exports.propertyInData = exports.isOwnProperty = exports.hasPropFunc = exports.reportMissingProp = exports.checkMissingProp = exports.checkReportMissingProp = void 0; var codegen_1 = require("../compile/codegen"); var util_1 = require("../compile/util"); var names_1 = require("../compile/names"); var util_2 = require("../compile/util"); function checkReportMissingProp(cxt, prop) { var gen = cxt.gen, data = cxt.data, it = cxt.it; gen["if"](noPropertyInData(gen, data, prop, it.opts.ownProperties), function () { cxt.setParams({ missingProperty: (0, codegen_1._)(_templateObject || (_templateObject = _taggedTemplateLiteral(["", ""])), prop) }, true); cxt.error(); }); } exports.checkReportMissingProp = checkReportMissingProp; function checkMissingProp(_ref, properties, missing) { var gen = _ref.gen, data = _ref.data, opts = _ref.it.opts; return (0, codegen_1.or).apply(void 0, _toConsumableArray(properties.map(function (prop) { return (0, codegen_1.and)(noPropertyInData(gen, data, prop, opts.ownProperties), (0, codegen_1._)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["", " = ", ""])), missing, prop)); }))); } exports.checkMissingProp = checkMissingProp; function reportMissingProp(cxt, missing) { cxt.setParams({ missingProperty: missing }, true); cxt.error(); } exports.reportMissingProp = reportMissingProp; function hasPropFunc(gen) { return gen.scopeValue("func", { // eslint-disable-next-line @typescript-eslint/unbound-method ref: Object.prototype.hasOwnProperty, code: (0, codegen_1._)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["Object.prototype.hasOwnProperty"]))) }); } exports.hasPropFunc = hasPropFunc; function isOwnProperty(gen, data, property) { return (0, codegen_1._)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["", ".call(", ", ", ")"])), hasPropFunc(gen), data, property); } exports.isOwnProperty = isOwnProperty; function propertyInData(gen, data, property, ownProperties) { var cond = (0, codegen_1._)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["", "", " !== undefined"])), data, (0, codegen_1.getProperty)(property)); return ownProperties ? (0, codegen_1._)(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["", " && ", ""])), cond, isOwnProperty(gen, data, property)) : cond; } exports.propertyInData = propertyInData; function noPropertyInData(gen, data, property, ownProperties) { var cond = (0, codegen_1._)(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["", "", " === undefined"])), data, (0, codegen_1.getProperty)(property)); return ownProperties ? (0, codegen_1.or)(cond, (0, codegen_1.not)(isOwnProperty(gen, data, property))) : cond; } exports.noPropertyInData = noPropertyInData; function allSchemaProperties(schemaMap) { return schemaMap ? Object.keys(schemaMap).filter(function (p) { return p !== "__proto__"; }) : []; } exports.allSchemaProperties = allSchemaProperties; function schemaProperties(it, schemaMap) { return allSchemaProperties(schemaMap).filter(function (p) { return !(0, util_1.alwaysValidSchema)(it, schemaMap[p]); }); } exports.schemaProperties = schemaProperties; function callValidateCode(_ref2, func, context, passSchema) { var schemaCode = _ref2.schemaCode, data = _ref2.data, _ref2$it = _ref2.it, gen = _ref2$it.gen, topSchemaRef = _ref2$it.topSchemaRef, schemaPath = _ref2$it.schemaPath, errorPath = _ref2$it.errorPath, it = _ref2.it; var dataAndSchema = passSchema ? (0, codegen_1._)(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["", ", ", ", ", "", ""])), schemaCode, data, topSchemaRef, schemaPath) : data; var valCxt = [[names_1["default"].instancePath, (0, codegen_1.strConcat)(names_1["default"].instancePath, errorPath)], [names_1["default"].parentData, it.parentData], [names_1["default"].parentDataProperty, it.parentDataProperty], [names_1["default"].rootData, names_1["default"].rootData]]; if (it.opts.dynamicRef) valCxt.push([names_1["default"].dynamicAnchors, names_1["default"].dynamicAnchors]); var args = (0, codegen_1._)(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["", ", ", ""])), dataAndSchema, gen.object.apply(gen, valCxt)); return context !== codegen_1.nil ? (0, codegen_1._)(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["", ".call(", ", ", ")"])), func, context, args) : (0, codegen_1._)(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["", "(", ")"])), func, args); } exports.callValidateCode = callValidateCode; var newRegExp = (0, codegen_1._)(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["new RegExp"]))); function usePattern(_ref3, pattern) { var gen = _ref3.gen, opts = _ref3.it.opts; var u = opts.unicodeRegExp ? "u" : ""; var regExp = opts.code.regExp; var rx = regExp(pattern, u); return gen.scopeValue("pattern", { key: rx.toString(), ref: rx, code: (0, codegen_1._)(_templateObject13 || (_templateObject13 = _taggedTemplateLiteral(["", "(", ", ", ")"])), regExp.code === "new RegExp" ? newRegExp : (0, util_2.useFunc)(gen, regExp), pattern, u) }); } exports.usePattern = usePattern; function validateArray(cxt) { var gen = cxt.gen, data = cxt.data, keyword = cxt.keyword, it = cxt.it; var valid = gen.name("valid"); if (it.allErrors) { var validArr = gen["let"]("valid", true); validateItems(function () { return gen.assign(validArr, false); }); return validArr; } gen["var"](valid, true); validateItems(function () { return gen["break"](); }); return valid; function validateItems(notValid) { var len = gen["const"]("len", (0, codegen_1._)(_templateObject14 || (_templateObject14 = _taggedTemplateLiteral(["", ".length"])), data)); gen.forRange("i", 0, len, function (i) { cxt.subschema({ keyword: keyword, dataProp: i, dataPropType: util_1.Type.Num }, valid); gen["if"]((0, codegen_1.not)(valid), notValid); }); } } exports.validateArray = validateArray; function validateUnion(cxt) { var gen = cxt.gen, schema = cxt.schema, keyword = cxt.keyword, it = cxt.it; /* istanbul ignore if */ if (!Array.isArray(schema)) throw new Error("ajv implementation error"); var alwaysValid = schema.some(function (sch) { return (0, util_1.alwaysValidSchema)(it, sch); }); if (alwaysValid && !it.opts.unevaluated) return; var valid = gen["let"]("valid", false); var schValid = gen.name("_valid"); gen.block(function () { return schema.forEach(function (_sch, i) { var schCxt = cxt.subschema({ keyword: keyword, schemaProp: i, compositeRule: true }, schValid); gen.assign(valid, (0, codegen_1._)(_templateObject15 || (_templateObject15 = _taggedTemplateLiteral(["", " || ", ""])), valid, schValid)); var merged = cxt.mergeValidEvaluated(schCxt, schValid); // can short-circuit if `unevaluatedProperties/Items` not supported (opts.unevaluated !== true) // or if all properties and items were evaluated (it.props === true && it.items === true) if (!merged) gen["if"]((0, codegen_1.not)(valid)); }); }); cxt.result(valid, function () { return cxt.reset(); }, function () { return cxt.error(true); }); } exports.validateUnion = validateUnion; },{"../compile/codegen":13,"../compile/names":17,"../compile/util":21}],54:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var def = { keyword: "id", code: function code() { throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID'); } }; exports["default"] = def; },{}],55:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var id_1 = require("./id"); var ref_1 = require("./ref"); var core = ["$schema", "$id", "$defs", "$vocabulary", { keyword: "$comment" }, "definitions", id_1["default"], ref_1["default"]]; exports["default"] = core; },{"./id":54,"./ref":56}],56:[function(require,module,exports){ "use strict"; var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9; function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } Object.defineProperty(exports, "__esModule", { value: true }); exports.callRef = exports.getValidate = void 0; var ref_error_1 = require("../../compile/ref_error"); var code_1 = require("../code"); var codegen_1 = require("../../compile/codegen"); var names_1 = require("../../compile/names"); var compile_1 = require("../../compile"); var util_1 = require("../../compile/util"); var def = { keyword: "$ref", schemaType: "string", code: function code(cxt) { var gen = cxt.gen, $ref = cxt.schema, it = cxt.it; var baseId = it.baseId, env = it.schemaEnv, validateName = it.validateName, opts = it.opts, self = it.self; var root = env.root; if (($ref === "#" || $ref === "#/") && baseId === root.baseId) return callRootRef(); var schOrEnv = compile_1.resolveRef.call(self, root, baseId, $ref); if (schOrEnv === undefined) throw new ref_error_1["default"](it.opts.uriResolver, baseId, $ref); if (schOrEnv instanceof compile_1.SchemaEnv) return callValidate(schOrEnv); return inlineRefSchema(schOrEnv); function callRootRef() { if (env === root) return callRef(cxt, validateName, env, env.$async); var rootName = gen.scopeValue("root", { ref: root }); return callRef(cxt, (0, codegen_1._)(_templateObject || (_templateObject = _taggedTemplateLiteral(["", ".validate"])), rootName), root, root.$async); } function callValidate(sch) { var v = getValidate(cxt, sch); callRef(cxt, v, sch, sch.$async); } function inlineRefSchema(sch) { var schName = gen.scopeValue("schema", opts.code.source === true ? { ref: sch, code: (0, codegen_1.stringify)(sch) } : { ref: sch }); var valid = gen.name("valid"); var schCxt = cxt.subschema({ schema: sch, dataTypes: [], schemaPath: codegen_1.nil, topSchemaRef: schName, errSchemaPath: $ref }, valid); cxt.mergeEvaluated(schCxt); cxt.ok(valid); } } }; function getValidate(cxt, sch) { var gen = cxt.gen; return sch.validate ? gen.scopeValue("validate", { ref: sch.validate }) : (0, codegen_1._)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["", ".validate"])), gen.scopeValue("wrapper", { ref: sch })); } exports.getValidate = getValidate; function callRef(cxt, v, sch, $async) { var gen = cxt.gen, it = cxt.it; var allErrors = it.allErrors, env = it.schemaEnv, opts = it.opts; var passCxt = opts.passContext ? names_1["default"]["this"] : codegen_1.nil; if ($async) callAsyncRef();else callSyncRef(); function callAsyncRef() { if (!env.$async) throw new Error("async schema referenced by sync schema"); var valid = gen["let"]("valid"); gen["try"](function () { gen.code((0, codegen_1._)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["await ", ""])), (0, code_1.callValidateCode)(cxt, v, passCxt))); addEvaluatedFrom(v); // TODO will not work with async, it has to be returned with the result if (!allErrors) gen.assign(valid, true); }, function (e) { gen["if"]((0, codegen_1._)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["!(", " instanceof ", ")"])), e, it.ValidationError), function () { return gen["throw"](e); }); addErrorsFrom(e); if (!allErrors) gen.assign(valid, false); }); cxt.ok(valid); } function callSyncRef() { cxt.result((0, code_1.callValidateCode)(cxt, v, passCxt), function () { return addEvaluatedFrom(v); }, function () { return addErrorsFrom(v); }); } function addErrorsFrom(source) { var errs = (0, codegen_1._)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["", ".errors"])), source); gen.assign(names_1["default"].vErrors, (0, codegen_1._)(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["", " === null ? ", " : ", ".concat(", ")"])), names_1["default"].vErrors, errs, names_1["default"].vErrors, errs)); // TODO tagged gen.assign(names_1["default"].errors, (0, codegen_1._)(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["", ".length"])), names_1["default"].vErrors)); } function addEvaluatedFrom(source) { var _a; if (!it.opts.unevaluated) return; var schEvaluated = (_a = sch === null || sch === void 0 ? void 0 : sch.validate) === null || _a === void 0 ? void 0 : _a.evaluated; // TODO refactor if (it.props !== true) { if (schEvaluated && !schEvaluated.dynamicProps) { if (schEvaluated.props !== undefined) { it.props = util_1.mergeEvaluated.props(gen, schEvaluated.props, it.props); } } else { var props = gen["var"]("props", (0, codegen_1._)(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["", ".evaluated.props"])), source)); it.props = util_1.mergeEvaluated.props(gen, props, it.props, codegen_1.Name); } } if (it.items !== true) { if (schEvaluated && !schEvaluated.dynamicItems) { if (schEvaluated.items !== undefined) { it.items = util_1.mergeEvaluated.items(gen, schEvaluated.items, it.items); } } else { var items = gen["var"]("items", (0, codegen_1._)(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["", ".evaluated.items"])), source)); it.items = util_1.mergeEvaluated.items(gen, items, it.items, codegen_1.Name); } } } } exports.callRef = callRef; exports["default"] = def; },{"../../compile":16,"../../compile/codegen":13,"../../compile/names":17,"../../compile/ref_error":18,"../../compile/util":21,"../code":53}],57:[function(require,module,exports){ "use strict"; var _templateObject, _templateObject2, _templateObject3, _templateObject4; function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } Object.defineProperty(exports, "__esModule", { value: true }); var codegen_1 = require("../../compile/codegen"); var types_1 = require("../discriminator/types"); var compile_1 = require("../../compile"); var util_1 = require("../../compile/util"); var error = { message: function message(_ref) { var _ref$params = _ref.params, discrError = _ref$params.discrError, tagName = _ref$params.tagName; return discrError === types_1.DiscrError.Tag ? "tag \"".concat(tagName, "\" must be string") : "value of tag \"".concat(tagName, "\" must be in oneOf"); }, params: function params(_ref2) { var _ref2$params = _ref2.params, discrError = _ref2$params.discrError, tag = _ref2$params.tag, tagName = _ref2$params.tagName; return (0, codegen_1._)(_templateObject || (_templateObject = _taggedTemplateLiteral(["{error: ", ", tag: ", ", tagValue: ", "}"])), discrError, tagName, tag); } }; var def = { keyword: "discriminator", type: "object", schemaType: "object", error: error, code: function code(cxt) { var gen = cxt.gen, data = cxt.data, schema = cxt.schema, parentSchema = cxt.parentSchema, it = cxt.it; var oneOf = parentSchema.oneOf; if (!it.opts.discriminator) { throw new Error("discriminator: requires discriminator option"); } var tagName = schema.propertyName; if (typeof tagName != "string") throw new Error("discriminator: requires propertyName"); if (schema.mapping) throw new Error("discriminator: mapping is not supported"); if (!oneOf) throw new Error("discriminator: requires oneOf keyword"); var valid = gen["let"]("valid", false); var tag = gen["const"]("tag", (0, codegen_1._)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["", "", ""])), data, (0, codegen_1.getProperty)(tagName))); gen["if"]((0, codegen_1._)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["typeof ", " == \"string\""])), tag), function () { return validateMapping(); }, function () { return cxt.error(false, { discrError: types_1.DiscrError.Tag, tag: tag, tagName: tagName }); }); cxt.ok(valid); function validateMapping() { var mapping = getMapping(); gen["if"](false); for (var tagValue in mapping) { gen.elseIf((0, codegen_1._)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["", " === ", ""])), tag, tagValue)); gen.assign(valid, applyTagSchema(mapping[tagValue])); } gen["else"](); cxt.error(false, { discrError: types_1.DiscrError.Mapping, tag: tag, tagName: tagName }); gen.endIf(); } function applyTagSchema(schemaProp) { var _valid = gen.name("valid"); var schCxt = cxt.subschema({ keyword: "oneOf", schemaProp: schemaProp }, _valid); cxt.mergeEvaluated(schCxt, codegen_1.Name); return _valid; } function getMapping() { var _a; var oneOfMapping = {}; var topRequired = hasRequired(parentSchema); var tagRequired = true; for (var i = 0; i < oneOf.length; i++) { var sch = oneOf[i]; if ((sch === null || sch === void 0 ? void 0 : sch.$ref) && !(0, util_1.schemaHasRulesButRef)(sch, it.self.RULES)) { sch = compile_1.resolveRef.call(it.self, it.schemaEnv.root, it.baseId, sch === null || sch === void 0 ? void 0 : sch.$ref); if (sch instanceof compile_1.SchemaEnv) sch = sch.schema; } var propSch = (_a = sch === null || sch === void 0 ? void 0 : sch.properties) === null || _a === void 0 ? void 0 : _a[tagName]; if (_typeof(propSch) != "object") { throw new Error("discriminator: oneOf subschemas (or referenced schemas) must have \"properties/".concat(tagName, "\"")); } tagRequired = tagRequired && (topRequired || hasRequired(sch)); addMappings(propSch, i); } if (!tagRequired) throw new Error("discriminator: \"".concat(tagName, "\" must be required")); return oneOfMapping; function hasRequired(_ref3) { var required = _ref3.required; return Array.isArray(required) && required.includes(tagName); } function addMappings(sch, i) { if (sch["const"]) { addMapping(sch["const"], i); } else if (sch["enum"]) { var _iterator = _createForOfIteratorHelper(sch["enum"]), _step; try { for (_iterator.s(); !(_step = _iterator.n()).done;) { var tagValue = _step.value; addMapping(tagValue, i); } } catch (err) { _iterator.e(err); } finally { _iterator.f(); } } else { throw new Error("discriminator: \"properties/".concat(tagName, "\" must have \"const\" or \"enum\"")); } } function addMapping(tagValue, i) { if (typeof tagValue != "string" || tagValue in oneOfMapping) { throw new Error("discriminator: \"".concat(tagName, "\" values must be unique strings")); } oneOfMapping[tagValue] = i; } } } }; exports["default"] = def; },{"../../compile":16,"../../compile/codegen":13,"../../compile/util":21,"../discriminator/types":58}],58:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DiscrError = void 0; var DiscrError; (function (DiscrError) { DiscrError["Tag"] = "tag"; DiscrError["Mapping"] = "mapping"; })(DiscrError = exports.DiscrError || (exports.DiscrError = {})); },{}],59:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var core_1 = require("./core"); var validation_1 = require("./validation"); var applicator_1 = require("./applicator"); var format_1 = require("./format"); var metadata_1 = require("./metadata"); var draft7Vocabularies = [core_1["default"], validation_1["default"], (0, applicator_1["default"])(), format_1["default"], metadata_1.metadataVocabulary, metadata_1.contentVocabulary]; exports["default"] = draft7Vocabularies; },{"./applicator":43,"./core":55,"./format":61,"./metadata":62,"./validation":65}],60:[function(require,module,exports){ "use strict"; var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17; function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } } function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } Object.defineProperty(exports, "__esModule", { value: true }); var codegen_1 = require("../../compile/codegen"); var error = { message: function message(_ref) { var schemaCode = _ref.schemaCode; return (0, codegen_1.str)(_templateObject || (_templateObject = _taggedTemplateLiteral(["must match format \"", "\""])), schemaCode); }, params: function params(_ref2) { var schemaCode = _ref2.schemaCode; return (0, codegen_1._)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["{format: ", "}"])), schemaCode); } }; var def = { keyword: "format", type: ["number", "string"], schemaType: "string", $data: true, error: error, code: function code(cxt, ruleType) { var gen = cxt.gen, data = cxt.data, $data = cxt.$data, schema = cxt.schema, schemaCode = cxt.schemaCode, it = cxt.it; var opts = it.opts, errSchemaPath = it.errSchemaPath, schemaEnv = it.schemaEnv, self = it.self; if (!opts.validateFormats) return; if ($data) validate$DataFormat();else validateFormat(); function validate$DataFormat() { var fmts = gen.scopeValue("formats", { ref: self.formats, code: opts.code.formats }); var fDef = gen["const"]("fDef", (0, codegen_1._)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["", "[", "]"])), fmts, schemaCode)); var fType = gen["let"]("fType"); var format = gen["let"]("format"); // TODO simplify gen["if"]((0, codegen_1._)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["typeof ", " == \"object\" && !(", " instanceof RegExp)"])), fDef, fDef), function () { return gen.assign(fType, (0, codegen_1._)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["", ".type || \"string\""])), fDef)).assign(format, (0, codegen_1._)(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["", ".validate"])), fDef)); }, function () { return gen.assign(fType, (0, codegen_1._)(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\"string\""])))).assign(format, fDef); }); cxt.fail$data((0, codegen_1.or)(unknownFmt(), invalidFmt())); function unknownFmt() { if (opts.strictSchema === false) return codegen_1.nil; return (0, codegen_1._)(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["", " && !", ""])), schemaCode, format); } function invalidFmt() { var callFormat = schemaEnv.$async ? (0, codegen_1._)(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["(", ".async ? await ", "(", ") : ", "(", "))"])), fDef, format, data, format, data) : (0, codegen_1._)(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["", "(", ")"])), format, data); var validData = (0, codegen_1._)(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["(typeof ", " == \"function\" ? ", " : ", ".test(", "))"])), format, callFormat, format, data); return (0, codegen_1._)(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["", " && ", " !== true && ", " === ", " && !", ""])), format, format, fType, ruleType, validData); } } function validateFormat() { var formatDef = self.formats[schema]; if (!formatDef) { unknownFormat(); return; } if (formatDef === true) return; var _getFormat = getFormat(formatDef), _getFormat2 = _slicedToArray(_getFormat, 3), fmtType = _getFormat2[0], format = _getFormat2[1], fmtRef = _getFormat2[2]; if (fmtType === ruleType) cxt.pass(validCondition()); function unknownFormat() { if (opts.strictSchema === false) { self.logger.warn(unknownMsg()); return; } throw new Error(unknownMsg()); function unknownMsg() { return "unknown format \"".concat(schema, "\" ignored in schema at path \"").concat(errSchemaPath, "\""); } } function getFormat(fmtDef) { var code = fmtDef instanceof RegExp ? (0, codegen_1.regexpCode)(fmtDef) : opts.code.formats ? (0, codegen_1._)(_templateObject13 || (_templateObject13 = _taggedTemplateLiteral(["", "", ""])), opts.code.formats, (0, codegen_1.getProperty)(schema)) : undefined; var fmt = gen.scopeValue("formats", { key: schema, ref: fmtDef, code: code }); if (_typeof(fmtDef) == "object" && !(fmtDef instanceof RegExp)) { return [fmtDef.type || "string", fmtDef.validate, (0, codegen_1._)(_templateObject14 || (_templateObject14 = _taggedTemplateLiteral(["", ".validate"])), fmt)]; } return ["string", fmtDef, fmt]; } function validCondition() { if (_typeof(formatDef) == "object" && !(formatDef instanceof RegExp) && formatDef.async) { if (!schemaEnv.$async) throw new Error("async format in sync schema"); return (0, codegen_1._)(_templateObject15 || (_templateObject15 = _taggedTemplateLiteral(["await ", "(", ")"])), fmtRef, data); } return typeof format == "function" ? (0, codegen_1._)(_templateObject16 || (_templateObject16 = _taggedTemplateLiteral(["", "(", ")"])), fmtRef, data) : (0, codegen_1._)(_templateObject17 || (_templateObject17 = _taggedTemplateLiteral(["", ".test(", ")"])), fmtRef, data); } } } }; exports["default"] = def; },{"../../compile/codegen":13}],61:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var format_1 = require("./format"); var format = [format_1["default"]]; exports["default"] = format; },{"./format":60}],62:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.contentVocabulary = exports.metadataVocabulary = void 0; exports.metadataVocabulary = ["title", "description", "default", "deprecated", "readOnly", "writeOnly", "examples"]; exports.contentVocabulary = ["contentMediaType", "contentEncoding", "contentSchema"]; },{}],63:[function(require,module,exports){ "use strict"; var _templateObject, _templateObject2, _templateObject3; function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } Object.defineProperty(exports, "__esModule", { value: true }); var codegen_1 = require("../../compile/codegen"); var util_1 = require("../../compile/util"); var equal_1 = require("../../runtime/equal"); var error = { message: "must be equal to constant", params: function params(_ref) { var schemaCode = _ref.schemaCode; return (0, codegen_1._)(_templateObject || (_templateObject = _taggedTemplateLiteral(["{allowedValue: ", "}"])), schemaCode); } }; var def = { keyword: "const", $data: true, error: error, code: function code(cxt) { var gen = cxt.gen, data = cxt.data, $data = cxt.$data, schemaCode = cxt.schemaCode, schema = cxt.schema; if ($data || schema && _typeof(schema) == "object") { cxt.fail$data((0, codegen_1._)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["!", "(", ", ", ")"])), (0, util_1.useFunc)(gen, equal_1["default"]), data, schemaCode)); } else { cxt.fail((0, codegen_1._)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["", " !== ", ""])), schema, data)); } } }; exports["default"] = def; },{"../../compile/codegen":13,"../../compile/util":21,"../../runtime/equal":32}],64:[function(require,module,exports){ "use strict"; var _templateObject, _templateObject2, _templateObject3, _templateObject4; function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } Object.defineProperty(exports, "__esModule", { value: true }); var codegen_1 = require("../../compile/codegen"); var util_1 = require("../../compile/util"); var equal_1 = require("../../runtime/equal"); var error = { message: "must be equal to one of the allowed values", params: function params(_ref) { var schemaCode = _ref.schemaCode; return (0, codegen_1._)(_templateObject || (_templateObject = _taggedTemplateLiteral(["{allowedValues: ", "}"])), schemaCode); } }; var def = { keyword: "enum", schemaType: "array", $data: true, error: error, code: function code(cxt) { var gen = cxt.gen, data = cxt.data, $data = cxt.$data, schema = cxt.schema, schemaCode = cxt.schemaCode, it = cxt.it; if (!$data && schema.length === 0) throw new Error("enum must have non-empty array"); var useLoop = schema.length >= it.opts.loopEnum; var eql; var getEql = function getEql() { return eql !== null && eql !== void 0 ? eql : eql = (0, util_1.useFunc)(gen, equal_1["default"]); }; var valid; if (useLoop || $data) { valid = gen["let"]("valid"); cxt.block$data(valid, loopEnum); } else { /* istanbul ignore if */ if (!Array.isArray(schema)) throw new Error("ajv implementation error"); var vSchema = gen["const"]("vSchema", schemaCode); valid = (0, codegen_1.or).apply(void 0, _toConsumableArray(schema.map(function (_x, i) { return equalCode(vSchema, i); }))); } cxt.pass(valid); function loopEnum() { gen.assign(valid, false); gen.forOf("v", schemaCode, function (v) { return gen["if"]((0, codegen_1._)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["", "(", ", ", ")"])), getEql(), data, v), function () { return gen.assign(valid, true)["break"](); }); }); } function equalCode(vSchema, i) { var sch = schema[i]; return _typeof(sch) === "object" && sch !== null ? (0, codegen_1._)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["", "(", ", ", "[", "])"])), getEql(), data, vSchema, i) : (0, codegen_1._)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["", " === ", ""])), data, sch); } } }; exports["default"] = def; },{"../../compile/codegen":13,"../../compile/util":21,"../../runtime/equal":32}],65:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var limitNumber_1 = require("./limitNumber"); var multipleOf_1 = require("./multipleOf"); var limitLength_1 = require("./limitLength"); var pattern_1 = require("./pattern"); var limitProperties_1 = require("./limitProperties"); var required_1 = require("./required"); var limitItems_1 = require("./limitItems"); var uniqueItems_1 = require("./uniqueItems"); var const_1 = require("./const"); var enum_1 = require("./enum"); var validation = [ // number limitNumber_1["default"], multipleOf_1["default"], // string limitLength_1["default"], pattern_1["default"], // object limitProperties_1["default"], required_1["default"], // array limitItems_1["default"], uniqueItems_1["default"], // any { keyword: "type", schemaType: ["string", "array"] }, { keyword: "nullable", schemaType: "boolean" }, const_1["default"], enum_1["default"]]; exports["default"] = validation; },{"./const":63,"./enum":64,"./limitItems":66,"./limitLength":67,"./limitNumber":68,"./limitProperties":69,"./multipleOf":70,"./pattern":71,"./required":72,"./uniqueItems":73}],66:[function(require,module,exports){ "use strict"; var _templateObject, _templateObject2, _templateObject3; function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } Object.defineProperty(exports, "__esModule", { value: true }); var codegen_1 = require("../../compile/codegen"); var error = { message: function message(_ref) { var keyword = _ref.keyword, schemaCode = _ref.schemaCode; var comp = keyword === "maxItems" ? "more" : "fewer"; return (0, codegen_1.str)(_templateObject || (_templateObject = _taggedTemplateLiteral(["must NOT have ", " than ", " items"])), comp, schemaCode); }, params: function params(_ref2) { var schemaCode = _ref2.schemaCode; return (0, codegen_1._)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["{limit: ", "}"])), schemaCode); } }; var def = { keyword: ["maxItems", "minItems"], type: "array", schemaType: "number", $data: true, error: error, code: function code(cxt) { var keyword = cxt.keyword, data = cxt.data, schemaCode = cxt.schemaCode; var op = keyword === "maxItems" ? codegen_1.operators.GT : codegen_1.operators.LT; cxt.fail$data((0, codegen_1._)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["", ".length ", " ", ""])), data, op, schemaCode)); } }; exports["default"] = def; },{"../../compile/codegen":13}],67:[function(require,module,exports){ "use strict"; var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5; function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } Object.defineProperty(exports, "__esModule", { value: true }); var codegen_1 = require("../../compile/codegen"); var util_1 = require("../../compile/util"); var ucs2length_1 = require("../../runtime/ucs2length"); var error = { message: function message(_ref) { var keyword = _ref.keyword, schemaCode = _ref.schemaCode; var comp = keyword === "maxLength" ? "more" : "fewer"; return (0, codegen_1.str)(_templateObject || (_templateObject = _taggedTemplateLiteral(["must NOT have ", " than ", " characters"])), comp, schemaCode); }, params: function params(_ref2) { var schemaCode = _ref2.schemaCode; return (0, codegen_1._)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["{limit: ", "}"])), schemaCode); } }; var def = { keyword: ["maxLength", "minLength"], type: "string", schemaType: "number", $data: true, error: error, code: function code(cxt) { var keyword = cxt.keyword, data = cxt.data, schemaCode = cxt.schemaCode, it = cxt.it; var op = keyword === "maxLength" ? codegen_1.operators.GT : codegen_1.operators.LT; var len = it.opts.unicode === false ? (0, codegen_1._)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["", ".length"])), data) : (0, codegen_1._)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["", "(", ")"])), (0, util_1.useFunc)(cxt.gen, ucs2length_1["default"]), data); cxt.fail$data((0, codegen_1._)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["", " ", " ", ""])), len, op, schemaCode)); } }; exports["default"] = def; },{"../../compile/codegen":13,"../../compile/util":21,"../../runtime/ucs2length":33}],68:[function(require,module,exports){ "use strict"; var _templateObject, _templateObject2, _templateObject3; function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } Object.defineProperty(exports, "__esModule", { value: true }); var codegen_1 = require("../../compile/codegen"); var ops = codegen_1.operators; var KWDs = { maximum: { okStr: "<=", ok: ops.LTE, fail: ops.GT }, minimum: { okStr: ">=", ok: ops.GTE, fail: ops.LT }, exclusiveMaximum: { okStr: "<", ok: ops.LT, fail: ops.GTE }, exclusiveMinimum: { okStr: ">", ok: ops.GT, fail: ops.LTE } }; var error = { message: function message(_ref) { var keyword = _ref.keyword, schemaCode = _ref.schemaCode; return (0, codegen_1.str)(_templateObject || (_templateObject = _taggedTemplateLiteral(["must be ", " ", ""])), KWDs[keyword].okStr, schemaCode); }, params: function params(_ref2) { var keyword = _ref2.keyword, schemaCode = _ref2.schemaCode; return (0, codegen_1._)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["{comparison: ", ", limit: ", "}"])), KWDs[keyword].okStr, schemaCode); } }; var def = { keyword: Object.keys(KWDs), type: "number", schemaType: "number", $data: true, error: error, code: function code(cxt) { var keyword = cxt.keyword, data = cxt.data, schemaCode = cxt.schemaCode; cxt.fail$data((0, codegen_1._)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["", " ", " ", " || isNaN(", ")"])), data, KWDs[keyword].fail, schemaCode, data)); } }; exports["default"] = def; },{"../../compile/codegen":13}],69:[function(require,module,exports){ "use strict"; var _templateObject, _templateObject2, _templateObject3; function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } Object.defineProperty(exports, "__esModule", { value: true }); var codegen_1 = require("../../compile/codegen"); var error = { message: function message(_ref) { var keyword = _ref.keyword, schemaCode = _ref.schemaCode; var comp = keyword === "maxProperties" ? "more" : "fewer"; return (0, codegen_1.str)(_templateObject || (_templateObject = _taggedTemplateLiteral(["must NOT have ", " than ", " properties"])), comp, schemaCode); }, params: function params(_ref2) { var schemaCode = _ref2.schemaCode; return (0, codegen_1._)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["{limit: ", "}"])), schemaCode); } }; var def = { keyword: ["maxProperties", "minProperties"], type: "object", schemaType: "number", $data: true, error: error, code: function code(cxt) { var keyword = cxt.keyword, data = cxt.data, schemaCode = cxt.schemaCode; var op = keyword === "maxProperties" ? codegen_1.operators.GT : codegen_1.operators.LT; cxt.fail$data((0, codegen_1._)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["Object.keys(", ").length ", " ", ""])), data, op, schemaCode)); } }; exports["default"] = def; },{"../../compile/codegen":13}],70:[function(require,module,exports){ "use strict"; var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5; function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } Object.defineProperty(exports, "__esModule", { value: true }); var codegen_1 = require("../../compile/codegen"); var error = { message: function message(_ref) { var schemaCode = _ref.schemaCode; return (0, codegen_1.str)(_templateObject || (_templateObject = _taggedTemplateLiteral(["must be multiple of ", ""])), schemaCode); }, params: function params(_ref2) { var schemaCode = _ref2.schemaCode; return (0, codegen_1._)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["{multipleOf: ", "}"])), schemaCode); } }; var def = { keyword: "multipleOf", type: "number", schemaType: "number", $data: true, error: error, code: function code(cxt) { var gen = cxt.gen, data = cxt.data, schemaCode = cxt.schemaCode, it = cxt.it; // const bdt = bad$DataType(schemaCode, def.schemaType, $data) var prec = it.opts.multipleOfPrecision; var res = gen["let"]("res"); var invalid = prec ? (0, codegen_1._)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["Math.abs(Math.round(", ") - ", ") > 1e-", ""])), res, res, prec) : (0, codegen_1._)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["", " !== parseInt(", ")"])), res, res); cxt.fail$data((0, codegen_1._)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["(", " === 0 || (", " = ", "/", ", ", "))"])), schemaCode, res, data, schemaCode, invalid)); } }; exports["default"] = def; },{"../../compile/codegen":13}],71:[function(require,module,exports){ "use strict"; var _templateObject, _templateObject2, _templateObject3, _templateObject4; function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } Object.defineProperty(exports, "__esModule", { value: true }); var code_1 = require("../code"); var codegen_1 = require("../../compile/codegen"); var error = { message: function message(_ref) { var schemaCode = _ref.schemaCode; return (0, codegen_1.str)(_templateObject || (_templateObject = _taggedTemplateLiteral(["must match pattern \"", "\""])), schemaCode); }, params: function params(_ref2) { var schemaCode = _ref2.schemaCode; return (0, codegen_1._)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["{pattern: ", "}"])), schemaCode); } }; var def = { keyword: "pattern", type: "string", schemaType: "string", $data: true, error: error, code: function code(cxt) { var data = cxt.data, $data = cxt.$data, schema = cxt.schema, schemaCode = cxt.schemaCode, it = cxt.it; // TODO regexp should be wrapped in try/catchs var u = it.opts.unicodeRegExp ? "u" : ""; var regExp = $data ? (0, codegen_1._)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["(new RegExp(", ", ", "))"])), schemaCode, u) : (0, code_1.usePattern)(cxt, schema); cxt.fail$data((0, codegen_1._)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["!", ".test(", ")"])), regExp, data)); } }; exports["default"] = def; },{"../../compile/codegen":13,"../code":53}],72:[function(require,module,exports){ "use strict"; var _templateObject, _templateObject2; function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } Object.defineProperty(exports, "__esModule", { value: true }); var code_1 = require("../code"); var codegen_1 = require("../../compile/codegen"); var util_1 = require("../../compile/util"); var error = { message: function message(_ref) { var missingProperty = _ref.params.missingProperty; return (0, codegen_1.str)(_templateObject || (_templateObject = _taggedTemplateLiteral(["must have required property '", "'"])), missingProperty); }, params: function params(_ref2) { var missingProperty = _ref2.params.missingProperty; return (0, codegen_1._)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["{missingProperty: ", "}"])), missingProperty); } }; var def = { keyword: "required", type: "object", schemaType: "array", $data: true, error: error, code: function code(cxt) { var gen = cxt.gen, schema = cxt.schema, schemaCode = cxt.schemaCode, data = cxt.data, $data = cxt.$data, it = cxt.it; var opts = it.opts; if (!$data && schema.length === 0) return; var useLoop = schema.length >= opts.loopRequired; if (it.allErrors) allErrorsMode();else exitOnErrorMode(); if (opts.strictRequired) { var props = cxt.parentSchema.properties; var definedProperties = cxt.it.definedProperties; var _iterator = _createForOfIteratorHelper(schema), _step; try { for (_iterator.s(); !(_step = _iterator.n()).done;) { var requiredKey = _step.value; if ((props === null || props === void 0 ? void 0 : props[requiredKey]) === undefined && !definedProperties.has(requiredKey)) { var schemaPath = it.schemaEnv.baseId + it.errSchemaPath; var msg = "required property \"".concat(requiredKey, "\" is not defined at \"").concat(schemaPath, "\" (strictRequired)"); (0, util_1.checkStrictMode)(it, msg, it.opts.strictRequired); } } } catch (err) { _iterator.e(err); } finally { _iterator.f(); } } function allErrorsMode() { if (useLoop || $data) { cxt.block$data(codegen_1.nil, loopAllRequired); } else { var _iterator2 = _createForOfIteratorHelper(schema), _step2; try { for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { var prop = _step2.value; (0, code_1.checkReportMissingProp)(cxt, prop); } } catch (err) { _iterator2.e(err); } finally { _iterator2.f(); } } } function exitOnErrorMode() { var missing = gen["let"]("missing"); if (useLoop || $data) { var valid = gen["let"]("valid", true); cxt.block$data(valid, function () { return loopUntilMissing(missing, valid); }); cxt.ok(valid); } else { gen["if"]((0, code_1.checkMissingProp)(cxt, schema, missing)); (0, code_1.reportMissingProp)(cxt, missing); gen["else"](); } } function loopAllRequired() { gen.forOf("prop", schemaCode, function (prop) { cxt.setParams({ missingProperty: prop }); gen["if"]((0, code_1.noPropertyInData)(gen, data, prop, opts.ownProperties), function () { return cxt.error(); }); }); } function loopUntilMissing(missing, valid) { cxt.setParams({ missingProperty: missing }); gen.forOf(missing, schemaCode, function () { gen.assign(valid, (0, code_1.propertyInData)(gen, data, missing, opts.ownProperties)); gen["if"]((0, codegen_1.not)(valid), function () { cxt.error(); gen["break"](); }); }, codegen_1.nil); } } }; exports["default"] = def; },{"../../compile/codegen":13,"../../compile/util":21,"../code":53}],73:[function(require,module,exports){ "use strict"; var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17; function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } Object.defineProperty(exports, "__esModule", { value: true }); var dataType_1 = require("../../compile/validate/dataType"); var codegen_1 = require("../../compile/codegen"); var util_1 = require("../../compile/util"); var equal_1 = require("../../runtime/equal"); var error = { message: function message(_ref) { var _ref$params = _ref.params, i = _ref$params.i, j = _ref$params.j; return (0, codegen_1.str)(_templateObject || (_templateObject = _taggedTemplateLiteral(["must NOT have duplicate items (items ## ", " and ", " are identical)"])), j, i); }, params: function params(_ref2) { var _ref2$params = _ref2.params, i = _ref2$params.i, j = _ref2$params.j; return (0, codegen_1._)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["{i: ", ", j: ", "}"])), i, j); } }; var def = { keyword: "uniqueItems", type: "array", schemaType: "boolean", $data: true, error: error, code: function code(cxt) { var gen = cxt.gen, data = cxt.data, $data = cxt.$data, schema = cxt.schema, parentSchema = cxt.parentSchema, schemaCode = cxt.schemaCode, it = cxt.it; if (!$data && !schema) return; var valid = gen["let"]("valid"); var itemTypes = parentSchema.items ? (0, dataType_1.getSchemaTypes)(parentSchema.items) : []; cxt.block$data(valid, validateUniqueItems, (0, codegen_1._)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["", " === false"])), schemaCode)); cxt.ok(valid); function validateUniqueItems() { var i = gen["let"]("i", (0, codegen_1._)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["", ".length"])), data)); var j = gen["let"]("j"); cxt.setParams({ i: i, j: j }); gen.assign(valid, true); gen["if"]((0, codegen_1._)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["", " > 1"])), i), function () { return (canOptimize() ? loopN : loopN2)(i, j); }); } function canOptimize() { return itemTypes.length > 0 && !itemTypes.some(function (t) { return t === "object" || t === "array"; }); } function loopN(i, j) { var item = gen.name("item"); var wrongType = (0, dataType_1.checkDataTypes)(itemTypes, item, it.opts.strictNumbers, dataType_1.DataType.Wrong); var indices = gen["const"]("indices", (0, codegen_1._)(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["{}"])))); gen["for"]((0, codegen_1._)(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral([";", "--;"])), i), function () { gen["let"](item, (0, codegen_1._)(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["", "[", "]"])), data, i)); gen["if"](wrongType, (0, codegen_1._)(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["continue"])))); if (itemTypes.length > 1) gen["if"]((0, codegen_1._)(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["typeof ", " == \"string\""])), item), (0, codegen_1._)(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["", " += \"_\""])), item)); gen["if"]((0, codegen_1._)(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["typeof ", "[", "] == \"number\""])), indices, item), function () { gen.assign(j, (0, codegen_1._)(_templateObject13 || (_templateObject13 = _taggedTemplateLiteral(["", "[", "]"])), indices, item)); cxt.error(); gen.assign(valid, false)["break"](); }).code((0, codegen_1._)(_templateObject14 || (_templateObject14 = _taggedTemplateLiteral(["", "[", "] = ", ""])), indices, item, i)); }); } function loopN2(i, j) { var eql = (0, util_1.useFunc)(gen, equal_1["default"]); var outer = gen.name("outer"); gen.label(outer)["for"]((0, codegen_1._)(_templateObject15 || (_templateObject15 = _taggedTemplateLiteral([";", "--;"])), i), function () { return gen["for"]((0, codegen_1._)(_templateObject16 || (_templateObject16 = _taggedTemplateLiteral(["", " = ", "; ", "--;"])), j, i, j), function () { return gen["if"]((0, codegen_1._)(_templateObject17 || (_templateObject17 = _taggedTemplateLiteral(["", "(", "[", "], ", "[", "])"])), eql, data, i, data, j), function () { cxt.error(); gen.assign(valid, false)["break"](outer); }); }); }); } } }; exports["default"] = def; },{"../../compile/codegen":13,"../../compile/util":21,"../../compile/validate/dataType":24,"../../runtime/equal":32}],74:[function(require,module,exports){ /*! * content-type * Copyright(c) 2015 Douglas Christopher Wilson * MIT Licensed */ 'use strict'; /** * RegExp to match *( ";" parameter ) in RFC 7231 sec 3.1.1.1 * * parameter = token "=" ( token / quoted-string ) * token = 1*tchar * tchar = "!" / "#" / "$" / "%" / "&" / "'" / "*" * / "+" / "-" / "." / "^" / "_" / "`" / "|" / "~" * / DIGIT / ALPHA * ; any VCHAR, except delimiters * quoted-string = DQUOTE *( qdtext / quoted-pair ) DQUOTE * qdtext = HTAB / SP / %x21 / %x23-5B / %x5D-7E / obs-text * obs-text = %x80-FF * quoted-pair = "\" ( HTAB / SP / VCHAR / obs-text ) */ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } var PARAM_REGEXP = /; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g; // eslint-disable-line no-control-regex var TEXT_REGEXP = /^[\u000b\u0020-\u007e\u0080-\u00ff]+$/; // eslint-disable-line no-control-regex var TOKEN_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/; /** * RegExp to match quoted-pair in RFC 7230 sec 3.2.6 * * quoted-pair = "\" ( HTAB / SP / VCHAR / obs-text ) * obs-text = %x80-FF */ var QESC_REGEXP = /\\([\u000b\u0020-\u00ff])/g; // eslint-disable-line no-control-regex /** * RegExp to match chars that must be quoted-pair in RFC 7230 sec 3.2.6 */ var QUOTE_REGEXP = /([\\"])/g; /** * RegExp to match type in RFC 7231 sec 3.1.1.1 * * media-type = type "/" subtype * type = token * subtype = token */ var TYPE_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/; /** * Module exports. * @public */ exports.format = format; exports.parse = parse; /** * Format object to media type. * * @param {object} obj * @return {string} * @public */ function format(obj) { if (!obj || _typeof(obj) !== 'object') { throw new TypeError('argument obj is required'); } var parameters = obj.parameters; var type = obj.type; if (!type || !TYPE_REGEXP.test(type)) { throw new TypeError('invalid type'); } var string = type; // append parameters if (parameters && _typeof(parameters) === 'object') { var param; var params = Object.keys(parameters).sort(); for (var i = 0; i < params.length; i++) { param = params[i]; if (!TOKEN_REGEXP.test(param)) { throw new TypeError('invalid parameter name'); } string += '; ' + param + '=' + qstring(parameters[param]); } } return string; } /** * Parse media type to object. * * @param {string|object} string * @return {Object} * @public */ function parse(string) { if (!string) { throw new TypeError('argument string is required'); } // support req/res-like objects as argument var header = _typeof(string) === 'object' ? getcontenttype(string) : string; if (typeof header !== 'string') { throw new TypeError('argument string is required to be a string'); } var index = header.indexOf(';'); var type = index !== -1 ? header.slice(0, index).trim() : header.trim(); if (!TYPE_REGEXP.test(type)) { throw new TypeError('invalid media type'); } var obj = new ContentType(type.toLowerCase()); // parse parameters if (index !== -1) { var key; var match; var value; PARAM_REGEXP.lastIndex = index; while (match = PARAM_REGEXP.exec(header)) { if (match.index !== index) { throw new TypeError('invalid parameter format'); } index += match[0].length; key = match[1].toLowerCase(); value = match[2]; if (value.charCodeAt(0) === 0x22 /* " */) { // remove quotes value = value.slice(1, -1); // remove escapes if (value.indexOf('\\') !== -1) { value = value.replace(QESC_REGEXP, '$1'); } } obj.parameters[key] = value; } if (index !== header.length) { throw new TypeError('invalid parameter format'); } } return obj; } /** * Get content-type from req/res objects. * * @param {object} * @return {Object} * @private */ function getcontenttype(obj) { var header; if (typeof obj.getHeader === 'function') { // res-like header = obj.getHeader('content-type'); } else if (_typeof(obj.headers) === 'object') { // req-like header = obj.headers && obj.headers['content-type']; } if (typeof header !== 'string') { throw new TypeError('content-type header is missing from object'); } return header; } /** * Quote a string if necessary. * * @param {string} val * @return {string} * @private */ function qstring(val) { var str = String(val); // no need to quote tokens if (TOKEN_REGEXP.test(str)) { return str; } if (str.length > 0 && !TEXT_REGEXP.test(str)) { throw new TypeError('invalid parameter value'); } return '"' + str.replace(QUOTE_REGEXP, '\\$1') + '"'; } /** * Class to represent a content type. * @private */ function ContentType(type) { this.parameters = Object.create(null); this.type = type; } },{}],75:[function(require,module,exports){ 'use strict'; // do not edit .js files directly - edit src/index.jst function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } module.exports = function equal(a, b) { if (a === b) return true; if (a && b && _typeof(a) == 'object' && _typeof(b) == 'object') { if (a.constructor !== b.constructor) return false; var length, i, keys; if (Array.isArray(a)) { length = a.length; if (length != b.length) return false; for (i = length; i-- !== 0;) if (!equal(a[i], b[i])) return false; return true; } if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags; if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf(); if (a.toString !== Object.prototype.toString) return a.toString() === b.toString(); keys = Object.keys(a); length = keys.length; if (length !== Object.keys(b).length) return false; for (i = length; i-- !== 0;) if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false; for (i = length; i-- !== 0;) { var key = keys[i]; if (!equal(a[key], b[key])) return false; } return true; } // true if both NaN, false otherwise return a !== a && b !== b; }; },{}],76:[function(require,module,exports){ "use strict"; function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } function Coords() {} Coords.prototype.init = function () { if (!arguments.length) { throw new Error('no arguments'); } else if (arguments[0].lat && arguments[0].lng) { this.lat = arguments[0].lat; this.lon = arguments[0].lng; } else if (typeof arguments[0] === "string") { var strarr = arguments[0].split(","); this.lat = parseFloat(strarr[0].trim()); this.lon = parseFloat(strarr[1].trim()); } else if (Object.prototype.toString.call(arguments[0]) === "[object Array]") { var arr = arguments[0]; if (arguments[1] === true) { this.lat = arr[1]; this.lon = arr[0]; } else { this.lat = arr[0]; this.lon = arr[1]; } } else if (arguments[2] === true) { this.lat = arguments[1]; this.lon = arguments[0]; } else { this.lat = arguments[0]; this.lon = arguments[1]; } this.compute(); }; Coords.prototype.compute = function () { this.north = this.lat > 0; this.east = this.lon > 0; this.latValues = computeFor(this.lat); this.lonValues = computeFor(this.lon); function computeFor(initValue) { var values = {}; values.initValue = initValue; values.degrees = Math.abs(initValue); values.degreesInt = Math.floor(values.degrees); values.degreesFrac = values.degrees - values.degreesInt; values.secondsTotal = 3600 * values.degreesFrac; values.minutes = values.secondsTotal / 60; values.minutesInt = Math.floor(values.minutes); values.seconds = values.secondsTotal - values.minutesInt * 60; return values; } }; var shortFormats = { 'FFf': 'DD MM ss X', 'Ff': 'DD mm X', 'f': 'dd X' }; var units = { degrees: '°', minutes: '′', seconds: '″' }; Coords.prototype.format = function (format, options) { if (_typeof(format) === 'object') { var submittedFormat = format; options = format; format = 'FFf'; } if (typeof format === 'undefined') { format = 'FFf'; } if (typeof options === 'undefined') { options = {}; } if (typeof options === 'string') { var submittedString = options; options = { latLonSeparator: submittedString }; } if (typeof options.latLonSeparator === 'undefined') { options.latLonSeparator = ' '; } if (typeof options.decimalPlaces === 'undefined') { options.decimalPlaces = 5; } else { options.decimalPlaces = parseInt(options.decimalPlaces); } if (Object.keys(shortFormats).indexOf(format) > -1) { format = shortFormats[format]; } var lat = formatFor(this.latValues, this.north ? 'N' : 'S'); var lon = formatFor(this.lonValues, this.east ? 'E' : 'W'); function formatFor(values, X) { var formatted = format; formatted = formatted.replace(/DD/g, values.degreesInt + units.degrees); formatted = formatted.replace(/dd/g, values.degrees.toFixed(options.decimalPlaces) + units.degrees); formatted = formatted.replace(/D/g, values.degreesInt); formatted = formatted.replace(/d/g, values.degrees.toFixed(options.decimalPlaces)); formatted = formatted.replace(/MM/g, values.minutesInt + units.minutes); formatted = formatted.replace(/mm/g, values.minutes.toFixed(options.decimalPlaces) + units.minutes); formatted = formatted.replace(/M/g, values.minutesInt); formatted = formatted.replace(/m/g, values.minutes.toFixed(options.decimalPlaces)); formatted = formatted.replace(/ss/g, values.seconds.toFixed(options.decimalPlaces) + units.seconds); formatted = formatted.replace(/s/g, values.seconds.toFixed(options.decimalPlaces)); formatted = formatted.replace(/-/g, values.initValue < 0 ? '-' : ''); formatted = formatted.replace(/X/g, X); return formatted; } return lat + options.latLonSeparator + lon; }; function formatcoords() { var c = new Coords(); c.init.apply(c, arguments); return c; } module.exports = formatcoords; },{}],77:[function(require,module,exports){ (function (process,global){(function (){ "use strict"; function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } /** * [js-sha256]{@link https://github.com/emn178/js-sha256} * * @version 0.10.1 * @author Chen, Yi-Cyuan [emn178@gmail.com] * @copyright Chen, Yi-Cyuan 2014-2023 * @license MIT */ /*jslint bitwise: true */ (function () { 'use strict'; var ERROR = 'input is invalid type'; var WINDOW = (typeof window === "undefined" ? "undefined" : _typeof(window)) === 'object'; var root = WINDOW ? window : {}; if (root.JS_SHA256_NO_WINDOW) { WINDOW = false; } var WEB_WORKER = !WINDOW && (typeof self === "undefined" ? "undefined" : _typeof(self)) === 'object'; var NODE_JS = !root.JS_SHA256_NO_NODE_JS && (typeof process === "undefined" ? "undefined" : _typeof(process)) === 'object' && process.versions && process.versions.node; if (NODE_JS) { root = global; } else if (WEB_WORKER) { root = self; } var COMMON_JS = !root.JS_SHA256_NO_COMMON_JS && (typeof module === "undefined" ? "undefined" : _typeof(module)) === 'object' && module.exports; var AMD = typeof define === 'function' && define.amd; var ARRAY_BUFFER = !root.JS_SHA256_NO_ARRAY_BUFFER && typeof ArrayBuffer !== 'undefined'; var HEX_CHARS = '0123456789abcdef'.split(''); var EXTRA = [-2147483648, 8388608, 32768, 128]; var SHIFT = [24, 16, 8, 0]; var K = [0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2]; var OUTPUT_TYPES = ['hex', 'array', 'digest', 'arrayBuffer']; var blocks = []; if (root.JS_SHA256_NO_NODE_JS || !Array.isArray) { Array.isArray = function (obj) { return Object.prototype.toString.call(obj) === '[object Array]'; }; } if (ARRAY_BUFFER && (root.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView)) { ArrayBuffer.isView = function (obj) { return _typeof(obj) === 'object' && obj.buffer && obj.buffer.constructor === ArrayBuffer; }; } var createOutputMethod = function createOutputMethod(outputType, is224) { return function (message) { return new Sha256(is224, true).update(message)[outputType](); }; }; var createMethod = function createMethod(is224) { var method = createOutputMethod('hex', is224); if (NODE_JS) { method = nodeWrap(method, is224); } method.create = function () { return new Sha256(is224); }; method.update = function (message) { return method.create().update(message); }; for (var i = 0; i < OUTPUT_TYPES.length; ++i) { var type = OUTPUT_TYPES[i]; method[type] = createOutputMethod(type, is224); } return method; }; var nodeWrap = function nodeWrap(method, is224) { var crypto = require('crypto'); var Buffer = require('buffer').Buffer; var algorithm = is224 ? 'sha224' : 'sha256'; var bufferFrom; if (Buffer.from && !root.JS_SHA256_NO_BUFFER_FROM) { bufferFrom = Buffer.from; } else { bufferFrom = function bufferFrom(message) { return new Buffer(message); }; } var nodeMethod = function nodeMethod(message) { if (typeof message === 'string') { return crypto.createHash(algorithm).update(message, 'utf8').digest('hex'); } else { if (message === null || message === undefined) { throw new Error(ERROR); } else if (message.constructor === ArrayBuffer) { message = new Uint8Array(message); } } if (Array.isArray(message) || ArrayBuffer.isView(message) || message.constructor === Buffer) { return crypto.createHash(algorithm).update(bufferFrom(message)).digest('hex'); } else { return method(message); } }; return nodeMethod; }; var createHmacOutputMethod = function createHmacOutputMethod(outputType, is224) { return function (key, message) { return new HmacSha256(key, is224, true).update(message)[outputType](); }; }; var createHmacMethod = function createHmacMethod(is224) { var method = createHmacOutputMethod('hex', is224); method.create = function (key) { return new HmacSha256(key, is224); }; method.update = function (key, message) { return method.create(key).update(message); }; for (var i = 0; i < OUTPUT_TYPES.length; ++i) { var type = OUTPUT_TYPES[i]; method[type] = createHmacOutputMethod(type, is224); } return method; }; function Sha256(is224, sharedMemory) { if (sharedMemory) { blocks[0] = blocks[16] = blocks[1] = blocks[2] = blocks[3] = blocks[4] = blocks[5] = blocks[6] = blocks[7] = blocks[8] = blocks[9] = blocks[10] = blocks[11] = blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0; this.blocks = blocks; } else { this.blocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; } if (is224) { this.h0 = 0xc1059ed8; this.h1 = 0x367cd507; this.h2 = 0x3070dd17; this.h3 = 0xf70e5939; this.h4 = 0xffc00b31; this.h5 = 0x68581511; this.h6 = 0x64f98fa7; this.h7 = 0xbefa4fa4; } else { // 256 this.h0 = 0x6a09e667; this.h1 = 0xbb67ae85; this.h2 = 0x3c6ef372; this.h3 = 0xa54ff53a; this.h4 = 0x510e527f; this.h5 = 0x9b05688c; this.h6 = 0x1f83d9ab; this.h7 = 0x5be0cd19; } this.block = this.start = this.bytes = this.hBytes = 0; this.finalized = this.hashed = false; this.first = true; this.is224 = is224; } Sha256.prototype.update = function (message) { if (this.finalized) { return; } var notString, type = _typeof(message); if (type !== 'string') { if (type === 'object') { if (message === null) { throw new Error(ERROR); } else if (ARRAY_BUFFER && message.constructor === ArrayBuffer) { message = new Uint8Array(message); } else if (!Array.isArray(message)) { if (!ARRAY_BUFFER || !ArrayBuffer.isView(message)) { throw new Error(ERROR); } } } else { throw new Error(ERROR); } notString = true; } var code, index = 0, i, length = message.length, blocks = this.blocks; while (index < length) { if (this.hashed) { this.hashed = false; blocks[0] = this.block; blocks[16] = blocks[1] = blocks[2] = blocks[3] = blocks[4] = blocks[5] = blocks[6] = blocks[7] = blocks[8] = blocks[9] = blocks[10] = blocks[11] = blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0; } if (notString) { for (i = this.start; index < length && i < 64; ++index) { blocks[i >> 2] |= message[index] << SHIFT[i++ & 3]; } } else { for (i = this.start; index < length && i < 64; ++index) { code = message.charCodeAt(index); if (code < 0x80) { blocks[i >> 2] |= code << SHIFT[i++ & 3]; } else if (code < 0x800) { blocks[i >> 2] |= (0xc0 | code >> 6) << SHIFT[i++ & 3]; blocks[i >> 2] |= (0x80 | code & 0x3f) << SHIFT[i++ & 3]; } else if (code < 0xd800 || code >= 0xe000) { blocks[i >> 2] |= (0xe0 | code >> 12) << SHIFT[i++ & 3]; blocks[i >> 2] |= (0x80 | code >> 6 & 0x3f) << SHIFT[i++ & 3]; blocks[i >> 2] |= (0x80 | code & 0x3f) << SHIFT[i++ & 3]; } else { code = 0x10000 + ((code & 0x3ff) << 10 | message.charCodeAt(++index) & 0x3ff); blocks[i >> 2] |= (0xf0 | code >> 18) << SHIFT[i++ & 3]; blocks[i >> 2] |= (0x80 | code >> 12 & 0x3f) << SHIFT[i++ & 3]; blocks[i >> 2] |= (0x80 | code >> 6 & 0x3f) << SHIFT[i++ & 3]; blocks[i >> 2] |= (0x80 | code & 0x3f) << SHIFT[i++ & 3]; } } } this.lastByteIndex = i; this.bytes += i - this.start; if (i >= 64) { this.block = blocks[16]; this.start = i - 64; this.hash(); this.hashed = true; } else { this.start = i; } } if (this.bytes > 4294967295) { this.hBytes += this.bytes / 4294967296 << 0; this.bytes = this.bytes % 4294967296; } return this; }; Sha256.prototype.finalize = function () { if (this.finalized) { return; } this.finalized = true; var blocks = this.blocks, i = this.lastByteIndex; blocks[16] = this.block; blocks[i >> 2] |= EXTRA[i & 3]; this.block = blocks[16]; if (i >= 56) { if (!this.hashed) { this.hash(); } blocks[0] = this.block; blocks[16] = blocks[1] = blocks[2] = blocks[3] = blocks[4] = blocks[5] = blocks[6] = blocks[7] = blocks[8] = blocks[9] = blocks[10] = blocks[11] = blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0; } blocks[14] = this.hBytes << 3 | this.bytes >>> 29; blocks[15] = this.bytes << 3; this.hash(); }; Sha256.prototype.hash = function () { var a = this.h0, b = this.h1, c = this.h2, d = this.h3, e = this.h4, f = this.h5, g = this.h6, h = this.h7, blocks = this.blocks, j, s0, s1, maj, t1, t2, ch, ab, da, cd, bc; for (j = 16; j < 64; ++j) { // rightrotate t1 = blocks[j - 15]; s0 = (t1 >>> 7 | t1 << 25) ^ (t1 >>> 18 | t1 << 14) ^ t1 >>> 3; t1 = blocks[j - 2]; s1 = (t1 >>> 17 | t1 << 15) ^ (t1 >>> 19 | t1 << 13) ^ t1 >>> 10; blocks[j] = blocks[j - 16] + s0 + blocks[j - 7] + s1 << 0; } bc = b & c; for (j = 0; j < 64; j += 4) { if (this.first) { if (this.is224) { ab = 300032; t1 = blocks[0] - 1413257819; h = t1 - 150054599 << 0; d = t1 + 24177077 << 0; } else { ab = 704751109; t1 = blocks[0] - 210244248; h = t1 - 1521486534 << 0; d = t1 + 143694565 << 0; } this.first = false; } else { s0 = (a >>> 2 | a << 30) ^ (a >>> 13 | a << 19) ^ (a >>> 22 | a << 10); s1 = (e >>> 6 | e << 26) ^ (e >>> 11 | e << 21) ^ (e >>> 25 | e << 7); ab = a & b; maj = ab ^ a & c ^ bc; ch = e & f ^ ~e & g; t1 = h + s1 + ch + K[j] + blocks[j]; t2 = s0 + maj; h = d + t1 << 0; d = t1 + t2 << 0; } s0 = (d >>> 2 | d << 30) ^ (d >>> 13 | d << 19) ^ (d >>> 22 | d << 10); s1 = (h >>> 6 | h << 26) ^ (h >>> 11 | h << 21) ^ (h >>> 25 | h << 7); da = d & a; maj = da ^ d & b ^ ab; ch = h & e ^ ~h & f; t1 = g + s1 + ch + K[j + 1] + blocks[j + 1]; t2 = s0 + maj; g = c + t1 << 0; c = t1 + t2 << 0; s0 = (c >>> 2 | c << 30) ^ (c >>> 13 | c << 19) ^ (c >>> 22 | c << 10); s1 = (g >>> 6 | g << 26) ^ (g >>> 11 | g << 21) ^ (g >>> 25 | g << 7); cd = c & d; maj = cd ^ c & a ^ da; ch = g & h ^ ~g & e; t1 = f + s1 + ch + K[j + 2] + blocks[j + 2]; t2 = s0 + maj; f = b + t1 << 0; b = t1 + t2 << 0; s0 = (b >>> 2 | b << 30) ^ (b >>> 13 | b << 19) ^ (b >>> 22 | b << 10); s1 = (f >>> 6 | f << 26) ^ (f >>> 11 | f << 21) ^ (f >>> 25 | f << 7); bc = b & c; maj = bc ^ b & d ^ cd; ch = f & g ^ ~f & h; t1 = e + s1 + ch + K[j + 3] + blocks[j + 3]; t2 = s0 + maj; e = a + t1 << 0; a = t1 + t2 << 0; this.chromeBugWorkAround = true; } this.h0 = this.h0 + a << 0; this.h1 = this.h1 + b << 0; this.h2 = this.h2 + c << 0; this.h3 = this.h3 + d << 0; this.h4 = this.h4 + e << 0; this.h5 = this.h5 + f << 0; this.h6 = this.h6 + g << 0; this.h7 = this.h7 + h << 0; }; Sha256.prototype.hex = function () { this.finalize(); var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3, h4 = this.h4, h5 = this.h5, h6 = this.h6, h7 = this.h7; var hex = HEX_CHARS[h0 >> 28 & 0x0F] + HEX_CHARS[h0 >> 24 & 0x0F] + HEX_CHARS[h0 >> 20 & 0x0F] + HEX_CHARS[h0 >> 16 & 0x0F] + HEX_CHARS[h0 >> 12 & 0x0F] + HEX_CHARS[h0 >> 8 & 0x0F] + HEX_CHARS[h0 >> 4 & 0x0F] + HEX_CHARS[h0 & 0x0F] + HEX_CHARS[h1 >> 28 & 0x0F] + HEX_CHARS[h1 >> 24 & 0x0F] + HEX_CHARS[h1 >> 20 & 0x0F] + HEX_CHARS[h1 >> 16 & 0x0F] + HEX_CHARS[h1 >> 12 & 0x0F] + HEX_CHARS[h1 >> 8 & 0x0F] + HEX_CHARS[h1 >> 4 & 0x0F] + HEX_CHARS[h1 & 0x0F] + HEX_CHARS[h2 >> 28 & 0x0F] + HEX_CHARS[h2 >> 24 & 0x0F] + HEX_CHARS[h2 >> 20 & 0x0F] + HEX_CHARS[h2 >> 16 & 0x0F] + HEX_CHARS[h2 >> 12 & 0x0F] + HEX_CHARS[h2 >> 8 & 0x0F] + HEX_CHARS[h2 >> 4 & 0x0F] + HEX_CHARS[h2 & 0x0F] + HEX_CHARS[h3 >> 28 & 0x0F] + HEX_CHARS[h3 >> 24 & 0x0F] + HEX_CHARS[h3 >> 20 & 0x0F] + HEX_CHARS[h3 >> 16 & 0x0F] + HEX_CHARS[h3 >> 12 & 0x0F] + HEX_CHARS[h3 >> 8 & 0x0F] + HEX_CHARS[h3 >> 4 & 0x0F] + HEX_CHARS[h3 & 0x0F] + HEX_CHARS[h4 >> 28 & 0x0F] + HEX_CHARS[h4 >> 24 & 0x0F] + HEX_CHARS[h4 >> 20 & 0x0F] + HEX_CHARS[h4 >> 16 & 0x0F] + HEX_CHARS[h4 >> 12 & 0x0F] + HEX_CHARS[h4 >> 8 & 0x0F] + HEX_CHARS[h4 >> 4 & 0x0F] + HEX_CHARS[h4 & 0x0F] + HEX_CHARS[h5 >> 28 & 0x0F] + HEX_CHARS[h5 >> 24 & 0x0F] + HEX_CHARS[h5 >> 20 & 0x0F] + HEX_CHARS[h5 >> 16 & 0x0F] + HEX_CHARS[h5 >> 12 & 0x0F] + HEX_CHARS[h5 >> 8 & 0x0F] + HEX_CHARS[h5 >> 4 & 0x0F] + HEX_CHARS[h5 & 0x0F] + HEX_CHARS[h6 >> 28 & 0x0F] + HEX_CHARS[h6 >> 24 & 0x0F] + HEX_CHARS[h6 >> 20 & 0x0F] + HEX_CHARS[h6 >> 16 & 0x0F] + HEX_CHARS[h6 >> 12 & 0x0F] + HEX_CHARS[h6 >> 8 & 0x0F] + HEX_CHARS[h6 >> 4 & 0x0F] + HEX_CHARS[h6 & 0x0F]; if (!this.is224) { hex += HEX_CHARS[h7 >> 28 & 0x0F] + HEX_CHARS[h7 >> 24 & 0x0F] + HEX_CHARS[h7 >> 20 & 0x0F] + HEX_CHARS[h7 >> 16 & 0x0F] + HEX_CHARS[h7 >> 12 & 0x0F] + HEX_CHARS[h7 >> 8 & 0x0F] + HEX_CHARS[h7 >> 4 & 0x0F] + HEX_CHARS[h7 & 0x0F]; } return hex; }; Sha256.prototype.toString = Sha256.prototype.hex; Sha256.prototype.digest = function () { this.finalize(); var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3, h4 = this.h4, h5 = this.h5, h6 = this.h6, h7 = this.h7; var arr = [h0 >> 24 & 0xFF, h0 >> 16 & 0xFF, h0 >> 8 & 0xFF, h0 & 0xFF, h1 >> 24 & 0xFF, h1 >> 16 & 0xFF, h1 >> 8 & 0xFF, h1 & 0xFF, h2 >> 24 & 0xFF, h2 >> 16 & 0xFF, h2 >> 8 & 0xFF, h2 & 0xFF, h3 >> 24 & 0xFF, h3 >> 16 & 0xFF, h3 >> 8 & 0xFF, h3 & 0xFF, h4 >> 24 & 0xFF, h4 >> 16 & 0xFF, h4 >> 8 & 0xFF, h4 & 0xFF, h5 >> 24 & 0xFF, h5 >> 16 & 0xFF, h5 >> 8 & 0xFF, h5 & 0xFF, h6 >> 24 & 0xFF, h6 >> 16 & 0xFF, h6 >> 8 & 0xFF, h6 & 0xFF]; if (!this.is224) { arr.push(h7 >> 24 & 0xFF, h7 >> 16 & 0xFF, h7 >> 8 & 0xFF, h7 & 0xFF); } return arr; }; Sha256.prototype.array = Sha256.prototype.digest; Sha256.prototype.arrayBuffer = function () { this.finalize(); var buffer = new ArrayBuffer(this.is224 ? 28 : 32); var dataView = new DataView(buffer); dataView.setUint32(0, this.h0); dataView.setUint32(4, this.h1); dataView.setUint32(8, this.h2); dataView.setUint32(12, this.h3); dataView.setUint32(16, this.h4); dataView.setUint32(20, this.h5); dataView.setUint32(24, this.h6); if (!this.is224) { dataView.setUint32(28, this.h7); } return buffer; }; function HmacSha256(key, is224, sharedMemory) { var i, type = _typeof(key); if (type === 'string') { var bytes = [], length = key.length, index = 0, code; for (i = 0; i < length; ++i) { code = key.charCodeAt(i); if (code < 0x80) { bytes[index++] = code; } else if (code < 0x800) { bytes[index++] = 0xc0 | code >> 6; bytes[index++] = 0x80 | code & 0x3f; } else if (code < 0xd800 || code >= 0xe000) { bytes[index++] = 0xe0 | code >> 12; bytes[index++] = 0x80 | code >> 6 & 0x3f; bytes[index++] = 0x80 | code & 0x3f; } else { code = 0x10000 + ((code & 0x3ff) << 10 | key.charCodeAt(++i) & 0x3ff); bytes[index++] = 0xf0 | code >> 18; bytes[index++] = 0x80 | code >> 12 & 0x3f; bytes[index++] = 0x80 | code >> 6 & 0x3f; bytes[index++] = 0x80 | code & 0x3f; } } key = bytes; } else { if (type === 'object') { if (key === null) { throw new Error(ERROR); } else if (ARRAY_BUFFER && key.constructor === ArrayBuffer) { key = new Uint8Array(key); } else if (!Array.isArray(key)) { if (!ARRAY_BUFFER || !ArrayBuffer.isView(key)) { throw new Error(ERROR); } } } else { throw new Error(ERROR); } } if (key.length > 64) { key = new Sha256(is224, true).update(key).array(); } var oKeyPad = [], iKeyPad = []; for (i = 0; i < 64; ++i) { var b = key[i] || 0; oKeyPad[i] = 0x5c ^ b; iKeyPad[i] = 0x36 ^ b; } Sha256.call(this, is224, sharedMemory); this.update(iKeyPad); this.oKeyPad = oKeyPad; this.inner = true; this.sharedMemory = sharedMemory; } HmacSha256.prototype = new Sha256(); HmacSha256.prototype.finalize = function () { Sha256.prototype.finalize.call(this); if (this.inner) { this.inner = false; var innerHash = this.array(); Sha256.call(this, this.is224, this.sharedMemory); this.update(this.oKeyPad); this.update(innerHash); Sha256.prototype.finalize.call(this); } }; var exports = createMethod(); exports.sha256 = exports; exports.sha224 = createMethod(true); exports.sha256.hmac = createHmacMethod(); exports.sha224.hmac = createHmacMethod(true); if (COMMON_JS) { module.exports = exports; } else { root.sha256 = exports.sha256; root.sha224 = exports.sha224; if (AMD) { define(function () { return exports; }); } } })(); }).call(this)}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) },{"_process":6,"buffer":2,"crypto":2}],78:[function(require,module,exports){ 'use strict'; function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } var traverse = module.exports = function (schema, opts, cb) { // Legacy support for v0.3.1 and earlier. if (typeof opts == 'function') { cb = opts; opts = {}; } cb = opts.cb || cb; var pre = typeof cb == 'function' ? cb : cb.pre || function () {}; var post = cb.post || function () {}; _traverse(opts, pre, post, schema, '', schema); }; traverse.keywords = { additionalItems: true, items: true, contains: true, additionalProperties: true, propertyNames: true, not: true, "if": true, then: true, "else": true }; traverse.arrayKeywords = { items: true, allOf: true, anyOf: true, oneOf: true }; traverse.propsKeywords = { $defs: true, definitions: true, properties: true, patternProperties: true, dependencies: true }; traverse.skipKeywords = { "default": true, "enum": true, "const": true, required: true, maximum: true, minimum: true, exclusiveMaximum: true, exclusiveMinimum: true, multipleOf: true, maxLength: true, minLength: true, pattern: true, format: true, maxItems: true, minItems: true, uniqueItems: true, maxProperties: true, minProperties: true }; function _traverse(opts, pre, post, schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex) { if (schema && _typeof(schema) == 'object' && !Array.isArray(schema)) { pre(schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex); for (var key in schema) { var sch = schema[key]; if (Array.isArray(sch)) { if (key in traverse.arrayKeywords) { for (var i = 0; i < sch.length; i++) _traverse(opts, pre, post, sch[i], jsonPtr + '/' + key + '/' + i, rootSchema, jsonPtr, key, schema, i); } } else if (key in traverse.propsKeywords) { if (sch && _typeof(sch) == 'object') { for (var prop in sch) _traverse(opts, pre, post, sch[prop], jsonPtr + '/' + key + '/' + escapeJsonPtr(prop), rootSchema, jsonPtr, key, schema, prop); } } else if (key in traverse.keywords || opts.allKeys && !(key in traverse.skipKeywords)) { _traverse(opts, pre, post, sch, jsonPtr + '/' + key, rootSchema, jsonPtr, key, schema); } } post(schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex); } } function escapeJsonPtr(str) { return str.replace(/~/g, '~0').replace(/\//g, '~1'); } },{}],79:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MiniMap = void 0; var MiniMap = exports.MiniMap = L.Control.MiniMap = L.Control.extend({ includes: L.Evented ? L.Evented.prototype : L.Mixin.Events, options: { position: 'bottomright', toggleDisplay: false, zoomLevelOffset: -5, zoomLevelFixed: false, centerFixed: false, zoomAnimation: false, autoToggleDisplay: false, minimized: false, width: 150, height: 150, collapsedWidth: 19, collapsedHeight: 19, aimingRectOptions: { color: '#ff7800', weight: 1, interactive: false }, shadowRectOptions: { color: '#000000', weight: 1, interactive: false, opacity: 0, fillOpacity: 0 }, hideText: 'Hide MiniMap', showText: 'Show MiniMap', mapOptions: {} // Allows definition / override of Leaflet map options. }, // layer is the map layer to be shown in the minimap initialize: function initialize(layer, options) { L.Util.setOptions(this, options); // Make sure the aiming rects are non-clickable even if the user tries to set them clickable (most likely by forgetting to specify them false) this.options.aimingRectOptions.interactive = false; this.options.shadowRectOptions.interactive = false; this._layer = layer; }, onAdd: function onAdd(map) { this._mainMap = map; // Creating the container and stopping events from spilling through to the main map. this._container = L.DomUtil.create('div', 'leaflet-control-minimap'); this._container.style.width = this.options.width + 'px'; this._container.style.height = this.options.height + 'px'; L.DomEvent.disableClickPropagation(this._container); L.DomEvent.on(this._container, 'mousewheel', L.DomEvent.stopPropagation); var mapOptions = { attributionControl: false, dragging: !this.options.centerFixed, zoomControl: false, zoomAnimation: this.options.zoomAnimation, autoToggleDisplay: this.options.autoToggleDisplay, touchZoom: this.options.centerFixed ? 'center' : !this._isZoomLevelFixed(), scrollWheelZoom: this.options.centerFixed ? 'center' : !this._isZoomLevelFixed(), doubleClickZoom: this.options.centerFixed ? 'center' : !this._isZoomLevelFixed(), boxZoom: !this._isZoomLevelFixed(), crs: map.options.crs }; mapOptions = L.Util.extend(this.options.mapOptions, mapOptions); // merge with priority of the local mapOptions object. this._miniMap = new L.Map(this._container, mapOptions); this._miniMap.addLayer(this._layer); // These bools are used to prevent infinite loops of the two maps notifying each other that they've moved. this._mainMapMoving = false; this._miniMapMoving = false; // Keep a record of this to prevent auto toggling when the user explicitly doesn't want it. this._userToggledDisplay = false; this._minimized = false; if (this.options.toggleDisplay) { this._addToggleButton(); } this._miniMap.whenReady(L.Util.bind(function () { this._aimingRect = L.rectangle(this._mainMap.getBounds(), this.options.aimingRectOptions).addTo(this._miniMap); this._shadowRect = L.rectangle(this._mainMap.getBounds(), this.options.shadowRectOptions).addTo(this._miniMap); this._mainMap.on('move', this._onMainMapMoving, this); this._mainMap.on('moveend', this._onMainMapMoved, this); this._mainMap.on('resize', this._onMainMapResize, this); this._miniMap.on('movestart', this._onMiniMapMoveStarted, this); this._miniMap.on('move', this._onMiniMapMoving, this); this._miniMap.on('moveend', this._onMiniMapMoved, this); }, this)); return this._container; }, addTo: function addTo(map) { L.Control.prototype.addTo.call(this, map); var center = this.options.centerFixed || this._mainMap.getCenter(); this._miniMap.setView(center, this._decideZoom(true)); this._setDisplay(this.options.minimized); return this; }, onRemove: function onRemove(map) { this._mainMap.off('move', this._onMainMapMoving, this); this._mainMap.off('moveend', this._onMainMapMoved, this); this._mainMap.off('resize', this._onMainMapResize, this); this._miniMap.off('movestart', this._onMiniMapMoveStarted, this); this._miniMap.off('move', this._onMiniMapMoving, this); this._miniMap.off('moveend', this._onMiniMapMoved, this); this._miniMap.removeLayer(this._layer); }, changeLayer: function changeLayer(layer) { this._miniMap.removeLayer(this._layer); this._layer = layer; this._miniMap.addLayer(this._layer); }, _addToggleButton: function _addToggleButton() { this._toggleDisplayButton = this.options.toggleDisplay ? this._createButton('', this._toggleButtonInitialTitleText(), 'leaflet-control-minimap-toggle-display leaflet-control-minimap-toggle-display-' + this.options.position, this._container, this._toggleDisplayButtonClicked, this) : undefined; this._toggleDisplayButton.style.width = this.options.collapsedWidth + 'px'; this._toggleDisplayButton.style.height = this.options.collapsedHeight + 'px'; }, _toggleButtonInitialTitleText: function _toggleButtonInitialTitleText() { if (this.options.minimized) { return this.options.showText; } else { return this.options.hideText; } }, _createButton: function _createButton(html, title, className, container, fn, context) { var link = L.DomUtil.create('a', className, container); link.innerHTML = html; link.href = '#'; link.title = title; var stop = L.DomEvent.stopPropagation; L.DomEvent.on(link, 'click', stop).on(link, 'mousedown', stop).on(link, 'dblclick', stop).on(link, 'click', L.DomEvent.preventDefault).on(link, 'click', fn, context); return link; }, _toggleDisplayButtonClicked: function _toggleDisplayButtonClicked() { this._userToggledDisplay = true; if (!this._minimized) { this.minimize(); } else { this.restore(); } }, _setDisplay: function _setDisplay(minimize) { if (minimize !== this._minimized) { if (!this._minimized) { this.minimize(); } else { this.restore(); } } }, minimize: function minimize() { // hide the minimap if (this.options.toggleDisplay) { this._container.style.width = this.options.collapsedWidth + 'px'; this._container.style.height = this.options.collapsedHeight + 'px'; this._toggleDisplayButton.className += ' minimized-' + this.options.position; this._toggleDisplayButton.title = this.options.showText; } else { this._container.style.display = 'none'; } this._minimized = true; this._toggle(); }, restore: function restore() { if (this.options.toggleDisplay) { this._container.style.width = this.options.width + 'px'; this._container.style.height = this.options.height + 'px'; this._toggleDisplayButton.className = this._toggleDisplayButton.className.replace('minimized-' + this.options.position, ''); this._toggleDisplayButton.title = this.options.hideText; } else { this._container.style.display = 'block'; } this._minimized = false; this._toggle(); }, invalidateSize: function invalidateSize() { this._miniMap.invalidateSize(); }, _onMainMapMoved: function _onMainMapMoved(e) { if (!this._miniMapMoving) { var center = this.options.centerFixed || this._mainMap.getCenter(); this._mainMapMoving = true; this._miniMap.setView(center, this._decideZoom(true)); this._setDisplay(this._decideMinimized()); } else { this._miniMapMoving = false; } this._aimingRect.setBounds(this._mainMap.getBounds()); }, _onMainMapMoving: function _onMainMapMoving(e) { this._aimingRect.setBounds(this._mainMap.getBounds()); }, _onMiniMapMoveStarted: function _onMiniMapMoveStarted(e) { if (!this.options.centerFixed) { var lastAimingRect = this._aimingRect.getBounds(); var sw = this._miniMap.latLngToContainerPoint(lastAimingRect.getSouthWest()); var ne = this._miniMap.latLngToContainerPoint(lastAimingRect.getNorthEast()); this._lastAimingRectPosition = { sw: sw, ne: ne }; } }, _onMiniMapMoving: function _onMiniMapMoving(e) { if (!this.options.centerFixed) { if (!this._mainMapMoving && this._lastAimingRectPosition) { this._shadowRect.setBounds(new L.LatLngBounds(this._miniMap.containerPointToLatLng(this._lastAimingRectPosition.sw), this._miniMap.containerPointToLatLng(this._lastAimingRectPosition.ne))); this._shadowRect.setStyle({ opacity: 1, fillOpacity: 0.3 }); } } }, _onMiniMapMoved: function _onMiniMapMoved(e) { if (!this._mainMapMoving) { this._miniMapMoving = true; this._mainMap.setView(this._miniMap.getCenter(), this._decideZoom(false)); this._shadowRect.setStyle({ opacity: 0, fillOpacity: 0 }); } else { this._mainMapMoving = false; } }, _onMainMapResize: function _onMainMapResize(e) { this._miniMap.invalidateSize(); }, _isZoomLevelFixed: function _isZoomLevelFixed() { var zoomLevelFixed = this.options.zoomLevelFixed; return this._isDefined(zoomLevelFixed) && this._isInteger(zoomLevelFixed); }, _decideZoom: function _decideZoom(fromMaintoMini) { if (!this._isZoomLevelFixed()) { if (fromMaintoMini) { return this._mainMap.getZoom() + this.options.zoomLevelOffset; } else { var currentDiff = this._miniMap.getZoom() - this._mainMap.getZoom(); var proposedZoom = this._miniMap.getZoom() - this.options.zoomLevelOffset; var toRet; if (currentDiff > this.options.zoomLevelOffset && this._mainMap.getZoom() < this._miniMap.getMinZoom() - this.options.zoomLevelOffset) { // This means the miniMap is zoomed out to the minimum zoom level and can't zoom any more. if (this._miniMap.getZoom() > this._lastMiniMapZoom) { // This means the user is trying to zoom in by using the minimap, zoom the main map. toRet = this._mainMap.getZoom() + 1; // Also we cheat and zoom the minimap out again to keep it visually consistent. this._miniMap.setZoom(this._miniMap.getZoom() - 1); } else { // Either the user is trying to zoom out past the mini map's min zoom or has just panned using it, we can't tell the difference. // Therefore, we ignore it! toRet = this._mainMap.getZoom(); } } else { // This is what happens in the majority of cases, and always if you configure the min levels + offset in a sane fashion. toRet = proposedZoom; } this._lastMiniMapZoom = this._miniMap.getZoom(); return toRet; } } else { if (fromMaintoMini) { return this.options.zoomLevelFixed; } else { return this._mainMap.getZoom(); } } }, _decideMinimized: function _decideMinimized() { if (this._userToggledDisplay) { return this._minimized; } if (this.options.autoToggleDisplay) { if (this._mainMap.getBounds().contains(this._miniMap.getBounds())) { return true; } return false; } return this._minimized; }, _isInteger: function _isInteger(value) { return typeof value === 'number'; }, _isDefined: function _isDefined(value) { return typeof value !== 'undefined'; }, _toggle: function _toggle() { L.Util.requestAnimFrame(function () { L.DomEvent.on(this._container, 'transitionend', this._fireToggleEvents, this); if (!L.Browser.any3d) { L.Util.requestAnimFrame(this._fireToggleEvents, this); } }, this); }, disableInteractivity: function disableInteractivity() { this._miniMap.dragging.disable(); this._miniMap.scrollWheelZoom.disable(); this._miniMap.doubleClickZoom.disable(); this._miniMap.touchZoom.disable(); }, isMiniMapOpen: function isMiniMapOpen() { return !this._minimized; }, _fireToggleEvents: function _fireToggleEvents() { this.invalidateSize(); L.DomEvent.off(this._container, 'transitionend', this._fireToggleEvents, this); var data = { minimized: this._minimized }; this.fire(this._minimized ? 'minimize' : 'restore', data); this.invalidateSize(); this.fire('toggle', data); } }); L.Map.mergeOptions({ miniMapControl: false }); L.Map.addInitHook(function () { if (this.options.miniMapControl) { this.miniMapControl = new MiniMap().addTo(this); } }); L.control.minimap = function (layer, options) { return new L.Control.MiniMap(layer, options); }; },{}],80:[function(require,module,exports){ "use strict"; function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } !function (a, t) { "object" == (typeof exports === "undefined" ? "undefined" : _typeof(exports)) && "undefined" != typeof module ? t(exports) : "function" == typeof define && define.amd ? define("leafletGestureHandling", ["exports"], t) : t(a.leafletGestureHandling = {}); }(void 0, function (a) { "use strict"; var o = { ar: { touch: "استخدم إصبعين لتحريك الخريطة", scroll: "‏استخدم ctrl + scroll لتصغير/تكبير الخريطة", scrollMac: "يمكنك استخدام ⌘ + التمرير لتكبير/تصغير الخريطة" }, bg: { touch: "Използвайте два пръста, за да преместите картата", scroll: "Задръжте бутона Ctrl натиснат, докато превъртате, за да промените мащаба на картата", scrollMac: "Задръжте бутона ⌘ натиснат, докато превъртате, за да промените мащаба на картата" }, bn: { touch: "মানচিত্রটিকে সরাতে দুটি আঙ্গুল ব্যবহার করুন", scroll: "ম্যাপ জুম করতে ctrl + scroll ব্যবহার করুন", scrollMac: "ম্যাপে জুম করতে ⌘ বোতাম টিপে স্ক্রল করুন" }, ca: { touch: "Fes servir dos dits per moure el mapa", scroll: "Prem la tecla Control mentre et desplaces per apropar i allunyar el mapa", scrollMac: "Prem la tecla ⌘ mentre et desplaces per apropar i allunyar el mapa" }, cs: { touch: "K posunutí mapy použijte dva prsty", scroll: "Velikost zobrazení mapy změňte podržením klávesy Ctrl a posouváním kolečka myši", scrollMac: "Velikost zobrazení mapy změníte podržením klávesy ⌘ a posunutím kolečka myši / touchpadu" }, da: { touch: "Brug to fingre til at flytte kortet", scroll: "Brug ctrl + rullefunktionen til at zoome ind og ud på kortet", scrollMac: "Brug ⌘ + rullefunktionen til at zoome ind og ud på kortet" }, de: { touch: "Verschieben der Karte mit zwei Fingern", scroll: "Verwende Strg+Scrollen zum Zoomen der Karte", scrollMac: "⌘" }, el: { touch: "Χρησιμοποιήστε δύο δάχτυλα για μετακίνηση στον χάρτη", scroll: "Χρησιμοποιήστε το πλήκτρο Ctrl και κύλιση, για να μεγεθύνετε τον χάρτη", scrollMac: "Χρησιμοποιήστε το πλήκτρο ⌘ + κύλιση για εστίαση στον χάρτη" }, en: { touch: "Use two fingers to move the map", scroll: "Use ctrl + scroll to zoom the map", scrollMac: "Use ⌘ + scroll to zoom the map" }, "en-AU": { touch: "Use two fingers to move the map", scroll: "Use ctrl + scroll to zoom the map", scrollMac: "Use ⌘ + scroll to zoom the map" }, "en-GB": { touch: "Use two fingers to move the map", scroll: "Use ctrl + scroll to zoom the map", scrollMac: "Use ⌘ + scroll to zoom the map" }, es: { touch: "Para mover el mapa, utiliza dos dedos", scroll: "Mantén pulsada la tecla Ctrl mientras te desplazas para acercar o alejar el mapa", scrollMac: "Mantén pulsada la tecla ⌘ mientras te desplazas para acercar o alejar el mapa" }, eu: { touch: "Erabili bi hatz mapa mugitzeko", scroll: "Mapan zooma aplikatzeko, sakatu Ktrl eta egin gora edo behera", scrollMac: "Eduki sakatuta ⌘ eta egin gora eta behera mapa handitu eta txikitzeko" }, fa: { touch: "برای حرکت دادن نقشه از دو انگشت استفاده کنید.", scroll: "‏برای بزرگ‌نمایی نقشه از ctrl + scroll استفاده کنید", scrollMac: "برای بزرگ‌نمایی نقشه، از ⌘ + پیمایش استفاده کنید." }, fi: { touch: "Siirrä karttaa kahdella sormella.", scroll: "Zoomaa karttaa painamalla Ctrl-painiketta ja vierittämällä.", scrollMac: "Zoomaa karttaa pitämällä painike ⌘ painettuna ja vierittämällä." }, fil: { touch: "Gumamit ng dalawang daliri upang iusog ang mapa", scroll: "Gamitin ang ctrl + scroll upang i-zoom ang mapa", scrollMac: "Gamitin ang ⌘ + scroll upang i-zoom ang mapa" }, fr: { touch: "Utilisez deux doigts pour déplacer la carte", scroll: "Vous pouvez zoomer sur la carte à l'aide de CTRL+Molette de défilement", scrollMac: "Vous pouvez zoomer sur la carte à l'aide de ⌘+Molette de défilement" }, gl: { touch: "Utiliza dous dedos para mover o mapa", scroll: "Preme Ctrl mentres te desprazas para ampliar o mapa", scrollMac: "Preme ⌘ e desprázate para ampliar o mapa" }, gu: { touch: "નકશો ખસેડવા બે આંગળીઓનો ઉપયોગ કરો", scroll: "નકશાને ઝૂમ કરવા માટે ctrl + સ્ક્રોલનો ઉપયોગ કરો", scrollMac: "નકશાને ઝૂમ કરવા ⌘ + સ્ક્રોલનો ઉપયોગ કરો" }, hi: { touch: "मैप एक जगह से दूसरी जगह ले जाने के लिए दो उंगलियों का इस्तेमाल करें", scroll: "मैप को ज़ूम करने के लिए ctrl + स्क्रोल का उपयोग करें", scrollMac: "मैप को ज़ूम करने के लिए ⌘ + स्क्रोल का उपयोग करें" }, hr: { touch: "Pomičite kartu pomoću dva prsta", scroll: "Upotrijebite Ctrl i klizač miša da biste zumirali kartu", scrollMac: "Upotrijebite gumb ⌘ dok se pomičete za zumiranje karte" }, hu: { touch: "Két ujjal mozgassa a térképet", scroll: "A térkép a ctrl + görgetés használatával nagyítható", scrollMac: "A térkép a ⌘ + görgetés használatával nagyítható" }, id: { touch: "Gunakan dua jari untuk menggerakkan peta", scroll: "Gunakan ctrl + scroll untuk memperbesar atau memperkecil peta", scrollMac: "Gunakan ⌘ + scroll untuk memperbesar atau memperkecil peta" }, it: { touch: "Utilizza due dita per spostare la mappa", scroll: "Utilizza CTRL + scorrimento per eseguire lo zoom della mappa", scrollMac: "Utilizza ⌘ + scorrimento per eseguire lo zoom della mappa" }, iw: { touch: "הזז את המפה באמצעות שתי אצבעות", scroll: "‏אפשר לשנות את מרחק התצוגה במפה באמצעות מקש ctrl וגלילה", scrollMac: "אפשר לשנות את מרחק התצוגה במפה באמצעות מקש ⌘ וגלילה" }, ja: { touch: "地図を移動させるには指 2 本で操作します", scroll: "地図をズームするには、Ctrl キーを押しながらスクロールしてください", scrollMac: "地図をズームするには、⌘ キーを押しながらスクロールしてください" }, kn: { touch: "Use two fingers to move the map", scroll: "Use Ctrl + scroll to zoom the map", scrollMac: "Use ⌘ + scroll to zoom the map" }, ko: { touch: "지도를 움직이려면 두 손가락을 사용하세요.", scroll: "지도를 확대/축소하려면 Ctrl을 누른 채 스크롤하세요.", scrollMac: "지도를 확대하려면 ⌘ + 스크롤 사용" }, lt: { touch: "Perkelkite žemėlapį dviem pirštais", scroll: "Slinkite nuspaudę klavišą „Ctrl“, kad pakeistumėte žemėlapio mastelį", scrollMac: "Paspauskite klavišą ⌘ ir slinkite, kad priartintumėte žemėlapį" }, lv: { touch: "Lai pārvietotu karti, bīdiet to ar diviem pirkstiem", scroll: "Kartes tālummaiņai izmantojiet ctrl + ritināšanu", scrollMac: "Lai veiktu kartes tālummaiņu, izmantojiet ⌘ + ritināšanu" }, ml: { touch: "മാപ്പ് നീക്കാൻ രണ്ട് വിരലുകൾ ഉപയോഗിക്കുക", scroll: "കൺട്രോൾ + സ്‌ക്രോൾ ഉപയോഗിച്ച് ‌മാപ്പ് ‌സൂം ചെയ്യുക", scrollMac: "⌘ + സ്‌ക്രോൾ ഉപയോഗിച്ച് ‌മാപ്പ് ‌സൂം ചെയ്യുക" }, mr: { touch: "नकाशा हलविण्यासाठी दोन बोटे वापरा", scroll: "नकाशा झूम करण्यासाठी ctrl + scroll वापरा", scrollMac: "नकाशावर झूम करण्यासाठी ⌘ + स्क्रोल वापरा" }, nl: { touch: "Gebruik twee vingers om de kaart te verplaatsen", scroll: "Gebruik Ctrl + scrollen om in- en uit te zoomen op de kaart", scrollMac: "Gebruik ⌘ + scrollen om in en uit te zoomen op de kaart" }, no: { touch: "Bruk to fingre for å flytte kartet", scroll: "Hold ctrl-tasten inne og rull for å zoome på kartet", scrollMac: "Hold inne ⌘-tasten og rull for å zoome på kartet" }, pl: { touch: "Przesuń mapę dwoma palcami", scroll: "Naciśnij CTRL i przewiń, by przybliżyć mapę", scrollMac: "Naciśnij ⌘ i przewiń, by przybliżyć mapę" }, pt: { touch: "Use dois dedos para mover o mapa", scroll: "Pressione Ctrl e role a tela simultaneamente para aplicar zoom no mapa", scrollMac: "Use ⌘ e role a tela simultaneamente para aplicar zoom no mapa" }, "pt-BR": { touch: "Use dois dedos para mover o mapa", scroll: "Pressione Ctrl e role a tela simultaneamente para aplicar zoom no mapa", scrollMac: "Use ⌘ e role a tela simultaneamente para aplicar zoom no mapa" }, "pt-PT": { touch: "Utilize dois dedos para mover o mapa", scroll: "Utilizar ctrl + deslocar para aumentar/diminuir zoom do mapa", scrollMac: "Utilize ⌘ + deslocar para aumentar/diminuir o zoom do mapa" }, ro: { touch: "Folosiți două degete pentru a deplasa harta", scroll: "Apăsați tasta ctrl și derulați simultan pentru a mări harta", scrollMac: "Folosiți ⌘ și derulați pentru a mări/micșora harta" }, ru: { touch: "Чтобы переместить карту, проведите по ней двумя пальцами", scroll: "Чтобы изменить масштаб, прокручивайте карту, удерживая клавишу Ctrl.", scrollMac: "Чтобы изменить масштаб, нажмите ⌘ + прокрутка" }, sk: { touch: "Mapu môžete posunúť dvoma prstami", scroll: "Ak chcete priblížiť mapu, stlačte kláves ctrl a posúvajte", scrollMac: "Ak chcete priblížiť mapu, stlačte kláves ⌘ a posúvajte kolieskom myši" }, sl: { touch: "Premaknite zemljevid z dvema prstoma", scroll: "Zemljevid povečate tako, da držite tipko Ctrl in vrtite kolesce na miški", scrollMac: "Uporabite ⌘ + funkcijo pomika, da povečate ali pomanjšate zemljevid" }, sr: { touch: "Мапу померајте помоћу два прста", scroll: "Притисните ctrl тастер док померате да бисте зумирали мапу", scrollMac: "Притисните тастер ⌘ док померате да бисте зумирали мапу" }, sv: { touch: "Använd två fingrar för att flytta kartan", scroll: "Använd ctrl + rulla för att zooma kartan", scrollMac: "Använd ⌘ + rulla för att zooma på kartan" }, ta: { touch: "மேப்பை நகர்த்த இரண்டு விரல்களைப் பயன்படுத்தவும்", scroll: "மேப்பை பெரிதாக்கி/சிறிதாக்கிப் பார்க்க, ctrl பட்டனைப் பிடித்தபடி, மேலே/கீழே ஸ்க்ரால் செய்யவும்", scrollMac: "மேப்பை பெரிதாக்கி/சிறிதாக்கிப் பார்க்க, ⌘ பட்டனைப் பிடித்தபடி, மேலே/கீழே ஸ்க்ரால் செய்யவும்" }, te: { touch: "మ్యాప్‌ని తరలించడం కోసం రెండు వేళ్లను ఉపయోగించండి", scroll: "మ్యాప్‌ని జూమ్ చేయడానికి ctrl బటన్‌ను నొక్కి ఉంచి, స్క్రోల్ చేయండి", scrollMac: "మ్యాప్ జూమ్ చేయాలంటే ⌘ + స్క్రోల్ ఉపయోగించండి" }, th: { touch: "ใช้ 2 นิ้วเพื่อเลื่อนแผนที่", scroll: "กด Ctrl ค้างไว้ แล้วเลื่อนหน้าจอเพื่อซูมแผนที่", scrollMac: "กด ⌘ แล้วเลื่อนหน้าจอเพื่อซูมแผนที่" }, tl: { touch: "Gumamit ng dalawang daliri upang iusog ang mapa", scroll: "Gamitin ang ctrl + scroll upang i-zoom ang mapa", scrollMac: "Gamitin ang ⌘ + scroll upang i-zoom ang mapa" }, tr: { touch: "Haritada gezinmek için iki parmağınızı kullanın", scroll: "Haritayı yakınlaştırmak için ctrl + kaydırma kombinasyonunu kullanın", scrollMac: "Haritayı yakınlaştırmak için ⌘ tuşuna basıp ekranı kaydırın" }, uk: { touch: "Переміщуйте карту двома пальцями", scroll: "Щоб змінювати масштаб карти, прокручуйте коліщатко миші, утримуючи клавішу Ctrl", scrollMac: "Щоб змінити масштаб карти, використовуйте ⌘ + прокручування" }, vi: { touch: "Sử dụng hai ngón tay để di chuyển bản đồ", scroll: "Sử dụng ctrl + cuộn để thu phóng bản đồ", scrollMac: "Sử dụng ⌘ + cuộn để thu phóng bản đồ" }, "zh-CN": { touch: "使用双指移动地图", scroll: "按住 Ctrl 并滚动鼠标滚轮才可缩放地图", scrollMac: "按住 ⌘ 并滚动鼠标滚轮才可缩放地图" }, "zh-TW": { touch: "同時以兩指移動地圖", scroll: "按住 ctrl 鍵加上捲動滑鼠可以縮放地圖", scrollMac: "按 ⌘ 加上滾動捲軸可以縮放地圖" } }; L.Map.mergeOptions({ gestureHandlingOptions: { text: {}, duration: 1e3 } }); var t = !1, e = L.Handler.extend({ addHooks: function addHooks() { this._handleTouch = this._handleTouch.bind(this), this._setupPluginOptions(), this._setLanguageContent(), this._disableInteractions(), this._map._container.addEventListener("touchstart", this._handleTouch), this._map._container.addEventListener("touchmove", this._handleTouch), this._map._container.addEventListener("touchend", this._handleTouch), this._map._container.addEventListener("touchcancel", this._handleTouch), this._map._container.addEventListener("click", this._handleTouch), L.DomEvent.on(this._map._container, "wheel", this._handleScroll, this), L.DomEvent.on(this._map, "mouseover", this._handleMouseOver, this), L.DomEvent.on(this._map, "mouseout", this._handleMouseOut, this), L.DomEvent.on(this._map, "movestart", this._handleDragging, this), L.DomEvent.on(this._map, "move", this._handleDragging, this), L.DomEvent.on(this._map, "moveend", this._handleDragging, this); }, removeHooks: function removeHooks() { this._enableInteractions(), this._map._container.removeEventListener("touchstart", this._handleTouch), this._map._container.removeEventListener("touchmove", this._handleTouch), this._map._container.removeEventListener("touchend", this._handleTouch), this._map._container.removeEventListener("touchcancel", this._handleTouch), this._map._container.removeEventListener("click", this._handleTouch), L.DomEvent.off(this._map._container, "wheel", this._handleScroll, this), L.DomEvent.off(this._map, "mouseover", this._handleMouseOver, this), L.DomEvent.off(this._map, "mouseout", this._handleMouseOut, this), L.DomEvent.off(this._map, "movestart", this._handleDragging, this), L.DomEvent.off(this._map, "move", this._handleDragging, this), L.DomEvent.off(this._map, "moveend", this._handleDragging, this); }, _handleDragging: function _handleDragging(a) { "movestart" == a.type || "move" == a.type ? t = !0 : "moveend" == a.type && (t = !1); }, _disableInteractions: function _disableInteractions() { this._map.dragging.disable(), this._map.scrollWheelZoom.disable(), this._map.tap && this._map.tap.disable(); }, _enableInteractions: function _enableInteractions() { this._map.dragging.enable(), this._map.scrollWheelZoom.enable(), this._map.tap && this._map.tap.enable(); }, _setupPluginOptions: function _setupPluginOptions() { this._map.options.gestureHandlingText && (this._map.options.gestureHandlingOptions.text = this._map.options.gestureHandlingText); }, _setLanguageContent: function _setLanguageContent() { var a; if (this._map.options.gestureHandlingOptions && this._map.options.gestureHandlingOptions.text && this._map.options.gestureHandlingOptions.text.touch && this._map.options.gestureHandlingOptions.text.scroll && this._map.options.gestureHandlingOptions.text.scrollMac) a = this._map.options.gestureHandlingOptions.text;else { var t = this._getUserLanguage(); t || (t = "en"), o[t] && (a = o[t]), a || -1 === t.indexOf("-") || (t = t.split("-")[0], a = o[t]), a || (a = o[t = "en"]); } var e = !1; 0 <= navigator.platform.toUpperCase().indexOf("MAC") && (e = !0); var l = a.scroll; e && (l = a.scrollMac), this._map._container.setAttribute("data-gesture-handling-touch-content", a.touch), this._map._container.setAttribute("data-gesture-handling-scroll-content", l); }, _getUserLanguage: function _getUserLanguage() { return navigator.languages ? navigator.languages[0] : navigator.language || navigator.userLanguage; }, _handleTouch: function _handleTouch(a) { for (var t = ["leaflet-control-minimap", "leaflet-interactive", "leaflet-popup-content", "leaflet-popup-content-wrapper", "leaflet-popup-close-button", "leaflet-control-zoom-in", "leaflet-control-zoom-out"], e = !1, l = 0; l < t.length; l++) L.DomUtil.hasClass(a.target, t[l]) && (e = !0); e ? L.DomUtil.hasClass(a.target, "leaflet-interactive") && "touchmove" === a.type && 1 === a.touches.length ? (L.DomUtil.addClass(this._map._container, "leaflet-gesture-handling-touch-warning"), this._disableInteractions()) : L.DomUtil.removeClass(this._map._container, "leaflet-gesture-handling-touch-warning") : "touchmove" === a.type || "touchstart" === a.type ? 1 === a.touches.length ? (L.DomUtil.addClass(this._map._container, "leaflet-gesture-handling-touch-warning"), this._disableInteractions()) : (a.preventDefault(), this._enableInteractions(), L.DomUtil.removeClass(this._map._container, "leaflet-gesture-handling-touch-warning")) : L.DomUtil.removeClass(this._map._container, "leaflet-gesture-handling-touch-warning"); }, _isScrolling: !1, _handleScroll: function _handleScroll(a) { a.metaKey || a.ctrlKey ? (a.preventDefault(), L.DomUtil.removeClass(this._map._container, "leaflet-gesture-handling-scroll-warning"), this._map.scrollWheelZoom.enable()) : (L.DomUtil.addClass(this._map._container, "leaflet-gesture-handling-scroll-warning"), this._map.scrollWheelZoom.disable(), clearTimeout(this._isScrolling), this._isScrolling = setTimeout(function () { for (var a = document.getElementsByClassName("leaflet-gesture-handling-scroll-warning"), t = 0; t < a.length; t++) L.DomUtil.removeClass(a[t], "leaflet-gesture-handling-scroll-warning"); }, this._map.options.gestureHandlingOptions.duration)); }, _handleMouseOver: function _handleMouseOver(a) { this._enableInteractions(); }, _handleMouseOut: function _handleMouseOut(a) { t || this._disableInteractions(); } }); L.Map.addInitHook("addHandler", "gestureHandling", e), a.GestureHandling = e, a["default"] = e, Object.defineProperty(a, "__esModule", { value: !0 }); }); },{}],81:[function(require,module,exports){ "use strict"; /** * Leaflet vector features drag functionality * @author Alexander Milevski * @preserve */ L.Path.include({ _transform: function _transform(t) { if (this._renderer) { if (t) { this._renderer.transformPath(this, t); } else { this._renderer._resetTransformPath(this); this._update(); } } return this; }, _onMouseClick: function _onMouseClick(t) { if (this.dragging && this.dragging.moved() || this._map.dragging && this._map.dragging.moved()) { return; } this._fireMouseEvent(t); } }); var END = { mousedown: "mouseup", touchstart: "touchend", pointerdown: "touchend", MSPointerDown: "touchend" }; var MOVE = { mousedown: "mousemove", touchstart: "touchmove", pointerdown: "touchmove", MSPointerDown: "touchmove" }; function distance(t, a) { var i = t.x - a.x, n = t.y - a.y; return Math.sqrt(i * i + n * n); } L.Handler.PathDrag = L.Handler.extend({ statics: { DRAGGING_CLS: "leaflet-path-draggable" }, initialize: function initialize(t) { this._path = t; this._matrix = null; this._startPoint = null; this._dragStartPoint = null; this._mapDraggingWasEnabled = false; this._path._dragMoved = false; }, addHooks: function addHooks() { this._path.on("mousedown", this._onDragStart, this); this._path.options.className = this._path.options.className ? this._path.options.className + " " + L.Handler.PathDrag.DRAGGING_CLS : L.Handler.PathDrag.DRAGGING_CLS; if (this._path._path) { L.DomUtil.addClass(this._path._path, L.Handler.PathDrag.DRAGGING_CLS); } }, removeHooks: function removeHooks() { this._path.off("mousedown", this._onDragStart, this); this._path.options.className = this._path.options.className.replace(new RegExp("\\s+" + L.Handler.PathDrag.DRAGGING_CLS), ""); if (this._path._path) { L.DomUtil.removeClass(this._path._path, L.Handler.PathDrag.DRAGGING_CLS); } }, moved: function moved() { return this._path._dragMoved; }, _onDragStart: function _onDragStart(t) { var a = t.originalEvent._simulated ? "touchstart" : t.originalEvent.type; this._mapDraggingWasEnabled = false; this._startPoint = t.containerPoint.clone(); this._dragStartPoint = t.containerPoint.clone(); this._matrix = [1, 0, 0, 1, 0, 0]; L.DomEvent.stop(t.originalEvent); L.DomUtil.addClass(this._path._renderer._container, "leaflet-interactive"); L.DomEvent.on(document, MOVE[a], this._onDrag, this).on(document, END[a], this._onDragEnd, this); if (this._path._map.dragging.enabled()) { this._path._map.dragging.disable(); this._mapDraggingWasEnabled = true; } this._path._dragMoved = false; if (this._path._popup) { this._path._popup.close(); } this._replaceCoordGetters(t); }, _onDrag: function _onDrag(t) { L.DomEvent.stop(t); var a = t.touches && t.touches.length >= 1 ? t.touches[0] : t; var i = this._path._map.mouseEventToContainerPoint(a); if (t.type === "touchmove" && !this._path._dragMoved) { var n = this._dragStartPoint.distanceTo(i); if (n <= this._path._map.options.tapTolerance) { return; } } var e = i.x; var r = i.y; var s = e - this._startPoint.x; var o = r - this._startPoint.y; if (s || o) { if (!this._path._dragMoved) { this._path._dragMoved = true; this._path.options.interactive = false; this._path._map.dragging._draggable._moved = true; this._path.fire("dragstart", t); this._path.bringToFront(); } this._matrix[4] += s; this._matrix[5] += o; this._startPoint.x = e; this._startPoint.y = r; this._path.fire("predrag", t); this._path._transform(this._matrix); this._path.fire("drag", t); } }, _onDragEnd: function _onDragEnd(t) { var a = this._path._map.mouseEventToContainerPoint(t); var i = this.moved(); if (i) { this._transformPoints(this._matrix); this._path._updatePath(); this._path._project(); this._path._transform(null); L.DomEvent.stop(t); } L.DomEvent.off(document, "mousemove touchmove", this._onDrag, this); L.DomEvent.off(document, "mouseup touchend", this._onDragEnd, this); this._restoreCoordGetters(); if (i) { this._path.fire("dragend", { distance: distance(this._dragStartPoint, a) }); var n = this._path._containsPoint; this._path._containsPoint = L.Util.falseFn; L.Util.requestAnimFrame(function () { this._path._dragMoved = false; this._path.options.interactive = true; this._path._containsPoint = n; }, this); } if (this._mapDraggingWasEnabled) { this._path._map.dragging.enable(); } }, _transformPoints: function _transformPoints(t, a) { var i = this._path; var n, e, r; var s = L.point(t[4], t[5]); var o = i._map.options.crs; var h = o.transformation; var _ = o.scale(i._map.getZoom()); var g = o.projection; var d = h.untransform(s, _).subtract(h.untransform(L.point(0, 0), _)); var p = !a; i._bounds = new L.LatLngBounds(); if (i._point) { a = g.unproject(g.project(i._latlng)._add(d)); if (p) { i._latlng = a; i._point._add(s); } } else if (i._rings || i._parts) { var l = i._rings || i._parts; var f = i._latlngs; a = a || f; if (!L.Util.isArray(f[0])) { f = [f]; a = [a]; } for (n = 0, e = l.length; n < e; n++) { a[n] = a[n] || []; for (var u = 0, m = l[n].length; u < m; u++) { r = f[n][u]; a[n][u] = g.unproject(g.project(r)._add(d)); if (p) { i._bounds.extend(f[n][u]); l[n][u]._add(s); } } } } return a; }, _replaceCoordGetters: function _replaceCoordGetters() { if (this._path.getLatLng) { this._path.getLatLng_ = this._path.getLatLng; this._path.getLatLng = L.Util.bind(function () { return this.dragging._transformPoints(this.dragging._matrix, {}); }, this._path); } else if (this._path.getLatLngs) { this._path.getLatLngs_ = this._path.getLatLngs; this._path.getLatLngs = L.Util.bind(function () { return this.dragging._transformPoints(this.dragging._matrix, []); }, this._path); } }, _restoreCoordGetters: function _restoreCoordGetters() { if (this._path.getLatLng_) { this._path.getLatLng = this._path.getLatLng_; delete this._path.getLatLng_; } else if (this._path.getLatLngs_) { this._path.getLatLngs = this._path.getLatLngs_; delete this._path.getLatLngs_; } } }); L.Handler.PathDrag.makeDraggable = function (t) { t.dragging = new L.Handler.PathDrag(t); return t; }; L.Path.prototype.makeDraggable = function () { return L.Handler.PathDrag.makeDraggable(this); }; L.Path.addInitHook(function () { if (this.options.draggable) { this.options.interactive = true; if (this.dragging) { this.dragging.enable(); } else { L.Handler.PathDrag.makeDraggable(this); this.dragging.enable(); } } else if (this.dragging) { this.dragging.disable(); } }); L.SVG.include({ _resetTransformPath: function _resetTransformPath(t) { t._path.setAttributeNS(null, "transform", ""); }, transformPath: function transformPath(t, a) { t._path.setAttributeNS(null, "transform", "matrix(" + a.join(" ") + ")"); } }); L.SVG.include(!L.Browser.vml ? {} : { _resetTransformPath: function _resetTransformPath(t) { if (t._skew) { t._skew.on = false; t._path.removeChild(t._skew); t._skew = null; } }, transformPath: function transformPath(t, a) { var i = t._skew; if (!i) { i = L.SVG.create("skew"); t._path.appendChild(i); i.style.behavior = "url(#default#VML)"; t._skew = i; } var n = a[0].toFixed(8) + " " + a[1].toFixed(8) + " " + a[2].toFixed(8) + " " + a[3].toFixed(8) + " 0 0"; var e = Math.floor(a[4]).toFixed() + ", " + Math.floor(a[5]).toFixed() + ""; var r = this._path.style; var s = parseFloat(r.left); var o = parseFloat(r.top); var h = parseFloat(r.width); var _ = parseFloat(r.height); if (isNaN(s)) s = 0; if (isNaN(o)) o = 0; if (isNaN(h) || !h) h = 1; if (isNaN(_) || !_) _ = 1; var g = (-s / h - .5).toFixed(8) + " " + (-o / _ - .5).toFixed(8); i.on = "f"; i.matrix = n; i.origin = g; i.offset = e; i.on = true; } }); function TRUE_FN() { return true; } L.Canvas.include({ _resetTransformPath: function _resetTransformPath(t) { if (!this._containerCopy) return; delete this._containerCopy; if (t._containsPoint_) { t._containsPoint = t._containsPoint_; delete t._containsPoint_; this._requestRedraw(t); } }, transformPath: function transformPath(t, a) { var i = this._containerCopy; var n = this._ctx, e; var r = L.Browser.retina ? 2 : 1; var s = this._bounds; var o = s.getSize(); var h = s.min; if (!i) { i = this._containerCopy = document.createElement("canvas"); e = i.getContext("2d"); i.width = r * o.x; i.height = r * o.y; this._removePath(t); this._redraw(); e.translate(r * s.min.x, r * s.min.y); e.drawImage(this._container, 0, 0); this._initPath(t); t._containsPoint_ = t._containsPoint; t._containsPoint = TRUE_FN; } n.save(); n.clearRect(h.x, h.y, o.x * r, o.y * r); n.setTransform(1, 0, 0, 1, 0, 0); n.restore(); n.save(); n.drawImage(this._containerCopy, 0, 0, o.x, o.y); n.transform.apply(n, a); this._drawing = true; t._updatePath(); this._drawing = false; n.restore(); } }); },{}],82:[function(require,module,exports){ "use strict"; L.Control.ScaleNautic = L.Control.Scale.extend({ options: { nautic: false }, _addScales: function _addScales(options, className, container) { L.Control.Scale.prototype._addScales.call(this, options, className, container); L.setOptions(options); if (this.options.nautic) { this._nScale = L.DomUtil.create('div', className, container); } }, _updateScales: function _updateScales(maxMeters) { L.Control.Scale.prototype._updateScales.call(this, maxMeters); if (this.options.nautic && maxMeters) { this._updateNautic(maxMeters); } }, _updateNautic: function _updateNautic(maxMeters) { var scale = this._nScale, maxNauticalMiles = maxMeters / 1852, nauticalMiles; if (maxMeters >= 1852) { nauticalMiles = L.Control.Scale.prototype._getRoundNum.call(this, maxNauticalMiles); } else { nauticalMiles = maxNauticalMiles > 0.1 ? Math.round(maxNauticalMiles * 10) / 10 : Math.round(maxNauticalMiles * 100) / 100; } scale.style.width = Math.round(this.options.maxWidth * (nauticalMiles / maxNauticalMiles)) - 10 + 'px'; scale.innerHTML = nauticalMiles + ' nm'; } }); L.control.scalenautic = function (options) { return new L.Control.ScaleNautic(options); }; },{}],83:[function(require,module,exports){ "use strict"; function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } /* @preserve * Leaflet 1.9.4, a JS library for interactive maps. https://leafletjs.com * (c) 2010-2023 Vladimir Agafonkin, (c) 2010-2011 CloudMade */ (function (global, factory) { (typeof exports === "undefined" ? "undefined" : _typeof(exports)) === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.leaflet = {})); })(void 0, function (exports) { 'use strict'; var version = "1.9.4"; /* * @namespace Util * * Various utility functions, used by Leaflet internally. */ // @function extend(dest: Object, src?: Object): Object // Merges the properties of the `src` object (or multiple objects) into `dest` object and returns the latter. Has an `L.extend` shortcut. function extend(dest) { var i, j, len, src; for (j = 1, len = arguments.length; j < len; j++) { src = arguments[j]; for (i in src) { dest[i] = src[i]; } } return dest; } // @function create(proto: Object, properties?: Object): Object // Compatibility polyfill for [Object.create](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/create) var create$2 = Object.create || function () { function F() {} return function (proto) { F.prototype = proto; return new F(); }; }(); // @function bind(fn: Function, …): Function // Returns a new function bound to the arguments passed, like [Function.prototype.bind](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function/bind). // Has a `L.bind()` shortcut. function bind(fn, obj) { var slice = Array.prototype.slice; if (fn.bind) { return fn.bind.apply(fn, slice.call(arguments, 1)); } var args = slice.call(arguments, 2); return function () { return fn.apply(obj, args.length ? args.concat(slice.call(arguments)) : arguments); }; } // @property lastId: Number // Last unique ID used by [`stamp()`](#util-stamp) var lastId = 0; // @function stamp(obj: Object): Number // Returns the unique ID of an object, assigning it one if it doesn't have it. function stamp(obj) { if (!('_leaflet_id' in obj)) { obj['_leaflet_id'] = ++lastId; } return obj._leaflet_id; } // @function throttle(fn: Function, time: Number, context: Object): Function // Returns a function which executes function `fn` with the given scope `context` // (so that the `this` keyword refers to `context` inside `fn`'s code). The function // `fn` will be called no more than one time per given amount of `time`. The arguments // received by the bound function will be any arguments passed when binding the // function, followed by any arguments passed when invoking the bound function. // Has an `L.throttle` shortcut. function throttle(fn, time, context) { var lock, args, wrapperFn, later; later = function later() { // reset lock and call if queued lock = false; if (args) { wrapperFn.apply(context, args); args = false; } }; wrapperFn = function wrapperFn() { if (lock) { // called too soon, queue to call later args = arguments; } else { // call and lock until later fn.apply(context, arguments); setTimeout(later, time); lock = true; } }; return wrapperFn; } // @function wrapNum(num: Number, range: Number[], includeMax?: Boolean): Number // Returns the number `num` modulo `range` in such a way so it lies within // `range[0]` and `range[1]`. The returned value will be always smaller than // `range[1]` unless `includeMax` is set to `true`. function wrapNum(x, range, includeMax) { var max = range[1], min = range[0], d = max - min; return x === max && includeMax ? x : ((x - min) % d + d) % d + min; } // @function falseFn(): Function // Returns a function which always returns `false`. function falseFn() { return false; } // @function formatNum(num: Number, precision?: Number|false): Number // Returns the number `num` rounded with specified `precision`. // The default `precision` value is 6 decimal places. // `false` can be passed to skip any processing (can be useful to avoid round-off errors). function formatNum(num, precision) { if (precision === false) { return num; } var pow = Math.pow(10, precision === undefined ? 6 : precision); return Math.round(num * pow) / pow; } // @function trim(str: String): String // Compatibility polyfill for [String.prototype.trim](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/Trim) function trim(str) { return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, ''); } // @function splitWords(str: String): String[] // Trims and splits the string on whitespace and returns the array of parts. function splitWords(str) { return trim(str).split(/\s+/); } // @function setOptions(obj: Object, options: Object): Object // Merges the given properties to the `options` of the `obj` object, returning the resulting options. See `Class options`. Has an `L.setOptions` shortcut. function setOptions(obj, options) { if (!Object.prototype.hasOwnProperty.call(obj, 'options')) { obj.options = obj.options ? create$2(obj.options) : {}; } for (var i in options) { obj.options[i] = options[i]; } return obj.options; } // @function getParamString(obj: Object, existingUrl?: String, uppercase?: Boolean): String // Converts an object into a parameter URL string, e.g. `{a: "foo", b: "bar"}` // translates to `'?a=foo&b=bar'`. If `existingUrl` is set, the parameters will // be appended at the end. If `uppercase` is `true`, the parameter names will // be uppercased (e.g. `'?A=foo&B=bar'`) function getParamString(obj, existingUrl, uppercase) { var params = []; for (var i in obj) { params.push(encodeURIComponent(uppercase ? i.toUpperCase() : i) + '=' + encodeURIComponent(obj[i])); } return (!existingUrl || existingUrl.indexOf('?') === -1 ? '?' : '&') + params.join('&'); } var templateRe = /\{ *([\w_ -]+) *\}/g; // @function template(str: String, data: Object): String // Simple templating facility, accepts a template string of the form `'Hello {a}, {b}'` // and a data object like `{a: 'foo', b: 'bar'}`, returns evaluated string // `('Hello foo, bar')`. You can also specify functions instead of strings for // data values — they will be evaluated passing `data` as an argument. function template(str, data) { return str.replace(templateRe, function (str, key) { var value = data[key]; if (value === undefined) { throw new Error('No value provided for variable ' + str); } else if (typeof value === 'function') { value = value(data); } return value; }); } // @function isArray(obj): Boolean // Compatibility polyfill for [Array.isArray](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray) var isArray = Array.isArray || function (obj) { return Object.prototype.toString.call(obj) === '[object Array]'; }; // @function indexOf(array: Array, el: Object): Number // Compatibility polyfill for [Array.prototype.indexOf](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf) function indexOf(array, el) { for (var i = 0; i < array.length; i++) { if (array[i] === el) { return i; } } return -1; } // @property emptyImageUrl: String // Data URI string containing a base64-encoded empty GIF image. // Used as a hack to free memory from unused images on WebKit-powered // mobile devices (by setting image `src` to this string). var emptyImageUrl = 'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs='; // inspired by https://paulirish.com/2011/requestanimationframe-for-smart-animating/ function getPrefixed(name) { return window['webkit' + name] || window['moz' + name] || window['ms' + name]; } var lastTime = 0; // fallback for IE 7-8 function timeoutDefer(fn) { var time = +new Date(), timeToCall = Math.max(0, 16 - (time - lastTime)); lastTime = time + timeToCall; return window.setTimeout(fn, timeToCall); } var requestFn = window.requestAnimationFrame || getPrefixed('RequestAnimationFrame') || timeoutDefer; var cancelFn = window.cancelAnimationFrame || getPrefixed('CancelAnimationFrame') || getPrefixed('CancelRequestAnimationFrame') || function (id) { window.clearTimeout(id); }; // @function requestAnimFrame(fn: Function, context?: Object, immediate?: Boolean): Number // Schedules `fn` to be executed when the browser repaints. `fn` is bound to // `context` if given. When `immediate` is set, `fn` is called immediately if // the browser doesn't have native support for // [`window.requestAnimationFrame`](https://developer.mozilla.org/docs/Web/API/window/requestAnimationFrame), // otherwise it's delayed. Returns a request ID that can be used to cancel the request. function requestAnimFrame(fn, context, immediate) { if (immediate && requestFn === timeoutDefer) { fn.call(context); } else { return requestFn.call(window, bind(fn, context)); } } // @function cancelAnimFrame(id: Number): undefined // Cancels a previous `requestAnimFrame`. See also [window.cancelAnimationFrame](https://developer.mozilla.org/docs/Web/API/window/cancelAnimationFrame). function cancelAnimFrame(id) { if (id) { cancelFn.call(window, id); } } var Util = { __proto__: null, extend: extend, create: create$2, bind: bind, get lastId() { return lastId; }, stamp: stamp, throttle: throttle, wrapNum: wrapNum, falseFn: falseFn, formatNum: formatNum, trim: trim, splitWords: splitWords, setOptions: setOptions, getParamString: getParamString, template: template, isArray: isArray, indexOf: indexOf, emptyImageUrl: emptyImageUrl, requestFn: requestFn, cancelFn: cancelFn, requestAnimFrame: requestAnimFrame, cancelAnimFrame: cancelAnimFrame }; // @class Class // @aka L.Class // @section // @uninheritable // Thanks to John Resig and Dean Edwards for inspiration! function Class() {} Class.extend = function (props) { // @function extend(props: Object): Function // [Extends the current class](#class-inheritance) given the properties to be included. // Returns a Javascript function that is a class constructor (to be called with `new`). var NewClass = function NewClass() { setOptions(this); // call the constructor if (this.initialize) { this.initialize.apply(this, arguments); } // call all constructor hooks this.callInitHooks(); }; var parentProto = NewClass.__super__ = this.prototype; var proto = create$2(parentProto); proto.constructor = NewClass; NewClass.prototype = proto; // inherit parent's statics for (var i in this) { if (Object.prototype.hasOwnProperty.call(this, i) && i !== 'prototype' && i !== '__super__') { NewClass[i] = this[i]; } } // mix static properties into the class if (props.statics) { extend(NewClass, props.statics); } // mix includes into the prototype if (props.includes) { checkDeprecatedMixinEvents(props.includes); extend.apply(null, [proto].concat(props.includes)); } // mix given properties into the prototype extend(proto, props); delete proto.statics; delete proto.includes; // merge options if (proto.options) { proto.options = parentProto.options ? create$2(parentProto.options) : {}; extend(proto.options, props.options); } proto._initHooks = []; // add method for calling all hooks proto.callInitHooks = function () { if (this._initHooksCalled) { return; } if (parentProto.callInitHooks) { parentProto.callInitHooks.call(this); } this._initHooksCalled = true; for (var i = 0, len = proto._initHooks.length; i < len; i++) { proto._initHooks[i].call(this); } }; return NewClass; }; // @function include(properties: Object): this // [Includes a mixin](#class-includes) into the current class. Class.include = function (props) { var parentOptions = this.prototype.options; extend(this.prototype, props); if (props.options) { this.prototype.options = parentOptions; this.mergeOptions(props.options); } return this; }; // @function mergeOptions(options: Object): this // [Merges `options`](#class-options) into the defaults of the class. Class.mergeOptions = function (options) { extend(this.prototype.options, options); return this; }; // @function addInitHook(fn: Function): this // Adds a [constructor hook](#class-constructor-hooks) to the class. Class.addInitHook = function (fn) { // (Function) || (String, args...) var args = Array.prototype.slice.call(arguments, 1); var init = typeof fn === 'function' ? fn : function () { this[fn].apply(this, args); }; this.prototype._initHooks = this.prototype._initHooks || []; this.prototype._initHooks.push(init); return this; }; function checkDeprecatedMixinEvents(includes) { /* global L: true */ if (typeof L === 'undefined' || !L || !L.Mixin) { return; } includes = isArray(includes) ? includes : [includes]; for (var i = 0; i < includes.length; i++) { if (includes[i] === L.Mixin.Events) { console.warn('Deprecated include of L.Mixin.Events: ' + 'this property will be removed in future releases, ' + 'please inherit from L.Evented instead.', new Error().stack); } } } /* * @class Evented * @aka L.Evented * @inherits Class * * A set of methods shared between event-powered classes (like `Map` and `Marker`). Generally, events allow you to execute some function when something happens with an object (e.g. the user clicks on the map, causing the map to fire `'click'` event). * * @example * * ```js * map.on('click', function(e) { * alert(e.latlng); * } ); * ``` * * Leaflet deals with event listeners by reference, so if you want to add a listener and then remove it, define it as a function: * * ```js * function onClick(e) { ... } * * map.on('click', onClick); * map.off('click', onClick); * ``` */ var Events = { /* @method on(type: String, fn: Function, context?: Object): this * Adds a listener function (`fn`) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. `'click dblclick'`). * * @alternative * @method on(eventMap: Object): this * Adds a set of type/listener pairs, e.g. `{click: onClick, mousemove: onMouseMove}` */ on: function on(types, fn, context) { // types can be a map of types/handlers if (_typeof(types) === 'object') { for (var type in types) { // we don't process space-separated events here for performance; // it's a hot path since Layer uses the on(obj) syntax this._on(type, types[type], fn); } } else { // types can be a string of space-separated words types = splitWords(types); for (var i = 0, len = types.length; i < len; i++) { this._on(types[i], fn, context); } } return this; }, /* @method off(type: String, fn?: Function, context?: Object): this * Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to `on`, you must pass the same context to `off` in order to remove the listener. * * @alternative * @method off(eventMap: Object): this * Removes a set of type/listener pairs. * * @alternative * @method off: this * Removes all listeners to all events on the object. This includes implicitly attached events. */ off: function off(types, fn, context) { if (!arguments.length) { // clear all listeners if called without arguments delete this._events; } else if (_typeof(types) === 'object') { for (var type in types) { this._off(type, types[type], fn); } } else { types = splitWords(types); var removeAll = arguments.length === 1; for (var i = 0, len = types.length; i < len; i++) { if (removeAll) { this._off(types[i]); } else { this._off(types[i], fn, context); } } } return this; }, // attach listener (without syntactic sugar now) _on: function _on(type, fn, context, _once) { if (typeof fn !== 'function') { console.warn('wrong listener type: ' + _typeof(fn)); return; } // check if fn already there if (this._listens(type, fn, context) !== false) { return; } if (context === this) { // Less memory footprint. context = undefined; } var newListener = { fn: fn, ctx: context }; if (_once) { newListener.once = true; } this._events = this._events || {}; this._events[type] = this._events[type] || []; this._events[type].push(newListener); }, _off: function _off(type, fn, context) { var listeners, i, len; if (!this._events) { return; } listeners = this._events[type]; if (!listeners) { return; } if (arguments.length === 1) { // remove all if (this._firingCount) { // Set all removed listeners to noop // so they are not called if remove happens in fire for (i = 0, len = listeners.length; i < len; i++) { listeners[i].fn = falseFn; } } // clear all listeners for a type if function isn't specified delete this._events[type]; return; } if (typeof fn !== 'function') { console.warn('wrong listener type: ' + _typeof(fn)); return; } // find fn and remove it var index = this._listens(type, fn, context); if (index !== false) { var listener = listeners[index]; if (this._firingCount) { // set the removed listener to noop so that's not called if remove happens in fire listener.fn = falseFn; /* copy array in case events are being fired */ this._events[type] = listeners = listeners.slice(); } listeners.splice(index, 1); } }, // @method fire(type: String, data?: Object, propagate?: Boolean): this // Fires an event of the specified type. You can optionally provide a data // object — the first argument of the listener function will contain its // properties. The event can optionally be propagated to event parents. fire: function fire(type, data, propagate) { if (!this.listens(type, propagate)) { return this; } var event = extend({}, data, { type: type, target: this, sourceTarget: data && data.sourceTarget || this }); if (this._events) { var listeners = this._events[type]; if (listeners) { this._firingCount = this._firingCount + 1 || 1; for (var i = 0, len = listeners.length; i < len; i++) { var l = listeners[i]; // off overwrites l.fn, so we need to copy fn to a var var fn = l.fn; if (l.once) { this.off(type, fn, l.ctx); } fn.call(l.ctx || this, event); } this._firingCount--; } } if (propagate) { // propagate the event to parents (set with addEventParent) this._propagateEvent(event); } return this; }, // @method listens(type: String, propagate?: Boolean): Boolean // @method listens(type: String, fn: Function, context?: Object, propagate?: Boolean): Boolean // Returns `true` if a particular event type has any listeners attached to it. // The verification can optionally be propagated, it will return `true` if parents have the listener attached to it. listens: function listens(type, fn, context, propagate) { if (typeof type !== 'string') { console.warn('"string" type argument expected'); } // we don't overwrite the input `fn` value, because we need to use it for propagation var _fn = fn; if (typeof fn !== 'function') { propagate = !!fn; _fn = undefined; context = undefined; } var listeners = this._events && this._events[type]; if (listeners && listeners.length) { if (this._listens(type, _fn, context) !== false) { return true; } } if (propagate) { // also check parents for listeners if event propagates for (var id in this._eventParents) { if (this._eventParents[id].listens(type, fn, context, propagate)) { return true; } } } return false; }, // returns the index (number) or false _listens: function _listens(type, fn, context) { if (!this._events) { return false; } var listeners = this._events[type] || []; if (!fn) { return !!listeners.length; } if (context === this) { // Less memory footprint. context = undefined; } for (var i = 0, len = listeners.length; i < len; i++) { if (listeners[i].fn === fn && listeners[i].ctx === context) { return i; } } return false; }, // @method once(…): this // Behaves as [`on(…)`](#evented-on), except the listener will only get fired once and then removed. once: function once(types, fn, context) { // types can be a map of types/handlers if (_typeof(types) === 'object') { for (var type in types) { // we don't process space-separated events here for performance; // it's a hot path since Layer uses the on(obj) syntax this._on(type, types[type], fn, true); } } else { // types can be a string of space-separated words types = splitWords(types); for (var i = 0, len = types.length; i < len; i++) { this._on(types[i], fn, context, true); } } return this; }, // @method addEventParent(obj: Evented): this // Adds an event parent - an `Evented` that will receive propagated events addEventParent: function addEventParent(obj) { this._eventParents = this._eventParents || {}; this._eventParents[stamp(obj)] = obj; return this; }, // @method removeEventParent(obj: Evented): this // Removes an event parent, so it will stop receiving propagated events removeEventParent: function removeEventParent(obj) { if (this._eventParents) { delete this._eventParents[stamp(obj)]; } return this; }, _propagateEvent: function _propagateEvent(e) { for (var id in this._eventParents) { this._eventParents[id].fire(e.type, extend({ layer: e.target, propagatedFrom: e.target }, e), true); } } }; // aliases; we should ditch those eventually // @method addEventListener(…): this // Alias to [`on(…)`](#evented-on) Events.addEventListener = Events.on; // @method removeEventListener(…): this // Alias to [`off(…)`](#evented-off) // @method clearAllEventListeners(…): this // Alias to [`off()`](#evented-off) Events.removeEventListener = Events.clearAllEventListeners = Events.off; // @method addOneTimeEventListener(…): this // Alias to [`once(…)`](#evented-once) Events.addOneTimeEventListener = Events.once; // @method fireEvent(…): this // Alias to [`fire(…)`](#evented-fire) Events.fireEvent = Events.fire; // @method hasEventListeners(…): Boolean // Alias to [`listens(…)`](#evented-listens) Events.hasEventListeners = Events.listens; var Evented = Class.extend(Events); /* * @class Point * @aka L.Point * * Represents a point with `x` and `y` coordinates in pixels. * * @example * * ```js * var point = L.point(200, 300); * ``` * * All Leaflet methods and options that accept `Point` objects also accept them in a simple Array form (unless noted otherwise), so these lines are equivalent: * * ```js * map.panBy([200, 300]); * map.panBy(L.point(200, 300)); * ``` * * Note that `Point` does not inherit from Leaflet's `Class` object, * which means new classes can't inherit from it, and new methods * can't be added to it with the `include` function. */ function Point(x, y, round) { // @property x: Number; The `x` coordinate of the point this.x = round ? Math.round(x) : x; // @property y: Number; The `y` coordinate of the point this.y = round ? Math.round(y) : y; } var trunc = Math.trunc || function (v) { return v > 0 ? Math.floor(v) : Math.ceil(v); }; Point.prototype = { // @method clone(): Point // Returns a copy of the current point. clone: function clone() { return new Point(this.x, this.y); }, // @method add(otherPoint: Point): Point // Returns the result of addition of the current and the given points. add: function add(point) { // non-destructive, returns a new point return this.clone()._add(toPoint(point)); }, _add: function _add(point) { // destructive, used directly for performance in situations where it's safe to modify existing point this.x += point.x; this.y += point.y; return this; }, // @method subtract(otherPoint: Point): Point // Returns the result of subtraction of the given point from the current. subtract: function subtract(point) { return this.clone()._subtract(toPoint(point)); }, _subtract: function _subtract(point) { this.x -= point.x; this.y -= point.y; return this; }, // @method divideBy(num: Number): Point // Returns the result of division of the current point by the given number. divideBy: function divideBy(num) { return this.clone()._divideBy(num); }, _divideBy: function _divideBy(num) { this.x /= num; this.y /= num; return this; }, // @method multiplyBy(num: Number): Point // Returns the result of multiplication of the current point by the given number. multiplyBy: function multiplyBy(num) { return this.clone()._multiplyBy(num); }, _multiplyBy: function _multiplyBy(num) { this.x *= num; this.y *= num; return this; }, // @method scaleBy(scale: Point): Point // Multiply each coordinate of the current point by each coordinate of // `scale`. In linear algebra terms, multiply the point by the // [scaling matrix](https://en.wikipedia.org/wiki/Scaling_%28geometry%29#Matrix_representation) // defined by `scale`. scaleBy: function scaleBy(point) { return new Point(this.x * point.x, this.y * point.y); }, // @method unscaleBy(scale: Point): Point // Inverse of `scaleBy`. Divide each coordinate of the current point by // each coordinate of `scale`. unscaleBy: function unscaleBy(point) { return new Point(this.x / point.x, this.y / point.y); }, // @method round(): Point // Returns a copy of the current point with rounded coordinates. round: function round() { return this.clone()._round(); }, _round: function _round() { this.x = Math.round(this.x); this.y = Math.round(this.y); return this; }, // @method floor(): Point // Returns a copy of the current point with floored coordinates (rounded down). floor: function floor() { return this.clone()._floor(); }, _floor: function _floor() { this.x = Math.floor(this.x); this.y = Math.floor(this.y); return this; }, // @method ceil(): Point // Returns a copy of the current point with ceiled coordinates (rounded up). ceil: function ceil() { return this.clone()._ceil(); }, _ceil: function _ceil() { this.x = Math.ceil(this.x); this.y = Math.ceil(this.y); return this; }, // @method trunc(): Point // Returns a copy of the current point with truncated coordinates (rounded towards zero). trunc: function trunc() { return this.clone()._trunc(); }, _trunc: function _trunc() { this.x = trunc(this.x); this.y = trunc(this.y); return this; }, // @method distanceTo(otherPoint: Point): Number // Returns the cartesian distance between the current and the given points. distanceTo: function distanceTo(point) { point = toPoint(point); var x = point.x - this.x, y = point.y - this.y; return Math.sqrt(x * x + y * y); }, // @method equals(otherPoint: Point): Boolean // Returns `true` if the given point has the same coordinates. equals: function equals(point) { point = toPoint(point); return point.x === this.x && point.y === this.y; }, // @method contains(otherPoint: Point): Boolean // Returns `true` if both coordinates of the given point are less than the corresponding current point coordinates (in absolute values). contains: function contains(point) { point = toPoint(point); return Math.abs(point.x) <= Math.abs(this.x) && Math.abs(point.y) <= Math.abs(this.y); }, // @method toString(): String // Returns a string representation of the point for debugging purposes. toString: function toString() { return 'Point(' + formatNum(this.x) + ', ' + formatNum(this.y) + ')'; } }; // @factory L.point(x: Number, y: Number, round?: Boolean) // Creates a Point object with the given `x` and `y` coordinates. If optional `round` is set to true, rounds the `x` and `y` values. // @alternative // @factory L.point(coords: Number[]) // Expects an array of the form `[x, y]` instead. // @alternative // @factory L.point(coords: Object) // Expects a plain object of the form `{x: Number, y: Number}` instead. function toPoint(x, y, round) { if (x instanceof Point) { return x; } if (isArray(x)) { return new Point(x[0], x[1]); } if (x === undefined || x === null) { return x; } if (_typeof(x) === 'object' && 'x' in x && 'y' in x) { return new Point(x.x, x.y); } return new Point(x, y, round); } /* * @class Bounds * @aka L.Bounds * * Represents a rectangular area in pixel coordinates. * * @example * * ```js * var p1 = L.point(10, 10), * p2 = L.point(40, 60), * bounds = L.bounds(p1, p2); * ``` * * All Leaflet methods that accept `Bounds` objects also accept them in a simple Array form (unless noted otherwise), so the bounds example above can be passed like this: * * ```js * otherBounds.intersects([[10, 10], [40, 60]]); * ``` * * Note that `Bounds` does not inherit from Leaflet's `Class` object, * which means new classes can't inherit from it, and new methods * can't be added to it with the `include` function. */ function Bounds(a, b) { if (!a) { return; } var points = b ? [a, b] : a; for (var i = 0, len = points.length; i < len; i++) { this.extend(points[i]); } } Bounds.prototype = { // @method extend(point: Point): this // Extends the bounds to contain the given point. // @alternative // @method extend(otherBounds: Bounds): this // Extend the bounds to contain the given bounds extend: function extend(obj) { var min2, max2; if (!obj) { return this; } if (obj instanceof Point || typeof obj[0] === 'number' || 'x' in obj) { min2 = max2 = toPoint(obj); } else { obj = toBounds(obj); min2 = obj.min; max2 = obj.max; if (!min2 || !max2) { return this; } } // @property min: Point // The top left corner of the rectangle. // @property max: Point // The bottom right corner of the rectangle. if (!this.min && !this.max) { this.min = min2.clone(); this.max = max2.clone(); } else { this.min.x = Math.min(min2.x, this.min.x); this.max.x = Math.max(max2.x, this.max.x); this.min.y = Math.min(min2.y, this.min.y); this.max.y = Math.max(max2.y, this.max.y); } return this; }, // @method getCenter(round?: Boolean): Point // Returns the center point of the bounds. getCenter: function getCenter(round) { return toPoint((this.min.x + this.max.x) / 2, (this.min.y + this.max.y) / 2, round); }, // @method getBottomLeft(): Point // Returns the bottom-left point of the bounds. getBottomLeft: function getBottomLeft() { return toPoint(this.min.x, this.max.y); }, // @method getTopRight(): Point // Returns the top-right point of the bounds. getTopRight: function getTopRight() { // -> Point return toPoint(this.max.x, this.min.y); }, // @method getTopLeft(): Point // Returns the top-left point of the bounds (i.e. [`this.min`](#bounds-min)). getTopLeft: function getTopLeft() { return this.min; // left, top }, // @method getBottomRight(): Point // Returns the bottom-right point of the bounds (i.e. [`this.max`](#bounds-max)). getBottomRight: function getBottomRight() { return this.max; // right, bottom }, // @method getSize(): Point // Returns the size of the given bounds getSize: function getSize() { return this.max.subtract(this.min); }, // @method contains(otherBounds: Bounds): Boolean // Returns `true` if the rectangle contains the given one. // @alternative // @method contains(point: Point): Boolean // Returns `true` if the rectangle contains the given point. contains: function contains(obj) { var min, max; if (typeof obj[0] === 'number' || obj instanceof Point) { obj = toPoint(obj); } else { obj = toBounds(obj); } if (obj instanceof Bounds) { min = obj.min; max = obj.max; } else { min = max = obj; } return min.x >= this.min.x && max.x <= this.max.x && min.y >= this.min.y && max.y <= this.max.y; }, // @method intersects(otherBounds: Bounds): Boolean // Returns `true` if the rectangle intersects the given bounds. Two bounds // intersect if they have at least one point in common. intersects: function intersects(bounds) { // (Bounds) -> Boolean bounds = toBounds(bounds); var min = this.min, max = this.max, min2 = bounds.min, max2 = bounds.max, xIntersects = max2.x >= min.x && min2.x <= max.x, yIntersects = max2.y >= min.y && min2.y <= max.y; return xIntersects && yIntersects; }, // @method overlaps(otherBounds: Bounds): Boolean // Returns `true` if the rectangle overlaps the given bounds. Two bounds // overlap if their intersection is an area. overlaps: function overlaps(bounds) { // (Bounds) -> Boolean bounds = toBounds(bounds); var min = this.min, max = this.max, min2 = bounds.min, max2 = bounds.max, xOverlaps = max2.x > min.x && min2.x < max.x, yOverlaps = max2.y > min.y && min2.y < max.y; return xOverlaps && yOverlaps; }, // @method isValid(): Boolean // Returns `true` if the bounds are properly initialized. isValid: function isValid() { return !!(this.min && this.max); }, // @method pad(bufferRatio: Number): Bounds // Returns bounds created by extending or retracting the current bounds by a given ratio in each direction. // For example, a ratio of 0.5 extends the bounds by 50% in each direction. // Negative values will retract the bounds. pad: function pad(bufferRatio) { var min = this.min, max = this.max, heightBuffer = Math.abs(min.x - max.x) * bufferRatio, widthBuffer = Math.abs(min.y - max.y) * bufferRatio; return toBounds(toPoint(min.x - heightBuffer, min.y - widthBuffer), toPoint(max.x + heightBuffer, max.y + widthBuffer)); }, // @method equals(otherBounds: Bounds): Boolean // Returns `true` if the rectangle is equivalent to the given bounds. equals: function equals(bounds) { if (!bounds) { return false; } bounds = toBounds(bounds); return this.min.equals(bounds.getTopLeft()) && this.max.equals(bounds.getBottomRight()); } }; // @factory L.bounds(corner1: Point, corner2: Point) // Creates a Bounds object from two corners coordinate pairs. // @alternative // @factory L.bounds(points: Point[]) // Creates a Bounds object from the given array of points. function toBounds(a, b) { if (!a || a instanceof Bounds) { return a; } return new Bounds(a, b); } /* * @class LatLngBounds * @aka L.LatLngBounds * * Represents a rectangular geographical area on a map. * * @example * * ```js * var corner1 = L.latLng(40.712, -74.227), * corner2 = L.latLng(40.774, -74.125), * bounds = L.latLngBounds(corner1, corner2); * ``` * * All Leaflet methods that accept LatLngBounds objects also accept them in a simple Array form (unless noted otherwise), so the bounds example above can be passed like this: * * ```js * map.fitBounds([ * [40.712, -74.227], * [40.774, -74.125] * ]); * ``` * * Caution: if the area crosses the antimeridian (often confused with the International Date Line), you must specify corners _outside_ the [-180, 180] degrees longitude range. * * Note that `LatLngBounds` does not inherit from Leaflet's `Class` object, * which means new classes can't inherit from it, and new methods * can't be added to it with the `include` function. */ function LatLngBounds(corner1, corner2) { // (LatLng, LatLng) or (LatLng[]) if (!corner1) { return; } var latlngs = corner2 ? [corner1, corner2] : corner1; for (var i = 0, len = latlngs.length; i < len; i++) { this.extend(latlngs[i]); } } LatLngBounds.prototype = { // @method extend(latlng: LatLng): this // Extend the bounds to contain the given point // @alternative // @method extend(otherBounds: LatLngBounds): this // Extend the bounds to contain the given bounds extend: function extend(obj) { var sw = this._southWest, ne = this._northEast, sw2, ne2; if (obj instanceof LatLng) { sw2 = obj; ne2 = obj; } else if (obj instanceof LatLngBounds) { sw2 = obj._southWest; ne2 = obj._northEast; if (!sw2 || !ne2) { return this; } } else { return obj ? this.extend(toLatLng(obj) || toLatLngBounds(obj)) : this; } if (!sw && !ne) { this._southWest = new LatLng(sw2.lat, sw2.lng); this._northEast = new LatLng(ne2.lat, ne2.lng); } else { sw.lat = Math.min(sw2.lat, sw.lat); sw.lng = Math.min(sw2.lng, sw.lng); ne.lat = Math.max(ne2.lat, ne.lat); ne.lng = Math.max(ne2.lng, ne.lng); } return this; }, // @method pad(bufferRatio: Number): LatLngBounds // Returns bounds created by extending or retracting the current bounds by a given ratio in each direction. // For example, a ratio of 0.5 extends the bounds by 50% in each direction. // Negative values will retract the bounds. pad: function pad(bufferRatio) { var sw = this._southWest, ne = this._northEast, heightBuffer = Math.abs(sw.lat - ne.lat) * bufferRatio, widthBuffer = Math.abs(sw.lng - ne.lng) * bufferRatio; return new LatLngBounds(new LatLng(sw.lat - heightBuffer, sw.lng - widthBuffer), new LatLng(ne.lat + heightBuffer, ne.lng + widthBuffer)); }, // @method getCenter(): LatLng // Returns the center point of the bounds. getCenter: function getCenter() { return new LatLng((this._southWest.lat + this._northEast.lat) / 2, (this._southWest.lng + this._northEast.lng) / 2); }, // @method getSouthWest(): LatLng // Returns the south-west point of the bounds. getSouthWest: function getSouthWest() { return this._southWest; }, // @method getNorthEast(): LatLng // Returns the north-east point of the bounds. getNorthEast: function getNorthEast() { return this._northEast; }, // @method getNorthWest(): LatLng // Returns the north-west point of the bounds. getNorthWest: function getNorthWest() { return new LatLng(this.getNorth(), this.getWest()); }, // @method getSouthEast(): LatLng // Returns the south-east point of the bounds. getSouthEast: function getSouthEast() { return new LatLng(this.getSouth(), this.getEast()); }, // @method getWest(): Number // Returns the west longitude of the bounds getWest: function getWest() { return this._southWest.lng; }, // @method getSouth(): Number // Returns the south latitude of the bounds getSouth: function getSouth() { return this._southWest.lat; }, // @method getEast(): Number // Returns the east longitude of the bounds getEast: function getEast() { return this._northEast.lng; }, // @method getNorth(): Number // Returns the north latitude of the bounds getNorth: function getNorth() { return this._northEast.lat; }, // @method contains(otherBounds: LatLngBounds): Boolean // Returns `true` if the rectangle contains the given one. // @alternative // @method contains (latlng: LatLng): Boolean // Returns `true` if the rectangle contains the given point. contains: function contains(obj) { // (LatLngBounds) or (LatLng) -> Boolean if (typeof obj[0] === 'number' || obj instanceof LatLng || 'lat' in obj) { obj = toLatLng(obj); } else { obj = toLatLngBounds(obj); } var sw = this._southWest, ne = this._northEast, sw2, ne2; if (obj instanceof LatLngBounds) { sw2 = obj.getSouthWest(); ne2 = obj.getNorthEast(); } else { sw2 = ne2 = obj; } return sw2.lat >= sw.lat && ne2.lat <= ne.lat && sw2.lng >= sw.lng && ne2.lng <= ne.lng; }, // @method intersects(otherBounds: LatLngBounds): Boolean // Returns `true` if the rectangle intersects the given bounds. Two bounds intersect if they have at least one point in common. intersects: function intersects(bounds) { bounds = toLatLngBounds(bounds); var sw = this._southWest, ne = this._northEast, sw2 = bounds.getSouthWest(), ne2 = bounds.getNorthEast(), latIntersects = ne2.lat >= sw.lat && sw2.lat <= ne.lat, lngIntersects = ne2.lng >= sw.lng && sw2.lng <= ne.lng; return latIntersects && lngIntersects; }, // @method overlaps(otherBounds: LatLngBounds): Boolean // Returns `true` if the rectangle overlaps the given bounds. Two bounds overlap if their intersection is an area. overlaps: function overlaps(bounds) { bounds = toLatLngBounds(bounds); var sw = this._southWest, ne = this._northEast, sw2 = bounds.getSouthWest(), ne2 = bounds.getNorthEast(), latOverlaps = ne2.lat > sw.lat && sw2.lat < ne.lat, lngOverlaps = ne2.lng > sw.lng && sw2.lng < ne.lng; return latOverlaps && lngOverlaps; }, // @method toBBoxString(): String // Returns a string with bounding box coordinates in a 'southwest_lng,southwest_lat,northeast_lng,northeast_lat' format. Useful for sending requests to web services that return geo data. toBBoxString: function toBBoxString() { return [this.getWest(), this.getSouth(), this.getEast(), this.getNorth()].join(','); }, // @method equals(otherBounds: LatLngBounds, maxMargin?: Number): Boolean // Returns `true` if the rectangle is equivalent (within a small margin of error) to the given bounds. The margin of error can be overridden by setting `maxMargin` to a small number. equals: function equals(bounds, maxMargin) { if (!bounds) { return false; } bounds = toLatLngBounds(bounds); return this._southWest.equals(bounds.getSouthWest(), maxMargin) && this._northEast.equals(bounds.getNorthEast(), maxMargin); }, // @method isValid(): Boolean // Returns `true` if the bounds are properly initialized. isValid: function isValid() { return !!(this._southWest && this._northEast); } }; // TODO International date line? // @factory L.latLngBounds(corner1: LatLng, corner2: LatLng) // Creates a `LatLngBounds` object by defining two diagonally opposite corners of the rectangle. // @alternative // @factory L.latLngBounds(latlngs: LatLng[]) // Creates a `LatLngBounds` object defined by the geographical points it contains. Very useful for zooming the map to fit a particular set of locations with [`fitBounds`](#map-fitbounds). function toLatLngBounds(a, b) { if (a instanceof LatLngBounds) { return a; } return new LatLngBounds(a, b); } /* @class LatLng * @aka L.LatLng * * Represents a geographical point with a certain latitude and longitude. * * @example * * ``` * var latlng = L.latLng(50.5, 30.5); * ``` * * All Leaflet methods that accept LatLng objects also accept them in a simple Array form and simple object form (unless noted otherwise), so these lines are equivalent: * * ``` * map.panTo([50, 30]); * map.panTo({lon: 30, lat: 50}); * map.panTo({lat: 50, lng: 30}); * map.panTo(L.latLng(50, 30)); * ``` * * Note that `LatLng` does not inherit from Leaflet's `Class` object, * which means new classes can't inherit from it, and new methods * can't be added to it with the `include` function. */ function LatLng(lat, lng, alt) { if (isNaN(lat) || isNaN(lng)) { throw new Error('Invalid LatLng object: (' + lat + ', ' + lng + ')'); } // @property lat: Number // Latitude in degrees this.lat = +lat; // @property lng: Number // Longitude in degrees this.lng = +lng; // @property alt: Number // Altitude in meters (optional) if (alt !== undefined) { this.alt = +alt; } } LatLng.prototype = { // @method equals(otherLatLng: LatLng, maxMargin?: Number): Boolean // Returns `true` if the given `LatLng` point is at the same position (within a small margin of error). The margin of error can be overridden by setting `maxMargin` to a small number. equals: function equals(obj, maxMargin) { if (!obj) { return false; } obj = toLatLng(obj); var margin = Math.max(Math.abs(this.lat - obj.lat), Math.abs(this.lng - obj.lng)); return margin <= (maxMargin === undefined ? 1.0E-9 : maxMargin); }, // @method toString(): String // Returns a string representation of the point (for debugging purposes). toString: function toString(precision) { return 'LatLng(' + formatNum(this.lat, precision) + ', ' + formatNum(this.lng, precision) + ')'; }, // @method distanceTo(otherLatLng: LatLng): Number // Returns the distance (in meters) to the given `LatLng` calculated using the [Spherical Law of Cosines](https://en.wikipedia.org/wiki/Spherical_law_of_cosines). distanceTo: function distanceTo(other) { return Earth.distance(this, toLatLng(other)); }, // @method wrap(): LatLng // Returns a new `LatLng` object with the longitude wrapped so it's always between -180 and +180 degrees. wrap: function wrap() { return Earth.wrapLatLng(this); }, // @method toBounds(sizeInMeters: Number): LatLngBounds // Returns a new `LatLngBounds` object in which each boundary is `sizeInMeters/2` meters apart from the `LatLng`. toBounds: function toBounds(sizeInMeters) { var latAccuracy = 180 * sizeInMeters / 40075017, lngAccuracy = latAccuracy / Math.cos(Math.PI / 180 * this.lat); return toLatLngBounds([this.lat - latAccuracy, this.lng - lngAccuracy], [this.lat + latAccuracy, this.lng + lngAccuracy]); }, clone: function clone() { return new LatLng(this.lat, this.lng, this.alt); } }; // @factory L.latLng(latitude: Number, longitude: Number, altitude?: Number): LatLng // Creates an object representing a geographical point with the given latitude and longitude (and optionally altitude). // @alternative // @factory L.latLng(coords: Array): LatLng // Expects an array of the form `[Number, Number]` or `[Number, Number, Number]` instead. // @alternative // @factory L.latLng(coords: Object): LatLng // Expects an plain object of the form `{lat: Number, lng: Number}` or `{lat: Number, lng: Number, alt: Number}` instead. function toLatLng(a, b, c) { if (a instanceof LatLng) { return a; } if (isArray(a) && _typeof(a[0]) !== 'object') { if (a.length === 3) { return new LatLng(a[0], a[1], a[2]); } if (a.length === 2) { return new LatLng(a[0], a[1]); } return null; } if (a === undefined || a === null) { return a; } if (_typeof(a) === 'object' && 'lat' in a) { return new LatLng(a.lat, 'lng' in a ? a.lng : a.lon, a.alt); } if (b === undefined) { return null; } return new LatLng(a, b, c); } /* * @namespace CRS * @crs L.CRS.Base * Object that defines coordinate reference systems for projecting * geographical points into pixel (screen) coordinates and back (and to * coordinates in other units for [WMS](https://en.wikipedia.org/wiki/Web_Map_Service) services). See * [spatial reference system](https://en.wikipedia.org/wiki/Spatial_reference_system). * * Leaflet defines the most usual CRSs by default. If you want to use a * CRS not defined by default, take a look at the * [Proj4Leaflet](https://github.com/kartena/Proj4Leaflet) plugin. * * Note that the CRS instances do not inherit from Leaflet's `Class` object, * and can't be instantiated. Also, new classes can't inherit from them, * and methods can't be added to them with the `include` function. */ var CRS = { // @method latLngToPoint(latlng: LatLng, zoom: Number): Point // Projects geographical coordinates into pixel coordinates for a given zoom. latLngToPoint: function latLngToPoint(latlng, zoom) { var projectedPoint = this.projection.project(latlng), scale = this.scale(zoom); return this.transformation._transform(projectedPoint, scale); }, // @method pointToLatLng(point: Point, zoom: Number): LatLng // The inverse of `latLngToPoint`. Projects pixel coordinates on a given // zoom into geographical coordinates. pointToLatLng: function pointToLatLng(point, zoom) { var scale = this.scale(zoom), untransformedPoint = this.transformation.untransform(point, scale); return this.projection.unproject(untransformedPoint); }, // @method project(latlng: LatLng): Point // Projects geographical coordinates into coordinates in units accepted for // this CRS (e.g. meters for EPSG:3857, for passing it to WMS services). project: function project(latlng) { return this.projection.project(latlng); }, // @method unproject(point: Point): LatLng // Given a projected coordinate returns the corresponding LatLng. // The inverse of `project`. unproject: function unproject(point) { return this.projection.unproject(point); }, // @method scale(zoom: Number): Number // Returns the scale used when transforming projected coordinates into // pixel coordinates for a particular zoom. For example, it returns // `256 * 2^zoom` for Mercator-based CRS. scale: function scale(zoom) { return 256 * Math.pow(2, zoom); }, // @method zoom(scale: Number): Number // Inverse of `scale()`, returns the zoom level corresponding to a scale // factor of `scale`. zoom: function zoom(scale) { return Math.log(scale / 256) / Math.LN2; }, // @method getProjectedBounds(zoom: Number): Bounds // Returns the projection's bounds scaled and transformed for the provided `zoom`. getProjectedBounds: function getProjectedBounds(zoom) { if (this.infinite) { return null; } var b = this.projection.bounds, s = this.scale(zoom), min = this.transformation.transform(b.min, s), max = this.transformation.transform(b.max, s); return new Bounds(min, max); }, // @method distance(latlng1: LatLng, latlng2: LatLng): Number // Returns the distance between two geographical coordinates. // @property code: String // Standard code name of the CRS passed into WMS services (e.g. `'EPSG:3857'`) // // @property wrapLng: Number[] // An array of two numbers defining whether the longitude (horizontal) coordinate // axis wraps around a given range and how. Defaults to `[-180, 180]` in most // geographical CRSs. If `undefined`, the longitude axis does not wrap around. // // @property wrapLat: Number[] // Like `wrapLng`, but for the latitude (vertical) axis. // wrapLng: [min, max], // wrapLat: [min, max], // @property infinite: Boolean // If true, the coordinate space will be unbounded (infinite in both axes) infinite: false, // @method wrapLatLng(latlng: LatLng): LatLng // Returns a `LatLng` where lat and lng has been wrapped according to the // CRS's `wrapLat` and `wrapLng` properties, if they are outside the CRS's bounds. wrapLatLng: function wrapLatLng(latlng) { var lng = this.wrapLng ? wrapNum(latlng.lng, this.wrapLng, true) : latlng.lng, lat = this.wrapLat ? wrapNum(latlng.lat, this.wrapLat, true) : latlng.lat, alt = latlng.alt; return new LatLng(lat, lng, alt); }, // @method wrapLatLngBounds(bounds: LatLngBounds): LatLngBounds // Returns a `LatLngBounds` with the same size as the given one, ensuring // that its center is within the CRS's bounds. // Only accepts actual `L.LatLngBounds` instances, not arrays. wrapLatLngBounds: function wrapLatLngBounds(bounds) { var center = bounds.getCenter(), newCenter = this.wrapLatLng(center), latShift = center.lat - newCenter.lat, lngShift = center.lng - newCenter.lng; if (latShift === 0 && lngShift === 0) { return bounds; } var sw = bounds.getSouthWest(), ne = bounds.getNorthEast(), newSw = new LatLng(sw.lat - latShift, sw.lng - lngShift), newNe = new LatLng(ne.lat - latShift, ne.lng - lngShift); return new LatLngBounds(newSw, newNe); } }; /* * @namespace CRS * @crs L.CRS.Earth * * Serves as the base for CRS that are global such that they cover the earth. * Can only be used as the base for other CRS and cannot be used directly, * since it does not have a `code`, `projection` or `transformation`. `distance()` returns * meters. */ var Earth = extend({}, CRS, { wrapLng: [-180, 180], // Mean Earth Radius, as recommended for use by // the International Union of Geodesy and Geophysics, // see https://rosettacode.org/wiki/Haversine_formula R: 6371000, // distance between two geographical points using spherical law of cosines approximation distance: function distance(latlng1, latlng2) { var rad = Math.PI / 180, lat1 = latlng1.lat * rad, lat2 = latlng2.lat * rad, sinDLat = Math.sin((latlng2.lat - latlng1.lat) * rad / 2), sinDLon = Math.sin((latlng2.lng - latlng1.lng) * rad / 2), a = sinDLat * sinDLat + Math.cos(lat1) * Math.cos(lat2) * sinDLon * sinDLon, c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); return this.R * c; } }); /* * @namespace Projection * @projection L.Projection.SphericalMercator * * Spherical Mercator projection — the most common projection for online maps, * used by almost all free and commercial tile providers. Assumes that Earth is * a sphere. Used by the `EPSG:3857` CRS. */ var earthRadius = 6378137; var SphericalMercator = { R: earthRadius, MAX_LATITUDE: 85.0511287798, project: function project(latlng) { var d = Math.PI / 180, max = this.MAX_LATITUDE, lat = Math.max(Math.min(max, latlng.lat), -max), sin = Math.sin(lat * d); return new Point(this.R * latlng.lng * d, this.R * Math.log((1 + sin) / (1 - sin)) / 2); }, unproject: function unproject(point) { var d = 180 / Math.PI; return new LatLng((2 * Math.atan(Math.exp(point.y / this.R)) - Math.PI / 2) * d, point.x * d / this.R); }, bounds: function () { var d = earthRadius * Math.PI; return new Bounds([-d, -d], [d, d]); }() }; /* * @class Transformation * @aka L.Transformation * * Represents an affine transformation: a set of coefficients `a`, `b`, `c`, `d` * for transforming a point of a form `(x, y)` into `(a*x + b, c*y + d)` and doing * the reverse. Used by Leaflet in its projections code. * * @example * * ```js * var transformation = L.transformation(2, 5, -1, 10), * p = L.point(1, 2), * p2 = transformation.transform(p), // L.point(7, 8) * p3 = transformation.untransform(p2); // L.point(1, 2) * ``` */ // factory new L.Transformation(a: Number, b: Number, c: Number, d: Number) // Creates a `Transformation` object with the given coefficients. function Transformation(a, b, c, d) { if (isArray(a)) { // use array properties this._a = a[0]; this._b = a[1]; this._c = a[2]; this._d = a[3]; return; } this._a = a; this._b = b; this._c = c; this._d = d; } Transformation.prototype = { // @method transform(point: Point, scale?: Number): Point // Returns a transformed point, optionally multiplied by the given scale. // Only accepts actual `L.Point` instances, not arrays. transform: function transform(point, scale) { // (Point, Number) -> Point return this._transform(point.clone(), scale); }, // destructive transform (faster) _transform: function _transform(point, scale) { scale = scale || 1; point.x = scale * (this._a * point.x + this._b); point.y = scale * (this._c * point.y + this._d); return point; }, // @method untransform(point: Point, scale?: Number): Point // Returns the reverse transformation of the given point, optionally divided // by the given scale. Only accepts actual `L.Point` instances, not arrays. untransform: function untransform(point, scale) { scale = scale || 1; return new Point((point.x / scale - this._b) / this._a, (point.y / scale - this._d) / this._c); } }; // factory L.transformation(a: Number, b: Number, c: Number, d: Number) // @factory L.transformation(a: Number, b: Number, c: Number, d: Number) // Instantiates a Transformation object with the given coefficients. // @alternative // @factory L.transformation(coefficients: Array): Transformation // Expects an coefficients array of the form // `[a: Number, b: Number, c: Number, d: Number]`. function toTransformation(a, b, c, d) { return new Transformation(a, b, c, d); } /* * @namespace CRS * @crs L.CRS.EPSG3857 * * The most common CRS for online maps, used by almost all free and commercial * tile providers. Uses Spherical Mercator projection. Set in by default in * Map's `crs` option. */ var EPSG3857 = extend({}, Earth, { code: 'EPSG:3857', projection: SphericalMercator, transformation: function () { var scale = 0.5 / (Math.PI * SphericalMercator.R); return toTransformation(scale, 0.5, -scale, 0.5); }() }); var EPSG900913 = extend({}, EPSG3857, { code: 'EPSG:900913' }); // @namespace SVG; @section // There are several static functions which can be called without instantiating L.SVG: // @function create(name: String): SVGElement // Returns a instance of [SVGElement](https://developer.mozilla.org/docs/Web/API/SVGElement), // corresponding to the class name passed. For example, using 'line' will return // an instance of [SVGLineElement](https://developer.mozilla.org/docs/Web/API/SVGLineElement). function svgCreate(name) { return document.createElementNS('http://www.w3.org/2000/svg', name); } // @function pointsToPath(rings: Point[], closed: Boolean): String // Generates a SVG path string for multiple rings, with each ring turning // into "M..L..L.." instructions function pointsToPath(rings, closed) { var str = '', i, j, len, len2, points, p; for (i = 0, len = rings.length; i < len; i++) { points = rings[i]; for (j = 0, len2 = points.length; j < len2; j++) { p = points[j]; str += (j ? 'L' : 'M') + p.x + ' ' + p.y; } // closes the ring for polygons; "x" is VML syntax str += closed ? Browser.svg ? 'z' : 'x' : ''; } // SVG complains about empty path strings return str || 'M0 0'; } /* * @namespace Browser * @aka L.Browser * * A namespace with static properties for browser/feature detection used by Leaflet internally. * * @example * * ```js * if (L.Browser.ielt9) { * alert('Upgrade your browser, dude!'); * } * ``` */ var style = document.documentElement.style; // @property ie: Boolean; `true` for all Internet Explorer versions (not Edge). var ie = ('ActiveXObject' in window); // @property ielt9: Boolean; `true` for Internet Explorer versions less than 9. var ielt9 = ie && !document.addEventListener; // @property edge: Boolean; `true` for the Edge web browser. var edge = 'msLaunchUri' in navigator && !('documentMode' in document); // @property webkit: Boolean; // `true` for webkit-based browsers like Chrome and Safari (including mobile versions). var webkit = userAgentContains('webkit'); // @property android: Boolean // **Deprecated.** `true` for any browser running on an Android platform. var android = userAgentContains('android'); // @property android23: Boolean; **Deprecated.** `true` for browsers running on Android 2 or Android 3. var android23 = userAgentContains('android 2') || userAgentContains('android 3'); /* See https://stackoverflow.com/a/17961266 for details on detecting stock Android */ var webkitVer = parseInt(/WebKit\/([0-9]+)|$/.exec(navigator.userAgent)[1], 10); // also matches AppleWebKit // @property androidStock: Boolean; **Deprecated.** `true` for the Android stock browser (i.e. not Chrome) var androidStock = android && userAgentContains('Google') && webkitVer < 537 && !('AudioNode' in window); // @property opera: Boolean; `true` for the Opera browser var opera = !!window.opera; // @property chrome: Boolean; `true` for the Chrome browser. var chrome = !edge && userAgentContains('chrome'); // @property gecko: Boolean; `true` for gecko-based browsers like Firefox. var gecko = userAgentContains('gecko') && !webkit && !opera && !ie; // @property safari: Boolean; `true` for the Safari browser. var safari = !chrome && userAgentContains('safari'); var phantom = userAgentContains('phantom'); // @property opera12: Boolean // `true` for the Opera browser supporting CSS transforms (version 12 or later). var opera12 = ('OTransition' in style); // @property win: Boolean; `true` when the browser is running in a Windows platform var win = navigator.platform.indexOf('Win') === 0; // @property ie3d: Boolean; `true` for all Internet Explorer versions supporting CSS transforms. var ie3d = ie && 'transition' in style; // @property webkit3d: Boolean; `true` for webkit-based browsers supporting CSS transforms. var webkit3d = 'WebKitCSSMatrix' in window && 'm11' in new window.WebKitCSSMatrix() && !android23; // @property gecko3d: Boolean; `true` for gecko-based browsers supporting CSS transforms. var gecko3d = ('MozPerspective' in style); // @property any3d: Boolean // `true` for all browsers supporting CSS transforms. var any3d = !window.L_DISABLE_3D && (ie3d || webkit3d || gecko3d) && !opera12 && !phantom; // @property mobile: Boolean; `true` for all browsers running in a mobile device. var mobile = typeof orientation !== 'undefined' || userAgentContains('mobile'); // @property mobileWebkit: Boolean; `true` for all webkit-based browsers in a mobile device. var mobileWebkit = mobile && webkit; // @property mobileWebkit3d: Boolean // `true` for all webkit-based browsers in a mobile device supporting CSS transforms. var mobileWebkit3d = mobile && webkit3d; // @property msPointer: Boolean // `true` for browsers implementing the Microsoft touch events model (notably IE10). var msPointer = !window.PointerEvent && window.MSPointerEvent; // @property pointer: Boolean // `true` for all browsers supporting [pointer events](https://msdn.microsoft.com/en-us/library/dn433244%28v=vs.85%29.aspx). var pointer = !!(window.PointerEvent || msPointer); // @property touchNative: Boolean // `true` for all browsers supporting [touch events](https://developer.mozilla.org/docs/Web/API/Touch_events). // **This does not necessarily mean** that the browser is running in a computer with // a touchscreen, it only means that the browser is capable of understanding // touch events. var touchNative = 'ontouchstart' in window || !!window.TouchEvent; // @property touch: Boolean // `true` for all browsers supporting either [touch](#browser-touch) or [pointer](#browser-pointer) events. // Note: pointer events will be preferred (if available), and processed for all `touch*` listeners. var touch = !window.L_NO_TOUCH && (touchNative || pointer); // @property mobileOpera: Boolean; `true` for the Opera browser in a mobile device. var mobileOpera = mobile && opera; // @property mobileGecko: Boolean // `true` for gecko-based browsers running in a mobile device. var mobileGecko = mobile && gecko; // @property retina: Boolean // `true` for browsers on a high-resolution "retina" screen or on any screen when browser's display zoom is more than 100%. var retina = (window.devicePixelRatio || window.screen.deviceXDPI / window.screen.logicalXDPI) > 1; // @property passiveEvents: Boolean // `true` for browsers that support passive events. var passiveEvents = function () { var supportsPassiveOption = false; try { var opts = Object.defineProperty({}, 'passive', { get: function get() { // eslint-disable-line getter-return supportsPassiveOption = true; } }); window.addEventListener('testPassiveEventSupport', falseFn, opts); window.removeEventListener('testPassiveEventSupport', falseFn, opts); } catch (e) { // Errors can safely be ignored since this is only a browser support test. } return supportsPassiveOption; }(); // @property canvas: Boolean // `true` when the browser supports [``](https://developer.mozilla.org/docs/Web/API/Canvas_API). var canvas$1 = function () { return !!document.createElement('canvas').getContext; }(); // @property svg: Boolean // `true` when the browser supports [SVG](https://developer.mozilla.org/docs/Web/SVG). var svg$1 = !!(document.createElementNS && svgCreate('svg').createSVGRect); var inlineSvg = !!svg$1 && function () { var div = document.createElement('div'); div.innerHTML = ''; return (div.firstChild && div.firstChild.namespaceURI) === 'http://www.w3.org/2000/svg'; }(); // @property vml: Boolean // `true` if the browser supports [VML](https://en.wikipedia.org/wiki/Vector_Markup_Language). var vml = !svg$1 && function () { try { var div = document.createElement('div'); div.innerHTML = ''; var shape = div.firstChild; shape.style.behavior = 'url(#default#VML)'; return shape && _typeof(shape.adj) === 'object'; } catch (e) { return false; } }(); // @property mac: Boolean; `true` when the browser is running in a Mac platform var mac = navigator.platform.indexOf('Mac') === 0; // @property mac: Boolean; `true` when the browser is running in a Linux platform var linux = navigator.platform.indexOf('Linux') === 0; function userAgentContains(str) { return navigator.userAgent.toLowerCase().indexOf(str) >= 0; } var Browser = { ie: ie, ielt9: ielt9, edge: edge, webkit: webkit, android: android, android23: android23, androidStock: androidStock, opera: opera, chrome: chrome, gecko: gecko, safari: safari, phantom: phantom, opera12: opera12, win: win, ie3d: ie3d, webkit3d: webkit3d, gecko3d: gecko3d, any3d: any3d, mobile: mobile, mobileWebkit: mobileWebkit, mobileWebkit3d: mobileWebkit3d, msPointer: msPointer, pointer: pointer, touch: touch, touchNative: touchNative, mobileOpera: mobileOpera, mobileGecko: mobileGecko, retina: retina, passiveEvents: passiveEvents, canvas: canvas$1, svg: svg$1, vml: vml, inlineSvg: inlineSvg, mac: mac, linux: linux }; /* * Extends L.DomEvent to provide touch support for Internet Explorer and Windows-based devices. */ var POINTER_DOWN = Browser.msPointer ? 'MSPointerDown' : 'pointerdown'; var POINTER_MOVE = Browser.msPointer ? 'MSPointerMove' : 'pointermove'; var POINTER_UP = Browser.msPointer ? 'MSPointerUp' : 'pointerup'; var POINTER_CANCEL = Browser.msPointer ? 'MSPointerCancel' : 'pointercancel'; var pEvent = { touchstart: POINTER_DOWN, touchmove: POINTER_MOVE, touchend: POINTER_UP, touchcancel: POINTER_CANCEL }; var handle = { touchstart: _onPointerStart, touchmove: _handlePointer, touchend: _handlePointer, touchcancel: _handlePointer }; var _pointers = {}; var _pointerDocListener = false; // Provides a touch events wrapper for (ms)pointer events. // ref https://www.w3.org/TR/pointerevents/ https://www.w3.org/Bugs/Public/show_bug.cgi?id=22890 function addPointerListener(obj, type, handler) { if (type === 'touchstart') { _addPointerDocListener(); } if (!handle[type]) { console.warn('wrong event specified:', type); return falseFn; } handler = handle[type].bind(this, handler); obj.addEventListener(pEvent[type], handler, false); return handler; } function removePointerListener(obj, type, handler) { if (!pEvent[type]) { console.warn('wrong event specified:', type); return; } obj.removeEventListener(pEvent[type], handler, false); } function _globalPointerDown(e) { _pointers[e.pointerId] = e; } function _globalPointerMove(e) { if (_pointers[e.pointerId]) { _pointers[e.pointerId] = e; } } function _globalPointerUp(e) { delete _pointers[e.pointerId]; } function _addPointerDocListener() { // need to keep track of what pointers and how many are active to provide e.touches emulation if (!_pointerDocListener) { // we listen document as any drags that end by moving the touch off the screen get fired there document.addEventListener(POINTER_DOWN, _globalPointerDown, true); document.addEventListener(POINTER_MOVE, _globalPointerMove, true); document.addEventListener(POINTER_UP, _globalPointerUp, true); document.addEventListener(POINTER_CANCEL, _globalPointerUp, true); _pointerDocListener = true; } } function _handlePointer(handler, e) { if (e.pointerType === (e.MSPOINTER_TYPE_MOUSE || 'mouse')) { return; } e.touches = []; for (var i in _pointers) { e.touches.push(_pointers[i]); } e.changedTouches = [e]; handler(e); } function _onPointerStart(handler, e) { // IE10 specific: MsTouch needs preventDefault. See #2000 if (e.MSPOINTER_TYPE_TOUCH && e.pointerType === e.MSPOINTER_TYPE_TOUCH) { preventDefault(e); } _handlePointer(handler, e); } /* * Extends the event handling code with double tap support for mobile browsers. * * Note: currently most browsers fire native dblclick, with only a few exceptions * (see https://github.com/Leaflet/Leaflet/issues/7012#issuecomment-595087386) */ function makeDblclick(event) { // in modern browsers `type` cannot be just overridden: // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Getter_only var newEvent = {}, prop, i; for (i in event) { prop = event[i]; newEvent[i] = prop && prop.bind ? prop.bind(event) : prop; } event = newEvent; newEvent.type = 'dblclick'; newEvent.detail = 2; newEvent.isTrusted = false; newEvent._simulated = true; // for debug purposes return newEvent; } var delay = 200; function addDoubleTapListener(obj, handler) { // Most browsers handle double tap natively obj.addEventListener('dblclick', handler); // On some platforms the browser doesn't fire native dblclicks for touch events. // It seems that in all such cases `detail` property of `click` event is always `1`. // So here we rely on that fact to avoid excessive 'dblclick' simulation when not needed. var last = 0, detail; function simDblclick(e) { if (e.detail !== 1) { detail = e.detail; // keep in sync to avoid false dblclick in some cases return; } if (e.pointerType === 'mouse' || e.sourceCapabilities && !e.sourceCapabilities.firesTouchEvents) { return; } // When clicking on an , the browser generates a click on its //