/*!
 * @author electricessence / https://github.com/electricessence/
 * Licensing: MIT https://github.com/electricessence/TypeScript.NET/blob/master/LICENSE.md
 */
!function(e){if("object"==typeof module&&"object"==typeof module.exports){var t=e(require,exports);void 0!==t&&(module.exports=t)}else"function"==typeof define&&define.amd&&define(["require","exports","../../Types","../../Integer","../../Compare","../../Exceptions/ArgumentException","../../Exceptions/ArgumentNullException","../../Exceptions/ArgumentOutOfRangeException"],e)}(function(e,t){"use strict";function n(e){y["default"].assert(e,"length");var t;return e>65536?t=new Array(e):(t=[],t.length=e),t}function r(e,t,r){return void 0===t&&(t=0),void 0===r&&(r=1/0),e?i(e,n(Math.min(r,Math.max(e.length-t,0))),t,0,r):e}function i(e,t,n,r,i){if(void 0===n&&(n=0),void 0===r&&(r=0),void 0===i&&(i=1/0),!e)throw new b["default"]("source",M);if(!t)throw new b["default"]("destination",M);if(0>n)throw new I["default"]("sourceIndex",n,q);var o=e.length;if(n>=o)throw new I["default"]("sourceIndex",n,"Must be less than the length of the source array.");if(t.length<0)throw new I["default"]("destinationIndex",r,q);var a=e.length-n;if(isFinite(i)&&i>a)throw new I["default"]("sourceIndex",n,"Source index + length cannot exceed the length of the source array.");i=Math.min(i,a);for(var f=0;i>f;++f)t[r+f]=e[n+f];return t}function o(e,t,n){if(void 0===n&&(n=E.areEqual),e&&e.length){if(Array.isArray(e))return-1!=e.indexOf(t);for(var r=0;r<e.length;++r)if(n(e[r],t))return!0}return!1}function a(e,t,n,r){var i=0;if(0!==r){if(r){if(0>r)throw new I["default"]("max",r,q)}else r=1/0;for(var o=e.length-1;o>=0&&(e[o]!==t||(e[o]=n,++i,--r));--o);}return i}function f(e,t,n,r){y["default"].assert(n,"index"),y["default"].assert(n,"length");for(var i=n+r,o=n;i>o;++o)e[o]=t}function u(e,t,n){f(e,null,t,n)}function l(e,t,n){if(void 0===n&&(n=E.areEqual),!e)throw new b["default"]("array",M);var r=e.length,i=!r||!o(e,t,n);return i&&(e[r]=t),i}function d(e,t){if(!e)throw new b["default"]("array",M);if(!m["default"].isFunction(t))throw new A["default"]("predicate","Must be a function.");for(var n=e.length,r=0;n>r;++r)if(r in e&&t(e[r]))return r;return-1}function c(e,t){if(!e)throw new b["default"]("source",M);if(t)for(var n=0;n<e.length&&t(e[n])!==!1;++n);return e}function s(e,t){if(!e)throw new b["default"]("target",M);if(t)for(var n=0;n<e.length;++n)e[n]=t(e[n]);return e}function h(e,t){if(!e)throw new b["default"]("array",M);if(y["default"].assert(t,"index"),0>t)throw new I["default"]("index",t,q);var n=t<e.length;return n&&e.splice(t,1),n}function w(e,t,n,r){if(void 0===r&&(r=E.areEqual),!e)throw new b["default"]("array",M);var i=0;if(e&&e.length&&0!==n){if(n){if(0>n)throw new I["default"]("max",n,q)}else n=1/0;for(var o=e.length-1;o>=0&&(!r(e[o],t)||(e.splice(o,1),++i,--n));--o);}return i}function v(e,t){if(y["default"].assert(t,"count"),0>t)throw new I["default"]("count",t,q);for(var r=n(t),i=0;t>i;++i)r[i]=e;return r}function g(e,t,r){if(void 0===r&&(r=1),isNaN(e)||!isFinite(e))throw new I["default"]("first",e,C);if(isNaN(t)||!isFinite(t))throw new I["default"]("count",t,C);if(0>t)throw new I["default"]("count",t,q);for(var i=n(t),o=0;t>o;++o)i[o]=e,e+=r;return i}function p(e,t,n){if(void 0===n&&(n=1),0==n)throw new I["default"]("step",n,N);return g(e,(t-e)/n,n)}function x(e,t){void 0===t&&(t=0);for(var n=[],r=0;r<e.length;r++){var i=e[r];if(Array.isArray(i)){t>0&&(i=x(i,t-1));for(var o=0;o<i.length;o++)n.push(i[o])}else n.push(i)}return n}var m=e("../../Types"),y=e("../../Integer"),E=e("../../Compare"),A=e("../../Exceptions/ArgumentException"),b=e("../../Exceptions/ArgumentNullException"),I=e("../../Exceptions/ArgumentOutOfRangeException");t.initialize=n,t.copy=r;var M="Cannot be null.",N="Cannot be zero.",q="Cannot be less than zero.",C="Must be a valid finite number";t.copyTo=i,t.contains=o,t.replace=a,t.updateRange=f,t.clear=u,t.register=l,t.findIndex=d,t.forEach=c,t.applyTo=s,t.removeIndex=h,t.remove=w,t.repeat=v,t.range=g,t.rangeUntil=p,t.flatten=x});
//# sourceMappingURL=Utility.js.map
