// 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/dijit/geoenrichment/ReportPlayer/dataProviders/commands/CreatePDFCommand","dojo/_base/declare dojo/_base/lang dojo/when esri/dijit/geoenrichment/utils/FileUtil esri/dijit/geoenrichment/utils/MaskUtil esri/dijit/geoenrichment/utils/JsonXmlConverter esri/dijit/geoenrichment/utils/requests/FileContent ./CreateHTMLCommand ./supportClasses/PlayerCommands ./supportClasses/ProgressSteps ./createHTML/CommandMode ../supportClasses/GEUtil esri/dijit/geoenrichment/ReportPlayer/core/conversion/reportingEngine/converters/DocumentConverter esri/dijit/geoenrichment/ReportPlayer/core/conversion/ConversionUtil esri/dijit/geoenrichment/ReportPlayer/core/supportClasses/DocumentOptions esri/dijit/geoenrichment/ReportPlayer/core/sections/SectionTypes dojo/i18n!../../../../../nls/jsapi ../../_devConfig".split(" "),
function(l,m,h,n,p,q,r,t,u,b,v,k,w,g,x,y,a,z){a=a.geoenrichment.dijit.ReportPlayer.ReportPlayer;var A={buildLayoutXML:function(f){var e=w.buildDocumentTag({report:{templateJson:{documentOptions:m.mixin({},f.documentOptions,{left:0,right:0,top:0,bottom:0})}}}).documentTag,b=x.getPageBox(f.documentOptions),c=g.pxToPt(b.w),a=g.pxToPt(b.h);f.svgStrings.forEach(function(d,b){e.tags.push({name:"section",attributes:{type:y.DETAILS},tags:[{name:"img",attributes:{left:0,top:0,width:c,height:a},tags:[{text:"__svgString__"+
b+"__svgString__"}]}]});b<f.svgStrings.length-1&&e.tags.push({name:"pageBreak"})});var d=q.parseJson(e);f.svgStrings.forEach(function(c,b){d=d.replace("__svgString__"+b+"__svgString__",c)});return d}};return l(t,{id:u.PDF,label:a.createPDFCommandLabel,errorMessage:a.createPDFError,_saveFiles:!1,_stopPrintableContainer:!1,_mode:v.SVG,_requestSizeLimit:9E6,execute:function(f,e,a){var c=this,g=function(b){if(!e.skipErrorNotification)return c._handleError(b)};return h(this.inherited(arguments),function(d){if(d.svgStrings){var a=
A.buildLayoutXML(d);z.createPDFCommand.removeUnicodeChars&&(a=p.removeXMLMasks(a,"X"));if(e.returnLayoutXMLOnly)return a;d={report:f.getReportTitle(),format:"pdf",f:"bin"};a=r.fromFileData("report.xml",a);delete a.filename;d["report.xml"]=a;return k.formatReport(f.getReportData().config.geoenrichmentUrl,d).then(function(a){if(a&&a.data){e.creditsTaskID&&k.consumeCredits(f.getReportData().config.geoenrichmentUrl,e.creditsTaskID);c._stepFinished(b.FORMAT_REPORT);var d=f.getReportTitle()+".pdf";e.skipSavingFile||
n.saveAs(a.data,d);return{name:d,data:a.data}}g()})}}).otherwise(g).always(function(a){return h(c._printableContainer&&c._printableContainer.stop(),function(){return a})})},_stepFinished:function(a,e,g){if(this._currentProgressBack){var c=0;switch(a){case b.REPLACE_MAPS:c=10;break;case b.PREPARE_DOM:c=20;break;case b.RENDER_PAGE:c=20+60*e/g;break;case b.UNSET_LAYOUT:c=90;break;case b.FORMAT_REPORT:c=100}this._currentProgressBack(c/100)}}})});