@arcgis/core 4.31.0-next.20240820 → 4.31.0-next.20240821

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.
Files changed (56) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/{dc03a639c97a6f99dbc9.js → 1ac47b7a77818c372e1a.js} +1 -1
  3. package/assets/esri/core/workers/chunks/{a2c40517266fe420017c.js → 25fa59544c13db8cee30.js} +1 -1
  4. package/assets/esri/core/workers/chunks/40e4224f700206c67053.js +1 -0
  5. package/assets/esri/core/workers/chunks/5c4173205f885cd21422.js +1 -0
  6. package/assets/esri/core/workers/chunks/5cb07fa227b7fd06499f.js +1 -0
  7. package/assets/esri/core/workers/chunks/{44bb9ca79b7eeb605b32.js → 7fda3d3b211b6da5b0e5.js} +1 -1
  8. package/assets/esri/core/workers/chunks/949cbb667531527e6918.js +1 -0
  9. package/assets/esri/core/workers/chunks/9bbf7129579fe04ab268.js +1 -0
  10. package/assets/esri/core/workers/chunks/{1bd48c11947082f8b296.js → cd8d595d577b74817623.js} +1 -1
  11. package/assets/esri/core/workers/chunks/{c27f0a9b14f82feb9792.js → cfc93bbd35cc4bfde7c0.js} +1 -1
  12. package/assets/esri/core/workers/chunks/{07737567079db2a208b3.js → e2a6f77c05d0818e3f74.js} +1 -1
  13. package/assets/esri/core/workers/chunks/{1ee365125c9fb9d9cafe.js → e5474bcde5b8fa037b56.js} +11 -11
  14. package/assets/esri/core/workers/chunks/{bd9c85047ef82c5a8bef.js → ea561b2460e634a643fc.js} +1 -1
  15. package/chunks/BloomComposition.glsl.js +45 -0
  16. package/chunks/OperatorGeodesicBuffer.js +1 -1
  17. package/chunks/OperatorGeodeticDensifyByLength.js +1 -1
  18. package/chunks/OperatorGeodeticDistance.js +1 -1
  19. package/chunks/OperatorProximity.js +5 -0
  20. package/chunks/Polyline.js +1 -1
  21. package/core/mathUtils.js +1 -1
  22. package/geometry/operators/gx/operatorAutoComplete.js +1 -1
  23. package/geometry/operators/gx/operatorCut.js +1 -1
  24. package/geometry/operators/gx/operatorLabelPoint.js +1 -1
  25. package/geometry/operators/gx/operatorOffset.js +1 -1
  26. package/geometry/operators/gx/operatorSimplify.js +1 -1
  27. package/geometry/operators/gx/operatorUnion.js +1 -1
  28. package/geometry/operators/operatorProximity.js +5 -0
  29. package/geometry/operators/operatorRelate.js +1 -1
  30. package/geometry/operators/operatorReshape.js +5 -0
  31. package/layers/LinkChartLayer.js +1 -1
  32. package/layers/graphics/sources/geojson/geojson.js +1 -1
  33. package/layers/knowledgeGraph/KnowledgeGraphLayerDataManager.js +1 -1
  34. package/layers/knowledgeGraph/KnowledgeGraphSublayer.js +1 -1
  35. package/layers/knowledgeGraph/SessionMemoryStorage.js +1 -1
  36. package/layers/knowledgeGraph/layerUtils.js +1 -1
  37. package/package.json +1 -1
  38. package/portal/PortalItem.js +1 -1
  39. package/support/revision.js +1 -1
  40. package/symbols/cim/cimAnalyzer.js +1 -1
  41. package/symbols/support/utils.js +1 -1
  42. package/views/3d/state/ViewStateManager.js +1 -1
  43. package/views/3d/support/cameraUtils.js +1 -1
  44. package/views/3d/support/pointsOfInterest/CameraOnSurface.js +1 -1
  45. package/views/3d/support/viewpointUtils.js +1 -1
  46. package/views/3d/webgl-engine/core/shaderLibrary/output/Emissions.glsl.js +3 -3
  47. package/views/3d/webgl-engine/effects/bloom/BloomComposition.glsl.js +5 -0
  48. package/views/3d/webgl-engine/effects/bloom/BloomRenderNode.js +5 -0
  49. package/views/3d/webgl-engine/effects/bloom/BloomTechnique.js +5 -0
  50. package/views/3d/webgl-engine/lib/MainFramebuffer.js +1 -1
  51. package/widgets/OrientedImageryViewer.js +1 -1
  52. package/assets/esri/core/workers/chunks/2b61de00084c1ca97da6.js +0 -1
  53. package/assets/esri/core/workers/chunks/31f931de94414f13bd13.js +0 -1
  54. package/assets/esri/core/workers/chunks/6f1853ab502bebefd3c3.js +0 -1
  55. package/assets/esri/core/workers/chunks/9661398ce832137461f6.js +0 -1
  56. package/assets/esri/core/workers/chunks/cd737bfb5ff43737a3df.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import"../../geometry.js";import{convertFromGeometry as e}from"../graphics/featureConversionUtils.js";import{OptimizedFeature as t}from"../graphics/OptimizedFeature.js";import{fromJSON as r}from"../../geometry/support/jsonUtils.js";const i="ESRI__DESTINATION_ID",s="ESRI__ORIGIN_ID";class o{constructor(){this._featureLookup=new Map}static getInstance(){return o.instance||(o.instance=new o),o.instance}static resetInstance(){o.instance&&(o.instance=null)}deleteFromStore(e){e.forEach((e=>{this._featureLookup.delete(e)}))}readFromStoreByList(e){const t=[];return e.forEach((e=>{const r=this.readFromStoreById(e);r&&t.push(r)})),t}readFromStoreById(e){return this._featureLookup.get(e)??null}writeToStore(o,n,p){const a=[];return o.forEach((o=>{if(!o?.id)return;o.properties||(o.properties=[]);let u,c=null;if(p&&o.properties[p]&&(c=e(o.properties[p])),"originId"in o&&"destinationId"in o&&(o.properties[s]=o.originId,o.properties[i]=o.destinationId),o.properties[n]=o.id,o.id&&this._featureLookup.has(o.id)&&this._featureLookup.get(o.id).attributes){const e=this._featureLookup.get(o.id),i=JSON.parse(JSON.stringify(Object.assign(e.attributes,o.properties)));p&&o.properties[p]&&(i[p]=r(o.properties[p])),u=new t(c?JSON.parse(JSON.stringify(c)):e?.geometry?JSON.parse(JSON.stringify(e.geometry)):null,i,null,o.properties[n])}else u=new t(c?JSON.parse(JSON.stringify(c)):null,o.properties,null,o.properties[n]);this._featureLookup.set(o.id,u),a.push(u)})),a}}export{o as default};
5
+ import"../../geometry.js";import{convertFromGeometry as e}from"../graphics/featureConversionUtils.js";import{OptimizedFeature as t}from"../graphics/OptimizedFeature.js";import{systemOriginIdFieldName as r,systemDestinationIdFieldName as i}from"./layerUtils.js";import{fromJSON as s}from"../../geometry/support/jsonUtils.js";class o{constructor(){this._featureLookup=new Map}static getInstance(){return o.instance||(o.instance=new o),o.instance}static resetInstance(){o.instance&&(o.instance=null)}deleteFromStore(e){e.forEach((e=>{this._featureLookup.delete(e)}))}readFromStoreByList(e){const t=[];return e.forEach((e=>{const r=this.readFromStoreById(e);r&&t.push(r)})),t}readFromStoreById(e){return this._featureLookup.get(e)??null}writeToStore(o,n,p){const a=[];return o.forEach((o=>{if(!o?.id)return;o.properties||(o.properties=[]);let u,l=null;if(p&&o.properties[p]&&(l=e(o.properties[p])),"originId"in o&&"destinationId"in o&&(o.properties[r]=o.originId,o.properties[i]=o.destinationId),o.properties[n]=o.id,o.id&&this._featureLookup.has(o.id)&&this._featureLookup.get(o.id).attributes){const e=this._featureLookup.get(o.id),r=JSON.parse(JSON.stringify(Object.assign(e.attributes,o.properties)));p&&o.properties[p]&&(r[p]=s(o.properties[p])),u=new t(l?JSON.parse(JSON.stringify(l)):e?.geometry?JSON.parse(JSON.stringify(e.geometry)):null,r,null,o.properties[n])}else u=new t(l?JSON.parse(JSON.stringify(l)):null,o.properties,null,o.properties[n]);this._featureLookup.set(o.id,u),a.push(u)})),a}}export{o as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import{fetchClientDataAtKeys as e}from"../../rest/knowledgeGraphService.js";const a={initializeLayersFromClientData:async(a,r)=>{if(r||(r=[...a.layers,...a.tables].map((e=>e.graphTypeName))),0===r?.length)return;const n=new Map;for(const e of r)n.set(e,t(a,e));const o=await e(a.dataManager.knowledgeGraph,Array.from(n.values()));for(const e of[...a.layers,...a.tables]){const r=e.objectType.name;if(null===r)continue;const n=o.get(t(a,r));if(n){const a=JSON.parse(n);null===a||"object"!=typeof a||a.hasOwnProperty("showLabels")||(a.showLabels=!1),e.read(a,{origin:"service"})}}}},t=(e,a)=>"knowledge-graph"===e.type?`${a}/Map`:`${a}/LinkChart/LinkChartSubLayer`;async function r(e,t){return a.initializeLayersFromClientData(e,t)}export{r as initializeLayersFromClientData,a as layerUtils};
5
+ import{fetchClientDataAtKeys as e}from"../../rest/knowledgeGraphService.js";const a="ESRI__ID",t="ESRI__OriginID",r="ESRI__DestID",n="ESRI__LayoutGeometry",o="ESRI__AggregationCount",s="LC.ESRI__IsSpatial",i={initializeLayersFromClientData:async(a,t)=>{if(t||(t=[...a.layers,...a.tables].map((e=>e.graphTypeName))),0===t?.length)return;const r=new Map;for(const e of t)r.set(e,l(a,e));const n=await e(a.dataManager.knowledgeGraph,Array.from(r.values()));for(const e of[...a.layers,...a.tables]){const t=e.objectType.name;if(null===t)continue;const r=n.get(l(a,t));if(r){const a=JSON.parse(r);null===a||"object"!=typeof a||a.hasOwnProperty("showLabels")||(a.showLabels=!1),e.read(a,{origin:"service"})}}}},l=(e,a)=>"knowledge-graph"===e.type?`${a}/Map`:`${a}/LinkChart/LinkChartSubLayer`;async function c(e,a){return i.initializeLayersFromClientData(e,a)}export{c as initializeLayersFromClientData,i as layerUtils,o as systemAggregationCountFieldName,r as systemDestinationIdFieldName,s as systemIsSpatialFieldName,n as systemLayoutGeometryFieldName,a as systemOidFieldName,t as systemOriginIdFieldName};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/core",
3
- "version": "4.31.0-next.20240820",
3
+ "version": "4.31.0-next.20240821",
4
4
  "homepage": "https://js.arcgis.com",
5
5
  "description": "ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API",
6
6
  "keywords": [
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import{getAssetUrl as t}from"../assets.js";import i from"../core/Error.js";import{JSONSupportMixin as r}from"../core/JSONSupport.js";import{clone as o,fixJson as s}from"../core/lang.js";import a from"../core/Loadable.js";import{isDataProtocol as n,makeAbsolute as l}from"../core/urlUtils.js";import{property as p}from"../core/accessorSupport/decorators/property.js";import{ensureClass as c}from"../core/accessorSupport/ensureType.js";import{reader as d}from"../core/accessorSupport/decorators/reader.js";import{subclass as u}from"../core/accessorSupport/decorators/subclass.js";import m from"../geometry/Extent.js";import h from"./Portal.js";import g from"./PortalItemResource.js";import y from"./PortalRating.js";import{a as w}from"../chunks/persistableUrlUtils.js";var v;const f=new Set(["3DTiles Service","CSV","Feature Collection","Feature Service","Feed","GeoJson","Group Layer","Image Service","KML","Map Service","Media Layer","Scene Service","Stream Service","Vector Tile Service","WFS","WMS","WMTS"]),b=new Set(["KML","GeoJson","CSV"]);let k=v=class extends(r(a)){static from(e){return c(v,e)}constructor(e){super(e),this.access=null,this.accessInformation=null,this.apiKey=null,this.applicationProxies=null,this.avgRating=null,this.categories=null,this.classification=null,this.created=null,this.culture=null,this.description=null,this.extent=null,this.groupCategories=null,this.id=null,this.isOrgItem=!1,this.itemControl=null,this.licenseInfo=null,this.modified=null,this.name=null,this.numComments=null,this.numRatings=null,this.numViews=null,this.owner=null,this.ownerFolder=null,this.portal=null,this.screenshots=null,this.size=null,this.snippet=null,this.sourceJSON=null,this.sourceUrl=null,this.spatialReference=null,this.tags=null,this.title=null,this.type=null,this.typeKeywords=null,this.url=null}destroy(){this.portal=null}get displayName(){const e=this.type,t=this.typeKeywords||[];let i=e;return"Feature Service"===e||"Feature Collection"===e?i=t.includes("Table")?"Table":t.includes("Route Layer")?"Route Layer":t.includes("Markup")?"Markup":"Feature Layer":"Image Service"===e?i=t.includes("Elevation 3D Layer")?"Elevation Layer":t.includes("Tiled Imagery")?"Tiled Imagery Layer":"Imagery Layer":"Scene Service"===e?i="Scene Layer":"Video Service"===e?i="Video Layer":"Scene Package"===e?i="Scene Layer Package":"Stream Service"===e?i="Feature Layer":"Geoprocessing Service"===e?i=t.includes("Web Tool")?"Tool":"Geoprocessing Service":"Geoenrichment Service"===e?i="GeoEnrichment Service":"Geocoding Service"===e?i="Locator":"Microsoft Powerpoint"===e?i="Microsoft PowerPoint":"GeoJson"===e?i="GeoJSON":"Globe Service"===e?i="Globe Layer":"Vector Tile Service"===e?i="Tile Layer":"netCDF"===e?i="NetCDF":"Map Service"===e?i=t.includes("Spatiotemporal")||!t.includes("Hosted Service")&&!t.includes("Tiled")||t.includes("Relational")?"Map Image Layer":"Tile Layer":e?.toLowerCase().includes("add in")?i=e.replaceAll(/(add in)/gi,"Add-In"):"datastore catalog service"===e?i="Big Data File Share":"Compact Tile Package"===e?i="Tile Package (tpkx)":"Raster function template"===e?i="Raster Function Template":"OGCFeatureServer"===e?i="OGC Feature Layer":"web mapping application"===e&&t.includes("configurableApp")?i="Instant App":"Insights Page"===e?i="Insights Report":"Excalibur Imagery Project"===e?i="Excalibur Project":"3DTiles Service"===e?i="3D tiles layer":"3DTiles Package"===e&&(i="3D tiles package"),i}readExtent(e){return e&&e.length?new m(e[0][0],e[0][1],e[1][0],e[1][1]):null}get iconUrl(){const e=this.type?.toLowerCase()||"",i=this.typeKeywords||[],r="esri/images/portal/",o="16";let s,a=!1,n=!1,l=!1,p=!1,c=!1,d=!1,u=!1,m=!1;return e.indexOf("service")>0||"feature collection"===e||"kml"===e||"wms"===e||"wmts"===e||"wfs"===e?(a=i.includes("Hosted Service"),"feature service"===e||"feature collection"===e||"kml"===e||"wfs"===e?(n=i.includes("Table"),l=i.includes("Route Layer"),p=i.includes("Markup"),c=i.includes("Spatiotemporal"),d=i.includes("UtilityNetwork"),s=c&&n?"spatiotemporaltable":n?"table":l?"routelayer":p?"markup":c?"spatiotemporal":d?"utilitynetwork":a?"featureshosted":"features"):"map service"===e||"wms"===e||"wmts"===e?(c=i.includes("Spatiotemporal"),u=i.includes("Relational"),s=c||u?"mapimages":a||i.includes("Tiled")||"wmts"===e?"maptiles":"mapimages"):s="scene service"===e?i.includes("Line")?"sceneweblayerline":i.includes("3DObject")?"sceneweblayermultipatch":i.includes("Point")?"sceneweblayerpoint":i.includes("IntegratedMesh")?"sceneweblayermesh":i.includes("PointCloud")?"sceneweblayerpointcloud":i.includes("Polygon")?"sceneweblayerpolygon":i.includes("Building")?"sceneweblayerbuilding":i.includes("Voxel")?"sceneweblayervoxel":"sceneweblayer":"image service"===e?i.includes("Elevation 3D Layer")?"elevationlayer":i.includes("Tiled Imagery")?"tiledimagerylayer":"imagery":"stream service"===e?"streamlayer":"vector tile service"===e?"vectortile":"datastore catalog service"===e?"datastorecollection":"geocoding service"===e?"geocodeservice":"video service"===e?i.includes("Live Stream")?"livestreamvideolayer":"videolayer":"geoprocessing service"===e?i.includes("Web Tool")?"tool":"layers":"geodata service"===e?"geodataservice":"3dtiles service"===e?i.includes("3DObject")?"3dobjecttileslayer":i.includes("IntegratedMesh")?"integratedmeshtileslayer":"3dtileslayer":"layers"):"web map"===e||"cityengine web scene"===e?s="maps":"web scene"===e?s=i.includes("ViewingMode-Local")?"webscenelocal":"websceneglobal":"web mapping application"===e&&i.includes("configurableApp")?s="instantapps":"web mapping application"===e||"mobile application"===e||"application"===e||"operation view"===e||"desktop application"===e?s="apps":"map document"===e||"map package"===e||"published map"===e||"scene document"===e||"globe document"===e||"basemap package"===e||"mobile basemap package"===e||"mobile map package"===e||"project package"===e||"project template"===e||"pro map"===e||"layout"===e||"layer"===e&&i.includes("ArcGIS Pro")||"explorer map"===e&&i.indexOf("Explorer Document")?s="mapsgray":"service definition"===e||"shapefile"===e||"cad drawing"===e||"geojson"===e||"netcdf"===e||"administrative report"===e?s="datafiles":"360 vr experience"===e?s="360vr":"explorer add in"===e||"desktop add in"===e||"windows viewer add in"===e||"windows viewer configuration"===e?s="appsgray":"arcgis pro add in"===e||"arcgis pro configuration"===e?s="addindesktop":"pdf"===e?s="pdf":"microsoft word"===e?s="word":"microsoft excel"===e?s="excel":"microsoft powerpoint"===e?s="ppt":"rule package"===e||"file geodatabase"===e||"sqlite geodatabase"===e||"csv collection"===e||"kml collection"===e||"windows mobile package"===e||"map template"===e||"desktop application template"===e||"gml"===e||"arcpad package"===e||"code sample"===e||"document link"===e||"earth configuration"===e||"operations dashboard add in"===e||"rules package"===e||"workflow manager package"===e||"explorer map"===e&&i.includes("Explorer Mapping Application")||i.includes("Document")?s="datafilesgray":"network analysis service"===e||"geoprocessing service"===e||"geodata service"===e||"geometry service"===e||"geoprocessing package"===e||"locator package"===e||"geoprocessing sample"===e||"workflow manager service"===e?s="toolsgray":"layer"===e||"layer package"===e||"explorer layer"===e?s="layersgray":"analysis model"===e?s="analysismodel":"scene package"===e?s="scenepackage":"3dtiles package"===e?s="3dtileslayerpackage":"3dtiles service"===e?s="3dtileslayer":"mobile scene package"===e?s="mobilescenepackage":"tile package"===e||"compact tile package"===e?s="tilepackage":"task file"===e?s="taskfile":"report template"===e?s="report-template":"statistical data collection"===e?s="statisticaldatacollection":"insights workbook"===e?s="workbook":"insights model"===e?s="insightsmodel":"insights page"===e?s="insightspage":"insights theme"===e?s="insightstheme":"hub initiative"===e?s="hubinitiative":"hub page"===e?s="hubpage":"hub site application"===e?s="hubsite":"hub event"===e?s="hubevent":"hub project"===e?s="hubproject":"relational database connection"===e?s="relationaldatabaseconnection":"big data file share"===e?s="datastorecollection":"image collection"===e?s="imagecollection":"desktop style"===e?s="desktopstyle":"style"===e?s=i.includes("Dictionary")?"dictionarystyle":"style":"dashboard"===e?s="dashboard":"raster function template"===e?s="rasterprocessingtemplate":"vector tile package"===e?s="vectortilepackage":"ortho mapping project"===e?s="orthomappingproject":"ortho mapping template"===e?s="orthomappingtemplate":"solution"===e?s="solutions":"geopackage"===e?s="geopackage":"deep learning package"===e?s="deeplearningpackage":"real time analytic"===e?s="realtimeanalytics":"big data analytic"===e?s="bigdataanalytics":"feed"===e?s="feed":"excalibur imagery project"===e?s="excaliburimageryproject":"notebook"===e?s="notebook":"storymap"===e?s="storymap":"survey123 add in"===e?s="survey123addin":"mission"===e?s="mission":"mission report"===e?s="missionreport":"mission template"===e?s="missiontemplate":"quickcapture project"===e?s="quickcaptureproject":"pro report"===e?s="proreport":"pro report template"===e?s="proreporttemplate":"urban model"===e?s="urbanmodel":"web experience"===e?s="experiencebuilder":"web experience template"===e?s="webexperiencetemplate":"experience builder widget"===e?s="experiencebuilderwidget":"experience builder widget package"===e?s="experiencebuilderwidgetpackage":"workflow"===e?s="workflow":"kernel gateway connection"===e?s="kernelgatewayconnection":"insights script"===e?s="insightsscript":"hub initiative template"===e?s="hubinitiativetemplate":"storymap theme"===e?s="storymaptheme":"knowledge graph"===e?s="knowledgegraph":"knowledge graph layer"===e?s="knowledgegraphlayer":"knowledge studio project"===e?s="knowledgestudio":"native application"===e?s="nativeapp":"native application installer"===e?s="nativeappinstaller":"web link chart"===e?s="linkchart":"knowledge graph web investigation"===e?s="investigation":"ogcfeatureserver"===e?s="features":"pro project"===e?s="proproject":"insights workbook package"===e?s="insightsworkbookpackage":"apache parquet"===e?s="apacheparquet":"notebook code snippet library"===e?s="notebookcodesnippets":"suitability model"===e?s="suitabilitymodel":"esri classifier definition"===e?s="classifierdefinition":"esri classification schema"===e?s="classificationschema":"insights data engineering workbook"===e?s="dataengineeringworkbook":"insights data engineering model"===e?s="dataengineeringmodel":"deep learning studio project"===e?s="deeplearningproject":"discussion"===e?s="discussion":"allsource project"===e?s="allsourceproject":"api key"===e?s="apikey":"data pipeline"===e?s="datapipelines":"group layer"===e?(m=i.includes("Map"),s=m?"layergroup2d":"layergroup"):s="media layer"===e?"onlinemedialayer":"form"===e?i.includes("Survey123")?"survey":"datafilesgray":"csv"===e?"csv":"image"===e?"image":"maps",s?t(r+s+o+".png"):null}get isLayer(){return null!=this.type&&f.has(this.type)}get itemCdnUrl(){return w(this.itemUrl)}get itemPageUrl(){const e=this.portal?.itemPageUrl;return e&&this.id?`${e}?id=${this.id}`:null}get itemUrl(){const e=this.portal?.restUrl;return e&&this.id?`${e}/content/items/${this.id}`:null}get thumbnailUrl(){const e=this.itemUrl,t=this.thumbnail;return e&&t?this.portal?.normalizeUrl(`${e}/info/${t}?f=json`)??null:null}get userItemUrl(){const e=this.portal?.restUrl;if(!e)return null;const t=this.owner||this.portal?.user?.username;if(!t)return null;return`${e}/content/users/${this.ownerFolder?`${t}/${this.ownerFolder}`:t}/items/${this.id}`}load(e){const t=this.portal??(this.portal=h.getDefault()),i=t.load(e).then((()=>this.sourceJSON?this.sourceJSON:this.id&&this.itemUrl?t.request(this.itemUrl,{signal:null!=e?e.signal:null,query:{token:this.apiKey}}):{})).then((e=>{this.sourceJSON=e,this.read(e)}));return this.addResolvingPromise(i),Promise.resolve(this)}async addRating(e){const t={method:"post",query:{}};return e instanceof y&&(e=e.rating),null==e||isNaN(e)||"number"!=typeof e||(t.query.rating=e),this.portal?(await this.portal.request(this.itemUrl+"/addRating",t),new y({rating:e,created:new Date})):null}clone(){const e={access:this.access,accessInformation:this.accessInformation,applicationProxies:o(this.applicationProxies),avgRating:this.avgRating,categories:o(this.categories),classification:o(this.classification),created:o(this.created),culture:this.culture,description:this.description,extent:o(this.extent),groupCategories:o(this.groupCategories),id:this.id,itemControl:this.itemControl,licenseInfo:this.licenseInfo,modified:o(this.modified),name:this.name,numComments:this.numComments,numRatings:this.numRatings,numViews:this.numViews,owner:this.owner,ownerFolder:this.ownerFolder,portal:this.portal,screenshots:o(this.screenshots),size:this.size,snippet:this.snippet,sourceUrl:this.sourceUrl,spatialReference:this.spatialReference,tags:o(this.tags),thumbnail:this.thumbnail,title:this.title,type:this.type,typeKeywords:o(this.typeKeywords),url:this.url};this.loaded&&(e.loadStatus="loaded");const t=new v({sourceJSON:this.sourceJSON}).set(e);return t._set("isOrgItem",this.isOrgItem),t}createPostQuery(){const e=this.toJSON();for(const i of["tags","typeKeywords","categories"])e[i]=e[i]?.join(", ");const{extent:t}=e;return t&&(e.extent=JSON.stringify(t)),e}async deleteRating(){await this.portal.request(this.itemUrl+"/deleteRating",{method:"post"})}fetchData(e="json",t){return this.portal.request(this.itemUrl+"/data",{responseType:e,...t,query:{token:this.apiKey}})}async fetchRating(e){const t=await this.portal.request(this.itemUrl+"/rating",{query:{token:this.apiKey},...e});return null!=t.rating?(t.created=new Date(t.created),new y(t)):null}fetchRelatedItems(e,t){return this.portal.requestToTypedArray(this.itemUrl+"/relatedItems",{query:{...e,token:this.apiKey},...t},v)}getThumbnailUrl(e){let t=this.thumbnailUrl;return t&&e&&(t+=`&w=${e}`),t}reload(){return this.portal.request(this.itemUrl??"",{cacheBust:!0,query:{token:this.apiKey}}).then((e=>(this.applicationProxies&&!Object.hasOwn(e,"appProxies")&&(this.applicationProxies=null),this.sourceJSON=e,this.read(e),this)))}update(e){return this.id?this.load().then((()=>this.portal.signIn())).then((()=>{const t=e?.data,i={method:"post"};i.query=this.createPostQuery();for(const e in i.query)null===i.query[e]&&(i.query[e]="");return i.query.clearEmptyFields=!0,null!=t&&("string"==typeof t?i.query.text=t:"object"==typeof t&&(i.query.text=JSON.stringify(t))),this.portal.request(`${this.userItemUrl}/update`,i).then((()=>this.reload()))})):Promise.reject(new i("portal:item-does-not-exist","The item does not exist yet and cannot be updated"))}async copy(e){if(!this.id)throw new i("portal:item-does-not-exist","The item does not exist yet");await this.load();const{portal:t,itemUrl:r}=this;await t.signIn();const{copyResources:o,folder:s,tags:a,title:n}=e||{},l={method:"post",query:{copyPrivateResources:"all"===o,folder:"string"==typeof s?s:s?.id,includeResources:!!o,tags:a?.join(","),title:n}},{itemId:p}=await t.request(`${r}/copy`,l);return new v({id:p,portal:t})}updateThumbnail(e){return this.id?this.load().then((()=>this.portal.signIn())).then((()=>{const t=e.thumbnail,i=e.filename,r={method:"post"};if("string"==typeof t)n(t)?r.query={data:t}:r.query={url:l(t)},null!=i&&(r.query.filename=i);else{const e=new FormData;null!=i?e.append("file",t,i):e.append("file",t),r.body=e}return this.portal.request(`${this.userItemUrl}/updateThumbnail`,r).then((()=>this.reload()))})):Promise.reject(new i("portal:item-does-not-exist","The item does not exist yet and cannot be updated"))}async fetchResources(e={},t){const{fetchResources:i}=await import("./support/resourceUtils.js");return i(this,e,t)}async addResource(e,t,i){const{addOrUpdateResources:r}=await import("./support/resourceUtils.js");return e.portalItem=this,await r(this,[{resource:e,content:t,compress:i?.compress,access:i?.access}],"add",i),e}async removeResource(e,t){const{removeResource:r}=await import("./support/resourceUtils.js");if(e.portalItem&&e.portalItem.itemUrl!==this.itemUrl)throw new i("removeresource:portal-item-mismatch","The portal item associated with the provided resource does not match the item");return r(this,e,t)}async removeAllResources(e){const{removeAllResources:t}=await import("./support/resourceUtils.js");return t(this,e)}resourceFromPath(e){return new g({portalItem:this,path:e})}toJSON(){const e=this.extent,t={accessInformation:this.accessInformation,categories:o(this.categories),classification:o(this.classification),created:this.created?.getTime(),description:this.description,extent:e&&[[e.xmin,e.ymin],[e.xmax,e.ymax]],id:this.id,isOrgItem:this.isOrgItem,licenseInfo:this.licenseInfo,modified:this.modified?.getTime(),name:this.name,owner:this.owner,ownerFolder:this.ownerFolder,snippet:this.snippet,sourceUrl:this.sourceUrl,spatialReference:this.spatialReference,tags:o(this.tags),thumbnail:this.thumbnail,title:this.title,type:this.type,typeKeywords:o(this.typeKeywords),url:this.url};return s(t)}static fromJSON(e){if(!e)return null;if(e.declaredClass)throw new Error("JSON object is already hydrated");return new v({sourceJSON:e})}_getPostQuery(){const e=this.toJSON();for(const t in e)"tags"===t&&null!==e[t]&&(e[t]=e[t].join(", ")),"typeKeywords"===t&&null!==e[t]&&(e[t]=e[t].join(", ")),"extent"===t&&e[t]&&(e[t]=JSON.stringify(e[t]));return e}};e([p({type:["private","shared","org","public"]})],k.prototype,"access",void 0),e([p()],k.prototype,"accessInformation",void 0),e([p({type:String})],k.prototype,"apiKey",void 0),e([p({json:{read:{source:"appProxies"}}})],k.prototype,"applicationProxies",void 0),e([p()],k.prototype,"avgRating",void 0),e([p()],k.prototype,"categories",void 0),e([p()],k.prototype,"classification",void 0),e([p({type:Date})],k.prototype,"created",void 0),e([p()],k.prototype,"culture",void 0),e([p()],k.prototype,"description",void 0),e([p({readOnly:!0})],k.prototype,"displayName",null),e([p({type:m})],k.prototype,"extent",void 0),e([d("extent")],k.prototype,"readExtent",null),e([p()],k.prototype,"groupCategories",void 0),e([p({readOnly:!0})],k.prototype,"iconUrl",null),e([p()],k.prototype,"id",void 0),e([p({readOnly:!0})],k.prototype,"isLayer",null),e([p({type:Boolean,readOnly:!0})],k.prototype,"isOrgItem",void 0),e([p()],k.prototype,"itemControl",void 0),e([p({readOnly:!0})],k.prototype,"itemPageUrl",null),e([p({readOnly:!0})],k.prototype,"itemUrl",null),e([p()],k.prototype,"licenseInfo",void 0),e([p({type:Date})],k.prototype,"modified",void 0),e([p()],k.prototype,"name",void 0),e([p()],k.prototype,"numComments",void 0),e([p()],k.prototype,"numRatings",void 0),e([p()],k.prototype,"numViews",void 0),e([p()],k.prototype,"owner",void 0),e([p()],k.prototype,"ownerFolder",void 0),e([p({type:h})],k.prototype,"portal",void 0),e([p()],k.prototype,"screenshots",void 0),e([p()],k.prototype,"size",void 0),e([p()],k.prototype,"snippet",void 0),e([p()],k.prototype,"sourceJSON",void 0),e([p({type:String})],k.prototype,"sourceUrl",void 0),e([p({type:String})],k.prototype,"spatialReference",void 0),e([p()],k.prototype,"tags",void 0),e([p()],k.prototype,"thumbnail",void 0),e([p({readOnly:!0})],k.prototype,"thumbnailUrl",null),e([p()],k.prototype,"title",void 0),e([p()],k.prototype,"type",void 0),e([p()],k.prototype,"typeKeywords",void 0),e([p({type:String,json:{read(e,t){if(b.has(t.type)){const t=this.portal?.restUrl;e||=t&&this.id?`${t}/content/items/${this.id}/data`:null}return e}}})],k.prototype,"url",void 0),e([p({readOnly:!0})],k.prototype,"userItemUrl",null),k=v=e([u("esri.portal.PortalItem")],k);const S=k;export{S as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import{getAssetUrl as t}from"../assets.js";import i from"../core/Error.js";import{JSONSupportMixin as r}from"../core/JSONSupport.js";import{clone as o,fixJson as s}from"../core/lang.js";import a from"../core/Loadable.js";import{isDataProtocol as n,makeAbsolute as l}from"../core/urlUtils.js";import{property as p}from"../core/accessorSupport/decorators/property.js";import{ensureClass as c}from"../core/accessorSupport/ensureType.js";import{reader as d}from"../core/accessorSupport/decorators/reader.js";import{subclass as u}from"../core/accessorSupport/decorators/subclass.js";import m from"../geometry/Extent.js";import h from"./Portal.js";import g from"./PortalItemResource.js";import y from"./PortalRating.js";import{a as w}from"../chunks/persistableUrlUtils.js";var v;const f=new Set(["3DTiles Service","CSV","Feature Collection","Feature Service","Feed","GeoJson","Group Layer","Image Service","KML","Map Service","Media Layer","Scene Service","Stream Service","Vector Tile Service","WFS","WMS","WMTS"]),b=new Set(["KML","GeoJson","CSV"]);let k=v=class extends(r(a)){static from(e){return c(v,e)}constructor(e){super(e),this.access=null,this.accessInformation=null,this.apiKey=null,this.applicationProxies=null,this.avgRating=null,this.categories=null,this.classification=null,this.created=null,this.culture=null,this.description=null,this.extent=null,this.groupCategories=null,this.id=null,this.isOrgItem=!1,this.itemControl=null,this.licenseInfo=null,this.modified=null,this.name=null,this.numComments=null,this.numRatings=null,this.numViews=null,this.owner=null,this.ownerFolder=null,this.portal=null,this.screenshots=null,this.size=null,this.snippet=null,this.sourceJSON=null,this.sourceUrl=null,this.spatialReference=null,this.tags=null,this.title=null,this.type=null,this.typeKeywords=null,this.url=null}destroy(){this.portal=null}get displayName(){const e=this.type,t=this.typeKeywords||[];let i=e;return"Feature Service"===e||"Feature Collection"===e?i=t.includes("Table")?"Table":t.includes("Route Layer")?"Route Layer":t.includes("Markup")?"Markup":"Feature Layer":"Image Service"===e?i=t.includes("Elevation 3D Layer")?"Elevation Layer":t.includes("Tiled Imagery")?"Tiled Imagery Layer":"Imagery Layer":"Scene Service"===e?i="Scene Layer":"Video Service"===e?i="Video Layer":"Scene Package"===e?i="Scene Layer Package":"Stream Service"===e?i="Feature Layer":"Geoprocessing Service"===e?i=t.includes("Web Tool")?"Tool":"Geoprocessing Service":"Geoenrichment Service"===e?i="GeoEnrichment Service":"Geocoding Service"===e?i="Locator":"Microsoft Powerpoint"===e?i="Microsoft PowerPoint":"GeoJson"===e?i="GeoJSON":"Globe Service"===e?i="Globe Layer":"Vector Tile Service"===e?i="Tile Layer":"netCDF"===e?i="NetCDF":"Map Service"===e?i=t.includes("Spatiotemporal")||!t.includes("Hosted Service")&&!t.includes("Tiled")||t.includes("Relational")?"Map Image Layer":"Tile Layer":e?.toLowerCase().includes("add in")?i=e.replaceAll(/(add in)/gi,"Add-In"):"datastore catalog service"===e?i="Big Data File Share":"Compact Tile Package"===e?i="Tile Package (tpkx)":"Raster function template"===e?i="Raster Function Template":"OGCFeatureServer"===e?i="OGC Feature Layer":"web mapping application"===e&&t.includes("configurableApp")?i="Instant App":"Insights Page"===e?i="Insights Report":"Excalibur Imagery Project"===e?i="Excalibur Project":"3DTiles Service"===e?i="3D tiles layer":"3DTiles Package"===e&&(i="3D tiles package"),i}readExtent(e){return e&&e.length?new m(e[0][0],e[0][1],e[1][0],e[1][1]):null}get iconUrl(){const e=this.type?.toLowerCase()||"",i=this.typeKeywords||[],r="esri/images/portal/",o="16";let s,a=!1,n=!1,l=!1,p=!1,c=!1,d=!1,u=!1,m=!1;return e.indexOf("service")>0||"feature collection"===e||"kml"===e||"wms"===e||"wmts"===e||"wfs"===e?(a=i.includes("Hosted Service"),"feature service"===e||"feature collection"===e||"kml"===e||"wfs"===e?(n=i.includes("Table"),l=i.includes("Route Layer"),p=i.includes("Markup"),c=i.includes("Spatiotemporal"),d=i.includes("UtilityNetwork"),s=c&&n?"spatiotemporaltable":n?"table":l?"routelayer":p?"markup":c?"spatiotemporal":d?"utilitynetwork":a?"featureshosted":"features"):"map service"===e||"wms"===e||"wmts"===e?(c=i.includes("Spatiotemporal"),u=i.includes("Relational"),s=c||u?"mapimages":a||i.includes("Tiled")||"wmts"===e?"maptiles":"mapimages"):s="scene service"===e?i.includes("Line")?"sceneweblayerline":i.includes("3DObject")?"sceneweblayermultipatch":i.includes("Point")?"sceneweblayerpoint":i.includes("IntegratedMesh")?"sceneweblayermesh":i.includes("PointCloud")?"sceneweblayerpointcloud":i.includes("Polygon")?"sceneweblayerpolygon":i.includes("Building")?"sceneweblayerbuilding":i.includes("Voxel")?"sceneweblayervoxel":"sceneweblayer":"image service"===e?i.includes("Elevation 3D Layer")?"elevationlayer":i.includes("Tiled Imagery")?"tiledimagerylayer":"imagery":"stream service"===e?"streamlayer":"vector tile service"===e?"vectortile":"datastore catalog service"===e?"datastorecollection":"geocoding service"===e?"geocodeservice":"video service"===e?i.includes("Live Stream")?"livestreamvideolayer":"videolayer":"geoprocessing service"===e?i.includes("Web Tool")?"tool":"layers":"geodata service"===e?"geodataservice":"3dtiles service"===e?i.includes("3DObject")?"3dobjecttileslayer":i.includes("IntegratedMesh")?"integratedmeshtileslayer":"3dtileslayer":"layers"):"web map"===e||"cityengine web scene"===e?s="maps":"web scene"===e?s=i.includes("ViewingMode-Local")?"webscenelocal":"websceneglobal":"web mapping application"===e&&i.includes("configurableApp")?s="instantapps":"web mapping application"===e||"mobile application"===e||"application"===e||"operation view"===e||"desktop application"===e?s="apps":"map document"===e||"map package"===e||"published map"===e||"scene document"===e||"globe document"===e||"basemap package"===e||"mobile basemap package"===e||"mobile map package"===e||"project package"===e||"project template"===e||"pro map"===e||"layout"===e||"layer"===e&&i.includes("ArcGIS Pro")||"explorer map"===e&&i.indexOf("Explorer Document")?s="mapsgray":"service definition"===e||"shapefile"===e||"cad drawing"===e||"geojson"===e||"netcdf"===e||"administrative report"===e?s="datafiles":"360 vr experience"===e?s="360vr":"explorer add in"===e||"desktop add in"===e||"windows viewer add in"===e||"windows viewer configuration"===e?s="appsgray":"arcgis pro add in"===e||"arcgis pro configuration"===e?s="addindesktop":"pdf"===e?s="pdf":"microsoft word"===e?s="word":"microsoft excel"===e?s="excel":"microsoft powerpoint"===e?s="ppt":"rule package"===e||"file geodatabase"===e||"sqlite geodatabase"===e||"csv collection"===e||"kml collection"===e||"windows mobile package"===e||"map template"===e||"desktop application template"===e||"gml"===e||"arcpad package"===e||"code sample"===e||"document link"===e||"earth configuration"===e||"operations dashboard add in"===e||"rules package"===e||"workflow manager package"===e||"explorer map"===e&&i.includes("Explorer Mapping Application")||i.includes("Document")?s="datafilesgray":"network analysis service"===e||"geoprocessing service"===e||"geodata service"===e||"geometry service"===e||"geoprocessing package"===e||"locator package"===e||"geoprocessing sample"===e||"workflow manager service"===e?s="toolsgray":"layer"===e||"layer package"===e||"explorer layer"===e?s="layersgray":"analysis model"===e?s="analysismodel":"scene package"===e?s="scenepackage":"3dtiles package"===e?s="3dtileslayerpackage":"3dtiles service"===e?s="3dtileslayer":"mobile scene package"===e?s="mobilescenepackage":"tile package"===e||"compact tile package"===e?s="tilepackage":"task file"===e?s="taskfile":"report template"===e?s="report-template":"statistical data collection"===e?s="statisticaldatacollection":"insights workbook"===e?s="workbook":"insights model"===e?s="insightsmodel":"insights page"===e?s="insightspage":"insights theme"===e?s="insightstheme":"hub initiative"===e?s="hubinitiative":"hub page"===e?s="hubpage":"hub site application"===e?s="hubsite":"hub event"===e?s="hubevent":"hub project"===e?s="hubproject":"relational database connection"===e?s="relationaldatabaseconnection":"big data file share"===e?s="datastorecollection":"image collection"===e?s="imagecollection":"desktop style"===e?s="desktopstyle":"style"===e?s=i.includes("Dictionary")?"dictionarystyle":"style":"dashboard"===e?s="dashboard":"raster function template"===e?s="rasterprocessingtemplate":"vector tile package"===e?s="vectortilepackage":"ortho mapping project"===e?s="orthomappingproject":"ortho mapping template"===e?s="orthomappingtemplate":"solution"===e?s="solutions":"geopackage"===e?s="geopackage":"deep learning package"===e?s="deeplearningpackage":"real time analytic"===e?s="realtimeanalytics":"big data analytic"===e?s="bigdataanalytics":"feed"===e?s="feed":"excalibur imagery project"===e?s="excaliburimageryproject":"notebook"===e?s="notebook":"storymap"===e?s="storymap":"survey123 add in"===e?s="survey123addin":"mission"===e?s="mission":"mission report"===e?s="missionreport":"mission template"===e?s="missiontemplate":"quickcapture project"===e?s="quickcaptureproject":"pro report"===e?s="proreport":"pro report template"===e?s="proreporttemplate":"urban model"===e?s="urbanmodel":"web experience"===e?s="experiencebuilder":"web experience template"===e?s="webexperiencetemplate":"experience builder widget"===e?s="experiencebuilderwidget":"experience builder widget package"===e?s="experiencebuilderwidgetpackage":"workflow"===e?s="workflow":"kernel gateway connection"===e?s="kernelgatewayconnection":"insights script"===e?s="insightsscript":"hub initiative template"===e?s="hubinitiativetemplate":"storymap theme"===e?s="storymaptheme":"knowledge graph"===e?s="knowledgegraph":"knowledge graph layer"===e?s="knowledgegraphlayer":"knowledge studio project"===e?s="knowledgestudio":"native application"===e?s="nativeapp":"native application installer"===e?s="nativeappinstaller":"web link chart"===e?s="linkchart":"knowledge graph web investigation"===e?s="investigation":"ogcfeatureserver"===e?s="features":"pro project"===e?s="proproject":"insights workbook package"===e?s="insightsworkbookpackage":"apache parquet"===e?s="apacheparquet":"notebook code snippet library"===e?s="notebookcodesnippets":"suitability model"===e?s="suitabilitymodel":"esri classifier definition"===e?s="classifierdefinition":"esri classification schema"===e?s="classificationschema":"insights data engineering workbook"===e?s="dataengineeringworkbook":"insights data engineering model"===e?s="dataengineeringmodel":"deep learning studio project"===e?s="deeplearningproject":"discussion"===e?s="discussion":"allsource project"===e?s="allsourceproject":"api key"===e?s="apikey":"data pipeline"===e?s="datapipelines":"group layer"===e?(m=i.includes("Map"),s=m?"layergroup2d":"layergroup"):s="media layer"===e?"onlinemedialayer":"form"===e?i.includes("Survey123")?"survey":"datafilesgray":"csv"===e?"csv":"image"===e?"image":"maps",s?t(r+s+o+".png"):null}get isLayer(){return null!=this.type&&f.has(this.type)}get itemCdnUrl(){return w(this.itemUrl)}get itemPageUrl(){const e=this.portal?.itemPageUrl;return e&&this.id?`${e}?id=${this.id}`:null}get itemUrl(){const e=this.portal?.restUrl;return e&&this.id?`${e}/content/items/${this.id}`:null}get thumbnailUrl(){const e=this.itemUrl,t=this.thumbnail;return e&&t?this.portal?.normalizeUrl(`${e}/info/${t}?f=json`)??null:null}get userItemUrl(){const e=this.portal?.restUrl;if(!e)return null;const t=this.owner||this.portal?.user?.username;if(!t)return null;return`${e}/content/users/${this.ownerFolder?`${t}/${this.ownerFolder}`:t}/items/${this.id}`}load(e){const t=this.portal??(this.portal=h.getDefault()),i=t.load(e).then((()=>this.sourceJSON?this.sourceJSON:this.id&&this.itemUrl?t.request(this.itemUrl,{signal:null!=e?e.signal:null,query:{token:this.apiKey}}):{})).then((e=>{this.sourceJSON=e,this.read(e)}));return this.addResolvingPromise(i),Promise.resolve(this)}async addRating(e){const t={method:"post",query:{}};return e instanceof y&&(e=e.rating),null==e||isNaN(e)||"number"!=typeof e||(t.query.rating=e),this.portal?(await this.portal.request(this.itemUrl+"/addRating",t),new y({rating:e,created:new Date})):null}clone(){const e={access:this.access,accessInformation:this.accessInformation,applicationProxies:o(this.applicationProxies),avgRating:this.avgRating,categories:o(this.categories),classification:o(this.classification),created:o(this.created),culture:this.culture,description:this.description,extent:o(this.extent),groupCategories:o(this.groupCategories),id:this.id,itemControl:this.itemControl,licenseInfo:this.licenseInfo,modified:o(this.modified),name:this.name,numComments:this.numComments,numRatings:this.numRatings,numViews:this.numViews,owner:this.owner,ownerFolder:this.ownerFolder,portal:this.portal,screenshots:o(this.screenshots),size:this.size,snippet:this.snippet,sourceUrl:this.sourceUrl,spatialReference:this.spatialReference,tags:o(this.tags),thumbnail:this.thumbnail,title:this.title,type:this.type,typeKeywords:o(this.typeKeywords),url:this.url};this.loaded&&(e.loadStatus="loaded");const t=new v({sourceJSON:this.sourceJSON}).set(e);return t._set("isOrgItem",this.isOrgItem),t}createPostQuery(){const e=this.toJSON();for(const t of["tags","typeKeywords","categories"])e[t]=e[t]?.join(", ");for(const t of["extent","classification"]){const i=e[t];i&&(e[t]=JSON.stringify(i))}return e}async deleteRating(){await this.portal.request(this.itemUrl+"/deleteRating",{method:"post"})}fetchData(e="json",t){return this.portal.request(this.itemUrl+"/data",{responseType:e,...t,query:{token:this.apiKey}})}async fetchRating(e){const t=await this.portal.request(this.itemUrl+"/rating",{query:{token:this.apiKey},...e});return null!=t.rating?(t.created=new Date(t.created),new y(t)):null}fetchRelatedItems(e,t){return this.portal.requestToTypedArray(this.itemUrl+"/relatedItems",{query:{...e,token:this.apiKey},...t},v)}getThumbnailUrl(e){let t=this.thumbnailUrl;return t&&e&&(t+=`&w=${e}`),t}reload(){return this.portal.request(this.itemUrl??"",{cacheBust:!0,query:{token:this.apiKey}}).then((e=>(this.applicationProxies&&!Object.hasOwn(e,"appProxies")&&(this.applicationProxies=null),this.sourceJSON=e,this.read(e),this)))}update(e){return this.id?this.load().then((()=>this.portal.signIn())).then((()=>{const t=e?.data,i={method:"post"};i.query=this.createPostQuery();for(const e in i.query)null===i.query[e]&&(i.query[e]="");return i.query.clearEmptyFields=!0,null!=t&&("string"==typeof t?i.query.text=t:"object"==typeof t&&(i.query.text=JSON.stringify(t))),this.portal.request(`${this.userItemUrl}/update`,i).then((()=>this.reload()))})):Promise.reject(new i("portal:item-does-not-exist","The item does not exist yet and cannot be updated"))}async copy(e){if(!this.id)throw new i("portal:item-does-not-exist","The item does not exist yet");await this.load();const{portal:t,itemUrl:r}=this;await t.signIn();const{copyResources:o,folder:s,tags:a,title:n}=e||{},l={method:"post",query:{copyPrivateResources:"all"===o,folder:"string"==typeof s?s:s?.id,includeResources:!!o,tags:a?.join(","),title:n}},{itemId:p}=await t.request(`${r}/copy`,l);return new v({id:p,portal:t})}updateThumbnail(e){return this.id?this.load().then((()=>this.portal.signIn())).then((()=>{const t=e.thumbnail,i=e.filename,r={method:"post"};if("string"==typeof t)n(t)?r.query={data:t}:r.query={url:l(t)},null!=i&&(r.query.filename=i);else{const e=new FormData;null!=i?e.append("file",t,i):e.append("file",t),r.body=e}return this.portal.request(`${this.userItemUrl}/updateThumbnail`,r).then((()=>this.reload()))})):Promise.reject(new i("portal:item-does-not-exist","The item does not exist yet and cannot be updated"))}async fetchResources(e={},t){const{fetchResources:i}=await import("./support/resourceUtils.js");return i(this,e,t)}async addResource(e,t,i){const{addOrUpdateResources:r}=await import("./support/resourceUtils.js");return e.portalItem=this,await r(this,[{resource:e,content:t,compress:i?.compress,access:i?.access}],"add",i),e}async removeResource(e,t){const{removeResource:r}=await import("./support/resourceUtils.js");if(e.portalItem&&e.portalItem.itemUrl!==this.itemUrl)throw new i("removeresource:portal-item-mismatch","The portal item associated with the provided resource does not match the item");return r(this,e,t)}async removeAllResources(e){const{removeAllResources:t}=await import("./support/resourceUtils.js");return t(this,e)}resourceFromPath(e){return new g({portalItem:this,path:e})}toJSON(){const e=this.extent,t={accessInformation:this.accessInformation,categories:o(this.categories),classification:o(this.classification),created:this.created?.getTime(),description:this.description,extent:e&&[[e.xmin,e.ymin],[e.xmax,e.ymax]],id:this.id,isOrgItem:this.isOrgItem,licenseInfo:this.licenseInfo,modified:this.modified?.getTime(),name:this.name,owner:this.owner,ownerFolder:this.ownerFolder,snippet:this.snippet,sourceUrl:this.sourceUrl,spatialReference:this.spatialReference,tags:o(this.tags),thumbnail:this.thumbnail,title:this.title,type:this.type,typeKeywords:o(this.typeKeywords),url:this.url};return s(t)}static fromJSON(e){if(!e)return null;if(e.declaredClass)throw new Error("JSON object is already hydrated");return new v({sourceJSON:e})}_getPostQuery(){const e=this.toJSON();for(const t in e)"tags"===t&&null!==e[t]&&(e[t]=e[t].join(", ")),"typeKeywords"===t&&null!==e[t]&&(e[t]=e[t].join(", ")),"extent"===t&&e[t]&&(e[t]=JSON.stringify(e[t]));return e}};e([p({type:["private","shared","org","public"]})],k.prototype,"access",void 0),e([p()],k.prototype,"accessInformation",void 0),e([p({type:String})],k.prototype,"apiKey",void 0),e([p({json:{read:{source:"appProxies"}}})],k.prototype,"applicationProxies",void 0),e([p()],k.prototype,"avgRating",void 0),e([p()],k.prototype,"categories",void 0),e([p()],k.prototype,"classification",void 0),e([p({type:Date})],k.prototype,"created",void 0),e([p()],k.prototype,"culture",void 0),e([p()],k.prototype,"description",void 0),e([p({readOnly:!0})],k.prototype,"displayName",null),e([p({type:m})],k.prototype,"extent",void 0),e([d("extent")],k.prototype,"readExtent",null),e([p()],k.prototype,"groupCategories",void 0),e([p({readOnly:!0})],k.prototype,"iconUrl",null),e([p()],k.prototype,"id",void 0),e([p({readOnly:!0})],k.prototype,"isLayer",null),e([p({type:Boolean,readOnly:!0})],k.prototype,"isOrgItem",void 0),e([p()],k.prototype,"itemControl",void 0),e([p({readOnly:!0})],k.prototype,"itemPageUrl",null),e([p({readOnly:!0})],k.prototype,"itemUrl",null),e([p()],k.prototype,"licenseInfo",void 0),e([p({type:Date})],k.prototype,"modified",void 0),e([p()],k.prototype,"name",void 0),e([p()],k.prototype,"numComments",void 0),e([p()],k.prototype,"numRatings",void 0),e([p()],k.prototype,"numViews",void 0),e([p()],k.prototype,"owner",void 0),e([p()],k.prototype,"ownerFolder",void 0),e([p({type:h})],k.prototype,"portal",void 0),e([p()],k.prototype,"screenshots",void 0),e([p()],k.prototype,"size",void 0),e([p()],k.prototype,"snippet",void 0),e([p()],k.prototype,"sourceJSON",void 0),e([p({type:String})],k.prototype,"sourceUrl",void 0),e([p({type:String})],k.prototype,"spatialReference",void 0),e([p()],k.prototype,"tags",void 0),e([p()],k.prototype,"thumbnail",void 0),e([p({readOnly:!0})],k.prototype,"thumbnailUrl",null),e([p()],k.prototype,"title",void 0),e([p()],k.prototype,"type",void 0),e([p()],k.prototype,"typeKeywords",void 0),e([p({type:String,json:{read(e,t){if(b.has(t.type)){const t=this.portal?.restUrl;e||=t&&this.id?`${t}/content/items/${this.id}/data`:null}return e}}})],k.prototype,"url",void 0),e([p({readOnly:!0})],k.prototype,"userItemUrl",null),k=v=e([u("esri.portal.PortalItem")],k);const S=k;export{S as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- const a="20240820",d="d13730a280ad10a4a0fcba47ea5f6cfde4e9db08";export{a as buildDate,d as commitHash};
5
+ const e="20240821",c="1741bf32a83cc6d4fb5ec05ef01ff9551de65cee";export{e as buildDate,c as commitHash};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import{isRGB as e}from"../../core/colorUtils.js";import{getFontFamily as r}from"../../core/fontUtils.js";import{clone as t}from"../../core/lang.js";import i from"../../core/Logger.js";import{pt2px as o,px2pt as a}from"../../core/screenUtils.js";import{numericHash as s}from"../../core/string.js";import{checkForAnimations as l,getAnimationParams as n,handleAnchor as p,handleVectorFrame as c,translate as m,shouldUseAnimatedPath as f}from"./animationUtils.js";import{CIMSymbolHelper as y}from"./CIMSymbolHelper.js";import{defaultCIMValues as h}from"./defaultCIMValues.js";import{Alignment as d}from"./enums.js";import{OverrideHelper as u}from"./OverrideHelper.js";import{getExtent as v,getSDFMetrics as O}from"./SDFHelper.js";import{colorToArray as _,normalizeAlpha as g,getSize as M,isCIMMarkerStrokePlacement as k,getTintColor as S,getNumericValue as C,normalizePrimitiveOverrideProps as b,getDefaultCIMValue as P,getEnum as x,getFillColor as z,getStrokeColor as L,getStrokeWidth as E,fromCIMFontDecoration as I,fromCIMFontStyle as V,fromCIMHorizontalAlignment as N,fromCIMVerticalAlignment as w,isValidCIMValue as A,uncapitalize as R}from"./utils.js";import{CIMEffectHelper as G}from"./effects/CIMEffectHelper.js";import{randomInsidePolygonTextureSize as X}from"../../views/2d/engine/webgl/definitions.js";const F=()=>i.getLogger("esri.symbols.cim.cimAnalyzer");function T(e){const r=e.markerPlacement;return r&&r.angleToLine?d.MAP:d.SCREEN}class Y{constructor(e){this._cimLayers=[],this._poMap={},this._primitiveOverrides=[],e&&(this._resourceManager=e)}analyzeSymbolReference(r,t,i){if(this._cimLayers=i??[],!r)return this._cimLayers;if(this._reset(),r.primitiveOverrides){this._primitiveOverrides=r.primitiveOverrides;for(const r of this._primitiveOverrides){const t=r.valueExpressionInfo;if(t)this._setPoMap(r.primitiveName,r.propertyName,t);else if(null!=r.value){let t=r.value;r.propertyName.includes("Color")&&(e(t)&&(t=_(t)),t=g(t)),this._setPoMap(r.primitiveName,r.propertyName,t)}}}return this._analyzeSymbol(r.symbol,t),this._cimLayers}_reset(){this._cimLayers=[],this._poMap={},this._primitiveOverrides=[]}_analyzeSymbol(e,r){switch(e?.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":this._analyzeMultiLayerSymbol(e,r)}}_analyzeMultiLayerSymbol(e,r){const t=e?.symbolLayers;if(!t)return;const i=e.effects;let o=d.SCREEN;const a=M(e)??0;"CIMPointSymbol"===e.type&&"Map"===e.angleAlignment&&(o=d.MAP);let s={transform:[0,0,0,1],color:[1,1,1,1],hasAnimations:l(e)};s=n(this._poMap,e,s);const p="CIMPolygonSymbol"===e.type;let c=t.length;for(;c--;){const l=t[c];if(!l||!1===l.enable)continue;let n;i?.length&&(n=[...i]);const m=l.effects;m?.length&&(i?n.push(...m):n=[...m]);let f=null;if(n){f=[];for(const e of n){const r=u.findEffectOverrides(e,this._primitiveOverrides);r&&f.push(r)}}const y=[];switch(u.findApplicableOverrides(l,this._primitiveOverrides,y),l.type){case"CIMSolidFill":this._analyzeSolidFill(l,f);break;case"CIMPictureFill":this._analyzePictureFill(l,f);break;case"CIMHatchFill":this._analyzeHatchFill(l,f);break;case"CIMGradientFill":this._analyzeGradientFill(l,f);break;case"CIMSolidStroke":this._analyzeSolidStroke(l,f,p,a);break;case"CIMPictureStroke":this._analyzePictureStroke(l,f,p,a);break;case"CIMGradientStroke":this._analyzeGradientStroke(l,f,p,a);break;case"CIMCharacterMarker":case"CIMPictureMarker":case"CIMVectorMarker":{"CIMLineSymbol"!==e.type&&"CIMPolygonSymbol"!==e.type||(o=T(l));const t=[],i=l.primitiveName;i&&t.push(i);const n=p&&k(l.markerPlacement);this._analyzeMarker(l,f,null,t,o,a,r,[],s,!1,n);break}default:F().error("Cannot analyze CIM layer",l.type)}}}_analyzeSolidFill(e,r){const{primitiveName:t,type:i}=e,o=g(e.color);this._cimLayers.push({type:"fill",spriteRasterizationParam:null,colorLocked:!!e.colorLocked,color:this._getValueOrOverrideExpression(i,t,"Color",o),height:0,angle:0,offsetX:0,offsetY:0,scaleX:1,effects:r,applyRandomOffset:!1,sampleAlphaOnly:!0,hasUnresolvedReplacementColor:!1})}_analyzePictureFill(e,r){const{primitiveName:t,type:i}=e,o=S(e),a=C(e.height,h.CIMPictureFill.height);let s=C(e.scaleX,1);if("width"in e&&"number"==typeof e.width){const r=e.width;let t=1;const i=this._resourceManager.getResource(e.url);null!=i&&(t=i.width/i.height),s/=t*(a/r)}const l={type:"sprite-rasterization-param",resource:e,overrides:this._getPrimitiveMaterialOverrides(t,i)};this._cimLayers.push({type:"fill",spriteRasterizationParam:l,colorLocked:!!e.colorLocked,effects:r,color:this._getValueOrOverrideExpression(i,t,"TintColor",o),height:this._getValueOrOverrideExpression(i,t,"Height",a),scaleX:this._getValueOrOverrideExpression(i,t,"ScaleX",s),angle:this._getValueOrOverrideExpression(i,t,"Rotation",C(e.rotation)),offsetX:this._getValueOrOverrideExpression(i,t,"OffsetX",C(e.offsetX)),offsetY:this._getValueOrOverrideExpression(i,t,"OffsetY",C(e.offsetY)),applyRandomOffset:!1,sampleAlphaOnly:!1,hasUnresolvedReplacementColor:!1})}_analyzeHatchFill(e,r){const{primitiveName:t,type:i}=e,o=this._analyzeMaterialOverrides(t,["Rotation","OffsetX","OffsetY"]),a=b(o);let s=[255,255,255,1],l=!1;if(e.lineSymbol?.symbolLayers)for(const p of e.lineSymbol.symbolLayers){if("CIMSolidStroke"!==p.type)continue;const e=p.primitiveName??t;l||!e||p.colorLocked||null==this._poMap[e]?.Color&&null==this._poMap[e]?.StrokeColor||(s=g(p.color),s=this._maybeGetValueOrOverrideExpression(e,"StrokeColor")??this._getValueOrOverrideExpression(i,e,"Color",s),l=!0);const r=this._maybeGetValueOrOverrideExpression(e,"StrokeWidth");if(r){let t=null,o=null;"number"==typeof r?t=r:o=r.valueExpressionInfo;let s=a.find((e=>"strokeWidth"===e.propertyName));s?s.propertyName="width":(s={type:"CIMPrimitiveOverride",primitiveName:e,propertyName:"width",valueExpressionInfo:o,value:t,defaultValue:P(i,"width")},a.push(s))}}const n={type:"sprite-rasterization-param",resource:e,overrides:a};this._cimLayers.push({type:"fill",spriteRasterizationParam:n,colorLocked:!!e.colorLocked,effects:r,color:s,height:this._getValueOrOverrideExpression(i,t,"Separation",C(e.separation,h.CIMHatchFill.separation)),scaleX:1,angle:this._getValueOrOverrideExpression(i,t,"Rotation",C(e.rotation)),offsetX:this._getValueOrOverrideExpression(i,t,"OffsetX",C(e.offsetX)),offsetY:this._getValueOrOverrideExpression(i,t,"OffsetY",C(e.offsetY)),applyRandomOffset:!1,sampleAlphaOnly:!0,hasUnresolvedReplacementColor:!l})}_analyzeGradientFill(e,r){this._cimLayers.push({type:"fill",spriteRasterizationParam:null,colorLocked:!!e.colorLocked,effects:r,color:[128,128,128,1],height:0,angle:0,offsetX:0,offsetY:0,scaleX:1,applyRandomOffset:!1,sampleAlphaOnly:!1,hasUnresolvedReplacementColor:!1})}_analyzeSolidStroke(e,r,t,i){const{primitiveName:o,type:a}=e,s=g(e.color),l=C(e.width,h.CIMSolidStroke.width),n=x(e.capStyle,h.CIMSolidStroke.capstyle),p=x(e.joinStyle,h.CIMSolidStroke.joinstyle),c=e.miterLimit;let m,f,y,d,u=[];if(this._analyzePrimitiveOverrides(o,r,null,null)&&(u=this._getPrimitiveMaterialOverrides(o,a)),r&&Array.isArray(r)&&r.length>0){const e=r[r.length-1].effect;e&&"CIMGeometricEffectDashes"===e.type&&"NoConstraint"===e.lineDashEnding&&(m=e.dashTemplate,f=e.scaleDash,y=e.offsetAlongLine,d=e.primitiveName,(r=[...r]).pop())}null!=d&&u.push(...this._getPrimitiveMaterialOverrides(d,a).filter((e=>"dashTemplate"===e.propertyName)));const v=void 0!==m?{type:"sprite-rasterization-param",resource:{type:"dash",dashTemplate:m,primitiveName:d},overrides:u}:null;this._cimLayers.push({type:"line",spriteRasterizationParam:v,isOutline:t,colorLocked:!!e.colorLocked,effects:r,color:this._getValueOrOverrideExpression(a,o,"Color",s),width:this._getValueOrOverrideExpression(a,o,"Width",l),cap:this._getValueOrOverrideExpression(a,o,"CapStyle",n),join:this._getValueOrOverrideExpression(a,o,"JoinStyle",p),miterLimit:c&&this._getValueOrOverrideExpression(a,o,"MiterLimit",c),referenceWidth:i,zOrder:W(e.name),dashTemplate:this._maybeGetValueOrOverrideExpression(d,"DashTemplate")??m,offsetAlongLine:this._getValueOrOverrideExpression(a,d,"OffsetAlongLine",y??0),scaleDash:f,sampleAlphaOnly:!0})}_analyzePictureStroke(e,r,t,i){const{primitiveName:o,type:a}=e,s=S(e),l=C(e.width,h.CIMPictureStroke.width),n=x(e.capStyle,h.CIMPictureStroke.capstyle),p=x(e.joinStyle,h.CIMPictureStroke.joinstyle),c=e.miterLimit,m={type:"sprite-rasterization-param",resource:e,overrides:this._getPrimitiveMaterialOverrides(o,a)};this._cimLayers.push({type:"line",spriteRasterizationParam:m,isOutline:t,colorLocked:!!e.colorLocked,effects:r,color:this._getValueOrOverrideExpression(a,o,"TintColor",s),width:this._getValueOrOverrideExpression(a,o,"Width",l),cap:this._getValueOrOverrideExpression(a,o,"CapStyle",n),join:this._getValueOrOverrideExpression(a,o,"JoinStyle",p),miterLimit:c&&this._getValueOrOverrideExpression(a,o,"MiterLimit",c),referenceWidth:i,zOrder:W(e.name),dashTemplate:null,scaleDash:!1,sampleAlphaOnly:!1})}_analyzeGradientStroke(e,r,t,i){const{primitiveName:o,type:a}=e,s=C(e.width,h.CIMSolidStroke.width),l=x(e.capStyle,h.CIMGradientStroke.capstyle),n=x(e.joinStyle,h.CIMGradientStroke.joinstyle),p=e.miterLimit;this._cimLayers.push({type:"line",spriteRasterizationParam:null,isOutline:t,colorLocked:!!e.colorLocked,effects:r,color:[128,128,128,1],width:this._getValueOrOverrideExpression(a,o,"Width",s),cap:this._getValueOrOverrideExpression(a,o,"CapStyle",l),join:this._getValueOrOverrideExpression(a,o,"JoinStyle",n),miterLimit:p&&this._getValueOrOverrideExpression(a,o,"MiterLimit",p),referenceWidth:i,zOrder:W(e.name),dashTemplate:null,scaleDash:!1,sampleAlphaOnly:!1})}_analyzeMarker(e,r,t,i,o,a,s,l,c,m=!1,f=!1){if(m||=!!e.colorLocked,this._analyzeMarkerInsidePolygon(e,r,m))return;const y=C(e.size,h.CIMVectorMarker.size),d=C(e.rotation),u=C(e.offsetX),v=C(e.offsetY),{primitiveName:O,type:_}=e,g=this._getValueOrOverrideExpression(_,O,"Size",y),M=this._getValueOrOverrideExpression(_,O,"Rotation",d),k=this._getValueOrOverrideExpression(_,O,"OffsetX",u),S=this._getValueOrOverrideExpression(_,O,"OffsetY",v),b=p(e,c),P=n(this._poMap,e,b);switch(e.type){case"CIMPictureMarker":this._analyzePictureMarker(e,r,t,i,o,a,g,M,k,S,l,P,m,f);break;case"CIMVectorMarker":this._analyzeVectorMarker(e,r,t,i,o,a,g,M,k,S,l,P,s,m,f)}}_analyzeMarkerInsidePolygon(e,r,t){const{markerPlacement:i,type:o}=e;if(!i||"CIMMarkerPlacementInsidePolygon"!==i.type)return!1;if("CIMVectorMarker"===o||"CIMPictureMarker"===o){const t=e.primitiveName;if(t&&this._analyzePrimitiveOverrides([t],r,null,null))return!1;const a=i.primitiveName;if(a&&this._analyzePrimitiveOverrides([a],r,null,null))return!1;if("CIMVectorMarker"===o){const{markerGraphics:r}=e;if(r)for(const e of r){const{symbol:r}=e;if("CIMPolygonSymbol"===r?.type&&r.symbolLayers){const{symbolLayers:e}=r;for(const r of e)if("CIMSolidStroke"===r.type)return!1}}}else{const{animatedSymbolProperties:r}=e;if(r)return!1}}const s=Math.abs(i.stepX),l=Math.abs(i.stepY);if(0===s||0===l)return!0;let n,p;if("Random"===i.gridType){const e=a(X),r=Math.max(Math.floor(e/s),1);n=l*Math.max(Math.floor(e/l),1);p=r*s/n}else i.shiftOddRows?(n=2*l,p=s/l*.5):(n=l,p=s/l);const c=S(e),m="CIMCharacterMarker"===e.type?null:{type:"sprite-rasterization-param",resource:e,overrides:[]};return this._cimLayers.push({type:"fill",spriteRasterizationParam:m,colorLocked:t,effects:r,color:c,height:n,scaleX:p,angle:i.gridAngle,offsetX:C(i.offsetX),offsetY:C(i.offsetY),applyRandomOffset:"Random"===i.gridType,sampleAlphaOnly:"CIMPictureMarker"!==e.type,hasUnresolvedReplacementColor:!0}),!0}_analyzePictureMarker(e,r,i,o,a,l,n,p,c,m,f,y,h,d){const{animatedSymbolProperties:u,primitiveName:v,type:O}=e;let _=C(e.scaleX,1);const g=S(e);i||(i=this._createMarkerPlacementOverrideExpression(e.markerPlacement));const M=this._createGIFAnimatedSymbolPropertiesOverrideExpression(u),k=e.anchorPoint??{x:0,y:0};if("width"in e&&"number"==typeof e.width){const r=e.width;let t=1;const i=this._resourceManager.getResource(e.url);null!=i&&(t=i.width/i.height);_/=t*(C(e.size)/r)}const b=[...o];let P;e.primitiveName&&b.push(e.primitiveName),u||M?P={type:"animated",url:e.url,urlHash:"H"+s(e.url),playAnimation:e.animatedSymbolProperties?.playAnimation,reverseAnimation:e.animatedSymbolProperties?.reverseAnimation,randomizeStartTime:e.animatedSymbolProperties?.randomizeStartTime,randomizeStartSeed:e.animatedSymbolProperties?.randomizeStartSeed,startTimeOffset:e.animatedSymbolProperties?.startTimeOffset,duration:e.animatedSymbolProperties?.duration,repeatType:e.animatedSymbolProperties?.repeatType,repeatDelay:e.animatedSymbolProperties?.repeatDelay}:(P=t(e),P.markerPlacement=null);const x={type:"sprite-rasterization-param",resource:P,overrides:this._getMaterialOverrides(b,O)};M&&x.overrides.push(...M.overrides),this._cimLayers.push({type:"marker",spriteRasterizationParam:x,colorLocked:h,effects:r,scaleSymbolsProportionally:!1,alignment:a,size:n,scaleX:this._getValueOrOverrideExpression(O,v,"ScaleX",_),rotation:p,offsetX:c,offsetY:m,transform:{type:"cim-marker-transform-param",params:f},color:this._getValueOrOverrideExpression(O,v,"TintColor",g),anchorPoint:{x:k.x,y:k.y},isAbsoluteAnchorPoint:"Relative"!==e.anchorPointUnits,outlineColor:[0,0,0,0],outlineWidth:0,frameHeight:0,widthRatio:1,rotateClockwise:!!e.rotateClockwise,referenceSize:l,sizeRatio:1,isOutline:d,markerPlacement:i,animationParams:B(y)})}_analyzeVectorMarker(e,r,t,i,o,a,s,l,p,f,y,h,d,u,v){const O=e.markerGraphics;if(!O)return;const _=e.frame;let g=0;if(g=_?_.ymax-_.ymin:a,g){const r={offsetX:p,offsetY:f,rotation:l,size:s,frameHeight:g,rotateClockWise:!!e.rotateClockwise};y=[...y,r]}let M=h;e.frame&&(M=c(this._poMap,e,M)),t||(t=this._createMarkerPlacementOverrideExpression(e.markerPlacement));for(const c of O)if(c){const s=c.symbol;if(!s)continue;const l=c.primitiveName;l&&i.push(l);let p,f=M,h=0,O=0;if(("CIMPointSymbol"===s.type||"CIMTextSymbol"===s.type)&&_){let r=0,t=0;const i=c.geometry;"x"in i&&"y"in i&&(h+=i.x-.5*(_.xmin+_.xmax),O+=i.y-.5*(_.xmin+_.xmax),r+=i.x-.5*(_.xmin+_.xmax),t+=i.y-.5*(_.ymin+_.ymax));const o=e.anchorPoint;o&&("Absolute"===e.anchorPointUnits?(r-=o.x,t-=o.y):_&&(r-=(_.xmax-_.xmin)*o.x,t-=(_.ymax-_.ymin)*o.y));const a={offsetX:r,offsetY:t,rotation:0,size:0,frameHeight:0,rotateClockWise:!1};p=[...y,a]}switch(0===h&&0===O||(f=m(f,h,O)),"CIMPointSymbol"===s.type&&(f=n(this._poMap,s,f)),s.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":d||U(s)?this._analyzeMultiLayerGraphicNonSDF(e,r,t,c,i,o,a,p??y,g,u,v):this._analyzeMultiLayerGraphic(e,r,t,c,i,o,a,p??y,f,g,u,v);break;case"CIMTextSymbol":this._analyzeTextGraphic(r,t,c,i,o,a,p??y,u)}l&&i.pop()}}_analyzeMultiLayerGraphic(e,r,t,i,o,a,s,l,p,c,m,y){const h=i.symbol,d=h.symbolLayers;if(!d)return;let u=d.length;if(H(d)&&!f(p))return void this._analyzeCompositeMarkerGraphic(e,r,t,i,d,a,s,l,c,m,y);const _=this._resourceManager.geometryEngine,M=G.applyEffects(h.effects,i.geometry,_);if(M)for(;u--;){const f=d[u];if(!f||!1===f.enable)continue;const h=f.primitiveName;switch(h&&o.push(h),f.type){case"CIMSolidFill":case"CIMSolidStroke":{const o=G.applyEffects(f.effects,M,_),d=v(o);if(!d)continue;const u="Relative"!==e.anchorPointUnits,[k,S,C,b]=O(d,e.frame,e.size,e.anchorPoint,u),P="CIMSolidFill"===f.type,x={type:"sdf",geom:o,asFill:P},{path:I}=f,V=P?g(z(f)):null==I?g(L(f)):[0,0,0,0],N=P?[0,0,0,0]:g(L(f)),w=E(f)??0;if(!P&&!w)break;const A=i.primitiveName;let R=null;P&&!f.colorLocked&&(R=this._maybeGetValueOrOverrideExpression(A,"FillColor"));let X=null;P||f.colorLocked||(X=this._maybeGetValueOrOverrideExpression(A,"StrokeColor"));const F=R??this._getValueOrOverrideExpression(f.type,h,"Color",V),T=X??this._getValueOrOverrideExpression(f.type,h,"Color",N),Y=this._maybeGetValueOrOverrideExpression(A,"StrokeWidth")??this._getValueOrOverrideExpression(f.type,h,"Width",w),j=I?{type:"sprite-rasterization-param",resource:{type:"path",path:I,asFill:P},overrides:[]}:{type:"sprite-rasterization-param",resource:x,overrides:[]},W=n(this._poMap,f,p);this._cimLayers.push({type:"marker",spriteRasterizationParam:j,colorLocked:!!f.colorLocked||!!m,effects:r,scaleSymbolsProportionally:!!e.scaleSymbolsProportionally,alignment:a,anchorPoint:{x:S,y:C},isAbsoluteAnchorPoint:u,size:c,rotation:0,offsetX:0,offsetY:0,scaleX:1,transform:{type:"cim-marker-transform-param",params:l},frameHeight:c,widthRatio:b,rotateClockwise:!1,referenceSize:s,sizeRatio:k,color:F,outlineColor:T,outlineWidth:Y,isOutline:y,markerPlacement:t,animationParams:B(W),isStroke:"CIMSolidFill"!==f.type});break}case"CIMPictureMarker":case"CIMVectorMarker":f.markerPlacement?this._analyzeMultiLayerGraphicNonSDF(e,r,t,i,o,a,s,l,c,!!f.colorLocked||!!m,y):this._analyzeMarker(f,r,t,o,a,s,!1,l,p,m,y);break;default:this._analyzeMultiLayerGraphicNonSDF(e,r,t,i,o,a,s,l,c,!!f.colorLocked||!!m,y)}h&&o.pop()}}_analyzeTextGraphic(e,t,i,o,a,s,l,n){const p=[];u.findApplicableOverrides(i,this._primitiveOverrides,p);const c=i.geometry;if(!("x"in c)||!("y"in c))return;const m=i.symbol,f=I(m),y=V(m.fontStyleName),d=r(m.fontFamilyName);m.font={family:d,decoration:f,...y};const v=C(m.height,h.CIMTextSymbol.height),O=C(m.angle),_=C(m.offsetX),M=C(m.offsetY),k=g(z(m));let S=g(L(m)),b=E(m)??0;b||(S=g(z(m.haloSymbol)),b=C(m.haloSize));let P=!1;if(m.symbol?.symbolLayers)for(const r of m.symbol.symbolLayers){null!=g(z(r))&&(P=!!r.colorLocked)}const x=i.primitiveName;let A=null;P||(A=this._maybeGetValueOrOverrideExpression(x,"FillColor"));const R=this._maybeGetValueOrOverrideExpression(x,"TextSize"),G=this._maybeGetValueOrOverrideExpression(x,"TextAngle"),X=this._maybeGetValueOrOverrideExpression(x,"TextOffsetX"),F=this._maybeGetValueOrOverrideExpression(x,"TextOffsetY");let T=null,Y=null,j=0;if(m.callout&&"CIMBackgroundCallout"===m.callout.type){const e=m.callout;if(e.backgroundSymbol){const r=e.backgroundSymbol.symbolLayers;if(r)for(const e of r)"CIMSolidFill"===e.type?T=g(e.color):"CIMSolidStroke"===e.type&&(Y=g(e.color),j=C(e.width,h.CIMSolidStroke.width))}}const W=this._getValueOrOverrideExpression(m.type,i.primitiveName,"TextString",i.textString??"");if(null==W)return;const{fontStyleName:D}=m,H=d+(D?"-"+D.toLowerCase():"-regular"),U=this._getMaterialOverrides(o,m.type);U.push(...this._getPrimitiveMaterialOverrides(i.primitiveName,m.type));const J={type:"text-rasterization-param",resource:{type:"text",textString:i.textString??"",font:m.font,symbol:m,primitiveName:i.primitiveName},overrides:U};this._cimLayers.push({type:"text",lineWidth:m.lineWidth,textRasterizationParam:J,colorLocked:!!n||!!P,effects:e,alignment:a,anchorPoint:{x:0,y:0},isAbsoluteAnchorPoint:!1,fontName:H,decoration:f,weight:y.weight,style:y.style,size:R??v,angle:G??O,offsetX:X??_,offsetY:F??M,transform:{type:"cim-marker-transform-param",params:l},horizontalAlignment:N(m.horizontalAlignment),verticalAlignment:w(m.verticalAlignment),text:W,color:A??this._getValueOrOverrideExpression(m.type,i.primitiveName,"Color",k),outlineColor:S,outlineSize:b,backgroundColor:T,borderLineColor:Y,borderLineWidth:j,referenceSize:s,sizeRatio:1,markerPlacement:t})}_analyzeMultiLayerGraphicNonSDF(e,r,t,i,a,s,l,n,p,c,m){const f=j(e,i),h=e.primitiveName,d=this._analyzeMaterialOverrides(h,["Rotation","OffsetX","OffsetY"]),u=b(d),[v,O,_]=y.getTextureAnchor(f,this._resourceManager),g=this._getMaterialOverrides(a,e.type);g.push(...u);const M={type:"sprite-rasterization-param",resource:{...f,avoidSDFRasterization:!0},overrides:g};this._cimLayers.push({type:"marker",spriteRasterizationParam:M,colorLocked:c,effects:r,scaleSymbolsProportionally:!!e.scaleSymbolsProportionally,alignment:s,anchorPoint:{x:v,y:O},isAbsoluteAnchorPoint:!1,size:p,rotation:0,offsetX:0,offsetY:0,transform:{type:"cim-marker-transform-param",params:n},color:[255,255,255,1],outlineColor:[0,0,0,0],outlineWidth:0,scaleX:1,frameHeight:p,widthRatio:1,rotateClockwise:!!e.rotateClockwise,referenceSize:l,sizeRatio:_/o(e.size),isOutline:m,markerPlacement:t})}_createMarkerPlacementOverrideExpression(e){if(!e)return null;const r=[];return u.findApplicableOverrides(e,this._primitiveOverrides,r),{type:"cim-marker-placement-param",placement:e,overrides:J(r)}}_createGIFAnimatedSymbolPropertiesOverrideExpression(e){if(!e)return null;const r=[];return u.findApplicableOverrides(e,this._primitiveOverrides,r),{type:"cim-gif-animation-params",animation:e,overrides:J(r)}}_analyzeCompositeMarkerGraphic(e,r,t,i,o,a,s,l,n,p,c){const m=i.geometry,f=o[0],y=o[1],d=v(m);if(!d)return;const u="Relative"!==e.anchorPointUnits,[_,M,k,S]=O(d,e.frame,e.size,e.anchorPoint,u),{path:b}=y,P=y.primitiveName,x=f.primitiveName,z=i.primitiveName;let L=null;y.colorLocked||p||(L=this._maybeGetValueOrOverrideExpression(z,"FillColor"));const E=L??this._getValueOrOverrideExpression(y.type,P,"Color",g(y.color));let I=null;f.colorLocked||p||(I=this._maybeGetValueOrOverrideExpression(z,"StrokeColor"));const V=I??this._getValueOrOverrideExpression(f.type,x,"Color",g(f.color)),N=this._maybeGetValueOrOverrideExpression(z,"StrokeWidth")??this._getValueOrOverrideExpression(f.type,x,"Width",C(f.width,h.CIMSolidStroke.width)),w={type:"sprite-rasterization-param",resource:b?{type:"path",path:b,asFill:!0}:{type:"sdf",geom:m,asFill:!0},overrides:[]};this._cimLayers.push({type:"marker",spriteRasterizationParam:w,colorLocked:p,effects:r,scaleSymbolsProportionally:!!e.scaleSymbolsProportionally,alignment:a,anchorPoint:{x:M,y:k},isAbsoluteAnchorPoint:u,size:n,rotation:0,offsetX:0,offsetY:0,scaleX:1,transform:{type:"cim-marker-transform-param",params:l},frameHeight:n,widthRatio:S,rotateClockwise:!1,referenceSize:s,sizeRatio:_,color:E,outlineColor:V,outlineWidth:N,isOutline:c,markerPlacement:t})}_setPoMap(e,r,t){let i;this._poMap[e]?i=this._poMap[e]:(i={},this._poMap[e]=i),i[r]=t}_maybeGetValueOrOverrideExpression(e,r,t){return this._getValueOrOverrideExpression("",e,r,t,!1)}_getValueOrOverrideExpression(e,r,t,i,o=!0){if(o&&!A(i)&&(i=P(e,t.toLowerCase())),null==r)return i;const a=this._poMap[r];if(null==a)return i;const s=a[t];return"string"==typeof s||"number"==typeof s||Array.isArray(s)?s:s?{valueExpressionInfo:s,defaultValue:i}:i}_analyzePrimitiveOverrides(e,r,t,i){if(null==e)return!1;"string"==typeof e&&(e=[e]);for(const o of this._primitiveOverrides)if(e.includes(o.primitiveName)&&o.valueExpressionInfo)return!0;if(null!=r)for(const o of r)if(o?.overrides.length>0)return!0;if(null!=t)for(const o of t)if(o?.overrides.length>0)return!0;if(null!=i)for(const o of i)if(o?.overrides.length>0)return!0;return!1}_getMaterialOverrides(e,r){if(!e)return[];const t=[];for(const i of e)t.push(...this._getPrimitiveMaterialOverrides(i,r));return t}_getPrimitiveMaterialOverrides(e,r){if(!e)return[];const t=b(this._primitiveOverrides.filter((r=>r.primitiveName===e)));return t.forEach((e=>e.defaultValue=P(r,e.propertyName.toLowerCase()))),t}_analyzeMaterialOverrides(e,r){return this._primitiveOverrides.filter((t=>t.primitiveName!==e||!r.includes(t.propertyName)))}}function j(e,r){return{type:e.type,enable:!0,name:e.name,colorLocked:e.colorLocked,primitiveName:e.primitiveName,anchorPoint:e.anchorPoint,anchorPointUnits:e.anchorPointUnits,offsetX:0,offsetY:0,rotateClockwise:e.rotateClockwise,rotation:0,size:e.size,billboardMode3D:e.billboardMode3D,depth3D:e.depth3D,frame:e.frame,markerGraphics:[r],scaleSymbolsProportionally:e.scaleSymbolsProportionally,respectFrame:e.respectFrame,clippingPath:e.clippingPath}}function W(e){if(e&&0===e.indexOf("Level_")){const r=parseInt(e.slice(6),10);if(!isNaN(r))return r}return 0}function D(e,r){if(!r||0===r.length)return e;const i=t(e);return u.applyOverrides(i,r),i}const H=e=>e&&2===e.length&&e[0].enable&&e[1].enable&&"CIMSolidStroke"===e[0].type&&"CIMSolidFill"===e[1].type&&null==e[0].path&&null==e[1].path&&!e[0].effects&&!e[1].effects&&!e[0].animations&&!e[1].animations;function U(e){const r=e.symbolLayers;if(!r||2!==r.length)return!1;const t=r.find((e=>e.effects?.find((e=>"CIMGeometricEffectDashes"===e.type&&null!=e.dashTemplate)))),i=r.find((e=>e.effects?.find((e=>"CIMGeometricEffectAddControlPoints"===e.type))));return!!t||!!i}function J(e){return t(e).map((e=>({...e,propertyName:R(e.propertyName)})))}function B(e){return f(e)?{type:"animation-params",params:e}:null}export{Y as CIMAnalyzer,D as analyzeCIMResource};
5
+ import{isRGB as e}from"../../core/colorUtils.js";import{getFontFamily as r}from"../../core/fontUtils.js";import{clone as t}from"../../core/lang.js";import i from"../../core/Logger.js";import{pt2px as o,px2pt as a}from"../../core/screenUtils.js";import{numericHash as s}from"../../core/string.js";import{checkForAnimations as l,getAnimationParams as n,handleAnchor as p,handleVectorFrame as c,translate as m,shouldUseAnimatedPath as f}from"./animationUtils.js";import{CIMSymbolHelper as y}from"./CIMSymbolHelper.js";import{defaultCIMValues as h}from"./defaultCIMValues.js";import{Alignment as d}from"./enums.js";import{OverrideHelper as u}from"./OverrideHelper.js";import{getExtent as v,getSDFMetrics as O}from"./SDFHelper.js";import{colorToArray as _,normalizeAlpha as g,getSize as M,isCIMMarkerStrokePlacement as k,getTintColor as S,getNumericValue as C,normalizePrimitiveOverrideProps as b,getDefaultCIMValue as P,getEnum as x,getFillColor as z,getStrokeColor as L,getStrokeWidth as E,fromCIMFontDecoration as I,fromCIMFontStyle as V,fromCIMHorizontalAlignment as N,fromCIMVerticalAlignment as w,isValidCIMValue as A,uncapitalize as R}from"./utils.js";import{CIMEffectHelper as G}from"./effects/CIMEffectHelper.js";import{randomInsidePolygonTextureSize as X}from"../../views/2d/engine/webgl/definitions.js";const F=()=>i.getLogger("esri.symbols.cim.cimAnalyzer");function T(e){const r=e.markerPlacement;return r&&r.angleToLine?d.MAP:d.SCREEN}class Y{constructor(e){this._cimLayers=[],this._poMap={},this._primitiveOverrides=[],e&&(this._resourceManager=e)}analyzeSymbolReference(r,t,i){if(this._cimLayers=i??[],!r)return this._cimLayers;if(this._reset(),r.primitiveOverrides){this._primitiveOverrides=r.primitiveOverrides;for(const r of this._primitiveOverrides){const t=r.valueExpressionInfo;if(t)this._setPoMap(r.primitiveName,r.propertyName,t);else if(null!=r.value){let t=r.value;r.propertyName.includes("Color")&&(e(t)&&(t=_(t)),t=g(t)),this._setPoMap(r.primitiveName,r.propertyName,t)}}}return this._analyzeSymbol(r.symbol,t),this._cimLayers}_reset(){this._cimLayers=[],this._poMap={},this._primitiveOverrides=[]}_analyzeSymbol(e,r){switch(e?.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":this._analyzeMultiLayerSymbol(e,r)}}_analyzeMultiLayerSymbol(e,r){const t=e?.symbolLayers;if(!t)return;const i=e.effects;let o=d.SCREEN;const a=M(e)??0;"CIMPointSymbol"===e.type&&"Map"===e.angleAlignment&&(o=d.MAP);let s={transform:[0,0,0,1],color:[1,1,1,1],hasAnimations:l(e)};s=n(this._poMap,e,s);const p="CIMPolygonSymbol"===e.type;let c=t.length;for(;c--;){const l=t[c];if(!l||!1===l.enable)continue;let n;i?.length&&(n=[...i]);const m=l.effects;m?.length&&(i?n.push(...m):n=[...m]);let f=null;if(n){f=[];for(const e of n){const r=u.findEffectOverrides(e,this._primitiveOverrides);r&&f.push(r)}}const y=[];switch(u.findApplicableOverrides(l,this._primitiveOverrides,y),l.type){case"CIMSolidFill":this._analyzeSolidFill(l,f);break;case"CIMPictureFill":this._analyzePictureFill(l,f);break;case"CIMHatchFill":this._analyzeHatchFill(l,f);break;case"CIMGradientFill":this._analyzeGradientFill(l,f);break;case"CIMSolidStroke":this._analyzeSolidStroke(l,f,p,a);break;case"CIMPictureStroke":this._analyzePictureStroke(l,f,p,a);break;case"CIMGradientStroke":this._analyzeGradientStroke(l,f,p,a);break;case"CIMCharacterMarker":case"CIMPictureMarker":case"CIMVectorMarker":{"CIMLineSymbol"!==e.type&&"CIMPolygonSymbol"!==e.type||(o=T(l));const t=[],i=l.primitiveName;i&&t.push(i);const n=p&&k(l.markerPlacement);this._analyzeMarker(l,f,null,t,o,a,r,[],s,!1,n);break}default:F().error("Cannot analyze CIM layer",l.type)}}}_analyzeSolidFill(e,r){const{primitiveName:t,type:i}=e,o=g(e.color);this._cimLayers.push({type:"fill",spriteRasterizationParam:null,colorLocked:!!e.colorLocked,color:this._getValueOrOverrideExpression(i,t,"Color",o),height:0,angle:0,offsetX:0,offsetY:0,scaleX:1,effects:r,applyRandomOffset:!1,sampleAlphaOnly:!0,hasUnresolvedReplacementColor:!1})}_analyzePictureFill(e,r){const{primitiveName:t,type:i}=e,o=S(e),a=C(e.height,h.CIMPictureFill.height);let s=C(e.scaleX,1);if("width"in e&&"number"==typeof e.width){const r=e.width;let t=1;const i=this._resourceManager.getResource(e.url);null!=i&&(t=i.width/i.height),s/=t*(a/r)}const l={type:"sprite-rasterization-param",resource:e,overrides:this._getPrimitiveMaterialOverrides(t,i)};this._cimLayers.push({type:"fill",spriteRasterizationParam:l,colorLocked:!!e.colorLocked,effects:r,color:this._getValueOrOverrideExpression(i,t,"TintColor",o),height:this._getValueOrOverrideExpression(i,t,"Height",a),scaleX:this._getValueOrOverrideExpression(i,t,"ScaleX",s),angle:this._getValueOrOverrideExpression(i,t,"Rotation",C(e.rotation)),offsetX:this._getValueOrOverrideExpression(i,t,"OffsetX",C(e.offsetX)),offsetY:this._getValueOrOverrideExpression(i,t,"OffsetY",C(e.offsetY)),applyRandomOffset:!1,sampleAlphaOnly:!1,hasUnresolvedReplacementColor:!1})}_analyzeHatchFill(e,r){const{primitiveName:t,type:i}=e,o=this._analyzeMaterialOverrides(t,["Rotation","OffsetX","OffsetY"]),a=b(o);let s=[255,255,255,1],l=!1;if(e.lineSymbol?.symbolLayers)for(const p of e.lineSymbol.symbolLayers){if("CIMSolidStroke"!==p.type)continue;const e=p.primitiveName??t;l||!e||p.colorLocked||null==this._poMap[e]?.Color&&null==this._poMap[e]?.StrokeColor||(s=g(p.color),s=this._maybeGetValueOrOverrideExpression(e,"StrokeColor")??this._getValueOrOverrideExpression(i,e,"Color",s),l=!0);const r=this._maybeGetValueOrOverrideExpression(e,"StrokeWidth");if(r){let t=null,o=null;"number"==typeof r?t=r:o=r.valueExpressionInfo;let s=a.find((e=>"strokeWidth"===e.propertyName));s?s.propertyName="width":(s={type:"CIMPrimitiveOverride",primitiveName:e,propertyName:"width",valueExpressionInfo:o,value:t,defaultValue:P(i,"width")},a.push(s))}}const n={type:"sprite-rasterization-param",resource:e,overrides:a};this._cimLayers.push({type:"fill",spriteRasterizationParam:n,colorLocked:!!e.colorLocked,effects:r,color:s,height:this._getValueOrOverrideExpression(i,t,"Separation",C(e.separation,h.CIMHatchFill.separation)),scaleX:1,angle:this._getValueOrOverrideExpression(i,t,"Rotation",C(e.rotation)),offsetX:this._getValueOrOverrideExpression(i,t,"OffsetX",C(e.offsetX)),offsetY:this._getValueOrOverrideExpression(i,t,"OffsetY",C(e.offsetY)),applyRandomOffset:!1,sampleAlphaOnly:!0,hasUnresolvedReplacementColor:!l})}_analyzeGradientFill(e,r){this._cimLayers.push({type:"fill",spriteRasterizationParam:null,colorLocked:!!e.colorLocked,effects:r,color:[128,128,128,1],height:0,angle:0,offsetX:0,offsetY:0,scaleX:1,applyRandomOffset:!1,sampleAlphaOnly:!1,hasUnresolvedReplacementColor:!1})}_analyzeSolidStroke(e,r,t,i){const{primitiveName:o,type:a}=e,s=g(e.color),l=C(e.width,h.CIMSolidStroke.width),n=x(e.capStyle,h.CIMSolidStroke.capstyle),p=x(e.joinStyle,h.CIMSolidStroke.joinstyle),c=e.miterLimit;let m,f,y,d,u=[];if(this._analyzePrimitiveOverrides(o,r,null,null)&&(u=this._getPrimitiveMaterialOverrides(o,a)),r&&Array.isArray(r)&&r.length>0){const e=r[r.length-1].effect;e&&"CIMGeometricEffectDashes"===e.type&&"NoConstraint"===e.lineDashEnding&&(m=e.dashTemplate,f=e.scaleDash,y=e.offsetAlongLine,d=e.primitiveName,(r=[...r]).pop())}null!=d&&u.push(...this._getPrimitiveMaterialOverrides(d,a).filter((e=>"dashTemplate"===e.propertyName)));const v=void 0!==m?{type:"sprite-rasterization-param",resource:{type:"dash",dashTemplate:m,primitiveName:d},overrides:u}:null;this._cimLayers.push({type:"line",spriteRasterizationParam:v,isOutline:t,colorLocked:!!e.colorLocked,effects:r,color:this._getValueOrOverrideExpression(a,o,"Color",s),width:this._getValueOrOverrideExpression(a,o,"Width",l),cap:this._getValueOrOverrideExpression(a,o,"CapStyle",n),join:this._getValueOrOverrideExpression(a,o,"JoinStyle",p),miterLimit:c&&this._getValueOrOverrideExpression(a,o,"MiterLimit",c),referenceWidth:i,zOrder:W(e.name),dashTemplate:this._maybeGetValueOrOverrideExpression(d,"DashTemplate")??m,offsetAlongLine:this._getValueOrOverrideExpression(a,d,"OffsetAlongLine",y??0),scaleDash:f,sampleAlphaOnly:!0})}_analyzePictureStroke(e,r,t,i){const{primitiveName:o,type:a}=e,s=S(e),l=C(e.width,h.CIMPictureStroke.width),n=x(e.capStyle,h.CIMPictureStroke.capstyle),p=x(e.joinStyle,h.CIMPictureStroke.joinstyle),c=e.miterLimit,m={type:"sprite-rasterization-param",resource:e,overrides:this._getPrimitiveMaterialOverrides(o,a)};this._cimLayers.push({type:"line",spriteRasterizationParam:m,isOutline:t,colorLocked:!!e.colorLocked,effects:r,color:this._getValueOrOverrideExpression(a,o,"TintColor",s),width:this._getValueOrOverrideExpression(a,o,"Width",l),cap:this._getValueOrOverrideExpression(a,o,"CapStyle",n),join:this._getValueOrOverrideExpression(a,o,"JoinStyle",p),miterLimit:c&&this._getValueOrOverrideExpression(a,o,"MiterLimit",c),referenceWidth:i,zOrder:W(e.name),dashTemplate:null,scaleDash:!1,sampleAlphaOnly:!1})}_analyzeGradientStroke(e,r,t,i){const{primitiveName:o,type:a}=e,s=C(e.width,h.CIMSolidStroke.width),l=x(e.capStyle,h.CIMGradientStroke.capstyle),n=x(e.joinStyle,h.CIMGradientStroke.joinstyle),p=e.miterLimit;this._cimLayers.push({type:"line",spriteRasterizationParam:null,isOutline:t,colorLocked:!!e.colorLocked,effects:r,color:[128,128,128,1],width:this._getValueOrOverrideExpression(a,o,"Width",s),cap:this._getValueOrOverrideExpression(a,o,"CapStyle",l),join:this._getValueOrOverrideExpression(a,o,"JoinStyle",n),miterLimit:p&&this._getValueOrOverrideExpression(a,o,"MiterLimit",p),referenceWidth:i,zOrder:W(e.name),dashTemplate:null,scaleDash:!1,sampleAlphaOnly:!1})}_analyzeMarker(e,r,t,i,o,a,s,l,c,m=!1,f=!1){if(m||=!!e.colorLocked,this._analyzeMarkerInsidePolygon(e,r,m))return;const y=C(e.size,h.CIMVectorMarker.size),d=C(e.rotation),u=C(e.offsetX),v=C(e.offsetY),{primitiveName:O,type:_}=e,g=this._getValueOrOverrideExpression(_,O,"Size",y),M=this._getValueOrOverrideExpression(_,O,"Rotation",d),k=this._getValueOrOverrideExpression(_,O,"OffsetX",u),S=this._getValueOrOverrideExpression(_,O,"OffsetY",v),b=p(e,c),P=n(this._poMap,e,b);switch(e.type){case"CIMPictureMarker":this._analyzePictureMarker(e,r,t,i,o,a,g,M,k,S,l,P,m,f);break;case"CIMVectorMarker":this._analyzeVectorMarker(e,r,t,i,o,a,g,M,k,S,l,P,s,m,f)}}_analyzeMarkerInsidePolygon(e,r,t){const{markerPlacement:i,type:o}=e;if(!i||"CIMMarkerPlacementInsidePolygon"!==i.type)return!1;if("CIMVectorMarker"===o||"CIMPictureMarker"===o){const t=e.primitiveName;if(t&&this._analyzePrimitiveOverrides([t],r,null,null))return!1;const a=i.primitiveName;if(a&&this._analyzePrimitiveOverrides([a],r,null,null))return!1;if("CIMVectorMarker"===o){const{markerGraphics:r}=e;if(r)for(const e of r){const{symbol:r}=e;if("CIMPolygonSymbol"===r?.type&&r.symbolLayers){const{symbolLayers:e}=r;for(const r of e)if("CIMSolidStroke"===r.type)return!1}}}else{const{animatedSymbolProperties:r}=e;if(r)return!1}}const s=Math.abs(i.stepX),l=Math.abs(i.stepY);if(0===s||0===l)return!0;let n,p;if("Random"===i.gridType){const e=a(X),r=Math.max(Math.floor(e/s),1);n=l*Math.max(Math.floor(e/l),1);p=r*s/n}else i.shiftOddRows?(n=2*l,p=s/l*.5):(n=l,p=s/l);const c=S(e),m="CIMCharacterMarker"===e.type?null:{type:"sprite-rasterization-param",resource:e,overrides:[]};return this._cimLayers.push({type:"fill",spriteRasterizationParam:m,colorLocked:t,effects:r,color:c,height:n,scaleX:p,angle:i.gridAngle,offsetX:C(i.offsetX),offsetY:C(i.offsetY),applyRandomOffset:"Random"===i.gridType,sampleAlphaOnly:"CIMPictureMarker"!==e.type,hasUnresolvedReplacementColor:!0}),!0}_analyzePictureMarker(e,r,i,o,a,l,n,p,c,m,f,y,h,d){const{animatedSymbolProperties:u,primitiveName:v,type:O}=e;let _=C(e.scaleX,1);const g=S(e);i||(i=this._createMarkerPlacementOverrideExpression(e.markerPlacement));const M=this._createGIFAnimatedSymbolPropertiesOverrideExpression(u),k=e.anchorPoint??{x:0,y:0};if("width"in e&&"number"==typeof e.width){const r=e.width;let t=1;const i=this._resourceManager.getResource(e.url);null!=i&&(t=i.width/i.height);_/=t*(C(e.size)/r)}const b=[...o];let P;e.primitiveName&&b.push(e.primitiveName),u||M?P={type:"animated",url:e.url,urlHash:"H"+s(e.url),playAnimation:e.animatedSymbolProperties?.playAnimation,reverseAnimation:e.animatedSymbolProperties?.reverseAnimation,randomizeStartTime:e.animatedSymbolProperties?.randomizeStartTime,randomizeStartSeed:e.animatedSymbolProperties?.randomizeStartSeed,startTimeOffset:e.animatedSymbolProperties?.startTimeOffset,duration:e.animatedSymbolProperties?.duration,repeatType:e.animatedSymbolProperties?.repeatType,repeatDelay:e.animatedSymbolProperties?.repeatDelay}:(P=t(e),P.markerPlacement=null);const x={type:"sprite-rasterization-param",resource:P,overrides:this._getMaterialOverrides(b,O)};M&&x.overrides.push(...M.overrides),this._cimLayers.push({type:"marker",spriteRasterizationParam:x,colorLocked:h,effects:r,scaleSymbolsProportionally:!1,alignment:a,size:n,scaleX:this._getValueOrOverrideExpression(O,v,"ScaleX",_),rotation:p,offsetX:c,offsetY:m,transform:{type:"cim-marker-transform-param",params:f},color:this._getValueOrOverrideExpression(O,v,"TintColor",g),anchorPoint:{x:k.x,y:k.y},isAbsoluteAnchorPoint:"Relative"!==e.anchorPointUnits,outlineColor:[0,0,0,0],outlineWidth:0,frameHeight:0,widthRatio:1,rotateClockwise:!!e.rotateClockwise,referenceSize:l,sizeRatio:1,isOutline:d,markerPlacement:i,animationParams:B(y)})}_analyzeVectorMarker(e,r,t,i,o,a,s,l,p,f,y,h,d,u,v){const O=e.markerGraphics;if(!O)return;const _=e.frame;let g=0;if(g=_?_.ymax-_.ymin:a,g){const r={offsetX:p,offsetY:f,rotation:l,size:s,frameHeight:g,rotateClockWise:!!e.rotateClockwise};y=[...y,r]}let M=h;e.frame&&(M=c(this._poMap,e,M)),t||(t=this._createMarkerPlacementOverrideExpression(e.markerPlacement));for(const c of O)if(c){const s=c.symbol;if(!s)continue;const l=c.primitiveName;l&&i.push(l);let p,f=M,h=0,O=0;if(("CIMPointSymbol"===s.type||"CIMTextSymbol"===s.type)&&_){let r=0,t=0;const i=c.geometry;"x"in i&&"y"in i&&(h+=i.x-.5*(_.xmin+_.xmax),O+=i.y-.5*(_.xmin+_.xmax),r+=i.x-.5*(_.xmin+_.xmax),t+=i.y-.5*(_.ymin+_.ymax));const o=e.anchorPoint;o&&("Absolute"===e.anchorPointUnits?(r-=o.x,t-=o.y):_&&(r-=(_.xmax-_.xmin)*o.x,t-=(_.ymax-_.ymin)*o.y));const a={offsetX:r,offsetY:t,rotation:0,size:0,frameHeight:0,rotateClockWise:!1};p=[...y,a]}switch(0===h&&0===O||(f=m(f,h,O)),"CIMPointSymbol"===s.type&&(f=n(this._poMap,s,f)),s.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":d||U(s)?this._analyzeMultiLayerGraphicNonSDF(e,r,t,c,i,o,a,p??y,g,u,v):this._analyzeMultiLayerGraphic(e,r,t,c,i,o,a,p??y,f,g,u,v);break;case"CIMTextSymbol":this._analyzeTextGraphic(r,t,c,i,o,a,p??y,u)}l&&i.pop()}}_analyzeMultiLayerGraphic(e,r,t,i,o,a,s,l,p,c,m,y){const h=i.symbol,d=h.symbolLayers;if(!d)return;let u=d.length;if(H(d)&&!f(p))return void this._analyzeCompositeMarkerGraphic(e,r,t,i,d,a,s,l,c,m,y);const _=this._resourceManager.geometryEngine,M=G.applyEffects(h.effects,i.geometry,_);if(M)for(;u--;){const f=d[u];if(!f||!1===f.enable)continue;const h=f.primitiveName;switch(h&&o.push(h),f.type){case"CIMSolidFill":case"CIMSolidStroke":{const o=G.applyEffects(f.effects,M,_),d=v(o);if(!d)continue;const u="Relative"!==e.anchorPointUnits,[k,S,C,b]=O(d,e.frame,e.size,e.anchorPoint,u),P="CIMSolidFill"===f.type,x={type:"sdf",geom:o,asFill:P},{path:I}=f,V=P?g(z(f)):null==I?g(L(f)):[0,0,0,0],N=P?[0,0,0,0]:g(L(f)),w=E(f)??0;if(!P&&!w)break;const A=i.primitiveName;let R=null;P&&!f.colorLocked&&(R=this._maybeGetValueOrOverrideExpression(A,"FillColor"));let X=null;P||f.colorLocked||(X=this._maybeGetValueOrOverrideExpression(A,"StrokeColor"));const F=R??this._getValueOrOverrideExpression(f.type,h,"Color",V),T=X??this._getValueOrOverrideExpression(f.type,h,"Color",N),Y=this._maybeGetValueOrOverrideExpression(A,"StrokeWidth")??this._getValueOrOverrideExpression(f.type,h,"Width",w),j=I?{type:"sprite-rasterization-param",resource:{type:"path",path:I,asFill:P},overrides:[]}:{type:"sprite-rasterization-param",resource:x,overrides:[]},W=n(this._poMap,f,p);this._cimLayers.push({type:"marker",spriteRasterizationParam:j,colorLocked:!!f.colorLocked||!!m,effects:r,scaleSymbolsProportionally:!!e.scaleSymbolsProportionally,alignment:a,anchorPoint:{x:S,y:C},isAbsoluteAnchorPoint:u,size:c,rotation:0,offsetX:0,offsetY:0,scaleX:1,transform:{type:"cim-marker-transform-param",params:l},frameHeight:c,widthRatio:b,rotateClockwise:!1,referenceSize:s,sizeRatio:k,color:F,outlineColor:T,outlineWidth:Y,isOutline:y,markerPlacement:t,animationParams:B(W),isStroke:"CIMSolidFill"!==f.type});break}case"CIMPictureMarker":case"CIMVectorMarker":f.markerPlacement?this._analyzeMultiLayerGraphicNonSDF(e,r,t,i,o,a,s,l,c,!!f.colorLocked||!!m,y):this._analyzeMarker(f,r,t,o,a,s,!1,l,p,m,y);break;default:this._analyzeMultiLayerGraphicNonSDF(e,r,t,i,o,a,s,l,c,!!f.colorLocked||!!m,y)}h&&o.pop()}}_analyzeTextGraphic(e,t,i,o,a,s,l,n){const p=[];u.findApplicableOverrides(i,this._primitiveOverrides,p);const c=i.geometry;if(!("x"in c)||!("y"in c))return;const m=i.symbol,f=I(m),y=V(m.fontStyleName),d=r(m.fontFamilyName);m.font={family:d,decoration:f,...y};const v=C(m.height,h.CIMTextSymbol.height),O=C(m.angle),_=C(m.offsetX),M=C(m.offsetY),k=g(z(m));let S=g(L(m)),b=E(m)??0;b||(S=g(z(m.haloSymbol)),b=C(m.haloSize));let P=!1;if(m.symbol?.symbolLayers)for(const r of m.symbol.symbolLayers){null!=g(z(r))&&(P=!!r.colorLocked)}const x=i.primitiveName;let A=null;P||(A=this._maybeGetValueOrOverrideExpression(x,"FillColor"));const R=this._maybeGetValueOrOverrideExpression(x,"TextSize"),G=this._maybeGetValueOrOverrideExpression(x,"TextAngle"),X=this._maybeGetValueOrOverrideExpression(x,"TextOffsetX"),F=this._maybeGetValueOrOverrideExpression(x,"TextOffsetY");let T=null,Y=null,j=0;if(m.callout&&"CIMBackgroundCallout"===m.callout.type){const e=m.callout;if(e.backgroundSymbol){const r=e.backgroundSymbol.symbolLayers;if(r)for(const e of r)"CIMSolidFill"===e.type?T=g(e.color):"CIMSolidStroke"===e.type&&(Y=g(e.color),j=C(e.width,h.CIMSolidStroke.width))}}const W=this._getValueOrOverrideExpression(m.type,i.primitiveName,"TextString",i.textString??"");if(null==W)return;const{fontStyleName:D}=m,H=d+(D?"-"+D.toLowerCase():"-regular"),U=this._getMaterialOverrides(o,m.type);U.push(...this._getPrimitiveMaterialOverrides(i.primitiveName,m.type));const J={type:"text-rasterization-param",resource:{type:"text",textString:i.textString??"",font:m.font,symbol:m,primitiveName:i.primitiveName},overrides:U};this._cimLayers.push({type:"text",lineWidth:m.lineWidth,textRasterizationParam:J,colorLocked:!!n||!!P,effects:e,alignment:a,anchorPoint:{x:0,y:0},isAbsoluteAnchorPoint:!1,fontName:H,decoration:f,weight:y.weight,style:y.style,size:R??v,angle:G??O,offsetX:X??_,offsetY:F??M,transform:{type:"cim-marker-transform-param",params:l},horizontalAlignment:N(m.horizontalAlignment),verticalAlignment:w(m.verticalAlignment),text:W,color:A??this._getValueOrOverrideExpression(m.type,i.primitiveName,"Color",k),outlineColor:S,outlineSize:b,backgroundColor:T,borderLineColor:Y,borderLineWidth:j,referenceSize:s,sizeRatio:1,markerPlacement:t})}_analyzeMultiLayerGraphicNonSDF(e,r,t,i,a,s,l,n,p,c,m){const f=j(e,i),h=e.primitiveName,d=this._analyzeMaterialOverrides(h,["Rotation","OffsetX","OffsetY"]),u=b(d),[v,O,_]=y.getTextureAnchor(f,this._resourceManager),g=this._getMaterialOverrides(a,e.type);g.push(...u);const M={type:"sprite-rasterization-param",resource:{...f,avoidSDFRasterization:!0},overrides:g};this._cimLayers.push({type:"marker",spriteRasterizationParam:M,colorLocked:c,effects:r,scaleSymbolsProportionally:!!e.scaleSymbolsProportionally,alignment:s,anchorPoint:{x:v,y:O},isAbsoluteAnchorPoint:!1,size:p,rotation:0,offsetX:0,offsetY:0,transform:{type:"cim-marker-transform-param",params:n},color:[255,255,255,1],outlineColor:[0,0,0,0],outlineWidth:0,scaleX:1,frameHeight:p,widthRatio:1,rotateClockwise:!!e.rotateClockwise,referenceSize:l,sizeRatio:_/o(e.size),isOutline:m,markerPlacement:t})}_createMarkerPlacementOverrideExpression(e){if(!e)return null;const r=[];return u.findApplicableOverrides(e,this._primitiveOverrides,r),{type:"cim-marker-placement-param",placement:e,overrides:J(r)}}_createGIFAnimatedSymbolPropertiesOverrideExpression(e){if(!e)return null;const r=[];return u.findApplicableOverrides(e,this._primitiveOverrides,r),{type:"cim-gif-animation-params",animation:e,overrides:J(r)}}_analyzeCompositeMarkerGraphic(e,r,t,i,o,a,s,l,n,p,c){const m=i.geometry,f=o[0],y=o[1],d=v(m);if(!d)return;const u="Relative"!==e.anchorPointUnits,[_,M,k,S]=O(d,e.frame,e.size,e.anchorPoint,u),{path:b}=y,P=y.primitiveName,x=f.primitiveName,z=i.primitiveName;let L=null;y.colorLocked||p||(L=this._maybeGetValueOrOverrideExpression(z,"FillColor"));const E=L??this._getValueOrOverrideExpression(y.type,P,"Color",g(y.color));let I=null;f.colorLocked||p||(I=this._maybeGetValueOrOverrideExpression(z,"StrokeColor"));const V=I??this._getValueOrOverrideExpression(f.type,x,"Color",g(f.color)),N=this._maybeGetValueOrOverrideExpression(z,"StrokeWidth")??this._getValueOrOverrideExpression(f.type,x,"Width",C(f.width,h.CIMSolidStroke.width)),w={type:"sprite-rasterization-param",resource:b?{type:"path",path:b,asFill:!0}:{type:"sdf",geom:m,asFill:!0},overrides:[]};this._cimLayers.push({type:"marker",spriteRasterizationParam:w,colorLocked:p,effects:r,scaleSymbolsProportionally:!!e.scaleSymbolsProportionally,alignment:a,anchorPoint:{x:M,y:k},isAbsoluteAnchorPoint:u,size:n,rotation:0,offsetX:0,offsetY:0,scaleX:1,transform:{type:"cim-marker-transform-param",params:l},frameHeight:n,widthRatio:S,rotateClockwise:!1,referenceSize:s,sizeRatio:_,color:E,outlineColor:V,outlineWidth:N,isOutline:c,markerPlacement:t})}_setPoMap(e,r,t){let i;this._poMap[e]?i=this._poMap[e]:(i={},this._poMap[e]=i),i[r]=t}_maybeGetValueOrOverrideExpression(e,r,t){return this._getValueOrOverrideExpression("",e,r,t,!1)}_getValueOrOverrideExpression(e,r,t,i,o=!0){if(o&&!A(i)&&(i=P(e,t.toLowerCase())),null==r)return i;const a=this._poMap[r];if(null==a)return i;const s=a[t];return"string"==typeof s||"number"==typeof s||Array.isArray(s)?s:s?{valueExpressionInfo:s,defaultValue:i}:i}_analyzePrimitiveOverrides(e,r,t,i){if(null==e)return!1;"string"==typeof e&&(e=[e]);for(const o of this._primitiveOverrides)if(e.includes(o.primitiveName)&&o.valueExpressionInfo)return!0;if(null!=r)for(const o of r)if(o?.overrides.length>0)return!0;if(null!=t)for(const o of t)if(o?.overrides.length>0)return!0;if(null!=i)for(const o of i)if(o?.overrides.length>0)return!0;return!1}_getMaterialOverrides(e,r){if(!e)return[];const t=[];for(const i of e)t.push(...this._getPrimitiveMaterialOverrides(i,r));return t}_getPrimitiveMaterialOverrides(e,r){if(!e)return[];const t=b(this._primitiveOverrides.filter((r=>r.primitiveName===e)));return t.forEach((e=>e.defaultValue=P(r,e.propertyName.toLowerCase()))),t}_analyzeMaterialOverrides(e,r){return this._primitiveOverrides.filter((t=>t.primitiveName!==e||!r.includes(t.propertyName)))}}function j(e,r){return{type:e.type,enable:!0,name:e.name,colorLocked:e.colorLocked,primitiveName:e.primitiveName,anchorPoint:e.anchorPoint,anchorPointUnits:e.anchorPointUnits,offsetX:0,offsetY:0,rotateClockwise:e.rotateClockwise,rotation:0,size:e.size,billboardMode3D:e.billboardMode3D,depth3D:e.depth3D,frame:e.frame,markerGraphics:[r],scaleSymbolsProportionally:e.scaleSymbolsProportionally,respectFrame:e.respectFrame,clippingPath:e.clippingPath}}function W(e){if(e&&0===e.indexOf("Level_")){const r=parseInt(e.slice(6),10);if(!isNaN(r))return r}return 0}function D(e,r){if(!r||0===r.length)return e;const i=t(e);return u.applyOverrides(i,r),i}const H=e=>e&&2===e.length&&e[0].enable&&e[1].enable&&"CIMSolidStroke"===e[0].type&&"CIMSolidFill"===e[1].type&&null==e[0].path&&null==e[1].path&&!e[0].effects&&!e[1].effects&&!e[0].animations&&!e[1].animations;function U(e){const r=e.symbolLayers;if(!r)return!1;const t=r.find((e=>e.effects?.find((e=>"CIMGeometricEffectDashes"===e.type&&null!=e.dashTemplate)))),i=r.find((e=>e.effects?.find((e=>"CIMGeometricEffectAddControlPoints"===e.type))));return!!t||!!i}function J(e){return t(e).map((e=>({...e,propertyName:R(e.propertyName)})))}function B(e){return f(e)?{type:"animation-params",params:e}:null}export{Y as CIMAnalyzer,D as analyzeCIMResource};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../Color.js";import{isSymbol3D as t,isSymbol2D as o}from"../../symbols.js";import{forEach as r}from"../../core/asyncUtils.js";import"../../core/has.js";import{px2pt as n}from"../../core/screenUtils.js";import{ONES as l}from"../../core/libs/gl-matrix-2/factories/vec3f64.js";import{effectFunctionsFromJSON as i}from"../../layers/effects/jsonUtils.js";import{getCIMSymbolColor as c}from"./cimSymbolUtils.js";import{getStroke as s}from"./gfxUtils.js";import{Symbol3DMaterial as u}from"./Symbol3DMaterial.js";const a=new e("white");function f(e){const t=e.symbolLayers?.at(-1);if(t&&"outline"in t)return t?.outline?.size}function m(e){if(!e)return 0;if(t(e)){const t=f(e);return null!=t?t:0}return n(s(e)?.width)}function y(e){if(null==e||!("symbolLayers"in e)||null==e.symbolLayers)return!1;switch(e.type){case"point-3d":return e.symbolLayers.some((e=>"object"===e.type));case"line-3d":return e.symbolLayers.some((e=>"path"===e.type));case"polygon-3d":return e.symbolLayers.some((e=>"object"===e.type||"extrude"===e.type));default:return!1}}function p(e){return e.resource?.href??""}function h(r,n){if(!r)return null;let l=null;return t(r)?l=b(r):o(r)&&(l="cim"===r.type?c(r):r.color?new e(r.color):null),l?w(l,n):null}function b(t){const o=t.symbolLayers;if(!o)return null;let r=null;return o.forEach((e=>{"object"===e.type&&e.resource?.href||(r="water"===e.type?e.color:e.material?e.material.color:null)})),r?new e(r):null}function w(t,o){if(null==o||null==t)return t;const r=t.toRgba();return r[3]=r[3]*o,new e(r)}function d(e,t,o){const r=e.symbolLayers;if(!r)return;const n=e=>w(t=t??e??(null!=o?a:null),o);r.forEach((e=>{if("object"!==e.type||!e.resource?.href||t)if("water"===e.type)e.color=n(e.color);else{const t=null!=e.material?e.material.color:null,r=n(t);null==e.material?e.material=new u({color:r}):e.material.color=r,null!=o&&"outline"in e&&null!=e.outline?.color&&(e.outline.color=w(e.outline.color,o))}}))}function j(e,t,o){(t=t??e.color)&&(e.color=w(t,o)),null!=o&&"outline"in e&&e.outline?.color&&(e.outline.color=w(e.outline.color,o))}function g(r,n,l){r&&(n||null!=l)&&(n&&(n=new e(n)),t(r)?d(r,n,l):o(r)&&j(r,n,l))}async function k(e,t){const o=e.symbolLayers;o&&await r(o,(async e=>L(e,t)))}async function L(e,t){switch(e.type){case"extrude":x(e,t);break;case"icon":case"line":case"text":z(e,t);break;case"path":v(e,t);break;case"object":await U(e,t)}}function z(e,t){const o=S(t);null!=o&&(e.size=o)}function S(e){for(const t of e)if("number"==typeof t)return t;return null}function x(e,t){e.size="number"==typeof t[2]?t[2]:0}async function U(e,t){const{resourceSize:o,symbolSize:r}=await C(e),n=E(t,o,r);e.width=M(t[0],r[0],o[0],n),e.depth=M(t[1],r[1],o[1],n),e.height=M(t[2],r[2],o[2],n)}function v(e,t){const o=E(t,l,[e.width,void 0,e.height]);e.width=M(t[0],e.width,1,o),e.height=M(t[2],e.height,1,o)}function E(e,t,o){for(let r=0;r<3;r++){const n=e[r];switch(n){case"symbol-value":{const e=o[r];return null!=e?e/t[r]:1}case"proportional":break;default:if(n&&t[r])return n/t[r]}}return 1}async function C(e){const{computeObjectLayerResourceSize:t}=await import("./symbolLayerUtils.js"),o=await t(e,10),{width:r,height:n,depth:l}=e,i=[r,l,n];let c=1;for(let s=0;s<3;s++){const e=i[s];if(null!=e){c=e/o[s];break}}for(let s=0;s<3;s++)null==i[s]&&(i[s]=o[s]*c);return{resourceSize:o,symbolSize:i}}function M(e,t,o,r){switch(e){case"proportional":return o*r;case"symbol-value":return null!=t?t:o;default:return e}}function O(e,t){const o=S(t);if(null!=o)switch(e.type){case"simple-marker":e.size=o;break;case"picture-marker":{const t=e.width/e.height;t>1?(e.width=o,e.height=o*t):(e.width=o*t,e.height=o);break}case"simple-line":e.width=o;break;case"text":e.font.size=o}}async function R(e,r){if(e&&r)return t(e)?k(e,r):void(o(e)&&O(e,r))}function D(e,r,n){if(e&&null!=r)if(t(e)){const t=e.symbolLayers;t&&t.forEach((e=>{if(e&&"object"===e.type)switch(n){case"tilt":e.tilt=(e.tilt??0)+r;break;case"roll":e.roll=(e.roll??0)+r;break;default:e.heading=(e.heading??0)+r}}))}else o(e)&&("simple-marker"!==e.type&&"picture-marker"!==e.type&&"text"!==e.type||(e.angle+=r))}function I(e){if(!e)return null;const t=e.effects.filter((e=>"bloom"!==e.type)).map((e=>e.toJSON()));return i(t)}function J(e){return null!=e&&"polygon-3d"===e.type&&e.symbolLayers.some((e=>"extrude"===e.type))}async function N(e,t){const o=await e.fetchSymbol(t);return o||e.fetchCIMSymbol(t)}export{g as applyColorToSymbol,w as applyOpacityToColor,D as applyRotationToSymbol,R as applySizesToSymbol,N as fetchWebStyleSymbol,I as getCSSFilterFromEffectList,h as getColorFromSymbol,p as getIconHref,m as getSymbolOutlineSize,y as isVolumetricSymbol,J as symbolHasExtrudeSymbolLayer};
5
+ import e from"../../Color.js";import{isSymbol3D as t,isSymbol2D as o}from"../../symbols.js";import{forEach as r}from"../../core/asyncUtils.js";import"../../core/has.js";import{px2pt as n}from"../../core/screenUtils.js";import{ONES as l}from"../../core/libs/gl-matrix-2/factories/vec3f64.js";import{effectFunctionsFromJSON as i}from"../../layers/effects/jsonUtils.js";import{getCIMSymbolColor as c}from"./cimSymbolUtils.js";import{getStroke as s}from"./gfxUtils.js";import{Symbol3DMaterial as u}from"./Symbol3DMaterial.js";const a=new e("white");function f(e){const t=e.symbolLayers?.at(-1);if(t&&"outline"in t)return t?.outline?.size}function m(e){if(!e)return 0;if(t(e)){const t=f(e);return null!=t?t:0}return n(s(e)?.width)}function y(e){if(null==e||!("symbolLayers"in e)||null==e.symbolLayers)return!1;switch(e.type){case"point-3d":return e.symbolLayers.some((e=>"object"===e.type));case"line-3d":return e.symbolLayers.some((e=>"path"===e.type));case"polygon-3d":return e.symbolLayers.some((e=>"object"===e.type||"extrude"===e.type));default:return!1}}function p(e){return e.resource?.href??""}function h(r,n){if(!r)return null;let l=null;return t(r)?l=b(r):o(r)&&(l="cim"===r.type?c(r):r.color?new e(r.color):null),l?w(l,n):null}function b(t){const o=t.symbolLayers;if(!o)return null;let r=null;return o.forEach((e=>{"object"===e.type&&e.resource?.href||(r="water"===e.type?e.color:e.material?e.material.color:null)})),r?new e(r):null}function w(t,o){if(null==o||null==t)return t;const r=t.toRgba();return r[3]=r[3]*o,new e(r)}function d(e,t,o){const r=e.symbolLayers;if(!r)return;const n=e=>w(t=t??e??(null!=o?a:null),o);r.forEach((e=>{if("object"!==e.type||!e.resource?.href||t)if("water"===e.type)e.color=n(e.color);else{const t=null!=e.material?e.material.color:null,r=n(t);null==e.material?e.material=new u({color:r}):e.material.color=r,null!=o&&"outline"in e&&null!=e.outline?.color&&(e.outline.color=w(e.outline.color,o))}}))}function j(e,t,o){(t=t??e.color)&&(e.color=w(t,o)),null!=o&&"outline"in e&&e.outline?.color&&(e.outline.color=w(e.outline.color,o))}function g(r,n,l){r&&(n||null!=l)&&(n&&(n=new e(n)),t(r)?d(r,n,l):o(r)&&j(r,n,l))}async function k(e,t){const o=e.symbolLayers;o&&await r(o,(async e=>L(e,t)))}async function L(e,t){switch(e.type){case"extrude":x(e,t);break;case"icon":case"line":case"text":z(e,t);break;case"path":v(e,t);break;case"object":await U(e,t)}}function z(e,t){const o=S(t);null!=o&&(e.size=o)}function S(e){for(const t of e)if("number"==typeof t)return t;return null}function x(e,t){e.size="number"==typeof t[2]?t[2]:0}async function U(e,t){const{resourceSize:o,symbolSize:r}=await C(e),n=E(t,o,r);e.width=M(t[0],r[0],o[0],n),e.depth=M(t[1],r[1],o[1],n),e.height=M(t[2],r[2],o[2],n)}function v(e,t){const o=E(t,l,[e.width,void 0,e.height]);e.width=M(t[0],e.width,1,o),e.height=M(t[2],e.height,1,o)}function E(e,t,o){for(let r=0;r<3;r++){const n=e[r];switch(n){case"symbol-value":{const e=o[r];return null!=e?e/t[r]:1}case"proportional":break;default:if(n&&t[r])return n/t[r]}}return 1}async function C(e){const{computeObjectLayerResourceSize:t}=await import("./symbolLayerUtils.js"),o=await t(e,10),{width:r,height:n,depth:l}=e,i=[r,l,n];let c=1;for(let s=0;s<3;s++){const e=i[s];if(null!=e){c=e/o[s];break}}for(let s=0;s<3;s++)null==i[s]&&(i[s]=o[s]*c);return{resourceSize:o,symbolSize:i}}function M(e,t,o,r){switch(e){case"proportional":return o*r;case"symbol-value":return null!=t?t:o;default:return e}}function O(e,t){const o=S(t);if(null!=o)switch(e.type){case"simple-marker":e.size=o;break;case"picture-marker":{const t=e.width/e.height;t>1?(e.width=o,e.height=o*t):(e.width=o*t,e.height=o);break}case"simple-line":e.width=o;break;case"text":e.font.size=o}}async function R(e,r){if(e&&r)return t(e)?k(e,r):void(o(e)&&O(e,r))}function D(e,r,n){if(e&&null!=r)if(t(e)){const t=e.symbolLayers;t&&t.forEach((e=>{if("object"===e.type)switch(n){case"tilt":e.tilt=(e.tilt??0)+r;break;case"roll":e.roll=(e.roll??0)+r;break;default:e.heading=(e.heading??0)+r}"icon"===e.type&&(e.rotation+=r)}))}else o(e)&&("simple-marker"!==e.type&&"picture-marker"!==e.type&&"text"!==e.type||(e.angle+=r))}function I(e){if(!e)return null;const t=e.effects.filter((e=>"bloom"!==e.type)).map((e=>e.toJSON()));return i(t)}function J(e){return null!=e&&"polygon-3d"===e.type&&e.symbolLayers.some((e=>"extrude"===e.type))}async function N(e,t){const o=await e.fetchSymbol(t);return o||e.fetchCIMSymbol(t)}export{g as applyColorToSymbol,w as applyOpacityToColor,D as applyRotationToSymbol,R as applySizesToSymbol,N as fetchWebStyleSymbol,I as getCSSFilterFromEffectList,h as getColorFromSymbol,p as getIconHref,m as getSymbolOutlineSize,y as isVolumetricSymbol,J as symbolHasExtrudeSymbolLayer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Camera.js";import"../../../geometry.js";import i from"../../../Viewpoint.js";import r from"../../../core/Accessor.js";import a from"../../../core/Logger.js";import{destroyMaybe as s}from"../../../core/maybe.js";import{on as n,watch as o,sync as h,when as l}from"../../../core/reactiveUtils.js";import{addFrameTask as p}from"../../../core/scheduling.js";import{createScreenPoint as c}from"../../../core/screenUtils.js";import{property as m}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as d}from"../../../core/accessorSupport/decorators/subclass.js";import{a as v}from"../../../chunks/vec32.js";import{fromArray as u}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{s as w}from"../../../chunks/vec42.js";import{create as g}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import _ from"../../../geometry/Extent.js";import y from"../../../geometry/Point.js";import{isLoadedOrLoadFor as f,requiresLoad as C}from"../../../geometry/projection.js";import{ViewingMode as x}from"../../ViewingMode.js";import{applyAll as R}from"../camera/constraintUtils.js";import{cameraOnContentAlongViewDirection as P,surfaceElevationBelowRenderLocation as S}from"../camera/intersectionUtils.js";import{ConstraintsManager as O}from"./ConstraintsManager.js";import{Frustum as T}from"./Frustum.js";import{GoToOperation as b}from"./GoToOperation.js";import{SurfaceCollisionCorrectionController as j}from"./controllers/SurfaceCollisionCorrectionController.js";import{internalToExternal as I,externalToInternal as M,toArea as z,toExtent as A,distanceToScale as E,directionToHeadingTilt as L,scaleToZoom as N,fromExtentSync as H,OrientationMode as V,getObserverForPointAtDistanceSync as B,scaleToDistance as D,zoomToScale as G}from"../support/cameraUtils.js";import{fromCamera as F,toCameraSync as U}from"../support/viewpointUtils.js";import k from"../webgl/RenderCamera.js";import{PaddingSide as q}from"../webgl-engine/lib/rendererUtils.js";import{RenderFeature as W}from"../webgl-engine/lib/RenderFeature.js";import{PropertiesPool as J}from"../../support/PropertiesPool.js";import{RenderState as K}from"../../support/RenderState.js";import{ensureAttachmentMaxSize as Q}from"../../webgl/FramebufferObject.js";import X from"../../../geometry/Polygon.js";let Y=class extends r{constructor(e){super(e),this.ready=!1,this._windowDevicePixelRatio=1,this._devicePixelRatioOverride=null,this._idleTimeout=oe,this.test={viewStateManager:this,contentCameraResetState:new Map,setDevicePixelRatio:e=>this._devicePixelRatioOverride=e,renderState:null,get maximumPixelRatio(){return this.viewStateManager.view.qualitySettings.maximumPixelRatio},get updatingIgnoreRenderState(){return null!=this.renderState},get idleTimeoutEnabled(){return this.viewStateManager._idleTimeout>0},set idleTimeoutEnabled(e){this.viewStateManager._idleTimeout=e?oe:0}},this._propertiesPool=new J({frustum:T},this),this._cameraSetByUser=!1,this._gotoOperation=null,this._cameraChangeTime=0,this._tmpCanvasSize=new Z}initialize(){this._cameraChangeTime=performance.now(),this.addHandles([n((()=>this.view.state.events),"before-camera-change",(e=>e&&this._updateElevation(e))),o((()=>this.view.state?.camera),((e,t)=>this._cameraChangedHandler(e,t)),h)]),l((()=>this.view.state?.camera),(e=>this._updateElevation(e)),{once:!0,sync:!0}),this.addHandles([p({prepare:()=>this._prepareFrame()}),o((()=>this.view.state.cameraController),(()=>{this._cameraSetByUser=!0,this.removeHandles(se)})),n((()=>this.view.state.events),"camera-projection-changed",(()=>this.notifyChange("scale")))])}destroy(){this.exit(),this._propertiesPool=s(this._propertiesPool)}get camera(){const e=this._get("camera");if(!this.ready)return e;const t=I(this.view,this.view.state.camera,ie);return t&&e&&t.equals(e)?e:t.clone()}set camera(e){this._updatePropertyBeforeReady("camera",e)||(this.view.elevationProvider?.enableCache(!0),this.setStateCamera(M(this.view,e),{applyConstraints:!1})||a.getLogger(this).error("#camera=","Invalid camera",e),this.view.elevationProvider?.enableCache(!1))}get contentCamera(){const e=this._get("contentCamera");if(!this.ready)return e;const t=I(this.view,this.view.state.contentCamera,ie);return t&&e&&t.equals(e)?e:t.clone()}set contentCamera(e){if(this._updatePropertyBeforeReady("contentCamera",e))return;const t=M(this.view,e);null!=t?(this._updateElevation(t),this.view.state.contentCamera=t):this.view.state.contentCamera=null}installContentCameraReset(e){if(this.removeHandles(ne),this.test.contentCameraResetState.clear(),!this.view.state.fixedContentCamera)return!1;const t=this.zoom,i=this.view.state.camera.distance**2,r=u(this.view.state.camera.center),a=e.sticky?this.contentCamera.clone():null;return this.addHandles([o((()=>this.contentCamera),(()=>{e.sticky||(this.removeHandles(ne),this.test.contentCameraResetState.clear())})),o((()=>this.zoom),(e=>{void 0!==e&&void 0!==t&&(this.test.contentCameraResetState.set("view.zoom",Math.abs(e-t)/2),Math.abs(e-t)>2?this.contentCamera=null:this.view.state.fixedContentCamera||(this.contentCamera=a))})),o((()=>this.view.state.camera),(e=>{const t=v(r,e.center);this.test.contentCameraResetState.set("camera.center",t/i),t>i?this.contentCamera=null:this.view.state.fixedContentCamera||(this.contentCamera=a)}))],ne),!0}get center(){return this.ready?this.view.pointsOfInterest.centerOnContent.location:this._get("center")}set center(e){this._updatePropertyBeforeReady("center",e)||(e?this.isCompatible(e)?this.setStateCamera(this._centerToCamera(e),{applyConstraints:!0})?this.view.pointsOfInterest.centerOnContent.runTask():a.getLogger(this).error("#center=","Invalid center",e):a.getLogger(this).error("#center=","Center has an incompatible spatial reference (center: "+(e.spatialReference?e.spatialReference.wkid:"none")+", view: "+this.view.spatialReference?.wkid+")",e):a.getLogger(this).error("#center=","Center may not be null or undefined"))}get visibleArea(){if(!this.ready){const e=this._get("extent");return e?X.fromExtent(e):null}return z(this.view,this.view.pointsOfInterest.focus.renderLocation)}get extent(){if(!this.ready)return this._get("extent");const e=this.view,t=A(e,e.state.camera,e.pointsOfInterest.centerOnContent.renderLocation);return null!=t?t:this._get("extent")}set extent(e){this._updatePropertyBeforeReady("extent",e)||(e?this.isCompatible(e)?this.setStateCamera(this._extentToCamera(e),{applyConstraints:!0})||a.getLogger(this).error("#extent=","Invalid extent",e):a.getLogger(this).error("#extent=","Extent has an incompatible spatial reference (extent: "+(e.spatialReference?e.spatialReference.wkid:"none")+", view: "+this.view.spatialReference?.wkid+")",e):a.getLogger(this).error("#extent=","Extent may not be null or undefined"))}get frustum(){const e=this._propertiesPool.get("frustum");return e.renderCoordsHelper=this.view.renderCoordsHelper,e.update(this.view.state.camera),e}get constraintsManager(){return this._constraintsManager}get _initialViewpoint(){const e=this.view.map;return e&&"initialViewProperties"in e?e.initialViewProperties?.viewpoint:void 0}get hasInitialView(){return!!this._initialViewpoint}get scale(){if(this.ready){const e=this.view.pointsOfInterest.centerOnContent;return E(this.view,e.distance,e.location.latitude)}return this._get("scale")}set scale(e){this._updatePropertyBeforeReady("scale",e)||this.setStateCamera(this._scaleToCamera(e),{applyConstraints:!0})||a.getLogger(this).error("#scale=","Invalid scale",e)}get terrainScale(){if(!this.ready)return this._get("scale");const e=this.view,t=e.basemapTerrain.tilingScheme,i=e.pointsOfInterest.cameraOnSurface.scale;if(!t||!i)return this._get("scale");const r=e.state.contentCamera;let a=L(e,r.eye,r.viewForward,r.up).tilt;a>90&&(a=180-a);const s=2*(a/90)**2,n=t.levelAtScale(i)-s;return n<0?this._get("scale"):t.scaleAtLevel(n)}get padding(){if(!this.ready)return this._get("padding");const e=this.view.state.camera,t=e.padding,i=e.pixelRatio,r=this._get("padding"),a=Math.round(t[q.TOP]/i),s=Math.round(t[q.RIGHT]/i),n=Math.round(t[q.BOTTOM]/i),o=Math.round(t[q.LEFT]/i);return null!=r&&r.top===a&&r.right===s&&r.bottom===n&&r.left===o?r:{top:a,right:s,bottom:n,left:o}}set padding(e){this._updatePropertyBeforeReady("padding",e)||(this._paddingToArray(e,this.view.state.camera.pixelRatio,ae),this.view.state.updateCamera((e=>e.padding=ae)))}_paddingToArray(e,t,i){e?w(i,e.top||0,e.right||0,e.bottom||0,e.left||0):w(i,0,0,0,0);for(let r=0;r<4;r++)i[r]=Math.round(i[r]*t)}get screenCenter(){const e=this.padding;return c((this.view.width-(e.left+e.right))/2+e.left,(this.view.height-(e.top+e.bottom))/2+e.top)}get viewpoint(){return this.ready?F(this.view,this.camera):this._get("viewpoint")}set viewpoint(e){if(!this._updatePropertyBeforeReady("viewpoint",e))if(e)if(this.isCompatible(e))this.setStateCamera(this._viewpointToCamera(e),{applyConstraints:!e.camera})||a.getLogger(this).error("#viewpoint=","Invalid viewpoint",e);else{const t=null!=e.camera?e.camera.position:e.targetGeometry,i=null!=t&&t.spatialReference;a.getLogger(this).error("#viewpoint=","Viewpoint has an incompatible spatial reference (viewpoint: "+(i?i.wkid:"none")+", view: "+this.view.spatialReference?.wkid+")",e)}else a.getLogger(this).error("#viewpoint=","Viewpoint may not be null or undefined")}get zoom(){return this.ready?N(this.view,this.scale):this._get("zoom")}set zoom(e){this._updatePropertyBeforeReady("zoom",e)||void 0===e||this.setStateCamera(this._zoomToCamera(e),{applyConstraints:!0})||a.getLogger(this).error("#zoom=","Invalid zoom",e)}_computeCanvasSize(){if(this._devicePixelRatioOverride)return this.view.state.contentPixelRatio=this._devicePixelRatioOverride,this._tmpCanvasSize.width=Math.round(this.view.surface.clientWidth*this._devicePixelRatioOverride),this._tmpCanvasSize.height=Math.round(this.view.surface.clientHeight*this._devicePixelRatioOverride),this._tmpCanvasSize.pixelRatio=this._devicePixelRatioOverride,this._tmpCanvasSize;const e=Math.min(this._windowDevicePixelRatio,this.view.qualitySettings.maximumPixelRatio),t=(this._usePhysicalPixelRendering?this._windowDevicePixelRatio:e)*this.view.resolutionScale;this._tmpCanvasSize.width=Math.round(this.view.surface.clientWidth*t),this._tmpCanvasSize.height=Math.round(this.view.surface.clientHeight*t);const i=this.view._stage.renderView.renderingContext?.parameters.maxTextureSize;return i&&Q(this._tmpCanvasSize,i),this._tmpCanvasSize.pixelRatio=this._tmpCanvasSize.width>0?this._tmpCanvasSize.width/this.view.surface.clientWidth*.5+this._tmpCanvasSize.height/this.view.surface.clientHeight*.5:t,this.view.state&&(this.view.state.contentPixelRatio=Math.min(this._windowDevicePixelRatio,this.view.qualitySettings.maximumPixelRatio)),this._tmpCanvasSize}get _rasterPixelRatio(){return null!=this._devicePixelRatioOverride?this._devicePixelRatioOverride:this._usePhysicalPixelRenderingAny?this._windowDevicePixelRatio:Math.min(this._windowDevicePixelRatio,this.view.qualitySettings.maximumPixelRatio)}get _usePhysicalPixelRendering(){return this.view?._stage?.renderer.isFeatureEnabled(W.PhysicalPixelRendering)??!1}get _usePhysicalPixelRenderingAny(){const e=this.view?._stage?.renderer;return e&&(e.isFeatureEnabled(W.PhysicalPixelRendering,K.IDLE)||e.isFeatureEnabled(W.PhysicalPixelRendering,K.INTERACTING)||e.isFeatureEnabled(W.PhysicalPixelRendering,K.ANIMATING))}preinit(e){return!(this._isOverridden("center")&&!f(this.center.spatialReference,e))&&(!(this._isOverridden("camera")&&!f(this.camera.position.spatialReference,e))&&(!(this._isOverridden("extent")&&!f(this.extent.spatialReference,e))&&!!(!this._isOverridden("viewpoint")||f(this.viewpoint.targetGeometry?.spatialReference,e)&&f(this.viewpoint.camera?.position?.spatialReference,e))))}init(){this._constraintsManager=new O({view:this.view}),this._prepareFrame();const e=this._getInitialProperties();this._cameraSetByUser=!1,this._set("ready",!0);for(const t of e)this.set(t.name,t.value);if(!this._cameraSetByUser){const e=this._initialViewpoint||this.view.initialExtent;e&&this.isCompatible(e)?this._setInitialView(e):this.view.state.viewingMode===x.Local&&this.addHandles(l((()=>this.view.basemapTerrain.ready),(()=>{this.removeHandles(se),this._setInitialView(this.view.dataExtent)}),{once:!0,initial:!0}),se)}}exit(){this._cancelGoToOperation(),this.ready&&(this._override("padding",this.padding),this._set("ready",!1),this._clearOverride("hasInitialView"),this._cameraSetByUser=!1,this.removeHandles(se),this._constraintsManager=s(this._constraintsManager))}async goTo(e,t){return t={animate:!0,...t},null!=this._gotoOperation&&this._gotoOperation.abort(t.animate),this._gotoOperation=new b(e,t,this.view),this.view.resourceController.scheduler.stopFrame(),this._gotoOperation.promise}debugSetCameraOnContent(){this.setStateCamera(P(this.view),{applyConstraints:!1})}step(e){const t=this.view.state,i=t?.cameraController;i&&(t.updateCamera((t=>i.stepController(e,t))),i.steppingFinished&&i.finishController())}_cancelGoToOperation(){null!=this._gotoOperation&&(this._gotoOperation.abort(),this._gotoOperation=null)}_getInitialProperties(){const e=new Set,t=[];for(const{propertyName:i,overrides:r}of ee){const a=e.has(i),s=this._isOverridden(i);!a&&s&&t.push({name:i,value:this._get(i)}),this._clearOverride(i),(a||s)&&r.forEach((t=>e.add(t)))}return t}_setInitialView(e){if(null==e||this._cameraSetByUser)return;if(e instanceof t)return void this.setStateCamera(M(this.view,e),{applyConstraints:!1});if(e instanceof i){if(e.targetGeometry instanceof _){const t=H(this.view,e.targetGeometry,0,.5,V.LOCKED);return void(null!=t&&this.setStateCamera(M(this.view,t),{applyConstraints:!0}))}const t={applyConstraints:!e.camera},i=this._viewpointToCamera(e);return void this.setStateCamera(i,t)}const r=H(this.view,e,0,.5,V.LOCKED);null!=r&&this.setStateCamera(M(this.view,r),{applyConstraints:!0})}_updatePropertyBeforeReady(e,t){return!this.ready&&(this._override(e,t),t&&$.has(e)&&this._override("hasInitialView",!0),!0)}isCompatible(e){return null!=e&&(e instanceof i?e.camera?this.isCompatible(e.camera):this.isCompatible(e.targetGeometry):e instanceof t?this.isCompatible(e.position):e.spatialReference&&!C(e.spatialReference,this.view.spatialReference))}_getPreservingHeadingTilt(e=te){return this._cameraSetByUser?(e.heading=this.camera.heading,e.tilt=this.camera.tilt):(e.heading=0,e.tilt=.5),e}_centerPointAtDistanceToCamera(e,t,i=re){const{heading:r,tilt:a}=this._getPreservingHeadingTilt(),s=B(this.view,r,a,e,t,V.ADJUST);return null==s?null:(i.copyFrom(this.view.state.camera),i.eye=s.eye,i.center=s.center,i.up=s.up,i)}_centerToCamera(e){const t=this.view.pointsOfInterest.centerOnContent;t.runTask();const i=t.distance;return this._centerPointAtDistanceToCamera(e,i)}_extentToCamera(e){const{heading:t,tilt:i}=this._getPreservingHeadingTilt(),r=H(this.view,e,t,i,V.ADJUST,ie);return r?M(this.view,r):null}_scaleToCamera(e){if(null==e)return null;const t=this.view.pointsOfInterest.centerOnContent;t.runTask();const i=t.renderLocation,r=t.location.latitude,a=D(this.view,e,r);return this._centerPointAtDistanceToCamera(i,a)}_zoomToCamera(e){return this._scaleToCamera(G(this.view,e))}_viewpointToCamera(e){return M(this.view,U(this.view,e))}setStateCamera(e,t){return!(null==e||!this.view.state.stopActiveCameraController())&&(this._cameraSetByUser=!0,t.doNotCancelGoToOperation||this._cancelGoToOperation(),this.view.state.updateCamera((i=>{t.positionAndOrientationOnly?(i.eye=e.eye,i.center=e.center,i.up=e.up,i.fov=e.fov):i.copyFrom(e),t.applyConstraints&&R(this.view,i)})),t.applyConstraints||(this.view.state.cameraController=new j({view:this.view,desiredCamera:e})),!0)}_prepareFrame(){const{surface:e,canvas:t}=this.view;if(!e||!t)return;this._windowDevicePixelRatio=window.devicePixelRatio;const i=this._computeCanvasSize();if(0!==i.width&&0!==i.height&&(t.width===i.width&&t.height===i.height||(t.width=i.width,t.height=i.height),this.view.state)){const e=this.view.state.camera;e.fullWidth===i.width&&e.fullHeight===i.height&&e.pixelRatio===i.pixelRatio||(re.copyFrom(e),re.pixelRatio!==i.pixelRatio&&(this._paddingToArray(this.padding,i.pixelRatio,ae),re.padding=ae),re.fullWidth=i.width,re.fullHeight=i.height,re.pixelRatio=i.pixelRatio,this.view.state.camera=re),this._updateViewState()}}_updateElevation(e){const t=this.view.basemapTerrain?.spatialReference,i=this.view.renderCoordsHelper?.getAltitude(e.eye)??0,r=t?S(this.view,e.eye):0;e.relativeElevation=i-r}_updateViewState(){null!=this.test.renderState?this.view.state.mode=this.test.renderState:this.view.animation?this.view.state.mode=K.ANIMATING:this.view.interacting?this.view.state.mode=K.INTERACTING:(this.view.state.mode===K.ANIMATING&&(this._cameraChangeTime=0),performance.now()-this._cameraChangeTime<this._idleTimeout?this.view.state.mode=K.INTERACTING:this.view.state.mode=K.IDLE),this.view.state.rasterPixelRatio=this._rasterPixelRatio}_cameraChangedHandler(e,t){e&&t&&e.almostEquals(t)||(this._cameraChangeTime=performance.now(),this._updateViewState())}};e([m({type:t,dependsOn:["view.state.camera","ready"]})],Y.prototype,"camera",null),e([m({type:t,dependsOn:["view.state.contentCamera","ready"]})],Y.prototype,"contentCamera",null),e([m({type:y})],Y.prototype,"center",null),e([m()],Y.prototype,"visibleArea",null),e([m({type:_})],Y.prototype,"extent",null),e([m({readOnly:!0})],Y.prototype,"frustum",null),e([m()],Y.prototype,"_constraintsManager",void 0),e([m({readOnly:!0})],Y.prototype,"constraintsManager",null),e([m()],Y.prototype,"_initialViewpoint",null),e([m({readOnly:!0})],Y.prototype,"hasInitialView",null),e([m({readOnly:!0,type:Boolean})],Y.prototype,"ready",void 0),e([m({type:Number})],Y.prototype,"scale",null),e([m({type:Number})],Y.prototype,"terrainScale",null),e([m()],Y.prototype,"padding",null),e([m({readOnly:!0})],Y.prototype,"screenCenter",null),e([m({constructOnly:!0})],Y.prototype,"view",void 0),e([m({type:i})],Y.prototype,"viewpoint",null),e([m({type:Number})],Y.prototype,"zoom",null),e([m({readOnly:!0})],Y.prototype,"_rasterPixelRatio",null),e([m({readOnly:!0})],Y.prototype,"_usePhysicalPixelRendering",null),e([m({readOnly:!0})],Y.prototype,"_usePhysicalPixelRenderingAny",null),e([m()],Y.prototype,"_windowDevicePixelRatio",void 0),e([m()],Y.prototype,"_devicePixelRatioOverride",void 0),Y=e([d("esri.views.3d.state.ViewStateManager")],Y);class Z{constructor(){this.width=0,this.height=0,this.pixelRatio=1}}const $=new Set(["camera","viewpoint","extent","scale","center","zoom"]),ee=[{propertyName:"camera",overrides:["viewpoint"]},{propertyName:"viewpoint",overrides:["extent"]},{propertyName:"extent",overrides:["center","scale"]},{propertyName:"center",overrides:[]},{propertyName:"scale",overrides:["zoom"]},{propertyName:"zoom",overrides:[]},{propertyName:"padding",overrides:[]}],te={heading:0,tilt:0},ie=new t,re=new k,ae=g(),se="pending-initial-view",ne="content-camera-reset",oe=300,he=100;export{Y as ViewStateManager,he as interactingTimeout};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Camera.js";import"../../../geometry.js";import i from"../../../Viewpoint.js";import r from"../../../core/Accessor.js";import a from"../../../core/Logger.js";import{destroyMaybe as s}from"../../../core/maybe.js";import{on as n,watch as o,sync as h,when as l}from"../../../core/reactiveUtils.js";import{addFrameTask as p}from"../../../core/scheduling.js";import{createScreenPoint as c}from"../../../core/screenUtils.js";import{property as m}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as d}from"../../../core/accessorSupport/decorators/subclass.js";import{a as v}from"../../../chunks/vec32.js";import{fromArray as u}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{s as w}from"../../../chunks/vec42.js";import{create as g}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import _ from"../../../geometry/Extent.js";import y from"../../../geometry/Point.js";import{isLoadedOrLoadFor as f,requiresLoad as C}from"../../../geometry/projection.js";import{ViewingMode as x}from"../../ViewingMode.js";import{applyAll as R}from"../camera/constraintUtils.js";import{cameraOnContentAlongViewDirection as P,surfaceElevationBelowRenderLocation as S}from"../camera/intersectionUtils.js";import{ConstraintsManager as O}from"./ConstraintsManager.js";import{Frustum as T}from"./Frustum.js";import{GoToOperation as b}from"./GoToOperation.js";import{SurfaceCollisionCorrectionController as j}from"./controllers/SurfaceCollisionCorrectionController.js";import{internalToExternal as I,externalToInternal as M,toArea as z,toExtent as A,distanceToScale as E,directionToHeadingTilt as L,scaleToZoom as N,fromExtentSync as H,OrientationMode as V,getObserverForPointAtDistanceSync as B,scaleToDistance as D,zoomToScale as G}from"../support/cameraUtils.js";import{fromCamera as F,toCameraSync as U}from"../support/viewpointUtils.js";import k from"../webgl/RenderCamera.js";import{PaddingSide as q}from"../webgl-engine/lib/rendererUtils.js";import{RenderFeature as W}from"../webgl-engine/lib/RenderFeature.js";import{PropertiesPool as J}from"../../support/PropertiesPool.js";import{RenderState as K}from"../../support/RenderState.js";import{ensureAttachmentMaxSize as Q}from"../../webgl/FramebufferObject.js";import X from"../../../geometry/Polygon.js";let Y=class extends r{constructor(e){super(e),this.ready=!1,this._windowDevicePixelRatio=1,this._devicePixelRatioOverride=null,this._idleTimeout=oe,this.test={viewStateManager:this,contentCameraResetState:new Map,setDevicePixelRatio:e=>this._devicePixelRatioOverride=e,renderState:null,get maximumPixelRatio(){return this.viewStateManager.view.qualitySettings.maximumPixelRatio},get updatingIgnoreRenderState(){return null!=this.renderState},get idleTimeoutEnabled(){return this.viewStateManager._idleTimeout>0},set idleTimeoutEnabled(e){this.viewStateManager._idleTimeout=e?oe:0}},this._propertiesPool=new J({frustum:T},this),this._cameraSetByUser=!1,this._gotoOperation=null,this._cameraChangeTime=0,this._tmpCanvasSize=new Z}initialize(){this._cameraChangeTime=performance.now(),this.addHandles([n((()=>this.view.state.events),"before-camera-change",(e=>e&&this._updateElevation(e))),o((()=>this.view.state?.camera),((e,t)=>this._cameraChangedHandler(e,t)),h)]),l((()=>this.view.state?.camera),(e=>this._updateElevation(e)),{once:!0,sync:!0}),this.addHandles([p({prepare:()=>this._prepareFrame()}),o((()=>this.view.state.cameraController),(()=>{this._cameraSetByUser=!0,this.removeHandles(se)})),n((()=>this.view.state.events),"camera-projection-changed",(()=>this.notifyChange("scale")))])}destroy(){this.exit(),this._propertiesPool=s(this._propertiesPool)}get camera(){const e=this._get("camera");if(!this.ready)return e;const t=I(this.view,this.view.state.camera,ie);return t&&e&&t.equals(e)?e:t.clone()}set camera(e){this._updatePropertyBeforeReady("camera",e)||(this.view.elevationProvider?.enableCache(!0),this.setStateCamera(M(this.view,e),{applyConstraints:!1})||a.getLogger(this).error("#camera=","Invalid camera",e),this.view.elevationProvider?.enableCache(!1))}get contentCamera(){const e=this._get("contentCamera");if(!this.ready)return e;const t=I(this.view,this.view.state.contentCamera,ie);return t&&e&&t.equals(e)?e:t.clone()}set contentCamera(e){if(this._updatePropertyBeforeReady("contentCamera",e))return;const t=M(this.view,e);null!=t?(this._updateElevation(t),this.view.state.contentCamera=t):this.view.state.contentCamera=null}installContentCameraReset(e){if(this.removeHandles(ne),this.test.contentCameraResetState.clear(),!this.view.state.fixedContentCamera)return!1;const t=this.zoom,i=this.view.state.camera.distance**2,r=u(this.view.state.camera.center),a=e.sticky?this.contentCamera.clone():null;return this.addHandles([o((()=>this.contentCamera),(()=>{e.sticky||(this.removeHandles(ne),this.test.contentCameraResetState.clear())})),o((()=>this.zoom),(e=>{void 0!==e&&void 0!==t&&(this.test.contentCameraResetState.set("view.zoom",Math.abs(e-t)/2),Math.abs(e-t)>2?this.contentCamera=null:this.view.state.fixedContentCamera||(this.contentCamera=a))})),o((()=>this.view.state.camera),(e=>{const t=v(r,e.center);this.test.contentCameraResetState.set("camera.center",t/i),t>i?this.contentCamera=null:this.view.state.fixedContentCamera||(this.contentCamera=a)}))],ne),!0}get center(){return this.ready?this.view.pointsOfInterest.centerOnContent.location:this._get("center")}set center(e){this._updatePropertyBeforeReady("center",e)||(e?this.isCompatible(e)?this.setStateCamera(this._centerToCamera(e),{applyConstraints:!0})?this.view.pointsOfInterest.centerOnContent.runTask():a.getLogger(this).error("#center=","Invalid center",e):a.getLogger(this).error("#center=","Center has an incompatible spatial reference (center: "+(e.spatialReference?e.spatialReference.wkid:"none")+", view: "+this.view.spatialReference?.wkid+")",e):a.getLogger(this).error("#center=","Center may not be null or undefined"))}get visibleArea(){if(!this.ready){const e=this._get("extent");return e?X.fromExtent(e):null}return z(this.view,this.view.pointsOfInterest.focus.renderLocation)}get extent(){if(!this.ready)return this._get("extent");const e=this.view,t=A(e,e.state.camera,e.pointsOfInterest.centerOnContent.renderLocation);return null!=t?t:this._get("extent")}set extent(e){this._updatePropertyBeforeReady("extent",e)||(e?this.isCompatible(e)?this.setStateCamera(this._extentToCamera(e),{applyConstraints:!0})||a.getLogger(this).error("#extent=","Invalid extent",e):a.getLogger(this).error("#extent=","Extent has an incompatible spatial reference (extent: "+(e.spatialReference?e.spatialReference.wkid:"none")+", view: "+this.view.spatialReference?.wkid+")",e):a.getLogger(this).error("#extent=","Extent may not be null or undefined"))}get frustum(){const e=this._propertiesPool.get("frustum");return e.renderCoordsHelper=this.view.renderCoordsHelper,e.update(this.view.state.camera),e}get constraintsManager(){return this._constraintsManager}get _initialViewpoint(){const e=this.view.map;return e&&"initialViewProperties"in e?e.initialViewProperties?.viewpoint:void 0}get hasInitialView(){return!!this._initialViewpoint}get scale(){if(this.ready){const e=this.view.pointsOfInterest.centerOnContent.distance;return E(this.view,e)}return this._get("scale")}set scale(e){this._updatePropertyBeforeReady("scale",e)||this.setStateCamera(this._scaleToCamera(e),{applyConstraints:!0})||a.getLogger(this).error("#scale=","Invalid scale",e)}get terrainScale(){if(!this.ready)return this._get("scale");const e=this.view,t=e.basemapTerrain.tilingScheme,i=e.pointsOfInterest.cameraOnSurface.scale;if(!t||!i)return this._get("scale");const r=e.state.contentCamera;let a=L(e,r.eye,r.viewForward,r.up).tilt;a>90&&(a=180-a);const s=2*(a/90)**2,n=t.levelAtScale(i)-s;return n<0?this._get("scale"):t.scaleAtLevel(n)}get padding(){if(!this.ready)return this._get("padding");const e=this.view.state.camera,t=e.padding,i=e.pixelRatio,r=this._get("padding"),a=Math.round(t[q.TOP]/i),s=Math.round(t[q.RIGHT]/i),n=Math.round(t[q.BOTTOM]/i),o=Math.round(t[q.LEFT]/i);return null!=r&&r.top===a&&r.right===s&&r.bottom===n&&r.left===o?r:{top:a,right:s,bottom:n,left:o}}set padding(e){this._updatePropertyBeforeReady("padding",e)||(this._paddingToArray(e,this.view.state.camera.pixelRatio,ae),this.view.state.updateCamera((e=>e.padding=ae)))}_paddingToArray(e,t,i){e?w(i,e.top||0,e.right||0,e.bottom||0,e.left||0):w(i,0,0,0,0);for(let r=0;r<4;r++)i[r]=Math.round(i[r]*t)}get screenCenter(){const e=this.padding;return c((this.view.width-(e.left+e.right))/2+e.left,(this.view.height-(e.top+e.bottom))/2+e.top)}get viewpoint(){return this.ready?F(this.view,this.camera):this._get("viewpoint")}set viewpoint(e){if(!this._updatePropertyBeforeReady("viewpoint",e))if(e)if(this.isCompatible(e))this.setStateCamera(this._viewpointToCamera(e),{applyConstraints:!e.camera})||a.getLogger(this).error("#viewpoint=","Invalid viewpoint",e);else{const t=null!=e.camera?e.camera.position:e.targetGeometry,i=null!=t&&t.spatialReference;a.getLogger(this).error("#viewpoint=","Viewpoint has an incompatible spatial reference (viewpoint: "+(i?i.wkid:"none")+", view: "+this.view.spatialReference?.wkid+")",e)}else a.getLogger(this).error("#viewpoint=","Viewpoint may not be null or undefined")}get zoom(){return this.ready?N(this.view,this.scale):this._get("zoom")}set zoom(e){this._updatePropertyBeforeReady("zoom",e)||void 0===e||this.setStateCamera(this._zoomToCamera(e),{applyConstraints:!0})||a.getLogger(this).error("#zoom=","Invalid zoom",e)}_computeCanvasSize(){if(this._devicePixelRatioOverride)return this.view.state.contentPixelRatio=this._devicePixelRatioOverride,this._tmpCanvasSize.width=Math.round(this.view.surface.clientWidth*this._devicePixelRatioOverride),this._tmpCanvasSize.height=Math.round(this.view.surface.clientHeight*this._devicePixelRatioOverride),this._tmpCanvasSize.pixelRatio=this._devicePixelRatioOverride,this._tmpCanvasSize;const e=Math.min(this._windowDevicePixelRatio,this.view.qualitySettings.maximumPixelRatio),t=(this._usePhysicalPixelRendering?this._windowDevicePixelRatio:e)*this.view.resolutionScale;this._tmpCanvasSize.width=Math.round(this.view.surface.clientWidth*t),this._tmpCanvasSize.height=Math.round(this.view.surface.clientHeight*t);const i=this.view._stage.renderView.renderingContext?.parameters.maxTextureSize;return i&&Q(this._tmpCanvasSize,i),this._tmpCanvasSize.pixelRatio=this._tmpCanvasSize.width>0?this._tmpCanvasSize.width/this.view.surface.clientWidth*.5+this._tmpCanvasSize.height/this.view.surface.clientHeight*.5:t,this.view.state&&(this.view.state.contentPixelRatio=Math.min(this._windowDevicePixelRatio,this.view.qualitySettings.maximumPixelRatio)),this._tmpCanvasSize}get _rasterPixelRatio(){return null!=this._devicePixelRatioOverride?this._devicePixelRatioOverride:this._usePhysicalPixelRenderingAny?this._windowDevicePixelRatio:Math.min(this._windowDevicePixelRatio,this.view.qualitySettings.maximumPixelRatio)}get _usePhysicalPixelRendering(){return this.view?._stage?.renderer.isFeatureEnabled(W.PhysicalPixelRendering)??!1}get _usePhysicalPixelRenderingAny(){const e=this.view?._stage?.renderer;return e&&(e.isFeatureEnabled(W.PhysicalPixelRendering,K.IDLE)||e.isFeatureEnabled(W.PhysicalPixelRendering,K.INTERACTING)||e.isFeatureEnabled(W.PhysicalPixelRendering,K.ANIMATING))}preinit(e){return!(this._isOverridden("center")&&!f(this.center.spatialReference,e))&&(!(this._isOverridden("camera")&&!f(this.camera.position.spatialReference,e))&&(!(this._isOverridden("extent")&&!f(this.extent.spatialReference,e))&&!!(!this._isOverridden("viewpoint")||f(this.viewpoint.targetGeometry?.spatialReference,e)&&f(this.viewpoint.camera?.position?.spatialReference,e))))}init(){this._constraintsManager=new O({view:this.view}),this._prepareFrame();const e=this._getInitialProperties();this._cameraSetByUser=!1,this._set("ready",!0);for(const t of e)this.set(t.name,t.value);if(!this._cameraSetByUser){const e=this._initialViewpoint||this.view.initialExtent;e&&this.isCompatible(e)?this._setInitialView(e):this.view.state.viewingMode===x.Local&&this.addHandles(l((()=>this.view.basemapTerrain.ready),(()=>{this.removeHandles(se),this._setInitialView(this.view.dataExtent)}),{once:!0,initial:!0}),se)}}exit(){this._cancelGoToOperation(),this.ready&&(this._override("padding",this.padding),this._set("ready",!1),this._clearOverride("hasInitialView"),this._cameraSetByUser=!1,this.removeHandles(se),this._constraintsManager=s(this._constraintsManager))}async goTo(e,t){return t={animate:!0,...t},null!=this._gotoOperation&&this._gotoOperation.abort(t.animate),this._gotoOperation=new b(e,t,this.view),this.view.resourceController.scheduler.stopFrame(),this._gotoOperation.promise}debugSetCameraOnContent(){this.setStateCamera(P(this.view),{applyConstraints:!1})}step(e){const t=this.view.state,i=t?.cameraController;i&&(t.updateCamera((t=>i.stepController(e,t))),i.steppingFinished&&i.finishController())}_cancelGoToOperation(){null!=this._gotoOperation&&(this._gotoOperation.abort(),this._gotoOperation=null)}_getInitialProperties(){const e=new Set,t=[];for(const{propertyName:i,overrides:r}of ee){const a=e.has(i),s=this._isOverridden(i);!a&&s&&t.push({name:i,value:this._get(i)}),this._clearOverride(i),(a||s)&&r.forEach((t=>e.add(t)))}return t}_setInitialView(e){if(null==e||this._cameraSetByUser)return;if(e instanceof t)return void this.setStateCamera(M(this.view,e),{applyConstraints:!1});if(e instanceof i){if(e.targetGeometry instanceof _){const t=H(this.view,e.targetGeometry,0,.5,V.LOCKED);return void(null!=t&&this.setStateCamera(M(this.view,t),{applyConstraints:!0}))}const t={applyConstraints:!e.camera},i=this._viewpointToCamera(e);return void this.setStateCamera(i,t)}const r=H(this.view,e,0,.5,V.LOCKED);null!=r&&this.setStateCamera(M(this.view,r),{applyConstraints:!0})}_updatePropertyBeforeReady(e,t){return!this.ready&&(this._override(e,t),t&&$.has(e)&&this._override("hasInitialView",!0),!0)}isCompatible(e){return null!=e&&(e instanceof i?e.camera?this.isCompatible(e.camera):this.isCompatible(e.targetGeometry):e instanceof t?this.isCompatible(e.position):e.spatialReference&&!C(e.spatialReference,this.view.spatialReference))}_getPreservingHeadingTilt(e=te){return this._cameraSetByUser?(e.heading=this.camera.heading,e.tilt=this.camera.tilt):(e.heading=0,e.tilt=.5),e}_centerPointAtDistanceToCamera(e,t,i=re){const{heading:r,tilt:a}=this._getPreservingHeadingTilt(),s=B(this.view,r,a,e,t,V.ADJUST);return null==s?null:(i.copyFrom(this.view.state.camera),i.eye=s.eye,i.center=s.center,i.up=s.up,i)}_centerToCamera(e){const t=this.view.pointsOfInterest.centerOnContent;t.runTask();const i=t.distance;return this._centerPointAtDistanceToCamera(e,i)}_extentToCamera(e){const{heading:t,tilt:i}=this._getPreservingHeadingTilt(),r=H(this.view,e,t,i,V.ADJUST,ie);return r?M(this.view,r):null}_scaleToCamera(e){if(null==e)return null;const t=this.view.pointsOfInterest.centerOnContent;t.runTask();const i=t.renderLocation,r=D(this.view,e);return this._centerPointAtDistanceToCamera(i,r)}_zoomToCamera(e){return this._scaleToCamera(G(this.view,e))}_viewpointToCamera(e){return M(this.view,U(this.view,e))}setStateCamera(e,t){return!(null==e||!this.view.state.stopActiveCameraController())&&(this._cameraSetByUser=!0,t.doNotCancelGoToOperation||this._cancelGoToOperation(),this.view.state.updateCamera((i=>{t.positionAndOrientationOnly?(i.eye=e.eye,i.center=e.center,i.up=e.up,i.fov=e.fov):i.copyFrom(e),t.applyConstraints&&R(this.view,i)})),t.applyConstraints||(this.view.state.cameraController=new j({view:this.view,desiredCamera:e})),!0)}_prepareFrame(){const{surface:e,canvas:t}=this.view;if(!e||!t)return;this._windowDevicePixelRatio=window.devicePixelRatio;const i=this._computeCanvasSize();if(0!==i.width&&0!==i.height&&(t.width===i.width&&t.height===i.height||(t.width=i.width,t.height=i.height),this.view.state)){const e=this.view.state.camera;e.fullWidth===i.width&&e.fullHeight===i.height&&e.pixelRatio===i.pixelRatio||(re.copyFrom(e),re.pixelRatio!==i.pixelRatio&&(this._paddingToArray(this.padding,i.pixelRatio,ae),re.padding=ae),re.fullWidth=i.width,re.fullHeight=i.height,re.pixelRatio=i.pixelRatio,this.view.state.camera=re),this._updateViewState()}}_updateElevation(e){const t=this.view.basemapTerrain?.spatialReference,i=this.view.renderCoordsHelper?.getAltitude(e.eye)??0,r=t?S(this.view,e.eye):0;e.relativeElevation=i-r}_updateViewState(){null!=this.test.renderState?this.view.state.mode=this.test.renderState:this.view.animation?this.view.state.mode=K.ANIMATING:this.view.interacting?this.view.state.mode=K.INTERACTING:(this.view.state.mode===K.ANIMATING&&(this._cameraChangeTime=0),performance.now()-this._cameraChangeTime<this._idleTimeout?this.view.state.mode=K.INTERACTING:this.view.state.mode=K.IDLE),this.view.state.rasterPixelRatio=this._rasterPixelRatio}_cameraChangedHandler(e,t){e&&t&&e.almostEquals(t)||(this._cameraChangeTime=performance.now(),this._updateViewState())}};e([m({type:t,dependsOn:["view.state.camera","ready"]})],Y.prototype,"camera",null),e([m({type:t,dependsOn:["view.state.contentCamera","ready"]})],Y.prototype,"contentCamera",null),e([m({type:y})],Y.prototype,"center",null),e([m()],Y.prototype,"visibleArea",null),e([m({type:_})],Y.prototype,"extent",null),e([m({readOnly:!0})],Y.prototype,"frustum",null),e([m()],Y.prototype,"_constraintsManager",void 0),e([m({readOnly:!0})],Y.prototype,"constraintsManager",null),e([m()],Y.prototype,"_initialViewpoint",null),e([m({readOnly:!0})],Y.prototype,"hasInitialView",null),e([m({readOnly:!0,type:Boolean})],Y.prototype,"ready",void 0),e([m({type:Number})],Y.prototype,"scale",null),e([m({type:Number})],Y.prototype,"terrainScale",null),e([m()],Y.prototype,"padding",null),e([m({readOnly:!0})],Y.prototype,"screenCenter",null),e([m({constructOnly:!0})],Y.prototype,"view",void 0),e([m({type:i})],Y.prototype,"viewpoint",null),e([m({type:Number})],Y.prototype,"zoom",null),e([m({readOnly:!0})],Y.prototype,"_rasterPixelRatio",null),e([m({readOnly:!0})],Y.prototype,"_usePhysicalPixelRendering",null),e([m({readOnly:!0})],Y.prototype,"_usePhysicalPixelRenderingAny",null),e([m()],Y.prototype,"_windowDevicePixelRatio",void 0),e([m()],Y.prototype,"_devicePixelRatioOverride",void 0),Y=e([d("esri.views.3d.state.ViewStateManager")],Y);class Z{constructor(){this.width=0,this.height=0,this.pixelRatio=1}}const $=new Set(["camera","viewpoint","extent","scale","center","zoom"]),ee=[{propertyName:"camera",overrides:["viewpoint"]},{propertyName:"viewpoint",overrides:["extent"]},{propertyName:"extent",overrides:["center","scale"]},{propertyName:"center",overrides:[]},{propertyName:"scale",overrides:["zoom"]},{propertyName:"zoom",overrides:[]},{propertyName:"padding",overrides:[]}],te={heading:0,tilt:0},ie=new t,re=new k,ae=g(),se="pending-initial-view",ne="content-camera-reset",oe=300,he=100;export{Y as ViewStateManager,he as interactingTimeout};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../Camera.js";import{Cyclical as t}from"../../../core/Cyclical.js";import n from"../../../core/Logger.js";import{deg2rad as r,rad2deg as o}from"../../../core/mathUtils.js";import{throwIfAborted as i}from"../../../core/promiseUtils.js";import{j as a,g as c,F as l,c as s,p as u}from"../../../chunks/vec32.js";import{clone as f,create as m}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as p}from"../../../geometry/ellipsoidUtils.js";import d from"../../../geometry/Point.js";import{projectWithZConversion as h,project as y}from"../../../geometry/projection.js";import g from"../../../geometry/SpatialReference.js";import{projectPointToVector as v,projectPointToVectorAsync as w}from"../../../geometry/projection/projectPointToVector.js";import{projectVectorToPoint as R,projectVectorToPointAsync as x}from"../../../geometry/projection/projectVectorToPoint.js";import{projectVectorToVector as j}from"../../../geometry/projection/projectVectorToVector.js";import{getGCSForPlanet as T}from"../../../geometry/support/planetGCSUtils.js";import{ViewingMode as S}from"../../ViewingMode.js";import{cameraOnContentAlongViewDirection as M}from"../camera/intersectionUtils.js";import{c as C}from"../../../chunks/cameraUtilsPlanar.js";import{c as z}from"../../../chunks/cameraUtilsSpherical.js";import{getGreatCircleSpanAt as U}from"./earthUtils.js";import{getElevationAtPoint as b}from"./ElevationProvider.js";import{isSpatialReferenceSupported as P}from"../../support/spatialReferenceSupport.js";const A=()=>n.getLogger("esri.views.3d.support.cameraUtils"),D=39.37,G=96,L=G*D,H=1,E=8,O=5,q=1,I=m(),k={heading:0,tilt:0},F=m(),J=new t(-20037508.342788905,20037508.342788905),V=new t(-180,180);var X;function K(e){return e.spatialReference??g.WGS84}function W({state:e}){return e.isGlobal?z:C}function Y(e,t,n,r,o){return W(e).headingTiltToDirectionUp(t,n,r,o)}function N(e,t){if(null==t)return null;const n=e.renderSpatialReference,o=W(e).headingTiltToDirectionUp,i=m();if(!v(t.position,i,n))return null;const l=o(i,t.heading,t.tilt);a(l.direction,l.direction,e.state.camera.distance),c(l.direction,l.direction,i);const s=M(e,i,l.direction,l.up);return s.fov=r(t.fov),s.row=t.layout.row,s.rows=t.layout.rows,s.column=t.layout.column,s.columns=t.layout.columns,s}!function(e){e[e.LOCKED=0]="LOCKED",e[e.ADJUST=1]="ADJUST"}(X||(X={}));const Z=m();function B(t,n,r){const i=t.renderSpatialReference,a=ne(t,n.eye,n.viewForward,n.up,k);let c=K(t);return j(n.eye,i,Z,c)||(c=g.WGS84,j(n.eye,i,Z,c)),null==r?r=new e(new d(Z,c),a.heading,a.tilt,o(n.fov)):(r.position.x=Z[0],r.position.y=Z[1],r.position.z=Z[2],r.position.spatialReference=c,r.heading=a.heading,r.tilt=a.tilt,r.fov=o(n.fov)),r.layout.row=n.row,r.layout.rows=n.rows,r.layout.column=n.column,r.layout.columns=n.columns,r}function Q(e,t,n){const o=e.state.camera,i=o.width/2/o.pixelRatio;e.renderCoordsHelper.viewingMode===S.Global&&null!=n&&(t*=Math.cos(r(n))),t/=e.renderCoordsHelper.unitInMeters;return i/(G*D/t)/Math.tan(o.fovX/2)}function $(e,t,n){const{camera:o}=e.state,{viewingMode:i,unitInMeters:a}=e.renderCoordsHelper,c=t*Math.tan(o.fovX/2),l=o.width/2/o.pixelRatio;let s=L/(l/c);return i===S.Global&&null!=n&&(s/=Math.cos(r(n))),s*a}async function _(e,t,n,r,o,i){return te(e,t,Q(e,n,t.latitude),r,o,i)}function ee(e,t,n,r,o,i){return Ue(e,ce(e,r.heading,r.tilt,t,n,o),r.fov,i)}async function te(e,t,n,r,o,a){const c=await le(e,r.heading,r.tilt,t,n,o,a);return i(a),be(e,c,r.fov,a)}function ne(e,t,n,r,o){return W(e).directionToHeadingTilt(t,n,r,o)}function re(e,t){return!!(e.basemapTerrain&&e.renderCoordsHelper.fromRenderCoords(t,F,e.spatialReference)&&e.elevationProvider&&(b(e.elevationProvider,F)??0)>F[2]-q)}async function oe(e,t,n){if(re(e,t))return!0;const{elevationProvider:r,spatialReference:o,renderCoordsHelper:a}=e;if(null==r||!a.fromRenderCoords(t,F,o))return!1;const[c,l,s]=F,u=await r.queryElevation(c,l,s,o,"ground",n)??0;return i(n),u>s-q}async function ie(e,t,n){const r=m();if(null==t)return s(r,e.state.camera.center);if(t instanceof d){const{renderSpatialReference:o,basemapTerrain:a,elevationProvider:c}=e,l=t.spatialReference;if(await w(t,r,o,0,{signal:n}),i(n),null==t.z&&null!=a&&null!=c){const o=await c.queryElevation(t.x,t.y,t.z??0,l,"ground",n);i(n),null!=o&&e.renderCoordsHelper.setAltitude(r,o)}return r}return s(r,t)}function ae(e,t){const n=m();if(null==t)return s(n,e.state.camera.center);if(t instanceof d){if(!v(t,n,e.renderSpatialReference))return null;const{basemapTerrain:r,elevationProvider:o}=e;if(null==t.z&&null!=r&&null!=o){const r=b(o,t);null!=r&&e.renderCoordsHelper.setAltitude(n,r)}return n}return s(n,t)}function ce(e,t,n,r,o,i){return se(e,t,n,r instanceof d?r:null,ae(e,r),o,i)}async function le(e,t,n,r,o,a,c){const l=r instanceof d?r:null,s=await ie(e,r,c);return i(c),ue(e,t,n,l,s,o,a,c)}function se(e,t,n,r,o,i,a){if(null==o)return null;if(!r&&(r=new d({spatialReference:K(e)}),!R(o,e.renderSpatialReference,r)))return null;const c=fe(e,t,n,o,i,a);if(me(e,n,a)&&re(e,c.eye)){const{tilt:a,mode:c}=pe(e,n,o,i);return se(e,t,a,r,o,i,c)}return de(c,o)}async function ue(e,t,n,r,o,a,c,l){r||(r=new d({spatialReference:K(e)}),await x(o,e.renderSpatialReference,r,{signal:l})||(r=null)),i(l);const s=fe(e,t,n,o,a,c);if(me(e,n,c)&&await oe(e,s.eye,l)){i(l);const{tilt:c,mode:s}=pe(e,n,o,a);return ue(e,t,c,r,o,a,s,l)}return de(s,o)}function fe(e,t,n,r,o,i){const a=je(e,t,n,r,o=Math.max(o,e.state.constraints.minimumPoiDistance),i);return(0,W(e).eyeForCenterWithHeadingTilt)(r,o,a.heading,a.tilt)}function me(e,t,n){const r=e.map.ground.navigationConstraint;return n===X.ADJUST&&e.state.isGlobal&&t>0&&(null==r||"stay-above"===r.type)}function pe(e,t,n,r){const o=Ce(e,n,r,Me(e,r,t,n));return{tilt:o,mode:t-o<1?X.LOCKED:X.ADJUST}}function de(e,t){return{...e,center:f(t)}}function he(e,t){const{state:n,spatialReference:r}=e,o=t.spatialReference;return n.isGlobal&&P(o,S.Global)||n.isLocal&&r.equals(o)}function ye(e,t){let n,r,o;if(e.state.isGlobal){const e=new d(t.xmin,t.ymin,t.spatialReference),i=new d(t.xmax,t.ymax,t.spatialReference),a=t.spatialReference.isGeographic?V:J;n=new d({x:a.center(e.x,i.x),y:(i.y+e.y)/2,z:null!=t.zmax&&null!=t.zmin?(t.zmax+t.zmin)/2:void 0,spatialReference:t.spatialReference});const c=p(t.spatialReference),l=U(n,e,i);r=l.lon,o=l.lat,a.diff(e.x,i.x)>a.range/2&&(r+=c.halfCircumference),r=Math.min(r,c.halfCircumference),o=Math.min(o,c.halfCircumference)}else{const i=e.renderSpatialReference??t.spatialReference;i.equals(t.spatialReference)||(t=y(t,i)),r=t.xmax-t.xmin,o=t.ymax-t.ymin;const a=null!=t.zmax&&null!=t.zmin?(t.zmax+t.zmin)/2:void 0;n=new d({x:t.xmin+.5*r,y:t.ymin+.5*o,z:a,spatialReference:i})}const i=null!=t.zmax&&null!=t.zmin?t.zmax-t.zmin:0,a=e.state.camera,c=1/Math.tan(a.fovX/2),l=1/Math.tan(a.fovY/2),s=1/Math.tan(a.fov/2);return{center:n,distance:Math.max(.5*r*c,.5*o*l,.5*i*s)/H}}async function ge(e,t,n,r,o,a){const c=he(e,t)?t:await h(t,e.spatialReference,{signal:a});i(a);const{center:l,distance:s}=ye(e,c),u=await le(e,n,r,l,s,o,a);return i(a),be(e,u,e.camera.fov,a)}function ve(e,t,n,r,o,i){let a;try{a=he(e,t)?t:y(t,e.spatialReference)}catch(u){return null}const{center:c,distance:l}=ye(e,a),s=ce(e,n,r,c,l,o);return null==s?null:Ue(e,s,e.camera.fov,i)}function we(e,t,n){const r=e.renderSpatialReference,o=new d({spatialReference:K(e)});if(!R(n,r,o))return null;const i=Math.tan(t.fovX/2),a=Math.tan(t.fovY/2),c=l(t.eye,n),s=2*c*i*H,u=2*c*a*H;return W(e).toExtent(e,o,s,u)}function Re(e,t){return W(e).toArea(e,t)}function xe(e,t,n){const r=e.pointsOfInterest.centerOnSurfaceFrequent.distance;if(Math.log(n/r)/Math.LN2>E)return!0;const o=t,i=e.pointsOfInterest.centerOnSurfaceFrequent.renderLocation;return u(o,i)/(Math.tan(.5*e.state.camera.fov)*r)>O}function je(e,t,n,r,o,i){let a=0;return i===X.ADJUST&&xe(e,r,o)?(t=0,a=Se(e,o,n,r)):a=ze(e,r,o,n),a=e.state.constraints.clampTilt(o,a),{heading:t,tilt:n=Ce(e,r,o,a)}}const Te=.7;function Se(e,t,n,r){const o=ze(e,r,t,n);if(!e.state.constraints.tilt)return o;const i=e.state.constraints.tilt(t);i.max=Math.min(i.max,.5*Math.PI);const a=i.min*(1-Te)+i.max*Te;return Math.min(o,a)}function Me(e,t,n,r){let o=ze(e,r,t,n);if(!e.state.constraints.tilt)return o;const i=e.state.constraints.tilt(t);return o=Math.min(o,.5*Math.PI),i.min*(1-Te)+o*Te}function Ce(e,t,n,r){return W(e).lookAtTiltToEyeTilt(r,t,n)}function ze(e,t,n,r){return W(e).eyeTiltToLookAtTilt(r,t,n)}function Ue(t,n,r,o){if(null==n)return null;const i=t.renderSpatialReference,a=new d({spatialReference:K(t)});return R(n.eye,i,a)?(o??=new e,o.position=a,o.heading=n.heading,o.tilt=n.tilt,o.fov=r,o):null}async function be(t,n,r,o){const a=t.renderSpatialReference,c=new d({spatialReference:K(t)});return await x(n.eye,a,c,{signal:o}),i(o),new e(c,n.heading,n.tilt,r)}function Pe(e,t){const n=e.basemapTerrain?.tilingScheme;if(n)return n.levelAtScale(t);A().error("#scaleToZoom()","Cannot compute zoom from scale without a tiling scheme")}function Ae(e,t){const n=e.basemapTerrain?.tilingScheme;if(n)return n.scaleAtLevel(t);A().error("#zoomToScale()","Cannot compute scale from zoom without a tiling scheme")}function De(e,t){const{renderSpatialReference:n}=e,r=T(n);let o=null;try{j(t.center,n,I,r)&&(o=I[1])}catch{}return $(e,t.distance,o)}export{X as OrientationMode,De as computeScale,ne as directionToHeadingTilt,$ as distanceToScale,N as externalToInternal,te as fromCenterDistanceAsync,ee as fromCenterDistanceSync,_ as fromCenterScale,ge as fromExtentAsync,ve as fromExtentSync,le as getObserverForPointAtDistanceAsync,ce as getObserverForPointAtDistanceSync,K as getViewSR,Y as headingTiltToDirectionUp,B as internalToExternal,Q as scaleToDistance,Pe as scaleToZoom,Re as toArea,we as toExtent,Ae as zoomToScale};
5
+ import e from"../../../Camera.js";import{Cyclical as t}from"../../../core/Cyclical.js";import n from"../../../core/Logger.js";import{deg2rad as r,rad2deg as o}from"../../../core/mathUtils.js";import{throwIfAborted as i}from"../../../core/promiseUtils.js";import{j as a,g as c,F as l,c as s,p as u}from"../../../chunks/vec32.js";import{clone as f,create as m}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as p}from"../../../geometry/ellipsoidUtils.js";import d from"../../../geometry/Point.js";import{projectWithZConversion as h,project as y}from"../../../geometry/projection.js";import g from"../../../geometry/SpatialReference.js";import{projectPointToVector as v,projectPointToVectorAsync as w}from"../../../geometry/projection/projectPointToVector.js";import{projectVectorToPoint as R,projectVectorToPointAsync as x}from"../../../geometry/projection/projectVectorToPoint.js";import{projectVectorToVector as j}from"../../../geometry/projection/projectVectorToVector.js";import{ViewingMode as T}from"../../ViewingMode.js";import{cameraOnContentAlongViewDirection as S}from"../camera/intersectionUtils.js";import{c as M}from"../../../chunks/cameraUtilsPlanar.js";import{c as z}from"../../../chunks/cameraUtilsSpherical.js";import{getGreatCircleSpanAt as C}from"./earthUtils.js";import{getElevationAtPoint as U}from"./ElevationProvider.js";import{isSpatialReferenceSupported as P}from"../../support/spatialReferenceSupport.js";const b=()=>n.getLogger("esri.views.3d.support.cameraUtils"),A=39.37,D=96,L=D*A,E=1,G=8,H=5,O=1,q={heading:0,tilt:0},I=m(),k=new t(-20037508.342788905,20037508.342788905),F=new t(-180,180);var J;function V(e){return e.spatialReference??g.WGS84}function X({state:e}){return e.isGlobal?z:M}function K(e,t,n,r,o){return X(e).headingTiltToDirectionUp(t,n,r,o)}function W(e,t){if(null==t)return null;const n=e.renderSpatialReference,o=X(e).headingTiltToDirectionUp,i=m();if(!v(t.position,i,n))return null;const l=o(i,t.heading,t.tilt);a(l.direction,l.direction,e.state.camera.distance),c(l.direction,l.direction,i);const s=S(e,i,l.direction,l.up);return s.fov=r(t.fov),s.row=t.layout.row,s.rows=t.layout.rows,s.column=t.layout.column,s.columns=t.layout.columns,s}!function(e){e[e.LOCKED=0]="LOCKED",e[e.ADJUST=1]="ADJUST"}(J||(J={}));const Y=m();function N(t,n,r){const i=t.renderSpatialReference,a=ee(t,n.eye,n.viewForward,n.up,q);let c=V(t);return j(n.eye,i,Y,c)||(c=g.WGS84,j(n.eye,i,Y,c)),null==r?r=new e(new d(Y,c),a.heading,a.tilt,o(n.fov)):(r.position.x=Y[0],r.position.y=Y[1],r.position.z=Y[2],r.position.spatialReference=c,r.heading=a.heading,r.tilt=a.tilt,r.fov=o(n.fov)),r.layout.row=n.row,r.layout.rows=n.rows,r.layout.column=n.column,r.layout.columns=n.columns,r}function Z(e,t){const n=e.state.camera,r=n.width/2/n.pixelRatio;t/=e.renderCoordsHelper.unitInMeters;return r/(D*A/t)/Math.tan(n.fovX/2)}function B(e,t){const{camera:n}=e.state,{unitInMeters:r}=e.renderCoordsHelper,o=t*Math.tan(n.fovX/2),i=n.width/2/n.pixelRatio;return L/(i/o)*r}async function Q(e,t,n,r,o,i){return _(e,t,Z(e,n),r,o,i)}function $(e,t,n,r,o,i){return ze(e,ie(e,r.heading,r.tilt,t,n,o),r.fov,i)}async function _(e,t,n,r,o,a){const c=await ae(e,r.heading,r.tilt,t,n,o,a);return i(a),Ce(e,c,r.fov,a)}function ee(e,t,n,r,o){return X(e).directionToHeadingTilt(t,n,r,o)}function te(e,t){return!!(e.basemapTerrain&&e.renderCoordsHelper.fromRenderCoords(t,I,e.spatialReference)&&e.elevationProvider&&(U(e.elevationProvider,I)??0)>I[2]-O)}async function ne(e,t,n){if(te(e,t))return!0;const{elevationProvider:r,spatialReference:o,renderCoordsHelper:a}=e;if(null==r||!a.fromRenderCoords(t,I,o))return!1;const[c,l,s]=I,u=await r.queryElevation(c,l,s,o,"ground",n)??0;return i(n),u>s-O}async function re(e,t,n){const r=m();if(null==t)return s(r,e.state.camera.center);if(t instanceof d){const{renderSpatialReference:o,basemapTerrain:a,elevationProvider:c}=e,l=t.spatialReference;if(await w(t,r,o,0,{signal:n}),i(n),null==t.z&&null!=a&&null!=c){const o=await c.queryElevation(t.x,t.y,t.z??0,l,"ground",n);i(n),null!=o&&e.renderCoordsHelper.setAltitude(r,o)}return r}return s(r,t)}function oe(e,t){const n=m();if(null==t)return s(n,e.state.camera.center);if(t instanceof d){if(!v(t,n,e.renderSpatialReference))return null;const{basemapTerrain:r,elevationProvider:o}=e;if(null==t.z&&null!=r&&null!=o){const r=U(o,t);null!=r&&e.renderCoordsHelper.setAltitude(n,r)}return n}return s(n,t)}function ie(e,t,n,r,o,i){return ce(e,t,n,r instanceof d?r:null,oe(e,r),o,i)}async function ae(e,t,n,r,o,a,c){const l=r instanceof d?r:null,s=await re(e,r,c);return i(c),le(e,t,n,l,s,o,a,c)}function ce(e,t,n,r,o,i,a){if(null==o)return null;if(!r&&(r=new d({spatialReference:V(e)}),!R(o,e.renderSpatialReference,r)))return null;const c=se(e,t,n,o,i,a);if(ue(e,n,a)&&te(e,c.eye)){const{tilt:a,mode:c}=fe(e,n,o,i);return ce(e,t,a,r,o,i,c)}return me(c,o)}async function le(e,t,n,r,o,a,c,l){r||(r=new d({spatialReference:V(e)}),await x(o,e.renderSpatialReference,r,{signal:l})||(r=null)),i(l);const s=se(e,t,n,o,a,c);if(ue(e,n,c)&&await ne(e,s.eye,l)){i(l);const{tilt:c,mode:s}=fe(e,n,o,a);return le(e,t,c,r,o,a,s,l)}return me(s,o)}function se(e,t,n,r,o,i){const a=Re(e,t,n,r,o=Math.max(o,e.state.constraints.minimumPoiDistance),i);return(0,X(e).eyeForCenterWithHeadingTilt)(r,o,a.heading,a.tilt)}function ue(e,t,n){const r=e.map.ground.navigationConstraint;return n===J.ADJUST&&e.state.isGlobal&&t>0&&(null==r||"stay-above"===r.type)}function fe(e,t,n,r){const o=Se(e,n,r,Te(e,r,t,n));return{tilt:o,mode:t-o<1?J.LOCKED:J.ADJUST}}function me(e,t){return{...e,center:f(t)}}function pe(e,t){const{state:n,spatialReference:r}=e,o=t.spatialReference;return n.isGlobal&&P(o,T.Global)||n.isLocal&&r.equals(o)}function de(e,t){let n,r,o;if(e.state.isGlobal){const e=new d(t.xmin,t.ymin,t.spatialReference),i=new d(t.xmax,t.ymax,t.spatialReference),a=t.spatialReference.isGeographic?F:k;n=new d({x:a.center(e.x,i.x),y:(i.y+e.y)/2,z:null!=t.zmax&&null!=t.zmin?(t.zmax+t.zmin)/2:void 0,spatialReference:t.spatialReference});const c=p(t.spatialReference),l=C(n,e,i);r=l.lon,o=l.lat,a.diff(e.x,i.x)>a.range/2&&(r+=c.halfCircumference),r=Math.min(r,c.halfCircumference),o=Math.min(o,c.halfCircumference)}else{const i=e.renderSpatialReference??t.spatialReference;i.equals(t.spatialReference)||(t=y(t,i)),r=t.xmax-t.xmin,o=t.ymax-t.ymin;const a=null!=t.zmax&&null!=t.zmin?(t.zmax+t.zmin)/2:void 0;n=new d({x:t.xmin+.5*r,y:t.ymin+.5*o,z:a,spatialReference:i})}const i=null!=t.zmax&&null!=t.zmin?t.zmax-t.zmin:0,a=e.state.camera,c=1/Math.tan(a.fovX/2),l=1/Math.tan(a.fovY/2),s=1/Math.tan(a.fov/2);return{center:n,distance:Math.max(.5*r*c,.5*o*l,.5*i*s)/E}}async function he(e,t,n,r,o,a){const c=pe(e,t)?t:await h(t,e.spatialReference,{signal:a});i(a);const{center:l,distance:s}=de(e,c),u=await ae(e,n,r,l,s,o,a);return i(a),Ce(e,u,e.camera.fov,a)}function ye(e,t,n,r,o,i){let a;try{a=pe(e,t)?t:y(t,e.spatialReference)}catch(u){return null}const{center:c,distance:l}=de(e,a),s=ie(e,n,r,c,l,o);return null==s?null:ze(e,s,e.camera.fov,i)}function ge(e,t,n){const r=e.renderSpatialReference,o=new d({spatialReference:V(e)});if(!R(n,r,o))return null;const i=Math.tan(t.fovX/2),a=Math.tan(t.fovY/2),c=l(t.eye,n),s=2*c*i*E,u=2*c*a*E;return X(e).toExtent(e,o,s,u)}function ve(e,t){return X(e).toArea(e,t)}function we(e,t,n){const r=e.pointsOfInterest.centerOnSurfaceFrequent.distance;if(Math.log(n/r)/Math.LN2>G)return!0;const o=t,i=e.pointsOfInterest.centerOnSurfaceFrequent.renderLocation;return u(o,i)/(Math.tan(.5*e.state.camera.fov)*r)>H}function Re(e,t,n,r,o,i){let a=0;return i===J.ADJUST&&we(e,r,o)?(t=0,a=je(e,o,n,r)):a=Me(e,r,o,n),a=e.state.constraints.clampTilt(o,a),{heading:t,tilt:n=Se(e,r,o,a)}}const xe=.7;function je(e,t,n,r){const o=Me(e,r,t,n);if(!e.state.constraints.tilt)return o;const i=e.state.constraints.tilt(t);i.max=Math.min(i.max,.5*Math.PI);const a=i.min*(1-xe)+i.max*xe;return Math.min(o,a)}function Te(e,t,n,r){let o=Me(e,r,t,n);if(!e.state.constraints.tilt)return o;const i=e.state.constraints.tilt(t);return o=Math.min(o,.5*Math.PI),i.min*(1-xe)+o*xe}function Se(e,t,n,r){return X(e).lookAtTiltToEyeTilt(r,t,n)}function Me(e,t,n,r){return X(e).eyeTiltToLookAtTilt(r,t,n)}function ze(t,n,r,o){if(null==n)return null;const i=t.renderSpatialReference,a=new d({spatialReference:V(t)});return R(n.eye,i,a)?(o??=new e,o.position=a,o.heading=n.heading,o.tilt=n.tilt,o.fov=r,o):null}async function Ce(t,n,r,o){const a=t.renderSpatialReference,c=new d({spatialReference:V(t)});return await x(n.eye,a,c,{signal:o}),i(o),new e(c,n.heading,n.tilt,r)}function Ue(e,t){const n=e.basemapTerrain?.tilingScheme;if(n)return n.levelAtScale(t);b().error("#scaleToZoom()","Cannot compute zoom from scale without a tiling scheme")}function Pe(e,t){const n=e.basemapTerrain?.tilingScheme;if(n)return n.scaleAtLevel(t);b().error("#zoomToScale()","Cannot compute scale from zoom without a tiling scheme")}export{J as OrientationMode,ee as directionToHeadingTilt,B as distanceToScale,W as externalToInternal,_ as fromCenterDistanceAsync,$ as fromCenterDistanceSync,Q as fromCenterScale,he as fromExtentAsync,ye as fromExtentSync,ae as getObserverForPointAtDistanceAsync,ie as getObserverForPointAtDistanceSync,V as getViewSR,K as headingTiltToDirectionUp,N as internalToExternal,Z as scaleToDistance,Ue as scaleToZoom,ve as toArea,ge as toExtent,Pe as zoomToScale};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../../../chunks/tslib.es6.js";import{destroyMaybe as e}from"../../../../core/maybe.js";import{isAbortError as r}from"../../../../core/promiseUtils.js";import{on as o}from"../../../../core/reactiveUtils.js";import{property as i}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as s}from"../../../../core/accessorSupport/decorators/subclass.js";import{p as n,e as a,c as l}from"../../../../chunks/vec32.js";import{create as p}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import c from"../../../../geometry/Point.js";import{ViewingMode as d}from"../../../ViewingMode.js";import{distanceToScale as h}from"../cameraUtils.js";import{PointOfInterest as u}from"./PointOfInterest.js";import{PropertiesPool as m}from"../../../support/PropertiesPool.js";import{Yield as _}from"../../../support/Yield.js";const g=Array;let y=class extends u{constructor(t){super(t),this._dirty=!1,this._propertiesPool=new m({location:c,renderLocation:g},this),this._estimatedSurfaceAltitude=0,this._pendingElevationQueryController=null,this.renderLocation=p(),this._tmpPoint=new c}initialize(){if(this.scheduler&&this.addHandles(this.scheduler.registerTask(this.task,this)),this.runTask(),this.map){const t=()=>this._setDirty();this.addHandles(o((()=>this.map?.ground?.layers),"change",t,{onListenerAdd:t,onListenerRemove:t}))}this._updateRenderLocation()}destroy(){this._cancelPendingRequest(),this._propertiesPool=e(this._propertiesPool)}get _camera(){return this.state.contentCamera}get location(){const t=this._propertiesPool.get("location");return t.spatialReference=this.state.spatialReference,this.renderCoordsHelper.fromRenderCoords(this.renderLocation,t),t}get scale(){const t=this._camera,e=n(t.eye,this.renderLocation),r={renderCoordsHelper:this.renderCoordsHelper,state:{camera:t}};return h(r,e,0)}get updating(){return this._dirty||null!=this._pendingElevationQueryController}updateRenderLocation(){this._setDirty(),this._updateRenderLocation()}_setDirty(){this._dirty||(this._dirty=!0,this.notifyChange("updating"))}_cancelPendingRequest(){const t=this._pendingElevationQueryController;t&&(this._pendingElevationQueryController=null,t.abort(),this.notifyChange("updating"))}get running(){return!this._pendingElevationQueryController&&this._dirty}runTask(){if(this._cancelPendingRequest(),this._dirty=!1,this.notifyChange("updating"),!this.map?.ground)return this._updateSurfaceAltitude(0),_;const t=this.state.spatialReference;this._tmpPoint.spatialReference=t,this.renderCoordsHelper.fromRenderCoords(this._camera.eye,this._tmpPoint);const e=(this._tmpPoint.z??0)>C&&this.renderCoordsHelper.viewingMode===d.Global&&(t.isWGS84||t.isWebMercator);let o=new AbortController;return this.map.ground.queryElevation(this._tmpPoint,{signal:o.signal,cache:this.cache,minDemResolution:e?v:0}).then((t=>this._updateSurfaceAltitude(t.geometry.z??0))).catch((t=>{r(t)||this._updateSurfaceAltitude(0)})).catch((()=>{})).then((()=>{this._pendingElevationQueryController===o&&(this._pendingElevationQueryController=null,this.notifyChange("updating")),o=null})),this._pendingElevationQueryController=o,_}_updateSurfaceAltitude(t){this._estimatedSurfaceAltitude!==t&&(this._estimatedSurfaceAltitude=t,this._updateRenderLocation())}_updateRenderLocation(){this.renderCoordsHelper.setAltitude(f,this._estimatedSurfaceAltitude,this._camera.eye),a(this._get("renderLocation"),f)||(this._set("renderLocation",l(this._propertiesPool.get("renderLocation"),f)),this.notifyChange("renderLocation"))}};t([i({constructOnly:!0})],y.prototype,"scheduler",void 0),t([i({constructOnly:!0})],y.prototype,"cache",void 0),t([i({constructOnly:!0})],y.prototype,"task",void 0),t([i()],y.prototype,"location",null),t([i({constructOnly:!0})],y.prototype,"map",void 0),t([i()],y.prototype,"renderLocation",void 0),t([i()],y.prototype,"scale",null),t([i()],y.prototype,"updating",null),y=t([s("esri.views.3d.support.pointsOfInterest.CameraOnSurface")],y);const f=p(),C=1e5,v=1e6;export{y as CameraOnSurface};
5
+ import{_ as t}from"../../../../chunks/tslib.es6.js";import{destroyMaybe as e}from"../../../../core/maybe.js";import{isAbortError as r}from"../../../../core/promiseUtils.js";import{on as o}from"../../../../core/reactiveUtils.js";import{property as i}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as s}from"../../../../core/accessorSupport/decorators/subclass.js";import{p as n,e as a,c as l}from"../../../../chunks/vec32.js";import{create as p}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import c from"../../../../geometry/Point.js";import{ViewingMode as d}from"../../../ViewingMode.js";import{distanceToScale as h}from"../cameraUtils.js";import{PointOfInterest as u}from"./PointOfInterest.js";import{PropertiesPool as m}from"../../../support/PropertiesPool.js";import{Yield as _}from"../../../support/Yield.js";const g=Array;let y=class extends u{constructor(t){super(t),this._dirty=!1,this._propertiesPool=new m({location:c,renderLocation:g},this),this._estimatedSurfaceAltitude=0,this._pendingElevationQueryController=null,this.renderLocation=p(),this._tmpPoint=new c}initialize(){if(this.scheduler&&this.addHandles(this.scheduler.registerTask(this.task,this)),this.runTask(),this.map){const t=()=>this._setDirty();this.addHandles(o((()=>this.map?.ground?.layers),"change",t,{onListenerAdd:t,onListenerRemove:t}))}this._updateRenderLocation()}destroy(){this._cancelPendingRequest(),this._propertiesPool=e(this._propertiesPool)}get _camera(){return this.state.contentCamera}get location(){const t=this._propertiesPool.get("location");return t.spatialReference=this.state.spatialReference,this.renderCoordsHelper.fromRenderCoords(this.renderLocation,t),t}get scale(){const t=this._camera,e=n(t.eye,this.renderLocation),r={renderCoordsHelper:this.renderCoordsHelper,state:{camera:t}};return h(r,e)}get updating(){return this._dirty||null!=this._pendingElevationQueryController}updateRenderLocation(){this._setDirty(),this._updateRenderLocation()}_setDirty(){this._dirty||(this._dirty=!0,this.notifyChange("updating"))}_cancelPendingRequest(){const t=this._pendingElevationQueryController;t&&(this._pendingElevationQueryController=null,t.abort(),this.notifyChange("updating"))}get running(){return!this._pendingElevationQueryController&&this._dirty}runTask(){if(this._cancelPendingRequest(),this._dirty=!1,this.notifyChange("updating"),!this.map?.ground)return this._updateSurfaceAltitude(0),_;const t=this.state.spatialReference;this._tmpPoint.spatialReference=t,this.renderCoordsHelper.fromRenderCoords(this._camera.eye,this._tmpPoint);const e=(this._tmpPoint.z??0)>C&&this.renderCoordsHelper.viewingMode===d.Global&&(t.isWGS84||t.isWebMercator);let o=new AbortController;return this.map.ground.queryElevation(this._tmpPoint,{signal:o.signal,cache:this.cache,minDemResolution:e?v:0}).then((t=>this._updateSurfaceAltitude(t.geometry.z??0))).catch((t=>{r(t)||this._updateSurfaceAltitude(0)})).catch((()=>{})).then((()=>{this._pendingElevationQueryController===o&&(this._pendingElevationQueryController=null,this.notifyChange("updating")),o=null})),this._pendingElevationQueryController=o,_}_updateSurfaceAltitude(t){this._estimatedSurfaceAltitude!==t&&(this._estimatedSurfaceAltitude=t,this._updateRenderLocation())}_updateRenderLocation(){this.renderCoordsHelper.setAltitude(f,this._estimatedSurfaceAltitude,this._camera.eye),a(this._get("renderLocation"),f)||(this._set("renderLocation",l(this._propertiesPool.get("renderLocation"),f)),this.notifyChange("renderLocation"))}};t([i({constructOnly:!0})],y.prototype,"scheduler",void 0),t([i({constructOnly:!0})],y.prototype,"cache",void 0),t([i({constructOnly:!0})],y.prototype,"task",void 0),t([i()],y.prototype,"location",null),t([i({constructOnly:!0})],y.prototype,"map",void 0),t([i()],y.prototype,"renderLocation",void 0),t([i()],y.prototype,"scale",null),t([i()],y.prototype,"updating",null),y=t([s("esri.views.3d.support.pointsOfInterest.CameraOnSurface")],y);const f=p(),C=1e5,v=1e6;export{y as CameraOnSurface};