/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.24/esri/copyright.txt for details. */ import{_ as e}from"../chunks/tslib.es6.js";import"../geometry.js";import r from"../PopupTemplate.js";import"../renderers/ClassBreaksRenderer.js";import"../renderers/DictionaryRenderer.js";import"../renderers/DotDensityRenderer.js";import"../renderers/HeatmapRenderer.js";import"../renderers/PieChartRenderer.js";import"../renderers/Renderer.js";import t from"../renderers/SimpleRenderer.js";import o from"../renderers/UniqueValueRenderer.js";import{read as i}from"../renderers/support/jsonUtils.js";import{rendererTypes as s,webSceneRendererTypes as p}from"../renderers/support/types.js";import n from"../request.js";import{symbolTypesRenderer as a}from"../symbols.js";import l from"../core/Error.js";import d from"../core/Logger.js";import{isSome as m}from"../core/maybe.js";import{MultiOriginJSONMixin as y}from"../core/MultiOriginJSONSupport.js";import{throwIfAbortError as f}from"../core/promiseUtils.js";import{property as u}from"../core/accessorSupport/decorators/property.js";import"../core/arrayUtils.js";import"../core/has.js";import{Integer as c}from"../core/accessorSupport/ensureType.js";import{reader as h}from"../core/accessorSupport/decorators/reader.js";import{subclass as g}from"../core/accessorSupport/decorators/subclass.js";import{createTypeReader as j}from"../core/accessorSupport/extensions/serializableProperty/reader.js";import{featureGeometryTypeKebabDictionary as S}from"../geometry/support/typeUtils.js";import v from"./Layer.js";import{ArcGISService as b}from"./mixins/ArcGISService.js";import{BlendLayer as I}from"./mixins/BlendLayer.js";import{CustomParametersMixin as w}from"./mixins/CustomParametersMixin.js";import{FeatureEffectLayer as x}from"./mixins/FeatureEffectLayer.js";import{OperationalLayer as R}from"./mixins/OperationalLayer.js";import{PortalLayer as T}from"./mixins/PortalLayer.js";import{RefreshableLayer as P}from"./mixins/RefreshableLayer.js";import{ScaleRangeLayer as L}from"./mixins/ScaleRangeLayer.js";import{TemporalLayer as F}from"./mixins/TemporalLayer.js";import{labelsVisible as U,legendEnabled as D,maxScale as E,minScale as O,popupEnabled as k,screenSizePerspectiveEnabled as N,url as _}from"./support/commonProperties.js";import{featureReductionProperty as J}from"./support/featureReductionUtils.js";import{defineFieldProperties as A}from"./support/fieldProperties.js";import{fixRendererFields as G,fixTimeInfoFields as q}from"./support/fieldUtils.js";import C from"./support/LabelClass.js";import{reader as V}from"./support/labelingInfo.js";import z from"./support/PurgeOptions.js";import{loadStyleRenderer as M}from"../renderers/support/styleUtils.js";import W from"../rest/support/Query.js";import{createPopupTemplate as B}from"../support/popupUtils.js";import Q from"../symbols/support/ElevationInfo.js";import H from"../geometry/SpatialReference.js";import K from"../geometry/Extent.js";const X=d.getLogger("esri.layers.StreamLayer"),Y=A();let Z=class extends(x(I(F(L(P(b(R(T(y(w(v))))))))))){constructor(...e){super(...e),this.copyright=null,this.definitionExpression=null,this.displayField=null,this.elevationInfo=null,this.featureReduction=null,this.fields=null,this.fieldsIndex=null,this.geometryDefinition=null,this.geometryType=null,this.labelsVisible=!0,this.labelingInfo=null,this.legendEnabled=!0,this.maxReconnectionAttempts=0,this.maxReconnectionInterval=20,this.maxScale=0,this.minScale=0,this.objectIdField=null,this.operationalLayerType="ArcGISStreamLayer",this.popupEnabled=!0,this.popupTemplate=null,this.purgeOptions=new z,this.screenSizePerspectiveEnabled=!0,this.sourceJSON=null,this.spatialReference=H.WGS84,this.type="stream",this.url=null,this.updateInterval=300,this.webSocketUrl=null}normalizeCtorArgs(e,r){return"string"==typeof e?{url:e,...r}:e}load(e){if(!("WebSocket"in globalThis))return this.addResolvingPromise(Promise.reject(new l("stream-layer:websocket-unsupported","WebSocket is not supported in this browser. StreamLayer will not have real-time connection with the stream service."))),Promise.resolve(this);const r=m(e)?e.signal:null;return this.addResolvingPromise(this.loadFromPortal({supportedTypes:["Stream Service","Feed"]},e).catch(f).then((()=>this._fetchService(r)))),Promise.resolve(this)}get defaultPopupTemplate(){return this.createPopupTemplate()}set renderer(e){G(e,this.fieldsIndex),this._set("renderer",e)}readRenderer(e,r,s){const p=(r=r.layerDefinition||r).drawingInfo&&r.drawingInfo.renderer||void 0;if(p){const e=i(p,r,s)||void 0;return e||X.error("Failed to create renderer",{rendererDefinition:r.drawingInfo.renderer,layer:this,context:s}),e}if(r.defaultSymbol)return r.types&&r.types.length?new o({defaultSymbol:$(r.defaultSymbol,r,s),field:r.typeIdField,uniqueValueInfos:r.types.map((e=>({id:e.id,symbol:$(e.symbol,e,s)})))}):new t({symbol:$(r.defaultSymbol,r,s)})}createPopupTemplate(e){return B(this,e)}createQuery(){const e=new W;return e.returnGeometry=!0,e.outFields=["*"],e.where=this.definitionExpression||"1=1",e}getFieldDomain(e,r){if(!this.fields)return null;let t=null;return this.fields.some((r=>(r.name===e&&(t=r.domain),!!t))),t}getField(e){return this.fieldsIndex.get(e)}serviceSupportsSpatialReference(e){return!0}async _fetchService(e){if(!!this.webSocketUrl){if(!this.timeInfo?.trackIdField)throw new l("stream-layer:missing-metadata","The stream layer trackIdField must be specified.");if(!this.objectIdField)throw new l("stream-layer:missing-metadata","The stream layer objectIdField must be specified.");if(!this.fields)throw new l("stream-layer:missing-metadata","The stream layer fields must be specified.");if(!this.geometryType)throw new l("stream-layer:missing-metadata","The stream layer geometryType must be specified.");this.url=this.webSocketUrl}else if(!this.sourceJSON){const{data:r}=await n(this.parsedUrl.path,{query:{f:"json",...this.customParameters,...this.parsedUrl.query},responseType:"json",signal:e});this.sourceJSON=r}return this.sourceJSON={...this.sourceJSON??{},objectIdField:"__esri_stream_id__"},this.read(this.sourceJSON,{origin:"service",url:this.parsedUrl}),G(this.renderer,this.fieldsIndex),q(this.timeInfo,this.fieldsIndex),M(this,{origin:"service"})}};e([u({type:String})],Z.prototype,"copyright",void 0),e([u({readOnly:!0})],Z.prototype,"defaultPopupTemplate",null),e([u({type:String,json:{name:"layerDefinition.definitionExpression",write:{enabled:!0,allowNull:!0}}})],Z.prototype,"definitionExpression",void 0),e([u({type:String})],Z.prototype,"displayField",void 0),e([u({type:Q})],Z.prototype,"elevationInfo",void 0),e([u(J)],Z.prototype,"featureReduction",void 0),e([u(Y.fields)],Z.prototype,"fields",void 0),e([u(Y.fieldsIndex)],Z.prototype,"fieldsIndex",void 0),e([u({type:K})],Z.prototype,"geometryDefinition",void 0),e([u({type:S.apiValues,json:{read:{reader:S.read}}})],Z.prototype,"geometryType",void 0),e([u(U)],Z.prototype,"labelsVisible",void 0),e([u({type:[C],json:{read:{source:"layerDefinition.drawingInfo.labelingInfo",reader:V},write:{target:"layerDefinition.drawingInfo.labelingInfo"}}})],Z.prototype,"labelingInfo",void 0),e([u(D)],Z.prototype,"legendEnabled",void 0),e([u({type:["show","hide"]})],Z.prototype,"listMode",void 0),e([u({type:c})],Z.prototype,"maxReconnectionAttempts",void 0),e([u({type:c})],Z.prototype,"maxReconnectionInterval",void 0),e([u(E)],Z.prototype,"maxScale",void 0),e([u(O)],Z.prototype,"minScale",void 0),e([u({type:String})],Z.prototype,"objectIdField",void 0),e([u({value:"ArcGISStreamLayer",type:["ArcGISStreamLayer"]})],Z.prototype,"operationalLayerType",void 0),e([u(k)],Z.prototype,"popupEnabled",void 0),e([u({type:r,json:{read:{source:"popupInfo"},write:{target:"popupInfo"}}})],Z.prototype,"popupTemplate",void 0),e([u({type:z})],Z.prototype,"purgeOptions",void 0),e([u({types:s,json:{origins:{service:{write:{target:"drawingInfo.renderer",enabled:!1}},"web-scene":{name:"layerDefinition.drawingInfo.renderer",types:p,write:!0}},write:{target:"layerDefinition.drawingInfo.renderer"}}})],Z.prototype,"renderer",null),e([h("service","renderer",["drawingInfo.renderer","defaultSymbol"]),h("renderer",["layerDefinition.drawingInfo.renderer","layerDefinition.defaultSymbol"])],Z.prototype,"readRenderer",null),e([u(N)],Z.prototype,"screenSizePerspectiveEnabled",void 0),e([u()],Z.prototype,"sourceJSON",void 0),e([u({type:H,json:{origins:{service:{read:{source:"spatialReference"}}}}})],Z.prototype,"spatialReference",void 0),e([u({json:{read:!1}})],Z.prototype,"type",void 0),e([u(_)],Z.prototype,"url",void 0),e([u({type:Number})],Z.prototype,"updateInterval",void 0),e([u({type:String})],Z.prototype,"webSocketUrl",void 0),Z=e([g("esri.layers.StreamLayer")],Z);const $=j({types:a}),ee=Z;export{ee as default};