UNPKG

aid.js

Version:

A Bundle of Javascript util Library to help developers. No dependency to other Libraries.

10 lines (9 loc) 48.9 kB
/* * aid.js 0.1.96 * https://www.npmjs.com/package/aid.js * * The MIT License (MIT) * Copyright (c) 2016-2019 Hyun-Seok.Kim, dragmove@gmail.com */ !function(){"use strict";var f="object"==typeof self&&self.self===self&&self||"object"==typeof f&&f.global===f&&f||this||{},w=Array.prototype.slice,c=Object.prototype.hasOwnProperty,b={},e={},t={},r={},a={},n={},i={},v={},h={},o={},u={},s={},p={};function l(){}b.existy=function(e){return null!=e},b.isDefined=function(e){return null!=e},b.isBoolean=function(e){return!!b.isDefined(e)&&e.constructor===Boolean},b.isNumber=function(e){return!!b.isDefined(e)&&(!isNaN(e)&&e.constructor===Number)},b.isInteger=function(e){return!!b.isNumber(e)&&(isFinite(e)&&Math.floor(e)===e)},b.isString=function(e){return!!b.isDefined(e)&&e.constructor===String},b.isArray=function(e){return!!b.isDefined(e)&&e.constructor===Array},b.isObject=function(e){return!!b.isDefined(e)&&e.constructor===Object},b.isFunction=function(e){return!!b.isDefined(e)&&e.constructor===Function},b.isRegExp=function(e){return!!b.isDefined(e)&&e.constructor===RegExp},b.isError=function(e,t){if(!b.isDefined(e))return!1;var r=e.constructor;return b.isDefined(t)?r===t:!(!window.InternalError||r!==window.InternalError)||(r===Error||r===EvalError||r===RangeError||r===ReferenceError||r===SyntaxError||r===TypeError||r===URIError)},b.isElement=function(e){return b.isDefined(e)&&"object"==typeof e&&1===e.nodeType&&e instanceof Node},b.extend=function(e,t){if(!(e instanceof Object)||"object"!=typeof e)throw new TypeError("[aid.extend] Type of destination parameter must be instance of Object, and object.");if("object"!=typeof t)throw new TypeError("[aid.extend] Type of source parameter must be Object.");for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r]);return e},b.inherit=function(e,t){l.prototype=t.prototype,e.prototype=new l,(e.prototype.constructor=e).super=t.prototype},b.namespace=function(e,t){if(!b.isString(e))throw new TypeError("[aid.namespace] Type of namespace parameter must be String.");if(!b.isObject(t)&&b.isDefined(t))throw new TypeError("[aid.namespace] Type of parent parameter must be Object or null or undefined.");var r=t||f;e&&e.split(".").forEach(function(e){r[e]||(r[e]={}),r=r[e]});return r},b.memoize=function(i,o){if(!b.isFunction(i))throw new TypeError("[aid.memoize] Type of func parameter must be Function.");if(b.isDefined(o)&&!b.isFunction(o))throw new TypeError("[aid.memoize] Type of hasher parameter must be undefined or null or Function.");var a=function(e){var t=a.cache,r=o?o.apply(null,w.call(arguments)):e;if(t.has(r))return t.get(r);var n=i.apply(null,w.call(arguments));return t.set(r,n),n};return a.cache=b.createDictionary(),a},b.borrow=function(e,t,r){if(!b.isObject(e)||!b.isObject(t))throw new TypeError("[aid.borrow] Type of borrower, donor parameters must be Object.");if(!b.isString(r))throw new TypeError("[aid.borrow] Type of funcName parameter must be String.");if(!b.isDefined(t[r]))throw new Error("[aid.borrow] donor object parameter has not function with funcName parameter.");if(b.isDefined(e[r]))throw new Error("[aid.borrow] borrower object parameter already has function with funcName parameter.");e[r]=function(){var e=w.call(arguments);return t[r].apply(this,e)}},b.bind=function(e,t){if(!b.isFunction(e))throw new TypeError("[aid.bind] Type of func parameter must be Function.");return function(){return e.apply(t,arguments)}},b.compose=function(e,t){if(!b.isFunction(e)||!b.isFunction(t))throw new TypeError("[aid.compose] Type of func_a, func_b parameters must be Function.");return function(){return e(t.apply(null,arguments))}},b.not=function(e){if(!b.isFunction(e))throw new TypeError("[aid.not] Type of func parameter must be Function.");return function(){return!e.apply(null,arguments)}},b.each=function(e,t,r){if(!b.isArray(e)&&!b.isString(e))throw new TypeError("[aid.each] Type of iterable parameter must be Array or String.");for(var n=b.existy(r)?r:null,i=0,o=e.length;i<o;i++)t.call(n,e[i])},b.truthy=function(e){return!!e},b.falsy=function(e){return!e},b.nth=function(e,t){if(!b.isArray(e)&&!b.isString(e))throw new TypeError("[aid.nth] Type of iterable parameter must be Array or String.");if(!b.isInteger(t))throw new TypeError("[aid.nth] Type of index parameter must be Integer Number.");return t<0||t>e.length-1?null:e[t]},b.allOf=function(){return w.call(arguments).every(function(e){return!0===e})},b.anyOf=function(){return w.call(arguments).some(function(e){return!0===e})},b.constant=function(e){return function(){return e}},b.plucker=function(t){if(!b.isString(t)&&!b.isNumber(t))throw new TypeError("[aid.plucker] Type of field parameter must be String or Number.");return function(e){if(!(b.isObject(e)||b.isArray(e)||b.isString(e)))throw new TypeError("[aid.plucker] Type of obj parameter must be Object or Array or String.");return e[t]}},b.best=function(r,e){if(!b.isFunction(r))throw new TypeError("[aid.best] Type of conditionFunc parameter must be Function.");if(!b.isArray(e))throw new TypeError("[aid.best] Type of array parameter must be Array.");return e.reduce(function(e,t){return r(e,t)?e:t})},b.iterateUntil=function(e,t,r){if(!b.isFunction(e))throw new TypeError("[aid.iterateUntil] Type of calculateFunc parameter must be Function.");if(!b.isFunction(t))throw new TypeError("[aid.iterateUntil] Type of conditionFunc parameter must be Function.");for(var n=[],i=e(r);t(i);)n.push(i),i=e(i);return n},b.curry=function(t){if(!b.isFunction(t))throw new TypeError("[aid.curry] Type of func parameter must be Function.");return function(e){return t(e)}},b.curry2=function(r){if(!b.isFunction(r))throw new TypeError("[aid.curry2] Type of func parameter must be Function.");return function(t){return function(e){return r(e,t)}}},b.curryAll=function(e,t){if(!b.isFunction(e))throw new TypeError("[aid.curryAll] Type of func parameter must be Function.");var i=t||e.length;return function t(){var r=w.call(arguments),n=this;return r.length>=i?e.apply(n,r):function(){var e=w.call(arguments);return t.apply(n,r.concat(e))}}},b.reverseArgs=function(t){if(!b.isFunction(t))throw new TypeError("[aid.reverseArgs] Type of func parameter must be Function.");return function(){var e=w.call(arguments);return t.apply(null,e.concat().reverse())}},b.partial=function(e){if(!b.isFunction(e))throw new TypeError("[aid.partial] Type of func parameter must be Function.");var t=b.rest(w.call(arguments));return function(){return e.apply(e,t.concat(w.call(arguments)))}},b.partialRight=function(e){if(!b.isFunction(e))throw new TypeError("[aid.partialRight] Type of func parameter must be Function.");var t=b.rest(w.call(arguments));return function(){return e.apply(null,w.call(arguments).concat(t))}},b.rest=function(e,t){if(!b.isArray(e))throw new TypeError("[aid.rest] Type of array parameter must be Array.");var r=b.existy(t)?t:1;return w.call(e,r)},b.pipeline=function(e){var t=b.rest(w.call(arguments));return b.each(t,function(e){if(!b.isFunction(e))throw new TypeError("[aid.pipeline] Type of rest parameters must be Function.")},null),t.reduce(function(e,t){return t(e)},e)},b.lazyChain=function(e){var t=[];return{invoke:function(r){var n=b.rest(w.call(arguments));return t.push(function(e){var t=e[r];if(!b.isDefined(t))throw Error("[aid.lazyChain] "+e.constructor.name+" has not "+r+" method.");return t.apply(e,n)}),this},force:function(){return t.reduce(function(e,t){return t(e)},e)}}},b.eq=b.curry2(function(e,t){return e===t}),b.identity=function(e){return e},b.tab=function(t){if(!b.isFunction(t))throw new TypeError("[aid.tab] Type of func parameter must be Function.");return function(e){return t(e),e}},b.alt=function(r,n){if(!b.isFunction(r)||!b.isFunction(n))throw new TypeError("[aid.alt] Type of func_a, func_b parameters must be Function.");return function(e){var t=r(e);return b.isDefined(t)&&!1!==t?t:n(e)}},b.seq=function(){var e=w.call(arguments);return e.forEach(function(e){if(!b.isFunction(e))throw new TypeError("[aid.seq] Requires function parameters.")}),function(t){e.forEach(function(e){e.call(null,t)})}},b.fork=function(t,r,n){if(!b.isFunction(t)||!b.isFunction(r)||!b.isFunction(n))throw new TypeError("[aid.fork] Type of join, func_a, func_b parameters must be Function.");return function(e){return t.call(null,r.call(null,e),n.call(null,e))}};function d(){this._dataStore=[],this._top=0}d.prototype.push=function(e){this._top<0&&(this._top=0),this._dataStore[this._top++]=e},d.prototype.pop=function(){return this._dataStore[--this._top]},d.prototype.peek=function(){return this._dataStore[this._top-1]},d.prototype.length=function(){return 0<this._top?this._top:0},d.prototype.clear=function(){this._dataStore=[],this._top=0},b.createStack=function(){return new d};function y(){this._dataStore=[]}y.prototype.enqueue=function(e){this._dataStore.push(e)},y.prototype.dequeue=function(){return this._dataStore.shift()},y.prototype.front=function(){return this._dataStore[0]},y.prototype.rear=function(){return this._dataStore[this._dataStore.length-1]},y.prototype.length=function(){return this._dataStore.length},y.prototype.isEmpty=function(){return this._dataStore.length<=0},b.createQueue=function(){return new y};function m(e){this.data=e,this.next=null}function g(){this.head=new m("LinkedListHead_"+Date.now())}g.prototype.getHead=function(){return this.head},g.prototype.isEmpty=function(){return!this.head.next},g.prototype.find=function(e){for(var t=this.head;t.data!==e;)if(!(t=t.next))return t;return t},g.prototype.findPrevious=function(e){if(this.head.data===e)return null;for(var t=this.head;t.next&&t.next.data!==e;)t=t.next;return t},g.prototype.insert=function(e,t){var r=this.find(t);if(!r)return!1;var n=new m(e);return n.next=r.next,r.next=n,!0},g.prototype.remove=function(e){var t=this.findPrevious(e);return!(!t||!t.next)&&(t.next=t.next.next,!0)},g.prototype.append=function(e){for(var t=new m(e),r=this.head;r.next;)r=r.next;r.next=t},g.prototype.getAllNodes=function(){for(var e=[this.head],t=this.head;t.next;)e.push(t.next),t=t.next;return e},b.createLinkedList=function(){return new g};function T(){this.store=[]}T.prototype.size=function(){return this.store.length},T.prototype.add=function(e){return!this.has(e)&&(this.store.push(e),!0)},T.prototype.remove=function(e){var t=this.store.indexOf(e);return 0<=t&&(this.store.splice(t,1),!0)},T.prototype.clear=function(){this.store=[]},T.prototype.has=function(e){return 0<=this.store.indexOf(e)},T.prototype.values=function(){return this.store},T.prototype.union=function(e){var t=new T;return this.values().forEach(function(e){t.add(e)}),e.values().forEach(function(e){t.add(e)}),t},T.prototype.intersection=function(t){var r=new T;return this.values().forEach(function(e){t.has(e)&&r.add(e)}),r},T.prototype.difference=function(t){var r=new T;return this.values().forEach(function(e){t.has(e)||r.add(e)}),r},T.prototype.isSubset=function(t){return!(this.size()>t.size())&&this.values().every(function(e){return t.has(e)})},b.createSet=function(){return new T};function E(e){this.table=[],this._hashFunc=b.isFunction(e)?e:this._djb2Hash}function x(){this.items={}}E.prototype.put=function(e,t){var r=this._hashFunc.call(null,e);void 0===this.table[r]&&(this.table[r]=b.createLinkedList()),this.table[r].append({key:e,value:t})},E.prototype.get=function(e){var t=this._hashFunc.call(null,e),r=this.table[t];if(r){var n=r.getHead();if(!n.next)return;for(var i=n;i&&i.data&&i.data.key!==e;)i=i.next;if(i&&i.data)return i.data.value}},E.prototype.remove=function(e){var t=this._hashFunc.call(null,e),r=this.table[t];if(r){var n=r.getHead();if(!n.next)return!1;for(var i=n;i.next&&i.next.data&&i.next.data.key!==e;)i=i.next;if(i&&i.next)return i.next=i.next.next,r.isEmpty()&&(this.table[t]=void 0),!0}return!1},E.prototype._djb2Hash=function(e){for(var t=5381,r=0,n=e.length;r<n;r++)t=33*t+e.charCodeAt(r);return t%1013},b.createHashTable=function(e){return new E(e)},x.prototype.has=function(e){return c.call(this.items,e)},x.prototype.get=function(e){return this.has(e)?this.items[e]:void 0},x.prototype.set=function(e,t){this.items[e]=t},x.prototype.remove=function(e){return!!this.has(e)&&(delete this.items[e],!0)},x.prototype.clear=function(){this.items={}},x.prototype.keys=function(){return Object.keys(this.items)},x.prototype.values=function(){var e=[];for(var t in this.items)this.has(t)&&e.push(this.items[t]);return e},x.prototype.size=function(){return Object.keys(this.items).length},x.prototype.getItems=function(){return this.items},b.createDictionary=function(){return new x};function S(e){this.data=e,this.left=null,this.right=null}function F(){this.root=null}function O(){this.vertices=[],this.adjacencyList=b.createDictionary()}F.prototype._insertNode=function(e,t){if(!b.isDefined(e)||!b.isDefined(t))throw new TypeError("[BinarySearchTree.prototype._insertNode] node and newNode parameters must be defined.");e.data!==t.data&&(t.data<e.data?b.isDefined(e.left)?this._insertNode(e.left,t):e.left=t:b.isDefined(e.right)?this._insertNode(e.right,t):e.right=t)},F.prototype._searchNode=function(e,t){if(!b.isDefined(e))return!1;if(!b.isDefined(t))throw new TypeError("[BinarySearchTree.prototype._searchNode] data parameters must be defined.");return t<e.data?this._searchNode(e.left,t):!(t>e.data)||this._searchNode(e.right,t)},F.prototype._findMinNode=function(e){if(!b.isDefined(e))return null;for(;e&&b.isDefined(e.left);)e=e.left;return e},F.prototype._removeNode=function(e,t){if(!b.isDefined(t))throw new TypeError("[BinarySearchTree.prototype._removeNode] data parameters must be defined.");if(!b.isDefined(e))return null;if(t<e.data)return e.left=this._removeNode(e.left,t),e;if(t>e.data)return e.right=this._removeNode(e.right,t),e;if(!b.isDefined(e.left)&&!b.isDefined(e.right))return e=null;if(!b.isDefined(e.left))return e=e.right;if(!b.isDefined(e.right))return e=e.left;var r=this._findMinNode(e.right);return e.data=r.data,e.right=this._removeNode(e.right,r.data),e},F.prototype._minNode=function(e){if(!b.isDefined(e))return null;for(;e&&b.isDefined(e.left);)e=e.left;return e.data},F.prototype._maxNode=function(e){if(!b.isDefined(e))return null;for(;e&&b.isDefined(e.right);)e=e.right;return e.data},F.prototype._inOrderTraverseNode=function(e,t){if(!b.isFunction(t))throw new TypeError("[BinarySearchTree.prototype._inOrderTraverseNode] Type of callback parameter must be Function.");b.isDefined(e)&&(this._inOrderTraverseNode(e.left,t),t(e.data),this._inOrderTraverseNode(e.right,t))},F.prototype._preOrderTraverseNode=function(e,t){if(!b.isFunction(t))throw new TypeError("[BinarySearchTree.prototype._preOrderTraverseNode] Type of callback parameter must be Function.");b.isDefined(e)&&(t(e.data),this._preOrderTraverseNode(e.left,t),this._preOrderTraverseNode(e.right,t))},F.prototype._postOrderTraverseNode=function(e,t){if(!b.isFunction(t))throw new TypeError("[BinarySearchTree.prototype._postOrderTraverseNode] Type of callback parameter must be Function.");b.isDefined(e)&&(this._postOrderTraverseNode(e.left,t),this._postOrderTraverseNode(e.right,t),t(e.data))},F.prototype.getRoot=function(){return this.root},F.prototype.insert=function(e){if(!b.isDefined(e))throw new TypeError("[BinarySearchTree.prototype.insert] data parameter must be defined.");var t=new S(e);b.isDefined(this.root)?this._insertNode(this.root,t):this.root=t},F.prototype.search=function(e){if(!b.isDefined(e))throw new TypeError("[BinarySearchTree.prototype.search] data parameter must be defined.");return this._searchNode(this.root,e)},F.prototype.remove=function(e){if(!b.isDefined(e))throw new TypeError("[BinarySearchTree.prototype.remove] data parameter must be defined.");this.root=this._removeNode(this.root,e)},F.prototype.min=function(){return this._minNode(this.root)},F.prototype.max=function(){return this._maxNode(this.root)},F.prototype.inOrderTraverse=function(e){if(!b.isFunction(e))throw new TypeError("[BinarySearchTree.prototype.inOrderTraverse] Type of callback parameter must be Function.");this._inOrderTraverseNode(this.root,e)},F.prototype.preOrderTraverse=function(e){if(!b.isFunction(e))throw new TypeError("[BinarySearchTree.prototype.preOrderTraverse] Type of callback parameter must be Function.");this._preOrderTraverseNode(this.root,e)},F.prototype.postOrderTraverse=function(e){if(!b.isFunction(e))throw new TypeError("[BinarySearchTree.prototype.postOrderTraverse] Type of callback parameter must be Function.");this._postOrderTraverseNode(this.root,e)},b.createBinarySearchTree=function(){return new F},O.prototype.addVertex=function(e){if(0<=v.indexOf(this.vertices,e))throw new Error("[Graph.prototype.addVertex] this.vertices already has the same vertex.");this.vertices.push(e),this.adjacencyList.set(e,[])},O.prototype.addEdge=function(e,t){if(v.indexOf(this.vertices,e)<0)throw new Error("[Graph.prototype.addEdge] this.vertices has not fromVertex.");if(v.indexOf(this.vertices,t)<0)throw new Error("[Graph.prototype.addEdge] this.vertices has not toVertex.");this.adjacencyList.get(e).push(t),this.adjacencyList.get(t).push(e)},O.prototype.bfs=function(e,t){if(v.indexOf(this.vertices,e)<0)throw new Error("[Graph.prototype.bfs] this.vertices has not fromVertex.");var r=this.adjacencyList.get(e);if(!r||r.length<=0)throw new Error("[Graph.prototype.bfs] fromVertex is not connected to any vertices.");if(b.isDefined(t)&&!b.isFunction(t))throw new TypeError("[Graph.prototype.bfs] Type of callback parameter must be undefined or null or Function.");var n={},i={},o={},a=new b.createQueue;for(this.vertices.forEach(function(e){n[e]="white",i[e]=0,o[e]=null}),a.enqueue(e);!a.isEmpty();){var u=a.dequeue(),s=this.adjacencyList.get(u);n[u]="grey",s.forEach(function(e){"white"===n[e]&&(n[e]="grey",i[e]=i[u]+1,o[e]=u,a.enqueue(e))}),n[u]="black",t&&t.call(null,u)}return{distances:i,predecessors:o}},O.prototype.getBfsPaths=function(o){var e=this.adjacencyList.get(o);if(!e||e.length<=0)throw new Error("[Graph.prototype.getBfsPaths] fromVertex is not connected to any vertices.");var a=[],u=this.bfs(o);return this.vertices.filter(function(e){return e!==o}).forEach(function(e){for(var t=b.createStack(),r=e;r!==o;r=u.predecessors[r])t.push(r);t.push(o);for(var n=t.length()-1,i=t.pop();t.length();)i+=" - "+t.pop();a.push({path:i,edgesNum:n})}),a},O.prototype.dfs=function(e,t){if(v.indexOf(this.vertices,e)<0)throw new Error("[Graph.prototype.dfs] this.vertices has not fromVertex.");if(b.isDefined(t)&&!b.isFunction(t))throw new TypeError("[Graph.prototype.dfs] Type of callback parameter must be undefined or null or Function.");var r={time:0,colors:{},discovered:{},finished:{},predecessors:{}};return this.vertices.forEach(function(e){r.colors[e]="white",r.discovered[e]=0,r.finished[e]=0,r.predecessors[e]=null}),this._dfsVisit(e,r,t),r},O.prototype._dfsVisit=function(t,r,n){var i=this,o=r.colors,e=r.discovered,a=r.finished,u=r.predecessors;o[t]="grey",e[t]=++r.time,n&&n.call(null,t),this.adjacencyList.get(t).forEach(function(e){"white"===o[e]&&(u[e]=t,i._dfsVisit(e,r,n))}),o[t]="black",a[t]=++r.time},b.createGraph=function(){return new O},e["+"]=function(e,t){return e+t},e["==="]=function(e,t){return e===t},e["!"]=function(e){return!e},t.isWindow=function(e){return/Windows/i.test(e)},t.isMac=function(e){return/Macintosh/i.test(e)},t.isIOS=function(e){return/iPad|iPhone|iPod/.test(e)&&!f.MSStream},t.isIPhone=function(e){return!!t.isIOS(e)&&/iPhone/.test(e)},t.isIPad=function(e){return!!t.isIOS(e)&&/iPad/.test(e)},t.isAndroid=function(e){return/Android/.test(e)},r.isIE=function(e){return/msie/.test(e)||/trident/.test(e)},r.isEdge=function(e){return/Gecko/.test(e)&&/Edge/.test(e)},r.isFF=function(e){return/Firefox/.test(e)},r.isOpera=function(e){return/Opera/.test(e)||/OPR\//.test(e)},r.isChrome=function(e){return!t.isAndroid(e)&&!t.isIOS(e)&&(!r.isEdge(e)&&!r.isOpera(e)&&/Chrome/.test(e))},r.isChromePhone=function(e){return t.isIPhone(e)?!/Chrome/.test(e)&&/Safari/.test(e)&&/CriOS/.test(e)&&/Mobile/.test(e):!!t.isAndroid(e)&&(/Chrome\/[.0-9]* Mobile/.test(e)&&/Safari/i.test(e))},r.isChromeTablet=function(e){return t.isIPad(e)?!/Chrome/.test(e)&&/Safari/.test(e)&&/CriOS/.test(e)&&/Mobile/.test(e):!!t.isAndroid(e)&&(/Chrome\/[.0-9]* (?!Mobile)/.test(e)&&/Safari/i.test(e))},r.isSafari=function(e){return!t.isIOS(e)&&(!/Chrome/.test(e)&&/Safari/.test(e)&&!/CriOS/.test(e)&&!/Mobile/.test(e))},r.isSafariPhone=function(e){return!!t.isIPhone(e)&&(!/Chrome/.test(e)&&/Safari/.test(e)&&!/CriOS/.test(e)&&/Mobile/.test(e))},r.isSafariTablet=function(e){return!!t.isIPad(e)&&(!/Chrome/.test(e)&&/Safari/.test(e)&&!/CriOS/.test(e)&&/Mobile/.test(e))},r.getIEVersion=function(e){if(r.isIE(e)){if(/msie (\d+\.\d+);/i.test(e))return parseFloat(RegExp.$1,10);if(/trident.*rv:(\d+)\.(\d+)/i.test(e))return parseFloat(RegExp.$1,10)}return-1},r.getFFVersion=function(e){return r.isFF(e)&&/Firefox[\/\s](\d+\.\d+)/i.test(e)?parseFloat(RegExp.$1,10):-1},r.getOperaVersion=function(e){if(r.isOpera(e)){if(/Opera/i.test(e)){if(/Version[\/\s](\d+\.\d+)/i.test(e))return parseFloat(RegExp.$1,10);if(/Opera[\/\s](\d+\.\d+)/i.test(e))return parseFloat(RegExp.$1,10)}if(/OPR[\/\s](\d+\.\d+)/i.test(e))return parseFloat(RegExp.$1,10)}return-1},r.getChromeVersion=function(e){return r.isChrome(e)&&/Chrome[\/\s](\d+\.\d+)/i.test(e)?parseFloat(RegExp.$1,10):-1},r.getSafariVersion=function(e){return r.isSafari(e)&&/Version[\/\s](\d+\.\d+)/i.test(e)?parseFloat(RegExp.$1,10):-1},r.getIECompatibility=function(e){var t=e||f.navigator.userAgent.toLowerCase(),r=/msie/i,n=/msie 7/i,i=/rv:11[\.0-9]{0,}/,o=/trident\/7/;if(!r.test(t)&&!i.test(t))return{isIE:!1,isCompatibilityMode:!1,compatibilityVersion:-1};if(i.test(t)&&o.test(t))return{isIE:!0,isCompatibilityMode:!1,compatibilityVersion:-1};if(r.test(t)&&o.test(t)){if(n.test(t))return{isIE:!0,isCompatibilityMode:!0,compatibilityVersion:7};if(/msie 8/i.test(t))return{isIE:!0,isCompatibilityMode:!0,compatibilityVersion:8};if(/msie 9/i.test(t))return{isIE:!0,isCompatibilityMode:!0,compatibilityVersion:9};if(/msie 10/i.test(t))return{isIE:!0,isCompatibilityMode:!0,compatibilityVersion:10}}return n.test(t)&&/trident/i.test(t)?{isIE:!0,isCompatibilityMode:!0,compatibilityVersion:7}:{isIE:!0,isCompatibilityMode:!1,compatibilityVersion:-1}},r.isSupportDraggable=function(){return"draggable"in document.createElement("div")},r.isSupportDragAndDrop=function(){var e=document.createElement("div");return"ondragstart"in e&&"ondrop"in e},r.isSupportFileApi=function(){return!!(f.File&&f.FileReader&&f.FileList&&f.Blob)},r.isChromeExtension=function(e){return!(!r.isChrome(e)||!f.chrome)&&(f.chrome.cookies||f.chrome.experimental&&(f.chrome.cookies=f.chrome.experimental.cookies),!!f.chrome.cookies)},r.canUseDOM=function(){return b.truthy("undefined"!=typeof window&&window.document&&window.document.createElement)},r.getCookie=function(e){for(var t=document.cookie.split("; "),r=[],n="",i="",o=0,a=t.length;o<a;++o)if(n=(r=t[o].split("="))[0],i=f.decodeURIComponent(r[1]),n===e)return i;return null},r.setCookie=function(e,t,r,n,i){var o="",a="; path="+(n||"/"),u=i?"; domain="+i:"";if(r){var s=new Date;s.setTime(s.getTime()+1e3*r),o="; expires="+s.toGMTString()}document.cookie=e+"="+f.encodeURIComponent(t)+a+u+o},a.trim=function(e){if(!b.isString(e))throw new TypeError("[aid.string.trim] Type of str parameter must be String.");return e.replace(/^\s+/,"").replace(/\s+$/,"")},a.hasUniqueChars=function(e){if(!b.isString(e))throw new TypeError("[aid.string.hasUniqueChars] Type of str parameter must be String.");if(!e.length)return!0;for(var t={},r="",n=0,i=e.length;n<i;n++){if(!0===t[r=e.charAt(n)])return!1;t[r]=!0}return!0},a.getFileExtension=function(e){if(!b.isString(e))throw new TypeError("[aid.string.getFileExtension] Type of fileName parameter must be String.");if(e.length<=0)return"";var t=e.lastIndexOf(".");return e.substr(t+1)},a.isEmail=function(e){if(!b.isString(e))throw new TypeError("[aid.string.isEmail] Type of email parameter must be String.");return!!new RegExp("^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$").exec(e)},a.isIFrame=function(e){if(!b.isString(e))throw new TypeError("[aid.string.isIFrame] Type of iframeHtml parameter must be String.");return/^(<iframe).*(<\/iframe>|\/>)$/.test(e)},a.getUriParam=function(e,t){if(!b.isString(e)||!b.isString(t))throw new TypeError("[aid.string.getUriParam] Type of uri, parameterName parameters must be String.");if(e.length<1)return"";var r=(e=e.split("#")[0]).split("?");if(r.length<2)return"";for(var n=r[1].split("&"),i="",o=-1,a="",u="",s=0,f=n.length;s<f;++s)if(0<=(o=(i=n[s]).indexOf("="))&&(a=i.substr(0,o),u=i.substr(o+1),a===t))return u;return""},a.getUriParams=function(e){if(!b.isString(e))throw new TypeError("[aid.string.getUriParam] Type of uri parameter must be String.");if(e.length<1)return null;var t=(e=e.split("#")[0]).split("?");if(t.length<2)return null;var r=t[1].split("&");if(r.length<=0)return null;for(var n={},i="",o=-1,a="",u="",s=0,f=r.length;s<f;++s)0<=(o=(i=r[s]).indexOf("="))&&(a=i.substr(0,o),u=i.substr(o+1),a&&(n[a]=u));return b.object.isEmpty(n)?null:n},a.getUriCombinedParams=function(e,t){if(!b.isString(e))throw new TypeError("[aid.string.getUriCombinedParams] Type of uri parameter must be String.");if(!b.isObject(t))throw new TypeError("[aid.string.getUriCombinedParams] Type of parameters parameter must be Object.");if(!e)return"";if(!t)return e;var r="";for(var n in t)c.call(t,n)&&(r+="&"+n+"="+String(t[n]));if(""===r)return e;var i=e.split("#"),o=b.isDefined(i[1])&&i[1].length?"#"+i[1]:"";return e=(0<=(e=i[0]).indexOf("?")?e+r:e+"?"+r.substr(1))+o},a.isValidYoutubeVideoId=function(e){if(!b.isString(e))throw new TypeError("[aid.string.isValidYoutubeVideoId] Type of youtubeId parameter must be String.");return!!/^(\w|-|_){11}$/.exec(e)},a.getObjCheckYoutubeURI=function(e){if(!b.isString(e))throw new TypeError("[aid.string.getObjCheckYoutubeURI] Type of uri parameter must be String.");var t={watch:/^(?:(?:https?:)?\/\/)?(?:www\.)?youtube\.com\/watch/,embed:/^(?:(?:https?:)?\/\/)?(?:www\.)?youtube\.com\/(?:embed\/((?:\w|-|_){11}))/,v:/^(?:(?:https?:)?\/\/)?(?:www\.)?youtube\.com\/(?:v\/((?:\w|-|_){11}))/,"youtu.be":/^(?:(?:https?:)?\/\/)?(?:www\.)?youtu\.be\/((?:\w|-|_){11})/},r=null;for(var n in t){if(t[n])if(!!t[n].exec(e)){r=n;break}}var i="",o=[];switch(r){case"watch":i=a.getUriParam(e,"v")||"";break;case"embed":case"v":case"youtu.be":i=(o=e.split("?")[0].split("/"))[o.length-1]||""}return{type:"youtube",uri:e,youtubeId:i,isValidURI:""!==i&&a.isValidYoutubeVideoId(i)}},a.getObjCheckTwitchURI=function(e){if(!b.isString(e))throw new TypeError("[aid.string.getObjCheckTwitchURI] Type of uri parameter must be String.");var t={liveChannel:/^(?:(?:https?:)?\/\/)?(?:www\.)?twitch\.tv\/([a-zA-Z0-9][\w]{2,24})$/,liveVideo:/^(?:(?:https?:)?\/\/)?player\.twitch\.tv\/\?channel\=([a-zA-Z0-9][\w]{2,24})$/,chatting:/^(?:(?:https?:)?\/\/)?(?:www\.)?twitch\.tv\/([a-zA-Z0-9][\w]{2,24})\/chat/,pastChannel:/^(?:(?:https?:)?\/\/)?(?:www\.)?twitch\.tv\/([a-zA-Z0-9][\w]{2,24})\/v\/(\d+)/,pastVideo:/^(?:(?:https?:)?\/\/)?player\.twitch\.tv\/\?video\=v(\d+)/},r="",n="",i=!1,o=null;for(var a in t){if(t.hasOwnProperty(a))if(!!t[a].exec(e)){o=a,!0;break}}var u=[];switch(o){case"liveChannel":case"liveVideo":r=(u=t[o].exec(e))[1];break;case"chatting":r=(u=t[o].exec(e))[1],i=!0;break;case"pastChannel":r=(u=t[o].exec(e))[1],n=u[2];break;case"pastVideo":n=(u=t[o].exec(e))[1]}return{type:"twitch",uri:e,channelName:r,videoId:n,isChatting:i,isValidURI:!(!r&&!n)}},a.getDocumentPrefixedProperty=function(e,t){if(!b.isString(e))throw new TypeError("[aid.string.getDocumentPrefixedProperty] Type of propertyName parameter must be String.");if(!b.isBoolean(t))throw new TypeError("[aid.string.getDocumentPrefixedProperty] Type of isPropertyFirstCharToUpperCase parameter must be Boolean.");if(e in f.document)return e;for(var r=["webkit","moz","ms","o"],n=!0===t,i="",o=0,a=r.length;o<a;o++)if(i=n?e.charAt(0).toUpperCase()+e.slice(1):e,(i=r[o]+i)in document)return i;return""},a.getElementPrefixedStyle=function(e,t){if(!b.isString(e))throw new TypeError("[aid.string.getElementPrefixedStyle] Type of propertyName parameter must be String.");if(!b.isBoolean(t))throw new TypeError("[aid.string.getElementPrefixedStyle] Type of isPropertyFirstCharToUpperCase parameter must be Boolean.");var r=f.document.createElement("div").style;if(e in r)return e;for(var n=["webkit","moz","ms","o"],i=!0===t,o="",a=0,u=n.length;a<u;a++)if(o=i?e.charAt(0).toUpperCase()+e.slice(1):e,(o=n[a]+o)in r)return o;return""},a.removeNoContentElements=function(e,t){if(!b.isString(e))throw new TypeError("[aid.string.removeNoContentElements] Type of html parameter must be String.");if(b.isDefined(t)&&!b.isBoolean(t))throw new TypeError("[aid.string.removeNoContentElements] Type of withWhitespaceContent parameter must be Boolean.");if(!e)return"";var r=t?/<([^>]+)>\s*<\/\1>/g:/<([^>]+)><\/\1>/g;return e.replace(r,"")},a.removeNoContentElementsRecursively=function(e,t){if(!b.isString(e))throw new TypeError("[aid.string.removeNoContentElementsRecursively] Type of html parameter must be String.");if(b.isDefined(t)&&!b.isBoolean(t))throw new TypeError("[aid.string.removeNoContentElementsRecursively] Type of withWhitespaceContent parameter must be Boolean.");if(!e)return"";for(var r=t?/<([^>]+)>\s*<\/\1>/g:/<([^>]+)><\/\1>/g,n=e;r.exec(n);)n=a.removeNoContentElements(n,t),r.lastIndex=0;return n},a.absentToEmpty=function(e){return b.existy(e)&&b.isString(e)?e:""},a.numberWithCommas=function(e){if(!b.isInteger(e))throw new TypeError("[aid.string.numberWithCommas] Type of number parameter must be Integer Number.");return e.toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")},a.getPositionFromTranslateStr=function(e){if(!b.isString(e))throw new TypeError("[aid.string.getPositionFromTranslateStr] Type of str parameter must be String.");var t={x:0,y:0};if(!b.isDefined(e))return t;var r=e.match(/[+-]?(\d*\.)?\d+/g);return r.length<=0||(/translateX/g.test(e)?t.x=parseFloat(r[0],10):/translateY/g.test(e)?t.y=parseFloat(r[0],10):(t.x=parseFloat(r[0],10),1<r.length&&(t.y=parseFloat(r[1],10)))),t},a.isPalindrome=function(e){if(!b.isString(e))throw new TypeError("[aid.string.isPalindrome] Type of str parameter must be String.");return e.length<=1||e.slice(0,1)===e.slice(-1)&&b.string.isPalindrome(e.slice(-1,1))},a.isDecoded=function(e,t){var r=f.decodeURIComponent;if(!b.isString(e))throw new TypeError("[aid.string.isDecoded] Type of str parameter must be String.");if(b.isDefined(t)){if(!b.isFunction(t))throw new TypeError("[aid.string.isDecoded] Type of decodeFunc parameter must be Function.");r=t}else if(!b.isFunction(r))throw new TypeError("[aid.string.isDecoded] Type of decodeFunc parameter must be defined.");var n="";try{n=r.call(null,e)}catch(e){return e}return n===e},a.decodeRecursively=function e(t,r){var n=f.decodeURIComponent;if(!b.isString(t))throw new TypeError("[aid.string.decodeRecursively] Type of str parameter must be String.");if(b.isDefined(r)){if(!b.isFunction(r))throw new TypeError("[aid.string.decodeRecursively] Type of decodeFunc parameter must be Function.");n=r}else if(!b.isFunction(n))throw new TypeError("[aid.string.decodeRecursively] Type of decodeFunc parameter must be defined.");var i="";try{i=n.call(null,t)}catch(e){return e}return i!==t?e(i,n):i},a.escapeRegExp=function(e){if(!b.isString(e))throw new TypeError("[aid.string.escapeRegExp] Type of str parameter must be String.");return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")},n.getSizeAspectFill=function(e,t,r,n){var i=b.isNumber;if(!(i(e)&&i(t)&&i(r)&&i(n)))throw new TypeError("[aid.math.getSizeAspectFill] Type of parameters must be Number.");var o=r,a=Math.ceil(r/e*t);return a<n&&(o=Math.ceil(n/t*e),a=n),{width:o,height:a}},n.getSizeAspectFit=function(e,t,r,n){var i=b.isNumber;if(!(i(e)&&i(t)&&i(r)&&i(n)))throw new TypeError("[aid.math.getSizeAspectFit] Type of parameters must be Number.");var o=Math.min(r/e,n/t);return{width:Math.ceil(e*o),height:Math.ceil(t*o)}},n.getSizeWidthFit=function(e,t,r){var n=b.isNumber;if(!n(e)||!n(t)||!n(r))throw new TypeError("[aid.math.getSizeWidthFit] Type of parameters must be Number.");return{width:r,height:Math.ceil(r/e*t)}},n.isEpsilonEqual=function(e,t){if(!b.isNumber(e)||!b.isNumber(t))throw new TypeError("[aid.math.isEpsilonEqual] Type of parameters must be Number.");var r=b.isDefined(Number.EPSILON)?Number.EPSILON:2220446049250313e-31;return Math.abs(e-t)<r},n.isIndexInLoop=function(e,t,r,n){if(arguments.length<4)throw new Error("[aid.math.isIndexInLoop] Requires 4 parameters.");var i=b.isInteger;if(!(i(e)&&i(t)&&i(r)&&i(n)))throw new TypeError("[aid.math.isIndexInLoop] Type of parameters must be Number.");if(e<1||r<1)throw new Error("[aid.math.isIndexInLoop] totalLength, firstIndex parameters cannot smaller than 1.");if(e<t)throw new Error("[aid.math.isIndexInLoop] loopGap parameter cannot bigger than totalLength parameter.");for(var o=r,a=0;a<t;a++){if(o===n)return!0;o=e<o+1?1:o+1}return!1},n.getLoopedLastIndex=function(e,t,r){if(arguments.length<3)throw new Error("[aid.math.getLoopedLastIndex] Requires 3 parameters.");var n=b.isInteger;if(!n(e)||!n(t)||!n(r))throw new TypeError("[aid.math.getLoopedLastIndex] Type of parameters must be Integer Number.");if(e<1||r<1)throw new Error("[aid.math.getLoopedLastIndex] totalLength, firstIndex parameters cannot smaller than 1.");if(e<t||e<r)throw new Error("[aid.math.getLoopedLastIndex] loopGap, firstIndex parameters cannot bigger than totalLength parameter.");for(var i=r,o=0;o<t-1;o++)i=e<i+1?1:i+1;return i},n.getReverseLoopedFirstIndex=function(e,t,r){if(arguments.length<3)throw new Error("[aid.math.getReverseLoopedFirstIndex] Requires 3 parameters.");var n=b.isInteger;if(!n(e)||!n(t)||!n(r))throw new TypeError("[aid.math.getReverseLoopedFirstIndex] Type of parameters must be Integer Number.");if(e<1||r<1)throw new Error("[aid.math.getReverseLoopedFirstIndex] totalLength, lastIndex parameters cannot smaller than 1.");if(e<t||e<r)throw new Error("[aid.math.getReverseLoopedFirstIndex] loopGap, lastIndex parameters cannot bigger than totalLength parameter.");for(var i=r,o=0;o<t-1;o++)i=i-1<1?e:i-1;return i},n.factorial=function(e){if(!b.isInteger(e))throw new TypeError("[aid.math.factorial] Type of parameters must be Integer Number.");return e<1?1:e*b.math.factorial(e-1)},n.getObjForPagination=function(e,t,r,n){if(arguments.length<4)throw new Error("[aid.math.getObjForPagination] Requires 4 parameters.");var i=b.isInteger;if(!(i(e)&&i(t)&&i(r)&&i(n)))throw new TypeError("[aid.math.getObjForPagination] Type of parameters must be Integer Number.");if(e<=0||t<=0||r<=0||n<=0)throw new TypeError("[aid.math.getObjForPagination] Type of parameters must be positive Integer Number.");var o=Math.ceil(e/t);n<1&&(n=1),o<n&&(n=o);var a=Math.floor((n-1)/r),u=a*r+1,s=u+r-1,f=s+1;return o<s&&(s=o),o<f&&(f=0),{totalPostNum:e,displayPostNumPerPage:t,displayPaginationBtnNum:r,pageIndex:n,totalPageNum:o,prevPageIndex:a*r,firstPageIndex:u,lastPageIndex:s,nextPageIndex:f}},n.degreeToRadian=function(e){if(!b.isNumber(e))throw new TypeError("[aid.math.degreeToRadian] Type of degree parameter must be Number.");return e*Math.PI/180},n.radianToDegree=function(e){if(!b.isNumber(e))throw new TypeError("[aid.math.radianToDegree] Type of degree parameter must be Number.");return 180*e/Math.PI},n.getHeightOfRightTriangle=function(e,t){if(!b.isNumber(e)||!b.isNumber(t))throw new TypeError("[aid.math.getHeightOfRightTriangle] Type of parameters must be Number.");if(90<=t)throw new Error("[aid.math.getHeightOfRightTriangle] acuteAngleDegree parameter cannot greater than or equal to 90.");return e*Math.tan(n.degreeToRadian(t))},n.getDistanceBetweenTwoPoints=function(e,t){if(!b.isObject(e)||!b.isObject(t))throw new TypeError("[aid.math.getDistanceBetweenTwoPoints] Type of parameters must be Object.");var r=b.isNumber;if(!(r(e.x)&&r(e.y)&&r(t.x)&&r(t.y)))throw new TypeError("[aid.math.getDistanceBetweenTwoPoints] Type of parameters must be Object that has x, y properties.");return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))},n.getOrthogonalPointBetweenLineAndSomePoint=function(e,t,r){var n=b.isObject;if(!n(e)||!n(t)||!n(r))throw new TypeError("[aid.math.getOrthogonalPointBetweenLineAndSomePoint] Type of parameters must be Object.");var i=b.isNumber;if(!(i(e.x)&&i(e.y)&&i(t.x)&&i(t.y)&&i(r.x)&&i(r.y)))throw new TypeError("[aid.math.getOrthogonalPointBetweenLineAndSomePoint] Type of parameters must be Object that has x, y properties.");if(e.x===t.x&&e.y===t.y)return null;var o=t.x-e.x,a=t.y-e.y;if(0==o)return{x:e.x,y:r.y};if(0==a)return{x:r.x,y:e.y};var u=a/o,s=-1/u,f={};return f.x=(s*r.x-u*e.x+e.y-r.y)/(s-u),f.y=s*(f.x-r.x)+r.y,f},n.getRandomPositiveNegative=function(){return 0<Math.round(Math.random())?1:-1},n.getRandomFloat=function(e,t){var r=b.isNumber;if(!r(e)||!r(t))throw new TypeError("[aid.math.getRandomFloat] Type of parameters must be Number.");return e+Math.random()*(t-e)},n.getRandomInt=function(e,t){var r=b.isInteger;if(!r(e)||!r(t))throw new TypeError("[aid.math.getRandomInt] Type of parameters must be Integer Number.");return e+Math.floor(Math.random()*(t-e+1))},n.remap=function(e,t,r,n,i){var o=b.isNumber;if(!(o(e)&&o(t)&&o(r)&&o(n)&&o(i)))throw new TypeError("[aid.math.remap] Type of parameters must be Number.");return(e-t)/(r-t)*(i-n)+n},n.gt=b.curry2(function(e,t){if(!b.allOf(b.isNumber(e),b.isNumber(t)))throw new TypeError("[aid.math.gt] Type of parameters must be Number.");return t<e}),n.lt=b.curry2(function(e,t){if(!b.allOf(b.isNumber(e),b.isNumber(t)))throw new TypeError("[aid.math.lt] Type of parameters must be Number.");return e<t}),n.gte=b.curry2(function(e,t){if(!b.allOf(b.isNumber(e),b.isNumber(t)))throw new TypeError("[aid.math.gte] Type of parameters must be Number.");return t<=e}),n.lte=b.curry2(function(e,t){if(!b.allOf(b.isNumber(e),b.isNumber(t)))throw new TypeError("[aid.math.lte] Type of parameters must be Number.");return e<=t}),i.DAYS=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],i.MONTHS=["January","February","March","April","May","June","July","August","September","October","November","December"],i.MIN_TO_SEC=60,i.HOUR_TO_SEC=3600,i.DAY_TO_SEC=86400,v.indexOf=function(e,t){if(!b.isArray(e))throw new TypeError("[aid.math.indexOf] Type of arr parameters must be Array.");for(var r=0,n=e.length;r<n;++r)if(e[r]===t)return r;return-1},v.indexOfMin=function(e,t){if(!b.isArray(e)||!b.isInteger(t))return-1;var r=0<t?t:0;if(e.length<=r)return-1;for(var n=e[r],i=r,o=i+1,a=e.length;o<a;o++)e[o]<n&&(n=e[o],i=o);return i},v.swap=function(e,t,r){if(3!==arguments.length)return null;if(!b.isArray(e)||!b.isInteger(t)||!b.isInteger(r))return null;if(t<0||t>=e.length||r<0||r>=e.length)return null;var n=e[t];return e[t]=e[r],e[r]=n,e},v.selectionSort=function(e){if(!b.isArray(e)||e.length<=0)return null;for(var t=0,r=0,n=e.length-1;r<n;r++)t=v.indexOfMin(e,r),v.swap(e,r,t);return e},v.insertionSort=function(e){if(!b.isArray(e)||e.length<=0)return null;for(var t,r=1,n=e.length;r<n;r++){t=e[r];for(var i=r-1;0<=i&&e[i]>t;i--)e[i+1]=e[i];e[i+1]=t}return e},v.merge=function(e,t,r,n){if(!b.isArray(e)||e.length<=0)return null;if(r<t||n<r)return null;for(var i=t,o=r+1,a=t,u=[];i<=r&&o<=n;)e[i]<=e[o]?u[a++]=e[i++]:u[a++]=e[o++];if(r<i)for(var s=o;s<=n;s++)u[a]=e[s],a++;else for(var f=i;f<=r;f++)u[a]=e[f],a++;for(var p=t;p<=n;p++)e[p]=u[p];return e},v.mergeSort=function(e,t,r){if(!b.isArray(e)||e.length<=0)return null;if(e.length<=1||t===r)return null;if(t+1===r)return e[t]>e[r]&&b.array.swap(e,t,r),e;var n=Math.floor((t+r)/2);return b.array.mergeSort(e,t,n),b.array.mergeSort(e,n+1,r),b.array.merge(e,t,n,r),e},v.getPivotIndexAfterPartition=function(e,t,r){if(!b.isArray(e)||e.length<=0)return-1;if(r<t)return-1;if(e.length<=1)return 0;for(var n=e[r],i=t,o=t;o<r;o++)e[o]<=n&&(b.array.swap(e,o,i),i++);return r!==i&&b.array.swap(e,r,i),i},v.quickSort=function(e,t,r){if(!b.isArray(e)||e.length<=0)return null;if(e.length<=1||t===r)return null;if(t<r){var n=b.array.getPivotIndexAfterPartition(e,t,r);b.array.quickSort(e,t,n-1),b.array.quickSort(e,n+1,r)}return e},v.remove=function(e,t){if(!b.isArray(e))throw new TypeError("[aid.array.remove] Type of arr parameter must be Array.");var r=e.slice(0),n=v.indexOf(r,t);return 0<=n&&r.splice(n,1),r},v.getMatrixArr=function(e,t,r){if(!b.isInteger(e)||!b.isInteger(t))throw new TypeError("[aid.array.getMatrixArr] Type of rowNum, columnNum parameters must be Integer Number.");if(3!==arguments.length)throw Error("[aid.array.getMatrixArr] Requires 3 parameters.");for(var n=[],i=[],o=0;o<e;++o){i=[];for(var a=0;a<t;++a)i[a]=r;n[o]=i}return n},v.binaryIndexOf=function(e,t){if(!b.isArray(e)||e.length<=0)return-1;for(var r,n=0,i=e.length-1;n<=i;){if(t===e[r=Math.floor((n+i)/2)])return r;t<e[r]?i=r-1:n=r+1}return-1},v.getFirstObjectHasProperty=function(e,t,r){if(!b.isArray(e)||e.length<=0)return null;if(!b.isString(t))return null;for(var n,i=null,o=0,a=e.length;o<a;++o)if((n=e[o]).hasOwnProperty(t))if(b.isRegExp(r)){if(r.test(n[t])){i=n;break}}else if(n[t]===r){i=n;break}return i},v.getIndexOfObjectHasProperty=function(e,t,r){if(!b.isArray(e)||e.length<=0)return null;if(!b.isString(t))return null;for(var n,i=null,o=0,a=e.length;o<a;++o)if((n=e[o]).hasOwnProperty(t))if(b.isRegExp(r)){if(r.test(n[t])){i=n;break}}else if(n[t]===r){i=n;break}return i?o:-1},v.overlappedConditionSortByProperty=function(e,t){if(!b.isArray(e))return null;var r=w.call(e);if(r.length<=1)return r;if(!b.isDefined(t)||!b.isArray(t)||t.length<=0)return r;var n=b.rest(w.call(arguments),2),i=1<=n.length?n[0]:0,o=t[i];if(i<=0&&r.sort(o.func),t.length<=1)return r;if(i<t.length-1){for(var a,u,s,f=o.property,p=i+1,c=t[p],h={},l=[],d=0,y=r.length;d<y;d++)u=r[d],h[s=String(u[f])]||(h[s]=[],l.push(h[s])),(a=h[s]).push(u);for(var m=0,g=l.length;m<g;m++)(a=l[m]).sort(c.func),l[m]=v.overlappedConditionSortByProperty(a,t,p);return l.reduce(function(e,t){return e.concat(t)})}return r},h.isEmpty=function(e){if(!b.isObject(e))throw new TypeError("[aid.object.isEmpty] Type of obj parameter must be Object.");for(var t in e)if(e.hasOwnProperty(t))return!1;return!0},h.keys=function(e){var t=!{toString:null}.propertyIsEnumerable("toString"),r=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],n=r.length;if(b.not(b.isFunction)(e)&&(b.not(b.isObject)(e)||null===e))throw new TypeError("[aid.object.keys] Called on non-object.");var i=[];for(var o in e)c.call(e,o)&&i.push(o);if(t)for(var a=0;a<n;a++)c.call(e,r[a])&&i.push(r[a]);return i},h.shallowEqual=function(e,t){var r=b.not,n=b.eq,i=r(b.isObject),o=n(null);if(n(e)(t))return!0;if(i(e)||o(e)||i(t)||o(t))return!1;var a=h.keys(e),u=h.keys(t);if(r(n(a.length))(u.length))return!1;for(var s=c.bind(t),f=0,p=a.length;f<p;f++)if(!s(a[f])||r(n(e[a[f]]))(t[a[f]]))return!1;return!0},o.isEntirelyInViewport=function(e){if("function"==typeof jQuery&&e instanceof jQuery&&(e=e.get(0)),!e)return!1;var t=e.getBoundingClientRect(),r=b.eq(0);return!b.allOf(r(t.top),r(t.left),r(t.bottom),r(t.right),r(t.width),r(t.height),r(t.x),r(t.y))&&(0<=t.top&&0<=t.left&&t.bottom<=(f.innerHeight||document.documentElement.clientHeight)&&t.right<=(f.innerWidth||document.documentElement.clientWidth))},o.isPartiallyInViewport=function(e){if("function"==typeof jQuery&&e instanceof jQuery&&(e=e.get(0)),!e)return!1;var t=e.getBoundingClientRect(),r=b.eq(0);if(b.allOf(r(t.top),r(t.left),r(t.bottom),r(t.right),r(t.width),r(t.height),r(t.x),r(t.y)))return!1;var n=f.innerHeight||document.documentElement.clientHeight,i=f.innerWidth||document.documentElement.clientWidth,o=t.top<=n&&0<=t.top+t.height,a=t.left<=i&&0<=t.left+t.width;return o&&a},u.appendScriptFile=function(e,t,r){var n=document.createElement("script");n.type="text/javascript","function"==typeof r&&(void 0===n.onreadystatechange?n.onload=r:n.onreadystatechange=function(){"loaded"!==n.readyState&&"complete"!==n.readyState||(n.onreadystatechange=null,r())}),n.src=e;var i=t;if("function"==typeof jQuery&&i instanceof jQuery&&(i=i.get(0)),i)i.appendChild(n);else{var o=document.getElementsByTagName("script")[0];o.parentNode.insertBefore(n,o)}},s.copyText=function(e,t,r){if(!b.isString(e))throw new TypeError("[aid.clipboard.copyText] Type of str parameter must be String.");if(b.isDefined(t)&&!b.isFunction(t))throw new TypeError("[aid.clipboard.copyText] Type of successCallback parameter must be undefined or null or Function.");if(b.isDefined(r)&&!b.isFunction(r))throw new TypeError("[aid.clipboard.copyText] Type of errorCallback parameter must be undefined or null or Function.");if(navigator.clipboard)navigator.clipboard.writeText(e).then(function(){t&&t.call(null,e)},function(e){r&&r.call(null,e)});else{var n=document.createElement("textarea");n.style.position="fixed",n.style.top="-9999px",n.style.left="-9999px",n.style.width="2em",n.style.height="2em",n.value=e,document.body.appendChild(n),n.focus(),n.select();try{if(document.execCommand("copy"))return void(t&&t.call(null,e));r&&r.call(null,new Error('[aid.clipboard.copyText] Cannot copy string with using document.execCommand("copy").'))}catch(e){r&&r.call(null,e)}document.body.removeChild(n)}};function N(e){this._value=e}N.prototype.bind=function(e){return e(this._value)},N.prototype.toString=function(){return"Identity ("+this._value+")"},p.Identity=N;function I(){}I.prototype.map=function(){return this},I.prototype.flatmap=function(){return new I},I.prototype.toString=function(){return"Empty ()"},p.Empty=I;function _(e){this._value=e}_.of=function(e){return new _(e)},_.prototype.map=function(e){return _.of(e(this._value))},_.prototype.join=function(){return this._value instanceof _?this._value.join():this},_.prototype.get=function(){return this._value},_.prototype.toString=function(){return"Wrapper ("+this._value+")"},p.Wrapper=_;function C(){}C.prototype.value=function(){throw new TypeError("[aid.monad.Nothing] Cannot extract the value.")},C.prototype.map=function(){return this},C.prototype.getOrElse=function(e){return e},C.prototype.filter=function(){return this._value},C.prototype.chain=function(){return this},C.prototype.toString=function(){return"Maybe.Nothing"},p.Nothing=C;function P(e){this._value=e}P.prototype.value=function(){throw this._value},P.prototype.map=function(e){return D.fromNullable(e(this._value))},P.prototype.getOrElse=function(){return this._value},P.prototype.filter=function(e){D.fromNullable(e(this._value)?this._value:null)},P.prototype.chain=function(e){return e(this._value)},P.prototype.toString=function(){return"Maybe.Just ("+this._value+")"},p.Just=P;var D=function(){};D.just=function(e){return new P(e)},D.nothing=function(){return new C},D.of=function(e){return D.just(e)},D.fromNullable=function(e){return b.isDefined(e)?D.just(e):D.nothing()},p.Maybe=D;function j(e){this._value=e}j.prototype.map=function(){return this},j.prototype.value=function(){throw new TypeError("[aid.monad.Left] Cannot extract the value.")},j.prototype.getOrElse=function(e){return e},j.prototype.orElse=function(e){return e(this._value)},j.prototype.chain=function(){return this},j.prototype.getOrElseThrow=function(e){throw new Error(e)},j.prototype.filter=function(){return this},j.prototype.toString=function(){return"Either.Left ("+this._value+")"},p.Left=j;function A(e){this._value=e}A.prototype.map=function(e){return R.of(e(this._value))},A.prototype.getOrElse=function(){return this._value},A.prototype.orElse=function(){return this},A.prototype.chain=function(e){return e(this._value)},A.prototype.getOrElseThrow=function(){return this._value},A.prototype.filter=function(e){return R.fromNullable(e(this._value)?this._value:null)},A.prototype.toString=function(){return"Either.Right ("+this._value+")"},p.Right=A;var R=function(e){this._value=e};R.left=function(e){return new p.Left(e)},R.right=function(e){return new p.Right(e)},R.fromNullable=function(e){return b.isDefined(e)?R.right(e):R.left(e)},R.of=function(e){return R.right(e)},R.prototype.value=function(){return this._value},p.Either=R;function k(e){if(!b.isFunction(e))throw new TypeError("[aid.monad.IO] Type of effect parameter must be Function.");this.effect=e}k.of=function(e){return new k(function(){return e})},k.from=function(e){return new k(e)},k.prototype.map=function(e){var t=this;return new k(function(){return e(t.effect())})},k.prototype.chain=function(e){return e(this.effect())},k.prototype.run=function(){return this.effect()},p.IO=k,b.operator=e,b.platform=t,b.browser=r,b.string=a,b.math=n,b.date=i,b.array=v,b.object=h,b.element=o,b.file=u,b.clipboard=s,b.monad=p,"undefined"!=typeof exports?"undefined"!=typeof module&&module.exports&&(exports=module.exports=b):"function"==typeof define&&define.amd?define("aid",[],function(){return b}):f.aid=b}(); //# sourceMappingURL=aid.min.js.map