/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/LICENSE.txt */
import t from"../../request.js";import{parseUrl as e,asValidOptions as r,encode as s}from"../utils.js";import o from"./support/TraceResult.js";async function n(o,n,c){const u=e(o),i=n.toJSON();i.traceLocations=JSON.stringify(n.traceLocations),n.resultTypes&&(i.resultTypes=JSON.stringify(n.resultTypes)),n.moment||"SDE.DEFAULT"!==n.gdbVersion?.toUpperCase()&&n.gdbVersion||(i.moment=Date.now());const y=r(u.query,{query:s({...i,f:"json"}),...c}),p=`${u.path}/trace`;return t(p,y).then(t=>a(t,n.telecomSourceSet))}async function c(o,n,c){const a=e(o),u=n.toJSON();u.traceLocations=JSON.stringify(n.traceLocations),n.resultTypes&&(u.resultTypes=JSON.stringify(n.resultTypes));const i=r(a.query,{query:s({...u,async:!0,f:"json"}),...c}),y=`${a.path}/trace`,{data:p}=await t(y,i);return p.statusUrl}function a(t,e){const{data:r}=t;return o.fromJSON({...r.traceResults,telecomSourceSet:e})}export{c as submitTraceJob,n as trace};
