@geoscene/core 4.29.5 → 4.29.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/arcade/serviceAreaMetaData.js +1 -1
- package/assets/geoscene/core/workers/RemoteClient.js +1 -1
- package/assets/geoscene/core/workers/chunks/02a8f0cc511b810d29dd.js +1 -1
- package/assets/geoscene/core/workers/chunks/0b2f4079142b4c2a4ddf.js +1 -1
- package/assets/geoscene/core/workers/chunks/26f1ec6ce2720bcc1202.js +1 -1
- package/assets/geoscene/core/workers/chunks/348bcc57b99a975902a8.js +1 -1
- package/assets/geoscene/core/workers/chunks/54c8eea3a70e92842c6a.js +1 -1
- package/assets/geoscene/core/workers/chunks/5db9739e00f15613d1ea.js +1 -1
- package/assets/geoscene/core/workers/chunks/71fed2917f4bee173836.js +1 -1
- package/assets/geoscene/core/workers/chunks/851de06c5980b9b7362a.js +1 -1
- package/assets/geoscene/core/workers/chunks/9d8ce7eec9d80a038477.js +1 -1
- package/assets/geoscene/core/workers/chunks/b139cf91bc148aa84419.js +1 -1
- package/assets/geoscene/core/workers/chunks/c527692694688a5b3b07.js +2 -4
- package/assets/geoscene/core/workers/chunks/c556644bb0cf88770939.js +1 -1
- package/assets/geoscene/core/workers/chunks/cf3d5bd2c9115a3e0b79.js +1 -1
- package/assets/geoscene/core/workers/chunks/eceaa46f622f6fa31128.js +1 -1
- package/assets/geoscene/core/workers/chunks/f59b5ea05caca8a1a398.js +1 -1
- package/assets/geoscene/core/workers/chunks/f60e5dd0e712cf32f782.js +1 -1
- package/assets/geoscene/images/basemap/gray.jpg +0 -0
- package/assets/geoscene/themes/base/widgets/_BasemapGallery.scss +0 -1
- package/assets/geoscene/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_ar.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_bg.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_bs.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_ca.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_cs.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_da.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_de.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_el.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_en.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_es.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_et.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_fi.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_fr.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_he.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_hr.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_hu.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_id.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_it.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_ja.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_ko.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_lt.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_lv.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_nb.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_nl.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_pl.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_pt-BR.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_pt-PT.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_ro.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_ru.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_sk.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_sl.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_sr.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_sv.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_th.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_tr.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_uk.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_vi.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_zh-CN.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_zh-HK.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_zh-TW.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_ar.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_bg.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_bs.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_ca.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_cs.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_da.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_de.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_el.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_en.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_es.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_et.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_fi.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_fr.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_he.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_hr.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_hu.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_id.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_it.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_ja.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_ko.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_lt.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_lv.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_nb.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_nl.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_pl.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_pt-BR.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_pt-PT.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_ro.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_ru.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_sk.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_sl.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_sr.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_sv.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_th.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_tr.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_uk.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_vi.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_zh-CN.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_zh-HK.json +1 -1
- package/assets/geoscene/widgets/UtilityNetworkValidateTopology/t9n/UtilityNetworkValidateTopology_zh-TW.json +1 -1
- package/chunks/HUDMaterial.glsl.js +0 -1
- package/chunks/persistableUrlUtils.js +1 -1
- package/config.js +1 -1
- package/copyright.txt +1 -1
- package/core/devEnvironmentUtils.js +1 -1
- package/core/urlUtils.js +1 -1
- package/identity/IdentityManagerBase.js +1 -1
- package/identity/IdentityModal.js +1 -1
- package/layers/TileLayer.js +1 -1
- package/layers/VectorTileLayer.js +1 -1
- package/layers/support/arcgisLayerUrl.js +1 -1
- package/layers/support/arcgisLayers.js +1 -1
- package/package.json +1 -1
- package/portal/schemas/definitions.js +1 -1
- package/portal/support/urlUtils.js +1 -1
- package/request.js +1 -1
- package/rest/support/PlacesParameters.js +1 -1
- package/smartMapping/support/utils.js +1 -1
- package/support/BasemapStyle.js +1 -1
- package/support/apiKeyUtils.js +1 -1
- package/support/basemapDefinitions.js +1 -1
- package/support/basemapUtils.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/attributes/InstancedDoublePrecision.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/util/MixExternalColor.glsl.js +0 -2
- package/widgets/Editor/EditorViewModel.js +1 -1
- package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
- package/widgets/Search/support/layerSearchUtils.js +1 -1
- package/assets/geoscene/core/workers/chunks/0af5d2f792b83f7dd0aa.js.LICENSE.txt +0 -5
- package/assets/geoscene/core/workers/chunks/5015d4fccf4854b9da1e.js.LICENSE.txt +0 -10
- package/assets/geoscene/core/workers/chunks/54c8eea3a70e92842c6a.js.LICENSE.txt +0 -16
- package/assets/geoscene/core/workers/chunks/804267fca0627d277286.js.LICENSE.txt +0 -5
- package/assets/geoscene/core/workers/chunks/87c4848dd48119fd75f9.js.LICENSE.txt +0 -5
- package/assets/geoscene/core/workers/chunks/8ec7475f19f8979dfaae.js.LICENSE.txt +0 -5
- package/assets/geoscene/core/workers/chunks/904b3e9c98e5de220650.js.LICENSE.txt +0 -11
- package/assets/geoscene/core/workers/chunks/c1f78653c70f6bde65b3.js.LICENSE.txt +0 -5
- package/assets/geoscene/core/workers/chunks/da21d31db537be097da9.js.LICENSE.txt +0 -5
- package/assets/geoscene/core/workers/chunks/e742cd41ab9b164ad974.js.LICENSE.txt +0 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(self.webpackChunkRemoteClient=self.webpackChunkRemoteClient||[]).push([[872],{54792:(t,e,s)=>{s.d(e,{c:()=>n});var i=s(67432),r=s(9592);class n{constructor(t=(t=>t.values().next().value)){this._peeker=t,this._observable=new r.n,this._items=new Set}get length(){return(0,i.am)(this._observable),this._items.size}clear(){0!==this.length&&(this._items.clear(),this._observable.notify())}last(){if(0===this.length)return;let t;for(t of this._items);return t}peek(){if(0!==this.length)return this._peeker(this._items)}push(t){this.contains(t)||(this._items.add(t),this._observable.notify())}contains(t){return(0,i.am)(this._observable),this._items.has(t)}pop(){if(0===this.length)return;const t=this.peek();return this._items.delete(t),this._observable.notify(),t}popLast(){if(0===this.length)return;const t=this.last();return this._items.delete(t),this._observable.notify(),t}remove(t){this.contains(t)&&(this._items.delete(t),this._observable.notify())}filter(t){const e=this.length;return this._items.forEach((e=>{t(e)||this._items.delete(e)})),e!==this._items.size&&this._observable.notify(),this}*[Symbol.iterator](){(0,i.am)(this._observable),yield*this._items}}},23964:(t,e,s)=>{s.d(e,{c:()=>n});var i=s(67432),r=s(9592);class n{constructor(t){this._observable=new r.n,this._map=new Map(t)}get size(){return(0,i.am)(this._observable),this._map.size}clear(){this._map.size>0&&(this._map.clear(),this._observable.notify())}delete(t){const e=this._map.delete(t);return e&&this._observable.notify(),e}entries(){return(0,i.am)(this._observable),this._map.entries()}forEach(t,e){(0,i.am)(this._observable),this._map.forEach(((s,i)=>t.call(e,s,i,this)),e)}get(t){return(0,i.am)(this._observable),this._map.get(t)}has(t){return(0,i.am)(this._observable),this._map.has(t)}keys(){return(0,i.am)(this._observable),this._map.keys()}set(t,e){return this._map.set(t,e),this._observable.notify(),this}values(){return(0,i.am)(this._observable),this._map.values()}[Symbol.iterator](){return(0,i.am)(this._observable),this._map[Symbol.iterator]()}get[Symbol.toStringTag](){return this._map[Symbol.toStringTag]}}},38600:(t,e,s)=>{function i(){return new Float32Array(2)}function r(t,e){const s=new Float32Array(2);return s[0]=t,s[1]=e,s}function n(){return i()}function o(){return r(1,1)}function a(){return r(1,0)}function h(){return r(0,1)}s.d(e,{Qw:()=>l,Su:()=>i,WK:()=>r,cX:()=>c});const c=n(),l=o(),u=a(),d=h();Object.freeze(Object.defineProperty({__proto__:null,ONES:l,UNIT_X:u,UNIT_Y:d,ZEROS:c,clone:function(t){const e=new Float32Array(2);return e[0]=t[0],e[1]=t[1],e},create:i,createView:function(t,e){return new Float32Array(t,e,2)},fromValues:r,ones:o,unitX:a,unitY:h,zeros:n},Symbol.toStringTag,{value:"Module"}))},85256:(t,e,s)=>{function i(){return[0,0]}function r(t,e){return[t,e]}function n(){return r(1,1)}function o(){return r(1,0)}function a(){return r(0,1)}s.d(e,{Qw:()=>h,Su:()=>i,WK:()=>r});const h=n(),c=o(),l=a();Object.freeze(Object.defineProperty({__proto__:null,ONES:h,UNIT_X:c,UNIT_Y:l,ZEROS:[0,0],clone:function(t){return[t[0],t[1]]},create:i,createView:function(t,e){return new Float64Array(t,e,2)},fromArray:function(t,e=[0,0]){const s=Math.min(2,t.length);for(let i=0;i<s;++i)e[i]=t[i];return e},fromValues:r,ones:n,unitX:o,unitY:a,zeros:function(){return[0,0]}},Symbol.toStringTag,{value:"Module"}))},37648:(t,e,s)=>{s.d(e,{Cq:()=>d,WO:()=>r,c9:()=>_,m4:()=>p,qy:()=>h});var i=s(47364);function r(t,e,s){return t[0]=e,t[1]=s,t}function n(t,e,s){return t[0]=e[0]-s[0],t[1]=e[1]-s[1],t}function o(t,e,s){return t[0]=e[0]*s[0],t[1]=e[1]*s[1],t}function a(t,e,s){return t[0]=e[0]/s[0],t[1]=e[1]/s[1],t}function h(t,e){const s=e[0]-t[0],i=e[1]-t[1];return Math.sqrt(s*s+i*i)}function c(t,e){const s=e[0]-t[0],i=e[1]-t[1];return s*s+i*i}function l(t){const e=t[0],s=t[1];return Math.sqrt(e*e+s*s)}function u(t){const e=t[0],s=t[1];return e*e+s*s}function d(t,e,s,i){const r=e[0],n=e[1];return t[0]=r+i*(s[0]-r),t[1]=n+i*(s[1]-n),t}function p(t,e,s){const i=e[0],r=e[1];return t[0]=s[0]*i+s[2]*r+s[4],t[1]=s[1]*i+s[3]*r+s[5],t}function _(t,e,s,i){const r=e[0]-s[0],n=e[1]-s[1],o=Math.sin(i),a=Math.cos(i);return t[0]=r*a-n*o+s[0],t[1]=r*o+n*a+s[1],t}const f=l,m=n,g=o,y=a,x=h,b=c,w=u;Object.freeze(Object.defineProperty({__proto__:null,add:function(t,e,s){return t[0]=e[0]+s[0],t[1]=e[1]+s[1],t},angle:function(t,e){const s=t[0],i=t[1],r=e[0],n=e[1];let o=s*s+i*i;o>0&&(o=1/Math.sqrt(o));let a=r*r+n*n;a>0&&(a=1/Math.sqrt(a));const h=(s*r+i*n)*o*a;return h>1?0:h<-1?Math.PI:Math.acos(h)},ceil:function(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t},copy:function(t,e){return t[0]=e[0],t[1]=e[1],t},cross:function(t,e,s){const i=e[0]*s[1]-e[1]*s[0];return t[0]=t[1]=0,t[2]=i,t},dist:x,distance:h,div:y,divide:a,dot:function(t,e){return t[0]*e[0]+t[1]*e[1]},equals:function(t,e){const s=t[0],r=t[1],n=e[0],o=e[1],a=(0,i.Au)();return Math.abs(s-n)<=a*Math.max(1,Math.abs(s),Math.abs(n))&&Math.abs(r-o)<=a*Math.max(1,Math.abs(r),Math.abs(o))},exactEquals:function(t,e){return t[0]===e[0]&&t[1]===e[1]},floor:function(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t},inverse:function(t,e){return t[0]=1/e[0],t[1]=1/e[1],t},len:f,length:l,lerp:d,max:function(t,e,s){return t[0]=Math.max(e[0],s[0]),t[1]=Math.max(e[1],s[1]),t},min:function(t,e,s){return t[0]=Math.min(e[0],s[0]),t[1]=Math.min(e[1],s[1]),t},mul:g,multiply:o,negate:function(t,e){return t[0]=-e[0],t[1]=-e[1],t},normalize:function(t,e){const s=e[0],i=e[1];let r=s*s+i*i;return r>0&&(r=1/Math.sqrt(r),t[0]=e[0]*r,t[1]=e[1]*r),t},projectAndScale:function(t,e,s,i,r){let n=e[0]-s[0],o=e[1]-s[1];const a=(i[0]*n+i[1]*o)*(r-1);return n=i[0]*a,o=i[1]*a,t[0]=e[0]+n,t[1]=e[1]+o,t},random:function(t,e){e=e||1;const s=2*(0,i.QR)()*Math.PI;return t[0]=Math.cos(s)*e,t[1]=Math.sin(s)*e,t},rotate:_,round:function(t,e){return t[0]=Math.round(e[0]),t[1]=Math.round(e[1]),t},scale:function(t,e,s){return t[0]=e[0]*s,t[1]=e[1]*s,t},scaleAndAdd:function(t,e,s,i){return t[0]=e[0]+s[0]*i,t[1]=e[1]+s[1]*i,t},set:r,sqrDist:b,sqrLen:w,squaredDistance:c,squaredLength:u,str:function(t){return"vec2("+t[0]+", "+t[1]+")"},sub:m,subtract:n,transformMat2:function(t,e,s){const i=e[0],r=e[1];return t[0]=s[0]*i+s[2]*r,t[1]=s[1]*i+s[3]*r,t},transformMat2d:p,transformMat3:function(t,e,s){const i=e[0],r=e[1];return t[0]=s[0]*i+s[3]*r+s[6],t[1]=s[1]*i+s[4]*r+s[7],t},transformMat4:function(t,e,s){const i=e[0],r=e[1];return t[0]=s[0]*i+s[4]*r+s[12],t[1]=s[1]*i+s[5]*r+s[13],t}},Symbol.toStringTag,{value:"Module"}))},60936:(t,e,s)=>{s.d(e,{A:()=>l});var i=s(41948),r=s(43780),n=s(38912),o=s(57896),a=s(66168),h=s(1580),c=s(12552);let l=class extends r.c{constructor(){super(...arguments),this.updating=!1,this._handleId=0,this._scheduleHandleId=0,this._pendingPromises=new Set}destroy(){this.removeAll()}add(t,e,s={}){return this._installWatch(t,e,s,o.aE)}addWhen(t,e,s={}){return this._installWatch(t,e,s,o._I)}addOnCollectionChange(t,e,{initial:s=!1,final:i=!1}={}){const r=++this._handleId;return this.addHandles([(0,o.on)(t,"after-changes",this._createSyncUpdatingCallback(),o.du),(0,o.on)(t,"change",e,{onListenerAdd:s?t=>e({added:t.toArray(),removed:[]}):void 0,onListenerRemove:i?t=>e({added:[],removed:t.toArray()}):void 0})],r),(0,n.uU)((()=>this.removeHandles(r)))}addPromise(t){if(null==t)return t;const e=++this._handleId;this.addHandles((0,n.uU)((()=>{this._pendingPromises.delete(t)&&(0!==this._pendingPromises.size||this.hasHandles(u)||this._set("updating",!1))})),e),this._pendingPromises.add(t),this._set("updating",!0);const s=()=>this.removeHandles(e);return t.then(s,s),t}removeAll(){this._pendingPromises.clear(),this.removeAllHandles(),this._set("updating",!1)}_installWatch(t,e,s={},i){const r=++this._handleId;s.sync||this._installSyncUpdatingWatch(t,r);const o=i(t,e,s);return this.addHandles(o,r),(0,n.uU)((()=>this.removeHandles(r)))}_installSyncUpdatingWatch(t,e){const s=this._createSyncUpdatingCallback(),i=(0,o.aE)(t,s,{sync:!0,equals:()=>!1});return this.addHandles(i,e),i}_createSyncUpdatingCallback(){return()=>{this.removeHandles(u),++this._scheduleHandleId;const t=this._scheduleHandleId;this._get("updating")||this._set("updating",!0),this.addHandles((0,a.Ow)((()=>{t===this._scheduleHandleId&&(this._set("updating",this._pendingPromises.size>0),this.removeHandles(u))})),u)}}};(0,i._)([(0,h.qq)({readOnly:!0})],l.prototype,"updating",void 0),l=(0,i._)([(0,c.c)("geoscene.core.support.UpdatingHandles")],l);const u=-42},46448:(t,e,s)=>{s.d(e,{c:()=>c});var i=s(38912),r=s(10860),n=s(54792),o=s(13056),a=s(25512),h=s(38432);class c{constructor(){this._inUseClients=new Array,this._clients=new Array,this._clientPromises=new Array,this._ongoingJobsQueue=new n.c}destroy(){this.close()}get closed(){return!this._clients?.length}open(t,e){return new Promise(((s,i)=>{let n=!0;const o=t=>{(0,r.wp)(e.signal),n&&(n=!1,t())};this._clients.length=t.length,this._clientPromises.length=t.length,this._inUseClients.length=t.length;for(let n=0;n<t.length;++n){const a=t[n];(0,r.eW)(a)?this._clientPromises[n]=a.then((t=>(this._clients[n]=new h.default(t,e,this._ongoingJobsQueue),o(s),this._clients[n])),(()=>(o(i),null))):(this._clients[n]=new h.default(a,e,this._ongoingJobsQueue),this._clientPromises[n]=Promise.resolve(this._clients[n]),o(s))}}))}broadcast(t,e,s){const i=new Array(this._clientPromises.length);for(let r=0;r<this._clientPromises.length;++r){const n=this._clientPromises[r];i[r]=n.then((i=>i?.invoke(t,e,s)))}return i}close(){let t;for(;t=this._ongoingJobsQueue.pop();)t.resolver.reject((0,r.Uh)(`Worker closing, aborting job calling '${t.methodName}'`));for(const t of this._clientPromises)t.then((t=>t?.close()));this._clients.length=0,this._clientPromises.length=0,this._inUseClients.length=0,(0,o.S)(this)}invoke(t,e,s){return this.apply(t,[e],s)}apply(t,e,s){const i=(0,r.qG)();this._ongoingJobsQueue.push({methodName:t,data:e,invokeOptions:s,resolver:i});for(let t=0;t<this._clientPromises.length;t++){const e=this._clients[t];e?e.jobAdded():this._clientPromises[t].then((t=>t?.jobAdded()))}return i.promise}createInvokeProxy(t){return(0,a.Y)(this,t)}on(t,e){return Promise.all(this._clientPromises).then((()=>(0,i.Ip)(this._clients.map((s=>s.on(t,e))))))}openPorts(){return new Promise((t=>{const e=new Array(this._clientPromises.length);let s=e.length;for(let i=0;i<this._clientPromises.length;++i)this._clientPromises[i].then((r=>{r&&(e[i]=r.openPort()),0==--s&&t(e)}))}))}get test(){return{numClients:this._clients.length}}}},13056:(t,e,s)=>{s.d(e,{S:()=>n,s:()=>r});const i=new FinalizationRegistry((t=>{t.close()}));function r(t,e){i.register(t,e,e)}function n(t){i.unregister(t)}},59612:(t,e,s)=>{s.d(e,{EN:()=>S,S8:()=>w,i2:()=>m,wt:()=>f}),s(9456);var i=s(53648),r=s(95247),n=s(7488),o=s(56156),a=s(67932),h=s(97088),c=s(85152),l=s(7684);const u=new Float64Array(2),d=new Float64Array(2),p="0123456789bcdefghjkmnpqrstuvwxyz",_=64;function f(t,e,s,i){const a=[t.xmin,t.ymin,t.xmax,t.ymax],u=n.c.fromExtent(r.c.fromBounds(a,i)),d=(0,l.yU)(u,i,o.c.WGS84,{densificationStep:e*_});if(!d)return null;const p=(0,h.Uh)(new c.c,d,!1,!1),f=p.coords.filter(((t,e)=>!(e%2))),g=p.coords.filter(((t,e)=>e%2)),y=Math.min(...f),x=Math.min(...g),b=Math.max(...f),w=Math.max(...g),v=m(y,x,s,o.c.WGS84),S=m(b,w,s,o.c.WGS84);return v&&S?{bounds:a,geohashBounds:{xLL:v[0],yLL:v[1],xTR:S[0],yTR:S[1]},level:s}:null}function m(t,e,s,r){if(r.isWebMercator){const r=(0,i.UB)(t/a.ug.radius),n=r-360*Math.floor((r+180)/360),o=[0,0];return v(o,0,(0,i.UB)(Math.PI/2-2*Math.atan(Math.exp(-e/a.ug.radius))),n,s),o}const n=(0,l.yU)({x:t,y:e},r,o.c.WGS84);if(!n)return null;const h=[0,0];return v(h,0,n.y,n.x,s),h}function g(t){return p[t]}function y(t){return(t[0]+t[1])/2}function x(t,e,s){return t[0]=e,t[1]=s,t}function b(t,e){const s=e>y(t);return function(t,e){const s=y(t),i=e,r=!e;t[0]=r*t[0]+i*s,t[1]=r*s+i*t[1]}(t,s),s}function w(t,e){let s=-90,i=90,r=-180,n=180;for(let o=0;o<e;o++){const e=Math.ceil((o+1)/2),a=Math.floor((o+1)/2),h=1-o%2,c=30-(3*e+2*a),l=30-(2*e+3*a),u=3*h+2*(1-h),d=2*h+3*(1-h),p=3*h+7*(1-h)<<l,_=(7*h+3*(1-h)<<c&t.geohashX)>>c,f=(p&t.geohashY)>>l;for(let t=u-1;t>=0;t--){const e=(r+n)/2,s=_&1<<t?1:0;r=(1-s)*r+s*e,n=(1-s)*e+s*n}for(let t=d-1;t>=0;t--){const e=(s+i)/2,r=f&1<<t?1:0;s=(1-r)*s+r*e,i=(1-r)*e+r*i}}return[r,s,n,i]}function v(t,e,s,i,r){r%2&&(r+=1);let n=0,o=0,a=-90,h=90,c=-180,l=180;for(let t=0;t<r/2;t++){for(let e=0;e<5;e++){const s=(c+l)/2,r=i>s?1:0;n|=r<<29-(e+5*t),c=(1-r)*c+r*s,l=(1-r)*s+r*l}for(let e=0;e<5;e++){const i=(a+h)/2,r=s>i?1:0;o|=r<<29-(e+5*t),a=(1-r)*a+r*i,h=(1-r)*i+r*h}}t[2*e]=n,t[2*e+1]=o}function S(t,e,s){let i="";const r=x(u,-90,90),n=x(d,-180,180);for(let o=0;o<s;o++){let s=0;o%2?(s|=b(r,t)<<4,s|=b(n,e)<<3,s|=b(r,t)<<2,s|=b(n,e)<<1,s|=b(r,t)<<0):(s|=b(n,e)<<4,s|=b(r,t)<<3,s|=b(n,e)<<2,s|=b(r,t)<<1,s|=b(n,e)<<0),i+=g(s)}return i}},57006:(t,e,s)=>{s.r(e),s.d(e,{createConnection:()=>M});var i=s(41948),r=(s(60708),s(2600)),n=s(20744),o=s(66360),a=s(10860),h=s(28176),c=(s(9456),s(72052),s(12552)),l=s(1580),u=s(37924),d=s(77860);let p=class extends d.c.EventedAccessor{destroy(){this.emit("destroy")}get connectionError(){return this.errorString?new n.c("stream-connection",this.errorString):null}onFeature(t){this.emit("data-received",t)}onMessage(t){this.emit("message-received",t)}};(0,i._)([(0,l.qq)({readOnly:!0})],p.prototype,"connectionError",null),p=(0,i._)([(0,c.c)("geoscene.layers.support.StreamConnection")],p);const _=p;var f,m;(m=f||(f={}))[m.CONNECTING=0]="CONNECTING",m[m.OPEN=1]="OPEN",m[m.CLOSING=2]="CLOSING",m[m.CLOSED=3]="CLOSED";let g=class extends _{constructor(t){super({}),this._outstandingMessages=[],this.errorString=null;const{geometryType:e,spatialReference:s,sourceSpatialReference:i}=t;this._config=t,this._featureZScaler=(0,u.O)(e,i,s),this._open()}normalizeCtorArgs(){return{}}async _open(){await this._tryCreateWebSocket(),this.destroyed||await this._handshake()}destroy(){super.destroy(),null!=this._websocket&&(this._websocket.onopen=null,this._websocket.onclose=null,this._websocket.onerror=null,this._websocket.onmessage=null,this._websocket.close()),this._websocket=null}get connectionStatus(){if(null==this._websocket)return"disconnected";switch(this._websocket.readyState){case f.CONNECTING:case f.OPEN:return"connected";case f.CLOSING:case f.CLOSED:return"disconnected"}}sendMessageToSocket(t){null!=this._websocket?this._websocket.send(JSON.stringify(t)):this._outstandingMessages.push(t)}sendMessageToClient(t){this._onMessage(t)}updateCustomParameters(t){this._config.customParameters=t,null!=this._websocket&&this._websocket.close()}async _tryCreateWebSocket(t=this._config.source.path,e=1e3,s=0){try{if(this.destroyed)return;const e=(0,h.UP)(t,this._config.customParameters??{});this._websocket=await this._createWebSocket(e),this.notifyChange("connectionStatus")}catch(i){const r=e/1e3;return this._config.maxReconnectionAttempts&&s>=this._config.maxReconnectionAttempts?(o.c.getLogger(this).error(new n.c("websocket-connection","Exceeded maxReconnectionAttempts attempts. No further attempts will be made")),void this.destroy()):(o.c.getLogger(this).error(new n.c("websocket-connection",`Failed to connect. Attempting to reconnect in ${r}s`,i)),await(0,a.iV)(e),this._tryCreateWebSocket(t,Math.min(1.5*e,1e3*this._config.maxReconnectionInterval),s+1))}}_setWebSocketJSONParseHandler(t){t.onmessage=t=>{try{const e=JSON.parse(t.data);this._onMessage(e)}catch(t){return void o.c.getLogger(this).error(new n.c("websocket-connection","Failed to parse message, invalid JSON",{error:t}))}}}_createWebSocket(t){return new Promise(((e,s)=>{const i=new WebSocket(t);i.onopen=()=>{if(i.onopen=null,this.destroyed)return i.onclose=null,void i.close();i.onclose=t=>this._onClose(t),i.onerror=t=>this._onError(t),this._setWebSocketJSONParseHandler(i),e(i)},i.onclose=t=>{i.onopen=i.onclose=null,s(t)}}))}async _handshake(t=1e4){const e=this._websocket;if(null==e)return;const s=(0,a.qG)(),i=e.onmessage,{filter:r,outFields:h,spatialReference:c}=this._config;return s.timeout(t),e.onmessage=t=>{let a=null;try{a=JSON.parse(t.data)}catch(t){}a&&"object"==typeof a||(o.c.getLogger(this).error(new n.c("websocket-connection","Protocol violation. Handshake failed - malformed message",t.data)),s.reject(),this.destroy()),a.spatialReference?.wkid!==c?.wkid&&(o.c.getLogger(this).error(new n.c("websocket-connection",`Protocol violation. Handshake failed - expected wkid of ${c.wkid}`,t.data)),s.reject(),this.destroy()),"json"!==a.format&&(o.c.getLogger(this).error(new n.c("websocket-connection","Protocol violation. Handshake failed - format is not set",t.data)),s.reject(),this.destroy()),r&&a.filter!==r&&o.c.getLogger(this).error(new n.c("websocket-connection","Tried to set filter, but server doesn't support it")),h&&a.outFields!==h&&o.c.getLogger(this).error(new n.c("websocket-connection","Tried to set outFields, but server doesn't support it")),e.onmessage=i;for(const t of this._outstandingMessages)e.send(JSON.stringify(t));this._outstandingMessages=[],s.resolve()},e.send(JSON.stringify({filter:r,outFields:h,format:"json",spatialReference:{wkid:c.wkid}})),s.promise}_onMessage(t){if(this.onMessage(t),"type"in t)switch(t.type){case"features":case"featureResult":for(const e of t.features)null!=this._featureZScaler&&this._featureZScaler(e.geometry),this.onFeature(e)}}_onError(t){const e="Encountered an error over WebSocket connection";this._set("errorString",e),o.c.getLogger(this).error("websocket-connection",e)}_onClose(t){this._websocket=null,this.notifyChange("connectionStatus"),1e3!==t.code&&o.c.getLogger(this).error("websocket-connection",`WebSocket closed unexpectedly with error code ${t.code}`),this.destroyed||this._open()}};(0,i._)([(0,l.qq)()],g.prototype,"connectionStatus",null),(0,i._)([(0,l.qq)()],g.prototype,"errorString",void 0),g=(0,i._)([(0,c.c)("geoscene.layers.graphics.sources.connections.WebSocketConnection")],g);var y=s(32848),x=s(95776),b=s(6704),w=s(56156);const v={maxQueryDepth:5,maxRecordCountFactor:3};let S=class extends g{constructor(t){super({...v,...t}),this._buddyServicesQuery=null,this._relatedFeatures=null}async _open(){const t=await this._fetchServiceDefinition(this._config.source);t.timeInfo.trackIdField||o.c.getLogger(this).warn("GeoEvent service was configured without a TrackIdField. This may result in certain functionality being disabled. The purgeOptions.maxObservations property will have no effect.");const e=this._fetchWebSocketUrl(t.streamUrls,this._config.spatialReference);this._buddyServicesQuery||(this._buddyServicesQuery=this._queryBuddyServices()),await this._buddyServicesQuery,await this._tryCreateWebSocket(e);const{filter:s,outFields:i}=this._config;this.destroyed||this._setFilter(s,i)}_onMessage(t){if("attributes"in t){let e;try{e=this._enrich(t),null!=this._featureZScaler&&this._featureZScaler(e.geometry)}catch(t){return void o.c.getLogger(this).error(new n.c("geoevent-connection","Failed to parse message",t))}this.onFeature(e)}else this.onMessage(t)}async _fetchServiceDefinition(t){const e={f:"json",...this._config.customParameters},s=(0,r.c)(t.path,{query:e,responseType:"json"}),i=(await s).data;return this._serviceDefinition=i,i}_fetchWebSocketUrl(t,e){const s=t[0],{urls:i,token:r}=s,n=this._inferWebSocketBaseUrl(i);return(0,h.UP)(`${n}/subscribe`,{outSR:""+e.wkid,token:r})}_inferWebSocketBaseUrl(t){if(1===t.length)return t[0];for(const e of t)if(e.includes("wss"))return e;return o.c.getLogger(this).error(new n.c("geoevent-connection","Unable to infer WebSocket url",t)),null}async _setFilter(t,e){const s=this._websocket;if(null==s||null==t&&null==e)return;const i=JSON.stringify({filter:this._serializeFilter(t,e)});let r=!1;const h=(0,a.qG)();return s.onmessage=t=>{const e=JSON.parse(t.data);e.filter&&(e.error&&(o.c.getLogger(this).error(new n.c("geoevent-connection","Failed to set service filter",e.error)),this._set("errorString",`Could not set service filter - ${e.error}`),h.reject(e.error)),this._setWebSocketJSONParseHandler(s),r=!0,h.resolve())},s.send(i),setTimeout((()=>{r||(this.destroyed||this._websocket!==s||o.c.getLogger(this).error(new n.c("geoevent-connection","Server timed out when setting filter")),h.reject())}),1e4),h.promise}_serializeFilter(t,e){const s={};if(null==t&&null==e)return s;if(t?.geometry)try{const e=(0,b.h4)(t.geometry);if("extent"!==e.type)throw new n.c(`Expected extent but found type ${e.type}`);s.geometry=JSON.stringify(e.shiftCentralMeridian())}catch(t){o.c.getLogger(this).error(new n.c("geoevent-connection","Encountered an error when setting connection geometryDefinition",t))}return t?.where&&"1 = 1"!==t.where&&"1=1"!==t.where&&(s.where=t.where),null!=e&&(s.outFields=e.join(",")),s}_enrich(t){if(!this._relatedFeatures)return t;const e=this._serviceDefinition.relatedFeatures.joinField,s=t.attributes[e],i=this._relatedFeatures.get(s);if(!i)return o.c.getLogger(this).warn("geoevent-connection","Feature join failed. Is the join field configured correctly?",t),t;const{attributes:r,geometry:a}=i;for(const e in r)t.attributes[e]=r[e];return a&&(t.geometry=a),t.geometry||t.centroid||o.c.getLogger(this).error(new n.c("geoevent-connection","Found malformed feature - no geometry found",t)),t}async _queryBuddyServices(){try{const{relatedFeatures:t,keepLatestArchive:e}=this._serviceDefinition,s=this._queryRelatedFeatures(t),i=this._queryArchive(e);await s;const r=await i;if(!r)return;for(const t of r.features)this.onFeature(this._enrich(t))}catch(t){o.c.getLogger(this).error(new n.c("geoevent-connection","Encountered an error when querying buddy services",{error:t}))}}async _queryRelatedFeatures(t){if(!t)return;const e=await this._queryBuddy(t.featuresUrl);this._addRelatedFeatures(e)}async _queryArchive(t){if(t)return this._queryBuddy(t.featuresUrl)}async _queryBuddy(t){const e=new((await Promise.all([s.e(5612),s.e(5156),s.e(2692),s.e(7988),s.e(9364),s.e(236),s.e(8976),s.e(9512),s.e(2664),s.e(6556),s.e(672),s.e(1004)]).then(s.bind(s,672))).default)({url:t}),{capabilities:i}=await e.load(),r=i.query.supportsMaxRecordCountFactor,n=i.query.supportsPagination,o=i.query.supportsCentroid,a=this._config.maxRecordCountFactor,h=e.capabilities.query.maxRecordCount,c=r?h*a:h,l=new x.c;if(l.outFields=this._config.outFields??["*"],l.where=this._config.filter?.where??"1=1",l.returnGeometry=!0,l.returnExceededLimitFeatures=!0,l.outSpatialReference=w.c.fromJSON(this._config.spatialReference),o&&(l.returnCentroid=!0),r&&(l.maxRecordCountFactor=a),n)return l.num=c,e.destroy(),this._queryPages(t,l);const u=await(0,y.EL)(t,l,this._config.sourceSpatialReference);return e.destroy(),u.data}async _queryPages(t,e,s=[],i=0){e.start=null!=e.num?i*e.num:null;const{data:r}=await(0,y.EL)(t,e,this._config.sourceSpatialReference);return r.exceededTransferLimit&&i<(this._config.maxQueryDepth??0)?(r.features.forEach((t=>s.push(t))),this._queryPages(t,e,s,i+1)):(s.forEach((t=>r.features.push(t))),r)}_addRelatedFeatures(t){const e=new Map,s=t.features,i=this._serviceDefinition.relatedFeatures.joinField;for(const t of s){const s=t.attributes[i];e.set(s,t)}this._relatedFeatures=e}};S=(0,i._)([(0,c.c)("geoscene.layers.graphics.sources.connections.GeoEventConnection")],S);const I=S;let T=class extends _{constructor(t){super({}),this.connectionStatus="connected",this.errorString=null;const{geometryType:e,spatialReference:s,sourceSpatialReference:i}=t;this._featureZScaler=(0,u.O)(e,i,s)}normalizeCtorArgs(){return{}}updateCustomParameters(t){}sendMessageToSocket(t){}sendMessageToClient(t){if("type"in t)switch(t.type){case"features":case"featureResult":for(const e of t.features)null!=this._featureZScaler&&this._featureZScaler(e.geometry),this.onFeature(e)}this.onMessage(t)}};function P(t,e){if(null==t&&null==e)return null;const s={};return null!=e&&(s.geometry=e),null!=t&&(s.where=t),s}function M(t,e,s,i,r,n,o,a,h){const c={source:t,sourceSpatialReference:e,spatialReference:s,geometryType:i,filter:P(r,n),maxReconnectionAttempts:o,maxReconnectionInterval:a,customParameters:h};return t?t.path.startsWith("wss://")||t.path.startsWith("ws://")?new g(c):new I(c):new T(c)}(0,i._)([(0,l.qq)()],T.prototype,"connectionStatus",void 0),(0,i._)([(0,l.qq)()],T.prototype,"errorString",void 0),T=(0,i._)([(0,c.c)("geoscene.layers.support.ClientSideConnection")],T)},22108:(t,e,s)=>{s.d(e,{c:()=>l});var i,r=s(41948),n=s(40504),o=s(1580),a=s(53368),h=(s(72052),s(9456),s(12552));let c=i=class extends n.am{constructor(t){super(t),this.cols=null,this.level=0,this.levelValue=null,this.origin=null,this.resolution=0,this.rows=null,this.scale=0}clone(){return new i({cols:this.cols,level:this.level,levelValue:this.levelValue,resolution:this.resolution,rows:this.rows,scale:this.scale})}};(0,r._)([(0,o.qq)({json:{write:!0,origins:{"web-document":{read:!1,write:!1},"portal-item":{read:!1,write:!1}}}})],c.prototype,"cols",void 0),(0,r._)([(0,o.qq)({type:a.Ab,json:{write:!0}})],c.prototype,"level",void 0),(0,r._)([(0,o.qq)({type:String,json:{write:!0}})],c.prototype,"levelValue",void 0),(0,r._)([(0,o.qq)({json:{write:!0,origins:{"web-document":{read:!1,write:!1},"portal-item":{read:!1,write:!1}}}})],c.prototype,"origin",void 0),(0,r._)([(0,o.qq)({type:Number,json:{write:!0}})],c.prototype,"resolution",void 0),(0,r._)([(0,o.qq)({json:{write:!0,origins:{"web-document":{read:!1,write:!1},"portal-item":{read:!1,write:!1}}}})],c.prototype,"rows",void 0),(0,r._)([(0,o.qq)({type:Number,json:{write:!0}})],c.prototype,"scale",void 0),c=i=(0,r._)([(0,h.c)("geoscene.layers.support.LOD")],c);const l=c},87576:(t,e,s)=>{s.d(e,{c:()=>I});var i,r=s(41948),n=s(14628),o=s(40504),a=s(24296),h=s(1580),c=s(53368),l=(s(72052),s(9456),s(33600)),u=s(12552),d=s(18996),p=s(67776),_=s(56156),f=s(83372),m=s(60544),g=s(29120),y=s(22108),x=s(11712);const b=new n.O({PNG:"png",PNG8:"png8",PNG24:"png24",PNG32:"png32",JPEG:"jpg",JPG:"jpg",DIB:"dib",TIFF:"tiff",EMF:"emf",PS:"ps",PDF:"pdf",GIF:"gif",SVG:"svg",SVGZ:"svgz",Mixed:"mixed",MIXED:"mixed",LERC:"lerc",LERC2D:"lerc2d",RAW:"raw",pbf:"pbf"});let w=i=class extends o.am{static create(t={}){const{resolutionFactor:e=1,scales:s,size:r=256,spatialReference:n=_.c.WebMercator,numLODs:o=24}=t;if(!(0,m.U3)(n)){const t=[];if(s)for(let e=0;e<s.length;e++){const i=s[e];t.push(new y.c({level:e,scale:i,resolution:i}))}else{let e=5e-4;for(let s=o-1;s>=0;s--)t.unshift(new y.c({level:s,scale:e,resolution:e})),e*=2}return new i({dpi:96,lods:t,origin:new p.c(0,0,n),size:[r,r],spatialReference:n})}const h=(0,m.Nq)(n),c=t.origin?new p.c({x:t.origin.x,y:t.origin.y,spatialReference:n}):new p.c(h?{x:h.origin[0],y:h.origin[1],spatialReference:n}:{x:0,y:0,spatialReference:n}),l=1/(39.37*(0,a.k8)(n)*96),u=[];if(s)for(let t=0;t<s.length;t++){const e=s[t],i=e*l;u.push(new y.c({level:t,scale:e,resolution:i}))}else{let t=(0,m.Eb)(n)?512/r*591657527.5917094:256/r*591657527.591555;const s=Math.ceil(o/e);u.push(new y.c({level:0,scale:t,resolution:t*l}));for(let i=1;i<s;i++){const s=t/2**e,r=s*l;u.push(new y.c({level:i,scale:s,resolution:r})),t=s}}return new i({dpi:96,lods:u,origin:c,size:[r,r],spatialReference:n})}constructor(t){super(t),this.dpi=96,this.format=null,this.origin=null,this.size=null,this.spatialReference=null}get isWrappable(){const{spatialReference:t,origin:e}=this;if(t&&e){const s=(0,m.Nq)(t);return t.isWrappable&&!!s&&Math.abs(s.origin[0]-e.x)<=s.dx}return!1}readOrigin(t,e){return p.c.fromJSON({spatialReference:e.spatialReference,...t})}set lods(t){let e=0,s=0;const i=[],r=this._levelToLOD={};t&&(e=-1/0,s=1/0,t.forEach((t=>{i.push(t.scale),e=t.scale>e?t.scale:e,s=t.scale<s?t.scale:s,r[t.level]=t}))),this._set("scales",i),this._set("lods",t),this._initializeUpsampleLevels()}readSize(t,e){return[e.cols,e.rows]}writeSize(t,e){e.cols=t[0],e.rows=t[1]}zoomToScale(t){const e=this.scales;if(t<=0)return e[0];if(t>=e.length-1)return e[e.length-1];const s=Math.floor(t),i=s+1;return e[s]/(e[s]/e[i])**(t-s)}scaleToZoom(t){const e=this.scales,s=e.length-1;let i=0;for(;i<s;i++){const s=e[i],r=e[i+1];if(s<=t)return i;if(r===t)return i+1;if(s>t&&r<t)return i+Math.log(s/t)/Math.log(s/r)}return i}snapScale(t,e=.95){const s=this.scaleToZoom(t);return s%Math.floor(s)>=e?this.zoomToScale(Math.ceil(s)):this.zoomToScale(Math.floor(s))}tileAt(t,e,s,i){const r=this.lodAt(t);if(!r)return null;let n,o;if("number"==typeof e)n=e,o=s;else if((0,m.yK)(e.spatialReference,this.spatialReference))n=e.x,o=e.y,i=s;else{const t=(0,g.yU)(e,this.spatialReference);if(null==t)return null;n=t.x,o=t.y,i=s}const a=r.resolution*this.size[0],h=r.resolution*this.size[1];return i||(i=new x.g(null,0,0,0,(0,f.Su)())),i.level=t,i.row=Math.floor((this.origin.y-o)/h+.001),i.col=Math.floor((n-this.origin.x)/a+.001),this.updateTileInfo(i),i}updateTileInfo(t,e=i.ExtrapolateOptions.NONE){let s=this.lodAt(t.level);if(!s&&e===i.ExtrapolateOptions.POWER_OF_TWO){const e=this.lods[this.lods.length-1];e.level<t.level&&(s=e)}if(!s)return;const r=t.level-s.level,n=s.resolution*this.size[0]/2**r,o=s.resolution*this.size[1]/2**r;t.id=`${t.level}/${t.row}/${t.col}`,t.extent||(t.extent=(0,f.Su)()),t.extent[0]=this.origin.x+t.col*n,t.extent[1]=this.origin.y-(t.row+1)*o,t.extent[2]=t.extent[0]+n,t.extent[3]=t.extent[1]+o}upsampleTile(t){const e=this._upsampleLevels[t.level];return!(!e||-1===e.parentLevel||(t.level=e.parentLevel,t.row=Math.floor(t.row/e.factor+.001),t.col=Math.floor(t.col/e.factor+.001),this.updateTileInfo(t),0))}getTileBounds(t,e){const s=this.lodAt(e.level);if(null==s)return null;const{resolution:i}=s,r=i*this.size[0],n=i*this.size[1];return t[0]=this.origin.x+e.col*r,t[1]=this.origin.y-(e.row+1)*n,t[2]=t[0]+r,t[3]=t[1]+n,t}lodAt(t){return this._levelToLOD?.[t]??null}clone(){return i.fromJSON(this.write({}))}getOrCreateCompatible(t,e){if(256===this.size[0]&&256===this.size[1])return 256===t?this:null;const s=[],r=this.lods.length;for(let t=0;t<r;t++){const i=this.lods[t],r=i.resolution*e;s.push(new y.c({level:i.level,scale:i.scale,resolution:r}))}return new i({size:[t,t],dpi:this.dpi,format:this.format,compressionQuality:this.compressionQuality,origin:this.origin,spatialReference:this.spatialReference,lods:s})}_initializeUpsampleLevels(){const t=this.lods;this._upsampleLevels=[];let e=null;for(let s=0;s<t.length;s++){const i=t[s];this._upsampleLevels[i.level]={parentLevel:e?e.level:-1,factor:e?e.resolution/i.resolution:0},e=i}}};var v,S;(0,r._)([(0,h.qq)({type:Number,json:{write:!0}})],w.prototype,"compressionQuality",void 0),(0,r._)([(0,h.qq)({type:Number,json:{write:!0}})],w.prototype,"dpi",void 0),(0,r._)([(0,h.qq)({type:String,json:{read:b.read,write:b.write,origins:{"web-scene":{read:!1,write:!1}}}})],w.prototype,"format",void 0),(0,r._)([(0,h.qq)({readOnly:!0})],w.prototype,"isWrappable",null),(0,r._)([(0,h.qq)({type:p.c,json:{write:!0}})],w.prototype,"origin",void 0),(0,r._)([(0,l.E)("origin")],w.prototype,"readOrigin",null),(0,r._)([(0,h.qq)({type:[y.c],value:null,json:{write:!0}})],w.prototype,"lods",null),(0,r._)([(0,h.qq)({readOnly:!0})],w.prototype,"scales",void 0),(0,r._)([(0,h.qq)({cast:t=>Array.isArray(t)?t:"number"==typeof t?[t,t]:[256,256]})],w.prototype,"size",void 0),(0,r._)([(0,l.E)("size",["rows","cols"])],w.prototype,"readSize",null),(0,r._)([(0,d.G)("size",{cols:{type:c.Ab},rows:{type:c.Ab}})],w.prototype,"writeSize",null),(0,r._)([(0,h.qq)({type:_.c,json:{write:!0}})],w.prototype,"spatialReference",void 0),w=i=(0,r._)([(0,u.c)("geoscene.layers.support.TileInfo")],w),v=w||(w={}),(S=v.ExtrapolateOptions||(v.ExtrapolateOptions={}))[S.NONE=0]="NONE",S[S.POWER_OF_TWO=1]="POWER_OF_TWO";const I=w},11712:(t,e,s)=>{s.d(e,{g:()=>i});class i{constructor(t,e,s,i,r=void 0){this.id=t,this.level=e,this.row=s,this.col=i,this.extent=r}}},48212:(t,e,s)=>{s.d(e,{Ab:()=>x,Ej:()=>d,K0:()=>u,M9:()=>p,Wq:()=>f,YB:()=>l,_2:()=>g,oR:()=>m,q_:()=>_,wn:()=>y});var i=s(28176),r=s(91952);const n={mapserver:"MapServer",imageserver:"ImageServer",featureserver:"FeatureServer",sceneserver:"SceneServer",streamserver:"StreamServer",vectortileserver:"VectorTileServer","3dtilesserver":"3DTilesServer"},o=Object.values(n),a=new RegExp(`^((?:https?:)?\\/\\/\\S+?\\/rest\\/services\\/(.+?)\\/(${o.join("|")}))(?:\\/(?:layers\\/)?(\\d+))?`,"i"),h=new RegExp(`^((?:https?:)?\\/\\/\\S+?\\/([^\\/\\n]+)\\/(${o.join("|")}))(?:\\/(?:layers\\/)?(\\d+))?`,"i"),c=/(.*?)\/(?:layers\/)?(\d+)\/?$/i;function l(t){return!!a.test(t)}function u(t){if(null==t)return null;const e=(0,i.as)(t),s=e?.path.match(a)||e?.path.match(h);if(!s)return null;const[,r,o,c,l]=s,u=o.indexOf("/");return{title:p(-1!==u?o.slice(u+1):o),serverType:n[c.toLowerCase()],sublayer:null!=l&&""!==l?parseInt(l,10):null,url:{path:r}}}function d(t){const e=(0,i.as)(t).path.match(c);return e?{serviceUrl:e[1],sublayerId:Number(e[2])}:null}function p(t){return(t=t.replaceAll(/\s*[/_]+\s*/g," "))[0].toUpperCase()+t.slice(1)}function _(t,e){const s=[];if(t){const e=u(t);null!=e&&e.title&&s.push(e.title)}if(e){const t=p(e);s.push(t)}if(2===s.length){if(s[0].toLowerCase().includes(s[1].toLowerCase()))return s[0];if(s[1].toLowerCase().includes(s[0].toLowerCase()))return s[1]}return s.join(" - ")}function f(t){if(!t)return!1;const e=(t=t.toLowerCase()).includes(".arcgis.com/"),s=t.includes("//services")||t.includes("//tiles")||t.includes("//features");return e&&s}function m(t,e){return t?(0,i.ai)((0,i.kN)(t,e)):t}function g(t){let{url:e}=t;if(!e)return{url:e};e=(0,i.kN)(e,t.logger);const s=(0,i.as)(e),r=u(s.path);let n;if(null!=r)null!=r.sublayer&&null==t.layer.layerId&&(n=r.sublayer),e=r.url.path;else if(t.nonStandardUrlAllowed){const t=d(s.path);null!=t&&(e=t.serviceUrl,n=t.sublayerId)}return{url:(0,i.ai)(e),layerId:n}}function y(t,e,s,n,o){(0,r.w)(e,n,"url",o),n.url&&null!=t.layerId&&(n.url=(0,i.kn)(n.url,s,t.layerId.toString()))}function x(t){if(!t)return!1;const e=t.toLowerCase(),s=e.includes("/services/"),i=e.includes("/mapserver/wmsserver"),r=e.includes("/imageserver/wmsserver"),n=e.includes("/wmsserver");return s&&(i||r||n)}},21012:(t,e,s)=>{s.d(e,{M:()=>r});var i=s(37924);function r(t,e,s){if(!s?.features||!s.hasZ)return;const r=(0,i.O)(s.geometryType,e,t.outSpatialReference);if(null!=r)for(const t of s.features)r(t.geometry)}},51552:(t,e,s)=>{s.r(e),s.d(e,{default:()=>Hd});var i=s(20744),r=s(38912),n=s(9456),o=s(52324),a=s(10860),h=s(72052),c=s(57896),l=s(50144),u=s(87576),d=s(60544),p=s(53680);function _(t,e){return[t,e]}function f(t,e,s){return t[0]=e,t[1]=s,t}const m=new p.c("0/0/0/0");class g{static create(t,e,s=null){const i=(0,d.Nq)(t.spatialReference),r=e.origin||_(t.origin.x,t.origin.y),n=_(t.size[0]*e.resolution,t.size[1]*e.resolution),o=_(-1/0,-1/0),a=_(1/0,1/0),h=_(1/0,1/0);null!=s&&(f(o,Math.max(0,Math.floor((s.xmin-r[0])/n[0])),Math.max(0,Math.floor((r[1]-s.ymax)/n[1]))),f(a,Math.max(0,Math.floor((s.xmax-r[0])/n[0])),Math.max(0,Math.floor((r[1]-s.ymin)/n[1]))),f(h,a[0]-o[0]+1,a[1]-o[1]+1));const{cols:c,rows:l}=e;let u,p,m,y;return!s&&c&&l&&(f(o,c[0],l[0]),f(a,c[1],l[1]),f(h,c[1]-c[0]+1,l[1]-l[0]+1)),t.isWrappable?(u=_(Math.ceil(Math.round((i.valid[1]-i.valid[0])/e.resolution)/t.size[0]),h[1]),p=_(Math.floor((i.origin[0]-r[0])/n[0]),o[1]),m=_(u[0]+p[0]-1,a[1]),y=!0):(p=o,m=a,u=h,y=!1),new g(e.level,e.resolution,e.scale,r,o,a,h,n,p,m,u,y)}constructor(t,e,s,i,r,n,o,a,h,c,l,u){this.level=t,this.resolution=e,this.scale=s,this.origin=i,this.first=r,this.last=n,this.size=o,this.norm=a,this.worldStart=h,this.worldEnd=c,this.worldSize=l,this.wrap=u}normalizeCol(t){if(!this.wrap)return t;const e=this.worldSize[0];return t<0?e-1-Math.abs((t+1)%e):t%e}denormalizeCol(t,e){return this.wrap?this.worldSize[0]*e+t:t}getWorldForColumn(t){return this.wrap?Math.floor(t/this.worldSize[0]):0}getFirstColumnForWorld(t){return t*this.worldSize[0]+this.first[0]}getLastColumnForWorld(t){return t*this.worldSize[0]+this.first[0]+this.size[0]-1}getColumnForX(t){return(t-this.origin[0])/this.norm[0]}getXForColumn(t){return this.origin[0]+t*this.norm[0]}getRowForY(t){return(this.origin[1]-t)/this.norm[1]}getYForRow(t){return this.origin[1]-t*this.norm[1]}getTileBounds(t,e,s=!1){m.set(e);const i=s?m.col:this.denormalizeCol(m.col,m.world),r=m.row;return function(t,e,s,i,r){t[0]=e,t[1]=s,t[2]=i,t[3]=r}(t,this.getXForColumn(i),this.getYForRow(r+1),this.getXForColumn(i+1),this.getYForRow(r)),t}getTileCoords(t,e,s=!1){m.set(e);const i=s?m.col:this.denormalizeCol(m.col,m.world);return Array.isArray(t)?f(t,this.getXForColumn(i),this.getYForRow(m.row)):(t.x=this.getXForColumn(i),t.y=this.getYForRow(m.row)),t}}var y=s(69752);class x{constructor(){this.spans=[]}acquire(t){this.lodInfo=t}release(){this.lodInfo=null,this.spans.length=0}*keys(){const t=this.lodInfo;for(const{row:e,colFrom:s,colTo:i}of this.spans)for(let r=s;r<=i;r++){const s=t.getWorldForColumn(r);yield new p.c(t.level,e,t.normalizeCol(r),s)}}forEach(t,e){const{spans:s,lodInfo:i}=this,{level:r}=i;if(0!==s.length)for(const{row:n,colFrom:o,colTo:a}of s)for(let s=o;s<=a;s++)t.call(e,r,n,i.normalizeCol(s),i.getWorldForColumn(s))}}x.pool=new y.c(x);class b{constructor(t,e,s){this.row=t,this.colFrom=e,this.colTo=s}}const w=new p.c("0/0/0/0");class v{static create(t,e){t[1]>e[1]&&([t,e]=[e,t]);const[s,i]=t,[r,n]=e,o=r-s,a=n-i,h=0!==a?o/a:0,c=(Math.ceil(i)-i)*h,l=(Math.floor(i)-i)*h;return new v(s,Math.floor(i),Math.ceil(n),h,o<0?c:l,o<0?l:c,o<0?r:s,o<0?s:r)}constructor(t,e,s,i,r,n,o,a){this.x=t,this.ymin=e,this.ymax=s,this.invM=i,this.leftAdjust=r,this.rightAdjust=n,this.leftBound=o,this.rightBound=a}incrRow(){this.x+=this.invM}getLeftCol(){return Math.max(this.x+this.leftAdjust,this.leftBound)}getRightCol(){return Math.min(this.x+this.rightAdjust,this.rightBound)}}const S=[[0,0],[0,0],[0,0],[0,0]];class I{constructor(t,e=null,s=t.lods[0].level,i=t.lods[t.lods.length-1].level){this.tileInfo=t,this.fullExtent=e,this.scales=[],this._infoByScale={},this._infoByLevel={};const r=t.lods.filter((t=>t.level>=s&&t.level<=i));this.minScale=r[0].scale,this.maxScale=r[r.length-1].scale;const n=this._lodInfos=r.map((s=>g.create(t,s,e)));r.forEach(((t,e)=>{this._infoByLevel[t.level]=n[e],this._infoByScale[t.scale]=n[e],this.scales[e]=t.scale}),this),this._wrap=t.isWrappable}get spatialReference(){return this.tileInfo.spatialReference}getLODInfoAt(t){return this._infoByLevel["number"==typeof t?t:t.level]}getTileBounds(t,e,s=!1){w.set(e);const i=this._infoByLevel[w.level];return i?i.getTileBounds(t,w,s):t}getTileCoords(t,e,s=!1){w.set(e);const i=this._infoByLevel[w.level];return i?i.getTileCoords(t,w,s):t}getTileCoverage(t,e=192,s=!0,i="closest"){if(!s&&(t.scale>this.minScale||t.scale<this.maxScale))return null;const r="closest"===i?this.getClosestInfoForScale(t.scale):this.getSmallestInfoForScale(t.scale),n=x.pool.acquire(r),o=this._wrap;let a,h,c,l=1/0,u=-1/0;const d=n.spans;S[0][0]=S[0][1]=S[1][1]=S[3][0]=-e,S[1][0]=S[2][0]=t.size[0]+e,S[2][1]=S[3][1]=t.size[1]+e;for(const e of S)t.toMap(e,e),e[0]=r.getColumnForX(e[0]),e[1]=r.getRowForY(e[1]);const p=[];let _=3;for(let t=0;t<4;t++){if(S[t][1]===S[_][1]){_=t;continue}const e=v.create(S[t],S[_]);l=Math.min(e.ymin,l),u=Math.max(e.ymax,u),void 0===p[e.ymin]&&(p[e.ymin]=[]),p[e.ymin].push(e),_=t}if(null==l||null==u||u-l>100)return null;let f=[];for(a=l;a<u;){null!=p[a]&&(f=f.concat(p[a])),h=1/0,c=-1/0;for(let t=f.length-1;t>=0;t--){const e=f[t];h=Math.min(h,e.getLeftCol()),c=Math.max(c,e.getRightCol())}if(h=Math.floor(h),c=Math.floor(c),a>=r.first[1]&&a<=r.last[1])if(o)if(r.size[0]<r.worldSize[0]){const t=Math.floor(c/r.worldSize[0]);for(let e=Math.floor(h/r.worldSize[0]);e<=t;e++)d.push(new b(a,Math.max(r.getFirstColumnForWorld(e),h),Math.min(r.getLastColumnForWorld(e),c)))}else d.push(new b(a,h,c));else h>r.last[0]||c<r.first[0]||(h=Math.max(h,r.first[0]),c=Math.min(c,r.last[0]),d.push(new b(a,h,c)));a+=1;for(let t=f.length-1;t>=0;t--){const e=f[t];e.ymax>=a?e.incrRow():f.splice(t,1)}}return n}getTileParentId(t){w.set(t);const e=this._infoByLevel[w.level],s=this._lodInfos.indexOf(e)-1;return s<0?null:(this._getTileIdAtLOD(w,this._lodInfos[s],w),w.id)}getTileResolution(t){const e=this._infoByLevel["object"==typeof t?t.level:t];return e?e.resolution:-1}getTileScale(t){const e=this._infoByLevel[t.level];return e?e.scale:-1}intersects(t,e){w.set(e);const s=this._infoByLevel[w.level],i=t.lodInfo;if(i.resolution>s.resolution){this._getTileIdAtLOD(w,i,w);const e=i.denormalizeCol(w.col,w.world);for(const s of t.spans)if(s.row===w.row&&s.colFrom<=e&&s.colTo>=e)return!0}if(i.resolution<s.resolution){const[e,r,n,o]=t.spans.reduce(((t,e)=>(t[0]=Math.min(t[0],e.row),t[1]=Math.max(t[1],e.row),t[2]=Math.min(t[2],e.colFrom),t[3]=Math.max(t[3],e.colTo),t)),[1/0,-1/0,1/0,-1/0]),a=s.denormalizeCol(w.col,w.world),h=i.getColumnForX(s.getXForColumn(a)),c=i.getRowForY(s.getYForRow(w.row)),l=i.getColumnForX(s.getXForColumn(a+1))-1,u=i.getRowForY(s.getYForRow(w.row+1))-1;return!(h>o||l<n||c>r||u<e)}const r=i.denormalizeCol(w.col,w.world);return t.spans.some((t=>t.row===w.row&&t.colFrom<=r&&t.colTo>=r))}normalizeBounds(t,e,s){if(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],this._wrap){const e=(0,d.Nq)(this.tileInfo.spatialReference),i=-s*(e.valid[1]-e.valid[0]);t[0]+=i,t[2]+=i}return t}getSmallestInfoForScale(t){const e=this.scales;if(this._infoByScale[t])return this._infoByScale[t];if(t>e[0])return this._infoByScale[e[0]];for(let s=1;s<e.length-1;s++)if(t>e[s]+1e-6)return this._infoByScale[e[s-1]];return this._infoByScale[e[e.length-1]]}getClosestInfoForScale(t){const e=this.scales;return this._infoByScale[t]||(t=e.reduce(((e,s)=>Math.abs(s-t)<Math.abs(e-t)?s:e),e[0])),this._infoByScale[t]}scaleToLevel(t){const e=this.scales;if(this._infoByScale[t])return this._infoByScale[t].level;for(let s=e.length-1;s>=0;s--)if(t<e[s])return s===e.length-1?this._infoByScale[e[e.length-1]].level:this._infoByScale[e[s]].level+(e[s]-t)/(e[s]-e[s+1]);return this._infoByScale[e[0]].level}scaleToZoom(t){return this.tileInfo.scaleToZoom(t)}_getTileIdAtLOD(t,e,s){const i=this._infoByLevel[s.level];return t.set(s),e.resolution<i.resolution?null:(e.resolution===i.resolution||(t.level=e.level,t.col=Math.floor(s.col*i.resolution/e.resolution+.01),t.row=Math.floor(s.row*i.resolution/e.resolution+.01)),t)}}var T=s(41948),P=s(43780),M=s(70680),E=s(1580),C=s(66360),k=s(12552),F=s(37648),A=s(27064);const R=new Set,O=[],N=new Map,D=[0,0];let z=class extends P.c{constructor(t){super(t),this._keyToItem=new Map,this.concurrency=6,this.strategy="scale-first",this.tileInfoView=null}initialize(){const{concurrency:t,process:e,strategy:s}=this;this._queue=new A.K({concurrency:t,process:(t,s)=>{const i=this._keyToItem.get(t);return e(i,{signal:s})},peeker:"scale-first"===s?t=>this._peekByScaleFirst(t):t=>this._peekByCenterFirst(t)})}destroy(){this.clear(),this._queue=(0,M.mG)(this._queue)}get length(){return this._queue?this._queue.length:0}get onGoingCount(){return this._keyToItem.size}abort(t){const e="string"==typeof t?t:t.id;this._queue.abort(e)}clear(){this._queue.clear(),this._keyToItem.clear()}has(t){return"string"==typeof t?this._keyToItem.has(t):this._keyToItem.has(t.id)}isOngoing(t){const e="string"==typeof t?t:t.id;return this.has(e)&&this._queue.isOngoing(e)}pause(){this._queue.pause()}push(t){const e=t.key.id;if(this._queue.has(e))return this._queue.get(e);const s=this._queue.push(e),i=()=>{this._keyToItem.delete(e)};return this._keyToItem.set(e,t),s.then(i,i),s}reset(){this._queue.reset()}resume(){this._queue.resume()}_peekByScaleFirst(t){if(!this.state)return t.values().next().value;const e=this.tileInfoView;let s=Number.NEGATIVE_INFINITY,i=Number.POSITIVE_INFINITY;t.forEach((t=>{const e=this._keyToItem.get(t),r=this.tileInfoView.getTileScale(e.key);N.has(r)||(N.set(r,[]),s=Math.max(r,s),i=Math.min(r,i)),N.get(r).push(e.key),R.add(r)}));let r=this.state.scale;N.has(r)||(function(t,e){t.length=0,e.forEach((e=>t.push(e)))}(O,R),O.sort(((t,e)=>t-e)),r=O.reduce(((t,e)=>Math.abs(e-r)<Math.abs(t-r)?e:t),O[0])),r=Math.min(r,s),r=Math.max(r,i);const n=N.get(r),o=e.getClosestInfoForScale(r),a=o.getColumnForX(this.state.center[0]),h=o.getRowForY(this.state.center[1]);return n.sort(((t,e)=>{const s=o.denormalizeCol(t.col,t.world),i=o.denormalizeCol(e.col,e.world);return Math.sqrt((a-s)*(a-s)+(h-t.row)*(h-t.row))-Math.sqrt((a-i)*(a-i)+(h-e.row)*(h-e.row))})),R.clear(),N.clear(),n[0].id}_peekByCenterFirst(t){if(!this.state)return t.values().next().value;const e=this.tileInfoView,s=this.state.center;let i,r=Number.POSITIVE_INFINITY;return t.forEach((t=>{const n=this._keyToItem.get(t);e.getTileCoords(D,n.key);const o=(0,F.qy)(D,s);o<r&&(r=o,i=n.key)})),i.id}};(0,T._)([(0,E.qq)({constructOnly:!0})],z.prototype,"concurrency",void 0),(0,T._)([(0,E.qq)({constructOnly:!0})],z.prototype,"process",void 0),(0,T._)([(0,E.qq)()],z.prototype,"state",void 0),(0,T._)([(0,E.qq)({constructOnly:!0})],z.prototype,"strategy",void 0),(0,T._)([(0,E.qq)({constructOnly:!0})],z.prototype,"tileInfoView",void 0),z=(0,T._)([(0,k.c)("geoscene.views.2d.tiling.TileQueue")],z);var L=s(83372);new p.c(0,0,0,0),new Map;var B=s(67720);class U{constructor(t){this._client=t,this.layerView=this._client.createInvokeProxy(),this.container=this._client.createInvokeProxy("container"),this.eventLog=this._client.createInvokeProxy("eventLog")}}var G=s(96523),V=s(56156);class q{constructor(t,e,s,i,r,n,o){this.instanceId=t,this.textureKey=e,this.indexStart=s,this.indexCount=i,this.vertexStart=r,this.vertexCount=n,this.overlaps=o}updateBaseOffsets(t){this.vertexStart+=t.vertexFrom,this.indexStart+=t.indexFrom}clone(){return new q(this.instanceId,this.textureKey,this.indexStart,this.indexCount,this.vertexStart,this.vertexCount,this.overlaps)}static write(t,e,s,i,r,n,o,a){t.push(e),t.push(s),t.push(i),t.push(r),t.push(n),t.push(o),t.push(a)}serialize(t){return t.push(this.instanceId),t.push(this.textureKey),t.push(this.indexStart),t.push(this.indexCount),t.push(this.vertexStart),t.push(this.vertexCount),t.push(this.overlaps),t}static deserialize(t){const e=t.readInt32(),s=t.readInt32(),i=t.readInt32(),r=t.readInt32(),n=t.readInt32(),o=t.readInt32(),a=t.readInt32();return new q(e,s,i,r,n,o,a)}}function W(t,e){if(null!==e){t.push(e.length);for(const s of e)s.serialize(t);return t}t.push(0)}function X(t,e,s){const i=t.readInt32(),r=new Array(i);for(let i=0;i<r.length;i++)r[i]=e.deserialize(t,s);return r}q.byteSizeHint=7*Uint32Array.BYTES_PER_ELEMENT;class Y{constructor(t,e){this.id=t,this.sortKey=e,this.records=[]}serialize(t){return t.push(this.id),t.writeF32(this.sortKey),W(t,this.records),t}static deserialize(t){const e=t.readInt32(),s=t.readF32(),i=new Y(e,s);return i.records=X(t,q)??[],i}}Y.byteSizeHint=2*Uint32Array.BYTES_PER_ELEMENT+q.byteSizeHint;class j{get length(){return this._pos}constructor(t,e){this._pos=0;const s=e?this._roundToNearest(e,t.BYTES_PER_ELEMENT):40;this._array=new ArrayBuffer(s),this._buffer=new t(this._array),this._ctor=t,this._i16View=new Int16Array(this._array)}_roundToNearest(t,e){const s=Math.round(t);return 1===e?s:s+(e-s%e)}_ensureSize(t){if(this._pos+t>=this._buffer.length){const e=this._roundToNearest(1.25*(this._array.byteLength+t*this._buffer.BYTES_PER_ELEMENT),this._buffer.BYTES_PER_ELEMENT),s=new ArrayBuffer(e),i=new this._ctor(s);i.set(this._buffer,0),this._array=s,this._buffer=i,this._i16View=new Int16Array(this._array)}}ensureSize(t){this._ensureSize(t)}writeF32(t){this._ensureSize(1);const e=this._pos;return new Float32Array(this._array,4*this._pos,1)[0]=t,this._pos++,e}push(t){this._ensureSize(1);const e=this._pos;return this._buffer[this._pos++]=t,e}writeFixed(t){this._buffer[this._pos++]=t}setValue(t,e){this._buffer[t]=e}i1616Add(t,e,s){this._i16View[2*t]+=e,this._i16View[2*t+1]+=s}getValue(t){return this._buffer[t]}getValueF32(t){return new Float32Array(this._array,4*t,1)[0]}incr(t){if(this._buffer.length<t)throw new Error("Increment index overflows the target buffer");this._buffer[t]++}decr(t){this._buffer[t]--}writeRegion(t){this._ensureSize(t.length);const e=this._pos;return this._buffer.set(t,this._pos),this._pos+=t.length,e}writeManyFrom(t,e,s){this._ensureSize(s-e);for(let i=e;i!==s;i++)this.writeFixed(t._buffer[i])}buffer(){const t=this._array.slice(0,4*this._pos);return this.destroy(),t}toArray(){return[...this._buffer]}seek(t){this._pos=t}destroy(){this._array=null,this._buffer=null}}class H{constructor(t,e,s,i=0){const r=6*i*Uint32Array.BYTES_PER_ELEMENT,n=4*i*s,o=s/4,a=e.attributes.find((t=>"pos"===t.name||"position"===t.name));if(!a)throw new Error("InternalError: Unable to find position attribute");this.layout={...e,position:a},this._indices=new j(Uint32Array,r),this._vertices=new j(Uint32Array,n),this._metrics=new j(Uint32Array,0),this._metricCountOffset=this._metrics.push(0),this._strideInt=o,this._instanceId=t}serialize(t){const e=this._indices.buffer(),s=this._vertices.buffer(),i=this._metrics.length?this._metrics.buffer():null;return t.push(e,s),{instanceId:this._instanceId,layout:this.layout,indices:e,vertices:s,metrics:i}}get strideInt(){return this._strideInt}get vertexCount(){return this._vertices.length/this._strideInt}get indexCount(){return this._indices.length}get indexWriter(){return this._indices}get vertexWriter(){return this._vertices}get metricWriter(){return this._metrics}vertexEnsureSize(t){this._vertices.ensureSize(t)}indexEnsureSize(t){this._indices.ensureSize(t)}writeIndex(t){this._indices.push(t)}writeVertex(t){this._vertices.push(t)}writeVertexRegion(t){this._vertices.writeRegion(t)}writeVertexF32(t){this._vertices.writeF32(t)}writeMetric(t){this._metrics.incr(this._metricCountOffset),t.serialize(this._metrics)}}class ${constructor(t,e=0){this._id=t,this._sizeHint=e,this._entityRecordCountOffset=0,this._entityCountOffset=0,this._entityIdIndex=0,this._entitySortKeyIndex=0,this._instanceIdToVertexData=new Map,this._current={metric:null,writer:null,start:0,sortKey:0,instanceId:0,layoutHash:0,indexStart:0,vertexStart:0,textureKey:0,metricBoxLenPointer:0},this._entities=new j(Uint32Array,this._sizeHint*Y.byteSizeHint),this._entityCountOffset=this._entities.push(0)}get id(){return this._id}serialize(){const t=new Array,e=[],s=this._entities.buffer();for(const s of this._instanceIdToVertexData.values())e.push(s.serialize(t));return{message:{data:e,entities:s},transferList:t}}vertexCount(){return this._current.writer?.vertexCount??0}indexCount(){return this._current.writer?.indexCount??0}vertexEnsureSize(t){this._current.writer.vertexEnsureSize(t)}indexEnsureSize(t){this._current.writer.indexEnsureSize(t)}vertexWrite(t){this._current.writer.writeVertex(t)}vertexWriteRegion(t){this._current.writer.writeVertexRegion(t)}vertexWriteF32(t){this._current.writer.writeVertexF32(t)}recordBounds(t,e,s,i){}indexWrite(t){this._current.writer.writeIndex(t)}metricStart(t){this._current.metric=t}metricEnd(){const t=this._current.writer;this._current.metric.bounds.length&&t.writeMetric(this._current.metric)}metricBoxWrite(t){this._current.metric.bounds.push(t)}entityStart(t,e=t){this._entityIdIndex=this._entities.push(t),this._entitySortKeyIndex=this._entities.writeF32(e),this._entityRecordCountOffset=this._entities.push(0)}entityRecordCount(){return this._entities.getValue(this._entityRecordCountOffset)}entityEnd(){0===this.entityRecordCount()?this._entities.seek(this._entityIdIndex):this._entities.incr(this._entityCountOffset)}recordCount(){return this._entities.getValue(this._entityRecordCountOffset)}recordStart(t,e,s=0){this._current.writer=this._getVertexWriter(t,e),this._current.indexStart=this._current.writer.indexCount,this._current.vertexStart=this._current.writer.vertexCount,this._current.instanceId=t,this._current.layoutHash=e.hash,this._current.textureKey=s}recordEnd(t=0){const e=this._current.vertexStart,s=this._current.writer.vertexCount-e;if(!s)return!1;const i=this._current.indexStart,r=this._current.writer.indexCount-i;return this._entities.incr(this._entityRecordCountOffset),q.write(this._entities,this._current.instanceId,this._current.textureKey,i,r,e,s,t),!0}copyLastFrom(t,e,s){const i=t._entities.getValue(t._entityIdIndex);if(i!==this._entities.getValue(this._entityIdIndex)){const e=t._entities.getValueF32(t._entitySortKeyIndex);this.entityStart(i,e)}this.recordStart(t._current.instanceId,t._current.writer.layout,t._current.textureKey);const r=this._current.writer.layout.stride/Uint32Array.BYTES_PER_ELEMENT,n=this._current.vertexStart,o=t._current.vertexStart-n,a=this._current.writer.indexWriter,h=this._current.writer.vertexWriter,c=t._current.writer.indexWriter,l=t._current.writer.vertexWriter;for(let e=t._current.indexStart;e!==c.length;e++){const t=c.getValue(e);a.push(t-o)}for(let e=t._current.vertexStart*r;e!==l.length;e++){const t=l.getValue(e);h.push(t)}const u=this._current.writer.layout.position,d=u.packPrecisionFactor??1,p=u.offset/Uint32Array.BYTES_PER_ELEMENT,_=e*d,f=s*d;for(let t=n*r;t<=h.length;t+=r)h.i1616Add(t+p,_,f);this.recordEnd()}_getVertexWriter(t,e){const{stride:s}=e,i=this._instanceIdToVertexData;return i.has(t)||i.set(t,new H(t,e,s,this._sizeHint)),i.get(t)}}function K(t){switch(t){case 1:case 8:case 32:return-1;case 2:case 64:return 0;case 4:case 16:case 128:return 1}}function Z(t){switch(t){case 1:case 2:case 4:return-1;case 8:case 16:return 0;case 32:case 64:case 128:return 1}}class Q{constructor(t,e,s=0){this.tileKey=t,this._bufferingEnabled=e,this._sizeHint=s,this._meshes={self:new $(this.id,this._sizeHint),neighbors:new Array},this._currentRecordOverlaps=0,this._currentEntityOverlaps=0}get id(){return this.tileKey}vertexCount(){return this._meshes.self.vertexCount()}indexCount(){return this._meshes.self.indexCount()}indexEnsureSize(t){this._meshes.self.indexEnsureSize(t)}entityStart(t,e=t){this._currentEntityOverlaps=0,this._meshes.self.entityStart(t,e)}entityRecordCount(){return this._meshes.self.entityRecordCount()}entityEnd(){if(this._meshes.self.entityEnd(),this._bufferingEnabled)for(let t=0;t<8;t++){const e=1<<t;this._currentEntityOverlaps&e&&this._meshes.neighbors[t].entityEnd()}}recordStart(t,e,s){this._currentRecordOverlaps=0,this._meshes.self.recordStart(t,e,s)}recordEnd(t=0){const e=this._meshes.self.recordEnd(this._currentRecordOverlaps);return e&&0!==this._currentRecordOverlaps?(this._copyIntoNeighbors(),this._currentEntityOverlaps|=this._currentRecordOverlaps,!0):e}recordBounds(t,e,s,i){this._bufferingEnabled&&this._addOverlap(t,e,s,i)}recordCount(){return this._meshes.self.recordCount()}metricStart(t){this._meshes.self.metricStart(t)}metricBoxWrite(t){this._meshes.self.metricBoxWrite(t)}metricEnd(){this._meshes.self.metricEnd()}vertexWrite(t){this._meshes.self.vertexWrite(t)}vertexWriteF32(t){this._meshes.self.vertexWriteF32(t)}vertexWriteRegion(t){this._meshes.self.vertexWriteRegion(t)}indexWrite(t){this._meshes.self.indexWrite(t)}serialize(t){const e={message:[],transferList:[]},s=this._meshes.self.serialize();return e.message.push({tileId:this.tileKey,...s.message}),e.transferList.push(...s.transferList),this._meshes.neighbors.forEach(((s,i)=>{const r=s.serialize(),n=1<<i,o=K(n),a=Z(n),h=function(t,e,s,i){const r=t.clone(),n=1<<r.level,o=r.col+e,a=r.row+s;return i&&o<0?(r.col=o+n,r.world-=1):o>=n?(r.col=o-n,r.world+=1):r.col=o,r.row=a,r}(new p.c(this.tileKey),o,a,t);e.message.push({tileId:h.id,...r.message}),e.transferList.push(...r.transferList)})),e}_addOverlap(t,e,s,i){const r=Math.min(B.gT/2,s),n=Math.min(B.gT/2,i),o=255^((t<0+r?148:t>=B.gT-r?41:189)|(e<0+n?224:e>=B.gT-n?7:231));this._currentRecordOverlaps|=o}_copyIntoNeighbors(){for(let t=0;t<8;t++){const e=1<<t;if(this._currentRecordOverlaps&e){if(!this._meshes.neighbors[t]){const s=Math.floor(this._sizeHint/16);this._meshes.neighbors[t]=new $(e,s)}const s=this._meshes.neighbors[t],i=-K(e)*B.gT,r=-Z(e)*B.gT;s.copyLastFrom(this._meshes.self,i,r)}}}}class J{}var tt=s(92400),et=s(62088),st=s(88264);const it=53290320,rt=10;function nt(t,e,s,i,r,n,o){if(t.primitiveName===e)for(const e in t)if(e===s){let s=i?.readWithDefault(r,n,t[e]&&o);return"text"===t.type&&(s=s.toString()),void(t[e]=s)}if("type"in t&&null!=t.type)switch(t.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":if(t.symbolLayers)for(const a of t.symbolLayers)nt(a,e,s,i,r,n,o);break;case"CIMHatchFill":t.lineSymbol&&nt(t.lineSymbol,e,s,i,r,n,o);break;case"CIMSolidStroke":case"CIMSolidFill":case"CIMVectorMarker":if("CIMVectorMarker"===t.type&&t.markerGraphics)for(const a of t.markerGraphics)nt(a,e,s,i,r,n,o),nt(a.symbol,e,s,i,r,n,o)}}class ot{destroy(){}}class at extends ot{constructor(t){super(),this._value=t}resize(t){}read(t,e){return this._value}readWithDefault(t,e,s){return this._value}referencesScale(){return!1}referencesGeometry(){return!1}}async function ht(t,e,s=!1){const{defaultValue:i,valueExpressionInfo:r,value:n}=e;if(r){const{expression:n}=r,o=await t.createComputedField({expression:n},s);return o?{...e,computed:o,defaultValue:i}:null}return{...e,computed:new at(n),defaultValue:i}}async function ct(t,e){const{defaultValue:s,valueExpressionInfo:i}=e,{expression:r}=i,n=await t.createComputedField({expression:r});return n?{...e,computed:n,defaultValue:s}:null}const lt=t=>"boolean"!=typeof t&&"number"!=typeof t&&"valueExpressionInfo"in t,ut=t=>t.some((t=>{for(const e in t){const s=t[e];if(lt(s))return!0}return!1}));class dt{static async create(t,e,s){const i={},r=new Map,n=new Map,o=new Map,a=new Map,h=new Map;for(const c in s.params){const l=s.params[c];if(null!=l&&"object"==typeof l)if(Array.isArray(l)){if("object"==typeof l[0])throw new Error(`InternalError: Cannot handle ${c}. Nested array params are not supported`);i[c]=l}else if("valueExpressionInfo"in l){if(l.value){i[c]=l.value;continue}const e=await ct(t,l);if(!e){i[c]=l.defaultValue;continue}r.set(c,e),i[c]=null}else switch(l.type){case"cim-effect-infos":if(l.effectInfos.some((t=>t.overrides.length))){n.set(c,{effects:await Promise.all(l.effectInfos.map((async e=>{const s=e.overrides.map((e=>ht(t,e)));return{effect:e.effect,compiledOverrides:(await Promise.all(s)).filter(tt.G6)}})))});break}i[c]=l.effectInfos.map((t=>t.effect));break;case"cim-marker-placement-info":l.overrides.length&&o.set(c,{placementInfo:l,compiledOverrides:(await Promise.all(l.overrides.map((e=>ht(t,e))))).filter(tt.G6)}),i[c]=l.placement;break;case"text-rasterization-param":{if(l.overrides.length){const e=l.overrides.map((e=>ht(t,e,l.useLegacyLabelEvaluationRules)));a.set(c,{compiledOverrides:(await Promise.all(e)).filter(tt.G6),rasterizationParam:l,objectIdToResourceId:new Map});continue}const s={type:"cim-rasterization-info",resource:l.resource};i[c]=await e.fetchResourceImmediate(s)??null;break}case"sprite-rasterization-param":{if(l.overrides.length){const e=l.overrides.map((e=>ht(t,e)));a.set(c,{compiledOverrides:(await Promise.all(e)).filter(tt.G6),rasterizationParam:l,objectIdToResourceId:new Map});continue}if("animated"===l.resource.type){a.set(c,{compiledOverrides:[],rasterizationParam:l,objectIdToResourceId:new Map});continue}const s={type:"cim-rasterization-info",resource:l.resource};i[c]=await e.fetchResourceImmediate(s)??null;break}case"cim-marker-transform-param":{const{params:e}=l;if(ut(e)){const s={compiledMarkerInfos:[]};await Promise.all(e.map((async e=>{const i={props:{}};for(const s in e)if(lt(e[s])){const r=await ct(t,e[s]);i.compiledExpressionMap||(i.compiledExpressionMap=new Map);const n=i.compiledExpressionMap;r&&n.set(s,r)}else i.props[s]=e[s];s.compiledMarkerInfos.push(i)}))),h.set(c,s)}else i[c]={type:"cim-marker-transform-info",infos:e};break}default:i[c]=l}else i[c]=l}return new dt(s,i,r,n,o,a,h)}constructor(t,e,s,i,r,n,o){this.inputMeshParams=t,this._resolvedMeshParams=e,this._dynamicProperties=s,this._dynamicEffectProperties=i,this._dynamicPlacementProperties=r,this._dynamicAsyncProperties=n,this._dynamicTransformProperties=o,this.evaluator=t=>t}get hasDynamicProperties(){return!!(this._dynamicProperties.size||this._dynamicAsyncProperties.size||this._dynamicEffectProperties.size||this._dynamicTransformProperties.size||this._dynamicPlacementProperties.size)}get evaluatedMeshParams(){return this._evaluatedMeshParams||(this._evaluatedMeshParams=this.evaluator(this._resolvedMeshParams)),this._evaluatedMeshParams}enqueueRequest(t,e,s){for(const n of this._dynamicAsyncProperties.values()){const o=(0,et.ct)(n.rasterizationParam.resource);"animated"===n.rasterizationParam.resource.type&&n.rasterizationParam.resource.randomizeStartTime&&(o.primitiveName="__RESERVED__PRIMITIVE__NAME__",o.startGroup=(r=e.getObjectId()||0,Math.floor(function(t,e){let s;if("string"==typeof t)s=(0,st.sV)(t+`-seed(${e})`);else{let i=12;s=t^e;do{s=107*(s>>8^s)+i|0}while(0!=--i)}return(1+s/(1<<31))/2}(r,it)*rt)));for(const{primitiveName:t,propertyName:r,computed:a,defaultValue:h,valueExpressionInfo:c}of n.compiledOverrides)try{nt(o,"animated"===n.rasterizationParam.resource.type?o.primitiveName:t,r,a,e,s,h)}catch(e){C.c.getLogger("geoscene.views.2d.engine.webgl.shaderGraph.techniques.mesh.MeshWriterInputEvaluator").errorOnce(new i.c("invalid-arcade-expression",`Encountered an error when evaluating the arcade expression '${c?.expression}' (primitive: '${t}', property: '${r}')`,e))}const a=t.enqueueRequest({type:"cim-rasterization-info",resource:o});n.objectIdToResourceId.set(e.getObjectId(),a)}var r}evaluateMeshParams(t,e,s){for(const[t,i]of this._dynamicProperties.entries())this._resolvedMeshParams[t]=i.computed.readWithDefault(e,s,i.defaultValue);for(const[t,i]of this._dynamicPlacementProperties.entries())for(const{computed:r,defaultValue:n,propertyName:o}of i.compiledOverrides){const a=r.readWithDefault(e,s,n);i.placementInfo.placement[o]=a,this._resolvedMeshParams[t]=i.placementInfo.placement}for(const[t,i]of this._dynamicEffectProperties.entries())for(const r of i.effects){for(const{computed:t,defaultValue:i,propertyName:n}of r.compiledOverrides){const o=t.readWithDefault(e,s,i);r.effect[n]=o}this._resolvedMeshParams[t]=i.effects.map((t=>t.effect))}for(const[t,i]of this._dynamicTransformProperties.entries()){const r={type:"cim-marker-transform-info",infos:[]};for(const t of i.compiledMarkerInfos){const i={...t.props};if(t.compiledExpressionMap)for(const[r,n]of t.compiledExpressionMap){const t=n.computed.readWithDefault(e,s,n.defaultValue);i[r]="number"==typeof t||"boolean"==typeof t?t:n.defaultValue}r.infos.push(i)}this._resolvedMeshParams[t]=r}for(const[s,i]of this._dynamicAsyncProperties.entries()){const r=i.objectIdToResourceId.get(e.getObjectId());if(null==r)continue;const n=t.getResource(r);this._resolvedMeshParams[s]=n}return this._evaluatedMeshParams=this.evaluator(this._resolvedMeshParams),this.evaluatedMeshParams}}var pt=s(30936),_t=(s(17012),s(93320)),ft=s(85152);function mt(t,e,s,i,r,n,o){Ut=0;const a=(i-s)*n,h=r&&r.length,c=h?(r[0]-s)*n:a;let l,u,d,p,_,f=gt(e,s,0,0,c,n,!0);if(f&&f.next!==f.prev){if(h&&(f=function(t,e,s,i,r,n){const o=new Array;for(let r=0,a=i.length;r<a;r++){const h=gt(t,e,0,i[r]*n,r<a-1?i[r+1]*n:s*n,n,!1);h===h.next&&(h.steiner=!0),o.push(It(h))}o.sort(Rt);for(const t of o)r=Tt(t,r);return r}(e,s,i,r,f,n)),a>80*n){l=d=e[0+s*n],u=p=e[1+s*n];for(let t=n;t<c;t+=n){const i=e[t+s*n],r=e[t+1+s*n];l=Math.min(l,i),u=Math.min(u,r),d=Math.max(d,i),p=Math.max(p,r)}_=Math.max(d-l,p-u),_=0!==_?1/_:0}xt(f,t,n,l,u,_,o,0)}}function gt(t,e,s,i,r,n,o){let a;if(o===function(t,e,s,i,r,n){let o=0;for(let s=i,a=r-n;s<r;s+=n)o+=(t[a+e*n]-t[s+e*n])*(t[s+1+e*n]+t[a+1+e*n]),a=s;return o}(t,e,0,i,r,n)>0)for(let s=i;s<r;s+=n)a=vt(s+e*n,t[s+e*n],t[s+1+e*n],a);else for(let s=r-n;s>=i;s-=n)a=vt(s+e*n,t[s+e*n],t[s+1+e*n],a);return a&&At(a,a.next)&&(St(a),a=a.next),a}function yt(t,e=t){if(!t)return t;let s,i=t;do{if(s=!1,i.steiner||!At(i,i.next)&&0!==Mt(i.prev,i,i.next))i=i.next;else{if(St(i),i=e=i.prev,i===i.next)break;s=!0}}while(s||i!==e);return e}function xt(t,e,s,i,r,n,o,a){if(!t)return;!a&&n&&(t=Pt(t,i,r,n));let h=t;for(;t.prev!==t.next;){const c=t.prev,l=t.next;if(n?wt(t,i,r,n):bt(t))e.push(c.index/s+o),e.push(t.index/s+o),e.push(l.index/s+o),St(t),t=l.next,h=l.next;else if((t=l)===h){a?1===a?xt(t=Ot(t,e,s,o),e,s,i,r,n,o,2):2===a&&Nt(t,e,s,i,r,n,o):xt(yt(t),e,s,i,r,n,o,1);break}}}function bt(t){const e=t.prev,s=t,i=t.next;if(Mt(e,s,i)>=0)return!1;let r=t.next.next;const n=r;let o=0;for(;r!==t.prev&&(0===o||r!==n);){if(o++,Ct(e.x,e.y,s.x,s.y,i.x,i.y,r.x,r.y)&&Mt(r.prev,r,r.next)>=0)return!1;r=r.next}return!0}function wt(t,e,s,i){const r=t.prev,n=t,o=t.next;if(Mt(r,n,o)>=0)return!1;const a=r.x<n.x?r.x<o.x?r.x:o.x:n.x<o.x?n.x:o.x,h=r.y<n.y?r.y<o.y?r.y:o.y:n.y<o.y?n.y:o.y,c=r.x>n.x?r.x>o.x?r.x:o.x:n.x>o.x?n.x:o.x,l=r.y>n.y?r.y>o.y?r.y:o.y:n.y>o.y?n.y:o.y,u=Ft(a,h,e,s,i),d=Ft(c,l,e,s,i);let p=t.prevZ,_=t.nextZ;for(;p&&p.z>=u&&_&&_.z<=d;){if(p!==t.prev&&p!==t.next&&Ct(r.x,r.y,n.x,n.y,o.x,o.y,p.x,p.y)&&Mt(p.prev,p,p.next)>=0)return!1;if(p=p.prevZ,_!==t.prev&&_!==t.next&&Ct(r.x,r.y,n.x,n.y,o.x,o.y,_.x,_.y)&&Mt(_.prev,_,_.next)>=0)return!1;_=_.nextZ}for(;p&&p.z>=u;){if(p!==t.prev&&p!==t.next&&Ct(r.x,r.y,n.x,n.y,o.x,o.y,p.x,p.y)&&Mt(p.prev,p,p.next)>=0)return!1;p=p.prevZ}for(;_&&_.z<=d;){if(_!==t.prev&&_!==t.next&&Ct(r.x,r.y,n.x,n.y,o.x,o.y,_.x,_.y)&&Mt(_.prev,_,_.next)>=0)return!1;_=_.nextZ}return!0}function vt(t,e,s,i){const r=Lt.create(t,e,s);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function St(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function It(t){let e=t,s=t;do{(e.x<s.x||e.x===s.x&&e.y<s.y)&&(s=e),e=e.next}while(e!==t);return s}function Tt(t,e){const s=function(t,e){let s=e;const i=t.x,r=t.y;let n,o=-1/0;do{if(r<=s.y&&r>=s.next.y&&s.next.y!==s.y){const t=s.x+(r-s.y)*(s.next.x-s.x)/(s.next.y-s.y);if(t<=i&&t>o){if(o=t,t===i){if(r===s.y)return s;if(r===s.next.y)return s.next}n=s.x<s.next.x?s:s.next}}s=s.next}while(s!==e);if(!n)return null;if(i===o)return n.prev;const a=n,h=n.x,c=n.y;let l,u=1/0;for(s=n.next;s!==a;)i>=s.x&&s.x>=h&&i!==s.x&&Ct(r<c?i:o,r,h,c,r<c?o:i,r,s.x,s.y)&&(l=Math.abs(r-s.y)/(i-s.x),(l<u||l===u&&s.x>n.x)&&kt(s,t)&&(n=s,u=l)),s=s.next;return n}(t,e);if(!s)return e;const i=zt(s,t);return yt(i,i.next),yt(s,s.next)}function Pt(t,e,s,i){let r;for(;r!==t;r=r.next){if(r=r||t,null===r.z&&(r.z=Ft(r.x,r.y,e,s,i)),r.prev.next!==r||r.next.prev!==r)return r.prev.next=r,r.next.prev=r,Pt(t,e,s,i);r.prevZ=r.prev,r.nextZ=r.next}return t.prevZ.nextZ=null,t.prevZ=null,function(t){let e,s=1;for(;;){let i,r=t;t=null,e=null;let n=0;for(;r;){n++,i=r;let o=0;for(;o<s&&i;o++)i=i.nextZ;let a=s;for(;o>0||a>0&&i;){let s;0===o?(s=i,i=i.nextZ,a--):0!==a&&i?r.z<=i.z?(s=r,r=r.nextZ,o--):(s=i,i=i.nextZ,a--):(s=r,r=r.nextZ,o--),e?e.nextZ=s:t=s,s.prevZ=e,e=s}r=i}if(e.nextZ=null,s*=2,n<2)return t}}(t)}function Mt(t,e,s){return(e.y-t.y)*(s.x-e.x)-(e.x-t.x)*(s.y-e.y)}function Et(t,e,s,i){return!!(At(t,e)&&At(s,i)||At(t,i)&&At(s,e))||Mt(t,e,s)>0!=Mt(t,e,i)>0&&Mt(s,i,t)>0!=Mt(s,i,e)>0}function Ct(t,e,s,i,r,n,o,a){return(r-o)*(e-a)-(t-o)*(n-a)>=0&&(t-o)*(i-a)-(s-o)*(e-a)>=0&&(s-o)*(n-a)-(r-o)*(i-a)>=0}function kt(t,e){return Mt(t.prev,t,t.next)<0?Mt(t,e,t.next)>=0&&Mt(t,t.prev,e)>=0:Mt(t,e,t.prev)<0||Mt(t,t.next,e)<0}function Ft(t,e,s,i,r){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-s)*r)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-i)*r)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function At(t,e){return t.x===e.x&&t.y===e.y}function Rt(t,e){return t.x-e.x}function Ot(t,e,s,i){let r=t;do{const n=r.prev,o=r.next.next;!At(n,o)&&Et(n,r,r.next,o)&&kt(n,o)&&kt(o,n)&&(e.push(n.index/s+i),e.push(r.index/s+i),e.push(o.index/s+i),St(r),St(r.next),r=t=o),r=r.next}while(r!==t);return r}function Nt(t,e,s,i,r,n,o){let a=t;do{let t=a.next.next;for(;t!==a.prev;){if(a.index!==t.index&&Dt(a,t)){let h=zt(a,t);return a=yt(a,a.next),h=yt(h,h.next),xt(a,e,s,i,r,n,o,0),void xt(h,e,s,i,r,n,o,0)}t=t.next}a=a.next}while(a!==t)}function Dt(t,e){return t.next.index!==e.index&&t.prev.index!==e.index&&!function(t,e){let s=t;do{if(s.index!==t.index&&s.next.index!==t.index&&s.index!==e.index&&s.next.index!==e.index&&Et(s,s.next,t,e))return!0;s=s.next}while(s!==t);return!1}(t,e)&&kt(t,e)&&kt(e,t)&&function(t,e){let s=t,i=!1;const r=(t.x+e.x)/2,n=(t.y+e.y)/2;do{s.y>n!=s.next.y>n&&s.next.y!==s.y&&r<(s.next.x-s.x)*(n-s.y)/(s.next.y-s.y)+s.x&&(i=!i),s=s.next}while(s!==t);return i}(t,e)}function zt(t,e){const s=Lt.create(t.index,t.x,t.y),i=Lt.create(e.index,e.x,e.y),r=t.next,n=e.prev;return t.next=e,e.prev=t,s.next=r,r.prev=s,i.next=s,s.prev=i,n.next=i,i.prev=n,i}class Lt{constructor(){this.index=0,this.x=0,this.y=0,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}static create(t,e,s){const i=Ut<Bt.length?Bt[Ut++]:new Lt;return i.index=t,i.x=e,i.y=s,i.prev=null,i.next=null,i.z=null,i.prevZ=null,i.nextZ=null,i.steiner=!1,i}}const Bt=[];let Ut=0;for(let t=0;t<8096;t++)Bt.push(new Lt);const Gt=new _t.CU(0,0,0,1,0),Vt=new _t.CU(0,0,0,1,0);function qt(t,e,s){let i=0;for(let r=1;r<s;r++){const s=t[2*(e+r-1)],n=t[2*(e+r-1)+1];i+=(t[2*(e+r)]-s)*(t[2*(e+r)+1]+n)}return i}function Wt(t,e,s,i,r){let n=0;for(let o=s;o<i;o+=3){const s=2*(t[o]-r),i=2*(t[o+1]-r),a=2*(t[o+2]-r);n+=Math.abs((e[s]-e[a])*(e[i+1]-e[s+1])-(e[s]-e[i])*(e[a+1]-e[s+1]))}return n}Gt.setExtent(B.gT),Vt.setExtent(B.gT);var Xt=s(68564),Yt=s(6704);class jt{static fromOptimized(t,e,s=!1,i=!1,r=1){return(new Ht).initialize(t,e,s,i,r)}static fromJSON(t,e=!1,s=!1){const[i,r]=Kt(t);return(new Zt).initialize(i,r,e,s,1)}static fromOptimizedCIM(t,e,s=!1,i=!1,r=1){return(new Qt).initialize(t,e,s,i,r)}static fromJSONCIM(t,e=!1,s=!1,i=1){const[r,n]=Kt(t);return(new Jt).initialize(r,n,e,s,i)}static fromFeatureSetReader(t){const e=t.readGeometryForDisplay(),s=t.geometryType;return e&&s?this.fromOptimized(e,s):null}static fromFeatureSetReaderCIM(t){const e=t.readGeometryForDisplay(),s=t.geometryType;return e&&s?this.fromOptimizedCIM(e,s):null}static createEmptyOptimized(t,e=!1,s=!1,i=1){return(new Ht).initialize(new ft.c,t,e,s,i)}static createEmptyJSON(t,e=!1,s=!1){return(new Zt).initialize([],t,e,s,1)}static createEmptyOptimizedCIM(t,e=!1,s=!1,i=1){return(new Qt).initialize(new ft.c,t,e,s,i)}static createEmptyJSONCIM(t,e=!1,s=!1,i=1){return(new Jt).initialize([],t,e,s,i)}asJSON(){const t=(0,Xt.k)(this);return"esriGeometryEnvelope"===this.geometryType?{xmin:t[0][0][0],ymin:t[0][0][1],xmax:t[0][2][0],ymax:t[0][2][1]}:"esriGeometryMultipoint"===this.geometryType?{points:t.flat()}:"esriGeometryPoint"===this.geometryType?{x:t[0][0][0],y:t[0][0][1]}:"esriGeometryPolygon"===this.geometryType?{rings:t}:{paths:t}}getCurrentRingArea(){if(this.pathSize<3)return 0;let t,e,s=0;if(this.seekPathStart(),!this.nextPoint())return 0;t=this.x,e=this.y;const i=t,r=e;for(;this.nextPoint();)s+=(t-this.x)*(e+this.y),t=this.x,e=this.y;return s+=(t-i)*(e+r),-.5*s}invertY(){this.yFactor*=-1}}class Ht extends jt{constructor(){super(...arguments),this._end=-1}initialize(t,e,s,i,r){return this.hasZ=s,this.hasM=i,this.geometryType=e,this._stride=2+Number(s)+Number(i),this._geometry=t,this._pathIndex=-1,this._pathOffset=0,this._pointOffset=-this._stride,this._end=-1,this.yFactor=r,this}reset(){this.initialize(this._geometry,this.geometryType,this.hasZ,this.hasM,this.yFactor)}seekPath(t){if(t>=0&&t<this.totalSize){if(this._pathIndex<t)for(;this._pathIndex<t&&this.nextPath(););else if(this._pathIndex>t)for(;this._pathIndex>t&&this.prevPath(););return!0}return!1}seekPathStart(){this._pointOffset=this._pathOffset-this._stride}seekPathEnd(){this._pointOffset=this._end}seekInPath(t){const e=this._pathOffset+t*this._stride;return e>=0&&e<this._end&&(this._pointOffset=e,!0)}nextPoint(){return(this._pointOffset+=this._stride)<this._end}prevPoint(){return(this._pointOffset-=this._stride)>=this._pathOffset}nextPath(){return!(this.pathIndex>=this.totalSize-1||(this._pathIndex>=0&&(this._pathOffset+=this._stride*this.pathSize),this._pathIndex++,this._pointOffset=this._pathOffset-this._stride,this._end=this._pointOffset+this._stride+this._stride*this.pathSize,0))}prevPath(){return!(this.pathIndex<=0||(this._pathIndex--,this._end=this._pathOffset,this._pathOffset-=this._stride*this.pathSize,this._pointOffset=this._pathOffset-this._stride,0))}pathLength(){const t=this._end,e=this._stride,s=this._geometry.coords;let i=0;for(let r=this._pathOffset+e;r<t;r+=e){const t=s[r-e],n=s[r-e+1],o=s[r]-t,a=s[r+1]-n;i+=Math.sqrt(o*o+a*a)}return i}startPath(){this._geometry.lengths.push(0)}pushPath(t){this.startPath(),this.pushPoints(t)}pushPoint(t){for(let e=0;e<this._stride;++e)this._geometry.coords.push(t[e]);this._geometry.lengths[this.totalSize-1]++}pushXY(t,e){this._geometry.coords.push(t,e),this._geometry.lengths[this.totalSize-1]++}pushPoints(t){for(const e of t)for(let t=0;t<this._stride;++t)this._geometry.coords.push(e[t]);this._geometry.lengths[this.totalSize-1]+=t.length}pushCursor(t){const e=t.asOptimized();this._geometry.coords.push(...e.coords),this._geometry.lengths.push(...e.lengths)}asOptimized(){const t=this._geometry.clone();if(1!==this.yFactor)for(let e=1;e<t.coords.length;e+=this._stride)t.coords[e]*=this.yFactor;return"esriGeometryPoint"===this.geometryType&&(t.lengths.length=0),t}isClosed(){const t=this._geometry.coords,e=this._pathOffset,s=this._end-this._stride;for(let i=0;i<this._stride;i++)if(t[e+i]!==t[s+i])return!1;return!0}clone(){return(new Ht).initialize(this._geometry.clone(),this.geometryType,this.hasZ,this.hasM,this.yFactor)}get totalPoints(){return this._geometry.isPoint?1:this._geometry.lengths.reduce(((t,e)=>t+e))}get pathSize(){const{lengths:t}=this._geometry;return this._pathIndex<0||this._pathIndex>t.length-1?0:this._geometry.isPoint?1:t[this._pathIndex]}get totalSize(){return this._geometry.lengths.length}get x(){return this._geometry.coords[this._pointOffset]}set x(t){this._geometry.coords[this._pointOffset]=t}get y(){return this.yFactor*this._geometry.coords[this._pointOffset+1]}set y(t){this._geometry.coords[this._pointOffset+1]=this.yFactor*t}get z(){return this._geometry.coords[this._pointOffset+2]}set z(t){this._geometry.coords[this._pointOffset+2]=t}get m(){const t=this.hasZ?3:2;return this._geometry.coords[this._pointOffset+t]}set m(t){this._geometry.coords[this._pointOffset+3]=t}get pathIndex(){return this._pathIndex}get _coordIndex(){return this._pointOffset/this._stride}}function $t(t){const e=[t.x,t.y];return t.z&&e.push(t.z),t.m&&e.push(t.m),e}function Kt(t){return(0,Yt.Cs)(t)?[t.rings,"esriGeometryPolygon"]:(0,Yt.cZ)(t)?[t.paths,"esriGeometryPolyline"]:(0,Yt._)(t)?[[t.points],"esriGeometryMultipoint"]:(0,Yt.Ul)(t)?[[[[t.xmin,t.ymin],[t.xmin,t.ymax],[t.xmax,t.ymax],[t.xmax,t.ymin],[t.xmin,t.ymin]]],"esriGeometryEnvelope"]:(0,Yt._x)(t)?[[[$t(t)]],"esriGeometryPoint"]:[[],"esriGeometryPolyline"]}class Zt extends jt{initialize(t,e,s,i,r){return this._paths=t,this.geometryType=e,this.hasZ=s,this.hasM=i,this._pathIndex=this._pointIndex=-1,this.yFactor=r,this._mIndex=this.hasZ?3:2,this}reset(){this._pathIndex=this._pointIndex=-1}seekPath(t){return this._pathIndex=t,this._pointIndex=-1,t>=0&&t<this.totalSize&&(this._currentPath=this._paths[t],!0)}seekPathStart(){this._pointIndex=-1}seekPathEnd(){this._pointIndex=this._currentPath.length}seekInPath(t){return t>=0&&t<this._currentPath.length&&(this._pointIndex=t,this._currentPoint=this._currentPath[this._pointIndex],!0)}nextPoint(){return this._currentPoint=this._currentPath[++this._pointIndex],this._pointIndex<this._currentPath.length}prevPoint(){return this._currentPoint=this._currentPath[--this._pointIndex],this._pointIndex>=0}nextPath(){return this._pointIndex=-1,this._currentPath=this._paths[++this._pathIndex],this._pathIndex<this.totalSize}prevPath(){return this.pathIndex>0&&(this._pointIndex=-1,this._pathIndex--,this._currentPath=this._paths[this._pathIndex],!0)}pathLength(){const t=this._currentPath.length,e=this._currentPath;let s=0;for(let i=1;i<t;i++){const t=e[i-1],r=e[i],n=t[0],o=t[1],a=r[0]-n,h=r[1]-o;s+=Math.sqrt(a*a+h*h)}return s}startPath(){this._paths.push([])}pushPath(t){this._paths.push(t)}pushPoint(t){this._paths[this.totalSize-1].push(t)}pushXY(t,e){this._paths[this.totalSize-1].push([t,e])}pushPoints(t){this._paths[this.totalSize-1].push(...t)}pushCursor(t){const e=(0,Xt.k)(t);for(const t of e)this.pushPath(t)}asOptimized(){const t=new ft.c;if("esriGeometryPoint"===this.geometryType)t.coords.push(...this._paths[0][0]),t.lengths.length=0;else for(const e of this._paths){for(const s of e)t.coords.push(s[0]),t.coords.push(s[1]*this.yFactor),this.hasZ&&t.coords.push(s[2]),this.hasM&&t.coords.push(s[this._mIndex]);t.lengths.push(e.length)}return t}isClosed(){const t=this._currentPath[0],e=this._currentPath[this._currentPath.length-1];for(let s=0;s<t.length;s++)if(t[s]!==e[s])return!1;return!0}clone(){return(new Zt).initialize((0,et.ct)(this._paths),this.geometryType,this.hasZ,this.hasM,this.yFactor)}get totalPoints(){return this._paths.map((t=>t.length)).reduce(((t,e)=>t+e))}get pathSize(){return this._pathIndex<0||this._pathIndex>this.totalSize-1?-1:this._paths[this._pathIndex].length}get totalSize(){return this._paths.length}get x(){return this._currentPoint[0]}set x(t){this._currentPoint[0]=t}get y(){return this.yFactor*this._currentPoint[1]}set y(t){this._currentPoint[1]=this.yFactor*t}get z(){return this._currentPoint[2]}set z(t){this._currentPoint[2]=t}get m(){return this._currentPoint[this._mIndex]}set m(t){this._currentPoint[this._mIndex]=t}get pathIndex(){return this._pathIndex}}class Qt extends Ht{initialize(t,e,s,i,r){return super.initialize(t,e,s,i,r),this._controlPoints||(this._controlPoints=this._controlPoints=new Array(this.totalSize).fill(void 0).map((t=>new Set))),this}startPath(){super.startPath(),this._controlPoints.push(new Set)}clone(){const t=(new Qt).initialize(this._geometry.clone(),this.geometryType,this.hasZ,this.hasM,this.yFactor);return t._controlPoints=this._controlPoints,t}setControlPoint(){this._controlPoints[this.pathIndex].add(this._coordIndex)}getControlPoint(){return this._controlPoints[this.pathIndex].has(this._coordIndex)}setControlPointAt(t){this._controlPoints[this.pathIndex].add(t)}getControlPointAt(t){return this._controlPoints[this.pathIndex].has(t)}}class Jt extends Zt{initialize(t,e,s,i,r){return super.initialize(t,e,s,i,r)}clone(){return(new Jt).initialize((0,et.ct)(this._paths),this.geometryType,this.hasZ,this.hasM,this.yFactor)}setControlPoint(){this._paths[this.pathIndex][this._pointIndex][4]=1}getControlPoint(){return 1===this._paths[this.pathIndex][this._pointIndex][4]}setControlPointAt(t){this._paths[this.pathIndex][t][4]=1}getControlPointAt(t){return 1===this._paths[this.pathIndex][t][4]}}let te;class ee{constructor(t){this._geometry=t}next(){const t=this._geometry;return this._geometry=null,t}}function se(t,e){te||(te=new _t.CU(0,0,0,1));const s="esriGeometryPolygon"===t.geometryType,i=s?_t.ao.Polygon:_t.ao.LineString,r=s?3:2;let n,o;for(te.reset(i),te.setPixelMargin(e+1),te.setExtent(512);t.nextPath();)if(!(t.pathSize<r)){for(t.nextPoint(),n=t.x,o=-t.y,te.moveTo(n,o);t.nextPoint();)n=t.x,o=-t.y,te.lineTo(n,o);s&&te.close()}const a=te.result(!1);if(a){const e=jt.createEmptyOptimizedCIM(t.geometryType);for(const t of a){e.startPath();for(const s of t)e.pushXY(s.x,-s.y)}return e.reset(),e}return null}class ie{static local(){return null===ie.instance&&(ie.instance=new ie),ie.instance}execute(t,e,s,i,r){return new re(t,e,s)}}ie.instance=null;class re{constructor(t,e,s){this._inputGeometries=t,this._angleTolerance=void 0!==e.angleTolerance?e.angleTolerance:120,this._maxCosAngle=Math.cos((1-Math.abs(this._angleTolerance)/180)*Math.PI)}next(){let t=this._inputGeometries.next();for(;t;){if("esriGeometryPolygon"===t.geometryType)this._isClosed=!0;else if("esriGeometryPolyline"===t.geometryType)this._isClosed=!1;else{if("esriGeometryEnvelope"!==t.geometryType){t=this._inputGeometries.next();continue}if(this._maxCosAngle)return t;this._isClosed=!0}for(;t.nextPath();)this._processPath(t);return t.reset(),t}return null}_processPath(t){if(t.nextPoint()){const e=t.x,s=t.y;let i=e,r=s,n=t.pathSize,o=0,a=0,h=0,c=0,l=0,u=0;this._isClosed&&++n;for(let d=1;t.nextPoint()||d<n;++d){let p,_;this._isClosed&&d===n-1?(p=e,_=s):(p=t.x,_=t.y);const f=p-i,m=_-r,g=Math.sqrt(f*f+m*m);d>1&&g>0&&h>0&&(o*f+a*m)/g/h<=this._maxCosAngle&&t.setControlPointAt(d-1),1===d&&(c=f,l=m,u=g),g>0&&(i=p,r=_,o=f,a=m,h=g)}this._isClosed&&h>0&&u>0&&(o*c+a*l)/u/h<=this._maxCosAngle&&t.setControlPointAt(0)}}}class ne{constructor(){this.setIdentity()}getAngle(){return(null==this.rz||0===this.rz&&1!==this.rzCos&&0!==this.rzSin)&&(this.rz=Math.atan2(this.rzSin,this.rzCos)),this.rz}setIdentity(){this.tx=0,this.ty=0,this.tz=0,this.s=1,this.rx=0,this.ry=0,this.rz=0,this.rzCos=1,this.rzSin=0}setTranslate(t,e){this.tx=t,this.ty=e}setTranslateZ(t){this.tz=t}setRotateCS(t,e){this.rz=void 0,this.rzCos=t,this.rzSin=e}setRotate(t){this.rz=t,this.rzCos=void 0,this.rzSin=void 0}setRotateY(t){this.ry=t}setScale(t){this.s=t}setMeasure(t){this.m=t}}function oe(t,e){t[4]=e}class ae{constructor(t,e=!0,s=!0,i=0){this.isClosed=!1,this.geometryCursor=null,this.geometryCursor=!e&&"esriGeometryPolygon"===t.geometryType||!s&&"esriGeometryPolyline"===t.geometryType?null:t,this.geomUnitsPerPoint=i,this.iteratePath=!1,this.internalPlacement=new ne}next(){if(!this.geometryCursor)return null;for(;this.iteratePath||this.geometryCursor.pathIndex<this.geometryCursor.totalSize-1;){this.iteratePath||this.geometryCursor.nextPath();const t=this.processPath(this.geometryCursor);if(t)return t}return this.geometryCursor=null,null}}class he{constructor(t,e,s,i=0){this.isClosed=!1,this.inputGeometries=t,this.acceptPolygon=e,this.acceptPolyline=s,this.geomUnitsPerPoint=i,this.iteratePath=!1,this.multiPathCursor=null}next(){for(;;){if(!this.multiPathCursor){let t=this.inputGeometries.next();for(;t&&(this.isClosed=this.acceptPolygon&&"esriGeometryPolygon"===t.geometryType||"esriGeometryEnvelope"===t.geometryType,this.multiPathCursor=t,!this.multiPathCursor);)t=this.inputGeometries.next();if(!this.multiPathCursor)return null}for(;this.iteratePath||this.multiPathCursor.nextPath();){this.multiPathCursor.seekPathStart();const t=this.processPath(this.multiPathCursor);if(t)return t}this.multiPathCursor=null}}}var ce=s(89232);const le=.03;class ue{constructor(t=0,e=!1){}isEmpty(t){if(!t.nextPoint())return!0;let e,s,i,r;for(e=t.x,s=t.y;t.nextPoint();e=s,s=r)if(i=t.x,r=t.y,i!==e||r!==s)return t.seekPathStart(),!1;return t.seekPathStart(),!0}normalize(t){const e=Math.sqrt(t[0]*t[0]+t[1]*t[1]);0!==e&&(t[0]/=e,t[1]/=e)}getLength(t,e,s,i){const r=s-t,n=i-e;return Math.sqrt(r*r+n*n)}getSegLength(t){const[[e,s],[i,r]]=t;return this.getLength(e,s,i,r)}getCoord2D(t,e,s,i,r){return[t+(s-t)*r,e+(i-e)*r]}getSegCoord2D(t,e){const[[s,i],[r,n]]=t;return this.getCoord2D(s,i,r,n,e)}getAngle(t,e,s,i,r){const n=s-t,o=i-e;return Math.atan2(o,n)}getAngleCS(t,e,s,i,r){const n=s-t,o=i-e,a=Math.sqrt(n*n+o*o);return a>0?[n/a,o/a]:[1,0]}getSegAngleCS(t,e){const[[s,i],[r,n]]=t;return this.getAngleCS(s,i,r,n,e)}cut(t,e,s,i,r,n){return[r<=0?[t,e]:this.getCoord2D(t,e,s,i,r),n>=1?[s,i]:this.getCoord2D(t,e,s,i,n)]}getSubCurve(t,e,s){const i=jt.createEmptyOptimizedCIM("esriGeometryPolyline");return this.appendSubCurve(i,t,e,s)?i:null}appendSubCurve(t,e,s,i){t.startPath(),e.seekPathStart();let r=0,n=!0;if(!e.nextPoint())return!1;let o=e.x,a=e.y;for(;e.nextPoint();){const h=this.getLength(o,a,e.x,e.y);if(0!==h){if(n){if(r+h>s){const c=(s-r)/h;let l=1,u=!1;r+h>=i&&(l=(i-r)/h,u=!0);const d=this.cut(o,a,e.x,e.y,c,l);if(d&&t.pushPoints(d),u)break;n=!1}}else{if(r+h>i){const s=this.cut(o,a,e.x,e.y,0,(i-r)/h);s&&t.pushPoint(s[1]);break}t.pushXY(e.x,e.y)}r+=h,o=e.x,a=e.y}else o=e.x,a=e.y}return!0}getCIMPointAlong(t,e){if(!t.nextPoint())return null;let s,i,r,n,o=0;for(s=t.x,i=t.y;t.nextPoint();s=r,i=n){r=t.x,n=t.y;const a=this.getLength(s,i,r,n);if(0!==a){if(o+a>e){const t=(e-o)/a;return this.getCoord2D(s,i,r,n,t)}o+=a}}return null}offset(t,e,s,i,r){if(!t||t.length<2)return null;let n=0,o=t[n++],a=n;for(;n<t.length;){const e=t[n];e[0]===o[0]&&e[1]===o[1]||(n!==a&&(t[a]=t[n]),o=t[a++]),n++}const h=t[0][0]===t[a-1][0]&&t[0][1]===t[a-1][1];if(h&&--a,a<(h?3:2))return null;const c=[];o=h?t[a-1]:null;let l=t[0];for(let r=0;r<a;r++){const n=r===a-1?h?t[0]:null:t[r+1];if(o)if(n){const t=[n[0]-l[0],n[1]-l[1]];this.normalize(t);const r=[l[0]-o[0],l[1]-o[1]];this.normalize(r);const a=r[0]*t[1]-r[1]*t[0],h=r[0]*t[0]+r[1]*t[1];if(0===a&&1===h){l=n;continue}if(a>=0==e<=0){if(h<1){const s=[t[0]-r[0],t[1]-r[1]];this.normalize(s);const n=Math.sqrt((1+h)/2);if(n>1/i){const t=-Math.abs(e)/n;c.push([l[0]-s[0]*t,l[1]-s[1]*t])}}}else switch(s){case ce.yM.Mitered:{const s=Math.sqrt((1+h)/2);if(s>0&&1/s<i){const i=[t[0]-r[0],t[1]-r[1]];this.normalize(i);const n=Math.abs(e)/s;c.push([l[0]-i[0]*n,l[1]-i[1]*n]);break}}case ce.yM.Bevelled:c.push([l[0]+r[1]*e,l[1]-r[0]*e]),c.push([l[0]+t[1]*e,l[1]-t[0]*e]);break;case ce.yM.Rounded:if(h<1){c.push([l[0]+r[1]*e,l[1]-r[0]*e]);const s=Math.floor(2.5*(1-h));if(s>0){const i=1/s;let n=i;for(let o=1;o<s;o++,n+=i){const s=[r[1]*(1-n)+t[1]*n,-r[0]*(1-n)-t[0]*n];this.normalize(s),c.push([l[0]+s[0]*e,l[1]+s[1]*e])}}c.push([l[0]+t[1]*e,l[1]-t[0]*e])}break;case ce.yM.Square:default:if(a<0)c.push([l[0]+(r[1]+r[0])*e,l[1]+(r[1]-r[0])*e]),c.push([l[0]+(t[1]-t[0])*e,l[1]-(t[0]+t[1])*e]);else{const s=Math.sqrt((1+Math.abs(h))/2),i=[t[0]-r[0],t[1]-r[1]];this.normalize(i);const n=e/s;c.push([l[0]-i[0]*n,l[1]-i[1]*n])}}}else{const t=[l[0]-o[0],l[1]-o[1]];this.normalize(t),c.push([l[0]+t[1]*e,l[1]-t[0]*e])}else{const t=[n[0]-l[0],n[1]-l[1]];this.normalize(t),c.push([l[0]+t[1]*e,l[1]-t[0]*e])}o=l,l=n}return c.length<(h?3:2)?null:(h&&c.push([c[0][0],c[0][1]]),c)}}const de=ce.AX.OpenEnded;class pe{static local(){return null===pe.instance&&(pe.instance=new pe),pe.instance}execute(t,e,s,i,r){return new _e(t,e,s)}}pe.instance=null;class _e extends he{constructor(t,e,s){super(t,!1,!0),this._curveHelper=new ue,this._width=(void 0!==e.width?e.width:5)*s,this._arrowType=void 0!==e.geometricEffectArrowType?e.geometricEffectArrowType:void 0!==e.arrowType?e.arrowType:de,this._offsetFlattenError=le*s}processPath(t){const e=jt.createEmptyOptimizedCIM(t.geometryType);switch(this._arrowType){case ce.AX.OpenEnded:default:this._constructSimpleArrow(e,t,!0);break;case ce.AX.Block:this._constructSimpleArrow(e,t,!1);break;case ce.AX.Crossed:this._constructCrossedArrow(e,t)}return e}_constructSimpleArrow(t,e,s){const i=e.pathLength();let r=this._width;i<2*r&&(r=i/2);const n=this._curveHelper.getSubCurve(e,0,i-r);if(!n||!n.nextPath())return;n.seekPathStart();const o=r/2;if(this._curveHelper.isEmpty(n))return;const a=(0,Xt.g)(n),h=this._constructOffset(a,-o);if(!h)return;const c=this._constructOffset(a,o);if(!c)return;const l=this._constructArrowBasePoint(h,-o/2);if(!l)return;const u=this._constructArrowBasePoint(c,o/2);if(!u)return;e.seekInPath(e.pathSize-1);const d=[e.x,e.y];t.pushPath(c),t.nextPath(),t.nextPoint(),t.setControlPoint(),t.pushPoint(u),t.nextPoint(),t.setControlPoint(),t.pushPoint(d),t.nextPoint(),t.setControlPoint(),t.pushPoint(l),t.nextPoint(),t.setControlPoint(),t.pushPoints(h.reverse()),t.setControlPoint(),s||(t.setControlPointAt(0),t.setControlPointAt(t.pathSize-1),t.pushPoint(c[0])),t.reset()}_constructCrossedArrow(t,e){const s=e.pathLength();let i=this._width;s<3.732050807568877*i&&(i=s/3.732050807568877),e.seekPathStart();const r=this._curveHelper.getSubCurve(e,0,s-2.732050807568877*i);if(!r)return;r.nextPath();const n=i/2;if(this._curveHelper.isEmpty(r))return;const o=(0,Xt.g)(r),a=this._constructOffset(o,n);if(!a)return;const h=this._constructOffset(o,-n);if(!h)return;const c=this._curveHelper.getSubCurve(e,0,s-i);if(!c)return;if(c.nextPath(),this._curveHelper.isEmpty(c))return;const l=(0,Xt.g)(c),u=this._constructOffset(l,n);if(!u)return;const d=this._constructOffset(l,-n);if(!d)return;const p=u[u.length-1],_=this._constructArrowBasePoint(u,n/2);if(!_)return;const f=d[d.length-1],m=this._constructArrowBasePoint(d,-n/2);if(!m)return;e.seekInPath(e.pathSize-1);const g=[e.x,e.y];t.pushPath(a),t.nextPath(),t.nextPoint(),t.setControlPoint(),t.pushPoint(f),t.nextPoint(),t.setControlPoint(),t.pushPoint(m),t.nextPoint(),t.setControlPoint(),t.pushPoint(g),t.nextPoint(),t.setControlPoint(),t.pushPoint(_),t.nextPoint(),t.setControlPoint(),t.pushPoint(p),t.nextPoint(),t.setControlPoint(),t.pushPoints(h.reverse()),t.nextPoint(),t.setControlPoint(),t.reset()}_constructOffset(t,e){return this._curveHelper.offset(t,e,ce.yM.Rounded,4,this._offsetFlattenError)}_constructArrowBasePoint(t,e){if(!t||t.length<2)return null;const s=t[t.length-2],i=t[t.length-1],r=[i[0]-s[0],i[1]-s[1]];return this._curveHelper.normalize(r),[i[0]+r[1]*e,i[1]-r[0]*e]}}s(60708);class fe{static local(){return null===fe.instance&&(fe.instance=new fe),fe.instance}execute(t,e,s,i,r,n){return new me(t,e,s,i,r,n)}}fe.instance=null;class me{constructor(t,e,s,i,r,n){this._inputGeometries=t,this._tileKey=i,this._geometryEngine=r,this._curveHelper=new ue,this._size=(void 0!==e.size?e.size:1)*s,this._maxInflateSize=n*s,this._offsetFlattenError=le*s}next(){let t;for(;t=this._inputGeometries.next();){if(0===this._size)return t;if("esriGeometryEnvelope"===t.geometryType)if(this._size>0){const e=jt.createEmptyOptimizedCIM(t.geometryType),s=(0,Xt.k)(t)[0],i=this._curveHelper.offset(s,this._size,ce.yM.Rounded,4,this._offsetFlattenError);if(i)return e.pushPath(i),e}else if(this._size<0){const e=t.asJSON();if(Math.min(e.xmax-e.xmin,e.ymax-e.ymin)+2*this._size>0)return jt.fromJSONCIM({xmin:e.xmin-this._size,xmax:e.xmax+this._size,ymin:e.ymin-this._size,ymax:e.ymax+this._size})}const e=this._geometryEngine;if(null==e)return null;const s=this._tileKey?se(t,this._maxInflateSize):t;if(!s)continue;const i=e.buffer(V.c.WebMercator,s.asJSON(),this._size,1);return i?jt.fromJSONCIM(i):null}return null}}class ge{static local(){return null===ge.instance&&(ge.instance=new ge),ge.instance}execute(t,e,s,i,r){return new ye(t,e,s)}}ge.instance=null;class ye{constructor(t,e,s){this._defaultPointSize=20,this._inputGeometries=t,this._geomUnitsPerPoint=s,this._rule=e.rule??ce.Ki.FullGeometry,this._defaultSize=this._defaultPointSize*s}next(){let t;for(;t=this._inputGeometries.next();){const e=this._processGeom((0,Xt.k)(t));if(e&&e.length)return jt.fromJSONCIM({paths:e})}return null}_clone(t){return[t[0],t[1]]}_mid(t,e){return[(t[0]+e[0])/2,(t[1]+e[1])/2]}_mix(t,e,s,i){return[t[0]*e+s[0]*i,t[1]*e+s[1]*i]}_add(t,e){return[t[0]+e[0],t[1]+e[1]]}_add2(t,e,s){return[t[0]+e,t[1]+s]}_sub(t,e){return[t[0]-e[0],t[1]-e[1]]}_dist(t,e){return Math.sqrt((t[0]-e[0])*(t[0]-e[0])+(t[1]-e[1])*(t[1]-e[1]))}_norm(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}_normalize(t,e=1){const s=e/this._norm(t);t[0]*=s,t[1]*=s}_leftPerpendicular(t){const e=-t[1],s=t[0];t[0]=e,t[1]=s}_leftPerp(t){return[-t[1],t[0]]}_rightPerpendicular(t){const e=t[1],s=-t[0];t[0]=e,t[1]=s}_rightPerp(t){return[t[1],-t[0]]}_dotProduct(t,e){return t[0]*e[0]+t[1]*e[1]}_crossProduct(t,e){return t[0]*e[1]-t[1]*e[0]}_rotateDirect(t,e,s){const i=t[0]*e-t[1]*s,r=t[0]*s+t[1]*e;t[0]=i,t[1]=r}_makeCtrlPt(t){const e=[t[0],t[1]];return oe(e,1),e}_addAngledTicks(t,e,s,i){const r=this._sub(s,e);this._normalize(r);const n=this._crossProduct(r,this._sub(i,e));let o;o=n>0?this._rightPerp(r):this._leftPerp(r);const a=Math.abs(n)/2,h=[];h.push([e[0]+(o[0]-r[0])*a,e[1]+(o[1]-r[1])*a]),h.push(e),h.push(s),h.push([s[0]+(o[0]+r[0])*a,s[1]+(o[1]+r[1])*a]),t.push(h)}_addBezier2(t,e,s,i,r){if(0==r--)return void t.push(i);const n=this._mid(e,s),o=this._mid(s,i),a=this._mid(n,o);this._addBezier2(t,e,n,a,r),this._addBezier2(t,a,o,i,r)}_addBezier3(t,e,s,i,r,n){if(0==n--)return void t.push(r);const o=this._mid(e,s),a=this._mid(s,i),h=this._mid(i,r),c=this._mid(o,a),l=this._mid(a,h),u=this._mid(c,l);this._addBezier3(t,e,o,c,u,n),this._addBezier3(t,u,l,h,r,n)}_add90DegArc(t,e,s,i,r){const n=r??this._crossProduct(this._sub(s,e),this._sub(i,e))>0,o=this._mid(e,s),a=this._sub(o,e);n?this._leftPerpendicular(a):this._rightPerpendicular(a),o[0]+=a[0],o[1]+=a[1],this._addBezier3(t,e,this._mix(e,.33333,o,.66667),this._mix(s,.33333,o,.66667),s,4)}_addArrow(t,e,s){const i=e[0],r=e[1],n=e[e.length-1],o=this._sub(i,r);this._normalize(o);const a=this._crossProduct(o,this._sub(n,r)),h=.5*a,c=this._leftPerp(o),l=[n[0]-c[0]*a,n[1]-c[1]*a],u=e.length-1,d=[];d.push(s?[-c[0],-c[1]]:c);let p=[-o[0],-o[1]];for(let t=1;t<u-1;t++){const s=this._sub(e[t+1],e[t]);this._normalize(s);const i=this._dotProduct(s,p),r=this._crossProduct(s,p),n=Math.sqrt((1+i)/2),o=this._sub(s,p);this._normalize(o),o[0]/=n,o[1]/=n,d.push(r<0?[-o[0],-o[1]]:o),p=s}d.push(this._rightPerp(p));for(let s=d.length-1;s>0;s--)t.push([e[s][0]+d[s][0]*h,e[s][1]+d[s][1]*h]);t.push([l[0]+d[0][0]*h,l[1]+d[0][1]*h]),t.push([l[0]+d[0][0]*a,l[1]+d[0][1]*a]),t.push(i),t.push([l[0]-d[0][0]*a,l[1]-d[0][1]*a]),t.push([l[0]-d[0][0]*h,l[1]-d[0][1]*h]);for(let s=1;s<d.length;s++)t.push([e[s][0]-d[s][0]*h,e[s][1]-d[s][1]*h])}_cp2(t,e,s){return t.length>=2?t[1]:this._add2(t[0],e*this._defaultSize,s*this._defaultSize)}_cp3(t,e,s,i){if(t.length>=3)return t[2];const r=this._mix(t[0],1-s,e,s),n=this._sub(e,t[0]);return this._normalize(n),this._rightPerpendicular(n),[r[0]+n[0]*i*this._defaultSize,r[1]+n[1]*i*this._defaultSize]}_arrowPath(t){if(t.length>2)return t;const e=t[0],s=this._cp2(t,-4,0),i=this._sub(e,s);this._normalize(i);const r=this._rightPerp(i);return[e,s,[e[0]+(r[0]-i[0])*this._defaultSize,e[1]+(r[1]-i[1])*this._defaultSize]]}_arrowLastSeg(t){const e=t[0],s=this._cp2(t,-4,0);let i;if(t.length>=3)i=t[t.length-1];else{const t=this._sub(e,s);this._normalize(t);const r=this._rightPerp(t);i=[e[0]+(r[0]-t[0])*this._defaultSize,e[1]+(r[1]-t[1])*this._defaultSize]}return[s,i]}_processGeom(t){if(!t)return null;const e=[];for(const s of t){if(!s||0===s.length)continue;const t=s.length;let i=s[0];switch(this._rule){case ce.Ki.PerpendicularFromFirstSegment:{const t=this._cp2(s,0,-1),r=this._cp3(s,t,.5,4),n=[];n.push(r),n.push(this._mid(i,t)),e.push(n);break}case ce.Ki.ReversedFirstSegment:{const t=this._cp2(s,0,-1);e.push([t,i]);break}case ce.Ki.PerpendicularToSecondSegment:{const t=this._cp2(s,-4,1),r=this._cp3(s,t,.882353,-1.94),n=[];n.push(this._mid(t,r)),n.push(i),e.push(n);break}case ce.Ki.SecondSegmentWithTicks:{const t=this._cp2(s,-4,1),r=this._cp3(s,t,.882353,-1.94),n=this._sub(r,t);let o;o=this._crossProduct(n,this._sub(i,t))>0?this._rightPerp(o):this._leftPerp(n);const a=[];a.push([t[0]+(o[0]-n[0])/3,t[1]+(o[1]-n[1])/3]),a.push(t),a.push(r),a.push([r[0]+(o[0]+n[0])/3,r[1]+(o[1]+n[1])/3]),e.push(a);break}case ce.Ki.DoublePerpendicular:{const t=this._cp2(s,0,-1),r=this._cp3(s,t,.5,3),n=this._mid(i,t),o=this._sub(n,r);this._normalize(o);const a=this._crossProduct(o,this._sub(i,r));this._leftPerpendicular(o);const h=[];h.push(i),h.push([r[0]+o[0]*a,r[1]+o[1]*a]),e.push(h);const c=[];c.push([r[0]-o[0]*a,r[1]-o[1]*a]),c.push(t),e.push(c);break}case ce.Ki.OppositeToFirstSegment:{const t=this._cp2(s,0,-1),r=this._cp3(s,t,.5,3),n=this._mid(i,t),o=this._sub(n,r);this._normalize(o);const a=this._crossProduct(o,this._sub(i,r));this._leftPerpendicular(o);const h=[];h.push([r[0]+o[0]*a,r[1]+o[1]*a]),h.push([r[0]-o[0]*a,r[1]-o[1]*a]),e.push(h);break}case ce.Ki.TriplePerpendicular:{const t=this._cp2(s,0,-1),r=this._cp3(s,t,.5,4),n=this._mid(i,t),o=this._sub(n,r);this._normalize(o);const a=this._crossProduct(o,this._sub(i,r));this._leftPerpendicular(o);const h=[];h.push([r[0]+o[0]*a*.8,r[1]+o[1]*a*.8]),h.push([n[0]+.8*(i[0]-n[0]),n[1]+.8*(i[1]-n[1])]),e.push(h),e.push([r,n]);const c=[];c.push([r[0]-o[0]*a*.8,r[1]-o[1]*a*.8]),c.push([n[0]+.8*(t[0]-n[0]),n[1]+.8*(t[1]-n[1])]),e.push(c);break}case ce.Ki.HalfCircleFirstSegment:{const t=this._cp2(s,0,-1),r=this._cp3(s,t,.5,4),n=this._mid(i,t);let o=this._sub(t,i);const a=Math.cos(Math.PI/18),h=Math.sin(Math.PI/18),c=Math.sqrt((1+a)/2),l=Math.sqrt((1-a)/2),u=[];let d;this._crossProduct(o,this._sub(r,i))>0?(u.push(i),o=this._sub(i,n),d=t):(u.push(t),o=this._sub(t,n),d=i),this._rotateDirect(o,c,l),o[0]/=c,o[1]/=c;for(let t=1;t<=18;t++)u.push(this._add(n,o)),this._rotateDirect(o,a,h);u.push(d),e.push(u);break}case ce.Ki.HalfCircleSecondSegment:{const t=this._cp2(s,0,-1),r=this._cp3(s,t,1,-1);let n=this._sub(i,t);this._normalize(n);const o=this._crossProduct(n,this._sub(r,t))/2;this._leftPerpendicular(n);const a=[t[0]+n[0]*o,t[1]+n[1]*o];n=this._sub(t,a);const h=Math.cos(Math.PI/18);let c=Math.sin(Math.PI/18);o>0&&(c=-c);const l=[t];for(let t=1;t<=18;t++)this._rotateDirect(n,h,c),l.push(this._add(a,n));e.push(l);break}case ce.Ki.HalfCircleExtended:{const r=this._cp2(s,0,-2),n=this._cp3(s,r,1,-1);let o;if(t>=4)o=s[3];else{const t=this._sub(i,r);o=this._add(n,t)}const a=this._dist(r,n)/2/.75,h=this._sub(r,i);this._normalize(h,a);const c=this._sub(n,o);this._normalize(c,a);const l=[o,n];e.push(l);const u=[this._clone(n)];this._addBezier3(u,n,this._add(n,c),this._add(r,h),r,4),u.push(i),e.push(u);break}case ce.Ki.OpenCircle:{const t=this._cp2(s,-2,0),r=this._sub(t,i),n=Math.cos(Math.PI/18),o=-Math.sin(Math.PI/18),a=[t];for(let t=1;t<=33;t++)this._rotateDirect(r,n,o),a.push(this._add(i,r));e.push(a);break}case ce.Ki.CoverageEdgesWithTicks:{const r=this._cp2(s,0,-1);let n,o;if(t>=3)n=s[2];else{const t=this._sub(r,i),e=this._leftPerp(t);n=[i[0]+e[0]-.25*t[0],i[1]+e[1]-.25*t[1]]}if(t>=4)o=s[3];else{const t=this._mid(i,r),e=this._sub(i,r);this._normalize(e),this._leftPerpendicular(e);const s=this._crossProduct(e,this._sub(n,t));this._rightPerpendicular(e),o=[n[0]+e[0]*s*2,n[1]+e[1]*s*2]}const a=this._sub(r,i);let h,c;h=this._crossProduct(a,this._sub(n,i))>0?this._rightPerp(a):this._leftPerp(a),c=[],c.push(n),c.push(i),c.push([i[0]+(h[0]-a[0])/3,i[1]+(h[1]-a[1])/3]),e.push(c),h=this._crossProduct(a,this._sub(o,r))>0?this._rightPerp(h):this._leftPerp(a),c=[],c.push([r[0]+(h[0]+a[0])/3,r[1]+(h[1]+a[1])/3]),c.push(r),c.push(o),e.push(c);break}case ce.Ki.GapExtentWithDoubleTicks:{const r=this._cp2(s,0,2),n=this._cp3(s,r,0,1);let o;if(t>=4)o=s[3];else{const t=this._sub(r,i);o=this._add(n,t)}this._addAngledTicks(e,i,r,this._mid(n,o)),this._addAngledTicks(e,n,o,this._mid(i,r));break}case ce.Ki.GapExtentMidline:{const r=this._cp2(s,2,0),n=this._cp3(s,r,0,1);let o;if(t>=4)o=s[3];else{const t=this._sub(r,i);o=this._add(n,t)}const a=[];a.push(this._mid(i,n)),a.push(this._mid(r,o)),e.push(a);break}case ce.Ki.Chevron:{const r=this._cp2(s,-1,-1);let n;if(t>=3)n=s[2];else{const t=this._sub(r,i);this._leftPerpendicular(t),n=this._add(i,t)}e.push([r,this._makeCtrlPt(i),n]);break}case ce.Ki.PerpendicularWithArc:{const t=this._cp2(s,0,-2),r=this._cp3(s,t,.5,-1);let n=this._sub(t,i);const o=this._norm(n);n[0]/=o,n[1]/=o;const a=this._crossProduct(n,this._sub(r,i));let h=this._dotProduct(n,this._sub(r,i));h<.05*o?h=.05*o:h>.95*o&&(h=.95*o);const c=[i[0]+n[0]*h,i[1]+n[1]*h];this._leftPerpendicular(n);let l=[];l.push([c[0]-n[0]*a,c[1]-n[1]*a]),l.push([c[0]+n[0]*a,c[1]+n[1]*a]),e.push(l);const u=[t[0]+n[0]*a,t[1]+n[1]*a];n=this._sub(t,u);const d=Math.cos(Math.PI/18);let p=Math.sin(Math.PI/18);a<0&&(p=-p),l=[i,t];for(let t=1;t<=9;t++)this._rotateDirect(n,d,p),l.push(this._add(u,n));e.push(l);break}case ce.Ki.ClosedHalfCircle:{const t=this._cp2(s,2,0),r=this._mid(i,t),n=this._sub(t,r),o=Math.cos(Math.PI/18),a=Math.sin(Math.PI/18),h=[i,t];for(let t=1;t<=18;t++)this._rotateDirect(n,o,a),h.push(this._add(r,n));e.push(h);break}case ce.Ki.TripleParallelExtended:{const t=this._cp2(s,0,-2),r=this._cp3(s,t,1,-2),n=this._mid(i,t),o=this._sub(r,t);this._normalize(o);const a=Math.abs(this._crossProduct(o,this._sub(n,t)))/2,h=this._dist(t,r),c=[t,i];c.push([i[0]+o[0]*h*.5,i[1]+o[1]*h*.5]),e.push(c);const l=[];l.push([n[0]-o[0]*a,n[1]-o[1]*a]),l.push([n[0]+o[0]*h*.375,n[1]+o[1]*h*.375]),oe(l[l.length-1],1),l.push([n[0]+o[0]*h*.75,n[1]+o[1]*h*.75]),e.push(l);const u=[t,r];e.push(u);break}case ce.Ki.ParallelWithTicks:{const t=this._cp2(s,3,0),r=this._cp3(s,t,.5,-1),n=this._sub(r,t);this._normalize(n);const o=this._crossProduct(n,this._sub(r,i));this._leftPerpendicular(n),this._addAngledTicks(e,i,t,r),this._addAngledTicks(e,this._mix(i,1,n,o),this._mix(t,1,n,o),this._mid(i,t));break}case ce.Ki.Parallel:{const t=this._cp2(s,3,0),r=this._cp3(s,t,.5,-1),n=this._sub(t,i);this._normalize(n);const o=this._leftPerp(n),a=this._crossProduct(n,this._sub(r,i));let h=[i,t];e.push(h),h=[],h.push([i[0]+o[0]*a,i[1]+o[1]*a]),h.push([t[0]+o[0]*a,t[1]+o[1]*a]),e.push(h);break}case ce.Ki.PerpendicularToFirstSegment:{const t=this._cp2(s,3,0),r=this._cp3(s,t,.5,-1),n=this._mid(i,t),o=this._sub(t,i);this._normalize(o);const a=this._crossProduct(o,this._sub(r,i));this._leftPerpendicular(o);const h=[];h.push([n[0]-o[0]*a*.25,n[1]-o[1]*a*.25]),h.push([n[0]+o[0]*a*1.25,n[1]+o[1]*a*1.25]),e.push(h);break}case ce.Ki.ParallelOffset:{const t=this._cp2(s,3,0),r=this._cp3(s,t,.5,-1),n=this._sub(t,i);this._normalize(n);const o=this._crossProduct(n,this._sub(r,i));this._leftPerpendicular(n);const a=[];a.push([i[0]-n[0]*o,i[1]-n[1]*o]),a.push([t[0]-n[0]*o,t[1]-n[1]*o]),e.push(a);const h=[];h.push([i[0]+n[0]*o,i[1]+n[1]*o]),h.push([t[0]+n[0]*o,t[1]+n[1]*o]),e.push(h);break}case ce.Ki.OffsetOpposite:{const t=this._cp2(s,3,0),r=this._cp3(s,t,.5,-1),n=this._sub(t,i);this._normalize(n);const o=this._crossProduct(n,this._sub(r,i));this._leftPerpendicular(n);const a=[];a.push([i[0]-n[0]*o,i[1]-n[1]*o]),a.push([t[0]-n[0]*o,t[1]-n[1]*o]),e.push(a);break}case ce.Ki.OffsetSame:{const t=this._cp2(s,3,0),r=this._cp3(s,t,.5,-1),n=this._sub(t,i);this._normalize(n);const o=this._crossProduct(n,this._sub(r,i));this._leftPerpendicular(n);const a=[];a.push([i[0]+n[0]*o,i[1]+n[1]*o]),a.push([t[0]+n[0]*o,t[1]+n[1]*o]),e.push(a);break}case ce.Ki.CircleWithArc:{let r=this._cp2(s,3,0);const n=this._cp3(s,r,.5,-1);let o,a;if(t>=4)o=s[3],a=this._crossProduct(this._sub(o,r),this._sub(n,r))>0;else{o=r,a=this._crossProduct(this._sub(o,i),this._sub(n,i))>0;const t=24*this._geomUnitsPerPoint,e=this._sub(o,i);this._normalize(e,t);const s=Math.sqrt(2)/2;this._rotateDirect(e,s,a?s:-s),r=this._add(i,e)}const h=this._sub(r,i),c=Math.cos(Math.PI/18),l=Math.sin(Math.PI/18),u=[r];for(let t=1;t<=36;t++)this._rotateDirect(h,c,l),u.push(this._add(i,h));this._add90DegArc(u,r,o,n,a),oe(u[u.length-8],1),e.push(u);break}case ce.Ki.DoubleJog:{let r,n,o=this._cp2(s,-3,1);if(r=t>=3?s[2]:this._add(i,this._sub(i,o)),t>=4)n=s[3];else{const t=i;i=o,n=r;const e=this._dist(i,t),s=this._dist(n,t);let a=30*this._geomUnitsPerPoint;.5*e<a&&(a=.5*e),.5*s<a&&(a=.5*s),o=this._mix(i,a/e,t,(e-a)/e),r=this._mix(n,a/s,t,(s-a)/s)}const a=this._mid(i,o),h=this._mid(n,r),c=this._dist(i,o),l=this._dist(r,n);let u=Math.min(c,l)/8;u=Math.min(u,24*this._geomUnitsPerPoint);const d=Math.cos(Math.PI/4);let p=this._sub(i,o);this._normalize(p,u),this._crossProduct(p,this._sub(n,o))>0?this._rotateDirect(p,d,-d):this._rotateDirect(p,d,d);let _=[];_.push(o),_.push(this._add(a,p)),_.push(this._sub(a,p)),_.push(i),e.push(_),p=this._sub(n,r),this._normalize(p,u),this._crossProduct(p,this._sub(i,r))<0?this._rotateDirect(p,d,d):this._rotateDirect(p,d,-d),_=[],_.push(r),_.push(this._add(h,p)),_.push(this._sub(h,p)),_.push(n),e.push(_);break}case ce.Ki.PerpendicularOffset:{const t=this._cp2(s,-4,1),r=this._cp3(s,t,.882353,-1.94),n=this._sub(r,t);this._crossProduct(n,this._sub(i,t))>0?this._rightPerpendicular(n):this._leftPerpendicular(n);const o=[n[0]/8,n[1]/8],a=this._sub(this._mid(t,r),o);e.push([a,i]);break}case ce.Ki.LineExcludingLastSegment:{const t=this._arrowPath(s),i=[];let r=t.length-2;for(;r--;)i.push(t[r]);e.push(i);break}case ce.Ki.MultivertexArrow:{const t=this._arrowPath(s),i=[];this._addArrow(i,t,!1),e.push(i);break}case ce.Ki.CrossedArrow:{const t=this._arrowPath(s),i=[];this._addArrow(i,t,!0),e.push(i);break}case ce.Ki.ChevronArrow:{const[t,r]=this._arrowLastSeg(s),n=10*this._geomUnitsPerPoint,o=this._sub(i,t);this._normalize(o);const a=this._crossProduct(o,this._sub(r,t)),h=this._leftPerp(o),c=[r[0]-h[0]*a*2,r[1]-h[1]*a*2],l=[];l.push([r[0]+o[0]*n,r[1]+o[1]*n]),l.push(i),l.push([c[0]+o[0]*n,c[1]+o[1]*n]),e.push(l);break}case ce.Ki.ChevronArrowOffset:{const[t,r]=this._arrowLastSeg(s),n=this._sub(i,t);this._normalize(n);const o=this._crossProduct(n,this._sub(r,t));this._leftPerpendicular(n);const a=[r[0]-n[0]*o,r[1]-n[1]*o],h=[];h.push([a[0]+n[0]*o*.5,a[1]+n[1]*o*.5]),h.push(this._mid(a,i)),h.push([a[0]-n[0]*o*.5,a[1]-n[1]*o*.5]),e.push(h);break}case ce.Ki.PartialFirstSegment:{const[t,r]=this._arrowLastSeg(s),n=this._sub(i,t);this._normalize(n);const o=this._crossProduct(n,this._sub(r,t));this._leftPerpendicular(n);const a=[r[0]-n[0]*o,r[1]-n[1]*o];e.push([t,a]);break}case ce.Ki.Arch:{const t=this._cp2(s,0,-1),r=this._cp3(s,t,.5,1),n=this._sub(i,t),o=this._mix(r,1,n,.55),a=this._mix(r,1,n,-.55),h=[i];this._addBezier2(h,i,o,r,4),this._addBezier2(h,r,a,t,4),e.push(h);break}case ce.Ki.CurvedParallelTicks:{const t=this._cp2(s,-4,1),r=this._cp3(s,t,.882353,-1.94),n=this._sub(r,t);this._crossProduct(n,this._sub(i,t))>0?this._rightPerpendicular(n):this._leftPerpendicular(n);const o=[n[0]/8,n[1]/8],a=this._sub(this._mid(t,r),o),h=this._sub(this._mix(t,.75,r,.25),o),c=this._sub(this._mix(t,.25,r,.75),o),l=[t];this._addBezier2(l,t,h,a,3),this._addBezier2(l,a,c,r,3),e.push(l);for(let t=0;t<8;t++){const s=l[2*t+1],i=[this._clone(s)];i.push(this._add(s,[n[0]/4,n[1]/4])),e.push(i)}break}case ce.Ki.Arc90Degrees:{const t=this._cp2(s,0,-1),r=this._cp3(s,t,.5,1),n=[t];this._add90DegArc(n,t,i,r),e.push(n);break}case ce.Ki.FullGeometry:default:e.push(s)}}return e}}class xe{static local(){return null===xe.instance&&(xe.instance=new xe),xe.instance}execute(t,e,s,i,r){return new be(t,e,s)}}xe.instance=null;class be extends he{constructor(t,e,s){super(t,!0,!0),this._curveHelper=new ue,this._beginCut=(void 0!==e.beginCut?e.beginCut:1)*s,this._endCut=(void 0!==e.endCut?e.endCut:1)*s,this._middleCut=(void 0!==e.middleCut?e.middleCut:0)*s,this._invert=void 0!==e.invert&&e.invert,this._beginCut<0&&(this._beginCut=0),this._endCut<0&&(this._endCut=0),this._middleCut<0&&(this._middleCut=0)}processPath(t){const{_beginCut:e,_endCut:s,_middleCut:i}=this,r=t.pathLength(),n=jt.createEmptyOptimizedCIM("esriGeometryPolyline");if(this._invert){if(0!==e||0!==s||0!==i)if(e+s+i>=r)for(n.startPath();t.nextPoint();)n.pushXY(t.x,t.y);else this._curveHelper.appendSubCurve(n,t,0,e),this._curveHelper.appendSubCurve(n,t,.5*(r-i),.5*(r+i)),this._curveHelper.appendSubCurve(n,t,r-s,s)}else if(0===e&&0===s&&0===i)for(n.startPath();t.nextPoint();)n.pushXY(t.x,t.y);else e+s+i<r&&(0===i?this._curveHelper.appendSubCurve(n,t,e,r-s):(this._curveHelper.appendSubCurve(n,t,e,.5*(r-i)),this._curveHelper.appendSubCurve(n,t,.5*(r+i),r-s)));return 0===n.totalSize?null:n}}class we{constructor(){this._values=[],this.extPtGap=0,this.ctrlPtGap=0,this._length=0,this._currentValue=0}isEmpty(){return 0===this._values.length}size(){return this._values.length}init(t,e,s=!0){if(this._setEmpty(),!t||0===t.length)return!1;for(let e=0;e<t.length;e++){let i=Math.abs(t[e]);s&&i<1e-7&&(i=1e-7),this._values.push(i),this._length+=i}return e&&1&t.length&&(this._length*=2),0!==this._length&&(this.ctrlPtGap=this.extPtGap=0,this._currentValue=-1,!0)}scale(t){const e=this._values?this._values.length:0;for(let s=0;s<e;++s)this._values[s]*=t;this._length*=t,this.extPtGap*=t,this.ctrlPtGap*=t}addValue(t){this._length+=t,this._values.push(t)}firstValue(){return this._values[0]}lastValue(){return this._values[this._values.length-1]}nextValue(){return this._currentValue++,this._currentValue===this._values.length&&(this._currentValue=0),this._values[this._currentValue]}reset(){this._currentValue=-1}length(){return this._length}_setEmpty(){this.extPtGap=this.ctrlPtGap=this._length=0,this._currentValue=-1,this._values.length=0}}class ve{constructor(){this.pt=null,this.ca=0,this.sa=0}}var Se,Ie;(Ie=Se||(Se={}))[Ie.FAIL=0]="FAIL",Ie[Ie.END=1]="END",Ie[Ie.CONTINUE=2]="CONTINUE";class Te{constructor(){this.reset()}reset(){this.segment=null,this.segmentLength=0,this.abscissa=0,this.isPathEnd=!1,this.isPartEnd=!1}isValid(){return null!==this.segment}copyTo(t){t.segment=this.segment,t.segmentLength=this.segmentLength,t.abscissa=this.abscissa,t.isPathEnd=this.isPathEnd,t.isPartEnd=this.isPartEnd}}class Pe extends ue{constructor(t=0,e=!1){super(t,e),this._tolerance=le,this._currentPosition=new Te}updateTolerance(t){this._tolerance=le*t}init(t,e,s=!0){return s?(this._patternLength=e.length(),this._partExtPtGap=e.extPtGap,this._partCtrlPtGap=e.ctrlPtGap):(this._patternLength=0,this._partExtPtGap=0,this._partCtrlPtGap=0),this._currentPosition.reset(),this._partSegCount=0,this._pathCursor=t,this._seg=-1,this._setPosAtNextPart()}curPositionIsValid(){return this._currentPosition.isValid()}nextPosition(t,e=Se.FAIL){const s=new Te;return!!this._nextPosition(t,s,null,e)&&(s.copyTo(this._currentPosition),!0)}curPointAndAngle(t){t.pt=this._getPoint(this._currentPosition);const[e,s]=this._getAngleCS(this._currentPosition);t.ca=e,t.sa=s}nextPointAndAngle(t,e,s=Se.FAIL){const i=new Te;if(!this._nextPosition(t,i,null,s))return!1;i.copyTo(this._currentPosition),e.pt=this._getPoint(i);const[r,n]=this._getAngleCS(i);return e.ca=r,e.sa=n,!0}nextCurve(t){if(0===t)return null;const e=jt.createEmptyOptimizedCIM("esriGeometryPolyline");e.startPath(),e.nextPath();const s=new Te;return this._nextPosition(t,s,e,Se.END)?(s.copyTo(this._currentPosition),e):null}isPathEnd(){return this._currentPosition.isPathEnd}getPathEnd(){return this._currentPosition.segment[1]}getPt(t){return this._pathCursor.seekInPath(t),[this._pathCursor.x,this._pathCursor.y]}getSeg(t){return[this.getPt(t),this.getPt(t+1)]}_nextPosition(t,e,s,i){if(this._currentPosition.isPathEnd)return!1;let r=this._currentPosition.abscissa;for(this._currentPosition.segmentLength>0&&(r/=this._currentPosition.segmentLength),this._currentPosition.copyTo(e);e.abscissa+t*this._partLengthRatio>e.segmentLength+this._tolerance;){if(s){if(0===s.pathSize)if(0===r){const t=e.segment[0];s.pushXY(t[0],t[1])}else s.pushPoint(this.getSegCoord2D(e.segment,r));const t=e.segment[1];s.pushXY(t[0],t[1])}if(r=0,t-=(e.segmentLength-e.abscissa)/this._partLengthRatio,this._partSegCount)e.segment=this._nextSegment(),e.segmentLength=this.getSegLength(e.segment),e.abscissa=0,this._partSegCount--;else{if(!this._setPosAtNextPart())return i!==Se.FAIL&&(e.segmentLength=this.getSegLength(e.segment),e.isPartEnd=!0,i===Se.END?(e.abscissa=e.segmentLength,e.isPathEnd=!0):e.abscissa=e.segmentLength+t,!0);this._currentPosition.copyTo(e)}}if(e.abscissa+=t*this._partLengthRatio,s){0===s.pathSize&&(0===r?s.pushPoint(e.segment[0]):s.pushPoint(this.getSegCoord2D(e.segment,r)));const t=e.abscissa/e.segmentLength;1===t?s.pushPoint(e.segment[1]):s.pushPoint(this.getSegCoord2D(e.segment,t))}return this._partSegCount||Math.abs(e.abscissa-e.segmentLength)<this._tolerance&&(e.isPathEnd=this._partIsLast,e.isPartEnd=!0),!0}_getPoint(t){const e=t.segmentLength<=0?0:t.abscissa/t.segmentLength;return this.getSegCoord2D(this._currentPosition.segment,e)}_getAngleCS(t){const e=t.segmentLength<=0?0:t.abscissa/t.segmentLength;return this.getSegAngleCS(this._currentPosition.segment,e)}_setPosAtNextPart(){for(;this._partSegCount;)this._hasNextSegment()&&this._nextSegment(),this._partSegCount--;if(!this._hasNextSegment())return!1;for(this._partLength=0,this._partIsLast=!0,this._partSegCount=0;this._hasNextSegment();)if(this._partLength+=this.getSegLength(this._nextSegment()),this._partSegCount++,this._pathCursor.getControlPointAt(this._getEndPointIndex())){this._partIsLast=!this._hasNextSegment();break}let t=this._partSegCount;for(;t;)this._previousSegment(),--t;this._currentPosition.segment=this._nextSegment(),this._currentPosition.segmentLength=this.getSegLength(this._currentPosition.segment),this._currentPosition.abscissa=0,this._currentPosition.isPathEnd=this._currentPosition.isPartEnd=!1,--this._partSegCount;const e=this._getStartPointIndex();this._ctrlPtBegin=this._pathCursor.getControlPointAt(e);let s=e+this._partSegCount+1;if(s>=this._pathCursor.pathSize&&(s=0),this._ctrlPtEnd=this._pathCursor.getControlPointAt(s),this._patternLength>0){const t=this._ctrlPtBegin?this._partCtrlPtGap:this._partExtPtGap,e=this._ctrlPtEnd?this._partCtrlPtGap:this._partExtPtGap;let s=Math.round((this._partLength-(t+e))/this._patternLength);s<=0&&(s=t+e>0?0:1),this._partLengthRatio=this._partLength/(t+e+s*this._patternLength),this._partLengthRatio<.01&&(this._partLengthRatio=1)}else this._partLengthRatio=1;return!0}_hasNextSegment(){return this._seg<this._pathCursor.pathSize-2}_previousSegment(){return this.getSeg(--this._seg)}_nextSegment(){return this.getSeg(++this._seg)}_getStartPointIndex(){return this._seg}_getEndPointIndex(){return this._seg+1}}var Me=s(14624);class Ee{static local(){return null===Ee.instance&&(Ee.instance=new Ee),Ee.instance}execute(t,e,s,i,r){return new Ce(t,e,s)}}Ee.instance=null;class Ce extends he{constructor(t,e,s){super(t,!0,!0),this._firstCurve=null,this._walker=new Pe,this._walker.updateTolerance(s),this._endings=e.lineDashEnding,this._customDashPos=-(e.offsetAlongLine??0)*s,this._offsetAtEnd=(e.customEndingOffset??0)*s,this._pattern=new we,this._pattern.init((0,Me.Wy)(e).dashTemplate,!0),this._pattern.scale(s)}processPath(t){if(0===this._pattern.length()){this.iteratePath=!1;const e=(0,Xt.g)(t);return jt.fromJSONCIM({paths:[e]})}if(!this.iteratePath){let e=!0;switch(this._endings){case ce.Gi.HalfPattern:case ce.Gi.HalfGap:default:this._pattern.extPtGap=0;break;case ce.Gi.FullPattern:this.isClosed||(this._pattern.extPtGap=.5*this._pattern.firstValue());break;case ce.Gi.FullGap:this.isClosed||(this._pattern.extPtGap=.5*this._pattern.lastValue());break;case ce.Gi.NoConstraint:this.isClosed||(e=!1);break;case ce.Gi.Custom:this.isClosed||(this._pattern.extPtGap=.5*this._offsetAtEnd)}const s=t.pathLength();if(this._pattern.isEmpty()||s<.1*this._pattern.length()){const e=(0,Xt.g)(t);return jt.fromJSONCIM({paths:[e]})}if(!this._walker.init(t,this._pattern,e)){const e=(0,Xt.g)(t);return jt.fromJSONCIM({paths:[e]})}}let e;if(this.iteratePath)e=this._pattern.nextValue();else{let t;switch(this._endings){case ce.Gi.HalfPattern:default:t=.5*this._pattern.firstValue();break;case ce.Gi.HalfGap:t=.5*-this._pattern.lastValue();break;case ce.Gi.FullGap:t=-this._pattern.lastValue();break;case ce.Gi.FullPattern:t=0;break;case ce.Gi.NoConstraint:case ce.Gi.Custom:t=-this._customDashPos}let s=t/this._pattern.length();s-=Math.floor(s),t=s*this._pattern.length(),this._pattern.reset(),e=this._pattern.nextValue();let i=!1;for(;t>=e;)t-=e,e=this._pattern.nextValue(),i=!i;e-=t,i?(this._walker.nextPosition(e),e=this._pattern.nextValue()):this.isClosed&&(this._firstCurve=this._walker.nextCurve(e),e=this._pattern.nextValue(),this._walker.nextPosition(e),e=this._pattern.nextValue())}let s=this._walker.nextCurve(e);if(s)if(this._walker.isPathEnd()){if(this.iteratePath=!1,this._firstCurve){for(this._firstCurve.nextPath();this._firstCurve.nextPoint();)s.pushXY(this._firstCurve.x,this._firstCurve.y);this._firstCurve=null}}else e=this._pattern.nextValue(),!this._walker.nextPosition(e)||this._walker.isPathEnd()?(this.iteratePath=!1,this._firstCurve&&(s.pushCursor(this._firstCurve),this._firstCurve=null)):this.iteratePath=!0;else this.iteratePath=!1,s=this._firstCurve,this._firstCurve=null;return s?.reset(),s}}class ke{static local(){return null===ke.instance&&(ke.instance=new ke),ke.instance}execute(t,e,s,i,r,n){return new Fe(t,e,s,i,r,n)}}ke.instance=null;class Fe{constructor(t,e,s,i,r,n){switch(this._inputGeometries=t,this._tileKey=i,this._geometryEngine=r,this._maxInflateSize=n*s,this._width=(void 0!==e.width?e.width:2)*s,e.method){case ce.Q9.Mitered:case ce.Q9.Bevelled:case ce.Q9.Rounded:case ce.Q9.TrueBuffer:case ce.Q9.Square:}this._option=e.option}next(){let t;for(;t=this._inputGeometries.next();){if("esriGeometryEnvelope"===t.geometryType&&this._width>0){const e=t.asJSON();return Math.min(e.xmax-e.xmin,e.ymax-e.ymin)-2*this._width<0?t:jt.fromJSONCIM({paths:[[[e.xmin+this._width,e.ymin+this._width],[e.xmax-this._width,e.ymin+this._width],[e.xmax-this._width,e.ymax-this._width],[e.xmin+this._width,e.ymax-this._width],[e.xmin+this._width,e.ymin+this._width]],[[e.xmin,e.ymin],[e.xmin,e.ymax],[e.xmax,e.ymax],[e.xmax,e.ymin],[e.xmin,e.ymin]]]})}if("esriGeometryPolygon"===t.geometryType){if(0===this._width)return t.clone();const e=this._geometryEngine;if(null==e)return null;const s=this._tileKey?se(t,this._maxInflateSize):t.clone();if(!s)continue;const i=e.buffer(V.c.WebMercator,s.asJSON(),-this._width,1);if(i)for(const t of i.rings)if(t){s.startPath();for(const e of t.reverse())s.pushXY(e[0],s.yFactor*e[1])}return s}}return null}}class Ae{static local(){return null===Ae.instance&&(Ae.instance=new Ae),Ae.instance}execute(t,e,s,i,r){return new Re(t,e,s)}}Ae.instance=null;class Re extends he{constructor(t,e,s){super(t,!1,!0),this._curveHelper=new ue,this._length=(void 0!==e.length?e.length:20)*s,this._angle=void 0!==e.angle?e.angle:225,this._position=void 0!==e.position?e.position:50,this._length<0&&(this._length=-this._length),this._position<20&&(this._position=20),this._position>80&&(this._position=80),this._mirror=!1}processPath(t){const e=jt.createEmptyOptimizedCIM("esriGeometryPolyline");if(this._curveHelper.isEmpty(t))return null;t.seekInPath(0);const s=t.x,i=t.y;t.seekInPath(t.pathSize-1);const r=t.x,n=t.y,o=[r-s,n-i];this._curveHelper.normalize(o);const a=s+(r-s)*this._position/100,h=i+(n-i)*this._position/100,c=Math.cos((90-this._angle)/180*Math.PI);let l=Math.sin((90-this._angle)/180*Math.PI);this._mirror&&(l=-l),this._mirror=!this._mirror;const u=[a-this._length/2*c,h-this._length/2*l],d=[a+this._length/2*c,h+this._length/2*l];return e.pushPath([[s,i],u,d,[r,n]]),e}}class Oe{static local(){return null===Oe.instance&&(Oe.instance=new Oe),Oe.instance}execute(t,e,s,i,r){return new Ne(t,e,s)}}Oe.instance=null;class Ne{constructor(t,e,s){this._inputGeometries=t,this._offsetX=void 0!==e.offsetX?e.offsetX*s:0,this._offsetY=void 0!==e.offsetY?e.offsetY*s:0}next(){let t=this._inputGeometries.next();for(;t;){if(t.totalSize>0)return this._move(t.clone(),this._offsetX,this._offsetY);t=this._inputGeometries.next()}return null}_move(t,e,s){for(;t.nextPath();)for(;t.nextPoint();)t.x=t.x+e,t.y=t.y+s;return t.reset(),t}}class De{static local(){return null===De.instance&&(De.instance=new De),De.instance}execute(t,e,s,i,r,n){return new ze(t,e,s,i,r,n)}}De.instance=null;class ze{constructor(t,e,s,i,r,n){this._inputGeometries=t,this._tileKey=i,this._geometryEngine=r,this._curveHelper=new ue,this._offset=(e.offset??1)*s,this._method=e.method,this._maxInflateSize=Math.max(Math.abs(n*s),10),this._option=e.option,this._offsetFlattenError=le*s}next(){let t;for(;t=this._inputGeometries.next();){if(0===this._offset)return t.clone();if("esriGeometryEnvelope"===t.geometryType){if(this._method===ce.yM.Rounded&&this._offset>0){const e=(0,Xt.g)(t),s=this._curveHelper.offset(e,-this._offset,this._method,4,this._offsetFlattenError);if(s){const e=jt.createEmptyOptimizedCIM(t.geometryType);return e.pushPath(s),e}return null}const e=t.asJSON();if((0,Yt.Ul)(e)&&Math.min(e.xmax-e.xmin,e.ymax-e.ymin)+2*this._offset>0)return jt.fromJSONCIM({xmin:e.xmin-this._offset,xmax:e.xmax+this._offset,ymin:e.ymin-this._offset,ymax:e.ymax+this._offset})}const e=this._geometryEngine;if(null==e)continue;const s=this._tileKey?se(t,this._maxInflateSize):t.clone();if(!s)continue;const i=e.offset(V.c.WebMercator,s.asJSON(),-this._offset,1,this._method,4,this._offsetFlattenError);return i?jt.fromJSONCIM(i):null}return null}}class Le{static local(){return null===Le.instance&&(Le.instance=new Le),Le.instance}execute(t,e,s,i,r){return new Be(t,e,s)}}Le.instance=null;class Be{constructor(t,e,s){this._inputGeometries=t,this._reverse=void 0===e.reverse||e.reverse}next(){let t=this._inputGeometries.next();for(;t;){if(!this._reverse)return t;if("esriGeometryPolyline"===t.geometryType)return Ue(t.clone());t=this._inputGeometries.next()}return null}}function Ue(t){for(;t.nextPath();)for(let e=0;e<t.pathSize/2;e++){t.seekInPath(e);const s=t.x,i=t.y;t.seekInPath(t.pathSize-e-1);const r=t.x,n=t.y;t.x=s,t.y=i,t.seekInPath(e),t.x=r,t.y=n}return t.reset(),t}var Ge=s(33008);class Ve{static local(){return null===Ve.instance&&(Ve.instance=new Ve),Ve.instance}execute(t,e,s,i,r){return new qe(t,e,s)}}Ve.instance=null;class qe{constructor(t,e,s){this._inputGeometries=t,this._rotateAngle=void 0!==e.angle?e.angle*Math.PI/180:0}next(){let t=this._inputGeometries.next();for(;t;){if(0===this._rotateAngle||"esriGeometryPoint"===t.geometryType)return t;if(t.totalSize>0){const e=(0,Ge.IV)(t),s=(e[2]+e[0])/2,i=(e[3]+e[1])/2;return t.reset(),this._rotate(t.clone(),s,i)}t=this._inputGeometries.next()}return null}_rotate(t,e,s){const i=Math.cos(this._rotateAngle),r=Math.sin(this._rotateAngle);for(;t.nextPath();)for(;t.nextPoint();){const n=t.x-e,o=t.y-s;t.x=e+n*i-o*r,t.y=s+n*r+o*i}return t.reset(),t}}class We{static local(){return null===We.instance&&(We.instance=new We),We.instance}execute(t,e,s,i,r){return new Xe(t,e,s)}}We.instance=null;class Xe{constructor(t,e,s){this._inputGeometries=t,this._xFactor=void 0!==e.XScaleFactor?e.XScaleFactor:1.15,this._yFactor=void 0!==e.YScaleFactor?e.YScaleFactor:1.15}next(){const t=this._inputGeometries.next();if(t){if(1===this._xFactor&&1===this._yFactor)return t;if("esriGeometryPoint"===t.geometryType)return t;if(t.totalSize>0){const e=(0,Ge.IV)(t),s=(e[2]+e[0])/2,i=(e[3]+e[1])/2;return t.reset(),this._scaleCursor(t.clone(),s,i)}}return null}_scaleCursor(t,e,s){for(;t.nextPath();)for(;t.nextPoint();)t.x=e+(t.x-e)*this._xFactor,t.y=s+(t.y-s)*this._yFactor;return t.reset(),t}}class Ye{static local(){return null===Ye.instance&&(Ye.instance=new Ye),Ye.instance}execute(t,e,s,i,r){return new je(t,e,s)}}Ye.instance=null;class je{constructor(t,e,s){this._inputGeometries=t,this._height=(void 0!==e.amplitude?e.amplitude:2)*s,this._period=(void 0!==e.period?e.period:3)*s,this._style=e.waveform,this._height<=0&&(this._height=Math.abs(this._height)),this._period<=0&&(this._period=Math.abs(this._period)),this._pattern=new we,this._pattern.addValue(this._period),this._pattern.addValue(this._period),this._walker=new Pe,this._walker.updateTolerance(s)}next(){let t=this._inputGeometries.next();for(;t;){if(0===this._height||0===this._period)return t;const e=this._processGeom(t);if(e)return e;t=this._inputGeometries.next()}return null}_processGeom(t){const e=jt.createEmptyOptimizedCIM(t.geometryType);for(;t.nextPath();){e.startPath();const s=t.pathLength();if(this._walker.init(t,this._pattern))switch(this._style){case ce.y2.Sinus:default:this._constructCurve(e,s,!1);break;case ce.y2.Square:this._constructSquare(e,s);break;case ce.y2.Triangle:this._constructTriangle(e,s);break;case ce.y2.Random:this._constructCurve(e,s,!0)}else for(;t.nextPoint();)e.pushXY(t.x,t.y)}return e}_constructCurve(t,e,s){let i=Math.round(e/this._period);0===i&&(i=1);const r=16*i+1,n=e/i,o=this._period/16,a=1/r,h=2*Math.PI*e/n,c=2*Math.PI*Math.random(),l=2*Math.PI*Math.random(),u=2*Math.PI*Math.random(),d=.75-Math.random()/2,p=.75-Math.random()/2,_=new ve;this._walker.curPointAndAngle(_),t.pushPoint(_.pt);let f=0;for(;;){if(!this._walker.nextPointAndAngle(o,_)){t.pushPoint(this._walker.getPathEnd());break}{const e=f;let i;if(f+=a,s){const t=this._height/2*(1+.3*Math.sin(d*h*e+c));i=t*Math.sin(h*e+l),i+=t*Math.sin(p*h*e+u),i/=2}else i=.5*this._height*Math.sin(.5*h*e);t.pushXY(_.pt[0]-i*_.sa,_.pt[1]+i*_.ca)}}}_constructSquare(t,e){Math.round(e/this._period);let s=!0;for(;;){let e=!1;if(this._walker.curPositionIsValid()){const i=new ve;this._walker.curPointAndAngle(i);const r=new ve;if(this._walker.nextPointAndAngle(this._period,r)){const n=new ve;this._walker.nextPointAndAngle(this._period,n)&&(s?(t.pushPoint(i.pt),s=!1):t.pushPoint(i.pt),t.pushXY(i.pt[0]-this._height/2*i.sa,i.pt[1]+this._height/2*i.ca),t.pushXY(r.pt[0]-this._height/2*r.sa,r.pt[1]+this._height/2*r.ca),t.pushXY(r.pt[0]+this._height/2*r.sa,r.pt[1]-this._height/2*r.ca),t.pushXY(n.pt[0]+this._height/2*n.sa,n.pt[1]-this._height/2*n.ca),e=!0)}}if(!e){t.pushPoint(this._walker.getPathEnd());break}}}_constructTriangle(t,e){Math.round(e/this._period);let s=!0;for(;;){let e=!1;if(this._walker.curPositionIsValid()){const i=new ve;this._walker.curPointAndAngle(i);const r=new ve;if(this._walker.nextPointAndAngle(this._period/2,r)){const n=new ve;this._walker.nextPointAndAngle(this._period,n)&&(this._walker.nextPosition(this._period/2)&&(s?(t.pushPoint(i.pt),s=!1):t.pushPoint(i.pt),t.pushXY(r.pt[0]-this._height/2*r.sa,r.pt[1]+this._height/2*r.ca),t.pushXY(n.pt[0]+this._height/2*n.sa,n.pt[1]-this._height/2*n.ca)),e=!0)}}if(!e){t.pushPoint(this._walker.getPathEnd());break}}}}class He{static local(){return null===He.instance&&(He.instance=new He),He.instance}execute(t,e,s,i,r){return new $e(t,e,s)}}He.instance=null;class $e extends ae{constructor(t,e,s){super(t),this._geometryWalker=new Pe,this._geometryWalker.updateTolerance(s),this._angleToLine=e.angleToLine??!0,this._offset=(e.offset?e.offset:0)*s,this._originalEndings=e.endings,this._offsetAtEnd=(e.customEndingOffset?e.customEndingOffset:0)*s,this._position=-(e.offsetAlongLine?e.offsetAlongLine:0)*s,this._pattern=new we,this._pattern.init(e.placementTemplate,!1),this._pattern.scale(s),this._endings=this._originalEndings}processPath(t){if(this._pattern.isEmpty())return null;let e;if(this.iteratePath)e=this._pattern.nextValue();else{this._originalEndings===ce.AZ.WithFullGap&&this.isClosed?this._endings=ce.AZ.WithMarkers:this._endings=this._originalEndings,this._pattern.extPtGap=0;let s,i=!0;switch(this._endings){case ce.AZ.NoConstraint:s=-this._position,s=this._adjustPosition(s),i=!1;break;case ce.AZ.WithHalfGap:default:s=-this._pattern.lastValue()/2;break;case ce.AZ.WithFullGap:s=-this._pattern.lastValue(),this._pattern.extPtGap=this._pattern.lastValue();break;case ce.AZ.WithMarkers:s=0;break;case ce.AZ.Custom:s=-this._position,s=this._adjustPosition(s),this._pattern.extPtGap=.5*this._offsetAtEnd}if(!this._geometryWalker.init(t,this._pattern,i))return null;this._pattern.reset();let r=0;for(;s>r;)s-=r,r=this._pattern.nextValue();r-=s,e=r,this.iteratePath=!0}const s=new ve;return this._geometryWalker.nextPointAndAngle(e,s)?this._endings===ce.AZ.WithFullGap&&this._geometryWalker.isPathEnd()?(this.iteratePath=!1,null):this._endings===ce.AZ.WithMarkers&&this._geometryWalker.isPathEnd()&&(this.iteratePath=!1,this.isClosed)?null:(this.internalPlacement.setTranslate(s.pt[0]-this._offset*s.sa,s.pt[1]+this._offset*s.ca),this._angleToLine&&this.internalPlacement.setRotateCS(s.ca,s.sa),this.internalPlacement):(this.iteratePath=!1,null)}_adjustPosition(t){let e=t/this._pattern.length();return e-=Math.floor(e),e*this._pattern.length()}}class Ke{static local(){return null===Ke.instance&&(Ke.instance=new Ke),Ke.instance}execute(t,e,s,i,r){return new Ze(t,e,s)}}Ke.instance=null;class Ze extends ae{constructor(t,e,s){super(t,!1,!0),this._curveHelper=new ue,this._angleToLine=void 0===e.angleToLine||e.angleToLine,this._offset=void 0!==e.offset?e.offset*s:0,this._type=e.extremityPlacement,this._position=void 0!==e.offsetAlongLine?e.offsetAlongLine*s:0,this._beginProcessed=!1}processPath(t){let e;switch(this._type){case ce.G6.Both:default:this._beginProcessed?(e=this._atExtremities(t,this._position,!1),this._beginProcessed=!1,this.iteratePath=!1):(e=this._atExtremities(t,this._position,!0),this._beginProcessed=!0,this.iteratePath=!0);break;case ce.G6.JustBegin:e=this._atExtremities(t,this._position,!0);break;case ce.G6.JustEnd:e=this._atExtremities(t,this._position,!1);case ce.G6.None:}return e}_atExtremities(t,e,s){if(s||t.seekPathEnd(),s?t.nextPoint():t.prevPoint()){let i=0,[r,n]=[0,0],[o,a]=[t.x,t.y];for(;s?t.nextPoint():t.prevPoint();){r=o,n=a,o=t.x,a=t.y;const s=this._curveHelper.getLength(r,n,o,a);if(i+s>e){const t=(e-i)/s,[h,c]=this._curveHelper.getAngleCS(r,n,o,a,t),l=this._curveHelper.getCoord2D(r,n,o,a,t);return this.internalPlacement.setTranslate(l[0]-this._offset*c,l[1]+this._offset*h),this._angleToLine&&this.internalPlacement.setRotateCS(-h,-c),this.internalPlacement}i+=s}}return null}}class Qe{static local(){return null===Qe.instance&&(Qe.instance=new Qe),Qe.instance}execute(t,e,s,i,r){return new Je(t,e,s)}}Qe.instance=null;class Je extends ae{constructor(t,e,s){super(t),this._walker=new Pe,this._walker.updateTolerance(s),this._angleToLine=void 0===e.angleToLine||e.angleToLine,this._offset=void 0!==e.offset?e.offset*s:0,this._beginGap=void 0!==e.beginPosition?e.beginPosition*s:0,this._endGap=void 0!==e.endPosition?e.endPosition*s:0,this._flipFirst=void 0===e.flipFirst||e.flipFirst,this._pattern=new we,this._pattern.init(e.positionArray,!1,!1),this._subPathLen=0,this._posCount=this._pattern.size(),this._isFirst=!0,this._prevPos=0}processPath(t){if(this._pattern.isEmpty())return null;let e;if(this.iteratePath){const t=this._pattern.nextValue()*this._subPathLen,s=this._beginGap+t;e=s-this._prevPos,this._prevPos=s}else{if(this._posCount=this._pattern.size(),this._isFirst=!0,this._prevPos=0,this._subPathLen=t.pathLength()-this._beginGap-this._endGap,this._subPathLen<0)return this.iteratePath=!1,null;if(!this._walker.init(t,this._pattern,!1))return null;this._pattern.reset();const s=this._pattern.nextValue()*this._subPathLen,i=this._beginGap+s;e=i-this._prevPos,this._prevPos=i,this.iteratePath=!0}const s=new ve;if(!this._walker.nextPointAndAngle(e,s,Se.END))return this.iteratePath=!1,null;this.internalPlacement.setTranslate(s.pt[0]-this._offset*s.sa,s.pt[1]+this._offset*s.ca);const i=this._isFirst&&this._flipFirst;let r,n;return this._angleToLine?(r=s.ca,n=s.sa):(r=1,n=0),i&&(r=-r,n=-n),this.internalPlacement.setRotateCS(r,n),this._isFirst=!1,this._posCount--,0===this._posCount&&(this.iteratePath=!1),this.internalPlacement}}const ts=512,es=24,ss=1e-6;class is{static local(){return null===is.instance&&(is.instance=new is),is.instance}execute(t,e,s,i,r){return new rs(t,e,s,i,r)}}is.instance=null;class rs{constructor(t,e,s,i,r){if(this._xMin=0,this._xMax=0,this._yMin=0,this._yMax=0,this._currentX=0,this._currentY=0,this._accelerationMap=null,this._testInsidePolygon=!1,this._verticalSubdivision=!0,this._stepX=Math.abs(e.stepX??16)*s,this._stepY=Math.abs(e.stepY??16)*s,this._stepX=Math.round(128*this._stepX)/128,this._stepY=Math.round(128*this._stepY)/128,0!==this._stepX&&0!==this._stepY){if(this._gridType=e.gridType??ce.sP.Fixed,this._gridType===ce.sP.Random){const t=e.seed??13,s=1;this._randomLCG=new h.c(t*s),this._randomness=(e.randomness??100)/100,this._gridAngle=0,this._shiftOddRows=!1,this._cosAngle=1,this._sinAngle=0,this._offsetX=0,this._offsetY=0,this._buildRandomValues()}else{if(this._randomness=0,this._gridAngle=e.gridAngle??0,this._shiftOddRows=e.shiftOddRows??!1,this._offsetX=(e.offsetX??0)*s,this._offsetY=(e.offsetY??0)*s,this._cosAngle=Math.cos(this._gridAngle/180*Math.PI),this._sinAngle=-Math.sin(this._gridAngle/180*Math.PI),this._stepX)if(this._offsetX<0)for(;this._offsetX<-.5*this._stepX;)this._offsetX+=this._stepX;else for(;this._offsetX>=.5*this._stepX;)this._offsetX-=this._stepX;if(this._stepY)if(this._offsetY<0)for(;this._offsetY<-.5*this._stepY;)this._offsetY+=this._stepY;else for(;this._offsetY>=.5*this._stepY;)this._offsetY-=this._stepY}if(this._graphicOriginX=0,this._graphicOriginY=0,null!=i){const[t,e,s,r]=i.split("/"),n=parseFloat(t),o=parseFloat(e),a=parseFloat(s),h=parseFloat(r);this._graphicOriginX=-(h*2**n+a)*ts,this._graphicOriginY=o*ts,this._testInsidePolygon=!0}this._internalPlacement=new ne,this._calculateMinMax(t),this._geometryCursor=t}}next(){return this._geometryCursor?this._nextInside():null}_buildRandomValues(){if(!rs._randValues){rs._randValues=[];for(let t=0;t<es;t++)for(let t=0;t<es;t++)rs._randValues.push(this._randomLCG.getFloat()),rs._randValues.push(this._randomLCG.getFloat())}}_calculateMinMax(t){let e,s,i,r,n,o,a,h,c,l,u,d,p,_;this._xMin=0,this._xMax=0,this._yMin=0,this._yMax=0,a=h=p=u=Number.MAX_VALUE,c=l=_=d=-Number.MAX_VALUE;const f=1!==this._cosAngle;for(t.reset();t.nextPath();)for(;t.nextPoint();)o=t.x,n=t.y,e=o-this._graphicOriginX-this._offsetX,s=n-this._graphicOriginY-this._offsetY,f?(i=this._cosAngle*e-this._sinAngle*s,r=this._sinAngle*e+this._cosAngle*s):(i=e,r=s),a=Math.min(a,i),c=Math.max(c,i),h=Math.min(h,r),l=Math.max(l,r),u=Math.min(u,n),d=Math.max(d,n),p=Math.min(p,o),_=Math.max(_,o);u=u!==Number.MAX_VALUE?u:-512-this._stepY,d=d!==-Number.MAX_VALUE?d:this._stepY,p=p!==Number.MAX_VALUE?p:-this._stepX,_=_!==-Number.MAX_VALUE?_:ts+this._stepX;const m=d-u,g=_-p;if(this._verticalSubdivision=m>=g,this._polygonMin=this._verticalSubdivision?u:p,this._testInsidePolygon){let t=0-this._graphicOriginX-this._offsetX-this._stepX,e=ts-this._graphicOriginX-this._offsetX+this._stepX,s=-512-this._graphicOriginY-this._offsetY-this._stepY,i=0-this._graphicOriginY-this._offsetY+this._stepY;if(f){const r=[[t,s],[t,i],[e,s],[e,i]];t=s=Number.MAX_VALUE,e=i=-Number.MAX_VALUE;for(const n of r){const r=this._cosAngle*n[0]-this._sinAngle*n[1],o=this._sinAngle*n[0]+this._cosAngle*n[1];t=Math.min(t,r),e=Math.max(e,r),s=Math.min(s,o),i=Math.max(i,o)}}a=a!==Number.MAX_VALUE?Math.max(a,t):t,h=h!==Number.MAX_VALUE?Math.max(h,s):s,c=c!==-Number.MAX_VALUE?Math.min(c,e):e,l=l!==-Number.MAX_VALUE?Math.min(l,i):i}this._xMin=Math.round(a/this._stepX),this._xMax=Math.round(c/this._stepX),this._yMin=Math.round(h/this._stepY),this._yMax=Math.round(l/this._stepY),this._currentX=this._xMax+1,this._currentY=this._yMin-1,this._buildAccelerationMap(t,p,_,u,d)}_buildAccelerationMap(t,e,s,i,r){t.reset();const n=new Map,o=this._verticalSubdivision,a=o?r-i:s-e;let h=Math.ceil(a/10);if(h<=1)return;const c=Math.floor(a/h);let l,u,d,p,_,f,m,g,y,x,b;for(h++,this._delta=c,o?(y=-512-2*this._stepY,x=2*this._stepY,b=i):(y=-2*this._stepX,x=ts+2*this._stepX,b=e);t.nextPath();)if(!(t.pathSize<2)&&t.nextPoint())for(l=t.x,u=t.y;t.nextPoint();l=d,u=p){if(d=t.x,p=t.y,o){if(u===p||u<y&&p<y||u>x&&p>x)continue;_=Math.min(u,p),f=Math.max(u,p)}else{if(l===d||l<y&&d<y||l>x&&d>x)continue;_=Math.min(l,d),f=Math.max(l,d)}for(;_<f;)m=Math.floor((_-b)/c),ns(m,l,u,d,p,n),_+=c;g=Math.floor((f-b)/c),g>m&&ns(g,l,u,d,p,n)}this._accelerationMap=n}_nextInside(){for(;;){if(this._currentX>this._xMax){if(this._currentY++,this._currentY>this._yMax)return null;this._currentX=this._xMin,this._shiftOddRows&&this._currentY%2&&this._currentX--}let t=this._currentX*this._stepX+this._offsetX;this._shiftOddRows&&this._currentY%2&&(t+=.5*this._stepX);const e=this._currentY*this._stepY+this._offsetY;let s,i;if(this._currentX++,this._gridType===ce.sP.Random){const r=(this._currentX%es+es)%es,n=(this._currentY%es+es)%es;s=this._graphicOriginX+t+this._stepX*this._randomness*(.5-rs._randValues[n*es+r])*2/3,i=this._graphicOriginY+e+this._stepY*this._randomness*(.5-rs._randValues[n*es+r+1])*2/3}else s=this._graphicOriginX+this._cosAngle*t+this._sinAngle*e,i=this._graphicOriginY-this._sinAngle*t+this._cosAngle*e;if(!this._testInsidePolygon||this._isInsidePolygon(s,i,this._geometryCursor))return this._internalPlacement.setTranslate(s,i),this._internalPlacement}}_isInsidePolygon(t,e,s){if(null==this._accelerationMap)return function(t,e,s){let i,r,n,o,a=0;for(t+=ss,e+=ss,s.reset();s.nextPath();)if(s.nextPoint())for(i=s.x,r=s.y;s.nextPoint();i=n,r=o)n=s.x,o=s.y,r>e!=o>e&&((n-i)*(e-r)-(o-r)*(t-i)>0?a++:a--);return 0!==a}(t,e,s);t+=ss,e+=ss;const i=this._verticalSubdivision,r=i?e:t,n=Math.floor((r-this._polygonMin)/this._delta),o=this._accelerationMap.get(n);if(!o)return!1;let a,h,c,l=0;for(const s of o){if(a=s[0],h=s[1],i){if(a[1]>e==h[1]>e)continue;c=(h[0]-a[0])*(e-a[1])-(h[1]-a[1])*(t-a[0])}else{if(a[0]>t==h[0]>t)continue;c=(h[1]-a[1])*(t-a[0])-(h[0]-a[0])*(e-a[1])}c>0?l++:l--}return 0!==l}}function ns(t,e,s,i,r,n){let o=n.get(t);o||(o=[],n.set(t,o)),o.push([[e,s],[i,r]])}class os{static local(){return null===os.instance&&(os.instance=new os),os.instance}execute(t,e,s,i,r){return new as(t,e,s)}}os.instance=null;class as extends ae{constructor(t,e,s){super(t),this._curveHelper=new ue,this._angleToLine=void 0===e.angleToLine||e.angleToLine,this._offset=void 0!==e.offset?e.offset*s:0,this._relativeTo=e.relativeTo,this._position=void 0!==e.startPointOffset?e.startPointOffset*s:0,this._epsilon=.001*s}processPath(t){const e=this._position;if(this._relativeTo===ce.IJ.SegmentMidpoint){if(this.iteratePath||(this.iteratePath=!0),t.nextPoint()){let[e,s]=[t.x,t.y],[i,r]=[0,0];for(;t.nextPoint();){i=t.x,r=t.y;const n=this._curveHelper.getLength(e,s,i,r);if(n<this._epsilon){e=i,s=r;continue}const o=.5+this._position/n,[a,h]=this._curveHelper.getAngleCS(e,s,i,r,o),c=this._curveHelper.getCoord2D(e,s,i,r,o);return this.internalPlacement.setTranslate(c[0]-this._offset*h,c[1]+this._offset*a),this._angleToLine&&this.internalPlacement.setRotateCS(a,h),this.internalPlacement}}return this.iteratePath=!1,null}const s=this._relativeTo===ce.IJ.LineEnd;return this.onLine(t,e,s)}onLine(t,e,s){let i,r=!1;switch(this._relativeTo){case ce.IJ.LineMiddle:default:t.seekPathStart(),i=t.pathLength()/2+e;break;case ce.IJ.LineBeginning:i=e;break;case ce.IJ.LineEnd:i=e,r=!0}s?t.seekPathEnd():t.seekPathStart();let n=0;if(s?t.prevPoint():t.nextPoint()){let[e,o]=[t.x,t.y],[a,h]=[0,0];for(;s?t.prevPoint():t.nextPoint();){a=t.x,h=t.y;const s=this._curveHelper.getLength(e,o,a,h);if(n+s>i){const t=(i-n)/s,[c,l]=this._curveHelper.getAngleCS(e,o,a,h,t),u=this._curveHelper.getCoord2D(e,o,a,h,t),d=r?-this._offset:this._offset;return this.internalPlacement.setTranslate(u[0]-d*l,u[1]+d*c),this._angleToLine&&(r?this.internalPlacement.setRotateCS(-c,-l):this.internalPlacement.setRotateCS(c,l)),this.internalPlacement}e=a,o=h,n+=s}}return null}}class hs{static local(){return null===hs.instance&&(hs.instance=new hs),hs.instance}execute(t,e,s,i,r){return new cs(t,e,s)}}hs.instance=null;class cs extends ae{constructor(t,e,s){super(t),this._curveHelper=new ue,this._angleToLine=void 0===e.angleToLine||e.angleToLine,this._offset=void 0!==e.offset?e.offset*s:0,this._endPoints=void 0===e.placeOnEndPoints||e.placeOnEndPoints,this._controlPoints=void 0===e.placeOnControlPoints||e.placeOnControlPoints,this._regularVertices=void 0===e.placeOnRegularVertices||e.placeOnRegularVertices,this._tags=[],this._tagIterator=0}processPath(t){if(this.iteratePath||(this._preparePath(t),this.iteratePath=!0),this._tagIterator>=this._tags.length)return this._tags.length=0,this._tagIterator=0,this.iteratePath=!1,null;const e=this._tags[this._tagIterator];this._angleToLine&&this.internalPlacement.setRotate(e[2]);let s=e[0],i=e[1];if(0!==this._offset){const t=Math.cos(e[2]),r=Math.sin(e[2]);s-=this._offset*r,i+=this._offset*t}return this.internalPlacement.setTranslate(s,i),this._tagIterator++,this.internalPlacement}_preparePath(t){this._tags.length=0,this._tagIterator=0,t.seekPathStart();const e=t.isClosed();let s=0,i=!1,r=0,n=0;if(t.seekPathStart(),t.nextPoint()){let o=t.x,a=t.y,h=t.getControlPoint(),c=!0,l=t.nextPoint();for(;l;){const u=t.x,d=t.y,p=t.getControlPoint();(this._angleToLine||0!==this._offset)&&(r=this._curveHelper.getAngle(o,a,u,d,0)),c?(c=!1,e?(s=r,i=h):(this._endPoints||this._controlPoints&&h)&&this._tags.push([o,a,r])):h?this._controlPoints&&this._tags.push([o,a,ls(n,r)]):this._regularVertices&&this._tags.push([o,a,ls(n,r)]),(this._angleToLine||0!==this._offset)&&(n=this._curveHelper.getAngle(o,a,u,d,1)),l=t.nextPoint(),l||(e?p||i?this._controlPoints&&this._tags.push([u,d,ls(n,s)]):this._regularVertices&&this._tags.push([u,d,ls(n,s)]):(this._endPoints||this._controlPoints&&p)&&this._tags.push([u,d,n])),o=u,a=d,h=p}}this._tagIterator=0}}function ls(t,e){const s=Math.PI;for(;Math.abs(e-t)>s+2e-15;)e-t>s?e-=2*s:e+=2*s;return(t+e)/2}var us=s(95788),ds=s(47452),ps=s(41980);function _s(t){if(0===t.totalSize)return null;const e=(0,Ge.IV)(t);if(!e)return null;const s=4*(Math.abs(e[0])+Math.abs(e[2])+Math.abs(e[1])+Math.abs(e[3])+1)*222045e-19;let i=0,r=0;t.reset();for(let e=0;t.nextPath();e++){const s=t.getCurrentRingArea();s>r&&(r=s,i=e)}if(t.seekPath(i),0===t.pathSize)return null;t.seekPathStart();const n=(0,Ge.yC)(t);if(Math.abs(r)<=2*s*s)return[(n[0]+n[2])/2,(n[1]+n[3])/2];t.seekPathStart();const o=(0,us.$c)(t,(0,L.Su)());if(null===o)return null;if(t.totalPoints<4)return o;const a=[[NaN,NaN],[NaN,NaN],[NaN,NaN],[NaN,NaN]],h=[NaN,NaN,NaN,NaN],c=[NaN,NaN,NaN,NaN];let l=!1,u=ms(o,t,!0);0===u.distance&&(l=!0,a[0][0]=o[0],a[0][1]=o[1],u=ms(o,t,!1)),h[0]=u.distance,c[0]=0;const d=[NaN,NaN];let p=!1,_=.25,f=-1,m=NaN;do{if(m=NaN,a[1]=gs(t,Ts(n[0],n[2],_),0,e),isNaN(a[1][0])||isNaN(a[1][1])||(u=ms(a[1],t,!1),m=u.distance),!isNaN(m)&&m>s&&fs(a[1],t))p=!0,h[1]=m,c[1]=Ps(a[1],o);else if(!isNaN(m)&&m>f&&(f=m,d[0]=a[1][0],d[1]=a[1][1]),_-=.01,_<.1){if(!(f>=0))break;p=!0,h[1]=f,a[1][0]=d[0],a[1][1]=d[1],c[1]=Ps(a[1],o)}}while(!p);p=!1,_=.5,f=-1;let g=.01,y=1;do{if(m=NaN,a[2]=gs(t,Ts(n[0],n[2],_),0,e),isNaN(a[2][0])||isNaN(a[2][1])||(u=ms(a[2],t,!1),m=u.distance),!isNaN(m)&&m>s&&fs(a[2],t))p=!0,h[2]=m,c[2]=Ps(a[2],o);else if(!isNaN(m)&&m>f)f=m,d[0]=a[2][0],d[1]=a[2][1];else if(m>f&&(f=m,d[0]=a[2][0],d[1]=a[2][1]),_=.5+g*y,g+=.01,y*=-1,_<.3||_>.7){if(!(f>=0))break;p=!0,h[2]=f,a[2][0]=d[0],a[2][1]=d[1],c[2]=Ps(a[2],o)}}while(!p);p=!1,_=.75,f=-1;do{if(m=NaN,a[3]=gs(t,Ts(n[0],n[2],_),0,e),isNaN(a[3][0])||isNaN(a[3][1])||(u=ms(a[3],t,!1),m=u.distance),!isNaN(m)&&m>s&&fs(a[3],t))p=!0,h[3]=m,c[3]=Ps(a[3],o);else if(m>f&&(f=m,d[0]=a[3][0],d[1]=a[3][1]),_+=.01,_>.9){if(!(f>=0))break;p=!0,h[3]=f,a[3][0]=d[0],a[3][1]=d[1],c[3]=Ps(a[3],o)}}while(!p);const x=[0,1,2,3],b=l?0:1;let w;for(let t=b;t<4;t++)for(let t=b;t<3;t++){const e=c[t],s=c[t+1];Ms(e,s)>0&&(w=x[t],x[t]=x[t+1],x[t+1]=w,c[t]=s,c[t+1]=e)}let v=b,S=0,I=0;for(let t=b;t<4;t++){switch(t){case 0:I=2*h[x[t]];break;case 1:I=1.66666666*h[x[t]];break;case 2:I=1.33333333*h[x[t]];break;case 3:I=h[x[t]]}I>S&&(S=I,v=x[t])}return a[v]}function fs(t,e){let s,i,r,n,o=0;for(e.reset();e.nextPath()&&e.nextPoint();)for(s=e.x,i=e.y;e.nextPoint();s=r,i=n)r=e.x,n=e.y,i>t[1]!=n>t[1]&&((r-s)*(t[1]-i)-(n-i)*(t[0]-s)>0?o++:o--);return 0!==o}function ms(t,e,s){if(s&&fs(t,e))return{coord:t,distance:0};let i=1/0,r=0,n=0,o=[0,0],a=[0,0];const h=[0,0];for(e.reset();e.nextPath()&&e.nextPoint();)if(!(e.pathSize<2))for(o[0]=e.x,o[1]=e.y;e.nextPoint();o=a){a=[e.x,e.y],(0,ds.ym)(h,t,o,a);const s=Ps(t,h);s<i&&(i=s,r=h[0],n=h[1])}return{coord:[r,n],distance:Math.sqrt(i)}}function gs(t,e,s,i){const r=[e,0];let n=1/0,o=1/0,a=!1,h=!1;const c=[[e,i[1]-1],[e,i[3]+1]],l=[0,0],u=[0,0],d=[0,0],p=[[0,0],[0,0]],_=(0,L.Su)();for(t.reset();t.nextPath()&&t.nextPoint();)if(!(t.pathSize<2))for(p[0][0]=t.x,p[0][1]=t.y;t.nextPoint();p[0][0]=p[1][0],p[0][1]=p[1][1]){if(p[1][0]=t.x,p[1][1]=t.y,null===ys(_,p))continue;if(u[0]=c[0][0],u[1]=c[0][1],d[0]=c[1][0],d[1]=c[1][1],0===Ss(_,u,d))continue;if(!(0,ps.qm)(c[0],c[1],p[0],p[1],l))continue;const e=l[1];n>o?e<n&&(n=e,a=!0):e<o&&(o=e,h=!0)}return a&&h?r[1]=(n+o)/2:r[0]=r[1]=NaN,r}function ys(t,e){if(e.length<2)return null;t||(t=(0,L.Su)());const[s,i]=e[0],[r,n]=e[1];return t[0]=Math.min(s,r),t[1]=Math.min(i,n),t[2]=Math.max(s,r),t[3]=Math.max(i,n),t}const xs=1,bs=4,ws=3,vs=12;function Ss(t,e,s){let i=Is(e,t),r=Is(s,t);const n=t[0],o=t[1],a=t[2],h=t[3];if(i&r)return 0;if(!(i|r))return 4;const c=(i?1:0)|(r?2:0);do{const c=s[0]-e[0],l=s[1]-e[1];if(c>l)i&ws?(i&xs?(e[1]+=l*(n-e[0])/c,e[0]=n):(e[1]+=l*(a-e[0])/c,e[0]=a),i=Is(e,t)):r&ws?(r&xs?(s[1]+=l*(n-s[0])/c,s[0]=n):(s[1]+=l*(a-s[0])/c,s[0]=a),r=Is(s,t)):i?(i&bs?(e[0]+=c*(o-e[1])/l,e[1]=o):(e[0]+=c*(h-e[1])/l,e[1]=h),i=Is(e,t)):(r&bs?(s[0]+=c*(o-s[1])/l,s[1]=o):(s[0]+=c*(h-s[1])/l,s[1]=h),r=Is(s,t));else if(i&vs?(i&bs?(e[0]+=c*(o-e[1])/l,e[1]=o):(e[0]+=c*(h-e[1])/l,e[1]=h),i=Is(e,t)):r&vs?(r&bs?(s[0]+=c*(o-s[1])/l,s[1]=o):(s[0]+=c*(h-s[1])/l,s[1]=h),r=Is(s,t)):i?(i&xs?(e[1]+=l*(n-e[0])/c,e[0]=n):(e[1]+=l*(a-e[0])/c,e[0]=a),i=Is(e,t)):(r&xs?(s[1]+=l*(n-s[0])/c,s[0]=n):(s[1]+=l*(a-s[0])/c,s[0]=a),r=Is(s,t)),i&r)return 0}while(i|r);return c}function Is(t,e){return(t[0]<e[0]?1:0)|(t[0]>e[2]?1:0)<<1|(t[1]<e[1]?1:0)<<2|(t[1]>e[3]?1:0)<<3}function Ts(t,e,s){return t+(e-t)*s}function Ps(t,e){return(t[0]-e[0])*(t[0]-e[0])+(t[1]-e[1])*(t[1]-e[1])}function Ms(t,e){if(t<e)return-1;if(t>e)return 1;if(t===e)return 0;const s=isNaN(t),i=isNaN(e);return s<i?-1:s>i?1:0}class Es{static local(){return null===Es.instance&&(Es.instance=new Es),Es.instance}execute(t,e,s,i,r){return new Cs(t,e,s)}}Es.instance=null;class Cs{constructor(t,e,s){this._geometryCursor=t,this._offsetX=void 0!==e.offsetX?e.offsetX*s:0,this._offsetY=void 0!==e.offsetY?e.offsetY*s:0,this._method=void 0!==e.method?e.method:ce.ms.OnPolygon,this._internalPlacement=new ne}next(){const t=this._geometryCursor;return this._geometryCursor=null,t?this._polygonCenter(t):null}_polygonCenter(t){let e=!1;switch(this._method){case ce.ms.CenterOfMass:{const s=(0,us.iy)(t);s&&(this._internalPlacement.setTranslate(s[0]+this._offsetX,s[1]+this._offsetY),e=!0)}break;case ce.ms.BoundingBoxCenter:{const s=(0,Ge.IV)(t);s&&(this._internalPlacement.setTranslate((s[2]+s[0])/2+this._offsetX,(s[3]+s[1])/2+this._offsetY),e=!0)}break;case ce.ms.OnPolygon:default:{const s=_s(t);null!==s&&(this._internalPlacement.setTranslate(s[0]+this._offsetX,s[1]+this._offsetY),e=!0)}}return e?this._internalPlacement:null}}function ks(t){if(!t)return null;switch(t.type){case"CIMGeometricEffectAddControlPoints":return ie.local();case"CIMGeometricEffectArrow":return pe.local();case"CIMGeometricEffectBuffer":return fe.local();case"CIMGeometricEffectControlMeasureLine":return ge.local();case"CIMGeometricEffectCut":return xe.local();case"CIMGeometricEffectDashes":return Ee.local();case"CIMGeometricEffectDonut":return ke.local();case"CIMGeometricEffectJog":return Ae.local();case"CIMGeometricEffectMove":return Oe.local();case"CIMGeometricEffectOffset":return De.local();case"CIMGeometricEffectReverse":return Le.local();case"CIMGeometricEffectRotate":return Ve.local();case"CIMGeometricEffectScale":return We.local();case"CIMGeometricEffectWave":return Ye.local()}return null}new(s(60024).c),s(73771),s(6220),new Map,new Set,s(60536),s(39056);var Fs=s(47364);function As(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t[4]=0,t[5]=0,t}function Rs(t,e,s){const i=e[0],r=e[1],n=e[2],o=e[3],a=e[4],h=e[5],c=s[0],l=s[1],u=s[2],d=s[3],p=s[4],_=s[5];return t[0]=i*c+n*l,t[1]=r*c+o*l,t[2]=i*u+n*d,t[3]=r*u+o*d,t[4]=i*p+n*_+a,t[5]=r*p+o*_+h,t}function Os(t,e,s){const i=e[0],r=e[1],n=e[2],o=e[3],a=e[4],h=e[5],c=Math.sin(s),l=Math.cos(s);return t[0]=i*l+n*c,t[1]=r*l+o*c,t[2]=i*-c+n*l,t[3]=r*-c+o*l,t[4]=a,t[5]=h,t}function Ns(t,e,s){const i=e[0],r=e[1],n=e[2],o=e[3],a=e[4],h=e[5],c=s[0],l=s[1];return t[0]=i,t[1]=r,t[2]=n,t[3]=o,t[4]=i*c+n*l+a,t[5]=r*c+o*l+h,t}function Ds(t,e){const s=Math.sin(e),i=Math.cos(e);return t[0]=i,t[1]=s,t[2]=-s,t[3]=i,t[4]=0,t[5]=0,t}function zs(t,e,s){return t[0]=e[0]-s[0],t[1]=e[1]-s[1],t[2]=e[2]-s[2],t[3]=e[3]-s[3],t[4]=e[4]-s[4],t[5]=e[5]-s[5],t}const Ls=Rs,Bs=zs;function Us(){const t=new Float32Array(6);return t[0]=1,t[3]=1,t}function Gs(t,e,s,i){const r=e[i],n=e[i+1];t[i]=s[0]*r+s[2]*n+s[4],t[i+1]=s[1]*r+s[3]*n+s[5]}function Vs(t,e,s,i=0,r=0,n=2){const o=r||e.length/n;for(let r=i;r<o;r++)Gs(t,e,s,r*n)}Object.freeze(Object.defineProperty({__proto__:null,add:function(t,e,s){return t[0]=e[0]+s[0],t[1]=e[1]+s[1],t[2]=e[2]+s[2],t[3]=e[3]+s[3],t[4]=e[4]+s[4],t[5]=e[5]+s[5],t},copy:function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t},determinant:function(t){return t[0]*t[3]-t[1]*t[2]},equals:function(t,e){const s=t[0],i=t[1],r=t[2],n=t[3],o=t[4],a=t[5],h=e[0],c=e[1],l=e[2],u=e[3],d=e[4],p=e[5],_=(0,Fs.Au)();return Math.abs(s-h)<=_*Math.max(1,Math.abs(s),Math.abs(h))&&Math.abs(i-c)<=_*Math.max(1,Math.abs(i),Math.abs(c))&&Math.abs(r-l)<=_*Math.max(1,Math.abs(r),Math.abs(l))&&Math.abs(n-u)<=_*Math.max(1,Math.abs(n),Math.abs(u))&&Math.abs(o-d)<=_*Math.max(1,Math.abs(o),Math.abs(d))&&Math.abs(a-p)<=_*Math.max(1,Math.abs(a),Math.abs(p))},exactEquals:function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]},frob:function(t){return Math.sqrt(t[0]**2+t[1]**2+t[2]**2+t[3]**2+t[4]**2+t[5]**2+1)},fromRotation:Ds,fromScaling:function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=e[1],t[4]=0,t[5]=0,t},fromTranslation:function(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t[4]=e[0],t[5]=e[1],t},identity:As,invert:function(t,e){const s=e[0],i=e[1],r=e[2],n=e[3],o=e[4],a=e[5];let h=s*n-i*r;return h?(h=1/h,t[0]=n*h,t[1]=-i*h,t[2]=-r*h,t[3]=s*h,t[4]=(r*a-n*o)*h,t[5]=(i*o-s*a)*h,t):null},mul:Ls,multiply:Rs,multiplyScalar:function(t,e,s){return t[0]=e[0]*s,t[1]=e[1]*s,t[2]=e[2]*s,t[3]=e[3]*s,t[4]=e[4]*s,t[5]=e[5]*s,t},multiplyScalarAndAdd:function(t,e,s,i){return t[0]=e[0]+s[0]*i,t[1]=e[1]+s[1]*i,t[2]=e[2]+s[2]*i,t[3]=e[3]+s[3]*i,t[4]=e[4]+s[4]*i,t[5]=e[5]+s[5]*i,t},rotate:Os,scale:function(t,e,s){const i=e[0],r=e[1],n=e[2],o=e[3],a=e[4],h=e[5],c=s[0],l=s[1];return t[0]=i*c,t[1]=r*c,t[2]=n*l,t[3]=o*l,t[4]=a,t[5]=h,t},set:function(t,e,s,i,r,n,o){return t[0]=e,t[1]=s,t[2]=i,t[3]=r,t[4]=n,t[5]=o,t},str:function(t){return"mat2d("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+")"},sub:Bs,subtract:zs,translate:Ns},Symbol.toStringTag,{value:"Module"})),Object.freeze(Object.defineProperty({__proto__:null,clone:function(t){const e=new Float32Array(6);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e},create:Us,createView:function(t,e){return new Float32Array(t,e,6)},fromValues:function(t,e,s,i,r,n){const o=new Float32Array(6);return o[0]=t,o[1]=e,o[2]=s,o[3]=i,o[4]=r,o[5]=n,o},transform:Gs,transformMany:Vs},Symbol.toStringTag,{value:"Module"}));var qs=s(38600);const Ws=()=>C.c.getLogger("geoscene.views.2d.engine.webgl.alignmentUtils");var Xs,Ys,js;function Hs(t){if(!t)return Xs.Center;switch(t){case"Left":case"left":return Xs.Left;case"Right":case"right":return Xs.Right;case"Justify":return Ws().warnOnce("Horizontal alignment 'justify' is not implemented. Falling back to 'center'."),Xs.Center;case"Center":case"center":return Xs.Center}}function $s(t){if(!t)return Ys.Center;switch(t){case"Top":case"top":return Ys.Top;case"Center":case"middle":return Ys.Center;case"Baseline":case"baseline":return Ys.Baseline;case"Bottom":case"bottom":return Ys.Bottom}}(js=Xs||(Xs={}))[js.Left=-1]="Left",js[js.Center=0]="Center",js[js.Right=1]="Right",function(t){t[t.Top=1]="Top",t[t.Center=0]="Center",t[t.Bottom=-1]="Bottom",t[t.Baseline=2]="Baseline"}(Ys||(Ys={}));var Ks=s(27364);class Zs{constructor(t,e,s,i){this.computedX=0,this.computedY=0,this.center=(0,qs.WK)(t,e),this.centerT=(0,qs.Su)(),this.halfWidth=s/2,this.halfHeight=i/2,this.width=s,this.height=i}get x(){return this.center[0]}get y(){return this.center[1]}get blX(){return this.center[0]+this.halfWidth}get blY(){return this.center[1]+this.halfHeight}get trX(){return this.center[0]-this.halfWidth}get trY(){return this.center[1]-this.halfHeight}get xmin(){return this.x-this.halfWidth}get xmax(){return this.x+this.halfWidth}get ymin(){return this.y-this.halfHeight}get ymax(){return this.y+this.halfHeight}set x(t){this.center[0]=t}set y(t){this.center[1]=t}clone(){return new Zs(this.x,this.y,this.width,this.height)}serialize(t){return t.writeF32(this.center[0]),t.writeF32(this.center[1]),t.push(this.width),t.push(this.height),t}findCollisionDelta(t,e=4){const s=Math.abs(t.centerT[0]-this.centerT[0]),i=Math.abs(t.centerT[1]-this.centerT[1]),r=(t.halfWidth+this.halfWidth+e)/s,n=(t.halfHeight+this.halfHeight+e)/i,o=Math.min(r,n);return Math.log2(o)}extend(t){const e=Math.min(this.xmin,t.xmin),s=Math.min(this.ymin,t.ymin),i=Math.max(this.xmax,t.xmax)-e,r=Math.max(this.ymax,t.ymax)-s,n=e+i/2,o=s+r/2;this.width=i,this.height=r,this.halfWidth=i/2,this.halfHeight=r/2,this.x=n,this.y=o}static deserialize(t){const e=t.readF32(),s=t.readF32(),i=t.readInt32(),r=t.readInt32();return new Zs(e,s,i,r)}}const Qs=Math.PI/180;class Js{constructor(t,e,s,i){this._rotationT=Us(),this._xBounds=0,this._yBounds=0,this.minZoom=0,this.maxZoom=255,this._bounds=null;const r=s.rect,n=new Float32Array(8);t*=i,e*=i;const o=s.code?r.width*i:s.metrics.width,a=s.code?r.height*i:s.metrics.height;this.width=o,this.height=a,n[0]=t,n[1]=e,n[2]=t+o,n[3]=e,n[4]=t,n[5]=e+a,n[6]=t+o,n[7]=e+a,this._data=n,this._setTextureCoords(r),this._scale=i,this._mosaic=s,this.x=t,this.y=e,this.maxOffset=Math.max(t+o,e+a)}get mosaic(){return this._mosaic}set angle(t){this._angle=t,Ds(this._rotationT,-t),this._setOffsets()}get angle(){return this._angle}get xTopLeft(){return this._data[0]}get yTopLeft(){return this._data[1]}get xBottomRight(){return this._data[6]}get yBottomRight(){return this._data[7]}get texcoords(){return this._texcoords}get textureBinding(){return this._mosaic.textureBinding}get offsets(){return this._offsets||this._setOffsets(),this._offsets}get char(){return String.fromCharCode(this._mosaic.code)}get code(){return this._mosaic.code}get bounds(){if(!this._bounds){const{height:t,width:e}=this._mosaic.metrics,s=e*this._scale,i=Math.abs(t)*this._scale,r=new Float32Array(8);r[0]=this.x,r[1]=this.y,r[2]=this.x+s,r[3]=this.y,r[4]=this.x,r[5]=this.y+i,r[6]=this.x+s,r[7]=this.y+i,Vs(r,r,Rs(Us(),this._rotationT,this._transform));let n=1/0,o=1/0,a=0,h=0;for(let t=0;t<4;t++){const e=r[2*t],s=r[2*t+1];n=Math.min(n,e),o=Math.min(o,s),a=Math.max(a,e),h=Math.max(h,s)}const c=a-n,l=h-o,u=n+c/2,d=o+l/2;this._bounds=new Zs(u,d,c,l)}return this._bounds}setTransform(t){this._transform=t,this._offsets=null}_setOffsets(){this._offsets||(this._offsets={topLeft:[0,0],topRight:[0,0],bottomLeft:[0,0],bottomRight:[0,0]});const t=Rs(Us(),this._rotationT,this._transform);this._offsets.topLeft[0]=this._data[0],this._offsets.topLeft[1]=this._data[1],this._offsets.topRight[0]=this._data[2],this._offsets.topRight[1]=this._data[3],this._offsets.bottomLeft[0]=this._data[4],this._offsets.bottomLeft[1]=this._data[5],this._offsets.bottomRight[0]=this._data[6],this._offsets.bottomRight[1]=this._data[7],(0,F.m4)(this._offsets.topLeft,this._offsets.topLeft,t),(0,F.m4)(this._offsets.topRight,this._offsets.topRight,t),(0,F.m4)(this._offsets.bottomLeft,this._offsets.bottomLeft,t),(0,F.m4)(this._offsets.bottomRight,this._offsets.bottomRight,t)}_setTextureCoords({x:t,y:e,width:s,height:i}){this._texcoords={topLeft:[t,e],topRight:[t+s,e],bottomLeft:[t,e+i],bottomRight:[t+s,e+i]}}}const ti=(t,e)=>({code:0,page:0,sdf:!0,rect:new Ks.c(0,0,11,8),textureBinding:e,metrics:{advance:0,height:4,width:t,left:0,top:0}});function ei(t,e){return t.forEach((t=>(0,F.m4)(t,t,e))),{topLeft:t[0],topRight:t[1],bottomLeft:t[2],bottomRight:t[3]}}class si{constructor(t,e,s){this._rotation=0,this._decorate(t,e,s),this.glyphs=t,this.bounds=this._createBounds(t),this.isMultiline=e.length>1,this._hasRotation=0!==s.angle,this._transform=this._createGlyphTransform(this.bounds,s),this._borderLineSizePx=s.borderLineSizePx,(s.borderLineSizePx||s.hasBackground)&&([this.bounds,this.textBox]=this.shapeBackground(this._transform));for(const e of t)e.setTransform(this._transform)}setRotation(t){if(0===t&&0===this._rotation)return;this._rotation=t;const e=this._transform;Rs(e,Ds(Us(),t),e);for(const t of this.glyphs)t.setTransform(this._transform)}_decorate(t,e,s){if(!s.decoration||"none"===s.decoration||!t.length)return;const i=s.scale,r="underline"===s.decoration?26:16,n=t[0].textureBinding;for(const s of e){const e=s.startX*i,o=s.startY*i,a=(s.width+s.glyphWidthEnd)*i;t.push(new Js(e,o+r*i,ti(a,n),1))}}shapeBackground(t){const e=(1.5+(this._borderLineSizePx||0))/2,s=this._borderLineSizePx?e:0,{xmin:i,ymin:r,xmax:n,ymax:o,x:a,y:h,width:c,height:l}=this.bounds,u=[i-8,r-8],d=[n+8,r-8],p=[i-8,o+8],_=[n+8,o+8],f=ei([[u[0]-e,u[1]-e],[d[0]+e,d[1]-e],[u[0]+s,u[1]+s],[d[0]-s,d[1]+s]],t),m=ei([[p[0]+s,p[1]-s],[_[0]-s,_[1]-s],[p[0]-e,p[1]+e],[_[0]+e,_[1]+e]],t),g=ei([[u[0]-e,u[1]-e],[u[0]+s,u[1]+s],[p[0]-e,p[1]+e],[p[0]+s,p[1]-s]],t),y=ei([[d[0]-s,d[1]+s],[d[0]+e,d[1]-e],[_[0]-s,_[1]-s],[_[0]+e,_[1]+e]],t),x={main:ei([u,d,p,_],t),top:f,bot:m,left:g,right:y};return[new Zs(a,h,c+2*e,l+2*e),x]}get boundsT(){const t=this.bounds,e=(0,F.WO)((0,qs.Su)(),t.x,t.y);if((0,F.m4)(e,e,this._transform),this._hasRotation){const s=Math.max(t.width,t.height);return new Zs(e[0],e[1],s,s)}return new Zs(e[0],e[1],t.width,t.height)}_createBounds(t){let e=1/0,s=1/0,i=0,r=0;for(const n of t)e=Math.min(e,n.xTopLeft),s=Math.min(s,n.yTopLeft),i=Math.max(i,n.xBottomRight),r=Math.max(r,n.yBottomRight);const n=i-e,o=r-s;return new Zs(e+n/2,s+o/2,n,o)}_createGlyphTransform(t,e){const s=Qs*e.angle,i=Us(),r=(0,qs.Su)();return Ns(i,i,(0,F.WO)(r,e.xOffset,-e.yOffset)),e.useCIMAngleBehavior?Os(i,i,s):(Ns(i,i,(0,F.WO)(r,t.x,t.y)),Os(i,i,s),Ns(i,i,(0,F.WO)(r,-t.x,-t.y))),i}}class ii{constructor(t,e,s,i,r,n){this.glyphWidthEnd=0,this.startX=0,this.startY=0,this.start=Math.max(0,Math.min(e,s)),this.end=Math.max(0,Math.max(e,s)),this.end<t.length&&(this.glyphWidthEnd=t[this.end].metrics.width),this.width=i,this.yMin=r,this.yMax=n}}const ri=t=>10===t,ni=t=>32===t;Math.PI,s(45704);var oi=s(51760);function ai(t){if(!t)return 0;switch(t.type){case"CIMGeometricEffectArrow":return Math.abs(.5*t.width);case"CIMGeometricEffectBuffer":return Math.abs(t.size);case"CIMGeometricEffectExtension":case"CIMGeometricEffectRadial":return Math.abs(t.length);case"CIMGeometricEffectJog":return Math.abs(.5*t.length);case"CIMGeometricEffectMove":return Math.max(Math.abs((0,Me.uc)(t.offsetX)),Math.abs((0,Me.uc)(t.offsetY)));case"CIMGeometricEffectOffset":case"CIMGeometricEffectOffsetTangent":return Math.abs(t.offset);case"CIMGeometricEffectRegularPolygon":return Math.abs(t.radius);case"CIMGeometricEffectRotate":case"CIMGeometricEffectScale":default:return 0;case"CIMGeometricEffectTaperedPolygon":return.5*Math.max(Math.abs(t.fromWidth),Math.abs(t.toWidth));case"CIMGeometricEffectWave":return Math.abs(t.amplitude);case"CIMGeometricEffectDonut":return Math.abs(t.width)}}function hi(t){if(!t)return 0;let e=0;for(const s of t)e+=ai(s);return e}Math.PI,Math.PI;class ci{static executeEffects(t,e,s,i){const r=hi(t);let n=new ee(e);for(const e of t){const t=ks(e);t&&(n=t.execute(n,e,1.3333333333333333,s,i,r))}return n}static applyEffects(t,e,s){if(!t)return e;const i=hi(t);let r,n=new ee(jt.fromJSONCIM(e));for(const e of t){const t=ks(e);t&&(n=t.execute(n,e,1,null,s,i))}const o=[];let a=null;for(;r=n.next();)o.push(...(0,Xt.k)(r)),a=r.geometryType;return 0===o.length||null===a?null:"esriGeometryPolygon"===a?{rings:o}:{paths:o}}}let li=null;function ui(){return li}const di=new Float32Array(1);new Uint32Array(di.buffer);var pi=s(77800);function _i(t){switch(t){case pi.Ck.BYTE:case pi.Ck.UNSIGNED_BYTE:return 1;case pi.Ck.SHORT:case pi.Ck.UNSIGNED_SHORT:return 2;case pi.Ck.FLOAT:case pi.Ck.INT:case pi.Ck.UNSIGNED_INT:return 4}}class fi{static fromVertexSpec({attributes:t},e){let s,i,r;const n=[];for(const o in t){const a=t[o];!1!==e?.[o]&&("position"===a.pack?s={...a,name:o,offset:0}:"id"===a.pack?i={...a,name:o,offset:4}:"bitset"===o?r={...a,name:o,offset:7}:n.push({...a,name:o}))}const o=function(t){const e=[],s=[],i=[];for(const r of t){const t=_i(r.type)*r.count;switch(t%2||t%4||4){case 4:e.push(r);continue;case 2:s.push(r);continue;case 1:i.push(r);continue;default:throw new Error("Found unexpected dataType byte count")}}return e.push(...s),e.push(...i),e}(n),a=[];let h=8,c=1;for(const t of o)a.push({...t,offset:h}),h+=_i(t.type)*t.count,t.packAlternating&&(c=Math.max(t.packAlternating.count,c));const l=Uint32Array.BYTES_PER_ELEMENT,u=h%l;return new fi(s,i,r,a,h+(u?l-u:0),c)}constructor(t,e,s,i,r,n){this.position=t,this.id=e,this.bitset=s,this.standardAttributes=i,this.stride=r,this.packVertexCount=n,i.push(s),this._attributes=[t,e,s,...i]}get attributeLayout(){if(!this._attributeLayout){const t=function(t){const e=t.map((({name:t,count:e,type:s})=>`${t}.${e}.${s}`)).join(",");return(0,st.sV)(e)}(this._attributes),e=this._attributes.map((t=>({name:t.name,count:t.count,offset:t.offset,type:t.type,packPrecisionFactor:t.packPrecisionFactor,normalized:t.normalized??!1})));this._attributeLayout={attributes:e,hash:t,stride:this.stride}}return this._attributeLayout}}class mi{static fromVertexSpec(t,e){const s=fi.fromVertexSpec(t,e);return new mi(s)}constructor(t){this._spec=t,this._packed=new Uint8Array(this._spec.stride*this._spec.packVertexCount),this._packedU32View=new Uint32Array(this._packed.buffer),this._dataView=new DataView(this._packed.buffer)}get attributeLayout(){return this._spec.attributeLayout}get stride(){return this._spec.stride}writeVertex(t,e,s,i,r,n){for(let t=0;t<this._spec.packVertexCount;t++){const o=t*this._spec.stride;this._packPosition(s,i,o),this._packId(e,o);const a=this._spec.bitset;if(n){if(a.packTessellation){const t=a.packTessellation(n,r);this._pack(t,a,o)}for(const t of this._spec.standardAttributes)if(null!=t.packTessellation){const e=t.packTessellation(n,r);this._pack(e,t,o)}else if(t.packAlternating?.packTessellation){const e=t.packAlternating.packTessellation(n,r);for(let s=0;s<this._spec.packVertexCount;s++){const i=e[s];this._pack(i,t,s*this._spec.stride)}}}}t.vertexWriteRegion(this._packedU32View)}pack(t,e){for(const s of this._spec.standardAttributes)if(s.pack&&"string"!=typeof s.pack){const i=s.pack(t,e);for(let t=0;t<this._spec.packVertexCount;t++)this._pack(i,s,t*this._spec.stride)}else if(s.packAlternating?.pack){const i=s.packAlternating.pack(t,e);for(let t=0;t<this._spec.packVertexCount;t++){const e=i[t];this._pack(e,s,t*this._spec.stride)}}}_packPosition(t,e,s){const{offset:i}=this._spec.position,r=this._spec.position.packPrecisionFactor??1,n=65535&t*r|e*r<<16;this._dataView.setUint32(s+i,n,!0)}_packId(t,e){const s=t*(this._spec.id.packPrecisionFactor??1),i=4278190080&this._dataView.getUint32(e+this._spec.id.offset,!0);this._dataView.setUint32(e+this._spec.id.offset,s|i,!0)}_pack(t,e,s){!function(t,e,s,i){const r=s.packPrecisionFactor??1;switch(s.type){case pi.Ck.BYTE:if(1===s.count)t.setInt8(i+s.offset,e*r);else for(let n=0;n<s.count;n++){const o=n*Int8Array.BYTES_PER_ELEMENT;t.setInt8(i+s.offset+o,e[n]*r)}break;case pi.Ck.UNSIGNED_BYTE:if(1===s.count)t.setUint8(i+s.offset,e*r);else for(let n=0;n<s.count;n++){const o=n*Uint8Array.BYTES_PER_ELEMENT;t.setUint8(i+s.offset+o,e[n]*r)}break;case pi.Ck.SHORT:if(1===s.count)t.setInt16(i+s.offset,e*r,!0);else for(let n=0;n<s.count;n++){const o=n*Int16Array.BYTES_PER_ELEMENT;t.setInt16(i+s.offset+o,e[n]*r,!0)}break;case pi.Ck.UNSIGNED_SHORT:if(1===s.count)t.setUint16(i+s.offset,e*r,!0);else for(let n=0;n<s.count;n++){const o=n*Uint16Array.BYTES_PER_ELEMENT;t.setUint16(i+s.offset+o,e[n]*r,!0)}break;case pi.Ck.INT:if(1===s.count)t.setInt32(i+s.offset,e*r,!0);else for(let n=0;n<s.count;n++){const o=n*Int32Array.BYTES_PER_ELEMENT;t.setInt32(i+s.offset+o,e[n]*r,!0)}break;case pi.Ck.UNSIGNED_INT:if(1===s.count)t.setUint32(i+s.offset,e*r,!0);else for(let n=0;n<s.count;n++){const o=n*Uint32Array.BYTES_PER_ELEMENT;t.setUint32(i+s.offset+o,e[n]*r,!0)}break;case pi.Ck.FLOAT:if(1===s.count)t.setFloat32(i+s.offset,e*r,!0);else for(let n=0;n<s.count;n++){const o=n*Float32Array.BYTES_PER_ELEMENT;t.setFloat32(i+s.offset+o,e[n]*r,!0)}}}(this._dataView,t,e,s)}}class gi{constructor(t,e,s,i){this._instanceId=t,this._evaluator=e,this._viewParams=s,this._optionalAttributes=i,this._evaluator.evaluator=t=>this.vertexSpec.createComputedParams(t)}get _vertexPack(){if(!this._cachedVertexPack){const t=mi.fromVertexSpec(this.vertexSpec,this._optionalAttributes);this._evaluator.hasDynamicProperties||t.pack(this._evaluator.evaluatedMeshParams,this._viewParams),this._cachedVertexPack=t}return this._cachedVertexPack}get evaluatedMeshParams(){return this._evaluator.evaluatedMeshParams}get hasEffects(){return!!this.evaluatedMeshParams.effects}get instanceId(){return this._instanceId}get attributeLayout(){return this._vertexPack.attributeLayout}setReferences(t){this._references=t}getBoundsInfo(){return null}getTileInfo(){return this._viewParams.tileInfo}async loadDependencies(){(function(t){if(!t)return!1;for(const e of t)switch(e.effect.type){case"CIMGeometricEffectBuffer":case"CIMGeometricEffectOffset":case"CIMGeometricEffectDonut":return!0}return!1})(this._evaluator.inputMeshParams.params.effects?.effectInfos)&&await async function(){li=await Promise.all([s.e(984),s.e(324)]).then(s.bind(s,82704))}()}enqueueRequest(t,e,s){this._evaluator.hasDynamicProperties&&this._evaluator.enqueueRequest(t,e,s)}write(t,e,s,i,r){this.ensurePacked(e,s,i);const n=this.evaluatedMeshParams.effects;if(!n||0===n.length)return void this._write(t,s,void 0,r);const o=s.readGeometryForDisplay()?.clone();if(!o)return;const a=jt.fromOptimizedCIM(o,s.geometryType),h=ui();a.invertY();const c=t.id||"",l=ci.executeEffects(n,a,c,h);let u;for(;u=l.next();)u.invertY(),this._write(t,s,u,r)}ensurePacked(t,e,s){if(!this._evaluator.hasDynamicProperties)return;const i=this._evaluator.evaluateMeshParams(t,e,s);this._vertexPack.pack(i,this._viewParams)}_writeVertex(t,e,s,i,r){const n=this.evaluatedMeshParams;this._vertexPack.writeVertex(t,e,s,i,n,r)}}const yi=(0,n.c)("featurelayer-fast-triangulation-enabled");class xi extends gi{async loadDependencies(){await Promise.all([super.loadDependencies(),(0,pt.C)()])}_write(t,e,s){const i=s?.asOptimized()??e.readGeometryForDisplay(),r=this._clip(i);r&&(t.recordStart(this.instanceId,this.attributeLayout),this._writeGeometry(t,e,r),t.recordEnd())}_clip(t){return t?function(t,e){if(null==t)return null;if(!function(t,e,s){let i=0;for(let e=0;e<t.lengths.length;e++){const r=t.lengths[e];for(let e=0;e<r;e++){const r=t.coords[2*(e+i)],n=t.coords[2*(e+i)+1];if(r<-128||r>s||n<-128||n>s)return!0}i+=r}return!1}(t,0,B.gT+128))return t;Gt.setPixelMargin(e),Gt.reset(_t.ao.Polygon);let s=0;for(let e=0;e<t.lengths.length;e++){const i=t.lengths[e];let r=t.coords[2*(0+s)],n=t.coords[2*(0+s)+1];Gt.moveTo(r,n);for(let e=1;e<i;e++)r=t.coords[2*(e+s)],n=t.coords[2*(e+s)+1],Gt.lineTo(r,n);Gt.close(),s+=i}const i=Gt.result(!1);if(!i)return null;const r=[],n=[];for(const t of i){let e=0;for(const s of t)n.push(s.x),n.push(s.y),e++;r.push(e)}return new ft.c(r,n)}(t,this.hasEffects?256:8):null}_writeGeometry(t,e,s){const i=s.maxLength>100,r=[],n=this.createTesselationParams(e);if(!i&&yi&&function(t,e){const{coords:s,lengths:i,hasIndeterminateRingOrder:r}=e,n=t;if(r)return!1;let o=0;for(let t=0;t<i.length;){let e=t,r=i[t],a=qt(s,o,r);const h=[];for(;++e<i.length;){const t=i[e],n=qt(s,o+r,t);if(!(n>0))break;a+=n,h.push(o+r),r+=t}const c=n.length;mt(n,s,o,o+r,h,2,0);const l=Wt(n,s,c,n.length,0),u=Math.abs(a);if(Math.abs((l-u)/Math.max(1e-7,u))>1e-5)return n.length=0,!1;t=e,o+=r}return!0}(r,s))return void(r.length&&this._writeVertices(t,e,s.coords,n,r));const o=function(t){const{coords:e,lengths:s}=t,{buffer:i}=(0,pt.y)(e,s);return i}(s);this._writeVertices(t,e,o,n)}_writeVertices(t,e,s,i,r){const n=e.getDisplayId(),o=t.vertexCount(),a=this.hasEffects;let h=0;if(r)for(const e of r){const r=s[2*e],o=s[2*e+1];a&&t.recordBounds(r,o,0,0),this._writeVertex(t,n,r,o,i),h++}else for(let e=0;e<s.length;e+=2){const r=Math.round(s[e]),o=Math.round(s[e+1]);a&&t.recordBounds(r,o,0,0),this._writeVertex(t,n,r,o,i),h++}t.indexEnsureSize(h);for(let e=0;e<h;e++)t.indexWrite(e+o)}}const bi={createComputedParams:t=>t,attributes:{id:{type:pi.Ck.UNSIGNED_BYTE,count:3,pack:"id"},bitset:{type:pi.Ck.UNSIGNED_BYTE,count:1},pos:{type:pi.Ck.SHORT,count:2,pack:"position",packPrecisionFactor:10},inverseArea:{type:pi.Ck.FLOAT,count:1,packTessellation:({inverseArea:t})=>t}}};var wi=s(44728);function vi(t,e){return[!!t?.minScale&&e.scaleToZoom(t.minScale)||0,!!t?.maxScale&&e.scaleToZoom(t.maxScale)||100]}function Si(t){return 1<<t}function Ii(t){let e=0;for(const[s,i]of t)i&&(e|=1<<s);return e}function Ti(t){let e;if(!t)return[0,0,0,0];if("string"==typeof t){const s=wi.c.fromString(t);if(!s)return C.c.getLogger("geoscene.views.2d.engine.webgl.shaderGraph.techniques.meshWriterUtils").errorOnce(new i.c("mapview:mesh-processing","Unable to parse string into color",{color:t})),[0,0,0,0];e=s.toArray()}else e=t;const[s,r,n,o]=e;return[s*(o/255),r*(o/255),n*(o/255),o]}function Pi(t,e){return Math.round(Math.min(Math.sqrt(t*e),255))}function Mi(t,e){return Math.round(t*e)/e}function Ei(t,e){return Math.ceil(t*e)/e}const Ci={createComputedParams:t=>t,attributes:{id:{type:pi.Ck.UNSIGNED_BYTE,count:3,pack:"id"},bitset:{type:pi.Ck.UNSIGNED_BYTE,count:1},pos:{type:pi.Ck.SHORT,count:2,pack:"position",packPrecisionFactor:10},zoomRange:{type:pi.Ck.SHORT,count:2,packPrecisionFactor:B.M6,pack:({scaleInfo:t},{tileInfo:e})=>vi(t,e)},color:{type:pi.Ck.UNSIGNED_BYTE,count:4,normalized:!0,pack:({color:t})=>Ti(t)}}};class ki extends xi{constructor(){super(...arguments),this.vertexSpec=Ci}createTesselationParams(t){return null}}const Fi={createComputedParams:t=>t,attributes:{...Ci.attributes,tlbr:{count:4,type:pi.Ck.UNSIGNED_SHORT,pack:({sprite:t})=>{const{rect:e,width:s,height:i}=t,r=e.x+B.mc,n=e.y+B.mc;return[r,n,r+s,n+i]}},inverseRasterizationScale:{count:1,type:pi.Ck.BYTE,packPrecisionFactor:16,pack:({sprite:t})=>1/t.rasterizationScale}}};class Ai extends ki{constructor(){super(...arguments),this.vertexSpec=Fi}_write(t,e,s){const i=s?.asOptimized()??e.readGeometryForDisplay(),r=this._clip(i);if(!r)return;const n=this.evaluatedMeshParams.sprite?.textureBinding;t.recordStart(this.instanceId,this.attributeLayout,n),this._writeGeometry(t,e,r),t.recordEnd()}}var Ri,Oi;(Oi=Ri||(Ri={}))[Oi.Geographic=0]="Geographic",Oi[Oi.Arithmatic=1]="Arithmatic";const Ni=1.1,Di=1,zi=1e-5,Li=.05,Bi=1e-30,Ui=2;function Gi(t){const{sprite:e,aspectRatio:s,scaleProportionally:i}=t,r=(0,l.im)(t.height),n=r>0?r:e.height;let o=r*s;return o<=0?o=e.width:i&&(o*=e.width/e.height),{width:o,height:n}}function Vi(t){const{applyRandomOffset:e,sampleAlphaOnly:s}=t,{width:i,height:r}=Gi(t);return Ii([[Ui,e],[4,s],[6,i<B.c5],[5,r<B.c5]])}function qi(t){const{width:e}=Gi(t);return Math.round(e<B.c5?e*B.Q0:e)}function Wi(t){const{height:e}=Gi(t);return Math.round(e<B.c5?e*B.Q0:e)}const Xi={createComputedParams:t=>t,attributes:{...Fi.attributes,bitset:{count:1,type:pi.Ck.UNSIGNED_BYTE,pack:Vi},width:{count:1,type:pi.Ck.UNSIGNED_SHORT,pack:qi},height:{count:1,type:pi.Ck.UNSIGNED_SHORT,pack:Wi},offset:{count:2,type:pi.Ck.SHORT,pack:({offsetX:t,offsetY:e})=>[(0,l.im)(t),-(0,l.im)(e)]},scale:{count:2,type:pi.Ck.UNSIGNED_BYTE,packPrecisionFactor:16,pack:({scaleX:t,scaleY:e})=>[t,e]},angle:{count:1,type:pi.Ck.UNSIGNED_BYTE,pack:({angle:t})=>(0,oi.Qf)(t)}}};var Yi=s(93552);class ji{constructor(){this.extrusionOffsetX=0,this.extrusionOffsetY=0,this.normalX=0,this.normalY=0,this.directionX=0,this.directionY=0,this.distance=0}}const Hi={createComputedParams:t=>t,attributes:{id:{type:pi.Ck.UNSIGNED_BYTE,count:3,pack:"id"},pos:{type:pi.Ck.SHORT,count:2,pack:"position",packPrecisionFactor:10},bitset:{type:pi.Ck.UNSIGNED_BYTE,count:1},zoomRange:{type:pi.Ck.SHORT,count:2,packPrecisionFactor:B.M6,pack:({scaleInfo:t},{tileInfo:e})=>vi(t,e)},color:{type:pi.Ck.UNSIGNED_BYTE,count:4,normalized:!0,pack:({color:t})=>Ti(t)},offset:{type:pi.Ck.BYTE,count:2,packPrecisionFactor:16,packTessellation:({extrusionOffsetX:t,extrusionOffsetY:e})=>[Mi(t,16),Mi(e,16)]},normal:{type:pi.Ck.BYTE,count:2,packPrecisionFactor:16,packTessellation:({normalX:t,normalY:e})=>[Mi(t,16),Mi(e,16)]},halfWidth:{type:pi.Ck.UNSIGNED_SHORT,count:1,packPrecisionFactor:16,pack:({width:t})=>Ei((0,l.im)(.5*t),16)},referenceHalfWidth:{type:pi.Ck.UNSIGNED_SHORT,count:1,packPrecisionFactor:16,pack:({referenceWidth:t})=>Ei((0,l.im)(.5*t),16)}}};class $i{constructor(){this.id=0,this.bitset=0,this.indexCount=0,this.vertexCount=0,this.vertexFrom=0,this.vertexBounds=0}}class Ki extends gi{constructor(t,e,s,i){super(t,e,s,i),this.vertexSpec=Hi,this._currentWrite=new $i,this._tessellationOptions={halfWidth:0,pixelCoordRatio:1,offset:0,wrapDistance:65535,textured:!1},this._tessParams=new ji,this._initializeTessellator()}writeLineVertices(t,e,s){const i=this._getLines(e);null!=i&&this._writeVertices(t,s,i)}_initializeTessellator(){this._lineTessellator=new Yi.A(this._writeTesselatedVertex.bind(this),this._writeTriangle.bind(this),!0)}_write(t,e,s){const i=s??jt.fromFeatureSetReaderCIM(e);i&&this._writeGeometry(t,e,i)}_writeGeometry(t,e,s,i){t.recordStart(this.instanceId,this.attributeLayout,i),this.writeLineVertices(t,s,e),t.recordEnd()}_getLines(t){return function(t,e){Vt.setPixelMargin(e);const s=Vt,i=-e,r=B.gT+e;let n=[],o=!1;if(!t.nextPath())return null;let a=!0;for(;a;){t.seekPathStart();const e=[];if(!t.pathSize)return null;s.reset(_t.ao.LineString),t.nextPoint();let h=t.x,c=t.y;if(o)s.moveTo(h,c);else{if(h<i||h>r||c<i||c>r){o=!0;continue}e.push({x:h,y:c})}let l=!1;for(;t.nextPoint();)if(h=t.x,c=t.y,o)s.lineTo(h,c);else{if(h<i||h>r||c<i||c>r){l=!0;break}e.push({x:h,y:c})}if(l)o=!0;else{if(o){const t=s.resultWithStarts();if(t)for(const e of t)n.push(e)}else n.push({line:e,start:0});a=t.nextPath(),o=!1}}return n=n.filter((t=>t.line.length>1)),0===n.length?null:n}(t,this.hasEffects?256:16)}_writeVertices(t,e,s){const{_currentWrite:i,_tessellationOptions:r,evaluatedMeshParams:n}=this,{width:o,capType:a,joinType:h,miterLimit:c,hasSizeVV:u}=n,d=(0,l.im)(.5*o);r.halfWidth=d,r.capType=function(t){switch(t){case"butt":case ce.q.Butt:return ce.wD.BUTT;case"round":case ce.q.Round:return ce.wD.ROUND;case"square":case ce.q.Square:return ce.wD.SQUARE}}(a),r.joinType=function(t){switch(t){case"bevel":case ce.Sg.Bevel:return ce.qY.BEVEL;case"miter":case ce.Sg.Miter:return ce.qY.MITER;case"round":case ce.Sg.Round:return ce.qY.ROUND}}(h),r.miterLimit=c;const p=!u;i.out=t,i.id=e.getDisplayId(),i.vertexCount=0,i.indexCount=0,i.vertexFrom=t.vertexCount(),i.vertexBounds=p&&d<B.wt?0:1;for(const{line:t,start:e}of s)r.initialDistance=e%65535,this._lineTessellator.tessellate(t,r,p)}_writeTesselatedVertex(t,e,s,i,r,n,o,a,h,c,l){const{out:u,id:d,vertexBounds:p}=this._currentWrite;return this.hasEffects&&u.recordBounds(t,e,p,p),this._tessParams.extrusionOffsetX=o,this._tessParams.extrusionOffsetY=a,this._tessParams.normalX=h,this._tessParams.normalY=c,this._tessParams.directionX=r,this._tessParams.directionY=n,this._tessParams.distance=l,this._writeVertex(u,d,t,e,this._tessParams),this._currentWrite.vertexFrom+this._currentWrite.vertexCount++}_writeTriangle(t,e,s){const{out:i}=this._currentWrite;i.indexEnsureSize(3),i.indexWrite(t),i.indexWrite(e),i.indexWrite(s),this._currentWrite.indexCount+=3}}const Zi={createComputedParams:t=>t,attributes:{...Hi.attributes,bitset:{type:pi.Ck.UNSIGNED_BYTE,count:1,pack:t=>0},color:{type:pi.Ck.UNSIGNED_BYTE,count:4,normalized:!0,pack:({color:t})=>Ti(t)}}},Qi={createComputedParams:t=>t,attributes:{...Hi.attributes,bitset:{type:pi.Ck.UNSIGNED_BYTE,count:1,pack:t=>Ii([[0,!0]])},color:{type:pi.Ck.UNSIGNED_BYTE,count:4,normalized:!0,pack:({outlineColor:t})=>Ti(t)}}};class Ji extends Ki{constructor(){super(...arguments),this.vertexSpec=Qi}}class tr extends ki{constructor(t,e,s,i){super(t,e,s,i),this.vertexSpec=Zi,this._lineMeshWriter=this._createOutlineWriter(t,e,s,i)}_createOutlineWriter(t,e,s,i){return new Ji(t,e,s,i)}_write(t,e,s){const i=s?.asOptimized()??e.readGeometryForDisplay(),r=this._clip(i);r&&(t.recordStart(this.instanceId,this.attributeLayout),this._writeGeometry(t,e,r),this._lineMeshWriter.writeLineVertices(t,jt.fromOptimizedCIM(r,"esriGeometryPolyline"),e),t.recordEnd())}ensurePacked(t,e,s){super.ensurePacked(t,e,s),this._lineMeshWriter.ensurePacked(t,e,s)}enqueueRequest(t,e,s){super.enqueueRequest(t,e,s),this._lineMeshWriter.enqueueRequest(t,e,s)}async loadDependencies(){await Promise.all([super.loadDependencies(),this._lineMeshWriter.loadDependencies()])}}var er=s(75040),sr=s(90736);const ir=()=>C.c.getLogger("geoscene.views.3d.webgl-engine.core.shaderModules.shaderBuilder");class rr{constructor(){this._includedModules=new Map}include(t,e){if(this._includedModules.has(t)){const s=this._includedModules.get(t);if(s!==e){ir().error("Trying to include shader module multiple times with different sets of options.");const e=new Set;for(const i of Object.keys(s))s[i]!==t[i]&&e.add(i);for(const i of Object.keys(t))s[i]!==t[i]&&e.add(i);e.forEach((e=>console.error(` ${e}: current ${s[e]} new ${t[e]}`)))}}else this._includedModules.set(t,e),t(this.builder,e)}}class nr extends rr{constructor(){super(...arguments),this.vertex=new hr,this.fragment=new hr,this.attributes=new cr,this.varyings=new lr,this.extensions=new ur,this.constants=new dr}get fragmentUniforms(){return this.fragment.uniforms.entries}get builder(){return this}generate(t,e=!0){const s=this.extensions.generateSource(t),i=this.attributes.generateSource(t),r=this.varyings.generateSource(t),n="vertex"===t?this.vertex:this.fragment,o=n.uniforms.generateSource(),a=n.code.generateSource(),h="vertex"===t?pr:function(t=!0){return`#ifdef GL_FRAGMENT_PRECISION_HIGH\n precision highp float;\n precision highp sampler2D;\n#else\n precision mediump float;\n precision mediump sampler2D;\n#endif\n${t?"out vec4 fragColor;":""}\n`}(e),c=this.constants.generateSource().concat(n.constants.generateSource());return`${e?"#version 300 es":""}\n${s.join("\n")}\n${h}\n${c.join("\n")}\n${o.join("\n")}\n${i.join("\n")}\n${r.join("\n")}\n${a.join("\n")}`}generateBindPass(t){const e=new Map;this.vertex.uniforms.entries.forEach((t=>{const s=t.bind[er.u.Pass];s&&e.set(t.name,s)})),this.fragment.uniforms.entries.forEach((t=>{const s=t.bind[er.u.Pass];s&&e.set(t.name,s)}));const s=Array.from(e.values()),i=s.length;return(e,r)=>{for(let n=0;n<i;++n)s[n](t,e,r)}}generateBindDraw(t){const e=new Map;this.vertex.uniforms.entries.forEach((t=>{const s=t.bind[er.u.Draw];s&&e.set(t.name,s)})),this.fragment.uniforms.entries.forEach((t=>{const s=t.bind[er.u.Draw];s&&e.set(t.name,s)}));const s=Array.from(e.values()),i=s.length;return(e,r,n)=>{for(let o=0;o<i;++o)s[o](t,e,r,n)}}}class or{constructor(){this._entries=new Map}add(...t){for(const e of t)this._add(e)}get(t){return this._entries.get(t)}_add(t){if(null!=t){if(this._entries.has(t.name)&&!this._entries.get(t.name).equals(t))throw new i.c(`Duplicate uniform name ${t.name} for different uniform type`);this._entries.set(t.name,t)}else ir().error(`Trying to add null Uniform from ${(new Error).stack}.`)}generateSource(){return Array.from(this._entries.values()).map((t=>null!=t.arraySize?`uniform ${t.type} ${t.name}[${t.arraySize}];`:`uniform ${t.type} ${t.name};`))}get entries(){return Array.from(this._entries.values())}}class ar{constructor(){this._entries=new Array}add(t){this._entries.push(t)}generateSource(){return this._entries}}class hr extends rr{constructor(){super(...arguments),this.uniforms=new or,this.code=new ar,this.constants=new dr}get builder(){return this}}class cr{constructor(){this._entries=new Array}add(t,e){this._entries.push([t,e])}generateSource(t){return"fragment"===t?[]:this._entries.map((t=>`in ${t[1]} ${t[0]};`))}}class lr{constructor(){this._entries=new Map}add(t,e){this._entries.has(t)&&(0,sr.Uc)(this._entries.get(t)===e),this._entries.set(t,e)}generateSource(t){const e=new Array;return this._entries.forEach(((s,i)=>e.push("vertex"===t?`out ${s} ${i};`:`in ${s} ${i};`))),e}}class ur{constructor(){this._entries=new Set}add(t){this._entries.add(t)}generateSource(t){const e="vertex"===t?ur.ALLOWLIST_VERTEX:ur.ALLOWLIST_FRAGMENT;return Array.from(this._entries).filter((t=>e.includes(t))).map((t=>`#extension ${t} : enable`))}}ur.ALLOWLIST_FRAGMENT=["GL_EXT_shader_texture_lod","GL_OES_standard_derivatives"],ur.ALLOWLIST_VERTEX=[];class dr{constructor(){this._entries=new Set}add(t,e,s){let i="ERROR_CONSTRUCTOR_STRING";switch(e){case"float":i=dr._numberToFloatStr(s);break;case"int":i=dr._numberToIntStr(s);break;case"bool":i=s.toString();break;case"vec2":i=`vec2(${dr._numberToFloatStr(s[0])}, ${dr._numberToFloatStr(s[1])})`;break;case"vec3":i=`vec3(${dr._numberToFloatStr(s[0])}, ${dr._numberToFloatStr(s[1])}, ${dr._numberToFloatStr(s[2])})`;break;case"vec4":i=`vec4(${dr._numberToFloatStr(s[0])}, ${dr._numberToFloatStr(s[1])}, ${dr._numberToFloatStr(s[2])}, ${dr._numberToFloatStr(s[3])})`;break;case"ivec2":i=`ivec2(${dr._numberToIntStr(s[0])}, ${dr._numberToIntStr(s[1])})`;break;case"ivec3":i=`ivec3(${dr._numberToIntStr(s[0])}, ${dr._numberToIntStr(s[1])}, ${dr._numberToIntStr(s[2])})`;break;case"ivec4":i=`ivec4(${dr._numberToIntStr(s[0])}, ${dr._numberToIntStr(s[1])}, ${dr._numberToIntStr(s[2])}, ${dr._numberToIntStr(s[3])})`;break;case"mat2":case"mat3":case"mat4":i=`${e}(${Array.prototype.map.call(s,(t=>dr._numberToFloatStr(t))).join(", ")})`}return this._entries.add(`const ${e} ${t} = ${i};`),this}static _numberToIntStr(t){return t.toFixed(0)}static _numberToFloatStr(t){return Number.isInteger(t)?t.toFixed(1):t.toString()}generateSource(){return Array.from(this._entries)}}const pr="precision highp float;\nprecision highp sampler2D;";function _r(t,e){const s=[];for(s.push(e);s.length;){const e=s.pop();if("object"==typeof e&&!t.has(e.uid)){t.add(e.uid);for(const t of e.children)s.push(t)}}}class fr{constructor(){this.uid=fr.NodeCount++,this._debugName=null,this._isMutable=!1,this.isImplicit=!1}get isMutable(){return this._isMutable}setMutable(){return this._isMutable=!0,this}setDebugName(t){return t=function(t){return t.split(" ").map(((t,e)=>e>0?t.charAt(0).toUpperCase()+t.slice(1):t)).join("")}(t),this._debugName=t,this.isImplicit&&this.children[0]instanceof fr&&this.children[0].setDebugName(t),this}get debugInfo(){return{name:this._debugName??""}}cloneInto(t){t._debugName=this._debugName,t._isMutable=this._isMutable,t.isImplicit=this.isImplicit,t.uid=this.uid}}function mr(t){return"object"==typeof t?t.clone():t}fr.NodeCount=0;class gr extends fr{constructor(){super(...arguments),this.shaderType="primitive-node"}}class yr extends fr{constructor(t){super(),this.child=t,this.shaderType="scope-node"}get children(){return[this.child]}clone(){const t=new yr(mr(this.child));return this.cloneInto(t),t}}class xr extends fr{constructor(t,e,s){super(),this.property=t,this.target=e,this.returnType=s,this.shaderType="property-access-node"}get children(){const t=[this.target];return"string"!=typeof this.property&&t.push(this.property),t}clone(){const t=new xr(this.property,mr(this.target),this.returnType);return this.cloneInto(t),t}}class br extends fr{constructor(t,e,s){super(),this.condition=t,this.ifTrue=e,this.ifFalse=s,this.shaderType="condition-node"}get children(){return[this.condition,this.ifTrue,this.ifFalse]}clone(){const t=mr(this.ifTrue),e=this.ifFalse?mr(this.ifFalse):null,s=new br(this.condition,t,e);return this.cloneInto(s),s}}class wr extends fr{constructor(t,e,s,i){super(),this.captureList=t,this.returnType=e,this.generator=i,this.shaderType="block-node",s&&(this.subgraph=new yr(s))}get children(){return Object.keys(this.captureList).map((t=>this.captureList[t])).concat(this.subgraph??[])}clone(){const t={};for(const e in this.captureList)t[e]=mr(this.captureList[e]);const e=new wr(t,this.returnType,this.subgraph?mr(this.subgraph.child):this.subgraph,this.generator);return this.cloneInto(e),e}}class vr extends fr{constructor(t,e,s,i,r,n=!1){super(),this.token=t,this._children=e,this.isInfix=s,this.isPropertyAccess=i,this.returnType=r,this.isTernary=n,this.shaderType="function-node"}get children(){return this._children}clone(){const t=new vr(this.token,this._children.map(mr),this.isInfix,this.isPropertyAccess,this.returnType,this.isTernary);return this.cloneInto(t),t}}var Sr,Ir,Tr,Pr,Mr,Er,Cr,kr,Fr,Ar,Rr,Or,Nr,Dr;function zr(t){return new Proxy(t,{get(e,s){if("constructor"===s)return new Proxy(e.constructor,{construct:(t,e,s)=>zr(new t(...e))});if(s in e)return e[s];if("string"==typeof s){const e=function(t){const e=[["float","vec2","vec3","vec4"],["int","ivec2","ivec3","ivec4"],["uint","uvec2","uvec3","uvec4"],["bool","bvec2","bvec3","bvec4"]];for(const s of e)if(s.includes(t))return s.map((t=>cn[t]));throw new Error("Unable to find type family")}(t.type);return fn(t,s,e[s.length-1])}}})}function Lr(t){return new Proxy(t,{construct:(t,e,s)=>zr(new t(...e))})}class Br extends Error{}let Ur=Sr=class extends gr{constructor(t,e){super(),this.elementType=t,this.size=e,this.children=[],this.type="array"}clone(){const t=new Sr(this.elementType,this.size);return super.cloneInto(t),t}get(t){if("number"==typeof t){const e=new en(t);return e.isImplicit=!0,fn(this,e,this.elementType.constructor)}return fn(this,t,this.elementType.constructor)}last(){return this.get(this.size-1)}first(){return this.get(0)}findIndex(t,e,s){return function(t,e,s=0,i=t.size){const r=new en(s).setMutable().setDebugName("FindIndexIterator"),n=e(t.get(r)).setDebugName("FindIndexPredicate"),o=wn({iter:r},en,n,(({out:t,iter:e,subgraph:s})=>`\n${t} = -1;\n\nfor (; ${e} < ${i}; ${e}++) {\n\n${s.body}\n\n if (${s.varName}) {\n ${t} = ${e};\n break;\n }\n\n}\n`)).setDebugName("FindIndexBlock");return o}(this,t,e,s)}glslFindIndex(t,e,s){return function(t,e,s=0,i=t.size){const r=wn({array:t},en,null,(({out:t,array:r})=>`\n${t} = -1;\nfor (int i = ${s}; i < ${i}; i++) {\n bool condition;\n ${e({array:r,i:"i",out:"condition"})}\n if (condition) {\n ${t} = i;\n break;\n }\n}\n`)).setDebugName("GlslFindIndexBlock");return r}(this,t,e,s)}static ofType(t,e){const s={construct:(s,i)=>new Sr(new t,e)};return new Proxy(Sr,s)}};Ur.type="array",Ur=Sr=(0,T._)([function(t){return new Proxy(t,{construct:(t,e,s)=>function(t){return new Proxy(t,{get(e,s){if(s in e)return e[s];if("string"==typeof s){const e=parseInt(s,10);if(!isNaN(e))return fn(t,`[${e}]`,t.elementType.constructor)}}})}(new t(...e))})}],Ur);class Gr extends gr{constructor(){super(...arguments),this.type="sampler2D",this.children=[]}clone(){const t=new Gr;return t.children=this.children.map(mr),super.cloneInto(t),t}}Gr.type="sampler2D";class Vr extends gr{constructor(t){super(),this.type="float",this.children=[t]}clone(){const t=new Vr(mr(this.children[0]));return super.cloneInto(t),t}multiply(t){return In(this,"number"==typeof t?Jr(t,Vr):t)}divide(t){return Tn(this,"number"==typeof t?Jr(t,Vr):t)}add(t){return Pn(this,"number"==typeof t?Jr(t,Vr):t)}subtract(t){return Mn(this,"number"==typeof t?Jr(t,Vr):t)}}Vr.type="float";let qr=Ir=class extends gr{constructor(t,e){super(),this.type="vec2",this.children=[t,e].filter((t=>null!=t))}clone(){const t=new Ir(mr(this.children[0]),mr(this.children[1]));return super.cloneInto(t),t}get 0(){return fn(this,"[0]",Vr)}get 1(){return fn(this,"[1]",Vr)}get 2(){throw new Br}get 3(){throw new Br}multiply(t){return In(this,"number"==typeof t?Jr(t,Vr):t)}divide(t){return Tn(this,"number"==typeof t?Jr(t,Vr):t)}add(t){return Pn(this,"number"==typeof t?Jr(t,Vr):t)}subtract(t){return Mn(this,"number"==typeof t?Jr(t,Vr):t)}};qr.type="vec2",qr=Ir=(0,T._)([Lr],qr);let Wr=Tr=class extends gr{constructor(t,e,s){super(),this.type="vec3",this.children=[t,e,s].filter((t=>null!=t))}get 0(){return fn(this,"[0]",Vr)}get 1(){return fn(this,"[1]",Vr)}get 2(){return fn(this,"[2]",Vr)}get 3(){throw new Br}clone(){const t=new Tr(mr(this.children[0]),mr(this.children[1]),mr(this.children[2]));return super.cloneInto(t),t}multiply(t){return In(this,"number"==typeof t?Jr(t,Vr):t)}divide(t){return Tn(this,"number"==typeof t?Jr(t,Vr):t)}add(t){return Pn(this,"number"==typeof t?Jr(t,Vr):t)}subtract(t){return Mn(this,"number"==typeof t?Jr(t,Vr):t)}};Wr.type="vec3",Wr=Tr=(0,T._)([Lr],Wr);let Xr=Pr=class extends gr{constructor(t,e,s,i){super(),this.type="vec4",this.children=[t,e,s,i].filter((t=>null!=t))}clone(){const t=new Pr(mr(this.children[0]),mr(this.children[1]),mr(this.children[2]),mr(this.children[3]));return super.cloneInto(t),t}get 0(){return fn(this,"[0]",Vr)}get 1(){return fn(this,"[1]",Vr)}get 2(){return fn(this,"[2]",Vr)}get 3(){return fn(this,"[3]",Vr)}multiply(t){return In(this,"number"==typeof t?Jr(t,Vr):t)}divide(t){return Tn(this,"number"==typeof t?Jr(t,Vr):t)}add(t){return Pn(this,"number"==typeof t?Jr(t,Vr):t)}subtract(t){return Mn(this,"number"==typeof t?Jr(t,Vr):t)}};Xr.type="vec4",Xr=Pr=(0,T._)([Lr],Xr);let Yr=Mr=class extends gr{constructor(t){super(),this.type="uint",this.children=[t]}clone(){const t=new Mr(mr(this.children[0]));return super.cloneInto(t),t}};Yr.type="uint",Yr=Mr=(0,T._)([Lr],Yr);let jr=Er=class extends gr{constructor(t,e){super(),this.type="uvec2",this.children=[t,e].filter((t=>null!=t))}clone(){const t=new Er(mr(this.children[0]),mr(this.children[1]));return super.cloneInto(t),t}};jr.type="uvec2",jr=Er=(0,T._)([Lr],jr);let Hr=Cr=class extends gr{constructor(t,e,s){super(),this.type="uvec3",this.children=[t,e,s].filter((t=>null!=t))}clone(){const t=new Cr(mr(this.children[0]),mr(this.children[1]),mr(this.children[2]));return super.cloneInto(t),t}};Hr.type="uvec3",Hr=Cr=(0,T._)([Lr],Hr);let $r=kr=class extends gr{constructor(t,e,s,i){super(),this.type="uvec4",this.children=[t,e,s,i].filter((t=>null!=t))}clone(){const t=new kr(mr(this.children[0]),mr(this.children[1]),mr(this.children[2]),mr(this.children[3]));return super.cloneInto(t),t}};$r.type="uvec4",$r=kr=(0,T._)([Lr],$r);class Kr extends gr{constructor(t){super(),this.type="bool",this.children=[t]}and(t){return Rn(this,t)}or(t){return An(this,t)}clone(){const t=new Kr(mr(this.children[0]));return super.cloneInto(t),t}}Kr.type="bool";let Zr=Fr=class extends gr{constructor(t,e){super(),this.type="bvec2",this.children=[t,e].filter((t=>null!=t))}all(){return On(this)}any(){return Nn(this)}clone(){const t=new Fr(mr(this.children[0]),mr(this.children[1]));return super.cloneInto(t),t}};Zr.type="bvec2",Zr=Fr=(0,T._)([Lr],Zr);let Qr=Ar=class extends gr{constructor(t,e,s){super(),this.type="bvec3",this.children=[t,e,s].filter((t=>null!=t))}all(){return On(this)}any(){return Nn(this)}clone(){const t=new Ar(mr(this.children[0]),mr(this.children[1]),mr(this.children[2]));return super.cloneInto(t),t}};function Jr(t,e){return"number"==typeof t?new e(t):t}Qr.type="bvec3",Qr=Ar=(0,T._)([Lr],Qr);let tn=Rr=class extends gr{constructor(t,e,s,i){super(),this.type="bvec4",this.children=[t,e,s,i].filter((t=>null!=t))}all(){return On(this)}any(){return Nn(this)}clone(){const t=new Rr(mr(this.children[0]),mr(this.children[1]),mr(this.children[2]),mr(this.children[3]));return super.cloneInto(t),t}};tn.type="bvec4",tn=Rr=(0,T._)([Lr],tn);class en extends gr{constructor(t){super(),this.type="int",this.children=[t]}multiply(t){return In(this,Jr(t,en))}add(t){return Pn(this,Jr(t,en))}subtract(t){return Mn(this,Jr(t,en))}divide(t){return Tn(this,Jr(t,en))}clone(){const t=new en(mr(this.children[0]));return super.cloneInto(t),t}}en.type="int";let sn=Or=class extends gr{constructor(t,e){super(),this.type="ivec2",this.children=[t,e].filter((t=>null!=t))}clone(){const t=new Or(mr(this.children[0]),mr(this.children[1]));return super.cloneInto(t),t}};sn.type="ivec2",sn=Or=(0,T._)([Lr],sn);let rn=Nr=class extends gr{constructor(t,e,s){super(),this.type="ivec3",this.children=[t,e,s].filter((t=>null!=t))}clone(){const t=new Nr(mr(this.children[0]),mr(this.children[1]),mr(this.children[2]));return super.cloneInto(t),t}};rn.type="ivec3",rn=Nr=(0,T._)([Lr],rn);let nn=Dr=class extends gr{constructor(t,e,s,i){super(),this.type="ivec4",this.children=[t,e,s,i].filter((t=>null!=t))}clone(){const t=new Dr(mr(this.children[0]),mr(this.children[1]),mr(this.children[2]),mr(this.children[3]));return super.cloneInto(t),t}};nn.type="ivec4",nn=Dr=(0,T._)([Lr],nn);class on extends gr{constructor(t,e,s,i){super(),this.type="mat2",this.children=[t,e,s,i]}clone(){const t=new on(mr(this.children[0]),mr(this.children[1]),mr(this.children[2]),mr(this.children[3]));return super.cloneInto(t),t}}on.type="mat2";class an extends gr{static identity(){return new an(1,0,0,0,1,0,0,0,1)}static fromRotation(t){const e=Yn(t),s=zn(t);return new an(s,e,0,bn(e),s,0,0,0,1)}constructor(t,e,s,i,r,n,o,a,h){super(),this.type="mat3",this.children=[t,e,s,i,r,n,o,a,h]}add(t){return Pn(this,t)}multiply(t){return In(this,t)}clone(){const t=new an(mr(this.children[0]),mr(this.children[1]),mr(this.children[2]),mr(this.children[3]),mr(this.children[4]),mr(this.children[5]),mr(this.children[6]),mr(this.children[7]),mr(this.children[8]));return super.cloneInto(t),t}}an.type="mat3";class hn extends gr{static identity(){return new hn(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)}constructor(t,e,s,i,r,n,o,a,h,c,l,u,d,p,_,f){super(),this.type="mat4",this.children=[t,e,s,i,r,n,o,a,h,c,l,u,d,p,_,f]}static fromColumns(t,e,s,i){return new hn(t.x,t.y,t.z,t.w,e.x,e.y,e.z,e.w,s.x,s.y,s.z,s.w,i.x,i.y,i.z,i.w)}multiply(t){return In(this,t)}clone(){const t=new hn(mr(this.children[0]),mr(this.children[1]),mr(this.children[2]),mr(this.children[3]),mr(this.children[4]),mr(this.children[5]),mr(this.children[6]),mr(this.children[7]),mr(this.children[8]),mr(this.children[9]),mr(this.children[10]),mr(this.children[11]),mr(this.children[12]),mr(this.children[13]),mr(this.children[14]),mr(this.children[15]));return super.cloneInto(t),t}}hn.type="mat4";const cn={float:Vr,vec2:qr,vec3:Wr,vec4:Xr,int:en,ivec2:sn,ivec3:rn,ivec4:nn,uint:Yr,uvec2:jr,uvec3:Hr,uvec4:$r,bool:Kr,bvec2:Zr,bvec3:Qr,bvec4:tn},ln=(...t)=>new en(...t),un=(...t)=>new Vr(...t),dn=(...t)=>new qr(...t),pn=(...t)=>new Xr(...t),_n=(...t)=>new an(...t);function fn(t,e,s){const i=new s(new xr(e,t,s));return i.isImplicit=!0,i}function mn(t,e,s,i=null){if(i){const r=new i,n=new i(new vr(t,[e,s],!0,!1,r));return n.isImplicit=!0,n}if("float"===e.type||"int"===e.type){const i=new s.constructor(new vr(t,[e,s],!0,!1,s.constructor));return i.isImplicit=!0,i}if(("mat2"===e.type||"mat3"===e.type||"mat4"===e.type)&&"float"!==s.type){const i=new s.constructor(new vr(t,[e,s],!0,!1,s.constructor));return i.isImplicit=!0,i}const r=new e.constructor(new vr(t,[e,s],!0,!1,e.constructor));return r.isImplicit=!0,r}function gn(t,e,s=e.constructor){const i=new s(new vr(t,[e],!1,!1,s));return i.isImplicit=!0,i}function yn(t,e,s,i=e.constructor){const r=new i(new vr(t,[e,s],!1,!1,i));return r.isImplicit=!0,r}function xn(t,e,s,i,r=e.constructor){const n=new r(new vr(t,[e,s,i],!1,!1,r));return n.isImplicit=!0,n}function bn(t){return In(t,un(-1))}function wn(t,e,s,i){return new e(new wr(t,e,s,i))}function vn(t,e,s){const i="function"==typeof e?e():e,r="function"==typeof s?s():s,n=new i.constructor(new br(t,i,r));return n.isImplicit=!0,n}function Sn(...t){const e=t.map((([t,e])=>"function"==typeof e?[t,e()]:[t,e])),s=e[0][1].constructor,i=e.findIndex((t=>!0===t[0]));if(-1===i)throw new Error("A cond must have a fallthrough case with `true`/; ");const r=e.slice(0,i),n=e[i][1],o=new s(r.reduceRight(((t,e)=>vn(e[0],e[1],t)),n));return o.isImplicit=!0,o}function In(t,e){return mn("*",t,e)}function Tn(t,e){return mn("/",t,e)}function Pn(t,e){return mn("+",t,e)}function Mn(t,e){return mn("-",t,e)}function En(t,e){return mn("==",t,e,Kr)}function Cn(t,e){return mn("<=",t,e,Kr)}function kn(t,e){return mn(">",t,e,Kr)}function Fn(t,e){return mn(">=",t,e,Kr)}function An(...t){return t.length<=1?t[0]:t.slice(1).reduce(((t,e)=>function(t,e){return mn("||",t,e,Kr)}(t,e)),t[0])}function Rn(...t){return t.length<=1?t[0]:t.slice(1).reduce(((t,e)=>function(t,e){return mn("&&",t,e,Kr)}(t,e)),t[0])}function On(t){return gn("all",t,Kr)}function Nn(t){return gn("any",t,Kr)}function Dn(t,e,s){return xn("clamp",t,e,s,t.constructor)}function zn(t){return gn("cos",t)}function Ln(t,e){return yn("dot",t,e,Vr)}function Bn(t){return gn("fract",t)}function Un(t){return gn("length",t,Vr)}function Gn(t,e){return yn("max",t,e)}function Vn(t,e){return yn("min",t,e)}function qn(t,e,s){return xn("mix",t,e,s)}function Wn(t,e){return yn("mod",t,e)}function Xn(t){return"bool"===t.type?gn("!",t):gn("not",t)}function Yn(t){return gn("sin",t)}function jn(t,e){return yn("step",t,e,e.constructor)}function Hn(t,e){return yn("texture2D",t,e,Xr)}function $n(t,e,s){const i=e.split("\n");for(const e of i)if(e.trim().length){{let e="";null!=s&&(e+=`/*id:${s??"000"}*/ `),t.body+=e.padEnd(14)}t.body+=" ".repeat(t.indent)+e+"\n"}}class Kn{write(t){for(const e of t.rootOutputNodes())t.shouldPruneOutputNode(e)||(e.variableName=this._write(t,e.node));return t}_createVarName(t,e){let s="";return"boolean"!=typeof e&&"number"!=typeof e&&e.debugInfo.name&&(s=`${e.debugInfo.name}_`),`${s}v${t.varCount++}`}_write(t,e,s=!1){if("number"==typeof e)return e.toString();if("boolean"==typeof e)return e.toString();let i=t.getEmit(e);if(i)return i;switch(e.shaderType){case"scope-node":i=this._writeScopeNode(t,e);break;case"primitive-node":i=this._writePrimitveNode(t,e,s);break;case"function-node":i=this._writeFunctionNode(t,e);break;case"property-access-node":i=this._writePropertyAccessNode(t,e);break;case"text-node":i=e.text;break;case"block-node":i=this._writeBlockNode(t,e);break;case"condition-node":i=this._writeConditionNode(t,e)}return t.setEmit(e,i),i}_writeScopeNode(t,e){const s=new e.child.constructor;s.setDebugName(e.debugInfo.name);const i=this._write(t,s,!0);return $n(t,`{ /*ScopeStart: ${e.uid} ${e.debugInfo.name}*/`),t.indent+=2,$n(t,`${i} = ${this._write(t,e.child)};`),t.indent-=2,$n(t,`} /*ScopeEnd: ${e.uid} ${e.debugInfo.name}*/`),i}_writeConditionNode(t,e){const s=new e.ifTrue.constructor,i=this._write(t,s,!0);$n(t,`if (${this._write(t,e.condition)}) {`),t.indent+=2;const r=t.createSubgraphContext(),n=this._write(r,e.ifTrue);if(t.body+=r.body,n&&$n(t,`${i} = ${n};`),t.indent-=2,$n(t,"}"),e.ifFalse){$n(t,"else {"),t.indent+=2;const s=t.createSubgraphContext(),r=this._write(s,e.ifFalse);t.body+=s.body,r&&$n(t,`${i} = ${r};`),t.indent-=2,$n(t,"}")}return i}_writeBlockNode(t,e){const{captureList:s,generator:i,returnType:r}=e,n={};for(const e in s){if(!s[e])continue;const i=this._write(t,s[e]);n[e]=i}const o=new r,a=this._write(t,o,!0);if(n.out=a,e.subgraph){const s=t.createSubgraphContext(),i=this._write(s,e.subgraph.child),r=s.body;n.subgraph={varName:i,body:r}}const h=i(n);return $n(t,"{\n"),t.indent+=2,$n(t,h),t.indent-=2,$n(t,"}\n"),a}_writePropertyAccessNode(t,e){const s=this._write(t,e.target);return"string"==typeof e.property&&e.property.includes("[")?`${s}${e.property}`:"string"!=typeof e.property?`${s}[${this._write(t,e.property)}]`:`${s}.${e.property}`}_writeFunctionNode(t,e){const s=e.returnType.type;if(e.isInfix){const[i,r]=e.children.map((e=>this._write(t,e))),n=this._createVarName(t,e);return $n(t,`${s.padEnd(5)} ${n} = ${i} ${e.token} ${r};`,e.uid),n}const i=e.children.map((e=>this._write(t,e))).join(", "),r=this._createVarName(t,e);return $n(t,`${s.padEnd(5)} ${r} = ${e.token}(${i});`,e.uid),r}_writePrimitveNode(t,e,s=!1){const i=t.getInput(e);if(i)return i.isUsed=!0,i.variableName;const r=1===e.children.length&&e.children[0]?.type===e.type;if(e.isImplicit||r)return this._write(t,e.children[0]);const n=this._createVarName(t,e);if(s)return $n(t,`${e.type.padEnd(5)} ${n};`,e.uid),n;const o=!e.debugInfo.name&&!e.isMutable;if(o&&"float"===e.type&&"number"==typeof e.children[0])return Number.isInteger(e.children[0])?e.children[0].toFixed(1):e.children[0].toString();if(o&&"int"===e.type&&"number"==typeof e.children[0]&&Number.isInteger(e.children[0]))return e.children[0].toString();const a=e.children.map((e=>this._write(t,e))).join(", ");return"array"===e.type?($n(t,`${e.type.padEnd(5)} ${n} = [${a}];`,e.uid),n):o?`${e.type}(${a})`:($n(t,`${e.type.padEnd(5)} ${n} = ${e.type}(${a});`,e.uid),n)}}class Zn{constructor(t,e,s){this.variableName=t,this.variableInputType=e,this.node=s,this.type="shader-input",this.isUsed=!1}clone(){return new Zn(this.variableName,this.variableInputType,mr(this.node))}}class Qn{constructor(t,e,s){this.outVariableName=t,this.outVariableType=e,this.node=s,this.type="shader-output"}clone(){const t=new Qn(this.outVariableName,this.outVariableType,mr(this.node));return t.variableName=this.variableName,t}}class Jn{static createVertex(t,e,s,i,r,n){const o=[];for(const e in t){const i=t[e],r=s.get(e);r?o.push(new Zn(r,"builtin",i)):o.push(new Zn("a_"+e,"attribute",i))}for(const t of i){const e=t.uniformHydrated;o.push(new Zn(t.uniformName,"uniform",e))}const a=[];for(const t in e){const s=e[t];"glPosition"===t?a.push(new Qn("gl_Position","builtin",s)):"glPointSize"===t?a.push(new Qn("gl_PointSize","builtin",s)):a.push(new Qn("v_"+t,"varying",s))}return new Jn(o,a,r,n)}static createFragment(t,e,s,i,r,n){const o=[],a=Array.from(r.rootOutputNodes());for(const e in t){const i=t[e],r=s.get(e);if(r){o.push(new Zn(r,"builtin",i));continue}const n=a.find((t=>t.node===i));n&&o.push(new Zn(n.outVariableName,n.outVariableType,i))}for(const t of i){const e=t.uniformHydrated;o.push(new Zn(t.uniformName,"uniform",e))}const h=[];for(const t in e){const i=e[t],r=s.get(t);if("discard"===t)h.push(new Qn(null,"discard",i));else{if(!r)throw new Error(`Member ${t} in shader fragment output shoule be tagged as builtin`);h.push(new Qn(r,"builtin",i))}}return new Jn(o,h,n)}constructor(t,e,s,i){this.type="shader-graph-context",this.indent=0,this.body="",this.varCount=0,this._inputShaderTypesByNodeUid=new Map,this._nodeEmitMap=new Map;for(const e of t)this._inputShaderTypesByNodeUid.set(e.node.uid,e);this._outputShaderTypes=e,this._transformFeedbackBindings=s,this._transformFeedbackNames=new Set(s.map((t=>"v_"+t.propertyKey))),this._usedInFragmentShader=i}shouldPruneOutputNode(t){return!!this._usedInFragmentShader&&"builtin"!==t.outVariableType&&!this._transformFeedbackNames.has(t.outVariableName)&&!this._usedInFragmentShader.has(t.node.uid)}setEmit(t,e){this._nodeEmitMap.set(t.uid,e)}getEmit(t){return this._nodeEmitMap.get(t.uid)}inputs(){return this._inputShaderTypesByNodeUid.values()}getInput(t){return this._inputShaderTypesByNodeUid.get(t.uid)}*rootOutputNodes(){for(const t of this._outputShaderTypes)yield t}*nodes(){const t=[];for(const e of this._outputShaderTypes.values())t.push(e.node);for(;t.length;){const e=t.pop();"number"!=typeof e&&"boolean"!=typeof e&&t.push(...e.children.filter(Boolean)),yield e}}*nodesOfTypeOrFunction(){for(const t of this.nodes())"number"!=typeof t&&"boolean"!=typeof t&&(yield t)}createSubgraphContext(){const t=this.clone();return t.body="",t.indent=this.indent+2,t._nodeEmitMap=new Map(this._nodeEmitMap),t}clone(){const t=new Jn([],this._outputShaderTypes,this._transformFeedbackBindings,this._usedInFragmentShader);return t._inputShaderTypesByNodeUid=this._inputShaderTypesByNodeUid,t.indent=this.indent,t.body=this.body,t.varCount=this.varCount,t._nodeEmitMap=this._nodeEmitMap,t}insertVertexShader(t){t.vertex.code.add(""),this._insertInputs(t,"vertex"),t.vertex.code.add(""),t.vertex.code.add("// OUTPUTS: "),t.vertex.code.add("// --------------------------------------------------------- ");for(const e of this.rootOutputNodes()){const s="builtin"===e.outVariableType;this.shouldPruneOutputNode(e)||(s?t.vertex.code.add(`// ${e.outVariableType.padEnd(7)} ${e.node.type.padEnd(9)} ${e.outVariableName};`):t.vertex.code.add(`${e.outVariableType.padEnd(10)} ${e.node.type.padEnd(9)} ${e.outVariableName};`))}t.vertex.code.add(""),t.vertex.code.add("void main() {"),t.vertex.code.add(" "+this.body.split("\n").join("\n "));for(const e of this.rootOutputNodes())this.shouldPruneOutputNode(e)||t.vertex.code.add(` ${e.outVariableName} = ${e.variableName};`);t.vertex.code.add("}")}insertFragmentShader(t){this._insertInputs(t,"fragment"),t.fragment.code.add(""),t.fragment.code.add("void main() {"),t.fragment.code.add(" "+this.body.split("\n").join("\n "));for(const e of this.rootOutputNodes())"discard"===e.outVariableType?(t.fragment.code.add(" // TODO: Should ensure codegen for discard appears first in fragment shader"),t.fragment.code.add(` if (${e.variableName}) {`),t.fragment.code.add(" discard;"),t.fragment.code.add(" }"),t.fragment.code.add(" ")):t.fragment.code.add(` ${e.outVariableName} = ${e.variableName};`);t.fragment.code.add("}")}_insertInputs(t,e){t[e].code.add("// INPUTS: "),t[e].code.add("// --------------------------------------------------------- ");for(const s of this.inputs())s.isUsed&&"builtin"!==s.variableInputType&&("array"===s.node.type?t[e].code.add(`${s.variableInputType.padEnd(10)} ${s.node.elementType.type.padEnd(9)} ${s.variableName}[${s.node.size}];`):t[e].code.add(`${s.variableInputType.padEnd(10)} ${s.node.type.padEnd(9)} ${s.variableName};`))}}var to=s(58820),eo=s(94460),so=s(72008);const io=()=>C.c.getLogger("geoscene.views.webgl.BufferObject");class ro{static createIndex(t,e,s){return new ro(t,pi.K.ELEMENT_ARRAY_BUFFER,e,s)}static createVertex(t,e,s){return new ro(t,pi.K.ARRAY_BUFFER,e,s)}static createUniform(t,e,s){return new ro(t,pi.K.UNIFORM_BUFFER,e,s)}static createPixelPack(t,e=pi._m.STREAM_READ,s){const i=new ro(t,pi.K.PIXEL_PACK_BUFFER,e);return s&&i.setSize(s),i}static createPixelUnpack(t,e=pi._m.STREAM_DRAW,s){return new ro(t,pi.K.PIXEL_UNPACK_BUFFER,e,s)}static createTransformFeedback(t,e=pi._m.STATIC_DRAW,s){const i=new ro(t,pi.K.TRANSFORM_FEEDBACK_BUFFER,e);return i.setSize(s),i}constructor(t,e,s,i){this._context=t,this.bufferType=e,this.usage=s,this._glName=null,this._size=-1,this._indexType=void 0,t.instanceCounter.increment(pi.y4.BufferObject,this),this._glName=this._context.gl.createBuffer(),(0,eo.m_)(this._context.gl),i&&this.setData(i)}get glName(){return this._glName}get size(){return this._size}get indexType(){return this._indexType}get usedMemory(){return this.bufferType===pi.K.ELEMENT_ARRAY_BUFFER?this._indexType===pi.Ck.UNSIGNED_INT?4*this._size:2*this._size:this._size}get _isVAOAware(){return this.bufferType===pi.K.ELEMENT_ARRAY_BUFFER||this.bufferType===pi.K.ARRAY_BUFFER}dispose(){this._context?.gl?(this._glName&&(this._context.gl.deleteBuffer(this._glName),this._glName=null),this._context.instanceCounter.decrement(pi.y4.BufferObject,this),this._context=null):this._glName&&io().warn("Leaked WebGL buffer object")}setSize(t,e=null){if(t<=0&&io().error("Buffer size needs to be positive!"),this.bufferType===pi.K.ELEMENT_ARRAY_BUFFER&&null!=e)switch(this._indexType=e,e){case pi.Ck.UNSIGNED_SHORT:t*=2;break;case pi.Ck.UNSIGNED_INT:t*=4}this._setBufferData(t)}setData(t){if(!t)return;let e=t.byteLength;this.bufferType===pi.K.ELEMENT_ARRAY_BUFFER&&((0,so.Qx)(t)&&(e/=2,this._indexType=pi.Ck.UNSIGNED_SHORT),(0,so.Nt)(t)&&(e/=4,this._indexType=pi.Ck.UNSIGNED_INT)),this._setBufferData(e,t)}_setBufferData(t,e=null){this._size=t;const s=this._context.getBoundVAO();this._isVAOAware&&this._context.bindVAO(null),this._context.bindBuffer(this);const i=this._context.gl;null!=e?i.bufferData(this.bufferType,e,this.usage):i.bufferData(this.bufferType,t,this.usage),(0,eo.m_)(i),this._isVAOAware&&this._context.bindVAO(s)}setSubData(t,e,s,i){if(!t)return;(e<0||e*t.BYTES_PER_ELEMENT>=this.usedMemory)&&io().error("offset is out of range!"),s>=i&&io().error("end must be bigger than start!"),(e+(i-s))*t.BYTES_PER_ELEMENT>this.usedMemory&&io().error("An attempt to write beyond the end of the buffer!");const r=this._context.getBoundVAO();this._isVAOAware&&this._context.bindVAO(null),this._context.bindBuffer(this);const{gl:n}=this._context;n.bufferSubData(this.bufferType,e*t.BYTES_PER_ELEMENT,t,s,i-s),(0,eo.m_)(n),this._isVAOAware&&this._context.bindVAO(r)}getSubData(t,e=0,s,i){if(s<0||i<0)return void io().error("Problem getting subdata: offset and length were less than zero!");const r=function(t){return(0,tt.GQ)(t)}(t)?t.BYTES_PER_ELEMENT:1;if(r*((s??0)+(i??0))>t.byteLength)return void io().error("Problem getting subdata: offset and length exceeded destination size!");e+r*(i??0)>this.usedMemory&&io().warn("Potential problem getting subdata: requested data exceeds buffer size!");const n=this._context.gl;this.bufferType===pi.K.TRANSFORM_FEEDBACK_BUFFER?(this._context.bindBuffer(this,pi.K.TRANSFORM_FEEDBACK_BUFFER),n.getBufferSubData(pi.K.TRANSFORM_FEEDBACK_BUFFER,e,t,s,i),this._context.unbindBuffer(pi.K.TRANSFORM_FEEDBACK_BUFFER)):(this._context.bindBuffer(this,pi.K.COPY_READ_BUFFER),n.getBufferSubData(pi.K.COPY_READ_BUFFER,e,t,s,i),this._context.unbindBuffer(pi.K.COPY_READ_BUFFER))}async getSubDataAsync(t,e=0,s,i){await this._context.clientWaitAsync(),this.getSubData(t,e,s,i)}}var no=s(39104),oo=s(97684);class ao{constructor(t,e){this._context=t,this._descriptor=e,this.type=no.A.RenderBuffer,this._context.instanceCounter.increment(pi.y4.Renderbuffer,this);const s=this._context.gl;this.glName=s.createRenderbuffer(),this._context.bindRenderbuffer(this);const{width:i,height:r,internalFormat:n,multisampled:o}=e;o?s.renderbufferStorageMultisample(s.RENDERBUFFER,this.samples,n,i,r):s.renderbufferStorage(s.RENDERBUFFER,n,i,r)}get descriptor(){return this._descriptor}get samples(){const t=this._descriptor.samples,e=this._context.parameters.maxSamples;return t?Math.min(t,e):e}get usedMemory(){return function(t){return t.width<=0||t.height<=0||null==t.internalFormat?0:t.width*t.height*(0,oo.O4)(t.internalFormat)}(this._descriptor)}resize(t,e){const s=this._descriptor;if(s.width===t&&s.height===e)return;s.width=t,s.height=e;const i=this._context.gl;this._context.bindRenderbuffer(this),s.multisampled?i.renderbufferStorageMultisample(i.RENDERBUFFER,this.samples,s.internalFormat,s.width,s.height):i.renderbufferStorage(i.RENDERBUFFER,s.internalFormat,s.width,s.height)}dispose(){this._context&&(this._context.gl.deleteRenderbuffer(this.glName),this._context.instanceCounter.decrement(pi.y4.Renderbuffer,this),this._context=null)}}var ho=s(22184);class co{constructor(t,e,s=null){this._context=t,this._glName=null,this._colorAttachments=new Map,this._depthStencilBuffer=null,this._depthStencilTexture=null,this._initialized=!1,t.instanceCounter.increment(pi.y4.FramebufferObject,this);const i=lo(e)?e:new ho.w(this._context,e);if(this._colorAttachments.set(pi.Qx.COLOR_ATTACHMENT0,i),this._validateTextureDescriptor(i.descriptor),this._validateColorAttachmentPoint(pi.Qx.COLOR_ATTACHMENT0),null!=s)if(function(t){return lo(t)||null!=t&&"pixelFormat"in t}(s))this._context.capabilities.depthTexture||console.error("Setting the depth/stencil texture as an attachment requires WEBGL_depth_texture or WebGL2"),this._depthStencilTexture=lo(s)?s:new ho.w(this._context,s),this._validateTextureDescriptor(this._depthStencilTexture.descriptor);else{const t=function(t){return null!=t&&"type"in t&&t.type===no.A.RenderBuffer}(s)?s:new ao(this._context,s);this._depthStencilBuffer=t,this._validateRenderBufferDescriptor(t.descriptor)}}dispose(){if(0===this._colorAttachments.size&&!this._glName)return;const t=this._context.getBoundFramebufferObject();this._colorAttachments.forEach(((t,e)=>this.detachColorTexture(e)?.dispose())),this.detachDepthStencilBuffer()?.dispose(),this.detachDepthStencilTexture()?.dispose(),this._glName&&(this._context.gl.deleteFramebuffer(this._glName),this._glName=null),this._context.bindFramebuffer(t),this._context.instanceCounter.decrement(pi.y4.FramebufferObject,this)}get glName(){return this._glName}get colorTexture(){return this._colorAttachments.get(pi.Qx.COLOR_ATTACHMENT0)}get depthStencil(){return this._depthStencilTexture||this._depthStencilBuffer}get depthStencilTexture(){return this._depthStencilTexture}get width(){const t=this._colorAttachments.get(pi.Qx.COLOR_ATTACHMENT0);return t?.descriptor?.width??0}get height(){const t=this._colorAttachments.get(pi.Qx.COLOR_ATTACHMENT0);return t?.descriptor?.height??0}get usedMemory(){return[...this._colorAttachments].reduce(((t,[e,s])=>t+s.usedMemory),this.depthStencil?.usedMemory??0)}getColorTexture(t){const e=this._colorAttachments.get(t);return e&&lo(e)?e:null}get colorAttachments(){return[...this._colorAttachments.keys()]}attachColorTexture(t,e=pi.Qx.COLOR_ATTACHMENT0){if(!t)return;this._validateColorAttachmentPoint(e);const s=t.descriptor;this._validateTextureDescriptor(s),this.detachColorTexture(e)?.dispose(),this._initialized&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(t.glName,e)),this._colorAttachments.set(e,t)}detachColorTexture(t=pi.Qx.COLOR_ATTACHMENT0){const e=this._colorAttachments.get(t);if(e){if(this._initialized){const e=this._context.getBoundFramebufferObject();this._context.bindFramebuffer(this),this._framebufferTexture2D(null,t),this._context.bindFramebuffer(e)}return this._colorAttachments.delete(t),e}}setColorTextureTarget(t,e=pi.Qx.COLOR_ATTACHMENT0){const s=this._colorAttachments.get(e);s&&this._framebufferTexture2D(s.glName,e,t)}attachDepthStencil(t){if(t)switch(t.type){case no.A.Texture:return this._attachDepthStencilTexture(t);case no.A.RenderBuffer:return this._attachDepthStencilBuffer(t)}}_attachDepthStencilTexture(t){if(null==t)return;const e=t.descriptor;e.pixelFormat!==pi.Id.DEPTH_STENCIL&&e.pixelFormat!==pi.Id.DEPTH24_STENCIL8&&console.error("Depth/Stencil texture must have a pixel type of DEPTH_STENCIL!"),e.dataType!==pi.OK.UNSIGNED_INT_24_8&&console.error("Depth/Stencil texture must have data type of UNSIGNED_INT_24_8!"),this._context.capabilities.depthTexture||console.error("Extension WEBGL_depth_texture isn't supported therefore it is no possible to set the depth/stencil texture!"),this._validateTextureDescriptor(e),this._disposeDepthStencilAttachments(),this._initialized&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(t.glName,pi.GE)),this._depthStencilTexture?.dispose(),this._depthStencilTexture=t}detachDepthStencilTexture(){const t=this._depthStencilTexture;return t&&this._initialized&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(null,pi.GE)),this._depthStencilTexture=null,t}_attachDepthStencilBuffer(t){if(null==t)return;const e=t.descriptor;if(this._validateRenderBufferDescriptor(e),this._disposeDepthStencilAttachments(),this._initialized){this._context.bindFramebuffer(this);const s=this._context.gl,i=this._getGLAttachmentPoint(e);s.framebufferRenderbuffer(pi.kl.FRAMEBUFFER,i,s.RENDERBUFFER,t.glName)}this._depthStencilBuffer=t}detachDepthStencilBuffer(){const t=this._depthStencilBuffer;if(t&&this._initialized){this._context.bindFramebuffer(this);const e=this._context.gl,s=this._getGLAttachmentPoint(t.descriptor);e.framebufferRenderbuffer(pi.kl.FRAMEBUFFER,s,e.RENDERBUFFER,null)}return this._depthStencilBuffer=null,t}copyToTexture(t,e,s,i,r,n,o){(t<0||e<0||r<0||n<0)&&console.error("Offsets cannot be negative!"),(s<=0||i<=0)&&console.error("Copy width and height must be greater than zero!");const a=o.descriptor;o.descriptor.target!==pi.c5.TEXTURE_2D&&console.error("Texture target must be TEXTURE_2D!"),(null==a?.width||null==a?.height||t+s>this.width||e+i>this.height||r+s>a.width||n+i>a.height)&&console.error("Bad dimensions, the current input values will attempt to read or copy out of bounds!");const h=this._context,c=h.bindTexture(o,ho.w.TEXTURE_UNIT_FOR_UPDATES);h.setActiveTexture(ho.w.TEXTURE_UNIT_FOR_UPDATES),h.bindFramebuffer(this),h.gl.copyTexSubImage2D(pi.c5.TEXTURE_2D,0,r,n,t,e,s,i),h.bindTexture(c,ho.w.TEXTURE_UNIT_FOR_UPDATES)}readPixels(t,e,s,i,r,n,o){(s<=0||i<=0)&&console.error("Copy width and height must be greater than zero!"),o||console.error("Target memory is not initialized!"),this._context.bindFramebuffer(this),this._context.gl.readPixels(t,e,s,i,r,n,o)}async readPixelsAsync(t,e,s,i,r,n,o){const{gl:a}=this._context,h=ro.createPixelPack(this._context,pi._m.STREAM_READ,o.byteLength);this._context.bindBuffer(h),this._context.bindFramebuffer(this),a.readPixels(t,e,s,i,r,n,0),this._context.unbindBuffer(pi.K.PIXEL_PACK_BUFFER),await h.getSubDataAsync(o),h.dispose()}resize(t,e){if(this.width===t&&this.height===e)return;const s={width:t,height:e};uo(s,this._context.parameters.maxTextureSize),this._colorAttachments.forEach((t=>t.resize(s.width,s.height))),this._depthStencilTexture?.resize(s.width,s.height),this._initialized&&(uo(s,this._context.parameters.maxRenderbufferSize),this._depthStencilBuffer?.resize(s.width,s.height),this._context.getBoundFramebufferObject()===this&&this._context.bindFramebuffer(null),this._initialized=!1)}initializeAndBind(t=pi.kl.FRAMEBUFFER){const e=this._context.gl;if(this._initialized)return void e.bindFramebuffer(t,this.glName);this._glName&&e.deleteFramebuffer(this._glName);const s=e.createFramebuffer();if(e.bindFramebuffer(t,s),this._colorAttachments.forEach(((e,s)=>this._framebufferTexture2D(e.glName,s,po(e),t))),this._depthStencilBuffer){const s=this._getGLAttachmentPoint(this._depthStencilBuffer.descriptor);e.framebufferRenderbuffer(t,s,e.RENDERBUFFER,this._depthStencilBuffer.glName)}else this._depthStencilTexture&&this._framebufferTexture2D(this._depthStencilTexture.glName,e.DEPTH_STENCIL_ATTACHMENT,po(this._depthStencilTexture),t);(0,eo.gv)()&&e.checkFramebufferStatus(t)!==e.FRAMEBUFFER_COMPLETE&&console.error("Framebuffer is incomplete!"),this._glName=s,this._initialized=!0}_framebufferTexture2D(t,e=pi.Qx.COLOR_ATTACHMENT0,s=pi.c5.TEXTURE_2D,i=pi.kl.FRAMEBUFFER,r=0){this._context.gl.framebufferTexture2D(i,e,s,t,r)}_disposeDepthStencilAttachments(){const t=this._context.gl;if(this._depthStencilBuffer){if(this._initialized){this._context.bindFramebuffer(this);const e=this._getGLAttachmentPoint(this._depthStencilBuffer.descriptor);t.framebufferRenderbuffer(pi.kl.FRAMEBUFFER,e,t.RENDERBUFFER,null)}this._depthStencilBuffer=(0,M.yI)(this._depthStencilBuffer)}this._depthStencilTexture&&(this._initialized&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(null,t.DEPTH_STENCIL_ATTACHMENT)),this._depthStencilTexture=(0,M.yI)(this._depthStencilTexture))}_validateTextureDescriptor(t){t.target!==pi.c5.TEXTURE_2D&&t.target!==pi.c5.TEXTURE_CUBE_MAP&&console.error("Texture type must be TEXTURE_2D or TEXTURE_CUBE_MAP!"),uo(t,this._context.parameters.maxTextureSize),this._validateBufferDimensions(t)}_validateRenderBufferDescriptor(t){uo(t,this._context.parameters.maxRenderbufferSize),this._validateBufferDimensions(t)}_validateBufferDimensions(t){t.width<=0&&(t.width=this.width),t.height<=0&&(t.height=this.height),this.width>0&&this.height>0&&(this.width===t.width&&this.height===t.height||console.error("Attachment size must match framebuffer size!"))}_getGLAttachmentPoint(t){switch(t.internalFormat){case pi.Qb.DEPTH_COMPONENT16:case pi.Qb.DEPTH_COMPONENT24:case pi.Qb.DEPTH_COMPONENT32F:return this._context.gl.DEPTH_ATTACHMENT;case pi.Qb.DEPTH24_STENCIL8:case pi.Qb.DEPTH32F_STENCIL8:case pi.Qb.DEPTH_STENCIL:return this._context.gl.DEPTH_STENCIL_ATTACHMENT;case pi.Qb.STENCIL_INDEX8:return this._context.gl.STENCIL_ATTACHMENT}}_validateColorAttachmentPoint(t){if(-1===co._MAX_COLOR_ATTACHMENTS){const{gl:t}=this._context;co._MAX_COLOR_ATTACHMENTS=t.getParameter(t.MAX_COLOR_ATTACHMENTS)}const e=t-pi.Qx.COLOR_ATTACHMENT0;e+1>co._MAX_COLOR_ATTACHMENTS&&C.c.getLogger("geoscene.views.webgl.FrameBufferObject").error("geoscene.FrameBufferObject",`illegal attachment point for color attachment: ${e+1}. Implementation supports up to ${co._MAX_COLOR_ATTACHMENTS} color attachments`)}}function lo(t){return null!=t&&"type"in t&&t.type===no.A.Texture}function uo(t,e){const s=Math.max(t.width,t.height);if(s>e){C.c.getLogger("geoscene.views.webgl.FramebufferObject").warn(`Resizing FBO attachment size ${t.width}x${t.height} to device limit ${e}`);const i=e/s;return t.width=Math.round(t.width*i),t.height=Math.round(t.height*i),!1}return!0}function po(t){return t.descriptor.target===pi.c5.TEXTURE_CUBE_MAP?pi.c5.TEXTURE_CUBE_MAP_POSITIVE_X:pi.c5.TEXTURE_2D}co._MAX_COLOR_ATTACHMENTS=-1;const _o=["layout","centroid","smooth","case","mat2x2","mat2x3","mat2x4","mat3x2","mat3x3","mat3x4","mat4x2","mat4x3","mat4x4","uint","uvec2","uvec3","uvec4","samplerCubeShadow","sampler2DArray","sampler2DArrayShadow","isampler2D","isampler3D","isamplerCube","isampler2DArray","usampler2D","usampler3D","usamplerCube","usampler2DArray","coherent","restrict","readonly","writeonly","resource","atomic_uint","noperspective","patch","sample","subroutine","common","partition","active","filter","image1D","image2D","image3D","imageCube","iimage1D","iimage2D","iimage3D","iimageCube","uimage1D","uimage2D","uimage3D","uimageCube","image1DArray","image2DArray","iimage1DArray","iimage2DArray","uimage1DArray","uimage2DArray","image1DShadow","image2DShadow","image1DArrayShadow","image2DArrayShadow","imageBuffer","iimageBuffer","uimageBuffer","sampler1DArray","sampler1DArrayShadow","isampler1D","isampler1DArray","usampler1D","usampler1DArray","isampler2DRect","usampler2DRect","samplerBuffer","isamplerBuffer","usamplerBuffer","sampler2DMS","isampler2DMS","usampler2DMS","sampler2DMSArray","isampler2DMSArray","usampler2DMSArray","trunc","round","roundEven","isnan","isinf","floatBitsToInt","floatBitsToUint","intBitsToFloat","uintBitsToFloat","packSnorm2x16","unpackSnorm2x16","packUnorm2x16","unpackUnorm2x16","packHalf2x16","unpackHalf2x16","outerProduct","transpose","determinant","inverse","texture","textureSize","textureProj","textureLod","textureOffset","texelFetch","texelFetchOffset","textureProjOffset","textureLodOffset","textureProjLod","textureProjLodOffset","textureGrad","textureGradOffset","textureProjGrad","textureProjGradOffset"],fo=!1;var mo,go=s(8528),yo={exports:{}};void 0!==(mo=["precision","highp","mediump","lowp","attribute","const","uniform","varying","break","continue","do","for","while","if","else","in","out","inout","float","int","void","bool","true","false","discard","return","mat2","mat3","mat4","vec2","vec3","vec4","ivec2","ivec3","ivec4","bvec2","bvec3","bvec4","sampler1D","sampler2D","sampler3D","samplerCube","sampler1DShadow","sampler2DShadow","struct","asm","class","union","enum","typedef","template","this","packed","goto","switch","default","inline","noinline","volatile","public","static","extern","external","interface","long","short","double","half","fixed","unsigned","input","output","hvec2","hvec3","hvec4","dvec2","dvec3","dvec4","fvec2","fvec3","fvec4","sampler2DRect","sampler3DRect","sampler2DRectShadow","sizeof","cast","namespace","using"])&&(yo.exports=mo);const xo=(0,go.g)(yo.exports);var bo,wo={exports:{}};void 0!==(bo=["<<=",">>=","++","--","<<",">>","<=",">=","==","!=","&&","||","+=","-=","*=","/=","%=","&=","^^","^=","|=","(",")","[","]",".","!","~","*","/","%","+","-","<",">","&","^","|","?",":","=",",",";","{","}"])&&(wo.exports=bo);const vo=(0,go.g)(wo.exports);var So={exports:{}};!function(t){!function(e){var s=["abs","acos","all","any","asin","atan","ceil","clamp","cos","cross","dFdx","dFdy","degrees","distance","dot","equal","exp","exp2","faceforward","floor","fract","gl_BackColor","gl_BackLightModelProduct","gl_BackLightProduct","gl_BackMaterial","gl_BackSecondaryColor","gl_ClipPlane","gl_ClipVertex","gl_Color","gl_DepthRange","gl_DepthRangeParameters","gl_EyePlaneQ","gl_EyePlaneR","gl_EyePlaneS","gl_EyePlaneT","gl_Fog","gl_FogCoord","gl_FogFragCoord","gl_FogParameters","gl_FragColor","gl_FragCoord","gl_FragData","gl_FragDepth","gl_FragDepthEXT","gl_FrontColor","gl_FrontFacing","gl_FrontLightModelProduct","gl_FrontLightProduct","gl_FrontMaterial","gl_FrontSecondaryColor","gl_LightModel","gl_LightModelParameters","gl_LightModelProducts","gl_LightProducts","gl_LightSource","gl_LightSourceParameters","gl_MaterialParameters","gl_MaxClipPlanes","gl_MaxCombinedTextureImageUnits","gl_MaxDrawBuffers","gl_MaxFragmentUniformComponents","gl_MaxLights","gl_MaxTextureCoords","gl_MaxTextureImageUnits","gl_MaxTextureUnits","gl_MaxVaryingFloats","gl_MaxVertexAttribs","gl_MaxVertexTextureImageUnits","gl_MaxVertexUniformComponents","gl_ModelViewMatrix","gl_ModelViewMatrixInverse","gl_ModelViewMatrixInverseTranspose","gl_ModelViewMatrixTranspose","gl_ModelViewProjectionMatrix","gl_ModelViewProjectionMatrixInverse","gl_ModelViewProjectionMatrixInverseTranspose","gl_ModelViewProjectionMatrixTranspose","gl_MultiTexCoord0","gl_MultiTexCoord1","gl_MultiTexCoord2","gl_MultiTexCoord3","gl_MultiTexCoord4","gl_MultiTexCoord5","gl_MultiTexCoord6","gl_MultiTexCoord7","gl_Normal","gl_NormalMatrix","gl_NormalScale","gl_ObjectPlaneQ","gl_ObjectPlaneR","gl_ObjectPlaneS","gl_ObjectPlaneT","gl_Point","gl_PointCoord","gl_PointParameters","gl_PointSize","gl_Position","gl_ProjectionMatrix","gl_ProjectionMatrixInverse","gl_ProjectionMatrixInverseTranspose","gl_ProjectionMatrixTranspose","gl_SecondaryColor","gl_TexCoord","gl_TextureEnvColor","gl_TextureMatrix","gl_TextureMatrixInverse","gl_TextureMatrixInverseTranspose","gl_TextureMatrixTranspose","gl_Vertex","greaterThan","greaterThanEqual","inversesqrt","length","lessThan","lessThanEqual","log","log2","matrixCompMult","max","min","mix","mod","normalize","not","notEqual","pow","radians","reflect","refract","sign","sin","smoothstep","sqrt","step","tan","texture2D","texture2DLod","texture2DProj","texture2DProjLod","textureCube","textureCubeLod","texture2DLodEXT","texture2DProjLodEXT","textureCubeLodEXT","texture2DGradEXT","texture2DProjGradEXT","textureCubeGradEXT","textureSize","texelFetch"];void 0!==s&&(t.exports=s)}()}(So);const Io=(0,go.g)(So.exports);var To=999,Po=9999,Mo=0,Eo=1,Co=2,ko=3,Fo=4,Ao=5,Ro=6,Oo=7,No=8,Do=9,zo=10,Lo=11,Bo=["block-comment","line-comment","preprocessor","operator","integer","float","ident","builtin","keyword","whitespace","eof","integer"];function Uo(t){return function(t){var e=function(){var t,e,s,i=0,r=0,n=To,o=[],a=[],h=1,c=0,l=0,u=!1,d=!1,p="";return function(t){return a=[],null!==t?f(t.replace?t.replace(/\r\n/g,"\n"):t):(o.length&&_(o.join("")),n=zo,_("(eof)"),a)};function _(t){t.length&&a.push({type:Bo[n],data:t,position:l,line:h,column:c})}function f(e){var o;for(i=0,s=(p+=e).length;t=p[i],i<s;){switch(o=i,n){case Mo:i=x();break;case Eo:case Co:i=y();break;case ko:i=b();break;case Fo:i=S();break;case Lo:i=v();break;case Ao:i=I();break;case Po:i=T();break;case Do:i=g();break;case To:i=m()}o!==i&&("\n"===p[o]?(c=0,++h):++c)}return r+=i,p=p.slice(i),a}function m(){return o=o.length?[]:o,"/"===e&&"*"===t?(l=r+i-1,n=Mo,e=t,i+1):"/"===e&&"/"===t?(l=r+i-1,n=Eo,e=t,i+1):"#"===t?(n=Co,l=r+i,i):/\s/.test(t)?(n=Do,l=r+i,i):(u=/\d/.test(t),d=/[^\w_]/.test(t),l=r+i,n=u?Fo:d?ko:Po,i)}function g(){return/[^\s]/g.test(t)?(_(o.join("")),n=To,i):(o.push(t),e=t,i+1)}function y(){return"\r"!==t&&"\n"!==t||"\\"===e?(o.push(t),e=t,i+1):(_(o.join("")),n=To,i)}function x(){return"/"===t&&"*"===e?(o.push(t),_(o.join("")),n=To,i+1):(o.push(t),e=t,i+1)}function b(){if("."===e&&/\d/.test(t))return n=Ao,i;if("/"===e&&"*"===t)return n=Mo,i;if("/"===e&&"/"===t)return n=Eo,i;if("."===t&&o.length){for(;w(o););return n=Ao,i}if(";"===t||")"===t||"("===t){if(o.length)for(;w(o););return _(t),n=To,i+1}var s=2===o.length&&"="!==t;if(/[\w_\d\s]/.test(t)||s){for(;w(o););return n=To,i}return o.push(t),e=t,i+1}function w(t){for(var e,s,i=0;;){if(e=vo.indexOf(t.slice(0,t.length+i).join("")),s=vo[e],-1===e){if(i--+t.length>0)continue;s=t.slice(0,1).join("")}return _(s),l+=s.length,(o=o.slice(s.length)).length}}function v(){return/[^a-fA-F0-9]/.test(t)?(_(o.join("")),n=To,i):(o.push(t),e=t,i+1)}function S(){return"."===t||/[eE]/.test(t)?(o.push(t),n=Ao,e=t,i+1):"x"===t&&1===o.length&&"0"===o[0]?(n=Lo,o.push(t),e=t,i+1):/[^\d]/.test(t)?(_(o.join("")),n=To,i):(o.push(t),e=t,i+1)}function I(){return"f"===t&&(o.push(t),e=t,i+=1),/[eE]/.test(t)||"-"===t&&/[eE]/.test(e)?(o.push(t),e=t,i+1):/[^\d]/.test(t)?(_(o.join("")),n=To,i):(o.push(t),e=t,i+1)}function T(){if(/[^\d\w_]/.test(t)){var s=o.join("");return n=xo.indexOf(s)>-1?No:Io.indexOf(s)>-1?Oo:Ro,_(o.join("")),n=To,i}return o.push(t),e=t,i+1}}(),s=[];return(s=s.concat(e(t))).concat(e(null))}(t)}const Go=new Set(["GL_OES_standard_derivatives","GL_EXT_frag_depth","GL_EXT_draw_buffers","GL_EXT_shader_texture_lod"]);function Vo(t,e){for(let s=e-1;s>=0;s--){const e=t[s];if("whitespace"!==e.type&&"block-comment"!==e.type){if("keyword"!==e.type)break;if("attribute"===e.data||"in"===e.data)return!0}}return!1}function qo(t,e,s,i){i=i||s;for(const r of t)if("ident"===r.type&&r.data===s)return i in e?e[i]++:e[i]=0,qo(t,e,i+"_"+e[i],i);return s}function Wo(t,e,s="afterVersion"){function i(t,e){for(let s=e;s<t.length;s++){const e=t[s];if("operator"===e.type&&";"===e.data)return s}return null}const r={data:"\n",type:"whitespace"},n=e=>e<t.length&&/[^\r\n]$/.test(t[e].data);let o=function(t){let e=-1,r=0,n=-1;for(let o=0;o<t.length;o++){const a=t[o];if("preprocessor"===a.type&&(/\#(if|ifdef|ifndef)\s+.+/.test(a.data)?++r:/\#endif\s*.*/.test(a.data)&&--r),"afterVersion"!==s&&"afterPrecision"!==s||"preprocessor"===a.type&&a.data.startsWith("#version")&&(n=Math.max(n,o)),"afterPrecision"===s&&"keyword"===a.type&&"precision"===a.data){const e=i(t,o);if(null===e)throw new Error("precision statement not followed by any semicolons!");n=Math.max(n,e)}e<n&&0===r&&(e=o)}return e+1}(t);n(o-1)&&t.splice(o++,0,r);for(const s of e)t.splice(o++,0,s);n(o-1)&&n(o)&&t.splice(o,0,r)}function Xo(t,e,s,i="lowp"){Wo(t,[{type:"keyword",data:"out"},{type:"whitespace",data:" "},{type:"keyword",data:i},{type:"whitespace",data:" "},{type:"keyword",data:s},{type:"whitespace",data:" "},{type:"ident",data:e},{type:"operator",data:";"}],"afterPrecision")}function Yo(t,e,s,i,r="lowp"){Wo(t,[{type:"keyword",data:"layout"},{type:"operator",data:"("},{type:"keyword",data:"location"},{type:"whitespace",data:" "},{type:"operator",data:"="},{type:"whitespace",data:" "},{type:"integer",data:i.toString()},{type:"operator",data:")"},{type:"whitespace",data:" "},{type:"keyword",data:"out"},{type:"whitespace",data:" "},{type:"keyword",data:r},{type:"whitespace",data:" "},{type:"keyword",data:s},{type:"whitespace",data:" "},{type:"ident",data:e},{type:"operator",data:";"}],"afterPrecision")}function jo(t,e){let s,i,r=-1;for(let n=e;n<t.length;n++){const e=t[n];if("operator"===e.type&&("["===e.data&&(s=n),"]"===e.data)){i=n;break}"integer"===e.type&&(r=parseInt(e.data,10))}return s&&i&&t.splice(s,i-s+1),r}function Ho(t,e){if(t.startsWith("#version 300"))return t;const s=function(t){return fo?$o.get(t):null}(t);if(null!=s)return s;const i=Uo(t);if("300 es"===function(t,e="100",s="300 es"){const i=/^\s*\#version\s+([0-9]+(\s+[a-zA-Z]+)?)\s*/;for(const r of t)if("preprocessor"===r.type){const t=i.exec(r.data);if(t){const i=t[1].replaceAll(/\s\s+/g," ");if(i===s)return i;if(i===e)return r.data="#version "+s,e;throw new Error("unknown glsl version: "+i)}}return t.splice(0,0,{type:"preprocessor",data:"#version "+s},{type:"whitespace",data:"\n"}),null}(i,"100","300 es"))return t;let r=null,n=null;const o={},a={};for(let t=0;t<i.length;++t){const s=i[t];switch(s.type){case"keyword":e===pi.Gs.VERTEX_SHADER&&"attribute"===s.data?s.data="in":"varying"===s.data&&(s.data=e===pi.Gs.VERTEX_SHADER?"out":"in");break;case"builtin":if(/^texture(2D|Cube)(Proj)?(Lod|Grad)?(EXT)?$/.test(s.data.trim())&&(s.data=s.data.replaceAll(/(2D|Cube|EXT)/g,"")),e===pi.Gs.FRAGMENT_SHADER&&"gl_FragColor"===s.data&&(r||(r=qo(i,o,"fragColor"),Xo(i,r,"vec4")),s.data=r),e===pi.Gs.FRAGMENT_SHADER&&"gl_FragData"===s.data){const e=jo(i,t+1),r=qo(i,o,"fragData");Yo(i,r,"vec4",e,"mediump"),s.data=r}else e===pi.Gs.FRAGMENT_SHADER&&"gl_FragDepthEXT"===s.data&&(n||(n=qo(i,o,"gl_FragDepth")),s.data=n);break;case"ident":if(_o.includes(s.data)){if(e===pi.Gs.VERTEX_SHADER&&Vo(i,t))throw new Error("attribute in vertex shader uses a name that is a reserved word in glsl 300 es");s.data in a||(a[s.data]=qo(i,o,s.data)),s.data=a[s.data]}}}for(let t=i.length-1;t>=0;--t){const e=i[t];if("preprocessor"===e.type){const s=e.data.match(/\#extension\s+(.*)\:/);if(s&&s[1]&&Go.has(s[1].trim())){const e=i[t+1];i.splice(t,e&&"whitespace"===e.type?2:1)}const r=e.data.match(/\#ifdef\s+(.*)/);r&&r[1]&&Go.has(r[1].trim())&&(e.data="#if 1");const n=e.data.match(/\#ifndef\s+(.*)/);n&&n[1]&&Go.has(n[1].trim())&&(e.data="#if 0")}}return function(t,e){return fo&&$o.set(t,e),e}(t,function(t){return t.map((t=>"eof"!==t.type?t.data:"")).join("")}(i))}const $o=new Map;class Ko{constructor(t,e,s,i,r=new Map,n=[]){this._context=t,this._locations=i,this._uniformBlockBindings=r,this._transformFeedbackVaryings=n,this._refCount=1,this._compiled=!1,this._linesOfCode=0,this._nameToUniformLocation=new Map,this._nameToUniform1=new Map,this._nameToUniform1v=new Map,this._nameToUniform2=new Map,this._nameToUniform3=new Map,this._nameToUniform4=new Map,this._nameToUniformMatrix3=new Map,this._nameToUniformMatrix4=new Map,t||console.error("RenderingContext isn't initialized!"),0===e.length&&console.error("Shaders source should not be empty!"),e=Ho(e,pi.Gs.VERTEX_SHADER),s=Ho(s,pi.Gs.FRAGMENT_SHADER),this._vShader=Zo(this._context,pi.Gs.VERTEX_SHADER,e),this._fShader=Zo(this._context,pi.Gs.FRAGMENT_SHADER,s),Jo.enabled&&(this._linesOfCode=e.match(/\n/g).length+s.match(/\n/g).length+2,this._context.instanceCounter.increment(pi.y4.LinesOfCode,this._vShader,this._linesOfCode)),this._vShader&&this._fShader||console.error("Error loading shaders!"),this._context.instanceCounter.increment(pi.y4.Shader,this),(0,eo.E5)()&&(this.vertexShader=e,this.fragmentShader=s),this.usedMemory=e.length+s.length;const o=this._context.gl,a=o.createProgram();o.attachShader(a,this._vShader),o.attachShader(a,this._fShader),this._locations.forEach(((t,e)=>o.bindAttribLocation(a,t,e))),this._transformFeedbackVaryings?.length&&o.transformFeedbackVaryings(a,this._transformFeedbackVaryings,o.SEPARATE_ATTRIBS),o.linkProgram(a),(0,eo.E5)()&&!o.getProgramParameter(a,o.LINK_STATUS)&&console.error(`Could not link shader\nvalidated: ${o.getProgramParameter(a,o.VALIDATE_STATUS)}, gl error ${o.getError()}, vertex: ${o.getShaderParameter(this._vShader,o.COMPILE_STATUS)}, fragment: ${o.getShaderParameter(this._fShader,o.COMPILE_STATUS)}, info log: ${o.getProgramInfoLog(a)}, vertex source: ${this.vertexShader}, fragment source: ${this.fragmentShader}`);for(const[t,e]of this._uniformBlockBindings){const s=o.getUniformBlockIndex(a,t);s<4294967295&&o.uniformBlockBinding(a,s,e)}this._glName=a,this._context.instanceCounter.increment(pi.y4.Program,this)}get glName(){return this._glName}get hasGLName(){return null!=this._glName}get hasTransformFeedbackVaryings(){return!!this._transformFeedbackVaryings?.length}get compiled(){if(this._compiled)return!0;const t=this._context.gl.getExtension("KHR_parallel_shader_compile");return null==t||null==this.glName?(this._compiled=!0,!0):(this._compiled=!!this._context.gl.getProgramParameter(this.glName,t.COMPLETION_STATUS_KHR),this._compiled)}dispose(){if(--this._refCount>0)return;const t=this._context.gl,e=this._context.instanceCounter;this._nameToUniformLocation.forEach((t=>t&&e.decrement(pi.y4.Uniform,t))),this._nameToUniformLocation.clear(),this._vShader&&(this._linesOfCode>0&&(e.decrement(pi.y4.LinesOfCode,this._vShader,this._linesOfCode),this._linesOfCode=0),t.deleteShader(this._vShader),this._vShader=null,e.decrement(pi.y4.Shader,this)),this._fShader&&(t.deleteShader(this._fShader),this._fShader=null),this._glName&&(t.deleteProgram(this._glName),this._glName=null,e.decrement(pi.y4.Program,this))}ref(){++this._refCount}_getUniformLocation(t){const e=this._nameToUniformLocation.get(t);if(void 0!==e)return e;if(this.glName){const e=this._context.gl.getUniformLocation(this.glName,t);return this._nameToUniformLocation.set(t,e),e&&this._context.instanceCounter.increment(pi.y4.Uniform,e),e}return null}hasUniform(t){return null!=this._getUniformLocation(t)}setUniform1i(t,e){const s=this._nameToUniform1.get(t);void 0!==s&&e===s||(this._context.gl.uniform1i(this._getUniformLocation(t),e),this._nameToUniform1.set(t,e))}setUniform1iv(t,e){Qo(this._nameToUniform1v,t,e)&&this._context.gl.uniform1iv(this._getUniformLocation(t),e)}setUniform2iv(t,e){Qo(this._nameToUniform2,t,e)&&this._context.gl.uniform2iv(this._getUniformLocation(t),e)}setUniform3iv(t,e){Qo(this._nameToUniform3,t,e)&&this._context.gl.uniform3iv(this._getUniformLocation(t),e)}setUniform4iv(t,e){Qo(this._nameToUniform4,t,e)&&this._context.gl.uniform4iv(this._getUniformLocation(t),e)}setUniform1f(t,e){const s=this._nameToUniform1.get(t);void 0!==s&&e===s||(this._context.gl.uniform1f(this._getUniformLocation(t),e),this._nameToUniform1.set(t,e))}setUniform1fv(t,e){Qo(this._nameToUniform1v,t,e)&&this._context.gl.uniform1fv(this._getUniformLocation(t),e)}setUniform2f(t,e,s){const i=this._nameToUniform2.get(t);void 0===i?(this._context.gl.uniform2f(this._getUniformLocation(t),e,s),this._nameToUniform2.set(t,[e,s])):e===i[0]&&s===i[1]||(this._context.gl.uniform2f(this._getUniformLocation(t),e,s),i[0]=e,i[1]=s)}setUniform2fv(t,e){Qo(this._nameToUniform2,t,e)&&this._context.gl.uniform2fv(this._getUniformLocation(t),e)}setUniform3f(t,e,s,i){const r=this._nameToUniform3.get(t);void 0===r?(this._context.gl.uniform3f(this._getUniformLocation(t),e,s,i),this._nameToUniform3.set(t,[e,s,i])):e===r[0]&&s===r[1]&&i===r[2]||(this._context.gl.uniform3f(this._getUniformLocation(t),e,s,i),r[0]=e,r[1]=s,r[2]=i)}setUniform3fv(t,e){const s=this._getUniformLocation(t);null!=s&&Qo(this._nameToUniform3,t,e)&&this._context.gl.uniform3fv(s,e)}setUniform4f(t,e,s,i,r){const n=this._nameToUniform4.get(t);void 0===n?(this._context.gl.uniform4f(this._getUniformLocation(t),e,s,i,r),this._nameToUniform4.set(t,[e,s,i,r])):void 0!==n&&e===n[0]&&s===n[1]&&i===n[2]&&r===n[3]||(this._context.gl.uniform4f(this._getUniformLocation(t),e,s,i,r),n[0]=e,n[1]=s,n[2]=i,n[3]=r)}setUniform4fv(t,e){const s=this._getUniformLocation(t);null!=s&&Qo(this._nameToUniform4,t,e)&&this._context.gl.uniform4fv(s,e)}setUniformMatrix3fv(t,e,s=!1){const i=this._getUniformLocation(t);null!=i&&Qo(this._nameToUniformMatrix3,t,e)&&this._context.gl.uniformMatrix3fv(i,s,e)}setUniformMatrix4fv(t,e,s=!1){const i=this._getUniformLocation(t);null!=i&&Qo(this._nameToUniformMatrix4,t,e)&&this._context.gl.uniformMatrix4fv(i,s,e)}stop(){}}function Zo(t,e,s){const i=t.gl,r=i.createShader(e);return i.shaderSource(r,s),i.compileShader(r),(0,eo.E5)()&&!i.getShaderParameter(r,i.COMPILE_STATUS)&&(console.error("Compile error in ".concat(e===pi.Gs.VERTEX_SHADER?"vertex":"fragment"," shader")),console.error(i.getShaderInfoLog(r)),console.error(function(t){let e=2;return t.replaceAll("\n",(()=>"\n"+function(t){return t>=1e3?t.toString():(" "+t).slice(-3)}(e++)+":"))}(s))),r}function Qo(t,e,s){const i=t.get(e);if(!i)return t.set(e,Array.from(s)),!0;const r=s.length;if(i.length!==r)return t.set(e,Array.from(s)),!0;for(let t=0;t<r;++t){const e=s[t];if(i[t]!==e){for(i[t]=e;t<r;++t)i[t]=s[t];return!0}}return!1}const Jo={enabled:!1};s(2944);var ta=s(51576);function ea(t,e,s){const i=new ta.O(e.width,e.height);return i.dataType=e.dataType,e.depth&&(i.depth=e.depth),e.flipped&&(i.flipped=e.flipped),e.hasMipmap&&(i.hasMipmap=e.hasMipmap),i.internalFormat=e.internalFormat,e.isImmutable&&(i.isImmutable=e.isImmutable),e.isOpaque&&(i.isOpaque=e.isOpaque),e.maxAnisotropy&&(i.maxAnisotropy=e.maxAnisotropy),i.pixelFormat=e.pixelFormat,e.preMultiplyAlpha&&(i.preMultiplyAlpha=e.preMultiplyAlpha),e.samplingMode&&(i.samplingMode=e.samplingMode),e.target&&(i.target=e.target),i.uniform=e.uniform,e.unpackAlignment&&(i.unpackAlignment=e.unpackAlignment),e.wrapMode&&(i.wrapMode=e.wrapMode),new ho.w(t,i,s)}function sa(t,e,s){const r=e.length;if(r!==s){const n=new i.c("Invalid Uniform",`Invalid length, expected ${s} but got ${r}`,{uniformName:t,values:e});C.c.getLogger("geoscene.views.2d.engine.webgl.shaderGraph.typed.TypedShaderProgram").errorOnce(n)}}new Map;class ia{constructor(t,e,s,i,r,n){this._program=null,this._vao=null,this._temporaryTextures=[],this.vertexShader=t,this.fragmentShader=e,this._locations=s,this._locationInfo=i,this._uniformBindings=r,this._transformFeedbackBindings=n}destroy(){this._program&&this._program.dispose(),this.cleanupTemporaryTextures()}get locations(){return this._locations}get locationInfo(){return this._locationInfo}setUniforms(t){this._uniforms=t}cleanupTemporaryTextures(){for(const t of this._temporaryTextures)t.dispose();this._temporaryTextures=[]}bind(t){const e=this._uniforms;if(!this._program){const e=new Map;for(const[t,s]of this._locations)e.set(t,s);const s=[];for(const t of this._transformFeedbackBindings??[]){const{index:e,propertyKey:i}=t;s[e]=`v_${i}`}this._program=new Ko(t,this.vertexShader,this.fragmentShader,e,new Map,s)}const s=this._program;t.useProgram(s);for(const i of this._uniformBindings){const{shaderModulePath:r,uniformName:n,uniformType:o,uniformArrayLength:a}=i,h=(0,to.YT)(r,e);if(null==h){if("sampler2D"===o)continue;throw new Error(`Failed to find uniform value for ${r}`)}switch("array"===o?i.uniformArrayElementType:o){case"sampler2D":{const{unit:e,texture:i}=h;if(s.setUniform1i(n,e),"type"in i)t.bindTexture(i,e);else{const s=ea(t,i.descriptor,i.data);t.bindTexture(s,e)}break}case"int":if(!a){s.setUniform1i(n,h);break}sa(i.uniformName,h,a),s.setUniform1iv(n,h);break;case"float":if(!a){s.setUniform1f(n,h);break}sa(i.uniformName,h,a),s.setUniform1fv(n,h);break;case"vec2":if(!a){s.setUniform2f(n,h[0],h[1]);break}sa(i.uniformName,h,a),s.setUniform2fv(n,h.flat());break;case"vec3":if(!a){s.setUniform3f(n,h[0],h[1],h[2]);break}sa(i.uniformName,h,a),s.setUniform3fv(n,h.flat());break;case"vec4":if(!a){s.setUniform4f(n,h[0],h[1],h[2],h[3]);break}sa(i.uniformName,h,a),s.setUniform4fv(n,h.flat());break;case"mat3":s.setUniformMatrix3fv(n,h.flat());break;case"mat4":s.setUniformMatrix4fv(n,h.flat());break;default:throw new Error(`Unable to set uniform for type ${o}`)}}}}function ra(t){return new t}function na(t,e,s){const i=t.constructor[e]??[];t.constructor.hasOwnProperty(e)||Object.defineProperty(t.constructor,e,{value:i.slice()}),t.constructor[e].push(s)}function oa(t,e){return(s,i)=>{na(s,"locations",{typeCtor:e,propertyKey:i,parameterIndex:null,index:t})}}const aa=t=>(e,s,i)=>{na(e,"inputs",{inputCtor:t,propertyKey:s,parameterIndex:i})},ha=t=>(e,s)=>{na(e,"uniforms",{typeCtor:t,propertyKey:s})},ca=t=>(e,s)=>{na(e,"options",{typeCtor:t,propertyKey:s})},la=(t,e)=>{na(t,"defines",{propertyKey:e})},ua=(t,e)=>(s,i)=>{s.constructor.builtins.push({builtin:t,propertyKey:i,typeCtor:e})};class da{}da.builtins=[],(0,T._)([ua("gl_VertexID",en)],da.prototype,"glVertexID",void 0);class pa{}class _a{}_a.builtins=[],(0,T._)([ua("gl_FragCoord",Xr)],_a.prototype,"glFragCoord",void 0),(0,T._)([ua("gl_PointCoord",qr)],_a.prototype,"glPointCoord",void 0);class fa{}(0,T._)([(t,e)=>{na(t,"builtins",{builtin:"gl_FragColor",propertyKey:e})}],fa.prototype,"glFragColor",void 0);class ma{constructor(){this.type="uniform-group"}get _uniforms(){return this.constructor.uniforms??[]}}class ga{constructor(){this.logShader=!1,this.computeAttributes={}}get vertexInput(){const t=(0,tt.mk)(this._shaderModuleClass.inputs,(t=>"vertex"===t.propertyKey&&0===t.parameterIndex));if(!t)throw new Error("Unable to find vertex input parameter");return t}get computeInput(){return(0,tt.mk)(this._shaderModuleClass.inputs,(t=>"vertex"===t.propertyKey&&1===t.parameterIndex))}get fragmentInput(){const t=(0,tt.mk)(this._shaderModuleClass.inputs,(t=>"fragment"===t.propertyKey));if(!t)throw new Error("Unable to find fragment input parameter");return t}get transformFeedbackBindings(){return this.fragmentInput.inputCtor.transformFeedbackBindings??[]}get locations(){return[...this.vertexInput.inputCtor.locations,...this.computeInput?.inputCtor.locations??[]]}get locationsMap(){const t=new Map,e=new Set;for(const s of this.locations)e.has(s.index)?C.c.getLogger("geoscene.views.2d.engine.webgl.shaderGraph.GraphShaderModule").warnOnce("mapview-rendering",`Unable to assigned attribute ${s.propertyKey} to ${s.index}. Index already in use`,{locationsMap:t}):(t.set(s.propertyKey,s.index),e.add(s.index));return t}get locationInfo(){if(!this._locationInfo){const t=this.locationsMap,e=Array.from(t.entries()).map((([t,e])=>`${t}.${e}`)).join("."),s=(0,st.sV)(e);this._locationInfo={hash:s,locations:t}}return this._locationInfo}get renamedLocationsMap(){const t=new Map;for(const e of this.locations)t.set("a_"+e.propertyKey,e.index);return t}get optionPropertyKeys(){if(!this._optionPropertyKeys){const t=new Set;for(const e of this._options)t.add(e.propertyKey);this._optionPropertyKeys=t}return this._optionPropertyKeys}get _shaderModuleClass(){return this.constructor}get _defines(){return this._shaderModuleClass.defines??[]}get _options(){return this._shaderModuleClass.options??[]}get _uniforms(){return this._shaderModuleClass.uniforms??[]}getProgram(t,e,s,i){try{const{vertex:r,fragment:n,uniformBindings:o}=this._generateShaders(t,e,s,i);return new ia(r,n,this.renamedLocationsMap,this.locationInfo,o,this.transformFeedbackBindings)}catch(t){return console.error("Failed to create program",{error:t}),new ia("","",this.renamedLocationsMap,this.locationInfo,[],this.transformFeedbackBindings)}}getDebugUniformClassInfo(t){const e=this._options.find((e=>e.propertyKey===t));if(e)return{type:"option",className:e.typeCtor};const s=this._uniforms.find((e=>e.propertyKey===t));if(!s)throw new Error(`Unable to find uniform class type for property: ${t}`);return{type:"required",className:s.typeCtor}}getShaderKey(t,e,s,i){const r=Object.keys(s).map((t=>`${t}.${s[t]}`)).join("."),n=Object.keys(i).map((t=>`${t}.${i[t]}`)).join("."),o=Object.keys(e).filter((t=>this.optionPropertyKeys.has(t)&&e[t])).join(".");return`${this.constructor.name}.${t.hash}.${r}.${n}.${o}`}_generateShaders(t,e,s,i){const r=[];this._setDefines(s),this._setOptionalUniforms(r,e),this._setRequiredUniforms(r);const n=this._hydrateVertexInput(i),o=this._injectPackPrecisionFactor(n,t),a=this._hydrateComputeInput(),h=a&&this._injectPackPrecisionFactor(a,t),c=this.vertex(o,h),l=this._hydrateFragmentInput(c),u=this.fragment(l),d=new Set;for(const t in u)_r(d,u[t]);const p=this._getVertexInputBuiltins(),_=Jn.createVertex({...n,...a},c,p,r,this.transformFeedbackBindings,d);(new Kn).write(_);const f=this._getFragmentInputBuiltins(u);f.set("glPointCoord","gl_PointCoord");const m=Jn.createFragment(l,u,f,r,_,this.transformFeedbackBindings);(new Kn).write(m);const g=this._createShaderBuilder(_,m),y=g.generate("vertex",!1),x=g.generate("fragment",!1);return this.logShader&&(console.log(y),console.log(x)),{vertex:y,fragment:x,uniformBindings:r}}_setDefines(t){for(const e in t)this[e]=t[e]}_setOptionalUniforms(t,e){for(const s of this._options)e[s.propertyKey]?this[s.propertyKey]=this._hydrateUniformGroup(t,s):this[s.propertyKey]=null}_setRequiredUniforms(t){for(const e of this._uniforms)this[e.propertyKey]=this._hydrateUniformGroup(t,e)}_hydrateUniformGroup(t,e){const s=new(0,e.typeCtor);for(const i of s._uniforms??[]){const r=ra(i.typeCtor),n=`u_${e.propertyKey}_${i.propertyKey}`,o=r.type,a=[e.propertyKey,i.propertyKey].join(".");if("type"in i.typeCtor&&"array"===i.typeCtor.type){const e=r;t.push({shaderModulePath:a,uniformName:n,uniformType:o,uniformArrayLength:e.size,uniformArrayElementType:e.elementType.type,uniformHydrated:r})}else t.push({shaderModulePath:a,uniformName:n,uniformType:o,uniformHydrated:r});s[i.propertyKey]=r}return s}_hydrateVertexInput(t){const e=this.vertexInput.inputCtor,s=e.locations.reduce(((e,s)=>!1===t[s.propertyKey]?e:{...e,[s.propertyKey]:ra(s.typeCtor)}),{});for(const{propertyKey:t,typeCtor:i}of e.builtins){const e=ra(i);s[t]=e}return s}_hydrateComputeInput(){return null==this.computeInput?null:this.computeInput.inputCtor.locations.reduce(((t,e)=>({...t,[e.propertyKey]:ra(e.typeCtor)})),{})}_injectPackPrecisionFactor(t,e){const s={};for(const i in t){const r=t[i],n=e.attributes.find((t=>t.name===i));if(n?.packPrecisionFactor){if("float"!==r.type&&"vec2"!==r.type&&"vec3"!==r.type&&"vec4"!==r.type)throw new Error(`InternalError: packPrecisionFactor requires GenType, but found ${r.type}`);s[i]=r.divide(new Vr(n.packPrecisionFactor))}else s[i]=r}return s}_hydrateFragmentInput(t){const e={};for(const s in t)e[s]=t[s];for(const{propertyKey:t,typeCtor:s}of _a.builtins){const i=ra(s);e[t]=i}return e}_getVertexInputBuiltins(){const t=this.vertexInput.inputCtor,e=new Map;for(const{builtin:s,propertyKey:i}of t.builtins)e.set(i,s);return e}_getFragmentInputBuiltins(t){const e=t.constructor,s=new Map;for(const t of e.builtins??[])s.set(t.propertyKey,t.builtin);return s}_createShaderBuilder(t,e){const s=new nr;return this._insertDebugInfo(s),t.insertVertexShader(s),e.insertFragmentShader(s),s}_insertDebugInfo(t){t.vertex.code.add("// DEFINES: "),t.vertex.code.add("// --------------------------------------------------------- ");for(const e of this._defines)this[e.propertyKey]?t.vertex.code.add(`// ${e.propertyKey}: true`):t.vertex.code.add(`// ${e.propertyKey}: false`);t.vertex.code.add(""),t.vertex.code.add("// OPTIONS: "),t.vertex.code.add("// --------------------------------------------------------- ");for(const e of this._options)this[e.propertyKey]?t.vertex.code.add(`// ${e.propertyKey}: true`):t.vertex.code.add(`// ${e.propertyKey}: false`)}}let ya=class extends P.c{constructor(){super(...arguments),this.color=new wi.c([0,255,255]),this.haloOpacity=1,this.fillOpacity=.25,this.multiHighlightEnabled=!1}equals(t){return this.color.equals(t.color)&&(this.haloColor||this.color).equals(t.haloColor||t.color)&&this.haloOpacity===t.haloOpacity&&this.fillOpacity===t.fillOpacity&&this.multiHighlightEnabled===t.multiHighlightEnabled}};(0,T._)([(0,E.qq)({type:wi.c})],ya.prototype,"color",void 0),(0,T._)([(0,E.qq)({type:wi.c})],ya.prototype,"haloColor",void 0),(0,T._)([(0,E.qq)()],ya.prototype,"haloOpacity",void 0),(0,T._)([(0,E.qq)()],ya.prototype,"fillOpacity",void 0),(0,T._)([(0,E.qq)()],ya.prototype,"multiHighlightEnabled",void 0),ya=(0,T._)([(0,k.c)("geoscene.views.2d.support.HighlightOptions")],ya);const xa=ya,ba={selection:t=>new xa({color:new wi.c([t.color.r/2,t.color.g/2,t.color.b/2,t.color.a])}),highlight:t=>t,popup:t=>new xa({color:new wi.c([t.color.g,t.color.b,t.color.r,t.color.a])})},wa=Object.keys(ba);function va(t){const e=un(12.9898),s=un(78.233),i=un(43758.5453);return Bn(Yn(Wn(Ln(t,dn(e,s)),un(3.14))).multiply(i))}function Sa(t){return En(t,un(Bi))}function Ia(t,e){const s=un(2**e);return Wn(function(t){return gn("floor",t)}(t.divide(s)),un(2))}function Ta(t,e){return Ia(t,e+wa.length)}class Pa extends ma{getVisualVariableData(t){if(!this._vvData){const e=this.getAttributeDataCoords(t);this._vvData=Hn(this.visualVariableData,e).setDebugName("storage2")}return this._vvData}getAttributeDataCoords(t){if(!this._uv){const e=function(t){const e=Ia(t.z,7),s=un(1).subtract(e),i=t.xyz.subtract(((...t)=>new Wr(...t))(0,0,un(128)));return s.multiply(t).add(e.multiply(i))}(t),s=this.size,i=ln(e.x),r=ln(e.y).multiply(ln(256)),n=ln(e.z).multiply(ln(256)).multiply(ln(256)),o=un(i.add(r).add(n)),a=Wn(o,s),h=o.subtract(a).divide(s);this._uv=new qr(a,h).add(.5).divide(s)}return this._uv}getFilterData(t){const e=this.getAttributeDataCoords(t);return Hn(this.filterFlags,e).setDebugName("storage0")}getAnimationData(t){const e=this.getAttributeDataCoords(t);return Hn(this.animation,e).setDebugName("storage1")}getVVData(t){return this.getVisualVariableData(t)}getDataDrivenData0(t){const e=this.getAttributeDataCoords(t);return Hn(this.dataDriven0,e).setDebugName("storage30")}getDataDrivenData1(t){const e=this.getAttributeDataCoords(t);return Hn(this.dataDriven1,e).setDebugName("storage31")}getDataDrivenData2(t){const e=this.getAttributeDataCoords(t);return Hn(this.dataDriven2,e).setDebugName("storage32")}getGPGPUData(t){const e=this.getAttributeDataCoords(t);return Hn(this.gpgpu,e).setDebugName("storage4")}getFilterFlags(t){return(0,n.c)("webgl-ignores-sampler-precision")?function(t){return gn("ceil",t)}(this.getFilterData(t).x.multiply(un(255))):this.getFilterData(t).x.multiply(un(255))}getAnimationValue(t){return this.getAnimationData(t).x}getSizeValue(t){return this.getVisualVariableData(t).x}getColorValue(t){return this.getVisualVariableData(t).y}getOpacityValue(t){return this.getVisualVariableData(t).z}getRotationValue(t){return this.getVisualVariableData(t).w}}(0,T._)([ha(Gr)],Pa.prototype,"filterFlags",void 0),(0,T._)([ha(Gr)],Pa.prototype,"animation",void 0),(0,T._)([ha(Gr)],Pa.prototype,"gpgpu",void 0),(0,T._)([ha(Gr)],Pa.prototype,"visualVariableData",void 0),(0,T._)([ha(Gr)],Pa.prototype,"dataDriven0",void 0),(0,T._)([ha(Gr)],Pa.prototype,"dataDriven1",void 0),(0,T._)([ha(Gr)],Pa.prototype,"dataDriven2",void 0),(0,T._)([ha(Vr)],Pa.prototype,"size",void 0);class Ma extends ma{}(0,T._)([ha(Vr)],Ma.prototype,"activeReasons",void 0),(0,T._)([ha(Vr)],Ma.prototype,"highlightAll",void 0);class Ea extends ma{}(0,T._)([ha(qr)],Ea.prototype,"position",void 0),(0,T._)([ha(Vr)],Ea.prototype,"distance",void 0),(0,T._)([ha(Vr)],Ea.prototype,"smallSymbolDistance",void 0),(0,T._)([ha(Vr)],Ea.prototype,"smallSymbolSizeThreshold",void 0);class Ca extends ma{}(0,T._)([ha(an)],Ca.prototype,"displayViewScreenMat3",void 0),(0,T._)([ha(an)],Ca.prototype,"displayViewMat3",void 0),(0,T._)([ha(an)],Ca.prototype,"displayMat3",void 0),(0,T._)([ha(an)],Ca.prototype,"viewMat3",void 0),(0,T._)([ha(an)],Ca.prototype,"tileMat3",void 0),(0,T._)([ha(Vr)],Ca.prototype,"displayZoomFactor",void 0),(0,T._)([ha(Vr)],Ca.prototype,"requiredZoomFactor",void 0),(0,T._)([ha(qr)],Ca.prototype,"tileOffset",void 0),(0,T._)([ha(Vr)],Ca.prototype,"currentScale",void 0),(0,T._)([ha(Vr)],Ca.prototype,"currentZoom",void 0),(0,T._)([ha(Vr)],Ca.prototype,"metersPerSRUnit",void 0),(0,T._)([ha(Vr)],Ca.prototype,"rotation",void 0),(0,T._)([ha(Vr)],Ca.prototype,"pixelRatio",void 0);class ka extends da{}(0,T._)([oa(0,Wr)],ka.prototype,"id",void 0),(0,T._)([oa(1,Vr)],ka.prototype,"bitset",void 0),(0,T._)([oa(2,qr)],ka.prototype,"pos",void 0);class Fa extends pa{}(0,T._)([oa(14,qr)],Fa.prototype,"nextPos1",void 0),(0,T._)([oa(15,qr)],Fa.prototype,"nextPos2",void 0);class Aa extends _a{}class Ra extends ga{clip(t,e){let s=new Vr(0);const i=this.storage.getFilterFlags(t);if(s=s.add(un(2).multiply(un(1).subtract(Ta(i,0)))),this.inside?s=s.add(un(2).multiply(un(1).subtract(Ta(i,1)))):this.outside?s=s.add(un(2).multiply(Ta(i,1))):this.highlight&&(s=s.add(un(2).multiply(un(1).subtract(this._checkHighlight(i))))),null!=e){const t=new Vr(1).subtract(jn(e.x,this.view.currentZoom)),i=jn(e.y,this.view.currentZoom);s=s.add(new Vr(2).multiply(t.add(i)))}return s}getFragmentOutput(t,e,s=new Vr(1/255)){const i=new fa;return i.glFragColor=this._maybeWriteHittest(e)??this._maybeHighlight(t,s)??t,i}_maybeHighlight(t,e){return this.highlight?new Xr(t.rgb,jn(e,t.a)):null}_checkHighlight(t){let e=this._checkHighlightBit(t,0);for(let s=1;s<wa.length;s++)e=e.add(this._checkHighlightBit(t,s));return jn(new Vr(.1),e.add(this.highlight.highlightAll))}_checkHighlightBit(t,e){return function(t,e){return Ia(t,e)}(t,e).multiply(Ia(this.highlight.activeReasons,e))}maybeRunHittest(t,e,s){if(null==this.hittestRequest)return null;let i=vn(kn(this.hittest(t,e,s),this.hittestRequest.distance),new Vr(2),new Vr(0));const r=function(t){return t.multiply(2).subtract(1)}(this.storage.getAttributeDataCoords(t.id));i=i.add(this.clip(t.id,t.zoomRange));const n=new Xr(new Vr(1/255),0,0,0);return{glPointSize:new Vr(1),glPosition:new Xr(r,i,1),color:n}}_maybeWriteHittest(t){return null!=this.hittestRequest?t.color:null}}function Oa(t,e,s){const i=s.subtract(e),r=Dn(function(t,e){return Ln(t,function(t){return gn("normalize",t)}(e))}(t.subtract(e),i).divide(Un(i)),new Vr(0),new Vr(1));return function(t,e){return yn("distance",t,e,Vr)}(t,e.add(r.multiply(s.subtract(e))))}function Na(t,e,s,i){return En(function(t){const e=function(t){return gn("abs",t)}(t);return jn(e.x.add(e.y).add(e.z),new Vr(1.05))}(function(t,e,s,i){const r=new an(s.x.multiply(i.y).subtract(i.x.multiply(s.y)),i.x.multiply(e.y).subtract(e.x.multiply(i.y)),e.x.multiply(s.y).subtract(s.x.multiply(e.y)),s.y.subtract(i.y),i.y.subtract(e.y),e.y.subtract(s.y),i.x.subtract(s.x),e.x.subtract(i.x),s.x.subtract(e.x)),n=e.x.multiply(s.y.subtract(i.y)),o=s.x.multiply(i.y.subtract(e.y)),a=i.x.multiply(e.y.subtract(s.y)),h=n.add(o).add(a);return new Vr(1).divide(h).multiply(r.multiply(new Wr(1,t)))}(t,e,s,i)),new Vr(1))}function Da(t){return t.distance.add(1)}function za(t,e,s){const{viewMat3:i,tileMat3:r}=t.view,n=i.multiply(r),o=n.multiply(new Wr(e.pos,1)),a=n.multiply(new Wr(s.nextPos1,1)),h=n.multiply(new Wr(s.nextPos2,1));return function(t,e,s,i){const r=function(t,e){return t.x.multiply(e.y).subtract(e.x.multiply(t.y))}(s.subtract(e),i.subtract(e)),n=Rn(function(t,e){return mn("<",t,e,Kr)}(r,new Vr(Li)),kn(r,new Vr(-Li)));return Sn([Rn(Xn(n),Na(t.xy,e,s,i)),new Vr(-1)],[!0,()=>{const r=Oa(t,e,s),n=Oa(t,s,i),o=Oa(t,i,e);return Vn(Vn(r,n),o)}])}(t.hittestRequest.position,o.xy,a.xy,h.xy)}(0,T._)([la],Ra.prototype,"inside",void 0),(0,T._)([la],Ra.prototype,"outside",void 0),(0,T._)([ca(Ma)],Ra.prototype,"highlight",void 0),(0,T._)([ha(Pa)],Ra.prototype,"storage",void 0),(0,T._)([ha(Ca)],Ra.prototype,"view",void 0),(0,T._)([ca(Ea)],Ra.prototype,"hittestRequest",void 0);class La extends ma{getColor(t,e,s){return Sn([An(Sa(t),s),e],[Cn(t,this.values.first()),this.colors.first()],[Fn(t,this.values.last()),this.colors.last()],[!0,()=>{const e=this.values.findIndex((e=>kn(e,t))),s=this.values.get(e),i=e.subtract(1),r=this.values.get(i),n=t.subtract(r).divide(s.subtract(r));return qn(this.colors.get(i),this.colors.get(e),n)}])}}(0,T._)([ha(Ur.ofType(Xr,8))],La.prototype,"colors",void 0),(0,T._)([ha(Ur.ofType(Vr,8))],La.prototype,"values",void 0);class Ba extends ma{getOpacity(t){return Sn([Sa(t),new Vr(1)],[Cn(t,this.opacityValues.first()),this.opacities.first()],[Fn(t,this.opacityValues.last()),this.opacities.last()],[!0,()=>{const e=this.opacityValues.findIndex((e=>kn(e,t))),s=this.opacityValues.get(e),i=e.subtract(1),r=this.opacityValues.get(i),n=t.subtract(r).divide(s.subtract(r));return qn(this.opacities.get(i),this.opacities.get(e),n)}])}}function Ua(t){return null!=t.visualVariableSizeMinMaxValue||null!=t.visualVariableSizeScaleStops||null!=t.visualVariableSizeStops||null!=t.visualVariableSizeUnitValue}function Ga(t,e,s,i=new Kr(!1)){if(null==t.visualVariableColor)return s;const r=t.storage.getColorValue(e);return t.visualVariableColor.getColor(r,s,i)}function Va(t,e){if(null==t.visualVariableOpacity)return new Vr(1);const s=t.storage.getOpacityValue(e);return t.visualVariableOpacity.getOpacity(s)}(0,T._)([ha(Ur.ofType(Vr,8))],Ba.prototype,"opacities",void 0),(0,T._)([ha(Ur.ofType(Vr,8))],Ba.prototype,"opacityValues",void 0);class qa extends ka{}(0,T._)([oa(3,Xr)],qa.prototype,"color",void 0),(0,T._)([oa(4,qr)],qa.prototype,"zoomRange",void 0);class Wa extends Ra{constructor(){super(...arguments),this.computeAttributes={pos:["nextPos1","nextPos2"]}}vertex(t,e){const s=Va(this,t.id),i=Ga(this,t.id,t.color).multiply(s),r=this.view.displayViewScreenMat3.multiply(new Wr(t.pos.xy,1)),n=this.clip(t.id,t.zoomRange);return{glPosition:new Xr(r.xy,n,1),color:i,...this.maybeRunHittest(t,e,null)}}fragment(t){return this.getFragmentOutput(t.color,t,new Vr(0))}hittest(t,e){return za(this,t,e)}}(0,T._)([ca(La)],Wa.prototype,"visualVariableColor",void 0),(0,T._)([ca(Ba)],Wa.prototype,"visualVariableOpacity",void 0),(0,T._)([(0,T.a)(0,aa(qa)),(0,T.a)(1,aa(Fa))],Wa.prototype,"vertex",null),(0,T._)([(0,T.a)(0,aa(Aa))],Wa.prototype,"fragment",null);class Xa extends ma{getPatternOffsetAtTileOrigin(t,e=new Vr(0),s=new Vr(1)){const i=new qr(16777216).divide(t);let r=t.multiply(Bn(this.maxIntsToLocalOrigin.multiply(i))).add(this.tileOffsetFromLocalOrigin).subtract(new Vr(.5).multiply(t));return r=new qr(r.x.multiply(s).subtract(r.y.multiply(e)),r.x.multiply(e).add(r.y.multiply(s))),Wn(r,t)}}(0,T._)([ha(qr)],Xa.prototype,"tileOffsetFromLocalOrigin",void 0),(0,T._)([ha(qr)],Xa.prototype,"maxIntsToLocalOrigin",void 0);class Ya extends ma{}(0,T._)([ha(qr)],Ya.prototype,"size",void 0),(0,T._)([ha(Gr)],Ya.prototype,"texture",void 0);class ja extends qa{}function Ha(t,e){const s=qn(new qr(1),new qr(1/B.Q0),new qr(Ia(e.bitset,6),Ia(e.bitset,5))),i=t.view.requiredZoomFactor,r=new qr(e.width,e.height).multiply(s),n=r.multiply(e.scale).multiply(i),o=e.angle.multiply(.024543692606171875),a=Yn(o),h=zn(o),c=function(t,e,s,i,r){const n=En(Ia(r,Ui),un(1)),o=function(t){return Ln(t,pn(255/256,255/65536,255/16777216,255/4294967296))}(new Xr(t,0));return vn(n,_n(i.divide(e.x),s.divide(e.y),0,bn(s.divide(e.x)),i.divide(e.y),0,va(dn(o,0)),va(dn(0,o)),1),_n(i.divide(e.x),s.divide(e.y),0,bn(s.divide(e.x)),i.divide(e.y),0,0,0,1))}(e.id,n,a,h,e.bitset),l=t.localTileOffset.getPatternOffsetAtTileOrigin(r,a,h),u=i.multiply(e.scale).multiply(e.offset.subtract(l)).divide(n),d=new Wr(e.pos,1),p=c.multiply(d).xy.subtract(u),_=e.tlbr.divide(t.mosaicInfo.size.xyxy);let f=Ia(e.bitset,4);return null!=t.visualVariableColor&&(f=vn(Sa(t.storage.getColorValue(e.id)),new Vr(0),f)),{tileTextureCoord:p,tlbr:_,sampleAlphaOnly:f}}function $a(t,e){const s=Wn(e.tileTextureCoord,new Vr(1)),i=qn(e.tlbr.xy,e.tlbr.zw,s);let r=Hn(t.mosaicInfo.texture,i);return r=vn(kn(e.sampleAlphaOnly,new Vr(.5)),r.aaaa,r),e.color.multiply(r)}(0,T._)([oa(5,Xr)],ja.prototype,"tlbr",void 0),(0,T._)([oa(6,Vr)],ja.prototype,"width",void 0),(0,T._)([oa(7,Vr)],ja.prototype,"height",void 0),(0,T._)([oa(8,qr)],ja.prototype,"offset",void 0),(0,T._)([oa(9,qr)],ja.prototype,"scale",void 0),(0,T._)([oa(10,Vr)],ja.prototype,"angle",void 0);class Ka extends Wa{vertex(t,e){return{...super.vertex(t,e),...Ha(this,t)}}fragment(t){const e=$a(this,t);return this.getFragmentOutput(e,t,new Vr(0))}}(0,T._)([ha(Ya)],Ka.prototype,"mosaicInfo",void 0),(0,T._)([ha(Xa)],Ka.prototype,"localTileOffset",void 0),(0,T._)([(0,T.a)(0,aa(ja)),(0,T.a)(1,aa(Fa))],Ka.prototype,"vertex",null),(0,T._)([(0,T.a)(0,aa(class extends Aa{}))],Ka.prototype,"fragment",null);class Za extends ma{getSize(t,e){const s=this.minMaxValueAndSize.xy,i=this.minMaxValueAndSize.zw;return vn(Sa(t),e,(()=>{const e=Dn(t.subtract(s.x).divide(s.y.subtract(s.x)),new Vr(0),new Vr(1));return i.x.add(e.multiply(i.y.subtract(i.x)))}))}}(0,T._)([ha(Xr)],Za.prototype,"minMaxValueAndSize",void 0);class Qa extends ma{getSizeForViewScale(t){return Sn([Cn(t,this.values.first()),this.sizes.first()],[Fn(t,this.values.last()),this.sizes.last()],[!0,()=>{const e=this.values.findIndex((e=>kn(e,t))),s=this.values.get(e),i=e.subtract(1),r=this.values.get(i),n=t.subtract(r).divide(s.subtract(r));return qn(this.sizes.get(i),this.sizes.get(e),n)}])}}(0,T._)([ha(Ur.ofType(Vr,8))],Qa.prototype,"sizes",void 0),(0,T._)([ha(Ur.ofType(Vr,8))],Qa.prototype,"values",void 0);class Ja extends ma{getSize(t,e){const s=Sn([Sa(t),e],[Cn(t,this.values.first()),this.sizes.first()],[Fn(t,this.values.last()),this.sizes.last()],[!0,()=>{const e=this.values.findIndex((e=>kn(e,t))),s=this.values.get(e),i=e.subtract(1),r=this.values.get(i),n=t.subtract(r).divide(s.subtract(r));return qn(this.sizes.get(i),this.sizes.get(e),n)}]);return vn(Sa(s),e,s)}}(0,T._)([ha(Ur.ofType(Vr,8))],Ja.prototype,"sizes",void 0),(0,T._)([ha(Ur.ofType(Vr,8))],Ja.prototype,"values",void 0);class th extends ma{getSize(t,e){return vn(Sa(t),e,t.multiply(this.unitValueToPixelsRatio))}}(0,T._)([ha(Vr)],th.prototype,"unitValueToPixelsRatio",void 0);class eh extends ka{}(0,T._)([oa(3,Xr)],eh.prototype,"color",void 0),(0,T._)([oa(4,qr)],eh.prototype,"offset",void 0),(0,T._)([oa(5,qr)],eh.prototype,"normal",void 0),(0,T._)([oa(6,Vr)],eh.prototype,"halfWidth",void 0),(0,T._)([oa(7,Vr)],eh.prototype,"referenceHalfWidth",void 0),(0,T._)([oa(8,qr)],eh.prototype,"zoomRange",void 0);class sh extends Aa{}class ih extends ma{}function rh(t){return Gn(new Vr(Ni).multiply(jn(t,new Vr(Di))),new Vr(1))}function nh(t,e){const{id:s,offset:i,pos:r,normal:n,zoomRange:o}=e,{displayViewScreenMat3:a,displayViewMat3:h}=t.view,c=Ga(t,s,e.color),l=Va(t,s),u=function(t,e){const{id:s,halfWidth:i,referenceHalfWidth:r}=e;if(Ua(t)){const e=function(t,e,s){if(Ua(t)){const i=t.storage.getSizeValue(e);return t.visualVariableSizeMinMaxValue?.getSize(i,s)??t.visualVariableSizeScaleStops?.getSizeForViewScale(t.view.currentScale)??t.visualVariableSizeStops?.getSize(i,s)??t.visualVariableSizeUnitValue?.getSize(i,s)}return s}(t,s,new Vr(2).multiply(r));return new Vr(.5).multiply(i.divide(Gn(r,new Vr(zi)))).multiply(e)}return i}(t,e),d=new Vr(.5).multiply(t.antialiasingControls.antialiasing),p=Gn(u.add(d),new Vr(.45)).add(new Vr(.1).multiply(d)),_=rh(p).multiply(p).multiply(i),f=h.multiply(new Wr(_,new Vr(0))),m=a.multiply(new Wr(r,new Vr(1))).add(f),g=new Vr(2).multiply(jn(u,new Vr(0))).add(t.clip(s,o)),y=new Xr(m.xy,g,1);return{color:c,opacity:l,halfWidth:p,normal:n,scaledOffset:_,scaledHalfWidth:u,glPosition:new Xr(y.xy,g,1)}}function oh(t,e){const{opacity:s,color:i}=t,r=function(t,e){const{halfWidth:s,normal:i}=t,r=rh(s),n=Un(i).multiply(s);return Dn(r.multiply(s.subtract(n)).divide(e.add(r).subtract(new Vr(1))),new Vr(0),new Vr(1))}(t,e);return s.multiply(i).multiply(r)}(0,T._)([ha(Vr)],ih.prototype,"antialiasing",void 0),(0,T._)([ha(Vr)],ih.prototype,"blur",void 0);class ah extends Ra{constructor(){super(...arguments),this.computeAttributes={pos:["nextPos1","nextPos2"]}}vertex(t,e){const s=nh(this,t);return{...s,...this.maybeRunHittest(t,e,s.halfWidth)}}fragment(t){const e=oh(t,this.antialiasingControls.blur);return this.getFragmentOutput(e,t)}hittest(t,e,s){const{viewMat3:i,tileMat3:r}=this.view,n=i.multiply(r),o=n.multiply(new Wr(t.pos,1)),a=n.multiply(new Wr(e.nextPos1,1)),h=n.multiply(new Wr(e.nextPos2,1)),{distance:c,smallSymbolDistance:l,smallSymbolSizeThreshold:u}=this.hittestRequest,d=jn(s,u.multiply(.5)).multiply(c.subtract(l)),p=this.hittestRequest.position;return Vn(Oa(p,o.xy,a.xy),Oa(p,o.xy,h.xy)).subtract(s).add(d)}}(0,T._)([ha(ih)],ah.prototype,"antialiasingControls",void 0),(0,T._)([ca(La)],ah.prototype,"visualVariableColor",void 0),(0,T._)([ca(Ba)],ah.prototype,"visualVariableOpacity",void 0),(0,T._)([ca(Za)],ah.prototype,"visualVariableSizeMinMaxValue",void 0),(0,T._)([ca(Qa)],ah.prototype,"visualVariableSizeScaleStops",void 0),(0,T._)([ca(Ja)],ah.prototype,"visualVariableSizeStops",void 0),(0,T._)([ca(th)],ah.prototype,"visualVariableSizeUnitValue",void 0),(0,T._)([(0,T.a)(0,aa(eh)),(0,T.a)(1,aa(Fa))],ah.prototype,"vertex",null),(0,T._)([(0,T.a)(0,aa(sh))],ah.prototype,"fragment",null);class hh extends ka{}(0,T._)([oa(3,qr)],hh.prototype,"offset",void 0),(0,T._)([oa(4,Xr)],hh.prototype,"color",void 0),(0,T._)([oa(5,qr)],hh.prototype,"normal",void 0),(0,T._)([oa(6,Vr)],hh.prototype,"halfWidth",void 0),(0,T._)([oa(7,Vr)],hh.prototype,"referenceHalfWidth",void 0),(0,T._)([oa(8,qr)],hh.prototype,"zoomRange",void 0);class ch extends sh{}function lh(t,e,s){const{id:i,bitset:r}=e,n=Ia(r,0),o=kn(n,new Vr(.5)),a=nh(t,e),h=vn(o,a.halfWidth,new Vr(0)),c=Va(t,i),l=Ga(t,i,e.color),u=vn(o,e.color,l.multiply(c)),d=t.view.displayViewScreenMat3.multiply(new Wr(e.pos.xy,1)),p=t.clip(e.id),_=new Xr(d.xy,p,1),f=vn(o,a.glPosition,_),m=s&&t.maybeRunHittest(e,s,o);return{isOutline:n,color:u,opacity:new Vr(1),halfWidth:h,normal:a.normal,glPosition:f,...m}}class uh extends Ra{constructor(){super(...arguments),this.computeAttributes={pos:["nextPos1","nextPos2"]}}}(0,T._)([ha(ih)],uh.prototype,"antialiasingControls",void 0),(0,T._)([ca(La)],uh.prototype,"visualVariableColor",void 0),(0,T._)([ca(Ba)],uh.prototype,"visualVariableOpacity",void 0),(0,T._)([ca(Za)],uh.prototype,"visualVariableSizeMinMaxValue",void 0),(0,T._)([ca(Qa)],uh.prototype,"visualVariableSizeScaleStops",void 0),(0,T._)([ca(Ja)],uh.prototype,"visualVariableSizeStops",void 0),(0,T._)([ca(th)],uh.prototype,"visualVariableSizeUnitValue",void 0);class dh extends uh{vertex(t,e){return lh(this,t,e)}fragment(t){const{color:e,isOutline:s}=t,i=kn(s,new Vr(.5)),r=vn(i,oh(t,this.antialiasingControls.blur),e),n=vn(i,new Vr(1/255),new Vr(0));return this.getFragmentOutput(r,t,n)}hittest(t,e,s){return vn(s,Da(this.hittestRequest),za(this,t,e))}}(0,T._)([(0,T.a)(0,aa(hh)),(0,T.a)(1,aa(Fa))],dh.prototype,"vertex",null),(0,T._)([(0,T.a)(0,aa(ch))],dh.prototype,"fragment",null);class ph extends qa{}function _h(t,e){const s=e.tlbr.xy,i=e.tlbr.zw,r=i.x.subtract(s.x),n=s.y.subtract(i.y),o=new qr(r,n).multiply(e.inverseRasterizationScale),a=o.multiply(t.view.requiredZoomFactor),h=function(t){const e=new Vr(1),s=new Vr(0);return new an(e.divide(t.x),s.divide(t.y),0,bn(s.divide(t.x)),e.divide(t.y),0,0,0,1)}(a),c=t.localTileOffset.getPatternOffsetAtTileOrigin(o).divide(a),l=new Wr(e.pos,1);return{tileTextureCoord:h.multiply(l).xy.subtract(c),tlbr:e.tlbr.divide(t.mosaicInfo.size.xyxy)}}function fh(t,e){const s=Wn(t.tileTextureCoord,new Vr(1)),i=qn(t.tlbr.xy,t.tlbr.zw,s),r=Hn(e.texture,i);return t.color.multiply(r)}(0,T._)([oa(5,Xr)],ph.prototype,"tlbr",void 0),(0,T._)([oa(6,Vr)],ph.prototype,"inverseRasterizationScale",void 0);class mh extends Wa{vertex(t,e){return{...super.vertex(t,e),..._h(this,t)}}fragment(t){const e=fh(t,this.mosaicInfo);return this.getFragmentOutput(e,t,new Vr(0))}}(0,T._)([ha(Ya)],mh.prototype,"mosaicInfo",void 0),(0,T._)([ha(Xa)],mh.prototype,"localTileOffset",void 0),(0,T._)([(0,T.a)(0,aa(ph)),(0,T.a)(1,aa(Fa))],mh.prototype,"vertex",null),(0,T._)([(0,T.a)(0,aa(class extends Aa{}))],mh.prototype,"fragment",null);class gh extends hh{}(0,T._)([oa(9,Xr)],gh.prototype,"tlbr",void 0),(0,T._)([oa(10,Vr)],gh.prototype,"inverseRasterizationScale",void 0);class yh extends ch{}class xh extends dh{vertex(t,e){return{...lh(this,t,e),..._h(this,t)}}fragment(t){const{isOutline:e}=t,s=kn(e,new Vr(.5)),i=vn(s,oh(t,this.antialiasingControls.blur),fh(t,this.mosaicInfo)),r=vn(s,new Vr(1/255),new Vr(0));return this.getFragmentOutput(i,t,r)}}(0,T._)([ha(Ya)],xh.prototype,"mosaicInfo",void 0),(0,T._)([ha(Xa)],xh.prototype,"localTileOffset",void 0),(0,T._)([(0,T.a)(0,aa(gh)),(0,T.a)(1,aa(Fa))],xh.prototype,"vertex",null),(0,T._)([(0,T.a)(0,aa(yh))],xh.prototype,"fragment",null);const bh=16,wh=.0625;class vh extends ka{}(0,T._)([oa(3,Xr)],vh.prototype,"color",void 0),(0,T._)([oa(4,Xr)],vh.prototype,"tlbr",void 0),(0,T._)([oa(5,Vr)],vh.prototype,"angle",void 0),(0,T._)([oa(6,Vr)],vh.prototype,"aux1",void 0),(0,T._)([oa(7,Vr)],vh.prototype,"aux2",void 0),(0,T._)([oa(8,qr)],vh.prototype,"aux3",void 0),(0,T._)([oa(9,qr)],vh.prototype,"aux4",void 0),(0,T._)([oa(10,qr)],vh.prototype,"zoomRange",void 0);class Sh extends uh{vertex(t,e){const{aux1:s,aux2:i,aux3:r,aux4:n}=t,o={...t,width:s,height:i,offset:r,scale:n.multiply(wh)},a=lh(this,{...t,halfWidth:s.multiply(wh),referenceHalfWidth:i.multiply(wh),offset:r.multiply(wh),normal:n.subtract(128).multiply(wh)}),h=Ha(this,o),c=kn(a.isOutline,new Vr(.5));return{...a,...h,...this.maybeRunHittest(t,e,c)}}fragment(t){const{isOutline:e}=t,s=kn(e,new Vr(.5)),i=vn(s,oh(t,this.antialiasingControls.blur),$a(this,t)),r=vn(s,new Vr(1/255),new Vr(0));return this.getFragmentOutput(i,t,r)}hittest(t,e,s){return vn(s,Da(this.hittestRequest),za(this,t,e))}}(0,T._)([ha(Ya)],Sh.prototype,"mosaicInfo",void 0),(0,T._)([ha(Xa)],Sh.prototype,"localTileOffset",void 0),(0,T._)([(0,T.a)(0,aa(vh)),(0,T.a)(1,aa(Fa))],Sh.prototype,"vertex",null),(0,T._)([(0,T.a)(0,aa(class extends yh{}))],Sh.prototype,"fragment",null);const Ih=Xi.attributes,Th=Qi.attributes,Ph={createComputedParams:t=>t,attributes:{id:Ih.id,pos:Ih.pos,zoomRange:Ih.zoomRange,tlbr:Ih.tlbr,angle:Ih.angle,color:Ih.color,bitset:{type:pi.Ck.UNSIGNED_BYTE,count:1,pack:t=>Vi(t)},aux1:{count:1,type:pi.Ck.UNSIGNED_SHORT,pack:t=>qi(t)},aux2:{count:1,type:pi.Ck.UNSIGNED_SHORT,pack:t=>Wi(t)},aux3:{count:2,type:pi.Ck.SHORT,pack:({offsetX:t,offsetY:e})=>[(0,l.im)(t),(0,l.im)(e)]},aux4:{count:2,type:pi.Ck.UNSIGNED_BYTE,pack:({scaleX:t,scaleY:e})=>[t*bh,e*bh]}}},Mh={createComputedParams:t=>t,attributes:{id:Ih.id,pos:Ih.pos,zoomRange:Ih.zoomRange,tlbr:Ih.tlbr,angle:Ih.angle,color:Th.color,bitset:{type:pi.Ck.UNSIGNED_BYTE,count:1,pack:t=>Ii([[0,!0]])},aux1:{count:1,type:pi.Ck.UNSIGNED_SHORT,pack:t=>(0,l.im)(.5*t.width)*bh},aux2:{count:1,type:pi.Ck.UNSIGNED_SHORT,pack:t=>(0,l.im)(.5*t.referenceWidth)*bh},aux3:{count:2,type:pi.Ck.SHORT,packTessellation:({extrusionOffsetX:t,extrusionOffsetY:e})=>[t*bh,e*bh]},aux4:{count:2,type:pi.Ck.UNSIGNED_BYTE,packTessellation:({normalX:t,normalY:e})=>[t*bh+128,e*bh+128]}}};class Eh extends Ji{constructor(){super(...arguments),this.vertexSpec=Mh}}const Ch={createComputedParams:t=>t,attributes:{...Fi.attributes,...Zi.attributes}},kh={createComputedParams:t=>t,attributes:{...Fi.attributes,...Qi.attributes}};class Fh extends Ji{constructor(){super(...arguments),this.vertexSpec=kh}}const Ah={createComputedParams:t=>t,attributes:{pos:{type:pi.Ck.SHORT,count:2,pack:"position",packPrecisionFactor:10},id:{type:pi.Ck.UNSIGNED_BYTE,count:3,pack:"id"},bitset:{type:pi.Ck.UNSIGNED_BYTE,count:1},offset:{type:pi.Ck.BYTE,count:2,packAlternating:{count:4,pack:()=>[[-1,-1],[1,-1],[-1,1],[1,1]]}}}};var Rh=s(86916);const Oh=8388607,Nh=t=>t&Oh;class Dh{constructor(t,e,s,i,r,n,o,a,h=[]){this.entityTexel=t,this.anchorX=e,this.anchorY=s,this.directionX=i,this.directionY=r,this.maxScale=n,this.minScale=o,this.referenceBounds=a,this.bounds=h}serialize(t){t.push(this.entityTexel),t.writeF32(this.anchorX),t.writeF32(this.anchorY),t.writeF32(this.directionX),t.writeF32(this.directionY),t.writeF32(this.maxScale),t.writeF32(this.minScale),null===this.referenceBounds?(t.writeF32(0),t.writeF32(0),t.writeF32(0)):(t.writeF32(this.referenceBounds.size),t.writeF32(this.referenceBounds.offsetX),t.writeF32(this.referenceBounds.offsetY)),W(t,this.bounds)}static deserialize(t){const e=t.readInt32(),s=t.readF32(),i=t.readF32(),r=t.readF32(),n=t.readF32(),o=t.readF32(),a=t.readF32(),h=t.readF32(),c=t.readF32(),l=t.readF32(),u=X(t,Zs)??[];return new Dh(e,s,i,r,n,o,a,{size:h,offsetX:c,offsetY:l},u)}}const zh=1024;function Lh(t,e,s){return t[0]=e[0]-s[0],t[1]=e[1]-s[1],t}function Bh(t,e){return Math.sqrt(t*t+e*e)}function Uh(t){const e=Bh(t[0],t[1]);t[0]/=e,t[1]/=e}function Gh(t,e){return Bh(t[0]-e[0],t[1]-e[1])}function Vh(t){return t.length-1}function qh(t,e,s=1){let[i,r]=function(t,e){return t[e+1]}(t,e);return[i,r]=[Math.round(i),Math.round(r)],Math.sqrt(i*i+r*r)*s}class Wh{constructor(t,e,s,i,r){this._segments=t,this._index=e,this._distance=s,this._xStart=i,this._yStart=r,this._done=!1}static create(t){return new Wh(t,0,0,t[0][0],t[0][1])}clone(){return new Wh(this._segments,this._index,this._distance,this.xStart,this.yStart)}equals(t){return this._index===t._index||t._index===this._index-1&&(0===this._distance||1===t._distance)||t._index===this._index+1&&(1===this._distance||0===t._distance)}leq(t){return this._index<t._index||this._index===t._index&&this._distance<=t._distance}geq(t){return this._index>t._index||this._index===t._index&&this._distance>=t._distance}get _segment(){return this._segments[this._index+1]}get angle(){const t=this.dy,e=(0*t+-1*-this.dx)/(1*this.length);let s=Math.acos(e);return t>0&&(s=2*Math.PI-s),s}get xStart(){return this._xStart}get yStart(){return this._yStart}get x(){return this.xStart+this.distance*this.dx}get y(){return this.yStart+this.distance*this.dy}get dx(){return this._segment[0]}get dy(){return this._segment[1]}get xMidpoint(){return this.xStart+.5*this.dx}get yMidpoint(){return this.yStart+.5*this.dy}get xEnd(){return this.xStart+this.dx}get yEnd(){return this.yStart+this.dy}get length(){const{dx:t,dy:e}=this;return Math.sqrt(t*t+e*e)}get remainingLength(){return this.length*(1-this._distance)}get backwardLength(){return this.length*this._distance}get distance(){return this._distance}get done(){return this._done}hasPrev(){return this._index-1>=0}hasNext(){return this._index+1<Vh(this._segments)}next(){return this.hasNext()?(this._xStart+=this.dx,this._yStart+=this.dy,this._distance=0,this._index+=1,this):null}prev(){return this.hasPrev()?(this._index-=1,this._xStart-=this.dx,this._yStart-=this.dy,this._distance=1,this):(this._done=!0,null)}_seekBackwards(t,e){const s=this.backwardLength;if(t<=s)return this._distance=(s-t)/this.length,this;let i=this.backwardLength;for(;this.prev();){if(i+this.length>t)return this._seekBackwards(t-i);i+=this.length}return this._distance=0,e?this:null}seek(t,e=!1){if(t<0)return this._seekBackwards(Math.abs(t),e);if(t<=this.remainingLength)return this._distance=(this.backwardLength+t)/this.length,this;let s=this.remainingLength;for(;this.next();){if(s+this.length>t)return this.seek(t-s,e);s+=this.length}return this._distance=1,e?this:null}}function Xh(t,e,s,i=!0){const r=function(t){let e=0;for(let s=0;s<Vh(t);s++)e+=qh(t,s);return e}(t),n=Wh.create(t),o=r/2;if(!i)return n.seek(o),void(Math.abs(n.x)<zh&&Math.abs(n.y)<zh&&s(n.clone(),0,o+0*e,r));const a=Math.max((r-e)/2,0),h=Math.floor(a/e),c=o-h*e;n.seek(c);for(let t=-h;t<=h;t++)Math.abs(n.x)<zh&&Math.abs(n.y)<zh&&s(n.clone(),t,o+t*e,r),n.seek(e)}function Yh(t,e){const s=1e-6;if(e<=0)return;const i=t.length;if(i<3)return;const r=[];let n=0;r.push(0);for(let e=1;e<i;e++)n+=Gh(t[e],t[e-1]),r.push(n);e=Math.min(e,.2*n);const o=[];o.push(t[0][0]),o.push(t[0][1]);const a=t[i-1][0],h=t[i-1][1],c=Lh([0,0],t[0],t[1]);Uh(c),t[0][0]+=e*c[0],t[0][1]+=e*c[1],Lh(c,t[i-1],t[i-2]),Uh(c),t[i-1][0]+=e*c[0],t[i-1][1]+=e*c[1];for(let t=1;t<i;t++)r[t]+=e;r[i-1]+=e;const l=.5*e;for(let n=1;n<i-1;n++){let a=0,h=0,c=0;for(let i=n-1;i>=0&&!(r[i+1]<r[n]-l);i--){const o=l+r[i+1]-r[n],u=r[i+1]-r[i],d=r[n]-r[i]<l?1:o/u;if(Math.abs(d)<s)break;const p=d*d,_=d*o-.5*p*u,f=d*u/e,m=t[i+1],g=t[i][0]-m[0],y=t[i][1]-m[1];a+=f/_*(m[0]*d*o+.5*p*(o*g-u*m[0])-p*d*u*g/3),h+=f/_*(m[1]*d*o+.5*p*(o*y-u*m[1])-p*d*u*y/3),c+=f}for(let o=n+1;o<i&&!(r[o-1]>r[n]+l);o++){const i=l-r[o-1]+r[n],u=r[o]-r[o-1],d=r[o]-r[n]<l?1:i/u;if(Math.abs(d)<s)break;const p=d*d,_=d*i-.5*p*u,f=d*u/e,m=t[o-1],g=t[o][0]-m[0],y=t[o][1]-m[1];a+=f/_*(m[0]*d*i+.5*p*(i*g-u*m[0])-p*d*u*g/3),h+=f/_*(m[1]*d*i+.5*p*(i*y-u*m[1])-p*d*u*y/3),c+=f}o.push(a/c),o.push(h/c)}o.push(a),o.push(h);for(let e=0,s=0;e<i;e++)t[e][0]=o[s++],t[e][1]=o[s++]}var jh=s(53648);class Hh{static getPlacement(t,e,s,i,r,n){const o=function(t){if(!t)return null;switch(t.type){case"CIMMarkerPlacementAlongLineSameSize":return He.local();case"CIMMarkerPlacementAtExtremities":return Ke.local();case"CIMMarkerPlacementAtRatioPositions":return Qe.local();case"CIMMarkerPlacementInsidePolygon":return is.local();case"CIMMarkerPlacementOnLine":return os.local();case"CIMMarkerPlacementOnVertices":return hs.local();case"CIMMarkerPlacementPolygonCenter":return Es.local()}return null}(s);return o?(-1===e&&t.invertY(),o.execute(t,s,i,r,n)):null}}class $h{constructor(t){const{offsetX:e,offsetY:s,postAngle:i,fontSize:r,scaleFactor:n,transforms:o}=t;if(this.offsetX=e,this.offsetY=s,this.postAngle=i,this.fontSize=Math.min(r,96),this.transforms=o,o&&o.infos.length>1){const t=(0,Me.ol)(r,i,!1,e,s,o);this.fontSize=Math.min(t.size,96),this.postAngle=t.rotation,this.offsetX=t.offsetX,this.offsetY=t.offsetY}n&&(this.fontSize*=n,this.offsetX*=n,this.offsetY*=n)}}const Kh=[4,4],Zh=[16,4],Qh={topLeft:Zh,topRight:Zh,bottomLeft:Zh,bottomRight:Zh},Jh=[4,2],tc=[4,6],ec={topLeft:Jh,topRight:Jh,bottomLeft:tc,bottomRight:tc},sc={topLeft:Jh,topRight:tc,bottomLeft:Jh,bottomRight:tc},ic={topLeft:tc,topRight:tc,bottomLeft:Kh,bottomRight:Kh},rc={topLeft:Kh,topRight:Kh,bottomLeft:tc,bottomRight:tc},nc={topLeft:tc,topRight:Kh,bottomLeft:tc,bottomRight:Kh},oc={topLeft:Kh,topRight:tc,bottomLeft:Kh,bottomRight:tc},ac={createComputedParams:t=>t,attributes:{pos:{type:pi.Ck.SHORT,count:2,pack:"position",packPrecisionFactor:10},id:{type:pi.Ck.UNSIGNED_BYTE,count:3,pack:"id"},bitset:{type:pi.Ck.UNSIGNED_BYTE,count:1,packTessellation:({isBackground:t,mapAligned:e})=>Ii([[0,t],[3,!!e]])},zoomRange:{type:pi.Ck.UNSIGNED_SHORT,count:2,packPrecisionFactor:B.M6,packTessellation:({minZoom:t,maxZoom:e})=>[t||0,e||28]},offset:{type:pi.Ck.SHORT,count:2,packPrecisionFactor:8,packAlternating:{count:4,packTessellation:({offsets:t})=>{const{bottomLeft:e,bottomRight:s,topLeft:i,topRight:r}=t;return[i,r,e,s]}}},textureUV:{type:pi.Ck.SHORT,count:2,packPrecisionFactor:4,packAlternating:{count:4,packTessellation:({texcoords:t})=>{const{bottomLeft:e,bottomRight:s,topLeft:i,topRight:r}=t;return[i,r,e,s]}}},color:{type:pi.Ck.UNSIGNED_BYTE,count:4,normalized:!0,packTessellation:({color:t})=>t},fontSize:{type:pi.Ck.UNSIGNED_SHORT,count:1,packPrecisionFactor:4,packTessellation:({fontSize:t})=>(0,l.im)(t)},referenceSize:{type:pi.Ck.UNSIGNED_BYTE,count:1,packPrecisionFactor:4,packTessellation:({fontSize:t},{referenceSize:e})=>(0,l.im)(e??t)},haloColor:{type:pi.Ck.UNSIGNED_BYTE,count:4,normalized:!0,pack:({haloColor:t})=>Ti(t)},haloFontSize:{type:pi.Ck.UNSIGNED_SHORT,count:1,packPrecisionFactor:4,pack:({haloFontSize:t})=>(0,l.im)(t)},clipAngle:{type:pi.Ck.UNSIGNED_BYTE,count:1,packTessellation:({clipAngle:t})=>cc(t||0)},referenceSymbol:{type:pi.Ck.BYTE,count:4,packPrecisionFactor:1,packTessellation:(t,e)=>{if(!t.referenceBounds)return[0,0,0,0];const s=function(t){switch(t){case Xs.Right:case"right":return-1;case Xs.Center:case"center":return 0;case Xs.Left:case"left":return 1;default:return console.debug(`Found invalid horizontal alignment ${t}`),0}}(e.horizontalAlignment),i=function(t){switch(t){case Ys.Top:case"top":return 1;case Ys.Center:case"middle":return 0;case Ys.Bottom:case Ys.Baseline:case"baseline":case"bottom":return-1;default:return console.debug(`Found invalid vertical alignment ${t}`),0}}(e.verticalAlignment),{offsetX:r,offsetY:n,size:o}=t.referenceBounds;return[(0,l.im)(r),-(0,l.im)(n),(0,l.im)(o),s+1<<2|i+1]}}}};class hc extends gi{constructor(){super(...arguments),this.vertexSpec=ac,this._textMeshParamsPropsInitialized=!1}ensurePacked(t,e,s){super.ensurePacked(t,e,s),this._textMeshParamsPropsInitialized&&!this._evaluator.hasDynamicProperties||(this._textMeshTransformProps=new $h(this.evaluatedMeshParams),this._textMeshParamsPropsInitialized=!0)}_write(t,e,s){const i=this._getShaping();if(!i)return;const r=e.getDisplayId();if(null!=this.evaluatedMeshParams.placement)return this._writePlacedTextMarkers(t,e,i,s);if(s&&s.nextPath())return s.nextPoint(),this._writeGlyphs(t,r,s.x,s.y,i,0);if("esriGeometryPolygon"===e.geometryType){const s=e.readCentroidForDisplay();if(!s)return;const[n,o]=s.coords;return this._writeGlyphs(t,r,n,o,i,0)}if("esriGeometryMultipoint"===e.geometryType){const s=e.readGeometryForDisplay();return void s?.forEachVertex(((e,s)=>this._writeGlyphs(t,r,e,s,i,0)))}const n=e.readXForDisplay(),o=e.readYForDisplay();return this._writeGlyphs(t,r,n,o,i,0)}_writePlacedTextMarkers(t,e,s,i){const r=i??jt.fromFeatureSetReaderCIM(e);if(!r)return;const n=Hh.getPlacement(r,-1,this.evaluatedMeshParams.placement,(0,l.im)(1),t.id,ui());if(!n)return;const o=e.getDisplayId();let a=n.next();for(;null!=a;){const e=a.tx,i=-a.ty,r=-a.getAngle();this._writeGlyphs(t,o,e,i,s,r),a=n.next()}}_getShaping(){const t=this._textMeshTransformProps,e=this.evaluatedMeshParams;if(!e.glyphs?.glyphs.length)return null;const s=Math.round((0,l.im)(t.fontSize)),i=(0,l.im)(t.offsetX),r=(0,l.im)(t.offsetY),n=(0,jh.qk)((0,l.im)(e.lineWidth),32,512),o=B.Cq*(0,jh.qk)(e.lineHeightRatio,.25,4);return function(t,e){const s=e.scale,i=new Array,{glyphs:r,isRightToLeft:n}=t,o=function(t,e,s){const i=new Array,r=1/s.scale,n=s.maxLineWidth*r,o=e?t.length-1:0,a=e?-1:t.length,h=e?-1:1;let c=o,l=0,u=0,d=c,p=d,_=0,f=1/0,m=0;for(;c!==a;){const{code:e,metrics:s}=t[c],r=Math.abs(s.top);if(ri(e)||ni(e)||(f=Math.min(f,r),m=Math.max(m,r+s.height)),ri(e))c!==o&&(i.push(new ii(t,d,c-h,l,f,m)),f=1/0,m=0),l=0,d=c+h,p=c+h,u=0;else if(ni(e))p=c+h,u=0,_=s.advance,l+=s.advance;else if(l>n){if(p!==d){const e=p-2*h;l-=_,i.push(new ii(t,d,e,l-u,f,m)),f=1/0,m=0,d=p,l=u}else i.push(new ii(t,d,c-h,l,f,m)),f=1/0,m=0,d=c,p=c,l=0;l+=s.advance,u+=s.advance}else l+=s.advance,u+=s.advance;c+=h}const g=new ii(t,d,c-h,l,f,m);return g.start>=0&&g.end<t.length&&i.push(g),i}(r,n,e),a=function(t,e){let s=0;for(let e=0;e<t.length;e++){const{width:i}=t[e];s=Math.max(i,s)}const i="underline"===e.decoration?4:0,r=t[0].yMin;return{x:0,y:r,height:t[t.length-1].yMax+e.lineHeight*(t.length-1)+i-r,width:s}}(o,e),h=Hs(e.horizontalAlignment),c=$s(e.verticalAlignment),l=c===Ys.Baseline?1:0,u=l?0:c-1,d=(1-l)*-a.y+u*(a.height/2)+-22*(l?1:0);for(let t=0;t<o.length;t++){const{start:n,end:a,width:c}=o[t];let l=-1*(h+1)*(c/2)-3;const u=t*e.lineHeight+d-3;o[t].startX=l,o[t].startY=u;for(let t=n;t<=a;t++){const e=r[t];if(ri(e.code))continue;const n=new Js(l+e.metrics.left,u-e.metrics.top,e,s);l+=e.metrics.advance,i.push(n)}}return new si(i,o,e)}(e.glyphs,{scale:s/B.iK,angle:t.postAngle,xOffset:i,yOffset:r,horizontalAlignment:e.horizontalAlignment,verticalAlignment:e.verticalAlignment,maxLineWidth:n,lineHeight:o,decoration:e.decoration,borderLineSizePx:(0,l.im)(e.boxBorderLineSize),hasBackground:!!e.boxBackgroundColor,useCIMAngleBehavior:e.useCIMAngleBehavior})}_writeGlyphs(t,e,s,i,r,n,o){const a=this.evaluatedMeshParams,h=this._textMeshTransformProps,c=h.fontSize,u=(0,l.im)(h.offsetX),d=(0,l.im)(h.offsetY);0!==n&&r.setRotation(n);const p=r.bounds,_=s+p.x+u,f=i+p.y-d,m=2*(a.minPixelBuffer?a.minPixelBuffer/c:1),g=Math.max(p.width,p.height)*m;r.textBox&&(t.recordStart(this.instanceId,this.attributeLayout,r.glyphs[0].textureBinding),t.recordBounds(_,f,g,g),this._writeTextBox(t,e,s,i,r.textBox,o),t.recordEnd());for(const n of r.glyphs){t.recordStart(this.instanceId,this.attributeLayout,n.textureBinding),t.recordBounds(_,f,g,g);const{texcoords:r,offsets:h}=n;this._writeQuad(t,e,s,i,{texcoords:r,offsets:h,fontSize:c,color:Ti(a.color),isBackground:!1,referenceBounds:o}),t.recordEnd()}0!==n&&r.setRotation(-n)}_writeTextBox(t,e,s,i,r,n,o){const a=this.evaluatedMeshParams,{fontSize:h}=this._textMeshTransformProps,{boxBackgroundColor:c,boxBorderLineColor:l}=a,u={isBackground:!0,fontSize:h,referenceBounds:n,...o};c&&(this._writeQuad(t,e,s,i,{texcoords:Qh,offsets:r.main,color:Ti(c),...u}),l||(this._writeQuad(t,e,s,i,{texcoords:ic,offsets:r.top,color:Ti(c),...u}),this._writeQuad(t,e,s,i,{texcoords:rc,offsets:r.bot,color:Ti(c),...u}),this._writeQuad(t,e,s,i,{texcoords:nc,offsets:r.left,color:Ti(c),...u}),this._writeQuad(t,e,s,i,{texcoords:oc,offsets:r.right,color:Ti(c),...u}))),l&&(this._writeQuad(t,e,s,i,{texcoords:ec,offsets:r.top,color:Ti(l),...u}),this._writeQuad(t,e,s,i,{texcoords:ec,offsets:r.bot,color:Ti(l),...u}),this._writeQuad(t,e,s,i,{texcoords:sc,offsets:r.left,color:Ti(l),...u}),this._writeQuad(t,e,s,i,{texcoords:sc,offsets:r.right,color:Ti(l),...u}))}_writeQuad(t,e,s,i,r){const n=t.vertexCount();this._writeVertex(t,e,s,i,r),t.indexWrite(n+0),t.indexWrite(n+1),t.indexWrite(n+2),t.indexWrite(n+1),t.indexWrite(n+3),t.indexWrite(n+2)}}const cc=t=>Math.round(t*(254/360)),lc=(0,Rh.sB)((t=>{let e=0;if(0===t)return 1/0;for(;!(t%2);)e++,t/=2;return e})),uc={createComputedParams:t=>t,attributes:{...Hi.attributes,bitset:{type:pi.Ck.UNSIGNED_BYTE,count:1,pack:({shouldSampleAlphaOnly:t,shouldScaleDash:e,isSDF:s})=>Ii([[4,t],[2,e],[3,s]])},tlbr:{type:pi.Ck.UNSIGNED_SHORT,count:4,pack:({sprite:t})=>{const{rect:e,width:s,height:i}=t,r=e.x+B.mc,n=e.y+B.mc;return[r,n,r+s,n+i]}},accumulatedDistance:{type:pi.Ck.UNSIGNED_SHORT,count:1,packTessellation:({distance:t})=>t},segmentDirection:{type:pi.Ck.BYTE,count:2,packPrecisionFactor:16,packTessellation:({directionX:t,directionY:e})=>[t,e]}}};class dc{static from(t){return"width"in t?this.fromSimpleMeshParams(t):this.fromComplexMeshParams(t)}static fromSimpleMeshParams(t){const e=new dc(t.sprite,t.color,t.outlineColor,t.minPixelBuffer,t.placement,t.scaleInfo,t.effects),{type:s,width:i,height:r,angle:n,outlineSize:o,referenceSize:a,sprite:h,overrideOutlineColor:c}=t;return e.rawWidth=(0,l.im)(i),e.rawHeight=(0,l.im)(r),e.angle=n,e.outlineSize=(0,l.im)(o),e.referenceSize=(0,l.im)(a),e.overrideOutlineColor=c,e.offsetX=(0,l.im)(t.offsetX),e.offsetY=(0,l.im)(t.offsetY),"simple"!==s||h.sdf||(e.rawWidth=h.width,e.rawHeight=h.height),e.sizeRatio=h.sdf?2:1,e._computeSize(t,!1),e}static fromComplexMeshParams(t){const e=new dc(t.sprite,t.color,t.outlineColor,t.minPixelBuffer,t.placement,t.scaleInfo,t.effects);let{alignment:s,transforms:i,size:r,scaleX:n,anchorX:o,anchorY:a,angle:h,colorLocked:c,frameHeight:u,widthRatio:d,offsetX:p,offsetY:_,outlineSize:f,referenceSize:m,scaleFactor:g,sizeRatio:y,isAbsoluteAnchorPoint:x,rotateClockwise:b,scaleSymbolsProportionally:w,sprite:v}=t;if(i&&i.infos.length>0){const t=(0,Me.ol)(r,h,b,p,_,i);r=t.size,h=t.rotation,p=t.offsetX,_=t.offsetY,b=!1}g&&(r*=g,p*=g,_*=g);const S=n*(v.width/v.height);e.alignment=s,e.rawHeight=(0,l.im)(r),e.rawWidth=e.rawHeight*S,e.referenceSize=(0,l.im)(m),e.sizeRatio=y,e.angle=h,e.rotateClockwise=b,e.anchorX=o,e.anchorY=a,e.offsetX=(0,l.im)(p),e.offsetY=(0,l.im)(_),x&&r&&(v.sdf?e.anchorX=o/(r*d):e.anchorX=o/(r*S),e.anchorY=a/r);const I=w&&u?r/u:1;return e.outlineSize=0===f||isNaN(f)?0:(0,l.im)(f)*I,e.scaleSymbolsProportionally=w,e.colorLocked=c,e._computeSize(t,!0),e}constructor(t,e,s,i,r,n,o){this.sprite=t,this.color=e,this.outlineColor=s,this.minPixelBuffer=i,this.placement=r,this.scaleInfo=n,this.effects=o,this.rawWidth=0,this.rawHeight=0,this.angle=0,this.outlineSize=0,this.referenceSize=0,this.sizeRatio=1,this.alignment=ce.yu.SCREEN,this.scaleSymbolsProportionally=!1,this.overrideOutlineColor=!1,this.colorLocked=!1,this.anchorX=0,this.anchorY=0,this.computedWidth=0,this.computedHeight=0,this.texXmin=0,this.texYmin=0,this.texXmax=0,this.texYmax=0,this.offsetX=0,this.offsetY=0,this.rotateClockwise=!0}get boundsInfo(){return{size:Math.max(this.computedHeight,this.computedWidth),offsetX:this.offsetX,offsetY:this.offsetY}}_computeSize(t,e){const{sprite:s,hasSizeVV:i}=t,r=!!s.sdf,{rawWidth:n,rawHeight:o,sizeRatio:a,outlineSize:h}=this,c=n*a,l=o*a;if(r&&!i){const t=e&&n>o?c:n,s=o,i=h+2;this.computedWidth=Math.min(t+i,c),this.computedHeight=Math.min(s+i,l)}else this.computedWidth=c,this.computedHeight=l;const u=r?B.y/Math.max(c,l):1,d=.5*(c-this.computedWidth)*u,p=.5*(l-this.computedHeight)*u,_=s.rect.x+B.mc+d,f=s.rect.y+B.mc+p,m=_+s.width-2*d,g=f+s.height-2*p;this.texXmin=Math.floor(_),this.texYmin=Math.floor(f),this.texXmax=Math.ceil(m),this.texYmax=Math.ceil(g),this.computedWidth*=(this.texXmax-this.texXmin)/(m-_),this.computedHeight*=(this.texYmax-this.texYmin)/(g-f),this.anchorX*=c/this.computedWidth,this.anchorY*=l/this.computedHeight}}const pc=0,_c=1,fc=2,mc=3,gc=4,yc=3.14159265359/180,xc=128/Math.PI;const bc={createComputedParams:t=>dc.from(t),attributes:{pos:{type:pi.Ck.SHORT,count:2,pack:"position",packPrecisionFactor:10},id:{type:pi.Ck.UNSIGNED_BYTE,count:3,pack:"id"},bitset:{type:pi.Ck.UNSIGNED_BYTE,count:1,pack:({sprite:t,alignment:e,scaleSymbolsProportionally:s,overrideOutlineColor:i,colorLocked:r})=>{let n=0;return t.sdf&&(n|=Si(pc)),e===ce.yu.MAP&&(n|=Si(_c)),s&&(n|=Si(fc)),i&&(n|=Si(mc)),r&&(n|=Si(gc)),n}},zoomRange:{type:pi.Ck.SHORT,count:2,packPrecisionFactor:B.M6,pack:({scaleInfo:t},{tileInfo:e})=>vi(t,e)},offset:{type:pi.Ck.SHORT,count:2,packPrecisionFactor:4,packAlternating:{count:4,pack:({angle:t,computedWidth:e,computedHeight:s,anchorX:i,anchorY:r,offsetX:n,offsetY:o,rotateClockwise:a})=>{const h=function(t,e,s,i,r=!1){const n=Us(),o=r?1:-1;return t?Ds(n,o*yc*t):As(n),(e||s)&&Ns(n,n,[e,-s]),i&&Os(n,n,o*yc*-i),n}(0,n,o,-t,a),c=-(.5+i)*e,l=-(.5-r)*s,u=[c,l],d=[c+e,l],p=[c,l+s],_=[c+e,l+s];return(0,F.m4)(u,u,h),(0,F.m4)(d,d,h),(0,F.m4)(p,p,h),(0,F.m4)(_,_,h),[u,d,p,_]}}},textureUV:{type:pi.Ck.SHORT,count:2,packPrecisionFactor:4,packAlternating:{count:4,pack:({texXmax:t,texXmin:e,texYmax:s,texYmin:i})=>[[e,i],[t,i],[e,s],[t,s]]}},color:{type:pi.Ck.UNSIGNED_BYTE,count:4,normalized:!0,pack:({color:t})=>Ti(t)},outlineColor:{type:pi.Ck.UNSIGNED_BYTE,count:4,normalized:!0,pack:({outlineColor:t})=>Ti(t)},sizing:{type:pi.Ck.UNSIGNED_BYTE,count:4,pack:({rawWidth:t,rawHeight:e,outlineSize:s,referenceSize:i})=>[Pi(Math.max(t,e),128),Pi(s,128),Pi(i,128),0]},placementAngle:{type:pi.Ck.UNSIGNED_BYTE,count:1,packTessellation:({placementAngle:t})=>function(t){return function(t,e){return t%=256,Math.abs(t>=0?t:t+256)}(t*xc)}(t)},sizeRatio:{type:pi.Ck.UNSIGNED_SHORT,count:1,packPrecisionFactor:64,pack:({sizeRatio:t})=>t}}},wc={createComputedParams:t=>t,attributes:{pos:{type:pi.Ck.SHORT,count:2,packPrecisionFactor:10,pack:"position"},id:{type:pi.Ck.UNSIGNED_BYTE,count:3,pack:"id"},bitset:{type:pi.Ck.UNSIGNED_BYTE,count:1,pack:t=>0},offset:{type:pi.Ck.SHORT,count:2,packPrecisionFactor:16,packAlternating:{count:4,pack:({size:t})=>{const e=(0,l.im)(t),s=-e/2,i=-e/2;return[[s,i],[s+e,i],[s,i+e],[s+e,i+e]]}}},texCoords:{type:pi.Ck.SHORT,count:2,packPrecisionFactor:4,packAlternating:{count:4,pack:()=>[[0,1],[1,1],[0,0],[1,0]]}},size:{type:pi.Ck.UNSIGNED_BYTE,count:2,pack:({size:t})=>[t,t]},referenceSize:{type:pi.Ck.UNSIGNED_BYTE,count:1,pack:({size:t})=>(0,l.im)(t)},zoomRange:{type:pi.Ck.UNSIGNED_BYTE,count:2,pack:({scaleInfo:t},{tileInfo:e})=>vi(t,e)}}},vc=function(t){const e={};for(const s in t){const i={name:s,constructor:t[s]};e[s]=i}return e}({FillMeshWriter:ki,DotDensityMeshWriter:class extends xi{constructor(){super(...arguments),this.vertexSpec=bi}createTesselationParams(t){return{inverseArea:1/t.readGeometryArea()}}},ComplexFillMeshWriter:class extends Ai{constructor(){super(...arguments),this.vertexSpec=Xi}},PatternFillMeshWriter:Ai,OutlineFillMeshWriter:tr,PatternOutlineFillMeshWriter:class extends tr{constructor(){super(...arguments),this.vertexSpec=Ch}_createOutlineWriter(t,e,s,i){return new Fh(t,e,s,i)}_write(t,e,s){const i=s?.asOptimized()??e.readGeometryForDisplay(),r=this._clip(i);if(!r)return;const n=this.evaluatedMeshParams.sprite?.textureBinding;t.recordStart(this.instanceId,this.attributeLayout,n),this._writeGeometry(t,e,r),this._lineMeshWriter.writeLineVertices(t,jt.fromOptimizedCIM(r,"esriGeometryPolyline"),e),t.recordEnd()}ensurePacked(t,e,s){super.ensurePacked(t,e,s),this._lineMeshWriter.ensurePacked(t,e,s)}enqueueRequest(t,e,s){super.enqueueRequest(t,e,s),this._lineMeshWriter.enqueueRequest(t,e,s)}async loadDependencies(){await Promise.all([super.loadDependencies(),this._lineMeshWriter.loadDependencies()])}},ComplexOutlineFillMeshWriter:class extends tr{constructor(){super(...arguments),this.vertexSpec=Ph}_createOutlineWriter(t,e,s,i){return new Eh(t,e,s,i)}_write(t,e,s){const i=s?.asOptimized()??e.readGeometryForDisplay(),r=this._clip(i);if(!r)return;const n=this.evaluatedMeshParams.sprite?.textureBinding;t.recordStart(this.instanceId,this.attributeLayout,n),this._writeGeometry(t,e,r),this._lineMeshWriter.writeLineVertices(t,jt.fromOptimizedCIM(r,"esriGeometryPolyline"),e),t.recordEnd()}ensurePacked(t,e,s){super.ensurePacked(t,e,s),this._lineMeshWriter.ensurePacked(t,e,s)}enqueueRequest(t,e,s){super.enqueueRequest(t,e,s),this._lineMeshWriter.enqueueRequest(t,e,s)}async loadDependencies(){await Promise.all([super.loadDependencies(),this._lineMeshWriter.loadDependencies()])}},MarkerMeshWriter:class extends gi{constructor(){super(...arguments),this.vertexSpec=bc}getBoundsInfo(){return this.evaluatedMeshParams.boundsInfo}_write(t,e,s){const i=this.evaluatedMeshParams.sprite?.textureBinding,r=e.getDisplayId();t.recordStart(this.instanceId,this.attributeLayout,i);const n=this.evaluatedMeshParams.minPixelBuffer,o=Math.max(this.evaluatedMeshParams.computedWidth,n),a=Math.max(this.evaluatedMeshParams.computedHeight,n),h=this.evaluatedMeshParams.offsetX,c=-this.evaluatedMeshParams.offsetY;if(null!=this.evaluatedMeshParams.placement)this._writePlacedMarkers(t,e,s,o,a);else if(s&&s.nextPath()){s.nextPoint();const e=s.x,i=s.y;t.recordBounds(e+h,i+c,o,a),this._writeQuad(t,r,e,i)}else if("esriGeometryPolygon"===e.geometryType){const s=e.readCentroidForDisplay();if(!s)return;const[i,n]=s.coords;t.recordBounds(i+h,n+c,o,a),this._writeQuad(t,r,i,n)}else if("esriGeometryPoint"===e.geometryType){const s=e.readXForDisplay(),i=e.readYForDisplay();t.recordBounds(s+h,i+c,o,a),this._writeQuad(t,r,s,i)}else{const s=e.readGeometryForDisplay();s?.forEachVertex(((e,s)=>{t.recordBounds(e+h,s+c,o,a),Math.abs(e)>zh||Math.abs(s)>zh||this._writeQuad(t,r,e,s)}))}t.recordEnd()}_writePlacedMarkers(t,e,s,i,r){const n=s??jt.fromFeatureSetReaderCIM(e)?.clone();if(!n)return;const o=Hh.getPlacement(n,-1,this.evaluatedMeshParams.placement,(0,l.im)(1),t.id,ui());if(!o)return;const a=e.getDisplayId();let h=o.next();const c=this.evaluatedMeshParams.offsetX,u=-this.evaluatedMeshParams.offsetY;for(;null!=h;){const e=h.tx,s=-h.ty;if(Math.abs(e)>zh||Math.abs(s)>zh){h=o.next();continue}const n=-h.getAngle();t.recordBounds(e+c,s+u,i,r),this._writeQuad(t,a,e,s,n),h=o.next()}}_writeQuad(t,e,s,i,r){const n=t.vertexCount(),o=null==r?null:{placementAngle:r};this._writeVertex(t,e,s,i,o),t.indexWrite(n+0),t.indexWrite(n+1),t.indexWrite(n+2),t.indexWrite(n+1),t.indexWrite(n+3),t.indexWrite(n+2)}},PieChartMeshWriter:class extends gi{constructor(){super(...arguments),this.vertexSpec=wc}_write(t,e){const s=e.getDisplayId(),i=this.evaluatedMeshParams.minPixelBuffer,r=Math.max((0,l.im)(this.evaluatedMeshParams.size),i);let n,o;if("esriGeometryPoint"===e.geometryType)n=e.readXForDisplay(),o=e.readYForDisplay();else{const t=e.readCentroidForDisplay();if(!t)return;n=t?.coords[0],o=t?.coords[1]}t.recordStart(this.instanceId,this.attributeLayout),t.recordBounds(n,o,r,r);const a=t.vertexCount();this._writeVertex(t,s,n,o),t.indexWrite(a+0),t.indexWrite(a+1),t.indexWrite(a+2),t.indexWrite(a+1),t.indexWrite(a+3),t.indexWrite(a+2),t.recordEnd()}},TextMeshWriter:hc,LineMeshWriter:Ki,TexturedLineMeshWriter:class extends Ki{constructor(t,e,s,i){super(t,e,s,i),this.vertexSpec=uc,this._tessellationOptions.textured=!0}_write(t,e,s){const i=s??jt.fromFeatureSetReaderCIM(e);if(!i)return;const{sprite:r}=this.evaluatedMeshParams;this._writeGeometry(t,e,i,r?.textureBinding)}},HeatmapMeshWriter:class extends gi{constructor(){super(...arguments),this.vertexSpec=Ah}_write(t,e){t.recordStart(this.instanceId,this.attributeLayout);const s=e.getDisplayId();if("esriGeometryPoint"===e.geometryType){const i=e.readXForDisplay(),r=e.readYForDisplay();this._writeQuad(t,s,i,r)}else if("esriGeometryMultipoint"===e.geometryType){const i=e.readGeometryForDisplay();i?.forEachVertex(((e,i)=>{e>=0&&e<=512&&i>=0&&i<=512&&this._writeQuad(t,s,e,i)}))}t.recordEnd()}_writeQuad(t,e,s,i){const r=t.vertexCount();this._writeVertex(t,e,s,i),t.indexWrite(r+0),t.indexWrite(r+1),t.indexWrite(r+2),t.indexWrite(r+1),t.indexWrite(r+3),t.indexWrite(r+2)}},LabelMeshWriter:class extends hc{constructor(){super(...arguments),this._zoomLevel=0}_write(t,e,s,i){if(this._zoomLevel=i||0,null!=s)throw new Error("InternalError: EffectGeometry not support for LabelMeshWriter");switch(e.geometryType){case"esriGeometryPoint":{const s=e.readXForDisplay(),i=e.readYForDisplay();return this._writePoint(t,s,i,e)}case"esriGeometryEnvelope":case"esriGeometryPolygon":case"esriGeometryMultipoint":{const s=e.readCentroidForDisplay();if(!s)return;const[i,r]=s.coords;return this._writePoint(t,i,r,e)}case"esriGeometryPolyline":{const s=e.readLegacyGeometryForDisplay();this._writeLines(t,e,s)}}}_writePoint(t,e,s,i){const r=this._getShaping();if(!r)return;let n=this._getPointReferenceBounds();n||(n={offsetX:0,offsetY:0,size:0});const o=r.boundsT,a=Hs(this.evaluatedMeshParams.horizontalAlignment),h=$s(this.evaluatedMeshParams.verticalAlignment),c=this.evaluatedMeshParams.scaleInfo?.maxScale??0,l=this.evaluatedMeshParams.scaleInfo?.minScale??0,u=Nh(i.getDisplayId());t.metricStart(new Dh(u,e,s,a,h,c,l,n)),t.metricBoxWrite(o),this._writeGlyphs(t,i.getDisplayId(),e,s,r,0,n),t.metricEnd()}_getPointReferenceBounds(){if(!this._references)return null;for(const t of this._references){const e=t.getBoundsInfo();if(e)return e}return null}_writeLines(t,e,s){const{repeatLabel:i,scaleInfo:r}=this.evaluatedMeshParams,n=this.evaluatedMeshParams.repeatLabelDistance||128,o=this._getShaping();if(!o)return;this._current={out:t,id:e.getDisplayId(),shaping:o,zoomRange:vi(r,this.getTileInfo()),referenceBounds:this._getPointReferenceBounds()||{offsetX:0,offsetY:0,size:0}};const a=function(t,e){const s=e;for(let e=0;e<t.length;e++){let i=t[e];Yh(i,s);const r=[];r.push(i[0]);for(let t=1;t<i.length;t++){const[e,s]=i[t-1],[n,o]=i[t],a=n-e,h=o-s;r.push([a,h])}t[e]=r,i=r}return t}(s.paths,o.bounds.width),h=this._placeSubdivGlyphs.bind(this),c=(o.bounds.width+n)/2;for(const t of a)Xh(t,c,h,!!i)}_placeSubdivGlyphs(t,e,s,i){const{allowOverrun:r,labelPosition:n,repeatLabelDistance:o}=this.evaluatedMeshParams,a=this._current.zoomRange[0],h=lc(e),c=this._current.shaping.bounds.width/2,l=Math.sqrt(o||128)/2,u=Math.min(s,i-s),d=this._current.shaping.isMultiline?28:Math.log2(u/(l+c/2)),p=0===e?d:Math.min(h,d),_=Math.max(a,this._zoomLevel+1-p),f=this._zoomLevel-_,m=this._current.shaping.bounds.width/2*2**f;this._current.shaping.isMultiline?0===e&&this._placeStraight(t,_):r&&f<0?this._placeStraightAlong(t,a):"parallel"===n?this._placeStraightAlong(t,_):"curved"===n&&this._placeCurved(t,_,m)}_placeStraight(t,e){const{out:s,id:i,shaping:r,zoomRange:n,referenceBounds:o}=this._current,{x:a,y:h}=t,c=t.angle*(180/Math.PI)%360,l=(t.angle*(180/Math.PI)+180)%360;if(r.textBox){const a=Math.max(e,n[0],0),h=Math.min(28,n[1]),u=Ds(Us(),-t.angle),[d,p]=r.shapeBackground(u),_={minZoom:a,maxZoom:h,clipAngle:c,mapAligned:!0,isLineLabel:!0};s.recordStart(this.instanceId,this.attributeLayout,r.glyphs[0].textureBinding),this._writeTextBox(s,i,t.x,t.y,p,o,_),s.recordEnd(),_.clipAngle=l,s.recordStart(this.instanceId,this.attributeLayout,r.glyphs[0].textureBinding),this._writeTextBox(s,i,t.x,t.y,p,o,_),s.recordEnd()}const u=Nh(i),d=this.evaluatedMeshParams.scaleInfo?.maxScale??0,p=this.evaluatedMeshParams.scaleInfo?.minScale??0;s.metricStart(new Dh(u,t.x,t.y,0,0,d,p,null)),s.metricBoxWrite(r.bounds);for(const u of r.glyphs)u.minZoom=e,u.maxZoom=n[1],u.angle=t.angle,this._writeLineGlyph(s,i,a,h,r.bounds,u,c,o,!0),u.angle=t.angle+Math.PI,this._writeLineGlyph(s,i,a,h,r.bounds,u,l,o,!0);s.metricEnd()}_placeCurved(t,e,s){const{out:i,id:r}=this._current,n=t.clone(),o=t.angle*(180/Math.PI)%360,a=(t.angle*(180/Math.PI)+180)%360,h=Nh(r),c=this.evaluatedMeshParams.scaleInfo?.maxScale??0,l=this.evaluatedMeshParams.scaleInfo?.minScale??0;i.metricStart(new Dh(h,t.x,t.y,0,0,c,l,null)),this._placeFirst(n,e,1,o),this._placeBack(t,n,e,s,1,o),this._placeForward(t,n,e,s,1,o),this._placeFirst(n,e,0,a),this._placeBack(t,n,e,s,0,a),this._placeForward(t,n,e,s,0,a),i.metricEnd()}_placeStraightAlong(t,e){const{out:s,id:i,shaping:r,zoomRange:n,referenceBounds:o}=this._current,{boxBorderLineColor:a,boxBackgroundColor:h}=this.evaluatedMeshParams,c=t.clone(),l=t.angle*(180/Math.PI)%360,u=(t.angle*(180/Math.PI)+180)%360;if(r.glyphs.length>0&&(a||h)){const a=Math.max(e,n[0],0),h=Math.min(28,n[1]),c=Ds(Us(),-t.angle),[d,p]=r.shapeBackground(c),_={minZoom:a,maxZoom:h,clipAngle:l,mapAligned:!0,isLineLabel:!0};s.recordStart(this.instanceId,this.attributeLayout,r.glyphs[0].textureBinding),this._writeTextBox(s,i,t.x,t.y,p,o,_),s.recordEnd(),_.clipAngle=u,s.recordStart(this.instanceId,this.attributeLayout,r.glyphs[0].textureBinding),this._writeTextBox(s,i,t.x,t.y,p,o,_),s.recordEnd()}const d=Nh(i),p=this.evaluatedMeshParams.scaleInfo?.maxScale??0,_=this.evaluatedMeshParams.scaleInfo?.minScale??0;s.metricStart(new Dh(d,t.x,t.y,0,0,p,_,null)),this._placeFirst(c,e,1,l,!0),this._placeFirst(c,e,0,u,!0),s.metricEnd()}_placeBack(t,e,s,i,r,n){const o=t.clone();let a=t.backwardLength+0;for(;o.prev()&&!(a>=i);)this._placeOnSegment(o,e,a,s,-1,r,n),a+=o.length+0}_placeForward(t,e,s,i,r,n){const o=t.clone();let a=t.remainingLength+0;for(;o.next()&&!(a>=i);)this._placeOnSegment(o,e,a,s,1,r,n),a+=o.length+0}_placeFirst(t,e,s,i,r=!1){const n=t,{out:o,id:a,shaping:h,zoomRange:c,referenceBounds:l}=this._current,u=h.glyphs;for(const d of u){const u=d.x>h.bounds.x?s:1-s,p=u*t.remainingLength+(1-u)*t.backwardLength,_=Math.abs(d.x+d.width/2-h.bounds.x),f=Math.max(0,this._zoomLevel+Math.log2(_/(p+0))),m=Math.max(e,r?0:f);d.maxZoom=Math.min(c[1],28),d.angle=t.angle+(1-s)*Math.PI,d.minZoom=Math.max(c[0],m),o.metricBoxWrite(d.bounds),this._writeLineGlyph(o,a,n.x,n.y,h.bounds,d,i,l,!0)}}_placeOnSegment(t,e,s,i,r,n,o){const{out:a,id:h,shaping:c,referenceBounds:l}=this._current,u=c.glyphs,d=t.dx/t.length,p=t.dy/t.length,_={x:t.x+s*-r*d,y:t.y+s*-r*p};for(const e of u){const u=e.x>c.bounds.x?n:1-n;if(!(u&&1===r||!u&&-1===r))continue;const d=Math.abs(e.x+e.width/2-c.bounds.x),p=Math.max(0,this._zoomLevel+Math.log2(d/s)-.1),f=Math.max(i,this._zoomLevel+Math.log2(d/(s+t.length+0)));0!==p&&(e.angle=t.angle+(1-n)*Math.PI,e.minZoom=f,e.maxZoom=p,this._writeLineGlyph(a,h,_.x,_.y,c.bounds,e,o,l,!0))}}_writeLineGlyph(t,e,s,i,r,n,o,a,h){const c=s+r.x,l=i+r.y,u=2*(this.evaluatedMeshParams.minPixelBuffer?this.evaluatedMeshParams.minPixelBuffer/this._textMeshTransformProps.fontSize:1),d=Math.max(r.width,r.height)*u;t.recordStart(this.instanceId,this.attributeLayout,n.textureBinding),t.recordBounds(c,l,d,d);const{texcoords:p,offsets:_}=n,f=this._textMeshTransformProps.fontSize;this._writeQuad(t,e,s,i,{texcoords:p,offsets:_,fontSize:f,color:Ti(this.evaluatedMeshParams.color),isBackground:!1,referenceBounds:a,minZoom:Math.max(this._current.zoomRange[0],n.minZoom),maxZoom:Math.min(this._current.zoomRange[1],n.maxZoom),clipAngle:o,mapAligned:h,isLineLabel:!0}),t.recordEnd()}}});async function Sc(t,e,s,i){return Promise.all(s.map((s=>async function(t,e,s,i,r,n,o){const a=vc[s],h=await dt.create(t,e,r),c=new a.constructor(i,h,n,o);return await c.loadDependencies(),c}(t,e,s.meshWriterName,s.id,s.options,i,s.optionalAttributes))))}class Ic{constructor(){this._defaultResult=null,this._backgroundFillResult=null}static async from(t,e,s,i){const r=new Ic;return r.setDefault(await Sc(t,e,s.meshes,i)),r}size(){return 1}getDefault(){return this._defaultResult}setDefault(t){this._defaultResult=t}getBackgroundFill(){return this._backgroundFillResult}setBackgroundFill(t){this._backgroundFillResult=t}match(t,e){const s=this.doMatch(t,e)||this.getDefault();if(s&&s.length>0){const t=this.getBackgroundFill();if(t)return[...t,...s]}return s}getSortKey(t,e){return 0}doMatch(t,e){return null}async fetchResources(t,e){}}class Tc extends Ic{static async fromDictionaryRenderer(t,e,s){return new Tc(t,e,s)}constructor(t,e,s){super(),this._storage=t,this._schema=e,this._viewParams=s,this._hashToGroup=new Map}get fieldMap(){return this._schema.fieldMap}async fetchResources(t,e){const s=e.getCursor(),i=[];for(;s.next();)i.push(this._updateMeshWriterGroup(t,s));await Promise.all(i)}match(t,e){const s=t.getAttributeHash();return this._hashToGroup.get(s)}async _updateMeshWriterGroup(t,e){const s=e.readLegacyFeatureForDisplay(),i=e.getAttributeHash();if(this._hashToGroup.has(i))return;this._hashToGroup.set(i,null);const r=await t.fetchDictionaryResourceImmediate({type:"dictionary-request",feature:s});if(!r)return;const n=await Sc(this._storage,t,r.meshes,this._viewParams);this._hashToGroup.set(i,n)}}class Pc extends Ic{constructor(t,e){super(),this._intervals=[],this._isMaxInclusive=e,this._field=t}static async fromIntervalSchema(t,e,s,i){const r=await t.createComputedField(s),n=new Pc(r,s.isMaxInclusive);await Promise.all(s.intervals.map((async s=>{const r=await Sc(t,e,s.meshes,i);n.add(s,r)})));const o=await Sc(t,e,s.defaultSymbol,i);n.setDefault(o);const a=await Sc(t,e,s.backgroundFill,i);return n.setBackgroundFill(a),n}add(t,e){this._intervals.push({interval:t,result:e}),this._intervals.sort(((t,e)=>t.interval.min-e.interval.min))}size(){return super.size()+this._intervals.length}doMatch(t,e){const s=this._field?.read(t,e);if(null==s||isNaN(s)||s===1/0||s===-1/0)return null;for(let t=0;t<this._intervals.length;t++){const{interval:e,result:i}=this._intervals[t],r=s>=e.min,n=this._isMaxInclusive?s<=e.max:s<e.max;if(r&&n)return i}return null}}class Mc extends Ic{static async fromLabelSchema(t,e,s,i){const r=s.classes.map((async s=>{const r=await Sc(t,e,s.meshes,i);return{minScale:s.minScale,maxScale:s.maxScale,meshes:r,expression:null,where:await t.createWhereClause(s.where)}})),n=await Promise.all(r);return new Mc(n)}constructor(t){super(),this._labels=t}match(t,e){if(!this._labels.length)return null;const s=this._getLabels(e.$view.scale),i=[];for(const e of s)e.where&&!e.where(t)||i.push(...e.meshes);return i}_getLabels(t){return this._labels.filter((e=>this._validForTileScale(e,t)))}_validForTileScale(t,e){const s=e-e/4,i=e+e/2;return(!t.minScale||t.minScale>=s)&&(!t.maxScale||t.maxScale<=i)}}class Ec extends Ic{constructor(t,e){super(),this._defaultSymbolSortKey=0,this._nullResult=null,this._resultsMap=new Map,this._fields=[],this._fields=t,this._separator=e||""}static async fromMatcherSchema(t,e,s,i){const r=s.expression?[t.createComputedField({expression:s.expression})]:[s.field?t.createComputedField({field:s.field}):null,s.field2?t.createComputedField({field:s.field2}):null,s.field3?t.createComputedField({field:s.field3}):null],n=(await Promise.all(r)).filter((t=>!!t)),o=new Ec(n,s.fieldDelimiter),a=await Sc(t,e,s.defaultSymbol,i);o.setDefault(a);const h=await Sc(t,e,s.backgroundFill,i);return o.setBackgroundFill(h),await Promise.all(s.map.map((async(s,r)=>{const n=await Sc(t,e,s.symbol,i);"<Null>"===s.value?o.setNullResult(n):o.add(s.value,n,r+1)}))),o}setNullResult(t){this._nullResult=t}getSortKey(t,e){const s=this._getValueFromFields(t,e);if(null==s||""===s||"<Null>"===s)return 0;const i=this._resultsMap.get(s.toString());return i?i.sortKey:this._defaultSymbolSortKey}add(t,e,s){this._resultsMap.set(t.toString(),{meshWriters:e,sortKey:s}),this._defaultSymbolSortKey=Math.max(this._defaultSymbolSortKey,s+1)}size(){return super.size()+this._resultsMap.size}doMatch(t,e){const s=this._getValueFromFields(t,e);if(null!==this._nullResult&&(null==s||""===s||"<Null>"===s))return this._nullResult;if(null==s)return null;const i=s.toString();return this._resultsMap.get(i)?.meshWriters}_getValueFromFields(t,e){const s=[];for(const i of this._fields){const r=i.read(t,e);null==r||""===r?s.push("<Null>"):s.push(r)}return s.join(this._separator)}}async function Cc(t,e,s,i){switch(s.type){case"simple":case"heatmap":case"dot-density":case"pie-chart":return Ic.from(t,e,s,i);case"interval":return Pc.fromIntervalSchema(t,e,s,i);case"dictionary":return Tc.fromDictionaryRenderer(t,s,i);case"label":return Mc.fromLabelSchema(t,e,s,i);case"map":return Ec.fromMatcherSchema(t,e,s,i);case"subtype":return kc.fromSubtypes(t,e,s,i);case"cluster":return Fc.fromClusterSchema(t,e,s,i);default:throw new Error("Impl")}}class kc extends Ic{constructor(t,e){super(),this._subMatchers=t,this._subtypeField=e}static async fromSubtypes(t,e,s,i){const r=new Map,n=[];for(const o in s.renderers){const a=parseInt(o,10),h=Cc(t,e,s.renderers[o],i).then((t=>r.set(a,t)));n.push(h)}return await Promise.all(n),new kc(r,s.subtypeField)}match(t,e){const s=t.readAttribute(this._subtypeField),i=this._subMatchers.get(s);return i?i.match(t,e):null}}class Fc extends Ic{static async fromClusterSchema(t,e,s,i){const[r,n]=await Promise.all([Cc(t,e,s.feature,i),Cc(t,e,s.cluster,i)]);return new Fc(r,n)}constructor(t,e){super(),this._featureMatcher=t,this._clusterMatcher=e}match(t,e){return 1===t.readAttribute("cluster_count")?this._featureMatcher.match(t,e):this._clusterMatcher.match(t,e)}}class Ac extends J{static async create(t,e,s,i){const r=await Cc(t,e,s.symbology,i),n=s.labels?await Cc(t,e,s.labels,i):null;return new Ac(r,n)}constructor(t,e){super(),this._symbology=t,this._labels=e}destroy(){}async enqueueMatcherRequests(t,e){await Promise.all([this._symbology.fetchResources(t,e),this._labels?.fetchResources(t,e)])}enqueueWriterRequests(t,e,s){const i=this._symbology.match(e,s);if(i){for(const r of i)r.enqueueRequest(t,e,s);if(this._labels){const i=this._labels.match(e,s);if(!i)return;for(const r of i)r.enqueueRequest(t,e,s)}}}write(t,e,s,i,r){const n=this._symbology.match(s,i);if(n){for(const o of n)o.write(t,e,s,i,r);if(t.entityRecordCount()>=1&&this._labels){const o=this._labels.match(s,i);if(!o)return;for(const a of o)a.setReferences(n),a.write(t,e,s,i,r)}}}getSortKey(t,e){return this._symbology.getSortKey(t,e)}}class Rc{}class Oc extends Rc{constructor(t){super(),this._fetcher=t,this._controller=new AbortController,this._pendingIds=new Set,this._pendingRequests=[],this._resourceIdToResource=new Map}destory(){this._controller.abort()}get _abortOptions(){return{signal:this._controller.signal}}enqueueRequest(t){const e=function(t){return"url"in t&&"urlHash"in t?{...t,url:""}:t}(t.resource),s=(0,st.sV)(JSON.stringify(e));return this._pendingIds.has(s)||(this._pendingIds.add(s),this._pendingRequests.push({...t,resourceId:s})),s}async fetchEnqueuedResources(){const t=this._pendingRequests;this._pendingIds.clear(),this._pendingRequests=[];const e=await this._fetcher.fetch(t,this._abortOptions);for(let s=0;s<e.length;s++){const i=t[s].resourceId;this._resourceIdToResource.set(i,e[s])}}async fetchResourceImmediate(t){const e=await this._fetcher.fetch([t],this._abortOptions);if(1!==e.length)throw new Error("FeaturePipelineResourceProxy: failed to fetch resources");return e[0]}async fetchDictionaryResourceImmediate(t){const e=await this._fetcher.fetchDictionary([t],this._abortOptions);if(1!==e.length)throw new Error("FeaturePipelineResourceProxy: failed to fetch dictionary resources");return e[0]}getResource(t){return this._resourceIdToResource.get(t)}}class Nc{constructor(t){this._outstandingMessages=[],this._queue=new A.K({concurrency:t.concurrency,process:e=>t.process(e)})}async push(t){if(t.end)return await Promise.all(this._outstandingMessages),await this._queue.push(t),void(this._outstandingMessages=[]);const e=this._queue.push(t);return this._outstandingMessages.push(e),e}}var Dc=s(59612),zc=s(97088),Lc=s(34888),Bc=s(7684);class Uc{static async create(t,e){if("count"===e.statisticType){const t=new at(1);return new Uc(e.name,e.alias,e.type,e.statisticType,t)}const s=await t.createComputedField({expression:e.onStatisticExpression?.expression,field:e.onStatisticField});return new Uc(e.name,e.alias,e.type,e.statisticType,s)}constructor(t,e,s,i,r){this.name=t,this.alias=e,this.type=s,this.statisticType=i,this.computed=r}}var Gc=s(77860),Vc=s(77048),qc=s(51752),Wc=s(47302);class Xc{constructor(t){this.subscription=t,this.handledChunks=new Set}destroy(){}}class Yc{constructor(t,e){this._source=t,this._attributeStore=e,this._sendStates=new Map}destroy(){}get enablePixelBuffering(){return!0}onSubscribe(t){const e=this.createState(t);this._sendStates.set(t.key.id,e),this.updateChunks()}onUnsubscribe(t){this._sendStates.get(t.key.id)?.destroy(),this._sendStates.delete(t.key.id)}invalidate(){const t=Array.from(this._sendStates.values());this._sendStates.clear();for(const e of t)e.destroy(),this.onSubscribe(e.subscription)}invalidateAttributeData(){}getFeatureObjectIdsForAggregate(t){throw new Error("InternalError: AggregateId lookup not supported")}getDisplayIds(t){return this.displayMap(t,(t=>t),(t=>t))}getDisplayAndObjectIds(t){return this.displayMap(t,(t=>t),((t,e,s)=>[t,s]))}afterUpdateChunks(){}}class jc extends Yc{constructor(t,e,s,i){super(t,e),this.spatialReference=s,this.aggregateFields=i,this.events=new Gc.c,this.featureAdapter=qc.u}get aggregateQueryEngine(){return this._aggregateQueryEngine||(this._aggregateQueryEngine=new Wc.U({featureStore:this,fieldsIndex:this._metadata.fieldsIndex,geometryType:this._metadata.geometryType,objectIdField:this._metadata.objectIdField,spatialReference:this.spatialReference})),this._aggregateQueryEngine}removeChunks(t){}forEach(t){return this.forEachAggregateWorldSpace(t)}forEachInBounds(t,e){}forEachBounds(t,e){const s=(0,Vc.Su)();for(const i of t){const t=(0,zc.C_)(s,i.geometry,!1,!1);t&&e(t)}}}class Hc{constructor(t,e,s,i,r){this.subscription=t,this.reader=e,this.clear=s,this.end=i,this.debugInfo=r,this.type="append"}get id(){return this.subscription.tile.id}createMessage(t,e,s){return{type:"append",clear:this.clear,id:this.id,append:t,end:this.end,debugInfo:this.debugInfo,subscriptionVesrion:this.subscription.version,version:e,attributeEpoch:s}}}class $c{constructor(t,e,s,i,r){this.subscription=t,this.reader=e,this.remove=s,this.end=i,this.debugInfo=r,this.type="update"}get id(){return this.subscription.tile.id}createMessage(t,e,s){return{type:"update",id:this.id,modify:t,debugInfo:this.debugInfo,remove:this.remove,version:e,subscriptionVesrion:this.subscription.version,end:this.end,attributeEpoch:s}}}class Kc extends ot{constructor(t){super(),this._field=t}resize(t){throw new Error("Method not implemented.")}read(t,e){return t.readAttribute(this._field)}readWithDefault(t,e){return t.readAttribute(this._field)}referencesScale(){return!1}referencesGeometry(){return!1}}var Zc=s(6384);function Qc(t,e,s){if(null==t)return null;const i=e.readArcadeFeature();e.contextTimeZone=s.$view?.timeZone;try{return t.evaluate({...s,$feature:i},t.services)}catch(t){return C.c.getLogger("geoscene.views.2d.support.arcadeOnDemand").warn("Feature arcade evaluation failed:",t),null}}function Jc(t){return null==t||t===1/0||t===-1/0||"number"==typeof t&&isNaN(t)}function tl(t,e,s,i){if(null==t)return null!=i?i:null;const r=e.readArcadeFeature();e.contextTimeZone=s.$view?.timeZone;const n=t.evaluate({...s,$feature:r},t.services);return Jc(n)?null!=i?i:null:n}class el extends ot{static async create(t,e){const s=await(0,Zc.kr)(t,e.spatialReference,e.fields),i=(0,st.sV)(t);return new el(s,i)}constructor(t,e){super(),this._compiled=t,this._cacheKey=e}resize(t){}read(t,e){return this.referencesScale()||"system"!==e.$view.timeZone?Qc(this._compiled,t,e):this._readCached(t,e)}readWithDefault(t,e,s){return this.referencesScale()||"system"!==e.$view.timeZone?tl(this._compiled,t,e,s):this._readWithDefaultCached(t,e,s)}referencesScale(){return this._compiled?.referencesScale()??!1}referencesGeometry(){return this._compiled?.referencesGeometry()??!1}_readCached(t,e){if(t.setCache(this._cacheKey),t.hasCachedValue())return t.getCachedValue();const s=Qc(this._compiled,t,e);return t.setCachedValue(s),s}_readWithDefaultCached(t,e,s){if(t.setCache(this._cacheKey),t.hasCachedValue())return t.getCachedValue();const i=tl(this._compiled,t,e,s);return t.setCachedValue(i),i}}var sl=s(47828),il=s(54052),rl=s(41936),nl=s(564),ol=s(4144);class al extends ot{static async create(t,e){const s=(0,ol.y6)(t);return new al((t=>s.replaceAll(/{[^}]*}/g,(e=>{const s=e.slice(1,-1),i=t.metadata.fieldsIndex.get(s);if(null==i)return e;const r=t.readAttribute(s);return null==r?"":function(t,e){if(null==t)return"";const s=e.domain;if(s)if("codedValue"===s.type||"coded-value"===s.type){const e=t;for(const t of s.codedValues)if(t.code===e)return t.name}else if("range"===s.type){const{max:i,min:r}=(0,rl.w1)(e),n=+t;if(null!=r&&null!=i&&r<=n&&n<=i)return s.name}let i=t;return(0,nl.gp)(e)?i=(0,sl._m)(i,(0,sl.Cg)("short-date")):(0,nl.iW)(e)&&(i=(0,il.iy)(+i)),i||""}(r,i)}))))}constructor(t){super(),this._evaluator=t}resize(t){}read(t,e){return this._evaluator(t)}readWithDefault(t,e,s){const i=this._evaluator(t);return Jc(i)?s:i}referencesScale(){return!1}referencesGeometry(){return!1}}class hl extends ot{constructor(t,e){super(),this._field=t,this._normalizationInfo=e}resize(t){throw new Error("Method not implemented.")}read(t,e){return this._readNormalized(t)}readWithDefault(t,e){return this._readNormalized(t)}referencesScale(){return!1}referencesGeometry(){return!1}_readNormalized(t){const e=t.readAttribute(this._field);if(null==e)return null;const{normalizationField:s,normalizationTotal:i,normalizationType:r}=this._normalizationInfo,n=t.readAttribute(s);switch(r??"esriNormalizeByField"){case"esriNormalizeByField":return n?n?e/n:void 0:null;case"esriNormalizeByLog":return Math.log(e)*Math.LOG10E;case"esriNormalizeByPercentOfTotal":return i?e/i*100:null}}}class cl{static fromBuffer(t,e){return new cl(t,e)}static create(t,e=4294967295){const s=new Uint32Array(Math.ceil(t/32));return new cl(s,e)}constructor(t,e){this._mask=0,this._buf=t,this._mask=e}_getIndex(t){return Math.floor(t/32)}has(t){const e=this._mask&t;return!!(this._buf[this._getIndex(e)]&1<<e%32)}hasRange(t,e){let s=t,i=e;for(;s%32&&s!==i;){if(this.has(s))return!0;s++}for(;i%32&&s!==i;){if(this.has(s))return!0;i--}if(s===i)return!1;for(let t=s/32;t!==i/32;t++)if(this._buf[t])return!0;return!1}set(t){const e=this._mask&t,s=this._getIndex(e),i=1<<e%32;this._buf[s]|=i}setRange(t,e){let s=t,i=e;for(;s%32&&s!==i;)this.set(s++);for(;i%32&&s!==i;)this.set(i--);if(s!==i)for(let t=s/32;t!==i/32;t++)this._buf[t]=4294967295}unset(t){const e=this._mask&t,s=this._getIndex(e),i=1<<e%32;this._buf[s]&=4294967295^i}resize(t){const e=this._buf,s=new Uint32Array(Math.ceil(t/32));s.set(e),this._buf=s}or(t){for(let e=0;e<this._buf.length;e++)this._buf[e]|=t._buf[e];return this}and(t){for(let e=0;e<this._buf.length;e++)this._buf[e]&=t._buf[e];return this}xor(t){for(let e=0;e<this._buf.length;e++)this._buf[e]^=t._buf[e];return this}ior(t){for(let e=0;e<this._buf.length;e++)this._buf[e]|=~t._buf[e];return this}iand(t){for(let e=0;e<this._buf.length;e++)this._buf[e]&=~t._buf[e];return this}ixor(t){for(let e=0;e<this._buf.length;e++)this._buf[e]^=~t._buf[e];return this}any(){for(let t=0;t<this._buf.length;t++)if(this._buf[t])return!0;return!1}copy(t){for(let e=0;e<this._buf.length;e++)this._buf[e]=t._buf[e];return this}clone(){return new cl(this._buf.slice(),this._mask)}clear(){for(let t=0;t<this._buf.length;t++)this._buf[t]=0;return this}forEachSet(t){for(let e=0;e<this._buf.length;e++){let s=this._buf[e],i=32*e;if(s)for(;s;)1&s&&t(i),s>>>=1,i++}}countSet(){let t=0;return this.forEachSet((e=>{t++})),t}}var ll=s(44247);const ul=()=>C.c.getLogger("geoscene.views.2d.layers.features.support.whereUtils"),dl={getAttribute:(t,e)=>t.readAttribute(e)};async function pl(t,e){try{const s=await(0,ll.u)(t,e);if(!s.isStandardized){const t=new i.c("mapview - bad input","Unable to apply filter's definition expression, as expression is not standardized.",s);ul().error(t)}return e=>{const i=e.readArcadeFeature();try{return s.testFeature(i,dl)}catch(e){return ul().warn("mapview-bad-where-clause","Encountered an error when evaluating where clause",t),!0}}}catch(e){return ul().warn("mapview-bad-where-clause","Encountered an error when evaluating where clause",t),t=>!0}}const _l=()=>C.c.getLogger("geoscene.views.2d.layers.features.support.ComputedAttributeStorage"),fl=4294967295;function ml(t,e,s){if(!(t.length>e))for(;t.length<=e;)t.push(s)}class gl{constructor(t){this._numerics=[],this._strings=[],this._allocatedSize=256,this._bitsets=[],this._instanceIds=[],this._bounds=[],this._dirtyBitset=this.getBitset(this.createBitset()),this.compilationOptions=t}createBitset(){const t=this._bitsets.length;return this._bitsets.push(cl.create(this._allocatedSize,Oh)),t+1}async createComputedField(t,e=!1){if(t.expression)try{if(!this.compilationOptions)throw new Error("InternalError: Compilation options not defined");return e?al.create(t.expression,this.compilationOptions):await el.create(t.expression,this.compilationOptions)}catch(e){const s=new i.c("featurelayer","Failed to compile arcade expression",{error:e,expression:t.expression});return _l().error(s),null}if(t.normalizationType||t.normalizationField)return new hl(t.field,t);if(t.field)return new Kc(t.field);const s=new i.c("featurelayer","Unable to create computed field. No expression or field found",{info:t});return _l().error(s),null}async createWhereClause(t){return t?pl(t,this.compilationOptions.fields):null}getBitset(t){return this._bitsets[t-1]}getComputedNumeric(t,e){return this.getComputedNumericAtIndex(t&Oh,0)}setComputedNumeric(t,e,s){return this.setComputedNumericAtIndex(t&Oh,s,0)}getComputedString(t,e){return this.getComputedStringAtIndex(t&Oh,0)}setComputedString(t,e,s){return this.setComputedStringAtIndex(t&Oh,0,s)}getComputedNumericAtIndex(t,e){const s=t&Oh;return this._ensureNumeric(e,s),this._numerics[e][s]}setComputedNumericAtIndex(t,e,s){const i=t&Oh;this._ensureNumeric(e,i),this._numerics[e][i]=s}getPackedChunkId(t){const e=t&Oh;return this._ensureInstanceId(e),this._instanceIds[e]}setPackedChunkId(t,e){const s=t&Oh;this._ensureInstanceId(s),this._instanceIds[s]=e}getComputedStringAtIndex(t,e){const s=t&Oh;return this._ensureString(e,s),this._strings[e][s]}setComputedStringAtIndex(t,e,s){const i=t&Oh;this._ensureString(e,i),this._strings[e][i]=s}getXMin(t){return this._bounds[4*(t&Oh)]}getYMin(t){return this._bounds[4*(t&Oh)+1]}getXMax(t){return this._bounds[4*(t&Oh)+2]}getYMax(t){return this._bounds[4*(t&Oh)+3]}setBounds(t,e,s=!1){const i=t&Oh;if(!s&&!this._dirtyBitset.has(t))return this._bounds[4*i]!==fl;this._dirtyBitset.unset(t);const r=e.readGeometryWorldSpace();if(ml(this._bounds,4*i+4,0),!r||!r.coords.length)return this._bounds[4*i]=fl,this._bounds[4*i+1]=fl,this._bounds[4*i+2]=fl,this._bounds[4*i+3]=fl,!1;let n=1/0,o=1/0,a=-1/0,h=-1/0;return r.forEachVertex(((t,e)=>{n=Math.min(n,t),o=Math.min(o,e),a=Math.max(a,t),h=Math.max(h,e)})),this._bounds[4*i]=n,this._bounds[4*i+1]=o,this._bounds[4*i+2]=a,this._bounds[4*i+3]=h,!0}getBounds(t,e){const s=this.getXMin(e),i=this.getYMin(e),r=this.getXMax(e),n=this.getYMax(e);return(0,Vc.qy)(t,s,i,r,n),s!==fl}_ensureNumeric(t,e){this._numerics[t]||(this._numerics[t]=[]),ml(this._numerics[t],e,0)}_ensureInstanceId(t){ml(this._instanceIds,t,0)}_ensureString(t,e){this._strings[t]||(this._strings[t]=[]),ml(this._strings[t],e,null)}}var yl=s(3900),xl=s(79596),bl=s(78104),wl=s(95776);class vl{getObjectId(t){return t.getObjectId()}getAttributes(t){return t.readAttributes()}getAttribute(t,e){return t.readAttribute(e)}getAttributeAsTimestamp(t,e){return t.readAttributeAsTimestamp(e)}cloneWithGeometry(t,e){return t}getGeometry(t){return t.readGeometryWorldSpace()}getCentroid(t,e){return t.readCentroidForDisplay()}}vl.Shared=new vl;class Sl{constructor(t){this._geometryBounds=(0,L.Su)(),this._idToVisibility=new Map,this._serviceInfo=t}static async create(t){const e=new Sl(t);return await e.update(t.filterJSON,t.spatialReference),e}get hash(){return this._hash}check(t){return this._applyFilter(t)}clear(){const t=this._resetAllHiddenIds();return this.update(),{show:t,hide:[]}}invalidate(){this._idToVisibility.forEach(((t,e)=>{this._idToVisibility.set(e,0)}))}setKnownIds(t){for(const e of t)this._idToVisibility.set(e,1)}setTrue(t){const e=[],s=[],i=new Set(t);return this._idToVisibility.forEach(((t,r)=>{const n=!!(1&this._idToVisibility.get(r)),o=i.has(r);!n&&o?e.push(r):n&&!o&&s.push(r),this._idToVisibility.set(r,o?3:0)})),{show:e,hide:s}}createQuery(){const{geometry:t,spatialRel:e,where:s,timeExtent:i,objectIds:r}=this;return wl.c.fromJSON({geometry:t,spatialRel:e,where:s,timeExtent:i,objectIds:r})}async update(t,e){this._hash=JSON.stringify(t);const s=await(0,yl._8)(t,null,e);await Promise.all([this._setGeometryFilter(s),this._setIdFilter(s),this._setAttributeFilter(s),this._setTimeFilter(s)])}async _setAttributeFilter(t){if(!t?.where)return this._clause=null,void(this.where=null);this._clause=await pl(t.where,this._serviceInfo.fieldsIndex),this.where=t.where}_setIdFilter(t){this._idsToShow=t?.objectIds&&new Set(t.objectIds),this._idsToHide=t?.hiddenIds&&new Set(t.hiddenIds),this.objectIds=t?.objectIds}async _setGeometryFilter(t){if(!t?.geometry)return this._spatialQueryOperator=null,this.geometry=null,void(this.spatialRel=null);const e=t.geometry,s=t.spatialRel||"esriSpatialRelIntersects",i=await(0,xl.q0)(s,e,this._serviceInfo.geometryType,this._serviceInfo.hasZ,this._serviceInfo.hasM);(0,Ge.ac)(this._geometryBounds,e),this._spatialQueryOperator=i,this.geometry=e,this.spatialRel=s}_setTimeFilter(t){if(this.timeExtent=this._timeOperator=null,t?.timeExtent)if(this._serviceInfo.timeInfo)this.timeExtent=t.timeExtent,this._timeOperator=(0,bl.k)(this._serviceInfo.timeInfo,t.timeExtent,vl.Shared);else{const e=new i.c("feature-layer-view:time-filter-not-available","Unable to apply time filter, as layer doesn't have time metadata.",t.timeExtent);C.c.getLogger("geoscene.views.2d.layers.features.controllers.FeatureFilter").error(e)}}_applyFilter(t){return this._filterByGeometry(t)&&this._filterById(t)&&this._filterByTime(t)&&this._filterByExpression(t)}_filterByExpression(t){return!this.where||this._clause(t)}_filterById(t){return(!this._idsToHide?.size||!this._idsToHide.has(t.getObjectId()))&&(!this._idsToShow?.size||this._idsToShow.has(t.getObjectId()))}_filterByGeometry(t){if(!this.geometry)return!0;const e=t.readGeometryWorldSpace();return!!e&&this._spatialQueryOperator(e)}_filterByTime(t){return null==this._timeOperator||this._timeOperator(t)}_resetAllHiddenIds(){const t=[];return this._idToVisibility.forEach(((e,s)=>{1&e||(this._idToVisibility.set(s,1),t.push(s))})),t}}var Il=s(16424);class Tl{constructor(t){this._options=t,this._fieldsIndex="fieldsIndex"in t?Il.c.fromJSON(t.fieldsIndex):new Il.c(t.fields),t.spatialReference&&(this._spatialReference=V.c.fromJSON(t.spatialReference)),this._arcadeSchema={fields:this.fieldsIndex.fields,fieldsIndex:this.fieldsIndex,geometryType:this.geometryType,objectIdField:this.objectIdField,globalIdField:this._options.globalIdField,spatialReference:this._spatialReference,timeInfo:this._options.timeInfo,typeIdField:this._options.typeIdField??void 0,types:this._options.types??void 0,subtypeField:this._options.subtypeField,subtypes:this._options.subtypes??void 0}}get fieldsIndex(){return this._fieldsIndex}get geometryType(){return this._options.geometryType}get timeInfo(){return this._options.timeInfo}get objectIdField(){return this._options.objectIdField}get globalIdField(){return this._options.globalIdField}get arcadeSchema(){return this._arcadeSchema}get spatialReference(){return this._spatialReference}get timeReferenceUnknownClient(){return this._options.timeReferenceUnknownClient}}var Pl=s(10724),Ml=s(85436),El=s(62024),Cl=s(28484);class kl{constructor(t){this._valid=cl.create(t),this._data=new Array(t)}has(t){return this._valid.has(t)}set(t,e){this._valid.set(t),this._data[t]=e}get(t){return this._data[t]}}const Fl=(0,n.c)("featurelayer-simplify-thresholds")??[.5,.5,.5,.5],Al=Fl[0],Rl=Fl[1],Ol=Fl[2],Nl=Fl[3],Dl=(0,n.c)("featurelayer-simplify-payload-size-factors")??[1,2,4],zl=Dl[0],Ll=Dl[1],Bl=Dl[2],Ul=(0,n.c)("featurelayer-simplify-mobile-factor")??2,Gl=(0,n.c)("geoscene-mobile"),Vl=4294967295;class ql{constructor(t){this.metadata=t,this.type="FeatureSetReader",this._deleted=null,this._joined=[],this._objectIdToIndex=null,this._boundsBuffer=[],this._caches=new Map,this.arcadeDeclaredClass="geoscene.arcade.Feature",this._contextTimeZone=null}get isEmpty(){return null!=this._deleted&&this._deleted.countSet()===this.getSize()}getAreaSimplificationThreshold(t,e){let s=1;const i=Gl?Ul:1;e>4e6?s=Bl*i:e>1e6?s=Ll*i:e>5e5?s=zl*i:e>1e5&&(s=i);let r=0;return t>4e3?r=Nl*s:t>2e3?r=Ol*s:t>100?r=Rl:t>15&&(r=Al),r}parseTimestampOffset(t){return t}getBounds(t){if(function(t,e,s){if(!(t.length>e))for(;t.length<=e;)t.push(0)}(this._boundsBuffer,4*this.getIndex()+4),this.getBoundsXMin()===Vl)return!1;if(0===this.getBoundsXMin()){const e=this.readGeometryWorldSpace();if(!e)return this.setBoundsXMin(Vl),!1;let s=1/0,i=1/0,r=-1/0,n=-1/0;return e.forEachVertex(((t,e)=>{s=Math.min(s,t),i=Math.min(i,e),r=Math.max(r,t),n=Math.max(n,e)})),this.setBoundsXMin(s),this.setBoundsYMin(i),this.setBoundsXMax(r),this.setBoundsYMax(n),(0,Vc.qy)(t,s,i,r,n),!0}const e=this.getBoundsXMin(),s=this.getBoundsYMin(),i=this.getBoundsXMax(),r=this.getBoundsYMax();return(0,Vc.qy)(t,e,s,i,r),!0}getBoundsXMin(){return this._boundsBuffer[4*this.getIndex()]}setBoundsXMin(t){this._boundsBuffer[4*this.getIndex()]=t}getBoundsYMin(){return this._boundsBuffer[4*this.getIndex()+1]}setBoundsYMin(t){this._boundsBuffer[4*this.getIndex()+1]=t}getBoundsXMax(){return this._boundsBuffer[4*this.getIndex()+2]}setBoundsXMax(t){this._boundsBuffer[4*this.getIndex()+2]=t}getBoundsYMax(){return this._boundsBuffer[4*this.getIndex()+3]}setBoundsYMax(t){this._boundsBuffer[4*this.getIndex()+3]=t}readAttributeAsTimestamp(t){const e=this.readAttribute(t);return"string"==typeof e?new Date(e).getTime():"number"==typeof e||null==e?e:null}readAttribute(t,e=!1){const s=this._readAttribute(t,e);if(void 0!==s)return s;for(const s of this._joined){s.setIndex(this.getIndex());const i=s._readAttribute(t,e);if(void 0!==i)return i}}readAttributes(){const t=this._readAttributes();for(const e of this._joined){e.setIndex(this.getIndex());const s=e._readAttributes();for(const e of Object.keys(s))t[e]=s[e]}return t}joinAttributes(t){this._joined.push(t)}removeIds(t){if(null==this._objectIdToIndex){const t=new Map,e=this.getCursor();for(;e.next();){const s=e.getObjectId();(0,M.EN)(s),t.set(s,e.getIndex())}this._objectIdToIndex=t}const e=this._objectIdToIndex;for(const s of t.values())e.has(s)&&this._removeAtIndex(e.get(s))}readOptimizedFeatureWorldSpace(){const t=this.readGeometryWorldSpace(),e=this.readAttributes(),s=this.readCentroidWorldSpace(),i=new Lc._M(t,e,s);return i.objectId=this.getObjectId(),i.displayId=this.getDisplayId(),i}readLegacyFeatureForDisplay(){const t=this.readCentroidForDisplay();return{attributes:this.readAttributes(),geometry:this.readLegacyGeometryForDisplay(),centroid:(t&&{x:t.coords[0],y:t.coords[1]})??null}}readLegacyFeatureWorldSpace(){const t=this.readCentroidWorldSpace();return{attributes:this.readAttributes(),geometry:this._readLegacyGeometryWorldSpace(),centroid:(t&&{x:t.coords[0],y:t.coords[1]})??null}}readLegacyGeometryForDisplay(){const t=this.readGeometryForDisplay();return(0,zc.qw)(t,this.geometryType,!1,!1)}readXForDisplay(){return this._readX()}readYForDisplay(){return this._readY()}readXWorldSpace(){const t=this._readX(),e=this.getInTransform();return null==e?t:t*e.scale[0]+e.translate[0]}readYWorldSpace(){const t=this._readY(),e=this.getInTransform();return null==e?t:e.translate[1]-t*e.scale[1]}readGeometryForDisplay(){const t=this._readGeometryDeltaDecoded(!0);if(!t){const t=this._createGeometryFromServerCentroid();return t?t.deltaDecode():null}return t}readGeometryWorldSpace(){let t=this._readGeometry();if(t||(t=this._createGeometryFromServerCentroid()),!t)return null;const e=t.clone(),s=this.getInTransform();return null!=s&&(0,zc.Ij)(e,e,this.hasZ,this.hasM,s),e}readCentroidForDisplay(){const t=this.readGeometryForDisplay();return t?this._computeDisplayCentroid(t):this._readServerCentroid()}readCentroidWorldSpace(){const t=this.readGeometryForDisplay(),e=t?this._computeDisplayCentroid(t):this._readServerCentroid();if(!e)return null;const s=e.clone(),i=this.getInTransform();return null!=i&&(0,zc.Ij)(s,s,this.hasZ,this.hasM,i),s}setCache(t){let e=this._caches.get(t);null==e&&(e=new kl(this.getSize()),this._caches.set(t,e)),this._activeCache=e}setCachedValue(t){this._activeCache.set(this.getIndex(),t)}hasCachedValue(){return this._activeCache.has(this.getIndex())}getCachedValue(){return this._activeCache.get(this.getIndex())}_readGeometryDeltaDecoded(t){const e=this._readGeometry(t);return"esriGeometryPoint"!==this.geometryType&&e&&this.getInTransform()?e.deltaDecode():e}get contextTimeZone(){return this._contextTimeZone}set contextTimeZone(t){this._contextTimeZone=t}readArcadeFeature(){return this}hasField(t){return this.fields.has(t)||this._joined.some((e=>e.hasField(t)))}geometry(){const t=this.readGeometryWorldSpace(),e=(0,zc.qw)(t,this.geometryType,this.hasZ,this.hasM),s=(0,Yt.h4)(e);if(s){if(!this.metadata.spatialReference)throw new Error("InternalError: Expected spatial reference to be defined");s.spatialReference=this.metadata.spatialReference}return s}autocastArcadeDate(t,e){return e&&e instanceof Date?this.isUnknownDateTimeField(t)?Pl.Ql.unknownDateJSToArcadeDate(e):Pl.Ql.dateJSAndZoneToArcadeDate(e,this.contextTimeZone??Cl.OX):e}isUnknownDateTimeField(t){return this.metadata.fieldsIndex.getTimeZone(t)===Cl.OI}field(t){let e=this.fields.get(t);if(e)switch(e.type){case"date-only":case"esriFieldTypeDateOnly":return Ml.K.fromReader(this.readAttribute(t,!1));case"time-only":case"esriFieldTypeTimeOnly":return El.C.fromReader(this.readAttribute(t,!1));case"esriFieldTypeTimestampOffset":case"timestamp-offset":return Pl.Ql.fromReaderAsTimeStampOffset(this.readAttribute(t,!1));case"date":case"esriFieldTypeDate":return this.autocastArcadeDate(t,this.readAttribute(t,!0));default:return this.readAttribute(t,!1)}for(const s of this._joined)if(s.setIndex(this.getIndex()),e=s.fields.get(t),e)switch(e.type){case"date-only":case"esriFieldTypeDateOnly":return Ml.K.fromReader(s._readAttribute(t,!1));case"time-only":case"esriFieldTypeTimeOnly":return El.C.fromReader(s._readAttribute(t,!1));case"esriFieldTypeTimestampOffset":case"timestamp-offset":return Pl.Ql.fromReaderAsTimeStampOffset(s._readAttribute(t,!1));case"date":case"esriFieldTypeDate":return this.autocastArcadeDate(t,s._readAttribute(t,!0));default:return this.readAttribute(t,!1)}throw new Error(`Field ${t} does not exist`)}setField(t,e){throw new Error("Unable to update feature attribute values, feature is readonly")}keys(){return this.fields.fields.map((t=>t.name))}castToText(t=!1){if(!t)return JSON.stringify(this.readLegacyFeatureForDisplay());const e=this.readLegacyFeatureForDisplay();if(!e)return JSON.stringify(null);const s={geometry:e.geometry,attributes:{...e.attributes??{}}};for(const t in s.attributes){const e=s.attributes[t];e instanceof Date&&(s.attributes[t]=e.getTime())}return JSON.stringify(s)}gdbVersion(){return null}fullSchema(){return this.metadata.arcadeSchema}castAsJson(t=null){return{attributes:this._readAttributes(),geometry:!0===t?.keepGeometryType?this.geometry():this.geometry()?.toJSON()??null}}castAsJsonAsync(t=null,e=null){return Promise.resolve(this.castAsJson(e))}_getExists(){return null==this._deleted||!this._deleted.has(this.getIndex())}_computeDisplayCentroid(t){const e=jt.fromOptimized(t,this.geometryType);e.yFactor*=-1;const s=_s(e);return s?(s[1]*=-1,new ft.c([],s)):null}copyInto(t){t._joined=this._joined,t._deleted=this._deleted,t._objectIdToIndex=this._objectIdToIndex,t._boundsBuffer=this._boundsBuffer,t._activeCache=this._activeCache,t._caches=this._caches}_readLegacyGeometryWorldSpace(){const t=this.readGeometryWorldSpace();return(0,zc.qw)(t,this.geometryType,!1,!1)}_createGeometryFromServerCentroid(){const t=this._readServerCentroid();if(!t)return null;const[e,s]=t.coords;return this._createQuantizedExtrudedGeometry(e,s)}_createQuantizedExtrudedGeometry(t,e){return"esriGeometryPolyline"===this.geometryType?this._createQuantizedExtrudedLine(t,e):this._createQuantizedExtrudedQuad(t,e)}_createQuantizedExtrudedQuad(t,e){return new ft.c([5],[t-1,e,1,-1,1,1,-1,1,-1,-1])}_createQuantizedExtrudedLine(t,e){return new ft.c([2],[t-1,e+1,1,-1])}_removeAtIndex(t){null==this._deleted&&(this._deleted=cl.create(this.getSize())),this._deleted.set(t)}}class Wl extends ql{static fromFeatures(t,e){const{objectIdField:s,geometryType:i}=e,r=(0,zc.od)([],t,i,!1,!1,s);for(let e=0;e<r.length;e++)r[e].displayId=t[e].displayId;return Wl.fromOptimizedFeatures(r,e)}static fromFeatureSet(t,e){const s=(0,zc.ui)(t,e.objectIdField);return Wl.fromOptimizedFeatureSet(s,e)}static fromOptimizedFeatureSet(t,e){const s=Wl.fromOptimizedFeatures(t.features,e);return s._exceededTransferLimit=t.exceededTransferLimit,s._transform=t.transform,s._fieldsIndex=new Il.c(t.fields),s}static fromOptimizedFeatures(t,e,s){const i=new Wl(t,e);return i._fieldsIndex=e.fieldsIndex,i._transform=s,i}static empty(t){return new Wl([],t)}constructor(t,e){super(e),this._exceededTransferLimit=!1,this._featureIndex=-1,this._fieldsIndex=null,this._geometryType=e.geometryType,this._features=t}get fields(){return this._fieldsIndex}get geometryType(){return this._geometryType}get hasFeatures(){return!!this._features.length}get hasNext(){return this._featureIndex+1<this._features.length}get exceededTransferLimit(){return this._exceededTransferLimit}get hasZ(){return!1}get hasM(){return!1}get _current(){return this._features[this._featureIndex]}removeIds(t){const e=new Set(t);this._features=this._features.filter((t=>!(null!=t.objectId&&e.has(t.objectId))))}getSize(){return this._features.length}getCursor(){return this.copy()}getInTransform(){return this._transform}getAttributeHash(){let t="";for(const e in this._current.attributes)t+=this._current.attributes[e];return t}getIndex(){return this._featureIndex}setIndex(t){this._featureIndex=t}getObjectId(){return this._current?.objectId}getDisplayId(){return this._current.displayId}setDisplayId(t){this._current.displayId=t}copy(){const t=new Wl(this._features,this.metadata);return this.copyInto(t),t}next(){for(;++this._featureIndex<this._features.length&&!this._getExists(););return this._featureIndex<this._features.length}readGeometryArea(){return(0,Lc.ED)(this._current)?(0,zc.Oo)(this._current.geometry,2):0}_readX(){return(0,Lc.ED)(this._current)?this._current.geometry.coords[0]:0}_readY(){return(0,Lc.ED)(this._current)?this._current.geometry.coords[1]:0}_readGeometry(){return(0,Lc.ED)(this._current)?this._current.geometry??null:null}_readServerCentroid(){return this._current.centroid}_readAttribute(t,e){if(!this._fieldsIndex){const e=this._current.attributes[t];if(void 0!==e)return e;const s=t.toLowerCase();for(const t in this._current.attributes)if(t.toLowerCase()===s)return this._current.attributes[t];return}const s=this._fieldsIndex.get(t);if(!s)return;let i=this._current.attributes[s.name];return null==i?i:("esriFieldTypeTimestampOffset"===this.fields.get(t)?.type&&(i=this.parseTimestampOffset(i)),e&&this.fields.isDateField(t)?new Date(i):i)}_readAttributes(){return this._current.attributes}copyInto(t){super.copyInto(t),t._featureIndex=this._featureIndex,t._transform=this._transform,t._fieldsIndex=this._fieldsIndex}}class Xl extends Xc{constructor(t,e){super(t),this.bins=new Map,this.done=!1,this._store=e}reset(){this.destroy(),this.bins.clear(),this.done=!1,this.handledChunks.clear()}destroy(){const t=this.subscription.tile.key.level;for(const e of this.bins.values()){const s=e.cachedFeature?.objectId;null!=s&&this._store.releaseDisplayIdForObjectId(`${s}.${t}`)}}*featuresWorldSpace(){for(const t of this.bins.values()){const e=t.cachedFeature;if(e){const t=e.clone();(0,zc.Ij)(t.geometry,t.geometry,!1,!1,this.subscription.tile.transform),yield t}}}getGeohashBounds(t,e){const s=this.subscription.tile;return(0,Dc.wt)(s.extent,s.resolution,e,t)}}class Yl extends jc{static async create(t,e,s,i,r){const n=new gl({spatialReference:e}),o=t.fixedBinLevel,a=await Promise.all(t.fields.map((async t=>Uc.create(n,t)))),h=t.featureFilter?await Sl.create({geometryType:s.metadata.geometryType,hasM:!1,hasZ:!1,timeInfo:s.metadata.timeInfo,fieldsIndex:s.metadata.fieldsIndex,spatialReference:e,filterJSON:t.featureFilter}):null;return await(0,Bc.Qv)(e,V.c.WGS84),new Yl({fields:a,geohashLevel:o,spatialReference:e,featureFilter:h,timeZone:r},t.fields,s,i)}constructor(t,e,s,i){super(s,i,t.spatialReference,t.fields),this._indexOptions=t,this._metadata=new Tl({geometryType:"esriGeometryPolygon",objectIdField:"aggregateId",fields:e,globalIdField:null,spatialReference:s.metadata.spatialReference,subtypeField:null,subtypes:null,timeInfo:null,timeReferenceUnknownClient:null,typeIdField:null,types:null})}createState(t){return new Xl(t,this._attributeStore)}async*applyOverride(t){for(const t of this._sendStates.values())t.reset()}displayMap(t,e,s){const i=new Map(t.map((t=>[e(t),t]))),r=[];for(const t of this._sendStates.values())for(const e of t.featuresWorldSpace()){const{objectId:t,displayId:n}=e,o=i.get(t);if(null!=o){const e=s(n,o,t);r.push(e),i.delete(t)}}return r}getDisplayFeatures(t){const e=new Set(t),s=new Set,i=[];for(const t of this._sendStates.values())for(const r of t.featuresWorldSpace())e.has(r.displayId)&&!s.has(r.objectId)&&(r.geometry&&i.push({...(0,zc.G0)(r,this._metadata.geometryType,!1,!1),displayId:r.displayId}),s.add(r.objectId));return{features:[],aggregates:i}}getFeatureObjectIdsForAggregate(t){for(const e of this._sendStates.values())for(const s of e.bins.values())if(s.id===t)return Array.from(s.objectIds);return[]}async*updateChunks(){if(this._source.chunks().length)for(const t of this._sendStates.values())yield*this._update(t,this._source)}forEachAggregateWorldSpace(t){for(const e of this._sendStates.values())for(const s of e.featuresWorldSpace())t(s)}async*_update(t,e){const{handledChunks:s,subscription:i,bins:r}=t,{spatialReference:n,geohashLevel:o}=this._indexOptions,a=i.tile;if(t.done)return;for(const i of e.chunks()){if(s.has(i.chunkId))continue;s.add(i.chunkId);const e=i.queryInfo;if("tileId"in e){const t=new p.c(e.tileId);if(t.level!==a.level||t.world!==a.key.world)continue}const h=i.getGeohashIndex(this._indexOptions),c=t.getGeohashBounds(n,o);null!=c&&h.putBins(r,c)}const h=[],c=i.tile.transform,l=i.tile.key.level;for(const t of r.values()){if(t.cachedFeature)t.cachedFeature.attributes=t.getAttributes();else{const e=t.getGeometry(this.spatialReference,c),s=new Lc._M(e,t.getAttributes(),null);e||(s.centroid=t.getGeometryCentroid(this.spatialReference,c)),s.objectId=t.id,s.displayId=this._attributeStore.createDisplayIdForObjectId(`${s.objectId}.${l}`),t.cachedFeature=s}h.push(t.cachedFeature)}this.events.emit("changed"),t.done=!e.updateTracking.updating;const u=Wl.fromOptimizedFeatures(h,this._metadata,c),d=u.getCursor(),_=t.subscription.tile.createArcadeEvaluationOptions(this._indexOptions.timeZone);for(;d.next();)this._attributeStore.setAttributeData(d.getDisplayId(),d,_);const f=new $c(t.subscription,u,[],t.done,{});yield f}}const jl=Math.PI/180;class Hl{static create(t){return new Hl(t.map((t=>function(t){switch(t.statisticType){case"min":return new Kl(t);case"max":return new Zl(t);case"avg":return new Jl(t);case"avg_angle":return new tu(t);case"sum":case"count":return new Ql(t);case"mode":return new eu(t)}}(t))))}constructor(t){this._statistics=t}values(){return this._statistics.values()}insert(t,e){for(const s of this._statistics)s.insert(t,e)}merge(t){for(let e=0;e<this._statistics.length;e++){const s=this._statistics[e],i=t._statistics[e];if(s.field.name!==i.field.name)throw new Error("InternalError: Tried to merge incompatible statistics");s.merge(i)}}clone(){return new Hl(this._statistics.map((t=>t.clone())))}}class $l{constructor(t){this.field=t}insert(t,e){if(!this.field.computed)return;const s=this.field.computed.read(t,e);Jc(s)||this._insertValue(s)}}class Kl extends $l{constructor(){super(...arguments),this.type="min",this.value=Number.MAX_VALUE}_insertValue(t){this.value=Math.min(this.value,t)}merge(t){this.value=Math.min(this.value,t.value)}clone(){const t=new Kl(this.field);return t.value=this.value,t}}class Zl extends $l{constructor(){super(...arguments),this.type="max",this.value=Number.MIN_VALUE}_insertValue(t){this.value=Math.max(this.value,t)}merge(t){this.value=Math.max(this.value,t.value)}clone(){const t=new Zl(this.field);return t.value=this.value,t}}class Ql extends $l{constructor(){super(...arguments),this.type="sum",this.value=0}_insertValue(t){this.value+=t}merge(t){this.value+=t.value}clone(){const t=new Ql(this.field);return t.value=this.value,t}}class Jl extends $l{constructor(){super(...arguments),this.type="avg",this._total=0,this._count=0}get value(){return this._total/this._count}_insertValue(t){this._total+=t,this._count+=1}merge(t){this._total+=t._total,this._count+=t._count}clone(){const t=new Jl(this.field);return t._total=this._total,t._count=this._count,t}}class tu extends $l{constructor(){super(...arguments),this.type="avg_angle",this._x=0,this._y=0,this._count=0}get value(){const t=this._x/this._count,e=this._y/this._count,s=180/Math.PI;return Math.atan2(e,t)*s}_insertValue(t){this._x=this._x+Math.cos(t*jl),this._y=this._y+Math.sin(t*jl),this._count+=1}merge(t){this._x+=t._x,this._y+=t._y,this._count+=t._count}clone(){const t=new tu(this.field);return t._x=this._x,t._y=this._y,t._count=this._count,t}}class eu extends $l{constructor(){super(...arguments),this._frequencies=new Map}get value(){let t,e=0;for(const[s,i]of this._frequencies.entries())i>e&&(e=i,t=s);return t}_insertValue(t){const e=this._frequencies.get(t);null!=e?this._frequencies.set(t,e+1):this._frequencies.set(t,1)}merge(t){for(const[e,s]of t._frequencies.entries()){const t=this._frequencies.get(e);null!=t?this._frequencies.set(e,t+s):this._frequencies.set(e,s)}}clone(){const t=new eu(this.field);return t._frequencies=new Map(this._frequencies),t}}class su{static createId(t,e){return`${t}.${e}`}static create(t,e,s,i){return new su(t,e,Hl.create(s),i)}constructor(t,e,s,i){this.gridX=t,this.gridY=e,this._statistics=s,this._worldUnitsPerCell=i,this._count=0,this._xWorldTotal=0,this._yWorldTotal=0,this._objectIds=new Set}get id(){return su.createId(this.gridX,this.gridY)}get count(){return this._count}get statistics(){return this._statistics}get objectIds(){return this._objectIds}get firstObjectId(){return this._objectIds.values().next().value}get centroidXWorld(){return this._xWorldTotal/this._count}get centroidYWorld(){return this._yWorldTotal/this._count}clone(){const t=new su(this.gridX,this.gridY,this._statistics.clone(),this._worldUnitsPerCell);return t._count=this._count,t._xWorldTotal=this._xWorldTotal,t._yWorldTotal=this._yWorldTotal,t._firstFeatureAttributes=this._firstFeatureAttributes,t._objectIds=new Set(this._objectIds),t}insert(t,e,s,i){0===this._count?this._firstFeatureAttributes=t.readAttributes():this._firstFeatureAttributes=null,this._count+=1,this._xWorldTotal+=s,this._yWorldTotal+=i,this._statistics.insert(t,e),this._objectIds.add(t.getObjectId())}merge(t){if(0!==t._count){this._count+=t._count,this._firstFeatureAttributes=t._firstFeatureAttributes,this._xWorldTotal+=t._xWorldTotal,this._yWorldTotal+=t._yWorldTotal,this._statistics.merge(t._statistics);for(const e of t._objectIds.values())this._objectIds.add(e)}}getCentroidX(t){return null==t?this.centroidXWorld:(0,zc.uY)(t,this.centroidXWorld)}getCentroidY(t){return null==t?this.centroidYWorld:(0,zc.mk)(t,this.centroidYWorld)}getCentroid(t){const e=new ft.c([],[this.centroidXWorld,this.centroidYWorld]);if(null!=t){const s=new ft.c;return(0,zc.iC)(s,e,!1,!1,"esriGeometryPoint",t)}return e}getGeometricCentroid(t){const e=this.gridX*this._worldUnitsPerCell+.5*this._worldUnitsPerCell,s=this.gridY*this._worldUnitsPerCell+.5*this._worldUnitsPerCell,i=new ft.c([],[e,s]);if(null!=t){const e=new ft.c;return(0,zc.iC)(e,i,!1,!1,"esriGeometryPoint",t)}return i}getAttributes(){const t={aggregateId:this.id};for(const e of this._statistics.values())t[e.field.name]=e.value;return null!=this._firstFeatureAttributes?{...t,...this._firstFeatureAttributes}:t}}var iu=s(24296);function ru(t,e){return(0,iu.k8)(t)*iu.Co*96/e}class nu{constructor(t){this._options=t,this._cells=new Map,this._pixelsPerMapUnit=ru(t.spatialReference,t.scale)}insert(t,e){const s=t.getCursor(),i={$view:{scale:this._options.scale,timeZone:this._options.timeZone}};for(;s.next();)this._insertFeature(s,i,e)}putCellsInBounds(t,e){const[s,i,r,n]=e,o=Math.floor(s*this._pixelsPerMapUnit/this._options.cellSize),a=Math.floor(i*this._pixelsPerMapUnit/this._options.cellSize),h=Math.ceil(r*this._pixelsPerMapUnit/this._options.cellSize),c=Math.ceil(n*this._pixelsPerMapUnit/this._options.cellSize);for(let e=a;e<=c;e++)for(let s=o;s<=h;s++){const i=`${s}.${e}`,r=this._cells.get(i);if(!r)continue;const n=t.get(r.id);n?r&&!t.has(r.id)&&n.merge(r):t.set(r.id,r.clone())}}putCells(t){for(const e of this._cells.values()){const s=t.get(e.id);s?s.merge(e):t.set(e.id,e.clone())}}_insertFeature(t,e,s){const{featureFilter:i}=this._options;if(null!==i&&!i.check(t))return;let r=0,n=0;if("esriGeometryPoint"===t.geometryType)r=t.readXWorldSpace(),n=t.readYWorldSpace();else{if(s){const e=t.readCentroidForDisplay();if(null==e)return;const[s,i]=e.coords;if(s<0||s>B.gT||i<0||i>B.gT)return}const e=t.readCentroidWorldSpace();if(null==e)return;r=e.coords[0],n=e.coords[1]}const o=r*this._pixelsPerMapUnit,a=n*this._pixelsPerMapUnit,h=Math.floor(o/this._options.cellSize),c=Math.floor(a/this._options.cellSize);this._getCellOrCreate(h,c).insert(t,e,r,n)}_getCellOrCreate(t,e){const s=su.createId(t,e);let i=this._cells.get(s);if(!i){const r=1*this._options.cellSize/this._pixelsPerMapUnit;i=su.create(t,e,this._options.fields,r),this._cells.set(s,i)}return i}}class ou{constructor(t,e){this.inner=t,this.displayId=e}}class au extends Xc{constructor(t){super(t),this.didSend=!1,this.done=!1}}class hu{constructor(t,e,s,i,r){this._level=t,this._scale=e,this._indexOptions=s,this._clusterRadius=i,this._store=r,this._cells=new Map,this._handledChunks=new Set,this._statistics=new Map,this._clusters=new Map}destroy(){this._clearClusters()}_clearClusters(){for(const t of this._clusters.values())this._store.releaseDisplayIdForObjectId(t.inner.id);this._clusters.clear()}*aggregatesWorldSpace(){for(const t of this._clusters.values()){const e=t.inner.getCentroid(null),s=new Lc._M(e,t.inner.getAttributes(),null);s.objectId=t.inner.id,s.displayId=t.displayId,yield s}}clusters(){return this._clusters.values()}updateChunks(t,e){let s=!1;for(const e of t){const t=e.queryInfo;"tileId"in t&&new p.c(t.tileId).level!==this._level||this._handledChunks.has(e.normalizedChunkId)||(this._handledChunks.add(e.normalizedChunkId),s=!0,e.getGridIndex({...this._indexOptions,scale:this._scale}).putCells(this._cells))}const i={xMin:1/0,yMin:1/0,xMax:-1/0,yMax:-1/0},r=ru(this._indexOptions.spatialReference,this._scale),n=this._indexOptions.cellSize;for(const{subscription:t}of e){const e=t.tile.bounds,s=Math.floor(e[0]*r/n),o=Math.floor(e[1]*r/n),a=Math.ceil(e[2]*r/n),h=Math.ceil(e[3]*r/n);i.xMin=Math.min(i.xMin,s),i.yMin=Math.min(i.yMin,o),i.xMax=Math.max(i.xMax,a),i.yMax=Math.max(i.yMax,h)}return null!=this._lastCellBounds&&i.xMin===this._lastCellBounds.xMin&&i.yMin===this._lastCellBounds.yMin&&i.yMin===this._lastCellBounds.yMin&&i.yMax===this._lastCellBounds.yMax||(s=!0,this._lastCellBounds=i),s&&this._clusterCells(i),s}async updateStatistics(t){let e=!1;for(const t of this._clusters.values())t.inner.count>1&&(e=this._updateAggregateStatistics(this._statistics,t.inner)||e);if(e){const e=Array.from(this._statistics.entries()).map((([t,e])=>({fieldName:t,minValue:e.minValue,maxValue:e.maxValue})));await t.container.updateStatistics(this._level,e)}}createAggregateFeatures(t,e){const s=t.subscription,i=[],r=s.tile.transform;for(const t of this._clusters.values()){let e=t.inner.getCentroidX(r);const n=t.inner.getCentroidY(r),o=s.tile.lod,a=o.wrap?o.worldSize[0]:null,h=1===t.inner.count?t.inner.firstObjectId:t.inner.id,c=t.displayId;if(null!=a)if(1===a){const s=new ft.c([],[e,n]),r=new Lc._M(s,t.inner.getAttributes(),null);r.geometry.coords[0]-=B.gT,r.objectId=h,r.displayId=c,i.push(r);const o=new ft.c([],[e,n]),a=new Lc._M(o,t.inner.getAttributes(),null);a.geometry.coords[0]+=B.gT,a.objectId=h,a.displayId=c,i.push(a)}else e>B.gT+B.gT/2?e-=a*B.gT:e<-B.gT/2&&(e+=a*B.gT);if(e<B.gT+128&&e>=-128&&n<B.gT+128&&n>=-128){const s=new ft.c([],[e,n]),r=new Lc._M(s,t.inner.getAttributes(),null);r.objectId=h,r.displayId=c,i.push(r)}}return Wl.fromOptimizedFeatures(i,e,s.tile.transform)}_clusterCells(t){let e=Array.from(this._cells.values());e=e.sort(((t,e)=>e.count-t.count));const s=[];for(const t of this._clusters.values())s.push(t.inner.id);this._clusters.clear();const i=this._clusterRadius*(1/ru(this._indexOptions.spatialReference,this._scale)),r=1+this._clusterRadius/this._indexOptions.cellSize,n=new Set;for(const s of e){if(n.has(s.id))continue;if(s.gridX<t.xMin||s.gridX>t.xMax||s.gridY<t.yMin||s.gridY>t.yMax)continue;const e=this._store.createDisplayIdForObjectId(s.id),o=new ou(s.clone(),e);n.add(s.id),this._clusters.set(s.id,o);const a=s.centroidXWorld,h=s.centroidYWorld;for(let t=s.gridY-r;t<=s.gridY+r;t++)for(let e=s.gridX-r;e<=s.gridX+r;e++){if(t===s.gridY&&e===s.gridX)continue;const r=this._cells.get(su.createId(e,t));if(!r||n.has(r.id))continue;const c=Math.abs(r.centroidXWorld-a),l=Math.abs(r.centroidYWorld-h);c<i&&l<i&&(o.inner.merge(r),n.add(r.id))}}for(const t of s)this._store.releaseDisplayIdForObjectId(t)}_updateAggregateStatistics(t,e){let s=!1;for(const i of e.statistics.values()){if("esriFieldTypeString"===i.field.type)continue;const e=i.value,r=i.field,n=t.get(r.name);if(n){const{minValue:t,maxValue:i}=n,r=Math.min(n.minValue,e),o=Math.max(n.maxValue,e);t===r&&i===o||(n.minValue=r,n.maxValue=o,s=!0)}else t.set(r.name,{minValue:e,maxValue:e}),s=!0}return s}}class cu extends jc{static async create(t,e,s,i,r,n){const o=new gl({spatialReference:s}),a={fields:await Promise.all(e.fields.map((async t=>Uc.create(o,t)))),spatialReference:s,featureFilter:e.featureFilter?await Sl.create({geometryType:i.metadata.geometryType,hasM:!1,hasZ:!1,timeInfo:i.metadata.timeInfo,fieldsIndex:i.metadata.fieldsIndex,spatialReference:s,filterJSON:e.featureFilter}):null,cellSize:e.clusterRadius/4,timeZone:n};return new cu(t,e.clusterRadius,a,e.fields,i,r)}constructor(t,e,s,i,r,n){super(r,n,s.spatialReference,s.fields),this._connection=t,this._clusterRadius=e,this._indexOptions=s,this._cellsPerScale=new Map,this._metadata=new Tl({geometryType:"esriGeometryPoint",objectIdField:"aggregateId",fields:[...i,...this._source.metadata.fieldsIndex.fields,{name:"aggregateId",alias:"aggregateId",type:"esriFieldTypeOID"}],globalIdField:null,spatialReference:r.metadata.spatialReference,subtypeField:null,subtypes:null,timeInfo:null,timeReferenceUnknownClient:null,typeIdField:null,types:null})}get enablePixelBuffering(){return!1}invalidate(){super.invalidate();for(const t of this._cellsPerScale.values())t.destroy();this._cellsPerScale.clear()}onSubscribe(t){super.onSubscribe(t),this._requiredLevel=t.tile.level,this._requiredScale=t.tile.scale}createState(t){return new au(t)}async*applyOverride(t){for(const t of this._cellsPerScale.values())t.destroy();this._cellsPerScale.clear();for(const t of this._sendStates.values())t.done=!1}displayMap(t,e,s){const i=new Map(t.map((t=>[e(t),t]))),r=[],n=this._getClusterState(this._requiredLevel,this._requiredScale);for(const t of n.clusters()){const e=i.get(t.inner.id);if(null==e){if(1===t.inner.count){const e=i.get(t.inner.firstObjectId);if(null!=e){const n=s(t.displayId,e,t.inner.firstObjectId);r.push(n),i.delete(t.inner.firstObjectId)}}}else{const n=s(t.displayId,e,t.inner.id);r.push(n),i.delete(t.inner.id)}}return r}getDisplayFeatures(t){const e=new Set(t),s=new Set,i=[],r=[],n=this._getClusterState(this._requiredLevel,this._requiredScale);for(const t of n.aggregatesWorldSpace())if(e.has(t.displayId)&&!s.has(t.displayId)){const e=(0,zc.G0)(t,this._metadata.geometryType,!1,!1);if(s.add(t.displayId),1===e.attributes.cluster_count){i.push({...e,displayId:t.displayId});continue}r.push({...e,displayId:t.displayId})}return{features:i,aggregates:r}}getFeatureObjectIdsForAggregate(t){const e=this._getClusterState(this._requiredLevel,this._requiredScale);for(const s of e.clusters())if(s.inner.id===t)return Array.from(s.inner.objectIds);return[]}async*updateChunks(){const t=this._source.chunks();if(!t.length)return;const e=this._getClusterState(this._requiredLevel,this._requiredScale),s=Array.from(this._sendStates.values()).filter((t=>t.subscription.tile.level===this._requiredLevel));if(e.updateChunks(t,s)||!this._source.updateTracking.updating)for(const t of s)t.subscription.tile.level===this._requiredLevel&&(t.didSend=!1,t.done=!1);const i=Array.from(this._sendStates.values()).filter((t=>t.done)).map((t=>t.subscription.tile.key)),r=new Set(i);for(const t of this._sendStates.values()){if(this._source.updateTracking.updating){if(i.some((e=>e.containsChild(t.subscription.tile.key))))continue;if(t.subscription.tile.key.getChildKeys().every((t=>r.has(t))))continue}t.didSend||t.subscription.tile.level!==this._requiredLevel||(t.didSend=!0,yield*this._update(t,e,this._source))}await e.updateStatistics(this._connection)}forEachAggregateWorldSpace(t){if(null==this._requiredLevel||null==this._requiredScale)return;const e=this._getClusterState(this._requiredLevel,this._requiredScale);for(const s of e.aggregatesWorldSpace())t(s)}_getClusterState(t,e){if(null==t||null==e)throw new Error("InternalError: Level and scale must be defined");let s=this._cellsPerScale.get(e);return s||(s=new hu(t,e,this._indexOptions,this._clusterRadius,this._attributeStore),this._cellsPerScale.set(e,s)),s}async*_update(t,e,s){if(t.done)return;const i=e.createAggregateFeatures(t,this._metadata);this.events.emit("changed"),t.done=!s.updateTracking.updating;const r=i.getCursor(),n=t.subscription.tile.createArcadeEvaluationOptions(this._indexOptions.timeZone);for(;r.next();)this._attributeStore.setAttributeData(r.getDisplayId(),r,n);const o=new Hc(t.subscription,i,!0,t.done,{});yield o}}var lu=s(85304);function uu(t,e){if(!(this instanceof uu))return new uu(t,e);this._maxEntries=Math.max(4,t||9),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),e&&("function"==typeof e?this.toBBox=e:this._initFormat(e)),this.clear()}function du(t,e,s){if(!s)return e.indexOf(t);for(var i=0;i<e.length;i++)if(s(t,e[i]))return i;return-1}function pu(t,e){_u(t,0,t.children.length,e,t)}function _u(t,e,s,i,r){r||(r=Iu(null)),r.minX=1/0,r.minY=1/0,r.maxX=-1/0,r.maxY=-1/0;for(var n,o=e;o<s;o++)n=t.children[o],fu(r,t.leaf?i(n):n);return r}function fu(t,e){return t.minX=Math.min(t.minX,e.minX),t.minY=Math.min(t.minY,e.minY),t.maxX=Math.max(t.maxX,e.maxX),t.maxY=Math.max(t.maxY,e.maxY),t}function mu(t,e){return t.minX-e.minX}function gu(t,e){return t.minY-e.minY}function yu(t){return(t.maxX-t.minX)*(t.maxY-t.minY)}function xu(t){return t.maxX-t.minX+(t.maxY-t.minY)}function bu(t,e){return(Math.max(e.maxX,t.maxX)-Math.min(e.minX,t.minX))*(Math.max(e.maxY,t.maxY)-Math.min(e.minY,t.minY))}function wu(t,e){var s=Math.max(t.minX,e.minX),i=Math.max(t.minY,e.minY),r=Math.min(t.maxX,e.maxX),n=Math.min(t.maxY,e.maxY);return Math.max(0,r-s)*Math.max(0,n-i)}function vu(t,e){return t.minX<=e.minX&&t.minY<=e.minY&&e.maxX<=t.maxX&&e.maxY<=t.maxY}function Su(t,e){return e.minX<=t.maxX&&e.minY<=t.maxY&&e.maxX>=t.minX&&e.maxY>=t.minY}function Iu(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Tu(t,e,s,i,r){for(var n,o=[e,s];o.length;)(s=o.pop())-(e=o.pop())<=i||(n=e+Math.ceil((s-e)/i/2)*i,(0,lu.q)(t,n,e,s,r),o.push(e,n,n,s))}uu.prototype={all:function(){return this._all(this.data,[])},search:function(t){var e=this.data,s=[],i=this.toBBox;if(!Su(t,e))return s;for(var r,n,o,a,h=[];e;){for(r=0,n=e.children.length;r<n;r++)o=e.children[r],Su(t,a=e.leaf?i(o):o)&&(e.leaf?s.push(o):vu(t,a)?this._all(o,s):h.push(o));e=h.pop()}return s},collides:function(t){var e=this.data,s=this.toBBox;if(!Su(t,e))return!1;for(var i,r,n,o,a=[];e;){for(i=0,r=e.children.length;i<r;i++)if(n=e.children[i],Su(t,o=e.leaf?s(n):n)){if(e.leaf||vu(t,o))return!0;a.push(n)}e=a.pop()}return!1},load:function(t){if(!t||!t.length)return this;if(t.length<this._minEntries){for(var e=0,s=t.length;e<s;e++)this.insert(t[e]);return this}var i=this._build(t.slice(),0,t.length-1,0);if(this.data.children.length)if(this.data.height===i.height)this._splitRoot(this.data,i);else{if(this.data.height<i.height){var r=this.data;this.data=i,i=r}this._insert(i,this.data.height-i.height-1,!0)}else this.data=i;return this},insert:function(t){return null!=t&&this._insert(t,this.data.height-1),this},clear:function(){return this.data=Iu([]),this},remove:function(t,e){if(null==t)return this;for(var s,i,r,n,o=this.data,a=this.toBBox(t),h=[],c=[];o||h.length;){if(o||(o=h.pop(),i=h[h.length-1],s=c.pop(),n=!0),o.leaf&&-1!==(r=du(t,o.children,e)))return o.children.splice(r,1),h.push(o),this._condense(h),this;n||o.leaf||!vu(o,a)?i?(s++,o=i.children[s],n=!1):o=null:(h.push(o),c.push(s),s=0,i=o,o=o.children[0])}return this},toBBox:function(t){return t},compareMinX:mu,compareMinY:gu,toJSON:function(){return this.data},fromJSON:function(t){return this.data=t,this},_all:function(t,e){for(var s=[];t;)t.leaf?e.push.apply(e,t.children):s.push.apply(s,t.children),t=s.pop();return e},_build:function(t,e,s,i){var r,n=s-e+1,o=this._maxEntries;if(n<=o)return pu(r=Iu(t.slice(e,s+1)),this.toBBox),r;i||(i=Math.ceil(Math.log(n)/Math.log(o)),o=Math.ceil(n/Math.pow(o,i-1))),(r=Iu([])).leaf=!1,r.height=i;var a,h,c,l,u=Math.ceil(n/o),d=u*Math.ceil(Math.sqrt(o));for(Tu(t,e,s,d,this.compareMinX),a=e;a<=s;a+=d)for(Tu(t,a,c=Math.min(a+d-1,s),u,this.compareMinY),h=a;h<=c;h+=u)l=Math.min(h+u-1,c),r.children.push(this._build(t,h,l,i-1));return pu(r,this.toBBox),r},_chooseSubtree:function(t,e,s,i){for(var r,n,o,a,h,c,l,u;i.push(e),!e.leaf&&i.length-1!==s;){for(l=u=1/0,r=0,n=e.children.length;r<n;r++)h=yu(o=e.children[r]),(c=bu(t,o)-h)<u?(u=c,l=h<l?h:l,a=o):c===u&&h<l&&(l=h,a=o);e=a||e.children[0]}return e},_insert:function(t,e,s){var i=this.toBBox,r=s?t:i(t),n=[],o=this._chooseSubtree(r,this.data,e,n);for(o.children.push(t),fu(o,r);e>=0&&n[e].children.length>this._maxEntries;)this._split(n,e),e--;this._adjustParentBBoxes(r,n,e)},_split:function(t,e){var s=t[e],i=s.children.length,r=this._minEntries;this._chooseSplitAxis(s,r,i);var n=this._chooseSplitIndex(s,r,i),o=Iu(s.children.splice(n,s.children.length-n));o.height=s.height,o.leaf=s.leaf,pu(s,this.toBBox),pu(o,this.toBBox),e?t[e-1].children.push(o):this._splitRoot(s,o)},_splitRoot:function(t,e){this.data=Iu([t,e]),this.data.height=t.height+1,this.data.leaf=!1,pu(this.data,this.toBBox)},_chooseSplitIndex:function(t,e,s){var i,r,n,o,a,h,c,l;for(h=c=1/0,i=e;i<=s-e;i++)o=wu(r=_u(t,0,i,this.toBBox),n=_u(t,i,s,this.toBBox)),a=yu(r)+yu(n),o<h?(h=o,l=i,c=a<c?a:c):o===h&&a<c&&(c=a,l=i);return l},_chooseSplitAxis:function(t,e,s){var i=t.leaf?this.compareMinX:mu,r=t.leaf?this.compareMinY:gu;this._allDistMargin(t,e,s,i)<this._allDistMargin(t,e,s,r)&&t.children.sort(i)},_allDistMargin:function(t,e,s,i){t.children.sort(i);var r,n,o=this.toBBox,a=_u(t,0,e,o),h=_u(t,s-e,s,o),c=xu(a)+xu(h);for(r=e;r<s-e;r++)n=t.children[r],fu(a,t.leaf?o(n):n),c+=xu(a);for(r=s-e-1;r>=e;r--)n=t.children[r],fu(h,t.leaf?o(n):n),c+=xu(h);return c},_adjustParentBBoxes:function(t,e,s){for(var i=s;i>=0;i--)fu(e[i],t)},_condense:function(t){for(var e,s=t.length-1;s>=0;s--)0===t[s].children.length?s>0?(e=t[s-1].children).splice(e.indexOf(t[s]),1):this.clear():pu(t[s],this.toBBox)},_initFormat:function(t){var e=["return a"," - b",";"];this.compareMinX=new Function("a","b",e.join(t[0])),this.compareMinY=new Function("a","b",e.join(t[1])),this.toBBox=new Function("a","return {minX: a"+t[0]+", minY: a"+t[1]+", maxX: a"+t[2]+", maxY: a"+t[3]+"};")}};class Pu{static fromReader(t){const e=[],s=t.copy(),i=(0,Vc.Su)();for(;s.next();)s.getBounds(i)&&e.push(s.getIndex());const r=uu(9,(t=>(s.setIndex(t),{minX:s.getBoundsXMin(),minY:s.getBoundsYMin(),maxX:s.getBoundsXMax(),maxY:s.getBoundsYMax()})));return r.load(e),new Pu(r)}constructor(t){this._index=t}search(t){const e={minX:t[0],minY:t[1],maxX:t[2],maxY:t[3]};return this._index.search(e)}}class Mu{static create(t,e,s,i){const r=Hl.create(t),n=new Array(32);for(let t=0;t<n.length;t++)n[t]=null;return new Mu(r,e,s,i,n)}constructor(t,e,s,i,r){this._statistics=t,this.xNode=e,this.yNode=s,this.depth=i,this.children=r,this._objectIds=new Set,this._count=0,this._xWorldTotal=0,this._yWorldTotal=0,this._xGeohashTotal=0,this._yGeohashTotal=0,this.next=null}get id(){return`${this.xNode}.${this.yNode}`}get objectIds(){return this._objectIds}clone(){const t=new Mu(this._statistics.clone(),this.xNode,this.yNode,this.depth,this.children);return t._count=this._count,t._xWorldTotal=this._xWorldTotal,t._yWorldTotal=this._yWorldTotal,t._xGeohashTotal=this._xGeohashTotal,t._yGeohashTotal=this._yGeohashTotal,t.next=this.next,t.cachedFeature=this.cachedFeature,t._objectIds=new Set(this._objectIds),t}insert(t,e,s,i,r,n){this._count+=1,this._xWorldTotal+=e,this._yWorldTotal+=s,this._xGeohashTotal+=i,this._yGeohashTotal+=r,this._statistics.insert(t,n),this._objectIds.add(t.getObjectId())}merge(t){if(0!==t._count){this._count+=t._count,this._xWorldTotal+=t._xWorldTotal,this._yWorldTotal+=t._yWorldTotal,this._xGeohashTotal+=t._xWorldTotal,this._yGeohashTotal+=t._yWorldTotal,this._statistics.merge(t._statistics);for(const e of t._objectIds.values())this._objectIds.add(e)}}getGeometry(t,e){const s=this._getLngLatBounds(),[i,r,n,o]=s,a=(0,Bc.yU)({rings:[[[i,r],[i,o],[n,o],[n,r],[i,r]]]},V.c.WGS84,t),h=(0,zc.Uh)(new ft.c,a,!1,!1);return null!=e?(0,zc.iC)(new ft.c,h,!1,!1,"esriGeometryPolygon",e,!1,!1):h}getGeometryCentroid(t,e){const s=this._getLngLatBounds(),[i,r,n,o]=s,a=(0,Bc.yU)({x:(i+n)/2,y:(r+o)/2},V.c.WGS84,t),h=(0,zc.M$)(new ft.c,a);return null!=e?(0,zc.iC)(new ft.c,h,!1,!1,"esriGeometryPoint",e,!1,!1):h}getAttributes(){const t={aggregateId:this.id};for(const e of this._statistics.values())t[e.field.name]=e.value;return t.aggregateCount=this._count,t}_getLngLatBounds(){const t=this.depth,e=Math.ceil(t/2),s=Math.floor(t/2),i=30-(3*e+2*s),r=30-(2*e+3*s),n=this.xNode<<i,o=this.yNode<<r;return(0,Dc.S8)({geohashX:n,geohashY:o},this.depth)}}class Eu{constructor(t){this._fields=t,this._root=Mu.create(this._fields,0,0,0)}destroy(){}insert(t,e,s,i,r,n,o){let a=this._root,h=0,c=0,l=0;for(;null!==a;){if(a.insert(t,e,s,i,r,o),h>=n)return;const u=Math.ceil((h+1)/2),d=Math.floor((h+1)/2),p=1-h%2,_=30-(3*u+2*d),f=30-(2*u+3*d),m=(i&7*p+3*(1-p)<<_)>>_,g=(r&3*p+7*(1-p)<<f)>>f,y=m+g*(8*p+4*(1-p));c=c<<3*p+2*(1-p)|m,l=l<<2*p+3*(1-p)|g,null==a.children[y]&&(a.children[y]=Mu.create(this._fields,c,l,h+1)),h+=1,a=a.children[y]}}putBins(t,e){for(const s of this.getNodes(e)){const e=t.get(s.id);e?e.merge(s):t.set(s.id,s.clone())}}getNodes(t){const e=[],{geohashBounds:s,level:i}=t;let r=this._root;for(;null!==r;){const t=r.depth,n=r.xNode,o=r.yNode;if(t>=i){e.push(r),r=r.next;continue}const a=Math.ceil((t+1)/2),h=Math.floor((t+1)/2),c=1-t%2,l=30-(3*a+2*h),u=30-(2*a+3*h),d=~((1<<l)-1),p=~((1<<u)-1),_=(s.xLL&d)>>l,f=(s.yLL&p)>>u,m=(s.xTR&d)>>l,g=(s.yTR&p)>>u,y=n<<3*c+2*(1-c),x=o<<2*c+3*(1-c),b=y+8*c+4*(1-c),w=x+4*c+8*(1-c),v=Math.max(y,_),S=Math.max(x,f),I=Math.min(b,m),T=Math.min(w,g);let P=null,M=null;for(let t=S;t<=T;t++)for(let e=v;e<=I;e++){const s=e-y+(t-x)*(8*c+4*(1-c)),i=r.children[s];i&&(P||(P=i,P.next=r.next),M&&(M.next=i),M=i,i.next=r.next)}r=P||r.next}return e}}class Cu{constructor(t){this._options=t,this._tree=new Eu(t.fields)}insert(t,e){const s=t.getCursor(),i={$view:{scale:0,timeZone:this._options.timeZone}};for(;s.next();)this._insertFeature(s,i,e)}putBins(t,e){this._tree.putBins(t,e)}_insertFeature(t,e,s){const{featureFilter:i,geohashLevel:r,spatialReference:n}=this._options;if(null!==i&&!i.check(t))return;let o=0,a=0;if("esriGeometryPoint"===t.geometryType)o=t.readXWorldSpace(),a=t.readYWorldSpace();else{if(s){const e=t.readCentroidForDisplay();if(null==e)return;const[s,i]=e.coords;if(s<0||s>B.gT||i<0||i>B.gT)return}const e=t.readCentroidWorldSpace();if(null==e)return;o=e.coords[0],a=e.coords[1]}const h=(0,Dc.i2)(o,a,r,n);h&&this._tree.insert(t,o,a,h[0],h[1],r,e)}}class ku extends ql{static from(t,e){return new ku(t.copy(),e)}constructor(t,e){super(t.metadata),this._currentIndex=-1,this._displayTranslationX=0,this._displayTranslationY=0,this._displayScaleX=1,this._displayScaleY=1,this._reader=t,this._indices=e,this._isPoint="esriGeometryPoint"===t.geometryType}setTransformForDisplay(t){const e=this._reader.getInTransform();if(null==e){const[e,s]=t.scale,[i,r]=t.translate;return this._displayTranslationX=-i/e,this._displayScaleX=1/e,this._displayTranslationY=r/s,this._displayScaleY=1/-s,void(this._displayTransform=t)}const[s,i]=e.scale,[r,n]=e.translate,[o,a]=t.scale,[h,c]=t.translate;if(this._displayScaleX=s/o,this._displayTranslationX=(r-h)/o,this._displayScaleY=i/a,this._displayTranslationY=(-n+c)/a,!this._isPoint&&e)throw new Error("InternalError: Relative transformations not supported for non-point features");this._displayTransform=t}getInTransform(){return this._reader.getInTransform()}get fields(){return this._reader.fields}get hasNext(){return this._currentIndex+1<this._indices.length}getSize(){return this._indices.length}getCursor(){return this.copy()}copy(){const t=new ku(this._reader.copy(),this._indices);return t._currentIndex=this._currentIndex,t._displayTransform=this._displayTransform,t._displayTranslationX=this._displayTranslationX,t._displayTranslationY=this._displayTranslationY,t._displayScaleX=this._displayScaleX,t._displayScaleY=this._displayScaleY,t}_nextIndex(){return++this._currentIndex<this._indices.length&&(this._reader.setIndex(this._indices[this._currentIndex]),!0)}next(){for(;this._nextIndex()&&!this._reader._getExists(););return this._currentIndex<this._indices.length}readXForDisplay(){return this._reader.readXForDisplay()*this._displayScaleX+this._displayTranslationX}readYForDisplay(){return this._reader.readYForDisplay()*this._displayScaleY+this._displayTranslationY}readGeometryForDisplay(){const t=this._reader.readGeometryForDisplay();if(!this._displayTransform)return t;const e=new ft.c;return(0,zc.iC)(e,t,this.hasZ,this.hasM,this.geometryType,this._displayTransform),e.deltaDecode()}readCentroidForDisplay(){const t=this._reader.readCentroidForDisplay()?.clone();if(t){const[e,s]=t.coords;t.coords[0]=e*this._displayScaleX+this._displayTranslationX,t.coords[1]=s*this._displayScaleY+this._displayTranslationY}return t}get geometryType(){return this._reader.geometryType}get hasFeatures(){return this._reader.hasFeatures}get exceededTransferLimit(){return this._reader.exceededTransferLimit}get hasZ(){return this._reader.hasZ}get hasM(){return this._reader.hasM}readAttribute(t,e=!1){return this._reader.readAttribute(t,e)}readAttributes(){return this._reader.readAttributes()}joinAttributes(t){return this._reader.joinAttributes(t)}getBounds(t){return this._reader.getBounds(t)}getAttributeHash(){return this._reader.getAttributeHash()}getObjectId(){return this._reader.getObjectId()}getDisplayId(){return this._reader.getDisplayId()}setDisplayId(t){return this._reader.setDisplayId(t)}setIndex(t){return this._reader.setIndex(t)}getIndex(){return this._reader.getIndex()}readXWorldSpace(){return this._reader.readXWorldSpace()}readYWorldSpace(){return this._reader.readYWorldSpace()}_readX(){return this._reader.readXForDisplay()}_readY(){return this._reader.readYForDisplay()}_readServerCentroid(){return this._reader._readServerCentroid()}readLegacyFeatureForDisplay(){return this._reader.readLegacyFeatureForDisplay()}readLegacyGeometryForDisplay(){return this._reader.readLegacyGeometryForDisplay()}readGeometryArea(){return this._reader.readGeometryArea()}readGeometryWorldSpace(){return this._reader.readGeometryWorldSpace()}_readGeometry(){return this._reader._readGeometry()}_readAttribute(t,e){throw new Error("Error: Should not be called. Underlying _reader should be used instead")}_readAttributes(){throw new Error("Error: Should not be called. Underlying _reader should be used instead")}readArcadeFeature(){return this._reader.readArcadeFeature()}geometry(){return this._reader.geometry()}field(t){return this.readAttribute(t,!0)}hasField(t){return this._reader.hasField(t)}setField(t,e){return this._reader.setField(t,e)}keys(){return this._reader.keys()}castToText(t=!1){return this._reader.castToText(t)}}class Fu{size(){return this.reader.getSize()}get fields(){return this.reader.fields}invalidate(){this._geohashIndex=null,this._geohashIndexHash=null,this._spatialIndex=null,this._gridIndex=null,this._gridIndexHash=null}queryFeaturesInBounds(t){const e=this._getSpatialIndex().search(t);return ku.from(this.reader,e)}getGeohashIndex(t){const e=JSON.stringify(t);return e!==this._geohashIndexHash&&(this._geohashIndexHash=e,this._geohashIndex=new Cu(t),this._geohashIndex.insert(this.reader,this.isTiled)),this._geohashIndex}getGridIndex(t){const e=JSON.stringify(t);return e!==this._gridIndexHash&&(this._gridIndexHash=e,this._gridIndex=new nu(t),this._gridIndex.insert(this.reader,this.isTiled)),this._gridIndex}_getSpatialIndex(){return this._spatialIndex||(this._spatialIndex=Pu.fromReader(this.reader)),this._spatialIndex}}class Au extends Fu{constructor(){super(...arguments),this.chunkId="override",this.normalizedChunkId="override",this.removed=new Set,this.overridenIds=new Set,this._features=[]}get reader(){return Wl.fromOptimizedFeatures(this._features,this._layerSchema??{fields:[]})}get queryInfo(){return{}}get first(){return!1}get end(){return!1}get isTiled(){return!1}applyOverrides(t){super.invalidate(),this._layerSchema||(this._layerSchema=t.reader.fullSchema());const{reader:e,removed:s}=t,i=[],r=new Set,n=e.getCursor(),o=new Set(s);for(this.overridenIds.clear();n.next();){const t=n.readOptimizedFeatureWorldSpace(),e=t.objectId;i.push(t),r.add(e),this.overridenIds.add(e),this.removed.delete(e)}for(const t of this._features){const e=t.objectId;o.has(e)||r.has(e)||(i.push(t),this.overridenIds.add(e))}this._features=i;for(const t of r.values())this.removed.delete(t);for(const t of s)this.removed.add(t),this.overridenIds.add(t)}getTileReader(t){if(!this._features.length)return null;const e=this.queryFeaturesInBounds(t.bounds);return e.setTransformForDisplay(t.transform),e}}class Ru extends Xc{}class Ou extends Yc{constructor(t,e,s){super(t,e),this._timeZone=s,this.handledChunks=new Set,this.handledChunksForIdCreation=new Set,this.handledChunksForAttributeData=new Set,this._streamLayerDeferredObjectIdsToRemove=[]}destroy(){super.destroy();for(const t of this._source.chunks())this._cleanupChunkIds(t)}invalidateAttributeData(){this.handledChunksForAttributeData.clear()}onSubscribe(t){super.onSubscribe(t),this._evalOptions=t.tile.createArcadeEvaluationOptions(this._timeZone)}createState(t){return new Ru(t)}get aggregateQueryEngine(){return null}displayMap(t,e,s){const i=new Map(t.map((t=>[e(t),t]))),r=[];for(const t of this._source.chunks()){const e=t.reader.getCursor();for(;e.next();){const t=e.getObjectId(),n=e.getDisplayId(),o=i.get(t);if(null!=o){const e=s(n,o,t);r.push(e),i.delete(t)}}}return r}getDisplayFeatures(t){const e=new Set(t),s=new Set,i=[];for(const t of this._source.chunks()){const r=t.reader.getCursor();for(;r.next();){const t=r.getObjectId(),n=r.getDisplayId();e.has(n)&&!s.has(t)&&(i.push({...r.readLegacyFeatureWorldSpace(),displayId:n}),s.add(t))}}return{features:i,aggregates:[]}}async*applyOverride(t){const e=[],s=t.reader.getCursor();for(;s.next();){const t=s.getObjectId();e.push(t);const i=this._attributeStore.createDisplayIdForObjectId(t);s.setDisplayId(i),this._attributeStore.setAttributeData(i,s,this._evalOptions)}const i=this.getDisplayIds(e),r=this.getDisplayIds(t.removed),n=new Au;n.applyOverrides(t);for(const t of this._sendStates.values())yield new $c(t.subscription,null,i,!1,n.queryInfo);for(const t of this._sendStates.values()){const e=n.getTileReader(t.subscription.tile);yield new $c(t.subscription,e,r,!1,n.queryInfo)}for(const e of t.removed)this._attributeStore.releaseDisplayIdForObjectId(e)}async*updateChunks(){if(this._source.chunks().length){await this._updateAttributeData();for(const t of this._sendStates.values())yield*this._update(t)}}removeChunks(t){for(const e of t)this.handledChunks.delete(e.chunkId),this.handledChunksForAttributeData.delete(e.chunkId),this._cleanupChunkIds(e)}afterUpdateChunks(){for(const t of this._streamLayerDeferredObjectIdsToRemove)this._attributeStore.releaseDisplayIdForObjectId(t);this._streamLayerDeferredObjectIdsToRemove=[]}_cleanupChunkIds(t){if(this.handledChunksForIdCreation.has(t.chunkId)){const e=t.reader.getCursor();for(;e.next();){const t=e.getObjectId();this._source.isStream?this._streamLayerDeferredObjectIdsToRemove.push(t):this._attributeStore.releaseDisplayIdForObjectId(t)}this.handledChunksForIdCreation.delete(t.chunkId)}}async _updateAttributeData(){for(const t of this._source.chunks()){const{chunkId:e,reader:s}=t;if(!this.handledChunksForIdCreation.has(e)){this.handledChunksForIdCreation.add(e);const t=s.getCursor();for(;t.next();){const e=this._attributeStore.createDisplayIdForObjectId(t.getObjectId());t.setDisplayId(e)}}}for(const t of this._source.chunks())if(!this.handledChunksForAttributeData.has(t.chunkId)){this.handledChunksForAttributeData.add(t.chunkId);const e=t.reader.getCursor();for(;e.next();){const t=e.getDisplayId();this._attributeStore.setAttributeData(t,e,this._evalOptions)}}}*_update(t){const{subscription:e,handledChunks:s}=t;for(const i of this._source.chunks()){const{chunkId:r}=i;if(s.has(r))continue;s.add(r);const n=i.getTileReader(e.tile);n&&(yield new Hc(t.subscription,n,!1,i.end,i.queryInfo))}}}class Nu{constructor(t){this.data=t,this._referenceCount=0}increment(){this._referenceCount+=1}decrement(){this._referenceCount-=1}empty(){return 0===this._referenceCount}}class Du{constructor(){this._freeIdsGenerationA=[],this._freeIdsGenerationB=[],this._idCounter=1,this._freeIds=this._freeIdsGenerationA,this._objectIdToDisplayId=new Map}createIdForObjectId(t){let e=this._objectIdToDisplayId.get(t);return e?e.increment():(e=new Nu((0|this._getFreeId())>>>0),e.increment(),this._objectIdToDisplayId.set(t,e)),e.data}releaseIdForObjectId(t){const e=this._objectIdToDisplayId.get(t);e&&(e.decrement(),e.empty()&&(this._objectIdToDisplayId.delete(t),this._freeIds.push(e.data)))}releaseAll(){for(const t of this._objectIdToDisplayId.values())this._freeIds.push(t.data);this._objectIdToDisplayId.clear()}incrementGeneration(){this._freeIds=this._freeIds===this._freeIdsGenerationA?this._freeIdsGenerationB:this._freeIdsGenerationA}_getFreeId(){return this._freeIds.length?this._freeIds.pop():this._idCounter++}}const zu=()=>C.c.getLogger("geoscene.views.layers.2d.features.support.AttributeStore"),Lu=(zu(),()=>null),Bu=(0,n.c)("geoscene-shared-array-buffer");(0,n.c)("geoscene-atomics");class Uu{constructor(t,e,s){this.size=0,this.texelSize=4,this.dirtyStart=0,this.dirtyEnd=0;const{pixelType:i,layout:r,textureOnly:n}=e;this.textureOnly=n||!1,this.pixelType=i,this.layout=r,this._resetRange(),this.size=t,this.isLocal=s,n||(this.data=this._initData(i,t))}get buffer(){return this.data?.buffer}unsetComponentAllTexels(t,e){const s=this.data;for(let i=0;i<this.size*this.size;i++)s[i*this.texelSize+t]&=~e;this.dirtyStart=0,this.dirtyEnd=this.size*this.size-1}setComponentAllTexels(t,e){const s=this.data;for(let i=0;i<this.size*this.size;i++)s[i*this.texelSize+t]|=255&e;this.dirtyStart=0,this.dirtyEnd=this.size*this.size-1}setComponent(t,e,s){const i=this.data;for(const r of s)i[r*this.texelSize+t]|=e,this.dirtyStart=Math.min(this.dirtyStart,r),this.dirtyEnd=Math.max(this.dirtyEnd,r)}setComponentTexel(t,e,s){this.data[s*this.texelSize+t]|=e,this.dirtyStart=Math.min(this.dirtyStart,s),this.dirtyEnd=Math.max(this.dirtyEnd,s)}unsetComponentTexel(t,e,s){this.data[s*this.texelSize+t]&=~e,this.dirtyStart=Math.min(this.dirtyStart,s),this.dirtyEnd=Math.max(this.dirtyEnd,s)}getData(t,e){const s=Nh(t);return this.data[s*this.texelSize+e]}setData(t,e,s){const i=Nh(t),r=1<<e;0!=(this.layout&r)?null!=this.data&&(this.data[i*this.texelSize+e]=s,this.dirtyStart=Math.min(this.dirtyStart,i),this.dirtyEnd=Math.max(this.dirtyEnd,i)):zu().error("mapview-attributes-store","Tried to set a value for a texel's readonly component")}expand(t){if(this.size=t,!this.textureOnly){const e=this._initData(this.pixelType,t),s=this.data;e.set(s),this.data=e}}toMessage(){const t=this.dirtyStart,e=this.dirtyEnd,s=this.texelSize;if(t>e)return null;this._resetRange();const i=!this.isLocal,r=this.pixelType,n=this.layout,o=this.data;return{start:t,end:e,data:i&&o.slice(t*s,(e+1)*s)||null,pixelType:r,layout:n}}_initData(t,e){const s=ArrayBuffer,r=function(t){switch(t){case pi.OK.UNSIGNED_BYTE:return Uint8Array;case pi.OK.UNSIGNED_SHORT_4_4_4_4:return Uint16Array;case pi.OK.FLOAT:return Float32Array;default:return void C.c.getLogger("geoscene.views.2d.engine.webgl.Utils").error(new i.c("webgl-utils",`Unable to handle type ${t}`))}}(t),n=new r(new s(e*e*4*r.BYTES_PER_ELEMENT));for(let t=0;t<n.length;t+=4)n[t+1]=255;return n}_resetRange(){this.dirtyStart=2147483647,this.dirtyEnd=0}}class Gu{constructor(t){this._client=t,this._filters=[],this._blocks=new Array,this._attributeComputeInfo=null,this._abortController=new AbortController,this._size=B.OO,this._idsToHighlight=new Map,this._referencesScale=!1,this._referencesGeometry=!1,this._initialized=!1,this.version=0,this._idGenerator=new Du,this._epoch=1}destroy(){this._abortController.abort()}_initialize(){if(null!=this._blockDescriptors)return;const t=pi.OK.FLOAT;Lu(`Creating AttributeStore ${Bu?"with":"without"} shared memory`),this._blockDescriptors=[{pixelType:pi.OK.UNSIGNED_BYTE,layout:1},{pixelType:pi.OK.UNSIGNED_BYTE,layout:15,textureOnly:!0},{pixelType:pi.OK.UNSIGNED_BYTE,layout:15,textureOnly:!0},{pixelType:t,layout:15},{pixelType:t,layout:15},{pixelType:t,layout:15},{pixelType:t,layout:15}],this._blocks=this._blockDescriptors.map((()=>null))}get referencesScale(){return this._referencesScale}get referencesGeometry(){return this._referencesGeometry}get _signal(){return this._abortController.signal}get hasHighlight(){return this._idsToHighlight.size>0}createDisplayIdForObjectId(t){return this._idGenerator.createIdForObjectId(t)}releaseDisplayIdForObjectId(t){return this._idGenerator.releaseIdForObjectId(t)}incrementDisplayIdGeneration(){this._idGenerator.incrementGeneration()}releaseAllIds(){this._idGenerator.releaseAll()}async update(t,e,s,i,r=0){const o=(0,G.qq)(this._schema,t);if(this.version=r,o&&((0,n.c)("geoscene-2d-update-debug")&&console.debug(`Version[${r}] AttributeStore.update`,{changed:o}),this._schema=t,this._attributeComputeInfo=null,this._initialize(),null!=t))if(s&&(this._filters=await Promise.all(t.filters.map((t=>t?Sl.create({geometryType:s.geometryType,hasM:!1,hasZ:!1,timeInfo:s.timeInfo,fieldsIndex:s.fieldsIndex,spatialReference:i??s.spatialReference,filterJSON:t}):null)))),"subtype"!==t.type)this._attributeComputeInfo={isSubtype:!1,map:new Map},await Promise.all(t.bindings.map((async t=>{const s=await this._bind(e,t);this._referencesGeometry=this._referencesGeometry||(s?.referencesGeometry()??!1),this._referencesScale=this._referencesScale||(s?.referencesScale()??!1)})));else{this._attributeComputeInfo={isSubtype:!0,subtypeField:t.subtypeField,map:new Map},this._referencesScale=!1,this._referencesGeometry=!1;for(const s in t.bindings){const i=t.bindings[s];await Promise.all(i.map((async t=>{const i=await this._bind(e,t,parseInt(s,10));this._referencesGeometry=this._referencesGeometry||(i?.referencesGeometry()??!1),this._referencesScale=this._referencesScale||(i?.referencesScale()??!1)})))}}}setHighlight(t,e){const s=this._getBlock(0);s.unsetComponentAllTexels(0,(1<<wa.length)-1);for(const{displayId:e,highlightFlags:i}of t){if(null==e)continue;const t=Nh(e);s.setComponent(0,i,[t])}this._idsToHighlight.clear();for(const{objectId:e,highlightFlags:s}of t)this._idsToHighlight.set(e,s);for(const{objectId:t,highlightFlags:s}of e)this._idsToHighlight.set(t,s)}setData(t,e,s,i){const r=Nh(t);this._ensureSizeForTexel(r),this._getBlock(e).setData(t,s,i)}getData(t,e,s){return this._getBlock(e).getData(t,s)}getHighlightFlags(t){return this._idsToHighlight.get(t)||0}unsetAttributeData(t){const e=Nh(t);this._getBlock(0).setData(e,0,0)}setAttributeData(t,e,s){const i=Nh(t);this._ensureSizeForTexel(i),this._getBlock(0).setData(i,0,this.getFilterFlags(e));const r=this._attributeComputeInfo;let n=null;r&&(n=r.isSubtype?r.map.get(e.readAttribute(r.subtypeField)):r.map,n?.size&&n.forEach(((t,r)=>{const n=1*r%4,o=Math.floor(1*r/4),a=this._getBlock(o+B.Kc.VV);let h=t.field?.read(e,s);t.valueRepresentation&&(h=function(t,e){if(!t||!e)return t;switch(e){case"radius":case"distance":return 2*t;case"diameter":case"width":return t;case"area":return Math.sqrt(t)}return t}(h,t.valueRepresentation)),(null===h||isNaN(h)||h===1/0||h===-1/0)&&(h=Bi),a.setData(i,n,h)})))}get epoch(){return this._epoch}async sendUpdates(){const t=this._blocks.map((t=>null!=t?t.toMessage():null)),e=this._getInitArgs();(0,n.c)("geoscene-2d-log-updating")&&console.log("AttributeStore: _doSendUpdate.start"),await this._client.update({initArgs:e,blockData:t,version:this.version,sendUpdateEpoch:this._epoch},this._signal),this._epoch+=1,(0,n.c)("geoscene-2d-log-updating")&&console.log("AttributeStore: _doSendUpdate.end")}_ensureSizeForTexel(t){for(;t>=this._size*this._size;)if(this._expand())return}async _bind(t,e,s){const i=await t.createComputedField(e),{valueRepresentation:r}=e,n=this._attributeComputeInfo;if(n.isSubtype){const t=n.map.get(s)??new Map;t.set(e.binding,{field:i,valueRepresentation:r}),n.map.set(s,t)}else n.map.set(e.binding,{field:i,valueRepresentation:r});return i}_getInitArgs(){return this._initialized?null:(this._initialized=!0,this._getBlock(B.Kc.Animation),this._getBlock(B.Kc.GPGPU),{blockSize:this._size,blockDescriptors:this._blocks.map((t=>null!=t?{textureOnly:t.textureOnly,buffer:t.buffer,pixelType:t.pixelType}:null))})}_getBlock(t){const e=this._blocks[t];if(null!=e)return e;Lu(`Initializing AttributeBlock at index ${t}`);const s=new Uu(this._size,this._blockDescriptors[t],this._client.isLocal);return this._blocks[t]=s,this._initialized=!1,s}_expand(){if(this._size<this._schema.capabilities.maxTextureSize){const t=this._size<<=1;Lu("Expanding block size to",t,this._blocks);for(const e of this._blocks)e?.expand(t);return this._initialized=!1,this._size=t,0}return zu().error(new i.c("mapview-limitations","Maximum number of onscreen features exceeded.")),-1}isVisible(t){return!!(this._getBlock(0).getData(t,0)&1<<wa.length)}getFilterFlags(t){let e=0;for(let s=0;s<this._filters.length;s++){const i=!!(1<<s),r=this._filters[s];e|=(!i||null==r||r.check(t)?1:0)<<s}let s=0;if(this._idsToHighlight.size){const e=t.getObjectId();s=this.getHighlightFlags(e)}return e<<wa.length|s}}class Vu{constructor(t,e){this._connection=t,this._source=e,this._version=1,this._proxy=new Oc({fetch:(t,e)=>this._connection.layerView.fetch(t,e),fetchDictionary:(t,e)=>this._connection.layerView.fetchDictionary(t,e)}),this._attributeStore=new Gu({isLocal:!1,update:t=>(0,a.jO)(this._connection.container.updateAttributeView(t))})}destroy(){this._proxy.destory(),this._strategy?.destroy(),this._attributeStore.destroy()}get aggregateQueryEngine(){return this._strategy?.aggregateQueryEngine}getDisplayFeatures(t){return this._strategy?this._strategy.getDisplayFeatures(t):{features:[],aggregates:[]}}getFeatureObjectIdsForAggregate(t){return this._strategy?this._strategy.getFeatureObjectIdsForAggregate(t):[]}onSubscribe(t){this._strategy?.onSubscribe(t)}onUnsubscribe(t){this._strategy?.onUnsubscribe(t)}async update(t,e,s,i,r){const o=t.processor,a=(0,G.qq)(this._schema,o);if(!a&&!i)return;(0,n.c)("geoscene-2d-update-debug")&&console.debug(`Version[${this._version}] SymbolProcessor.update`,{changes:a,schema:o}),this._schema=o;const h=V.c.fromJSON(t.source.mutable.dataFilter.outSpatialReference),c=new gl({fields:this._source.metadata.fieldsIndex,spatialReference:h});return await this._attributeStore.update(o.storage,c,this._source.metadata,h,e),this._strategy?.invalidateAttributeData(),i||(0,G.Y5)(a,"mesh")?((0,G.Y5)(a,"mesh.strategy")&&await this._updateStrategy(o.mesh.strategy,h,r,o.mesh.timeZone),this._updateSortKey(c,"sortKey"in o.mesh?o.mesh.sortKey:null),((0,G.Y5)(a,"mesh.factory")||"dictionary"===o.mesh.factory.symbology.type)&&(this._factory=await Ac.create(c,this._proxy,o.mesh.factory,s)),this._invalidate(),this._version=e,this._connection.container.updateRenderState(this._version)):void 0}async applyOverride(t){if(!this._strategy)return;const e=this._strategy.applyOverride(t);for await(const t of e)try{await this._process(t)}catch(t){}this._source.applyOverride(t)}async updateChunks(){await this._doUpdateChunks(),this._strategy?.afterUpdateChunks()}async removeChunks(t){this._strategy?.removeChunks(t),this._attributeStore.incrementDisplayIdGeneration()}updateHighlight({highlights:t}){if(!this._strategy)return void this._attributeStore.setHighlight(t.map((({objectId:t,highlightFlags:e})=>({objectId:t,highlightFlags:e,displayId:-1}))),t);const e=this._strategy.displayMap(t,(({objectId:t})=>t),((t,{highlightFlags:e},s)=>({objectId:s,displayId:t,highlightFlags:e})));this._attributeStore.setHighlight(e,t)}async _doUpdateChunks(){if(!this._strategy)return;const t=this._strategy.updateChunks(),e=[],s=new Map;for await(const i of t){let t=s.get(i.id);null==t&&(t=new Nc({concurrency:16,process:t=>this._process(t)}),s.set(i.id,t));const r=t.push(i).catch((t=>(0,a.Az)(t)));e.push(r)}try{await Promise.all(e)}catch(t){}(0,n.c)("geoscene-2d-update-debug")&&console.log("SendUpdates"),await this._attributeStore.sendUpdates(),(0,n.c)("geoscene-2d-update-debug")&&console.log("SendUpdates.await")}async _updateStrategy(t,e,s,i){switch(this._strategy?.destroy(),t.type){case"feature":this._strategy=new Ou(this._source,this._attributeStore,i);break;case"binning":this._strategy=await Yl.create(t,e,this._source,this._attributeStore,i);break;case"cluster":this._strategy=await cu.create(this._connection,t,e,this._source,this._attributeStore,i)}for(const t of s)this._strategy.onSubscribe(t)}async _updateSortKey(t,e){if(this._sortInfo=(0,M.mG)(this._sortInfo?.computed),null!=e){const s=e.byRenderer?null:await t.createComputedField(e);this._sortInfo={...e,computed:s}}}_invalidate(){this._strategy&&this._strategy.invalidate()}async _process(t){const e=t.subscription;if((0,n.c)("geoscene-2d-update-debug")){const s=e.tile;console.debug(`Version[${this._version}] Tile[${s.key.id}, end=${t.end}] Processor._process`)}await this._fetchResources(t),(0,a.wp)(e.signal);const s=await this._write(t,e.tile.createArcadeEvaluationOptions(this._schema.mesh.timeZone)),i=e.tile.tileInfoView.tileInfo.isWrappable,{message:r,transferList:o}=s.serialize(i),h=t.createMessage(r,this._version,this._attributeStore.epoch);if((0,a.wp)(e.signal),this._connection.container.onMessage(h,{signal:e.signal,transferList:o}),this._attributeStore.sendUpdates(),(0,n.c)("geoscene-2d-update-debug")){const s=e.tile;console.debug(`Version[${this._version}] Tile[${s.key.id}, end=${t.end}] Processor._process.await`)}}async _fetchResources(t){await this._fetchMatcherResources(t),await this._fetchWriterResources(t)}async _fetchMatcherResources(t){if(t.reader)return this._factory.enqueueMatcherRequests(this._proxy,t.reader)}async _fetchWriterResources(t){if(!t.reader)return;const e=t.reader.getCursor(),s=t.subscription.tile.createArcadeEvaluationOptions(this._schema.mesh.timeZone);for(;e.next();)this._factory.enqueueWriterRequests(this._proxy,e,s);await this._proxy.fetchEnqueuedResources()}async _write(t,e){const s=t.subscription.tile,i=t.reader?.getCursor(),r=i?.getSize()??0,n=new Q(s.key.id,this._strategy.enablePixelBuffering,r);if(!i)return n;const o=s.createArcadeEvaluationOptions(this._schema.mesh.timeZone);for(;i.next();){const t=this._getSortKeyValue(i,e);n.entityStart(i.getDisplayId(),t),this._factory.write(n,this._proxy,i,o,s.level),n.entityEnd()}return n}_getSortKeyValue(t,e){if(!this._sortInfo)return 0;const{computed:s,order:i,byRenderer:r}=this._sortInfo,n=r?this._factory.getSortKey(t,e):s?.read(t,e);return null==n||isNaN(n)?0:n*("asc"===i?-1:1)}}var qu=s(2600),Wu=s(32848);class Xu{static from(t){let e=0,s=0,i=0;return t.forEach((t=>{const r=t._readGeometry();r&&(s+=r.isPoint?1:r.lengths.reduce(((t,e)=>t+e),0),i+=r.isPoint?1:r.lengths.length,e+=1)})),new Xu(e,s,i)}constructor(t,e,s){this.featureCount=t,this.vertexCount=e,this.ringCount=s}toJSON(){return{featureCount:this.featureCount,ringCount:this.featureCount,vertexCount:this.featureCount}}}var Yu=s(25228),ju=s(48212);class Hu{static fromSchema(t,e){return new Hu(function(t,e){const{service:s}=t,i=s.orderByFields??e.objectIdField+" ASC",r=s.source,n={returnCentroid:!(null!==r&&"object"==typeof r&&"path"in r&&(0,ju.Wq)(r.path))&&"esriGeometryPolygon"===e.geometryType,returnGeometry:!0,timeReferenceUnknownClient:e.timeReferenceUnknownClient??void 0,outSpatialReference:V.c.fromJSON(t.mutable.dataFilter.outSpatialReference),orderByFields:[i],where:t.mutable.dataFilter.definitionExpression??"1=1",outFields:t.mutable.availableFields};if("feature"===t.type){const{gdbVersion:e,historicMoment:s,timeExtent:i}=t.mutable.dataFilter;return{...n,gdbVersion:e,historicMoment:s?new Date(s):null,timeExtent:i?Yu.c.fromJSON(i):null,outFields:t.mutable.availableFields}}return n}(t,e),t.mutable.dataFilter.customParameters,e.geometryType,t.service.queryMetadata.capabilities)}constructor(t,e,s,i){this._queryParams=t,this._customParameters=e,this._geometryType=s,this._capabilities=i}get pageSize(){if(null==this._capabilities)throw new Error("InternalError: Service does not support paged queries");const{query:t}=this._capabilities,e=t.supportsMaxRecordCountFactor?4:null,s=(t.maxRecordCount??8e3)*(e??1);return Math.min(8e3,s)}updateFields(t){this._queryParams.outFields=t}createPatchFieldsQuery(t,e){const s=t.clone();if("*"===this._queryParams.outFields[0]){if("*"===(s.outFields??[])[0])return null;s.outFields=this._queryParams.outFields}else{const t=new Set(this._queryParams.outFields),i=[];for(const s of t)e.has(s)||i.push(s);if(0===i.length)return null;s.outFields=i}return s.returnGeometry=!1,s.returnCentroid=!1,s.quantizationParameters=null,s.cacheHint=!0,{inner:s,customParameters:this._customParameters}}createQuery(t={}){if(!this._queryParams)throw new Error("InternalError: queryInfo should be defined");return{inner:new wl.c({...this._queryParams,...t}),customParameters:this._customParameters}}createTileQuery(t,e){if(null==this._capabilities)throw new Error("InternalError: Service does not support tile queries");const s=this.createQuery(e),i=s.inner;return i.quantizationParameters=e.quantizationParameters??t.getQuantizationParameters(),i.resultType="tile",i.geometry=t.extent,this._capabilities.query.supportsQuantization?"esriGeometryPolyline"===this._geometryType&&(i.maxAllowableOffset=t.resolution*(0,n.c)("feature-polyline-generalization-factor")):"esriGeometryPolyline"!==this._geometryType&&"esriGeometryPolygon"!==this._geometryType||(i.maxAllowableOffset=t.resolution,"esriGeometryPolyline"===this._geometryType&&(i.maxAllowableOffset*=(0,n.c)("feature-polyline-generalization-factor"))),i.defaultSpatialReferenceEnabled=this._capabilities.query.supportsDefaultSpatialReference,i.compactGeometryEnabled=this._capabilities.query.supportsCompactGeometry,this._capabilities.query.supportsMaxRecordCountFactor&&(i.maxRecordCountFactor=4),s}createPagedTileQuery(t,e){const s=this.pageSize;return this.createTileQuery(t,{start:s*e,num:s,returnExceededLimitFeatures:!0})}createPagedQuery(t){const e=this.pageSize;return this.createQuery({start:e*t,num:e,returnExceededLimitFeatures:!0,maxRecordCountFactor:4})}}let $u=class extends P.c{constructor(t){super(),this._connection=t,this._enabledEventTypes=new Set,this._updateInfo={websocket:0,client:0},this._lastTime=performance.now(),this.addHandles([(0,c.aE)((()=>this._strategy?.connectionStatus??"disconnected"),(t=>{this._layerView.setProperty({propertyName:"pipelineConnectionStatus",value:t})}),{initial:!0}),(0,c.aE)((()=>this._strategy?.errorString||null),(t=>this._layerView.setProperty({propertyName:"pipelineErrorString",value:t})),{initial:!0})])}destroy(){this._strategy=null,this.removeAllHandles()}get _layerView(){return this._connection.layerView}set strategy(t){null==this._strategy&&this._resetUpdateInfo(performance.now());const e="event-handles";this.removeHandles(e),null!=t&&this.addHandles([t.events.on("data-received",(t=>this._onFeature(t))),t.events.on("message-received",(t=>this._onWebSocketMessage(t))),t.events.on("features-updated",(t=>this._onUpdate(t))),t.events.on("tick",(()=>this._onTick()))],e),this._strategy=t}updateCustomParameters(t){null!=t&&this._strategy?.updateCustomParameters(t)}sendMessageToSocket(t){this._strategy?.sendMessageToSocket(t)}sendMessageToClient(t){this._strategy?.sendMessageToClient(t)}enableEvent(t,e){e?this._enabledEventTypes.add(t):this._enabledEventTypes.delete(t)}disconnect(){this._strategy?.disconnect()}connect(){this._strategy?.connect()}clear(){this._strategy?.clear()}_onWebSocketMessage(t){this._enabledEventTypes.has("message-received")&&this._layerView.emitEvent({name:"message-received",event:t})}_onFeature(t){this._updateInfo.websocket++,this._enabledEventTypes.has("data-received")&&this._layerView.emitEvent({name:"data-received",event:{attributes:t.attributes,centroid:t.centroid,geometry:t.geometry}})}_onUpdate(t){this._updateInfo.client+=t}_onTick(){const t=performance.now(),e=t-this._lastTime;if(e>2500){const s=Math.round(this._updateInfo.client/(e/1e3)),i=Math.round(this._updateInfo.websocket/(e/1e3));this._resetUpdateInfo(t),this._layerView.emitEvent({name:"update-rate",event:{client:s,websocket:i}})}}_resetUpdateInfo(t){this._lastTime=t,this._updateInfo.client=0,this._updateInfo.websocket=0}};(0,T._)([(0,E.qq)()],$u.prototype,"_strategy",void 0),$u=(0,T._)([(0,k.c)("geoscene.views.2d.layers.features.sources.StreamMessenger")],$u);class Ku{constructor(t){this._store=t,this._controller=new AbortController}destroy(){this._controller.abort()}get _options(){return{signal:this._controller.signal}}async queryOverride(t){throw new Error("InternalError: LoadStrategy does not support fetching")}}var Zu=s(46448),Qu=s(42736),Ju=s(96248),td=s(91232),ed=s(58580);const sd=268435455;class id{constructor(){this.hasFeatures=!1,this.exceededTransferLimit=!1,this.fieldCount=0,this.featureCount=0,this.objectIdFieldIndex=0,this.vertexCount=0,this.offsets={attributes:new Array,geometry:new Array},this.centroid=new Array}}const rd=268435455,nd=128e3,od={small:{delta:new Int32Array(128),decoded:new Int32Array(128)},large:{delta:new Int32Array(nd),decoded:new Int32Array(nd)}};function ad(t){return t<=od.small.delta.length?od.small:(t<=od.large.delta.length||(od.large.delta=new Int32Array(Math.round(1.25*t)),od.large.decoded=new Int32Array(Math.round(1.25*t))),od.large)}function hd(t){for(;t.next();){if(1===t.tag())return t.getMessage();t.skip()}return null}function cd(t,e,s,i,r,n){return.5*Math.abs(t*i+s*n+r*e-t*n-s*e-r*i)}function ld(t,e,s,i){return 0==t*i-s*e&&t*s+e*i>0}class ud extends ql{static fromBuffer(t,e,s=!1){const r=e.geometryType,n=function(t){try{const e=2,s=new td.c(new Uint8Array(t),new DataView(t));for(;s.next();){if(s.tag()===e)return hd(s.getMessage());s.skip()}}catch(t){const e=new i.c("query:parsing-pbf","Error while parsing FeatureSet PBF payload",{error:t});C.c.getLogger("geoscene.view.2d.layers.features.support.FeatureSetReaderPBF").error(e)}return null}(t),o=function(t,e,s=!1){const r=t.asUnsafe(),n=r.pos(),o=new id;let a=0,h=0,c=null,l=null,u=null,d=!1;const p=[];for(;r.next();)switch(r.tag()){case 1:c=r.getString();break;case 3:l=r.getString();break;case 12:u=r.processMessage(ed.UH);break;case 9:if(o.exceededTransferLimit=r.getBool(),o.exceededTransferLimit){o.offsets.geometry=s?new Float64Array(8e3):new Int32Array(8e3),o.centroid=s?new Float64Array(16e3):new Int32Array(16e3);for(let t=0;t<o.centroid.length;t++)o.centroid[t]=sd}break;case 13:{const t=r.processMessage(ed.gD);t.index=a++,p.push(t);break}case 15:{const t=r.getLength(),i=r.pos()+t;if(!o.exceededTransferLimit){const t=o.offsets.geometry,e=o.centroid;t.push(0),e.push(sd),e.push(sd)}!d&&o.exceededTransferLimit&&(d=!0,o.offsets.attributes=s?new Float64Array(8e3*a):new Uint32Array(8e3*a));let n=h*a;for(;r.pos()<i&&r.next();)switch(r.tag()){case 1:{d?o.offsets.attributes[n++]=r.pos():o.offsets.attributes.push(r.pos());const t=r.getLength();r.skipLen(t);break}case 2:if(e){const t=r.getLength(),e=r.pos()+t;for(;r.pos()<e&&r.next();)switch(r.tag()){case 3:{r.getUInt32();const t=r.getSInt64(),e=r.getSInt64();o.centroid[2*h]=t,o.centroid[2*h+1]=e;break}default:r.skip()}}else{o.offsets.geometry[h]=r.pos();const t=r.getLength();o.vertexCount+=t,r.skipLen(t)}break;case 4:{const t=r.getLength(),e=r.pos()+t;for(;r.pos()<e&&r.next();)switch(r.tag()){case 3:{r.getUInt32();const t=r.getSInt64(),e=r.getSInt64();o.centroid[2*h]=t,o.centroid[2*h+1]=e;break}default:r.skip()}break}default:r.skip()}h++,o.hasFeatures=!0;break}default:r.skip()}const _=c||l;if(!_)throw new i.c("FeatureSet has no objectId or globalId field name");return o.fields=new Il.c(p),o.featureCount=h,o.fieldCount=a,o.objectIdFieldIndex=o.fields.get(_)?.index,o.transform=u,o.displayIds=new Uint32Array(o.featureCount),o.groupIds=new Uint16Array(o.featureCount),r.move(n),o}(n,"esriGeometryPoint"===r,s);return new ud(n,o,e)}constructor(t,e,s){super(s),this._hasNext=!1,this._isPoints=!1,this._featureIndex=-1,this._featureOffset=0,this._cache={area:0,unquantGeometry:void 0,geometry:void 0,centroid:void 0,legacyFeature:void 0,optFeature:void 0},this._parseCaches=new Array,this._geometryType=s.geometryType,this._reader=t,this._header=e,this._hasNext=e.hasFeatures,this._isPoints="esriGeometryPoint"===s.geometryType}get _size(){return this._header.featureCount}get fields(){return this._header.fields}get geometryType(){return this._geometryType}get hasZ(){return!1}get hasM(){return!1}get hasFeatures(){return this._header.hasFeatures}get hasNext(){return this._hasNext}get exceededTransferLimit(){return this._header.exceededTransferLimit}getSize(){return this._size}getInTransform(){return this._header.transform}getCursor(){return this.copy()}getIndex(){return this._featureIndex}setIndex(t){this._cache.area=0,this._cache.unquantGeometry=void 0,this._cache.geometry=void 0,this._cache.centroid=void 0,this._cache.legacyFeature=void 0,this._cache.optFeature=void 0,this._featureIndex=t}getAttributeHash(){let t="";for(const e of this._header.fields.fields)t+=this._readAttributeAtIndex(e.index)+".";return t}getObjectId(){return this._readAttributeAtIndex(this._header.objectIdFieldIndex)}getDisplayId(){return this._header.displayIds[this._featureIndex]}setDisplayId(t){this._header.displayIds[this._featureIndex]=t}readGeometryArea(){return this._cache.area||this._readGeometry(!0),this._cache.area}copy(){const t=this._reader.clone(),e=new ud(t,this._header,this.metadata);return this.copyInto(e),e}next(){for(this._cache.area=0,this._cache.unquantGeometry=void 0,this._cache.geometry=void 0,this._cache.centroid=void 0,this._cache.legacyFeature=void 0,this._cache.optFeature=void 0;++this._featureIndex<this._size&&!this._getExists(););return this._featureIndex<this._size}_readX(){return this._header.centroid[2*this._featureIndex]}_readY(){return this._header.centroid[2*this._featureIndex+1]}_readServerCentroid(){const t=this._header.centroid[2*this._featureIndex],e=this._header.centroid[2*this._featureIndex+1];return t===rd?null:new ft.c([],[t,e])}_readGeometry(t=!1){if(void 0===this._cache.geometry){let e=null;if(this._isPoints){if(this._header.centroid[2*this._featureIndex]===rd)return null;const t=this._header.centroid[2*this._featureIndex],s=this._header.centroid[2*this._featureIndex+1];e=new ft.c([],[t,s])}else{const s=this._header.offsets.geometry[this._featureIndex],i=this._reader;if(0===s)return null;i.move(s);try{e=t?this._parseGeometryForDisplay(i):this._parseGeometry(i)}catch(t){return console.error("Failed to parse geometry!",t),null}}return 0===e?.coords.length&&(e=null),this._cache.geometry=e,e}return this._cache.geometry}_readAttribute(t,e){const s=this._header.fields.get(t);if(null==s)return;let i=this._readAttributeAtIndex(s.index);"esriFieldTypeTimestampOffset"===this.fields.get(t)?.type&&(i=this.parseTimestampOffset(i));const r=this._header.fields.isDateField(s.name);return e?null==i?i:r?new Date(i):i:i}_readAttributes(){const t={};for(const e of this._header.fields.fields)t[e.name]=this._readAttributeAtIndex(e.index);return t}copyInto(t){super.copyInto(t),t._featureIndex=this._featureIndex,t._featureOffset=this._featureOffset,t._hasNext=this._hasNext,t._parseCaches=this._parseCaches}_readAttributeAtIndex(t){let e=this._parseCaches[t];if(e||(e=new kl(this.getSize()),this._parseCaches[t]=e),e.has(this._featureIndex))return e.get(this._featureIndex);const s=this._header.offsets.attributes[this._featureIndex*this._header.fieldCount+t],i=this._reader;i.move(s);const r=function(t){const e=t.getLength(),s=t.pos()+e;for(;t.pos()<s&&t.next();)switch(t.tag()){case 1:return t.getString();case 2:return t.getFloat();case 3:return t.getDouble();case 4:return t.getSInt32();case 5:return t.getUInt32();case 6:return t.getInt64();case 7:return t.getUInt64();case 8:return t.getSInt64();case 9:return t.getBool();default:return t.skip(),null}return null}(i);return e.set(this._featureIndex,r),r}_readGeometryDeltaDecoded(t=!1){if(void 0===this._cache.unquantGeometry){const e=this._readGeometry(t);if(!e)return this._cache.unquantGeometry=void 0,null;if(!this.getInTransform())return this._cache.unquantGeometry=e,e;const s=ad(e.coords.length).decoded,i=e.clone(s),r=i.coords;let n=0;for(const t of i.lengths){for(let e=1;e<t;e++){const t=2*(n+e),s=2*(n+e-1);r[t]+=r[s],r[t+1]+=r[s+1]}n+=t}return this._cache.unquantGeometry=i,i}return this._cache.unquantGeometry}_parseGeometry(t){const e=t.asUnsafe(),s=e.getLength(),i=e.pos()+s,r=[],n=[];for(;e.pos()<i&&e.next();)switch(e.tag()){case 2:{const t=e.getUInt32(),s=e.pos()+t;for(;e.pos()<s;)n.push(e.getUInt32());break}case 3:{const t=e.getUInt32(),s=e.pos()+t;for(r.push(e.getSInt64()),r.push(e.getSInt64()),this.hasZ&&e.getSInt64(),this.hasM&&e.getSInt64();e.pos()<s;)r.push(e.getSInt64()),r.push(e.getSInt64()),this.hasZ&&e.getSInt64(),this.hasM&&e.getSInt64();break}default:e.skip()}return new ft.c(n,r)}_parseGeometryForDisplay(t){const e=t.asUnsafe(),s=e.getLength(),i=e.pos()+s,r=[],n=[];let o=0,a=0,h=null,c=0;const l="esriGeometryPolygon"===this.geometryType;for(;e.pos()<i&&e.next();)switch(e.tag()){case 2:{const t=e.getUInt32(),s=e.pos()+t;for(;e.pos()<s;){const t=e.getUInt32();r.push(t),o+=t}h=ad(2*o).delta;break}case 3:{e.getUInt32();const t=2+(this.hasZ?1:0)+(this.hasM?1:0);(0,M.EN)(h);for(const s of r)if(a+t*s>h.length)for(let t=0;t<s;t++)e.getSInt32(),e.getSInt32(),this.hasZ&&e.getSInt32(),this.hasM&&e.getSInt32();else if(l){const t=this.getAreaSimplificationThreshold(s,this._header.vertexCount);let i=2,r=1;const o=!1;let l=e.getSInt32(),u=e.getSInt32();h[a++]=l,h[a++]=u,this.hasZ&&e.getSInt32(),this.hasM&&e.getSInt32();let d=e.getSInt32(),p=e.getSInt32();for(this.hasZ&&e.getSInt32(),this.hasM&&e.getSInt32();i<s;){let s=e.getSInt32(),n=e.getSInt32();this.hasZ&&e.getSInt32(),this.hasM&&e.getSInt32();const o=l+d,_=u+p;cd(l,u,o,_,o+s,_+n)>=t?(c+=-.5*(o-l)*(_+u),r>1&&ld(h[a-2],h[a-1],d,p)?(h[a-2]+=d,h[a-1]+=p):(h[a++]=d,h[a++]=p,r++),l=o,u=_):(s+=d,n+=p),d=s,p=n,i++}r<3||o?a-=2*r:(c+=-.5*(l+d-l)*(u+p+u),ld(h[a-2],h[a-1],d,p)?(h[a-2]+=d,h[a-1]+=p,n.push(r)):(h[a++]=d,h[a++]=p,n.push(++r)))}else{let t=0,i=e.getSInt32(),r=e.getSInt32();this.hasZ&&e.getSInt32(),this.hasM&&e.getSInt32(),h[a++]=i,h[a++]=r,t+=1;for(let n=1;n<s;n++){const s=e.getSInt32(),o=e.getSInt32(),l=i+s,u=r+o;c+=-.5*(l-i)*(u+r),this.hasZ&&e.getSInt32(),this.hasM&&e.getSInt32(),n>2&&ld(h[a-2],h[a-1],s,o)?(h[a-2]+=s,h[a-1]+=o):(h[a++]=s,h[a++]=o,t+=1),i=l,r=u}n.push(t)}break}default:e.skip()}return this._cache.area=c,n.length?new ft.c(n,h):null}}class dd{constructor(t,e){this.service=t,this._metadata=e}destroy(){}}class pd extends dd{constructor(t,e){super(t,e),this._portsOpen=async function(t){const e=new Zu.c;return await e.open(t,{}),e}(t.source).then((t=>this.client=t))}destroy(){this.client.close(),this.client=null}async executeQuery(t,e){await this._portsOpen;const s=await this.client.invoke("queryFeatures",t.toJSON(),e);return Wl.fromFeatureSet(s,this._metadata)}}class _d extends dd{async executeQuery(t,e){const{data:s}=await(0,Wu.u_)(this.service.source,t,e),i=!t.quantizationParameters;return ud.fromBuffer(s,this._metadata,i)}}class fd extends dd{async executeQuery(t,e){const{source:s,queryMetadata:i}=this.service,r=i.capabilities;if(null!=t.quantizationParameters&&!r.query.supportsQuantization){const i=t.clone(),r=(0,Qu.eE)(i.quantizationParameters);i.quantizationParameters=null;const{data:n}=await(0,Wu.EL)(s,i,this._metadata.spatialReference,e),o=(0,zc.ui)(n,this._metadata.objectIdField);return(0,zc.m)(r,o),Wl.fromOptimizedFeatureSet(o,this._metadata)}const{data:n}=await(0,Wu.EL)(s,t,this._metadata.spatialReference,e);return"esriGeometryPoint"===this._metadata.geometryType&&(n.features=n.features?.filter((t=>{if(null!=t.geometry){const e=t.geometry;return Number.isFinite(e.x)&&Number.isFinite(e.y)}return!0}))),Wl.fromFeatureSet(n,this._metadata)}}class md extends dd{async executeQuery(t,e){const{capabilities:s}=this.service.queryMetadata;if(t.quantizationParameters&&!s.query.supportsQuantization){const s=t.clone(),i=(0,Qu.eE)(s.quantizationParameters);s.quantizationParameters=null;const r=await(0,Ju.wB)(this.service.source,t,e);return(0,zc.m)(i,r),Wl.fromOptimizedFeatureSet(r,this._metadata)}const i=await(0,Ju.wB)(this.service.source,t,e);return Wl.fromOptimizedFeatureSet(i,this._metadata)}}class gd extends Ku{constructor(t,e,s,i,r){super(s),this._serviceInfo=t,this._queryInfo=e,this._metadata=i,this._eventLog=r,this._queue=new A.K({concurrency:16,process:async t=>{const e={signal:t.options?.signal,query:t.query.customParameters};return this._adapter.executeQuery(t.query.inner,e)}}),this._adapter=function(t,e){switch(t.type){case"memory":return new pd(t,e);case"ogc":return new md(t,e);case"feature-service":return t.queryMetadata.capabilities.query.supportsFormatPBF&&(0,n.c)("featurelayer-pbf")?new _d(t,e):new fd(t,e)}}(t,i)}async updateFields(t){this._queryInfo.updateFields(t);const e=Array.from(this._store.chunks()).map((async t=>{const e=wl.c.fromJSON(t.queryInfo.queryJSON);if(e)try{return await this._tryUpdateFields(t.reader,e),null}catch(t){return t}})),s=(await Promise.all(e)).filter((t=>t));if(s.length)throw new i.c("featurelayer-query","Encountered errors when downloading fields",{errors:s})}async queryOverride({edits:t}){const e=[],s=[];for(const i of t.removed)null!=i.objectId&&-1!==i.objectId?e.push(i.objectId):s.push(i.globalId);s.length&&e.push(...this._mapGlobalIdsToObjectIds(s));const i=t.addOrModified.map((({objectId:t})=>t)),r=this._queryInfo.createQuery({objectIds:i});return{reader:await this._fetch(r),removed:e}}_mapGlobalIdsToObjectIds(t){const e=new Set(t),s=this._metadata.globalIdField;if(null==s)throw new Error("InternalError: Recieved an edit with globalIds, but not supported by the service");const i=[];return this._store.forEachUnsafe((t=>{const r=t.readAttribute(s);e.has(r)&&i.push(t.getObjectId())})),i}async _fetch(t,e){const s=await this._enqueue(t,e);return await this._tryUpdateFields(s,t.inner),s}async _tryUpdateFields(t,e){const s=this._queryInfo.createPatchFieldsQuery(e,t.fields);if(!s)return;const i=await this._enqueue(s,this._options);t.joinAttributes(i)}async _enqueue(t,e){return this._eventLog.onEvent({type:"fetchStart"}),this._queue.push({query:t,options:e}).finally((()=>{this._eventLog.onEvent({type:"fetchEnd",done:0===this._queue.length})}))}}class yd extends gd{constructor(){super(...arguments),this._chunksById=new Map}unload(t){this._removeChunks(t.tile)}_addChunk(t){const e=t.tile.id;this._chunksById.has(e)||this._chunksById.set(e,[]);const s=t.size();(s||t.first||t.end)&&((0,n.c)("geoscene-2d-update-debug")&&console.debug(`Chunk[${t.chunkId}] ATileLoadStrategy.addChunk [count=${s}]`),this._chunksById.get(e).push(t),this._store.insert(t))}_removeChunks(t){const e=this._chunksById.get(t.key.id)??[];for(const s of e)(0,n.c)("geoscene-2d-update-debug")&&console.debug(`Tile[${t.key.id}] Chunk[${s.chunkId}] ATileLoadStrategy.removeChunk`),this._store.remove(s);this._chunksById.delete(t.key.id)}}class xd extends Fu{constructor(t,e,s,i,r,n){super(),this._reader=t,this._queryJSON=e,this._tile=s,this._sourceTile=i,this._sourceTileDepth=r,this._end=n,this.chunkId=`${this._tile.key.id}.${this._sourceTile?.key.id}${this._end?"e":""}`,this.normalizedChunkId=`${this._tile.key.normalizedId}.${this._sourceTile?.key.normalizedId}${this._end?"e":""}`}get queryInfo(){return{type:"drill-down-tile",chunkId:this.chunkId,tileId:this._tile.key.id,queryJSON:this._queryJSON,sourceTileDepth:this._sourceTileDepth,sourceTileId:this._sourceTile?.key.id,size:this.size(),end:this.end}}get first(){return 0===this._sourceTileDepth}get reader(){return this._reader}get end(){return this._end}get tile(){return this._tile}get isTiled(){return!0}getTileReader(t){return this._tile.key.id===t.key.id?this.reader:null}}class bd{constructor(t,e){this.subscription=t,this._tileIdToResult=new Map,this._controller=new AbortController,(0,a.wD)(t.options,(()=>this._controller.abort())),(0,a.wD)(e,(()=>this._controller.abort()))}get(t){return this._tileIdToResult.get(t)}set(t,e){this._tileIdToResult.set(t,e)}get options(){return{signal:this._controller.signal}}}class wd extends yd{constructor(){super(...arguments),this._loadStates=new Map}get about(){return{willQueryAllFeatures:!1,willQueryFullResolutionGeometry:!1}}async load(t){this._loadStates.has(t.key.id)||this._loadStates.set(t.key.id,new bd(t,this._options));const e=this._loadStates.get(t.key.id);let s;try{for await(const s of this._fetchChunkInfos(e,t.tile,0)){const{queryJSON:e,reader:i,sourceTile:r,sourceTileDepth:n,tile:o}=s,h=new xd(i,e,o,r,n,!1);(0,a.wp)(t.options),this._addChunk(h)}}catch(t){s=t}const i=new xd(Wl.empty(this._metadata),null,t.tile,null,-1,!0);if(this._addChunk(i),s)throw s}unload(t){super.unload(t),this._loadStates.delete(t.key.id)}async*_fetchChunkInfos(t,e,s){let i=t.get(e.id);const r=!!i;if(i||(i=await this._fetchChunkInfo(t,e,s),t.set(e.id,i)),i.reader.exceededTransferLimit&&s<(0,n.c)("featurelayer-query-max-depth"))for(const i of e.createChildTiles())yield*this._fetchChunkInfos(t,i,s+1);else r||(yield i)}async _fetchChunkInfo(t,e,s){const i=t.subscription.tile.getQuantizationParameters(),r=this._queryInfo.createTileQuery(e,{returnExceededLimitFeatures:!1,quantizationParameters:i});return{reader:await this._fetch(r,t.subscription.options),queryJSON:r.inner.toJSON(),tile:t.subscription.tile,sourceTile:e,sourceTileDepth:s}}}class vd extends Fu{constructor(t,e,s,i,r){super(),this._reader=t,this._queryJSON=e,this._tile=s,this._page=i,this._end=r,this.chunkId=`${this._tile.key.id}.${this._page}${this.end?"e":""}`,this.normalizedChunkId=`${this._tile.key.normalizedId}.${this._page}${this.end?"e":""}`}get queryInfo(){return{type:"paged-tile",chunkId:this.chunkId,tileId:this._tile.key.id,queryJSON:this._queryJSON,page:this._page,size:this.size(),end:this.end}}get reader(){return this._reader}get first(){return 0===this._page}get end(){return this._end}get page(){return this._page}get tile(){return this._tile}get isTiled(){return!0}getTileReader(t){return this._tile.key.id===t.key.id?this.reader:null}}class Sd{constructor(t,e){this.subscription=t,this._pages=new Set,this._controller=new AbortController,this._done=!1,(0,a.wD)(t.options,(()=>this._controller.abort())),(0,a.wD)(e,(()=>this._controller.abort()))}resetAbortController(){this._controller=new AbortController}get pageStart(){let t=-1;for(const e of this._pages.values())t=Math.max(t,e);return t+1}get done(){return this._done}get options(){return{signal:this._controller.signal}}add(t,e){this._pages.add(t),this._done=this._done||e}}class Id extends yd{constructor(){super(...arguments),this._loadStates=new Map}get about(){return{willQueryAllFeatures:!1,willQueryFullResolutionGeometry:!1}}async load(t){this._loadStates.has(t.key.id)||this._loadStates.set(t.key.id,new Sd(t,this._options));const e=this._loadStates.get(t.key.id);let s;e.resetAbortController();try{await this._fetchPages(e)}catch(t){s=t}const i=new vd(Wl.empty(this._metadata),null,t.tile,-1,!0);if((0,a.wv)(e.options)||this._addChunk(i),s)throw s}unload(t){super.unload(t),this._loadStates.delete(t.key.id)}async _fetchPages(t){let e=0,s=t.pageStart,i=1;for(;e<20&&!t.done;){const r=[];for(let e=0;e<i;e++)r.push(this._fetchChunk(t,s++));const n=await Promise.all(r);for(const e of n)(0!==e.size()||e.first)&&(t.add(e.page,!e.reader.exceededTransferLimit),(0,a.wp)(t.options),this._addChunk(e));e++,i=Math.min(i+1,4)}}async _fetchChunk(t,e){const s=t.subscription.tile,i=this._queryInfo.createPagedTileQuery(s,e),r=await this._fetch(i,t.options);return new vd(r,i.inner.toJSON(),s,e,!1)}}class Td extends Fu{constructor(t,e,s,i){super(),this._reader=t,this._queryJSON=e,this._page=s,this._end=i,this.chunkId=`${this._page}${this.end?"e":""}`,this.normalizedChunkId=this.chunkId}get reader(){return this._reader}get first(){return 0===this._page}get end(){return this._end}get queryInfo(){return{type:"snapshot",chunkId:this.chunkId,queryJSON:this._queryJSON,page:this._page,size:this.size(),end:this.end}}get isTiled(){return!1}getTileReader(t){const e=this.queryFeaturesInBounds(t.bounds);return e.setTransformForDisplay(t.transform),e}}class Pd extends gd{constructor(t,e,s,i,r,n){super(t,e,s,r,n),this._random=new h.c(1e3),this._featureCount=i}get about(){return{willQueryAllFeatures:!0,willQueryFullResolutionGeometry:!0}}load(t){return null==this._promise&&(this._promise=this._downloadPages(this._featureCount)),this._promise}unload(t){}async _downloadPages(t){const e=Math.ceil(t/this._queryInfo.pageSize),s=Array.from({length:e},((t,e)=>e)).sort(((t,e)=>this._random.getInt()-this._random.getInt())),r=await Promise.all(s.map((t=>this._downloadPage(t)))),n=new Td(Wl.empty(this._metadata),null,-1,!0);this._store.insert(n);const o=r.filter((t=>t));if(o.length)throw new i.c("featurelayer-query","Encountered errors when downloading data",{errors:o})}async _downloadPage(t){try{const e=this._queryInfo.createPagedQuery(t),s=await this._fetch(e,this._options),i=new Td(s,e.inner.toJSON(),t,!1);return(0,a.wp)(this._options),this._store.insert(i),null}catch(t){return t}}}class Md{constructor(t){this.size=0,this._start=0,this.maxSize=t,this._buffer=new Array(t)}get entries(){return this._buffer}enqueue(t){if(this.size===this.maxSize){const e=this._buffer[this._start];return this._buffer[this._start]=t,this._start=(this._start+1)%this.maxSize,e}return this._buffer[(this._start+this.size++)%this.maxSize]=t,null}dequeue(){if(0===this.size)return null;const t=this._buffer[this._start];return this._buffer[this._start]=null,this.size--,this._start=(this._start+1)%this.maxSize,t}peek(){return 0===this.size?null:this._buffer[this._start]}find(t){if(0===this.size)return null;for(const e of this._buffer)if(null!=e&&t(e))return e;return null}clear(t){let e=this.dequeue();for(;null!=e;)t&&t(e),e=this.dequeue()}}const Ed="__esri_timestamp__";class Cd{constructor(t,e,s,i,r=128){this._trackIdToObservations=new Map,this._idCounter=0,this._lastPurge=performance.now(),this._addOrUpdated=new Map,this._removed=[],this._maxAge=0,this._timeInfo=s,this._purgeOptions=i,this.store=t,this.objectIdField=e,this.purgeInterval=r,this._useGeneratedIds="__esri_stream_id__"===this.objectIdField}removeById(t){this._removed.push(t)}removeByTrackId(t){const e=this._trackIdToObservations.get(t);if(e)for(const t of e.entries)this._removed.push(t)}add(t){if(this._useGeneratedIds){const e=this._nextId();t.attributes[this.objectIdField]=e,t.objectId=e}else t.objectId=t.attributes[this.objectIdField];const e=t.objectId;if(this._addOrUpdated.set(e,t),this._maxAge=Math.max(this._maxAge,t.attributes[this._timeInfo.startTimeField]),!this._timeInfo.trackIdField)return null==this._trackIdLessObservations&&(this._trackIdLessObservations=new Md(1e5)),void this._trackIdLessObservations.enqueue(e);const s=t.attributes[this._timeInfo.trackIdField];if(!this._trackIdToObservations.has(s)){const t=null!=this._purgeOptions?.maxObservations?this._purgeOptions.maxObservations:1e3,e=(0,jh.qk)(t,0,1e3);this._trackIdToObservations.set(s,new Md(e))}const i=this._trackIdToObservations.get(s),r=i?.enqueue(e);null!=r&&(this._addOrUpdated.has(r)?this._addOrUpdated.delete(r):this._removed.push(r))}checkForUpdates(){const t=this._getToAdd(),e=this._getToRemove(),s=performance.now();s-this._lastPurge>=this.purgeInterval&&(this._purge(s),this._lastPurge=s);const i=[];if(null!=e)for(const t of e){const e=this.store.removeById(t);null!=e&&i.push(e)}const r=[];if(null!=t){const i=new Set(e??[]);for(const e of t)i.has(e.objectId)||(e.attributes[Ed]=s,this.store.add(e),r.push(e))}return!(!r.length&&!i?.length||(this.store.update(r,i),0))}_getToAdd(){if(!this._addOrUpdated.size)return null;const t=new Array(this._addOrUpdated.size);let e=0;return this._addOrUpdated.forEach((s=>t[e++]=s)),this._addOrUpdated.clear(),t}_getToRemove(){const t=this._removed;return this._removed.length?(this._removed=[],t):null}_nextId(){const t=this._idCounter;return this._idCounter=(this._idCounter+1)%4294967294+1,t}_purge(t){const e=this._purgeOptions;null!=e&&(this._purgeSomeByDisplayCount(e),this._purgeByAge(e),this._purgeByAgeReceived(t,e),this._purgeTracks())}_purgeSomeByDisplayCount(t){if(!t.displayCount)return;let e=this.store.size;if(e>t.displayCount){if(this._timeInfo.trackIdField)for(const s of this._trackIdToObservations.values())if(e>t.displayCount&&s.size){const t=s.dequeue();this._removed.push(t),e--}if(null!=this._trackIdLessObservations){let s=e-t.displayCount;for(;s-- >0;){const t=this._trackIdLessObservations.dequeue();null!=t&&this._removed.push(t)}}}}_purgeByAge(t){const e=this._timeInfo?.startTimeField;if(!t.age||!e)return;const s=60*t.age*1e3,i=this._maxAge-s;this.store.forEach((t=>{t.attributes[e]<i&&this._removed.push(t.objectId)}))}_purgeByAgeReceived(t,e){if(!e.ageReceived)return;const s=t-60*e.ageReceived*1e3;this.store.forEach((t=>{t.attributes[Ed]<s&&this._removed.push(t.objectId)}))}_purgeTracks(){this._trackIdToObservations.forEach(((t,e)=>{0===t.size&&this._trackIdToObservations.delete(e)}))}}var kd=s(57006);let Fd=class extends P.c{constructor(t){super(t)}get connectionStatus(){return this.connection?.connectionStatus}get errorString(){return this.connection?.errorString}};(0,T._)([(0,E.qq)()],Fd.prototype,"connection",void 0),(0,T._)([(0,E.qq)()],Fd.prototype,"connectionStatus",null),(0,T._)([(0,E.qq)()],Fd.prototype,"errorString",null),Fd=(0,T._)([(0,k.c)("geoscene.views.2d.layers.features.sources.StreamConnectionState")],Fd);class Ad{constructor(t,e){this._metadata=t,this._onUpdate=e,this._objectIdToFeature=new Map}get size(){return this._objectIdToFeature.size}get reader(){return Wl.fromFeatures([...this._objectIdToFeature.values()],this._metadata)}add(t){this._objectIdToFeature.set(t.objectId,t)}forEach(t){this._objectIdToFeature.forEach(t)}removeById(t){const e=this._objectIdToFeature.get(t);return e?(this._objectIdToFeature.delete(t),e):null}clear(){this._objectIdToFeature=new Map}update(t,e){this._onUpdate(t?.length??0)}}class Rd extends Fu{constructor(t){super(),this._reader=t,this.chunkId="stream-chunk",this.normalizedChunkId="stream-chunk"}get reader(){return this._reader}get first(){return!0}get end(){return!0}get queryInfo(){return{type:"stream",chunkId:this.chunkId,size:this.size(),end:this.end}}get isTiled(){return!1}getTileReader(t){const e=this.queryFeaturesInBounds(t.bounds);return e.setTransformForDisplay(t.transform),e}}class Od extends Ku{constructor(t,e,s,i,r){super(s),this._service=t,this._dataFilter=e,this._streamOptions=i,this._metadata=r,this._connectionState=new Fd,this._forceRefresh=!1,this.events=new Gc.c;const{objectIdField:n,timeInfo:o}=this._metadata,{purgeOptions:a}=e;this._stagingStore=new Ad(this._metadata,(t=>this.events.emit("features-updated",t))),this._manager=new Cd(this._stagingStore,n,o,a),this.connect()}destroy(){super.destroy(),this.disconnect()}get about(){return{willQueryAllFeatures:!1,willQueryFullResolutionGeometry:!1}}get connectionStatus(){return this._connectionState.connectionStatus}get errorString(){return this._connectionState?.errorString}async refresh(){const t=null!=this._chunk;this._manager.checkForUpdates()||!t||this._forceRefresh?(this._chunk&&this._store.remove(this._chunk),this._forceRefresh=!1,this._chunk=new Rd(this._stagingStore.reader),this._store.insert(this._chunk),this.events.emit("tick")):this.events.emit("tick")}async updateFields(t){throw new Error("Updating available fields not supported for StreamLayer")}async load(t){}unload(t){}disconnect(){this._connection=(0,M.mG)(this._connection),this._connectionState.connection=null,this._handlesGroup?.remove()}connect(){if(null!=this._connection)return;const{geometryType:t,spatialReference:e}=this._metadata,{maxReconnectionAttempts:s,maxReconnectionInterval:i,geometryDefinition:n,definitionExpression:o,customParameters:a}=this._dataFilter;this._connection=(0,kd.createConnection)(this._service.source,e,this._streamOptions.outSR,t,o,n,s,i,a),this._handlesGroup=(0,r.Ip)([this._connection.on("data-received",(t=>this._onFeature(t))),this._connection.on("message-received",(t=>this._onWebSocketMessage(t)))]),this._connectionState.connection=this._connection}clear(){this._manager.checkForUpdates(),this._stagingStore.clear(),this._forceRefresh=!0}updateCustomParameters(t){this._connection?.updateCustomParameters(t)}sendMessageToSocket(t){this._connection?.sendMessageToSocket(t)}sendMessageToClient(t){this._connection?.sendMessageToClient(t)}_onWebSocketMessage(t){if("type"in t)switch(t.type){case"delete":if(t.objectIds)for(const e of t.objectIds)this._manager.removeById(e);if(t.trackIds)for(const e of t.trackIds)this._manager.removeByTrackId(e);break;case"clear":this.clear()}this.events.emit("message-received",t)}_onFeature(t){try{this._manager.add(t),this.events.emit("data-received",t)}catch(t){}}}class Nd{constructor(t){this._onChange=t,this._chunks=new Map,this._overrideChunk=new Au,this._chunksToRemove=[],this.events=new Gc.c,this.featureAdapter=new vl}destroy(){this.clear()}clear(){for(const t of this._chunks.values())this._chunksToRemove.push(t);this._chunks.clear(),this._overrideChunk&&this._chunksToRemove.push(this._overrideChunk),this._overrideChunk=new Au}*chunks(){this._overrideChunk&&(yield this._overrideChunk),yield*this._chunks.values()}insert(t){(0,n.c)("geoscene-2d-update-debug")&&console.debug(`Chunk[${t.chunkId}] SourceChunkStore.insert`),this._overrideChunk.overridenIds.size&&t.reader.removeIds(this._overrideChunk.overridenIds),this._chunks.set(t.chunkId,t),this.events.emit("changed"),this._onChange()}remove(t){(0,n.c)("geoscene-2d-update-debug")&&console.debug(`Chunk[${t.chunkId}] SourceChunkStore.remove`),this._chunks.delete(t.chunkId),this._chunksToRemove.push(t)}cleanupRemovedChunks(){const t=this._chunksToRemove;return this._chunksToRemove=[],t}applyOverrides(t){this._overrideChunk.applyOverrides(t);for(const t of this._chunks.values())t.reader.removeIds(this._overrideChunk.overridenIds),t.invalidate()}forEach(t){const e=new Set;for(const s of this.chunks()){const i=s.reader.getCursor();for(;i.next();){const s=i.getObjectId();e.has(s)||(t(i.copy()),e.add(s))}}}forEachUnsafe(t){const e=new Set;for(const s of this.chunks()){const i=s.reader.getCursor();for(;i.next();){const s=i.getObjectId();e.has(s)||(t(i),e.add(s))}}}forEachInBounds(t,e){const s=new Set;for(const i of this.chunks()){const r=i.queryFeaturesInBounds(t);for(;r.next();){const t=r.getObjectId();s.has(t)||(e(r.copy()),s.add(t))}}}forEachBounds(t,e){const s=(0,Vc.Su)();for(const i of t)i.getBounds(s)&&e(s)}}var Dd=s(23964),zd=s(60936);let Ld=class extends P.c{constructor(t){super(t),this.debugName="",this._updatingHandles=new zd.A,this._idToUpdatingState=new Dd.c}get updating(){const t=this._updatingHandles.updating||Array.from(this._idToUpdatingState.values()).some((t=>t));if((0,n.c)("geoscene-2d-log-updating")){const e=Array.from(this._idToUpdatingState.entries()).map((([t,e])=>`-> ${t}: ${e}`)).join("\n");console.log(`${this.debugName}: Updating: ${t}\n-> Handles: ${this._updatingHandles.updating}\n${e}`)}return t}addUpdateTracking(t,e){const s=(0,c.aE)((()=>e.updating),(e=>this._idToUpdatingState.set(t,e)),{sync:!0});this.addHandles(s)}addPromise(t){return this._updatingHandles.addPromise(t)}};(0,T._)([(0,E.qq)({constructOnly:!0})],Ld.prototype,"debugName",void 0),(0,T._)([(0,E.qq)({readOnly:!0})],Ld.prototype,"updating",null),Ld=(0,T._)([(0,k.c)("geoscene.view.2d.layers.support.UpdateTracking2D")],Ld);class Bd{constructor(t,e,s,i){this._aggregateAdapter=t,this._subscriptions=e,this._onChange=s,this._connection=i,this._updateTracking=new Ld({debugName:"FeatureSource"}),this._store=new Nd(this._onChange)}destroy(){this._strategy?.destroy(),this._store.destroy(),this._streamMessenger?.destroy()}get _eventLog(){return this._connection.eventLog}get metadata(){if(!this._metadata)throw new Error("InternalError: Metadata not defined. Was update called?");return this._metadata}get service(){return this._schema.service}get store(){return this._store}get streamMessenger(){return null==this._streamMessenger&&this._initStreamMessenger(),this._streamMessenger}get statistics(){return Xu.from(this._store)}get updateTracking(){return this._updateTracking}get queryEngine(){if(!this._queryEngine){if(!this._schema)return null;const{dataFilter:t}=this._schema.mutable,e=this._schema.mutable.availableFields,s=this._metadata;this._queryEngine=new Wc.U({featureStore:this._store,fieldsIndex:s.fieldsIndex,geometryType:s.geometryType,objectIdField:s.objectIdField,hasM:!1,hasZ:!1,spatialReference:t.outSpatialReference,cacheSpatialQueries:!0,aggregateAdapter:this._aggregateAdapter,timeInfo:s.timeInfo,definitionExpression:t.definitionExpression,availableFields:e})}return this._queryEngine}get isStream(){return"stream"===this._schema.type}chunks(){return Array.from(this._store.chunks())}cleanupRemovedChunks(){return this._store.cleanupRemovedChunks()}onSubscribe(t){this._eventLog.onEvent({type:"subscribe",tile:t.tile.id});const e=this._strategy?.load(t);e&&(e.then((()=>this._eventLog.onEvent({type:"loaded",tile:t.tile.id}))).catch((e=>this._eventLog.onEvent({type:"error",tile:t.tile.id,error:e}))),this._updateTracking.addPromise(e))}onResume(t){this._updateTracking.addPromise((0,a.jO)(this._strategy?.load(t)))}onUnsubscribe(t){this._eventLog.onEvent({type:"unsubscribe",tile:t.tile.id}),this._strategy?.unload(t)}getOverride(t){return this._updateTracking.addPromise(this._doGetOverride(t))}applyOverride(t){this._store.applyOverrides(t)}async update(t,e){const s=t.source,i=(0,G.qq)(this._schema?.mutable,s.mutable);if(!i)return!1;if((0,n.c)("geoscene-2d-update-debug")&&console.debug(`Version[${e}] FeatureSource.update`,{changes:i}),this._schema=s,this._metadata=new Tl(this._schema.service.metadata),this._queryEngine?.destroy(),this._queryEngine=null,"feature"===this._schema.type&&null!=this._schema.service.queryMetadata.lastEditDate&&(this._lastEditDate=this._schema.service.queryMetadata.lastEditDate),null==this._streamMessenger&&"stream"===this._schema.type&&this._initStreamMessenger(),(0,G.mQ)(i,"sourceRefreshVersion")&&this._strategy?.refresh)return await this._strategy.refresh(),!0;if("feature"===s.type&&(0,G.mQ)(i,"availableFields")){if(await this._queryLastEditDateChanged())await this._updateStrategy(e);else{this._eventLog.onEvent({type:"updateFieldsStart"});try{await this._strategy.updateFields(s.mutable.availableFields),this._eventLog.onEvent({type:"updateFieldsEnd"})}catch(t){this._eventLog.onEvent({type:"updateFieldsError",error:t})}}return!1}return!(!(0,G.Go)(i,"dataFilter")&&!(0,G.Go)(i,"sourceRefreshVersion")||(await this._updateStrategy(e),0))}_initStreamMessenger(){null==this._streamMessenger&&(this._streamMessenger=new $u(this._connection))}async _doGetOverride(t){return this._strategy.queryOverride(t)}async _queryLastEditDateChanged(){if(null==this._lastEditDate)return!1;const t=this._schema.service.source,e={...t.query,f:"json"},s=(await(0,qu.c)(t.path,{query:e,responseType:"json"})).data.editingInfo.lastEditDate;return s!==this._lastEditDate&&(this._lastEditDate=s,!0)}async _createStrategy(){const t=this.service,e="isSourceHosted"in t&&t.isSourceHosted,s=Array.isArray(t.source),i=t.source&&"collection"in t.source,r=e||s||i;if("stream"===this._schema.type){const t=new Od(this._schema.service,this._schema.mutable.dataFilter,this._store,{outSR:this._schema.mutable.dataFilter.outSpatialReference},this.metadata);return this._streamMessenger.strategy=t,t}const n=Hu.fromSchema(this._schema,this._metadata),o=await this._supportSnapshotMode(this._schema,n);return o?new Pd(this._schema.service,n,this._store,o.featureCount,this.metadata,this._eventLog):r?new Id(this._schema.service,n,this._store,this.metadata,this._eventLog):new wd(this._schema.service,n,this._store,this.metadata,this._eventLog)}async _updateStrategy(t){const e=await this._createStrategy();this._eventLog.onEvent({type:"updateStrategyStart",about:e.about});const s=!!this._strategy;this._store.clear(),this._strategy?.destroy(),this._strategy=e,(0,n.c)("geoscene-2d-update-debug")&&console.debug(`Version[${t}] FeatureSource.updateStrategy`,{strategy:e});const i=Array.from(this._subscriptions.values());if(!i.length)return void this._eventLog.onEvent({type:"updateStrategyEnd"});const r=Promise.all(i.map((t=>this._strategy.load(t).then((()=>this._eventLog.onEvent({type:"loaded",tile:t.tile.id}))).catch((e=>this._eventLog.onEvent({type:"error",tile:t.tile.id,error:e}))))));this._updateTracking.addPromise(r);try{s&&await r}catch(t){(0,a.Az)(t)}this._eventLog.onEvent({type:"updateStrategyEnd"}),(0,n.c)("geoscene-2d-update-debug")&&console.debug(`Version[${t}] FeatureSource.updateStrategyEnd`,{strategy:e})}async _supportSnapshotMode(t,e){const{queryMetadata:s}=t.service,i=s.snapshotInfo;if(!i||!i.supportsSnapshotMinThreshold||!i.snapshotCountThresholds)return null;const r=t.service.source,n=e.createQuery();n.inner.orderByFields=[],n.inner.returnGeometry=!1;const o=(await(0,Wu.WE)(r,n.inner,{query:n.customParameters})).data.count,{min:a,max:h}=i.snapshotCountThresholds;return o<=a||i.supportsSnapshotMaxThreshold&&o<h?{featureCount:o}:null}}var Ud=s(44980);class Gd{constructor(t,e){this._handles=new Ud.c,this._abortController=new AbortController,this._resolver=(0,a.qG)(),this._isDone=!1,this._aborted=!1,this.tile=t,this._version=e,this._handles.add([])}destroy(){this.pause(),this._handles.destroy()}get key(){return this.tile.key}get version(){return this._version}set version(t){this._version=t}get signal(){return this._abortController.signal}get options(){return{signal:this._abortController.signal}}get done(){return this._resolver.promise}get isDone(){return this._isDone}resolve(){this._isDone=!0,this._resolver.resolve()}get paused(){return this._aborted}resume(){this._abortController=new AbortController,this._aborted=!1}pause(){this._aborted||(this._aborted=!0,this._abortController.abort())}}var Vd=s(29624),qd=s(95247),Wd=s(87636);class Xd{constructor(t,e){this.key=new p.c(0,0,0,0),this.bounds=(0,L.Su)(),this.objectIds=new Set,this.key.set(e);const s=t.getLODInfoAt(this.key);this.tileInfoView=t,this.tileInfoView.getTileBounds(this.bounds,this.key,!0),this.resolution=s.resolution,this.scale=s.scale,this.level=s.level}get lod(){return this.tileInfoView.getLODInfoAt(this.key)}get id(){return this.key.id}get extent(){return qd.c.fromBounds(this.bounds,this.tileInfoView.tileInfo.spatialReference)}get transform(){return{originPosition:"upperLeft",scale:[this.resolution,this.resolution],translate:[this.bounds[0],this.bounds[3]]}}createArcadeEvaluationOptions(t){return{$view:{scale:this.scale,timeZone:t}}}createChildTiles(){const t=this.key.getChildKeys(),e=Vd.c.acquire();for(let s=0;s<t.length;s++)e[s]=new Xd(this.tileInfoView,t[s]);return e}getQuantizationParameters(){return Wd.c.fromJSON({mode:"view",originPosition:"upperLeft",tolerance:this.resolution,extent:{xmin:this.bounds[0],ymin:this.bounds[1],xmax:this.bounds[2],ymax:this.bounds[3],spatialReference:this.tileInfoView.tileInfo.spatialReference}})}}class Yd{constructor(t){this.edit=t,this.resolver=(0,a.qG)()}}class jd{constructor(t,e){this.schema=t,this.version=e,this.resolver=(0,a.qG)()}}class Hd{constructor(){this._aggregateAdapter={getFeatureObjectIds:t=>this._processor.getFeatureObjectIdsForAggregate(t)},this._subscriptions=new Map,this._updateRequested=!1,this._updateSubscriptionRequests=[],this._updateHighlightRequests=[]}destroy(){this._subscriptions.clear(),this._processor.destroy(),this._source.destroy(),this._handles.remove(),this._editState=null,this._tileInfoView=null}onDetach(){this.destroy(),this._initialize(this._connection)}_initialize(t){this._source=new Bd(this._aggregateAdapter,this._subscriptions,(()=>this._requestUpdate()),t),this._processor=new Vu(t,this._source),this._handles=(0,r.Ip)([(0,c.aE)((()=>this._source.updateTracking.updating),(()=>{this._requestUpdate(),this._connection.layerView.setUpdating({data:this._source.updateTracking.updating,pipeline:!0})}))])}set remoteClient(t){this._connection=new U(t),this._initialize(this._connection)}get features(){const t=this._source.queryEngine;if(!t)throw new i.c("no-queryEngine","No query engine defined");return t}get aggregates(){const t=this._processor.aggregateQueryEngine;if(!t)throw new i.c("no-queryEngine","No aggregate query engine defined");return t}get processor(){return this._processor}get streamMessenger(){return this._source.streamMessenger}getDisplayFeatures(t){return this._processor.getDisplayFeatures(t)}async updateSchema(t,e){return(0,n.c)("geoscene-2d-update-debug")&&this._updateSchemaState&&console.error("InternalError: Schema already updating"),this._updateSchemaState=new jd(t,e),this._requestUpdate(),this._updateSchemaState.resolver.promise}updateSubscriptions(t){this._updateSubscriptionRequests.push(t),this._requestUpdate()}updateHighlight(t){this._updateHighlightRequests.push(t),this._requestUpdate()}async onEdits(t){if(null!=this._editState)throw new i.c("InternalError - Already processing an edit");this._editState=new Yd(t);const e=this._editState.resolver.promise;return this._requestUpdate(),e}queryStatistics(){return this._source.statistics.toJSON()}async queryVisibleFeatures(t,e){return this.features.executeQuery(t,e)}async queryHeatmapStatistics(t){const e=Math.round((0,l.im)(t.radius));let s=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY;const r="string"==typeof t.fieldOffset,n=t.fieldOffset??0,o=Array.from(this._subscriptions.values()),a=this._source.chunks(),h=e**2,c=3/(Math.PI*h),u=2*e,d=Math.ceil(B.gT/u);for(const e of o){const o=e.tile,l=new Float64Array(d*d);for(const e of a){const s=e.getTileReader(o);if(!s)continue;const i=s.getCursor();for(;i.next();){let e=1;if(null!=t.field){const s=i.readAttribute(t.field);e=r?-1*+s:+s+n}const s=i.readXForDisplay()/u,o=i.readYForDisplay()/u,a=Math.floor(s),p=Math.floor(o);if(a<0||p<0||a>=d||p>=d)continue;const _=((.5+a-s)*u)**2+((.5+p-o)*u)**2;if(_>h)continue;const f=e*(c*(1-_/h)**2);l[p+a*d]+=f}}for(let t=0;t<l.length;t++)s=Math.min(s,l[t]),i=Math.max(i,l[t])}return{max:i,min:s}}async getSampleFeatures(t){const e=this._source.chunks();if(e.reduce(((t,e)=>t+e.size()),0)<=t.minFeatureCount){if(!this._source.updateTracking.updating){const t=[];return this._source.store.forEachUnsafe((e=>t.push(e.readLegacyFeatureWorldSpace()))),t}return null}const s=new Set,i=[],r=e.map((t=>t.reader.getCursor())),n=new h.c,o=3*t.sampleSize;for(let a=0;a<o&&i.length<t.sampleSize;a++){const t=r[n.getIntRange(0,e.length-1)];if(0===t.getSize())continue;const o=n.getIntRange(0,t.getSize()-1);t.setIndex(o);const a=t.getObjectId();s.has(a)||(s.add(a),i.push(t.readLegacyFeatureWorldSpace()))}return i.length>=t.sampleSize?i:null}_requestUpdate(){this._updateRequested||(this._updateRequested=!0,(0,o.o)((()=>this._scheduleNextUpdate())))}_scheduleNextUpdate(){this._updateRequested&&(this._ongoingUpdate||(this._ongoingUpdate=this._doUpdate().finally((()=>{this._ongoingUpdate=null,this._scheduleNextUpdate()})),this._updateRequested=!1))}_subscribe(t){const e=t.tileId;if(this._subscriptions.has(e)){const s=this._subscriptions.get(e);return void(s.paused&&((0,n.c)("geoscene-2d-update-debug")&&console.debug(`Tile[${e}] Pipeline.resume`),s.resume(),s.version=t.version,this._source.onResume(s)))}(0,n.c)("geoscene-2d-update-debug")&&console.debug(`Tile[${e}] Pipeline.subscribe`);const s=new Xd(this._tileInfoView,e),i=new Gd(s,t.version);this._subscriptions.set(e,i),this._source.onSubscribe(i),this._processor.onSubscribe(i)}_unsubscribe(t){const e=this._subscriptions.get(t);e&&((0,n.c)("geoscene-2d-update-debug")&&console.debug(`Tile[${t}] Pipeline.unsubscribe`),this._source.onUnsubscribe(e),this._processor.onUnsubscribe(e),this._subscriptions.delete(e.key.id),e.destroy())}_pauseSubscription(t){const e=this._subscriptions.get(t);e&&((0,n.c)("geoscene-2d-update-debug")&&console.debug(`Tile[${t}] Pipeline.pause`),e.pause())}async _doUpdate(){if((0,n.c)("geoscene-2d-update-debug")&&console.debug("Pipeline._doUpdateStart"),await this._connection.layerView.setUpdating({data:this._source.updateTracking.updating,pipeline:!0}),this._updateSubscriptionRequests.length){const t=this._updateSubscriptionRequests;this._updateSubscriptionRequests=[];for(const e of t)this._doUpdateSubscriptions(e)}const t=this._updateSchemaState;if(this._updateSchemaState=null,null!=t){const{schema:e,version:s}=t;await this._doUpdateSchema(e,s)}const e=this._editState;if(this._editState=null,null!=e){(0,n.c)("geoscene-2d-update-debug")&&console.debug("Pipeline.applyEditOverride",e.edit);const t=await this._source.getOverride(e.edit);await this._processor.applyOverride(t),(0,n.c)("geoscene-2d-update-debug")&&console.debug("Pipeline.endEditOverride",e.edit)}if(this._updateHighlightRequests.length){const t=this._updateHighlightRequests;this._updateHighlightRequests=[];for(const e of t)this._processor.updateHighlight(e)}const s=this._source.cleanupRemovedChunks();this._processor.removeChunks(s);try{this._subscriptions.size&&((0,n.c)("geoscene-2d-update-debug")&&console.debug("Pipeline.updateChunksStart"),await this._processor.updateChunks(),(0,n.c)("geoscene-2d-update-debug")&&console.debug("Pipeline.updateChunksEnd"))}catch(t){(0,a.Az)(t)}null!=e&&e.resolver.resolve(),null!=t&&t.resolver.resolve(),this._updateRequested?((0,n.c)("geoscene-2d-update-debug")&&console.debug("Pipeline._doUpdateEnd [updateRequested=true]"),await this._connection.layerView.setUpdating({data:this._source.updateTracking.updating,pipeline:!0})):((0,n.c)("geoscene-2d-update-debug")&&console.debug("Pipeline._doUpdateEnd [updateRequested=false, After flush]"),await this._connection.layerView.setUpdating({data:this._source.updateTracking.updating,pipeline:this._updateRequested}))}async _doUpdateSchema(t,e){if((0,n.c)("geoscene-2d-update-debug")&&console.debug(`Version[${e}] Pipeline.updateStart`,{schema:t}),!this._tileInfoView){const e=u.c.fromJSON(t.source.tileInfoJSON);this._tileInfoView=new I(e)}const s={tileInfo:this._tileInfoView?.tileInfo};try{const i=await this._source.update(t,e),r=Array.from(this._subscriptions.values());await this._processor.update(t,e,s,i,r)}catch(t){console.error(t)}(0,n.c)("geoscene-2d-update-debug")&&console.debug(`Version[${e}] Pipeline.updateEnd`)}_doUpdateSubscriptions(t){if((0,n.c)("geoscene-2d-update-debug")&&console.debug("Pipeline.updateSubscriptions",t),!this._tileInfoView){const e=u.c.fromJSON(t.tileInfoJSON);this._tileInfoView=new I(e)}for(const e of t.subscribe)this._subscribe(e);for(const e of t.unsubscribe)this._unsubscribe(e);if((0,n.c)("featurelayer-query-pausing-enabled"))for(const e of t.pause)this._pauseSubscription(e)}}},53680:(t,e,s)=>{s.d(e,{c:()=>r});var i=s(69752);class r{static getId(t,e,s,i){return"object"==typeof t?`${t.level}/${t.row}/${t.col}/${t.world}`:`${t}/${e}/${s}/${i}`}constructor(t,e,s,i){this.set(t,e,s,i)}get key(){return this}get id(){return this.toString()}get normalizedId(){return`${this.level}/${this.row}/${this.col}`}set id(t){this.set(t)}get hash(){const t=4095&this.row,e=4095&this.col,s=63&this.level;return(3&this.world)<<30|e<<22|t<<8|s}acquire(t,e,s,i){this.set(t,e,s,i)}contains(t){const e=t.level-this.level;return e>=0&&this.row===t.row>>e&&this.col===t.col>>e&&this.world===t.world}containsChild(t){const e=t.level-this.level;return e>0&&this.row===t.row>>e&&this.col===t.col>>e&&this.world===t.world}equals(t){return this.level===t.level&&this.row===t.row&&this.col===t.col&&this.world===t.world}clone(){return new r(this)}release(){this.level=0,this.row=0,this.col=0,this.world=0}set(t,e,s,i){if(null==t)this.level=0,this.row=0,this.col=0,this.world=0;else if("object"==typeof t)this.level=t.level||0,this.row=t.row||0,this.col=t.col||0,this.world=t.world||0;else if("string"==typeof t){const[e,s,i,r]=t.split("/");this.level=parseFloat(e),this.row=parseFloat(s),this.col=parseFloat(i),this.world=parseFloat(r)}else this.level=+t,this.row=+e,this.col=+s,this.world=+i||0;return this}toString(){return`${this.level}/${this.row}/${this.col}/${this.world}`}getParentKey(){return this.level<=0?null:new r(this.level-1,this.row>>1,this.col>>1,this.world)}getNeighborId(t,e){return`${this.level}/${this.row+e}/${this.col+t}/${this.world}`}getChildKeys(){const t=this.level+1,e=this.row<<1,s=this.col<<1,i=this.world;return[new r(t,e,s,i),new r(t,e,s+1,i),new r(t,e+1,s,i),new r(t,e+1,s+1,i)]}compareRowMajor(t){return this.row<t.row?-1:this.row>t.row?1:this.col<t.col?-1:this.col>t.col?1:0}}r.pool=new i.c(r,null,null,25,50)},75040:(t,e,s)=>{var i;s.d(e,{u:()=>i}),function(t){t[t.Pass=0]="Pass",t[t.Draw=1]="Draw"}(i||(i={}))},90736:(t,e,s)=>{s.d(e,{If:()=>n,Uc:()=>r}),s(85256),s(74784),(0,s(37008).Su)();class i{constructor(t){this.message=t}toString(){return`AssertException: ${this.message}`}}function r(t,e){if(!t){e=e||"Assertion";const t=new Error(e).stack;throw new i(`${e} at ${t}`)}}function n(t,e,s,i){let r,n=(s[0]-t[0])/e[0],o=(i[0]-t[0])/e[0];n>o&&(r=n,n=o,o=r);let a=(s[1]-t[1])/e[1],h=(i[1]-t[1])/e[1];if(a>h&&(r=a,a=h,h=r),n>h||a>o)return!1;a>n&&(n=a),h<o&&(o=h);let c=(s[2]-t[2])/e[2],l=(i[2]-t[2])/e[2];return c>l&&(r=c,c=l,l=r),!(n>l||c>o||(l<o&&(o=l),o<0))}},27064:(t,e,s)=>{s.d(e,{K:()=>l});var i=s(70680),r=s(10860),n=s(54792),o=s(23964),a=s(66168),h=s(52888);class c{constructor(t,e){this.item=t,this.controller=e,this.promise=null}}class l{constructor(t){this._schedule=null,this._task=null,this._deferreds=new o.c,this._controllers=new o.c,this._processingItems=new o.c,this._pausedSignal=(0,h.O)(!1),this.concurrency=1,t.concurrency&&(this.concurrency=t.concurrency),this._queue=new n.c(t.peeker),this.process=t.process;const e=t.scheduler;t.priority&&e&&(this._task=e.registerTask(t.priority,this))}destroy(){this.clear(),this._schedule=(0,i.oR)(this._schedule),this._task=(0,i.oR)(this._task)}get updating(){return!!this._task?.updating||this.running}get length(){return this._processingItems.size+this._queue.length}abort(t){const e=this._controllers.get(t);e&&e.abort()}clear(){this._queue.clear();const t=[];this._controllers.forEach((e=>t.push(e))),this._controllers.clear(),t.forEach((t=>t.abort())),this._processingItems.clear(),this._cancelNext()}forEach(t){this._deferreds.forEach(((e,s)=>t(s)))}get(t){const e=this._deferreds.get(t);return e?e.promise:void 0}isOngoing(t){return this._processingItems.has(t)}has(t){return this._deferreds.has(t)}pause(){this._pausedSignal.value||(this._pausedSignal.value=!0,this._cancelNext())}push(t,e){const s=this.get(t);if(s)return s;const i=new AbortController;let n=null;e&&(n=(0,r.wD)(e,(()=>i.abort())));const o=()=>{a.remove(),null!=n&&n.remove(),this._removeItem(t),this._queue.remove(t),this._scheduleNext()},a=(0,r.Ij)(i.signal,(()=>{const e=this._processingItems.get(t);e&&e.controller.abort(),o(),h.reject((0,r.Uh)())})),h=(0,r.qG)();return this._deferreds.set(t,h),this._controllers.set(t,i),h.promise.then(o,o),this._queue.push(t),this._scheduleNext(),h.promise}last(){return this._queue.last()}lastPromise(){const t=this.last();return t?this.get(t):null}peek(){return this._queue.peek()}popLast(){const t=this._queue.popLast();return t&&(this._deferreds.get(t)?.reject((0,r.Uh)("Removed from queue")),this._removeItem(t)),t}reset(){const t=[];this._processingItems.forEach((e=>t.push(e))),this._processingItems.clear();for(const e of t)this._queue.push(e.item),e.controller.abort();this._scheduleNext()}resume(){this._pausedSignal.value&&(this._pausedSignal.value=!1,this._scheduleNext())}takeAll(){const t=[];for(;this._queue.length;)t.push(this._queue.pop());return this.clear(),t}get running(){return!this._pausedSignal.value&&this._queue.length>0&&this._processingItems.size<this.concurrency}runTask(t){for(;!t.done&&this._queue.length>0&&this._processingItems.size<this.concurrency;)this._process(this._queue.pop()),t.madeProgress()}_removeItem(t){this._deferreds.delete(t),this._controllers.delete(t),this._processingItems.delete(t)}_scheduleNext(){this._task||this._pausedSignal.value||this._schedule||(this._schedule=(0,a.Ow)((()=>{this._schedule=null,this._next()})))}_next(){for(;this._queue.length>0&&this._processingItems.size<this.concurrency;)this._process(this._queue.pop())}_cancelNext(){this._schedule&&(this._schedule.remove(),this._schedule=null)}_processResult(t,e){this._canProcessFulfillment(t)&&(this._scheduleNext(),this._deferreds.get(t.item).resolve(e))}_processError(t,e){this._canProcessFulfillment(t)&&(this._scheduleNext(),this._deferreds.get(t.item).reject(e))}_canProcessFulfillment(t){return!!this._deferreds.get(t.item)&&this._processingItems.get(t.item)===t}_process(t){if(null==t)return;let e;const s=new AbortController,i=new c(t,s);this._processingItems.set(t,i);try{e=this.process(t,s.signal)}catch(t){this._processError(i,t)}(0,r.eW)(e)?(i.promise=e,e.then((t=>this._processResult(i,t)),(t=>this._processError(i,t)))):this._processResult(i,e)}get test(){return{update:t=>this.runTask(t)}}}},39104:(t,e,s)=>{var i;s.d(e,{A:()=>i}),function(t){t[t.Texture=0]="Texture",t[t.RenderBuffer=1]="RenderBuffer"}(i||(i={}))},22184:(t,e,s)=>{s.d(e,{w:()=>c});var i=s(20744),r=(s(9456),s(94460)),n=s(77800),o=s(39104),a=s(51576);class h extends a.O{constructor(t,e){switch(super(),this.context=t,Object.assign(this,e),this.internalFormat){case n.UV.R16F:case n.UV.R16I:case n.UV.R16UI:case n.UV.R32F:case n.UV.R32I:case n.UV.R32UI:case n.UV.R8_SNORM:case n.UV.R8:case n.UV.R8I:case n.UV.R8UI:this.pixelFormat=n.Id.RED}}static validate(t,e){return new h(t,e)}}let c=class t{constructor(t,e=null,s=null){if(this.type=o.A.Texture,this._glName=null,this._samplingModeDirty=!1,this._wrapModeDirty=!1,this._wasImmutablyAllocated=!1,"context"in t)this._descriptor=t,s=e;else{const s=h.validate(t,e);if(!s)throw new i.c("Texture descriptor invalid");this._descriptor=s}this._descriptor.target===n.c5.TEXTURE_CUBE_MAP?this._setDataCubeMap(s):this.setData(s)}get glName(){return this._glName}get descriptor(){return this._descriptor}get usedMemory(){return(0,a.k)(this._descriptor)}get isDirty(){return this._samplingModeDirty||this._wrapModeDirty}dispose(){this._glName&&this._descriptor.context.instanceCounter.decrement(n.y4.Texture,this),this._descriptor.context.gl&&this._glName&&(this._descriptor.context.unbindTexture(this),this._descriptor.context.gl.deleteTexture(this._glName),this._glName=null)}release(){this.dispose()}resize(t,e){const s=this._descriptor;if(s.width!==t||s.height!==e){if(this._wasImmutablyAllocated)throw new i.c("Immutable textures can't be resized!");s.width=t,s.height=e,this._descriptor.target===n.c5.TEXTURE_CUBE_MAP?this._setDataCubeMap(null):this.setData(null)}}_setDataCubeMap(t=null){for(let e=n.c5.TEXTURE_CUBE_MAP_POSITIVE_X;e<=n.c5.TEXTURE_CUBE_MAP_NEGATIVE_Z;e++)this._setData(t,e)}setData(t){this._setData(t)}_setData(e,s){if(!this._descriptor.context?.gl)return;const o=this._descriptor.context.gl;(0,r.m_)(o),this._glName||(this._glName=o.createTexture(),this._glName&&this._descriptor.context.instanceCounter.increment(n.y4.Texture,this)),void 0===e&&(e=null);const a=this._descriptor,h=s??a.target,c=f(h);null===e&&(a.width=a.width||4,a.height=a.height||4,c&&(a.depth=a.depth??1));const g=this._descriptor.context.bindTexture(this,t.TEXTURE_UNIT_FOR_UPDATES);this._descriptor.context.setActiveTexture(t.TEXTURE_UNIT_FOR_UPDATES),l(a),this._configurePixelStorage(),(0,r.m_)(o);const y=this._deriveInternalFormat();if(_(e)){let t="width"in e?e.width:e.codedWidth,s="height"in e?e.height:e.codedHeight;const i=1;e instanceof HTMLVideoElement&&(t=e.videoWidth,s=e.videoHeight),a.width&&a.height,c&&a.depth,a.isImmutable&&!this._wasImmutablyAllocated&&this._texStorage(h,y,a.hasMipmap,t,s,i),this._texImage(h,0,y,t,s,i,e),(0,r.m_)(o),a.hasMipmap&&this.generateMipmap(),a.width||(a.width=t),a.height||(a.height=s),c&&!a.depth&&(a.depth=i)}else{const{width:t,height:s,depth:l}=a;if(null==t||null==s)throw new i.c("Width and height must be specified!");if(c&&null==l)throw new i.c("Depth must be specified!");if(a.isImmutable&&!this._wasImmutablyAllocated&&this._texStorage(h,y,a.hasMipmap,t,s,l),p(e)){const r=e.levels,c=m(h,t,s,l),u=Math.min(c-1,r.length-1);o.texParameteri(a.target,this._descriptor.context.gl.TEXTURE_MAX_LEVEL,u);const d=y;if(!(d in n.sr))throw new i.c("Attempting to use compressed data with an uncompressed format!");this._forEachMipmapLevel(((t,e,s,i)=>{const n=r[Math.min(t,r.length-1)];this._compressedTexImage(h,t,d,e,s,i,n)}),u)}else this._texImage(h,0,y,t,s,l,e),(0,r.m_)(o),a.hasMipmap&&this.generateMipmap()}u(o,this._descriptor),d(o,this._descriptor),function(t,e){const s=t.capabilities.textureFilterAnisotropic;s&&t.gl.texParameterf(e.target,s.TEXTURE_MAX_ANISOTROPY,e.maxAnisotropy??1)}(this._descriptor.context,this._descriptor),(0,r.m_)(o),this._descriptor.context.bindTexture(g,t.TEXTURE_UNIT_FOR_UPDATES)}updateData(e,s,r,n,o,a,h=0){a||console.error("An attempt to use uninitialized data!"),this._glName||console.error("An attempt to update uninitialized texture!");const c=this._descriptor,l=this._deriveInternalFormat(),{context:u,pixelFormat:d,dataType:f,target:m,isImmutable:g}=c;if(g&&!this._wasImmutablyAllocated)throw new i.c("Cannot update immutable texture before allocation!");const y=u.bindTexture(this,t.TEXTURE_UNIT_FOR_UPDATES,!0);(s<0||r<0||n>c.width||o>c.height||s+n>c.width||r+o>c.height)&&console.error("An attempt to update out of bounds of the texture!"),this._configurePixelStorage();const{gl:x}=u;h&&x.pixelStorei(x.UNPACK_SKIP_ROWS,h),_(a)?x.texSubImage2D(m,e,s,r,n,o,d,f,a):p(a)?x.compressedTexSubImage2D(m,e,s,r,n,o,l,a.levels[e]):x.texSubImage2D(m,e,s,r,n,o,d,f,a),h&&x.pixelStorei(x.UNPACK_SKIP_ROWS,0),u.bindTexture(y,t.TEXTURE_UNIT_FOR_UPDATES)}updateData3D(e,s,r,n,o,a,h,c){c||console.error("An attempt to use uninitialized data!"),this._glName||console.error("An attempt to update uninitialized texture!");const l=this._descriptor,u=this._deriveInternalFormat(),{context:d,pixelFormat:_,dataType:m,isImmutable:g,target:y}=l;if(g&&!this._wasImmutablyAllocated)throw new i.c("Cannot update immutable texture before allocation!");f(y)||console.warn("Attempting to set 3D texture data on a non-3D texture");const x=d.bindTexture(this,t.TEXTURE_UNIT_FOR_UPDATES);d.setActiveTexture(t.TEXTURE_UNIT_FOR_UPDATES),(s<0||r<0||n<0||o>l.width||a>l.height||h>l.depth||s+o>l.width||r+a>l.height||n+h>l.depth)&&console.error("An attempt to update out of bounds of the texture!"),this._configurePixelStorage();const{gl:b}=d;if(p(c))c=c.levels[e],b.compressedTexSubImage3D(y,e,s,r,n,o,a,h,u,c);else{const t=c;b.texSubImage3D(y,e,s,r,n,o,a,h,_,m,t)}d.bindTexture(x,t.TEXTURE_UNIT_FOR_UPDATES)}generateMipmap(){const e=this._descriptor;if(!e.hasMipmap){if(this._wasImmutablyAllocated)throw new i.c("Cannot add mipmaps to immutable texture after allocation");e.hasMipmap=!0,this._samplingModeDirty=!0,l(e)}e.samplingMode===n.Ud.LINEAR?(this._samplingModeDirty=!0,e.samplingMode=n.Ud.LINEAR_MIPMAP_NEAREST):e.samplingMode===n.Ud.NEAREST&&(this._samplingModeDirty=!0,e.samplingMode=n.Ud.NEAREST_MIPMAP_NEAREST);const s=this._descriptor.context.bindTexture(this,t.TEXTURE_UNIT_FOR_UPDATES);this._descriptor.context.setActiveTexture(t.TEXTURE_UNIT_FOR_UPDATES),this._descriptor.context.gl.generateMipmap(e.target),this._descriptor.context.bindTexture(s,t.TEXTURE_UNIT_FOR_UPDATES)}setSamplingMode(t){t!==this._descriptor.samplingMode&&(this._descriptor.samplingMode=t,this._samplingModeDirty=!0)}setWrapMode(t){t!==this._descriptor.wrapMode&&(this._descriptor.wrapMode=t,l(this._descriptor),this._wrapModeDirty=!0)}applyChanges(){const t=this._descriptor,e=t.context.gl;this._samplingModeDirty&&(u(e,t),this._samplingModeDirty=!1),this._wrapModeDirty&&(d(e,t),this._wrapModeDirty=!1)}_deriveInternalFormat(){if(null!=this._descriptor.internalFormat)return this._descriptor.internalFormat===n.Id.DEPTH_STENCIL&&(this._descriptor.internalFormat=n.Id.DEPTH24_STENCIL8),this._descriptor.internalFormat;switch(this._descriptor.dataType){case n.OK.FLOAT:switch(this._descriptor.pixelFormat){case n.Id.RGBA:return this._descriptor.internalFormat=n.UV.RGBA32F;case n.Id.RGB:return this._descriptor.internalFormat=n.UV.RGB32F;default:throw new i.c("Unable to derive format")}case n.OK.UNSIGNED_BYTE:switch(this._descriptor.pixelFormat){case n.Id.RGBA:return this._descriptor.internalFormat=n.UV.RGBA8;case n.Id.RGB:return this._descriptor.internalFormat=n.UV.RGB8}}return this._descriptor.internalFormat=this._descriptor.pixelFormat===n.Id.DEPTH_STENCIL?n.Id.DEPTH24_STENCIL8:this._descriptor.pixelFormat}_configurePixelStorage(){const t=this._descriptor.context.gl,{unpackAlignment:e,flipped:s,preMultiplyAlpha:i}=this._descriptor;t.pixelStorei(t.UNPACK_ALIGNMENT,e),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,s?1:0),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,i?1:0)}_texStorage(t,e,s,r,o,a){const{gl:h}=this._descriptor.context;if(!(e in n.UV))throw new i.c("Immutable textures must have a sized internal format");if(!this._descriptor.isImmutable)return;const c=s?m(t,r,o,a):1;if(f(t)){if(null==a)throw new i.c("Missing depth dimension for 3D texture upload");h.texStorage3D(t,c,e,r,o,a)}else h.texStorage2D(t,c,e,r,o);this._wasImmutablyAllocated=!0}_texImage(t,e,s,r,n,o,a){const h=this._descriptor.context.gl,c=f(t),{isImmutable:l,pixelFormat:u,dataType:d}=this._descriptor;if(l){if(null!=a){const s=a;if(c){if(null==o)throw new i.c("Missing depth dimension for 3D texture upload");h.texSubImage3D(t,e,0,0,0,r,n,o,u,d,s)}else h.texSubImage2D(t,e,0,0,r,n,u,d,s)}}else{const l=a;if(c){if(null==o)throw new i.c("Missing depth dimension for 3D texture upload");h.texImage3D(t,e,s,r,n,o,0,u,d,l)}else h.texImage2D(t,e,s,r,n,0,u,d,l)}}_compressedTexImage(t,e,s,r,n,o,a){const h=this._descriptor.context.gl,c=f(t);if(this._descriptor.isImmutable){if(null!=a)if(c){if(null==o)throw new i.c("Missing depth dimension for 3D texture upload");h.compressedTexSubImage3D(t,e,0,0,0,r,n,o,s,a)}else h.compressedTexSubImage2D(t,e,0,0,r,n,s,a)}else if(c){if(null==o)throw new i.c("Missing depth dimension for 3D texture upload");h.compressedTexImage3D(t,e,s,r,n,o,0,a)}else h.compressedTexImage2D(t,e,s,r,n,0,a)}_forEachMipmapLevel(t,e=1/0){let{width:s,height:r,depth:o,hasMipmap:a,target:h}=this._descriptor;const c=h===n.c5.TEXTURE_3D;if(null==s||null==r||c&&null==o)throw new i.c("Missing texture dimensions for mipmap calculation");for(let i=0;t(i,s,r,o),a&&(1!==s||1!==r||c&&1!==o)&&!(i>=e);++i)s=Math.max(1,s>>1),r=Math.max(1,r>>1),c&&(o=Math.max(1,o>>1))}};function l(t){(null!=t.width&&t.width<0||null!=t.height&&t.height<0||null!=t.depth&&t.depth<0)&&console.error("Negative dimension parameters are not allowed!")}function u(t,e){let s=e.samplingMode,i=e.samplingMode;s===n.Ud.LINEAR_MIPMAP_NEAREST||s===n.Ud.LINEAR_MIPMAP_LINEAR?(s=n.Ud.LINEAR,e.hasMipmap||(i=n.Ud.LINEAR)):s!==n.Ud.NEAREST_MIPMAP_NEAREST&&s!==n.Ud.NEAREST_MIPMAP_LINEAR||(s=n.Ud.NEAREST,e.hasMipmap||(i=n.Ud.NEAREST)),t.texParameteri(e.target,t.TEXTURE_MAG_FILTER,s),t.texParameteri(e.target,t.TEXTURE_MIN_FILTER,i)}function d(t,e){"number"==typeof e.wrapMode?(t.texParameteri(e.target,t.TEXTURE_WRAP_S,e.wrapMode),t.texParameteri(e.target,t.TEXTURE_WRAP_T,e.wrapMode)):(t.texParameteri(e.target,t.TEXTURE_WRAP_S,e.wrapMode.s),t.texParameteri(e.target,t.TEXTURE_WRAP_T,e.wrapMode.t))}function p(t){return null!=t&&"type"in t&&"compressed"===t.type}function _(t){return null!=t&&!p(t)&&!function(t){return null!=t&&"byteLength"in t}(t)}function f(t){return t===n.c5.TEXTURE_3D||t===n.c5.TEXTURE_2D_ARRAY}function m(t,e,s,i=1){let r=Math.max(e,s);return t===n.c5.TEXTURE_3D&&(r=Math.max(r,i)),Math.round(Math.log(r)/Math.LN2)+1}c.TEXTURE_UNIT_FOR_UPDATES=0},51576:(t,e,s)=>{s.d(e,{O:()=>n,k:()=>o});var i=s(77800),r=s(97684);class n{constructor(t=0,e=t){this.width=t,this.height=e,this.target=i.c5.TEXTURE_2D,this.pixelFormat=i.Id.RGBA,this.dataType=i.OK.UNSIGNED_BYTE,this.samplingMode=i.Ud.LINEAR,this.wrapMode=i.Qz.REPEAT,this.maxAnisotropy=1,this.flipped=!1,this.hasMipmap=!1,this.isOpaque=!1,this.unpackAlignment=4,this.preMultiplyAlpha=!1,this.depth=1,this.isImmutable=!1}}function o(t){return t.width<=0||t.height<=0?0:Math.round(t.width*t.height*(t.hasMipmap?4/3:1)*(null==t.internalFormat?4:(0,r.O4)(t.internalFormat)))}},97684:(t,e,s)=>{s.d(e,{O4:()=>r}),s(9456),s(94460);var i=s(77800);function r(t){switch(t){case i.Id.ALPHA:case i.Id.LUMINANCE:case i.Id.RED:case i.Id.RED_INTEGER:case i.UV.R8:case i.UV.R8I:case i.UV.R8UI:case i.UV.R8_SNORM:case i.Qb.STENCIL_INDEX8:return 1;case i.Id.LUMINANCE_ALPHA:case i.Id.RG:case i.Id.RG_INTEGER:case i.UV.RGBA4:case i.UV.R16F:case i.UV.R16I:case i.UV.R16UI:case i.UV.RG8:case i.UV.RG8I:case i.UV.RG8UI:case i.UV.RG8_SNORM:case i.UV.RGB565:case i.UV.RGB5_A1:case i.Qb.DEPTH_COMPONENT16:return 2;case i.Id.DEPTH_COMPONENT:case i.Id.RGB:case i.Id.RGB_INTEGER:case i.UV.RGB8:case i.UV.RGB8I:case i.UV.RGB8UI:case i.UV.RGB8_SNORM:case i.UV.SRGB8:case i.Qb.DEPTH_COMPONENT24:return 3;case i.Id.DEPTH_STENCIL:case i.Id.DEPTH24_STENCIL8:case i.Id.RGBA:case i.Id.RGBA_INTEGER:case i.UV.RGBA8:case i.UV.R32F:case i.UV.R11F_G11F_B10F:case i.UV.RG16F:case i.UV.R32I:case i.UV.R32UI:case i.UV.RG16I:case i.UV.RG16UI:case i.UV.RGBA8I:case i.UV.RGBA8UI:case i.UV.RGBA8_SNORM:case i.UV.SRGB8_ALPHA8:case i.UV.RGB9_E5:case i.UV.RGB10_A2UI:case i.UV.RGB10_A2:case i.Qb.DEPTH_STENCIL:case i.Qb.DEPTH_COMPONENT32F:case i.Qb.DEPTH24_STENCIL8:return 4;case i.Qb.DEPTH32F_STENCIL8:return 5;case i.UV.RGB16F:case i.UV.RGB16I:case i.UV.RGB16UI:return 6;case i.UV.RG32F:case i.UV.RG32I:case i.UV.RG32UI:case i.UV.RGBA16F:case i.UV.RGBA16I:case i.UV.RGBA16UI:return 8;case i.UV.RGB32F:case i.UV.RGB32I:case i.UV.RGB32UI:return 12;case i.UV.RGBA32F:case i.UV.RGBA32I:case i.UV.RGBA32UI:return 16;case i.sr.COMPRESSED_RGB_S3TC_DXT1_EXT:case i.sr.COMPRESSED_RGBA_S3TC_DXT1_EXT:return.5;case i.sr.COMPRESSED_RGBA_S3TC_DXT3_EXT:case i.sr.COMPRESSED_RGBA_S3TC_DXT5_EXT:return 1;case i.sr.COMPRESSED_R11_EAC:case i.sr.COMPRESSED_SIGNED_R11_EAC:case i.sr.COMPRESSED_RGB8_ETC2:case i.sr.COMPRESSED_SRGB8_ETC2:case i.sr.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:case i.sr.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:return.5;case i.sr.COMPRESSED_RG11_EAC:case i.sr.COMPRESSED_SIGNED_RG11_EAC:case i.sr.COMPRESSED_RGBA8_ETC2_EAC:case i.sr.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:return 1}return 0}s(2944)},94460:(t,e,s)=>{s.d(e,{E5:()=>c,gv:()=>h,m_:()=>l});var i=s(20744),r=s(9456),n=s(66360);const o=()=>n.c.getLogger("geoscene.views.webgl.checkWebGLError"),a=!!(0,r.c)("enable-feature:webgl-debug");function h(){return a}function c(){return a}function l(t){if(h()){const e=t.getError();if(e){const s=function(t,e){switch(e){case t.INVALID_ENUM:return"Invalid Enum. An unacceptable value has been specified for an enumerated argument.";case t.INVALID_VALUE:return"Invalid Value. A numeric argument is out of range.";case t.INVALID_OPERATION:return"Invalid Operation. The specified command is not allowed for the current state.";case t.INVALID_FRAMEBUFFER_OPERATION:return"Invalid Framebuffer operation. The currently bound framebuffer is not framebuffer complete when trying to render to or to read from it.";case t.OUT_OF_MEMORY:return"Out of memory. Not enough memory is left to execute the command.";case t.CONTEXT_LOST_WEBGL:return"WebGL context has been lost";default:return"Unknown error"}}(t,e),r=(new Error).stack;o().error(new i.c("webgl-error","WebGL error occurred",{message:s,stack:r}))}}}},2944:(t,e,s)=>{s(77800)}}]);
|
|
1
|
+
"use strict";(self.webpackChunkRemoteClient=self.webpackChunkRemoteClient||[]).push([[872],{54792:(t,e,s)=>{s.d(e,{c:()=>n});var i=s(67432),r=s(9592);class n{constructor(t=(t=>t.values().next().value)){this._peeker=t,this._observable=new r.n,this._items=new Set}get length(){return(0,i.am)(this._observable),this._items.size}clear(){0!==this.length&&(this._items.clear(),this._observable.notify())}last(){if(0===this.length)return;let t;for(t of this._items);return t}peek(){if(0!==this.length)return this._peeker(this._items)}push(t){this.contains(t)||(this._items.add(t),this._observable.notify())}contains(t){return(0,i.am)(this._observable),this._items.has(t)}pop(){if(0===this.length)return;const t=this.peek();return this._items.delete(t),this._observable.notify(),t}popLast(){if(0===this.length)return;const t=this.last();return this._items.delete(t),this._observable.notify(),t}remove(t){this.contains(t)&&(this._items.delete(t),this._observable.notify())}filter(t){const e=this.length;return this._items.forEach((e=>{t(e)||this._items.delete(e)})),e!==this._items.size&&this._observable.notify(),this}*[Symbol.iterator](){(0,i.am)(this._observable),yield*this._items}}},23964:(t,e,s)=>{s.d(e,{c:()=>n});var i=s(67432),r=s(9592);class n{constructor(t){this._observable=new r.n,this._map=new Map(t)}get size(){return(0,i.am)(this._observable),this._map.size}clear(){this._map.size>0&&(this._map.clear(),this._observable.notify())}delete(t){const e=this._map.delete(t);return e&&this._observable.notify(),e}entries(){return(0,i.am)(this._observable),this._map.entries()}forEach(t,e){(0,i.am)(this._observable),this._map.forEach(((s,i)=>t.call(e,s,i,this)),e)}get(t){return(0,i.am)(this._observable),this._map.get(t)}has(t){return(0,i.am)(this._observable),this._map.has(t)}keys(){return(0,i.am)(this._observable),this._map.keys()}set(t,e){return this._map.set(t,e),this._observable.notify(),this}values(){return(0,i.am)(this._observable),this._map.values()}[Symbol.iterator](){return(0,i.am)(this._observable),this._map[Symbol.iterator]()}get[Symbol.toStringTag](){return this._map[Symbol.toStringTag]}}},38600:(t,e,s)=>{function i(){return new Float32Array(2)}function r(t,e){const s=new Float32Array(2);return s[0]=t,s[1]=e,s}function n(){return i()}function o(){return r(1,1)}function a(){return r(1,0)}function h(){return r(0,1)}s.d(e,{Qw:()=>l,Su:()=>i,WK:()=>r,cX:()=>c});const c=n(),l=o(),u=a(),d=h();Object.freeze(Object.defineProperty({__proto__:null,ONES:l,UNIT_X:u,UNIT_Y:d,ZEROS:c,clone:function(t){const e=new Float32Array(2);return e[0]=t[0],e[1]=t[1],e},create:i,createView:function(t,e){return new Float32Array(t,e,2)},fromValues:r,ones:o,unitX:a,unitY:h,zeros:n},Symbol.toStringTag,{value:"Module"}))},85256:(t,e,s)=>{function i(){return[0,0]}function r(t,e){return[t,e]}function n(){return r(1,1)}function o(){return r(1,0)}function a(){return r(0,1)}s.d(e,{Qw:()=>h,Su:()=>i,WK:()=>r});const h=n(),c=o(),l=a();Object.freeze(Object.defineProperty({__proto__:null,ONES:h,UNIT_X:c,UNIT_Y:l,ZEROS:[0,0],clone:function(t){return[t[0],t[1]]},create:i,createView:function(t,e){return new Float64Array(t,e,2)},fromArray:function(t,e=[0,0]){const s=Math.min(2,t.length);for(let i=0;i<s;++i)e[i]=t[i];return e},fromValues:r,ones:n,unitX:o,unitY:a,zeros:function(){return[0,0]}},Symbol.toStringTag,{value:"Module"}))},37648:(t,e,s)=>{s.d(e,{Cq:()=>d,WO:()=>r,c9:()=>_,m4:()=>p,qy:()=>h});var i=s(47364);function r(t,e,s){return t[0]=e,t[1]=s,t}function n(t,e,s){return t[0]=e[0]-s[0],t[1]=e[1]-s[1],t}function o(t,e,s){return t[0]=e[0]*s[0],t[1]=e[1]*s[1],t}function a(t,e,s){return t[0]=e[0]/s[0],t[1]=e[1]/s[1],t}function h(t,e){const s=e[0]-t[0],i=e[1]-t[1];return Math.sqrt(s*s+i*i)}function c(t,e){const s=e[0]-t[0],i=e[1]-t[1];return s*s+i*i}function l(t){const e=t[0],s=t[1];return Math.sqrt(e*e+s*s)}function u(t){const e=t[0],s=t[1];return e*e+s*s}function d(t,e,s,i){const r=e[0],n=e[1];return t[0]=r+i*(s[0]-r),t[1]=n+i*(s[1]-n),t}function p(t,e,s){const i=e[0],r=e[1];return t[0]=s[0]*i+s[2]*r+s[4],t[1]=s[1]*i+s[3]*r+s[5],t}function _(t,e,s,i){const r=e[0]-s[0],n=e[1]-s[1],o=Math.sin(i),a=Math.cos(i);return t[0]=r*a-n*o+s[0],t[1]=r*o+n*a+s[1],t}const f=l,m=n,g=o,y=a,x=h,b=c,w=u;Object.freeze(Object.defineProperty({__proto__:null,add:function(t,e,s){return t[0]=e[0]+s[0],t[1]=e[1]+s[1],t},angle:function(t,e){const s=t[0],i=t[1],r=e[0],n=e[1];let o=s*s+i*i;o>0&&(o=1/Math.sqrt(o));let a=r*r+n*n;a>0&&(a=1/Math.sqrt(a));const h=(s*r+i*n)*o*a;return h>1?0:h<-1?Math.PI:Math.acos(h)},ceil:function(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t},copy:function(t,e){return t[0]=e[0],t[1]=e[1],t},cross:function(t,e,s){const i=e[0]*s[1]-e[1]*s[0];return t[0]=t[1]=0,t[2]=i,t},dist:x,distance:h,div:y,divide:a,dot:function(t,e){return t[0]*e[0]+t[1]*e[1]},equals:function(t,e){const s=t[0],r=t[1],n=e[0],o=e[1],a=(0,i.Au)();return Math.abs(s-n)<=a*Math.max(1,Math.abs(s),Math.abs(n))&&Math.abs(r-o)<=a*Math.max(1,Math.abs(r),Math.abs(o))},exactEquals:function(t,e){return t[0]===e[0]&&t[1]===e[1]},floor:function(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t},inverse:function(t,e){return t[0]=1/e[0],t[1]=1/e[1],t},len:f,length:l,lerp:d,max:function(t,e,s){return t[0]=Math.max(e[0],s[0]),t[1]=Math.max(e[1],s[1]),t},min:function(t,e,s){return t[0]=Math.min(e[0],s[0]),t[1]=Math.min(e[1],s[1]),t},mul:g,multiply:o,negate:function(t,e){return t[0]=-e[0],t[1]=-e[1],t},normalize:function(t,e){const s=e[0],i=e[1];let r=s*s+i*i;return r>0&&(r=1/Math.sqrt(r),t[0]=e[0]*r,t[1]=e[1]*r),t},projectAndScale:function(t,e,s,i,r){let n=e[0]-s[0],o=e[1]-s[1];const a=(i[0]*n+i[1]*o)*(r-1);return n=i[0]*a,o=i[1]*a,t[0]=e[0]+n,t[1]=e[1]+o,t},random:function(t,e){e=e||1;const s=2*(0,i.QR)()*Math.PI;return t[0]=Math.cos(s)*e,t[1]=Math.sin(s)*e,t},rotate:_,round:function(t,e){return t[0]=Math.round(e[0]),t[1]=Math.round(e[1]),t},scale:function(t,e,s){return t[0]=e[0]*s,t[1]=e[1]*s,t},scaleAndAdd:function(t,e,s,i){return t[0]=e[0]+s[0]*i,t[1]=e[1]+s[1]*i,t},set:r,sqrDist:b,sqrLen:w,squaredDistance:c,squaredLength:u,str:function(t){return"vec2("+t[0]+", "+t[1]+")"},sub:m,subtract:n,transformMat2:function(t,e,s){const i=e[0],r=e[1];return t[0]=s[0]*i+s[2]*r,t[1]=s[1]*i+s[3]*r,t},transformMat2d:p,transformMat3:function(t,e,s){const i=e[0],r=e[1];return t[0]=s[0]*i+s[3]*r+s[6],t[1]=s[1]*i+s[4]*r+s[7],t},transformMat4:function(t,e,s){const i=e[0],r=e[1];return t[0]=s[0]*i+s[4]*r+s[12],t[1]=s[1]*i+s[5]*r+s[13],t}},Symbol.toStringTag,{value:"Module"}))},60936:(t,e,s)=>{s.d(e,{A:()=>l});var i=s(41948),r=s(43780),n=s(38912),o=s(57896),a=s(66168),h=s(1580),c=s(12552);let l=class extends r.c{constructor(){super(...arguments),this.updating=!1,this._handleId=0,this._scheduleHandleId=0,this._pendingPromises=new Set}destroy(){this.removeAll()}add(t,e,s={}){return this._installWatch(t,e,s,o.aE)}addWhen(t,e,s={}){return this._installWatch(t,e,s,o._I)}addOnCollectionChange(t,e,{initial:s=!1,final:i=!1}={}){const r=++this._handleId;return this.addHandles([(0,o.on)(t,"after-changes",this._createSyncUpdatingCallback(),o.du),(0,o.on)(t,"change",e,{onListenerAdd:s?t=>e({added:t.toArray(),removed:[]}):void 0,onListenerRemove:i?t=>e({added:[],removed:t.toArray()}):void 0})],r),(0,n.uU)((()=>this.removeHandles(r)))}addPromise(t){if(null==t)return t;const e=++this._handleId;this.addHandles((0,n.uU)((()=>{this._pendingPromises.delete(t)&&(0!==this._pendingPromises.size||this.hasHandles(u)||this._set("updating",!1))})),e),this._pendingPromises.add(t),this._set("updating",!0);const s=()=>this.removeHandles(e);return t.then(s,s),t}removeAll(){this._pendingPromises.clear(),this.removeAllHandles(),this._set("updating",!1)}_installWatch(t,e,s={},i){const r=++this._handleId;s.sync||this._installSyncUpdatingWatch(t,r);const o=i(t,e,s);return this.addHandles(o,r),(0,n.uU)((()=>this.removeHandles(r)))}_installSyncUpdatingWatch(t,e){const s=this._createSyncUpdatingCallback(),i=(0,o.aE)(t,s,{sync:!0,equals:()=>!1});return this.addHandles(i,e),i}_createSyncUpdatingCallback(){return()=>{this.removeHandles(u),++this._scheduleHandleId;const t=this._scheduleHandleId;this._get("updating")||this._set("updating",!0),this.addHandles((0,a.Ow)((()=>{t===this._scheduleHandleId&&(this._set("updating",this._pendingPromises.size>0),this.removeHandles(u))})),u)}}};(0,i._)([(0,h.qq)({readOnly:!0})],l.prototype,"updating",void 0),l=(0,i._)([(0,c.c)("geoscene.core.support.UpdatingHandles")],l);const u=-42},46448:(t,e,s)=>{s.d(e,{c:()=>c});var i=s(38912),r=s(10860),n=s(54792),o=s(13056),a=s(25512),h=s(38432);class c{constructor(){this._inUseClients=new Array,this._clients=new Array,this._clientPromises=new Array,this._ongoingJobsQueue=new n.c}destroy(){this.close()}get closed(){return!this._clients?.length}open(t,e){return new Promise(((s,i)=>{let n=!0;const o=t=>{(0,r.wp)(e.signal),n&&(n=!1,t())};this._clients.length=t.length,this._clientPromises.length=t.length,this._inUseClients.length=t.length;for(let n=0;n<t.length;++n){const a=t[n];(0,r.eW)(a)?this._clientPromises[n]=a.then((t=>(this._clients[n]=new h.default(t,e,this._ongoingJobsQueue),o(s),this._clients[n])),(()=>(o(i),null))):(this._clients[n]=new h.default(a,e,this._ongoingJobsQueue),this._clientPromises[n]=Promise.resolve(this._clients[n]),o(s))}}))}broadcast(t,e,s){const i=new Array(this._clientPromises.length);for(let r=0;r<this._clientPromises.length;++r){const n=this._clientPromises[r];i[r]=n.then((i=>i?.invoke(t,e,s)))}return i}close(){let t;for(;t=this._ongoingJobsQueue.pop();)t.resolver.reject((0,r.Uh)(`Worker closing, aborting job calling '${t.methodName}'`));for(const t of this._clientPromises)t.then((t=>t?.close()));this._clients.length=0,this._clientPromises.length=0,this._inUseClients.length=0,(0,o.S)(this)}invoke(t,e,s){return this.apply(t,[e],s)}apply(t,e,s){const i=(0,r.qG)();this._ongoingJobsQueue.push({methodName:t,data:e,invokeOptions:s,resolver:i});for(let t=0;t<this._clientPromises.length;t++){const e=this._clients[t];e?e.jobAdded():this._clientPromises[t].then((t=>t?.jobAdded()))}return i.promise}createInvokeProxy(t){return(0,a.Y)(this,t)}on(t,e){return Promise.all(this._clientPromises).then((()=>(0,i.Ip)(this._clients.map((s=>s.on(t,e))))))}openPorts(){return new Promise((t=>{const e=new Array(this._clientPromises.length);let s=e.length;for(let i=0;i<this._clientPromises.length;++i)this._clientPromises[i].then((r=>{r&&(e[i]=r.openPort()),0==--s&&t(e)}))}))}get test(){return{numClients:this._clients.length}}}},13056:(t,e,s)=>{s.d(e,{S:()=>n,s:()=>r});const i=new FinalizationRegistry((t=>{t.close()}));function r(t,e){i.register(t,e,e)}function n(t){i.unregister(t)}},59612:(t,e,s)=>{s.d(e,{EN:()=>S,S8:()=>w,i2:()=>m,wt:()=>f}),s(9456);var i=s(53648),r=s(95247),n=s(7488),o=s(56156),a=s(67932),h=s(97088),c=s(85152),l=s(7684);const u=new Float64Array(2),d=new Float64Array(2),p="0123456789bcdefghjkmnpqrstuvwxyz",_=64;function f(t,e,s,i){const a=[t.xmin,t.ymin,t.xmax,t.ymax],u=n.c.fromExtent(r.c.fromBounds(a,i)),d=(0,l.yU)(u,i,o.c.WGS84,{densificationStep:e*_});if(!d)return null;const p=(0,h.Uh)(new c.c,d,!1,!1),f=p.coords.filter(((t,e)=>!(e%2))),g=p.coords.filter(((t,e)=>e%2)),y=Math.min(...f),x=Math.min(...g),b=Math.max(...f),w=Math.max(...g),v=m(y,x,s,o.c.WGS84),S=m(b,w,s,o.c.WGS84);return v&&S?{bounds:a,geohashBounds:{xLL:v[0],yLL:v[1],xTR:S[0],yTR:S[1]},level:s}:null}function m(t,e,s,r){if(r.isWebMercator){const r=(0,i.UB)(t/a.ug.radius),n=r-360*Math.floor((r+180)/360),o=[0,0];return v(o,0,(0,i.UB)(Math.PI/2-2*Math.atan(Math.exp(-e/a.ug.radius))),n,s),o}const n=(0,l.yU)({x:t,y:e},r,o.c.WGS84);if(!n)return null;const h=[0,0];return v(h,0,n.y,n.x,s),h}function g(t){return p[t]}function y(t){return(t[0]+t[1])/2}function x(t,e,s){return t[0]=e,t[1]=s,t}function b(t,e){const s=e>y(t);return function(t,e){const s=y(t),i=e,r=!e;t[0]=r*t[0]+i*s,t[1]=r*s+i*t[1]}(t,s),s}function w(t,e){let s=-90,i=90,r=-180,n=180;for(let o=0;o<e;o++){const e=Math.ceil((o+1)/2),a=Math.floor((o+1)/2),h=1-o%2,c=30-(3*e+2*a),l=30-(2*e+3*a),u=3*h+2*(1-h),d=2*h+3*(1-h),p=3*h+7*(1-h)<<l,_=(7*h+3*(1-h)<<c&t.geohashX)>>c,f=(p&t.geohashY)>>l;for(let t=u-1;t>=0;t--){const e=(r+n)/2,s=_&1<<t?1:0;r=(1-s)*r+s*e,n=(1-s)*e+s*n}for(let t=d-1;t>=0;t--){const e=(s+i)/2,r=f&1<<t?1:0;s=(1-r)*s+r*e,i=(1-r)*e+r*i}}return[r,s,n,i]}function v(t,e,s,i,r){r%2&&(r+=1);let n=0,o=0,a=-90,h=90,c=-180,l=180;for(let t=0;t<r/2;t++){for(let e=0;e<5;e++){const s=(c+l)/2,r=i>s?1:0;n|=r<<29-(e+5*t),c=(1-r)*c+r*s,l=(1-r)*s+r*l}for(let e=0;e<5;e++){const i=(a+h)/2,r=s>i?1:0;o|=r<<29-(e+5*t),a=(1-r)*a+r*i,h=(1-r)*i+r*h}}t[2*e]=n,t[2*e+1]=o}function S(t,e,s){let i="";const r=x(u,-90,90),n=x(d,-180,180);for(let o=0;o<s;o++){let s=0;o%2?(s|=b(r,t)<<4,s|=b(n,e)<<3,s|=b(r,t)<<2,s|=b(n,e)<<1,s|=b(r,t)<<0):(s|=b(n,e)<<4,s|=b(r,t)<<3,s|=b(n,e)<<2,s|=b(r,t)<<1,s|=b(n,e)<<0),i+=g(s)}return i}},57006:(t,e,s)=>{s.r(e),s.d(e,{createConnection:()=>M});var i=s(41948),r=(s(60708),s(2600)),n=s(20744),o=s(66360),a=s(10860),h=s(28176),c=(s(9456),s(72052),s(12552)),l=s(1580),u=s(37924),d=s(77860);let p=class extends d.c.EventedAccessor{destroy(){this.emit("destroy")}get connectionError(){return this.errorString?new n.c("stream-connection",this.errorString):null}onFeature(t){this.emit("data-received",t)}onMessage(t){this.emit("message-received",t)}};(0,i._)([(0,l.qq)({readOnly:!0})],p.prototype,"connectionError",null),p=(0,i._)([(0,c.c)("geoscene.layers.support.StreamConnection")],p);const _=p;var f,m;(m=f||(f={}))[m.CONNECTING=0]="CONNECTING",m[m.OPEN=1]="OPEN",m[m.CLOSING=2]="CLOSING",m[m.CLOSED=3]="CLOSED";let g=class extends _{constructor(t){super({}),this._outstandingMessages=[],this.errorString=null;const{geometryType:e,spatialReference:s,sourceSpatialReference:i}=t;this._config=t,this._featureZScaler=(0,u.O)(e,i,s),this._open()}normalizeCtorArgs(){return{}}async _open(){await this._tryCreateWebSocket(),this.destroyed||await this._handshake()}destroy(){super.destroy(),null!=this._websocket&&(this._websocket.onopen=null,this._websocket.onclose=null,this._websocket.onerror=null,this._websocket.onmessage=null,this._websocket.close()),this._websocket=null}get connectionStatus(){if(null==this._websocket)return"disconnected";switch(this._websocket.readyState){case f.CONNECTING:case f.OPEN:return"connected";case f.CLOSING:case f.CLOSED:return"disconnected"}}sendMessageToSocket(t){null!=this._websocket?this._websocket.send(JSON.stringify(t)):this._outstandingMessages.push(t)}sendMessageToClient(t){this._onMessage(t)}updateCustomParameters(t){this._config.customParameters=t,null!=this._websocket&&this._websocket.close()}async _tryCreateWebSocket(t=this._config.source.path,e=1e3,s=0){try{if(this.destroyed)return;const e=(0,h.UP)(t,this._config.customParameters??{});this._websocket=await this._createWebSocket(e),this.notifyChange("connectionStatus")}catch(i){const r=e/1e3;return this._config.maxReconnectionAttempts&&s>=this._config.maxReconnectionAttempts?(o.c.getLogger(this).error(new n.c("websocket-connection","Exceeded maxReconnectionAttempts attempts. No further attempts will be made")),void this.destroy()):(o.c.getLogger(this).error(new n.c("websocket-connection",`Failed to connect. Attempting to reconnect in ${r}s`,i)),await(0,a.iV)(e),this._tryCreateWebSocket(t,Math.min(1.5*e,1e3*this._config.maxReconnectionInterval),s+1))}}_setWebSocketJSONParseHandler(t){t.onmessage=t=>{try{const e=JSON.parse(t.data);this._onMessage(e)}catch(t){return void o.c.getLogger(this).error(new n.c("websocket-connection","Failed to parse message, invalid JSON",{error:t}))}}}_createWebSocket(t){return new Promise(((e,s)=>{const i=new WebSocket(t);i.onopen=()=>{if(i.onopen=null,this.destroyed)return i.onclose=null,void i.close();i.onclose=t=>this._onClose(t),i.onerror=t=>this._onError(t),this._setWebSocketJSONParseHandler(i),e(i)},i.onclose=t=>{i.onopen=i.onclose=null,s(t)}}))}async _handshake(t=1e4){const e=this._websocket;if(null==e)return;const s=(0,a.qG)(),i=e.onmessage,{filter:r,outFields:h,spatialReference:c}=this._config;return s.timeout(t),e.onmessage=t=>{let a=null;try{a=JSON.parse(t.data)}catch(t){}a&&"object"==typeof a||(o.c.getLogger(this).error(new n.c("websocket-connection","Protocol violation. Handshake failed - malformed message",t.data)),s.reject(),this.destroy()),a.spatialReference?.wkid!==c?.wkid&&(o.c.getLogger(this).error(new n.c("websocket-connection",`Protocol violation. Handshake failed - expected wkid of ${c.wkid}`,t.data)),s.reject(),this.destroy()),"json"!==a.format&&(o.c.getLogger(this).error(new n.c("websocket-connection","Protocol violation. Handshake failed - format is not set",t.data)),s.reject(),this.destroy()),r&&a.filter!==r&&o.c.getLogger(this).error(new n.c("websocket-connection","Tried to set filter, but server doesn't support it")),h&&a.outFields!==h&&o.c.getLogger(this).error(new n.c("websocket-connection","Tried to set outFields, but server doesn't support it")),e.onmessage=i;for(const t of this._outstandingMessages)e.send(JSON.stringify(t));this._outstandingMessages=[],s.resolve()},e.send(JSON.stringify({filter:r,outFields:h,format:"json",spatialReference:{wkid:c.wkid}})),s.promise}_onMessage(t){if(this.onMessage(t),"type"in t)switch(t.type){case"features":case"featureResult":for(const e of t.features)null!=this._featureZScaler&&this._featureZScaler(e.geometry),this.onFeature(e)}}_onError(t){const e="Encountered an error over WebSocket connection";this._set("errorString",e),o.c.getLogger(this).error("websocket-connection",e)}_onClose(t){this._websocket=null,this.notifyChange("connectionStatus"),1e3!==t.code&&o.c.getLogger(this).error("websocket-connection",`WebSocket closed unexpectedly with error code ${t.code}`),this.destroyed||this._open()}};(0,i._)([(0,l.qq)()],g.prototype,"connectionStatus",null),(0,i._)([(0,l.qq)()],g.prototype,"errorString",void 0),g=(0,i._)([(0,c.c)("geoscene.layers.graphics.sources.connections.WebSocketConnection")],g);var y=s(32848),x=s(95776),b=s(6704),w=s(56156);const v={maxQueryDepth:5,maxRecordCountFactor:3};let S=class extends g{constructor(t){super({...v,...t}),this._buddyServicesQuery=null,this._relatedFeatures=null}async _open(){const t=await this._fetchServiceDefinition(this._config.source);t.timeInfo.trackIdField||o.c.getLogger(this).warn("GeoEvent service was configured without a TrackIdField. This may result in certain functionality being disabled. The purgeOptions.maxObservations property will have no effect.");const e=this._fetchWebSocketUrl(t.streamUrls,this._config.spatialReference);this._buddyServicesQuery||(this._buddyServicesQuery=this._queryBuddyServices()),await this._buddyServicesQuery,await this._tryCreateWebSocket(e);const{filter:s,outFields:i}=this._config;this.destroyed||this._setFilter(s,i)}_onMessage(t){if("attributes"in t){let e;try{e=this._enrich(t),null!=this._featureZScaler&&this._featureZScaler(e.geometry)}catch(t){return void o.c.getLogger(this).error(new n.c("geoevent-connection","Failed to parse message",t))}this.onFeature(e)}else this.onMessage(t)}async _fetchServiceDefinition(t){const e={f:"json",...this._config.customParameters},s=(0,r.c)(t.path,{query:e,responseType:"json"}),i=(await s).data;return this._serviceDefinition=i,i}_fetchWebSocketUrl(t,e){const s=t[0],{urls:i,token:r}=s,n=this._inferWebSocketBaseUrl(i);return(0,h.UP)(`${n}/subscribe`,{outSR:""+e.wkid,token:r})}_inferWebSocketBaseUrl(t){if(1===t.length)return t[0];for(const e of t)if(e.includes("wss"))return e;return o.c.getLogger(this).error(new n.c("geoevent-connection","Unable to infer WebSocket url",t)),null}async _setFilter(t,e){const s=this._websocket;if(null==s||null==t&&null==e)return;const i=JSON.stringify({filter:this._serializeFilter(t,e)});let r=!1;const h=(0,a.qG)();return s.onmessage=t=>{const e=JSON.parse(t.data);e.filter&&(e.error&&(o.c.getLogger(this).error(new n.c("geoevent-connection","Failed to set service filter",e.error)),this._set("errorString",`Could not set service filter - ${e.error}`),h.reject(e.error)),this._setWebSocketJSONParseHandler(s),r=!0,h.resolve())},s.send(i),setTimeout((()=>{r||(this.destroyed||this._websocket!==s||o.c.getLogger(this).error(new n.c("geoevent-connection","Server timed out when setting filter")),h.reject())}),1e4),h.promise}_serializeFilter(t,e){const s={};if(null==t&&null==e)return s;if(t?.geometry)try{const e=(0,b.h4)(t.geometry);if("extent"!==e.type)throw new n.c(`Expected extent but found type ${e.type}`);s.geometry=JSON.stringify(e.shiftCentralMeridian())}catch(t){o.c.getLogger(this).error(new n.c("geoevent-connection","Encountered an error when setting connection geometryDefinition",t))}return t?.where&&"1 = 1"!==t.where&&"1=1"!==t.where&&(s.where=t.where),null!=e&&(s.outFields=e.join(",")),s}_enrich(t){if(!this._relatedFeatures)return t;const e=this._serviceDefinition.relatedFeatures.joinField,s=t.attributes[e],i=this._relatedFeatures.get(s);if(!i)return o.c.getLogger(this).warn("geoevent-connection","Feature join failed. Is the join field configured correctly?",t),t;const{attributes:r,geometry:a}=i;for(const e in r)t.attributes[e]=r[e];return a&&(t.geometry=a),t.geometry||t.centroid||o.c.getLogger(this).error(new n.c("geoevent-connection","Found malformed feature - no geometry found",t)),t}async _queryBuddyServices(){try{const{relatedFeatures:t,keepLatestArchive:e}=this._serviceDefinition,s=this._queryRelatedFeatures(t),i=this._queryArchive(e);await s;const r=await i;if(!r)return;for(const t of r.features)this.onFeature(this._enrich(t))}catch(t){o.c.getLogger(this).error(new n.c("geoevent-connection","Encountered an error when querying buddy services",{error:t}))}}async _queryRelatedFeatures(t){if(!t)return;const e=await this._queryBuddy(t.featuresUrl);this._addRelatedFeatures(e)}async _queryArchive(t){if(t)return this._queryBuddy(t.featuresUrl)}async _queryBuddy(t){const e=new((await Promise.all([s.e(5612),s.e(5156),s.e(2692),s.e(7988),s.e(9364),s.e(236),s.e(8976),s.e(9512),s.e(2664),s.e(6556),s.e(672),s.e(1004)]).then(s.bind(s,672))).default)({url:t}),{capabilities:i}=await e.load(),r=i.query.supportsMaxRecordCountFactor,n=i.query.supportsPagination,o=i.query.supportsCentroid,a=this._config.maxRecordCountFactor,h=e.capabilities.query.maxRecordCount,c=r?h*a:h,l=new x.c;if(l.outFields=this._config.outFields??["*"],l.where=this._config.filter?.where??"1=1",l.returnGeometry=!0,l.returnExceededLimitFeatures=!0,l.outSpatialReference=w.c.fromJSON(this._config.spatialReference),o&&(l.returnCentroid=!0),r&&(l.maxRecordCountFactor=a),n)return l.num=c,e.destroy(),this._queryPages(t,l);const u=await(0,y.EL)(t,l,this._config.sourceSpatialReference);return e.destroy(),u.data}async _queryPages(t,e,s=[],i=0){e.start=null!=e.num?i*e.num:null;const{data:r}=await(0,y.EL)(t,e,this._config.sourceSpatialReference);return r.exceededTransferLimit&&i<(this._config.maxQueryDepth??0)?(r.features.forEach((t=>s.push(t))),this._queryPages(t,e,s,i+1)):(s.forEach((t=>r.features.push(t))),r)}_addRelatedFeatures(t){const e=new Map,s=t.features,i=this._serviceDefinition.relatedFeatures.joinField;for(const t of s){const s=t.attributes[i];e.set(s,t)}this._relatedFeatures=e}};S=(0,i._)([(0,c.c)("geoscene.layers.graphics.sources.connections.GeoEventConnection")],S);const I=S;let T=class extends _{constructor(t){super({}),this.connectionStatus="connected",this.errorString=null;const{geometryType:e,spatialReference:s,sourceSpatialReference:i}=t;this._featureZScaler=(0,u.O)(e,i,s)}normalizeCtorArgs(){return{}}updateCustomParameters(t){}sendMessageToSocket(t){}sendMessageToClient(t){if("type"in t)switch(t.type){case"features":case"featureResult":for(const e of t.features)null!=this._featureZScaler&&this._featureZScaler(e.geometry),this.onFeature(e)}this.onMessage(t)}};function P(t,e){if(null==t&&null==e)return null;const s={};return null!=e&&(s.geometry=e),null!=t&&(s.where=t),s}function M(t,e,s,i,r,n,o,a,h){const c={source:t,sourceSpatialReference:e,spatialReference:s,geometryType:i,filter:P(r,n),maxReconnectionAttempts:o,maxReconnectionInterval:a,customParameters:h};return t?t.path.startsWith("wss://")||t.path.startsWith("ws://")?new g(c):new I(c):new T(c)}(0,i._)([(0,l.qq)()],T.prototype,"connectionStatus",void 0),(0,i._)([(0,l.qq)()],T.prototype,"errorString",void 0),T=(0,i._)([(0,c.c)("geoscene.layers.support.ClientSideConnection")],T)},22108:(t,e,s)=>{s.d(e,{c:()=>l});var i,r=s(41948),n=s(40504),o=s(1580),a=s(53368),h=(s(72052),s(9456),s(12552));let c=i=class extends n.am{constructor(t){super(t),this.cols=null,this.level=0,this.levelValue=null,this.origin=null,this.resolution=0,this.rows=null,this.scale=0}clone(){return new i({cols:this.cols,level:this.level,levelValue:this.levelValue,resolution:this.resolution,rows:this.rows,scale:this.scale})}};(0,r._)([(0,o.qq)({json:{write:!0,origins:{"web-document":{read:!1,write:!1},"portal-item":{read:!1,write:!1}}}})],c.prototype,"cols",void 0),(0,r._)([(0,o.qq)({type:a.Ab,json:{write:!0}})],c.prototype,"level",void 0),(0,r._)([(0,o.qq)({type:String,json:{write:!0}})],c.prototype,"levelValue",void 0),(0,r._)([(0,o.qq)({json:{write:!0,origins:{"web-document":{read:!1,write:!1},"portal-item":{read:!1,write:!1}}}})],c.prototype,"origin",void 0),(0,r._)([(0,o.qq)({type:Number,json:{write:!0}})],c.prototype,"resolution",void 0),(0,r._)([(0,o.qq)({json:{write:!0,origins:{"web-document":{read:!1,write:!1},"portal-item":{read:!1,write:!1}}}})],c.prototype,"rows",void 0),(0,r._)([(0,o.qq)({type:Number,json:{write:!0}})],c.prototype,"scale",void 0),c=i=(0,r._)([(0,h.c)("geoscene.layers.support.LOD")],c);const l=c},87576:(t,e,s)=>{s.d(e,{c:()=>I});var i,r=s(41948),n=s(14628),o=s(40504),a=s(24296),h=s(1580),c=s(53368),l=(s(72052),s(9456),s(33600)),u=s(12552),d=s(18996),p=s(67776),_=s(56156),f=s(83372),m=s(60544),g=s(29120),y=s(22108),x=s(11712);const b=new n.O({PNG:"png",PNG8:"png8",PNG24:"png24",PNG32:"png32",JPEG:"jpg",JPG:"jpg",DIB:"dib",TIFF:"tiff",EMF:"emf",PS:"ps",PDF:"pdf",GIF:"gif",SVG:"svg",SVGZ:"svgz",Mixed:"mixed",MIXED:"mixed",LERC:"lerc",LERC2D:"lerc2d",RAW:"raw",pbf:"pbf"});let w=i=class extends o.am{static create(t={}){const{resolutionFactor:e=1,scales:s,size:r=256,spatialReference:n=_.c.WebMercator,numLODs:o=24}=t;if(!(0,m.U3)(n)){const t=[];if(s)for(let e=0;e<s.length;e++){const i=s[e];t.push(new y.c({level:e,scale:i,resolution:i}))}else{let e=5e-4;for(let s=o-1;s>=0;s--)t.unshift(new y.c({level:s,scale:e,resolution:e})),e*=2}return new i({dpi:96,lods:t,origin:new p.c(0,0,n),size:[r,r],spatialReference:n})}const h=(0,m.Nq)(n),c=t.origin?new p.c({x:t.origin.x,y:t.origin.y,spatialReference:n}):new p.c(h?{x:h.origin[0],y:h.origin[1],spatialReference:n}:{x:0,y:0,spatialReference:n}),l=1/(39.37*(0,a.k8)(n)*96),u=[];if(s)for(let t=0;t<s.length;t++){const e=s[t],i=e*l;u.push(new y.c({level:t,scale:e,resolution:i}))}else{let t=(0,m.Eb)(n)?512/r*591657527.5917094:256/r*591657527.591555;const s=Math.ceil(o/e);u.push(new y.c({level:0,scale:t,resolution:t*l}));for(let i=1;i<s;i++){const s=t/2**e,r=s*l;u.push(new y.c({level:i,scale:s,resolution:r})),t=s}}return new i({dpi:96,lods:u,origin:c,size:[r,r],spatialReference:n})}constructor(t){super(t),this.dpi=96,this.format=null,this.origin=null,this.size=null,this.spatialReference=null}get isWrappable(){const{spatialReference:t,origin:e}=this;if(t&&e){const s=(0,m.Nq)(t);return t.isWrappable&&!!s&&Math.abs(s.origin[0]-e.x)<=s.dx}return!1}readOrigin(t,e){return p.c.fromJSON({spatialReference:e.spatialReference,...t})}set lods(t){let e=0,s=0;const i=[],r=this._levelToLOD={};t&&(e=-1/0,s=1/0,t.forEach((t=>{i.push(t.scale),e=t.scale>e?t.scale:e,s=t.scale<s?t.scale:s,r[t.level]=t}))),this._set("scales",i),this._set("lods",t),this._initializeUpsampleLevels()}readSize(t,e){return[e.cols,e.rows]}writeSize(t,e){e.cols=t[0],e.rows=t[1]}zoomToScale(t){const e=this.scales;if(t<=0)return e[0];if(t>=e.length-1)return e[e.length-1];const s=Math.floor(t),i=s+1;return e[s]/(e[s]/e[i])**(t-s)}scaleToZoom(t){const e=this.scales,s=e.length-1;let i=0;for(;i<s;i++){const s=e[i],r=e[i+1];if(s<=t)return i;if(r===t)return i+1;if(s>t&&r<t)return i+Math.log(s/t)/Math.log(s/r)}return i}snapScale(t,e=.95){const s=this.scaleToZoom(t);return s%Math.floor(s)>=e?this.zoomToScale(Math.ceil(s)):this.zoomToScale(Math.floor(s))}tileAt(t,e,s,i){const r=this.lodAt(t);if(!r)return null;let n,o;if("number"==typeof e)n=e,o=s;else if((0,m.yK)(e.spatialReference,this.spatialReference))n=e.x,o=e.y,i=s;else{const t=(0,g.yU)(e,this.spatialReference);if(null==t)return null;n=t.x,o=t.y,i=s}const a=r.resolution*this.size[0],h=r.resolution*this.size[1];return i||(i=new x.g(null,0,0,0,(0,f.Su)())),i.level=t,i.row=Math.floor((this.origin.y-o)/h+.001),i.col=Math.floor((n-this.origin.x)/a+.001),this.updateTileInfo(i),i}updateTileInfo(t,e=i.ExtrapolateOptions.NONE){let s=this.lodAt(t.level);if(!s&&e===i.ExtrapolateOptions.POWER_OF_TWO){const e=this.lods[this.lods.length-1];e.level<t.level&&(s=e)}if(!s)return;const r=t.level-s.level,n=s.resolution*this.size[0]/2**r,o=s.resolution*this.size[1]/2**r;t.id=`${t.level}/${t.row}/${t.col}`,t.extent||(t.extent=(0,f.Su)()),t.extent[0]=this.origin.x+t.col*n,t.extent[1]=this.origin.y-(t.row+1)*o,t.extent[2]=t.extent[0]+n,t.extent[3]=t.extent[1]+o}upsampleTile(t){const e=this._upsampleLevels[t.level];return!(!e||-1===e.parentLevel||(t.level=e.parentLevel,t.row=Math.floor(t.row/e.factor+.001),t.col=Math.floor(t.col/e.factor+.001),this.updateTileInfo(t),0))}getTileBounds(t,e){const s=this.lodAt(e.level);if(null==s)return null;const{resolution:i}=s,r=i*this.size[0],n=i*this.size[1];return t[0]=this.origin.x+e.col*r,t[1]=this.origin.y-(e.row+1)*n,t[2]=t[0]+r,t[3]=t[1]+n,t}lodAt(t){return this._levelToLOD?.[t]??null}clone(){return i.fromJSON(this.write({}))}getOrCreateCompatible(t,e){if(256===this.size[0]&&256===this.size[1])return 256===t?this:null;const s=[],r=this.lods.length;for(let t=0;t<r;t++){const i=this.lods[t],r=i.resolution*e;s.push(new y.c({level:i.level,scale:i.scale,resolution:r}))}return new i({size:[t,t],dpi:this.dpi,format:this.format,compressionQuality:this.compressionQuality,origin:this.origin,spatialReference:this.spatialReference,lods:s})}_initializeUpsampleLevels(){const t=this.lods;this._upsampleLevels=[];let e=null;for(let s=0;s<t.length;s++){const i=t[s];this._upsampleLevels[i.level]={parentLevel:e?e.level:-1,factor:e?e.resolution/i.resolution:0},e=i}}};var v,S;(0,r._)([(0,h.qq)({type:Number,json:{write:!0}})],w.prototype,"compressionQuality",void 0),(0,r._)([(0,h.qq)({type:Number,json:{write:!0}})],w.prototype,"dpi",void 0),(0,r._)([(0,h.qq)({type:String,json:{read:b.read,write:b.write,origins:{"web-scene":{read:!1,write:!1}}}})],w.prototype,"format",void 0),(0,r._)([(0,h.qq)({readOnly:!0})],w.prototype,"isWrappable",null),(0,r._)([(0,h.qq)({type:p.c,json:{write:!0}})],w.prototype,"origin",void 0),(0,r._)([(0,l.E)("origin")],w.prototype,"readOrigin",null),(0,r._)([(0,h.qq)({type:[y.c],value:null,json:{write:!0}})],w.prototype,"lods",null),(0,r._)([(0,h.qq)({readOnly:!0})],w.prototype,"scales",void 0),(0,r._)([(0,h.qq)({cast:t=>Array.isArray(t)?t:"number"==typeof t?[t,t]:[256,256]})],w.prototype,"size",void 0),(0,r._)([(0,l.E)("size",["rows","cols"])],w.prototype,"readSize",null),(0,r._)([(0,d.G)("size",{cols:{type:c.Ab},rows:{type:c.Ab}})],w.prototype,"writeSize",null),(0,r._)([(0,h.qq)({type:_.c,json:{write:!0}})],w.prototype,"spatialReference",void 0),w=i=(0,r._)([(0,u.c)("geoscene.layers.support.TileInfo")],w),v=w||(w={}),(S=v.ExtrapolateOptions||(v.ExtrapolateOptions={}))[S.NONE=0]="NONE",S[S.POWER_OF_TWO=1]="POWER_OF_TWO";const I=w},11712:(t,e,s)=>{s.d(e,{g:()=>i});class i{constructor(t,e,s,i,r=void 0){this.id=t,this.level=e,this.row=s,this.col=i,this.extent=r}}},48212:(t,e,s)=>{s.d(e,{Ab:()=>x,Ej:()=>d,K0:()=>u,M9:()=>p,Wq:()=>f,YB:()=>l,_2:()=>g,oR:()=>m,q_:()=>_,wn:()=>y});var i=s(28176),r=s(91952);const n={mapserver:"MapServer",imageserver:"ImageServer",featureserver:"FeatureServer",sceneserver:"SceneServer",streamserver:"StreamServer",vectortileserver:"VectorTileServer","3dtilesserver":"3DTilesServer"},o=Object.values(n),a=new RegExp(`^((?:https?:)?\\/\\/\\S+?\\/rest\\/services\\/(.+?)\\/(${o.join("|")}))(?:\\/(?:layers\\/)?(\\d+))?`,"i"),h=new RegExp(`^((?:https?:)?\\/\\/\\S+?\\/([^\\/\\n]+)\\/(${o.join("|")}))(?:\\/(?:layers\\/)?(\\d+))?`,"i"),c=/(.*?)\/(?:layers\/)?(\d+)\/?$/i;function l(t){return!!a.test(t)}function u(t){if(null==t)return null;const e=(0,i.as)(t),s=e?.path.match(a)||e?.path.match(h);if(!s)return null;const[,r,o,c,l]=s,u=o.indexOf("/");return{title:p(-1!==u?o.slice(u+1):o),serverType:n[c.toLowerCase()],sublayer:null!=l&&""!==l?parseInt(l,10):null,url:{path:r}}}function d(t){const e=(0,i.as)(t).path.match(c);return e?{serviceUrl:e[1],sublayerId:Number(e[2])}:null}function p(t){return(t=t.replaceAll(/\s*[/_]+\s*/g," "))[0].toUpperCase()+t.slice(1)}function _(t,e){const s=[];if(t){const e=u(t);null!=e&&e.title&&s.push(e.title)}if(e){const t=p(e);s.push(t)}if(2===s.length){if(s[0].toLowerCase().includes(s[1].toLowerCase()))return s[0];if(s[1].toLowerCase().includes(s[0].toLowerCase()))return s[1]}return s.join(" - ")}function f(t){if(!t)return!1;const e=(t=t.toLowerCase()).includes(".Grcgis.cn/"),s=t.includes("//services")||t.includes("//tiles")||t.includes("//features");return e&&s}function m(t,e){return t?(0,i.ai)((0,i.kN)(t,e)):t}function g(t){let{url:e}=t;if(!e)return{url:e};e=(0,i.kN)(e,t.logger);const s=(0,i.as)(e),r=u(s.path);let n;if(null!=r)null!=r.sublayer&&null==t.layer.layerId&&(n=r.sublayer),e=r.url.path;else if(t.nonStandardUrlAllowed){const t=d(s.path);null!=t&&(e=t.serviceUrl,n=t.sublayerId)}return{url:(0,i.ai)(e),layerId:n}}function y(t,e,s,n,o){(0,r.w)(e,n,"url",o),n.url&&null!=t.layerId&&(n.url=(0,i.kn)(n.url,s,t.layerId.toString()))}function x(t){if(!t)return!1;const e=t.toLowerCase(),s=e.includes("/services/"),i=e.includes("/mapserver/wmsserver"),r=e.includes("/imageserver/wmsserver"),n=e.includes("/wmsserver");return s&&(i||r||n)}},21012:(t,e,s)=>{s.d(e,{M:()=>r});var i=s(37924);function r(t,e,s){if(!s?.features||!s.hasZ)return;const r=(0,i.O)(s.geometryType,e,t.outSpatialReference);if(null!=r)for(const t of s.features)r(t.geometry)}},51552:(t,e,s)=>{s.r(e),s.d(e,{default:()=>Hd});var i=s(20744),r=s(38912),n=s(9456),o=s(52324),a=s(10860),h=s(72052),c=s(57896),l=s(50144),u=s(87576),d=s(60544),p=s(53680);function _(t,e){return[t,e]}function f(t,e,s){return t[0]=e,t[1]=s,t}const m=new p.c("0/0/0/0");class g{static create(t,e,s=null){const i=(0,d.Nq)(t.spatialReference),r=e.origin||_(t.origin.x,t.origin.y),n=_(t.size[0]*e.resolution,t.size[1]*e.resolution),o=_(-1/0,-1/0),a=_(1/0,1/0),h=_(1/0,1/0);null!=s&&(f(o,Math.max(0,Math.floor((s.xmin-r[0])/n[0])),Math.max(0,Math.floor((r[1]-s.ymax)/n[1]))),f(a,Math.max(0,Math.floor((s.xmax-r[0])/n[0])),Math.max(0,Math.floor((r[1]-s.ymin)/n[1]))),f(h,a[0]-o[0]+1,a[1]-o[1]+1));const{cols:c,rows:l}=e;let u,p,m,y;return!s&&c&&l&&(f(o,c[0],l[0]),f(a,c[1],l[1]),f(h,c[1]-c[0]+1,l[1]-l[0]+1)),t.isWrappable?(u=_(Math.ceil(Math.round((i.valid[1]-i.valid[0])/e.resolution)/t.size[0]),h[1]),p=_(Math.floor((i.origin[0]-r[0])/n[0]),o[1]),m=_(u[0]+p[0]-1,a[1]),y=!0):(p=o,m=a,u=h,y=!1),new g(e.level,e.resolution,e.scale,r,o,a,h,n,p,m,u,y)}constructor(t,e,s,i,r,n,o,a,h,c,l,u){this.level=t,this.resolution=e,this.scale=s,this.origin=i,this.first=r,this.last=n,this.size=o,this.norm=a,this.worldStart=h,this.worldEnd=c,this.worldSize=l,this.wrap=u}normalizeCol(t){if(!this.wrap)return t;const e=this.worldSize[0];return t<0?e-1-Math.abs((t+1)%e):t%e}denormalizeCol(t,e){return this.wrap?this.worldSize[0]*e+t:t}getWorldForColumn(t){return this.wrap?Math.floor(t/this.worldSize[0]):0}getFirstColumnForWorld(t){return t*this.worldSize[0]+this.first[0]}getLastColumnForWorld(t){return t*this.worldSize[0]+this.first[0]+this.size[0]-1}getColumnForX(t){return(t-this.origin[0])/this.norm[0]}getXForColumn(t){return this.origin[0]+t*this.norm[0]}getRowForY(t){return(this.origin[1]-t)/this.norm[1]}getYForRow(t){return this.origin[1]-t*this.norm[1]}getTileBounds(t,e,s=!1){m.set(e);const i=s?m.col:this.denormalizeCol(m.col,m.world),r=m.row;return function(t,e,s,i,r){t[0]=e,t[1]=s,t[2]=i,t[3]=r}(t,this.getXForColumn(i),this.getYForRow(r+1),this.getXForColumn(i+1),this.getYForRow(r)),t}getTileCoords(t,e,s=!1){m.set(e);const i=s?m.col:this.denormalizeCol(m.col,m.world);return Array.isArray(t)?f(t,this.getXForColumn(i),this.getYForRow(m.row)):(t.x=this.getXForColumn(i),t.y=this.getYForRow(m.row)),t}}var y=s(69752);class x{constructor(){this.spans=[]}acquire(t){this.lodInfo=t}release(){this.lodInfo=null,this.spans.length=0}*keys(){const t=this.lodInfo;for(const{row:e,colFrom:s,colTo:i}of this.spans)for(let r=s;r<=i;r++){const s=t.getWorldForColumn(r);yield new p.c(t.level,e,t.normalizeCol(r),s)}}forEach(t,e){const{spans:s,lodInfo:i}=this,{level:r}=i;if(0!==s.length)for(const{row:n,colFrom:o,colTo:a}of s)for(let s=o;s<=a;s++)t.call(e,r,n,i.normalizeCol(s),i.getWorldForColumn(s))}}x.pool=new y.c(x);class b{constructor(t,e,s){this.row=t,this.colFrom=e,this.colTo=s}}const w=new p.c("0/0/0/0");class v{static create(t,e){t[1]>e[1]&&([t,e]=[e,t]);const[s,i]=t,[r,n]=e,o=r-s,a=n-i,h=0!==a?o/a:0,c=(Math.ceil(i)-i)*h,l=(Math.floor(i)-i)*h;return new v(s,Math.floor(i),Math.ceil(n),h,o<0?c:l,o<0?l:c,o<0?r:s,o<0?s:r)}constructor(t,e,s,i,r,n,o,a){this.x=t,this.ymin=e,this.ymax=s,this.invM=i,this.leftAdjust=r,this.rightAdjust=n,this.leftBound=o,this.rightBound=a}incrRow(){this.x+=this.invM}getLeftCol(){return Math.max(this.x+this.leftAdjust,this.leftBound)}getRightCol(){return Math.min(this.x+this.rightAdjust,this.rightBound)}}const S=[[0,0],[0,0],[0,0],[0,0]];class I{constructor(t,e=null,s=t.lods[0].level,i=t.lods[t.lods.length-1].level){this.tileInfo=t,this.fullExtent=e,this.scales=[],this._infoByScale={},this._infoByLevel={};const r=t.lods.filter((t=>t.level>=s&&t.level<=i));this.minScale=r[0].scale,this.maxScale=r[r.length-1].scale;const n=this._lodInfos=r.map((s=>g.create(t,s,e)));r.forEach(((t,e)=>{this._infoByLevel[t.level]=n[e],this._infoByScale[t.scale]=n[e],this.scales[e]=t.scale}),this),this._wrap=t.isWrappable}get spatialReference(){return this.tileInfo.spatialReference}getLODInfoAt(t){return this._infoByLevel["number"==typeof t?t:t.level]}getTileBounds(t,e,s=!1){w.set(e);const i=this._infoByLevel[w.level];return i?i.getTileBounds(t,w,s):t}getTileCoords(t,e,s=!1){w.set(e);const i=this._infoByLevel[w.level];return i?i.getTileCoords(t,w,s):t}getTileCoverage(t,e=192,s=!0,i="closest"){if(!s&&(t.scale>this.minScale||t.scale<this.maxScale))return null;const r="closest"===i?this.getClosestInfoForScale(t.scale):this.getSmallestInfoForScale(t.scale),n=x.pool.acquire(r),o=this._wrap;let a,h,c,l=1/0,u=-1/0;const d=n.spans;S[0][0]=S[0][1]=S[1][1]=S[3][0]=-e,S[1][0]=S[2][0]=t.size[0]+e,S[2][1]=S[3][1]=t.size[1]+e;for(const e of S)t.toMap(e,e),e[0]=r.getColumnForX(e[0]),e[1]=r.getRowForY(e[1]);const p=[];let _=3;for(let t=0;t<4;t++){if(S[t][1]===S[_][1]){_=t;continue}const e=v.create(S[t],S[_]);l=Math.min(e.ymin,l),u=Math.max(e.ymax,u),void 0===p[e.ymin]&&(p[e.ymin]=[]),p[e.ymin].push(e),_=t}if(null==l||null==u||u-l>100)return null;let f=[];for(a=l;a<u;){null!=p[a]&&(f=f.concat(p[a])),h=1/0,c=-1/0;for(let t=f.length-1;t>=0;t--){const e=f[t];h=Math.min(h,e.getLeftCol()),c=Math.max(c,e.getRightCol())}if(h=Math.floor(h),c=Math.floor(c),a>=r.first[1]&&a<=r.last[1])if(o)if(r.size[0]<r.worldSize[0]){const t=Math.floor(c/r.worldSize[0]);for(let e=Math.floor(h/r.worldSize[0]);e<=t;e++)d.push(new b(a,Math.max(r.getFirstColumnForWorld(e),h),Math.min(r.getLastColumnForWorld(e),c)))}else d.push(new b(a,h,c));else h>r.last[0]||c<r.first[0]||(h=Math.max(h,r.first[0]),c=Math.min(c,r.last[0]),d.push(new b(a,h,c)));a+=1;for(let t=f.length-1;t>=0;t--){const e=f[t];e.ymax>=a?e.incrRow():f.splice(t,1)}}return n}getTileParentId(t){w.set(t);const e=this._infoByLevel[w.level],s=this._lodInfos.indexOf(e)-1;return s<0?null:(this._getTileIdAtLOD(w,this._lodInfos[s],w),w.id)}getTileResolution(t){const e=this._infoByLevel["object"==typeof t?t.level:t];return e?e.resolution:-1}getTileScale(t){const e=this._infoByLevel[t.level];return e?e.scale:-1}intersects(t,e){w.set(e);const s=this._infoByLevel[w.level],i=t.lodInfo;if(i.resolution>s.resolution){this._getTileIdAtLOD(w,i,w);const e=i.denormalizeCol(w.col,w.world);for(const s of t.spans)if(s.row===w.row&&s.colFrom<=e&&s.colTo>=e)return!0}if(i.resolution<s.resolution){const[e,r,n,o]=t.spans.reduce(((t,e)=>(t[0]=Math.min(t[0],e.row),t[1]=Math.max(t[1],e.row),t[2]=Math.min(t[2],e.colFrom),t[3]=Math.max(t[3],e.colTo),t)),[1/0,-1/0,1/0,-1/0]),a=s.denormalizeCol(w.col,w.world),h=i.getColumnForX(s.getXForColumn(a)),c=i.getRowForY(s.getYForRow(w.row)),l=i.getColumnForX(s.getXForColumn(a+1))-1,u=i.getRowForY(s.getYForRow(w.row+1))-1;return!(h>o||l<n||c>r||u<e)}const r=i.denormalizeCol(w.col,w.world);return t.spans.some((t=>t.row===w.row&&t.colFrom<=r&&t.colTo>=r))}normalizeBounds(t,e,s){if(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],this._wrap){const e=(0,d.Nq)(this.tileInfo.spatialReference),i=-s*(e.valid[1]-e.valid[0]);t[0]+=i,t[2]+=i}return t}getSmallestInfoForScale(t){const e=this.scales;if(this._infoByScale[t])return this._infoByScale[t];if(t>e[0])return this._infoByScale[e[0]];for(let s=1;s<e.length-1;s++)if(t>e[s]+1e-6)return this._infoByScale[e[s-1]];return this._infoByScale[e[e.length-1]]}getClosestInfoForScale(t){const e=this.scales;return this._infoByScale[t]||(t=e.reduce(((e,s)=>Math.abs(s-t)<Math.abs(e-t)?s:e),e[0])),this._infoByScale[t]}scaleToLevel(t){const e=this.scales;if(this._infoByScale[t])return this._infoByScale[t].level;for(let s=e.length-1;s>=0;s--)if(t<e[s])return s===e.length-1?this._infoByScale[e[e.length-1]].level:this._infoByScale[e[s]].level+(e[s]-t)/(e[s]-e[s+1]);return this._infoByScale[e[0]].level}scaleToZoom(t){return this.tileInfo.scaleToZoom(t)}_getTileIdAtLOD(t,e,s){const i=this._infoByLevel[s.level];return t.set(s),e.resolution<i.resolution?null:(e.resolution===i.resolution||(t.level=e.level,t.col=Math.floor(s.col*i.resolution/e.resolution+.01),t.row=Math.floor(s.row*i.resolution/e.resolution+.01)),t)}}var T=s(41948),P=s(43780),M=s(70680),E=s(1580),C=s(66360),k=s(12552),F=s(37648),A=s(27064);const R=new Set,O=[],N=new Map,D=[0,0];let z=class extends P.c{constructor(t){super(t),this._keyToItem=new Map,this.concurrency=6,this.strategy="scale-first",this.tileInfoView=null}initialize(){const{concurrency:t,process:e,strategy:s}=this;this._queue=new A.K({concurrency:t,process:(t,s)=>{const i=this._keyToItem.get(t);return e(i,{signal:s})},peeker:"scale-first"===s?t=>this._peekByScaleFirst(t):t=>this._peekByCenterFirst(t)})}destroy(){this.clear(),this._queue=(0,M.mG)(this._queue)}get length(){return this._queue?this._queue.length:0}get onGoingCount(){return this._keyToItem.size}abort(t){const e="string"==typeof t?t:t.id;this._queue.abort(e)}clear(){this._queue.clear(),this._keyToItem.clear()}has(t){return"string"==typeof t?this._keyToItem.has(t):this._keyToItem.has(t.id)}isOngoing(t){const e="string"==typeof t?t:t.id;return this.has(e)&&this._queue.isOngoing(e)}pause(){this._queue.pause()}push(t){const e=t.key.id;if(this._queue.has(e))return this._queue.get(e);const s=this._queue.push(e),i=()=>{this._keyToItem.delete(e)};return this._keyToItem.set(e,t),s.then(i,i),s}reset(){this._queue.reset()}resume(){this._queue.resume()}_peekByScaleFirst(t){if(!this.state)return t.values().next().value;const e=this.tileInfoView;let s=Number.NEGATIVE_INFINITY,i=Number.POSITIVE_INFINITY;t.forEach((t=>{const e=this._keyToItem.get(t),r=this.tileInfoView.getTileScale(e.key);N.has(r)||(N.set(r,[]),s=Math.max(r,s),i=Math.min(r,i)),N.get(r).push(e.key),R.add(r)}));let r=this.state.scale;N.has(r)||(function(t,e){t.length=0,e.forEach((e=>t.push(e)))}(O,R),O.sort(((t,e)=>t-e)),r=O.reduce(((t,e)=>Math.abs(e-r)<Math.abs(t-r)?e:t),O[0])),r=Math.min(r,s),r=Math.max(r,i);const n=N.get(r),o=e.getClosestInfoForScale(r),a=o.getColumnForX(this.state.center[0]),h=o.getRowForY(this.state.center[1]);return n.sort(((t,e)=>{const s=o.denormalizeCol(t.col,t.world),i=o.denormalizeCol(e.col,e.world);return Math.sqrt((a-s)*(a-s)+(h-t.row)*(h-t.row))-Math.sqrt((a-i)*(a-i)+(h-e.row)*(h-e.row))})),R.clear(),N.clear(),n[0].id}_peekByCenterFirst(t){if(!this.state)return t.values().next().value;const e=this.tileInfoView,s=this.state.center;let i,r=Number.POSITIVE_INFINITY;return t.forEach((t=>{const n=this._keyToItem.get(t);e.getTileCoords(D,n.key);const o=(0,F.qy)(D,s);o<r&&(r=o,i=n.key)})),i.id}};(0,T._)([(0,E.qq)({constructOnly:!0})],z.prototype,"concurrency",void 0),(0,T._)([(0,E.qq)({constructOnly:!0})],z.prototype,"process",void 0),(0,T._)([(0,E.qq)()],z.prototype,"state",void 0),(0,T._)([(0,E.qq)({constructOnly:!0})],z.prototype,"strategy",void 0),(0,T._)([(0,E.qq)({constructOnly:!0})],z.prototype,"tileInfoView",void 0),z=(0,T._)([(0,k.c)("geoscene.views.2d.tiling.TileQueue")],z);var L=s(83372);new p.c(0,0,0,0),new Map;var B=s(67720);class U{constructor(t){this._client=t,this.layerView=this._client.createInvokeProxy(),this.container=this._client.createInvokeProxy("container"),this.eventLog=this._client.createInvokeProxy("eventLog")}}var G=s(96523),V=s(56156);class q{constructor(t,e,s,i,r,n,o){this.instanceId=t,this.textureKey=e,this.indexStart=s,this.indexCount=i,this.vertexStart=r,this.vertexCount=n,this.overlaps=o}updateBaseOffsets(t){this.vertexStart+=t.vertexFrom,this.indexStart+=t.indexFrom}clone(){return new q(this.instanceId,this.textureKey,this.indexStart,this.indexCount,this.vertexStart,this.vertexCount,this.overlaps)}static write(t,e,s,i,r,n,o,a){t.push(e),t.push(s),t.push(i),t.push(r),t.push(n),t.push(o),t.push(a)}serialize(t){return t.push(this.instanceId),t.push(this.textureKey),t.push(this.indexStart),t.push(this.indexCount),t.push(this.vertexStart),t.push(this.vertexCount),t.push(this.overlaps),t}static deserialize(t){const e=t.readInt32(),s=t.readInt32(),i=t.readInt32(),r=t.readInt32(),n=t.readInt32(),o=t.readInt32(),a=t.readInt32();return new q(e,s,i,r,n,o,a)}}function W(t,e){if(null!==e){t.push(e.length);for(const s of e)s.serialize(t);return t}t.push(0)}function X(t,e,s){const i=t.readInt32(),r=new Array(i);for(let i=0;i<r.length;i++)r[i]=e.deserialize(t,s);return r}q.byteSizeHint=7*Uint32Array.BYTES_PER_ELEMENT;class Y{constructor(t,e){this.id=t,this.sortKey=e,this.records=[]}serialize(t){return t.push(this.id),t.writeF32(this.sortKey),W(t,this.records),t}static deserialize(t){const e=t.readInt32(),s=t.readF32(),i=new Y(e,s);return i.records=X(t,q)??[],i}}Y.byteSizeHint=2*Uint32Array.BYTES_PER_ELEMENT+q.byteSizeHint;class j{get length(){return this._pos}constructor(t,e){this._pos=0;const s=e?this._roundToNearest(e,t.BYTES_PER_ELEMENT):40;this._array=new ArrayBuffer(s),this._buffer=new t(this._array),this._ctor=t,this._i16View=new Int16Array(this._array)}_roundToNearest(t,e){const s=Math.round(t);return 1===e?s:s+(e-s%e)}_ensureSize(t){if(this._pos+t>=this._buffer.length){const e=this._roundToNearest(1.25*(this._array.byteLength+t*this._buffer.BYTES_PER_ELEMENT),this._buffer.BYTES_PER_ELEMENT),s=new ArrayBuffer(e),i=new this._ctor(s);i.set(this._buffer,0),this._array=s,this._buffer=i,this._i16View=new Int16Array(this._array)}}ensureSize(t){this._ensureSize(t)}writeF32(t){this._ensureSize(1);const e=this._pos;return new Float32Array(this._array,4*this._pos,1)[0]=t,this._pos++,e}push(t){this._ensureSize(1);const e=this._pos;return this._buffer[this._pos++]=t,e}writeFixed(t){this._buffer[this._pos++]=t}setValue(t,e){this._buffer[t]=e}i1616Add(t,e,s){this._i16View[2*t]+=e,this._i16View[2*t+1]+=s}getValue(t){return this._buffer[t]}getValueF32(t){return new Float32Array(this._array,4*t,1)[0]}incr(t){if(this._buffer.length<t)throw new Error("Increment index overflows the target buffer");this._buffer[t]++}decr(t){this._buffer[t]--}writeRegion(t){this._ensureSize(t.length);const e=this._pos;return this._buffer.set(t,this._pos),this._pos+=t.length,e}writeManyFrom(t,e,s){this._ensureSize(s-e);for(let i=e;i!==s;i++)this.writeFixed(t._buffer[i])}buffer(){const t=this._array.slice(0,4*this._pos);return this.destroy(),t}toArray(){return[...this._buffer]}seek(t){this._pos=t}destroy(){this._array=null,this._buffer=null}}class H{constructor(t,e,s,i=0){const r=6*i*Uint32Array.BYTES_PER_ELEMENT,n=4*i*s,o=s/4,a=e.attributes.find((t=>"pos"===t.name||"position"===t.name));if(!a)throw new Error("InternalError: Unable to find position attribute");this.layout={...e,position:a},this._indices=new j(Uint32Array,r),this._vertices=new j(Uint32Array,n),this._metrics=new j(Uint32Array,0),this._metricCountOffset=this._metrics.push(0),this._strideInt=o,this._instanceId=t}serialize(t){const e=this._indices.buffer(),s=this._vertices.buffer(),i=this._metrics.length?this._metrics.buffer():null;return t.push(e,s),{instanceId:this._instanceId,layout:this.layout,indices:e,vertices:s,metrics:i}}get strideInt(){return this._strideInt}get vertexCount(){return this._vertices.length/this._strideInt}get indexCount(){return this._indices.length}get indexWriter(){return this._indices}get vertexWriter(){return this._vertices}get metricWriter(){return this._metrics}vertexEnsureSize(t){this._vertices.ensureSize(t)}indexEnsureSize(t){this._indices.ensureSize(t)}writeIndex(t){this._indices.push(t)}writeVertex(t){this._vertices.push(t)}writeVertexRegion(t){this._vertices.writeRegion(t)}writeVertexF32(t){this._vertices.writeF32(t)}writeMetric(t){this._metrics.incr(this._metricCountOffset),t.serialize(this._metrics)}}class ${constructor(t,e=0){this._id=t,this._sizeHint=e,this._entityRecordCountOffset=0,this._entityCountOffset=0,this._entityIdIndex=0,this._entitySortKeyIndex=0,this._instanceIdToVertexData=new Map,this._current={metric:null,writer:null,start:0,sortKey:0,instanceId:0,layoutHash:0,indexStart:0,vertexStart:0,textureKey:0,metricBoxLenPointer:0},this._entities=new j(Uint32Array,this._sizeHint*Y.byteSizeHint),this._entityCountOffset=this._entities.push(0)}get id(){return this._id}serialize(){const t=new Array,e=[],s=this._entities.buffer();for(const s of this._instanceIdToVertexData.values())e.push(s.serialize(t));return{message:{data:e,entities:s},transferList:t}}vertexCount(){return this._current.writer?.vertexCount??0}indexCount(){return this._current.writer?.indexCount??0}vertexEnsureSize(t){this._current.writer.vertexEnsureSize(t)}indexEnsureSize(t){this._current.writer.indexEnsureSize(t)}vertexWrite(t){this._current.writer.writeVertex(t)}vertexWriteRegion(t){this._current.writer.writeVertexRegion(t)}vertexWriteF32(t){this._current.writer.writeVertexF32(t)}recordBounds(t,e,s,i){}indexWrite(t){this._current.writer.writeIndex(t)}metricStart(t){this._current.metric=t}metricEnd(){const t=this._current.writer;this._current.metric.bounds.length&&t.writeMetric(this._current.metric)}metricBoxWrite(t){this._current.metric.bounds.push(t)}entityStart(t,e=t){this._entityIdIndex=this._entities.push(t),this._entitySortKeyIndex=this._entities.writeF32(e),this._entityRecordCountOffset=this._entities.push(0)}entityRecordCount(){return this._entities.getValue(this._entityRecordCountOffset)}entityEnd(){0===this.entityRecordCount()?this._entities.seek(this._entityIdIndex):this._entities.incr(this._entityCountOffset)}recordCount(){return this._entities.getValue(this._entityRecordCountOffset)}recordStart(t,e,s=0){this._current.writer=this._getVertexWriter(t,e),this._current.indexStart=this._current.writer.indexCount,this._current.vertexStart=this._current.writer.vertexCount,this._current.instanceId=t,this._current.layoutHash=e.hash,this._current.textureKey=s}recordEnd(t=0){const e=this._current.vertexStart,s=this._current.writer.vertexCount-e;if(!s)return!1;const i=this._current.indexStart,r=this._current.writer.indexCount-i;return this._entities.incr(this._entityRecordCountOffset),q.write(this._entities,this._current.instanceId,this._current.textureKey,i,r,e,s,t),!0}copyLastFrom(t,e,s){const i=t._entities.getValue(t._entityIdIndex);if(i!==this._entities.getValue(this._entityIdIndex)){const e=t._entities.getValueF32(t._entitySortKeyIndex);this.entityStart(i,e)}this.recordStart(t._current.instanceId,t._current.writer.layout,t._current.textureKey);const r=this._current.writer.layout.stride/Uint32Array.BYTES_PER_ELEMENT,n=this._current.vertexStart,o=t._current.vertexStart-n,a=this._current.writer.indexWriter,h=this._current.writer.vertexWriter,c=t._current.writer.indexWriter,l=t._current.writer.vertexWriter;for(let e=t._current.indexStart;e!==c.length;e++){const t=c.getValue(e);a.push(t-o)}for(let e=t._current.vertexStart*r;e!==l.length;e++){const t=l.getValue(e);h.push(t)}const u=this._current.writer.layout.position,d=u.packPrecisionFactor??1,p=u.offset/Uint32Array.BYTES_PER_ELEMENT,_=e*d,f=s*d;for(let t=n*r;t<=h.length;t+=r)h.i1616Add(t+p,_,f);this.recordEnd()}_getVertexWriter(t,e){const{stride:s}=e,i=this._instanceIdToVertexData;return i.has(t)||i.set(t,new H(t,e,s,this._sizeHint)),i.get(t)}}function K(t){switch(t){case 1:case 8:case 32:return-1;case 2:case 64:return 0;case 4:case 16:case 128:return 1}}function Z(t){switch(t){case 1:case 2:case 4:return-1;case 8:case 16:return 0;case 32:case 64:case 128:return 1}}class Q{constructor(t,e,s=0){this.tileKey=t,this._bufferingEnabled=e,this._sizeHint=s,this._meshes={self:new $(this.id,this._sizeHint),neighbors:new Array},this._currentRecordOverlaps=0,this._currentEntityOverlaps=0}get id(){return this.tileKey}vertexCount(){return this._meshes.self.vertexCount()}indexCount(){return this._meshes.self.indexCount()}indexEnsureSize(t){this._meshes.self.indexEnsureSize(t)}entityStart(t,e=t){this._currentEntityOverlaps=0,this._meshes.self.entityStart(t,e)}entityRecordCount(){return this._meshes.self.entityRecordCount()}entityEnd(){if(this._meshes.self.entityEnd(),this._bufferingEnabled)for(let t=0;t<8;t++){const e=1<<t;this._currentEntityOverlaps&e&&this._meshes.neighbors[t].entityEnd()}}recordStart(t,e,s){this._currentRecordOverlaps=0,this._meshes.self.recordStart(t,e,s)}recordEnd(t=0){const e=this._meshes.self.recordEnd(this._currentRecordOverlaps);return e&&0!==this._currentRecordOverlaps?(this._copyIntoNeighbors(),this._currentEntityOverlaps|=this._currentRecordOverlaps,!0):e}recordBounds(t,e,s,i){this._bufferingEnabled&&this._addOverlap(t,e,s,i)}recordCount(){return this._meshes.self.recordCount()}metricStart(t){this._meshes.self.metricStart(t)}metricBoxWrite(t){this._meshes.self.metricBoxWrite(t)}metricEnd(){this._meshes.self.metricEnd()}vertexWrite(t){this._meshes.self.vertexWrite(t)}vertexWriteF32(t){this._meshes.self.vertexWriteF32(t)}vertexWriteRegion(t){this._meshes.self.vertexWriteRegion(t)}indexWrite(t){this._meshes.self.indexWrite(t)}serialize(t){const e={message:[],transferList:[]},s=this._meshes.self.serialize();return e.message.push({tileId:this.tileKey,...s.message}),e.transferList.push(...s.transferList),this._meshes.neighbors.forEach(((s,i)=>{const r=s.serialize(),n=1<<i,o=K(n),a=Z(n),h=function(t,e,s,i){const r=t.clone(),n=1<<r.level,o=r.col+e,a=r.row+s;return i&&o<0?(r.col=o+n,r.world-=1):o>=n?(r.col=o-n,r.world+=1):r.col=o,r.row=a,r}(new p.c(this.tileKey),o,a,t);e.message.push({tileId:h.id,...r.message}),e.transferList.push(...r.transferList)})),e}_addOverlap(t,e,s,i){const r=Math.min(B.gT/2,s),n=Math.min(B.gT/2,i),o=255^((t<0+r?148:t>=B.gT-r?41:189)|(e<0+n?224:e>=B.gT-n?7:231));this._currentRecordOverlaps|=o}_copyIntoNeighbors(){for(let t=0;t<8;t++){const e=1<<t;if(this._currentRecordOverlaps&e){if(!this._meshes.neighbors[t]){const s=Math.floor(this._sizeHint/16);this._meshes.neighbors[t]=new $(e,s)}const s=this._meshes.neighbors[t],i=-K(e)*B.gT,r=-Z(e)*B.gT;s.copyLastFrom(this._meshes.self,i,r)}}}}class J{}var tt=s(92400),et=s(62088),st=s(88264);const it=53290320,rt=10;function nt(t,e,s,i,r,n,o){if(t.primitiveName===e)for(const e in t)if(e===s){let s=i?.readWithDefault(r,n,t[e]&&o);return"text"===t.type&&(s=s.toString()),void(t[e]=s)}if("type"in t&&null!=t.type)switch(t.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":if(t.symbolLayers)for(const a of t.symbolLayers)nt(a,e,s,i,r,n,o);break;case"CIMHatchFill":t.lineSymbol&&nt(t.lineSymbol,e,s,i,r,n,o);break;case"CIMSolidStroke":case"CIMSolidFill":case"CIMVectorMarker":if("CIMVectorMarker"===t.type&&t.markerGraphics)for(const a of t.markerGraphics)nt(a,e,s,i,r,n,o),nt(a.symbol,e,s,i,r,n,o)}}class ot{destroy(){}}class at extends ot{constructor(t){super(),this._value=t}resize(t){}read(t,e){return this._value}readWithDefault(t,e,s){return this._value}referencesScale(){return!1}referencesGeometry(){return!1}}async function ht(t,e,s=!1){const{defaultValue:i,valueExpressionInfo:r,value:n}=e;if(r){const{expression:n}=r,o=await t.createComputedField({expression:n},s);return o?{...e,computed:o,defaultValue:i}:null}return{...e,computed:new at(n),defaultValue:i}}async function ct(t,e){const{defaultValue:s,valueExpressionInfo:i}=e,{expression:r}=i,n=await t.createComputedField({expression:r});return n?{...e,computed:n,defaultValue:s}:null}const lt=t=>"boolean"!=typeof t&&"number"!=typeof t&&"valueExpressionInfo"in t,ut=t=>t.some((t=>{for(const e in t){const s=t[e];if(lt(s))return!0}return!1}));class dt{static async create(t,e,s){const i={},r=new Map,n=new Map,o=new Map,a=new Map,h=new Map;for(const c in s.params){const l=s.params[c];if(null!=l&&"object"==typeof l)if(Array.isArray(l)){if("object"==typeof l[0])throw new Error(`InternalError: Cannot handle ${c}. Nested array params are not supported`);i[c]=l}else if("valueExpressionInfo"in l){if(l.value){i[c]=l.value;continue}const e=await ct(t,l);if(!e){i[c]=l.defaultValue;continue}r.set(c,e),i[c]=null}else switch(l.type){case"cim-effect-infos":if(l.effectInfos.some((t=>t.overrides.length))){n.set(c,{effects:await Promise.all(l.effectInfos.map((async e=>{const s=e.overrides.map((e=>ht(t,e)));return{effect:e.effect,compiledOverrides:(await Promise.all(s)).filter(tt.G6)}})))});break}i[c]=l.effectInfos.map((t=>t.effect));break;case"cim-marker-placement-info":l.overrides.length&&o.set(c,{placementInfo:l,compiledOverrides:(await Promise.all(l.overrides.map((e=>ht(t,e))))).filter(tt.G6)}),i[c]=l.placement;break;case"text-rasterization-param":{if(l.overrides.length){const e=l.overrides.map((e=>ht(t,e,l.useLegacyLabelEvaluationRules)));a.set(c,{compiledOverrides:(await Promise.all(e)).filter(tt.G6),rasterizationParam:l,objectIdToResourceId:new Map});continue}const s={type:"cim-rasterization-info",resource:l.resource};i[c]=await e.fetchResourceImmediate(s)??null;break}case"sprite-rasterization-param":{if(l.overrides.length){const e=l.overrides.map((e=>ht(t,e)));a.set(c,{compiledOverrides:(await Promise.all(e)).filter(tt.G6),rasterizationParam:l,objectIdToResourceId:new Map});continue}if("animated"===l.resource.type){a.set(c,{compiledOverrides:[],rasterizationParam:l,objectIdToResourceId:new Map});continue}const s={type:"cim-rasterization-info",resource:l.resource};i[c]=await e.fetchResourceImmediate(s)??null;break}case"cim-marker-transform-param":{const{params:e}=l;if(ut(e)){const s={compiledMarkerInfos:[]};await Promise.all(e.map((async e=>{const i={props:{}};for(const s in e)if(lt(e[s])){const r=await ct(t,e[s]);i.compiledExpressionMap||(i.compiledExpressionMap=new Map);const n=i.compiledExpressionMap;r&&n.set(s,r)}else i.props[s]=e[s];s.compiledMarkerInfos.push(i)}))),h.set(c,s)}else i[c]={type:"cim-marker-transform-info",infos:e};break}default:i[c]=l}else i[c]=l}return new dt(s,i,r,n,o,a,h)}constructor(t,e,s,i,r,n,o){this.inputMeshParams=t,this._resolvedMeshParams=e,this._dynamicProperties=s,this._dynamicEffectProperties=i,this._dynamicPlacementProperties=r,this._dynamicAsyncProperties=n,this._dynamicTransformProperties=o,this.evaluator=t=>t}get hasDynamicProperties(){return!!(this._dynamicProperties.size||this._dynamicAsyncProperties.size||this._dynamicEffectProperties.size||this._dynamicTransformProperties.size||this._dynamicPlacementProperties.size)}get evaluatedMeshParams(){return this._evaluatedMeshParams||(this._evaluatedMeshParams=this.evaluator(this._resolvedMeshParams)),this._evaluatedMeshParams}enqueueRequest(t,e,s){for(const n of this._dynamicAsyncProperties.values()){const o=(0,et.ct)(n.rasterizationParam.resource);"animated"===n.rasterizationParam.resource.type&&n.rasterizationParam.resource.randomizeStartTime&&(o.primitiveName="__RESERVED__PRIMITIVE__NAME__",o.startGroup=(r=e.getObjectId()||0,Math.floor(function(t,e){let s;if("string"==typeof t)s=(0,st.sV)(t+`-seed(${e})`);else{let i=12;s=t^e;do{s=107*(s>>8^s)+i|0}while(0!=--i)}return(1+s/(1<<31))/2}(r,it)*rt)));for(const{primitiveName:t,propertyName:r,computed:a,defaultValue:h,valueExpressionInfo:c}of n.compiledOverrides)try{nt(o,"animated"===n.rasterizationParam.resource.type?o.primitiveName:t,r,a,e,s,h)}catch(e){C.c.getLogger("geoscene.views.2d.engine.webgl.shaderGraph.techniques.mesh.MeshWriterInputEvaluator").errorOnce(new i.c("invalid-arcade-expression",`Encountered an error when evaluating the arcade expression '${c?.expression}' (primitive: '${t}', property: '${r}')`,e))}const a=t.enqueueRequest({type:"cim-rasterization-info",resource:o});n.objectIdToResourceId.set(e.getObjectId(),a)}var r}evaluateMeshParams(t,e,s){for(const[t,i]of this._dynamicProperties.entries())this._resolvedMeshParams[t]=i.computed.readWithDefault(e,s,i.defaultValue);for(const[t,i]of this._dynamicPlacementProperties.entries())for(const{computed:r,defaultValue:n,propertyName:o}of i.compiledOverrides){const a=r.readWithDefault(e,s,n);i.placementInfo.placement[o]=a,this._resolvedMeshParams[t]=i.placementInfo.placement}for(const[t,i]of this._dynamicEffectProperties.entries())for(const r of i.effects){for(const{computed:t,defaultValue:i,propertyName:n}of r.compiledOverrides){const o=t.readWithDefault(e,s,i);r.effect[n]=o}this._resolvedMeshParams[t]=i.effects.map((t=>t.effect))}for(const[t,i]of this._dynamicTransformProperties.entries()){const r={type:"cim-marker-transform-info",infos:[]};for(const t of i.compiledMarkerInfos){const i={...t.props};if(t.compiledExpressionMap)for(const[r,n]of t.compiledExpressionMap){const t=n.computed.readWithDefault(e,s,n.defaultValue);i[r]="number"==typeof t||"boolean"==typeof t?t:n.defaultValue}r.infos.push(i)}this._resolvedMeshParams[t]=r}for(const[s,i]of this._dynamicAsyncProperties.entries()){const r=i.objectIdToResourceId.get(e.getObjectId());if(null==r)continue;const n=t.getResource(r);this._resolvedMeshParams[s]=n}return this._evaluatedMeshParams=this.evaluator(this._resolvedMeshParams),this.evaluatedMeshParams}}var pt=s(30936),_t=(s(17012),s(93320)),ft=s(85152);function mt(t,e,s,i,r,n,o){Ut=0;const a=(i-s)*n,h=r&&r.length,c=h?(r[0]-s)*n:a;let l,u,d,p,_,f=gt(e,s,0,0,c,n,!0);if(f&&f.next!==f.prev){if(h&&(f=function(t,e,s,i,r,n){const o=new Array;for(let r=0,a=i.length;r<a;r++){const h=gt(t,e,0,i[r]*n,r<a-1?i[r+1]*n:s*n,n,!1);h===h.next&&(h.steiner=!0),o.push(It(h))}o.sort(Rt);for(const t of o)r=Tt(t,r);return r}(e,s,i,r,f,n)),a>80*n){l=d=e[0+s*n],u=p=e[1+s*n];for(let t=n;t<c;t+=n){const i=e[t+s*n],r=e[t+1+s*n];l=Math.min(l,i),u=Math.min(u,r),d=Math.max(d,i),p=Math.max(p,r)}_=Math.max(d-l,p-u),_=0!==_?1/_:0}xt(f,t,n,l,u,_,o,0)}}function gt(t,e,s,i,r,n,o){let a;if(o===function(t,e,s,i,r,n){let o=0;for(let s=i,a=r-n;s<r;s+=n)o+=(t[a+e*n]-t[s+e*n])*(t[s+1+e*n]+t[a+1+e*n]),a=s;return o}(t,e,0,i,r,n)>0)for(let s=i;s<r;s+=n)a=vt(s+e*n,t[s+e*n],t[s+1+e*n],a);else for(let s=r-n;s>=i;s-=n)a=vt(s+e*n,t[s+e*n],t[s+1+e*n],a);return a&&At(a,a.next)&&(St(a),a=a.next),a}function yt(t,e=t){if(!t)return t;let s,i=t;do{if(s=!1,i.steiner||!At(i,i.next)&&0!==Mt(i.prev,i,i.next))i=i.next;else{if(St(i),i=e=i.prev,i===i.next)break;s=!0}}while(s||i!==e);return e}function xt(t,e,s,i,r,n,o,a){if(!t)return;!a&&n&&(t=Pt(t,i,r,n));let h=t;for(;t.prev!==t.next;){const c=t.prev,l=t.next;if(n?wt(t,i,r,n):bt(t))e.push(c.index/s+o),e.push(t.index/s+o),e.push(l.index/s+o),St(t),t=l.next,h=l.next;else if((t=l)===h){a?1===a?xt(t=Ot(t,e,s,o),e,s,i,r,n,o,2):2===a&&Nt(t,e,s,i,r,n,o):xt(yt(t),e,s,i,r,n,o,1);break}}}function bt(t){const e=t.prev,s=t,i=t.next;if(Mt(e,s,i)>=0)return!1;let r=t.next.next;const n=r;let o=0;for(;r!==t.prev&&(0===o||r!==n);){if(o++,Ct(e.x,e.y,s.x,s.y,i.x,i.y,r.x,r.y)&&Mt(r.prev,r,r.next)>=0)return!1;r=r.next}return!0}function wt(t,e,s,i){const r=t.prev,n=t,o=t.next;if(Mt(r,n,o)>=0)return!1;const a=r.x<n.x?r.x<o.x?r.x:o.x:n.x<o.x?n.x:o.x,h=r.y<n.y?r.y<o.y?r.y:o.y:n.y<o.y?n.y:o.y,c=r.x>n.x?r.x>o.x?r.x:o.x:n.x>o.x?n.x:o.x,l=r.y>n.y?r.y>o.y?r.y:o.y:n.y>o.y?n.y:o.y,u=Ft(a,h,e,s,i),d=Ft(c,l,e,s,i);let p=t.prevZ,_=t.nextZ;for(;p&&p.z>=u&&_&&_.z<=d;){if(p!==t.prev&&p!==t.next&&Ct(r.x,r.y,n.x,n.y,o.x,o.y,p.x,p.y)&&Mt(p.prev,p,p.next)>=0)return!1;if(p=p.prevZ,_!==t.prev&&_!==t.next&&Ct(r.x,r.y,n.x,n.y,o.x,o.y,_.x,_.y)&&Mt(_.prev,_,_.next)>=0)return!1;_=_.nextZ}for(;p&&p.z>=u;){if(p!==t.prev&&p!==t.next&&Ct(r.x,r.y,n.x,n.y,o.x,o.y,p.x,p.y)&&Mt(p.prev,p,p.next)>=0)return!1;p=p.prevZ}for(;_&&_.z<=d;){if(_!==t.prev&&_!==t.next&&Ct(r.x,r.y,n.x,n.y,o.x,o.y,_.x,_.y)&&Mt(_.prev,_,_.next)>=0)return!1;_=_.nextZ}return!0}function vt(t,e,s,i){const r=Lt.create(t,e,s);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function St(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function It(t){let e=t,s=t;do{(e.x<s.x||e.x===s.x&&e.y<s.y)&&(s=e),e=e.next}while(e!==t);return s}function Tt(t,e){const s=function(t,e){let s=e;const i=t.x,r=t.y;let n,o=-1/0;do{if(r<=s.y&&r>=s.next.y&&s.next.y!==s.y){const t=s.x+(r-s.y)*(s.next.x-s.x)/(s.next.y-s.y);if(t<=i&&t>o){if(o=t,t===i){if(r===s.y)return s;if(r===s.next.y)return s.next}n=s.x<s.next.x?s:s.next}}s=s.next}while(s!==e);if(!n)return null;if(i===o)return n.prev;const a=n,h=n.x,c=n.y;let l,u=1/0;for(s=n.next;s!==a;)i>=s.x&&s.x>=h&&i!==s.x&&Ct(r<c?i:o,r,h,c,r<c?o:i,r,s.x,s.y)&&(l=Math.abs(r-s.y)/(i-s.x),(l<u||l===u&&s.x>n.x)&&kt(s,t)&&(n=s,u=l)),s=s.next;return n}(t,e);if(!s)return e;const i=zt(s,t);return yt(i,i.next),yt(s,s.next)}function Pt(t,e,s,i){let r;for(;r!==t;r=r.next){if(r=r||t,null===r.z&&(r.z=Ft(r.x,r.y,e,s,i)),r.prev.next!==r||r.next.prev!==r)return r.prev.next=r,r.next.prev=r,Pt(t,e,s,i);r.prevZ=r.prev,r.nextZ=r.next}return t.prevZ.nextZ=null,t.prevZ=null,function(t){let e,s=1;for(;;){let i,r=t;t=null,e=null;let n=0;for(;r;){n++,i=r;let o=0;for(;o<s&&i;o++)i=i.nextZ;let a=s;for(;o>0||a>0&&i;){let s;0===o?(s=i,i=i.nextZ,a--):0!==a&&i?r.z<=i.z?(s=r,r=r.nextZ,o--):(s=i,i=i.nextZ,a--):(s=r,r=r.nextZ,o--),e?e.nextZ=s:t=s,s.prevZ=e,e=s}r=i}if(e.nextZ=null,s*=2,n<2)return t}}(t)}function Mt(t,e,s){return(e.y-t.y)*(s.x-e.x)-(e.x-t.x)*(s.y-e.y)}function Et(t,e,s,i){return!!(At(t,e)&&At(s,i)||At(t,i)&&At(s,e))||Mt(t,e,s)>0!=Mt(t,e,i)>0&&Mt(s,i,t)>0!=Mt(s,i,e)>0}function Ct(t,e,s,i,r,n,o,a){return(r-o)*(e-a)-(t-o)*(n-a)>=0&&(t-o)*(i-a)-(s-o)*(e-a)>=0&&(s-o)*(n-a)-(r-o)*(i-a)>=0}function kt(t,e){return Mt(t.prev,t,t.next)<0?Mt(t,e,t.next)>=0&&Mt(t,t.prev,e)>=0:Mt(t,e,t.prev)<0||Mt(t,t.next,e)<0}function Ft(t,e,s,i,r){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-s)*r)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-i)*r)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function At(t,e){return t.x===e.x&&t.y===e.y}function Rt(t,e){return t.x-e.x}function Ot(t,e,s,i){let r=t;do{const n=r.prev,o=r.next.next;!At(n,o)&&Et(n,r,r.next,o)&&kt(n,o)&&kt(o,n)&&(e.push(n.index/s+i),e.push(r.index/s+i),e.push(o.index/s+i),St(r),St(r.next),r=t=o),r=r.next}while(r!==t);return r}function Nt(t,e,s,i,r,n,o){let a=t;do{let t=a.next.next;for(;t!==a.prev;){if(a.index!==t.index&&Dt(a,t)){let h=zt(a,t);return a=yt(a,a.next),h=yt(h,h.next),xt(a,e,s,i,r,n,o,0),void xt(h,e,s,i,r,n,o,0)}t=t.next}a=a.next}while(a!==t)}function Dt(t,e){return t.next.index!==e.index&&t.prev.index!==e.index&&!function(t,e){let s=t;do{if(s.index!==t.index&&s.next.index!==t.index&&s.index!==e.index&&s.next.index!==e.index&&Et(s,s.next,t,e))return!0;s=s.next}while(s!==t);return!1}(t,e)&&kt(t,e)&&kt(e,t)&&function(t,e){let s=t,i=!1;const r=(t.x+e.x)/2,n=(t.y+e.y)/2;do{s.y>n!=s.next.y>n&&s.next.y!==s.y&&r<(s.next.x-s.x)*(n-s.y)/(s.next.y-s.y)+s.x&&(i=!i),s=s.next}while(s!==t);return i}(t,e)}function zt(t,e){const s=Lt.create(t.index,t.x,t.y),i=Lt.create(e.index,e.x,e.y),r=t.next,n=e.prev;return t.next=e,e.prev=t,s.next=r,r.prev=s,i.next=s,s.prev=i,n.next=i,i.prev=n,i}class Lt{constructor(){this.index=0,this.x=0,this.y=0,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}static create(t,e,s){const i=Ut<Bt.length?Bt[Ut++]:new Lt;return i.index=t,i.x=e,i.y=s,i.prev=null,i.next=null,i.z=null,i.prevZ=null,i.nextZ=null,i.steiner=!1,i}}const Bt=[];let Ut=0;for(let t=0;t<8096;t++)Bt.push(new Lt);const Gt=new _t.CU(0,0,0,1,0),Vt=new _t.CU(0,0,0,1,0);function qt(t,e,s){let i=0;for(let r=1;r<s;r++){const s=t[2*(e+r-1)],n=t[2*(e+r-1)+1];i+=(t[2*(e+r)]-s)*(t[2*(e+r)+1]+n)}return i}function Wt(t,e,s,i,r){let n=0;for(let o=s;o<i;o+=3){const s=2*(t[o]-r),i=2*(t[o+1]-r),a=2*(t[o+2]-r);n+=Math.abs((e[s]-e[a])*(e[i+1]-e[s+1])-(e[s]-e[i])*(e[a+1]-e[s+1]))}return n}Gt.setExtent(B.gT),Vt.setExtent(B.gT);var Xt=s(68564),Yt=s(6704);class jt{static fromOptimized(t,e,s=!1,i=!1,r=1){return(new Ht).initialize(t,e,s,i,r)}static fromJSON(t,e=!1,s=!1){const[i,r]=Kt(t);return(new Zt).initialize(i,r,e,s,1)}static fromOptimizedCIM(t,e,s=!1,i=!1,r=1){return(new Qt).initialize(t,e,s,i,r)}static fromJSONCIM(t,e=!1,s=!1,i=1){const[r,n]=Kt(t);return(new Jt).initialize(r,n,e,s,i)}static fromFeatureSetReader(t){const e=t.readGeometryForDisplay(),s=t.geometryType;return e&&s?this.fromOptimized(e,s):null}static fromFeatureSetReaderCIM(t){const e=t.readGeometryForDisplay(),s=t.geometryType;return e&&s?this.fromOptimizedCIM(e,s):null}static createEmptyOptimized(t,e=!1,s=!1,i=1){return(new Ht).initialize(new ft.c,t,e,s,i)}static createEmptyJSON(t,e=!1,s=!1){return(new Zt).initialize([],t,e,s,1)}static createEmptyOptimizedCIM(t,e=!1,s=!1,i=1){return(new Qt).initialize(new ft.c,t,e,s,i)}static createEmptyJSONCIM(t,e=!1,s=!1,i=1){return(new Jt).initialize([],t,e,s,i)}asJSON(){const t=(0,Xt.k)(this);return"esriGeometryEnvelope"===this.geometryType?{xmin:t[0][0][0],ymin:t[0][0][1],xmax:t[0][2][0],ymax:t[0][2][1]}:"esriGeometryMultipoint"===this.geometryType?{points:t.flat()}:"esriGeometryPoint"===this.geometryType?{x:t[0][0][0],y:t[0][0][1]}:"esriGeometryPolygon"===this.geometryType?{rings:t}:{paths:t}}getCurrentRingArea(){if(this.pathSize<3)return 0;let t,e,s=0;if(this.seekPathStart(),!this.nextPoint())return 0;t=this.x,e=this.y;const i=t,r=e;for(;this.nextPoint();)s+=(t-this.x)*(e+this.y),t=this.x,e=this.y;return s+=(t-i)*(e+r),-.5*s}invertY(){this.yFactor*=-1}}class Ht extends jt{constructor(){super(...arguments),this._end=-1}initialize(t,e,s,i,r){return this.hasZ=s,this.hasM=i,this.geometryType=e,this._stride=2+Number(s)+Number(i),this._geometry=t,this._pathIndex=-1,this._pathOffset=0,this._pointOffset=-this._stride,this._end=-1,this.yFactor=r,this}reset(){this.initialize(this._geometry,this.geometryType,this.hasZ,this.hasM,this.yFactor)}seekPath(t){if(t>=0&&t<this.totalSize){if(this._pathIndex<t)for(;this._pathIndex<t&&this.nextPath(););else if(this._pathIndex>t)for(;this._pathIndex>t&&this.prevPath(););return!0}return!1}seekPathStart(){this._pointOffset=this._pathOffset-this._stride}seekPathEnd(){this._pointOffset=this._end}seekInPath(t){const e=this._pathOffset+t*this._stride;return e>=0&&e<this._end&&(this._pointOffset=e,!0)}nextPoint(){return(this._pointOffset+=this._stride)<this._end}prevPoint(){return(this._pointOffset-=this._stride)>=this._pathOffset}nextPath(){return!(this.pathIndex>=this.totalSize-1||(this._pathIndex>=0&&(this._pathOffset+=this._stride*this.pathSize),this._pathIndex++,this._pointOffset=this._pathOffset-this._stride,this._end=this._pointOffset+this._stride+this._stride*this.pathSize,0))}prevPath(){return!(this.pathIndex<=0||(this._pathIndex--,this._end=this._pathOffset,this._pathOffset-=this._stride*this.pathSize,this._pointOffset=this._pathOffset-this._stride,0))}pathLength(){const t=this._end,e=this._stride,s=this._geometry.coords;let i=0;for(let r=this._pathOffset+e;r<t;r+=e){const t=s[r-e],n=s[r-e+1],o=s[r]-t,a=s[r+1]-n;i+=Math.sqrt(o*o+a*a)}return i}startPath(){this._geometry.lengths.push(0)}pushPath(t){this.startPath(),this.pushPoints(t)}pushPoint(t){for(let e=0;e<this._stride;++e)this._geometry.coords.push(t[e]);this._geometry.lengths[this.totalSize-1]++}pushXY(t,e){this._geometry.coords.push(t,e),this._geometry.lengths[this.totalSize-1]++}pushPoints(t){for(const e of t)for(let t=0;t<this._stride;++t)this._geometry.coords.push(e[t]);this._geometry.lengths[this.totalSize-1]+=t.length}pushCursor(t){const e=t.asOptimized();this._geometry.coords.push(...e.coords),this._geometry.lengths.push(...e.lengths)}asOptimized(){const t=this._geometry.clone();if(1!==this.yFactor)for(let e=1;e<t.coords.length;e+=this._stride)t.coords[e]*=this.yFactor;return"esriGeometryPoint"===this.geometryType&&(t.lengths.length=0),t}isClosed(){const t=this._geometry.coords,e=this._pathOffset,s=this._end-this._stride;for(let i=0;i<this._stride;i++)if(t[e+i]!==t[s+i])return!1;return!0}clone(){return(new Ht).initialize(this._geometry.clone(),this.geometryType,this.hasZ,this.hasM,this.yFactor)}get totalPoints(){return this._geometry.isPoint?1:this._geometry.lengths.reduce(((t,e)=>t+e))}get pathSize(){const{lengths:t}=this._geometry;return this._pathIndex<0||this._pathIndex>t.length-1?0:this._geometry.isPoint?1:t[this._pathIndex]}get totalSize(){return this._geometry.lengths.length}get x(){return this._geometry.coords[this._pointOffset]}set x(t){this._geometry.coords[this._pointOffset]=t}get y(){return this.yFactor*this._geometry.coords[this._pointOffset+1]}set y(t){this._geometry.coords[this._pointOffset+1]=this.yFactor*t}get z(){return this._geometry.coords[this._pointOffset+2]}set z(t){this._geometry.coords[this._pointOffset+2]=t}get m(){const t=this.hasZ?3:2;return this._geometry.coords[this._pointOffset+t]}set m(t){this._geometry.coords[this._pointOffset+3]=t}get pathIndex(){return this._pathIndex}get _coordIndex(){return this._pointOffset/this._stride}}function $t(t){const e=[t.x,t.y];return t.z&&e.push(t.z),t.m&&e.push(t.m),e}function Kt(t){return(0,Yt.Cs)(t)?[t.rings,"esriGeometryPolygon"]:(0,Yt.cZ)(t)?[t.paths,"esriGeometryPolyline"]:(0,Yt._)(t)?[[t.points],"esriGeometryMultipoint"]:(0,Yt.Ul)(t)?[[[[t.xmin,t.ymin],[t.xmin,t.ymax],[t.xmax,t.ymax],[t.xmax,t.ymin],[t.xmin,t.ymin]]],"esriGeometryEnvelope"]:(0,Yt._x)(t)?[[[$t(t)]],"esriGeometryPoint"]:[[],"esriGeometryPolyline"]}class Zt extends jt{initialize(t,e,s,i,r){return this._paths=t,this.geometryType=e,this.hasZ=s,this.hasM=i,this._pathIndex=this._pointIndex=-1,this.yFactor=r,this._mIndex=this.hasZ?3:2,this}reset(){this._pathIndex=this._pointIndex=-1}seekPath(t){return this._pathIndex=t,this._pointIndex=-1,t>=0&&t<this.totalSize&&(this._currentPath=this._paths[t],!0)}seekPathStart(){this._pointIndex=-1}seekPathEnd(){this._pointIndex=this._currentPath.length}seekInPath(t){return t>=0&&t<this._currentPath.length&&(this._pointIndex=t,this._currentPoint=this._currentPath[this._pointIndex],!0)}nextPoint(){return this._currentPoint=this._currentPath[++this._pointIndex],this._pointIndex<this._currentPath.length}prevPoint(){return this._currentPoint=this._currentPath[--this._pointIndex],this._pointIndex>=0}nextPath(){return this._pointIndex=-1,this._currentPath=this._paths[++this._pathIndex],this._pathIndex<this.totalSize}prevPath(){return this.pathIndex>0&&(this._pointIndex=-1,this._pathIndex--,this._currentPath=this._paths[this._pathIndex],!0)}pathLength(){const t=this._currentPath.length,e=this._currentPath;let s=0;for(let i=1;i<t;i++){const t=e[i-1],r=e[i],n=t[0],o=t[1],a=r[0]-n,h=r[1]-o;s+=Math.sqrt(a*a+h*h)}return s}startPath(){this._paths.push([])}pushPath(t){this._paths.push(t)}pushPoint(t){this._paths[this.totalSize-1].push(t)}pushXY(t,e){this._paths[this.totalSize-1].push([t,e])}pushPoints(t){this._paths[this.totalSize-1].push(...t)}pushCursor(t){const e=(0,Xt.k)(t);for(const t of e)this.pushPath(t)}asOptimized(){const t=new ft.c;if("esriGeometryPoint"===this.geometryType)t.coords.push(...this._paths[0][0]),t.lengths.length=0;else for(const e of this._paths){for(const s of e)t.coords.push(s[0]),t.coords.push(s[1]*this.yFactor),this.hasZ&&t.coords.push(s[2]),this.hasM&&t.coords.push(s[this._mIndex]);t.lengths.push(e.length)}return t}isClosed(){const t=this._currentPath[0],e=this._currentPath[this._currentPath.length-1];for(let s=0;s<t.length;s++)if(t[s]!==e[s])return!1;return!0}clone(){return(new Zt).initialize((0,et.ct)(this._paths),this.geometryType,this.hasZ,this.hasM,this.yFactor)}get totalPoints(){return this._paths.map((t=>t.length)).reduce(((t,e)=>t+e))}get pathSize(){return this._pathIndex<0||this._pathIndex>this.totalSize-1?-1:this._paths[this._pathIndex].length}get totalSize(){return this._paths.length}get x(){return this._currentPoint[0]}set x(t){this._currentPoint[0]=t}get y(){return this.yFactor*this._currentPoint[1]}set y(t){this._currentPoint[1]=this.yFactor*t}get z(){return this._currentPoint[2]}set z(t){this._currentPoint[2]=t}get m(){return this._currentPoint[this._mIndex]}set m(t){this._currentPoint[this._mIndex]=t}get pathIndex(){return this._pathIndex}}class Qt extends Ht{initialize(t,e,s,i,r){return super.initialize(t,e,s,i,r),this._controlPoints||(this._controlPoints=this._controlPoints=new Array(this.totalSize).fill(void 0).map((t=>new Set))),this}startPath(){super.startPath(),this._controlPoints.push(new Set)}clone(){const t=(new Qt).initialize(this._geometry.clone(),this.geometryType,this.hasZ,this.hasM,this.yFactor);return t._controlPoints=this._controlPoints,t}setControlPoint(){this._controlPoints[this.pathIndex].add(this._coordIndex)}getControlPoint(){return this._controlPoints[this.pathIndex].has(this._coordIndex)}setControlPointAt(t){this._controlPoints[this.pathIndex].add(t)}getControlPointAt(t){return this._controlPoints[this.pathIndex].has(t)}}class Jt extends Zt{initialize(t,e,s,i,r){return super.initialize(t,e,s,i,r)}clone(){return(new Jt).initialize((0,et.ct)(this._paths),this.geometryType,this.hasZ,this.hasM,this.yFactor)}setControlPoint(){this._paths[this.pathIndex][this._pointIndex][4]=1}getControlPoint(){return 1===this._paths[this.pathIndex][this._pointIndex][4]}setControlPointAt(t){this._paths[this.pathIndex][t][4]=1}getControlPointAt(t){return 1===this._paths[this.pathIndex][t][4]}}let te;class ee{constructor(t){this._geometry=t}next(){const t=this._geometry;return this._geometry=null,t}}function se(t,e){te||(te=new _t.CU(0,0,0,1));const s="esriGeometryPolygon"===t.geometryType,i=s?_t.ao.Polygon:_t.ao.LineString,r=s?3:2;let n,o;for(te.reset(i),te.setPixelMargin(e+1),te.setExtent(512);t.nextPath();)if(!(t.pathSize<r)){for(t.nextPoint(),n=t.x,o=-t.y,te.moveTo(n,o);t.nextPoint();)n=t.x,o=-t.y,te.lineTo(n,o);s&&te.close()}const a=te.result(!1);if(a){const e=jt.createEmptyOptimizedCIM(t.geometryType);for(const t of a){e.startPath();for(const s of t)e.pushXY(s.x,-s.y)}return e.reset(),e}return null}class ie{static local(){return null===ie.instance&&(ie.instance=new ie),ie.instance}execute(t,e,s,i,r){return new re(t,e,s)}}ie.instance=null;class re{constructor(t,e,s){this._inputGeometries=t,this._angleTolerance=void 0!==e.angleTolerance?e.angleTolerance:120,this._maxCosAngle=Math.cos((1-Math.abs(this._angleTolerance)/180)*Math.PI)}next(){let t=this._inputGeometries.next();for(;t;){if("esriGeometryPolygon"===t.geometryType)this._isClosed=!0;else if("esriGeometryPolyline"===t.geometryType)this._isClosed=!1;else{if("esriGeometryEnvelope"!==t.geometryType){t=this._inputGeometries.next();continue}if(this._maxCosAngle)return t;this._isClosed=!0}for(;t.nextPath();)this._processPath(t);return t.reset(),t}return null}_processPath(t){if(t.nextPoint()){const e=t.x,s=t.y;let i=e,r=s,n=t.pathSize,o=0,a=0,h=0,c=0,l=0,u=0;this._isClosed&&++n;for(let d=1;t.nextPoint()||d<n;++d){let p,_;this._isClosed&&d===n-1?(p=e,_=s):(p=t.x,_=t.y);const f=p-i,m=_-r,g=Math.sqrt(f*f+m*m);d>1&&g>0&&h>0&&(o*f+a*m)/g/h<=this._maxCosAngle&&t.setControlPointAt(d-1),1===d&&(c=f,l=m,u=g),g>0&&(i=p,r=_,o=f,a=m,h=g)}this._isClosed&&h>0&&u>0&&(o*c+a*l)/u/h<=this._maxCosAngle&&t.setControlPointAt(0)}}}class ne{constructor(){this.setIdentity()}getAngle(){return(null==this.rz||0===this.rz&&1!==this.rzCos&&0!==this.rzSin)&&(this.rz=Math.atan2(this.rzSin,this.rzCos)),this.rz}setIdentity(){this.tx=0,this.ty=0,this.tz=0,this.s=1,this.rx=0,this.ry=0,this.rz=0,this.rzCos=1,this.rzSin=0}setTranslate(t,e){this.tx=t,this.ty=e}setTranslateZ(t){this.tz=t}setRotateCS(t,e){this.rz=void 0,this.rzCos=t,this.rzSin=e}setRotate(t){this.rz=t,this.rzCos=void 0,this.rzSin=void 0}setRotateY(t){this.ry=t}setScale(t){this.s=t}setMeasure(t){this.m=t}}function oe(t,e){t[4]=e}class ae{constructor(t,e=!0,s=!0,i=0){this.isClosed=!1,this.geometryCursor=null,this.geometryCursor=!e&&"esriGeometryPolygon"===t.geometryType||!s&&"esriGeometryPolyline"===t.geometryType?null:t,this.geomUnitsPerPoint=i,this.iteratePath=!1,this.internalPlacement=new ne}next(){if(!this.geometryCursor)return null;for(;this.iteratePath||this.geometryCursor.pathIndex<this.geometryCursor.totalSize-1;){this.iteratePath||this.geometryCursor.nextPath();const t=this.processPath(this.geometryCursor);if(t)return t}return this.geometryCursor=null,null}}class he{constructor(t,e,s,i=0){this.isClosed=!1,this.inputGeometries=t,this.acceptPolygon=e,this.acceptPolyline=s,this.geomUnitsPerPoint=i,this.iteratePath=!1,this.multiPathCursor=null}next(){for(;;){if(!this.multiPathCursor){let t=this.inputGeometries.next();for(;t&&(this.isClosed=this.acceptPolygon&&"esriGeometryPolygon"===t.geometryType||"esriGeometryEnvelope"===t.geometryType,this.multiPathCursor=t,!this.multiPathCursor);)t=this.inputGeometries.next();if(!this.multiPathCursor)return null}for(;this.iteratePath||this.multiPathCursor.nextPath();){this.multiPathCursor.seekPathStart();const t=this.processPath(this.multiPathCursor);if(t)return t}this.multiPathCursor=null}}}var ce=s(89232);const le=.03;class ue{constructor(t=0,e=!1){}isEmpty(t){if(!t.nextPoint())return!0;let e,s,i,r;for(e=t.x,s=t.y;t.nextPoint();e=s,s=r)if(i=t.x,r=t.y,i!==e||r!==s)return t.seekPathStart(),!1;return t.seekPathStart(),!0}normalize(t){const e=Math.sqrt(t[0]*t[0]+t[1]*t[1]);0!==e&&(t[0]/=e,t[1]/=e)}getLength(t,e,s,i){const r=s-t,n=i-e;return Math.sqrt(r*r+n*n)}getSegLength(t){const[[e,s],[i,r]]=t;return this.getLength(e,s,i,r)}getCoord2D(t,e,s,i,r){return[t+(s-t)*r,e+(i-e)*r]}getSegCoord2D(t,e){const[[s,i],[r,n]]=t;return this.getCoord2D(s,i,r,n,e)}getAngle(t,e,s,i,r){const n=s-t,o=i-e;return Math.atan2(o,n)}getAngleCS(t,e,s,i,r){const n=s-t,o=i-e,a=Math.sqrt(n*n+o*o);return a>0?[n/a,o/a]:[1,0]}getSegAngleCS(t,e){const[[s,i],[r,n]]=t;return this.getAngleCS(s,i,r,n,e)}cut(t,e,s,i,r,n){return[r<=0?[t,e]:this.getCoord2D(t,e,s,i,r),n>=1?[s,i]:this.getCoord2D(t,e,s,i,n)]}getSubCurve(t,e,s){const i=jt.createEmptyOptimizedCIM("esriGeometryPolyline");return this.appendSubCurve(i,t,e,s)?i:null}appendSubCurve(t,e,s,i){t.startPath(),e.seekPathStart();let r=0,n=!0;if(!e.nextPoint())return!1;let o=e.x,a=e.y;for(;e.nextPoint();){const h=this.getLength(o,a,e.x,e.y);if(0!==h){if(n){if(r+h>s){const c=(s-r)/h;let l=1,u=!1;r+h>=i&&(l=(i-r)/h,u=!0);const d=this.cut(o,a,e.x,e.y,c,l);if(d&&t.pushPoints(d),u)break;n=!1}}else{if(r+h>i){const s=this.cut(o,a,e.x,e.y,0,(i-r)/h);s&&t.pushPoint(s[1]);break}t.pushXY(e.x,e.y)}r+=h,o=e.x,a=e.y}else o=e.x,a=e.y}return!0}getCIMPointAlong(t,e){if(!t.nextPoint())return null;let s,i,r,n,o=0;for(s=t.x,i=t.y;t.nextPoint();s=r,i=n){r=t.x,n=t.y;const a=this.getLength(s,i,r,n);if(0!==a){if(o+a>e){const t=(e-o)/a;return this.getCoord2D(s,i,r,n,t)}o+=a}}return null}offset(t,e,s,i,r){if(!t||t.length<2)return null;let n=0,o=t[n++],a=n;for(;n<t.length;){const e=t[n];e[0]===o[0]&&e[1]===o[1]||(n!==a&&(t[a]=t[n]),o=t[a++]),n++}const h=t[0][0]===t[a-1][0]&&t[0][1]===t[a-1][1];if(h&&--a,a<(h?3:2))return null;const c=[];o=h?t[a-1]:null;let l=t[0];for(let r=0;r<a;r++){const n=r===a-1?h?t[0]:null:t[r+1];if(o)if(n){const t=[n[0]-l[0],n[1]-l[1]];this.normalize(t);const r=[l[0]-o[0],l[1]-o[1]];this.normalize(r);const a=r[0]*t[1]-r[1]*t[0],h=r[0]*t[0]+r[1]*t[1];if(0===a&&1===h){l=n;continue}if(a>=0==e<=0){if(h<1){const s=[t[0]-r[0],t[1]-r[1]];this.normalize(s);const n=Math.sqrt((1+h)/2);if(n>1/i){const t=-Math.abs(e)/n;c.push([l[0]-s[0]*t,l[1]-s[1]*t])}}}else switch(s){case ce.yM.Mitered:{const s=Math.sqrt((1+h)/2);if(s>0&&1/s<i){const i=[t[0]-r[0],t[1]-r[1]];this.normalize(i);const n=Math.abs(e)/s;c.push([l[0]-i[0]*n,l[1]-i[1]*n]);break}}case ce.yM.Bevelled:c.push([l[0]+r[1]*e,l[1]-r[0]*e]),c.push([l[0]+t[1]*e,l[1]-t[0]*e]);break;case ce.yM.Rounded:if(h<1){c.push([l[0]+r[1]*e,l[1]-r[0]*e]);const s=Math.floor(2.5*(1-h));if(s>0){const i=1/s;let n=i;for(let o=1;o<s;o++,n+=i){const s=[r[1]*(1-n)+t[1]*n,-r[0]*(1-n)-t[0]*n];this.normalize(s),c.push([l[0]+s[0]*e,l[1]+s[1]*e])}}c.push([l[0]+t[1]*e,l[1]-t[0]*e])}break;case ce.yM.Square:default:if(a<0)c.push([l[0]+(r[1]+r[0])*e,l[1]+(r[1]-r[0])*e]),c.push([l[0]+(t[1]-t[0])*e,l[1]-(t[0]+t[1])*e]);else{const s=Math.sqrt((1+Math.abs(h))/2),i=[t[0]-r[0],t[1]-r[1]];this.normalize(i);const n=e/s;c.push([l[0]-i[0]*n,l[1]-i[1]*n])}}}else{const t=[l[0]-o[0],l[1]-o[1]];this.normalize(t),c.push([l[0]+t[1]*e,l[1]-t[0]*e])}else{const t=[n[0]-l[0],n[1]-l[1]];this.normalize(t),c.push([l[0]+t[1]*e,l[1]-t[0]*e])}o=l,l=n}return c.length<(h?3:2)?null:(h&&c.push([c[0][0],c[0][1]]),c)}}const de=ce.AX.OpenEnded;class pe{static local(){return null===pe.instance&&(pe.instance=new pe),pe.instance}execute(t,e,s,i,r){return new _e(t,e,s)}}pe.instance=null;class _e extends he{constructor(t,e,s){super(t,!1,!0),this._curveHelper=new ue,this._width=(void 0!==e.width?e.width:5)*s,this._arrowType=void 0!==e.geometricEffectArrowType?e.geometricEffectArrowType:void 0!==e.arrowType?e.arrowType:de,this._offsetFlattenError=le*s}processPath(t){const e=jt.createEmptyOptimizedCIM(t.geometryType);switch(this._arrowType){case ce.AX.OpenEnded:default:this._constructSimpleArrow(e,t,!0);break;case ce.AX.Block:this._constructSimpleArrow(e,t,!1);break;case ce.AX.Crossed:this._constructCrossedArrow(e,t)}return e}_constructSimpleArrow(t,e,s){const i=e.pathLength();let r=this._width;i<2*r&&(r=i/2);const n=this._curveHelper.getSubCurve(e,0,i-r);if(!n||!n.nextPath())return;n.seekPathStart();const o=r/2;if(this._curveHelper.isEmpty(n))return;const a=(0,Xt.g)(n),h=this._constructOffset(a,-o);if(!h)return;const c=this._constructOffset(a,o);if(!c)return;const l=this._constructArrowBasePoint(h,-o/2);if(!l)return;const u=this._constructArrowBasePoint(c,o/2);if(!u)return;e.seekInPath(e.pathSize-1);const d=[e.x,e.y];t.pushPath(c),t.nextPath(),t.nextPoint(),t.setControlPoint(),t.pushPoint(u),t.nextPoint(),t.setControlPoint(),t.pushPoint(d),t.nextPoint(),t.setControlPoint(),t.pushPoint(l),t.nextPoint(),t.setControlPoint(),t.pushPoints(h.reverse()),t.setControlPoint(),s||(t.setControlPointAt(0),t.setControlPointAt(t.pathSize-1),t.pushPoint(c[0])),t.reset()}_constructCrossedArrow(t,e){const s=e.pathLength();let i=this._width;s<3.732050807568877*i&&(i=s/3.732050807568877),e.seekPathStart();const r=this._curveHelper.getSubCurve(e,0,s-2.732050807568877*i);if(!r)return;r.nextPath();const n=i/2;if(this._curveHelper.isEmpty(r))return;const o=(0,Xt.g)(r),a=this._constructOffset(o,n);if(!a)return;const h=this._constructOffset(o,-n);if(!h)return;const c=this._curveHelper.getSubCurve(e,0,s-i);if(!c)return;if(c.nextPath(),this._curveHelper.isEmpty(c))return;const l=(0,Xt.g)(c),u=this._constructOffset(l,n);if(!u)return;const d=this._constructOffset(l,-n);if(!d)return;const p=u[u.length-1],_=this._constructArrowBasePoint(u,n/2);if(!_)return;const f=d[d.length-1],m=this._constructArrowBasePoint(d,-n/2);if(!m)return;e.seekInPath(e.pathSize-1);const g=[e.x,e.y];t.pushPath(a),t.nextPath(),t.nextPoint(),t.setControlPoint(),t.pushPoint(f),t.nextPoint(),t.setControlPoint(),t.pushPoint(m),t.nextPoint(),t.setControlPoint(),t.pushPoint(g),t.nextPoint(),t.setControlPoint(),t.pushPoint(_),t.nextPoint(),t.setControlPoint(),t.pushPoint(p),t.nextPoint(),t.setControlPoint(),t.pushPoints(h.reverse()),t.nextPoint(),t.setControlPoint(),t.reset()}_constructOffset(t,e){return this._curveHelper.offset(t,e,ce.yM.Rounded,4,this._offsetFlattenError)}_constructArrowBasePoint(t,e){if(!t||t.length<2)return null;const s=t[t.length-2],i=t[t.length-1],r=[i[0]-s[0],i[1]-s[1]];return this._curveHelper.normalize(r),[i[0]+r[1]*e,i[1]-r[0]*e]}}s(60708);class fe{static local(){return null===fe.instance&&(fe.instance=new fe),fe.instance}execute(t,e,s,i,r,n){return new me(t,e,s,i,r,n)}}fe.instance=null;class me{constructor(t,e,s,i,r,n){this._inputGeometries=t,this._tileKey=i,this._geometryEngine=r,this._curveHelper=new ue,this._size=(void 0!==e.size?e.size:1)*s,this._maxInflateSize=n*s,this._offsetFlattenError=le*s}next(){let t;for(;t=this._inputGeometries.next();){if(0===this._size)return t;if("esriGeometryEnvelope"===t.geometryType)if(this._size>0){const e=jt.createEmptyOptimizedCIM(t.geometryType),s=(0,Xt.k)(t)[0],i=this._curveHelper.offset(s,this._size,ce.yM.Rounded,4,this._offsetFlattenError);if(i)return e.pushPath(i),e}else if(this._size<0){const e=t.asJSON();if(Math.min(e.xmax-e.xmin,e.ymax-e.ymin)+2*this._size>0)return jt.fromJSONCIM({xmin:e.xmin-this._size,xmax:e.xmax+this._size,ymin:e.ymin-this._size,ymax:e.ymax+this._size})}const e=this._geometryEngine;if(null==e)return null;const s=this._tileKey?se(t,this._maxInflateSize):t;if(!s)continue;const i=e.buffer(V.c.WebMercator,s.asJSON(),this._size,1);return i?jt.fromJSONCIM(i):null}return null}}class ge{static local(){return null===ge.instance&&(ge.instance=new ge),ge.instance}execute(t,e,s,i,r){return new ye(t,e,s)}}ge.instance=null;class ye{constructor(t,e,s){this._defaultPointSize=20,this._inputGeometries=t,this._geomUnitsPerPoint=s,this._rule=e.rule??ce.Ki.FullGeometry,this._defaultSize=this._defaultPointSize*s}next(){let t;for(;t=this._inputGeometries.next();){const e=this._processGeom((0,Xt.k)(t));if(e&&e.length)return jt.fromJSONCIM({paths:e})}return null}_clone(t){return[t[0],t[1]]}_mid(t,e){return[(t[0]+e[0])/2,(t[1]+e[1])/2]}_mix(t,e,s,i){return[t[0]*e+s[0]*i,t[1]*e+s[1]*i]}_add(t,e){return[t[0]+e[0],t[1]+e[1]]}_add2(t,e,s){return[t[0]+e,t[1]+s]}_sub(t,e){return[t[0]-e[0],t[1]-e[1]]}_dist(t,e){return Math.sqrt((t[0]-e[0])*(t[0]-e[0])+(t[1]-e[1])*(t[1]-e[1]))}_norm(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}_normalize(t,e=1){const s=e/this._norm(t);t[0]*=s,t[1]*=s}_leftPerpendicular(t){const e=-t[1],s=t[0];t[0]=e,t[1]=s}_leftPerp(t){return[-t[1],t[0]]}_rightPerpendicular(t){const e=t[1],s=-t[0];t[0]=e,t[1]=s}_rightPerp(t){return[t[1],-t[0]]}_dotProduct(t,e){return t[0]*e[0]+t[1]*e[1]}_crossProduct(t,e){return t[0]*e[1]-t[1]*e[0]}_rotateDirect(t,e,s){const i=t[0]*e-t[1]*s,r=t[0]*s+t[1]*e;t[0]=i,t[1]=r}_makeCtrlPt(t){const e=[t[0],t[1]];return oe(e,1),e}_addAngledTicks(t,e,s,i){const r=this._sub(s,e);this._normalize(r);const n=this._crossProduct(r,this._sub(i,e));let o;o=n>0?this._rightPerp(r):this._leftPerp(r);const a=Math.abs(n)/2,h=[];h.push([e[0]+(o[0]-r[0])*a,e[1]+(o[1]-r[1])*a]),h.push(e),h.push(s),h.push([s[0]+(o[0]+r[0])*a,s[1]+(o[1]+r[1])*a]),t.push(h)}_addBezier2(t,e,s,i,r){if(0==r--)return void t.push(i);const n=this._mid(e,s),o=this._mid(s,i),a=this._mid(n,o);this._addBezier2(t,e,n,a,r),this._addBezier2(t,a,o,i,r)}_addBezier3(t,e,s,i,r,n){if(0==n--)return void t.push(r);const o=this._mid(e,s),a=this._mid(s,i),h=this._mid(i,r),c=this._mid(o,a),l=this._mid(a,h),u=this._mid(c,l);this._addBezier3(t,e,o,c,u,n),this._addBezier3(t,u,l,h,r,n)}_add90DegArc(t,e,s,i,r){const n=r??this._crossProduct(this._sub(s,e),this._sub(i,e))>0,o=this._mid(e,s),a=this._sub(o,e);n?this._leftPerpendicular(a):this._rightPerpendicular(a),o[0]+=a[0],o[1]+=a[1],this._addBezier3(t,e,this._mix(e,.33333,o,.66667),this._mix(s,.33333,o,.66667),s,4)}_addArrow(t,e,s){const i=e[0],r=e[1],n=e[e.length-1],o=this._sub(i,r);this._normalize(o);const a=this._crossProduct(o,this._sub(n,r)),h=.5*a,c=this._leftPerp(o),l=[n[0]-c[0]*a,n[1]-c[1]*a],u=e.length-1,d=[];d.push(s?[-c[0],-c[1]]:c);let p=[-o[0],-o[1]];for(let t=1;t<u-1;t++){const s=this._sub(e[t+1],e[t]);this._normalize(s);const i=this._dotProduct(s,p),r=this._crossProduct(s,p),n=Math.sqrt((1+i)/2),o=this._sub(s,p);this._normalize(o),o[0]/=n,o[1]/=n,d.push(r<0?[-o[0],-o[1]]:o),p=s}d.push(this._rightPerp(p));for(let s=d.length-1;s>0;s--)t.push([e[s][0]+d[s][0]*h,e[s][1]+d[s][1]*h]);t.push([l[0]+d[0][0]*h,l[1]+d[0][1]*h]),t.push([l[0]+d[0][0]*a,l[1]+d[0][1]*a]),t.push(i),t.push([l[0]-d[0][0]*a,l[1]-d[0][1]*a]),t.push([l[0]-d[0][0]*h,l[1]-d[0][1]*h]);for(let s=1;s<d.length;s++)t.push([e[s][0]-d[s][0]*h,e[s][1]-d[s][1]*h])}_cp2(t,e,s){return t.length>=2?t[1]:this._add2(t[0],e*this._defaultSize,s*this._defaultSize)}_cp3(t,e,s,i){if(t.length>=3)return t[2];const r=this._mix(t[0],1-s,e,s),n=this._sub(e,t[0]);return this._normalize(n),this._rightPerpendicular(n),[r[0]+n[0]*i*this._defaultSize,r[1]+n[1]*i*this._defaultSize]}_arrowPath(t){if(t.length>2)return t;const e=t[0],s=this._cp2(t,-4,0),i=this._sub(e,s);this._normalize(i);const r=this._rightPerp(i);return[e,s,[e[0]+(r[0]-i[0])*this._defaultSize,e[1]+(r[1]-i[1])*this._defaultSize]]}_arrowLastSeg(t){const e=t[0],s=this._cp2(t,-4,0);let i;if(t.length>=3)i=t[t.length-1];else{const t=this._sub(e,s);this._normalize(t);const r=this._rightPerp(t);i=[e[0]+(r[0]-t[0])*this._defaultSize,e[1]+(r[1]-t[1])*this._defaultSize]}return[s,i]}_processGeom(t){if(!t)return null;const e=[];for(const s of t){if(!s||0===s.length)continue;const t=s.length;let i=s[0];switch(this._rule){case ce.Ki.PerpendicularFromFirstSegment:{const t=this._cp2(s,0,-1),r=this._cp3(s,t,.5,4),n=[];n.push(r),n.push(this._mid(i,t)),e.push(n);break}case ce.Ki.ReversedFirstSegment:{const t=this._cp2(s,0,-1);e.push([t,i]);break}case ce.Ki.PerpendicularToSecondSegment:{const t=this._cp2(s,-4,1),r=this._cp3(s,t,.882353,-1.94),n=[];n.push(this._mid(t,r)),n.push(i),e.push(n);break}case ce.Ki.SecondSegmentWithTicks:{const t=this._cp2(s,-4,1),r=this._cp3(s,t,.882353,-1.94),n=this._sub(r,t);let o;o=this._crossProduct(n,this._sub(i,t))>0?this._rightPerp(o):this._leftPerp(n);const a=[];a.push([t[0]+(o[0]-n[0])/3,t[1]+(o[1]-n[1])/3]),a.push(t),a.push(r),a.push([r[0]+(o[0]+n[0])/3,r[1]+(o[1]+n[1])/3]),e.push(a);break}case ce.Ki.DoublePerpendicular:{const t=this._cp2(s,0,-1),r=this._cp3(s,t,.5,3),n=this._mid(i,t),o=this._sub(n,r);this._normalize(o);const a=this._crossProduct(o,this._sub(i,r));this._leftPerpendicular(o);const h=[];h.push(i),h.push([r[0]+o[0]*a,r[1]+o[1]*a]),e.push(h);const c=[];c.push([r[0]-o[0]*a,r[1]-o[1]*a]),c.push(t),e.push(c);break}case ce.Ki.OppositeToFirstSegment:{const t=this._cp2(s,0,-1),r=this._cp3(s,t,.5,3),n=this._mid(i,t),o=this._sub(n,r);this._normalize(o);const a=this._crossProduct(o,this._sub(i,r));this._leftPerpendicular(o);const h=[];h.push([r[0]+o[0]*a,r[1]+o[1]*a]),h.push([r[0]-o[0]*a,r[1]-o[1]*a]),e.push(h);break}case ce.Ki.TriplePerpendicular:{const t=this._cp2(s,0,-1),r=this._cp3(s,t,.5,4),n=this._mid(i,t),o=this._sub(n,r);this._normalize(o);const a=this._crossProduct(o,this._sub(i,r));this._leftPerpendicular(o);const h=[];h.push([r[0]+o[0]*a*.8,r[1]+o[1]*a*.8]),h.push([n[0]+.8*(i[0]-n[0]),n[1]+.8*(i[1]-n[1])]),e.push(h),e.push([r,n]);const c=[];c.push([r[0]-o[0]*a*.8,r[1]-o[1]*a*.8]),c.push([n[0]+.8*(t[0]-n[0]),n[1]+.8*(t[1]-n[1])]),e.push(c);break}case ce.Ki.HalfCircleFirstSegment:{const t=this._cp2(s,0,-1),r=this._cp3(s,t,.5,4),n=this._mid(i,t);let o=this._sub(t,i);const a=Math.cos(Math.PI/18),h=Math.sin(Math.PI/18),c=Math.sqrt((1+a)/2),l=Math.sqrt((1-a)/2),u=[];let d;this._crossProduct(o,this._sub(r,i))>0?(u.push(i),o=this._sub(i,n),d=t):(u.push(t),o=this._sub(t,n),d=i),this._rotateDirect(o,c,l),o[0]/=c,o[1]/=c;for(let t=1;t<=18;t++)u.push(this._add(n,o)),this._rotateDirect(o,a,h);u.push(d),e.push(u);break}case ce.Ki.HalfCircleSecondSegment:{const t=this._cp2(s,0,-1),r=this._cp3(s,t,1,-1);let n=this._sub(i,t);this._normalize(n);const o=this._crossProduct(n,this._sub(r,t))/2;this._leftPerpendicular(n);const a=[t[0]+n[0]*o,t[1]+n[1]*o];n=this._sub(t,a);const h=Math.cos(Math.PI/18);let c=Math.sin(Math.PI/18);o>0&&(c=-c);const l=[t];for(let t=1;t<=18;t++)this._rotateDirect(n,h,c),l.push(this._add(a,n));e.push(l);break}case ce.Ki.HalfCircleExtended:{const r=this._cp2(s,0,-2),n=this._cp3(s,r,1,-1);let o;if(t>=4)o=s[3];else{const t=this._sub(i,r);o=this._add(n,t)}const a=this._dist(r,n)/2/.75,h=this._sub(r,i);this._normalize(h,a);const c=this._sub(n,o);this._normalize(c,a);const l=[o,n];e.push(l);const u=[this._clone(n)];this._addBezier3(u,n,this._add(n,c),this._add(r,h),r,4),u.push(i),e.push(u);break}case ce.Ki.OpenCircle:{const t=this._cp2(s,-2,0),r=this._sub(t,i),n=Math.cos(Math.PI/18),o=-Math.sin(Math.PI/18),a=[t];for(let t=1;t<=33;t++)this._rotateDirect(r,n,o),a.push(this._add(i,r));e.push(a);break}case ce.Ki.CoverageEdgesWithTicks:{const r=this._cp2(s,0,-1);let n,o;if(t>=3)n=s[2];else{const t=this._sub(r,i),e=this._leftPerp(t);n=[i[0]+e[0]-.25*t[0],i[1]+e[1]-.25*t[1]]}if(t>=4)o=s[3];else{const t=this._mid(i,r),e=this._sub(i,r);this._normalize(e),this._leftPerpendicular(e);const s=this._crossProduct(e,this._sub(n,t));this._rightPerpendicular(e),o=[n[0]+e[0]*s*2,n[1]+e[1]*s*2]}const a=this._sub(r,i);let h,c;h=this._crossProduct(a,this._sub(n,i))>0?this._rightPerp(a):this._leftPerp(a),c=[],c.push(n),c.push(i),c.push([i[0]+(h[0]-a[0])/3,i[1]+(h[1]-a[1])/3]),e.push(c),h=this._crossProduct(a,this._sub(o,r))>0?this._rightPerp(h):this._leftPerp(a),c=[],c.push([r[0]+(h[0]+a[0])/3,r[1]+(h[1]+a[1])/3]),c.push(r),c.push(o),e.push(c);break}case ce.Ki.GapExtentWithDoubleTicks:{const r=this._cp2(s,0,2),n=this._cp3(s,r,0,1);let o;if(t>=4)o=s[3];else{const t=this._sub(r,i);o=this._add(n,t)}this._addAngledTicks(e,i,r,this._mid(n,o)),this._addAngledTicks(e,n,o,this._mid(i,r));break}case ce.Ki.GapExtentMidline:{const r=this._cp2(s,2,0),n=this._cp3(s,r,0,1);let o;if(t>=4)o=s[3];else{const t=this._sub(r,i);o=this._add(n,t)}const a=[];a.push(this._mid(i,n)),a.push(this._mid(r,o)),e.push(a);break}case ce.Ki.Chevron:{const r=this._cp2(s,-1,-1);let n;if(t>=3)n=s[2];else{const t=this._sub(r,i);this._leftPerpendicular(t),n=this._add(i,t)}e.push([r,this._makeCtrlPt(i),n]);break}case ce.Ki.PerpendicularWithArc:{const t=this._cp2(s,0,-2),r=this._cp3(s,t,.5,-1);let n=this._sub(t,i);const o=this._norm(n);n[0]/=o,n[1]/=o;const a=this._crossProduct(n,this._sub(r,i));let h=this._dotProduct(n,this._sub(r,i));h<.05*o?h=.05*o:h>.95*o&&(h=.95*o);const c=[i[0]+n[0]*h,i[1]+n[1]*h];this._leftPerpendicular(n);let l=[];l.push([c[0]-n[0]*a,c[1]-n[1]*a]),l.push([c[0]+n[0]*a,c[1]+n[1]*a]),e.push(l);const u=[t[0]+n[0]*a,t[1]+n[1]*a];n=this._sub(t,u);const d=Math.cos(Math.PI/18);let p=Math.sin(Math.PI/18);a<0&&(p=-p),l=[i,t];for(let t=1;t<=9;t++)this._rotateDirect(n,d,p),l.push(this._add(u,n));e.push(l);break}case ce.Ki.ClosedHalfCircle:{const t=this._cp2(s,2,0),r=this._mid(i,t),n=this._sub(t,r),o=Math.cos(Math.PI/18),a=Math.sin(Math.PI/18),h=[i,t];for(let t=1;t<=18;t++)this._rotateDirect(n,o,a),h.push(this._add(r,n));e.push(h);break}case ce.Ki.TripleParallelExtended:{const t=this._cp2(s,0,-2),r=this._cp3(s,t,1,-2),n=this._mid(i,t),o=this._sub(r,t);this._normalize(o);const a=Math.abs(this._crossProduct(o,this._sub(n,t)))/2,h=this._dist(t,r),c=[t,i];c.push([i[0]+o[0]*h*.5,i[1]+o[1]*h*.5]),e.push(c);const l=[];l.push([n[0]-o[0]*a,n[1]-o[1]*a]),l.push([n[0]+o[0]*h*.375,n[1]+o[1]*h*.375]),oe(l[l.length-1],1),l.push([n[0]+o[0]*h*.75,n[1]+o[1]*h*.75]),e.push(l);const u=[t,r];e.push(u);break}case ce.Ki.ParallelWithTicks:{const t=this._cp2(s,3,0),r=this._cp3(s,t,.5,-1),n=this._sub(r,t);this._normalize(n);const o=this._crossProduct(n,this._sub(r,i));this._leftPerpendicular(n),this._addAngledTicks(e,i,t,r),this._addAngledTicks(e,this._mix(i,1,n,o),this._mix(t,1,n,o),this._mid(i,t));break}case ce.Ki.Parallel:{const t=this._cp2(s,3,0),r=this._cp3(s,t,.5,-1),n=this._sub(t,i);this._normalize(n);const o=this._leftPerp(n),a=this._crossProduct(n,this._sub(r,i));let h=[i,t];e.push(h),h=[],h.push([i[0]+o[0]*a,i[1]+o[1]*a]),h.push([t[0]+o[0]*a,t[1]+o[1]*a]),e.push(h);break}case ce.Ki.PerpendicularToFirstSegment:{const t=this._cp2(s,3,0),r=this._cp3(s,t,.5,-1),n=this._mid(i,t),o=this._sub(t,i);this._normalize(o);const a=this._crossProduct(o,this._sub(r,i));this._leftPerpendicular(o);const h=[];h.push([n[0]-o[0]*a*.25,n[1]-o[1]*a*.25]),h.push([n[0]+o[0]*a*1.25,n[1]+o[1]*a*1.25]),e.push(h);break}case ce.Ki.ParallelOffset:{const t=this._cp2(s,3,0),r=this._cp3(s,t,.5,-1),n=this._sub(t,i);this._normalize(n);const o=this._crossProduct(n,this._sub(r,i));this._leftPerpendicular(n);const a=[];a.push([i[0]-n[0]*o,i[1]-n[1]*o]),a.push([t[0]-n[0]*o,t[1]-n[1]*o]),e.push(a);const h=[];h.push([i[0]+n[0]*o,i[1]+n[1]*o]),h.push([t[0]+n[0]*o,t[1]+n[1]*o]),e.push(h);break}case ce.Ki.OffsetOpposite:{const t=this._cp2(s,3,0),r=this._cp3(s,t,.5,-1),n=this._sub(t,i);this._normalize(n);const o=this._crossProduct(n,this._sub(r,i));this._leftPerpendicular(n);const a=[];a.push([i[0]-n[0]*o,i[1]-n[1]*o]),a.push([t[0]-n[0]*o,t[1]-n[1]*o]),e.push(a);break}case ce.Ki.OffsetSame:{const t=this._cp2(s,3,0),r=this._cp3(s,t,.5,-1),n=this._sub(t,i);this._normalize(n);const o=this._crossProduct(n,this._sub(r,i));this._leftPerpendicular(n);const a=[];a.push([i[0]+n[0]*o,i[1]+n[1]*o]),a.push([t[0]+n[0]*o,t[1]+n[1]*o]),e.push(a);break}case ce.Ki.CircleWithArc:{let r=this._cp2(s,3,0);const n=this._cp3(s,r,.5,-1);let o,a;if(t>=4)o=s[3],a=this._crossProduct(this._sub(o,r),this._sub(n,r))>0;else{o=r,a=this._crossProduct(this._sub(o,i),this._sub(n,i))>0;const t=24*this._geomUnitsPerPoint,e=this._sub(o,i);this._normalize(e,t);const s=Math.sqrt(2)/2;this._rotateDirect(e,s,a?s:-s),r=this._add(i,e)}const h=this._sub(r,i),c=Math.cos(Math.PI/18),l=Math.sin(Math.PI/18),u=[r];for(let t=1;t<=36;t++)this._rotateDirect(h,c,l),u.push(this._add(i,h));this._add90DegArc(u,r,o,n,a),oe(u[u.length-8],1),e.push(u);break}case ce.Ki.DoubleJog:{let r,n,o=this._cp2(s,-3,1);if(r=t>=3?s[2]:this._add(i,this._sub(i,o)),t>=4)n=s[3];else{const t=i;i=o,n=r;const e=this._dist(i,t),s=this._dist(n,t);let a=30*this._geomUnitsPerPoint;.5*e<a&&(a=.5*e),.5*s<a&&(a=.5*s),o=this._mix(i,a/e,t,(e-a)/e),r=this._mix(n,a/s,t,(s-a)/s)}const a=this._mid(i,o),h=this._mid(n,r),c=this._dist(i,o),l=this._dist(r,n);let u=Math.min(c,l)/8;u=Math.min(u,24*this._geomUnitsPerPoint);const d=Math.cos(Math.PI/4);let p=this._sub(i,o);this._normalize(p,u),this._crossProduct(p,this._sub(n,o))>0?this._rotateDirect(p,d,-d):this._rotateDirect(p,d,d);let _=[];_.push(o),_.push(this._add(a,p)),_.push(this._sub(a,p)),_.push(i),e.push(_),p=this._sub(n,r),this._normalize(p,u),this._crossProduct(p,this._sub(i,r))<0?this._rotateDirect(p,d,d):this._rotateDirect(p,d,-d),_=[],_.push(r),_.push(this._add(h,p)),_.push(this._sub(h,p)),_.push(n),e.push(_);break}case ce.Ki.PerpendicularOffset:{const t=this._cp2(s,-4,1),r=this._cp3(s,t,.882353,-1.94),n=this._sub(r,t);this._crossProduct(n,this._sub(i,t))>0?this._rightPerpendicular(n):this._leftPerpendicular(n);const o=[n[0]/8,n[1]/8],a=this._sub(this._mid(t,r),o);e.push([a,i]);break}case ce.Ki.LineExcludingLastSegment:{const t=this._arrowPath(s),i=[];let r=t.length-2;for(;r--;)i.push(t[r]);e.push(i);break}case ce.Ki.MultivertexArrow:{const t=this._arrowPath(s),i=[];this._addArrow(i,t,!1),e.push(i);break}case ce.Ki.CrossedArrow:{const t=this._arrowPath(s),i=[];this._addArrow(i,t,!0),e.push(i);break}case ce.Ki.ChevronArrow:{const[t,r]=this._arrowLastSeg(s),n=10*this._geomUnitsPerPoint,o=this._sub(i,t);this._normalize(o);const a=this._crossProduct(o,this._sub(r,t)),h=this._leftPerp(o),c=[r[0]-h[0]*a*2,r[1]-h[1]*a*2],l=[];l.push([r[0]+o[0]*n,r[1]+o[1]*n]),l.push(i),l.push([c[0]+o[0]*n,c[1]+o[1]*n]),e.push(l);break}case ce.Ki.ChevronArrowOffset:{const[t,r]=this._arrowLastSeg(s),n=this._sub(i,t);this._normalize(n);const o=this._crossProduct(n,this._sub(r,t));this._leftPerpendicular(n);const a=[r[0]-n[0]*o,r[1]-n[1]*o],h=[];h.push([a[0]+n[0]*o*.5,a[1]+n[1]*o*.5]),h.push(this._mid(a,i)),h.push([a[0]-n[0]*o*.5,a[1]-n[1]*o*.5]),e.push(h);break}case ce.Ki.PartialFirstSegment:{const[t,r]=this._arrowLastSeg(s),n=this._sub(i,t);this._normalize(n);const o=this._crossProduct(n,this._sub(r,t));this._leftPerpendicular(n);const a=[r[0]-n[0]*o,r[1]-n[1]*o];e.push([t,a]);break}case ce.Ki.Arch:{const t=this._cp2(s,0,-1),r=this._cp3(s,t,.5,1),n=this._sub(i,t),o=this._mix(r,1,n,.55),a=this._mix(r,1,n,-.55),h=[i];this._addBezier2(h,i,o,r,4),this._addBezier2(h,r,a,t,4),e.push(h);break}case ce.Ki.CurvedParallelTicks:{const t=this._cp2(s,-4,1),r=this._cp3(s,t,.882353,-1.94),n=this._sub(r,t);this._crossProduct(n,this._sub(i,t))>0?this._rightPerpendicular(n):this._leftPerpendicular(n);const o=[n[0]/8,n[1]/8],a=this._sub(this._mid(t,r),o),h=this._sub(this._mix(t,.75,r,.25),o),c=this._sub(this._mix(t,.25,r,.75),o),l=[t];this._addBezier2(l,t,h,a,3),this._addBezier2(l,a,c,r,3),e.push(l);for(let t=0;t<8;t++){const s=l[2*t+1],i=[this._clone(s)];i.push(this._add(s,[n[0]/4,n[1]/4])),e.push(i)}break}case ce.Ki.Arc90Degrees:{const t=this._cp2(s,0,-1),r=this._cp3(s,t,.5,1),n=[t];this._add90DegArc(n,t,i,r),e.push(n);break}case ce.Ki.FullGeometry:default:e.push(s)}}return e}}class xe{static local(){return null===xe.instance&&(xe.instance=new xe),xe.instance}execute(t,e,s,i,r){return new be(t,e,s)}}xe.instance=null;class be extends he{constructor(t,e,s){super(t,!0,!0),this._curveHelper=new ue,this._beginCut=(void 0!==e.beginCut?e.beginCut:1)*s,this._endCut=(void 0!==e.endCut?e.endCut:1)*s,this._middleCut=(void 0!==e.middleCut?e.middleCut:0)*s,this._invert=void 0!==e.invert&&e.invert,this._beginCut<0&&(this._beginCut=0),this._endCut<0&&(this._endCut=0),this._middleCut<0&&(this._middleCut=0)}processPath(t){const{_beginCut:e,_endCut:s,_middleCut:i}=this,r=t.pathLength(),n=jt.createEmptyOptimizedCIM("esriGeometryPolyline");if(this._invert){if(0!==e||0!==s||0!==i)if(e+s+i>=r)for(n.startPath();t.nextPoint();)n.pushXY(t.x,t.y);else this._curveHelper.appendSubCurve(n,t,0,e),this._curveHelper.appendSubCurve(n,t,.5*(r-i),.5*(r+i)),this._curveHelper.appendSubCurve(n,t,r-s,s)}else if(0===e&&0===s&&0===i)for(n.startPath();t.nextPoint();)n.pushXY(t.x,t.y);else e+s+i<r&&(0===i?this._curveHelper.appendSubCurve(n,t,e,r-s):(this._curveHelper.appendSubCurve(n,t,e,.5*(r-i)),this._curveHelper.appendSubCurve(n,t,.5*(r+i),r-s)));return 0===n.totalSize?null:n}}class we{constructor(){this._values=[],this.extPtGap=0,this.ctrlPtGap=0,this._length=0,this._currentValue=0}isEmpty(){return 0===this._values.length}size(){return this._values.length}init(t,e,s=!0){if(this._setEmpty(),!t||0===t.length)return!1;for(let e=0;e<t.length;e++){let i=Math.abs(t[e]);s&&i<1e-7&&(i=1e-7),this._values.push(i),this._length+=i}return e&&1&t.length&&(this._length*=2),0!==this._length&&(this.ctrlPtGap=this.extPtGap=0,this._currentValue=-1,!0)}scale(t){const e=this._values?this._values.length:0;for(let s=0;s<e;++s)this._values[s]*=t;this._length*=t,this.extPtGap*=t,this.ctrlPtGap*=t}addValue(t){this._length+=t,this._values.push(t)}firstValue(){return this._values[0]}lastValue(){return this._values[this._values.length-1]}nextValue(){return this._currentValue++,this._currentValue===this._values.length&&(this._currentValue=0),this._values[this._currentValue]}reset(){this._currentValue=-1}length(){return this._length}_setEmpty(){this.extPtGap=this.ctrlPtGap=this._length=0,this._currentValue=-1,this._values.length=0}}class ve{constructor(){this.pt=null,this.ca=0,this.sa=0}}var Se,Ie;(Ie=Se||(Se={}))[Ie.FAIL=0]="FAIL",Ie[Ie.END=1]="END",Ie[Ie.CONTINUE=2]="CONTINUE";class Te{constructor(){this.reset()}reset(){this.segment=null,this.segmentLength=0,this.abscissa=0,this.isPathEnd=!1,this.isPartEnd=!1}isValid(){return null!==this.segment}copyTo(t){t.segment=this.segment,t.segmentLength=this.segmentLength,t.abscissa=this.abscissa,t.isPathEnd=this.isPathEnd,t.isPartEnd=this.isPartEnd}}class Pe extends ue{constructor(t=0,e=!1){super(t,e),this._tolerance=le,this._currentPosition=new Te}updateTolerance(t){this._tolerance=le*t}init(t,e,s=!0){return s?(this._patternLength=e.length(),this._partExtPtGap=e.extPtGap,this._partCtrlPtGap=e.ctrlPtGap):(this._patternLength=0,this._partExtPtGap=0,this._partCtrlPtGap=0),this._currentPosition.reset(),this._partSegCount=0,this._pathCursor=t,this._seg=-1,this._setPosAtNextPart()}curPositionIsValid(){return this._currentPosition.isValid()}nextPosition(t,e=Se.FAIL){const s=new Te;return!!this._nextPosition(t,s,null,e)&&(s.copyTo(this._currentPosition),!0)}curPointAndAngle(t){t.pt=this._getPoint(this._currentPosition);const[e,s]=this._getAngleCS(this._currentPosition);t.ca=e,t.sa=s}nextPointAndAngle(t,e,s=Se.FAIL){const i=new Te;if(!this._nextPosition(t,i,null,s))return!1;i.copyTo(this._currentPosition),e.pt=this._getPoint(i);const[r,n]=this._getAngleCS(i);return e.ca=r,e.sa=n,!0}nextCurve(t){if(0===t)return null;const e=jt.createEmptyOptimizedCIM("esriGeometryPolyline");e.startPath(),e.nextPath();const s=new Te;return this._nextPosition(t,s,e,Se.END)?(s.copyTo(this._currentPosition),e):null}isPathEnd(){return this._currentPosition.isPathEnd}getPathEnd(){return this._currentPosition.segment[1]}getPt(t){return this._pathCursor.seekInPath(t),[this._pathCursor.x,this._pathCursor.y]}getSeg(t){return[this.getPt(t),this.getPt(t+1)]}_nextPosition(t,e,s,i){if(this._currentPosition.isPathEnd)return!1;let r=this._currentPosition.abscissa;for(this._currentPosition.segmentLength>0&&(r/=this._currentPosition.segmentLength),this._currentPosition.copyTo(e);e.abscissa+t*this._partLengthRatio>e.segmentLength+this._tolerance;){if(s){if(0===s.pathSize)if(0===r){const t=e.segment[0];s.pushXY(t[0],t[1])}else s.pushPoint(this.getSegCoord2D(e.segment,r));const t=e.segment[1];s.pushXY(t[0],t[1])}if(r=0,t-=(e.segmentLength-e.abscissa)/this._partLengthRatio,this._partSegCount)e.segment=this._nextSegment(),e.segmentLength=this.getSegLength(e.segment),e.abscissa=0,this._partSegCount--;else{if(!this._setPosAtNextPart())return i!==Se.FAIL&&(e.segmentLength=this.getSegLength(e.segment),e.isPartEnd=!0,i===Se.END?(e.abscissa=e.segmentLength,e.isPathEnd=!0):e.abscissa=e.segmentLength+t,!0);this._currentPosition.copyTo(e)}}if(e.abscissa+=t*this._partLengthRatio,s){0===s.pathSize&&(0===r?s.pushPoint(e.segment[0]):s.pushPoint(this.getSegCoord2D(e.segment,r)));const t=e.abscissa/e.segmentLength;1===t?s.pushPoint(e.segment[1]):s.pushPoint(this.getSegCoord2D(e.segment,t))}return this._partSegCount||Math.abs(e.abscissa-e.segmentLength)<this._tolerance&&(e.isPathEnd=this._partIsLast,e.isPartEnd=!0),!0}_getPoint(t){const e=t.segmentLength<=0?0:t.abscissa/t.segmentLength;return this.getSegCoord2D(this._currentPosition.segment,e)}_getAngleCS(t){const e=t.segmentLength<=0?0:t.abscissa/t.segmentLength;return this.getSegAngleCS(this._currentPosition.segment,e)}_setPosAtNextPart(){for(;this._partSegCount;)this._hasNextSegment()&&this._nextSegment(),this._partSegCount--;if(!this._hasNextSegment())return!1;for(this._partLength=0,this._partIsLast=!0,this._partSegCount=0;this._hasNextSegment();)if(this._partLength+=this.getSegLength(this._nextSegment()),this._partSegCount++,this._pathCursor.getControlPointAt(this._getEndPointIndex())){this._partIsLast=!this._hasNextSegment();break}let t=this._partSegCount;for(;t;)this._previousSegment(),--t;this._currentPosition.segment=this._nextSegment(),this._currentPosition.segmentLength=this.getSegLength(this._currentPosition.segment),this._currentPosition.abscissa=0,this._currentPosition.isPathEnd=this._currentPosition.isPartEnd=!1,--this._partSegCount;const e=this._getStartPointIndex();this._ctrlPtBegin=this._pathCursor.getControlPointAt(e);let s=e+this._partSegCount+1;if(s>=this._pathCursor.pathSize&&(s=0),this._ctrlPtEnd=this._pathCursor.getControlPointAt(s),this._patternLength>0){const t=this._ctrlPtBegin?this._partCtrlPtGap:this._partExtPtGap,e=this._ctrlPtEnd?this._partCtrlPtGap:this._partExtPtGap;let s=Math.round((this._partLength-(t+e))/this._patternLength);s<=0&&(s=t+e>0?0:1),this._partLengthRatio=this._partLength/(t+e+s*this._patternLength),this._partLengthRatio<.01&&(this._partLengthRatio=1)}else this._partLengthRatio=1;return!0}_hasNextSegment(){return this._seg<this._pathCursor.pathSize-2}_previousSegment(){return this.getSeg(--this._seg)}_nextSegment(){return this.getSeg(++this._seg)}_getStartPointIndex(){return this._seg}_getEndPointIndex(){return this._seg+1}}var Me=s(14624);class Ee{static local(){return null===Ee.instance&&(Ee.instance=new Ee),Ee.instance}execute(t,e,s,i,r){return new Ce(t,e,s)}}Ee.instance=null;class Ce extends he{constructor(t,e,s){super(t,!0,!0),this._firstCurve=null,this._walker=new Pe,this._walker.updateTolerance(s),this._endings=e.lineDashEnding,this._customDashPos=-(e.offsetAlongLine??0)*s,this._offsetAtEnd=(e.customEndingOffset??0)*s,this._pattern=new we,this._pattern.init((0,Me.Wy)(e).dashTemplate,!0),this._pattern.scale(s)}processPath(t){if(0===this._pattern.length()){this.iteratePath=!1;const e=(0,Xt.g)(t);return jt.fromJSONCIM({paths:[e]})}if(!this.iteratePath){let e=!0;switch(this._endings){case ce.Gi.HalfPattern:case ce.Gi.HalfGap:default:this._pattern.extPtGap=0;break;case ce.Gi.FullPattern:this.isClosed||(this._pattern.extPtGap=.5*this._pattern.firstValue());break;case ce.Gi.FullGap:this.isClosed||(this._pattern.extPtGap=.5*this._pattern.lastValue());break;case ce.Gi.NoConstraint:this.isClosed||(e=!1);break;case ce.Gi.Custom:this.isClosed||(this._pattern.extPtGap=.5*this._offsetAtEnd)}const s=t.pathLength();if(this._pattern.isEmpty()||s<.1*this._pattern.length()){const e=(0,Xt.g)(t);return jt.fromJSONCIM({paths:[e]})}if(!this._walker.init(t,this._pattern,e)){const e=(0,Xt.g)(t);return jt.fromJSONCIM({paths:[e]})}}let e;if(this.iteratePath)e=this._pattern.nextValue();else{let t;switch(this._endings){case ce.Gi.HalfPattern:default:t=.5*this._pattern.firstValue();break;case ce.Gi.HalfGap:t=.5*-this._pattern.lastValue();break;case ce.Gi.FullGap:t=-this._pattern.lastValue();break;case ce.Gi.FullPattern:t=0;break;case ce.Gi.NoConstraint:case ce.Gi.Custom:t=-this._customDashPos}let s=t/this._pattern.length();s-=Math.floor(s),t=s*this._pattern.length(),this._pattern.reset(),e=this._pattern.nextValue();let i=!1;for(;t>=e;)t-=e,e=this._pattern.nextValue(),i=!i;e-=t,i?(this._walker.nextPosition(e),e=this._pattern.nextValue()):this.isClosed&&(this._firstCurve=this._walker.nextCurve(e),e=this._pattern.nextValue(),this._walker.nextPosition(e),e=this._pattern.nextValue())}let s=this._walker.nextCurve(e);if(s)if(this._walker.isPathEnd()){if(this.iteratePath=!1,this._firstCurve){for(this._firstCurve.nextPath();this._firstCurve.nextPoint();)s.pushXY(this._firstCurve.x,this._firstCurve.y);this._firstCurve=null}}else e=this._pattern.nextValue(),!this._walker.nextPosition(e)||this._walker.isPathEnd()?(this.iteratePath=!1,this._firstCurve&&(s.pushCursor(this._firstCurve),this._firstCurve=null)):this.iteratePath=!0;else this.iteratePath=!1,s=this._firstCurve,this._firstCurve=null;return s?.reset(),s}}class ke{static local(){return null===ke.instance&&(ke.instance=new ke),ke.instance}execute(t,e,s,i,r,n){return new Fe(t,e,s,i,r,n)}}ke.instance=null;class Fe{constructor(t,e,s,i,r,n){switch(this._inputGeometries=t,this._tileKey=i,this._geometryEngine=r,this._maxInflateSize=n*s,this._width=(void 0!==e.width?e.width:2)*s,e.method){case ce.Q9.Mitered:case ce.Q9.Bevelled:case ce.Q9.Rounded:case ce.Q9.TrueBuffer:case ce.Q9.Square:}this._option=e.option}next(){let t;for(;t=this._inputGeometries.next();){if("esriGeometryEnvelope"===t.geometryType&&this._width>0){const e=t.asJSON();return Math.min(e.xmax-e.xmin,e.ymax-e.ymin)-2*this._width<0?t:jt.fromJSONCIM({paths:[[[e.xmin+this._width,e.ymin+this._width],[e.xmax-this._width,e.ymin+this._width],[e.xmax-this._width,e.ymax-this._width],[e.xmin+this._width,e.ymax-this._width],[e.xmin+this._width,e.ymin+this._width]],[[e.xmin,e.ymin],[e.xmin,e.ymax],[e.xmax,e.ymax],[e.xmax,e.ymin],[e.xmin,e.ymin]]]})}if("esriGeometryPolygon"===t.geometryType){if(0===this._width)return t.clone();const e=this._geometryEngine;if(null==e)return null;const s=this._tileKey?se(t,this._maxInflateSize):t.clone();if(!s)continue;const i=e.buffer(V.c.WebMercator,s.asJSON(),-this._width,1);if(i)for(const t of i.rings)if(t){s.startPath();for(const e of t.reverse())s.pushXY(e[0],s.yFactor*e[1])}return s}}return null}}class Ae{static local(){return null===Ae.instance&&(Ae.instance=new Ae),Ae.instance}execute(t,e,s,i,r){return new Re(t,e,s)}}Ae.instance=null;class Re extends he{constructor(t,e,s){super(t,!1,!0),this._curveHelper=new ue,this._length=(void 0!==e.length?e.length:20)*s,this._angle=void 0!==e.angle?e.angle:225,this._position=void 0!==e.position?e.position:50,this._length<0&&(this._length=-this._length),this._position<20&&(this._position=20),this._position>80&&(this._position=80),this._mirror=!1}processPath(t){const e=jt.createEmptyOptimizedCIM("esriGeometryPolyline");if(this._curveHelper.isEmpty(t))return null;t.seekInPath(0);const s=t.x,i=t.y;t.seekInPath(t.pathSize-1);const r=t.x,n=t.y,o=[r-s,n-i];this._curveHelper.normalize(o);const a=s+(r-s)*this._position/100,h=i+(n-i)*this._position/100,c=Math.cos((90-this._angle)/180*Math.PI);let l=Math.sin((90-this._angle)/180*Math.PI);this._mirror&&(l=-l),this._mirror=!this._mirror;const u=[a-this._length/2*c,h-this._length/2*l],d=[a+this._length/2*c,h+this._length/2*l];return e.pushPath([[s,i],u,d,[r,n]]),e}}class Oe{static local(){return null===Oe.instance&&(Oe.instance=new Oe),Oe.instance}execute(t,e,s,i,r){return new Ne(t,e,s)}}Oe.instance=null;class Ne{constructor(t,e,s){this._inputGeometries=t,this._offsetX=void 0!==e.offsetX?e.offsetX*s:0,this._offsetY=void 0!==e.offsetY?e.offsetY*s:0}next(){let t=this._inputGeometries.next();for(;t;){if(t.totalSize>0)return this._move(t.clone(),this._offsetX,this._offsetY);t=this._inputGeometries.next()}return null}_move(t,e,s){for(;t.nextPath();)for(;t.nextPoint();)t.x=t.x+e,t.y=t.y+s;return t.reset(),t}}class De{static local(){return null===De.instance&&(De.instance=new De),De.instance}execute(t,e,s,i,r,n){return new ze(t,e,s,i,r,n)}}De.instance=null;class ze{constructor(t,e,s,i,r,n){this._inputGeometries=t,this._tileKey=i,this._geometryEngine=r,this._curveHelper=new ue,this._offset=(e.offset??1)*s,this._method=e.method,this._maxInflateSize=Math.max(Math.abs(n*s),10),this._option=e.option,this._offsetFlattenError=le*s}next(){let t;for(;t=this._inputGeometries.next();){if(0===this._offset)return t.clone();if("esriGeometryEnvelope"===t.geometryType){if(this._method===ce.yM.Rounded&&this._offset>0){const e=(0,Xt.g)(t),s=this._curveHelper.offset(e,-this._offset,this._method,4,this._offsetFlattenError);if(s){const e=jt.createEmptyOptimizedCIM(t.geometryType);return e.pushPath(s),e}return null}const e=t.asJSON();if((0,Yt.Ul)(e)&&Math.min(e.xmax-e.xmin,e.ymax-e.ymin)+2*this._offset>0)return jt.fromJSONCIM({xmin:e.xmin-this._offset,xmax:e.xmax+this._offset,ymin:e.ymin-this._offset,ymax:e.ymax+this._offset})}const e=this._geometryEngine;if(null==e)continue;const s=this._tileKey?se(t,this._maxInflateSize):t.clone();if(!s)continue;const i=e.offset(V.c.WebMercator,s.asJSON(),-this._offset,1,this._method,4,this._offsetFlattenError);return i?jt.fromJSONCIM(i):null}return null}}class Le{static local(){return null===Le.instance&&(Le.instance=new Le),Le.instance}execute(t,e,s,i,r){return new Be(t,e,s)}}Le.instance=null;class Be{constructor(t,e,s){this._inputGeometries=t,this._reverse=void 0===e.reverse||e.reverse}next(){let t=this._inputGeometries.next();for(;t;){if(!this._reverse)return t;if("esriGeometryPolyline"===t.geometryType)return Ue(t.clone());t=this._inputGeometries.next()}return null}}function Ue(t){for(;t.nextPath();)for(let e=0;e<t.pathSize/2;e++){t.seekInPath(e);const s=t.x,i=t.y;t.seekInPath(t.pathSize-e-1);const r=t.x,n=t.y;t.x=s,t.y=i,t.seekInPath(e),t.x=r,t.y=n}return t.reset(),t}var Ge=s(33008);class Ve{static local(){return null===Ve.instance&&(Ve.instance=new Ve),Ve.instance}execute(t,e,s,i,r){return new qe(t,e,s)}}Ve.instance=null;class qe{constructor(t,e,s){this._inputGeometries=t,this._rotateAngle=void 0!==e.angle?e.angle*Math.PI/180:0}next(){let t=this._inputGeometries.next();for(;t;){if(0===this._rotateAngle||"esriGeometryPoint"===t.geometryType)return t;if(t.totalSize>0){const e=(0,Ge.IV)(t),s=(e[2]+e[0])/2,i=(e[3]+e[1])/2;return t.reset(),this._rotate(t.clone(),s,i)}t=this._inputGeometries.next()}return null}_rotate(t,e,s){const i=Math.cos(this._rotateAngle),r=Math.sin(this._rotateAngle);for(;t.nextPath();)for(;t.nextPoint();){const n=t.x-e,o=t.y-s;t.x=e+n*i-o*r,t.y=s+n*r+o*i}return t.reset(),t}}class We{static local(){return null===We.instance&&(We.instance=new We),We.instance}execute(t,e,s,i,r){return new Xe(t,e,s)}}We.instance=null;class Xe{constructor(t,e,s){this._inputGeometries=t,this._xFactor=void 0!==e.XScaleFactor?e.XScaleFactor:1.15,this._yFactor=void 0!==e.YScaleFactor?e.YScaleFactor:1.15}next(){const t=this._inputGeometries.next();if(t){if(1===this._xFactor&&1===this._yFactor)return t;if("esriGeometryPoint"===t.geometryType)return t;if(t.totalSize>0){const e=(0,Ge.IV)(t),s=(e[2]+e[0])/2,i=(e[3]+e[1])/2;return t.reset(),this._scaleCursor(t.clone(),s,i)}}return null}_scaleCursor(t,e,s){for(;t.nextPath();)for(;t.nextPoint();)t.x=e+(t.x-e)*this._xFactor,t.y=s+(t.y-s)*this._yFactor;return t.reset(),t}}class Ye{static local(){return null===Ye.instance&&(Ye.instance=new Ye),Ye.instance}execute(t,e,s,i,r){return new je(t,e,s)}}Ye.instance=null;class je{constructor(t,e,s){this._inputGeometries=t,this._height=(void 0!==e.amplitude?e.amplitude:2)*s,this._period=(void 0!==e.period?e.period:3)*s,this._style=e.waveform,this._height<=0&&(this._height=Math.abs(this._height)),this._period<=0&&(this._period=Math.abs(this._period)),this._pattern=new we,this._pattern.addValue(this._period),this._pattern.addValue(this._period),this._walker=new Pe,this._walker.updateTolerance(s)}next(){let t=this._inputGeometries.next();for(;t;){if(0===this._height||0===this._period)return t;const e=this._processGeom(t);if(e)return e;t=this._inputGeometries.next()}return null}_processGeom(t){const e=jt.createEmptyOptimizedCIM(t.geometryType);for(;t.nextPath();){e.startPath();const s=t.pathLength();if(this._walker.init(t,this._pattern))switch(this._style){case ce.y2.Sinus:default:this._constructCurve(e,s,!1);break;case ce.y2.Square:this._constructSquare(e,s);break;case ce.y2.Triangle:this._constructTriangle(e,s);break;case ce.y2.Random:this._constructCurve(e,s,!0)}else for(;t.nextPoint();)e.pushXY(t.x,t.y)}return e}_constructCurve(t,e,s){let i=Math.round(e/this._period);0===i&&(i=1);const r=16*i+1,n=e/i,o=this._period/16,a=1/r,h=2*Math.PI*e/n,c=2*Math.PI*Math.random(),l=2*Math.PI*Math.random(),u=2*Math.PI*Math.random(),d=.75-Math.random()/2,p=.75-Math.random()/2,_=new ve;this._walker.curPointAndAngle(_),t.pushPoint(_.pt);let f=0;for(;;){if(!this._walker.nextPointAndAngle(o,_)){t.pushPoint(this._walker.getPathEnd());break}{const e=f;let i;if(f+=a,s){const t=this._height/2*(1+.3*Math.sin(d*h*e+c));i=t*Math.sin(h*e+l),i+=t*Math.sin(p*h*e+u),i/=2}else i=.5*this._height*Math.sin(.5*h*e);t.pushXY(_.pt[0]-i*_.sa,_.pt[1]+i*_.ca)}}}_constructSquare(t,e){Math.round(e/this._period);let s=!0;for(;;){let e=!1;if(this._walker.curPositionIsValid()){const i=new ve;this._walker.curPointAndAngle(i);const r=new ve;if(this._walker.nextPointAndAngle(this._period,r)){const n=new ve;this._walker.nextPointAndAngle(this._period,n)&&(s?(t.pushPoint(i.pt),s=!1):t.pushPoint(i.pt),t.pushXY(i.pt[0]-this._height/2*i.sa,i.pt[1]+this._height/2*i.ca),t.pushXY(r.pt[0]-this._height/2*r.sa,r.pt[1]+this._height/2*r.ca),t.pushXY(r.pt[0]+this._height/2*r.sa,r.pt[1]-this._height/2*r.ca),t.pushXY(n.pt[0]+this._height/2*n.sa,n.pt[1]-this._height/2*n.ca),e=!0)}}if(!e){t.pushPoint(this._walker.getPathEnd());break}}}_constructTriangle(t,e){Math.round(e/this._period);let s=!0;for(;;){let e=!1;if(this._walker.curPositionIsValid()){const i=new ve;this._walker.curPointAndAngle(i);const r=new ve;if(this._walker.nextPointAndAngle(this._period/2,r)){const n=new ve;this._walker.nextPointAndAngle(this._period,n)&&(this._walker.nextPosition(this._period/2)&&(s?(t.pushPoint(i.pt),s=!1):t.pushPoint(i.pt),t.pushXY(r.pt[0]-this._height/2*r.sa,r.pt[1]+this._height/2*r.ca),t.pushXY(n.pt[0]+this._height/2*n.sa,n.pt[1]-this._height/2*n.ca)),e=!0)}}if(!e){t.pushPoint(this._walker.getPathEnd());break}}}}class He{static local(){return null===He.instance&&(He.instance=new He),He.instance}execute(t,e,s,i,r){return new $e(t,e,s)}}He.instance=null;class $e extends ae{constructor(t,e,s){super(t),this._geometryWalker=new Pe,this._geometryWalker.updateTolerance(s),this._angleToLine=e.angleToLine??!0,this._offset=(e.offset?e.offset:0)*s,this._originalEndings=e.endings,this._offsetAtEnd=(e.customEndingOffset?e.customEndingOffset:0)*s,this._position=-(e.offsetAlongLine?e.offsetAlongLine:0)*s,this._pattern=new we,this._pattern.init(e.placementTemplate,!1),this._pattern.scale(s),this._endings=this._originalEndings}processPath(t){if(this._pattern.isEmpty())return null;let e;if(this.iteratePath)e=this._pattern.nextValue();else{this._originalEndings===ce.AZ.WithFullGap&&this.isClosed?this._endings=ce.AZ.WithMarkers:this._endings=this._originalEndings,this._pattern.extPtGap=0;let s,i=!0;switch(this._endings){case ce.AZ.NoConstraint:s=-this._position,s=this._adjustPosition(s),i=!1;break;case ce.AZ.WithHalfGap:default:s=-this._pattern.lastValue()/2;break;case ce.AZ.WithFullGap:s=-this._pattern.lastValue(),this._pattern.extPtGap=this._pattern.lastValue();break;case ce.AZ.WithMarkers:s=0;break;case ce.AZ.Custom:s=-this._position,s=this._adjustPosition(s),this._pattern.extPtGap=.5*this._offsetAtEnd}if(!this._geometryWalker.init(t,this._pattern,i))return null;this._pattern.reset();let r=0;for(;s>r;)s-=r,r=this._pattern.nextValue();r-=s,e=r,this.iteratePath=!0}const s=new ve;return this._geometryWalker.nextPointAndAngle(e,s)?this._endings===ce.AZ.WithFullGap&&this._geometryWalker.isPathEnd()?(this.iteratePath=!1,null):this._endings===ce.AZ.WithMarkers&&this._geometryWalker.isPathEnd()&&(this.iteratePath=!1,this.isClosed)?null:(this.internalPlacement.setTranslate(s.pt[0]-this._offset*s.sa,s.pt[1]+this._offset*s.ca),this._angleToLine&&this.internalPlacement.setRotateCS(s.ca,s.sa),this.internalPlacement):(this.iteratePath=!1,null)}_adjustPosition(t){let e=t/this._pattern.length();return e-=Math.floor(e),e*this._pattern.length()}}class Ke{static local(){return null===Ke.instance&&(Ke.instance=new Ke),Ke.instance}execute(t,e,s,i,r){return new Ze(t,e,s)}}Ke.instance=null;class Ze extends ae{constructor(t,e,s){super(t,!1,!0),this._curveHelper=new ue,this._angleToLine=void 0===e.angleToLine||e.angleToLine,this._offset=void 0!==e.offset?e.offset*s:0,this._type=e.extremityPlacement,this._position=void 0!==e.offsetAlongLine?e.offsetAlongLine*s:0,this._beginProcessed=!1}processPath(t){let e;switch(this._type){case ce.G6.Both:default:this._beginProcessed?(e=this._atExtremities(t,this._position,!1),this._beginProcessed=!1,this.iteratePath=!1):(e=this._atExtremities(t,this._position,!0),this._beginProcessed=!0,this.iteratePath=!0);break;case ce.G6.JustBegin:e=this._atExtremities(t,this._position,!0);break;case ce.G6.JustEnd:e=this._atExtremities(t,this._position,!1);case ce.G6.None:}return e}_atExtremities(t,e,s){if(s||t.seekPathEnd(),s?t.nextPoint():t.prevPoint()){let i=0,[r,n]=[0,0],[o,a]=[t.x,t.y];for(;s?t.nextPoint():t.prevPoint();){r=o,n=a,o=t.x,a=t.y;const s=this._curveHelper.getLength(r,n,o,a);if(i+s>e){const t=(e-i)/s,[h,c]=this._curveHelper.getAngleCS(r,n,o,a,t),l=this._curveHelper.getCoord2D(r,n,o,a,t);return this.internalPlacement.setTranslate(l[0]-this._offset*c,l[1]+this._offset*h),this._angleToLine&&this.internalPlacement.setRotateCS(-h,-c),this.internalPlacement}i+=s}}return null}}class Qe{static local(){return null===Qe.instance&&(Qe.instance=new Qe),Qe.instance}execute(t,e,s,i,r){return new Je(t,e,s)}}Qe.instance=null;class Je extends ae{constructor(t,e,s){super(t),this._walker=new Pe,this._walker.updateTolerance(s),this._angleToLine=void 0===e.angleToLine||e.angleToLine,this._offset=void 0!==e.offset?e.offset*s:0,this._beginGap=void 0!==e.beginPosition?e.beginPosition*s:0,this._endGap=void 0!==e.endPosition?e.endPosition*s:0,this._flipFirst=void 0===e.flipFirst||e.flipFirst,this._pattern=new we,this._pattern.init(e.positionArray,!1,!1),this._subPathLen=0,this._posCount=this._pattern.size(),this._isFirst=!0,this._prevPos=0}processPath(t){if(this._pattern.isEmpty())return null;let e;if(this.iteratePath){const t=this._pattern.nextValue()*this._subPathLen,s=this._beginGap+t;e=s-this._prevPos,this._prevPos=s}else{if(this._posCount=this._pattern.size(),this._isFirst=!0,this._prevPos=0,this._subPathLen=t.pathLength()-this._beginGap-this._endGap,this._subPathLen<0)return this.iteratePath=!1,null;if(!this._walker.init(t,this._pattern,!1))return null;this._pattern.reset();const s=this._pattern.nextValue()*this._subPathLen,i=this._beginGap+s;e=i-this._prevPos,this._prevPos=i,this.iteratePath=!0}const s=new ve;if(!this._walker.nextPointAndAngle(e,s,Se.END))return this.iteratePath=!1,null;this.internalPlacement.setTranslate(s.pt[0]-this._offset*s.sa,s.pt[1]+this._offset*s.ca);const i=this._isFirst&&this._flipFirst;let r,n;return this._angleToLine?(r=s.ca,n=s.sa):(r=1,n=0),i&&(r=-r,n=-n),this.internalPlacement.setRotateCS(r,n),this._isFirst=!1,this._posCount--,0===this._posCount&&(this.iteratePath=!1),this.internalPlacement}}const ts=512,es=24,ss=1e-6;class is{static local(){return null===is.instance&&(is.instance=new is),is.instance}execute(t,e,s,i,r){return new rs(t,e,s,i,r)}}is.instance=null;class rs{constructor(t,e,s,i,r){if(this._xMin=0,this._xMax=0,this._yMin=0,this._yMax=0,this._currentX=0,this._currentY=0,this._accelerationMap=null,this._testInsidePolygon=!1,this._verticalSubdivision=!0,this._stepX=Math.abs(e.stepX??16)*s,this._stepY=Math.abs(e.stepY??16)*s,this._stepX=Math.round(128*this._stepX)/128,this._stepY=Math.round(128*this._stepY)/128,0!==this._stepX&&0!==this._stepY){if(this._gridType=e.gridType??ce.sP.Fixed,this._gridType===ce.sP.Random){const t=e.seed??13,s=1;this._randomLCG=new h.c(t*s),this._randomness=(e.randomness??100)/100,this._gridAngle=0,this._shiftOddRows=!1,this._cosAngle=1,this._sinAngle=0,this._offsetX=0,this._offsetY=0,this._buildRandomValues()}else{if(this._randomness=0,this._gridAngle=e.gridAngle??0,this._shiftOddRows=e.shiftOddRows??!1,this._offsetX=(e.offsetX??0)*s,this._offsetY=(e.offsetY??0)*s,this._cosAngle=Math.cos(this._gridAngle/180*Math.PI),this._sinAngle=-Math.sin(this._gridAngle/180*Math.PI),this._stepX)if(this._offsetX<0)for(;this._offsetX<-.5*this._stepX;)this._offsetX+=this._stepX;else for(;this._offsetX>=.5*this._stepX;)this._offsetX-=this._stepX;if(this._stepY)if(this._offsetY<0)for(;this._offsetY<-.5*this._stepY;)this._offsetY+=this._stepY;else for(;this._offsetY>=.5*this._stepY;)this._offsetY-=this._stepY}if(this._graphicOriginX=0,this._graphicOriginY=0,null!=i){const[t,e,s,r]=i.split("/"),n=parseFloat(t),o=parseFloat(e),a=parseFloat(s),h=parseFloat(r);this._graphicOriginX=-(h*2**n+a)*ts,this._graphicOriginY=o*ts,this._testInsidePolygon=!0}this._internalPlacement=new ne,this._calculateMinMax(t),this._geometryCursor=t}}next(){return this._geometryCursor?this._nextInside():null}_buildRandomValues(){if(!rs._randValues){rs._randValues=[];for(let t=0;t<es;t++)for(let t=0;t<es;t++)rs._randValues.push(this._randomLCG.getFloat()),rs._randValues.push(this._randomLCG.getFloat())}}_calculateMinMax(t){let e,s,i,r,n,o,a,h,c,l,u,d,p,_;this._xMin=0,this._xMax=0,this._yMin=0,this._yMax=0,a=h=p=u=Number.MAX_VALUE,c=l=_=d=-Number.MAX_VALUE;const f=1!==this._cosAngle;for(t.reset();t.nextPath();)for(;t.nextPoint();)o=t.x,n=t.y,e=o-this._graphicOriginX-this._offsetX,s=n-this._graphicOriginY-this._offsetY,f?(i=this._cosAngle*e-this._sinAngle*s,r=this._sinAngle*e+this._cosAngle*s):(i=e,r=s),a=Math.min(a,i),c=Math.max(c,i),h=Math.min(h,r),l=Math.max(l,r),u=Math.min(u,n),d=Math.max(d,n),p=Math.min(p,o),_=Math.max(_,o);u=u!==Number.MAX_VALUE?u:-512-this._stepY,d=d!==-Number.MAX_VALUE?d:this._stepY,p=p!==Number.MAX_VALUE?p:-this._stepX,_=_!==-Number.MAX_VALUE?_:ts+this._stepX;const m=d-u,g=_-p;if(this._verticalSubdivision=m>=g,this._polygonMin=this._verticalSubdivision?u:p,this._testInsidePolygon){let t=0-this._graphicOriginX-this._offsetX-this._stepX,e=ts-this._graphicOriginX-this._offsetX+this._stepX,s=-512-this._graphicOriginY-this._offsetY-this._stepY,i=0-this._graphicOriginY-this._offsetY+this._stepY;if(f){const r=[[t,s],[t,i],[e,s],[e,i]];t=s=Number.MAX_VALUE,e=i=-Number.MAX_VALUE;for(const n of r){const r=this._cosAngle*n[0]-this._sinAngle*n[1],o=this._sinAngle*n[0]+this._cosAngle*n[1];t=Math.min(t,r),e=Math.max(e,r),s=Math.min(s,o),i=Math.max(i,o)}}a=a!==Number.MAX_VALUE?Math.max(a,t):t,h=h!==Number.MAX_VALUE?Math.max(h,s):s,c=c!==-Number.MAX_VALUE?Math.min(c,e):e,l=l!==-Number.MAX_VALUE?Math.min(l,i):i}this._xMin=Math.round(a/this._stepX),this._xMax=Math.round(c/this._stepX),this._yMin=Math.round(h/this._stepY),this._yMax=Math.round(l/this._stepY),this._currentX=this._xMax+1,this._currentY=this._yMin-1,this._buildAccelerationMap(t,p,_,u,d)}_buildAccelerationMap(t,e,s,i,r){t.reset();const n=new Map,o=this._verticalSubdivision,a=o?r-i:s-e;let h=Math.ceil(a/10);if(h<=1)return;const c=Math.floor(a/h);let l,u,d,p,_,f,m,g,y,x,b;for(h++,this._delta=c,o?(y=-512-2*this._stepY,x=2*this._stepY,b=i):(y=-2*this._stepX,x=ts+2*this._stepX,b=e);t.nextPath();)if(!(t.pathSize<2)&&t.nextPoint())for(l=t.x,u=t.y;t.nextPoint();l=d,u=p){if(d=t.x,p=t.y,o){if(u===p||u<y&&p<y||u>x&&p>x)continue;_=Math.min(u,p),f=Math.max(u,p)}else{if(l===d||l<y&&d<y||l>x&&d>x)continue;_=Math.min(l,d),f=Math.max(l,d)}for(;_<f;)m=Math.floor((_-b)/c),ns(m,l,u,d,p,n),_+=c;g=Math.floor((f-b)/c),g>m&&ns(g,l,u,d,p,n)}this._accelerationMap=n}_nextInside(){for(;;){if(this._currentX>this._xMax){if(this._currentY++,this._currentY>this._yMax)return null;this._currentX=this._xMin,this._shiftOddRows&&this._currentY%2&&this._currentX--}let t=this._currentX*this._stepX+this._offsetX;this._shiftOddRows&&this._currentY%2&&(t+=.5*this._stepX);const e=this._currentY*this._stepY+this._offsetY;let s,i;if(this._currentX++,this._gridType===ce.sP.Random){const r=(this._currentX%es+es)%es,n=(this._currentY%es+es)%es;s=this._graphicOriginX+t+this._stepX*this._randomness*(.5-rs._randValues[n*es+r])*2/3,i=this._graphicOriginY+e+this._stepY*this._randomness*(.5-rs._randValues[n*es+r+1])*2/3}else s=this._graphicOriginX+this._cosAngle*t+this._sinAngle*e,i=this._graphicOriginY-this._sinAngle*t+this._cosAngle*e;if(!this._testInsidePolygon||this._isInsidePolygon(s,i,this._geometryCursor))return this._internalPlacement.setTranslate(s,i),this._internalPlacement}}_isInsidePolygon(t,e,s){if(null==this._accelerationMap)return function(t,e,s){let i,r,n,o,a=0;for(t+=ss,e+=ss,s.reset();s.nextPath();)if(s.nextPoint())for(i=s.x,r=s.y;s.nextPoint();i=n,r=o)n=s.x,o=s.y,r>e!=o>e&&((n-i)*(e-r)-(o-r)*(t-i)>0?a++:a--);return 0!==a}(t,e,s);t+=ss,e+=ss;const i=this._verticalSubdivision,r=i?e:t,n=Math.floor((r-this._polygonMin)/this._delta),o=this._accelerationMap.get(n);if(!o)return!1;let a,h,c,l=0;for(const s of o){if(a=s[0],h=s[1],i){if(a[1]>e==h[1]>e)continue;c=(h[0]-a[0])*(e-a[1])-(h[1]-a[1])*(t-a[0])}else{if(a[0]>t==h[0]>t)continue;c=(h[1]-a[1])*(t-a[0])-(h[0]-a[0])*(e-a[1])}c>0?l++:l--}return 0!==l}}function ns(t,e,s,i,r,n){let o=n.get(t);o||(o=[],n.set(t,o)),o.push([[e,s],[i,r]])}class os{static local(){return null===os.instance&&(os.instance=new os),os.instance}execute(t,e,s,i,r){return new as(t,e,s)}}os.instance=null;class as extends ae{constructor(t,e,s){super(t),this._curveHelper=new ue,this._angleToLine=void 0===e.angleToLine||e.angleToLine,this._offset=void 0!==e.offset?e.offset*s:0,this._relativeTo=e.relativeTo,this._position=void 0!==e.startPointOffset?e.startPointOffset*s:0,this._epsilon=.001*s}processPath(t){const e=this._position;if(this._relativeTo===ce.IJ.SegmentMidpoint){if(this.iteratePath||(this.iteratePath=!0),t.nextPoint()){let[e,s]=[t.x,t.y],[i,r]=[0,0];for(;t.nextPoint();){i=t.x,r=t.y;const n=this._curveHelper.getLength(e,s,i,r);if(n<this._epsilon){e=i,s=r;continue}const o=.5+this._position/n,[a,h]=this._curveHelper.getAngleCS(e,s,i,r,o),c=this._curveHelper.getCoord2D(e,s,i,r,o);return this.internalPlacement.setTranslate(c[0]-this._offset*h,c[1]+this._offset*a),this._angleToLine&&this.internalPlacement.setRotateCS(a,h),this.internalPlacement}}return this.iteratePath=!1,null}const s=this._relativeTo===ce.IJ.LineEnd;return this.onLine(t,e,s)}onLine(t,e,s){let i,r=!1;switch(this._relativeTo){case ce.IJ.LineMiddle:default:t.seekPathStart(),i=t.pathLength()/2+e;break;case ce.IJ.LineBeginning:i=e;break;case ce.IJ.LineEnd:i=e,r=!0}s?t.seekPathEnd():t.seekPathStart();let n=0;if(s?t.prevPoint():t.nextPoint()){let[e,o]=[t.x,t.y],[a,h]=[0,0];for(;s?t.prevPoint():t.nextPoint();){a=t.x,h=t.y;const s=this._curveHelper.getLength(e,o,a,h);if(n+s>i){const t=(i-n)/s,[c,l]=this._curveHelper.getAngleCS(e,o,a,h,t),u=this._curveHelper.getCoord2D(e,o,a,h,t),d=r?-this._offset:this._offset;return this.internalPlacement.setTranslate(u[0]-d*l,u[1]+d*c),this._angleToLine&&(r?this.internalPlacement.setRotateCS(-c,-l):this.internalPlacement.setRotateCS(c,l)),this.internalPlacement}e=a,o=h,n+=s}}return null}}class hs{static local(){return null===hs.instance&&(hs.instance=new hs),hs.instance}execute(t,e,s,i,r){return new cs(t,e,s)}}hs.instance=null;class cs extends ae{constructor(t,e,s){super(t),this._curveHelper=new ue,this._angleToLine=void 0===e.angleToLine||e.angleToLine,this._offset=void 0!==e.offset?e.offset*s:0,this._endPoints=void 0===e.placeOnEndPoints||e.placeOnEndPoints,this._controlPoints=void 0===e.placeOnControlPoints||e.placeOnControlPoints,this._regularVertices=void 0===e.placeOnRegularVertices||e.placeOnRegularVertices,this._tags=[],this._tagIterator=0}processPath(t){if(this.iteratePath||(this._preparePath(t),this.iteratePath=!0),this._tagIterator>=this._tags.length)return this._tags.length=0,this._tagIterator=0,this.iteratePath=!1,null;const e=this._tags[this._tagIterator];this._angleToLine&&this.internalPlacement.setRotate(e[2]);let s=e[0],i=e[1];if(0!==this._offset){const t=Math.cos(e[2]),r=Math.sin(e[2]);s-=this._offset*r,i+=this._offset*t}return this.internalPlacement.setTranslate(s,i),this._tagIterator++,this.internalPlacement}_preparePath(t){this._tags.length=0,this._tagIterator=0,t.seekPathStart();const e=t.isClosed();let s=0,i=!1,r=0,n=0;if(t.seekPathStart(),t.nextPoint()){let o=t.x,a=t.y,h=t.getControlPoint(),c=!0,l=t.nextPoint();for(;l;){const u=t.x,d=t.y,p=t.getControlPoint();(this._angleToLine||0!==this._offset)&&(r=this._curveHelper.getAngle(o,a,u,d,0)),c?(c=!1,e?(s=r,i=h):(this._endPoints||this._controlPoints&&h)&&this._tags.push([o,a,r])):h?this._controlPoints&&this._tags.push([o,a,ls(n,r)]):this._regularVertices&&this._tags.push([o,a,ls(n,r)]),(this._angleToLine||0!==this._offset)&&(n=this._curveHelper.getAngle(o,a,u,d,1)),l=t.nextPoint(),l||(e?p||i?this._controlPoints&&this._tags.push([u,d,ls(n,s)]):this._regularVertices&&this._tags.push([u,d,ls(n,s)]):(this._endPoints||this._controlPoints&&p)&&this._tags.push([u,d,n])),o=u,a=d,h=p}}this._tagIterator=0}}function ls(t,e){const s=Math.PI;for(;Math.abs(e-t)>s+2e-15;)e-t>s?e-=2*s:e+=2*s;return(t+e)/2}var us=s(95788),ds=s(47452),ps=s(41980);function _s(t){if(0===t.totalSize)return null;const e=(0,Ge.IV)(t);if(!e)return null;const s=4*(Math.abs(e[0])+Math.abs(e[2])+Math.abs(e[1])+Math.abs(e[3])+1)*222045e-19;let i=0,r=0;t.reset();for(let e=0;t.nextPath();e++){const s=t.getCurrentRingArea();s>r&&(r=s,i=e)}if(t.seekPath(i),0===t.pathSize)return null;t.seekPathStart();const n=(0,Ge.yC)(t);if(Math.abs(r)<=2*s*s)return[(n[0]+n[2])/2,(n[1]+n[3])/2];t.seekPathStart();const o=(0,us.$c)(t,(0,L.Su)());if(null===o)return null;if(t.totalPoints<4)return o;const a=[[NaN,NaN],[NaN,NaN],[NaN,NaN],[NaN,NaN]],h=[NaN,NaN,NaN,NaN],c=[NaN,NaN,NaN,NaN];let l=!1,u=ms(o,t,!0);0===u.distance&&(l=!0,a[0][0]=o[0],a[0][1]=o[1],u=ms(o,t,!1)),h[0]=u.distance,c[0]=0;const d=[NaN,NaN];let p=!1,_=.25,f=-1,m=NaN;do{if(m=NaN,a[1]=gs(t,Ts(n[0],n[2],_),0,e),isNaN(a[1][0])||isNaN(a[1][1])||(u=ms(a[1],t,!1),m=u.distance),!isNaN(m)&&m>s&&fs(a[1],t))p=!0,h[1]=m,c[1]=Ps(a[1],o);else if(!isNaN(m)&&m>f&&(f=m,d[0]=a[1][0],d[1]=a[1][1]),_-=.01,_<.1){if(!(f>=0))break;p=!0,h[1]=f,a[1][0]=d[0],a[1][1]=d[1],c[1]=Ps(a[1],o)}}while(!p);p=!1,_=.5,f=-1;let g=.01,y=1;do{if(m=NaN,a[2]=gs(t,Ts(n[0],n[2],_),0,e),isNaN(a[2][0])||isNaN(a[2][1])||(u=ms(a[2],t,!1),m=u.distance),!isNaN(m)&&m>s&&fs(a[2],t))p=!0,h[2]=m,c[2]=Ps(a[2],o);else if(!isNaN(m)&&m>f)f=m,d[0]=a[2][0],d[1]=a[2][1];else if(m>f&&(f=m,d[0]=a[2][0],d[1]=a[2][1]),_=.5+g*y,g+=.01,y*=-1,_<.3||_>.7){if(!(f>=0))break;p=!0,h[2]=f,a[2][0]=d[0],a[2][1]=d[1],c[2]=Ps(a[2],o)}}while(!p);p=!1,_=.75,f=-1;do{if(m=NaN,a[3]=gs(t,Ts(n[0],n[2],_),0,e),isNaN(a[3][0])||isNaN(a[3][1])||(u=ms(a[3],t,!1),m=u.distance),!isNaN(m)&&m>s&&fs(a[3],t))p=!0,h[3]=m,c[3]=Ps(a[3],o);else if(m>f&&(f=m,d[0]=a[3][0],d[1]=a[3][1]),_+=.01,_>.9){if(!(f>=0))break;p=!0,h[3]=f,a[3][0]=d[0],a[3][1]=d[1],c[3]=Ps(a[3],o)}}while(!p);const x=[0,1,2,3],b=l?0:1;let w;for(let t=b;t<4;t++)for(let t=b;t<3;t++){const e=c[t],s=c[t+1];Ms(e,s)>0&&(w=x[t],x[t]=x[t+1],x[t+1]=w,c[t]=s,c[t+1]=e)}let v=b,S=0,I=0;for(let t=b;t<4;t++){switch(t){case 0:I=2*h[x[t]];break;case 1:I=1.66666666*h[x[t]];break;case 2:I=1.33333333*h[x[t]];break;case 3:I=h[x[t]]}I>S&&(S=I,v=x[t])}return a[v]}function fs(t,e){let s,i,r,n,o=0;for(e.reset();e.nextPath()&&e.nextPoint();)for(s=e.x,i=e.y;e.nextPoint();s=r,i=n)r=e.x,n=e.y,i>t[1]!=n>t[1]&&((r-s)*(t[1]-i)-(n-i)*(t[0]-s)>0?o++:o--);return 0!==o}function ms(t,e,s){if(s&&fs(t,e))return{coord:t,distance:0};let i=1/0,r=0,n=0,o=[0,0],a=[0,0];const h=[0,0];for(e.reset();e.nextPath()&&e.nextPoint();)if(!(e.pathSize<2))for(o[0]=e.x,o[1]=e.y;e.nextPoint();o=a){a=[e.x,e.y],(0,ds.ym)(h,t,o,a);const s=Ps(t,h);s<i&&(i=s,r=h[0],n=h[1])}return{coord:[r,n],distance:Math.sqrt(i)}}function gs(t,e,s,i){const r=[e,0];let n=1/0,o=1/0,a=!1,h=!1;const c=[[e,i[1]-1],[e,i[3]+1]],l=[0,0],u=[0,0],d=[0,0],p=[[0,0],[0,0]],_=(0,L.Su)();for(t.reset();t.nextPath()&&t.nextPoint();)if(!(t.pathSize<2))for(p[0][0]=t.x,p[0][1]=t.y;t.nextPoint();p[0][0]=p[1][0],p[0][1]=p[1][1]){if(p[1][0]=t.x,p[1][1]=t.y,null===ys(_,p))continue;if(u[0]=c[0][0],u[1]=c[0][1],d[0]=c[1][0],d[1]=c[1][1],0===Ss(_,u,d))continue;if(!(0,ps.qm)(c[0],c[1],p[0],p[1],l))continue;const e=l[1];n>o?e<n&&(n=e,a=!0):e<o&&(o=e,h=!0)}return a&&h?r[1]=(n+o)/2:r[0]=r[1]=NaN,r}function ys(t,e){if(e.length<2)return null;t||(t=(0,L.Su)());const[s,i]=e[0],[r,n]=e[1];return t[0]=Math.min(s,r),t[1]=Math.min(i,n),t[2]=Math.max(s,r),t[3]=Math.max(i,n),t}const xs=1,bs=4,ws=3,vs=12;function Ss(t,e,s){let i=Is(e,t),r=Is(s,t);const n=t[0],o=t[1],a=t[2],h=t[3];if(i&r)return 0;if(!(i|r))return 4;const c=(i?1:0)|(r?2:0);do{const c=s[0]-e[0],l=s[1]-e[1];if(c>l)i&ws?(i&xs?(e[1]+=l*(n-e[0])/c,e[0]=n):(e[1]+=l*(a-e[0])/c,e[0]=a),i=Is(e,t)):r&ws?(r&xs?(s[1]+=l*(n-s[0])/c,s[0]=n):(s[1]+=l*(a-s[0])/c,s[0]=a),r=Is(s,t)):i?(i&bs?(e[0]+=c*(o-e[1])/l,e[1]=o):(e[0]+=c*(h-e[1])/l,e[1]=h),i=Is(e,t)):(r&bs?(s[0]+=c*(o-s[1])/l,s[1]=o):(s[0]+=c*(h-s[1])/l,s[1]=h),r=Is(s,t));else if(i&vs?(i&bs?(e[0]+=c*(o-e[1])/l,e[1]=o):(e[0]+=c*(h-e[1])/l,e[1]=h),i=Is(e,t)):r&vs?(r&bs?(s[0]+=c*(o-s[1])/l,s[1]=o):(s[0]+=c*(h-s[1])/l,s[1]=h),r=Is(s,t)):i?(i&xs?(e[1]+=l*(n-e[0])/c,e[0]=n):(e[1]+=l*(a-e[0])/c,e[0]=a),i=Is(e,t)):(r&xs?(s[1]+=l*(n-s[0])/c,s[0]=n):(s[1]+=l*(a-s[0])/c,s[0]=a),r=Is(s,t)),i&r)return 0}while(i|r);return c}function Is(t,e){return(t[0]<e[0]?1:0)|(t[0]>e[2]?1:0)<<1|(t[1]<e[1]?1:0)<<2|(t[1]>e[3]?1:0)<<3}function Ts(t,e,s){return t+(e-t)*s}function Ps(t,e){return(t[0]-e[0])*(t[0]-e[0])+(t[1]-e[1])*(t[1]-e[1])}function Ms(t,e){if(t<e)return-1;if(t>e)return 1;if(t===e)return 0;const s=isNaN(t),i=isNaN(e);return s<i?-1:s>i?1:0}class Es{static local(){return null===Es.instance&&(Es.instance=new Es),Es.instance}execute(t,e,s,i,r){return new Cs(t,e,s)}}Es.instance=null;class Cs{constructor(t,e,s){this._geometryCursor=t,this._offsetX=void 0!==e.offsetX?e.offsetX*s:0,this._offsetY=void 0!==e.offsetY?e.offsetY*s:0,this._method=void 0!==e.method?e.method:ce.ms.OnPolygon,this._internalPlacement=new ne}next(){const t=this._geometryCursor;return this._geometryCursor=null,t?this._polygonCenter(t):null}_polygonCenter(t){let e=!1;switch(this._method){case ce.ms.CenterOfMass:{const s=(0,us.iy)(t);s&&(this._internalPlacement.setTranslate(s[0]+this._offsetX,s[1]+this._offsetY),e=!0)}break;case ce.ms.BoundingBoxCenter:{const s=(0,Ge.IV)(t);s&&(this._internalPlacement.setTranslate((s[2]+s[0])/2+this._offsetX,(s[3]+s[1])/2+this._offsetY),e=!0)}break;case ce.ms.OnPolygon:default:{const s=_s(t);null!==s&&(this._internalPlacement.setTranslate(s[0]+this._offsetX,s[1]+this._offsetY),e=!0)}}return e?this._internalPlacement:null}}function ks(t){if(!t)return null;switch(t.type){case"CIMGeometricEffectAddControlPoints":return ie.local();case"CIMGeometricEffectArrow":return pe.local();case"CIMGeometricEffectBuffer":return fe.local();case"CIMGeometricEffectControlMeasureLine":return ge.local();case"CIMGeometricEffectCut":return xe.local();case"CIMGeometricEffectDashes":return Ee.local();case"CIMGeometricEffectDonut":return ke.local();case"CIMGeometricEffectJog":return Ae.local();case"CIMGeometricEffectMove":return Oe.local();case"CIMGeometricEffectOffset":return De.local();case"CIMGeometricEffectReverse":return Le.local();case"CIMGeometricEffectRotate":return Ve.local();case"CIMGeometricEffectScale":return We.local();case"CIMGeometricEffectWave":return Ye.local()}return null}new(s(60024).c),s(73771),s(6220),new Map,new Set,s(60536),s(39056);var Fs=s(47364);function As(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t[4]=0,t[5]=0,t}function Rs(t,e,s){const i=e[0],r=e[1],n=e[2],o=e[3],a=e[4],h=e[5],c=s[0],l=s[1],u=s[2],d=s[3],p=s[4],_=s[5];return t[0]=i*c+n*l,t[1]=r*c+o*l,t[2]=i*u+n*d,t[3]=r*u+o*d,t[4]=i*p+n*_+a,t[5]=r*p+o*_+h,t}function Os(t,e,s){const i=e[0],r=e[1],n=e[2],o=e[3],a=e[4],h=e[5],c=Math.sin(s),l=Math.cos(s);return t[0]=i*l+n*c,t[1]=r*l+o*c,t[2]=i*-c+n*l,t[3]=r*-c+o*l,t[4]=a,t[5]=h,t}function Ns(t,e,s){const i=e[0],r=e[1],n=e[2],o=e[3],a=e[4],h=e[5],c=s[0],l=s[1];return t[0]=i,t[1]=r,t[2]=n,t[3]=o,t[4]=i*c+n*l+a,t[5]=r*c+o*l+h,t}function Ds(t,e){const s=Math.sin(e),i=Math.cos(e);return t[0]=i,t[1]=s,t[2]=-s,t[3]=i,t[4]=0,t[5]=0,t}function zs(t,e,s){return t[0]=e[0]-s[0],t[1]=e[1]-s[1],t[2]=e[2]-s[2],t[3]=e[3]-s[3],t[4]=e[4]-s[4],t[5]=e[5]-s[5],t}const Ls=Rs,Bs=zs;function Us(){const t=new Float32Array(6);return t[0]=1,t[3]=1,t}function Gs(t,e,s,i){const r=e[i],n=e[i+1];t[i]=s[0]*r+s[2]*n+s[4],t[i+1]=s[1]*r+s[3]*n+s[5]}function Vs(t,e,s,i=0,r=0,n=2){const o=r||e.length/n;for(let r=i;r<o;r++)Gs(t,e,s,r*n)}Object.freeze(Object.defineProperty({__proto__:null,add:function(t,e,s){return t[0]=e[0]+s[0],t[1]=e[1]+s[1],t[2]=e[2]+s[2],t[3]=e[3]+s[3],t[4]=e[4]+s[4],t[5]=e[5]+s[5],t},copy:function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t},determinant:function(t){return t[0]*t[3]-t[1]*t[2]},equals:function(t,e){const s=t[0],i=t[1],r=t[2],n=t[3],o=t[4],a=t[5],h=e[0],c=e[1],l=e[2],u=e[3],d=e[4],p=e[5],_=(0,Fs.Au)();return Math.abs(s-h)<=_*Math.max(1,Math.abs(s),Math.abs(h))&&Math.abs(i-c)<=_*Math.max(1,Math.abs(i),Math.abs(c))&&Math.abs(r-l)<=_*Math.max(1,Math.abs(r),Math.abs(l))&&Math.abs(n-u)<=_*Math.max(1,Math.abs(n),Math.abs(u))&&Math.abs(o-d)<=_*Math.max(1,Math.abs(o),Math.abs(d))&&Math.abs(a-p)<=_*Math.max(1,Math.abs(a),Math.abs(p))},exactEquals:function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]},frob:function(t){return Math.sqrt(t[0]**2+t[1]**2+t[2]**2+t[3]**2+t[4]**2+t[5]**2+1)},fromRotation:Ds,fromScaling:function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=e[1],t[4]=0,t[5]=0,t},fromTranslation:function(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t[4]=e[0],t[5]=e[1],t},identity:As,invert:function(t,e){const s=e[0],i=e[1],r=e[2],n=e[3],o=e[4],a=e[5];let h=s*n-i*r;return h?(h=1/h,t[0]=n*h,t[1]=-i*h,t[2]=-r*h,t[3]=s*h,t[4]=(r*a-n*o)*h,t[5]=(i*o-s*a)*h,t):null},mul:Ls,multiply:Rs,multiplyScalar:function(t,e,s){return t[0]=e[0]*s,t[1]=e[1]*s,t[2]=e[2]*s,t[3]=e[3]*s,t[4]=e[4]*s,t[5]=e[5]*s,t},multiplyScalarAndAdd:function(t,e,s,i){return t[0]=e[0]+s[0]*i,t[1]=e[1]+s[1]*i,t[2]=e[2]+s[2]*i,t[3]=e[3]+s[3]*i,t[4]=e[4]+s[4]*i,t[5]=e[5]+s[5]*i,t},rotate:Os,scale:function(t,e,s){const i=e[0],r=e[1],n=e[2],o=e[3],a=e[4],h=e[5],c=s[0],l=s[1];return t[0]=i*c,t[1]=r*c,t[2]=n*l,t[3]=o*l,t[4]=a,t[5]=h,t},set:function(t,e,s,i,r,n,o){return t[0]=e,t[1]=s,t[2]=i,t[3]=r,t[4]=n,t[5]=o,t},str:function(t){return"mat2d("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+")"},sub:Bs,subtract:zs,translate:Ns},Symbol.toStringTag,{value:"Module"})),Object.freeze(Object.defineProperty({__proto__:null,clone:function(t){const e=new Float32Array(6);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e},create:Us,createView:function(t,e){return new Float32Array(t,e,6)},fromValues:function(t,e,s,i,r,n){const o=new Float32Array(6);return o[0]=t,o[1]=e,o[2]=s,o[3]=i,o[4]=r,o[5]=n,o},transform:Gs,transformMany:Vs},Symbol.toStringTag,{value:"Module"}));var qs=s(38600);const Ws=()=>C.c.getLogger("geoscene.views.2d.engine.webgl.alignmentUtils");var Xs,Ys,js;function Hs(t){if(!t)return Xs.Center;switch(t){case"Left":case"left":return Xs.Left;case"Right":case"right":return Xs.Right;case"Justify":return Ws().warnOnce("Horizontal alignment 'justify' is not implemented. Falling back to 'center'."),Xs.Center;case"Center":case"center":return Xs.Center}}function $s(t){if(!t)return Ys.Center;switch(t){case"Top":case"top":return Ys.Top;case"Center":case"middle":return Ys.Center;case"Baseline":case"baseline":return Ys.Baseline;case"Bottom":case"bottom":return Ys.Bottom}}(js=Xs||(Xs={}))[js.Left=-1]="Left",js[js.Center=0]="Center",js[js.Right=1]="Right",function(t){t[t.Top=1]="Top",t[t.Center=0]="Center",t[t.Bottom=-1]="Bottom",t[t.Baseline=2]="Baseline"}(Ys||(Ys={}));var Ks=s(27364);class Zs{constructor(t,e,s,i){this.computedX=0,this.computedY=0,this.center=(0,qs.WK)(t,e),this.centerT=(0,qs.Su)(),this.halfWidth=s/2,this.halfHeight=i/2,this.width=s,this.height=i}get x(){return this.center[0]}get y(){return this.center[1]}get blX(){return this.center[0]+this.halfWidth}get blY(){return this.center[1]+this.halfHeight}get trX(){return this.center[0]-this.halfWidth}get trY(){return this.center[1]-this.halfHeight}get xmin(){return this.x-this.halfWidth}get xmax(){return this.x+this.halfWidth}get ymin(){return this.y-this.halfHeight}get ymax(){return this.y+this.halfHeight}set x(t){this.center[0]=t}set y(t){this.center[1]=t}clone(){return new Zs(this.x,this.y,this.width,this.height)}serialize(t){return t.writeF32(this.center[0]),t.writeF32(this.center[1]),t.push(this.width),t.push(this.height),t}findCollisionDelta(t,e=4){const s=Math.abs(t.centerT[0]-this.centerT[0]),i=Math.abs(t.centerT[1]-this.centerT[1]),r=(t.halfWidth+this.halfWidth+e)/s,n=(t.halfHeight+this.halfHeight+e)/i,o=Math.min(r,n);return Math.log2(o)}extend(t){const e=Math.min(this.xmin,t.xmin),s=Math.min(this.ymin,t.ymin),i=Math.max(this.xmax,t.xmax)-e,r=Math.max(this.ymax,t.ymax)-s,n=e+i/2,o=s+r/2;this.width=i,this.height=r,this.halfWidth=i/2,this.halfHeight=r/2,this.x=n,this.y=o}static deserialize(t){const e=t.readF32(),s=t.readF32(),i=t.readInt32(),r=t.readInt32();return new Zs(e,s,i,r)}}const Qs=Math.PI/180;class Js{constructor(t,e,s,i){this._rotationT=Us(),this._xBounds=0,this._yBounds=0,this.minZoom=0,this.maxZoom=255,this._bounds=null;const r=s.rect,n=new Float32Array(8);t*=i,e*=i;const o=s.code?r.width*i:s.metrics.width,a=s.code?r.height*i:s.metrics.height;this.width=o,this.height=a,n[0]=t,n[1]=e,n[2]=t+o,n[3]=e,n[4]=t,n[5]=e+a,n[6]=t+o,n[7]=e+a,this._data=n,this._setTextureCoords(r),this._scale=i,this._mosaic=s,this.x=t,this.y=e,this.maxOffset=Math.max(t+o,e+a)}get mosaic(){return this._mosaic}set angle(t){this._angle=t,Ds(this._rotationT,-t),this._setOffsets()}get angle(){return this._angle}get xTopLeft(){return this._data[0]}get yTopLeft(){return this._data[1]}get xBottomRight(){return this._data[6]}get yBottomRight(){return this._data[7]}get texcoords(){return this._texcoords}get textureBinding(){return this._mosaic.textureBinding}get offsets(){return this._offsets||this._setOffsets(),this._offsets}get char(){return String.fromCharCode(this._mosaic.code)}get code(){return this._mosaic.code}get bounds(){if(!this._bounds){const{height:t,width:e}=this._mosaic.metrics,s=e*this._scale,i=Math.abs(t)*this._scale,r=new Float32Array(8);r[0]=this.x,r[1]=this.y,r[2]=this.x+s,r[3]=this.y,r[4]=this.x,r[5]=this.y+i,r[6]=this.x+s,r[7]=this.y+i,Vs(r,r,Rs(Us(),this._rotationT,this._transform));let n=1/0,o=1/0,a=0,h=0;for(let t=0;t<4;t++){const e=r[2*t],s=r[2*t+1];n=Math.min(n,e),o=Math.min(o,s),a=Math.max(a,e),h=Math.max(h,s)}const c=a-n,l=h-o,u=n+c/2,d=o+l/2;this._bounds=new Zs(u,d,c,l)}return this._bounds}setTransform(t){this._transform=t,this._offsets=null}_setOffsets(){this._offsets||(this._offsets={topLeft:[0,0],topRight:[0,0],bottomLeft:[0,0],bottomRight:[0,0]});const t=Rs(Us(),this._rotationT,this._transform);this._offsets.topLeft[0]=this._data[0],this._offsets.topLeft[1]=this._data[1],this._offsets.topRight[0]=this._data[2],this._offsets.topRight[1]=this._data[3],this._offsets.bottomLeft[0]=this._data[4],this._offsets.bottomLeft[1]=this._data[5],this._offsets.bottomRight[0]=this._data[6],this._offsets.bottomRight[1]=this._data[7],(0,F.m4)(this._offsets.topLeft,this._offsets.topLeft,t),(0,F.m4)(this._offsets.topRight,this._offsets.topRight,t),(0,F.m4)(this._offsets.bottomLeft,this._offsets.bottomLeft,t),(0,F.m4)(this._offsets.bottomRight,this._offsets.bottomRight,t)}_setTextureCoords({x:t,y:e,width:s,height:i}){this._texcoords={topLeft:[t,e],topRight:[t+s,e],bottomLeft:[t,e+i],bottomRight:[t+s,e+i]}}}const ti=(t,e)=>({code:0,page:0,sdf:!0,rect:new Ks.c(0,0,11,8),textureBinding:e,metrics:{advance:0,height:4,width:t,left:0,top:0}});function ei(t,e){return t.forEach((t=>(0,F.m4)(t,t,e))),{topLeft:t[0],topRight:t[1],bottomLeft:t[2],bottomRight:t[3]}}class si{constructor(t,e,s){this._rotation=0,this._decorate(t,e,s),this.glyphs=t,this.bounds=this._createBounds(t),this.isMultiline=e.length>1,this._hasRotation=0!==s.angle,this._transform=this._createGlyphTransform(this.bounds,s),this._borderLineSizePx=s.borderLineSizePx,(s.borderLineSizePx||s.hasBackground)&&([this.bounds,this.textBox]=this.shapeBackground(this._transform));for(const e of t)e.setTransform(this._transform)}setRotation(t){if(0===t&&0===this._rotation)return;this._rotation=t;const e=this._transform;Rs(e,Ds(Us(),t),e);for(const t of this.glyphs)t.setTransform(this._transform)}_decorate(t,e,s){if(!s.decoration||"none"===s.decoration||!t.length)return;const i=s.scale,r="underline"===s.decoration?26:16,n=t[0].textureBinding;for(const s of e){const e=s.startX*i,o=s.startY*i,a=(s.width+s.glyphWidthEnd)*i;t.push(new Js(e,o+r*i,ti(a,n),1))}}shapeBackground(t){const e=(1.5+(this._borderLineSizePx||0))/2,s=this._borderLineSizePx?e:0,{xmin:i,ymin:r,xmax:n,ymax:o,x:a,y:h,width:c,height:l}=this.bounds,u=[i-8,r-8],d=[n+8,r-8],p=[i-8,o+8],_=[n+8,o+8],f=ei([[u[0]-e,u[1]-e],[d[0]+e,d[1]-e],[u[0]+s,u[1]+s],[d[0]-s,d[1]+s]],t),m=ei([[p[0]+s,p[1]-s],[_[0]-s,_[1]-s],[p[0]-e,p[1]+e],[_[0]+e,_[1]+e]],t),g=ei([[u[0]-e,u[1]-e],[u[0]+s,u[1]+s],[p[0]-e,p[1]+e],[p[0]+s,p[1]-s]],t),y=ei([[d[0]-s,d[1]+s],[d[0]+e,d[1]-e],[_[0]-s,_[1]-s],[_[0]+e,_[1]+e]],t),x={main:ei([u,d,p,_],t),top:f,bot:m,left:g,right:y};return[new Zs(a,h,c+2*e,l+2*e),x]}get boundsT(){const t=this.bounds,e=(0,F.WO)((0,qs.Su)(),t.x,t.y);if((0,F.m4)(e,e,this._transform),this._hasRotation){const s=Math.max(t.width,t.height);return new Zs(e[0],e[1],s,s)}return new Zs(e[0],e[1],t.width,t.height)}_createBounds(t){let e=1/0,s=1/0,i=0,r=0;for(const n of t)e=Math.min(e,n.xTopLeft),s=Math.min(s,n.yTopLeft),i=Math.max(i,n.xBottomRight),r=Math.max(r,n.yBottomRight);const n=i-e,o=r-s;return new Zs(e+n/2,s+o/2,n,o)}_createGlyphTransform(t,e){const s=Qs*e.angle,i=Us(),r=(0,qs.Su)();return Ns(i,i,(0,F.WO)(r,e.xOffset,-e.yOffset)),e.useCIMAngleBehavior?Os(i,i,s):(Ns(i,i,(0,F.WO)(r,t.x,t.y)),Os(i,i,s),Ns(i,i,(0,F.WO)(r,-t.x,-t.y))),i}}class ii{constructor(t,e,s,i,r,n){this.glyphWidthEnd=0,this.startX=0,this.startY=0,this.start=Math.max(0,Math.min(e,s)),this.end=Math.max(0,Math.max(e,s)),this.end<t.length&&(this.glyphWidthEnd=t[this.end].metrics.width),this.width=i,this.yMin=r,this.yMax=n}}const ri=t=>10===t,ni=t=>32===t;Math.PI,s(45704);var oi=s(51760);function ai(t){if(!t)return 0;switch(t.type){case"CIMGeometricEffectArrow":return Math.abs(.5*t.width);case"CIMGeometricEffectBuffer":return Math.abs(t.size);case"CIMGeometricEffectExtension":case"CIMGeometricEffectRadial":return Math.abs(t.length);case"CIMGeometricEffectJog":return Math.abs(.5*t.length);case"CIMGeometricEffectMove":return Math.max(Math.abs((0,Me.uc)(t.offsetX)),Math.abs((0,Me.uc)(t.offsetY)));case"CIMGeometricEffectOffset":case"CIMGeometricEffectOffsetTangent":return Math.abs(t.offset);case"CIMGeometricEffectRegularPolygon":return Math.abs(t.radius);case"CIMGeometricEffectRotate":case"CIMGeometricEffectScale":default:return 0;case"CIMGeometricEffectTaperedPolygon":return.5*Math.max(Math.abs(t.fromWidth),Math.abs(t.toWidth));case"CIMGeometricEffectWave":return Math.abs(t.amplitude);case"CIMGeometricEffectDonut":return Math.abs(t.width)}}function hi(t){if(!t)return 0;let e=0;for(const s of t)e+=ai(s);return e}Math.PI,Math.PI;class ci{static executeEffects(t,e,s,i){const r=hi(t);let n=new ee(e);for(const e of t){const t=ks(e);t&&(n=t.execute(n,e,1.3333333333333333,s,i,r))}return n}static applyEffects(t,e,s){if(!t)return e;const i=hi(t);let r,n=new ee(jt.fromJSONCIM(e));for(const e of t){const t=ks(e);t&&(n=t.execute(n,e,1,null,s,i))}const o=[];let a=null;for(;r=n.next();)o.push(...(0,Xt.k)(r)),a=r.geometryType;return 0===o.length||null===a?null:"esriGeometryPolygon"===a?{rings:o}:{paths:o}}}let li=null;function ui(){return li}const di=new Float32Array(1);new Uint32Array(di.buffer);var pi=s(77800);function _i(t){switch(t){case pi.Ck.BYTE:case pi.Ck.UNSIGNED_BYTE:return 1;case pi.Ck.SHORT:case pi.Ck.UNSIGNED_SHORT:return 2;case pi.Ck.FLOAT:case pi.Ck.INT:case pi.Ck.UNSIGNED_INT:return 4}}class fi{static fromVertexSpec({attributes:t},e){let s,i,r;const n=[];for(const o in t){const a=t[o];!1!==e?.[o]&&("position"===a.pack?s={...a,name:o,offset:0}:"id"===a.pack?i={...a,name:o,offset:4}:"bitset"===o?r={...a,name:o,offset:7}:n.push({...a,name:o}))}const o=function(t){const e=[],s=[],i=[];for(const r of t){const t=_i(r.type)*r.count;switch(t%2||t%4||4){case 4:e.push(r);continue;case 2:s.push(r);continue;case 1:i.push(r);continue;default:throw new Error("Found unexpected dataType byte count")}}return e.push(...s),e.push(...i),e}(n),a=[];let h=8,c=1;for(const t of o)a.push({...t,offset:h}),h+=_i(t.type)*t.count,t.packAlternating&&(c=Math.max(t.packAlternating.count,c));const l=Uint32Array.BYTES_PER_ELEMENT,u=h%l;return new fi(s,i,r,a,h+(u?l-u:0),c)}constructor(t,e,s,i,r,n){this.position=t,this.id=e,this.bitset=s,this.standardAttributes=i,this.stride=r,this.packVertexCount=n,i.push(s),this._attributes=[t,e,s,...i]}get attributeLayout(){if(!this._attributeLayout){const t=function(t){const e=t.map((({name:t,count:e,type:s})=>`${t}.${e}.${s}`)).join(",");return(0,st.sV)(e)}(this._attributes),e=this._attributes.map((t=>({name:t.name,count:t.count,offset:t.offset,type:t.type,packPrecisionFactor:t.packPrecisionFactor,normalized:t.normalized??!1})));this._attributeLayout={attributes:e,hash:t,stride:this.stride}}return this._attributeLayout}}class mi{static fromVertexSpec(t,e){const s=fi.fromVertexSpec(t,e);return new mi(s)}constructor(t){this._spec=t,this._packed=new Uint8Array(this._spec.stride*this._spec.packVertexCount),this._packedU32View=new Uint32Array(this._packed.buffer),this._dataView=new DataView(this._packed.buffer)}get attributeLayout(){return this._spec.attributeLayout}get stride(){return this._spec.stride}writeVertex(t,e,s,i,r,n){for(let t=0;t<this._spec.packVertexCount;t++){const o=t*this._spec.stride;this._packPosition(s,i,o),this._packId(e,o);const a=this._spec.bitset;if(n){if(a.packTessellation){const t=a.packTessellation(n,r);this._pack(t,a,o)}for(const t of this._spec.standardAttributes)if(null!=t.packTessellation){const e=t.packTessellation(n,r);this._pack(e,t,o)}else if(t.packAlternating?.packTessellation){const e=t.packAlternating.packTessellation(n,r);for(let s=0;s<this._spec.packVertexCount;s++){const i=e[s];this._pack(i,t,s*this._spec.stride)}}}}t.vertexWriteRegion(this._packedU32View)}pack(t,e){for(const s of this._spec.standardAttributes)if(s.pack&&"string"!=typeof s.pack){const i=s.pack(t,e);for(let t=0;t<this._spec.packVertexCount;t++)this._pack(i,s,t*this._spec.stride)}else if(s.packAlternating?.pack){const i=s.packAlternating.pack(t,e);for(let t=0;t<this._spec.packVertexCount;t++){const e=i[t];this._pack(e,s,t*this._spec.stride)}}}_packPosition(t,e,s){const{offset:i}=this._spec.position,r=this._spec.position.packPrecisionFactor??1,n=65535&t*r|e*r<<16;this._dataView.setUint32(s+i,n,!0)}_packId(t,e){const s=t*(this._spec.id.packPrecisionFactor??1),i=4278190080&this._dataView.getUint32(e+this._spec.id.offset,!0);this._dataView.setUint32(e+this._spec.id.offset,s|i,!0)}_pack(t,e,s){!function(t,e,s,i){const r=s.packPrecisionFactor??1;switch(s.type){case pi.Ck.BYTE:if(1===s.count)t.setInt8(i+s.offset,e*r);else for(let n=0;n<s.count;n++){const o=n*Int8Array.BYTES_PER_ELEMENT;t.setInt8(i+s.offset+o,e[n]*r)}break;case pi.Ck.UNSIGNED_BYTE:if(1===s.count)t.setUint8(i+s.offset,e*r);else for(let n=0;n<s.count;n++){const o=n*Uint8Array.BYTES_PER_ELEMENT;t.setUint8(i+s.offset+o,e[n]*r)}break;case pi.Ck.SHORT:if(1===s.count)t.setInt16(i+s.offset,e*r,!0);else for(let n=0;n<s.count;n++){const o=n*Int16Array.BYTES_PER_ELEMENT;t.setInt16(i+s.offset+o,e[n]*r,!0)}break;case pi.Ck.UNSIGNED_SHORT:if(1===s.count)t.setUint16(i+s.offset,e*r,!0);else for(let n=0;n<s.count;n++){const o=n*Uint16Array.BYTES_PER_ELEMENT;t.setUint16(i+s.offset+o,e[n]*r,!0)}break;case pi.Ck.INT:if(1===s.count)t.setInt32(i+s.offset,e*r,!0);else for(let n=0;n<s.count;n++){const o=n*Int32Array.BYTES_PER_ELEMENT;t.setInt32(i+s.offset+o,e[n]*r,!0)}break;case pi.Ck.UNSIGNED_INT:if(1===s.count)t.setUint32(i+s.offset,e*r,!0);else for(let n=0;n<s.count;n++){const o=n*Uint32Array.BYTES_PER_ELEMENT;t.setUint32(i+s.offset+o,e[n]*r,!0)}break;case pi.Ck.FLOAT:if(1===s.count)t.setFloat32(i+s.offset,e*r,!0);else for(let n=0;n<s.count;n++){const o=n*Float32Array.BYTES_PER_ELEMENT;t.setFloat32(i+s.offset+o,e[n]*r,!0)}}}(this._dataView,t,e,s)}}class gi{constructor(t,e,s,i){this._instanceId=t,this._evaluator=e,this._viewParams=s,this._optionalAttributes=i,this._evaluator.evaluator=t=>this.vertexSpec.createComputedParams(t)}get _vertexPack(){if(!this._cachedVertexPack){const t=mi.fromVertexSpec(this.vertexSpec,this._optionalAttributes);this._evaluator.hasDynamicProperties||t.pack(this._evaluator.evaluatedMeshParams,this._viewParams),this._cachedVertexPack=t}return this._cachedVertexPack}get evaluatedMeshParams(){return this._evaluator.evaluatedMeshParams}get hasEffects(){return!!this.evaluatedMeshParams.effects}get instanceId(){return this._instanceId}get attributeLayout(){return this._vertexPack.attributeLayout}setReferences(t){this._references=t}getBoundsInfo(){return null}getTileInfo(){return this._viewParams.tileInfo}async loadDependencies(){(function(t){if(!t)return!1;for(const e of t)switch(e.effect.type){case"CIMGeometricEffectBuffer":case"CIMGeometricEffectOffset":case"CIMGeometricEffectDonut":return!0}return!1})(this._evaluator.inputMeshParams.params.effects?.effectInfos)&&await async function(){li=await Promise.all([s.e(984),s.e(324)]).then(s.bind(s,82704))}()}enqueueRequest(t,e,s){this._evaluator.hasDynamicProperties&&this._evaluator.enqueueRequest(t,e,s)}write(t,e,s,i,r){this.ensurePacked(e,s,i);const n=this.evaluatedMeshParams.effects;if(!n||0===n.length)return void this._write(t,s,void 0,r);const o=s.readGeometryForDisplay()?.clone();if(!o)return;const a=jt.fromOptimizedCIM(o,s.geometryType),h=ui();a.invertY();const c=t.id||"",l=ci.executeEffects(n,a,c,h);let u;for(;u=l.next();)u.invertY(),this._write(t,s,u,r)}ensurePacked(t,e,s){if(!this._evaluator.hasDynamicProperties)return;const i=this._evaluator.evaluateMeshParams(t,e,s);this._vertexPack.pack(i,this._viewParams)}_writeVertex(t,e,s,i,r){const n=this.evaluatedMeshParams;this._vertexPack.writeVertex(t,e,s,i,n,r)}}const yi=(0,n.c)("featurelayer-fast-triangulation-enabled");class xi extends gi{async loadDependencies(){await Promise.all([super.loadDependencies(),(0,pt.C)()])}_write(t,e,s){const i=s?.asOptimized()??e.readGeometryForDisplay(),r=this._clip(i);r&&(t.recordStart(this.instanceId,this.attributeLayout),this._writeGeometry(t,e,r),t.recordEnd())}_clip(t){return t?function(t,e){if(null==t)return null;if(!function(t,e,s){let i=0;for(let e=0;e<t.lengths.length;e++){const r=t.lengths[e];for(let e=0;e<r;e++){const r=t.coords[2*(e+i)],n=t.coords[2*(e+i)+1];if(r<-128||r>s||n<-128||n>s)return!0}i+=r}return!1}(t,0,B.gT+128))return t;Gt.setPixelMargin(e),Gt.reset(_t.ao.Polygon);let s=0;for(let e=0;e<t.lengths.length;e++){const i=t.lengths[e];let r=t.coords[2*(0+s)],n=t.coords[2*(0+s)+1];Gt.moveTo(r,n);for(let e=1;e<i;e++)r=t.coords[2*(e+s)],n=t.coords[2*(e+s)+1],Gt.lineTo(r,n);Gt.close(),s+=i}const i=Gt.result(!1);if(!i)return null;const r=[],n=[];for(const t of i){let e=0;for(const s of t)n.push(s.x),n.push(s.y),e++;r.push(e)}return new ft.c(r,n)}(t,this.hasEffects?256:8):null}_writeGeometry(t,e,s){const i=s.maxLength>100,r=[],n=this.createTesselationParams(e);if(!i&&yi&&function(t,e){const{coords:s,lengths:i,hasIndeterminateRingOrder:r}=e,n=t;if(r)return!1;let o=0;for(let t=0;t<i.length;){let e=t,r=i[t],a=qt(s,o,r);const h=[];for(;++e<i.length;){const t=i[e],n=qt(s,o+r,t);if(!(n>0))break;a+=n,h.push(o+r),r+=t}const c=n.length;mt(n,s,o,o+r,h,2,0);const l=Wt(n,s,c,n.length,0),u=Math.abs(a);if(Math.abs((l-u)/Math.max(1e-7,u))>1e-5)return n.length=0,!1;t=e,o+=r}return!0}(r,s))return void(r.length&&this._writeVertices(t,e,s.coords,n,r));const o=function(t){const{coords:e,lengths:s}=t,{buffer:i}=(0,pt.y)(e,s);return i}(s);this._writeVertices(t,e,o,n)}_writeVertices(t,e,s,i,r){const n=e.getDisplayId(),o=t.vertexCount(),a=this.hasEffects;let h=0;if(r)for(const e of r){const r=s[2*e],o=s[2*e+1];a&&t.recordBounds(r,o,0,0),this._writeVertex(t,n,r,o,i),h++}else for(let e=0;e<s.length;e+=2){const r=Math.round(s[e]),o=Math.round(s[e+1]);a&&t.recordBounds(r,o,0,0),this._writeVertex(t,n,r,o,i),h++}t.indexEnsureSize(h);for(let e=0;e<h;e++)t.indexWrite(e+o)}}const bi={createComputedParams:t=>t,attributes:{id:{type:pi.Ck.UNSIGNED_BYTE,count:3,pack:"id"},bitset:{type:pi.Ck.UNSIGNED_BYTE,count:1},pos:{type:pi.Ck.SHORT,count:2,pack:"position",packPrecisionFactor:10},inverseArea:{type:pi.Ck.FLOAT,count:1,packTessellation:({inverseArea:t})=>t}}};var wi=s(44728);function vi(t,e){return[!!t?.minScale&&e.scaleToZoom(t.minScale)||0,!!t?.maxScale&&e.scaleToZoom(t.maxScale)||100]}function Si(t){return 1<<t}function Ii(t){let e=0;for(const[s,i]of t)i&&(e|=1<<s);return e}function Ti(t){let e;if(!t)return[0,0,0,0];if("string"==typeof t){const s=wi.c.fromString(t);if(!s)return C.c.getLogger("geoscene.views.2d.engine.webgl.shaderGraph.techniques.meshWriterUtils").errorOnce(new i.c("mapview:mesh-processing","Unable to parse string into color",{color:t})),[0,0,0,0];e=s.toArray()}else e=t;const[s,r,n,o]=e;return[s*(o/255),r*(o/255),n*(o/255),o]}function Pi(t,e){return Math.round(Math.min(Math.sqrt(t*e),255))}function Mi(t,e){return Math.round(t*e)/e}function Ei(t,e){return Math.ceil(t*e)/e}const Ci={createComputedParams:t=>t,attributes:{id:{type:pi.Ck.UNSIGNED_BYTE,count:3,pack:"id"},bitset:{type:pi.Ck.UNSIGNED_BYTE,count:1},pos:{type:pi.Ck.SHORT,count:2,pack:"position",packPrecisionFactor:10},zoomRange:{type:pi.Ck.SHORT,count:2,packPrecisionFactor:B.M6,pack:({scaleInfo:t},{tileInfo:e})=>vi(t,e)},color:{type:pi.Ck.UNSIGNED_BYTE,count:4,normalized:!0,pack:({color:t})=>Ti(t)}}};class ki extends xi{constructor(){super(...arguments),this.vertexSpec=Ci}createTesselationParams(t){return null}}const Fi={createComputedParams:t=>t,attributes:{...Ci.attributes,tlbr:{count:4,type:pi.Ck.UNSIGNED_SHORT,pack:({sprite:t})=>{const{rect:e,width:s,height:i}=t,r=e.x+B.mc,n=e.y+B.mc;return[r,n,r+s,n+i]}},inverseRasterizationScale:{count:1,type:pi.Ck.BYTE,packPrecisionFactor:16,pack:({sprite:t})=>1/t.rasterizationScale}}};class Ai extends ki{constructor(){super(...arguments),this.vertexSpec=Fi}_write(t,e,s){const i=s?.asOptimized()??e.readGeometryForDisplay(),r=this._clip(i);if(!r)return;const n=this.evaluatedMeshParams.sprite?.textureBinding;t.recordStart(this.instanceId,this.attributeLayout,n),this._writeGeometry(t,e,r),t.recordEnd()}}var Ri,Oi;(Oi=Ri||(Ri={}))[Oi.Geographic=0]="Geographic",Oi[Oi.Arithmatic=1]="Arithmatic";const Ni=1.1,Di=1,zi=1e-5,Li=.05,Bi=1e-30,Ui=2;function Gi(t){const{sprite:e,aspectRatio:s,scaleProportionally:i}=t,r=(0,l.im)(t.height),n=r>0?r:e.height;let o=r*s;return o<=0?o=e.width:i&&(o*=e.width/e.height),{width:o,height:n}}function Vi(t){const{applyRandomOffset:e,sampleAlphaOnly:s}=t,{width:i,height:r}=Gi(t);return Ii([[Ui,e],[4,s],[6,i<B.c5],[5,r<B.c5]])}function qi(t){const{width:e}=Gi(t);return Math.round(e<B.c5?e*B.Q0:e)}function Wi(t){const{height:e}=Gi(t);return Math.round(e<B.c5?e*B.Q0:e)}const Xi={createComputedParams:t=>t,attributes:{...Fi.attributes,bitset:{count:1,type:pi.Ck.UNSIGNED_BYTE,pack:Vi},width:{count:1,type:pi.Ck.UNSIGNED_SHORT,pack:qi},height:{count:1,type:pi.Ck.UNSIGNED_SHORT,pack:Wi},offset:{count:2,type:pi.Ck.SHORT,pack:({offsetX:t,offsetY:e})=>[(0,l.im)(t),-(0,l.im)(e)]},scale:{count:2,type:pi.Ck.UNSIGNED_BYTE,packPrecisionFactor:16,pack:({scaleX:t,scaleY:e})=>[t,e]},angle:{count:1,type:pi.Ck.UNSIGNED_BYTE,pack:({angle:t})=>(0,oi.Qf)(t)}}};var Yi=s(93552);class ji{constructor(){this.extrusionOffsetX=0,this.extrusionOffsetY=0,this.normalX=0,this.normalY=0,this.directionX=0,this.directionY=0,this.distance=0}}const Hi={createComputedParams:t=>t,attributes:{id:{type:pi.Ck.UNSIGNED_BYTE,count:3,pack:"id"},pos:{type:pi.Ck.SHORT,count:2,pack:"position",packPrecisionFactor:10},bitset:{type:pi.Ck.UNSIGNED_BYTE,count:1},zoomRange:{type:pi.Ck.SHORT,count:2,packPrecisionFactor:B.M6,pack:({scaleInfo:t},{tileInfo:e})=>vi(t,e)},color:{type:pi.Ck.UNSIGNED_BYTE,count:4,normalized:!0,pack:({color:t})=>Ti(t)},offset:{type:pi.Ck.BYTE,count:2,packPrecisionFactor:16,packTessellation:({extrusionOffsetX:t,extrusionOffsetY:e})=>[Mi(t,16),Mi(e,16)]},normal:{type:pi.Ck.BYTE,count:2,packPrecisionFactor:16,packTessellation:({normalX:t,normalY:e})=>[Mi(t,16),Mi(e,16)]},halfWidth:{type:pi.Ck.UNSIGNED_SHORT,count:1,packPrecisionFactor:16,pack:({width:t})=>Ei((0,l.im)(.5*t),16)},referenceHalfWidth:{type:pi.Ck.UNSIGNED_SHORT,count:1,packPrecisionFactor:16,pack:({referenceWidth:t})=>Ei((0,l.im)(.5*t),16)}}};class $i{constructor(){this.id=0,this.bitset=0,this.indexCount=0,this.vertexCount=0,this.vertexFrom=0,this.vertexBounds=0}}class Ki extends gi{constructor(t,e,s,i){super(t,e,s,i),this.vertexSpec=Hi,this._currentWrite=new $i,this._tessellationOptions={halfWidth:0,pixelCoordRatio:1,offset:0,wrapDistance:65535,textured:!1},this._tessParams=new ji,this._initializeTessellator()}writeLineVertices(t,e,s){const i=this._getLines(e);null!=i&&this._writeVertices(t,s,i)}_initializeTessellator(){this._lineTessellator=new Yi.A(this._writeTesselatedVertex.bind(this),this._writeTriangle.bind(this),!0)}_write(t,e,s){const i=s??jt.fromFeatureSetReaderCIM(e);i&&this._writeGeometry(t,e,i)}_writeGeometry(t,e,s,i){t.recordStart(this.instanceId,this.attributeLayout,i),this.writeLineVertices(t,s,e),t.recordEnd()}_getLines(t){return function(t,e){Vt.setPixelMargin(e);const s=Vt,i=-e,r=B.gT+e;let n=[],o=!1;if(!t.nextPath())return null;let a=!0;for(;a;){t.seekPathStart();const e=[];if(!t.pathSize)return null;s.reset(_t.ao.LineString),t.nextPoint();let h=t.x,c=t.y;if(o)s.moveTo(h,c);else{if(h<i||h>r||c<i||c>r){o=!0;continue}e.push({x:h,y:c})}let l=!1;for(;t.nextPoint();)if(h=t.x,c=t.y,o)s.lineTo(h,c);else{if(h<i||h>r||c<i||c>r){l=!0;break}e.push({x:h,y:c})}if(l)o=!0;else{if(o){const t=s.resultWithStarts();if(t)for(const e of t)n.push(e)}else n.push({line:e,start:0});a=t.nextPath(),o=!1}}return n=n.filter((t=>t.line.length>1)),0===n.length?null:n}(t,this.hasEffects?256:16)}_writeVertices(t,e,s){const{_currentWrite:i,_tessellationOptions:r,evaluatedMeshParams:n}=this,{width:o,capType:a,joinType:h,miterLimit:c,hasSizeVV:u}=n,d=(0,l.im)(.5*o);r.halfWidth=d,r.capType=function(t){switch(t){case"butt":case ce.q.Butt:return ce.wD.BUTT;case"round":case ce.q.Round:return ce.wD.ROUND;case"square":case ce.q.Square:return ce.wD.SQUARE}}(a),r.joinType=function(t){switch(t){case"bevel":case ce.Sg.Bevel:return ce.qY.BEVEL;case"miter":case ce.Sg.Miter:return ce.qY.MITER;case"round":case ce.Sg.Round:return ce.qY.ROUND}}(h),r.miterLimit=c;const p=!u;i.out=t,i.id=e.getDisplayId(),i.vertexCount=0,i.indexCount=0,i.vertexFrom=t.vertexCount(),i.vertexBounds=p&&d<B.wt?0:1;for(const{line:t,start:e}of s)r.initialDistance=e%65535,this._lineTessellator.tessellate(t,r,p)}_writeTesselatedVertex(t,e,s,i,r,n,o,a,h,c,l){const{out:u,id:d,vertexBounds:p}=this._currentWrite;return this.hasEffects&&u.recordBounds(t,e,p,p),this._tessParams.extrusionOffsetX=o,this._tessParams.extrusionOffsetY=a,this._tessParams.normalX=h,this._tessParams.normalY=c,this._tessParams.directionX=r,this._tessParams.directionY=n,this._tessParams.distance=l,this._writeVertex(u,d,t,e,this._tessParams),this._currentWrite.vertexFrom+this._currentWrite.vertexCount++}_writeTriangle(t,e,s){const{out:i}=this._currentWrite;i.indexEnsureSize(3),i.indexWrite(t),i.indexWrite(e),i.indexWrite(s),this._currentWrite.indexCount+=3}}const Zi={createComputedParams:t=>t,attributes:{...Hi.attributes,bitset:{type:pi.Ck.UNSIGNED_BYTE,count:1,pack:t=>0},color:{type:pi.Ck.UNSIGNED_BYTE,count:4,normalized:!0,pack:({color:t})=>Ti(t)}}},Qi={createComputedParams:t=>t,attributes:{...Hi.attributes,bitset:{type:pi.Ck.UNSIGNED_BYTE,count:1,pack:t=>Ii([[0,!0]])},color:{type:pi.Ck.UNSIGNED_BYTE,count:4,normalized:!0,pack:({outlineColor:t})=>Ti(t)}}};class Ji extends Ki{constructor(){super(...arguments),this.vertexSpec=Qi}}class tr extends ki{constructor(t,e,s,i){super(t,e,s,i),this.vertexSpec=Zi,this._lineMeshWriter=this._createOutlineWriter(t,e,s,i)}_createOutlineWriter(t,e,s,i){return new Ji(t,e,s,i)}_write(t,e,s){const i=s?.asOptimized()??e.readGeometryForDisplay(),r=this._clip(i);r&&(t.recordStart(this.instanceId,this.attributeLayout),this._writeGeometry(t,e,r),this._lineMeshWriter.writeLineVertices(t,jt.fromOptimizedCIM(r,"esriGeometryPolyline"),e),t.recordEnd())}ensurePacked(t,e,s){super.ensurePacked(t,e,s),this._lineMeshWriter.ensurePacked(t,e,s)}enqueueRequest(t,e,s){super.enqueueRequest(t,e,s),this._lineMeshWriter.enqueueRequest(t,e,s)}async loadDependencies(){await Promise.all([super.loadDependencies(),this._lineMeshWriter.loadDependencies()])}}var er=s(75040),sr=s(90736);const ir=()=>C.c.getLogger("geoscene.views.3d.webgl-engine.core.shaderModules.shaderBuilder");class rr{constructor(){this._includedModules=new Map}include(t,e){if(this._includedModules.has(t)){const s=this._includedModules.get(t);if(s!==e){ir().error("Trying to include shader module multiple times with different sets of options.");const e=new Set;for(const i of Object.keys(s))s[i]!==t[i]&&e.add(i);for(const i of Object.keys(t))s[i]!==t[i]&&e.add(i);e.forEach((e=>console.error(` ${e}: current ${s[e]} new ${t[e]}`)))}}else this._includedModules.set(t,e),t(this.builder,e)}}class nr extends rr{constructor(){super(...arguments),this.vertex=new hr,this.fragment=new hr,this.attributes=new cr,this.varyings=new lr,this.extensions=new ur,this.constants=new dr}get fragmentUniforms(){return this.fragment.uniforms.entries}get builder(){return this}generate(t,e=!0){const s=this.extensions.generateSource(t),i=this.attributes.generateSource(t),r=this.varyings.generateSource(t),n="vertex"===t?this.vertex:this.fragment,o=n.uniforms.generateSource(),a=n.code.generateSource(),h="vertex"===t?pr:function(t=!0){return`#ifdef GL_FRAGMENT_PRECISION_HIGH\n precision highp float;\n precision highp sampler2D;\n#else\n precision mediump float;\n precision mediump sampler2D;\n#endif\n${t?"out vec4 fragColor;":""}\n`}(e),c=this.constants.generateSource().concat(n.constants.generateSource());return`${e?"#version 300 es":""}\n${s.join("\n")}\n${h}\n${c.join("\n")}\n${o.join("\n")}\n${i.join("\n")}\n${r.join("\n")}\n${a.join("\n")}`}generateBindPass(t){const e=new Map;this.vertex.uniforms.entries.forEach((t=>{const s=t.bind[er.u.Pass];s&&e.set(t.name,s)})),this.fragment.uniforms.entries.forEach((t=>{const s=t.bind[er.u.Pass];s&&e.set(t.name,s)}));const s=Array.from(e.values()),i=s.length;return(e,r)=>{for(let n=0;n<i;++n)s[n](t,e,r)}}generateBindDraw(t){const e=new Map;this.vertex.uniforms.entries.forEach((t=>{const s=t.bind[er.u.Draw];s&&e.set(t.name,s)})),this.fragment.uniforms.entries.forEach((t=>{const s=t.bind[er.u.Draw];s&&e.set(t.name,s)}));const s=Array.from(e.values()),i=s.length;return(e,r,n)=>{for(let o=0;o<i;++o)s[o](t,e,r,n)}}}class or{constructor(){this._entries=new Map}add(...t){for(const e of t)this._add(e)}get(t){return this._entries.get(t)}_add(t){if(null!=t){if(this._entries.has(t.name)&&!this._entries.get(t.name).equals(t))throw new i.c(`Duplicate uniform name ${t.name} for different uniform type`);this._entries.set(t.name,t)}else ir().error(`Trying to add null Uniform from ${(new Error).stack}.`)}generateSource(){return Array.from(this._entries.values()).map((t=>null!=t.arraySize?`uniform ${t.type} ${t.name}[${t.arraySize}];`:`uniform ${t.type} ${t.name};`))}get entries(){return Array.from(this._entries.values())}}class ar{constructor(){this._entries=new Array}add(t){this._entries.push(t)}generateSource(){return this._entries}}class hr extends rr{constructor(){super(...arguments),this.uniforms=new or,this.code=new ar,this.constants=new dr}get builder(){return this}}class cr{constructor(){this._entries=new Array}add(t,e){this._entries.push([t,e])}generateSource(t){return"fragment"===t?[]:this._entries.map((t=>`in ${t[1]} ${t[0]};`))}}class lr{constructor(){this._entries=new Map}add(t,e){this._entries.has(t)&&(0,sr.Uc)(this._entries.get(t)===e),this._entries.set(t,e)}generateSource(t){const e=new Array;return this._entries.forEach(((s,i)=>e.push("vertex"===t?`out ${s} ${i};`:`in ${s} ${i};`))),e}}class ur{constructor(){this._entries=new Set}add(t){this._entries.add(t)}generateSource(t){const e="vertex"===t?ur.ALLOWLIST_VERTEX:ur.ALLOWLIST_FRAGMENT;return Array.from(this._entries).filter((t=>e.includes(t))).map((t=>`#extension ${t} : enable`))}}ur.ALLOWLIST_FRAGMENT=["GL_EXT_shader_texture_lod","GL_OES_standard_derivatives"],ur.ALLOWLIST_VERTEX=[];class dr{constructor(){this._entries=new Set}add(t,e,s){let i="ERROR_CONSTRUCTOR_STRING";switch(e){case"float":i=dr._numberToFloatStr(s);break;case"int":i=dr._numberToIntStr(s);break;case"bool":i=s.toString();break;case"vec2":i=`vec2(${dr._numberToFloatStr(s[0])}, ${dr._numberToFloatStr(s[1])})`;break;case"vec3":i=`vec3(${dr._numberToFloatStr(s[0])}, ${dr._numberToFloatStr(s[1])}, ${dr._numberToFloatStr(s[2])})`;break;case"vec4":i=`vec4(${dr._numberToFloatStr(s[0])}, ${dr._numberToFloatStr(s[1])}, ${dr._numberToFloatStr(s[2])}, ${dr._numberToFloatStr(s[3])})`;break;case"ivec2":i=`ivec2(${dr._numberToIntStr(s[0])}, ${dr._numberToIntStr(s[1])})`;break;case"ivec3":i=`ivec3(${dr._numberToIntStr(s[0])}, ${dr._numberToIntStr(s[1])}, ${dr._numberToIntStr(s[2])})`;break;case"ivec4":i=`ivec4(${dr._numberToIntStr(s[0])}, ${dr._numberToIntStr(s[1])}, ${dr._numberToIntStr(s[2])}, ${dr._numberToIntStr(s[3])})`;break;case"mat2":case"mat3":case"mat4":i=`${e}(${Array.prototype.map.call(s,(t=>dr._numberToFloatStr(t))).join(", ")})`}return this._entries.add(`const ${e} ${t} = ${i};`),this}static _numberToIntStr(t){return t.toFixed(0)}static _numberToFloatStr(t){return Number.isInteger(t)?t.toFixed(1):t.toString()}generateSource(){return Array.from(this._entries)}}const pr="precision highp float;\nprecision highp sampler2D;";function _r(t,e){const s=[];for(s.push(e);s.length;){const e=s.pop();if("object"==typeof e&&!t.has(e.uid)){t.add(e.uid);for(const t of e.children)s.push(t)}}}class fr{constructor(){this.uid=fr.NodeCount++,this._debugName=null,this._isMutable=!1,this.isImplicit=!1}get isMutable(){return this._isMutable}setMutable(){return this._isMutable=!0,this}setDebugName(t){return t=function(t){return t.split(" ").map(((t,e)=>e>0?t.charAt(0).toUpperCase()+t.slice(1):t)).join("")}(t),this._debugName=t,this.isImplicit&&this.children[0]instanceof fr&&this.children[0].setDebugName(t),this}get debugInfo(){return{name:this._debugName??""}}cloneInto(t){t._debugName=this._debugName,t._isMutable=this._isMutable,t.isImplicit=this.isImplicit,t.uid=this.uid}}function mr(t){return"object"==typeof t?t.clone():t}fr.NodeCount=0;class gr extends fr{constructor(){super(...arguments),this.shaderType="primitive-node"}}class yr extends fr{constructor(t){super(),this.child=t,this.shaderType="scope-node"}get children(){return[this.child]}clone(){const t=new yr(mr(this.child));return this.cloneInto(t),t}}class xr extends fr{constructor(t,e,s){super(),this.property=t,this.target=e,this.returnType=s,this.shaderType="property-access-node"}get children(){const t=[this.target];return"string"!=typeof this.property&&t.push(this.property),t}clone(){const t=new xr(this.property,mr(this.target),this.returnType);return this.cloneInto(t),t}}class br extends fr{constructor(t,e,s){super(),this.condition=t,this.ifTrue=e,this.ifFalse=s,this.shaderType="condition-node"}get children(){return[this.condition,this.ifTrue,this.ifFalse]}clone(){const t=mr(this.ifTrue),e=this.ifFalse?mr(this.ifFalse):null,s=new br(this.condition,t,e);return this.cloneInto(s),s}}class wr extends fr{constructor(t,e,s,i){super(),this.captureList=t,this.returnType=e,this.generator=i,this.shaderType="block-node",s&&(this.subgraph=new yr(s))}get children(){return Object.keys(this.captureList).map((t=>this.captureList[t])).concat(this.subgraph??[])}clone(){const t={};for(const e in this.captureList)t[e]=mr(this.captureList[e]);const e=new wr(t,this.returnType,this.subgraph?mr(this.subgraph.child):this.subgraph,this.generator);return this.cloneInto(e),e}}class vr extends fr{constructor(t,e,s,i,r,n=!1){super(),this.token=t,this._children=e,this.isInfix=s,this.isPropertyAccess=i,this.returnType=r,this.isTernary=n,this.shaderType="function-node"}get children(){return this._children}clone(){const t=new vr(this.token,this._children.map(mr),this.isInfix,this.isPropertyAccess,this.returnType,this.isTernary);return this.cloneInto(t),t}}var Sr,Ir,Tr,Pr,Mr,Er,Cr,kr,Fr,Ar,Rr,Or,Nr,Dr;function zr(t){return new Proxy(t,{get(e,s){if("constructor"===s)return new Proxy(e.constructor,{construct:(t,e,s)=>zr(new t(...e))});if(s in e)return e[s];if("string"==typeof s){const e=function(t){const e=[["float","vec2","vec3","vec4"],["int","ivec2","ivec3","ivec4"],["uint","uvec2","uvec3","uvec4"],["bool","bvec2","bvec3","bvec4"]];for(const s of e)if(s.includes(t))return s.map((t=>cn[t]));throw new Error("Unable to find type family")}(t.type);return fn(t,s,e[s.length-1])}}})}function Lr(t){return new Proxy(t,{construct:(t,e,s)=>zr(new t(...e))})}class Br extends Error{}let Ur=Sr=class extends gr{constructor(t,e){super(),this.elementType=t,this.size=e,this.children=[],this.type="array"}clone(){const t=new Sr(this.elementType,this.size);return super.cloneInto(t),t}get(t){if("number"==typeof t){const e=new en(t);return e.isImplicit=!0,fn(this,e,this.elementType.constructor)}return fn(this,t,this.elementType.constructor)}last(){return this.get(this.size-1)}first(){return this.get(0)}findIndex(t,e,s){return function(t,e,s=0,i=t.size){const r=new en(s).setMutable().setDebugName("FindIndexIterator"),n=e(t.get(r)).setDebugName("FindIndexPredicate"),o=wn({iter:r},en,n,(({out:t,iter:e,subgraph:s})=>`\n${t} = -1;\n\nfor (; ${e} < ${i}; ${e}++) {\n\n${s.body}\n\n if (${s.varName}) {\n ${t} = ${e};\n break;\n }\n\n}\n`)).setDebugName("FindIndexBlock");return o}(this,t,e,s)}glslFindIndex(t,e,s){return function(t,e,s=0,i=t.size){const r=wn({array:t},en,null,(({out:t,array:r})=>`\n${t} = -1;\nfor (int i = ${s}; i < ${i}; i++) {\n bool condition;\n ${e({array:r,i:"i",out:"condition"})}\n if (condition) {\n ${t} = i;\n break;\n }\n}\n`)).setDebugName("GlslFindIndexBlock");return r}(this,t,e,s)}static ofType(t,e){const s={construct:(s,i)=>new Sr(new t,e)};return new Proxy(Sr,s)}};Ur.type="array",Ur=Sr=(0,T._)([function(t){return new Proxy(t,{construct:(t,e,s)=>function(t){return new Proxy(t,{get(e,s){if(s in e)return e[s];if("string"==typeof s){const e=parseInt(s,10);if(!isNaN(e))return fn(t,`[${e}]`,t.elementType.constructor)}}})}(new t(...e))})}],Ur);class Gr extends gr{constructor(){super(...arguments),this.type="sampler2D",this.children=[]}clone(){const t=new Gr;return t.children=this.children.map(mr),super.cloneInto(t),t}}Gr.type="sampler2D";class Vr extends gr{constructor(t){super(),this.type="float",this.children=[t]}clone(){const t=new Vr(mr(this.children[0]));return super.cloneInto(t),t}multiply(t){return In(this,"number"==typeof t?Jr(t,Vr):t)}divide(t){return Tn(this,"number"==typeof t?Jr(t,Vr):t)}add(t){return Pn(this,"number"==typeof t?Jr(t,Vr):t)}subtract(t){return Mn(this,"number"==typeof t?Jr(t,Vr):t)}}Vr.type="float";let qr=Ir=class extends gr{constructor(t,e){super(),this.type="vec2",this.children=[t,e].filter((t=>null!=t))}clone(){const t=new Ir(mr(this.children[0]),mr(this.children[1]));return super.cloneInto(t),t}get 0(){return fn(this,"[0]",Vr)}get 1(){return fn(this,"[1]",Vr)}get 2(){throw new Br}get 3(){throw new Br}multiply(t){return In(this,"number"==typeof t?Jr(t,Vr):t)}divide(t){return Tn(this,"number"==typeof t?Jr(t,Vr):t)}add(t){return Pn(this,"number"==typeof t?Jr(t,Vr):t)}subtract(t){return Mn(this,"number"==typeof t?Jr(t,Vr):t)}};qr.type="vec2",qr=Ir=(0,T._)([Lr],qr);let Wr=Tr=class extends gr{constructor(t,e,s){super(),this.type="vec3",this.children=[t,e,s].filter((t=>null!=t))}get 0(){return fn(this,"[0]",Vr)}get 1(){return fn(this,"[1]",Vr)}get 2(){return fn(this,"[2]",Vr)}get 3(){throw new Br}clone(){const t=new Tr(mr(this.children[0]),mr(this.children[1]),mr(this.children[2]));return super.cloneInto(t),t}multiply(t){return In(this,"number"==typeof t?Jr(t,Vr):t)}divide(t){return Tn(this,"number"==typeof t?Jr(t,Vr):t)}add(t){return Pn(this,"number"==typeof t?Jr(t,Vr):t)}subtract(t){return Mn(this,"number"==typeof t?Jr(t,Vr):t)}};Wr.type="vec3",Wr=Tr=(0,T._)([Lr],Wr);let Xr=Pr=class extends gr{constructor(t,e,s,i){super(),this.type="vec4",this.children=[t,e,s,i].filter((t=>null!=t))}clone(){const t=new Pr(mr(this.children[0]),mr(this.children[1]),mr(this.children[2]),mr(this.children[3]));return super.cloneInto(t),t}get 0(){return fn(this,"[0]",Vr)}get 1(){return fn(this,"[1]",Vr)}get 2(){return fn(this,"[2]",Vr)}get 3(){return fn(this,"[3]",Vr)}multiply(t){return In(this,"number"==typeof t?Jr(t,Vr):t)}divide(t){return Tn(this,"number"==typeof t?Jr(t,Vr):t)}add(t){return Pn(this,"number"==typeof t?Jr(t,Vr):t)}subtract(t){return Mn(this,"number"==typeof t?Jr(t,Vr):t)}};Xr.type="vec4",Xr=Pr=(0,T._)([Lr],Xr);let Yr=Mr=class extends gr{constructor(t){super(),this.type="uint",this.children=[t]}clone(){const t=new Mr(mr(this.children[0]));return super.cloneInto(t),t}};Yr.type="uint",Yr=Mr=(0,T._)([Lr],Yr);let jr=Er=class extends gr{constructor(t,e){super(),this.type="uvec2",this.children=[t,e].filter((t=>null!=t))}clone(){const t=new Er(mr(this.children[0]),mr(this.children[1]));return super.cloneInto(t),t}};jr.type="uvec2",jr=Er=(0,T._)([Lr],jr);let Hr=Cr=class extends gr{constructor(t,e,s){super(),this.type="uvec3",this.children=[t,e,s].filter((t=>null!=t))}clone(){const t=new Cr(mr(this.children[0]),mr(this.children[1]),mr(this.children[2]));return super.cloneInto(t),t}};Hr.type="uvec3",Hr=Cr=(0,T._)([Lr],Hr);let $r=kr=class extends gr{constructor(t,e,s,i){super(),this.type="uvec4",this.children=[t,e,s,i].filter((t=>null!=t))}clone(){const t=new kr(mr(this.children[0]),mr(this.children[1]),mr(this.children[2]),mr(this.children[3]));return super.cloneInto(t),t}};$r.type="uvec4",$r=kr=(0,T._)([Lr],$r);class Kr extends gr{constructor(t){super(),this.type="bool",this.children=[t]}and(t){return Rn(this,t)}or(t){return An(this,t)}clone(){const t=new Kr(mr(this.children[0]));return super.cloneInto(t),t}}Kr.type="bool";let Zr=Fr=class extends gr{constructor(t,e){super(),this.type="bvec2",this.children=[t,e].filter((t=>null!=t))}all(){return On(this)}any(){return Nn(this)}clone(){const t=new Fr(mr(this.children[0]),mr(this.children[1]));return super.cloneInto(t),t}};Zr.type="bvec2",Zr=Fr=(0,T._)([Lr],Zr);let Qr=Ar=class extends gr{constructor(t,e,s){super(),this.type="bvec3",this.children=[t,e,s].filter((t=>null!=t))}all(){return On(this)}any(){return Nn(this)}clone(){const t=new Ar(mr(this.children[0]),mr(this.children[1]),mr(this.children[2]));return super.cloneInto(t),t}};function Jr(t,e){return"number"==typeof t?new e(t):t}Qr.type="bvec3",Qr=Ar=(0,T._)([Lr],Qr);let tn=Rr=class extends gr{constructor(t,e,s,i){super(),this.type="bvec4",this.children=[t,e,s,i].filter((t=>null!=t))}all(){return On(this)}any(){return Nn(this)}clone(){const t=new Rr(mr(this.children[0]),mr(this.children[1]),mr(this.children[2]),mr(this.children[3]));return super.cloneInto(t),t}};tn.type="bvec4",tn=Rr=(0,T._)([Lr],tn);class en extends gr{constructor(t){super(),this.type="int",this.children=[t]}multiply(t){return In(this,Jr(t,en))}add(t){return Pn(this,Jr(t,en))}subtract(t){return Mn(this,Jr(t,en))}divide(t){return Tn(this,Jr(t,en))}clone(){const t=new en(mr(this.children[0]));return super.cloneInto(t),t}}en.type="int";let sn=Or=class extends gr{constructor(t,e){super(),this.type="ivec2",this.children=[t,e].filter((t=>null!=t))}clone(){const t=new Or(mr(this.children[0]),mr(this.children[1]));return super.cloneInto(t),t}};sn.type="ivec2",sn=Or=(0,T._)([Lr],sn);let rn=Nr=class extends gr{constructor(t,e,s){super(),this.type="ivec3",this.children=[t,e,s].filter((t=>null!=t))}clone(){const t=new Nr(mr(this.children[0]),mr(this.children[1]),mr(this.children[2]));return super.cloneInto(t),t}};rn.type="ivec3",rn=Nr=(0,T._)([Lr],rn);let nn=Dr=class extends gr{constructor(t,e,s,i){super(),this.type="ivec4",this.children=[t,e,s,i].filter((t=>null!=t))}clone(){const t=new Dr(mr(this.children[0]),mr(this.children[1]),mr(this.children[2]),mr(this.children[3]));return super.cloneInto(t),t}};nn.type="ivec4",nn=Dr=(0,T._)([Lr],nn);class on extends gr{constructor(t,e,s,i){super(),this.type="mat2",this.children=[t,e,s,i]}clone(){const t=new on(mr(this.children[0]),mr(this.children[1]),mr(this.children[2]),mr(this.children[3]));return super.cloneInto(t),t}}on.type="mat2";class an extends gr{static identity(){return new an(1,0,0,0,1,0,0,0,1)}static fromRotation(t){const e=Yn(t),s=zn(t);return new an(s,e,0,bn(e),s,0,0,0,1)}constructor(t,e,s,i,r,n,o,a,h){super(),this.type="mat3",this.children=[t,e,s,i,r,n,o,a,h]}add(t){return Pn(this,t)}multiply(t){return In(this,t)}clone(){const t=new an(mr(this.children[0]),mr(this.children[1]),mr(this.children[2]),mr(this.children[3]),mr(this.children[4]),mr(this.children[5]),mr(this.children[6]),mr(this.children[7]),mr(this.children[8]));return super.cloneInto(t),t}}an.type="mat3";class hn extends gr{static identity(){return new hn(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)}constructor(t,e,s,i,r,n,o,a,h,c,l,u,d,p,_,f){super(),this.type="mat4",this.children=[t,e,s,i,r,n,o,a,h,c,l,u,d,p,_,f]}static fromColumns(t,e,s,i){return new hn(t.x,t.y,t.z,t.w,e.x,e.y,e.z,e.w,s.x,s.y,s.z,s.w,i.x,i.y,i.z,i.w)}multiply(t){return In(this,t)}clone(){const t=new hn(mr(this.children[0]),mr(this.children[1]),mr(this.children[2]),mr(this.children[3]),mr(this.children[4]),mr(this.children[5]),mr(this.children[6]),mr(this.children[7]),mr(this.children[8]),mr(this.children[9]),mr(this.children[10]),mr(this.children[11]),mr(this.children[12]),mr(this.children[13]),mr(this.children[14]),mr(this.children[15]));return super.cloneInto(t),t}}hn.type="mat4";const cn={float:Vr,vec2:qr,vec3:Wr,vec4:Xr,int:en,ivec2:sn,ivec3:rn,ivec4:nn,uint:Yr,uvec2:jr,uvec3:Hr,uvec4:$r,bool:Kr,bvec2:Zr,bvec3:Qr,bvec4:tn},ln=(...t)=>new en(...t),un=(...t)=>new Vr(...t),dn=(...t)=>new qr(...t),pn=(...t)=>new Xr(...t),_n=(...t)=>new an(...t);function fn(t,e,s){const i=new s(new xr(e,t,s));return i.isImplicit=!0,i}function mn(t,e,s,i=null){if(i){const r=new i,n=new i(new vr(t,[e,s],!0,!1,r));return n.isImplicit=!0,n}if("float"===e.type||"int"===e.type){const i=new s.constructor(new vr(t,[e,s],!0,!1,s.constructor));return i.isImplicit=!0,i}if(("mat2"===e.type||"mat3"===e.type||"mat4"===e.type)&&"float"!==s.type){const i=new s.constructor(new vr(t,[e,s],!0,!1,s.constructor));return i.isImplicit=!0,i}const r=new e.constructor(new vr(t,[e,s],!0,!1,e.constructor));return r.isImplicit=!0,r}function gn(t,e,s=e.constructor){const i=new s(new vr(t,[e],!1,!1,s));return i.isImplicit=!0,i}function yn(t,e,s,i=e.constructor){const r=new i(new vr(t,[e,s],!1,!1,i));return r.isImplicit=!0,r}function xn(t,e,s,i,r=e.constructor){const n=new r(new vr(t,[e,s,i],!1,!1,r));return n.isImplicit=!0,n}function bn(t){return In(t,un(-1))}function wn(t,e,s,i){return new e(new wr(t,e,s,i))}function vn(t,e,s){const i="function"==typeof e?e():e,r="function"==typeof s?s():s,n=new i.constructor(new br(t,i,r));return n.isImplicit=!0,n}function Sn(...t){const e=t.map((([t,e])=>"function"==typeof e?[t,e()]:[t,e])),s=e[0][1].constructor,i=e.findIndex((t=>!0===t[0]));if(-1===i)throw new Error("A cond must have a fallthrough case with `true`/; ");const r=e.slice(0,i),n=e[i][1],o=new s(r.reduceRight(((t,e)=>vn(e[0],e[1],t)),n));return o.isImplicit=!0,o}function In(t,e){return mn("*",t,e)}function Tn(t,e){return mn("/",t,e)}function Pn(t,e){return mn("+",t,e)}function Mn(t,e){return mn("-",t,e)}function En(t,e){return mn("==",t,e,Kr)}function Cn(t,e){return mn("<=",t,e,Kr)}function kn(t,e){return mn(">",t,e,Kr)}function Fn(t,e){return mn(">=",t,e,Kr)}function An(...t){return t.length<=1?t[0]:t.slice(1).reduce(((t,e)=>function(t,e){return mn("||",t,e,Kr)}(t,e)),t[0])}function Rn(...t){return t.length<=1?t[0]:t.slice(1).reduce(((t,e)=>function(t,e){return mn("&&",t,e,Kr)}(t,e)),t[0])}function On(t){return gn("all",t,Kr)}function Nn(t){return gn("any",t,Kr)}function Dn(t,e,s){return xn("clamp",t,e,s,t.constructor)}function zn(t){return gn("cos",t)}function Ln(t,e){return yn("dot",t,e,Vr)}function Bn(t){return gn("fract",t)}function Un(t){return gn("length",t,Vr)}function Gn(t,e){return yn("max",t,e)}function Vn(t,e){return yn("min",t,e)}function qn(t,e,s){return xn("mix",t,e,s)}function Wn(t,e){return yn("mod",t,e)}function Xn(t){return"bool"===t.type?gn("!",t):gn("not",t)}function Yn(t){return gn("sin",t)}function jn(t,e){return yn("step",t,e,e.constructor)}function Hn(t,e){return yn("texture2D",t,e,Xr)}function $n(t,e,s){const i=e.split("\n");for(const e of i)if(e.trim().length){{let e="";null!=s&&(e+=`/*id:${s??"000"}*/ `),t.body+=e.padEnd(14)}t.body+=" ".repeat(t.indent)+e+"\n"}}class Kn{write(t){for(const e of t.rootOutputNodes())t.shouldPruneOutputNode(e)||(e.variableName=this._write(t,e.node));return t}_createVarName(t,e){let s="";return"boolean"!=typeof e&&"number"!=typeof e&&e.debugInfo.name&&(s=`${e.debugInfo.name}_`),`${s}v${t.varCount++}`}_write(t,e,s=!1){if("number"==typeof e)return e.toString();if("boolean"==typeof e)return e.toString();let i=t.getEmit(e);if(i)return i;switch(e.shaderType){case"scope-node":i=this._writeScopeNode(t,e);break;case"primitive-node":i=this._writePrimitveNode(t,e,s);break;case"function-node":i=this._writeFunctionNode(t,e);break;case"property-access-node":i=this._writePropertyAccessNode(t,e);break;case"text-node":i=e.text;break;case"block-node":i=this._writeBlockNode(t,e);break;case"condition-node":i=this._writeConditionNode(t,e)}return t.setEmit(e,i),i}_writeScopeNode(t,e){const s=new e.child.constructor;s.setDebugName(e.debugInfo.name);const i=this._write(t,s,!0);return $n(t,`{ /*ScopeStart: ${e.uid} ${e.debugInfo.name}*/`),t.indent+=2,$n(t,`${i} = ${this._write(t,e.child)};`),t.indent-=2,$n(t,`} /*ScopeEnd: ${e.uid} ${e.debugInfo.name}*/`),i}_writeConditionNode(t,e){const s=new e.ifTrue.constructor,i=this._write(t,s,!0);$n(t,`if (${this._write(t,e.condition)}) {`),t.indent+=2;const r=t.createSubgraphContext(),n=this._write(r,e.ifTrue);if(t.body+=r.body,n&&$n(t,`${i} = ${n};`),t.indent-=2,$n(t,"}"),e.ifFalse){$n(t,"else {"),t.indent+=2;const s=t.createSubgraphContext(),r=this._write(s,e.ifFalse);t.body+=s.body,r&&$n(t,`${i} = ${r};`),t.indent-=2,$n(t,"}")}return i}_writeBlockNode(t,e){const{captureList:s,generator:i,returnType:r}=e,n={};for(const e in s){if(!s[e])continue;const i=this._write(t,s[e]);n[e]=i}const o=new r,a=this._write(t,o,!0);if(n.out=a,e.subgraph){const s=t.createSubgraphContext(),i=this._write(s,e.subgraph.child),r=s.body;n.subgraph={varName:i,body:r}}const h=i(n);return $n(t,"{\n"),t.indent+=2,$n(t,h),t.indent-=2,$n(t,"}\n"),a}_writePropertyAccessNode(t,e){const s=this._write(t,e.target);return"string"==typeof e.property&&e.property.includes("[")?`${s}${e.property}`:"string"!=typeof e.property?`${s}[${this._write(t,e.property)}]`:`${s}.${e.property}`}_writeFunctionNode(t,e){const s=e.returnType.type;if(e.isInfix){const[i,r]=e.children.map((e=>this._write(t,e))),n=this._createVarName(t,e);return $n(t,`${s.padEnd(5)} ${n} = ${i} ${e.token} ${r};`,e.uid),n}const i=e.children.map((e=>this._write(t,e))).join(", "),r=this._createVarName(t,e);return $n(t,`${s.padEnd(5)} ${r} = ${e.token}(${i});`,e.uid),r}_writePrimitveNode(t,e,s=!1){const i=t.getInput(e);if(i)return i.isUsed=!0,i.variableName;const r=1===e.children.length&&e.children[0]?.type===e.type;if(e.isImplicit||r)return this._write(t,e.children[0]);const n=this._createVarName(t,e);if(s)return $n(t,`${e.type.padEnd(5)} ${n};`,e.uid),n;const o=!e.debugInfo.name&&!e.isMutable;if(o&&"float"===e.type&&"number"==typeof e.children[0])return Number.isInteger(e.children[0])?e.children[0].toFixed(1):e.children[0].toString();if(o&&"int"===e.type&&"number"==typeof e.children[0]&&Number.isInteger(e.children[0]))return e.children[0].toString();const a=e.children.map((e=>this._write(t,e))).join(", ");return"array"===e.type?($n(t,`${e.type.padEnd(5)} ${n} = [${a}];`,e.uid),n):o?`${e.type}(${a})`:($n(t,`${e.type.padEnd(5)} ${n} = ${e.type}(${a});`,e.uid),n)}}class Zn{constructor(t,e,s){this.variableName=t,this.variableInputType=e,this.node=s,this.type="shader-input",this.isUsed=!1}clone(){return new Zn(this.variableName,this.variableInputType,mr(this.node))}}class Qn{constructor(t,e,s){this.outVariableName=t,this.outVariableType=e,this.node=s,this.type="shader-output"}clone(){const t=new Qn(this.outVariableName,this.outVariableType,mr(this.node));return t.variableName=this.variableName,t}}class Jn{static createVertex(t,e,s,i,r,n){const o=[];for(const e in t){const i=t[e],r=s.get(e);r?o.push(new Zn(r,"builtin",i)):o.push(new Zn("a_"+e,"attribute",i))}for(const t of i){const e=t.uniformHydrated;o.push(new Zn(t.uniformName,"uniform",e))}const a=[];for(const t in e){const s=e[t];"glPosition"===t?a.push(new Qn("gl_Position","builtin",s)):"glPointSize"===t?a.push(new Qn("gl_PointSize","builtin",s)):a.push(new Qn("v_"+t,"varying",s))}return new Jn(o,a,r,n)}static createFragment(t,e,s,i,r,n){const o=[],a=Array.from(r.rootOutputNodes());for(const e in t){const i=t[e],r=s.get(e);if(r){o.push(new Zn(r,"builtin",i));continue}const n=a.find((t=>t.node===i));n&&o.push(new Zn(n.outVariableName,n.outVariableType,i))}for(const t of i){const e=t.uniformHydrated;o.push(new Zn(t.uniformName,"uniform",e))}const h=[];for(const t in e){const i=e[t],r=s.get(t);if("discard"===t)h.push(new Qn(null,"discard",i));else{if(!r)throw new Error(`Member ${t} in shader fragment output shoule be tagged as builtin`);h.push(new Qn(r,"builtin",i))}}return new Jn(o,h,n)}constructor(t,e,s,i){this.type="shader-graph-context",this.indent=0,this.body="",this.varCount=0,this._inputShaderTypesByNodeUid=new Map,this._nodeEmitMap=new Map;for(const e of t)this._inputShaderTypesByNodeUid.set(e.node.uid,e);this._outputShaderTypes=e,this._transformFeedbackBindings=s,this._transformFeedbackNames=new Set(s.map((t=>"v_"+t.propertyKey))),this._usedInFragmentShader=i}shouldPruneOutputNode(t){return!!this._usedInFragmentShader&&"builtin"!==t.outVariableType&&!this._transformFeedbackNames.has(t.outVariableName)&&!this._usedInFragmentShader.has(t.node.uid)}setEmit(t,e){this._nodeEmitMap.set(t.uid,e)}getEmit(t){return this._nodeEmitMap.get(t.uid)}inputs(){return this._inputShaderTypesByNodeUid.values()}getInput(t){return this._inputShaderTypesByNodeUid.get(t.uid)}*rootOutputNodes(){for(const t of this._outputShaderTypes)yield t}*nodes(){const t=[];for(const e of this._outputShaderTypes.values())t.push(e.node);for(;t.length;){const e=t.pop();"number"!=typeof e&&"boolean"!=typeof e&&t.push(...e.children.filter(Boolean)),yield e}}*nodesOfTypeOrFunction(){for(const t of this.nodes())"number"!=typeof t&&"boolean"!=typeof t&&(yield t)}createSubgraphContext(){const t=this.clone();return t.body="",t.indent=this.indent+2,t._nodeEmitMap=new Map(this._nodeEmitMap),t}clone(){const t=new Jn([],this._outputShaderTypes,this._transformFeedbackBindings,this._usedInFragmentShader);return t._inputShaderTypesByNodeUid=this._inputShaderTypesByNodeUid,t.indent=this.indent,t.body=this.body,t.varCount=this.varCount,t._nodeEmitMap=this._nodeEmitMap,t}insertVertexShader(t){t.vertex.code.add(""),this._insertInputs(t,"vertex"),t.vertex.code.add(""),t.vertex.code.add("// OUTPUTS: "),t.vertex.code.add("// --------------------------------------------------------- ");for(const e of this.rootOutputNodes()){const s="builtin"===e.outVariableType;this.shouldPruneOutputNode(e)||(s?t.vertex.code.add(`// ${e.outVariableType.padEnd(7)} ${e.node.type.padEnd(9)} ${e.outVariableName};`):t.vertex.code.add(`${e.outVariableType.padEnd(10)} ${e.node.type.padEnd(9)} ${e.outVariableName};`))}t.vertex.code.add(""),t.vertex.code.add("void main() {"),t.vertex.code.add(" "+this.body.split("\n").join("\n "));for(const e of this.rootOutputNodes())this.shouldPruneOutputNode(e)||t.vertex.code.add(` ${e.outVariableName} = ${e.variableName};`);t.vertex.code.add("}")}insertFragmentShader(t){this._insertInputs(t,"fragment"),t.fragment.code.add(""),t.fragment.code.add("void main() {"),t.fragment.code.add(" "+this.body.split("\n").join("\n "));for(const e of this.rootOutputNodes())"discard"===e.outVariableType?(t.fragment.code.add(" // TODO: Should ensure codegen for discard appears first in fragment shader"),t.fragment.code.add(` if (${e.variableName}) {`),t.fragment.code.add(" discard;"),t.fragment.code.add(" }"),t.fragment.code.add(" ")):t.fragment.code.add(` ${e.outVariableName} = ${e.variableName};`);t.fragment.code.add("}")}_insertInputs(t,e){t[e].code.add("// INPUTS: "),t[e].code.add("// --------------------------------------------------------- ");for(const s of this.inputs())s.isUsed&&"builtin"!==s.variableInputType&&("array"===s.node.type?t[e].code.add(`${s.variableInputType.padEnd(10)} ${s.node.elementType.type.padEnd(9)} ${s.variableName}[${s.node.size}];`):t[e].code.add(`${s.variableInputType.padEnd(10)} ${s.node.type.padEnd(9)} ${s.variableName};`))}}var to=s(58820),eo=s(94460),so=s(72008);const io=()=>C.c.getLogger("geoscene.views.webgl.BufferObject");class ro{static createIndex(t,e,s){return new ro(t,pi.K.ELEMENT_ARRAY_BUFFER,e,s)}static createVertex(t,e,s){return new ro(t,pi.K.ARRAY_BUFFER,e,s)}static createUniform(t,e,s){return new ro(t,pi.K.UNIFORM_BUFFER,e,s)}static createPixelPack(t,e=pi._m.STREAM_READ,s){const i=new ro(t,pi.K.PIXEL_PACK_BUFFER,e);return s&&i.setSize(s),i}static createPixelUnpack(t,e=pi._m.STREAM_DRAW,s){return new ro(t,pi.K.PIXEL_UNPACK_BUFFER,e,s)}static createTransformFeedback(t,e=pi._m.STATIC_DRAW,s){const i=new ro(t,pi.K.TRANSFORM_FEEDBACK_BUFFER,e);return i.setSize(s),i}constructor(t,e,s,i){this._context=t,this.bufferType=e,this.usage=s,this._glName=null,this._size=-1,this._indexType=void 0,t.instanceCounter.increment(pi.y4.BufferObject,this),this._glName=this._context.gl.createBuffer(),(0,eo.m_)(this._context.gl),i&&this.setData(i)}get glName(){return this._glName}get size(){return this._size}get indexType(){return this._indexType}get usedMemory(){return this.bufferType===pi.K.ELEMENT_ARRAY_BUFFER?this._indexType===pi.Ck.UNSIGNED_INT?4*this._size:2*this._size:this._size}get _isVAOAware(){return this.bufferType===pi.K.ELEMENT_ARRAY_BUFFER||this.bufferType===pi.K.ARRAY_BUFFER}dispose(){this._context?.gl?(this._glName&&(this._context.gl.deleteBuffer(this._glName),this._glName=null),this._context.instanceCounter.decrement(pi.y4.BufferObject,this),this._context=null):this._glName&&io().warn("Leaked WebGL buffer object")}setSize(t,e=null){if(t<=0&&io().error("Buffer size needs to be positive!"),this.bufferType===pi.K.ELEMENT_ARRAY_BUFFER&&null!=e)switch(this._indexType=e,e){case pi.Ck.UNSIGNED_SHORT:t*=2;break;case pi.Ck.UNSIGNED_INT:t*=4}this._setBufferData(t)}setData(t){if(!t)return;let e=t.byteLength;this.bufferType===pi.K.ELEMENT_ARRAY_BUFFER&&((0,so.Qx)(t)&&(e/=2,this._indexType=pi.Ck.UNSIGNED_SHORT),(0,so.Nt)(t)&&(e/=4,this._indexType=pi.Ck.UNSIGNED_INT)),this._setBufferData(e,t)}_setBufferData(t,e=null){this._size=t;const s=this._context.getBoundVAO();this._isVAOAware&&this._context.bindVAO(null),this._context.bindBuffer(this);const i=this._context.gl;null!=e?i.bufferData(this.bufferType,e,this.usage):i.bufferData(this.bufferType,t,this.usage),(0,eo.m_)(i),this._isVAOAware&&this._context.bindVAO(s)}setSubData(t,e,s,i){if(!t)return;(e<0||e*t.BYTES_PER_ELEMENT>=this.usedMemory)&&io().error("offset is out of range!"),s>=i&&io().error("end must be bigger than start!"),(e+(i-s))*t.BYTES_PER_ELEMENT>this.usedMemory&&io().error("An attempt to write beyond the end of the buffer!");const r=this._context.getBoundVAO();this._isVAOAware&&this._context.bindVAO(null),this._context.bindBuffer(this);const{gl:n}=this._context;n.bufferSubData(this.bufferType,e*t.BYTES_PER_ELEMENT,t,s,i-s),(0,eo.m_)(n),this._isVAOAware&&this._context.bindVAO(r)}getSubData(t,e=0,s,i){if(s<0||i<0)return void io().error("Problem getting subdata: offset and length were less than zero!");const r=function(t){return(0,tt.GQ)(t)}(t)?t.BYTES_PER_ELEMENT:1;if(r*((s??0)+(i??0))>t.byteLength)return void io().error("Problem getting subdata: offset and length exceeded destination size!");e+r*(i??0)>this.usedMemory&&io().warn("Potential problem getting subdata: requested data exceeds buffer size!");const n=this._context.gl;this.bufferType===pi.K.TRANSFORM_FEEDBACK_BUFFER?(this._context.bindBuffer(this,pi.K.TRANSFORM_FEEDBACK_BUFFER),n.getBufferSubData(pi.K.TRANSFORM_FEEDBACK_BUFFER,e,t,s,i),this._context.unbindBuffer(pi.K.TRANSFORM_FEEDBACK_BUFFER)):(this._context.bindBuffer(this,pi.K.COPY_READ_BUFFER),n.getBufferSubData(pi.K.COPY_READ_BUFFER,e,t,s,i),this._context.unbindBuffer(pi.K.COPY_READ_BUFFER))}async getSubDataAsync(t,e=0,s,i){await this._context.clientWaitAsync(),this.getSubData(t,e,s,i)}}var no=s(39104),oo=s(97684);class ao{constructor(t,e){this._context=t,this._descriptor=e,this.type=no.A.RenderBuffer,this._context.instanceCounter.increment(pi.y4.Renderbuffer,this);const s=this._context.gl;this.glName=s.createRenderbuffer(),this._context.bindRenderbuffer(this);const{width:i,height:r,internalFormat:n,multisampled:o}=e;o?s.renderbufferStorageMultisample(s.RENDERBUFFER,this.samples,n,i,r):s.renderbufferStorage(s.RENDERBUFFER,n,i,r)}get descriptor(){return this._descriptor}get samples(){const t=this._descriptor.samples,e=this._context.parameters.maxSamples;return t?Math.min(t,e):e}get usedMemory(){return function(t){return t.width<=0||t.height<=0||null==t.internalFormat?0:t.width*t.height*(0,oo.O4)(t.internalFormat)}(this._descriptor)}resize(t,e){const s=this._descriptor;if(s.width===t&&s.height===e)return;s.width=t,s.height=e;const i=this._context.gl;this._context.bindRenderbuffer(this),s.multisampled?i.renderbufferStorageMultisample(i.RENDERBUFFER,this.samples,s.internalFormat,s.width,s.height):i.renderbufferStorage(i.RENDERBUFFER,s.internalFormat,s.width,s.height)}dispose(){this._context&&(this._context.gl.deleteRenderbuffer(this.glName),this._context.instanceCounter.decrement(pi.y4.Renderbuffer,this),this._context=null)}}var ho=s(22184);class co{constructor(t,e,s=null){this._context=t,this._glName=null,this._colorAttachments=new Map,this._depthStencilBuffer=null,this._depthStencilTexture=null,this._initialized=!1,t.instanceCounter.increment(pi.y4.FramebufferObject,this);const i=lo(e)?e:new ho.w(this._context,e);if(this._colorAttachments.set(pi.Qx.COLOR_ATTACHMENT0,i),this._validateTextureDescriptor(i.descriptor),this._validateColorAttachmentPoint(pi.Qx.COLOR_ATTACHMENT0),null!=s)if(function(t){return lo(t)||null!=t&&"pixelFormat"in t}(s))this._context.capabilities.depthTexture||console.error("Setting the depth/stencil texture as an attachment requires WEBGL_depth_texture or WebGL2"),this._depthStencilTexture=lo(s)?s:new ho.w(this._context,s),this._validateTextureDescriptor(this._depthStencilTexture.descriptor);else{const t=function(t){return null!=t&&"type"in t&&t.type===no.A.RenderBuffer}(s)?s:new ao(this._context,s);this._depthStencilBuffer=t,this._validateRenderBufferDescriptor(t.descriptor)}}dispose(){if(0===this._colorAttachments.size&&!this._glName)return;const t=this._context.getBoundFramebufferObject();this._colorAttachments.forEach(((t,e)=>this.detachColorTexture(e)?.dispose())),this.detachDepthStencilBuffer()?.dispose(),this.detachDepthStencilTexture()?.dispose(),this._glName&&(this._context.gl.deleteFramebuffer(this._glName),this._glName=null),this._context.bindFramebuffer(t),this._context.instanceCounter.decrement(pi.y4.FramebufferObject,this)}get glName(){return this._glName}get colorTexture(){return this._colorAttachments.get(pi.Qx.COLOR_ATTACHMENT0)}get depthStencil(){return this._depthStencilTexture||this._depthStencilBuffer}get depthStencilTexture(){return this._depthStencilTexture}get width(){const t=this._colorAttachments.get(pi.Qx.COLOR_ATTACHMENT0);return t?.descriptor?.width??0}get height(){const t=this._colorAttachments.get(pi.Qx.COLOR_ATTACHMENT0);return t?.descriptor?.height??0}get usedMemory(){return[...this._colorAttachments].reduce(((t,[e,s])=>t+s.usedMemory),this.depthStencil?.usedMemory??0)}getColorTexture(t){const e=this._colorAttachments.get(t);return e&&lo(e)?e:null}get colorAttachments(){return[...this._colorAttachments.keys()]}attachColorTexture(t,e=pi.Qx.COLOR_ATTACHMENT0){if(!t)return;this._validateColorAttachmentPoint(e);const s=t.descriptor;this._validateTextureDescriptor(s),this.detachColorTexture(e)?.dispose(),this._initialized&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(t.glName,e)),this._colorAttachments.set(e,t)}detachColorTexture(t=pi.Qx.COLOR_ATTACHMENT0){const e=this._colorAttachments.get(t);if(e){if(this._initialized){const e=this._context.getBoundFramebufferObject();this._context.bindFramebuffer(this),this._framebufferTexture2D(null,t),this._context.bindFramebuffer(e)}return this._colorAttachments.delete(t),e}}setColorTextureTarget(t,e=pi.Qx.COLOR_ATTACHMENT0){const s=this._colorAttachments.get(e);s&&this._framebufferTexture2D(s.glName,e,t)}attachDepthStencil(t){if(t)switch(t.type){case no.A.Texture:return this._attachDepthStencilTexture(t);case no.A.RenderBuffer:return this._attachDepthStencilBuffer(t)}}_attachDepthStencilTexture(t){if(null==t)return;const e=t.descriptor;e.pixelFormat!==pi.Id.DEPTH_STENCIL&&e.pixelFormat!==pi.Id.DEPTH24_STENCIL8&&console.error("Depth/Stencil texture must have a pixel type of DEPTH_STENCIL!"),e.dataType!==pi.OK.UNSIGNED_INT_24_8&&console.error("Depth/Stencil texture must have data type of UNSIGNED_INT_24_8!"),this._context.capabilities.depthTexture||console.error("Extension WEBGL_depth_texture isn't supported therefore it is no possible to set the depth/stencil texture!"),this._validateTextureDescriptor(e),this._disposeDepthStencilAttachments(),this._initialized&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(t.glName,pi.GE)),this._depthStencilTexture?.dispose(),this._depthStencilTexture=t}detachDepthStencilTexture(){const t=this._depthStencilTexture;return t&&this._initialized&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(null,pi.GE)),this._depthStencilTexture=null,t}_attachDepthStencilBuffer(t){if(null==t)return;const e=t.descriptor;if(this._validateRenderBufferDescriptor(e),this._disposeDepthStencilAttachments(),this._initialized){this._context.bindFramebuffer(this);const s=this._context.gl,i=this._getGLAttachmentPoint(e);s.framebufferRenderbuffer(pi.kl.FRAMEBUFFER,i,s.RENDERBUFFER,t.glName)}this._depthStencilBuffer=t}detachDepthStencilBuffer(){const t=this._depthStencilBuffer;if(t&&this._initialized){this._context.bindFramebuffer(this);const e=this._context.gl,s=this._getGLAttachmentPoint(t.descriptor);e.framebufferRenderbuffer(pi.kl.FRAMEBUFFER,s,e.RENDERBUFFER,null)}return this._depthStencilBuffer=null,t}copyToTexture(t,e,s,i,r,n,o){(t<0||e<0||r<0||n<0)&&console.error("Offsets cannot be negative!"),(s<=0||i<=0)&&console.error("Copy width and height must be greater than zero!");const a=o.descriptor;o.descriptor.target!==pi.c5.TEXTURE_2D&&console.error("Texture target must be TEXTURE_2D!"),(null==a?.width||null==a?.height||t+s>this.width||e+i>this.height||r+s>a.width||n+i>a.height)&&console.error("Bad dimensions, the current input values will attempt to read or copy out of bounds!");const h=this._context,c=h.bindTexture(o,ho.w.TEXTURE_UNIT_FOR_UPDATES);h.setActiveTexture(ho.w.TEXTURE_UNIT_FOR_UPDATES),h.bindFramebuffer(this),h.gl.copyTexSubImage2D(pi.c5.TEXTURE_2D,0,r,n,t,e,s,i),h.bindTexture(c,ho.w.TEXTURE_UNIT_FOR_UPDATES)}readPixels(t,e,s,i,r,n,o){(s<=0||i<=0)&&console.error("Copy width and height must be greater than zero!"),o||console.error("Target memory is not initialized!"),this._context.bindFramebuffer(this),this._context.gl.readPixels(t,e,s,i,r,n,o)}async readPixelsAsync(t,e,s,i,r,n,o){const{gl:a}=this._context,h=ro.createPixelPack(this._context,pi._m.STREAM_READ,o.byteLength);this._context.bindBuffer(h),this._context.bindFramebuffer(this),a.readPixels(t,e,s,i,r,n,0),this._context.unbindBuffer(pi.K.PIXEL_PACK_BUFFER),await h.getSubDataAsync(o),h.dispose()}resize(t,e){if(this.width===t&&this.height===e)return;const s={width:t,height:e};uo(s,this._context.parameters.maxTextureSize),this._colorAttachments.forEach((t=>t.resize(s.width,s.height))),this._depthStencilTexture?.resize(s.width,s.height),this._initialized&&(uo(s,this._context.parameters.maxRenderbufferSize),this._depthStencilBuffer?.resize(s.width,s.height),this._context.getBoundFramebufferObject()===this&&this._context.bindFramebuffer(null),this._initialized=!1)}initializeAndBind(t=pi.kl.FRAMEBUFFER){const e=this._context.gl;if(this._initialized)return void e.bindFramebuffer(t,this.glName);this._glName&&e.deleteFramebuffer(this._glName);const s=e.createFramebuffer();if(e.bindFramebuffer(t,s),this._colorAttachments.forEach(((e,s)=>this._framebufferTexture2D(e.glName,s,po(e),t))),this._depthStencilBuffer){const s=this._getGLAttachmentPoint(this._depthStencilBuffer.descriptor);e.framebufferRenderbuffer(t,s,e.RENDERBUFFER,this._depthStencilBuffer.glName)}else this._depthStencilTexture&&this._framebufferTexture2D(this._depthStencilTexture.glName,e.DEPTH_STENCIL_ATTACHMENT,po(this._depthStencilTexture),t);(0,eo.gv)()&&e.checkFramebufferStatus(t)!==e.FRAMEBUFFER_COMPLETE&&console.error("Framebuffer is incomplete!"),this._glName=s,this._initialized=!0}_framebufferTexture2D(t,e=pi.Qx.COLOR_ATTACHMENT0,s=pi.c5.TEXTURE_2D,i=pi.kl.FRAMEBUFFER,r=0){this._context.gl.framebufferTexture2D(i,e,s,t,r)}_disposeDepthStencilAttachments(){const t=this._context.gl;if(this._depthStencilBuffer){if(this._initialized){this._context.bindFramebuffer(this);const e=this._getGLAttachmentPoint(this._depthStencilBuffer.descriptor);t.framebufferRenderbuffer(pi.kl.FRAMEBUFFER,e,t.RENDERBUFFER,null)}this._depthStencilBuffer=(0,M.yI)(this._depthStencilBuffer)}this._depthStencilTexture&&(this._initialized&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(null,t.DEPTH_STENCIL_ATTACHMENT)),this._depthStencilTexture=(0,M.yI)(this._depthStencilTexture))}_validateTextureDescriptor(t){t.target!==pi.c5.TEXTURE_2D&&t.target!==pi.c5.TEXTURE_CUBE_MAP&&console.error("Texture type must be TEXTURE_2D or TEXTURE_CUBE_MAP!"),uo(t,this._context.parameters.maxTextureSize),this._validateBufferDimensions(t)}_validateRenderBufferDescriptor(t){uo(t,this._context.parameters.maxRenderbufferSize),this._validateBufferDimensions(t)}_validateBufferDimensions(t){t.width<=0&&(t.width=this.width),t.height<=0&&(t.height=this.height),this.width>0&&this.height>0&&(this.width===t.width&&this.height===t.height||console.error("Attachment size must match framebuffer size!"))}_getGLAttachmentPoint(t){switch(t.internalFormat){case pi.Qb.DEPTH_COMPONENT16:case pi.Qb.DEPTH_COMPONENT24:case pi.Qb.DEPTH_COMPONENT32F:return this._context.gl.DEPTH_ATTACHMENT;case pi.Qb.DEPTH24_STENCIL8:case pi.Qb.DEPTH32F_STENCIL8:case pi.Qb.DEPTH_STENCIL:return this._context.gl.DEPTH_STENCIL_ATTACHMENT;case pi.Qb.STENCIL_INDEX8:return this._context.gl.STENCIL_ATTACHMENT}}_validateColorAttachmentPoint(t){if(-1===co._MAX_COLOR_ATTACHMENTS){const{gl:t}=this._context;co._MAX_COLOR_ATTACHMENTS=t.getParameter(t.MAX_COLOR_ATTACHMENTS)}const e=t-pi.Qx.COLOR_ATTACHMENT0;e+1>co._MAX_COLOR_ATTACHMENTS&&C.c.getLogger("geoscene.views.webgl.FrameBufferObject").error("geoscene.FrameBufferObject",`illegal attachment point for color attachment: ${e+1}. Implementation supports up to ${co._MAX_COLOR_ATTACHMENTS} color attachments`)}}function lo(t){return null!=t&&"type"in t&&t.type===no.A.Texture}function uo(t,e){const s=Math.max(t.width,t.height);if(s>e){C.c.getLogger("geoscene.views.webgl.FramebufferObject").warn(`Resizing FBO attachment size ${t.width}x${t.height} to device limit ${e}`);const i=e/s;return t.width=Math.round(t.width*i),t.height=Math.round(t.height*i),!1}return!0}function po(t){return t.descriptor.target===pi.c5.TEXTURE_CUBE_MAP?pi.c5.TEXTURE_CUBE_MAP_POSITIVE_X:pi.c5.TEXTURE_2D}co._MAX_COLOR_ATTACHMENTS=-1;const _o=["layout","centroid","smooth","case","mat2x2","mat2x3","mat2x4","mat3x2","mat3x3","mat3x4","mat4x2","mat4x3","mat4x4","uint","uvec2","uvec3","uvec4","samplerCubeShadow","sampler2DArray","sampler2DArrayShadow","isampler2D","isampler3D","isamplerCube","isampler2DArray","usampler2D","usampler3D","usamplerCube","usampler2DArray","coherent","restrict","readonly","writeonly","resource","atomic_uint","noperspective","patch","sample","subroutine","common","partition","active","filter","image1D","image2D","image3D","imageCube","iimage1D","iimage2D","iimage3D","iimageCube","uimage1D","uimage2D","uimage3D","uimageCube","image1DArray","image2DArray","iimage1DArray","iimage2DArray","uimage1DArray","uimage2DArray","image1DShadow","image2DShadow","image1DArrayShadow","image2DArrayShadow","imageBuffer","iimageBuffer","uimageBuffer","sampler1DArray","sampler1DArrayShadow","isampler1D","isampler1DArray","usampler1D","usampler1DArray","isampler2DRect","usampler2DRect","samplerBuffer","isamplerBuffer","usamplerBuffer","sampler2DMS","isampler2DMS","usampler2DMS","sampler2DMSArray","isampler2DMSArray","usampler2DMSArray","trunc","round","roundEven","isnan","isinf","floatBitsToInt","floatBitsToUint","intBitsToFloat","uintBitsToFloat","packSnorm2x16","unpackSnorm2x16","packUnorm2x16","unpackUnorm2x16","packHalf2x16","unpackHalf2x16","outerProduct","transpose","determinant","inverse","texture","textureSize","textureProj","textureLod","textureOffset","texelFetch","texelFetchOffset","textureProjOffset","textureLodOffset","textureProjLod","textureProjLodOffset","textureGrad","textureGradOffset","textureProjGrad","textureProjGradOffset"],fo=!1;var mo,go=s(8528),yo={exports:{}};void 0!==(mo=["precision","highp","mediump","lowp","attribute","const","uniform","varying","break","continue","do","for","while","if","else","in","out","inout","float","int","void","bool","true","false","discard","return","mat2","mat3","mat4","vec2","vec3","vec4","ivec2","ivec3","ivec4","bvec2","bvec3","bvec4","sampler1D","sampler2D","sampler3D","samplerCube","sampler1DShadow","sampler2DShadow","struct","asm","class","union","enum","typedef","template","this","packed","goto","switch","default","inline","noinline","volatile","public","static","extern","external","interface","long","short","double","half","fixed","unsigned","input","output","hvec2","hvec3","hvec4","dvec2","dvec3","dvec4","fvec2","fvec3","fvec4","sampler2DRect","sampler3DRect","sampler2DRectShadow","sizeof","cast","namespace","using"])&&(yo.exports=mo);const xo=(0,go.g)(yo.exports);var bo,wo={exports:{}};void 0!==(bo=["<<=",">>=","++","--","<<",">>","<=",">=","==","!=","&&","||","+=","-=","*=","/=","%=","&=","^^","^=","|=","(",")","[","]",".","!","~","*","/","%","+","-","<",">","&","^","|","?",":","=",",",";","{","}"])&&(wo.exports=bo);const vo=(0,go.g)(wo.exports);var So={exports:{}};!function(t){!function(e){var s=["abs","acos","all","any","asin","atan","ceil","clamp","cos","cross","dFdx","dFdy","degrees","distance","dot","equal","exp","exp2","faceforward","floor","fract","gl_BackColor","gl_BackLightModelProduct","gl_BackLightProduct","gl_BackMaterial","gl_BackSecondaryColor","gl_ClipPlane","gl_ClipVertex","gl_Color","gl_DepthRange","gl_DepthRangeParameters","gl_EyePlaneQ","gl_EyePlaneR","gl_EyePlaneS","gl_EyePlaneT","gl_Fog","gl_FogCoord","gl_FogFragCoord","gl_FogParameters","gl_FragColor","gl_FragCoord","gl_FragData","gl_FragDepth","gl_FragDepthEXT","gl_FrontColor","gl_FrontFacing","gl_FrontLightModelProduct","gl_FrontLightProduct","gl_FrontMaterial","gl_FrontSecondaryColor","gl_LightModel","gl_LightModelParameters","gl_LightModelProducts","gl_LightProducts","gl_LightSource","gl_LightSourceParameters","gl_MaterialParameters","gl_MaxClipPlanes","gl_MaxCombinedTextureImageUnits","gl_MaxDrawBuffers","gl_MaxFragmentUniformComponents","gl_MaxLights","gl_MaxTextureCoords","gl_MaxTextureImageUnits","gl_MaxTextureUnits","gl_MaxVaryingFloats","gl_MaxVertexAttribs","gl_MaxVertexTextureImageUnits","gl_MaxVertexUniformComponents","gl_ModelViewMatrix","gl_ModelViewMatrixInverse","gl_ModelViewMatrixInverseTranspose","gl_ModelViewMatrixTranspose","gl_ModelViewProjectionMatrix","gl_ModelViewProjectionMatrixInverse","gl_ModelViewProjectionMatrixInverseTranspose","gl_ModelViewProjectionMatrixTranspose","gl_MultiTexCoord0","gl_MultiTexCoord1","gl_MultiTexCoord2","gl_MultiTexCoord3","gl_MultiTexCoord4","gl_MultiTexCoord5","gl_MultiTexCoord6","gl_MultiTexCoord7","gl_Normal","gl_NormalMatrix","gl_NormalScale","gl_ObjectPlaneQ","gl_ObjectPlaneR","gl_ObjectPlaneS","gl_ObjectPlaneT","gl_Point","gl_PointCoord","gl_PointParameters","gl_PointSize","gl_Position","gl_ProjectionMatrix","gl_ProjectionMatrixInverse","gl_ProjectionMatrixInverseTranspose","gl_ProjectionMatrixTranspose","gl_SecondaryColor","gl_TexCoord","gl_TextureEnvColor","gl_TextureMatrix","gl_TextureMatrixInverse","gl_TextureMatrixInverseTranspose","gl_TextureMatrixTranspose","gl_Vertex","greaterThan","greaterThanEqual","inversesqrt","length","lessThan","lessThanEqual","log","log2","matrixCompMult","max","min","mix","mod","normalize","not","notEqual","pow","radians","reflect","refract","sign","sin","smoothstep","sqrt","step","tan","texture2D","texture2DLod","texture2DProj","texture2DProjLod","textureCube","textureCubeLod","texture2DLodEXT","texture2DProjLodEXT","textureCubeLodEXT","texture2DGradEXT","texture2DProjGradEXT","textureCubeGradEXT","textureSize","texelFetch"];void 0!==s&&(t.exports=s)}()}(So);const Io=(0,go.g)(So.exports);var To=999,Po=9999,Mo=0,Eo=1,Co=2,ko=3,Fo=4,Ao=5,Ro=6,Oo=7,No=8,Do=9,zo=10,Lo=11,Bo=["block-comment","line-comment","preprocessor","operator","integer","float","ident","builtin","keyword","whitespace","eof","integer"];function Uo(t){return function(t){var e=function(){var t,e,s,i=0,r=0,n=To,o=[],a=[],h=1,c=0,l=0,u=!1,d=!1,p="";return function(t){return a=[],null!==t?f(t.replace?t.replace(/\r\n/g,"\n"):t):(o.length&&_(o.join("")),n=zo,_("(eof)"),a)};function _(t){t.length&&a.push({type:Bo[n],data:t,position:l,line:h,column:c})}function f(e){var o;for(i=0,s=(p+=e).length;t=p[i],i<s;){switch(o=i,n){case Mo:i=x();break;case Eo:case Co:i=y();break;case ko:i=b();break;case Fo:i=S();break;case Lo:i=v();break;case Ao:i=I();break;case Po:i=T();break;case Do:i=g();break;case To:i=m()}o!==i&&("\n"===p[o]?(c=0,++h):++c)}return r+=i,p=p.slice(i),a}function m(){return o=o.length?[]:o,"/"===e&&"*"===t?(l=r+i-1,n=Mo,e=t,i+1):"/"===e&&"/"===t?(l=r+i-1,n=Eo,e=t,i+1):"#"===t?(n=Co,l=r+i,i):/\s/.test(t)?(n=Do,l=r+i,i):(u=/\d/.test(t),d=/[^\w_]/.test(t),l=r+i,n=u?Fo:d?ko:Po,i)}function g(){return/[^\s]/g.test(t)?(_(o.join("")),n=To,i):(o.push(t),e=t,i+1)}function y(){return"\r"!==t&&"\n"!==t||"\\"===e?(o.push(t),e=t,i+1):(_(o.join("")),n=To,i)}function x(){return"/"===t&&"*"===e?(o.push(t),_(o.join("")),n=To,i+1):(o.push(t),e=t,i+1)}function b(){if("."===e&&/\d/.test(t))return n=Ao,i;if("/"===e&&"*"===t)return n=Mo,i;if("/"===e&&"/"===t)return n=Eo,i;if("."===t&&o.length){for(;w(o););return n=Ao,i}if(";"===t||")"===t||"("===t){if(o.length)for(;w(o););return _(t),n=To,i+1}var s=2===o.length&&"="!==t;if(/[\w_\d\s]/.test(t)||s){for(;w(o););return n=To,i}return o.push(t),e=t,i+1}function w(t){for(var e,s,i=0;;){if(e=vo.indexOf(t.slice(0,t.length+i).join("")),s=vo[e],-1===e){if(i--+t.length>0)continue;s=t.slice(0,1).join("")}return _(s),l+=s.length,(o=o.slice(s.length)).length}}function v(){return/[^a-fA-F0-9]/.test(t)?(_(o.join("")),n=To,i):(o.push(t),e=t,i+1)}function S(){return"."===t||/[eE]/.test(t)?(o.push(t),n=Ao,e=t,i+1):"x"===t&&1===o.length&&"0"===o[0]?(n=Lo,o.push(t),e=t,i+1):/[^\d]/.test(t)?(_(o.join("")),n=To,i):(o.push(t),e=t,i+1)}function I(){return"f"===t&&(o.push(t),e=t,i+=1),/[eE]/.test(t)||"-"===t&&/[eE]/.test(e)?(o.push(t),e=t,i+1):/[^\d]/.test(t)?(_(o.join("")),n=To,i):(o.push(t),e=t,i+1)}function T(){if(/[^\d\w_]/.test(t)){var s=o.join("");return n=xo.indexOf(s)>-1?No:Io.indexOf(s)>-1?Oo:Ro,_(o.join("")),n=To,i}return o.push(t),e=t,i+1}}(),s=[];return(s=s.concat(e(t))).concat(e(null))}(t)}const Go=new Set(["GL_OES_standard_derivatives","GL_EXT_frag_depth","GL_EXT_draw_buffers","GL_EXT_shader_texture_lod"]);function Vo(t,e){for(let s=e-1;s>=0;s--){const e=t[s];if("whitespace"!==e.type&&"block-comment"!==e.type){if("keyword"!==e.type)break;if("attribute"===e.data||"in"===e.data)return!0}}return!1}function qo(t,e,s,i){i=i||s;for(const r of t)if("ident"===r.type&&r.data===s)return i in e?e[i]++:e[i]=0,qo(t,e,i+"_"+e[i],i);return s}function Wo(t,e,s="afterVersion"){function i(t,e){for(let s=e;s<t.length;s++){const e=t[s];if("operator"===e.type&&";"===e.data)return s}return null}const r={data:"\n",type:"whitespace"},n=e=>e<t.length&&/[^\r\n]$/.test(t[e].data);let o=function(t){let e=-1,r=0,n=-1;for(let o=0;o<t.length;o++){const a=t[o];if("preprocessor"===a.type&&(/\#(if|ifdef|ifndef)\s+.+/.test(a.data)?++r:/\#endif\s*.*/.test(a.data)&&--r),"afterVersion"!==s&&"afterPrecision"!==s||"preprocessor"===a.type&&a.data.startsWith("#version")&&(n=Math.max(n,o)),"afterPrecision"===s&&"keyword"===a.type&&"precision"===a.data){const e=i(t,o);if(null===e)throw new Error("precision statement not followed by any semicolons!");n=Math.max(n,e)}e<n&&0===r&&(e=o)}return e+1}(t);n(o-1)&&t.splice(o++,0,r);for(const s of e)t.splice(o++,0,s);n(o-1)&&n(o)&&t.splice(o,0,r)}function Xo(t,e,s,i="lowp"){Wo(t,[{type:"keyword",data:"out"},{type:"whitespace",data:" "},{type:"keyword",data:i},{type:"whitespace",data:" "},{type:"keyword",data:s},{type:"whitespace",data:" "},{type:"ident",data:e},{type:"operator",data:";"}],"afterPrecision")}function Yo(t,e,s,i,r="lowp"){Wo(t,[{type:"keyword",data:"layout"},{type:"operator",data:"("},{type:"keyword",data:"location"},{type:"whitespace",data:" "},{type:"operator",data:"="},{type:"whitespace",data:" "},{type:"integer",data:i.toString()},{type:"operator",data:")"},{type:"whitespace",data:" "},{type:"keyword",data:"out"},{type:"whitespace",data:" "},{type:"keyword",data:r},{type:"whitespace",data:" "},{type:"keyword",data:s},{type:"whitespace",data:" "},{type:"ident",data:e},{type:"operator",data:";"}],"afterPrecision")}function jo(t,e){let s,i,r=-1;for(let n=e;n<t.length;n++){const e=t[n];if("operator"===e.type&&("["===e.data&&(s=n),"]"===e.data)){i=n;break}"integer"===e.type&&(r=parseInt(e.data,10))}return s&&i&&t.splice(s,i-s+1),r}function Ho(t,e){if(t.startsWith("#version 300"))return t;const s=function(t){return fo?$o.get(t):null}(t);if(null!=s)return s;const i=Uo(t);if("300 es"===function(t,e="100",s="300 es"){const i=/^\s*\#version\s+([0-9]+(\s+[a-zA-Z]+)?)\s*/;for(const r of t)if("preprocessor"===r.type){const t=i.exec(r.data);if(t){const i=t[1].replaceAll(/\s\s+/g," ");if(i===s)return i;if(i===e)return r.data="#version "+s,e;throw new Error("unknown glsl version: "+i)}}return t.splice(0,0,{type:"preprocessor",data:"#version "+s},{type:"whitespace",data:"\n"}),null}(i,"100","300 es"))return t;let r=null,n=null;const o={},a={};for(let t=0;t<i.length;++t){const s=i[t];switch(s.type){case"keyword":e===pi.Gs.VERTEX_SHADER&&"attribute"===s.data?s.data="in":"varying"===s.data&&(s.data=e===pi.Gs.VERTEX_SHADER?"out":"in");break;case"builtin":if(/^texture(2D|Cube)(Proj)?(Lod|Grad)?(EXT)?$/.test(s.data.trim())&&(s.data=s.data.replaceAll(/(2D|Cube|EXT)/g,"")),e===pi.Gs.FRAGMENT_SHADER&&"gl_FragColor"===s.data&&(r||(r=qo(i,o,"fragColor"),Xo(i,r,"vec4")),s.data=r),e===pi.Gs.FRAGMENT_SHADER&&"gl_FragData"===s.data){const e=jo(i,t+1),r=qo(i,o,"fragData");Yo(i,r,"vec4",e,"mediump"),s.data=r}else e===pi.Gs.FRAGMENT_SHADER&&"gl_FragDepthEXT"===s.data&&(n||(n=qo(i,o,"gl_FragDepth")),s.data=n);break;case"ident":if(_o.includes(s.data)){if(e===pi.Gs.VERTEX_SHADER&&Vo(i,t))throw new Error("attribute in vertex shader uses a name that is a reserved word in glsl 300 es");s.data in a||(a[s.data]=qo(i,o,s.data)),s.data=a[s.data]}}}for(let t=i.length-1;t>=0;--t){const e=i[t];if("preprocessor"===e.type){const s=e.data.match(/\#extension\s+(.*)\:/);if(s&&s[1]&&Go.has(s[1].trim())){const e=i[t+1];i.splice(t,e&&"whitespace"===e.type?2:1)}const r=e.data.match(/\#ifdef\s+(.*)/);r&&r[1]&&Go.has(r[1].trim())&&(e.data="#if 1");const n=e.data.match(/\#ifndef\s+(.*)/);n&&n[1]&&Go.has(n[1].trim())&&(e.data="#if 0")}}return function(t,e){return fo&&$o.set(t,e),e}(t,function(t){return t.map((t=>"eof"!==t.type?t.data:"")).join("")}(i))}const $o=new Map;class Ko{constructor(t,e,s,i,r=new Map,n=[]){this._context=t,this._locations=i,this._uniformBlockBindings=r,this._transformFeedbackVaryings=n,this._refCount=1,this._compiled=!1,this._linesOfCode=0,this._nameToUniformLocation=new Map,this._nameToUniform1=new Map,this._nameToUniform1v=new Map,this._nameToUniform2=new Map,this._nameToUniform3=new Map,this._nameToUniform4=new Map,this._nameToUniformMatrix3=new Map,this._nameToUniformMatrix4=new Map,t||console.error("RenderingContext isn't initialized!"),0===e.length&&console.error("Shaders source should not be empty!"),e=Ho(e,pi.Gs.VERTEX_SHADER),s=Ho(s,pi.Gs.FRAGMENT_SHADER),this._vShader=Zo(this._context,pi.Gs.VERTEX_SHADER,e),this._fShader=Zo(this._context,pi.Gs.FRAGMENT_SHADER,s),Jo.enabled&&(this._linesOfCode=e.match(/\n/g).length+s.match(/\n/g).length+2,this._context.instanceCounter.increment(pi.y4.LinesOfCode,this._vShader,this._linesOfCode)),this._vShader&&this._fShader||console.error("Error loading shaders!"),this._context.instanceCounter.increment(pi.y4.Shader,this),(0,eo.E5)()&&(this.vertexShader=e,this.fragmentShader=s),this.usedMemory=e.length+s.length;const o=this._context.gl,a=o.createProgram();o.attachShader(a,this._vShader),o.attachShader(a,this._fShader),this._locations.forEach(((t,e)=>o.bindAttribLocation(a,t,e))),this._transformFeedbackVaryings?.length&&o.transformFeedbackVaryings(a,this._transformFeedbackVaryings,o.SEPARATE_ATTRIBS),o.linkProgram(a),(0,eo.E5)()&&!o.getProgramParameter(a,o.LINK_STATUS)&&console.error(`Could not link shader\nvalidated: ${o.getProgramParameter(a,o.VALIDATE_STATUS)}, gl error ${o.getError()}, vertex: ${o.getShaderParameter(this._vShader,o.COMPILE_STATUS)}, fragment: ${o.getShaderParameter(this._fShader,o.COMPILE_STATUS)}, info log: ${o.getProgramInfoLog(a)}, vertex source: ${this.vertexShader}, fragment source: ${this.fragmentShader}`);for(const[t,e]of this._uniformBlockBindings){const s=o.getUniformBlockIndex(a,t);s<4294967295&&o.uniformBlockBinding(a,s,e)}this._glName=a,this._context.instanceCounter.increment(pi.y4.Program,this)}get glName(){return this._glName}get hasGLName(){return null!=this._glName}get hasTransformFeedbackVaryings(){return!!this._transformFeedbackVaryings?.length}get compiled(){if(this._compiled)return!0;const t=this._context.gl.getExtension("KHR_parallel_shader_compile");return null==t||null==this.glName?(this._compiled=!0,!0):(this._compiled=!!this._context.gl.getProgramParameter(this.glName,t.COMPLETION_STATUS_KHR),this._compiled)}dispose(){if(--this._refCount>0)return;const t=this._context.gl,e=this._context.instanceCounter;this._nameToUniformLocation.forEach((t=>t&&e.decrement(pi.y4.Uniform,t))),this._nameToUniformLocation.clear(),this._vShader&&(this._linesOfCode>0&&(e.decrement(pi.y4.LinesOfCode,this._vShader,this._linesOfCode),this._linesOfCode=0),t.deleteShader(this._vShader),this._vShader=null,e.decrement(pi.y4.Shader,this)),this._fShader&&(t.deleteShader(this._fShader),this._fShader=null),this._glName&&(t.deleteProgram(this._glName),this._glName=null,e.decrement(pi.y4.Program,this))}ref(){++this._refCount}_getUniformLocation(t){const e=this._nameToUniformLocation.get(t);if(void 0!==e)return e;if(this.glName){const e=this._context.gl.getUniformLocation(this.glName,t);return this._nameToUniformLocation.set(t,e),e&&this._context.instanceCounter.increment(pi.y4.Uniform,e),e}return null}hasUniform(t){return null!=this._getUniformLocation(t)}setUniform1i(t,e){const s=this._nameToUniform1.get(t);void 0!==s&&e===s||(this._context.gl.uniform1i(this._getUniformLocation(t),e),this._nameToUniform1.set(t,e))}setUniform1iv(t,e){Qo(this._nameToUniform1v,t,e)&&this._context.gl.uniform1iv(this._getUniformLocation(t),e)}setUniform2iv(t,e){Qo(this._nameToUniform2,t,e)&&this._context.gl.uniform2iv(this._getUniformLocation(t),e)}setUniform3iv(t,e){Qo(this._nameToUniform3,t,e)&&this._context.gl.uniform3iv(this._getUniformLocation(t),e)}setUniform4iv(t,e){Qo(this._nameToUniform4,t,e)&&this._context.gl.uniform4iv(this._getUniformLocation(t),e)}setUniform1f(t,e){const s=this._nameToUniform1.get(t);void 0!==s&&e===s||(this._context.gl.uniform1f(this._getUniformLocation(t),e),this._nameToUniform1.set(t,e))}setUniform1fv(t,e){Qo(this._nameToUniform1v,t,e)&&this._context.gl.uniform1fv(this._getUniformLocation(t),e)}setUniform2f(t,e,s){const i=this._nameToUniform2.get(t);void 0===i?(this._context.gl.uniform2f(this._getUniformLocation(t),e,s),this._nameToUniform2.set(t,[e,s])):e===i[0]&&s===i[1]||(this._context.gl.uniform2f(this._getUniformLocation(t),e,s),i[0]=e,i[1]=s)}setUniform2fv(t,e){Qo(this._nameToUniform2,t,e)&&this._context.gl.uniform2fv(this._getUniformLocation(t),e)}setUniform3f(t,e,s,i){const r=this._nameToUniform3.get(t);void 0===r?(this._context.gl.uniform3f(this._getUniformLocation(t),e,s,i),this._nameToUniform3.set(t,[e,s,i])):e===r[0]&&s===r[1]&&i===r[2]||(this._context.gl.uniform3f(this._getUniformLocation(t),e,s,i),r[0]=e,r[1]=s,r[2]=i)}setUniform3fv(t,e){const s=this._getUniformLocation(t);null!=s&&Qo(this._nameToUniform3,t,e)&&this._context.gl.uniform3fv(s,e)}setUniform4f(t,e,s,i,r){const n=this._nameToUniform4.get(t);void 0===n?(this._context.gl.uniform4f(this._getUniformLocation(t),e,s,i,r),this._nameToUniform4.set(t,[e,s,i,r])):void 0!==n&&e===n[0]&&s===n[1]&&i===n[2]&&r===n[3]||(this._context.gl.uniform4f(this._getUniformLocation(t),e,s,i,r),n[0]=e,n[1]=s,n[2]=i,n[3]=r)}setUniform4fv(t,e){const s=this._getUniformLocation(t);null!=s&&Qo(this._nameToUniform4,t,e)&&this._context.gl.uniform4fv(s,e)}setUniformMatrix3fv(t,e,s=!1){const i=this._getUniformLocation(t);null!=i&&Qo(this._nameToUniformMatrix3,t,e)&&this._context.gl.uniformMatrix3fv(i,s,e)}setUniformMatrix4fv(t,e,s=!1){const i=this._getUniformLocation(t);null!=i&&Qo(this._nameToUniformMatrix4,t,e)&&this._context.gl.uniformMatrix4fv(i,s,e)}stop(){}}function Zo(t,e,s){const i=t.gl,r=i.createShader(e);return i.shaderSource(r,s),i.compileShader(r),(0,eo.E5)()&&!i.getShaderParameter(r,i.COMPILE_STATUS)&&(console.error("Compile error in ".concat(e===pi.Gs.VERTEX_SHADER?"vertex":"fragment"," shader")),console.error(i.getShaderInfoLog(r)),console.error(function(t){let e=2;return t.replaceAll("\n",(()=>"\n"+function(t){return t>=1e3?t.toString():(" "+t).slice(-3)}(e++)+":"))}(s))),r}function Qo(t,e,s){const i=t.get(e);if(!i)return t.set(e,Array.from(s)),!0;const r=s.length;if(i.length!==r)return t.set(e,Array.from(s)),!0;for(let t=0;t<r;++t){const e=s[t];if(i[t]!==e){for(i[t]=e;t<r;++t)i[t]=s[t];return!0}}return!1}const Jo={enabled:!1};s(2944);var ta=s(51576);function ea(t,e,s){const i=new ta.O(e.width,e.height);return i.dataType=e.dataType,e.depth&&(i.depth=e.depth),e.flipped&&(i.flipped=e.flipped),e.hasMipmap&&(i.hasMipmap=e.hasMipmap),i.internalFormat=e.internalFormat,e.isImmutable&&(i.isImmutable=e.isImmutable),e.isOpaque&&(i.isOpaque=e.isOpaque),e.maxAnisotropy&&(i.maxAnisotropy=e.maxAnisotropy),i.pixelFormat=e.pixelFormat,e.preMultiplyAlpha&&(i.preMultiplyAlpha=e.preMultiplyAlpha),e.samplingMode&&(i.samplingMode=e.samplingMode),e.target&&(i.target=e.target),i.uniform=e.uniform,e.unpackAlignment&&(i.unpackAlignment=e.unpackAlignment),e.wrapMode&&(i.wrapMode=e.wrapMode),new ho.w(t,i,s)}function sa(t,e,s){const r=e.length;if(r!==s){const n=new i.c("Invalid Uniform",`Invalid length, expected ${s} but got ${r}`,{uniformName:t,values:e});C.c.getLogger("geoscene.views.2d.engine.webgl.shaderGraph.typed.TypedShaderProgram").errorOnce(n)}}new Map;class ia{constructor(t,e,s,i,r,n){this._program=null,this._vao=null,this._temporaryTextures=[],this.vertexShader=t,this.fragmentShader=e,this._locations=s,this._locationInfo=i,this._uniformBindings=r,this._transformFeedbackBindings=n}destroy(){this._program&&this._program.dispose(),this.cleanupTemporaryTextures()}get locations(){return this._locations}get locationInfo(){return this._locationInfo}setUniforms(t){this._uniforms=t}cleanupTemporaryTextures(){for(const t of this._temporaryTextures)t.dispose();this._temporaryTextures=[]}bind(t){const e=this._uniforms;if(!this._program){const e=new Map;for(const[t,s]of this._locations)e.set(t,s);const s=[];for(const t of this._transformFeedbackBindings??[]){const{index:e,propertyKey:i}=t;s[e]=`v_${i}`}this._program=new Ko(t,this.vertexShader,this.fragmentShader,e,new Map,s)}const s=this._program;t.useProgram(s);for(const i of this._uniformBindings){const{shaderModulePath:r,uniformName:n,uniformType:o,uniformArrayLength:a}=i,h=(0,to.YT)(r,e);if(null==h){if("sampler2D"===o)continue;throw new Error(`Failed to find uniform value for ${r}`)}switch("array"===o?i.uniformArrayElementType:o){case"sampler2D":{const{unit:e,texture:i}=h;if(s.setUniform1i(n,e),"type"in i)t.bindTexture(i,e);else{const s=ea(t,i.descriptor,i.data);t.bindTexture(s,e)}break}case"int":if(!a){s.setUniform1i(n,h);break}sa(i.uniformName,h,a),s.setUniform1iv(n,h);break;case"float":if(!a){s.setUniform1f(n,h);break}sa(i.uniformName,h,a),s.setUniform1fv(n,h);break;case"vec2":if(!a){s.setUniform2f(n,h[0],h[1]);break}sa(i.uniformName,h,a),s.setUniform2fv(n,h.flat());break;case"vec3":if(!a){s.setUniform3f(n,h[0],h[1],h[2]);break}sa(i.uniformName,h,a),s.setUniform3fv(n,h.flat());break;case"vec4":if(!a){s.setUniform4f(n,h[0],h[1],h[2],h[3]);break}sa(i.uniformName,h,a),s.setUniform4fv(n,h.flat());break;case"mat3":s.setUniformMatrix3fv(n,h.flat());break;case"mat4":s.setUniformMatrix4fv(n,h.flat());break;default:throw new Error(`Unable to set uniform for type ${o}`)}}}}function ra(t){return new t}function na(t,e,s){const i=t.constructor[e]??[];t.constructor.hasOwnProperty(e)||Object.defineProperty(t.constructor,e,{value:i.slice()}),t.constructor[e].push(s)}function oa(t,e){return(s,i)=>{na(s,"locations",{typeCtor:e,propertyKey:i,parameterIndex:null,index:t})}}const aa=t=>(e,s,i)=>{na(e,"inputs",{inputCtor:t,propertyKey:s,parameterIndex:i})},ha=t=>(e,s)=>{na(e,"uniforms",{typeCtor:t,propertyKey:s})},ca=t=>(e,s)=>{na(e,"options",{typeCtor:t,propertyKey:s})},la=(t,e)=>{na(t,"defines",{propertyKey:e})},ua=(t,e)=>(s,i)=>{s.constructor.builtins.push({builtin:t,propertyKey:i,typeCtor:e})};class da{}da.builtins=[],(0,T._)([ua("gl_VertexID",en)],da.prototype,"glVertexID",void 0);class pa{}class _a{}_a.builtins=[],(0,T._)([ua("gl_FragCoord",Xr)],_a.prototype,"glFragCoord",void 0),(0,T._)([ua("gl_PointCoord",qr)],_a.prototype,"glPointCoord",void 0);class fa{}(0,T._)([(t,e)=>{na(t,"builtins",{builtin:"gl_FragColor",propertyKey:e})}],fa.prototype,"glFragColor",void 0);class ma{constructor(){this.type="uniform-group"}get _uniforms(){return this.constructor.uniforms??[]}}class ga{constructor(){this.logShader=!1,this.computeAttributes={}}get vertexInput(){const t=(0,tt.mk)(this._shaderModuleClass.inputs,(t=>"vertex"===t.propertyKey&&0===t.parameterIndex));if(!t)throw new Error("Unable to find vertex input parameter");return t}get computeInput(){return(0,tt.mk)(this._shaderModuleClass.inputs,(t=>"vertex"===t.propertyKey&&1===t.parameterIndex))}get fragmentInput(){const t=(0,tt.mk)(this._shaderModuleClass.inputs,(t=>"fragment"===t.propertyKey));if(!t)throw new Error("Unable to find fragment input parameter");return t}get transformFeedbackBindings(){return this.fragmentInput.inputCtor.transformFeedbackBindings??[]}get locations(){return[...this.vertexInput.inputCtor.locations,...this.computeInput?.inputCtor.locations??[]]}get locationsMap(){const t=new Map,e=new Set;for(const s of this.locations)e.has(s.index)?C.c.getLogger("geoscene.views.2d.engine.webgl.shaderGraph.GraphShaderModule").warnOnce("mapview-rendering",`Unable to assigned attribute ${s.propertyKey} to ${s.index}. Index already in use`,{locationsMap:t}):(t.set(s.propertyKey,s.index),e.add(s.index));return t}get locationInfo(){if(!this._locationInfo){const t=this.locationsMap,e=Array.from(t.entries()).map((([t,e])=>`${t}.${e}`)).join("."),s=(0,st.sV)(e);this._locationInfo={hash:s,locations:t}}return this._locationInfo}get renamedLocationsMap(){const t=new Map;for(const e of this.locations)t.set("a_"+e.propertyKey,e.index);return t}get optionPropertyKeys(){if(!this._optionPropertyKeys){const t=new Set;for(const e of this._options)t.add(e.propertyKey);this._optionPropertyKeys=t}return this._optionPropertyKeys}get _shaderModuleClass(){return this.constructor}get _defines(){return this._shaderModuleClass.defines??[]}get _options(){return this._shaderModuleClass.options??[]}get _uniforms(){return this._shaderModuleClass.uniforms??[]}getProgram(t,e,s,i){try{const{vertex:r,fragment:n,uniformBindings:o}=this._generateShaders(t,e,s,i);return new ia(r,n,this.renamedLocationsMap,this.locationInfo,o,this.transformFeedbackBindings)}catch(t){return console.error("Failed to create program",{error:t}),new ia("","",this.renamedLocationsMap,this.locationInfo,[],this.transformFeedbackBindings)}}getDebugUniformClassInfo(t){const e=this._options.find((e=>e.propertyKey===t));if(e)return{type:"option",className:e.typeCtor};const s=this._uniforms.find((e=>e.propertyKey===t));if(!s)throw new Error(`Unable to find uniform class type for property: ${t}`);return{type:"required",className:s.typeCtor}}getShaderKey(t,e,s,i){const r=Object.keys(s).map((t=>`${t}.${s[t]}`)).join("."),n=Object.keys(i).map((t=>`${t}.${i[t]}`)).join("."),o=Object.keys(e).filter((t=>this.optionPropertyKeys.has(t)&&e[t])).join(".");return`${this.constructor.name}.${t.hash}.${r}.${n}.${o}`}_generateShaders(t,e,s,i){const r=[];this._setDefines(s),this._setOptionalUniforms(r,e),this._setRequiredUniforms(r);const n=this._hydrateVertexInput(i),o=this._injectPackPrecisionFactor(n,t),a=this._hydrateComputeInput(),h=a&&this._injectPackPrecisionFactor(a,t),c=this.vertex(o,h),l=this._hydrateFragmentInput(c),u=this.fragment(l),d=new Set;for(const t in u)_r(d,u[t]);const p=this._getVertexInputBuiltins(),_=Jn.createVertex({...n,...a},c,p,r,this.transformFeedbackBindings,d);(new Kn).write(_);const f=this._getFragmentInputBuiltins(u);f.set("glPointCoord","gl_PointCoord");const m=Jn.createFragment(l,u,f,r,_,this.transformFeedbackBindings);(new Kn).write(m);const g=this._createShaderBuilder(_,m),y=g.generate("vertex",!1),x=g.generate("fragment",!1);return this.logShader&&(console.log(y),console.log(x)),{vertex:y,fragment:x,uniformBindings:r}}_setDefines(t){for(const e in t)this[e]=t[e]}_setOptionalUniforms(t,e){for(const s of this._options)e[s.propertyKey]?this[s.propertyKey]=this._hydrateUniformGroup(t,s):this[s.propertyKey]=null}_setRequiredUniforms(t){for(const e of this._uniforms)this[e.propertyKey]=this._hydrateUniformGroup(t,e)}_hydrateUniformGroup(t,e){const s=new(0,e.typeCtor);for(const i of s._uniforms??[]){const r=ra(i.typeCtor),n=`u_${e.propertyKey}_${i.propertyKey}`,o=r.type,a=[e.propertyKey,i.propertyKey].join(".");if("type"in i.typeCtor&&"array"===i.typeCtor.type){const e=r;t.push({shaderModulePath:a,uniformName:n,uniformType:o,uniformArrayLength:e.size,uniformArrayElementType:e.elementType.type,uniformHydrated:r})}else t.push({shaderModulePath:a,uniformName:n,uniformType:o,uniformHydrated:r});s[i.propertyKey]=r}return s}_hydrateVertexInput(t){const e=this.vertexInput.inputCtor,s=e.locations.reduce(((e,s)=>!1===t[s.propertyKey]?e:{...e,[s.propertyKey]:ra(s.typeCtor)}),{});for(const{propertyKey:t,typeCtor:i}of e.builtins){const e=ra(i);s[t]=e}return s}_hydrateComputeInput(){return null==this.computeInput?null:this.computeInput.inputCtor.locations.reduce(((t,e)=>({...t,[e.propertyKey]:ra(e.typeCtor)})),{})}_injectPackPrecisionFactor(t,e){const s={};for(const i in t){const r=t[i],n=e.attributes.find((t=>t.name===i));if(n?.packPrecisionFactor){if("float"!==r.type&&"vec2"!==r.type&&"vec3"!==r.type&&"vec4"!==r.type)throw new Error(`InternalError: packPrecisionFactor requires GenType, but found ${r.type}`);s[i]=r.divide(new Vr(n.packPrecisionFactor))}else s[i]=r}return s}_hydrateFragmentInput(t){const e={};for(const s in t)e[s]=t[s];for(const{propertyKey:t,typeCtor:s}of _a.builtins){const i=ra(s);e[t]=i}return e}_getVertexInputBuiltins(){const t=this.vertexInput.inputCtor,e=new Map;for(const{builtin:s,propertyKey:i}of t.builtins)e.set(i,s);return e}_getFragmentInputBuiltins(t){const e=t.constructor,s=new Map;for(const t of e.builtins??[])s.set(t.propertyKey,t.builtin);return s}_createShaderBuilder(t,e){const s=new nr;return this._insertDebugInfo(s),t.insertVertexShader(s),e.insertFragmentShader(s),s}_insertDebugInfo(t){t.vertex.code.add("// DEFINES: "),t.vertex.code.add("// --------------------------------------------------------- ");for(const e of this._defines)this[e.propertyKey]?t.vertex.code.add(`// ${e.propertyKey}: true`):t.vertex.code.add(`// ${e.propertyKey}: false`);t.vertex.code.add(""),t.vertex.code.add("// OPTIONS: "),t.vertex.code.add("// --------------------------------------------------------- ");for(const e of this._options)this[e.propertyKey]?t.vertex.code.add(`// ${e.propertyKey}: true`):t.vertex.code.add(`// ${e.propertyKey}: false`)}}let ya=class extends P.c{constructor(){super(...arguments),this.color=new wi.c([0,255,255]),this.haloOpacity=1,this.fillOpacity=.25,this.multiHighlightEnabled=!1}equals(t){return this.color.equals(t.color)&&(this.haloColor||this.color).equals(t.haloColor||t.color)&&this.haloOpacity===t.haloOpacity&&this.fillOpacity===t.fillOpacity&&this.multiHighlightEnabled===t.multiHighlightEnabled}};(0,T._)([(0,E.qq)({type:wi.c})],ya.prototype,"color",void 0),(0,T._)([(0,E.qq)({type:wi.c})],ya.prototype,"haloColor",void 0),(0,T._)([(0,E.qq)()],ya.prototype,"haloOpacity",void 0),(0,T._)([(0,E.qq)()],ya.prototype,"fillOpacity",void 0),(0,T._)([(0,E.qq)()],ya.prototype,"multiHighlightEnabled",void 0),ya=(0,T._)([(0,k.c)("geoscene.views.2d.support.HighlightOptions")],ya);const xa=ya,ba={selection:t=>new xa({color:new wi.c([t.color.r/2,t.color.g/2,t.color.b/2,t.color.a])}),highlight:t=>t,popup:t=>new xa({color:new wi.c([t.color.g,t.color.b,t.color.r,t.color.a])})},wa=Object.keys(ba);function va(t){const e=un(12.9898),s=un(78.233),i=un(43758.5453);return Bn(Yn(Wn(Ln(t,dn(e,s)),un(3.14))).multiply(i))}function Sa(t){return En(t,un(Bi))}function Ia(t,e){const s=un(2**e);return Wn(function(t){return gn("floor",t)}(t.divide(s)),un(2))}function Ta(t,e){return Ia(t,e+wa.length)}class Pa extends ma{getVisualVariableData(t){if(!this._vvData){const e=this.getAttributeDataCoords(t);this._vvData=Hn(this.visualVariableData,e).setDebugName("storage2")}return this._vvData}getAttributeDataCoords(t){if(!this._uv){const e=function(t){const e=Ia(t.z,7),s=un(1).subtract(e),i=t.xyz.subtract(((...t)=>new Wr(...t))(0,0,un(128)));return s.multiply(t).add(e.multiply(i))}(t),s=this.size,i=ln(e.x),r=ln(e.y).multiply(ln(256)),n=ln(e.z).multiply(ln(256)).multiply(ln(256)),o=un(i.add(r).add(n)),a=Wn(o,s),h=o.subtract(a).divide(s);this._uv=new qr(a,h).add(.5).divide(s)}return this._uv}getFilterData(t){const e=this.getAttributeDataCoords(t);return Hn(this.filterFlags,e).setDebugName("storage0")}getAnimationData(t){const e=this.getAttributeDataCoords(t);return Hn(this.animation,e).setDebugName("storage1")}getVVData(t){return this.getVisualVariableData(t)}getDataDrivenData0(t){const e=this.getAttributeDataCoords(t);return Hn(this.dataDriven0,e).setDebugName("storage30")}getDataDrivenData1(t){const e=this.getAttributeDataCoords(t);return Hn(this.dataDriven1,e).setDebugName("storage31")}getDataDrivenData2(t){const e=this.getAttributeDataCoords(t);return Hn(this.dataDriven2,e).setDebugName("storage32")}getGPGPUData(t){const e=this.getAttributeDataCoords(t);return Hn(this.gpgpu,e).setDebugName("storage4")}getFilterFlags(t){return(0,n.c)("webgl-ignores-sampler-precision")?function(t){return gn("ceil",t)}(this.getFilterData(t).x.multiply(un(255))):this.getFilterData(t).x.multiply(un(255))}getAnimationValue(t){return this.getAnimationData(t).x}getSizeValue(t){return this.getVisualVariableData(t).x}getColorValue(t){return this.getVisualVariableData(t).y}getOpacityValue(t){return this.getVisualVariableData(t).z}getRotationValue(t){return this.getVisualVariableData(t).w}}(0,T._)([ha(Gr)],Pa.prototype,"filterFlags",void 0),(0,T._)([ha(Gr)],Pa.prototype,"animation",void 0),(0,T._)([ha(Gr)],Pa.prototype,"gpgpu",void 0),(0,T._)([ha(Gr)],Pa.prototype,"visualVariableData",void 0),(0,T._)([ha(Gr)],Pa.prototype,"dataDriven0",void 0),(0,T._)([ha(Gr)],Pa.prototype,"dataDriven1",void 0),(0,T._)([ha(Gr)],Pa.prototype,"dataDriven2",void 0),(0,T._)([ha(Vr)],Pa.prototype,"size",void 0);class Ma extends ma{}(0,T._)([ha(Vr)],Ma.prototype,"activeReasons",void 0),(0,T._)([ha(Vr)],Ma.prototype,"highlightAll",void 0);class Ea extends ma{}(0,T._)([ha(qr)],Ea.prototype,"position",void 0),(0,T._)([ha(Vr)],Ea.prototype,"distance",void 0),(0,T._)([ha(Vr)],Ea.prototype,"smallSymbolDistance",void 0),(0,T._)([ha(Vr)],Ea.prototype,"smallSymbolSizeThreshold",void 0);class Ca extends ma{}(0,T._)([ha(an)],Ca.prototype,"displayViewScreenMat3",void 0),(0,T._)([ha(an)],Ca.prototype,"displayViewMat3",void 0),(0,T._)([ha(an)],Ca.prototype,"displayMat3",void 0),(0,T._)([ha(an)],Ca.prototype,"viewMat3",void 0),(0,T._)([ha(an)],Ca.prototype,"tileMat3",void 0),(0,T._)([ha(Vr)],Ca.prototype,"displayZoomFactor",void 0),(0,T._)([ha(Vr)],Ca.prototype,"requiredZoomFactor",void 0),(0,T._)([ha(qr)],Ca.prototype,"tileOffset",void 0),(0,T._)([ha(Vr)],Ca.prototype,"currentScale",void 0),(0,T._)([ha(Vr)],Ca.prototype,"currentZoom",void 0),(0,T._)([ha(Vr)],Ca.prototype,"metersPerSRUnit",void 0),(0,T._)([ha(Vr)],Ca.prototype,"rotation",void 0),(0,T._)([ha(Vr)],Ca.prototype,"pixelRatio",void 0);class ka extends da{}(0,T._)([oa(0,Wr)],ka.prototype,"id",void 0),(0,T._)([oa(1,Vr)],ka.prototype,"bitset",void 0),(0,T._)([oa(2,qr)],ka.prototype,"pos",void 0);class Fa extends pa{}(0,T._)([oa(14,qr)],Fa.prototype,"nextPos1",void 0),(0,T._)([oa(15,qr)],Fa.prototype,"nextPos2",void 0);class Aa extends _a{}class Ra extends ga{clip(t,e){let s=new Vr(0);const i=this.storage.getFilterFlags(t);if(s=s.add(un(2).multiply(un(1).subtract(Ta(i,0)))),this.inside?s=s.add(un(2).multiply(un(1).subtract(Ta(i,1)))):this.outside?s=s.add(un(2).multiply(Ta(i,1))):this.highlight&&(s=s.add(un(2).multiply(un(1).subtract(this._checkHighlight(i))))),null!=e){const t=new Vr(1).subtract(jn(e.x,this.view.currentZoom)),i=jn(e.y,this.view.currentZoom);s=s.add(new Vr(2).multiply(t.add(i)))}return s}getFragmentOutput(t,e,s=new Vr(1/255)){const i=new fa;return i.glFragColor=this._maybeWriteHittest(e)??this._maybeHighlight(t,s)??t,i}_maybeHighlight(t,e){return this.highlight?new Xr(t.rgb,jn(e,t.a)):null}_checkHighlight(t){let e=this._checkHighlightBit(t,0);for(let s=1;s<wa.length;s++)e=e.add(this._checkHighlightBit(t,s));return jn(new Vr(.1),e.add(this.highlight.highlightAll))}_checkHighlightBit(t,e){return function(t,e){return Ia(t,e)}(t,e).multiply(Ia(this.highlight.activeReasons,e))}maybeRunHittest(t,e,s){if(null==this.hittestRequest)return null;let i=vn(kn(this.hittest(t,e,s),this.hittestRequest.distance),new Vr(2),new Vr(0));const r=function(t){return t.multiply(2).subtract(1)}(this.storage.getAttributeDataCoords(t.id));i=i.add(this.clip(t.id,t.zoomRange));const n=new Xr(new Vr(1/255),0,0,0);return{glPointSize:new Vr(1),glPosition:new Xr(r,i,1),color:n}}_maybeWriteHittest(t){return null!=this.hittestRequest?t.color:null}}function Oa(t,e,s){const i=s.subtract(e),r=Dn(function(t,e){return Ln(t,function(t){return gn("normalize",t)}(e))}(t.subtract(e),i).divide(Un(i)),new Vr(0),new Vr(1));return function(t,e){return yn("distance",t,e,Vr)}(t,e.add(r.multiply(s.subtract(e))))}function Na(t,e,s,i){return En(function(t){const e=function(t){return gn("abs",t)}(t);return jn(e.x.add(e.y).add(e.z),new Vr(1.05))}(function(t,e,s,i){const r=new an(s.x.multiply(i.y).subtract(i.x.multiply(s.y)),i.x.multiply(e.y).subtract(e.x.multiply(i.y)),e.x.multiply(s.y).subtract(s.x.multiply(e.y)),s.y.subtract(i.y),i.y.subtract(e.y),e.y.subtract(s.y),i.x.subtract(s.x),e.x.subtract(i.x),s.x.subtract(e.x)),n=e.x.multiply(s.y.subtract(i.y)),o=s.x.multiply(i.y.subtract(e.y)),a=i.x.multiply(e.y.subtract(s.y)),h=n.add(o).add(a);return new Vr(1).divide(h).multiply(r.multiply(new Wr(1,t)))}(t,e,s,i)),new Vr(1))}function Da(t){return t.distance.add(1)}function za(t,e,s){const{viewMat3:i,tileMat3:r}=t.view,n=i.multiply(r),o=n.multiply(new Wr(e.pos,1)),a=n.multiply(new Wr(s.nextPos1,1)),h=n.multiply(new Wr(s.nextPos2,1));return function(t,e,s,i){const r=function(t,e){return t.x.multiply(e.y).subtract(e.x.multiply(t.y))}(s.subtract(e),i.subtract(e)),n=Rn(function(t,e){return mn("<",t,e,Kr)}(r,new Vr(Li)),kn(r,new Vr(-Li)));return Sn([Rn(Xn(n),Na(t.xy,e,s,i)),new Vr(-1)],[!0,()=>{const r=Oa(t,e,s),n=Oa(t,s,i),o=Oa(t,i,e);return Vn(Vn(r,n),o)}])}(t.hittestRequest.position,o.xy,a.xy,h.xy)}(0,T._)([la],Ra.prototype,"inside",void 0),(0,T._)([la],Ra.prototype,"outside",void 0),(0,T._)([ca(Ma)],Ra.prototype,"highlight",void 0),(0,T._)([ha(Pa)],Ra.prototype,"storage",void 0),(0,T._)([ha(Ca)],Ra.prototype,"view",void 0),(0,T._)([ca(Ea)],Ra.prototype,"hittestRequest",void 0);class La extends ma{getColor(t,e,s){return Sn([An(Sa(t),s),e],[Cn(t,this.values.first()),this.colors.first()],[Fn(t,this.values.last()),this.colors.last()],[!0,()=>{const e=this.values.findIndex((e=>kn(e,t))),s=this.values.get(e),i=e.subtract(1),r=this.values.get(i),n=t.subtract(r).divide(s.subtract(r));return qn(this.colors.get(i),this.colors.get(e),n)}])}}(0,T._)([ha(Ur.ofType(Xr,8))],La.prototype,"colors",void 0),(0,T._)([ha(Ur.ofType(Vr,8))],La.prototype,"values",void 0);class Ba extends ma{getOpacity(t){return Sn([Sa(t),new Vr(1)],[Cn(t,this.opacityValues.first()),this.opacities.first()],[Fn(t,this.opacityValues.last()),this.opacities.last()],[!0,()=>{const e=this.opacityValues.findIndex((e=>kn(e,t))),s=this.opacityValues.get(e),i=e.subtract(1),r=this.opacityValues.get(i),n=t.subtract(r).divide(s.subtract(r));return qn(this.opacities.get(i),this.opacities.get(e),n)}])}}function Ua(t){return null!=t.visualVariableSizeMinMaxValue||null!=t.visualVariableSizeScaleStops||null!=t.visualVariableSizeStops||null!=t.visualVariableSizeUnitValue}function Ga(t,e,s,i=new Kr(!1)){if(null==t.visualVariableColor)return s;const r=t.storage.getColorValue(e);return t.visualVariableColor.getColor(r,s,i)}function Va(t,e){if(null==t.visualVariableOpacity)return new Vr(1);const s=t.storage.getOpacityValue(e);return t.visualVariableOpacity.getOpacity(s)}(0,T._)([ha(Ur.ofType(Vr,8))],Ba.prototype,"opacities",void 0),(0,T._)([ha(Ur.ofType(Vr,8))],Ba.prototype,"opacityValues",void 0);class qa extends ka{}(0,T._)([oa(3,Xr)],qa.prototype,"color",void 0),(0,T._)([oa(4,qr)],qa.prototype,"zoomRange",void 0);class Wa extends Ra{constructor(){super(...arguments),this.computeAttributes={pos:["nextPos1","nextPos2"]}}vertex(t,e){const s=Va(this,t.id),i=Ga(this,t.id,t.color).multiply(s),r=this.view.displayViewScreenMat3.multiply(new Wr(t.pos.xy,1)),n=this.clip(t.id,t.zoomRange);return{glPosition:new Xr(r.xy,n,1),color:i,...this.maybeRunHittest(t,e,null)}}fragment(t){return this.getFragmentOutput(t.color,t,new Vr(0))}hittest(t,e){return za(this,t,e)}}(0,T._)([ca(La)],Wa.prototype,"visualVariableColor",void 0),(0,T._)([ca(Ba)],Wa.prototype,"visualVariableOpacity",void 0),(0,T._)([(0,T.a)(0,aa(qa)),(0,T.a)(1,aa(Fa))],Wa.prototype,"vertex",null),(0,T._)([(0,T.a)(0,aa(Aa))],Wa.prototype,"fragment",null);class Xa extends ma{getPatternOffsetAtTileOrigin(t,e=new Vr(0),s=new Vr(1)){const i=new qr(16777216).divide(t);let r=t.multiply(Bn(this.maxIntsToLocalOrigin.multiply(i))).add(this.tileOffsetFromLocalOrigin).subtract(new Vr(.5).multiply(t));return r=new qr(r.x.multiply(s).subtract(r.y.multiply(e)),r.x.multiply(e).add(r.y.multiply(s))),Wn(r,t)}}(0,T._)([ha(qr)],Xa.prototype,"tileOffsetFromLocalOrigin",void 0),(0,T._)([ha(qr)],Xa.prototype,"maxIntsToLocalOrigin",void 0);class Ya extends ma{}(0,T._)([ha(qr)],Ya.prototype,"size",void 0),(0,T._)([ha(Gr)],Ya.prototype,"texture",void 0);class ja extends qa{}function Ha(t,e){const s=qn(new qr(1),new qr(1/B.Q0),new qr(Ia(e.bitset,6),Ia(e.bitset,5))),i=t.view.requiredZoomFactor,r=new qr(e.width,e.height).multiply(s),n=r.multiply(e.scale).multiply(i),o=e.angle.multiply(.024543692606171875),a=Yn(o),h=zn(o),c=function(t,e,s,i,r){const n=En(Ia(r,Ui),un(1)),o=function(t){return Ln(t,pn(255/256,255/65536,255/16777216,255/4294967296))}(new Xr(t,0));return vn(n,_n(i.divide(e.x),s.divide(e.y),0,bn(s.divide(e.x)),i.divide(e.y),0,va(dn(o,0)),va(dn(0,o)),1),_n(i.divide(e.x),s.divide(e.y),0,bn(s.divide(e.x)),i.divide(e.y),0,0,0,1))}(e.id,n,a,h,e.bitset),l=t.localTileOffset.getPatternOffsetAtTileOrigin(r,a,h),u=i.multiply(e.scale).multiply(e.offset.subtract(l)).divide(n),d=new Wr(e.pos,1),p=c.multiply(d).xy.subtract(u),_=e.tlbr.divide(t.mosaicInfo.size.xyxy);let f=Ia(e.bitset,4);return null!=t.visualVariableColor&&(f=vn(Sa(t.storage.getColorValue(e.id)),new Vr(0),f)),{tileTextureCoord:p,tlbr:_,sampleAlphaOnly:f}}function $a(t,e){const s=Wn(e.tileTextureCoord,new Vr(1)),i=qn(e.tlbr.xy,e.tlbr.zw,s);let r=Hn(t.mosaicInfo.texture,i);return r=vn(kn(e.sampleAlphaOnly,new Vr(.5)),r.aaaa,r),e.color.multiply(r)}(0,T._)([oa(5,Xr)],ja.prototype,"tlbr",void 0),(0,T._)([oa(6,Vr)],ja.prototype,"width",void 0),(0,T._)([oa(7,Vr)],ja.prototype,"height",void 0),(0,T._)([oa(8,qr)],ja.prototype,"offset",void 0),(0,T._)([oa(9,qr)],ja.prototype,"scale",void 0),(0,T._)([oa(10,Vr)],ja.prototype,"angle",void 0);class Ka extends Wa{vertex(t,e){return{...super.vertex(t,e),...Ha(this,t)}}fragment(t){const e=$a(this,t);return this.getFragmentOutput(e,t,new Vr(0))}}(0,T._)([ha(Ya)],Ka.prototype,"mosaicInfo",void 0),(0,T._)([ha(Xa)],Ka.prototype,"localTileOffset",void 0),(0,T._)([(0,T.a)(0,aa(ja)),(0,T.a)(1,aa(Fa))],Ka.prototype,"vertex",null),(0,T._)([(0,T.a)(0,aa(class extends Aa{}))],Ka.prototype,"fragment",null);class Za extends ma{getSize(t,e){const s=this.minMaxValueAndSize.xy,i=this.minMaxValueAndSize.zw;return vn(Sa(t),e,(()=>{const e=Dn(t.subtract(s.x).divide(s.y.subtract(s.x)),new Vr(0),new Vr(1));return i.x.add(e.multiply(i.y.subtract(i.x)))}))}}(0,T._)([ha(Xr)],Za.prototype,"minMaxValueAndSize",void 0);class Qa extends ma{getSizeForViewScale(t){return Sn([Cn(t,this.values.first()),this.sizes.first()],[Fn(t,this.values.last()),this.sizes.last()],[!0,()=>{const e=this.values.findIndex((e=>kn(e,t))),s=this.values.get(e),i=e.subtract(1),r=this.values.get(i),n=t.subtract(r).divide(s.subtract(r));return qn(this.sizes.get(i),this.sizes.get(e),n)}])}}(0,T._)([ha(Ur.ofType(Vr,8))],Qa.prototype,"sizes",void 0),(0,T._)([ha(Ur.ofType(Vr,8))],Qa.prototype,"values",void 0);class Ja extends ma{getSize(t,e){const s=Sn([Sa(t),e],[Cn(t,this.values.first()),this.sizes.first()],[Fn(t,this.values.last()),this.sizes.last()],[!0,()=>{const e=this.values.findIndex((e=>kn(e,t))),s=this.values.get(e),i=e.subtract(1),r=this.values.get(i),n=t.subtract(r).divide(s.subtract(r));return qn(this.sizes.get(i),this.sizes.get(e),n)}]);return vn(Sa(s),e,s)}}(0,T._)([ha(Ur.ofType(Vr,8))],Ja.prototype,"sizes",void 0),(0,T._)([ha(Ur.ofType(Vr,8))],Ja.prototype,"values",void 0);class th extends ma{getSize(t,e){return vn(Sa(t),e,t.multiply(this.unitValueToPixelsRatio))}}(0,T._)([ha(Vr)],th.prototype,"unitValueToPixelsRatio",void 0);class eh extends ka{}(0,T._)([oa(3,Xr)],eh.prototype,"color",void 0),(0,T._)([oa(4,qr)],eh.prototype,"offset",void 0),(0,T._)([oa(5,qr)],eh.prototype,"normal",void 0),(0,T._)([oa(6,Vr)],eh.prototype,"halfWidth",void 0),(0,T._)([oa(7,Vr)],eh.prototype,"referenceHalfWidth",void 0),(0,T._)([oa(8,qr)],eh.prototype,"zoomRange",void 0);class sh extends Aa{}class ih extends ma{}function rh(t){return Gn(new Vr(Ni).multiply(jn(t,new Vr(Di))),new Vr(1))}function nh(t,e){const{id:s,offset:i,pos:r,normal:n,zoomRange:o}=e,{displayViewScreenMat3:a,displayViewMat3:h}=t.view,c=Ga(t,s,e.color),l=Va(t,s),u=function(t,e){const{id:s,halfWidth:i,referenceHalfWidth:r}=e;if(Ua(t)){const e=function(t,e,s){if(Ua(t)){const i=t.storage.getSizeValue(e);return t.visualVariableSizeMinMaxValue?.getSize(i,s)??t.visualVariableSizeScaleStops?.getSizeForViewScale(t.view.currentScale)??t.visualVariableSizeStops?.getSize(i,s)??t.visualVariableSizeUnitValue?.getSize(i,s)}return s}(t,s,new Vr(2).multiply(r));return new Vr(.5).multiply(i.divide(Gn(r,new Vr(zi)))).multiply(e)}return i}(t,e),d=new Vr(.5).multiply(t.antialiasingControls.antialiasing),p=Gn(u.add(d),new Vr(.45)).add(new Vr(.1).multiply(d)),_=rh(p).multiply(p).multiply(i),f=h.multiply(new Wr(_,new Vr(0))),m=a.multiply(new Wr(r,new Vr(1))).add(f),g=new Vr(2).multiply(jn(u,new Vr(0))).add(t.clip(s,o)),y=new Xr(m.xy,g,1);return{color:c,opacity:l,halfWidth:p,normal:n,scaledOffset:_,scaledHalfWidth:u,glPosition:new Xr(y.xy,g,1)}}function oh(t,e){const{opacity:s,color:i}=t,r=function(t,e){const{halfWidth:s,normal:i}=t,r=rh(s),n=Un(i).multiply(s);return Dn(r.multiply(s.subtract(n)).divide(e.add(r).subtract(new Vr(1))),new Vr(0),new Vr(1))}(t,e);return s.multiply(i).multiply(r)}(0,T._)([ha(Vr)],ih.prototype,"antialiasing",void 0),(0,T._)([ha(Vr)],ih.prototype,"blur",void 0);class ah extends Ra{constructor(){super(...arguments),this.computeAttributes={pos:["nextPos1","nextPos2"]}}vertex(t,e){const s=nh(this,t);return{...s,...this.maybeRunHittest(t,e,s.halfWidth)}}fragment(t){const e=oh(t,this.antialiasingControls.blur);return this.getFragmentOutput(e,t)}hittest(t,e,s){const{viewMat3:i,tileMat3:r}=this.view,n=i.multiply(r),o=n.multiply(new Wr(t.pos,1)),a=n.multiply(new Wr(e.nextPos1,1)),h=n.multiply(new Wr(e.nextPos2,1)),{distance:c,smallSymbolDistance:l,smallSymbolSizeThreshold:u}=this.hittestRequest,d=jn(s,u.multiply(.5)).multiply(c.subtract(l)),p=this.hittestRequest.position;return Vn(Oa(p,o.xy,a.xy),Oa(p,o.xy,h.xy)).subtract(s).add(d)}}(0,T._)([ha(ih)],ah.prototype,"antialiasingControls",void 0),(0,T._)([ca(La)],ah.prototype,"visualVariableColor",void 0),(0,T._)([ca(Ba)],ah.prototype,"visualVariableOpacity",void 0),(0,T._)([ca(Za)],ah.prototype,"visualVariableSizeMinMaxValue",void 0),(0,T._)([ca(Qa)],ah.prototype,"visualVariableSizeScaleStops",void 0),(0,T._)([ca(Ja)],ah.prototype,"visualVariableSizeStops",void 0),(0,T._)([ca(th)],ah.prototype,"visualVariableSizeUnitValue",void 0),(0,T._)([(0,T.a)(0,aa(eh)),(0,T.a)(1,aa(Fa))],ah.prototype,"vertex",null),(0,T._)([(0,T.a)(0,aa(sh))],ah.prototype,"fragment",null);class hh extends ka{}(0,T._)([oa(3,qr)],hh.prototype,"offset",void 0),(0,T._)([oa(4,Xr)],hh.prototype,"color",void 0),(0,T._)([oa(5,qr)],hh.prototype,"normal",void 0),(0,T._)([oa(6,Vr)],hh.prototype,"halfWidth",void 0),(0,T._)([oa(7,Vr)],hh.prototype,"referenceHalfWidth",void 0),(0,T._)([oa(8,qr)],hh.prototype,"zoomRange",void 0);class ch extends sh{}function lh(t,e,s){const{id:i,bitset:r}=e,n=Ia(r,0),o=kn(n,new Vr(.5)),a=nh(t,e),h=vn(o,a.halfWidth,new Vr(0)),c=Va(t,i),l=Ga(t,i,e.color),u=vn(o,e.color,l.multiply(c)),d=t.view.displayViewScreenMat3.multiply(new Wr(e.pos.xy,1)),p=t.clip(e.id),_=new Xr(d.xy,p,1),f=vn(o,a.glPosition,_),m=s&&t.maybeRunHittest(e,s,o);return{isOutline:n,color:u,opacity:new Vr(1),halfWidth:h,normal:a.normal,glPosition:f,...m}}class uh extends Ra{constructor(){super(...arguments),this.computeAttributes={pos:["nextPos1","nextPos2"]}}}(0,T._)([ha(ih)],uh.prototype,"antialiasingControls",void 0),(0,T._)([ca(La)],uh.prototype,"visualVariableColor",void 0),(0,T._)([ca(Ba)],uh.prototype,"visualVariableOpacity",void 0),(0,T._)([ca(Za)],uh.prototype,"visualVariableSizeMinMaxValue",void 0),(0,T._)([ca(Qa)],uh.prototype,"visualVariableSizeScaleStops",void 0),(0,T._)([ca(Ja)],uh.prototype,"visualVariableSizeStops",void 0),(0,T._)([ca(th)],uh.prototype,"visualVariableSizeUnitValue",void 0);class dh extends uh{vertex(t,e){return lh(this,t,e)}fragment(t){const{color:e,isOutline:s}=t,i=kn(s,new Vr(.5)),r=vn(i,oh(t,this.antialiasingControls.blur),e),n=vn(i,new Vr(1/255),new Vr(0));return this.getFragmentOutput(r,t,n)}hittest(t,e,s){return vn(s,Da(this.hittestRequest),za(this,t,e))}}(0,T._)([(0,T.a)(0,aa(hh)),(0,T.a)(1,aa(Fa))],dh.prototype,"vertex",null),(0,T._)([(0,T.a)(0,aa(ch))],dh.prototype,"fragment",null);class ph extends qa{}function _h(t,e){const s=e.tlbr.xy,i=e.tlbr.zw,r=i.x.subtract(s.x),n=s.y.subtract(i.y),o=new qr(r,n).multiply(e.inverseRasterizationScale),a=o.multiply(t.view.requiredZoomFactor),h=function(t){const e=new Vr(1),s=new Vr(0);return new an(e.divide(t.x),s.divide(t.y),0,bn(s.divide(t.x)),e.divide(t.y),0,0,0,1)}(a),c=t.localTileOffset.getPatternOffsetAtTileOrigin(o).divide(a),l=new Wr(e.pos,1);return{tileTextureCoord:h.multiply(l).xy.subtract(c),tlbr:e.tlbr.divide(t.mosaicInfo.size.xyxy)}}function fh(t,e){const s=Wn(t.tileTextureCoord,new Vr(1)),i=qn(t.tlbr.xy,t.tlbr.zw,s),r=Hn(e.texture,i);return t.color.multiply(r)}(0,T._)([oa(5,Xr)],ph.prototype,"tlbr",void 0),(0,T._)([oa(6,Vr)],ph.prototype,"inverseRasterizationScale",void 0);class mh extends Wa{vertex(t,e){return{...super.vertex(t,e),..._h(this,t)}}fragment(t){const e=fh(t,this.mosaicInfo);return this.getFragmentOutput(e,t,new Vr(0))}}(0,T._)([ha(Ya)],mh.prototype,"mosaicInfo",void 0),(0,T._)([ha(Xa)],mh.prototype,"localTileOffset",void 0),(0,T._)([(0,T.a)(0,aa(ph)),(0,T.a)(1,aa(Fa))],mh.prototype,"vertex",null),(0,T._)([(0,T.a)(0,aa(class extends Aa{}))],mh.prototype,"fragment",null);class gh extends hh{}(0,T._)([oa(9,Xr)],gh.prototype,"tlbr",void 0),(0,T._)([oa(10,Vr)],gh.prototype,"inverseRasterizationScale",void 0);class yh extends ch{}class xh extends dh{vertex(t,e){return{...lh(this,t,e),..._h(this,t)}}fragment(t){const{isOutline:e}=t,s=kn(e,new Vr(.5)),i=vn(s,oh(t,this.antialiasingControls.blur),fh(t,this.mosaicInfo)),r=vn(s,new Vr(1/255),new Vr(0));return this.getFragmentOutput(i,t,r)}}(0,T._)([ha(Ya)],xh.prototype,"mosaicInfo",void 0),(0,T._)([ha(Xa)],xh.prototype,"localTileOffset",void 0),(0,T._)([(0,T.a)(0,aa(gh)),(0,T.a)(1,aa(Fa))],xh.prototype,"vertex",null),(0,T._)([(0,T.a)(0,aa(yh))],xh.prototype,"fragment",null);const bh=16,wh=.0625;class vh extends ka{}(0,T._)([oa(3,Xr)],vh.prototype,"color",void 0),(0,T._)([oa(4,Xr)],vh.prototype,"tlbr",void 0),(0,T._)([oa(5,Vr)],vh.prototype,"angle",void 0),(0,T._)([oa(6,Vr)],vh.prototype,"aux1",void 0),(0,T._)([oa(7,Vr)],vh.prototype,"aux2",void 0),(0,T._)([oa(8,qr)],vh.prototype,"aux3",void 0),(0,T._)([oa(9,qr)],vh.prototype,"aux4",void 0),(0,T._)([oa(10,qr)],vh.prototype,"zoomRange",void 0);class Sh extends uh{vertex(t,e){const{aux1:s,aux2:i,aux3:r,aux4:n}=t,o={...t,width:s,height:i,offset:r,scale:n.multiply(wh)},a=lh(this,{...t,halfWidth:s.multiply(wh),referenceHalfWidth:i.multiply(wh),offset:r.multiply(wh),normal:n.subtract(128).multiply(wh)}),h=Ha(this,o),c=kn(a.isOutline,new Vr(.5));return{...a,...h,...this.maybeRunHittest(t,e,c)}}fragment(t){const{isOutline:e}=t,s=kn(e,new Vr(.5)),i=vn(s,oh(t,this.antialiasingControls.blur),$a(this,t)),r=vn(s,new Vr(1/255),new Vr(0));return this.getFragmentOutput(i,t,r)}hittest(t,e,s){return vn(s,Da(this.hittestRequest),za(this,t,e))}}(0,T._)([ha(Ya)],Sh.prototype,"mosaicInfo",void 0),(0,T._)([ha(Xa)],Sh.prototype,"localTileOffset",void 0),(0,T._)([(0,T.a)(0,aa(vh)),(0,T.a)(1,aa(Fa))],Sh.prototype,"vertex",null),(0,T._)([(0,T.a)(0,aa(class extends yh{}))],Sh.prototype,"fragment",null);const Ih=Xi.attributes,Th=Qi.attributes,Ph={createComputedParams:t=>t,attributes:{id:Ih.id,pos:Ih.pos,zoomRange:Ih.zoomRange,tlbr:Ih.tlbr,angle:Ih.angle,color:Ih.color,bitset:{type:pi.Ck.UNSIGNED_BYTE,count:1,pack:t=>Vi(t)},aux1:{count:1,type:pi.Ck.UNSIGNED_SHORT,pack:t=>qi(t)},aux2:{count:1,type:pi.Ck.UNSIGNED_SHORT,pack:t=>Wi(t)},aux3:{count:2,type:pi.Ck.SHORT,pack:({offsetX:t,offsetY:e})=>[(0,l.im)(t),(0,l.im)(e)]},aux4:{count:2,type:pi.Ck.UNSIGNED_BYTE,pack:({scaleX:t,scaleY:e})=>[t*bh,e*bh]}}},Mh={createComputedParams:t=>t,attributes:{id:Ih.id,pos:Ih.pos,zoomRange:Ih.zoomRange,tlbr:Ih.tlbr,angle:Ih.angle,color:Th.color,bitset:{type:pi.Ck.UNSIGNED_BYTE,count:1,pack:t=>Ii([[0,!0]])},aux1:{count:1,type:pi.Ck.UNSIGNED_SHORT,pack:t=>(0,l.im)(.5*t.width)*bh},aux2:{count:1,type:pi.Ck.UNSIGNED_SHORT,pack:t=>(0,l.im)(.5*t.referenceWidth)*bh},aux3:{count:2,type:pi.Ck.SHORT,packTessellation:({extrusionOffsetX:t,extrusionOffsetY:e})=>[t*bh,e*bh]},aux4:{count:2,type:pi.Ck.UNSIGNED_BYTE,packTessellation:({normalX:t,normalY:e})=>[t*bh+128,e*bh+128]}}};class Eh extends Ji{constructor(){super(...arguments),this.vertexSpec=Mh}}const Ch={createComputedParams:t=>t,attributes:{...Fi.attributes,...Zi.attributes}},kh={createComputedParams:t=>t,attributes:{...Fi.attributes,...Qi.attributes}};class Fh extends Ji{constructor(){super(...arguments),this.vertexSpec=kh}}const Ah={createComputedParams:t=>t,attributes:{pos:{type:pi.Ck.SHORT,count:2,pack:"position",packPrecisionFactor:10},id:{type:pi.Ck.UNSIGNED_BYTE,count:3,pack:"id"},bitset:{type:pi.Ck.UNSIGNED_BYTE,count:1},offset:{type:pi.Ck.BYTE,count:2,packAlternating:{count:4,pack:()=>[[-1,-1],[1,-1],[-1,1],[1,1]]}}}};var Rh=s(86916);const Oh=8388607,Nh=t=>t&Oh;class Dh{constructor(t,e,s,i,r,n,o,a,h=[]){this.entityTexel=t,this.anchorX=e,this.anchorY=s,this.directionX=i,this.directionY=r,this.maxScale=n,this.minScale=o,this.referenceBounds=a,this.bounds=h}serialize(t){t.push(this.entityTexel),t.writeF32(this.anchorX),t.writeF32(this.anchorY),t.writeF32(this.directionX),t.writeF32(this.directionY),t.writeF32(this.maxScale),t.writeF32(this.minScale),null===this.referenceBounds?(t.writeF32(0),t.writeF32(0),t.writeF32(0)):(t.writeF32(this.referenceBounds.size),t.writeF32(this.referenceBounds.offsetX),t.writeF32(this.referenceBounds.offsetY)),W(t,this.bounds)}static deserialize(t){const e=t.readInt32(),s=t.readF32(),i=t.readF32(),r=t.readF32(),n=t.readF32(),o=t.readF32(),a=t.readF32(),h=t.readF32(),c=t.readF32(),l=t.readF32(),u=X(t,Zs)??[];return new Dh(e,s,i,r,n,o,a,{size:h,offsetX:c,offsetY:l},u)}}const zh=1024;function Lh(t,e,s){return t[0]=e[0]-s[0],t[1]=e[1]-s[1],t}function Bh(t,e){return Math.sqrt(t*t+e*e)}function Uh(t){const e=Bh(t[0],t[1]);t[0]/=e,t[1]/=e}function Gh(t,e){return Bh(t[0]-e[0],t[1]-e[1])}function Vh(t){return t.length-1}function qh(t,e,s=1){let[i,r]=function(t,e){return t[e+1]}(t,e);return[i,r]=[Math.round(i),Math.round(r)],Math.sqrt(i*i+r*r)*s}class Wh{constructor(t,e,s,i,r){this._segments=t,this._index=e,this._distance=s,this._xStart=i,this._yStart=r,this._done=!1}static create(t){return new Wh(t,0,0,t[0][0],t[0][1])}clone(){return new Wh(this._segments,this._index,this._distance,this.xStart,this.yStart)}equals(t){return this._index===t._index||t._index===this._index-1&&(0===this._distance||1===t._distance)||t._index===this._index+1&&(1===this._distance||0===t._distance)}leq(t){return this._index<t._index||this._index===t._index&&this._distance<=t._distance}geq(t){return this._index>t._index||this._index===t._index&&this._distance>=t._distance}get _segment(){return this._segments[this._index+1]}get angle(){const t=this.dy,e=(0*t+-1*-this.dx)/(1*this.length);let s=Math.acos(e);return t>0&&(s=2*Math.PI-s),s}get xStart(){return this._xStart}get yStart(){return this._yStart}get x(){return this.xStart+this.distance*this.dx}get y(){return this.yStart+this.distance*this.dy}get dx(){return this._segment[0]}get dy(){return this._segment[1]}get xMidpoint(){return this.xStart+.5*this.dx}get yMidpoint(){return this.yStart+.5*this.dy}get xEnd(){return this.xStart+this.dx}get yEnd(){return this.yStart+this.dy}get length(){const{dx:t,dy:e}=this;return Math.sqrt(t*t+e*e)}get remainingLength(){return this.length*(1-this._distance)}get backwardLength(){return this.length*this._distance}get distance(){return this._distance}get done(){return this._done}hasPrev(){return this._index-1>=0}hasNext(){return this._index+1<Vh(this._segments)}next(){return this.hasNext()?(this._xStart+=this.dx,this._yStart+=this.dy,this._distance=0,this._index+=1,this):null}prev(){return this.hasPrev()?(this._index-=1,this._xStart-=this.dx,this._yStart-=this.dy,this._distance=1,this):(this._done=!0,null)}_seekBackwards(t,e){const s=this.backwardLength;if(t<=s)return this._distance=(s-t)/this.length,this;let i=this.backwardLength;for(;this.prev();){if(i+this.length>t)return this._seekBackwards(t-i);i+=this.length}return this._distance=0,e?this:null}seek(t,e=!1){if(t<0)return this._seekBackwards(Math.abs(t),e);if(t<=this.remainingLength)return this._distance=(this.backwardLength+t)/this.length,this;let s=this.remainingLength;for(;this.next();){if(s+this.length>t)return this.seek(t-s,e);s+=this.length}return this._distance=1,e?this:null}}function Xh(t,e,s,i=!0){const r=function(t){let e=0;for(let s=0;s<Vh(t);s++)e+=qh(t,s);return e}(t),n=Wh.create(t),o=r/2;if(!i)return n.seek(o),void(Math.abs(n.x)<zh&&Math.abs(n.y)<zh&&s(n.clone(),0,o+0*e,r));const a=Math.max((r-e)/2,0),h=Math.floor(a/e),c=o-h*e;n.seek(c);for(let t=-h;t<=h;t++)Math.abs(n.x)<zh&&Math.abs(n.y)<zh&&s(n.clone(),t,o+t*e,r),n.seek(e)}function Yh(t,e){const s=1e-6;if(e<=0)return;const i=t.length;if(i<3)return;const r=[];let n=0;r.push(0);for(let e=1;e<i;e++)n+=Gh(t[e],t[e-1]),r.push(n);e=Math.min(e,.2*n);const o=[];o.push(t[0][0]),o.push(t[0][1]);const a=t[i-1][0],h=t[i-1][1],c=Lh([0,0],t[0],t[1]);Uh(c),t[0][0]+=e*c[0],t[0][1]+=e*c[1],Lh(c,t[i-1],t[i-2]),Uh(c),t[i-1][0]+=e*c[0],t[i-1][1]+=e*c[1];for(let t=1;t<i;t++)r[t]+=e;r[i-1]+=e;const l=.5*e;for(let n=1;n<i-1;n++){let a=0,h=0,c=0;for(let i=n-1;i>=0&&!(r[i+1]<r[n]-l);i--){const o=l+r[i+1]-r[n],u=r[i+1]-r[i],d=r[n]-r[i]<l?1:o/u;if(Math.abs(d)<s)break;const p=d*d,_=d*o-.5*p*u,f=d*u/e,m=t[i+1],g=t[i][0]-m[0],y=t[i][1]-m[1];a+=f/_*(m[0]*d*o+.5*p*(o*g-u*m[0])-p*d*u*g/3),h+=f/_*(m[1]*d*o+.5*p*(o*y-u*m[1])-p*d*u*y/3),c+=f}for(let o=n+1;o<i&&!(r[o-1]>r[n]+l);o++){const i=l-r[o-1]+r[n],u=r[o]-r[o-1],d=r[o]-r[n]<l?1:i/u;if(Math.abs(d)<s)break;const p=d*d,_=d*i-.5*p*u,f=d*u/e,m=t[o-1],g=t[o][0]-m[0],y=t[o][1]-m[1];a+=f/_*(m[0]*d*i+.5*p*(i*g-u*m[0])-p*d*u*g/3),h+=f/_*(m[1]*d*i+.5*p*(i*y-u*m[1])-p*d*u*y/3),c+=f}o.push(a/c),o.push(h/c)}o.push(a),o.push(h);for(let e=0,s=0;e<i;e++)t[e][0]=o[s++],t[e][1]=o[s++]}var jh=s(53648);class Hh{static getPlacement(t,e,s,i,r,n){const o=function(t){if(!t)return null;switch(t.type){case"CIMMarkerPlacementAlongLineSameSize":return He.local();case"CIMMarkerPlacementAtExtremities":return Ke.local();case"CIMMarkerPlacementAtRatioPositions":return Qe.local();case"CIMMarkerPlacementInsidePolygon":return is.local();case"CIMMarkerPlacementOnLine":return os.local();case"CIMMarkerPlacementOnVertices":return hs.local();case"CIMMarkerPlacementPolygonCenter":return Es.local()}return null}(s);return o?(-1===e&&t.invertY(),o.execute(t,s,i,r,n)):null}}class $h{constructor(t){const{offsetX:e,offsetY:s,postAngle:i,fontSize:r,scaleFactor:n,transforms:o}=t;if(this.offsetX=e,this.offsetY=s,this.postAngle=i,this.fontSize=Math.min(r,96),this.transforms=o,o&&o.infos.length>1){const t=(0,Me.ol)(r,i,!1,e,s,o);this.fontSize=Math.min(t.size,96),this.postAngle=t.rotation,this.offsetX=t.offsetX,this.offsetY=t.offsetY}n&&(this.fontSize*=n,this.offsetX*=n,this.offsetY*=n)}}const Kh=[4,4],Zh=[16,4],Qh={topLeft:Zh,topRight:Zh,bottomLeft:Zh,bottomRight:Zh},Jh=[4,2],tc=[4,6],ec={topLeft:Jh,topRight:Jh,bottomLeft:tc,bottomRight:tc},sc={topLeft:Jh,topRight:tc,bottomLeft:Jh,bottomRight:tc},ic={topLeft:tc,topRight:tc,bottomLeft:Kh,bottomRight:Kh},rc={topLeft:Kh,topRight:Kh,bottomLeft:tc,bottomRight:tc},nc={topLeft:tc,topRight:Kh,bottomLeft:tc,bottomRight:Kh},oc={topLeft:Kh,topRight:tc,bottomLeft:Kh,bottomRight:tc},ac={createComputedParams:t=>t,attributes:{pos:{type:pi.Ck.SHORT,count:2,pack:"position",packPrecisionFactor:10},id:{type:pi.Ck.UNSIGNED_BYTE,count:3,pack:"id"},bitset:{type:pi.Ck.UNSIGNED_BYTE,count:1,packTessellation:({isBackground:t,mapAligned:e})=>Ii([[0,t],[3,!!e]])},zoomRange:{type:pi.Ck.UNSIGNED_SHORT,count:2,packPrecisionFactor:B.M6,packTessellation:({minZoom:t,maxZoom:e})=>[t||0,e||28]},offset:{type:pi.Ck.SHORT,count:2,packPrecisionFactor:8,packAlternating:{count:4,packTessellation:({offsets:t})=>{const{bottomLeft:e,bottomRight:s,topLeft:i,topRight:r}=t;return[i,r,e,s]}}},textureUV:{type:pi.Ck.SHORT,count:2,packPrecisionFactor:4,packAlternating:{count:4,packTessellation:({texcoords:t})=>{const{bottomLeft:e,bottomRight:s,topLeft:i,topRight:r}=t;return[i,r,e,s]}}},color:{type:pi.Ck.UNSIGNED_BYTE,count:4,normalized:!0,packTessellation:({color:t})=>t},fontSize:{type:pi.Ck.UNSIGNED_SHORT,count:1,packPrecisionFactor:4,packTessellation:({fontSize:t})=>(0,l.im)(t)},referenceSize:{type:pi.Ck.UNSIGNED_BYTE,count:1,packPrecisionFactor:4,packTessellation:({fontSize:t},{referenceSize:e})=>(0,l.im)(e??t)},haloColor:{type:pi.Ck.UNSIGNED_BYTE,count:4,normalized:!0,pack:({haloColor:t})=>Ti(t)},haloFontSize:{type:pi.Ck.UNSIGNED_SHORT,count:1,packPrecisionFactor:4,pack:({haloFontSize:t})=>(0,l.im)(t)},clipAngle:{type:pi.Ck.UNSIGNED_BYTE,count:1,packTessellation:({clipAngle:t})=>cc(t||0)},referenceSymbol:{type:pi.Ck.BYTE,count:4,packPrecisionFactor:1,packTessellation:(t,e)=>{if(!t.referenceBounds)return[0,0,0,0];const s=function(t){switch(t){case Xs.Right:case"right":return-1;case Xs.Center:case"center":return 0;case Xs.Left:case"left":return 1;default:return console.debug(`Found invalid horizontal alignment ${t}`),0}}(e.horizontalAlignment),i=function(t){switch(t){case Ys.Top:case"top":return 1;case Ys.Center:case"middle":return 0;case Ys.Bottom:case Ys.Baseline:case"baseline":case"bottom":return-1;default:return console.debug(`Found invalid vertical alignment ${t}`),0}}(e.verticalAlignment),{offsetX:r,offsetY:n,size:o}=t.referenceBounds;return[(0,l.im)(r),-(0,l.im)(n),(0,l.im)(o),s+1<<2|i+1]}}}};class hc extends gi{constructor(){super(...arguments),this.vertexSpec=ac,this._textMeshParamsPropsInitialized=!1}ensurePacked(t,e,s){super.ensurePacked(t,e,s),this._textMeshParamsPropsInitialized&&!this._evaluator.hasDynamicProperties||(this._textMeshTransformProps=new $h(this.evaluatedMeshParams),this._textMeshParamsPropsInitialized=!0)}_write(t,e,s){const i=this._getShaping();if(!i)return;const r=e.getDisplayId();if(null!=this.evaluatedMeshParams.placement)return this._writePlacedTextMarkers(t,e,i,s);if(s&&s.nextPath())return s.nextPoint(),this._writeGlyphs(t,r,s.x,s.y,i,0);if("esriGeometryPolygon"===e.geometryType){const s=e.readCentroidForDisplay();if(!s)return;const[n,o]=s.coords;return this._writeGlyphs(t,r,n,o,i,0)}if("esriGeometryMultipoint"===e.geometryType){const s=e.readGeometryForDisplay();return void s?.forEachVertex(((e,s)=>this._writeGlyphs(t,r,e,s,i,0)))}const n=e.readXForDisplay(),o=e.readYForDisplay();return this._writeGlyphs(t,r,n,o,i,0)}_writePlacedTextMarkers(t,e,s,i){const r=i??jt.fromFeatureSetReaderCIM(e);if(!r)return;const n=Hh.getPlacement(r,-1,this.evaluatedMeshParams.placement,(0,l.im)(1),t.id,ui());if(!n)return;const o=e.getDisplayId();let a=n.next();for(;null!=a;){const e=a.tx,i=-a.ty,r=-a.getAngle();this._writeGlyphs(t,o,e,i,s,r),a=n.next()}}_getShaping(){const t=this._textMeshTransformProps,e=this.evaluatedMeshParams;if(!e.glyphs?.glyphs.length)return null;const s=Math.round((0,l.im)(t.fontSize)),i=(0,l.im)(t.offsetX),r=(0,l.im)(t.offsetY),n=(0,jh.qk)((0,l.im)(e.lineWidth),32,512),o=B.Cq*(0,jh.qk)(e.lineHeightRatio,.25,4);return function(t,e){const s=e.scale,i=new Array,{glyphs:r,isRightToLeft:n}=t,o=function(t,e,s){const i=new Array,r=1/s.scale,n=s.maxLineWidth*r,o=e?t.length-1:0,a=e?-1:t.length,h=e?-1:1;let c=o,l=0,u=0,d=c,p=d,_=0,f=1/0,m=0;for(;c!==a;){const{code:e,metrics:s}=t[c],r=Math.abs(s.top);if(ri(e)||ni(e)||(f=Math.min(f,r),m=Math.max(m,r+s.height)),ri(e))c!==o&&(i.push(new ii(t,d,c-h,l,f,m)),f=1/0,m=0),l=0,d=c+h,p=c+h,u=0;else if(ni(e))p=c+h,u=0,_=s.advance,l+=s.advance;else if(l>n){if(p!==d){const e=p-2*h;l-=_,i.push(new ii(t,d,e,l-u,f,m)),f=1/0,m=0,d=p,l=u}else i.push(new ii(t,d,c-h,l,f,m)),f=1/0,m=0,d=c,p=c,l=0;l+=s.advance,u+=s.advance}else l+=s.advance,u+=s.advance;c+=h}const g=new ii(t,d,c-h,l,f,m);return g.start>=0&&g.end<t.length&&i.push(g),i}(r,n,e),a=function(t,e){let s=0;for(let e=0;e<t.length;e++){const{width:i}=t[e];s=Math.max(i,s)}const i="underline"===e.decoration?4:0,r=t[0].yMin;return{x:0,y:r,height:t[t.length-1].yMax+e.lineHeight*(t.length-1)+i-r,width:s}}(o,e),h=Hs(e.horizontalAlignment),c=$s(e.verticalAlignment),l=c===Ys.Baseline?1:0,u=l?0:c-1,d=(1-l)*-a.y+u*(a.height/2)+-22*(l?1:0);for(let t=0;t<o.length;t++){const{start:n,end:a,width:c}=o[t];let l=-1*(h+1)*(c/2)-3;const u=t*e.lineHeight+d-3;o[t].startX=l,o[t].startY=u;for(let t=n;t<=a;t++){const e=r[t];if(ri(e.code))continue;const n=new Js(l+e.metrics.left,u-e.metrics.top,e,s);l+=e.metrics.advance,i.push(n)}}return new si(i,o,e)}(e.glyphs,{scale:s/B.iK,angle:t.postAngle,xOffset:i,yOffset:r,horizontalAlignment:e.horizontalAlignment,verticalAlignment:e.verticalAlignment,maxLineWidth:n,lineHeight:o,decoration:e.decoration,borderLineSizePx:(0,l.im)(e.boxBorderLineSize),hasBackground:!!e.boxBackgroundColor,useCIMAngleBehavior:e.useCIMAngleBehavior})}_writeGlyphs(t,e,s,i,r,n,o){const a=this.evaluatedMeshParams,h=this._textMeshTransformProps,c=h.fontSize,u=(0,l.im)(h.offsetX),d=(0,l.im)(h.offsetY);0!==n&&r.setRotation(n);const p=r.bounds,_=s+p.x+u,f=i+p.y-d,m=2*(a.minPixelBuffer?a.minPixelBuffer/c:1),g=Math.max(p.width,p.height)*m;r.textBox&&(t.recordStart(this.instanceId,this.attributeLayout,r.glyphs[0].textureBinding),t.recordBounds(_,f,g,g),this._writeTextBox(t,e,s,i,r.textBox,o),t.recordEnd());for(const n of r.glyphs){t.recordStart(this.instanceId,this.attributeLayout,n.textureBinding),t.recordBounds(_,f,g,g);const{texcoords:r,offsets:h}=n;this._writeQuad(t,e,s,i,{texcoords:r,offsets:h,fontSize:c,color:Ti(a.color),isBackground:!1,referenceBounds:o}),t.recordEnd()}0!==n&&r.setRotation(-n)}_writeTextBox(t,e,s,i,r,n,o){const a=this.evaluatedMeshParams,{fontSize:h}=this._textMeshTransformProps,{boxBackgroundColor:c,boxBorderLineColor:l}=a,u={isBackground:!0,fontSize:h,referenceBounds:n,...o};c&&(this._writeQuad(t,e,s,i,{texcoords:Qh,offsets:r.main,color:Ti(c),...u}),l||(this._writeQuad(t,e,s,i,{texcoords:ic,offsets:r.top,color:Ti(c),...u}),this._writeQuad(t,e,s,i,{texcoords:rc,offsets:r.bot,color:Ti(c),...u}),this._writeQuad(t,e,s,i,{texcoords:nc,offsets:r.left,color:Ti(c),...u}),this._writeQuad(t,e,s,i,{texcoords:oc,offsets:r.right,color:Ti(c),...u}))),l&&(this._writeQuad(t,e,s,i,{texcoords:ec,offsets:r.top,color:Ti(l),...u}),this._writeQuad(t,e,s,i,{texcoords:ec,offsets:r.bot,color:Ti(l),...u}),this._writeQuad(t,e,s,i,{texcoords:sc,offsets:r.left,color:Ti(l),...u}),this._writeQuad(t,e,s,i,{texcoords:sc,offsets:r.right,color:Ti(l),...u}))}_writeQuad(t,e,s,i,r){const n=t.vertexCount();this._writeVertex(t,e,s,i,r),t.indexWrite(n+0),t.indexWrite(n+1),t.indexWrite(n+2),t.indexWrite(n+1),t.indexWrite(n+3),t.indexWrite(n+2)}}const cc=t=>Math.round(t*(254/360)),lc=(0,Rh.sB)((t=>{let e=0;if(0===t)return 1/0;for(;!(t%2);)e++,t/=2;return e})),uc={createComputedParams:t=>t,attributes:{...Hi.attributes,bitset:{type:pi.Ck.UNSIGNED_BYTE,count:1,pack:({shouldSampleAlphaOnly:t,shouldScaleDash:e,isSDF:s})=>Ii([[4,t],[2,e],[3,s]])},tlbr:{type:pi.Ck.UNSIGNED_SHORT,count:4,pack:({sprite:t})=>{const{rect:e,width:s,height:i}=t,r=e.x+B.mc,n=e.y+B.mc;return[r,n,r+s,n+i]}},accumulatedDistance:{type:pi.Ck.UNSIGNED_SHORT,count:1,packTessellation:({distance:t})=>t},segmentDirection:{type:pi.Ck.BYTE,count:2,packPrecisionFactor:16,packTessellation:({directionX:t,directionY:e})=>[t,e]}}};class dc{static from(t){return"width"in t?this.fromSimpleMeshParams(t):this.fromComplexMeshParams(t)}static fromSimpleMeshParams(t){const e=new dc(t.sprite,t.color,t.outlineColor,t.minPixelBuffer,t.placement,t.scaleInfo,t.effects),{type:s,width:i,height:r,angle:n,outlineSize:o,referenceSize:a,sprite:h,overrideOutlineColor:c}=t;return e.rawWidth=(0,l.im)(i),e.rawHeight=(0,l.im)(r),e.angle=n,e.outlineSize=(0,l.im)(o),e.referenceSize=(0,l.im)(a),e.overrideOutlineColor=c,e.offsetX=(0,l.im)(t.offsetX),e.offsetY=(0,l.im)(t.offsetY),"simple"!==s||h.sdf||(e.rawWidth=h.width,e.rawHeight=h.height),e.sizeRatio=h.sdf?2:1,e._computeSize(t,!1),e}static fromComplexMeshParams(t){const e=new dc(t.sprite,t.color,t.outlineColor,t.minPixelBuffer,t.placement,t.scaleInfo,t.effects);let{alignment:s,transforms:i,size:r,scaleX:n,anchorX:o,anchorY:a,angle:h,colorLocked:c,frameHeight:u,widthRatio:d,offsetX:p,offsetY:_,outlineSize:f,referenceSize:m,scaleFactor:g,sizeRatio:y,isAbsoluteAnchorPoint:x,rotateClockwise:b,scaleSymbolsProportionally:w,sprite:v}=t;if(i&&i.infos.length>0){const t=(0,Me.ol)(r,h,b,p,_,i);r=t.size,h=t.rotation,p=t.offsetX,_=t.offsetY,b=!1}g&&(r*=g,p*=g,_*=g);const S=n*(v.width/v.height);e.alignment=s,e.rawHeight=(0,l.im)(r),e.rawWidth=e.rawHeight*S,e.referenceSize=(0,l.im)(m),e.sizeRatio=y,e.angle=h,e.rotateClockwise=b,e.anchorX=o,e.anchorY=a,e.offsetX=(0,l.im)(p),e.offsetY=(0,l.im)(_),x&&r&&(v.sdf?e.anchorX=o/(r*d):e.anchorX=o/(r*S),e.anchorY=a/r);const I=w&&u?r/u:1;return e.outlineSize=0===f||isNaN(f)?0:(0,l.im)(f)*I,e.scaleSymbolsProportionally=w,e.colorLocked=c,e._computeSize(t,!0),e}constructor(t,e,s,i,r,n,o){this.sprite=t,this.color=e,this.outlineColor=s,this.minPixelBuffer=i,this.placement=r,this.scaleInfo=n,this.effects=o,this.rawWidth=0,this.rawHeight=0,this.angle=0,this.outlineSize=0,this.referenceSize=0,this.sizeRatio=1,this.alignment=ce.yu.SCREEN,this.scaleSymbolsProportionally=!1,this.overrideOutlineColor=!1,this.colorLocked=!1,this.anchorX=0,this.anchorY=0,this.computedWidth=0,this.computedHeight=0,this.texXmin=0,this.texYmin=0,this.texXmax=0,this.texYmax=0,this.offsetX=0,this.offsetY=0,this.rotateClockwise=!0}get boundsInfo(){return{size:Math.max(this.computedHeight,this.computedWidth),offsetX:this.offsetX,offsetY:this.offsetY}}_computeSize(t,e){const{sprite:s,hasSizeVV:i}=t,r=!!s.sdf,{rawWidth:n,rawHeight:o,sizeRatio:a,outlineSize:h}=this,c=n*a,l=o*a;if(r&&!i){const t=e&&n>o?c:n,s=o,i=h+2;this.computedWidth=Math.min(t+i,c),this.computedHeight=Math.min(s+i,l)}else this.computedWidth=c,this.computedHeight=l;const u=r?B.y/Math.max(c,l):1,d=.5*(c-this.computedWidth)*u,p=.5*(l-this.computedHeight)*u,_=s.rect.x+B.mc+d,f=s.rect.y+B.mc+p,m=_+s.width-2*d,g=f+s.height-2*p;this.texXmin=Math.floor(_),this.texYmin=Math.floor(f),this.texXmax=Math.ceil(m),this.texYmax=Math.ceil(g),this.computedWidth*=(this.texXmax-this.texXmin)/(m-_),this.computedHeight*=(this.texYmax-this.texYmin)/(g-f),this.anchorX*=c/this.computedWidth,this.anchorY*=l/this.computedHeight}}const pc=0,_c=1,fc=2,mc=3,gc=4,yc=3.14159265359/180,xc=128/Math.PI;const bc={createComputedParams:t=>dc.from(t),attributes:{pos:{type:pi.Ck.SHORT,count:2,pack:"position",packPrecisionFactor:10},id:{type:pi.Ck.UNSIGNED_BYTE,count:3,pack:"id"},bitset:{type:pi.Ck.UNSIGNED_BYTE,count:1,pack:({sprite:t,alignment:e,scaleSymbolsProportionally:s,overrideOutlineColor:i,colorLocked:r})=>{let n=0;return t.sdf&&(n|=Si(pc)),e===ce.yu.MAP&&(n|=Si(_c)),s&&(n|=Si(fc)),i&&(n|=Si(mc)),r&&(n|=Si(gc)),n}},zoomRange:{type:pi.Ck.SHORT,count:2,packPrecisionFactor:B.M6,pack:({scaleInfo:t},{tileInfo:e})=>vi(t,e)},offset:{type:pi.Ck.SHORT,count:2,packPrecisionFactor:4,packAlternating:{count:4,pack:({angle:t,computedWidth:e,computedHeight:s,anchorX:i,anchorY:r,offsetX:n,offsetY:o,rotateClockwise:a})=>{const h=function(t,e,s,i,r=!1){const n=Us(),o=r?1:-1;return t?Ds(n,o*yc*t):As(n),(e||s)&&Ns(n,n,[e,-s]),i&&Os(n,n,o*yc*-i),n}(0,n,o,-t,a),c=-(.5+i)*e,l=-(.5-r)*s,u=[c,l],d=[c+e,l],p=[c,l+s],_=[c+e,l+s];return(0,F.m4)(u,u,h),(0,F.m4)(d,d,h),(0,F.m4)(p,p,h),(0,F.m4)(_,_,h),[u,d,p,_]}}},textureUV:{type:pi.Ck.SHORT,count:2,packPrecisionFactor:4,packAlternating:{count:4,pack:({texXmax:t,texXmin:e,texYmax:s,texYmin:i})=>[[e,i],[t,i],[e,s],[t,s]]}},color:{type:pi.Ck.UNSIGNED_BYTE,count:4,normalized:!0,pack:({color:t})=>Ti(t)},outlineColor:{type:pi.Ck.UNSIGNED_BYTE,count:4,normalized:!0,pack:({outlineColor:t})=>Ti(t)},sizing:{type:pi.Ck.UNSIGNED_BYTE,count:4,pack:({rawWidth:t,rawHeight:e,outlineSize:s,referenceSize:i})=>[Pi(Math.max(t,e),128),Pi(s,128),Pi(i,128),0]},placementAngle:{type:pi.Ck.UNSIGNED_BYTE,count:1,packTessellation:({placementAngle:t})=>function(t){return function(t,e){return t%=256,Math.abs(t>=0?t:t+256)}(t*xc)}(t)},sizeRatio:{type:pi.Ck.UNSIGNED_SHORT,count:1,packPrecisionFactor:64,pack:({sizeRatio:t})=>t}}},wc={createComputedParams:t=>t,attributes:{pos:{type:pi.Ck.SHORT,count:2,packPrecisionFactor:10,pack:"position"},id:{type:pi.Ck.UNSIGNED_BYTE,count:3,pack:"id"},bitset:{type:pi.Ck.UNSIGNED_BYTE,count:1,pack:t=>0},offset:{type:pi.Ck.SHORT,count:2,packPrecisionFactor:16,packAlternating:{count:4,pack:({size:t})=>{const e=(0,l.im)(t),s=-e/2,i=-e/2;return[[s,i],[s+e,i],[s,i+e],[s+e,i+e]]}}},texCoords:{type:pi.Ck.SHORT,count:2,packPrecisionFactor:4,packAlternating:{count:4,pack:()=>[[0,1],[1,1],[0,0],[1,0]]}},size:{type:pi.Ck.UNSIGNED_BYTE,count:2,pack:({size:t})=>[t,t]},referenceSize:{type:pi.Ck.UNSIGNED_BYTE,count:1,pack:({size:t})=>(0,l.im)(t)},zoomRange:{type:pi.Ck.UNSIGNED_BYTE,count:2,pack:({scaleInfo:t},{tileInfo:e})=>vi(t,e)}}},vc=function(t){const e={};for(const s in t){const i={name:s,constructor:t[s]};e[s]=i}return e}({FillMeshWriter:ki,DotDensityMeshWriter:class extends xi{constructor(){super(...arguments),this.vertexSpec=bi}createTesselationParams(t){return{inverseArea:1/t.readGeometryArea()}}},ComplexFillMeshWriter:class extends Ai{constructor(){super(...arguments),this.vertexSpec=Xi}},PatternFillMeshWriter:Ai,OutlineFillMeshWriter:tr,PatternOutlineFillMeshWriter:class extends tr{constructor(){super(...arguments),this.vertexSpec=Ch}_createOutlineWriter(t,e,s,i){return new Fh(t,e,s,i)}_write(t,e,s){const i=s?.asOptimized()??e.readGeometryForDisplay(),r=this._clip(i);if(!r)return;const n=this.evaluatedMeshParams.sprite?.textureBinding;t.recordStart(this.instanceId,this.attributeLayout,n),this._writeGeometry(t,e,r),this._lineMeshWriter.writeLineVertices(t,jt.fromOptimizedCIM(r,"esriGeometryPolyline"),e),t.recordEnd()}ensurePacked(t,e,s){super.ensurePacked(t,e,s),this._lineMeshWriter.ensurePacked(t,e,s)}enqueueRequest(t,e,s){super.enqueueRequest(t,e,s),this._lineMeshWriter.enqueueRequest(t,e,s)}async loadDependencies(){await Promise.all([super.loadDependencies(),this._lineMeshWriter.loadDependencies()])}},ComplexOutlineFillMeshWriter:class extends tr{constructor(){super(...arguments),this.vertexSpec=Ph}_createOutlineWriter(t,e,s,i){return new Eh(t,e,s,i)}_write(t,e,s){const i=s?.asOptimized()??e.readGeometryForDisplay(),r=this._clip(i);if(!r)return;const n=this.evaluatedMeshParams.sprite?.textureBinding;t.recordStart(this.instanceId,this.attributeLayout,n),this._writeGeometry(t,e,r),this._lineMeshWriter.writeLineVertices(t,jt.fromOptimizedCIM(r,"esriGeometryPolyline"),e),t.recordEnd()}ensurePacked(t,e,s){super.ensurePacked(t,e,s),this._lineMeshWriter.ensurePacked(t,e,s)}enqueueRequest(t,e,s){super.enqueueRequest(t,e,s),this._lineMeshWriter.enqueueRequest(t,e,s)}async loadDependencies(){await Promise.all([super.loadDependencies(),this._lineMeshWriter.loadDependencies()])}},MarkerMeshWriter:class extends gi{constructor(){super(...arguments),this.vertexSpec=bc}getBoundsInfo(){return this.evaluatedMeshParams.boundsInfo}_write(t,e,s){const i=this.evaluatedMeshParams.sprite?.textureBinding,r=e.getDisplayId();t.recordStart(this.instanceId,this.attributeLayout,i);const n=this.evaluatedMeshParams.minPixelBuffer,o=Math.max(this.evaluatedMeshParams.computedWidth,n),a=Math.max(this.evaluatedMeshParams.computedHeight,n),h=this.evaluatedMeshParams.offsetX,c=-this.evaluatedMeshParams.offsetY;if(null!=this.evaluatedMeshParams.placement)this._writePlacedMarkers(t,e,s,o,a);else if(s&&s.nextPath()){s.nextPoint();const e=s.x,i=s.y;t.recordBounds(e+h,i+c,o,a),this._writeQuad(t,r,e,i)}else if("esriGeometryPolygon"===e.geometryType){const s=e.readCentroidForDisplay();if(!s)return;const[i,n]=s.coords;t.recordBounds(i+h,n+c,o,a),this._writeQuad(t,r,i,n)}else if("esriGeometryPoint"===e.geometryType){const s=e.readXForDisplay(),i=e.readYForDisplay();t.recordBounds(s+h,i+c,o,a),this._writeQuad(t,r,s,i)}else{const s=e.readGeometryForDisplay();s?.forEachVertex(((e,s)=>{t.recordBounds(e+h,s+c,o,a),Math.abs(e)>zh||Math.abs(s)>zh||this._writeQuad(t,r,e,s)}))}t.recordEnd()}_writePlacedMarkers(t,e,s,i,r){const n=s??jt.fromFeatureSetReaderCIM(e)?.clone();if(!n)return;const o=Hh.getPlacement(n,-1,this.evaluatedMeshParams.placement,(0,l.im)(1),t.id,ui());if(!o)return;const a=e.getDisplayId();let h=o.next();const c=this.evaluatedMeshParams.offsetX,u=-this.evaluatedMeshParams.offsetY;for(;null!=h;){const e=h.tx,s=-h.ty;if(Math.abs(e)>zh||Math.abs(s)>zh){h=o.next();continue}const n=-h.getAngle();t.recordBounds(e+c,s+u,i,r),this._writeQuad(t,a,e,s,n),h=o.next()}}_writeQuad(t,e,s,i,r){const n=t.vertexCount(),o=null==r?null:{placementAngle:r};this._writeVertex(t,e,s,i,o),t.indexWrite(n+0),t.indexWrite(n+1),t.indexWrite(n+2),t.indexWrite(n+1),t.indexWrite(n+3),t.indexWrite(n+2)}},PieChartMeshWriter:class extends gi{constructor(){super(...arguments),this.vertexSpec=wc}_write(t,e){const s=e.getDisplayId(),i=this.evaluatedMeshParams.minPixelBuffer,r=Math.max((0,l.im)(this.evaluatedMeshParams.size),i);let n,o;if("esriGeometryPoint"===e.geometryType)n=e.readXForDisplay(),o=e.readYForDisplay();else{const t=e.readCentroidForDisplay();if(!t)return;n=t?.coords[0],o=t?.coords[1]}t.recordStart(this.instanceId,this.attributeLayout),t.recordBounds(n,o,r,r);const a=t.vertexCount();this._writeVertex(t,s,n,o),t.indexWrite(a+0),t.indexWrite(a+1),t.indexWrite(a+2),t.indexWrite(a+1),t.indexWrite(a+3),t.indexWrite(a+2),t.recordEnd()}},TextMeshWriter:hc,LineMeshWriter:Ki,TexturedLineMeshWriter:class extends Ki{constructor(t,e,s,i){super(t,e,s,i),this.vertexSpec=uc,this._tessellationOptions.textured=!0}_write(t,e,s){const i=s??jt.fromFeatureSetReaderCIM(e);if(!i)return;const{sprite:r}=this.evaluatedMeshParams;this._writeGeometry(t,e,i,r?.textureBinding)}},HeatmapMeshWriter:class extends gi{constructor(){super(...arguments),this.vertexSpec=Ah}_write(t,e){t.recordStart(this.instanceId,this.attributeLayout);const s=e.getDisplayId();if("esriGeometryPoint"===e.geometryType){const i=e.readXForDisplay(),r=e.readYForDisplay();this._writeQuad(t,s,i,r)}else if("esriGeometryMultipoint"===e.geometryType){const i=e.readGeometryForDisplay();i?.forEachVertex(((e,i)=>{e>=0&&e<=512&&i>=0&&i<=512&&this._writeQuad(t,s,e,i)}))}t.recordEnd()}_writeQuad(t,e,s,i){const r=t.vertexCount();this._writeVertex(t,e,s,i),t.indexWrite(r+0),t.indexWrite(r+1),t.indexWrite(r+2),t.indexWrite(r+1),t.indexWrite(r+3),t.indexWrite(r+2)}},LabelMeshWriter:class extends hc{constructor(){super(...arguments),this._zoomLevel=0}_write(t,e,s,i){if(this._zoomLevel=i||0,null!=s)throw new Error("InternalError: EffectGeometry not support for LabelMeshWriter");switch(e.geometryType){case"esriGeometryPoint":{const s=e.readXForDisplay(),i=e.readYForDisplay();return this._writePoint(t,s,i,e)}case"esriGeometryEnvelope":case"esriGeometryPolygon":case"esriGeometryMultipoint":{const s=e.readCentroidForDisplay();if(!s)return;const[i,r]=s.coords;return this._writePoint(t,i,r,e)}case"esriGeometryPolyline":{const s=e.readLegacyGeometryForDisplay();this._writeLines(t,e,s)}}}_writePoint(t,e,s,i){const r=this._getShaping();if(!r)return;let n=this._getPointReferenceBounds();n||(n={offsetX:0,offsetY:0,size:0});const o=r.boundsT,a=Hs(this.evaluatedMeshParams.horizontalAlignment),h=$s(this.evaluatedMeshParams.verticalAlignment),c=this.evaluatedMeshParams.scaleInfo?.maxScale??0,l=this.evaluatedMeshParams.scaleInfo?.minScale??0,u=Nh(i.getDisplayId());t.metricStart(new Dh(u,e,s,a,h,c,l,n)),t.metricBoxWrite(o),this._writeGlyphs(t,i.getDisplayId(),e,s,r,0,n),t.metricEnd()}_getPointReferenceBounds(){if(!this._references)return null;for(const t of this._references){const e=t.getBoundsInfo();if(e)return e}return null}_writeLines(t,e,s){const{repeatLabel:i,scaleInfo:r}=this.evaluatedMeshParams,n=this.evaluatedMeshParams.repeatLabelDistance||128,o=this._getShaping();if(!o)return;this._current={out:t,id:e.getDisplayId(),shaping:o,zoomRange:vi(r,this.getTileInfo()),referenceBounds:this._getPointReferenceBounds()||{offsetX:0,offsetY:0,size:0}};const a=function(t,e){const s=e;for(let e=0;e<t.length;e++){let i=t[e];Yh(i,s);const r=[];r.push(i[0]);for(let t=1;t<i.length;t++){const[e,s]=i[t-1],[n,o]=i[t],a=n-e,h=o-s;r.push([a,h])}t[e]=r,i=r}return t}(s.paths,o.bounds.width),h=this._placeSubdivGlyphs.bind(this),c=(o.bounds.width+n)/2;for(const t of a)Xh(t,c,h,!!i)}_placeSubdivGlyphs(t,e,s,i){const{allowOverrun:r,labelPosition:n,repeatLabelDistance:o}=this.evaluatedMeshParams,a=this._current.zoomRange[0],h=lc(e),c=this._current.shaping.bounds.width/2,l=Math.sqrt(o||128)/2,u=Math.min(s,i-s),d=this._current.shaping.isMultiline?28:Math.log2(u/(l+c/2)),p=0===e?d:Math.min(h,d),_=Math.max(a,this._zoomLevel+1-p),f=this._zoomLevel-_,m=this._current.shaping.bounds.width/2*2**f;this._current.shaping.isMultiline?0===e&&this._placeStraight(t,_):r&&f<0?this._placeStraightAlong(t,a):"parallel"===n?this._placeStraightAlong(t,_):"curved"===n&&this._placeCurved(t,_,m)}_placeStraight(t,e){const{out:s,id:i,shaping:r,zoomRange:n,referenceBounds:o}=this._current,{x:a,y:h}=t,c=t.angle*(180/Math.PI)%360,l=(t.angle*(180/Math.PI)+180)%360;if(r.textBox){const a=Math.max(e,n[0],0),h=Math.min(28,n[1]),u=Ds(Us(),-t.angle),[d,p]=r.shapeBackground(u),_={minZoom:a,maxZoom:h,clipAngle:c,mapAligned:!0,isLineLabel:!0};s.recordStart(this.instanceId,this.attributeLayout,r.glyphs[0].textureBinding),this._writeTextBox(s,i,t.x,t.y,p,o,_),s.recordEnd(),_.clipAngle=l,s.recordStart(this.instanceId,this.attributeLayout,r.glyphs[0].textureBinding),this._writeTextBox(s,i,t.x,t.y,p,o,_),s.recordEnd()}const u=Nh(i),d=this.evaluatedMeshParams.scaleInfo?.maxScale??0,p=this.evaluatedMeshParams.scaleInfo?.minScale??0;s.metricStart(new Dh(u,t.x,t.y,0,0,d,p,null)),s.metricBoxWrite(r.bounds);for(const u of r.glyphs)u.minZoom=e,u.maxZoom=n[1],u.angle=t.angle,this._writeLineGlyph(s,i,a,h,r.bounds,u,c,o,!0),u.angle=t.angle+Math.PI,this._writeLineGlyph(s,i,a,h,r.bounds,u,l,o,!0);s.metricEnd()}_placeCurved(t,e,s){const{out:i,id:r}=this._current,n=t.clone(),o=t.angle*(180/Math.PI)%360,a=(t.angle*(180/Math.PI)+180)%360,h=Nh(r),c=this.evaluatedMeshParams.scaleInfo?.maxScale??0,l=this.evaluatedMeshParams.scaleInfo?.minScale??0;i.metricStart(new Dh(h,t.x,t.y,0,0,c,l,null)),this._placeFirst(n,e,1,o),this._placeBack(t,n,e,s,1,o),this._placeForward(t,n,e,s,1,o),this._placeFirst(n,e,0,a),this._placeBack(t,n,e,s,0,a),this._placeForward(t,n,e,s,0,a),i.metricEnd()}_placeStraightAlong(t,e){const{out:s,id:i,shaping:r,zoomRange:n,referenceBounds:o}=this._current,{boxBorderLineColor:a,boxBackgroundColor:h}=this.evaluatedMeshParams,c=t.clone(),l=t.angle*(180/Math.PI)%360,u=(t.angle*(180/Math.PI)+180)%360;if(r.glyphs.length>0&&(a||h)){const a=Math.max(e,n[0],0),h=Math.min(28,n[1]),c=Ds(Us(),-t.angle),[d,p]=r.shapeBackground(c),_={minZoom:a,maxZoom:h,clipAngle:l,mapAligned:!0,isLineLabel:!0};s.recordStart(this.instanceId,this.attributeLayout,r.glyphs[0].textureBinding),this._writeTextBox(s,i,t.x,t.y,p,o,_),s.recordEnd(),_.clipAngle=u,s.recordStart(this.instanceId,this.attributeLayout,r.glyphs[0].textureBinding),this._writeTextBox(s,i,t.x,t.y,p,o,_),s.recordEnd()}const d=Nh(i),p=this.evaluatedMeshParams.scaleInfo?.maxScale??0,_=this.evaluatedMeshParams.scaleInfo?.minScale??0;s.metricStart(new Dh(d,t.x,t.y,0,0,p,_,null)),this._placeFirst(c,e,1,l,!0),this._placeFirst(c,e,0,u,!0),s.metricEnd()}_placeBack(t,e,s,i,r,n){const o=t.clone();let a=t.backwardLength+0;for(;o.prev()&&!(a>=i);)this._placeOnSegment(o,e,a,s,-1,r,n),a+=o.length+0}_placeForward(t,e,s,i,r,n){const o=t.clone();let a=t.remainingLength+0;for(;o.next()&&!(a>=i);)this._placeOnSegment(o,e,a,s,1,r,n),a+=o.length+0}_placeFirst(t,e,s,i,r=!1){const n=t,{out:o,id:a,shaping:h,zoomRange:c,referenceBounds:l}=this._current,u=h.glyphs;for(const d of u){const u=d.x>h.bounds.x?s:1-s,p=u*t.remainingLength+(1-u)*t.backwardLength,_=Math.abs(d.x+d.width/2-h.bounds.x),f=Math.max(0,this._zoomLevel+Math.log2(_/(p+0))),m=Math.max(e,r?0:f);d.maxZoom=Math.min(c[1],28),d.angle=t.angle+(1-s)*Math.PI,d.minZoom=Math.max(c[0],m),o.metricBoxWrite(d.bounds),this._writeLineGlyph(o,a,n.x,n.y,h.bounds,d,i,l,!0)}}_placeOnSegment(t,e,s,i,r,n,o){const{out:a,id:h,shaping:c,referenceBounds:l}=this._current,u=c.glyphs,d=t.dx/t.length,p=t.dy/t.length,_={x:t.x+s*-r*d,y:t.y+s*-r*p};for(const e of u){const u=e.x>c.bounds.x?n:1-n;if(!(u&&1===r||!u&&-1===r))continue;const d=Math.abs(e.x+e.width/2-c.bounds.x),p=Math.max(0,this._zoomLevel+Math.log2(d/s)-.1),f=Math.max(i,this._zoomLevel+Math.log2(d/(s+t.length+0)));0!==p&&(e.angle=t.angle+(1-n)*Math.PI,e.minZoom=f,e.maxZoom=p,this._writeLineGlyph(a,h,_.x,_.y,c.bounds,e,o,l,!0))}}_writeLineGlyph(t,e,s,i,r,n,o,a,h){const c=s+r.x,l=i+r.y,u=2*(this.evaluatedMeshParams.minPixelBuffer?this.evaluatedMeshParams.minPixelBuffer/this._textMeshTransformProps.fontSize:1),d=Math.max(r.width,r.height)*u;t.recordStart(this.instanceId,this.attributeLayout,n.textureBinding),t.recordBounds(c,l,d,d);const{texcoords:p,offsets:_}=n,f=this._textMeshTransformProps.fontSize;this._writeQuad(t,e,s,i,{texcoords:p,offsets:_,fontSize:f,color:Ti(this.evaluatedMeshParams.color),isBackground:!1,referenceBounds:a,minZoom:Math.max(this._current.zoomRange[0],n.minZoom),maxZoom:Math.min(this._current.zoomRange[1],n.maxZoom),clipAngle:o,mapAligned:h,isLineLabel:!0}),t.recordEnd()}}});async function Sc(t,e,s,i){return Promise.all(s.map((s=>async function(t,e,s,i,r,n,o){const a=vc[s],h=await dt.create(t,e,r),c=new a.constructor(i,h,n,o);return await c.loadDependencies(),c}(t,e,s.meshWriterName,s.id,s.options,i,s.optionalAttributes))))}class Ic{constructor(){this._defaultResult=null,this._backgroundFillResult=null}static async from(t,e,s,i){const r=new Ic;return r.setDefault(await Sc(t,e,s.meshes,i)),r}size(){return 1}getDefault(){return this._defaultResult}setDefault(t){this._defaultResult=t}getBackgroundFill(){return this._backgroundFillResult}setBackgroundFill(t){this._backgroundFillResult=t}match(t,e){const s=this.doMatch(t,e)||this.getDefault();if(s&&s.length>0){const t=this.getBackgroundFill();if(t)return[...t,...s]}return s}getSortKey(t,e){return 0}doMatch(t,e){return null}async fetchResources(t,e){}}class Tc extends Ic{static async fromDictionaryRenderer(t,e,s){return new Tc(t,e,s)}constructor(t,e,s){super(),this._storage=t,this._schema=e,this._viewParams=s,this._hashToGroup=new Map}get fieldMap(){return this._schema.fieldMap}async fetchResources(t,e){const s=e.getCursor(),i=[];for(;s.next();)i.push(this._updateMeshWriterGroup(t,s));await Promise.all(i)}match(t,e){const s=t.getAttributeHash();return this._hashToGroup.get(s)}async _updateMeshWriterGroup(t,e){const s=e.readLegacyFeatureForDisplay(),i=e.getAttributeHash();if(this._hashToGroup.has(i))return;this._hashToGroup.set(i,null);const r=await t.fetchDictionaryResourceImmediate({type:"dictionary-request",feature:s});if(!r)return;const n=await Sc(this._storage,t,r.meshes,this._viewParams);this._hashToGroup.set(i,n)}}class Pc extends Ic{constructor(t,e){super(),this._intervals=[],this._isMaxInclusive=e,this._field=t}static async fromIntervalSchema(t,e,s,i){const r=await t.createComputedField(s),n=new Pc(r,s.isMaxInclusive);await Promise.all(s.intervals.map((async s=>{const r=await Sc(t,e,s.meshes,i);n.add(s,r)})));const o=await Sc(t,e,s.defaultSymbol,i);n.setDefault(o);const a=await Sc(t,e,s.backgroundFill,i);return n.setBackgroundFill(a),n}add(t,e){this._intervals.push({interval:t,result:e}),this._intervals.sort(((t,e)=>t.interval.min-e.interval.min))}size(){return super.size()+this._intervals.length}doMatch(t,e){const s=this._field?.read(t,e);if(null==s||isNaN(s)||s===1/0||s===-1/0)return null;for(let t=0;t<this._intervals.length;t++){const{interval:e,result:i}=this._intervals[t],r=s>=e.min,n=this._isMaxInclusive?s<=e.max:s<e.max;if(r&&n)return i}return null}}class Mc extends Ic{static async fromLabelSchema(t,e,s,i){const r=s.classes.map((async s=>{const r=await Sc(t,e,s.meshes,i);return{minScale:s.minScale,maxScale:s.maxScale,meshes:r,expression:null,where:await t.createWhereClause(s.where)}})),n=await Promise.all(r);return new Mc(n)}constructor(t){super(),this._labels=t}match(t,e){if(!this._labels.length)return null;const s=this._getLabels(e.$view.scale),i=[];for(const e of s)e.where&&!e.where(t)||i.push(...e.meshes);return i}_getLabels(t){return this._labels.filter((e=>this._validForTileScale(e,t)))}_validForTileScale(t,e){const s=e-e/4,i=e+e/2;return(!t.minScale||t.minScale>=s)&&(!t.maxScale||t.maxScale<=i)}}class Ec extends Ic{constructor(t,e){super(),this._defaultSymbolSortKey=0,this._nullResult=null,this._resultsMap=new Map,this._fields=[],this._fields=t,this._separator=e||""}static async fromMatcherSchema(t,e,s,i){const r=s.expression?[t.createComputedField({expression:s.expression})]:[s.field?t.createComputedField({field:s.field}):null,s.field2?t.createComputedField({field:s.field2}):null,s.field3?t.createComputedField({field:s.field3}):null],n=(await Promise.all(r)).filter((t=>!!t)),o=new Ec(n,s.fieldDelimiter),a=await Sc(t,e,s.defaultSymbol,i);o.setDefault(a);const h=await Sc(t,e,s.backgroundFill,i);return o.setBackgroundFill(h),await Promise.all(s.map.map((async(s,r)=>{const n=await Sc(t,e,s.symbol,i);"<Null>"===s.value?o.setNullResult(n):o.add(s.value,n,r+1)}))),o}setNullResult(t){this._nullResult=t}getSortKey(t,e){const s=this._getValueFromFields(t,e);if(null==s||""===s||"<Null>"===s)return 0;const i=this._resultsMap.get(s.toString());return i?i.sortKey:this._defaultSymbolSortKey}add(t,e,s){this._resultsMap.set(t.toString(),{meshWriters:e,sortKey:s}),this._defaultSymbolSortKey=Math.max(this._defaultSymbolSortKey,s+1)}size(){return super.size()+this._resultsMap.size}doMatch(t,e){const s=this._getValueFromFields(t,e);if(null!==this._nullResult&&(null==s||""===s||"<Null>"===s))return this._nullResult;if(null==s)return null;const i=s.toString();return this._resultsMap.get(i)?.meshWriters}_getValueFromFields(t,e){const s=[];for(const i of this._fields){const r=i.read(t,e);null==r||""===r?s.push("<Null>"):s.push(r)}return s.join(this._separator)}}async function Cc(t,e,s,i){switch(s.type){case"simple":case"heatmap":case"dot-density":case"pie-chart":return Ic.from(t,e,s,i);case"interval":return Pc.fromIntervalSchema(t,e,s,i);case"dictionary":return Tc.fromDictionaryRenderer(t,s,i);case"label":return Mc.fromLabelSchema(t,e,s,i);case"map":return Ec.fromMatcherSchema(t,e,s,i);case"subtype":return kc.fromSubtypes(t,e,s,i);case"cluster":return Fc.fromClusterSchema(t,e,s,i);default:throw new Error("Impl")}}class kc extends Ic{constructor(t,e){super(),this._subMatchers=t,this._subtypeField=e}static async fromSubtypes(t,e,s,i){const r=new Map,n=[];for(const o in s.renderers){const a=parseInt(o,10),h=Cc(t,e,s.renderers[o],i).then((t=>r.set(a,t)));n.push(h)}return await Promise.all(n),new kc(r,s.subtypeField)}match(t,e){const s=t.readAttribute(this._subtypeField),i=this._subMatchers.get(s);return i?i.match(t,e):null}}class Fc extends Ic{static async fromClusterSchema(t,e,s,i){const[r,n]=await Promise.all([Cc(t,e,s.feature,i),Cc(t,e,s.cluster,i)]);return new Fc(r,n)}constructor(t,e){super(),this._featureMatcher=t,this._clusterMatcher=e}match(t,e){return 1===t.readAttribute("cluster_count")?this._featureMatcher.match(t,e):this._clusterMatcher.match(t,e)}}class Ac extends J{static async create(t,e,s,i){const r=await Cc(t,e,s.symbology,i),n=s.labels?await Cc(t,e,s.labels,i):null;return new Ac(r,n)}constructor(t,e){super(),this._symbology=t,this._labels=e}destroy(){}async enqueueMatcherRequests(t,e){await Promise.all([this._symbology.fetchResources(t,e),this._labels?.fetchResources(t,e)])}enqueueWriterRequests(t,e,s){const i=this._symbology.match(e,s);if(i){for(const r of i)r.enqueueRequest(t,e,s);if(this._labels){const i=this._labels.match(e,s);if(!i)return;for(const r of i)r.enqueueRequest(t,e,s)}}}write(t,e,s,i,r){const n=this._symbology.match(s,i);if(n){for(const o of n)o.write(t,e,s,i,r);if(t.entityRecordCount()>=1&&this._labels){const o=this._labels.match(s,i);if(!o)return;for(const a of o)a.setReferences(n),a.write(t,e,s,i,r)}}}getSortKey(t,e){return this._symbology.getSortKey(t,e)}}class Rc{}class Oc extends Rc{constructor(t){super(),this._fetcher=t,this._controller=new AbortController,this._pendingIds=new Set,this._pendingRequests=[],this._resourceIdToResource=new Map}destory(){this._controller.abort()}get _abortOptions(){return{signal:this._controller.signal}}enqueueRequest(t){const e=function(t){return"url"in t&&"urlHash"in t?{...t,url:""}:t}(t.resource),s=(0,st.sV)(JSON.stringify(e));return this._pendingIds.has(s)||(this._pendingIds.add(s),this._pendingRequests.push({...t,resourceId:s})),s}async fetchEnqueuedResources(){const t=this._pendingRequests;this._pendingIds.clear(),this._pendingRequests=[];const e=await this._fetcher.fetch(t,this._abortOptions);for(let s=0;s<e.length;s++){const i=t[s].resourceId;this._resourceIdToResource.set(i,e[s])}}async fetchResourceImmediate(t){const e=await this._fetcher.fetch([t],this._abortOptions);if(1!==e.length)throw new Error("FeaturePipelineResourceProxy: failed to fetch resources");return e[0]}async fetchDictionaryResourceImmediate(t){const e=await this._fetcher.fetchDictionary([t],this._abortOptions);if(1!==e.length)throw new Error("FeaturePipelineResourceProxy: failed to fetch dictionary resources");return e[0]}getResource(t){return this._resourceIdToResource.get(t)}}class Nc{constructor(t){this._outstandingMessages=[],this._queue=new A.K({concurrency:t.concurrency,process:e=>t.process(e)})}async push(t){if(t.end)return await Promise.all(this._outstandingMessages),await this._queue.push(t),void(this._outstandingMessages=[]);const e=this._queue.push(t);return this._outstandingMessages.push(e),e}}var Dc=s(59612),zc=s(97088),Lc=s(34888),Bc=s(7684);class Uc{static async create(t,e){if("count"===e.statisticType){const t=new at(1);return new Uc(e.name,e.alias,e.type,e.statisticType,t)}const s=await t.createComputedField({expression:e.onStatisticExpression?.expression,field:e.onStatisticField});return new Uc(e.name,e.alias,e.type,e.statisticType,s)}constructor(t,e,s,i,r){this.name=t,this.alias=e,this.type=s,this.statisticType=i,this.computed=r}}var Gc=s(77860),Vc=s(77048),qc=s(51752),Wc=s(47302);class Xc{constructor(t){this.subscription=t,this.handledChunks=new Set}destroy(){}}class Yc{constructor(t,e){this._source=t,this._attributeStore=e,this._sendStates=new Map}destroy(){}get enablePixelBuffering(){return!0}onSubscribe(t){const e=this.createState(t);this._sendStates.set(t.key.id,e),this.updateChunks()}onUnsubscribe(t){this._sendStates.get(t.key.id)?.destroy(),this._sendStates.delete(t.key.id)}invalidate(){const t=Array.from(this._sendStates.values());this._sendStates.clear();for(const e of t)e.destroy(),this.onSubscribe(e.subscription)}invalidateAttributeData(){}getFeatureObjectIdsForAggregate(t){throw new Error("InternalError: AggregateId lookup not supported")}getDisplayIds(t){return this.displayMap(t,(t=>t),(t=>t))}getDisplayAndObjectIds(t){return this.displayMap(t,(t=>t),((t,e,s)=>[t,s]))}afterUpdateChunks(){}}class jc extends Yc{constructor(t,e,s,i){super(t,e),this.spatialReference=s,this.aggregateFields=i,this.events=new Gc.c,this.featureAdapter=qc.u}get aggregateQueryEngine(){return this._aggregateQueryEngine||(this._aggregateQueryEngine=new Wc.U({featureStore:this,fieldsIndex:this._metadata.fieldsIndex,geometryType:this._metadata.geometryType,objectIdField:this._metadata.objectIdField,spatialReference:this.spatialReference})),this._aggregateQueryEngine}removeChunks(t){}forEach(t){return this.forEachAggregateWorldSpace(t)}forEachInBounds(t,e){}forEachBounds(t,e){const s=(0,Vc.Su)();for(const i of t){const t=(0,zc.C_)(s,i.geometry,!1,!1);t&&e(t)}}}class Hc{constructor(t,e,s,i,r){this.subscription=t,this.reader=e,this.clear=s,this.end=i,this.debugInfo=r,this.type="append"}get id(){return this.subscription.tile.id}createMessage(t,e,s){return{type:"append",clear:this.clear,id:this.id,append:t,end:this.end,debugInfo:this.debugInfo,subscriptionVesrion:this.subscription.version,version:e,attributeEpoch:s}}}class $c{constructor(t,e,s,i,r){this.subscription=t,this.reader=e,this.remove=s,this.end=i,this.debugInfo=r,this.type="update"}get id(){return this.subscription.tile.id}createMessage(t,e,s){return{type:"update",id:this.id,modify:t,debugInfo:this.debugInfo,remove:this.remove,version:e,subscriptionVesrion:this.subscription.version,end:this.end,attributeEpoch:s}}}class Kc extends ot{constructor(t){super(),this._field=t}resize(t){throw new Error("Method not implemented.")}read(t,e){return t.readAttribute(this._field)}readWithDefault(t,e){return t.readAttribute(this._field)}referencesScale(){return!1}referencesGeometry(){return!1}}var Zc=s(6384);function Qc(t,e,s){if(null==t)return null;const i=e.readArcadeFeature();e.contextTimeZone=s.$view?.timeZone;try{return t.evaluate({...s,$feature:i},t.services)}catch(t){return C.c.getLogger("geoscene.views.2d.support.arcadeOnDemand").warn("Feature arcade evaluation failed:",t),null}}function Jc(t){return null==t||t===1/0||t===-1/0||"number"==typeof t&&isNaN(t)}function tl(t,e,s,i){if(null==t)return null!=i?i:null;const r=e.readArcadeFeature();e.contextTimeZone=s.$view?.timeZone;const n=t.evaluate({...s,$feature:r},t.services);return Jc(n)?null!=i?i:null:n}class el extends ot{static async create(t,e){const s=await(0,Zc.kr)(t,e.spatialReference,e.fields),i=(0,st.sV)(t);return new el(s,i)}constructor(t,e){super(),this._compiled=t,this._cacheKey=e}resize(t){}read(t,e){return this.referencesScale()||"system"!==e.$view.timeZone?Qc(this._compiled,t,e):this._readCached(t,e)}readWithDefault(t,e,s){return this.referencesScale()||"system"!==e.$view.timeZone?tl(this._compiled,t,e,s):this._readWithDefaultCached(t,e,s)}referencesScale(){return this._compiled?.referencesScale()??!1}referencesGeometry(){return this._compiled?.referencesGeometry()??!1}_readCached(t,e){if(t.setCache(this._cacheKey),t.hasCachedValue())return t.getCachedValue();const s=Qc(this._compiled,t,e);return t.setCachedValue(s),s}_readWithDefaultCached(t,e,s){if(t.setCache(this._cacheKey),t.hasCachedValue())return t.getCachedValue();const i=tl(this._compiled,t,e,s);return t.setCachedValue(i),i}}var sl=s(47828),il=s(54052),rl=s(41936),nl=s(564),ol=s(4144);class al extends ot{static async create(t,e){const s=(0,ol.y6)(t);return new al((t=>s.replaceAll(/{[^}]*}/g,(e=>{const s=e.slice(1,-1),i=t.metadata.fieldsIndex.get(s);if(null==i)return e;const r=t.readAttribute(s);return null==r?"":function(t,e){if(null==t)return"";const s=e.domain;if(s)if("codedValue"===s.type||"coded-value"===s.type){const e=t;for(const t of s.codedValues)if(t.code===e)return t.name}else if("range"===s.type){const{max:i,min:r}=(0,rl.w1)(e),n=+t;if(null!=r&&null!=i&&r<=n&&n<=i)return s.name}let i=t;return(0,nl.gp)(e)?i=(0,sl._m)(i,(0,sl.Cg)("short-date")):(0,nl.iW)(e)&&(i=(0,il.iy)(+i)),i||""}(r,i)}))))}constructor(t){super(),this._evaluator=t}resize(t){}read(t,e){return this._evaluator(t)}readWithDefault(t,e,s){const i=this._evaluator(t);return Jc(i)?s:i}referencesScale(){return!1}referencesGeometry(){return!1}}class hl extends ot{constructor(t,e){super(),this._field=t,this._normalizationInfo=e}resize(t){throw new Error("Method not implemented.")}read(t,e){return this._readNormalized(t)}readWithDefault(t,e){return this._readNormalized(t)}referencesScale(){return!1}referencesGeometry(){return!1}_readNormalized(t){const e=t.readAttribute(this._field);if(null==e)return null;const{normalizationField:s,normalizationTotal:i,normalizationType:r}=this._normalizationInfo,n=t.readAttribute(s);switch(r??"esriNormalizeByField"){case"esriNormalizeByField":return n?n?e/n:void 0:null;case"esriNormalizeByLog":return Math.log(e)*Math.LOG10E;case"esriNormalizeByPercentOfTotal":return i?e/i*100:null}}}class cl{static fromBuffer(t,e){return new cl(t,e)}static create(t,e=4294967295){const s=new Uint32Array(Math.ceil(t/32));return new cl(s,e)}constructor(t,e){this._mask=0,this._buf=t,this._mask=e}_getIndex(t){return Math.floor(t/32)}has(t){const e=this._mask&t;return!!(this._buf[this._getIndex(e)]&1<<e%32)}hasRange(t,e){let s=t,i=e;for(;s%32&&s!==i;){if(this.has(s))return!0;s++}for(;i%32&&s!==i;){if(this.has(s))return!0;i--}if(s===i)return!1;for(let t=s/32;t!==i/32;t++)if(this._buf[t])return!0;return!1}set(t){const e=this._mask&t,s=this._getIndex(e),i=1<<e%32;this._buf[s]|=i}setRange(t,e){let s=t,i=e;for(;s%32&&s!==i;)this.set(s++);for(;i%32&&s!==i;)this.set(i--);if(s!==i)for(let t=s/32;t!==i/32;t++)this._buf[t]=4294967295}unset(t){const e=this._mask&t,s=this._getIndex(e),i=1<<e%32;this._buf[s]&=4294967295^i}resize(t){const e=this._buf,s=new Uint32Array(Math.ceil(t/32));s.set(e),this._buf=s}or(t){for(let e=0;e<this._buf.length;e++)this._buf[e]|=t._buf[e];return this}and(t){for(let e=0;e<this._buf.length;e++)this._buf[e]&=t._buf[e];return this}xor(t){for(let e=0;e<this._buf.length;e++)this._buf[e]^=t._buf[e];return this}ior(t){for(let e=0;e<this._buf.length;e++)this._buf[e]|=~t._buf[e];return this}iand(t){for(let e=0;e<this._buf.length;e++)this._buf[e]&=~t._buf[e];return this}ixor(t){for(let e=0;e<this._buf.length;e++)this._buf[e]^=~t._buf[e];return this}any(){for(let t=0;t<this._buf.length;t++)if(this._buf[t])return!0;return!1}copy(t){for(let e=0;e<this._buf.length;e++)this._buf[e]=t._buf[e];return this}clone(){return new cl(this._buf.slice(),this._mask)}clear(){for(let t=0;t<this._buf.length;t++)this._buf[t]=0;return this}forEachSet(t){for(let e=0;e<this._buf.length;e++){let s=this._buf[e],i=32*e;if(s)for(;s;)1&s&&t(i),s>>>=1,i++}}countSet(){let t=0;return this.forEachSet((e=>{t++})),t}}var ll=s(44247);const ul=()=>C.c.getLogger("geoscene.views.2d.layers.features.support.whereUtils"),dl={getAttribute:(t,e)=>t.readAttribute(e)};async function pl(t,e){try{const s=await(0,ll.u)(t,e);if(!s.isStandardized){const t=new i.c("mapview - bad input","Unable to apply filter's definition expression, as expression is not standardized.",s);ul().error(t)}return e=>{const i=e.readArcadeFeature();try{return s.testFeature(i,dl)}catch(e){return ul().warn("mapview-bad-where-clause","Encountered an error when evaluating where clause",t),!0}}}catch(e){return ul().warn("mapview-bad-where-clause","Encountered an error when evaluating where clause",t),t=>!0}}const _l=()=>C.c.getLogger("geoscene.views.2d.layers.features.support.ComputedAttributeStorage"),fl=4294967295;function ml(t,e,s){if(!(t.length>e))for(;t.length<=e;)t.push(s)}class gl{constructor(t){this._numerics=[],this._strings=[],this._allocatedSize=256,this._bitsets=[],this._instanceIds=[],this._bounds=[],this._dirtyBitset=this.getBitset(this.createBitset()),this.compilationOptions=t}createBitset(){const t=this._bitsets.length;return this._bitsets.push(cl.create(this._allocatedSize,Oh)),t+1}async createComputedField(t,e=!1){if(t.expression)try{if(!this.compilationOptions)throw new Error("InternalError: Compilation options not defined");return e?al.create(t.expression,this.compilationOptions):await el.create(t.expression,this.compilationOptions)}catch(e){const s=new i.c("featurelayer","Failed to compile arcade expression",{error:e,expression:t.expression});return _l().error(s),null}if(t.normalizationType||t.normalizationField)return new hl(t.field,t);if(t.field)return new Kc(t.field);const s=new i.c("featurelayer","Unable to create computed field. No expression or field found",{info:t});return _l().error(s),null}async createWhereClause(t){return t?pl(t,this.compilationOptions.fields):null}getBitset(t){return this._bitsets[t-1]}getComputedNumeric(t,e){return this.getComputedNumericAtIndex(t&Oh,0)}setComputedNumeric(t,e,s){return this.setComputedNumericAtIndex(t&Oh,s,0)}getComputedString(t,e){return this.getComputedStringAtIndex(t&Oh,0)}setComputedString(t,e,s){return this.setComputedStringAtIndex(t&Oh,0,s)}getComputedNumericAtIndex(t,e){const s=t&Oh;return this._ensureNumeric(e,s),this._numerics[e][s]}setComputedNumericAtIndex(t,e,s){const i=t&Oh;this._ensureNumeric(e,i),this._numerics[e][i]=s}getPackedChunkId(t){const e=t&Oh;return this._ensureInstanceId(e),this._instanceIds[e]}setPackedChunkId(t,e){const s=t&Oh;this._ensureInstanceId(s),this._instanceIds[s]=e}getComputedStringAtIndex(t,e){const s=t&Oh;return this._ensureString(e,s),this._strings[e][s]}setComputedStringAtIndex(t,e,s){const i=t&Oh;this._ensureString(e,i),this._strings[e][i]=s}getXMin(t){return this._bounds[4*(t&Oh)]}getYMin(t){return this._bounds[4*(t&Oh)+1]}getXMax(t){return this._bounds[4*(t&Oh)+2]}getYMax(t){return this._bounds[4*(t&Oh)+3]}setBounds(t,e,s=!1){const i=t&Oh;if(!s&&!this._dirtyBitset.has(t))return this._bounds[4*i]!==fl;this._dirtyBitset.unset(t);const r=e.readGeometryWorldSpace();if(ml(this._bounds,4*i+4,0),!r||!r.coords.length)return this._bounds[4*i]=fl,this._bounds[4*i+1]=fl,this._bounds[4*i+2]=fl,this._bounds[4*i+3]=fl,!1;let n=1/0,o=1/0,a=-1/0,h=-1/0;return r.forEachVertex(((t,e)=>{n=Math.min(n,t),o=Math.min(o,e),a=Math.max(a,t),h=Math.max(h,e)})),this._bounds[4*i]=n,this._bounds[4*i+1]=o,this._bounds[4*i+2]=a,this._bounds[4*i+3]=h,!0}getBounds(t,e){const s=this.getXMin(e),i=this.getYMin(e),r=this.getXMax(e),n=this.getYMax(e);return(0,Vc.qy)(t,s,i,r,n),s!==fl}_ensureNumeric(t,e){this._numerics[t]||(this._numerics[t]=[]),ml(this._numerics[t],e,0)}_ensureInstanceId(t){ml(this._instanceIds,t,0)}_ensureString(t,e){this._strings[t]||(this._strings[t]=[]),ml(this._strings[t],e,null)}}var yl=s(3900),xl=s(79596),bl=s(78104),wl=s(95776);class vl{getObjectId(t){return t.getObjectId()}getAttributes(t){return t.readAttributes()}getAttribute(t,e){return t.readAttribute(e)}getAttributeAsTimestamp(t,e){return t.readAttributeAsTimestamp(e)}cloneWithGeometry(t,e){return t}getGeometry(t){return t.readGeometryWorldSpace()}getCentroid(t,e){return t.readCentroidForDisplay()}}vl.Shared=new vl;class Sl{constructor(t){this._geometryBounds=(0,L.Su)(),this._idToVisibility=new Map,this._serviceInfo=t}static async create(t){const e=new Sl(t);return await e.update(t.filterJSON,t.spatialReference),e}get hash(){return this._hash}check(t){return this._applyFilter(t)}clear(){const t=this._resetAllHiddenIds();return this.update(),{show:t,hide:[]}}invalidate(){this._idToVisibility.forEach(((t,e)=>{this._idToVisibility.set(e,0)}))}setKnownIds(t){for(const e of t)this._idToVisibility.set(e,1)}setTrue(t){const e=[],s=[],i=new Set(t);return this._idToVisibility.forEach(((t,r)=>{const n=!!(1&this._idToVisibility.get(r)),o=i.has(r);!n&&o?e.push(r):n&&!o&&s.push(r),this._idToVisibility.set(r,o?3:0)})),{show:e,hide:s}}createQuery(){const{geometry:t,spatialRel:e,where:s,timeExtent:i,objectIds:r}=this;return wl.c.fromJSON({geometry:t,spatialRel:e,where:s,timeExtent:i,objectIds:r})}async update(t,e){this._hash=JSON.stringify(t);const s=await(0,yl._8)(t,null,e);await Promise.all([this._setGeometryFilter(s),this._setIdFilter(s),this._setAttributeFilter(s),this._setTimeFilter(s)])}async _setAttributeFilter(t){if(!t?.where)return this._clause=null,void(this.where=null);this._clause=await pl(t.where,this._serviceInfo.fieldsIndex),this.where=t.where}_setIdFilter(t){this._idsToShow=t?.objectIds&&new Set(t.objectIds),this._idsToHide=t?.hiddenIds&&new Set(t.hiddenIds),this.objectIds=t?.objectIds}async _setGeometryFilter(t){if(!t?.geometry)return this._spatialQueryOperator=null,this.geometry=null,void(this.spatialRel=null);const e=t.geometry,s=t.spatialRel||"esriSpatialRelIntersects",i=await(0,xl.q0)(s,e,this._serviceInfo.geometryType,this._serviceInfo.hasZ,this._serviceInfo.hasM);(0,Ge.ac)(this._geometryBounds,e),this._spatialQueryOperator=i,this.geometry=e,this.spatialRel=s}_setTimeFilter(t){if(this.timeExtent=this._timeOperator=null,t?.timeExtent)if(this._serviceInfo.timeInfo)this.timeExtent=t.timeExtent,this._timeOperator=(0,bl.k)(this._serviceInfo.timeInfo,t.timeExtent,vl.Shared);else{const e=new i.c("feature-layer-view:time-filter-not-available","Unable to apply time filter, as layer doesn't have time metadata.",t.timeExtent);C.c.getLogger("geoscene.views.2d.layers.features.controllers.FeatureFilter").error(e)}}_applyFilter(t){return this._filterByGeometry(t)&&this._filterById(t)&&this._filterByTime(t)&&this._filterByExpression(t)}_filterByExpression(t){return!this.where||this._clause(t)}_filterById(t){return(!this._idsToHide?.size||!this._idsToHide.has(t.getObjectId()))&&(!this._idsToShow?.size||this._idsToShow.has(t.getObjectId()))}_filterByGeometry(t){if(!this.geometry)return!0;const e=t.readGeometryWorldSpace();return!!e&&this._spatialQueryOperator(e)}_filterByTime(t){return null==this._timeOperator||this._timeOperator(t)}_resetAllHiddenIds(){const t=[];return this._idToVisibility.forEach(((e,s)=>{1&e||(this._idToVisibility.set(s,1),t.push(s))})),t}}var Il=s(16424);class Tl{constructor(t){this._options=t,this._fieldsIndex="fieldsIndex"in t?Il.c.fromJSON(t.fieldsIndex):new Il.c(t.fields),t.spatialReference&&(this._spatialReference=V.c.fromJSON(t.spatialReference)),this._arcadeSchema={fields:this.fieldsIndex.fields,fieldsIndex:this.fieldsIndex,geometryType:this.geometryType,objectIdField:this.objectIdField,globalIdField:this._options.globalIdField,spatialReference:this._spatialReference,timeInfo:this._options.timeInfo,typeIdField:this._options.typeIdField??void 0,types:this._options.types??void 0,subtypeField:this._options.subtypeField,subtypes:this._options.subtypes??void 0}}get fieldsIndex(){return this._fieldsIndex}get geometryType(){return this._options.geometryType}get timeInfo(){return this._options.timeInfo}get objectIdField(){return this._options.objectIdField}get globalIdField(){return this._options.globalIdField}get arcadeSchema(){return this._arcadeSchema}get spatialReference(){return this._spatialReference}get timeReferenceUnknownClient(){return this._options.timeReferenceUnknownClient}}var Pl=s(10724),Ml=s(85436),El=s(62024),Cl=s(28484);class kl{constructor(t){this._valid=cl.create(t),this._data=new Array(t)}has(t){return this._valid.has(t)}set(t,e){this._valid.set(t),this._data[t]=e}get(t){return this._data[t]}}const Fl=(0,n.c)("featurelayer-simplify-thresholds")??[.5,.5,.5,.5],Al=Fl[0],Rl=Fl[1],Ol=Fl[2],Nl=Fl[3],Dl=(0,n.c)("featurelayer-simplify-payload-size-factors")??[1,2,4],zl=Dl[0],Ll=Dl[1],Bl=Dl[2],Ul=(0,n.c)("featurelayer-simplify-mobile-factor")??2,Gl=(0,n.c)("geoscene-mobile"),Vl=4294967295;class ql{constructor(t){this.metadata=t,this.type="FeatureSetReader",this._deleted=null,this._joined=[],this._objectIdToIndex=null,this._boundsBuffer=[],this._caches=new Map,this.arcadeDeclaredClass="geoscene.arcade.Feature",this._contextTimeZone=null}get isEmpty(){return null!=this._deleted&&this._deleted.countSet()===this.getSize()}getAreaSimplificationThreshold(t,e){let s=1;const i=Gl?Ul:1;e>4e6?s=Bl*i:e>1e6?s=Ll*i:e>5e5?s=zl*i:e>1e5&&(s=i);let r=0;return t>4e3?r=Nl*s:t>2e3?r=Ol*s:t>100?r=Rl:t>15&&(r=Al),r}parseTimestampOffset(t){return t}getBounds(t){if(function(t,e,s){if(!(t.length>e))for(;t.length<=e;)t.push(0)}(this._boundsBuffer,4*this.getIndex()+4),this.getBoundsXMin()===Vl)return!1;if(0===this.getBoundsXMin()){const e=this.readGeometryWorldSpace();if(!e)return this.setBoundsXMin(Vl),!1;let s=1/0,i=1/0,r=-1/0,n=-1/0;return e.forEachVertex(((t,e)=>{s=Math.min(s,t),i=Math.min(i,e),r=Math.max(r,t),n=Math.max(n,e)})),this.setBoundsXMin(s),this.setBoundsYMin(i),this.setBoundsXMax(r),this.setBoundsYMax(n),(0,Vc.qy)(t,s,i,r,n),!0}const e=this.getBoundsXMin(),s=this.getBoundsYMin(),i=this.getBoundsXMax(),r=this.getBoundsYMax();return(0,Vc.qy)(t,e,s,i,r),!0}getBoundsXMin(){return this._boundsBuffer[4*this.getIndex()]}setBoundsXMin(t){this._boundsBuffer[4*this.getIndex()]=t}getBoundsYMin(){return this._boundsBuffer[4*this.getIndex()+1]}setBoundsYMin(t){this._boundsBuffer[4*this.getIndex()+1]=t}getBoundsXMax(){return this._boundsBuffer[4*this.getIndex()+2]}setBoundsXMax(t){this._boundsBuffer[4*this.getIndex()+2]=t}getBoundsYMax(){return this._boundsBuffer[4*this.getIndex()+3]}setBoundsYMax(t){this._boundsBuffer[4*this.getIndex()+3]=t}readAttributeAsTimestamp(t){const e=this.readAttribute(t);return"string"==typeof e?new Date(e).getTime():"number"==typeof e||null==e?e:null}readAttribute(t,e=!1){const s=this._readAttribute(t,e);if(void 0!==s)return s;for(const s of this._joined){s.setIndex(this.getIndex());const i=s._readAttribute(t,e);if(void 0!==i)return i}}readAttributes(){const t=this._readAttributes();for(const e of this._joined){e.setIndex(this.getIndex());const s=e._readAttributes();for(const e of Object.keys(s))t[e]=s[e]}return t}joinAttributes(t){this._joined.push(t)}removeIds(t){if(null==this._objectIdToIndex){const t=new Map,e=this.getCursor();for(;e.next();){const s=e.getObjectId();(0,M.EN)(s),t.set(s,e.getIndex())}this._objectIdToIndex=t}const e=this._objectIdToIndex;for(const s of t.values())e.has(s)&&this._removeAtIndex(e.get(s))}readOptimizedFeatureWorldSpace(){const t=this.readGeometryWorldSpace(),e=this.readAttributes(),s=this.readCentroidWorldSpace(),i=new Lc._M(t,e,s);return i.objectId=this.getObjectId(),i.displayId=this.getDisplayId(),i}readLegacyFeatureForDisplay(){const t=this.readCentroidForDisplay();return{attributes:this.readAttributes(),geometry:this.readLegacyGeometryForDisplay(),centroid:(t&&{x:t.coords[0],y:t.coords[1]})??null}}readLegacyFeatureWorldSpace(){const t=this.readCentroidWorldSpace();return{attributes:this.readAttributes(),geometry:this._readLegacyGeometryWorldSpace(),centroid:(t&&{x:t.coords[0],y:t.coords[1]})??null}}readLegacyGeometryForDisplay(){const t=this.readGeometryForDisplay();return(0,zc.qw)(t,this.geometryType,!1,!1)}readXForDisplay(){return this._readX()}readYForDisplay(){return this._readY()}readXWorldSpace(){const t=this._readX(),e=this.getInTransform();return null==e?t:t*e.scale[0]+e.translate[0]}readYWorldSpace(){const t=this._readY(),e=this.getInTransform();return null==e?t:e.translate[1]-t*e.scale[1]}readGeometryForDisplay(){const t=this._readGeometryDeltaDecoded(!0);if(!t){const t=this._createGeometryFromServerCentroid();return t?t.deltaDecode():null}return t}readGeometryWorldSpace(){let t=this._readGeometry();if(t||(t=this._createGeometryFromServerCentroid()),!t)return null;const e=t.clone(),s=this.getInTransform();return null!=s&&(0,zc.Ij)(e,e,this.hasZ,this.hasM,s),e}readCentroidForDisplay(){const t=this.readGeometryForDisplay();return t?this._computeDisplayCentroid(t):this._readServerCentroid()}readCentroidWorldSpace(){const t=this.readGeometryForDisplay(),e=t?this._computeDisplayCentroid(t):this._readServerCentroid();if(!e)return null;const s=e.clone(),i=this.getInTransform();return null!=i&&(0,zc.Ij)(s,s,this.hasZ,this.hasM,i),s}setCache(t){let e=this._caches.get(t);null==e&&(e=new kl(this.getSize()),this._caches.set(t,e)),this._activeCache=e}setCachedValue(t){this._activeCache.set(this.getIndex(),t)}hasCachedValue(){return this._activeCache.has(this.getIndex())}getCachedValue(){return this._activeCache.get(this.getIndex())}_readGeometryDeltaDecoded(t){const e=this._readGeometry(t);return"esriGeometryPoint"!==this.geometryType&&e&&this.getInTransform()?e.deltaDecode():e}get contextTimeZone(){return this._contextTimeZone}set contextTimeZone(t){this._contextTimeZone=t}readArcadeFeature(){return this}hasField(t){return this.fields.has(t)||this._joined.some((e=>e.hasField(t)))}geometry(){const t=this.readGeometryWorldSpace(),e=(0,zc.qw)(t,this.geometryType,this.hasZ,this.hasM),s=(0,Yt.h4)(e);if(s){if(!this.metadata.spatialReference)throw new Error("InternalError: Expected spatial reference to be defined");s.spatialReference=this.metadata.spatialReference}return s}autocastArcadeDate(t,e){return e&&e instanceof Date?this.isUnknownDateTimeField(t)?Pl.Ql.unknownDateJSToArcadeDate(e):Pl.Ql.dateJSAndZoneToArcadeDate(e,this.contextTimeZone??Cl.OX):e}isUnknownDateTimeField(t){return this.metadata.fieldsIndex.getTimeZone(t)===Cl.OI}field(t){let e=this.fields.get(t);if(e)switch(e.type){case"date-only":case"esriFieldTypeDateOnly":return Ml.K.fromReader(this.readAttribute(t,!1));case"time-only":case"esriFieldTypeTimeOnly":return El.C.fromReader(this.readAttribute(t,!1));case"esriFieldTypeTimestampOffset":case"timestamp-offset":return Pl.Ql.fromReaderAsTimeStampOffset(this.readAttribute(t,!1));case"date":case"esriFieldTypeDate":return this.autocastArcadeDate(t,this.readAttribute(t,!0));default:return this.readAttribute(t,!1)}for(const s of this._joined)if(s.setIndex(this.getIndex()),e=s.fields.get(t),e)switch(e.type){case"date-only":case"esriFieldTypeDateOnly":return Ml.K.fromReader(s._readAttribute(t,!1));case"time-only":case"esriFieldTypeTimeOnly":return El.C.fromReader(s._readAttribute(t,!1));case"esriFieldTypeTimestampOffset":case"timestamp-offset":return Pl.Ql.fromReaderAsTimeStampOffset(s._readAttribute(t,!1));case"date":case"esriFieldTypeDate":return this.autocastArcadeDate(t,s._readAttribute(t,!0));default:return this.readAttribute(t,!1)}throw new Error(`Field ${t} does not exist`)}setField(t,e){throw new Error("Unable to update feature attribute values, feature is readonly")}keys(){return this.fields.fields.map((t=>t.name))}castToText(t=!1){if(!t)return JSON.stringify(this.readLegacyFeatureForDisplay());const e=this.readLegacyFeatureForDisplay();if(!e)return JSON.stringify(null);const s={geometry:e.geometry,attributes:{...e.attributes??{}}};for(const t in s.attributes){const e=s.attributes[t];e instanceof Date&&(s.attributes[t]=e.getTime())}return JSON.stringify(s)}gdbVersion(){return null}fullSchema(){return this.metadata.arcadeSchema}castAsJson(t=null){return{attributes:this._readAttributes(),geometry:!0===t?.keepGeometryType?this.geometry():this.geometry()?.toJSON()??null}}castAsJsonAsync(t=null,e=null){return Promise.resolve(this.castAsJson(e))}_getExists(){return null==this._deleted||!this._deleted.has(this.getIndex())}_computeDisplayCentroid(t){const e=jt.fromOptimized(t,this.geometryType);e.yFactor*=-1;const s=_s(e);return s?(s[1]*=-1,new ft.c([],s)):null}copyInto(t){t._joined=this._joined,t._deleted=this._deleted,t._objectIdToIndex=this._objectIdToIndex,t._boundsBuffer=this._boundsBuffer,t._activeCache=this._activeCache,t._caches=this._caches}_readLegacyGeometryWorldSpace(){const t=this.readGeometryWorldSpace();return(0,zc.qw)(t,this.geometryType,!1,!1)}_createGeometryFromServerCentroid(){const t=this._readServerCentroid();if(!t)return null;const[e,s]=t.coords;return this._createQuantizedExtrudedGeometry(e,s)}_createQuantizedExtrudedGeometry(t,e){return"esriGeometryPolyline"===this.geometryType?this._createQuantizedExtrudedLine(t,e):this._createQuantizedExtrudedQuad(t,e)}_createQuantizedExtrudedQuad(t,e){return new ft.c([5],[t-1,e,1,-1,1,1,-1,1,-1,-1])}_createQuantizedExtrudedLine(t,e){return new ft.c([2],[t-1,e+1,1,-1])}_removeAtIndex(t){null==this._deleted&&(this._deleted=cl.create(this.getSize())),this._deleted.set(t)}}class Wl extends ql{static fromFeatures(t,e){const{objectIdField:s,geometryType:i}=e,r=(0,zc.od)([],t,i,!1,!1,s);for(let e=0;e<r.length;e++)r[e].displayId=t[e].displayId;return Wl.fromOptimizedFeatures(r,e)}static fromFeatureSet(t,e){const s=(0,zc.ui)(t,e.objectIdField);return Wl.fromOptimizedFeatureSet(s,e)}static fromOptimizedFeatureSet(t,e){const s=Wl.fromOptimizedFeatures(t.features,e);return s._exceededTransferLimit=t.exceededTransferLimit,s._transform=t.transform,s._fieldsIndex=new Il.c(t.fields),s}static fromOptimizedFeatures(t,e,s){const i=new Wl(t,e);return i._fieldsIndex=e.fieldsIndex,i._transform=s,i}static empty(t){return new Wl([],t)}constructor(t,e){super(e),this._exceededTransferLimit=!1,this._featureIndex=-1,this._fieldsIndex=null,this._geometryType=e.geometryType,this._features=t}get fields(){return this._fieldsIndex}get geometryType(){return this._geometryType}get hasFeatures(){return!!this._features.length}get hasNext(){return this._featureIndex+1<this._features.length}get exceededTransferLimit(){return this._exceededTransferLimit}get hasZ(){return!1}get hasM(){return!1}get _current(){return this._features[this._featureIndex]}removeIds(t){const e=new Set(t);this._features=this._features.filter((t=>!(null!=t.objectId&&e.has(t.objectId))))}getSize(){return this._features.length}getCursor(){return this.copy()}getInTransform(){return this._transform}getAttributeHash(){let t="";for(const e in this._current.attributes)t+=this._current.attributes[e];return t}getIndex(){return this._featureIndex}setIndex(t){this._featureIndex=t}getObjectId(){return this._current?.objectId}getDisplayId(){return this._current.displayId}setDisplayId(t){this._current.displayId=t}copy(){const t=new Wl(this._features,this.metadata);return this.copyInto(t),t}next(){for(;++this._featureIndex<this._features.length&&!this._getExists(););return this._featureIndex<this._features.length}readGeometryArea(){return(0,Lc.ED)(this._current)?(0,zc.Oo)(this._current.geometry,2):0}_readX(){return(0,Lc.ED)(this._current)?this._current.geometry.coords[0]:0}_readY(){return(0,Lc.ED)(this._current)?this._current.geometry.coords[1]:0}_readGeometry(){return(0,Lc.ED)(this._current)?this._current.geometry??null:null}_readServerCentroid(){return this._current.centroid}_readAttribute(t,e){if(!this._fieldsIndex){const e=this._current.attributes[t];if(void 0!==e)return e;const s=t.toLowerCase();for(const t in this._current.attributes)if(t.toLowerCase()===s)return this._current.attributes[t];return}const s=this._fieldsIndex.get(t);if(!s)return;let i=this._current.attributes[s.name];return null==i?i:("esriFieldTypeTimestampOffset"===this.fields.get(t)?.type&&(i=this.parseTimestampOffset(i)),e&&this.fields.isDateField(t)?new Date(i):i)}_readAttributes(){return this._current.attributes}copyInto(t){super.copyInto(t),t._featureIndex=this._featureIndex,t._transform=this._transform,t._fieldsIndex=this._fieldsIndex}}class Xl extends Xc{constructor(t,e){super(t),this.bins=new Map,this.done=!1,this._store=e}reset(){this.destroy(),this.bins.clear(),this.done=!1,this.handledChunks.clear()}destroy(){const t=this.subscription.tile.key.level;for(const e of this.bins.values()){const s=e.cachedFeature?.objectId;null!=s&&this._store.releaseDisplayIdForObjectId(`${s}.${t}`)}}*featuresWorldSpace(){for(const t of this.bins.values()){const e=t.cachedFeature;if(e){const t=e.clone();(0,zc.Ij)(t.geometry,t.geometry,!1,!1,this.subscription.tile.transform),yield t}}}getGeohashBounds(t,e){const s=this.subscription.tile;return(0,Dc.wt)(s.extent,s.resolution,e,t)}}class Yl extends jc{static async create(t,e,s,i,r){const n=new gl({spatialReference:e}),o=t.fixedBinLevel,a=await Promise.all(t.fields.map((async t=>Uc.create(n,t)))),h=t.featureFilter?await Sl.create({geometryType:s.metadata.geometryType,hasM:!1,hasZ:!1,timeInfo:s.metadata.timeInfo,fieldsIndex:s.metadata.fieldsIndex,spatialReference:e,filterJSON:t.featureFilter}):null;return await(0,Bc.Qv)(e,V.c.WGS84),new Yl({fields:a,geohashLevel:o,spatialReference:e,featureFilter:h,timeZone:r},t.fields,s,i)}constructor(t,e,s,i){super(s,i,t.spatialReference,t.fields),this._indexOptions=t,this._metadata=new Tl({geometryType:"esriGeometryPolygon",objectIdField:"aggregateId",fields:e,globalIdField:null,spatialReference:s.metadata.spatialReference,subtypeField:null,subtypes:null,timeInfo:null,timeReferenceUnknownClient:null,typeIdField:null,types:null})}createState(t){return new Xl(t,this._attributeStore)}async*applyOverride(t){for(const t of this._sendStates.values())t.reset()}displayMap(t,e,s){const i=new Map(t.map((t=>[e(t),t]))),r=[];for(const t of this._sendStates.values())for(const e of t.featuresWorldSpace()){const{objectId:t,displayId:n}=e,o=i.get(t);if(null!=o){const e=s(n,o,t);r.push(e),i.delete(t)}}return r}getDisplayFeatures(t){const e=new Set(t),s=new Set,i=[];for(const t of this._sendStates.values())for(const r of t.featuresWorldSpace())e.has(r.displayId)&&!s.has(r.objectId)&&(r.geometry&&i.push({...(0,zc.G0)(r,this._metadata.geometryType,!1,!1),displayId:r.displayId}),s.add(r.objectId));return{features:[],aggregates:i}}getFeatureObjectIdsForAggregate(t){for(const e of this._sendStates.values())for(const s of e.bins.values())if(s.id===t)return Array.from(s.objectIds);return[]}async*updateChunks(){if(this._source.chunks().length)for(const t of this._sendStates.values())yield*this._update(t,this._source)}forEachAggregateWorldSpace(t){for(const e of this._sendStates.values())for(const s of e.featuresWorldSpace())t(s)}async*_update(t,e){const{handledChunks:s,subscription:i,bins:r}=t,{spatialReference:n,geohashLevel:o}=this._indexOptions,a=i.tile;if(t.done)return;for(const i of e.chunks()){if(s.has(i.chunkId))continue;s.add(i.chunkId);const e=i.queryInfo;if("tileId"in e){const t=new p.c(e.tileId);if(t.level!==a.level||t.world!==a.key.world)continue}const h=i.getGeohashIndex(this._indexOptions),c=t.getGeohashBounds(n,o);null!=c&&h.putBins(r,c)}const h=[],c=i.tile.transform,l=i.tile.key.level;for(const t of r.values()){if(t.cachedFeature)t.cachedFeature.attributes=t.getAttributes();else{const e=t.getGeometry(this.spatialReference,c),s=new Lc._M(e,t.getAttributes(),null);e||(s.centroid=t.getGeometryCentroid(this.spatialReference,c)),s.objectId=t.id,s.displayId=this._attributeStore.createDisplayIdForObjectId(`${s.objectId}.${l}`),t.cachedFeature=s}h.push(t.cachedFeature)}this.events.emit("changed"),t.done=!e.updateTracking.updating;const u=Wl.fromOptimizedFeatures(h,this._metadata,c),d=u.getCursor(),_=t.subscription.tile.createArcadeEvaluationOptions(this._indexOptions.timeZone);for(;d.next();)this._attributeStore.setAttributeData(d.getDisplayId(),d,_);const f=new $c(t.subscription,u,[],t.done,{});yield f}}const jl=Math.PI/180;class Hl{static create(t){return new Hl(t.map((t=>function(t){switch(t.statisticType){case"min":return new Kl(t);case"max":return new Zl(t);case"avg":return new Jl(t);case"avg_angle":return new tu(t);case"sum":case"count":return new Ql(t);case"mode":return new eu(t)}}(t))))}constructor(t){this._statistics=t}values(){return this._statistics.values()}insert(t,e){for(const s of this._statistics)s.insert(t,e)}merge(t){for(let e=0;e<this._statistics.length;e++){const s=this._statistics[e],i=t._statistics[e];if(s.field.name!==i.field.name)throw new Error("InternalError: Tried to merge incompatible statistics");s.merge(i)}}clone(){return new Hl(this._statistics.map((t=>t.clone())))}}class $l{constructor(t){this.field=t}insert(t,e){if(!this.field.computed)return;const s=this.field.computed.read(t,e);Jc(s)||this._insertValue(s)}}class Kl extends $l{constructor(){super(...arguments),this.type="min",this.value=Number.MAX_VALUE}_insertValue(t){this.value=Math.min(this.value,t)}merge(t){this.value=Math.min(this.value,t.value)}clone(){const t=new Kl(this.field);return t.value=this.value,t}}class Zl extends $l{constructor(){super(...arguments),this.type="max",this.value=Number.MIN_VALUE}_insertValue(t){this.value=Math.max(this.value,t)}merge(t){this.value=Math.max(this.value,t.value)}clone(){const t=new Zl(this.field);return t.value=this.value,t}}class Ql extends $l{constructor(){super(...arguments),this.type="sum",this.value=0}_insertValue(t){this.value+=t}merge(t){this.value+=t.value}clone(){const t=new Ql(this.field);return t.value=this.value,t}}class Jl extends $l{constructor(){super(...arguments),this.type="avg",this._total=0,this._count=0}get value(){return this._total/this._count}_insertValue(t){this._total+=t,this._count+=1}merge(t){this._total+=t._total,this._count+=t._count}clone(){const t=new Jl(this.field);return t._total=this._total,t._count=this._count,t}}class tu extends $l{constructor(){super(...arguments),this.type="avg_angle",this._x=0,this._y=0,this._count=0}get value(){const t=this._x/this._count,e=this._y/this._count,s=180/Math.PI;return Math.atan2(e,t)*s}_insertValue(t){this._x=this._x+Math.cos(t*jl),this._y=this._y+Math.sin(t*jl),this._count+=1}merge(t){this._x+=t._x,this._y+=t._y,this._count+=t._count}clone(){const t=new tu(this.field);return t._x=this._x,t._y=this._y,t._count=this._count,t}}class eu extends $l{constructor(){super(...arguments),this._frequencies=new Map}get value(){let t,e=0;for(const[s,i]of this._frequencies.entries())i>e&&(e=i,t=s);return t}_insertValue(t){const e=this._frequencies.get(t);null!=e?this._frequencies.set(t,e+1):this._frequencies.set(t,1)}merge(t){for(const[e,s]of t._frequencies.entries()){const t=this._frequencies.get(e);null!=t?this._frequencies.set(e,t+s):this._frequencies.set(e,s)}}clone(){const t=new eu(this.field);return t._frequencies=new Map(this._frequencies),t}}class su{static createId(t,e){return`${t}.${e}`}static create(t,e,s,i){return new su(t,e,Hl.create(s),i)}constructor(t,e,s,i){this.gridX=t,this.gridY=e,this._statistics=s,this._worldUnitsPerCell=i,this._count=0,this._xWorldTotal=0,this._yWorldTotal=0,this._objectIds=new Set}get id(){return su.createId(this.gridX,this.gridY)}get count(){return this._count}get statistics(){return this._statistics}get objectIds(){return this._objectIds}get firstObjectId(){return this._objectIds.values().next().value}get centroidXWorld(){return this._xWorldTotal/this._count}get centroidYWorld(){return this._yWorldTotal/this._count}clone(){const t=new su(this.gridX,this.gridY,this._statistics.clone(),this._worldUnitsPerCell);return t._count=this._count,t._xWorldTotal=this._xWorldTotal,t._yWorldTotal=this._yWorldTotal,t._firstFeatureAttributes=this._firstFeatureAttributes,t._objectIds=new Set(this._objectIds),t}insert(t,e,s,i){0===this._count?this._firstFeatureAttributes=t.readAttributes():this._firstFeatureAttributes=null,this._count+=1,this._xWorldTotal+=s,this._yWorldTotal+=i,this._statistics.insert(t,e),this._objectIds.add(t.getObjectId())}merge(t){if(0!==t._count){this._count+=t._count,this._firstFeatureAttributes=t._firstFeatureAttributes,this._xWorldTotal+=t._xWorldTotal,this._yWorldTotal+=t._yWorldTotal,this._statistics.merge(t._statistics);for(const e of t._objectIds.values())this._objectIds.add(e)}}getCentroidX(t){return null==t?this.centroidXWorld:(0,zc.uY)(t,this.centroidXWorld)}getCentroidY(t){return null==t?this.centroidYWorld:(0,zc.mk)(t,this.centroidYWorld)}getCentroid(t){const e=new ft.c([],[this.centroidXWorld,this.centroidYWorld]);if(null!=t){const s=new ft.c;return(0,zc.iC)(s,e,!1,!1,"esriGeometryPoint",t)}return e}getGeometricCentroid(t){const e=this.gridX*this._worldUnitsPerCell+.5*this._worldUnitsPerCell,s=this.gridY*this._worldUnitsPerCell+.5*this._worldUnitsPerCell,i=new ft.c([],[e,s]);if(null!=t){const e=new ft.c;return(0,zc.iC)(e,i,!1,!1,"esriGeometryPoint",t)}return i}getAttributes(){const t={aggregateId:this.id};for(const e of this._statistics.values())t[e.field.name]=e.value;return null!=this._firstFeatureAttributes?{...t,...this._firstFeatureAttributes}:t}}var iu=s(24296);function ru(t,e){return(0,iu.k8)(t)*iu.Co*96/e}class nu{constructor(t){this._options=t,this._cells=new Map,this._pixelsPerMapUnit=ru(t.spatialReference,t.scale)}insert(t,e){const s=t.getCursor(),i={$view:{scale:this._options.scale,timeZone:this._options.timeZone}};for(;s.next();)this._insertFeature(s,i,e)}putCellsInBounds(t,e){const[s,i,r,n]=e,o=Math.floor(s*this._pixelsPerMapUnit/this._options.cellSize),a=Math.floor(i*this._pixelsPerMapUnit/this._options.cellSize),h=Math.ceil(r*this._pixelsPerMapUnit/this._options.cellSize),c=Math.ceil(n*this._pixelsPerMapUnit/this._options.cellSize);for(let e=a;e<=c;e++)for(let s=o;s<=h;s++){const i=`${s}.${e}`,r=this._cells.get(i);if(!r)continue;const n=t.get(r.id);n?r&&!t.has(r.id)&&n.merge(r):t.set(r.id,r.clone())}}putCells(t){for(const e of this._cells.values()){const s=t.get(e.id);s?s.merge(e):t.set(e.id,e.clone())}}_insertFeature(t,e,s){const{featureFilter:i}=this._options;if(null!==i&&!i.check(t))return;let r=0,n=0;if("esriGeometryPoint"===t.geometryType)r=t.readXWorldSpace(),n=t.readYWorldSpace();else{if(s){const e=t.readCentroidForDisplay();if(null==e)return;const[s,i]=e.coords;if(s<0||s>B.gT||i<0||i>B.gT)return}const e=t.readCentroidWorldSpace();if(null==e)return;r=e.coords[0],n=e.coords[1]}const o=r*this._pixelsPerMapUnit,a=n*this._pixelsPerMapUnit,h=Math.floor(o/this._options.cellSize),c=Math.floor(a/this._options.cellSize);this._getCellOrCreate(h,c).insert(t,e,r,n)}_getCellOrCreate(t,e){const s=su.createId(t,e);let i=this._cells.get(s);if(!i){const r=1*this._options.cellSize/this._pixelsPerMapUnit;i=su.create(t,e,this._options.fields,r),this._cells.set(s,i)}return i}}class ou{constructor(t,e){this.inner=t,this.displayId=e}}class au extends Xc{constructor(t){super(t),this.didSend=!1,this.done=!1}}class hu{constructor(t,e,s,i,r){this._level=t,this._scale=e,this._indexOptions=s,this._clusterRadius=i,this._store=r,this._cells=new Map,this._handledChunks=new Set,this._statistics=new Map,this._clusters=new Map}destroy(){this._clearClusters()}_clearClusters(){for(const t of this._clusters.values())this._store.releaseDisplayIdForObjectId(t.inner.id);this._clusters.clear()}*aggregatesWorldSpace(){for(const t of this._clusters.values()){const e=t.inner.getCentroid(null),s=new Lc._M(e,t.inner.getAttributes(),null);s.objectId=t.inner.id,s.displayId=t.displayId,yield s}}clusters(){return this._clusters.values()}updateChunks(t,e){let s=!1;for(const e of t){const t=e.queryInfo;"tileId"in t&&new p.c(t.tileId).level!==this._level||this._handledChunks.has(e.normalizedChunkId)||(this._handledChunks.add(e.normalizedChunkId),s=!0,e.getGridIndex({...this._indexOptions,scale:this._scale}).putCells(this._cells))}const i={xMin:1/0,yMin:1/0,xMax:-1/0,yMax:-1/0},r=ru(this._indexOptions.spatialReference,this._scale),n=this._indexOptions.cellSize;for(const{subscription:t}of e){const e=t.tile.bounds,s=Math.floor(e[0]*r/n),o=Math.floor(e[1]*r/n),a=Math.ceil(e[2]*r/n),h=Math.ceil(e[3]*r/n);i.xMin=Math.min(i.xMin,s),i.yMin=Math.min(i.yMin,o),i.xMax=Math.max(i.xMax,a),i.yMax=Math.max(i.yMax,h)}return null!=this._lastCellBounds&&i.xMin===this._lastCellBounds.xMin&&i.yMin===this._lastCellBounds.yMin&&i.yMin===this._lastCellBounds.yMin&&i.yMax===this._lastCellBounds.yMax||(s=!0,this._lastCellBounds=i),s&&this._clusterCells(i),s}async updateStatistics(t){let e=!1;for(const t of this._clusters.values())t.inner.count>1&&(e=this._updateAggregateStatistics(this._statistics,t.inner)||e);if(e){const e=Array.from(this._statistics.entries()).map((([t,e])=>({fieldName:t,minValue:e.minValue,maxValue:e.maxValue})));await t.container.updateStatistics(this._level,e)}}createAggregateFeatures(t,e){const s=t.subscription,i=[],r=s.tile.transform;for(const t of this._clusters.values()){let e=t.inner.getCentroidX(r);const n=t.inner.getCentroidY(r),o=s.tile.lod,a=o.wrap?o.worldSize[0]:null,h=1===t.inner.count?t.inner.firstObjectId:t.inner.id,c=t.displayId;if(null!=a)if(1===a){const s=new ft.c([],[e,n]),r=new Lc._M(s,t.inner.getAttributes(),null);r.geometry.coords[0]-=B.gT,r.objectId=h,r.displayId=c,i.push(r);const o=new ft.c([],[e,n]),a=new Lc._M(o,t.inner.getAttributes(),null);a.geometry.coords[0]+=B.gT,a.objectId=h,a.displayId=c,i.push(a)}else e>B.gT+B.gT/2?e-=a*B.gT:e<-B.gT/2&&(e+=a*B.gT);if(e<B.gT+128&&e>=-128&&n<B.gT+128&&n>=-128){const s=new ft.c([],[e,n]),r=new Lc._M(s,t.inner.getAttributes(),null);r.objectId=h,r.displayId=c,i.push(r)}}return Wl.fromOptimizedFeatures(i,e,s.tile.transform)}_clusterCells(t){let e=Array.from(this._cells.values());e=e.sort(((t,e)=>e.count-t.count));const s=[];for(const t of this._clusters.values())s.push(t.inner.id);this._clusters.clear();const i=this._clusterRadius*(1/ru(this._indexOptions.spatialReference,this._scale)),r=1+this._clusterRadius/this._indexOptions.cellSize,n=new Set;for(const s of e){if(n.has(s.id))continue;if(s.gridX<t.xMin||s.gridX>t.xMax||s.gridY<t.yMin||s.gridY>t.yMax)continue;const e=this._store.createDisplayIdForObjectId(s.id),o=new ou(s.clone(),e);n.add(s.id),this._clusters.set(s.id,o);const a=s.centroidXWorld,h=s.centroidYWorld;for(let t=s.gridY-r;t<=s.gridY+r;t++)for(let e=s.gridX-r;e<=s.gridX+r;e++){if(t===s.gridY&&e===s.gridX)continue;const r=this._cells.get(su.createId(e,t));if(!r||n.has(r.id))continue;const c=Math.abs(r.centroidXWorld-a),l=Math.abs(r.centroidYWorld-h);c<i&&l<i&&(o.inner.merge(r),n.add(r.id))}}for(const t of s)this._store.releaseDisplayIdForObjectId(t)}_updateAggregateStatistics(t,e){let s=!1;for(const i of e.statistics.values()){if("esriFieldTypeString"===i.field.type)continue;const e=i.value,r=i.field,n=t.get(r.name);if(n){const{minValue:t,maxValue:i}=n,r=Math.min(n.minValue,e),o=Math.max(n.maxValue,e);t===r&&i===o||(n.minValue=r,n.maxValue=o,s=!0)}else t.set(r.name,{minValue:e,maxValue:e}),s=!0}return s}}class cu extends jc{static async create(t,e,s,i,r,n){const o=new gl({spatialReference:s}),a={fields:await Promise.all(e.fields.map((async t=>Uc.create(o,t)))),spatialReference:s,featureFilter:e.featureFilter?await Sl.create({geometryType:i.metadata.geometryType,hasM:!1,hasZ:!1,timeInfo:i.metadata.timeInfo,fieldsIndex:i.metadata.fieldsIndex,spatialReference:s,filterJSON:e.featureFilter}):null,cellSize:e.clusterRadius/4,timeZone:n};return new cu(t,e.clusterRadius,a,e.fields,i,r)}constructor(t,e,s,i,r,n){super(r,n,s.spatialReference,s.fields),this._connection=t,this._clusterRadius=e,this._indexOptions=s,this._cellsPerScale=new Map,this._metadata=new Tl({geometryType:"esriGeometryPoint",objectIdField:"aggregateId",fields:[...i,...this._source.metadata.fieldsIndex.fields,{name:"aggregateId",alias:"aggregateId",type:"esriFieldTypeOID"}],globalIdField:null,spatialReference:r.metadata.spatialReference,subtypeField:null,subtypes:null,timeInfo:null,timeReferenceUnknownClient:null,typeIdField:null,types:null})}get enablePixelBuffering(){return!1}invalidate(){super.invalidate();for(const t of this._cellsPerScale.values())t.destroy();this._cellsPerScale.clear()}onSubscribe(t){super.onSubscribe(t),this._requiredLevel=t.tile.level,this._requiredScale=t.tile.scale}createState(t){return new au(t)}async*applyOverride(t){for(const t of this._cellsPerScale.values())t.destroy();this._cellsPerScale.clear();for(const t of this._sendStates.values())t.done=!1}displayMap(t,e,s){const i=new Map(t.map((t=>[e(t),t]))),r=[],n=this._getClusterState(this._requiredLevel,this._requiredScale);for(const t of n.clusters()){const e=i.get(t.inner.id);if(null==e){if(1===t.inner.count){const e=i.get(t.inner.firstObjectId);if(null!=e){const n=s(t.displayId,e,t.inner.firstObjectId);r.push(n),i.delete(t.inner.firstObjectId)}}}else{const n=s(t.displayId,e,t.inner.id);r.push(n),i.delete(t.inner.id)}}return r}getDisplayFeatures(t){const e=new Set(t),s=new Set,i=[],r=[],n=this._getClusterState(this._requiredLevel,this._requiredScale);for(const t of n.aggregatesWorldSpace())if(e.has(t.displayId)&&!s.has(t.displayId)){const e=(0,zc.G0)(t,this._metadata.geometryType,!1,!1);if(s.add(t.displayId),1===e.attributes.cluster_count){i.push({...e,displayId:t.displayId});continue}r.push({...e,displayId:t.displayId})}return{features:i,aggregates:r}}getFeatureObjectIdsForAggregate(t){const e=this._getClusterState(this._requiredLevel,this._requiredScale);for(const s of e.clusters())if(s.inner.id===t)return Array.from(s.inner.objectIds);return[]}async*updateChunks(){const t=this._source.chunks();if(!t.length)return;const e=this._getClusterState(this._requiredLevel,this._requiredScale),s=Array.from(this._sendStates.values()).filter((t=>t.subscription.tile.level===this._requiredLevel));if(e.updateChunks(t,s)||!this._source.updateTracking.updating)for(const t of s)t.subscription.tile.level===this._requiredLevel&&(t.didSend=!1,t.done=!1);const i=Array.from(this._sendStates.values()).filter((t=>t.done)).map((t=>t.subscription.tile.key)),r=new Set(i);for(const t of this._sendStates.values()){if(this._source.updateTracking.updating){if(i.some((e=>e.containsChild(t.subscription.tile.key))))continue;if(t.subscription.tile.key.getChildKeys().every((t=>r.has(t))))continue}t.didSend||t.subscription.tile.level!==this._requiredLevel||(t.didSend=!0,yield*this._update(t,e,this._source))}await e.updateStatistics(this._connection)}forEachAggregateWorldSpace(t){if(null==this._requiredLevel||null==this._requiredScale)return;const e=this._getClusterState(this._requiredLevel,this._requiredScale);for(const s of e.aggregatesWorldSpace())t(s)}_getClusterState(t,e){if(null==t||null==e)throw new Error("InternalError: Level and scale must be defined");let s=this._cellsPerScale.get(e);return s||(s=new hu(t,e,this._indexOptions,this._clusterRadius,this._attributeStore),this._cellsPerScale.set(e,s)),s}async*_update(t,e,s){if(t.done)return;const i=e.createAggregateFeatures(t,this._metadata);this.events.emit("changed"),t.done=!s.updateTracking.updating;const r=i.getCursor(),n=t.subscription.tile.createArcadeEvaluationOptions(this._indexOptions.timeZone);for(;r.next();)this._attributeStore.setAttributeData(r.getDisplayId(),r,n);const o=new Hc(t.subscription,i,!0,t.done,{});yield o}}var lu=s(85304);function uu(t,e){if(!(this instanceof uu))return new uu(t,e);this._maxEntries=Math.max(4,t||9),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),e&&("function"==typeof e?this.toBBox=e:this._initFormat(e)),this.clear()}function du(t,e,s){if(!s)return e.indexOf(t);for(var i=0;i<e.length;i++)if(s(t,e[i]))return i;return-1}function pu(t,e){_u(t,0,t.children.length,e,t)}function _u(t,e,s,i,r){r||(r=Iu(null)),r.minX=1/0,r.minY=1/0,r.maxX=-1/0,r.maxY=-1/0;for(var n,o=e;o<s;o++)n=t.children[o],fu(r,t.leaf?i(n):n);return r}function fu(t,e){return t.minX=Math.min(t.minX,e.minX),t.minY=Math.min(t.minY,e.minY),t.maxX=Math.max(t.maxX,e.maxX),t.maxY=Math.max(t.maxY,e.maxY),t}function mu(t,e){return t.minX-e.minX}function gu(t,e){return t.minY-e.minY}function yu(t){return(t.maxX-t.minX)*(t.maxY-t.minY)}function xu(t){return t.maxX-t.minX+(t.maxY-t.minY)}function bu(t,e){return(Math.max(e.maxX,t.maxX)-Math.min(e.minX,t.minX))*(Math.max(e.maxY,t.maxY)-Math.min(e.minY,t.minY))}function wu(t,e){var s=Math.max(t.minX,e.minX),i=Math.max(t.minY,e.minY),r=Math.min(t.maxX,e.maxX),n=Math.min(t.maxY,e.maxY);return Math.max(0,r-s)*Math.max(0,n-i)}function vu(t,e){return t.minX<=e.minX&&t.minY<=e.minY&&e.maxX<=t.maxX&&e.maxY<=t.maxY}function Su(t,e){return e.minX<=t.maxX&&e.minY<=t.maxY&&e.maxX>=t.minX&&e.maxY>=t.minY}function Iu(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Tu(t,e,s,i,r){for(var n,o=[e,s];o.length;)(s=o.pop())-(e=o.pop())<=i||(n=e+Math.ceil((s-e)/i/2)*i,(0,lu.q)(t,n,e,s,r),o.push(e,n,n,s))}uu.prototype={all:function(){return this._all(this.data,[])},search:function(t){var e=this.data,s=[],i=this.toBBox;if(!Su(t,e))return s;for(var r,n,o,a,h=[];e;){for(r=0,n=e.children.length;r<n;r++)o=e.children[r],Su(t,a=e.leaf?i(o):o)&&(e.leaf?s.push(o):vu(t,a)?this._all(o,s):h.push(o));e=h.pop()}return s},collides:function(t){var e=this.data,s=this.toBBox;if(!Su(t,e))return!1;for(var i,r,n,o,a=[];e;){for(i=0,r=e.children.length;i<r;i++)if(n=e.children[i],Su(t,o=e.leaf?s(n):n)){if(e.leaf||vu(t,o))return!0;a.push(n)}e=a.pop()}return!1},load:function(t){if(!t||!t.length)return this;if(t.length<this._minEntries){for(var e=0,s=t.length;e<s;e++)this.insert(t[e]);return this}var i=this._build(t.slice(),0,t.length-1,0);if(this.data.children.length)if(this.data.height===i.height)this._splitRoot(this.data,i);else{if(this.data.height<i.height){var r=this.data;this.data=i,i=r}this._insert(i,this.data.height-i.height-1,!0)}else this.data=i;return this},insert:function(t){return null!=t&&this._insert(t,this.data.height-1),this},clear:function(){return this.data=Iu([]),this},remove:function(t,e){if(null==t)return this;for(var s,i,r,n,o=this.data,a=this.toBBox(t),h=[],c=[];o||h.length;){if(o||(o=h.pop(),i=h[h.length-1],s=c.pop(),n=!0),o.leaf&&-1!==(r=du(t,o.children,e)))return o.children.splice(r,1),h.push(o),this._condense(h),this;n||o.leaf||!vu(o,a)?i?(s++,o=i.children[s],n=!1):o=null:(h.push(o),c.push(s),s=0,i=o,o=o.children[0])}return this},toBBox:function(t){return t},compareMinX:mu,compareMinY:gu,toJSON:function(){return this.data},fromJSON:function(t){return this.data=t,this},_all:function(t,e){for(var s=[];t;)t.leaf?e.push.apply(e,t.children):s.push.apply(s,t.children),t=s.pop();return e},_build:function(t,e,s,i){var r,n=s-e+1,o=this._maxEntries;if(n<=o)return pu(r=Iu(t.slice(e,s+1)),this.toBBox),r;i||(i=Math.ceil(Math.log(n)/Math.log(o)),o=Math.ceil(n/Math.pow(o,i-1))),(r=Iu([])).leaf=!1,r.height=i;var a,h,c,l,u=Math.ceil(n/o),d=u*Math.ceil(Math.sqrt(o));for(Tu(t,e,s,d,this.compareMinX),a=e;a<=s;a+=d)for(Tu(t,a,c=Math.min(a+d-1,s),u,this.compareMinY),h=a;h<=c;h+=u)l=Math.min(h+u-1,c),r.children.push(this._build(t,h,l,i-1));return pu(r,this.toBBox),r},_chooseSubtree:function(t,e,s,i){for(var r,n,o,a,h,c,l,u;i.push(e),!e.leaf&&i.length-1!==s;){for(l=u=1/0,r=0,n=e.children.length;r<n;r++)h=yu(o=e.children[r]),(c=bu(t,o)-h)<u?(u=c,l=h<l?h:l,a=o):c===u&&h<l&&(l=h,a=o);e=a||e.children[0]}return e},_insert:function(t,e,s){var i=this.toBBox,r=s?t:i(t),n=[],o=this._chooseSubtree(r,this.data,e,n);for(o.children.push(t),fu(o,r);e>=0&&n[e].children.length>this._maxEntries;)this._split(n,e),e--;this._adjustParentBBoxes(r,n,e)},_split:function(t,e){var s=t[e],i=s.children.length,r=this._minEntries;this._chooseSplitAxis(s,r,i);var n=this._chooseSplitIndex(s,r,i),o=Iu(s.children.splice(n,s.children.length-n));o.height=s.height,o.leaf=s.leaf,pu(s,this.toBBox),pu(o,this.toBBox),e?t[e-1].children.push(o):this._splitRoot(s,o)},_splitRoot:function(t,e){this.data=Iu([t,e]),this.data.height=t.height+1,this.data.leaf=!1,pu(this.data,this.toBBox)},_chooseSplitIndex:function(t,e,s){var i,r,n,o,a,h,c,l;for(h=c=1/0,i=e;i<=s-e;i++)o=wu(r=_u(t,0,i,this.toBBox),n=_u(t,i,s,this.toBBox)),a=yu(r)+yu(n),o<h?(h=o,l=i,c=a<c?a:c):o===h&&a<c&&(c=a,l=i);return l},_chooseSplitAxis:function(t,e,s){var i=t.leaf?this.compareMinX:mu,r=t.leaf?this.compareMinY:gu;this._allDistMargin(t,e,s,i)<this._allDistMargin(t,e,s,r)&&t.children.sort(i)},_allDistMargin:function(t,e,s,i){t.children.sort(i);var r,n,o=this.toBBox,a=_u(t,0,e,o),h=_u(t,s-e,s,o),c=xu(a)+xu(h);for(r=e;r<s-e;r++)n=t.children[r],fu(a,t.leaf?o(n):n),c+=xu(a);for(r=s-e-1;r>=e;r--)n=t.children[r],fu(h,t.leaf?o(n):n),c+=xu(h);return c},_adjustParentBBoxes:function(t,e,s){for(var i=s;i>=0;i--)fu(e[i],t)},_condense:function(t){for(var e,s=t.length-1;s>=0;s--)0===t[s].children.length?s>0?(e=t[s-1].children).splice(e.indexOf(t[s]),1):this.clear():pu(t[s],this.toBBox)},_initFormat:function(t){var e=["return a"," - b",";"];this.compareMinX=new Function("a","b",e.join(t[0])),this.compareMinY=new Function("a","b",e.join(t[1])),this.toBBox=new Function("a","return {minX: a"+t[0]+", minY: a"+t[1]+", maxX: a"+t[2]+", maxY: a"+t[3]+"};")}};class Pu{static fromReader(t){const e=[],s=t.copy(),i=(0,Vc.Su)();for(;s.next();)s.getBounds(i)&&e.push(s.getIndex());const r=uu(9,(t=>(s.setIndex(t),{minX:s.getBoundsXMin(),minY:s.getBoundsYMin(),maxX:s.getBoundsXMax(),maxY:s.getBoundsYMax()})));return r.load(e),new Pu(r)}constructor(t){this._index=t}search(t){const e={minX:t[0],minY:t[1],maxX:t[2],maxY:t[3]};return this._index.search(e)}}class Mu{static create(t,e,s,i){const r=Hl.create(t),n=new Array(32);for(let t=0;t<n.length;t++)n[t]=null;return new Mu(r,e,s,i,n)}constructor(t,e,s,i,r){this._statistics=t,this.xNode=e,this.yNode=s,this.depth=i,this.children=r,this._objectIds=new Set,this._count=0,this._xWorldTotal=0,this._yWorldTotal=0,this._xGeohashTotal=0,this._yGeohashTotal=0,this.next=null}get id(){return`${this.xNode}.${this.yNode}`}get objectIds(){return this._objectIds}clone(){const t=new Mu(this._statistics.clone(),this.xNode,this.yNode,this.depth,this.children);return t._count=this._count,t._xWorldTotal=this._xWorldTotal,t._yWorldTotal=this._yWorldTotal,t._xGeohashTotal=this._xGeohashTotal,t._yGeohashTotal=this._yGeohashTotal,t.next=this.next,t.cachedFeature=this.cachedFeature,t._objectIds=new Set(this._objectIds),t}insert(t,e,s,i,r,n){this._count+=1,this._xWorldTotal+=e,this._yWorldTotal+=s,this._xGeohashTotal+=i,this._yGeohashTotal+=r,this._statistics.insert(t,n),this._objectIds.add(t.getObjectId())}merge(t){if(0!==t._count){this._count+=t._count,this._xWorldTotal+=t._xWorldTotal,this._yWorldTotal+=t._yWorldTotal,this._xGeohashTotal+=t._xWorldTotal,this._yGeohashTotal+=t._yWorldTotal,this._statistics.merge(t._statistics);for(const e of t._objectIds.values())this._objectIds.add(e)}}getGeometry(t,e){const s=this._getLngLatBounds(),[i,r,n,o]=s,a=(0,Bc.yU)({rings:[[[i,r],[i,o],[n,o],[n,r],[i,r]]]},V.c.WGS84,t),h=(0,zc.Uh)(new ft.c,a,!1,!1);return null!=e?(0,zc.iC)(new ft.c,h,!1,!1,"esriGeometryPolygon",e,!1,!1):h}getGeometryCentroid(t,e){const s=this._getLngLatBounds(),[i,r,n,o]=s,a=(0,Bc.yU)({x:(i+n)/2,y:(r+o)/2},V.c.WGS84,t),h=(0,zc.M$)(new ft.c,a);return null!=e?(0,zc.iC)(new ft.c,h,!1,!1,"esriGeometryPoint",e,!1,!1):h}getAttributes(){const t={aggregateId:this.id};for(const e of this._statistics.values())t[e.field.name]=e.value;return t.aggregateCount=this._count,t}_getLngLatBounds(){const t=this.depth,e=Math.ceil(t/2),s=Math.floor(t/2),i=30-(3*e+2*s),r=30-(2*e+3*s),n=this.xNode<<i,o=this.yNode<<r;return(0,Dc.S8)({geohashX:n,geohashY:o},this.depth)}}class Eu{constructor(t){this._fields=t,this._root=Mu.create(this._fields,0,0,0)}destroy(){}insert(t,e,s,i,r,n,o){let a=this._root,h=0,c=0,l=0;for(;null!==a;){if(a.insert(t,e,s,i,r,o),h>=n)return;const u=Math.ceil((h+1)/2),d=Math.floor((h+1)/2),p=1-h%2,_=30-(3*u+2*d),f=30-(2*u+3*d),m=(i&7*p+3*(1-p)<<_)>>_,g=(r&3*p+7*(1-p)<<f)>>f,y=m+g*(8*p+4*(1-p));c=c<<3*p+2*(1-p)|m,l=l<<2*p+3*(1-p)|g,null==a.children[y]&&(a.children[y]=Mu.create(this._fields,c,l,h+1)),h+=1,a=a.children[y]}}putBins(t,e){for(const s of this.getNodes(e)){const e=t.get(s.id);e?e.merge(s):t.set(s.id,s.clone())}}getNodes(t){const e=[],{geohashBounds:s,level:i}=t;let r=this._root;for(;null!==r;){const t=r.depth,n=r.xNode,o=r.yNode;if(t>=i){e.push(r),r=r.next;continue}const a=Math.ceil((t+1)/2),h=Math.floor((t+1)/2),c=1-t%2,l=30-(3*a+2*h),u=30-(2*a+3*h),d=~((1<<l)-1),p=~((1<<u)-1),_=(s.xLL&d)>>l,f=(s.yLL&p)>>u,m=(s.xTR&d)>>l,g=(s.yTR&p)>>u,y=n<<3*c+2*(1-c),x=o<<2*c+3*(1-c),b=y+8*c+4*(1-c),w=x+4*c+8*(1-c),v=Math.max(y,_),S=Math.max(x,f),I=Math.min(b,m),T=Math.min(w,g);let P=null,M=null;for(let t=S;t<=T;t++)for(let e=v;e<=I;e++){const s=e-y+(t-x)*(8*c+4*(1-c)),i=r.children[s];i&&(P||(P=i,P.next=r.next),M&&(M.next=i),M=i,i.next=r.next)}r=P||r.next}return e}}class Cu{constructor(t){this._options=t,this._tree=new Eu(t.fields)}insert(t,e){const s=t.getCursor(),i={$view:{scale:0,timeZone:this._options.timeZone}};for(;s.next();)this._insertFeature(s,i,e)}putBins(t,e){this._tree.putBins(t,e)}_insertFeature(t,e,s){const{featureFilter:i,geohashLevel:r,spatialReference:n}=this._options;if(null!==i&&!i.check(t))return;let o=0,a=0;if("esriGeometryPoint"===t.geometryType)o=t.readXWorldSpace(),a=t.readYWorldSpace();else{if(s){const e=t.readCentroidForDisplay();if(null==e)return;const[s,i]=e.coords;if(s<0||s>B.gT||i<0||i>B.gT)return}const e=t.readCentroidWorldSpace();if(null==e)return;o=e.coords[0],a=e.coords[1]}const h=(0,Dc.i2)(o,a,r,n);h&&this._tree.insert(t,o,a,h[0],h[1],r,e)}}class ku extends ql{static from(t,e){return new ku(t.copy(),e)}constructor(t,e){super(t.metadata),this._currentIndex=-1,this._displayTranslationX=0,this._displayTranslationY=0,this._displayScaleX=1,this._displayScaleY=1,this._reader=t,this._indices=e,this._isPoint="esriGeometryPoint"===t.geometryType}setTransformForDisplay(t){const e=this._reader.getInTransform();if(null==e){const[e,s]=t.scale,[i,r]=t.translate;return this._displayTranslationX=-i/e,this._displayScaleX=1/e,this._displayTranslationY=r/s,this._displayScaleY=1/-s,void(this._displayTransform=t)}const[s,i]=e.scale,[r,n]=e.translate,[o,a]=t.scale,[h,c]=t.translate;if(this._displayScaleX=s/o,this._displayTranslationX=(r-h)/o,this._displayScaleY=i/a,this._displayTranslationY=(-n+c)/a,!this._isPoint&&e)throw new Error("InternalError: Relative transformations not supported for non-point features");this._displayTransform=t}getInTransform(){return this._reader.getInTransform()}get fields(){return this._reader.fields}get hasNext(){return this._currentIndex+1<this._indices.length}getSize(){return this._indices.length}getCursor(){return this.copy()}copy(){const t=new ku(this._reader.copy(),this._indices);return t._currentIndex=this._currentIndex,t._displayTransform=this._displayTransform,t._displayTranslationX=this._displayTranslationX,t._displayTranslationY=this._displayTranslationY,t._displayScaleX=this._displayScaleX,t._displayScaleY=this._displayScaleY,t}_nextIndex(){return++this._currentIndex<this._indices.length&&(this._reader.setIndex(this._indices[this._currentIndex]),!0)}next(){for(;this._nextIndex()&&!this._reader._getExists(););return this._currentIndex<this._indices.length}readXForDisplay(){return this._reader.readXForDisplay()*this._displayScaleX+this._displayTranslationX}readYForDisplay(){return this._reader.readYForDisplay()*this._displayScaleY+this._displayTranslationY}readGeometryForDisplay(){const t=this._reader.readGeometryForDisplay();if(!this._displayTransform)return t;const e=new ft.c;return(0,zc.iC)(e,t,this.hasZ,this.hasM,this.geometryType,this._displayTransform),e.deltaDecode()}readCentroidForDisplay(){const t=this._reader.readCentroidForDisplay()?.clone();if(t){const[e,s]=t.coords;t.coords[0]=e*this._displayScaleX+this._displayTranslationX,t.coords[1]=s*this._displayScaleY+this._displayTranslationY}return t}get geometryType(){return this._reader.geometryType}get hasFeatures(){return this._reader.hasFeatures}get exceededTransferLimit(){return this._reader.exceededTransferLimit}get hasZ(){return this._reader.hasZ}get hasM(){return this._reader.hasM}readAttribute(t,e=!1){return this._reader.readAttribute(t,e)}readAttributes(){return this._reader.readAttributes()}joinAttributes(t){return this._reader.joinAttributes(t)}getBounds(t){return this._reader.getBounds(t)}getAttributeHash(){return this._reader.getAttributeHash()}getObjectId(){return this._reader.getObjectId()}getDisplayId(){return this._reader.getDisplayId()}setDisplayId(t){return this._reader.setDisplayId(t)}setIndex(t){return this._reader.setIndex(t)}getIndex(){return this._reader.getIndex()}readXWorldSpace(){return this._reader.readXWorldSpace()}readYWorldSpace(){return this._reader.readYWorldSpace()}_readX(){return this._reader.readXForDisplay()}_readY(){return this._reader.readYForDisplay()}_readServerCentroid(){return this._reader._readServerCentroid()}readLegacyFeatureForDisplay(){return this._reader.readLegacyFeatureForDisplay()}readLegacyGeometryForDisplay(){return this._reader.readLegacyGeometryForDisplay()}readGeometryArea(){return this._reader.readGeometryArea()}readGeometryWorldSpace(){return this._reader.readGeometryWorldSpace()}_readGeometry(){return this._reader._readGeometry()}_readAttribute(t,e){throw new Error("Error: Should not be called. Underlying _reader should be used instead")}_readAttributes(){throw new Error("Error: Should not be called. Underlying _reader should be used instead")}readArcadeFeature(){return this._reader.readArcadeFeature()}geometry(){return this._reader.geometry()}field(t){return this.readAttribute(t,!0)}hasField(t){return this._reader.hasField(t)}setField(t,e){return this._reader.setField(t,e)}keys(){return this._reader.keys()}castToText(t=!1){return this._reader.castToText(t)}}class Fu{size(){return this.reader.getSize()}get fields(){return this.reader.fields}invalidate(){this._geohashIndex=null,this._geohashIndexHash=null,this._spatialIndex=null,this._gridIndex=null,this._gridIndexHash=null}queryFeaturesInBounds(t){const e=this._getSpatialIndex().search(t);return ku.from(this.reader,e)}getGeohashIndex(t){const e=JSON.stringify(t);return e!==this._geohashIndexHash&&(this._geohashIndexHash=e,this._geohashIndex=new Cu(t),this._geohashIndex.insert(this.reader,this.isTiled)),this._geohashIndex}getGridIndex(t){const e=JSON.stringify(t);return e!==this._gridIndexHash&&(this._gridIndexHash=e,this._gridIndex=new nu(t),this._gridIndex.insert(this.reader,this.isTiled)),this._gridIndex}_getSpatialIndex(){return this._spatialIndex||(this._spatialIndex=Pu.fromReader(this.reader)),this._spatialIndex}}class Au extends Fu{constructor(){super(...arguments),this.chunkId="override",this.normalizedChunkId="override",this.removed=new Set,this.overridenIds=new Set,this._features=[]}get reader(){return Wl.fromOptimizedFeatures(this._features,this._layerSchema??{fields:[]})}get queryInfo(){return{}}get first(){return!1}get end(){return!1}get isTiled(){return!1}applyOverrides(t){super.invalidate(),this._layerSchema||(this._layerSchema=t.reader.fullSchema());const{reader:e,removed:s}=t,i=[],r=new Set,n=e.getCursor(),o=new Set(s);for(this.overridenIds.clear();n.next();){const t=n.readOptimizedFeatureWorldSpace(),e=t.objectId;i.push(t),r.add(e),this.overridenIds.add(e),this.removed.delete(e)}for(const t of this._features){const e=t.objectId;o.has(e)||r.has(e)||(i.push(t),this.overridenIds.add(e))}this._features=i;for(const t of r.values())this.removed.delete(t);for(const t of s)this.removed.add(t),this.overridenIds.add(t)}getTileReader(t){if(!this._features.length)return null;const e=this.queryFeaturesInBounds(t.bounds);return e.setTransformForDisplay(t.transform),e}}class Ru extends Xc{}class Ou extends Yc{constructor(t,e,s){super(t,e),this._timeZone=s,this.handledChunks=new Set,this.handledChunksForIdCreation=new Set,this.handledChunksForAttributeData=new Set,this._streamLayerDeferredObjectIdsToRemove=[]}destroy(){super.destroy();for(const t of this._source.chunks())this._cleanupChunkIds(t)}invalidateAttributeData(){this.handledChunksForAttributeData.clear()}onSubscribe(t){super.onSubscribe(t),this._evalOptions=t.tile.createArcadeEvaluationOptions(this._timeZone)}createState(t){return new Ru(t)}get aggregateQueryEngine(){return null}displayMap(t,e,s){const i=new Map(t.map((t=>[e(t),t]))),r=[];for(const t of this._source.chunks()){const e=t.reader.getCursor();for(;e.next();){const t=e.getObjectId(),n=e.getDisplayId(),o=i.get(t);if(null!=o){const e=s(n,o,t);r.push(e),i.delete(t)}}}return r}getDisplayFeatures(t){const e=new Set(t),s=new Set,i=[];for(const t of this._source.chunks()){const r=t.reader.getCursor();for(;r.next();){const t=r.getObjectId(),n=r.getDisplayId();e.has(n)&&!s.has(t)&&(i.push({...r.readLegacyFeatureWorldSpace(),displayId:n}),s.add(t))}}return{features:i,aggregates:[]}}async*applyOverride(t){const e=[],s=t.reader.getCursor();for(;s.next();){const t=s.getObjectId();e.push(t);const i=this._attributeStore.createDisplayIdForObjectId(t);s.setDisplayId(i),this._attributeStore.setAttributeData(i,s,this._evalOptions)}const i=this.getDisplayIds(e),r=this.getDisplayIds(t.removed),n=new Au;n.applyOverrides(t);for(const t of this._sendStates.values())yield new $c(t.subscription,null,i,!1,n.queryInfo);for(const t of this._sendStates.values()){const e=n.getTileReader(t.subscription.tile);yield new $c(t.subscription,e,r,!1,n.queryInfo)}for(const e of t.removed)this._attributeStore.releaseDisplayIdForObjectId(e)}async*updateChunks(){if(this._source.chunks().length){await this._updateAttributeData();for(const t of this._sendStates.values())yield*this._update(t)}}removeChunks(t){for(const e of t)this.handledChunks.delete(e.chunkId),this.handledChunksForAttributeData.delete(e.chunkId),this._cleanupChunkIds(e)}afterUpdateChunks(){for(const t of this._streamLayerDeferredObjectIdsToRemove)this._attributeStore.releaseDisplayIdForObjectId(t);this._streamLayerDeferredObjectIdsToRemove=[]}_cleanupChunkIds(t){if(this.handledChunksForIdCreation.has(t.chunkId)){const e=t.reader.getCursor();for(;e.next();){const t=e.getObjectId();this._source.isStream?this._streamLayerDeferredObjectIdsToRemove.push(t):this._attributeStore.releaseDisplayIdForObjectId(t)}this.handledChunksForIdCreation.delete(t.chunkId)}}async _updateAttributeData(){for(const t of this._source.chunks()){const{chunkId:e,reader:s}=t;if(!this.handledChunksForIdCreation.has(e)){this.handledChunksForIdCreation.add(e);const t=s.getCursor();for(;t.next();){const e=this._attributeStore.createDisplayIdForObjectId(t.getObjectId());t.setDisplayId(e)}}}for(const t of this._source.chunks())if(!this.handledChunksForAttributeData.has(t.chunkId)){this.handledChunksForAttributeData.add(t.chunkId);const e=t.reader.getCursor();for(;e.next();){const t=e.getDisplayId();this._attributeStore.setAttributeData(t,e,this._evalOptions)}}}*_update(t){const{subscription:e,handledChunks:s}=t;for(const i of this._source.chunks()){const{chunkId:r}=i;if(s.has(r))continue;s.add(r);const n=i.getTileReader(e.tile);n&&(yield new Hc(t.subscription,n,!1,i.end,i.queryInfo))}}}class Nu{constructor(t){this.data=t,this._referenceCount=0}increment(){this._referenceCount+=1}decrement(){this._referenceCount-=1}empty(){return 0===this._referenceCount}}class Du{constructor(){this._freeIdsGenerationA=[],this._freeIdsGenerationB=[],this._idCounter=1,this._freeIds=this._freeIdsGenerationA,this._objectIdToDisplayId=new Map}createIdForObjectId(t){let e=this._objectIdToDisplayId.get(t);return e?e.increment():(e=new Nu((0|this._getFreeId())>>>0),e.increment(),this._objectIdToDisplayId.set(t,e)),e.data}releaseIdForObjectId(t){const e=this._objectIdToDisplayId.get(t);e&&(e.decrement(),e.empty()&&(this._objectIdToDisplayId.delete(t),this._freeIds.push(e.data)))}releaseAll(){for(const t of this._objectIdToDisplayId.values())this._freeIds.push(t.data);this._objectIdToDisplayId.clear()}incrementGeneration(){this._freeIds=this._freeIds===this._freeIdsGenerationA?this._freeIdsGenerationB:this._freeIdsGenerationA}_getFreeId(){return this._freeIds.length?this._freeIds.pop():this._idCounter++}}const zu=()=>C.c.getLogger("geoscene.views.layers.2d.features.support.AttributeStore"),Lu=(zu(),()=>null),Bu=(0,n.c)("geoscene-shared-array-buffer");(0,n.c)("geoscene-atomics");class Uu{constructor(t,e,s){this.size=0,this.texelSize=4,this.dirtyStart=0,this.dirtyEnd=0;const{pixelType:i,layout:r,textureOnly:n}=e;this.textureOnly=n||!1,this.pixelType=i,this.layout=r,this._resetRange(),this.size=t,this.isLocal=s,n||(this.data=this._initData(i,t))}get buffer(){return this.data?.buffer}unsetComponentAllTexels(t,e){const s=this.data;for(let i=0;i<this.size*this.size;i++)s[i*this.texelSize+t]&=~e;this.dirtyStart=0,this.dirtyEnd=this.size*this.size-1}setComponentAllTexels(t,e){const s=this.data;for(let i=0;i<this.size*this.size;i++)s[i*this.texelSize+t]|=255&e;this.dirtyStart=0,this.dirtyEnd=this.size*this.size-1}setComponent(t,e,s){const i=this.data;for(const r of s)i[r*this.texelSize+t]|=e,this.dirtyStart=Math.min(this.dirtyStart,r),this.dirtyEnd=Math.max(this.dirtyEnd,r)}setComponentTexel(t,e,s){this.data[s*this.texelSize+t]|=e,this.dirtyStart=Math.min(this.dirtyStart,s),this.dirtyEnd=Math.max(this.dirtyEnd,s)}unsetComponentTexel(t,e,s){this.data[s*this.texelSize+t]&=~e,this.dirtyStart=Math.min(this.dirtyStart,s),this.dirtyEnd=Math.max(this.dirtyEnd,s)}getData(t,e){const s=Nh(t);return this.data[s*this.texelSize+e]}setData(t,e,s){const i=Nh(t),r=1<<e;0!=(this.layout&r)?null!=this.data&&(this.data[i*this.texelSize+e]=s,this.dirtyStart=Math.min(this.dirtyStart,i),this.dirtyEnd=Math.max(this.dirtyEnd,i)):zu().error("mapview-attributes-store","Tried to set a value for a texel's readonly component")}expand(t){if(this.size=t,!this.textureOnly){const e=this._initData(this.pixelType,t),s=this.data;e.set(s),this.data=e}}toMessage(){const t=this.dirtyStart,e=this.dirtyEnd,s=this.texelSize;if(t>e)return null;this._resetRange();const i=!this.isLocal,r=this.pixelType,n=this.layout,o=this.data;return{start:t,end:e,data:i&&o.slice(t*s,(e+1)*s)||null,pixelType:r,layout:n}}_initData(t,e){const s=ArrayBuffer,r=function(t){switch(t){case pi.OK.UNSIGNED_BYTE:return Uint8Array;case pi.OK.UNSIGNED_SHORT_4_4_4_4:return Uint16Array;case pi.OK.FLOAT:return Float32Array;default:return void C.c.getLogger("geoscene.views.2d.engine.webgl.Utils").error(new i.c("webgl-utils",`Unable to handle type ${t}`))}}(t),n=new r(new s(e*e*4*r.BYTES_PER_ELEMENT));for(let t=0;t<n.length;t+=4)n[t+1]=255;return n}_resetRange(){this.dirtyStart=2147483647,this.dirtyEnd=0}}class Gu{constructor(t){this._client=t,this._filters=[],this._blocks=new Array,this._attributeComputeInfo=null,this._abortController=new AbortController,this._size=B.OO,this._idsToHighlight=new Map,this._referencesScale=!1,this._referencesGeometry=!1,this._initialized=!1,this.version=0,this._idGenerator=new Du,this._epoch=1}destroy(){this._abortController.abort()}_initialize(){if(null!=this._blockDescriptors)return;const t=pi.OK.FLOAT;Lu(`Creating AttributeStore ${Bu?"with":"without"} shared memory`),this._blockDescriptors=[{pixelType:pi.OK.UNSIGNED_BYTE,layout:1},{pixelType:pi.OK.UNSIGNED_BYTE,layout:15,textureOnly:!0},{pixelType:pi.OK.UNSIGNED_BYTE,layout:15,textureOnly:!0},{pixelType:t,layout:15},{pixelType:t,layout:15},{pixelType:t,layout:15},{pixelType:t,layout:15}],this._blocks=this._blockDescriptors.map((()=>null))}get referencesScale(){return this._referencesScale}get referencesGeometry(){return this._referencesGeometry}get _signal(){return this._abortController.signal}get hasHighlight(){return this._idsToHighlight.size>0}createDisplayIdForObjectId(t){return this._idGenerator.createIdForObjectId(t)}releaseDisplayIdForObjectId(t){return this._idGenerator.releaseIdForObjectId(t)}incrementDisplayIdGeneration(){this._idGenerator.incrementGeneration()}releaseAllIds(){this._idGenerator.releaseAll()}async update(t,e,s,i,r=0){const o=(0,G.qq)(this._schema,t);if(this.version=r,o&&((0,n.c)("geoscene-2d-update-debug")&&console.debug(`Version[${r}] AttributeStore.update`,{changed:o}),this._schema=t,this._attributeComputeInfo=null,this._initialize(),null!=t))if(s&&(this._filters=await Promise.all(t.filters.map((t=>t?Sl.create({geometryType:s.geometryType,hasM:!1,hasZ:!1,timeInfo:s.timeInfo,fieldsIndex:s.fieldsIndex,spatialReference:i??s.spatialReference,filterJSON:t}):null)))),"subtype"!==t.type)this._attributeComputeInfo={isSubtype:!1,map:new Map},await Promise.all(t.bindings.map((async t=>{const s=await this._bind(e,t);this._referencesGeometry=this._referencesGeometry||(s?.referencesGeometry()??!1),this._referencesScale=this._referencesScale||(s?.referencesScale()??!1)})));else{this._attributeComputeInfo={isSubtype:!0,subtypeField:t.subtypeField,map:new Map},this._referencesScale=!1,this._referencesGeometry=!1;for(const s in t.bindings){const i=t.bindings[s];await Promise.all(i.map((async t=>{const i=await this._bind(e,t,parseInt(s,10));this._referencesGeometry=this._referencesGeometry||(i?.referencesGeometry()??!1),this._referencesScale=this._referencesScale||(i?.referencesScale()??!1)})))}}}setHighlight(t,e){const s=this._getBlock(0);s.unsetComponentAllTexels(0,(1<<wa.length)-1);for(const{displayId:e,highlightFlags:i}of t){if(null==e)continue;const t=Nh(e);s.setComponent(0,i,[t])}this._idsToHighlight.clear();for(const{objectId:e,highlightFlags:s}of t)this._idsToHighlight.set(e,s);for(const{objectId:t,highlightFlags:s}of e)this._idsToHighlight.set(t,s)}setData(t,e,s,i){const r=Nh(t);this._ensureSizeForTexel(r),this._getBlock(e).setData(t,s,i)}getData(t,e,s){return this._getBlock(e).getData(t,s)}getHighlightFlags(t){return this._idsToHighlight.get(t)||0}unsetAttributeData(t){const e=Nh(t);this._getBlock(0).setData(e,0,0)}setAttributeData(t,e,s){const i=Nh(t);this._ensureSizeForTexel(i),this._getBlock(0).setData(i,0,this.getFilterFlags(e));const r=this._attributeComputeInfo;let n=null;r&&(n=r.isSubtype?r.map.get(e.readAttribute(r.subtypeField)):r.map,n?.size&&n.forEach(((t,r)=>{const n=1*r%4,o=Math.floor(1*r/4),a=this._getBlock(o+B.Kc.VV);let h=t.field?.read(e,s);t.valueRepresentation&&(h=function(t,e){if(!t||!e)return t;switch(e){case"radius":case"distance":return 2*t;case"diameter":case"width":return t;case"area":return Math.sqrt(t)}return t}(h,t.valueRepresentation)),(null===h||isNaN(h)||h===1/0||h===-1/0)&&(h=Bi),a.setData(i,n,h)})))}get epoch(){return this._epoch}async sendUpdates(){const t=this._blocks.map((t=>null!=t?t.toMessage():null)),e=this._getInitArgs();(0,n.c)("geoscene-2d-log-updating")&&console.log("AttributeStore: _doSendUpdate.start"),await this._client.update({initArgs:e,blockData:t,version:this.version,sendUpdateEpoch:this._epoch},this._signal),this._epoch+=1,(0,n.c)("geoscene-2d-log-updating")&&console.log("AttributeStore: _doSendUpdate.end")}_ensureSizeForTexel(t){for(;t>=this._size*this._size;)if(this._expand())return}async _bind(t,e,s){const i=await t.createComputedField(e),{valueRepresentation:r}=e,n=this._attributeComputeInfo;if(n.isSubtype){const t=n.map.get(s)??new Map;t.set(e.binding,{field:i,valueRepresentation:r}),n.map.set(s,t)}else n.map.set(e.binding,{field:i,valueRepresentation:r});return i}_getInitArgs(){return this._initialized?null:(this._initialized=!0,this._getBlock(B.Kc.Animation),this._getBlock(B.Kc.GPGPU),{blockSize:this._size,blockDescriptors:this._blocks.map((t=>null!=t?{textureOnly:t.textureOnly,buffer:t.buffer,pixelType:t.pixelType}:null))})}_getBlock(t){const e=this._blocks[t];if(null!=e)return e;Lu(`Initializing AttributeBlock at index ${t}`);const s=new Uu(this._size,this._blockDescriptors[t],this._client.isLocal);return this._blocks[t]=s,this._initialized=!1,s}_expand(){if(this._size<this._schema.capabilities.maxTextureSize){const t=this._size<<=1;Lu("Expanding block size to",t,this._blocks);for(const e of this._blocks)e?.expand(t);return this._initialized=!1,this._size=t,0}return zu().error(new i.c("mapview-limitations","Maximum number of onscreen features exceeded.")),-1}isVisible(t){return!!(this._getBlock(0).getData(t,0)&1<<wa.length)}getFilterFlags(t){let e=0;for(let s=0;s<this._filters.length;s++){const i=!!(1<<s),r=this._filters[s];e|=(!i||null==r||r.check(t)?1:0)<<s}let s=0;if(this._idsToHighlight.size){const e=t.getObjectId();s=this.getHighlightFlags(e)}return e<<wa.length|s}}class Vu{constructor(t,e){this._connection=t,this._source=e,this._version=1,this._proxy=new Oc({fetch:(t,e)=>this._connection.layerView.fetch(t,e),fetchDictionary:(t,e)=>this._connection.layerView.fetchDictionary(t,e)}),this._attributeStore=new Gu({isLocal:!1,update:t=>(0,a.jO)(this._connection.container.updateAttributeView(t))})}destroy(){this._proxy.destory(),this._strategy?.destroy(),this._attributeStore.destroy()}get aggregateQueryEngine(){return this._strategy?.aggregateQueryEngine}getDisplayFeatures(t){return this._strategy?this._strategy.getDisplayFeatures(t):{features:[],aggregates:[]}}getFeatureObjectIdsForAggregate(t){return this._strategy?this._strategy.getFeatureObjectIdsForAggregate(t):[]}onSubscribe(t){this._strategy?.onSubscribe(t)}onUnsubscribe(t){this._strategy?.onUnsubscribe(t)}async update(t,e,s,i,r){const o=t.processor,a=(0,G.qq)(this._schema,o);if(!a&&!i)return;(0,n.c)("geoscene-2d-update-debug")&&console.debug(`Version[${this._version}] SymbolProcessor.update`,{changes:a,schema:o}),this._schema=o;const h=V.c.fromJSON(t.source.mutable.dataFilter.outSpatialReference),c=new gl({fields:this._source.metadata.fieldsIndex,spatialReference:h});return await this._attributeStore.update(o.storage,c,this._source.metadata,h,e),this._strategy?.invalidateAttributeData(),i||(0,G.Y5)(a,"mesh")?((0,G.Y5)(a,"mesh.strategy")&&await this._updateStrategy(o.mesh.strategy,h,r,o.mesh.timeZone),this._updateSortKey(c,"sortKey"in o.mesh?o.mesh.sortKey:null),((0,G.Y5)(a,"mesh.factory")||"dictionary"===o.mesh.factory.symbology.type)&&(this._factory=await Ac.create(c,this._proxy,o.mesh.factory,s)),this._invalidate(),this._version=e,this._connection.container.updateRenderState(this._version)):void 0}async applyOverride(t){if(!this._strategy)return;const e=this._strategy.applyOverride(t);for await(const t of e)try{await this._process(t)}catch(t){}this._source.applyOverride(t)}async updateChunks(){await this._doUpdateChunks(),this._strategy?.afterUpdateChunks()}async removeChunks(t){this._strategy?.removeChunks(t),this._attributeStore.incrementDisplayIdGeneration()}updateHighlight({highlights:t}){if(!this._strategy)return void this._attributeStore.setHighlight(t.map((({objectId:t,highlightFlags:e})=>({objectId:t,highlightFlags:e,displayId:-1}))),t);const e=this._strategy.displayMap(t,(({objectId:t})=>t),((t,{highlightFlags:e},s)=>({objectId:s,displayId:t,highlightFlags:e})));this._attributeStore.setHighlight(e,t)}async _doUpdateChunks(){if(!this._strategy)return;const t=this._strategy.updateChunks(),e=[],s=new Map;for await(const i of t){let t=s.get(i.id);null==t&&(t=new Nc({concurrency:16,process:t=>this._process(t)}),s.set(i.id,t));const r=t.push(i).catch((t=>(0,a.Az)(t)));e.push(r)}try{await Promise.all(e)}catch(t){}(0,n.c)("geoscene-2d-update-debug")&&console.log("SendUpdates"),await this._attributeStore.sendUpdates(),(0,n.c)("geoscene-2d-update-debug")&&console.log("SendUpdates.await")}async _updateStrategy(t,e,s,i){switch(this._strategy?.destroy(),t.type){case"feature":this._strategy=new Ou(this._source,this._attributeStore,i);break;case"binning":this._strategy=await Yl.create(t,e,this._source,this._attributeStore,i);break;case"cluster":this._strategy=await cu.create(this._connection,t,e,this._source,this._attributeStore,i)}for(const t of s)this._strategy.onSubscribe(t)}async _updateSortKey(t,e){if(this._sortInfo=(0,M.mG)(this._sortInfo?.computed),null!=e){const s=e.byRenderer?null:await t.createComputedField(e);this._sortInfo={...e,computed:s}}}_invalidate(){this._strategy&&this._strategy.invalidate()}async _process(t){const e=t.subscription;if((0,n.c)("geoscene-2d-update-debug")){const s=e.tile;console.debug(`Version[${this._version}] Tile[${s.key.id}, end=${t.end}] Processor._process`)}await this._fetchResources(t),(0,a.wp)(e.signal);const s=await this._write(t,e.tile.createArcadeEvaluationOptions(this._schema.mesh.timeZone)),i=e.tile.tileInfoView.tileInfo.isWrappable,{message:r,transferList:o}=s.serialize(i),h=t.createMessage(r,this._version,this._attributeStore.epoch);if((0,a.wp)(e.signal),this._connection.container.onMessage(h,{signal:e.signal,transferList:o}),this._attributeStore.sendUpdates(),(0,n.c)("geoscene-2d-update-debug")){const s=e.tile;console.debug(`Version[${this._version}] Tile[${s.key.id}, end=${t.end}] Processor._process.await`)}}async _fetchResources(t){await this._fetchMatcherResources(t),await this._fetchWriterResources(t)}async _fetchMatcherResources(t){if(t.reader)return this._factory.enqueueMatcherRequests(this._proxy,t.reader)}async _fetchWriterResources(t){if(!t.reader)return;const e=t.reader.getCursor(),s=t.subscription.tile.createArcadeEvaluationOptions(this._schema.mesh.timeZone);for(;e.next();)this._factory.enqueueWriterRequests(this._proxy,e,s);await this._proxy.fetchEnqueuedResources()}async _write(t,e){const s=t.subscription.tile,i=t.reader?.getCursor(),r=i?.getSize()??0,n=new Q(s.key.id,this._strategy.enablePixelBuffering,r);if(!i)return n;const o=s.createArcadeEvaluationOptions(this._schema.mesh.timeZone);for(;i.next();){const t=this._getSortKeyValue(i,e);n.entityStart(i.getDisplayId(),t),this._factory.write(n,this._proxy,i,o,s.level),n.entityEnd()}return n}_getSortKeyValue(t,e){if(!this._sortInfo)return 0;const{computed:s,order:i,byRenderer:r}=this._sortInfo,n=r?this._factory.getSortKey(t,e):s?.read(t,e);return null==n||isNaN(n)?0:n*("asc"===i?-1:1)}}var qu=s(2600),Wu=s(32848);class Xu{static from(t){let e=0,s=0,i=0;return t.forEach((t=>{const r=t._readGeometry();r&&(s+=r.isPoint?1:r.lengths.reduce(((t,e)=>t+e),0),i+=r.isPoint?1:r.lengths.length,e+=1)})),new Xu(e,s,i)}constructor(t,e,s){this.featureCount=t,this.vertexCount=e,this.ringCount=s}toJSON(){return{featureCount:this.featureCount,ringCount:this.featureCount,vertexCount:this.featureCount}}}var Yu=s(25228),ju=s(48212);class Hu{static fromSchema(t,e){return new Hu(function(t,e){const{service:s}=t,i=s.orderByFields??e.objectIdField+" ASC",r=s.source,n={returnCentroid:!(null!==r&&"object"==typeof r&&"path"in r&&(0,ju.Wq)(r.path))&&"esriGeometryPolygon"===e.geometryType,returnGeometry:!0,timeReferenceUnknownClient:e.timeReferenceUnknownClient??void 0,outSpatialReference:V.c.fromJSON(t.mutable.dataFilter.outSpatialReference),orderByFields:[i],where:t.mutable.dataFilter.definitionExpression??"1=1",outFields:t.mutable.availableFields};if("feature"===t.type){const{gdbVersion:e,historicMoment:s,timeExtent:i}=t.mutable.dataFilter;return{...n,gdbVersion:e,historicMoment:s?new Date(s):null,timeExtent:i?Yu.c.fromJSON(i):null,outFields:t.mutable.availableFields}}return n}(t,e),t.mutable.dataFilter.customParameters,e.geometryType,t.service.queryMetadata.capabilities)}constructor(t,e,s,i){this._queryParams=t,this._customParameters=e,this._geometryType=s,this._capabilities=i}get pageSize(){if(null==this._capabilities)throw new Error("InternalError: Service does not support paged queries");const{query:t}=this._capabilities,e=t.supportsMaxRecordCountFactor?4:null,s=(t.maxRecordCount??8e3)*(e??1);return Math.min(8e3,s)}updateFields(t){this._queryParams.outFields=t}createPatchFieldsQuery(t,e){const s=t.clone();if("*"===this._queryParams.outFields[0]){if("*"===(s.outFields??[])[0])return null;s.outFields=this._queryParams.outFields}else{const t=new Set(this._queryParams.outFields),i=[];for(const s of t)e.has(s)||i.push(s);if(0===i.length)return null;s.outFields=i}return s.returnGeometry=!1,s.returnCentroid=!1,s.quantizationParameters=null,s.cacheHint=!0,{inner:s,customParameters:this._customParameters}}createQuery(t={}){if(!this._queryParams)throw new Error("InternalError: queryInfo should be defined");return{inner:new wl.c({...this._queryParams,...t}),customParameters:this._customParameters}}createTileQuery(t,e){if(null==this._capabilities)throw new Error("InternalError: Service does not support tile queries");const s=this.createQuery(e),i=s.inner;return i.quantizationParameters=e.quantizationParameters??t.getQuantizationParameters(),i.resultType="tile",i.geometry=t.extent,this._capabilities.query.supportsQuantization?"esriGeometryPolyline"===this._geometryType&&(i.maxAllowableOffset=t.resolution*(0,n.c)("feature-polyline-generalization-factor")):"esriGeometryPolyline"!==this._geometryType&&"esriGeometryPolygon"!==this._geometryType||(i.maxAllowableOffset=t.resolution,"esriGeometryPolyline"===this._geometryType&&(i.maxAllowableOffset*=(0,n.c)("feature-polyline-generalization-factor"))),i.defaultSpatialReferenceEnabled=this._capabilities.query.supportsDefaultSpatialReference,i.compactGeometryEnabled=this._capabilities.query.supportsCompactGeometry,this._capabilities.query.supportsMaxRecordCountFactor&&(i.maxRecordCountFactor=4),s}createPagedTileQuery(t,e){const s=this.pageSize;return this.createTileQuery(t,{start:s*e,num:s,returnExceededLimitFeatures:!0})}createPagedQuery(t){const e=this.pageSize;return this.createQuery({start:e*t,num:e,returnExceededLimitFeatures:!0,maxRecordCountFactor:4})}}let $u=class extends P.c{constructor(t){super(),this._connection=t,this._enabledEventTypes=new Set,this._updateInfo={websocket:0,client:0},this._lastTime=performance.now(),this.addHandles([(0,c.aE)((()=>this._strategy?.connectionStatus??"disconnected"),(t=>{this._layerView.setProperty({propertyName:"pipelineConnectionStatus",value:t})}),{initial:!0}),(0,c.aE)((()=>this._strategy?.errorString||null),(t=>this._layerView.setProperty({propertyName:"pipelineErrorString",value:t})),{initial:!0})])}destroy(){this._strategy=null,this.removeAllHandles()}get _layerView(){return this._connection.layerView}set strategy(t){null==this._strategy&&this._resetUpdateInfo(performance.now());const e="event-handles";this.removeHandles(e),null!=t&&this.addHandles([t.events.on("data-received",(t=>this._onFeature(t))),t.events.on("message-received",(t=>this._onWebSocketMessage(t))),t.events.on("features-updated",(t=>this._onUpdate(t))),t.events.on("tick",(()=>this._onTick()))],e),this._strategy=t}updateCustomParameters(t){null!=t&&this._strategy?.updateCustomParameters(t)}sendMessageToSocket(t){this._strategy?.sendMessageToSocket(t)}sendMessageToClient(t){this._strategy?.sendMessageToClient(t)}enableEvent(t,e){e?this._enabledEventTypes.add(t):this._enabledEventTypes.delete(t)}disconnect(){this._strategy?.disconnect()}connect(){this._strategy?.connect()}clear(){this._strategy?.clear()}_onWebSocketMessage(t){this._enabledEventTypes.has("message-received")&&this._layerView.emitEvent({name:"message-received",event:t})}_onFeature(t){this._updateInfo.websocket++,this._enabledEventTypes.has("data-received")&&this._layerView.emitEvent({name:"data-received",event:{attributes:t.attributes,centroid:t.centroid,geometry:t.geometry}})}_onUpdate(t){this._updateInfo.client+=t}_onTick(){const t=performance.now(),e=t-this._lastTime;if(e>2500){const s=Math.round(this._updateInfo.client/(e/1e3)),i=Math.round(this._updateInfo.websocket/(e/1e3));this._resetUpdateInfo(t),this._layerView.emitEvent({name:"update-rate",event:{client:s,websocket:i}})}}_resetUpdateInfo(t){this._lastTime=t,this._updateInfo.client=0,this._updateInfo.websocket=0}};(0,T._)([(0,E.qq)()],$u.prototype,"_strategy",void 0),$u=(0,T._)([(0,k.c)("geoscene.views.2d.layers.features.sources.StreamMessenger")],$u);class Ku{constructor(t){this._store=t,this._controller=new AbortController}destroy(){this._controller.abort()}get _options(){return{signal:this._controller.signal}}async queryOverride(t){throw new Error("InternalError: LoadStrategy does not support fetching")}}var Zu=s(46448),Qu=s(42736),Ju=s(96248),td=s(91232),ed=s(58580);const sd=268435455;class id{constructor(){this.hasFeatures=!1,this.exceededTransferLimit=!1,this.fieldCount=0,this.featureCount=0,this.objectIdFieldIndex=0,this.vertexCount=0,this.offsets={attributes:new Array,geometry:new Array},this.centroid=new Array}}const rd=268435455,nd=128e3,od={small:{delta:new Int32Array(128),decoded:new Int32Array(128)},large:{delta:new Int32Array(nd),decoded:new Int32Array(nd)}};function ad(t){return t<=od.small.delta.length?od.small:(t<=od.large.delta.length||(od.large.delta=new Int32Array(Math.round(1.25*t)),od.large.decoded=new Int32Array(Math.round(1.25*t))),od.large)}function hd(t){for(;t.next();){if(1===t.tag())return t.getMessage();t.skip()}return null}function cd(t,e,s,i,r,n){return.5*Math.abs(t*i+s*n+r*e-t*n-s*e-r*i)}function ld(t,e,s,i){return 0==t*i-s*e&&t*s+e*i>0}class ud extends ql{static fromBuffer(t,e,s=!1){const r=e.geometryType,n=function(t){try{const e=2,s=new td.c(new Uint8Array(t),new DataView(t));for(;s.next();){if(s.tag()===e)return hd(s.getMessage());s.skip()}}catch(t){const e=new i.c("query:parsing-pbf","Error while parsing FeatureSet PBF payload",{error:t});C.c.getLogger("geoscene.view.2d.layers.features.support.FeatureSetReaderPBF").error(e)}return null}(t),o=function(t,e,s=!1){const r=t.asUnsafe(),n=r.pos(),o=new id;let a=0,h=0,c=null,l=null,u=null,d=!1;const p=[];for(;r.next();)switch(r.tag()){case 1:c=r.getString();break;case 3:l=r.getString();break;case 12:u=r.processMessage(ed.UH);break;case 9:if(o.exceededTransferLimit=r.getBool(),o.exceededTransferLimit){o.offsets.geometry=s?new Float64Array(8e3):new Int32Array(8e3),o.centroid=s?new Float64Array(16e3):new Int32Array(16e3);for(let t=0;t<o.centroid.length;t++)o.centroid[t]=sd}break;case 13:{const t=r.processMessage(ed.gD);t.index=a++,p.push(t);break}case 15:{const t=r.getLength(),i=r.pos()+t;if(!o.exceededTransferLimit){const t=o.offsets.geometry,e=o.centroid;t.push(0),e.push(sd),e.push(sd)}!d&&o.exceededTransferLimit&&(d=!0,o.offsets.attributes=s?new Float64Array(8e3*a):new Uint32Array(8e3*a));let n=h*a;for(;r.pos()<i&&r.next();)switch(r.tag()){case 1:{d?o.offsets.attributes[n++]=r.pos():o.offsets.attributes.push(r.pos());const t=r.getLength();r.skipLen(t);break}case 2:if(e){const t=r.getLength(),e=r.pos()+t;for(;r.pos()<e&&r.next();)switch(r.tag()){case 3:{r.getUInt32();const t=r.getSInt64(),e=r.getSInt64();o.centroid[2*h]=t,o.centroid[2*h+1]=e;break}default:r.skip()}}else{o.offsets.geometry[h]=r.pos();const t=r.getLength();o.vertexCount+=t,r.skipLen(t)}break;case 4:{const t=r.getLength(),e=r.pos()+t;for(;r.pos()<e&&r.next();)switch(r.tag()){case 3:{r.getUInt32();const t=r.getSInt64(),e=r.getSInt64();o.centroid[2*h]=t,o.centroid[2*h+1]=e;break}default:r.skip()}break}default:r.skip()}h++,o.hasFeatures=!0;break}default:r.skip()}const _=c||l;if(!_)throw new i.c("FeatureSet has no objectId or globalId field name");return o.fields=new Il.c(p),o.featureCount=h,o.fieldCount=a,o.objectIdFieldIndex=o.fields.get(_)?.index,o.transform=u,o.displayIds=new Uint32Array(o.featureCount),o.groupIds=new Uint16Array(o.featureCount),r.move(n),o}(n,"esriGeometryPoint"===r,s);return new ud(n,o,e)}constructor(t,e,s){super(s),this._hasNext=!1,this._isPoints=!1,this._featureIndex=-1,this._featureOffset=0,this._cache={area:0,unquantGeometry:void 0,geometry:void 0,centroid:void 0,legacyFeature:void 0,optFeature:void 0},this._parseCaches=new Array,this._geometryType=s.geometryType,this._reader=t,this._header=e,this._hasNext=e.hasFeatures,this._isPoints="esriGeometryPoint"===s.geometryType}get _size(){return this._header.featureCount}get fields(){return this._header.fields}get geometryType(){return this._geometryType}get hasZ(){return!1}get hasM(){return!1}get hasFeatures(){return this._header.hasFeatures}get hasNext(){return this._hasNext}get exceededTransferLimit(){return this._header.exceededTransferLimit}getSize(){return this._size}getInTransform(){return this._header.transform}getCursor(){return this.copy()}getIndex(){return this._featureIndex}setIndex(t){this._cache.area=0,this._cache.unquantGeometry=void 0,this._cache.geometry=void 0,this._cache.centroid=void 0,this._cache.legacyFeature=void 0,this._cache.optFeature=void 0,this._featureIndex=t}getAttributeHash(){let t="";for(const e of this._header.fields.fields)t+=this._readAttributeAtIndex(e.index)+".";return t}getObjectId(){return this._readAttributeAtIndex(this._header.objectIdFieldIndex)}getDisplayId(){return this._header.displayIds[this._featureIndex]}setDisplayId(t){this._header.displayIds[this._featureIndex]=t}readGeometryArea(){return this._cache.area||this._readGeometry(!0),this._cache.area}copy(){const t=this._reader.clone(),e=new ud(t,this._header,this.metadata);return this.copyInto(e),e}next(){for(this._cache.area=0,this._cache.unquantGeometry=void 0,this._cache.geometry=void 0,this._cache.centroid=void 0,this._cache.legacyFeature=void 0,this._cache.optFeature=void 0;++this._featureIndex<this._size&&!this._getExists(););return this._featureIndex<this._size}_readX(){return this._header.centroid[2*this._featureIndex]}_readY(){return this._header.centroid[2*this._featureIndex+1]}_readServerCentroid(){const t=this._header.centroid[2*this._featureIndex],e=this._header.centroid[2*this._featureIndex+1];return t===rd?null:new ft.c([],[t,e])}_readGeometry(t=!1){if(void 0===this._cache.geometry){let e=null;if(this._isPoints){if(this._header.centroid[2*this._featureIndex]===rd)return null;const t=this._header.centroid[2*this._featureIndex],s=this._header.centroid[2*this._featureIndex+1];e=new ft.c([],[t,s])}else{const s=this._header.offsets.geometry[this._featureIndex],i=this._reader;if(0===s)return null;i.move(s);try{e=t?this._parseGeometryForDisplay(i):this._parseGeometry(i)}catch(t){return console.error("Failed to parse geometry!",t),null}}return 0===e?.coords.length&&(e=null),this._cache.geometry=e,e}return this._cache.geometry}_readAttribute(t,e){const s=this._header.fields.get(t);if(null==s)return;let i=this._readAttributeAtIndex(s.index);"esriFieldTypeTimestampOffset"===this.fields.get(t)?.type&&(i=this.parseTimestampOffset(i));const r=this._header.fields.isDateField(s.name);return e?null==i?i:r?new Date(i):i:i}_readAttributes(){const t={};for(const e of this._header.fields.fields)t[e.name]=this._readAttributeAtIndex(e.index);return t}copyInto(t){super.copyInto(t),t._featureIndex=this._featureIndex,t._featureOffset=this._featureOffset,t._hasNext=this._hasNext,t._parseCaches=this._parseCaches}_readAttributeAtIndex(t){let e=this._parseCaches[t];if(e||(e=new kl(this.getSize()),this._parseCaches[t]=e),e.has(this._featureIndex))return e.get(this._featureIndex);const s=this._header.offsets.attributes[this._featureIndex*this._header.fieldCount+t],i=this._reader;i.move(s);const r=function(t){const e=t.getLength(),s=t.pos()+e;for(;t.pos()<s&&t.next();)switch(t.tag()){case 1:return t.getString();case 2:return t.getFloat();case 3:return t.getDouble();case 4:return t.getSInt32();case 5:return t.getUInt32();case 6:return t.getInt64();case 7:return t.getUInt64();case 8:return t.getSInt64();case 9:return t.getBool();default:return t.skip(),null}return null}(i);return e.set(this._featureIndex,r),r}_readGeometryDeltaDecoded(t=!1){if(void 0===this._cache.unquantGeometry){const e=this._readGeometry(t);if(!e)return this._cache.unquantGeometry=void 0,null;if(!this.getInTransform())return this._cache.unquantGeometry=e,e;const s=ad(e.coords.length).decoded,i=e.clone(s),r=i.coords;let n=0;for(const t of i.lengths){for(let e=1;e<t;e++){const t=2*(n+e),s=2*(n+e-1);r[t]+=r[s],r[t+1]+=r[s+1]}n+=t}return this._cache.unquantGeometry=i,i}return this._cache.unquantGeometry}_parseGeometry(t){const e=t.asUnsafe(),s=e.getLength(),i=e.pos()+s,r=[],n=[];for(;e.pos()<i&&e.next();)switch(e.tag()){case 2:{const t=e.getUInt32(),s=e.pos()+t;for(;e.pos()<s;)n.push(e.getUInt32());break}case 3:{const t=e.getUInt32(),s=e.pos()+t;for(r.push(e.getSInt64()),r.push(e.getSInt64()),this.hasZ&&e.getSInt64(),this.hasM&&e.getSInt64();e.pos()<s;)r.push(e.getSInt64()),r.push(e.getSInt64()),this.hasZ&&e.getSInt64(),this.hasM&&e.getSInt64();break}default:e.skip()}return new ft.c(n,r)}_parseGeometryForDisplay(t){const e=t.asUnsafe(),s=e.getLength(),i=e.pos()+s,r=[],n=[];let o=0,a=0,h=null,c=0;const l="esriGeometryPolygon"===this.geometryType;for(;e.pos()<i&&e.next();)switch(e.tag()){case 2:{const t=e.getUInt32(),s=e.pos()+t;for(;e.pos()<s;){const t=e.getUInt32();r.push(t),o+=t}h=ad(2*o).delta;break}case 3:{e.getUInt32();const t=2+(this.hasZ?1:0)+(this.hasM?1:0);(0,M.EN)(h);for(const s of r)if(a+t*s>h.length)for(let t=0;t<s;t++)e.getSInt32(),e.getSInt32(),this.hasZ&&e.getSInt32(),this.hasM&&e.getSInt32();else if(l){const t=this.getAreaSimplificationThreshold(s,this._header.vertexCount);let i=2,r=1;const o=!1;let l=e.getSInt32(),u=e.getSInt32();h[a++]=l,h[a++]=u,this.hasZ&&e.getSInt32(),this.hasM&&e.getSInt32();let d=e.getSInt32(),p=e.getSInt32();for(this.hasZ&&e.getSInt32(),this.hasM&&e.getSInt32();i<s;){let s=e.getSInt32(),n=e.getSInt32();this.hasZ&&e.getSInt32(),this.hasM&&e.getSInt32();const o=l+d,_=u+p;cd(l,u,o,_,o+s,_+n)>=t?(c+=-.5*(o-l)*(_+u),r>1&&ld(h[a-2],h[a-1],d,p)?(h[a-2]+=d,h[a-1]+=p):(h[a++]=d,h[a++]=p,r++),l=o,u=_):(s+=d,n+=p),d=s,p=n,i++}r<3||o?a-=2*r:(c+=-.5*(l+d-l)*(u+p+u),ld(h[a-2],h[a-1],d,p)?(h[a-2]+=d,h[a-1]+=p,n.push(r)):(h[a++]=d,h[a++]=p,n.push(++r)))}else{let t=0,i=e.getSInt32(),r=e.getSInt32();this.hasZ&&e.getSInt32(),this.hasM&&e.getSInt32(),h[a++]=i,h[a++]=r,t+=1;for(let n=1;n<s;n++){const s=e.getSInt32(),o=e.getSInt32(),l=i+s,u=r+o;c+=-.5*(l-i)*(u+r),this.hasZ&&e.getSInt32(),this.hasM&&e.getSInt32(),n>2&&ld(h[a-2],h[a-1],s,o)?(h[a-2]+=s,h[a-1]+=o):(h[a++]=s,h[a++]=o,t+=1),i=l,r=u}n.push(t)}break}default:e.skip()}return this._cache.area=c,n.length?new ft.c(n,h):null}}class dd{constructor(t,e){this.service=t,this._metadata=e}destroy(){}}class pd extends dd{constructor(t,e){super(t,e),this._portsOpen=async function(t){const e=new Zu.c;return await e.open(t,{}),e}(t.source).then((t=>this.client=t))}destroy(){this.client.close(),this.client=null}async executeQuery(t,e){await this._portsOpen;const s=await this.client.invoke("queryFeatures",t.toJSON(),e);return Wl.fromFeatureSet(s,this._metadata)}}class _d extends dd{async executeQuery(t,e){const{data:s}=await(0,Wu.u_)(this.service.source,t,e),i=!t.quantizationParameters;return ud.fromBuffer(s,this._metadata,i)}}class fd extends dd{async executeQuery(t,e){const{source:s,queryMetadata:i}=this.service,r=i.capabilities;if(null!=t.quantizationParameters&&!r.query.supportsQuantization){const i=t.clone(),r=(0,Qu.eE)(i.quantizationParameters);i.quantizationParameters=null;const{data:n}=await(0,Wu.EL)(s,i,this._metadata.spatialReference,e),o=(0,zc.ui)(n,this._metadata.objectIdField);return(0,zc.m)(r,o),Wl.fromOptimizedFeatureSet(o,this._metadata)}const{data:n}=await(0,Wu.EL)(s,t,this._metadata.spatialReference,e);return"esriGeometryPoint"===this._metadata.geometryType&&(n.features=n.features?.filter((t=>{if(null!=t.geometry){const e=t.geometry;return Number.isFinite(e.x)&&Number.isFinite(e.y)}return!0}))),Wl.fromFeatureSet(n,this._metadata)}}class md extends dd{async executeQuery(t,e){const{capabilities:s}=this.service.queryMetadata;if(t.quantizationParameters&&!s.query.supportsQuantization){const s=t.clone(),i=(0,Qu.eE)(s.quantizationParameters);s.quantizationParameters=null;const r=await(0,Ju.wB)(this.service.source,t,e);return(0,zc.m)(i,r),Wl.fromOptimizedFeatureSet(r,this._metadata)}const i=await(0,Ju.wB)(this.service.source,t,e);return Wl.fromOptimizedFeatureSet(i,this._metadata)}}class gd extends Ku{constructor(t,e,s,i,r){super(s),this._serviceInfo=t,this._queryInfo=e,this._metadata=i,this._eventLog=r,this._queue=new A.K({concurrency:16,process:async t=>{const e={signal:t.options?.signal,query:t.query.customParameters};return this._adapter.executeQuery(t.query.inner,e)}}),this._adapter=function(t,e){switch(t.type){case"memory":return new pd(t,e);case"ogc":return new md(t,e);case"feature-service":return t.queryMetadata.capabilities.query.supportsFormatPBF&&(0,n.c)("featurelayer-pbf")?new _d(t,e):new fd(t,e)}}(t,i)}async updateFields(t){this._queryInfo.updateFields(t);const e=Array.from(this._store.chunks()).map((async t=>{const e=wl.c.fromJSON(t.queryInfo.queryJSON);if(e)try{return await this._tryUpdateFields(t.reader,e),null}catch(t){return t}})),s=(await Promise.all(e)).filter((t=>t));if(s.length)throw new i.c("featurelayer-query","Encountered errors when downloading fields",{errors:s})}async queryOverride({edits:t}){const e=[],s=[];for(const i of t.removed)null!=i.objectId&&-1!==i.objectId?e.push(i.objectId):s.push(i.globalId);s.length&&e.push(...this._mapGlobalIdsToObjectIds(s));const i=t.addOrModified.map((({objectId:t})=>t)),r=this._queryInfo.createQuery({objectIds:i});return{reader:await this._fetch(r),removed:e}}_mapGlobalIdsToObjectIds(t){const e=new Set(t),s=this._metadata.globalIdField;if(null==s)throw new Error("InternalError: Recieved an edit with globalIds, but not supported by the service");const i=[];return this._store.forEachUnsafe((t=>{const r=t.readAttribute(s);e.has(r)&&i.push(t.getObjectId())})),i}async _fetch(t,e){const s=await this._enqueue(t,e);return await this._tryUpdateFields(s,t.inner),s}async _tryUpdateFields(t,e){const s=this._queryInfo.createPatchFieldsQuery(e,t.fields);if(!s)return;const i=await this._enqueue(s,this._options);t.joinAttributes(i)}async _enqueue(t,e){return this._eventLog.onEvent({type:"fetchStart"}),this._queue.push({query:t,options:e}).finally((()=>{this._eventLog.onEvent({type:"fetchEnd",done:0===this._queue.length})}))}}class yd extends gd{constructor(){super(...arguments),this._chunksById=new Map}unload(t){this._removeChunks(t.tile)}_addChunk(t){const e=t.tile.id;this._chunksById.has(e)||this._chunksById.set(e,[]);const s=t.size();(s||t.first||t.end)&&((0,n.c)("geoscene-2d-update-debug")&&console.debug(`Chunk[${t.chunkId}] ATileLoadStrategy.addChunk [count=${s}]`),this._chunksById.get(e).push(t),this._store.insert(t))}_removeChunks(t){const e=this._chunksById.get(t.key.id)??[];for(const s of e)(0,n.c)("geoscene-2d-update-debug")&&console.debug(`Tile[${t.key.id}] Chunk[${s.chunkId}] ATileLoadStrategy.removeChunk`),this._store.remove(s);this._chunksById.delete(t.key.id)}}class xd extends Fu{constructor(t,e,s,i,r,n){super(),this._reader=t,this._queryJSON=e,this._tile=s,this._sourceTile=i,this._sourceTileDepth=r,this._end=n,this.chunkId=`${this._tile.key.id}.${this._sourceTile?.key.id}${this._end?"e":""}`,this.normalizedChunkId=`${this._tile.key.normalizedId}.${this._sourceTile?.key.normalizedId}${this._end?"e":""}`}get queryInfo(){return{type:"drill-down-tile",chunkId:this.chunkId,tileId:this._tile.key.id,queryJSON:this._queryJSON,sourceTileDepth:this._sourceTileDepth,sourceTileId:this._sourceTile?.key.id,size:this.size(),end:this.end}}get first(){return 0===this._sourceTileDepth}get reader(){return this._reader}get end(){return this._end}get tile(){return this._tile}get isTiled(){return!0}getTileReader(t){return this._tile.key.id===t.key.id?this.reader:null}}class bd{constructor(t,e){this.subscription=t,this._tileIdToResult=new Map,this._controller=new AbortController,(0,a.wD)(t.options,(()=>this._controller.abort())),(0,a.wD)(e,(()=>this._controller.abort()))}get(t){return this._tileIdToResult.get(t)}set(t,e){this._tileIdToResult.set(t,e)}get options(){return{signal:this._controller.signal}}}class wd extends yd{constructor(){super(...arguments),this._loadStates=new Map}get about(){return{willQueryAllFeatures:!1,willQueryFullResolutionGeometry:!1}}async load(t){this._loadStates.has(t.key.id)||this._loadStates.set(t.key.id,new bd(t,this._options));const e=this._loadStates.get(t.key.id);let s;try{for await(const s of this._fetchChunkInfos(e,t.tile,0)){const{queryJSON:e,reader:i,sourceTile:r,sourceTileDepth:n,tile:o}=s,h=new xd(i,e,o,r,n,!1);(0,a.wp)(t.options),this._addChunk(h)}}catch(t){s=t}const i=new xd(Wl.empty(this._metadata),null,t.tile,null,-1,!0);if(this._addChunk(i),s)throw s}unload(t){super.unload(t),this._loadStates.delete(t.key.id)}async*_fetchChunkInfos(t,e,s){let i=t.get(e.id);const r=!!i;if(i||(i=await this._fetchChunkInfo(t,e,s),t.set(e.id,i)),i.reader.exceededTransferLimit&&s<(0,n.c)("featurelayer-query-max-depth"))for(const i of e.createChildTiles())yield*this._fetchChunkInfos(t,i,s+1);else r||(yield i)}async _fetchChunkInfo(t,e,s){const i=t.subscription.tile.getQuantizationParameters(),r=this._queryInfo.createTileQuery(e,{returnExceededLimitFeatures:!1,quantizationParameters:i});return{reader:await this._fetch(r,t.subscription.options),queryJSON:r.inner.toJSON(),tile:t.subscription.tile,sourceTile:e,sourceTileDepth:s}}}class vd extends Fu{constructor(t,e,s,i,r){super(),this._reader=t,this._queryJSON=e,this._tile=s,this._page=i,this._end=r,this.chunkId=`${this._tile.key.id}.${this._page}${this.end?"e":""}`,this.normalizedChunkId=`${this._tile.key.normalizedId}.${this._page}${this.end?"e":""}`}get queryInfo(){return{type:"paged-tile",chunkId:this.chunkId,tileId:this._tile.key.id,queryJSON:this._queryJSON,page:this._page,size:this.size(),end:this.end}}get reader(){return this._reader}get first(){return 0===this._page}get end(){return this._end}get page(){return this._page}get tile(){return this._tile}get isTiled(){return!0}getTileReader(t){return this._tile.key.id===t.key.id?this.reader:null}}class Sd{constructor(t,e){this.subscription=t,this._pages=new Set,this._controller=new AbortController,this._done=!1,(0,a.wD)(t.options,(()=>this._controller.abort())),(0,a.wD)(e,(()=>this._controller.abort()))}resetAbortController(){this._controller=new AbortController}get pageStart(){let t=-1;for(const e of this._pages.values())t=Math.max(t,e);return t+1}get done(){return this._done}get options(){return{signal:this._controller.signal}}add(t,e){this._pages.add(t),this._done=this._done||e}}class Id extends yd{constructor(){super(...arguments),this._loadStates=new Map}get about(){return{willQueryAllFeatures:!1,willQueryFullResolutionGeometry:!1}}async load(t){this._loadStates.has(t.key.id)||this._loadStates.set(t.key.id,new Sd(t,this._options));const e=this._loadStates.get(t.key.id);let s;e.resetAbortController();try{await this._fetchPages(e)}catch(t){s=t}const i=new vd(Wl.empty(this._metadata),null,t.tile,-1,!0);if((0,a.wv)(e.options)||this._addChunk(i),s)throw s}unload(t){super.unload(t),this._loadStates.delete(t.key.id)}async _fetchPages(t){let e=0,s=t.pageStart,i=1;for(;e<20&&!t.done;){const r=[];for(let e=0;e<i;e++)r.push(this._fetchChunk(t,s++));const n=await Promise.all(r);for(const e of n)(0!==e.size()||e.first)&&(t.add(e.page,!e.reader.exceededTransferLimit),(0,a.wp)(t.options),this._addChunk(e));e++,i=Math.min(i+1,4)}}async _fetchChunk(t,e){const s=t.subscription.tile,i=this._queryInfo.createPagedTileQuery(s,e),r=await this._fetch(i,t.options);return new vd(r,i.inner.toJSON(),s,e,!1)}}class Td extends Fu{constructor(t,e,s,i){super(),this._reader=t,this._queryJSON=e,this._page=s,this._end=i,this.chunkId=`${this._page}${this.end?"e":""}`,this.normalizedChunkId=this.chunkId}get reader(){return this._reader}get first(){return 0===this._page}get end(){return this._end}get queryInfo(){return{type:"snapshot",chunkId:this.chunkId,queryJSON:this._queryJSON,page:this._page,size:this.size(),end:this.end}}get isTiled(){return!1}getTileReader(t){const e=this.queryFeaturesInBounds(t.bounds);return e.setTransformForDisplay(t.transform),e}}class Pd extends gd{constructor(t,e,s,i,r,n){super(t,e,s,r,n),this._random=new h.c(1e3),this._featureCount=i}get about(){return{willQueryAllFeatures:!0,willQueryFullResolutionGeometry:!0}}load(t){return null==this._promise&&(this._promise=this._downloadPages(this._featureCount)),this._promise}unload(t){}async _downloadPages(t){const e=Math.ceil(t/this._queryInfo.pageSize),s=Array.from({length:e},((t,e)=>e)).sort(((t,e)=>this._random.getInt()-this._random.getInt())),r=await Promise.all(s.map((t=>this._downloadPage(t)))),n=new Td(Wl.empty(this._metadata),null,-1,!0);this._store.insert(n);const o=r.filter((t=>t));if(o.length)throw new i.c("featurelayer-query","Encountered errors when downloading data",{errors:o})}async _downloadPage(t){try{const e=this._queryInfo.createPagedQuery(t),s=await this._fetch(e,this._options),i=new Td(s,e.inner.toJSON(),t,!1);return(0,a.wp)(this._options),this._store.insert(i),null}catch(t){return t}}}class Md{constructor(t){this.size=0,this._start=0,this.maxSize=t,this._buffer=new Array(t)}get entries(){return this._buffer}enqueue(t){if(this.size===this.maxSize){const e=this._buffer[this._start];return this._buffer[this._start]=t,this._start=(this._start+1)%this.maxSize,e}return this._buffer[(this._start+this.size++)%this.maxSize]=t,null}dequeue(){if(0===this.size)return null;const t=this._buffer[this._start];return this._buffer[this._start]=null,this.size--,this._start=(this._start+1)%this.maxSize,t}peek(){return 0===this.size?null:this._buffer[this._start]}find(t){if(0===this.size)return null;for(const e of this._buffer)if(null!=e&&t(e))return e;return null}clear(t){let e=this.dequeue();for(;null!=e;)t&&t(e),e=this.dequeue()}}const Ed="__esri_timestamp__";class Cd{constructor(t,e,s,i,r=128){this._trackIdToObservations=new Map,this._idCounter=0,this._lastPurge=performance.now(),this._addOrUpdated=new Map,this._removed=[],this._maxAge=0,this._timeInfo=s,this._purgeOptions=i,this.store=t,this.objectIdField=e,this.purgeInterval=r,this._useGeneratedIds="__esri_stream_id__"===this.objectIdField}removeById(t){this._removed.push(t)}removeByTrackId(t){const e=this._trackIdToObservations.get(t);if(e)for(const t of e.entries)this._removed.push(t)}add(t){if(this._useGeneratedIds){const e=this._nextId();t.attributes[this.objectIdField]=e,t.objectId=e}else t.objectId=t.attributes[this.objectIdField];const e=t.objectId;if(this._addOrUpdated.set(e,t),this._maxAge=Math.max(this._maxAge,t.attributes[this._timeInfo.startTimeField]),!this._timeInfo.trackIdField)return null==this._trackIdLessObservations&&(this._trackIdLessObservations=new Md(1e5)),void this._trackIdLessObservations.enqueue(e);const s=t.attributes[this._timeInfo.trackIdField];if(!this._trackIdToObservations.has(s)){const t=null!=this._purgeOptions?.maxObservations?this._purgeOptions.maxObservations:1e3,e=(0,jh.qk)(t,0,1e3);this._trackIdToObservations.set(s,new Md(e))}const i=this._trackIdToObservations.get(s),r=i?.enqueue(e);null!=r&&(this._addOrUpdated.has(r)?this._addOrUpdated.delete(r):this._removed.push(r))}checkForUpdates(){const t=this._getToAdd(),e=this._getToRemove(),s=performance.now();s-this._lastPurge>=this.purgeInterval&&(this._purge(s),this._lastPurge=s);const i=[];if(null!=e)for(const t of e){const e=this.store.removeById(t);null!=e&&i.push(e)}const r=[];if(null!=t){const i=new Set(e??[]);for(const e of t)i.has(e.objectId)||(e.attributes[Ed]=s,this.store.add(e),r.push(e))}return!(!r.length&&!i?.length||(this.store.update(r,i),0))}_getToAdd(){if(!this._addOrUpdated.size)return null;const t=new Array(this._addOrUpdated.size);let e=0;return this._addOrUpdated.forEach((s=>t[e++]=s)),this._addOrUpdated.clear(),t}_getToRemove(){const t=this._removed;return this._removed.length?(this._removed=[],t):null}_nextId(){const t=this._idCounter;return this._idCounter=(this._idCounter+1)%4294967294+1,t}_purge(t){const e=this._purgeOptions;null!=e&&(this._purgeSomeByDisplayCount(e),this._purgeByAge(e),this._purgeByAgeReceived(t,e),this._purgeTracks())}_purgeSomeByDisplayCount(t){if(!t.displayCount)return;let e=this.store.size;if(e>t.displayCount){if(this._timeInfo.trackIdField)for(const s of this._trackIdToObservations.values())if(e>t.displayCount&&s.size){const t=s.dequeue();this._removed.push(t),e--}if(null!=this._trackIdLessObservations){let s=e-t.displayCount;for(;s-- >0;){const t=this._trackIdLessObservations.dequeue();null!=t&&this._removed.push(t)}}}}_purgeByAge(t){const e=this._timeInfo?.startTimeField;if(!t.age||!e)return;const s=60*t.age*1e3,i=this._maxAge-s;this.store.forEach((t=>{t.attributes[e]<i&&this._removed.push(t.objectId)}))}_purgeByAgeReceived(t,e){if(!e.ageReceived)return;const s=t-60*e.ageReceived*1e3;this.store.forEach((t=>{t.attributes[Ed]<s&&this._removed.push(t.objectId)}))}_purgeTracks(){this._trackIdToObservations.forEach(((t,e)=>{0===t.size&&this._trackIdToObservations.delete(e)}))}}var kd=s(57006);let Fd=class extends P.c{constructor(t){super(t)}get connectionStatus(){return this.connection?.connectionStatus}get errorString(){return this.connection?.errorString}};(0,T._)([(0,E.qq)()],Fd.prototype,"connection",void 0),(0,T._)([(0,E.qq)()],Fd.prototype,"connectionStatus",null),(0,T._)([(0,E.qq)()],Fd.prototype,"errorString",null),Fd=(0,T._)([(0,k.c)("geoscene.views.2d.layers.features.sources.StreamConnectionState")],Fd);class Ad{constructor(t,e){this._metadata=t,this._onUpdate=e,this._objectIdToFeature=new Map}get size(){return this._objectIdToFeature.size}get reader(){return Wl.fromFeatures([...this._objectIdToFeature.values()],this._metadata)}add(t){this._objectIdToFeature.set(t.objectId,t)}forEach(t){this._objectIdToFeature.forEach(t)}removeById(t){const e=this._objectIdToFeature.get(t);return e?(this._objectIdToFeature.delete(t),e):null}clear(){this._objectIdToFeature=new Map}update(t,e){this._onUpdate(t?.length??0)}}class Rd extends Fu{constructor(t){super(),this._reader=t,this.chunkId="stream-chunk",this.normalizedChunkId="stream-chunk"}get reader(){return this._reader}get first(){return!0}get end(){return!0}get queryInfo(){return{type:"stream",chunkId:this.chunkId,size:this.size(),end:this.end}}get isTiled(){return!1}getTileReader(t){const e=this.queryFeaturesInBounds(t.bounds);return e.setTransformForDisplay(t.transform),e}}class Od extends Ku{constructor(t,e,s,i,r){super(s),this._service=t,this._dataFilter=e,this._streamOptions=i,this._metadata=r,this._connectionState=new Fd,this._forceRefresh=!1,this.events=new Gc.c;const{objectIdField:n,timeInfo:o}=this._metadata,{purgeOptions:a}=e;this._stagingStore=new Ad(this._metadata,(t=>this.events.emit("features-updated",t))),this._manager=new Cd(this._stagingStore,n,o,a),this.connect()}destroy(){super.destroy(),this.disconnect()}get about(){return{willQueryAllFeatures:!1,willQueryFullResolutionGeometry:!1}}get connectionStatus(){return this._connectionState.connectionStatus}get errorString(){return this._connectionState?.errorString}async refresh(){const t=null!=this._chunk;this._manager.checkForUpdates()||!t||this._forceRefresh?(this._chunk&&this._store.remove(this._chunk),this._forceRefresh=!1,this._chunk=new Rd(this._stagingStore.reader),this._store.insert(this._chunk),this.events.emit("tick")):this.events.emit("tick")}async updateFields(t){throw new Error("Updating available fields not supported for StreamLayer")}async load(t){}unload(t){}disconnect(){this._connection=(0,M.mG)(this._connection),this._connectionState.connection=null,this._handlesGroup?.remove()}connect(){if(null!=this._connection)return;const{geometryType:t,spatialReference:e}=this._metadata,{maxReconnectionAttempts:s,maxReconnectionInterval:i,geometryDefinition:n,definitionExpression:o,customParameters:a}=this._dataFilter;this._connection=(0,kd.createConnection)(this._service.source,e,this._streamOptions.outSR,t,o,n,s,i,a),this._handlesGroup=(0,r.Ip)([this._connection.on("data-received",(t=>this._onFeature(t))),this._connection.on("message-received",(t=>this._onWebSocketMessage(t)))]),this._connectionState.connection=this._connection}clear(){this._manager.checkForUpdates(),this._stagingStore.clear(),this._forceRefresh=!0}updateCustomParameters(t){this._connection?.updateCustomParameters(t)}sendMessageToSocket(t){this._connection?.sendMessageToSocket(t)}sendMessageToClient(t){this._connection?.sendMessageToClient(t)}_onWebSocketMessage(t){if("type"in t)switch(t.type){case"delete":if(t.objectIds)for(const e of t.objectIds)this._manager.removeById(e);if(t.trackIds)for(const e of t.trackIds)this._manager.removeByTrackId(e);break;case"clear":this.clear()}this.events.emit("message-received",t)}_onFeature(t){try{this._manager.add(t),this.events.emit("data-received",t)}catch(t){}}}class Nd{constructor(t){this._onChange=t,this._chunks=new Map,this._overrideChunk=new Au,this._chunksToRemove=[],this.events=new Gc.c,this.featureAdapter=new vl}destroy(){this.clear()}clear(){for(const t of this._chunks.values())this._chunksToRemove.push(t);this._chunks.clear(),this._overrideChunk&&this._chunksToRemove.push(this._overrideChunk),this._overrideChunk=new Au}*chunks(){this._overrideChunk&&(yield this._overrideChunk),yield*this._chunks.values()}insert(t){(0,n.c)("geoscene-2d-update-debug")&&console.debug(`Chunk[${t.chunkId}] SourceChunkStore.insert`),this._overrideChunk.overridenIds.size&&t.reader.removeIds(this._overrideChunk.overridenIds),this._chunks.set(t.chunkId,t),this.events.emit("changed"),this._onChange()}remove(t){(0,n.c)("geoscene-2d-update-debug")&&console.debug(`Chunk[${t.chunkId}] SourceChunkStore.remove`),this._chunks.delete(t.chunkId),this._chunksToRemove.push(t)}cleanupRemovedChunks(){const t=this._chunksToRemove;return this._chunksToRemove=[],t}applyOverrides(t){this._overrideChunk.applyOverrides(t);for(const t of this._chunks.values())t.reader.removeIds(this._overrideChunk.overridenIds),t.invalidate()}forEach(t){const e=new Set;for(const s of this.chunks()){const i=s.reader.getCursor();for(;i.next();){const s=i.getObjectId();e.has(s)||(t(i.copy()),e.add(s))}}}forEachUnsafe(t){const e=new Set;for(const s of this.chunks()){const i=s.reader.getCursor();for(;i.next();){const s=i.getObjectId();e.has(s)||(t(i),e.add(s))}}}forEachInBounds(t,e){const s=new Set;for(const i of this.chunks()){const r=i.queryFeaturesInBounds(t);for(;r.next();){const t=r.getObjectId();s.has(t)||(e(r.copy()),s.add(t))}}}forEachBounds(t,e){const s=(0,Vc.Su)();for(const i of t)i.getBounds(s)&&e(s)}}var Dd=s(23964),zd=s(60936);let Ld=class extends P.c{constructor(t){super(t),this.debugName="",this._updatingHandles=new zd.A,this._idToUpdatingState=new Dd.c}get updating(){const t=this._updatingHandles.updating||Array.from(this._idToUpdatingState.values()).some((t=>t));if((0,n.c)("geoscene-2d-log-updating")){const e=Array.from(this._idToUpdatingState.entries()).map((([t,e])=>`-> ${t}: ${e}`)).join("\n");console.log(`${this.debugName}: Updating: ${t}\n-> Handles: ${this._updatingHandles.updating}\n${e}`)}return t}addUpdateTracking(t,e){const s=(0,c.aE)((()=>e.updating),(e=>this._idToUpdatingState.set(t,e)),{sync:!0});this.addHandles(s)}addPromise(t){return this._updatingHandles.addPromise(t)}};(0,T._)([(0,E.qq)({constructOnly:!0})],Ld.prototype,"debugName",void 0),(0,T._)([(0,E.qq)({readOnly:!0})],Ld.prototype,"updating",null),Ld=(0,T._)([(0,k.c)("geoscene.view.2d.layers.support.UpdateTracking2D")],Ld);class Bd{constructor(t,e,s,i){this._aggregateAdapter=t,this._subscriptions=e,this._onChange=s,this._connection=i,this._updateTracking=new Ld({debugName:"FeatureSource"}),this._store=new Nd(this._onChange)}destroy(){this._strategy?.destroy(),this._store.destroy(),this._streamMessenger?.destroy()}get _eventLog(){return this._connection.eventLog}get metadata(){if(!this._metadata)throw new Error("InternalError: Metadata not defined. Was update called?");return this._metadata}get service(){return this._schema.service}get store(){return this._store}get streamMessenger(){return null==this._streamMessenger&&this._initStreamMessenger(),this._streamMessenger}get statistics(){return Xu.from(this._store)}get updateTracking(){return this._updateTracking}get queryEngine(){if(!this._queryEngine){if(!this._schema)return null;const{dataFilter:t}=this._schema.mutable,e=this._schema.mutable.availableFields,s=this._metadata;this._queryEngine=new Wc.U({featureStore:this._store,fieldsIndex:s.fieldsIndex,geometryType:s.geometryType,objectIdField:s.objectIdField,hasM:!1,hasZ:!1,spatialReference:t.outSpatialReference,cacheSpatialQueries:!0,aggregateAdapter:this._aggregateAdapter,timeInfo:s.timeInfo,definitionExpression:t.definitionExpression,availableFields:e})}return this._queryEngine}get isStream(){return"stream"===this._schema.type}chunks(){return Array.from(this._store.chunks())}cleanupRemovedChunks(){return this._store.cleanupRemovedChunks()}onSubscribe(t){this._eventLog.onEvent({type:"subscribe",tile:t.tile.id});const e=this._strategy?.load(t);e&&(e.then((()=>this._eventLog.onEvent({type:"loaded",tile:t.tile.id}))).catch((e=>this._eventLog.onEvent({type:"error",tile:t.tile.id,error:e}))),this._updateTracking.addPromise(e))}onResume(t){this._updateTracking.addPromise((0,a.jO)(this._strategy?.load(t)))}onUnsubscribe(t){this._eventLog.onEvent({type:"unsubscribe",tile:t.tile.id}),this._strategy?.unload(t)}getOverride(t){return this._updateTracking.addPromise(this._doGetOverride(t))}applyOverride(t){this._store.applyOverrides(t)}async update(t,e){const s=t.source,i=(0,G.qq)(this._schema?.mutable,s.mutable);if(!i)return!1;if((0,n.c)("geoscene-2d-update-debug")&&console.debug(`Version[${e}] FeatureSource.update`,{changes:i}),this._schema=s,this._metadata=new Tl(this._schema.service.metadata),this._queryEngine?.destroy(),this._queryEngine=null,"feature"===this._schema.type&&null!=this._schema.service.queryMetadata.lastEditDate&&(this._lastEditDate=this._schema.service.queryMetadata.lastEditDate),null==this._streamMessenger&&"stream"===this._schema.type&&this._initStreamMessenger(),(0,G.mQ)(i,"sourceRefreshVersion")&&this._strategy?.refresh)return await this._strategy.refresh(),!0;if("feature"===s.type&&(0,G.mQ)(i,"availableFields")){if(await this._queryLastEditDateChanged())await this._updateStrategy(e);else{this._eventLog.onEvent({type:"updateFieldsStart"});try{await this._strategy.updateFields(s.mutable.availableFields),this._eventLog.onEvent({type:"updateFieldsEnd"})}catch(t){this._eventLog.onEvent({type:"updateFieldsError",error:t})}}return!1}return!(!(0,G.Go)(i,"dataFilter")&&!(0,G.Go)(i,"sourceRefreshVersion")||(await this._updateStrategy(e),0))}_initStreamMessenger(){null==this._streamMessenger&&(this._streamMessenger=new $u(this._connection))}async _doGetOverride(t){return this._strategy.queryOverride(t)}async _queryLastEditDateChanged(){if(null==this._lastEditDate)return!1;const t=this._schema.service.source,e={...t.query,f:"json"},s=(await(0,qu.c)(t.path,{query:e,responseType:"json"})).data.editingInfo.lastEditDate;return s!==this._lastEditDate&&(this._lastEditDate=s,!0)}async _createStrategy(){const t=this.service,e="isSourceHosted"in t&&t.isSourceHosted,s=Array.isArray(t.source),i=t.source&&"collection"in t.source,r=e||s||i;if("stream"===this._schema.type){const t=new Od(this._schema.service,this._schema.mutable.dataFilter,this._store,{outSR:this._schema.mutable.dataFilter.outSpatialReference},this.metadata);return this._streamMessenger.strategy=t,t}const n=Hu.fromSchema(this._schema,this._metadata),o=await this._supportSnapshotMode(this._schema,n);return o?new Pd(this._schema.service,n,this._store,o.featureCount,this.metadata,this._eventLog):r?new Id(this._schema.service,n,this._store,this.metadata,this._eventLog):new wd(this._schema.service,n,this._store,this.metadata,this._eventLog)}async _updateStrategy(t){const e=await this._createStrategy();this._eventLog.onEvent({type:"updateStrategyStart",about:e.about});const s=!!this._strategy;this._store.clear(),this._strategy?.destroy(),this._strategy=e,(0,n.c)("geoscene-2d-update-debug")&&console.debug(`Version[${t}] FeatureSource.updateStrategy`,{strategy:e});const i=Array.from(this._subscriptions.values());if(!i.length)return void this._eventLog.onEvent({type:"updateStrategyEnd"});const r=Promise.all(i.map((t=>this._strategy.load(t).then((()=>this._eventLog.onEvent({type:"loaded",tile:t.tile.id}))).catch((e=>this._eventLog.onEvent({type:"error",tile:t.tile.id,error:e}))))));this._updateTracking.addPromise(r);try{s&&await r}catch(t){(0,a.Az)(t)}this._eventLog.onEvent({type:"updateStrategyEnd"}),(0,n.c)("geoscene-2d-update-debug")&&console.debug(`Version[${t}] FeatureSource.updateStrategyEnd`,{strategy:e})}async _supportSnapshotMode(t,e){const{queryMetadata:s}=t.service,i=s.snapshotInfo;if(!i||!i.supportsSnapshotMinThreshold||!i.snapshotCountThresholds)return null;const r=t.service.source,n=e.createQuery();n.inner.orderByFields=[],n.inner.returnGeometry=!1;const o=(await(0,Wu.WE)(r,n.inner,{query:n.customParameters})).data.count,{min:a,max:h}=i.snapshotCountThresholds;return o<=a||i.supportsSnapshotMaxThreshold&&o<h?{featureCount:o}:null}}var Ud=s(44980);class Gd{constructor(t,e){this._handles=new Ud.c,this._abortController=new AbortController,this._resolver=(0,a.qG)(),this._isDone=!1,this._aborted=!1,this.tile=t,this._version=e,this._handles.add([])}destroy(){this.pause(),this._handles.destroy()}get key(){return this.tile.key}get version(){return this._version}set version(t){this._version=t}get signal(){return this._abortController.signal}get options(){return{signal:this._abortController.signal}}get done(){return this._resolver.promise}get isDone(){return this._isDone}resolve(){this._isDone=!0,this._resolver.resolve()}get paused(){return this._aborted}resume(){this._abortController=new AbortController,this._aborted=!1}pause(){this._aborted||(this._aborted=!0,this._abortController.abort())}}var Vd=s(29624),qd=s(95247),Wd=s(87636);class Xd{constructor(t,e){this.key=new p.c(0,0,0,0),this.bounds=(0,L.Su)(),this.objectIds=new Set,this.key.set(e);const s=t.getLODInfoAt(this.key);this.tileInfoView=t,this.tileInfoView.getTileBounds(this.bounds,this.key,!0),this.resolution=s.resolution,this.scale=s.scale,this.level=s.level}get lod(){return this.tileInfoView.getLODInfoAt(this.key)}get id(){return this.key.id}get extent(){return qd.c.fromBounds(this.bounds,this.tileInfoView.tileInfo.spatialReference)}get transform(){return{originPosition:"upperLeft",scale:[this.resolution,this.resolution],translate:[this.bounds[0],this.bounds[3]]}}createArcadeEvaluationOptions(t){return{$view:{scale:this.scale,timeZone:t}}}createChildTiles(){const t=this.key.getChildKeys(),e=Vd.c.acquire();for(let s=0;s<t.length;s++)e[s]=new Xd(this.tileInfoView,t[s]);return e}getQuantizationParameters(){return Wd.c.fromJSON({mode:"view",originPosition:"upperLeft",tolerance:this.resolution,extent:{xmin:this.bounds[0],ymin:this.bounds[1],xmax:this.bounds[2],ymax:this.bounds[3],spatialReference:this.tileInfoView.tileInfo.spatialReference}})}}class Yd{constructor(t){this.edit=t,this.resolver=(0,a.qG)()}}class jd{constructor(t,e){this.schema=t,this.version=e,this.resolver=(0,a.qG)()}}class Hd{constructor(){this._aggregateAdapter={getFeatureObjectIds:t=>this._processor.getFeatureObjectIdsForAggregate(t)},this._subscriptions=new Map,this._updateRequested=!1,this._updateSubscriptionRequests=[],this._updateHighlightRequests=[]}destroy(){this._subscriptions.clear(),this._processor.destroy(),this._source.destroy(),this._handles.remove(),this._editState=null,this._tileInfoView=null}onDetach(){this.destroy(),this._initialize(this._connection)}_initialize(t){this._source=new Bd(this._aggregateAdapter,this._subscriptions,(()=>this._requestUpdate()),t),this._processor=new Vu(t,this._source),this._handles=(0,r.Ip)([(0,c.aE)((()=>this._source.updateTracking.updating),(()=>{this._requestUpdate(),this._connection.layerView.setUpdating({data:this._source.updateTracking.updating,pipeline:!0})}))])}set remoteClient(t){this._connection=new U(t),this._initialize(this._connection)}get features(){const t=this._source.queryEngine;if(!t)throw new i.c("no-queryEngine","No query engine defined");return t}get aggregates(){const t=this._processor.aggregateQueryEngine;if(!t)throw new i.c("no-queryEngine","No aggregate query engine defined");return t}get processor(){return this._processor}get streamMessenger(){return this._source.streamMessenger}getDisplayFeatures(t){return this._processor.getDisplayFeatures(t)}async updateSchema(t,e){return(0,n.c)("geoscene-2d-update-debug")&&this._updateSchemaState&&console.error("InternalError: Schema already updating"),this._updateSchemaState=new jd(t,e),this._requestUpdate(),this._updateSchemaState.resolver.promise}updateSubscriptions(t){this._updateSubscriptionRequests.push(t),this._requestUpdate()}updateHighlight(t){this._updateHighlightRequests.push(t),this._requestUpdate()}async onEdits(t){if(null!=this._editState)throw new i.c("InternalError - Already processing an edit");this._editState=new Yd(t);const e=this._editState.resolver.promise;return this._requestUpdate(),e}queryStatistics(){return this._source.statistics.toJSON()}async queryVisibleFeatures(t,e){return this.features.executeQuery(t,e)}async queryHeatmapStatistics(t){const e=Math.round((0,l.im)(t.radius));let s=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY;const r="string"==typeof t.fieldOffset,n=t.fieldOffset??0,o=Array.from(this._subscriptions.values()),a=this._source.chunks(),h=e**2,c=3/(Math.PI*h),u=2*e,d=Math.ceil(B.gT/u);for(const e of o){const o=e.tile,l=new Float64Array(d*d);for(const e of a){const s=e.getTileReader(o);if(!s)continue;const i=s.getCursor();for(;i.next();){let e=1;if(null!=t.field){const s=i.readAttribute(t.field);e=r?-1*+s:+s+n}const s=i.readXForDisplay()/u,o=i.readYForDisplay()/u,a=Math.floor(s),p=Math.floor(o);if(a<0||p<0||a>=d||p>=d)continue;const _=((.5+a-s)*u)**2+((.5+p-o)*u)**2;if(_>h)continue;const f=e*(c*(1-_/h)**2);l[p+a*d]+=f}}for(let t=0;t<l.length;t++)s=Math.min(s,l[t]),i=Math.max(i,l[t])}return{max:i,min:s}}async getSampleFeatures(t){const e=this._source.chunks();if(e.reduce(((t,e)=>t+e.size()),0)<=t.minFeatureCount){if(!this._source.updateTracking.updating){const t=[];return this._source.store.forEachUnsafe((e=>t.push(e.readLegacyFeatureWorldSpace()))),t}return null}const s=new Set,i=[],r=e.map((t=>t.reader.getCursor())),n=new h.c,o=3*t.sampleSize;for(let a=0;a<o&&i.length<t.sampleSize;a++){const t=r[n.getIntRange(0,e.length-1)];if(0===t.getSize())continue;const o=n.getIntRange(0,t.getSize()-1);t.setIndex(o);const a=t.getObjectId();s.has(a)||(s.add(a),i.push(t.readLegacyFeatureWorldSpace()))}return i.length>=t.sampleSize?i:null}_requestUpdate(){this._updateRequested||(this._updateRequested=!0,(0,o.o)((()=>this._scheduleNextUpdate())))}_scheduleNextUpdate(){this._updateRequested&&(this._ongoingUpdate||(this._ongoingUpdate=this._doUpdate().finally((()=>{this._ongoingUpdate=null,this._scheduleNextUpdate()})),this._updateRequested=!1))}_subscribe(t){const e=t.tileId;if(this._subscriptions.has(e)){const s=this._subscriptions.get(e);return void(s.paused&&((0,n.c)("geoscene-2d-update-debug")&&console.debug(`Tile[${e}] Pipeline.resume`),s.resume(),s.version=t.version,this._source.onResume(s)))}(0,n.c)("geoscene-2d-update-debug")&&console.debug(`Tile[${e}] Pipeline.subscribe`);const s=new Xd(this._tileInfoView,e),i=new Gd(s,t.version);this._subscriptions.set(e,i),this._source.onSubscribe(i),this._processor.onSubscribe(i)}_unsubscribe(t){const e=this._subscriptions.get(t);e&&((0,n.c)("geoscene-2d-update-debug")&&console.debug(`Tile[${t}] Pipeline.unsubscribe`),this._source.onUnsubscribe(e),this._processor.onUnsubscribe(e),this._subscriptions.delete(e.key.id),e.destroy())}_pauseSubscription(t){const e=this._subscriptions.get(t);e&&((0,n.c)("geoscene-2d-update-debug")&&console.debug(`Tile[${t}] Pipeline.pause`),e.pause())}async _doUpdate(){if((0,n.c)("geoscene-2d-update-debug")&&console.debug("Pipeline._doUpdateStart"),await this._connection.layerView.setUpdating({data:this._source.updateTracking.updating,pipeline:!0}),this._updateSubscriptionRequests.length){const t=this._updateSubscriptionRequests;this._updateSubscriptionRequests=[];for(const e of t)this._doUpdateSubscriptions(e)}const t=this._updateSchemaState;if(this._updateSchemaState=null,null!=t){const{schema:e,version:s}=t;await this._doUpdateSchema(e,s)}const e=this._editState;if(this._editState=null,null!=e){(0,n.c)("geoscene-2d-update-debug")&&console.debug("Pipeline.applyEditOverride",e.edit);const t=await this._source.getOverride(e.edit);await this._processor.applyOverride(t),(0,n.c)("geoscene-2d-update-debug")&&console.debug("Pipeline.endEditOverride",e.edit)}if(this._updateHighlightRequests.length){const t=this._updateHighlightRequests;this._updateHighlightRequests=[];for(const e of t)this._processor.updateHighlight(e)}const s=this._source.cleanupRemovedChunks();this._processor.removeChunks(s);try{this._subscriptions.size&&((0,n.c)("geoscene-2d-update-debug")&&console.debug("Pipeline.updateChunksStart"),await this._processor.updateChunks(),(0,n.c)("geoscene-2d-update-debug")&&console.debug("Pipeline.updateChunksEnd"))}catch(t){(0,a.Az)(t)}null!=e&&e.resolver.resolve(),null!=t&&t.resolver.resolve(),this._updateRequested?((0,n.c)("geoscene-2d-update-debug")&&console.debug("Pipeline._doUpdateEnd [updateRequested=true]"),await this._connection.layerView.setUpdating({data:this._source.updateTracking.updating,pipeline:!0})):((0,n.c)("geoscene-2d-update-debug")&&console.debug("Pipeline._doUpdateEnd [updateRequested=false, After flush]"),await this._connection.layerView.setUpdating({data:this._source.updateTracking.updating,pipeline:this._updateRequested}))}async _doUpdateSchema(t,e){if((0,n.c)("geoscene-2d-update-debug")&&console.debug(`Version[${e}] Pipeline.updateStart`,{schema:t}),!this._tileInfoView){const e=u.c.fromJSON(t.source.tileInfoJSON);this._tileInfoView=new I(e)}const s={tileInfo:this._tileInfoView?.tileInfo};try{const i=await this._source.update(t,e),r=Array.from(this._subscriptions.values());await this._processor.update(t,e,s,i,r)}catch(t){console.error(t)}(0,n.c)("geoscene-2d-update-debug")&&console.debug(`Version[${e}] Pipeline.updateEnd`)}_doUpdateSubscriptions(t){if((0,n.c)("geoscene-2d-update-debug")&&console.debug("Pipeline.updateSubscriptions",t),!this._tileInfoView){const e=u.c.fromJSON(t.tileInfoJSON);this._tileInfoView=new I(e)}for(const e of t.subscribe)this._subscribe(e);for(const e of t.unsubscribe)this._unsubscribe(e);if((0,n.c)("featurelayer-query-pausing-enabled"))for(const e of t.pause)this._pauseSubscription(e)}}},53680:(t,e,s)=>{s.d(e,{c:()=>r});var i=s(69752);class r{static getId(t,e,s,i){return"object"==typeof t?`${t.level}/${t.row}/${t.col}/${t.world}`:`${t}/${e}/${s}/${i}`}constructor(t,e,s,i){this.set(t,e,s,i)}get key(){return this}get id(){return this.toString()}get normalizedId(){return`${this.level}/${this.row}/${this.col}`}set id(t){this.set(t)}get hash(){const t=4095&this.row,e=4095&this.col,s=63&this.level;return(3&this.world)<<30|e<<22|t<<8|s}acquire(t,e,s,i){this.set(t,e,s,i)}contains(t){const e=t.level-this.level;return e>=0&&this.row===t.row>>e&&this.col===t.col>>e&&this.world===t.world}containsChild(t){const e=t.level-this.level;return e>0&&this.row===t.row>>e&&this.col===t.col>>e&&this.world===t.world}equals(t){return this.level===t.level&&this.row===t.row&&this.col===t.col&&this.world===t.world}clone(){return new r(this)}release(){this.level=0,this.row=0,this.col=0,this.world=0}set(t,e,s,i){if(null==t)this.level=0,this.row=0,this.col=0,this.world=0;else if("object"==typeof t)this.level=t.level||0,this.row=t.row||0,this.col=t.col||0,this.world=t.world||0;else if("string"==typeof t){const[e,s,i,r]=t.split("/");this.level=parseFloat(e),this.row=parseFloat(s),this.col=parseFloat(i),this.world=parseFloat(r)}else this.level=+t,this.row=+e,this.col=+s,this.world=+i||0;return this}toString(){return`${this.level}/${this.row}/${this.col}/${this.world}`}getParentKey(){return this.level<=0?null:new r(this.level-1,this.row>>1,this.col>>1,this.world)}getNeighborId(t,e){return`${this.level}/${this.row+e}/${this.col+t}/${this.world}`}getChildKeys(){const t=this.level+1,e=this.row<<1,s=this.col<<1,i=this.world;return[new r(t,e,s,i),new r(t,e,s+1,i),new r(t,e+1,s,i),new r(t,e+1,s+1,i)]}compareRowMajor(t){return this.row<t.row?-1:this.row>t.row?1:this.col<t.col?-1:this.col>t.col?1:0}}r.pool=new i.c(r,null,null,25,50)},75040:(t,e,s)=>{var i;s.d(e,{u:()=>i}),function(t){t[t.Pass=0]="Pass",t[t.Draw=1]="Draw"}(i||(i={}))},90736:(t,e,s)=>{s.d(e,{If:()=>n,Uc:()=>r}),s(85256),s(74784),(0,s(37008).Su)();class i{constructor(t){this.message=t}toString(){return`AssertException: ${this.message}`}}function r(t,e){if(!t){e=e||"Assertion";const t=new Error(e).stack;throw new i(`${e} at ${t}`)}}function n(t,e,s,i){let r,n=(s[0]-t[0])/e[0],o=(i[0]-t[0])/e[0];n>o&&(r=n,n=o,o=r);let a=(s[1]-t[1])/e[1],h=(i[1]-t[1])/e[1];if(a>h&&(r=a,a=h,h=r),n>h||a>o)return!1;a>n&&(n=a),h<o&&(o=h);let c=(s[2]-t[2])/e[2],l=(i[2]-t[2])/e[2];return c>l&&(r=c,c=l,l=r),!(n>l||c>o||(l<o&&(o=l),o<0))}},27064:(t,e,s)=>{s.d(e,{K:()=>l});var i=s(70680),r=s(10860),n=s(54792),o=s(23964),a=s(66168),h=s(52888);class c{constructor(t,e){this.item=t,this.controller=e,this.promise=null}}class l{constructor(t){this._schedule=null,this._task=null,this._deferreds=new o.c,this._controllers=new o.c,this._processingItems=new o.c,this._pausedSignal=(0,h.O)(!1),this.concurrency=1,t.concurrency&&(this.concurrency=t.concurrency),this._queue=new n.c(t.peeker),this.process=t.process;const e=t.scheduler;t.priority&&e&&(this._task=e.registerTask(t.priority,this))}destroy(){this.clear(),this._schedule=(0,i.oR)(this._schedule),this._task=(0,i.oR)(this._task)}get updating(){return!!this._task?.updating||this.running}get length(){return this._processingItems.size+this._queue.length}abort(t){const e=this._controllers.get(t);e&&e.abort()}clear(){this._queue.clear();const t=[];this._controllers.forEach((e=>t.push(e))),this._controllers.clear(),t.forEach((t=>t.abort())),this._processingItems.clear(),this._cancelNext()}forEach(t){this._deferreds.forEach(((e,s)=>t(s)))}get(t){const e=this._deferreds.get(t);return e?e.promise:void 0}isOngoing(t){return this._processingItems.has(t)}has(t){return this._deferreds.has(t)}pause(){this._pausedSignal.value||(this._pausedSignal.value=!0,this._cancelNext())}push(t,e){const s=this.get(t);if(s)return s;const i=new AbortController;let n=null;e&&(n=(0,r.wD)(e,(()=>i.abort())));const o=()=>{a.remove(),null!=n&&n.remove(),this._removeItem(t),this._queue.remove(t),this._scheduleNext()},a=(0,r.Ij)(i.signal,(()=>{const e=this._processingItems.get(t);e&&e.controller.abort(),o(),h.reject((0,r.Uh)())})),h=(0,r.qG)();return this._deferreds.set(t,h),this._controllers.set(t,i),h.promise.then(o,o),this._queue.push(t),this._scheduleNext(),h.promise}last(){return this._queue.last()}lastPromise(){const t=this.last();return t?this.get(t):null}peek(){return this._queue.peek()}popLast(){const t=this._queue.popLast();return t&&(this._deferreds.get(t)?.reject((0,r.Uh)("Removed from queue")),this._removeItem(t)),t}reset(){const t=[];this._processingItems.forEach((e=>t.push(e))),this._processingItems.clear();for(const e of t)this._queue.push(e.item),e.controller.abort();this._scheduleNext()}resume(){this._pausedSignal.value&&(this._pausedSignal.value=!1,this._scheduleNext())}takeAll(){const t=[];for(;this._queue.length;)t.push(this._queue.pop());return this.clear(),t}get running(){return!this._pausedSignal.value&&this._queue.length>0&&this._processingItems.size<this.concurrency}runTask(t){for(;!t.done&&this._queue.length>0&&this._processingItems.size<this.concurrency;)this._process(this._queue.pop()),t.madeProgress()}_removeItem(t){this._deferreds.delete(t),this._controllers.delete(t),this._processingItems.delete(t)}_scheduleNext(){this._task||this._pausedSignal.value||this._schedule||(this._schedule=(0,a.Ow)((()=>{this._schedule=null,this._next()})))}_next(){for(;this._queue.length>0&&this._processingItems.size<this.concurrency;)this._process(this._queue.pop())}_cancelNext(){this._schedule&&(this._schedule.remove(),this._schedule=null)}_processResult(t,e){this._canProcessFulfillment(t)&&(this._scheduleNext(),this._deferreds.get(t.item).resolve(e))}_processError(t,e){this._canProcessFulfillment(t)&&(this._scheduleNext(),this._deferreds.get(t.item).reject(e))}_canProcessFulfillment(t){return!!this._deferreds.get(t.item)&&this._processingItems.get(t.item)===t}_process(t){if(null==t)return;let e;const s=new AbortController,i=new c(t,s);this._processingItems.set(t,i);try{e=this.process(t,s.signal)}catch(t){this._processError(i,t)}(0,r.eW)(e)?(i.promise=e,e.then((t=>this._processResult(i,t)),(t=>this._processError(i,t)))):this._processResult(i,e)}get test(){return{update:t=>this.runTask(t)}}}},39104:(t,e,s)=>{var i;s.d(e,{A:()=>i}),function(t){t[t.Texture=0]="Texture",t[t.RenderBuffer=1]="RenderBuffer"}(i||(i={}))},22184:(t,e,s)=>{s.d(e,{w:()=>c});var i=s(20744),r=(s(9456),s(94460)),n=s(77800),o=s(39104),a=s(51576);class h extends a.O{constructor(t,e){switch(super(),this.context=t,Object.assign(this,e),this.internalFormat){case n.UV.R16F:case n.UV.R16I:case n.UV.R16UI:case n.UV.R32F:case n.UV.R32I:case n.UV.R32UI:case n.UV.R8_SNORM:case n.UV.R8:case n.UV.R8I:case n.UV.R8UI:this.pixelFormat=n.Id.RED}}static validate(t,e){return new h(t,e)}}let c=class t{constructor(t,e=null,s=null){if(this.type=o.A.Texture,this._glName=null,this._samplingModeDirty=!1,this._wrapModeDirty=!1,this._wasImmutablyAllocated=!1,"context"in t)this._descriptor=t,s=e;else{const s=h.validate(t,e);if(!s)throw new i.c("Texture descriptor invalid");this._descriptor=s}this._descriptor.target===n.c5.TEXTURE_CUBE_MAP?this._setDataCubeMap(s):this.setData(s)}get glName(){return this._glName}get descriptor(){return this._descriptor}get usedMemory(){return(0,a.k)(this._descriptor)}get isDirty(){return this._samplingModeDirty||this._wrapModeDirty}dispose(){this._glName&&this._descriptor.context.instanceCounter.decrement(n.y4.Texture,this),this._descriptor.context.gl&&this._glName&&(this._descriptor.context.unbindTexture(this),this._descriptor.context.gl.deleteTexture(this._glName),this._glName=null)}release(){this.dispose()}resize(t,e){const s=this._descriptor;if(s.width!==t||s.height!==e){if(this._wasImmutablyAllocated)throw new i.c("Immutable textures can't be resized!");s.width=t,s.height=e,this._descriptor.target===n.c5.TEXTURE_CUBE_MAP?this._setDataCubeMap(null):this.setData(null)}}_setDataCubeMap(t=null){for(let e=n.c5.TEXTURE_CUBE_MAP_POSITIVE_X;e<=n.c5.TEXTURE_CUBE_MAP_NEGATIVE_Z;e++)this._setData(t,e)}setData(t){this._setData(t)}_setData(e,s){if(!this._descriptor.context?.gl)return;const o=this._descriptor.context.gl;(0,r.m_)(o),this._glName||(this._glName=o.createTexture(),this._glName&&this._descriptor.context.instanceCounter.increment(n.y4.Texture,this)),void 0===e&&(e=null);const a=this._descriptor,h=s??a.target,c=f(h);null===e&&(a.width=a.width||4,a.height=a.height||4,c&&(a.depth=a.depth??1));const g=this._descriptor.context.bindTexture(this,t.TEXTURE_UNIT_FOR_UPDATES);this._descriptor.context.setActiveTexture(t.TEXTURE_UNIT_FOR_UPDATES),l(a),this._configurePixelStorage(),(0,r.m_)(o);const y=this._deriveInternalFormat();if(_(e)){let t="width"in e?e.width:e.codedWidth,s="height"in e?e.height:e.codedHeight;const i=1;e instanceof HTMLVideoElement&&(t=e.videoWidth,s=e.videoHeight),a.width&&a.height,c&&a.depth,a.isImmutable&&!this._wasImmutablyAllocated&&this._texStorage(h,y,a.hasMipmap,t,s,i),this._texImage(h,0,y,t,s,i,e),(0,r.m_)(o),a.hasMipmap&&this.generateMipmap(),a.width||(a.width=t),a.height||(a.height=s),c&&!a.depth&&(a.depth=i)}else{const{width:t,height:s,depth:l}=a;if(null==t||null==s)throw new i.c("Width and height must be specified!");if(c&&null==l)throw new i.c("Depth must be specified!");if(a.isImmutable&&!this._wasImmutablyAllocated&&this._texStorage(h,y,a.hasMipmap,t,s,l),p(e)){const r=e.levels,c=m(h,t,s,l),u=Math.min(c-1,r.length-1);o.texParameteri(a.target,this._descriptor.context.gl.TEXTURE_MAX_LEVEL,u);const d=y;if(!(d in n.sr))throw new i.c("Attempting to use compressed data with an uncompressed format!");this._forEachMipmapLevel(((t,e,s,i)=>{const n=r[Math.min(t,r.length-1)];this._compressedTexImage(h,t,d,e,s,i,n)}),u)}else this._texImage(h,0,y,t,s,l,e),(0,r.m_)(o),a.hasMipmap&&this.generateMipmap()}u(o,this._descriptor),d(o,this._descriptor),function(t,e){const s=t.capabilities.textureFilterAnisotropic;s&&t.gl.texParameterf(e.target,s.TEXTURE_MAX_ANISOTROPY,e.maxAnisotropy??1)}(this._descriptor.context,this._descriptor),(0,r.m_)(o),this._descriptor.context.bindTexture(g,t.TEXTURE_UNIT_FOR_UPDATES)}updateData(e,s,r,n,o,a,h=0){a||console.error("An attempt to use uninitialized data!"),this._glName||console.error("An attempt to update uninitialized texture!");const c=this._descriptor,l=this._deriveInternalFormat(),{context:u,pixelFormat:d,dataType:f,target:m,isImmutable:g}=c;if(g&&!this._wasImmutablyAllocated)throw new i.c("Cannot update immutable texture before allocation!");const y=u.bindTexture(this,t.TEXTURE_UNIT_FOR_UPDATES,!0);(s<0||r<0||n>c.width||o>c.height||s+n>c.width||r+o>c.height)&&console.error("An attempt to update out of bounds of the texture!"),this._configurePixelStorage();const{gl:x}=u;h&&x.pixelStorei(x.UNPACK_SKIP_ROWS,h),_(a)?x.texSubImage2D(m,e,s,r,n,o,d,f,a):p(a)?x.compressedTexSubImage2D(m,e,s,r,n,o,l,a.levels[e]):x.texSubImage2D(m,e,s,r,n,o,d,f,a),h&&x.pixelStorei(x.UNPACK_SKIP_ROWS,0),u.bindTexture(y,t.TEXTURE_UNIT_FOR_UPDATES)}updateData3D(e,s,r,n,o,a,h,c){c||console.error("An attempt to use uninitialized data!"),this._glName||console.error("An attempt to update uninitialized texture!");const l=this._descriptor,u=this._deriveInternalFormat(),{context:d,pixelFormat:_,dataType:m,isImmutable:g,target:y}=l;if(g&&!this._wasImmutablyAllocated)throw new i.c("Cannot update immutable texture before allocation!");f(y)||console.warn("Attempting to set 3D texture data on a non-3D texture");const x=d.bindTexture(this,t.TEXTURE_UNIT_FOR_UPDATES);d.setActiveTexture(t.TEXTURE_UNIT_FOR_UPDATES),(s<0||r<0||n<0||o>l.width||a>l.height||h>l.depth||s+o>l.width||r+a>l.height||n+h>l.depth)&&console.error("An attempt to update out of bounds of the texture!"),this._configurePixelStorage();const{gl:b}=d;if(p(c))c=c.levels[e],b.compressedTexSubImage3D(y,e,s,r,n,o,a,h,u,c);else{const t=c;b.texSubImage3D(y,e,s,r,n,o,a,h,_,m,t)}d.bindTexture(x,t.TEXTURE_UNIT_FOR_UPDATES)}generateMipmap(){const e=this._descriptor;if(!e.hasMipmap){if(this._wasImmutablyAllocated)throw new i.c("Cannot add mipmaps to immutable texture after allocation");e.hasMipmap=!0,this._samplingModeDirty=!0,l(e)}e.samplingMode===n.Ud.LINEAR?(this._samplingModeDirty=!0,e.samplingMode=n.Ud.LINEAR_MIPMAP_NEAREST):e.samplingMode===n.Ud.NEAREST&&(this._samplingModeDirty=!0,e.samplingMode=n.Ud.NEAREST_MIPMAP_NEAREST);const s=this._descriptor.context.bindTexture(this,t.TEXTURE_UNIT_FOR_UPDATES);this._descriptor.context.setActiveTexture(t.TEXTURE_UNIT_FOR_UPDATES),this._descriptor.context.gl.generateMipmap(e.target),this._descriptor.context.bindTexture(s,t.TEXTURE_UNIT_FOR_UPDATES)}setSamplingMode(t){t!==this._descriptor.samplingMode&&(this._descriptor.samplingMode=t,this._samplingModeDirty=!0)}setWrapMode(t){t!==this._descriptor.wrapMode&&(this._descriptor.wrapMode=t,l(this._descriptor),this._wrapModeDirty=!0)}applyChanges(){const t=this._descriptor,e=t.context.gl;this._samplingModeDirty&&(u(e,t),this._samplingModeDirty=!1),this._wrapModeDirty&&(d(e,t),this._wrapModeDirty=!1)}_deriveInternalFormat(){if(null!=this._descriptor.internalFormat)return this._descriptor.internalFormat===n.Id.DEPTH_STENCIL&&(this._descriptor.internalFormat=n.Id.DEPTH24_STENCIL8),this._descriptor.internalFormat;switch(this._descriptor.dataType){case n.OK.FLOAT:switch(this._descriptor.pixelFormat){case n.Id.RGBA:return this._descriptor.internalFormat=n.UV.RGBA32F;case n.Id.RGB:return this._descriptor.internalFormat=n.UV.RGB32F;default:throw new i.c("Unable to derive format")}case n.OK.UNSIGNED_BYTE:switch(this._descriptor.pixelFormat){case n.Id.RGBA:return this._descriptor.internalFormat=n.UV.RGBA8;case n.Id.RGB:return this._descriptor.internalFormat=n.UV.RGB8}}return this._descriptor.internalFormat=this._descriptor.pixelFormat===n.Id.DEPTH_STENCIL?n.Id.DEPTH24_STENCIL8:this._descriptor.pixelFormat}_configurePixelStorage(){const t=this._descriptor.context.gl,{unpackAlignment:e,flipped:s,preMultiplyAlpha:i}=this._descriptor;t.pixelStorei(t.UNPACK_ALIGNMENT,e),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,s?1:0),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,i?1:0)}_texStorage(t,e,s,r,o,a){const{gl:h}=this._descriptor.context;if(!(e in n.UV))throw new i.c("Immutable textures must have a sized internal format");if(!this._descriptor.isImmutable)return;const c=s?m(t,r,o,a):1;if(f(t)){if(null==a)throw new i.c("Missing depth dimension for 3D texture upload");h.texStorage3D(t,c,e,r,o,a)}else h.texStorage2D(t,c,e,r,o);this._wasImmutablyAllocated=!0}_texImage(t,e,s,r,n,o,a){const h=this._descriptor.context.gl,c=f(t),{isImmutable:l,pixelFormat:u,dataType:d}=this._descriptor;if(l){if(null!=a){const s=a;if(c){if(null==o)throw new i.c("Missing depth dimension for 3D texture upload");h.texSubImage3D(t,e,0,0,0,r,n,o,u,d,s)}else h.texSubImage2D(t,e,0,0,r,n,u,d,s)}}else{const l=a;if(c){if(null==o)throw new i.c("Missing depth dimension for 3D texture upload");h.texImage3D(t,e,s,r,n,o,0,u,d,l)}else h.texImage2D(t,e,s,r,n,0,u,d,l)}}_compressedTexImage(t,e,s,r,n,o,a){const h=this._descriptor.context.gl,c=f(t);if(this._descriptor.isImmutable){if(null!=a)if(c){if(null==o)throw new i.c("Missing depth dimension for 3D texture upload");h.compressedTexSubImage3D(t,e,0,0,0,r,n,o,s,a)}else h.compressedTexSubImage2D(t,e,0,0,r,n,s,a)}else if(c){if(null==o)throw new i.c("Missing depth dimension for 3D texture upload");h.compressedTexImage3D(t,e,s,r,n,o,0,a)}else h.compressedTexImage2D(t,e,s,r,n,0,a)}_forEachMipmapLevel(t,e=1/0){let{width:s,height:r,depth:o,hasMipmap:a,target:h}=this._descriptor;const c=h===n.c5.TEXTURE_3D;if(null==s||null==r||c&&null==o)throw new i.c("Missing texture dimensions for mipmap calculation");for(let i=0;t(i,s,r,o),a&&(1!==s||1!==r||c&&1!==o)&&!(i>=e);++i)s=Math.max(1,s>>1),r=Math.max(1,r>>1),c&&(o=Math.max(1,o>>1))}};function l(t){(null!=t.width&&t.width<0||null!=t.height&&t.height<0||null!=t.depth&&t.depth<0)&&console.error("Negative dimension parameters are not allowed!")}function u(t,e){let s=e.samplingMode,i=e.samplingMode;s===n.Ud.LINEAR_MIPMAP_NEAREST||s===n.Ud.LINEAR_MIPMAP_LINEAR?(s=n.Ud.LINEAR,e.hasMipmap||(i=n.Ud.LINEAR)):s!==n.Ud.NEAREST_MIPMAP_NEAREST&&s!==n.Ud.NEAREST_MIPMAP_LINEAR||(s=n.Ud.NEAREST,e.hasMipmap||(i=n.Ud.NEAREST)),t.texParameteri(e.target,t.TEXTURE_MAG_FILTER,s),t.texParameteri(e.target,t.TEXTURE_MIN_FILTER,i)}function d(t,e){"number"==typeof e.wrapMode?(t.texParameteri(e.target,t.TEXTURE_WRAP_S,e.wrapMode),t.texParameteri(e.target,t.TEXTURE_WRAP_T,e.wrapMode)):(t.texParameteri(e.target,t.TEXTURE_WRAP_S,e.wrapMode.s),t.texParameteri(e.target,t.TEXTURE_WRAP_T,e.wrapMode.t))}function p(t){return null!=t&&"type"in t&&"compressed"===t.type}function _(t){return null!=t&&!p(t)&&!function(t){return null!=t&&"byteLength"in t}(t)}function f(t){return t===n.c5.TEXTURE_3D||t===n.c5.TEXTURE_2D_ARRAY}function m(t,e,s,i=1){let r=Math.max(e,s);return t===n.c5.TEXTURE_3D&&(r=Math.max(r,i)),Math.round(Math.log(r)/Math.LN2)+1}c.TEXTURE_UNIT_FOR_UPDATES=0},51576:(t,e,s)=>{s.d(e,{O:()=>n,k:()=>o});var i=s(77800),r=s(97684);class n{constructor(t=0,e=t){this.width=t,this.height=e,this.target=i.c5.TEXTURE_2D,this.pixelFormat=i.Id.RGBA,this.dataType=i.OK.UNSIGNED_BYTE,this.samplingMode=i.Ud.LINEAR,this.wrapMode=i.Qz.REPEAT,this.maxAnisotropy=1,this.flipped=!1,this.hasMipmap=!1,this.isOpaque=!1,this.unpackAlignment=4,this.preMultiplyAlpha=!1,this.depth=1,this.isImmutable=!1}}function o(t){return t.width<=0||t.height<=0?0:Math.round(t.width*t.height*(t.hasMipmap?4/3:1)*(null==t.internalFormat?4:(0,r.O4)(t.internalFormat)))}},97684:(t,e,s)=>{s.d(e,{O4:()=>r}),s(9456),s(94460);var i=s(77800);function r(t){switch(t){case i.Id.ALPHA:case i.Id.LUMINANCE:case i.Id.RED:case i.Id.RED_INTEGER:case i.UV.R8:case i.UV.R8I:case i.UV.R8UI:case i.UV.R8_SNORM:case i.Qb.STENCIL_INDEX8:return 1;case i.Id.LUMINANCE_ALPHA:case i.Id.RG:case i.Id.RG_INTEGER:case i.UV.RGBA4:case i.UV.R16F:case i.UV.R16I:case i.UV.R16UI:case i.UV.RG8:case i.UV.RG8I:case i.UV.RG8UI:case i.UV.RG8_SNORM:case i.UV.RGB565:case i.UV.RGB5_A1:case i.Qb.DEPTH_COMPONENT16:return 2;case i.Id.DEPTH_COMPONENT:case i.Id.RGB:case i.Id.RGB_INTEGER:case i.UV.RGB8:case i.UV.RGB8I:case i.UV.RGB8UI:case i.UV.RGB8_SNORM:case i.UV.SRGB8:case i.Qb.DEPTH_COMPONENT24:return 3;case i.Id.DEPTH_STENCIL:case i.Id.DEPTH24_STENCIL8:case i.Id.RGBA:case i.Id.RGBA_INTEGER:case i.UV.RGBA8:case i.UV.R32F:case i.UV.R11F_G11F_B10F:case i.UV.RG16F:case i.UV.R32I:case i.UV.R32UI:case i.UV.RG16I:case i.UV.RG16UI:case i.UV.RGBA8I:case i.UV.RGBA8UI:case i.UV.RGBA8_SNORM:case i.UV.SRGB8_ALPHA8:case i.UV.RGB9_E5:case i.UV.RGB10_A2UI:case i.UV.RGB10_A2:case i.Qb.DEPTH_STENCIL:case i.Qb.DEPTH_COMPONENT32F:case i.Qb.DEPTH24_STENCIL8:return 4;case i.Qb.DEPTH32F_STENCIL8:return 5;case i.UV.RGB16F:case i.UV.RGB16I:case i.UV.RGB16UI:return 6;case i.UV.RG32F:case i.UV.RG32I:case i.UV.RG32UI:case i.UV.RGBA16F:case i.UV.RGBA16I:case i.UV.RGBA16UI:return 8;case i.UV.RGB32F:case i.UV.RGB32I:case i.UV.RGB32UI:return 12;case i.UV.RGBA32F:case i.UV.RGBA32I:case i.UV.RGBA32UI:return 16;case i.sr.COMPRESSED_RGB_S3TC_DXT1_EXT:case i.sr.COMPRESSED_RGBA_S3TC_DXT1_EXT:return.5;case i.sr.COMPRESSED_RGBA_S3TC_DXT3_EXT:case i.sr.COMPRESSED_RGBA_S3TC_DXT5_EXT:return 1;case i.sr.COMPRESSED_R11_EAC:case i.sr.COMPRESSED_SIGNED_R11_EAC:case i.sr.COMPRESSED_RGB8_ETC2:case i.sr.COMPRESSED_SRGB8_ETC2:case i.sr.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:case i.sr.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:return.5;case i.sr.COMPRESSED_RG11_EAC:case i.sr.COMPRESSED_SIGNED_RG11_EAC:case i.sr.COMPRESSED_RGBA8_ETC2_EAC:case i.sr.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:return 1}return 0}s(2944)},94460:(t,e,s)=>{s.d(e,{E5:()=>c,gv:()=>h,m_:()=>l});var i=s(20744),r=s(9456),n=s(66360);const o=()=>n.c.getLogger("geoscene.views.webgl.checkWebGLError"),a=!!(0,r.c)("enable-feature:webgl-debug");function h(){return a}function c(){return a}function l(t){if(h()){const e=t.getError();if(e){const s=function(t,e){switch(e){case t.INVALID_ENUM:return"Invalid Enum. An unacceptable value has been specified for an enumerated argument.";case t.INVALID_VALUE:return"Invalid Value. A numeric argument is out of range.";case t.INVALID_OPERATION:return"Invalid Operation. The specified command is not allowed for the current state.";case t.INVALID_FRAMEBUFFER_OPERATION:return"Invalid Framebuffer operation. The currently bound framebuffer is not framebuffer complete when trying to render to or to read from it.";case t.OUT_OF_MEMORY:return"Out of memory. Not enough memory is left to execute the command.";case t.CONTEXT_LOST_WEBGL:return"WebGL context has been lost";default:return"Unknown error"}}(t,e),r=(new Error).stack;o().error(new i.c("webgl-error","WebGL error occurred",{message:s,stack:r}))}}}},2944:(t,e,s)=>{s(77800)}}]);
|