// All material copyright ESRI, All Rights Reserved, unless otherwise specified.
// See http://js.arcgis.com/3.23/esri/copyright.txt for details.
//>>built
define("esri/tasks/DirectionsFeatureSet","dojo/_base/declare dojo/_base/lang dojo/_base/array dojo/has dojo/json ../kernel ../geometry/Extent ../geometry/Polyline ../geometry/Point ../graphic ./FeatureSet".split(" "),function(e,p,m,w,x,y,z,u,A,B,C){e=e(C,{declaredClass:"esri.tasks.DirectionsFeatureSet",constructor:function(q,t){this.routeId=q.routeId;this.routeName=q.routeName;p.mixin(this,q.summary);this.extent=new z(this.envelope);var f=this._fromCompressedGeometry,g=this.features,h=this.extent.spatialReference,
k=[];m.forEach(t,function(c,a){g[a].setGeometry(k[a]=c?f(c,h):g[a].geometry)});this.mergedGeometry=this._mergePolylinesToSinglePath(k,h);this.geometryType="esriGeometryPolyline";m.forEach(q.events,function(c,a){m.forEach(c,function(a,b){c[b]=new B(new A(a.point.x,a.point.y,h),null,{ETA:a.ETA,strings:x.stringify(a.strings),arriveTimeUTC:a.arriveTimeUTC})});q.events[a]=c});delete this.envelope},_fromCompressedGeometry:function(q,t){var f=0,g=0,h=0,k=0,c=[],a,l,b,e,p,v,d=0,n=0,r=0;(b=q.match(/((\+|\-)[^\+\-\|]+|\|)/g))||
(b=[]);0===parseInt(b[d],32)?(d=2,a=parseInt(b[d],32),d++,e=parseInt(b[d],32),d++,a&1&&(n=m.indexOf(b,"|")+1,p=parseInt(b[n],32),n++),a&2&&(r=m.indexOf(b,"|",n)+1,v=parseInt(b[r],32),r++)):(e=parseInt(b[d],32),d++);for(;d<b.length&&"|"!==b[d];)a=parseInt(b[d],32)+f,d++,f=a,l=parseInt(b[d],32)+g,d++,g=l,a=[a/e,l/e],n&&(l=parseInt(b[n],32)+h,n++,h=l,a.push(l/p)),r&&(l=parseInt(b[r],32)+k,r++,k=l,a.push(l/v)),c.push(a);f=new u({paths:[c],hasZ:0<n,hasM:0<r});f.setSpatialReference(t);return f},_mergePolylinesToSinglePath:function(e,
p){var f=[],g=!1;m.forEach(e,function(c){m.forEach(c.paths,function(a){g=g||c.hasM;f=f.concat(a)})});var h=[],k=[0,0];m.forEach(f,function(c){if(c[0]!==k[0]||c[1]!==k[1])h.push(c),k=c});return new u({paths:[h],spatialReference:p,hasM:g})}});w("extend-esri")&&p.setObject("tasks.DirectionsFeatureSet",e,y);return e});