@arcgis/core 4.28.3 → 4.28.5

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 (84) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/{15852a47129b9e0d04c6.js → 023fc8504d032762ad82.js} +1 -1
  3. package/assets/esri/core/workers/chunks/{80d9bb9f247ecdfa266f.js → 0695fcdc01f195c5ae8d.js} +1 -1
  4. package/assets/esri/core/workers/chunks/{4363f2cc3909c9258064.js → 076ac767b5148357f1b5.js} +1 -1
  5. package/assets/esri/core/workers/chunks/07cb7d142205f2eccc83.js +1 -0
  6. package/assets/esri/core/workers/chunks/0f6b766f08c648fd7b99.js +1 -0
  7. package/assets/esri/core/workers/chunks/16b56e541afa438dfb7f.js +1 -0
  8. package/assets/esri/core/workers/chunks/1c855f091d1305b82594.js +1 -0
  9. package/assets/esri/core/workers/chunks/28c4a21cdddf2602ab97.js +1 -0
  10. package/assets/esri/core/workers/chunks/2cf2340ad817f3c27802.js +1 -0
  11. package/assets/esri/core/workers/chunks/319c222ce72254934060.js +1 -0
  12. package/assets/esri/core/workers/chunks/340ab726ba40fe3a99c8.js +1 -0
  13. package/assets/esri/core/workers/chunks/46b4a17ec898ab744861.js +1 -0
  14. package/assets/esri/core/workers/chunks/4a5d0b49a641d182b5ea.js +1 -0
  15. package/assets/esri/core/workers/chunks/{7f3bc7a2de59e485f22f.js → 4f0412b52844aa9c7bd4.js} +1 -1
  16. package/assets/esri/core/workers/chunks/54867a094fb740a6f4d9.js +1 -0
  17. package/assets/esri/core/workers/chunks/5b80ae1eb79f1db75dc6.js +1 -0
  18. package/assets/esri/core/workers/chunks/80fcb63476829b6a48d2.js +1 -0
  19. package/assets/esri/core/workers/chunks/84725021c43f1122056a.js +1 -0
  20. package/assets/esri/core/workers/chunks/{9f0e8dd5c9bacfc0f03c.js → 908a5326b61843d6d2b3.js} +1 -1
  21. package/assets/esri/core/workers/chunks/9607460895182d31aef9.js +1 -0
  22. package/assets/esri/core/workers/chunks/9ef3746c545296565ef6.js +1 -0
  23. package/assets/esri/core/workers/chunks/{77f557359a5033d7e429.js → a0a86383e69932a25e50.js} +1 -1
  24. package/assets/esri/core/workers/chunks/a3bf50d9e24ad1de9847.js +1 -0
  25. package/assets/esri/core/workers/chunks/a5db3be5eeb3005df3c1.js +1 -0
  26. package/assets/esri/core/workers/chunks/a87ab14d6a6ccc9004a0.js +1 -0
  27. package/assets/esri/core/workers/chunks/af13150c711ba7b7f3ac.js +1 -0
  28. package/assets/esri/core/workers/chunks/ba00df2e707550939a6f.js +1 -0
  29. package/assets/esri/core/workers/chunks/ca43955065012d4b22e9.js +1 -0
  30. package/assets/esri/core/workers/chunks/cfa6d1b63b794febe70a.js +1 -0
  31. package/assets/esri/core/workers/chunks/e0382138cf58191a9697.js +1 -0
  32. package/assets/esri/core/workers/chunks/e076c5523dfb6c53a825.js +1 -0
  33. package/assets/esri/core/workers/chunks/{e3950975030412ff6e20.js → f343db8dad71f3840610.js} +1 -1
  34. package/assets/esri/core/workers/chunks/{46ddc52fe9cdd573a614.js → fa5c69a0cdd78aa34ad7.js} +1 -1
  35. package/assets/esri/core/workers/chunks/fe0c6814ef56604540b3.js +1 -0
  36. package/core/date.js +1 -1
  37. package/core/sql/WhereClause.js +1 -1
  38. package/kernel.js +1 -1
  39. package/layers/graphics/data/QueryEngineResult.js +1 -1
  40. package/layers/graphics/sources/geojson/geojson.js +1 -1
  41. package/layers/save/featureLayerUtils.js +1 -1
  42. package/layers/support/fetchService.js +1 -1
  43. package/layers/support/vectorTileLayerLoader.js +1 -1
  44. package/package.json +1 -1
  45. package/support/revision.js +1 -1
  46. package/views/2d/engine/webgl/Painter.js +1 -1
  47. package/views/2d/layers/features/sources/DataTileSubscription.js +1 -1
  48. package/views/3d/layers/graphics/elevationAlignPointsInFeatures.js +1 -1
  49. package/views/PopupView.js +1 -1
  50. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceSnappingSourceWorker.js +1 -1
  51. package/views/interactive/snapping/featureSources/snappingCandidateElevationAlignment.js +1 -1
  52. package/widgets/FeatureForm/FieldInput.js +1 -1
  53. package/widgets/FeatureForm/featureFormUtils.js +1 -1
  54. package/widgets/FeatureForm.js +1 -1
  55. package/widgets/Features.js +1 -1
  56. package/widgets/Legend/LegendViewModel.js +1 -1
  57. package/widgets/Popup.js +1 -1
  58. package/assets/esri/core/workers/chunks/32fbd4355a4a649623a7.js +0 -1
  59. package/assets/esri/core/workers/chunks/41306b698f78001dda55.js +0 -1
  60. package/assets/esri/core/workers/chunks/423672fe765083e1a0ec.js +0 -1
  61. package/assets/esri/core/workers/chunks/49d958631bcd93f6333a.js +0 -1
  62. package/assets/esri/core/workers/chunks/49faa024bab1ba6e2bf0.js +0 -1
  63. package/assets/esri/core/workers/chunks/534726130ef1698ec89e.js +0 -1
  64. package/assets/esri/core/workers/chunks/7beae29abdfae23b15cc.js +0 -1
  65. package/assets/esri/core/workers/chunks/846e5e51dc278bc3f80f.js +0 -1
  66. package/assets/esri/core/workers/chunks/8b541cbf82a5ba0317ee.js +0 -1
  67. package/assets/esri/core/workers/chunks/8e91be2e38010391e351.js +0 -1
  68. package/assets/esri/core/workers/chunks/90f96a2ddfb25d851d4d.js +0 -1
  69. package/assets/esri/core/workers/chunks/91a3181071874525ed44.js +0 -1
  70. package/assets/esri/core/workers/chunks/97fd7b82eec26449977e.js +0 -1
  71. package/assets/esri/core/workers/chunks/9d97a20f69047d0c47cc.js +0 -1
  72. package/assets/esri/core/workers/chunks/ac4636e82a103e2c27ca.js +0 -1
  73. package/assets/esri/core/workers/chunks/ae7ba94af6d4fd97dd8b.js +0 -1
  74. package/assets/esri/core/workers/chunks/b0653f63745e756f55fe.js +0 -1
  75. package/assets/esri/core/workers/chunks/c2199fb8f7a54a0ef18a.js +0 -1
  76. package/assets/esri/core/workers/chunks/c3f462d11ed570482e7a.js +0 -1
  77. package/assets/esri/core/workers/chunks/c8cb5fe1d23145c4842b.js +0 -1
  78. package/assets/esri/core/workers/chunks/ce409944221a784ddb61.js +0 -1
  79. package/assets/esri/core/workers/chunks/e8b7d1c586aff229484c.js +0 -1
  80. package/assets/esri/core/workers/chunks/eb5213ffb83d83a4dd05.js +0 -1
  81. package/assets/esri/core/workers/chunks/f037e4f9877ea08ced9d.js +0 -1
  82. package/assets/esri/core/workers/chunks/f520f093aa81d8ee1790.js +0 -1
  83. package/assets/esri/core/workers/chunks/f7ccc6c681fc9218555c.js +0 -1
  84. package/assets/esri/core/workers/chunks/fab4ee57b7c5376c9ccd.js +0 -1
@@ -1 +1 @@
1
- "use strict";(self.webpackChunkRemoteClient=self.webpackChunkRemoteClient||[]).push([[2330],{70272:(e,t,s)=>{s.d(t,{S6:()=>o,nd:()=>n,u_:()=>r});class r{constructor(e=null,t={},s,r){this.geometry=e,this.attributes=t,this.centroid=s,this.objectId=r,this.displayId=0,this.geohashX=0,this.geohashY=0}weakClone(){const e=new r(this.geometry,this.attributes,this.centroid,this.objectId);return e.displayId=this.displayId,e.geohashX=this.geohashX,e.geohashY=this.geohashY,e}}function o(e){return!!e.geometry?.coords?.length}class n extends r{}},44876:(e,t,s)=>{s.d(t,{Z:()=>r});class r{constructor(){this.objectIdFieldName=null,this.globalIdFieldName=null,this.geohashFieldName=null,this.geometryProperties=null,this.geometryType=null,this.spatialReference=null,this.hasZ=!1,this.hasM=!1,this.features=[],this.fields=[],this.transform=null,this.exceededTransferLimit=!1,this.uniqueIdField=null,this.queryGeometryType=null,this.queryGeometry=null}weakClone(){const e=new r;return e.objectIdFieldName=this.objectIdFieldName,e.globalIdFieldName=this.globalIdFieldName,e.geohashFieldName=this.geohashFieldName,e.geometryProperties=this.geometryProperties,e.geometryType=this.geometryType,e.spatialReference=this.spatialReference,e.hasZ=this.hasZ,e.hasM=this.hasM,e.features=this.features,e.fields=this.fields,e.transform=this.transform,e.exceededTransferLimit=this.exceededTransferLimit,e.uniqueIdField=this.uniqueIdField,e.queryGeometry=this.queryGeometry,e.queryGeometryType=this.queryGeometryType,e}}},5428:(e,t,s)=>{s.d(t,{Z:()=>r});class r{constructor(e=[],t=[],s=!1){this.lengths=e??[],this.coords=t??[],this.hasIndeterminateRingOrder=s}static fromRect(e){const[t,s,o,n]=e,i=o-t,a=n-s;return new r([5],[t,s,i,0,0,a,-i,0,0,-a])}get isPoint(){return 0===this.lengths.length}get maxLength(){return Math.max(...this.lengths)}get size(){return this.lengths.reduce(((e,t)=>e+t))}forEachVertex(e){let t=0;this.lengths.length||e(this.coords[0],this.coords[1]);for(let s=0;s<this.lengths.length;s++){const r=this.lengths[s];for(let s=0;s<r;s++)e(this.coords[2*(s+t)],this.coords[2*(s+t)+1]);t+=r}}clone(e){return e?(e.set(this.coords),new r(this.lengths.slice(),e,this.hasIndeterminateRingOrder)):new r(this.lengths.slice(),this.coords.slice(),this.hasIndeterminateRingOrder)}}},95047:(e,t,s)=>{s.r(t),s.d(t,{createConnection:()=>C});var r=s(43697),o=(s(66577),s(3172)),n=s(20102),i=s(92604),a=s(95330),c=s(17452),h=(s(75215),s(67676),s(80442),s(52011)),l=s(5600),u=s(69285),d=s(32448);let g=class extends d.Z.EventedAccessor{destroy(){this.emit("destroy")}get connectionError(){return this.errorString?new n.Z("stream-connection",this.errorString):null}onFeature(e){this.emit("data-received",e)}onMessage(e){this.emit("message-received",e)}};(0,r._)([(0,l.Cb)({readOnly:!0})],g.prototype,"connectionError",null),g=(0,r._)([(0,h.j)("esri.layers.support.StreamConnection")],g);const f=g;var y,m;(m=y||(y={}))[m.CONNECTING=0]="CONNECTING",m[m.OPEN=1]="OPEN",m[m.CLOSING=2]="CLOSING",m[m.CLOSED=3]="CLOSED";let _=class extends f{constructor(e){super(),this._outstandingMessages=[],this.errorString=null;const{geometryType:t,spatialReference:s,sourceSpatialReference:r}=e;this._config=e,this._featureZScaler=(0,u.k)(t,r,s),this._open()}async _open(){await this._tryCreateWebSocket(),this.destroyed||await this._handshake()}destroy(){super.destroy(),null!=this._websocket&&(this._websocket.onopen=null,this._websocket.onclose=null,this._websocket.onerror=null,this._websocket.onmessage=null,this._websocket.close()),this._websocket=null}get connectionStatus(){if(null==this._websocket)return"disconnected";switch(this._websocket.readyState){case y.CONNECTING:case y.OPEN:return"connected";case y.CLOSING:case y.CLOSED:return"disconnected"}}sendMessageToSocket(e){null!=this._websocket?this._websocket.send(JSON.stringify(e)):this._outstandingMessages.push(e)}sendMessageToClient(e){this._onMessage(e)}updateCustomParameters(e){this._config.customParameters=e,null!=this._websocket&&this._websocket.close()}async _tryCreateWebSocket(e=this._config.source.path,t=1e3,s=0){try{if(this.destroyed)return;const t=(0,c.fl)(e,this._config.customParameters??{});this._websocket=await this._createWebSocket(t),this.notifyChange("connectionStatus")}catch(r){const o=t/1e3;return this._config.maxReconnectionAttempts&&s>=this._config.maxReconnectionAttempts?(i.Z.getLogger(this).error(new n.Z("websocket-connection","Exceeded maxReconnectionAttempts attempts. No further attempts will be made")),void this.destroy()):(i.Z.getLogger(this).error(new n.Z("websocket-connection",`Failed to connect. Attempting to reconnect in ${o}s`,r)),await(0,a.e4)(t),this._tryCreateWebSocket(e,Math.min(1.5*t,1e3*this._config.maxReconnectionInterval),s+1))}}_setWebSocketJSONParseHandler(e){e.onmessage=e=>{try{const t=JSON.parse(e.data);this._onMessage(t)}catch(e){return void i.Z.getLogger(this).error(new n.Z("websocket-connection","Failed to parse message, invalid JSON",{error:e}))}}}_createWebSocket(e){return new Promise(((t,s)=>{const r=new WebSocket(e);r.onopen=()=>{if(r.onopen=null,this.destroyed)return r.onclose=null,void r.close();r.onclose=e=>this._onClose(e),r.onerror=e=>this._onError(e),this._setWebSocketJSONParseHandler(r),t(r)},r.onclose=e=>{r.onopen=r.onclose=null,s(e)}}))}async _handshake(e=1e4){const t=this._websocket;if(null==t)return;const s=(0,a.hh)(),r=t.onmessage,{filter:o,outFields:c,spatialReference:h}=this._config;return s.timeout(e),t.onmessage=e=>{let a=null;try{a=JSON.parse(e.data)}catch(e){}a&&"object"==typeof a||(i.Z.getLogger(this).error(new n.Z("websocket-connection","Protocol violation. Handshake failed - malformed message",e.data)),s.reject(),this.destroy()),a.spatialReference?.wkid!==h?.wkid&&(i.Z.getLogger(this).error(new n.Z("websocket-connection",`Protocol violation. Handshake failed - expected wkid of ${h.wkid}`,e.data)),s.reject(),this.destroy()),"json"!==a.format&&(i.Z.getLogger(this).error(new n.Z("websocket-connection","Protocol violation. Handshake failed - format is not set",e.data)),s.reject(),this.destroy()),o&&a.filter!==o&&i.Z.getLogger(this).error(new n.Z("websocket-connection","Tried to set filter, but server doesn't support it")),c&&a.outFields!==c&&i.Z.getLogger(this).error(new n.Z("websocket-connection","Tried to set outFields, but server doesn't support it")),t.onmessage=r;for(const e of this._outstandingMessages)t.send(JSON.stringify(e));this._outstandingMessages=[],s.resolve()},t.send(JSON.stringify({filter:o,outFields:c,format:"json",spatialReference:{wkid:h.wkid}})),s.promise}_onMessage(e){if(this.onMessage(e),"type"in e)switch(e.type){case"features":case"featureResult":for(const t of e.features)null!=this._featureZScaler&&this._featureZScaler(t.geometry),this.onFeature(t)}}_onError(e){const t="Encountered an error over WebSocket connection";this._set("errorString",t),i.Z.getLogger(this).error("websocket-connection",t)}_onClose(e){this._websocket=null,this.notifyChange("connectionStatus"),1e3!==e.code&&i.Z.getLogger(this).error("websocket-connection",`WebSocket closed unexpectedly with error code ${e.code}`),this.destroyed||this._open()}};(0,r._)([(0,l.Cb)()],_.prototype,"connectionStatus",null),(0,r._)([(0,l.Cb)()],_.prototype,"errorString",void 0),_=(0,r._)([(0,h.j)("esri.layers.graphics.sources.connections.WebSocketConnection")],_);var p=s(34599),w=s(14165),b=s(33955),S=s(82971);const k={maxQueryDepth:5,maxRecordCountFactor:3};let v=class extends _{constructor(e){super({...k,...e}),this._buddyServicesQuery=null,this._relatedFeatures=null}async _open(){const e=await this._fetchServiceDefinition(this._config.source);e.timeInfo.trackIdField||i.Z.getLogger(this).warn("GeoEvent service was configured without a TrackIdField. This may result in certain functionality being disabled. The purgeOptions.maxObservations property will have no effect.");const t=this._fetchWebSocketUrl(e.streamUrls,this._config.spatialReference);this._buddyServicesQuery||(this._buddyServicesQuery=this._queryBuddyServices()),await this._buddyServicesQuery,await this._tryCreateWebSocket(t);const{filter:s,outFields:r}=this._config;this.destroyed||this._setFilter(s,r)}_onMessage(e){if("attributes"in e){let t;try{t=this._enrich(e),null!=this._featureZScaler&&this._featureZScaler(t.geometry)}catch(e){return void i.Z.getLogger(this).error(new n.Z("geoevent-connection","Failed to parse message",e))}this.onFeature(t)}else this.onMessage(e)}async _fetchServiceDefinition(e){const t={f:"json",...this._config.customParameters},s=(0,o.Z)(e.path,{query:t,responseType:"json"}),r=(await s).data;return this._serviceDefinition=r,r}_fetchWebSocketUrl(e,t){const s=e[0],{urls:r,token:o}=s,n=this._inferWebSocketBaseUrl(r);return(0,c.fl)(`${n}/subscribe`,{outSR:""+t.wkid,token:o})}_inferWebSocketBaseUrl(e){if(1===e.length)return e[0];for(const t of e)if(t.includes("wss"))return t;return i.Z.getLogger(this).error(new n.Z("geoevent-connection","Unable to infer WebSocket url",e)),null}async _setFilter(e,t){const s=this._websocket;if(null==s||null==e&&null==t)return;const r=JSON.stringify({filter:this._serializeFilter(e,t)});let o=!1;const c=(0,a.hh)();return s.onmessage=e=>{const t=JSON.parse(e.data);t.filter&&(t.error&&(i.Z.getLogger(this).error(new n.Z("geoevent-connection","Failed to set service filter",t.error)),this._set("errorString",`Could not set service filter - ${t.error}`),c.reject(t.error)),this._setWebSocketJSONParseHandler(s),o=!0,c.resolve())},s.send(r),setTimeout((()=>{o||(this.destroyed||this._websocket!==s||i.Z.getLogger(this).error(new n.Z("geoevent-connection","Server timed out when setting filter")),c.reject())}),1e4),c.promise}_serializeFilter(e,t){const s={};if(null==e&&null==t)return s;if(e?.geometry)try{const t=(0,b.im)(e.geometry);if("extent"!==t.type)throw new n.Z(`Expected extent but found type ${t.type}`);s.geometry=JSON.stringify(t.shiftCentralMeridian())}catch(e){i.Z.getLogger(this).error(new n.Z("geoevent-connection","Encountered an error when setting connection geometryDefinition",e))}return e?.where&&"1 = 1"!==e.where&&"1=1"!==e.where&&(s.where=e.where),null!=t&&(s.outFields=t.join(",")),s}_enrich(e){if(!this._relatedFeatures)return e;const t=this._serviceDefinition.relatedFeatures.joinField,s=e.attributes[t],r=this._relatedFeatures.get(s);if(!r)return i.Z.getLogger(this).warn("geoevent-connection","Feature join failed. Is the join field configured correctly?",e),e;const{attributes:o,geometry:a}=r;for(const t in o)e.attributes[t]=o[t];return a&&(e.geometry=a),e.geometry||e.centroid||i.Z.getLogger(this).error(new n.Z("geoevent-connection","Found malformed feature - no geometry found",e)),e}async _queryBuddyServices(){try{const{relatedFeatures:e,keepLatestArchive:t}=this._serviceDefinition,s=this._queryRelatedFeatures(e),r=this._queryArchive(t);await s;const o=await r;if(!o)return;for(const e of o.features)this.onFeature(this._enrich(e))}catch(e){i.Z.getLogger(this).error(new n.Z("geoevent-connection","Encountered an error when querying buddy services",{error:e}))}}async _queryRelatedFeatures(e){if(!e)return;const t=await this._queryBuddy(e.featuresUrl);this._addRelatedFeatures(t)}async _queryArchive(e){if(e)return this._queryBuddy(e.featuresUrl)}async _queryBuddy(e){const t=new((await Promise.all([s.e(163),s.e(4609),s.e(9790),s.e(8775),s.e(7899),s.e(1423),s.e(3778),s.e(6404),s.e(4680),s.e(9238),s.e(3342)]).then(s.bind(s,19238))).default)({url:e}),{capabilities:r}=await t.load(),o=r.query.supportsMaxRecordCountFactor,n=r.query.supportsPagination,i=r.query.supportsCentroid,a=this._config.maxRecordCountFactor,c=t.capabilities.query.maxRecordCount,h=o?c*a:c,l=new w.Z;if(l.outFields=this._config.outFields??["*"],l.where=this._config.filter?.where??"1=1",l.returnGeometry=!0,l.returnExceededLimitFeatures=!0,l.outSpatialReference=S.Z.fromJSON(this._config.spatialReference),i&&(l.returnCentroid=!0),o&&(l.maxRecordCountFactor=a),n)return l.num=h,t.destroy(),this._queryPages(e,l);const u=await(0,p.JT)(e,l,this._config.sourceSpatialReference);return t.destroy(),u.data}async _queryPages(e,t,s=[],r=0){t.start=null!=t.num?r*t.num:null;const{data:o}=await(0,p.JT)(e,t,this._config.sourceSpatialReference);return o.exceededTransferLimit&&r<(this._config.maxQueryDepth??0)?(o.features.forEach((e=>s.push(e))),this._queryPages(e,t,s,r+1)):(s.forEach((e=>o.features.push(e))),o)}_addRelatedFeatures(e){const t=new Map,s=e.features,r=this._serviceDefinition.relatedFeatures.joinField;for(const e of s){const s=e.attributes[r];t.set(s,e)}this._relatedFeatures=t}};v=(0,r._)([(0,h.j)("esri.layers.graphics.sources.connections.GeoEventConnection")],v);const F=v;let Z=class extends f{constructor(e){super(),this.connectionStatus="connected",this.errorString=null;const{geometryType:t,spatialReference:s,sourceSpatialReference:r}=e;this._featureZScaler=(0,u.k)(t,r,s)}updateCustomParameters(e){}sendMessageToSocket(e){}sendMessageToClient(e){if("type"in e)switch(e.type){case"features":case"featureResult":for(const t of e.features)null!=this._featureZScaler&&this._featureZScaler(t.geometry),this.onFeature(t)}this.onMessage(e)}};function C(e,t,s,r,o,n,i,a){const c={source:e,sourceSpatialReference:t,spatialReference:s,geometryType:r,filter:o,maxReconnectionAttempts:n,maxReconnectionInterval:i,customParameters:a};return e?e.path.startsWith("wss://")||e.path.startsWith("ws://")?new _(c):new F(c):new Z(c)}(0,r._)([(0,l.Cb)()],Z.prototype,"connectionStatus",void 0),(0,r._)([(0,l.Cb)()],Z.prototype,"errorString",void 0),Z=(0,r._)([(0,h.j)("esri.layers.support.ClientSideConnection")],Z)},28694:(e,t,s)=>{s.d(t,{p:()=>o});var r=s(69285);function o(e,t,s){if(!s?.features||!s.hasZ)return;const o=(0,r.k)(s.geometryType,t,e.outSpatialReference);if(null!=o)for(const e of s.features)o(e.geometry)}}}]);
1
+ "use strict";(self.webpackChunkRemoteClient=self.webpackChunkRemoteClient||[]).push([[2330],{70272:(e,t,s)=>{s.d(t,{S6:()=>o,nd:()=>n,u_:()=>r});class r{constructor(e=null,t={},s,r){this.geometry=e,this.attributes=t,this.centroid=s,this.objectId=r,this.displayId=0,this.geohashX=0,this.geohashY=0}weakClone(){const e=new r(this.geometry,this.attributes,this.centroid,this.objectId);return e.displayId=this.displayId,e.geohashX=this.geohashX,e.geohashY=this.geohashY,e}}function o(e){return!!e.geometry?.coords?.length}class n extends r{}},44876:(e,t,s)=>{s.d(t,{Z:()=>r});class r{constructor(){this.objectIdFieldName=null,this.globalIdFieldName=null,this.geohashFieldName=null,this.geometryProperties=null,this.geometryType=null,this.spatialReference=null,this.hasZ=!1,this.hasM=!1,this.features=[],this.fields=[],this.transform=null,this.exceededTransferLimit=!1,this.uniqueIdField=null,this.queryGeometryType=null,this.queryGeometry=null}weakClone(){const e=new r;return e.objectIdFieldName=this.objectIdFieldName,e.globalIdFieldName=this.globalIdFieldName,e.geohashFieldName=this.geohashFieldName,e.geometryProperties=this.geometryProperties,e.geometryType=this.geometryType,e.spatialReference=this.spatialReference,e.hasZ=this.hasZ,e.hasM=this.hasM,e.features=this.features,e.fields=this.fields,e.transform=this.transform,e.exceededTransferLimit=this.exceededTransferLimit,e.uniqueIdField=this.uniqueIdField,e.queryGeometry=this.queryGeometry,e.queryGeometryType=this.queryGeometryType,e}}},5428:(e,t,s)=>{s.d(t,{Z:()=>r});class r{constructor(e=[],t=[],s=!1){this.lengths=e??[],this.coords=t??[],this.hasIndeterminateRingOrder=s}static fromRect(e){const[t,s,o,n]=e,i=o-t,a=n-s;return new r([5],[t,s,i,0,0,a,-i,0,0,-a])}get isPoint(){return 0===this.lengths.length}get maxLength(){return Math.max(...this.lengths)}get size(){return this.lengths.reduce(((e,t)=>e+t))}forEachVertex(e){let t=0;this.lengths.length||e(this.coords[0],this.coords[1]);for(let s=0;s<this.lengths.length;s++){const r=this.lengths[s];for(let s=0;s<r;s++)e(this.coords[2*(s+t)],this.coords[2*(s+t)+1]);t+=r}}clone(e){return e?(e.set(this.coords),new r(this.lengths.slice(),e,this.hasIndeterminateRingOrder)):new r(this.lengths.slice(),this.coords.slice(),this.hasIndeterminateRingOrder)}}},95047:(e,t,s)=>{s.r(t),s.d(t,{createConnection:()=>C});var r=s(43697),o=(s(66577),s(3172)),n=s(20102),i=s(92604),a=s(95330),c=s(17452),h=(s(75215),s(67676),s(80442),s(52011)),l=s(5600),u=s(69285),d=s(32448);let g=class extends d.Z.EventedAccessor{destroy(){this.emit("destroy")}get connectionError(){return this.errorString?new n.Z("stream-connection",this.errorString):null}onFeature(e){this.emit("data-received",e)}onMessage(e){this.emit("message-received",e)}};(0,r._)([(0,l.Cb)({readOnly:!0})],g.prototype,"connectionError",null),g=(0,r._)([(0,h.j)("esri.layers.support.StreamConnection")],g);const f=g;var y,m;(m=y||(y={}))[m.CONNECTING=0]="CONNECTING",m[m.OPEN=1]="OPEN",m[m.CLOSING=2]="CLOSING",m[m.CLOSED=3]="CLOSED";let _=class extends f{constructor(e){super(),this._outstandingMessages=[],this.errorString=null;const{geometryType:t,spatialReference:s,sourceSpatialReference:r}=e;this._config=e,this._featureZScaler=(0,u.k)(t,r,s),this._open()}async _open(){await this._tryCreateWebSocket(),this.destroyed||await this._handshake()}destroy(){super.destroy(),null!=this._websocket&&(this._websocket.onopen=null,this._websocket.onclose=null,this._websocket.onerror=null,this._websocket.onmessage=null,this._websocket.close()),this._websocket=null}get connectionStatus(){if(null==this._websocket)return"disconnected";switch(this._websocket.readyState){case y.CONNECTING:case y.OPEN:return"connected";case y.CLOSING:case y.CLOSED:return"disconnected"}}sendMessageToSocket(e){null!=this._websocket?this._websocket.send(JSON.stringify(e)):this._outstandingMessages.push(e)}sendMessageToClient(e){this._onMessage(e)}updateCustomParameters(e){this._config.customParameters=e,null!=this._websocket&&this._websocket.close()}async _tryCreateWebSocket(e=this._config.source.path,t=1e3,s=0){try{if(this.destroyed)return;const t=(0,c.fl)(e,this._config.customParameters??{});this._websocket=await this._createWebSocket(t),this.notifyChange("connectionStatus")}catch(r){const o=t/1e3;return this._config.maxReconnectionAttempts&&s>=this._config.maxReconnectionAttempts?(i.Z.getLogger(this).error(new n.Z("websocket-connection","Exceeded maxReconnectionAttempts attempts. No further attempts will be made")),void this.destroy()):(i.Z.getLogger(this).error(new n.Z("websocket-connection",`Failed to connect. Attempting to reconnect in ${o}s`,r)),await(0,a.e4)(t),this._tryCreateWebSocket(e,Math.min(1.5*t,1e3*this._config.maxReconnectionInterval),s+1))}}_setWebSocketJSONParseHandler(e){e.onmessage=e=>{try{const t=JSON.parse(e.data);this._onMessage(t)}catch(e){return void i.Z.getLogger(this).error(new n.Z("websocket-connection","Failed to parse message, invalid JSON",{error:e}))}}}_createWebSocket(e){return new Promise(((t,s)=>{const r=new WebSocket(e);r.onopen=()=>{if(r.onopen=null,this.destroyed)return r.onclose=null,void r.close();r.onclose=e=>this._onClose(e),r.onerror=e=>this._onError(e),this._setWebSocketJSONParseHandler(r),t(r)},r.onclose=e=>{r.onopen=r.onclose=null,s(e)}}))}async _handshake(e=1e4){const t=this._websocket;if(null==t)return;const s=(0,a.hh)(),r=t.onmessage,{filter:o,outFields:c,spatialReference:h}=this._config;return s.timeout(e),t.onmessage=e=>{let a=null;try{a=JSON.parse(e.data)}catch(e){}a&&"object"==typeof a||(i.Z.getLogger(this).error(new n.Z("websocket-connection","Protocol violation. Handshake failed - malformed message",e.data)),s.reject(),this.destroy()),a.spatialReference?.wkid!==h?.wkid&&(i.Z.getLogger(this).error(new n.Z("websocket-connection",`Protocol violation. Handshake failed - expected wkid of ${h.wkid}`,e.data)),s.reject(),this.destroy()),"json"!==a.format&&(i.Z.getLogger(this).error(new n.Z("websocket-connection","Protocol violation. Handshake failed - format is not set",e.data)),s.reject(),this.destroy()),o&&a.filter!==o&&i.Z.getLogger(this).error(new n.Z("websocket-connection","Tried to set filter, but server doesn't support it")),c&&a.outFields!==c&&i.Z.getLogger(this).error(new n.Z("websocket-connection","Tried to set outFields, but server doesn't support it")),t.onmessage=r;for(const e of this._outstandingMessages)t.send(JSON.stringify(e));this._outstandingMessages=[],s.resolve()},t.send(JSON.stringify({filter:o,outFields:c,format:"json",spatialReference:{wkid:h.wkid}})),s.promise}_onMessage(e){if(this.onMessage(e),"type"in e)switch(e.type){case"features":case"featureResult":for(const t of e.features)null!=this._featureZScaler&&this._featureZScaler(t.geometry),this.onFeature(t)}}_onError(e){const t="Encountered an error over WebSocket connection";this._set("errorString",t),i.Z.getLogger(this).error("websocket-connection",t)}_onClose(e){this._websocket=null,this.notifyChange("connectionStatus"),1e3!==e.code&&i.Z.getLogger(this).error("websocket-connection",`WebSocket closed unexpectedly with error code ${e.code}`),this.destroyed||this._open()}};(0,r._)([(0,l.Cb)()],_.prototype,"connectionStatus",null),(0,r._)([(0,l.Cb)()],_.prototype,"errorString",void 0),_=(0,r._)([(0,h.j)("esri.layers.graphics.sources.connections.WebSocketConnection")],_);var p=s(34599),w=s(14165),b=s(33955),S=s(82971);const k={maxQueryDepth:5,maxRecordCountFactor:3};let v=class extends _{constructor(e){super({...k,...e}),this._buddyServicesQuery=null,this._relatedFeatures=null}async _open(){const e=await this._fetchServiceDefinition(this._config.source);e.timeInfo.trackIdField||i.Z.getLogger(this).warn("GeoEvent service was configured without a TrackIdField. This may result in certain functionality being disabled. The purgeOptions.maxObservations property will have no effect.");const t=this._fetchWebSocketUrl(e.streamUrls,this._config.spatialReference);this._buddyServicesQuery||(this._buddyServicesQuery=this._queryBuddyServices()),await this._buddyServicesQuery,await this._tryCreateWebSocket(t);const{filter:s,outFields:r}=this._config;this.destroyed||this._setFilter(s,r)}_onMessage(e){if("attributes"in e){let t;try{t=this._enrich(e),null!=this._featureZScaler&&this._featureZScaler(t.geometry)}catch(e){return void i.Z.getLogger(this).error(new n.Z("geoevent-connection","Failed to parse message",e))}this.onFeature(t)}else this.onMessage(e)}async _fetchServiceDefinition(e){const t={f:"json",...this._config.customParameters},s=(0,o.Z)(e.path,{query:t,responseType:"json"}),r=(await s).data;return this._serviceDefinition=r,r}_fetchWebSocketUrl(e,t){const s=e[0],{urls:r,token:o}=s,n=this._inferWebSocketBaseUrl(r);return(0,c.fl)(`${n}/subscribe`,{outSR:""+t.wkid,token:o})}_inferWebSocketBaseUrl(e){if(1===e.length)return e[0];for(const t of e)if(t.includes("wss"))return t;return i.Z.getLogger(this).error(new n.Z("geoevent-connection","Unable to infer WebSocket url",e)),null}async _setFilter(e,t){const s=this._websocket;if(null==s||null==e&&null==t)return;const r=JSON.stringify({filter:this._serializeFilter(e,t)});let o=!1;const c=(0,a.hh)();return s.onmessage=e=>{const t=JSON.parse(e.data);t.filter&&(t.error&&(i.Z.getLogger(this).error(new n.Z("geoevent-connection","Failed to set service filter",t.error)),this._set("errorString",`Could not set service filter - ${t.error}`),c.reject(t.error)),this._setWebSocketJSONParseHandler(s),o=!0,c.resolve())},s.send(r),setTimeout((()=>{o||(this.destroyed||this._websocket!==s||i.Z.getLogger(this).error(new n.Z("geoevent-connection","Server timed out when setting filter")),c.reject())}),1e4),c.promise}_serializeFilter(e,t){const s={};if(null==e&&null==t)return s;if(e?.geometry)try{const t=(0,b.im)(e.geometry);if("extent"!==t.type)throw new n.Z(`Expected extent but found type ${t.type}`);s.geometry=JSON.stringify(t.shiftCentralMeridian())}catch(e){i.Z.getLogger(this).error(new n.Z("geoevent-connection","Encountered an error when setting connection geometryDefinition",e))}return e?.where&&"1 = 1"!==e.where&&"1=1"!==e.where&&(s.where=e.where),null!=t&&(s.outFields=t.join(",")),s}_enrich(e){if(!this._relatedFeatures)return e;const t=this._serviceDefinition.relatedFeatures.joinField,s=e.attributes[t],r=this._relatedFeatures.get(s);if(!r)return i.Z.getLogger(this).warn("geoevent-connection","Feature join failed. Is the join field configured correctly?",e),e;const{attributes:o,geometry:a}=r;for(const t in o)e.attributes[t]=o[t];return a&&(e.geometry=a),e.geometry||e.centroid||i.Z.getLogger(this).error(new n.Z("geoevent-connection","Found malformed feature - no geometry found",e)),e}async _queryBuddyServices(){try{const{relatedFeatures:e,keepLatestArchive:t}=this._serviceDefinition,s=this._queryRelatedFeatures(e),r=this._queryArchive(t);await s;const o=await r;if(!o)return;for(const e of o.features)this.onFeature(this._enrich(e))}catch(e){i.Z.getLogger(this).error(new n.Z("geoevent-connection","Encountered an error when querying buddy services",{error:e}))}}async _queryRelatedFeatures(e){if(!e)return;const t=await this._queryBuddy(e.featuresUrl);this._addRelatedFeatures(t)}async _queryArchive(e){if(e)return this._queryBuddy(e.featuresUrl)}async _queryBuddy(e){const t=new((await Promise.all([s.e(163),s.e(4609),s.e(9790),s.e(8775),s.e(7899),s.e(1423),s.e(3778),s.e(7215),s.e(4723),s.e(9238),s.e(3342)]).then(s.bind(s,19238))).default)({url:e}),{capabilities:r}=await t.load(),o=r.query.supportsMaxRecordCountFactor,n=r.query.supportsPagination,i=r.query.supportsCentroid,a=this._config.maxRecordCountFactor,c=t.capabilities.query.maxRecordCount,h=o?c*a:c,l=new w.Z;if(l.outFields=this._config.outFields??["*"],l.where=this._config.filter?.where??"1=1",l.returnGeometry=!0,l.returnExceededLimitFeatures=!0,l.outSpatialReference=S.Z.fromJSON(this._config.spatialReference),i&&(l.returnCentroid=!0),o&&(l.maxRecordCountFactor=a),n)return l.num=h,t.destroy(),this._queryPages(e,l);const u=await(0,p.JT)(e,l,this._config.sourceSpatialReference);return t.destroy(),u.data}async _queryPages(e,t,s=[],r=0){t.start=null!=t.num?r*t.num:null;const{data:o}=await(0,p.JT)(e,t,this._config.sourceSpatialReference);return o.exceededTransferLimit&&r<(this._config.maxQueryDepth??0)?(o.features.forEach((e=>s.push(e))),this._queryPages(e,t,s,r+1)):(s.forEach((e=>o.features.push(e))),o)}_addRelatedFeatures(e){const t=new Map,s=e.features,r=this._serviceDefinition.relatedFeatures.joinField;for(const e of s){const s=e.attributes[r];t.set(s,e)}this._relatedFeatures=t}};v=(0,r._)([(0,h.j)("esri.layers.graphics.sources.connections.GeoEventConnection")],v);const F=v;let Z=class extends f{constructor(e){super(),this.connectionStatus="connected",this.errorString=null;const{geometryType:t,spatialReference:s,sourceSpatialReference:r}=e;this._featureZScaler=(0,u.k)(t,r,s)}updateCustomParameters(e){}sendMessageToSocket(e){}sendMessageToClient(e){if("type"in e)switch(e.type){case"features":case"featureResult":for(const t of e.features)null!=this._featureZScaler&&this._featureZScaler(t.geometry),this.onFeature(t)}this.onMessage(e)}};function C(e,t,s,r,o,n,i,a){const c={source:e,sourceSpatialReference:t,spatialReference:s,geometryType:r,filter:o,maxReconnectionAttempts:n,maxReconnectionInterval:i,customParameters:a};return e?e.path.startsWith("wss://")||e.path.startsWith("ws://")?new _(c):new F(c):new Z(c)}(0,r._)([(0,l.Cb)()],Z.prototype,"connectionStatus",void 0),(0,r._)([(0,l.Cb)()],Z.prototype,"errorString",void 0),Z=(0,r._)([(0,h.j)("esri.layers.support.ClientSideConnection")],Z)},28694:(e,t,s)=>{s.d(t,{p:()=>o});var r=s(69285);function o(e,t,s){if(!s?.features||!s.hasZ)return;const o=(0,r.k)(s.geometryType,t,e.outSpatialReference);if(null!=o)for(const e of s.features)o(e.geometry)}}}]);
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunkRemoteClient=self.webpackChunkRemoteClient||[]).push([[7021,5732,5935],{5732:(e,t,i)=>{i.d(t,{c:()=>n,g:()=>r});var n="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function r(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}},60437:(e,t,i)=>{i.d(t,{G_:()=>w,HH:()=>s,JR:()=>h,TC:()=>a,Tn:()=>c,Ue:()=>r,al:()=>o,bZ:()=>m,cS:()=>y,dp:()=>u,fS:()=>b,is:()=>f,op:()=>d,pp:()=>l,t8:()=>p});var n=i(6570);function r(e=g){return[e[0],e[1],e[2],e[3],e[4],e[5]]}function o(e,t,i,n,o,s,a=r()){return a[0]=e,a[1]=t,a[2]=i,a[3]=n,a[4]=o,a[5]=s,a}function s(e,t){const i=isFinite(e[2])||isFinite(e[5]);return new n.Z(i?{xmin:e[0],xmax:e[3],ymin:e[1],ymax:e[4],zmin:e[2],zmax:e[5],spatialReference:t}:{xmin:e[0],xmax:e[3],ymin:e[1],ymax:e[4],spatialReference:t})}function a(e,t){e[0]=Math.min(e[0],t[0]),e[1]=Math.min(e[1],t[1]),e[2]=Math.min(e[2],t[2]),e[3]=Math.max(e[3],t[3]),e[4]=Math.max(e[4],t[4]),e[5]=Math.max(e[5],t[5])}function l(e,t){e[0]=Math.min(e[0],t[0]),e[1]=Math.min(e[1],t[1]),e[2]=Math.min(e[2],t[2]),e[3]=Math.max(e[3],t[0]),e[4]=Math.max(e[4],t[1]),e[5]=Math.max(e[5],t[2])}function u(e,t=[0,0,0]){return t[0]=function(e){return e[0]>=e[3]?0:e[3]-e[0]}(e),t[1]=function(e){return e[1]>=e[4]?0:e[4]-e[1]}(e),t[2]=function(e){return e[2]>=e[5]?0:e[5]-e[2]}(e),t}function d(e,t,i=e){return i[0]=t[0],i[1]=t[1],i[2]=t[2],i!==e&&(i[3]=e[3],i[4]=e[4],i[5]=e[5]),i}function c(e,t,i=e){return i[3]=t[0],i[4]=t[1],i[5]=t[2],i!==e&&(i[0]=e[0],i[1]=e[1],i[2]=e[2]),e}function p(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e}function y(e){return e?p(e,w):r(w)}function h(e,t){return e[0]=t[0],e[1]=t[1],e[2]=Number.NEGATIVE_INFINITY,e[3]=t[2],e[4]=t[3],e[5]=Number.POSITIVE_INFINITY,e}function m(e,t,i,n,r){return e[0]=t,e[1]=i,e[2]=Number.NEGATIVE_INFINITY,e[3]=n,e[4]=r,e[5]=Number.POSITIVE_INFINITY,e}function f(e){return 6===e.length}function b(e,t,i){if(null==e||null==t)return e===t;if(!f(e)||!f(t))return!1;if(i){for(let n=0;n<e.length;n++)if(!i(e[n],t[n]))return!1}else for(let i=0;i<e.length;i++)if(e[i]!==t[i])return!1;return!0}i(24470);const w=[1/0,1/0,1/0,-1/0,-1/0,-1/0],g=[0,0,0,0,0,0];r()},1231:(e,t,i)=>{i.d(t,{Z:()=>f});var n,r=i(43697),o=i(35454),s=i(96674),a=i(5600),l=i(75215),u=(i(67676),i(80442),i(36030)),d=i(71715),c=i(52011),p=i(72729),y=i(86719);const h=new o.X({binary:"binary",coordinate:"coordinate",countOrAmount:"count-or-amount",dateAndTime:"date-and-time",description:"description",locationOrPlaceName:"location-or-place-name",measurement:"measurement",nameOrTitle:"name-or-title",none:"none",orderedOrRanked:"ordered-or-ranked",percentageOrRatio:"percentage-or-ratio",typeOrCategory:"type-or-category",uniqueIdentifier:"unique-identifier"});let m=n=class extends s.wq{constructor(e){super(e),this.alias=null,this.defaultValue=void 0,this.description=null,this.domain=null,this.editable=!0,this.length=void 0,this.name=null,this.nullable=!0,this.type=null,this.valueType=null,this.visible=!0}readDescription(e,{description:t}){let i=null;try{i=t?JSON.parse(t):null}catch(e){}return i?.value??null}readValueType(e,{description:t}){let i=null;try{i=t?JSON.parse(t):null}catch(e){}return i?h.fromJSON(i.fieldValueType):null}clone(){return new n({alias:this.alias,defaultValue:this.defaultValue,description:this.description,domain:this.domain&&this.domain.clone()||null,editable:this.editable,length:this.length,name:this.name,nullable:this.nullable,type:this.type,valueType:this.valueType,visible:this.visible})}};(0,r._)([(0,a.Cb)({type:String,json:{write:!0}})],m.prototype,"alias",void 0),(0,r._)([(0,a.Cb)({type:[String,Number],json:{write:{allowNull:!0}}})],m.prototype,"defaultValue",void 0),(0,r._)([(0,a.Cb)()],m.prototype,"description",void 0),(0,r._)([(0,d.r)("description")],m.prototype,"readDescription",null),(0,r._)([(0,a.Cb)({types:p.V5,json:{read:{reader:p.im},write:!0}})],m.prototype,"domain",void 0),(0,r._)([(0,a.Cb)({type:Boolean,json:{write:!0}})],m.prototype,"editable",void 0),(0,r._)([(0,a.Cb)({type:l.z8,json:{write:{overridePolicy:e=>({enabled:Number.isFinite(e)})}}})],m.prototype,"length",void 0),(0,r._)([(0,a.Cb)({type:String,json:{write:!0}})],m.prototype,"name",void 0),(0,r._)([(0,a.Cb)({type:Boolean,json:{write:!0}})],m.prototype,"nullable",void 0),(0,r._)([(0,u.J)(y.v)],m.prototype,"type",void 0),(0,r._)([(0,a.Cb)()],m.prototype,"valueType",void 0),(0,r._)([(0,d.r)("valueType",["description"])],m.prototype,"readValueType",null),(0,r._)([(0,a.Cb)({type:Boolean,json:{read:!1}})],m.prototype,"visible",void 0),m=n=(0,r._)([(0,c.j)("esri.layers.support.Field")],m);const f=m},99514:(e,t,i)=>{i.d(t,{Z:()=>l});var n=i(20102),r=i(96674),o=i(92604),s=i(69165),a=i(25031);class l{static fromJSON(e){return new l(e.fields,e.timeZoneByFieldName)}static fromLayer(e){return new l(e.fields??[],p(e))}static fromLayerJSON(e){return new l(e.fields??[],p(e))}constructor(e=[],t){this._fieldsMap=new Map,this._normalizedFieldsMap=new Map,this._dateFieldsSet=new Set,this._numericFieldsSet=new Set,this._requiredFields=null,this.dateFields=[],this.numericFields=[],this.fields=e||[],this._timeZoneByFieldName=t?new Map(t):null;const i=[];for(const e of this.fields){const t=e?.name,n=d(t);if(t&&n){const r=u(t);this._fieldsMap.set(t,e),this._fieldsMap.set(r,e),this._normalizedFieldsMap.set(n,e),i.push(`${r}:${e.type}:${this._timeZoneByFieldName?.get(t)}`),(0,s.y2)(e)?(this.dateFields.push(e),this._dateFieldsSet.add(e)):(0,s.H7)(e)&&(this._numericFieldsSet.add(e),this.numericFields.push(e)),(0,s.Dl)(e)||(0,s.Se)(e)||(e.editable=null==e.editable||!!e.editable,e.nullable=null==e.nullable||!!e.nullable)}}i.sort(),this.uid=i.join()}get requiredFields(){if(!this._requiredFields){this._requiredFields=[];for(const e of this.fields)(0,s.Dl)(e)||(0,s.Se)(e)||e.nullable||void 0!==(0,s.os)(e)||this._requiredFields.push(e)}return this._requiredFields}equals(e){return this.uid===e?.uid}has(e){return null!=this.get(e)}get(e){if(!e)return;let t=this._fieldsMap.get(e);return t||(t=this._fieldsMap.get(u(e))??this._normalizedFieldsMap.get(d(e)),t&&this._fieldsMap.set(e,t),t)}getTimeZone(e){const t=this.get(e&&"string"!=typeof e?e.name:e);return t?this._timeZoneByFieldName?this._timeZoneByFieldName.get(t.name):"date"===t.type||"esriFieldTypeDate"===t.type?(o.Z.getLogger("esri.layers.support.FieldsIndex").error(new n.Z("getTimeZone:no-timezone-information",`no time zone information for field '${t.name}'`)),a.pt):c.has(t.type)?a._4:null:null}isDateField(e){return this._dateFieldsSet.has(this.get(e))}isTimeOnlyField(e){return(0,s.sX)(this.get(e))}isNumericField(e){return this._numericFieldsSet.has(this.get(e))}normalizeFieldName(e){return this.get(e)?.name??void 0}toJSON(){return{fields:this.fields.map((e=>(0,r.AK)(e)?e.toJSON():e)),timeZoneByFieldName:this._timeZoneByFieldName?Array.from(this._timeZoneByFieldName.entries()):null}}}function u(e){return e.trim().toLowerCase()}function d(e){return(0,s.q6)(e)?.toLowerCase()??""}const c=new Set(["time-only","date-only","timestamp-offset","esriFieldTypeDateOnly","esriFieldTypeTimeOnly","esriFieldTypeTimestampOffset"]);function p(e){const t=new Map;if(!e.fields)return t;const i=!0===e.datesInUnknownTimezone,{timeInfo:n,editFieldsInfo:r}=e,o=(n?"startField"in n?n.startField:n.startTimeField:"")??"",s=(n?"endField"in n?n.endField:n.endTimeField:"")??"",l=function(e){return"dateFieldsTimeZone"in e}(e)?e.dateFieldsTimeZone??null:e.dateFieldsTimeReference?(0,a.Jv)(e.dateFieldsTimeReference):null,d=r?function(e){return"timeZone"in e}(r)?r.timeZone??l:r.dateFieldsTimeReference?(0,a.Jv)(r.dateFieldsTimeReference):l??a.pt:null,p=n?function(e){return"timeZone"in e}(n)?n.timeZone??l:n.timeReference?(0,a.Jv)(n.timeReference):l:null,y=new Map([[u(r?.creationDateField??""),d],[u(r?.editDateField??""),d],[u(o),p],[u(s),p]]);for(const{name:n,type:r}of e.fields)if(c.has(r))t.set(n,a._4);else if("date"!==r&&"esriFieldTypeDate"!==r)t.set(n,null);else if(i)t.set(n,a._4);else{const e=y.get(u(n??""))??l;t.set(n,e)}return t}},72729:(e,t,i)=>{i.d(t,{im:()=>T,V5:()=>I}),i(80442);var n,r=i(43697),o=i(22974),s=i(5600),a=(i(75215),i(36030)),l=i(52011),u=i(96674);i(67676);let d=n=class extends u.wq{constructor(e){super(e),this.name=null,this.code=null}clone(){return new n({name:this.name,code:this.code})}};(0,r._)([(0,s.Cb)({type:String,json:{write:!0}})],d.prototype,"name",void 0),(0,r._)([(0,s.Cb)({type:[String,Number],json:{write:!0}})],d.prototype,"code",void 0),d=n=(0,r._)([(0,l.j)("esri.layers.support.CodedValue")],d);const c=new(i(35454).X)({inherited:"inherited",codedValue:"coded-value",range:"range"});let p=class extends u.wq{constructor(e){super(e),this.name=null,this.type=null}};(0,r._)([(0,s.Cb)({type:String,json:{write:!0}})],p.prototype,"name",void 0),(0,r._)([(0,a.J)(c)],p.prototype,"type",void 0),p=(0,r._)([(0,l.j)("esri.layers.support.Domain")],p);const y=p;var h;let m=h=class extends y{constructor(e){super(e),this.codedValues=null,this.type="coded-value"}getName(e){let t=null;if(this.codedValues){const i=String(e);this.codedValues.some((e=>(String(e.code)===i&&(t=e.name),!!t)))}return t}clone(){return new h({codedValues:(0,o.d9)(this.codedValues),name:this.name})}};(0,r._)([(0,s.Cb)({type:[d],json:{write:!0}})],m.prototype,"codedValues",void 0),(0,r._)([(0,a.J)({codedValue:"coded-value"})],m.prototype,"type",void 0),m=h=(0,r._)([(0,l.j)("esri.layers.support.CodedValueDomain")],m);const f=m;var b;i(92604),i(20102);let w=b=class extends y{constructor(e){super(e),this.type="inherited"}clone(){return new b}};(0,r._)([(0,a.J)({inherited:"inherited"})],w.prototype,"type",void 0),w=b=(0,r._)([(0,l.j)("esri.layers.support.InheritedDomain")],w);const g=w;var F;let _=F=class extends y{constructor(e){super(e),this.maxValue=null,this.minValue=null,this.type="range"}clone(){return new F({maxValue:this.maxValue,minValue:this.minValue,name:this.name})}};(0,r._)([(0,s.Cb)({json:{type:[Number],read:{source:"range",reader:(e,t)=>t.range?.[1]},write:{enabled:!1,overridePolicy(){return{enabled:null!=this.maxValue&&null==this.minValue}},target:"range",writer(e,t,i){t[i]=[this.minValue||0,e]}}}})],_.prototype,"maxValue",void 0),(0,r._)([(0,s.Cb)({json:{type:[Number],read:{source:"range",reader:(e,t)=>t.range?.[0]},write:{target:"range",writer(e,t,i){t[i]=[e,this.maxValue||0]}}}})],_.prototype,"minValue",void 0),(0,r._)([(0,a.J)({range:"range"})],_.prototype,"type",void 0),_=F=(0,r._)([(0,l.j)("esri.layers.support.RangeDomain")],_);const v=_,I={key:"type",base:y,typeMap:{range:_,"coded-value":f,inherited:g}};function T(e){if(!e?.type)return null;switch(e.type){case"range":return v.fromJSON(e);case"codedValue":return f.fromJSON(e);case"inherited":return g.fromJSON(e)}return null}},45574:(e,t,i)=>{i.d(t,{JD:()=>g,Jj:()=>v,sX:()=>E,Ob:()=>G,rP:()=>V,FV:()=>T,nU:()=>P,Ci:()=>S,Fr:()=>w,HW:()=>B,gG:()=>N,uA:()=>L,SU:()=>j,KE:()=>Z,VG:()=>O,tD:()=>C,kp:()=>x,C9:()=>M,rk:()=>q,kZ:()=>R,JY:()=>A,Y5:()=>_,uj:()=>I});var n=i(40330),r=i(9790),o=i(66643),s=i(20102),a=i(35454),l=i(42033),u=i(63213),d=i(14165);async function c(e,t,i){t=t.clone(),e.capabilities.query.supportsMaxRecordCountFactor&&(t.maxRecordCountFactor=p(e));const n=function(e){return p(e)*function(e){return e.capabilities.query.maxRecordCount||2e3}(e)}(e),r=e.capabilities.query.supportsPagination;t.start=0,t.num=n;let o=null;for(;;){const s=await e.source.queryFeaturesJSON(t,i);if(null==o?o=s:o.features=o.features.concat(s.features),o.exceededTransferLimit=s.exceededTransferLimit,!r||!s.exceededTransferLimit)break;t.start+=n}return o}function p(e){return e.capabilities.query.supportsMaxRecordCountFactor?d.Z.MAX_MAX_RECORD_COUNT_FACTOR:1}var y=i(84230),h=i(84382),m=i(81571),f=i(56545),b=i(75935);const w=new a.X({esriGeometryPoint:"point",esriGeometryMultipoint:"multipoint",esriGeometryPolyline:"polyline",esriGeometryPolygon:"polygon",esriGeometryMultiPatch:"multipatch"});async function g(e,t,i,n){const r=await D(e);if(await F(e,t,n),!r.addAttachment)throw new s.Z(n,"Layer source does not support addAttachment capability");return r.addAttachment(t,i)}function F(e,t,i){const{attributes:n}=t,{objectIdField:r}=e;return e.capabilities?.data?.supportsAttachment?t?n?r&&n[r]?Promise.resolve():Promise.reject(new s.Z(i,`feature is missing the identifying attribute ${r}`)):Promise.reject(new s.Z(i,"'attributes' are required on a feature to query attachments")):Promise.reject(new s.Z(i,"A feature is required to add/delete/update attachments")):Promise.reject(new s.Z(i,"this layer doesn't support attachments"))}async function _(e,t,i,n,r){const o=await D(e);if(await F(e,t,r),!o.updateAttachment)throw new s.Z(r,"Layer source does not support updateAttachment capability");return o.updateAttachment(t,i,n)}async function v(e,t,n){const{applyEdits:r}=await i.e(4720).then(i.bind(i,14720)),o=await e.load(),{source:s,globalIdField:a}=o;let l=n;return("feature"===o.type?o.infoFor3D:null)&&null!=t.deleteFeatures&&null!=a&&(l={...l,globalIdToObjectId:await B(e,t.deleteFeatures,a)}),r(o,s,t,n)}async function I(e,t,n){const{uploadAssets:r}=await i.e(4720).then(i.bind(i,14720)),o=await e.load();return r(o,o.source,t,n)}async function T(e,t,i,n){const r=await D(e);if(await F(e,t,n),!r.deleteAttachments)throw new s.Z(n,"Layer source does not support deleteAttachments capability");return r.deleteAttachments(t,i)}async function S(e,t,i){const n=(await e.load({signal:t?.signal})).source;if(!n.fetchRecomputedExtents)throw new s.Z(i,"Layer source does not support fetchUpdates capability");return n.fetchRecomputedExtents(t)}async function j(e,t,i,n){t=f.Z.from(t),await e.load();const r=e.source,o=e.capabilities;if(!o?.data?.supportsAttachment)throw new s.Z(n,"this layer doesn't support attachments");const{attachmentTypes:a,objectIds:l,globalIds:u,num:d,size:c,start:p,where:y}=t;if(!o?.operations?.supportsQueryAttachments&&(a?.length>0||u?.length>0||c?.length>0||d||p||y))throw new s.Z(n,"when 'capabilities.operations.supportsQueryAttachments' is false, only objectIds is supported",t);if(!(l?.length||u?.length||y))throw new s.Z(n,"'objectIds', 'globalIds', or 'where' are required to perform attachment query",t);if(!r.queryAttachments)throw new s.Z(n,"Layer source does not support queryAttachments capability",t);return r.queryAttachments(t)}async function C(e,t,i,n){const r=await D(e);if(!r.queryObjectIds)throw new s.Z(n,"Layer source does not support queryObjectIds capability");return r.queryObjectIds(d.Z.from(t)??e.createQuery(),i)}async function O(e,t,i,n){const r=await D(e);if(!r.queryFeatureCount)throw new s.Z(n,"Layer source does not support queryFeatureCount capability");return r.queryFeatureCount(d.Z.from(t)??e.createQuery(),i)}async function Z(e,t,i,n){const r=await D(e);if(!r.queryExtent)throw new s.Z(n,"Layer source does not support queryExtent capability");return r.queryExtent(d.Z.from(t)??e.createQuery(),i)}async function x(e,t,i,n){const r=await D(e);if(!r.queryRelatedFeatures)throw new s.Z(n,"Layer source does not support queryRelatedFeatures capability");return r.queryRelatedFeatures(b.default.from(t),i)}async function M(e,t,i,n){const r=await D(e);if(!r.queryRelatedFeaturesCount)throw new s.Z(n,"Layer source does not support queryRelatedFeaturesCount capability");return r.queryRelatedFeaturesCount(b.default.from(t),i)}async function N(e){const t=e.source;if(t?.refresh)try{const{dataChanged:i,updates:n}=await t.refresh();if(null!=n&&(e.sourceJSON={...e.sourceJSON,...n},e.read(n,{origin:"service",url:e.parsedUrl})),i)return!0}catch{}if(e.definitionExpression)try{return(await(0,l.E)(e.definitionExpression,e.fieldsIndex)).hasDateFunctions}catch{}return!1}function V(e){const t=new d.Z,i=e.capabilities?.data,n=e.capabilities?.query;t.historicMoment=e.historicMoment,t.gdbVersion=e.gdbVersion,t.returnGeometry=!0,n&&(t.compactGeometryEnabled=n.supportsCompactGeometry,t.defaultSpatialReferenceEnabled=n.supportsDefaultSpatialReference),i&&(i.supportsZ&&null!=e.returnZ&&(t.returnZ=e.returnZ),i.supportsM&&null!=e.returnM&&(t.returnM=e.returnM)),t.outFields=["*"];const{timeOffset:r,timeExtent:o}=e;return t.timeExtent=null!=r&&null!=o?o.offset(-r.value,r.unit):o||null,t.multipatchOption="multipatch"===e.geometryType?"xyFootprint":null,t}function q(e){const{globalIdField:t,fields:i}=e;if(t)return t;if(i)for(const e of i)if("esriFieldTypeGlobalID"===e.type)return e.name}function R(e){const{objectIdField:t,fields:i}=e;if(t)return t;if(i)for(const e of i)if("esriFieldTypeOID"===e.type)return e.name}function A(e){return e.currentVersion?e.currentVersion:e.hasOwnProperty("capabilities")||e.hasOwnProperty("drawingInfo")||e.hasOwnProperty("hasAttachments")||e.hasOwnProperty("htmlPopupType")||e.hasOwnProperty("relationships")||e.hasOwnProperty("timeInfo")||e.hasOwnProperty("typeIdField")||e.hasOwnProperty("types")?10:9.3}async function D(e){return(await e.load()).source}async function P(e,t,i){const r=e.parsedUrl?.path;r&&e.authenticationTriggerEvent===t&&await async function(e,t){if(!n.id)return;if(n.id.findCredential(e))return;let i;try{const r=await(0,y.oP)(e,t);r&&(i=await n.id.checkSignInStatus(`${r}/sharing`))}catch(e){}if(i)try{const i=null!=t?t.signal:null;await n.id.getCredential(e,{signal:i})}catch(e){}}(r,i)}function E(e){return!e.sourceJSON?.isMultiServicesView&&(e.userHasUpdateItemPrivileges||e.editingEnabled)}const J=(0,u.d)({types:r.QT});function G(e,t){if(e.defaultSymbol)return e.types?.length?new m.Z({defaultSymbol:J(e.defaultSymbol,e,t),field:e.typeIdField,uniqueValueInfos:e.types.map((e=>({id:e.id,symbol:J(e.symbol,e,t)})))}):new h.Z({symbol:J(e.defaultSymbol,e,t)})}function L(e){let t=e.sourceJSON?.cacheMaxAge;if(!t)return!1;const i=e.editingInfo?.lastEditDate?.getTime();return null==i||(t*=1e3,Date.now()-i<t)}async function B(e,t,i){if(null==t)return null;const n=[],{objectIdField:r}=e;if(t.forEach((e=>{let t=null;if("attributes"in e){const{attributes:n}=e;t={globalId:n[i],objectId:null!=n[r]&&-1!==n[r]?n[r]:null}}else t={globalId:e.globalId,objectId:null!=e.objectId&&-1!==e.objectId?e.objectId:null};null!=t.globalId&&(null!=t.objectId&&-1!==t.objectId||n.push(t.globalId))})),0===n.length)return null;const s=e.createQuery();s.where=n.map((e=>`${i}='${e}'`)).join(" OR "),s.returnGeometry=!1,s.outFields=[r,i],s.cacheHint=!1;const a=await(0,o.mt)(c(e,s));if(!a.ok)return null;const l=new Map,u=a.value.features;for(const e of u){const t=e.attributes[i],n=e.attributes[r];null!=t&&null!=n&&-1!==n&&l.set(t,n)}return l}},53518:(e,t,i)=>{i.d(t,{v:()=>l});var n=i(80442),r=i(92604),o=i(1231),s=i(99514),a=i(69165);function l(){return{fields:{type:[o.Z],value:null,set:function(e){if(e&&(0,n.Z)("big-integer-warning-enabled")){const t=e.filter((e=>"big-integer"===e.type||"oid"===e.type&&(e.length||0)>=8));if(t.length){const e=t.map((e=>`'${e.name}'`)).join(", ");r.Z.getLogger(this).warn("#fields",`Layer (title: '${this.title??"no title"}', id: '${this.id??"no id"}') references big-integer field(s): ${e}, support for which is experimental. Only integers less than ${Number.MAX_SAFE_INTEGER} (Number.MAX_SAFE_INTEGER) are supported.`)}}this._set("fields",e)}},fieldsIndex:{readOnly:!0,get(){return s.Z.fromLayer(this)}},outFields:{type:[String],json:{read:!1},set:function(e){this._userOutFields=e,this.notifyChange("outFields")},get:function(){const e=this._userOutFields;if(!e?.length)return null;if(e.includes("*"))return["*"];if(!this.fields)return e;for(const t of e){const i=this.fieldsIndex?.has(t);i||r.Z.getLogger("esri.layers.support.fieldProperties").error("field-attributes-layer:invalid-field",`Invalid field ${t} found in outFields`,{layer:this,outFields:e})}return(0,a.Q0)(this.fieldsIndex,e)}}}}},86719:(e,t,i)=>{i.d(t,{v:()=>n});const n=new(i(35454).X)({esriFieldTypeSmallInteger:"small-integer",esriFieldTypeInteger:"integer",esriFieldTypeSingle:"single",esriFieldTypeDouble:"double",esriFieldTypeLong:"long",esriFieldTypeString:"string",esriFieldTypeDate:"date",esriFieldTypeOID:"oid",esriFieldTypeGeometry:"geometry",esriFieldTypeBlob:"blob",esriFieldTypeRaster:"raster",esriFieldTypeGUID:"guid",esriFieldTypeGlobalID:"global-id",esriFieldTypeXML:"xml",esriFieldTypeBigInteger:"big-integer",esriFieldTypeDateOnly:"date-only",esriFieldTypeTimeOnly:"time-only",esriFieldTypeTimestampOffset:"timestamp-offset"})},75935:(e,t,i)=>{i.r(t),i.d(t,{default:()=>h});var n,r=i(43697),o=(i(66577),i(96674)),s=i(22974),a=i(5600),l=i(75215),u=i(52011),d=i(30556),c=i(10158),p=i(82971);let y=n=class extends o.wq{constructor(e){super(e),this.cacheHint=void 0,this.dynamicDataSource=void 0,this.gdbVersion=null,this.geometryPrecision=void 0,this.historicMoment=null,this.maxAllowableOffset=void 0,this.objectIds=null,this.orderByFields=null,this.outFields=null,this.outSpatialReference=null,this.relationshipId=void 0,this.start=void 0,this.num=void 0,this.returnGeometry=!1,this.returnM=void 0,this.returnZ=void 0,this.where=null}_writeHistoricMoment(e,t){t.historicMoment=e&&e.getTime()}writeStart(e,t){t.resultOffset=this.start,t.resultRecordCount=this.num||10,this.start>0&&null==this.where&&(t.definitionExpression="1=1")}clone(){return new n((0,s.d9)({cacheHint:this.cacheHint,dynamicDataSource:this.dynamicDataSource,gdbVersion:this.gdbVersion,geometryPrecision:this.geometryPrecision,historicMoment:this.historicMoment&&new Date(this.historicMoment.getTime()),maxAllowableOffset:this.maxAllowableOffset,objectIds:this.objectIds,orderByFields:this.orderByFields,outFields:this.outFields,outSpatialReference:this.outSpatialReference,relationshipId:this.relationshipId,start:this.start,num:this.num,returnGeometry:this.returnGeometry,where:this.where,returnZ:this.returnZ,returnM:this.returnM}))}};(0,r._)([(0,a.Cb)({type:Boolean,json:{write:!0}})],y.prototype,"cacheHint",void 0),(0,r._)([(0,a.Cb)({type:c.n,json:{write:!0}})],y.prototype,"dynamicDataSource",void 0),(0,r._)([(0,a.Cb)({type:String,json:{write:!0}})],y.prototype,"gdbVersion",void 0),(0,r._)([(0,a.Cb)({type:Number,json:{write:!0}})],y.prototype,"geometryPrecision",void 0),(0,r._)([(0,a.Cb)({type:Date})],y.prototype,"historicMoment",void 0),(0,r._)([(0,d.c)("historicMoment")],y.prototype,"_writeHistoricMoment",null),(0,r._)([(0,a.Cb)({type:Number,json:{write:!0}})],y.prototype,"maxAllowableOffset",void 0),(0,r._)([(0,a.Cb)({type:[Number],json:{write:!0}})],y.prototype,"objectIds",void 0),(0,r._)([(0,a.Cb)({type:[String],json:{write:!0}})],y.prototype,"orderByFields",void 0),(0,r._)([(0,a.Cb)({type:[String],json:{write:!0}})],y.prototype,"outFields",void 0),(0,r._)([(0,a.Cb)({type:p.Z,json:{read:{source:"outSR"},write:{target:"outSR"}}})],y.prototype,"outSpatialReference",void 0),(0,r._)([(0,a.Cb)({json:{write:!0}})],y.prototype,"relationshipId",void 0),(0,r._)([(0,a.Cb)({type:Number,json:{read:{source:"resultOffset"}}})],y.prototype,"start",void 0),(0,r._)([(0,d.c)("start"),(0,d.c)("num")],y.prototype,"writeStart",null),(0,r._)([(0,a.Cb)({type:Number,json:{read:{source:"resultRecordCount"}}})],y.prototype,"num",void 0),(0,r._)([(0,a.Cb)({json:{write:!0}})],y.prototype,"returnGeometry",void 0),(0,r._)([(0,a.Cb)({type:Boolean,json:{write:{overridePolicy:e=>({enabled:e})}}})],y.prototype,"returnM",void 0),(0,r._)([(0,a.Cb)({type:Boolean,json:{write:{overridePolicy:e=>({enabled:e})}}})],y.prototype,"returnZ",void 0),(0,r._)([(0,a.Cb)({type:String,json:{read:{source:"definitionExpression"},write:{target:"definitionExpression"}}})],y.prototype,"where",void 0),y=n=(0,r._)([(0,u.j)("esri.rest.support.RelationshipQuery")],y),y.from=(0,l.se)(y);const h=y}}]);
package/core/date.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.28/esri/copyright.txt for details.
4
4
  */
5
- function e(e){return null!=u(e)||null!=n(e)}function t(e){return u(e)??n(e)}function n(e){const t=new Date(e);return r(t,e)?Number.isNaN(t.getTime())?null:t.getTime()-6e4*t.getTimezoneOffset():null}function u(e){const t=s.exec(e);if(!t?.groups)return null;const n=t.groups,u=+n.year,r=+n.month-1,o=+n.day,i=+(n.hours??"0"),f=+(n.minutes??"0"),l=+(n.seconds??"0");if(i>23)return null;if(f>59)return null;if(l>59)return null;const m=n.ms??"0",a=m?+m.padEnd(3,"0").substring(0,3):0;let c;if(n.isUTC||!n.offsetSign)c=Date.UTC(u,r,o,i,f,l,a);else{const e=+n.offsetHours,t=+n.offsetMinutes;c=6e4*("+"===n.offsetSign?-1:1)*(60*e+t)+Date.UTC(u,r,o,i,f,l,a)}return Number.isNaN(c)?null:c}const s=/^(?:(?<year>-?\d{4,})-(?<month>\d{2})-(?<day>\d{2}))(?:T(?<hours>\d{2}):(?<minutes>\d{2}):(?<seconds>\d{2})(?:\.(?<ms>\d+))?)?(?:(?<isUTC>Z)|(?:(?<offsetSign>\+|-)(?<offsetHours>\d{2}):(?<offsetMinutes>\d{2})))?$/;function r(e,t){if(Number.isNaN(e.getTime()))return!1;let n=!0;if(i&&/\d+\W*$/.test(t)){const e=t.match(/[a-zA-Z]{2,}/);if(e){let t=!1,u=0;for(;!t&&u<=e.length;)t=!o.test(e[u]),u++;n=!t}}return n}const o=/^((jan(uary)?)|(feb(ruary)?)|(mar(ch)?)|(apr(il)?)|(may)|(jun(e)?)|(jul(y)?)|(aug(ust)?)|(sep(tember)?)|(oct(ober)?)|(nov(ember)?)|(dec(ember)?)|(am)|(pm)|(gmt)|(utc))$/i,i=!Number.isNaN(new Date("technology 10").getTime());export{e as isDateString,t as parseDate};
5
+ function e(e){return null!=r(e)||null!=u(e)}function t(e){return s.test(e)}function n(e){return r(e)??u(e)}function u(e){const t=new Date(e);return o(t,e)?Number.isNaN(t.getTime())?null:t.getTime()-6e4*t.getTimezoneOffset():null}function r(e){const t=s.exec(e);if(!t?.groups)return null;const n=t.groups,u=+n.year,r=+n.month-1,o=+n.day,i=+(n.hours??"0"),f=+(n.minutes??"0"),l=+(n.seconds??"0");if(i>23)return null;if(f>59)return null;if(l>59)return null;const m=n.ms??"0",a=m?+m.padEnd(3,"0").substring(0,3):0;let c;if(n.isUTC||!n.offsetSign)c=Date.UTC(u,r,o,i,f,l,a);else{const e=+n.offsetHours,t=+n.offsetMinutes;c=6e4*("+"===n.offsetSign?-1:1)*(60*e+t)+Date.UTC(u,r,o,i,f,l,a)}return Number.isNaN(c)?null:c}const s=/^(?:(?<year>-?\d{4,})-(?<month>\d{2})-(?<day>\d{2}))(?:T(?<hours>\d{2}):(?<minutes>\d{2}):(?<seconds>\d{2})(?:\.(?<ms>\d+))?)?(?:(?<isUTC>Z)|(?:(?<offsetSign>\+|-)(?<offsetHours>\d{2}):(?<offsetMinutes>\d{2})))?$/;function o(e,t){if(Number.isNaN(e.getTime()))return!1;let n=!0;if(f&&/\d+\W*$/.test(t)){const e=t.match(/[a-zA-Z]{2,}/);if(e){let t=!1,u=0;for(;!t&&u<=e.length;)t=!i.test(e[u]),u++;n=!t}}return n}const i=/^((jan(uary)?)|(feb(ruary)?)|(mar(ch)?)|(apr(il)?)|(may)|(jun(e)?)|(jul(y)?)|(aug(ust)?)|(sep(tember)?)|(oct(ober)?)|(nov(ember)?)|(dec(ember)?)|(am)|(pm)|(gmt)|(utc))$/i,f=!Number.isNaN(new Date("technology 10").getTime());export{e as isDateString,t as isISO8601Date,n as parseDate};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{ArcadeDate as e}from"../../arcade/ArcadeDate.js";import{SqlError as t,SqlErrorCodes as a}from"../../arcade/featureset/support/errorsupport.js";import has from"../has.js";import{isAggregate as r,aggregateFunction as s}from"./AggregateFunctions.js";import{DateOnly as i}from"./DateOnly.js";import{sqlCalculateFunction as n}from"./sqlArithmeticUtils.js";import{sqlCompare as o}from"./sqlCompareUtils.js";import{isDate as l,isDateTime as u,isTimestampOffset as c,isTimeOnly as h,isDateOnly as p,convertToExecutingTimeZone as m,parseTime as d,parseTimestamp as f,parseDate as v}from"./sqlDateParsingUtils.js";import{SqlInterval as N}from"./SqlInterval.js";import{SqlTimeStampOffset as g}from"./SqlTimestampOffset.js";import{isStandardized as S,evaluateFunction as T}from"./StandardizedFunctions.js";import{TimeOnly as y}from"./TimeOnly.js";import{WhereGrammar as _}from"./WhereGrammar.js";import{DateTime as w}from"luxon";const J=new Set(["current_timestamp","current_date","current_time"]);class A{static makeBool(e){return O(e)}static featureValue(e,t,a,r){return L(e,t,a,r)}static equalsNull(e){return null===e}static applyLike(e,t,a){return j(e,t,a)}static ensureArray(e){return x(e)}static applyIn(e,t){return k(e,t)}static currentDate(e){return i.fromNow(e)}static makeSqlInterval(e,t,a){return N.createFromValueAndQualifer(e,t,a)}static convertInterval(e){return e instanceof N?e.valueInMilliseconds():e}static currentTimestamp(e){return m(new Date,e)}static compare(e,t,a,r){return o(t,a,e)}static calculate(e,t,a,r){return n(e,t,a,r)}static evaluateTime(e){return d(e)}static evaluateTimestamp(e,t,a){return f(e,t,a)}static evaluateDate(e,t){return v(e,t)}static evaluateFunction(e,t,a){return T(e,t,a)}static lookup(e,t){const a=t[e];return void 0===a?null:a}static between(e,t,a){return null==e||null==t[0]||null==t[1]?null:o(e,t[0],">=")&&o(e,t[1],"<=")}static notbetween(e,t,a){return null==e||null==t[0]||null==t[1]?null:o(e,t[0],"<")||o(e,t[1],">")}static ternaryNot(e){return F(e)}static ternaryAnd(e,t){return b(e,t)}static ternaryOr(e,t){return D(e,t)}}class I{constructor(e,t,a="UTC"){this.fieldsIndex=t,this.timeZone=a,this.parameters={},this._hasDateFunctions=void 0,this.parseTree=_.parse(e);const{isStandardized:r,isAggregate:s,referencedFieldNames:i}=this._extractExpressionInfo(t);this._referencedFieldNames=i,this.isStandardized=r,this.isAggregate=s}static convertValueToStorageFormat(e,t=null){if(null===t)return l(e)?e.getTime():u(e)?e.toMillis():c(e)?e.toStorageFormat():h(e)?e.toStorageString():p(e)?e.toStorageFormat():e;switch(t){case"date":return l(e)?e.getTime():u(e)?e.toMillis():c(e)?e.toMilliseconds():p(e)?e.toNumber():e;case"date-only":return l(e)?i.fromDateJS(e).toString():c(e)?i.fromSqlTimeStampOffset(e).toString():u(e)?i.fromDateTime(e).toString():e;case"time-only":return l(e)?y.fromDateJS(e).toStorageString():u(e)?y.fromDateTime(e).toStorageString():c(e)?y.fromSqlTimeStampOffset(e).toStorageString():h(e)?e.toStorageString():e;case"timestamp-offset":if(l(e))return g.fromJSDate(e).toStorageFormat();if(u(e))return g.fromDateTime(e).toStorageFormat();if(c(e))return e.toStorageFormat()}return e}static create(e,t,a="UTC"){return new I(e,t,a)}get fieldNames(){return this._referencedFieldNames}testSet(e,t=C){return!!this._evaluateNode(this.parseTree,null,t,e)}calculateValue(e,t=C){const a=this._evaluateNode(this.parseTree,e,t,null);return a instanceof N?a.valueInMilliseconds()/864e5:a}calculateValueCompiled(e,t=C){return null!=this.parseTree._compiledVersion?this.parseTree._compiledVersion(e,this.parameters,t,this.fieldsIndex,this.timeZone):has("esri-csp-restrictions")?this.calculateValue(e,t):(this._compileMe(),this.parseTree._compiledVersion(e,this.parameters,t,this.fieldsIndex,this.timeZone))}testFeature(e,t=C){return!!this._evaluateNode(this.parseTree,e,t,null)}testFeatureCompiled(e,t=C){return null!=this.parseTree._compiledVersion?!!this.parseTree._compiledVersion(e,this.parameters,t,this.fieldsIndex,this.timeZone):has("esri-csp-restrictions")?this.testFeature(e,t):(this._compileMe(),!!this.parseTree._compiledVersion(e,this.parameters,t,this.fieldsIndex,this.timeZone))}get hasDateFunctions(){return null!=this._hasDateFunctions||(this._hasDateFunctions=!1,this._visitAll(this.parseTree,(e=>{"current-time"===e.type?this._hasDateFunctions=!0:"function"===e.type&&(this._hasDateFunctions=this._hasDateFunctions||J.has(e.name.toLowerCase()))}))),this._hasDateFunctions}getFunctions(){const e=new Set;return this._visitAll(this.parseTree,(t=>{"function"===t.type&&e.add(t.name.toLowerCase())})),Array.from(e)}getExpressions(){const e=new Map;return this._visitAll(this.parseTree,(t=>{if("function"===t.type){const a=t.name.toLowerCase(),r=t.args.value[0];if("column-reference"===r.type){const t=r.column,s=`${a}-${t}`;e.has(s)||e.set(s,{aggregateType:a,field:t})}}})),[...e.values()]}getVariables(){const e=new Set;return this._visitAll(this.parseTree,(t=>{"parameter"===t.type&&e.add(t.value.toLowerCase())})),Array.from(e)}_compileMe(){const e="return this.convertInterval("+this.evaluateNodeToJavaScript(this.parseTree)+")";this.parseTree._compiledVersion=new Function("feature","lookups","attributeAdapter","fieldsIndex","timeZone",e).bind(A)}_extractExpressionInfo(e){const t=[],a=new Set;let s=!0,i=!1;return this._visitAll(this.parseTree,(n=>{switch(n.type){case"column-reference":{const r=e?.get(n.column);let s,i;r?s=i=r.name??"":(i=n.column,s=i.toLowerCase()),a.has(s)||(a.add(s),t.push(i)),n.column=i;break}case"function":{const{name:e,args:t}=n,a=t.value.length;s&&(s=S(e,a)),!1===i&&(i=r(e,a));break}}})),{referencedFieldNames:Array.from(t),isStandardized:s,isAggregate:i}}_visitAll(e,t){if(null!=e)switch(t(e),e.type){case"when-clause":this._visitAll(e.operand,t),this._visitAll(e.value,t);break;case"case-expression":for(const a of e.clauses)this._visitAll(a,t);"simple"===e.format&&this._visitAll(e.operand,t),null!==e.else&&this._visitAll(e.else,t);break;case"expression-list":for(const a of e.value)this._visitAll(a,t);break;case"unary-expression":this._visitAll(e.expr,t);break;case"binary-expression":this._visitAll(e.left,t),this._visitAll(e.right,t);break;case"function":this._visitAll(e.args,t)}}evaluateNodeToJavaScript(e){switch(e.type){case"interval":return"this.makeSqlInterval("+this.evaluateNodeToJavaScript(e.value)+", "+JSON.stringify(e.qualifier)+","+JSON.stringify(e.op)+")";case"case-expression":{let t="";if("simple"===e.format){const a=this.evaluateNodeToJavaScript(e.operand);t="( ";for(let r=0;r<e.clauses.length;r++)t+=" (this.compare('=',"+a+","+this.evaluateNodeToJavaScript(e.clauses[r].operand)+") ? ("+this.evaluateNodeToJavaScript(e.clauses[r].value)+") : ";null!==e.else?t+=this.evaluateNodeToJavaScript(e.else):t+="null",t+=" )"}else{t="( ";for(let a=0;a<e.clauses.length;a++)t+=" this.makeBool("+this.evaluateNodeToJavaScript(e.clauses[a].operand)+")===true ? ("+this.evaluateNodeToJavaScript(e.clauses[a].value)+") : ";null!==e.else?t+=this.evaluateNodeToJavaScript(e.else):t+="null",t+=" )"}return t}case"parameter":return"this.lookup("+JSON.stringify(e.value.toLowerCase())+",lookups)";case"expression-list":{let t="[";for(const a of e.value)"["!==t&&(t+=","),t+=this.evaluateNodeToJavaScript(a);return t+="]",t}case"unary-expression":return"this.ternaryNot("+this.evaluateNodeToJavaScript(e.expr)+")";case"binary-expression":switch(e.operator){case"AND":return"this.ternaryAnd("+this.evaluateNodeToJavaScript(e.left)+","+this.evaluateNodeToJavaScript(e.right)+" )";case"OR":return"this.ternaryOr("+this.evaluateNodeToJavaScript(e.left)+","+this.evaluateNodeToJavaScript(e.right)+" )";case"IS":if("null"!==e.right.type)throw new t(a.UnsupportedIsRhs);return"this.equalsNull("+this.evaluateNodeToJavaScript(e.left)+")";case"ISNOT":if("null"!==e.right.type)throw new t(a.UnsupportedIsRhs);return"(!(this.equalsNull("+this.evaluateNodeToJavaScript(e.left)+")))";case"IN":return"this.applyIn("+this.evaluateNodeToJavaScript(e.left)+",this.ensureArray("+this.evaluateNodeToJavaScript(e.right)+"))";case"NOT IN":return"this.ternaryNot(this.applyIn("+this.evaluateNodeToJavaScript(e.left)+",this.ensureArray("+this.evaluateNodeToJavaScript(e.right)+")))";case"BETWEEN":return"this.between("+this.evaluateNodeToJavaScript(e.left)+","+this.evaluateNodeToJavaScript(e.right)+", timeZone)";case"NOTBETWEEN":return"this.notbetween("+this.evaluateNodeToJavaScript(e.left)+","+this.evaluateNodeToJavaScript(e.right)+", timeZone)";case"LIKE":return"this.applyLike("+this.evaluateNodeToJavaScript(e.left)+","+this.evaluateNodeToJavaScript(e.right)+","+JSON.stringify(e.escape)+")";case"NOT LIKE":return"this.ternaryNot(this.applyLike("+this.evaluateNodeToJavaScript(e.left)+","+this.evaluateNodeToJavaScript(e.right)+","+JSON.stringify(e.escape)+"))";case"<>":case"<":case">":case">=":case"<=":case"=":return"this.compare("+JSON.stringify(e.operator)+","+this.evaluateNodeToJavaScript(e.left)+","+this.evaluateNodeToJavaScript(e.right)+", timeZone)";case"*":case"-":case"+":case"/":case"||":return"this.calculate("+JSON.stringify(e.operator)+","+this.evaluateNodeToJavaScript(e.left)+","+this.evaluateNodeToJavaScript(e.right)+", timeZone)"}throw new t(a.UnsupportedOperator,{operator:e.operator});case"null":case"boolean":case"string":case"number":return JSON.stringify(e.value);case"time":return"this.evaluateTime(JSON.stringify(node.value))";case"date":return"this.evaluateDate(JSON.stringify(node.value), 'unknown')";case"timestamp":return"this.evaluateTimestamp(JSON.stringify(node.value), 'unknown')";case"current-time":return"date"===e.mode?"this.currentDate(timeZone)":"this.currentTimestamp(timeZone)";case"column-reference":return"this.featureValue(feature,"+JSON.stringify(e.column)+",fieldsIndex,attributeAdapter)";case"function":return"this.evaluateFunction("+JSON.stringify(e.name)+","+this.evaluateNodeToJavaScript(e.args)+", timeZone)"}throw new t(a.UnsupportedSyntax,{node:e.type})}_evaluateNode(u,c,h,p){let g;switch(u.type){case"interval":{const e=this._evaluateNode(u.value,c,h,p);return N.createFromValueAndQualifer(e,u.qualifier,u.op)}case"case-expression":if("simple"===u.format){const e=this._evaluateNode(u.operand,c,h,p);for(let t=0;t<u.clauses.length;t++)if(o(e,this._evaluateNode(u.clauses[t].operand,c,h,p),"=",this.timeZone))return this._evaluateNode(u.clauses[t].value,c,h,p);if(null!==u.else)return this._evaluateNode(u.else,c,h,p)}else{for(let e=0;e<u.clauses.length;e++)if(O(this._evaluateNode(u.clauses[e].operand,c,h,p)))return this._evaluateNode(u.clauses[e].value,c,h,p);if(null!==u.else)return this._evaluateNode(u.else,c,h,p)}return null;case"parameter":return g=this.parameters[u.value.toLowerCase()],l(g)?w.fromJSDate(g):g instanceof e?g.toDateTime():g;case"expression-list":{const e=[];for(const t of u.value)e.push(this._evaluateNode(t,c,h,p));return e}case"unary-expression":return F(this._evaluateNode(u.expr,c,h,p));case"binary-expression":switch(u.operator){case"AND":return b(this._evaluateNode(u.left,c,h,p),this._evaluateNode(u.right,c,h,p));case"OR":return D(this._evaluateNode(u.left,c,h,p),this._evaluateNode(u.right,c,h,p));case"IS":if("null"!==u.right.type)throw new t(a.UnsupportedIsRhs);return null===this._evaluateNode(u.left,c,h,p);case"ISNOT":if("null"!==u.right.type)throw new t(a.UnsupportedIsRhs);return null!==this._evaluateNode(u.left,c,h,p);case"IN":{const e=x(this._evaluateNode(u.right,c,h,p));return k(this._evaluateNode(u.left,c,h,p),e)}case"NOT IN":{const e=x(this._evaluateNode(u.right,c,h,p));return F(k(this._evaluateNode(u.left,c,h,p),e))}case"BETWEEN":{const e=this._evaluateNode(u.left,c,h,p),t=this._evaluateNode(u.right,c,h,p);return null==e||null==t[0]||null==t[1]?null:o(e,t[0],">=",this.timeZone)&&o(e,t[1],"<=",this.timeZone)}case"NOTBETWEEN":{const e=this._evaluateNode(u.left,c,h,p),t=this._evaluateNode(u.right,c,h,p);return null==e||null==t[0]||null==t[1]?null:o(e,t[0],"<",this.timeZone)||o(e,t[1],">",this.timeZone)}case"LIKE":return j(this._evaluateNode(u.left,c,h,p),this._evaluateNode(u.right,c,h,p),u.escape);case"NOT LIKE":return F(j(this._evaluateNode(u.left,c,h,p),this._evaluateNode(u.right,c,h,p),u.escape));case"<>":case"<":case">":case">=":case"<=":case"=":return o(this._evaluateNode(u.left,c,h,p),this._evaluateNode(u.right,c,h,p),u.operator,this.timeZone);case"-":case"+":case"*":case"/":case"||":return n(u.operator,this._evaluateNode(u.left,c,h,p),this._evaluateNode(u.right,c,h,p),this.timeZone)}case"null":case"boolean":case"string":case"number":return u.value;case"date":return v(u.value,"unknown");case"timestamp":return f(u.value,"unknown");case"time":return d(u.value);case"current-time":return"date"===u.mode?i.fromNow(this.timeZone):m(new Date,this.timeZone);case"column-reference":return L(c,u.column,this.fieldsIndex,h);case"data-type":return u.value;case"function":{if(this.isAggregate&&r(u.name,u.args.value.length)){const e=[];for(const t of u.args?.value||[]){const a=[];for(const e of p||[])a.push(this._evaluateNode(t,e,h,null));e.push(a)}return s(u.name,e)}const e=this._evaluateNode(u.args,c,h,p);return T(u.name,e,this.timeZone)}}throw new t(a.UnsupportedSyntax,{node:u.type})}}function O(e){return!0===e}function x(e){return Array.isArray(e)?e:[e]}function F(e){return null!==e?!0!==e:null}function b(e,t){return null!=e&&null!=t?!0===e&&!0===t:!1!==e&&!1!==t&&null}function D(e,t){return null!=e&&null!=t?!0===e||!0===t:!0===e||!0===t||null}function k(e,t){if(null==e)return null;let a=!1;for(const r of t)if(null==r)a=null;else if(e===r){a=!0;break}return a}const E="-[]/{}()*+?.\\^$|";var Z;function V(e,t){const a=t;let r="",s=Z.Normal;for(let i=0;i<e.length;i++){const t=e.charAt(i);switch(s){case Z.Normal:t===a?s=Z.Escaped:E.includes(t)?r+="\\"+t:r+="%"===t?".*":"_"===t?".":t;break;case Z.Escaped:E.includes(t)?r+="\\"+t:r+=t,s=Z.Normal}}return new RegExp("^"+r+"$","m")}function j(e,t,a){if(null==e)return null;return V(t,a).test(e)}function q(e){return e&&"object"==typeof e.attributes}function L(e,t,a,r){const s=r.getAttribute(e,t),n=a?.get(t);return null==s||"esriFieldTypeDate"!==n?.type&&"date"!==n?.type?null==s||"esriFieldTypeDateOnly"!==n?.type&&"date-only"!==n?.type?null==s||"esriFieldTypeTimeOnly"!==n?.type&&"time-only"!==n?.type?null==s||"esriFieldTypeTimestampOffset"!==n?.type&&"timestamp-offset"!==n?.type?s:new g(s):y.fromReader(s):i.fromReader(s):m(new Date(s),a.getTimeZone(n.name)??"UTC")}!function(e){e[e.Normal=0]="Normal",e[e.Escaped=1]="Escaped"}(Z||(Z={}));const C={getAttribute:(e,t)=>(q(e)?e.attributes:e)[t]};export{I as WhereClause,C as defaultAttributeAdapter};
5
+ import{ArcadeDate as e}from"../../arcade/ArcadeDate.js";import{SqlError as t,SqlErrorCodes as a}from"../../arcade/featureset/support/errorsupport.js";import has from"../has.js";import{isAggregate as r,aggregateFunction as s}from"./AggregateFunctions.js";import{DateOnly as i}from"./DateOnly.js";import{sqlCalculateFunction as n}from"./sqlArithmeticUtils.js";import{sqlCompare as l}from"./sqlCompareUtils.js";import{isDate as o,isDateTime as u,isTimestampOffset as c,isTimeOnly as h,isDateOnly as p,convertToExecutingTimeZone as m,parseTime as d,parseTimestamp as f,parseDate as v}from"./sqlDateParsingUtils.js";import{SqlInterval as N}from"./SqlInterval.js";import{SqlTimeStampOffset as g}from"./SqlTimestampOffset.js";import{isStandardized as S,evaluateFunction as T}from"./StandardizedFunctions.js";import{TimeOnly as y}from"./TimeOnly.js";import{WhereGrammar as _}from"./WhereGrammar.js";import{DateTime as w}from"luxon";const J=new Set(["current_timestamp","current_date","current_time"]);class A{static makeBool(e){return O(e)}static featureValue(e,t,a,r){return L(e,t,a,r)}static equalsNull(e){return null===e}static applyLike(e,t,a){return j(e,t,a)}static ensureArray(e){return x(e)}static applyIn(e,t){return k(e,t)}static currentDate(e){return i.fromNow(e)}static makeSqlInterval(e,t,a){return N.createFromValueAndQualifer(e,t,a)}static convertInterval(e){return e instanceof N?e.valueInMilliseconds():e}static currentTimestamp(e){return m(new Date,e)}static compare(e,t,a,r){return l(t,a,e)}static calculate(e,t,a,r){return n(e,t,a,r)}static evaluateTime(e){return d(e)}static evaluateTimestamp(e,t,a){return f(e,t,a)}static evaluateDate(e,t){return v(e,t)}static evaluateFunction(e,t,a){return T(e,t,a)}static lookup(e,t){const a=t[e];return void 0===a?null:a}static between(e,t,a){return null==e||null==t[0]||null==t[1]?null:l(e,t[0],">=")&&l(e,t[1],"<=")}static notbetween(e,t,a){return null==e||null==t[0]||null==t[1]?null:l(e,t[0],"<")||l(e,t[1],">")}static ternaryNot(e){return F(e)}static ternaryAnd(e,t){return b(e,t)}static ternaryOr(e,t){return D(e,t)}}class I{constructor(e,t,a="UTC"){this.fieldsIndex=t,this.timeZone=a,this.parameters={},this._hasDateFunctions=void 0,this.parseTree=_.parse(e);const{isStandardized:r,isAggregate:s,referencedFieldNames:i}=this._extractExpressionInfo(t);this._referencedFieldNames=i,this.isStandardized=r,this.isAggregate=s}static convertValueToStorageFormat(e,t=null){if(null===t)return o(e)?e.getTime():u(e)?e.toMillis():c(e)?e.toStorageFormat():h(e)?e.toStorageString():p(e)?e.toStorageFormat():e;switch(t){case"date":return o(e)?e.getTime():u(e)?e.toMillis():c(e)?e.toMilliseconds():p(e)?e.toNumber():e;case"date-only":return o(e)?i.fromDateJS(e).toString():c(e)?i.fromSqlTimeStampOffset(e).toString():u(e)?i.fromDateTime(e).toString():e;case"time-only":return o(e)?y.fromDateJS(e).toStorageString():u(e)?y.fromDateTime(e).toStorageString():c(e)?y.fromSqlTimeStampOffset(e).toStorageString():h(e)?e.toStorageString():e;case"timestamp-offset":if(o(e))return g.fromJSDate(e).toStorageFormat();if(u(e))return g.fromDateTime(e).toStorageFormat();if(c(e))return e.toStorageFormat()}return e}static create(e,t,a="UTC"){return new I(e,t,a)}get fieldNames(){return this._referencedFieldNames}testSet(e,t=C){return!!this._evaluateNode(this.parseTree,null,t,e)}calculateValue(e,t=C){const a=this._evaluateNode(this.parseTree,e,t,null);return a instanceof N?a.valueInMilliseconds()/864e5:a}calculateValueCompiled(e,t=C){return null!=this.parseTree._compiledVersion?this.parseTree._compiledVersion(e,this.parameters,t,this.fieldsIndex,this.timeZone):has("esri-csp-restrictions")?this.calculateValue(e,t):(this._compileMe(),this.parseTree._compiledVersion(e,this.parameters,t,this.fieldsIndex,this.timeZone))}testFeature(e,t=C){return!!this._evaluateNode(this.parseTree,e,t,null)}testFeatureCompiled(e,t=C){return null!=this.parseTree._compiledVersion?!!this.parseTree._compiledVersion(e,this.parameters,t,this.fieldsIndex,this.timeZone):has("esri-csp-restrictions")?this.testFeature(e,t):(this._compileMe(),!!this.parseTree._compiledVersion(e,this.parameters,t,this.fieldsIndex,this.timeZone))}get hasDateFunctions(){return null!=this._hasDateFunctions||(this._hasDateFunctions=!1,this._visitAll(this.parseTree,(e=>{"current-time"===e.type?this._hasDateFunctions=!0:"function"===e.type&&(this._hasDateFunctions=this._hasDateFunctions||J.has(e.name.toLowerCase()))}))),this._hasDateFunctions}getFunctions(){const e=new Set;return this._visitAll(this.parseTree,(t=>{"function"===t.type&&e.add(t.name.toLowerCase())})),Array.from(e)}getExpressions(){const e=new Map;return this._visitAll(this.parseTree,(t=>{if("function"===t.type){const a=t.name.toLowerCase(),r=t.args.value[0];if("column-reference"===r.type){const t=r.column,s=`${a}-${t}`;e.has(s)||e.set(s,{aggregateType:a,field:t})}}})),[...e.values()]}getVariables(){const e=new Set;return this._visitAll(this.parseTree,(t=>{"parameter"===t.type&&e.add(t.value.toLowerCase())})),Array.from(e)}_compileMe(){const e="return this.convertInterval("+this.evaluateNodeToJavaScript(this.parseTree)+")";this.parseTree._compiledVersion=new Function("feature","lookups","attributeAdapter","fieldsIndex","timeZone",e).bind(A)}_extractExpressionInfo(e){const t=[],a=new Set;let s=!0,i=!1;return this._visitAll(this.parseTree,(n=>{switch(n.type){case"column-reference":{const r=e?.get(n.column);let s,i;r?s=i=r.name??"":(i=n.column,s=i.toLowerCase()),a.has(s)||(a.add(s),t.push(i)),n.column=i;break}case"function":{const{name:e,args:t}=n,a=t.value.length;s&&(s=S(e,a)),!1===i&&(i=r(e,a));break}}})),{referencedFieldNames:Array.from(t),isStandardized:s,isAggregate:i}}_visitAll(e,t){if(null!=e)switch(t(e),e.type){case"when-clause":this._visitAll(e.operand,t),this._visitAll(e.value,t);break;case"case-expression":for(const a of e.clauses)this._visitAll(a,t);"simple"===e.format&&this._visitAll(e.operand,t),null!==e.else&&this._visitAll(e.else,t);break;case"expression-list":for(const a of e.value)this._visitAll(a,t);break;case"unary-expression":this._visitAll(e.expr,t);break;case"binary-expression":this._visitAll(e.left,t),this._visitAll(e.right,t);break;case"function":this._visitAll(e.args,t)}}evaluateNodeToJavaScript(e){switch(e.type){case"interval":return"this.makeSqlInterval("+this.evaluateNodeToJavaScript(e.value)+", "+JSON.stringify(e.qualifier)+","+JSON.stringify(e.op)+")";case"case-expression":{let t="";if("simple"===e.format){const a=this.evaluateNodeToJavaScript(e.operand);t="( ";for(let r=0;r<e.clauses.length;r++)t+=" (this.compare('=',"+a+","+this.evaluateNodeToJavaScript(e.clauses[r].operand)+") ? ("+this.evaluateNodeToJavaScript(e.clauses[r].value)+") : ";null!==e.else?t+=this.evaluateNodeToJavaScript(e.else):t+="null",t+=" )"}else{t="( ";for(let a=0;a<e.clauses.length;a++)t+=" this.makeBool("+this.evaluateNodeToJavaScript(e.clauses[a].operand)+")===true ? ("+this.evaluateNodeToJavaScript(e.clauses[a].value)+") : ";null!==e.else?t+=this.evaluateNodeToJavaScript(e.else):t+="null",t+=" )"}return t}case"parameter":return"this.lookup("+JSON.stringify(e.value.toLowerCase())+",lookups)";case"expression-list":{let t="[";for(const a of e.value)"["!==t&&(t+=","),t+=this.evaluateNodeToJavaScript(a);return t+="]",t}case"unary-expression":return"this.ternaryNot("+this.evaluateNodeToJavaScript(e.expr)+")";case"binary-expression":switch(e.operator){case"AND":return"this.ternaryAnd("+this.evaluateNodeToJavaScript(e.left)+","+this.evaluateNodeToJavaScript(e.right)+" )";case"OR":return"this.ternaryOr("+this.evaluateNodeToJavaScript(e.left)+","+this.evaluateNodeToJavaScript(e.right)+" )";case"IS":if("null"!==e.right.type)throw new t(a.UnsupportedIsRhs);return"this.equalsNull("+this.evaluateNodeToJavaScript(e.left)+")";case"ISNOT":if("null"!==e.right.type)throw new t(a.UnsupportedIsRhs);return"(!(this.equalsNull("+this.evaluateNodeToJavaScript(e.left)+")))";case"IN":return"this.applyIn("+this.evaluateNodeToJavaScript(e.left)+",this.ensureArray("+this.evaluateNodeToJavaScript(e.right)+"))";case"NOT IN":return"this.ternaryNot(this.applyIn("+this.evaluateNodeToJavaScript(e.left)+",this.ensureArray("+this.evaluateNodeToJavaScript(e.right)+")))";case"BETWEEN":return"this.between("+this.evaluateNodeToJavaScript(e.left)+","+this.evaluateNodeToJavaScript(e.right)+", timeZone)";case"NOTBETWEEN":return"this.notbetween("+this.evaluateNodeToJavaScript(e.left)+","+this.evaluateNodeToJavaScript(e.right)+", timeZone)";case"LIKE":return"this.applyLike("+this.evaluateNodeToJavaScript(e.left)+","+this.evaluateNodeToJavaScript(e.right)+","+JSON.stringify(e.escape)+")";case"NOT LIKE":return"this.ternaryNot(this.applyLike("+this.evaluateNodeToJavaScript(e.left)+","+this.evaluateNodeToJavaScript(e.right)+","+JSON.stringify(e.escape)+"))";case"<>":case"<":case">":case">=":case"<=":case"=":return"this.compare("+JSON.stringify(e.operator)+","+this.evaluateNodeToJavaScript(e.left)+","+this.evaluateNodeToJavaScript(e.right)+", timeZone)";case"*":case"-":case"+":case"/":case"||":return"this.calculate("+JSON.stringify(e.operator)+","+this.evaluateNodeToJavaScript(e.left)+","+this.evaluateNodeToJavaScript(e.right)+", timeZone)"}throw new t(a.UnsupportedOperator,{operator:e.operator});case"null":case"boolean":case"string":case"number":return JSON.stringify(e.value);case"time":return"this.evaluateTime(JSON.stringify(node.value))";case"date":return"this.evaluateDate(JSON.stringify(node.value), 'unknown')";case"timestamp":return"this.evaluateTimestamp(JSON.stringify(node.value), 'unknown')";case"current-time":return"date"===e.mode?"this.currentDate(timeZone)":"this.currentTimestamp(timeZone)";case"column-reference":return"this.featureValue(feature,"+JSON.stringify(e.column)+",fieldsIndex,attributeAdapter)";case"function":return"this.evaluateFunction("+JSON.stringify(e.name)+","+this.evaluateNodeToJavaScript(e.args)+", timeZone)"}throw new t(a.UnsupportedSyntax,{node:e.type})}_evaluateNode(u,c,h,p){let g;switch(u.type){case"interval":{const e=this._evaluateNode(u.value,c,h,p);return N.createFromValueAndQualifer(e,u.qualifier,u.op)}case"case-expression":if("simple"===u.format){const e=this._evaluateNode(u.operand,c,h,p);for(let t=0;t<u.clauses.length;t++)if(l(e,this._evaluateNode(u.clauses[t].operand,c,h,p),"=",this.timeZone))return this._evaluateNode(u.clauses[t].value,c,h,p);if(null!==u.else)return this._evaluateNode(u.else,c,h,p)}else{for(let e=0;e<u.clauses.length;e++)if(O(this._evaluateNode(u.clauses[e].operand,c,h,p)))return this._evaluateNode(u.clauses[e].value,c,h,p);if(null!==u.else)return this._evaluateNode(u.else,c,h,p)}return null;case"parameter":return g=this.parameters[u.value.toLowerCase()],o(g)?w.fromJSDate(g):g instanceof e?g.toDateTime():g;case"expression-list":{const e=[];for(const t of u.value)e.push(this._evaluateNode(t,c,h,p));return e}case"unary-expression":return F(this._evaluateNode(u.expr,c,h,p));case"binary-expression":switch(u.operator){case"AND":return b(this._evaluateNode(u.left,c,h,p),this._evaluateNode(u.right,c,h,p));case"OR":return D(this._evaluateNode(u.left,c,h,p),this._evaluateNode(u.right,c,h,p));case"IS":if("null"!==u.right.type)throw new t(a.UnsupportedIsRhs);return null===this._evaluateNode(u.left,c,h,p);case"ISNOT":if("null"!==u.right.type)throw new t(a.UnsupportedIsRhs);return null!==this._evaluateNode(u.left,c,h,p);case"IN":{const e=x(this._evaluateNode(u.right,c,h,p));return k(this._evaluateNode(u.left,c,h,p),e)}case"NOT IN":{const e=x(this._evaluateNode(u.right,c,h,p));return F(k(this._evaluateNode(u.left,c,h,p),e))}case"BETWEEN":{const e=this._evaluateNode(u.left,c,h,p),t=this._evaluateNode(u.right,c,h,p);return null==e||null==t[0]||null==t[1]?null:l(e,t[0],">=",this.timeZone)&&l(e,t[1],"<=",this.timeZone)}case"NOTBETWEEN":{const e=this._evaluateNode(u.left,c,h,p),t=this._evaluateNode(u.right,c,h,p);return null==e||null==t[0]||null==t[1]?null:l(e,t[0],"<",this.timeZone)||l(e,t[1],">",this.timeZone)}case"LIKE":return j(this._evaluateNode(u.left,c,h,p),this._evaluateNode(u.right,c,h,p),u.escape);case"NOT LIKE":return F(j(this._evaluateNode(u.left,c,h,p),this._evaluateNode(u.right,c,h,p),u.escape));case"<>":case"<":case">":case">=":case"<=":case"=":return l(this._evaluateNode(u.left,c,h,p),this._evaluateNode(u.right,c,h,p),u.operator,this.timeZone);case"-":case"+":case"*":case"/":case"||":return n(u.operator,this._evaluateNode(u.left,c,h,p),this._evaluateNode(u.right,c,h,p),this.timeZone)}case"null":case"boolean":case"string":case"number":return u.value;case"date":return u.parsedValue??=v(u.value,"unknown"),u.parsedValue;case"timestamp":return u.parsedValue??=f(u.value,"unknown"),u.parsedValue;case"time":return d(u.value);case"current-time":return"date"===u.mode?i.fromNow(this.timeZone):m(new Date,this.timeZone);case"column-reference":return L(c,u.column,this.fieldsIndex,h);case"data-type":return u.value;case"function":{if(this.isAggregate&&r(u.name,u.args.value.length)){const e=[];for(const t of u.args?.value||[]){const a=[];for(const e of p||[])a.push(this._evaluateNode(t,e,h,null));e.push(a)}return s(u.name,e)}const e=this._evaluateNode(u.args,c,h,p);return T(u.name,e,this.timeZone)}}throw new t(a.UnsupportedSyntax,{node:u.type})}}function O(e){return!0===e}function x(e){return Array.isArray(e)?e:[e]}function F(e){return null!==e?!0!==e:null}function b(e,t){return null!=e&&null!=t?!0===e&&!0===t:!1!==e&&!1!==t&&null}function D(e,t){return null!=e&&null!=t?!0===e||!0===t:!0===e||!0===t||null}function k(e,t){if(null==e)return null;let a=!1;for(const r of t)if(null==r)a=null;else if(e===r){a=!0;break}return a}const E="-[]/{}()*+?.\\^$|";var Z;function V(e,t){const a=t;let r="",s=Z.Normal;for(let i=0;i<e.length;i++){const t=e.charAt(i);switch(s){case Z.Normal:t===a?s=Z.Escaped:E.includes(t)?r+="\\"+t:r+="%"===t?".*":"_"===t?".":t;break;case Z.Escaped:E.includes(t)?r+="\\"+t:r+=t,s=Z.Normal}}return new RegExp("^"+r+"$","m")}function j(e,t,a){if(null==e)return null;return V(t,a).test(e)}function q(e){return e&&"object"==typeof e.attributes}function L(e,t,a,r){const s=r.getAttribute(e,t),n=a?.get(t);return null==s||"esriFieldTypeDate"!==n?.type&&"date"!==n?.type?null==s||"esriFieldTypeDateOnly"!==n?.type&&"date-only"!==n?.type?null==s||"esriFieldTypeTimeOnly"!==n?.type&&"time-only"!==n?.type?null==s||"esriFieldTypeTimestampOffset"!==n?.type&&"timestamp-offset"!==n?.type?s:new g(s):y.fromReader(s):i.fromReader(s):m(new Date(s),a.getTimeZone(n.name)??"UTC")}!function(e){e[e.Normal=0]="Normal",e[e.Escaped=1]="Escaped"}(Z||(Z={}));const C={getAttribute:(e,t)=>(q(e)?e.attributes:e)[t]};export{I as WhereClause,C as defaultAttributeAdapter};
package/kernel.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.28/esri/copyright.txt for details.
4
4
  */
5
- import has from"./core/has.js";import{addQueryParameter as o}from"./core/urlUtils.js";import{buildDate as s,commitHash as e}from"./support/revision.js";Symbol.dispose??=Symbol("Symbol.dispose"),Symbol.asyncDispose??=Symbol("Symbol.asyncDispose");const r="4.28";let t,i=r;i="4.28.3";function n(o){t=o}function m(s){const e=t?.findCredential(s);return e?.token?o(s,"token",e.token):s}has("host-webworker");export{m as addTokenParameter,s as buildDate,i as fullVersion,t as id,e as revision,n as setId,r as version};
5
+ import has from"./core/has.js";import{addQueryParameter as o}from"./core/urlUtils.js";import{buildDate as s,commitHash as e}from"./support/revision.js";Symbol.dispose??=Symbol("Symbol.dispose"),Symbol.asyncDispose??=Symbol("Symbol.asyncDispose");const r="4.28";let t,i=r;i="4.28.5";function n(o){t=o}function m(s){const e=t?.findCredential(s);return e?.token?o(s,"token",e.token):s}has("host-webworker");export{m as addTokenParameter,s as buildDate,i as fullVersion,t as id,e as revision,n as setId,r as version};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{clone as e}from"../../../core/lang.js";import{polygonCentroid as t,extentCentroid as s}from"../../../geometry/support/centroid.js";import{getPolygonExtent as i,getGeometryExtent as a}from"../../../geometry/support/extentUtils.js";import{toQuantizationTransform as r}from"../../../geometry/support/quantizationUtils.js";import{isValid as n,equals as o}from"../../../geometry/support/spatialReferenceUtils.js";import l from"./AttributesBuilder.js";import{cleanFromGeometryEngine as u,getGeometry as c,transformCentroid as d}from"./geometryUtils.js";import{project as m}from"./projectionSupport.js";import{makeEdgeCandidate as h,makeVertexCandidate as g}from"./SnappingCandidate.js";import{isDateField as f,isDateOnlyField as p,isTimestampOffsetField as y,isStringField as x,isTimeOnlyField as I}from"../../support/fieldUtils.js";import{isNullCountSupported as T,calculateStringStatistics as V,calculateStatistics as F,processSummaryStatisticsResult as S,calculateUniqueValuesCount as _,createUVResult as v,calculateClassBreaks as b,resolveCBResult as R,calculateHistogram as A,getAttributeComparator as z,calculatePercentile as M}from"../../../statistics/utils.js";class q{constructor(e,t,s){this.items=e,this.query=t,this.geometryType=s.geometryType,this.hasM=s.hasM,this.hasZ=s.hasZ,this.fieldsIndex=s.fieldsIndex,this.objectIdField=s.objectIdField,this.spatialReference=s.spatialReference,this.featureAdapter=s.featureAdapter}get size(){return this.items.length}createQueryResponseForCount(){const e=new l(this.query,this.featureAdapter,this.fieldsIndex);if(!this.query.outStatistics)return e.countDistinctValues(this.items);const{groupByFieldsForStatistics:t,having:s,outStatistics:i}=this.query,a=t?.length;if(!!!a)return 1;const r=new Map,n=new Map,o=new Set;for(const l of i){const{statisticType:i}=l,a="exceedslimit"!==i?l.onStatisticField:void 0;if(!n.has(a)){const s=[];for(const i of t){const t=this._getAttributeValues(e,i,r);s.push(t)}n.set(a,this._calculateUniqueValues(s,e.returnDistinctValues))}const u=n.get(a);for(const t in u){const{data:i,items:a}=u[t],r=i.join(",");s&&!e.validateItems(a,s)||o.add(r)}}return o.size}async createQueryResponse(){let e;if(this.query.outStatistics){e=this.query.outStatistics.some((e=>"exceedslimit"===e.statisticType))?this._createExceedsLimitQueryResponse(this.query):await this._createStatisticsQueryResponse(this.query)}else e=this._createFeatureQueryResponse(this.query);if(this.query.returnQueryGeometry){const t=this.query.geometry;n(this.query.outSR)&&!o(t.spatialReference,this.query.outSR)?e.queryGeometry=u({spatialReference:this.query.outSR,...m(t,t.spatialReference,this.query.outSR)}):e.queryGeometry=u({spatialReference:this.query.outSR,...t})}return e}createSnappingResponse(e,t){const s=this.featureAdapter,i=C(this.hasZ,this.hasM),{point:a,mode:r}=e,n="number"==typeof e.distance?e.distance:e.distance.x,o="number"==typeof e.distance?e.distance:e.distance.y,l={candidates:[]},u="esriGeometryPolygon"===this.geometryType,c=this._getPointCreator(r,this.spatialReference,t),d=new D(null,0),m=new D(null,0),f={x:0,y:0,z:0};for(const p of this.items){const t=s.getGeometry(p);if(null==t)continue;const{coords:r,lengths:y}=t;if(d.coords=r,m.coords=r,e.returnEdge){let e=0;for(let t=0;t<y.length;t++){const r=y[t];for(let t=0;t<r;t++,e+=i){const u=d;if(u.coordsIndex=e,t!==r-1){const t=m;t.coordsIndex=e+i;const r=f;N(f,a,u,t);const d=(a.x-r.x)/n,g=(a.y-r.y)/o,y=d*d+g*g;y<=1&&l.candidates.push(h(s.getObjectId(p),c(r),Math.sqrt(y),c(u),c(t)))}}}}if("none"!==e.vertexMode){const t=u?r.length-i:r.length;if("all"===e.vertexMode)for(let e=0;e<t;e+=i){const t=d;t.coordsIndex=e;const i=(a.x-t.x)/n,r=(a.y-t.y)/o,u=i*i+r*r;u<=1&&l.candidates.push(g(s.getObjectId(p),c(t),Math.sqrt(u)))}else if("ends"===e.vertexMode){const e=[0];u||e.push(r.length-i);for(const t of e){const e=d;e.coordsIndex=t;const i=(a.x-e.x)/n,r=(a.y-e.y)/o,u=i*i+r*r;u<=1&&l.candidates.push(g(s.getObjectId(p),c(e),Math.sqrt(u)))}}}}return l.candidates.sort(((e,t)=>e.distance-t.distance)),l}_getPointCreator(e,t,s){const i=null==s||o(t,s)?e=>e:e=>m(e,t,s),{hasZ:a}=this,r=0;return"3d"===e?a?({x:e,y:t,z:s})=>i({x:e,y:t,z:s}):({x:e,y:t})=>i({x:e,y:t,z:r}):({x:e,y:t})=>i({x:e,y:t})}async createSummaryStatisticsResponse(e){const{field:t,valueExpression:s,normalizationField:i,normalizationType:a,normalizationTotal:r,minValue:n,maxValue:o,scale:l,timeZone:u}=e,c=this.fieldsIndex.get(t),d=f(c)||p(c)||y(c),m=await this._getDataValues({field:t,valueExpression:s,normalizationField:i,normalizationType:a,normalizationTotal:r,scale:l,timeZone:u}),h=T({normalizationType:a,normalizationField:i,minValue:n,maxValue:o}),g={value:.5,fieldType:c?.type},I=x(c)?V({values:m,supportsNullCount:h,percentileParams:g}):F({values:m,minValue:n,maxValue:o,useSampleStdDev:!a,supportsNullCount:h,percentileParams:g});return S(I,d)}async createUniqueValuesResponse(e){const{field:t,valueExpression:s,domains:i,returnAllCodedValues:a,scale:r,timeZone:n}=e,o=await this._getDataValues({field:t,field2:e.field2,field3:e.field3,fieldDelimiter:e.fieldDelimiter,valueExpression:s,scale:r,timeZone:n},!1),l=_(o);return v(l,i,a,e.fieldDelimiter)}async createClassBreaksResponse(e){const{field:t,valueExpression:s,normalizationField:i,normalizationType:a,normalizationTotal:r,classificationMethod:n,standardDeviationInterval:o,minValue:l,maxValue:u,numClasses:c,scale:d,timeZone:m}=e,h=await this._getDataValues({field:t,valueExpression:s,normalizationField:i,normalizationType:a,normalizationTotal:r,scale:d,timeZone:m}),g=b(h,{field:t,normalizationField:i,normalizationType:a,normalizationTotal:r,classificationMethod:n,standardDeviationInterval:o,minValue:l,maxValue:u,numClasses:c});return R(g,n)}async createHistogramResponse(e){const{field:t,valueExpression:s,normalizationField:i,normalizationType:a,normalizationTotal:r,classificationMethod:n,standardDeviationInterval:o,minValue:l,maxValue:u,numBins:c,scale:d,timeZone:m}=e,h=await this._getDataValues({field:t,valueExpression:s,normalizationField:i,normalizationType:a,normalizationTotal:r,scale:d,timeZone:m});return A(h,{field:t,normalizationField:i,normalizationType:a,normalizationTotal:r,classificationMethod:n,standardDeviationInterval:o,minValue:l,maxValue:u,numBins:c})}_sortFeatures(e,t,s){if(e.length>1&&t?.length)for(const i of t.reverse()){const t=i.split(" "),a=t[0],r=this.fieldsIndex.get(a),n=!!t[1]&&"desc"===t[1].toLowerCase(),o=z(r?.type,n);e.sort(((e,t)=>{const i=s(e,a,r),n=s(t,a,r);return o(i,n)}))}}_createFeatureQueryResponse(e){const t=this.items,{geometryType:s,hasM:i,hasZ:a,objectIdField:n,spatialReference:o}=this,{outFields:l,outSR:c,quantizationParameters:d,resultRecordCount:m,resultOffset:h,returnZ:g,returnM:f}=e,p=null!=m&&t.length>(h||0)+m,y=l&&(l.includes("*")?[...this.fieldsIndex.fields]:l.map((e=>this.fieldsIndex.get(e))));return{exceededTransferLimit:p,features:this._createFeatures(e,t),fields:y,geometryType:s,hasM:i&&f,hasZ:a&&g,objectIdFieldName:n,spatialReference:u(c||o),transform:d&&r(d)||null}}_createFeatures(e,t){const s=new l(e,this.featureAdapter,this.fieldsIndex),{hasM:i,hasZ:a}=this,{orderByFields:n,quantizationParameters:o,returnGeometry:u,returnCentroid:m,maxAllowableOffset:h,resultOffset:g,resultRecordCount:f,returnZ:p=!1,returnM:y=!1}=e,x=a&&p,I=i&&y;let T=[],V=0;const F=[...t];if(this._sortFeatures(F,n,((e,t,i)=>s.getFieldValue(e,t,i))),this.geometryType&&(u||m)){const e=r(o)??void 0;if(u&&!m)for(const t of F)T[V++]={attributes:s.getAttributes(t),geometry:c(this.geometryType,this.hasZ,this.hasM,this.featureAdapter.getGeometry(t),h,e,x,I)};else if(!u&&m)for(const t of F)T[V++]={attributes:s.getAttributes(t),centroid:d(this,this.featureAdapter.getCentroid(t,this),e)};else for(const t of F)T[V++]={attributes:s.getAttributes(t),centroid:d(this,this.featureAdapter.getCentroid(t,this),e),geometry:c(this.geometryType,this.hasZ,this.hasM,this.featureAdapter.getGeometry(t),h,e,x,I)}}else for(const r of F){const e=s.getAttributes(r);e&&(T[V++]={attributes:e})}const S=g||0;if(null!=f){const e=S+f;T=T.slice(S,Math.min(T.length,e))}return T}_createExceedsLimitQueryResponse(e){let t=!1,s=Number.POSITIVE_INFINITY,i=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY;for(const r of e.outStatistics??[])if("exceedslimit"===r.statisticType){s=null!=r.maxPointCount?r.maxPointCount:Number.POSITIVE_INFINITY,i=null!=r.maxRecordCount?r.maxRecordCount:Number.POSITIVE_INFINITY,a=null!=r.maxVertexCount?r.maxVertexCount:Number.POSITIVE_INFINITY;break}if("esriGeometryPoint"===this.geometryType)t=this.items.length>s;else if(this.items.length>i)t=!0;else{const e=C(this.hasZ,this.hasM),s=this.featureAdapter;t=this.items.reduce(((e,t)=>{const i=s.getGeometry(t);return e+(null!=i&&i.coords.length||0)}),0)/e>a}return{fields:[{name:"exceedslimit",type:"esriFieldTypeInteger",alias:"exceedslimit",sqlType:"sqlTypeInteger",domain:null,defaultValue:null}],features:[{attributes:{exceedslimit:Number(t)}}]}}async _createStatisticsQueryResponse(e){const t={attributes:{}},s=[],i=new Map,a=new Map,r=new Map,n=new Map,o=new l(e,this.featureAdapter,this.fieldsIndex),u=e.outStatistics,{groupByFieldsForStatistics:c,having:d,orderByFields:m,resultRecordCount:h}=e,g=c?.length,f=!!g,p=f?c[0]:null,y=f&&!this.fieldsIndex.get(p);for(const l of u??[]){const{outStatisticFieldName:e,statisticType:u}=l,m=l,I="exceedslimit"!==u?l.onStatisticField:void 0,T="percentile_disc"===u||"percentile_cont"===u,V="EnvelopeAggregate"===u||"CentroidAggregate"===u||"ConvexHullAggregate"===u,F=f&&1===g&&(I===p||y)&&"count"===u;if(f){if(!r.has(I)){const e=[];for(const t of c){const s=this._getAttributeValues(o,t,i);e.push(s)}r.set(I,this._calculateUniqueValues(e,!V&&o.returnDistinctValues))}const t=r.get(I);if(!t)continue;const s=Object.keys(t);h&&(s.sort(),s.length=Math.min(h,s.length));for(const a of s){const{count:s,data:r,items:l,itemPositions:u}=t[a],h=r.join(",");if(!d||o.validateItems(l,d)){const t=n.get(h)||{attributes:{}};if(V){t.aggregateGeometries||(t.aggregateGeometries={});const{aggregateGeometries:e,outStatisticFieldName:s}=await this._getAggregateGeometry(m,l);t.aggregateGeometries[s]=e}else{let a=null;if(F)a=s;else{const e=this._getAttributeValues(o,I,i),t=u.map((t=>e[t]));a=T&&"statisticParameters"in m?this._getPercentileValue(m,t):this._getStatisticValue(m,t,null,o.returnDistinctValues)}t.attributes[e]=a}let a=0;c.forEach(((e,s)=>t.attributes[this.fieldsIndex.get(e)?e:"EXPR_"+ ++a]=r[s])),n.set(h,t)}}}else if(V){t.aggregateGeometries||(t.aggregateGeometries={});const{aggregateGeometries:e,outStatisticFieldName:s}=await this._getAggregateGeometry(m,this.items);t.aggregateGeometries[s]=e}else{const s=this._getAttributeValues(o,I,i);t.attributes[e]=T&&"statisticParameters"in m?this._getPercentileValue(m,s):this._getStatisticValue(m,s,a,o.returnDistinctValues)}const S="min"!==u&&"max"!==u||!x(this.fieldsIndex.get(I))&&!this._isAnyDateField(I)?null:this.fieldsIndex.get(I)?.type;s.push({name:e,alias:e,type:S||"esriFieldTypeDouble"})}const I=f?Array.from(n.values()):[t];return this._sortFeatures(I,m,((e,t)=>e.attributes[t])),{fields:s,features:I}}_isAnyDateField(e){const t=this.fieldsIndex.get(e);return f(t)||p(t)||y(t)||I(t)}async _getAggregateGeometry(e,r){const{convexHull:n,union:o}=await import("../../../geometry/geometryEngineJSON.js"),{statisticType:l,outStatisticFieldName:u}=e,{featureAdapter:d,spatialReference:m,geometryType:h,hasZ:g,hasM:f}=this,p=r.map((e=>c(h,g,f,d.getGeometry(e)))),y=n(m,p,!0)[0],x={aggregateGeometries:null,outStatisticFieldName:null};if("EnvelopeAggregate"===l){const e=y?i(y):a(o(m,p));x.aggregateGeometries={...e,spatialReference:m},x.outStatisticFieldName=u||"extent"}else if("CentroidAggregate"===l){const e=y?t(y):s(a(o(m,p)));x.aggregateGeometries={x:e[0],y:e[1],spatialReference:m},x.outStatisticFieldName=u||"centroid"}else"ConvexHullAggregate"===l&&(x.aggregateGeometries=y,x.outStatisticFieldName=u||"convexHull");return x}_getStatisticValue(e,t,s,i){const{onStatisticField:a,statisticType:r}=e;let n=null;n=s?.has(a)?s.get(a):x(this.fieldsIndex.get(a))||this._isAnyDateField(a)?V({values:t,returnDistinct:i}):F({values:i?[...new Set(t)]:t,minValue:null,maxValue:null,useSampleStdDev:!0}),s&&s.set(a,n);return n["var"===r?"variance":r]}_getPercentileValue(e,t){const{onStatisticField:s,statisticParameters:i,statisticType:a}=e,{value:r,orderBy:n}=i,o=this.fieldsIndex.get(s);return M(t,{value:r,orderBy:n,fieldType:o?.type,isDiscrete:"percentile_disc"===a})}_getAttributeValues(e,t,s){if(s.has(t))return s.get(t);const i=this.fieldsIndex.get(t),a=this.items.map((s=>e.getFieldValue(s,t,i)));return s.set(t,a),a}_calculateUniqueValues(e,t){const s={},i=this.items,a=i.length;for(let r=0;r<a;r++){const a=i[r],n=[];for(const t of e)n.push(t[r]);const o=n.join(",");null==s[o]?s[o]={count:1,data:n,items:[a],itemPositions:[r]}:(t||s[o].count++,s[o].items.push(a),s[o].itemPositions.push(r))}return s}async _getDataValues(t,s=!0){const i=new l(this.query,this.featureAdapter,this.fieldsIndex),{valueExpression:a,scale:r,timeZone:n}=t;return a?i.getExpressionValues(this.items,a,{viewingMode:"map",scale:r,spatialReference:this.query.outSR||this.spatialReference},{geometryType:this.geometryType,hasZ:this.hasZ,hasM:this.hasM},n):i.getDataValues(this.items,e(t),s)}}function N(e,t,s,i){const a=i.x-s.x,r=i.y-s.y,n=a*a+r*r,o=(t.x-s.x)*a+(t.y-s.y)*r,l=Math.min(1,Math.max(0,o/n));e.x=s.x+a*l,e.y=s.y+r*l}function C(e,t){return e?t?4:3:t?3:2}class D{constructor(e,t){this.coords=e,this.coordsIndex=t}get x(){return this.coords[this.coordsIndex]}get y(){return this.coords[this.coordsIndex+1]}get z(){return this.coords[this.coordsIndex+2]}}export{q as QueryEngineResult};
5
+ import{clone as e}from"../../../core/lang.js";import{polygonCentroid as t,extentCentroid as s}from"../../../geometry/support/centroid.js";import{getPolygonExtent as i,getGeometryExtent as a}from"../../../geometry/support/extentUtils.js";import{toQuantizationTransform as r}from"../../../geometry/support/quantizationUtils.js";import{isValid as n,equals as o}from"../../../geometry/support/spatialReferenceUtils.js";import l from"./AttributesBuilder.js";import{cleanFromGeometryEngine as u,getGeometry as c,transformCentroid as d}from"./geometryUtils.js";import{project as m}from"./projectionSupport.js";import{makeEdgeCandidate as h,makeVertexCandidate as g}from"./SnappingCandidate.js";import{isDateField as f,isDateOnlyField as p,isTimestampOffsetField as y,isStringField as x,isTimeOnlyField as I}from"../../support/fieldUtils.js";import{isNullCountSupported as T,calculateStringStatistics as V,calculateStatistics as F,processSummaryStatisticsResult as S,calculateUniqueValuesCount as _,createUVResult as v,calculateClassBreaks as b,resolveCBResult as R,calculateHistogram as A,getAttributeComparator as z,calculatePercentile as M}from"../../../statistics/utils.js";class q{constructor(e,t,s){this.items=e,this.query=t,this.geometryType=s.geometryType,this.hasM=s.hasM,this.hasZ=s.hasZ,this.fieldsIndex=s.fieldsIndex,this.objectIdField=s.objectIdField,this.spatialReference=s.spatialReference,this.featureAdapter=s.featureAdapter}get size(){return this.items.length}createQueryResponseForCount(){const e=new l(this.query,this.featureAdapter,this.fieldsIndex);if(!this.query.outStatistics)return e.countDistinctValues(this.items);const{groupByFieldsForStatistics:t,having:s,outStatistics:i}=this.query,a=t?.length;if(!!!a)return 1;const r=new Map,n=new Map,o=new Set;for(const l of i){const{statisticType:i}=l,a="exceedslimit"!==i?l.onStatisticField:void 0;if(!n.has(a)){const s=[];for(const i of t){const t=this._getAttributeValues(e,i,r);s.push(t)}n.set(a,this._calculateUniqueValues(s,e.returnDistinctValues))}const u=n.get(a);for(const t in u){const{data:i,items:a}=u[t],r=i.join(",");s&&!e.validateItems(a,s)||o.add(r)}}return o.size}async createQueryResponse(){let e;if(this.query.outStatistics){e=this.query.outStatistics.some((e=>"exceedslimit"===e.statisticType))?this._createExceedsLimitQueryResponse(this.query):await this._createStatisticsQueryResponse(this.query)}else e=this._createFeatureQueryResponse(this.query);if(this.query.returnQueryGeometry){const t=this.query.geometry;n(this.query.outSR)&&!o(t.spatialReference,this.query.outSR)?e.queryGeometry=u({spatialReference:this.query.outSR,...m(t,t.spatialReference,this.query.outSR)}):e.queryGeometry=u({spatialReference:this.query.outSR,...t})}return e}createSnappingResponse(e,t){const s=this.featureAdapter,i=C(this.hasZ,this.hasM),{point:a,mode:r}=e,n="number"==typeof e.distance?e.distance:e.distance.x,o="number"==typeof e.distance?e.distance:e.distance.y,l={candidates:[]},u="esriGeometryPolygon"===this.geometryType,c=this._getPointCreator(r,this.spatialReference,t),d=new D(null,0),m=new D(null,0),f={x:0,y:0,z:0};for(const p of this.items){const t=s.getGeometry(p);if(null==t)continue;const{coords:r,lengths:y}=t;if(d.coords=r,m.coords=r,e.returnEdge){let e=0;for(let t=0;t<y.length;t++){const r=y[t];for(let t=0;t<r;t++,e+=i){const u=d;if(u.coordsIndex=e,t!==r-1){const t=m;t.coordsIndex=e+i;const r=f;N(f,a,u,t);const d=(a.x-r.x)/n,g=(a.y-r.y)/o,y=d*d+g*g;y<=1&&l.candidates.push(h(s.getObjectId(p),c(r),Math.sqrt(y),c(u),c(t)))}}}}if("none"!==e.vertexMode){const t=u?r.length-i:r.length;if("all"===e.vertexMode)for(let e=0;e<t;e+=i){const t=d;t.coordsIndex=e;const i=(a.x-t.x)/n,r=(a.y-t.y)/o,u=i*i+r*r;u<=1&&l.candidates.push(g(s.getObjectId(p),c(t),Math.sqrt(u)))}else if("ends"===e.vertexMode){const e=[0];u||e.push(r.length-i);for(const t of e){const e=d;e.coordsIndex=t;const i=(a.x-e.x)/n,r=(a.y-e.y)/o,u=i*i+r*r;u<=1&&l.candidates.push(g(s.getObjectId(p),c(e),Math.sqrt(u)))}}}}return l.candidates.sort(((e,t)=>e.distance-t.distance)),l}_getPointCreator(e,t,s){const i=null==s||o(t,s)?e=>e:e=>m(e,t,s),{hasZ:a}=this,r=0;return"3d"===e?a?({x:e,y:t,z:s})=>i({x:e,y:t,z:s}):({x:e,y:t})=>i({x:e,y:t,z:r}):({x:e,y:t})=>i({x:e,y:t})}async createSummaryStatisticsResponse(e){const{field:t,valueExpression:s,normalizationField:i,normalizationType:a,normalizationTotal:r,minValue:n,maxValue:o,scale:l,timeZone:u}=e,c=this.fieldsIndex.get(t),d=f(c)||p(c)||y(c),m=await this._getDataValues({field:t,valueExpression:s,normalizationField:i,normalizationType:a,normalizationTotal:r,scale:l,timeZone:u}),h=T({normalizationType:a,normalizationField:i,minValue:n,maxValue:o}),g={value:.5,fieldType:c?.type},I=x(c)?V({values:m,supportsNullCount:h,percentileParams:g}):F({values:m,minValue:n,maxValue:o,useSampleStdDev:!a,supportsNullCount:h,percentileParams:g});return S(I,d)}async createUniqueValuesResponse(e){const{field:t,valueExpression:s,domains:i,returnAllCodedValues:a,scale:r,timeZone:n}=e,o=await this._getDataValues({field:t,field2:e.field2,field3:e.field3,fieldDelimiter:e.fieldDelimiter,valueExpression:s,scale:r,timeZone:n},!1),l=_(o);return v(l,i,a,e.fieldDelimiter)}async createClassBreaksResponse(e){const{field:t,valueExpression:s,normalizationField:i,normalizationType:a,normalizationTotal:r,classificationMethod:n,standardDeviationInterval:o,minValue:l,maxValue:u,numClasses:c,scale:d,timeZone:m}=e,h=await this._getDataValues({field:t,valueExpression:s,normalizationField:i,normalizationType:a,normalizationTotal:r,scale:d,timeZone:m}),g=b(h,{field:t,normalizationField:i,normalizationType:a,normalizationTotal:r,classificationMethod:n,standardDeviationInterval:o,minValue:l,maxValue:u,numClasses:c});return R(g,n)}async createHistogramResponse(e){const{field:t,valueExpression:s,normalizationField:i,normalizationType:a,normalizationTotal:r,classificationMethod:n,standardDeviationInterval:o,minValue:l,maxValue:u,numBins:c,scale:d,timeZone:m}=e,h=await this._getDataValues({field:t,valueExpression:s,normalizationField:i,normalizationType:a,normalizationTotal:r,scale:d,timeZone:m});return A(h,{field:t,normalizationField:i,normalizationType:a,normalizationTotal:r,classificationMethod:n,standardDeviationInterval:o,minValue:l,maxValue:u,numBins:c})}_sortFeatures(e,t,s){if(e.length>1&&t?.length)for(const i of t.reverse()){const t=i.split(" "),a=t[0],r=this.fieldsIndex.get(a),n=!!t[1]&&"desc"===t[1].toLowerCase(),o=z(r?.type,n);e.sort(((e,t)=>{const i=s(e,a,r),n=s(t,a,r);return o(i,n)}))}}_createFeatureQueryResponse(e){const t=this.items,{geometryType:s,hasM:i,hasZ:a,objectIdField:n,spatialReference:o}=this,{outFields:l,outSR:c,quantizationParameters:d,resultRecordCount:m,resultOffset:h,returnZ:g,returnM:f}=e,p=null!=m&&t.length>(h||0)+m,y=l&&(l.includes("*")?[...this.fieldsIndex.fields]:l.map((e=>this.fieldsIndex.get(e))));return{exceededTransferLimit:p,features:this._createFeatures(e,t),fields:y,geometryType:s,hasM:i&&f,hasZ:a&&g,objectIdFieldName:n,spatialReference:u(c||o),transform:d&&r(d)||null}}_createFeatures(e,t){const s=new l(e,this.featureAdapter,this.fieldsIndex),{hasM:i,hasZ:a}=this,{orderByFields:n,quantizationParameters:o,returnGeometry:u,returnCentroid:m,maxAllowableOffset:h,resultOffset:g,resultRecordCount:f,returnZ:p=!1,returnM:y=!1}=e,x=a&&p,I=i&&y;let T=[],V=0;const F=[...t];if(this._sortFeatures(F,n,((e,t,i)=>s.getFieldValue(e,t,i))),this.geometryType&&(u||m)){const e=r(o)??void 0;if(u&&!m)for(const t of F)T[V++]={attributes:s.getAttributes(t),geometry:c(this.geometryType,this.hasZ,this.hasM,this.featureAdapter.getGeometry(t),h,e,x,I)};else if(!u&&m)for(const t of F)T[V++]={attributes:s.getAttributes(t),centroid:d(this,this.featureAdapter.getCentroid(t,this),e)};else for(const t of F)T[V++]={attributes:s.getAttributes(t),centroid:d(this,this.featureAdapter.getCentroid(t,this),e),geometry:c(this.geometryType,this.hasZ,this.hasM,this.featureAdapter.getGeometry(t),h,e,x,I)}}else for(const r of F){const e=s.getAttributes(r);e&&(T[V++]={attributes:e})}const S=g||0;if(null!=f){const e=S+f;T=T.slice(S,Math.min(T.length,e))}return T}_createExceedsLimitQueryResponse(e){let t=!1,s=Number.POSITIVE_INFINITY,i=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY;for(const r of e.outStatistics??[])if("exceedslimit"===r.statisticType){s=null!=r.maxPointCount?r.maxPointCount:Number.POSITIVE_INFINITY,i=null!=r.maxRecordCount?r.maxRecordCount:Number.POSITIVE_INFINITY,a=null!=r.maxVertexCount?r.maxVertexCount:Number.POSITIVE_INFINITY;break}if("esriGeometryPoint"===this.geometryType)t=this.items.length>s;else if(this.items.length>i)t=!0;else{const e=C(this.hasZ,this.hasM),s=this.featureAdapter;t=this.items.reduce(((e,t)=>{const i=s.getGeometry(t);return e+(null!=i&&i.coords.length||0)}),0)/e>a}return{fields:[{name:"exceedslimit",type:"esriFieldTypeInteger",alias:"exceedslimit",sqlType:"sqlTypeInteger",domain:null,defaultValue:null}],features:[{attributes:{exceedslimit:Number(t)}}]}}async _createStatisticsQueryResponse(e){const t={attributes:{}},s=[],i=new Map,a=new Map,r=new Map,n=new Map,o=new l(e,this.featureAdapter,this.fieldsIndex),u=e.outStatistics,{groupByFieldsForStatistics:c,having:d,orderByFields:m,resultRecordCount:h}=e,g=c?.length,f=!!g,p=f?c[0]:null,y=f&&!this.fieldsIndex.get(p);for(const l of u??[]){const{outStatisticFieldName:e,statisticType:u}=l,m=l,h="exceedslimit"!==u?l.onStatisticField:void 0,I="percentile_disc"===u||"percentile_cont"===u,T="EnvelopeAggregate"===u||"CentroidAggregate"===u||"ConvexHullAggregate"===u,V=f&&1===g&&(h===p||y)&&"count"===u;if(f){if(!r.has(h)){const e=[];for(const t of c){const s=this._getAttributeValues(o,t,i);e.push(s)}r.set(h,this._calculateUniqueValues(e,!T&&o.returnDistinctValues))}const t=r.get(h);if(!t)continue;const s=Object.keys(t);for(const a of s){const{count:s,data:r,items:l,itemPositions:u}=t[a],g=r.join(",");if(!d||o.validateItems(l,d)){const t=n.get(g)||{attributes:{}};if(T){t.aggregateGeometries||(t.aggregateGeometries={});const{aggregateGeometries:e,outStatisticFieldName:s}=await this._getAggregateGeometry(m,l);t.aggregateGeometries[s]=e}else{let a=null;if(V)a=s;else{const e=this._getAttributeValues(o,h,i),t=u.map((t=>e[t]));a=I&&"statisticParameters"in m?this._getPercentileValue(m,t):this._getStatisticValue(m,t,null,o.returnDistinctValues)}t.attributes[e]=a}let a=0;c.forEach(((e,s)=>t.attributes[this.fieldsIndex.get(e)?e:"EXPR_"+ ++a]=r[s])),n.set(g,t)}}}else if(T){t.aggregateGeometries||(t.aggregateGeometries={});const{aggregateGeometries:e,outStatisticFieldName:s}=await this._getAggregateGeometry(m,this.items);t.aggregateGeometries[s]=e}else{const s=this._getAttributeValues(o,h,i);t.attributes[e]=I&&"statisticParameters"in m?this._getPercentileValue(m,s):this._getStatisticValue(m,s,a,o.returnDistinctValues)}const F="min"!==u&&"max"!==u||!x(this.fieldsIndex.get(h))&&!this._isAnyDateField(h)?null:this.fieldsIndex.get(h)?.type;s.push({name:e,alias:e,type:F||"esriFieldTypeDouble"})}const I=f?Array.from(n.values()):[t];return this._sortFeatures(I,m,((e,t)=>e.attributes[t])),h&&(I.length=Math.min(h,I.length)),{fields:s,features:I}}_isAnyDateField(e){const t=this.fieldsIndex.get(e);return f(t)||p(t)||y(t)||I(t)}async _getAggregateGeometry(e,r){const{convexHull:n,union:o}=await import("../../../geometry/geometryEngineJSON.js"),{statisticType:l,outStatisticFieldName:u}=e,{featureAdapter:d,spatialReference:m,geometryType:h,hasZ:g,hasM:f}=this,p=r.map((e=>c(h,g,f,d.getGeometry(e)))),y=n(m,p,!0)[0],x={aggregateGeometries:null,outStatisticFieldName:null};if("EnvelopeAggregate"===l){const e=y?i(y):a(o(m,p));x.aggregateGeometries={...e,spatialReference:m},x.outStatisticFieldName=u||"extent"}else if("CentroidAggregate"===l){const e=y?t(y):s(a(o(m,p)));x.aggregateGeometries={x:e[0],y:e[1],spatialReference:m},x.outStatisticFieldName=u||"centroid"}else"ConvexHullAggregate"===l&&(x.aggregateGeometries=y,x.outStatisticFieldName=u||"convexHull");return x}_getStatisticValue(e,t,s,i){const{onStatisticField:a,statisticType:r}=e;let n=null;n=s?.has(a)?s.get(a):x(this.fieldsIndex.get(a))||this._isAnyDateField(a)?V({values:t,returnDistinct:i}):F({values:i?[...new Set(t)]:t,minValue:null,maxValue:null,useSampleStdDev:!0}),s&&s.set(a,n);return n["var"===r?"variance":r]}_getPercentileValue(e,t){const{onStatisticField:s,statisticParameters:i,statisticType:a}=e,{value:r,orderBy:n}=i,o=this.fieldsIndex.get(s);return M(t,{value:r,orderBy:n,fieldType:o?.type,isDiscrete:"percentile_disc"===a})}_getAttributeValues(e,t,s){if(s.has(t))return s.get(t);const i=this.fieldsIndex.get(t),a=this.items.map((s=>e.getFieldValue(s,t,i)));return s.set(t,a),a}_calculateUniqueValues(e,t){const s={},i=this.items,a=i.length;for(let r=0;r<a;r++){const a=i[r],n=[];for(const t of e)n.push(t[r]);const o=n.join(",");null==s[o]?s[o]={count:1,data:n,items:[a],itemPositions:[r]}:(t||s[o].count++,s[o].items.push(a),s[o].itemPositions.push(r))}return s}async _getDataValues(t,s=!0){const i=new l(this.query,this.featureAdapter,this.fieldsIndex),{valueExpression:a,scale:r,timeZone:n}=t;return a?i.getExpressionValues(this.items,a,{viewingMode:"map",scale:r,spatialReference:this.query.outSR||this.spatialReference},{geometryType:this.geometryType,hasZ:this.hasZ,hasM:this.hasM},n):i.getDataValues(this.items,e(t),s)}}function N(e,t,s,i){const a=i.x-s.x,r=i.y-s.y,n=a*a+r*r,o=(t.x-s.x)*a+(t.y-s.y)*r,l=Math.min(1,Math.max(0,o/n));e.x=s.x+a*l,e.y=s.y+r*l}function C(e,t){return e?t?4:3:t?3:2}class D{constructor(e,t){this.coords=e,this.coordsIndex=t}get x(){return this.coords[this.coordsIndex]}get y(){return this.coords[this.coordsIndex+1]}get z(){return this.coords[this.coordsIndex+2]}}export{q as QueryEngineResult};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{isDateString as e}from"../../../../core/date.js";import t from"../../../../core/Error.js";import{isWGS84 as n}from"../../../../geometry/support/spatialReferenceUtils.js";import{OptimizedFeature as o}from"../../OptimizedFeature.js";import r from"../../OptimizedGeometry.js";import{normalizeFieldName as i,isNumericField as s}from"../../../support/fieldUtils.js";const c={LineString:"esriGeometryPolyline",MultiLineString:"esriGeometryPolyline",MultiPoint:"esriGeometryMultipoint",Point:"esriGeometryPoint",Polygon:"esriGeometryPolygon",MultiPolygon:"esriGeometryPolygon"};function u(e){return c[e]}function*l(e){switch(e.type){case"Feature":yield e;break;case"FeatureCollection":for(const t of e.features)t&&(yield t)}}function*f(e){if(e)switch(e.type){case"Point":yield e.coordinates;break;case"LineString":case"MultiPoint":yield*e.coordinates;break;case"MultiLineString":case"Polygon":for(const t of e.coordinates)yield*t;break;case"MultiPolygon":for(const t of e.coordinates)for(const e of t)yield*e}}function*p(e,t={}){const{geometryType:n,objectIdField:i}=t;for(const s of e){const{geometry:e,properties:c,id:l}=s;if(e&&u(e.type)!==n)continue;const f=c||{};let p;i&&(p=f[i],null==l||p||(f[i]=p=l));const a=new o(e?h(new r,e,t):null,f,null,p??void 0);yield a}}function a(e){for(const t of e)if(t.length>2)return!0;return!1}function y(e){return!g(e)}function d(e){return g(e)}function g(e){let t=0;for(let n=0;n<e.length;n++){const o=e[n],r=e[(n+1)%e.length];t+=o[0]*r[1]-r[0]*o[1]}return t<=0}function m(e){const t=e[0],n=e[e.length-1];return t[0]===n[0]&&t[1]===n[1]&&t[2]===n[2]||e.push(t),e}function h(e,t,n){switch(t.type){case"LineString":return w(e,t,n);case"MultiLineString":return P(e,t,n);case"MultiPoint":return j(e,t,n);case"MultiPolygon":return b(e,t,n);case"Point":return S(e,t,n);case"Polygon":return F(e,t,n)}}function w(e,t,n){return M(e,t.coordinates,n),e}function P(e,t,n){for(const o of t.coordinates)M(e,o,n);return e}function j(e,t,n){return M(e,t.coordinates,n),e}function b(e,t,n){for(const o of t.coordinates){G(e,o[0],n);for(let t=1;t<o.length;t++)k(e,o[t],n)}return e}function S(e,t,n){return O(e,t.coordinates,n),e}function F(e,t,n){const o=t.coordinates;G(e,o[0],n);for(let r=1;r<o.length;r++)k(e,o[r],n);return e}function G(e,t,n){const o=m(t);y(o)?T(e,o,n):M(e,o,n)}function k(e,t,n){const o=m(t);d(o)?T(e,o,n):M(e,o,n)}function M(e,t,n){for(const o of t)O(e,o,n);e.lengths.push(t.length)}function T(e,t,n){for(let o=t.length-1;o>=0;o--)O(e,t[o],n);e.lengths.push(t.length)}function O(e,t,n){const[o,r,i]=t;e.coords.push(o,r),n.hasZ&&e.coords.push(i||0)}function L(t){switch(typeof t){case"string":return e(t)?"esriFieldTypeDate":"esriFieldTypeString";case"number":return"esriFieldTypeDouble";default:return"unknown"}}function E(e,o=4326){if(!e)throw new t("geojson-layer:empty","GeoJSON data is empty");if("Feature"!==e.type&&"FeatureCollection"!==e.type)throw new t("geojson-layer:unsupported-geojson-object","missing or not supported GeoJSON object type",{data:e});const{crs:r}=e;if(!r)return;const i="string"==typeof r?r:"name"===r.type?r.properties.name:"EPSG"===r.type?r.properties.code:null,s=n({wkid:o})?new RegExp(".*(CRS84H?|4326)$","i"):new RegExp(`.*(${o})$`,"i");if(!i||!s.test(i))throw new t("geojson:unsupported-crs","unsupported GeoJSON 'crs' member",{crs:r})}function I(e,t={}){const n=[],o=new Set,r=new Set;let c,p=!1,y=null,d=!1,{geometryType:g=null}=t,m=!1;for(const s of l(e)){const{geometry:e,properties:t,id:l}=s;if(!e||(g||(g=u(e.type)),u(e.type)===g)){if(!p){p=a(f(e))}if(d||(d=null!=l,d&&(c=typeof l,t&&(y=Object.keys(t).filter((e=>t[e]===l))))),t&&y&&d&&null!=l&&(y.length>1?y=y.filter((e=>t[e]===l)):1===y.length&&(y=t[y[0]]===l?y:[])),!m&&t){let e=!0;for(const s in t){if(o.has(s))continue;const c=t[s];if(null==c){e=!1,r.add(s);continue}const u=L(c);if("unknown"===u){r.add(s);continue}r.delete(s),o.add(s);const l=i(s);l&&n.push({name:l,alias:s,type:u})}m=e}}}const h=i(1===y?.length&&y[0]||null)??void 0;if(h)for(const i of n)if(i.name===h&&s(i)){i.type="esriFieldTypeOID";break}return{fields:n,geometryType:g,hasZ:p,objectIdFieldName:h,objectIdFieldType:c,unknownFields:Array.from(r)}}function N(e,t){return Array.from(p(l(e),t))}export{N as createOptimizedFeatures,u as getGeometryType,I as inferLayerProperties,E as validateGeoJSON};
5
+ import{isISO8601Date as e}from"../../../../core/date.js";import t from"../../../../core/Error.js";import{isWGS84 as n}from"../../../../geometry/support/spatialReferenceUtils.js";import{OptimizedFeature as o}from"../../OptimizedFeature.js";import r from"../../OptimizedGeometry.js";import{normalizeFieldName as i,isNumericField as s}from"../../../support/fieldUtils.js";const c={LineString:"esriGeometryPolyline",MultiLineString:"esriGeometryPolyline",MultiPoint:"esriGeometryMultipoint",Point:"esriGeometryPoint",Polygon:"esriGeometryPolygon",MultiPolygon:"esriGeometryPolygon"};function u(e){return c[e]}function*l(e){switch(e.type){case"Feature":yield e;break;case"FeatureCollection":for(const t of e.features)t&&(yield t)}}function*f(e){if(e)switch(e.type){case"Point":yield e.coordinates;break;case"LineString":case"MultiPoint":yield*e.coordinates;break;case"MultiLineString":case"Polygon":for(const t of e.coordinates)yield*t;break;case"MultiPolygon":for(const t of e.coordinates)for(const e of t)yield*e}}function*p(e,t={}){const{geometryType:n,objectIdField:i}=t;for(const s of e){const{geometry:e,properties:c,id:l}=s;if(e&&u(e.type)!==n)continue;const f=c||{};let p;i&&(p=f[i],null==l||p||(f[i]=p=l));const a=new o(e?h(new r,e,t):null,f,null,p??void 0);yield a}}function a(e){for(const t of e)if(t.length>2)return!0;return!1}function y(e){return!g(e)}function d(e){return g(e)}function g(e){let t=0;for(let n=0;n<e.length;n++){const o=e[n],r=e[(n+1)%e.length];t+=o[0]*r[1]-r[0]*o[1]}return t<=0}function m(e){const t=e[0],n=e[e.length-1];return t[0]===n[0]&&t[1]===n[1]&&t[2]===n[2]||e.push(t),e}function h(e,t,n){switch(t.type){case"LineString":return w(e,t,n);case"MultiLineString":return P(e,t,n);case"MultiPoint":return j(e,t,n);case"MultiPolygon":return b(e,t,n);case"Point":return S(e,t,n);case"Polygon":return F(e,t,n)}}function w(e,t,n){return M(e,t.coordinates,n),e}function P(e,t,n){for(const o of t.coordinates)M(e,o,n);return e}function j(e,t,n){return M(e,t.coordinates,n),e}function b(e,t,n){for(const o of t.coordinates){G(e,o[0],n);for(let t=1;t<o.length;t++)k(e,o[t],n)}return e}function S(e,t,n){return O(e,t.coordinates,n),e}function F(e,t,n){const o=t.coordinates;G(e,o[0],n);for(let r=1;r<o.length;r++)k(e,o[r],n);return e}function G(e,t,n){const o=m(t);y(o)?T(e,o,n):M(e,o,n)}function k(e,t,n){const o=m(t);d(o)?T(e,o,n):M(e,o,n)}function M(e,t,n){for(const o of t)O(e,o,n);e.lengths.push(t.length)}function T(e,t,n){for(let o=t.length-1;o>=0;o--)O(e,t[o],n);e.lengths.push(t.length)}function O(e,t,n){const[o,r,i]=t;e.coords.push(o,r),n.hasZ&&e.coords.push(i||0)}function L(t){switch(typeof t){case"string":return e(t)?"esriFieldTypeDate":"esriFieldTypeString";case"number":return"esriFieldTypeDouble";default:return"unknown"}}function E(e,o=4326){if(!e)throw new t("geojson-layer:empty","GeoJSON data is empty");if("Feature"!==e.type&&"FeatureCollection"!==e.type)throw new t("geojson-layer:unsupported-geojson-object","missing or not supported GeoJSON object type",{data:e});const{crs:r}=e;if(!r)return;const i="string"==typeof r?r:"name"===r.type?r.properties.name:"EPSG"===r.type?r.properties.code:null,s=n({wkid:o})?new RegExp(".*(CRS84H?|4326)$","i"):new RegExp(`.*(${o})$`,"i");if(!i||!s.test(i))throw new t("geojson:unsupported-crs","unsupported GeoJSON 'crs' member",{crs:r})}function I(e,t={}){const n=[],o=new Set,r=new Set;let c,p=!1,y=null,d=!1,{geometryType:g=null}=t,m=!1;for(const s of l(e)){const{geometry:e,properties:t,id:l}=s;if(!e||(g||(g=u(e.type)),u(e.type)===g)){if(!p){p=a(f(e))}if(d||(d=null!=l,d&&(c=typeof l,t&&(y=Object.keys(t).filter((e=>t[e]===l))))),t&&y&&d&&null!=l&&(y.length>1?y=y.filter((e=>t[e]===l)):1===y.length&&(y=t[y[0]]===l?y:[])),!m&&t){let e=!0;for(const s in t){if(o.has(s))continue;const c=t[s];if(null==c){e=!1,r.add(s);continue}const u=L(c);if("unknown"===u){r.add(s);continue}r.delete(s),o.add(s);const l=i(s);l&&n.push({name:l,alias:s,type:u})}m=e}}}const h=i(1===y?.length&&y[0]||null)??void 0;if(h)for(const i of n)if(i.name===h&&s(i)){i.type="esriFieldTypeOID";break}return{fields:n,geometryType:g,hasZ:p,objectIdFieldName:h,objectIdFieldType:c,unknownFields:Array.from(r)}}function N(e,t){return Array.from(p(l(e),t))}export{N as createOptimizedFeatures,u as getGeometryType,I as inferLayerProperties,E as validateGeoJSON};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{difference as e,isSome as a}from"../../core/arrayUtils.js";import r from"../../core/Error.js";import{updateOrigins as t}from"../../core/accessorSupport/originUtils.js";import o from"../FeatureLayer.js";import{save as s,getLayerJSON as l,setCommonItemProperties as n,saveAs as i,getPortalItem as u,addItem as c,ensureLayerConfig as p,ensureItemConfig as m,createErrorMessage as f}from"./utils.js";import{parse as y}from"../support/arcgisLayerUrl.js";import{fetchFeatureService as d}from"../support/fetchService.js";import{isLayerWithFeatureLayerSource as h}from"../support/layerUtils.js";import{createForItemWrite as w}from"../../portal/support/jsonContext.js";import{getWGS84ExtentForItem as v,removeTypeKeyword as S,TypeKeyword as I,toggleTypeKeword as b,addTypeKeyword as T}from"../../portal/support/portalItemUtils.js";const P="Feature Service",$="feature-layer-utils",E=`${$}-save`,A=`${$}-save-as`,L=`${$}-saveall`,N=`${$}-saveall-as`;function x(e){return{isValid:h(e)&&("feature"!==e.type||!e.dynamicDataSource),errorMessage:"Feature layer should be a layer or table in a map or feature service"}}function j(e){const a=[],r=[];for(const{layer:t,layerJSON:o}of e)t.isTable?r.push(o):a.push(o);return{layers:a,tables:r}}function U(e){return j([e])}async function g(e,a){return/\/\d+\/?$/.test(e.url)?U(a[0]):O(a,e)}async function O(e,a){if(!a)return e.reverse(),j(e);const{layer:{url:r,customParameters:t,apiKey:o}}=e[0];let s=await a.fetchData("json");null!=s?.layers&&null!=s?.tables||(s=await J(s,{url:r??"",customParameters:t,apiKey:o},e.map((e=>e.layer.layerId))));for(const l of e)D(l.layer,l.layerJSON,s);return s}async function J(e,a,r){e||={},e.layers||=[],e.tables||=[];const{url:t,customParameters:o,apiKey:s}=a,{serviceJSON:l,layersJSON:n}=await d(t,{customParameters:o,apiKey:s}),i=M(e.layers,l.layers,r),u=M(e.tables,l.tables,r);e.layers=i.itemResources,e.tables=u.itemResources;const c=[...i.added,...u.added],p=n?[...n.layers,...n.tables]:[];return await R(e,c,t,p),e}function M(a,r,t){const o=e(a,r,((e,a)=>e.id===a.id));a=a.filter((e=>!o.removed.some((a=>a.id===e.id))));const s=o.added.map((({id:e})=>({id:e})));return s.forEach((({id:e})=>{a.push({id:e})})),{itemResources:a,added:s.filter((({id:e})=>!t.includes(e)))}}async function R(e,a,r,t){const s=a.map((({id:e})=>new o({url:r,layerId:e,sourceJSON:t.find((({id:a})=>a===e))})));await Promise.allSettled(s.map((e=>e.load()))),s.forEach((a=>{const{layerId:r,loaded:t,defaultPopupTemplate:o}=a;if(!t||null==o)return;D(a,{id:r,popupInfo:o.toJSON()},e)}))}function D(e,a,r){e.isTable?F(r.tables,a):F(r.layers,a)}function F(e,a){const r=e.findIndex((({id:e})=>e===a.id));-1===r?e.push(a):e[r]=a}function K(e,a){if(!e.length)throw new r(`${a}:missing-parameters`,"'layers' array should contain at least one feature layer")}function Y(e,a){const t=e.map((e=>e.portalItem.id));if(new Set(t).size>1)throw new r(`${a}:invalid-parameters`,"All layers in the 'layers' array should be loaded from the same portal item")}function _(e,a){const t=e.map((e=>e.layerId));if(new Set(t).size!==t.length)throw new r(`${a}:invalid-parameters`,"'layers' array should contain only one instance each of layer or table in a feature service")}async function z(e){K(e,L),await Promise.all(e.map((e=>e.load())));for(const a of e)p(a,L,x),m({layer:a,itemType:P,errorNamePrefix:L});Y(e,L),_(e,L)}async function B(e,a){const{url:r,layerId:t,title:o,fullExtent:s,isTable:l}=e,n=y(r);a.url="FeatureServer"===n?.serverType?r:`${r}/${t}`,a.title||=o,a.extent=null,l||null==s||(a.extent=await v(s)),S(a,I.METADATA),S(a,I.MULTI_LAYER),T(a,I.SINGLE_LAYER),l&&T(a,I.TABLE)}function G(e,a){for(const l of e){const t=l.parsedUrl.path,o=y(t),s=o?.url.path;if(!s)throw new r(`${a}:invalid-parameters`,f(l,`has unsupported url pattern: ${t}`),{layer:l});const n=o?.serverType;if("FeatureServer"!==n&&"MapServer"!==n)throw new r(`${a}:invalid-parameters`,f(l,`has unsupported server type: ${n}`),{layer:l});if("MapServer"===n&&e.length>1)throw new r(`${a}:invalid-parameters`,"Only one layer or table in a map service can be saved")}const t=y(e[0].parsedUrl.path),o=t?.url.path,s=e.every((e=>{const a=y(e.parsedUrl.path);return a?.url.path===o}));if(!s)throw new r(`${a}:invalid-parameters`,"'layers' array should only contain layers or tables that belong to the same feature service")}async function C(e){K(e,N),await Promise.all(e.map((e=>e.load())));for(const a of e)p(a,N,x);G(e,N),_(e,N)}async function V(e,r){let t=0,o=0;for(const{isTable:a}of r)a?o++:t++;const s=r[0].parsedUrl.path,l=y(s);if(e.url="FeatureServer"===l?.serverType?l.url.path:s,e.title||=l.title,e.extent=null,t>0){const t=r.map((e=>e.fullExtent)).filter(a).reduce(((e,a)=>e.clone().union(a)));t&&(e.extent=await v(t))}S(e,I.METADATA),b(e,I.MULTI_LAYER,r.length>1),b(e,I.SINGLE_LAYER,1===r.length),b(e,I.TABLE,o>0&&0===t),n(e)}async function k(e,a){return s({layer:e,itemType:P,validateLayer:x,createItemData:(e,a)=>g(a,[e]),errorNamePrefix:E},a)}async function q(e,a){await z(e);const r=e[0].portalItem,o=w(r),s=await Promise.all(e.map((e=>l(e,o,a)))),i=await g(r,e.map(((e,a)=>({layer:e,layerJSON:s[a]}))));return n(r),await r.update({data:i}),await Promise.all(e.slice(1).map((e=>e.portalItem.reload()))),t(o),r.clone()}async function H(e,a,r){return i({layer:e,itemType:P,validateLayer:x,createItemData:(e,a)=>Promise.resolve(U(e)),errorNamePrefix:A,newItem:a,setItemProperties:B},r)}async function Q(e,a,r){await C(e);const o=u({itemType:P,errorNamePrefix:N,newItem:a}),s=w(o),n=await Promise.all(e.map((e=>l(e,s,r)))),i=await O(e.map(((e,a)=>({layer:e,layerJSON:n[a]}))));await V(o,e),await c(o,i,r);for(const t of e)t.portalItem=o.clone();return t(s),o}export{k as save,q as saveAll,Q as saveAllAs,H as saveAs};
5
+ import{difference as e,isSome as a}from"../../core/arrayUtils.js";import r from"../../core/Error.js";import{updateOrigins as t}from"../../core/accessorSupport/originUtils.js";import{save as o,getLayerJSON as s,setCommonItemProperties as n,saveAs as l,getPortalItem as i,addItem as c,ensureLayerConfig as u,ensureItemConfig as p,createErrorMessage as y}from"./utils.js";import{parse as m}from"../support/arcgisLayerUrl.js";import{fetchFeatureService as f}from"../support/fetchService.js";import{isLayerWithFeatureLayerSource as d}from"../support/layerUtils.js";import{layerLookupMap as h}from"../support/lazyLayerLoader.js";import{createForItemWrite as w}from"../../portal/support/jsonContext.js";import{getWGS84ExtentForItem as v,removeTypeKeyword as I,TypeKeyword as T,toggleTypeKeword as S,addTypeKeyword as b}from"../../portal/support/portalItemUtils.js";const L="Feature Service",P="feature-layer-utils",E=`${P}-save`,$=`${P}-save-as`,A=`${P}-saveall`,N=`${P}-saveall-as`;function g(e){return{isValid:d(e)&&("feature"!==e.type||!e.dynamicDataSource),errorMessage:"Feature layer should be a layer or table in a map or feature service"}}function x(e){const a=[],r=[];for(const{layer:t,layerJSON:o}of e)t.isTable?r.push(o):a.push(o);return{layers:a,tables:r}}function j(e){return x([e])}async function O(e,a){return/\/\d+\/?$/.test(e.url)?j(a[0]):U(a,e)}async function U(e,a){if(!a)return e.reverse(),x(e);const{layer:{url:r,customParameters:t,apiKey:o}}=e[0];let s=await a.fetchData("json");null!=s?.layers&&null!=s?.tables||(s=await F(s,{url:r??"",customParameters:t,apiKey:o},e.map((e=>e.layer.layerId))));for(const n of e)K(n.layer,n.layerJSON,s);return s}async function F(e,a,r){e||={},e.layers||=[],e.tables||=[];const{url:t,customParameters:o,apiKey:s}=a,{serviceJSON:n,layersJSON:l}=await f(t,{customParameters:o,apiKey:s}),i=J(e.layers,n.layers,r),c=J(e.tables,n.tables,r);e.layers=i.itemResources,e.tables=c.itemResources;const u=[...i.added,...c.added],p=l?[...l.layers,...l.tables]:[];return await M(e,u,t,p),e}function J(a,r,t){const o=e(a,r,((e,a)=>e.id===a.id));a=a.filter((e=>!o.removed.some((a=>a.id===e.id))));const s=o.added;return s.forEach((({id:e})=>{a.push({id:e})})),{itemResources:a,added:s.filter((({id:e})=>!t.includes(e)))}}async function M(e,a,r,t){const o=await R(a),s=a.map((({id:e,type:a})=>new(o.get(a))({url:r,layerId:e,sourceJSON:t.find((({id:a})=>a===e))})));await Promise.allSettled(s.map((e=>e.load()))),s.forEach((a=>{const{layerId:r,loaded:t,defaultPopupTemplate:o}=a;if(!t||null==o)return;const s={id:r,popupInfo:o.toJSON()};"ArcGISFeatureLayer"!==a.operationalLayerType&&(s.layerType=a.operationalLayerType),K(a,s,e)}))}async function R(e){const a=[];e.forEach((({type:e})=>{const r=D(e),t=h[r];a.push(t())}));const r=await Promise.all(a),t=new Map;return e.forEach((({type:e},a)=>{t.set(e,r[a])})),t}function D(e){let a;switch(e){case"Feature Layer":case"Table":a="FeatureLayer";break;case"Oriented Imagery Layer":a="OrientedImageryLayer"}return a}function K(e,a,r){e.isTable?Y(r.tables,a):Y(r.layers,a)}function Y(e,a){const r=e.findIndex((({id:e})=>e===a.id));-1===r?e.push(a):e[r]=a}function _(e,a){if(!e.length)throw new r(`${a}:missing-parameters`,"'layers' array should contain at least one feature layer")}function z(e,a){const t=e.map((e=>e.portalItem.id));if(new Set(t).size>1)throw new r(`${a}:invalid-parameters`,"All layers in the 'layers' array should be loaded from the same portal item")}function G(e,a){const t=e.map((e=>e.layerId));if(new Set(t).size!==t.length)throw new r(`${a}:invalid-parameters`,"'layers' array should contain only one instance each of layer or table in a feature service")}async function B(e){_(e,A),await Promise.all(e.map((e=>e.load())));for(const a of e)u(a,A,g),p({layer:a,itemType:L,errorNamePrefix:A});z(e,A),G(e,A)}async function k(e,a){const{url:r,layerId:t,title:o,fullExtent:s,isTable:n}=e,l=m(r);a.url="FeatureServer"===l?.serverType?r:`${r}/${t}`,a.title||=o,a.extent=null,n||null==s||(a.extent=await v(s)),I(a,T.METADATA),I(a,T.MULTI_LAYER),b(a,T.SINGLE_LAYER),n&&b(a,T.TABLE)}function C(e,a){for(const n of e){const t=n.parsedUrl.path,o=m(t),s=o?.url.path;if(!s)throw new r(`${a}:invalid-parameters`,y(n,`has unsupported url pattern: ${t}`),{layer:n});const l=o?.serverType;if("FeatureServer"!==l&&"MapServer"!==l)throw new r(`${a}:invalid-parameters`,y(n,`has unsupported server type: ${l}`),{layer:n});if("MapServer"===l&&e.length>1)throw new r(`${a}:invalid-parameters`,"Only one layer or table in a map service can be saved")}const t=m(e[0].parsedUrl.path),o=t?.url.path,s=e.every((e=>{const a=m(e.parsedUrl.path);return a?.url.path===o}));if(!s)throw new r(`${a}:invalid-parameters`,"'layers' array should only contain layers or tables that belong to the same feature service")}async function V(e){_(e,N),await Promise.all(e.map((e=>e.load())));for(const a of e)u(a,N,g);C(e,N),G(e,N)}async function q(e,r){let t=0,o=0;for(const{isTable:a}of r)a?o++:t++;const s=r[0].parsedUrl.path,l=m(s);if(e.url="FeatureServer"===l?.serverType?l.url.path:s,e.title||=l.title,e.extent=null,t>0){const t=r.map((e=>e.fullExtent)).filter(a).reduce(((e,a)=>e.clone().union(a)));t&&(e.extent=await v(t))}I(e,T.METADATA),S(e,T.MULTI_LAYER,r.length>1),S(e,T.SINGLE_LAYER,1===r.length),S(e,T.TABLE,o>0&&0===t),n(e)}async function H(e,a){return o({layer:e,itemType:L,validateLayer:g,createItemData:(e,a)=>O(a,[e]),errorNamePrefix:E},a)}async function Q(e,a){await B(e);const r=e[0].portalItem,o=w(r),l=await Promise.all(e.map((e=>s(e,o,a)))),i=await O(r,e.map(((e,a)=>({layer:e,layerJSON:l[a]}))));return n(r),await r.update({data:i}),await Promise.all(e.slice(1).map((e=>e.portalItem.reload()))),t(o),r.clone()}async function W(e,a,r){return l({layer:e,itemType:L,validateLayer:g,createItemData:(e,a)=>Promise.resolve(j(e)),errorNamePrefix:$,newItem:a,setItemProperties:k},r)}async function X(e,a,r){await V(e);const o=i({itemType:L,errorNamePrefix:N,newItem:a}),n=w(o),l=await Promise.all(e.map((e=>s(e,n,r)))),u=await U(e.map(((e,a)=>({layer:e,layerJSON:l[a]}))));await q(o,e),await c(o,u,r);for(const t of e)t.portalItem=o.clone();return t(n),o}export{H as save,Q as saveAll,X as saveAllAs,W as saveAs};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{fetchArcGISServiceJSON as e}from"../../support/requestPresets.js";async function r(r,s){const a=await e(r,s);a.layers=a.layers.filter(t);const n={serviceJSON:a};if((a.currentVersion??0)<10.5)return n;const y=await e(r+"/layers",s);return n.layersJSON={layers:y.layers.filter(t),tables:y.tables},n}function t(e){return!e.type||"Feature Layer"===e.type||"Oriented Imagery Layer"===e.type}export{r as fetchFeatureService};
5
+ import{fetchArcGISServiceJSON as e}from"../../support/requestPresets.js";async function t(t,r){const a=await e(t,r);y(a),n(a);const s={serviceJSON:a};if((a.currentVersion??0)<10.5)return s;const o=await e(t+"/layers",r);return y(o),n(o),s.layersJSON={layers:o.layers,tables:o.tables},s}function r(e){return"Feature Layer"===e.type||"Oriented Imagery Layer"===e.type}function a(e){return"Table"===e.type}function n(e){e.layers=e.layers?.filter(r),e.tables=e.tables?.filter(a)}function s(e){e.type||="Feature Layer"}function o(e){e.type||="Table"}function y(e){e.layers?.forEach(s),e.tables?.forEach(o)}export{t as fetchFeatureService};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import"../../geometry.js";import e from"../../request.js";import{clone as t}from"../../core/lang.js";import{throwIfAborted as r}from"../../core/promiseUtils.js";import{isProtocolRelative as o,isAbsolute as s,join as l,removeTrailingSlash as n,normalize as i,removeFile as u,getAppBaseUrl as a,addQueryParameters as c}from"../../core/urlUtils.js";import{WGS84 as f,WebMercator as m}from"../../geometry/support/spatialReferenceUtils.js";import{geographicToWebMercator as p}from"../../geometry/support/webMercatorUtils.js";import y from"./TileInfo.js";import d from"../../views/2d/engine/vectorTiles/style/VectorTileSource.js";import x from"../../views/2d/tiling/TileInfoView.js";import S from"../../geometry/SpatialReference.js";async function w(e,t){const r={source:null,sourceBase:null,sourceUrl:null,validatedSource:null,style:null,styleBase:null,styleUrl:null,sourceNameToSource:{},primarySourceName:"",spriteFormat:"png"},[o,s]="string"==typeof e?[e,null]:[null,e.jsonUrl];await j(r,"esri",e,s,t);return{layerDefinition:r.validatedSource,url:o,serviceUrl:r.sourceUrl,style:r.style,styleUrl:r.styleUrl,spriteUrl:r.style.sprite&&h(r.styleBase,r.style.sprite),spriteFormat:r.spriteFormat,glyphsUrl:r.style.glyphs&&h(r.styleBase,r.style.glyphs),sourceNameToSource:r.sourceNameToSource,primarySourceName:r.primarySourceName}}function h(...e){let t;for(const r of e)if(null!=r)if(o(r)){if(t){const e=t.split("://")[0];t=e+":"+r.trim()}}else t=s(r)?r:l(t,r);return t?n(t):void 0}async function j(t,o,s,l,n){let u,a,c;if(r(n),"string"==typeof s){const t=i(s);c=await e(t,{...n,responseType:"json",query:{f:"json",...n?.query}}),c.ssl&&(u&&(u=u.replace(/^http:/i,"https:")),a&&(a=a.replace(/^http:/i,"https:"))),u=t,a=t}else null!=s&&(c={data:s},u=s.jsonUrl||null,a=l);const f=c?.data;if(U(f))return t.styleUrl=u||null,N(t,f,a,n);if(v(f))return t.sourceUrl?I(t,f,a,!1,o,n):(t.sourceUrl=u||null,I(t,f,a,!0,o,n));throw new Error("You must specify the URL or the JSON for a service or for a style.")}function g(e){return"object"==typeof e&&!!e&&"tilejson"in e&&null!=e.tilejson}function U(e){return!!e&&"sources"in e&&!!e.sources}function v(e){return!U(e)}async function N(e,t,r,o){const s=r?u(r):a();e.styleBase=s,e.style=t,t["sprite-format"]&&"webp"===t["sprite-format"].toLowerCase()&&(e.spriteFormat="webp");const l=[];if(t.sources&&t.sources.esri){const r=t.sources.esri;r.url?await j(e,"esri",h(s,r.url),void 0,o):l.push(j(e,"esri",r,s,o))}for(const n of Object.keys(t.sources))"esri"!==n&&"vector"===t.sources[n].type&&(t.sources[n].url?l.push(j(e,n,h(s,t.sources[n].url),void 0,o)):t.sources[n].tiles&&l.push(j(e,n,t.sources[n],s,o)));await Promise.all(l)}async function I(e,t,r,o,s,l){const i=r?n(r)+"/":a(),u=T(t),f=new d(s,c(i,l?.query??{}),u);if(!o&&e.primarySourceName in e.sourceNameToSource){const t=e.sourceNameToSource[e.primarySourceName];if(!t.isCompatibleWith(f))return;null!=f.fullExtent&&(null!=t.fullExtent?t.fullExtent.union(f.fullExtent):t.fullExtent=f.fullExtent.clone()),t.tileInfo&&f.tileInfo&&t.tileInfo.lods.length<f.tileInfo.lods.length&&(t.tileInfo=f.tileInfo)}if(o&&(e.sourceBase=i,e.source=t,e.validatedSource=u,e.primarySourceName=s),e.sourceNameToSource[s]=f,!g(e)&&"defaultStyles"in t&&!e.style){if(null==t.defaultStyles)throw new Error;return"string"==typeof t.defaultStyles?j(e,"",h(i,t.defaultStyles,"root.json"),void 0,l):j(e,"",t.defaultStyles,h(i,"root.json"),l)}}function T(e){if(e.hasOwnProperty("tileInfo"))return e;const r={xmin:-20037507.067161843,ymin:-20037507.067161843,xmax:20037507.067161843,ymax:20037507.067161843,spatialReference:{wkid:102100,latestWkid:3857}};let o=null;if(g(e)){const{bounds:r}=e;if(r){const e=p({x:r[0],y:r[1],spatialReference:t(f)}),s=p({x:r[2],y:r[3],spatialReference:t(f)});o={xmin:e.x,ymin:e.y,xmax:s.x,ymax:s.y,spatialReference:t(m)}}}null===o&&(o=r);const s=new x(y.create({spatialReference:S.WebMercator,size:512,numLODs:25})),l=512;let n=78271.51696400007,i=295828763.7957775;const u=[],a=e.hasOwnProperty("minzoom")&&null!=e.minzoom,c=e.hasOwnProperty("maxzoom")&&null!=e.maxzoom,d=a?+e.minzoom:0,w=c?+e.maxzoom:22;let h=0;a&&d>0&&d<25&&(h=s.getLODInfoAt(d).scale);let j=0;c&&w>0&&w<25&&(j=s.getLODInfoAt(w).scale);for(let t=0;t<=w;t++)u.push({level:t,scale:i,resolution:n}),n/=2,i/=2;return{capabilities:"TilesOnly",initialExtent:o,fullExtent:r,minScale:h,maxScale:j,tiles:e.tiles,tileInfo:{rows:l,cols:l,dpi:96,format:"pbf",origin:{x:-20037508.342787,y:20037508.342787},lods:u,spatialReference:t(m)}}}export{w as loadMetadata};
5
+ import e from"../../request.js";import{clone as t}from"../../core/lang.js";import{throwIfAborted as r}from"../../core/promiseUtils.js";import{isProtocolRelative as s,isAbsolute as o,join as l,removeTrailingSlash as n,normalize as i,removeFile as u,getAppBaseUrl as a,addQueryParameters as c}from"../../core/urlUtils.js";import{WGS84 as f,WebMercator as p}from"../../geometry/support/spatialReferenceUtils.js";import{geographicToWebMercator as y}from"../../geometry/support/webMercatorUtils.js";import m from"../../views/2d/engine/vectorTiles/style/VectorTileSource.js";async function x(e,t){const r={source:null,sourceBase:null,sourceUrl:null,validatedSource:null,style:null,styleBase:null,styleUrl:null,sourceNameToSource:{},primarySourceName:"",spriteFormat:"png"},[s,o]="string"==typeof e?[e,null]:[null,e.jsonUrl];await S(r,"esri",e,o,t);return{layerDefinition:r.validatedSource,url:s,serviceUrl:r.sourceUrl,style:r.style,styleUrl:r.styleUrl,spriteUrl:r.style.sprite&&d(r.styleBase,r.style.sprite),spriteFormat:r.spriteFormat,glyphsUrl:r.style.glyphs&&d(r.styleBase,r.style.glyphs),sourceNameToSource:r.sourceNameToSource,primarySourceName:r.primarySourceName}}function d(...e){let t;for(const r of e)if(null!=r)if(s(r)){if(t){const e=t.split("://")[0];t=e+":"+r.trim()}}else t=o(r)?r:l(t,r);return t?n(t):void 0}async function S(t,s,o,l,n){let u,a,c;if(r(n),"string"==typeof o){const t=i(o);c=await e(t,{...n,responseType:"json",query:{f:"json",...n?.query}}),c.ssl&&(u&&(u=u.replace(/^http:/i,"https:")),a&&(a=a.replace(/^http:/i,"https:"))),u=t,a=t}else null!=o&&(c={data:o},u=o.jsonUrl||null,a=l);const f=c?.data;if(w(f))return t.styleUrl=u||null,j(t,f,a,n);if(U(f))return t.sourceUrl?g(t,f,a,!1,s,n):(t.sourceUrl=u||null,g(t,f,a,!0,s,n));throw new Error("You must specify the URL or the JSON for a service or for a style.")}function h(e){return"object"==typeof e&&!!e&&"tilejson"in e&&null!=e.tilejson}function w(e){return!!e&&"sources"in e&&!!e.sources}function U(e){return!w(e)}async function j(e,t,r,s){const o=r?u(r):a();e.styleBase=o,e.style=t,t["sprite-format"]&&"webp"===t["sprite-format"].toLowerCase()&&(e.spriteFormat="webp");const l=[];if(t.sources&&t.sources.esri){const r=t.sources.esri;r.url?await S(e,"esri",d(o,r.url),void 0,s):l.push(S(e,"esri",r,o,s))}for(const n of Object.keys(t.sources))"esri"!==n&&"vector"===t.sources[n].type&&(t.sources[n].url?l.push(S(e,n,d(o,t.sources[n].url),void 0,s)):t.sources[n].tiles&&l.push(S(e,n,t.sources[n],o,s)));await Promise.all(l)}async function g(e,t,r,s,o,l){const i=r?n(r)+"/":a(),u=v(t),f=new m(o,c(i,l?.query??{}),u);if(!s&&e.primarySourceName in e.sourceNameToSource){const t=e.sourceNameToSource[e.primarySourceName];if(!t.isCompatibleWith(f))return;null!=f.fullExtent&&(null!=t.fullExtent?t.fullExtent.union(f.fullExtent):t.fullExtent=f.fullExtent.clone()),t.tileInfo&&f.tileInfo&&t.tileInfo.lods.length<f.tileInfo.lods.length&&(t.tileInfo=f.tileInfo)}if(s&&(e.sourceBase=i,e.source=t,e.validatedSource=u,e.primarySourceName=o),e.sourceNameToSource[o]=f,!h(e)&&"defaultStyles"in t&&!e.style){if(null==t.defaultStyles)throw new Error;return"string"==typeof t.defaultStyles?S(e,"",d(i,t.defaultStyles,"root.json"),void 0,l):S(e,"",t.defaultStyles,d(i,"root.json"),l)}}function v(e){if(e.hasOwnProperty("tileInfo"))return e;const r={xmin:-20037507.067161843,ymin:-20037507.067161843,xmax:20037507.067161843,ymax:20037507.067161843,spatialReference:{wkid:102100,latestWkid:3857}};let s=null;if(h(e)){const{bounds:r}=e;if(r){const e=y({x:r[0],y:r[1],spatialReference:t(f)}),o=y({x:r[2],y:r[3],spatialReference:t(f)});s={xmin:e.x,ymin:e.y,xmax:o.x,ymax:o.y,spatialReference:t(p)}}}null===s&&(s=r);const o=512;let l=78271.51696400007,n=295828763.7957775;const i=[],u=e.hasOwnProperty("maxzoom")&&null!=e.maxzoom?+e.maxzoom:22,a=0,c=0;for(let t=0;t<=u;t++)i.push({level:t,scale:n,resolution:l}),l/=2,n/=2;return{capabilities:"TilesOnly",initialExtent:s,fullExtent:r,minScale:a,maxScale:c,tiles:e.tiles,tileInfo:{rows:o,cols:o,dpi:96,format:"pbf",origin:{x:-20037508.342787,y:20037508.342787},lods:i,spatialReference:t(p)}}}export{x as loadMetadata};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/core",
3
- "version": "4.28.3",
3
+ "version": "4.28.5",
4
4
  "homepage": "https://js.arcgis.com",
5
5
  "description": "ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API",
6
6
  "keywords": [
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- const c="20231027",e="4365eabcb865212b826cc225af940caae85e3e7d";export{c as buildDate,e as commitHash};
5
+ const a="20231031",f="9d4739f17349f6b91528389e902a79a440af3b57";export{a as buildDate,f 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.28/esri/copyright.txt for details.
4
4
  */
5
- import"../../../../core/has.js";import{disposeMaybe as e}from"../../../../core/maybe.js";import{brushes as t}from"../brushes.js";import s from"../vectorTiles/shaders/VTLMaterialManager.js";import{BitBlitRenderer as r}from"./BitBlitRenderer.js";import{WGLDrawPhase as i,WGLGeometryType as n,WGLSymbologyType as o}from"./enums.js";import a from"./MaterialManager.js";import f from"./TextureManager.js";import{TextureUploadManager as h}from"./TextureUploadManager.js";import{WorldExtentRenderer as l}from"./WorldExtentClipRenderer.js";import{AnimationEffect as c}from"./effects/AnimationEffect.js";import{BlendEffect as d}from"./effects/BlendEffect.js";import{FeatureEffect as u}from"./effects/FeatureEffect.js";import _ from"./effects/HighlightEffect.js";import{HittestEffect as b}from"./effects/HittestEffect.js";import{HittestEffectVTL as p}from"./effects/HittestEffectVTL.js";import{EffectManager as E}from"./effects/post-processing/EffectManager.js";import g from"./painter/RenderPass.js";import{ContextType as m}from"../../../webgl/contextUtils.js";import{TextureSamplingMode as w,TextureWrapMode as M,CompareFunction as B,BlendFactor as F,RenderbufferFormat as T}from"../../../webgl/enums.js";import{FramebufferObject as C}from"../../../webgl/FramebufferObject.js";import{Renderbuffer as R}from"../../../webgl/Renderbuffer.js";import{RenderbufferDescriptor as P}from"../../../webgl/RenderbufferDescriptor.js";import{TextureDescriptor as O}from"../../../webgl/TextureDescriptor.js";function j(e,s){switch(e){case n.LINE:return t.line;case n.TEXT:return t.text;case n.LABEL:return t.label;case n.FILL:return s===o.DOT_DENSITY?t.dotDensity:t.fill;case n.MARKER:switch(s){case o.HEATMAP:return t.heatmap;case o.PIE_CHART:return t.pieChart;default:return t.marker}}}class x{constructor(e,t,i){this.context=e,this._blitRenderer=new r,this._worldExtentRenderer=new l,this._brushCache=new Map,this._lastWidth=null,this._lastHeight=null,this._vtlMaterialManager=new s,this._blendEffect=new d,this._stencilBuf=null,this._prevBeforeLayerFBOStack=[],this._fboPool=[],this.effects={highlight:new _,hittest:new b,hittestVTL:new p,integrate:new c,insideEffect:new u("inside"),outsideEffect:new u("outside")},this.materialManager=new a(e),this.textureManager=new f(t,i,e.type===m.WEBGL2),this.textureUploadManager=new h(e,t),this._effectsManager=new E}dispose(){if(this.materialManager.dispose(),this.textureManager.dispose(),this.textureUploadManager.destroy(),this._blitRenderer=e(this._blitRenderer),this._worldExtentRenderer=e(this._worldExtentRenderer),this._brushCache&&(this._brushCache.forEach((e=>e.dispose())),this._brushCache.clear(),this._brushCache=null),this._fbos){let e;for(e in this._fbos)this._fbos[e]&&this._fbos[e].dispose()}for(const e of this._fboPool)e.dispose();if(this._fboPool.length=0,this.effects){let e;for(e in this.effects)this.effects[e]&&this.effects[e].dispose()}this._effectsManager.dispose(),this._blendEffect.dispose(this.context),this._vtlMaterialManager=e(this._vtlMaterialManager)}get blitRenderer(){return this._blitRenderer}get vectorTilesMaterialManager(){return this._vtlMaterialManager}getFbos(){if(!this._fbos)throw new Error("InternalError: Painter FBOs not initialized");return this._fbos}acquireFbo(e,t){let s;if(this._fboPool.length>0)s=this._fboPool.pop();else{const r=new O(e,t);r.samplingMode=w.NEAREST,r.wrapMode=M.CLAMP_TO_EDGE,s=new C(this.context,r,this._stencilBuf)}return s.width===e&&s.height===t||s.resize(e,t),s}releaseFbo(e){this._fboPool.push(e)}getSharedStencilBuffer(){return this._stencilBuf}beforeRenderPhases(e,t,s){const{context:r}=e;this._worldExtentRenderer.render(e,t,s);const{width:i,height:n}=r.getViewport();if(this.updateFBOs(i,n),this._prevFBO=r.getBoundFramebufferObject(),r.bindFramebuffer(this.getFbos().output),r.setColorMask(!0,!0,!0,!0),null!=t){const{r:e,g:s,b:i,a:n}=t;r.setClearColor(n*e/255,n*s/255,n*i/255,n)}else r.setClearColor(0,0,0,0);r.setDepthWriteEnabled(!0),r.setClearDepth(1),r.clear(r.gl.COLOR_BUFFER_BIT|r.gl.DEPTH_BUFFER_BIT),r.setDepthWriteEnabled(!1)}afterRenderPhases(e){const{context:t}=e;t.bindFramebuffer(this._prevFBO),t.setStencilFunction(B.EQUAL,1,255),t.setStencilTestEnabled(!0),t.setDepthTestEnabled(!1),this.blitTexture(t,this.getFbos().output.colorTexture,w.NEAREST)}beforeRenderLayer(e,t,s){const{context:r,blendMode:i,effects:n,drawPhase:o,requireFBO:a}=e;if(a||S(o,i,n,s)){const e=r.getBoundFramebufferObject();this._prevBeforeLayerFBOStack.push(e);const{width:t,height:s}=r.getViewport(),i=this.acquireFbo(t,s);r.bindFramebuffer(i),r.setColorMask(!0,!0,!0,!0),r.setClearColor(0,0,0,0),r.setDepthWriteEnabled(!0),r.setClearDepth(1),r.clear(r.gl.COLOR_BUFFER_BIT|r.gl.DEPTH_BUFFER_BIT),r.setDepthWriteEnabled(!1)}r.setDepthWriteEnabled(!1),r.setDepthTestEnabled(!1),r.setStencilTestEnabled(!0),r.setClearStencil(t),r.setStencilWriteMask(255),r.clear(r.gl.STENCIL_BUFFER_BIT)}afterRenderLayer(e,t){const{context:s,blendMode:r,effects:n,requireFBO:o,drawPhase:a}=e;if(o||S(a,r,n,t)){const o=s.getBoundFramebufferObject();null!=n&&n.length>0&&a===i.MAP&&this._applyEffects(e,n,o),s.bindFramebuffer(this._prevBeforeLayerFBOStack.pop()),s.setStencilTestEnabled(!1),s.setStencilWriteMask(0),s.setBlendingEnabled(!0),s.setBlendFunctionSeparate(F.ONE,F.ONE_MINUS_SRC_ALPHA,F.ONE,F.ONE_MINUS_SRC_ALPHA),s.setColorMask(!0,!0,!0,!0);const f=null==r||a===i.HIGHLIGHT?"normal":r;this._blendEffect.draw(e,o.colorTexture,w.NEAREST,f,t),this.releaseFbo(o)}}getBrush(e,t){const s=j(e,t);let r=this._brushCache.get(s);return void 0===r&&(r=new s,this._brushCache.set(s,r)),r}renderObject(e,s,r,i){const n=t[r];if(!n)return;let o=this._brushCache.get(n);void 0===o&&(o=new n,this._brushCache.set(n,o)),o.prepareState(e,i),o.draw(e,s,i)}renderObjects(e,s,r,i){const n=t[r];if(!n)return;let o=this._brushCache.get(n);void 0===o&&(o=new n,this._brushCache.set(n,o)),o.drawMany(e,s,i)}registerRenderPass(e){const t=e.brushes.map((e=>(this._brushCache.has(e)||this._brushCache.set(e,new e),this._brushCache.get(e))));return new g(t,e)}blitTexture(e,t,s,r=1){e.setBlendingEnabled(!0),e.setBlendFunctionSeparate(F.ONE,F.ONE_MINUS_SRC_ALPHA,F.ONE,F.ONE_MINUS_SRC_ALPHA),e.setColorMask(!0,!0,!0,!0),this._blitRenderer.render(e,t,s,r)}getPostProcessingEffects(e){return this._effectsManager.getPostProcessingEffects(e)}updateFBOs(e,t){if(e!==this._lastWidth||t!==this._lastHeight){if(this._lastWidth=e,this._lastHeight=t,this._fbos){let s;for(s in this._fbos)this._fbos[s].resize(e,t);return}const s=new O(e,t);s.samplingMode=w.NEAREST,s.wrapMode=M.CLAMP_TO_EDGE;const r=new P(T.DEPTH_STENCIL,e,t);this._stencilBuf=new R(this.context,r),this._fbos={output:new C(this.context,s,this._stencilBuf),effect0:new C(this.context,s,this._stencilBuf)}}}_applyEffects(e,t,s){const{context:r}=e,i=this._effectsManager.getPostProcessingEffects(t);for(const{postProcessingEffect:n,effect:o}of i)r.bindFramebuffer(s),n.draw(e,s,o)}}function S(e,t,s,r){return e!==i.HIGHLIGHT&&(1!==r||null!=t&&"normal"!==t||null!=s&&s.length>0)}export{x as default};
5
+ import"../../../../core/has.js";import{disposeMaybe as e}from"../../../../core/maybe.js";import{brushes as t}from"../brushes.js";import s from"../vectorTiles/shaders/VTLMaterialManager.js";import{BitBlitRenderer as r}from"./BitBlitRenderer.js";import{WGLDrawPhase as i,WGLGeometryType as n,WGLSymbologyType as o}from"./enums.js";import a from"./MaterialManager.js";import f from"./TextureManager.js";import{TextureUploadManager as h}from"./TextureUploadManager.js";import{WorldExtentRenderer as l}from"./WorldExtentClipRenderer.js";import{AnimationEffect as c}from"./effects/AnimationEffect.js";import{BlendEffect as d}from"./effects/BlendEffect.js";import{FeatureEffect as u}from"./effects/FeatureEffect.js";import _ from"./effects/HighlightEffect.js";import{HittestEffect as b}from"./effects/HittestEffect.js";import{HittestEffectVTL as p}from"./effects/HittestEffectVTL.js";import{EffectManager as E}from"./effects/post-processing/EffectManager.js";import g from"./painter/RenderPass.js";import{ContextType as m}from"../../../webgl/contextUtils.js";import{TextureSamplingMode as w,TextureWrapMode as M,CompareFunction as B,BlendFactor as F,RenderbufferFormat as T}from"../../../webgl/enums.js";import{FramebufferObject as C}from"../../../webgl/FramebufferObject.js";import{Renderbuffer as R}from"../../../webgl/Renderbuffer.js";import{RenderbufferDescriptor as P}from"../../../webgl/RenderbufferDescriptor.js";import{TextureDescriptor as L}from"../../../webgl/TextureDescriptor.js";function O(e,s){switch(e){case n.LINE:return t.line;case n.TEXT:return t.text;case n.LABEL:return t.label;case n.FILL:return s===o.DOT_DENSITY?t.dotDensity:t.fill;case n.MARKER:switch(s){case o.HEATMAP:return t.heatmap;case o.PIE_CHART:return t.pieChart;default:return t.marker}}}class j{constructor(e,t,i){this.context=e,this._blitRenderer=new r,this._worldExtentRenderer=new l,this._brushCache=new Map,this._lastWidth=null,this._lastHeight=null,this._vtlMaterialManager=new s,this._blendEffect=new d,this._stencilBuf=null,this._prevBeforeLayerFBOStack=[],this._fboPool=[],this.effects={highlight:new _,hittest:new b,hittestVTL:new p,integrate:new c,insideEffect:new u("inside"),outsideEffect:new u("outside")},this.materialManager=new a(e),this.textureManager=new f(t,i,e.type===m.WEBGL2),this.textureUploadManager=new h(e,t),this._effectsManager=new E}dispose(){if(this.materialManager.dispose(),this.textureManager.dispose(),this.textureUploadManager.destroy(),this._blitRenderer=e(this._blitRenderer),this._worldExtentRenderer=e(this._worldExtentRenderer),this._brushCache&&(this._brushCache.forEach((e=>e.dispose())),this._brushCache.clear(),this._brushCache=null),this._fbos){let e;for(e in this._fbos)this._fbos[e]&&this._fbos[e].dispose()}for(const e of this._fboPool)e.dispose();if(this._fboPool.length=0,this.effects){let e;for(e in this.effects)this.effects[e]&&this.effects[e].dispose()}this._effectsManager.dispose(),this._blendEffect.dispose(this.context),this._vtlMaterialManager=e(this._vtlMaterialManager)}get blitRenderer(){return this._blitRenderer}get vectorTilesMaterialManager(){return this._vtlMaterialManager}getFbos(){if(!this._fbos)throw new Error("InternalError: Painter FBOs not initialized");return this._fbos}acquireFbo(e,t){let s;if(this._fboPool.length>0)s=this._fboPool.pop();else{const r=new L(e,t);r.samplingMode=w.NEAREST,r.wrapMode=M.CLAMP_TO_EDGE,s=new C(this.context,r,this._stencilBuf)}return s.width===e&&s.height===t||s.resize(e,t),s}releaseFbo(e){this._fboPool.push(e)}getSharedStencilBuffer(){return this._stencilBuf}beforeRenderPhases(e,t,s){const{context:r}=e;this._worldExtentRenderer.render(e,t,s);const{width:i,height:n}=r.getViewport();if(this.updateFBOs(i,n),this._prevFBO=r.getBoundFramebufferObject(),r.bindFramebuffer(this.getFbos().output),r.setColorMask(!0,!0,!0,!0),null!=t){const{r:e,g:s,b:i,a:n}=t;r.setClearColor(n*e/255,n*s/255,n*i/255,n)}else r.setClearColor(0,0,0,0);r.setDepthWriteEnabled(!0),r.setClearDepth(1),r.clear(r.gl.COLOR_BUFFER_BIT|r.gl.DEPTH_BUFFER_BIT),r.setDepthWriteEnabled(!1)}afterRenderPhases(e){const{context:t}=e;t.bindFramebuffer(this._prevFBO),t.setStencilFunction(B.EQUAL,1,255),t.setStencilTestEnabled(!0),t.setDepthTestEnabled(!1),this.blitTexture(t,this.getFbos().output.colorTexture,w.NEAREST)}beforeRenderLayer(e,t,s){const{context:r,blendMode:i,effects:n,drawPhase:o,requireFBO:a}=e;if(a||x(o,i,n,s)){const e=r.getBoundFramebufferObject();this._prevBeforeLayerFBOStack.push(e);const{width:t,height:s}=r.getViewport(),i=this.acquireFbo(t,s);r.bindFramebuffer(i),r.setColorMask(!0,!0,!0,!0),r.setClearColor(0,0,0,0),r.setDepthWriteEnabled(!0),r.setClearDepth(1),r.clear(r.gl.COLOR_BUFFER_BIT|r.gl.DEPTH_BUFFER_BIT),r.setDepthWriteEnabled(!1)}r.setDepthWriteEnabled(!1),r.setDepthTestEnabled(!1),r.setStencilTestEnabled(!0),r.setClearStencil(t),r.setStencilWriteMask(255),r.clear(r.gl.STENCIL_BUFFER_BIT)}afterRenderLayer(e,t){const{context:s,blendMode:r,effects:n,requireFBO:o,drawPhase:a}=e;if(o||x(a,r,n,t)){const o=s.getBoundFramebufferObject();null!=n&&n.length>0&&a===i.MAP&&this._applyEffects(e,n,o),s.bindFramebuffer(this._prevBeforeLayerFBOStack.pop()),s.setStencilTestEnabled(!1),s.setStencilWriteMask(0),s.setBlendingEnabled(!0),s.setBlendFunctionSeparate(F.ONE,F.ONE_MINUS_SRC_ALPHA,F.ONE,F.ONE_MINUS_SRC_ALPHA),s.setColorMask(!0,!0,!0,!0);const f=null==r||a===i.HIGHLIGHT?"normal":r;this._blendEffect.draw(e,o.colorTexture,w.NEAREST,f,t),this.releaseFbo(o)}}getBrush(e,t){const s=O(e,t);let r=this._brushCache.get(s);return void 0===r&&(r=new s,this._brushCache.set(s,r)),r}renderObject(e,s,r,i){const n=t[r];if(!n)return;let o=this._brushCache.get(n);void 0===o&&(o=new n,this._brushCache.set(n,o)),o.prepareState(e,i),o.draw(e,s,i)}renderObjects(e,s,r,i){const n=t[r];if(!n)return;let o=this._brushCache.get(n);void 0===o&&(o=new n,this._brushCache.set(n,o)),o.drawMany(e,s,i)}registerRenderPass(e){const t=e.brushes.map((e=>(this._brushCache.has(e)||this._brushCache.set(e,new e),this._brushCache.get(e))));return new g(t,e)}blitTexture(e,t,s,r=1){e.setBlendingEnabled(!0),e.setBlendFunctionSeparate(F.ONE,F.ONE_MINUS_SRC_ALPHA,F.ONE,F.ONE_MINUS_SRC_ALPHA),e.setColorMask(!0,!0,!0,!0),this._blitRenderer.render(e,t,s,r)}getPostProcessingEffects(e){return this._effectsManager.getPostProcessingEffects(e)}updateFBOs(e,t){if(e!==this._lastWidth||t!==this._lastHeight){if(this._lastWidth=e,this._lastHeight=t,this._fbos){let s;for(s in this._fbos)this._fbos[s].resize(e,t);return}const s=new L(e,t);s.samplingMode=w.NEAREST,s.wrapMode=M.CLAMP_TO_EDGE;const r=new P(T.DEPTH_STENCIL,e,t);this._stencilBuf=new R(this.context,r),this._fbos={output:new C(this.context,s,this._stencilBuf),effect0:new C(this.context,s,this._stencilBuf)}}}_applyEffects(e,t,s){const{context:r}=e,i=this._effectsManager.getPostProcessingEffects(t);for(const{postProcessingEffect:n,effect:o}of i)r.bindFramebuffer(s),n.draw(e,s,o)}}function x(e,t,s,r){return e!==i.LABEL_ALPHA&&e!==i.LABEL&&e!==i.HIGHLIGHT&&(1!==r||null!=t&&"normal"!==t||null!=s&&s.length>0)}export{j 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.28/esri/copyright.txt for details.
4
4
  */
5
- import{isSome as e}from"../../../../../core/arrayUtils.js";import s from"../../../../../core/CircularArray.js";import has from"../../../../../core/has.js";import{createResolver as t}from"../../../../../core/promiseUtils.js";import{FeatureSetReaderJSON as r}from"../support/FeatureSetReaderJSON.js";import{UpdateToken as i}from"../support/UpdateToken.js";class o{constructor(e,r){this.requests={done:new Array,stream:new s(10)},this._edits=null,this._abortController=new AbortController,this._version=0,this._resolver=t(),this._isDone=!1,this.didSend=!1,this.tile=e,this._version=r}get signal(){return this._abortController.signal}get options(){return{signal:this._abortController.signal}}get empty(){return!this.requests.done.length&&null==this.edits}get edits(){return this._edits}get done(){return this._resolver.promise}get isDone(){return this._isDone}resolve(){this._isDone=!0,this._resolver.resolve()}clear(){this.requests.done=[]}applyUpdate(e){this.requests.done.forEach((s=>s.message.status.unset(e))),this._version=e.version,null!=this._edits&&this._edits.status.unset(e)}add(e){e.message.status=e.message.status??i.empty(),e.message.status.version=this._version,has("esri-2d-update-debug")&&console.debug(this.tile.id,"DataTileSubscription:add",this._version),e.message.end&&(this.requests.done.forEach((e=>{null!=e.message&&e.message.end&&(e.message.end=!1)})),this._resolver.resolve(),this._isDone=!0),this.requests.done.push(e)}edit(s,t){const o=s.getQuantizationTransform(),d=s.fullSchema(),a=Array.from(s.features()).filter(e),n=[...t,...a.map((e=>e.objectId))];if(this.removeIds(n),this._invalidate(),null==this._edits)return void(this._edits={type:"append",addOrUpdate:r.fromOptimizedFeatures(a,d,o),id:this.tile.id,status:i.empty(),end:!0});this.requests.done.forEach((e=>e.message.end=!1));this._edits.addOrUpdate.append(s.features())}*readers(){for(const{message:e}of this.requests.done)null!=e.addOrUpdate&&(yield e.addOrUpdate);null!=this._edits?.addOrUpdate&&(yield this._edits.addOrUpdate)}_invalidate(){for(const e of this.requests.done)e.message.status=i.empty();null!=this._edits&&(this._edits.status=i.empty())}removeIds(e){this._invalidate();for(const{message:s}of this.requests.done){const t=s.addOrUpdate;null!=t&&(t.removeIds(e),t.isEmpty&&(has("esri-2d-update-debug")&&console.debug("Removing FeatureSetReader"),s.addOrUpdate=null))}null!=this._edits?.addOrUpdate&&this._edits.addOrUpdate.removeIds(e),this.requests.done=this.requests.done.filter((e=>e.message.addOrUpdate||e.message.end))}abort(){this._abortController.abort(),this._resolver.reject()}}export{o as DataTileSubscription};
5
+ import{isSome as e}from"../../../../../core/arrayUtils.js";import s from"../../../../../core/CircularArray.js";import has from"../../../../../core/has.js";import{createResolver as t,throwIfNotAbortError as r,createAbortError as i}from"../../../../../core/promiseUtils.js";import{FeatureSetReaderJSON as o}from"../support/FeatureSetReaderJSON.js";import{UpdateToken as d}from"../support/UpdateToken.js";class a{constructor(e,i){this.requests={done:new Array,stream:new s(10)},this._edits=null,this._abortController=new AbortController,this._version=0,this._isDone=!1,this.didSend=!1,this.tile=e,this._version=i,this._resolver=t(),this._resolver.promise.catch((e=>r(e)))}get signal(){return this._abortController.signal}get options(){return{signal:this._abortController.signal}}get empty(){return!this.requests.done.length&&null==this.edits}get edits(){return this._edits}get done(){return this._resolver.promise}get isDone(){return this._isDone}resolve(){this._isDone=!0,this._resolver.resolve()}clear(){this.requests.done=[]}applyUpdate(e){this.requests.done.forEach((s=>s.message.status.unset(e))),this._version=e.version,null!=this._edits&&this._edits.status.unset(e)}add(e){e.message.status=e.message.status??d.empty(),e.message.status.version=this._version,has("esri-2d-update-debug")&&console.debug(this.tile.id,"DataTileSubscription:add",this._version),e.message.end&&(this.requests.done.forEach((e=>{null!=e.message&&e.message.end&&(e.message.end=!1)})),this._resolver.resolve(),this._isDone=!0),this.requests.done.push(e)}edit(s,t){const r=s.getQuantizationTransform(),i=s.fullSchema(),a=Array.from(s.features()).filter(e),n=[...t,...a.map((e=>e.objectId))];if(this.removeIds(n),this._invalidate(),null==this._edits)return void(this._edits={type:"append",addOrUpdate:o.fromOptimizedFeatures(a,i,r),id:this.tile.id,status:d.empty(),end:!0});this.requests.done.forEach((e=>e.message.end=!1));this._edits.addOrUpdate.append(s.features())}*readers(){for(const{message:e}of this.requests.done)null!=e.addOrUpdate&&(yield e.addOrUpdate);null!=this._edits?.addOrUpdate&&(yield this._edits.addOrUpdate)}_invalidate(){for(const e of this.requests.done)e.message.status=d.empty();null!=this._edits&&(this._edits.status=d.empty())}removeIds(e){this._invalidate();for(const{message:s}of this.requests.done){const t=s.addOrUpdate;null!=t&&(t.removeIds(e),t.isEmpty&&(has("esri-2d-update-debug")&&console.debug("Removing FeatureSetReader"),s.addOrUpdate=null))}null!=this._edits?.addOrUpdate&&this._edits.addOrUpdate.removeIds(e),this.requests.done=this.requests.done.filter((e=>e.message.addOrUpdate||e.message.end))}abort(){this._abortController.abort(),this._resolver.reject(i())}}export{a as DataTileSubscription};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import"../../../../geometry.js";import{throwIfAborted as e}from"../../../../core/promiseUtils.js";import{makeDehydratedPoint as o}from"../../../../layers/graphics/dehydratedPoint.js";import{getGeometryEffectiveElevationInfo as t}from"../../../../support/elevationInfoUtils.js";import{evaluateElevationInfoAtPoint as r,SampleElevationInfo as n}from"./elevationAlignmentUtils.js";import{ElevationContext as s}from"./ElevationContext.js";import{extractExpressionInfo as i,createContext as a}from"./featureExpressionInfoUtils.js";import p from"../../../../geometry/SpatialReference.js";async function f(o,n,s,f,d){const{elevationProvider:j,renderCoordsHelper:u}=o,{elevationInfo:I}=n,{pointsInFeatures:v,spatialReference:y}=f,g=p.fromJSON(y),x=i(I,!0),h=await a(x,g,d);e(d);const w=[],S=new Set,z=new Set;c.spatialReference=g;for(const{objectId:e,points:i}of v){const o=s(e);if(null==o){for(const e of i)w.push(e.z??0);S.add(e);continue}o.isDraped&&z.add(e);const a=o.graphic.geometry;m.setFromElevationInfo(t(a,I)),m.updateFeatureExpressionInfoContext(h,o.graphic,n);for(const{x:e,y:t,z:n}of i)c.x=e,c.y=t,c.z=n??0,r(c,j,m,u,l),w.push(l.z)}return{elevations:w,drapedObjectIds:z,failedObjectIds:S}}const m=new s,c=o(0,0,0,p.WGS84),l=new n;export{f as elevationAlignPointsInFeatures};
5
+ import"../../../../geometry.js";import{throwIfAborted as e}from"../../../../core/promiseUtils.js";import{projectPointToVectorWithEngine as o}from"../../../../geometry/projection/projectPointToVectorWithEngine.js";import{makeDehydratedPoint as t}from"../../../../layers/graphics/dehydratedPoint.js";import{getGeometryEffectiveElevationInfo as r}from"../../../../support/elevationInfoUtils.js";import{evaluateElevationInfoAtPoint as n,SampleElevationInfo as i}from"./elevationAlignmentUtils.js";import{ElevationContext as s}from"./ElevationContext.js";import{extractExpressionInfo as a,createContext as p}from"./featureExpressionInfoUtils.js";import f from"../../../../geometry/SpatialReference.js";async function c(t,i,s,c,u){const{elevationProvider:g,renderCoordsHelper:v}=t,{elevationInfo:y}=i,{pointsInFeatures:I,spatialReference:h}=c,x=f.fromJSON(h),w=a(y,!0),E=await p(w,x,u);e(u);const R=[],S=new Set,z=new Set;l.spatialReference=x;const P=t.elevationProvider.spatialReference??t.spatialReference;for(const{objectId:e,points:a}of I){const t=s(e);if(null==t){for(const e of a)R.push(e.z??0);S.add(e);continue}t.isDraped&&z.add(e);const p=t.graphic.geometry;m.setFromElevationInfo(r(p,y)),m.updateFeatureExpressionInfoContext(E,t.graphic,i);for(const{x:e,y:r,z:i}of a)l.x=e,l.y=r,l.z=i??0,await o(l,j,P,0,{signal:u}),n(j,g,m,v,d),R.push(d.z)}return{elevations:R,drapedObjectIds:z,failedObjectIds:S}}const m=new s,l=t(0,0,0,f.WGS84),d=new i,j=[0,0,0];export{c as elevationAlignPointsInFeatures};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import{createTask as p}from"../core/asyncUtils.js";import{deprecated as t}from"../core/deprecate.js";import i from"../core/Error.js";import s from"../core/Logger.js";import{eachAlwaysValues as o,throwIfAborted as r}from"../core/promiseUtils.js";import{watch as a,initial as n,whenOnce as u}from"../core/reactiveUtils.js";import{property as l}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as c}from"../core/accessorSupport/decorators/subclass.js";import{ViewEventPriorities as h}from"./input/InputManager.js";function d(e){return null!=e&&"open"in e&&"declaredClass"in e}function y(e){return null!=e&&"declaredClass"in e&&"dockOptions"in e}const w=w=>{let m=class extends w{constructor(){super(...arguments),this._popupSetupTask=null,this.popup={},this.popupEnabled=!0}initialize(){this.addHandles([a((()=>[this.ui,this.popup]),(([e,p],t)=>{const i="popup",s="manual";if(t){const[e,p]=t;e&&d(p)&&(p.view=null,y(p)&&e.remove(p,i))}e&&d(p)&&(p.view=this,y(p)&&e.add(p,{key:i,position:s,internal:!0}))}),n),this.on("click",(e=>{this.popup&&this.popupEnabled&&("mouse"!==e.pointerType||0===e.button)&&(!d(this.popup)&&"autoOpenEnabled"in this.popup&&!1===this.popup.autoOpenEnabled||(d(this.popup)?this.popup.viewModel.handleViewClick(e):e.async((async()=>{await this.setupPopup(),d(this.popup)&&!this.destroyed&&this.ready&&this.popupEnabled&&this.popup.viewModel.handleViewClick(e)}))))}),h.WIDGET)]),u((()=>this.ready&&this.popupEnabled&&!this.updating)).then((()=>{import("../widgets/Popup.js")}))}destroy(){this.destroyed||this.closePopup()}async openPopup(e){d(this.popup)&&this.popup.open(e);try{if(await this.setupPopup(),!this.popup)return void s.getLogger(this).error(new i("view:null-popup","Popup is null and can't be opened"));this.popup.open(e)}catch{}}closePopup(){this._popupSetupTask?.abort(),d(this.popup)&&this.popup.close()}async fetchPopupFeatures(e,p){await this.when();const{location:t,queryArea:i,layerViewsAndGraphics:s,clientOnlyGraphics:r}=await this._prepareFetchPopupFeatures(e,p),a=Promise.resolve(r),n=this._queryLayerPopupFeatures(i,s,p),u=n.map((e=>e.promise));return{location:t,clientOnlyGraphics:r,allGraphicsPromise:o([a,...u]).then((e=>Array.from(new Set(e.flat())))),promisesPerLayerView:n}}async setupPopup(){if(this._popupSetupTask?.abort(),this.popup&&!d(this.popup))return this._popupSetupTask=p((async e=>{const{default:p}=await import("../widgets/Popup.js");if(r(e),!this.popup||d(this.popup))return;const t=this.popup;delete t.open,delete t.close,this.popup=new p(t)})),this._popupSetupTask.promise}_queryLayerPopupFeatures(e,p,t){return p.map((({layerView:p,graphics:i})=>{const s={clientGraphics:i,event:null!=t?t.event:void 0,signal:null!=t?t.signal:void 0,defaultPopupTemplateEnabled:null!=t&&!!t.defaultPopupTemplateEnabled},o=p.fetchPopupFeatures(e,s);return{layerView:p,promise:o}}))}_isValidPopupGraphic(e,p){return e&&!!e.getEffectivePopupTemplate(null!=p&&p.defaultPopupTemplateEnabled)}async _prepareFetchPopupFeatures(e,p){const{clientGraphics:t,queryArea:i,location:s}=await this._popupHitTestGraphics(e,p),o=this._getFetchPopupLayerViews(),{layerViewsAndGraphics:r,clientOnlyGraphics:a}=this._graphicsPerFetchPopupLayerView(t,o);return{clientOnlyGraphics:a,layerViewsAndGraphics:r,queryArea:i,location:s}}async _popupHitTestGraphics(e,p){const t=await this.popupHitTest(e),i=t.results,s=t.mapPoint,o=i.filter((e=>"graphic"===e.type&&this._isValidPopupGraphic(e.graphic,p))),r=o.length?o[0].mapPoint:null;return{clientGraphics:o.map((e=>e.graphic)),queryArea:s,location:s||r}}_getFetchPopupLayerViews(){const e=[];return this.allLayerViews.forEach((p=>{this._isValidPopupLayerView(p)&&e.push(p)})),null!=this.graphicsView&&this._isValidPopupLayerView(this.graphicsView)&&e.push(this.graphicsView),e.reverse()}_isValidPopupLayerView(e){return null!=e&&(!("layer"in e)||!e.suspended)&&"fetchPopupFeatures"in e}_graphicsPerFetchPopupLayerView(e,p){const t=[],i=new Map,s=p.map((e=>{const p=[];return"layer"in e?i.set(e.layer,p):i.set(e.graphics,p),{layerView:e,graphics:p}}));for(const o of e){const e=i.get(o.layer)||i.get(o.sourceLayer)||null;e?e.push(o):t.push(o)}return{layerViewsAndGraphics:s,clientOnlyGraphics:t}}};return e([l({cast(e){return!e||d(e)||"object"==typeof e&&(e.open=e=>(t(s.getLogger(this),"view.popup is no longer created by default. view.popup.open() will stop working when the popup isn't created",{replacement:"Use view.openPopup() instead.",version:"4.27"}),this.openPopup(e)),e.close=()=>(t(s.getLogger(this),"view.popup is no longer created by default. view.popup.close() will stop working when the popup isn't created",{replacement:"Use view.closePopup() instead.",version:"4.27"}),this.closePopup())),e}})],m.prototype,"popup",void 0),e([l()],m.prototype,"popupEnabled",void 0),m=e([c("esri.views.PopupView")],m),m};export{w as PopupView};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import{createTask as p}from"../core/asyncUtils.js";import{deprecated as t}from"../core/deprecate.js";import i from"../core/Error.js";import s from"../core/Logger.js";import{eachAlwaysValues as o,throwIfAborted as r}from"../core/promiseUtils.js";import{watch as a,initial as n,whenOnce as u}from"../core/reactiveUtils.js";import{property as l}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as c}from"../core/accessorSupport/decorators/subclass.js";import{ViewEventPriorities as h}from"./input/InputManager.js";function d(e){return null!=e&&"open"in e&&"declaredClass"in e}function y(e){return null!=e&&"declaredClass"in e&&"dockOptions"in e}const w=w=>{let m=class extends w{constructor(){super(...arguments),this._popupSetupTask=null,this.popup={},this.popupEnabled=!0}initialize(){this.addHandles([a((()=>[this.ui,this.popup]),(([e,p],t)=>{const i="popup",s="manual";if(t){const[e,p]=t;e&&d(p)&&(p.view=null,y(p)&&e.remove(p,i))}e&&d(p)&&(p.view=this,y(p)&&e.add(p,{key:i,position:s,internal:!0}))}),n),this.on("click",(e=>{this.popup&&this.popupEnabled&&("mouse"!==e.pointerType||0===e.button)&&(!d(this.popup)&&"autoOpenEnabled"in this.popup&&!1===this.popup.autoOpenEnabled||(d(this.popup)?this.popup.viewModel.handleViewClick(e):e.async((async()=>{await this.setupPopup(),d(this.popup)&&!this.destroyed&&this.ready&&this.popupEnabled&&this.popup.viewModel.handleViewClick(e)}))))}),h.WIDGET)]),u((()=>this.ready&&this.popupEnabled&&!this.updating)).then((()=>{import("../widgets/Popup.js")}))}destroy(){this.destroyed||this.closePopup()}async openPopup(e){if(d(this.popup))return this.popup.open(e);try{if(await this.setupPopup(),!this.popup)return void s.getLogger(this).error(new i("view:null-popup","Popup is null and can't be opened"));this.popup.open(e)}catch{}}closePopup(){this._popupSetupTask?.abort(),d(this.popup)&&this.popup.close()}async fetchPopupFeatures(e,p){await this.when();const{location:t,queryArea:i,layerViewsAndGraphics:s,clientOnlyGraphics:r}=await this._prepareFetchPopupFeatures(e,p),a=Promise.resolve(r),n=this._queryLayerPopupFeatures(i,s,p),u=n.map((e=>e.promise));return{location:t,clientOnlyGraphics:r,allGraphicsPromise:o([a,...u]).then((e=>Array.from(new Set(e.flat())))),promisesPerLayerView:n}}async setupPopup(){if(this._popupSetupTask?.abort(),this.popup&&!d(this.popup))return this._popupSetupTask=p((async e=>{const{default:p}=await import("../widgets/Popup.js");if(r(e),!this.popup||d(this.popup))return;const t=this.popup;delete t.open,delete t.close,this.popup=new p(t)})),this._popupSetupTask.promise}_queryLayerPopupFeatures(e,p,t){return p.map((({layerView:p,graphics:i})=>{const s={clientGraphics:i,event:null!=t?t.event:void 0,signal:null!=t?t.signal:void 0,defaultPopupTemplateEnabled:null!=t&&!!t.defaultPopupTemplateEnabled},o=p.fetchPopupFeatures(e,s);return{layerView:p,promise:o}}))}_isValidPopupGraphic(e,p){return e&&!!e.getEffectivePopupTemplate(null!=p&&p.defaultPopupTemplateEnabled)}async _prepareFetchPopupFeatures(e,p){const{clientGraphics:t,queryArea:i,location:s}=await this._popupHitTestGraphics(e,p),o=this._getFetchPopupLayerViews(),{layerViewsAndGraphics:r,clientOnlyGraphics:a}=this._graphicsPerFetchPopupLayerView(t,o);return{clientOnlyGraphics:a,layerViewsAndGraphics:r,queryArea:i,location:s}}async _popupHitTestGraphics(e,p){const t=await this.popupHitTest(e),i=t.results,s=t.mapPoint,o=i.filter((e=>"graphic"===e.type&&this._isValidPopupGraphic(e.graphic,p))),r=o.length?o[0].mapPoint:null;return{clientGraphics:o.map((e=>e.graphic)),queryArea:s,location:s||r}}_getFetchPopupLayerViews(){const e=[];return this.allLayerViews.forEach((p=>{this._isValidPopupLayerView(p)&&e.push(p)})),null!=this.graphicsView&&this._isValidPopupLayerView(this.graphicsView)&&e.push(this.graphicsView),e.reverse()}_isValidPopupLayerView(e){return null!=e&&(!("layer"in e)||!e.suspended)&&"fetchPopupFeatures"in e}_graphicsPerFetchPopupLayerView(e,p){const t=[],i=new Map,s=p.map((e=>{const p=[];return"layer"in e?i.set(e.layer,p):i.set(e.graphics,p),{layerView:e,graphics:p}}));for(const o of e){const e=i.get(o.layer)||i.get(o.sourceLayer)||null;e?e.push(o):t.push(o)}return{layerViewsAndGraphics:s,clientOnlyGraphics:t}}};return e([l({cast(e){return!e||d(e)||"object"==typeof e&&(e.open=e=>(t(s.getLogger(this),"view.popup is no longer created by default. view.popup.open() will stop working when the popup isn't created",{replacement:"Use view.openPopup() instead.",version:"4.27"}),this.openPopup(e)),e.close=()=>(t(s.getLogger(this),"view.popup is no longer created by default. view.popup.close() will stop working when the popup isn't created",{replacement:"Use view.closePopup() instead.",version:"4.27"}),this.closePopup())),e}})],m.prototype,"popup",void 0),e([l()],m.prototype,"popupEnabled",void 0),m=e([c("esri.views.PopupView")],m),m};export{w as PopupView};