/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/LICENSE.txt */
import r from"../../../request.js";import s from"../../../core/Error.js";import{parseUrl as o,asValidOptions as t,encode as i}from"../../utils.js";import{addServerVersion as e}from"./serverVersionUtils.js";import n from"./support/PostResult.js";const p=new Map;async function m(m,f,a,u){p.has(m)||await e(p,m);const c=p.get(m);if((c?.serverVersion??0)<=11.1)throw new s("post:enterprise-version","versioning API requires ArcGIS Enterprise version 11.2 or higher");if(!f)throw new s("post:missing-guid","guid for version is missing");const w=o(m),g=a.toJSON();a.rows&&(g.rows=JSON.stringify(a.rows));const h=t(w.query,{query:i({...g,f:"json"}),...u,method:"post"});f.startsWith("{")&&(f=f.slice(1,-1));const v=`${w.path}/versions/${f}/post`,{data:j}=await r(v,h);return n.fromJSON(j)}export{m as post,p as serverVersionCacheMap};
