(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){ (function (Buffer){ /*! * The buffer module from node.js, for the browser. * * @author Feross Aboukhadijeh * @license MIT */ /* eslint-disable no-proto */ 'use strict' 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 () { return 42 } } return arr.foo() === 42 } catch (e) { return false } } Object.defineProperty(Buffer.prototype, 'parent', { enumerable: true, get: function () { if (!Buffer.isBuffer(this)) return undefined return this.buffer } }) Object.defineProperty(Buffer.prototype, 'offset', { enumerable: true, get: function () { 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,require("buffer").Buffer) },{"base64-js":1,"buffer":2,"ieee754":4}],3:[function(require,module,exports){ 'use strict'; /****************************************************************************** * Created 2008-08-19. * * Dijkstra path-finding functions. Adapted from the Dijkstar Python project. * * Copyright (C) 2008 * Wyatt Baldwin * All rights reserved * * Licensed under the MIT license. * * http://www.opensource.org/licenses/mit-license.php * * 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. *****************************************************************************/ var dijkstra = { single_source_shortest_paths: function(graph, s, d) { // Predecessor map for each node that has been encountered. // node ID => predecessor node ID var predecessors = {}; // Costs of shortest paths from s to all nodes encountered. // node ID => cost var costs = {}; costs[s] = 0; // Costs of shortest paths from s to all nodes encountered; differs from // `costs` in that it provides easy access to the node that currently has // the known shortest path from s. // XXX: Do we actually need both `costs` and `open`? var open = dijkstra.PriorityQueue.make(); open.push(s, 0); var closest, u, v, cost_of_s_to_u, adjacent_nodes, cost_of_e, cost_of_s_to_u_plus_cost_of_e, cost_of_s_to_v, first_visit; while (!open.empty()) { // In the nodes remaining in graph that have a known cost from s, // find the node, u, that currently has the shortest path from s. closest = open.pop(); u = closest.value; cost_of_s_to_u = closest.cost; // Get nodes adjacent to u... adjacent_nodes = graph[u] || {}; // ...and explore the edges that connect u to those nodes, updating // the cost of the shortest paths to any or all of those nodes as // necessary. v is the node across the current edge from u. for (v in adjacent_nodes) { if (adjacent_nodes.hasOwnProperty(v)) { // Get the cost of the edge running from u to v. cost_of_e = adjacent_nodes[v]; // Cost of s to u plus the cost of u to v across e--this is *a* // cost from s to v that may or may not be less than the current // known cost to v. cost_of_s_to_u_plus_cost_of_e = cost_of_s_to_u + cost_of_e; // If we haven't visited v yet OR if the current known cost from s to // v is greater than the new cost we just found (cost of s to u plus // cost of u to v across e), update v's cost in the cost list and // update v's predecessor in the predecessor list (it's now u). cost_of_s_to_v = costs[v]; first_visit = (typeof costs[v] === 'undefined'); if (first_visit || cost_of_s_to_v > cost_of_s_to_u_plus_cost_of_e) { costs[v] = cost_of_s_to_u_plus_cost_of_e; open.push(v, cost_of_s_to_u_plus_cost_of_e); predecessors[v] = u; } } } } if (typeof d !== 'undefined' && typeof costs[d] === 'undefined') { var msg = ['Could not find a path from ', s, ' to ', d, '.'].join(''); throw new Error(msg); } return predecessors; }, extract_shortest_path_from_predecessor_list: function(predecessors, d) { var nodes = []; var u = d; var predecessor; while (u) { nodes.push(u); predecessor = predecessors[u]; u = predecessors[u]; } nodes.reverse(); return nodes; }, find_path: function(graph, s, d) { var predecessors = dijkstra.single_source_shortest_paths(graph, s, d); return dijkstra.extract_shortest_path_from_predecessor_list( predecessors, d); }, /** * A very naive priority queue implementation. */ PriorityQueue: { make: function (opts) { var T = dijkstra.PriorityQueue, t = {}, key; opts = opts || {}; for (key in T) { if (T.hasOwnProperty(key)) { t[key] = T[key]; } } t.queue = []; t.sorter = opts.sorter || T.default_sorter; return t; }, default_sorter: function (a, b) { return a.cost - b.cost; }, /** * Add a new item to the queue and ensure the highest priority element * is at the front of the queue. */ push: function (value, cost) { var item = {value: value, cost: cost}; this.queue.push(item); this.queue.sort(this.sorter); }, /** * Return the highest priority element in the queue. */ pop: function () { return this.queue.shift(); }, empty: function () { return this.queue.length === 0; } } }; // node.js module exports if (typeof module !== 'undefined') { module.exports = dijkstra; } },{}],4:[function(require,module,exports){ 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){ var toString = {}.toString; module.exports = Array.isArray || function (arr) { return toString.call(arr) == '[object Array]'; }; },{}],6:[function(require,module,exports){ // 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){ var canPromise = require('./can-promise') var QRCode = require('./core/qrcode') var CanvasRenderer = require('./renderer/canvas') var SvgRenderer = require('./renderer/svg-tag.js') function renderCanvas (renderFunc, canvas, text, opts, cb) { var args = [].slice.call(arguments, 1) var argsNum = args.length var isLastArgCb = typeof args[argsNum - 1] === 'function' if (!isLastArgCb && !canPromise()) { throw new Error('Callback required as last argument') } if (isLastArgCb) { if (argsNum < 2) { throw new Error('Too few arguments provided') } if (argsNum === 2) { cb = text text = canvas canvas = opts = undefined } else if (argsNum === 3) { if (canvas.getContext && typeof cb === 'undefined') { cb = opts opts = undefined } else { cb = opts opts = text text = canvas canvas = undefined } } } else { if (argsNum < 1) { throw new Error('Too few arguments provided') } if (argsNum === 1) { text = canvas canvas = opts = undefined } else if (argsNum === 2 && !canvas.getContext) { opts = text text = canvas canvas = undefined } return new Promise(function (resolve, reject) { try { var data = QRCode.create(text, opts) resolve(renderFunc(data, canvas, opts)) } catch (e) { reject(e) } }) } try { var data = QRCode.create(text, opts) cb(null, renderFunc(data, canvas, opts)) } catch (e) { cb(e) } } exports.create = QRCode.create exports.toCanvas = renderCanvas.bind(null, CanvasRenderer.render) exports.toDataURL = renderCanvas.bind(null, CanvasRenderer.renderToDataURL) // only svg for now. exports.toString = renderCanvas.bind(null, function (data, _, opts) { return SvgRenderer.render(data, opts) }) },{"./can-promise":8,"./core/qrcode":24,"./renderer/canvas":31,"./renderer/svg-tag.js":32}],8:[function(require,module,exports){ // can-promise has a crash in some versions of react native that dont have // standard global objects // https://github.com/soldair/node-qrcode/issues/157 module.exports = function () { return typeof Promise === 'function' && Promise.prototype && Promise.prototype.then } },{}],9:[function(require,module,exports){ /** * Alignment pattern are fixed reference pattern in defined positions * in a matrix symbology, which enables the decode software to re-synchronise * the coordinate mapping of the image modules in the event of moderate amounts * of distortion of the image. * * Alignment patterns are present only in QR Code symbols of version 2 or larger * and their number depends on the symbol version. */ var getSymbolSize = require('./utils').getSymbolSize /** * Calculate the row/column coordinates of the center module of each alignment pattern * for the specified QR Code version. * * The alignment patterns are positioned symmetrically on either side of the diagonal * running from the top left corner of the symbol to the bottom right corner. * * Since positions are simmetrical only half of the coordinates are returned. * Each item of the array will represent in turn the x and y coordinate. * @see {@link getPositions} * * @param {Number} version QR Code version * @return {Array} Array of coordinate */ exports.getRowColCoords = function getRowColCoords (version) { if (version === 1) return [] var posCount = Math.floor(version / 7) + 2 var size = getSymbolSize(version) var intervals = size === 145 ? 26 : Math.ceil((size - 13) / (2 * posCount - 2)) * 2 var positions = [size - 7] // Last coord is always (size - 7) for (var i = 1; i < posCount - 1; i++) { positions[i] = positions[i - 1] - intervals } positions.push(6) // First coord is always 6 return positions.reverse() } /** * Returns an array containing the positions of each alignment pattern. * Each array's element represent the center point of the pattern as (x, y) coordinates * * Coordinates are calculated expanding the row/column coordinates returned by {@link getRowColCoords} * and filtering out the items that overlaps with finder pattern * * @example * For a Version 7 symbol {@link getRowColCoords} returns values 6, 22 and 38. * The alignment patterns, therefore, are to be centered on (row, column) * positions (6,22), (22,6), (22,22), (22,38), (38,22), (38,38). * Note that the coordinates (6,6), (6,38), (38,6) are occupied by finder patterns * and are not therefore used for alignment patterns. * * var pos = getPositions(7) * // [[6,22], [22,6], [22,22], [22,38], [38,22], [38,38]] * * @param {Number} version QR Code version * @return {Array} Array of coordinates */ exports.getPositions = function getPositions (version) { var coords = [] var pos = exports.getRowColCoords(version) var posLength = pos.length for (var i = 0; i < posLength; i++) { for (var j = 0; j < posLength; j++) { // Skip if position is occupied by finder patterns if ((i === 0 && j === 0) || // top-left (i === 0 && j === posLength - 1) || // bottom-left (i === posLength - 1 && j === 0)) { // top-right continue } coords.push([pos[i], pos[j]]) } } return coords } },{"./utils":28}],10:[function(require,module,exports){ var Mode = require('./mode') /** * Array of characters available in alphanumeric mode * * As per QR Code specification, to each character * is assigned a value from 0 to 44 which in this case coincides * with the array index * * @type {Array} */ var ALPHA_NUM_CHARS = [ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', ' ', '$', '%', '*', '+', '-', '.', '/', ':' ] function AlphanumericData (data) { this.mode = Mode.ALPHANUMERIC this.data = data } AlphanumericData.getBitsLength = function getBitsLength (length) { return 11 * Math.floor(length / 2) + 6 * (length % 2) } AlphanumericData.prototype.getLength = function getLength () { return this.data.length } AlphanumericData.prototype.getBitsLength = function getBitsLength () { return AlphanumericData.getBitsLength(this.data.length) } AlphanumericData.prototype.write = function write (bitBuffer) { var i // Input data characters are divided into groups of two characters // and encoded as 11-bit binary codes. for (i = 0; i + 2 <= this.data.length; i += 2) { // The character value of the first character is multiplied by 45 var value = ALPHA_NUM_CHARS.indexOf(this.data[i]) * 45 // The character value of the second digit is added to the product value += ALPHA_NUM_CHARS.indexOf(this.data[i + 1]) // The sum is then stored as 11-bit binary number bitBuffer.put(value, 11) } // If the number of input data characters is not a multiple of two, // the character value of the final character is encoded as a 6-bit binary number. if (this.data.length % 2) { bitBuffer.put(ALPHA_NUM_CHARS.indexOf(this.data[i]), 6) } } module.exports = AlphanumericData },{"./mode":21}],11:[function(require,module,exports){ function BitBuffer () { this.buffer = [] this.length = 0 } BitBuffer.prototype = { get: function (index) { var bufIndex = Math.floor(index / 8) return ((this.buffer[bufIndex] >>> (7 - index % 8)) & 1) === 1 }, put: function (num, length) { for (var i = 0; i < length; i++) { this.putBit(((num >>> (length - i - 1)) & 1) === 1) } }, getLengthInBits: function () { return this.length }, putBit: function (bit) { var bufIndex = Math.floor(this.length / 8) if (this.buffer.length <= bufIndex) { this.buffer.push(0) } if (bit) { this.buffer[bufIndex] |= (0x80 >>> (this.length % 8)) } this.length++ } } module.exports = BitBuffer },{}],12:[function(require,module,exports){ var BufferUtil = require('../utils/buffer') /** * Helper class to handle QR Code symbol modules * * @param {Number} size Symbol size */ function BitMatrix (size) { if (!size || size < 1) { throw new Error('BitMatrix size must be defined and greater than 0') } this.size = size this.data = BufferUtil.alloc(size * size) this.reservedBit = BufferUtil.alloc(size * size) } /** * Set bit value at specified location * If reserved flag is set, this bit will be ignored during masking process * * @param {Number} row * @param {Number} col * @param {Boolean} value * @param {Boolean} reserved */ BitMatrix.prototype.set = function (row, col, value, reserved) { var index = row * this.size + col this.data[index] = value if (reserved) this.reservedBit[index] = true } /** * Returns bit value at specified location * * @param {Number} row * @param {Number} col * @return {Boolean} */ BitMatrix.prototype.get = function (row, col) { return this.data[row * this.size + col] } /** * Applies xor operator at specified location * (used during masking process) * * @param {Number} row * @param {Number} col * @param {Boolean} value */ BitMatrix.prototype.xor = function (row, col, value) { this.data[row * this.size + col] ^= value } /** * Check if bit at specified location is reserved * * @param {Number} row * @param {Number} col * @return {Boolean} */ BitMatrix.prototype.isReserved = function (row, col) { return this.reservedBit[row * this.size + col] } module.exports = BitMatrix },{"../utils/buffer":34}],13:[function(require,module,exports){ var BufferUtil = require('../utils/buffer') var Mode = require('./mode') function ByteData (data) { this.mode = Mode.BYTE this.data = BufferUtil.from(data) } ByteData.getBitsLength = function getBitsLength (length) { return length * 8 } ByteData.prototype.getLength = function getLength () { return this.data.length } ByteData.prototype.getBitsLength = function getBitsLength () { return ByteData.getBitsLength(this.data.length) } ByteData.prototype.write = function (bitBuffer) { for (var i = 0, l = this.data.length; i < l; i++) { bitBuffer.put(this.data[i], 8) } } module.exports = ByteData },{"../utils/buffer":34,"./mode":21}],14:[function(require,module,exports){ var ECLevel = require('./error-correction-level') var EC_BLOCKS_TABLE = [ // L M Q H 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 2, 2, 4, 1, 2, 4, 4, 2, 4, 4, 4, 2, 4, 6, 5, 2, 4, 6, 6, 2, 5, 8, 8, 4, 5, 8, 8, 4, 5, 8, 11, 4, 8, 10, 11, 4, 9, 12, 16, 4, 9, 16, 16, 6, 10, 12, 18, 6, 10, 17, 16, 6, 11, 16, 19, 6, 13, 18, 21, 7, 14, 21, 25, 8, 16, 20, 25, 8, 17, 23, 25, 9, 17, 23, 34, 9, 18, 25, 30, 10, 20, 27, 32, 12, 21, 29, 35, 12, 23, 34, 37, 12, 25, 34, 40, 13, 26, 35, 42, 14, 28, 38, 45, 15, 29, 40, 48, 16, 31, 43, 51, 17, 33, 45, 54, 18, 35, 48, 57, 19, 37, 51, 60, 19, 38, 53, 63, 20, 40, 56, 66, 21, 43, 59, 70, 22, 45, 62, 74, 24, 47, 65, 77, 25, 49, 68, 81 ] var EC_CODEWORDS_TABLE = [ // L M Q H 7, 10, 13, 17, 10, 16, 22, 28, 15, 26, 36, 44, 20, 36, 52, 64, 26, 48, 72, 88, 36, 64, 96, 112, 40, 72, 108, 130, 48, 88, 132, 156, 60, 110, 160, 192, 72, 130, 192, 224, 80, 150, 224, 264, 96, 176, 260, 308, 104, 198, 288, 352, 120, 216, 320, 384, 132, 240, 360, 432, 144, 280, 408, 480, 168, 308, 448, 532, 180, 338, 504, 588, 196, 364, 546, 650, 224, 416, 600, 700, 224, 442, 644, 750, 252, 476, 690, 816, 270, 504, 750, 900, 300, 560, 810, 960, 312, 588, 870, 1050, 336, 644, 952, 1110, 360, 700, 1020, 1200, 390, 728, 1050, 1260, 420, 784, 1140, 1350, 450, 812, 1200, 1440, 480, 868, 1290, 1530, 510, 924, 1350, 1620, 540, 980, 1440, 1710, 570, 1036, 1530, 1800, 570, 1064, 1590, 1890, 600, 1120, 1680, 1980, 630, 1204, 1770, 2100, 660, 1260, 1860, 2220, 720, 1316, 1950, 2310, 750, 1372, 2040, 2430 ] /** * Returns the number of error correction block that the QR Code should contain * for the specified version and error correction level. * * @param {Number} version QR Code version * @param {Number} errorCorrectionLevel Error correction level * @return {Number} Number of error correction blocks */ exports.getBlocksCount = function getBlocksCount (version, errorCorrectionLevel) { switch (errorCorrectionLevel) { case ECLevel.L: return EC_BLOCKS_TABLE[(version - 1) * 4 + 0] case ECLevel.M: return EC_BLOCKS_TABLE[(version - 1) * 4 + 1] case ECLevel.Q: return EC_BLOCKS_TABLE[(version - 1) * 4 + 2] case ECLevel.H: return EC_BLOCKS_TABLE[(version - 1) * 4 + 3] default: return undefined } } /** * Returns the number of error correction codewords to use for the specified * version and error correction level. * * @param {Number} version QR Code version * @param {Number} errorCorrectionLevel Error correction level * @return {Number} Number of error correction codewords */ exports.getTotalCodewordsCount = function getTotalCodewordsCount (version, errorCorrectionLevel) { switch (errorCorrectionLevel) { case ECLevel.L: return EC_CODEWORDS_TABLE[(version - 1) * 4 + 0] case ECLevel.M: return EC_CODEWORDS_TABLE[(version - 1) * 4 + 1] case ECLevel.Q: return EC_CODEWORDS_TABLE[(version - 1) * 4 + 2] case ECLevel.H: return EC_CODEWORDS_TABLE[(version - 1) * 4 + 3] default: return undefined } } },{"./error-correction-level":15}],15:[function(require,module,exports){ exports.L = { bit: 1 } exports.M = { bit: 0 } exports.Q = { bit: 3 } exports.H = { bit: 2 } function fromString (string) { if (typeof string !== 'string') { throw new Error('Param is not a string') } var lcStr = string.toLowerCase() switch (lcStr) { case 'l': case 'low': return exports.L case 'm': case 'medium': return exports.M case 'q': case 'quartile': return exports.Q case 'h': case 'high': return exports.H default: throw new Error('Unknown EC Level: ' + string) } } exports.isValid = function isValid (level) { return level && typeof level.bit !== 'undefined' && level.bit >= 0 && level.bit < 4 } exports.from = function from (value, defaultValue) { if (exports.isValid(value)) { return value } try { return fromString(value) } catch (e) { return defaultValue } } },{}],16:[function(require,module,exports){ var getSymbolSize = require('./utils').getSymbolSize var FINDER_PATTERN_SIZE = 7 /** * Returns an array containing the positions of each finder pattern. * Each array's element represent the top-left point of the pattern as (x, y) coordinates * * @param {Number} version QR Code version * @return {Array} Array of coordinates */ exports.getPositions = function getPositions (version) { var size = getSymbolSize(version) return [ // top-left [0, 0], // top-right [size - FINDER_PATTERN_SIZE, 0], // bottom-left [0, size - FINDER_PATTERN_SIZE] ] } },{"./utils":28}],17:[function(require,module,exports){ var Utils = require('./utils') var G15 = (1 << 10) | (1 << 8) | (1 << 5) | (1 << 4) | (1 << 2) | (1 << 1) | (1 << 0) var G15_MASK = (1 << 14) | (1 << 12) | (1 << 10) | (1 << 4) | (1 << 1) var G15_BCH = Utils.getBCHDigit(G15) /** * Returns format information with relative error correction bits * * The format information is a 15-bit sequence containing 5 data bits, * with 10 error correction bits calculated using the (15, 5) BCH code. * * @param {Number} errorCorrectionLevel Error correction level * @param {Number} mask Mask pattern * @return {Number} Encoded format information bits */ exports.getEncodedBits = function getEncodedBits (errorCorrectionLevel, mask) { var data = ((errorCorrectionLevel.bit << 3) | mask) var d = data << 10 while (Utils.getBCHDigit(d) - G15_BCH >= 0) { d ^= (G15 << (Utils.getBCHDigit(d) - G15_BCH)) } // xor final data with mask pattern in order to ensure that // no combination of Error Correction Level and data mask pattern // will result in an all-zero data string return ((data << 10) | d) ^ G15_MASK } },{"./utils":28}],18:[function(require,module,exports){ var BufferUtil = require('../utils/buffer') var EXP_TABLE = BufferUtil.alloc(512) var LOG_TABLE = BufferUtil.alloc(256) /** * Precompute the log and anti-log tables for faster computation later * * For each possible value in the galois field 2^8, we will pre-compute * the logarithm and anti-logarithm (exponential) of this value * * ref {@link https://en.wikiversity.org/wiki/Reed%E2%80%93Solomon_codes_for_coders#Introduction_to_mathematical_fields} */ ;(function initTables () { var x = 1 for (var i = 0; i < 255; i++) { EXP_TABLE[i] = x LOG_TABLE[x] = i x <<= 1 // multiply by 2 // The QR code specification says to use byte-wise modulo 100011101 arithmetic. // This means that when a number is 256 or larger, it should be XORed with 0x11D. if (x & 0x100) { // similar to x >= 256, but a lot faster (because 0x100 == 256) x ^= 0x11D } } // Optimization: double the size of the anti-log table so that we don't need to mod 255 to // stay inside the bounds (because we will mainly use this table for the multiplication of // two GF numbers, no more). // @see {@link mul} for (i = 255; i < 512; i++) { EXP_TABLE[i] = EXP_TABLE[i - 255] } }()) /** * Returns log value of n inside Galois Field * * @param {Number} n * @return {Number} */ exports.log = function log (n) { if (n < 1) throw new Error('log(' + n + ')') return LOG_TABLE[n] } /** * Returns anti-log value of n inside Galois Field * * @param {Number} n * @return {Number} */ exports.exp = function exp (n) { return EXP_TABLE[n] } /** * Multiplies two number inside Galois Field * * @param {Number} x * @param {Number} y * @return {Number} */ exports.mul = function mul (x, y) { if (x === 0 || y === 0) return 0 // should be EXP_TABLE[(LOG_TABLE[x] + LOG_TABLE[y]) % 255] if EXP_TABLE wasn't oversized // @see {@link initTables} return EXP_TABLE[LOG_TABLE[x] + LOG_TABLE[y]] } },{"../utils/buffer":34}],19:[function(require,module,exports){ var Mode = require('./mode') var Utils = require('./utils') function KanjiData (data) { this.mode = Mode.KANJI this.data = data } KanjiData.getBitsLength = function getBitsLength (length) { return length * 13 } KanjiData.prototype.getLength = function getLength () { return this.data.length } KanjiData.prototype.getBitsLength = function getBitsLength () { return KanjiData.getBitsLength(this.data.length) } KanjiData.prototype.write = function (bitBuffer) { var i // In the Shift JIS system, Kanji characters are represented by a two byte combination. // These byte values are shifted from the JIS X 0208 values. // JIS X 0208 gives details of the shift coded representation. for (i = 0; i < this.data.length; i++) { var value = Utils.toSJIS(this.data[i]) // For characters with Shift JIS values from 0x8140 to 0x9FFC: if (value >= 0x8140 && value <= 0x9FFC) { // Subtract 0x8140 from Shift JIS value value -= 0x8140 // For characters with Shift JIS values from 0xE040 to 0xEBBF } else if (value >= 0xE040 && value <= 0xEBBF) { // Subtract 0xC140 from Shift JIS value value -= 0xC140 } else { throw new Error( 'Invalid SJIS character: ' + this.data[i] + '\n' + 'Make sure your charset is UTF-8') } // Multiply most significant byte of result by 0xC0 // and add least significant byte to product value = (((value >>> 8) & 0xff) * 0xC0) + (value & 0xff) // Convert result to a 13-bit binary string bitBuffer.put(value, 13) } } module.exports = KanjiData },{"./mode":21,"./utils":28}],20:[function(require,module,exports){ /** * Data mask pattern reference * @type {Object} */ exports.Patterns = { PATTERN000: 0, PATTERN001: 1, PATTERN010: 2, PATTERN011: 3, PATTERN100: 4, PATTERN101: 5, PATTERN110: 6, PATTERN111: 7 } /** * Weighted penalty scores for the undesirable features * @type {Object} */ var PenaltyScores = { N1: 3, N2: 3, N3: 40, N4: 10 } /** * Check if mask pattern value is valid * * @param {Number} mask Mask pattern * @return {Boolean} true if valid, false otherwise */ exports.isValid = function isValid (mask) { return mask != null && mask !== '' && !isNaN(mask) && mask >= 0 && mask <= 7 } /** * Returns mask pattern from a value. * If value is not valid, returns undefined * * @param {Number|String} value Mask pattern value * @return {Number} Valid mask pattern or undefined */ exports.from = function from (value) { return exports.isValid(value) ? parseInt(value, 10) : undefined } /** * Find adjacent modules in row/column with the same color * and assign a penalty value. * * Points: N1 + i * i is the amount by which the number of adjacent modules of the same color exceeds 5 */ exports.getPenaltyN1 = function getPenaltyN1 (data) { var size = data.size var points = 0 var sameCountCol = 0 var sameCountRow = 0 var lastCol = null var lastRow = null for (var row = 0; row < size; row++) { sameCountCol = sameCountRow = 0 lastCol = lastRow = null for (var col = 0; col < size; col++) { var module = data.get(row, col) if (module === lastCol) { sameCountCol++ } else { if (sameCountCol >= 5) points += PenaltyScores.N1 + (sameCountCol - 5) lastCol = module sameCountCol = 1 } module = data.get(col, row) if (module === lastRow) { sameCountRow++ } else { if (sameCountRow >= 5) points += PenaltyScores.N1 + (sameCountRow - 5) lastRow = module sameCountRow = 1 } } if (sameCountCol >= 5) points += PenaltyScores.N1 + (sameCountCol - 5) if (sameCountRow >= 5) points += PenaltyScores.N1 + (sameCountRow - 5) } return points } /** * Find 2x2 blocks with the same color and assign a penalty value * * Points: N2 * (m - 1) * (n - 1) */ exports.getPenaltyN2 = function getPenaltyN2 (data) { var size = data.size var points = 0 for (var row = 0; row < size - 1; row++) { for (var col = 0; col < size - 1; col++) { var last = data.get(row, col) + data.get(row, col + 1) + data.get(row + 1, col) + data.get(row + 1, col + 1) if (last === 4 || last === 0) points++ } } return points * PenaltyScores.N2 } /** * Find 1:1:3:1:1 ratio (dark:light:dark:light:dark) pattern in row/column, * preceded or followed by light area 4 modules wide * * Points: N3 * number of pattern found */ exports.getPenaltyN3 = function getPenaltyN3 (data) { var size = data.size var points = 0 var bitsCol = 0 var bitsRow = 0 for (var row = 0; row < size; row++) { bitsCol = bitsRow = 0 for (var col = 0; col < size; col++) { bitsCol = ((bitsCol << 1) & 0x7FF) | data.get(row, col) if (col >= 10 && (bitsCol === 0x5D0 || bitsCol === 0x05D)) points++ bitsRow = ((bitsRow << 1) & 0x7FF) | data.get(col, row) if (col >= 10 && (bitsRow === 0x5D0 || bitsRow === 0x05D)) points++ } } return points * PenaltyScores.N3 } /** * Calculate proportion of dark modules in entire symbol * * Points: N4 * k * * k is the rating of the deviation of the proportion of dark modules * in the symbol from 50% in steps of 5% */ exports.getPenaltyN4 = function getPenaltyN4 (data) { var darkCount = 0 var modulesCount = data.data.length for (var i = 0; i < modulesCount; i++) darkCount += data.data[i] var k = Math.abs(Math.ceil((darkCount * 100 / modulesCount) / 5) - 10) return k * PenaltyScores.N4 } /** * Return mask value at given position * * @param {Number} maskPattern Pattern reference value * @param {Number} i Row * @param {Number} j Column * @return {Boolean} Mask value */ function getMaskAt (maskPattern, i, j) { switch (maskPattern) { case exports.Patterns.PATTERN000: return (i + j) % 2 === 0 case exports.Patterns.PATTERN001: return i % 2 === 0 case exports.Patterns.PATTERN010: return j % 3 === 0 case exports.Patterns.PATTERN011: return (i + j) % 3 === 0 case exports.Patterns.PATTERN100: return (Math.floor(i / 2) + Math.floor(j / 3)) % 2 === 0 case exports.Patterns.PATTERN101: return (i * j) % 2 + (i * j) % 3 === 0 case exports.Patterns.PATTERN110: return ((i * j) % 2 + (i * j) % 3) % 2 === 0 case exports.Patterns.PATTERN111: return ((i * j) % 3 + (i + j) % 2) % 2 === 0 default: throw new Error('bad maskPattern:' + maskPattern) } } /** * Apply a mask pattern to a BitMatrix * * @param {Number} pattern Pattern reference number * @param {BitMatrix} data BitMatrix data */ exports.applyMask = function applyMask (pattern, data) { var size = data.size for (var col = 0; col < size; col++) { for (var row = 0; row < size; row++) { if (data.isReserved(row, col)) continue data.xor(row, col, getMaskAt(pattern, row, col)) } } } /** * Returns the best mask pattern for data * * @param {BitMatrix} data * @return {Number} Mask pattern reference number */ exports.getBestMask = function getBestMask (data, setupFormatFunc) { var numPatterns = Object.keys(exports.Patterns).length var bestPattern = 0 var lowerPenalty = Infinity for (var p = 0; p < numPatterns; p++) { setupFormatFunc(p) exports.applyMask(p, data) // Calculate penalty var penalty = exports.getPenaltyN1(data) + exports.getPenaltyN2(data) + exports.getPenaltyN3(data) + exports.getPenaltyN4(data) // Undo previously applied mask exports.applyMask(p, data) if (penalty < lowerPenalty) { lowerPenalty = penalty bestPattern = p } } return bestPattern } },{}],21:[function(require,module,exports){ var VersionCheck = require('./version-check') var Regex = require('./regex') /** * Numeric mode encodes data from the decimal digit set (0 - 9) * (byte values 30HEX to 39HEX). * Normally, 3 data characters are represented by 10 bits. * * @type {Object} */ exports.NUMERIC = { id: 'Numeric', bit: 1 << 0, ccBits: [10, 12, 14] } /** * Alphanumeric mode encodes data from a set of 45 characters, * i.e. 10 numeric digits (0 - 9), * 26 alphabetic characters (A - Z), * and 9 symbols (SP, $, %, *, +, -, ., /, :). * Normally, two input characters are represented by 11 bits. * * @type {Object} */ exports.ALPHANUMERIC = { id: 'Alphanumeric', bit: 1 << 1, ccBits: [9, 11, 13] } /** * In byte mode, data is encoded at 8 bits per character. * * @type {Object} */ exports.BYTE = { id: 'Byte', bit: 1 << 2, ccBits: [8, 16, 16] } /** * The Kanji mode efficiently encodes Kanji characters in accordance with * the Shift JIS system based on JIS X 0208. * The Shift JIS values are shifted from the JIS X 0208 values. * JIS X 0208 gives details of the shift coded representation. * Each two-byte character value is compacted to a 13-bit binary codeword. * * @type {Object} */ exports.KANJI = { id: 'Kanji', bit: 1 << 3, ccBits: [8, 10, 12] } /** * Mixed mode will contain a sequences of data in a combination of any of * the modes described above * * @type {Object} */ exports.MIXED = { bit: -1 } /** * Returns the number of bits needed to store the data length * according to QR Code specifications. * * @param {Mode} mode Data mode * @param {Number} version QR Code version * @return {Number} Number of bits */ exports.getCharCountIndicator = function getCharCountIndicator (mode, version) { if (!mode.ccBits) throw new Error('Invalid mode: ' + mode) if (!VersionCheck.isValid(version)) { throw new Error('Invalid version: ' + version) } if (version >= 1 && version < 10) return mode.ccBits[0] else if (version < 27) return mode.ccBits[1] return mode.ccBits[2] } /** * Returns the most efficient mode to store the specified data * * @param {String} dataStr Input data string * @return {Mode} Best mode */ exports.getBestModeForData = function getBestModeForData (dataStr) { if (Regex.testNumeric(dataStr)) return exports.NUMERIC else if (Regex.testAlphanumeric(dataStr)) return exports.ALPHANUMERIC else if (Regex.testKanji(dataStr)) return exports.KANJI else return exports.BYTE } /** * Return mode name as string * * @param {Mode} mode Mode object * @returns {String} Mode name */ exports.toString = function toString (mode) { if (mode && mode.id) return mode.id throw new Error('Invalid mode') } /** * Check if input param is a valid mode object * * @param {Mode} mode Mode object * @returns {Boolean} True if valid mode, false otherwise */ exports.isValid = function isValid (mode) { return mode && mode.bit && mode.ccBits } /** * Get mode object from its name * * @param {String} string Mode name * @returns {Mode} Mode object */ function fromString (string) { if (typeof string !== 'string') { throw new Error('Param is not a string') } var lcStr = string.toLowerCase() switch (lcStr) { case 'numeric': return exports.NUMERIC case 'alphanumeric': return exports.ALPHANUMERIC case 'kanji': return exports.KANJI case 'byte': return exports.BYTE default: throw new Error('Unknown mode: ' + string) } } /** * Returns mode from a value. * If value is not a valid mode, returns defaultValue * * @param {Mode|String} value Encoding mode * @param {Mode} defaultValue Fallback value * @return {Mode} Encoding mode */ exports.from = function from (value, defaultValue) { if (exports.isValid(value)) { return value } try { return fromString(value) } catch (e) { return defaultValue } } },{"./regex":26,"./version-check":29}],22:[function(require,module,exports){ var Mode = require('./mode') function NumericData (data) { this.mode = Mode.NUMERIC this.data = data.toString() } NumericData.getBitsLength = function getBitsLength (length) { return 10 * Math.floor(length / 3) + ((length % 3) ? ((length % 3) * 3 + 1) : 0) } NumericData.prototype.getLength = function getLength () { return this.data.length } NumericData.prototype.getBitsLength = function getBitsLength () { return NumericData.getBitsLength(this.data.length) } NumericData.prototype.write = function write (bitBuffer) { var i, group, value // The input data string is divided into groups of three digits, // and each group is converted to its 10-bit binary equivalent. for (i = 0; i + 3 <= this.data.length; i += 3) { group = this.data.substr(i, 3) value = parseInt(group, 10) bitBuffer.put(value, 10) } // If the number of input digits is not an exact multiple of three, // the final one or two digits are converted to 4 or 7 bits respectively. var remainingNum = this.data.length - i if (remainingNum > 0) { group = this.data.substr(i) value = parseInt(group, 10) bitBuffer.put(value, remainingNum * 3 + 1) } } module.exports = NumericData },{"./mode":21}],23:[function(require,module,exports){ var BufferUtil = require('../utils/buffer') var GF = require('./galois-field') /** * Multiplies two polynomials inside Galois Field * * @param {Buffer} p1 Polynomial * @param {Buffer} p2 Polynomial * @return {Buffer} Product of p1 and p2 */ exports.mul = function mul (p1, p2) { var coeff = BufferUtil.alloc(p1.length + p2.length - 1) for (var i = 0; i < p1.length; i++) { for (var j = 0; j < p2.length; j++) { coeff[i + j] ^= GF.mul(p1[i], p2[j]) } } return coeff } /** * Calculate the remainder of polynomials division * * @param {Buffer} divident Polynomial * @param {Buffer} divisor Polynomial * @return {Buffer} Remainder */ exports.mod = function mod (divident, divisor) { var result = BufferUtil.from(divident) while ((result.length - divisor.length) >= 0) { var coeff = result[0] for (var i = 0; i < divisor.length; i++) { result[i] ^= GF.mul(divisor[i], coeff) } // remove all zeros from buffer head var offset = 0 while (offset < result.length && result[offset] === 0) offset++ result = result.slice(offset) } return result } /** * Generate an irreducible generator polynomial of specified degree * (used by Reed-Solomon encoder) * * @param {Number} degree Degree of the generator polynomial * @return {Buffer} Buffer containing polynomial coefficients */ exports.generateECPolynomial = function generateECPolynomial (degree) { var poly = BufferUtil.from([1]) for (var i = 0; i < degree; i++) { poly = exports.mul(poly, [1, GF.exp(i)]) } return poly } },{"../utils/buffer":34,"./galois-field":18}],24:[function(require,module,exports){ var BufferUtil = require('../utils/buffer') var Utils = require('./utils') var ECLevel = require('./error-correction-level') var BitBuffer = require('./bit-buffer') var BitMatrix = require('./bit-matrix') var AlignmentPattern = require('./alignment-pattern') var FinderPattern = require('./finder-pattern') var MaskPattern = require('./mask-pattern') var ECCode = require('./error-correction-code') var ReedSolomonEncoder = require('./reed-solomon-encoder') var Version = require('./version') var FormatInfo = require('./format-info') var Mode = require('./mode') var Segments = require('./segments') var isArray = require('isarray') /** * QRCode for JavaScript * * modified by Ryan Day for nodejs support * Copyright (c) 2011 Ryan Day * * Licensed under the MIT license: * http://www.opensource.org/licenses/mit-license.php * //--------------------------------------------------------------------- // QRCode for JavaScript // // Copyright (c) 2009 Kazuhiko Arase // // URL: http://www.d-project.com/ // // Licensed under the MIT license: // http://www.opensource.org/licenses/mit-license.php // // The word "QR Code" is registered trademark of // DENSO WAVE INCORPORATED // http://www.denso-wave.com/qrcode/faqpatent-e.html // //--------------------------------------------------------------------- */ /** * Add finder patterns bits to matrix * * @param {BitMatrix} matrix Modules matrix * @param {Number} version QR Code version */ function setupFinderPattern (matrix, version) { var size = matrix.size var pos = FinderPattern.getPositions(version) for (var i = 0; i < pos.length; i++) { var row = pos[i][0] var col = pos[i][1] for (var r = -1; r <= 7; r++) { if (row + r <= -1 || size <= row + r) continue for (var c = -1; c <= 7; c++) { if (col + c <= -1 || size <= col + c) continue if ((r >= 0 && r <= 6 && (c === 0 || c === 6)) || (c >= 0 && c <= 6 && (r === 0 || r === 6)) || (r >= 2 && r <= 4 && c >= 2 && c <= 4)) { matrix.set(row + r, col + c, true, true) } else { matrix.set(row + r, col + c, false, true) } } } } } /** * Add timing pattern bits to matrix * * Note: this function must be called before {@link setupAlignmentPattern} * * @param {BitMatrix} matrix Modules matrix */ function setupTimingPattern (matrix) { var size = matrix.size for (var r = 8; r < size - 8; r++) { var value = r % 2 === 0 matrix.set(r, 6, value, true) matrix.set(6, r, value, true) } } /** * Add alignment patterns bits to matrix * * Note: this function must be called after {@link setupTimingPattern} * * @param {BitMatrix} matrix Modules matrix * @param {Number} version QR Code version */ function setupAlignmentPattern (matrix, version) { var pos = AlignmentPattern.getPositions(version) for (var i = 0; i < pos.length; i++) { var row = pos[i][0] var col = pos[i][1] for (var r = -2; r <= 2; r++) { for (var c = -2; c <= 2; c++) { if (r === -2 || r === 2 || c === -2 || c === 2 || (r === 0 && c === 0)) { matrix.set(row + r, col + c, true, true) } else { matrix.set(row + r, col + c, false, true) } } } } } /** * Add version info bits to matrix * * @param {BitMatrix} matrix Modules matrix * @param {Number} version QR Code version */ function setupVersionInfo (matrix, version) { var size = matrix.size var bits = Version.getEncodedBits(version) var row, col, mod for (var i = 0; i < 18; i++) { row = Math.floor(i / 3) col = i % 3 + size - 8 - 3 mod = ((bits >> i) & 1) === 1 matrix.set(row, col, mod, true) matrix.set(col, row, mod, true) } } /** * Add format info bits to matrix * * @param {BitMatrix} matrix Modules matrix * @param {ErrorCorrectionLevel} errorCorrectionLevel Error correction level * @param {Number} maskPattern Mask pattern reference value */ function setupFormatInfo (matrix, errorCorrectionLevel, maskPattern) { var size = matrix.size var bits = FormatInfo.getEncodedBits(errorCorrectionLevel, maskPattern) var i, mod for (i = 0; i < 15; i++) { mod = ((bits >> i) & 1) === 1 // vertical if (i < 6) { matrix.set(i, 8, mod, true) } else if (i < 8) { matrix.set(i + 1, 8, mod, true) } else { matrix.set(size - 15 + i, 8, mod, true) } // horizontal if (i < 8) { matrix.set(8, size - i - 1, mod, true) } else if (i < 9) { matrix.set(8, 15 - i - 1 + 1, mod, true) } else { matrix.set(8, 15 - i - 1, mod, true) } } // fixed module matrix.set(size - 8, 8, 1, true) } /** * Add encoded data bits to matrix * * @param {BitMatrix} matrix Modules matrix * @param {Buffer} data Data codewords */ function setupData (matrix, data) { var size = matrix.size var inc = -1 var row = size - 1 var bitIndex = 7 var byteIndex = 0 for (var col = size - 1; col > 0; col -= 2) { if (col === 6) col-- while (true) { for (var c = 0; c < 2; c++) { if (!matrix.isReserved(row, col - c)) { var dark = false if (byteIndex < data.length) { dark = (((data[byteIndex] >>> bitIndex) & 1) === 1) } matrix.set(row, col - c, dark) bitIndex-- if (bitIndex === -1) { byteIndex++ bitIndex = 7 } } } row += inc if (row < 0 || size <= row) { row -= inc inc = -inc break } } } } /** * Create encoded codewords from data input * * @param {Number} version QR Code version * @param {ErrorCorrectionLevel} errorCorrectionLevel Error correction level * @param {ByteData} data Data input * @return {Buffer} Buffer containing encoded codewords */ function createData (version, errorCorrectionLevel, segments) { // Prepare data buffer var buffer = new BitBuffer() segments.forEach(function (data) { // prefix data with mode indicator (4 bits) buffer.put(data.mode.bit, 4) // Prefix data with character count indicator. // The character count indicator is a string of bits that represents the // number of characters that are being encoded. // The character count indicator must be placed after the mode indicator // and must be a certain number of bits long, depending on the QR version // and data mode // @see {@link Mode.getCharCountIndicator}. buffer.put(data.getLength(), Mode.getCharCountIndicator(data.mode, version)) // add binary data sequence to buffer data.write(buffer) }) // Calculate required number of bits var totalCodewords = Utils.getSymbolTotalCodewords(version) var ecTotalCodewords = ECCode.getTotalCodewordsCount(version, errorCorrectionLevel) var dataTotalCodewordsBits = (totalCodewords - ecTotalCodewords) * 8 // Add a terminator. // If the bit string is shorter than the total number of required bits, // a terminator of up to four 0s must be added to the right side of the string. // If the bit string is more than four bits shorter than the required number of bits, // add four 0s to the end. if (buffer.getLengthInBits() + 4 <= dataTotalCodewordsBits) { buffer.put(0, 4) } // If the bit string is fewer than four bits shorter, add only the number of 0s that // are needed to reach the required number of bits. // After adding the terminator, if the number of bits in the string is not a multiple of 8, // pad the string on the right with 0s to make the string's length a multiple of 8. while (buffer.getLengthInBits() % 8 !== 0) { buffer.putBit(0) } // Add pad bytes if the string is still shorter than the total number of required bits. // Extend the buffer to fill the data capacity of the symbol corresponding to // the Version and Error Correction Level by adding the Pad Codewords 11101100 (0xEC) // and 00010001 (0x11) alternately. var remainingByte = (dataTotalCodewordsBits - buffer.getLengthInBits()) / 8 for (var i = 0; i < remainingByte; i++) { buffer.put(i % 2 ? 0x11 : 0xEC, 8) } return createCodewords(buffer, version, errorCorrectionLevel) } /** * Encode input data with Reed-Solomon and return codewords with * relative error correction bits * * @param {BitBuffer} bitBuffer Data to encode * @param {Number} version QR Code version * @param {ErrorCorrectionLevel} errorCorrectionLevel Error correction level * @return {Buffer} Buffer containing encoded codewords */ function createCodewords (bitBuffer, version, errorCorrectionLevel) { // Total codewords for this QR code version (Data + Error correction) var totalCodewords = Utils.getSymbolTotalCodewords(version) // Total number of error correction codewords var ecTotalCodewords = ECCode.getTotalCodewordsCount(version, errorCorrectionLevel) // Total number of data codewords var dataTotalCodewords = totalCodewords - ecTotalCodewords // Total number of blocks var ecTotalBlocks = ECCode.getBlocksCount(version, errorCorrectionLevel) // Calculate how many blocks each group should contain var blocksInGroup2 = totalCodewords % ecTotalBlocks var blocksInGroup1 = ecTotalBlocks - blocksInGroup2 var totalCodewordsInGroup1 = Math.floor(totalCodewords / ecTotalBlocks) var dataCodewordsInGroup1 = Math.floor(dataTotalCodewords / ecTotalBlocks) var dataCodewordsInGroup2 = dataCodewordsInGroup1 + 1 // Number of EC codewords is the same for both groups var ecCount = totalCodewordsInGroup1 - dataCodewordsInGroup1 // Initialize a Reed-Solomon encoder with a generator polynomial of degree ecCount var rs = new ReedSolomonEncoder(ecCount) var offset = 0 var dcData = new Array(ecTotalBlocks) var ecData = new Array(ecTotalBlocks) var maxDataSize = 0 var buffer = BufferUtil.from(bitBuffer.buffer) // Divide the buffer into the required number of blocks for (var b = 0; b < ecTotalBlocks; b++) { var dataSize = b < blocksInGroup1 ? dataCodewordsInGroup1 : dataCodewordsInGroup2 // extract a block of data from buffer dcData[b] = buffer.slice(offset, offset + dataSize) // Calculate EC codewords for this data block ecData[b] = rs.encode(dcData[b]) offset += dataSize maxDataSize = Math.max(maxDataSize, dataSize) } // Create final data // Interleave the data and error correction codewords from each block var data = BufferUtil.alloc(totalCodewords) var index = 0 var i, r // Add data codewords for (i = 0; i < maxDataSize; i++) { for (r = 0; r < ecTotalBlocks; r++) { if (i < dcData[r].length) { data[index++] = dcData[r][i] } } } // Apped EC codewords for (i = 0; i < ecCount; i++) { for (r = 0; r < ecTotalBlocks; r++) { data[index++] = ecData[r][i] } } return data } /** * Build QR Code symbol * * @param {String} data Input string * @param {Number} version QR Code version * @param {ErrorCorretionLevel} errorCorrectionLevel Error level * @param {MaskPattern} maskPattern Mask pattern * @return {Object} Object containing symbol data */ function createSymbol (data, version, errorCorrectionLevel, maskPattern) { var segments if (isArray(data)) { segments = Segments.fromArray(data) } else if (typeof data === 'string') { var estimatedVersion = version if (!estimatedVersion) { var rawSegments = Segments.rawSplit(data) // Estimate best version that can contain raw splitted segments estimatedVersion = Version.getBestVersionForData(rawSegments, errorCorrectionLevel) } // Build optimized segments // If estimated version is undefined, try with the highest version segments = Segments.fromString(data, estimatedVersion || 40) } else { throw new Error('Invalid data') } // Get the min version that can contain data var bestVersion = Version.getBestVersionForData(segments, errorCorrectionLevel) // If no version is found, data cannot be stored if (!bestVersion) { throw new Error('The amount of data is too big to be stored in a QR Code') } // If not specified, use min version as default if (!version) { version = bestVersion // Check if the specified version can contain the data } else if (version < bestVersion) { throw new Error('\n' + 'The chosen QR Code version cannot contain this amount of data.\n' + 'Minimum version required to store current data is: ' + bestVersion + '.\n' ) } var dataBits = createData(version, errorCorrectionLevel, segments) // Allocate matrix buffer var moduleCount = Utils.getSymbolSize(version) var modules = new BitMatrix(moduleCount) // Add function modules setupFinderPattern(modules, version) setupTimingPattern(modules) setupAlignmentPattern(modules, version) // Add temporary dummy bits for format info just to set them as reserved. // This is needed to prevent these bits from being masked by {@link MaskPattern.applyMask} // since the masking operation must be performed only on the encoding region. // These blocks will be replaced with correct values later in code. setupFormatInfo(modules, errorCorrectionLevel, 0) if (version >= 7) { setupVersionInfo(modules, version) } // Add data codewords setupData(modules, dataBits) if (isNaN(maskPattern)) { // Find best mask pattern maskPattern = MaskPattern.getBestMask(modules, setupFormatInfo.bind(null, modules, errorCorrectionLevel)) } // Apply mask pattern MaskPattern.applyMask(maskPattern, modules) // Replace format info bits with correct values setupFormatInfo(modules, errorCorrectionLevel, maskPattern) return { modules: modules, version: version, errorCorrectionLevel: errorCorrectionLevel, maskPattern: maskPattern, segments: segments } } /** * QR Code * * @param {String | Array} data Input data * @param {Object} options Optional configurations * @param {Number} options.version QR Code version * @param {String} options.errorCorrectionLevel Error correction level * @param {Function} options.toSJISFunc Helper func to convert utf8 to sjis */ exports.create = function create (data, options) { if (typeof data === 'undefined' || data === '') { throw new Error('No input text') } var errorCorrectionLevel = ECLevel.M var version var mask if (typeof options !== 'undefined') { // Use higher error correction level as default errorCorrectionLevel = ECLevel.from(options.errorCorrectionLevel, ECLevel.M) version = Version.from(options.version) mask = MaskPattern.from(options.maskPattern) if (options.toSJISFunc) { Utils.setToSJISFunction(options.toSJISFunc) } } return createSymbol(data, version, errorCorrectionLevel, mask) } },{"../utils/buffer":34,"./alignment-pattern":9,"./bit-buffer":11,"./bit-matrix":12,"./error-correction-code":14,"./error-correction-level":15,"./finder-pattern":16,"./format-info":17,"./mask-pattern":20,"./mode":21,"./reed-solomon-encoder":25,"./segments":27,"./utils":28,"./version":30,"isarray":5}],25:[function(require,module,exports){ var BufferUtil = require('../utils/buffer') var Polynomial = require('./polynomial') var Buffer = require('buffer').Buffer function ReedSolomonEncoder (degree) { this.genPoly = undefined this.degree = degree if (this.degree) this.initialize(this.degree) } /** * Initialize the encoder. * The input param should correspond to the number of error correction codewords. * * @param {Number} degree */ ReedSolomonEncoder.prototype.initialize = function initialize (degree) { // create an irreducible generator polynomial this.degree = degree this.genPoly = Polynomial.generateECPolynomial(this.degree) } /** * Encodes a chunk of data * * @param {Buffer} data Buffer containing input data * @return {Buffer} Buffer containing encoded data */ ReedSolomonEncoder.prototype.encode = function encode (data) { if (!this.genPoly) { throw new Error('Encoder not initialized') } // Calculate EC for this data block // extends data size to data+genPoly size var pad = BufferUtil.alloc(this.degree) var paddedData = Buffer.concat([data, pad], data.length + this.degree) // The error correction codewords are the remainder after dividing the data codewords // by a generator polynomial var remainder = Polynomial.mod(paddedData, this.genPoly) // return EC data blocks (last n byte, where n is the degree of genPoly) // If coefficients number in remainder are less than genPoly degree, // pad with 0s to the left to reach the needed number of coefficients var start = this.degree - remainder.length if (start > 0) { var buff = BufferUtil.alloc(this.degree) remainder.copy(buff, start) return buff } return remainder } module.exports = ReedSolomonEncoder },{"../utils/buffer":34,"./polynomial":23,"buffer":2}],26:[function(require,module,exports){ var numeric = '[0-9]+' var alphanumeric = '[A-Z $%*+\\-./:]+' var kanji = '(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|' + '[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|' + '[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|' + '[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+' kanji = kanji.replace(/u/g, '\\u') var byte = '(?:(?![A-Z0-9 $%*+\\-./:]|' + kanji + ')(?:.|[\r\n]))+' exports.KANJI = new RegExp(kanji, 'g') exports.BYTE_KANJI = new RegExp('[^A-Z0-9 $%*+\\-./:]+', 'g') exports.BYTE = new RegExp(byte, 'g') exports.NUMERIC = new RegExp(numeric, 'g') exports.ALPHANUMERIC = new RegExp(alphanumeric, 'g') var TEST_KANJI = new RegExp('^' + kanji + '$') var TEST_NUMERIC = new RegExp('^' + numeric + '$') var TEST_ALPHANUMERIC = new RegExp('^[A-Z0-9 $%*+\\-./:]+$') exports.testKanji = function testKanji (str) { return TEST_KANJI.test(str) } exports.testNumeric = function testNumeric (str) { return TEST_NUMERIC.test(str) } exports.testAlphanumeric = function testAlphanumeric (str) { return TEST_ALPHANUMERIC.test(str) } },{}],27:[function(require,module,exports){ var Mode = require('./mode') var NumericData = require('./numeric-data') var AlphanumericData = require('./alphanumeric-data') var ByteData = require('./byte-data') var KanjiData = require('./kanji-data') var Regex = require('./regex') var Utils = require('./utils') var dijkstra = require('dijkstrajs') /** * Returns UTF8 byte length * * @param {String} str Input string * @return {Number} Number of byte */ function getStringByteLength (str) { return unescape(encodeURIComponent(str)).length } /** * Get a list of segments of the specified mode * from a string * * @param {Mode} mode Segment mode * @param {String} str String to process * @return {Array} Array of object with segments data */ function getSegments (regex, mode, str) { var segments = [] var result while ((result = regex.exec(str)) !== null) { segments.push({ data: result[0], index: result.index, mode: mode, length: result[0].length }) } return segments } /** * Extracts a series of segments with the appropriate * modes from a string * * @param {String} dataStr Input string * @return {Array} Array of object with segments data */ function getSegmentsFromString (dataStr) { var numSegs = getSegments(Regex.NUMERIC, Mode.NUMERIC, dataStr) var alphaNumSegs = getSegments(Regex.ALPHANUMERIC, Mode.ALPHANUMERIC, dataStr) var byteSegs var kanjiSegs if (Utils.isKanjiModeEnabled()) { byteSegs = getSegments(Regex.BYTE, Mode.BYTE, dataStr) kanjiSegs = getSegments(Regex.KANJI, Mode.KANJI, dataStr) } else { byteSegs = getSegments(Regex.BYTE_KANJI, Mode.BYTE, dataStr) kanjiSegs = [] } var segs = numSegs.concat(alphaNumSegs, byteSegs, kanjiSegs) return segs .sort(function (s1, s2) { return s1.index - s2.index }) .map(function (obj) { return { data: obj.data, mode: obj.mode, length: obj.length } }) } /** * Returns how many bits are needed to encode a string of * specified length with the specified mode * * @param {Number} length String length * @param {Mode} mode Segment mode * @return {Number} Bit length */ function getSegmentBitsLength (length, mode) { switch (mode) { case Mode.NUMERIC: return NumericData.getBitsLength(length) case Mode.ALPHANUMERIC: return AlphanumericData.getBitsLength(length) case Mode.KANJI: return KanjiData.getBitsLength(length) case Mode.BYTE: return ByteData.getBitsLength(length) } } /** * Merges adjacent segments which have the same mode * * @param {Array} segs Array of object with segments data * @return {Array} Array of object with segments data */ function mergeSegments (segs) { return segs.reduce(function (acc, curr) { var prevSeg = acc.length - 1 >= 0 ? acc[acc.length - 1] : null if (prevSeg && prevSeg.mode === curr.mode) { acc[acc.length - 1].data += curr.data return acc } acc.push(curr) return acc }, []) } /** * Generates a list of all possible nodes combination which * will be used to build a segments graph. * * Nodes are divided by groups. Each group will contain a list of all the modes * in which is possible to encode the given text. * * For example the text '12345' can be encoded as Numeric, Alphanumeric or Byte. * The group for '12345' will contain then 3 objects, one for each * possible encoding mode. * * Each node represents a possible segment. * * @param {Array} segs Array of object with segments data * @return {Array} Array of object with segments data */ function buildNodes (segs) { var nodes = [] for (var i = 0; i < segs.length; i++) { var seg = segs[i] switch (seg.mode) { case Mode.NUMERIC: nodes.push([seg, { data: seg.data, mode: Mode.ALPHANUMERIC, length: seg.length }, { data: seg.data, mode: Mode.BYTE, length: seg.length } ]) break case Mode.ALPHANUMERIC: nodes.push([seg, { data: seg.data, mode: Mode.BYTE, length: seg.length } ]) break case Mode.KANJI: nodes.push([seg, { data: seg.data, mode: Mode.BYTE, length: getStringByteLength(seg.data) } ]) break case Mode.BYTE: nodes.push([ { data: seg.data, mode: Mode.BYTE, length: getStringByteLength(seg.data) } ]) } } return nodes } /** * Builds a graph from a list of nodes. * All segments in each node group will be connected with all the segments of * the next group and so on. * * At each connection will be assigned a weight depending on the * segment's byte length. * * @param {Array} nodes Array of object with segments data * @param {Number} version QR Code version * @return {Object} Graph of all possible segments */ function buildGraph (nodes, version) { var table = {} var graph = {'start': {}} var prevNodeIds = ['start'] for (var i = 0; i < nodes.length; i++) { var nodeGroup = nodes[i] var currentNodeIds = [] for (var j = 0; j < nodeGroup.length; j++) { var node = nodeGroup[j] var key = '' + i + j currentNodeIds.push(key) table[key] = { node: node, lastCount: 0 } graph[key] = {} for (var n = 0; n < prevNodeIds.length; n++) { var prevNodeId = prevNodeIds[n] if (table[prevNodeId] && table[prevNodeId].node.mode === node.mode) { graph[prevNodeId][key] = getSegmentBitsLength(table[prevNodeId].lastCount + node.length, node.mode) - getSegmentBitsLength(table[prevNodeId].lastCount, node.mode) table[prevNodeId].lastCount += node.length } else { if (table[prevNodeId]) table[prevNodeId].lastCount = node.length graph[prevNodeId][key] = getSegmentBitsLength(node.length, node.mode) + 4 + Mode.getCharCountIndicator(node.mode, version) // switch cost } } } prevNodeIds = currentNodeIds } for (n = 0; n < prevNodeIds.length; n++) { graph[prevNodeIds[n]]['end'] = 0 } return { map: graph, table: table } } /** * Builds a segment from a specified data and mode. * If a mode is not specified, the more suitable will be used. * * @param {String} data Input data * @param {Mode | String} modesHint Data mode * @return {Segment} Segment */ function buildSingleSegment (data, modesHint) { var mode var bestMode = Mode.getBestModeForData(data) mode = Mode.from(modesHint, bestMode) // Make sure data can be encoded if (mode !== Mode.BYTE && mode.bit < bestMode.bit) { throw new Error('"' + data + '"' + ' cannot be encoded with mode ' + Mode.toString(mode) + '.\n Suggested mode is: ' + Mode.toString(bestMode)) } // Use Mode.BYTE if Kanji support is disabled if (mode === Mode.KANJI && !Utils.isKanjiModeEnabled()) { mode = Mode.BYTE } switch (mode) { case Mode.NUMERIC: return new NumericData(data) case Mode.ALPHANUMERIC: return new AlphanumericData(data) case Mode.KANJI: return new KanjiData(data) case Mode.BYTE: return new ByteData(data) } } /** * Builds a list of segments from an array. * Array can contain Strings or Objects with segment's info. * * For each item which is a string, will be generated a segment with the given * string and the more appropriate encoding mode. * * For each item which is an object, will be generated a segment with the given * data and mode. * Objects must contain at least the property "data". * If property "mode" is not present, the more suitable mode will be used. * * @param {Array} array Array of objects with segments data * @return {Array} Array of Segments */ exports.fromArray = function fromArray (array) { return array.reduce(function (acc, seg) { if (typeof seg === 'string') { acc.push(buildSingleSegment(seg, null)) } else if (seg.data) { acc.push(buildSingleSegment(seg.data, seg.mode)) } return acc }, []) } /** * Builds an optimized sequence of segments from a string, * which will produce the shortest possible bitstream. * * @param {String} data Input string * @param {Number} version QR Code version * @return {Array} Array of segments */ exports.fromString = function fromString (data, version) { var segs = getSegmentsFromString(data, Utils.isKanjiModeEnabled()) var nodes = buildNodes(segs) var graph = buildGraph(nodes, version) var path = dijkstra.find_path(graph.map, 'start', 'end') var optimizedSegs = [] for (var i = 1; i < path.length - 1; i++) { optimizedSegs.push(graph.table[path[i]].node) } return exports.fromArray(mergeSegments(optimizedSegs)) } /** * Splits a string in various segments with the modes which * best represent their content. * The produced segments are far from being optimized. * The output of this function is only used to estimate a QR Code version * which may contain the data. * * @param {string} data Input string * @return {Array} Array of segments */ exports.rawSplit = function rawSplit (data) { return exports.fromArray( getSegmentsFromString(data, Utils.isKanjiModeEnabled()) ) } },{"./alphanumeric-data":10,"./byte-data":13,"./kanji-data":19,"./mode":21,"./numeric-data":22,"./regex":26,"./utils":28,"dijkstrajs":3}],28:[function(require,module,exports){ var toSJISFunction var CODEWORDS_COUNT = [ 0, // Not used 26, 44, 70, 100, 134, 172, 196, 242, 292, 346, 404, 466, 532, 581, 655, 733, 815, 901, 991, 1085, 1156, 1258, 1364, 1474, 1588, 1706, 1828, 1921, 2051, 2185, 2323, 2465, 2611, 2761, 2876, 3034, 3196, 3362, 3532, 3706 ] /** * Returns the QR Code size for the specified version * * @param {Number} version QR Code version * @return {Number} size of QR code */ exports.getSymbolSize = function getSymbolSize (version) { if (!version) throw new Error('"version" cannot be null or undefined') if (version < 1 || version > 40) throw new Error('"version" should be in range from 1 to 40') return version * 4 + 17 } /** * Returns the total number of codewords used to store data and EC information. * * @param {Number} version QR Code version * @return {Number} Data length in bits */ exports.getSymbolTotalCodewords = function getSymbolTotalCodewords (version) { return CODEWORDS_COUNT[version] } /** * Encode data with Bose-Chaudhuri-Hocquenghem * * @param {Number} data Value to encode * @return {Number} Encoded value */ exports.getBCHDigit = function (data) { var digit = 0 while (data !== 0) { digit++ data >>>= 1 } return digit } exports.setToSJISFunction = function setToSJISFunction (f) { if (typeof f !== 'function') { throw new Error('"toSJISFunc" is not a valid function.') } toSJISFunction = f } exports.isKanjiModeEnabled = function () { return typeof toSJISFunction !== 'undefined' } exports.toSJIS = function toSJIS (kanji) { return toSJISFunction(kanji) } },{}],29:[function(require,module,exports){ /** * Check if QR Code version is valid * * @param {Number} version QR Code version * @return {Boolean} true if valid version, false otherwise */ exports.isValid = function isValid (version) { return !isNaN(version) && version >= 1 && version <= 40 } },{}],30:[function(require,module,exports){ var Utils = require('./utils') var ECCode = require('./error-correction-code') var ECLevel = require('./error-correction-level') var Mode = require('./mode') var VersionCheck = require('./version-check') var isArray = require('isarray') // Generator polynomial used to encode version information var G18 = (1 << 12) | (1 << 11) | (1 << 10) | (1 << 9) | (1 << 8) | (1 << 5) | (1 << 2) | (1 << 0) var G18_BCH = Utils.getBCHDigit(G18) function getBestVersionForDataLength (mode, length, errorCorrectionLevel) { for (var currentVersion = 1; currentVersion <= 40; currentVersion++) { if (length <= exports.getCapacity(currentVersion, errorCorrectionLevel, mode)) { return currentVersion } } return undefined } function getReservedBitsCount (mode, version) { // Character count indicator + mode indicator bits return Mode.getCharCountIndicator(mode, version) + 4 } function getTotalBitsFromDataArray (segments, version) { var totalBits = 0 segments.forEach(function (data) { var reservedBits = getReservedBitsCount(data.mode, version) totalBits += reservedBits + data.getBitsLength() }) return totalBits } function getBestVersionForMixedData (segments, errorCorrectionLevel) { for (var currentVersion = 1; currentVersion <= 40; currentVersion++) { var length = getTotalBitsFromDataArray(segments, currentVersion) if (length <= exports.getCapacity(currentVersion, errorCorrectionLevel, Mode.MIXED)) { return currentVersion } } return undefined } /** * Returns version number from a value. * If value is not a valid version, returns defaultValue * * @param {Number|String} value QR Code version * @param {Number} defaultValue Fallback value * @return {Number} QR Code version number */ exports.from = function from (value, defaultValue) { if (VersionCheck.isValid(value)) { return parseInt(value, 10) } return defaultValue } /** * Returns how much data can be stored with the specified QR code version * and error correction level * * @param {Number} version QR Code version (1-40) * @param {Number} errorCorrectionLevel Error correction level * @param {Mode} mode Data mode * @return {Number} Quantity of storable data */ exports.getCapacity = function getCapacity (version, errorCorrectionLevel, mode) { if (!VersionCheck.isValid(version)) { throw new Error('Invalid QR Code version') } // Use Byte mode as default if (typeof mode === 'undefined') mode = Mode.BYTE // Total codewords for this QR code version (Data + Error correction) var totalCodewords = Utils.getSymbolTotalCodewords(version) // Total number of error correction codewords var ecTotalCodewords = ECCode.getTotalCodewordsCount(version, errorCorrectionLevel) // Total number of data codewords var dataTotalCodewordsBits = (totalCodewords - ecTotalCodewords) * 8 if (mode === Mode.MIXED) return dataTotalCodewordsBits var usableBits = dataTotalCodewordsBits - getReservedBitsCount(mode, version) // Return max number of storable codewords switch (mode) { case Mode.NUMERIC: return Math.floor((usableBits / 10) * 3) case Mode.ALPHANUMERIC: return Math.floor((usableBits / 11) * 2) case Mode.KANJI: return Math.floor(usableBits / 13) case Mode.BYTE: default: return Math.floor(usableBits / 8) } } /** * Returns the minimum version needed to contain the amount of data * * @param {Segment} data Segment of data * @param {Number} [errorCorrectionLevel=H] Error correction level * @param {Mode} mode Data mode * @return {Number} QR Code version */ exports.getBestVersionForData = function getBestVersionForData (data, errorCorrectionLevel) { var seg var ecl = ECLevel.from(errorCorrectionLevel, ECLevel.M) if (isArray(data)) { if (data.length > 1) { return getBestVersionForMixedData(data, ecl) } if (data.length === 0) { return 1 } seg = data[0] } else { seg = data } return getBestVersionForDataLength(seg.mode, seg.getLength(), ecl) } /** * Returns version information with relative error correction bits * * The version information is included in QR Code symbols of version 7 or larger. * It consists of an 18-bit sequence containing 6 data bits, * with 12 error correction bits calculated using the (18, 6) Golay code. * * @param {Number} version QR Code version * @return {Number} Encoded version info bits */ exports.getEncodedBits = function getEncodedBits (version) { if (!VersionCheck.isValid(version) || version < 7) { throw new Error('Invalid QR Code version') } var d = version << 12 while (Utils.getBCHDigit(d) - G18_BCH >= 0) { d ^= (G18 << (Utils.getBCHDigit(d) - G18_BCH)) } return (version << 12) | d } },{"./error-correction-code":14,"./error-correction-level":15,"./mode":21,"./utils":28,"./version-check":29,"isarray":5}],31:[function(require,module,exports){ var Utils = require('./utils') function clearCanvas (ctx, canvas, size) { ctx.clearRect(0, 0, canvas.width, canvas.height) if (!canvas.style) canvas.style = {} canvas.height = size canvas.width = size canvas.style.height = size + 'px' canvas.style.width = size + 'px' } function getCanvasElement () { try { return document.createElement('canvas') } catch (e) { throw new Error('You need to specify a canvas element') } } exports.render = function render (qrData, canvas, options) { var opts = options var canvasEl = canvas if (typeof opts === 'undefined' && (!canvas || !canvas.getContext)) { opts = canvas canvas = undefined } if (!canvas) { canvasEl = getCanvasElement() } opts = Utils.getOptions(opts) var size = Utils.getImageWidth(qrData.modules.size, opts) var ctx = canvasEl.getContext('2d') var image = ctx.createImageData(size, size) Utils.qrToImageData(image.data, qrData, opts) clearCanvas(ctx, canvasEl, size) ctx.putImageData(image, 0, 0) return canvasEl } exports.renderToDataURL = function renderToDataURL (qrData, canvas, options) { var opts = options if (typeof opts === 'undefined' && (!canvas || !canvas.getContext)) { opts = canvas canvas = undefined } if (!opts) opts = {} var canvasEl = exports.render(qrData, canvas, opts) var type = opts.type || 'image/png' var rendererOpts = opts.rendererOpts || {} return canvasEl.toDataURL(type, rendererOpts.quality) } },{"./utils":33}],32:[function(require,module,exports){ var Utils = require('./utils') function getColorAttrib (color, attrib) { var alpha = color.a / 255 var str = attrib + '="' + color.hex + '"' return alpha < 1 ? str + ' ' + attrib + '-opacity="' + alpha.toFixed(2).slice(1) + '"' : str } function svgCmd (cmd, x, y) { var str = cmd + x if (typeof y !== 'undefined') str += ' ' + y return str } function qrToPath (data, size, margin) { var path = '' var moveBy = 0 var newRow = false var lineLength = 0 for (var i = 0; i < data.length; i++) { var col = Math.floor(i % size) var row = Math.floor(i / size) if (!col && !newRow) newRow = true if (data[i]) { lineLength++ if (!(i > 0 && col > 0 && data[i - 1])) { path += newRow ? svgCmd('M', col + margin, 0.5 + row + margin) : svgCmd('m', moveBy, 0) moveBy = 0 newRow = false } if (!(col + 1 < size && data[i + 1])) { path += svgCmd('h', lineLength) lineLength = 0 } } else { moveBy++ } } return path } exports.render = function render (qrData, options, cb) { var opts = Utils.getOptions(options) var size = qrData.modules.size var data = qrData.modules.data var qrcodesize = size + opts.margin * 2 var bg = !opts.color.light.a ? '' : '' var path = '' var viewBox = 'viewBox="' + '0 0 ' + qrcodesize + ' ' + qrcodesize + '"' var width = !opts.width ? '' : 'width="' + opts.width + '" height="' + opts.width + '" ' var svgTag = '' + bg + path + '\n' if (typeof cb === 'function') { cb(null, svgTag) } return svgTag } },{"./utils":33}],33:[function(require,module,exports){ function hex2rgba (hex) { if (typeof hex === 'number') { hex = hex.toString() } if (typeof hex !== 'string') { throw new Error('Color should be defined as hex string') } var hexCode = hex.slice().replace('#', '').split('') if (hexCode.length < 3 || hexCode.length === 5 || hexCode.length > 8) { throw new Error('Invalid hex color: ' + hex) } // Convert from short to long form (fff -> ffffff) if (hexCode.length === 3 || hexCode.length === 4) { hexCode = Array.prototype.concat.apply([], hexCode.map(function (c) { return [c, c] })) } // Add default alpha value if (hexCode.length === 6) hexCode.push('F', 'F') var hexValue = parseInt(hexCode.join(''), 16) return { r: (hexValue >> 24) & 255, g: (hexValue >> 16) & 255, b: (hexValue >> 8) & 255, a: hexValue & 255, hex: '#' + hexCode.slice(0, 6).join('') } } exports.getOptions = function getOptions (options) { if (!options) options = {} if (!options.color) options.color = {} var margin = typeof options.margin === 'undefined' || options.margin === null || options.margin < 0 ? 4 : options.margin var width = options.width && options.width >= 21 ? options.width : undefined var scale = options.scale || 4 return { width: width, scale: width ? 4 : scale, margin: margin, color: { dark: hex2rgba(options.color.dark || '#000000ff'), light: hex2rgba(options.color.light || '#ffffffff') }, type: options.type, rendererOpts: options.rendererOpts || {} } } exports.getScale = function getScale (qrSize, opts) { return opts.width && opts.width >= qrSize + opts.margin * 2 ? opts.width / (qrSize + opts.margin * 2) : opts.scale } exports.getImageWidth = function getImageWidth (qrSize, opts) { var scale = exports.getScale(qrSize, opts) return Math.floor((qrSize + opts.margin * 2) * scale) } exports.qrToImageData = function qrToImageData (imgData, qr, opts) { var size = qr.modules.size var data = qr.modules.data var scale = exports.getScale(size, opts) var symbolSize = Math.floor((size + opts.margin * 2) * scale) var scaledMargin = opts.margin * scale var palette = [opts.color.light, opts.color.dark] for (var i = 0; i < symbolSize; i++) { for (var j = 0; j < symbolSize; j++) { var posDst = (i * symbolSize + j) * 4 var pxColor = opts.color.light if (i >= scaledMargin && j >= scaledMargin && i < symbolSize - scaledMargin && j < symbolSize - scaledMargin) { var iSrc = Math.floor((i - scaledMargin) / scale) var jSrc = Math.floor((j - scaledMargin) / scale) pxColor = palette[data[iSrc * size + jSrc] ? 1 : 0] } imgData[posDst++] = pxColor.r imgData[posDst++] = pxColor.g imgData[posDst++] = pxColor.b imgData[posDst] = pxColor.a } } } },{}],34:[function(require,module,exports){ (function (Buffer){ /** * Implementation of a subset of node.js Buffer methods for the browser. * Based on https://github.com/feross/buffer */ /* eslint-disable no-proto */ 'use strict' var isArray = require('isarray') function typedArraySupport () { // Can typed array instances be augmented? try { var arr = new Uint8Array(1) arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }} return arr.foo() === 42 } catch (e) { return false } } Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport() var K_MAX_LENGTH = Buffer.TYPED_ARRAY_SUPPORT ? 0x7fffffff : 0x3fffffff function Buffer (arg, offset, length) { if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) { return new Buffer(arg, offset, length) } if (typeof arg === 'number') { return allocUnsafe(this, arg) } return from(this, arg, offset, length) } if (Buffer.TYPED_ARRAY_SUPPORT) { Buffer.prototype.__proto__ = Uint8Array.prototype Buffer.__proto__ = Uint8Array // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97 if (typeof Symbol !== 'undefined' && Symbol.species && Buffer[Symbol.species] === Buffer) { Object.defineProperty(Buffer, Symbol.species, { value: null, configurable: true, enumerable: false, writable: false }) } } 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 isnan (val) { return val !== val // eslint-disable-line no-self-compare } function createBuffer (that, length) { var buf if (Buffer.TYPED_ARRAY_SUPPORT) { buf = new Uint8Array(length) buf.__proto__ = Buffer.prototype } else { // Fallback: Return an object instance of the Buffer class buf = that if (buf === null) { buf = new Buffer(length) } buf.length = length } return buf } function allocUnsafe (that, size) { var buf = createBuffer(that, size < 0 ? 0 : checked(size) | 0) if (!Buffer.TYPED_ARRAY_SUPPORT) { for (var i = 0; i < size; ++i) { buf[i] = 0 } } return buf } function fromString (that, string) { var length = byteLength(string) | 0 var buf = createBuffer(that, length) var actual = buf.write(string) 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 (that, array) { var length = array.length < 0 ? 0 : checked(array.length) | 0 var buf = createBuffer(that, length) for (var i = 0; i < length; i += 1) { buf[i] = array[i] & 255 } return buf } function fromArrayBuffer (that, array, byteOffset, length) { if (byteOffset < 0 || array.byteLength < byteOffset) { throw new RangeError('\'offset\' is out of bounds') } if (array.byteLength < byteOffset + (length || 0)) { throw new RangeError('\'length\' is out of 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) } if (Buffer.TYPED_ARRAY_SUPPORT) { // Return an augmented `Uint8Array` instance, for best performance buf.__proto__ = Buffer.prototype } else { // Fallback: Return an object instance of the Buffer class buf = fromArrayLike(that, buf) } return buf } function fromObject (that, obj) { if (Buffer.isBuffer(obj)) { var len = checked(obj.length) | 0 var buf = createBuffer(that, len) if (buf.length === 0) { return buf } obj.copy(buf, 0, 0, len) return buf } if (obj) { if ((typeof ArrayBuffer !== 'undefined' && obj.buffer instanceof ArrayBuffer) || 'length' in obj) { if (typeof obj.length !== 'number' || isnan(obj.length)) { return createBuffer(that, 0) } return fromArrayLike(that, obj) } if (obj.type === 'Buffer' && Array.isArray(obj.data)) { return fromArrayLike(that, obj.data) } } throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.') } 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 byteLength (string) { if (Buffer.isBuffer(string)) { return string.length } if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' && (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) { return string.byteLength } if (typeof string !== 'string') { string = '' + string } var len = string.length if (len === 0) return 0 return utf8ToBytes(string).length } 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 } function utf8Write (buf, string, offset, length) { return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length) } function from (that, value, offset, length) { if (typeof value === 'number') { throw new TypeError('"value" argument must not be a number') } if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) { return fromArrayBuffer(that, value, offset, length) } if (typeof value === 'string') { return fromString(that, value, offset) } return fromObject(that, value) } Buffer.prototype.write = function write (string, offset, length) { // Buffer#write(string) if (offset === undefined) { length = this.length offset = 0 // Buffer#write(string, encoding) } else if (length === undefined && typeof offset === 'string') { length = this.length offset = 0 // Buffer#write(string, offset[, length]) } else if (isFinite(offset)) { offset = offset | 0 if (isFinite(length)) { length = length | 0 } else { length = undefined } } 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') } return utf8Write(this, string, offset, length) } 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 if (Buffer.TYPED_ARRAY_SUPPORT) { newBuf = this.subarray(start, end) // Return an augmented `Uint8Array` instance newBuf.__proto__ = Buffer.prototype } else { var sliceLen = end - start newBuf = new Buffer(sliceLen, undefined) for (var i = 0; i < sliceLen; ++i) { newBuf[i] = this[i + start] } } return newBuf } Buffer.prototype.copy = function copy (target, targetStart, start, end) { 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('sourceStart out of bounds') 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 var i if (this === target && start < targetStart && targetStart < end) { // descending copy from end for (i = len - 1; i >= 0; --i) { target[i + targetStart] = this[i + start] } } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) { // ascending copy from start for (i = 0; i < len; ++i) { target[i + targetStart] = this[i + start] } } else { Uint8Array.prototype.set.call( target, this.subarray(start, start + len), targetStart ) } return len } Buffer.prototype.fill = function fill (val, start, end) { // Handle string cases: if (typeof val === 'string') { if (typeof start === 'string') { start = 0 end = this.length } else if (typeof end === 'string') { end = this.length } if (val.length === 1) { var code = val.charCodeAt(0) if (code < 256) { 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 : new Buffer(val) var len = bytes.length for (i = 0; i < end - start; ++i) { this[i + start] = bytes[i % len] } } return this } Buffer.concat = function concat (list, length) { if (!isArray(list)) { throw new TypeError('"list" argument must be an Array of Buffers') } if (list.length === 0) { return createBuffer(null, 0) } var i if (length === undefined) { length = 0 for (i = 0; i < list.length; ++i) { length += list[i].length } } var buffer = allocUnsafe(null, length) var pos = 0 for (i = 0; i < list.length; ++i) { var buf = list[i] if (!Buffer.isBuffer(buf)) { throw new TypeError('"list" argument must be an Array of Buffers') } buf.copy(buffer, pos) pos += buf.length } return buffer } Buffer.byteLength = byteLength Buffer.prototype._isBuffer = true Buffer.isBuffer = function isBuffer (b) { return !!(b != null && b._isBuffer) } module.exports.alloc = function (size) { var buffer = new Buffer(size) buffer.fill(0) return buffer } module.exports.from = function (data) { return new Buffer(data) } }).call(this,require("buffer").Buffer) },{"buffer":2,"isarray":5}],35:[function(require,module,exports){ "use strict"; var _AdapterBase2 = _interopRequireDefault(require("../../../api/AdapterBase")); var _ApproveAdminAdapter2 = _interopRequireDefault(require("../../../api/ApproveAdminAdapter")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(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, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { 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; } 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 { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 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 } }); if (superClass) _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } /** * OvertimeCategoryAdapter */ var OvertimeCategoryAdapter = /*#__PURE__*/function (_AdapterBase) { _inherits(OvertimeCategoryAdapter, _AdapterBase); var _super = _createSuper(OvertimeCategoryAdapter); function OvertimeCategoryAdapter() { _classCallCheck(this, OvertimeCategoryAdapter); return _super.apply(this, arguments); } _createClass(OvertimeCategoryAdapter, [{ key: "getDataMapping", value: function getDataMapping() { return ['id', 'name']; } }, { key: "getHeaders", value: function getHeaders() { return [{ sTitle: 'ID', bVisible: false }, { sTitle: 'Name' }]; } }, { key: "getFormFields", value: function getFormFields() { return [['id', { label: 'ID', type: 'hidden' }], ['name', { label: 'Name', type: 'text', validation: '' }]]; } }]); return OvertimeCategoryAdapter; }(_AdapterBase2["default"]); /** * EmployeeOvertimeAdminAdapter */ var EmployeeOvertimeAdminAdapter = /*#__PURE__*/function (_ApproveAdminAdapter) { _inherits(EmployeeOvertimeAdminAdapter, _ApproveAdminAdapter); var _super2 = _createSuper(EmployeeOvertimeAdminAdapter); function EmployeeOvertimeAdminAdapter(endPoint, tab, filter, orderBy) { var _this; _classCallCheck(this, EmployeeOvertimeAdminAdapter); _this = _super2.call(this, endPoint, tab, filter, orderBy); _this.itemName = 'OvertimeRequest'; _this.itemNameLower = 'overtimerequest'; _this.modulePathName = 'overtime'; return _this; } _createClass(EmployeeOvertimeAdminAdapter, [{ key: "getDataMapping", value: function getDataMapping() { return ['id', 'employee', 'category', 'start_time', 'end_time', 'project', 'status']; } }, { key: "getHeaders", value: function getHeaders() { return [{ sTitle: 'ID', bVisible: false }, { sTitle: 'Employee' }, { sTitle: 'Category' }, { sTitle: 'Start Time' }, { sTitle: 'End Time' }, { sTitle: 'Project' }, { sTitle: 'Status' }]; } }, { key: "getFormFields", value: function getFormFields() { return [['id', { label: 'ID', type: 'hidden' }], ['employee', { label: 'Employee', type: 'select2', sort: 'none', 'allow-null': false, 'remote-source': ['Employee', 'id', 'first_name+last_name', 'getActiveSubordinateEmployees'] }], ['category', { label: 'Category', type: 'select2', 'allow-null': false, 'remote-source': ['OvertimeCategory', 'id', 'name'] }], ['start_time', { label: 'Start Time', type: 'datetime', validation: '' }], ['end_time', { label: 'End Time', type: 'datetime', validation: '' }], ['project', { label: 'Project', type: 'select2', 'allow-null': true, 'null=label': 'none', 'remote-source': ['Project', 'id', 'name'] }], ['notes', { label: 'Notes', type: 'textarea', validation: 'none' }]]; } }]); return EmployeeOvertimeAdminAdapter; }(_ApproveAdminAdapter2["default"]); module.exports = { OvertimeCategoryAdapter: OvertimeCategoryAdapter, EmployeeOvertimeAdminAdapter: EmployeeOvertimeAdminAdapter }; },{"../../../api/AdapterBase":39,"../../../api/ApproveAdminAdapter":40}],36:[function(require,module,exports){ "use strict"; var _AdapterBase3 = _interopRequireDefault(require("../../../api/AdapterBase")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(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, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { 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; } 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 { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 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 } }); if (superClass) _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } /** * ReportAdapter */ var ReportAdapter = /*#__PURE__*/function (_AdapterBase) { _inherits(ReportAdapter, _AdapterBase); var _super = _createSuper(ReportAdapter); function ReportAdapter(endPoint, tab, filter, orderBy) { var _this; _classCallCheck(this, ReportAdapter); _this = _super.call(this, endPoint, tab, filter, orderBy); _this._construct(); return _this; } _createClass(ReportAdapter, [{ key: "_construct", value: function _construct() { this._formFileds = [['id', { label: 'ID', type: 'hidden' }], ['name', { label: 'Name', type: 'label', validation: '' }], ['parameters', { label: 'Parameters', type: 'fieldset', validation: 'none' }]]; this.remoteFieldsExists = false; } }, { key: "_initLocalFormFields", value: function _initLocalFormFields() { this._formFileds = [['id', { label: 'ID', type: 'hidden' }], ['name', { label: 'Name', type: 'label', validation: '' }], ['parameters', { label: 'Parameters', type: 'fieldset', validation: 'none' }]]; } }, { key: "setRemoteFieldExists", value: function setRemoteFieldExists(val) { this.remoteFieldsExists = val; } }, { key: "getDataMapping", value: function getDataMapping() { return ['id', 'icon', 'name', 'details', 'parameters']; } }, { key: "getHeaders", value: function getHeaders() { return [{ sTitle: 'ID', bVisible: false }, { sTitle: '', bSortable: false, sWidth: '22px' }, { sTitle: 'Name', sWidth: '30%' }, { sTitle: 'Details' }, { sTitle: 'Parameters', bVisible: false }]; } }, { key: "getFormFields", value: function getFormFields() { return this._formFileds; } }, { key: "processFormFieldsWithObject", value: function processFormFieldsWithObject(object) { var that = this; this._initLocalFormFields(); var len = this._formFileds.length; var fieldIDsToDelete = []; var fieldsToDelete = []; this.remoteFieldsExists = false; for (var i = 0; i < len; i++) { if (this._formFileds[i][1].type === 'fieldset') { var newFields = JSON.parse(object[this._formFileds[i][0]]); fieldsToDelete.push(this._formFileds[i][0]); newFields.forEach(function (entry) { that._formFileds.push(entry); if (entry[1]['remote-source'] !== undefined && entry[1]['remote-source'] != null) { that.remoteFieldsExists = true; } }); } } var tempArray = []; that._formFileds.forEach(function (entry) { if (jQuery.inArray(entry[0], fieldsToDelete) < 0) { tempArray.push(entry); } }); that._formFileds = tempArray; } }, { key: "renderForm", value: function renderForm(object) { var that = this; this.processFormFieldsWithObject(object); if (this.remoteFieldsExists) { var cb = function cb() { that.renderFormNew(object); }; this.initFieldMasterData(cb); } else { this.initFieldMasterData(); that.renderFormNew(object); } this.currentReport = object; } }, { key: "renderFormNew", value: function renderFormNew(object) { var that = this; var signatureIds = []; if (object == null || object === undefined) { this.currentId = null; } this.preRenderForm(object); var formHtml = this.templates.formTemplate; var html = ''; var fields = this.getFormFields(); for (var i = 0; i < fields.length; i++) { var metaField = this.getMetaFieldForRendering(fields[i][0]); if (metaField === '' || metaField === undefined) { html += this.renderFormField(fields[i]); } else { var metaVal = object[metaField]; if (metaVal !== '' && metaVal != null && metaVal !== undefined && metaVal.trim() !== '') { html += this.renderFormField(JSON.parse(metaVal)); } else { html += this.renderFormField(fields[i]); } } } formHtml = formHtml.replace(/_id_/g, "".concat(this.getTableName(), "_submit")); formHtml = formHtml.replace(/_fields_/g, html); var $tempDomObj; var randomFormId = this.generateRandom(14); if (!this.showFormOnPopup) { $tempDomObj = $("#".concat(this.getTableName(), "Form")); } else { $tempDomObj = $('
'); $tempDomObj.attr('id', randomFormId); } $tempDomObj.html(formHtml); $tempDomObj.find('.datefield').datepicker({ viewMode: 2 }); $tempDomObj.find('.timefield').datetimepicker({ language: 'en', pickDate: false }); $tempDomObj.find('.datetimefield').datetimepicker({ language: 'en' }); $tempDomObj.find('.colorpick').colorpicker(); // $tempDomObj.find('.select2Field').select2(); $tempDomObj.find('.select2Field').each(function () { $(this).select2().select2('val', $(this).find('option:eq(0)').val()); }); $tempDomObj.find('.select2Multi').each(function () { $(this).select2().on('change', function (e) { var parentRow = $(this).parents('.row'); var height = parentRow.find('.select2-choices').height(); parentRow.height(parseInt(height, 10)); }); }); $tempDomObj.find('.signatureField').each(function () { // $(this).data('signaturePad',new SignaturePad($(this))); signatureIds.push($(this).attr('id')); }); for (var _i = 0; _i < fields.length; _i++) { if (fields[_i][1].type === 'datagroup') { $tempDomObj.find("#".concat(fields[_i][0])).data('field', fields[_i]); } } if (this.showSave === false) { $tempDomObj.find('.saveBtn').remove(); } else { $tempDomObj.find('.saveBtn').off(); $tempDomObj.find('.saveBtn').data('modJs', this); $tempDomObj.find('.saveBtn').on('click', function () { if ($(this).data('modJs').saveSuccessItemCallback != null && $(this).data('modJs').saveSuccessItemCallback !== undefined) { $(this).data('modJs').save($(this).data('modJs').retriveItemsAfterSave(), $(this).data('modJs').saveSuccessItemCallback); } else { $(this).data('modJs').save(); } return false; }); } if (this.showCancel === false) { $tempDomObj.find('.cancelBtn').remove(); } else { $tempDomObj.find('.cancelBtn').off(); $tempDomObj.find('.cancelBtn').data('modJs', this); $tempDomObj.find('.cancelBtn').on('click', function () { $(this).data('modJs').cancel(); return false; }); } if (!this.showFormOnPopup) { $("#".concat(this.getTableName(), "Form")).show(); $("#".concat(this.getTableName())).hide(); for (var _i2 = 0; _i2 < signatureIds.length; _i2++) { $("#".concat(signatureIds[_i2])).data('signaturePad', new SignaturePad(document.getElementById(signatureIds[_i2]))); } if (object !== undefined && object != null) { this.fillForm(object); } } else { // var tHtml = $tempDomObj.wrap('
').parent().html(); // this.showMessage("Edit",tHtml,null,null,true); this.showMessage('Edit', '', null, null, true); $('#plainMessageModel .modal-body').html(''); $('#plainMessageModel .modal-body').append($tempDomObj); for (var _i3 = 0; _i3 < signatureIds.length; _i3++) { $("#".concat(signatureIds[_i3])).data('signaturePad', new SignaturePad(document.getElementById(signatureIds[_i3]))); } if (object !== undefined && object != null) { this.fillForm(object, "#".concat(randomFormId)); } } this.postRenderForm(object, $tempDomObj); } }, { key: "getActionButtonsHtml", value: function getActionButtonsHtml(id, data) { var html = '
'; html = html.replace(/_id_/g, id); html = html.replace(/_BASE_/g, this.baseUrl); return html; } }, { key: "addSuccessCallBack", value: function addSuccessCallBack(callBackData, serverData) { var fileName = serverData[0]; var link; if (fileName.indexOf('https:') === 0) { link = "Download Report "); } else { link = "Download Report "); } link = link.replace(/_BASE_/g, this.baseUrl); if (this.currentReport.output === 'PDF' || this.currentReport.output === 'JSON') { this.showMessage('Download Report', link); } else { if (serverData[1].length === 0) { this.showMessage('Empty Report', 'There were no data for selected filters'); return; } var tableHtml = "".concat(link, "

"); // Delete existing temp report table $('#tempReportTable').remove(); // this.showMessage("Report",tableHtml); $("#".concat(this.table)).html(tableHtml); $("#".concat(this.table)).show(); $("#".concat(this.table, "Form")).hide(); // Prepare headers var headers = []; for (var index in serverData[1]) { headers.push({ sTitle: serverData[1][index] }); } var data = serverData[2]; var dataTableParams = { oLanguage: { sLengthMenu: '_MENU_ records per page' }, aaData: data, aoColumns: headers, bSort: false, iDisplayLength: 15, iDisplayStart: 0 }; $('#tempReportTable').dataTable(dataTableParams); $('.dataTables_paginate ul').addClass('pagination'); $('.dataTables_length').hide(); $('.dataTables_filter input').addClass('form-control'); $('.dataTables_filter input').attr('placeholder', 'Search'); $('.dataTables_filter label').contents().filter(function () { return this.nodeType === 3; }).remove(); $('.tableActionButton').tooltip(); } } }, { key: "fillForm", value: function fillForm(object) { var fields = this.getFormFields(); for (var i = 0; i < fields.length; i++) { if (fields[i][1].type === 'label') { $("#".concat(this.getTableName(), "Form #").concat(fields[i][0])).html(object[fields[i][0]]); } else { $("#".concat(this.getTableName(), "Form #").concat(fields[i][0])).val(object[fields[i][0]]); } } } }]); return ReportAdapter; }(_AdapterBase3["default"]); var ReportGenAdapter = /*#__PURE__*/function (_AdapterBase2) { _inherits(ReportGenAdapter, _AdapterBase2); var _super2 = _createSuper(ReportGenAdapter); function ReportGenAdapter() { _classCallCheck(this, ReportGenAdapter); return _super2.apply(this, arguments); } _createClass(ReportGenAdapter, [{ key: "getDataMapping", value: function getDataMapping() { return ['id', 'name']; } }, { key: "getHeaders", value: function getHeaders() { return [{ sTitle: 'ID', bVisible: false }, { sTitle: 'Name' }]; } }, { key: "getFormFields", value: function getFormFields() { return []; } }, { key: "getActionButtonsHtml", value: function getActionButtonsHtml(id, data) { var html = '
'; html = html.replace(/_id_/g, id); html = html.replace(/_name_/g, data[1]); html = html.replace(/_BASE_/g, this.baseUrl); return html; } }]); return ReportGenAdapter; }(_AdapterBase3["default"]); module.exports = { ReportAdapter: ReportAdapter, ReportGenAdapter: ReportGenAdapter }; },{"../../../api/AdapterBase":39}],37:[function(require,module,exports){ "use strict"; var _AdapterBase3 = _interopRequireDefault(require("../../../api/AdapterBase")); var _CustomFieldAdapter = _interopRequireDefault(require("../../../api/CustomFieldAdapter")); var _ApproveAdminAdapter2 = _interopRequireDefault(require("../../../api/ApproveAdminAdapter")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(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, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { 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; } 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 { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 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 } }); if (superClass) _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } /** * ImmigrationDocumentAdapter */ var ImmigrationDocumentAdapter = /*#__PURE__*/function (_AdapterBase) { _inherits(ImmigrationDocumentAdapter, _AdapterBase); var _super = _createSuper(ImmigrationDocumentAdapter); function ImmigrationDocumentAdapter() { _classCallCheck(this, ImmigrationDocumentAdapter); return _super.apply(this, arguments); } _createClass(ImmigrationDocumentAdapter, [{ key: "getDataMapping", value: function getDataMapping() { return ['id', 'name', 'details', 'required', 'alert_on_missing', 'alert_before_expiry']; } }, { key: "getHeaders", value: function getHeaders() { return [{ sTitle: 'ID', bVisible: false }, { sTitle: 'Name' }, { sTitle: 'Details' }, { sTitle: 'Compulsory' }, { sTitle: 'Alert If Not Found' }, { sTitle: 'Alert Before Expiry' }]; } }, { key: "getFormFields", value: function getFormFields() { var fields = [['id', { label: 'ID', type: 'hidden' }], ['name', { label: 'Name', type: 'text', validation: '' }], ['details', { label: 'Details', type: 'textarea', validation: 'none' }], ['required', { label: 'Compulsory', type: 'select', source: [['No', 'No'], ['Yes', 'Yes']] }], ['alert_on_missing', { label: 'Alert If Not Found', type: 'select', source: [['No', 'No'], ['Yes', 'Yes']] }], ['alert_before_expiry', { label: 'Alert Before Expiry', type: 'select', source: [['No', 'No'], ['Yes', 'Yes']] }], ['alert_before_day_number', { label: 'Days for Expiry Alert', type: 'text', validation: '' }]]; for (var i = 0; i < this.customFields.length; i++) { fields.push(this.customFields[i]); } return fields; } }]); return ImmigrationDocumentAdapter; }(_AdapterBase3["default"]); /** * EmployeeImmigrationAdapter */ var EmployeeImmigrationAdapter = /*#__PURE__*/function (_AdapterBase2) { _inherits(EmployeeImmigrationAdapter, _AdapterBase2); var _super2 = _createSuper(EmployeeImmigrationAdapter); function EmployeeImmigrationAdapter() { _classCallCheck(this, EmployeeImmigrationAdapter); return _super2.apply(this, arguments); } _createClass(EmployeeImmigrationAdapter, [{ key: "getDataMapping", value: function getDataMapping() { return ['id', 'employee', 'document', 'documentname', 'valid_until', 'status']; } }, { key: "getHeaders", value: function getHeaders() { return [{ sTitle: 'ID', bVisible: false }, { sTitle: 'Employee' }, { sTitle: 'Document' }, { sTitle: 'Document Id' }, { sTitle: 'Valid Until' }, { sTitle: 'Status' }]; } }, { key: "getFormFields", value: function getFormFields() { return [['id', { label: 'ID', type: 'hidden' }], ['employee', { label: 'Employee', type: 'select2', 'remote-source': ['Employee', 'id', 'first_name+last_name'] }], ['document', { label: 'Document', type: 'select2', 'remote-source': ['ImmigrationDocument', 'id', 'name'] }], ['documentname', { label: 'Document Id', type: 'text', validation: '' }], ['valid_until', { label: 'Valid Until', type: 'date', validation: 'none' }], ['status', { label: 'Status', type: 'select', source: [['Active', 'Active'], ['Inactive', 'Inactive'], ['Draft', 'Draft']] }], ['details', { label: 'Details', type: 'textarea', validation: 'none' }], ['attachment1', { label: 'Attachment 1', type: 'fileupload', validation: 'none' }], ['attachment2', { label: 'Attachment 2', type: 'fileupload', validation: 'none' }], ['attachment3', { label: 'Attachment 3', type: 'fileupload', validation: 'none' }]]; } }, { key: "getFilters", value: function getFilters() { return [['employee', { label: 'Employee', type: 'select2', 'remote-source': ['Employee', 'id', 'first_name+last_name'] }]]; } }]); return EmployeeImmigrationAdapter; }(_AdapterBase3["default"]); /** * EmployeeTravelRecordAdminAdapter */ var EmployeeTravelRecordAdminAdapter = /*#__PURE__*/function (_ApproveAdminAdapter) { _inherits(EmployeeTravelRecordAdminAdapter, _ApproveAdminAdapter); var _super3 = _createSuper(EmployeeTravelRecordAdminAdapter); function EmployeeTravelRecordAdminAdapter(endPoint, tab, filter, orderBy) { var _this; _classCallCheck(this, EmployeeTravelRecordAdminAdapter); _this = _super3.call(this, endPoint, tab, filter, orderBy); _this.itemName = 'TravelRequest'; _this.itemNameLower = 'travelrequest'; _this.modulePathName = 'travel'; return _this; } _createClass(EmployeeTravelRecordAdminAdapter, [{ key: "getDataMapping", value: function getDataMapping() { return ['id', 'employee', 'type', 'purpose', 'travel_from', 'travel_to', 'travel_date', 'status']; } }, { key: "getHeaders", value: function getHeaders() { return [{ sTitle: 'ID', bVisible: false }, { sTitle: 'Employee' }, { sTitle: 'Travel Type' }, { sTitle: 'Purpose' }, { sTitle: 'From' }, { sTitle: 'To' }, { sTitle: 'Travel Date' }, { sTitle: 'Status' }]; } }, { key: "getFormFields", value: function getFormFields() { return this.addCustomFields([['id', { label: 'ID', type: 'hidden' }], ['employee', { label: 'Employee', type: 'select2', sort: 'none', 'allow-null': false, 'remote-source': ['Employee', 'id', 'first_name+last_name', 'getActiveSubordinateEmployees'] }], ['type', { label: 'Means of Transportation', type: 'select', source: [['Plane', 'Plane'], ['Rail', 'Rail'], ['Taxi', 'Taxi'], ['Own Vehicle', 'Own Vehicle'], ['Rented Vehicle', 'Rented Vehicle'], ['Other', 'Other']] }], ['purpose', { label: 'Purpose of Travel', type: 'textarea', validation: '' }], ['travel_from', { label: 'Travel From', type: 'text', validation: '' }], ['travel_to', { label: 'Travel To', type: 'text', validation: '' }], ['travel_date', { label: 'Travel Date', type: 'datetime', validation: '' }], ['return_date', { label: 'Return Date', type: 'datetime', validation: '' }], ['details', { label: 'Notes', type: 'textarea', validation: 'none' }], ['currency', { label: 'Currency', type: 'select2', 'allow-null': false, 'remote-source': ['CurrencyType', 'id', 'code'] }], ['funding', { label: 'Total Funding Proposed', type: 'text', validation: 'float', "default": '0.00', mask: '9{0,10}.99' }], ['attachment1', { label: 'Attachment', type: 'fileupload', validation: 'none' }], ['attachment2', { label: 'Attachment', type: 'fileupload', validation: 'none' }], ['attachment3', { label: 'Attachment', type: 'fileupload', validation: 'none' }]]); } }]); return EmployeeTravelRecordAdminAdapter; }(_ApproveAdminAdapter2["default"]); module.exports = { ImmigrationDocumentAdapter: ImmigrationDocumentAdapter, EmployeeImmigrationAdapter: EmployeeImmigrationAdapter, EmployeeTravelRecordAdminAdapter: EmployeeTravelRecordAdminAdapter, CustomFieldAdapter: _CustomFieldAdapter["default"] }; },{"../../../api/AdapterBase":39,"../../../api/ApproveAdminAdapter":40,"../../../api/CustomFieldAdapter":43}],38:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; 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, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } /* Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) */ /** * RequestCache */ var MemoryStorage = /*#__PURE__*/function () { function MemoryStorage() { _classCallCheck(this, MemoryStorage); this.data = {}; } _createClass(MemoryStorage, [{ key: "getItem", value: function getItem(key) { return this.data[key]; } }, { key: "setItem", value: function setItem(key, data) { this.data[key] = data; } }, { key: "removeAllByPrefix", value: function removeAllByPrefix(prefix) { var keys = Object.keys(this.data); for (var i = 0; i < keys.length; i++) { if (keys[i].indexOf(prefix) > 0) { delete this.data[keys[i]]; } } } }]); return MemoryStorage; }(); var RequestCache = /*#__PURE__*/function () { function RequestCache(storage) { _classCallCheck(this, RequestCache); if (!storage) { this.storage = new MemoryStorage(); } else { this.storage = storage; } } _createClass(RequestCache, [{ key: "getKey", value: function getKey(url, params) { var key = "".concat(url, "|"); for (var index in params) { key += "".concat(index, "=").concat(params[index], "|"); } return key; } /* invalidateTable(table) { let key; for (let i = 0; i < this.storage.length; i++) { key = this.storage.key(i); if (key.indexOf(`t=${table}`) > 0) { this.storage.removeItem(key); } } } */ }, { key: "invalidateTable", value: function invalidateTable(table) { this.storage.removeAllByPrefix("t=".concat(table)); } }, { key: "getData", value: function getData(key) { var data = this.storage.getItem(key); if (!data) { return null; } return data; } }, { key: "setData", value: function setData(key, data) { if (data.status !== undefined && data.status != null && data.status !== 'SUCCESS') { return null; } this.storage.setItem(key, data); return data; } }]); return RequestCache; }(); var _default = RequestCache; exports["default"] = _default; },{}],39:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; var _IceApiClient = _interopRequireDefault(require("./IceApiClient")); var _ModuleBase2 = _interopRequireDefault(require("./ModuleBase")); var _RequestCache = _interopRequireDefault(require("../api-common/RequestCache")); var _MasterDataReader = _interopRequireDefault(require("./MasterDataReader")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(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, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { 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; } 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 { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 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 } }); if (superClass) _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } var AdapterBase = /*#__PURE__*/function (_ModuleBase) { _inherits(AdapterBase, _ModuleBase); var _super = _createSuper(AdapterBase); function AdapterBase(endPoint, tab, filter, orderBy) { var _this; _classCallCheck(this, AdapterBase); _this = _super.call(this); _this.moduleRelativeURL = null; _this.tableData = []; _this.sourceData = []; _this.filter = null; _this.origFilter = null; _this.orderBy = null; _this.currentElement = null; _this.initAdapter(endPoint, tab, filter, orderBy); return _this; } _createClass(AdapterBase, [{ key: "initAdapter", value: function initAdapter(endPoint, tab, filter, orderBy) { this.moduleRelativeURL = baseUrl; this.table = endPoint; if (tab === undefined || tab === null) { this.tab = endPoint; } else { this.tab = tab; } if (filter === undefined || filter === null) { this.filter = null; } else { this.filter = filter; } this.origFilter = this.filter; if (orderBy === undefined || orderBy === null) { this.orderBy = null; } else { this.orderBy = orderBy; } this.trackEvent('initAdapter', tab); this.requestCache = new _RequestCache["default"](); } }, { key: "initMasterDataReader", value: function initMasterDataReader() { this.masterDataReader = new _MasterDataReader["default"](this); } }, { key: "setupApiClient", value: function setupApiClient(token) { this.apiClient = new _IceApiClient["default"](this.apiUrl, token, window.CLIENT_BASE_URL, true); } }, { key: "setApiUrl", value: function setApiUrl(apiUrl) { this.apiUrl = apiUrl; } }, { key: "setFilter", value: function setFilter(filter) { this.filter = filter; } }, { key: "preSetFilterExternal", value: function preSetFilterExternal(filter) { this.initialFilter = filter; } }, { key: "setFilterExternal", value: function setFilterExternal(_filter) { var filter = _filter; if (filter === undefined || filter === null) { filter = this.initialFilter; } if (filter === undefined || filter === null) { return; } this.setFilter(filter); this.filtersAlreadySet = true; $("#".concat(this.getTableName(), "_resetFilters")).show(); this.currentFilterString = this.getFilterString(filter); } }, { key: "getFilter", value: function getFilter() { return this.filter; } }, { key: "setOrderBy", value: function setOrderBy(orderBy) { this.orderBy = orderBy; } }, { key: "getOrderBy", value: function getOrderBy() { return this.orderBy; } }, { key: "getFile", value: function getFile(name) { var _this2 = this; this.trackEvent('file', name); return new Promise(function (resolve, reject) { $.getJSON(_this2.moduleRelativeURL, { a: 'file', name: name }, function (data) { if (data.status === 'SUCCESS') { resolve(data.data); } else { reject(); } }).fail(function () { return reject(); }); }); } /** * @method add * @param object {Array} object data to be added to database * @param getFunctionCallBackData {Array} once a success is returned call get() function for this module with these parameters * @param _callGetFunction {Boolean} if false the get function of the module will not be called (default: true) * @param successCallback {Function} this will get called after success response */ }, { key: "add", value: function add(object, getFunctionCallBackData, callGetFunction, successCallback) { var that = this; if (callGetFunction === undefined || callGetFunction === null) { // eslint-disable-next-line no-param-reassign callGetFunction = true; } $(object).attr('a', 'add'); $(object).attr('t', this.table); that.showLoader(); this.requestCache.invalidateTable(this.table); $.post(this.moduleRelativeURL, object, function (data) { if (data.status === 'SUCCESS') { that.addSuccessCallBack(getFunctionCallBackData, data.object, callGetFunction, successCallback, that); } else { that.addFailCallBack(getFunctionCallBackData, data.object); } }, 'json').fail(function (e) { if (e.status === 403) { that.showMessage('Access Forbidden', e.responseJSON.message); } }).always(function () { that.hideLoader(); }); this.trackEvent('add', this.tab, this.table); } }, { key: "addSuccessCallBack", value: function addSuccessCallBack(callBackData, serverData, callGetFunction, successCallback, thisObject) { if (callGetFunction) { this.get(callBackData); } this.initFieldMasterData(); if (successCallback !== undefined && successCallback !== null) { successCallback.apply(thisObject, [serverData]); } this.trackEvent('addSuccess', this.tab, this.table); } }, { key: "addFailCallBack", value: function addFailCallBack(callBackData, serverData) { try { this.closePlainMessage(); } catch (e) {// No need to report } this.showMessage('Error saving', serverData); this.trackEvent('addFailed', this.tab, this.table); } }, { key: "deleteObj", value: function deleteObj(id, callBackData) { var that = this; that.showLoader(); this.requestCache.invalidateTable(this.table); $.post(this.moduleRelativeURL, { t: this.table, a: 'delete', id: id }, function (data) { if (data.status === 'SUCCESS') { that.deleteSuccessCallBack(callBackData, data.object); } else { that.deleteFailCallBack(callBackData, data.object); } }, 'json').fail(function (e) { if (e.status === 403) { that.showMessage('Access Forbidden', e.responseJSON.message); } }).always(function () { that.hideLoader(); }); this.trackEvent('delete', this.tab, this.table); } // eslint-disable-next-line no-unused-vars }, { key: "deleteSuccessCallBack", value: function deleteSuccessCallBack(callBackData, serverData) { this.get(callBackData); this.clearDeleteParams(); } }, { key: "deleteFailCallBack", value: function deleteFailCallBack(callBackData, serverData) { this.clearDeleteParams(); this.showMessage('Error Occurred while Deleting Item', serverData); } }, { key: "get", value: function get(callBackData) { var that = this; if (this.getRemoteTable()) { this.createTableServer(this.getTableName()); $("#".concat(this.getTableName(), "Form")).hide(); $("#".concat(this.getTableName())).show(); return; } var sourceMappingJson = JSON.stringify(this.getSourceMapping()); var filterJson = ''; if (this.getFilter() !== null) { filterJson = JSON.stringify(this.getFilter()); } var orderBy = ''; if (this.getOrderBy() !== null) { orderBy = this.getOrderBy(); } sourceMappingJson = this.fixJSON(sourceMappingJson); filterJson = this.fixJSON(filterJson); that.showLoader(); $.post(this.moduleRelativeURL, { t: this.table, a: 'get', sm: sourceMappingJson, ft: filterJson, ob: orderBy }, function (data) { if (data.status === 'SUCCESS') { that.getSuccessCallBack(callBackData, data.object); } else { that.getFailCallBack(callBackData, data.object); } }, 'json').fail(function (e) { if (e.status === 403) { that.showMessage('Access Forbidden', e.responseJSON.message); } }).always(function () { that.hideLoader(); }); that.initFieldMasterData(); this.trackEvent('get', this.tab, this.table); // var url = this.getDataUrl(); // console.log(url); } }, { key: "getDataUrl", value: function getDataUrl(_columns) { var sourceMappingJson = JSON.stringify(this.getSourceMapping()); var columns = JSON.stringify(_columns); var filterJson = ''; if (this.getFilter() !== null) { filterJson = JSON.stringify(this.getFilter()); } var orderBy = ''; if (this.getOrderBy() !== null) { orderBy = this.getOrderBy(); } var url = this.moduleRelativeURL.replace('service.php', 'data.php'); url = "".concat(url, "?t=").concat(this.table); url = "".concat(url, "&sm=").concat(this.fixJSON(sourceMappingJson)); url = "".concat(url, "&cl=").concat(this.fixJSON(columns)); url = "".concat(url, "&ft=").concat(this.fixJSON(filterJson)); url = "".concat(url, "&ob=").concat(orderBy); if (this.isSubProfileTable()) { url = "".concat(url, "&type=sub"); } if (this.remoteTableSkipProfileRestriction()) { url = "".concat(url, "&skip=1"); } return url; } }, { key: "isSubProfileTable", value: function isSubProfileTable() { return false; } }, { key: "remoteTableSkipProfileRestriction", value: function remoteTableSkipProfileRestriction() { return false; } }, { key: "preProcessTableData", value: function preProcessTableData(row) { return row; } }, { key: "getSuccessCallBack", value: function getSuccessCallBack(callBackData, serverData) { var data = []; var mapping = this.getDataMapping(); for (var i = 0; i < serverData.length; i++) { var row = []; for (var j = 0; j < mapping.length; j++) { row[j] = serverData[i][mapping[j]]; } data.push(this.preProcessTableData(row)); } this.sourceData = serverData; if (callBackData.callBack !== undefined && callBackData.callBack !== null) { if (callBackData.callBackData === undefined || callBackData.callBackData === null) { callBackData.callBackData = []; } callBackData.callBackData.push(serverData); callBackData.callBackData.push(data); this.callFunction(callBackData.callBack, callBackData.callBackData); } this.tableData = data; if (!(callBackData.noRender !== undefined && callBackData.noRender !== null && callBackData.noRender === true)) { this.createTable(this.getTableName()); $("#".concat(this.getTableName(), "Form")).hide(); $("#".concat(this.getTableName())).show(); } } // eslint-disable-next-line no-unused-vars }, { key: "getFailCallBack", value: function getFailCallBack(callBackData, serverData) {} }, { key: "getElement", value: function getElement(id, callBackData, clone) { var that = this; var sourceMappingJson = JSON.stringify(this.getSourceMapping()); sourceMappingJson = this.fixJSON(sourceMappingJson); that.showLoader(); $.post(this.moduleRelativeURL, { t: this.table, a: 'getElement', id: id, sm: sourceMappingJson }, function (data) { if (data.status === 'SUCCESS') { if (clone) { delete data.object.id; } this.currentElement = data.object; that.getElementSuccessCallBack.apply(that, [callBackData, data.object]); } else { that.getElementFailCallBack.apply(that, [callBackData, data.object]); } }, 'json').fail(function (e) { if (e.status === 403) { that.showMessage('Access Forbidden', e.responseJSON.message); } }).always(function () { that.hideLoader(); }); this.trackEvent('getElement', this.tab, this.table); } }, { key: "getElementSuccessCallBack", value: function getElementSuccessCallBack(callBackData, serverData) { if (callBackData.callBack !== undefined && callBackData.callBack !== null) { if (callBackData.callBackData === undefined || callBackData.callBackData === null) { callBackData.callBackData = []; } callBackData.callBackData.push(serverData); this.callFunction(callBackData.callBack, callBackData.callBackData, this); } this.currentElement = serverData; if (!(callBackData.noRender !== undefined && callBackData.noRender !== null && callBackData.noRender === true)) { this.renderForm(serverData); } } // eslint-disable-next-line no-unused-vars }, { key: "getElementFailCallBack", value: function getElementFailCallBack(callBackData, serverData) {} }, { key: "getTableData", value: function getTableData() { return this.tableData; } }, { key: "getTableName", value: function getTableName() { return this.tab; } }, { key: "getFieldValues", value: function getFieldValues(fieldMaster, callBackData) { var that = this; var method = ''; var methodParams = ''; if (fieldMaster[3] !== undefined && fieldMaster[3] !== null) { // eslint-disable-next-line prefer-destructuring method = fieldMaster[3]; } if (fieldMaster[4] !== undefined && fieldMaster[4] !== null) { methodParams = JSON.stringify(fieldMaster[4]); } var key = this.requestCache.getKey(this.moduleRelativeURL, { t: fieldMaster[0], key: fieldMaster[1], value: fieldMaster[2], method: method, methodParams: methodParams, a: 'getFieldValues' }); var cacheData = this.requestCache.getData(key); if (cacheData !== null && cacheData !== undefined) { if (cacheData.status === 'SUCCESS') { callBackData.callBackData.push(cacheData.data); if (callBackData.callBackSuccess !== null && callBackData.callBackSuccess !== undefined) { callBackData.callBackData.push(callBackData.callBackSuccess); } that.callFunction(callBackData.callBack, callBackData.callBackData); } } else { var callbackWraper = function callbackWraper(data) { if (data.status === 'SUCCESS') { that.requestCache.setData(this.success.key, data); var localCallBackData = callBackData; localCallBackData.callBackData = [callBackData.callBackData[0]]; localCallBackData.callBackData.push(data.data); if (localCallBackData.callBackSuccess !== null && localCallBackData.callBackSuccess !== undefined) { localCallBackData.callBackData.push(callBackData.callBackSuccess); } that.callFunction(localCallBackData.callBack, localCallBackData.callBackData); } else if (data.message === 'Access violation') { alert("Error : ".concat(callbackWraper.table, " ").concat(data.message)); } }; callbackWraper.key = key; // eslint-disable-next-line prefer-destructuring callbackWraper.table = fieldMaster[0]; $.post(this.moduleRelativeURL, { t: fieldMaster[0], key: fieldMaster[1], value: fieldMaster[2], method: method, methodParams: methodParams, a: 'getFieldValues' }, callbackWraper, 'json'); } } }, { key: "setAdminProfile", value: function setAdminProfile(empId) { try { localStorage.clear(); } catch (e) {// No need to report } $.post(this.moduleRelativeURL, { a: 'setAdminEmp', empid: empId }, function () { // eslint-disable-next-line no-restricted-globals top.location.href = clientUrl; }, 'json'); } }, { key: "customAction", value: function customAction(subAction, module, request, callBackData, isPost) { var that = this; request = this.fixJSON(request); if (!isPost) { $.getJSON(this.moduleRelativeURL, { t: this.table, a: 'ca', sa: subAction, mod: module, req: request }, function (data) { if (data.status === 'SUCCESS') { console.log("successsss"); callBackData.callBackData.push(data.data); that.callFunction(callBackData.callBackSuccess, callBackData.callBackData); } else { console.log("nooo"); callBackData.callBackData.push(data.data); that.callFunction(callBackData.callBackFail, callBackData.callBackData); } }); } else { $.post(this.moduleRelativeURL, { t: this.table, a: 'ca', sa: subAction, mod: module, req: request }, function (data) { if (data.status === 'SUCCESS') { callBackData.callBackData.push(data.data); that.callFunction(callBackData.callBackSuccess, callBackData.callBackData); } else { callBackData.callBackData.push(data.data); that.callFunction(callBackData.callBackFail, callBackData.callBackData); } }, 'json'); } } }, { key: "sendCustomRequest", value: function sendCustomRequest(action, params, successCallback, failCallback) { params.a = action; $.post(this.moduleRelativeURL, params, function (data) { if (data.status === 'SUCCESS') { successCallback(data.data); } else { failCallback(data.data); } }, 'json'); } }, { key: "getCustomActionUrl", value: function getCustomActionUrl(action, params) { params.a = action; var str = ''; for (var key in params) { if (params.hasOwnProperty(key)) { if (str !== '') { str += '&'; } str += "".concat(key, "=").concat(params[key]); } } return "".concat(this.moduleRelativeURL, "?").concat(str); } }, { key: "getClientDataUrl", value: function getClientDataUrl() { return "".concat(this.moduleRelativeURL.replace('service.php', ''), "data/"); } }, { key: "getCustomUrl", value: function getCustomUrl(str) { return this.moduleRelativeURL.replace('service.php', str); } }]); return AdapterBase; }(_ModuleBase2["default"]); var _default = AdapterBase; exports["default"] = _default; },{"../api-common/RequestCache":38,"./IceApiClient":45,"./MasterDataReader":47,"./ModuleBase":48}],40:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; var _LogViewAdapter2 = _interopRequireDefault(require("./LogViewAdapter")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(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, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { 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; } 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 { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 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 } }); if (superClass) _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } var ApproveAdminAdapter = /*#__PURE__*/function (_LogViewAdapter) { _inherits(ApproveAdminAdapter, _LogViewAdapter); var _super = _createSuper(ApproveAdminAdapter); function ApproveAdminAdapter(endPoint, tab, filter, orderBy) { _classCallCheck(this, ApproveAdminAdapter); return _super.call(this, endPoint, tab, filter, orderBy); } _createClass(ApproveAdminAdapter, [{ key: "getStatusFieldPosition", value: function getStatusFieldPosition() { var dm = this.getDataMapping(); return dm.length - 1; } }, { key: "openStatus", value: function openStatus(id, status) { $("#".concat(this.itemNameLower, "StatusModel")).modal('show'); $("#".concat(this.itemNameLower, "_status")).html(this.getStatusOptions(status)); $("#".concat(this.itemNameLower, "_status")).val(status); this.statusChangeId = id; } }, { key: "closeDialog", value: function closeDialog() { $("#".concat(this.itemNameLower, "StatusModel")).modal('hide'); } }, { key: "changeStatus", value: function changeStatus() { var status = $("#".concat(this.itemNameLower, "_status")).val(); var reason = $("#".concat(this.itemNameLower, "_reason")).val(); if (status == undefined || status == null || status == '') { this.showMessage('Error', "Please select ".concat(this.itemNameLower, " status")); return; } var object = { id: this.statusChangeId, status: status, reason: reason }; var reqJson = JSON.stringify(object); var callBackData = []; callBackData.callBackData = []; callBackData.callBackSuccess = 'changeStatusSuccessCallBack'; callBackData.callBackFail = 'changeStatusFailCallBack'; this.customAction('changeStatus', "admin=".concat(this.modulePathName), reqJson, callBackData); this.closeDialog(); this.statusChangeId = null; } }, { key: "changeStatusSuccessCallBack", value: function changeStatusSuccessCallBack(callBackData) { this.showMessage('Successful', "".concat(this.itemName, " Request status changed successfully")); this.get([]); } }, { key: "changeStatusFailCallBack", value: function changeStatusFailCallBack(callBackData) { this.showMessage('Error', "Error occurred while changing ".concat(this.itemName, " request status")); } }, { key: "getActionButtonsHtml", value: function getActionButtonsHtml(id, data) { var editButton = ''; var deleteButton = ''; var statusChangeButton = ''; var viewLogsButton = ''; var html = '
_edit__delete__status__logs_
'; var optiondata = this.getStatusOptionsData(data[this.getStatusFieldPosition()]); if (Object.keys(optiondata).length > 0) { html = html.replace('_status_', statusChangeButton); } else { html = html.replace('_status_', ''); } html = html.replace('_logs_', viewLogsButton); if (this.showDelete) { html = html.replace('_delete_', deleteButton); } else { html = html.replace('_delete_', ''); } if (this.showEdit) { html = html.replace('_edit_', editButton); } else { html = html.replace('_edit_', ''); } html = html.replace(/_id_/g, id); html = html.replace(/_BASE_/g, this.baseUrl); html = html.replace(/_cstatus_/g, data[this.getStatusFieldPosition()]); return html; } }, { key: "isSubProfileTable", value: function isSubProfileTable() { return this.user.user_level !== 'Admin' && this.user.user_level !== 'Restricted Admin'; } }, { key: "getStatusOptionsData", value: function getStatusOptionsData(currentStatus) { var data = {}; if (currentStatus === 'Approved') {} else if (currentStatus === 'Pending') { data.Approved = 'Approved'; data.Rejected = 'Rejected'; } else if (currentStatus === 'Rejected') {} else if (currentStatus === 'Cancelled') {} else if (currentStatus === 'Processing') {} else { data['Cancellation Requested'] = 'Cancellation Requested'; data.Cancelled = 'Cancelled'; } return data; } }, { key: "getStatusOptions", value: function getStatusOptions(currentStatus) { return this.generateOptions(this.getStatusOptionsData(currentStatus)); } }]); return ApproveAdminAdapter; }(_LogViewAdapter2["default"]); var _default = ApproveAdminAdapter; exports["default"] = _default; },{"./LogViewAdapter":46}],41:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; var _LogViewAdapter2 = _interopRequireDefault(require("./LogViewAdapter")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(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, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { 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; } 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 { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 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 } }); if (superClass) _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } var ApproveModuleAdapter = /*#__PURE__*/function (_LogViewAdapter) { _inherits(ApproveModuleAdapter, _LogViewAdapter); var _super = _createSuper(ApproveModuleAdapter); function ApproveModuleAdapter() { _classCallCheck(this, ApproveModuleAdapter); return _super.apply(this, arguments); } _createClass(ApproveModuleAdapter, [{ key: "cancelRequest", value: function cancelRequest(id) { var object = {}; object.id = id; var reqJson = JSON.stringify(object); var callBackData = []; callBackData.callBackData = []; callBackData.callBackSuccess = 'cancelSuccessCallBack'; callBackData.callBackFail = 'cancelFailCallBack'; this.customAction('cancel', "modules=".concat(this.modulePathName), reqJson, callBackData); } // eslint-disable-next-line no-unused-vars }, { key: "cancelSuccessCallBack", value: function cancelSuccessCallBack(callBackData) { this.showMessage('Successful', "".concat(this.itemName, " cancellation request sent")); this.get([]); } }, { key: "cancelFailCallBack", value: function cancelFailCallBack(callBackData) { this.showMessage("Error Occurred while cancelling ".concat(this.itemName), callBackData); } }, { key: "getActionButtonsHtml", value: function getActionButtonsHtml(id, data) { var editButton = ''; var deleteButton = ''; var requestCancellationButton = ""); var viewLogsButton = ''; var html = '
_edit__logs__delete_
'; html = html.replace('_logs_', viewLogsButton); if (this.showDelete) { if (data[7] === 'Approved') { html = html.replace('_delete_', requestCancellationButton); } else if (data[7] === 'Pending' || this.user.user_level === 'Admin') { html = html.replace('_delete_', deleteButton); } else { html = html.replace('_delete_', ''); } } else { html = html.replace('_delete_', ''); } if (this.showEdit) { html = html.replace('_edit_', editButton); } else { html = html.replace('_edit_', ''); } html = html.replace(/_id_/g, id); html = html.replace(/_BASE_/g, this.baseUrl); return html; } }]); return ApproveModuleAdapter; }(_LogViewAdapter2["default"]); var _default = ApproveModuleAdapter; exports["default"] = _default; },{"./LogViewAdapter":46}],42:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; 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, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } var axios = require('axios'); var CustomAction = /*#__PURE__*/function () { function CustomAction(adapter) { _classCallCheck(this, CustomAction); this.adapter = adapter; } _createClass(CustomAction, [{ key: "execute", value: function execute(subAction, module, request, isPost) { if (!isPost) { return axios.get(this.adapter.moduleRelativeURL, { params: { t: this.adapter.table, a: 'ca', sa: subAction, mod: module, req: request } }); } return axios.post(this.moduleRelativeURL, { t: this.adapter.table, a: 'ca', sa: subAction, mod: module, req: request }); } }]); return CustomAction; }(); var _default = CustomAction; exports["default"] = _default; },{"axios":98}],43:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; var _AdapterBase2 = _interopRequireDefault(require("./AdapterBase")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(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, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { 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; } 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 { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 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 } }); if (superClass) _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } /* * CustomFieldAdapter */ var CustomFieldAdapter = /*#__PURE__*/function (_AdapterBase) { _inherits(CustomFieldAdapter, _AdapterBase); var _super = _createSuper(CustomFieldAdapter); function CustomFieldAdapter(endPoint, tab, filter, orderBy) { var _this; _classCallCheck(this, CustomFieldAdapter); _this = _super.call(this, endPoint, tab, filter, orderBy); _this.tableType = ''; return _this; } _createClass(CustomFieldAdapter, [{ key: "getDataMapping", value: function getDataMapping() { return ['id', 'name', 'display', 'display_order']; } }, { key: "getHeaders", value: function getHeaders() { return [{ sTitle: 'ID', bVisible: false }, { sTitle: 'Name' }, { sTitle: 'Display Status' }, { sTitle: 'Priority' }]; } }, { key: "getFormFields", value: function getFormFields() { return [['id', { label: 'ID', type: 'hidden' }], ['name', { label: 'Name', type: 'text', validation: '' }], ['display', { label: 'Display Status', type: 'select', source: [['Form', 'Show'], ['Hidden', 'Hidden']] }], ['field_type', { label: 'Field Type', type: 'select', source: [['text', 'Text Field'], ['textarea', 'Multiline Text'], ['select', 'Dropdown'], ['select2', 'Searchable DropDown'], ['select2multi', 'Multi Select'], ['fileupload', 'File Upload'], ['date', 'Date'], ['datetime', 'Date Time'], ['time', 'Time'], ['signature', 'Signature']] }], ['field_label', { label: 'Field Label', type: 'text', validation: '' }], ['field_validation', { label: 'Validation', type: 'select2', validation: 'none', sort: 'none', 'null-label': 'Required', 'allow-null': true, source: [['none', 'None'], ['number', 'Number'], ['numberOrEmpty', 'Number or Empty'], ['float', 'Decimal'], ['email', 'Email'], ['emailOrEmpty', 'Email or Empty']] }], ['field_options', { label: 'Field Options', type: 'datagroup', form: [['label', { label: 'Label', type: 'text', validation: '' }], ['value', { label: 'Value', type: 'text', validation: 'none' }]], html: '
#_delete_##_edit_##_label_#:#_value_#
', validation: 'none' }], ['display_order', { label: 'Priority', type: 'text', validation: 'number' }], ['display_section', { label: 'Display Section', type: 'text', validation: 'none' }]]; } }, { key: "setTableType", value: function setTableType(type) { this.tableType = type; } }, { key: "doCustomValidation", value: function doCustomValidation(params) { var validateName = function validateName(str) { var name = /^[a-z][a-z0-9._]+$/; return str != null && name.test(str); }; if (!validateName(params.name)) { return 'Invalid name for custom field'; } return null; } }, { key: "forceInjectValuesBeforeSave", value: function forceInjectValuesBeforeSave(params) { var data = [params.name]; var options = []; var optionsData; data.push({}); data[1].label = params.field_label; data[1].type = params.field_type; data[1].validation = params.field_validation; if (['select', 'select2', 'select2multi'].indexOf(params.field_type) >= 0) { optionsData = params.field_options === '' || params.field_options === undefined ? [] : JSON.parse(params.field_options); for (var index in optionsData) { options.push([optionsData[index].value, optionsData[index].label]); } data[1].source = options; } if (params.field_validation == null || params.field_validation === undefined) { params.field_validation = ''; } params.data = JSON.stringify(data); params.type = this.tableType; return params; } }]); return CustomFieldAdapter; }(_AdapterBase2["default"]); var _default = CustomFieldAdapter; exports["default"] = _default; },{"./AdapterBase":39}],44:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; 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, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } /* Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) */ /* global tinyMCE */ var ValidationRules = { "float": function float(str) { var floatstr = /^[-+]?[0-9]+(\.[0-9]+)?$/; if (str != null && str.match(floatstr)) { return true; } return false; }, number: function number(str) { var numstr = /^[0-9]+$/; if (str != null && str.match(numstr)) { return true; } return false; }, numberOrEmpty: function numberOrEmpty(str) { if (str === '') { return true; } var numstr = /^[0-9]+$/; if (str != null && str.match(numstr)) { return true; } return false; }, email: function email(str) { var emailPattern = /^\s*[\w\-+_]+(\.[\w\-+_]+)*@[\w\-+_]+\.[\w\-+_]+(\.[\w\-+_]+)*\s*$/; return str != null && emailPattern.test(str); }, emailOrEmpty: function emailOrEmpty(str) { if (str === '') { return true; } var emailPattern = /^\s*[\w\-+_]+(\.[\w\-+_]+)*@[\w\-+_]+\.[\w\-+_]+(\.[\w\-+_]+)*\s*$/; return str != null && emailPattern.test(str); }, username: function username(str) { var username = /^[a-zA-Z0-9.-]+$/; return str != null && username.test(str); }, input: function input(str) { if (str != null && str.length > 0) { return true; } return false; } }; var FormValidation = /*#__PURE__*/function () { function FormValidation(formId, validateAll, options) { _classCallCheck(this, FormValidation); this.tempOptions = {}; this.formId = formId; this.formError = false; this.formObject = null; this.errorMessages = ''; this.popupDialog = null; this.validateAll = validateAll; this.errorMap = []; this.settings = { thirdPartyPopup: null, LabelErrorClass: false, ShowPopup: true }; this.settings = jQuery.extend(this.settings, options); this.inputTypes = ['text', 'radio', 'checkbox', 'file', 'password', 'select-one', 'select-multi', 'textarea', 'fileupload', 'signature']; this.validator = ValidationRules; } // eslint-disable-next-line no-unused-vars _createClass(FormValidation, [{ key: "clearError", value: function clearError(formInput, overrideMessage) { var id = formInput.attr('id'); $("#".concat(this.formId, " #field_").concat(id)).removeClass('error'); $("#".concat(this.formId, " #help_").concat(id)).html(''); } // eslint-disable-next-line no-unused-vars }, { key: "addError", value: function addError(formInput, overrideMessage) { this.formError = true; if (formInput.attr('message') != null) { this.errorMessages += "".concat(formInput.attr('message'), "\n"); this.errorMap[formInput.attr('name')] = formInput.attr('message'); } else { this.errorMap[formInput.attr('name')] = ''; } var id = formInput.attr('id'); var validation = formInput.attr('validation'); var message = formInput.attr('validation'); $("#".concat(this.formId, " #field_").concat(id)).addClass('error'); if (message === undefined || message == null || message === '') { $("#".concat(this.formId, " #help_err_").concat(id)).html(message); } else if (validation === undefined || validation == null || validation === '') { $("#".concat(this.formId, " #help_err_").concat(id)).html('Required'); } else if (validation === 'float' || validation === 'number') { $("#".concat(this.formId, " #help_err_").concat(id)).html('Number required'); } else if (validation === 'email') { $("#".concat(this.formId, " #help_err_").concat(id)).html('Email required'); } else { $("#".concat(this.formId, " #help_err_").concat(id)).html('Required'); } } }, { key: "showErrors", value: function showErrors() { if (this.formError) { if (this.settings.thirdPartyPopup !== undefined && this.settings.thirdPartyPopup != null) { this.settings.thirdPartyPopup.alert(); } else if (this.settings.ShowPopup === true) { if (this.tempOptions.popupTop !== undefined && this.tempOptions.popupTop != null) { this.alert('Errors Found', this.errorMessages, this.tempOptions.popupTop); } else { this.alert('Errors Found', this.errorMessages, -1); } } } } }, { key: "checkValues", value: function checkValues(options) { this.tempOptions = options; var that = this; this.formError = false; this.errorMessages = ''; this.formObject = {}; // eslint-disable-next-line consistent-return var validate = function validate(inputObject) { var inputValue = null; var name = inputObject.attr('name'); if (that.settings.LabelErrorClass !== false) { $("label[for='".concat(name, "']")).removeClass(that.settings.LabelErrorClass); } var id = inputObject.attr('id'); var type = inputObject.attr('type'); if (inputObject.hasClass('select2-focusser') || inputObject.hasClass('select2-input')) { return true; } if (jQuery.inArray(type, that.inputTypes) >= 0) { if (inputObject.hasClass('uploadInput')) { inputValue = inputObject.attr('val'); } else if (type === 'radio' || type === 'checkbox') { inputValue = $("input[name='".concat(name, "']:checked")).val(); } else if (inputObject.hasClass('select2Field')) { if ($("#".concat(that.formId, " #").concat(id)).select2('data') != null && $("#".concat(that.formId, " #").concat(id)).select2('data') !== undefined) { inputValue = $("#".concat(that.formId, " #").concat(id)).select2('data').id; } else { inputValue = ''; } } else if (inputObject.hasClass('select2Multi')) { if ($("#".concat(that.formId, " #").concat(id)).select2('data') != null && $("#".concat(that.formId, " #").concat(id)).select2('data') !== undefined) { var inputValueObjects = $("#".concat(that.formId, " #").concat(id)).select2('data'); inputValue = []; for (var i = 0; i < inputValueObjects.length; i++) { inputValue.push(inputValueObjects[i].id); } inputValue = JSON.stringify(inputValue); } else { inputValue = ''; } } else if (inputObject.hasClass('signatureField')) { if ($("#".concat(that.formId, " #").concat(id)).data('signaturePad').isEmpty()) { inputValue = ''; } else { inputValue = $("#".concat(id)).data('signaturePad').toDataURL(); } } else if (inputObject.hasClass('simplemde')) { inputValue = $("#".concat(that.formId, " #").concat(id)).data('simplemde').value(); } else if (inputObject.hasClass('code')) { inputValue = $("#".concat(that.formId, " #").concat(id)).data('codemirror').getValue(); } else if (inputObject.hasClass('tinymce')) { inputValue = tinyMCE.get(id).getContent({ format: 'raw' }); } else { inputValue = inputObject.val(); } var validation = inputObject.attr('validation'); var valid = false; if (validation !== undefined && validation != null && that.validator[validation] !== undefined && that.validator[validation] != null) { valid = that.validator[validation](inputValue); } else { if (that.validateAll) { if (validation !== undefined && validation != null && validation === 'none') { valid = true; } else { valid = that.validator.input(inputValue); } } else { valid = true; } that.formObject[id] = inputValue; } if (!valid) { that.addError(inputObject, null); } else { that.clearError(inputObject, null); that.formObject[id] = inputValue; } } }; var inputs = $("#".concat(this.formId, " :input")); inputs.each(function () { validate($(this)); }); inputs = $("#".concat(this.formId, " .uploadInput")); inputs.each(function () { validate($(this)); }); this.showErrors(); this.tempOptions = {}; return !this.formError; } }, { key: "getFormParameters", value: function getFormParameters() { return this.formObject; } }, { key: "alert", value: function (_alert) { function alert(_x, _x2) { return _alert.apply(this, arguments); } alert.toString = function () { return _alert.toString(); }; return alert; }(function (title, text) { alert(text); }) }], [{ key: "getValidationRules", value: function getValidationRules() { return ValidationRules; } }]); return FormValidation; }(); var _default = FormValidation; exports["default"] = _default; },{}],45:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; 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, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } var axios = require('axios'); var IceApiClient = /*#__PURE__*/function () { function IceApiClient(baseUrl, token, clientBaseUrl) { var legacyApiWrapper = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true; _classCallCheck(this, IceApiClient); this.baseUrl = baseUrl; this.token = token; this.clientBaseUrl = clientBaseUrl; this.legacyApiWrapper = legacyApiWrapper; } _createClass(IceApiClient, [{ key: "get", value: function get(endpoint) { if (this.legacyApiWrapper) { var url = "".concat(this.clientBaseUrl, "api/index.php?token=").concat(this.token, "&method=get&url=/").concat(endpoint); return axios.get(url); } return axios.get(this.baseUrl + endpoint, { headers: { Authorization: "Bearer ".concat(this.token) } }); } }]); return IceApiClient; }(); var _default = IceApiClient; exports["default"] = _default; },{"axios":98}],46:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; var _AdapterBase2 = _interopRequireDefault(require("./AdapterBase")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(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, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { 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; } 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 { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 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 } }); if (superClass) _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } var LogViewAdapter = /*#__PURE__*/function (_AdapterBase) { _inherits(LogViewAdapter, _AdapterBase); var _super = _createSuper(LogViewAdapter); function LogViewAdapter() { _classCallCheck(this, LogViewAdapter); return _super.apply(this, arguments); } _createClass(LogViewAdapter, [{ key: "getLogs", value: function getLogs(id) { var object = { id: id }; var reqJson = JSON.stringify(object); var callBackData = []; callBackData.callBackData = []; callBackData.callBackSuccess = 'getLogsSuccessCallBack'; callBackData.callBackFail = 'getLogsFailCallBack'; this.customAction('getLogs', "admin=".concat(this.modulePathName), reqJson, callBackData); } }, { key: "getLogsSuccessCallBack", value: function getLogsSuccessCallBack(callBackData) { var tableLog = '_days_
Notes
'; var rowLog = '_date_  _status_
_note_'; var logs = callBackData.data; var html = ''; var rowsLogs = ''; for (var i = 0; i < logs.length; i++) { var trow = rowLog; trow = trow.replace(/_date_/g, logs[i].time); trow = trow.replace(/_status_/g, "".concat(logs[i].status_from, " -> ").concat(logs[i].status_to)); trow = trow.replace(/_note_/g, logs[i].note); rowsLogs += trow; } if (rowsLogs !== '') { tableLog = tableLog.replace('_days_', rowsLogs); html += tableLog; } this.showMessage('Logs', html); timeUtils.convertToRelativeTime($('.logTime')); } // eslint-disable-next-line no-unused-vars }, { key: "getLogsFailCallBack", value: function getLogsFailCallBack(callBackData) { this.showMessage('Error', 'Error occured while getting data'); } }]); return LogViewAdapter; }(_AdapterBase2["default"]); var _default = LogViewAdapter; exports["default"] = _default; },{"./AdapterBase":39}],47:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; 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, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } var axios = require('axios'); var MasterDataReader = /*#__PURE__*/function () { function MasterDataReader(adapter) { _classCallCheck(this, MasterDataReader); this.adapter = adapter; this.requestCache = this.adapter.requestCache; } _createClass(MasterDataReader, [{ key: "fetchMasterData", value: function fetchMasterData(fieldMaster) { var _this = this; var method = ''; var methodParams = ''; if (fieldMaster[3] != null) { method = fieldMaster[3]; } if (fieldMaster[4] != null) { methodParams = JSON.stringify(fieldMaster[4]); } var key = this.requestCache.getKey(this.adapter.moduleRelativeURL, { t: fieldMaster[0], key: fieldMaster[1], value: fieldMaster[2], method: method, methodParams: methodParams, a: 'getFieldValues' }); var cacheData = this.requestCache.getData(key); if (cacheData != null && cacheData.status === 'SUCCESS') { return new Promise(function (resolve, reject) { return resolve(cacheData.data); }); } var urlData = { t: fieldMaster[0], key: fieldMaster[1], value: fieldMaster[2], method: method, methodParams: methodParams, a: 'getFieldValues' }; var url = "".concat(this.adapter.moduleRelativeURL, "?_url=1"); for (var index in urlData) { url = "".concat(url, "&").concat(index, "=").concat(encodeURIComponent(urlData[index])); } // TODO - Should be a get request return axios.post(url, {}).then(function (response) { if (response.data.status !== 'SUCCESS') { throw Error("Response for ".concat(key, " failed")); } _this.requestCache.setData(key, response.data); return response.data.data; }); } }, { key: "updateAllMasterData", value: function updateAllMasterData() { var _this2 = this; var remoteSourceFields = this.adapter.getRemoteSourceFields(); var promiseList = []; for (var i = 0; i < remoteSourceFields.length; i++) { var fieldRemote = remoteSourceFields[i]; if (fieldRemote[1]['remote-source'] !== undefined && fieldRemote[1]['remote-source'] != null) { (function () { var key = "".concat(fieldRemote[1]['remote-source'][0], "_").concat(fieldRemote[1]['remote-source'][1], "_").concat(fieldRemote[1]['remote-source'][2]); if (fieldRemote[1]['remote-source'].length === 4) { key = "".concat(key, "_").concat(fieldRemote[1]['remote-source'][3]); } var masterDataPromise = _this2.fetchMasterData(fieldRemote[1]['remote-source']).then(function (data) { _this2.adapter.fieldMasterData[key] = data; }); promiseList.push(masterDataPromise); })(); } } return Promise.all(promiseList); } }]); return MasterDataReader; }(); var _default = MasterDataReader; exports["default"] = _default; },{"axios":98}],48:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; var _FormValidation = _interopRequireDefault(require("./FormValidation")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": 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, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } /** * The base class for providing core functions to all module classes. * @class Base.js */ var ModuleBase = /*#__PURE__*/function () { function ModuleBase() { _classCallCheck(this, ModuleBase); this.deleteParams = {}; this.createRemoteTable = false; this.instanceId = 'None'; this.ga = []; this.showAddNew = true; this.showEdit = true; this.showDelete = true; this.showSave = true; this.showCancel = true; this.showFormOnPopup = false; this.filtersAlreadySet = false; this.currentFilterString = ''; this.sorting = 0; this.settings = {}; this.translations = {}; this.customFields = []; this.csrfRequired = false; this.fieldTemplates = null; this.templates = null; this.customTemplates = null; this.emailTemplates = null; this.fieldMasterData = {}; this.fieldMasterDataKeys = {}; this.fieldMasterDataCallback = null; this.sourceMapping = null; this.currentId = null; this.currentElement = null; this.user = null; this.currentProfile = null; this.permissions = {}; this.baseUrl = null; this.clientUrl = null; this.that = this; } // eslint-disable-next-line no-unused-vars _createClass(ModuleBase, [{ key: "init", value: function init(appName, currentView, dataUrl, permissions) {} }, { key: "initForm", value: function initForm() {} }, { key: "setObjectTypeName", value: function setObjectTypeName(objectTypeName) { this.objectTypeName = objectTypeName; } /** * Some browsers do not support sending JSON in get parameters. Set this to true to avoid sending JSON * @method setNoJSONRequests * @param val {Boolean} */ }, { key: "setNoJSONRequests", value: function setNoJSONRequests(val) { this.noJSONRequests = val; } }, { key: "setPermissions", value: function setPermissions(permissions) { this.permissions = permissions; } }, { key: "sortingStarted", value: function sortingStarted(val) { this.sorting = val; } /** * Check if the current user has a permission * @method checkPermission * @param permission {String} * @example * this.checkPermission("Upload/Delete Profile Image") */ }, { key: "checkPermission", value: function checkPermission(permission) { if (this.permissions[permission] === undefined || this.permissions[permission] == null || this.permissions[permission] === 'Yes') { return 'Yes'; } return this.permissions[permission]; } }, { key: "setBaseUrl", value: function setBaseUrl(url) { this.baseUrl = url; } }, { key: "setClientUrl", value: function setClientUrl(url) { this.clientUrl = url; } }, { key: "setUser", value: function setUser(user) { this.user = user; } }, { key: "getUser", value: function getUser() { return this.user; } }, { key: "setInstanceId", value: function setInstanceId(id) { this.instanceId = id; } }, { key: "setCSRFRequired", value: function setCSRFRequired(val) { this.csrfRequired = val; } }, { key: "scrollToTop", value: function scrollToTop() { $('html, body').animate({ scrollTop: 0 }, 'fast'); } }, { key: "scrollToBottom", value: function scrollToBottom() { $('html, body').animate({ scrollTop: $(document).height() }, 'slow'); } }, { key: "scrollToElement", value: function scrollToElement(element) { if ($(window).height() <= element.offset().top) { $('html, body').animate({ scrollTop: element.offset().top }, 'slow'); } } }, { key: "scrollToElementBottom", value: function scrollToElementBottom(element) { if ($(window).height() <= element.offset().top + element.height()) { $('html, body').animate({ scrollTop: element.offset().top + element.height() }, 'slow'); } } }, { key: "setTranslations", value: function setTranslations(txt) { this.translations = txt.messages['']; } }, { key: "setTranslationsSubModules", value: function setTranslationsSubModules(translations) { this.translations = translations; } }, { key: "gt", value: function gt(key) { if (this.translations[key] === undefined || this.translations[key] === null) { console.log("Tr:".concat(key)); return key; } return this.translations[key][0]; } }, { key: "addToLangTerms", value: function addToLangTerms(key) { var termsArr; var terms = localStorage.getItem('terms'); if (terms === undefined) { termsArr = {}; } else { try { termsArr = JSON.parse(terms); } catch (e) { termsArr = {}; } } if (this.translations[key] === undefined) { termsArr[key] = key; localStorage.setItem('terms', JSON.stringify(termsArr)); } } /** * If this method returned false the action buttons in data table for modules will not be displayed. * Override this method in module lib.js to hide action buttons * @method showActionButtons * @param permission {String} * @example * EmployeeLeaveEntitlementAdapter.method('showActionButtons() { * return false; * } */ }, { key: "showActionButtons", value: function showActionButtons() { return true; } }, { key: "trackEvent", value: function trackEvent(action, label, value) { try { if (label === undefined || label == null) { this.ga.push(['_trackEvent', this.instanceId, action]); } else if (value === undefined || value == null) { this.ga.push(['_trackEvent', this.instanceId, action, label]); } else { this.ga.push(['_trackEvent', this.instanceId, action, label, value]); } } catch (e) {// Do nothing } } }, { key: "setCurrentProfile", value: function setCurrentProfile(currentProfile) { this.currentProfile = currentProfile; } /** * Get the current profile * @method getCurrentProfile * @returns Profile of the current user if the profile is not switched if not switched profile */ }, { key: "getCurrentProfile", value: function getCurrentProfile() { return this.currentProfile; } /** * Retrive data required to create select boxes for add new /edit forms for a given module. This is called when loading the module * @method initFieldMasterData * @param callback {Function} call this once loading completed * @param callback {Function} call this once all field loading completed. This indicate that the form can be displayed saftly * @example * ReportAdapter.method('renderForm(object) { * var that = this; * this.processFormFieldsWithObject(object); * var cb = function(){ * that.super.renderForm(object); * }; * this.initFieldMasterData(cb); * } */ }, { key: "initFieldMasterData", value: function initFieldMasterData(callback, loadAllCallback, loadAllCallbackData) { this.fieldMasterData = {}; this.fieldMasterDataKeys = {}; this.fieldMasterDataCallback = loadAllCallback; this.fieldMasterDataCallbackData = loadAllCallbackData; var remoteSourceFields = this.getRemoteSourceFields(); for (var i = 0; i < remoteSourceFields.length; i++) { var fieldRemote = remoteSourceFields[i]; if (fieldRemote[1]['remote-source'] !== undefined && fieldRemote[1]['remote-source'] != null) { // let key = `${fieldRemote[1]['remote-source'][0]}_${fieldRemote[1]['remote-source'][1]}_${fieldRemote[1]['remote-source'][2]}`; // if (fieldRemote[1]['remote-source'].length === 4) { // key = `${key}_${fieldRemote[1]['remote-source'][3]}`; // } var key = this.getRemoteSourceKey(fieldRemote); this.fieldMasterDataKeys[key] = false; var callBackData = {}; callBackData.callBack = 'initFieldMasterDataResponse'; callBackData.callBackData = [key]; if (callback !== null && callback !== undefined) { callBackData.callBackSuccess = callback; } this.getFieldValues(fieldRemote[1]['remote-source'], callBackData); } } } }, { key: "initSourceMappings", value: function initSourceMappings() { this.sourceMapping = {}; var remoteSourceFields = this.getRemoteSourceFields(); for (var i = 0; i < remoteSourceFields.length; i++) { var fieldRemote = remoteSourceFields[i]; if (fieldRemote[1]['remote-source'] !== undefined && fieldRemote[1]['remote-source'] != null) { this.sourceMapping[fieldRemote[0]] = fieldRemote[1]['remote-source']; } } } }, { key: "getRemoteSourceKey", value: function getRemoteSourceKey(field) { var key = "".concat(field[1]['remote-source'][0], "_").concat(field[1]['remote-source'][1], "_").concat(field[1]['remote-source'][2]); if (field[1]['remote-source'].length > 3) { key = "".concat(key, "_").concat(field[1]['remote-source'][3]); } return key; } }, { key: "getRemoteSourceFields", value: function getRemoteSourceFields() { var values; var fields = this.getFormFields(); var filterFields = this.getFilters(); if (filterFields != null) { for (var j = 0; j < filterFields.length; j++) { values = this.getMetaFieldValues(filterFields[j][0], fields); if (values == null || values.type !== 'select' && values.type !== 'select2' && values.type !== 'select2multi') { fields.push(filterFields[j]); } } } var remoteSourceFields = []; var remoteSourceFieldKeys = []; var field = null; var fieldSub = null; for (var i = 0; i < fields.length; i++) { field = fields[i]; if (field[1]['remote-source'] !== undefined && field[1]['remote-source'] !== null) { var key = this.getRemoteSourceKey(field); if (remoteSourceFieldKeys.indexOf(key) < 0) { remoteSourceFields.push(field); remoteSourceFieldKeys.push(key); } } else if (field[1].form !== undefined && field[1].form !== null) { for (var _j = 0; _j < field[1].form.length; _j++) { fieldSub = field[1].form[_j]; if (fieldSub[1]['remote-source'] !== undefined && fieldSub[1]['remote-source'] !== null) { var _key = this.getRemoteSourceKey(fieldSub); if (remoteSourceFieldKeys.indexOf(_key) < 0) { remoteSourceFields.push(fieldSub); remoteSourceFieldKeys.push(_key); } } } } } return remoteSourceFields; } /** * Pass true to this method after creating module JS object to open new/edit entry form for the module on a popup. * @method setShowFormOnPopup * @param val {Boolean} * @example * modJs.subModJsList['tabCandidateApplication'] = new CandidateApplicationAdapter('Application','CandidateApplication',{"candidate":data.id} * modJs.subModJsList['tabCandidateApplication'].setShowFormOnPopup(true); */ }, { key: "setShowFormOnPopup", value: function setShowFormOnPopup(val) { this.showFormOnPopup = val; } /** * Set this to true to if you need the datatable to load data page by page instead of loading all data at once. * @method setRemoteTable * @param val {Boolean} * @example * modJs.subModJsList['tabCandidateApplication'] = new CandidateApplicationAdapter('Application','CandidateApplication',{"candidate":data.id} * modJs.subModJsList['tabCandidateApplication'].setRemoteTable(true); */ }, { key: "setRemoteTable", value: function setRemoteTable(val) { this.createRemoteTable = val; } }, { key: "setSettings", value: function setSettings(val) { this.settings = val; } }, { key: "getRemoteTable", value: function getRemoteTable() { return this.createRemoteTable; } }, { key: "isAllLoaded", value: function isAllLoaded(fieldMasterDataKeys) { for (var key in fieldMasterDataKeys) { if (fieldMasterDataKeys[key] === false) { return false; } } return true; } // eslint-disable-next-line no-unused-vars }, { key: "initFieldMasterDataResponse", value: function initFieldMasterDataResponse(key, data, callback, loadAllCallbackData) { this.fieldMasterData[key] = data; this.fieldMasterDataKeys[key] = true; if (callback !== undefined && callback !== null) { callback(); } if (this.fieldMasterDataCallback !== null && this.fieldMasterDataCallback !== undefined && this.isAllLoaded(this.fieldMasterDataKeys) && this.fieldMasterDataCallbackData !== null && this.fieldMasterDataCallbackData !== undefined) { this.fieldMasterDataCallback(this.fieldMasterDataCallbackData); } else if (this.fieldMasterDataCallback !== null && this.fieldMasterDataCallback !== undefined && this.isAllLoaded(this.fieldMasterDataKeys)) { this.fieldMasterDataCallback(); } } }, { key: "getMetaFieldValues", value: function getMetaFieldValues(key, fields) { for (var i = 0; i < fields.length; i++) { if (key === fields[i][0]) { return fields[i][1]; } } return null; } }, { key: "getThemeColors", value: function getThemeColors() { var colors = ['red', 'yellow', 'aqua', 'blue', 'light-blue', 'green', 'navy', 'teal', 'olive', 'orange', 'fuchsia', 'purple']; return colors; } }, { key: "getColorByRandomString", value: function getColorByRandomString(string) { var colors = this.getThemeColors(); var k = string.charCodeAt(0); return colors[k % colors.length]; } }, { key: "getColorByFileType", value: function getColorByFileType(type) { type = type.toLowerCase(); var colorMap = {}; colorMap.pdf = 'red'; colorMap.csv = 'yellow'; colorMap.xls = 'green'; colorMap.xlsx = 'green'; colorMap.doc = 'light-blue'; colorMap.docx = 'light-blue'; colorMap.docx = 'blue'; colorMap.ppt = 'orange'; colorMap.pptx = 'orange'; colorMap.jpg = 'teal'; colorMap.jpeg = 'teal'; colorMap.gif = 'green'; colorMap.png = 'yellow'; colorMap.bmp = 'fuchsia'; if (colorMap[type] !== undefined || colorMap[type] != null) { return colorMap[type]; } return this.getColorByRandomString(type); } }, { key: "getIconByFileType", value: function getIconByFileType(type) { type = type.toLowerCase(); var iconMap = {}; iconMap.pdf = 'fa fa-file-pdf-o'; iconMap.csv = 'fa fa fa-file-code-o'; iconMap.xls = 'fa fa-file-excel-o'; iconMap.xlsx = 'fa fa-file-excel-o'; iconMap.doc = 'fa fa-file-word-o'; iconMap.docx = 'fa fa-file-word-o'; iconMap.ppt = 'fa fa-file-powerpoint-o'; iconMap.pptx = 'fa fa-file-powerpoint-o'; iconMap.jpg = 'fa fa-file-image-o'; iconMap.jpeg = 'fa fa-file-image-o'; iconMap.gif = 'fa fa-file-image-o'; iconMap.png = 'fa fa-file-image-o'; iconMap.bmp = 'fa fa-file-image-o'; iconMap.txt = 'fa fa-file-text-o'; iconMap.rtf = 'fa fa-file-text-o'; if (iconMap[type] !== undefined || iconMap[type] != null) { return iconMap[type]; } return 'fa fa-file-o'; } }, { key: "getSourceMapping", value: function getSourceMapping() { return this.sourceMapping; } }, { key: "setTesting", value: function setTesting(testing) { this.testing = testing; } }, { key: "consoleLog", value: function consoleLog(message) { if (this.testing) { console.log(message); } } }, { key: "setClientMessages", value: function setClientMessages(msgList) { this.msgList = msgList; } }, { key: "setTemplates", value: function setTemplates(templates) { this.templates = templates; } }, { key: "getWSProperty", value: function getWSProperty(array, key) { if (array.hasOwnProperty(key)) { return array[key]; } return null; } }, { key: "getClientMessage", value: function getClientMessage(key) { return this.getWSProperty(this.msgList, key); } }, { key: "getTemplate", value: function getTemplate(key) { return this.getWSProperty(this.templates, key); } }, { key: "setGoogleAnalytics", value: function setGoogleAnalytics(gaq) { this.gaq = gaq; } }, { key: "showView", value: function showView(view) { if (this.currentView != null) { this.previousView = this.currentView; $("#".concat(this.currentView)).hide(); } $("#".concat(view)).show(); this.currentView = view; this.moveToTop(); } }, { key: "showPreviousView", value: function showPreviousView() { this.showView(this.previousView); } }, { key: "moveToTop", value: function moveToTop() {} }, { key: "callFunction", value: function callFunction(callback, cbParams, thisParam) { if ($.isFunction(callback)) { try { if (thisParam === undefined || thisParam === null) { callback.apply(document, cbParams); } else { callback.apply(thisParam, cbParams); } } catch (e) { console.log(e.message); } } else { var f = this[callback]; if ($.isFunction(f)) { try { f.apply(this, cbParams); } catch (e) { console.log(e.message); } } } } }, { key: "getTableTopButtonHtml", value: function getTableTopButtonHtml() { var html = ''; if (this.getShowAddNew()) { html = ""); } if (this.getFilters() != null) { if (html !== '') { html += '  '; } html += ""); html += '  '; if (this.filtersAlreadySet) { html += ''; } else { html += ''; } } html = html.replace(/__id__/g, this.getTableName()); if (this.currentFilterString !== '' && this.currentFilterString != null) { html = html.replace(/__filterString__/g, this.currentFilterString); } else { html = html.replace(/__filterString__/g, 'Reset Filters'); } if (html !== '') { html = "
".concat(html, "
"); } return html; } }, { key: "getActionButtonHeader", value: function getActionButtonHeader() { return { sTitle: '', sClass: 'center' }; } }, { key: "getTableHTMLTemplate", value: function getTableHTMLTemplate() { return '
'; } }, { key: "isSortable", value: function isSortable() { return true; } /** * Create the data table on provided element id * @method createTable * @param val {Boolean} */ }, { key: "createTable", value: function createTable(elementId) { var that = this; if (this.getRemoteTable()) { this.createTableServer(elementId); return; } var headers = this.getHeaders(); // add translations for (var index in headers) { headers[index].sTitle = this.gt(headers[index].sTitle); } var data = this.getTableData(); if (this.showActionButtons()) { headers.push(this.getActionButtonHeader()); } if (this.showActionButtons()) { for (var i = 0; i < data.length; i++) { data[i].push(this.getActionButtonsHtml(data[i][0], data[i])); } } var html = ''; html = this.getTableTopButtonHtml() + this.getTableHTMLTemplate(); /* if(this.getShowAddNew()){ html = this.getTableTopButtonHtml()+'
'; }else{ html = '
'; } */ // Find current page var activePage = $("#".concat(elementId, " .dataTables_paginate .active a")).html(); var start = 0; if (activePage !== undefined && activePage != null) { start = parseInt(activePage, 10) * 15 - 15; } $("#".concat(elementId)).html(html); var dataTableParams = { oLanguage: { sLengthMenu: '_MENU_ records per page' }, aaData: data, aoColumns: headers, bSort: that.isSortable(), iDisplayLength: 15, iDisplayStart: start }; var customTableParams = this.getCustomTableParams(); $.extend(dataTableParams, customTableParams); $("#".concat(elementId, " #grid")).dataTable(dataTableParams); $('.dataTables_paginate ul').addClass('pagination'); $('.dataTables_length').hide(); $('.dataTables_filter input').addClass('form-control'); $('.dataTables_filter input').attr('placeholder', 'Search'); $('.dataTables_filter label').contents().filter(function () { return this.nodeType === 3; }).remove(); $('.tableActionButton').tooltip(); } /** * Create a data table on provided element id which loads data page by page * @method createTableServer * @param val {Boolean} */ }, { key: "createTableServer", value: function createTableServer(elementId) { var that = this; var headers = this.getHeaders(); headers.push({ sTitle: '', sClass: 'center' }); // add translations for (var index in headers) { headers[index].sTitle = this.gt(headers[index].sTitle); } var html = ''; html = this.getTableTopButtonHtml() + this.getTableHTMLTemplate(); // Find current page var activePage = $("#".concat(elementId, " .dataTables_paginate .active a")).html(); var start = 0; if (activePage !== undefined && activePage != null) { start = parseInt(activePage, 10) * 15 - 15; } $("#".concat(elementId)).html(html); var dataTableParams = { oLanguage: { sLengthMenu: '_MENU_ records per page' }, bProcessing: true, bServerSide: true, sAjaxSource: that.getDataUrl(that.getDataMapping()), aoColumns: headers, bSort: that.isSortable(), parent: that, iDisplayLength: 15, iDisplayStart: start }; if (this.showActionButtons()) { dataTableParams.aoColumnDefs = [{ fnRender: that.getActionButtons, aTargets: [that.getDataMapping().length] }]; } var customTableParams = this.getCustomTableParams(); $.extend(dataTableParams, customTableParams); $("#".concat(elementId, " #grid")).dataTable(dataTableParams); $('.dataTables_paginate ul').addClass('pagination'); $('.dataTables_length').hide(); $('.dataTables_filter input').addClass('form-control'); $('.dataTables_filter input').attr('placeholder', 'Search'); $('.dataTables_filter label').contents().filter(function () { return this.nodeType === 3; }).remove(); $('.tableActionButton').tooltip(); } /** * This should be overridden in module lib.js classes to return module headers which are used to create the data table. * @method getHeaders * @example SettingAdapter.method('getHeaders() { return [ { "sTitle": "ID" ,"bVisible":false}, { "sTitle": "Name" }, { "sTitle": "Value"}, { "sTitle": "Details"} ]; } */ }, { key: "getHeaders", value: function getHeaders() {} /** * This should be overridden in module lib.js classes to return module field values which are used to create the data table. * @method getDataMapping * @example SettingAdapter.method('getDataMapping() { return [ "id", "name", "value", "description" ]; } */ }, { key: "getDataMapping", value: function getDataMapping() {} /** * This should be overridden in module lib.js classes to return module from fields which are used to create the add/edit form and also used for initializing select box values in form. * @method getFormFields * @example SettingAdapter.method('getFormFields() { return [ [ "id", {"label":"ID","type":"hidden"}], [ "value", {"label":"Value","type":"text","validation":"none"}] ]; } */ }, { key: "getFormFields", value: function getFormFields() {} }, { key: "getTableColumns", value: function getTableColumns() { return []; } }, { key: "getTableData", value: function getTableData() {} /** * This can be overridden in module lib.js classes inorder to show a filter form * @method getFilters * @example EmployeeAdapter.method('getFilters() { return [ [ "job_title", {"label":"Job Title","type":"select2","allow-null":true,"null-label":"All Job Titles","remote-source":["JobTitle","id","name"]}], [ "department", {"label":"Department","type":"select2","allow-null":true,"null-label":"All Departments","remote-source":["CompanyStructure","id","title"]}], [ "supervisor", {"label":"Supervisor","type":"select2","allow-null":true,"null-label":"Anyone","remote-source":["Employee","id","first_name+last_name"]}] ]; } */ }, { key: "getFilters", value: function getFilters() { return null; } /** * Show the edit form for an item * @method edit * @param id {int} id of the item to edit */ }, { key: "edit", value: function edit(id) { this.currentId = id; this.getElement(id, []); } }, { key: "copyRow", value: function copyRow(id) { this.getElement(id, [], true); } }, { key: "renderModel", value: function renderModel(id, header, body) { $("#".concat(id, "ModelBody")).html(''); if (body === undefined || body == null) { body = ''; } $("#".concat(id, "ModelLabel")).html(header); $("#".concat(id, "ModelBody")).html(body); } }, { key: "renderYesNoModel", value: function renderYesNoModel(header, body, yesBtnName, noBtnName, callback, callbackParams) { var that = this; var modelId = '#yesnoModel'; if (body === undefined || body == null) { body = ''; } $("".concat(modelId, "Label")).html(header); $("".concat(modelId, "Body")).html(body); if (yesBtnName != null) { $("".concat(modelId, "YesBtn")).html(yesBtnName); } if (noBtnName != null) { $("".concat(modelId, "NoBtn")).html(noBtnName); } $("".concat(modelId, "YesBtn")).off().on('click', function () { if (callback !== undefined && callback != null) { callback.apply(that, callbackParams); that.cancelYesno(); } }); $(modelId).modal({ backdrop: 'static' }); } }, { key: "renderModelFromDom", value: function renderModelFromDom(id, header, element) { $("#".concat(id, "ModelBody")).html(''); if (element === undefined || element == null) { element = $('
'); } $("#".concat(id, "ModelLabel")).html(header); $("#".concat(id, "ModelBody")).html(''); $("#".concat(id, "ModelBody")).append(element); } /** * Delete an item * @method deleteRow * @param id {int} id of the item to edit */ }, { key: "deleteRow", value: function deleteRow(id) { this.deleteParams.id = id; this.renderModel('delete', 'Confirm Deletion', 'Are you sure you want to delete this item ?'); $('#deleteModel').modal('show'); } /** * Show a popup with message * @method showMessage * @param title {String} title of the message box * @param message {String} message * @param closeCallback {Function} this will be called once the dialog is closed (optional) * @param closeCallback {Function} data to pass to close callback (optional) * @param closeCallbackData * @param isPlain {Boolean} if true buttons are not shown (optional / default = true) * @example * this.showMessage("Error Occured while Applying Leave", callBackData); */ }, { key: "showMessage", value: function showMessage(title, message) { var closeCallback = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; var closeCallbackData = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; var isPlain = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false; var that = this; var modelId = ''; if (isPlain) { modelId = '#plainMessageModel'; } else { modelId = '#messageModel'; } $(modelId).off(); if (isPlain) { this.renderModel('plainMessage', title, message); } else { this.renderModel('message', title, message); } if (closeCallback !== null && closeCallback !== undefined) { $(modelId).modal({ show: true }); $(modelId).on('hidden.bs.modal', function () { closeCallback.apply(that, closeCallbackData); $('.modal-backdrop').remove(); }); } else { $(modelId).modal({ backdrop: 'static' }); } } }, { key: "showDomElement", value: function showDomElement(title, element, closeCallback, closeCallbackData, isPlain) { var that = this; var modelId = ''; if (isPlain) { modelId = '#dataMessageModel'; } else { modelId = '#messageModel'; } $(modelId).unbind('hide'); if (isPlain) { this.renderModelFromDom('dataMessage', title, element); } else { this.renderModelFromDom('message', title, element); } if (closeCallback !== null && closeCallback !== undefined) { $(modelId).modal({ show: true }); $(modelId).on('hidden.bs.modal', function () { closeCallback.apply(that, closeCallbackData); $('.modal-backdrop').remove(); }); } else { $(modelId).modal({ backdrop: 'static' }); } } }, { key: "confirmDelete", value: function confirmDelete() { if (this.deleteParams.id !== undefined || this.deleteParams.id != null) { this.deleteObj(this.deleteParams.id, []); } $('#deleteModel').modal('hide'); } }, { key: "cancelDelete", value: function cancelDelete() { $('#deleteModel').modal('hide'); this.deleteParams.id = null; } }, { key: "closeMessage", value: function closeMessage() { $('#messageModel').modal('hide'); } }, { key: "cancelYesno", value: function cancelYesno() { $('#yesnoModel').modal('hide'); } }, { key: "closePlainMessage", value: function closePlainMessage() { $('#plainMessageModel').modal('hide'); $('#dataMessageModel').modal('hide'); } }, { key: "closeDataMessage", value: function closeDataMessage() { $('#dataMessageModel').modal('hide'); } /** * Create or edit an element * @method save * @param getFunctionCallBackData {Array} once a success is returned call get() function for this module with these parameters * @param successCallback {Function} this will get called after success response */ }, { key: "save", value: function save(callGetFunction, successCallback) { var validator = new _FormValidation["default"]("".concat(this.getTableName(), "_submit"), true, { ShowPopup: false, LabelErrorClass: 'error' }); if (validator.checkValues()) { var params = validator.getFormParameters(); params = this.forceInjectValuesBeforeSave(params); var msg = this.doCustomValidation(params); if (msg == null) { if (this.csrfRequired) { params.csrf = $("#".concat(this.getTableName(), "Form")).data('csrf'); } var id = $("#".concat(this.getTableName(), "_submit #id")).val(); if (id != null && id !== undefined && id !== '') { params.id = id; } params = this.makeEmptyDateFieldsNull(params); this.add(params, [], callGetFunction, successCallback); } else { $("#".concat(this.getTableName(), "Form .label")).html(msg); $("#".concat(this.getTableName(), "Form .label")).show(); this.scrollToTop(); } } } }, { key: "makeEmptyDateFieldsNull", value: function makeEmptyDateFieldsNull(params) { var fields = this.getFormFields(); fields.forEach(function (field) { if ((field[1].type === 'date' || field[1].type === 'datetime') && (params[field[0]] === '' || params[field[0]] === '0000-00-00' || params[field[0]] === '0000-00-00 00:00:00')) { if (field[1].validation === 'none') { params[field[0]] = 'NULL'; } else { delete params[field[0]]; } } }); return params; } }, { key: "validatePassword", value: function validatePassword(password) { if (password.length < 8) { return this.gt('Password too short'); } if (password.length > 30) { return this.gt('Password too long'); } var numberTester = /.*[0-9]+.*$/; if (!password.match(numberTester)) { return this.gt('Password must include at least one number'); } var lowerTester = /.*[a-z]+.*$/; if (!password.match(lowerTester)) { return this.gt('Password must include at least one lowercase letter'); } var upperTester = /.*[A-Z]+.*$/; if (!password.match(upperTester)) { return this.gt('Password must include at least one uppercase letter'); } var symbolTester = /.*[\W]+.*$/; if (!password.match(symbolTester)) { return this.gt('Password must include at least one symbol'); } return null; } /** * Override this method to inject attitional parameters or modify existing parameters retrived from * add/edit form before sending to the server * @method forceInjectValuesBeforeSave * @param params {Array} keys and values in form * @returns {Array} modified parameters */ }, { key: "forceInjectValuesBeforeSave", value: function forceInjectValuesBeforeSave(params) { return params; } /** * Override this method to do custom validations at client side * @method doCustomValidation * @param params {Array} keys and values in form * @returns {Null or String} return null if validation success, returns error message if unsuccessful * @example EmployeeLeaveAdapter.method('doCustomValidation(params) { try{ if(params['date_start'] != params['date_end']){ var ds = new Date(params['date_start']); var de = new Date(params['date_end']); if(de < ds){ return "Start date should be earlier than end date of the leave period"; } } }catch(e){ } return null; } */ // eslint-disable-next-line no-unused-vars }, { key: "doCustomValidation", value: function doCustomValidation(params) { return null; } }, { key: "filterQuery", value: function filterQuery() { var validator = new _FormValidation["default"]("".concat(this.getTableName(), "_filter"), true, { ShowPopup: false, LabelErrorClass: 'error' }); if (validator.checkValues()) { var params = validator.getFormParameters(); if (this.doCustomFilterValidation(params)) { // remove null params for (var prop in params) { if (params.hasOwnProperty(prop)) { if (params[prop] === 'NULL') { delete params[prop]; } } } this.setFilter(params); this.filtersAlreadySet = true; $("#".concat(this.getTableName(), "_resetFilters")).show(); this.currentFilterString = this.getFilterString(params); this.get([]); this.closePlainMessage(); } } } }, { key: "getFilterString", value: function getFilterString(filters) { var str = ''; var rmf; var source; var values; var select2MVal; var value; var valueOrig; var filterFields = this.getFilters(); if (values == null) { values = []; } for (var prop in filters) { if (filters.hasOwnProperty(prop)) { values = this.getMetaFieldValues(prop, filterFields); if (!values) { continue; } value = ''; valueOrig = null; if (values.type === 'select' || values.type === 'select2') { if (values['remote-source'] !== undefined && values['remote-source'] != null) { rmf = values['remote-source']; if (filters[prop] === 'NULL') { if (values['null-label'] !== undefined && values['null-label'] != null) { value = values['null-label']; } else { value = 'Not Selected'; } } else { var key = "".concat(rmf[0], "_").concat(rmf[1], "_").concat(rmf[2]); if (rmf.length > 3) { key = "".concat(key, "_").concat(rmf[3]); } // value = this.fieldMasterData[`${rmf[0]}_${rmf[1]}_${rmf[2]}`][filters[prop]]; value = this.fieldMasterData[key][filters[prop]]; valueOrig = value; } } else { source = values.source[0]; if (filters[prop] === 'NULL') { if (values['null-label'] !== undefined && values['null-label'] != null) { value = values['null-label']; } else { value = 'Not Selected'; } } else { for (var i = 0; i < source.length; i++) { if (filters[prop] === values.source[i][0]) { value = values.source[i][1]; valueOrig = value; break; } } } } } else if (values.type === 'select2multi') { select2MVal = []; try { select2MVal = JSON.parse(filters[prop]); } catch (e) {// Do nothing } value = select2MVal.join(','); if (value !== '') { valueOrig = value; } } else { value = filters[prop]; if (value !== '') { valueOrig = value; } } if (valueOrig != null) { if (str !== '') { str += ' | '; } str += "".concat(values.label, " = ").concat(value); } } } return str; } /** * Override this method to do custom validations at client side for values selected in filters * @method doCustomFilterValidation * @param params {Array} keys and values in form * @returns {Null or String} return null if validation success, returns error message if unsuccessful */ }, { key: "doCustomFilterValidation", value: function doCustomFilterValidation(params) { return true; } /** * Reset selected filters * @method resetFilters */ }, { key: "resetFilters", value: function resetFilters() { this.filter = this.origFilter; this.filtersAlreadySet = false; $("#".concat(this.getTableName(), "_resetFilters")).hide(); this.currentFilterString = ''; this.get([]); } }, { key: "showFilters", value: function showFilters(object) { var formHtml = this.templates.filterTemplate; var html = ''; var fields = this.getFilters(); for (var i = 0; i < fields.length; i++) { var metaField = this.getMetaFieldForRendering(fields[i][0]); if (metaField === '' || metaField === undefined) { html += this.renderFormField(fields[i]); } else { var metaVal = object[metaField]; if (metaVal !== '' && metaVal != null && metaVal !== undefined && metaVal.trim() !== '') { html += this.renderFormField(JSON.parse(metaVal)); } else { html += this.renderFormField(fields[i]); } } } formHtml = formHtml.replace(/_id_/g, "".concat(this.getTableName(), "_filter")); formHtml = formHtml.replace(/_fields_/g, html); var randomFormId = this.generateRandom(14); var $tempDomObj = $('
'); $tempDomObj.attr('id', randomFormId); $tempDomObj.html(formHtml); $tempDomObj.find('.datefield').datepicker({ viewMode: 2 }); $tempDomObj.find('.timefield').datetimepicker({ language: 'en', pickDate: false }); $tempDomObj.find('.datetimefield').datetimepicker({ language: 'en' }); $tempDomObj.find('.colorpick').colorpicker(); tinymce.init({ selector: "#".concat($tempDomObj.attr('id'), " .tinymce"), height: '400' }); $tempDomObj.find('.simplemde').each(function () { var simplemde = new SimpleMDE({ element: $(this)[0] }); $(this).data('simplemde', simplemde); // simplemde.value($(this).val()); }); // $tempDomObj.find('.select2Field').select2(); $tempDomObj.find('.select2Field').each(function () { $(this).select2().select2('val', $(this).find('option:eq(0)').val()); }); $tempDomObj.find('.select2Multi').each(function () { $(this).select2().on('change', function (e) { var parentRow = $(this).parents('.row'); var height = parentRow.find('.select2-choices').height(); parentRow.height(parseInt(height, 10)); }); }); /* $tempDomObj.find('.signatureField').each(function() { $(this).data('signaturePad',new SignaturePad($(this))); }); */ // var tHtml = $tempDomObj.wrap('
').parent().html(); this.showDomElement('Edit', $tempDomObj, null, null, true); $('.filterBtn').off(); $('.filterBtn').on('click', function (e) { e.preventDefault(); e.stopPropagation(); try { modJs.filterQuery(); } catch (err) { console.log(err); console.log(err.message); } return false; }); if (this.filter !== undefined && this.filter != null && this.filter !== '') { this.fillForm(this.filter, "#".concat(this.getTableName(), "_filter"), this.getFilters()); } } /** * Override this method in your module class to make changes to data fo the form before showing the form * @method preRenderForm * @param object {Array} keys value list for populating form */ }, { key: "preRenderForm", value: function preRenderForm(object) {} /** * Create the form * @method renderForm * @param object {Array} keys value list for populating form */ }, { key: "renderForm", value: function renderForm(object) { var signatureIds = []; if (object == null || object === undefined) { this.currentId = null; } this.preRenderForm(object); var formHtml = this.templates.formTemplate; var html = ''; var fields = this.getFormFields(); for (var i = 0; i < fields.length; i++) { var metaField = this.getMetaFieldForRendering(fields[i][0]); if (metaField === '' || metaField === undefined) { html += this.renderFormField(fields[i]); } else { var metaVal = object[metaField]; if (metaVal !== '' && metaVal != null && metaVal !== undefined && metaVal.trim() !== '') { html += this.renderFormField(JSON.parse(metaVal)); } else { html += this.renderFormField(fields[i]); } } } formHtml = formHtml.replace(/_id_/g, "".concat(this.getTableName(), "_submit")); formHtml = formHtml.replace(/_fields_/g, html); var $tempDomObj; var randomFormId = this.generateRandom(14); if (!this.showFormOnPopup) { $tempDomObj = $("#".concat(this.getTableName(), "Form")); } else { $tempDomObj = $('
'); $tempDomObj.attr('id', randomFormId); } $tempDomObj.html(formHtml); $tempDomObj.find('.datefield').datepicker({ viewMode: 2 }); $tempDomObj.find('.timefield').datetimepicker({ language: 'en', pickDate: false }); $tempDomObj.find('.datetimefield').datetimepicker({ language: 'en' }); $tempDomObj.find('.colorpick').colorpicker(); tinymce.init({ selector: "#".concat($tempDomObj.attr('id'), " .tinymce"), height: '400' }); $tempDomObj.find('.simplemde').each(function () { var simplemde = new SimpleMDE({ element: $(this)[0] }); $(this).data('simplemde', simplemde); // simplemde.value($(this).val()); }); var codeMirror = this.codeMirror; if (codeMirror) { $tempDomObj.find('.code').each(function () { var editor = codeMirror.fromTextArea($(this)[0], { lineNumbers: false, matchBrackets: true, continueComments: 'Enter', extraKeys: { 'Ctrl-Q': 'toggleComment' } }); $(this).data('codemirror', editor); }); } // $tempDomObj.find('.select2Field').select2(); $tempDomObj.find('.select2Field').each(function () { $(this).select2().select2('val', $(this).find('option:eq(0)').val()); }); $tempDomObj.find('.select2Multi').each(function () { $(this).select2().on('change', function (e) { var parentRow = $(this).parents('.row'); var height = parentRow.find('.select2-choices').height(); parentRow.height(parseInt(height, 10)); }); }); $tempDomObj.find('.signatureField').each(function () { // $(this).data('signaturePad',new SignaturePad($(this))); signatureIds.push($(this).attr('id')); }); for (var _i = 0; _i < fields.length; _i++) { if (fields[_i][1].type === 'datagroup') { $tempDomObj.find("#".concat(fields[_i][0])).data('field', fields[_i]); } } if (this.showSave === false) { $tempDomObj.find('.saveBtn').remove(); } else { $tempDomObj.find('.saveBtn').off(); $tempDomObj.find('.saveBtn').data('modJs', this); $tempDomObj.find('.saveBtn').on('click', function () { if ($(this).data('modJs').saveSuccessItemCallback != null && $(this).data('modJs').saveSuccessItemCallback !== undefined) { $(this).data('modJs').save($(this).data('modJs').retriveItemsAfterSave(), $(this).data('modJs').saveSuccessItemCallback); } else { $(this).data('modJs').save(); } return false; }); } if (this.showCancel === false) { $tempDomObj.find('.cancelBtn').remove(); } else { $tempDomObj.find('.cancelBtn').off(); $tempDomObj.find('.cancelBtn').data('modJs', this); $tempDomObj.find('.cancelBtn').on('click', function () { $(this).data('modJs').cancel(); return false; }); } // Input mask $tempDomObj.find('[mask]').each(function () { $(this).inputmask($(this).attr('mask')); }); $tempDomObj.find('[datemask]').each(function () { $(this).inputmask({ mask: 'y-1-2', placeholder: 'YYYY-MM-DD', leapday: '-02-29', separator: '-', alias: 'yyyy/mm/dd' }); }); $tempDomObj.find('[datetimemask]').each(function () { $(this).inputmask('datetime', { mask: 'y-2-1 h:s:00', placeholder: 'YYYY-MM-DD hh:mm:ss', leapday: '-02-29', separator: '-', alias: 'yyyy/mm/dd' }); }); if (!this.showFormOnPopup) { $("#".concat(this.getTableName(), "Form")).show(); $("#".concat(this.getTableName())).hide(); for (var _i2 = 0; _i2 < signatureIds.length; _i2++) { $("#".concat(signatureIds[_i2])).data('signaturePad', new SignaturePad(document.getElementById(signatureIds[_i2]))); } if (object !== undefined && object != null) { this.fillForm(object); } else { this.setDefaultValues(); } this.scrollToTop(); } else { // var tHtml = $tempDomObj.wrap('
').parent().html(); // this.showMessage("Edit",tHtml,null,null,true); this.showMessage('Edit', '', null, null, true); $('#plainMessageModel .modal-body').html(''); $('#plainMessageModel .modal-body').append($tempDomObj); for (var _i3 = 0; _i3 < signatureIds.length; _i3++) { $("#".concat(signatureIds[_i3])).data('signaturePad', new SignaturePad(document.getElementById(signatureIds[_i3]))); } if (object !== undefined && object != null) { this.fillForm(object, "#".concat(randomFormId)); } else { this.setDefaultValues("#".concat(randomFormId)); } } this.postRenderForm(object, $tempDomObj); } }, { key: "setDefaultValues", value: function setDefaultValues(formId, fields) { if (fields == null || fields === undefined) { fields = this.getFormFields(); } if (formId == null || formId === undefined || formId === '') { formId = "#".concat(this.getTableName(), "Form"); } for (var i = 0; i < fields.length; i++) { if (fields[i][1].type !== 'text' && fields[i][1].type !== 'textarea') { continue; } if (fields[i][1]["default"] !== undefined && fields[i][1]["default"] !== null) { $("".concat(formId, " #").concat(fields[i][0])).val(fields[i][1]["default"]); } } } }, { key: "retriveItemsAfterSave", value: function retriveItemsAfterSave() { return true; } /** * Override this method in your module class to make changes to data fo the form after showing it * @method postRenderForm * @param object {Array} keys value list for populating form * @param $tempDomObj {DOM} a DOM element for the form * @example * UserAdapter.method('postRenderForm(object, $tempDomObj) { if(object == null || object == undefined){ $tempDomObj.find("#changePasswordBtn").remove(); } } */ }, { key: "postRenderForm", value: function postRenderForm(object, $tempDomObj) {} /** * Convert data group field to HTML * @method dataGroupToHtml * @param val {String} value in the field * @param field {Array} field meta data */ }, { key: "dataGroupToHtml", value: function dataGroupToHtml(val, field) { var data = JSON.parse(val); var t; var sortFunction; var item; var itemHtml; var itemVal; var deleteButton = '
  • '; var editButton = '
  • '; var template = field[1].html; if (data != null && data !== undefined && field[1]['sort-function'] !== undefined && field[1]['sort-function'] != null) { data.sort(field[1]['sort-function']); } var html = $("
    ")); for (var i = 0; i < data.length; i++) { item = data[i]; if (field[1]['pre-format-function'] !== undefined && field[1]['pre-format-function'] != null) { item = field[1]['pre-format-function'].apply(this, [item]); } t = template; t = t.replace('#_delete_#', deleteButton); t = t.replace('#_edit_#', editButton); t = t.replace(/#_id_#/g, item.id); for (var key in item) { itemVal = item[key]; if (itemVal !== undefined && itemVal != null && typeof itemVal === 'string') { itemVal = itemVal.replace(/(?:\r\n|\r|\n)/g, '
    '); } t = t.replace("#_".concat(key, "_#"), itemVal); } if (field[1].render !== undefined && field[1].render != null) { t = t.replace('#_renderFunction_#', field[1].render(item)); } itemHtml = $(t); itemHtml.attr('fieldId', "".concat(field[0], "_div")); html.append(itemHtml); } return html; } /** * Reset the DataGroup for a given field * @method resetDataGroup * @param field {Array} field meta data */ }, { key: "resetDataGroup", value: function resetDataGroup(field) { $("#".concat(field[0])).val(''); $("#".concat(field[0], "_div")).html(''); } }, { key: "showDataGroup", value: function showDataGroup(field, object, callback) { var formHtml = this.templates.datagroupTemplate; var html = ''; var fields = field[1].form; if (object !== undefined && object != null && object.id !== undefined) { this.currentDataGroupItemId = object.id; } else { this.currentDataGroupItemId = null; } for (var i = 0; i < fields.length; i++) { html += this.renderFormField(fields[i]); } formHtml = formHtml.replace(/_id_/g, "".concat(this.getTableName(), "_field_").concat(field[0])); formHtml = formHtml.replace(/_fields_/g, html); var randomFormId = this.generateRandom(14); var $tempDomObj = $('
    '); $tempDomObj.attr('id', randomFormId); $tempDomObj.html(formHtml); $tempDomObj.find('.datefield').datepicker({ viewMode: 2 }); $tempDomObj.find('.timefield').datetimepicker({ language: 'en', pickDate: false }); $tempDomObj.find('.datetimefield').datetimepicker({ language: 'en' }); $tempDomObj.find('.colorpick').colorpicker(); tinymce.init({ selector: "#".concat($tempDomObj.attr('id'), " .tinymce"), height: '400' }); $tempDomObj.find('.simplemde').each(function () { var simplemde = new SimpleMDE({ element: $(this)[0] }); $(this).data('simplemde', simplemde); // simplemde.value($(this).val()); }); $tempDomObj.find('.select2Field').each(function () { $(this).select2().select2('val', $(this).find('option:eq(0)').val()); }); $tempDomObj.find('.select2Multi').each(function () { $(this).select2().on('change', function (e) { var parentRow = $(this).parents('.row'); var height = parentRow.find('.select2-choices').height(); parentRow.height(parseInt(height, 10)); }); }); this.currentDataGroupField = field; this.showDomElement("Add ".concat(field[1].label), $tempDomObj, null, null, true); if (object !== undefined && object != null) { this.fillForm(object, "#".concat(this.getTableName(), "_field_").concat(field[0]), field[1].form); } else { this.setDefaultValues("#".concat(this.getTableName(), "_field_").concat(field[0]), field[1].form); } $('.groupAddBtn').off(); if (object !== undefined && object != null && object.id !== undefined) { $('.groupAddBtn').on('click', function (e) { e.preventDefault(); e.stopPropagation(); try { modJs.editDataGroup(callback); } catch (err) { console.log("Error editing data group: ".concat(err.message)); } return false; }); } else { $('.groupAddBtn').on('click', function (e) { e.preventDefault(); e.stopPropagation(); try { modJs.addDataGroup(callback); } catch (err) { console.log("Error adding data group: ".concat(err.message)); } return false; }); } } }, { key: "addDataGroup", value: function addDataGroup(callback, existingData) { var field = this.currentDataGroupField; var tempParams; $("#".concat(this.getTableName(), "_field_").concat(field[0], "_error")).html(''); $("#".concat(this.getTableName(), "_field_").concat(field[0], "_error")).hide(); var validator = new _FormValidation["default"]("".concat(this.getTableName(), "_field_").concat(field[0]), true, { ShowPopup: false, LabelErrorClass: 'error' }); if (validator.checkValues()) { var params = validator.getFormParameters(); if (field[1]['custom-validate-function'] !== undefined && field[1]['custom-validate-function'] != null) { tempParams = field[1]['custom-validate-function'].apply(this, [params]); if (tempParams.valid) { params = tempParams.params; } else { $("#".concat(this.getTableName(), "_field_").concat(field[0], "_error")).html(tempParams.message); $("#".concat(this.getTableName(), "_field_").concat(field[0], "_error")).show(); return false; } } var val = '[]'; if (existingData) { val = existingData; } else { val = $("#".concat(field[0])).val(); if (val === '' || val == null) { val = '[]'; } } var data = JSON.parse(val); params.id = "".concat(field[0], "_").concat(this.dataGroupGetNextAutoIncrementId(data)); data.push(params); if (field[1]['sort-function'] !== undefined && field[1]['sort-function'] != null) { data.sort(field[1]['sort-function']); } val = JSON.stringify(data); var html = this.dataGroupToHtml(val, field); if (callback) { callback(val); } $("#".concat(field[0], "_div")).html(''); $("#".concat(field[0], "_div")).append(html); this.makeDataGroupSortable(field, $("#".concat(field[0], "_div_inner"))); $("#".concat(field[0])).val(val); this.orderDataGroup(field); this.closeDataMessage(); this.showMessage('Item Added', 'This change will be effective only when you save the form'); } return true; } }, { key: "nl2br", value: function nl2br(str, len) { var t = ''; try { var arr = str.split(' '); var count = 0; for (var i = 0; i < arr.length; i++) { count += arr[i].length + 1; if (count > len) { t += "".concat(arr[i], "
    "); count = 0; } else { t += "".concat(arr[i], " "); } } } catch (e) {// Do nothing } return t; } }, { key: "makeDataGroupSortable", value: function makeDataGroupSortable(field, obj) { obj.data('field', field); obj.data('firstSort', true); obj.sortable({ create: function create() { $(this).height($(this).height()); }, 'ui-floating': false, start: function start(e, uiStart) { $('#sortable-ul-selector-id').sortable({ sort: function sort(event, ui) { var $target = $(event.target); if (!/html|body/i.test($target.offsetParent()[0].tagName)) { var top = event.pageY - $target.offsetParent().offset().top - ui.helper.outerHeight(true) / 2; ui.helper.css({ top: "".concat(top, "px") }); } } }); }, revert: true, stop: function stop() { modJs.orderDataGroup($(this).data('field')); }, axis: 'y', scroll: false, placeholder: 'sortable-placeholder', cursor: 'move' }); } }, { key: "orderDataGroup", value: function orderDataGroup(field, callback) { var newArr = []; var id; var list = $("#".concat(field[0], "_div_inner [fieldid='").concat(field[0], "_div']")); var val = $("#".concat(field[0])).val(); if (val === '' || val == null) { val = '[]'; } var data = JSON.parse(val); list.each(function () { id = $(this).attr('id'); for (var index in data) { if (data[index].id === id) { newArr.push(data[index]); break; } } }); $("#".concat(field[0])).val(JSON.stringify(newArr)); if (callback != null) { callback(newArr); } } }, { key: "editDataGroup", value: function editDataGroup(callback, existingData) { var field = this.currentDataGroupField; var id = this.currentDataGroupItemId; var validator = new _FormValidation["default"]("".concat(this.getTableName(), "_field_").concat(field[0]), true, { ShowPopup: false, LabelErrorClass: 'error' }); if (validator.checkValues()) { var params = validator.getFormParameters(); if (field[1]['custom-validate-function'] !== undefined && field[1]['custom-validate-function'] != null) { var tempParams = field[1]['custom-validate-function'].apply(this, [params]); if (tempParams.valid) { params = tempParams.params; } else { $("#".concat(this.getTableName(), "_field_").concat(field[0], "_error")).html(tempParams.message); $("#".concat(this.getTableName(), "_field_").concat(field[0], "_error")).show(); return false; } } if (this.doCustomFilterValidation(params)) { var val = '[]'; if (existingData) { val = existingData; } else { val = $("#".concat(field[0])).val(); if (val === '' || val == null) { val = '[]'; } } var data = JSON.parse(val); var editVal = {}; var editValIndex = -1; var newVals = []; for (var i = 0; i < data.length; i++) { var item = data[i]; if (item.id === id) { editVal = item; editValIndex = i; } newVals.push(item); } params.id = editVal.id; newVals[editValIndex] = params; if (field[1]['sort-function'] !== undefined && field[1]['sort-function'] != null) { newVals.sort(field[1]['sort-function']); } val = JSON.stringify(newVals); $("#".concat(field[0])).val(val); var html = this.dataGroupToHtml(val, field); if (callback) { callback(newVals); } this.orderDataGroup(field); $("#".concat(field[0], "_div")).html(''); $("#".concat(field[0], "_div")).append(html); this.makeDataGroupSortable(field, $("#".concat(field[0], "_div_inner"))); this.closeDataMessage(); this.showMessage('Item Edited', 'This change will be effective only when you save the form'); } } return true; } }, { key: "editDataGroupItem", value: function editDataGroupItem(id, existingData, field) { var fieldId = id.substring(0, id.lastIndexOf('_')); var val; if (existingData) { val = decodeURI(existingData); } else { val = $("#".concat(fieldId)).val(); } var data = JSON.parse(val); var editVal = {}; for (var i = 0; i < data.length; i++) { var item = data[i]; if (item.id === id) { editVal = item; } } if (field) { field = JSON.parse(decodeURI(field)); } else { field = $("#".concat(fieldId)).data('field'); } this.showDataGroup(field, editVal); } }, { key: "dataGroupGetNextAutoIncrementId", value: function dataGroupGetNextAutoIncrementId(data) { var autoId = 1; var id; for (var i = 0; i < data.length; i++) { var item = data[i]; if (item.id === undefined || item.id == null) { item.id = 1; } id = item.id.substring(item.id.lastIndexOf('_') + 1, item.id.length); if (id >= autoId) { autoId = parseInt(id, 10) + 1; } } return autoId; } }, { key: "deleteDataGroupItem", value: function deleteDataGroupItem(id, existingData) { var fieldId = id.substring(0, id.lastIndexOf('_')); var val; if (existingData) { val = decodeURI(existingData); } else { val = $("#".concat(fieldId)).val(); } var data = JSON.parse(val); var newVal = []; for (var i = 0; i < data.length; i++) { var item = data[i]; if (item.id !== id) { newVal.push(item); } } $("#".concat(fieldId)).val(JSON.stringify(newVal)); $("#".concat(id)).remove(); this.showMessage('Item Removed', 'Item removed. This change will be effective only when you save the form'); } /** * Fill a form with required values after showing it * @method fillForm * @param object {Array} form data * @param formId {String} id of the form * @param formId {Array} field meta data */ }, { key: "fillForm", value: function fillForm(object, formId, fields) { var placeHolderVal; if (fields == null || fields === undefined) { fields = this.getFormFields(); } if (formId == null || formId === undefined || formId === '') { formId = "#".concat(this.getTableName(), "Form"); } for (var i = 0; i < fields.length; i++) { if (fields[i][1].type === 'date') { if (object[fields[i][0]] !== '0000-00-00' && object[fields[i][0]] !== '' && object[fields[i][0]] != null && object[fields[i][0]] !== undefined) { $("".concat(formId, " #").concat(fields[i][0], "_date")).datepicker('setValue', object[fields[i][0]]); } } else if (fields[i][1].type === 'colorpick') { if (object[fields[i][0]] != null && object[fields[i][0]] !== undefined) { $("".concat(formId, " #").concat(fields[i][0], "_colorpick")).colorpicker('setValue', object[fields[i][0]]); $("".concat(formId, " #").concat(fields[i][0])).val(object[fields[i][0]]); } } else if (fields[i][1].type === 'datetime' || fields[i][1].type === 'time') { if (object[fields[i][0]] !== '0000-00-00 00:00:00' && object[fields[i][0]] !== '' && object[fields[i][0]] != null && object[fields[i][0]] !== undefined) { var tempDate = object[fields[i][0]]; var arr = tempDate.split(' '); var dateArr = arr[0].split('-'); var timeArr = arr[1].split(':'); $("".concat(formId, " #").concat(fields[i][0], "_datetime")).data('datetimepicker').setLocalDate(new Date(dateArr[0], parseInt(dateArr[1], 10) - 1, dateArr[2], timeArr[0], timeArr[1], timeArr[2])); } } else if (fields[i][1].type === 'label') { $("".concat(formId, " #").concat(fields[i][0])).html(object[fields[i][0]]); } else if (fields[i][1].type === 'placeholder') { if (fields[i][1]['remote-source'] !== undefined && fields[i][1]['remote-source'] != null) { // const key = `${fields[i][1]['remote-source'][0]}_${fields[i][1]['remote-source'][1]}_${fields[i][1]['remote-source'][2]}`; var key = this.getRemoteSourceKey(fields[i]); placeHolderVal = this.fieldMasterData[key][object[fields[i][0]]]; } else { placeHolderVal = object[fields[i][0]]; } if (placeHolderVal === undefined || placeHolderVal == null) { placeHolderVal = ''; } else { try { placeHolderVal = placeHolderVal.replace(/(?:\r\n|\r|\n)/g, '
    '); } catch (e) {// Do nothing } } if (fields[i][1].formatter !== undefined && fields[i][1].formatter && $.isFunction(fields[i][1].formatter)) { try { placeHolderVal = fields[i][1].formatter(placeHolderVal); } catch (e) {// Do nothing } } $("".concat(formId, " #").concat(fields[i][0])).html(placeHolderVal); } else if (fields[i][1].type === 'fileupload') { if (object[fields[i][0]] != null && object[fields[i][0]] !== undefined && object[fields[i][0]] !== '') { $("".concat(formId, " #").concat(fields[i][0])).html(object[fields[i][0]]); $("".concat(formId, " #").concat(fields[i][0])).attr('val', object[fields[i][0]]); $("".concat(formId, " #").concat(fields[i][0])).show(); $("".concat(formId, " #").concat(fields[i][0], "_download")).show(); $("".concat(formId, " #").concat(fields[i][0], "_remove")).show(); } if (fields[i][1].readonly === true) { $("".concat(formId, " #").concat(fields[i][0], "_upload")).remove(); } } else if (fields[i][1].type === 'select') { if (object[fields[i][0]] === undefined || object[fields[i][0]] == null || object[fields[i][0]] === '') { object[fields[i][0]] = 'NULL'; } $("".concat(formId, " #").concat(fields[i][0])).val(object[fields[i][0]]); } else if (fields[i][1].type === 'select2') { if (object[fields[i][0]] === undefined || object[fields[i][0]] == null || object[fields[i][0]] === '') { object[fields[i][0]] = 'NULL'; } $("".concat(formId, " #").concat(fields[i][0])).select2('val', object[fields[i][0]]); } else if (fields[i][1].type === 'select2multi') { // TODO - SM if (object[fields[i][0]] === undefined || object[fields[i][0]] == null || object[fields[i][0]] === '') { object[fields[i][0]] = 'NULL'; } var msVal = []; if (object[fields[i][0]] !== undefined && object[fields[i][0]] != null && object[fields[i][0]] !== '') { try { msVal = JSON.parse(object[fields[i][0]]); } catch (e) {// Do nothing } } $("".concat(formId, " #").concat(fields[i][0])).select2('val', msVal); var select2Height = $("".concat(formId, " #").concat(fields[i][0])).find('.select2-choices').height(); $("".concat(formId, " #").concat(fields[i][0])).find('.controls').css('min-height', "".concat(select2Height, "px")); $("".concat(formId, " #").concat(fields[i][0])).css('min-height', "".concat(select2Height, "px")); } else if (fields[i][1].type === 'datagroup') { try { var html = this.dataGroupToHtml(object[fields[i][0]], fields[i]); $("".concat(formId, " #").concat(fields[i][0])).val(object[fields[i][0]]); $("".concat(formId, " #").concat(fields[i][0], "_div")).html(''); $("".concat(formId, " #").concat(fields[i][0], "_div")).append(html); this.makeDataGroupSortable(fields[i], $("".concat(formId, " #").concat(fields[i][0], "_div_inner"))); } catch (e) {// Do nothing } } else if (fields[i][1].type === 'signature') { if (object[fields[i][0]] !== '' || object[fields[i][0]] !== undefined || object[fields[i][0]] != null) { $("".concat(formId, " #").concat(fields[i][0])).data('signaturePad').fromDataURL(object[fields[i][0]]); } } else if (fields[i][1].type === 'simplemde') { $("".concat(formId, " #").concat(fields[i][0])).data('simplemde').value(object[fields[i][0]]); } else if (fields[i][1].type === 'code') { var cm = $("".concat(formId, " #").concat(fields[i][0])).data('codemirror'); if (cm) { cm.getDoc().setValue(object[fields[i][0]]); } } else { $("".concat(formId, " #").concat(fields[i][0])).val(object[fields[i][0]]); } } } /** * Cancel edit or add new on modules * @method cancel */ }, { key: "cancel", value: function cancel() { $("#".concat(this.getTableName(), "Form")).hide(); $("#".concat(this.getTableName())).show(); } }, { key: "renderFormField", value: function renderFormField(field) { var userId = 0; if (this.fieldTemplates[field[1].type] === undefined || this.fieldTemplates[field[1].type] == null) { return ''; } var t = this.fieldTemplates[field[1].type]; field[1].label = this.gt(field[1].label); if (field[1].validation !== 'none' && field[1].validation !== 'emailOrEmpty' && field[1].validation !== 'numberOrEmpty' && field[1].type !== 'placeholder' && field[1].label.indexOf('*') < 0) { var tempSelectBoxes = ['select', 'select2']; if (!(tempSelectBoxes.indexOf(field[1].type) >= 0 && field[1]['allow-null'] === true)) { field[1].label = "".concat(field[1].label, "*"); } } if (field[1].type === 'select' || field[1].type === 'select2' || field[1].type === 'select2multi') { t = t.replace(/_id_/g, field[0]); t = t.replace(/_label_/g, field[1].label); if (field[1].source !== undefined && field[1].source != null) { t = t.replace('_options_', this.renderFormSelectOptions(field[1].source, field)); } else if (field[1]['remote-source'] !== undefined && field[1]['remote-source'] != null) { // let key = `${field[1]['remote-source'][0]}_${field[1]['remote-source'][1]}_${field[1]['remote-source'][2]}`; // if (field[1]['remote-source'].length === 4) { // key = `${key}_${field[1]['remote-source'][3]}`; // } var key = this.getRemoteSourceKey(field); t = t.replace('_options_', this.renderFormSelectOptionsRemote(this.fieldMasterData[key], field)); } } else if (field[1].type === 'colorpick') { t = t.replace(/_id_/g, field[0]); t = t.replace(/_label_/g, field[1].label); } else if (field[1].type === 'date') { t = t.replace(/_id_/g, field[0]); t = t.replace(/_label_/g, field[1].label); } else if (field[1].type === 'datetime') { t = t.replace(/_id_/g, field[0]); t = t.replace(/_label_/g, field[1].label); } else if (field[1].type === 'time') { t = t.replace(/_id_/g, field[0]); t = t.replace(/_label_/g, field[1].label); } else if (field[1].type === 'fileupload') { t = t.replace(/_id_/g, field[0]); t = t.replace(/_label_/g, field[1].label); var ce = this.getCurrentProfile(); if (ce != null && ce !== undefined) { userId = ce.id; } else { userId = this.getUser().id * -1; } t = t.replace(/_userId_/g, userId); t = t.replace(/_group_/g, this.tab); if (field[1].filetypes !== undefined && field[1].filetypes != null) { t = t.replace(/_filetypes_/g, field[1].filetypes); } else { t = t.replace(/_filetypes_/g, 'all'); } t = t.replace(/_rand_/g, this.generateRandom(14)); } else if (field[1].type === 'datagroup') { t = t.replace(/_id_/g, field[0]); t = t.replace(/_label_/g, field[1].label); } else if (field[1].type === 'signature') { t = t.replace(/_id_/g, field[0]); t = t.replace(/_label_/g, field[1].label); } else if (field[1].type === 'tinymce' || field[1].type === 'simplemde') { t = t.replace(/_id_/g, field[0]); t = t.replace(/_label_/g, field[1].label); } else { t = t.replace(/_id_/g, field[0]); t = t.replace(/_label_/g, field[1].label); } if (field[1].validation !== undefined && field[1].validation != null && field[1].validation !== '') { t = t.replace(/_validation_/g, "validation=\"".concat(field[1].validation, "\"")); } else { t = t.replace(/_validation_/g, ''); } if (field[1].help !== undefined && field[1].help !== null) { t = t.replace(/_helpline_/g, field[1].help); t = t.replace(/_hidden_class_help_/g, ''); } else { t = t.replace(/_helpline_/g, ''); t = t.replace(/_hidden_class_help_/g, 'hide'); } if (field[1].placeholder !== undefined && field[1].placeholder !== null) { t = t.replace(/_placeholder_/g, "placeholder=\"".concat(field[1].placeholder, "\"")); } else { t = t.replace(/_placeholder_/g, ''); } if (field[1].mask !== undefined && field[1].mask !== null) { t = t.replace(/_mask_/g, "mask=\"".concat(field[1].mask, "\"")); } else { t = t.replace(/_mask_/g, ''); } return t; } }, { key: "renderFormSelectOptions", value: function renderFormSelectOptions(options, field) { var html = ''; if (field != null && field !== undefined) { if (field[1]['allow-null'] === true) { if (field[1]['null-label'] !== undefined && field[1]['null-label'] != null) { html += ""); } else { html += ''; } } } // Sort options var tuples = []; for (var key in options) { tuples.push(options[key]); } if (field[1].sort === true) { tuples.sort(function (a, b) { a = a[1]; b = b[1]; // eslint-disable-next-line no-nested-ternary return a < b ? -1 : a > b ? 1 : 0; }); } for (var i = 0; i < tuples.length; i++) { var prop = tuples[i][0]; var value = tuples[i][1]; var t = ''; t = t.replace('_id_', prop); t = t.replace('_val_', this.gt(value)); html += t; } return html; } }, { key: "renderFormSelectOptionsRemote", value: function renderFormSelectOptionsRemote(options, field) { var html = ''; if (field[1]['allow-null'] === true) { if (field[1]['null-label'] !== undefined && field[1]['null-label'] != null) { html += ""); } else { html += ''; } } // Sort options var tuples = []; for (var key in options) { tuples.push([key, options[key]]); } if (field[1].sort === 'true') { tuples.sort(function (a, b) { a = a[1]; b = b[1]; // eslint-disable-next-line no-nested-ternary return a < b ? -1 : a > b ? 1 : 0; }); } for (var i = 0; i < tuples.length; i++) { var prop = tuples[i][0]; var value = tuples[i][1]; var t = ''; t = t.replace('_id_', prop); t = t.replace('_val_', this.gt(value)); html += t; } return html; } }, { key: "setCustomTemplates", value: function setCustomTemplates(templates) { this.customTemplates = templates; } }, { key: "setEmailTemplates", value: function setEmailTemplates(templates) { this.emailTemplates = templates; } }, { key: "getCustomTemplate", value: function getCustomTemplate(file) { return this.customTemplates[file]; } }, { key: "setFieldTemplates", value: function setFieldTemplates(templates) { this.fieldTemplates = templates; } }, { key: "getMetaFieldForRendering", value: function getMetaFieldForRendering(fieldName) { return ''; } }, { key: "clearDeleteParams", value: function clearDeleteParams() { this.deleteParams = {}; } }, { key: "getShowAddNew", value: function getShowAddNew() { return this.showAddNew; } /** * Override this method to change add new button label * @method getAddNewLabel */ }, { key: "getAddNewLabel", value: function getAddNewLabel() { return 'Add New'; } /** * Used to set whether to show the add new button for a module * @method setShowAddNew * @param showAddNew {Boolean} value */ }, { key: "setShowAddNew", value: function setShowAddNew(showAddNew) { this.showAddNew = showAddNew; } /** * Used to set whether to show delete button for each entry in module * @method setShowDelete * @param val {Boolean} value */ }, { key: "setShowDelete", value: function setShowDelete(val) { this.showDelete = val; } /** * Used to set whether to show edit button for each entry in module * @method setShowEdit * @param val {Boolean} value */ }, { key: "setShowEdit", value: function setShowEdit(val) { this.showEdit = val; } /** * Used to set whether to show save button in form * @method setShowSave * @param val {Boolean} value */ }, { key: "setShowSave", value: function setShowSave(val) { this.showSave = val; } /** * Used to set whether to show cancel button in form * @method setShowCancel * @param val {Boolean} value */ }, { key: "setShowCancel", value: function setShowCancel(val) { this.showCancel = val; } /** * Datatable option array will be extended with associative array provided here * @method getCustomTableParams * @param val {Boolean} value */ }, { key: "getCustomTableParams", value: function getCustomTableParams() { return {}; } }, { key: "getActionButtons", value: function getActionButtons(obj) { return modJs.getActionButtonsHtml(obj.aData[0], obj.aData); } /** * This return html for action buttons in each row. Override this method if you need to make changes to action buttons. * @method getActionButtonsHtml * @param id {int} id of the row * @param data {Array} data for the row * @returns {String} html for action buttons */ }, { key: "getActionButtonsHtml", value: function getActionButtonsHtml(id, data) { var editButton = ''; var deleteButton = ''; var cloneButton = ''; var html = '
    _edit__delete__clone_
    '; if (this.showAddNew) { html = html.replace('_clone_', cloneButton); } else { html = html.replace('_clone_', ''); } if (this.showDelete) { html = html.replace('_delete_', deleteButton); } else { html = html.replace('_delete_', ''); } if (this.showEdit) { html = html.replace('_edit_', editButton); } else { html = html.replace('_edit_', ''); } html = html.replace(/_id_/g, id); html = html.replace(/_BASE_/g, this.baseUrl); return html; } /** * Generates a random string * @method generateRandom * @param length {int} required length of the string * @returns {String} random string */ }, { key: "generateRandom", value: function generateRandom(length) { var d = new Date(); var chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; var result = ''; for (var i = length; i > 0; --i) { result += chars[Math.round(Math.random() * (chars.length - 1))]; } return result + d.getTime(); } }, { key: "checkFileType", value: function checkFileType(elementName, fileTypes) { var fileElement = document.getElementById(elementName); var fileExtension = ''; if (fileElement.value.lastIndexOf('.') > 0) { fileExtension = fileElement.value.substring(fileElement.value.lastIndexOf('.') + 1, fileElement.value.length); } fileExtension = fileExtension.toLowerCase(); var allowed = fileTypes.split(','); if (allowed.indexOf(fileExtension) < 0) { fileElement.value = ''; this.showMessage('File Type Error', 'Selected file type is not supported'); this.clearFileElement(elementName); return false; } return true; } }, { key: "clearFileElement", value: function clearFileElement(elementName) { var control = $("#".concat(elementName)); control.replaceWith(control = control.val('').clone(true)); } }, { key: "fixJSON", value: function fixJSON(json) { if (this.noJSONRequests === '1') { json = window.btoa(json); } return json; } }, { key: "getClientDate", value: function getClientDate(date) { var offset = this.getClientGMTOffset(); var tzDate = date.addMinutes(offset * 60); return tzDate; } }, { key: "getClientGMTOffset", value: function getClientGMTOffset() { var rightNow = new Date(); var jan1 = new Date(rightNow.getFullYear(), 0, 1, 0, 0, 0, 0); var temp = jan1.toGMTString(); var jan2 = new Date(temp.substring(0, temp.lastIndexOf(' ') - 1)); return (jan1 - jan2) / (1000 * 60 * 60); } /** * Override this method in a module to provide the help link for the module. Help link of the module on frontend will get updated with this. * @method getHelpLink * @returns {String} help link */ }, { key: "getHelpLink", value: function getHelpLink() { return null; } }, { key: "showLoader", value: function showLoader() { $('#iceloader').show(); } }, { key: "hideLoader", value: function hideLoader() { $('#iceloader').hide(); } }, { key: "generateOptions", value: function generateOptions(data) { var template = ''; var options = ''; for (var index in data) { options += template.replace('__val__', index).replace('__text__', data[index]); } return options; } }, { key: "isModuleInstalled", value: function isModuleInstalled(type, name) { if (modulesInstalled === undefined || modulesInstalled === null) { return false; } return modulesInstalled["".concat(type, "_").concat(name)] === 1; } }, { key: "setCustomFields", value: function setCustomFields(fields) { var field; var parsed; for (var i = 0; i < fields.length; i++) { field = fields[i]; if (field.display !== 'Hidden' && field.data !== '' && field.data !== undefined) { try { parsed = JSON.parse(field.data); if (parsed === undefined || parsed == null) { continue; } else if (parsed.length !== 2) { continue; } else if (parsed[1].type === undefined || parsed[1].type == null) { continue; } this.customFields.push(parsed); } catch (e) {// Do nothing } } } } }, { key: "addCustomFields", value: function addCustomFields(fields) { for (var i = 0; i < this.customFields.length; i++) { fields.push(this.customFields[i]); } return fields; } }, { key: "getImageUrlFromName", value: function getImageUrlFromName(firstName, lastName) { var seed = firstName.substring(0, 1); if (!lastName && lastName.length > 0) { seed += firstName.substring(firstName.length - 1, 1); } else { seed += lastName.substring(0, 1); } var arr = "".concat(firstName).concat(lastName).split(''); seed += arr.reduce(function (acc, item) { return parseInt(item.charCodeAt(0), 10) + acc; }, 0); return "https://avatars.dicebear.com/api/initials/:".concat(seed, ".svg"); } }, { key: "downloadPdf", value: function downloadPdf(type, data) { var url = "".concat(this.clientUrl, "service.php?a=pdf&h=").concat(type, "&data=").concat(data); window.open(url, '_blank'); } }]); return ModuleBase; }(); var _default = ModuleBase; exports["default"] = _default; },{"./FormValidation":44}],49:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; var _AdapterBase2 = _interopRequireDefault(require("./AdapterBase")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(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, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { 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; } 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 { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 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 } }); if (superClass) _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } /** * ObjectAdapter */ var ObjectAdapter = /*#__PURE__*/function (_AdapterBase) { _inherits(ObjectAdapter, _AdapterBase); var _super = _createSuper(ObjectAdapter); function ObjectAdapter(endPoint, tab, filter, orderBy) { var _this; _classCallCheck(this, ObjectAdapter); _this = _super.call(this, endPoint, tab, filter, orderBy); _this.container = null; _this.loadMoreButton = null; _this.start = 0; _this.pageSize = 6; _this.currentPage = 1; _this.hasMoreData = true; _this.searchTerm = ''; _this.searchInput = null; return _this; } _createClass(ObjectAdapter, [{ key: "getObjectHTML", value: function getObjectHTML(object) { var template = this.getCustomTemplate(this.getTemplateName()); var t = template; for (var index in object) { t = t.replace(new RegExp("#_".concat(index, "_#"), 'g'), object[index]); } return t; } }, { key: "setPageSize", value: function setPageSize(pageSize) { this.pageSize = pageSize; } }, { key: "addDomEvents", value: function addDomEvents(object) {} }, { key: "getTemplateName", value: function getTemplateName() { return ''; } }, { key: "renderObject", value: function renderObject(object) { var objDom = this.getObjectDom(object.id); var html = this.getObjectHTML(object); var domObj = $(html); if (objDom !== undefined && objDom != null) { objDom.replace(domObj); } else { this.container.append(domObj); } this.addDomEvents(domObj); } }, { key: "setContainer", value: function setContainer(container) { this.container = container; } }, { key: "setLoadMoreButton", value: function setLoadMoreButton(loadMoreButton) { var that = this; this.loadMoreButton = loadMoreButton; this.loadMoreButton.off().on('click', function () { that.loadMoreButton.attr('disabled', 'disabled'); that.loadMore([]); }); } }, { key: "showLoadError", value: function showLoadError(msg) { $("#".concat(this.getTableName(), "_error")).html(msg); $("#".concat(this.getTableName(), "_error")).show(); } }, { key: "hideLoadError", value: function hideLoadError() { $("#".concat(this.getTableName(), "_error")).hide(); } }, { key: "setSearchBox", value: function setSearchBox(searchInput) { var that = this; this.searchInput = searchInput; this.searchInput.off(); this.searchInput.keydown(function (event) { var val = $(this).val(); if (event.which === 13) { event.preventDefault(); that.search([]); } else if ((event.which === 8 || event.which === 46) && val.length === 1 && that.searchTerm !== '') { that.search([]); } }); } }, { key: "getObjectDom", value: function getObjectDom(id) { var obj = this.container.find("#obj_".concat(id)); if (obj.length) { return obj; } return null; } }, { key: "loadMore", value: function loadMore(callBackData) { if (!this.hasMoreData) { return; } this.currentPage++; this.get(callBackData, true); } }, { key: "get", value: function get(callBackData, loadMore) { var that = this; this.hideLoadError(); if (!loadMore) { this.currentPage = 1; if (this.container != null) { this.container.html(''); } this.hasMoreData = true; this.tableData = []; } this.start = (this.currentPage - 1) * this.pageSize; this.container = $("#".concat(this.getTableName())).find('.objectList'); that.showLoader(); var url = "".concat(this.getDataUrl(that.getDataMapping()), "&iDisplayStart=").concat(this.start, "&iDisplayLength=").concat(this.pageSize, "&objects=1"); if (this.searchTerm !== '' && this.searchTerm !== undefined && this.searchTerm != null) { url += "&sSearch=".concat(this.searchTerm); } $.post(url, function (data) { that.getSuccessCallBack(callBackData, data); }, 'json').always(function () { that.hideLoader(); }); that.initFieldMasterData(); this.trackEvent('get', this.tab, this.table); } }, { key: "search", value: function search(callBackData) { var that = this; this.searchTerm = $("#".concat(this.getTableName(), "_search")).val(); this.get(callBackData); } }, { key: "getSuccessCallBack", value: function getSuccessCallBack(callBackData, serverData) { var data = []; if (serverData.length === 0 && this.container.html() === '') { this.showLoadError('No Results Found !!!'); return; } try { if (this.getFilters() == null) { $("#".concat(this.getTableName(), "_filterBtn")).hide(); $("#".concat(this.getTableName(), "_resetFilters")).hide(); } else { $("#".concat(this.getTableName(), "_filterBtn")).show(); $("#".concat(this.getTableName(), "_resetFilters")).show(); if (this.currentFilterString !== '' && this.currentFilterString != null) { $("#".concat(this.getTableName(), "_resetFilters")).html("".concat(this.currentFilterString, "")); } else { $("#".concat(this.getTableName(), "_resetFilters")).html('Reset Filters'); $("#".concat(this.getTableName(), "_resetFilters")).hide(); } } } catch (error) {// Do nothing } $("#".concat(this.getTableName())).find('.search-controls').show(); if (serverData.length > this.pageSize) { this.hasMoreData = true; serverData.pop(); if (this.loadMoreButton !== null) { this.loadMoreButton.removeAttr('disabled'); this.loadMoreButton.show(); } } else { this.hasMoreData = false; if (this.loadMoreButton !== null) { this.loadMoreButton.hide(); } } this.scrollToElementBottom(this.container); for (var i = 0; i < serverData.length; i++) { data.push(this.preProcessTableData(serverData[i])); } this.sourceData = serverData; if (callBackData.callBack !== undefined && callBackData.callBack != null) { if (callBackData.callBackData === undefined || callBackData.callBackData == null) { callBackData.callBackData = []; } callBackData.callBackData.push(serverData); callBackData.callBackData.push(data); this.callFunction(callBackData.callBack, callBackData.callBackData); } this.tableData = data; if (!(callBackData.noRender !== undefined && callBackData.noRender != null && callBackData.noRender === true)) { for (var _i = 0; _i < data.length; _i++) { this.renderObject(data[_i]); } } } }]); return ObjectAdapter; }(_AdapterBase2["default"]); var _default = ObjectAdapter; exports["default"] = _default; },{"./AdapterBase":39}],50:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; var _react = _interopRequireDefault(require("react")); var _reactDom = _interopRequireDefault(require("react-dom")); var _antd = require("antd"); var _icons = require("@ant-design/icons"); var _AdapterBase2 = _interopRequireDefault(require("./AdapterBase")); var _IceFormModal = _interopRequireDefault(require("../components/IceFormModal")); var _IceStepFromModal = _interopRequireDefault(require("../components/IceStepFromModal")); var _IceTable = _interopRequireDefault(require("../components/IceTable")); var _MasterDataReader = _interopRequireDefault(require("./MasterDataReader")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 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(n); 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(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } 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, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { 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; } 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 { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 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 } }); if (superClass) _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } var ReactModalAdapterBase = /*#__PURE__*/function (_AdapterBase) { _inherits(ReactModalAdapterBase, _AdapterBase); var _super = _createSuper(ReactModalAdapterBase); _createClass(ReactModalAdapterBase, null, [{ key: "MODAL_TYPE_NORMAL", get: function get() { return 'Normal'; } }, { key: "MODAL_TYPE_STEPS", get: function get() { return 'Steps'; } }]); function ReactModalAdapterBase(endPoint, tab, filter, orderBy) { var _this; _classCallCheck(this, ReactModalAdapterBase); _this = _super.call(this, endPoint, tab, filter, orderBy); _this.modalType = _this.MODAL_TYPE_NORMAL; _this.dataPipe = null; _this.formInitialized = false; _this.tableInitialized = false; _this.access = []; _this.localStorageEnabled = false; _this.isV2 = true; _this.masterDataReader = new _MasterDataReader["default"](_assertThisInitialized(_this)); return _this; } _createClass(ReactModalAdapterBase, [{ key: "enableLocalStorage", value: function enableLocalStorage() { this.localStorageEnabled = true; } }, { key: "setModalType", value: function setModalType(type) { this.modalType = type; } }, { key: "setDataPipe", value: function setDataPipe(dataPipe) { this.dataPipe = dataPipe; } }, { key: "setAccess", value: function setAccess(access) { this.access = access; } }, { key: "hasAccess", value: function hasAccess(type) { return this.access.indexOf(type) > 0; } }, { key: "hasCustomButtons", value: function hasCustomButtons() { return false; } }, { key: "initTable", value: function initTable() { var _this2 = this; if (this.tableInitialized) { return false; } var tableDom = document.getElementById("".concat(this.tab, "Table")); if (tableDom) { this.tableContainer = _react["default"].createRef(); var columns = this.getTableColumns(); if (this.hasAccess('save') || this.hasAccess('delete') || this.hasAccess('element') || this.hasCustomButtons()) { columns.push({ title: 'Actions', key: 'actions', render: this.getTableActionButtonJsx(this) }); } columns = columns.map(function (item) { item.title = _this2.gt(item.title); return item; }); _reactDom["default"].render( /*#__PURE__*/_react["default"].createElement(_IceTable["default"], { ref: this.tableContainer, reader: this.dataPipe, columns: columns, adapter: this }, this.getTableChildComponents()), tableDom); } this.tableInitialized = true; return true; } }, { key: "initForm", value: function initForm() { var _this3 = this; if (this.formInitialized) { return false; } this.formContainer = _react["default"].createRef(); if (this.modalType === this.MODAL_TYPE_NORMAL) { _reactDom["default"].render( /*#__PURE__*/_react["default"].createElement(_IceFormModal["default"], { ref: this.formContainer, fields: this.getFormFields(), adapter: this, formReference: this.formReference }), document.getElementById("".concat(this.tab, "Form"))); } else { _reactDom["default"].render( /*#__PURE__*/_react["default"].createElement(_IceStepFromModal["default"], { ref: this.formContainer, fields: this.getMappedFields(), adapter: this, formReference: this.formReference }), document.getElementById("".concat(this.tab, "Form"))); } var filterDom = document.getElementById("".concat(this.tab, "FilterForm")); if (filterDom && this.getFilters()) { this.filtersContainer = _react["default"].createRef(); _reactDom["default"].render( /*#__PURE__*/_react["default"].createElement(_IceFormModal["default"], { ref: this.filtersContainer, fields: this.getFilters(), adapter: this, saveCallback: function saveCallback(values, showError, closeModal) { _this3.setFilter(values); _this3.filtersAlreadySet = true; _this3.get([]); _this3.tableContainer.current.setFilterData(values); closeModal(); } }), filterDom); } this.formInitialized = true; return true; } }, { key: "getTableChildComponents", value: function getTableChildComponents() { return false; } }, { key: "reloadCurrentElement", value: function reloadCurrentElement() { this.viewElement(this.currentId); } }, { key: "getTableActionButtonJsx", value: function getTableActionButtonJsx(adapter) { return function (text, record) { return /*#__PURE__*/_react["default"].createElement(_antd.Space, { size: "middle" }, adapter.hasAccess('save') && adapter.showEdit && /*#__PURE__*/_react["default"].createElement(_antd.Tag, { color: "green", onClick: function onClick() { return modJs.edit(record.id); }, style: { cursor: 'pointer' } }, /*#__PURE__*/_react["default"].createElement(_icons.EditOutlined, null), " ".concat(adapter.gt('Edit'))), adapter.hasAccess('element') && /*#__PURE__*/_react["default"].createElement(_antd.Tag, { color: "blue", onClick: function onClick() { return modJs.viewElement(record.id); }, style: { cursor: 'pointer' } }, /*#__PURE__*/_react["default"].createElement(_icons.MonitorOutlined, null), " ".concat(adapter.gt('View'))), adapter.hasAccess('delete') && adapter.showDelete && /*#__PURE__*/_react["default"].createElement(_antd.Tag, { color: "volcano", onClick: function onClick() { return modJs.deleteRow(record.id); }, style: { cursor: 'pointer' } }, /*#__PURE__*/_react["default"].createElement(_icons.DeleteOutlined, null), " ".concat(adapter.gt('Delete'))), adapter.hasAccess('save') && /*#__PURE__*/_react["default"].createElement(_antd.Tag, { color: "cyan", onClick: function onClick() { return modJs.copyRow(record.id); }, style: { cursor: 'pointer' } }, /*#__PURE__*/_react["default"].createElement(_icons.CopyOutlined, null), " ".concat(adapter.gt('Copy')))); }; } }, { key: "setTableLoading", value: function setTableLoading(value) { this.tableContainer.current.setLoading(value); } /** * Show the view form for an item * @method viewElement * @param id {int} id of the item to view */ }, { key: "viewElement", value: function viewElement(id) { var _this4 = this; this.setTableLoading(true); this.currentId = id; this.getElement(id, { noRender: true, callBack: function callBack(element) { _this4.showElement(element); _this4.setTableLoading(false); } }); } }, { key: "showElement", value: function showElement(element) { this.renderForm(element, true); } /** * Show the edit form for an item * @method edit * @param id {int} id of the item to edit */ }, { key: "edit", value: function edit(id) { this.setTableLoading(true); this.currentId = id; this.getElement(id, []); } }, { key: "renderForm", value: function renderForm() { var object = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; var viewOnly = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; if (object == null) { this.currentId = null; this.currentElement = null; } this.setTableLoading(false); this.initForm(); this.formContainer.current.setViewOnly(viewOnly); this.formContainer.current.show(object); } }, { key: "showFilters", value: function showFilters() { this.initForm(); this.filtersContainer.current.show(this.filter); } }, { key: "resetFilters", value: function resetFilters() { this.filter = this.origFilter; this.filtersAlreadySet = false; this.currentFilterString = ''; this.get([]); this.tableContainer.current.setFilterData(this.filter); } }, { key: "get", value: function get() { var _this5 = this; if (this.tableContainer && this.tableContainer.current) { this.tableContainer.current.setCurrentElement(null); } this.initTable(); this.masterDataReader.updateAllMasterData().then(function () { _this5.tableContainer.current.reload(); }); this.trackEvent('get', this.tab, this.table); } }, { key: "showLoader", value: function showLoader() {// $('#iceloader').show(); } }, { key: "addActualFieldsForStepModal", value: function addActualFieldsForStepModal(steps, fields) { return steps.map(function (item) { item.fields = item.fields.reduce(function (acc, fieldName) { var field = fields.find(function (_ref) { var _ref2 = _slicedToArray(_ref, 1), name = _ref2[0]; return name === fieldName; }); if (field) { acc.push(field); } return acc; }, []); return item; }); } }, { key: "getFormOptions", value: function getFormOptions() { return { width: 1024, twoColumnLayout: false }; } }]); return ReactModalAdapterBase; }(_AdapterBase2["default"]); var _default = ReactModalAdapterBase; exports["default"] = _default; },{"../components/IceFormModal":55,"../components/IceStepFromModal":60,"../components/IceTable":61,"./AdapterBase":39,"./MasterDataReader":47,"@ant-design/icons":"@ant-design/icons","antd":"antd","react":"react","react-dom":"react-dom"}],51:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; var _AdapterBase2 = _interopRequireDefault(require("./AdapterBase")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(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, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { 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; } 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 { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 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 } }); if (superClass) _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } /** * TableEditAdapter */ var TableEditAdapter = /*#__PURE__*/function (_AdapterBase) { _inherits(TableEditAdapter, _AdapterBase); var _super = _createSuper(TableEditAdapter); function TableEditAdapter(endPoint, tab, filter, orderBy) { var _this; _classCallCheck(this, TableEditAdapter); _this = _super.call(this, endPoint, tab, filter, orderBy); _this.cellDataUpdates = {}; _this.modulePath = ''; _this.rowFieldName = ''; _this.columnFieldName = ''; _this.rowTable = ''; _this.columnTable = ''; _this.valueTable = ''; _this.csvData = []; _this.columnIDMap = {}; return _this; } _createClass(TableEditAdapter, [{ key: "setModulePath", value: function setModulePath(path) { this.modulePath = path; } }, { key: "setRowFieldName", value: function setRowFieldName(name) { this.rowFieldName = name; } }, { key: "setTables", value: function setTables(rowTable, columnTable, valueTable) { this.rowTable = rowTable; this.columnTable = columnTable; this.valueTable = valueTable; } }, { key: "setColumnFieldName", value: function setColumnFieldName(name) { this.columnFieldName = name; } }, { key: "getDataMapping", value: function getDataMapping() { return []; } }, { key: "getFormFields", value: function getFormFields() { return []; } }, { key: "get", value: function get() { this.getAllData(); } }, { key: "getAllData", value: function getAllData(save) { var req = {}; req.rowTable = this.rowTable; req.columnTable = this.columnTable; req.valueTable = this.valueTable; req = this.addAdditionalRequestData('getAllData', req); req.save = save === undefined || save == null || save === false ? 0 : 1; var reqJson = JSON.stringify(req); var callBackData = []; callBackData.callBackData = []; callBackData.callBackSuccess = 'getAllDataSuccessCallBack'; callBackData.callBackFail = 'getAllDataFailCallBack'; this.customAction('getAllData', this.modulePath, reqJson, callBackData); } }, { key: "getDataItem", value: function getDataItem(row, column, allData) { var columnData = allData[1]; var rowData = allData[0]; var serverData = allData[2]; if (column === -1) { return rowData[row].name; } return this.getDataItemByKeyValues(this.rowFieldName, rowData[row].id, this.columnFieldName, columnData[column].id, serverData); } }, { key: "getDataItemByKeyValues", value: function getDataItemByKeyValues(rowKeyName, rowKeyVal, colKeyName, colKeyVal, data) { for (var i = 0; i < data.length; i++) { if (data[i][rowKeyName] === rowKeyVal && data[i][colKeyName] === colKeyVal) { return data[i].amount !== undefined && data[i].amount != null ? data[i].amount : ''; } } return ''; } }, { key: "getAllDataSuccessCallBack", value: function getAllDataSuccessCallBack(allData) { var serverData = allData[2]; var columnData = allData[1]; var rowData = allData[0]; var data = []; for (var i = 0; i < rowData.length; i++) { var row = []; for (var j = -1; j < columnData.length; j++) { row[j + 1] = this.getDataItem(i, j, allData); } data.push(this.preProcessTableData(row)); } this.sourceData = serverData; this.tableData = data; this.setHeaders(columnData, rowData); this.createTable(this.getTableName()); $("#".concat(this.getTableName(), "Form")).hide(); $("#".concat(this.getTableName())).show(); this.csvData = []; var tmpRow = []; for (var _i = 0; _i < columnData.length; _i++) { tmpRow.push(columnData[_i].name); } tmpRow = this.modifyCSVHeader(tmpRow); this.csvData.push(tmpRow); for (var _i2 = 0; _i2 < data.length; _i2++) { this.csvData.push(data[_i2]); } } }, { key: "modifyCSVHeader", value: function modifyCSVHeader(header) { return header; } }, { key: "getAllDataFailCallBack", value: function getAllDataFailCallBack(callBackData, serverData) {} }, { key: "setHeaders", value: function setHeaders(columns, rows) { var headers = []; headers.push({ sTitle: '', sWidth: '180px;' }); var sclass = ''; this.columnIDMap = {}; for (var i = 0; i < columns.length; i++) { this.columnIDMap[columns[i].id] = i; if (columns[i].editable === undefined || columns[i].editable == null || columns[i].editable === 'Yes') { sclass = 'editcell'; } else { sclass = ''; } headers.push({ sTitle: columns[i].name, sClass: sclass, fnCreatedCell: function fnCreatedCell(nTd, sData, oData, iRow, iCol) { $(nTd).data('colId', columns[iCol - 1].id); $(nTd).data('rowId', rows[iRow].id); } }); } this.headers = headers; } }, { key: "getHeaders", value: function getHeaders() { return this.headers; } }, { key: "createTable", value: function createTable(elementId) { var data = this.getTableData(); var headers = this.getHeaders(); if (this.showActionButtons()) { headers.push({ sTitle: '', sClass: 'center' }); } if (this.showActionButtons()) { for (var i = 0; i < data.length; i++) { data[i].push(this.getActionButtonsHtml(data[i][0], data[i])); } } var html = ''; html = "".concat(this.getTableTopButtonHtml(), "
    "); // Find current page var activePage = $("#".concat(elementId, " .dataTables_paginate .active a")).html(); var start = 0; if (activePage !== undefined && activePage != null) { start = parseInt(activePage, 10) * 15 - 15; } $("#".concat(elementId)).html(html); var dataTableParams = { oLanguage: { sLengthMenu: '_MENU_ records per page' }, aaData: data, aoColumns: headers, bSort: false, iDisplayLength: 15, iDisplayStart: start }; var customTableParams = this.getCustomTableParams(); $.extend(dataTableParams, customTableParams); $("#".concat(elementId, " #grid")).dataTable(dataTableParams); $('.dataTables_paginate ul').addClass('pagination'); $('.dataTables_length').hide(); $('.dataTables_filter input').addClass('form-control'); $('.dataTables_filter input').attr('placeholder', 'Search'); $('.dataTables_filter label').contents().filter(function () { return this.nodeType === 3; }).remove(); // $('.tableActionButton').tooltip(); $("#".concat(elementId, " #grid")).editableTableWidget(); $("#".concat(elementId, " #grid .editcell")).on('validate', function (evt, newValue) { return modJs.validateCellValue($(this), evt, newValue); }); this.afterCreateTable(elementId); } }, { key: "afterCreateTable", value: function afterCreateTable(elementId) {} }, { key: "addCellDataUpdate", value: function addCellDataUpdate(colId, rowId, data) { this.cellDataUpdates["".concat(colId, "=").concat(rowId)] = [colId, rowId, data]; } }, { key: "addAdditionalRequestData", value: function addAdditionalRequestData(type, req) { return req; } }, { key: "sendCellDataUpdates", value: function sendCellDataUpdates() { var req = this.cellDataUpdates; req.rowTable = this.rowTable; req.columnTable = this.columnTable; req.valueTable = this.valueTable; req = this.addAdditionalRequestData('updateData', req); var reqJson = JSON.stringify(req); var callBackData = []; callBackData.callBackData = []; callBackData.callBackSuccess = 'updateDataSuccessCallBack'; callBackData.callBackFail = 'updateDataFailCallBack'; this.showLoader(); this.customAction('updateData', this.modulePath, reqJson, callBackData); } }, { key: "updateDataSuccessCallBack", value: function updateDataSuccessCallBack(callBackData, serverData) { this.hideLoader(); modJs.cellDataUpdates = {}; modJs.get(); } }, { key: "updateDataFailCallBack", value: function updateDataFailCallBack(callBackData, serverData) { this.hideLoader(); } }, { key: "sendAllCellDataUpdates", value: function sendAllCellDataUpdates() { var req = this.cellDataUpdates; req.rowTable = this.rowTable; req.columnTable = this.columnTable; req.valueTable = this.valueTable; req = this.addAdditionalRequestData('updateAllData', req); var reqJson = JSON.stringify(req); var callBackData = []; callBackData.callBackData = []; callBackData.callBackSuccess = 'updateDataAllSuccessCallBack'; callBackData.callBackFail = 'updateDataAllFailCallBack'; this.showLoader(); this.customAction('updateAllData', this.modulePath, reqJson, callBackData); } }, { key: "updateDataAllSuccessCallBack", value: function updateDataAllSuccessCallBack(callBackData, serverData) { this.hideLoader(); modJs.cellDataUpdates = {}; modJs.getAllData(true); } }, { key: "updateDataAllFailCallBack", value: function updateDataAllFailCallBack(callBackData, serverData) { this.hideLoader(); } }, { key: "showActionButtons", value: function showActionButtons() { return false; } }]); return TableEditAdapter; }(_AdapterBase2["default"]); var _default = TableEditAdapter; exports["default"] = _default; },{"./AdapterBase":39}],52:[function(require,module,exports){ "use strict"; function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; var _react = _interopRequireWildcard(require("react")); var _reactColor = require("react-color"); function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; } function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } 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(n); 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(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } function useComponentVisible(initialIsVisible) { var _useState = (0, _react.useState)(initialIsVisible), _useState2 = _slicedToArray(_useState, 2), isComponentVisible = _useState2[0], setIsComponentVisible = _useState2[1]; var ref = (0, _react.useRef)(null); var handleClickOutside = function handleClickOutside(event) { if (ref.current && !ref.current.contains(event.target)) { setIsComponentVisible(false); } }; (0, _react.useEffect)(function () { document.addEventListener('click', handleClickOutside, true); return function () { document.removeEventListener('click', handleClickOutside, true); }; }); return { ref: ref, isComponentVisible: isComponentVisible, setIsComponentVisible: setIsComponentVisible }; } function IceColorPick(props) { var value = props.value, onChange = props.onChange, readOnly = props.readOnly; var _useComponentVisible = useComponentVisible(true), ref = _useComponentVisible.ref, isComponentVisible = _useComponentVisible.isComponentVisible, setIsComponentVisible = _useComponentVisible.setIsComponentVisible; var _useState3 = (0, _react.useState)(value || '#FFF'), _useState4 = _slicedToArray(_useState3, 2), color = _useState4[0], setColor = _useState4[1]; var _useState5 = (0, _react.useState)(false), _useState6 = _slicedToArray(_useState5, 2), showPicker = _useState6[0], setShowPicker = _useState6[1]; (0, _react.useEffect)(function () { if (!isComponentVisible) { setShowPicker(false); } }, [isComponentVisible]); (0, _react.useEffect)(function () { if (value) { setColor(value); } }, [value]); return /*#__PURE__*/_react["default"].createElement("div", { className: "colorpicker-container" }, /*#__PURE__*/_react["default"].createElement("div", { className: "colorpicker-preview", onClick: function onClick() { if (!showPicker) { setIsComponentVisible(true); } setShowPicker(!showPicker); }, style: { backgroundColor: color } }), /*#__PURE__*/_react["default"].createElement("div", { ref: ref, className: "colorpicker-component ".concat(readOnly || !showPicker ? 'hidden' : '') }, /*#__PURE__*/_react["default"].createElement(_reactColor.SketchPicker, { color: color, disableAlpha: true, presetColors: [], onChangeComplete: function onChangeComplete(_ref) { var hex = _ref.hex; onChange(hex); setColor(hex); } }))); } var _default = IceColorPick; exports["default"] = _default; },{"react":"react","react-color":365}],53:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; var _react = _interopRequireDefault(require("react")); var _antd = require("antd"); var _IceFormModal = _interopRequireDefault(require("./IceFormModal")); var _reactDom = _interopRequireDefault(require("react-dom")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } function _defineProperty(obj, key, value) { 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, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { 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; } 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 { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 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 } }); if (superClass) _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } var Option = _antd.Select.Option; var IceDataGroup = /*#__PURE__*/function (_React$Component) { _inherits(IceDataGroup, _React$Component); var _super = _createSuper(IceDataGroup); function IceDataGroup(props) { var _this; _classCallCheck(this, IceDataGroup); _this = _super.call(this, props); _this.state = {}; _this.onChange = props.onChange; _this.formReference = _react["default"].createRef(); return _this; } _createClass(IceDataGroup, [{ key: "render", value: function render() { var _this2 = this; var _this$props = this.props, field = _this$props.field, adapter = _this$props.adapter; var value = this.props.value; value = this.parseValue(value); value = value.map(function (item) { return _objectSpread({}, item, { key: item.id }); }); var columns = JSON.parse(JSON.stringify(field[1].columns)); if (!this.props.readOnly) { columns.push({ title: 'Action', key: 'action', render: function render(text, record) { return _this2.getDefaultButtons(record.id); } }); } return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, !this.props.readOnly && /*#__PURE__*/_react["default"].createElement(_antd.Space, { direction: "horizontal" }, /*#__PURE__*/_react["default"].createElement(_antd.Button, { type: "link", htmlType: "button", onClick: function onClick() { _this2.createForm(field, adapter, {}); } }, "Add"), /*#__PURE__*/_react["default"].createElement(_antd.Button, { type: "link", htmlType: "button", danger: true, onClick: function onClick() { _this2.resetDataGroup(); } }, "Reset")), /*#__PURE__*/_react["default"].createElement(_antd.Table, { columns: columns, dataSource: value })); } }, { key: "createForm", value: function createForm(field, adapter, object) { this.formContainer = _react["default"].createRef(); var formFields = field[1].form; formFields.unshift(['id', { label: 'ID', type: 'hidden' }]); _reactDom["default"].render( /*#__PURE__*/_react["default"].createElement(_IceFormModal["default"], { ref: this.formContainer, fields: formFields, title: this.props.title, adapter: adapter, formReference: this.formReference, saveCallback: this.save.bind(this), cancelCallback: this.unmountForm.bind(this) }), document.getElementById('dataGroup')); this.formContainer.current.show(object); } }, { key: "unmountForm", value: function unmountForm() { _reactDom["default"].unmountComponentAtNode(document.getElementById('dataGroup')); } }, { key: "show", value: function show(data) { var _this3 = this; if (!data) { this.setState({ visible: true }); this.updateFields(data); } else { this.setState({ visible: true }); if (this.formReference.current) { this.updateFields(data); } else { this.waitForIt(function () { return _this3.formReference.current != null; }, function () { _this3.updateFields(data); }, 100); } } } }, { key: "parseValue", value: function parseValue(value) { try { value = JSON.parse(value); } catch (e) { value = []; } if (value == null) { value = []; } return value; } }, { key: "save", value: function save(params, errorCallback, closeCallback) { var _this$props2 = this.props, field = _this$props2.field, value = _this$props2.value; if (field[1]['custom-validate-function'] != null) { var tempParams = field[1]['custom-validate-function'].apply(this, [params]); if (tempParams.valid) { params = tempParams.params; } else { errorCallback(tempParams.message); return false; } } var data = this.parseValue(value); var newData = []; if (!params.id) { params.id = "".concat(field[0], "_").concat(this.dataGroupGetNextAutoIncrementId(data)); data.push(params); newData = data; } else { for (var i = 0; i < data.length; i++) { var item = data[i]; if (item.id !== params.id) { newData.push(item); } else { newData.push(params); } } } if (field[1]['sort-function'] != null) { newData.sort(field[1]['sort-function']); } var val = JSON.stringify(newData); this.onChange(val); this.unmountForm(); } }, { key: "createCard", value: function createCard(item) { var field = this.props.field; if (field[1]['pre-format-function'] != null) { item = field[1]['pre-format-function'].apply(this, [item]); } var template = field[1].html; var t = template.replace('#_delete_#', ''); t = t.replace('#_edit_#', ''); t = t.replace(/#_id_#/g, item.id); for (var key in item) { var itemVal = item[key]; if (itemVal !== undefined && itemVal != null && typeof itemVal === 'string') { itemVal = itemVal.replace(/(?:\r\n|\r|\n)/g, '
    '); } t = t.replace("#_".concat(key, "_#"), itemVal); } if (field[1].render !== undefined && field[1].render != null) { t = t.replace('#_renderFunction_#', field[1].render(item)); } return /*#__PURE__*/_react["default"].createElement(_antd.Card, { key: item.id, title: "", extra: this.getDefaultButtons(item.id) }, /*#__PURE__*/_react["default"].createElement("div", { dangerouslySetInnerHTML: { __html: t } })); } }, { key: "getDefaultButtons", value: function getDefaultButtons(id) { var _this4 = this; return /*#__PURE__*/_react["default"].createElement(_antd.Space, null, /*#__PURE__*/_react["default"].createElement("a", { href: "#", onClick: function onClick() { _this4.editDataGroupItem(id); } }, /*#__PURE__*/_react["default"].createElement("li", { className: "fa fa-edit" })), /*#__PURE__*/_react["default"].createElement("a", { href: "#", onClick: function onClick() { _this4.deleteDataGroupItem(id); } }, /*#__PURE__*/_react["default"].createElement("li", { className: "fa fa-times" }))); } }, { key: "deleteDataGroupItem", value: function deleteDataGroupItem(id) { var value = this.props.value; var data = this.parseValue(value); var newVal = []; for (var i = 0; i < data.length; i++) { var item = data[i]; if (item.id !== id) { newVal.push(item); } } var val = JSON.stringify(newVal); this.onChange(val); } }, { key: "editDataGroupItem", value: function editDataGroupItem(id) { var _this$props3 = this.props, field = _this$props3.field, adapter = _this$props3.adapter, value = _this$props3.value; var data = this.parseValue(value); var editVal = {}; for (var i = 0; i < data.length; i++) { var item = data[i]; if (item.id === id) { editVal = item; } } this.createForm(field, adapter, editVal); } }, { key: "resetDataGroup", value: function resetDataGroup() { this.onChange('[]'); } }, { key: "dataGroupGetNextAutoIncrementId", value: function dataGroupGetNextAutoIncrementId(data) { var autoId = 1; var id; for (var i = 0; i < data.length; i++) { var item = data[i]; if (item.id === undefined || item.id == null) { item.id = 1; } id = item.id.substring(item.id.lastIndexOf('_') + 1, item.id.length); if (id >= autoId) { autoId = parseInt(id, 10) + 1; } } return autoId; } }]); return IceDataGroup; }(_react["default"].Component); var _default = IceDataGroup; exports["default"] = _default; },{"./IceFormModal":55,"antd":"antd","react":"react","react-dom":"react-dom"}],54:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; var _react = _interopRequireDefault(require("react")); var _antd = require("antd"); var _moment = _interopRequireDefault(require("moment")); var _IceUpload = _interopRequireDefault(require("./IceUpload")); var _IceDataGroup = _interopRequireDefault(require("./IceDataGroup")); var _IceSelect = _interopRequireDefault(require("./IceSelect")); var _IceLabel = _interopRequireDefault(require("./IceLabel")); var _IceColorPick = _interopRequireDefault(require("./IceColorPick")); var _IceSignature = _interopRequireDefault(require("./IceSignature")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 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(n); 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(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } 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, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { 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; } 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 { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 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 } }); if (superClass) _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } var ValidationRules = { "float": function float(str) { var floatstr = /^[-+]?[0-9]+(\.[0-9]+)?$/; if (str != null && str.match(floatstr)) { return true; } return false; }, number: function number(str) { var numstr = /^[0-9]+$/; if (str != null && str.match(numstr)) { return true; } return false; }, numberOrEmpty: function numberOrEmpty(str) { if (str === '') { return true; } var numstr = /^[0-9]+$/; if (str != null && str.match(numstr)) { return true; } return false; }, email: function email(str) { var emailPattern = /^\s*[\w\-+_]+(\.[\w\-+_]+)*@[\w\-+_]+\.[\w\-+_]+(\.[\w\-+_]+)*\s*$/; return str != null && emailPattern.test(str); }, emailOrEmpty: function emailOrEmpty(str) { if (str === '') { return true; } var emailPattern = /^\s*[\w\-+_]+(\.[\w\-+_]+)*@[\w\-+_]+\.[\w\-+_]+(\.[\w\-+_]+)*\s*$/; return str != null && emailPattern.test(str); }, username: function username(str) { var username = /^[a-zA-Z0-9.-]+$/; return str != null && username.test(str); } }; var IceForm = /*#__PURE__*/function (_React$Component) { _inherits(IceForm, _React$Component); var _super = _createSuper(IceForm); function IceForm(props) { var _this; _classCallCheck(this, IceForm); _this = _super.call(this, props); _this.validationRules = {}; _this.state = { validations: {}, errorMsg: false }; _this.formReference = _react["default"].createRef(); return _this; } _createClass(IceForm, [{ key: "showError", value: function showError(errorMsg) { this.setState({ errorMsg: errorMsg }); } }, { key: "hideError", value: function hideError() { this.setState({ errorMsg: false }); } }, { key: "isReady", value: function isReady() { return this.formReference.current != null; } }, { key: "validateFields", value: function validateFields() { return this.formReference.current.validateFields(); } }, { key: "render", value: function render() { var _this$props = this.props, fields = _this$props.fields, twoColumnLayout = _this$props.twoColumnLayout, adapter = _this$props.adapter; var formInputs = []; var formInputs1 = []; var formInputs2 = []; var columns = !twoColumnLayout ? 1 : 2; for (var i = 0; i < fields.length; i++) { formInputs.push(adapter.beforeRenderFieldHook(fields[i][0], this.createFromField(fields[i], this.props.viewOnly), fields[i][1])); } formInputs = formInputs.filter(function (input) { return !!input; }); for (var _i = 0; _i < formInputs.length; _i++) { if (formInputs[_i] != null) { if (columns === 1) { formInputs1.push(formInputs[_i]); } else if (_i % 2 === 0) { formInputs1.push(formInputs[_i]); } else { formInputs2.push(formInputs[_i]); } } } var onFormLayoutChange = function onFormLayoutChange() {}; return /*#__PURE__*/_react["default"].createElement(_antd.Form, { ref: this.formReference, labelCol: { span: 6 }, wrapperCol: { span: 16 }, layout: this.props.layout || 'horizontal', initialValues: { size: 'middle' }, onValuesChange: onFormLayoutChange, size: "middle" }, this.state.errorMsg && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_antd.Alert, { message: this.state.errorMsg, type: "error", showIcon: true }), /*#__PURE__*/_react["default"].createElement("br", null)), columns === 1 && formInputs1, columns === 2 && /*#__PURE__*/_react["default"].createElement(_antd.Row, { gutter: 16 }, /*#__PURE__*/_react["default"].createElement(_antd.Col, { className: "gutter-row", span: 12 }, formInputs1), /*#__PURE__*/_react["default"].createElement(_antd.Col, { className: "gutter-row", span: 12 }, formInputs2))); } }, { key: "isValid", value: function isValid() { var _this2 = this; return Object.keys(this.validationRules).reduce(function (acc, fieldName) { return acc && (_this2.state[fieldName] === 'success' || _this2.state[fieldName] == null); }, true); } }, { key: "validateOnChange", value: function validateOnChange(event) { var validationRule = this.validationRules[event.target.id]; var validations = this.state.validations; if (validationRule) { if (validationRule.rule(event.target.value)) { this.state[event.target.id] = 'success'; this.state["".concat(event.target.id, "_message")] = null; } else { this.state[event.target.id] = 'error'; this.state["".concat(event.target.id, "_message")] = validationRule.message; } } this.setState({ validations: validations }); } }, { key: "createFromField", value: function createFromField(field) { var viewOnly = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; var userId = 0; var rules = []; var requiredRule = { required: true }; var _field = _slicedToArray(field, 2), name = _field[0], data = _field[1]; var _this$props2 = this.props, adapter = _this$props2.adapter, layout = _this$props2.layout; var validationRule = null; data.label = adapter.gt(data.label); var labelSpan = layout === 'vertical' ? { span: 24 } : { span: 6 }; var tempSelectBoxes = ['select', 'select2', 'select2multi']; if (tempSelectBoxes.indexOf(data.type) >= 0 && data['allow-null'] === true) { requiredRule.required = false; } else if (data.validation === 'none' || data.validation === 'emailOrEmpty' || data.validation === 'numberOrEmpty') { requiredRule.required = false; } else { requiredRule.required = true; requiredRule.message = this.generateFieldMessage(data.label); } rules.push(requiredRule); if (data.type === 'hidden') { requiredRule.required = false; return /*#__PURE__*/_react["default"].createElement(_antd.Form.Item, { labelCol: labelSpan, style: { display: 'none' }, label: data.label, key: name, name: name, rules: rules }, /*#__PURE__*/_react["default"].createElement(_antd.Input, null)); } if (data.type === 'text') { if (data.validation) { data.validation = data.validation.replace('OrEmpty', ''); validationRule = this.getValidationRule(data); if (validationRule) { this.validationRules[name] = { rule: validationRule, message: "Invalid value for ".concat(data.label) }; } } if (validationRule != null) { return /*#__PURE__*/_react["default"].createElement(_antd.Form.Item, { labelCol: labelSpan, label: data.label, key: name, name: name, rules: rules, validateStatus: this.state[name], help: this.state["".concat(name, "_message")] }, viewOnly ? /*#__PURE__*/_react["default"].createElement(_IceLabel["default"], null) : /*#__PURE__*/_react["default"].createElement(_antd.Input, { onChange: this.validateOnChange.bind(this) })); } return /*#__PURE__*/_react["default"].createElement(_antd.Form.Item, { labelCol: labelSpan, label: data.label, key: name, name: name, rules: rules }, viewOnly ? /*#__PURE__*/_react["default"].createElement(_IceLabel["default"], null) : /*#__PURE__*/_react["default"].createElement(_antd.Input, null)); } if (data.type === 'textarea') { if (!data.rows) { data.rows = 4; } return /*#__PURE__*/_react["default"].createElement(_antd.Form.Item, { labelCol: labelSpan, label: data.label, key: name, name: name, rules: rules }, viewOnly ? /*#__PURE__*/_react["default"].createElement(_IceLabel["default"], null) : /*#__PURE__*/_react["default"].createElement(_antd.Input.TextArea, { rows: data.rows })); } if (data.type === 'date') { return /*#__PURE__*/_react["default"].createElement(_antd.Form.Item, { labelCol: labelSpan, label: data.label, key: name, name: name, rules: rules }, /*#__PURE__*/_react["default"].createElement(_antd.DatePicker, { disabled: viewOnly })); } if (data.type === 'datetime') { return /*#__PURE__*/_react["default"].createElement(_antd.Form.Item, { labelCol: labelSpan, label: data.label, key: name, name: name, rules: rules }, /*#__PURE__*/_react["default"].createElement(_antd.DatePicker, { format: "YYYY-MM-DD HH:mm:ss", disabled: viewOnly })); } if (data.type === 'time') { return /*#__PURE__*/_react["default"].createElement(_antd.Form.Item, { labelCol: labelSpan, label: data.label, key: name, name: name, rules: rules }, /*#__PURE__*/_react["default"].createElement(_antd.TimePicker, { format: "HH:mm", disabled: viewOnly })); } if (data.type === 'fileupload') { var currentEmployee = adapter.getCurrentProfile(); if (currentEmployee != null) { userId = currentEmployee.id; } else { userId = adapter.getUser().id * -1; } if (data.filetypes == null) { data.filetypes = '.doc,.docx,.xml,' + 'application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,' + 'image/*,' + '.pdf'; } return /*#__PURE__*/_react["default"].createElement(_antd.Form.Item, { labelCol: labelSpan, name: name, key: name, label: data.label }, /*#__PURE__*/_react["default"].createElement(_IceUpload["default"], { user: userId, fileGroup: adapter.tab, fileName: name, adapter: adapter, accept: data.filetypes, readOnly: viewOnly })); } if (data.type === 'datagroup') { return /*#__PURE__*/_react["default"].createElement(_antd.Form.Item, { labelCol: labelSpan, name: name, key: name, label: data.label }, /*#__PURE__*/_react["default"].createElement(_IceDataGroup["default"], { adapter: adapter, field: field, title: data.label, readOnly: viewOnly })); } if (data.type === 'select2' || data.type === 'select' || data.type === 'select2multi') { return /*#__PURE__*/_react["default"].createElement(_antd.Form.Item, { labelCol: labelSpan, label: data.label, key: name, name: name, rules: rules }, /*#__PURE__*/_react["default"].createElement(_IceSelect["default"], { adapter: adapter, field: field, readOnly: viewOnly })); } if (data.type === 'colorpick') { return /*#__PURE__*/_react["default"].createElement(_antd.Form.Item, { labelCol: labelSpan, name: name, key: name, label: data.label }, /*#__PURE__*/_react["default"].createElement(_IceColorPick["default"], { adapter: adapter, field: field, title: data.label, readOnly: viewOnly })); } if (data.type === 'signature') { return /*#__PURE__*/_react["default"].createElement(_antd.Form.Item, { labelCol: labelSpan, label: data.label, key: name, name: name, rules: rules }, /*#__PURE__*/_react["default"].createElement(_IceSignature["default"], { readOnly: viewOnly })); } return null; } }, { key: "generateFieldMessage", value: function generateFieldMessage(label) { return "".concat(label, ": ").concat(this.props.adapter.gt('is required')); } }, { key: "getValidationRule", value: function getValidationRule(data) { if (ValidationRules[data.validation] == null) { return null; } return ValidationRules[data.validation]; } }, { key: "dataToFormFields", value: function dataToFormFields(data, fields) { for (var i = 0; i < fields.length; i++) { var _fields$i = _slicedToArray(fields[i], 2), key = _fields$i[0], formInputData = _fields$i[1]; if (formInputData.type === 'date') { data[key] = data[key] ? (0, _moment["default"])(data[key], 'YYYY-MM-DD') : null; } else if (formInputData.type === 'datetime') { data[key] = data[key] ? (0, _moment["default"])(data[key], 'YYYY-MM-DD HH:mm:ss') : null; } else if (formInputData.type === 'time') { data[key] = data[key] ? (0, _moment["default"])(data[key], 'HH:mm') : null; } } return data; } }, { key: "formFieldsToData", value: function formFieldsToData(params, fields) { for (var i = 0; i < fields.length; i++) { var _fields$i2 = _slicedToArray(fields[i], 2), key = _fields$i2[0], formInputData = _fields$i2[1]; if (formInputData.type === 'date') { params[key] = params[key] ? params[key].format('YYYY-MM-DD') : 'NULL'; } else if (formInputData.type === 'datetime') { params[key] = params[key] ? params[key].format('YYYY-MM-DD HH:mm:ss') : 'NULL'; } else if (formInputData.type === 'time') { params[key] = params[key] ? params[key].format('HH:mm') : 'NULL'; } else if ((formInputData.type === 'select' || formInputData.type === 'select2') && params[key] == null) { params[key] = 'NULL'; } } return params; } }, { key: "updateFields", value: function updateFields(data) { var fields = this.props.fields; data = this.dataToFormFields(data, fields); this.formReference.current.resetFields(); if (data == null) { return; } try { this.formReference.current.setFieldsValue(data); } catch (e) { console.log(e); } } }, { key: "resetFields", value: function resetFields() { this.formReference.current.resetFields(); } }, { key: "setFieldsValue", value: function setFieldsValue(data) { this.formReference.current.setFieldsValue(data); } }, { key: "save", value: function save(params, success) { var _this3 = this; var _this$props3 = this.props, adapter = _this$props3.adapter, fields = _this$props3.fields; var values = params; values = adapter.forceInjectValuesBeforeSave(values); var msg = adapter.doCustomValidation(values); if (msg !== null) { this.showError(msg); return; } if (adapter.csrfRequired) { values.csrf = $("#".concat(adapter.getTableName(), "Form")).data('csrf'); } var id = adapter.currentElement != null ? adapter.currentElement.id : null; if (id != null && id !== '') { values.id = id; } values = this.formFieldsToData(values, fields); adapter.add(values, [], function () { return adapter.get([]); }, function () { _this3.formReference.current.resetFields(); _this3.showError(false); success(); }); } }]); return IceForm; }(_react["default"].Component); var _default = IceForm; exports["default"] = _default; },{"./IceColorPick":52,"./IceDataGroup":53,"./IceLabel":56,"./IceSelect":57,"./IceSignature":58,"./IceUpload":62,"antd":"antd","moment":"moment","react":"react"}],55:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; var _react = _interopRequireDefault(require("react")); var _antd = require("antd"); var _IceForm = _interopRequireDefault(require("./IceForm")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } 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, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { 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; } 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 { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 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 } }); if (superClass) _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } var IceFormModal = /*#__PURE__*/function (_React$Component) { _inherits(IceFormModal, _React$Component); var _super = _createSuper(IceFormModal); function IceFormModal(props) { var _this; _classCallCheck(this, IceFormModal); _this = _super.call(this, props); _this.state = { visible: false, viewOnly: false, loading: false }; _this.iceFormReference = _react["default"].createRef(); _this.width = 800; return _this; } _createClass(IceFormModal, [{ key: "setViewOnly", value: function setViewOnly(value) { this.setState({ viewOnly: value }); } }, { key: "show", value: function show(data) { var _this2 = this; this.props.adapter.beforeRenderFieldHook = this.props.adapter.beforeRenderField ? this.props.adapter.beforeRenderField(data) : function (fieldName, field) { return field; }; if (!data) { this.setState({ visible: true }); if (this.iceFormReference.current) { this.iceFormReference.current.resetFields(); } } else { this.setState({ visible: true }); if (this.iceFormReference.current && this.iceFormReference.current.isReady()) { this.iceFormReference.current.updateFields(data); } else { this.waitForIt(function () { return _this2.iceFormReference.current && _this2.iceFormReference.current.isReady(); }, function () { _this2.iceFormReference.current.updateFields(data); }, 1000); } } } }, { key: "waitForIt", value: function waitForIt(condition, callback, time) { var _this3 = this; setTimeout(function () { if (condition()) { callback(); } else { _this3.waitForIt(condition, callback, time); } }, time); } }, { key: "hide", value: function hide() { this.setState({ visible: false }); } }, { key: "save", value: function save(params) { var _this4 = this; this.iceFormReference.current.save(params, function () { _this4.closeModal(); }); } }, { key: "closeModal", value: function closeModal() { this.hide(); this.iceFormReference.current.showError(false); } }, { key: "render", value: function render() { var _this5 = this; var _this$props = this.props, fields = _this$props.fields, adapter = _this$props.adapter, saveCallback = _this$props.saveCallback, cancelCallback = _this$props.cancelCallback; var additionalProps = {}; additionalProps.footer = /*#__PURE__*/_react["default"].createElement(_antd.Row, { gutter: 16 }, /*#__PURE__*/_react["default"].createElement(_antd.Col, { className: "gutter-row", span: 12, style: {} }), /*#__PURE__*/_react["default"].createElement(_antd.Col, { className: "gutter-row", span: 12, style: { textAlign: 'right' } }, /*#__PURE__*/_react["default"].createElement(_antd.Space, null, /*#__PURE__*/_react["default"].createElement(_antd.Button, { onClick: function onClick() { if (cancelCallback) { cancelCallback(); } else { _this5.closeModal(); } } }, this.props.adapter.gt('Cancel')), /*#__PURE__*/_react["default"].createElement(_antd.Button, { loading: this.state.loading, type: "primary", onClick: function onClick() { _this5.setState({ loading: true }); var iceFrom = _this5.iceFormReference.current; iceFrom.validateFields().then(function (values) { if (!iceFrom.isValid()) { _this5.setState({ loading: false }); return; } if (saveCallback) { saveCallback(values, iceFrom.showError.bind(_this5), _this5.closeModal.bind(_this5)); } else { _this5.save(values); } _this5.setState({ loading: false }); })["catch"](function (info) { _this5.setState({ loading: false }); }); } }, this.state.viewOnly ? this.props.adapter.gt('Done') : this.props.adapter.gt('Save'))))); if (this.state.viewOnly) { additionalProps.footer = null; } return /*#__PURE__*/_react["default"].createElement(_antd.Modal, _extends({ visible: this.state.visible, title: this.props.adapter.gt(this.props.title || adapter.objectTypeName), maskClosable: false, width: this.width, onCancel: function onCancel() { if (cancelCallback) { cancelCallback(); } else { _this5.closeModal(); } } }, additionalProps), /*#__PURE__*/_react["default"].createElement(_IceForm["default"], { ref: this.iceFormReference, adapter: adapter, fields: fields, viewOnly: this.state.viewOnly })); } }]); return IceFormModal; }(_react["default"].Component); var _default = IceFormModal; exports["default"] = _default; },{"./IceForm":54,"antd":"antd","react":"react"}],56:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; var _react = _interopRequireDefault(require("react")); var _antd = require("antd"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(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, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { 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; } 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 { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 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 } }); if (superClass) _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } var IceLabel = /*#__PURE__*/function (_React$Component) { _inherits(IceLabel, _React$Component); var _super = _createSuper(IceLabel); function IceLabel(props) { _classCallCheck(this, IceLabel); return _super.call(this, props); } _createClass(IceLabel, [{ key: "render", value: function render() { var value = this.props.value; return /*#__PURE__*/_react["default"].createElement(_antd.Space, null, /*#__PURE__*/_react["default"].createElement("div", { contentEditable: "true", dangerouslySetInnerHTML: { __html: this.nl2br(value || '') } })); } }, { key: "nl2br", value: function nl2br(str) { return "".concat(str).replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '
    '); } }]); return IceLabel; }(_react["default"].Component); var _default = IceLabel; exports["default"] = _default; },{"antd":"antd","react":"react"}],57:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; var _react = _interopRequireDefault(require("react")); var _antd = require("antd"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(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, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { 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; } 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 { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 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 } }); if (superClass) _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } var Option = _antd.Select.Option; var IceSelect = /*#__PURE__*/function (_React$Component) { _inherits(IceSelect, _React$Component); var _super = _createSuper(IceSelect); function IceSelect(props) { var _this; _classCallCheck(this, IceSelect); _this = _super.call(this, props); _this.onChange = props.onChange; return _this; } _createClass(IceSelect, [{ key: "render", value: function render() { var options; var _this$props = this.props, field = _this$props.field, adapter = _this$props.adapter; var value = this.props.value; var data = field[1]; if (data['remote-source'] != null) { var key = "".concat(data['remote-source'][0], "_").concat(data['remote-source'][1], "_").concat(data['remote-source'][2]); if (data['remote-source'].length === 4) { key = "".concat(key, "_").concat(data['remote-source'][3]); } options = adapter.fieldMasterData[key]; } else { options = data.source; } var optionData = this.getFormSelectOptionsRemote(options, field, adapter); // value should be an array if multi-select if (data.type === 'select2multi') { try { value = JSON.parse(value); if (value == null) { value = []; } value = value.map(function (item) { return "".concat(item); }); } catch (e) { value = []; } } return /*#__PURE__*/_react["default"].createElement(_antd.Select, { mode: data.type === 'select2multi' ? 'multiple' : undefined, showSearch: true, placeholder: "Select ".concat(data.label), optionFilterProp: "children", filterOption: function filterOption(input, option) { return input != null && option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0; }, value: value, options: optionData, allowClear: true, onChange: this.handleChange.bind(this), disabled: this.props.readOnly }); } }, { key: "handleChange", value: function handleChange(value) { var field = this.props.field; var data = field[1]; if (data.type === 'select2multi') { this.onChange(JSON.stringify(value)); } else { this.onChange(value); } } }, { key: "makeOption", value: function makeOption(option) { return /*#__PURE__*/_react["default"].createElement(Option, { key: "".concat(option[0]), value: "".concat(option[0]) }, option[1]); } }, { key: "getFormSelectOptionsRemote", value: function getFormSelectOptionsRemote(options, field, adapter) { var optionData = []; if (Array.isArray(options)) { for (var i = 0; i < options.length; i++) { optionData.push({ label: options[i][1], value: options[i][0] }); } } else { for (var key in options) { optionData.push({ label: options[key], value: key }); } } // if (field[1].sort === 'true') { // tuples.sort((a, b) => { // a = a[1]; // b = b[1]; // // // eslint-disable-next-line no-nested-ternary // return a < b ? -1 : (a > b ? 1 : 0); // }); // } // for (let i = 0; i < tuples.length; i++) { // const prop = tuples[i][0]; // const value = tuples[i][1]; // optionData.push([prop, adapter.gt(value)]); // } return optionData; } }]); return IceSelect; }(_react["default"].Component); var _default = IceSelect; exports["default"] = _default; },{"antd":"antd","react":"react"}],58:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; var _react = _interopRequireDefault(require("react")); var _reactSignatureCanvas = _interopRequireDefault(require("react-signature-canvas")); var _antd = require("antd"); var _icons = require("@ant-design/icons"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } function _defineProperty(obj, key, value) { 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, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { 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; } 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 { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 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 } }); if (superClass) _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } var IceSignature = /*#__PURE__*/function (_React$Component) { _inherits(IceSignature, _React$Component); var _super = _createSuper(IceSignature); function IceSignature(props) { var _this; _classCallCheck(this, IceSignature); _this = _super.call(this, props); _this.onChange = props.onChange; _this.state = { visible: false }; _this.signature = _react["default"].createRef(); return _this; } _createClass(IceSignature, [{ key: "componentDidMount", value: function componentDidMount() {} }, { key: "show", value: function show() { this.setState({ visible: true }); } }, { key: "setSignature", value: function setSignature(ref) { if (ref == null) { return; } var value = this.props.value; if (value != null && value.length > 10) { ref.fromDataURL(value); } } }, { key: "hide", value: function hide() { this.setState({ visible: false }); } }, { key: "clear", value: function clear() { this.signature.clear(); } }, { key: "save", value: function save() { var data = this.signature.toDataURL('image/png'); this.onChange(data); this.setState({ visible: false }); } }, { key: "render", value: function render() { var _this2 = this; var readOnly = this.props.readOnly; return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_antd.Modal, { visible: this.state.visible, title: "Signature", maskClosable: false, centered: true, width: 300, onCancel: function onCancel() { _this2.hide(); }, footer: [/*#__PURE__*/_react["default"].createElement(_antd.Button, { key: "cancel", onClick: function onClick() { _this2.hide(); } }, "Cancel"), /*#__PURE__*/_react["default"].createElement(_antd.Button, { key: "clear", disabled: readOnly, type: "dashed", onClick: function onClick() { if (!readOnly) { _this2.clear(); } } }, "Clear"), /*#__PURE__*/_react["default"].createElement(_antd.Button, { key: "ok", disabled: readOnly, type: "primary", onClick: function onClick() { if (!readOnly) { _this2.save(); } } }, "Submit")] }, /*#__PURE__*/_react["default"].createElement(_reactSignatureCanvas["default"], { ref: function ref(_ref) { _this2.signature = _ref; _this2.setSignature(_ref); }, canvasProps: _objectSpread({ width: 250, height: 200, className: 'sigCanvas' }, readOnly ? { readOnly: readOnly } : {}) })), /*#__PURE__*/_react["default"].createElement(_antd.Tag, { color: "blue", style: { cursor: 'pointer' }, onClick: function onClick() { _this2.show(); } }, /*#__PURE__*/_react["default"].createElement(_icons.VerifiedOutlined, null), ' ', "Sign")); } }]); return IceSignature; }(_react["default"].Component); var _default = IceSignature; exports["default"] = _default; },{"@ant-design/icons":"@ant-design/icons","antd":"antd","react":"react","react-signature-canvas":369}],59:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; var _react = _interopRequireDefault(require("react")); var _antd = require("antd"); var _IceForm2 = _interopRequireDefault(require("./IceForm")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 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 _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); } function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } 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(n); 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(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } 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 ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } function _defineProperty(obj, key, value) { 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, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { 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; } 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 { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 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 } }); if (superClass) _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } var Step = _antd.Steps.Step; var IceStepForm = /*#__PURE__*/function (_IceForm) { _inherits(IceStepForm, _IceForm); var _super = _createSuper(IceStepForm); function IceStepForm(props) { var _this; _classCallCheck(this, IceStepForm); _this = _super.call(this, props); _this.onChange = props.onChange; var steps = _this.props.fields.map(function (item) { return _objectSpread({}, item, { ref: _react["default"].createRef() }); }); steps = steps.map(function (item) { var ref = item.ref, fields = item.fields; item.content = /*#__PURE__*/_react["default"].createElement(_IceForm2["default"], { ref: ref, adapter: props.adapter, fields: fields, twoColumnLayout: props.twoColumnLayout, width: props.width, layout: props.layout || 'horizontal' }); return item; }); _this.state = { current: 0, steps: steps, loading: false }; return _this; } _createClass(IceStepForm, [{ key: "moveToStep", value: function moveToStep(current) { this.setState({ current: current }); } }, { key: "next", value: function next() { if (this.validateFields(false) === false) { return; } this.showError(false); var current = this.state.current + 1; this.setState({ current: current }); } }, { key: "prev", value: function prev() { var current = this.state.current - 1; if (current < 0) { return; } this.setState({ current: current }); } }, { key: "render", value: function render() { var _this2 = this; var adapter = this.props.adapter; var _this$state = this.state, current = _this$state.current, steps = _this$state.steps; return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_antd.Steps, { current: current }, steps.map(function (item, index) { return /*#__PURE__*/_react["default"].createElement(Step, { key: item.title, title: item.title, onClick: function onClick() { return _this2.moveToStep(index); } }); })), /*#__PURE__*/_react["default"].createElement(_antd.Divider, null), /*#__PURE__*/_react["default"].createElement("div", { className: "steps-content" }, steps.map(function (item, index) { return /*#__PURE__*/_react["default"].createElement("div", { style: { display: index === current ? 'block' : 'none' } }, item.content); })), /*#__PURE__*/_react["default"].createElement(_antd.Divider, null), /*#__PURE__*/_react["default"].createElement("div", { className: "steps-action" }, /*#__PURE__*/_react["default"].createElement(_antd.Row, { gutter: 16 }, /*#__PURE__*/_react["default"].createElement(_antd.Col, { className: "gutter-row", span: 12, style: {} }, /*#__PURE__*/_react["default"].createElement(_antd.Space, null, current < steps.length - 1 && /*#__PURE__*/_react["default"].createElement(_antd.Button, { type: "primary", onClick: function onClick() { return _this2.next(); } }, adapter.gt('Next')), current > 0 && /*#__PURE__*/_react["default"].createElement(_antd.Button, { onClick: function onClick() { return _this2.prev(); } }, adapter.gt('Previous')))), /*#__PURE__*/_react["default"].createElement(_antd.Col, { className: "gutter-row", span: 12, style: { textAlign: 'right' } }, /*#__PURE__*/_react["default"].createElement(_antd.Space, null, /*#__PURE__*/_react["default"].createElement(_antd.Button, { onClick: function onClick() { return _this2.props.closeModal(); } }, adapter.gt('Cancel')), /*#__PURE__*/_react["default"].createElement(_antd.Button, { type: "primary", loading: this.state.loading, onClick: function onClick() { return _this2.saveData(); } }, adapter.gt('Save'))))))); } }, { key: "saveData", value: function () { var _saveData = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() { var _this3 = this; var data; return regeneratorRuntime.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: this.setState({ loading: true }); _context.next = 3; return this.validateFields(true); case 3: data = _context.sent; if (data) { this.save(data, function () { return _this3.props.closeModal(); }); } this.setState({ loading: false }); case 6: case "end": return _context.stop(); } } }, _callee, this); })); function saveData() { return _saveData.apply(this, arguments); } return saveData; }() }, { key: "save", value: function save(params, success) { var _this4 = this; var adapter = this.props.adapter; adapter.add(params, [], function () { return adapter.get([]); }, function () { _this4.resetFields(); _this4.showError(false); success(); }); } }, { key: "updateFields", value: function updateFields(data) { var _this5 = this; this.state.steps.forEach(function (item) { var subData = {}; item.fields.forEach(function (_ref) { var _ref2 = _slicedToArray(_ref, 1), key = _ref2[0]; subData[key] = data[key]; }); _this5.updateFieldsSubForm(item.ref, item.fields, subData); }); } }, { key: "updateFieldsSubForm", value: function updateFieldsSubForm(ref, fields, data) { data = this.dataToFormFields(data, fields); ref.current.resetFields(); if (data == null) { return; } try { ref.current.setFieldsValue(data); } catch (e) { console.log(e); } } }, { key: "validateFields", value: function () { var _validateFields = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(all) { var adapter, steps, promiseList, allData, failedIndex, values, msg, id, fields; return regeneratorRuntime.wrap(function _callee2$(_context2) { while (1) { switch (_context2.prev = _context2.next) { case 0: adapter = this.props.adapter; steps = all ? this.state.steps : this.state.steps.slice(0, this.state.current + 1); promiseList = steps.map(function (item) { return item.ref.current.validateFields().then(function (values) { if (!item.ref.current.isValid()) { return false; } return values; })["catch"](function () { return false; }); }); _context2.next = 5; return Promise.all(promiseList); case 5: allData = _context2.sent; failedIndex = allData.findIndex(function (item) { return item === false; }); if (!(failedIndex >= 0)) { _context2.next = 10; break; } this.setState({ current: failedIndex }); return _context2.abrupt("return", false); case 10: values = Object.assign.apply(Object, [{}].concat(_toConsumableArray(allData))); values = adapter.forceInjectValuesBeforeSave(values); msg = adapter.doCustomValidation(values); if (!(msg !== null)) { _context2.next = 16; break; } this.showError(msg); return _context2.abrupt("return", false); case 16: if (adapter.csrfRequired) { values.csrf = $("#".concat(adapter.getTableName(), "Form")).data('csrf'); } id = adapter.currentElement != null ? adapter.currentElement.id : null; if (id != null && id !== '') { values.id = id; } fields = [].concat.apply([], this.state.steps.map(function (item) { return item.fields; })); return _context2.abrupt("return", this.formFieldsToData(values, fields)); case 21: case "end": return _context2.stop(); } } }, _callee2, this); })); function validateFields(_x) { return _validateFields.apply(this, arguments); } return validateFields; }() }, { key: "getSubFormData", value: function getSubFormData(ref, fields, params) { var adapter = this.props.adapter; var values = params; values = adapter.forceInjectValuesBeforeSave(values); var msg = adapter.doCustomValidation(values); if (msg !== null) { ref.current.showError(msg); return; } if (adapter.csrfRequired) { values.csrf = $("#".concat(adapter.getTableName(), "Form")).data('csrf'); } var id = adapter.currentElement != null ? adapter.currentElement.id : null; if (id != null && id !== '') { values.id = id; } return this.formFieldsToData(values, fields); } }, { key: "showError", value: function showError(errorMsg) { this.state.steps.forEach(function (item) { return item.ref.current.showError(errorMsg); }); } }, { key: "resetFields", value: function resetFields() { this.state.steps.forEach(function (item) { return item.ref.current.resetFields(); }); } }, { key: "hideError", value: function hideError() { this.state.steps.forEach(function (item) { return item.ref.current.hideError(); }); } }, { key: "isReady", value: function isReady() { return this.state.steps.reduce(function (acc, item) { return acc && item.ref.current != null; }, true); } }]); return IceStepForm; }(_IceForm2["default"]); var _default = IceStepForm; exports["default"] = _default; },{"./IceForm":54,"antd":"antd","react":"react"}],60:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; var _react = _interopRequireDefault(require("react")); var _antd = require("antd"); var _IceFormModal2 = _interopRequireDefault(require("./IceFormModal")); var _IceStepForm = _interopRequireDefault(require("./IceStepForm")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(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, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { 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; } 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 { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 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 } }); if (superClass) _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } var IceStepFormModal = /*#__PURE__*/function (_IceFormModal) { _inherits(IceStepFormModal, _IceFormModal); var _super = _createSuper(IceStepFormModal); function IceStepFormModal(props) { var _this; _classCallCheck(this, IceStepFormModal); _this = _super.call(this, props); _this.width = 850; return _this; } _createClass(IceStepFormModal, [{ key: "show", value: function show(data) { var _this2 = this; this.props.adapter.beforeRenderFieldHook = this.props.adapter.beforeRenderField ? this.props.adapter.beforeRenderField(data) : function (fieldName, field) { return field; }; if (!data) { this.setState({ visible: true }); if (this.iceFormReference.current) { this.iceFormReference.current.resetFields(); } } else { this.setState({ visible: true }); if (this.iceFormReference.current && this.iceFormReference.current.isReady()) { this.iceFormReference.current.moveToStep(0); this.iceFormReference.current.updateFields(data); } else { this.waitForIt(function () { return _this2.iceFormReference.current && _this2.iceFormReference.current.isReady(); }, function () { _this2.iceFormReference.current.updateFields(data); _this2.iceFormReference.current.moveToStep(0); }, 1000); } } } }, { key: "hide", value: function hide() { this.iceFormReference.current.moveToStep(0); this.setState({ visible: false }); } }, { key: "render", value: function render() { var _this3 = this; var _this$props = this.props, fields = _this$props.fields, adapter = _this$props.adapter; var _this$props$adapter$g = this.props.adapter.getFormOptions(), width = _this$props$adapter$g.width, twoColumnLayout = _this$props$adapter$g.twoColumnLayout, layout = _this$props$adapter$g.layout; return /*#__PURE__*/_react["default"].createElement(_antd.Modal, { visible: this.state.visible, title: this.props.adapter.gt(this.props.title || adapter.objectTypeName), maskClosable: false, width: width || this.width, footer: [], onCancel: function onCancel() { _this3.closeModal(); } }, /*#__PURE__*/_react["default"].createElement(_IceStepForm["default"], { ref: this.iceFormReference, adapter: adapter, fields: fields, closeModal: function closeModal() { _this3.closeModal(); }, twoColumnLayout: twoColumnLayout || false, layout: layout })); } }]); return IceStepFormModal; }(_IceFormModal2["default"]); var _default = IceStepFormModal; exports["default"] = _default; },{"./IceFormModal":55,"./IceStepForm":59,"antd":"antd","react":"react"}],61:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; var _react = _interopRequireWildcard(require("react")); var _antd = require("antd"); var _icons = require("@ant-design/icons"); function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; } function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } function _defineProperty(obj, key, value) { 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, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { 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; } 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 { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 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 } }); if (superClass) _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } var Search = _antd.Input.Search; var IceTable = /*#__PURE__*/function (_React$Component) { _inherits(IceTable, _React$Component); var _super = _createSuper(IceTable); function IceTable(props) { var _this; _classCallCheck(this, IceTable); _this = _super.call(this, props); _this.state = { data: [], pagination: {}, loading: true, fetchConfig: false, //filter: null, showLoading: true, currentElement: null, fetchCompleted: false }; _this.handleTableChange = function (pagination, filters, sorter) { var pager = _objectSpread({}, _this.state.pagination); var search = _this.state.search; pager.current = pagination.current; _this.setState({ pagination: pager }); var fetchConfig = { limit: pagination.pageSize, page: pagination.current, sortField: sorter.field, sortOrder: sorter.order, filters: JSON.stringify(filters), search: search }; _this.setState({ fetchConfig: fetchConfig }); _this.fetch(fetchConfig); }; _this.reload = function () { var fetchConfig = _this.state.fetchConfig; if (fetchConfig) { _this.fetch(fetchConfig); } }; _this.search = function (value) { _this.setState({ search: value }); var fetchConfig = _this.state.fetchConfig; console.log(fetchConfig); if (fetchConfig) { fetchConfig.search = value; _this.setState({ fetchConfig: fetchConfig }); _this.fetch(fetchConfig); } }; _this.addNew = function () { _this.props.adapter.renderForm(); }; _this.showFilters = function () { _this.props.adapter.showFilters(); }; _this.setFilterData = function (filter) { _this.setState({ filter: filter }); }; _this.setCurrentElement = function (currentElement) { _this.setState({ currentElement: currentElement }); }; _this.fetch = function () { var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; //this.setState({ loading: this.state.showLoading }); _this.setState({ loading: true }); //const hideMessage = message.loading({ content: 'Loading Latest Data ...', key: 'loadingTable', duration: 1}); var pagination = _objectSpread({}, _this.state.pagination); if (_this.props.adapter.localStorageEnabled) { try { var cachedResponse = _this.props.reader.getCachedResponse(params); if (cachedResponse.items) { _this.setState({ loading: false, data: cachedResponse.items, pagination: pagination, showLoading: false }); } else { _this.props.reader.clearCachedResponse(params); } } catch (e) { _this.props.reader.clearCachedResponse(params); } } _this.props.reader.get(params).then(function (data) { // Read total count from server // pagination.total = data.totalCount; pagination.total = data.total; //hideMessage(); // setTimeout( // () => message.success({ content: 'Loading Completed!', key: 'loadingSuccess', duration: 1 }), // 600 // ); _this.setState({ loading: false, data: data.items, pagination: pagination, showLoading: false, fetchCompleted: true }); }); }; return _this; } _createClass(IceTable, [{ key: "componentDidMount", value: function componentDidMount() { var fetchConfig = { page: 1 }; _antd.message.config({ top: 40 }); this.setState({ fetchConfig: fetchConfig, //filter: this.props.adapter.filter, pagination: { 'pageSize': this.props.reader.pageSize } }); //this.fetch(fetchConfig); } }, { key: "setLoading", value: function setLoading(value) { this.setState({ loading: value }); } }, { key: "getChildrenWithProps", value: function getChildrenWithProps(element) { var _this2 = this; var childrenWithProps = _react["default"].Children.map(this.props.children, function (child) { // checking isValidElement is the safe way and avoids a typescript error too var props = { element: element, adapter: _this2.props.adapter, loading: _this2.state.loading }; if (_react["default"].isValidElement(child)) { return _react["default"].cloneElement(child, props); } return child; }); return childrenWithProps; } }, { key: "render", value: function render() { var _this3 = this; return /*#__PURE__*/_react["default"].createElement(_antd.Row, { direction: "vertical", style: { width: '100%' } }, !this.state.currentElement && /*#__PURE__*/_react["default"].createElement(_antd.Col, { span: 24 }, /*#__PURE__*/_react["default"].createElement(_antd.Row, { gutter: 24 }, /*#__PURE__*/_react["default"].createElement(_antd.Col, { span: 18 }, /*#__PURE__*/_react["default"].createElement(_antd.Space, null, this.props.adapter.hasAccess('save') && this.props.adapter.getShowAddNew() && /*#__PURE__*/_react["default"].createElement(_antd.Button, { type: "primary", onClick: this.addNew }, /*#__PURE__*/_react["default"].createElement(_icons.PlusCircleOutlined, null), " Add New"), this.props.adapter.getFilters() && /*#__PURE__*/_react["default"].createElement(_antd.Button, { onClick: this.showFilters }, /*#__PURE__*/_react["default"].createElement(_icons.FilterOutlined, null), " Filters"), this.state.fetchCompleted && this.props.adapter.getFilters() && this.props.adapter.filter != null && this.props.adapter.filter !== [] && this.props.adapter.filter !== '' && this.props.adapter.getFilterString(this.props.adapter.filter) !== '' && /*#__PURE__*/_react["default"].createElement(_antd.Tag, { closable: true, style: { 'lineHeight': '30px' }, color: "blue", onClose: function onClose() { return _this3.props.adapter.resetFilters(); }, visible: this.props.adapter.filter != null && this.props.adapter.filter !== [] && this.props.adapter.filter !== '' }, this.props.adapter.getFilterString(this.props.adapter.filter)))), /*#__PURE__*/_react["default"].createElement(_antd.Col, { span: 6 }, /*#__PURE__*/_react["default"].createElement(_antd.Form, { ref: function ref(formRef) { return _this3.form = formRef; }, name: "advanced_search", className: "ant-advanced-search-form" }, /*#__PURE__*/_react["default"].createElement(_antd.Form.Item, { name: "searchTerm", label: "", rules: [{ required: false }] }, /*#__PURE__*/_react["default"].createElement(Search, { placeholder: "input search text", enterButton: "Search", onSearch: function onSearch(value) { return _this3.search(value); } }))))), /*#__PURE__*/_react["default"].createElement(_antd.Row, { gutter: 24 }, /*#__PURE__*/_react["default"].createElement(_antd.Col, { span: 24 }, /*#__PURE__*/_react["default"].createElement(_antd.Table // bordered , { rowClassName: function rowClassName(record, index) { return index % 2 === 0 ? 'table-row-light' : 'table-row-dark'; }, columns: this.props.columns, rowKey: function rowKey(record) { return record.id; }, dataSource: this.state.data, pagination: this.state.pagination, loading: this.state.loading, onChange: this.handleTableChange, reader: this.props.dataPipe })))), this.state.currentElement && this.getChildrenWithProps(this.state.currentElement)); } }]); return IceTable; }(_react["default"].Component); var _default = IceTable; exports["default"] = _default; },{"@ant-design/icons":"@ant-design/icons","antd":"antd","react":"react"}],62:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; var _react = _interopRequireDefault(require("react")); var _antd = require("antd"); var _icons = require("@ant-design/icons"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } 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(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) 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 _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, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { 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; } 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 { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 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 } }); if (superClass) _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } var IceUpload = /*#__PURE__*/function (_React$Component) { _inherits(IceUpload, _React$Component); var _super = _createSuper(IceUpload); function IceUpload(props) { var _this; _classCallCheck(this, IceUpload); _this = _super.call(this, props); _this.state = { fileList: [], uploaded: false }; _this._isMounted = false; _this.handleDelete = function () { _this.setState({ fileList: [], value: null, uploaded: false }); _this.onChange(null); }; _this.handleView = function () { var currentValue = _this.props.value; if (_this.state.value != null && _this.state.value !== '') { currentValue = _this.state.value; } if (currentValue == null || currentValue === '') { _antd.message.error('File not found'); return; } var adapter = _this.props.adapter; adapter.getFile(currentValue).then(function (data) { var file = { key: data.uid, uid: data.uid, name: data.name, status: data.status, url: data.filename }; window.open(file.url); })["catch"](function (e) {}); }; _this.handleChange = function (info) { var fileList = _toConsumableArray(info.fileList); if (fileList.length === 0) { _this.setState({ value: null }); _this.onChange(null); _this.setState({ fileList: [] }); _this.setState({ uploaded: false }); return; } fileList = fileList.slice(-1); if (fileList[0].response && fileList[0].response.status === 'error') { _this.setState({ value: null }); _this.onChange(null); _this.setState({ fileList: [] }); _this.setState({ uploaded: false }); _antd.message.error("Error: ".concat(fileList[0].response.message)); return; } fileList = fileList.map(function (file) { if (file.response) { // Component will show file.url as link file.name = file.response.name; file.url = file.response.url; } return file; }); _this.setState({ fileList: fileList }); _this.setState({ value: _this.getFileName(fileList), uploaded: true }); _this.onChange(_this.getFileName(fileList)); }; _this.onChange = props.onChange; return _this; } _createClass(IceUpload, [{ key: "componentDidMount", value: function componentDidMount() { this._isMounted = true; _antd.message.config({ top: 55, duration: 2 }); } }, { key: "componentWillUnmount", value: function componentWillUnmount() { this._isMounted = false; } }, { key: "getFileName", value: function getFileName(fileList) { var file = null; if (fileList) { file = fileList[0]; } return file ? file.name : ''; } }, { key: "generateRandom", value: function generateRandom(length) { var d = new Date(); var chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; var result = ''; for (var i = length; i > 0; --i) { result += chars[Math.round(Math.random() * (chars.length - 1))]; } return result + d.getTime(); } }, { key: "render", value: function render() { var fileName = this.generateRandom(14); var props = { action: "".concat(window.CLIENT_BASE_URL, "fileupload-new.php?user=").concat(this.props.user, "&file_group=").concat(this.props.fileGroup, "&file_name=").concat(fileName), onChange: this.handleChange, onRemove: this.handleDelete, multiple: false, listType: 'picture' }; return /*#__PURE__*/_react["default"].createElement(_antd.Space, { direction: 'vertical' }, !this.props.readOnly && /*#__PURE__*/_react["default"].createElement(_antd.Space, null, /*#__PURE__*/_react["default"].createElement(_antd.Upload, _extends({}, props, { fileList: this.state.fileList }), /*#__PURE__*/_react["default"].createElement(_antd.Tag, { color: "blue", style: { cursor: 'pointer' } }, /*#__PURE__*/_react["default"].createElement(_icons.UploadOutlined, null), ' ', "Upload"))), /*#__PURE__*/_react["default"].createElement(_antd.Space, null, (this.props.value != null && this.props.value !== '' || this.state.value != null && this.state.value !== '') && !this.state.uploaded && /*#__PURE__*/_react["default"].createElement(_antd.Button, { type: "link", htmlType: "button", onClick: this.handleView }, /*#__PURE__*/_react["default"].createElement(_icons.DownloadOutlined, null), " View File"), (this.props.value != null && this.props.value !== '' || this.state.value != null && this.state.value !== '') && !this.state.uploaded && !this.props.readOnly && /*#__PURE__*/_react["default"].createElement(_antd.Button, { type: "link", htmlType: "button", danger: true, onClick: this.handleDelete }, /*#__PURE__*/_react["default"].createElement(_icons.DeleteOutlined, null), " Delete"))); } }]); return IceUpload; }(_react["default"].Component); var _default = IceUpload; exports["default"] = _default; },{"@ant-design/icons":"@ant-design/icons","antd":"antd","react":"react"}],63:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; var _react = _interopRequireDefault(require("react")); var _antd = require("antd"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(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, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { 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; } 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 { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 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 } }); if (superClass) _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } var TagList = /*#__PURE__*/function (_React$Component) { _inherits(TagList, _React$Component); var _super = _createSuper(TagList); function TagList(props) { var _this; _classCallCheck(this, TagList); _this = _super.call(this, props); _this.state = { tags: [], loading: true }; return _this; } _createClass(TagList, [{ key: "componentDidMount", value: function componentDidMount() { this.fetch(); } }, { key: "fetch", value: function fetch() { var _this2 = this; this.setState({ loading: true }); this.props.apiClient.get(this.props.url).then(function (response) { var tags = response.data.data.map(_this2.props.extractTag); _this2.setState({ tags: tags, loading: false }); }); } }, { key: "render", value: function render() { var _this3 = this; return /*#__PURE__*/_react["default"].createElement("div", { style: { display: 'inline-block', textOverflow: 'ellipsis', whiteSpace: 'nowrap', overflow: 'hidden', width: '100%' } }, this.state.loading && /*#__PURE__*/_react["default"].createElement(_antd.Skeleton, { active: true }), !this.state.loading && this.state.tags.map(function (tag, index) { return _this3.props.render ? _this3.props.render(tag) : /*#__PURE__*/_react["default"].createElement("div", { key: "p".concat(index) }, /*#__PURE__*/_react["default"].createElement(_antd.Tag, { color: _this3.props.color, key: index, style: { margin: '10px' } }, tag), /*#__PURE__*/_react["default"].createElement("br", null)); })); } }]); return TagList; }(_react["default"].Component); var _default = TagList; exports["default"] = _default; },{"antd":"antd","react":"react"}],64:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; var _react = _interopRequireWildcard(require("react")); var _antd = require("antd"); var _CustomAction = _interopRequireDefault(require("../api/CustomAction")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; } function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } 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, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { 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; } 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 { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 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 } }); if (superClass) _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } var UpdatePasswordModal = /*#__PURE__*/function (_React$Component) { _inherits(UpdatePasswordModal, _React$Component); var _super = _createSuper(UpdatePasswordModal); function UpdatePasswordModal(props) { var _this; _classCallCheck(this, UpdatePasswordModal); _this = _super.call(this, props); _this.state = { loading: false, passwordHasError: false, passwordState: { hasFeedback: false, validateStatus: '', help: 'Password must include at least one number, one lowercase letter, one uppercase letter and a symbol' }, confirmationHasError: false, confirmationState: { hasFeedback: false, validateStatus: '', help: '' } }; _this.clearConfirmFeedback = function () { _this.setState({ confirmationHasError: false }); _this.setState({ confirmationState: { hasFeedback: false, validateStatus: '', help: '' } }); }; _this.handleOk = function () { var from = _this.formRef.current; from.validateFields().then(function (values) { if (_this.updatePasswordState(values["new"]) && _this.updateConfirmPasswordState(values)) { _this.updatePassword(values.current, values["new"]).then(function (response) { var data = response.data; console.log(data); if (data.status === 'SUCCESS') { _this.handleCancel(); _antd.message.success(_this.props.adapter.gt('Password updated')); } else { _antd.message.error("".concat(_this.props.adapter.gt('Error updating password'), ": ").concat(_this.props.adapter.gt(data.data))); } })["catch"](function (error) { _antd.message.error("".concat(_this.props.adapter.gt('Error updating password'))); console.log(error.message); }); } })["catch"](function (info) { _this.setState({ loading: false }); }); }; _this.handleCancel = function () { if (_this.formRef.current) { _this.formRef.current.resetFields(); } _this.props.closeModal(); }; _this.updatePassword = function (oldPassword, newPassword) { var req = { current: oldPassword ? oldPassword : '', pwd: newPassword }; var reqJson = JSON.stringify(req); var callBackData = []; callBackData.callBackData = []; callBackData.callBackSuccess = 'changePasswordSuccessCallBack'; callBackData.callBackFail = 'changePasswordFailCallBack'; return _this.customAction.execute('changePassword', 'modules=employees', reqJson); }; _this.validatePassword = function (password) { if (password.length < 8) { return _this.props.adapter.gt('Password too short'); } if (password.length > 30) { return _this.props.adapter.gt('Password too long'); } var numberTester = /.*[0-9]+.*$/; if (!password.match(numberTester)) { return _this.props.adapter.gt('Password must include at least one number'); } var lowerTester = /.*[a-z]+.*$/; if (!password.match(lowerTester)) { return _this.props.adapter.gt('Password must include at least one lowercase letter'); } var upperTester = /.*[A-Z]+.*$/; if (!password.match(upperTester)) { return _this.props.adapter.gt('Password must include at least one uppercase letter'); } var symbolTester = /.*[\W]+.*$/; if (!password.match(symbolTester)) { return _this.props.adapter.gt('Password must include at least one symbol'); } return null; }; _this.formRef = _react["default"].createRef(); _this.customAction = new _CustomAction["default"](_this.props.adapter); return _this; } _createClass(UpdatePasswordModal, [{ key: "componentDidMount", value: function componentDidMount() { _antd.message.config({ top: 40 }); } }, { key: "updatePasswordState", value: function updatePasswordState(value) { var passwordValidationResult = this.validatePassword(value); if (passwordValidationResult !== null) { this.setState({ passwordHasError: true }); this.setState({ passwordState: { hasFeedback: true, validateStatus: 'error', help: passwordValidationResult } }); return false; } else { this.setState({ passwordHasError: false }); this.setState({ passwordState: { hasFeedback: true, validateStatus: 'success', help: '' } }); } return true; } }, { key: "updateConfirmPasswordState", value: function updateConfirmPasswordState(values) { if (values.confirm !== values["new"]) { this.setState({ confirmationHasError: true }); this.setState({ confirmationState: { hasFeedback: true, validateStatus: 'error', help: 'Passwords don\'t match' } }); return false; } else { this.setState({ confirmationHasError: false }); this.setState({ confirmationState: { hasFeedback: false, validateStatus: '', help: '' } }); } return true; } }, { key: "render", value: function render() { var _this2 = this; var layout = { labelCol: { span: 8 }, wrapperCol: { span: 16 } }; return /*#__PURE__*/_react["default"].createElement(_antd.Modal, { visible: this.props.visible, title: "Update Password", onOk: this.handleOk, onCancel: this.handleCancel, footer: [/*#__PURE__*/_react["default"].createElement(_antd.Button, { key: "back", onClick: this.handleCancel }, this.props.adapter.gt('Cancel')), /*#__PURE__*/_react["default"].createElement(_antd.Button, { key: "submit", type: "primary", loading: this.state.loading, onClick: this.handleOk }, this.props.adapter.gt('Update'))] }, /*#__PURE__*/_react["default"].createElement(_antd.Form, _extends({}, layout, { ref: this.formRef }), /*#__PURE__*/_react["default"].createElement(_antd.Form.Item, { label: "Current Password", key: "current", name: "current" }, /*#__PURE__*/_react["default"].createElement(_antd.Input.Password, { placeholder: "current password" })), this.state.passwordHasError && /*#__PURE__*/_react["default"].createElement(_antd.Form.Item, _extends({ label: "New Password", key: "new", name: "new" }, this.state.passwordState), /*#__PURE__*/_react["default"].createElement(_antd.Input.Password, { placeholder: "new password", onChange: function onChange(event) { return _this2.updatePasswordState(event.target.value); } })), !this.state.passwordHasError && /*#__PURE__*/_react["default"].createElement(_antd.Form.Item, _extends({ label: "New Password", key: "new", name: "new" }, this.state.passwordState), /*#__PURE__*/_react["default"].createElement(_antd.Input.Password, { placeholder: "new password", onChange: function onChange(event) { return _this2.updatePasswordState(event.target.value); } })), this.state.confirmationHasError && /*#__PURE__*/_react["default"].createElement(_antd.Form.Item, _extends({ label: "Confirm Password", key: "confirm", name: "confirm" }, this.state.confirmationState), /*#__PURE__*/_react["default"].createElement(_antd.Input.Password, { placeholder: "confirm password", onChange: function onChange(event) { return _this2.clearConfirmFeedback(); } })), !this.state.confirmationHasError && /*#__PURE__*/_react["default"].createElement(_antd.Form.Item, { label: "Confirm Password", key: "confirm", name: "confirm" }, /*#__PURE__*/_react["default"].createElement(_antd.Input.Password, { placeholder: "confirm password", onChange: function onChange(event) { return _this2.clearConfirmFeedback(); } })))); } }]); return UpdatePasswordModal; }(_react["default"].Component); var _default = UpdatePasswordModal; exports["default"] = _default; },{"../api/CustomAction":42,"antd":"antd","react":"react"}],65:[function(require,module,exports){ "use strict"; var _lib = require("./lib"); window.AttendanceAdapter = _lib.AttendanceAdapter; window.EmployeeAttendanceSheetAdapter = _lib.EmployeeAttendanceSheetAdapter; },{"./lib":66}],66:[function(require,module,exports){ "use strict"; var _AdapterBase3 = _interopRequireDefault(require("../../../api/AdapterBase")); var _FormValidation = _interopRequireDefault(require("../../../api/FormValidation")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(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, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { 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; } 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 { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 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 } }); if (superClass) _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } var AttendanceAdapter = /*#__PURE__*/function (_AdapterBase) { _inherits(AttendanceAdapter, _AdapterBase); var _super = _createSuper(AttendanceAdapter); function AttendanceAdapter(endPoint, tab, filter, orderBy) { var _this; _classCallCheck(this, AttendanceAdapter); _this = _super.call(this, endPoint, tab, filter, orderBy); _this.punch = null; _this.useServerTime = 0; _this.photoTaken = 0; _this.photoAttendance = 0; return _this; } _createClass(AttendanceAdapter, [{ key: "updatePunchButton", value: function updatePunchButton() { this.getPunch('changePunchButtonSuccessCallBack'); } }, { key: "setUseServerTime", value: function setUseServerTime(val) { this.useServerTime = val; } }, { key: "setPhotoAttendance", value: function setPhotoAttendance(val) { this.photoAttendance = parseInt(val, 10); } }, { key: "getDataMapping", value: function getDataMapping() { return ['id', 'in_time', 'out_time', 'note']; } }, { key: "getHeaders", value: function getHeaders() { return [{ sTitle: 'ID', bVisible: false }, { sTitle: 'Time-In' }, { sTitle: 'Time-Out' }, { sTitle: 'Note' }]; } }, { key: "getFormFields", value: function getFormFields() { if (this.useServerTime === 0) { return [['id', { label: 'ID', type: 'hidden' }], ['time', { label: 'Time', type: 'datetime' }], ['note', { label: 'Note', type: 'textarea', validation: 'none' }]]; } return [['id', { label: 'ID', type: 'hidden' }], ['note', { label: 'Note', type: 'textarea', validation: 'none' }]]; } }, { key: "getCustomTableParams", value: function getCustomTableParams() { var that = this; var dataTableParams = { aoColumnDefs: [{ fnRender: function fnRender(data, cell) { return that.preProcessRemoteTableData(data, cell, 1); }, aTargets: [1] }, { fnRender: function fnRender(data, cell) { return that.preProcessRemoteTableData(data, cell, 2); }, aTargets: [2] }, { fnRender: function fnRender(data, cell) { return that.preProcessRemoteTableData(data, cell, 3); }, aTargets: [3] }, { fnRender: that.getActionButtons, aTargets: [that.getDataMapping().length] }] }; return dataTableParams; } }, { key: "preProcessRemoteTableData", value: function preProcessRemoteTableData(data, cell, id) { if (id === 1) { if (cell === '0000-00-00 00:00:00' || cell === '' || cell === undefined || cell === null) { return ''; } return Date.parse(cell).toString('yyyy MMM d HH:mm'); } if (id === 2) { if (cell === '0000-00-00 00:00:00' || cell === '' || cell === undefined || cell === null) { return ''; } return Date.parse(cell).toString('MMM d HH:mm'); } if (id === 3) { if (cell !== undefined && cell !== null) { if (cell.length > 20) { return "".concat(cell.substring(0, 20), ".."); } } return cell; } return cell; } }, { key: "getActionButtonsHtml", value: function getActionButtonsHtml(id, data) { return ''; } }, { key: "getTableTopButtonHtml", value: function getTableTopButtonHtml() { if (this.punch === null || this.punch === undefined) { return ''; } return ''; } }, { key: "save", value: function save() { var that = this; var validator = new _FormValidation["default"]("".concat(this.getTableName(), "_submit"), true, { ShowPopup: false, LabelErrorClass: 'error' }); if (validator.checkValues()) { var msg = this.doCustomValidation(); if (msg == null) { var params = validator.getFormParameters(); params = this.forceInjectValuesBeforeSave(params); params.cdate = this.getClientDate(new Date()).toISOString().slice(0, 19).replace('T', ' '); var reqJson = JSON.stringify(params); var callBackData = []; callBackData.callBackData = []; callBackData.callBackSuccess = 'saveSuccessCallback'; callBackData.callBackFail = 'getPunchFailCallBack'; this.customAction('savePunch', 'modules=attendance', reqJson, callBackData, true); } else { $("#".concat(this.getTableName(), "Form .label")).html(msg); $("#".concat(this.getTableName(), "Form .label")).show(); } } } }, { key: "saveSuccessCallback", value: function saveSuccessCallback(callBackData) { this.punch = callBackData; this.getPunch('changePunchButtonSuccessCallBack'); $('#PunchModel').modal('hide'); this.get([]); } }, { key: "cancel", value: function cancel() { $('#PunchModel').modal('hide'); } }, { key: "showPunchDialog", value: function showPunchDialog() { this.getPunch('showPunchDialogShowPunchSuccessCallBack'); } }, { key: "getPunch", value: function getPunch(successCallBack) { var that = this; var object = {}; object.date = this.getClientDate(new Date()).toISOString().slice(0, 19).replace('T', ' '); object.offset = this.getClientGMTOffset(); var reqJson = JSON.stringify(object); var callBackData = []; callBackData.callBackData = []; callBackData.callBackSuccess = successCallBack; callBackData.callBackFail = 'getPunchFailCallBack'; this.customAction('getPunch', 'modules=attendance', reqJson, callBackData); } }, { key: "showPunchDialogShowPunchSuccessCallBack", value: function showPunchDialogShowPunchSuccessCallBack(callBackData) { this.punch = callBackData; $('#PunchModel').modal('show'); if (this.punch === null) { $('#PunchModel').find('h3').html('Punch Time-in'); modJs.renderForm(); } else { $('#PunchModel').find('h3').html('Punch Time-out'); modJs.renderForm(this.punch); } $('#Attendance').show(); var picker = $('#time_datetime').data('datetimepicker'); picker.setLocalDate(new Date()); } }, { key: "changePunchButtonSuccessCallBack", value: function changePunchButtonSuccessCallBack(callBackData) { this.punch = callBackData; if (this.punch === null) { $('#punchButton').html('Punch-in '); } else { $('#punchButton').html('Punch-out '); } } }, { key: "getPunchFailCallBack", value: function getPunchFailCallBack(callBackData) { this.showMessage('Error Occured while Time Punch', callBackData); } }, { key: "getClientDate", value: function getClientDate(date) { var offset = this.getClientGMTOffset(); var tzDate = date.addMinutes(offset * 60); return tzDate; } }, { key: "getClientGMTOffset", value: function getClientGMTOffset() { var rightNow = new Date(); var jan1 = new Date(rightNow.getFullYear(), 0, 1, 0, 0, 0, 0); var temp = jan1.toGMTString(); var jan2 = new Date(temp.substring(0, temp.lastIndexOf(' ') - 1)); return (jan1 - jan2) / (1000 * 60 * 60); } }, { key: "doCustomValidation", value: function doCustomValidation(params) { if (this.photoAttendance === 1 && !this.photoTaken) { return 'Please attach a photo before submitting'; } return null; } }, { key: "forceInjectValuesBeforeSave", value: function forceInjectValuesBeforeSave(params) { if (this.photoAttendance === 1) { var canvas = document.getElementById('attendnaceCanvas'); params.image = canvas.toDataURL(); } return params; } }, { key: "postRenderForm", value: function postRenderForm() { if (this.photoAttendance === 1) { $('.photoAttendance').show(); var video = document.getElementById('attendnaceVideo'); // Get access to the camera! if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) { navigator.mediaDevices.getUserMedia({ video: true }).then(function (stream) { //video.src = (window.URL ? window.URL : webkitURL).createObjectURL(stream); video.srcObject = stream; video.play(); }); } this.photoTaken = false; this.configureEvents(); } else { $('.photoAttendance').remove(); } } }, { key: "configureEvents", value: function configureEvents() { var that = this; var canvas = document.getElementById('attendnaceCanvas'); var context = canvas.getContext('2d'); var video = document.getElementById('attendnaceVideo'); $('.attendnaceSnap').click(function () { context.drawImage(video, 0, 0, 208, 156); that.photoTaken = true; return false; }); } }]); return AttendanceAdapter; }(_AdapterBase3["default"]); var EmployeeAttendanceSheetAdapter = /*#__PURE__*/function (_AdapterBase2) { _inherits(EmployeeAttendanceSheetAdapter, _AdapterBase2); var _super2 = _createSuper(EmployeeAttendanceSheetAdapter); function EmployeeAttendanceSheetAdapter(endPoint, tab, filter, orderBy) { var _this2; _classCallCheck(this, EmployeeAttendanceSheetAdapter); _this2 = _super2.call(this, endPoint, tab, filter, orderBy); _this2.currentTimesheetId = null; _this2.currentTimesheet = null; return _this2; } _createClass(EmployeeAttendanceSheetAdapter, [{ key: "getDataMapping", value: function getDataMapping() { return ['id', 'date_start', 'date_end', 'total_time', 'status']; } }, { key: "getHeaders", value: function getHeaders() { return [{ sTitle: 'ID', bVisible: false }, { sTitle: 'Start Date' }, { sTitle: 'End Date' }, { sTitle: 'Total Time' }, { sTitle: 'Status' }]; } }, { key: "getFormFields", value: function getFormFields() { return [['id', { label: 'ID', type: 'hidden' }], ['date_start', { label: 'TimeSheet Start Date', type: 'date', validation: '' }], ['date_end', { label: 'TimeSheet End Date', type: 'date', validation: '' }], ['details', { label: 'Reason', type: 'textarea', validation: 'none' }]]; } }, { key: "preProcessTableData", value: function preProcessTableData(row) { row[1] = Date.parse(row[1]).toString('MMM d, yyyy (dddd)'); row[2] = Date.parse(row[2]).toString('MMM d, yyyy (dddd)'); return row; } }, { key: "renderForm", value: function renderForm(object) { var formHtml = this.templates.formTemplate; var html = ''; $("#".concat(this.getTableName(), "Form")).html(formHtml); $("#".concat(this.getTableName(), "Form")).show(); $("#".concat(this.getTableName())).hide(); $('#attendnacesheet_start').html(Date.parse(object.date_start).toString('MMM d, yyyy (dddd)')); $('#attendnacesheet_end').html(Date.parse(object.date_end).toString('MMM d, yyyy (dddd)')); this.currentTimesheet = object; this.getTimeEntries(); } }, { key: "getTimeEntries", value: function getTimeEntries() { var timesheetId = this.currentId; var sourceMappingJson = JSON.stringify(modJsList.tabEmployeeTimeEntry.getSourceMapping()); var reqJson = JSON.stringify({ id: timesheetId, sm: sourceMappingJson }); var callBackData = []; callBackData.callBackData = []; callBackData.callBackSuccess = 'getTimeEntriesSuccessCallBack'; callBackData.callBackFail = 'getTimeEntriesFailCallBack'; this.customAction('getTimeEntries', 'modules=time_sheets', reqJson, callBackData); } }, { key: "getTimeEntriesSuccessCallBack", value: function getTimeEntriesSuccessCallBack(callBackData) { var entries = callBackData; var html = ''; var temp = '_start__end__duration__project__details_'; for (var i = 0; i < entries.length; i++) { try { var t = temp; t = t.replace(/_start_/g, Date.parse(entries[i].date_start).toString('MMM d, yyyy [hh:mm tt]')); t = t.replace(/_end_/g, Date.parse(entries[i].date_end).toString('MMM d, yyyy [hh:mm tt]')); var mili = Date.parse(entries[i].date_end) - Date.parse(entries[i].date_start); var minutes = Math.round(mili / 60000); var hourMinutes = minutes % 60; var hours = (minutes - hourMinutes) / 60; t = t.replace(/_duration_/g, "Hours (".concat(hours, ") - Min (").concat(hourMinutes, ")")); if (entries[i].project === 'null' || entries[i].project === null || entries[i].project === undefined) { t = t.replace(/_project_/g, 'None'); } else { t = t.replace(/_project_/g, entries[i].project); } t = t.replace(/_project_/g, entries[i].project); t = t.replace(/_details_/g, entries[i].details); t = t.replace(/_id_/g, entries[i].id); t = t.replace(/_BASE_/g, this.baseUrl); html += t; } catch (e) {// DN } } $('.timesheet_entries_table_body').html(html); if (modJs.getTableName() === 'SubEmployeeTimeSheetAll') { $('#submit_sheet').hide(); $('#add_time_sheet_entry').hide(); } else if (this.currentElement.status === 'Approved') { $('#submit_sheet').hide(); $('#add_time_sheet_entry').hide(); } else { $('#submit_sheet').show(); $('#add_time_sheet_entry').show(); } } }, { key: "getTimeEntriesFailCallBack", value: function getTimeEntriesFailCallBack(callBackData) { this.showMessage('Error', 'Error occured while getting timesheet entries'); } }, { key: "createPreviousAttendnacesheet", value: function createPreviousAttendnacesheet(id) { var reqJson = JSON.stringify({ id: id }); var callBackData = []; callBackData.callBackData = []; callBackData.callBackSuccess = 'createPreviousAttendnacesheetSuccessCallBack'; callBackData.callBackFail = 'createPreviousAttendnacesheetFailCallBack'; this.customAction('createPreviousAttendnaceSheet', 'modules=attendnace', reqJson, callBackData); } }, { key: "createPreviousAttendnacesheetSuccessCallBack", value: function createPreviousAttendnacesheetSuccessCallBack(callBackData) { $('.tooltip').css('display', 'none'); $('.tooltip').remove(); // this.showMessage("Success", "Previous Timesheet created"); this.get([]); } }, { key: "createPreviousAttendnacesheetFailCallBack", value: function createPreviousAttendnacesheetFailCallBack(callBackData) { this.showMessage('Error', callBackData); } }, { key: "getActionButtonsHtml", value: function getActionButtonsHtml(id, data) { var html = ''; if (this.getTableName() === 'EmployeeTimeSheetAll') { html = '
    '; } else { html = '
    '; } html = html.replace(/_id_/g, id); html = html.replace(/_BASE_/g, this.baseUrl); return html; } }, { key: "getCustomTableParams", value: function getCustomTableParams() { var that = this; var dataTableParams = { aoColumnDefs: [{ fnRender: function fnRender(data, cell) { return that.preProcessRemoteTableData(data, cell, 1); }, aTargets: [1] }, { fnRender: function fnRender(data, cell) { return that.preProcessRemoteTableData(data, cell, 2); }, aTargets: [2] }, { fnRender: that.getActionButtons, aTargets: [that.getDataMapping().length] }] }; return dataTableParams; } }, { key: "preProcessRemoteTableData", value: function preProcessRemoteTableData(data, cell, id) { return Date.parse(cell).toString('MMM d, yyyy (dddd)'); } }]); return EmployeeAttendanceSheetAdapter; }(_AdapterBase3["default"]); module.exports = { AttendanceAdapter: AttendanceAdapter, EmployeeAttendanceSheetAdapter: EmployeeAttendanceSheetAdapter }; },{"../../../api/AdapterBase":39,"../../../api/FormValidation":44}],67:[function(require,module,exports){ "use strict"; var _lib = require("./lib"); window.DashboardAdapter = _lib.DashboardAdapter; },{"./lib":68}],68:[function(require,module,exports){ "use strict"; var _AdapterBase2 = _interopRequireDefault(require("../../../api/AdapterBase")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(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, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { 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; } 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 { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 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 } }); if (superClass) _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } var DashboardAdapter = /*#__PURE__*/function (_AdapterBase) { _inherits(DashboardAdapter, _AdapterBase); var _super = _createSuper(DashboardAdapter); function DashboardAdapter() { _classCallCheck(this, DashboardAdapter); return _super.apply(this, arguments); } _createClass(DashboardAdapter, [{ key: "getDataMapping", value: function getDataMapping() { return []; } }, { key: "getHeaders", value: function getHeaders() { return []; } }, { key: "getFormFields", value: function getFormFields() { return []; } }, { key: "get", value: function get(callBackData) {} }, { key: "getPunch", value: function getPunch() { var that = this; var object = {}; object.date = this.getClientDate(new Date()).toISOString().slice(0, 19).replace('T', ' '); object.offset = this.getClientGMTOffset(); var reqJson = JSON.stringify(object); var callBackData = []; callBackData.callBackData = []; callBackData.callBackSuccess = 'getPunchSuccessCallBack'; callBackData.callBackFail = 'getPunchFailCallBack'; this.customAction('getPunch', 'modules=attendance', reqJson, callBackData); } }, { key: "getPunchSuccessCallBack", value: function getPunchSuccessCallBack(callBackData) { var punch = callBackData; if (punch == null) { $('#lastPunchTime').html('Not'); $('#punchTimeText').html('Punched In'); } else { $('#lastPunchTime').html(Date.parse(punch.in_time).toString('h:mm tt')); $('#punchTimeText').html('Punched In'); } } }, { key: "getPunchFailCallBack", value: function getPunchFailCallBack(callBackData) {} }, { key: "getInitData", value: function getInitData() { var that = this; var object = {}; var reqJson = JSON.stringify(object); var callBackData = []; callBackData.callBackData = []; callBackData.callBackSuccess = 'getInitDataSuccessCallBack'; callBackData.callBackFail = 'getInitDataFailCallBack'; this.customAction('getInitData', 'modules=dashboard', reqJson, callBackData); } }, { key: "getInitDataSuccessCallBack", value: function getInitDataSuccessCallBack(data) { $('#timeSheetHoursWorked').html(data.lastTimeSheetHours); $('#numberOfProjects').html(data.activeProjects); $('#pendingLeaveCount').html(data.pendingLeaves); $('#numberOfEmployees').html("".concat(data.numberOfEmployees, " Subordinates")); $('#numberOfCandidates').html("".concat(data.numberOfCandidates, " Candidates")); $('#numberOfJobs').html("".concat(data.numberOfJobs, " Active")); $('#numberOfCourses').html("".concat(data.numberOfCourses, " Active")); } }, { key: "getInitDataFailCallBack", value: function getInitDataFailCallBack(callBackData) {} }, { key: "getClientDate", value: function getClientDate(date) { var offset = this.getClientGMTOffset(); var tzDate = date.addMinutes(offset * 60); return tzDate; } }, { key: "getClientGMTOffset", value: function getClientGMTOffset() { var rightNow = new Date(); var jan1 = new Date(rightNow.getFullYear(), 0, 1, 0, 0, 0, 0); var temp = jan1.toGMTString(); var jan2 = new Date(temp.substring(0, temp.lastIndexOf(' ') - 1)); return (jan1 - jan2) / (1000 * 60 * 60); } }]); return DashboardAdapter; }(_AdapterBase2["default"]); module.exports = { DashboardAdapter: DashboardAdapter }; },{"../../../api/AdapterBase":39}],69:[function(require,module,exports){ "use strict"; var _lib = require("./lib"); window.EmployeeDependentAdapter = _lib.EmployeeDependentAdapter; },{"./lib":70}],70:[function(require,module,exports){ "use strict"; var _AdapterBase2 = _interopRequireDefault(require("../../../api/AdapterBase")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(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, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { 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; } 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 { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 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 } }); if (superClass) _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } /** * EmployeeDependentAdapter */ var EmployeeDependentAdapter = /*#__PURE__*/function (_AdapterBase) { _inherits(EmployeeDependentAdapter, _AdapterBase); var _super = _createSuper(EmployeeDependentAdapter); function EmployeeDependentAdapter() { _classCallCheck(this, EmployeeDependentAdapter); return _super.apply(this, arguments); } _createClass(EmployeeDependentAdapter, [{ key: "getDataMapping", value: function getDataMapping() { return ['id', 'name', 'relationship', 'dob', 'id_number']; } }, { key: "getHeaders", value: function getHeaders() { return [{ sTitle: 'ID', bVisible: false }, { sTitle: 'Name' }, { sTitle: 'Relationship' }, { sTitle: 'Date of Birth' }, { sTitle: 'Id Number' }]; } }, { key: "getFormFields", value: function getFormFields() { return [['id', { label: 'ID', type: 'hidden' }], ['name', { label: 'Name', type: 'text', validation: '' }], ['relationship', { label: 'Relationship', type: 'select', source: [['Child', 'Child'], ['Spouse', 'Spouse'], ['Parent', 'Parent'], ['Other', 'Other']] }], ['dob', { label: 'Date of Birth', type: 'date', validation: '' }], ['id_number', { label: 'Id Number', type: 'text', validation: 'none' }]]; } }]); return EmployeeDependentAdapter; }(_AdapterBase2["default"]); module.exports = { EmployeeDependentAdapter: EmployeeDependentAdapter }; },{"../../../api/AdapterBase":39}],71:[function(require,module,exports){ "use strict"; var _lib = require("./lib"); window.EmployeeDocumentAdapter = _lib.EmployeeDocumentAdapter; window.EmployeeCompanyDocumentAdapter = _lib.EmployeeCompanyDocumentAdapter; },{"./lib":72}],72:[function(require,module,exports){ "use strict"; var _AdapterBase2 = _interopRequireDefault(require("../../../api/AdapterBase")); var _ObjectAdapter2 = _interopRequireDefault(require("../../../api/ObjectAdapter")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(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, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { 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; } 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 { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 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 } }); if (superClass) _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } var EmployeeDocumentAdapter = /*#__PURE__*/function (_AdapterBase) { _inherits(EmployeeDocumentAdapter, _AdapterBase); var _super = _createSuper(EmployeeDocumentAdapter); function EmployeeDocumentAdapter() { _classCallCheck(this, EmployeeDocumentAdapter); return _super.apply(this, arguments); } _createClass(EmployeeDocumentAdapter, [{ key: "getDataMapping", value: function getDataMapping() { return ['id', 'document', 'details', 'date_added', 'status', 'attachment']; } }, { key: "getHeaders", value: function getHeaders() { return [{ sTitle: 'ID', bVisible: false }, { sTitle: 'Document' }, { sTitle: 'Details' }, { sTitle: 'Date Added' }, { sTitle: 'Status' }, { sTitle: 'Attachment', bVisible: false }]; } }, { key: "getFormFields", value: function getFormFields() { return [['id', { label: 'ID', type: 'hidden' }], ['document', { label: 'Document', type: 'select2', 'remote-source': ['Document', 'id', 'name', 'getDocumentTypesForUser'] }], // [ "date_added", {"label":"Date Added","type":"date","validation":""}], ['valid_until', { label: 'Valid Until', type: 'date', validation: 'none' }], ['status', { label: 'Status', type: 'select', source: [['Active', 'Active'], ['Inactive', 'Inactive'], ['Draft', 'Draft']] }], ['details', { label: 'Details', type: 'textarea', validation: 'none' }], ['attachment', { label: 'Attachment', type: 'fileupload', validation: '' }]]; } }, { key: "getActionButtonsHtml", value: function getActionButtonsHtml(id, data) { var downloadButton = ''; var editButton = ''; var deleteButton = ''; var html = '
    _edit__download__delete_
    '; html = html.replace('_download_', downloadButton); if (this.showDelete) { html = html.replace('_delete_', deleteButton); } else { html = html.replace('_delete_', ''); } if (this.showEdit) { html = html.replace('_edit_', editButton); } else { html = html.replace('_edit_', ''); } html = html.replace(/_id_/g, id); html = html.replace(/_attachment_/g, data[5]); html = html.replace(/_BASE_/g, this.baseUrl); return html; } }]); return EmployeeDocumentAdapter; }(_AdapterBase2["default"]); /** * EmployeeCompanyDocumentAdapter */ var EmployeeCompanyDocumentAdapter = /*#__PURE__*/function (_ObjectAdapter) { _inherits(EmployeeCompanyDocumentAdapter, _ObjectAdapter); var _super2 = _createSuper(EmployeeCompanyDocumentAdapter); function EmployeeCompanyDocumentAdapter() { _classCallCheck(this, EmployeeCompanyDocumentAdapter); return _super2.apply(this, arguments); } _createClass(EmployeeCompanyDocumentAdapter, [{ key: "getDataMapping", value: function getDataMapping() { return ['id', 'name', 'details']; } }, { key: "getHeaders", value: function getHeaders() { return [{ sTitle: 'ID', bVisible: false }, { sTitle: 'Name' }, { sTitle: 'Details' }]; } }, { key: "getFormFields", value: function getFormFields() { return [['id', { label: 'ID', type: 'hidden' }], ['name', { label: 'Name', type: 'placeholder', validation: '' }], ['details', { label: 'Details', type: 'placeholder', validation: 'none' }], ['attachment', { label: 'Attachment', type: 'placeholder', validation: 'none' }]]; } }, { key: "addDomEvents", value: function addDomEvents(object) {} }, { key: "getTemplateName", value: function getTemplateName() { return 'file.html'; } }, { key: "preProcessTableData", value: function preProcessTableData(row) { row.color = this.getColorByFileType(row.type); row.icon = this.getIconByFileType(row.type); row.details_long = this.nl2br(row.details); if (row.details.length > 30) { row.details = row.details.substring(0, 30); } if (row.size === undefined || row.size == null) { row.size = ''; } return row; } }]); return EmployeeCompanyDocumentAdapter; }(_ObjectAdapter2["default"]); module.exports = { EmployeeDocumentAdapter: EmployeeDocumentAdapter, EmployeeCompanyDocumentAdapter: EmployeeCompanyDocumentAdapter }; },{"../../../api/AdapterBase":39,"../../../api/ObjectAdapter":49}],73:[function(require,module,exports){ "use strict"; var _lib = require("./lib"); window.EmergencyContactAdapter = _lib.EmergencyContactAdapter; },{"./lib":74}],74:[function(require,module,exports){ "use strict"; var _AdapterBase2 = _interopRequireDefault(require("../../../api/AdapterBase")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(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, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { 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; } 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 { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 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 } }); if (superClass) _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } var EmergencyContactAdapter = /*#__PURE__*/function (_AdapterBase) { _inherits(EmergencyContactAdapter, _AdapterBase); var _super = _createSuper(EmergencyContactAdapter); function EmergencyContactAdapter() { _classCallCheck(this, EmergencyContactAdapter); return _super.apply(this, arguments); } _createClass(EmergencyContactAdapter, [{ key: "getDataMapping", value: function getDataMapping() { return ['id', 'name', 'relationship', 'home_phone', 'work_phone', 'mobile_phone']; } }, { key: "getHeaders", value: function getHeaders() { return [{ sTitle: 'ID', bVisible: false }, { sTitle: 'Name' }, { sTitle: 'Relationship' }, { sTitle: 'Home Phone' }, { sTitle: 'Work Phone' }, { sTitle: 'Mobile Phone' }]; } }, { key: "getFormFields", value: function getFormFields() { return [['id', { label: 'ID', type: 'hidden' }], ['name', { label: 'Name', type: 'text', validation: '' }], ['relationship', { label: 'Relationship', type: 'text', validation: 'none' }], ['home_phone', { label: 'Home Phone', type: 'text', validation: 'none' }], ['work_phone', { label: 'Work Phone', type: 'text', validation: 'none' }], ['mobile_phone', { label: 'Mobile Phone', type: 'text', validation: 'none' }]]; } }]); return EmergencyContactAdapter; }(_AdapterBase2["default"]); module.exports = { EmergencyContactAdapter: EmergencyContactAdapter }; },{"../../../api/AdapterBase":39}],75:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; var _react = _interopRequireDefault(require("react")); var _antd = require("antd"); var _icons = require("@ant-design/icons"); var _TagList = _interopRequireDefault(require("../../../../components/TagList")); var _UpdatePasswordModal = _interopRequireDefault(require("../../../../components/UpdatePasswordModal")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(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, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { 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; } 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 { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 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 } }); if (superClass) _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } var Title = _antd.Typography.Title, Text = _antd.Typography.Text; var TabPane = _antd.Tabs.TabPane; var EmployeeProfile = /*#__PURE__*/function (_React$Component) { _inherits(EmployeeProfile, _React$Component); var _super = _createSuper(EmployeeProfile); function EmployeeProfile(props) { var _this; _classCallCheck(this, EmployeeProfile); _this = _super.call(this, props); _this.state = { loading: true, showPasswordResetModal: false }; return _this; } _createClass(EmployeeProfile, [{ key: "setLoading", value: function setLoading(value) { this.setState({ loading: value }); } }, { key: "setShowPasswordUpdate", value: function setShowPasswordUpdate(value) { this.setState({ showPasswordResetModal: value }); } }, { key: "updateProfileImage", value: function updateProfileImage() { showUploadDialog("profile_image_".concat(this.props.element.id, "_").concat(new Date().getTime()), 'Upload Profile Image', 'profile_image', this.props.element.id, "profile_image_".concat(this.props.element.id), 'function', 'reloadCurrentElement', 'image'); } }, { key: "getEditButtonJsx", value: function getEditButtonJsx() { var _this2 = this; return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, this.state.loading && /*#__PURE__*/_react["default"].createElement(_antd.Tag, { icon: /*#__PURE__*/_react["default"].createElement(_icons.SyncOutlined, { spin: true }), color: "processing" }, this.props.adapter.gt('Edit')), !this.state.loading && /*#__PURE__*/_react["default"].createElement(_antd.Tag, { icon: /*#__PURE__*/_react["default"].createElement(_icons.EditOutlined, null), color: "processing", onClick: function onClick() { return modJs.edit(_this2.props.element.id); } }, this.props.adapter.gt('Edit'))); } }, { key: "getEditButtonJsxWithPassword", value: function getEditButtonJsxWithPassword() { var _this3 = this; return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, this.state.loading && /*#__PURE__*/_react["default"].createElement(_antd.Tag, { icon: /*#__PURE__*/_react["default"].createElement(_icons.SyncOutlined, { spin: true }), color: "processing" }, this.props.adapter.gt('Edit')), !this.state.loading && /*#__PURE__*/_react["default"].createElement(_antd.Tag, { icon: /*#__PURE__*/_react["default"].createElement(_icons.EditOutlined, null), color: "processing", onClick: function onClick() { return modJs.edit(_this3.props.element.id); } }, this.props.adapter.gt('Edit')), /*#__PURE__*/_react["default"].createElement(_antd.Tag, { icon: /*#__PURE__*/_react["default"].createElement(_icons.LockOutlined, null), color: "volcano", onClick: function onClick() { return _this3.setShowPasswordUpdate(true); } }, this.props.adapter.gt('Update Password'))); } }, { key: "getUpdatePasswordButtonJsx", value: function getUpdatePasswordButtonJsx() { return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_antd.Tag, { icon: /*#__PURE__*/_react["default"].createElement(_icons.SyncOutlined, { spin: true }), color: "processing" }, this.props.adapter.gt('Update Password'))); } }, { key: "getTabViewEmployeeFilterButtonJsx", value: function getTabViewEmployeeFilterButtonJsx(tab) { var _this4 = this; return /*#__PURE__*/_react["default"].createElement(_antd.Tag, { icon: /*#__PURE__*/_react["default"].createElement(_icons.EditOutlined, null), color: "processing", onClick: function onClick() { switchTab(tab, { employee: _this4.props.element.id }); } }, this.props.adapter.gt('Edit')); } }, { key: "render", value: function render() { var _this5 = this; if (this.state.loading || !this.props.element) { return /*#__PURE__*/_react["default"].createElement("div", { style: { padding: '20px' } }, /*#__PURE__*/_react["default"].createElement(_antd.Skeleton, { active: true })); } return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_UpdatePasswordModal["default"], { visible: this.state.showPasswordResetModal, closeModal: function closeModal() { _this5.setState({ showPasswordResetModal: false }); }, adapter: this.props.adapter }), /*#__PURE__*/_react["default"].createElement(_antd.Row, { direction: "vertical", style: { width: '100%', padding: '10px' }, gutter: 24 }, /*#__PURE__*/_react["default"].createElement(_antd.Col, { span: 24 }, /*#__PURE__*/_react["default"].createElement(_antd.Card, { title: this.props.adapter.gt('Employee Profile'), extra: this.getEditButtonJsxWithPassword(), style: { width: '100%' } }, /*#__PURE__*/_react["default"].createElement(_antd.Space, { size: 'large' }, /*#__PURE__*/_react["default"].createElement(_antd.Avatar, { size: 140, src: this.props.element.image, onClick: function onClick() { return _this5.updateProfileImage(); } }), /*#__PURE__*/_react["default"].createElement(_antd.Space, { direction: 'vertical' }, /*#__PURE__*/_react["default"].createElement(Title, { level: 4 }, "".concat(this.props.element.first_name, " ").concat(this.props.element.last_name)), /*#__PURE__*/_react["default"].createElement(_antd.Space, null, /*#__PURE__*/_react["default"].createElement(_icons.PhoneTwoTone, null), /*#__PURE__*/_react["default"].createElement(Text, { copyable: true }, " ".concat(this.props.element.mobile_phone || ''))), /*#__PURE__*/_react["default"].createElement(_antd.Space, null, /*#__PURE__*/_react["default"].createElement(_icons.MailTwoTone, null), /*#__PURE__*/_react["default"].createElement(Text, { copyable: true }, " ".concat(this.props.element.work_email || '')))), /*#__PURE__*/_react["default"].createElement(_antd.Descriptions, { title: "", bordered: true, style: { width: '100%', padding: '10px' } }, /*#__PURE__*/_react["default"].createElement(_antd.Descriptions.Item, { label: this.props.adapter.gt('Employee Number'), span: 3 }, this.props.element.employee_id), /*#__PURE__*/_react["default"].createElement(_antd.Descriptions.Item, { label: this.props.adapter.gt('ID Number'), span: 3 }, this.props.element.nic_num), this.props.element.ssn_num && this.props.element.ssn_num !== '' && /*#__PURE__*/_react["default"].createElement(_antd.Descriptions.Item, { label: this.props.adapter.gt('Social Security Number'), span: 3 }, this.props.element.ssn_num)))))), /*#__PURE__*/_react["default"].createElement(_antd.Row, { direction: "vertical", style: { width: '100%', padding: '10px' }, gutter: 24 }, /*#__PURE__*/_react["default"].createElement(_antd.Tabs, { type: "card", style: { width: '100%' } }, /*#__PURE__*/_react["default"].createElement(TabPane, { tab: "Basic Information", key: "1", style: { width: '100%' } }, /*#__PURE__*/_react["default"].createElement(_antd.Row, { direction: "vertical", style: { width: '100%', padding: '10px' }, gutter: 24 }, /*#__PURE__*/_react["default"].createElement(_antd.Col, { span: 24 }, /*#__PURE__*/_react["default"].createElement(_antd.Card, { title: this.props.adapter.gt('Personal Information'), extra: this.getEditButtonJsx(), style: { width: '100%' } }, /*#__PURE__*/_react["default"].createElement(_antd.Descriptions, { title: "", bordered: true }, /*#__PURE__*/_react["default"].createElement(_antd.Descriptions.Item, { label: this.props.adapter.gt('Date of Birth') }, this.props.element.birthday || ''), /*#__PURE__*/_react["default"].createElement(_antd.Descriptions.Item, { label: this.props.adapter.gt('Gender') }, this.props.element.gender), /*#__PURE__*/_react["default"].createElement(_antd.Descriptions.Item, { label: this.props.adapter.gt('Nationality') }, this.props.element.nationality_Name), /*#__PURE__*/_react["default"].createElement(_antd.Descriptions.Item, { label: this.props.adapter.gt('Marital Status') }, this.props.element.marital_status), /*#__PURE__*/_react["default"].createElement(_antd.Descriptions.Item, { label: this.props.adapter.gt('Joined Date') }, this.props.element.joined_date), /*#__PURE__*/_react["default"].createElement(_antd.Descriptions.Item, { label: this.props.adapter.gt('Driving License No') }, this.props.element.driving_license || ''), /*#__PURE__*/_react["default"].createElement(_antd.Descriptions.Item, { label: this.props.adapter.gt('Other ID') }, this.props.element.other_id || '')))), /*#__PURE__*/_react["default"].createElement(_antd.Col, { span: 24 }, /*#__PURE__*/_react["default"].createElement(_antd.Card, { title: this.props.adapter.gt('Contact Information'), extra: this.getEditButtonJsx(), style: { width: '100%' } }, /*#__PURE__*/_react["default"].createElement(_antd.Descriptions, { title: "", bordered: true }, /*#__PURE__*/_react["default"].createElement(_antd.Descriptions.Item, { label: this.props.adapter.gt('Address'), span: 3 }, "".concat(this.props.element.address1, ", ").concat(this.props.element.address2 || '')), /*#__PURE__*/_react["default"].createElement(_antd.Descriptions.Item, { label: this.props.adapter.gt('City') }, this.props.element.city), /*#__PURE__*/_react["default"].createElement(_antd.Descriptions.Item, { label: this.props.adapter.gt('Country') }, this.props.element.country_Name), /*#__PURE__*/_react["default"].createElement(_antd.Descriptions.Item, { label: this.props.adapter.gt('Postal/Zip Code') }, this.props.element.postal_code), /*#__PURE__*/_react["default"].createElement(_antd.Descriptions.Item, { label: this.props.adapter.gt('Home Phone'), span: 2 }, /*#__PURE__*/_react["default"].createElement(_antd.Space, null, /*#__PURE__*/_react["default"].createElement(_icons.PhoneTwoTone, null), /*#__PURE__*/_react["default"].createElement(Text, { copyable: true }, " ".concat(this.props.element.home_phone || '')))), /*#__PURE__*/_react["default"].createElement(_antd.Descriptions.Item, { label: this.props.adapter.gt('Work Phone'), span: 2 }, /*#__PURE__*/_react["default"].createElement(_antd.Space, null, /*#__PURE__*/_react["default"].createElement(_icons.PhoneTwoTone, null), /*#__PURE__*/_react["default"].createElement(Text, { copyable: true }, " ".concat(this.props.element.work_phone || '')))), /*#__PURE__*/_react["default"].createElement(_antd.Descriptions.Item, { label: this.props.adapter.gt('Private Email'), span: 2 }, /*#__PURE__*/_react["default"].createElement(_antd.Space, null, /*#__PURE__*/_react["default"].createElement(_icons.MailTwoTone, null), /*#__PURE__*/_react["default"].createElement(Text, { copyable: true }, " ".concat(this.props.element.private_email || ''))))))), /*#__PURE__*/_react["default"].createElement(_antd.Col, { span: 24 }, /*#__PURE__*/_react["default"].createElement(_antd.Card, { title: this.props.adapter.gt('Job Details'), extra: this.getEditButtonJsx(), style: { width: '100%' } }, /*#__PURE__*/_react["default"].createElement(_antd.Descriptions, { title: "", bordered: true }, /*#__PURE__*/_react["default"].createElement(_antd.Descriptions.Item, { label: this.props.adapter.gt('Job Title'), span: 2 }, this.props.element.job_title_Name), /*#__PURE__*/_react["default"].createElement(_antd.Descriptions.Item, { label: this.props.adapter.gt('Employment Status') }, this.props.element.employment_status_Name), /*#__PURE__*/_react["default"].createElement(_antd.Descriptions.Item, { label: this.props.adapter.gt('Department') }, this.props.element.department_Name), /*#__PURE__*/_react["default"].createElement(_antd.Descriptions.Item, { label: this.props.adapter.gt('Supervisor') }, this.props.element.supervisor_Name)))))), /*#__PURE__*/_react["default"].createElement(TabPane, { tab: this.props.adapter.gt('Qualifications'), key: "2", style: { width: '100%' } }, /*#__PURE__*/_react["default"].createElement(_antd.Row, { style: { width: '100%', padding: '10px' }, gutter: 24 }, /*#__PURE__*/_react["default"].createElement(_antd.Col, { span: 6 }, /*#__PURE__*/_react["default"].createElement(_antd.Card, { title: this.props.adapter.gt('Skills') // extra={this.getTabViewEmployeeFilterButtonJsx('tabEmployeeSkill')} , style: { width: '100%' } }, /*#__PURE__*/_react["default"].createElement(_TagList["default"], { color: "geekblue", apiClient: this.props.adapter.apiClient, url: "employees/".concat(this.props.element.id, "/skills"), extractTag: function extractTag(item) { return item.skill_id.display; } }))), /*#__PURE__*/_react["default"].createElement(_antd.Col, { span: 6 }, /*#__PURE__*/_react["default"].createElement(_antd.Card, { title: this.props.adapter.gt('Education') // extra={this.getTabViewEmployeeFilterButtonJsx('tabEmployeeEducation')} , style: { width: '100%' } }, /*#__PURE__*/_react["default"].createElement(_TagList["default"], { color: "cyan", apiClient: this.props.adapter.apiClient, url: "employees/".concat(this.props.element.id, "/educations"), extractTag: function extractTag(item) { return item.education_id.display; } }))), /*#__PURE__*/_react["default"].createElement(_antd.Col, { span: 6 }, /*#__PURE__*/_react["default"].createElement(_antd.Card, { title: this.props.adapter.gt('Certifications') // extra={this.getTabViewEmployeeFilterButtonJsx('tabEmployeeCertification')} , style: { width: '100%' } }, /*#__PURE__*/_react["default"].createElement(_TagList["default"], { color: "volcano", apiClient: this.props.adapter.apiClient, url: "employees/".concat(this.props.element.id, "/certifications"), extractTag: function extractTag(item) { return item.certification_id.display; } }))), /*#__PURE__*/_react["default"].createElement(_antd.Col, { span: 6 }, /*#__PURE__*/_react["default"].createElement(_antd.Card, { title: this.props.adapter.gt('Languages') // extra={this.getTabViewEmployeeFilterButtonJsx('tabEmployeeLanguage')} , style: { width: '100%' } }, /*#__PURE__*/_react["default"].createElement(_TagList["default"], { color: "orange", apiClient: this.props.adapter.apiClient, url: "employees/".concat(this.props.element.id, "/languages"), extractTag: function extractTag(item) { return item.language_id.display; } })))))))); } }]); return EmployeeProfile; }(_react["default"].Component); var _default = EmployeeProfile; exports["default"] = _default; },{"../../../../components/TagList":63,"../../../../components/UpdatePasswordModal":64,"@ant-design/icons":"@ant-design/icons","antd":"antd","react":"react"}],76:[function(require,module,exports){ "use strict"; var _lib = require("./lib"); window.EmployeeAdapter = _lib.EmployeeAdapter; window.CompanyGraphAdapter = _lib.CompanyGraphAdapter; window.ApiAccessAdapter = _lib.ApiAccessAdapter; },{"./lib":77}],77:[function(require,module,exports){ "use strict"; var _react = _interopRequireDefault(require("react")); var _reactDom = _interopRequireDefault(require("react-dom")); var _qrcode = _interopRequireDefault(require("qrcode")); var _AdapterBase3 = _interopRequireDefault(require("../../../api/AdapterBase")); var _ReactModalAdapterBase = _interopRequireDefault(require("../../../api/ReactModalAdapterBase")); var _EmployeeProfile = _interopRequireDefault(require("./components/EmployeeProfile")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 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(n); 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(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } 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, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { 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; } 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 { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 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 } }); if (superClass) _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } var EmployeeAdapter = /*#__PURE__*/function (_ReactModalAdapterBas) { _inherits(EmployeeAdapter, _ReactModalAdapterBas); var _super = _createSuper(EmployeeAdapter); function EmployeeAdapter(endPoint, tab, filter, orderBy) { var _this; _classCallCheck(this, EmployeeAdapter); _this = _super.call(this, endPoint, tab, filter, orderBy); _this.fieldNameMap = {}; _this.hiddenFields = {}; _this.tableFields = {}; _this.formOnlyFields = {}; _this.currentUserId = null; return _this; } _createClass(EmployeeAdapter, [{ key: "setFieldNameMap", value: function setFieldNameMap(fields) { var field; for (var i = 0; i < fields.length; i++) { field = fields[i]; this.fieldNameMap[field.name] = field; if (field.display === 'Hidden') { this.hiddenFields[field.name] = field; } else if (field.display === 'Table and Form') { this.tableFields[field.name] = field; } else { this.formOnlyFields[field.name] = field; } } } }, { key: "getDataMapping", value: function getDataMapping() { return ['id', 'employee_id', 'first_name', 'last_name', 'mobile_phone', 'department', 'gender', 'supervisor']; } }, { key: "getHeaders", value: function getHeaders() { return [{ sTitle: 'ID' }, { sTitle: 'Employee Number' }, { sTitle: 'First Name' }, { sTitle: 'Last Name' }, { sTitle: 'Mobile' }, { sTitle: 'Department' }, { sTitle: 'Gender' }, { sTitle: 'Supervisor' }]; } }, { key: "initTable", value: function initTable() { this.initProfile(); } }, { key: "initProfile", value: function initProfile(employee) { var tableDom = document.getElementById("".concat(this.tab)); this.tableContainer = _react["default"].createRef(); _reactDom["default"].render( /*#__PURE__*/_react["default"].createElement(_EmployeeProfile["default"], { ref: this.tableContainer, adapter: this, element: employee }), tableDom); this.tableContainer.current.setLoading(!employee); } }, { key: "get", value: function get() { var _this2 = this; this.initTable(); this.masterDataReader.updateAllMasterData().then(function () { _this2.viewElement(); }); this.trackEvent('get', this.tab, this.table); } }, { key: "edit", value: function edit(id) { this.setTableLoading(true); this.currentId = id; this.getElement(id, []); } }, { key: "getFormOptions", value: function getFormOptions() { return { width: 1024, twoColumnLayout: false }; } }, { key: "getFormFields", value: function getFormFields() { var newFields = []; var employee_id; var ssn_num; var employment_status; var job_title; var pay_grade; var joined_date; var department; var work_email; var country; if (this.checkPermission('Edit Employee Number') === 'Yes') { employee_id = ['employee_id', { label: 'Employee Number', type: 'text', validation: '' }]; } else { employee_id = ['employee_id', { label: 'Employee Number', type: 'placeholder', validation: '' }]; } if (this.checkPermission('Edit EPF/CPF Number') === 'Yes') { ssn_num = ['ssn_num', { label: 'EPF/CPF/SS No', type: 'text', validation: 'none' }]; } else { ssn_num = ['ssn_num', { label: 'EPF/CPF/SS No', type: 'placeholder', validation: 'none' }]; } if (this.checkPermission('Edit Employment Status') === 'Yes') { employment_status = ['employment_status', { label: 'Employment Status', type: 'select2', 'remote-source': ['EmploymentStatus', 'id', 'name'] }]; } else { employment_status = ['employment_status', { label: 'Employment Status', type: 'placeholder', 'remote-source': ['EmploymentStatus', 'id', 'name'] }]; } if (this.checkPermission('Edit Job Title') === 'Yes') { job_title = ['job_title', { label: 'Job Title', type: 'select2', 'remote-source': ['JobTitle', 'id', 'name'] }]; } else { job_title = ['job_title', { label: 'Job Title', type: 'placeholder', 'remote-source': ['JobTitle', 'id', 'name'] }]; } if (this.checkPermission('Edit Pay Grade') === 'Yes') { pay_grade = ['pay_grade', { label: 'Pay Grade', type: 'select2', 'allow-null': true, 'remote-source': ['PayGrade', 'id', 'name'] }]; } else { pay_grade = ['pay_grade', { label: 'Pay Grade', type: 'placeholder', 'allow-null': true, 'remote-source': ['PayGrade', 'id', 'name'] }]; } if (this.checkPermission('Edit Joined Date') === 'Yes') { joined_date = ['joined_date', { label: 'Joined Date', type: 'date', validation: '' }]; } else { joined_date = ['joined_date', { label: 'Joined Date', type: 'placeholder', validation: '' }]; } if (this.checkPermission('Edit Department') === 'Yes') { department = ['department', { label: 'Department', type: 'select2', 'remote-source': ['CompanyStructure', 'id', 'title'] }]; } else { department = ['department', { label: 'Department', type: 'placeholder', 'remote-source': ['CompanyStructure', 'id', 'title'] }]; } if (this.checkPermission('Edit Work Email') === 'Yes') { work_email = ['work_email', { label: 'Work Email', type: 'text', validation: 'email' }]; } else { work_email = ['work_email', { label: 'Work Email', type: 'placeholder', validation: 'emailOrEmpty' }]; } if (this.checkPermission('Edit Country') === 'Yes') { country = ['country', { label: 'Country', type: 'select2', 'remote-source': ['Country', 'code', 'name'] }]; } else { country = ['country', { label: 'Country', type: 'placeholder', 'remote-source': ['Country', 'code', 'name'] }]; } var fields = [['id', { label: 'ID', type: 'hidden', validation: '' }], employee_id, ['first_name', { label: 'First Name', type: 'text', validation: '' }], ['middle_name', { label: 'Middle Name', type: 'text', validation: 'none' }], ['last_name', { label: 'Last Name', type: 'text', validation: '' }], ['nationality', { label: 'Nationality', type: 'select2', 'remote-source': ['Nationality', 'id', 'name'] }], ['birthday', { label: 'Date of Birth', type: 'date', validation: '' }], ['gender', { label: 'Gender', type: 'select', source: [['Male', 'Male'], ['Female', 'Female'], ['Other', 'Other']] }], ['marital_status', { label: 'Marital Status', type: 'select', source: [['Married', 'Married'], ['Single', 'Single'], ['Divorced', 'Divorced'], ['Widowed', 'Widowed'], ['Other', 'Other']] }], ssn_num, ['nic_num', { label: 'NIC', type: 'text', validation: 'none' }], ['other_id', { label: 'Other ID', type: 'text', validation: 'none' }], ['driving_license', { label: 'Driving License No', type: 'text', validation: 'none' }], employment_status, job_title, pay_grade, ['work_station_id', { label: 'Work Station Id', type: 'text', validation: 'none' }], ['address1', { label: 'Address Line 1', type: 'text', validation: 'none' }], ['address2', { label: 'Address Line 2', type: 'text', validation: 'none' }], ['city', { label: 'City', type: 'text', validation: 'none' }], country, ['province', { label: 'Province', type: 'select2', 'allow-null': true, 'remote-source': ['Province', 'id', 'name'] }], ['postal_code', { label: 'Postal/Zip Code', type: 'text', validation: 'none' }], ['home_phone', { label: 'Home Phone', type: 'text', validation: 'none' }], ['mobile_phone', { label: 'Mobile Phone', type: 'text', validation: 'none' }], ['work_phone', { label: 'Work Phone', type: 'text', validation: 'none' }], work_email, ['private_email', { label: 'Private Email', type: 'text', validation: 'emailOrEmpty' }], joined_date, department]; for (var i = 0; i < this.customFields.length; i++) { fields.push(this.customFields[i]); } for (var _i = 0; _i < fields.length; _i++) { var tempField = fields[_i]; if (this.hiddenFields[tempField[0]] === undefined || this.hiddenFields[tempField[0]] === null) { if (this.fieldNameMap[tempField[0]] !== undefined && this.fieldNameMap[tempField[0]] !== null) { var title = this.fieldNameMap[tempField[0]].textMapped; tempField[1].label = title; } newFields.push(tempField); } } return newFields; } }, { key: "getMappedFields", value: function getMappedFields() { var fields = this.getFormFields(); var steps = [{ title: this.gt('Personal'), description: this.gt('Personal Information'), fields: ['id', 'employee_id', 'first_name', 'middle_name', 'last_name', 'nationality', 'birthday', 'gender', 'marital_status', 'ethnicity'] }, { title: this.gt('Identification'), description: this.gt('Personal Information'), fields: ['immigration_status', 'ssn_num', 'nic_num', 'other_id', 'driving_license'] }, { title: this.gt('Work'), description: this.gt('Work related details'), fields: ['employment_status', 'department', 'job_title', 'pay_grade', 'joined_date', 'confirmation_date', 'termination_date', 'work_station_id'] }, { title: this.gt('Contact'), description: this.gt('Contact details'), fields: ['address1', 'address2', 'city', 'country', 'province', 'postal_code', 'home_phone', 'mobile_phone', 'work_phone', 'work_email', 'private_email'] }]; if (this.customFields.length > 0) { steps.push({ title: this.gt('Other'), description: this.gt('Additional details'), fields: this.customFields.map(function (item) { return item[0]; }) }); } return this.addActualFields(steps, fields); } }, { key: "addActualFields", value: function addActualFields(steps, fields) { return steps.map(function (item) { item.fields = item.fields.reduce(function (acc, fieldName) { var field = fields.find(function (_ref) { var _ref2 = _slicedToArray(_ref, 1), name = _ref2[0]; return name === fieldName; }); if (field) { acc.push(field); } return acc; }, []); return item; }); } }, { key: "getSourceMapping", value: function getSourceMapping() { var k = this.sourceMapping; k.supervisor = ['Employee', 'id', 'first_name+last_name']; return k; } }, { key: "viewElement", value: function viewElement(id) { var sourceMappingJson = JSON.stringify(this.getSourceMapping()); var req = { map: sourceMappingJson }; var reqJson = JSON.stringify(req); var callBackData = []; callBackData.callBackData = []; callBackData.callBackSuccess = 'modEmployeeGetSuccessCallBack'; callBackData.callBackFail = 'modEmployeeGetFailCallBack'; this.customAction('get', 'modules=employees', reqJson, callBackData); } }, { key: "deleteProfileImage", value: function deleteProfileImage(empId) { var req = { id: empId }; var reqJson = JSON.stringify(req); var callBackData = []; callBackData.callBackData = []; callBackData.callBackSuccess = 'modEmployeeDeleteProfileImageCallBack'; callBackData.callBackFail = 'modEmployeeDeleteProfileImageCallBack'; this.customAction('deleteProfileImage', 'modules=employees', reqJson, callBackData); } }, { key: "modEmployeeDeleteProfileImageCallBack", value: function modEmployeeDeleteProfileImageCallBack(data) { // eslint-disable-next-line no-restricted-globals top.location.href = top.location.href; } }, { key: "modEmployeeGetSuccessCallBack", value: function modEmployeeGetSuccessCallBack(data) { var currentEmpId = data[1]; var userEmpId = data[2]; var _data = _slicedToArray(data, 1), element = _data[0]; this.initProfile(element); } }, { key: "modEmployeeGetSuccessCallBack1", value: function modEmployeeGetSuccessCallBack1(data) { var fields = this.getFormFields(); var currentEmpId = data[1]; var userEmpId = data[2]; var _data2 = data; var _data3 = _slicedToArray(_data2, 1); data = _data3[0]; var html = this.getCustomTemplate('myDetails.html'); for (var i = 0; i < fields.length; i++) { if (this.fieldNameMap[fields[i][0]] !== undefined && this.fieldNameMap[fields[i][0]] !== null) { var title = this.fieldNameMap[fields[i][0]].textMapped; html = html.replace("#_label_".concat(fields[i][0], "_#"), this.gt(title)); } } html = html.replace(/#_.+_#/gi, ''); html = html.replace(/_id_/g, data.id); $("#".concat(this.getTableName())).html(html); for (var _i2 = 0; _i2 < fields.length; _i2++) { $("#".concat(this.getTableName(), " #").concat(fields[_i2][0])).html(data[fields[_i2][0]]); $("#".concat(this.getTableName(), " #").concat(fields[_i2][0], "_Name")).html(data["".concat(fields[_i2][0], "_Name")]); } $("#".concat(this.getTableName(), " #supervisor_Name")).html(data.supervisor_Name); var subordinates = ''; for (var _i3 = 0; _i3 < data.subordinates.length; _i3++) { if (data.subordinates[_i3].first_name !== undefined && data.subordinates[_i3].first_name !== null) { subordinates += "".concat(data.subordinates[_i3].first_name, " "); } if (data.subordinates[_i3].middle_name !== undefined && data.subordinates[_i3].middle_name !== null && data.subordinates[_i3].middle_name !== '') { subordinates += "".concat(data.subordinates[_i3].middle_name, " "); } if (data.subordinates[_i3].last_name !== undefined && data.subordinates[_i3].last_name !== null && data.subordinates[_i3].last_name !== '') { subordinates += data.subordinates[_i3].last_name; } subordinates += '
    '; } // Add custom fields if (data.customFields !== undefined && data.customFields !== null && Object.keys(data.customFields).length > 0) { var ct = '
    '; var sectionTemplate = '

    #_section.name_#

    '; var customFieldHtml; for (var index in data.customFields) { if (!data.customFields[index][1]) { data.customFields[index][1] = this.gt('Other Details'); } var sectionId = data.customFields[index][1].toLocaleLowerCase(); sectionId = sectionId.replace(' ', '_'); if ($("#cont_".concat(sectionId)).length <= 0) { // Add section var sectionHtml = sectionTemplate; sectionHtml = sectionHtml.replace('#_section_#', sectionId); sectionHtml = sectionHtml.replace('#_section.name_#', data.customFields[index][1]); $('#customFieldsCont').append($(sectionHtml)); } customFieldHtml = ct; customFieldHtml = customFieldHtml.replace('#_label_#', index); if (data.customFields[index][2] === 'fileupload') { customFieldHtml = customFieldHtml.replace('#_value_#', "")); } else { customFieldHtml = customFieldHtml.replace('#_value_#', data.customFields[index][0]); } $("#cont_".concat(sectionId)).append($(customFieldHtml)); } } else { $('#customFieldsCont').remove(); } $("#".concat(this.getTableName(), " #subordinates")).html(subordinates); $("#".concat(this.getTableName(), " #name")).html("".concat(data.first_name, " ").concat(data.last_name)); this.currentUserId = data.id; $("#".concat(this.getTableName(), " #profile_image_").concat(data.id)).attr('src', data.image); if (this.checkPermission('Upload/Delete Profile Image') === 'No') { $('#employeeUploadProfileImage').remove(); $('#employeeDeleteProfileImage').remove(); } if (this.checkPermission('Edit Employee Details') === 'No') { $('#employeeProfileEditInfo').remove(); } if (currentEmpId !== userEmpId) { $('#employeeUpdatePassword').remove(); } this.cancel(); } }, { key: "modEmployeeGetFailCallBack", value: function modEmployeeGetFailCallBack(data) {} }, { key: "editEmployee", value: function editEmployee() { this.edit(this.currentUserId); } }, { key: "changePassword", value: function changePassword() { $('#adminUsersModel').modal('show'); $('#adminUsersChangePwd #newpwd').val(''); $('#adminUsersChangePwd #conpwd').val(''); $('#adminUsersChangePwd_error').hide(); } }, { key: "changePasswordConfirm", value: function changePasswordConfirm() { $('#adminUsersChangePwd_error').hide(); var password = $('#adminUsersChangePwd #newpwd').val(); var conPassword = $('#adminUsersChangePwd #conpwd').val(); if (conPassword !== password) { $('#adminUsersChangePwd_error').html("Passwords don't match"); $('#adminUsersChangePwd_error').show(); return; } var validatePasswordResult = this.validatePassword(password); if (validatePasswordResult != null) { $('#adminUsersChangePwd_error').html(validatePasswordResult); $('#adminUsersChangePwd_error').show(); return; } var req = { pwd: conPassword }; var reqJson = JSON.stringify(req); var callBackData = []; callBackData.callBackData = []; callBackData.callBackSuccess = 'changePasswordSuccessCallBack'; callBackData.callBackFail = 'changePasswordFailCallBack'; this.customAction('changePassword', 'modules=employees', reqJson, callBackData); } }, { key: "closeChangePassword", value: function closeChangePassword() { $('#adminUsersModel').modal('hide'); } }, { key: "changePasswordSuccessCallBack", value: function changePasswordSuccessCallBack(callBackData, serverData) { this.closeChangePassword(); this.showMessage('Password Change', 'Password changed successfully'); } }, { key: "changePasswordFailCallBack", value: function changePasswordFailCallBack(callBackData, serverData) { this.closeChangePassword(); this.showMessage('Error', callBackData); } }]); return EmployeeAdapter; }(_ReactModalAdapterBase["default"]); /* * Company Graph */ var CompanyStructureAdapter = /*#__PURE__*/function (_AdapterBase) { _inherits(CompanyStructureAdapter, _AdapterBase); var _super2 = _createSuper(CompanyStructureAdapter); function CompanyStructureAdapter() { _classCallCheck(this, CompanyStructureAdapter); return _super2.apply(this, arguments); } _createClass(CompanyStructureAdapter, [{ key: "getDataMapping", value: function getDataMapping() { return ['id', 'title', 'address', 'type', 'country', 'parent']; } }, { key: "getHeaders", value: function getHeaders() { return [{ sTitle: 'ID', bVisible: false }, { sTitle: 'Name' }, { sTitle: 'Address' }, { sTitle: 'Type' }, { sTitle: 'Country', sClass: 'center' }, { sTitle: 'Parent Structure' }]; } }, { key: "getFormFields", value: function getFormFields() { return [['id', { label: 'ID', type: 'hidden', validation: '' }], ['title', { label: 'Name', type: 'text', validation: '' }], ['description', { label: 'Details', type: 'textarea', validation: '' }], ['address', { label: 'Address', type: 'textarea', validation: 'none' }], ['type', { label: 'Type', type: 'select', source: [['Company', 'Company'], ['Head Office', 'Head Office'], ['Regional Office', 'Regional Office'], ['Department', 'Department'], ['Unit', 'Unit'], ['Sub Unit', 'Sub Unit'], ['Other', 'Other']] }], ['country', { label: 'Country', type: 'select', 'remote-source': ['Country', 'code', 'name'] }], ['parent', { label: 'Parent Structure', type: 'select', 'allow-null': true, 'remote-source': ['CompanyStructure', 'id', 'title'] }]]; } }]); return CompanyStructureAdapter; }(_AdapterBase3["default"]); var CompanyGraphAdapter = /*#__PURE__*/function (_CompanyStructureAdap) { _inherits(CompanyGraphAdapter, _CompanyStructureAdap); var _super3 = _createSuper(CompanyGraphAdapter); function CompanyGraphAdapter(endPoint, tab, filter, orderBy) { var _this3; _classCallCheck(this, CompanyGraphAdapter); _this3 = _super3.call(this, endPoint, tab, filter, orderBy); _this3.nodeIdCounter = 0; return _this3; } _createClass(CompanyGraphAdapter, [{ key: "convertToTree", value: function convertToTree(data) { var ice = {}; ice.id = -1; ice.title = ''; ice.name = ''; ice.children = []; var parent = null; var added = {}; for (var i = 0; i < data.length; i++) { data[i].name = data[i].title; if (data[i].parent !== null && data[i].parent !== undefined) { parent = this.findParent(data, data[i].parent); if (parent !== null) { if (parent.children === undefined || parent.children === null) { parent.children = []; } parent.children.push(data[i]); } } } for (var _i4 = 0; _i4 < data.length; _i4++) { if (data[_i4].parent === null || data[_i4].parent === undefined) { ice.children.push(data[_i4]); } } return ice; } }, { key: "findParent", value: function findParent(data, parent) { for (var i = 0; i < data.length; i++) { if (data[i].title === parent || data[i].title === parent) { return data[i]; } } return null; } }, { key: "createTable", value: function createTable(elementId) { $('#tabPageCompanyGraph').html(''); var that = this; // eslint-disable-next-line prefer-destructuring var sourceData = this.sourceData; // this.fixCyclicParent(sourceData); var treeData = this.convertToTree(sourceData); var m = [20, 120, 20, 120]; var w = 5000 - m[1] - m[3]; var h = 1000 - m[0] - m[2]; var tree = d3.layout.tree().size([h, w]); this.diagonal = d3.svg.diagonal().projection(function (d) { return [d.y, d.x]; }); this.vis = d3.select('#tabPageCompanyGraph').append('svg:svg').attr('width', w + m[1] + m[3]).attr('height', h + m[0] + m[2]).append('svg:g').attr('transform', "translate(".concat(m[3], ",").concat(m[0], ")")); var root = treeData; root.x0 = h / 2; root.y0 = 0; function toggleAll(d) { if (d.children) { console.log(d.name); d.children.forEach(toggleAll); that.toggle(d); } } this.update(root, tree, root); } }, { key: "update", value: function update(source, tree, root) { var that = this; var duration = d3.event && d3.event.altKey ? 5000 : 500; // Compute the new tree layout. var nodes = tree.nodes(root).reverse(); // Normalize for fixed-depth. nodes.forEach(function (d) { d.y = d.depth * 180; }); // Update the nodes� var node = that.vis.selectAll('g.node') // eslint-disable-next-line no-return-assign .data(nodes, function (d) { return d.id || (d.id = ++that.nodeIdCounter); }); // Enter any new nodes at the parent's previous position. var nodeEnter = node.enter().append('svg:g').attr('class', 'node').attr('transform', function (d) { return "translate(".concat(source.y0, ",").concat(source.x0, ")"); }).on('click', function (d) { that.toggle(d); that.update(d, tree, root); }); nodeEnter.append('svg:circle').attr('r', 1e-6) // eslint-disable-next-line no-underscore-dangle .style('fill', function (d) { return d._children ? 'lightsteelblue' : '#fff'; }); nodeEnter.append('svg:text').attr('x', function (d) { return d.children || d._children ? -10 : 10; }).attr('dy', '.35em').attr('text-anchor', function (d) { return d.children || d._children ? 'end' : 'start'; }).text(function (d) { return d.name; }).style('fill-opacity', 1e-6); // Transition nodes to their new position. var nodeUpdate = node.transition().duration(duration).attr('transform', function (d) { return "translate(".concat(d.y, ",").concat(d.x, ")"); }); nodeUpdate.select('circle').attr('r', 4.5).style('fill', function (d) { return d._children ? 'lightsteelblue' : '#fff'; }); nodeUpdate.select('text').style('fill-opacity', 1); // Transition exiting nodes to the parent's new position. var nodeExit = node.exit().transition().duration(duration).attr('transform', function (d) { return "translate(".concat(source.y, ",").concat(source.x, ")"); }).remove(); nodeExit.select('circle').attr('r', 1e-6); nodeExit.select('text').style('fill-opacity', 1e-6); // Update the links� var link = that.vis.selectAll('path.link').data(tree.links(nodes), function (d) { return d.target.id; }); // Enter any new links at the parent's previous position. link.enter().insert('svg:path', 'g').attr('class', 'link').attr('d', function (d) { var o = { x: source.x0, y: source.y0 }; return that.diagonal({ source: o, target: o }); }).transition().duration(duration).attr('d', that.diagonal); // Transition links to their new position. link.transition().duration(duration).attr('d', that.diagonal); // Transition exiting nodes to the parent's new position. link.exit().transition().duration(duration).attr('d', function (d) { var o = { x: source.x, y: source.y }; return that.diagonal({ source: o, target: o }); }).remove(); // Stash the old positions for transition. nodes.forEach(function (d) { d.x0 = d.x; d.y0 = d.y; }); } // Toggle children. }, { key: "toggle", value: function toggle(d) { if (d.children) { d._children = d.children; d.children = null; } else { d.children = d._children; d._children = null; } } }, { key: "getSourceDataById", value: function getSourceDataById(id) { for (var i = 0; i < this.sourceData.length; i++) { if (this.sourceData[i].id === id) { return this.sourceData[i]; } } return null; } }, { key: "fixCyclicParent", value: function fixCyclicParent(sourceData) { var errorMsg = ''; for (var i = 0; i < sourceData.length; i++) { var obj = sourceData[i]; var curObj = obj; var parentIdArr = {}; parentIdArr[curObj.id] = 1; while (curObj.parent != null && curObj.parent !== undefined) { var parent = this.getSourceDataById(curObj.parent); if (parent == null) { break; } else if (parentIdArr[parent.id] === 1) { errorMsg = "".concat(obj.title, "'s parent structure set to ").concat(parent.title, "
    "); obj.parent = null; break; } parentIdArr[parent.id] = 1; curObj = parent; } } if (errorMsg !== '') { this.showMessage('Company Structure is having a cyclic dependency', "We found a cyclic dependency due to following reasons:
    ".concat(errorMsg)); return false; } return true; } }]); return CompanyGraphAdapter; }(CompanyStructureAdapter); /* * Api Access */ var ApiAccessAdapter = /*#__PURE__*/function (_AdapterBase2) { _inherits(ApiAccessAdapter, _AdapterBase2); var _super4 = _createSuper(ApiAccessAdapter); function ApiAccessAdapter() { _classCallCheck(this, ApiAccessAdapter); return _super4.apply(this, arguments); } _createClass(ApiAccessAdapter, [{ key: "getDataMapping", value: function getDataMapping() { return []; } }, { key: "getHeaders", value: function getHeaders() { return []; } }, { key: "getFormFields", value: function getFormFields() { return []; } }, { key: "setToken", value: function setToken(token) { this.token = token; } }, { key: "get", value: function get() { var canvas = document.getElementById('apiQRcode'); _qrcode["default"].toCanvas(canvas, JSON.stringify({ key: 'IceHrm', url: this.apiUrl, token: this.token }), function (error) { if (error) { console.log(error); } }); } }]); return ApiAccessAdapter; }(_AdapterBase3["default"]); module.exports = { EmployeeAdapter: EmployeeAdapter, CompanyGraphAdapter: CompanyGraphAdapter, ApiAccessAdapter: ApiAccessAdapter }; },{"../../../api/AdapterBase":39,"../../../api/ReactModalAdapterBase":50,"./components/EmployeeProfile":75,"qrcode":7,"react":"react","react-dom":"react-dom"}],78:[function(require,module,exports){ "use strict"; var _lib = require("./lib"); window.EmployeeCompanyLoanAdapter = _lib.EmployeeCompanyLoanAdapter; },{"./lib":79}],79:[function(require,module,exports){ "use strict"; var _AdapterBase2 = _interopRequireDefault(require("../../../api/AdapterBase")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(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, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { 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; } 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 { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 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 } }); if (superClass) _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } var EmployeeCompanyLoanAdapter = /*#__PURE__*/function (_AdapterBase) { _inherits(EmployeeCompanyLoanAdapter, _AdapterBase); var _super = _createSuper(EmployeeCompanyLoanAdapter); function EmployeeCompanyLoanAdapter() { _classCallCheck(this, EmployeeCompanyLoanAdapter); return _super.apply(this, arguments); } _createClass(EmployeeCompanyLoanAdapter, [{ key: "getDataMapping", value: function getDataMapping() { return ['id', 'loan', 'start_date', 'period_months', 'currency', 'amount', 'status']; } }, { key: "getHeaders", value: function getHeaders() { return [{ sTitle: 'ID', bVisible: false }, { sTitle: 'Loan Type' }, { sTitle: 'Loan Start Date' }, { sTitle: 'Loan Period (Months)' }, { sTitle: 'Currency' }, { sTitle: 'Amount' }, { sTitle: 'Status' }]; } }, { key: "getFormFields", value: function getFormFields() { return [['id', { label: 'ID', type: 'hidden' }], ['loan', { label: 'Loan Type', type: 'placeholder', 'remote-source': ['CompanyLoan', 'id', 'name'] }], ['start_date', { label: 'Loan Start Date', type: 'placeholder', validation: '' }], ['last_installment_date', { label: 'Last Installment Date', type: 'placeholder', validation: 'none' }], ['period_months', { label: 'Loan Period (Months)', type: 'placeholder', validation: 'number' }], ['currency', { label: 'Currency', type: 'placeholder', 'remote-source': ['CurrencyType', 'id', 'name'] }], ['amount', { label: 'Loan Amount', type: 'placeholder', validation: 'float' }], ['monthly_installment', { label: 'Monthly Installment', type: 'placeholder', validation: 'float' }], ['status', { label: 'Status', type: 'placeholder', source: [['Approved', 'Approved'], ['Paid', 'Paid'], ['Suspended', 'Suspended']] }], ['details', { label: 'Details', type: 'placeholder', validation: 'none' }]]; } // eslint-disable-next-line no-unused-vars }, { key: "getActionButtonsHtml", value: function getActionButtonsHtml(id, data) { var editButton = '' + ''; var deleteButton = '' + ''; var html = '
    _edit__delete_
    '; if (this.showDelete) { html = html.replace('_delete_', deleteButton); } else { html = html.replace('_delete_', ''); } if (this.showEdit) { html = html.replace('_edit_', editButton); } else { html = html.replace('_edit_', ''); } html = html.replace(/_id_/g, id); html = html.replace(/_BASE_/g, this.baseUrl); return html; } }]); return EmployeeCompanyLoanAdapter; }(_AdapterBase2["default"]); module.exports = { EmployeeCompanyLoanAdapter: EmployeeCompanyLoanAdapter }; },{"../../../api/AdapterBase":39}],80:[function(require,module,exports){ "use strict"; var _lib = require("./lib"); window.EmployeeOvertimeAdapter = _lib.EmployeeOvertimeAdapter; window.EmployeeOvertimeApproverAdapter = _lib.EmployeeOvertimeApproverAdapter; window.SubordinateEmployeeOvertimeAdapter = _lib.SubordinateEmployeeOvertimeAdapter; },{"./lib":81}],81:[function(require,module,exports){ "use strict"; var _ApproveModuleAdapter2 = _interopRequireDefault(require("../../../api/ApproveModuleAdapter")); var _lib = require("../../../admin/src/overtime/lib"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(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, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { 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; } 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 { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 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 } }); if (superClass) _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } var EmployeeOvertimeAdapter = /*#__PURE__*/function (_ApproveModuleAdapter) { _inherits(EmployeeOvertimeAdapter, _ApproveModuleAdapter); var _super = _createSuper(EmployeeOvertimeAdapter); function EmployeeOvertimeAdapter(endPoint, tab, filter, orderBy) { var _this; _classCallCheck(this, EmployeeOvertimeAdapter); _this = _super.call(this, endPoint, tab, filter, orderBy); _this.itemName = 'Overtime'; _this.itemNameLower = 'employeeovertime'; _this.modulePathName = 'overtime'; return _this; } _createClass(EmployeeOvertimeAdapter, [{ key: "getDataMapping", value: function getDataMapping() { return ['id', 'category', 'start_time', 'end_time', 'project', 'status']; } }, { key: "getHeaders", value: function getHeaders() { return [{ sTitle: 'ID', bVisible: false }, { sTitle: 'Category' }, { sTitle: 'Start Time' }, { sTitle: 'End Time' }, { sTitle: 'Project' }, { sTitle: 'Status' }]; } }, { key: "getFormFields", value: function getFormFields() { return [['id', { label: 'ID', type: 'hidden' }], ['category', { label: 'Category', type: 'select2', 'allow-null': false, 'remote-source': ['OvertimeCategory', 'id', 'name'] }], ['start_time', { label: 'Start Time', type: 'datetime', validation: '' }], ['end_time', { label: 'End Time', type: 'datetime', validation: '' }], ['project', { label: 'Project', type: 'select2', 'allow-null': true, 'null=label': 'none', 'remote-source': ['Project', 'id', 'name'] }], ['notes', { label: 'Notes', type: 'textarea', validation: 'none' }]]; } }]); return EmployeeOvertimeAdapter; }(_ApproveModuleAdapter2["default"]); /* EmployeeOvertimeApproverAdapter */ var EmployeeOvertimeApproverAdapter = /*#__PURE__*/function (_EmployeeOvertimeAdmi) { _inherits(EmployeeOvertimeApproverAdapter, _EmployeeOvertimeAdmi); var _super2 = _createSuper(EmployeeOvertimeApproverAdapter); function EmployeeOvertimeApproverAdapter(endPoint, tab, filter, orderBy) { var _this2; _classCallCheck(this, EmployeeOvertimeApproverAdapter); _this2 = _super2.call(this, endPoint, tab, filter, orderBy); _this2.itemName = 'Overtime'; _this2.itemNameLower = 'employeeovertime'; _this2.modulePathName = 'overtime'; return _this2; } _createClass(EmployeeOvertimeApproverAdapter, [{ key: "getActionButtonsHtml", value: function getActionButtonsHtml(id, data) { var statusChangeButton = '' + ''; var viewLogsButton = ''; var html = '
    _status__logs_
    '; html = html.replace('_logs_', viewLogsButton); if (data[this.getStatusFieldPosition()] === 'Processing') { html = html.replace('_status_', statusChangeButton); } else { html = html.replace('_status_', ''); } html = html.replace(/_id_/g, id); html = html.replace(/_BASE_/g, this.baseUrl); html = html.replace(/_cstatus_/g, data[this.getStatusFieldPosition()]); return html; } }, { key: "getStatusOptionsData", value: function getStatusOptionsData(currentStatus) { var data = {}; if (currentStatus === 'Processing') { data.Approved = 'Approved'; data.Rejected = 'Rejected'; } return data; } }, { key: "getStatusOptions", value: function getStatusOptions(currentStatus) { return this.generateOptions(this.getStatusOptionsData(currentStatus)); } }]); return EmployeeOvertimeApproverAdapter; }(_lib.EmployeeOvertimeAdminAdapter); /* EmployeeOvertimeAdapter */ var SubordinateEmployeeOvertimeAdapter = /*#__PURE__*/function (_EmployeeOvertimeAdmi2) { _inherits(SubordinateEmployeeOvertimeAdapter, _EmployeeOvertimeAdmi2); var _super3 = _createSuper(SubordinateEmployeeOvertimeAdapter); function SubordinateEmployeeOvertimeAdapter(endPoint, tab, filter, orderBy) { var _this3; _classCallCheck(this, SubordinateEmployeeOvertimeAdapter); _this3 = _super3.call(this, endPoint, tab, filter, orderBy); _this3.itemName = 'Overtime'; _this3.itemNameLower = 'employeeovertime'; _this3.modulePathName = 'overtime'; return _this3; } return SubordinateEmployeeOvertimeAdapter; }(_lib.EmployeeOvertimeAdminAdapter); module.exports = { EmployeeOvertimeAdapter: EmployeeOvertimeAdapter, EmployeeOvertimeApproverAdapter: EmployeeOvertimeApproverAdapter, SubordinateEmployeeOvertimeAdapter: SubordinateEmployeeOvertimeAdapter }; },{"../../../admin/src/overtime/lib":35,"../../../api/ApproveModuleAdapter":41}],82:[function(require,module,exports){ "use strict"; var _lib = require("./lib"); window.EmployeeProjectAdapter = _lib.EmployeeProjectAdapter; },{"./lib":83}],83:[function(require,module,exports){ "use strict"; var _AdapterBase2 = _interopRequireDefault(require("../../../api/AdapterBase")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(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, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { 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; } 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 { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 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 } }); if (superClass) _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } var EmployeeProjectAdapter = /*#__PURE__*/function (_AdapterBase) { _inherits(EmployeeProjectAdapter, _AdapterBase); var _super = _createSuper(EmployeeProjectAdapter); function EmployeeProjectAdapter() { _classCallCheck(this, EmployeeProjectAdapter); return _super.apply(this, arguments); } _createClass(EmployeeProjectAdapter, [{ key: "getDataMapping", value: function getDataMapping() { return ['id', 'project']; } }, { key: "getHeaders", value: function getHeaders() { return [{ sTitle: 'ID', bVisible: false }, { sTitle: 'Project' }]; } }, { key: "getFormFields", value: function getFormFields() { return [['id', { label: 'ID', type: 'hidden' }], ['project', { label: 'Project', type: 'select2', 'remote-source': ['Project', 'id', 'name'] }], ['details', { label: 'Details', type: 'textarea', validation: 'none' }]]; } }]); return EmployeeProjectAdapter; }(_AdapterBase2["default"]); module.exports = { EmployeeProjectAdapter: EmployeeProjectAdapter }; },{"../../../api/AdapterBase":39}],84:[function(require,module,exports){ "use strict"; var _lib = require("./lib"); window.EmployeeSkillAdapter = _lib.EmployeeSkillAdapter; window.EmployeeEducationAdapter = _lib.EmployeeEducationAdapter; window.EmployeeCertificationAdapter = _lib.EmployeeCertificationAdapter; window.EmployeeLanguageAdapter = _lib.EmployeeLanguageAdapter; },{"./lib":85}],85:[function(require,module,exports){ "use strict"; var _AdapterBase5 = _interopRequireDefault(require("../../../api/AdapterBase")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(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, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { 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; } 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 { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 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 } }); if (superClass) _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } var EmployeeSkillAdapter = /*#__PURE__*/function (_AdapterBase) { _inherits(EmployeeSkillAdapter, _AdapterBase); var _super = _createSuper(EmployeeSkillAdapter); function EmployeeSkillAdapter() { _classCallCheck(this, EmployeeSkillAdapter); return _super.apply(this, arguments); } _createClass(EmployeeSkillAdapter, [{ key: "getDataMapping", value: function getDataMapping() { return ['id', 'skill_id', 'details']; } }, { key: "getHeaders", value: function getHeaders() { return [{ sTitle: 'ID', bVisible: false }, { sTitle: 'Skill' }, { sTitle: 'Details' }]; } }, { key: "getFormFields", value: function getFormFields() { return [['id', { label: 'ID', type: 'hidden' }], ['skill_id', { label: 'Skill', type: 'select2', 'allow-null': true, 'remote-source': ['Skill', 'id', 'name'] }], ['details', { label: 'Details', type: 'textarea', validation: '' }]]; } }]); return EmployeeSkillAdapter; }(_AdapterBase5["default"]); /** * EmployeeEducationAdapter */ var EmployeeEducationAdapter = /*#__PURE__*/function (_AdapterBase2) { _inherits(EmployeeEducationAdapter, _AdapterBase2); var _super2 = _createSuper(EmployeeEducationAdapter); function EmployeeEducationAdapter() { _classCallCheck(this, EmployeeEducationAdapter); return _super2.apply(this, arguments); } _createClass(EmployeeEducationAdapter, [{ key: "getDataMapping", value: function getDataMapping() { return ['id', 'education_id', 'institute', 'date_start', 'date_end']; } }, { key: "getHeaders", value: function getHeaders() { return [{ sTitle: 'ID', bVisible: false }, { sTitle: 'Qualification' }, { sTitle: 'Institute' }, { sTitle: 'Start Date' }, { sTitle: 'Completed On' }]; } }, { key: "getFormFields", value: function getFormFields() { return [['id', { label: 'ID', type: 'hidden' }], ['education_id', { label: 'Qualification', type: 'select2', 'allow-null': false, 'remote-source': ['Education', 'id', 'name'] }], ['institute', { label: 'Institute', type: 'text', validation: '' }], ['date_start', { label: 'Start Date', type: 'date', validation: 'none' }], ['date_end', { label: 'Completed On', type: 'date', validation: 'none' }]]; } }]); return EmployeeEducationAdapter; }(_AdapterBase5["default"]); /** * EmployeeCertificationAdapter */ var EmployeeCertificationAdapter = /*#__PURE__*/function (_AdapterBase3) { _inherits(EmployeeCertificationAdapter, _AdapterBase3); var _super3 = _createSuper(EmployeeCertificationAdapter); function EmployeeCertificationAdapter() { _classCallCheck(this, EmployeeCertificationAdapter); return _super3.apply(this, arguments); } _createClass(EmployeeCertificationAdapter, [{ key: "getDataMapping", value: function getDataMapping() { return ['id', 'certification_id', 'institute', 'date_start', 'date_start']; } }, { key: "getHeaders", value: function getHeaders() { return [{ sTitle: 'ID', bVisible: false }, { sTitle: 'Certification' }, { sTitle: 'Institute' }, { sTitle: 'Granted On' }, { sTitle: 'Valid Thru' }]; } }, { key: "getFormFields", value: function getFormFields() { return [['id', { label: 'ID', type: 'hidden' }], ['certification_id', { label: 'Certification', type: 'select2', 'allow-null': false, 'remote-source': ['Certification', 'id', 'name'] }], ['institute', { label: 'Institute', type: 'text', validation: '' }], ['date_start', { label: 'Granted On', type: 'date', validation: 'none' }], ['date_end', { label: 'Valid Thru', type: 'date', validation: 'none' }]]; } }]); return EmployeeCertificationAdapter; }(_AdapterBase5["default"]); /** * EmployeeLanguageAdapter */ var EmployeeLanguageAdapter = /*#__PURE__*/function (_AdapterBase4) { _inherits(EmployeeLanguageAdapter, _AdapterBase4); var _super4 = _createSuper(EmployeeLanguageAdapter); function EmployeeLanguageAdapter() { _classCallCheck(this, EmployeeLanguageAdapter); return _super4.apply(this, arguments); } _createClass(EmployeeLanguageAdapter, [{ key: "getDataMapping", value: function getDataMapping() { return ['id', 'language_id', 'reading', 'speaking', 'writing', 'understanding']; } }, { key: "getHeaders", value: function getHeaders() { return [{ sTitle: 'ID', bVisible: false }, { sTitle: 'Language' }, { sTitle: 'Reading' }, { sTitle: 'Speaking' }, { sTitle: 'Writing' }, { sTitle: 'Understanding' }]; } }, { key: "getFormFields", value: function getFormFields() { var compArray = [['Elementary Proficiency', 'Elementary Proficiency'], ['Limited Working Proficiency', 'Limited Working Proficiency'], ['Professional Working Proficiency', 'Professional Working Proficiency'], ['Full Professional Proficiency', 'Full Professional Proficiency'], ['Native or Bilingual Proficiency', 'Native or Bilingual Proficiency']]; return [['id', { label: 'ID', type: 'hidden' }], ['language_id', { label: 'Language', type: 'select2', 'allow-null': false, 'remote-source': ['Language', 'id', 'description'] }], ['reading', { label: 'Reading', type: 'select', source: compArray }], ['speaking', { label: 'Speaking', type: 'select', source: compArray }], ['writing', { label: 'Writing', type: 'select', source: compArray }], ['understanding', { label: 'Understanding', type: 'select', source: compArray }]]; } }]); return EmployeeLanguageAdapter; }(_AdapterBase5["default"]); module.exports = { EmployeeSkillAdapter: EmployeeSkillAdapter, EmployeeEducationAdapter: EmployeeEducationAdapter, EmployeeCertificationAdapter: EmployeeCertificationAdapter, EmployeeLanguageAdapter: EmployeeLanguageAdapter }; },{"../../../api/AdapterBase":39}],86:[function(require,module,exports){ "use strict"; var _lib = require("./lib"); window.UserReportAdapter = _lib.UserReportAdapter; },{"./lib":87}],87:[function(require,module,exports){ "use strict"; var _lib = require("../../../admin/src/reports/lib"); function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(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, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { 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; } 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 { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 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 } }); if (superClass) _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } /** * UserReportAdapter */ var UserReportAdapter = /*#__PURE__*/function (_ReportAdapter) { _inherits(UserReportAdapter, _ReportAdapter); var _super = _createSuper(UserReportAdapter); function UserReportAdapter() { _classCallCheck(this, UserReportAdapter); return _super.apply(this, arguments); } _createClass(UserReportAdapter, [{ key: "renderForm", value: function renderForm(object) { var that = this; this.processFormFieldsWithObject(object); if (this.remoteFieldsExists) { var cb = function cb() { that.renderFormNew(object); }; this.initFieldMasterData(cb); } else { this.initFieldMasterData(); that.renderFormNew(object); } this.currentReport = object; } }]); return UserReportAdapter; }(_lib.ReportAdapter); module.exports = { UserReportAdapter: UserReportAdapter }; },{"../../../admin/src/reports/lib":36}],88:[function(require,module,exports){ "use strict"; var _lib = require("./lib"); window.EmployeeSalaryAdapter = _lib.EmployeeSalaryAdapter; },{"./lib":89}],89:[function(require,module,exports){ "use strict"; var _AdapterBase2 = _interopRequireDefault(require("../../../api/AdapterBase")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(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, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { 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; } 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 { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 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 } }); if (superClass) _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } var EmployeeSalaryAdapter = /*#__PURE__*/function (_AdapterBase) { _inherits(EmployeeSalaryAdapter, _AdapterBase); var _super = _createSuper(EmployeeSalaryAdapter); function EmployeeSalaryAdapter() { _classCallCheck(this, EmployeeSalaryAdapter); return _super.apply(this, arguments); } _createClass(EmployeeSalaryAdapter, [{ key: "getDataMapping", value: function getDataMapping() { return ['id', 'component', 'amount', 'details']; } }, { key: "getHeaders", value: function getHeaders() { return [{ sTitle: 'ID', bVisible: false }, { sTitle: 'Salary Component' }, { sTitle: 'Amount' }, { sTitle: 'Details' }]; } }, { key: "getFormFields", value: function getFormFields() { return [['id', { label: 'ID', type: 'hidden' }], ['component', { label: 'Salary Component', type: 'select2', 'remote-source': ['SalaryComponent', 'id', 'name'] }], ['amount', { label: 'Amount', type: 'text', validation: 'float' }], ['details', { label: 'Details', type: 'textarea', validation: 'none' }]]; } }]); return EmployeeSalaryAdapter; }(_AdapterBase2["default"]); module.exports = { EmployeeSalaryAdapter: EmployeeSalaryAdapter }; },{"../../../api/AdapterBase":39}],90:[function(require,module,exports){ "use strict"; var _lib = require("./lib"); window.StaffDirectoryAdapter = _lib.StaffDirectoryAdapter; window.StaffDirectoryObjectAdapter = _lib.StaffDirectoryObjectAdapter; },{"./lib":91}],91:[function(require,module,exports){ "use strict"; var _AdapterBase2 = _interopRequireDefault(require("../../../api/AdapterBase")); var _ObjectAdapter2 = _interopRequireDefault(require("../../../api/ObjectAdapter")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(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, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { 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; } 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 { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 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 } }); if (superClass) _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } var StaffDirectoryAdapter = /*#__PURE__*/function (_AdapterBase) { _inherits(StaffDirectoryAdapter, _AdapterBase); var _super = _createSuper(StaffDirectoryAdapter); function StaffDirectoryAdapter() { _classCallCheck(this, StaffDirectoryAdapter); return _super.apply(this, arguments); } _createClass(StaffDirectoryAdapter, [{ key: "getDataMapping", value: function getDataMapping() { return ['id', 'image', 'first_name', 'last_name', 'job_title', 'department', 'work_phone', 'work_email', 'joined_date']; } }, { key: "getHeaders", value: function getHeaders() { return [{ sTitle: 'ID', bVisible: false }, { sTitle: '' }, { sTitle: 'First Name' }, { sTitle: 'Last Name' }, { sTitle: 'Job Title' }, { sTitle: 'Department' }, { sTitle: 'Work Phone' }, { sTitle: 'Work Email' }, { sTitle: 'Joined Date' }]; } }, { key: "getFormFields", value: function getFormFields() { return [['id', { label: 'ID', type: 'hidden', validation: '' }], ['first_name', { label: 'First Name', type: 'text', validation: '' }], ['last_name', { label: 'Last Name', type: 'text', validation: '' }], ['job_title', { label: 'Job Title', type: 'select2', 'remote-source': ['JobTitle', 'id', 'name'] }], ['department', { label: 'Department', type: 'select2', 'remote-source': ['CompanyStructure', 'id', 'title'] }], ['work_phone', { label: 'Work Phone', type: 'text', validation: 'none' }], ['work_email', { label: 'Work Email', type: 'placeholder', validation: 'emailOrEmpty' }], ['joined_date', { label: 'Joined Date', type: 'date', validation: '' }]]; } }, { key: "showActionButtons", value: function showActionButtons() { return false; } }, { key: "getCustomTableParams", value: function getCustomTableParams() { var that = this; var dataTableParams = { aoColumnDefs: [{ fnRender: function fnRender(data, cell) { try { return that.preProcessRemoteTableData(data, cell, 1); } catch (e) { return cell; } }, aTargets: [1] }, { fnRender: function fnRender(data, cell) { try { return that.preProcessRemoteTableData(data, cell, 8); } catch (e) { return cell; } }, aTargets: [8] }] }; return dataTableParams; } // eslint-disable-next-line consistent-return }, { key: "preProcessRemoteTableData", value: function preProcessRemoteTableData(data, cell, id) { if (id === 8) { if (cell === '0000-00-00 00:00:00' || cell === '' || cell === undefined || cell === null) { return ''; } return Date.parse(cell).toString('yyyy MMM d'); } if (id === 1) { var tmp = 'User Image'; return tmp.replace('_img_', cell); } } }]); return StaffDirectoryAdapter; }(_AdapterBase2["default"]); /* StaffDirectoryObjectAdapter */ var StaffDirectoryObjectAdapter = /*#__PURE__*/function (_ObjectAdapter) { _inherits(StaffDirectoryObjectAdapter, _ObjectAdapter); var _super2 = _createSuper(StaffDirectoryObjectAdapter); function StaffDirectoryObjectAdapter() { _classCallCheck(this, StaffDirectoryObjectAdapter); return _super2.apply(this, arguments); } _createClass(StaffDirectoryObjectAdapter, [{ key: "getDataMapping", value: function getDataMapping() { return ['id', 'image', 'first_name', 'last_name', 'job_title', 'department', 'work_phone', 'work_email', 'joined_date']; } }, { key: "getHeaders", value: function getHeaders() { return [{ sTitle: 'ID', bVisible: false }, { sTitle: '' }, { sTitle: 'First Name' }, { sTitle: 'Last Name' }, { sTitle: 'Job Title' }, { sTitle: 'Department' }, { sTitle: 'Work Phone' }, { sTitle: 'Work Email' }, { sTitle: 'Joined Date' }]; } }, { key: "getFormFields", value: function getFormFields() { return [['id', { label: 'ID', type: 'hidden', validation: '' }], ['first_name', { label: 'First Name', type: 'text', validation: '' }], ['last_name', { label: 'Last Name', type: 'text', validation: '' }], ['job_title', { label: 'Job Title', type: 'select2', 'remote-source': ['JobTitle', 'id', 'name'] }], ['department', { label: 'Department', type: 'select2', 'remote-source': ['CompanyStructure', 'id', 'title'] }], ['work_phone', { label: 'Work Phone', type: 'text', validation: 'none' }], ['work_email', { label: 'Work Email', type: 'placeholder', validation: 'emailOrEmpty' }], ['joined_date', { label: 'Joined Date', type: 'date', validation: '' }]]; } // eslint-disable-next-line no-unused-vars }, { key: "addDomEvents", value: function addDomEvents(object) {} }, { key: "getTemplateName", value: function getTemplateName() { return 'element.html'; } }, { key: "preProcessTableData", value: function preProcessTableData(_row) { var row = _row; row.color = this.getColorByRandomString(row.first_name); return row; } }, { key: "getFilters", value: function getFilters() { return [['job_title', { label: 'Job Title', type: 'select2', 'allow-null': true, 'null-label': 'All Job Titles', 'remote-source': ['JobTitle', 'id', 'name'] }], ['department', { label: 'Department', type: 'select2', 'allow-null': true, 'null-label': 'All Departments', 'remote-source': ['CompanyStructure', 'id', 'title'] }]]; } }]); return StaffDirectoryObjectAdapter; }(_ObjectAdapter2["default"]); module.exports = { StaffDirectoryAdapter: StaffDirectoryAdapter, StaffDirectoryObjectAdapter: StaffDirectoryObjectAdapter }; },{"../../../api/AdapterBase":39,"../../../api/ObjectAdapter":49}],92:[function(require,module,exports){ "use strict"; var _lib = require("./lib"); window.EmployeeTimeSheetAdapter = _lib.EmployeeTimeSheetAdapter; window.SubEmployeeTimeSheetAdapter = _lib.SubEmployeeTimeSheetAdapter; window.EmployeeTimeEntryAdapter = _lib.EmployeeTimeEntryAdapter; window.QtsheetAdapter = _lib.QtsheetAdapter; },{"./lib":93}],93:[function(require,module,exports){ "use strict"; var _AdapterBase3 = _interopRequireDefault(require("../../../api/AdapterBase")); var _FormValidation = _interopRequireDefault(require("../../../api/FormValidation")); var _TableEditAdapter2 = _interopRequireDefault(require("../../../api/TableEditAdapter")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(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, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { 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; } 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 { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 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 } }); if (superClass) _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } var ValidationRules = _FormValidation["default"].getValidationRules(); var EmployeeTimeSheetAdapter = /*#__PURE__*/function (_AdapterBase) { _inherits(EmployeeTimeSheetAdapter, _AdapterBase); var _super = _createSuper(EmployeeTimeSheetAdapter); function EmployeeTimeSheetAdapter(endPoint, tab, filter, orderBy) { var _this; _classCallCheck(this, EmployeeTimeSheetAdapter); _this = _super.call(this, endPoint, tab, filter, orderBy); _this.currentTimesheetId = null; _this.currentTimesheet = null; _this.needStartEndTime = false; return _this; } _createClass(EmployeeTimeSheetAdapter, [{ key: "getDataMapping", value: function getDataMapping() { return ['id', 'date_start', 'date_end', 'total_time', 'status']; } }, { key: "getHeaders", value: function getHeaders() { return [{ sTitle: 'ID', bVisible: false }, { sTitle: 'Start Date' }, { sTitle: 'End Date' }, { sTitle: 'Total Time' }, { sTitle: 'Status' }]; } }, { key: "getFormFields", value: function getFormFields() { return [['id', { label: 'ID', type: 'hidden' }], ['date_start', { label: 'TimeSheet Start Date', type: 'date', validation: '' }], ['date_end', { label: 'TimeSheet End Date', type: 'date', validation: '' }], ['details', { label: 'Reason', type: 'textarea', validation: 'none' }]]; } }, { key: "preProcessTableData", value: function preProcessTableData(_row) { var row = _row; row[1] = Date.parse(row[1]).toString('MMM d, yyyy (dddd)'); row[2] = Date.parse(row[2]).toString('MMM d, yyyy (dddd)'); return row; } }, { key: "setNeedStartEndTime", value: function setNeedStartEndTime(status) { this.needStartEndTime = status; } }, { key: "renderForm", value: function renderForm(object) { var formHtml = this.templates.formTemplate; $('#EmployeeTimesheetBlock').remove(); $("#".concat(this.getTableName(), "Form")).html(formHtml); $("#".concat(this.getTableName(), "Form")).show(); $("#".concat(this.getTableName())).hide(); $('.timesheet_start').html(Date.parse(object.date_start).toString('MMM d, yyyy (dddd)')); $('.timesheet_end').html(Date.parse(object.date_end).toString('MMM d, yyyy (dddd)')); this.currentTimesheet = object; this.getTimeEntries(); var st = Date.parse(object.date_start); $('#EmployeeTimesheetBlock').fullCalendar({ header: { // left: 'prev,next today', left: false, // center: 'title', center: false, // right: 'month,agendaWeek,agendaDay' right: false }, year: st.toString('yyyy'), month: st.toString('M'), date: st.toString('d'), defaultView: 'basicWeek', height: 200, editable: false, events: modJs.getScheduleJsonUrl(this.currentTimesheet.employee), loading: function loading(bool) { if (bool) $('#loadingBlock').show();else $('#loadingBlock').hide(); }, // eslint-disable-next-line no-unused-vars dayClick: function dayClick(date, jsEvent, view, resourceObj) { modJs.renderFormByDate(date.format()); }, // eslint-disable-next-line no-unused-vars eventClick: function eventClick(calEvent, jsEvent, view) { modJs.renderFormTimeEntryCalender(calEvent.id); }, eventRender: function eventRender(event, element) { element.find('.fc-time').remove(); } }); $('#EmployeeTimesheetBlock').fullCalendar('gotoDate', st); $('.fc-toolbar').hide(); } }, { key: "quickEdit", value: function quickEdit(id, status, sdate, edate) { $('#Qtsheet').data('lastActiveTab', modJs.tab); // eslint-disable-next-line no-global-assign modJs = modJsList.tabQtsheet; modJs.setCurrentTimeSheetId(id); $('.timesheet_start').html(sdate); $('.timesheet_end').html(edate); $('#timesheetTabs').find('.active').find('.reviewBlock.reviewBlockTable').hide(); $('#QtsheetHeader').show(); $('#Qtsheet').show(); $('#QtsheetDataButtons').show(); if (status === 'Submitted' || status === 'Approved') { $('.completeBtnTable').hide(); $('.saveBtnTable').hide(); } else { $('.completeBtnTable').show(); $('.saveBtnTable').show(); } modJs.get([]); } }, { key: "getScheduleJsonUrl", value: function getScheduleJsonUrl(employeeId) { var url = "".concat(this.moduleRelativeURL, "?a=ca&sa=getEmployeeTimeEntries&t=").concat(this.table, "&mod=modules%3Dtime_sheets&e=").concat(employeeId); return url; } }, { key: "renderFormByDate", value: function renderFormByDate(_date) { var date = _date; if (date.indexOf('T') < 0) { var s1 = moment(); date = "".concat(date, " ").concat(s1.format('HH:mm:ss')); } var start = date.replace('T', ' '); var m1 = moment(start); m1.add(1, 'h'); var end = m1.format('YYYY-MM-DD HH:mm:ss'); var obj = {}; obj.date = _date; obj.date_start = start; obj.date_end = end; this.renderFormTimeEntryCalender(obj); } }, { key: "renderFormTimeEntryCalender", value: function renderFormTimeEntryCalender(object) { if ("".concat(this.needStartEndTime) === '0') { return; } this.openTimeEntryDialog(object); if (object.id !== undefined && object.id != null) { var cid = object.id; $('.deleteBtnWorkSchedule').show(); $('.deleteBtnWorkSchedule').off().on('click', function () { modJs.deleteRow(cid); return false; }); } else { $('.deleteBtnWorkSchedule').remove(); } } }, { key: "openTimeEntryDialog", value: function openTimeEntryDialog(object) { this.currentTimesheetId = this.currentId; var obj = modJsList.tabEmployeeTimeEntry; $('#TimeEntryModel').modal({ backdrop: 'static', keyboard: false }); obj.currentTimesheet = this.currentTimesheet; obj.renderForm(object); obj.timesheetId = this.currentId; } }, { key: "closeTimeEntryDialog", value: function closeTimeEntryDialog() { $('#TimeEntryModel').modal('hide'); } }, { key: "getTimeEntries", value: function getTimeEntries() { var timesheetId = this.currentId; var sourceMappingJson = JSON.stringify(modJsList.tabEmployeeTimeEntry.getSourceMapping()); var object = { id: timesheetId, sm: sourceMappingJson }; var reqJson = JSON.stringify(object); var callBackData = []; callBackData.callBackData = []; callBackData.callBackSuccess = 'getTimeEntriesSuccessCallBack'; callBackData.callBackFail = 'getTimeEntriesFailCallBack'; this.customAction('getTimeEntries', 'modules=time_sheets', reqJson, callBackData); } }, { key: "getTimeEntriesSuccessCallBack", value: function getTimeEntriesSuccessCallBack(callBackData) { var entries = callBackData; var html = ''; var temp = '_start__end__duration__project__details_'; for (var i = 0; i < entries.length; i++) { try { var t = temp; t = t.replace(/_start_/g, Date.parse(entries[i].date_start).toString('MMM d, yyyy [hh:mm tt]')); t = t.replace(/_end_/g, Date.parse(entries[i].date_end).toString('MMM d, yyyy [hh:mm tt]')); var mili = Date.parse(entries[i].date_end) - Date.parse(entries[i].date_start); var minutes = Math.round(mili / 60000); var hourMinutes = minutes % 60; var hours = (minutes - hourMinutes) / 60; t = t.replace(/_duration_/g, "Hours (".concat(hours, ") - Min (").concat(hourMinutes, ")")); if (entries[i].project === 'null' || entries[i].project == null || entries[i].project === undefined) { t = t.replace(/_project_/g, 'None'); } else { t = t.replace(/_project_/g, entries[i].project); } t = t.replace(/_project_/g, entries[i].project); t = t.replace(/_details_/g, entries[i].details); t = t.replace(/_id_/g, entries[i].id); t = t.replace(/_BASE_/g, this.baseUrl); html += t; } catch (e) {// Do nothing } } $('.timesheet_entries_table_body').html(html); if (modJs.getTableName() === 'SubEmployeeTimeSheetAll' || "".concat(this.needStartEndTime) === '0') { $('.submit_sheet').hide(); $('.add_time_sheet_entry').hide(); } else if (this.currentElement.status === 'Approved') { $('.submit_sheet').hide(); $('.add_time_sheet_entry').hide(); } else { $('.submit_sheet').show(); $('.add_time_sheet_entry').show(); } $('#EmployeeTimesheetBlock').fullCalendar('refetchEvents'); } // eslint-disable-next-line no-unused-vars }, { key: "getTimeEntriesFailCallBack", value: function getTimeEntriesFailCallBack(callBackData) { this.showMessage('Error', 'Error occured while getting timesheet entries'); } }, { key: "createPreviousTimesheet", value: function createPreviousTimesheet(id) { var object = { id: id }; var reqJson = JSON.stringify(object); var callBackData = []; callBackData.callBackData = []; callBackData.callBackSuccess = 'createPreviousTimesheetSuccessCallBack'; callBackData.callBackFail = 'createPreviousTimesheetFailCallBack'; this.customAction('createPreviousTimesheet', 'modules=time_sheets', reqJson, callBackData); } // eslint-disable-next-line no-unused-vars }, { key: "createPreviousTimesheetSuccessCallBack", value: function createPreviousTimesheetSuccessCallBack(callBackData) { $('.tooltip').css('display', 'none'); $('.tooltip').remove(); // this.showMessage("Success", "Previous Timesheet created"); this.get([]); } }, { key: "createPreviousTimesheetFailCallBack", value: function createPreviousTimesheetFailCallBack(callBackData) { this.showMessage('Error', callBackData); } }, { key: "changeTimeSheetStatusWithId", value: function changeTimeSheetStatusWithId(id, status) { if (status === '' || status == null || status === undefined) { this.showMessage('Status Error', 'Please select a status'); return; } var object = { id: id, status: status }; var reqJson = JSON.stringify(object); var callBackData = []; callBackData.callBackData = []; callBackData.callBackSuccess = 'changeTimeSheetStatusSuccessCallBack'; callBackData.callBackFail = 'changeTimeSheetStatusFailCallBack'; this.customAction('changeTimeSheetStatus', 'modules=time_sheets', reqJson, callBackData); } // eslint-disable-next-line no-unused-vars }, { key: "changeTimeSheetStatusSuccessCallBack", value: function changeTimeSheetStatusSuccessCallBack(callBackData) { this.showMessage('Successful', 'Timesheet status changed successfully'); this.get([]); } // eslint-disable-next-line no-unused-vars }, { key: "changeTimeSheetStatusFailCallBack", value: function changeTimeSheetStatusFailCallBack(callBackData) { this.showMessage('Error', 'Error occured while changing Timesheet status'); } }, { key: "getActionButtonsHtml", value: function getActionButtonsHtml(id, data) { var html = ''; if ("".concat(this.needStartEndTime) === '0') { html = '
    ' + '' + '' + '_redoBtn_' + '
    '; } else { html = '
    ' + '' + '_redoBtn_' + '
    '; } if (this.getTableName() === 'EmployeeTimeSheetAll') { var redoBtn = ''; html = html.replace(/_redoBtn_/g, redoBtn); } else { html = html.replace(/_redoBtn_/g, ''); } html = html.replace(/_id_/g, id); html = html.replace(/_sdate_/g, data[1]); html = html.replace(/_edate_/g, data[2]); html = html.replace(/_status_/g, data[4]); html = html.replace(/_BASE_/g, this.baseUrl); return html; } }, { key: "getCustomTableParams", value: function getCustomTableParams() { var that = this; var dataTableParams = { aoColumnDefs: [{ fnRender: function fnRender(data, cell) { return that.preProcessRemoteTableData(data, cell, 1); }, aTargets: [1] }, { fnRender: function fnRender(data, cell) { return that.preProcessRemoteTableData(data, cell, 2); }, aTargets: [2] }, { fnRender: that.getActionButtons, aTargets: [that.getDataMapping().length] }] }; return dataTableParams; } // eslint-disable-next-line no-unused-vars }, { key: "preProcessRemoteTableData", value: function preProcessRemoteTableData(data, cell, id) { return Date.parse(cell).toString('MMM d, yyyy (dddd)'); } }]); return EmployeeTimeSheetAdapter; }(_AdapterBase3["default"]); /* * Subordinate TimeSheets */ var SubEmployeeTimeSheetAdapter = /*#__PURE__*/function (_EmployeeTimeSheetAda) { _inherits(SubEmployeeTimeSheetAdapter, _EmployeeTimeSheetAda); var _super2 = _createSuper(SubEmployeeTimeSheetAdapter); function SubEmployeeTimeSheetAdapter(endPoint, tab, filter, orderBy) { var _this2; _classCallCheck(this, SubEmployeeTimeSheetAdapter); _this2 = _super2.call(this, endPoint, tab, filter, orderBy); _this2.timeSheetStatusChangeId = null; return _this2; } _createClass(SubEmployeeTimeSheetAdapter, [{ key: "getDataMapping", value: function getDataMapping() { return ['id', 'employee', 'date_start', 'date_end', 'total_time', 'status']; } }, { key: "getHeaders", value: function getHeaders() { return [{ sTitle: 'ID', bVisible: false }, { sTitle: 'Employee', bSearchable: true }, { sTitle: 'Start Date', bSearchable: true }, { sTitle: 'End Date', bSearchable: true }, { sTitle: 'Total Time', bSearchable: false }, { sTitle: 'Status' }]; } }, { key: "getFormFields", value: function getFormFields() { return [['id', { label: 'ID', type: 'hidden' }], ['employee', { label: 'Employee', type: 'select', 'allow-null': false, 'remote-source': ['Employee', 'id', 'first_name+last_name'] }], ['date_start', { label: 'TimeSheet Start Date', type: 'date', validation: '' }], ['date_end', { label: 'TimeSheet Start Date', type: 'date', validation: '' }], ['details', { label: 'Reason', type: 'textarea', validation: 'none' }]]; } }, { key: "isSubProfileTable", value: function isSubProfileTable() { return true; } }, { key: "getCustomSuccessCallBack", value: function getCustomSuccessCallBack(serverData) { var data = []; var mapping = this.getDataMapping(); for (var i = 0; i < serverData.length; i++) { var row = []; for (var j = 0; j < mapping.length; j++) { row[j] = serverData[i][mapping[j]]; } data.push(this.preProcessTableData(row)); } this.tableData = data; this.createTable(this.getTableName()); $("#".concat(this.getTableName(), "Form")).hide(); $("#".concat(this.getTableName())).show(); } }, { key: "preProcessTableData", value: function preProcessTableData(_row) { var row = _row; row[2] = Date.parse(row[2]).toString('MMM d, yyyy (dddd)'); row[3] = Date.parse(row[3]).toString('MMM d, yyyy (dddd)'); return row; } }, { key: "openTimeSheetStatus", value: function openTimeSheetStatus(timeSheetId, status) { this.currentTimesheetId = timeSheetId; $('#TimeSheetStatusModel').modal('show'); $('#timesheet_status').val(status); this.timeSheetStatusChangeId = timeSheetId; } }, { key: "closeTimeSheetStatus", value: function closeTimeSheetStatus() { $('#TimeSheetStatusModel').modal('hide'); } }, { key: "changeTimeSheetStatus", value: function changeTimeSheetStatus() { var timeSheetStatus = $('#timesheet_status').val(); this.changeTimeSheetStatusWithId(this.timeSheetStatusChangeId, timeSheetStatus); this.closeTimeSheetStatus(); this.timeSheetStatusChangeId = null; } }, { key: "getActionButtonsHtml", value: function getActionButtonsHtml(id, data) { var html; if ("".concat(this.needStartEndTime) === '0') { html = '
    ' + '' + '' + '' + '
    '; } else { html = '
    ' + '' + '' + '
    '; } html = html.replace(/_id_/g, id); html = html.replace(/_BASE_/g, this.baseUrl); html = html.replace(/_sdate_/g, data[1]); html = html.replace(/_edate_/g, data[2]); html = html.replace(/_status_/g, data[4]); return html; } }, { key: "getCustomTableParams", value: function getCustomTableParams() { var that = this; var dataTableParams = { aoColumnDefs: [{ fnRender: function fnRender(data, cell) { return that.preProcessRemoteTableData(data, cell, 2); }, aTargets: [2] }, { fnRender: function fnRender(data, cell) { return that.preProcessRemoteTableData(data, cell, 3); }, aTargets: [3] }, { fnRender: that.getActionButtons, aTargets: [that.getDataMapping().length] }] }; return dataTableParams; } }, { key: "getFilters", value: function getFilters() { return [['employee', { label: 'Employee', type: 'select2', 'allow-null': true, 'null-label': 'All Employees', 'remote-source': ['Employee', 'id', 'first_name+last_name'] }], ['status', { label: 'Status', type: 'select', 'allow-null': true, 'null-label': 'All', source: [['Submitted', 'Submitted'], ['Pending', 'Pending'], ['Approved', 'Approved'], ['Rejected', 'Rejected']] }]]; } }]); return SubEmployeeTimeSheetAdapter; }(EmployeeTimeSheetAdapter); /** * EmployeeTimeEntryAdapter */ var EmployeeTimeEntryAdapter = /*#__PURE__*/function (_AdapterBase2) { _inherits(EmployeeTimeEntryAdapter, _AdapterBase2); var _super3 = _createSuper(EmployeeTimeEntryAdapter); function EmployeeTimeEntryAdapter(endPoint, tab, filter, orderBy) { var _this3; _classCallCheck(this, EmployeeTimeEntryAdapter); _this3 = _super3.call(this, endPoint, tab, filter, orderBy); _this3.timesheetId = null; _this3.currentTimesheet = null; _this3.allProjectsAllowed = 1; _this3.employeeProjects = []; return _this3; } _createClass(EmployeeTimeEntryAdapter, [{ key: "getDataMapping", value: function getDataMapping() { return ['id', 'project', 'date_start', 'time_start', 'date_end', 'time_end', 'details']; } }, { key: "getHeaders", value: function getHeaders() { return [{ sTitle: 'ID', bVisible: false }, { sTitle: 'Project' }, { sTitle: 'Start Date' }, { sTitle: 'Start Time' }, { sTitle: 'End Date' }, { sTitle: 'End Time' }, { sTitle: 'Details' }]; } }, { key: "getFormFields", value: function getFormFields() { return [['id', { label: 'ID', type: 'hidden' }], ['project', { label: 'Project', type: 'select2', 'allow-null': false, 'remote-source': ['Project', 'id', 'name', 'getEmployeeProjects'] }], ['date_select', { label: 'Date', type: 'select', source: [] }], ['date_start', { label: 'Start Time', type: 'time', validation: '' }], ['date_end', { label: 'End Time', type: 'time', validation: '' }], ['details', { label: 'Details', type: 'textarea', validation: '' }]]; } }, { key: "getDates", value: function getDates(startDate, stopDate) { var dateArray = []; var currentDate = startDate; while (currentDate <= stopDate) { dateArray.push(new Date(currentDate)); currentDate = currentDate.add({ days: 1 }); } return dateArray; } }, { key: "renderForm", value: function renderForm(object) { var _this4 = this; this.initMasterDataReader(); this.masterDataReader.updateAllMasterData().then(function () { _this4._renderForm(object); }); } }, { key: "_renderForm", value: function _renderForm(object) { var formHtml = this.getCustomTemplate('time_entry_form.html'); formHtml = formHtml.replace(/modJs/g, "modJsList['tabEmployeeTimeEntry']"); var html = ''; var fields = this.getFormFields(); for (var i = 0; i < fields.length; i++) { var metaField = this.getMetaFieldForRendering(fields[i][0]); if (metaField === '' || metaField === undefined) { html += this.renderFormField(fields[i]); } else { var metaVal = object[metaField]; if (metaVal !== '' && metaVal != null && metaVal !== undefined && metaVal.trim() !== '') { html += this.renderFormField(JSON.parse(metaVal)); } else { html += this.renderFormField(fields[i]); } } } // append dates // var dateStart = new Date(this.currentTimesheet.date_start); // var dateStop = new Date(this.currentTimesheet.date_end); // var datesArray = this.getDates(dateStart, dateStop); var optionList = ''; for (var _i = 0; _i < this.currentTimesheet.days.length; _i++) { var k = this.currentTimesheet.days[_i]; // optionList += ''; optionList += ""); } formHtml = formHtml.replace(/_id_/g, "".concat(this.getTableName(), "_submit")); formHtml = formHtml.replace(/_fields_/g, html); $("#".concat(this.getTableName(), "Form")).html(formHtml); $("#".concat(this.getTableName(), "Form")).show(); $("#".concat(this.getTableName())).hide(); $("#".concat(this.getTableName(), "Form .datefield")).datepicker({ viewMode: 2 }); $("#".concat(this.getTableName(), "Form .datetimefield")).datetimepicker({ language: 'en' }); $("#".concat(this.getTableName(), "Form .timefield")).datetimepicker({ language: 'en', pickDate: false }); $("#".concat(this.getTableName(), "Form .select2Field")).select2(); $('#date_select').html(optionList); if (object !== undefined && object != null) { this.fillForm(object); } } // eslint-disable-next-line no-unused-vars }, { key: "fillForm", value: function fillForm(object, _formId, fields) { var formId = _formId; if (formId == null || formId === undefined || formId === '') { formId = "#".concat(this.getTableName(), "Form"); } if (object.id != null && object.id !== undefined) { $("".concat(formId, " #id")).val(object.id); } if (object.project != null && object.project !== undefined) { $("".concat(formId, " #project")).select2('val', object.project); } if (object.date != null && object.date !== undefined) { $("".concat(formId, " #date_select")).val(object.date); } } }, { key: "cancel", value: function cancel() { $('#TimeEntryModel').modal('hide'); } }, { key: "setAllProjectsAllowed", value: function setAllProjectsAllowed(allProjectsAllowed) { this.allProjectsAllowed = allProjectsAllowed; } }, { key: "setEmployeeProjects", value: function setEmployeeProjects(employeeProjects) { this.employeeProjects = employeeProjects; } }, { key: "save", value: function save() { var validator = new _FormValidation["default"]("".concat(this.getTableName(), "_submit"), true, { ShowPopup: false, LabelErrorClass: 'error' }); if (validator.checkValues()) { var params = validator.getFormParameters(); params.timesheet = this.timesheetId; params.time_start = params.date_start; params.time_end = params.date_end; params.date_start = "".concat(params.date_select, " ").concat(params.date_start); params.date_end = "".concat(params.date_select, " ").concat(params.date_end); var msg = this.doCustomValidation(params); if (msg == null) { var id = $("#".concat(this.getTableName(), "_submit #id")).val(); if (id != null && id !== undefined && id !== '') { params.id = id; } this.add(params, []); this.cancel(); } else { $("#".concat(this.getTableName(), "Form .label")).html(msg); $("#".concat(this.getTableName(), "Form .label")).show(); } } } }, { key: "doCustomValidation", value: function doCustomValidation(params) { var st = Date.parse(params.date_start); var et = Date.parse(params.date_end); if (st.compareTo(et) !== -1) { return 'Start time should be less than End time'; } /* var sd = Date.parse(this.currentTimesheet.date_start); var ed = Date.parse(this.currentTimesheet.date_end).addDays(1); if(sd.compareTo(et) != -1 || sd.compareTo(st) > 0 || st.compareTo(ed) != -1 || et.compareTo(ed) != -1){ return "Start time and end time shoud be with in " + sd.toString('MMM d, yyyy (dddd)') + " and " + ed.toString('MMM d, yyyy (dddd)'); } */ return null; } // eslint-disable-next-line no-unused-vars }, { key: "addSuccessCallBack", value: function addSuccessCallBack(callBackData, serverData) { this.get(callBackData); modJs.getTimeEntries(); } }, { key: "deleteRow", value: function deleteRow(id) { this.deleteObj(id, []); } // eslint-disable-next-line no-unused-vars }, { key: "deleteSuccessCallBack", value: function deleteSuccessCallBack(callBackData, serverData) { modJs.getTimeEntries(); } }]); return EmployeeTimeEntryAdapter; }(_AdapterBase3["default"]); /** * QtsheetAdapter */ var QtsheetAdapter = /*#__PURE__*/function (_TableEditAdapter) { _inherits(QtsheetAdapter, _TableEditAdapter); var _super4 = _createSuper(QtsheetAdapter); function QtsheetAdapter(endPoint, tab, filter, orderBy) { var _this5; _classCallCheck(this, QtsheetAdapter); _this5 = _super4.call(this, endPoint, tab, filter, orderBy); _this5.cellDataUpdates = {}; _this5.currentId = null; return _this5; } _createClass(QtsheetAdapter, [{ key: "validateCellValue", value: function validateCellValue(element, evt, newValue) { if (!ValidationRules["float"](newValue)) { return false; } var val = parseFloat(newValue); if (val < 0 || val > 24) { return false; } // Update total // Find current column number // Adding 2 because nth child is based on 1 and we are adding a virtual column for row names var coldNum = this.columnIDMap[element.data('colId')] + 2; var columnTotal = 0; var columnTotalWithoutCurrent = 0; $("#".concat(this.getTableName(), " tr td:nth-child(").concat(coldNum, ")")).each(function () { var rowId = $(this).data('rowId'); var tval = ''; if (element.data('rowId') === rowId) { tval = newValue; } else { tval = $(this).html(); } if (rowId !== -1) { if (ValidationRules["float"](tval)) { columnTotal += parseFloat(tval); if (element.data('rowId') !== rowId) { columnTotalWithoutCurrent += parseFloat(tval); } } } else if (columnTotal > 24) { $(this).html(columnTotalWithoutCurrent); } else { $(this).html(columnTotal); } }); if (columnTotal > 24) { return false; } modJs.addCellDataUpdate(element.data('colId'), element.data('rowId'), newValue); return true; } }, { key: "setCurrentTimeSheetId", value: function setCurrentTimeSheetId(val) { this.currentId = val; this.cellDataUpdates = {}; } }, { key: "addAdditionalRequestData", value: function addAdditionalRequestData(type, req) { if (type === 'updateData') { req.currentId = this.currentId; } else if (type === 'updateAllData') { req.currentId = this.currentId; } else if (type === 'getAllData') { req.currentId = this.currentId; } return req; } }, { key: "modifyCSVHeader", value: function modifyCSVHeader(header) { header.unshift(''); return header; } }, { key: "getCSVData", value: function getCSVData() { var csv = ''; for (var i = 0; i < this.csvData.length; i++) { csv += this.csvData[i].join(','); if (i < this.csvData.length - 1) { csv += '\r\n'; } } return csv; } }, { key: "downloadTimesheet", value: function downloadTimesheet() { var element = document.createElement('a'); element.setAttribute('href', "data:text/plain;charset=utf-8,".concat(encodeURIComponent(this.getCSVData()))); element.setAttribute('download', "timesheet_".concat(this.currentId, ".csv")); element.style.display = 'none'; document.body.appendChild(element); element.click(); document.body.removeChild(element); } }, { key: "createTable", value: function createTable(elementId) { var data = this.getTableData(); var headers = this.getHeaders(); if (this.showActionButtons()) { headers.push({ sTitle: '', sClass: 'center' }); } if (this.showActionButtons()) { for (var i = 0; i < data.length; i++) { data[i].push(this.getActionButtonsHtml(data[i][0], data[i])); } } var html = ''; html = "".concat(this.getTableTopButtonHtml(), "
    "); // Find current page var activePage = $("#".concat(elementId, " .dataTables_paginate .active a")).html(); var start = 0; if (activePage !== undefined && activePage !== null) { start = parseInt(activePage, 10) * 100 - 100; } $("#".concat(elementId)).html(html); var dataTableParams = { oLanguage: { sLengthMenu: '_MENU_ records per page' }, aaData: data, aoColumns: headers, bSort: false, iDisplayLength: 100, iDisplayStart: start }; var customTableParams = this.getCustomTableParams(); $.extend(dataTableParams, customTableParams); $("#".concat(elementId, " #grid")).dataTable(dataTableParams); $("#".concat(elementId, " #grid tr:last")).find('td').removeClass('editcell'); $('.dataTables_paginate ul').addClass('pagination'); $('.dataTables_length').hide(); $('.dataTables_filter input').addClass('form-control'); $('.dataTables_filter input').attr('placeholder', 'Search'); $('.dataTables_filter label').contents().filter(function () { return this.nodeType === 3; }).remove(); // $('.tableActionButton').tooltip(); $("#".concat(elementId, " #grid")).editableTableWidget(); $("#".concat(elementId, " #grid .editcell")).on('validate', function (evt, newValue) { return modJs.validateCellValue($(this), evt, newValue); }); } }]); return QtsheetAdapter; }(_TableEditAdapter2["default"]); module.exports = { EmployeeTimeSheetAdapter: EmployeeTimeSheetAdapter, SubEmployeeTimeSheetAdapter: SubEmployeeTimeSheetAdapter, EmployeeTimeEntryAdapter: EmployeeTimeEntryAdapter, QtsheetAdapter: QtsheetAdapter }; },{"../../../api/AdapterBase":39,"../../../api/FormValidation":44,"../../../api/TableEditAdapter":51}],94:[function(require,module,exports){ "use strict"; var _lib = require("./lib"); window.EmployeeImmigrationAdapter = _lib.EmployeeImmigrationAdapter; window.EmployeeTravelRecordAdapter = _lib.EmployeeTravelRecordAdapter; window.EmployeeTravelRecordApproverAdapter = _lib.EmployeeTravelRecordApproverAdapter; window.SubordinateEmployeeTravelRecordAdapter = _lib.SubordinateEmployeeTravelRecordAdapter; },{"./lib":95}],95:[function(require,module,exports){ "use strict"; var _AdapterBase2 = _interopRequireDefault(require("../../../api/AdapterBase")); var _ApproveModuleAdapter2 = _interopRequireDefault(require("../../../api/ApproveModuleAdapter")); var _lib = require("../../../admin/src/travel/lib"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(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, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { 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; } 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 { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 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 } }); if (superClass) _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } var EmployeeImmigrationAdapter = /*#__PURE__*/function (_AdapterBase) { _inherits(EmployeeImmigrationAdapter, _AdapterBase); var _super = _createSuper(EmployeeImmigrationAdapter); function EmployeeImmigrationAdapter() { _classCallCheck(this, EmployeeImmigrationAdapter); return _super.apply(this, arguments); } _createClass(EmployeeImmigrationAdapter, [{ key: "getDataMapping", value: function getDataMapping() { return ['id', 'document', 'documentname', 'valid_until', 'status']; } }, { key: "getHeaders", value: function getHeaders() { return [{ sTitle: 'ID', bVisible: false }, { sTitle: 'Document' }, { sTitle: 'Document Id' }, { sTitle: 'Valid Until' }, { sTitle: 'Status' }]; } }, { key: "getFormFields", value: function getFormFields() { return [['id', { label: 'ID', type: 'hidden' }], ['document', { label: 'Document', type: 'select2', 'remote-source': ['ImmigrationDocument', 'id', 'name'] }], ['documentname', { label: 'Document Id', type: 'text', validation: '' }], ['valid_until', { label: 'Valid Until', type: 'date', validation: 'none' }], ['status', { label: 'Status', type: 'select', source: [['Active', 'Active'], ['Inactive', 'Inactive'], ['Draft', 'Draft']] }], ['details', { label: 'Details', type: 'textarea', validation: 'none' }], ['attachment1', { label: 'Attachment 1', type: 'fileupload', validation: 'none' }], ['attachment2', { label: 'Attachment 2', type: 'fileupload', validation: 'none' }], ['attachment3', { label: 'Attachment 3', type: 'fileupload', validation: 'none' }]]; } }]); return EmployeeImmigrationAdapter; }(_AdapterBase2["default"]); var EmployeeTravelRecordAdapter = /*#__PURE__*/function (_ApproveModuleAdapter) { _inherits(EmployeeTravelRecordAdapter, _ApproveModuleAdapter); var _super2 = _createSuper(EmployeeTravelRecordAdapter); function EmployeeTravelRecordAdapter(endPoint, tab, filter, orderBy) { var _this; _classCallCheck(this, EmployeeTravelRecordAdapter); _this = _super2.call(this, endPoint, tab, filter, orderBy); _this.itemName = 'Travel'; _this.itemNameLower = 'employeetravelrecord'; _this.modulePathName = 'travel'; return _this; } _createClass(EmployeeTravelRecordAdapter, [{ key: "getDataMapping", value: function getDataMapping() { return ['id', 'type', 'purpose', 'travel_from', 'travel_to', 'travel_date', 'return_date', 'status']; } }, { key: "getHeaders", value: function getHeaders() { return [{ sTitle: 'ID', bVisible: false }, { sTitle: 'Travel Type' }, { sTitle: 'Purpose' }, { sTitle: 'From' }, { sTitle: 'To' }, { sTitle: 'Travel Date' }, { sTitle: 'Return Date' }, { sTitle: 'Status' }]; } }, { key: "getFormFields", value: function getFormFields() { return this.addCustomFields([['id', { label: 'ID', type: 'hidden' }], ['type', { label: 'Means of Transportation', type: 'select', source: [['Plane', 'Plane'], ['Rail', 'Rail'], ['Taxi', 'Taxi'], ['Own Vehicle', 'Own Vehicle'], ['Rented Vehicle', 'Rented Vehicle'], ['Other', 'Other']] }], ['purpose', { label: 'Purpose of Travel', type: 'textarea', validation: '' }], ['travel_from', { label: 'Travel From', type: 'text', validation: '' }], ['travel_to', { label: 'Travel To', type: 'text', validation: '' }], ['travel_date', { label: 'Travel Date', type: 'datetime', validation: '' }], ['return_date', { label: 'Return Date', type: 'datetime', validation: '' }], ['details', { label: 'Notes', type: 'textarea', validation: 'none' }], ['currency', { label: 'Currency', type: 'select2', 'allow-null': false, 'remote-source': ['CurrencyType', 'id', 'code'] }], ['funding', { label: 'Total Funding Proposed', type: 'text', validation: 'float', "default": '0.00', mask: '9{0,10}.99' }], ['attachment1', { label: 'Attachment', type: 'fileupload', validation: 'none' }], ['attachment2', { label: 'Attachment', type: 'fileupload', validation: 'none' }], ['attachment3', { label: 'Attachment', type: 'fileupload', validation: 'none' }]]); } }]); return EmployeeTravelRecordAdapter; }(_ApproveModuleAdapter2["default"]); /* EmployeeTravelRecordApproverAdapter */ var EmployeeTravelRecordApproverAdapter = /*#__PURE__*/function (_EmployeeTravelRecord) { _inherits(EmployeeTravelRecordApproverAdapter, _EmployeeTravelRecord); var _super3 = _createSuper(EmployeeTravelRecordApproverAdapter); function EmployeeTravelRecordApproverAdapter(endPoint, tab, filter, orderBy) { var _this2; _classCallCheck(this, EmployeeTravelRecordApproverAdapter); _this2 = _super3.call(this, endPoint, tab, filter, orderBy); _this2.itemName = 'Travel'; _this2.itemNameLower = 'employeetravelrecord'; _this2.modulePathName = 'travel'; return _this2; } _createClass(EmployeeTravelRecordApproverAdapter, [{ key: "getActionButtonsHtml", value: function getActionButtonsHtml(id, data) { var statusChangeButton = ''; var viewLogsButton = ''; var html = '
    _status__logs_
    '; html = html.replace('_logs_', viewLogsButton); if (data[this.getStatusFieldPosition()] === 'Processing') { html = html.replace('_status_', statusChangeButton); } else { html = html.replace('_status_', ''); } html = html.replace(/_id_/g, id); html = html.replace(/_BASE_/g, this.baseUrl); html = html.replace(/_cstatus_/g, data[this.getStatusFieldPosition()]); return html; } }, { key: "getStatusOptionsData", value: function getStatusOptionsData(currentStatus) { var data = {}; if (currentStatus === 'Processing') { data.Approved = 'Approved'; data.Rejected = 'Rejected'; } return data; } }, { key: "getStatusOptions", value: function getStatusOptions(currentStatus) { return this.generateOptions(this.getStatusOptionsData(currentStatus)); } }]); return EmployeeTravelRecordApproverAdapter; }(_lib.EmployeeTravelRecordAdminAdapter); /* SubordinateExpenseModuleAdapter */ var SubordinateEmployeeTravelRecordAdapter = /*#__PURE__*/function (_EmployeeTravelRecord2) { _inherits(SubordinateEmployeeTravelRecordAdapter, _EmployeeTravelRecord2); var _super4 = _createSuper(SubordinateEmployeeTravelRecordAdapter); function SubordinateEmployeeTravelRecordAdapter(endPoint, tab, filter, orderBy) { var _this3; _classCallCheck(this, SubordinateEmployeeTravelRecordAdapter); _this3 = _super4.call(this, endPoint, tab, filter, orderBy); _this3.itemName = 'Travel'; _this3.itemNameLower = 'employeetravelrecord'; _this3.modulePathName = 'travel'; return _this3; } return SubordinateEmployeeTravelRecordAdapter; }(_lib.EmployeeTravelRecordAdminAdapter); module.exports = { EmployeeImmigrationAdapter: EmployeeImmigrationAdapter, EmployeeTravelRecordAdapter: EmployeeTravelRecordAdapter, EmployeeTravelRecordApproverAdapter: EmployeeTravelRecordApproverAdapter, SubordinateEmployeeTravelRecordAdapter: SubordinateEmployeeTravelRecordAdapter }; },{"../../../admin/src/travel/lib":37,"../../../api/AdapterBase":39,"../../../api/ApproveModuleAdapter":41}],96:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _react = require('react'); var _react2 = _interopRequireDefault(_react); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } var DEFAULT_SIZE = 24; exports.default = function (_ref) { var _ref$fill = _ref.fill, fill = _ref$fill === undefined ? 'currentColor' : _ref$fill, _ref$width = _ref.width, width = _ref$width === undefined ? DEFAULT_SIZE : _ref$width, _ref$height = _ref.height, height = _ref$height === undefined ? DEFAULT_SIZE : _ref$height, _ref$style = _ref.style, style = _ref$style === undefined ? {} : _ref$style, props = _objectWithoutProperties(_ref, ['fill', 'width', 'height', 'style']); return _react2.default.createElement( 'svg', _extends({ viewBox: '0 0 ' + DEFAULT_SIZE + ' ' + DEFAULT_SIZE, style: _extends({ fill: fill, width: width, height: height }, style) }, props), _react2.default.createElement('path', { d: 'M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z' }) ); }; },{"react":"react"}],97:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _react = require('react'); var _react2 = _interopRequireDefault(_react); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } var DEFAULT_SIZE = 24; exports.default = function (_ref) { var _ref$fill = _ref.fill, fill = _ref$fill === undefined ? 'currentColor' : _ref$fill, _ref$width = _ref.width, width = _ref$width === undefined ? DEFAULT_SIZE : _ref$width, _ref$height = _ref.height, height = _ref$height === undefined ? DEFAULT_SIZE : _ref$height, _ref$style = _ref.style, style = _ref$style === undefined ? {} : _ref$style, props = _objectWithoutProperties(_ref, ['fill', 'width', 'height', 'style']); return _react2.default.createElement( 'svg', _extends({ viewBox: '0 0 ' + DEFAULT_SIZE + ' ' + DEFAULT_SIZE, style: _extends({ fill: fill, width: width, height: height }, style) }, props), _react2.default.createElement('path', { d: 'M12,18.17L8.83,15L7.42,16.41L12,21L16.59,16.41L15.17,15M12,5.83L15.17,9L16.58,7.59L12,3L7.41,7.59L8.83,9L12,5.83Z' }) ); }; },{"react":"react"}],98:[function(require,module,exports){ module.exports = require('./lib/axios'); },{"./lib/axios":100}],99:[function(require,module,exports){ 'use strict'; var utils = require('./../utils'); var settle = require('./../core/settle'); var cookies = require('./../helpers/cookies'); var buildURL = require('./../helpers/buildURL'); var buildFullPath = require('../core/buildFullPath'); var parseHeaders = require('./../helpers/parseHeaders'); var isURLSameOrigin = require('./../helpers/isURLSameOrigin'); var createError = require('../core/createError'); module.exports = function xhrAdapter(config) { return new Promise(function dispatchXhrRequest(resolve, reject) { var requestData = config.data; var requestHeaders = config.headers; if (utils.isFormData(requestData)) { delete requestHeaders['Content-Type']; // Let the browser set it } if ( (utils.isBlob(requestData) || utils.isFile(requestData)) && requestData.type ) { delete requestHeaders['Content-Type']; // Let the browser set it } var request = new XMLHttpRequest(); // HTTP basic authentication if (config.auth) { var username = config.auth.username || ''; var password = unescape(encodeURIComponent(config.auth.password)) || ''; requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password); } var fullPath = buildFullPath(config.baseURL, config.url); request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true); // Set the request timeout in MS request.timeout = config.timeout; // Listen for ready state request.onreadystatechange = function handleLoad() { if (!request || request.readyState !== 4) { return; } // The request errored out and we didn't get a response, this will be // handled by onerror instead // With one exception: request that using file: protocol, most browsers // will return status as 0 even though it's a successful request if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) { return; } // Prepare the response var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null; var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response; var response = { data: responseData, status: request.status, statusText: request.statusText, headers: responseHeaders, config: config, request: request }; settle(resolve, reject, response); // Clean up request request = null; }; // Handle browser request cancellation (as opposed to a manual cancellation) request.onabort = function handleAbort() { if (!request) { return; } reject(createError('Request aborted', config, 'ECONNABORTED', request)); // Clean up request request = null; }; // Handle low level network errors request.onerror = function handleError() { // Real errors are hidden from us by the browser // onerror should only fire if it's a network error reject(createError('Network Error', config, null, request)); // Clean up request request = null; }; // Handle timeout request.ontimeout = function handleTimeout() { var timeoutErrorMessage = 'timeout of ' + config.timeout + 'ms exceeded'; if (config.timeoutErrorMessage) { timeoutErrorMessage = config.timeoutErrorMessage; } reject(createError(timeoutErrorMessage, config, 'ECONNABORTED', request)); // Clean up request request = null; }; // Add xsrf header // This is only done if running in a standard browser environment. // Specifically not if we're in a web worker, or react-native. if (utils.isStandardBrowserEnv()) { // Add xsrf header var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ? cookies.read(config.xsrfCookieName) : undefined; if (xsrfValue) { requestHeaders[config.xsrfHeaderName] = xsrfValue; } } // Add headers to the request if ('setRequestHeader' in request) { utils.forEach(requestHeaders, function setRequestHeader(val, key) { if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') { // Remove Content-Type if data is undefined delete requestHeaders[key]; } else { // Otherwise add header to the request request.setRequestHeader(key, val); } }); } // Add withCredentials to request if needed if (!utils.isUndefined(config.withCredentials)) { request.withCredentials = !!config.withCredentials; } // Add responseType to request if needed if (config.responseType) { try { request.responseType = config.responseType; } catch (e) { // Expected DOMException thrown by browsers not compatible XMLHttpRequest Level 2. // But, this can be suppressed for 'json' type as it can be parsed by default 'transformResponse' function. if (config.responseType !== 'json') { throw e; } } } // Handle progress if needed if (typeof config.onDownloadProgress === 'function') { request.addEventListener('progress', config.onDownloadProgress); } // Not all browsers support upload events if (typeof config.onUploadProgress === 'function' && request.upload) { request.upload.addEventListener('progress', config.onUploadProgress); } if (config.cancelToken) { // Handle cancellation config.cancelToken.promise.then(function onCanceled(cancel) { if (!request) { return; } request.abort(); reject(cancel); // Clean up request request = null; }); } if (!requestData) { requestData = null; } // Send the request request.send(requestData); }); }; },{"../core/buildFullPath":106,"../core/createError":107,"./../core/settle":111,"./../helpers/buildURL":115,"./../helpers/cookies":117,"./../helpers/isURLSameOrigin":119,"./../helpers/parseHeaders":121,"./../utils":123}],100:[function(require,module,exports){ 'use strict'; var utils = require('./utils'); var bind = require('./helpers/bind'); var Axios = require('./core/Axios'); var mergeConfig = require('./core/mergeConfig'); var defaults = require('./defaults'); /** * Create an instance of Axios * * @param {Object} defaultConfig The default config for the instance * @return {Axios} A new instance of Axios */ function createInstance(defaultConfig) { var context = new Axios(defaultConfig); var instance = bind(Axios.prototype.request, context); // Copy axios.prototype to instance utils.extend(instance, Axios.prototype, context); // Copy context to instance utils.extend(instance, context); return instance; } // Create the default instance to be exported var axios = createInstance(defaults); // Expose Axios class to allow class inheritance axios.Axios = Axios; // Factory for creating new instances axios.create = function create(instanceConfig) { return createInstance(mergeConfig(axios.defaults, instanceConfig)); }; // Expose Cancel & CancelToken axios.Cancel = require('./cancel/Cancel'); axios.CancelToken = require('./cancel/CancelToken'); axios.isCancel = require('./cancel/isCancel'); // Expose all/spread axios.all = function all(promises) { return Promise.all(promises); }; axios.spread = require('./helpers/spread'); module.exports = axios; // Allow use of default import syntax in TypeScript module.exports.default = axios; },{"./cancel/Cancel":101,"./cancel/CancelToken":102,"./cancel/isCancel":103,"./core/Axios":104,"./core/mergeConfig":110,"./defaults":113,"./helpers/bind":114,"./helpers/spread":122,"./utils":123}],101:[function(require,module,exports){ 'use strict'; /** * A `Cancel` is an object that is thrown when an operation is canceled. * * @class * @param {string=} message The message. */ function Cancel(message) { this.message = message; } Cancel.prototype.toString = function toString() { return 'Cancel' + (this.message ? ': ' + this.message : ''); }; Cancel.prototype.__CANCEL__ = true; module.exports = Cancel; },{}],102:[function(require,module,exports){ 'use strict'; var Cancel = require('./Cancel'); /** * A `CancelToken` is an object that can be used to request cancellation of an operation. * * @class * @param {Function} executor The executor function. */ function CancelToken(executor) { if (typeof executor !== 'function') { throw new TypeError('executor must be a function.'); } var resolvePromise; this.promise = new Promise(function promiseExecutor(resolve) { resolvePromise = resolve; }); var token = this; executor(function cancel(message) { if (token.reason) { // Cancellation has already been requested return; } token.reason = new Cancel(message); resolvePromise(token.reason); }); } /** * Throws a `Cancel` if cancellation has been requested. */ CancelToken.prototype.throwIfRequested = function throwIfRequested() { if (this.reason) { throw this.reason; } }; /** * Returns an object that contains a new `CancelToken` and a function that, when called, * cancels the `CancelToken`. */ CancelToken.source = function source() { var cancel; var token = new CancelToken(function executor(c) { cancel = c; }); return { token: token, cancel: cancel }; }; module.exports = CancelToken; },{"./Cancel":101}],103:[function(require,module,exports){ 'use strict'; module.exports = function isCancel(value) { return !!(value && value.__CANCEL__); }; },{}],104:[function(require,module,exports){ 'use strict'; var utils = require('./../utils'); var buildURL = require('../helpers/buildURL'); var InterceptorManager = require('./InterceptorManager'); var dispatchRequest = require('./dispatchRequest'); var mergeConfig = require('./mergeConfig'); /** * Create a new instance of Axios * * @param {Object} instanceConfig The default config for the instance */ function Axios(instanceConfig) { this.defaults = instanceConfig; this.interceptors = { request: new InterceptorManager(), response: new InterceptorManager() }; } /** * Dispatch a request * * @param {Object} config The config specific for this request (merged with this.defaults) */ Axios.prototype.request = function request(config) { /*eslint no-param-reassign:0*/ // Allow for axios('example/url'[, config]) a la fetch API if (typeof config === 'string') { config = arguments[1] || {}; config.url = arguments[0]; } else { config = config || {}; } config = mergeConfig(this.defaults, config); // Set config.method if (config.method) { config.method = config.method.toLowerCase(); } else if (this.defaults.method) { config.method = this.defaults.method.toLowerCase(); } else { config.method = 'get'; } // Hook up interceptors middleware var chain = [dispatchRequest, undefined]; var promise = Promise.resolve(config); this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) { chain.unshift(interceptor.fulfilled, interceptor.rejected); }); this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) { chain.push(interceptor.fulfilled, interceptor.rejected); }); while (chain.length) { promise = promise.then(chain.shift(), chain.shift()); } return promise; }; Axios.prototype.getUri = function getUri(config) { config = mergeConfig(this.defaults, config); return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, ''); }; // Provide aliases for supported request methods utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) { /*eslint func-names:0*/ Axios.prototype[method] = function(url, config) { return this.request(mergeConfig(config || {}, { method: method, url: url })); }; }); utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) { /*eslint func-names:0*/ Axios.prototype[method] = function(url, data, config) { return this.request(mergeConfig(config || {}, { method: method, url: url, data: data })); }; }); module.exports = Axios; },{"../helpers/buildURL":115,"./../utils":123,"./InterceptorManager":105,"./dispatchRequest":108,"./mergeConfig":110}],105:[function(require,module,exports){ 'use strict'; var utils = require('./../utils'); function InterceptorManager() { this.handlers = []; } /** * Add a new interceptor to the stack * * @param {Function} fulfilled The function to handle `then` for a `Promise` * @param {Function} rejected The function to handle `reject` for a `Promise` * * @return {Number} An ID used to remove interceptor later */ InterceptorManager.prototype.use = function use(fulfilled, rejected) { this.handlers.push({ fulfilled: fulfilled, rejected: rejected }); return this.handlers.length - 1; }; /** * Remove an interceptor from the stack * * @param {Number} id The ID that was returned by `use` */ InterceptorManager.prototype.eject = function eject(id) { if (this.handlers[id]) { this.handlers[id] = null; } }; /** * Iterate over all the registered interceptors * * This method is particularly useful for skipping over any * interceptors that may have become `null` calling `eject`. * * @param {Function} fn The function to call for each interceptor */ InterceptorManager.prototype.forEach = function forEach(fn) { utils.forEach(this.handlers, function forEachHandler(h) { if (h !== null) { fn(h); } }); }; module.exports = InterceptorManager; },{"./../utils":123}],106:[function(require,module,exports){ 'use strict'; var isAbsoluteURL = require('../helpers/isAbsoluteURL'); var combineURLs = require('../helpers/combineURLs'); /** * Creates a new URL by combining the baseURL with the requestedURL, * only when the requestedURL is not already an absolute URL. * If the requestURL is absolute, this function returns the requestedURL untouched. * * @param {string} baseURL The base URL * @param {string} requestedURL Absolute or relative URL to combine * @returns {string} The combined full path */ module.exports = function buildFullPath(baseURL, requestedURL) { if (baseURL && !isAbsoluteURL(requestedURL)) { return combineURLs(baseURL, requestedURL); } return requestedURL; }; },{"../helpers/combineURLs":116,"../helpers/isAbsoluteURL":118}],107:[function(require,module,exports){ 'use strict'; var enhanceError = require('./enhanceError'); /** * Create an Error with the specified message, config, error code, request and response. * * @param {string} message The error message. * @param {Object} config The config. * @param {string} [code] The error code (for example, 'ECONNABORTED'). * @param {Object} [request] The request. * @param {Object} [response] The response. * @returns {Error} The created error. */ module.exports = function createError(message, config, code, request, response) { var error = new Error(message); return enhanceError(error, config, code, request, response); }; },{"./enhanceError":109}],108:[function(require,module,exports){ 'use strict'; var utils = require('./../utils'); var transformData = require('./transformData'); var isCancel = require('../cancel/isCancel'); var defaults = require('../defaults'); /** * Throws a `Cancel` if cancellation has been requested. */ function throwIfCancellationRequested(config) { if (config.cancelToken) { config.cancelToken.throwIfRequested(); } } /** * Dispatch a request to the server using the configured adapter. * * @param {object} config The config that is to be used for the request * @returns {Promise} The Promise to be fulfilled */ module.exports = function dispatchRequest(config) { throwIfCancellationRequested(config); // Ensure headers exist config.headers = config.headers || {}; // Transform request data config.data = transformData( config.data, config.headers, config.transformRequest ); // Flatten headers config.headers = utils.merge( config.headers.common || {}, config.headers[config.method] || {}, config.headers ); utils.forEach( ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'], function cleanHeaderConfig(method) { delete config.headers[method]; } ); var adapter = config.adapter || defaults.adapter; return adapter(config).then(function onAdapterResolution(response) { throwIfCancellationRequested(config); // Transform response data response.data = transformData( response.data, response.headers, config.transformResponse ); return response; }, function onAdapterRejection(reason) { if (!isCancel(reason)) { throwIfCancellationRequested(config); // Transform response data if (reason && reason.response) { reason.response.data = transformData( reason.response.data, reason.response.headers, config.transformResponse ); } } return Promise.reject(reason); }); }; },{"../cancel/isCancel":103,"../defaults":113,"./../utils":123,"./transformData":112}],109:[function(require,module,exports){ 'use strict'; /** * Update an Error with the specified config, error code, and response. * * @param {Error} error The error to update. * @param {Object} config The config. * @param {string} [code] The error code (for example, 'ECONNABORTED'). * @param {Object} [request] The request. * @param {Object} [response] The response. * @returns {Error} The error. */ module.exports = function enhanceError(error, config, code, request, response) { error.config = config; if (code) { error.code = code; } error.request = request; error.response = response; error.isAxiosError = true; error.toJSON = function toJSON() { return { // Standard message: this.message, name: this.name, // Microsoft description: this.description, number: this.number, // Mozilla fileName: this.fileName, lineNumber: this.lineNumber, columnNumber: this.columnNumber, stack: this.stack, // Axios config: this.config, code: this.code }; }; return error; }; },{}],110:[function(require,module,exports){ 'use strict'; var utils = require('../utils'); /** * Config-specific merge-function which creates a new config-object * by merging two configuration objects together. * * @param {Object} config1 * @param {Object} config2 * @returns {Object} New object resulting from merging config2 to config1 */ module.exports = function mergeConfig(config1, config2) { // eslint-disable-next-line no-param-reassign config2 = config2 || {}; var config = {}; var valueFromConfig2Keys = ['url', 'method', 'data']; var mergeDeepPropertiesKeys = ['headers', 'auth', 'proxy', 'params']; var defaultToConfig2Keys = [ 'baseURL', 'transformRequest', 'transformResponse', 'paramsSerializer', 'timeout', 'timeoutMessage', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName', 'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress', 'decompress', 'maxContentLength', 'maxBodyLength', 'maxRedirects', 'transport', 'httpAgent', 'httpsAgent', 'cancelToken', 'socketPath', 'responseEncoding' ]; var directMergeKeys = ['validateStatus']; function getMergedValue(target, source) { if (utils.isPlainObject(target) && utils.isPlainObject(source)) { return utils.merge(target, source); } else if (utils.isPlainObject(source)) { return utils.merge({}, source); } else if (utils.isArray(source)) { return source.slice(); } return source; } function mergeDeepProperties(prop) { if (!utils.isUndefined(config2[prop])) { config[prop] = getMergedValue(config1[prop], config2[prop]); } else if (!utils.isUndefined(config1[prop])) { config[prop] = getMergedValue(undefined, config1[prop]); } } utils.forEach(valueFromConfig2Keys, function valueFromConfig2(prop) { if (!utils.isUndefined(config2[prop])) { config[prop] = getMergedValue(undefined, config2[prop]); } }); utils.forEach(mergeDeepPropertiesKeys, mergeDeepProperties); utils.forEach(defaultToConfig2Keys, function defaultToConfig2(prop) { if (!utils.isUndefined(config2[prop])) { config[prop] = getMergedValue(undefined, config2[prop]); } else if (!utils.isUndefined(config1[prop])) { config[prop] = getMergedValue(undefined, config1[prop]); } }); utils.forEach(directMergeKeys, function merge(prop) { if (prop in config2) { config[prop] = getMergedValue(config1[prop], config2[prop]); } else if (prop in config1) { config[prop] = getMergedValue(undefined, config1[prop]); } }); var axiosKeys = valueFromConfig2Keys .concat(mergeDeepPropertiesKeys) .concat(defaultToConfig2Keys) .concat(directMergeKeys); var otherKeys = Object .keys(config1) .concat(Object.keys(config2)) .filter(function filterAxiosKeys(key) { return axiosKeys.indexOf(key) === -1; }); utils.forEach(otherKeys, mergeDeepProperties); return config; }; },{"../utils":123}],111:[function(require,module,exports){ 'use strict'; var createError = require('./createError'); /** * Resolve or reject a Promise based on response status. * * @param {Function} resolve A function that resolves the promise. * @param {Function} reject A function that rejects the promise. * @param {object} response The response. */ module.exports = function settle(resolve, reject, response) { var validateStatus = response.config.validateStatus; if (!response.status || !validateStatus || validateStatus(response.status)) { resolve(response); } else { reject(createError( 'Request failed with status code ' + response.status, response.config, null, response.request, response )); } }; },{"./createError":107}],112:[function(require,module,exports){ 'use strict'; var utils = require('./../utils'); /** * Transform the data for a request or a response * * @param {Object|String} data The data to be transformed * @param {Array} headers The headers for the request or response * @param {Array|Function} fns A single function or Array of functions * @returns {*} The resulting transformed data */ module.exports = function transformData(data, headers, fns) { /*eslint no-param-reassign:0*/ utils.forEach(fns, function transform(fn) { data = fn(data, headers); }); return data; }; },{"./../utils":123}],113:[function(require,module,exports){ (function (process){ 'use strict'; var utils = require('./utils'); var normalizeHeaderName = require('./helpers/normalizeHeaderName'); var DEFAULT_CONTENT_TYPE = { 'Content-Type': 'application/x-www-form-urlencoded' }; function setContentTypeIfUnset(headers, value) { if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) { headers['Content-Type'] = value; } } function getDefaultAdapter() { var adapter; if (typeof XMLHttpRequest !== 'undefined') { // For browsers use XHR adapter adapter = require('./adapters/xhr'); } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') { // For node use HTTP adapter adapter = require('./adapters/http'); } return adapter; } var defaults = { adapter: getDefaultAdapter(), transformRequest: [function transformRequest(data, headers) { normalizeHeaderName(headers, 'Accept'); normalizeHeaderName(headers, 'Content-Type'); if (utils.isFormData(data) || utils.isArrayBuffer(data) || utils.isBuffer(data) || utils.isStream(data) || utils.isFile(data) || utils.isBlob(data) ) { return data; } if (utils.isArrayBufferView(data)) { return data.buffer; } if (utils.isURLSearchParams(data)) { setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8'); return data.toString(); } if (utils.isObject(data)) { setContentTypeIfUnset(headers, 'application/json;charset=utf-8'); return JSON.stringify(data); } return data; }], transformResponse: [function transformResponse(data) { /*eslint no-param-reassign:0*/ if (typeof data === 'string') { try { data = JSON.parse(data); } catch (e) { /* Ignore */ } } return data; }], /** * A timeout in milliseconds to abort a request. If set to 0 (default) a * timeout is not created. */ timeout: 0, xsrfCookieName: 'XSRF-TOKEN', xsrfHeaderName: 'X-XSRF-TOKEN', maxContentLength: -1, maxBodyLength: -1, validateStatus: function validateStatus(status) { return status >= 200 && status < 300; } }; defaults.headers = { common: { 'Accept': 'application/json, text/plain, */*' } }; utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) { defaults.headers[method] = {}; }); utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) { defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE); }); module.exports = defaults; }).call(this,require('_process')) },{"./adapters/http":99,"./adapters/xhr":99,"./helpers/normalizeHeaderName":120,"./utils":123,"_process":6}],114:[function(require,module,exports){ 'use strict'; module.exports = function bind(fn, thisArg) { return function wrap() { var args = new Array(arguments.length); for (var i = 0; i < args.length; i++) { args[i] = arguments[i]; } return fn.apply(thisArg, args); }; }; },{}],115:[function(require,module,exports){ 'use strict'; var utils = require('./../utils'); function encode(val) { return encodeURIComponent(val). replace(/%3A/gi, ':'). replace(/%24/g, '$'). replace(/%2C/gi, ','). replace(/%20/g, '+'). replace(/%5B/gi, '['). replace(/%5D/gi, ']'); } /** * Build a URL by appending params to the end * * @param {string} url The base of the url (e.g., http://www.google.com) * @param {object} [params] The params to be appended * @returns {string} The formatted url */ module.exports = function buildURL(url, params, paramsSerializer) { /*eslint no-param-reassign:0*/ if (!params) { return url; } var serializedParams; if (paramsSerializer) { serializedParams = paramsSerializer(params); } else if (utils.isURLSearchParams(params)) { serializedParams = params.toString(); } else { var parts = []; utils.forEach(params, function serialize(val, key) { if (val === null || typeof val === 'undefined') { return; } if (utils.isArray(val)) { key = key + '[]'; } else { val = [val]; } utils.forEach(val, function parseValue(v) { if (utils.isDate(v)) { v = v.toISOString(); } else if (utils.isObject(v)) { v = JSON.stringify(v); } parts.push(encode(key) + '=' + encode(v)); }); }); serializedParams = parts.join('&'); } if (serializedParams) { var hashmarkIndex = url.indexOf('#'); if (hashmarkIndex !== -1) { url = url.slice(0, hashmarkIndex); } url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams; } return url; }; },{"./../utils":123}],116:[function(require,module,exports){ 'use strict'; /** * Creates a new URL by combining the specified URLs * * @param {string} baseURL The base URL * @param {string} relativeURL The relative URL * @returns {string} The combined URL */ module.exports = function combineURLs(baseURL, relativeURL) { return relativeURL ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '') : baseURL; }; },{}],117:[function(require,module,exports){ 'use strict'; var utils = require('./../utils'); module.exports = ( utils.isStandardBrowserEnv() ? // Standard browser envs support document.cookie (function standardBrowserEnv() { return { write: function write(name, value, expires, path, domain, secure) { var cookie = []; cookie.push(name + '=' + encodeURIComponent(value)); if (utils.isNumber(expires)) { cookie.push('expires=' + new Date(expires).toGMTString()); } if (utils.isString(path)) { cookie.push('path=' + path); } if (utils.isString(domain)) { cookie.push('domain=' + domain); } if (secure === true) { cookie.push('secure'); } document.cookie = cookie.join('; '); }, read: function read(name) { var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)')); return (match ? decodeURIComponent(match[3]) : null); }, remove: function remove(name) { this.write(name, '', Date.now() - 86400000); } }; })() : // Non standard browser env (web workers, react-native) lack needed support. (function nonStandardBrowserEnv() { return { write: function write() {}, read: function read() { return null; }, remove: function remove() {} }; })() ); },{"./../utils":123}],118:[function(require,module,exports){ 'use strict'; /** * Determines whether the specified URL is absolute * * @param {string} url The URL to test * @returns {boolean} True if the specified URL is absolute, otherwise false */ module.exports = function isAbsoluteURL(url) { // A URL is considered absolute if it begins with "://" or "//" (protocol-relative URL). // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed // by any combination of letters, digits, plus, period, or hyphen. return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url); }; },{}],119:[function(require,module,exports){ 'use strict'; var utils = require('./../utils'); module.exports = ( utils.isStandardBrowserEnv() ? // Standard browser envs have full support of the APIs needed to test // whether the request URL is of the same origin as current location. (function standardBrowserEnv() { var msie = /(msie|trident)/i.test(navigator.userAgent); var urlParsingNode = document.createElement('a'); var originURL; /** * Parse a URL to discover it's components * * @param {String} url The URL to be parsed * @returns {Object} */ function resolveURL(url) { var href = url; if (msie) { // IE needs attribute set twice to normalize properties urlParsingNode.setAttribute('href', href); href = urlParsingNode.href; } urlParsingNode.setAttribute('href', href); // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils return { href: urlParsingNode.href, protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '', host: urlParsingNode.host, search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '', hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '', hostname: urlParsingNode.hostname, port: urlParsingNode.port, pathname: (urlParsingNode.pathname.charAt(0) === '/') ? urlParsingNode.pathname : '/' + urlParsingNode.pathname }; } originURL = resolveURL(window.location.href); /** * Determine if a URL shares the same origin as the current location * * @param {String} requestURL The URL to test * @returns {boolean} True if URL shares the same origin, otherwise false */ return function isURLSameOrigin(requestURL) { var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL; return (parsed.protocol === originURL.protocol && parsed.host === originURL.host); }; })() : // Non standard browser envs (web workers, react-native) lack needed support. (function nonStandardBrowserEnv() { return function isURLSameOrigin() { return true; }; })() ); },{"./../utils":123}],120:[function(require,module,exports){ 'use strict'; var utils = require('../utils'); module.exports = function normalizeHeaderName(headers, normalizedName) { utils.forEach(headers, function processHeader(value, name) { if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) { headers[normalizedName] = value; delete headers[name]; } }); }; },{"../utils":123}],121:[function(require,module,exports){ 'use strict'; var utils = require('./../utils'); // Headers whose duplicates are ignored by node // c.f. https://nodejs.org/api/http.html#http_message_headers var ignoreDuplicateOf = [ 'age', 'authorization', 'content-length', 'content-type', 'etag', 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since', 'last-modified', 'location', 'max-forwards', 'proxy-authorization', 'referer', 'retry-after', 'user-agent' ]; /** * Parse headers into an object * * ``` * Date: Wed, 27 Aug 2014 08:58:49 GMT * Content-Type: application/json * Connection: keep-alive * Transfer-Encoding: chunked * ``` * * @param {String} headers Headers needing to be parsed * @returns {Object} Headers parsed into an object */ module.exports = function parseHeaders(headers) { var parsed = {}; var key; var val; var i; if (!headers) { return parsed; } utils.forEach(headers.split('\n'), function parser(line) { i = line.indexOf(':'); key = utils.trim(line.substr(0, i)).toLowerCase(); val = utils.trim(line.substr(i + 1)); if (key) { if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) { return; } if (key === 'set-cookie') { parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]); } else { parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val; } } }); return parsed; }; },{"./../utils":123}],122:[function(require,module,exports){ 'use strict'; /** * Syntactic sugar for invoking a function and expanding an array for arguments. * * Common use case would be to use `Function.prototype.apply`. * * ```js * function f(x, y, z) {} * var args = [1, 2, 3]; * f.apply(null, args); * ``` * * With `spread` this example can be re-written. * * ```js * spread(function(x, y, z) {})([1, 2, 3]); * ``` * * @param {Function} callback * @returns {Function} */ module.exports = function spread(callback) { return function wrap(arr) { return callback.apply(null, arr); }; }; },{}],123:[function(require,module,exports){ 'use strict'; var bind = require('./helpers/bind'); /*global toString:true*/ // utils is a library of generic helper functions non-specific to axios var toString = Object.prototype.toString; /** * Determine if a value is an Array * * @param {Object} val The value to test * @returns {boolean} True if value is an Array, otherwise false */ function isArray(val) { return toString.call(val) === '[object Array]'; } /** * Determine if a value is undefined * * @param {Object} val The value to test * @returns {boolean} True if the value is undefined, otherwise false */ function isUndefined(val) { return typeof val === 'undefined'; } /** * Determine if a value is a Buffer * * @param {Object} val The value to test * @returns {boolean} True if value is a Buffer, otherwise false */ function isBuffer(val) { return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor) && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val); } /** * Determine if a value is an ArrayBuffer * * @param {Object} val The value to test * @returns {boolean} True if value is an ArrayBuffer, otherwise false */ function isArrayBuffer(val) { return toString.call(val) === '[object ArrayBuffer]'; } /** * Determine if a value is a FormData * * @param {Object} val The value to test * @returns {boolean} True if value is an FormData, otherwise false */ function isFormData(val) { return (typeof FormData !== 'undefined') && (val instanceof FormData); } /** * Determine if a value is a view on an ArrayBuffer * * @param {Object} val The value to test * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false */ function isArrayBufferView(val) { var result; if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) { result = ArrayBuffer.isView(val); } else { result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer); } return result; } /** * Determine if a value is a String * * @param {Object} val The value to test * @returns {boolean} True if value is a String, otherwise false */ function isString(val) { return typeof val === 'string'; } /** * Determine if a value is a Number * * @param {Object} val The value to test * @returns {boolean} True if value is a Number, otherwise false */ function isNumber(val) { return typeof val === 'number'; } /** * Determine if a value is an Object * * @param {Object} val The value to test * @returns {boolean} True if value is an Object, otherwise false */ function isObject(val) { return val !== null && typeof val === 'object'; } /** * Determine if a value is a plain Object * * @param {Object} val The value to test * @return {boolean} True if value is a plain Object, otherwise false */ function isPlainObject(val) { if (toString.call(val) !== '[object Object]') { return false; } var prototype = Object.getPrototypeOf(val); return prototype === null || prototype === Object.prototype; } /** * Determine if a value is a Date * * @param {Object} val The value to test * @returns {boolean} True if value is a Date, otherwise false */ function isDate(val) { return toString.call(val) === '[object Date]'; } /** * Determine if a value is a File * * @param {Object} val The value to test * @returns {boolean} True if value is a File, otherwise false */ function isFile(val) { return toString.call(val) === '[object File]'; } /** * Determine if a value is a Blob * * @param {Object} val The value to test * @returns {boolean} True if value is a Blob, otherwise false */ function isBlob(val) { return toString.call(val) === '[object Blob]'; } /** * Determine if a value is a Function * * @param {Object} val The value to test * @returns {boolean} True if value is a Function, otherwise false */ function isFunction(val) { return toString.call(val) === '[object Function]'; } /** * Determine if a value is a Stream * * @param {Object} val The value to test * @returns {boolean} True if value is a Stream, otherwise false */ function isStream(val) { return isObject(val) && isFunction(val.pipe); } /** * Determine if a value is a URLSearchParams object * * @param {Object} val The value to test * @returns {boolean} True if value is a URLSearchParams object, otherwise false */ function isURLSearchParams(val) { return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams; } /** * Trim excess whitespace off the beginning and end of a string * * @param {String} str The String to trim * @returns {String} The String freed of excess whitespace */ function trim(str) { return str.replace(/^\s*/, '').replace(/\s*$/, ''); } /** * Determine if we're running in a standard browser environment * * This allows axios to run in a web worker, and react-native. * Both environments support XMLHttpRequest, but not fully standard globals. * * web workers: * typeof window -> undefined * typeof document -> undefined * * react-native: * navigator.product -> 'ReactNative' * nativescript * navigator.product -> 'NativeScript' or 'NS' */ function isStandardBrowserEnv() { if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' || navigator.product === 'NativeScript' || navigator.product === 'NS')) { return false; } return ( typeof window !== 'undefined' && typeof document !== 'undefined' ); } /** * Iterate over an Array or an Object invoking a function for each item. * * If `obj` is an Array callback will be called passing * the value, index, and complete array for each item. * * If 'obj' is an Object callback will be called passing * the value, key, and complete object for each property. * * @param {Object|Array} obj The object to iterate * @param {Function} fn The callback to invoke for each item */ function forEach(obj, fn) { // Don't bother if no value provided if (obj === null || typeof obj === 'undefined') { return; } // Force an array if not already something iterable if (typeof obj !== 'object') { /*eslint no-param-reassign:0*/ obj = [obj]; } if (isArray(obj)) { // Iterate over array values for (var i = 0, l = obj.length; i < l; i++) { fn.call(null, obj[i], i, obj); } } else { // Iterate over object keys for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { fn.call(null, obj[key], key, obj); } } } } /** * Accepts varargs expecting each argument to be an object, then * immutably merges the properties of each object and returns result. * * When multiple objects contain the same key the later object in * the arguments list will take precedence. * * Example: * * ```js * var result = merge({foo: 123}, {foo: 456}); * console.log(result.foo); // outputs 456 * ``` * * @param {Object} obj1 Object to merge * @returns {Object} Result of all merge properties */ function merge(/* obj1, obj2, obj3, ... */) { var result = {}; function assignValue(val, key) { if (isPlainObject(result[key]) && isPlainObject(val)) { result[key] = merge(result[key], val); } else if (isPlainObject(val)) { result[key] = merge({}, val); } else if (isArray(val)) { result[key] = val.slice(); } else { result[key] = val; } } for (var i = 0, l = arguments.length; i < l; i++) { forEach(arguments[i], assignValue); } return result; } /** * Extends object a by mutably adding to it the properties of object b. * * @param {Object} a The object to be extended * @param {Object} b The object to copy properties from * @param {Object} thisArg The object to bind function to * @return {Object} The resulting value of object a */ function extend(a, b, thisArg) { forEach(b, function assignValue(val, key) { if (thisArg && typeof val === 'function') { a[key] = bind(val, thisArg); } else { a[key] = val; } }); return a; } /** * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM) * * @param {string} content with BOM * @return {string} content value without BOM */ function stripBOM(content) { if (content.charCodeAt(0) === 0xFEFF) { content = content.slice(1); } return content; } module.exports = { isArray: isArray, isArrayBuffer: isArrayBuffer, isBuffer: isBuffer, isFormData: isFormData, isArrayBufferView: isArrayBufferView, isString: isString, isNumber: isNumber, isObject: isObject, isPlainObject: isPlainObject, isUndefined: isUndefined, isDate: isDate, isFile: isFile, isBlob: isBlob, isFunction: isFunction, isStream: isStream, isURLSearchParams: isURLSearchParams, isStandardBrowserEnv: isStandardBrowserEnv, forEach: forEach, merge: merge, extend: extend, trim: trim, stripBOM: stripBOM }; },{"./helpers/bind":114}],124:[function(require,module,exports){ var getNative = require('./_getNative'), root = require('./_root'); /* Built-in method references that are verified to be native. */ var DataView = getNative(root, 'DataView'); module.exports = DataView; },{"./_getNative":207,"./_root":250}],125:[function(require,module,exports){ var hashClear = require('./_hashClear'), hashDelete = require('./_hashDelete'), hashGet = require('./_hashGet'), hashHas = require('./_hashHas'), hashSet = require('./_hashSet'); /** * Creates a hash object. * * @private * @constructor * @param {Array} [entries] The key-value pairs to cache. */ function Hash(entries) { var index = -1, length = entries == null ? 0 : entries.length; this.clear(); while (++index < length) { var entry = entries[index]; this.set(entry[0], entry[1]); } } // Add methods to `Hash`. Hash.prototype.clear = hashClear; Hash.prototype['delete'] = hashDelete; Hash.prototype.get = hashGet; Hash.prototype.has = hashHas; Hash.prototype.set = hashSet; module.exports = Hash; },{"./_hashClear":215,"./_hashDelete":216,"./_hashGet":217,"./_hashHas":218,"./_hashSet":219}],126:[function(require,module,exports){ var listCacheClear = require('./_listCacheClear'), listCacheDelete = require('./_listCacheDelete'), listCacheGet = require('./_listCacheGet'), listCacheHas = require('./_listCacheHas'), listCacheSet = require('./_listCacheSet'); /** * Creates an list cache object. * * @private * @constructor * @param {Array} [entries] The key-value pairs to cache. */ function ListCache(entries) { var index = -1, length = entries == null ? 0 : entries.length; this.clear(); while (++index < length) { var entry = entries[index]; this.set(entry[0], entry[1]); } } // Add methods to `ListCache`. ListCache.prototype.clear = listCacheClear; ListCache.prototype['delete'] = listCacheDelete; ListCache.prototype.get = listCacheGet; ListCache.prototype.has = listCacheHas; ListCache.prototype.set = listCacheSet; module.exports = ListCache; },{"./_listCacheClear":230,"./_listCacheDelete":231,"./_listCacheGet":232,"./_listCacheHas":233,"./_listCacheSet":234}],127:[function(require,module,exports){ var getNative = require('./_getNative'), root = require('./_root'); /* Built-in method references that are verified to be native. */ var Map = getNative(root, 'Map'); module.exports = Map; },{"./_getNative":207,"./_root":250}],128:[function(require,module,exports){ var mapCacheClear = require('./_mapCacheClear'), mapCacheDelete = require('./_mapCacheDelete'), mapCacheGet = require('./_mapCacheGet'), mapCacheHas = require('./_mapCacheHas'), mapCacheSet = require('./_mapCacheSet'); /** * Creates a map cache object to store key-value pairs. * * @private * @constructor * @param {Array} [entries] The key-value pairs to cache. */ function MapCache(entries) { var index = -1, length = entries == null ? 0 : entries.length; this.clear(); while (++index < length) { var entry = entries[index]; this.set(entry[0], entry[1]); } } // Add methods to `MapCache`. MapCache.prototype.clear = mapCacheClear; MapCache.prototype['delete'] = mapCacheDelete; MapCache.prototype.get = mapCacheGet; MapCache.prototype.has = mapCacheHas; MapCache.prototype.set = mapCacheSet; module.exports = MapCache; },{"./_mapCacheClear":235,"./_mapCacheDelete":236,"./_mapCacheGet":237,"./_mapCacheHas":238,"./_mapCacheSet":239}],129:[function(require,module,exports){ var getNative = require('./_getNative'), root = require('./_root'); /* Built-in method references that are verified to be native. */ var Promise = getNative(root, 'Promise'); module.exports = Promise; },{"./_getNative":207,"./_root":250}],130:[function(require,module,exports){ var getNative = require('./_getNative'), root = require('./_root'); /* Built-in method references that are verified to be native. */ var Set = getNative(root, 'Set'); module.exports = Set; },{"./_getNative":207,"./_root":250}],131:[function(require,module,exports){ var MapCache = require('./_MapCache'), setCacheAdd = require('./_setCacheAdd'), setCacheHas = require('./_setCacheHas'); /** * * Creates an array cache object to store unique values. * * @private * @constructor * @param {Array} [values] The values to cache. */ function SetCache(values) { var index = -1, length = values == null ? 0 : values.length; this.__data__ = new MapCache; while (++index < length) { this.add(values[index]); } } // Add methods to `SetCache`. SetCache.prototype.add = SetCache.prototype.push = setCacheAdd; SetCache.prototype.has = setCacheHas; module.exports = SetCache; },{"./_MapCache":128,"./_setCacheAdd":252,"./_setCacheHas":253}],132:[function(require,module,exports){ var ListCache = require('./_ListCache'), stackClear = require('./_stackClear'), stackDelete = require('./_stackDelete'), stackGet = require('./_stackGet'), stackHas = require('./_stackHas'), stackSet = require('./_stackSet'); /** * Creates a stack cache object to store key-value pairs. * * @private * @constructor * @param {Array} [entries] The key-value pairs to cache. */ function Stack(entries) { var data = this.__data__ = new ListCache(entries); this.size = data.size; } // Add methods to `Stack`. Stack.prototype.clear = stackClear; Stack.prototype['delete'] = stackDelete; Stack.prototype.get = stackGet; Stack.prototype.has = stackHas; Stack.prototype.set = stackSet; module.exports = Stack; },{"./_ListCache":126,"./_stackClear":257,"./_stackDelete":258,"./_stackGet":259,"./_stackHas":260,"./_stackSet":261}],133:[function(require,module,exports){ var root = require('./_root'); /** Built-in value references. */ var Symbol = root.Symbol; module.exports = Symbol; },{"./_root":250}],134:[function(require,module,exports){ var root = require('./_root'); /** Built-in value references. */ var Uint8Array = root.Uint8Array; module.exports = Uint8Array; },{"./_root":250}],135:[function(require,module,exports){ var getNative = require('./_getNative'), root = require('./_root'); /* Built-in method references that are verified to be native. */ var WeakMap = getNative(root, 'WeakMap'); module.exports = WeakMap; },{"./_getNative":207,"./_root":250}],136:[function(require,module,exports){ /** * A faster alternative to `Function#apply`, this function invokes `func` * with the `this` binding of `thisArg` and the arguments of `args`. * * @private * @param {Function} func The function to invoke. * @param {*} thisArg The `this` binding of `func`. * @param {Array} args The arguments to invoke `func` with. * @returns {*} Returns the result of `func`. */ function apply(func, thisArg, args) { switch (args.length) { case 0: return func.call(thisArg); case 1: return func.call(thisArg, args[0]); case 2: return func.call(thisArg, args[0], args[1]); case 3: return func.call(thisArg, args[0], args[1], args[2]); } return func.apply(thisArg, args); } module.exports = apply; },{}],137:[function(require,module,exports){ /** * A specialized version of `_.forEach` for arrays without support for * iteratee shorthands. * * @private * @param {Array} [array] The array to iterate over. * @param {Function} iteratee The function invoked per iteration. * @returns {Array} Returns `array`. */ function arrayEach(array, iteratee) { var index = -1, length = array == null ? 0 : array.length; while (++index < length) { if (iteratee(array[index], index, array) === false) { break; } } return array; } module.exports = arrayEach; },{}],138:[function(require,module,exports){ /** * A specialized version of `_.filter` for arrays without support for * iteratee shorthands. * * @private * @param {Array} [array] The array to iterate over. * @param {Function} predicate The function invoked per iteration. * @returns {Array} Returns the new filtered array. */ function arrayFilter(array, predicate) { var index = -1, length = array == null ? 0 : array.length, resIndex = 0, result = []; while (++index < length) { var value = array[index]; if (predicate(value, index, array)) { result[resIndex++] = value; } } return result; } module.exports = arrayFilter; },{}],139:[function(require,module,exports){ var baseTimes = require('./_baseTimes'), isArguments = require('./isArguments'), isArray = require('./isArray'), isBuffer = require('./isBuffer'), isIndex = require('./_isIndex'), isTypedArray = require('./isTypedArray'); /** Used for built-in method references. */ var objectProto = Object.prototype; /** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty; /** * Creates an array of the enumerable property names of the array-like `value`. * * @private * @param {*} value The value to query. * @param {boolean} inherited Specify returning inherited property names. * @returns {Array} Returns the array of property names. */ function arrayLikeKeys(value, inherited) { var isArr = isArray(value), isArg = !isArr && isArguments(value), isBuff = !isArr && !isArg && isBuffer(value), isType = !isArr && !isArg && !isBuff && isTypedArray(value), skipIndexes = isArr || isArg || isBuff || isType, result = skipIndexes ? baseTimes(value.length, String) : [], length = result.length; for (var key in value) { if ((inherited || hasOwnProperty.call(value, key)) && !(skipIndexes && ( // Safari 9 has enumerable `arguments.length` in strict mode. key == 'length' || // Node.js 0.10 has enumerable non-index properties on buffers. (isBuff && (key == 'offset' || key == 'parent')) || // PhantomJS 2 has enumerable non-index properties on typed arrays. (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) || // Skip index properties. isIndex(key, length) ))) { result.push(key); } } return result; } module.exports = arrayLikeKeys; },{"./_baseTimes":178,"./_isIndex":223,"./isArguments":275,"./isArray":276,"./isBuffer":279,"./isTypedArray":289}],140:[function(require,module,exports){ /** * A specialized version of `_.map` for arrays without support for iteratee * shorthands. * * @private * @param {Array} [array] The array to iterate over. * @param {Function} iteratee The function invoked per iteration. * @returns {Array} Returns the new mapped array. */ function arrayMap(array, iteratee) { var index = -1, length = array == null ? 0 : array.length, result = Array(length); while (++index < length) { result[index] = iteratee(array[index], index, array); } return result; } module.exports = arrayMap; },{}],141:[function(require,module,exports){ /** * Appends the elements of `values` to `array`. * * @private * @param {Array} array The array to modify. * @param {Array} values The values to append. * @returns {Array} Returns `array`. */ function arrayPush(array, values) { var index = -1, length = values.length, offset = array.length; while (++index < length) { array[offset + index] = values[index]; } return array; } module.exports = arrayPush; },{}],142:[function(require,module,exports){ /** * A specialized version of `_.some` for arrays without support for iteratee * shorthands. * * @private * @param {Array} [array] The array to iterate over. * @param {Function} predicate The function invoked per iteration. * @returns {boolean} Returns `true` if any element passes the predicate check, * else `false`. */ function arraySome(array, predicate) { var index = -1, length = array == null ? 0 : array.length; while (++index < length) { if (predicate(array[index], index, array)) { return true; } } return false; } module.exports = arraySome; },{}],143:[function(require,module,exports){ var baseAssignValue = require('./_baseAssignValue'), eq = require('./eq'); /** * This function is like `assignValue` except that it doesn't assign * `undefined` values. * * @private * @param {Object} object The object to modify. * @param {string} key The key of the property to assign. * @param {*} value The value to assign. */ function assignMergeValue(object, key, value) { if ((value !== undefined && !eq(object[key], value)) || (value === undefined && !(key in object))) { baseAssignValue(object, key, value); } } module.exports = assignMergeValue; },{"./_baseAssignValue":148,"./eq":269}],144:[function(require,module,exports){ var baseAssignValue = require('./_baseAssignValue'), eq = require('./eq'); /** Used for built-in method references. */ var objectProto = Object.prototype; /** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty; /** * Assigns `value` to `key` of `object` if the existing value is not equivalent * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) * for equality comparisons. * * @private * @param {Object} object The object to modify. * @param {string} key The key of the property to assign. * @param {*} value The value to assign. */ function assignValue(object, key, value) { var objValue = object[key]; if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) || (value === undefined && !(key in object))) { baseAssignValue(object, key, value); } } module.exports = assignValue; },{"./_baseAssignValue":148,"./eq":269}],145:[function(require,module,exports){ var eq = require('./eq'); /** * Gets the index at which the `key` is found in `array` of key-value pairs. * * @private * @param {Array} array The array to inspect. * @param {*} key The key to search for. * @returns {number} Returns the index of the matched value, else `-1`. */ function assocIndexOf(array, key) { var length = array.length; while (length--) { if (eq(array[length][0], key)) { return length; } } return -1; } module.exports = assocIndexOf; },{"./eq":269}],146:[function(require,module,exports){ var copyObject = require('./_copyObject'), keys = require('./keys'); /** * The base implementation of `_.assign` without support for multiple sources * or `customizer` functions. * * @private * @param {Object} object The destination object. * @param {Object} source The source object. * @returns {Object} Returns `object`. */ function baseAssign(object, source) { return object && copyObject(source, keys(source), object); } module.exports = baseAssign; },{"./_copyObject":191,"./keys":291}],147:[function(require,module,exports){ var copyObject = require('./_copyObject'), keysIn = require('./keysIn'); /** * The base implementation of `_.assignIn` without support for multiple sources * or `customizer` functions. * * @private * @param {Object} object The destination object. * @param {Object} source The source object. * @returns {Object} Returns `object`. */ function baseAssignIn(object, source) { return object && copyObject(source, keysIn(source), object); } module.exports = baseAssignIn; },{"./_copyObject":191,"./keysIn":292}],148:[function(require,module,exports){ var defineProperty = require('./_defineProperty'); /** * The base implementation of `assignValue` and `assignMergeValue` without * value checks. * * @private * @param {Object} object The object to modify. * @param {string} key The key of the property to assign. * @param {*} value The value to assign. */ function baseAssignValue(object, key, value) { if (key == '__proto__' && defineProperty) { defineProperty(object, key, { 'configurable': true, 'enumerable': true, 'value': value, 'writable': true }); } else { object[key] = value; } } module.exports = baseAssignValue; },{"./_defineProperty":198}],149:[function(require,module,exports){ var Stack = require('./_Stack'), arrayEach = require('./_arrayEach'), assignValue = require('./_assignValue'), baseAssign = require('./_baseAssign'), baseAssignIn = require('./_baseAssignIn'), cloneBuffer = require('./_cloneBuffer'), copyArray = require('./_copyArray'), copySymbols = require('./_copySymbols'), copySymbolsIn = require('./_copySymbolsIn'), getAllKeys = require('./_getAllKeys'), getAllKeysIn = require('./_getAllKeysIn'), getTag = require('./_getTag'), initCloneArray = require('./_initCloneArray'), initCloneByTag = require('./_initCloneByTag'), initCloneObject = require('./_initCloneObject'), isArray = require('./isArray'), isBuffer = require('./isBuffer'), isMap = require('./isMap'), isObject = require('./isObject'), isSet = require('./isSet'), keys = require('./keys'), keysIn = require('./keysIn'); /** Used to compose bitmasks for cloning. */ var CLONE_DEEP_FLAG = 1, CLONE_FLAT_FLAG = 2, CLONE_SYMBOLS_FLAG = 4; /** `Object#toString` result references. */ var argsTag = '[object Arguments]', arrayTag = '[object Array]', boolTag = '[object Boolean]', dateTag = '[object Date]', errorTag = '[object Error]', funcTag = '[object Function]', genTag = '[object GeneratorFunction]', mapTag = '[object Map]', numberTag = '[object Number]', objectTag = '[object Object]', regexpTag = '[object RegExp]', setTag = '[object Set]', stringTag = '[object String]', symbolTag = '[object Symbol]', weakMapTag = '[object WeakMap]'; var arrayBufferTag = '[object ArrayBuffer]', dataViewTag = '[object DataView]', float32Tag = '[object Float32Array]', float64Tag = '[object Float64Array]', int8Tag = '[object Int8Array]', int16Tag = '[object Int16Array]', int32Tag = '[object Int32Array]', uint8Tag = '[object Uint8Array]', uint8ClampedTag = '[object Uint8ClampedArray]', uint16Tag = '[object Uint16Array]', uint32Tag = '[object Uint32Array]'; /** Used to identify `toStringTag` values supported by `_.clone`. */ var cloneableTags = {}; cloneableTags[argsTag] = cloneableTags[arrayTag] = cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] = cloneableTags[boolTag] = cloneableTags[dateTag] = cloneableTags[float32Tag] = cloneableTags[float64Tag] = cloneableTags[int8Tag] = cloneableTags[int16Tag] = cloneableTags[int32Tag] = cloneableTags[mapTag] = cloneableTags[numberTag] = cloneableTags[objectTag] = cloneableTags[regexpTag] = cloneableTags[setTag] = cloneableTags[stringTag] = cloneableTags[symbolTag] = cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] = cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true; cloneableTags[errorTag] = cloneableTags[funcTag] = cloneableTags[weakMapTag] = false; /** * The base implementation of `_.clone` and `_.cloneDeep` which tracks * traversed objects. * * @private * @param {*} value The value to clone. * @param {boolean} bitmask The bitmask flags. * 1 - Deep clone * 2 - Flatten inherited properties * 4 - Clone symbols * @param {Function} [customizer] The function to customize cloning. * @param {string} [key] The key of `value`. * @param {Object} [object] The parent object of `value`. * @param {Object} [stack] Tracks traversed objects and their clone counterparts. * @returns {*} Returns the cloned value. */ function baseClone(value, bitmask, customizer, key, object, stack) { var result, isDeep = bitmask & CLONE_DEEP_FLAG, isFlat = bitmask & CLONE_FLAT_FLAG, isFull = bitmask & CLONE_SYMBOLS_FLAG; if (customizer) { result = object ? customizer(value, key, object, stack) : customizer(value); } if (result !== undefined) { return result; } if (!isObject(value)) { return value; } var isArr = isArray(value); if (isArr) { result = initCloneArray(value); if (!isDeep) { return copyArray(value, result); } } else { var tag = getTag(value), isFunc = tag == funcTag || tag == genTag; if (isBuffer(value)) { return cloneBuffer(value, isDeep); } if (tag == objectTag || tag == argsTag || (isFunc && !object)) { result = (isFlat || isFunc) ? {} : initCloneObject(value); if (!isDeep) { return isFlat ? copySymbolsIn(value, baseAssignIn(result, value)) : copySymbols(value, baseAssign(result, value)); } } else { if (!cloneableTags[tag]) { return object ? value : {}; } result = initCloneByTag(value, tag, isDeep); } } // Check for circular references and return its corresponding clone. stack || (stack = new Stack); var stacked = stack.get(value); if (stacked) { return stacked; } stack.set(value, result); if (isSet(value)) { value.forEach(function(subValue) { result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack)); }); } else if (isMap(value)) { value.forEach(function(subValue, key) { result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack)); }); } var keysFunc = isFull ? (isFlat ? getAllKeysIn : getAllKeys) : (isFlat ? keysIn : keys); var props = isArr ? undefined : keysFunc(value); arrayEach(props || value, function(subValue, key) { if (props) { key = subValue; subValue = value[key]; } // Recursively populate clone (susceptible to call stack limits). assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack)); }); return result; } module.exports = baseClone; },{"./_Stack":132,"./_arrayEach":137,"./_assignValue":144,"./_baseAssign":146,"./_baseAssignIn":147,"./_cloneBuffer":185,"./_copyArray":190,"./_copySymbols":192,"./_copySymbolsIn":193,"./_getAllKeys":203,"./_getAllKeysIn":204,"./_getTag":212,"./_initCloneArray":220,"./_initCloneByTag":221,"./_initCloneObject":222,"./isArray":276,"./isBuffer":279,"./isMap":282,"./isObject":283,"./isSet":286,"./keys":291,"./keysIn":292}],150:[function(require,module,exports){ var isObject = require('./isObject'); /** Built-in value references. */ var objectCreate = Object.create; /** * The base implementation of `_.create` without support for assigning * properties to the created object. * * @private * @param {Object} proto The object to inherit from. * @returns {Object} Returns the new object. */ var baseCreate = (function() { function object() {} return function(proto) { if (!isObject(proto)) { return {}; } if (objectCreate) { return objectCreate(proto); } object.prototype = proto; var result = new object; object.prototype = undefined; return result; }; }()); module.exports = baseCreate; },{"./isObject":283}],151:[function(require,module,exports){ var baseForOwn = require('./_baseForOwn'), createBaseEach = require('./_createBaseEach'); /** * The base implementation of `_.forEach` without support for iteratee shorthands. * * @private * @param {Array|Object} collection The collection to iterate over. * @param {Function} iteratee The function invoked per iteration. * @returns {Array|Object} Returns `collection`. */ var baseEach = createBaseEach(baseForOwn); module.exports = baseEach; },{"./_baseForOwn":153,"./_createBaseEach":196}],152:[function(require,module,exports){ var createBaseFor = require('./_createBaseFor'); /** * The base implementation of `baseForOwn` which iterates over `object` * properties returned by `keysFunc` and invokes `iteratee` for each property. * Iteratee functions may exit iteration early by explicitly returning `false`. * * @private * @param {Object} object The object to iterate over. * @param {Function} iteratee The function invoked per iteration. * @param {Function} keysFunc The function to get the keys of `object`. * @returns {Object} Returns `object`. */ var baseFor = createBaseFor(); module.exports = baseFor; },{"./_createBaseFor":197}],153:[function(require,module,exports){ var baseFor = require('./_baseFor'), keys = require('./keys'); /** * The base implementation of `_.forOwn` without support for iteratee shorthands. * * @private * @param {Object} object The object to iterate over. * @param {Function} iteratee The function invoked per iteration. * @returns {Object} Returns `object`. */ function baseForOwn(object, iteratee) { return object && baseFor(object, iteratee, keys); } module.exports = baseForOwn; },{"./_baseFor":152,"./keys":291}],154:[function(require,module,exports){ var castPath = require('./_castPath'), toKey = require('./_toKey'); /** * The base implementation of `_.get` without support for default values. * * @private * @param {Object} object The object to query. * @param {Array|string} path The path of the property to get. * @returns {*} Returns the resolved value. */ function baseGet(object, path) { path = castPath(path, object); var index = 0, length = path.length; while (object != null && index < length) { object = object[toKey(path[index++])]; } return (index && index == length) ? object : undefined; } module.exports = baseGet; },{"./_castPath":183,"./_toKey":263}],155:[function(require,module,exports){ var arrayPush = require('./_arrayPush'), isArray = require('./isArray'); /** * The base implementation of `getAllKeys` and `getAllKeysIn` which uses * `keysFunc` and `symbolsFunc` to get the enumerable property names and * symbols of `object`. * * @private * @param {Object} object The object to query. * @param {Function} keysFunc The function to get the keys of `object`. * @param {Function} symbolsFunc The function to get the symbols of `object`. * @returns {Array} Returns the array of property names and symbols. */ function baseGetAllKeys(object, keysFunc, symbolsFunc) { var result = keysFunc(object); return isArray(object) ? result : arrayPush(result, symbolsFunc(object)); } module.exports = baseGetAllKeys; },{"./_arrayPush":141,"./isArray":276}],156:[function(require,module,exports){ var Symbol = require('./_Symbol'), getRawTag = require('./_getRawTag'), objectToString = require('./_objectToString'); /** `Object#toString` result references. */ var nullTag = '[object Null]', undefinedTag = '[object Undefined]'; /** Built-in value references. */ var symToStringTag = Symbol ? Symbol.toStringTag : undefined; /** * The base implementation of `getTag` without fallbacks for buggy environments. * * @private * @param {*} value The value to query. * @returns {string} Returns the `toStringTag`. */ function baseGetTag(value) { if (value == null) { return value === undefined ? undefinedTag : nullTag; } return (symToStringTag && symToStringTag in Object(value)) ? getRawTag(value) : objectToString(value); } module.exports = baseGetTag; },{"./_Symbol":133,"./_getRawTag":209,"./_objectToString":247}],157:[function(require,module,exports){ /** * The base implementation of `_.hasIn` without support for deep paths. * * @private * @param {Object} [object] The object to query. * @param {Array|string} key The key to check. * @returns {boolean} Returns `true` if `key` exists, else `false`. */ function baseHasIn(object, key) { return object != null && key in Object(object); } module.exports = baseHasIn; },{}],158:[function(require,module,exports){ var baseGetTag = require('./_baseGetTag'), isObjectLike = require('./isObjectLike'); /** `Object#toString` result references. */ var argsTag = '[object Arguments]'; /** * The base implementation of `_.isArguments`. * * @private * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is an `arguments` object, */ function baseIsArguments(value) { return isObjectLike(value) && baseGetTag(value) == argsTag; } module.exports = baseIsArguments; },{"./_baseGetTag":156,"./isObjectLike":284}],159:[function(require,module,exports){ var baseIsEqualDeep = require('./_baseIsEqualDeep'), isObjectLike = require('./isObjectLike'); /** * The base implementation of `_.isEqual` which supports partial comparisons * and tracks traversed objects. * * @private * @param {*} value The value to compare. * @param {*} other The other value to compare. * @param {boolean} bitmask The bitmask flags. * 1 - Unordered comparison * 2 - Partial comparison * @param {Function} [customizer] The function to customize comparisons. * @param {Object} [stack] Tracks traversed `value` and `other` objects. * @returns {boolean} Returns `true` if the values are equivalent, else `false`. */ function baseIsEqual(value, other, bitmask, customizer, stack) { if (value === other) { return true; } if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) { return value !== value && other !== other; } return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack); } module.exports = baseIsEqual; },{"./_baseIsEqualDeep":160,"./isObjectLike":284}],160:[function(require,module,exports){ var Stack = require('./_Stack'), equalArrays = require('./_equalArrays'), equalByTag = require('./_equalByTag'), equalObjects = require('./_equalObjects'), getTag = require('./_getTag'), isArray = require('./isArray'), isBuffer = require('./isBuffer'), isTypedArray = require('./isTypedArray'); /** Used to compose bitmasks for value comparisons. */ var COMPARE_PARTIAL_FLAG = 1; /** `Object#toString` result references. */ var argsTag = '[object Arguments]', arrayTag = '[object Array]', objectTag = '[object Object]'; /** Used for built-in method references. */ var objectProto = Object.prototype; /** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty; /** * A specialized version of `baseIsEqual` for arrays and objects which performs * deep comparisons and tracks traversed objects enabling objects with circular * references to be compared. * * @private * @param {Object} object The object to compare. * @param {Object} other The other object to compare. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. * @param {Function} customizer The function to customize comparisons. * @param {Function} equalFunc The function to determine equivalents of values. * @param {Object} [stack] Tracks traversed `object` and `other` objects. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. */ function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) { var objIsArr = isArray(object), othIsArr = isArray(other), objTag = objIsArr ? arrayTag : getTag(object), othTag = othIsArr ? arrayTag : getTag(other); objTag = objTag == argsTag ? objectTag : objTag; othTag = othTag == argsTag ? objectTag : othTag; var objIsObj = objTag == objectTag, othIsObj = othTag == objectTag, isSameTag = objTag == othTag; if (isSameTag && isBuffer(object)) { if (!isBuffer(other)) { return false; } objIsArr = true; objIsObj = false; } if (isSameTag && !objIsObj) { stack || (stack = new Stack); return (objIsArr || isTypedArray(object)) ? equalArrays(object, other, bitmask, customizer, equalFunc, stack) : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack); } if (!(bitmask & COMPARE_PARTIAL_FLAG)) { var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'), othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__'); if (objIsWrapped || othIsWrapped) { var objUnwrapped = objIsWrapped ? object.value() : object, othUnwrapped = othIsWrapped ? other.value() : other; stack || (stack = new Stack); return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack); } } if (!isSameTag) { return false; } stack || (stack = new Stack); return equalObjects(object, other, bitmask, customizer, equalFunc, stack); } module.exports = baseIsEqualDeep; },{"./_Stack":132,"./_equalArrays":199,"./_equalByTag":200,"./_equalObjects":201,"./_getTag":212,"./isArray":276,"./isBuffer":279,"./isTypedArray":289}],161:[function(require,module,exports){ var getTag = require('./_getTag'), isObjectLike = require('./isObjectLike'); /** `Object#toString` result references. */ var mapTag = '[object Map]'; /** * The base implementation of `_.isMap` without Node.js optimizations. * * @private * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is a map, else `false`. */ function baseIsMap(value) { return isObjectLike(value) && getTag(value) == mapTag; } module.exports = baseIsMap; },{"./_getTag":212,"./isObjectLike":284}],162:[function(require,module,exports){ var Stack = require('./_Stack'), baseIsEqual = require('./_baseIsEqual'); /** Used to compose bitmasks for value comparisons. */ var COMPARE_PARTIAL_FLAG = 1, COMPARE_UNORDERED_FLAG = 2; /** * The base implementation of `_.isMatch` without support for iteratee shorthands. * * @private * @param {Object} object The object to inspect. * @param {Object} source The object of property values to match. * @param {Array} matchData The property names, values, and compare flags to match. * @param {Function} [customizer] The function to customize comparisons. * @returns {boolean} Returns `true` if `object` is a match, else `false`. */ function baseIsMatch(object, source, matchData, customizer) { var index = matchData.length, length = index, noCustomizer = !customizer; if (object == null) { return !length; } object = Object(object); while (index--) { var data = matchData[index]; if ((noCustomizer && data[2]) ? data[1] !== object[data[0]] : !(data[0] in object) ) { return false; } } while (++index < length) { data = matchData[index]; var key = data[0], objValue = object[key], srcValue = data[1]; if (noCustomizer && data[2]) { if (objValue === undefined && !(key in object)) { return false; } } else { var stack = new Stack; if (customizer) { var result = customizer(objValue, srcValue, key, object, source, stack); } if (!(result === undefined ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack) : result )) { return false; } } } return true; } module.exports = baseIsMatch; },{"./_Stack":132,"./_baseIsEqual":159}],163:[function(require,module,exports){ var isFunction = require('./isFunction'), isMasked = require('./_isMasked'), isObject = require('./isObject'), toSource = require('./_toSource'); /** * Used to match `RegExp` * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns). */ var reRegExpChar = /[\\^$.*+?()[\]{}|]/g; /** Used to detect host constructors (Safari). */ var reIsHostCtor = /^\[object .+?Constructor\]$/; /** Used for built-in method references. */ var funcProto = Function.prototype, objectProto = Object.prototype; /** Used to resolve the decompiled source of functions. */ var funcToString = funcProto.toString; /** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty; /** Used to detect if a method is native. */ var reIsNative = RegExp('^' + funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&') .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' ); /** * The base implementation of `_.isNative` without bad shim checks. * * @private * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is a native function, * else `false`. */ function baseIsNative(value) { if (!isObject(value) || isMasked(value)) { return false; } var pattern = isFunction(value) ? reIsNative : reIsHostCtor; return pattern.test(toSource(value)); } module.exports = baseIsNative; },{"./_isMasked":227,"./_toSource":264,"./isFunction":280,"./isObject":283}],164:[function(require,module,exports){ var getTag = require('./_getTag'), isObjectLike = require('./isObjectLike'); /** `Object#toString` result references. */ var setTag = '[object Set]'; /** * The base implementation of `_.isSet` without Node.js optimizations. * * @private * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is a set, else `false`. */ function baseIsSet(value) { return isObjectLike(value) && getTag(value) == setTag; } module.exports = baseIsSet; },{"./_getTag":212,"./isObjectLike":284}],165:[function(require,module,exports){ var baseGetTag = require('./_baseGetTag'), isLength = require('./isLength'), isObjectLike = require('./isObjectLike'); /** `Object#toString` result references. */ var argsTag = '[object Arguments]', arrayTag = '[object Array]', boolTag = '[object Boolean]', dateTag = '[object Date]', errorTag = '[object Error]', funcTag = '[object Function]', mapTag = '[object Map]', numberTag = '[object Number]', objectTag = '[object Object]', regexpTag = '[object RegExp]', setTag = '[object Set]', stringTag = '[object String]', weakMapTag = '[object WeakMap]'; var arrayBufferTag = '[object ArrayBuffer]', dataViewTag = '[object DataView]', float32Tag = '[object Float32Array]', float64Tag = '[object Float64Array]', int8Tag = '[object Int8Array]', int16Tag = '[object Int16Array]', int32Tag = '[object Int32Array]', uint8Tag = '[object Uint8Array]', uint8ClampedTag = '[object Uint8ClampedArray]', uint16Tag = '[object Uint16Array]', uint32Tag = '[object Uint32Array]'; /** Used to identify `toStringTag` values of typed arrays. */ var typedArrayTags = {}; typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = typedArrayTags[uint32Tag] = true; typedArrayTags[argsTag] = typedArrayTags[arrayTag] = typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = typedArrayTags[errorTag] = typedArrayTags[funcTag] = typedArrayTags[mapTag] = typedArrayTags[numberTag] = typedArrayTags[objectTag] = typedArrayTags[regexpTag] = typedArrayTags[setTag] = typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false; /** * The base implementation of `_.isTypedArray` without Node.js optimizations. * * @private * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. */ function baseIsTypedArray(value) { return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[baseGetTag(value)]; } module.exports = baseIsTypedArray; },{"./_baseGetTag":156,"./isLength":281,"./isObjectLike":284}],166:[function(require,module,exports){ var baseMatches = require('./_baseMatches'), baseMatchesProperty = require('./_baseMatchesProperty'), identity = require('./identity'), isArray = require('./isArray'), property = require('./property'); /** * The base implementation of `_.iteratee`. * * @private * @param {*} [value=_.identity] The value to convert to an iteratee. * @returns {Function} Returns the iteratee. */ function baseIteratee(value) { // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9. // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details. if (typeof value == 'function') { return value; } if (value == null) { return identity; } if (typeof value == 'object') { return isArray(value) ? baseMatchesProperty(value[0], value[1]) : baseMatches(value); } return property(value); } module.exports = baseIteratee; },{"./_baseMatches":170,"./_baseMatchesProperty":171,"./identity":274,"./isArray":276,"./property":297}],167:[function(require,module,exports){ var isPrototype = require('./_isPrototype'), nativeKeys = require('./_nativeKeys'); /** Used for built-in method references. */ var objectProto = Object.prototype; /** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty; /** * The base implementation of `_.keys` which doesn't treat sparse arrays as dense. * * @private * @param {Object} object The object to query. * @returns {Array} Returns the array of property names. */ function baseKeys(object) { if (!isPrototype(object)) { return nativeKeys(object); } var result = []; for (var key in Object(object)) { if (hasOwnProperty.call(object, key) && key != 'constructor') { result.push(key); } } return result; } module.exports = baseKeys; },{"./_isPrototype":228,"./_nativeKeys":244}],168:[function(require,module,exports){ var isObject = require('./isObject'), isPrototype = require('./_isPrototype'), nativeKeysIn = require('./_nativeKeysIn'); /** Used for built-in method references. */ var objectProto = Object.prototype; /** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty; /** * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense. * * @private * @param {Object} object The object to query. * @returns {Array} Returns the array of property names. */ function baseKeysIn(object) { if (!isObject(object)) { return nativeKeysIn(object); } var isProto = isPrototype(object), result = []; for (var key in object) { if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) { result.push(key); } } return result; } module.exports = baseKeysIn; },{"./_isPrototype":228,"./_nativeKeysIn":245,"./isObject":283}],169:[function(require,module,exports){ var baseEach = require('./_baseEach'), isArrayLike = require('./isArrayLike'); /** * The base implementation of `_.map` without support for iteratee shorthands. * * @private * @param {Array|Object} collection The collection to iterate over. * @param {Function} iteratee The function invoked per iteration. * @returns {Array} Returns the new mapped array. */ function baseMap(collection, iteratee) { var index = -1, result = isArrayLike(collection) ? Array(collection.length) : []; baseEach(collection, function(value, key, collection) { result[++index] = iteratee(value, key, collection); }); return result; } module.exports = baseMap; },{"./_baseEach":151,"./isArrayLike":277}],170:[function(require,module,exports){ var baseIsMatch = require('./_baseIsMatch'), getMatchData = require('./_getMatchData'), matchesStrictComparable = require('./_matchesStrictComparable'); /** * The base implementation of `_.matches` which doesn't clone `source`. * * @private * @param {Object} source The object of property values to match. * @returns {Function} Returns the new spec function. */ function baseMatches(source) { var matchData = getMatchData(source); if (matchData.length == 1 && matchData[0][2]) { return matchesStrictComparable(matchData[0][0], matchData[0][1]); } return function(object) { return object === source || baseIsMatch(object, source, matchData); }; } module.exports = baseMatches; },{"./_baseIsMatch":162,"./_getMatchData":206,"./_matchesStrictComparable":241}],171:[function(require,module,exports){ var baseIsEqual = require('./_baseIsEqual'), get = require('./get'), hasIn = require('./hasIn'), isKey = require('./_isKey'), isStrictComparable = require('./_isStrictComparable'), matchesStrictComparable = require('./_matchesStrictComparable'), toKey = require('./_toKey'); /** Used to compose bitmasks for value comparisons. */ var COMPARE_PARTIAL_FLAG = 1, COMPARE_UNORDERED_FLAG = 2; /** * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`. * * @private * @param {string} path The path of the property to get. * @param {*} srcValue The value to match. * @returns {Function} Returns the new spec function. */ function baseMatchesProperty(path, srcValue) { if (isKey(path) && isStrictComparable(srcValue)) { return matchesStrictComparable(toKey(path), srcValue); } return function(object) { var objValue = get(object, path); return (objValue === undefined && objValue === srcValue) ? hasIn(object, path) : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG); }; } module.exports = baseMatchesProperty; },{"./_baseIsEqual":159,"./_isKey":225,"./_isStrictComparable":229,"./_matchesStrictComparable":241,"./_toKey":263,"./get":272,"./hasIn":273}],172:[function(require,module,exports){ var Stack = require('./_Stack'), assignMergeValue = require('./_assignMergeValue'), baseFor = require('./_baseFor'), baseMergeDeep = require('./_baseMergeDeep'), isObject = require('./isObject'), keysIn = require('./keysIn'), safeGet = require('./_safeGet'); /** * The base implementation of `_.merge` without support for multiple sources. * * @private * @param {Object} object The destination object. * @param {Object} source The source object. * @param {number} srcIndex The index of `source`. * @param {Function} [customizer] The function to customize merged values. * @param {Object} [stack] Tracks traversed source values and their merged * counterparts. */ function baseMerge(object, source, srcIndex, customizer, stack) { if (object === source) { return; } baseFor(source, function(srcValue, key) { stack || (stack = new Stack); if (isObject(srcValue)) { baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack); } else { var newValue = customizer ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack) : undefined; if (newValue === undefined) { newValue = srcValue; } assignMergeValue(object, key, newValue); } }, keysIn); } module.exports = baseMerge; },{"./_Stack":132,"./_assignMergeValue":143,"./_baseFor":152,"./_baseMergeDeep":173,"./_safeGet":251,"./isObject":283,"./keysIn":292}],173:[function(require,module,exports){ var assignMergeValue = require('./_assignMergeValue'), cloneBuffer = require('./_cloneBuffer'), cloneTypedArray = require('./_cloneTypedArray'), copyArray = require('./_copyArray'), initCloneObject = require('./_initCloneObject'), isArguments = require('./isArguments'), isArray = require('./isArray'), isArrayLikeObject = require('./isArrayLikeObject'), isBuffer = require('./isBuffer'), isFunction = require('./isFunction'), isObject = require('./isObject'), isPlainObject = require('./isPlainObject'), isTypedArray = require('./isTypedArray'), safeGet = require('./_safeGet'), toPlainObject = require('./toPlainObject'); /** * A specialized version of `baseMerge` for arrays and objects which performs * deep merges and tracks traversed objects enabling objects with circular * references to be merged. * * @private * @param {Object} object The destination object. * @param {Object} source The source object. * @param {string} key The key of the value to merge. * @param {number} srcIndex The index of `source`. * @param {Function} mergeFunc The function to merge values. * @param {Function} [customizer] The function to customize assigned values. * @param {Object} [stack] Tracks traversed source values and their merged * counterparts. */ function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) { var objValue = safeGet(object, key), srcValue = safeGet(source, key), stacked = stack.get(srcValue); if (stacked) { assignMergeValue(object, key, stacked); return; } var newValue = customizer ? customizer(objValue, srcValue, (key + ''), object, source, stack) : undefined; var isCommon = newValue === undefined; if (isCommon) { var isArr = isArray(srcValue), isBuff = !isArr && isBuffer(srcValue), isTyped = !isArr && !isBuff && isTypedArray(srcValue); newValue = srcValue; if (isArr || isBuff || isTyped) { if (isArray(objValue)) { newValue = objValue; } else if (isArrayLikeObject(objValue)) { newValue = copyArray(objValue); } else if (isBuff) { isCommon = false; newValue = cloneBuffer(srcValue, true); } else if (isTyped) { isCommon = false; newValue = cloneTypedArray(srcValue, true); } else { newValue = []; } } else if (isPlainObject(srcValue) || isArguments(srcValue)) { newValue = objValue; if (isArguments(objValue)) { newValue = toPlainObject(objValue); } else if (!isObject(objValue) || isFunction(objValue)) { newValue = initCloneObject(srcValue); } } else { isCommon = false; } } if (isCommon) { // Recursively merge objects and arrays (susceptible to call stack limits). stack.set(srcValue, newValue); mergeFunc(newValue, srcValue, srcIndex, customizer, stack); stack['delete'](srcValue); } assignMergeValue(object, key, newValue); } module.exports = baseMergeDeep; },{"./_assignMergeValue":143,"./_cloneBuffer":185,"./_cloneTypedArray":189,"./_copyArray":190,"./_initCloneObject":222,"./_safeGet":251,"./isArguments":275,"./isArray":276,"./isArrayLikeObject":278,"./isBuffer":279,"./isFunction":280,"./isObject":283,"./isPlainObject":285,"./isTypedArray":289,"./toPlainObject":302}],174:[function(require,module,exports){ /** * The base implementation of `_.property` without support for deep paths. * * @private * @param {string} key The key of the property to get. * @returns {Function} Returns the new accessor function. */ function baseProperty(key) { return function(object) { return object == null ? undefined : object[key]; }; } module.exports = baseProperty; },{}],175:[function(require,module,exports){ var baseGet = require('./_baseGet'); /** * A specialized version of `baseProperty` which supports deep paths. * * @private * @param {Array|string} path The path of the property to get. * @returns {Function} Returns the new accessor function. */ function basePropertyDeep(path) { return function(object) { return baseGet(object, path); }; } module.exports = basePropertyDeep; },{"./_baseGet":154}],176:[function(require,module,exports){ var identity = require('./identity'), overRest = require('./_overRest'), setToString = require('./_setToString'); /** * The base implementation of `_.rest` which doesn't validate or coerce arguments. * * @private * @param {Function} func The function to apply a rest parameter to. * @param {number} [start=func.length-1] The start position of the rest parameter. * @returns {Function} Returns the new function. */ function baseRest(func, start) { return setToString(overRest(func, start, identity), func + ''); } module.exports = baseRest; },{"./_overRest":249,"./_setToString":255,"./identity":274}],177:[function(require,module,exports){ var constant = require('./constant'), defineProperty = require('./_defineProperty'), identity = require('./identity'); /** * The base implementation of `setToString` without support for hot loop shorting. * * @private * @param {Function} func The function to modify. * @param {Function} string The `toString` result. * @returns {Function} Returns `func`. */ var baseSetToString = !defineProperty ? identity : function(func, string) { return defineProperty(func, 'toString', { 'configurable': true, 'enumerable': false, 'value': constant(string), 'writable': true }); }; module.exports = baseSetToString; },{"./_defineProperty":198,"./constant":266,"./identity":274}],178:[function(require,module,exports){ /** * The base implementation of `_.times` without support for iteratee shorthands * or max array length checks. * * @private * @param {number} n The number of times to invoke `iteratee`. * @param {Function} iteratee The function invoked per iteration. * @returns {Array} Returns the array of results. */ function baseTimes(n, iteratee) { var index = -1, result = Array(n); while (++index < n) { result[index] = iteratee(index); } return result; } module.exports = baseTimes; },{}],179:[function(require,module,exports){ var Symbol = require('./_Symbol'), arrayMap = require('./_arrayMap'), isArray = require('./isArray'), isSymbol = require('./isSymbol'); /** Used as references for various `Number` constants. */ var INFINITY = 1 / 0; /** Used to convert symbols to primitives and strings. */ var symbolProto = Symbol ? Symbol.prototype : undefined, symbolToString = symbolProto ? symbolProto.toString : undefined; /** * The base implementation of `_.toString` which doesn't convert nullish * values to empty strings. * * @private * @param {*} value The value to process. * @returns {string} Returns the string. */ function baseToString(value) { // Exit early for strings to avoid a performance hit in some environments. if (typeof value == 'string') { return value; } if (isArray(value)) { // Recursively convert values (susceptible to call stack limits). return arrayMap(value, baseToString) + ''; } if (isSymbol(value)) { return symbolToString ? symbolToString.call(value) : ''; } var result = (value + ''); return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; } module.exports = baseToString; },{"./_Symbol":133,"./_arrayMap":140,"./isArray":276,"./isSymbol":288}],180:[function(require,module,exports){ /** * The base implementation of `_.unary` without support for storing metadata. * * @private * @param {Function} func The function to cap arguments for. * @returns {Function} Returns the new capped function. */ function baseUnary(func) { return function(value) { return func(value); }; } module.exports = baseUnary; },{}],181:[function(require,module,exports){ /** * Checks if a `cache` value for `key` exists. * * @private * @param {Object} cache The cache to query. * @param {string} key The key of the entry to check. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. */ function cacheHas(cache, key) { return cache.has(key); } module.exports = cacheHas; },{}],182:[function(require,module,exports){ var identity = require('./identity'); /** * Casts `value` to `identity` if it's not a function. * * @private * @param {*} value The value to inspect. * @returns {Function} Returns cast function. */ function castFunction(value) { return typeof value == 'function' ? value : identity; } module.exports = castFunction; },{"./identity":274}],183:[function(require,module,exports){ var isArray = require('./isArray'), isKey = require('./_isKey'), stringToPath = require('./_stringToPath'), toString = require('./toString'); /** * Casts `value` to a path array if it's not one. * * @private * @param {*} value The value to inspect. * @param {Object} [object] The object to query keys on. * @returns {Array} Returns the cast property path array. */ function castPath(value, object) { if (isArray(value)) { return value; } return isKey(value, object) ? [value] : stringToPath(toString(value)); } module.exports = castPath; },{"./_isKey":225,"./_stringToPath":262,"./isArray":276,"./toString":303}],184:[function(require,module,exports){ var Uint8Array = require('./_Uint8Array'); /** * Creates a clone of `arrayBuffer`. * * @private * @param {ArrayBuffer} arrayBuffer The array buffer to clone. * @returns {ArrayBuffer} Returns the cloned array buffer. */ function cloneArrayBuffer(arrayBuffer) { var result = new arrayBuffer.constructor(arrayBuffer.byteLength); new Uint8Array(result).set(new Uint8Array(arrayBuffer)); return result; } module.exports = cloneArrayBuffer; },{"./_Uint8Array":134}],185:[function(require,module,exports){ var root = require('./_root'); /** Detect free variable `exports`. */ var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports; /** Detect free variable `module`. */ var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module; /** Detect the popular CommonJS extension `module.exports`. */ var moduleExports = freeModule && freeModule.exports === freeExports; /** Built-in value references. */ var Buffer = moduleExports ? root.Buffer : undefined, allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined; /** * Creates a clone of `buffer`. * * @private * @param {Buffer} buffer The buffer to clone. * @param {boolean} [isDeep] Specify a deep clone. * @returns {Buffer} Returns the cloned buffer. */ function cloneBuffer(buffer, isDeep) { if (isDeep) { return buffer.slice(); } var length = buffer.length, result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length); buffer.copy(result); return result; } module.exports = cloneBuffer; },{"./_root":250}],186:[function(require,module,exports){ var cloneArrayBuffer = require('./_cloneArrayBuffer'); /** * Creates a clone of `dataView`. * * @private * @param {Object} dataView The data view to clone. * @param {boolean} [isDeep] Specify a deep clone. * @returns {Object} Returns the cloned data view. */ function cloneDataView(dataView, isDeep) { var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer; return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength); } module.exports = cloneDataView; },{"./_cloneArrayBuffer":184}],187:[function(require,module,exports){ /** Used to match `RegExp` flags from their coerced string values. */ var reFlags = /\w*$/; /** * Creates a clone of `regexp`. * * @private * @param {Object} regexp The regexp to clone. * @returns {Object} Returns the cloned regexp. */ function cloneRegExp(regexp) { var result = new regexp.constructor(regexp.source, reFlags.exec(regexp)); result.lastIndex = regexp.lastIndex; return result; } module.exports = cloneRegExp; },{}],188:[function(require,module,exports){ var Symbol = require('./_Symbol'); /** Used to convert symbols to primitives and strings. */ var symbolProto = Symbol ? Symbol.prototype : undefined, symbolValueOf = symbolProto ? symbolProto.valueOf : undefined; /** * Creates a clone of the `symbol` object. * * @private * @param {Object} symbol The symbol object to clone. * @returns {Object} Returns the cloned symbol object. */ function cloneSymbol(symbol) { return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {}; } module.exports = cloneSymbol; },{"./_Symbol":133}],189:[function(require,module,exports){ var cloneArrayBuffer = require('./_cloneArrayBuffer'); /** * Creates a clone of `typedArray`. * * @private * @param {Object} typedArray The typed array to clone. * @param {boolean} [isDeep] Specify a deep clone. * @returns {Object} Returns the cloned typed array. */ function cloneTypedArray(typedArray, isDeep) { var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer; return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length); } module.exports = cloneTypedArray; },{"./_cloneArrayBuffer":184}],190:[function(require,module,exports){ /** * Copies the values of `source` to `array`. * * @private * @param {Array} source The array to copy values from. * @param {Array} [array=[]] The array to copy values to. * @returns {Array} Returns `array`. */ function copyArray(source, array) { var index = -1, length = source.length; array || (array = Array(length)); while (++index < length) { array[index] = source[index]; } return array; } module.exports = copyArray; },{}],191:[function(require,module,exports){ var assignValue = require('./_assignValue'), baseAssignValue = require('./_baseAssignValue'); /** * Copies properties of `source` to `object`. * * @private * @param {Object} source The object to copy properties from. * @param {Array} props The property identifiers to copy. * @param {Object} [object={}] The object to copy properties to. * @param {Function} [customizer] The function to customize copied values. * @returns {Object} Returns `object`. */ function copyObject(source, props, object, customizer) { var isNew = !object; object || (object = {}); var index = -1, length = props.length; while (++index < length) { var key = props[index]; var newValue = customizer ? customizer(object[key], source[key], key, object, source) : undefined; if (newValue === undefined) { newValue = source[key]; } if (isNew) { baseAssignValue(object, key, newValue); } else { assignValue(object, key, newValue); } } return object; } module.exports = copyObject; },{"./_assignValue":144,"./_baseAssignValue":148}],192:[function(require,module,exports){ var copyObject = require('./_copyObject'), getSymbols = require('./_getSymbols'); /** * Copies own symbols of `source` to `object`. * * @private * @param {Object} source The object to copy symbols from. * @param {Object} [object={}] The object to copy symbols to. * @returns {Object} Returns `object`. */ function copySymbols(source, object) { return copyObject(source, getSymbols(source), object); } module.exports = copySymbols; },{"./_copyObject":191,"./_getSymbols":210}],193:[function(require,module,exports){ var copyObject = require('./_copyObject'), getSymbolsIn = require('./_getSymbolsIn'); /** * Copies own and inherited symbols of `source` to `object`. * * @private * @param {Object} source The object to copy symbols from. * @param {Object} [object={}] The object to copy symbols to. * @returns {Object} Returns `object`. */ function copySymbolsIn(source, object) { return copyObject(source, getSymbolsIn(source), object); } module.exports = copySymbolsIn; },{"./_copyObject":191,"./_getSymbolsIn":211}],194:[function(require,module,exports){ var root = require('./_root'); /** Used to detect overreaching core-js shims. */ var coreJsData = root['__core-js_shared__']; module.exports = coreJsData; },{"./_root":250}],195:[function(require,module,exports){ var baseRest = require('./_baseRest'), isIterateeCall = require('./_isIterateeCall'); /** * Creates a function like `_.assign`. * * @private * @param {Function} assigner The function to assign values. * @returns {Function} Returns the new assigner function. */ function createAssigner(assigner) { return baseRest(function(object, sources) { var index = -1, length = sources.length, customizer = length > 1 ? sources[length - 1] : undefined, guard = length > 2 ? sources[2] : undefined; customizer = (assigner.length > 3 && typeof customizer == 'function') ? (length--, customizer) : undefined; if (guard && isIterateeCall(sources[0], sources[1], guard)) { customizer = length < 3 ? undefined : customizer; length = 1; } object = Object(object); while (++index < length) { var source = sources[index]; if (source) { assigner(object, source, index, customizer); } } return object; }); } module.exports = createAssigner; },{"./_baseRest":176,"./_isIterateeCall":224}],196:[function(require,module,exports){ var isArrayLike = require('./isArrayLike'); /** * Creates a `baseEach` or `baseEachRight` function. * * @private * @param {Function} eachFunc The function to iterate over a collection. * @param {boolean} [fromRight] Specify iterating from right to left. * @returns {Function} Returns the new base function. */ function createBaseEach(eachFunc, fromRight) { return function(collection, iteratee) { if (collection == null) { return collection; } if (!isArrayLike(collection)) { return eachFunc(collection, iteratee); } var length = collection.length, index = fromRight ? length : -1, iterable = Object(collection); while ((fromRight ? index-- : ++index < length)) { if (iteratee(iterable[index], index, iterable) === false) { break; } } return collection; }; } module.exports = createBaseEach; },{"./isArrayLike":277}],197:[function(require,module,exports){ /** * Creates a base function for methods like `_.forIn` and `_.forOwn`. * * @private * @param {boolean} [fromRight] Specify iterating from right to left. * @returns {Function} Returns the new base function. */ function createBaseFor(fromRight) { return function(object, iteratee, keysFunc) { var index = -1, iterable = Object(object), props = keysFunc(object), length = props.length; while (length--) { var key = props[fromRight ? length : ++index]; if (iteratee(iterable[key], key, iterable) === false) { break; } } return object; }; } module.exports = createBaseFor; },{}],198:[function(require,module,exports){ var getNative = require('./_getNative'); var defineProperty = (function() { try { var func = getNative(Object, 'defineProperty'); func({}, '', {}); return func; } catch (e) {} }()); module.exports = defineProperty; },{"./_getNative":207}],199:[function(require,module,exports){ var SetCache = require('./_SetCache'), arraySome = require('./_arraySome'), cacheHas = require('./_cacheHas'); /** Used to compose bitmasks for value comparisons. */ var COMPARE_PARTIAL_FLAG = 1, COMPARE_UNORDERED_FLAG = 2; /** * A specialized version of `baseIsEqualDeep` for arrays with support for * partial deep comparisons. * * @private * @param {Array} array The array to compare. * @param {Array} other The other array to compare. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. * @param {Function} customizer The function to customize comparisons. * @param {Function} equalFunc The function to determine equivalents of values. * @param {Object} stack Tracks traversed `array` and `other` objects. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`. */ function equalArrays(array, other, bitmask, customizer, equalFunc, stack) { var isPartial = bitmask & COMPARE_PARTIAL_FLAG, arrLength = array.length, othLength = other.length; if (arrLength != othLength && !(isPartial && othLength > arrLength)) { return false; } // Check that cyclic values are equal. var arrStacked = stack.get(array); var othStacked = stack.get(other); if (arrStacked && othStacked) { return arrStacked == other && othStacked == array; } var index = -1, result = true, seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined; stack.set(array, other); stack.set(other, array); // Ignore non-index properties. while (++index < arrLength) { var arrValue = array[index], othValue = other[index]; if (customizer) { var compared = isPartial ? customizer(othValue, arrValue, index, other, array, stack) : customizer(arrValue, othValue, index, array, other, stack); } if (compared !== undefined) { if (compared) { continue; } result = false; break; } // Recursively compare arrays (susceptible to call stack limits). if (seen) { if (!arraySome(other, function(othValue, othIndex) { if (!cacheHas(seen, othIndex) && (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) { return seen.push(othIndex); } })) { result = false; break; } } else if (!( arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack) )) { result = false; break; } } stack['delete'](array); stack['delete'](other); return result; } module.exports = equalArrays; },{"./_SetCache":131,"./_arraySome":142,"./_cacheHas":181}],200:[function(require,module,exports){ var Symbol = require('./_Symbol'), Uint8Array = require('./_Uint8Array'), eq = require('./eq'), equalArrays = require('./_equalArrays'), mapToArray = require('./_mapToArray'), setToArray = require('./_setToArray'); /** Used to compose bitmasks for value comparisons. */ var COMPARE_PARTIAL_FLAG = 1, COMPARE_UNORDERED_FLAG = 2; /** `Object#toString` result references. */ var boolTag = '[object Boolean]', dateTag = '[object Date]', errorTag = '[object Error]', mapTag = '[object Map]', numberTag = '[object Number]', regexpTag = '[object RegExp]', setTag = '[object Set]', stringTag = '[object String]', symbolTag = '[object Symbol]'; var arrayBufferTag = '[object ArrayBuffer]', dataViewTag = '[object DataView]'; /** Used to convert symbols to primitives and strings. */ var symbolProto = Symbol ? Symbol.prototype : undefined, symbolValueOf = symbolProto ? symbolProto.valueOf : undefined; /** * A specialized version of `baseIsEqualDeep` for comparing objects of * the same `toStringTag`. * * **Note:** This function only supports comparing values with tags of * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. * * @private * @param {Object} object The object to compare. * @param {Object} other The other object to compare. * @param {string} tag The `toStringTag` of the objects to compare. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. * @param {Function} customizer The function to customize comparisons. * @param {Function} equalFunc The function to determine equivalents of values. * @param {Object} stack Tracks traversed `object` and `other` objects. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. */ function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) { switch (tag) { case dataViewTag: if ((object.byteLength != other.byteLength) || (object.byteOffset != other.byteOffset)) { return false; } object = object.buffer; other = other.buffer; case arrayBufferTag: if ((object.byteLength != other.byteLength) || !equalFunc(new Uint8Array(object), new Uint8Array(other))) { return false; } return true; case boolTag: case dateTag: case numberTag: // Coerce booleans to `1` or `0` and dates to milliseconds. // Invalid dates are coerced to `NaN`. return eq(+object, +other); case errorTag: return object.name == other.name && object.message == other.message; case regexpTag: case stringTag: // Coerce regexes to strings and treat strings, primitives and objects, // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring // for more details. return object == (other + ''); case mapTag: var convert = mapToArray; case setTag: var isPartial = bitmask & COMPARE_PARTIAL_FLAG; convert || (convert = setToArray); if (object.size != other.size && !isPartial) { return false; } // Assume cyclic values are equal. var stacked = stack.get(object); if (stacked) { return stacked == other; } bitmask |= COMPARE_UNORDERED_FLAG; // Recursively compare objects (susceptible to call stack limits). stack.set(object, other); var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack); stack['delete'](object); return result; case symbolTag: if (symbolValueOf) { return symbolValueOf.call(object) == symbolValueOf.call(other); } } return false; } module.exports = equalByTag; },{"./_Symbol":133,"./_Uint8Array":134,"./_equalArrays":199,"./_mapToArray":240,"./_setToArray":254,"./eq":269}],201:[function(require,module,exports){ var getAllKeys = require('./_getAllKeys'); /** Used to compose bitmasks for value comparisons. */ var COMPARE_PARTIAL_FLAG = 1; /** Used for built-in method references. */ var objectProto = Object.prototype; /** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty; /** * A specialized version of `baseIsEqualDeep` for objects with support for * partial deep comparisons. * * @private * @param {Object} object The object to compare. * @param {Object} other The other object to compare. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. * @param {Function} customizer The function to customize comparisons. * @param {Function} equalFunc The function to determine equivalents of values. * @param {Object} stack Tracks traversed `object` and `other` objects. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. */ function equalObjects(object, other, bitmask, customizer, equalFunc, stack) { var isPartial = bitmask & COMPARE_PARTIAL_FLAG, objProps = getAllKeys(object), objLength = objProps.length, othProps = getAllKeys(other), othLength = othProps.length; if (objLength != othLength && !isPartial) { return false; } var index = objLength; while (index--) { var key = objProps[index]; if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) { return false; } } // Check that cyclic values are equal. var objStacked = stack.get(object); var othStacked = stack.get(other); if (objStacked && othStacked) { return objStacked == other && othStacked == object; } var result = true; stack.set(object, other); stack.set(other, object); var skipCtor = isPartial; while (++index < objLength) { key = objProps[index]; var objValue = object[key], othValue = other[key]; if (customizer) { var compared = isPartial ? customizer(othValue, objValue, key, other, object, stack) : customizer(objValue, othValue, key, object, other, stack); } // Recursively compare objects (susceptible to call stack limits). if (!(compared === undefined ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack)) : compared )) { result = false; break; } skipCtor || (skipCtor = key == 'constructor'); } if (result && !skipCtor) { var objCtor = object.constructor, othCtor = other.constructor; // Non `Object` object instances with different constructors are not equal. if (objCtor != othCtor && ('constructor' in object && 'constructor' in other) && !(typeof objCtor == 'function' && objCtor instanceof objCtor && typeof othCtor == 'function' && othCtor instanceof othCtor)) { result = false; } } stack['delete'](object); stack['delete'](other); return result; } module.exports = equalObjects; },{"./_getAllKeys":203}],202:[function(require,module,exports){ (function (global){ /** Detect free variable `global` from Node.js. */ var freeGlobal = typeof global == 'object' && global && global.Object === Object && global; module.exports = freeGlobal; }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) },{}],203:[function(require,module,exports){ var baseGetAllKeys = require('./_baseGetAllKeys'), getSymbols = require('./_getSymbols'), keys = require('./keys'); /** * Creates an array of own enumerable property names and symbols of `object`. * * @private * @param {Object} object The object to query. * @returns {Array} Returns the array of property names and symbols. */ function getAllKeys(object) { return baseGetAllKeys(object, keys, getSymbols); } module.exports = getAllKeys; },{"./_baseGetAllKeys":155,"./_getSymbols":210,"./keys":291}],204:[function(require,module,exports){ var baseGetAllKeys = require('./_baseGetAllKeys'), getSymbolsIn = require('./_getSymbolsIn'), keysIn = require('./keysIn'); /** * Creates an array of own and inherited enumerable property names and * symbols of `object`. * * @private * @param {Object} object The object to query. * @returns {Array} Returns the array of property names and symbols. */ function getAllKeysIn(object) { return baseGetAllKeys(object, keysIn, getSymbolsIn); } module.exports = getAllKeysIn; },{"./_baseGetAllKeys":155,"./_getSymbolsIn":211,"./keysIn":292}],205:[function(require,module,exports){ var isKeyable = require('./_isKeyable'); /** * Gets the data for `map`. * * @private * @param {Object} map The map to query. * @param {string} key The reference key. * @returns {*} Returns the map data. */ function getMapData(map, key) { var data = map.__data__; return isKeyable(key) ? data[typeof key == 'string' ? 'string' : 'hash'] : data.map; } module.exports = getMapData; },{"./_isKeyable":226}],206:[function(require,module,exports){ var isStrictComparable = require('./_isStrictComparable'), keys = require('./keys'); /** * Gets the property names, values, and compare flags of `object`. * * @private * @param {Object} object The object to query. * @returns {Array} Returns the match data of `object`. */ function getMatchData(object) { var result = keys(object), length = result.length; while (length--) { var key = result[length], value = object[key]; result[length] = [key, value, isStrictComparable(value)]; } return result; } module.exports = getMatchData; },{"./_isStrictComparable":229,"./keys":291}],207:[function(require,module,exports){ var baseIsNative = require('./_baseIsNative'), getValue = require('./_getValue'); /** * Gets the native function at `key` of `object`. * * @private * @param {Object} object The object to query. * @param {string} key The key of the method to get. * @returns {*} Returns the function if it's native, else `undefined`. */ function getNative(object, key) { var value = getValue(object, key); return baseIsNative(value) ? value : undefined; } module.exports = getNative; },{"./_baseIsNative":163,"./_getValue":213}],208:[function(require,module,exports){ var overArg = require('./_overArg'); /** Built-in value references. */ var getPrototype = overArg(Object.getPrototypeOf, Object); module.exports = getPrototype; },{"./_overArg":248}],209:[function(require,module,exports){ var Symbol = require('./_Symbol'); /** Used for built-in method references. */ var objectProto = Object.prototype; /** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty; /** * Used to resolve the * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) * of values. */ var nativeObjectToString = objectProto.toString; /** Built-in value references. */ var symToStringTag = Symbol ? Symbol.toStringTag : undefined; /** * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values. * * @private * @param {*} value The value to query. * @returns {string} Returns the raw `toStringTag`. */ function getRawTag(value) { var isOwn = hasOwnProperty.call(value, symToStringTag), tag = value[symToStringTag]; try { value[symToStringTag] = undefined; var unmasked = true; } catch (e) {} var result = nativeObjectToString.call(value); if (unmasked) { if (isOwn) { value[symToStringTag] = tag; } else { delete value[symToStringTag]; } } return result; } module.exports = getRawTag; },{"./_Symbol":133}],210:[function(require,module,exports){ var arrayFilter = require('./_arrayFilter'), stubArray = require('./stubArray'); /** Used for built-in method references. */ var objectProto = Object.prototype; /** Built-in value references. */ var propertyIsEnumerable = objectProto.propertyIsEnumerable; /* Built-in method references for those with the same name as other `lodash` methods. */ var nativeGetSymbols = Object.getOwnPropertySymbols; /** * Creates an array of the own enumerable symbols of `object`. * * @private * @param {Object} object The object to query. * @returns {Array} Returns the array of symbols. */ var getSymbols = !nativeGetSymbols ? stubArray : function(object) { if (object == null) { return []; } object = Object(object); return arrayFilter(nativeGetSymbols(object), function(symbol) { return propertyIsEnumerable.call(object, symbol); }); }; module.exports = getSymbols; },{"./_arrayFilter":138,"./stubArray":298}],211:[function(require,module,exports){ var arrayPush = require('./_arrayPush'), getPrototype = require('./_getPrototype'), getSymbols = require('./_getSymbols'), stubArray = require('./stubArray'); /* Built-in method references for those with the same name as other `lodash` methods. */ var nativeGetSymbols = Object.getOwnPropertySymbols; /** * Creates an array of the own and inherited enumerable symbols of `object`. * * @private * @param {Object} object The object to query. * @returns {Array} Returns the array of symbols. */ var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) { var result = []; while (object) { arrayPush(result, getSymbols(object)); object = getPrototype(object); } return result; }; module.exports = getSymbolsIn; },{"./_arrayPush":141,"./_getPrototype":208,"./_getSymbols":210,"./stubArray":298}],212:[function(require,module,exports){ var DataView = require('./_DataView'), Map = require('./_Map'), Promise = require('./_Promise'), Set = require('./_Set'), WeakMap = require('./_WeakMap'), baseGetTag = require('./_baseGetTag'), toSource = require('./_toSource'); /** `Object#toString` result references. */ var mapTag = '[object Map]', objectTag = '[object Object]', promiseTag = '[object Promise]', setTag = '[object Set]', weakMapTag = '[object WeakMap]'; var dataViewTag = '[object DataView]'; /** Used to detect maps, sets, and weakmaps. */ var dataViewCtorString = toSource(DataView), mapCtorString = toSource(Map), promiseCtorString = toSource(Promise), setCtorString = toSource(Set), weakMapCtorString = toSource(WeakMap); /** * Gets the `toStringTag` of `value`. * * @private * @param {*} value The value to query. * @returns {string} Returns the `toStringTag`. */ var getTag = baseGetTag; // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6. if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) || (Map && getTag(new Map) != mapTag) || (Promise && getTag(Promise.resolve()) != promiseTag) || (Set && getTag(new Set) != setTag) || (WeakMap && getTag(new WeakMap) != weakMapTag)) { getTag = function(value) { var result = baseGetTag(value), Ctor = result == objectTag ? value.constructor : undefined, ctorString = Ctor ? toSource(Ctor) : ''; if (ctorString) { switch (ctorString) { case dataViewCtorString: return dataViewTag; case mapCtorString: return mapTag; case promiseCtorString: return promiseTag; case setCtorString: return setTag; case weakMapCtorString: return weakMapTag; } } return result; }; } module.exports = getTag; },{"./_DataView":124,"./_Map":127,"./_Promise":129,"./_Set":130,"./_WeakMap":135,"./_baseGetTag":156,"./_toSource":264}],213:[function(require,module,exports){ /** * Gets the value at `key` of `object`. * * @private * @param {Object} [object] The object to query. * @param {string} key The key of the property to get. * @returns {*} Returns the property value. */ function getValue(object, key) { return object == null ? undefined : object[key]; } module.exports = getValue; },{}],214:[function(require,module,exports){ var castPath = require('./_castPath'), isArguments = require('./isArguments'), isArray = require('./isArray'), isIndex = require('./_isIndex'), isLength = require('./isLength'), toKey = require('./_toKey'); /** * Checks if `path` exists on `object`. * * @private * @param {Object} object The object to query. * @param {Array|string} path The path to check. * @param {Function} hasFunc The function to check properties. * @returns {boolean} Returns `true` if `path` exists, else `false`. */ function hasPath(object, path, hasFunc) { path = castPath(path, object); var index = -1, length = path.length, result = false; while (++index < length) { var key = toKey(path[index]); if (!(result = object != null && hasFunc(object, key))) { break; } object = object[key]; } if (result || ++index != length) { return result; } length = object == null ? 0 : object.length; return !!length && isLength(length) && isIndex(key, length) && (isArray(object) || isArguments(object)); } module.exports = hasPath; },{"./_castPath":183,"./_isIndex":223,"./_toKey":263,"./isArguments":275,"./isArray":276,"./isLength":281}],215:[function(require,module,exports){ var nativeCreate = require('./_nativeCreate'); /** * Removes all key-value entries from the hash. * * @private * @name clear * @memberOf Hash */ function hashClear() { this.__data__ = nativeCreate ? nativeCreate(null) : {}; this.size = 0; } module.exports = hashClear; },{"./_nativeCreate":243}],216:[function(require,module,exports){ /** * Removes `key` and its value from the hash. * * @private * @name delete * @memberOf Hash * @param {Object} hash The hash to modify. * @param {string} key The key of the value to remove. * @returns {boolean} Returns `true` if the entry was removed, else `false`. */ function hashDelete(key) { var result = this.has(key) && delete this.__data__[key]; this.size -= result ? 1 : 0; return result; } module.exports = hashDelete; },{}],217:[function(require,module,exports){ var nativeCreate = require('./_nativeCreate'); /** Used to stand-in for `undefined` hash values. */ var HASH_UNDEFINED = '__lodash_hash_undefined__'; /** Used for built-in method references. */ var objectProto = Object.prototype; /** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty; /** * Gets the hash value for `key`. * * @private * @name get * @memberOf Hash * @param {string} key The key of the value to get. * @returns {*} Returns the entry value. */ function hashGet(key) { var data = this.__data__; if (nativeCreate) { var result = data[key]; return result === HASH_UNDEFINED ? undefined : result; } return hasOwnProperty.call(data, key) ? data[key] : undefined; } module.exports = hashGet; },{"./_nativeCreate":243}],218:[function(require,module,exports){ var nativeCreate = require('./_nativeCreate'); /** Used for built-in method references. */ var objectProto = Object.prototype; /** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty; /** * Checks if a hash value for `key` exists. * * @private * @name has * @memberOf Hash * @param {string} key The key of the entry to check. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. */ function hashHas(key) { var data = this.__data__; return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key); } module.exports = hashHas; },{"./_nativeCreate":243}],219:[function(require,module,exports){ var nativeCreate = require('./_nativeCreate'); /** Used to stand-in for `undefined` hash values. */ var HASH_UNDEFINED = '__lodash_hash_undefined__'; /** * Sets the hash `key` to `value`. * * @private * @name set * @memberOf Hash * @param {string} key The key of the value to set. * @param {*} value The value to set. * @returns {Object} Returns the hash instance. */ function hashSet(key, value) { var data = this.__data__; this.size += this.has(key) ? 0 : 1; data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value; return this; } module.exports = hashSet; },{"./_nativeCreate":243}],220:[function(require,module,exports){ /** Used for built-in method references. */ var objectProto = Object.prototype; /** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty; /** * Initializes an array clone. * * @private * @param {Array} array The array to clone. * @returns {Array} Returns the initialized clone. */ function initCloneArray(array) { var length = array.length, result = new array.constructor(length); // Add properties assigned by `RegExp#exec`. if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) { result.index = array.index; result.input = array.input; } return result; } module.exports = initCloneArray; },{}],221:[function(require,module,exports){ var cloneArrayBuffer = require('./_cloneArrayBuffer'), cloneDataView = require('./_cloneDataView'), cloneRegExp = require('./_cloneRegExp'), cloneSymbol = require('./_cloneSymbol'), cloneTypedArray = require('./_cloneTypedArray'); /** `Object#toString` result references. */ var boolTag = '[object Boolean]', dateTag = '[object Date]', mapTag = '[object Map]', numberTag = '[object Number]', regexpTag = '[object RegExp]', setTag = '[object Set]', stringTag = '[object String]', symbolTag = '[object Symbol]'; var arrayBufferTag = '[object ArrayBuffer]', dataViewTag = '[object DataView]', float32Tag = '[object Float32Array]', float64Tag = '[object Float64Array]', int8Tag = '[object Int8Array]', int16Tag = '[object Int16Array]', int32Tag = '[object Int32Array]', uint8Tag = '[object Uint8Array]', uint8ClampedTag = '[object Uint8ClampedArray]', uint16Tag = '[object Uint16Array]', uint32Tag = '[object Uint32Array]'; /** * Initializes an object clone based on its `toStringTag`. * * **Note:** This function only supports cloning values with tags of * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`. * * @private * @param {Object} object The object to clone. * @param {string} tag The `toStringTag` of the object to clone. * @param {boolean} [isDeep] Specify a deep clone. * @returns {Object} Returns the initialized clone. */ function initCloneByTag(object, tag, isDeep) { var Ctor = object.constructor; switch (tag) { case arrayBufferTag: return cloneArrayBuffer(object); case boolTag: case dateTag: return new Ctor(+object); case dataViewTag: return cloneDataView(object, isDeep); case float32Tag: case float64Tag: case int8Tag: case int16Tag: case int32Tag: case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag: return cloneTypedArray(object, isDeep); case mapTag: return new Ctor; case numberTag: case stringTag: return new Ctor(object); case regexpTag: return cloneRegExp(object); case setTag: return new Ctor; case symbolTag: return cloneSymbol(object); } } module.exports = initCloneByTag; },{"./_cloneArrayBuffer":184,"./_cloneDataView":186,"./_cloneRegExp":187,"./_cloneSymbol":188,"./_cloneTypedArray":189}],222:[function(require,module,exports){ var baseCreate = require('./_baseCreate'), getPrototype = require('./_getPrototype'), isPrototype = require('./_isPrototype'); /** * Initializes an object clone. * * @private * @param {Object} object The object to clone. * @returns {Object} Returns the initialized clone. */ function initCloneObject(object) { return (typeof object.constructor == 'function' && !isPrototype(object)) ? baseCreate(getPrototype(object)) : {}; } module.exports = initCloneObject; },{"./_baseCreate":150,"./_getPrototype":208,"./_isPrototype":228}],223:[function(require,module,exports){ /** Used as references for various `Number` constants. */ var MAX_SAFE_INTEGER = 9007199254740991; /** Used to detect unsigned integer values. */ var reIsUint = /^(?:0|[1-9]\d*)$/; /** * Checks if `value` is a valid array-like index. * * @private * @param {*} value The value to check. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. */ function isIndex(value, length) { var type = typeof value; length = length == null ? MAX_SAFE_INTEGER : length; return !!length && (type == 'number' || (type != 'symbol' && reIsUint.test(value))) && (value > -1 && value % 1 == 0 && value < length); } module.exports = isIndex; },{}],224:[function(require,module,exports){ var eq = require('./eq'), isArrayLike = require('./isArrayLike'), isIndex = require('./_isIndex'), isObject = require('./isObject'); /** * Checks if the given arguments are from an iteratee call. * * @private * @param {*} value The potential iteratee value argument. * @param {*} index The potential iteratee index or key argument. * @param {*} object The potential iteratee object argument. * @returns {boolean} Returns `true` if the arguments are from an iteratee call, * else `false`. */ function isIterateeCall(value, index, object) { if (!isObject(object)) { return false; } var type = typeof index; if (type == 'number' ? (isArrayLike(object) && isIndex(index, object.length)) : (type == 'string' && index in object) ) { return eq(object[index], value); } return false; } module.exports = isIterateeCall; },{"./_isIndex":223,"./eq":269,"./isArrayLike":277,"./isObject":283}],225:[function(require,module,exports){ var isArray = require('./isArray'), isSymbol = require('./isSymbol'); /** Used to match property names within property paths. */ var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, reIsPlainProp = /^\w*$/; /** * Checks if `value` is a property name and not a property path. * * @private * @param {*} value The value to check. * @param {Object} [object] The object to query keys on. * @returns {boolean} Returns `true` if `value` is a property name, else `false`. */ function isKey(value, object) { if (isArray(value)) { return false; } var type = typeof value; if (type == 'number' || type == 'symbol' || type == 'boolean' || value == null || isSymbol(value)) { return true; } return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || (object != null && value in Object(object)); } module.exports = isKey; },{"./isArray":276,"./isSymbol":288}],226:[function(require,module,exports){ /** * Checks if `value` is suitable for use as unique object key. * * @private * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is suitable, else `false`. */ function isKeyable(value) { var type = typeof value; return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean') ? (value !== '__proto__') : (value === null); } module.exports = isKeyable; },{}],227:[function(require,module,exports){ var coreJsData = require('./_coreJsData'); /** Used to detect methods masquerading as native. */ var maskSrcKey = (function() { var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || ''); return uid ? ('Symbol(src)_1.' + uid) : ''; }()); /** * Checks if `func` has its source masked. * * @private * @param {Function} func The function to check. * @returns {boolean} Returns `true` if `func` is masked, else `false`. */ function isMasked(func) { return !!maskSrcKey && (maskSrcKey in func); } module.exports = isMasked; },{"./_coreJsData":194}],228:[function(require,module,exports){ /** Used for built-in method references. */ var objectProto = Object.prototype; /** * Checks if `value` is likely a prototype object. * * @private * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is a prototype, else `false`. */ function isPrototype(value) { var Ctor = value && value.constructor, proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto; return value === proto; } module.exports = isPrototype; },{}],229:[function(require,module,exports){ var isObject = require('./isObject'); /** * Checks if `value` is suitable for strict equality comparisons, i.e. `===`. * * @private * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` if suitable for strict * equality comparisons, else `false`. */ function isStrictComparable(value) { return value === value && !isObject(value); } module.exports = isStrictComparable; },{"./isObject":283}],230:[function(require,module,exports){ /** * Removes all key-value entries from the list cache. * * @private * @name clear * @memberOf ListCache */ function listCacheClear() { this.__data__ = []; this.size = 0; } module.exports = listCacheClear; },{}],231:[function(require,module,exports){ var assocIndexOf = require('./_assocIndexOf'); /** Used for built-in method references. */ var arrayProto = Array.prototype; /** Built-in value references. */ var splice = arrayProto.splice; /** * Removes `key` and its value from the list cache. * * @private * @name delete * @memberOf ListCache * @param {string} key The key of the value to remove. * @returns {boolean} Returns `true` if the entry was removed, else `false`. */ function listCacheDelete(key) { var data = this.__data__, index = assocIndexOf(data, key); if (index < 0) { return false; } var lastIndex = data.length - 1; if (index == lastIndex) { data.pop(); } else { splice.call(data, index, 1); } --this.size; return true; } module.exports = listCacheDelete; },{"./_assocIndexOf":145}],232:[function(require,module,exports){ var assocIndexOf = require('./_assocIndexOf'); /** * Gets the list cache value for `key`. * * @private * @name get * @memberOf ListCache * @param {string} key The key of the value to get. * @returns {*} Returns the entry value. */ function listCacheGet(key) { var data = this.__data__, index = assocIndexOf(data, key); return index < 0 ? undefined : data[index][1]; } module.exports = listCacheGet; },{"./_assocIndexOf":145}],233:[function(require,module,exports){ var assocIndexOf = require('./_assocIndexOf'); /** * Checks if a list cache value for `key` exists. * * @private * @name has * @memberOf ListCache * @param {string} key The key of the entry to check. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. */ function listCacheHas(key) { return assocIndexOf(this.__data__, key) > -1; } module.exports = listCacheHas; },{"./_assocIndexOf":145}],234:[function(require,module,exports){ var assocIndexOf = require('./_assocIndexOf'); /** * Sets the list cache `key` to `value`. * * @private * @name set * @memberOf ListCache * @param {string} key The key of the value to set. * @param {*} value The value to set. * @returns {Object} Returns the list cache instance. */ function listCacheSet(key, value) { var data = this.__data__, index = assocIndexOf(data, key); if (index < 0) { ++this.size; data.push([key, value]); } else { data[index][1] = value; } return this; } module.exports = listCacheSet; },{"./_assocIndexOf":145}],235:[function(require,module,exports){ var Hash = require('./_Hash'), ListCache = require('./_ListCache'), Map = require('./_Map'); /** * Removes all key-value entries from the map. * * @private * @name clear * @memberOf MapCache */ function mapCacheClear() { this.size = 0; this.__data__ = { 'hash': new Hash, 'map': new (Map || ListCache), 'string': new Hash }; } module.exports = mapCacheClear; },{"./_Hash":125,"./_ListCache":126,"./_Map":127}],236:[function(require,module,exports){ var getMapData = require('./_getMapData'); /** * Removes `key` and its value from the map. * * @private * @name delete * @memberOf MapCache * @param {string} key The key of the value to remove. * @returns {boolean} Returns `true` if the entry was removed, else `false`. */ function mapCacheDelete(key) { var result = getMapData(this, key)['delete'](key); this.size -= result ? 1 : 0; return result; } module.exports = mapCacheDelete; },{"./_getMapData":205}],237:[function(require,module,exports){ var getMapData = require('./_getMapData'); /** * Gets the map value for `key`. * * @private * @name get * @memberOf MapCache * @param {string} key The key of the value to get. * @returns {*} Returns the entry value. */ function mapCacheGet(key) { return getMapData(this, key).get(key); } module.exports = mapCacheGet; },{"./_getMapData":205}],238:[function(require,module,exports){ var getMapData = require('./_getMapData'); /** * Checks if a map value for `key` exists. * * @private * @name has * @memberOf MapCache * @param {string} key The key of the entry to check. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. */ function mapCacheHas(key) { return getMapData(this, key).has(key); } module.exports = mapCacheHas; },{"./_getMapData":205}],239:[function(require,module,exports){ var getMapData = require('./_getMapData'); /** * Sets the map `key` to `value`. * * @private * @name set * @memberOf MapCache * @param {string} key The key of the value to set. * @param {*} value The value to set. * @returns {Object} Returns the map cache instance. */ function mapCacheSet(key, value) { var data = getMapData(this, key), size = data.size; data.set(key, value); this.size += data.size == size ? 0 : 1; return this; } module.exports = mapCacheSet; },{"./_getMapData":205}],240:[function(require,module,exports){ /** * Converts `map` to its key-value pairs. * * @private * @param {Object} map The map to convert. * @returns {Array} Returns the key-value pairs. */ function mapToArray(map) { var index = -1, result = Array(map.size); map.forEach(function(value, key) { result[++index] = [key, value]; }); return result; } module.exports = mapToArray; },{}],241:[function(require,module,exports){ /** * A specialized version of `matchesProperty` for source values suitable * for strict equality comparisons, i.e. `===`. * * @private * @param {string} key The key of the property to get. * @param {*} srcValue The value to match. * @returns {Function} Returns the new spec function. */ function matchesStrictComparable(key, srcValue) { return function(object) { if (object == null) { return false; } return object[key] === srcValue && (srcValue !== undefined || (key in Object(object))); }; } module.exports = matchesStrictComparable; },{}],242:[function(require,module,exports){ var memoize = require('./memoize'); /** Used as the maximum memoize cache size. */ var MAX_MEMOIZE_SIZE = 500; /** * A specialized version of `_.memoize` which clears the memoized function's * cache when it exceeds `MAX_MEMOIZE_SIZE`. * * @private * @param {Function} func The function to have its output memoized. * @returns {Function} Returns the new memoized function. */ function memoizeCapped(func) { var result = memoize(func, function(key) { if (cache.size === MAX_MEMOIZE_SIZE) { cache.clear(); } return key; }); var cache = result.cache; return result; } module.exports = memoizeCapped; },{"./memoize":294}],243:[function(require,module,exports){ var getNative = require('./_getNative'); /* Built-in method references that are verified to be native. */ var nativeCreate = getNative(Object, 'create'); module.exports = nativeCreate; },{"./_getNative":207}],244:[function(require,module,exports){ var overArg = require('./_overArg'); /* Built-in method references for those with the same name as other `lodash` methods. */ var nativeKeys = overArg(Object.keys, Object); module.exports = nativeKeys; },{"./_overArg":248}],245:[function(require,module,exports){ /** * This function is like * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) * except that it includes inherited enumerable properties. * * @private * @param {Object} object The object to query. * @returns {Array} Returns the array of property names. */ function nativeKeysIn(object) { var result = []; if (object != null) { for (var key in Object(object)) { result.push(key); } } return result; } module.exports = nativeKeysIn; },{}],246:[function(require,module,exports){ var freeGlobal = require('./_freeGlobal'); /** Detect free variable `exports`. */ var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports; /** Detect free variable `module`. */ var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module; /** Detect the popular CommonJS extension `module.exports`. */ var moduleExports = freeModule && freeModule.exports === freeExports; /** Detect free variable `process` from Node.js. */ var freeProcess = moduleExports && freeGlobal.process; /** Used to access faster Node.js helpers. */ var nodeUtil = (function() { try { // Use `util.types` for Node.js 10+. var types = freeModule && freeModule.require && freeModule.require('util').types; if (types) { return types; } // Legacy `process.binding('util')` for Node.js < 10. return freeProcess && freeProcess.binding && freeProcess.binding('util'); } catch (e) {} }()); module.exports = nodeUtil; },{"./_freeGlobal":202}],247:[function(require,module,exports){ /** Used for built-in method references. */ var objectProto = Object.prototype; /** * Used to resolve the * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) * of values. */ var nativeObjectToString = objectProto.toString; /** * Converts `value` to a string using `Object.prototype.toString`. * * @private * @param {*} value The value to convert. * @returns {string} Returns the converted string. */ function objectToString(value) { return nativeObjectToString.call(value); } module.exports = objectToString; },{}],248:[function(require,module,exports){ /** * Creates a unary function that invokes `func` with its argument transformed. * * @private * @param {Function} func The function to wrap. * @param {Function} transform The argument transform. * @returns {Function} Returns the new function. */ function overArg(func, transform) { return function(arg) { return func(transform(arg)); }; } module.exports = overArg; },{}],249:[function(require,module,exports){ var apply = require('./_apply'); /* Built-in method references for those with the same name as other `lodash` methods. */ var nativeMax = Math.max; /** * A specialized version of `baseRest` which transforms the rest array. * * @private * @param {Function} func The function to apply a rest parameter to. * @param {number} [start=func.length-1] The start position of the rest parameter. * @param {Function} transform The rest array transform. * @returns {Function} Returns the new function. */ function overRest(func, start, transform) { start = nativeMax(start === undefined ? (func.length - 1) : start, 0); return function() { var args = arguments, index = -1, length = nativeMax(args.length - start, 0), array = Array(length); while (++index < length) { array[index] = args[start + index]; } index = -1; var otherArgs = Array(start + 1); while (++index < start) { otherArgs[index] = args[index]; } otherArgs[start] = transform(array); return apply(func, this, otherArgs); }; } module.exports = overRest; },{"./_apply":136}],250:[function(require,module,exports){ var freeGlobal = require('./_freeGlobal'); /** Detect free variable `self`. */ var freeSelf = typeof self == 'object' && self && self.Object === Object && self; /** Used as a reference to the global object. */ var root = freeGlobal || freeSelf || Function('return this')(); module.exports = root; },{"./_freeGlobal":202}],251:[function(require,module,exports){ /** * Gets the value at `key`, unless `key` is "__proto__" or "constructor". * * @private * @param {Object} object The object to query. * @param {string} key The key of the property to get. * @returns {*} Returns the property value. */ function safeGet(object, key) { if (key === 'constructor' && typeof object[key] === 'function') { return; } if (key == '__proto__') { return; } return object[key]; } module.exports = safeGet; },{}],252:[function(require,module,exports){ /** Used to stand-in for `undefined` hash values. */ var HASH_UNDEFINED = '__lodash_hash_undefined__'; /** * Adds `value` to the array cache. * * @private * @name add * @memberOf SetCache * @alias push * @param {*} value The value to cache. * @returns {Object} Returns the cache instance. */ function setCacheAdd(value) { this.__data__.set(value, HASH_UNDEFINED); return this; } module.exports = setCacheAdd; },{}],253:[function(require,module,exports){ /** * Checks if `value` is in the array cache. * * @private * @name has * @memberOf SetCache * @param {*} value The value to search for. * @returns {number} Returns `true` if `value` is found, else `false`. */ function setCacheHas(value) { return this.__data__.has(value); } module.exports = setCacheHas; },{}],254:[function(require,module,exports){ /** * Converts `set` to an array of its values. * * @private * @param {Object} set The set to convert. * @returns {Array} Returns the values. */ function setToArray(set) { var index = -1, result = Array(set.size); set.forEach(function(value) { result[++index] = value; }); return result; } module.exports = setToArray; },{}],255:[function(require,module,exports){ var baseSetToString = require('./_baseSetToString'), shortOut = require('./_shortOut'); /** * Sets the `toString` method of `func` to return `string`. * * @private * @param {Function} func The function to modify. * @param {Function} string The `toString` result. * @returns {Function} Returns `func`. */ var setToString = shortOut(baseSetToString); module.exports = setToString; },{"./_baseSetToString":177,"./_shortOut":256}],256:[function(require,module,exports){ /** Used to detect hot functions by number of calls within a span of milliseconds. */ var HOT_COUNT = 800, HOT_SPAN = 16; /* Built-in method references for those with the same name as other `lodash` methods. */ var nativeNow = Date.now; /** * Creates a function that'll short out and invoke `identity` instead * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN` * milliseconds. * * @private * @param {Function} func The function to restrict. * @returns {Function} Returns the new shortable function. */ function shortOut(func) { var count = 0, lastCalled = 0; return function() { var stamp = nativeNow(), remaining = HOT_SPAN - (stamp - lastCalled); lastCalled = stamp; if (remaining > 0) { if (++count >= HOT_COUNT) { return arguments[0]; } } else { count = 0; } return func.apply(undefined, arguments); }; } module.exports = shortOut; },{}],257:[function(require,module,exports){ var ListCache = require('./_ListCache'); /** * Removes all key-value entries from the stack. * * @private * @name clear * @memberOf Stack */ function stackClear() { this.__data__ = new ListCache; this.size = 0; } module.exports = stackClear; },{"./_ListCache":126}],258:[function(require,module,exports){ /** * Removes `key` and its value from the stack. * * @private * @name delete * @memberOf Stack * @param {string} key The key of the value to remove. * @returns {boolean} Returns `true` if the entry was removed, else `false`. */ function stackDelete(key) { var data = this.__data__, result = data['delete'](key); this.size = data.size; return result; } module.exports = stackDelete; },{}],259:[function(require,module,exports){ /** * Gets the stack value for `key`. * * @private * @name get * @memberOf Stack * @param {string} key The key of the value to get. * @returns {*} Returns the entry value. */ function stackGet(key) { return this.__data__.get(key); } module.exports = stackGet; },{}],260:[function(require,module,exports){ /** * Checks if a stack value for `key` exists. * * @private * @name has * @memberOf Stack * @param {string} key The key of the entry to check. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. */ function stackHas(key) { return this.__data__.has(key); } module.exports = stackHas; },{}],261:[function(require,module,exports){ var ListCache = require('./_ListCache'), Map = require('./_Map'), MapCache = require('./_MapCache'); /** Used as the size to enable large array optimizations. */ var LARGE_ARRAY_SIZE = 200; /** * Sets the stack `key` to `value`. * * @private * @name set * @memberOf Stack * @param {string} key The key of the value to set. * @param {*} value The value to set. * @returns {Object} Returns the stack cache instance. */ function stackSet(key, value) { var data = this.__data__; if (data instanceof ListCache) { var pairs = data.__data__; if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) { pairs.push([key, value]); this.size = ++data.size; return this; } data = this.__data__ = new MapCache(pairs); } data.set(key, value); this.size = data.size; return this; } module.exports = stackSet; },{"./_ListCache":126,"./_Map":127,"./_MapCache":128}],262:[function(require,module,exports){ var memoizeCapped = require('./_memoizeCapped'); /** Used to match property names within property paths. */ var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g; /** Used to match backslashes in property paths. */ var reEscapeChar = /\\(\\)?/g; /** * Converts `string` to a property path array. * * @private * @param {string} string The string to convert. * @returns {Array} Returns the property path array. */ var stringToPath = memoizeCapped(function(string) { var result = []; if (string.charCodeAt(0) === 46 /* . */) { result.push(''); } string.replace(rePropName, function(match, number, quote, subString) { result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match)); }); return result; }); module.exports = stringToPath; },{"./_memoizeCapped":242}],263:[function(require,module,exports){ var isSymbol = require('./isSymbol'); /** Used as references for various `Number` constants. */ var INFINITY = 1 / 0; /** * Converts `value` to a string key if it's not a string or symbol. * * @private * @param {*} value The value to inspect. * @returns {string|symbol} Returns the key. */ function toKey(value) { if (typeof value == 'string' || isSymbol(value)) { return value; } var result = (value + ''); return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; } module.exports = toKey; },{"./isSymbol":288}],264:[function(require,module,exports){ /** Used for built-in method references. */ var funcProto = Function.prototype; /** Used to resolve the decompiled source of functions. */ var funcToString = funcProto.toString; /** * Converts `func` to its source code. * * @private * @param {Function} func The function to convert. * @returns {string} Returns the source code. */ function toSource(func) { if (func != null) { try { return funcToString.call(func); } catch (e) {} try { return (func + ''); } catch (e) {} } return ''; } module.exports = toSource; },{}],265:[function(require,module,exports){ var baseClone = require('./_baseClone'); /** Used to compose bitmasks for cloning. */ var CLONE_DEEP_FLAG = 1, CLONE_SYMBOLS_FLAG = 4; /** * This method is like `_.clone` except that it recursively clones `value`. * * @static * @memberOf _ * @since 1.0.0 * @category Lang * @param {*} value The value to recursively clone. * @returns {*} Returns the deep cloned value. * @see _.clone * @example * * var objects = [{ 'a': 1 }, { 'b': 2 }]; * * var deep = _.cloneDeep(objects); * console.log(deep[0] === objects[0]); * // => false */ function cloneDeep(value) { return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG); } module.exports = cloneDeep; },{"./_baseClone":149}],266:[function(require,module,exports){ /** * Creates a function that returns `value`. * * @static * @memberOf _ * @since 2.4.0 * @category Util * @param {*} value The value to return from the new function. * @returns {Function} Returns the new constant function. * @example * * var objects = _.times(2, _.constant({ 'a': 1 })); * * console.log(objects); * // => [{ 'a': 1 }, { 'a': 1 }] * * console.log(objects[0] === objects[1]); * // => true */ function constant(value) { return function() { return value; }; } module.exports = constant; },{}],267:[function(require,module,exports){ var isObject = require('./isObject'), now = require('./now'), toNumber = require('./toNumber'); /** Error message constants. */ var FUNC_ERROR_TEXT = 'Expected a function'; /* Built-in method references for those with the same name as other `lodash` methods. */ var nativeMax = Math.max, nativeMin = Math.min; /** * Creates a debounced function that delays invoking `func` until after `wait` * milliseconds have elapsed since the last time the debounced function was * invoked. The debounced function comes with a `cancel` method to cancel * delayed `func` invocations and a `flush` method to immediately invoke them. * Provide `options` to indicate whether `func` should be invoked on the * leading and/or trailing edge of the `wait` timeout. The `func` is invoked * with the last arguments provided to the debounced function. Subsequent * calls to the debounced function return the result of the last `func` * invocation. * * **Note:** If `leading` and `trailing` options are `true`, `func` is * invoked on the trailing edge of the timeout only if the debounced function * is invoked more than once during the `wait` timeout. * * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred * until to the next tick, similar to `setTimeout` with a timeout of `0`. * * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/) * for details over the differences between `_.debounce` and `_.throttle`. * * @static * @memberOf _ * @since 0.1.0 * @category Function * @param {Function} func The function to debounce. * @param {number} [wait=0] The number of milliseconds to delay. * @param {Object} [options={}] The options object. * @param {boolean} [options.leading=false] * Specify invoking on the leading edge of the timeout. * @param {number} [options.maxWait] * The maximum time `func` is allowed to be delayed before it's invoked. * @param {boolean} [options.trailing=true] * Specify invoking on the trailing edge of the timeout. * @returns {Function} Returns the new debounced function. * @example * * // Avoid costly calculations while the window size is in flux. * jQuery(window).on('resize', _.debounce(calculateLayout, 150)); * * // Invoke `sendMail` when clicked, debouncing subsequent calls. * jQuery(element).on('click', _.debounce(sendMail, 300, { * 'leading': true, * 'trailing': false * })); * * // Ensure `batchLog` is invoked once after 1 second of debounced calls. * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 }); * var source = new EventSource('/stream'); * jQuery(source).on('message', debounced); * * // Cancel the trailing debounced invocation. * jQuery(window).on('popstate', debounced.cancel); */ function debounce(func, wait, options) { var lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true; if (typeof func != 'function') { throw new TypeError(FUNC_ERROR_TEXT); } wait = toNumber(wait) || 0; if (isObject(options)) { leading = !!options.leading; maxing = 'maxWait' in options; maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait; trailing = 'trailing' in options ? !!options.trailing : trailing; } function invokeFunc(time) { var args = lastArgs, thisArg = lastThis; lastArgs = lastThis = undefined; lastInvokeTime = time; result = func.apply(thisArg, args); return result; } function leadingEdge(time) { // Reset any `maxWait` timer. lastInvokeTime = time; // Start the timer for the trailing edge. timerId = setTimeout(timerExpired, wait); // Invoke the leading edge. return leading ? invokeFunc(time) : result; } function remainingWait(time) { var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime, timeWaiting = wait - timeSinceLastCall; return maxing ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) : timeWaiting; } function shouldInvoke(time) { var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime; // Either this is the first call, activity has stopped and we're at the // trailing edge, the system time has gone backwards and we're treating // it as the trailing edge, or we've hit the `maxWait` limit. return (lastCallTime === undefined || (timeSinceLastCall >= wait) || (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait)); } function timerExpired() { var time = now(); if (shouldInvoke(time)) { return trailingEdge(time); } // Restart the timer. timerId = setTimeout(timerExpired, remainingWait(time)); } function trailingEdge(time) { timerId = undefined; // Only invoke if we have `lastArgs` which means `func` has been // debounced at least once. if (trailing && lastArgs) { return invokeFunc(time); } lastArgs = lastThis = undefined; return result; } function cancel() { if (timerId !== undefined) { clearTimeout(timerId); } lastInvokeTime = 0; lastArgs = lastCallTime = lastThis = timerId = undefined; } function flush() { return timerId === undefined ? result : trailingEdge(now()); } function debounced() { var time = now(), isInvoking = shouldInvoke(time); lastArgs = arguments; lastThis = this; lastCallTime = time; if (isInvoking) { if (timerId === undefined) { return leadingEdge(lastCallTime); } if (maxing) { // Handle invocations in a tight loop. clearTimeout(timerId); timerId = setTimeout(timerExpired, wait); return invokeFunc(lastCallTime); } } if (timerId === undefined) { timerId = setTimeout(timerExpired, wait); } return result; } debounced.cancel = cancel; debounced.flush = flush; return debounced; } module.exports = debounce; },{"./isObject":283,"./now":296,"./toNumber":301}],268:[function(require,module,exports){ module.exports = require('./forEach'); },{"./forEach":270}],269:[function(require,module,exports){ /** * Performs a * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) * comparison between two values to determine if they are equivalent. * * @static * @memberOf _ * @since 4.0.0 * @category Lang * @param {*} value The value to compare. * @param {*} other The other value to compare. * @returns {boolean} Returns `true` if the values are equivalent, else `false`. * @example * * var object = { 'a': 1 }; * var other = { 'a': 1 }; * * _.eq(object, object); * // => true * * _.eq(object, other); * // => false * * _.eq('a', 'a'); * // => true * * _.eq('a', Object('a')); * // => false * * _.eq(NaN, NaN); * // => true */ function eq(value, other) { return value === other || (value !== value && other !== other); } module.exports = eq; },{}],270:[function(require,module,exports){ var arrayEach = require('./_arrayEach'), baseEach = require('./_baseEach'), castFunction = require('./_castFunction'), isArray = require('./isArray'); /** * Iterates over elements of `collection` and invokes `iteratee` for each element. * The iteratee is invoked with three arguments: (value, index|key, collection). * Iteratee functions may exit iteration early by explicitly returning `false`. * * **Note:** As with other "Collections" methods, objects with a "length" * property are iterated like arrays. To avoid this behavior use `_.forIn` * or `_.forOwn` for object iteration. * * @static * @memberOf _ * @since 0.1.0 * @alias each * @category Collection * @param {Array|Object} collection The collection to iterate over. * @param {Function} [iteratee=_.identity] The function invoked per iteration. * @returns {Array|Object} Returns `collection`. * @see _.forEachRight * @example * * _.forEach([1, 2], function(value) { * console.log(value); * }); * // => Logs `1` then `2`. * * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) { * console.log(key); * }); * // => Logs 'a' then 'b' (iteration order is not guaranteed). */ function forEach(collection, iteratee) { var func = isArray(collection) ? arrayEach : baseEach; return func(collection, castFunction(iteratee)); } module.exports = forEach; },{"./_arrayEach":137,"./_baseEach":151,"./_castFunction":182,"./isArray":276}],271:[function(require,module,exports){ var baseForOwn = require('./_baseForOwn'), castFunction = require('./_castFunction'); /** * Iterates over own enumerable string keyed properties of an object and * invokes `iteratee` for each property. The iteratee is invoked with three * arguments: (value, key, object). Iteratee functions may exit iteration * early by explicitly returning `false`. * * @static * @memberOf _ * @since 0.3.0 * @category Object * @param {Object} object The object to iterate over. * @param {Function} [iteratee=_.identity] The function invoked per iteration. * @returns {Object} Returns `object`. * @see _.forOwnRight * @example * * function Foo() { * this.a = 1; * this.b = 2; * } * * Foo.prototype.c = 3; * * _.forOwn(new Foo, function(value, key) { * console.log(key); * }); * // => Logs 'a' then 'b' (iteration order is not guaranteed). */ function forOwn(object, iteratee) { return object && baseForOwn(object, castFunction(iteratee)); } module.exports = forOwn; },{"./_baseForOwn":153,"./_castFunction":182}],272:[function(require,module,exports){ var baseGet = require('./_baseGet'); /** * Gets the value at `path` of `object`. If the resolved value is * `undefined`, the `defaultValue` is returned in its place. * * @static * @memberOf _ * @since 3.7.0 * @category Object * @param {Object} object The object to query. * @param {Array|string} path The path of the property to get. * @param {*} [defaultValue] The value returned for `undefined` resolved values. * @returns {*} Returns the resolved value. * @example * * var object = { 'a': [{ 'b': { 'c': 3 } }] }; * * _.get(object, 'a[0].b.c'); * // => 3 * * _.get(object, ['a', '0', 'b', 'c']); * // => 3 * * _.get(object, 'a.b.c', 'default'); * // => 'default' */ function get(object, path, defaultValue) { var result = object == null ? undefined : baseGet(object, path); return result === undefined ? defaultValue : result; } module.exports = get; },{"./_baseGet":154}],273:[function(require,module,exports){ var baseHasIn = require('./_baseHasIn'), hasPath = require('./_hasPath'); /** * Checks if `path` is a direct or inherited property of `object`. * * @static * @memberOf _ * @since 4.0.0 * @category Object * @param {Object} object The object to query. * @param {Array|string} path The path to check. * @returns {boolean} Returns `true` if `path` exists, else `false`. * @example * * var object = _.create({ 'a': _.create({ 'b': 2 }) }); * * _.hasIn(object, 'a'); * // => true * * _.hasIn(object, 'a.b'); * // => true * * _.hasIn(object, ['a', 'b']); * // => true * * _.hasIn(object, 'b'); * // => false */ function hasIn(object, path) { return object != null && hasPath(object, path, baseHasIn); } module.exports = hasIn; },{"./_baseHasIn":157,"./_hasPath":214}],274:[function(require,module,exports){ /** * This method returns the first argument it receives. * * @static * @since 0.1.0 * @memberOf _ * @category Util * @param {*} value Any value. * @returns {*} Returns `value`. * @example * * var object = { 'a': 1 }; * * console.log(_.identity(object) === object); * // => true */ function identity(value) { return value; } module.exports = identity; },{}],275:[function(require,module,exports){ var baseIsArguments = require('./_baseIsArguments'), isObjectLike = require('./isObjectLike'); /** Used for built-in method references. */ var objectProto = Object.prototype; /** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty; /** Built-in value references. */ var propertyIsEnumerable = objectProto.propertyIsEnumerable; /** * Checks if `value` is likely an `arguments` object. * * @static * @memberOf _ * @since 0.1.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is an `arguments` object, * else `false`. * @example * * _.isArguments(function() { return arguments; }()); * // => true * * _.isArguments([1, 2, 3]); * // => false */ var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) { return isObjectLike(value) && hasOwnProperty.call(value, 'callee') && !propertyIsEnumerable.call(value, 'callee'); }; module.exports = isArguments; },{"./_baseIsArguments":158,"./isObjectLike":284}],276:[function(require,module,exports){ /** * Checks if `value` is classified as an `Array` object. * * @static * @memberOf _ * @since 0.1.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is an array, else `false`. * @example * * _.isArray([1, 2, 3]); * // => true * * _.isArray(document.body.children); * // => false * * _.isArray('abc'); * // => false * * _.isArray(_.noop); * // => false */ var isArray = Array.isArray; module.exports = isArray; },{}],277:[function(require,module,exports){ var isFunction = require('./isFunction'), isLength = require('./isLength'); /** * Checks if `value` is array-like. A value is considered array-like if it's * not a function and has a `value.length` that's an integer greater than or * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`. * * @static * @memberOf _ * @since 4.0.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is array-like, else `false`. * @example * * _.isArrayLike([1, 2, 3]); * // => true * * _.isArrayLike(document.body.children); * // => true * * _.isArrayLike('abc'); * // => true * * _.isArrayLike(_.noop); * // => false */ function isArrayLike(value) { return value != null && isLength(value.length) && !isFunction(value); } module.exports = isArrayLike; },{"./isFunction":280,"./isLength":281}],278:[function(require,module,exports){ var isArrayLike = require('./isArrayLike'), isObjectLike = require('./isObjectLike'); /** * This method is like `_.isArrayLike` except that it also checks if `value` * is an object. * * @static * @memberOf _ * @since 4.0.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is an array-like object, * else `false`. * @example * * _.isArrayLikeObject([1, 2, 3]); * // => true * * _.isArrayLikeObject(document.body.children); * // => true * * _.isArrayLikeObject('abc'); * // => false * * _.isArrayLikeObject(_.noop); * // => false */ function isArrayLikeObject(value) { return isObjectLike(value) && isArrayLike(value); } module.exports = isArrayLikeObject; },{"./isArrayLike":277,"./isObjectLike":284}],279:[function(require,module,exports){ var root = require('./_root'), stubFalse = require('./stubFalse'); /** Detect free variable `exports`. */ var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports; /** Detect free variable `module`. */ var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module; /** Detect the popular CommonJS extension `module.exports`. */ var moduleExports = freeModule && freeModule.exports === freeExports; /** Built-in value references. */ var Buffer = moduleExports ? root.Buffer : undefined; /* Built-in method references for those with the same name as other `lodash` methods. */ var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined; /** * Checks if `value` is a buffer. * * @static * @memberOf _ * @since 4.3.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is a buffer, else `false`. * @example * * _.isBuffer(new Buffer(2)); * // => true * * _.isBuffer(new Uint8Array(2)); * // => false */ var isBuffer = nativeIsBuffer || stubFalse; module.exports = isBuffer; },{"./_root":250,"./stubFalse":299}],280:[function(require,module,exports){ var baseGetTag = require('./_baseGetTag'), isObject = require('./isObject'); /** `Object#toString` result references. */ var asyncTag = '[object AsyncFunction]', funcTag = '[object Function]', genTag = '[object GeneratorFunction]', proxyTag = '[object Proxy]'; /** * Checks if `value` is classified as a `Function` object. * * @static * @memberOf _ * @since 0.1.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is a function, else `false`. * @example * * _.isFunction(_); * // => true * * _.isFunction(/abc/); * // => false */ function isFunction(value) { if (!isObject(value)) { return false; } // The use of `Object#toString` avoids issues with the `typeof` operator // in Safari 9 which returns 'object' for typed arrays and other constructors. var tag = baseGetTag(value); return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag; } module.exports = isFunction; },{"./_baseGetTag":156,"./isObject":283}],281:[function(require,module,exports){ /** Used as references for various `Number` constants. */ var MAX_SAFE_INTEGER = 9007199254740991; /** * Checks if `value` is a valid array-like length. * * **Note:** This method is loosely based on * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). * * @static * @memberOf _ * @since 4.0.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. * @example * * _.isLength(3); * // => true * * _.isLength(Number.MIN_VALUE); * // => false * * _.isLength(Infinity); * // => false * * _.isLength('3'); * // => false */ function isLength(value) { return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; } module.exports = isLength; },{}],282:[function(require,module,exports){ var baseIsMap = require('./_baseIsMap'), baseUnary = require('./_baseUnary'), nodeUtil = require('./_nodeUtil'); /* Node.js helper references. */ var nodeIsMap = nodeUtil && nodeUtil.isMap; /** * Checks if `value` is classified as a `Map` object. * * @static * @memberOf _ * @since 4.3.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is a map, else `false`. * @example * * _.isMap(new Map); * // => true * * _.isMap(new WeakMap); * // => false */ var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap; module.exports = isMap; },{"./_baseIsMap":161,"./_baseUnary":180,"./_nodeUtil":246}],283:[function(require,module,exports){ /** * Checks if `value` is the * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types) * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) * * @static * @memberOf _ * @since 0.1.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is an object, else `false`. * @example * * _.isObject({}); * // => true * * _.isObject([1, 2, 3]); * // => true * * _.isObject(_.noop); * // => true * * _.isObject(null); * // => false */ function isObject(value) { var type = typeof value; return value != null && (type == 'object' || type == 'function'); } module.exports = isObject; },{}],284:[function(require,module,exports){ /** * Checks if `value` is object-like. A value is object-like if it's not `null` * and has a `typeof` result of "object". * * @static * @memberOf _ * @since 4.0.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is object-like, else `false`. * @example * * _.isObjectLike({}); * // => true * * _.isObjectLike([1, 2, 3]); * // => true * * _.isObjectLike(_.noop); * // => false * * _.isObjectLike(null); * // => false */ function isObjectLike(value) { return value != null && typeof value == 'object'; } module.exports = isObjectLike; },{}],285:[function(require,module,exports){ var baseGetTag = require('./_baseGetTag'), getPrototype = require('./_getPrototype'), isObjectLike = require('./isObjectLike'); /** `Object#toString` result references. */ var objectTag = '[object Object]'; /** Used for built-in method references. */ var funcProto = Function.prototype, objectProto = Object.prototype; /** Used to resolve the decompiled source of functions. */ var funcToString = funcProto.toString; /** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty; /** Used to infer the `Object` constructor. */ var objectCtorString = funcToString.call(Object); /** * Checks if `value` is a plain object, that is, an object created by the * `Object` constructor or one with a `[[Prototype]]` of `null`. * * @static * @memberOf _ * @since 0.8.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is a plain object, else `false`. * @example * * function Foo() { * this.a = 1; * } * * _.isPlainObject(new Foo); * // => false * * _.isPlainObject([1, 2, 3]); * // => false * * _.isPlainObject({ 'x': 0, 'y': 0 }); * // => true * * _.isPlainObject(Object.create(null)); * // => true */ function isPlainObject(value) { if (!isObjectLike(value) || baseGetTag(value) != objectTag) { return false; } var proto = getPrototype(value); if (proto === null) { return true; } var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor; return typeof Ctor == 'function' && Ctor instanceof Ctor && funcToString.call(Ctor) == objectCtorString; } module.exports = isPlainObject; },{"./_baseGetTag":156,"./_getPrototype":208,"./isObjectLike":284}],286:[function(require,module,exports){ var baseIsSet = require('./_baseIsSet'), baseUnary = require('./_baseUnary'), nodeUtil = require('./_nodeUtil'); /* Node.js helper references. */ var nodeIsSet = nodeUtil && nodeUtil.isSet; /** * Checks if `value` is classified as a `Set` object. * * @static * @memberOf _ * @since 4.3.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is a set, else `false`. * @example * * _.isSet(new Set); * // => true * * _.isSet(new WeakSet); * // => false */ var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet; module.exports = isSet; },{"./_baseIsSet":164,"./_baseUnary":180,"./_nodeUtil":246}],287:[function(require,module,exports){ var baseGetTag = require('./_baseGetTag'), isArray = require('./isArray'), isObjectLike = require('./isObjectLike'); /** `Object#toString` result references. */ var stringTag = '[object String]'; /** * Checks if `value` is classified as a `String` primitive or object. * * @static * @since 0.1.0 * @memberOf _ * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is a string, else `false`. * @example * * _.isString('abc'); * // => true * * _.isString(1); * // => false */ function isString(value) { return typeof value == 'string' || (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag); } module.exports = isString; },{"./_baseGetTag":156,"./isArray":276,"./isObjectLike":284}],288:[function(require,module,exports){ var baseGetTag = require('./_baseGetTag'), isObjectLike = require('./isObjectLike'); /** `Object#toString` result references. */ var symbolTag = '[object Symbol]'; /** * Checks if `value` is classified as a `Symbol` primitive or object. * * @static * @memberOf _ * @since 4.0.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`. * @example * * _.isSymbol(Symbol.iterator); * // => true * * _.isSymbol('abc'); * // => false */ function isSymbol(value) { return typeof value == 'symbol' || (isObjectLike(value) && baseGetTag(value) == symbolTag); } module.exports = isSymbol; },{"./_baseGetTag":156,"./isObjectLike":284}],289:[function(require,module,exports){ var baseIsTypedArray = require('./_baseIsTypedArray'), baseUnary = require('./_baseUnary'), nodeUtil = require('./_nodeUtil'); /* Node.js helper references. */ var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray; /** * Checks if `value` is classified as a typed array. * * @static * @memberOf _ * @since 3.0.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. * @example * * _.isTypedArray(new Uint8Array); * // => true * * _.isTypedArray([]); * // => false */ var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray; module.exports = isTypedArray; },{"./_baseIsTypedArray":165,"./_baseUnary":180,"./_nodeUtil":246}],290:[function(require,module,exports){ /** * Checks if `value` is `undefined`. * * @static * @since 0.1.0 * @memberOf _ * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`. * @example * * _.isUndefined(void 0); * // => true * * _.isUndefined(null); * // => false */ function isUndefined(value) { return value === undefined; } module.exports = isUndefined; },{}],291:[function(require,module,exports){ var arrayLikeKeys = require('./_arrayLikeKeys'), baseKeys = require('./_baseKeys'), isArrayLike = require('./isArrayLike'); /** * Creates an array of the own enumerable property names of `object`. * * **Note:** Non-object values are coerced to objects. See the * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) * for more details. * * @static * @since 0.1.0 * @memberOf _ * @category Object * @param {Object} object The object to query. * @returns {Array} Returns the array of property names. * @example * * function Foo() { * this.a = 1; * this.b = 2; * } * * Foo.prototype.c = 3; * * _.keys(new Foo); * // => ['a', 'b'] (iteration order is not guaranteed) * * _.keys('hi'); * // => ['0', '1'] */ function keys(object) { return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object); } module.exports = keys; },{"./_arrayLikeKeys":139,"./_baseKeys":167,"./isArrayLike":277}],292:[function(require,module,exports){ var arrayLikeKeys = require('./_arrayLikeKeys'), baseKeysIn = require('./_baseKeysIn'), isArrayLike = require('./isArrayLike'); /** * Creates an array of the own and inherited enumerable property names of `object`. * * **Note:** Non-object values are coerced to objects. * * @static * @memberOf _ * @since 3.0.0 * @category Object * @param {Object} object The object to query. * @returns {Array} Returns the array of property names. * @example * * function Foo() { * this.a = 1; * this.b = 2; * } * * Foo.prototype.c = 3; * * _.keysIn(new Foo); * // => ['a', 'b', 'c'] (iteration order is not guaranteed) */ function keysIn(object) { return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object); } module.exports = keysIn; },{"./_arrayLikeKeys":139,"./_baseKeysIn":168,"./isArrayLike":277}],293:[function(require,module,exports){ var arrayMap = require('./_arrayMap'), baseIteratee = require('./_baseIteratee'), baseMap = require('./_baseMap'), isArray = require('./isArray'); /** * Creates an array of values by running each element in `collection` thru * `iteratee`. The iteratee is invoked with three arguments: * (value, index|key, collection). * * Many lodash methods are guarded to work as iteratees for methods like * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`. * * The guarded methods are: * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`, * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`, * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`, * `template`, `trim`, `trimEnd`, `trimStart`, and `words` * * @static * @memberOf _ * @since 0.1.0 * @category Collection * @param {Array|Object} collection The collection to iterate over. * @param {Function} [iteratee=_.identity] The function invoked per iteration. * @returns {Array} Returns the new mapped array. * @example * * function square(n) { * return n * n; * } * * _.map([4, 8], square); * // => [16, 64] * * _.map({ 'a': 4, 'b': 8 }, square); * // => [16, 64] (iteration order is not guaranteed) * * var users = [ * { 'user': 'barney' }, * { 'user': 'fred' } * ]; * * // The `_.property` iteratee shorthand. * _.map(users, 'user'); * // => ['barney', 'fred'] */ function map(collection, iteratee) { var func = isArray(collection) ? arrayMap : baseMap; return func(collection, baseIteratee(iteratee, 3)); } module.exports = map; },{"./_arrayMap":140,"./_baseIteratee":166,"./_baseMap":169,"./isArray":276}],294:[function(require,module,exports){ var MapCache = require('./_MapCache'); /** Error message constants. */ var FUNC_ERROR_TEXT = 'Expected a function'; /** * Creates a function that memoizes the result of `func`. If `resolver` is * provided, it determines the cache key for storing the result based on the * arguments provided to the memoized function. By default, the first argument * provided to the memoized function is used as the map cache key. The `func` * is invoked with the `this` binding of the memoized function. * * **Note:** The cache is exposed as the `cache` property on the memoized * function. Its creation may be customized by replacing the `_.memoize.Cache` * constructor with one whose instances implement the * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object) * method interface of `clear`, `delete`, `get`, `has`, and `set`. * * @static * @memberOf _ * @since 0.1.0 * @category Function * @param {Function} func The function to have its output memoized. * @param {Function} [resolver] The function to resolve the cache key. * @returns {Function} Returns the new memoized function. * @example * * var object = { 'a': 1, 'b': 2 }; * var other = { 'c': 3, 'd': 4 }; * * var values = _.memoize(_.values); * values(object); * // => [1, 2] * * values(other); * // => [3, 4] * * object.a = 2; * values(object); * // => [1, 2] * * // Modify the result cache. * values.cache.set(object, ['a', 'b']); * values(object); * // => ['a', 'b'] * * // Replace `_.memoize.Cache`. * _.memoize.Cache = WeakMap; */ function memoize(func, resolver) { if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) { throw new TypeError(FUNC_ERROR_TEXT); } var memoized = function() { var args = arguments, key = resolver ? resolver.apply(this, args) : args[0], cache = memoized.cache; if (cache.has(key)) { return cache.get(key); } var result = func.apply(this, args); memoized.cache = cache.set(key, result) || cache; return result; }; memoized.cache = new (memoize.Cache || MapCache); return memoized; } // Expose `MapCache`. memoize.Cache = MapCache; module.exports = memoize; },{"./_MapCache":128}],295:[function(require,module,exports){ var baseMerge = require('./_baseMerge'), createAssigner = require('./_createAssigner'); /** * This method is like `_.assign` except that it recursively merges own and * inherited enumerable string keyed properties of source objects into the * destination object. Source properties that resolve to `undefined` are * skipped if a destination value exists. Array and plain object properties * are merged recursively. Other objects and value types are overridden by * assignment. Source objects are applied from left to right. Subsequent * sources overwrite property assignments of previous sources. * * **Note:** This method mutates `object`. * * @static * @memberOf _ * @since 0.5.0 * @category Object * @param {Object} object The destination object. * @param {...Object} [sources] The source objects. * @returns {Object} Returns `object`. * @example * * var object = { * 'a': [{ 'b': 2 }, { 'd': 4 }] * }; * * var other = { * 'a': [{ 'c': 3 }, { 'e': 5 }] * }; * * _.merge(object, other); * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] } */ var merge = createAssigner(function(object, source, srcIndex) { baseMerge(object, source, srcIndex); }); module.exports = merge; },{"./_baseMerge":172,"./_createAssigner":195}],296:[function(require,module,exports){ var root = require('./_root'); /** * Gets the timestamp of the number of milliseconds that have elapsed since * the Unix epoch (1 January 1970 00:00:00 UTC). * * @static * @memberOf _ * @since 2.4.0 * @category Date * @returns {number} Returns the timestamp. * @example * * _.defer(function(stamp) { * console.log(_.now() - stamp); * }, _.now()); * // => Logs the number of milliseconds it took for the deferred invocation. */ var now = function() { return root.Date.now(); }; module.exports = now; },{"./_root":250}],297:[function(require,module,exports){ var baseProperty = require('./_baseProperty'), basePropertyDeep = require('./_basePropertyDeep'), isKey = require('./_isKey'), toKey = require('./_toKey'); /** * Creates a function that returns the value at `path` of a given object. * * @static * @memberOf _ * @since 2.4.0 * @category Util * @param {Array|string} path The path of the property to get. * @returns {Function} Returns the new accessor function. * @example * * var objects = [ * { 'a': { 'b': 2 } }, * { 'a': { 'b': 1 } } * ]; * * _.map(objects, _.property('a.b')); * // => [2, 1] * * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b'); * // => [1, 2] */ function property(path) { return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path); } module.exports = property; },{"./_baseProperty":174,"./_basePropertyDeep":175,"./_isKey":225,"./_toKey":263}],298:[function(require,module,exports){ /** * This method returns a new empty array. * * @static * @memberOf _ * @since 4.13.0 * @category Util * @returns {Array} Returns the new empty array. * @example * * var arrays = _.times(2, _.stubArray); * * console.log(arrays); * // => [[], []] * * console.log(arrays[0] === arrays[1]); * // => false */ function stubArray() { return []; } module.exports = stubArray; },{}],299:[function(require,module,exports){ /** * This method returns `false`. * * @static * @memberOf _ * @since 4.13.0 * @category Util * @returns {boolean} Returns `false`. * @example * * _.times(2, _.stubFalse); * // => [false, false] */ function stubFalse() { return false; } module.exports = stubFalse; },{}],300:[function(require,module,exports){ var debounce = require('./debounce'), isObject = require('./isObject'); /** Error message constants. */ var FUNC_ERROR_TEXT = 'Expected a function'; /** * Creates a throttled function that only invokes `func` at most once per * every `wait` milliseconds. The throttled function comes with a `cancel` * method to cancel delayed `func` invocations and a `flush` method to * immediately invoke them. Provide `options` to indicate whether `func` * should be invoked on the leading and/or trailing edge of the `wait` * timeout. The `func` is invoked with the last arguments provided to the * throttled function. Subsequent calls to the throttled function return the * result of the last `func` invocation. * * **Note:** If `leading` and `trailing` options are `true`, `func` is * invoked on the trailing edge of the timeout only if the throttled function * is invoked more than once during the `wait` timeout. * * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred * until to the next tick, similar to `setTimeout` with a timeout of `0`. * * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/) * for details over the differences between `_.throttle` and `_.debounce`. * * @static * @memberOf _ * @since 0.1.0 * @category Function * @param {Function} func The function to throttle. * @param {number} [wait=0] The number of milliseconds to throttle invocations to. * @param {Object} [options={}] The options object. * @param {boolean} [options.leading=true] * Specify invoking on the leading edge of the timeout. * @param {boolean} [options.trailing=true] * Specify invoking on the trailing edge of the timeout. * @returns {Function} Returns the new throttled function. * @example * * // Avoid excessively updating the position while scrolling. * jQuery(window).on('scroll', _.throttle(updatePosition, 100)); * * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes. * var throttled = _.throttle(renewToken, 300000, { 'trailing': false }); * jQuery(element).on('click', throttled); * * // Cancel the trailing throttled invocation. * jQuery(window).on('popstate', throttled.cancel); */ function throttle(func, wait, options) { var leading = true, trailing = true; if (typeof func != 'function') { throw new TypeError(FUNC_ERROR_TEXT); } if (isObject(options)) { leading = 'leading' in options ? !!options.leading : leading; trailing = 'trailing' in options ? !!options.trailing : trailing; } return debounce(func, wait, { 'leading': leading, 'maxWait': wait, 'trailing': trailing }); } module.exports = throttle; },{"./debounce":267,"./isObject":283}],301:[function(require,module,exports){ var isObject = require('./isObject'), isSymbol = require('./isSymbol'); /** Used as references for various `Number` constants. */ var NAN = 0 / 0; /** Used to match leading and trailing whitespace. */ var reTrim = /^\s+|\s+$/g; /** Used to detect bad signed hexadecimal string values. */ var reIsBadHex = /^[-+]0x[0-9a-f]+$/i; /** Used to detect binary string values. */ var reIsBinary = /^0b[01]+$/i; /** Used to detect octal string values. */ var reIsOctal = /^0o[0-7]+$/i; /** Built-in method references without a dependency on `root`. */ var freeParseInt = parseInt; /** * Converts `value` to a number. * * @static * @memberOf _ * @since 4.0.0 * @category Lang * @param {*} value The value to process. * @returns {number} Returns the number. * @example * * _.toNumber(3.2); * // => 3.2 * * _.toNumber(Number.MIN_VALUE); * // => 5e-324 * * _.toNumber(Infinity); * // => Infinity * * _.toNumber('3.2'); * // => 3.2 */ function toNumber(value) { if (typeof value == 'number') { return value; } if (isSymbol(value)) { return NAN; } if (isObject(value)) { var other = typeof value.valueOf == 'function' ? value.valueOf() : value; value = isObject(other) ? (other + '') : other; } if (typeof value != 'string') { return value === 0 ? value : +value; } value = value.replace(reTrim, ''); var isBinary = reIsBinary.test(value); return (isBinary || reIsOctal.test(value)) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : (reIsBadHex.test(value) ? NAN : +value); } module.exports = toNumber; },{"./isObject":283,"./isSymbol":288}],302:[function(require,module,exports){ var copyObject = require('./_copyObject'), keysIn = require('./keysIn'); /** * Converts `value` to a plain object flattening inherited enumerable string * keyed properties of `value` to own properties of the plain object. * * @static * @memberOf _ * @since 3.0.0 * @category Lang * @param {*} value The value to convert. * @returns {Object} Returns the converted plain object. * @example * * function Foo() { * this.b = 2; * } * * Foo.prototype.c = 3; * * _.assign({ 'a': 1 }, new Foo); * // => { 'a': 1, 'b': 2 } * * _.assign({ 'a': 1 }, _.toPlainObject(new Foo)); * // => { 'a': 1, 'b': 2, 'c': 3 } */ function toPlainObject(value) { return copyObject(value, keysIn(value)); } module.exports = toPlainObject; },{"./_copyObject":191,"./keysIn":292}],303:[function(require,module,exports){ var baseToString = require('./_baseToString'); /** * Converts `value` to a string. An empty string is returned for `null` * and `undefined` values. The sign of `-0` is preserved. * * @static * @memberOf _ * @since 4.0.0 * @category Lang * @param {*} value The value to convert. * @returns {string} Returns the converted string. * @example * * _.toString(null); * // => '' * * _.toString(-0); * // => '-0' * * _.toString([1, 2, 3]); * // => '1,2,3' */ function toString(value) { return value == null ? '' : baseToString(value); } module.exports = toString; },{"./_baseToString":179}],304:[function(require,module,exports){ (function(root, factory) { if (typeof define === 'function' && define.amd) { define([], factory); } else if (typeof exports === 'object') { module.exports = factory(); } else { root.materialColors = factory(); } })(this, function() { return {"red":{"50":"#ffebee","100":"#ffcdd2","200":"#ef9a9a","300":"#e57373","400":"#ef5350","500":"#f44336","600":"#e53935","700":"#d32f2f","800":"#c62828","900":"#b71c1c","a100":"#ff8a80","a200":"#ff5252","a400":"#ff1744","a700":"#d50000"},"pink":{"50":"#fce4ec","100":"#f8bbd0","200":"#f48fb1","300":"#f06292","400":"#ec407a","500":"#e91e63","600":"#d81b60","700":"#c2185b","800":"#ad1457","900":"#880e4f","a100":"#ff80ab","a200":"#ff4081","a400":"#f50057","a700":"#c51162"},"purple":{"50":"#f3e5f5","100":"#e1bee7","200":"#ce93d8","300":"#ba68c8","400":"#ab47bc","500":"#9c27b0","600":"#8e24aa","700":"#7b1fa2","800":"#6a1b9a","900":"#4a148c","a100":"#ea80fc","a200":"#e040fb","a400":"#d500f9","a700":"#aa00ff"},"deepPurple":{"50":"#ede7f6","100":"#d1c4e9","200":"#b39ddb","300":"#9575cd","400":"#7e57c2","500":"#673ab7","600":"#5e35b1","700":"#512da8","800":"#4527a0","900":"#311b92","a100":"#b388ff","a200":"#7c4dff","a400":"#651fff","a700":"#6200ea"},"indigo":{"50":"#e8eaf6","100":"#c5cae9","200":"#9fa8da","300":"#7986cb","400":"#5c6bc0","500":"#3f51b5","600":"#3949ab","700":"#303f9f","800":"#283593","900":"#1a237e","a100":"#8c9eff","a200":"#536dfe","a400":"#3d5afe","a700":"#304ffe"},"blue":{"50":"#e3f2fd","100":"#bbdefb","200":"#90caf9","300":"#64b5f6","400":"#42a5f5","500":"#2196f3","600":"#1e88e5","700":"#1976d2","800":"#1565c0","900":"#0d47a1","a100":"#82b1ff","a200":"#448aff","a400":"#2979ff","a700":"#2962ff"},"lightBlue":{"50":"#e1f5fe","100":"#b3e5fc","200":"#81d4fa","300":"#4fc3f7","400":"#29b6f6","500":"#03a9f4","600":"#039be5","700":"#0288d1","800":"#0277bd","900":"#01579b","a100":"#80d8ff","a200":"#40c4ff","a400":"#00b0ff","a700":"#0091ea"},"cyan":{"50":"#e0f7fa","100":"#b2ebf2","200":"#80deea","300":"#4dd0e1","400":"#26c6da","500":"#00bcd4","600":"#00acc1","700":"#0097a7","800":"#00838f","900":"#006064","a100":"#84ffff","a200":"#18ffff","a400":"#00e5ff","a700":"#00b8d4"},"teal":{"50":"#e0f2f1","100":"#b2dfdb","200":"#80cbc4","300":"#4db6ac","400":"#26a69a","500":"#009688","600":"#00897b","700":"#00796b","800":"#00695c","900":"#004d40","a100":"#a7ffeb","a200":"#64ffda","a400":"#1de9b6","a700":"#00bfa5"},"green":{"50":"#e8f5e9","100":"#c8e6c9","200":"#a5d6a7","300":"#81c784","400":"#66bb6a","500":"#4caf50","600":"#43a047","700":"#388e3c","800":"#2e7d32","900":"#1b5e20","a100":"#b9f6ca","a200":"#69f0ae","a400":"#00e676","a700":"#00c853"},"lightGreen":{"50":"#f1f8e9","100":"#dcedc8","200":"#c5e1a5","300":"#aed581","400":"#9ccc65","500":"#8bc34a","600":"#7cb342","700":"#689f38","800":"#558b2f","900":"#33691e","a100":"#ccff90","a200":"#b2ff59","a400":"#76ff03","a700":"#64dd17"},"lime":{"50":"#f9fbe7","100":"#f0f4c3","200":"#e6ee9c","300":"#dce775","400":"#d4e157","500":"#cddc39","600":"#c0ca33","700":"#afb42b","800":"#9e9d24","900":"#827717","a100":"#f4ff81","a200":"#eeff41","a400":"#c6ff00","a700":"#aeea00"},"yellow":{"50":"#fffde7","100":"#fff9c4","200":"#fff59d","300":"#fff176","400":"#ffee58","500":"#ffeb3b","600":"#fdd835","700":"#fbc02d","800":"#f9a825","900":"#f57f17","a100":"#ffff8d","a200":"#ffff00","a400":"#ffea00","a700":"#ffd600"},"amber":{"50":"#fff8e1","100":"#ffecb3","200":"#ffe082","300":"#ffd54f","400":"#ffca28","500":"#ffc107","600":"#ffb300","700":"#ffa000","800":"#ff8f00","900":"#ff6f00","a100":"#ffe57f","a200":"#ffd740","a400":"#ffc400","a700":"#ffab00"},"orange":{"50":"#fff3e0","100":"#ffe0b2","200":"#ffcc80","300":"#ffb74d","400":"#ffa726","500":"#ff9800","600":"#fb8c00","700":"#f57c00","800":"#ef6c00","900":"#e65100","a100":"#ffd180","a200":"#ffab40","a400":"#ff9100","a700":"#ff6d00"},"deepOrange":{"50":"#fbe9e7","100":"#ffccbc","200":"#ffab91","300":"#ff8a65","400":"#ff7043","500":"#ff5722","600":"#f4511e","700":"#e64a19","800":"#d84315","900":"#bf360c","a100":"#ff9e80","a200":"#ff6e40","a400":"#ff3d00","a700":"#dd2c00"},"brown":{"50":"#efebe9","100":"#d7ccc8","200":"#bcaaa4","300":"#a1887f","400":"#8d6e63","500":"#795548","600":"#6d4c41","700":"#5d4037","800":"#4e342e","900":"#3e2723"},"grey":{"50":"#fafafa","100":"#f5f5f5","200":"#eeeeee","300":"#e0e0e0","400":"#bdbdbd","500":"#9e9e9e","600":"#757575","700":"#616161","800":"#424242","900":"#212121"},"blueGrey":{"50":"#eceff1","100":"#cfd8dc","200":"#b0bec5","300":"#90a4ae","400":"#78909c","500":"#607d8b","600":"#546e7a","700":"#455a64","800":"#37474f","900":"#263238"},"darkText":{"primary":"rgba(0, 0, 0, 0.87)","secondary":"rgba(0, 0, 0, 0.54)","disabled":"rgba(0, 0, 0, 0.38)","dividers":"rgba(0, 0, 0, 0.12)"},"lightText":{"primary":"rgba(255, 255, 255, 1)","secondary":"rgba(255, 255, 255, 0.7)","disabled":"rgba(255, 255, 255, 0.5)","dividers":"rgba(255, 255, 255, 0.12)"},"darkIcons":{"active":"rgba(0, 0, 0, 0.54)","inactive":"rgba(0, 0, 0, 0.38)"},"lightIcons":{"active":"rgba(255, 255, 255, 1)","inactive":"rgba(255, 255, 255, 0.5)"},"white":"#ffffff","black":"#000000"}; }); },{}],305:[function(require,module,exports){ /* object-assign (c) Sindre Sorhus @license MIT */ 'use strict'; /* eslint-disable no-unused-vars */ var getOwnPropertySymbols = Object.getOwnPropertySymbols; var hasOwnProperty = Object.prototype.hasOwnProperty; var propIsEnumerable = Object.prototype.propertyIsEnumerable; function toObject(val) { if (val === null || val === undefined) { throw new TypeError('Object.assign cannot be called with null or undefined'); } return Object(val); } function shouldUseNative() { try { if (!Object.assign) { return false; } // Detect buggy property enumeration order in older V8 versions. // https://bugs.chromium.org/p/v8/issues/detail?id=4118 var test1 = new String('abc'); // eslint-disable-line no-new-wrappers test1[5] = 'de'; if (Object.getOwnPropertyNames(test1)[0] === '5') { return false; } // https://bugs.chromium.org/p/v8/issues/detail?id=3056 var test2 = {}; for (var i = 0; i < 10; i++) { test2['_' + String.fromCharCode(i)] = i; } var order2 = Object.getOwnPropertyNames(test2).map(function (n) { return test2[n]; }); if (order2.join('') !== '0123456789') { return false; } // https://bugs.chromium.org/p/v8/issues/detail?id=3056 var test3 = {}; 'abcdefghijklmnopqrst'.split('').forEach(function (letter) { test3[letter] = letter; }); if (Object.keys(Object.assign({}, test3)).join('') !== 'abcdefghijklmnopqrst') { return false; } return true; } catch (err) { // We don't expect any of the above to throw, but better to be safe. return false; } } module.exports = shouldUseNative() ? Object.assign : function (target, source) { var from; var to = toObject(target); var symbols; for (var s = 1; s < arguments.length; s++) { from = Object(arguments[s]); for (var key in from) { if (hasOwnProperty.call(from, key)) { to[key] = from[key]; } } if (getOwnPropertySymbols) { symbols = getOwnPropertySymbols(from); for (var i = 0; i < symbols.length; i++) { if (propIsEnumerable.call(from, symbols[i])) { to[symbols[i]] = from[symbols[i]]; } } } } return to; }; },{}],306:[function(require,module,exports){ (function (process){ /** * Copyright (c) 2013-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ 'use strict'; var printWarning = function() {}; if (process.env.NODE_ENV !== 'production') { var ReactPropTypesSecret = require('./lib/ReactPropTypesSecret'); var loggedTypeFailures = {}; var has = Function.call.bind(Object.prototype.hasOwnProperty); printWarning = function(text) { var message = 'Warning: ' + text; if (typeof console !== 'undefined') { console.error(message); } try { // --- Welcome to debugging React --- // This error was thrown as a convenience so that you can use this stack // to find the callsite that caused this warning to fire. throw new Error(message); } catch (x) {} }; } /** * Assert that the values match with the type specs. * Error messages are memorized and will only be shown once. * * @param {object} typeSpecs Map of name to a ReactPropType * @param {object} values Runtime values that need to be type-checked * @param {string} location e.g. "prop", "context", "child context" * @param {string} componentName Name of the component for error messages. * @param {?Function} getStack Returns the component stack. * @private */ function checkPropTypes(typeSpecs, values, location, componentName, getStack) { if (process.env.NODE_ENV !== 'production') { for (var typeSpecName in typeSpecs) { if (has(typeSpecs, typeSpecName)) { var error; // Prop type validation may throw. In case they do, we don't want to // fail the render phase where it didn't fail before. So we log it. // After these have been cleaned up, we'll let them throw. try { // This is intentionally an invariant that gets caught. It's the same // behavior as without this statement except with a better message. if (typeof typeSpecs[typeSpecName] !== 'function') { var err = Error( (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' ); err.name = 'Invariant Violation'; throw err; } error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret); } catch (ex) { error = ex; } if (error && !(error instanceof Error)) { printWarning( (componentName || 'React class') + ': type specification of ' + location + ' `' + typeSpecName + '` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).' ); } if (error instanceof Error && !(error.message in loggedTypeFailures)) { // Only monitor this failure once because there tends to be a lot of the // same error. loggedTypeFailures[error.message] = true; var stack = getStack ? getStack() : ''; printWarning( 'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '') ); } } } } } /** * Resets warning cache when testing. * * @private */ checkPropTypes.resetWarningCache = function() { if (process.env.NODE_ENV !== 'production') { loggedTypeFailures = {}; } } module.exports = checkPropTypes; }).call(this,require('_process')) },{"./lib/ReactPropTypesSecret":310,"_process":6}],307:[function(require,module,exports){ /** * Copyright (c) 2013-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ 'use strict'; var ReactPropTypesSecret = require('./lib/ReactPropTypesSecret'); function emptyFunction() {} function emptyFunctionWithReset() {} emptyFunctionWithReset.resetWarningCache = emptyFunction; module.exports = function() { function shim(props, propName, componentName, location, propFullName, secret) { if (secret === ReactPropTypesSecret) { // It is still safe when called from React. return; } var err = new Error( 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' + 'Use PropTypes.checkPropTypes() to call them. ' + 'Read more at http://fb.me/use-check-prop-types' ); err.name = 'Invariant Violation'; throw err; }; shim.isRequired = shim; function getShim() { return shim; }; // Important! // Keep this list in sync with production version in `./factoryWithTypeCheckers.js`. var ReactPropTypes = { array: shim, bool: shim, func: shim, number: shim, object: shim, string: shim, symbol: shim, any: shim, arrayOf: getShim, element: shim, elementType: shim, instanceOf: getShim, node: shim, objectOf: getShim, oneOf: getShim, oneOfType: getShim, shape: getShim, exact: getShim, checkPropTypes: emptyFunctionWithReset, resetWarningCache: emptyFunction }; ReactPropTypes.PropTypes = ReactPropTypes; return ReactPropTypes; }; },{"./lib/ReactPropTypesSecret":310}],308:[function(require,module,exports){ (function (process){ /** * Copyright (c) 2013-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ 'use strict'; var ReactIs = require('react-is'); var assign = require('object-assign'); var ReactPropTypesSecret = require('./lib/ReactPropTypesSecret'); var checkPropTypes = require('./checkPropTypes'); var has = Function.call.bind(Object.prototype.hasOwnProperty); var printWarning = function() {}; if (process.env.NODE_ENV !== 'production') { printWarning = function(text) { var message = 'Warning: ' + text; if (typeof console !== 'undefined') { console.error(message); } try { // --- Welcome to debugging React --- // This error was thrown as a convenience so that you can use this stack // to find the callsite that caused this warning to fire. throw new Error(message); } catch (x) {} }; } function emptyFunctionThatReturnsNull() { return null; } module.exports = function(isValidElement, throwOnDirectAccess) { /* global Symbol */ var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator; var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec. /** * Returns the iterator method function contained on the iterable object. * * Be sure to invoke the function with the iterable as context: * * var iteratorFn = getIteratorFn(myIterable); * if (iteratorFn) { * var iterator = iteratorFn.call(myIterable); * ... * } * * @param {?object} maybeIterable * @return {?function} */ function getIteratorFn(maybeIterable) { var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]); if (typeof iteratorFn === 'function') { return iteratorFn; } } /** * Collection of methods that allow declaration and validation of props that are * supplied to React components. Example usage: * * var Props = require('ReactPropTypes'); * var MyArticle = React.createClass({ * propTypes: { * // An optional string prop named "description". * description: Props.string, * * // A required enum prop named "category". * category: Props.oneOf(['News','Photos']).isRequired, * * // A prop named "dialog" that requires an instance of Dialog. * dialog: Props.instanceOf(Dialog).isRequired * }, * render: function() { ... } * }); * * A more formal specification of how these methods are used: * * type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...) * decl := ReactPropTypes.{type}(.isRequired)? * * Each and every declaration produces a function with the same signature. This * allows the creation of custom validation functions. For example: * * var MyLink = React.createClass({ * propTypes: { * // An optional string or URI prop named "href". * href: function(props, propName, componentName) { * var propValue = props[propName]; * if (propValue != null && typeof propValue !== 'string' && * !(propValue instanceof URI)) { * return new Error( * 'Expected a string or an URI for ' + propName + ' in ' + * componentName * ); * } * } * }, * render: function() {...} * }); * * @internal */ var ANONYMOUS = '<>'; // Important! // Keep this list in sync with production version in `./factoryWithThrowingShims.js`. var ReactPropTypes = { array: createPrimitiveTypeChecker('array'), bool: createPrimitiveTypeChecker('boolean'), func: createPrimitiveTypeChecker('function'), number: createPrimitiveTypeChecker('number'), object: createPrimitiveTypeChecker('object'), string: createPrimitiveTypeChecker('string'), symbol: createPrimitiveTypeChecker('symbol'), any: createAnyTypeChecker(), arrayOf: createArrayOfTypeChecker, element: createElementTypeChecker(), elementType: createElementTypeTypeChecker(), instanceOf: createInstanceTypeChecker, node: createNodeChecker(), objectOf: createObjectOfTypeChecker, oneOf: createEnumTypeChecker, oneOfType: createUnionTypeChecker, shape: createShapeTypeChecker, exact: createStrictShapeTypeChecker, }; /** * inlined Object.is polyfill to avoid requiring consumers ship their own * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is */ /*eslint-disable no-self-compare*/ function is(x, y) { // SameValue algorithm if (x === y) { // Steps 1-5, 7-10 // Steps 6.b-6.e: +0 != -0 return x !== 0 || 1 / x === 1 / y; } else { // Step 6.a: NaN == NaN return x !== x && y !== y; } } /*eslint-enable no-self-compare*/ /** * We use an Error-like object for backward compatibility as people may call * PropTypes directly and inspect their output. However, we don't use real * Errors anymore. We don't inspect their stack anyway, and creating them * is prohibitively expensive if they are created too often, such as what * happens in oneOfType() for any type before the one that matched. */ function PropTypeError(message) { this.message = message; this.stack = ''; } // Make `instanceof Error` still work for returned errors. PropTypeError.prototype = Error.prototype; function createChainableTypeChecker(validate) { if (process.env.NODE_ENV !== 'production') { var manualPropTypeCallCache = {}; var manualPropTypeWarningCount = 0; } function checkType(isRequired, props, propName, componentName, location, propFullName, secret) { componentName = componentName || ANONYMOUS; propFullName = propFullName || propName; if (secret !== ReactPropTypesSecret) { if (throwOnDirectAccess) { // New behavior only for users of `prop-types` package var err = new Error( 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' + 'Use `PropTypes.checkPropTypes()` to call them. ' + 'Read more at http://fb.me/use-check-prop-types' ); err.name = 'Invariant Violation'; throw err; } else if (process.env.NODE_ENV !== 'production' && typeof console !== 'undefined') { // Old behavior for people using React.PropTypes var cacheKey = componentName + ':' + propName; if ( !manualPropTypeCallCache[cacheKey] && // Avoid spamming the console because they are often not actionable except for lib authors manualPropTypeWarningCount < 3 ) { printWarning( 'You are manually calling a React.PropTypes validation ' + 'function for the `' + propFullName + '` prop on `' + componentName + '`. This is deprecated ' + 'and will throw in the standalone `prop-types` package. ' + 'You may be seeing this warning due to a third-party PropTypes ' + 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.' ); manualPropTypeCallCache[cacheKey] = true; manualPropTypeWarningCount++; } } } if (props[propName] == null) { if (isRequired) { if (props[propName] === null) { return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.')); } return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.')); } return null; } else { return validate(props, propName, componentName, location, propFullName); } } var chainedCheckType = checkType.bind(null, false); chainedCheckType.isRequired = checkType.bind(null, true); return chainedCheckType; } function createPrimitiveTypeChecker(expectedType) { function validate(props, propName, componentName, location, propFullName, secret) { var propValue = props[propName]; var propType = getPropType(propValue); if (propType !== expectedType) { // `propValue` being instance of, say, date/regexp, pass the 'object' // check, but we can offer a more precise error message here rather than // 'of type `object`'. var preciseType = getPreciseType(propValue); return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.')); } return null; } return createChainableTypeChecker(validate); } function createAnyTypeChecker() { return createChainableTypeChecker(emptyFunctionThatReturnsNull); } function createArrayOfTypeChecker(typeChecker) { function validate(props, propName, componentName, location, propFullName) { if (typeof typeChecker !== 'function') { return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.'); } var propValue = props[propName]; if (!Array.isArray(propValue)) { var propType = getPropType(propValue); return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.')); } for (var i = 0; i < propValue.length; i++) { var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret); if (error instanceof Error) { return error; } } return null; } return createChainableTypeChecker(validate); } function createElementTypeChecker() { function validate(props, propName, componentName, location, propFullName) { var propValue = props[propName]; if (!isValidElement(propValue)) { var propType = getPropType(propValue); return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.')); } return null; } return createChainableTypeChecker(validate); } function createElementTypeTypeChecker() { function validate(props, propName, componentName, location, propFullName) { var propValue = props[propName]; if (!ReactIs.isValidElementType(propValue)) { var propType = getPropType(propValue); return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement type.')); } return null; } return createChainableTypeChecker(validate); } function createInstanceTypeChecker(expectedClass) { function validate(props, propName, componentName, location, propFullName) { if (!(props[propName] instanceof expectedClass)) { var expectedClassName = expectedClass.name || ANONYMOUS; var actualClassName = getClassName(props[propName]); return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.')); } return null; } return createChainableTypeChecker(validate); } function createEnumTypeChecker(expectedValues) { if (!Array.isArray(expectedValues)) { if (process.env.NODE_ENV !== 'production') { if (arguments.length > 1) { printWarning( 'Invalid arguments supplied to oneOf, expected an array, got ' + arguments.length + ' arguments. ' + 'A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).' ); } else { printWarning('Invalid argument supplied to oneOf, expected an array.'); } } return emptyFunctionThatReturnsNull; } function validate(props, propName, componentName, location, propFullName) { var propValue = props[propName]; for (var i = 0; i < expectedValues.length; i++) { if (is(propValue, expectedValues[i])) { return null; } } var valuesString = JSON.stringify(expectedValues, function replacer(key, value) { var type = getPreciseType(value); if (type === 'symbol') { return String(value); } return value; }); return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + String(propValue) + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.')); } return createChainableTypeChecker(validate); } function createObjectOfTypeChecker(typeChecker) { function validate(props, propName, componentName, location, propFullName) { if (typeof typeChecker !== 'function') { return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.'); } var propValue = props[propName]; var propType = getPropType(propValue); if (propType !== 'object') { return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.')); } for (var key in propValue) { if (has(propValue, key)) { var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret); if (error instanceof Error) { return error; } } } return null; } return createChainableTypeChecker(validate); } function createUnionTypeChecker(arrayOfTypeCheckers) { if (!Array.isArray(arrayOfTypeCheckers)) { process.env.NODE_ENV !== 'production' ? printWarning('Invalid argument supplied to oneOfType, expected an instance of array.') : void 0; return emptyFunctionThatReturnsNull; } for (var i = 0; i < arrayOfTypeCheckers.length; i++) { var checker = arrayOfTypeCheckers[i]; if (typeof checker !== 'function') { printWarning( 'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' + 'received ' + getPostfixForTypeWarning(checker) + ' at index ' + i + '.' ); return emptyFunctionThatReturnsNull; } } function validate(props, propName, componentName, location, propFullName) { for (var i = 0; i < arrayOfTypeCheckers.length; i++) { var checker = arrayOfTypeCheckers[i]; if (checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret) == null) { return null; } } return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.')); } return createChainableTypeChecker(validate); } function createNodeChecker() { function validate(props, propName, componentName, location, propFullName) { if (!isNode(props[propName])) { return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.')); } return null; } return createChainableTypeChecker(validate); } function createShapeTypeChecker(shapeTypes) { function validate(props, propName, componentName, location, propFullName) { var propValue = props[propName]; var propType = getPropType(propValue); if (propType !== 'object') { return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.')); } for (var key in shapeTypes) { var checker = shapeTypes[key]; if (!checker) { continue; } var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret); if (error) { return error; } } return null; } return createChainableTypeChecker(validate); } function createStrictShapeTypeChecker(shapeTypes) { function validate(props, propName, componentName, location, propFullName) { var propValue = props[propName]; var propType = getPropType(propValue); if (propType !== 'object') { return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.')); } // We need to check all keys in case some are required but missing from // props. var allKeys = assign({}, props[propName], shapeTypes); for (var key in allKeys) { var checker = shapeTypes[key]; if (!checker) { return new PropTypeError( 'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' + '\nBad object: ' + JSON.stringify(props[propName], null, ' ') + '\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ') ); } var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret); if (error) { return error; } } return null; } return createChainableTypeChecker(validate); } function isNode(propValue) { switch (typeof propValue) { case 'number': case 'string': case 'undefined': return true; case 'boolean': return !propValue; case 'object': if (Array.isArray(propValue)) { return propValue.every(isNode); } if (propValue === null || isValidElement(propValue)) { return true; } var iteratorFn = getIteratorFn(propValue); if (iteratorFn) { var iterator = iteratorFn.call(propValue); var step; if (iteratorFn !== propValue.entries) { while (!(step = iterator.next()).done) { if (!isNode(step.value)) { return false; } } } else { // Iterator will provide entry [k,v] tuples rather than values. while (!(step = iterator.next()).done) { var entry = step.value; if (entry) { if (!isNode(entry[1])) { return false; } } } } } else { return false; } return true; default: return false; } } function isSymbol(propType, propValue) { // Native Symbol. if (propType === 'symbol') { return true; } // falsy value can't be a Symbol if (!propValue) { return false; } // 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol' if (propValue['@@toStringTag'] === 'Symbol') { return true; } // Fallback for non-spec compliant Symbols which are polyfilled. if (typeof Symbol === 'function' && propValue instanceof Symbol) { return true; } return false; } // Equivalent of `typeof` but with special handling for array and regexp. function getPropType(propValue) { var propType = typeof propValue; if (Array.isArray(propValue)) { return 'array'; } if (propValue instanceof RegExp) { // Old webkits (at least until Android 4.0) return 'function' rather than // 'object' for typeof a RegExp. We'll normalize this here so that /bla/ // passes PropTypes.object. return 'object'; } if (isSymbol(propType, propValue)) { return 'symbol'; } return propType; } // This handles more types than `getPropType`. Only used for error messages. // See `createPrimitiveTypeChecker`. function getPreciseType(propValue) { if (typeof propValue === 'undefined' || propValue === null) { return '' + propValue; } var propType = getPropType(propValue); if (propType === 'object') { if (propValue instanceof Date) { return 'date'; } else if (propValue instanceof RegExp) { return 'regexp'; } } return propType; } // Returns a string that is postfixed to a warning about an invalid type. // For example, "undefined" or "of type array" function getPostfixForTypeWarning(value) { var type = getPreciseType(value); switch (type) { case 'array': case 'object': return 'an ' + type; case 'boolean': case 'date': case 'regexp': return 'a ' + type; default: return type; } } // Returns class name of the object, if any. function getClassName(propValue) { if (!propValue.constructor || !propValue.constructor.name) { return ANONYMOUS; } return propValue.constructor.name; } ReactPropTypes.checkPropTypes = checkPropTypes; ReactPropTypes.resetWarningCache = checkPropTypes.resetWarningCache; ReactPropTypes.PropTypes = ReactPropTypes; return ReactPropTypes; }; }).call(this,require('_process')) },{"./checkPropTypes":306,"./lib/ReactPropTypesSecret":310,"_process":6,"object-assign":305,"react-is":368}],309:[function(require,module,exports){ (function (process){ /** * Copyright (c) 2013-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ if (process.env.NODE_ENV !== 'production') { var ReactIs = require('react-is'); // By explicitly using `prop-types` you are opting into new development behavior. // http://fb.me/prop-types-in-prod var throwOnDirectAccess = true; module.exports = require('./factoryWithTypeCheckers')(ReactIs.isElement, throwOnDirectAccess); } else { // By explicitly using `prop-types` you are opting into new production behavior. // http://fb.me/prop-types-in-prod module.exports = require('./factoryWithThrowingShims')(); } }).call(this,require('_process')) },{"./factoryWithThrowingShims":307,"./factoryWithTypeCheckers":308,"_process":6,"react-is":368}],310:[function(require,module,exports){ /** * Copyright (c) 2013-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ 'use strict'; var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED'; module.exports = ReactPropTypesSecret; },{}],311:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.AlphaPicker = undefined; var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _reactcss = require('reactcss'); var _reactcss2 = _interopRequireDefault(_reactcss); var _common = require('../common'); var _AlphaPointer = require('./AlphaPointer'); var _AlphaPointer2 = _interopRequireDefault(_AlphaPointer); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var AlphaPicker = exports.AlphaPicker = function AlphaPicker(_ref) { var rgb = _ref.rgb, hsl = _ref.hsl, width = _ref.width, height = _ref.height, onChange = _ref.onChange, direction = _ref.direction, style = _ref.style, renderers = _ref.renderers, pointer = _ref.pointer, _ref$className = _ref.className, className = _ref$className === undefined ? '' : _ref$className; var styles = (0, _reactcss2.default)({ 'default': { picker: { position: 'relative', width: width, height: height }, alpha: { radius: '2px', style: style } } }); return _react2.default.createElement( 'div', { style: styles.picker, className: 'alpha-picker ' + className }, _react2.default.createElement(_common.Alpha, _extends({}, styles.alpha, { rgb: rgb, hsl: hsl, pointer: pointer, renderers: renderers, onChange: onChange, direction: direction })) ); }; AlphaPicker.defaultProps = { width: '316px', height: '16px', direction: 'horizontal', pointer: _AlphaPointer2.default }; exports.default = (0, _common.ColorWrap)(AlphaPicker); },{"../common":329,"./AlphaPointer":312,"react":"react","reactcss":374}],312:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.AlphaPointer = undefined; var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _reactcss = require('reactcss'); var _reactcss2 = _interopRequireDefault(_reactcss); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var AlphaPointer = exports.AlphaPointer = function AlphaPointer(_ref) { var direction = _ref.direction; var styles = (0, _reactcss2.default)({ 'default': { picker: { width: '18px', height: '18px', borderRadius: '50%', transform: 'translate(-9px, -1px)', backgroundColor: 'rgb(248, 248, 248)', boxShadow: '0 1px 4px 0 rgba(0, 0, 0, 0.37)' } }, 'vertical': { picker: { transform: 'translate(-3px, -9px)' } } }, { vertical: direction === 'vertical' }); return _react2.default.createElement('div', { style: styles.picker }); }; exports.default = AlphaPointer; },{"react":"react","reactcss":374}],313:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.Block = undefined; var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _propTypes = require('prop-types'); var _propTypes2 = _interopRequireDefault(_propTypes); var _reactcss = require('reactcss'); var _reactcss2 = _interopRequireDefault(_reactcss); var _merge = require('lodash/merge'); var _merge2 = _interopRequireDefault(_merge); var _color = require('../../helpers/color'); var color = _interopRequireWildcard(_color); var _common = require('../common'); var _BlockSwatches = require('./BlockSwatches'); var _BlockSwatches2 = _interopRequireDefault(_BlockSwatches); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var Block = exports.Block = function Block(_ref) { var onChange = _ref.onChange, onSwatchHover = _ref.onSwatchHover, hex = _ref.hex, colors = _ref.colors, width = _ref.width, triangle = _ref.triangle, _ref$styles = _ref.styles, passedStyles = _ref$styles === undefined ? {} : _ref$styles, _ref$className = _ref.className, className = _ref$className === undefined ? '' : _ref$className; var transparent = hex === 'transparent'; var handleChange = function handleChange(hexCode, e) { color.isValidHex(hexCode) && onChange({ hex: hexCode, source: 'hex' }, e); }; var styles = (0, _reactcss2.default)((0, _merge2.default)({ 'default': { card: { width: width, background: '#fff', boxShadow: '0 1px rgba(0,0,0,.1)', borderRadius: '6px', position: 'relative' }, head: { height: '110px', background: hex, borderRadius: '6px 6px 0 0', display: 'flex', alignItems: 'center', justifyContent: 'center', position: 'relative' }, body: { padding: '10px' }, label: { fontSize: '18px', color: color.getContrastingColor(hex), position: 'relative' }, triangle: { width: '0px', height: '0px', borderStyle: 'solid', borderWidth: '0 10px 10px 10px', borderColor: 'transparent transparent ' + hex + ' transparent', position: 'absolute', top: '-10px', left: '50%', marginLeft: '-10px' }, input: { width: '100%', fontSize: '12px', color: '#666', border: '0px', outline: 'none', height: '22px', boxShadow: 'inset 0 0 0 1px #ddd', borderRadius: '4px', padding: '0 7px', boxSizing: 'border-box' } }, 'hide-triangle': { triangle: { display: 'none' } } }, passedStyles), { 'hide-triangle': triangle === 'hide' }); return _react2.default.createElement( 'div', { style: styles.card, className: 'block-picker ' + className }, _react2.default.createElement('div', { style: styles.triangle }), _react2.default.createElement( 'div', { style: styles.head }, transparent && _react2.default.createElement(_common.Checkboard, { borderRadius: '6px 6px 0 0' }), _react2.default.createElement( 'div', { style: styles.label }, hex ) ), _react2.default.createElement( 'div', { style: styles.body }, _react2.default.createElement(_BlockSwatches2.default, { colors: colors, onClick: handleChange, onSwatchHover: onSwatchHover }), _react2.default.createElement(_common.EditableInput, { style: { input: styles.input }, value: hex, onChange: handleChange }) ) ); }; Block.propTypes = { width: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.number]), colors: _propTypes2.default.arrayOf(_propTypes2.default.string), triangle: _propTypes2.default.oneOf(['top', 'hide']), styles: _propTypes2.default.object }; Block.defaultProps = { width: 170, colors: ['#D9E3F0', '#F47373', '#697689', '#37D67A', '#2CCCE4', '#555555', '#dce775', '#ff8a65', '#ba68c8'], triangle: 'top', styles: {} }; exports.default = (0, _common.ColorWrap)(Block); },{"../../helpers/color":361,"../common":329,"./BlockSwatches":314,"lodash/merge":295,"prop-types":309,"react":"react","reactcss":374}],314:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.BlockSwatches = undefined; var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _reactcss = require('reactcss'); var _reactcss2 = _interopRequireDefault(_reactcss); var _map = require('lodash/map'); var _map2 = _interopRequireDefault(_map); var _common = require('../common'); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var BlockSwatches = exports.BlockSwatches = function BlockSwatches(_ref) { var colors = _ref.colors, onClick = _ref.onClick, onSwatchHover = _ref.onSwatchHover; var styles = (0, _reactcss2.default)({ 'default': { swatches: { marginRight: '-10px' }, swatch: { width: '22px', height: '22px', float: 'left', marginRight: '10px', marginBottom: '10px', borderRadius: '4px' }, clear: { clear: 'both' } } }); return _react2.default.createElement( 'div', { style: styles.swatches }, (0, _map2.default)(colors, function (c) { return _react2.default.createElement(_common.Swatch, { key: c, color: c, style: styles.swatch, onClick: onClick, onHover: onSwatchHover, focusStyle: { boxShadow: '0 0 4px ' + c } }); }), _react2.default.createElement('div', { style: styles.clear }) ); }; exports.default = BlockSwatches; },{"../common":329,"lodash/map":293,"react":"react","reactcss":374}],315:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.Chrome = undefined; var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _propTypes = require('prop-types'); var _propTypes2 = _interopRequireDefault(_propTypes); var _reactcss = require('reactcss'); var _reactcss2 = _interopRequireDefault(_reactcss); var _merge = require('lodash/merge'); var _merge2 = _interopRequireDefault(_merge); var _common = require('../common'); var _ChromeFields = require('./ChromeFields'); var _ChromeFields2 = _interopRequireDefault(_ChromeFields); var _ChromePointer = require('./ChromePointer'); var _ChromePointer2 = _interopRequireDefault(_ChromePointer); var _ChromePointerCircle = require('./ChromePointerCircle'); var _ChromePointerCircle2 = _interopRequireDefault(_ChromePointerCircle); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var Chrome = exports.Chrome = function Chrome(_ref) { var width = _ref.width, onChange = _ref.onChange, disableAlpha = _ref.disableAlpha, rgb = _ref.rgb, hsl = _ref.hsl, hsv = _ref.hsv, hex = _ref.hex, renderers = _ref.renderers, _ref$styles = _ref.styles, passedStyles = _ref$styles === undefined ? {} : _ref$styles, _ref$className = _ref.className, className = _ref$className === undefined ? '' : _ref$className, defaultView = _ref.defaultView; var styles = (0, _reactcss2.default)((0, _merge2.default)({ 'default': { picker: { width: width, background: '#fff', borderRadius: '2px', boxShadow: '0 0 2px rgba(0,0,0,.3), 0 4px 8px rgba(0,0,0,.3)', boxSizing: 'initial', fontFamily: 'Menlo' }, saturation: { width: '100%', paddingBottom: '55%', position: 'relative', borderRadius: '2px 2px 0 0', overflow: 'hidden' }, Saturation: { radius: '2px 2px 0 0' }, body: { padding: '16px 16px 12px' }, controls: { display: 'flex' }, color: { width: '32px' }, swatch: { marginTop: '6px', width: '16px', height: '16px', borderRadius: '8px', position: 'relative', overflow: 'hidden' }, active: { absolute: '0px 0px 0px 0px', borderRadius: '8px', boxShadow: 'inset 0 0 0 1px rgba(0,0,0,.1)', background: 'rgba(' + rgb.r + ', ' + rgb.g + ', ' + rgb.b + ', ' + rgb.a + ')', zIndex: '2' }, toggles: { flex: '1' }, hue: { height: '10px', position: 'relative', marginBottom: '8px' }, Hue: { radius: '2px' }, alpha: { height: '10px', position: 'relative' }, Alpha: { radius: '2px' } }, 'disableAlpha': { color: { width: '22px' }, alpha: { display: 'none' }, hue: { marginBottom: '0px' }, swatch: { width: '10px', height: '10px', marginTop: '0px' } } }, passedStyles), { disableAlpha: disableAlpha }); return _react2.default.createElement( 'div', { style: styles.picker, className: 'chrome-picker ' + className }, _react2.default.createElement( 'div', { style: styles.saturation }, _react2.default.createElement(_common.Saturation, { style: styles.Saturation, hsl: hsl, hsv: hsv, pointer: _ChromePointerCircle2.default, onChange: onChange }) ), _react2.default.createElement( 'div', { style: styles.body }, _react2.default.createElement( 'div', { style: styles.controls, className: 'flexbox-fix' }, _react2.default.createElement( 'div', { style: styles.color }, _react2.default.createElement( 'div', { style: styles.swatch }, _react2.default.createElement('div', { style: styles.active }), _react2.default.createElement(_common.Checkboard, { renderers: renderers }) ) ), _react2.default.createElement( 'div', { style: styles.toggles }, _react2.default.createElement( 'div', { style: styles.hue }, _react2.default.createElement(_common.Hue, { style: styles.Hue, hsl: hsl, pointer: _ChromePointer2.default, onChange: onChange }) ), _react2.default.createElement( 'div', { style: styles.alpha }, _react2.default.createElement(_common.Alpha, { style: styles.Alpha, rgb: rgb, hsl: hsl, pointer: _ChromePointer2.default, renderers: renderers, onChange: onChange }) ) ) ), _react2.default.createElement(_ChromeFields2.default, { rgb: rgb, hsl: hsl, hex: hex, view: defaultView, onChange: onChange, disableAlpha: disableAlpha }) ) ); }; Chrome.propTypes = { width: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.number]), disableAlpha: _propTypes2.default.bool, styles: _propTypes2.default.object, defaultView: _propTypes2.default.oneOf(["hex", "rgb", "hsl"]) }; Chrome.defaultProps = { width: 225, disableAlpha: false, styles: {} }; exports.default = (0, _common.ColorWrap)(Chrome); },{"../common":329,"./ChromeFields":316,"./ChromePointer":317,"./ChromePointerCircle":318,"lodash/merge":295,"prop-types":309,"react":"react","reactcss":374}],316:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.ChromeFields = undefined; var _createClass = 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _reactcss = require('reactcss'); var _reactcss2 = _interopRequireDefault(_reactcss); var _color = require('../../helpers/color'); var color = _interopRequireWildcard(_color); var _isUndefined = require('lodash/isUndefined'); var _isUndefined2 = _interopRequireDefault(_isUndefined); var _common = require('../common'); var _UnfoldMoreHorizontalIcon = require('@icons/material/UnfoldMoreHorizontalIcon'); var _UnfoldMoreHorizontalIcon2 = _interopRequireDefault(_UnfoldMoreHorizontalIcon); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /* eslint-disable react/no-did-mount-set-state, no-param-reassign */ var ChromeFields = exports.ChromeFields = function (_React$Component) { _inherits(ChromeFields, _React$Component); function ChromeFields(props) { _classCallCheck(this, ChromeFields); var _this = _possibleConstructorReturn(this, (ChromeFields.__proto__ || Object.getPrototypeOf(ChromeFields)).call(this)); _this.toggleViews = function () { if (_this.state.view === 'hex') { _this.setState({ view: 'rgb' }); } else if (_this.state.view === 'rgb') { _this.setState({ view: 'hsl' }); } else if (_this.state.view === 'hsl') { if (_this.props.hsl.a === 1) { _this.setState({ view: 'hex' }); } else { _this.setState({ view: 'rgb' }); } } }; _this.handleChange = function (data, e) { if (data.hex) { color.isValidHex(data.hex) && _this.props.onChange({ hex: data.hex, source: 'hex' }, e); } else if (data.r || data.g || data.b) { _this.props.onChange({ r: data.r || _this.props.rgb.r, g: data.g || _this.props.rgb.g, b: data.b || _this.props.rgb.b, source: 'rgb' }, e); } else if (data.a) { if (data.a < 0) { data.a = 0; } else if (data.a > 1) { data.a = 1; } _this.props.onChange({ h: _this.props.hsl.h, s: _this.props.hsl.s, l: _this.props.hsl.l, a: Math.round(data.a * 100) / 100, source: 'rgb' }, e); } else if (data.h || data.s || data.l) { // Remove any occurances of '%'. if (typeof data.s === 'string' && data.s.includes('%')) { data.s = data.s.replace('%', ''); } if (typeof data.l === 'string' && data.l.includes('%')) { data.l = data.l.replace('%', ''); } // We store HSL as a unit interval so we need to override the 1 input to 0.01 if (data.s == 1) { data.s = 0.01; } else if (data.l == 1) { data.l = 0.01; } _this.props.onChange({ h: data.h || _this.props.hsl.h, s: Number(!(0, _isUndefined2.default)(data.s) ? data.s : _this.props.hsl.s), l: Number(!(0, _isUndefined2.default)(data.l) ? data.l : _this.props.hsl.l), source: 'hsl' }, e); } }; _this.showHighlight = function (e) { e.currentTarget.style.background = '#eee'; }; _this.hideHighlight = function (e) { e.currentTarget.style.background = 'transparent'; }; if (props.hsl.a !== 1 && props.view === "hex") { _this.state = { view: "rgb" }; } else { _this.state = { view: props.view }; } return _this; } _createClass(ChromeFields, [{ key: 'render', value: function render() { var _this2 = this; var styles = (0, _reactcss2.default)({ 'default': { wrap: { paddingTop: '16px', display: 'flex' }, fields: { flex: '1', display: 'flex', marginLeft: '-6px' }, field: { paddingLeft: '6px', width: '100%' }, alpha: { paddingLeft: '6px', width: '100%' }, toggle: { width: '32px', textAlign: 'right', position: 'relative' }, icon: { marginRight: '-4px', marginTop: '12px', cursor: 'pointer', position: 'relative' }, iconHighlight: { position: 'absolute', width: '24px', height: '28px', background: '#eee', borderRadius: '4px', top: '10px', left: '12px', display: 'none' }, input: { fontSize: '11px', color: '#333', width: '100%', borderRadius: '2px', border: 'none', boxShadow: 'inset 0 0 0 1px #dadada', height: '21px', textAlign: 'center' }, label: { textTransform: 'uppercase', fontSize: '11px', lineHeight: '11px', color: '#969696', textAlign: 'center', display: 'block', marginTop: '12px' }, svg: { fill: '#333', width: '24px', height: '24px', border: '1px transparent solid', borderRadius: '5px' } }, 'disableAlpha': { alpha: { display: 'none' } } }, this.props, this.state); var fields = void 0; if (this.state.view === 'hex') { fields = _react2.default.createElement( 'div', { style: styles.fields, className: 'flexbox-fix' }, _react2.default.createElement( 'div', { style: styles.field }, _react2.default.createElement(_common.EditableInput, { style: { input: styles.input, label: styles.label }, label: 'hex', value: this.props.hex, onChange: this.handleChange }) ) ); } else if (this.state.view === 'rgb') { fields = _react2.default.createElement( 'div', { style: styles.fields, className: 'flexbox-fix' }, _react2.default.createElement( 'div', { style: styles.field }, _react2.default.createElement(_common.EditableInput, { style: { input: styles.input, label: styles.label }, label: 'r', value: this.props.rgb.r, onChange: this.handleChange }) ), _react2.default.createElement( 'div', { style: styles.field }, _react2.default.createElement(_common.EditableInput, { style: { input: styles.input, label: styles.label }, label: 'g', value: this.props.rgb.g, onChange: this.handleChange }) ), _react2.default.createElement( 'div', { style: styles.field }, _react2.default.createElement(_common.EditableInput, { style: { input: styles.input, label: styles.label }, label: 'b', value: this.props.rgb.b, onChange: this.handleChange }) ), _react2.default.createElement( 'div', { style: styles.alpha }, _react2.default.createElement(_common.EditableInput, { style: { input: styles.input, label: styles.label }, label: 'a', value: this.props.rgb.a, arrowOffset: 0.01, onChange: this.handleChange }) ) ); } else if (this.state.view === 'hsl') { fields = _react2.default.createElement( 'div', { style: styles.fields, className: 'flexbox-fix' }, _react2.default.createElement( 'div', { style: styles.field }, _react2.default.createElement(_common.EditableInput, { style: { input: styles.input, label: styles.label }, label: 'h', value: Math.round(this.props.hsl.h), onChange: this.handleChange }) ), _react2.default.createElement( 'div', { style: styles.field }, _react2.default.createElement(_common.EditableInput, { style: { input: styles.input, label: styles.label }, label: 's', value: Math.round(this.props.hsl.s * 100) + '%', onChange: this.handleChange }) ), _react2.default.createElement( 'div', { style: styles.field }, _react2.default.createElement(_common.EditableInput, { style: { input: styles.input, label: styles.label }, label: 'l', value: Math.round(this.props.hsl.l * 100) + '%', onChange: this.handleChange }) ), _react2.default.createElement( 'div', { style: styles.alpha }, _react2.default.createElement(_common.EditableInput, { style: { input: styles.input, label: styles.label }, label: 'a', value: this.props.hsl.a, arrowOffset: 0.01, onChange: this.handleChange }) ) ); } return _react2.default.createElement( 'div', { style: styles.wrap, className: 'flexbox-fix' }, fields, _react2.default.createElement( 'div', { style: styles.toggle }, _react2.default.createElement( 'div', { style: styles.icon, onClick: this.toggleViews, ref: function ref(icon) { return _this2.icon = icon; } }, _react2.default.createElement(_UnfoldMoreHorizontalIcon2.default, { style: styles.svg, onMouseOver: this.showHighlight, onMouseEnter: this.showHighlight, onMouseOut: this.hideHighlight }) ) ) ); } }], [{ key: 'getDerivedStateFromProps', value: function getDerivedStateFromProps(nextProps, state) { if (nextProps.hsl.a !== 1 && state.view === 'hex') { return { view: 'rgb' }; } return null; } }]); return ChromeFields; }(_react2.default.Component); ChromeFields.defaultProps = { view: "hex" }; exports.default = ChromeFields; },{"../../helpers/color":361,"../common":329,"@icons/material/UnfoldMoreHorizontalIcon":97,"lodash/isUndefined":290,"react":"react","reactcss":374}],317:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.ChromePointer = undefined; var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _reactcss = require('reactcss'); var _reactcss2 = _interopRequireDefault(_reactcss); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var ChromePointer = exports.ChromePointer = function ChromePointer() { var styles = (0, _reactcss2.default)({ 'default': { picker: { width: '12px', height: '12px', borderRadius: '6px', transform: 'translate(-6px, -1px)', backgroundColor: 'rgb(248, 248, 248)', boxShadow: '0 1px 4px 0 rgba(0, 0, 0, 0.37)' } } }); return _react2.default.createElement('div', { style: styles.picker }); }; exports.default = ChromePointer; },{"react":"react","reactcss":374}],318:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.ChromePointerCircle = undefined; var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _reactcss = require('reactcss'); var _reactcss2 = _interopRequireDefault(_reactcss); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var ChromePointerCircle = exports.ChromePointerCircle = function ChromePointerCircle() { var styles = (0, _reactcss2.default)({ 'default': { picker: { width: '12px', height: '12px', borderRadius: '6px', boxShadow: 'inset 0 0 0 1px #fff', transform: 'translate(-6px, -6px)' } } }); return _react2.default.createElement('div', { style: styles.picker }); }; exports.default = ChromePointerCircle; },{"react":"react","reactcss":374}],319:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.Circle = undefined; var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _propTypes = require('prop-types'); var _propTypes2 = _interopRequireDefault(_propTypes); var _reactcss = require('reactcss'); var _reactcss2 = _interopRequireDefault(_reactcss); var _map = require('lodash/map'); var _map2 = _interopRequireDefault(_map); var _merge = require('lodash/merge'); var _merge2 = _interopRequireDefault(_merge); var _materialColors = require('material-colors'); var material = _interopRequireWildcard(_materialColors); var _common = require('../common'); var _CircleSwatch = require('./CircleSwatch'); var _CircleSwatch2 = _interopRequireDefault(_CircleSwatch); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var Circle = exports.Circle = function Circle(_ref) { var width = _ref.width, onChange = _ref.onChange, onSwatchHover = _ref.onSwatchHover, colors = _ref.colors, hex = _ref.hex, circleSize = _ref.circleSize, _ref$styles = _ref.styles, passedStyles = _ref$styles === undefined ? {} : _ref$styles, circleSpacing = _ref.circleSpacing, _ref$className = _ref.className, className = _ref$className === undefined ? '' : _ref$className; var styles = (0, _reactcss2.default)((0, _merge2.default)({ 'default': { card: { width: width, display: 'flex', flexWrap: 'wrap', marginRight: -circleSpacing, marginBottom: -circleSpacing } } }, passedStyles)); var handleChange = function handleChange(hexCode, e) { return onChange({ hex: hexCode, source: 'hex' }, e); }; return _react2.default.createElement( 'div', { style: styles.card, className: 'circle-picker ' + className }, (0, _map2.default)(colors, function (c) { return _react2.default.createElement(_CircleSwatch2.default, { key: c, color: c, onClick: handleChange, onSwatchHover: onSwatchHover, active: hex === c.toLowerCase(), circleSize: circleSize, circleSpacing: circleSpacing }); }) ); }; Circle.propTypes = { width: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.number]), circleSize: _propTypes2.default.number, circleSpacing: _propTypes2.default.number, styles: _propTypes2.default.object }; Circle.defaultProps = { width: 252, circleSize: 28, circleSpacing: 14, colors: [material.red['500'], material.pink['500'], material.purple['500'], material.deepPurple['500'], material.indigo['500'], material.blue['500'], material.lightBlue['500'], material.cyan['500'], material.teal['500'], material.green['500'], material.lightGreen['500'], material.lime['500'], material.yellow['500'], material.amber['500'], material.orange['500'], material.deepOrange['500'], material.brown['500'], material.blueGrey['500']], styles: {} }; exports.default = (0, _common.ColorWrap)(Circle); },{"../common":329,"./CircleSwatch":320,"lodash/map":293,"lodash/merge":295,"material-colors":304,"prop-types":309,"react":"react","reactcss":374}],320:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.CircleSwatch = undefined; var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _reactcss = require('reactcss'); var _reactcss2 = _interopRequireDefault(_reactcss); var _common = require('../common'); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var CircleSwatch = exports.CircleSwatch = function CircleSwatch(_ref) { var color = _ref.color, onClick = _ref.onClick, onSwatchHover = _ref.onSwatchHover, hover = _ref.hover, active = _ref.active, circleSize = _ref.circleSize, circleSpacing = _ref.circleSpacing; var styles = (0, _reactcss2.default)({ 'default': { swatch: { width: circleSize, height: circleSize, marginRight: circleSpacing, marginBottom: circleSpacing, transform: 'scale(1)', transition: '100ms transform ease' }, Swatch: { borderRadius: '50%', background: 'transparent', boxShadow: 'inset 0 0 0 ' + (circleSize / 2 + 1) + 'px ' + color, transition: '100ms box-shadow ease' } }, 'hover': { swatch: { transform: 'scale(1.2)' } }, 'active': { Swatch: { boxShadow: 'inset 0 0 0 3px ' + color } } }, { hover: hover, active: active }); return _react2.default.createElement( 'div', { style: styles.swatch }, _react2.default.createElement(_common.Swatch, { style: styles.Swatch, color: color, onClick: onClick, onHover: onSwatchHover, focusStyle: { boxShadow: styles.Swatch.boxShadow + ', 0 0 5px ' + color } }) ); }; CircleSwatch.defaultProps = { circleSize: 28, circleSpacing: 14 }; exports.default = (0, _reactcss.handleHover)(CircleSwatch); },{"../common":329,"react":"react","reactcss":374}],321:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.Alpha = undefined; var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _createClass = 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _reactcss = require('reactcss'); var _reactcss2 = _interopRequireDefault(_reactcss); var _alpha = require('../../helpers/alpha'); var alpha = _interopRequireWildcard(_alpha); var _Checkboard = require('./Checkboard'); var _Checkboard2 = _interopRequireDefault(_Checkboard); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var Alpha = exports.Alpha = function (_ref) { _inherits(Alpha, _ref); function Alpha() { var _ref2; var _temp, _this, _ret; _classCallCheck(this, Alpha); for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref2 = Alpha.__proto__ || Object.getPrototypeOf(Alpha)).call.apply(_ref2, [this].concat(args))), _this), _this.handleChange = function (e) { var change = alpha.calculateChange(e, _this.props.hsl, _this.props.direction, _this.props.a, _this.container); change && typeof _this.props.onChange === 'function' && _this.props.onChange(change, e); }, _this.handleMouseDown = function (e) { _this.handleChange(e); window.addEventListener('mousemove', _this.handleChange); window.addEventListener('mouseup', _this.handleMouseUp); }, _this.handleMouseUp = function () { _this.unbindEventListeners(); }, _this.unbindEventListeners = function () { window.removeEventListener('mousemove', _this.handleChange); window.removeEventListener('mouseup', _this.handleMouseUp); }, _temp), _possibleConstructorReturn(_this, _ret); } _createClass(Alpha, [{ key: 'componentWillUnmount', value: function componentWillUnmount() { this.unbindEventListeners(); } }, { key: 'render', value: function render() { var _this2 = this; var rgb = this.props.rgb; var styles = (0, _reactcss2.default)({ 'default': { alpha: { absolute: '0px 0px 0px 0px', borderRadius: this.props.radius }, checkboard: { absolute: '0px 0px 0px 0px', overflow: 'hidden', borderRadius: this.props.radius }, gradient: { absolute: '0px 0px 0px 0px', background: 'linear-gradient(to right, rgba(' + rgb.r + ',' + rgb.g + ',' + rgb.b + ', 0) 0%,\n rgba(' + rgb.r + ',' + rgb.g + ',' + rgb.b + ', 1) 100%)', boxShadow: this.props.shadow, borderRadius: this.props.radius }, container: { position: 'relative', height: '100%', margin: '0 3px' }, pointer: { position: 'absolute', left: rgb.a * 100 + '%' }, slider: { width: '4px', borderRadius: '1px', height: '8px', boxShadow: '0 0 2px rgba(0, 0, 0, .6)', background: '#fff', marginTop: '1px', transform: 'translateX(-2px)' } }, 'vertical': { gradient: { background: 'linear-gradient(to bottom, rgba(' + rgb.r + ',' + rgb.g + ',' + rgb.b + ', 0) 0%,\n rgba(' + rgb.r + ',' + rgb.g + ',' + rgb.b + ', 1) 100%)' }, pointer: { left: 0, top: rgb.a * 100 + '%' } }, 'overwrite': _extends({}, this.props.style) }, { vertical: this.props.direction === 'vertical', overwrite: true }); return _react2.default.createElement( 'div', { style: styles.alpha }, _react2.default.createElement( 'div', { style: styles.checkboard }, _react2.default.createElement(_Checkboard2.default, { renderers: this.props.renderers }) ), _react2.default.createElement('div', { style: styles.gradient }), _react2.default.createElement( 'div', { style: styles.container, ref: function ref(container) { return _this2.container = container; }, onMouseDown: this.handleMouseDown, onTouchMove: this.handleChange, onTouchStart: this.handleChange }, _react2.default.createElement( 'div', { style: styles.pointer }, this.props.pointer ? _react2.default.createElement(this.props.pointer, this.props) : _react2.default.createElement('div', { style: styles.slider }) ) ) ); } }]); return Alpha; }(_react.PureComponent || _react.Component); exports.default = Alpha; },{"../../helpers/alpha":359,"./Checkboard":322,"react":"react","reactcss":374}],322:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.Checkboard = undefined; var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _reactcss = require('reactcss'); var _reactcss2 = _interopRequireDefault(_reactcss); var _checkboard = require('../../helpers/checkboard'); var checkboard = _interopRequireWildcard(_checkboard); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var Checkboard = exports.Checkboard = function Checkboard(_ref) { var white = _ref.white, grey = _ref.grey, size = _ref.size, renderers = _ref.renderers, borderRadius = _ref.borderRadius, boxShadow = _ref.boxShadow, children = _ref.children; var styles = (0, _reactcss2.default)({ 'default': { grid: { borderRadius: borderRadius, boxShadow: boxShadow, absolute: '0px 0px 0px 0px', background: 'url(' + checkboard.get(white, grey, size, renderers.canvas) + ') center left' } } }); return (0, _react.isValidElement)(children) ? _react2.default.cloneElement(children, _extends({}, children.props, { style: _extends({}, children.props.style, styles.grid) })) : _react2.default.createElement('div', { style: styles.grid }); }; Checkboard.defaultProps = { size: 8, white: 'transparent', grey: 'rgba(0,0,0,.08)', renderers: {} }; exports.default = Checkboard; },{"../../helpers/checkboard":360,"react":"react","reactcss":374}],323:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.ColorWrap = undefined; var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _createClass = 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _debounce = require('lodash/debounce'); var _debounce2 = _interopRequireDefault(_debounce); var _color = require('../../helpers/color'); var color = _interopRequireWildcard(_color); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var ColorWrap = exports.ColorWrap = function ColorWrap(Picker) { var ColorPicker = function (_ref) { _inherits(ColorPicker, _ref); function ColorPicker(props) { _classCallCheck(this, ColorPicker); var _this = _possibleConstructorReturn(this, (ColorPicker.__proto__ || Object.getPrototypeOf(ColorPicker)).call(this)); _this.handleChange = function (data, event) { var isValidColor = color.simpleCheckForValidColor(data); if (isValidColor) { var colors = color.toState(data, data.h || _this.state.oldHue); _this.setState(colors); _this.props.onChangeComplete && _this.debounce(_this.props.onChangeComplete, colors, event); _this.props.onChange && _this.props.onChange(colors, event); } }; _this.handleSwatchHover = function (data, event) { var isValidColor = color.simpleCheckForValidColor(data); if (isValidColor) { var colors = color.toState(data, data.h || _this.state.oldHue); _this.props.onSwatchHover && _this.props.onSwatchHover(colors, event); } }; _this.state = _extends({}, color.toState(props.color, 0)); _this.debounce = (0, _debounce2.default)(function (fn, data, event) { fn(data, event); }, 100); return _this; } _createClass(ColorPicker, [{ key: 'render', value: function render() { var optionalEvents = {}; if (this.props.onSwatchHover) { optionalEvents.onSwatchHover = this.handleSwatchHover; } return _react2.default.createElement(Picker, _extends({}, this.props, this.state, { onChange: this.handleChange }, optionalEvents)); } }], [{ key: 'getDerivedStateFromProps', value: function getDerivedStateFromProps(nextProps, state) { return _extends({}, color.toState(nextProps.color, state.oldHue)); } }]); return ColorPicker; }(_react.PureComponent || _react.Component); ColorPicker.propTypes = _extends({}, Picker.propTypes); ColorPicker.defaultProps = _extends({}, Picker.defaultProps, { color: { h: 250, s: 0.50, l: 0.20, a: 1 } }); return ColorPicker; }; exports.default = ColorWrap; },{"../../helpers/color":361,"lodash/debounce":267,"react":"react"}],324:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.EditableInput = undefined; var _createClass = 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _reactcss = require('reactcss'); var _reactcss2 = _interopRequireDefault(_reactcss); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _defineProperty(obj, key, value) { 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 _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var DEFAULT_ARROW_OFFSET = 1; var UP_KEY_CODE = 38; var DOWN_KEY_CODE = 40; var VALID_KEY_CODES = [UP_KEY_CODE, DOWN_KEY_CODE]; var isValidKeyCode = function isValidKeyCode(keyCode) { return VALID_KEY_CODES.indexOf(keyCode) > -1; }; var getNumberValue = function getNumberValue(value) { return Number(String(value).replace(/%/g, '')); }; var idCounter = 1; var EditableInput = exports.EditableInput = function (_ref) { _inherits(EditableInput, _ref); function EditableInput(props) { _classCallCheck(this, EditableInput); var _this = _possibleConstructorReturn(this, (EditableInput.__proto__ || Object.getPrototypeOf(EditableInput)).call(this)); _this.handleBlur = function () { if (_this.state.blurValue) { _this.setState({ value: _this.state.blurValue, blurValue: null }); } }; _this.handleChange = function (e) { _this.setUpdatedValue(e.target.value, e); }; _this.handleKeyDown = function (e) { // In case `e.target.value` is a percentage remove the `%` character // and update accordingly with a percentage // https://github.com/casesandberg/react-color/issues/383 var value = getNumberValue(e.target.value); if (!isNaN(value) && isValidKeyCode(e.keyCode)) { var offset = _this.getArrowOffset(); var updatedValue = e.keyCode === UP_KEY_CODE ? value + offset : value - offset; _this.setUpdatedValue(updatedValue, e); } }; _this.handleDrag = function (e) { if (_this.props.dragLabel) { var newValue = Math.round(_this.props.value + e.movementX); if (newValue >= 0 && newValue <= _this.props.dragMax) { _this.props.onChange && _this.props.onChange(_this.getValueObjectWithLabel(newValue), e); } } }; _this.handleMouseDown = function (e) { if (_this.props.dragLabel) { e.preventDefault(); _this.handleDrag(e); window.addEventListener('mousemove', _this.handleDrag); window.addEventListener('mouseup', _this.handleMouseUp); } }; _this.handleMouseUp = function () { _this.unbindEventListeners(); }; _this.unbindEventListeners = function () { window.removeEventListener('mousemove', _this.handleDrag); window.removeEventListener('mouseup', _this.handleMouseUp); }; _this.state = { value: String(props.value).toUpperCase(), blurValue: String(props.value).toUpperCase() }; _this.inputId = 'rc-editable-input-' + idCounter++; return _this; } _createClass(EditableInput, [{ key: 'componentDidUpdate', value: function componentDidUpdate(prevProps, prevState) { if (this.props.value !== this.state.value && (prevProps.value !== this.props.value || prevState.value !== this.state.value)) { if (this.input === document.activeElement) { this.setState({ blurValue: String(this.props.value).toUpperCase() }); } else { this.setState({ value: String(this.props.value).toUpperCase(), blurValue: !this.state.blurValue && String(this.props.value).toUpperCase() }); } } } }, { key: 'componentWillUnmount', value: function componentWillUnmount() { this.unbindEventListeners(); } }, { key: 'getValueObjectWithLabel', value: function getValueObjectWithLabel(value) { return _defineProperty({}, this.props.label, value); } }, { key: 'getArrowOffset', value: function getArrowOffset() { return this.props.arrowOffset || DEFAULT_ARROW_OFFSET; } }, { key: 'setUpdatedValue', value: function setUpdatedValue(value, e) { var onChangeValue = this.props.label ? this.getValueObjectWithLabel(value) : value; this.props.onChange && this.props.onChange(onChangeValue, e); this.setState({ value: value }); } }, { key: 'render', value: function render() { var _this2 = this; var styles = (0, _reactcss2.default)({ 'default': { wrap: { position: 'relative' } }, 'user-override': { wrap: this.props.style && this.props.style.wrap ? this.props.style.wrap : {}, input: this.props.style && this.props.style.input ? this.props.style.input : {}, label: this.props.style && this.props.style.label ? this.props.style.label : {} }, 'dragLabel-true': { label: { cursor: 'ew-resize' } } }, { 'user-override': true }, this.props); return _react2.default.createElement( 'div', { style: styles.wrap }, _react2.default.createElement('input', { id: this.inputId, style: styles.input, ref: function ref(input) { return _this2.input = input; }, value: this.state.value, onKeyDown: this.handleKeyDown, onChange: this.handleChange, onBlur: this.handleBlur, placeholder: this.props.placeholder, spellCheck: 'false' }), this.props.label && !this.props.hideLabel ? _react2.default.createElement( 'label', { htmlFor: this.inputId, style: styles.label, onMouseDown: this.handleMouseDown }, this.props.label ) : null ); } }]); return EditableInput; }(_react.PureComponent || _react.Component); exports.default = EditableInput; },{"react":"react","reactcss":374}],325:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.Hue = undefined; var _createClass = 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _reactcss = require('reactcss'); var _reactcss2 = _interopRequireDefault(_reactcss); var _hue = require('../../helpers/hue'); var hue = _interopRequireWildcard(_hue); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var Hue = exports.Hue = function (_ref) { _inherits(Hue, _ref); function Hue() { var _ref2; var _temp, _this, _ret; _classCallCheck(this, Hue); for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref2 = Hue.__proto__ || Object.getPrototypeOf(Hue)).call.apply(_ref2, [this].concat(args))), _this), _this.handleChange = function (e) { var change = hue.calculateChange(e, _this.props.direction, _this.props.hsl, _this.container); change && typeof _this.props.onChange === 'function' && _this.props.onChange(change, e); }, _this.handleMouseDown = function (e) { _this.handleChange(e); window.addEventListener('mousemove', _this.handleChange); window.addEventListener('mouseup', _this.handleMouseUp); }, _this.handleMouseUp = function () { _this.unbindEventListeners(); }, _temp), _possibleConstructorReturn(_this, _ret); } _createClass(Hue, [{ key: 'componentWillUnmount', value: function componentWillUnmount() { this.unbindEventListeners(); } }, { key: 'unbindEventListeners', value: function unbindEventListeners() { window.removeEventListener('mousemove', this.handleChange); window.removeEventListener('mouseup', this.handleMouseUp); } }, { key: 'render', value: function render() { var _this2 = this; var _props$direction = this.props.direction, direction = _props$direction === undefined ? 'horizontal' : _props$direction; var styles = (0, _reactcss2.default)({ 'default': { hue: { absolute: '0px 0px 0px 0px', borderRadius: this.props.radius, boxShadow: this.props.shadow }, container: { padding: '0 2px', position: 'relative', height: '100%', borderRadius: this.props.radius }, pointer: { position: 'absolute', left: this.props.hsl.h * 100 / 360 + '%' }, slider: { marginTop: '1px', width: '4px', borderRadius: '1px', height: '8px', boxShadow: '0 0 2px rgba(0, 0, 0, .6)', background: '#fff', transform: 'translateX(-2px)' } }, 'vertical': { pointer: { left: '0px', top: -(this.props.hsl.h * 100 / 360) + 100 + '%' } } }, { vertical: direction === 'vertical' }); return _react2.default.createElement( 'div', { style: styles.hue }, _react2.default.createElement( 'div', { className: 'hue-' + direction, style: styles.container, ref: function ref(container) { return _this2.container = container; }, onMouseDown: this.handleMouseDown, onTouchMove: this.handleChange, onTouchStart: this.handleChange }, _react2.default.createElement( 'style', null, '\n .hue-horizontal {\n background: linear-gradient(to right, #f00 0%, #ff0 17%, #0f0\n 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%);\n background: -webkit-linear-gradient(to right, #f00 0%, #ff0\n 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%);\n }\n\n .hue-vertical {\n background: linear-gradient(to top, #f00 0%, #ff0 17%, #0f0 33%,\n #0ff 50%, #00f 67%, #f0f 83%, #f00 100%);\n background: -webkit-linear-gradient(to top, #f00 0%, #ff0 17%,\n #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%);\n }\n ' ), _react2.default.createElement( 'div', { style: styles.pointer }, this.props.pointer ? _react2.default.createElement(this.props.pointer, this.props) : _react2.default.createElement('div', { style: styles.slider }) ) ) ); } }]); return Hue; }(_react.PureComponent || _react.Component); exports.default = Hue; },{"../../helpers/hue":362,"react":"react","reactcss":374}],326:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.Raised = undefined; var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _propTypes = require('prop-types'); var _propTypes2 = _interopRequireDefault(_propTypes); var _reactcss = require('reactcss'); var _reactcss2 = _interopRequireDefault(_reactcss); var _merge = require('lodash/merge'); var _merge2 = _interopRequireDefault(_merge); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var Raised = exports.Raised = function Raised(_ref) { var zDepth = _ref.zDepth, radius = _ref.radius, background = _ref.background, children = _ref.children, _ref$styles = _ref.styles, passedStyles = _ref$styles === undefined ? {} : _ref$styles; var styles = (0, _reactcss2.default)((0, _merge2.default)({ 'default': { wrap: { position: 'relative', display: 'inline-block' }, content: { position: 'relative' }, bg: { absolute: '0px 0px 0px 0px', boxShadow: '0 ' + zDepth + 'px ' + zDepth * 4 + 'px rgba(0,0,0,.24)', borderRadius: radius, background: background } }, 'zDepth-0': { bg: { boxShadow: 'none' } }, 'zDepth-1': { bg: { boxShadow: '0 2px 10px rgba(0,0,0,.12), 0 2px 5px rgba(0,0,0,.16)' } }, 'zDepth-2': { bg: { boxShadow: '0 6px 20px rgba(0,0,0,.19), 0 8px 17px rgba(0,0,0,.2)' } }, 'zDepth-3': { bg: { boxShadow: '0 17px 50px rgba(0,0,0,.19), 0 12px 15px rgba(0,0,0,.24)' } }, 'zDepth-4': { bg: { boxShadow: '0 25px 55px rgba(0,0,0,.21), 0 16px 28px rgba(0,0,0,.22)' } }, 'zDepth-5': { bg: { boxShadow: '0 40px 77px rgba(0,0,0,.22), 0 27px 24px rgba(0,0,0,.2)' } }, 'square': { bg: { borderRadius: '0' } }, 'circle': { bg: { borderRadius: '50%' } } }, passedStyles), { 'zDepth-1': zDepth === 1 }); return _react2.default.createElement( 'div', { style: styles.wrap }, _react2.default.createElement('div', { style: styles.bg }), _react2.default.createElement( 'div', { style: styles.content }, children ) ); }; Raised.propTypes = { background: _propTypes2.default.string, zDepth: _propTypes2.default.oneOf([0, 1, 2, 3, 4, 5]), radius: _propTypes2.default.number, styles: _propTypes2.default.object }; Raised.defaultProps = { background: '#fff', zDepth: 1, radius: 2, styles: {} }; exports.default = Raised; },{"lodash/merge":295,"prop-types":309,"react":"react","reactcss":374}],327:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.Saturation = undefined; var _createClass = 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _reactcss = require('reactcss'); var _reactcss2 = _interopRequireDefault(_reactcss); var _throttle = require('lodash/throttle'); var _throttle2 = _interopRequireDefault(_throttle); var _saturation = require('../../helpers/saturation'); var saturation = _interopRequireWildcard(_saturation); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var Saturation = exports.Saturation = function (_ref) { _inherits(Saturation, _ref); function Saturation(props) { _classCallCheck(this, Saturation); var _this = _possibleConstructorReturn(this, (Saturation.__proto__ || Object.getPrototypeOf(Saturation)).call(this, props)); _this.handleChange = function (e) { typeof _this.props.onChange === 'function' && _this.throttle(_this.props.onChange, saturation.calculateChange(e, _this.props.hsl, _this.container), e); }; _this.handleMouseDown = function (e) { _this.handleChange(e); var renderWindow = _this.getContainerRenderWindow(); renderWindow.addEventListener('mousemove', _this.handleChange); renderWindow.addEventListener('mouseup', _this.handleMouseUp); }; _this.handleMouseUp = function () { _this.unbindEventListeners(); }; _this.throttle = (0, _throttle2.default)(function (fn, data, e) { fn(data, e); }, 50); return _this; } _createClass(Saturation, [{ key: 'componentWillUnmount', value: function componentWillUnmount() { this.throttle.cancel(); this.unbindEventListeners(); } }, { key: 'getContainerRenderWindow', value: function getContainerRenderWindow() { var container = this.container; var renderWindow = window; while (!renderWindow.document.contains(container) && renderWindow.parent !== renderWindow) { renderWindow = renderWindow.parent; } return renderWindow; } }, { key: 'unbindEventListeners', value: function unbindEventListeners() { var renderWindow = this.getContainerRenderWindow(); renderWindow.removeEventListener('mousemove', this.handleChange); renderWindow.removeEventListener('mouseup', this.handleMouseUp); } }, { key: 'render', value: function render() { var _this2 = this; var _ref2 = this.props.style || {}, color = _ref2.color, white = _ref2.white, black = _ref2.black, pointer = _ref2.pointer, circle = _ref2.circle; var styles = (0, _reactcss2.default)({ 'default': { color: { absolute: '0px 0px 0px 0px', background: 'hsl(' + this.props.hsl.h + ',100%, 50%)', borderRadius: this.props.radius }, white: { absolute: '0px 0px 0px 0px', borderRadius: this.props.radius }, black: { absolute: '0px 0px 0px 0px', boxShadow: this.props.shadow, borderRadius: this.props.radius }, pointer: { position: 'absolute', top: -(this.props.hsv.v * 100) + 100 + '%', left: this.props.hsv.s * 100 + '%', cursor: 'default' }, circle: { width: '4px', height: '4px', boxShadow: '0 0 0 1.5px #fff, inset 0 0 1px 1px rgba(0,0,0,.3),\n 0 0 1px 2px rgba(0,0,0,.4)', borderRadius: '50%', cursor: 'hand', transform: 'translate(-2px, -2px)' } }, 'custom': { color: color, white: white, black: black, pointer: pointer, circle: circle } }, { 'custom': !!this.props.style }); return _react2.default.createElement( 'div', { style: styles.color, ref: function ref(container) { return _this2.container = container; }, onMouseDown: this.handleMouseDown, onTouchMove: this.handleChange, onTouchStart: this.handleChange }, _react2.default.createElement( 'style', null, '\n .saturation-white {\n background: -webkit-linear-gradient(to right, #fff, rgba(255,255,255,0));\n background: linear-gradient(to right, #fff, rgba(255,255,255,0));\n }\n .saturation-black {\n background: -webkit-linear-gradient(to top, #000, rgba(0,0,0,0));\n background: linear-gradient(to top, #000, rgba(0,0,0,0));\n }\n ' ), _react2.default.createElement( 'div', { style: styles.white, className: 'saturation-white' }, _react2.default.createElement('div', { style: styles.black, className: 'saturation-black' }), _react2.default.createElement( 'div', { style: styles.pointer }, this.props.pointer ? _react2.default.createElement(this.props.pointer, this.props) : _react2.default.createElement('div', { style: styles.circle }) ) ) ); } }]); return Saturation; }(_react.PureComponent || _react.Component); exports.default = Saturation; },{"../../helpers/saturation":364,"lodash/throttle":300,"react":"react","reactcss":374}],328:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.Swatch = undefined; var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _reactcss = require('reactcss'); var _reactcss2 = _interopRequireDefault(_reactcss); var _interaction = require('../../helpers/interaction'); var _Checkboard = require('./Checkboard'); var _Checkboard2 = _interopRequireDefault(_Checkboard); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var ENTER = 13; var Swatch = exports.Swatch = function Swatch(_ref) { var color = _ref.color, style = _ref.style, _ref$onClick = _ref.onClick, onClick = _ref$onClick === undefined ? function () {} : _ref$onClick, onHover = _ref.onHover, _ref$title = _ref.title, title = _ref$title === undefined ? color : _ref$title, children = _ref.children, focus = _ref.focus, _ref$focusStyle = _ref.focusStyle, focusStyle = _ref$focusStyle === undefined ? {} : _ref$focusStyle; var transparent = color === 'transparent'; var styles = (0, _reactcss2.default)({ default: { swatch: _extends({ background: color, height: '100%', width: '100%', cursor: 'pointer', position: 'relative', outline: 'none' }, style, focus ? focusStyle : {}) } }); var handleClick = function handleClick(e) { return onClick(color, e); }; var handleKeyDown = function handleKeyDown(e) { return e.keyCode === ENTER && onClick(color, e); }; var handleHover = function handleHover(e) { return onHover(color, e); }; var optionalEvents = {}; if (onHover) { optionalEvents.onMouseOver = handleHover; } return _react2.default.createElement( 'div', _extends({ style: styles.swatch, onClick: handleClick, title: title, tabIndex: 0, onKeyDown: handleKeyDown }, optionalEvents), children, transparent && _react2.default.createElement(_Checkboard2.default, { borderRadius: styles.swatch.borderRadius, boxShadow: 'inset 0 0 0 1px rgba(0,0,0,0.1)' }) ); }; exports.default = (0, _interaction.handleFocus)(Swatch); },{"../../helpers/interaction":363,"./Checkboard":322,"react":"react","reactcss":374}],329:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _Alpha = require('./Alpha'); Object.defineProperty(exports, 'Alpha', { enumerable: true, get: function get() { return _interopRequireDefault(_Alpha).default; } }); var _Checkboard = require('./Checkboard'); Object.defineProperty(exports, 'Checkboard', { enumerable: true, get: function get() { return _interopRequireDefault(_Checkboard).default; } }); var _EditableInput = require('./EditableInput'); Object.defineProperty(exports, 'EditableInput', { enumerable: true, get: function get() { return _interopRequireDefault(_EditableInput).default; } }); var _Hue = require('./Hue'); Object.defineProperty(exports, 'Hue', { enumerable: true, get: function get() { return _interopRequireDefault(_Hue).default; } }); var _Raised = require('./Raised'); Object.defineProperty(exports, 'Raised', { enumerable: true, get: function get() { return _interopRequireDefault(_Raised).default; } }); var _Saturation = require('./Saturation'); Object.defineProperty(exports, 'Saturation', { enumerable: true, get: function get() { return _interopRequireDefault(_Saturation).default; } }); var _ColorWrap = require('./ColorWrap'); Object.defineProperty(exports, 'ColorWrap', { enumerable: true, get: function get() { return _interopRequireDefault(_ColorWrap).default; } }); var _Swatch = require('./Swatch'); Object.defineProperty(exports, 'Swatch', { enumerable: true, get: function get() { return _interopRequireDefault(_Swatch).default; } }); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } },{"./Alpha":321,"./Checkboard":322,"./ColorWrap":323,"./EditableInput":324,"./Hue":325,"./Raised":326,"./Saturation":327,"./Swatch":328}],330:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.Compact = undefined; var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _propTypes = require('prop-types'); var _propTypes2 = _interopRequireDefault(_propTypes); var _reactcss = require('reactcss'); var _reactcss2 = _interopRequireDefault(_reactcss); var _map = require('lodash/map'); var _map2 = _interopRequireDefault(_map); var _merge = require('lodash/merge'); var _merge2 = _interopRequireDefault(_merge); var _color = require('../../helpers/color'); var color = _interopRequireWildcard(_color); var _common = require('../common'); var _CompactColor = require('./CompactColor'); var _CompactColor2 = _interopRequireDefault(_CompactColor); var _CompactFields = require('./CompactFields'); var _CompactFields2 = _interopRequireDefault(_CompactFields); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var Compact = exports.Compact = function Compact(_ref) { var onChange = _ref.onChange, onSwatchHover = _ref.onSwatchHover, colors = _ref.colors, hex = _ref.hex, rgb = _ref.rgb, _ref$styles = _ref.styles, passedStyles = _ref$styles === undefined ? {} : _ref$styles, _ref$className = _ref.className, className = _ref$className === undefined ? '' : _ref$className; var styles = (0, _reactcss2.default)((0, _merge2.default)({ 'default': { Compact: { background: '#f6f6f6', radius: '4px' }, compact: { paddingTop: '5px', paddingLeft: '5px', boxSizing: 'initial', width: '240px' }, clear: { clear: 'both' } } }, passedStyles)); var handleChange = function handleChange(data, e) { if (data.hex) { color.isValidHex(data.hex) && onChange({ hex: data.hex, source: 'hex' }, e); } else { onChange(data, e); } }; return _react2.default.createElement( _common.Raised, { style: styles.Compact, styles: passedStyles }, _react2.default.createElement( 'div', { style: styles.compact, className: 'compact-picker ' + className }, _react2.default.createElement( 'div', null, (0, _map2.default)(colors, function (c) { return _react2.default.createElement(_CompactColor2.default, { key: c, color: c, active: c.toLowerCase() === hex, onClick: handleChange, onSwatchHover: onSwatchHover }); }), _react2.default.createElement('div', { style: styles.clear }) ), _react2.default.createElement(_CompactFields2.default, { hex: hex, rgb: rgb, onChange: handleChange }) ) ); }; Compact.propTypes = { colors: _propTypes2.default.arrayOf(_propTypes2.default.string), styles: _propTypes2.default.object }; Compact.defaultProps = { colors: ['#4D4D4D', '#999999', '#FFFFFF', '#F44E3B', '#FE9200', '#FCDC00', '#DBDF00', '#A4DD00', '#68CCCA', '#73D8FF', '#AEA1FF', '#FDA1FF', '#333333', '#808080', '#cccccc', '#D33115', '#E27300', '#FCC400', '#B0BC00', '#68BC00', '#16A5A5', '#009CE0', '#7B64FF', '#FA28FF', '#000000', '#666666', '#B3B3B3', '#9F0500', '#C45100', '#FB9E00', '#808900', '#194D33', '#0C797D', '#0062B1', '#653294', '#AB149E'], styles: {} }; exports.default = (0, _common.ColorWrap)(Compact); },{"../../helpers/color":361,"../common":329,"./CompactColor":331,"./CompactFields":332,"lodash/map":293,"lodash/merge":295,"prop-types":309,"react":"react","reactcss":374}],331:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.CompactColor = undefined; var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _reactcss = require('reactcss'); var _reactcss2 = _interopRequireDefault(_reactcss); var _color = require('../../helpers/color'); var colorUtils = _interopRequireWildcard(_color); var _common = require('../common'); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var CompactColor = exports.CompactColor = function CompactColor(_ref) { var color = _ref.color, _ref$onClick = _ref.onClick, onClick = _ref$onClick === undefined ? function () {} : _ref$onClick, onSwatchHover = _ref.onSwatchHover, active = _ref.active; var styles = (0, _reactcss2.default)({ 'default': { color: { background: color, width: '15px', height: '15px', float: 'left', marginRight: '5px', marginBottom: '5px', position: 'relative', cursor: 'pointer' }, dot: { absolute: '5px 5px 5px 5px', background: colorUtils.getContrastingColor(color), borderRadius: '50%', opacity: '0' } }, 'active': { dot: { opacity: '1' } }, 'color-#FFFFFF': { color: { boxShadow: 'inset 0 0 0 1px #ddd' }, dot: { background: '#000' } }, 'transparent': { dot: { background: '#000' } } }, { active: active, 'color-#FFFFFF': color === '#FFFFFF', 'transparent': color === 'transparent' }); return _react2.default.createElement( _common.Swatch, { style: styles.color, color: color, onClick: onClick, onHover: onSwatchHover, focusStyle: { boxShadow: '0 0 4px ' + color } }, _react2.default.createElement('div', { style: styles.dot }) ); }; exports.default = CompactColor; },{"../../helpers/color":361,"../common":329,"react":"react","reactcss":374}],332:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.CompactFields = undefined; var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _reactcss = require('reactcss'); var _reactcss2 = _interopRequireDefault(_reactcss); var _common = require('../common'); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var CompactFields = exports.CompactFields = function CompactFields(_ref) { var hex = _ref.hex, rgb = _ref.rgb, onChange = _ref.onChange; var styles = (0, _reactcss2.default)({ 'default': { fields: { display: 'flex', paddingBottom: '6px', paddingRight: '5px', position: 'relative' }, active: { position: 'absolute', top: '6px', left: '5px', height: '9px', width: '9px', background: hex }, HEXwrap: { flex: '6', position: 'relative' }, HEXinput: { width: '80%', padding: '0px', paddingLeft: '20%', border: 'none', outline: 'none', background: 'none', fontSize: '12px', color: '#333', height: '16px' }, HEXlabel: { display: 'none' }, RGBwrap: { flex: '3', position: 'relative' }, RGBinput: { width: '70%', padding: '0px', paddingLeft: '30%', border: 'none', outline: 'none', background: 'none', fontSize: '12px', color: '#333', height: '16px' }, RGBlabel: { position: 'absolute', top: '3px', left: '0px', lineHeight: '16px', textTransform: 'uppercase', fontSize: '12px', color: '#999' } } }); var handleChange = function handleChange(data, e) { if (data.r || data.g || data.b) { onChange({ r: data.r || rgb.r, g: data.g || rgb.g, b: data.b || rgb.b, source: 'rgb' }, e); } else { onChange({ hex: data.hex, source: 'hex' }, e); } }; return _react2.default.createElement( 'div', { style: styles.fields, className: 'flexbox-fix' }, _react2.default.createElement('div', { style: styles.active }), _react2.default.createElement(_common.EditableInput, { style: { wrap: styles.HEXwrap, input: styles.HEXinput, label: styles.HEXlabel }, label: 'hex', value: hex, onChange: handleChange }), _react2.default.createElement(_common.EditableInput, { style: { wrap: styles.RGBwrap, input: styles.RGBinput, label: styles.RGBlabel }, label: 'r', value: rgb.r, onChange: handleChange }), _react2.default.createElement(_common.EditableInput, { style: { wrap: styles.RGBwrap, input: styles.RGBinput, label: styles.RGBlabel }, label: 'g', value: rgb.g, onChange: handleChange }), _react2.default.createElement(_common.EditableInput, { style: { wrap: styles.RGBwrap, input: styles.RGBinput, label: styles.RGBlabel }, label: 'b', value: rgb.b, onChange: handleChange }) ); }; exports.default = CompactFields; },{"../common":329,"react":"react","reactcss":374}],333:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.Github = undefined; var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _propTypes = require('prop-types'); var _propTypes2 = _interopRequireDefault(_propTypes); var _reactcss = require('reactcss'); var _reactcss2 = _interopRequireDefault(_reactcss); var _map = require('lodash/map'); var _map2 = _interopRequireDefault(_map); var _merge = require('lodash/merge'); var _merge2 = _interopRequireDefault(_merge); var _common = require('../common'); var _GithubSwatch = require('./GithubSwatch'); var _GithubSwatch2 = _interopRequireDefault(_GithubSwatch); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var Github = exports.Github = function Github(_ref) { var width = _ref.width, colors = _ref.colors, onChange = _ref.onChange, onSwatchHover = _ref.onSwatchHover, triangle = _ref.triangle, _ref$styles = _ref.styles, passedStyles = _ref$styles === undefined ? {} : _ref$styles, _ref$className = _ref.className, className = _ref$className === undefined ? '' : _ref$className; var styles = (0, _reactcss2.default)((0, _merge2.default)({ 'default': { card: { width: width, background: '#fff', border: '1px solid rgba(0,0,0,0.2)', boxShadow: '0 3px 12px rgba(0,0,0,0.15)', borderRadius: '4px', position: 'relative', padding: '5px', display: 'flex', flexWrap: 'wrap' }, triangle: { position: 'absolute', border: '7px solid transparent', borderBottomColor: '#fff' }, triangleShadow: { position: 'absolute', border: '8px solid transparent', borderBottomColor: 'rgba(0,0,0,0.15)' } }, 'hide-triangle': { triangle: { display: 'none' }, triangleShadow: { display: 'none' } }, 'top-left-triangle': { triangle: { top: '-14px', left: '10px' }, triangleShadow: { top: '-16px', left: '9px' } }, 'top-right-triangle': { triangle: { top: '-14px', right: '10px' }, triangleShadow: { top: '-16px', right: '9px' } }, 'bottom-left-triangle': { triangle: { top: '35px', left: '10px', transform: 'rotate(180deg)' }, triangleShadow: { top: '37px', left: '9px', transform: 'rotate(180deg)' } }, 'bottom-right-triangle': { triangle: { top: '35px', right: '10px', transform: 'rotate(180deg)' }, triangleShadow: { top: '37px', right: '9px', transform: 'rotate(180deg)' } } }, passedStyles), { 'hide-triangle': triangle === 'hide', 'top-left-triangle': triangle === 'top-left', 'top-right-triangle': triangle === 'top-right', 'bottom-left-triangle': triangle === 'bottom-left', 'bottom-right-triangle': triangle === 'bottom-right' }); var handleChange = function handleChange(hex, e) { return onChange({ hex: hex, source: 'hex' }, e); }; return _react2.default.createElement( 'div', { style: styles.card, className: 'github-picker ' + className }, _react2.default.createElement('div', { style: styles.triangleShadow }), _react2.default.createElement('div', { style: styles.triangle }), (0, _map2.default)(colors, function (c) { return _react2.default.createElement(_GithubSwatch2.default, { color: c, key: c, onClick: handleChange, onSwatchHover: onSwatchHover }); }) ); }; Github.propTypes = { width: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.number]), colors: _propTypes2.default.arrayOf(_propTypes2.default.string), triangle: _propTypes2.default.oneOf(['hide', 'top-left', 'top-right', 'bottom-left', 'bottom-right']), styles: _propTypes2.default.object }; Github.defaultProps = { width: 200, colors: ['#B80000', '#DB3E00', '#FCCB00', '#008B02', '#006B76', '#1273DE', '#004DCF', '#5300EB', '#EB9694', '#FAD0C3', '#FEF3BD', '#C1E1C5', '#BEDADC', '#C4DEF6', '#BED3F3', '#D4C4FB'], triangle: 'top-left', styles: {} }; exports.default = (0, _common.ColorWrap)(Github); },{"../common":329,"./GithubSwatch":334,"lodash/map":293,"lodash/merge":295,"prop-types":309,"react":"react","reactcss":374}],334:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.GithubSwatch = undefined; var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _reactcss = require('reactcss'); var _reactcss2 = _interopRequireDefault(_reactcss); var _common = require('../common'); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var GithubSwatch = exports.GithubSwatch = function GithubSwatch(_ref) { var hover = _ref.hover, color = _ref.color, onClick = _ref.onClick, onSwatchHover = _ref.onSwatchHover; var hoverSwatch = { position: 'relative', zIndex: '2', outline: '2px solid #fff', boxShadow: '0 0 5px 2px rgba(0,0,0,0.25)' }; var styles = (0, _reactcss2.default)({ 'default': { swatch: { width: '25px', height: '25px', fontSize: '0' } }, 'hover': { swatch: hoverSwatch } }, { hover: hover }); return _react2.default.createElement( 'div', { style: styles.swatch }, _react2.default.createElement(_common.Swatch, { color: color, onClick: onClick, onHover: onSwatchHover, focusStyle: hoverSwatch }) ); }; exports.default = (0, _reactcss.handleHover)(GithubSwatch); },{"../common":329,"react":"react","reactcss":374}],335:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.Google = undefined; var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _propTypes = require('prop-types'); var _propTypes2 = _interopRequireDefault(_propTypes); var _reactcss = require('reactcss'); var _reactcss2 = _interopRequireDefault(_reactcss); var _merge = require('lodash/merge'); var _merge2 = _interopRequireDefault(_merge); var _common = require('../common'); var _GooglePointerCircle = require('./GooglePointerCircle'); var _GooglePointerCircle2 = _interopRequireDefault(_GooglePointerCircle); var _GooglePointer = require('./GooglePointer'); var _GooglePointer2 = _interopRequireDefault(_GooglePointer); var _GoogleFields = require('./GoogleFields'); var _GoogleFields2 = _interopRequireDefault(_GoogleFields); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var Google = exports.Google = function Google(_ref) { var width = _ref.width, onChange = _ref.onChange, rgb = _ref.rgb, hsl = _ref.hsl, hsv = _ref.hsv, hex = _ref.hex, header = _ref.header, _ref$styles = _ref.styles, passedStyles = _ref$styles === undefined ? {} : _ref$styles, _ref$className = _ref.className, className = _ref$className === undefined ? '' : _ref$className; var styles = (0, _reactcss2.default)((0, _merge2.default)({ 'default': { picker: { width: width, background: '#fff', border: '1px solid #dfe1e5', boxSizing: 'initial', display: 'flex', flexWrap: 'wrap', borderRadius: '8px 8px 0px 0px' }, head: { height: '57px', width: '100%', paddingTop: '16px', paddingBottom: '16px', paddingLeft: '16px', fontSize: '20px', boxSizing: 'border-box', fontFamily: 'Roboto-Regular,HelveticaNeue,Arial,sans-serif' }, saturation: { width: '70%', padding: '0px', position: 'relative', overflow: 'hidden' }, swatch: { width: '30%', height: '228px', padding: '0px', background: 'rgba(' + rgb.r + ', ' + rgb.g + ', ' + rgb.b + ', 1)', position: 'relative', overflow: 'hidden' }, body: { margin: 'auto', width: '95%' }, controls: { display: 'flex', boxSizing: 'border-box', height: '52px', paddingTop: '22px' }, color: { width: '32px' }, hue: { height: '8px', position: 'relative', margin: '0px 16px 0px 16px', width: '100%' }, Hue: { radius: '2px' } } }, passedStyles)); return _react2.default.createElement( 'div', { style: styles.picker, className: 'google-picker ' + className }, _react2.default.createElement( 'div', { style: styles.head }, header ), _react2.default.createElement('div', { style: styles.swatch }), _react2.default.createElement( 'div', { style: styles.saturation }, _react2.default.createElement(_common.Saturation, { hsl: hsl, hsv: hsv, pointer: _GooglePointerCircle2.default, onChange: onChange }) ), _react2.default.createElement( 'div', { style: styles.body }, _react2.default.createElement( 'div', { style: styles.controls, className: 'flexbox-fix' }, _react2.default.createElement( 'div', { style: styles.hue }, _react2.default.createElement(_common.Hue, { style: styles.Hue, hsl: hsl, radius: '4px', pointer: _GooglePointer2.default, onChange: onChange }) ) ), _react2.default.createElement(_GoogleFields2.default, { rgb: rgb, hsl: hsl, hex: hex, hsv: hsv, onChange: onChange }) ) ); }; Google.propTypes = { width: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.number]), styles: _propTypes2.default.object, header: _propTypes2.default.string }; Google.defaultProps = { width: 652, styles: {}, header: 'Color picker' }; exports.default = (0, _common.ColorWrap)(Google); },{"../common":329,"./GoogleFields":336,"./GooglePointer":337,"./GooglePointerCircle":338,"lodash/merge":295,"prop-types":309,"react":"react","reactcss":374}],336:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.GoogleFields = undefined; var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _reactcss = require('reactcss'); var _reactcss2 = _interopRequireDefault(_reactcss); var _color = require('../../helpers/color'); var color = _interopRequireWildcard(_color); var _common = require('../common'); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var GoogleFields = exports.GoogleFields = function GoogleFields(_ref) { var onChange = _ref.onChange, rgb = _ref.rgb, hsl = _ref.hsl, hex = _ref.hex, hsv = _ref.hsv; var handleChange = function handleChange(data, e) { if (data.hex) { color.isValidHex(data.hex) && onChange({ hex: data.hex, source: 'hex' }, e); } else if (data.rgb) { var values = data.rgb.split(','); color.isvalidColorString(data.rgb, 'rgb') && onChange({ r: values[0], g: values[1], b: values[2], a: 1, source: 'rgb' }, e); } else if (data.hsv) { var _values = data.hsv.split(','); if (color.isvalidColorString(data.hsv, 'hsv')) { _values[2] = _values[2].replace('%', ''); _values[1] = _values[1].replace('%', ''); _values[0] = _values[0].replace('°', ''); if (_values[1] == 1) { _values[1] = 0.01; } else if (_values[2] == 1) { _values[2] = 0.01; } onChange({ h: Number(_values[0]), s: Number(_values[1]), v: Number(_values[2]), source: 'hsv' }, e); } } else if (data.hsl) { var _values2 = data.hsl.split(','); if (color.isvalidColorString(data.hsl, 'hsl')) { _values2[2] = _values2[2].replace('%', ''); _values2[1] = _values2[1].replace('%', ''); _values2[0] = _values2[0].replace('°', ''); if (hsvValue[1] == 1) { hsvValue[1] = 0.01; } else if (hsvValue[2] == 1) { hsvValue[2] = 0.01; } onChange({ h: Number(_values2[0]), s: Number(_values2[1]), v: Number(_values2[2]), source: 'hsl' }, e); } } }; var styles = (0, _reactcss2.default)({ 'default': { wrap: { display: 'flex', height: '100px', marginTop: '4px' }, fields: { width: '100%' }, column: { paddingTop: '10px', display: 'flex', justifyContent: 'space-between' }, double: { padding: '0px 4.4px', boxSizing: 'border-box' }, input: { width: '100%', height: '38px', boxSizing: 'border-box', padding: '4px 10% 3px', textAlign: 'center', border: '1px solid #dadce0', fontSize: '11px', textTransform: 'lowercase', borderRadius: '5px', outline: 'none', fontFamily: 'Roboto,Arial,sans-serif' }, input2: { height: '38px', width: '100%', border: '1px solid #dadce0', boxSizing: 'border-box', fontSize: '11px', textTransform: 'lowercase', borderRadius: '5px', outline: 'none', paddingLeft: '10px', fontFamily: 'Roboto,Arial,sans-serif' }, label: { textAlign: 'center', fontSize: '12px', background: '#fff', position: 'absolute', textTransform: 'uppercase', color: '#3c4043', width: '35px', top: '-6px', left: '0', right: '0', marginLeft: 'auto', marginRight: 'auto', fontFamily: 'Roboto,Arial,sans-serif' }, label2: { left: '10px', textAlign: 'center', fontSize: '12px', background: '#fff', position: 'absolute', textTransform: 'uppercase', color: '#3c4043', width: '32px', top: '-6px', fontFamily: 'Roboto,Arial,sans-serif' }, single: { flexGrow: '1', margin: '0px 4.4px' } } }); var rgbValue = rgb.r + ', ' + rgb.g + ', ' + rgb.b; var hslValue = Math.round(hsl.h) + '\xB0, ' + Math.round(hsl.s * 100) + '%, ' + Math.round(hsl.l * 100) + '%'; var hsvValue = Math.round(hsv.h) + '\xB0, ' + Math.round(hsv.s * 100) + '%, ' + Math.round(hsv.v * 100) + '%'; return _react2.default.createElement( 'div', { style: styles.wrap, className: 'flexbox-fix' }, _react2.default.createElement( 'div', { style: styles.fields }, _react2.default.createElement( 'div', { style: styles.double }, _react2.default.createElement(_common.EditableInput, { style: { input: styles.input, label: styles.label }, label: 'hex', value: hex, onChange: handleChange }) ), _react2.default.createElement( 'div', { style: styles.column }, _react2.default.createElement( 'div', { style: styles.single }, _react2.default.createElement(_common.EditableInput, { style: { input: styles.input2, label: styles.label2 }, label: 'rgb', value: rgbValue, onChange: handleChange }) ), _react2.default.createElement( 'div', { style: styles.single }, _react2.default.createElement(_common.EditableInput, { style: { input: styles.input2, label: styles.label2 }, label: 'hsv', value: hsvValue, onChange: handleChange }) ), _react2.default.createElement( 'div', { style: styles.single }, _react2.default.createElement(_common.EditableInput, { style: { input: styles.input2, label: styles.label2 }, label: 'hsl', value: hslValue, onChange: handleChange }) ) ) ) ); }; exports.default = GoogleFields; },{"../../helpers/color":361,"../common":329,"react":"react","reactcss":374}],337:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.GooglePointer = undefined; var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _reactcss = require('reactcss'); var _reactcss2 = _interopRequireDefault(_reactcss); var _propTypes = require('prop-types'); var _propTypes2 = _interopRequireDefault(_propTypes); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var GooglePointer = exports.GooglePointer = function GooglePointer(props) { var styles = (0, _reactcss2.default)({ 'default': { picker: { width: '20px', height: '20px', borderRadius: '22px', transform: 'translate(-10px, -7px)', background: 'hsl(' + Math.round(props.hsl.h) + ', 100%, 50%)', border: '2px white solid' } } }); return _react2.default.createElement('div', { style: styles.picker }); }; GooglePointer.propTypes = { hsl: _propTypes2.default.shape({ h: _propTypes2.default.number, s: _propTypes2.default.number, l: _propTypes2.default.number, a: _propTypes2.default.number }) }; GooglePointer.defaultProps = { hsl: { a: 1, h: 249.94, l: 0.2, s: 0.50 } }; exports.default = GooglePointer; },{"prop-types":309,"react":"react","reactcss":374}],338:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.GooglePointerCircle = undefined; var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _reactcss = require('reactcss'); var _reactcss2 = _interopRequireDefault(_reactcss); var _propTypes = require('prop-types'); var _propTypes2 = _interopRequireDefault(_propTypes); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var GooglePointerCircle = exports.GooglePointerCircle = function GooglePointerCircle(props) { var styles = (0, _reactcss2.default)({ 'default': { picker: { width: '20px', height: '20px', borderRadius: '22px', border: '2px #fff solid', transform: 'translate(-12px, -13px)', background: 'hsl(' + Math.round(props.hsl.h) + ', ' + Math.round(props.hsl.s * 100) + '%, ' + Math.round(props.hsl.l * 100) + '%)' } } }); return _react2.default.createElement('div', { style: styles.picker }); }; GooglePointerCircle.propTypes = { hsl: _propTypes2.default.shape({ h: _propTypes2.default.number, s: _propTypes2.default.number, l: _propTypes2.default.number, a: _propTypes2.default.number }) }; GooglePointerCircle.defaultProps = { hsl: { a: 1, h: 249.94, l: 0.2, s: 0.50 } }; exports.default = GooglePointerCircle; },{"prop-types":309,"react":"react","reactcss":374}],339:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.HuePicker = undefined; var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _propTypes = require('prop-types'); var _propTypes2 = _interopRequireDefault(_propTypes); var _reactcss = require('reactcss'); var _reactcss2 = _interopRequireDefault(_reactcss); var _merge = require('lodash/merge'); var _merge2 = _interopRequireDefault(_merge); var _common = require('../common'); var _HuePointer = require('./HuePointer'); var _HuePointer2 = _interopRequireDefault(_HuePointer); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var HuePicker = exports.HuePicker = function HuePicker(_ref) { var width = _ref.width, height = _ref.height, onChange = _ref.onChange, hsl = _ref.hsl, direction = _ref.direction, pointer = _ref.pointer, _ref$styles = _ref.styles, passedStyles = _ref$styles === undefined ? {} : _ref$styles, _ref$className = _ref.className, className = _ref$className === undefined ? '' : _ref$className; var styles = (0, _reactcss2.default)((0, _merge2.default)({ 'default': { picker: { position: 'relative', width: width, height: height }, hue: { radius: '2px' } } }, passedStyles)); // Overwrite to provide pure hue color var handleChange = function handleChange(data) { return onChange({ a: 1, h: data.h, l: 0.5, s: 1 }); }; return _react2.default.createElement( 'div', { style: styles.picker, className: 'hue-picker ' + className }, _react2.default.createElement(_common.Hue, _extends({}, styles.hue, { hsl: hsl, pointer: pointer, onChange: handleChange, direction: direction })) ); }; HuePicker.propTypes = { styles: _propTypes2.default.object }; HuePicker.defaultProps = { width: '316px', height: '16px', direction: 'horizontal', pointer: _HuePointer2.default, styles: {} }; exports.default = (0, _common.ColorWrap)(HuePicker); },{"../common":329,"./HuePointer":340,"lodash/merge":295,"prop-types":309,"react":"react","reactcss":374}],340:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.SliderPointer = undefined; var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _reactcss = require('reactcss'); var _reactcss2 = _interopRequireDefault(_reactcss); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var SliderPointer = exports.SliderPointer = function SliderPointer(_ref) { var direction = _ref.direction; var styles = (0, _reactcss2.default)({ 'default': { picker: { width: '18px', height: '18px', borderRadius: '50%', transform: 'translate(-9px, -1px)', backgroundColor: 'rgb(248, 248, 248)', boxShadow: '0 1px 4px 0 rgba(0, 0, 0, 0.37)' } }, 'vertical': { picker: { transform: 'translate(-3px, -9px)' } } }, { vertical: direction === 'vertical' }); return _react2.default.createElement('div', { style: styles.picker }); }; exports.default = SliderPointer; },{"react":"react","reactcss":374}],341:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.Material = undefined; var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _reactcss = require('reactcss'); var _reactcss2 = _interopRequireDefault(_reactcss); var _merge = require('lodash/merge'); var _merge2 = _interopRequireDefault(_merge); var _color = require('../../helpers/color'); var color = _interopRequireWildcard(_color); var _common = require('../common'); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var Material = exports.Material = function Material(_ref) { var onChange = _ref.onChange, hex = _ref.hex, rgb = _ref.rgb, _ref$styles = _ref.styles, passedStyles = _ref$styles === undefined ? {} : _ref$styles, _ref$className = _ref.className, className = _ref$className === undefined ? '' : _ref$className; var styles = (0, _reactcss2.default)((0, _merge2.default)({ 'default': { material: { width: '98px', height: '98px', padding: '16px', fontFamily: 'Roboto' }, HEXwrap: { position: 'relative' }, HEXinput: { width: '100%', marginTop: '12px', fontSize: '15px', color: '#333', padding: '0px', border: '0px', borderBottom: '2px solid ' + hex, outline: 'none', height: '30px' }, HEXlabel: { position: 'absolute', top: '0px', left: '0px', fontSize: '11px', color: '#999999', textTransform: 'capitalize' }, Hex: { style: {} }, RGBwrap: { position: 'relative' }, RGBinput: { width: '100%', marginTop: '12px', fontSize: '15px', color: '#333', padding: '0px', border: '0px', borderBottom: '1px solid #eee', outline: 'none', height: '30px' }, RGBlabel: { position: 'absolute', top: '0px', left: '0px', fontSize: '11px', color: '#999999', textTransform: 'capitalize' }, split: { display: 'flex', marginRight: '-10px', paddingTop: '11px' }, third: { flex: '1', paddingRight: '10px' } } }, passedStyles)); var handleChange = function handleChange(data, e) { if (data.hex) { color.isValidHex(data.hex) && onChange({ hex: data.hex, source: 'hex' }, e); } else if (data.r || data.g || data.b) { onChange({ r: data.r || rgb.r, g: data.g || rgb.g, b: data.b || rgb.b, source: 'rgb' }, e); } }; return _react2.default.createElement( _common.Raised, { styles: passedStyles }, _react2.default.createElement( 'div', { style: styles.material, className: 'material-picker ' + className }, _react2.default.createElement(_common.EditableInput, { style: { wrap: styles.HEXwrap, input: styles.HEXinput, label: styles.HEXlabel }, label: 'hex', value: hex, onChange: handleChange }), _react2.default.createElement( 'div', { style: styles.split, className: 'flexbox-fix' }, _react2.default.createElement( 'div', { style: styles.third }, _react2.default.createElement(_common.EditableInput, { style: { wrap: styles.RGBwrap, input: styles.RGBinput, label: styles.RGBlabel }, label: 'r', value: rgb.r, onChange: handleChange }) ), _react2.default.createElement( 'div', { style: styles.third }, _react2.default.createElement(_common.EditableInput, { style: { wrap: styles.RGBwrap, input: styles.RGBinput, label: styles.RGBlabel }, label: 'g', value: rgb.g, onChange: handleChange }) ), _react2.default.createElement( 'div', { style: styles.third }, _react2.default.createElement(_common.EditableInput, { style: { wrap: styles.RGBwrap, input: styles.RGBinput, label: styles.RGBlabel }, label: 'b', value: rgb.b, onChange: handleChange }) ) ) ) ); }; exports.default = (0, _common.ColorWrap)(Material); },{"../../helpers/color":361,"../common":329,"lodash/merge":295,"react":"react","reactcss":374}],342:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.Photoshop = undefined; var _createClass = 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _propTypes = require('prop-types'); var _propTypes2 = _interopRequireDefault(_propTypes); var _reactcss = require('reactcss'); var _reactcss2 = _interopRequireDefault(_reactcss); var _merge = require('lodash/merge'); var _merge2 = _interopRequireDefault(_merge); var _common = require('../common'); var _PhotoshopFields = require('./PhotoshopFields'); var _PhotoshopFields2 = _interopRequireDefault(_PhotoshopFields); var _PhotoshopPointerCircle = require('./PhotoshopPointerCircle'); var _PhotoshopPointerCircle2 = _interopRequireDefault(_PhotoshopPointerCircle); var _PhotoshopPointer = require('./PhotoshopPointer'); var _PhotoshopPointer2 = _interopRequireDefault(_PhotoshopPointer); var _PhotoshopButton = require('./PhotoshopButton'); var _PhotoshopButton2 = _interopRequireDefault(_PhotoshopButton); var _PhotoshopPreviews = require('./PhotoshopPreviews'); var _PhotoshopPreviews2 = _interopRequireDefault(_PhotoshopPreviews); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var Photoshop = exports.Photoshop = function (_React$Component) { _inherits(Photoshop, _React$Component); function Photoshop(props) { _classCallCheck(this, Photoshop); var _this = _possibleConstructorReturn(this, (Photoshop.__proto__ || Object.getPrototypeOf(Photoshop)).call(this)); _this.state = { currentColor: props.hex }; return _this; } _createClass(Photoshop, [{ key: 'render', value: function render() { var _props = this.props, _props$styles = _props.styles, passedStyles = _props$styles === undefined ? {} : _props$styles, _props$className = _props.className, className = _props$className === undefined ? '' : _props$className; var styles = (0, _reactcss2.default)((0, _merge2.default)({ 'default': { picker: { background: '#DCDCDC', borderRadius: '4px', boxShadow: '0 0 0 1px rgba(0,0,0,.25), 0 8px 16px rgba(0,0,0,.15)', boxSizing: 'initial', width: '513px' }, head: { backgroundImage: 'linear-gradient(-180deg, #F0F0F0 0%, #D4D4D4 100%)', borderBottom: '1px solid #B1B1B1', boxShadow: 'inset 0 1px 0 0 rgba(255,255,255,.2), inset 0 -1px 0 0 rgba(0,0,0,.02)', height: '23px', lineHeight: '24px', borderRadius: '4px 4px 0 0', fontSize: '13px', color: '#4D4D4D', textAlign: 'center' }, body: { padding: '15px 15px 0', display: 'flex' }, saturation: { width: '256px', height: '256px', position: 'relative', border: '2px solid #B3B3B3', borderBottom: '2px solid #F0F0F0', overflow: 'hidden' }, hue: { position: 'relative', height: '256px', width: '19px', marginLeft: '10px', border: '2px solid #B3B3B3', borderBottom: '2px solid #F0F0F0' }, controls: { width: '180px', marginLeft: '10px' }, top: { display: 'flex' }, previews: { width: '60px' }, actions: { flex: '1', marginLeft: '20px' } } }, passedStyles)); return _react2.default.createElement( 'div', { style: styles.picker, className: 'photoshop-picker ' + className }, _react2.default.createElement( 'div', { style: styles.head }, this.props.header ), _react2.default.createElement( 'div', { style: styles.body, className: 'flexbox-fix' }, _react2.default.createElement( 'div', { style: styles.saturation }, _react2.default.createElement(_common.Saturation, { hsl: this.props.hsl, hsv: this.props.hsv, pointer: _PhotoshopPointerCircle2.default, onChange: this.props.onChange }) ), _react2.default.createElement( 'div', { style: styles.hue }, _react2.default.createElement(_common.Hue, { direction: 'vertical', hsl: this.props.hsl, pointer: _PhotoshopPointer2.default, onChange: this.props.onChange }) ), _react2.default.createElement( 'div', { style: styles.controls }, _react2.default.createElement( 'div', { style: styles.top, className: 'flexbox-fix' }, _react2.default.createElement( 'div', { style: styles.previews }, _react2.default.createElement(_PhotoshopPreviews2.default, { rgb: this.props.rgb, currentColor: this.state.currentColor }) ), _react2.default.createElement( 'div', { style: styles.actions }, _react2.default.createElement(_PhotoshopButton2.default, { label: 'OK', onClick: this.props.onAccept, active: true }), _react2.default.createElement(_PhotoshopButton2.default, { label: 'Cancel', onClick: this.props.onCancel }), _react2.default.createElement(_PhotoshopFields2.default, { onChange: this.props.onChange, rgb: this.props.rgb, hsv: this.props.hsv, hex: this.props.hex }) ) ) ) ) ); } }]); return Photoshop; }(_react2.default.Component); Photoshop.propTypes = { header: _propTypes2.default.string, styles: _propTypes2.default.object }; Photoshop.defaultProps = { header: 'Color Picker', styles: {} }; exports.default = (0, _common.ColorWrap)(Photoshop); },{"../common":329,"./PhotoshopButton":343,"./PhotoshopFields":344,"./PhotoshopPointer":345,"./PhotoshopPointerCircle":346,"./PhotoshopPreviews":347,"lodash/merge":295,"prop-types":309,"react":"react","reactcss":374}],343:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.PhotoshopButton = undefined; var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _reactcss = require('reactcss'); var _reactcss2 = _interopRequireDefault(_reactcss); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var PhotoshopButton = exports.PhotoshopButton = function PhotoshopButton(_ref) { var onClick = _ref.onClick, label = _ref.label, children = _ref.children, active = _ref.active; var styles = (0, _reactcss2.default)({ 'default': { button: { backgroundImage: 'linear-gradient(-180deg, #FFFFFF 0%, #E6E6E6 100%)', border: '1px solid #878787', borderRadius: '2px', height: '20px', boxShadow: '0 1px 0 0 #EAEAEA', fontSize: '14px', color: '#000', lineHeight: '20px', textAlign: 'center', marginBottom: '10px', cursor: 'pointer' } }, 'active': { button: { boxShadow: '0 0 0 1px #878787' } } }, { active: active }); return _react2.default.createElement( 'div', { style: styles.button, onClick: onClick }, label || children ); }; exports.default = PhotoshopButton; },{"react":"react","reactcss":374}],344:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.PhotoshopPicker = undefined; var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _reactcss = require('reactcss'); var _reactcss2 = _interopRequireDefault(_reactcss); var _color = require('../../helpers/color'); var color = _interopRequireWildcard(_color); var _common = require('../common'); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var PhotoshopPicker = exports.PhotoshopPicker = function PhotoshopPicker(_ref) { var onChange = _ref.onChange, rgb = _ref.rgb, hsv = _ref.hsv, hex = _ref.hex; var styles = (0, _reactcss2.default)({ 'default': { fields: { paddingTop: '5px', paddingBottom: '9px', width: '80px', position: 'relative' }, divider: { height: '5px' }, RGBwrap: { position: 'relative' }, RGBinput: { marginLeft: '40%', width: '40%', height: '18px', border: '1px solid #888888', boxShadow: 'inset 0 1px 1px rgba(0,0,0,.1), 0 1px 0 0 #ECECEC', marginBottom: '5px', fontSize: '13px', paddingLeft: '3px', marginRight: '10px' }, RGBlabel: { left: '0px', top: '0px', width: '34px', textTransform: 'uppercase', fontSize: '13px', height: '18px', lineHeight: '22px', position: 'absolute' }, HEXwrap: { position: 'relative' }, HEXinput: { marginLeft: '20%', width: '80%', height: '18px', border: '1px solid #888888', boxShadow: 'inset 0 1px 1px rgba(0,0,0,.1), 0 1px 0 0 #ECECEC', marginBottom: '6px', fontSize: '13px', paddingLeft: '3px' }, HEXlabel: { position: 'absolute', top: '0px', left: '0px', width: '14px', textTransform: 'uppercase', fontSize: '13px', height: '18px', lineHeight: '22px' }, fieldSymbols: { position: 'absolute', top: '5px', right: '-7px', fontSize: '13px' }, symbol: { height: '20px', lineHeight: '22px', paddingBottom: '7px' } } }); var handleChange = function handleChange(data, e) { if (data['#']) { color.isValidHex(data['#']) && onChange({ hex: data['#'], source: 'hex' }, e); } else if (data.r || data.g || data.b) { onChange({ r: data.r || rgb.r, g: data.g || rgb.g, b: data.b || rgb.b, source: 'rgb' }, e); } else if (data.h || data.s || data.v) { onChange({ h: data.h || hsv.h, s: data.s || hsv.s, v: data.v || hsv.v, source: 'hsv' }, e); } }; return _react2.default.createElement( 'div', { style: styles.fields }, _react2.default.createElement(_common.EditableInput, { style: { wrap: styles.RGBwrap, input: styles.RGBinput, label: styles.RGBlabel }, label: 'h', value: Math.round(hsv.h), onChange: handleChange }), _react2.default.createElement(_common.EditableInput, { style: { wrap: styles.RGBwrap, input: styles.RGBinput, label: styles.RGBlabel }, label: 's', value: Math.round(hsv.s * 100), onChange: handleChange }), _react2.default.createElement(_common.EditableInput, { style: { wrap: styles.RGBwrap, input: styles.RGBinput, label: styles.RGBlabel }, label: 'v', value: Math.round(hsv.v * 100), onChange: handleChange }), _react2.default.createElement('div', { style: styles.divider }), _react2.default.createElement(_common.EditableInput, { style: { wrap: styles.RGBwrap, input: styles.RGBinput, label: styles.RGBlabel }, label: 'r', value: rgb.r, onChange: handleChange }), _react2.default.createElement(_common.EditableInput, { style: { wrap: styles.RGBwrap, input: styles.RGBinput, label: styles.RGBlabel }, label: 'g', value: rgb.g, onChange: handleChange }), _react2.default.createElement(_common.EditableInput, { style: { wrap: styles.RGBwrap, input: styles.RGBinput, label: styles.RGBlabel }, label: 'b', value: rgb.b, onChange: handleChange }), _react2.default.createElement('div', { style: styles.divider }), _react2.default.createElement(_common.EditableInput, { style: { wrap: styles.HEXwrap, input: styles.HEXinput, label: styles.HEXlabel }, label: '#', value: hex.replace('#', ''), onChange: handleChange }), _react2.default.createElement( 'div', { style: styles.fieldSymbols }, _react2.default.createElement( 'div', { style: styles.symbol }, '\xB0' ), _react2.default.createElement( 'div', { style: styles.symbol }, '%' ), _react2.default.createElement( 'div', { style: styles.symbol }, '%' ) ) ); }; exports.default = PhotoshopPicker; },{"../../helpers/color":361,"../common":329,"react":"react","reactcss":374}],345:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.PhotoshopPointerCircle = undefined; var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _reactcss = require('reactcss'); var _reactcss2 = _interopRequireDefault(_reactcss); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var PhotoshopPointerCircle = exports.PhotoshopPointerCircle = function PhotoshopPointerCircle() { var styles = (0, _reactcss2.default)({ 'default': { triangle: { width: 0, height: 0, borderStyle: 'solid', borderWidth: '4px 0 4px 6px', borderColor: 'transparent transparent transparent #fff', position: 'absolute', top: '1px', left: '1px' }, triangleBorder: { width: 0, height: 0, borderStyle: 'solid', borderWidth: '5px 0 5px 8px', borderColor: 'transparent transparent transparent #555' }, left: { Extend: 'triangleBorder', transform: 'translate(-13px, -4px)' }, leftInside: { Extend: 'triangle', transform: 'translate(-8px, -5px)' }, right: { Extend: 'triangleBorder', transform: 'translate(20px, -14px) rotate(180deg)' }, rightInside: { Extend: 'triangle', transform: 'translate(-8px, -5px)' } } }); return _react2.default.createElement( 'div', { style: styles.pointer }, _react2.default.createElement( 'div', { style: styles.left }, _react2.default.createElement('div', { style: styles.leftInside }) ), _react2.default.createElement( 'div', { style: styles.right }, _react2.default.createElement('div', { style: styles.rightInside }) ) ); }; exports.default = PhotoshopPointerCircle; },{"react":"react","reactcss":374}],346:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.PhotoshopPointerCircle = undefined; var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _reactcss = require('reactcss'); var _reactcss2 = _interopRequireDefault(_reactcss); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var PhotoshopPointerCircle = exports.PhotoshopPointerCircle = function PhotoshopPointerCircle(_ref) { var hsl = _ref.hsl; var styles = (0, _reactcss2.default)({ 'default': { picker: { width: '12px', height: '12px', borderRadius: '6px', boxShadow: 'inset 0 0 0 1px #fff', transform: 'translate(-6px, -6px)' } }, 'black-outline': { picker: { boxShadow: 'inset 0 0 0 1px #000' } } }, { 'black-outline': hsl.l > 0.5 }); return _react2.default.createElement('div', { style: styles.picker }); }; exports.default = PhotoshopPointerCircle; },{"react":"react","reactcss":374}],347:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.PhotoshopPreviews = undefined; var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _reactcss = require('reactcss'); var _reactcss2 = _interopRequireDefault(_reactcss); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var PhotoshopPreviews = exports.PhotoshopPreviews = function PhotoshopPreviews(_ref) { var rgb = _ref.rgb, currentColor = _ref.currentColor; var styles = (0, _reactcss2.default)({ 'default': { swatches: { border: '1px solid #B3B3B3', borderBottom: '1px solid #F0F0F0', marginBottom: '2px', marginTop: '1px' }, new: { height: '34px', background: 'rgb(' + rgb.r + ',' + rgb.g + ', ' + rgb.b + ')', boxShadow: 'inset 1px 0 0 #000, inset -1px 0 0 #000, inset 0 1px 0 #000' }, current: { height: '34px', background: currentColor, boxShadow: 'inset 1px 0 0 #000, inset -1px 0 0 #000, inset 0 -1px 0 #000' }, label: { fontSize: '14px', color: '#000', textAlign: 'center' } } }); return _react2.default.createElement( 'div', null, _react2.default.createElement( 'div', { style: styles.label }, 'new' ), _react2.default.createElement( 'div', { style: styles.swatches }, _react2.default.createElement('div', { style: styles.new }), _react2.default.createElement('div', { style: styles.current }) ), _react2.default.createElement( 'div', { style: styles.label }, 'current' ) ); }; exports.default = PhotoshopPreviews; },{"react":"react","reactcss":374}],348:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.Sketch = undefined; var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _propTypes = require('prop-types'); var _propTypes2 = _interopRequireDefault(_propTypes); var _reactcss = require('reactcss'); var _reactcss2 = _interopRequireDefault(_reactcss); var _merge = require('lodash/merge'); var _merge2 = _interopRequireDefault(_merge); var _common = require('../common'); var _SketchFields = require('./SketchFields'); var _SketchFields2 = _interopRequireDefault(_SketchFields); var _SketchPresetColors = require('./SketchPresetColors'); var _SketchPresetColors2 = _interopRequireDefault(_SketchPresetColors); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var Sketch = exports.Sketch = function Sketch(_ref) { var width = _ref.width, rgb = _ref.rgb, hex = _ref.hex, hsv = _ref.hsv, hsl = _ref.hsl, onChange = _ref.onChange, onSwatchHover = _ref.onSwatchHover, disableAlpha = _ref.disableAlpha, presetColors = _ref.presetColors, renderers = _ref.renderers, _ref$styles = _ref.styles, passedStyles = _ref$styles === undefined ? {} : _ref$styles, _ref$className = _ref.className, className = _ref$className === undefined ? '' : _ref$className; var styles = (0, _reactcss2.default)((0, _merge2.default)({ 'default': _extends({ picker: { width: width, padding: '10px 10px 0', boxSizing: 'initial', background: '#fff', borderRadius: '4px', boxShadow: '0 0 0 1px rgba(0,0,0,.15), 0 8px 16px rgba(0,0,0,.15)' }, saturation: { width: '100%', paddingBottom: '75%', position: 'relative', overflow: 'hidden' }, Saturation: { radius: '3px', shadow: 'inset 0 0 0 1px rgba(0,0,0,.15), inset 0 0 4px rgba(0,0,0,.25)' }, controls: { display: 'flex' }, sliders: { padding: '4px 0', flex: '1' }, color: { width: '24px', height: '24px', position: 'relative', marginTop: '4px', marginLeft: '4px', borderRadius: '3px' }, activeColor: { absolute: '0px 0px 0px 0px', borderRadius: '2px', background: 'rgba(' + rgb.r + ',' + rgb.g + ',' + rgb.b + ',' + rgb.a + ')', boxShadow: 'inset 0 0 0 1px rgba(0,0,0,.15), inset 0 0 4px rgba(0,0,0,.25)' }, hue: { position: 'relative', height: '10px', overflow: 'hidden' }, Hue: { radius: '2px', shadow: 'inset 0 0 0 1px rgba(0,0,0,.15), inset 0 0 4px rgba(0,0,0,.25)' }, alpha: { position: 'relative', height: '10px', marginTop: '4px', overflow: 'hidden' }, Alpha: { radius: '2px', shadow: 'inset 0 0 0 1px rgba(0,0,0,.15), inset 0 0 4px rgba(0,0,0,.25)' } }, passedStyles), 'disableAlpha': { color: { height: '10px' }, hue: { height: '10px' }, alpha: { display: 'none' } } }, passedStyles), { disableAlpha: disableAlpha }); return _react2.default.createElement( 'div', { style: styles.picker, className: 'sketch-picker ' + className }, _react2.default.createElement( 'div', { style: styles.saturation }, _react2.default.createElement(_common.Saturation, { style: styles.Saturation, hsl: hsl, hsv: hsv, onChange: onChange }) ), _react2.default.createElement( 'div', { style: styles.controls, className: 'flexbox-fix' }, _react2.default.createElement( 'div', { style: styles.sliders }, _react2.default.createElement( 'div', { style: styles.hue }, _react2.default.createElement(_common.Hue, { style: styles.Hue, hsl: hsl, onChange: onChange }) ), _react2.default.createElement( 'div', { style: styles.alpha }, _react2.default.createElement(_common.Alpha, { style: styles.Alpha, rgb: rgb, hsl: hsl, renderers: renderers, onChange: onChange }) ) ), _react2.default.createElement( 'div', { style: styles.color }, _react2.default.createElement(_common.Checkboard, null), _react2.default.createElement('div', { style: styles.activeColor }) ) ), _react2.default.createElement(_SketchFields2.default, { rgb: rgb, hsl: hsl, hex: hex, onChange: onChange, disableAlpha: disableAlpha }), _react2.default.createElement(_SketchPresetColors2.default, { colors: presetColors, onClick: onChange, onSwatchHover: onSwatchHover }) ); }; Sketch.propTypes = { disableAlpha: _propTypes2.default.bool, width: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.number]), styles: _propTypes2.default.object }; Sketch.defaultProps = { disableAlpha: false, width: 200, styles: {}, presetColors: ['#D0021B', '#F5A623', '#F8E71C', '#8B572A', '#7ED321', '#417505', '#BD10E0', '#9013FE', '#4A90E2', '#50E3C2', '#B8E986', '#000000', '#4A4A4A', '#9B9B9B', '#FFFFFF'] }; exports.default = (0, _common.ColorWrap)(Sketch); },{"../common":329,"./SketchFields":349,"./SketchPresetColors":350,"lodash/merge":295,"prop-types":309,"react":"react","reactcss":374}],349:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.SketchFields = undefined; var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _reactcss = require('reactcss'); var _reactcss2 = _interopRequireDefault(_reactcss); var _color = require('../../helpers/color'); var color = _interopRequireWildcard(_color); var _common = require('../common'); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /* eslint-disable no-param-reassign */ var SketchFields = exports.SketchFields = function SketchFields(_ref) { var onChange = _ref.onChange, rgb = _ref.rgb, hsl = _ref.hsl, hex = _ref.hex, disableAlpha = _ref.disableAlpha; var styles = (0, _reactcss2.default)({ 'default': { fields: { display: 'flex', paddingTop: '4px' }, single: { flex: '1', paddingLeft: '6px' }, alpha: { flex: '1', paddingLeft: '6px' }, double: { flex: '2' }, input: { width: '80%', padding: '4px 10% 3px', border: 'none', boxShadow: 'inset 0 0 0 1px #ccc', fontSize: '11px' }, label: { display: 'block', textAlign: 'center', fontSize: '11px', color: '#222', paddingTop: '3px', paddingBottom: '4px', textTransform: 'capitalize' } }, 'disableAlpha': { alpha: { display: 'none' } } }, { disableAlpha: disableAlpha }); var handleChange = function handleChange(data, e) { if (data.hex) { color.isValidHex(data.hex) && onChange({ hex: data.hex, source: 'hex' }, e); } else if (data.r || data.g || data.b) { onChange({ r: data.r || rgb.r, g: data.g || rgb.g, b: data.b || rgb.b, a: rgb.a, source: 'rgb' }, e); } else if (data.a) { if (data.a < 0) { data.a = 0; } else if (data.a > 100) { data.a = 100; } data.a /= 100; onChange({ h: hsl.h, s: hsl.s, l: hsl.l, a: data.a, source: 'rgb' }, e); } }; return _react2.default.createElement( 'div', { style: styles.fields, className: 'flexbox-fix' }, _react2.default.createElement( 'div', { style: styles.double }, _react2.default.createElement(_common.EditableInput, { style: { input: styles.input, label: styles.label }, label: 'hex', value: hex.replace('#', ''), onChange: handleChange }) ), _react2.default.createElement( 'div', { style: styles.single }, _react2.default.createElement(_common.EditableInput, { style: { input: styles.input, label: styles.label }, label: 'r', value: rgb.r, onChange: handleChange, dragLabel: 'true', dragMax: '255' }) ), _react2.default.createElement( 'div', { style: styles.single }, _react2.default.createElement(_common.EditableInput, { style: { input: styles.input, label: styles.label }, label: 'g', value: rgb.g, onChange: handleChange, dragLabel: 'true', dragMax: '255' }) ), _react2.default.createElement( 'div', { style: styles.single }, _react2.default.createElement(_common.EditableInput, { style: { input: styles.input, label: styles.label }, label: 'b', value: rgb.b, onChange: handleChange, dragLabel: 'true', dragMax: '255' }) ), _react2.default.createElement( 'div', { style: styles.alpha }, _react2.default.createElement(_common.EditableInput, { style: { input: styles.input, label: styles.label }, label: 'a', value: Math.round(rgb.a * 100), onChange: handleChange, dragLabel: 'true', dragMax: '100' }) ) ); }; exports.default = SketchFields; },{"../../helpers/color":361,"../common":329,"react":"react","reactcss":374}],350:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.SketchPresetColors = undefined; var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _propTypes = require('prop-types'); var _propTypes2 = _interopRequireDefault(_propTypes); var _reactcss = require('reactcss'); var _reactcss2 = _interopRequireDefault(_reactcss); var _common = require('../common'); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var SketchPresetColors = exports.SketchPresetColors = function SketchPresetColors(_ref) { var colors = _ref.colors, _ref$onClick = _ref.onClick, onClick = _ref$onClick === undefined ? function () {} : _ref$onClick, onSwatchHover = _ref.onSwatchHover; var styles = (0, _reactcss2.default)({ 'default': { colors: { margin: '0 -10px', padding: '10px 0 0 10px', borderTop: '1px solid #eee', display: 'flex', flexWrap: 'wrap', position: 'relative' }, swatchWrap: { width: '16px', height: '16px', margin: '0 10px 10px 0' }, swatch: { borderRadius: '3px', boxShadow: 'inset 0 0 0 1px rgba(0,0,0,.15)' } }, 'no-presets': { colors: { display: 'none' } } }, { 'no-presets': !colors || !colors.length }); var handleClick = function handleClick(hex, e) { onClick({ hex: hex, source: 'hex' }, e); }; return _react2.default.createElement( 'div', { style: styles.colors, className: 'flexbox-fix' }, colors.map(function (colorObjOrString) { var c = typeof colorObjOrString === 'string' ? { color: colorObjOrString } : colorObjOrString; var key = '' + c.color + (c.title || ''); return _react2.default.createElement( 'div', { key: key, style: styles.swatchWrap }, _react2.default.createElement(_common.Swatch, _extends({}, c, { style: styles.swatch, onClick: handleClick, onHover: onSwatchHover, focusStyle: { boxShadow: 'inset 0 0 0 1px rgba(0,0,0,.15), 0 0 4px ' + c.color } })) ); }) ); }; SketchPresetColors.propTypes = { colors: _propTypes2.default.arrayOf(_propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.shape({ color: _propTypes2.default.string, title: _propTypes2.default.string })])).isRequired }; exports.default = SketchPresetColors; },{"../common":329,"prop-types":309,"react":"react","reactcss":374}],351:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.Slider = undefined; var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _propTypes = require('prop-types'); var _propTypes2 = _interopRequireDefault(_propTypes); var _reactcss = require('reactcss'); var _reactcss2 = _interopRequireDefault(_reactcss); var _merge = require('lodash/merge'); var _merge2 = _interopRequireDefault(_merge); var _common = require('../common'); var _SliderSwatches = require('./SliderSwatches'); var _SliderSwatches2 = _interopRequireDefault(_SliderSwatches); var _SliderPointer = require('./SliderPointer'); var _SliderPointer2 = _interopRequireDefault(_SliderPointer); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var Slider = exports.Slider = function Slider(_ref) { var hsl = _ref.hsl, onChange = _ref.onChange, pointer = _ref.pointer, _ref$styles = _ref.styles, passedStyles = _ref$styles === undefined ? {} : _ref$styles, _ref$className = _ref.className, className = _ref$className === undefined ? '' : _ref$className; var styles = (0, _reactcss2.default)((0, _merge2.default)({ 'default': { hue: { height: '12px', position: 'relative' }, Hue: { radius: '2px' } } }, passedStyles)); return _react2.default.createElement( 'div', { style: styles.wrap || {}, className: 'slider-picker ' + className }, _react2.default.createElement( 'div', { style: styles.hue }, _react2.default.createElement(_common.Hue, { style: styles.Hue, hsl: hsl, pointer: pointer, onChange: onChange }) ), _react2.default.createElement( 'div', { style: styles.swatches }, _react2.default.createElement(_SliderSwatches2.default, { hsl: hsl, onClick: onChange }) ) ); }; Slider.propTypes = { styles: _propTypes2.default.object }; Slider.defaultProps = { pointer: _SliderPointer2.default, styles: {} }; exports.default = (0, _common.ColorWrap)(Slider); },{"../common":329,"./SliderPointer":352,"./SliderSwatches":354,"lodash/merge":295,"prop-types":309,"react":"react","reactcss":374}],352:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.SliderPointer = undefined; var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _reactcss = require('reactcss'); var _reactcss2 = _interopRequireDefault(_reactcss); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var SliderPointer = exports.SliderPointer = function SliderPointer() { var styles = (0, _reactcss2.default)({ 'default': { picker: { width: '14px', height: '14px', borderRadius: '6px', transform: 'translate(-7px, -1px)', backgroundColor: 'rgb(248, 248, 248)', boxShadow: '0 1px 4px 0 rgba(0, 0, 0, 0.37)' } } }); return _react2.default.createElement('div', { style: styles.picker }); }; exports.default = SliderPointer; },{"react":"react","reactcss":374}],353:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.SliderSwatch = undefined; var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _reactcss = require('reactcss'); var _reactcss2 = _interopRequireDefault(_reactcss); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var SliderSwatch = exports.SliderSwatch = function SliderSwatch(_ref) { var hsl = _ref.hsl, offset = _ref.offset, _ref$onClick = _ref.onClick, onClick = _ref$onClick === undefined ? function () {} : _ref$onClick, active = _ref.active, first = _ref.first, last = _ref.last; var styles = (0, _reactcss2.default)({ 'default': { swatch: { height: '12px', background: 'hsl(' + hsl.h + ', 50%, ' + offset * 100 + '%)', cursor: 'pointer' } }, 'first': { swatch: { borderRadius: '2px 0 0 2px' } }, 'last': { swatch: { borderRadius: '0 2px 2px 0' } }, 'active': { swatch: { transform: 'scaleY(1.8)', borderRadius: '3.6px/2px' } } }, { active: active, first: first, last: last }); var handleClick = function handleClick(e) { return onClick({ h: hsl.h, s: 0.5, l: offset, source: 'hsl' }, e); }; return _react2.default.createElement('div', { style: styles.swatch, onClick: handleClick }); }; exports.default = SliderSwatch; },{"react":"react","reactcss":374}],354:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.SliderSwatches = undefined; var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _reactcss = require('reactcss'); var _reactcss2 = _interopRequireDefault(_reactcss); var _SliderSwatch = require('./SliderSwatch'); var _SliderSwatch2 = _interopRequireDefault(_SliderSwatch); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var SliderSwatches = exports.SliderSwatches = function SliderSwatches(_ref) { var onClick = _ref.onClick, hsl = _ref.hsl; var styles = (0, _reactcss2.default)({ 'default': { swatches: { marginTop: '20px' }, swatch: { boxSizing: 'border-box', width: '20%', paddingRight: '1px', float: 'left' }, clear: { clear: 'both' } } }); // Acceptible difference in floating point equality var epsilon = 0.1; return _react2.default.createElement( 'div', { style: styles.swatches }, _react2.default.createElement( 'div', { style: styles.swatch }, _react2.default.createElement(_SliderSwatch2.default, { hsl: hsl, offset: '.80', active: Math.abs(hsl.l - 0.80) < epsilon && Math.abs(hsl.s - 0.50) < epsilon, onClick: onClick, first: true }) ), _react2.default.createElement( 'div', { style: styles.swatch }, _react2.default.createElement(_SliderSwatch2.default, { hsl: hsl, offset: '.65', active: Math.abs(hsl.l - 0.65) < epsilon && Math.abs(hsl.s - 0.50) < epsilon, onClick: onClick }) ), _react2.default.createElement( 'div', { style: styles.swatch }, _react2.default.createElement(_SliderSwatch2.default, { hsl: hsl, offset: '.50', active: Math.abs(hsl.l - 0.50) < epsilon && Math.abs(hsl.s - 0.50) < epsilon, onClick: onClick }) ), _react2.default.createElement( 'div', { style: styles.swatch }, _react2.default.createElement(_SliderSwatch2.default, { hsl: hsl, offset: '.35', active: Math.abs(hsl.l - 0.35) < epsilon && Math.abs(hsl.s - 0.50) < epsilon, onClick: onClick }) ), _react2.default.createElement( 'div', { style: styles.swatch }, _react2.default.createElement(_SliderSwatch2.default, { hsl: hsl, offset: '.20', active: Math.abs(hsl.l - 0.20) < epsilon && Math.abs(hsl.s - 0.50) < epsilon, onClick: onClick, last: true }) ), _react2.default.createElement('div', { style: styles.clear }) ); }; exports.default = SliderSwatches; },{"./SliderSwatch":353,"react":"react","reactcss":374}],355:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.Swatches = undefined; var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _propTypes = require('prop-types'); var _propTypes2 = _interopRequireDefault(_propTypes); var _reactcss = require('reactcss'); var _reactcss2 = _interopRequireDefault(_reactcss); var _map = require('lodash/map'); var _map2 = _interopRequireDefault(_map); var _merge = require('lodash/merge'); var _merge2 = _interopRequireDefault(_merge); var _materialColors = require('material-colors'); var material = _interopRequireWildcard(_materialColors); var _common = require('../common'); var _SwatchesGroup = require('./SwatchesGroup'); var _SwatchesGroup2 = _interopRequireDefault(_SwatchesGroup); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var Swatches = exports.Swatches = function Swatches(_ref) { var width = _ref.width, height = _ref.height, onChange = _ref.onChange, onSwatchHover = _ref.onSwatchHover, colors = _ref.colors, hex = _ref.hex, _ref$styles = _ref.styles, passedStyles = _ref$styles === undefined ? {} : _ref$styles, _ref$className = _ref.className, className = _ref$className === undefined ? '' : _ref$className; var styles = (0, _reactcss2.default)((0, _merge2.default)({ 'default': { picker: { width: width, height: height }, overflow: { height: height, overflowY: 'scroll' }, body: { padding: '16px 0 6px 16px' }, clear: { clear: 'both' } } }, passedStyles)); var handleChange = function handleChange(data, e) { return onChange({ hex: data, source: 'hex' }, e); }; return _react2.default.createElement( 'div', { style: styles.picker, className: 'swatches-picker ' + className }, _react2.default.createElement( _common.Raised, null, _react2.default.createElement( 'div', { style: styles.overflow }, _react2.default.createElement( 'div', { style: styles.body }, (0, _map2.default)(colors, function (group) { return _react2.default.createElement(_SwatchesGroup2.default, { key: group.toString(), group: group, active: hex, onClick: handleChange, onSwatchHover: onSwatchHover }); }), _react2.default.createElement('div', { style: styles.clear }) ) ) ) ); }; Swatches.propTypes = { width: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.number]), height: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.number]), colors: _propTypes2.default.arrayOf(_propTypes2.default.arrayOf(_propTypes2.default.string)), styles: _propTypes2.default.object /* eslint-disable max-len */ };Swatches.defaultProps = { width: 320, height: 240, colors: [[material.red['900'], material.red['700'], material.red['500'], material.red['300'], material.red['100']], [material.pink['900'], material.pink['700'], material.pink['500'], material.pink['300'], material.pink['100']], [material.purple['900'], material.purple['700'], material.purple['500'], material.purple['300'], material.purple['100']], [material.deepPurple['900'], material.deepPurple['700'], material.deepPurple['500'], material.deepPurple['300'], material.deepPurple['100']], [material.indigo['900'], material.indigo['700'], material.indigo['500'], material.indigo['300'], material.indigo['100']], [material.blue['900'], material.blue['700'], material.blue['500'], material.blue['300'], material.blue['100']], [material.lightBlue['900'], material.lightBlue['700'], material.lightBlue['500'], material.lightBlue['300'], material.lightBlue['100']], [material.cyan['900'], material.cyan['700'], material.cyan['500'], material.cyan['300'], material.cyan['100']], [material.teal['900'], material.teal['700'], material.teal['500'], material.teal['300'], material.teal['100']], ['#194D33', material.green['700'], material.green['500'], material.green['300'], material.green['100']], [material.lightGreen['900'], material.lightGreen['700'], material.lightGreen['500'], material.lightGreen['300'], material.lightGreen['100']], [material.lime['900'], material.lime['700'], material.lime['500'], material.lime['300'], material.lime['100']], [material.yellow['900'], material.yellow['700'], material.yellow['500'], material.yellow['300'], material.yellow['100']], [material.amber['900'], material.amber['700'], material.amber['500'], material.amber['300'], material.amber['100']], [material.orange['900'], material.orange['700'], material.orange['500'], material.orange['300'], material.orange['100']], [material.deepOrange['900'], material.deepOrange['700'], material.deepOrange['500'], material.deepOrange['300'], material.deepOrange['100']], [material.brown['900'], material.brown['700'], material.brown['500'], material.brown['300'], material.brown['100']], [material.blueGrey['900'], material.blueGrey['700'], material.blueGrey['500'], material.blueGrey['300'], material.blueGrey['100']], ['#000000', '#525252', '#969696', '#D9D9D9', '#FFFFFF']], styles: {} }; exports.default = (0, _common.ColorWrap)(Swatches); },{"../common":329,"./SwatchesGroup":357,"lodash/map":293,"lodash/merge":295,"material-colors":304,"prop-types":309,"react":"react","reactcss":374}],356:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.SwatchesColor = undefined; var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _reactcss = require('reactcss'); var _reactcss2 = _interopRequireDefault(_reactcss); var _color = require('../../helpers/color'); var colorUtils = _interopRequireWildcard(_color); var _common = require('../common'); var _CheckIcon = require('@icons/material/CheckIcon'); var _CheckIcon2 = _interopRequireDefault(_CheckIcon); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var SwatchesColor = exports.SwatchesColor = function SwatchesColor(_ref) { var color = _ref.color, _ref$onClick = _ref.onClick, onClick = _ref$onClick === undefined ? function () {} : _ref$onClick, onSwatchHover = _ref.onSwatchHover, first = _ref.first, last = _ref.last, active = _ref.active; var styles = (0, _reactcss2.default)({ 'default': { color: { width: '40px', height: '24px', cursor: 'pointer', background: color, marginBottom: '1px' }, check: { color: colorUtils.getContrastingColor(color), marginLeft: '8px', display: 'none' } }, 'first': { color: { overflow: 'hidden', borderRadius: '2px 2px 0 0' } }, 'last': { color: { overflow: 'hidden', borderRadius: '0 0 2px 2px' } }, 'active': { check: { display: 'block' } }, 'color-#FFFFFF': { color: { boxShadow: 'inset 0 0 0 1px #ddd' }, check: { color: '#333' } }, 'transparent': { check: { color: '#333' } } }, { first: first, last: last, active: active, 'color-#FFFFFF': color === '#FFFFFF', 'transparent': color === 'transparent' }); return _react2.default.createElement( _common.Swatch, { color: color, style: styles.color, onClick: onClick, onHover: onSwatchHover, focusStyle: { boxShadow: '0 0 4px ' + color } }, _react2.default.createElement( 'div', { style: styles.check }, _react2.default.createElement(_CheckIcon2.default, null) ) ); }; exports.default = SwatchesColor; },{"../../helpers/color":361,"../common":329,"@icons/material/CheckIcon":96,"react":"react","reactcss":374}],357:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.SwatchesGroup = undefined; var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _reactcss = require('reactcss'); var _reactcss2 = _interopRequireDefault(_reactcss); var _map = require('lodash/map'); var _map2 = _interopRequireDefault(_map); var _SwatchesColor = require('./SwatchesColor'); var _SwatchesColor2 = _interopRequireDefault(_SwatchesColor); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var SwatchesGroup = exports.SwatchesGroup = function SwatchesGroup(_ref) { var onClick = _ref.onClick, onSwatchHover = _ref.onSwatchHover, group = _ref.group, active = _ref.active; var styles = (0, _reactcss2.default)({ 'default': { group: { paddingBottom: '10px', width: '40px', float: 'left', marginRight: '10px' } } }); return _react2.default.createElement( 'div', { style: styles.group }, (0, _map2.default)(group, function (color, i) { return _react2.default.createElement(_SwatchesColor2.default, { key: color, color: color, active: color.toLowerCase() === active, first: i === 0, last: i === group.length - 1, onClick: onClick, onSwatchHover: onSwatchHover }); }) ); }; exports.default = SwatchesGroup; },{"./SwatchesColor":356,"lodash/map":293,"react":"react","reactcss":374}],358:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.Twitter = undefined; var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _propTypes = require('prop-types'); var _propTypes2 = _interopRequireDefault(_propTypes); var _reactcss = require('reactcss'); var _reactcss2 = _interopRequireDefault(_reactcss); var _map = require('lodash/map'); var _map2 = _interopRequireDefault(_map); var _merge = require('lodash/merge'); var _merge2 = _interopRequireDefault(_merge); var _color = require('../../helpers/color'); var color = _interopRequireWildcard(_color); var _common = require('../common'); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var Twitter = exports.Twitter = function Twitter(_ref) { var onChange = _ref.onChange, onSwatchHover = _ref.onSwatchHover, hex = _ref.hex, colors = _ref.colors, width = _ref.width, triangle = _ref.triangle, _ref$styles = _ref.styles, passedStyles = _ref$styles === undefined ? {} : _ref$styles, _ref$className = _ref.className, className = _ref$className === undefined ? '' : _ref$className; var styles = (0, _reactcss2.default)((0, _merge2.default)({ 'default': { card: { width: width, background: '#fff', border: '0 solid rgba(0,0,0,0.25)', boxShadow: '0 1px 4px rgba(0,0,0,0.25)', borderRadius: '4px', position: 'relative' }, body: { padding: '15px 9px 9px 15px' }, label: { fontSize: '18px', color: '#fff' }, triangle: { width: '0px', height: '0px', borderStyle: 'solid', borderWidth: '0 9px 10px 9px', borderColor: 'transparent transparent #fff transparent', position: 'absolute' }, triangleShadow: { width: '0px', height: '0px', borderStyle: 'solid', borderWidth: '0 9px 10px 9px', borderColor: 'transparent transparent rgba(0,0,0,.1) transparent', position: 'absolute' }, hash: { background: '#F0F0F0', height: '30px', width: '30px', borderRadius: '4px 0 0 4px', float: 'left', color: '#98A1A4', display: 'flex', alignItems: 'center', justifyContent: 'center' }, input: { width: '100px', fontSize: '14px', color: '#666', border: '0px', outline: 'none', height: '28px', boxShadow: 'inset 0 0 0 1px #F0F0F0', boxSizing: 'content-box', borderRadius: '0 4px 4px 0', float: 'left', paddingLeft: '8px' }, swatch: { width: '30px', height: '30px', float: 'left', borderRadius: '4px', margin: '0 6px 6px 0' }, clear: { clear: 'both' } }, 'hide-triangle': { triangle: { display: 'none' }, triangleShadow: { display: 'none' } }, 'top-left-triangle': { triangle: { top: '-10px', left: '12px' }, triangleShadow: { top: '-11px', left: '12px' } }, 'top-right-triangle': { triangle: { top: '-10px', right: '12px' }, triangleShadow: { top: '-11px', right: '12px' } } }, passedStyles), { 'hide-triangle': triangle === 'hide', 'top-left-triangle': triangle === 'top-left', 'top-right-triangle': triangle === 'top-right' }); var handleChange = function handleChange(hexcode, e) { color.isValidHex(hexcode) && onChange({ hex: hexcode, source: 'hex' }, e); }; return _react2.default.createElement( 'div', { style: styles.card, className: 'twitter-picker ' + className }, _react2.default.createElement('div', { style: styles.triangleShadow }), _react2.default.createElement('div', { style: styles.triangle }), _react2.default.createElement( 'div', { style: styles.body }, (0, _map2.default)(colors, function (c, i) { return _react2.default.createElement(_common.Swatch, { key: i, color: c, hex: c, style: styles.swatch, onClick: handleChange, onHover: onSwatchHover, focusStyle: { boxShadow: '0 0 4px ' + c } }); }), _react2.default.createElement( 'div', { style: styles.hash }, '#' ), _react2.default.createElement(_common.EditableInput, { label: null, style: { input: styles.input }, value: hex.replace('#', ''), onChange: handleChange }), _react2.default.createElement('div', { style: styles.clear }) ) ); }; Twitter.propTypes = { width: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.number]), triangle: _propTypes2.default.oneOf(['hide', 'top-left', 'top-right']), colors: _propTypes2.default.arrayOf(_propTypes2.default.string), styles: _propTypes2.default.object }; Twitter.defaultProps = { width: 276, colors: ['#FF6900', '#FCB900', '#7BDCB5', '#00D084', '#8ED1FC', '#0693E3', '#ABB8C3', '#EB144C', '#F78DA7', '#9900EF'], triangle: 'top-left', styles: {} }; exports.default = (0, _common.ColorWrap)(Twitter); },{"../../helpers/color":361,"../common":329,"lodash/map":293,"lodash/merge":295,"prop-types":309,"react":"react","reactcss":374}],359:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var calculateChange = exports.calculateChange = function calculateChange(e, hsl, direction, initialA, container) { var containerWidth = container.clientWidth; var containerHeight = container.clientHeight; var x = typeof e.pageX === 'number' ? e.pageX : e.touches[0].pageX; var y = typeof e.pageY === 'number' ? e.pageY : e.touches[0].pageY; var left = x - (container.getBoundingClientRect().left + window.pageXOffset); var top = y - (container.getBoundingClientRect().top + window.pageYOffset); if (direction === 'vertical') { var a = void 0; if (top < 0) { a = 0; } else if (top > containerHeight) { a = 1; } else { a = Math.round(top * 100 / containerHeight) / 100; } if (hsl.a !== a) { return { h: hsl.h, s: hsl.s, l: hsl.l, a: a, source: 'rgb' }; } } else { var _a = void 0; if (left < 0) { _a = 0; } else if (left > containerWidth) { _a = 1; } else { _a = Math.round(left * 100 / containerWidth) / 100; } if (initialA !== _a) { return { h: hsl.h, s: hsl.s, l: hsl.l, a: _a, source: 'rgb' }; } } return null; }; },{}],360:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var checkboardCache = {}; var render = exports.render = function render(c1, c2, size, serverCanvas) { if (typeof document === 'undefined' && !serverCanvas) { return null; } var canvas = serverCanvas ? new serverCanvas() : document.createElement('canvas'); canvas.width = size * 2; canvas.height = size * 2; var ctx = canvas.getContext('2d'); if (!ctx) { return null; } // If no context can be found, return early. ctx.fillStyle = c1; ctx.fillRect(0, 0, canvas.width, canvas.height); ctx.fillStyle = c2; ctx.fillRect(0, 0, size, size); ctx.translate(size, size); ctx.fillRect(0, 0, size, size); return canvas.toDataURL(); }; var get = exports.get = function get(c1, c2, size, serverCanvas) { var key = c1 + '-' + c2 + '-' + size + (serverCanvas ? '-server' : ''); if (checkboardCache[key]) { return checkboardCache[key]; } var checkboard = render(c1, c2, size, serverCanvas); checkboardCache[key] = checkboard; return checkboard; }; },{}],361:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.isvalidColorString = exports.red = exports.getContrastingColor = exports.isValidHex = exports.toState = exports.simpleCheckForValidColor = undefined; var _each = require('lodash/each'); var _each2 = _interopRequireDefault(_each); var _tinycolor = require('tinycolor2'); var _tinycolor2 = _interopRequireDefault(_tinycolor); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var simpleCheckForValidColor = exports.simpleCheckForValidColor = function simpleCheckForValidColor(data) { var keysToCheck = ['r', 'g', 'b', 'a', 'h', 's', 'l', 'v']; var checked = 0; var passed = 0; (0, _each2.default)(keysToCheck, function (letter) { if (data[letter]) { checked += 1; if (!isNaN(data[letter])) { passed += 1; } if (letter === 's' || letter === 'l') { var percentPatt = /^\d+%$/; if (percentPatt.test(data[letter])) { passed += 1; } } } }); return checked === passed ? data : false; }; var toState = exports.toState = function toState(data, oldHue) { var color = data.hex ? (0, _tinycolor2.default)(data.hex) : (0, _tinycolor2.default)(data); var hsl = color.toHsl(); var hsv = color.toHsv(); var rgb = color.toRgb(); var hex = color.toHex(); if (hsl.s === 0) { hsl.h = oldHue || 0; hsv.h = oldHue || 0; } var transparent = hex === '000000' && rgb.a === 0; return { hsl: hsl, hex: transparent ? 'transparent' : '#' + hex, rgb: rgb, hsv: hsv, oldHue: data.h || oldHue || hsl.h, source: data.source }; }; var isValidHex = exports.isValidHex = function isValidHex(hex) { if (hex === 'transparent') { return true; } // disable hex4 and hex8 var lh = String(hex).charAt(0) === '#' ? 1 : 0; return hex.length !== 4 + lh && hex.length < 7 + lh && (0, _tinycolor2.default)(hex).isValid(); }; var getContrastingColor = exports.getContrastingColor = function getContrastingColor(data) { if (!data) { return '#fff'; } var col = toState(data); if (col.hex === 'transparent') { return 'rgba(0,0,0,0.4)'; } var yiq = (col.rgb.r * 299 + col.rgb.g * 587 + col.rgb.b * 114) / 1000; return yiq >= 128 ? '#000' : '#fff'; }; var red = exports.red = { hsl: { a: 1, h: 0, l: 0.5, s: 1 }, hex: '#ff0000', rgb: { r: 255, g: 0, b: 0, a: 1 }, hsv: { h: 0, s: 1, v: 1, a: 1 } }; var isvalidColorString = exports.isvalidColorString = function isvalidColorString(string, type) { var stringWithoutDegree = string.replace('°', ''); return (0, _tinycolor2.default)(type + ' (' + stringWithoutDegree + ')')._ok; }; },{"lodash/each":268,"tinycolor2":378}],362:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var calculateChange = exports.calculateChange = function calculateChange(e, direction, hsl, container) { var containerWidth = container.clientWidth; var containerHeight = container.clientHeight; var x = typeof e.pageX === 'number' ? e.pageX : e.touches[0].pageX; var y = typeof e.pageY === 'number' ? e.pageY : e.touches[0].pageY; var left = x - (container.getBoundingClientRect().left + window.pageXOffset); var top = y - (container.getBoundingClientRect().top + window.pageYOffset); if (direction === 'vertical') { var h = void 0; if (top < 0) { h = 359; } else if (top > containerHeight) { h = 0; } else { var percent = -(top * 100 / containerHeight) + 100; h = 360 * percent / 100; } if (hsl.h !== h) { return { h: h, s: hsl.s, l: hsl.l, a: hsl.a, source: 'hsl' }; } } else { var _h = void 0; if (left < 0) { _h = 0; } else if (left > containerWidth) { _h = 359; } else { var _percent = left * 100 / containerWidth; _h = 360 * _percent / 100; } if (hsl.h !== _h) { return { h: _h, s: hsl.s, l: hsl.l, a: hsl.a, source: 'hsl' }; } } return null; }; },{}],363:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.handleFocus = undefined; var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _createClass = 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _react = require('react'); var _react2 = _interopRequireDefault(_react); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /* eslint-disable no-invalid-this */ var handleFocus = exports.handleFocus = function handleFocus(Component) { var Span = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'span'; return function (_React$Component) { _inherits(Focus, _React$Component); function Focus() { var _ref; var _temp, _this, _ret; _classCallCheck(this, Focus); for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Focus.__proto__ || Object.getPrototypeOf(Focus)).call.apply(_ref, [this].concat(args))), _this), _this.state = { focus: false }, _this.handleFocus = function () { return _this.setState({ focus: true }); }, _this.handleBlur = function () { return _this.setState({ focus: false }); }, _temp), _possibleConstructorReturn(_this, _ret); } _createClass(Focus, [{ key: 'render', value: function render() { return _react2.default.createElement( Span, { onFocus: this.handleFocus, onBlur: this.handleBlur }, _react2.default.createElement(Component, _extends({}, this.props, this.state)) ); } }]); return Focus; }(_react2.default.Component); }; },{"react":"react"}],364:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var calculateChange = exports.calculateChange = function calculateChange(e, hsl, container) { var _container$getBoundin = container.getBoundingClientRect(), containerWidth = _container$getBoundin.width, containerHeight = _container$getBoundin.height; var x = typeof e.pageX === 'number' ? e.pageX : e.touches[0].pageX; var y = typeof e.pageY === 'number' ? e.pageY : e.touches[0].pageY; var left = x - (container.getBoundingClientRect().left + window.pageXOffset); var top = y - (container.getBoundingClientRect().top + window.pageYOffset); if (left < 0) { left = 0; } else if (left > containerWidth) { left = containerWidth; } if (top < 0) { top = 0; } else if (top > containerHeight) { top = containerHeight; } var saturation = left / containerWidth; var bright = 1 - top / containerHeight; return { h: hsl.h, s: saturation, v: bright, a: hsl.a, source: 'hsv' }; }; },{}],365:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.CustomPicker = exports.GooglePicker = exports.TwitterPicker = exports.SwatchesPicker = exports.SliderPicker = exports.SketchPicker = exports.PhotoshopPicker = exports.MaterialPicker = exports.HuePicker = exports.GithubPicker = exports.CompactPicker = exports.ChromePicker = exports.default = exports.CirclePicker = exports.BlockPicker = exports.AlphaPicker = undefined; var _Alpha = require('./components/alpha/Alpha'); Object.defineProperty(exports, 'AlphaPicker', { enumerable: true, get: function get() { return _interopRequireDefault(_Alpha).default; } }); var _Block = require('./components/block/Block'); Object.defineProperty(exports, 'BlockPicker', { enumerable: true, get: function get() { return _interopRequireDefault(_Block).default; } }); var _Circle = require('./components/circle/Circle'); Object.defineProperty(exports, 'CirclePicker', { enumerable: true, get: function get() { return _interopRequireDefault(_Circle).default; } }); var _Chrome = require('./components/chrome/Chrome'); Object.defineProperty(exports, 'ChromePicker', { enumerable: true, get: function get() { return _interopRequireDefault(_Chrome).default; } }); var _Compact = require('./components/compact/Compact'); Object.defineProperty(exports, 'CompactPicker', { enumerable: true, get: function get() { return _interopRequireDefault(_Compact).default; } }); var _Github = require('./components/github/Github'); Object.defineProperty(exports, 'GithubPicker', { enumerable: true, get: function get() { return _interopRequireDefault(_Github).default; } }); var _Hue = require('./components/hue/Hue'); Object.defineProperty(exports, 'HuePicker', { enumerable: true, get: function get() { return _interopRequireDefault(_Hue).default; } }); var _Material = require('./components/material/Material'); Object.defineProperty(exports, 'MaterialPicker', { enumerable: true, get: function get() { return _interopRequireDefault(_Material).default; } }); var _Photoshop = require('./components/photoshop/Photoshop'); Object.defineProperty(exports, 'PhotoshopPicker', { enumerable: true, get: function get() { return _interopRequireDefault(_Photoshop).default; } }); var _Sketch = require('./components/sketch/Sketch'); Object.defineProperty(exports, 'SketchPicker', { enumerable: true, get: function get() { return _interopRequireDefault(_Sketch).default; } }); var _Slider = require('./components/slider/Slider'); Object.defineProperty(exports, 'SliderPicker', { enumerable: true, get: function get() { return _interopRequireDefault(_Slider).default; } }); var _Swatches = require('./components/swatches/Swatches'); Object.defineProperty(exports, 'SwatchesPicker', { enumerable: true, get: function get() { return _interopRequireDefault(_Swatches).default; } }); var _Twitter = require('./components/twitter/Twitter'); Object.defineProperty(exports, 'TwitterPicker', { enumerable: true, get: function get() { return _interopRequireDefault(_Twitter).default; } }); var _Google = require('./components/google/Google'); Object.defineProperty(exports, 'GooglePicker', { enumerable: true, get: function get() { return _interopRequireDefault(_Google).default; } }); var _ColorWrap = require('./components/common/ColorWrap'); Object.defineProperty(exports, 'CustomPicker', { enumerable: true, get: function get() { return _interopRequireDefault(_ColorWrap).default; } }); var _Chrome2 = _interopRequireDefault(_Chrome); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } exports.default = _Chrome2.default; },{"./components/alpha/Alpha":311,"./components/block/Block":313,"./components/chrome/Chrome":315,"./components/circle/Circle":319,"./components/common/ColorWrap":323,"./components/compact/Compact":330,"./components/github/Github":333,"./components/google/Google":335,"./components/hue/Hue":339,"./components/material/Material":341,"./components/photoshop/Photoshop":342,"./components/sketch/Sketch":348,"./components/slider/Slider":351,"./components/swatches/Swatches":355,"./components/twitter/Twitter":358}],366:[function(require,module,exports){ (function (process){ /** @license React v16.13.1 * react-is.development.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ 'use strict'; if (process.env.NODE_ENV !== "production") { (function() { 'use strict'; // The Symbol used to tag the ReactElement-like types. If there is no native Symbol // nor polyfill, then a plain number is used for performance. var hasSymbol = typeof Symbol === 'function' && Symbol.for; var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7; var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca; var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb; var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc; var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2; var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd; var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary // (unstable) APIs that have been removed. Can we remove the symbols? var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf; var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf; var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0; var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1; var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8; var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3; var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4; var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for('react.block') : 0xead9; var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5; var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6; var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for('react.scope') : 0xead7; function isValidElementType(type) { return typeof type === 'string' || typeof type === 'function' || // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill. type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE || type.$$typeof === REACT_SCOPE_TYPE || type.$$typeof === REACT_BLOCK_TYPE); } function typeOf(object) { if (typeof object === 'object' && object !== null) { var $$typeof = object.$$typeof; switch ($$typeof) { case REACT_ELEMENT_TYPE: var type = object.type; switch (type) { case REACT_ASYNC_MODE_TYPE: case REACT_CONCURRENT_MODE_TYPE: case REACT_FRAGMENT_TYPE: case REACT_PROFILER_TYPE: case REACT_STRICT_MODE_TYPE: case REACT_SUSPENSE_TYPE: return type; default: var $$typeofType = type && type.$$typeof; switch ($$typeofType) { case REACT_CONTEXT_TYPE: case REACT_FORWARD_REF_TYPE: case REACT_LAZY_TYPE: case REACT_MEMO_TYPE: case REACT_PROVIDER_TYPE: return $$typeofType; default: return $$typeof; } } case REACT_PORTAL_TYPE: return $$typeof; } } return undefined; } // AsyncMode is deprecated along with isAsyncMode var AsyncMode = REACT_ASYNC_MODE_TYPE; var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE; var ContextConsumer = REACT_CONTEXT_TYPE; var ContextProvider = REACT_PROVIDER_TYPE; var Element = REACT_ELEMENT_TYPE; var ForwardRef = REACT_FORWARD_REF_TYPE; var Fragment = REACT_FRAGMENT_TYPE; var Lazy = REACT_LAZY_TYPE; var Memo = REACT_MEMO_TYPE; var Portal = REACT_PORTAL_TYPE; var Profiler = REACT_PROFILER_TYPE; var StrictMode = REACT_STRICT_MODE_TYPE; var Suspense = REACT_SUSPENSE_TYPE; var hasWarnedAboutDeprecatedIsAsyncMode = false; // AsyncMode should be deprecated function isAsyncMode(object) { { if (!hasWarnedAboutDeprecatedIsAsyncMode) { hasWarnedAboutDeprecatedIsAsyncMode = true; // Using console['warn'] to evade Babel and ESLint console['warn']('The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 17+. Update your code to use ' + 'ReactIs.isConcurrentMode() instead. It has the exact same API.'); } } return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE; } function isConcurrentMode(object) { return typeOf(object) === REACT_CONCURRENT_MODE_TYPE; } function isContextConsumer(object) { return typeOf(object) === REACT_CONTEXT_TYPE; } function isContextProvider(object) { return typeOf(object) === REACT_PROVIDER_TYPE; } function isElement(object) { return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE; } function isForwardRef(object) { return typeOf(object) === REACT_FORWARD_REF_TYPE; } function isFragment(object) { return typeOf(object) === REACT_FRAGMENT_TYPE; } function isLazy(object) { return typeOf(object) === REACT_LAZY_TYPE; } function isMemo(object) { return typeOf(object) === REACT_MEMO_TYPE; } function isPortal(object) { return typeOf(object) === REACT_PORTAL_TYPE; } function isProfiler(object) { return typeOf(object) === REACT_PROFILER_TYPE; } function isStrictMode(object) { return typeOf(object) === REACT_STRICT_MODE_TYPE; } function isSuspense(object) { return typeOf(object) === REACT_SUSPENSE_TYPE; } exports.AsyncMode = AsyncMode; exports.ConcurrentMode = ConcurrentMode; exports.ContextConsumer = ContextConsumer; exports.ContextProvider = ContextProvider; exports.Element = Element; exports.ForwardRef = ForwardRef; exports.Fragment = Fragment; exports.Lazy = Lazy; exports.Memo = Memo; exports.Portal = Portal; exports.Profiler = Profiler; exports.StrictMode = StrictMode; exports.Suspense = Suspense; exports.isAsyncMode = isAsyncMode; exports.isConcurrentMode = isConcurrentMode; exports.isContextConsumer = isContextConsumer; exports.isContextProvider = isContextProvider; exports.isElement = isElement; exports.isForwardRef = isForwardRef; exports.isFragment = isFragment; exports.isLazy = isLazy; exports.isMemo = isMemo; exports.isPortal = isPortal; exports.isProfiler = isProfiler; exports.isStrictMode = isStrictMode; exports.isSuspense = isSuspense; exports.isValidElementType = isValidElementType; exports.typeOf = typeOf; })(); } }).call(this,require('_process')) },{"_process":6}],367:[function(require,module,exports){ /** @license React v16.13.1 * react-is.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ 'use strict';var b="function"===typeof Symbol&&Symbol.for,c=b?Symbol.for("react.element"):60103,d=b?Symbol.for("react.portal"):60106,e=b?Symbol.for("react.fragment"):60107,f=b?Symbol.for("react.strict_mode"):60108,g=b?Symbol.for("react.profiler"):60114,h=b?Symbol.for("react.provider"):60109,k=b?Symbol.for("react.context"):60110,l=b?Symbol.for("react.async_mode"):60111,m=b?Symbol.for("react.concurrent_mode"):60111,n=b?Symbol.for("react.forward_ref"):60112,p=b?Symbol.for("react.suspense"):60113,q=b? Symbol.for("react.suspense_list"):60120,r=b?Symbol.for("react.memo"):60115,t=b?Symbol.for("react.lazy"):60116,v=b?Symbol.for("react.block"):60121,w=b?Symbol.for("react.fundamental"):60117,x=b?Symbol.for("react.responder"):60118,y=b?Symbol.for("react.scope"):60119; function z(a){if("object"===typeof a&&null!==a){var u=a.$$typeof;switch(u){case c:switch(a=a.type,a){case l:case m:case e:case g:case f:case p:return a;default:switch(a=a&&a.$$typeof,a){case k:case n:case t:case r:case h:return a;default:return u}}case d:return u}}}function A(a){return z(a)===m}exports.AsyncMode=l;exports.ConcurrentMode=m;exports.ContextConsumer=k;exports.ContextProvider=h;exports.Element=c;exports.ForwardRef=n;exports.Fragment=e;exports.Lazy=t;exports.Memo=r;exports.Portal=d; exports.Profiler=g;exports.StrictMode=f;exports.Suspense=p;exports.isAsyncMode=function(a){return A(a)||z(a)===l};exports.isConcurrentMode=A;exports.isContextConsumer=function(a){return z(a)===k};exports.isContextProvider=function(a){return z(a)===h};exports.isElement=function(a){return"object"===typeof a&&null!==a&&a.$$typeof===c};exports.isForwardRef=function(a){return z(a)===n};exports.isFragment=function(a){return z(a)===e};exports.isLazy=function(a){return z(a)===t}; exports.isMemo=function(a){return z(a)===r};exports.isPortal=function(a){return z(a)===d};exports.isProfiler=function(a){return z(a)===g};exports.isStrictMode=function(a){return z(a)===f};exports.isSuspense=function(a){return z(a)===p}; exports.isValidElementType=function(a){return"string"===typeof a||"function"===typeof a||a===e||a===m||a===g||a===f||a===p||a===q||"object"===typeof a&&null!==a&&(a.$$typeof===t||a.$$typeof===r||a.$$typeof===h||a.$$typeof===k||a.$$typeof===n||a.$$typeof===w||a.$$typeof===x||a.$$typeof===y||a.$$typeof===v)};exports.typeOf=z; },{}],368:[function(require,module,exports){ (function (process){ 'use strict'; if (process.env.NODE_ENV === 'production') { module.exports = require('./cjs/react-is.production.min.js'); } else { module.exports = require('./cjs/react-is.development.js'); } }).call(this,require('_process')) },{"./cjs/react-is.development.js":366,"./cjs/react-is.production.min.js":367,"_process":6}],369:[function(require,module,exports){ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("prop-types"),require("react"),require("signature_pad"),require("trim-canvas")):"function"==typeof define&&define.amd?define(["prop-types","react","signature_pad","trim-canvas"],t):"object"==typeof exports?exports.SignatureCanvas=t(require("prop-types"),require("react"),require("signature_pad"),require("trim-canvas")):e.SignatureCanvas=t(e["prop-types"],e.react,e.signature_pad,e["trim-canvas"])}(this,function(e,t,n,r){return function(e){function t(r){if(n[r])return n[r].exports;var a=n[r]={exports:{},id:r,loaded:!1};return e[r].call(a.exports,a,a.exports,t),a.loaded=!0,a.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function a(e,t){var n={};for(var r in e)t.indexOf(r)>=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=Object.assign||function(e){for(var t=1;t 1 && arguments[1] !== undefined ? arguments[1] : 'span'; return function (_React$Component) { _inherits(Active, _React$Component); function Active() { var _ref; var _temp, _this, _ret; _classCallCheck(this, Active); for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Active.__proto__ || Object.getPrototypeOf(Active)).call.apply(_ref, [this].concat(args))), _this), _this.state = { active: false }, _this.handleMouseDown = function () { return _this.setState({ active: true }); }, _this.handleMouseUp = function () { return _this.setState({ active: false }); }, _this.render = function () { return _react2.default.createElement( Span, { onMouseDown: _this.handleMouseDown, onMouseUp: _this.handleMouseUp }, _react2.default.createElement(Component, _extends({}, _this.props, _this.state)) ); }, _temp), _possibleConstructorReturn(_this, _ret); } return Active; }(_react2.default.Component); }; exports.default = active; },{"react":"react"}],372:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.hover = undefined; var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _react = require('react'); var _react2 = _interopRequireDefault(_react); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var hover = exports.hover = function hover(Component) { var Span = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'span'; return function (_React$Component) { _inherits(Hover, _React$Component); function Hover() { var _ref; var _temp, _this, _ret; _classCallCheck(this, Hover); for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Hover.__proto__ || Object.getPrototypeOf(Hover)).call.apply(_ref, [this].concat(args))), _this), _this.state = { hover: false }, _this.handleMouseOver = function () { return _this.setState({ hover: true }); }, _this.handleMouseOut = function () { return _this.setState({ hover: false }); }, _this.render = function () { return _react2.default.createElement( Span, { onMouseOver: _this.handleMouseOver, onMouseOut: _this.handleMouseOut }, _react2.default.createElement(Component, _extends({}, _this.props, _this.state)) ); }, _temp), _possibleConstructorReturn(_this, _ret); } return Hover; }(_react2.default.Component); }; exports.default = hover; },{"react":"react"}],373:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.flattenNames = undefined; var _isString2 = require('lodash/isString'); var _isString3 = _interopRequireDefault(_isString2); var _forOwn2 = require('lodash/forOwn'); var _forOwn3 = _interopRequireDefault(_forOwn2); var _isPlainObject2 = require('lodash/isPlainObject'); var _isPlainObject3 = _interopRequireDefault(_isPlainObject2); var _map2 = require('lodash/map'); var _map3 = _interopRequireDefault(_map2); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var flattenNames = exports.flattenNames = function flattenNames() { var things = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; var names = []; (0, _map3.default)(things, function (thing) { if (Array.isArray(thing)) { flattenNames(thing).map(function (name) { return names.push(name); }); } else if ((0, _isPlainObject3.default)(thing)) { (0, _forOwn3.default)(thing, function (value, key) { value === true && names.push(key); names.push(key + '-' + value); }); } else if ((0, _isString3.default)(thing)) { names.push(thing); } }); return names; }; exports.default = flattenNames; },{"lodash/forOwn":271,"lodash/isPlainObject":285,"lodash/isString":287,"lodash/map":293}],374:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.ReactCSS = exports.loop = exports.handleActive = exports.handleHover = exports.hover = undefined; var _flattenNames = require('./flattenNames'); var _flattenNames2 = _interopRequireDefault(_flattenNames); var _mergeClasses = require('./mergeClasses'); var _mergeClasses2 = _interopRequireDefault(_mergeClasses); var _autoprefix = require('./autoprefix'); var _autoprefix2 = _interopRequireDefault(_autoprefix); var _hover2 = require('./components/hover'); var _hover3 = _interopRequireDefault(_hover2); var _active = require('./components/active'); var _active2 = _interopRequireDefault(_active); var _loop2 = require('./loop'); var _loop3 = _interopRequireDefault(_loop2); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } exports.hover = _hover3.default; exports.handleHover = _hover3.default; exports.handleActive = _active2.default; exports.loop = _loop3.default; var ReactCSS = exports.ReactCSS = function ReactCSS(classes) { for (var _len = arguments.length, activations = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { activations[_key - 1] = arguments[_key]; } var activeNames = (0, _flattenNames2.default)(activations); var merged = (0, _mergeClasses2.default)(classes, activeNames); return (0, _autoprefix2.default)(merged); }; exports.default = ReactCSS; },{"./autoprefix":370,"./components/active":371,"./components/hover":372,"./flattenNames":373,"./loop":375,"./mergeClasses":376}],375:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var loopable = function loopable(i, length) { var props = {}; var setProp = function setProp(name) { var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; props[name] = value; }; i === 0 && setProp('first-child'); i === length - 1 && setProp('last-child'); (i === 0 || i % 2 === 0) && setProp('even'); Math.abs(i % 2) === 1 && setProp('odd'); setProp('nth-child', i); return props; }; exports.default = loopable; },{}],376:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.mergeClasses = undefined; var _forOwn2 = require('lodash/forOwn'); var _forOwn3 = _interopRequireDefault(_forOwn2); var _cloneDeep2 = require('lodash/cloneDeep'); var _cloneDeep3 = _interopRequireDefault(_cloneDeep2); var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var mergeClasses = exports.mergeClasses = function mergeClasses(classes) { var activeNames = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; var styles = classes.default && (0, _cloneDeep3.default)(classes.default) || {}; activeNames.map(function (name) { var toMerge = classes[name]; if (toMerge) { (0, _forOwn3.default)(toMerge, function (value, key) { if (!styles[key]) { styles[key] = {}; } styles[key] = _extends({}, styles[key], toMerge[key]); }); } return name; }); return styles; }; exports.default = mergeClasses; },{"lodash/cloneDeep":265,"lodash/forOwn":271}],377:[function(require,module,exports){ /*! * Signature Pad v2.3.2 * https://github.com/szimek/signature_pad * * Copyright 2017 Szymon Nowak * Released under the MIT license * * The main idea and some parts of the code (e.g. drawing variable width Bézier curve) are taken from: * http://corner.squareup.com/2012/07/smoother-signatures.html * * Implementation of interpolation using cubic Bézier curves is taken from: * http://benknowscode.wordpress.com/2012/09/14/path-interpolation-using-cubic-bezier-and-control-point-estimation-in-javascript * * Algorithm for approximated length of a Bézier curve is taken from: * http://www.lemoda.net/maths/bezier-length/index.html * */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global.SignaturePad = factory()); }(this, (function () { 'use strict'; function Point(x, y, time) { this.x = x; this.y = y; this.time = time || new Date().getTime(); } Point.prototype.velocityFrom = function (start) { return this.time !== start.time ? this.distanceTo(start) / (this.time - start.time) : 1; }; Point.prototype.distanceTo = function (start) { return Math.sqrt(Math.pow(this.x - start.x, 2) + Math.pow(this.y - start.y, 2)); }; Point.prototype.equals = function (other) { return this.x === other.x && this.y === other.y && this.time === other.time; }; function Bezier(startPoint, control1, control2, endPoint) { this.startPoint = startPoint; this.control1 = control1; this.control2 = control2; this.endPoint = endPoint; } // Returns approximated length. Bezier.prototype.length = function () { var steps = 10; var length = 0; var px = void 0; var py = void 0; for (var i = 0; i <= steps; i += 1) { var t = i / steps; var cx = this._point(t, this.startPoint.x, this.control1.x, this.control2.x, this.endPoint.x); var cy = this._point(t, this.startPoint.y, this.control1.y, this.control2.y, this.endPoint.y); if (i > 0) { var xdiff = cx - px; var ydiff = cy - py; length += Math.sqrt(xdiff * xdiff + ydiff * ydiff); } px = cx; py = cy; } return length; }; /* eslint-disable no-multi-spaces, space-in-parens */ Bezier.prototype._point = function (t, start, c1, c2, end) { return start * (1.0 - t) * (1.0 - t) * (1.0 - t) + 3.0 * c1 * (1.0 - t) * (1.0 - t) * t + 3.0 * c2 * (1.0 - t) * t * t + end * t * t * t; }; /* eslint-disable */ // http://stackoverflow.com/a/27078401/815507 function throttle(func, wait, options) { var context, args, result; var timeout = null; var previous = 0; if (!options) options = {}; var later = function later() { previous = options.leading === false ? 0 : Date.now(); timeout = null; result = func.apply(context, args); if (!timeout) context = args = null; }; return function () { var now = Date.now(); if (!previous && options.leading === false) previous = now; var remaining = wait - (now - previous); context = this; args = arguments; if (remaining <= 0 || remaining > wait) { if (timeout) { clearTimeout(timeout); timeout = null; } previous = now; result = func.apply(context, args); if (!timeout) context = args = null; } else if (!timeout && options.trailing !== false) { timeout = setTimeout(later, remaining); } return result; }; } function SignaturePad(canvas, options) { var self = this; var opts = options || {}; this.velocityFilterWeight = opts.velocityFilterWeight || 0.7; this.minWidth = opts.minWidth || 0.5; this.maxWidth = opts.maxWidth || 2.5; this.throttle = 'throttle' in opts ? opts.throttle : 16; // in miliseconds this.minDistance = 'minDistance' in opts ? opts.minDistance : 5; if (this.throttle) { this._strokeMoveUpdate = throttle(SignaturePad.prototype._strokeUpdate, this.throttle); } else { this._strokeMoveUpdate = SignaturePad.prototype._strokeUpdate; } this.dotSize = opts.dotSize || function () { return (this.minWidth + this.maxWidth) / 2; }; this.penColor = opts.penColor || 'black'; this.backgroundColor = opts.backgroundColor || 'rgba(0,0,0,0)'; this.onBegin = opts.onBegin; this.onEnd = opts.onEnd; this._canvas = canvas; this._ctx = canvas.getContext('2d'); this.clear(); // We need add these inline so they are available to unbind while still having // access to 'self' we could use _.bind but it's not worth adding a dependency. this._handleMouseDown = function (event) { if (event.which === 1) { self._mouseButtonDown = true; self._strokeBegin(event); } }; this._handleMouseMove = function (event) { if (self._mouseButtonDown) { self._strokeMoveUpdate(event); } }; this._handleMouseUp = function (event) { if (event.which === 1 && self._mouseButtonDown) { self._mouseButtonDown = false; self._strokeEnd(event); } }; this._handleTouchStart = function (event) { if (event.targetTouches.length === 1) { var touch = event.changedTouches[0]; self._strokeBegin(touch); } }; this._handleTouchMove = function (event) { // Prevent scrolling. event.preventDefault(); var touch = event.targetTouches[0]; self._strokeMoveUpdate(touch); }; this._handleTouchEnd = function (event) { var wasCanvasTouched = event.target === self._canvas; if (wasCanvasTouched) { event.preventDefault(); self._strokeEnd(event); } }; // Enable mouse and touch event handlers this.on(); } // Public methods SignaturePad.prototype.clear = function () { var ctx = this._ctx; var canvas = this._canvas; ctx.fillStyle = this.backgroundColor; ctx.clearRect(0, 0, canvas.width, canvas.height); ctx.fillRect(0, 0, canvas.width, canvas.height); this._data = []; this._reset(); this._isEmpty = true; }; SignaturePad.prototype.fromDataURL = function (dataUrl) { var _this = this; var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; var image = new Image(); var ratio = options.ratio || window.devicePixelRatio || 1; var width = options.width || this._canvas.width / ratio; var height = options.height || this._canvas.height / ratio; this._reset(); image.src = dataUrl; image.onload = function () { _this._ctx.drawImage(image, 0, 0, width, height); }; this._isEmpty = false; }; SignaturePad.prototype.toDataURL = function (type) { var _canvas; switch (type) { case 'image/svg+xml': return this._toSVG(); default: for (var _len = arguments.length, options = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { options[_key - 1] = arguments[_key]; } return (_canvas = this._canvas).toDataURL.apply(_canvas, [type].concat(options)); } }; SignaturePad.prototype.on = function () { this._handleMouseEvents(); this._handleTouchEvents(); }; SignaturePad.prototype.off = function () { this._canvas.removeEventListener('mousedown', this._handleMouseDown); this._canvas.removeEventListener('mousemove', this._handleMouseMove); document.removeEventListener('mouseup', this._handleMouseUp); this._canvas.removeEventListener('touchstart', this._handleTouchStart); this._canvas.removeEventListener('touchmove', this._handleTouchMove); this._canvas.removeEventListener('touchend', this._handleTouchEnd); }; SignaturePad.prototype.isEmpty = function () { return this._isEmpty; }; // Private methods SignaturePad.prototype._strokeBegin = function (event) { this._data.push([]); this._reset(); this._strokeUpdate(event); if (typeof this.onBegin === 'function') { this.onBegin(event); } }; SignaturePad.prototype._strokeUpdate = function (event) { var x = event.clientX; var y = event.clientY; var point = this._createPoint(x, y); var lastPointGroup = this._data[this._data.length - 1]; var lastPoint = lastPointGroup && lastPointGroup[lastPointGroup.length - 1]; var isLastPointTooClose = lastPoint && point.distanceTo(lastPoint) < this.minDistance; // Skip this point if it's too close to the previous one if (!(lastPoint && isLastPointTooClose)) { var _addPoint = this._addPoint(point), curve = _addPoint.curve, widths = _addPoint.widths; if (curve && widths) { this._drawCurve(curve, widths.start, widths.end); } this._data[this._data.length - 1].push({ x: point.x, y: point.y, time: point.time, color: this.penColor }); } }; SignaturePad.prototype._strokeEnd = function (event) { var canDrawCurve = this.points.length > 2; var point = this.points[0]; // Point instance if (!canDrawCurve && point) { this._drawDot(point); } if (point) { var lastPointGroup = this._data[this._data.length - 1]; var lastPoint = lastPointGroup[lastPointGroup.length - 1]; // plain object // When drawing a dot, there's only one point in a group, so without this check // such group would end up with exactly the same 2 points. if (!point.equals(lastPoint)) { lastPointGroup.push({ x: point.x, y: point.y, time: point.time, color: this.penColor }); } } if (typeof this.onEnd === 'function') { this.onEnd(event); } }; SignaturePad.prototype._handleMouseEvents = function () { this._mouseButtonDown = false; this._canvas.addEventListener('mousedown', this._handleMouseDown); this._canvas.addEventListener('mousemove', this._handleMouseMove); document.addEventListener('mouseup', this._handleMouseUp); }; SignaturePad.prototype._handleTouchEvents = function () { // Pass touch events to canvas element on mobile IE11 and Edge. this._canvas.style.msTouchAction = 'none'; this._canvas.style.touchAction = 'none'; this._canvas.addEventListener('touchstart', this._handleTouchStart); this._canvas.addEventListener('touchmove', this._handleTouchMove); this._canvas.addEventListener('touchend', this._handleTouchEnd); }; SignaturePad.prototype._reset = function () { this.points = []; this._lastVelocity = 0; this._lastWidth = (this.minWidth + this.maxWidth) / 2; this._ctx.fillStyle = this.penColor; }; SignaturePad.prototype._createPoint = function (x, y, time) { var rect = this._canvas.getBoundingClientRect(); return new Point(x - rect.left, y - rect.top, time || new Date().getTime()); }; SignaturePad.prototype._addPoint = function (point) { var points = this.points; var tmp = void 0; points.push(point); if (points.length > 2) { // To reduce the initial lag make it work with 3 points // by copying the first point to the beginning. if (points.length === 3) points.unshift(points[0]); tmp = this._calculateCurveControlPoints(points[0], points[1], points[2]); var c2 = tmp.c2; tmp = this._calculateCurveControlPoints(points[1], points[2], points[3]); var c3 = tmp.c1; var curve = new Bezier(points[1], c2, c3, points[2]); var widths = this._calculateCurveWidths(curve); // Remove the first element from the list, // so that we always have no more than 4 points in points array. points.shift(); return { curve: curve, widths: widths }; } return {}; }; SignaturePad.prototype._calculateCurveControlPoints = function (s1, s2, s3) { var dx1 = s1.x - s2.x; var dy1 = s1.y - s2.y; var dx2 = s2.x - s3.x; var dy2 = s2.y - s3.y; var m1 = { x: (s1.x + s2.x) / 2.0, y: (s1.y + s2.y) / 2.0 }; var m2 = { x: (s2.x + s3.x) / 2.0, y: (s2.y + s3.y) / 2.0 }; var l1 = Math.sqrt(dx1 * dx1 + dy1 * dy1); var l2 = Math.sqrt(dx2 * dx2 + dy2 * dy2); var dxm = m1.x - m2.x; var dym = m1.y - m2.y; var k = l2 / (l1 + l2); var cm = { x: m2.x + dxm * k, y: m2.y + dym * k }; var tx = s2.x - cm.x; var ty = s2.y - cm.y; return { c1: new Point(m1.x + tx, m1.y + ty), c2: new Point(m2.x + tx, m2.y + ty) }; }; SignaturePad.prototype._calculateCurveWidths = function (curve) { var startPoint = curve.startPoint; var endPoint = curve.endPoint; var widths = { start: null, end: null }; var velocity = this.velocityFilterWeight * endPoint.velocityFrom(startPoint) + (1 - this.velocityFilterWeight) * this._lastVelocity; var newWidth = this._strokeWidth(velocity); widths.start = this._lastWidth; widths.end = newWidth; this._lastVelocity = velocity; this._lastWidth = newWidth; return widths; }; SignaturePad.prototype._strokeWidth = function (velocity) { return Math.max(this.maxWidth / (velocity + 1), this.minWidth); }; SignaturePad.prototype._drawPoint = function (x, y, size) { var ctx = this._ctx; ctx.moveTo(x, y); ctx.arc(x, y, size, 0, 2 * Math.PI, false); this._isEmpty = false; }; SignaturePad.prototype._drawCurve = function (curve, startWidth, endWidth) { var ctx = this._ctx; var widthDelta = endWidth - startWidth; var drawSteps = Math.floor(curve.length()); ctx.beginPath(); for (var i = 0; i < drawSteps; i += 1) { // Calculate the Bezier (x, y) coordinate for this step. var t = i / drawSteps; var tt = t * t; var ttt = tt * t; var u = 1 - t; var uu = u * u; var uuu = uu * u; var x = uuu * curve.startPoint.x; x += 3 * uu * t * curve.control1.x; x += 3 * u * tt * curve.control2.x; x += ttt * curve.endPoint.x; var y = uuu * curve.startPoint.y; y += 3 * uu * t * curve.control1.y; y += 3 * u * tt * curve.control2.y; y += ttt * curve.endPoint.y; var width = startWidth + ttt * widthDelta; this._drawPoint(x, y, width); } ctx.closePath(); ctx.fill(); }; SignaturePad.prototype._drawDot = function (point) { var ctx = this._ctx; var width = typeof this.dotSize === 'function' ? this.dotSize() : this.dotSize; ctx.beginPath(); this._drawPoint(point.x, point.y, width); ctx.closePath(); ctx.fill(); }; SignaturePad.prototype._fromData = function (pointGroups, drawCurve, drawDot) { for (var i = 0; i < pointGroups.length; i += 1) { var group = pointGroups[i]; if (group.length > 1) { for (var j = 0; j < group.length; j += 1) { var rawPoint = group[j]; var point = new Point(rawPoint.x, rawPoint.y, rawPoint.time); var color = rawPoint.color; if (j === 0) { // First point in a group. Nothing to draw yet. // All points in the group have the same color, so it's enough to set // penColor just at the beginning. this.penColor = color; this._reset(); this._addPoint(point); } else if (j !== group.length - 1) { // Middle point in a group. var _addPoint2 = this._addPoint(point), curve = _addPoint2.curve, widths = _addPoint2.widths; if (curve && widths) { drawCurve(curve, widths, color); } } else { // Last point in a group. Do nothing. } } } else { this._reset(); var _rawPoint = group[0]; drawDot(_rawPoint); } } }; SignaturePad.prototype._toSVG = function () { var _this2 = this; var pointGroups = this._data; var canvas = this._canvas; var ratio = Math.max(window.devicePixelRatio || 1, 1); var minX = 0; var minY = 0; var maxX = canvas.width / ratio; var maxY = canvas.height / ratio; var svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); svg.setAttributeNS(null, 'width', canvas.width); svg.setAttributeNS(null, 'height', canvas.height); this._fromData(pointGroups, function (curve, widths, color) { var path = document.createElement('path'); // Need to check curve for NaN values, these pop up when drawing // lines on the canvas that are not continuous. E.g. Sharp corners // or stopping mid-stroke and than continuing without lifting mouse. if (!isNaN(curve.control1.x) && !isNaN(curve.control1.y) && !isNaN(curve.control2.x) && !isNaN(curve.control2.y)) { var attr = 'M ' + curve.startPoint.x.toFixed(3) + ',' + curve.startPoint.y.toFixed(3) + ' ' + ('C ' + curve.control1.x.toFixed(3) + ',' + curve.control1.y.toFixed(3) + ' ') + (curve.control2.x.toFixed(3) + ',' + curve.control2.y.toFixed(3) + ' ') + (curve.endPoint.x.toFixed(3) + ',' + curve.endPoint.y.toFixed(3)); path.setAttribute('d', attr); path.setAttribute('stroke-width', (widths.end * 2.25).toFixed(3)); path.setAttribute('stroke', color); path.setAttribute('fill', 'none'); path.setAttribute('stroke-linecap', 'round'); svg.appendChild(path); } }, function (rawPoint) { var circle = document.createElement('circle'); var dotSize = typeof _this2.dotSize === 'function' ? _this2.dotSize() : _this2.dotSize; circle.setAttribute('r', dotSize); circle.setAttribute('cx', rawPoint.x); circle.setAttribute('cy', rawPoint.y); circle.setAttribute('fill', rawPoint.color); svg.appendChild(circle); }); var prefix = 'data:image/svg+xml;base64,'; var header = ''; var body = svg.innerHTML; // IE hack for missing innerHTML property on SVGElement if (body === undefined) { var dummy = document.createElement('dummy'); var nodes = svg.childNodes; dummy.innerHTML = ''; for (var i = 0; i < nodes.length; i += 1) { dummy.appendChild(nodes[i].cloneNode(true)); } body = dummy.innerHTML; } var footer = ''; var data = header + body + footer; return prefix + btoa(data); }; SignaturePad.prototype.fromData = function (pointGroups) { var _this3 = this; this.clear(); this._fromData(pointGroups, function (curve, widths) { return _this3._drawCurve(curve, widths.start, widths.end); }, function (rawPoint) { return _this3._drawDot(rawPoint); }); this._data = pointGroups; }; SignaturePad.prototype.toData = function () { return this._data; }; return SignaturePad; }))); },{}],378:[function(require,module,exports){ // TinyColor v1.4.2 // https://github.com/bgrins/TinyColor // Brian Grinstead, MIT License (function(Math) { var trimLeft = /^\s+/, trimRight = /\s+$/, tinyCounter = 0, mathRound = Math.round, mathMin = Math.min, mathMax = Math.max, mathRandom = Math.random; function tinycolor (color, opts) { color = (color) ? color : ''; opts = opts || { }; // If input is already a tinycolor, return itself if (color instanceof tinycolor) { return color; } // If we are called as a function, call using new instead if (!(this instanceof tinycolor)) { return new tinycolor(color, opts); } var rgb = inputToRGB(color); this._originalInput = color, this._r = rgb.r, this._g = rgb.g, this._b = rgb.b, this._a = rgb.a, this._roundA = mathRound(100*this._a) / 100, this._format = opts.format || rgb.format; this._gradientType = opts.gradientType; // Don't let the range of [0,255] come back in [0,1]. // Potentially lose a little bit of precision here, but will fix issues where // .5 gets interpreted as half of the total, instead of half of 1 // If it was supposed to be 128, this was already taken care of by `inputToRgb` if (this._r < 1) { this._r = mathRound(this._r); } if (this._g < 1) { this._g = mathRound(this._g); } if (this._b < 1) { this._b = mathRound(this._b); } this._ok = rgb.ok; this._tc_id = tinyCounter++; } tinycolor.prototype = { isDark: function() { return this.getBrightness() < 128; }, isLight: function() { return !this.isDark(); }, isValid: function() { return this._ok; }, getOriginalInput: function() { return this._originalInput; }, getFormat: function() { return this._format; }, getAlpha: function() { return this._a; }, getBrightness: function() { //http://www.w3.org/TR/AERT#color-contrast var rgb = this.toRgb(); return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000; }, getLuminance: function() { //http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef var rgb = this.toRgb(); var RsRGB, GsRGB, BsRGB, R, G, B; RsRGB = rgb.r/255; GsRGB = rgb.g/255; BsRGB = rgb.b/255; if (RsRGB <= 0.03928) {R = RsRGB / 12.92;} else {R = Math.pow(((RsRGB + 0.055) / 1.055), 2.4);} if (GsRGB <= 0.03928) {G = GsRGB / 12.92;} else {G = Math.pow(((GsRGB + 0.055) / 1.055), 2.4);} if (BsRGB <= 0.03928) {B = BsRGB / 12.92;} else {B = Math.pow(((BsRGB + 0.055) / 1.055), 2.4);} return (0.2126 * R) + (0.7152 * G) + (0.0722 * B); }, setAlpha: function(value) { this._a = boundAlpha(value); this._roundA = mathRound(100*this._a) / 100; return this; }, toHsv: function() { var hsv = rgbToHsv(this._r, this._g, this._b); return { h: hsv.h * 360, s: hsv.s, v: hsv.v, a: this._a }; }, toHsvString: function() { var hsv = rgbToHsv(this._r, this._g, this._b); var h = mathRound(hsv.h * 360), s = mathRound(hsv.s * 100), v = mathRound(hsv.v * 100); return (this._a == 1) ? "hsv(" + h + ", " + s + "%, " + v + "%)" : "hsva(" + h + ", " + s + "%, " + v + "%, "+ this._roundA + ")"; }, toHsl: function() { var hsl = rgbToHsl(this._r, this._g, this._b); return { h: hsl.h * 360, s: hsl.s, l: hsl.l, a: this._a }; }, toHslString: function() { var hsl = rgbToHsl(this._r, this._g, this._b); var h = mathRound(hsl.h * 360), s = mathRound(hsl.s * 100), l = mathRound(hsl.l * 100); return (this._a == 1) ? "hsl(" + h + ", " + s + "%, " + l + "%)" : "hsla(" + h + ", " + s + "%, " + l + "%, "+ this._roundA + ")"; }, toHex: function(allow3Char) { return rgbToHex(this._r, this._g, this._b, allow3Char); }, toHexString: function(allow3Char) { return '#' + this.toHex(allow3Char); }, toHex8: function(allow4Char) { return rgbaToHex(this._r, this._g, this._b, this._a, allow4Char); }, toHex8String: function(allow4Char) { return '#' + this.toHex8(allow4Char); }, toRgb: function() { return { r: mathRound(this._r), g: mathRound(this._g), b: mathRound(this._b), a: this._a }; }, toRgbString: function() { return (this._a == 1) ? "rgb(" + mathRound(this._r) + ", " + mathRound(this._g) + ", " + mathRound(this._b) + ")" : "rgba(" + mathRound(this._r) + ", " + mathRound(this._g) + ", " + mathRound(this._b) + ", " + this._roundA + ")"; }, toPercentageRgb: function() { return { r: mathRound(bound01(this._r, 255) * 100) + "%", g: mathRound(bound01(this._g, 255) * 100) + "%", b: mathRound(bound01(this._b, 255) * 100) + "%", a: this._a }; }, toPercentageRgbString: function() { return (this._a == 1) ? "rgb(" + mathRound(bound01(this._r, 255) * 100) + "%, " + mathRound(bound01(this._g, 255) * 100) + "%, " + mathRound(bound01(this._b, 255) * 100) + "%)" : "rgba(" + mathRound(bound01(this._r, 255) * 100) + "%, " + mathRound(bound01(this._g, 255) * 100) + "%, " + mathRound(bound01(this._b, 255) * 100) + "%, " + this._roundA + ")"; }, toName: function() { if (this._a === 0) { return "transparent"; } if (this._a < 1) { return false; } return hexNames[rgbToHex(this._r, this._g, this._b, true)] || false; }, toFilter: function(secondColor) { var hex8String = '#' + rgbaToArgbHex(this._r, this._g, this._b, this._a); var secondHex8String = hex8String; var gradientType = this._gradientType ? "GradientType = 1, " : ""; if (secondColor) { var s = tinycolor(secondColor); secondHex8String = '#' + rgbaToArgbHex(s._r, s._g, s._b, s._a); } return "progid:DXImageTransform.Microsoft.gradient("+gradientType+"startColorstr="+hex8String+",endColorstr="+secondHex8String+")"; }, toString: function(format) { var formatSet = !!format; format = format || this._format; var formattedString = false; var hasAlpha = this._a < 1 && this._a >= 0; var needsAlphaFormat = !formatSet && hasAlpha && (format === "hex" || format === "hex6" || format === "hex3" || format === "hex4" || format === "hex8" || format === "name"); if (needsAlphaFormat) { // Special case for "transparent", all other non-alpha formats // will return rgba when there is transparency. if (format === "name" && this._a === 0) { return this.toName(); } return this.toRgbString(); } if (format === "rgb") { formattedString = this.toRgbString(); } if (format === "prgb") { formattedString = this.toPercentageRgbString(); } if (format === "hex" || format === "hex6") { formattedString = this.toHexString(); } if (format === "hex3") { formattedString = this.toHexString(true); } if (format === "hex4") { formattedString = this.toHex8String(true); } if (format === "hex8") { formattedString = this.toHex8String(); } if (format === "name") { formattedString = this.toName(); } if (format === "hsl") { formattedString = this.toHslString(); } if (format === "hsv") { formattedString = this.toHsvString(); } return formattedString || this.toHexString(); }, clone: function() { return tinycolor(this.toString()); }, _applyModification: function(fn, args) { var color = fn.apply(null, [this].concat([].slice.call(args))); this._r = color._r; this._g = color._g; this._b = color._b; this.setAlpha(color._a); return this; }, lighten: function() { return this._applyModification(lighten, arguments); }, brighten: function() { return this._applyModification(brighten, arguments); }, darken: function() { return this._applyModification(darken, arguments); }, desaturate: function() { return this._applyModification(desaturate, arguments); }, saturate: function() { return this._applyModification(saturate, arguments); }, greyscale: function() { return this._applyModification(greyscale, arguments); }, spin: function() { return this._applyModification(spin, arguments); }, _applyCombination: function(fn, args) { return fn.apply(null, [this].concat([].slice.call(args))); }, analogous: function() { return this._applyCombination(analogous, arguments); }, complement: function() { return this._applyCombination(complement, arguments); }, monochromatic: function() { return this._applyCombination(monochromatic, arguments); }, splitcomplement: function() { return this._applyCombination(splitcomplement, arguments); }, triad: function() { return this._applyCombination(triad, arguments); }, tetrad: function() { return this._applyCombination(tetrad, arguments); } }; // If input is an object, force 1 into "1.0" to handle ratios properly // String input requires "1.0" as input, so 1 will be treated as 1 tinycolor.fromRatio = function(color, opts) { if (typeof color == "object") { var newColor = {}; for (var i in color) { if (color.hasOwnProperty(i)) { if (i === "a") { newColor[i] = color[i]; } else { newColor[i] = convertToPercentage(color[i]); } } } color = newColor; } return tinycolor(color, opts); }; // Given a string or object, convert that input to RGB // Possible string inputs: // // "red" // "#f00" or "f00" // "#ff0000" or "ff0000" // "#ff000000" or "ff000000" // "rgb 255 0 0" or "rgb (255, 0, 0)" // "rgb 1.0 0 0" or "rgb (1, 0, 0)" // "rgba (255, 0, 0, 1)" or "rgba 255, 0, 0, 1" // "rgba (1.0, 0, 0, 1)" or "rgba 1.0, 0, 0, 1" // "hsl(0, 100%, 50%)" or "hsl 0 100% 50%" // "hsla(0, 100%, 50%, 1)" or "hsla 0 100% 50%, 1" // "hsv(0, 100%, 100%)" or "hsv 0 100% 100%" // function inputToRGB(color) { var rgb = { r: 0, g: 0, b: 0 }; var a = 1; var s = null; var v = null; var l = null; var ok = false; var format = false; if (typeof color == "string") { color = stringInputToObject(color); } if (typeof color == "object") { if (isValidCSSUnit(color.r) && isValidCSSUnit(color.g) && isValidCSSUnit(color.b)) { rgb = rgbToRgb(color.r, color.g, color.b); ok = true; format = String(color.r).substr(-1) === "%" ? "prgb" : "rgb"; } else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.v)) { s = convertToPercentage(color.s); v = convertToPercentage(color.v); rgb = hsvToRgb(color.h, s, v); ok = true; format = "hsv"; } else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.l)) { s = convertToPercentage(color.s); l = convertToPercentage(color.l); rgb = hslToRgb(color.h, s, l); ok = true; format = "hsl"; } if (color.hasOwnProperty("a")) { a = color.a; } } a = boundAlpha(a); return { ok: ok, format: color.format || format, r: mathMin(255, mathMax(rgb.r, 0)), g: mathMin(255, mathMax(rgb.g, 0)), b: mathMin(255, mathMax(rgb.b, 0)), a: a }; } // Conversion Functions // -------------------- // `rgbToHsl`, `rgbToHsv`, `hslToRgb`, `hsvToRgb` modified from: // // `rgbToRgb` // Handle bounds / percentage checking to conform to CSS color spec // // *Assumes:* r, g, b in [0, 255] or [0, 1] // *Returns:* { r, g, b } in [0, 255] function rgbToRgb(r, g, b){ return { r: bound01(r, 255) * 255, g: bound01(g, 255) * 255, b: bound01(b, 255) * 255 }; } // `rgbToHsl` // Converts an RGB color value to HSL. // *Assumes:* r, g, and b are contained in [0, 255] or [0, 1] // *Returns:* { h, s, l } in [0,1] function rgbToHsl(r, g, b) { r = bound01(r, 255); g = bound01(g, 255); b = bound01(b, 255); var max = mathMax(r, g, b), min = mathMin(r, g, b); var h, s, l = (max + min) / 2; if(max == min) { h = s = 0; // achromatic } else { var d = max - min; s = l > 0.5 ? d / (2 - max - min) : d / (max + min); switch(max) { case r: h = (g - b) / d + (g < b ? 6 : 0); break; case g: h = (b - r) / d + 2; break; case b: h = (r - g) / d + 4; break; } h /= 6; } return { h: h, s: s, l: l }; } // `hslToRgb` // Converts an HSL color value to RGB. // *Assumes:* h is contained in [0, 1] or [0, 360] and s and l are contained [0, 1] or [0, 100] // *Returns:* { r, g, b } in the set [0, 255] function hslToRgb(h, s, l) { var r, g, b; h = bound01(h, 360); s = bound01(s, 100); l = bound01(l, 100); function hue2rgb(p, q, t) { if(t < 0) t += 1; if(t > 1) t -= 1; if(t < 1/6) return p + (q - p) * 6 * t; if(t < 1/2) return q; if(t < 2/3) return p + (q - p) * (2/3 - t) * 6; return p; } if(s === 0) { r = g = b = l; // achromatic } else { var q = l < 0.5 ? l * (1 + s) : l + s - l * s; var p = 2 * l - q; r = hue2rgb(p, q, h + 1/3); g = hue2rgb(p, q, h); b = hue2rgb(p, q, h - 1/3); } return { r: r * 255, g: g * 255, b: b * 255 }; } // `rgbToHsv` // Converts an RGB color value to HSV // *Assumes:* r, g, and b are contained in the set [0, 255] or [0, 1] // *Returns:* { h, s, v } in [0,1] function rgbToHsv(r, g, b) { r = bound01(r, 255); g = bound01(g, 255); b = bound01(b, 255); var max = mathMax(r, g, b), min = mathMin(r, g, b); var h, s, v = max; var d = max - min; s = max === 0 ? 0 : d / max; if(max == min) { h = 0; // achromatic } else { switch(max) { case r: h = (g - b) / d + (g < b ? 6 : 0); break; case g: h = (b - r) / d + 2; break; case b: h = (r - g) / d + 4; break; } h /= 6; } return { h: h, s: s, v: v }; } // `hsvToRgb` // Converts an HSV color value to RGB. // *Assumes:* h is contained in [0, 1] or [0, 360] and s and v are contained in [0, 1] or [0, 100] // *Returns:* { r, g, b } in the set [0, 255] function hsvToRgb(h, s, v) { h = bound01(h, 360) * 6; s = bound01(s, 100); v = bound01(v, 100); var i = Math.floor(h), f = h - i, p = v * (1 - s), q = v * (1 - f * s), t = v * (1 - (1 - f) * s), mod = i % 6, r = [v, q, p, p, t, v][mod], g = [t, v, v, q, p, p][mod], b = [p, p, t, v, v, q][mod]; return { r: r * 255, g: g * 255, b: b * 255 }; } // `rgbToHex` // Converts an RGB color to hex // Assumes r, g, and b are contained in the set [0, 255] // Returns a 3 or 6 character hex function rgbToHex(r, g, b, allow3Char) { var hex = [ pad2(mathRound(r).toString(16)), pad2(mathRound(g).toString(16)), pad2(mathRound(b).toString(16)) ]; // Return a 3 character hex if possible if (allow3Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1)) { return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0); } return hex.join(""); } // `rgbaToHex` // Converts an RGBA color plus alpha transparency to hex // Assumes r, g, b are contained in the set [0, 255] and // a in [0, 1]. Returns a 4 or 8 character rgba hex function rgbaToHex(r, g, b, a, allow4Char) { var hex = [ pad2(mathRound(r).toString(16)), pad2(mathRound(g).toString(16)), pad2(mathRound(b).toString(16)), pad2(convertDecimalToHex(a)) ]; // Return a 4 character hex if possible if (allow4Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1) && hex[3].charAt(0) == hex[3].charAt(1)) { return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0) + hex[3].charAt(0); } return hex.join(""); } // `rgbaToArgbHex` // Converts an RGBA color to an ARGB Hex8 string // Rarely used, but required for "toFilter()" function rgbaToArgbHex(r, g, b, a) { var hex = [ pad2(convertDecimalToHex(a)), pad2(mathRound(r).toString(16)), pad2(mathRound(g).toString(16)), pad2(mathRound(b).toString(16)) ]; return hex.join(""); } // `equals` // Can be called with any tinycolor input tinycolor.equals = function (color1, color2) { if (!color1 || !color2) { return false; } return tinycolor(color1).toRgbString() == tinycolor(color2).toRgbString(); }; tinycolor.random = function() { return tinycolor.fromRatio({ r: mathRandom(), g: mathRandom(), b: mathRandom() }); }; // Modification Functions // ---------------------- // Thanks to less.js for some of the basics here // function desaturate(color, amount) { amount = (amount === 0) ? 0 : (amount || 10); var hsl = tinycolor(color).toHsl(); hsl.s -= amount / 100; hsl.s = clamp01(hsl.s); return tinycolor(hsl); } function saturate(color, amount) { amount = (amount === 0) ? 0 : (amount || 10); var hsl = tinycolor(color).toHsl(); hsl.s += amount / 100; hsl.s = clamp01(hsl.s); return tinycolor(hsl); } function greyscale(color) { return tinycolor(color).desaturate(100); } function lighten (color, amount) { amount = (amount === 0) ? 0 : (amount || 10); var hsl = tinycolor(color).toHsl(); hsl.l += amount / 100; hsl.l = clamp01(hsl.l); return tinycolor(hsl); } function brighten(color, amount) { amount = (amount === 0) ? 0 : (amount || 10); var rgb = tinycolor(color).toRgb(); rgb.r = mathMax(0, mathMin(255, rgb.r - mathRound(255 * - (amount / 100)))); rgb.g = mathMax(0, mathMin(255, rgb.g - mathRound(255 * - (amount / 100)))); rgb.b = mathMax(0, mathMin(255, rgb.b - mathRound(255 * - (amount / 100)))); return tinycolor(rgb); } function darken (color, amount) { amount = (amount === 0) ? 0 : (amount || 10); var hsl = tinycolor(color).toHsl(); hsl.l -= amount / 100; hsl.l = clamp01(hsl.l); return tinycolor(hsl); } // Spin takes a positive or negative amount within [-360, 360] indicating the change of hue. // Values outside of this range will be wrapped into this range. function spin(color, amount) { var hsl = tinycolor(color).toHsl(); var hue = (hsl.h + amount) % 360; hsl.h = hue < 0 ? 360 + hue : hue; return tinycolor(hsl); } // Combination Functions // --------------------- // Thanks to jQuery xColor for some of the ideas behind these // function complement(color) { var hsl = tinycolor(color).toHsl(); hsl.h = (hsl.h + 180) % 360; return tinycolor(hsl); } function triad(color) { var hsl = tinycolor(color).toHsl(); var h = hsl.h; return [ tinycolor(color), tinycolor({ h: (h + 120) % 360, s: hsl.s, l: hsl.l }), tinycolor({ h: (h + 240) % 360, s: hsl.s, l: hsl.l }) ]; } function tetrad(color) { var hsl = tinycolor(color).toHsl(); var h = hsl.h; return [ tinycolor(color), tinycolor({ h: (h + 90) % 360, s: hsl.s, l: hsl.l }), tinycolor({ h: (h + 180) % 360, s: hsl.s, l: hsl.l }), tinycolor({ h: (h + 270) % 360, s: hsl.s, l: hsl.l }) ]; } function splitcomplement(color) { var hsl = tinycolor(color).toHsl(); var h = hsl.h; return [ tinycolor(color), tinycolor({ h: (h + 72) % 360, s: hsl.s, l: hsl.l}), tinycolor({ h: (h + 216) % 360, s: hsl.s, l: hsl.l}) ]; } function analogous(color, results, slices) { results = results || 6; slices = slices || 30; var hsl = tinycolor(color).toHsl(); var part = 360 / slices; var ret = [tinycolor(color)]; for (hsl.h = ((hsl.h - (part * results >> 1)) + 720) % 360; --results; ) { hsl.h = (hsl.h + part) % 360; ret.push(tinycolor(hsl)); } return ret; } function monochromatic(color, results) { results = results || 6; var hsv = tinycolor(color).toHsv(); var h = hsv.h, s = hsv.s, v = hsv.v; var ret = []; var modification = 1 / results; while (results--) { ret.push(tinycolor({ h: h, s: s, v: v})); v = (v + modification) % 1; } return ret; } // Utility Functions // --------------------- tinycolor.mix = function(color1, color2, amount) { amount = (amount === 0) ? 0 : (amount || 50); var rgb1 = tinycolor(color1).toRgb(); var rgb2 = tinycolor(color2).toRgb(); var p = amount / 100; var rgba = { r: ((rgb2.r - rgb1.r) * p) + rgb1.r, g: ((rgb2.g - rgb1.g) * p) + rgb1.g, b: ((rgb2.b - rgb1.b) * p) + rgb1.b, a: ((rgb2.a - rgb1.a) * p) + rgb1.a }; return tinycolor(rgba); }; // Readability Functions // --------------------- // false // tinycolor.isReadable("#000", "#111",{level:"AA",size:"large"}) => false tinycolor.isReadable = function(color1, color2, wcag2) { var readability = tinycolor.readability(color1, color2); var wcag2Parms, out; out = false; wcag2Parms = validateWCAG2Parms(wcag2); switch (wcag2Parms.level + wcag2Parms.size) { case "AAsmall": case "AAAlarge": out = readability >= 4.5; break; case "AAlarge": out = readability >= 3; break; case "AAAsmall": out = readability >= 7; break; } return out; }; // `mostReadable` // Given a base color and a list of possible foreground or background // colors for that base, returns the most readable color. // Optionally returns Black or White if the most readable color is unreadable. // *Example* // tinycolor.mostReadable(tinycolor.mostReadable("#123", ["#124", "#125"],{includeFallbackColors:false}).toHexString(); // "#112255" // tinycolor.mostReadable(tinycolor.mostReadable("#123", ["#124", "#125"],{includeFallbackColors:true}).toHexString(); // "#ffffff" // tinycolor.mostReadable("#a8015a", ["#faf3f3"],{includeFallbackColors:true,level:"AAA",size:"large"}).toHexString(); // "#faf3f3" // tinycolor.mostReadable("#a8015a", ["#faf3f3"],{includeFallbackColors:true,level:"AAA",size:"small"}).toHexString(); // "#ffffff" tinycolor.mostReadable = function(baseColor, colorList, args) { var bestColor = null; var bestScore = 0; var readability; var includeFallbackColors, level, size ; args = args || {}; includeFallbackColors = args.includeFallbackColors ; level = args.level; size = args.size; for (var i= 0; i < colorList.length ; i++) { readability = tinycolor.readability(baseColor, colorList[i]); if (readability > bestScore) { bestScore = readability; bestColor = tinycolor(colorList[i]); } } if (tinycolor.isReadable(baseColor, bestColor, {"level":level,"size":size}) || !includeFallbackColors) { return bestColor; } else { args.includeFallbackColors=false; return tinycolor.mostReadable(baseColor,["#fff", "#000"],args); } }; // Big List of Colors // ------------------ // var names = tinycolor.names = { aliceblue: "f0f8ff", antiquewhite: "faebd7", aqua: "0ff", aquamarine: "7fffd4", azure: "f0ffff", beige: "f5f5dc", bisque: "ffe4c4", black: "000", blanchedalmond: "ffebcd", blue: "00f", blueviolet: "8a2be2", brown: "a52a2a", burlywood: "deb887", burntsienna: "ea7e5d", cadetblue: "5f9ea0", chartreuse: "7fff00", chocolate: "d2691e", coral: "ff7f50", cornflowerblue: "6495ed", cornsilk: "fff8dc", crimson: "dc143c", cyan: "0ff", darkblue: "00008b", darkcyan: "008b8b", darkgoldenrod: "b8860b", darkgray: "a9a9a9", darkgreen: "006400", darkgrey: "a9a9a9", darkkhaki: "bdb76b", darkmagenta: "8b008b", darkolivegreen: "556b2f", darkorange: "ff8c00", darkorchid: "9932cc", darkred: "8b0000", darksalmon: "e9967a", darkseagreen: "8fbc8f", darkslateblue: "483d8b", darkslategray: "2f4f4f", darkslategrey: "2f4f4f", darkturquoise: "00ced1", darkviolet: "9400d3", deeppink: "ff1493", deepskyblue: "00bfff", dimgray: "696969", dimgrey: "696969", dodgerblue: "1e90ff", firebrick: "b22222", floralwhite: "fffaf0", forestgreen: "228b22", fuchsia: "f0f", gainsboro: "dcdcdc", ghostwhite: "f8f8ff", gold: "ffd700", goldenrod: "daa520", gray: "808080", green: "008000", greenyellow: "adff2f", grey: "808080", honeydew: "f0fff0", hotpink: "ff69b4", indianred: "cd5c5c", indigo: "4b0082", ivory: "fffff0", khaki: "f0e68c", lavender: "e6e6fa", lavenderblush: "fff0f5", lawngreen: "7cfc00", lemonchiffon: "fffacd", lightblue: "add8e6", lightcoral: "f08080", lightcyan: "e0ffff", lightgoldenrodyellow: "fafad2", lightgray: "d3d3d3", lightgreen: "90ee90", lightgrey: "d3d3d3", lightpink: "ffb6c1", lightsalmon: "ffa07a", lightseagreen: "20b2aa", lightskyblue: "87cefa", lightslategray: "789", lightslategrey: "789", lightsteelblue: "b0c4de", lightyellow: "ffffe0", lime: "0f0", limegreen: "32cd32", linen: "faf0e6", magenta: "f0f", maroon: "800000", mediumaquamarine: "66cdaa", mediumblue: "0000cd", mediumorchid: "ba55d3", mediumpurple: "9370db", mediumseagreen: "3cb371", mediumslateblue: "7b68ee", mediumspringgreen: "00fa9a", mediumturquoise: "48d1cc", mediumvioletred: "c71585", midnightblue: "191970", mintcream: "f5fffa", mistyrose: "ffe4e1", moccasin: "ffe4b5", navajowhite: "ffdead", navy: "000080", oldlace: "fdf5e6", olive: "808000", olivedrab: "6b8e23", orange: "ffa500", orangered: "ff4500", orchid: "da70d6", palegoldenrod: "eee8aa", palegreen: "98fb98", paleturquoise: "afeeee", palevioletred: "db7093", papayawhip: "ffefd5", peachpuff: "ffdab9", peru: "cd853f", pink: "ffc0cb", plum: "dda0dd", powderblue: "b0e0e6", purple: "800080", rebeccapurple: "663399", red: "f00", rosybrown: "bc8f8f", royalblue: "4169e1", saddlebrown: "8b4513", salmon: "fa8072", sandybrown: "f4a460", seagreen: "2e8b57", seashell: "fff5ee", sienna: "a0522d", silver: "c0c0c0", skyblue: "87ceeb", slateblue: "6a5acd", slategray: "708090", slategrey: "708090", snow: "fffafa", springgreen: "00ff7f", steelblue: "4682b4", tan: "d2b48c", teal: "008080", thistle: "d8bfd8", tomato: "ff6347", turquoise: "40e0d0", violet: "ee82ee", wheat: "f5deb3", white: "fff", whitesmoke: "f5f5f5", yellow: "ff0", yellowgreen: "9acd32" }; // Make it easy to access colors via `hexNames[hex]` var hexNames = tinycolor.hexNames = flip(names); // Utilities // --------- // `{ 'name1': 'val1' }` becomes `{ 'val1': 'name1' }` function flip(o) { var flipped = { }; for (var i in o) { if (o.hasOwnProperty(i)) { flipped[o[i]] = i; } } return flipped; } // Return a valid alpha value [0,1] with all invalid values being set to 1 function boundAlpha(a) { a = parseFloat(a); if (isNaN(a) || a < 0 || a > 1) { a = 1; } return a; } // Take input from [0, n] and return it as [0, 1] function bound01(n, max) { if (isOnePointZero(n)) { n = "100%"; } var processPercent = isPercentage(n); n = mathMin(max, mathMax(0, parseFloat(n))); // Automatically convert percentage into number if (processPercent) { n = parseInt(n * max, 10) / 100; } // Handle floating point rounding errors if ((Math.abs(n - max) < 0.000001)) { return 1; } // Convert into [0, 1] range if it isn't already return (n % max) / parseFloat(max); } // Force a number between 0 and 1 function clamp01(val) { return mathMin(1, mathMax(0, val)); } // Parse a base-16 hex value into a base-10 integer function parseIntFromHex(val) { return parseInt(val, 16); } // Need to handle 1.0 as 100%, since once it is a number, there is no difference between it and 1 // function isOnePointZero(n) { return typeof n == "string" && n.indexOf('.') != -1 && parseFloat(n) === 1; } // Check to see if string passed in is a percentage function isPercentage(n) { return typeof n === "string" && n.indexOf('%') != -1; } // Force a hex value to have 2 characters function pad2(c) { return c.length == 1 ? '0' + c : '' + c; } // Replace a decimal with it's percentage value function convertToPercentage(n) { if (n <= 1) { n = (n * 100) + "%"; } return n; } // Converts a decimal to a hex value function convertDecimalToHex(d) { return Math.round(parseFloat(d) * 255).toString(16); } // Converts a hex value to a decimal function convertHexToDecimal(h) { return (parseIntFromHex(h) / 255); } var matchers = (function() { // var CSS_INTEGER = "[-\\+]?\\d+%?"; // var CSS_NUMBER = "[-\\+]?\\d*\\.\\d+%?"; // Allow positive/negative integer/number. Don't capture the either/or, just the entire outcome. var CSS_UNIT = "(?:" + CSS_NUMBER + ")|(?:" + CSS_INTEGER + ")"; // Actual matching. // Parentheses and commas are optional, but not required. // Whitespace can take the place of commas or opening paren var PERMISSIVE_MATCH3 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?"; var PERMISSIVE_MATCH4 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?"; return { CSS_UNIT: new RegExp(CSS_UNIT), rgb: new RegExp("rgb" + PERMISSIVE_MATCH3), rgba: new RegExp("rgba" + PERMISSIVE_MATCH4), hsl: new RegExp("hsl" + PERMISSIVE_MATCH3), hsla: new RegExp("hsla" + PERMISSIVE_MATCH4), hsv: new RegExp("hsv" + PERMISSIVE_MATCH3), hsva: new RegExp("hsva" + PERMISSIVE_MATCH4), hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/, hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/, hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/, hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/ }; })(); // `isValidCSSUnit` // Take in a single string / number and check to see if it looks like a CSS unit // (see `matchers` above for definition). function isValidCSSUnit(color) { return !!matchers.CSS_UNIT.exec(color); } // `stringInputToObject` // Permissive string parsing. Take in a number of formats, and output an object // based on detected format. Returns `{ r, g, b }` or `{ h, s, l }` or `{ h, s, v}` function stringInputToObject(color) { color = color.replace(trimLeft,'').replace(trimRight, '').toLowerCase(); var named = false; if (names[color]) { color = names[color]; named = true; } else if (color == 'transparent') { return { r: 0, g: 0, b: 0, a: 0, format: "name" }; } // Try to match string input using regular expressions. // Keep most of the number bounding out of this function - don't worry about [0,1] or [0,100] or [0,360] // Just return an object and let the conversion functions handle that. // This way the result will be the same whether the tinycolor is initialized with string or object. var match; if ((match = matchers.rgb.exec(color))) { return { r: match[1], g: match[2], b: match[3] }; } if ((match = matchers.rgba.exec(color))) { return { r: match[1], g: match[2], b: match[3], a: match[4] }; } if ((match = matchers.hsl.exec(color))) { return { h: match[1], s: match[2], l: match[3] }; } if ((match = matchers.hsla.exec(color))) { return { h: match[1], s: match[2], l: match[3], a: match[4] }; } if ((match = matchers.hsv.exec(color))) { return { h: match[1], s: match[2], v: match[3] }; } if ((match = matchers.hsva.exec(color))) { return { h: match[1], s: match[2], v: match[3], a: match[4] }; } if ((match = matchers.hex8.exec(color))) { return { r: parseIntFromHex(match[1]), g: parseIntFromHex(match[2]), b: parseIntFromHex(match[3]), a: convertHexToDecimal(match[4]), format: named ? "name" : "hex8" }; } if ((match = matchers.hex6.exec(color))) { return { r: parseIntFromHex(match[1]), g: parseIntFromHex(match[2]), b: parseIntFromHex(match[3]), format: named ? "name" : "hex" }; } if ((match = matchers.hex4.exec(color))) { return { r: parseIntFromHex(match[1] + '' + match[1]), g: parseIntFromHex(match[2] + '' + match[2]), b: parseIntFromHex(match[3] + '' + match[3]), a: convertHexToDecimal(match[4] + '' + match[4]), format: named ? "name" : "hex8" }; } if ((match = matchers.hex3.exec(color))) { return { r: parseIntFromHex(match[1] + '' + match[1]), g: parseIntFromHex(match[2] + '' + match[2]), b: parseIntFromHex(match[3] + '' + match[3]), format: named ? "name" : "hex" }; } return false; } function validateWCAG2Parms(parms) { // return valid WCAG2 parms for isReadable. // If input parms are invalid, return {"level":"AA", "size":"small"} var level, size; parms = parms || {"level":"AA", "size":"small"}; level = (parms.level || "AA").toUpperCase(); size = (parms.size || "small").toLowerCase(); if (level !== "AA" && level !== "AAA") { level = "AA"; } if (size !== "small" && size !== "large") { size = "small"; } return {"level":level, "size":size}; } // Node: Export function if (typeof module !== "undefined" && module.exports) { module.exports = tinycolor; } // AMD/requirejs: Define the module else if (typeof define === 'function' && define.amd) { define(function () {return tinycolor;}); } // Browser: Expose to window else { window.tinycolor = tinycolor; } })(Math); },{}],379:[function(require,module,exports){ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.trimCanvas=t():e.trimCanvas=t()}(this,function(){return function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={exports:{},id:n,loaded:!1};return e[n].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t){"use strict";function r(e){var t=e.getContext("2d"),r=e.width,n=e.height,o=t.getImageData(0,0,r,n).data,f=a(!0,r,n,o),i=a(!1,r,n,o),c=u(!0,r,n,o),d=u(!1,r,n,o),p=d-c+1,l=i-f+1,s=t.getImageData(c,f,p,l);return e.width=p,e.height=l,t.clearRect(0,0,p,l),t.putImageData(s,0,0),e}function n(e,t,r,n){return{red:n[4*(r*t+e)],green:n[4*(r*t+e)+1],blue:n[4*(r*t+e)+2],alpha:n[4*(r*t+e)+3]}}function o(e,t,r,o){return n(e,t,r,o).alpha}function a(e,t,r,n){for(var a=e?1:-1,u=e?0:r-1,f=u;e?f-1;f+=a)for(var i=0;i-1;f+=a)for(var i=0;i