/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../../../../chunks/_rollupPluginBabelHelpers"],(function(e,t){"use strict";let r=function(){function e(e,t){this._pool=e,this._size=0,this._buffer=e.newBuffer(i(t))}var r=e.prototype;return r.dispose=function(){this._buffer=this._pool.deleteBuffer(this._buffer),this._size=0},r.release=function(){this.erase(0,this._size),this.dispose()},r.grow=function(e){this._resize(this._size+e,!0).dispose()},r.alloc=function(e){return this._resize(e,!1)},r._resize=function(e,t){let r;const s=f(this._buffer.length,this._size,e);if(this._buffer.length!==s){const e=this._pool.newBuffer(s);t&&(e.array.set(this._buffer.array.subarray(0,Math.min(this._size,s))),e.vao.vertexBuffers.geometry.setSubData(e.array,0,0,e.array.byteLength)),r=this._buffer,this._buffer=e}const i=this._size;return this._size=e,r?{dispose:()=>{r.array.fill(0,0,i),this._pool.deleteBuffer(r)},copy:(e,t,s)=>this._buffer.array.set(r.array.subarray(t,s),e),hasNewBuffer:!0}:{dispose:()=>{},copy:(e,t,r)=>{e!==t&&this._buffer.array.copyWithin(e,t,r)},hasNewBuffer:!1}},r.erase=function(e,t){this._buffer.array.fill(0,e,t)},t._createClass(e,[{key:"vao",get:function(){return this._buffer.vao}},{key:"array",get:function(){return this._buffer.array}},{key:"size",get:function(){return this._size}}]),e}();const s=65536;function i(e){return Math.ceil(e/s)*s}function f(e,t,r){return t<=r?e>=r?e:i(Math.max(2*e,r)):e<=2*r?e:i(r)}e.MergedGeometryBuffer=r,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
