// 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/PrintTask","dojo/_base/declare dojo/_base/lang dojo/_base/array dojo/_base/json dojo/_base/Deferred dojo/has ../kernel ../lang ../layerUtils ../deferredUtils ../Color ../urlUtils ./Task ../geometry/Polygon ../renderers/SimpleRenderer ../symbols/FillSymbol ./Geoprocessor ./PrintTemplate dojo/dom-attr dojo/dom-construct dojox/gfx/_base dojox/gfx/canvas dojox/json/query dojo/has!extend-esri?./PrintParameters dojo/has!extend-esri?./LegendLayer".split(" "),function(v,h,r,A,E,B,F,y,C,
G,H,I,J,K,L,M,N,O,P,Q,u,z,R){v=v(J,{declaredClass:"esri.tasks.PrintTask",constructor:function(b,e){this.url=b;this.printGp=new N(this.url);this._handler=h.hitch(this,this._handler);e&&e.async&&(this.async=e.async);this._colorEvaluator=R("$..color")},_vtlExtent:null,_handler:function(b,e,f,a,d){try{var c;this.async?"esriJobSucceeded"===b.jobStatus&&this.printGp.getResultData(b.jobId,"Output_File",h.hitch(this,function(a){c=a.value;this._successHandler([c],"onComplete",f,d)})):(c=b[0].value,this._successHandler([c],
"onComplete",f,d))}catch(g){this._errorHandler(g,a,d)}},execute:function(b,e,f){var a=this._handler,d=this._errorHandler,c=b.template||new O;c.hasOwnProperty("showLabels")||(c.showLabels=!0);var g=c.exportOptions,q;g&&(q={outputSize:[g.width,g.height],dpi:g.dpi});var g=c.layoutOptions,n,l=[];if(g){this.legendAll=!1;g.legendLayers?r.forEach(g.legendLayers,function(a){var b={};b.id=a.layerId;a.subLayerIds&&(b.subLayerIds=a.subLayerIds);l.push(b)}):this.legendAll=!0;var k,m;if("Miles"===g.scalebarUnit||
"Kilometers"===g.scalebarUnit)k="esriKilometers",m="esriMiles";else if("Meters"===g.scalebarUnit||"Feet"===g.scalebarUnit)k="esriMeters",m="esriFeet";n={esriMiles:"mi",esriKilometers:"km",esriFeet:"ft",esriMeters:"m"};n={titleText:g.titleText,authorText:g.authorText,copyrightText:g.copyrightText,customTextElements:g.customTextElements,scaleBarOptions:{metricUnit:k,metricLabel:n[k],nonMetricUnit:m,nonMetricLabel:n[m]},legendOptions:{operationalLayers:l}}}k=this._getPrintDefinition(b.map,c);b.outSpatialReference&&
(k.mapOptions.spatialReference=b.outSpatialReference.toJson());b.template&&y.isDefined(b.template.showAttribution)&&(k.mapOptions.showAttribution=b.template.showAttribution);h.mixin(k,{exportOptions:q,layoutOptions:n});this.allLayerslegend&&h.mixin(k.layoutOptions,{legendOptions:{operationalLayers:this.allLayerslegend}});if(k.operationalLayers){q=k.operationalLayers;var p,t=function(a){return y.fixJson(h.mixin(a,{type:"esriSLS",cap:void 0,join:void 0,meterLimit:void 0}))},x=RegExp("[\\u4E00-\\u9FFF\\u0E00-\\u0E7F\\u0900-\\u097F\\u3040-\\u309F\\u30A0-\\u30FF\\u31F0-\\u31FF]"),
D=/[\u0600-\u06FF]/,u=function(a){var b=a.text,c=(a=a.font)&&a.family&&a.family.toLowerCase();b&&a&&("arial"===c||"arial unicode ms"===c)&&(a.family=x.test(b)?"Arial Unicode MS":"Arial","normal"!==a.style&&D.test(b)&&(a.family="Arial Unicode MS"))};for(n=0;n<q.length;n++)if(q[n].featureCollection&&q[n].featureCollection.layers)for(m=0;m<q[n].featureCollection.layers.length;m++){var w=q[n].featureCollection.layers[m];w.layerDefinition&&w.layerDefinition.drawingInfo&&w.layerDefinition.drawingInfo.renderer&&
w.layerDefinition.drawingInfo.renderer.symbol&&(p=w.layerDefinition.drawingInfo.renderer,"esriCLS"===p.symbol.type?p.symbol=t(p.symbol):"esriTS"===p.symbol.type?u(p.symbol):p.symbol.outline&&"esriCLS"===p.symbol.outline.type&&(p.symbol.outline=t(p.symbol.outline)));if(w.featureSet&&w.featureSet.features)for(g=0;g<w.featureSet.features.length;g++)p=w.featureSet.features[g],p.symbol&&("esriCLS"===p.symbol.type?p.symbol=t(p.symbol):"esriTS"===p.symbol.type?u(p.symbol):p.symbol.outline&&"esriCLS"===p.symbol.outline.type&&
(p.symbol.outline=t(p.symbol.outline)))}}c={Web_Map_as_JSON:A.toJson(y.fixJson(k)),Format:c.format,Layout_Template:c.layout};b.extraParameters&&(c=h.mixin(c,b.extraParameters));var v=new E(G._dfdCanceller);b=function(b,c){a(b,c,e,f,v)};k=function(a){d(a,f,v)};v._pendingDfd=this.async?this.printGp.submitJob(c,b,null,k):this.printGp.execute(c,b,k);return v},onComplete:function(){},_createMultipointLayer:function(){return{layerDefinition:{name:"multipointLayer",geometryType:"esriGeometryMultipoint",
drawingInfo:{renderer:null}},featureSet:{geometryType:"esriGeometryMultipoint",features:[]}}},_createPolygonLayer:function(){return{layerDefinition:{name:"polygonLayer",geometryType:"esriGeometryPolygon",drawingInfo:{renderer:null}},featureSet:{geometryType:"esriGeometryPolygon",features:[]}}},_createPointLayer:function(){return{layerDefinition:{name:"pointLayer",geometryType:"esriGeometryPoint",drawingInfo:{renderer:null}},featureSet:{geometryType:"esriGeometryPoint",features:[]}}},_createPolylineLayer:function(){return{layerDefinition:{name:"polylineLayer",
geometryType:"esriGeometryPolyline",drawingInfo:{renderer:null}},featureSet:{geometryType:"esriGeometryPolyline",features:[]}}},_convertSvgSymbol:function(b){if(!(8>=B("ie")||!b.path&&"image/svg+xml"!==b.contentType)){var e,f=z.createSurface(Q.create("div"),1024,1024);e="image/svg+xml"===b.contentType?f.createObject(z.Image,{src:"data:image/svg+xml;base64,"+b.imageData,width:u.pt2px(b.width),height:u.pt2px(b.height),x:0,y:0}):f.createObject(z.Path,b.path).setFill(b.color).setStroke(b.outline);"pendingRender"in
f&&f._render(!0);var a=f.rawNode.getContext("2d"),d=Math.ceil(e.getBoundingBox().width),c=Math.ceil(e.getBoundingBox().height);e=a.getImageData(e.getBoundingBox().x,e.getBoundingBox().y,d,c);a.canvas.width=d;a.canvas.height=c;a.putImageData(e,0,0);a=a.canvas.toDataURL("image/png");b={type:"esriPMS",imageData:a.substr(22,a.length),angle:b.angle,contentType:"image/png",height:b.size?b.size:u.px2pt(c),width:b.size?d/c*b.size:u.px2pt(d),xoffset:b.xoffset,yoffset:b.yoffset};f.destroy();return b}},_convertSvgRenderer:function(b){"simple"===
b.type&&b.symbol&&(b.symbol.path||"image/svg+xml"===b.symbol.contentType)?b.symbol=this._convertSvgSymbol(b.symbol):"uniqueValue"===b.type?(b.defaultSymbol&&(b.defaultSymbol.path||"image/svg+xml"===b.defaultSymbol.contentType)&&(b.defaultSymbol=this._convertSvgSymbol(b.defaultSymbol)),b.uniqueValueInfos&&r.forEach(b.uniqueValueInfos,function(b){if(b.symbol.path||"image/svg+xml"===b.symbol.contentType)b.symbol=this._convertSvgSymbol(b.symbol)},this)):"classBreaks"===b.type&&(b.defaultSymbol&&(b.defaultSymbol.path||
"image/svg+xml"===b.defaultSymbol.contentType)&&(b.defaultSymbol=this._convertSvgSymbol(b.defaultSymbol)),b.classBreakInfos&&r.forEach(b.classBreakInfos,function(b){if(b.symbol.path||"image/svg+xml"===b.symbol.contentType)b.symbol=this._convertSvgSymbol(b.symbol)},this))},_createFeatureCollection:function(b,e,f){var a=this._createPolygonLayer(),d=this._createPolylineLayer(),c=this._createPointLayer(),g=this._createMultipointLayer(),q=this._createPointLayer();q.layerDefinition.name="textLayer";delete q.layerDefinition.drawingInfo;
if("esri.layers.FeatureLayer"===b.declaredClass||"esri.layers.StreamLayer"===b.declaredClass)a.layerDefinition.name=d.layerDefinition.name=c.layerDefinition.name=g.layerDefinition.name=h.getObject("arcgisProps.title",!1,b)||b.name||b.id;var n=b.renderer&&"esri.renderer.SimpleRenderer"===b.renderer.declaredClass;if(!b.renderer||b.renderer.valueExpression||h.isFunction(b.renderer.attributeField))delete a.layerDefinition.drawingInfo,delete d.layerDefinition.drawingInfo,delete c.layerDefinition.drawingInfo,
delete g.layerDefinition.drawingInfo;else{var l=b.renderer.toJson({useLegacyRotationProperties:!0});if("temporal"===l.type){var l={latestObservationRenderer:l.latestObservationRenderer,trackLinesRenderer:l.trackRenderer,observationAger:l.observationAger,renderer:l.observationRenderer},k={};b._trackIdField&&(k.trackIdField=b._trackIdField);b._startTimeField&&(k.startTimeField=b._startTimeField);b._endTimeField&&(k.endTimeField=b._endTimeField);a.layerDefinition.drawingInfo=l;a.layerDefinition.timeInfo=
k;d.layerDefinition.drawingInfo=l;d.layerDefinition.timeInfo=k;c.layerDefinition.drawingInfo=l;c.layerDefinition.timeInfo=k;g.layerDefinition.drawingInfo=l;g.layerDefinition.timeInfo=k}else a.layerDefinition.drawingInfo.renderer=l,d.layerDefinition.drawingInfo.renderer=l,c.layerDefinition.drawingInfo.renderer=l,g.layerDefinition.drawingInfo.renderer=l}l=b.fields;l||!b.renderer||b.renderer.valueExpression||h.isFunction(b.renderer.attributeField)||("esri.renderer.ClassBreaksRenderer"===b.renderer.declaredClass?
(l=[{name:b.renderer.attributeField,type:"esriFieldTypeDouble"}],b.renderer.normalizationField&&l.push({name:b.renderer.normalizationField,type:"esriFieldTypeDouble"})):"esri.renderer.UniqueValueRenderer"===b.renderer.declaredClass&&(l=[{name:b.renderer.attributeField,type:"esriFieldTypeString"}],b.renderer.attributeField2&&l.push({name:b.renderer.attributeField2,type:"esriFieldTypeString"}),b.renderer.attributeField3&&l.push({name:b.renderer.attributeField3,type:"esriFieldTypeString"})));l&&(a.layerDefinition.fields=
l,d.layerDefinition.fields=l,c.layerDefinition.fields=l,g.layerDefinition.fields=l);l=b.graphics;b.isFeatureReductionActive&&b.isFeatureReductionActive()&&(l=b.getSingleGraphics());var k=l.length,m,p;for(p=0;p<k;p++){var t=l[p];if(!1!==t.visible&&t.geometry){m=t.toJson();m.symbol&&m.symbol.outline&&m.symbol.outline.color&&m.symbol.outline.color[3]&&(m.symbol.outline.color[3]=255);if(b.renderer&&!m.symbol&&(h.isFunction(b.renderer.attributeField)||b.renderer.valueExpression||this._isFeatureCollectionRequired(b.renderer,
b)||"esri.renderer.DotDensityRenderer"===b.renderer.declaredClass||f)){f=f||b.renderer;var x=null;try{x=f.getSymbol(t)}catch(D){}if(!x)continue;m.symbol=x.toJson();this._isFeatureCollectionRequired(f,b)&&this._applyVisualVariables(m.symbol,{renderer:f,graphic:t,symbol:x,mapResolution:e&&e.getResolutionInMeters(),mapScale:e&&e.getScale()})}m.symbol&&(m.symbol.path||"image/svg+xml"===m.symbol.contentType?m.symbol=this._convertSvgSymbol(m.symbol):m.symbol.text&&delete m.attributes);switch(t.geometry.type){case "polygon":a.featureSet.features.push(m);
break;case "polyline":d.featureSet.features.push(m);break;case "point":m.symbol&&m.symbol.text?q.featureSet.features.push(m):c.featureSet.features.push(m);break;case "multipoint":g.featureSet.features.push(m);break;case "extent":m.geometry=K.fromExtent(t.geometry).toJson(),a.featureSet.features.push(m)}}}e=[];0<a.featureSet.features.length&&e.push(a);0<d.featureSet.features.length&&e.push(d);0<g.featureSet.features.length&&e.push(g);0<c.featureSet.features.length&&e.push(c);0<q.featureSet.features.length&&
e.push(q);if(!e.length)return null;r.forEach(e,function(a){var b=r.every(a.featureSet.features,function(a){return a.symbol});if(n||b)r.forEach(a.featureSet.features,function(a){delete a.attributes}),delete a.layerDefinition.fields;b&&delete a.layerDefinition.drawingInfo});r.forEach(e,function(a){a.layerDefinition.drawingInfo&&a.layerDefinition.drawingInfo.renderer&&this._convertSvgRenderer(a.layerDefinition.drawingInfo.renderer)},this);return{id:b.id,opacity:b.opacity,minScale:b.minScale||0,maxScale:b.maxScale||
0,featureCollection:{layers:e}}},_getPrintDefinition:function(b,e){var f={operationalLayers:this._createOperationalLayers(b,e)},a=this._vtlExtent||b.extent,d=b.spatialReference;this._vtlExtent=null;b.spatialReference._isWrappable()&&(a=a._normalize(!0),d=a.spatialReference);a={mapOptions:{showAttribution:b.showAttribution,extent:a.toJson(),spatialReference:d.toJson()}};e.preserveScale&&h.mixin(a.mapOptions,{scale:e.outScale||b.getScale()});b.timeExtent&&h.mixin(a.mapOptions,{time:[b.timeExtent.startTime.getTime(),
b.timeExtent.endTime.getTime()]});d={};h.mixin(d,a,f);return d},_createOperationalLayers:function(b,e){var f,a,d,c,g=[],q=0;e.preserveScale&&(q=e.outScale||b.getScale());this.allLayerslegend=this.legendAll?[]:null;this._vtlExtent=null;var n=r.map(b.layerIds,b.getLayer,b);b._mapImageLyr&&n.push(b._mapImageLyr);for(f=0;f<n.length;f++)if(a=n[f],a.loaded&&a.visible&&(!q||a.isVisibleAtScale(q)))switch(d=a.declaredClass,c={id:a.id,title:h.getObject("arcgisProps.title",!1,a)||a.id,opacity:a.opacity,minScale:a.minScale||
0,maxScale:a.maxScale||0},c=h.mixin(c,this._getUrlAndToken(a)),a.getNode()&&P.get(a.getNode(),"data-reference")&&(c._isRefLayer=!0),d){case "esri.layers.ArcGISDynamicMapServiceLayer":var l=[];d=!!a._params.layers;if(a._params.dynamicLayers)d=A.fromJson(a._params.dynamicLayers),r.forEach(d,function(a){l.push({id:a.id,name:a.name,layerDefinition:a});delete a.id;delete a.name;delete a.maxScale;delete a.minScale}),0===l.length&&(c.visibleLayers=[-1]);else if(a.supportsDynamicLayers){if(d||a.layerDefinitions||
a.layerTimeOptions){var k=a.createDynamicLayerInfosFromLayerInfos(),m=null;d&&(m=a.visibleLayers);var m=C._getVisibleLayers(k,m),p=C._getLayersForScale(e.outScale||b.getScale(),k);r.forEach(k,function(b){if(!b.subLayerIds){var c=b.id;-1<r.indexOf(m,c)&&-1<r.indexOf(p,c)&&(b={source:b.source.toJson()},a.layerDefinitions&&a.layerDefinitions[c]&&(b.definitionExpression=a.layerDefinitions[c]),a.layerTimeOptions&&a.layerTimeOptions[c]&&(b.layerTimeOptions=a.layerTimeOptions[c].toJson()),l.push({id:c,layerDefinition:b}))}});
0===l.length&&(c.visibleLayers=[-1])}}else r.forEach(a.layerInfos,function(b){var c={id:b.id,layerDefinition:{}};a.layerDefinitions&&a.layerDefinitions[b.id]&&(c.layerDefinition.definitionExpression=a.layerDefinitions[b.id]);a.layerTimeOptions&&a.layerTimeOptions[b.id]&&(c.layerDefinition.layerTimeOptions=a.layerTimeOptions[b.id].toJson());(c.layerDefinition.definitionExpression||c.layerDefinition.layerTimeOptions)&&l.push(c)}),d&&(c.visibleLayers=a.visibleLayers);l.length&&(c.layers=l);g.push(c);
this.allLayerslegend&&this.allLayerslegend.push({id:a.id,subLayerIds:a.visibleLayers});break;case "esri.layers.ArcGISImageServiceLayer":c=h.mixin(c,{url:a.url,bandIds:a.bandIds,compressionQuality:a.compressionQuality,format:a.format,interpolation:a.interpolation});a.mosaicRule&&h.mixin(c,{mosaicRule:a.mosaicRule.toJson()});(a.renderingRule||a.renderer)&&(d=a.getExportImageRenderingRule())&&h.mixin(c,{renderingRule:d.toJson()});g.push(c);this.allLayerslegend&&this.allLayerslegend.push({id:a.id});break;
case "esri.layers.WMSLayer":c=h.mixin(c,{url:a.url,title:a.title,type:"wms",version:a.version,transparentBackground:a.imageTransparency,visibleLayers:a.visibleLayers});g.push(c);this.allLayerslegend&&this.allLayerslegend.push({id:a.id,subLayerIds:a.visibleLayers});break;case "esri.virtualearth.VETiledLayer":d=a.mapStyle;"roadOnDemand"===d?d="Road":"aerialWithLabelsOnDemand"===d&&(d="Hybrid");c=h.mixin(c,{visibility:a.visible,type:"BingMaps"+d,culture:a.culture,key:a.bingMapsKey});g.push(c);break;
case "esri.layers.OpenStreetMapLayer":c=h.mixin(c,{credits:a.copyright,type:"OpenStreetMap",url:I.getAbsoluteUrl(a.tileServers[0])});g.push(c);break;case "esri.layers.WMTSLayer":c=h.mixin(c,{url:a.url,type:"wmts",layer:a._identifier,style:a._style,format:a.format,tileMatrixSet:a._tileMatrixSetId});g.push(c);break;case "esri.layers.MapImageLayer":d=a.getImages();r.forEach(d,function(b,d){b.visible&&b.href&&(c={id:a.id+"_image"+d,type:"image",title:a.id,minScale:a.minScale||0,maxScale:a.maxScale||0,
opacity:a.opacity*b.opacity,extent:b.extent.toJson()},"data:image/png;base64,"===b.href.substr(0,22)?c.imageData=b.href.substr(22):c.url=b.href,g.push(c))});break;case "esri.layers.VectorTileLayer":c.type="image";c.url&&delete c.url;d=this._vtlExtent||b.extent.offset(0,0);var t=e.exportOptions&&e.exportOptions.dpi||96,k={format:"png",pixelRatio:t/96};"MAP_ONLY"!==e.layout||!e.preserveScale||e.outScale&&e.outScale!==b.getScale()||96!==t||!e.exportOptions||e.exportOptions.width%2===b.width%2&&e.exportOptions.height%
2===b.height%2||(k.area={x:0,y:0,width:b.width,height:b.height},e.exportOptions.width%2!==b.width%2&&--k.area.width,e.exportOptions.height%2!==b.height%2&&--k.area.height,this._vtlExtent||(t=b.toMap({x:k.area.width,y:k.area.height}),d.update(d.xmin,t.y,t.x,d.ymax,d.spatialReference),this._vtlExtent=d));c.extent=d._normalize(!0).toJson();d=a.takeScreenshot(k);d.isResolved()?d.then(function(a){"data:image/png;base64,"===a.dataURL.substr(0,22)&&(c.imageData=a.dataURL.substr(22))}):console.error("PrintTask: VectorTileLayer.takeScreenshot() returned an unresolved Promise");
c.imageData&&g.push(c);break;case "esri.layers.WebTiledLayer":d=a.url.replace(/\$\{/g,"{");c=h.mixin(c,{type:"WebTiledLayer",urlTemplate:d,credits:a.copyright});a.subDomains&&0<a.subDomains.length&&(c.subDomains=a.subDomains);a._wmtsInfo&&(c.wmtsInfo=a._wmtsInfo);delete c.url;g.push(c);break;default:if(a.getTileUrl||a.getImageUrl)c=h.mixin(c,{url:a.url}),g.push(c)}n=r.map(b.graphicsLayerIds,b.getLayer,b);for(f=0;f<n.length;f++)a=n[f],a.isFeatureReductionActive&&a.isFeatureReductionActive()&&(a.getSingleGraphics().length?
n.splice(++f,0,a.getFeatureReductionLayer()):n[f]=a.getFeatureReductionLayer());for(f=0;f<n.length;f++)if(a=n[f],a.loaded&&a.visible&&(!q||a.isVisibleAtScale(q)))switch(d=a.declaredClass,d){case "esri.layers.FeatureLayer":case "esri.layers.LabelLayer":case "esri.layers.CSVLayer":case "esri.layers.StreamLayer":if("esri.layers.LabelLayer"===d&&!e.showLabels||a.renderer&&"esri.renderer.HeatmapRenderer"===a.renderer.declaredClass)continue;d=null;a.url&&a.renderer&&("esri.renderer.ScaleDependentRenderer"===
a.renderer.declaredClass?"scale"===a.renderer.rangeType?d=a.renderer.getRendererInfoByScale(b.getScale())&&a.renderer.getRendererInfoByScale(b.getScale()).renderer:"zoom"===a.renderer.rangeType&&(d=a.renderer.getRendererInfoByZoom(b.getZoom())&&a.renderer.getRendererInfoByZoom(b.getZoom()).renderer):d=a.renderer);if(d&&("esri.renderer.SimpleRenderer"===d.declaredClass||"esri.renderer.TemporalRenderer"===d.declaredClass||h.isString(d.attributeField)&&a._getField(d.attributeField,!0))&&!d.valueExpression&&
!this._isFeatureCollectionRequired(d,a)&&"esri.renderer.DotDensityRenderer"!==d.declaredClass&&"esri.layers.CSVLayer"!==a.declaredClass&&"esri.layers.StreamLayer"!==a.declaredClass)if(c={id:a.id,title:h.getObject("arcgisProps.title",!1,a)||a.id,opacity:a.opacity,minScale:a.minScale||0,maxScale:a.maxScale||0,layerDefinition:{drawingInfo:{renderer:d.toJson({useLegacyRotationProperties:!0})}}},c=h.mixin(c,this._getUrlAndToken(a)),"esri.renderer.TemporalRenderer"===d.declaredClass&&(k=c.layerDefinition.drawingInfo,
k.latestObservationRenderer=k.renderer.latestObservationRenderer,k.trackLinesRenderer=k.renderer.trackRenderer,k.observationAger=k.renderer.observationAger,k.renderer=k.renderer.observationRenderer,a._trackIdField&&(c.layerDefinition.timeInfo={trackIdField:a._trackIdField})),this._convertSvgRenderer(c.layerDefinition.drawingInfo.renderer),1>a.opacity||"esri.renderer.TemporalRenderer"===d.declaredClass||this._updateLayerOpacity(c))if(a._params.source&&(d=a._params.source.toJson(),h.mixin(c.layerDefinition,
{source:d})),a.getDefinitionExpression()&&h.mixin(c.layerDefinition,{definitionExpression:a.getDefinitionExpression()}),2!==a.mode)0<a.getSelectedFeatures().length&&(d=r.map(a.getSelectedFeatures(),function(b){return b.attributes[a.objectIdField]}),0<d.length&&a.getSelectionSymbol()&&h.mixin(c,{selectionObjectIds:d,selectionSymbol:a.getSelectionSymbol().toJson()}));else{d=r.map(a.getSelectedFeatures(),function(b){return b.attributes[a.objectIdField]});if(0===d.length||!a._params.drawMode)break;h.mixin(c.layerDefinition,
{objectIds:d});d=null;a.getSelectionSymbol()&&(d=new L(a.getSelectionSymbol()));h.mixin(c.layerDefinition.drawingInfo,{renderer:d&&d.toJson()})}else c=this._createFeatureCollection(a,b);else c=d&&(d.valueExpression||this._isFeatureCollectionRequired(d,a)||"esri.renderer.DotDensityRenderer"===d.declaredClass)?this._createFeatureCollection(a,b,d):this._createFeatureCollection(a,b);if(!c)continue;g.push(c);this.allLayerslegend&&this.allLayerslegend.push({id:a.id});break;case "esri.layers._GraphicsLayer":case "esri.layers.GraphicsLayer":case "esri.layers.WFSLayer":c=
this._createFeatureCollection(a,b);if(!c)continue;g.push(c);this.allLayerslegend&&this.allLayerslegend.push({id:a.id});break;case "esri.layers.ArcGISImageServiceVectorLayer":c={id:a.id,title:h.getObject("arcgisProps.title",!1,a)||a.id,opacity:a.opacity,minScale:a.minScale||0,maxScale:a.maxScale||0,visibility:a.visible,symbolTileSize:a.symbolTileSize,layerDefinition:{drawingInfo:{renderer:a.renderer.toJson({useLegacyRotationProperties:!0})}}},c=h.mixin(c,this._getUrlAndToken(a)),a.mosaicRule&&h.mixin(c,
{mosaicRule:a.mosaicRule.toJson()}),g.push(c),this.allLayerslegend&&this.allLayerslegend.push({id:a.id})}q&&r.forEach(g,function(a){a.minScale=0;a.maxScale=0});b.graphics&&0<b.graphics.graphics.length&&(c=this._createFeatureCollection(b.graphics,b))&&g.push(c);b._labels&&e.showLabels&&(c=this._createFeatureCollection(b._labels,b))&&g.push(c);r.forEach(g,function(a,b,c){a._isRefLayer&&(delete a._isRefLayer,c.splice(b,1),c.push(a))});return g},_getUrlAndToken:function(b){return{token:b._getToken(),
url:b._url?b._url.path:null}},_updateLayerOpacity:function(b){var e=this._colorEvaluator(b),e=r.filter(e,function(a){return h.isArray(a)&&4===a.length}),f=!0;if(e.length){var a=e[0][3],d;for(d=1;d<e.length;d++)if(a!==e[d][3]){f=!1;break}if(f)for(b.opacity=a/255,d=0;d<e.length;d++)e[d][3]=255}return f},_isFeatureCollectionRequired:function(b,e){if(e&&e.isFeatureReductionActive&&e.isFeatureReductionActive())return!0;var f=!1,a=this._getVariable(b,"rotationInfo",!1);a&&(f=(f=a.field)&&h.isFunction(f)||
a.valueExpression);return b.hasVisualVariables("sizeInfo")||b.hasVisualVariables("colorInfo")||b.hasVisualVariables("opacityInfo")||f},_getVariable:function(b,e,f){var a;b&&(a=(b=b.getVisualVariablesForType(e,f))&&b[0]);return a},_applyVisualVariables:function(b,e){var f=e.renderer,a=e.graphic,d=e.symbol,c=e.mapResolution,g=e.mapScale,h=d.type;if("textsymbol"!==h&&"shieldlabelsymbol"!==h){var n=this._getVariable(f,"sizeInfo",!1),l=this._getVariable(f,"colorInfo",!1),k=this._getVariable(f,"opacityInfo",
!1),m=this._getVariable(f,"rotationInfo",!1);d instanceof M&&(n=this._getVariable(f,"sizeInfo","outline")||n);c=n?f.getSize(a,{sizeInfo:n,shape:"simplemarkersymbol"===h?d.style:null,resolution:c,scale:g}):a.size;null!=c&&("simplemarkersymbol"===h?b.size=u.px2pt(c):"picturemarkersymbol"===h?(g=d.width/d.height*c,b.width=u.px2pt(g),b.height=u.px2pt(c),0!==d.xoffset&&(b.xoffset=u.px2pt(d.xoffset/d.width*g)),0!==d.yoffset&&(b.yoffset=u.px2pt(d.yoffset/d.height*c))):"simplelinesymbol"===h?b.width=u.px2pt(c):
b.outline&&(b.outline.width=u.px2pt(c)));l&&(!(d=f.getColor(a,{colorInfo:l}))||"simplemarkersymbol"!==h&&"simplelinesymbol"!==h&&"simplefillsymbol"!==h||(b.color=H.toJsonColor(d)));k&&(h=f.getOpacity(a,{opacityInfo:k}),null!=h&&b.color&&(b.color[3]=Math.round(255*h)));m&&(f=f.getRotationAngle(a,{rotationInfo:m}))&&(b.angle=-f)}}});B("extend-esri")&&h.setObject("tasks.PrintTask",v,F);return v});