text: // All material copyright ESRI, All Rights Reserved, unless otherwise specified.
  // See https://js.arcgis.com/4.10/esri/copyright.txt for details.
  //>>built
  define("require exports ../core/tsSupport/declareExtendsHelper ../core/tsSupport/decorateHelper dojo/i18n!./Print/nls/Print ../core/Collection ../core/Logger ../core/urlUtils ../core/watchUtils ../core/accessorSupport/decorators ../tasks/support/PrintTemplate ./Widget ./Print/FileLink ./Print/PrintViewModel ./Print/TemplateOptions ./support/widget".split(" "),function(F,G,z,g,c,A,B,C,k,f,D,E,p,v,w,a){var x=A.ofType(p),m=B.getLogger("esri.widgets.Print");return function(y){function e(b){b=y.call(this)||
  this;b._exportedFileNameMap={};b._layoutTabSelected=!0;b._advancedOptionsVisibleForLayout=!1;b._advancedOptionsVisibleForMapOnly=!1;b._pendingExportScroll=!1;b._rootNode=null;b._awaitingServerResponse=!1;b.exportedLinks=new x;b.iconClass="esri-icon-printer";b.label=c.widgetLabel;b.templateOptions=new w;b.printServiceUrl=null;b.view=null;b.viewModel=new v;return b}z(e,y);e.prototype.postInitialize=function(){var b=this;this.own([k.init(this,"viewModel.templatesInfo",function(a){var d=b.templateOptions,
  c=d.format,d=d.layout;if(a){var h=d===a.layout.defaultValue||d&&"MAP_ONLY"===d.toUpperCase()||a.layout.choiceList&&-1<a.layout.choiceList.indexOf(d),e=c===a.format.defaultValue||a.format.choiceList&&-1<a.format.choiceList.indexOf(c);h||(d&&m.warn("User sets an invalid layout, resetting it to the default valid one..."),b.templateOptions.layout=a.layout.defaultValue);e||(c&&m.warn("User sets an invalid format, resetting it to the default valid one..."),b.templateOptions.format=a.format.defaultValue);
  d&&"MAP_ONLY"===d.toUpperCase()&&(b._layoutTabSelected=!1)}}),k.init(this,"templateOptions.format",function(a){var d=b.viewModel.templatesInfo;if(d&&a){var c=!1;d.format.choiceList&&d.format.choiceList.forEach(function(d){d.toUpperCase()===a.toUpperCase()&&(b.templateOptions.format=d,c=!0)});c||(b.templateOptions.format=d.format.defaultValue,m.warn("User sets an invalid format, resetting it to the default valid one..."));b.scheduleRender()}}),k.init(this,"templateOptions.layout",function(a){var d=
  b.viewModel.templatesInfo;if(d&&a){b._layoutTabSelected="MAP_ONLY"!==a.toUpperCase();var c=!b._layoutTabSelected;c||d.layout.choiceList&&d.layout.choiceList.forEach(function(d){d.toUpperCase()===a.toUpperCase()&&(b.templateOptions.layout=d,c=!0)});c||(b.templateOptions.layout=d.layout.defaultValue,m.warn("User sets an invalid layout, resetting it to the default valid one..."));b.scheduleRender()}}),k.init(this,"templateOptions.dpi",function(a){0>=a?b.templateOptions.dpi=1:b.scheduleRender()}),k.init(this,
  "viewModel.view.scale",function(a){var d=b.templateOptions,c=d.scale;d.scaleEnabled&&c||(b.templateOptions.scale=a)}),k.whenOnce(this,"printServiceUrl",function(){var a=setTimeout(function(){b._awaitingServerResponse=!0;b.scheduleRender()},500);b.viewModel.load().then(function(){return clearTimeout(a)})})]);var a=this.templateOptions,c=a.height;this.templateOptions.width=a.width||800;this.templateOptions.height=c||1100};e.prototype.render=function(){var b,d=this.templateOptions,h=d.attributionEnabled,
  e=d.author,u=d.copyright,r=d.dpi,g=d.format,f=d.height,k=d.layout,m=d.legendEnabled,t=d.title,q=d.scaleEnabled,p=d.scale,d=d.width,t=a.tsx("div",{class:"esri-print__form-section-container"},a.tsx("label",null,this._layoutTabSelected?c.title:c.fileName,a.tsx("input",{type:"text",tabIndex:0,placeholder:this._layoutTabSelected?c.titlePlaceHolder:c.fileNamePlaceHolder,class:this.classes("esri-print__input-text","esri-input"),value:t,"data-input-name":"title",oninput:this._updateInputValue,bind:this}))),
  l=this.get("viewModel.templatesInfo.format.choiceList")||[],l=0<l.length?l.map(function(b){return a.tsx("option",{key:b,selected:b===g,value:b},b.toUpperCase())}):a.tsx("option",{key:"format-default-option"},c.formatDefaultOption),l=a.tsx("div",{class:"esri-print__form-section-container"},a.tsx("label",null,c.fileFormatTitle,a.tsx("select",{class:"esri-select",onchange:this._updateFromOption,"data-target-property":"format",bind:this},l))),n=this.get("viewModel.templatesInfo.layout.choiceList")||[],
  n=0<n.length?n.map(function(b){return a.tsx("option",{key:b,selected:b===k,value:b},c[b]||b)}):a.tsx("option",{key:"layout-default-option"},c.layoutDefaultOption),n=a.tsx("div",{class:"esri-print__form-section-container"},a.tsx("label",null,c.layoutTitle,a.tsx("select",{class:"esri-select",onchange:this._updateFromOption,"data-target-property":"layout",bind:this},n))),r=a.tsx("div",{class:"esri-print__form-section-container"},a.tsx("label",null,c.dpi,a.tsx("input",{type:"number",class:this.classes("esri-print__input-text",
  "esri-input"),"data-input-name":"dpi",oninput:this._updateInputValue,value:""+r,min:"1",tabIndex:0,bind:this}))),q=a.tsx("div",{class:this.classes("esri-print__scale-info-container","esri-print__form-section-container")},a.tsx("label",null,a.tsx("input",{"data-option-name":"scaleEnabled",checked:q,type:"checkbox",tabIndex:0,onchange:this._toggleInputValue,bind:this}),c.scale),a.tsx("div",{class:"esri-print__scale-input-container"},a.tsx("input",{"aria-label":c.scaleLabel,"aria-valuenow":""+p,role:"spinbutton",
  type:"number",class:this.classes("esri-print__input-text","esri-input","esri-print__scale-input"),tabIndex:0,"data-input-name":"scale",oninput:this._updateInputValue,disabled:!q,value:""+p,bind:this}),a.tsx("button",{role:"button","aria-label":c.reset,class:this.classes("esri-widget--button","esri-print__refresh-button","esri-icon-refresh"),tabIndex:0,onclick:this._resetToCurrentScale,bind:this}))),e=this._advancedOptionsVisibleForLayout?a.tsx("div",{"aria-labelledby":this.id+"__advancedOptionsForLayout",
  class:"esri-print__advanced-options-container"},q,a.tsx("div",{class:this.classes("esri-print__author-info-container","esri-print__form-section-container")},a.tsx("label",null,c.author,a.tsx("input",{type:"text",value:e,class:this.classes("esri-print__input-text","esri-input"),tabIndex:0,"data-input-name":"author",oninput:this._updateInputValue,bind:this}))),a.tsx("div",{class:this.classes("esri-print__copyright-info-container","esri-print__form-section-container")},a.tsx("label",null,c.copyright,
  a.tsx("input",{type:"text",class:this.classes("esri-print__input-text","esri-input"),tabIndex:0,value:u,"data-input-name":"copyright",oninput:this._updateInputValue,bind:this}))),r,a.tsx("div",{class:this.classes("esri-print__legend-info-container","esri-print__form-section-container")},a.tsx("label",null,a.tsx("input",{type:"checkbox","data-option-name":"legendEnabled",tabIndex:0,checked:m,onchange:this._toggleInputValue,bind:this}),c.legend))):null,h=this._advancedOptionsVisibleForMapOnly?a.tsx("div",
  {"aria-labelledby":this.id+"__advancedOptionsForMapOnly",class:"esri-print__advanced-options-container"},q,r,a.tsx("div",{class:"esri-print__form-section-container"},a.tsx("label",null,a.tsx("input",{"data-option-name":"attributionEnabled",type:"checkbox",onchange:this._toggleInputValue,tabIndex:0,checked:h,bind:this}),c.attribution))):null,f=this._layoutTabSelected?a.tsx("section",{key:"esri-print__layoutContent",id:this.id+"__layoutContent","aria-labelledby":this.id+"__layoutTab",class:"esri-print__layout-section",
  role:"tabpanel","aria-selected":this._layoutTabSelected},a.tsx("div",{class:"esri-print__panel-container"},t,n,this._layoutTabSelected?l:null),a.tsx("div",{class:this.classes("esri-print__panel-container","esri-print__advanced-options-section")},a.tsx("button",{"aria-label":c.advancedOptions,"aria-expanded":this._advancedOptionsVisibleForLayout?"true":"false",role:"button",class:"esri-print__advanced-options-button",onclick:this._showAdvancedOptions,bind:this},a.tsx("div",{class:"esri-print__advanced-options-button-container"},
  a.tsx("span",{"aria-hidden":"true",class:this.classes("esri-icon-right-triangle-arrow","esri-print__advanced-options-button-icon--closed")}),a.tsx("span",{"aria-hidden":"true",class:this.classes("esri-icon-left-triangle-arrow","esri-print__advanced-options-button-icon--closed-rtl")}),a.tsx("span",{"aria-hidden":"true",class:this.classes("esri-icon-down-arrow","esri-print__advanced-options-button-icon--opened")}),a.tsx("span",{class:"esri-print__advanced-options-button-title"},c.advancedOptions))),
  e)):a.tsx("section",{key:"esri-print__mapOnlyContent",id:this.id+"__mapOnlyContent","aria-selected":!this._layoutTabSelected,"aria-labelledby":this.id+"__mapOnlyTab",class:"esri-print__map-only-section",role:"tabpanel"},a.tsx("div",{class:"esri-print__panel-container"},t,this._layoutTabSelected?null:l,a.tsx("div",{class:this.classes("esri-print__size-container","esri-print__form-section-container")},a.tsx("div",{class:"esri-print__width-container"},a.tsx("label",null,c.width,a.tsx("input",{type:"text",
  class:this.classes("esri-print__input-text","esri-input"),"data-input-name":"width",onchange:this._updateInputValue,value:""+d,tabIndex:0,bind:this}))),a.tsx("div",{class:"esri-print__height-container"},a.tsx("label",null,c.height,a.tsx("input",{type:"text",class:this.classes("esri-print__input-text","esri-input"),"data-input-name":"height",onchange:this._updateInputValue,value:""+f,tabIndex:0,bind:this}))),a.tsx("button",{role:"button","aria-label":c.swap,class:this.classes("esri-widget--button",
  "esri-print__swap-button","esri-icon-swap"),onclick:this._switchInput,tabIndex:0,bind:this})),a.tsx("div",{class:this.classes("esri-print__panel-container","esri-print__advanced-options-section")},a.tsx("button",{"aria-label":c.advancedOptions,"aria-expanded":this._advancedOptionsVisibleForMapOnly?"true":"false",role:"button",class:"esri-print__advanced-options-button",onclick:this._showAdvancedOptions,bind:this},a.tsx("div",{class:"esri-print__advanced-options-button-container"},a.tsx("span",{"aria-hidden":"true",
  class:this.classes("esri-icon-right-triangle-arrow","esri-print__advanced-options-button-icon--closed")}),a.tsx("span",{"aria-hidden":"true",class:this.classes("esri-icon-left-triangle-arrow","esri-print__advanced-options-button-icon--closed-rtl")}),a.tsx("span",{"aria-hidden":"true",class:this.classes("esri-icon-down-arrow","esri-print__advanced-options-button-icon--opened")}),a.tsx("span",{class:"esri-print__advanced-options-button-title"},c.advancedOptions))),h))),h=this.exportedLinks.toArray(),
  d=this._renderExportedLink(h),e=(b={},b["esri-button--disabled"]=!k&&!g,b);b=null!=this.get("view")&&"2d"!==this.get("view.type");u=a.tsx("div",{class:"esri-print__panel--error"},b?c.sceneViewError:c.serviceError);f=a.tsx("div",null,a.tsx("ul",{class:"esri-print__layout-tab-list",role:"tablist",onclick:this._toggleLayoutPanel,onkeydown:this._toggleLayoutPanel,bind:this},a.tsx("li",{id:this.id+"__layoutTab","data-tab-id":"layoutTab",class:"esri-print__layout-tab",role:"tab",tabIndex:0,"aria-selected":""+
  this._layoutTabSelected},c.layoutTab),a.tsx("li",{id:this.id+"__mapOnlyTab","data-tab-id":"mapOnlyTab",class:"esri-print__layout-tab",role:"tab",tabIndex:0,"aria-selected":""+!this._layoutTabSelected},c.mapOnlyTab)),f,a.tsx("button",{"aria-label":c.exportDescription,role:"button",class:this.classes("esri-print__export-button","esri-button",e),tabIndex:0,onclick:this._handlePrintMap,bind:this},c.export),a.tsx("div",{class:"esri-print__export-panel-container",afterUpdate:this._scrollExportIntoView,
  onclick:this._removeLink,bind:this},a.tsx("h3",{class:this.classes("esri-print__export-title","esri-widget__heading")},c.exportText),0<h.length?null:a.tsx("div",null,a.tsx("div",null,c.exportHint)),d));b=a.tsx("div",null,a.tsx("div",{class:"esri-print__container"},a.tsx("header",{class:"esri-print__header-title"},c.export),this.error||!this.printServiceUrl||b||!this.view?u:f));b="initializing"===this.get("viewModel.state")?this._renderLoader():b;return a.tsx("div",{afterCreate:a.storeNode,bind:this,
  class:"esri-print esri-widget esri-widget--panel","data-node-ref":"_rootNode"},b)};e.prototype._renderLoader=function(){var b,d=(b={},b["esri-print__loader"]=this._awaitingServerResponse,b);return a.tsx("div",{class:this.classes(d),key:"loader"})};e.prototype._createFileLink=function(b){var a=b.layoutOptions.titleText||c.untitled;b=b.format.toLowerCase();b=-1<b.indexOf("png")?"png":b;var h=a+b;void 0!==this._exportedFileNameMap[h]?this._exportedFileNameMap[h]++:this._exportedFileNameMap[h]=0;return new p({name:a,
  extension:b,count:this._exportedFileNameMap[h]})};e.prototype._toPrintTemplate=function(b){var a=b.dpi,c=b.height,e=b.legendEnabled,f=b.width;b=new D({attributionVisible:b.attributionEnabled,layoutOptions:{authorText:b.author||"",copyrightText:b.copyright||"",titleText:b.title||""},forceFeatureAttributes:b.forceFeatureAttributes,format:b.format,layout:b.layout,outScale:b.scale});f&&(b.exportOptions.width=f);c&&(b.exportOptions.height=c);a&&(b.exportOptions.dpi=a);e||(b.layoutOptions.legendLayers=
  []);return b};e.prototype._resetToCurrentScale=function(){this.templateOptions.scale=this.viewModel.view.scale};e.prototype._updateInputValue=function(b){b=b.target;var a=b.getAttribute("data-input-name");this.templateOptions[a]=b.value};e.prototype._handlePrintMap=function(){var b=this;this._pendingExportScroll=!0;var a=this._toPrintTemplate(this.templateOptions),c=this._createFileLink(a);this.exportedLinks.add(c);this.viewModel.print(a).then(function(b){c.set({url:b&&b.url,state:"ready"})}).catch(function(){c.set({state:"error"})}).then(function(){return b.scheduleRender()})};
  e.prototype._updateFromOption=function(b){var a=b.target;b=a.selectedOptions?a.selectedOptions.item(0).value:a.options[a.selectedIndex].value;a=a.getAttribute("data-target-property");this.templateOptions[a]=b};e.prototype._switchInput=function(){var a;a=[this.templateOptions.height,this.templateOptions.width];this.templateOptions.width=a[0];this.templateOptions.height=a[1]};e.prototype._showAdvancedOptions=function(){this._layoutTabSelected?this._advancedOptionsVisibleForLayout=!this._advancedOptionsVisibleForLayout:
  this._advancedOptionsVisibleForMapOnly=!this._advancedOptionsVisibleForMapOnly};e.prototype._scrollExportIntoView=function(){if(this._pendingExportScroll){this._pendingExportScroll=!1;var a=this._rootNode,d=this._rootNode,d=d.scrollHeight-d.clientHeight;0<d&&(a.scrollTop=d)}};e.prototype._toggleInputValue=function(a){a=a.target;var b=a.getAttribute("data-option-name");this.templateOptions[b]=a.checked;"scaleEnabled"===b&&(this.viewModel.scaleEnabled=this.templateOptions.scaleEnabled,this.templateOptions[b]||
  this._resetToCurrentScale())};e.prototype._removeLink=function(a){(a=a.target["data-item"])&&"error"===a.state&&this.exportedLinks.remove(a)};e.prototype._renderExportedLink=function(b){var d=this;return b.map(function(b){var e,f,g,h=(e={},e["esri-widget__anchor--disabled"]="pending"===b.state||"error"===b.state,e);e=(f={},f["esri-icon-loading-indicator"]="pending"===b.state,f["esri-rotating"]="pending"===b.state,f["esri-icon-download"]="ready"===b.state,f["esri-icon-error"]="error"===b.state,f["esri-print__exported-file--error"]=
  "error"===b.state,f);f=(g={},g["esri-print__exported-file--error"]="error"===b.state,g);(g=""===b.url?null:b.url)&&(g=C.addProxy(g));return a.tsx("div",{"aria-label":"pending"===b.state?c.pending:"ready"===b.state?c.ready:c.error,key:b.formattedName,class:"esri-print__exported-file"},a.tsx("a",{"aria-label":b.formattedName+". "+c.linkReady,href:g,tabIndex:0,target:"_blank",class:d.classes("esri-widget__anchor esri-print__exported-file-link",h)},a.tsx("span",{"data-item":b,class:d.classes(e)}),a.tsx("span",
  {"data-item":b,class:d.classes("esri-print__exported-file-link-title",f)},b.formattedName)))})};e.prototype._resetInputValue=function(){this.templateOptions.title=""};e.prototype._toggleLayoutPanel=function(a){this._resetInputValue();(this._layoutTabSelected="layoutTab"===a.target.getAttribute("data-tab-id"))?(a=this.get("viewModel.templatesInfo.layout.choiceList"),this.templateOptions.layout=a&&a[0]):this.templateOptions.layout="MAP_ONLY"};g([f.property({type:x}),a.renderable()],e.prototype,"exportedLinks",
  void 0);g([f.property()],e.prototype,"iconClass",void 0);g([f.property()],e.prototype,"label",void 0);g([a.renderable(),f.property({type:w})],e.prototype,"templateOptions",void 0);g([f.aliasOf("viewModel.error")],e.prototype,"error",void 0);g([f.aliasOf("viewModel.printServiceUrl")],e.prototype,"printServiceUrl",void 0);g([f.aliasOf("viewModel.view"),a.renderable()],e.prototype,"view",void 0);g([f.property({type:v}),a.renderable(["viewModel.templatesInfo","viewModel.state"])],e.prototype,"viewModel",
  void 0);g([a.accessibleHandler()],e.prototype,"_toggleLayoutPanel",null);return e=g([f.subclass("esri.widgets.Print")],e)}(f.declared(E))});