/*
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","../../../../../core/promiseUtils","../../../../../chunks/vec3f64","../../../../../geometry/support/aaBoundingBox","./LodComponentData"],(function(e,n,t,o,i,r,s){"use strict";let u=function(){function e(e,n){this.minScreenSpaceRadius=e,this.components=n}e.create=function(){var t=n._asyncToGenerator((function*(n,t,i){const r=yield Promise.allSettled(t.components.map((e=>n.schedule((()=>new s.LodComponentData(n,e)),i)))),u=r.map((e=>"fulfilled"===e.status?e.value:null)).filter((e=>e));if(o.isAborted(i)||u.length!==r.length){u.forEach((e=>e.destroy())),o.throwIfAborted(i);for(const e of r)if("rejected"===e.status)throw e.reason}return new e(t.minScreenSpaceRadius,u)}));function i(e,n,o){return t.apply(this,arguments)}return i}();var u=e.prototype;return u.destroy=function(){this.components.forEach((e=>e.destroy()))},u.intersect=function(e,n,t,o,i,r,s){this.components.forEach((u=>u.intersect(e,n,t,o,i,r,this.boundingSphere,s)))},n._createClass(e,[{key:"boundingBox",get:function(){if(t.isNone(this._boundingBox)){const e=r.empty();this.components.forEach((n=>{t.isSome(n.boundingInfo)&&(r.expandWithVec3(e,n.boundingInfo.bbMin),r.expandWithVec3(e,n.boundingInfo.bbMax))})),this._boundingBox=e}return this._boundingBox}},{key:"boundingSphere",get:function(){if(t.isNone(this._boundingSphere)){const e=this.boundingBox,n=i.create();r.center(e,n),this._boundingSphere={center:n,radius:.5*r.diameter(e)}}return this._boundingSphere}},{key:"triangleCount",get:function(){return this.components.reduce(((e,n)=>e+n.triangleCount),0)}}]),e}();e.LodLevel=u,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
