// All material copyright ESRI, All Rights Reserved, unless otherwise specified.
// See http://@sbaseurl@/jsapi/jsapi/esri/copyright.txt and http://www.arcgis.com/apps/webappbuilder/copyright.txt for details.

//>>built
require({cache:{"url:widgets/SmartEditor/AttachmentUploader.html":"\x3cdiv class\x3d\"attachmentUploader\" dojoattachpoint\x3d\"attachmentUploader\"\x3e\r\n    \x3cbr /\x3e\r\n    \x3cdiv\x3e\r\n        \x3cb\x3e${nls.NLS_attachments}\x3c/b\x3e\r\n        \x3chr /\x3e\r\n\r\n        \x3cdiv dojoattachpoint\x3d'_attachmentList' style\x3d'white-space:nowrap'\x3e\x3c/div\x3e\r\n\r\n\r\n\r\n    \x3c/div\x3e\r\n\x3c/div\x3e"}});
define("dojo/Evented dojo dojo/_base/declare dojo/_base/lang dojo/on dojo/keys dojo/dom-construct dojo/dom-style dijit/_WidgetBase dijit/_TemplatedMixin dojo/text!./AttachmentUploader.html dojo/i18n!esri/nls/jsapi".split(" "),function(m,k,n,e,g,l,h,f,p,q,r,t){return n([p,m,q],{declaredClass:"jimu-widget-smartEditor-attachmentuploader",templateString:r,widgetsInTemplate:!0,_inputCount:0,_inputIndex:1,currentAction:null,constructor:function(){this.nls=e.mixin(this.nls,t.widgets.attachmentEditor)},_fileSelected:function(a){a=
a.target||a.srcElement;0<a.value.length&&(k.style(a.parentNode.childNodes[0],"display","inline-block"),this._addInput(),"block"===f.get(this.attachmentsRequiredMsg,"display")&&f.set(this.attachmentsRequiredMsg,"display","none"));this.emit("attachmentAdded")},clear:function(){if(void 0!==this._attachmentList&&null!==this._attachmentList){for(;this._attachmentList.firstChild;)this._attachmentList.removeChild(this._attachmentList.firstChild);this._addInput()}},_deleteAttachment:function(a){a=a.target||
a.srcElement;a.parentNode.parentNode.removeChild(a.parentNode);this._hasAddedAnyAttachments()||"Required"!==this.currentAction||"none"===f.get(this.attachmentsRequiredMsg,"display")&&f.set(this.attachmentsRequiredMsg,"display","block");this.emit("attachmentDeleted")},_reflect:function(a){return a.then(function(b){return{state:"fulfilled",value:b}},function(b){return{state:"rejected",error:b}})},_addInput:function(){for(var a=0;a<this._attachmentList.childNodes.length;a++)if(this._attachmentList.childNodes[a].childNodes[this._inputIndex].value){if(0===
this._attachmentList.childNodes[a].childNodes[this._inputIndex].value.length)return}else return;a=h.create("div",{id:"delInput"+String(this._inputCount),"class":"deleteAttachment",tabindex:"0","aria-label":this.nls.deleteAttachment||this.deleteAttachmentText||"",role:"button"});a.innerHTML="X";k.style(a,"display","none");this.own(g(a,"click",e.hitch(this,this._deleteAttachment)));this.own(g(a,"keydown",e.hitch(this,function(c){c.keyCode!==l.ENTER&&c.keyCode!==l.SPACE||this._deleteAttachment(c)})));
var b=h.create("form",{id:"formInput"+String(this._inputCount)}),d=h.create("input",{id:"fileInput"+String(this._inputCount),type:"file","class":"attInput",name:"attachment"});b.appendChild(a);b.appendChild(d);this._attachmentList.appendChild(b);this.own(g(d,"change",e.hitch(this,this._fileSelected)));this._inputCount+=1},startup:function(){this._addInput()},destroy:function(){this.inherited(arguments)},postAttachments:function(a,b){if(a&&"esri.layers.FeatureLayer"===a.declaredClass&&a.getEditCapabilities&&
a.addAttachment){for(var d=[],c=0;c<this._attachmentList.childNodes.length;c++)0<this._attachmentList.childNodes[c].childNodes[this._inputIndex].value.length&&d.push(a.addAttachment(b,this._attachmentList.childNodes[c]));return 0===d.length?null:d.map(this._reflect)}},_hasAddedAnyAttachments:function(){for(var a=!1,b=0;b<this._attachmentList.childNodes.length;b++)if(this._attachmentList.childNodes[b].childNodes[this._inputIndex].value&&0<this._attachmentList.childNodes[b].childNodes[this._inputIndex].value.length){a=
!0;break}return a}})});