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