/* COPYRIGHT Esri - https://js.arcgis.com/5.1.0/LICENSE.txt */
import t from"./geoprocessor/GPOptions.js";import{submitJob as e}from"./geoprocessor/submitJob.js";import{lastMileDeliveryParametersToQueryParameters as n}from"./route/utils.js";const s={cost:"usage_cost",depotVisits:"output_depot_visits",depots:"output_depots",directionLines:"output_direction_lines",directionPoints:"output_direction_points",networkAnalysisLayerPackage:"output_network_analysis_layer_package",orders:"output_orders",resultFile:"output_result_file",routeData:"output_route_data",routes:"output_routes"};function a(e){if(!e)return;const{outSpatialReference:n,processExtent:s,returnM:a,returnZ:o}=e;return new t({outSpatialReference:n,processExtent:s,returnM:a,returnZ:o})}function o(t,e){return{gpOptions:a(t),requestOptions:{...e,query:{...e?.query,token:t?.apiKey}}}}async function u(t,s,a,o){const u=n(s),r=await e(t,u,a,o);return await r.waitForJobCompletion({apiKey:s.apiKey}),r}async function r(t,e,n){const{gpOptions:a,requestOptions:u}=o(e,n),{value:r}=await t.fetchResultData(s.depots,a,u);return r}async function i(t,e,n){const{gpOptions:a,requestOptions:u}=o(e,n),{value:r}=await t.fetchResultData(s.orders,a,u);return r}async function c(t,e,n){const{gpOptions:a,requestOptions:u}=o(e,n),{value:r}=await t.fetchResultData(s.routes,a,u);return r}async function p(t,e,n){const{gpOptions:a,requestOptions:u}=o(e,n),r=await t.fetchResultData(s.cost,a,u);return{numberOfObjects:r.value.numObjects,credits:r.value.credits}}async function l(t,e,n){const{gpOptions:a,requestOptions:u}=o(e,n),{value:r}=await t.fetchResultData(s.directionPoints,a,u);return r}async function f(t,e,n){const{gpOptions:a,requestOptions:u}=o(e,n),{value:r}=await t.fetchResultData(s.depotVisits,a,u);return r}async function y(t,e,n){const{gpOptions:a,requestOptions:u}=o(e,n),{value:r}=await t.fetchResultData(s.directionLines,a,u);return r}async function d(t,e,n){const{dataType:a,value:{url:o}}=await t.fetchResultData(s.routeData,e,n);return{dataType:a,url:o}}async function O(t,e,n){const{dataType:a,value:{url:o}}=await t.fetchResultData(s.resultFile,e,n);return{dataType:a,url:o}}async function _(t,e,n){const{dataType:a,value:{url:o}}=await t.fetchResultData(s.networkAnalysisLayerPackage,e,n);return{dataType:a,url:o}}export{u as execute,p as getCost,f as getDepotVisits,r as getDepots,y as getDirectionLines,l as getDirectionPoints,_ as getNetworkAnalysisLayer,i as getOrders,O as getResultFile,d as getRouteData,c as getRoutes};
