text: var t,e=Object.defineProperty,n=Object.defineProperties,r=Object.getOwnPropertyDescriptors,o=Object.getOwnPropertySymbols,s=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable,a=(t,n,r)=>n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[n]=r,l=(t,e)=>{for(var n in e||(e={}))s.call(e,n)&&a(t,n,e[n]);if(o)for(var n of o(e))i.call(e,n)&&a(t,n,e[n]);return t},c=(t,e)=>n(t,r(e));import{X as u,Y as p,gg as h,bE as f,ft as g,Z as d,cd as m,gh as y,gi as w,gj as x,bk as v,r as b,n as A,c_ as M,b5 as F,fm as T,gk as R,a1 as j,eJ as O,a6 as C,gl as D,gm as P,cH as L,k as I,l as S,t as E,a as z,dO as $,e8 as U,ef as N,ej as W,el as k,dP as _,a2 as B,dY as H,gn as V,go as Z,e2 as G,e5 as Y,a4 as J,gb as X,ch as q,ce as K,bV as Q,aV as tt,a9 as et,cG as nt,cm as rt}from"./vendor.d9ce5f39.js";import{r as ot,M as st,x as it,v as at,F as lt,B as ct,a as ut,b as pt,R as ht,k as ft,c as gt,q as dt,d as mt,e as yt,f as wt,O as xt}from"./georeference.ee88f962.js";import{r as vt}from"./earcut.b5c0cad1.js";import{n as bt}from"./deduplicate.3ee84454.js";import{a as At}from"./quat.b9d69b87.js";import{e as Mt}from"./vec33.6044102f.js";const Ft=new WeakMap;let Tt=0,Rt=t=class extends m{constructor(t){super(t),this.wrap="repeat"}get url(){return this._get("url")||null}set url(t){this._set("url",t),t&&this._set("data",null)}get data(){return this._get("data")||null}set data(t){this._set("data",t),t&&this._set("url",null)}writeData(t,e,n,r){if(t instanceof HTMLImageElement){const o={type:"image-element",src:y(t.src,r),crossOrigin:t.crossOrigin};e[n]=o}else if(t instanceof HTMLCanvasElement){const r=t.getContext("2d").getImageData(0,0,t.width,t.height),o={type:"canvas-element",imageData:this.encodeImageData(r)};e[n]=o}else if(t instanceof HTMLVideoElement){const o={type:"video-element",src:y(t.src,r),autoplay:t.autoplay,loop:t.loop,muted:t.muted,crossOrigin:t.crossOrigin,preload:t.preload};e[n]=o}else{const r={type:"image-data",imageData:this.encodeImageData(t)};e[n]=r}}readData(t){switch(t.type){case"image-element":{const e=new Image;return e.src=t.src,e.crossOrigin=t.crossOrigin,e}case"canvas-element":{const e=this.decodeImageData(t.imageData),n=document.createElement("canvas");return n.width=e.width,n.height=e.height,n.getContext("2d").putImageData(e,0,0),n}case"image-data":return this.decodeImageData(t.imageData);case"video-element":{const e=document.createElement("video");return e.src=t.src,e.crossOrigin=t.crossOrigin,e.autoplay=t.autoplay,e.loop=t.loop,e.muted=t.muted,e.preload=t.preload,e}default:return}}get transparent(){const t=this.data,e=this.url;if(t instanceof HTMLCanvasElement)return this.imageDataContainsTransparent(t.getContext("2d").getImageData(0,0,t.width,t.height));if(t instanceof ImageData)return this.imageDataContainsTransparent(t);if(e){const t=e.substr(e.length-4,4).toLowerCase(),n=e.substr(0,15).toLocaleLowerCase();if(".png"===t||"data:image/png;"===n)return!0}return!1}set transparent(t){null!=t?this._override("transparent",t):this._clearOverride("transparent")}get contentHash(){const t="string"==typeof this.wrap?this.wrap:"object"==typeof this.wrap?`${this.wrap.horizontal}/${this.wrap.vertical}`:"",e=(e="")=>`d:${e},t:${this.transparent},w:${t}`;return null!=this.url?e(this.url):null!=this.data?this.data instanceof HTMLImageElement||this.data instanceof HTMLVideoElement?e(this.data.src):(Ft.has(this.data)||Ft.set(this.data,++Tt),e(Ft.get(this.data))):e()}clone(){const e={url:this.url,data:this.data,wrap:this.cloneWrap()};return new t(e)}cloneWithDeduplication(t){const e=t.get(this);if(e)return e;const n=this.clone();return t.set(this,n),n}cloneWrap(){return"string"==typeof this.wrap?this.wrap:{horizontal:this.wrap.horizontal,vertical:this.wrap.vertical}}encodeImageData(t){let e="";for(let n=0;n<t.data.length;n++)e+=String.fromCharCode(t.data[n]);return{data:btoa(e),width:t.width,height:t.height}}decodeImageData(t){const e=atob(t.data),n=new Uint8ClampedArray(e.length);for(let r=0;r<e.length;r++)n[r]=e.charCodeAt(r);return w(n,t.width,t.height)}imageDataContainsTransparent(t){for(let e=3;e<t.data.length;e+=4)if(255!==t.data[e])return!0;return!1}static from(e){return"string"==typeof e?new t({url:e}):e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof ImageData||e instanceof HTMLVideoElement?new t({data:e}):x(t,e)}};u([p({type:String,json:{write:h}})],Rt.prototype,"url",null),u([p({json:{write:{overridePolicy(){return{enabled:!this.url}}}}}),p()],Rt.prototype,"data",null),u([f("data")],Rt.prototype,"writeData",null),u([g("data")],Rt.prototype,"readData",null),u([p({type:Boolean,json:{write:{overridePolicy(){return{enabled:this._isOverridden("transparent")}}}}})],Rt.prototype,"transparent",null),u([p({json:{write:!0}})],Rt.prototype,"wrap",void 0),u([p({readOnly:!0})],Rt.prototype,"contentHash",null),Rt=t=u([d("esri.geometry.support.MeshTexture")],Rt);var jt,Ot=Rt;let Ct=jt=class extends m{constructor(t){super(t),this.color=null,this.colorTexture=null,this.normalTexture=null,this.alphaMode="auto",this.alphaCutoff=.5,this.doubleSided=!0}clone(){return this.cloneWithDeduplication(null,new Map)}cloneWithDeduplication(t,e){const n=b(t)?t.get(this):null;if(n)return n;const r=new jt(this.clonePropertiesWithDeduplication(e));return b(t)&&t.set(this,r),r}clonePropertiesWithDeduplication(t){return{color:b(this.color)?this.color.clone():null,colorTexture:b(this.colorTexture)?this.colorTexture.cloneWithDeduplication(t):null,normalTexture:b(this.normalTexture)?this.normalTexture.cloneWithDeduplication(t):null,alphaMode:this.alphaMode,alphaCutoff:this.alphaCutoff,doubleSided:this.doubleSided}}};u([p({type:v,json:{write:!0}})],Ct.prototype,"color",void 0),u([p({type:Ot,json:{write:!0}})],Ct.prototype,"colorTexture",void 0),u([p({type:Ot,json:{write:!0}})],Ct.prototype,"normalTexture",void 0),u([p({nonNullable:!0,json:{write:!0}})],Ct.prototype,"alphaMode",void 0),u([p({nonNullable:!0,json:{write:!0}})],Ct.prototype,"alphaCutoff",void 0),u([p({nonNullable:!0,json:{write:!0}})],Ct.prototype,"doubleSided",void 0),Ct=jt=u([d("esri.geometry.support.MeshMaterial")],Ct);var Dt,Pt=Ct;let Lt=Dt=class extends Pt{constructor(t){super(t),this.emissiveColor=null,this.emissiveTexture=null,this.occlusionTexture=null,this.metallic=1,this.roughness=1,this.metallicRoughnessTexture=null}clone(){return this.cloneWithDeduplication(null,new Map)}cloneWithDeduplication(t,e){const n=b(t)?t.get(this):null;if(n)return n;const r=new Dt(this.clonePropertiesWithDeduplication(e));return b(t)&&t.set(this,r),r}clonePropertiesWithDeduplication(t){return c(l({},super.clonePropertiesWithDeduplication(t)),{emissiveColor:b(this.emissiveColor)?this.emissiveColor.clone():null,emissiveTexture:b(this.emissiveTexture)?this.emissiveTexture.cloneWithDeduplication(t):null,occlusionTexture:b(this.occlusionTexture)?this.occlusionTexture.cloneWithDeduplication(t):null,metallic:this.metallic,roughness:this.roughness,metallicRoughnessTexture:b(this.metallicRoughnessTexture)?this.metallicRoughnessTexture.cloneWithDeduplication(t):null})}};u([p({type:v,json:{write:!0}})],Lt.prototype,"emissiveColor",void 0),u([p({type:Ot,json:{write:!0}})],Lt.prototype,"emissiveTexture",void 0),u([p({type:Ot,json:{write:!0}})],Lt.prototype,"occlusionTexture",void 0),u([p({type:Number,nonNullable:!0,json:{write:!0},range:{min:0,max:1}})],Lt.prototype,"metallic",void 0),u([p({type:Number,nonNullable:!0,json:{write:!0},range:{min:0,max:1}})],Lt.prototype,"roughness",void 0),u([p({type:Ot,json:{write:!0}})],Lt.prototype,"metallicRoughnessTexture",void 0),Lt=Dt=u([d("esri.geometry.support.MeshMaterialMetallicRoughness")],Lt);var It,St=Lt;const Et=A.getLogger("esri.geometry.support.MeshVertexAttributes");let zt=It=class extends m{constructor(t){super(t),this.color=null,this.position=new Float64Array(0),this.uv=null,this.normal=null,this.tangent=null}castColor(t){return Ut(t,Uint8Array,[Uint8ClampedArray],{loggerTag:".color=",stride:4},Et)}castPosition(t){return t&&t instanceof Float32Array&&Et.warn(".position=","Setting position attribute from a Float32Array may cause precision problems. Consider storing data in a Float64Array or a regular number array"),Ut(t,Float64Array,[Float32Array],{loggerTag:".position=",stride:3},Et)}castUv(t){return Ut(t,Float32Array,[Float64Array],{loggerTag:".uv=",stride:2},Et)}castNormal(t){return Ut(t,Float32Array,[Float64Array],{loggerTag:".normal=",stride:3},Et)}castTangent(t){return Ut(t,Float32Array,[Float64Array],{loggerTag:".tangent=",stride:4},Et)}clone(){const t={position:F(this.position),uv:F(this.uv),normal:F(this.normal),tangent:F(this.tangent),color:F(this.color)};return new It(t)}clonePositional(){const t={position:F(this.position),normal:F(this.normal),tangent:F(this.tangent),uv:this.uv,color:this.color};return new It(t)}};function $t(t,e,n,r){const{loggerTag:o,stride:s}=e;return t.length%s!=0?(r.error(o,`Invalid array length, expected a multiple of ${s}`),new n([])):t}function Ut(t,e,n,r,o){if(!t)return t;if(t instanceof e)return $t(t,r,e,o);for(const s of n)if(t instanceof s)return $t(new e(t),r,e,o);if(Array.isArray(t))return $t(new e(t),r,e,o);{const r=n.map((t=>`'${t.name}'`));return o.error(`Failed to set property, expected one of ${r}, but got ${t.constructor.name}`),new e([])}}function Nt(t,e,n){e[n]=function(t){const e=new Array(t.length);for(let n=0;n<t.length;n++)e[n]=t[n];return e}(t)}u([p({json:{write:Nt}})],zt.prototype,"color",void 0),u([M("color")],zt.prototype,"castColor",null),u([p({nonNullable:!0,json:{write:Nt}})],zt.prototype,"position",void 0),u([M("position")],zt.prototype,"castPosition",null),u([p({json:{write:Nt}})],zt.prototype,"uv",void 0),u([M("uv")],zt.prototype,"castUv",null),u([p({json:{write:Nt}})],zt.prototype,"normal",void 0),u([M("normal")],zt.prototype,"castNormal",null),u([p({json:{write:Nt}})],zt.prototype,"tangent",void 0),u([M("tangent")],zt.prototype,"castTangent",null),zt=It=u([d("esri.geometry.support.MeshVertexAttributes")],zt);var Wt,kt=zt;const _t=A.getLogger("esri.geometry.support.MeshComponent");let Bt=Wt=class extends m{constructor(t){super(t),this.faces=null,this.material=null,this.shading="source",this.trustSourceNormals=!1}static from(t){return x(Wt,t)}castFaces(t){return Ut(t,Uint32Array,[Uint16Array],{loggerTag:".faces=",stride:3},_t)}castMaterial(t){return x(t&&"object"==typeof t&&("metallic"in t||"roughness"in t||"metallicRoughnessTexture"in t)?St:Pt,t)}clone(){return new Wt({faces:F(this.faces),shading:this.shading,material:F(this.material),trustSourceNormals:this.trustSourceNormals})}cloneWithDeduplication(t,e){const n={faces:F(this.faces),shading:this.shading,material:this.material?this.material.cloneWithDeduplication(t,e):null,trustSourceNormals:this.trustSourceNormals};return new Wt(n)}};u([p({json:{write:!0}})],Bt.prototype,"faces",void 0),u([M("faces")],Bt.prototype,"castFaces",null),u([p({type:Pt,json:{write:!0}})],Bt.prototype,"material",void 0),u([M("material")],Bt.prototype,"castMaterial",null),u([p({type:String,json:{write:!0}})],Bt.prototype,"shading",void 0),u([p({type:Boolean})],Bt.prototype,"trustSourceNormals",void 0),Bt=Wt=u([d("esri.geometry.support.MeshComponent")],Bt);var Ht=Bt;function Vt(t){const e=function(t,e,n){const r=t.length,o=new Array(r),s=new Array(r),i=new Array(r);let a=0,l=0,c=0,u=0;for(let f=0;f<r;++f)u+=t[f].length;const p=new Float64Array(3*u);let h=0;for(let f=r-1;f>=0;f--){const u=t[f],g=1===n&&Gt(u);if(g&&1!==r)o[a++]=u;else{let t=u.length;for(let e=0;e<a;++e)t+=o[e].length;const n={index:h,pathLengths:new Array(a+1),count:t,holeIndices:new Array(a)};n.pathLengths[0]=u.length,u.length>0&&(i[c++]={index:h,count:u.length}),h=g?Zt(u,u.length-1,-1,p,h,u.length,e):Zt(u,0,1,p,h,u.length,e);for(let r=0;r<a;++r){const t=o[r];n.holeIndices[r]=h,n.pathLengths[r+1]=t.length,t.length>0&&(i[c++]={index:h,count:t.length}),h=Zt(t,0,1,p,h,t.length,e)}a=0,n.count>0&&(s[l++]=n)}}for(let f=0;f<a;++f){const t=o[f];t.length>0&&(i[c++]={index:h,count:t.length}),h=Zt(t,0,1,p,h,t.length,e)}return l<r&&(s.length=l),c<r&&(i.length=c),{position:p,polygons:s,outlines:i}}(t.rings,t.hasZ,1),n=[];let r=0,o=0;for(const a of e.polygons){const t=a.count,s=a.index,i=new Float64Array(e.position.buffer,3*s*e.position.BYTES_PER_ELEMENT,3*t),l=a.holeIndices.map((t=>t-s)),c=new Uint32Array(vt(i,l,3));n.push({position:i,faces:c}),r+=i.length,o+=c.length}const s=function(t,e,n){if(1===t.length)return t[0];const r=new Float64Array(e),o=new Uint32Array(n);let s=0,i=0,a=0;for(const l of t){for(let t=0;t<l.position.length;t++)r[s++]=l.position[t];for(let t=0;t<l.faces.length;t++)o[i++]=l.faces[t]+a;a=s/3}return{position:r,faces:o}}(n,r,o),i=bt(s.position.buffer,6,{originalIndices:s.faces});return s.position=new Float64Array(i.buffer),s.faces=i.indices,s}function Zt(t,e,n,r,o,s,i){o*=3;for(let a=0;a<s;++a){const s=t[e];r[o++]=s[0],r[o++]=s[1],r[o++]=i?s[2]:0,e+=n}return o/3}function Gt(t){return!T(t,!1,!1)}const Yt=A.getLogger("esri.geometry.support.meshUtils.centerAt");function Jt(t,e,n){var r;if(!t.vertexAttributes||!t.vertexAttributes.position)return;const o=null!=(r=null==n?void 0:n.origin)?r:t.origin;b(t.transform)?(null!=(null==n?void 0:n.geographic)&&n.geographic!==t.transform.geographic&&Yt.warn(`Specifying the 'geographic' parameter (${n.geographic}) different from the Mesh transform setting (${t.transform.geographic}) is not supported`),function(t,e,n){const r=e.x-n.x,o=e.y-n.y,s=e.hasZ&&n.hasZ?e.z-n.z:0,i=t.origin;t.origin=[i[0]+r,i[1]+o,i[2]+s]}(t.transform,e,o)):ot(t.spatialReference,n)?function(t,e,n){const r=st(t.vertexAttributes,n,{geographic:!0}),{position:o,normal:s,tangent:i}=it(r,e,{geographic:!0});t.vertexAttributes.position=o,t.vertexAttributes.normal=s,t.vertexAttributes.tangent=i,t.vertexAttributesChanged()}(t,e,o):function(t,e,n){const r=qt,o=Xt;if(R(e,o,t.spatialReference)){if(!R(n,r,t.spatialReference)){const e=t.origin;r[0]=e.x,r[1]=e.y,r[2]=e.z,Yt.error(`Failed to project specified origin (wkid:${n.spatialReference.wkid}) to mesh spatial reference (wkid:${t.spatialReference.wkid}).`)}(function(t,e,n){if(t)for(let r=0;r<t.length;r+=3)for(let o=0;o<3;o++)t[r+o]+=e[o]-n[o]})(t.vertexAttributes.position,o,r),t.vertexAttributesChanged()}else Yt.error(`Failed to project centerAt location (wkid:${e.spatialReference.wkid}) to mesh spatial reference (wkid:${t.spatialReference.wkid})`)}(t,e,o)}const Xt=j(),qt=j();function Kt(t){const e=P(t.url);return n=>{var r;const o=D(n,e,e),s=o?o.replace(/^ *\.\//,""):null;return null!=(r=t.files.get(s))?r:n}}async function Qt(t,e){return t instanceof Blob?te.fromBlob(t):"string"==typeof t?new te(t):Array.isArray(t)?async function(t,e){const n=new Map;let r=null;const o=await L(t.map((async t=>({name:t.name,source:await Qt(t instanceof Blob?t:t.source,e)})))),s=[];for(const i of o)i&&(I(e)?i.source.dispose():s.push(i));S(e);for(const{name:i,source:a}of s)(E(r)||/\.(gltf|glb)/i.test(i))&&(r=a.url),n.set(i,a.url),a.files&&a.files.forEach(((t,e)=>n.set(e,t)));if(E(r))throw new z("mesh-load-external:missing-files","Missing files to load external mesh source");return new te(r,(()=>s.forEach((({source:t})=>t.dispose()))),n)}(t,e):async function(t,e){const{default:n}=await O(import("./vendor.d9ce5f39.js").then((function(t){return t.iI})),e),r="string"==typeof t.multipart[0]?await Promise.all(t.multipart.map((async t=>(await n(t,{responseType:"array-buffer"})).data))):t.multipart;return te.fromBlob(new Blob(r))}(t,e)}class te{constructor(t,e=(()=>{}),n=new Map){this.url=t,this.dispose=e,this.files=n}static fromBlob(t){const e=URL.createObjectURL(t);return new te(e,(()=>URL.revokeObjectURL(e)))}}const ee=A.getLogger("esri.geometry.support.meshUtils.offset");function ne(t,e,n){t.vertexAttributes&&t.vertexAttributes.position&&(b(t.transform)?(null!=(null==n?void 0:n.geographic)&&n.geographic!==t.transform.geographic&&ee.warn(`Specifying the 'geographic' parameter (${n.geographic}) different from the Mesh transform setting (${t.transform.geographic}) is not supported`),function(t,e){const n=t.origin;t.origin=$(j(),n,e)}(t.transform,e)):ot(t.spatialReference,n)?function(t,e){const n=t.spatialReference,r=t.vertexAttributes.position,o=t.vertexAttributes.normal,s=t.vertexAttributes.tangent,i=new Float64Array(r.length),a=b(o)?new Float32Array(o.length):null,l=b(s)?new Float32Array(s.length):null,c=t.extent.center,u=oe;U(n,[c.x,c.y,c.z],se,N(n)),W(ie,se),k(u,e,ie),at(r,n,i),b(o)&&lt(o,r,i,n,a),b(s)&&ct(s,r,i,n,l),re(i,u),ut(i,r,n),b(o)&&pt(a,r,i,n,o),b(s)&&ht(l,r,i,n,s),t.vertexAttributesChanged()}(t,e):function(t,e){re(t.vertexAttributes.position,e),t.vertexAttributesChanged()}(t,e))}function re(t,e){if(t)for(let n=0;n<t.length;n+=3)for(let r=0;r<3;r++)t[n+r]+=e[r]}const oe=j(),se=Mt(),ie=At();const ae={position:[-.5,-.5,0,.5,-.5,0,.5,.5,0,-.5,.5,0],normal:[0,0,1,0,0,1,0,0,1,0,0,1],uv:[0,1,1,1,1,0,0,0],faces:[0,1,2,0,2,3],facingAxisOrderSwap:{east:[3,1,2],west:[-3,-1,2],north:[-1,3,2],south:[1,-3,2],up:[1,2,3],down:[1,-2,-3]}};function le(t,e,n){(function(t){for(let e=0;e<t.position.length;e+=3)t.position[e+2]+=.5})(t),function(t,e){if(null==e)return;const n="number"==typeof e?[e,e,e]:[null!=e.width?e.width:1,null!=e.depth?e.depth:1,null!=e.height?e.height:1];he[0]=n[0],he[4]=n[1],he[8]=n[2];for(let r=0;r<t.position.length;r+=3){for(let e=0;e<3;e++)pe[e]=t.position[r+e];k(pe,pe,he);for(let e=0;e<3;e++)t.position[r+e]=pe[e]}if(n[0]!==n[1]||n[1]!==n[2]){he[0]=1/n[0],he[4]=1/n[1],he[8]=1/n[2];for(let e=0;e<t.normal.length;e+=3){for(let n=0;n<3;n++)pe[n]=t.normal[e+n];k(pe,pe,he),_(pe,pe);for(let n=0;n<3;n++)t.normal[e+n]=pe[n]}}}(t,n&&n.size);const{vertexAttributes:r,transform:o}=ft(t,e,n);return{vertexAttributes:new kt(c(l({},r),{uv:t.uv})),transform:o,components:[new Ht({faces:t.faces,material:n&&n.material||null})],spatialReference:e.spatialReference}}const ce={faceDescriptions:[{axis:[0,-1,0],uvOrigin:[0,.625],corners:[[-1,-1],[1,-1],[1,1],[-1,1]]},{axis:[1,0,0],uvOrigin:[.25,.625],corners:[[-1,-1],[1,-1],[1,1],[-1,1]]},{axis:[0,1,0],uvOrigin:[.5,.625],corners:[[1,-1],[-1,-1],[-1,1],[1,1]]},{axis:[-1,0,0],uvOrigin:[.75,.625],corners:[[1,-1],[-1,-1],[-1,1],[1,1]]},{axis:[0,0,1],uvOrigin:[0,.375],corners:[[-1,-1],[1,-1],[1,1],[-1,1]]},{axis:[0,0,-1],uvOrigin:[0,.875],corners:[[-1,1],[1,1],[1,-1],[-1,-1]]}],uvScales:[[0,0],[1,0],[1,1],[0,1]],faceVertexOffsets:[0,1,2,0,2,3]},ue={south:0,east:1,north:2,west:3,up:4,down:5},pe=j(),he=At(),fe=A.getLogger("esri.geometry.support.meshUtils.rotate");function ge(t,e,n){if(!t.vertexAttributes||!t.vertexAttributes.position||0===e[3])return;const r=t.spatialReference;if(b(t.transform)){var o;null!=(null==n?void 0:n.geographic)&&n.geographic!==t.transform.geographic&&fe.warn(`Specifying the 'geographic' parameter (${n.geographic}) different from the Mesh transform setting (${t.transform.geographic}) is not supported`);const s=null!=(o=null==n?void 0:n.origin)?o:t.transform.getOriginPoint(r);!function(t,e,n){const r=B(me,n.x,n.y,n.z),o=H(me,r,t.origin);t.applyLocalInverse(o,ye),t.rotation=dt(t.rotation,e,gt()),t.applyLocalInverse(o,o),H(o,o,ye),t.translation=$(j(),t.translation,o)}(t.transform,e,s)}else{var s;const r=null!=(s=null==n?void 0:n.origin)?s:t.origin;ot(t.spatialReference,n)?function(t,e,n){const r=t.spatialReference,o=N(r),s=be;R(n,s,o)||R(t.origin,s,o);const i=t.vertexAttributes.position,a=t.vertexAttributes.normal,l=t.vertexAttributes.tangent,c=new Float64Array(i.length),u=b(a)?new Float32Array(a.length):null,p=b(l)?new Float32Array(l.length):null;U(o,s,xe,o),W(ve,xe);const h=we;k(mt(we),mt(e),ve),h[3]=e[3],at(i,r,c),b(a)&&lt(a,i,c,r,u),b(l)&&ct(l,i,c,r,p),de(c,h,3,s),ut(c,i,r),b(a)&&(de(u,h,3),pt(u,i,c,r,a)),b(l)&&(de(p,h,4),ht(p,i,c,r,l)),t.vertexAttributesChanged()}(t,e,r):function(t,e,n){const r=be;if(!R(n,r,t.spatialReference)){const e=t.origin;r[0]=e.x,r[1]=e.y,r[2]=e.z,fe.error(`Failed to project specified origin (wkid:${n.spatialReference.wkid}) to mesh spatial reference (wkid:${t.spatialReference.wkid}).`)}de(t.vertexAttributes.position,e,3,r),de(t.vertexAttributes.normal,e,3),de(t.vertexAttributes.tangent,e,4),t.vertexAttributesChanged()}(t,e,r)}}function de(t,e,n,r=V){if(!E(t)){Z(xe),G(xe,xe,yt(e),mt(e));for(let e=0;e<t.length;e+=n){for(let n=0;n<3;n++)me[n]=t[e+n]-r[n];Y(me,me,xe);for(let n=0;n<3;n++)t[e+n]=me[n]+r[n]}}}const me=j(),ye=j(),we=gt(),xe=Mt(),ve=At(),be=j(),Ae=A.getLogger("esri.geometry.support.meshUtils.scale");function Me(t,e,n){if(!t.vertexAttributes||!t.vertexAttributes.position)return;const r=t.spatialReference;if(b(t.transform)){var o;null!=(null==n?void 0:n.geographic)&&n.geographic!==t.transform.geographic&&Ae.warn(`Specifying the 'geographic' parameter (${n.geographic}) different from the Mesh transform setting (${t.transform.geographic}) is not supported`);const s=null!=(o=null==n?void 0:n.origin)?o:t.transform.getOriginPoint(r);!function(t,e,n){const r=B(Te,n.x,n.y,n.z),o=H(Te,r,t.origin);t.applyLocalInverse(o,Re);const s=J(j(),t.scale,e);t.scale=s,t.applyLocalInverse(o,o),H(o,o,Re),t.translation=$(j(),t.translation,o)}(t.transform,e,s)}else{const r=ot(t.spatialReference,n),o=n&&n.origin||t.origin;r?function(t,e,n){const r=t.spatialReference,o=N(r),s=je;R(n,s,o)||R(t.origin,s,o);const i=t.vertexAttributes.position,a=t.vertexAttributes.normal,l=t.vertexAttributes.tangent,c=new Float64Array(i.length),u=b(a)?new Float32Array(a.length):null,p=b(l)?new Float32Array(l.length):null;at(i,r,c),b(a)&&lt(a,i,c,r,u),b(l)&&ct(l,i,c,r,p),Fe(c,e,s),ut(c,i,r),b(a)&&pt(u,i,c,r,a),b(l)&&ht(p,i,c,r,l),t.vertexAttributesChanged()}(t,e,o):function(t,e,n){const r=je;if(!R(n,r,t.spatialReference)){const e=t.origin;r[0]=e.x,r[1]=e.y,r[2]=e.z,Ae.error(`Failed to project specified origin (wkid:${n.spatialReference.wkid}) to mesh spatial reference (wkid:${t.spatialReference.wkid}).`)}Fe(t.vertexAttributes.position,e,r),t.vertexAttributesChanged()}(t,e,o)}}function Fe(t,e,n=V){if(t)for(let r=0;r<t.length;r+=3){for(let e=0;e<3;e++)Te[e]=t[r+e]-n[e];J(Te,Te,e);for(let e=0;e<3;e++)t[r+e]=Te[e]+n[e]}}const Te=j(),Re=j(),je=j();var Oe;const Ce=A.getLogger("esri.geometry.Mesh");let De=Oe=class extends(X.LoadableMixin(q(K))){constructor(t){super(t),this.components=null,this.transform=null,this.external=null,this.hasZ=!0,this.hasM=!1,this.vertexAttributes=new zt,this.type="mesh"}initialize(){(E(this.external)||this.vertexAttributes.position.length)&&(this.loadStatus="loaded")}get hasExtent(){return!this.loaded&&b(this.external)&&b(this.external.extent)||this.loaded&&this.vertexAttributes.position.length>0&&(!this.components||this.components.length>0)}get boundingInfo(){const t=this.vertexAttributes.position,e=this.spatialReference;if(0===t.length||this.components&&0===this.components.length)return{extent:new Q({xmin:0,ymin:0,zmin:0,xmax:0,ymax:0,zmax:0,spatialReference:e}),center:new C({x:0,y:0,z:0,spatialReference:e})};const n=b(this.transform)?this.transform.project(t,e):t;let r=1/0,o=1/0,s=1/0,i=-1/0,a=-1/0,l=-1/0,c=0,u=0,p=0;const h=n.length,f=1/(h/3);let g=0;for(;g<h;){const t=n[g++],e=n[g++],h=n[g++];r=Math.min(r,t),o=Math.min(o,e),s=Math.min(s,h),i=Math.max(i,t),a=Math.max(a,e),l=Math.max(l,h),c+=f*t,u+=f*e,p+=f*h}return{extent:new Q({xmin:r,ymin:o,zmin:s,xmax:i,ymax:a,zmax:l,spatialReference:e}),center:new C({x:c,y:u,z:p,spatialReference:e})}}get anchor(){if(b(this.transform))return this.transform.getOriginPoint(this.spatialReference);const t=this.boundingInfo;return new C({x:t.center.x,y:t.center.y,z:t.extent.zmin,spatialReference:this.spatialReference})}get origin(){return b(this.transform)?this.transform.getOriginPoint(this.spatialReference):this.boundingInfo.center}get extent(){return!this.loaded&&b(this.external)&&b(this.external.extent)?this.external.extent.clone():this.boundingInfo.extent}addComponent(t){this.loaded?(this.components||(this.components=[]),this.components.push(Ht.from(t)),this.notifyChange("components")):Ce.error("addComponent()","Mesh must be loaded before applying operations")}removeComponent(t){if(this.loaded){if(this.components){const e=this.components.indexOf(t);if(-1!==e)return this.components.splice(e,1),void this.notifyChange("components")}Ce.error("removeComponent()","Provided component is not part of the list of components")}else Ce.error("removeComponent()","Mesh must be loaded before applying operations")}rotate(t,e,n,r){return wt(Pe.x,t,Le),wt(Pe.y,e,Ie),wt(Pe.z,n,Se),dt(Le,Ie,Le),dt(Le,Se,Le),ge(this,Le,r),this}offset(t,e,n,r){return this.loaded?(Ee[0]=t,Ee[1]=e,Ee[2]=n,ne(this,Ee,r),this):(Ce.error("offset()","Mesh must be loaded before applying operations"),this)}scale(t,e){return this.loaded?(Me(this,t,e),this):(Ce.error("scale()","Mesh must be loaded before applying operations"),this)}centerAt(t,e){return this.loaded?(Jt(this,t,e),this):(Ce.error("centerAt()","Mesh must be loaded before applying operations"),this)}load(t){return b(this.external)&&this.addResolvingPromise(async function(t,e,n){const{loadGLTFMesh:r}=await O(import("./loadGLTFMesh.37983ea4.js"),n),o=await Qt(e,n),s=r(new C({x:0,y:0,z:0,spatialReference:t.spatialReference}),o.url,{resolveFile:Kt(o),useTransform:!0,signal:b(n)?n.signal:null});s.then((()=>o.dispose()),(()=>o.dispose()));const{vertexAttributes:i,components:a}=await s;t.vertexAttributes=i,t.components=a}(this,this.external.source,t)),Promise.resolve(this)}clone(){const t=this.components?new Map:null,e=this.components?new Map:null,n={components:this.components?this.components.map((n=>n.cloneWithDeduplication(t,e))):null,spatialReference:this.spatialReference,vertexAttributes:this.vertexAttributes.clone(),transform:b(this.transform)?this.transform.clone():null,external:b(this.external)?{source:this.external.source,extent:b(this.external.extent)?this.external.extent.clone():null}:null};return new Oe(n)}vertexAttributesChanged(){this.notifyChange("vertexAttributes")}async toBinaryGLTF(t){const{toBinaryGLTF:e}=await import("./gltfexport.cdddb8e0.js");return e(this,t)}static createBox(t,e){if(!(t instanceof C))return Ce.error(".createBox()","expected location to be a Point instance"),null;const n=new Oe(le(function(){const{faceDescriptions:t,faceVertexOffsets:e,uvScales:n}=ce,r=4*t.length,o=new Float64Array(3*r),s=new Float32Array(3*r),i=new Float32Array(2*r),a=new Uint32Array(2*t.length*3);let l=0,c=0,u=0,p=0;for(let h=0;h<t.length;h++){const r=t[h],f=l/3;for(const t of e)a[p++]=f+t;const g=r.corners;for(let t=0;t<4;t++){const e=g[t];let a=0;i[u++]=.25*n[t][0]+r.uvOrigin[0],i[u++]=r.uvOrigin[1]-.25*n[t][1];for(let t=0;t<3;t++)0!==r.axis[t]?(o[l++]=.5*r.axis[t],s[c++]=r.axis[t]):(o[l++]=.5*e[a++],s[c++]=0)}}return{position:o,normal:s,uv:i,faces:a}}(),t,e));return e&&e.imageFace&&"all"!==e.imageFace?function(t,e){const n=t.components[0],r=n.faces,o=ue[e],s=6*o,i=new Uint32Array(6),a=new Uint32Array(r.length-6);let l=0,c=0;for(let u=0;u<r.length;u++)u>=s&&u<s+6?i[l++]=r[u]:a[c++]=r[u];if(b(t.vertexAttributes.uv)){const e=new Float32Array(t.vertexAttributes.uv),n=4*o*2,r=[0,1,1,1,1,0,0,0];for(let t=0;t<r.length;t++)e[n+t]=r[t];t.vertexAttributes.uv=e}return t.components=[new Ht({faces:i,material:n.material}),new Ht({faces:a})],t}(n,e.imageFace):n}static createSphere(t,e){return t instanceof C?new Oe(le(function(t=0){const e=Math.round(8*2**t),n=2*e,r=(e-1)*(n+1)+2*n,o=new Float64Array(3*r),s=new Float32Array(3*r),i=new Float32Array(2*r),a=new Uint32Array((e-1)*n*2*3);let l=0,c=0,u=0,p=0;for(let h=0;h<=e;h++){const t=h/e*Math.PI+.5*Math.PI,r=Math.cos(t),f=Math.sin(t);pe[2]=f;const g=0===h||h===e,d=g?n-1:n;for(let m=0;m<=d;m++){const t=m/d*2*Math.PI;pe[0]=-Math.sin(t)*r,pe[1]=Math.cos(t)*r;for(let e=0;e<3;e++)o[l]=.5*pe[e],s[l]=pe[e],++l;i[c++]=(m+(g?.5:0))/n,i[c++]=h/e,0!==h&&m!==n&&(h!==e&&(a[u++]=p,a[u++]=p+1,a[u++]=p-n),1!==h&&(a[u++]=p,a[u++]=p-n,a[u++]=p-n-1)),p++}}return{position:o,normal:s,uv:i,faces:a}}(e&&e.densificationFactor||0),t,e)):(Ce.error(".createSphere()","expected location to be a Point instance"),null)}static createCylinder(t,e){return t instanceof C?new Oe(le(function(t=0){const e=Math.round(16*2**t),n=4*(e+1)+2*e,r=new Float64Array(3*n),o=new Float32Array(3*n),s=new Float32Array(2*n),i=new Uint32Array(4*e*3);let a=0,l=0,c=0,u=0,p=0;for(let h=0;h<=5;h++){const t=0===h||5===h,n=h<=1||h>=4,f=2===h||4===h,g=t?e-1:e;for(let d=0;d<=g;d++){const m=d/g*2*Math.PI,y=t?0:.5;pe[0]=y*Math.sin(m),pe[1]=y*-Math.cos(m),pe[2]=h<=2?.5:-.5;for(let t=0;t<3;t++)r[a++]=pe[t],o[l++]=n?2===t?h<=1?1:-1:0:2===t?0:pe[t]/y;s[c++]=(d+(t?.5:0))/e,s[c++]=h<=1?1*h/3:h<=3?1*(h-2)/3+1/3:1*(h-4)/3+2/3,f||0===h||d===e||(5!==h&&(i[u++]=p,i[u++]=p+1,i[u++]=p-e),1!==h&&(i[u++]=p,i[u++]=p-e,i[u++]=p-e-1)),p++}}return{position:r,normal:o,uv:s,faces:i}}(e&&e.densificationFactor||0),t,e)):(Ce.error(".createCylinder()","expected location to be a Point instance"),null)}static createPlane(t,e){return t instanceof C?new Oe(le(function(t){const e=ae.facingAxisOrderSwap[t],n=ae.position,r=ae.normal,o=new Float64Array(n.length),s=new Float32Array(r.length);let i=0;for(let a=0;a<4;a++){const t=i;for(let a=0;a<3;a++){const l=e[a],c=Math.abs(l)-1,u=l>=0?1:-1;o[i]=n[t+c]*u,s[i]=r[t+c]*u,i++}}return{position:o,normal:s,uv:new Float32Array(ae.uv),faces:new Uint32Array(ae.faces)}}(e&&e.facing||"up"),t,e)):(Ce.error(".createPlane()","expected location to be a Point instance"),null)}static createFromPolygon(t,e){if(!(t instanceof tt))return Ce.error(".createFromPolygon()","expected polygon to be a Polygon instance"),null;const n=Vt(t);return new Oe({vertexAttributes:new zt({position:n.position}),components:[new Ht({faces:n.faces,shading:"flat",material:e&&e.material||null})],spatialReference:t.spatialReference})}static async createFromGLTF(t,e,n){if(!(t instanceof C))throw Ce.error(".createfromGLTF()","expected location to be a Point instance"),new z("invalid-input","Expected location to be a Point instance");const{loadGLTFMesh:r}=await O(import("./loadGLTFMesh.37983ea4.js"),n);return new Oe(await r(t,e,n))}static createWithExternalSource(t,e,n){var r,o,s;const i=null!=(r=null==n?void 0:n.extent)?r:null,a=null!=(o=null==n?void 0:n.transform.clone())?o:new xt;a.origin=[t.x,t.y,null!=(s=t.z)?s:0];const l=t.spatialReference;return new Oe({external:{source:e,extent:i},transform:a,spatialReference:l})}static createIncomplete(t,e){var n,r;const o=null!=(n=null==e?void 0:e.transform.clone())?n:new xt;o.origin=[t.x,t.y,null!=(r=t.z)?r:0];const s=t.spatialReference,i=new Oe({transform:o,spatialReference:s});return i.addResolvingPromise(Promise.reject(new z("mesh-incomplete","Mesh resources are not complete"))),i}};u([p({type:[Ht],json:{write:!0}})],De.prototype,"components",void 0),u([p({type:xt,json:{write:!0}})],De.prototype,"transform",void 0),u([p({constructOnly:!0})],De.prototype,"external",void 0),u([p({readOnly:!0})],De.prototype,"hasExtent",null),u([p({readOnly:!0})],De.prototype,"boundingInfo",null),u([p({readOnly:!0})],De.prototype,"anchor",null),u([p({readOnly:!0})],De.prototype,"origin",null),u([p({readOnly:!0,json:{read:!1}})],De.prototype,"extent",null),u([p({readOnly:!0,json:{read:!1,write:!0,default:!0}})],De.prototype,"hasZ",void 0),u([p({readOnly:!0,json:{read:!1,write:!0,default:!1}})],De.prototype,"hasM",void 0),u([p({type:zt,nonNullable:!0,json:{write:!0}})],De.prototype,"vertexAttributes",void 0),De=Oe=u([d("esri.geometry.Mesh")],De);const Pe={x:et(1,0,0),y:et(0,1,0),z:et(0,0,1)},Le=gt(),Ie=gt(),Se=gt(),Ee=j();var ze=De;function $e(t,e,n){const{status:r,source:o}=function(t){if(!t.assetMappings)return{status:0};const e=[],n=new Map;for(const r of t.assetMappings){const t=r.seqNo,o=r.assetName,s=r.assetURL,i=r.conversionStatus;if("FAILED"===i)return{status:0};if("COMPLETED"!==i)return{status:1};if(null==t)e.push({name:o,source:s});else{const r=n.get(o);let i;r?i=r.multipart:(i=[],e.push({name:o,source:{multipart:i}}),n.set(o,{multipart:i})),i[t]=s}}return{status:2,source:e}}(t);if(0===r)return null;const s=function({attributes:t},e,{transformFieldRoles:n}){return new C({x:t[n.originX],y:t[n.originY],z:t[n.originZ],spatialReference:e})}(t,e,n),i=Q.fromJSON(t.geometry);i.spatialReference=e;const a=function({attributes:t,assetMappings:e},{transformFieldRoles:n}){var r;return new xt({translation:[t[n.translationX],t[n.translationY],t[n.translationZ]],rotation:wt([t[n.rotationX],t[n.rotationY],t[n.rotationZ]],t[n.rotationDeg]),scale:[t[n.scaleX],t[n.scaleY],t[n.scaleZ]],geographic:!(null!=(r=e.flags)&&r.includes("PROJECT_VERTICES"))})}(t,n);return 1===r?ze.createIncomplete(s,{extent:i,transform:a}):ze.createWithExternalSource(s,o,{extent:i,transform:a})}var Ue=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",meshFeatureSetFromJSON:function(t,e,n){const r=n.features;n.features=[],delete n.geometryType;const o=nt.fromJSON(n);o.geometryType="mesh";const s=o.spatialReference,i=E(t.outFields)||!t.outFields.length?()=>({}):(a=t.outFields.includes("*")?null:new Set(t.outFields),({attributes:t})=>{if(!t)return{};if(!a)return t;for(const e in t)a.has(e)||delete t[e];return t});var a;for(const l of r){const t=$e(l,s,e);b(t)&&o.features.push(new rt({geometry:t,attributes:i(l)}))}return o}});export{Ue as a,St as c,Ht as f,Ot as m,kt as y};
  