/* COPYRIGHT Esri - https://js.arcgis.com/5.1.0/LICENSE.txt */
import{saveAs as e,save as t}from"./utils.js";import{getWGS84ExtentForItem as r,removeTypeKeyword as a,typeKeyword as s,addTypeKeyword 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,s.METADATA),l(t,s.SINGLE_LAYER)}async function p(e,r){return t({layer:e,itemType:n,additionalItemType:i,validateLayer:u,createItemData:c,errorNamePrefix:o},r)}async function f(t,r,a){return e({layer:t,itemType:n,validateLayer:u,createItemData:c,errorNamePrefix:m,newItem:r,setItemProperties:y},a)}export{p as save,f as saveAs};
