/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import{save as e,saveAs as t}from"./utils.js";import{getWGS84ExtentForItem as r,removeTypeKeyword as a,addTypeKeyword as s,typeKeyword as l}from"../../portal/support/portalItemUtils.js";const n="Stream Service",i="Feed",o="stream-layer-save",m="stream-layer-save-as";function u(e){return{isValid:"stream"===e.type&&!!e.url&&!e.webSocketUrl,errorMessage:"Stream layer should be created using a url to a stream service"}}function c(e){const t=e.layerJSON;return Promise.resolve(t&&Object.keys(t).length?t:null)}async function y(e,t){const{parsedUrl:n,title:i,fullExtent:o}=e;t.url=n.path,t.title||=i,t.extent=null,null!=o&&(t.extent=await r(o)),a(t,l.METADATA),s(t,l.SINGLE_LAYER)}async function p(t,r){return e({layer:t,itemType:n,additionalItemType:i,validateLayer:u,createItemData:c,errorNamePrefix:o},r)}async function f(e,r,a){return t({layer:e,itemType:n,validateLayer:u,createItemData:c,errorNamePrefix:m,newItem:r,setItemProperties:y},a)}export{p as save,f as saveAs};
