@arcgis/core 4.23.1 → 4.23.4

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 (32) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/{d209d82484aa725c5aa9.js → d006b4a239e93eeb9619.js} +1 -1
  3. package/assets/esri/core/workers/chunks/fcd87df3909e94410950.js +1 -0
  4. package/assets/esri/themes/base/widgets/_BasemapLayerList.scss +1 -1
  5. package/assets/esri/themes/base/widgets/_LayerList.scss +1 -1
  6. package/assets/esri/themes/dark/main.css +1 -1
  7. package/assets/esri/themes/dark-blue/main.css +1 -1
  8. package/assets/esri/themes/dark-green/main.css +1 -1
  9. package/assets/esri/themes/dark-purple/main.css +1 -1
  10. package/assets/esri/themes/dark-red/main.css +1 -1
  11. package/assets/esri/themes/light/main.css +1 -1
  12. package/assets/esri/themes/light/view.css +1 -1
  13. package/assets/esri/themes/light-blue/main.css +1 -1
  14. package/assets/esri/themes/light-green/main.css +1 -1
  15. package/assets/esri/themes/light-purple/main.css +1 -1
  16. package/assets/esri/themes/light-red/main.css +1 -1
  17. package/config.js +1 -1
  18. package/interfaces.d.ts +12 -9
  19. package/layers/RouteLayer.js +1 -1
  20. package/package.json +1 -1
  21. package/support/revision.js +1 -1
  22. package/symbols/cim/CIMSymbolDrawHelper.js +1 -1
  23. package/views/2d/engine/webgl/brushes/WGLGeometryBrush.js +1 -1
  24. package/views/2d/engine/webgl/brushes/WGLGeometryBrushFill.js +1 -1
  25. package/views/2d/engine/webgl/brushes/WGLGeometryBrushLine.js +1 -1
  26. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  27. package/widgets/Directions/DirectionsViewModel.js +1 -1
  28. package/widgets/Directions.js +1 -1
  29. package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
  30. package/widgets/FeatureForm/InputField.js +1 -1
  31. package/widgets/FeatureForm.js +1 -1
  32. package/assets/esri/core/workers/chunks/b04af5e4a9ae0c90a1de.js +0 -1
package/config.js CHANGED
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.23/esri/copyright.txt for details.
4
4
  */
5
- import"./core/has.js";import{deepMerge as e}from"./core/object.js";var r;const s={apiKey:void 0,applicationUrl:null==(r=globalThis.location)?void 0:r.href,assetsPath:"",fontsUrl:"https://static.arcgis.com/fonts",geometryServiceUrl:"https://utility.arcgisonline.com/arcgis/rest/services/Geometry/GeometryServer",geoRSSServiceUrl:"https://utility.arcgis.com/sharing/rss",kmlServiceUrl:"https://utility.arcgis.com/sharing/kml",portalUrl:"https://www.arcgis.com",routeServiceUrl:"https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World",workers:{loaderConfig:{has:{},paths:{},map:{},packages:[]}},request:{httpsDomains:["arcgis.com","arcgisonline.com","esrikr.com","premiumservices.blackbridge.com","esripremium.accuweather.com","gbm.digitalglobe.com","firstlook.digitalglobe.com","msi.digitalglobe.com"],interceptors:[],maxUrlLength:2e3,proxyRules:[],proxyUrl:null,timeout:6e4,trustedServers:[],useIdentity:!0},log:{interceptors:[],level:null}};if(globalThis.esriConfig&&(e(s,globalThis.esriConfig,!0),delete s.has),!s.assetsPath){const e="4.23.1";s.assetsPath=`https://js.arcgis.com/${e.slice(0,-2)}/@arcgis/core/assets`}s.baseUrl&&console.warn("[esri.config]","baseUrl has been replaced by assetsPath"),Object.defineProperty(s,"baseUrl",{set(){console.warn("[esri.config]","baseUrl has been replaced by assetsPath")}}),s.request.corsEnabledServers=[],s.request.corsEnabledServers.push=function(){return console.warn("[esri.config]","request.corsEnabledServers is not supported and will be removed in a future release. See http://esriurl.com/cors8664"),0};export{s as default};
5
+ import"./core/has.js";import{deepMerge as e}from"./core/object.js";var r;const s={apiKey:void 0,applicationUrl:null==(r=globalThis.location)?void 0:r.href,assetsPath:"",fontsUrl:"https://static.arcgis.com/fonts",geometryServiceUrl:"https://utility.arcgisonline.com/arcgis/rest/services/Geometry/GeometryServer",geoRSSServiceUrl:"https://utility.arcgis.com/sharing/rss",kmlServiceUrl:"https://utility.arcgis.com/sharing/kml",portalUrl:"https://www.arcgis.com",routeServiceUrl:"https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World",workers:{loaderConfig:{has:{},paths:{},map:{},packages:[]}},request:{httpsDomains:["arcgis.com","arcgisonline.com","esrikr.com","premiumservices.blackbridge.com","esripremium.accuweather.com","gbm.digitalglobe.com","firstlook.digitalglobe.com","msi.digitalglobe.com"],interceptors:[],maxUrlLength:2e3,proxyRules:[],proxyUrl:null,timeout:6e4,trustedServers:[],useIdentity:!0},log:{interceptors:[],level:null}};if(globalThis.esriConfig&&(e(s,globalThis.esriConfig,!0),delete s.has),!s.assetsPath){const e="4.23.4";s.assetsPath=`https://js.arcgis.com/${e.slice(0,-2)}/@arcgis/core/assets`}s.baseUrl&&console.warn("[esri.config]","baseUrl has been replaced by assetsPath"),Object.defineProperty(s,"baseUrl",{set(){console.warn("[esri.config]","baseUrl has been replaced by assetsPath")}}),s.request.corsEnabledServers=[],s.request.corsEnabledServers.push=function(){return console.warn("[esri.config]","request.corsEnabledServers is not supported and will be removed in a future release. See http://esriurl.com/cors8664"),0};export{s as default};
package/interfaces.d.ts CHANGED
@@ -15846,7 +15846,7 @@ declare namespace __esri {
15846
15846
 
15847
15847
  interface RouteLayerConstructor {
15848
15848
  /**
15849
- * RouteLayer is a layer for solving advanced routing problems.
15849
+ * RouteLayer is a layer for visualizing and solving routes.
15850
15850
  *
15851
15851
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-RouteLayer.html)
15852
15852
  */
@@ -28231,7 +28231,7 @@ declare namespace __esri {
28231
28231
  /**
28232
28232
  * A helper function that returns an instance of the portal's [ClosestFacilityTask](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-ClosestFacilityTask.html) [helper service](https://enterprise.arcgis.com/en/portal/latest/administer/windows/about-utility-services.htm).
28233
28233
  *
28234
- * @deprecated since version 4.21.
28234
+ * @deprecated since version 4.21. Use {@link module:esri/rest/closestFacility} with [helperServices](#helperServices) instead.
28235
28235
  *
28236
28236
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#createClosestFacilityTask)
28237
28237
  */
@@ -28245,7 +28245,7 @@ declare namespace __esri {
28245
28245
  /**
28246
28246
  * A helper function that returns an instance of the portal's [GeometryService](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-GeometryService.html) [helper service](https://enterprise.arcgis.com/en/portal/latest/administer/windows/about-utility-services.htm).
28247
28247
  *
28248
- * @deprecated since version 4.21.
28248
+ * @deprecated since version 4.21. Use {@link module:esri/rest/geometryService} with [helperServices](#helperServices) instead.
28249
28249
  *
28250
28250
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#createGeometryService)
28251
28251
  */
@@ -28253,7 +28253,7 @@ declare namespace __esri {
28253
28253
  /**
28254
28254
  * A helper function that returns an instance of the portal's [PrintTask](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-PrintTask.html) [helper service](https://enterprise.arcgis.com/en/portal/latest/administer/windows/about-utility-services.htm).
28255
28255
  *
28256
- * @deprecated since version 4.21.
28256
+ * @deprecated since version 4.21. Use {@link module:esri/rest/print} with [helperServices](#helperServices) instead.
28257
28257
  *
28258
28258
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#createPrintTask)
28259
28259
  */
@@ -28261,7 +28261,7 @@ declare namespace __esri {
28261
28261
  /**
28262
28262
  * A helper function that returns an instance of the portal's [RouteTask](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-RouteTask.html) [helper service](https://enterprise.arcgis.com/en/portal/latest/administer/windows/about-utility-services.htm).
28263
28263
  *
28264
- * @deprecated since version 4.21.
28264
+ * @deprecated since version 4.21. Use {@link module:esri/rest/route} with [helperServices](#helperServices) instead.
28265
28265
  *
28266
28266
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#createRouteTask)
28267
28267
  */
@@ -28269,7 +28269,7 @@ declare namespace __esri {
28269
28269
  /**
28270
28270
  * A helper function that returns an instance of the portal's [ServiceAreaTask](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-ServiceAreaTask.html) [helper service](https://enterprise.arcgis.com/en/portal/latest/administer/windows/about-utility-services.htm).
28271
28271
  *
28272
- * @deprecated since version 4.21.
28272
+ * @deprecated since version 4.21. Use {@link module:esri/rest/serviceArea} with [helperServices](#helperServices) instead.
28273
28273
  *
28274
28274
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#createServiceAreaTask)
28275
28275
  */
@@ -79833,7 +79833,7 @@ declare namespace __esri {
79833
79833
  */
79834
79834
  readonly state: "disabled" | "ready";
79835
79835
  /**
79836
- * An array of graphics that define the stop locations along the route.
79836
+ * A [Collection](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html) of [Stop](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Stop.html)s that define the stop locations along the route.
79837
79837
  *
79838
79838
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions-DirectionsViewModel.html#stops)
79839
79839
  */
@@ -79971,11 +79971,14 @@ declare namespace __esri {
79971
79971
  */
79972
79972
  selectedTravelMode?: TravelModeProperties;
79973
79973
  /**
79974
- * An array of graphics that define the stop locations along the route.
79974
+ * A [Collection](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html) of [Stop](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Stop.html)s that define the stop locations along the route.
79975
79975
  *
79976
79976
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions-DirectionsViewModel.html#stops)
79977
79977
  */
79978
- stops?: CollectionProperties<StopProperties> | CollectionProperties<GraphicProperties>;
79978
+ stops?: | CollectionProperties<StopProperties>
79979
+ | CollectionProperties<GraphicProperties>
79980
+ | GraphicProperties[]
79981
+ | StopProperties[];
79979
79982
  /**
79980
79983
  * The default stop symbols used to display locations between the origin and final destination.
79981
79984
  *
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.23/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import t from"../config.js";import"../geometry.js";import r from"../Graphic.js";import o from"../PopupTemplate.js";import"../renderers/ClassBreaksRenderer.js";import"../renderers/DictionaryRenderer.js";import"../renderers/DotDensityRenderer.js";import"../renderers/HeatmapRenderer.js";import"../renderers/Renderer.js";import"../renderers/SimpleRenderer.js";import"../renderers/UniqueValueRenderer.js";import{read as i}from"../renderers/support/jsonUtils.js";import s from"../core/Collection.js";import n from"../core/Error.js";import{HandleOwnerMixin as l}from"../core/HandleOwner.js";import a from"../core/Logger.js";import{isSome as p,isNone as u,unwrapOrValue as m}from"../core/maybe.js";import{MultiOriginJSONMixin as y}from"../core/MultiOriginJSONSupport.js";import{setDeepValue as f}from"../core/object.js";import{convertUnit as c}from"../core/unitUtils.js";import{urlToObject as d}from"../core/urlUtils.js";import{property as h}from"../core/accessorSupport/decorators/property.js";import"../core/arrayUtils.js";import"../core/has.js";import"../core/accessorSupport/ensureType.js";import{reader as S}from"../core/accessorSupport/decorators/reader.js";import{subclass as g}from"../core/accessorSupport/decorators/subclass.js";import{writer as w}from"../core/accessorSupport/decorators/writer.js";import{updateOrigins as v}from"../core/accessorSupport/originUtils.js";import b from"../geometry/Extent.js";import{initializeProjection as P,project as B}from"../geometry/projection.js";import{WGS84 as I}from"../geometry/support/spatialReferenceUtils.js";import N from"./Layer.js";import{BlendLayer as j}from"./mixins/BlendLayer.js";import{OperationalLayer as O}from"./mixins/OperationalLayer.js";import{PortalLayer as D}from"./mixins/PortalLayer.js";import{ScaleRangeLayer as L}from"./mixins/ScaleRangeLayer.js";import{sanitizeUrl as _}from"./support/arcgisLayerUrl.js";import C from"./support/DefaultSymbols.js";import T from"../portal/Portal.js";import R from"../portal/PortalItem.js";import{fetchServiceDescription as J}from"../rest/networkService.js";import{solve as A}from"../rest/route.js";import x from"../rest/support/DirectionLine.js";import F from"../rest/support/DirectionPoint.js";import{directionsTimeUnitJsonMap as k,directionsLengthUnitJsonMap as G}from"../rest/support/networkEnums.js";import M from"../rest/support/PointBarrier.js";import U from"../rest/support/PolygonBarrier.js";import q from"../rest/support/PolylineBarrier.js";import E from"../rest/support/RouteInfo.js";import W from"../rest/support/RouteParameters.js";import V from"../rest/support/RouteSettings.js";import H from"../rest/support/Stop.js";import K from"../geometry/SpatialReference.js";import Q from"../geometry/Multipoint.js";function Y(e){return e.length?e:null}function Z(e){return"layers"in e}function $(e){return"esri.rest.support.FeatureSet"===e.declaredClass}function z(e){return"esri.rest.support.NetworkFeatureSet"===e.declaredClass}function X(e,t,r){var o,i,s,l,a,u,m,y,f,c,d;const h=t.networkDataset.networkAttributes.filter((e=>"esriNAUTCost"===e.usageType)),S=t.supportedTravelModes.find((e=>e.id===t.defaultTravelMode)),g=null!=(o=r.travelMode)?o:S,{timeAttributeName:w,distanceAttributeName:v}=g,b=h.find((e=>e.name===w)),P=h.find((e=>e.name===v)),B=null!=(i=null!=(s=null==(l=r.travelMode)?void 0:l.impedanceAttributeName)?s:r.impedanceAttribute)?i:t.impedance,I=k.fromJSON(null==b?void 0:b.units),N=G.fromJSON(null==P?void 0:P.units);if(!I||!N)throw new n("routelayer:unknown-impedance-units","the units of either the distance or time impedance are unknown");const j=null!=(a=r.directionsLanguage)?a:t.directionsLanguage,O=null!=(u=null!=(m=r.accumulateAttributes)?m:t.accumulateAttributeNames)?u:[],D=new Set(h.filter((({name:e})=>e===w||e===v||e===B||O.includes(e))).map((({name:e})=>e))),L=e=>{for(const t in e)D.has(t)||delete e[t]};for(const n of e.pointBarriers){var _;if(p(n.costs))n.addedCost=null!=(_=n.costs[B])?_:0,L(n.costs)}for(const n of e.polygonBarriers){var C;if(p(n.costs))n.scaleFactor=null!=(C=n.costs[B])?C:1,L(n.costs)}for(const n of e.polylineBarriers){var T;if(p(n.costs))n.scaleFactor=null!=(T=n.costs[B])?T:1,L(n.costs)}const{routeInfo:R}=e,{findBestSequence:J,preserveFirstStop:A,preserveLastStop:x,startTimeIsUTC:F,timeWindowsAreUTC:M}=r;R.analysisSettings=new V({accumulateAttributes:O,directionsLanguage:j,findBestSequence:J,preserveFirstStop:A,preserveLastStop:x,startTimeIsUTC:F,timeWindowsAreUTC:M,travelMode:g}),R.totalDuration=te(null!=(y=R.totalCosts[w])?y:0,I),R.totalDistance=re(null!=(f=R.totalCosts[v])?f:0,N),R.totalLateDuration=te(null!=(c=R.totalViolations[w])?c:0,I),R.totalWaitDuration=te(null!=(d=R.totalWait[w])?d:0,I),p(R.totalCosts)&&L(R.totalCosts),p(R.totalViolations)&&L(R.totalViolations),p(R.totalWait)&&L(R.totalWait);for(const n of e.stops){var U,q,E,W,H,K;if(p(n.serviceCosts))n.serviceDuration=te(null!=(U=n.serviceCosts[w])?U:0,I),n.serviceDistance=re(null!=(q=n.serviceCosts[v])?q:0,N),L(n.serviceCosts);if(p(n.cumulativeCosts))n.cumulativeDuration=te(null!=(E=n.cumulativeCosts[w])?E:0,I),n.cumulativeDistance=re(null!=(W=n.cumulativeCosts[v])?W:0,N),L(n.cumulativeCosts);if(p(n.violations))n.lateDuration=te(null!=(H=n.violations[w])?H:0,I),L(n.violations);if(p(n.wait))n.waitDuration=te(null!=(K=n.wait[w])?K:0,I),L(n.wait)}}async function ee(e){const t=K.WGS84;return await P(e.spatialReference,t),B(e,t)}function te(e,t){switch(t){case"seconds":return e/60;case"hours":return 60*e;case"days":return 60*e*24;default:return e}}function re(e,t){return"decimal-degrees"===t||"points"===t||"unknown"===t?e:c(e,t,"meters")}const oe=s.ofType(x),ie=s.ofType(F),se=s.ofType(M),ne=s.ofType(U),le=s.ofType(q),ae=s.ofType(H);let pe=class extends(j(L(O(D(y(l(N))))))){constructor(...e){super(...e),this._featureCollection=null,this._type="Feature Collection",this.defaultSymbols=new C,this.directionLines=null,this.directionPoints=null,this.featureCollectionType="route",this.legendEnabled=!1,this.maxScale=0,this.minScale=0,this.pointBarriers=new se,this.polygonBarriers=new ne,this.polylineBarriers=new le,this.routeInfo=null,this.spatialReference=K.WGS84,this.stops=new ae,this.type="route"}writeFeatureCollectionWebmap(e,t,r,o){const i=[this._writePolygonBarriers(),this._writePolylineBarriers(),this._writePointBarriers(),this._writeRouteInfo(),this._writeDirectionLines(),this._writeDirectionPoints(),this._writeStops()].filter((e=>!!e)),s=i.map(((e,t)=>t)),n="web-map"===o.origin?"featureCollection.layers":"layers";f(n,i,t),t.opacity=this.opacity,t.visibility=this.visible,t.visibleLayers=s}readDirectionLines(e,t){return this._getNetworkFeatures(t,"DirectionLines",(e=>x.fromPortalJSON(e)))}readDirectionPoints(e,t){return this._getNetworkFeatures(t,"DirectionPoints",(e=>F.fromPortalJSON(e)))}get fullExtent(){if(p(this.routeInfo)&&p(this.routeInfo.geometry))return this.routeInfo.geometry.extent;if(this.stops.length>1){const{spatialReference:e}=this.stops[0],t=new Q({spatialReference:e}),r=this.stops.toArray().map((e=>e.geometry));for(const o of r)p(o)&&t.addPoint(o);return t.extent}return new b({xmin:-180,ymin:-90,xmax:180,ymax:90,spatialReference:K.WGS84})}readMaxScale(e,t){var r;const o=(Z(t)?t.layers:t.featureCollection.layers).find((e=>p(e.layerDefinition.maxScale)));return null!=(r=null==o?void 0:o.layerDefinition.maxScale)?r:0}readMinScale(e,t){var r;const o=(Z(t)?t.layers:t.featureCollection.layers).find((e=>p(e.layerDefinition.minScale)));return null!=(r=null==o?void 0:o.layerDefinition.minScale)?r:0}readPointBarriers(e,t){return this._getNetworkFeatures(t,"Barriers",(e=>M.fromPortalJSON(e)))}readPolygonBarriers(e,t){return this._getNetworkFeatures(t,"PolygonBarriers",(e=>U.fromPortalJSON(e)))}readPolylineBarriers(e,t){return this._getNetworkFeatures(t,"PolylineBarriers",(e=>q.fromPortalJSON(e)))}readRouteInfo(e,t){const r=this._getNetworkFeatures(t,"RouteInfo",(e=>E.fromPortalJSON(e)));return r.length>0?r.getItemAt(0):null}readSpatialReference(e,t){var r,o;const i=Z(t)?t.layers:t.featureCollection.layers;if(!i.length)return K.WGS84;const{layerDefinition:s}=i[0],n=null!=(r=null!=(o=s.spatialReference)?o:s.extent.spatialReference)?r:I;return K.fromJSON(n)}readStops(e,t){return this._getNetworkFeatures(t,"Stops",(e=>H.fromPortalJSON(e)),(e=>this._setStopSymbol(e)))}get title(){return p(this.routeInfo)&&p(this.routeInfo.name)?this.routeInfo.name:"Route"}set title(e){e?this._override("title",e):this._clearOverride("title")}get url(){return t.routeServiceUrl}set url(e){null!=e?this._set("url",_(e,a.getLogger(this.declaredClass))):this._set("url",t.routeServiceUrl)}load(e){return this.addResolvingPromise(this.loadFromPortal({supportedTypes:["Feature Collection"]},e)),Promise.resolve(this)}removeAll(){p(this.directionLines)&&(this.directionLines.removeAll(),this._set("directionLines",null)),p(this.directionPoints)&&(this.directionPoints.removeAll(),this._set("directionPoints",null)),p(this.routeInfo)&&this._set("routeInfo",null),this.pointBarriers.removeAll(),this.polygonBarriers.removeAll(),this.polylineBarriers.removeAll(),this.stops.removeAll()}async save(){await this.load();const{fullExtent:e,portalItem:t}=this;if(!t)throw new n("routelayer:portal-item-not-set","save() requires to the layer to have a portal item");if(!t.id)throw new n("routelayer:portal-item-not-saved","Please use saveAs() first to save the routelayer");if("Feature Collection"!==t.type)throw new n("routelayer:portal-item-wrong-type",'Portal item needs to have type "Feature Collection"');if(u(this.routeInfo))throw new n("routelayer:route-unsolved","save() requires a solved route");const{portal:r}=t;if(await r._signIn(),r.user||await t.reload(),r.user.username!==t.owner)throw new n("routelayer:not-portal-item-owner","You can only overwrite your portal items");const{itemUrl:o}=t,i={messages:[],origin:"portal-item",portal:r,url:o&&d(o),writtenProperties:[]},s=this.write(null,i);return t.extent=await ee(e),t.title=this.title,await t.update({data:s}),t}async saveAs(e,t={}){if(await this.load(),u(this.routeInfo))throw new n("routelayer:route-unsolved","saveAs() requires a solved route");const r=R.from(e).clone();null!=r.extent||(r.extent=await ee(this.fullExtent)),r.id=null,null!=r.portal||(r.portal=T.getDefault()),null!=r.title||(r.title=this.title),r.type="Feature Collection",r.typeKeywords=["Data","Feature Collection","Multilayer","Route Layer"];const{portal:o}=r,i={messages:[],origin:"portal-item",portal:o,url:null,writtenProperties:[]};await o._signIn();const s=null==t?void 0:t.folder,l=this.write(null,i);return await o.user.addItem({item:r,folder:s,data:l}),this.portalItem=r,v(i),i.portalItem=r,r}async solve(e,t){var r,o,i,l,a,p;const y=null!=(r=null==e?void 0:e.stops)?r:this.stops,f=null!=(o=null==e?void 0:e.pointBarriers)?o:Y(this.pointBarriers),c=null!=(i=null==e?void 0:e.polylineBarriers)?i:Y(this.polylineBarriers),d=null!=(l=null==e?void 0:e.polygonBarriers)?l:Y(this.polygonBarriers);if(u(y))throw new n("routelayer:undefined-stops","the route layer must have stops defined in the route parameters.");if(($(y)||z(y))&&y.features.length<2||s.isCollection(y)&&y.length<2)throw new n("routelayer:insufficent-stops","the route layer must have two or more stops to solve a route.");const h=await J(this.url,null==e?void 0:e.apiKey,t),S=h.supportedTravelModes.find((e=>e.id===h.defaultTravelMode)),g=null!=(a=null==e?void 0:e.travelMode)?a:S,{distanceAttributeName:w}=g,v=null!=(p=null==e?void 0:e.accumulateAttributes)?p:[];v.push(w);const b={startTime:new Date},P={accumulateAttributes:v,directionsOutputType:"featuresets",ignoreInvalidLocations:!0,pointBarriers:f,polylineBarriers:c,polygonBarriers:d,preserveFirstStop:!0,preserveLastStop:!0,returnBarriers:!!f,returnDirections:!0,returnPolygonBarriers:!!d,returnPolylineBarriers:!!c,returnRoutes:!0,returnStops:!0,stops:y},B=e?W.from(e):new W;for(const s in b)null==B[s]&&(B[s]=b[s]);B.set(P);const I=await A(this.url,B,t),N=this._toRouteLayerSolution(I);return this._isOverridden("title")||(this.title=m(N.routeInfo.name,"Route")),X(N,h,B),N}update(e){const{stops:t,directionLines:r,directionPoints:o,pointBarriers:i,polylineBarriers:s,polygonBarriers:n,routeInfo:l}=e;this.set({stops:t,pointBarriers:i,polylineBarriers:s,polygonBarriers:n}),this._set("directionLines",r),this._set("directionPoints",o),this._set("routeInfo",l)}_getLayerDefinition(){return{capabilities:"Query,Update,Editing",extent:this.fullExtent.toJSON(),hasM:!1,hasZ:!1,maxScale:this.maxScale,minScale:this.minScale,objectIdField:"__OBJECTID",spatialReference:this.spatialReference.toJSON(),type:"Feature Layer",typeIdField:""}}_getNetworkFeatures(e,t,n,l){const a=(Z(e)?e.layers:e.featureCollection.layers).find((e=>e.layerDefinition.name===t));if(u(a))return new s;const{layerDefinition:p,popupInfo:m,featureSet:y}=a,f=p.drawingInfo.renderer,{features:c}=y,d=f&&i(f),h=c.map((e=>{var i;const s=n(e),{attributes:l}=e,a=new r({attributes:l});return null!=s.symbol||(s.symbol=null!=(i=null==d?void 0:d.getSymbol(a))?i:this._getNetworkSymbol(t)),null!=s.popupTemplate||(s.popupTemplate=m&&o.fromJSON(m)),s}));return l&&h.some((e=>!e.symbol))&&l(h),new s(h)}_getNetworkSymbol(e){switch(e){case"Barriers":return this.defaultSymbols.pointBarriers;case"DirectionPoints":return this.defaultSymbols.directionPoints;case"DirectionLines":return this.defaultSymbols.directionLines;case"PolylineBarriers":return this.defaultSymbols.polylineBarriers;case"PolygonBarriers":return this.defaultSymbols.polygonBarriers;case"RouteInfo":return this.defaultSymbols.routeInfo;case"Stops":return null}}_setStopSymbol(e){if(!e)return;if(e.length<2){for(const t of e)t.symbol=this.defaultSymbols.invalidStop;return}const t=e.map((e=>e.sequence)).filter((e=>p(e))),r=Math.min(...t),o=Math.max(...t);for(const i of e)i.sequence!==r?i.sequence!==o?"ok"===i.status||"not-located-on-closest"===i.status?"waypoint"!==i.locationType?"break"!==i.locationType?i.symbol=this.defaultSymbols.middleStop:i.symbol=this.defaultSymbols.breakStop:i.symbol=this.defaultSymbols.waypointStop:i.symbol=this.defaultSymbols.invalidStop:i.symbol=this.defaultSymbols.lastStop:i.symbol=this.defaultSymbols.firstStop}_toRouteLayerSolution(e){var t,r,o;const i=e.routeResults[0].stops.map((e=>H.fromJSON(e.toJSON())));this._setStopSymbol(i);const s=new ae(i),n=new ne(null==(t=e.polygonBarriers)?void 0:t.map((e=>{const t=U.fromJSON(e.toJSON());return t.symbol=this.defaultSymbols.polygonBarriers,t}))),l=new le(null==(r=e.polylineBarriers)?void 0:r.map((e=>{const t=q.fromJSON(e.toJSON());return t.symbol=this.defaultSymbols.polylineBarriers,t}))),a=new se(null==(o=e.pointBarriers)?void 0:o.map((e=>{const t=M.fromJSON(e.toJSON());return t.symbol=this.defaultSymbols.pointBarriers,t}))),p=E.fromJSON(e.routeResults[0].route.toJSON());p.symbol=this.defaultSymbols.routeInfo;const u=new ie(e.routeResults[0].directionPoints.features.map((e=>{const t=F.fromJSON(e.toJSON());return t.symbol=this.defaultSymbols.directionPoints,t})));return{directionLines:new oe(e.routeResults[0].directionLines.features.map((e=>{const t=x.fromJSON(e.toJSON());return t.symbol=this.defaultSymbols.directionLines,t}))),directionPoints:u,pointBarriers:a,polygonBarriers:n,polylineBarriers:l,routeInfo:p,stops:s}}_writeDirectionLines(){return u(this.directionLines)||!this.directionLines.length?null:{featureSet:{features:this.directionLines.toArray().map((e=>e.toPortalJSON())),geometryType:"esriGeometryPolyline"},layerDefinition:{...this._getLayerDefinition(),drawingInfo:{renderer:{type:"simple",symbol:this.defaultSymbols.directionLines.toJSON()}},fields:x.fields,geometryType:"esriGeometryPolyline",name:"DirectionLines",title:"Direction Lines"},popupInfo:x.popupInfo}}_writeDirectionPoints(){return u(this.directionPoints)||!this.directionPoints.length?null:{featureSet:{features:this.directionPoints.toArray().map((e=>e.toPortalJSON())),geometryType:"esriGeometryPoint"},layerDefinition:{...this._getLayerDefinition(),drawingInfo:{renderer:{type:"simple",symbol:this.defaultSymbols.directionPoints.toJSON()}},fields:F.fields,geometryType:"esriGeometryPoint",name:"DirectionPoints",title:"Direction Points"},popupInfo:F.popupInfo}}_writePointBarriers(){return u(this.pointBarriers)||!this.pointBarriers.length?null:{featureSet:{features:this.pointBarriers.toArray().map((e=>e.toPortalJSON())),geometryType:"esriGeometryPoint"},layerDefinition:{...this._getLayerDefinition(),drawingInfo:{renderer:{type:"simple",symbol:this.defaultSymbols.pointBarriers.toJSON()}},fields:M.fields,geometryType:"esriGeometryPoint",name:"Barrier",title:"Point Barrier"},popupInfo:M.popupInfo}}_writePolygonBarriers(){return u(this.polygonBarriers)||!this.polygonBarriers.length?null:{featureSet:{features:this.polygonBarriers.toArray().map((e=>e.toPortalJSON())),geometryType:"esriGeometryPolygon"},layerDefinition:{...this._getLayerDefinition(),drawingInfo:{renderer:{type:"simple",symbol:this.defaultSymbols.polygonBarriers.toJSON()}},fields:U.fields,geometryType:"esriGeometryPolygon",name:"PolygonBarriers",title:"Polygon Barriers"},popupInfo:U.popupInfo}}_writePolylineBarriers(){return u(this.polylineBarriers)||!this.polylineBarriers.length?null:{featureSet:{features:this.polylineBarriers.toArray().map((e=>e.toPortalJSON())),geometryType:"esriGeometryPolyline"},layerDefinition:{...this._getLayerDefinition(),drawingInfo:{renderer:{type:"simple",symbol:this.defaultSymbols.polylineBarriers.toJSON()}},fields:q.fields,geometryType:"esriGeometryPolyline",name:"PolylineBarriers",title:"Line Barriers"},popupInfo:q.popupInfo}}_writeRouteInfo(){return u(this.routeInfo)?null:{featureSet:{features:[this.routeInfo.toPortalJSON()],geometryType:"esriGeometryPolyline"},layerDefinition:{...this._getLayerDefinition(),drawingInfo:{renderer:{type:"simple",symbol:this.defaultSymbols.routeInfo.toJSON()}},fields:E.fields,geometryType:"esriGeometryPolyline",name:"RouteInfo",title:"Route Details"},popupInfo:E.popupInfo}}_writeStops(){return u(this.stops)||!this.stops.length?null:{featureSet:{features:this.stops.toArray().map((e=>e.toPortalJSON())),geometryType:"esriGeometryPoint"},layerDefinition:{...this._getLayerDefinition(),drawingInfo:{renderer:{type:"uniqueValue",field1:"Sequence",defaultSymbol:this.defaultSymbols.middleStop.toJSON(),uniqueValueInfos:[{value:"1",symbol:this.defaultSymbols.firstStop.toJSON(),label:"First Stop"},{value:`${this.stops.length}`,symbol:this.defaultSymbols.lastStop.toJSON(),label:"Last Stop"}]}},fields:H.fields,geometryType:"esriGeometryPoint",name:"Stops",title:"Stops"},popupInfo:H.popupInfo}}};e([h({readOnly:!0,json:{read:!1,origins:{"portal-item":{write:{allowNull:!0,ignoreOrigin:!0}},"web-map":{write:{overridePolicy(){return{allowNull:!0,ignoreOrigin:null==this.portalItem}}}}}}})],pe.prototype,"_featureCollection",void 0),e([w(["web-map","portal-item"],"_featureCollection")],pe.prototype,"writeFeatureCollectionWebmap",null),e([h({readOnly:!0,json:{read:!1,origins:{"web-map":{write:{target:"type",overridePolicy(){return{ignoreOrigin:null!=this.portalItem}}}}}}})],pe.prototype,"_type",void 0),e([h({nonNullable:!0,type:C})],pe.prototype,"defaultSymbols",void 0),e([h({readOnly:!0})],pe.prototype,"directionLines",void 0),e([S(["web-map","portal-item"],"directionLines",["layers","featureCollection.layers"])],pe.prototype,"readDirectionLines",null),e([h({readOnly:!0})],pe.prototype,"directionPoints",void 0),e([S(["web-map","portal-item"],"directionPoints",["layers","featureCollection.layers"])],pe.prototype,"readDirectionPoints",null),e([h({readOnly:!0,json:{read:!1,origins:{"web-map":{write:{ignoreOrigin:!0}}}}})],pe.prototype,"featureCollectionType",void 0),e([h({readOnly:!0})],pe.prototype,"fullExtent",null),e([h({json:{origins:{"web-map":{name:"featureCollection.showLegend"}},write:!0}})],pe.prototype,"legendEnabled",void 0),e([h({type:["show","hide"]})],pe.prototype,"listMode",void 0),e([h({type:Number,nonNullable:!0,json:{write:!1}})],pe.prototype,"maxScale",void 0),e([S(["web-map","portal-item"],"maxScale",["layers","featureCollection.layers"])],pe.prototype,"readMaxScale",null),e([h({type:Number,nonNullable:!0,json:{write:!1}})],pe.prototype,"minScale",void 0),e([S(["web-map","portal-item"],"minScale",["layers","featureCollection.layers"])],pe.prototype,"readMinScale",null),e([h({type:["ArcGISFeatureLayer"],value:"ArcGISFeatureLayer"})],pe.prototype,"operationalLayerType",void 0),e([h({nonNullable:!0,type:s.ofType(M)})],pe.prototype,"pointBarriers",void 0),e([S(["web-map","portal-item"],"pointBarriers",["layers","featureCollection.layers"])],pe.prototype,"readPointBarriers",null),e([h({nonNullable:!0,type:s.ofType(U)})],pe.prototype,"polygonBarriers",void 0),e([S(["web-map","portal-item"],"polygonBarriers",["layers","featureCollection.layers"])],pe.prototype,"readPolygonBarriers",null),e([h({nonNullable:!0,type:s.ofType(q)})],pe.prototype,"polylineBarriers",void 0),e([S(["web-map","portal-item"],"polylineBarriers",["layers","featureCollection.layers"])],pe.prototype,"readPolylineBarriers",null),e([h({readOnly:!0})],pe.prototype,"routeInfo",void 0),e([S(["web-map","portal-item"],"routeInfo",["layers","featureCollection.layers"])],pe.prototype,"readRouteInfo",null),e([h({type:K})],pe.prototype,"spatialReference",void 0),e([S(["web-map","portal-item"],"spatialReference",["layers","featureCollection.layers"])],pe.prototype,"readSpatialReference",null),e([h({nonNullable:!0,type:s.ofType(H)})],pe.prototype,"stops",void 0),e([S(["web-map","portal-item"],"stops",["layers","featureCollection.layers"])],pe.prototype,"readStops",null),e([h()],pe.prototype,"title",null),e([h({readOnly:!0,json:{read:!1}})],pe.prototype,"type",void 0),e([h()],pe.prototype,"url",null),pe=e([g("esri.layers.RouteLayer")],pe);const ue=pe;export{ue as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import t from"../config.js";import"../geometry.js";import r from"../Graphic.js";import o from"../PopupTemplate.js";import"../renderers/ClassBreaksRenderer.js";import"../renderers/DictionaryRenderer.js";import"../renderers/DotDensityRenderer.js";import"../renderers/HeatmapRenderer.js";import"../renderers/Renderer.js";import"../renderers/SimpleRenderer.js";import"../renderers/UniqueValueRenderer.js";import{read as i}from"../renderers/support/jsonUtils.js";import s from"../core/Collection.js";import n from"../core/Error.js";import{HandleOwnerMixin as l}from"../core/HandleOwner.js";import a from"../core/Logger.js";import{isSome as p,isNone as u,unwrapOrValue as m}from"../core/maybe.js";import{MultiOriginJSONMixin as y}from"../core/MultiOriginJSONSupport.js";import{setDeepValue as f}from"../core/object.js";import{watch as c}from"../core/reactiveUtils.js";import{convertUnit as d}from"../core/unitUtils.js";import{urlToObject as h}from"../core/urlUtils.js";import{property as S}from"../core/accessorSupport/decorators/property.js";import"../core/arrayUtils.js";import"../core/has.js";import"../core/accessorSupport/ensureType.js";import{reader as g}from"../core/accessorSupport/decorators/reader.js";import{subclass as w}from"../core/accessorSupport/decorators/subclass.js";import{writer as v}from"../core/accessorSupport/decorators/writer.js";import{updateOrigins as b}from"../core/accessorSupport/originUtils.js";import P from"../geometry/Extent.js";import{initializeProjection as B,project as I}from"../geometry/projection.js";import{WGS84 as N}from"../geometry/support/spatialReferenceUtils.js";import j from"./Layer.js";import{BlendLayer as O}from"./mixins/BlendLayer.js";import{OperationalLayer as L}from"./mixins/OperationalLayer.js";import{PortalLayer as D}from"./mixins/PortalLayer.js";import{ScaleRangeLayer as _}from"./mixins/ScaleRangeLayer.js";import{sanitizeUrl as C}from"./support/arcgisLayerUrl.js";import T from"./support/DefaultSymbols.js";import R from"../portal/Portal.js";import J from"../portal/PortalItem.js";import{fetchServiceDescription as A}from"../rest/networkService.js";import{solve as x}from"../rest/route.js";import F from"../rest/support/DirectionLine.js";import k from"../rest/support/DirectionPoint.js";import{directionsTimeUnitJsonMap as G,directionsLengthUnitJsonMap as M}from"../rest/support/networkEnums.js";import U from"../rest/support/PointBarrier.js";import E from"../rest/support/PolygonBarrier.js";import q from"../rest/support/PolylineBarrier.js";import W from"../rest/support/RouteInfo.js";import V from"../rest/support/RouteParameters.js";import H from"../rest/support/RouteSettings.js";import K from"../rest/support/Stop.js";import Q from"../geometry/SpatialReference.js";import Y from"../geometry/Multipoint.js";function Z(e){return e.length?e:null}function $(e){return"layers"in e}function z(e){return"esri.rest.support.FeatureSet"===e.declaredClass}function X(e){return"esri.rest.support.NetworkFeatureSet"===e.declaredClass}function ee(e,t,r){var o,i,s,l,a,m,y,f,c,d,h;const{impedance:S,networkDataset:g,supportedTravelModes:w,defaultTravelMode:v}=t,b=g.networkAttributes.filter((e=>"esriNAUTCost"===e.usageType)),P=w.find((e=>e.id===v)),B=null!=(o=r.travelMode)?o:P;if(u(B))return void ue.warn("route-layer:missing-travel-mode","The routing service must have a default travel mode or one must be specified in the route parameter.");const{timeAttributeName:I,distanceAttributeName:N}=B,j=b.find((e=>e.name===I)),O=b.find((e=>e.name===N)),L=null!=(i=null!=(s=null==(l=r.travelMode)?void 0:l.impedanceAttributeName)?s:r.impedanceAttribute)?i:S,D=G.fromJSON(null==j?void 0:j.units),_=M.fromJSON(null==O?void 0:O.units);if(!D||!_)throw new n("routelayer:unknown-impedance-units","the units of either the distance or time impedance are unknown");const C=null!=(a=r.directionsLanguage)?a:t.directionsLanguage,T=null!=(m=null!=(y=r.accumulateAttributes)?y:t.accumulateAttributeNames)?m:[],R=new Set(b.filter((({name:e})=>e===I||e===N||e===L||T.includes(e))).map((({name:e})=>e))),J=e=>{for(const t in e)R.has(t)||delete e[t]};for(const n of e.pointBarriers){var A;if(p(n.costs))n.addedCost=null!=(A=n.costs[L])?A:0,J(n.costs)}for(const n of e.polygonBarriers){var x;if(p(n.costs))n.scaleFactor=null!=(x=n.costs[L])?x:1,J(n.costs)}for(const n of e.polylineBarriers){var F;if(p(n.costs))n.scaleFactor=null!=(F=n.costs[L])?F:1,J(n.costs)}const{routeInfo:k}=e,{findBestSequence:U,preserveFirstStop:E,preserveLastStop:q,startTimeIsUTC:W,timeWindowsAreUTC:V}=r;k.analysisSettings=new H({accumulateAttributes:T,directionsLanguage:C,findBestSequence:U,preserveFirstStop:E,preserveLastStop:q,startTimeIsUTC:W,timeWindowsAreUTC:V,travelMode:B}),k.totalDuration=re(null!=(f=k.totalCosts[I])?f:0,D),k.totalDistance=oe(null!=(c=k.totalCosts[N])?c:0,_),k.totalLateDuration=re(null!=(d=k.totalViolations[I])?d:0,D),k.totalWaitDuration=re(null!=(h=k.totalWait[I])?h:0,D),p(k.totalCosts)&&J(k.totalCosts),p(k.totalViolations)&&J(k.totalViolations),p(k.totalWait)&&J(k.totalWait);for(const n of e.stops){var K,Q,Y,Z,$,z;if(p(n.serviceCosts))n.serviceDuration=re(null!=(K=n.serviceCosts[I])?K:0,D),n.serviceDistance=oe(null!=(Q=n.serviceCosts[N])?Q:0,_),J(n.serviceCosts);if(p(n.cumulativeCosts))n.cumulativeDuration=re(null!=(Y=n.cumulativeCosts[I])?Y:0,D),n.cumulativeDistance=oe(null!=(Z=n.cumulativeCosts[N])?Z:0,_),J(n.cumulativeCosts);if(p(n.violations))n.lateDuration=re(null!=($=n.violations[I])?$:0,D),J(n.violations);if(p(n.wait))n.waitDuration=re(null!=(z=n.wait[I])?z:0,D),J(n.wait)}}async function te(e){const t=Q.WGS84;return await B(e.spatialReference,t),I(e,t)}function re(e,t){switch(t){case"seconds":return e/60;case"hours":return 60*e;case"days":return 60*e*24;default:return e}}function oe(e,t){return"decimal-degrees"===t||"points"===t||"unknown"===t?e:d(e,t,"meters")}const ie=s.ofType(F),se=s.ofType(k),ne=s.ofType(U),le=s.ofType(E),ae=s.ofType(q),pe=s.ofType(K),ue=a.getLogger("esri.layers.RouteLayer");let me=class extends(O(_(L(D(y(l(j))))))){constructor(...e){super(...e),this._featureCollection=null,this._type="Feature Collection",this.defaultSymbols=new T,this.directionLines=null,this.directionPoints=null,this.featureCollectionType="route",this.legendEnabled=!1,this.maxScale=0,this.minScale=0,this.pointBarriers=new ne,this.polygonBarriers=new le,this.polylineBarriers=new ae,this.routeInfo=null,this.spatialReference=Q.WGS84,this.stops=new pe,this.type="route",this.handles.add(c((()=>this.stops.toArray()),(()=>{u(this.routeInfo)&&this._setStopSymbol(this.stops)}),{sync:!0}))}writeFeatureCollectionWebmap(e,t,r,o){const i=[this._writePolygonBarriers(),this._writePolylineBarriers(),this._writePointBarriers(),this._writeRouteInfo(),this._writeDirectionLines(),this._writeDirectionPoints(),this._writeStops()].filter((e=>!!e)),s=i.map(((e,t)=>t)),n="web-map"===o.origin?"featureCollection.layers":"layers";f(n,i,t),t.opacity=this.opacity,t.visibility=this.visible,t.visibleLayers=s}readDirectionLines(e,t){return this._getNetworkFeatures(t,"DirectionLines",(e=>F.fromPortalJSON(e)))}readDirectionPoints(e,t){return this._getNetworkFeatures(t,"DirectionPoints",(e=>k.fromPortalJSON(e)))}get fullExtent(){if(p(this.routeInfo)&&p(this.routeInfo.geometry))return this.routeInfo.geometry.extent;if(this.stops.length>1){const{spatialReference:e}=this.stops[0],t=new Y({spatialReference:e}),r=this.stops.toArray().map((e=>e.geometry));for(const o of r)p(o)&&t.addPoint(o);return t.extent}return new P({xmin:-180,ymin:-90,xmax:180,ymax:90,spatialReference:Q.WGS84})}readMaxScale(e,t){var r;const o=($(t)?t.layers:t.featureCollection.layers).find((e=>p(e.layerDefinition.maxScale)));return null!=(r=null==o?void 0:o.layerDefinition.maxScale)?r:0}readMinScale(e,t){var r;const o=($(t)?t.layers:t.featureCollection.layers).find((e=>p(e.layerDefinition.minScale)));return null!=(r=null==o?void 0:o.layerDefinition.minScale)?r:0}readPointBarriers(e,t){return this._getNetworkFeatures(t,"Barriers",(e=>U.fromPortalJSON(e)))}readPolygonBarriers(e,t){return this._getNetworkFeatures(t,"PolygonBarriers",(e=>E.fromPortalJSON(e)))}readPolylineBarriers(e,t){return this._getNetworkFeatures(t,"PolylineBarriers",(e=>q.fromPortalJSON(e)))}readRouteInfo(e,t){const r=this._getNetworkFeatures(t,"RouteInfo",(e=>W.fromPortalJSON(e)));return r.length>0?r.getItemAt(0):null}readSpatialReference(e,t){var r,o;const i=$(t)?t.layers:t.featureCollection.layers;if(!i.length)return Q.WGS84;const{layerDefinition:s}=i[0],n=null!=(r=null!=(o=s.spatialReference)?o:s.extent.spatialReference)?r:N;return Q.fromJSON(n)}readStops(e,t){return this._getNetworkFeatures(t,"Stops",(e=>K.fromPortalJSON(e)),(e=>this._setStopSymbol(e)))}get title(){return p(this.routeInfo)&&p(this.routeInfo.name)?this.routeInfo.name:"Route"}set title(e){e?this._override("title",e):this._clearOverride("title")}get url(){return t.routeServiceUrl}set url(e){null!=e?this._set("url",C(e,ue)):this._set("url",t.routeServiceUrl)}load(e){return this.addResolvingPromise(this.loadFromPortal({supportedTypes:["Feature Collection"]},e)),Promise.resolve(this)}removeAll(){p(this.directionLines)&&(this.directionLines.removeAll(),this._set("directionLines",null)),p(this.directionPoints)&&(this.directionPoints.removeAll(),this._set("directionPoints",null)),p(this.routeInfo)&&this._set("routeInfo",null),this.pointBarriers.removeAll(),this.polygonBarriers.removeAll(),this.polylineBarriers.removeAll(),this.stops.removeAll()}async save(){await this.load();const{fullExtent:e,portalItem:t}=this;if(!t)throw new n("routelayer:portal-item-not-set","save() requires to the layer to have a portal item");if(!t.id)throw new n("routelayer:portal-item-not-saved","Please use saveAs() first to save the routelayer");if("Feature Collection"!==t.type)throw new n("routelayer:portal-item-wrong-type",'Portal item needs to have type "Feature Collection"');if(u(this.routeInfo))throw new n("routelayer:route-unsolved","save() requires a solved route");const{portal:r}=t;if(await r._signIn(),r.user||await t.reload(),r.user.username!==t.owner)throw new n("routelayer:not-portal-item-owner","You can only overwrite your portal items");const{itemUrl:o}=t,i={messages:[],origin:"portal-item",portal:r,url:o&&h(o),writtenProperties:[]},s=this.write(null,i);return t.extent=await te(e),t.title=this.title,await t.update({data:s}),t}async saveAs(e,t={}){if(await this.load(),u(this.routeInfo))throw new n("routelayer:route-unsolved","saveAs() requires a solved route");const r=J.from(e).clone();null!=r.extent||(r.extent=await te(this.fullExtent)),r.id=null,null!=r.portal||(r.portal=R.getDefault()),null!=r.title||(r.title=this.title),r.type="Feature Collection",r.typeKeywords=["Data","Feature Collection","Multilayer","Route Layer"];const{portal:o}=r,i={messages:[],origin:"portal-item",portal:o,url:null,writtenProperties:[]};await o._signIn();const s=null==t?void 0:t.folder,l=this.write(null,i);return await o.user.addItem({item:r,folder:s,data:l}),this.portalItem=r,b(i),i.portalItem=r,r}async solve(e,t){var r,o,i,l,a,y;const f=null!=(r=null==e?void 0:e.stops)?r:this.stops,c=null!=(o=null==e?void 0:e.pointBarriers)?o:Z(this.pointBarriers),d=null!=(i=null==e?void 0:e.polylineBarriers)?i:Z(this.polylineBarriers),h=null!=(l=null==e?void 0:e.polygonBarriers)?l:Z(this.polygonBarriers);if(u(f))throw new n("routelayer:undefined-stops","the route layer must have stops defined in the route parameters.");if((z(f)||X(f))&&f.features.length<2||s.isCollection(f)&&f.length<2)throw new n("routelayer:insufficent-stops","the route layer must have two or more stops to solve a route.");const S=await A(this.url,null==e?void 0:e.apiKey,t),{defaultTravelMode:g,supportedTravelModes:w}=S,v=w.find((e=>e.id===g)),b=null!=(a=null==e?void 0:e.travelMode)?a:v,P=null!=(y=null==e?void 0:e.accumulateAttributes)?y:[];p(b)&&P.push(b.distanceAttributeName);const B={startTime:new Date},I={accumulateAttributes:P,directionsOutputType:"featuresets",ignoreInvalidLocations:!0,pointBarriers:c,polylineBarriers:d,polygonBarriers:h,preserveFirstStop:!0,preserveLastStop:!0,returnBarriers:!!c,returnDirections:!0,returnPolygonBarriers:!!h,returnPolylineBarriers:!!d,returnRoutes:!0,returnStops:!0,stops:f},N=e?V.from(e):new V;for(const s in B)null==N[s]&&(N[s]=B[s]);N.set(I);const j=await x(this.url,N,t),O=this._toRouteLayerSolution(j);return this._isOverridden("title")||(this.title=m(O.routeInfo.name,"Route")),ee(O,S,N),O}update(e){const{stops:t,directionLines:r,directionPoints:o,pointBarriers:i,polylineBarriers:s,polygonBarriers:n,routeInfo:l}=e;this.set({stops:t,pointBarriers:i,polylineBarriers:s,polygonBarriers:n}),this._set("directionLines",r),this._set("directionPoints",o),this._set("routeInfo",l)}_getLayerDefinition(){return{capabilities:"Query,Update,Editing",extent:this.fullExtent.toJSON(),hasM:!1,hasZ:!1,maxScale:this.maxScale,minScale:this.minScale,objectIdField:"__OBJECTID",spatialReference:this.spatialReference.toJSON(),type:"Feature Layer",typeIdField:""}}_getNetworkFeatures(e,t,n,l){const a=($(e)?e.layers:e.featureCollection.layers).find((e=>e.layerDefinition.name===t));if(u(a))return new s;const{layerDefinition:p,popupInfo:m,featureSet:y}=a,f=p.drawingInfo.renderer,{features:c}=y,d=f&&i(f),h=c.map((e=>{var i;const s=n(e),{attributes:l}=e,a=new r({attributes:l});return null!=s.symbol||(s.symbol=null!=(i=null==d?void 0:d.getSymbol(a))?i:this._getNetworkSymbol(t)),null!=s.popupTemplate||(s.popupTemplate=m&&o.fromJSON(m)),s}));return l&&h.some((e=>!e.symbol))&&l(h),new s(h)}_getNetworkSymbol(e){switch(e){case"Barriers":return this.defaultSymbols.pointBarriers;case"DirectionPoints":return this.defaultSymbols.directionPoints;case"DirectionLines":return this.defaultSymbols.directionLines;case"PolylineBarriers":return this.defaultSymbols.polylineBarriers;case"PolygonBarriers":return this.defaultSymbols.polygonBarriers;case"RouteInfo":return this.defaultSymbols.routeInfo;case"Stops":return null}}_setStopSymbol(e){if(!e||0===e.length)return;if(u(this.routeInfo)||1===e.length)return void e.forEach(((t,r)=>{switch(r){case 0:t.symbol=this.defaultSymbols.firstStop;break;case e.length-1:t.symbol=this.defaultSymbols.lastStop;break;default:t.symbol=this.defaultSymbols.middleStop}}));const t=e.map((e=>e.sequence)).filter((e=>p(e))),r=Math.min(...t),o=Math.max(...t);for(const i of e)i.sequence!==r?i.sequence!==o?"ok"===i.status||"not-located-on-closest"===i.status?"waypoint"!==i.locationType?"break"!==i.locationType?i.symbol=this.defaultSymbols.middleStop:i.symbol=this.defaultSymbols.breakStop:i.symbol=this.defaultSymbols.waypointStop:i.symbol=this.defaultSymbols.invalidStop:i.symbol=this.defaultSymbols.lastStop:i.symbol=this.defaultSymbols.firstStop}_toRouteLayerSolution(e){var t,r,o,i,s;const n=e.routeResults[0].stops.map((e=>K.fromJSON(e.toJSON())));this._setStopSymbol(n);const l=new pe(n),a=new le(null==(t=e.polygonBarriers)?void 0:t.map((e=>{const t=E.fromJSON(e.toJSON());return t.symbol=this.defaultSymbols.polygonBarriers,t}))),p=new ae(null==(r=e.polylineBarriers)?void 0:r.map((e=>{const t=q.fromJSON(e.toJSON());return t.symbol=this.defaultSymbols.polylineBarriers,t}))),u=new ne(null==(o=e.pointBarriers)?void 0:o.map((e=>{const t=U.fromJSON(e.toJSON());return t.symbol=this.defaultSymbols.pointBarriers,t}))),m=W.fromJSON(e.routeResults[0].route.toJSON());m.symbol=this.defaultSymbols.routeInfo;const y=new se(null==(i=e.routeResults[0].directionPoints)?void 0:i.features.map((e=>{const t=k.fromJSON(e.toJSON());return t.symbol=this.defaultSymbols.directionPoints,t})));return{directionLines:new ie(null==(s=e.routeResults[0].directionLines)?void 0:s.features.map((e=>{const t=F.fromJSON(e.toJSON());return t.symbol=this.defaultSymbols.directionLines,t}))),directionPoints:y,pointBarriers:u,polygonBarriers:a,polylineBarriers:p,routeInfo:m,stops:l}}_writeDirectionLines(){return u(this.directionLines)||!this.directionLines.length?null:{featureSet:{features:this.directionLines.toArray().map((e=>e.toPortalJSON())),geometryType:"esriGeometryPolyline"},layerDefinition:{...this._getLayerDefinition(),drawingInfo:{renderer:{type:"simple",symbol:this.defaultSymbols.directionLines.toJSON()}},fields:F.fields,geometryType:"esriGeometryPolyline",name:"DirectionLines",title:"Direction Lines"},popupInfo:F.popupInfo}}_writeDirectionPoints(){return u(this.directionPoints)||!this.directionPoints.length?null:{featureSet:{features:this.directionPoints.toArray().map((e=>e.toPortalJSON())),geometryType:"esriGeometryPoint"},layerDefinition:{...this._getLayerDefinition(),drawingInfo:{renderer:{type:"simple",symbol:this.defaultSymbols.directionPoints.toJSON()}},fields:k.fields,geometryType:"esriGeometryPoint",name:"DirectionPoints",title:"Direction Points"},popupInfo:k.popupInfo}}_writePointBarriers(){return u(this.pointBarriers)||!this.pointBarriers.length?null:{featureSet:{features:this.pointBarriers.toArray().map((e=>e.toPortalJSON())),geometryType:"esriGeometryPoint"},layerDefinition:{...this._getLayerDefinition(),drawingInfo:{renderer:{type:"simple",symbol:this.defaultSymbols.pointBarriers.toJSON()}},fields:U.fields,geometryType:"esriGeometryPoint",name:"Barrier",title:"Point Barrier"},popupInfo:U.popupInfo}}_writePolygonBarriers(){return u(this.polygonBarriers)||!this.polygonBarriers.length?null:{featureSet:{features:this.polygonBarriers.toArray().map((e=>e.toPortalJSON())),geometryType:"esriGeometryPolygon"},layerDefinition:{...this._getLayerDefinition(),drawingInfo:{renderer:{type:"simple",symbol:this.defaultSymbols.polygonBarriers.toJSON()}},fields:E.fields,geometryType:"esriGeometryPolygon",name:"PolygonBarriers",title:"Polygon Barriers"},popupInfo:E.popupInfo}}_writePolylineBarriers(){return u(this.polylineBarriers)||!this.polylineBarriers.length?null:{featureSet:{features:this.polylineBarriers.toArray().map((e=>e.toPortalJSON())),geometryType:"esriGeometryPolyline"},layerDefinition:{...this._getLayerDefinition(),drawingInfo:{renderer:{type:"simple",symbol:this.defaultSymbols.polylineBarriers.toJSON()}},fields:q.fields,geometryType:"esriGeometryPolyline",name:"PolylineBarriers",title:"Line Barriers"},popupInfo:q.popupInfo}}_writeRouteInfo(){return u(this.routeInfo)?null:{featureSet:{features:[this.routeInfo.toPortalJSON()],geometryType:"esriGeometryPolyline"},layerDefinition:{...this._getLayerDefinition(),drawingInfo:{renderer:{type:"simple",symbol:this.defaultSymbols.routeInfo.toJSON()}},fields:W.fields,geometryType:"esriGeometryPolyline",name:"RouteInfo",title:"Route Details"},popupInfo:W.popupInfo}}_writeStops(){return u(this.stops)||!this.stops.length?null:{featureSet:{features:this.stops.toArray().map((e=>e.toPortalJSON())),geometryType:"esriGeometryPoint"},layerDefinition:{...this._getLayerDefinition(),drawingInfo:{renderer:{type:"uniqueValue",field1:"Sequence",defaultSymbol:this.defaultSymbols.middleStop.toJSON(),uniqueValueInfos:[{value:"1",symbol:this.defaultSymbols.firstStop.toJSON(),label:"First Stop"},{value:`${this.stops.length}`,symbol:this.defaultSymbols.lastStop.toJSON(),label:"Last Stop"}]}},fields:K.fields,geometryType:"esriGeometryPoint",name:"Stops",title:"Stops"},popupInfo:K.popupInfo}}};e([S({readOnly:!0,json:{read:!1,origins:{"portal-item":{write:{allowNull:!0,ignoreOrigin:!0}},"web-map":{write:{overridePolicy(){return{allowNull:!0,ignoreOrigin:null==this.portalItem}}}}}}})],me.prototype,"_featureCollection",void 0),e([v(["web-map","portal-item"],"_featureCollection")],me.prototype,"writeFeatureCollectionWebmap",null),e([S({readOnly:!0,json:{read:!1,origins:{"web-map":{write:{target:"type",overridePolicy(){return{ignoreOrigin:null!=this.portalItem}}}}}}})],me.prototype,"_type",void 0),e([S({nonNullable:!0,type:T})],me.prototype,"defaultSymbols",void 0),e([S({readOnly:!0})],me.prototype,"directionLines",void 0),e([g(["web-map","portal-item"],"directionLines",["layers","featureCollection.layers"])],me.prototype,"readDirectionLines",null),e([S({readOnly:!0})],me.prototype,"directionPoints",void 0),e([g(["web-map","portal-item"],"directionPoints",["layers","featureCollection.layers"])],me.prototype,"readDirectionPoints",null),e([S({readOnly:!0,json:{read:!1,origins:{"web-map":{write:{ignoreOrigin:!0}}}}})],me.prototype,"featureCollectionType",void 0),e([S({readOnly:!0})],me.prototype,"fullExtent",null),e([S({json:{origins:{"web-map":{name:"featureCollection.showLegend"}},write:!0}})],me.prototype,"legendEnabled",void 0),e([S({type:["show","hide"]})],me.prototype,"listMode",void 0),e([S({type:Number,nonNullable:!0,json:{write:!1}})],me.prototype,"maxScale",void 0),e([g(["web-map","portal-item"],"maxScale",["layers","featureCollection.layers"])],me.prototype,"readMaxScale",null),e([S({type:Number,nonNullable:!0,json:{write:!1}})],me.prototype,"minScale",void 0),e([g(["web-map","portal-item"],"minScale",["layers","featureCollection.layers"])],me.prototype,"readMinScale",null),e([S({type:["ArcGISFeatureLayer"],value:"ArcGISFeatureLayer"})],me.prototype,"operationalLayerType",void 0),e([S({nonNullable:!0,type:s.ofType(U)})],me.prototype,"pointBarriers",void 0),e([g(["web-map","portal-item"],"pointBarriers",["layers","featureCollection.layers"])],me.prototype,"readPointBarriers",null),e([S({nonNullable:!0,type:s.ofType(E)})],me.prototype,"polygonBarriers",void 0),e([g(["web-map","portal-item"],"polygonBarriers",["layers","featureCollection.layers"])],me.prototype,"readPolygonBarriers",null),e([S({nonNullable:!0,type:s.ofType(q)})],me.prototype,"polylineBarriers",void 0),e([g(["web-map","portal-item"],"polylineBarriers",["layers","featureCollection.layers"])],me.prototype,"readPolylineBarriers",null),e([S({readOnly:!0})],me.prototype,"routeInfo",void 0),e([g(["web-map","portal-item"],"routeInfo",["layers","featureCollection.layers"])],me.prototype,"readRouteInfo",null),e([S({type:Q})],me.prototype,"spatialReference",void 0),e([g(["web-map","portal-item"],"spatialReference",["layers","featureCollection.layers"])],me.prototype,"readSpatialReference",null),e([S({nonNullable:!0,type:s.ofType(K)})],me.prototype,"stops",void 0),e([g(["web-map","portal-item"],"stops",["layers","featureCollection.layers"])],me.prototype,"readStops",null),e([S()],me.prototype,"title",null),e([S({readOnly:!0,json:{read:!1}})],me.prototype,"type",void 0),e([S()],me.prototype,"url",null),me=e([w("esri.layers.RouteLayer")],me);const ye=me;export{ye as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/core",
3
- "version": "4.23.1",
3
+ "version": "4.23.4",
4
4
  "homepage": "https://js.arcgis.com",
5
5
  "description": "ArcGIS API 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.23/esri/copyright.txt for details.
4
4
  */
5
- const c="20220324",e="9cf26ea170966c3de028527befb4b12c79e5cd94";export{c as buildDate,e as commitHash};
5
+ const e="20220329",c="1e0db03a0283ec14783797fc566220657e8fb826";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.23/esri/copyright.txt for details.
4
4
  */
5
- import{bidiText as t}from"../../core/BidiText.js";import e from"../../core/Logger.js";import{isNone as s,isSome as i}from"../../core/maybe.js";import r from"../../core/ObjectPool.js";import{pt2px as n}from"../../core/screenUtils.js";import{create as o,fromValues as a}from"../../geometry/support/aaBoundingRect.js";import{getBoundsXY as h}from"../../geometry/support/boundsUtils.js";import{isPoint as l,isPolygon as c,isPolyline as m,isExtent as f,isMultipoint as u}from"../../geometry/support/jsonUtils.js";import{SimpleGeometryCursor as _}from"./CIMEffects.js";import{getEffectOperator as d,getPlacementOperator as p}from"./CIMOperators.js";import{Placement as y}from"./CIMPlacements.js";import g from"./CIMResourceManager.js";import{LineCapStyle as x,LineJoinStyle as P}from"./enums.js";import w from"./Rect.js";import{TextRasterizer as M}from"./TextRasterizer.js";import{HAlign as b,VAlign as S}from"../../views/2d/engine/webgl/alignmentUtils.js";import{GLYPH_SIZE as k,MAGIC_LABEL_LINE_HEIGHT as C}from"../../views/2d/engine/webgl/definitions.js";import{shapeGlyphs as R}from"../../views/2d/engine/webgl/mesh/templates/shapingUtils.js";const T=Math.PI/180,I=10,v=e.getLogger("esri.symbols.cim.CIMSymbolDrawHelper");class L{constructor(t){this._t=t}static createIdentity(){return new L([1,0,0,0,1,0])}clone(){const t=this._t;return new L(t.slice())}transform(t){const e=this._t;return[e[0]*t[0]+e[1]*t[1]+e[2],e[3]*t[0]+e[4]*t[1]+e[5]]}static createScale(t,e){return new L([t,0,0,0,e,0])}scale(t,e){const s=this._t;return s[0]*=t,s[1]*=t,s[2]*=t,s[3]*=e,s[4]*=e,s[5]*=e,this}scaleRatio(){return Math.sqrt(this._t[0]*this._t[0]+this._t[1]*this._t[1])}static createTranslate(t,e){return new L([0,0,t,0,0,e])}translate(t,e){const s=this._t;return s[2]+=t,s[5]+=e,this}static createRotate(t){const e=Math.cos(t),s=Math.sin(t);return new L([e,-s,0,s,e,0])}rotate(t){return L.multiply(this,L.createRotate(t),this)}static multiply(t,e,s){const i=t._t,r=e._t,n=i[0]*r[0]+i[3]*r[1],o=i[1]*r[0]+i[4]*r[1],a=i[2]*r[0]+i[5]*r[1]+r[2],h=i[0]*r[3]+i[3]*r[4],l=i[1]*r[3]+i[4]*r[4],c=i[2]*r[3]+i[5]*r[4]+r[5],m=s._t;return m[0]=n,m[1]=o,m[2]=a,m[3]=h,m[4]=l,m[5]=c,s}invert(){const t=this._t;let e=t[0]*t[4]-t[1]*t[3];if(0===e)return new L([0,0,0,0,0,0]);e=1/e;const s=(t[1]*t[5]-t[2]*t[4])*e,i=(t[2]*t[3]-t[0]*t[5])*e,r=t[4]*e,n=-t[1]*e,o=-t[3]*e,a=t[0]*e;return new L([r,n,s,o,a,i])}}class z{constructor(t,e){this._transfos=[],this._sizeTransfos=[],this._geomUnitsPerPoint=1,this._placementPool=new r(y,null,null,100),this._earlyReturn=!1,this._mapRotation=0,this._resourceManager=t||new g,this._transfos.push(e||L.createIdentity()),this._sizeTransfos.push(e?e.scaleRatio():1)}setTransform(t,e){this._transfos=[t||L.createIdentity()],this._sizeTransfos=[e||(t?t.scaleRatio():1)]}setGeomUnitsPerPoint(t){this._geomUnitsPerPoint=t}transformPt(t){return this._transfos[this._transfos.length-1].transform(t)}transformSize(t){return t*this._sizeTransfos[this._sizeTransfos.length-1]}reverseTransformPt(t){return this._transfos[this._transfos.length-1].invert().transform(t)}reverseTransformSize(t){return t/this._sizeTransfos[this._sizeTransfos.length-1]}geomUnitsPerPoint(){return this.isEmbedded()?1:this._geomUnitsPerPoint}isEmbedded(){return this._transfos.length>1}back(){return this._transfos[this._transfos.length-1]}push(t,e){const s=e?t.scaleRatio():1;L.multiply(t,this.back(),t),this._transfos.push(t),this._sizeTransfos.push(this._sizeTransfos[this._sizeTransfos.length-1]*s)}pop(){this._transfos.splice(-1,1),this._sizeTransfos.splice(-1,1)}drawSymbol(t,e){if(t)switch(t.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":this.drawMultiLayerSymbol(t,e);break;case"CIMTextSymbol":this.drawTextSymbol(t,e)}}drawMultiLayerSymbol(t,e){if(!t)return;const s=t.symbolLayers;if(!s)return;const i=t.effects;if(i&&i.length>0){const t=this.executeEffects(i,e);if(t){let e=t.next();for(;e;)this.drawSymbolLayers(s,e),e=t.next()}}else this.drawSymbolLayers(s,e)}executeEffects(t,e){const s=this._resourceManager.geometryEngine;let i=new _(e);for(const r of t){const t=d(r);t&&(i=t.execute(i,r,this.geomUnitsPerPoint(),s))}return i}drawSymbolLayers(t,e){let s=t.length;for(;s--;){const i=t[s];if(!i||!1===i.enable)continue;const r=i.effects;if(r&&r.length>0){const t=this.executeEffects(r,e);if(t){let e=null;for(;(e=t.next())&&(this.drawSymbolLayer(i,e),!this._earlyReturn););}}else this.drawSymbolLayer(i,e);if(this._earlyReturn)return}}drawSymbolLayer(t,e){switch(t.type){case"CIMSolidFill":this.drawSolidFill(e,t.color);break;case"CIMHatchFill":this.drawHatchFill(e,t);break;case"CIMPictureFill":this.drawPictureFill(e,t);break;case"CIMGradientFill":this.drawGradientFill(e,t);break;case"CIMSolidStroke":this.drawSolidStroke(e,t.color,t.width,t.capStyle,t.joinStyle,t.miterLimit);break;case"CIMPictureStroke":this.drawPictureStroke(e,t);break;case"CIMGradientStroke":this.drawGradientStroke(e,t);break;case"CIMCharacterMarker":case"CIMPictureMarker":case"CIMVectorMarker":this.drawMarkerLayer(t,e)}}drawHatchFill(t,e){const s=this._buildHatchPolyline(e,t,this.geomUnitsPerPoint());s&&(this.pushClipPath(t),this.drawMultiLayerSymbol(e.lineSymbol,s),this.popClipPath())}drawPictureFill(t,e){}drawGradientFill(t,e){}drawPictureStroke(t,e){}drawGradientStroke(t,e){}drawMarkerLayer(t,e){const s=t.markerPlacement;if(s){const i=p(s);if(i){const r="CIMMarkerPlacementInsidePolygon"===s.type;r&&this.pushClipPath(e);const n=i.execute(e,s,this.geomUnitsPerPoint(),this._resourceManager.geometryEngine);if(n){let e=null;for(;(e=n.next())&&(this.drawMarker(t,e),!this._earlyReturn););}r&&this.popClipPath()}}else{const s=this._placementPool.acquire();if(l(e))s.tx=e.x,s.ty=e.y,this.drawMarker(t,s);else for(const i of e.points)if(s.tx=i[0],s.ty=i[1],this.drawMarker(t,s),this._earlyReturn)break;this._placementPool.release(s)}}drawMarker(t,e){switch(t.type){case"CIMCharacterMarker":case"CIMPictureMarker":this.drawPictureMarker(t,e);break;case"CIMVectorMarker":this.drawVectorMarker(t,e)}}drawPictureMarker(t,e){var i,r,n,o,a;if(!t)return;const h=this._resourceManager.getResource(t.url),l=null!=(i=t.size)?i:10;if(s(h)||l<=0)return;const c=h.width,m=h.height;if(!c||!m)return;const f=c/m,u=null!=(r=t.scaleX)?r:1,_=L.createIdentity(),d=t.anchorPoint;if(d){let e=d.x,s=d.y;"Absolute"!==t.anchorPointUnits&&(e*=l*f*u,s*=l),_.translate(-e,-s)}let p=null!=(n=t.rotation)?n:0;t.rotateClockwise&&(p=-p),this._mapRotation&&(p+=this._mapRotation),p&&_.rotate(p*T);let y=null!=(o=t.offsetX)?o:0,g=null!=(a=t.offsetY)?a:0;if(y||g){if(this._mapRotation){const t=T*this._mapRotation,e=Math.cos(t),s=Math.sin(t),i=y*s+g*e;y=y*e-g*s,g=i}_.translate(y,g)}const x=this.geomUnitsPerPoint();1!==x&&_.scale(x,x);const P=e.getAngle();P&&_.rotate(P),_.translate(e.tx,e.ty),this.push(_,!1),this.drawImage(t.url,l,t.scaleX),this.pop()}drawVectorMarker(t,e){var s,i,r,n;if(!t)return;const o=t.markerGraphics;if(!o)return;const a=null!=(s=t.size)?s:10,h=t.frame,l=h?h.ymax-h.ymin:0,c=a&&l?a/l:1,m=L.createIdentity();h&&m.translate(.5*-(h.xmax+h.xmin),.5*-(h.ymax+h.ymin));const f=t.anchorPoint;if(f){let e=f.x,s=f.y;"Absolute"!==t.anchorPointUnits?h&&(e*=h.xmax-h.xmin,s*=h.ymax-h.ymin):(e/=c,s/=c),m.translate(-e,-s)}1!==c&&m.scale(c,c);let u=null!=(i=t.rotation)?i:0;t.rotateClockwise&&(u=-u),this._mapRotation&&(u+=this._mapRotation),u&&m.rotate(u*T);let _=null!=(r=t.offsetX)?r:0,d=null!=(n=t.offsetY)?n:0;if(_||d){if(this._mapRotation){const t=T*this._mapRotation,e=Math.cos(t),s=Math.sin(t),i=_*s+d*e;_=_*e-d*s,d=i}m.translate(_,d)}const p=this.geomUnitsPerPoint();1!==p&&m.scale(p,p);const y=e.getAngle();y&&m.rotate(y),m.translate(e.tx,e.ty),this.push(m,t.scaleSymbolsProportionally);for(const g of o)if(g&&g.symbol&&g.geometry||v.error("Invalid marker graphic",g),this.drawSymbol(g.symbol,g.geometry),this._earlyReturn)break;this.pop()}drawTextSymbol(t,e){var s,i,r,n;if(!t)return;if(!l(e))return;if((null!=(s=t.height)?s:10)<=0)return;const o=L.createIdentity();let a=null!=(i=t.angle)?i:0;a=-a,a&&o.rotate(a*T);const h=null!=(r=t.offsetX)?r:0,c=null!=(n=t.offsetY)?n:0;(h||c)&&o.translate(h,c);const m=this.geomUnitsPerPoint();1!==m&&o.scale(m,m),o.translate(e.x,e.y),this.push(o,!1),this.drawText(t),this.pop()}_buildHatchPolyline(t,e,s){let i=(void 0!==t.separation?t.separation:4)*s,r=void 0!==t.rotation?t.rotation:0;if(0===i)return null;i<0&&(i=-i);let n=0;const a=.5*i;for(;n>a;)n-=i;for(;n<-a;)n+=i;const l=o();h(l,e),l[0]-=a,l[1]-=a,l[2]+=a,l[3]+=a;const c=[[l[0],l[1]],[l[0],l[3]],[l[2],l[3]],[l[2],l[1]]];for(;r>180;)r-=180;for(;r<0;)r+=180;const m=Math.cos(r*T),f=Math.sin(r*T),u=-i*f,_=i*m;let d,p,y,g;n=(void 0!==t.offsetX?t.offsetX*s:0)*f-(void 0!==t.offsetY?t.offsetY*s:0)*m,d=y=Number.MAX_VALUE,p=g=-Number.MAX_VALUE;for(const o of c){const t=o[0],e=o[1],s=m*t+f*e,i=-f*t+m*e;d=Math.min(d,s),y=Math.min(y,i),p=Math.max(p,s),g=Math.max(g,i)}y=Math.floor(y/i)*i;let x=m*d-f*y-u*n/i,P=f*d+m*y-_*n/i,w=m*p-f*y-u*n/i,M=f*p+m*y-_*n/i;const b=1+Math.round((g-y)/i),S=[];for(let o=0;o<b;o++)x+=u,P+=_,w+=u,M+=_,S.push([[x,P],[w,M]]);return{paths:S}}}class U extends z{constructor(t,e){super(t,e),this.reset()}reset(){this._xmin=this._ymin=1/0,this._xmax=this._ymax=-1/0,this._clipCount=0}envelope(){return new w(this._xmin,this._ymin,this._xmax-this._xmin,this._ymax-this._ymin)}bounds(){return a(this._xmin,this._ymin,this._xmax,this._ymax)}drawSolidFill(t){if(t&&!(this._clipCount>0))if(c(t))this._processPath(t.rings,0);else if(m(t))this._processPath(t.paths,0);else if(f(t)){const e=A(t);e&&this._processPath(e.rings,0)}else console.error("drawSolidFill Unexpected geometry type!")}drawSolidStroke(t,e,s){if(!t||this._clipCount>0)return;const i=.5*this.transformSize(s);if(c(t))this._processPath(t.rings,i);else if(m(t))this._processPath(t.paths,i);else if(f(t)){const e=A(t);e&&this._processPath(e.rings,i)}else console.error("drawSolidStroke unexpected geometry type!")}pushClipPath(t){this.drawSolidFill(t),++this._clipCount}popClipPath(){--this._clipCount}drawImage(t,e,s){let r=s*e,n=e;const o=this._resourceManager.getResource(t);!e&&i(o)&&(r=s*o.width,n=o.height),this._merge(this.transformPt([-r/2,-n/2]),0),this._merge(this.transformPt([-r/2,n/2]),0),this._merge(this.transformPt([r/2,-n/2]),0),this._merge(this.transformPt([r/2,n/2]),0)}drawText(t){this._textRasterizer||(this._textRasterizer=new M)}_processPath(t,e){if(t)for(const s of t){const t=s?s.length:0;if(t>1){this._merge(this.transformPt(s[0]),e);for(let i=1;i<t;++i)this._merge(this.transformPt(s[i]),e)}}}_merge(t,e){t[0]-e<this._xmin&&(this._xmin=t[0]-e),t[0]+e>this._xmax&&(this._xmax=t[0]+e),t[1]-e<this._ymin&&(this._ymin=t[1]-e),t[1]+e>this._ymax&&(this._ymax=t[1]+e)}}class F extends z{constructor(){super(...arguments),this._searchPoint=[0,0],this._searchDistPoint=0}hitTest(t,e,s,i,r,o){const a=o*n(1);this.setTransform(),this.setGeomUnitsPerPoint(a),this._searchPoint=[(t[0]+t[2])/2,(t[1]+t[3])/2],this._searchDistPoint=(t[2]-t[0])/2/a,this._textInfo=i;const h=e&&("CIMPointSymbol"===e.type&&"Map"!==e.angleAlignment||"CIMTextSymbol"===e.type);return this._mapRotation=h?r:0,this._earlyReturn=!1,this.drawSymbol(e,s),this._earlyReturn}drawSolidFill(t,e){this._hitTestFill(t)}drawHatchFill(t,e){this._hitTestFill(t)}drawPictureFill(t,e){this._hitTestFill(t)}drawGradientFill(t,e){this._hitTestFill(t)}drawSolidStroke(t,e,s,i,r,n){this._hitTestStroke(t,s)}drawPictureStroke(t,e){this._hitTestStroke(t,e.width)}drawGradientStroke(t,e){this._hitTestStroke(t,e.width)}pushClipPath(t){}popClipPath(){}drawImage(t,e,i){const r=this._resourceManager.getResource(t);if(s(r)||0===r.height||0===e)return;const n=e*this.geomUnitsPerPoint(),o=n*i*(r.width/r.height),a=this.reverseTransformPt(this._searchPoint),h=this._searchDistPoint;Math.abs(a[0])<o/2+h&&Math.abs(a[1])<n/2+h&&(this._earlyReturn=!0)}drawText(e){var s,i;const r=this._textInfo;if(!r)return;const n=r.get(e);if(!n)return;const{text:o,mosaicItem:a}=n;if(!a||0===a.glyphMosaicItems.length)return;const h=null!=(s=e.height)?s:I,l=B(e.lineGapType,null!=(i=e.lineGap)?i:0,h),c=t(o)[1],m=a.glyphMosaicItems,f=R(m,c,{scale:h/k,angle:0,xOffset:0,yOffset:0,hAlign:G(e.horizontalAlignment),vAlign:E(e.verticalAlignment),maxLineWidth:512,lineHeight:C*Math.max(.25,Math.min(l||1,4)),decoration:e.font.decoration||"none",isCIM:!0}),u=this.reverseTransformPt(this._searchPoint),_=u[0],d=u[1];for(const t of f.glyphs)if(_>t.xTopLeft&&_<t.xBottomRight&&d>-t.yBottomRight&&d<-t.yTopLeft){this._earlyReturn=!0;break}}_hitTestFill(t){let e=null;if(f(t)){const s=t;e=[[[s.xmin,s.ymin],[s.xmin,s.ymax],[s.xmax,s.ymax],[s.xmax,s.ymin],[s.xmin,s.ymin]]]}else if(c(t))e=t.rings;else{if(!m(t))return;e=t.paths}const s=this.reverseTransformPt(this._searchPoint);this._pointInPolygon(s,e)&&(this._earlyReturn=!0);const i=this.reverseTransformSize(this._searchDistPoint)*this.geomUnitsPerPoint();this._nearLine(s,e,i)&&(this._earlyReturn=!0)}_hitTestStroke(t,e){let s=null;if(f(t)){const e=t;s=[[[e.xmin,e.ymin],[e.xmin,e.ymax],[e.xmax,e.ymax],[e.xmax,e.ymin],[e.xmin,e.ymin]]]}else if(c(t))s=t.rings;else{if(!m(t))return;s=t.paths}const i=this.reverseTransformPt(this._searchPoint),r=e*this.geomUnitsPerPoint(),n=this.reverseTransformSize(this._searchDistPoint)*this.geomUnitsPerPoint();this._nearLine(i,s,r/2+n)&&(this._earlyReturn=!0)}_pointInPolygon(t,e){let s=0;for(const i of e){const e=i.length;for(let r=1;r<e;++r){const e=i[r-1],n=i[r];if(e[1]>t[1]==n[1]>t[1])continue;(n[0]-e[0])*(t[1]-e[1])-(n[1]-e[1])*(t[0]-e[0])>0?s++:s--}}return 0!==s}_nearLine(t,e,s){for(const i of e){const e=i.length;for(let r=1;r<e;++r){const e=i[r-1],n=i[r];let o=(n[0]-e[0])*(n[0]-e[0])+(n[1]-e[1])*(n[1]-e[1]);if(0===o)continue;o=Math.sqrt(o);const a=((n[0]-e[0])*(t[1]-e[1])-(n[1]-e[1])*(t[0]-e[0]))/o;if(Math.abs(a)<s){const i=((n[0]-e[0])*(t[0]-e[0])+(n[1]-e[1])*(t[1]-e[1]))/o;if(i>-s&&i<o+s)return!0}}}return!1}}class j extends z{constructor(t,e,s){super(e,s),this._ctx=t}drawSolidFill(t,e){if(!t)return;if(c(t))this._buildPath(t.rings,!0);else if(m(t))this._buildPath(t.paths,!0);else if(f(t))this._buildPath(A(t).rings,!0);else{if(!u(t))return;console.log("CanvasDrawHelper.drawSolidFill - No implementation!")}const s=this._ctx;s.fillStyle="string"==typeof e?e:"rgba("+Math.round(e[0])+","+Math.round(e[1])+","+Math.round(e[2])+","+e[3]/255+")",s.fill("evenodd")}drawSolidStroke(t,e,s,i,r,n){if(!t||!e||0===s)return;if(c(t))this._buildPath(t.rings,!0);else if(m(t))this._buildPath(t.paths,!1);else{if(!f(t))return void console.log("CanvasDrawHelper.drawSolidStroke isn't implemented!");this._buildPath(A(t).rings,!0)}const o=this._ctx;o.strokeStyle="string"==typeof e?e:"rgba("+Math.round(e[0])+","+Math.round(e[1])+","+Math.round(e[2])+","+e[3]/255+")",o.lineWidth=this.transformSize(s)+.5,this._setCapStyle(i),this._setJoinStyle(r),o.miterLimit=n,o.stroke()}pushClipPath(t){if(this._ctx.save(),c(t))this._buildPath(t.rings,!0);else if(m(t))this._buildPath(t.paths,!0);else{if(!f(t))return;this._buildPath(A(t).rings,!0)}this._ctx.clip("evenodd")}popClipPath(){this._ctx.restore()}drawImage(t,e,i){const r=this._resourceManager.getResource(t);if(s(r))return;const n=this._ctx,o=n.canvas.width,a=n.canvas.height;let h=e*i*(r.width/r.height),l=i*e;e||(h=i*r.width,l=i*r.height),this._ctx.drawImage(r,0,0,r.width,r.height,0,0,Math.min(this.transformSize(h),o),Math.min(this.transformSize(l),a))}drawText(t){this._textRasterizer||(this._textRasterizer=new M)}_buildPath(t,e){const s=this._ctx;if(s.beginPath(),t)for(const i of t){const t=i?i.length:0;if(t>1){let r=this.transformPt(i[0]);s.moveTo(r[0],r[1]);for(let e=1;e<t;++e)r=this.transformPt(i[e]),s.lineTo(r[0],r[1]);e&&s.closePath()}}}_setCapStyle(t){switch(t){case x.Butt:this._ctx.lineCap="butt";break;case x.Round:this._ctx.lineCap="round";break;case x.Square:this._ctx.lineCap="square"}}_setJoinStyle(t){switch(t){case P.Bevel:this._ctx.lineJoin="bevel";break;case P.Round:this._ctx.lineJoin="round";break;case P.Miter:this._ctx.lineJoin="miter"}}}const A=t=>t?{spatialReference:t.spatialReference,rings:[[[t.xmin,t.ymin],[t.xmin,t.ymax],[t.xmax,t.ymax],[t.xmax,t.ymin],[t.xmin,t.ymin]]]}:null,G=t=>{switch(t){case"Left":return b.Left;case"Right":return b.Right;case"Center":case"Justify":return b.Center}},E=t=>{switch(t){case"Top":return S.Top;case"Center":return S.Center;case"Bottom":return S.Bottom;case"Baseline":return S.Baseline}},B=(t,e,s)=>{switch(t){case"ExtraLeading":return 1+e/s;case"Multiple":return e;case"Exact":return e/s}};export{z as CIMSymbolDrawHelper,T as C_DEG_TO_RAD,j as CanvasDrawHelper,U as EnvDrawHelper,F as HittestDrawHelper,L as Transformation,G as horizontalAlignment2HAlign,B as lineGapType2LineHeight,E as verticalAlignment2VAlign};
5
+ import{bidiText as t}from"../../core/BidiText.js";import e from"../../core/Logger.js";import{isNone as s,isSome as i}from"../../core/maybe.js";import r from"../../core/ObjectPool.js";import{pt2px as n}from"../../core/screenUtils.js";import{create as o,fromValues as a}from"../../geometry/support/aaBoundingRect.js";import{getBoundsXY as h}from"../../geometry/support/boundsUtils.js";import{polygonCentroid as l}from"../../geometry/support/centroid.js";import{isPoint as c,isPolygon as m,isPolyline as f,isExtent as u,isMultipoint as _}from"../../geometry/support/jsonUtils.js";import{SimpleGeometryCursor as d}from"./CIMEffects.js";import{getEffectOperator as p,getPlacementOperator as y}from"./CIMOperators.js";import{Placement as g}from"./CIMPlacements.js";import x from"./CIMResourceManager.js";import{LineCapStyle as P,LineJoinStyle as w}from"./enums.js";import M from"./Rect.js";import{TextRasterizer as b}from"./TextRasterizer.js";import{HAlign as S,VAlign as k}from"../../views/2d/engine/webgl/alignmentUtils.js";import{GLYPH_SIZE as C,MAGIC_LABEL_LINE_HEIGHT as R}from"../../views/2d/engine/webgl/definitions.js";import{shapeGlyphs as T}from"../../views/2d/engine/webgl/mesh/templates/shapingUtils.js";const I=Math.PI/180,v=10,L=e.getLogger("esri.symbols.cim.CIMSymbolDrawHelper");class z{constructor(t){this._t=t}static createIdentity(){return new z([1,0,0,0,1,0])}clone(){const t=this._t;return new z(t.slice())}transform(t){const e=this._t;return[e[0]*t[0]+e[1]*t[1]+e[2],e[3]*t[0]+e[4]*t[1]+e[5]]}static createScale(t,e){return new z([t,0,0,0,e,0])}scale(t,e){const s=this._t;return s[0]*=t,s[1]*=t,s[2]*=t,s[3]*=e,s[4]*=e,s[5]*=e,this}scaleRatio(){return Math.sqrt(this._t[0]*this._t[0]+this._t[1]*this._t[1])}static createTranslate(t,e){return new z([0,0,t,0,0,e])}translate(t,e){const s=this._t;return s[2]+=t,s[5]+=e,this}static createRotate(t){const e=Math.cos(t),s=Math.sin(t);return new z([e,-s,0,s,e,0])}rotate(t){return z.multiply(this,z.createRotate(t),this)}static multiply(t,e,s){const i=t._t,r=e._t,n=i[0]*r[0]+i[3]*r[1],o=i[1]*r[0]+i[4]*r[1],a=i[2]*r[0]+i[5]*r[1]+r[2],h=i[0]*r[3]+i[3]*r[4],l=i[1]*r[3]+i[4]*r[4],c=i[2]*r[3]+i[5]*r[4]+r[5],m=s._t;return m[0]=n,m[1]=o,m[2]=a,m[3]=h,m[4]=l,m[5]=c,s}invert(){const t=this._t;let e=t[0]*t[4]-t[1]*t[3];if(0===e)return new z([0,0,0,0,0,0]);e=1/e;const s=(t[1]*t[5]-t[2]*t[4])*e,i=(t[2]*t[3]-t[0]*t[5])*e,r=t[4]*e,n=-t[1]*e,o=-t[3]*e,a=t[0]*e;return new z([r,n,s,o,a,i])}}class U{constructor(t,e){this._transfos=[],this._sizeTransfos=[],this._geomUnitsPerPoint=1,this._placementPool=new r(g,null,null,100),this._earlyReturn=!1,this._mapRotation=0,this._resourceManager=t||new x,this._transfos.push(e||z.createIdentity()),this._sizeTransfos.push(e?e.scaleRatio():1)}setTransform(t,e){this._transfos=[t||z.createIdentity()],this._sizeTransfos=[e||(t?t.scaleRatio():1)]}setGeomUnitsPerPoint(t){this._geomUnitsPerPoint=t}transformPt(t){return this._transfos[this._transfos.length-1].transform(t)}transformSize(t){return t*this._sizeTransfos[this._sizeTransfos.length-1]}reverseTransformPt(t){return this._transfos[this._transfos.length-1].invert().transform(t)}reverseTransformSize(t){return t/this._sizeTransfos[this._sizeTransfos.length-1]}geomUnitsPerPoint(){return this.isEmbedded()?1:this._geomUnitsPerPoint}isEmbedded(){return this._transfos.length>1}back(){return this._transfos[this._transfos.length-1]}push(t,e){const s=e?t.scaleRatio():1;z.multiply(t,this.back(),t),this._transfos.push(t),this._sizeTransfos.push(this._sizeTransfos[this._sizeTransfos.length-1]*s)}pop(){this._transfos.splice(-1,1),this._sizeTransfos.splice(-1,1)}drawSymbol(t,e){if(t)switch(t.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":this.drawMultiLayerSymbol(t,e);break;case"CIMTextSymbol":this.drawTextSymbol(t,e)}}drawMultiLayerSymbol(t,e){if(!t)return;const s=t.symbolLayers;if(!s)return;const i=t.effects;if(i&&i.length>0){const t=this.executeEffects(i,e);if(t){let e=t.next();for(;e;)this.drawSymbolLayers(s,e),e=t.next()}}else this.drawSymbolLayers(s,e)}executeEffects(t,e){const s=this._resourceManager.geometryEngine;let i=new d(e);for(const r of t){const t=p(r);t&&(i=t.execute(i,r,this.geomUnitsPerPoint(),s))}return i}drawSymbolLayers(t,e){let s=t.length;for(;s--;){const i=t[s];if(!i||!1===i.enable)continue;const r=i.effects;if(r&&r.length>0){const t=this.executeEffects(r,e);if(t){let e=null;for(;(e=t.next())&&(this.drawSymbolLayer(i,e),!this._earlyReturn););}}else this.drawSymbolLayer(i,e);if(this._earlyReturn)return}}drawSymbolLayer(t,e){switch(t.type){case"CIMSolidFill":this.drawSolidFill(e,t.color);break;case"CIMHatchFill":this.drawHatchFill(e,t);break;case"CIMPictureFill":this.drawPictureFill(e,t);break;case"CIMGradientFill":this.drawGradientFill(e,t);break;case"CIMSolidStroke":this.drawSolidStroke(e,t.color,t.width,t.capStyle,t.joinStyle,t.miterLimit);break;case"CIMPictureStroke":this.drawPictureStroke(e,t);break;case"CIMGradientStroke":this.drawGradientStroke(e,t);break;case"CIMCharacterMarker":case"CIMPictureMarker":case"CIMVectorMarker":this.drawMarkerLayer(t,e)}}drawHatchFill(t,e){const s=this._buildHatchPolyline(e,t,this.geomUnitsPerPoint());s&&(this.pushClipPath(t),this.drawMultiLayerSymbol(e.lineSymbol,s),this.popClipPath())}drawPictureFill(t,e){}drawGradientFill(t,e){}drawPictureStroke(t,e){}drawGradientStroke(t,e){}drawMarkerLayer(t,e){const s=t.markerPlacement;if(s){const i=y(s);if(i){const r="CIMMarkerPlacementInsidePolygon"===s.type;r&&this.pushClipPath(e);const n=i.execute(e,s,this.geomUnitsPerPoint(),this._resourceManager.geometryEngine);if(n){let e=null;for(;(e=n.next())&&(this.drawMarker(t,e),!this._earlyReturn););}r&&this.popClipPath()}}else{const s=this._placementPool.acquire();if(c(e))s.tx=e.x,s.ty=e.y,this.drawMarker(t,s);else if(m(e))[s.tx,s.ty]=l(e),this.drawMarker(t,s);else for(const i of e.points)if(s.tx=i[0],s.ty=i[1],this.drawMarker(t,s),this._earlyReturn)break;this._placementPool.release(s)}}drawMarker(t,e){switch(t.type){case"CIMCharacterMarker":case"CIMPictureMarker":this.drawPictureMarker(t,e);break;case"CIMVectorMarker":this.drawVectorMarker(t,e)}}drawPictureMarker(t,e){var i,r,n,o,a;if(!t)return;const h=this._resourceManager.getResource(t.url),l=null!=(i=t.size)?i:10;if(s(h)||l<=0)return;const c=h.width,m=h.height;if(!c||!m)return;const f=c/m,u=null!=(r=t.scaleX)?r:1,_=z.createIdentity(),d=t.anchorPoint;if(d){let e=d.x,s=d.y;"Absolute"!==t.anchorPointUnits&&(e*=l*f*u,s*=l),_.translate(-e,-s)}let p=null!=(n=t.rotation)?n:0;t.rotateClockwise&&(p=-p),this._mapRotation&&(p+=this._mapRotation),p&&_.rotate(p*I);let y=null!=(o=t.offsetX)?o:0,g=null!=(a=t.offsetY)?a:0;if(y||g){if(this._mapRotation){const t=I*this._mapRotation,e=Math.cos(t),s=Math.sin(t),i=y*s+g*e;y=y*e-g*s,g=i}_.translate(y,g)}const x=this.geomUnitsPerPoint();1!==x&&_.scale(x,x);const P=e.getAngle();P&&_.rotate(P),_.translate(e.tx,e.ty),this.push(_,!1),this.drawImage(t.url,l,t.scaleX),this.pop()}drawVectorMarker(t,e){var s,i,r,n;if(!t)return;const o=t.markerGraphics;if(!o)return;const a=null!=(s=t.size)?s:10,h=t.frame,l=h?h.ymax-h.ymin:0,c=a&&l?a/l:1,m=z.createIdentity();h&&m.translate(.5*-(h.xmax+h.xmin),.5*-(h.ymax+h.ymin));const f=t.anchorPoint;if(f){let e=f.x,s=f.y;"Absolute"!==t.anchorPointUnits?h&&(e*=h.xmax-h.xmin,s*=h.ymax-h.ymin):(e/=c,s/=c),m.translate(-e,-s)}1!==c&&m.scale(c,c);let u=null!=(i=t.rotation)?i:0;t.rotateClockwise&&(u=-u),this._mapRotation&&(u+=this._mapRotation),u&&m.rotate(u*I);let _=null!=(r=t.offsetX)?r:0,d=null!=(n=t.offsetY)?n:0;if(_||d){if(this._mapRotation){const t=I*this._mapRotation,e=Math.cos(t),s=Math.sin(t),i=_*s+d*e;_=_*e-d*s,d=i}m.translate(_,d)}const p=this.geomUnitsPerPoint();1!==p&&m.scale(p,p);const y=e.getAngle();y&&m.rotate(y),m.translate(e.tx,e.ty),this.push(m,t.scaleSymbolsProportionally);for(const g of o)if(g&&g.symbol&&g.geometry||L.error("Invalid marker graphic",g),this.drawSymbol(g.symbol,g.geometry),this._earlyReturn)break;this.pop()}drawTextSymbol(t,e){var s,i,r,n;if(!t)return;if(!c(e))return;if((null!=(s=t.height)?s:10)<=0)return;const o=z.createIdentity();let a=null!=(i=t.angle)?i:0;a=-a,a&&o.rotate(a*I);const h=null!=(r=t.offsetX)?r:0,l=null!=(n=t.offsetY)?n:0;(h||l)&&o.translate(h,l);const m=this.geomUnitsPerPoint();1!==m&&o.scale(m,m),o.translate(e.x,e.y),this.push(o,!1),this.drawText(t),this.pop()}_buildHatchPolyline(t,e,s){let i=(void 0!==t.separation?t.separation:4)*s,r=void 0!==t.rotation?t.rotation:0;if(0===i)return null;i<0&&(i=-i);let n=0;const a=.5*i;for(;n>a;)n-=i;for(;n<-a;)n+=i;const l=o();h(l,e),l[0]-=a,l[1]-=a,l[2]+=a,l[3]+=a;const c=[[l[0],l[1]],[l[0],l[3]],[l[2],l[3]],[l[2],l[1]]];for(;r>180;)r-=180;for(;r<0;)r+=180;const m=Math.cos(r*I),f=Math.sin(r*I),u=-i*f,_=i*m;let d,p,y,g;n=(void 0!==t.offsetX?t.offsetX*s:0)*f-(void 0!==t.offsetY?t.offsetY*s:0)*m,d=y=Number.MAX_VALUE,p=g=-Number.MAX_VALUE;for(const o of c){const t=o[0],e=o[1],s=m*t+f*e,i=-f*t+m*e;d=Math.min(d,s),y=Math.min(y,i),p=Math.max(p,s),g=Math.max(g,i)}y=Math.floor(y/i)*i;let x=m*d-f*y-u*n/i,P=f*d+m*y-_*n/i,w=m*p-f*y-u*n/i,M=f*p+m*y-_*n/i;const b=1+Math.round((g-y)/i),S=[];for(let o=0;o<b;o++)x+=u,P+=_,w+=u,M+=_,S.push([[x,P],[w,M]]);return{paths:S}}}class F extends U{constructor(t,e){super(t,e),this.reset()}reset(){this._xmin=this._ymin=1/0,this._xmax=this._ymax=-1/0,this._clipCount=0}envelope(){return new M(this._xmin,this._ymin,this._xmax-this._xmin,this._ymax-this._ymin)}bounds(){return a(this._xmin,this._ymin,this._xmax,this._ymax)}drawSolidFill(t){if(t&&!(this._clipCount>0))if(m(t))this._processPath(t.rings,0);else if(f(t))this._processPath(t.paths,0);else if(u(t)){const e=G(t);e&&this._processPath(e.rings,0)}else console.error("drawSolidFill Unexpected geometry type!")}drawSolidStroke(t,e,s){if(!t||this._clipCount>0)return;const i=.5*this.transformSize(s);if(m(t))this._processPath(t.rings,i);else if(f(t))this._processPath(t.paths,i);else if(u(t)){const e=G(t);e&&this._processPath(e.rings,i)}else console.error("drawSolidStroke unexpected geometry type!")}pushClipPath(t){this.drawSolidFill(t),++this._clipCount}popClipPath(){--this._clipCount}drawImage(t,e,s){let r=s*e,n=e;const o=this._resourceManager.getResource(t);!e&&i(o)&&(r=s*o.width,n=o.height),this._merge(this.transformPt([-r/2,-n/2]),0),this._merge(this.transformPt([-r/2,n/2]),0),this._merge(this.transformPt([r/2,-n/2]),0),this._merge(this.transformPt([r/2,n/2]),0)}drawText(t){this._textRasterizer||(this._textRasterizer=new b)}_processPath(t,e){if(t)for(const s of t){const t=s?s.length:0;if(t>1){this._merge(this.transformPt(s[0]),e);for(let i=1;i<t;++i)this._merge(this.transformPt(s[i]),e)}}}_merge(t,e){t[0]-e<this._xmin&&(this._xmin=t[0]-e),t[0]+e>this._xmax&&(this._xmax=t[0]+e),t[1]-e<this._ymin&&(this._ymin=t[1]-e),t[1]+e>this._ymax&&(this._ymax=t[1]+e)}}class j extends U{constructor(){super(...arguments),this._searchPoint=[0,0],this._searchDistPoint=0}hitTest(t,e,s,i,r,o){const a=o*n(1);this.setTransform(),this.setGeomUnitsPerPoint(a),this._searchPoint=[(t[0]+t[2])/2,(t[1]+t[3])/2],this._searchDistPoint=(t[2]-t[0])/2/a,this._textInfo=i;const h=e&&("CIMPointSymbol"===e.type&&"Map"!==e.angleAlignment||"CIMTextSymbol"===e.type);return this._mapRotation=h?r:0,this._earlyReturn=!1,this.drawSymbol(e,s),this._earlyReturn}drawSolidFill(t,e){this._hitTestFill(t)}drawHatchFill(t,e){this._hitTestFill(t)}drawPictureFill(t,e){this._hitTestFill(t)}drawGradientFill(t,e){this._hitTestFill(t)}drawSolidStroke(t,e,s,i,r,n){this._hitTestStroke(t,s)}drawPictureStroke(t,e){this._hitTestStroke(t,e.width)}drawGradientStroke(t,e){this._hitTestStroke(t,e.width)}pushClipPath(t){}popClipPath(){}drawImage(t,e,i){const r=this._resourceManager.getResource(t);if(s(r)||0===r.height||0===e)return;const n=e*this.geomUnitsPerPoint(),o=n*i*(r.width/r.height),a=this.reverseTransformPt(this._searchPoint),h=this._searchDistPoint;Math.abs(a[0])<o/2+h&&Math.abs(a[1])<n/2+h&&(this._earlyReturn=!0)}drawText(e){var s,i;const r=this._textInfo;if(!r)return;const n=r.get(e);if(!n)return;const{text:o,mosaicItem:a}=n;if(!a||0===a.glyphMosaicItems.length)return;const h=null!=(s=e.height)?s:v,l=H(e.lineGapType,null!=(i=e.lineGap)?i:0,h),c=t(o)[1],m=a.glyphMosaicItems,f=T(m,c,{scale:h/C,angle:0,xOffset:0,yOffset:0,hAlign:E(e.horizontalAlignment),vAlign:B(e.verticalAlignment),maxLineWidth:512,lineHeight:R*Math.max(.25,Math.min(l||1,4)),decoration:e.font.decoration||"none",isCIM:!0}),u=this.reverseTransformPt(this._searchPoint),_=u[0],d=u[1];for(const t of f.glyphs)if(_>t.xTopLeft&&_<t.xBottomRight&&d>-t.yBottomRight&&d<-t.yTopLeft){this._earlyReturn=!0;break}}_hitTestFill(t){let e=null;if(u(t)){const s=t;e=[[[s.xmin,s.ymin],[s.xmin,s.ymax],[s.xmax,s.ymax],[s.xmax,s.ymin],[s.xmin,s.ymin]]]}else if(m(t))e=t.rings;else{if(!f(t))return;e=t.paths}const s=this.reverseTransformPt(this._searchPoint);this._pointInPolygon(s,e)&&(this._earlyReturn=!0);const i=this.reverseTransformSize(this._searchDistPoint)*this.geomUnitsPerPoint();this._nearLine(s,e,i)&&(this._earlyReturn=!0)}_hitTestStroke(t,e){let s=null;if(u(t)){const e=t;s=[[[e.xmin,e.ymin],[e.xmin,e.ymax],[e.xmax,e.ymax],[e.xmax,e.ymin],[e.xmin,e.ymin]]]}else if(m(t))s=t.rings;else{if(!f(t))return;s=t.paths}const i=this.reverseTransformPt(this._searchPoint),r=e*this.geomUnitsPerPoint(),n=this.reverseTransformSize(this._searchDistPoint)*this.geomUnitsPerPoint();this._nearLine(i,s,r/2+n)&&(this._earlyReturn=!0)}_pointInPolygon(t,e){let s=0;for(const i of e){const e=i.length;for(let r=1;r<e;++r){const e=i[r-1],n=i[r];if(e[1]>t[1]==n[1]>t[1])continue;(n[0]-e[0])*(t[1]-e[1])-(n[1]-e[1])*(t[0]-e[0])>0?s++:s--}}return 0!==s}_nearLine(t,e,s){for(const i of e){const e=i.length;for(let r=1;r<e;++r){const e=i[r-1],n=i[r];let o=(n[0]-e[0])*(n[0]-e[0])+(n[1]-e[1])*(n[1]-e[1]);if(0===o)continue;o=Math.sqrt(o);const a=((n[0]-e[0])*(t[1]-e[1])-(n[1]-e[1])*(t[0]-e[0]))/o;if(Math.abs(a)<s){const i=((n[0]-e[0])*(t[0]-e[0])+(n[1]-e[1])*(t[1]-e[1]))/o;if(i>-s&&i<o+s)return!0}}}return!1}}class A extends U{constructor(t,e,s){super(e,s),this._ctx=t}drawSolidFill(t,e){if(!t)return;if(m(t))this._buildPath(t.rings,!0);else if(f(t))this._buildPath(t.paths,!0);else if(u(t))this._buildPath(G(t).rings,!0);else{if(!_(t))return;console.log("CanvasDrawHelper.drawSolidFill - No implementation!")}const s=this._ctx;s.fillStyle="string"==typeof e?e:"rgba("+Math.round(e[0])+","+Math.round(e[1])+","+Math.round(e[2])+","+e[3]/255+")",s.fill("evenodd")}drawSolidStroke(t,e,s,i,r,n){if(!t||!e||0===s)return;if(m(t))this._buildPath(t.rings,!0);else if(f(t))this._buildPath(t.paths,!1);else{if(!u(t))return void console.log("CanvasDrawHelper.drawSolidStroke isn't implemented!");this._buildPath(G(t).rings,!0)}const o=this._ctx;o.strokeStyle="string"==typeof e?e:"rgba("+Math.round(e[0])+","+Math.round(e[1])+","+Math.round(e[2])+","+e[3]/255+")",o.lineWidth=this.transformSize(s)+.5,this._setCapStyle(i),this._setJoinStyle(r),o.miterLimit=n,o.stroke()}pushClipPath(t){if(this._ctx.save(),m(t))this._buildPath(t.rings,!0);else if(f(t))this._buildPath(t.paths,!0);else{if(!u(t))return;this._buildPath(G(t).rings,!0)}this._ctx.clip("evenodd")}popClipPath(){this._ctx.restore()}drawImage(t,e,i){const r=this._resourceManager.getResource(t);if(s(r))return;const n=this._ctx,o=n.canvas.width,a=n.canvas.height;let h=e*i*(r.width/r.height),l=i*e;e||(h=i*r.width,l=i*r.height),this._ctx.drawImage(r,0,0,r.width,r.height,0,0,Math.min(this.transformSize(h),o),Math.min(this.transformSize(l),a))}drawText(t){this._textRasterizer||(this._textRasterizer=new b)}_buildPath(t,e){const s=this._ctx;if(s.beginPath(),t)for(const i of t){const t=i?i.length:0;if(t>1){let r=this.transformPt(i[0]);s.moveTo(r[0],r[1]);for(let e=1;e<t;++e)r=this.transformPt(i[e]),s.lineTo(r[0],r[1]);e&&s.closePath()}}}_setCapStyle(t){switch(t){case P.Butt:this._ctx.lineCap="butt";break;case P.Round:this._ctx.lineCap="round";break;case P.Square:this._ctx.lineCap="square"}}_setJoinStyle(t){switch(t){case w.Bevel:this._ctx.lineJoin="bevel";break;case w.Round:this._ctx.lineJoin="round";break;case w.Miter:this._ctx.lineJoin="miter"}}}const G=t=>t?{spatialReference:t.spatialReference,rings:[[[t.xmin,t.ymin],[t.xmin,t.ymax],[t.xmax,t.ymax],[t.xmax,t.ymin],[t.xmin,t.ymin]]]}:null,E=t=>{switch(t){case"Left":return S.Left;case"Right":return S.Right;case"Center":case"Justify":return S.Center}},B=t=>{switch(t){case"Top":return k.Top;case"Center":return k.Center;case"Bottom":return k.Bottom;case"Baseline":return k.Baseline}},H=(t,e,s)=>{switch(t){case"ExtraLeading":return 1+e/s;case"Multiple":return e;case"Exact":return e/s}};export{U as CIMSymbolDrawHelper,I as C_DEG_TO_RAD,A as CanvasDrawHelper,F as EnvDrawHelper,j as HittestDrawHelper,z as Transformation,E as horizontalAlignment2HAlign,H as lineGapType2LineHeight,B as verticalAlignment2VAlign};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.23/esri/copyright.txt for details.
4
4
  */
5
- import{isNone as t,isSome as e}from"../../../../../core/maybe.js";import{MIN_MAX_ZOOM_PRECISION_FACTOR as i,TEXTURE_BINDING_ATTRIBUTE_DATA_0 as s,TEXTURE_BINDING_ATTRIBUTE_DATA_1 as o,TEXTURE_BINDING_ATTRIBUTE_DATA_2 as a,TEXTURE_BINDING_ATTRIBUTE_DATA_3 as r}from"../definitions.js";import n from"./WGLBrush.js";import{BlendFactor as v,CompareFunction as u,DataType as f}from"../../../../webgl/enums.js";class m extends n{constructor(){super(...arguments),this._computeDesc=null}prepareState({context:t},e,i){const s=i&&-1!==i.indexOf("hittest");t.setBlendingEnabled(!s),t.setBlendFunctionSeparate(v.ONE,v.ONE_MINUS_SRC_ALPHA,v.ONE,v.ONE_MINUS_SRC_ALPHA),t.setColorMask(!0,!0,!0,!0),t.setStencilWriteMask(0),t.setStencilTestEnabled(!0),t.setStencilFunction(u.EQUAL,e.stencilRef,255)}draw(e,i,s){const o=this.getGeometryType();i.commit(e);const a=i.getGeometry(o);t(a)||(e.timeline.begin(this.name),e.attributeView.bindTextures(e.context),a.forEachCommand((t=>this.drawGeometry(e,i,t,s))))}_setSharedUniforms(t,n,v){const{displayLevel:u,pixelRatio:f,state:m,passOptions:l}=n;e(l)&&"hittest"===l.type&&(t.setUniform2fv("u_hittestPos",l.position),t.setUniform1f("u_hittestDist",l.distance)),t.setUniform1f("u_pixelRatio",f),t.setUniformMatrix3fv("u_tileMat3",v.transforms.tileMat3),t.setUniformMatrix3fv("u_viewMat3",m.viewMat3),t.setUniformMatrix3fv("u_dvsMat3",v.transforms.dvs),t.setUniformMatrix3fv("u_displayViewMat3",m.displayViewMat3),t.setUniform1f("u_currentZoom",Math.round(u*i)),t.setUniform1i("u_attributeTextureSize",n.attributeView.size),t.setUniform1i("u_attributeData0",s),t.setUniform1i("u_attributeData1",o),t.setUniform1i("u_attributeData2",a),t.setUniform1i("u_attributeData3",r)}_setSizeVVUniforms(t,e,i,s){if(t.vvSizeMinMaxValue&&e.setUniform4fv("u_vvSizeMinMaxValue",i.vvSizeMinMaxValue),t.vvSizeScaleStops&&e.setUniform1f("u_vvSizeScaleStopsValue",i.vvSizeScaleStopsValue),t.vvSizeFieldStops){const t=i.getSizeVVFieldStops(s.key.level);e.setUniform1fv("u_vvSizeFieldStopsValues",t.values),e.setUniform1fv("u_vvSizeFieldStopsSizes",t.sizes)}t.vvSizeUnitValue&&e.setUniform1f("u_vvSizeUnitValueWorldToPixelsRatio",i.vvSizeUnitValueToPixelsRatio)}_setColorAndOpacityVVUniforms(t,e,i){t.vvColor&&(e.setUniform1fv("u_vvColorValues",i.vvColorValues),e.setUniform4fv("u_vvColors",i.vvColors)),t.vvOpacity&&(e.setUniform1fv("u_vvOpacityValues",i.vvOpacityValues),e.setUniform1fv("u_vvOpacities",i.vvOpacities))}_setRotationVVUniforms(t,e,i){t.vvRotation&&e.setUniform1f("u_vvRotationType","geographic"===i.vvMaterialParameters.vvRotationType?0:1)}_getTriangleDesc(t){if(!this._computeDesc){const e=t.strides,i=t.strides.geometry,s=new Map(t.attributes),o=t.bufferLayouts.geometry.map((t=>({...t}))),a=Math.max(...t.attributes.values()),r={geometry:o};r.geometry.push({count:2,name:"a_pos1",divisor:0,normalized:!1,offset:i,stride:i,type:f.SHORT}),r.geometry.push({count:2,name:"a_pos2",divisor:0,normalized:!1,offset:2*i,stride:i,type:f.SHORT}),s.set("a_pos1",a+1),s.set("a_pos2",a+2),this._computeDesc={bufferLayouts:r,attributes:s,strides:e}}return this._computeDesc}}export{m as default};
5
+ import{isNone as t,isSome as e}from"../../../../../core/maybe.js";import{MIN_MAX_ZOOM_PRECISION_FACTOR as i,TEXTURE_BINDING_ATTRIBUTE_DATA_0 as s,TEXTURE_BINDING_ATTRIBUTE_DATA_1 as o,TEXTURE_BINDING_ATTRIBUTE_DATA_2 as a,TEXTURE_BINDING_ATTRIBUTE_DATA_3 as r}from"../definitions.js";import n from"./WGLBrush.js";import{BlendFactor as v,CompareFunction as u,DataType as f}from"../../../../webgl/enums.js";class m extends n{constructor(){super(...arguments),this._computeDesc=new Map}prepareState({context:t},e,i){const s=i&&-1!==i.indexOf("hittest");t.setBlendingEnabled(!s),t.setBlendFunctionSeparate(v.ONE,v.ONE_MINUS_SRC_ALPHA,v.ONE,v.ONE_MINUS_SRC_ALPHA),t.setColorMask(!0,!0,!0,!0),t.setStencilWriteMask(0),t.setStencilTestEnabled(!0),t.setStencilFunction(u.EQUAL,e.stencilRef,255)}draw(e,i,s){const o=this.getGeometryType();i.commit(e);const a=i.getGeometry(o);t(a)||(e.timeline.begin(this.name),e.attributeView.bindTextures(e.context),a.forEachCommand((t=>this.drawGeometry(e,i,t,s))))}_setSharedUniforms(t,n,v){const{displayLevel:u,pixelRatio:f,state:m,passOptions:l}=n;e(l)&&"hittest"===l.type&&(t.setUniform2fv("u_hittestPos",l.position),t.setUniform1f("u_hittestDist",l.distance)),t.setUniform1f("u_pixelRatio",f),t.setUniformMatrix3fv("u_tileMat3",v.transforms.tileMat3),t.setUniformMatrix3fv("u_viewMat3",m.viewMat3),t.setUniformMatrix3fv("u_dvsMat3",v.transforms.dvs),t.setUniformMatrix3fv("u_displayViewMat3",m.displayViewMat3),t.setUniform1f("u_currentZoom",Math.round(u*i)),t.setUniform1i("u_attributeTextureSize",n.attributeView.size),t.setUniform1i("u_attributeData0",s),t.setUniform1i("u_attributeData1",o),t.setUniform1i("u_attributeData2",a),t.setUniform1i("u_attributeData3",r)}_setSizeVVUniforms(t,e,i,s){if(t.vvSizeMinMaxValue&&e.setUniform4fv("u_vvSizeMinMaxValue",i.vvSizeMinMaxValue),t.vvSizeScaleStops&&e.setUniform1f("u_vvSizeScaleStopsValue",i.vvSizeScaleStopsValue),t.vvSizeFieldStops){const t=i.getSizeVVFieldStops(s.key.level);e.setUniform1fv("u_vvSizeFieldStopsValues",t.values),e.setUniform1fv("u_vvSizeFieldStopsSizes",t.sizes)}t.vvSizeUnitValue&&e.setUniform1f("u_vvSizeUnitValueWorldToPixelsRatio",i.vvSizeUnitValueToPixelsRatio)}_setColorAndOpacityVVUniforms(t,e,i){t.vvColor&&(e.setUniform1fv("u_vvColorValues",i.vvColorValues),e.setUniform4fv("u_vvColors",i.vvColors)),t.vvOpacity&&(e.setUniform1fv("u_vvOpacityValues",i.vvOpacityValues),e.setUniform1fv("u_vvOpacities",i.vvOpacities))}_setRotationVVUniforms(t,e,i){t.vvRotation&&e.setUniform1f("u_vvRotationType","geographic"===i.vvMaterialParameters.vvRotationType?0:1)}_getTriangleDesc(t,e){let i=this._computeDesc.get(t);if(!i){const s=e.strides,o=e.strides.geometry,a=new Map(e.attributes),r=e.bufferLayouts.geometry.map((t=>({...t}))),n=Math.max(...e.attributes.values()),v={geometry:r};v.geometry.push({count:2,name:"a_pos1",divisor:0,normalized:!1,offset:o,stride:o,type:f.SHORT}),v.geometry.push({count:2,name:"a_pos2",divisor:0,normalized:!1,offset:2*o,stride:o,type:f.SHORT}),a.set("a_pos1",n+1),a.set("a_pos2",n+2),i={bufferLayouts:v,attributes:a,strides:s},this._computeDesc.set(t,i)}return i}}export{m 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.23/esri/copyright.txt for details.
4
4
  */
5
- import{disposeMaybe as t,isSome as e,isNone as o}from"../../../../../core/maybe.js";import r from"../../../../../core/RandomLCG.js";import{TEXTURE_BINDING_RENDERER_0 as i,TEXTURE_BINDING_RENDERER_1 as s,TILE_SIZE as n}from"../definitions.js";import{WGLGeometryType as a}from"../enums.js";import{createProgramDescriptor as d}from"../Utils.js";import l from"./WGLGeometryBrush.js";import{FillMaterialKey as m}from"../materialKey/MaterialKey.js";import{BufferObject as _}from"../../../../webgl/BufferObject.js";import{PrimitiveType as u,DataType as c,TextureType as f,PixelFormat as h,PixelType as T,TextureSamplingMode as p,TextureWrapMode as x,TargetType as y,DepthStencilTargetType as D,RenderbufferFormat as g,Usage as E}from"../../../../webgl/enums.js";import{FramebufferObject as S}from"../../../../webgl/FramebufferObject.js";import{Renderbuffer as w}from"../../../../webgl/Renderbuffer.js";import{Texture as U}from"../../../../webgl/Texture.js";import{VertexArrayObject as O}from"../../../../webgl/VertexArrayObject.js";const b=t=>{const e={geometry:[{location:0,name:"a_pos",count:2,type:c.SHORT},{location:1,name:"a_id",count:3,type:c.UNSIGNED_BYTE},{location:2,name:"a_bitset",count:1,type:c.UNSIGNED_BYTE}]};return t.dotDensity?(e.geometry.push({location:3,name:"a_inverseArea",count:1,type:c.FLOAT}),d(t.data,e)):(e.geometry.push({location:3,name:"a_color",count:4,type:c.UNSIGNED_BYTE,normalized:!0}),t.simple||e.geometry.push({location:4,name:"a_aux1",count:4,type:c.UNSIGNED_SHORT}),e.geometry.push({location:5,name:"a_aux2",count:4,type:c.UNSIGNED_BYTE},{location:6,name:"a_aux3",count:4,type:c.UNSIGNED_BYTE}),t.simple||e.geometry.push({location:7,name:"a_zoomRange",count:2,type:c.UNSIGNED_SHORT}),d(t.data,e))};class N extends l{constructor(){super(...arguments),this._dotTextureSize=0,this._dotTextures=null,this._dotSamplers=new Int32Array([i,s]),this._dotVAO=null,this._dotDesc={vsPath:"dot/dot",fsPath:"dot/dot",attributes:new Map([["a_pos",0]])}}dispose(){this._disposeTextures(),this._dotFBO=t(this._dotFBO),this._dotVAO=t(this._dotVAO)}getGeometryType(){return a.FILL}drawGeometry(t,o,r,i){const{context:s,painter:n,rendererInfo:a,requiredLevel:d,passOptions:l}=t,_=m.load(r.materialKey),f=n.materialManager;let h=u.TRIANGLES,T=b(_);e(l)&&"hittest"===l.type&&(T=this._getTriangleDesc(T),h=u.POINTS);const{attributes:p,bufferLayouts:x}=T,y=f.getMaterialProgram(t,_,"materials/fill",p,i);if(s.useProgram(y),this._setSharedUniforms(y,t,o),y.setUniform2f("u_tileOffset",512*o.key.col,512*o.key.row),_.textureBinding){n.textureManager.bindTextures(s,y,_);const e=1/2**(d-o.key.level)/t.pixelRatio;y.setUniform1f("u_zoomFactor",e)}const D=1/t.pixelRatio;y.setUniform1f("u_blur",D),y.setUniform1f("u_antialiasing",D),this._setSizeVVUniforms(_,y,a,o),this._setColorAndOpacityVVUniforms(_,y,a);const g=e(l)&&"hittest"===l.type,E=r.target.getVAO(s,x,p,g);let S=r.indexCount,w=r.indexFrom*Uint32Array.BYTES_PER_ELEMENT;if(g&&(S/=3,w/=3),s.bindVAO(E),!_.dotDensity||g)s.drawElements(h,S,c.UNSIGNED_INT,w);else{const e=this._drawDotLocations(t,o,y,S,w);this._drawDotDensity(t,o,e)}}_drawDotDensity(t,e,o){const{context:r,painter:i,rendererInfo:s}=t,n=i.materialManager.getProgram(t,this._dotDesc),a=this._createDotDensityMesh(r,this._dotDesc.attributes,{geometry:[{name:"a_pos",count:2,type:c.SHORT,divisor:0,normalized:!1,offset:0,stride:4}]});r.setStencilTestEnabled(!0),r.useProgram(n),n.setUniform1f("u_tileZoomFactor",1),n.setUniform1i("u_texture",this._dotSamplers[0]),n.setUniform1f("u_dotSize",Math.max(s.ddDotSize,1)),n.setUniform1f("u_pixelRatio",window.devicePixelRatio),this._setSharedUniforms(n,t,e),r.bindTexture(o,this._dotSamplers[0]),r.bindVAO(a),r.drawArrays(u.POINTS,0,262144)}_drawDotLocations(t,e,o,r,i){const{context:s,rendererInfo:a,requiredLevel:d}=t,l=s.getViewport();s.setViewport(0,0,512,512);const m=s.getBoundFramebufferObject(),_=this._createFBO(s);s.bindFramebuffer(_),s.setClearColor(0,0,0,0),s.clear(s.gl.COLOR_BUFFER_BIT|s.gl.STENCIL_BUFFER_BIT),s.setStencilTestEnabled(!1);const f=1/2**(d-e.key.level),h=n,T=h*window.devicePixelRatio*h*window.devicePixelRatio,p=1/f*(1/f),x=a.ddDotScale?t.state.scale/a.ddDotScale:1;return o.setUniform1f("u_tileZoomFactor",f),o.setUniform1f("u_tileDotsOverArea",T/(n*window.devicePixelRatio*n*window.devicePixelRatio)),o.setUniformMatrix4fv("u_dotColors",a.ddColors),o.setUniform4fv("u_isActive",a.ddActiveDots),o.setUniform4fv("u_dotBackgroundColor",a.ddBackgroundColor),o.setUniform1f("u_dotValue",Math.max(1,a.ddDotValue*x*p)),this._bindDotDensityTextures(s,o,a,h),s.drawElements(u.TRIANGLES,r,c.UNSIGNED_INT,i),s.setViewport(l.x,l.y,l.width,l.height),s.bindFramebuffer(m),_.colorTexture}_createFBO(t){if(o(this._dotFBO)){const e=512,o=512,r={target:f.TEXTURE_2D,pixelFormat:h.RGBA,dataType:T.UNSIGNED_BYTE,samplingMode:p.NEAREST,wrapMode:x.CLAMP_TO_EDGE,width:e,height:o},i={colorTarget:y.TEXTURE,depthStencilTarget:D.DEPTH_STENCIL_RENDER_BUFFER},s=new w(t,{width:e,height:o,internalFormat:g.DEPTH_STENCIL});this._dotFBO=new S(t,i,r,s)}return this._dotFBO}_disposeTextures(){if(this._dotTextures){for(let t=0;t<this._dotTextures.length;t++)this._dotTextures[t].dispose();this._dotTextures=null}}_bindDotDensityTextures(t,e,o,r){const i=this._createDotDensityTextures(t,r,o.ddSeed);e.setUniform1iv("u_dotTextures",this._dotSamplers);for(let s=0;s<i.length;s++)t.bindTexture(i[s],this._dotSamplers[s])}_createDotDensityMesh(t,e,r){if(o(this._dotVAO)){const o=2,i=new Int16Array(262144*o);for(let t=0;t<512;t++)for(let e=0;e<512;e++)i[o*(e+512*t)]=e,i[o*(e+512*t)+1]=t;const s=_.createVertex(t,E.STATIC_DRAW,i);this._dotVAO=new O(t,e,r,{geometry:s},null)}return this._dotVAO}_createDotDensityTextures(t,e,o){if(this._dotTextureSize===e&&this._seed===o||(this._disposeTextures(),this._dotTextureSize=e,this._seed=o),null===this._dotTextures){const i=new r(o);this._dotTextures=[this._allocDotDensityTexture(t,e,i),this._allocDotDensityTexture(t,e,i)]}return this._dotTextures}_allocDotDensityTexture(t,e,o){const r=new Float32Array(e*e*4);for(let i=0;i<r.length;i++)r[i]=o.getFloat();return new U(t,{wrapMode:x.REPEAT,pixelFormat:h.RGBA,dataType:T.FLOAT,samplingMode:p.NEAREST,width:e,height:e},r)}}export{N as default};
5
+ import{disposeMaybe as t,isSome as e,isNone as o}from"../../../../../core/maybe.js";import r from"../../../../../core/RandomLCG.js";import{TEXTURE_BINDING_RENDERER_0 as i,TEXTURE_BINDING_RENDERER_1 as s,TILE_SIZE as a}from"../definitions.js";import{WGLGeometryType as n}from"../enums.js";import{createProgramDescriptor as d}from"../Utils.js";import l from"./WGLGeometryBrush.js";import{FillMaterialKey as m}from"../materialKey/MaterialKey.js";import{BufferObject as _}from"../../../../webgl/BufferObject.js";import{PrimitiveType as u,DataType as c,TextureType as f,PixelFormat as h,PixelType as T,TextureSamplingMode as p,TextureWrapMode as y,TargetType as x,DepthStencilTargetType as D,RenderbufferFormat as g,Usage as E}from"../../../../webgl/enums.js";import{FramebufferObject as S}from"../../../../webgl/FramebufferObject.js";import{Renderbuffer as w}from"../../../../webgl/Renderbuffer.js";import{Texture as U}from"../../../../webgl/Texture.js";import{VertexArrayObject as O}from"../../../../webgl/VertexArrayObject.js";const b=t=>{const e={geometry:[{location:0,name:"a_pos",count:2,type:c.SHORT},{location:1,name:"a_id",count:3,type:c.UNSIGNED_BYTE},{location:2,name:"a_bitset",count:1,type:c.UNSIGNED_BYTE}]};return t.dotDensity?(e.geometry.push({location:3,name:"a_inverseArea",count:1,type:c.FLOAT}),d(t.data,e)):(e.geometry.push({location:3,name:"a_color",count:4,type:c.UNSIGNED_BYTE,normalized:!0}),t.simple||e.geometry.push({location:4,name:"a_aux1",count:4,type:c.UNSIGNED_SHORT}),e.geometry.push({location:5,name:"a_aux2",count:4,type:c.UNSIGNED_BYTE},{location:6,name:"a_aux3",count:4,type:c.UNSIGNED_BYTE}),t.simple||e.geometry.push({location:7,name:"a_zoomRange",count:2,type:c.UNSIGNED_SHORT}),d(t.data,e))};class N extends l{constructor(){super(...arguments),this._dotTextureSize=0,this._dotTextures=null,this._dotSamplers=new Int32Array([i,s]),this._dotVAO=null,this._dotDesc={vsPath:"dot/dot",fsPath:"dot/dot",attributes:new Map([["a_pos",0]])}}dispose(){this._disposeTextures(),this._dotFBO=t(this._dotFBO),this._dotVAO=t(this._dotVAO)}getGeometryType(){return n.FILL}drawGeometry(t,o,r,i){const{context:s,painter:a,rendererInfo:n,requiredLevel:d,passOptions:l}=t,_=m.load(r.materialKey),f=a.materialManager;let h=u.TRIANGLES,T=b(_);e(l)&&"hittest"===l.type&&(T=this._getTriangleDesc(r.materialKey,T),h=u.POINTS);const{attributes:p,bufferLayouts:y}=T,x=f.getMaterialProgram(t,_,"materials/fill",p,i);if(s.useProgram(x),this._setSharedUniforms(x,t,o),x.setUniform2f("u_tileOffset",512*o.key.col,512*o.key.row),_.textureBinding){a.textureManager.bindTextures(s,x,_);const e=1/2**(d-o.key.level)/t.pixelRatio;x.setUniform1f("u_zoomFactor",e)}const D=1/t.pixelRatio;x.setUniform1f("u_blur",D),x.setUniform1f("u_antialiasing",D),this._setSizeVVUniforms(_,x,n,o),this._setColorAndOpacityVVUniforms(_,x,n);const g=e(l)&&"hittest"===l.type,E=r.target.getVAO(s,y,p,g);let S=r.indexCount,w=r.indexFrom*Uint32Array.BYTES_PER_ELEMENT;if(g&&(S/=3,w/=3),s.bindVAO(E),!_.dotDensity||g)s.drawElements(h,S,c.UNSIGNED_INT,w);else{const e=this._drawDotLocations(t,o,x,S,w);this._drawDotDensity(t,o,e)}}_drawDotDensity(t,e,o){const{context:r,painter:i,rendererInfo:s}=t,a=i.materialManager.getProgram(t,this._dotDesc),n=this._createDotDensityMesh(r,this._dotDesc.attributes,{geometry:[{name:"a_pos",count:2,type:c.SHORT,divisor:0,normalized:!1,offset:0,stride:4}]});r.setStencilTestEnabled(!0),r.useProgram(a),a.setUniform1f("u_tileZoomFactor",1),a.setUniform1i("u_texture",this._dotSamplers[0]),a.setUniform1f("u_dotSize",Math.max(s.ddDotSize,1)),a.setUniform1f("u_pixelRatio",window.devicePixelRatio),this._setSharedUniforms(a,t,e),r.bindTexture(o,this._dotSamplers[0]),r.bindVAO(n),r.drawArrays(u.POINTS,0,262144)}_drawDotLocations(t,e,o,r,i){const{context:s,rendererInfo:n,requiredLevel:d}=t,l=s.getViewport();s.setViewport(0,0,512,512);const m=s.getBoundFramebufferObject(),_=this._createFBO(s);s.bindFramebuffer(_),s.setClearColor(0,0,0,0),s.clear(s.gl.COLOR_BUFFER_BIT|s.gl.STENCIL_BUFFER_BIT),s.setStencilTestEnabled(!1);const f=1/2**(d-e.key.level),h=a,T=h*window.devicePixelRatio*h*window.devicePixelRatio,p=1/f*(1/f),y=n.ddDotScale?t.state.scale/n.ddDotScale:1;return o.setUniform1f("u_tileZoomFactor",f),o.setUniform1f("u_tileDotsOverArea",T/(a*window.devicePixelRatio*a*window.devicePixelRatio)),o.setUniformMatrix4fv("u_dotColors",n.ddColors),o.setUniform4fv("u_isActive",n.ddActiveDots),o.setUniform4fv("u_dotBackgroundColor",n.ddBackgroundColor),o.setUniform1f("u_dotValue",Math.max(1,n.ddDotValue*y*p)),this._bindDotDensityTextures(s,o,n,h),s.drawElements(u.TRIANGLES,r,c.UNSIGNED_INT,i),s.setViewport(l.x,l.y,l.width,l.height),s.bindFramebuffer(m),_.colorTexture}_createFBO(t){if(o(this._dotFBO)){const e=512,o=512,r={target:f.TEXTURE_2D,pixelFormat:h.RGBA,dataType:T.UNSIGNED_BYTE,samplingMode:p.NEAREST,wrapMode:y.CLAMP_TO_EDGE,width:e,height:o},i={colorTarget:x.TEXTURE,depthStencilTarget:D.DEPTH_STENCIL_RENDER_BUFFER},s=new w(t,{width:e,height:o,internalFormat:g.DEPTH_STENCIL});this._dotFBO=new S(t,i,r,s)}return this._dotFBO}_disposeTextures(){if(this._dotTextures){for(let t=0;t<this._dotTextures.length;t++)this._dotTextures[t].dispose();this._dotTextures=null}}_bindDotDensityTextures(t,e,o,r){const i=this._createDotDensityTextures(t,r,o.ddSeed);e.setUniform1iv("u_dotTextures",this._dotSamplers);for(let s=0;s<i.length;s++)t.bindTexture(i[s],this._dotSamplers[s])}_createDotDensityMesh(t,e,r){if(o(this._dotVAO)){const o=2,i=new Int16Array(262144*o);for(let t=0;t<512;t++)for(let e=0;e<512;e++)i[o*(e+512*t)]=e,i[o*(e+512*t)+1]=t;const s=_.createVertex(t,E.STATIC_DRAW,i);this._dotVAO=new O(t,e,r,{geometry:s},null)}return this._dotVAO}_createDotDensityTextures(t,e,o){if(this._dotTextureSize===e&&this._seed===o||(this._disposeTextures(),this._dotTextureSize=e,this._seed=o),null===this._dotTextures){const i=new r(o);this._dotTextures=[this._allocDotDensityTexture(t,e,i),this._allocDotDensityTexture(t,e,i)]}return this._dotTextures}_allocDotDensityTexture(t,e,o){const r=new Float32Array(e*e*4);for(let i=0;i<r.length;i++)r[i]=o.getFloat();return new U(t,{wrapMode:y.REPEAT,pixelFormat:h.RGBA,dataType:T.FLOAT,samplingMode:p.NEAREST,width:e,height:e},r)}}export{N 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.23/esri/copyright.txt for details.
4
4
  */
5
- import{isSome as t}from"../../../../../core/maybe.js";import{WGLGeometryType as e}from"../enums.js";import{createProgramDescriptor as o}from"../Utils.js";import a from"./WGLGeometryBrush.js";import{LineMaterialKey as n}from"../materialKey/MaterialKey.js";import{DataType as i,PrimitiveType as r}from"../../../../webgl/enums.js";const s=t=>o(t.data,{geometry:[{location:0,name:"a_pos",count:2,type:i.SHORT},{location:1,name:"a_id",count:4,type:i.UNSIGNED_BYTE},{location:2,name:"a_color",count:4,type:i.UNSIGNED_BYTE,normalized:!0},{location:3,name:"a_offsetAndNormal",count:4,type:i.BYTE},{location:4,name:"a_accumulatedDistanceAndHalfWidth",count:2,type:i.UNSIGNED_SHORT},{location:5,name:"a_tlbr",count:4,type:i.UNSIGNED_SHORT},{location:6,name:"a_segmentDirection",count:4,type:i.BYTE},{location:7,name:"a_aux",count:2,type:i.UNSIGNED_SHORT},{location:8,name:"a_zoomRange",count:2,type:i.UNSIGNED_SHORT}]});class m extends a{dispose(){}getGeometryType(){return e.LINE}drawGeometry(e,o,a,m){const{context:l,painter:c,rendererInfo:u,displayLevel:p,passOptions:y}=e,_=n.load(a.materialKey);let d=s(_),f=r.TRIANGLES;t(y)&&"hittest"===y.type&&(d=this._getTriangleDesc(d),f=r.POINTS);const{attributes:E,bufferLayouts:N}=d,g=c.materialManager.getMaterialProgram(e,_,"materials/line",E,m),S=1/e.pixelRatio,T=0;l.useProgram(g),this._setSharedUniforms(g,e,o),_.textureBinding&&c.textureManager.bindTextures(l,g,_);const U=2**(p-o.key.level)/e.pixelRatio;g.setUniform1f("u_zoomFactor",U),g.setUniform1f("u_blur",T+S),g.setUniform1f("u_antialiasing",S),this._setSizeVVUniforms(_,g,u,o),this._setColorAndOpacityVVUniforms(_,g,u),l.setFaceCullingEnabled(!1);const G=t(y)&&"hittest"===y.type,I=a.target.getVAO(l,N,E,G);let x=a.indexCount,D=a.indexFrom*Uint32Array.BYTES_PER_ELEMENT;G&&(x/=3,D/=3),l.bindVAO(I),l.drawElements(f,x,i.UNSIGNED_INT,D)}}export{m as default};
5
+ import{isSome as t}from"../../../../../core/maybe.js";import{WGLGeometryType as e}from"../enums.js";import{createProgramDescriptor as a}from"../Utils.js";import o from"./WGLGeometryBrush.js";import{LineMaterialKey as n}from"../materialKey/MaterialKey.js";import{DataType as i,PrimitiveType as r}from"../../../../webgl/enums.js";const s=t=>a(t.data,{geometry:[{location:0,name:"a_pos",count:2,type:i.SHORT},{location:1,name:"a_id",count:4,type:i.UNSIGNED_BYTE},{location:2,name:"a_color",count:4,type:i.UNSIGNED_BYTE,normalized:!0},{location:3,name:"a_offsetAndNormal",count:4,type:i.BYTE},{location:4,name:"a_accumulatedDistanceAndHalfWidth",count:2,type:i.UNSIGNED_SHORT},{location:5,name:"a_tlbr",count:4,type:i.UNSIGNED_SHORT},{location:6,name:"a_segmentDirection",count:4,type:i.BYTE},{location:7,name:"a_aux",count:2,type:i.UNSIGNED_SHORT},{location:8,name:"a_zoomRange",count:2,type:i.UNSIGNED_SHORT}]});class m extends o{dispose(){}getGeometryType(){return e.LINE}drawGeometry(e,a,o,m){const{context:l,painter:c,rendererInfo:u,displayLevel:p,passOptions:y}=e,_=n.load(o.materialKey);let d=s(_),f=r.TRIANGLES;t(y)&&"hittest"===y.type&&(d=this._getTriangleDesc(o.materialKey,d),f=r.POINTS);const{attributes:E,bufferLayouts:N}=d,g=c.materialManager.getMaterialProgram(e,_,"materials/line",E,m),S=1/e.pixelRatio,T=0;l.useProgram(g),this._setSharedUniforms(g,e,a),_.textureBinding&&c.textureManager.bindTextures(l,g,_);const U=2**(p-a.key.level)/e.pixelRatio;g.setUniform1f("u_zoomFactor",U),g.setUniform1f("u_blur",T+S),g.setUniform1f("u_antialiasing",S),this._setSizeVVUniforms(_,g,u,a),this._setColorAndOpacityVVUniforms(_,g,u),l.setFaceCullingEnabled(!1);const G=t(y)&&"hittest"===y.type,I=o.target.getVAO(l,N,E,G);let x=o.indexCount,D=o.indexFrom*Uint32Array.BYTES_PER_ELEMENT;G&&(x/=3,D/=3),l.bindVAO(I),l.drawElements(f,x,i.UNSIGNED_INT,D)}}export{m as default};