// All material copyright Esri, All Rights Reserved, unless otherwise specified. // See https://js.arcgis.com/4.30/esri/copyright.txt for details. //>>built define("require ../chunks/tslib.es6 ../geometry ../PopupTemplate ../renderers/ClassBreaksRenderer ../renderers/DictionaryRenderer ../renderers/DotDensityRenderer ../renderers/HeatmapRenderer ../renderers/PieChartRenderer ../renderers/Renderer ../renderers/SimpleRenderer ../renderers/UniqueValueRenderer ../renderers/support/jsonUtils ../renderers/support/types ../request ../core/Clonable ../core/Error ../core/handleUtils ../core/lang ../core/Logger ../core/MultiOriginJSONSupport ../core/promiseUtils ../core/accessorSupport/decorators/property ../core/accessorSupport/ensureType ../core/accessorSupport/decorators/reader ../core/accessorSupport/decorators/subclass ../geometry/support/typeUtils ./Layer ./mixins/ArcGISService ./mixins/BlendLayer ./mixins/CustomParametersMixin ./mixins/FeatureEffectLayer ./mixins/FeatureReductionLayer ./mixins/OperationalLayer ./mixins/PortalLayer ./mixins/RefreshableLayer ./mixins/ScaleRangeLayer ./mixins/TemporalLayer ./support/commonProperties ./support/featureLayerUtils ./support/Field ./support/fieldProperties ./support/fieldUtils ./support/LabelClass ./support/labelingInfo ./support/PurgeOptions ../renderers/support/styleUtils ../rest/support/Query ../support/popupUtils ../symbols/support/ElevationInfo ../webdoc/interfaces ../geometry/SpatialReference ../geometry/Extent".split(" "), function(x,c,p,F,la,ma,na,oa,pa,qa,ra,sa,G,y,H,b,h,I,J,K,L,z,d,A,B,M,q,N,O,P,Q,R,S,T,U,V,W,X,g,Y,Z,aa,r,ba,ca,C,da,ea,fa,ha,m,D,ia){function E(a,e){return new h("layer:unsupported",`Layer (${a.title}, ${a.id}) of type '${a.declaredClass}' ${e}`,{layer:a})}p=aa.defineFieldProperties();b=class extends S.FeatureReductionLayer(R.FeatureEffectLayer(P.BlendLayer(X.TemporalLayer(W.ScaleRangeLayer(V.RefreshableLayer(O.ArcGISService(T.OperationalLayer(U.PortalLayer(L.MultiOriginJSONMixin(Q.CustomParametersMixin(b.ClonableMixin(N)))))))))))){constructor(...a){super(...a); this.geometryType=this.geometryDefinition=this.fieldsIndex=this.fields=this.elevationInfo=this.displayField=this.definitionExpression=this.copyright=null;this.labelsVisible=!0;this.labelingInfo=null;this.legendEnabled=!0;this.maxReconnectionAttempts=0;this.maxReconnectionInterval=20;this.minScale=this.maxScale=0;this.objectIdField=null;this.operationalLayerType="ArcGISStreamLayer";this.outFields=["*"];this.popupEnabled=!0;this.popupTemplate=null;this.purgeOptions=new C;this.refreshInterval=0;this.screenSizePerspectiveEnabled= !0;this.sourceJSON=null;this.spatialReference=D.WGS84;this.type="stream";this.url=null;this.updateInterval=300;this.useViewTime=!0;this.webSocketUrl=null;this._debouncedSaveOperations=z.debounce(async(e,f,k)=>{const {save:t,saveAs:u}=await new Promise((v,w)=>x(["./save/streamLayerUtils"],v,w));switch(e){case m.SaveOperationType.SAVE:return t(this,f);case m.SaveOperationType.SAVE_AS:return u(this,k,f)}})}normalizeCtorArgs(a,e){return"string"===typeof a?{url:a,...e}:a}load(a){if(!("WebSocket"in globalThis))return this.addResolvingPromise(Promise.reject(new h("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 e=null!=a?a.signal:null;this.addResolvingPromise(this.loadFromPortal({supportedTypes:["Stream Service","Feed"]},a).catch(z.throwIfAbortError).then(()=>this._fetchService(e)));return Promise.resolve(this)}get defaultPopupTemplate(){return this.createPopupTemplate()}set featureReduction(a){a=this._normalizeFeatureReduction(a);this._set("featureReduction", a)}set renderer(a){r.fixRendererFields(a,this.fieldsIndex);this._set("renderer",a)}readRenderer(a,e,f){e=e.layerDefinition||e;return(a=e.drawingInfo?.renderer)?((a=G.read(a,e,f)||void 0)||K.getLogger(this).error("Failed to create renderer",{rendererDefinition:e.drawingInfo.renderer,layer:this,context:f}),a):Y.createDefaultRenderer(e,f)}async connect(a){const [{createConnection:e}]=await Promise.all([new Promise((l,ja)=>x(["./graphics/sources/connections/createConnection"],l,ja)),this.load()]),f=this.geometryType? q.featureGeometryTypeKebabDictionary.toJSON(this.geometryType):null,{customParameters:k=null,definitionExpression:t=null,geometryDefinition:u=null,maxReconnectionAttempts:v=0,maxReconnectionInterval:w=20,spatialReference:ka=this.spatialReference}=a||this.createConnectionParameters(),n=e(this.parsedUrl,this.spatialReference,ka,f,t,u,v,w,k??void 0);a=I.handlesGroup([this.on("send-message-to-socket",l=>n.sendMessageToSocket(l)),this.on("send-message-to-client",l=>n.sendMessageToClient(l))]);n.once("destroy", a.remove);return n}createConnectionParameters(){return{spatialReference:this.spatialReference,customParameters:this.customParameters,definitionExpression:this.definitionExpression,geometryDefinition:this.geometryDefinition,maxReconnectionAttempts:this.maxReconnectionAttempts,maxReconnectionInterval:this.maxReconnectionInterval}}createPopupTemplate(a){return fa.createPopupTemplate(this,a)}createQuery(){const a=new ea;a.returnGeometry=!0;a.outFields=["*"];a.where=this.definitionExpression||"1\x3d1"; return a}getFieldDomain(a,e){if(!this.fields)return null;let f=null;this.fields.some(k=>{k.name===a&&(f=k.domain);return!!f});return f}getField(a){return this.fieldsIndex.get(a)}serviceSupportsSpatialReference(a){return!0}sendMessageToSocket(a){this.emit("send-message-to-socket",a)}sendMessageToClient(a){this.emit("send-message-to-client",a)}async save(a){return this._debouncedSaveOperations(m.SaveOperationType.SAVE,a)}async saveAs(a,e){return this._debouncedSaveOperations(m.SaveOperationType.SAVE_AS, e,a)}write(a,e){const f=e?.messages;return this.webSocketUrl?(f?.push(E(this,"using a custom websocket connection cannot be written to web scenes and web maps")),null):this.parsedUrl?super.write(a,e):(f?.push(E(this,"using a client-side only connection without a url cannot be written to web scenes and web maps")),null)}async _fetchService(a){if(!this.webSocketUrl&&this.parsedUrl)this.sourceJSON||({data:a}=await H(this.parsedUrl.path,{query:{f:"json",...this.customParameters,...this.parsedUrl.query}, responseType:"json",signal:a}),this.sourceJSON=a);else{if(!this.timeInfo?.trackIdField)throw new h("stream-layer:missing-metadata","The stream layer trackIdField must be specified.");if(!this.objectIdField){a=this.fields.find(e=>"oid"===e.type)?.name;if(!a)throw new h("stream-layer:missing-metadata","The stream layer objectIdField must be specified.");this.objectIdField=a}if(!this.fields)throw new h("stream-layer:missing-metadata","The stream layer fields must be specified.");this.fields.some(e=> e.name===this.objectIdField)||this.fields.push(new Z({name:this.objectIdField,alias:this.objectIdField,type:"oid"}));if(!this.geometryType)throw new h("stream-layer:missing-metadata","The stream layer geometryType must be specified.");this.webSocketUrl&&(this.url=this.webSocketUrl)}this.read(this.sourceJSON,{origin:"service",portalItem:this.portalItem,portal:this.portalItem?.portal,url:this.parsedUrl});r.fixRendererFields(this.renderer,this.fieldsIndex);r.fixTimeInfoFields(this.timeInfo,this.fieldsIndex); this.objectIdField||(this.objectIdField="__esri_stream_id__");return da.loadStyleRenderer(this,{origin:"service"})}};c.__decorate([d.property({type:String})],b.prototype,"copyright",void 0);c.__decorate([d.property({readOnly:!0})],b.prototype,"defaultPopupTemplate",null);c.__decorate([d.property({type:String,json:{name:"layerDefinition.definitionExpression",write:{enabled:!0,allowNull:!0}}})],b.prototype,"definitionExpression",void 0);c.__decorate([d.property({type:String})],b.prototype,"displayField", void 0);c.__decorate([d.property({type:ha})],b.prototype,"elevationInfo",void 0);c.__decorate([d.property({json:{origins:{"web-map":{read:!1,write:!1},"portal-item":{read:!1,write:!1},"web-scene":{read:!1,write:!1}}}})],b.prototype,"featureReduction",null);c.__decorate([d.property(p.fields)],b.prototype,"fields",void 0);c.__decorate([d.property(p.fieldsIndex)],b.prototype,"fieldsIndex",void 0);c.__decorate([d.property({type:ia,json:{name:"layerDefinition.definitionGeometry",write:!0}})],b.prototype, "geometryDefinition",void 0);c.__decorate([d.property({type:q.featureGeometryTypeKebabDictionary.apiValues,json:{read:{reader:q.featureGeometryTypeKebabDictionary.read}}})],b.prototype,"geometryType",void 0);c.__decorate([d.property(g.labelsVisible)],b.prototype,"labelsVisible",void 0);c.__decorate([d.property({type:[ba],json:{name:"layerDefinition.drawingInfo.labelingInfo",read:{reader:ca.reader},write:!0}})],b.prototype,"labelingInfo",void 0);c.__decorate([d.property(g.legendEnabled)],b.prototype, "legendEnabled",void 0);c.__decorate([d.property({type:["show","hide"],json:{origins:{"portal-item":{read:!1,write:!1}}}})],b.prototype,"listMode",void 0);c.__decorate([d.property({type:A.Integer})],b.prototype,"maxReconnectionAttempts",void 0);c.__decorate([d.property({type:A.Integer})],b.prototype,"maxReconnectionInterval",void 0);c.__decorate([d.property(g.maxScale)],b.prototype,"maxScale",void 0);c.__decorate([d.property(g.minScale)],b.prototype,"minScale",void 0);c.__decorate([d.property({type:String})], b.prototype,"objectIdField",void 0);c.__decorate([d.property({value:"ArcGISStreamLayer",type:["ArcGISStreamLayer"]})],b.prototype,"operationalLayerType",void 0);c.__decorate([d.property({readOnly:!0})],b.prototype,"outFields",void 0);c.__decorate([d.property(g.popupEnabled)],b.prototype,"popupEnabled",void 0);c.__decorate([d.property({type:F,json:{name:"popupInfo",write:!0}})],b.prototype,"popupTemplate",void 0);c.__decorate([d.property({type:C})],b.prototype,"purgeOptions",void 0);c.__decorate([d.property({json:{read:!1, write:!1}})],b.prototype,"refreshInterval",void 0);c.__decorate([d.property({types:y.rendererTypes,json:{origins:{service:{write:{target:"drawingInfo.renderer",enabled:!1}},"web-scene":{name:"layerDefinition.drawingInfo.renderer",types:y.webSceneRendererTypes,write:!0}},write:{target:"layerDefinition.drawingInfo.renderer"}}})],b.prototype,"renderer",null);c.__decorate([B.reader("service","renderer",["drawingInfo.renderer","defaultSymbol"]),B.reader("renderer",["layerDefinition.drawingInfo.renderer", "layerDefinition.defaultSymbol"])],b.prototype,"readRenderer",null);c.__decorate([d.property((()=>{const a=J.clone(g.screenSizePerspectiveEnabled);a.json.origins["portal-item"]={read:!1,write:!1};return a})())],b.prototype,"screenSizePerspectiveEnabled",void 0);c.__decorate([d.property()],b.prototype,"sourceJSON",void 0);c.__decorate([d.property({type:D,json:{origins:{service:{read:{source:"spatialReference"}}}}})],b.prototype,"spatialReference",void 0);c.__decorate([d.property({json:{read:!1}})], b.prototype,"type",void 0);c.__decorate([d.property(g.url)],b.prototype,"url",void 0);c.__decorate([d.property({type:Number})],b.prototype,"updateInterval",void 0);c.__decorate([d.property({json:{read:!1,write:!1}})],b.prototype,"useViewTime",void 0);c.__decorate([d.property({type:String})],b.prototype,"webSocketUrl",void 0);return b=c.__decorate([M.subclass("esri.layers.StreamLayer")],b)});