/*
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","../../../../geometry/support/buffer/BufferView","../../../../geometry/support/buffer/types"],(function(e,t,i,n){"use strict";let f=function(){function e(e,t){this.layout=e,this.buffer="number"==typeof t?new ArrayBuffer(t*e.stride):t;for(const i of e.fieldNames){const t=e.fields.get(i);this[i]=new t.constructor(this.buffer,t.offset,this.stride)}}var i=e.prototype;return i.getField=function(e,t){const i=this[e];return i&&i.elementCount===t.ElementCount&&i.elementType===t.ElementType?i:null},i.slice=function(t,i){return new e(this.layout,this.buffer.slice(t*this.stride,i*this.stride))},i.copyFrom=function(e,t,i,n){const f=this.stride;if(f%4==0){const r=new Uint32Array(e.buffer,t*f,n*f/4);new Uint32Array(this.buffer,i*f,n*f/4).set(r)}else{const r=new Uint8Array(e.buffer,t*f,n*f);new Uint8Array(this.buffer,i*f,n*f).set(r)}},t._createClass(e,[{key:"stride",get:function(){return this.layout.stride}},{key:"count",get:function(){return this.buffer.byteLength/this.stride}},{key:"byteLength",get:function(){return this.buffer.byteLength}}]),e}(),r=function(){function e(){this.stride=0,this.fields=new Map,this.fieldNames=[]}var t=e.prototype;return t.vec2f=function(e,t){return this._appendField(e,i.BufferViewVec2f,t),this},t.vec2f64=function(e,t){return this._appendField(e,i.BufferViewVec2f64,t),this},t.vec3f=function(e,t){return this._appendField(e,i.BufferViewVec3f,t),this},t.vec3f64=function(e,t){return this._appendField(e,i.BufferViewVec3f64,t),this},t.vec4f=function(e,t){return this._appendField(e,i.BufferViewVec4f,t),this},t.vec4f64=function(e,t){return this._appendField(e,i.BufferViewVec4f64,t),this},t.mat3f=function(e,t){return this._appendField(e,i.BufferViewMat3f,t),this},t.mat3f64=function(e,t){return this._appendField(e,i.BufferViewMat3f64,t),this},t.mat4f=function(e,t){return this._appendField(e,i.BufferViewMat4f,t),this},t.mat4f64=function(e,t){return this._appendField(e,i.BufferViewMat4f64,t),this},t.vec4u8=function(e,t){return this._appendField(e,i.BufferViewVec4u8,t),this},t.f32=function(e,t){return this._appendField(e,i.BufferViewFloat,t),this},t.f64=function(e,t){return this._appendField(e,i.BufferViewFloat64,t),this},t.u8=function(e,t){return this._appendField(e,i.BufferViewUint8,t),this},t.u16=function(e,t){return this._appendField(e,i.BufferViewUint16,t),this},t.i8=function(e,t){return this._appendField(e,i.BufferViewInt8,t),this},t.vec2i8=function(e,t){return this._appendField(e,i.BufferViewVec2i8,t),this},t.vec2i16=function(e,t){return this._appendField(e,i.BufferViewVec2i16,t),this},t.vec2u8=function(e,t){return this._appendField(e,i.BufferViewVec2u8,t),this},t.vec4u16=function(e,t){return this._appendField(e,i.BufferViewVec4u16,t),this},t.u32=function(e,t){return this._appendField(e,i.BufferViewUint32,t),this},t._appendField=function(e,t,i){const f=t.ElementCount*n.elementTypeSize(t.ElementType),r=this.stride;this.fields.set(e,{size:f,constructor:t,offset:r,optional:i}),this.stride+=f,this.fieldNames.push(e)},t.alignTo=function(e){return this.stride=Math.floor((this.stride+e-1)/e)*e,this},t.hasField=function(e){return this.fieldNames.includes(e)},t.createBuffer=function(e){return new f(this,e)},t.createView=function(e){return new f(this,e)},t.clone=function(){const t=new e;return t.stride=this.stride,t.fields=new Map,this.fields.forEach(((e,i)=>t.fields.set(i,e))),t.fieldNames=this.fieldNames.slice(),t.BufferType=this.BufferType,t},e}();function u(){return new r}e.InterleavedBuffer=f,e.InterleavedLayout=r,e.newLayout=u,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
