/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import{nativeArrayMaxSize as r,isTypedArray as n}from"../../core/typedArrayUtil.js";function t(r){return e(r,!0)}function e(t,e){if(Array.isArray(t)){if(t.length<r)return t}else if(t.length<r)return Array.from(t);let f=!0,a=!0;return t.some((r,n)=>(f=f&&0===r,a=a&&r===n,!f&&!a)),f?c(t.length):a?o(t.length):n(t)&&t.BYTES_PER_ELEMENT===Uint16Array.BYTES_PER_ELEMENT?t:i(t,!e)}function i(r,t){for(const e of r){if(e>=65536)return n(r)?r:new Uint32Array(r);e>=256&&(t=!1)}return t?new Uint8Array(r):new Uint16Array(r)}function f(n){return n<=r?new Array(n):n<=65536?new Uint16Array(n):new Uint32Array(n)}function a(n){return n<=r?new Array(n):new Uint32Array(n)}let u=w(131072);const y=[0],A=(()=>{const r=new Uint16Array(65536);for(let n=0;n<r.length;++n)r[n]=n;return r})();function o(n){return 1===n?y:n<r?Array.from(new Uint16Array(A.buffer,0,n)):n<A.length?new Uint16Array(A.buffer,0,n):(n>u.length&&(u=w(Math.max(2*u.length,n))),new Uint32Array(u.buffer,0,n))}function l(n){return 1===n?[0]:n<r?Array.from(new Uint16Array(A.buffer,0,n)):n<A.length?new Uint16Array(A.buffer,0,n).slice():(n>u.length&&(u=w(Math.max(2*u.length,n))),new Uint32Array(u.buffer,0,n).slice())}function w(r){const n=new Uint32Array(r);for(let t=0;t<n.length;t++)n[t]=t;return n}let U=new Uint8Array(65536);function c(n){if(1===n)return y;if(n<r)return new Array(n).fill(0);if(n>U.length){const r=Math.max(2*U.length,n);U=new Uint8Array(r)}return new Uint8Array(U.buffer,0,n)}function h(){u=w(131072),U=new Uint8Array(65536)}export{e as compactIndices,t as compactMeshIndices,o as getContinuousIndexArray,c as getZeroIndexArray,l as newContinuousIndexArray,f as newIndexArray,a as newIntArray,h as pruneIndexArrays};
