/*
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","../../../../core/maybe","./basicInterfaces","./BoundingInfo","./ContentObject","./ContentObjectType","./geometryDataUtils","./Util","./VertexAttribute"],(function(t,e,n,i,r,o,s,u,c,g){"use strict";let a=function(t){function o(e,n=[],r=i.PrimitiveType.Triangle,o=-1){var c;(c=t.call(this)||this)._primitiveType=r,c.edgeIndicesLength=o,c.type=s.ContentObjectType.Geometry,c._vertexAttributes=new Map,c._indices=new Map,c._boundingInfo=null;for(const[t,i]of e)i&&c._vertexAttributes.set(t,{...i});if(null==n||0===n.length){const t=l(c._vertexAttributes),e=u.generateDefaultIndexArray(t);c.edgeIndicesLength=c.edgeIndicesLength<0?t:c.edgeIndicesLength;for(const n of c._vertexAttributes.keys())c._indices.set(n,e)}else for(const[t,i]of n)i&&(c._indices.set(t,d(i)),t===g.VertexAttribute.POSITION&&(c.edgeIndicesLength=c.edgeIndicesLength<0?c._indices.get(t).length:c.edgeIndicesLength));return c}e._inheritsLoose(o,t);var a=o.prototype;return a.cloneShallow=function(){const t=new o([],void 0,this._primitiveType,void 0),{_vertexAttributes:e,_indices:n}=t;return this._vertexAttributes.forEach(((t,n)=>{e.set(n,t)})),this._indices.forEach(((t,e)=>{n.set(e,t)})),t.screenToWorldRatio=this.screenToWorldRatio,t._boundingInfo=this._boundingInfo,t},a.getMutableAttribute=function(t){const e=this._vertexAttributes.get(t);return e&&!e.exclusive&&(e.data=Array.from(e.data),e.exclusive=!0),e},a.computeAttachmentOrigin=function(t){return this.primitiveType===i.PrimitiveType.Triangle?this._computeAttachmentOriginTriangles(t):this._computeAttachmentOriginPoints(t)},a._computeAttachmentOriginTriangles=function(t){const e=this.indices.get(g.VertexAttribute.POSITION),n=this.vertexAttributes.get(g.VertexAttribute.POSITION);return u.computeAttachmentOriginTriangles(n,e,t)},a._computeAttachmentOriginPoints=function(t){const e=this.indices.get(g.VertexAttribute.POSITION),n=this.vertexAttributes.get(g.VertexAttribute.POSITION);return u.computeAttachmentOriginPoints(n,e,t)},a.invalidateBoundingInfo=function(){this._boundingInfo=null},a._calculateBoundingInfo=function(){const t=this.indices.get(g.VertexAttribute.POSITION);if(0===t.length)return null;const e=this.primitiveType===i.PrimitiveType.Triangle?3:1;c.assert(t.length%e==0,"Indexing error: "+t.length+" not divisible by "+e);const n=u.generateDefaultIndexArray(t.length/e),o=this.vertexAttributes.get(g.VertexAttribute.POSITION);return new r.BoundingInfo(n,e,t,o)},e._createClass(o,[{key:"vertexAttributes",get:function(){return this._vertexAttributes}},{key:"indices",get:function(){return this._indices}},{key:"indexCount",get:function(){const t=this._indices.values().next().value;return t?t.length:0}},{key:"primitiveType",get:function(){return this._primitiveType}},{key:"faceCount",get:function(){return this.indexCount/3}},{key:"boundingInfo",get:function(){return n.isNone(this._boundingInfo)&&(this._boundingInfo=this._calculateBoundingInfo()),this._boundingInfo}}]),o}(o.ContentObject);function l(t){const e=t.values().next().value;return null==e?0:e.data.length/e.size}function d(t){if(t.BYTES_PER_ELEMENT===Uint16Array.BYTES_PER_ELEMENT)return t;for(const e of t)if(e>=65536)return t;return new Uint16Array(t)}t.Geometry=a,Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
