YUI.add("file-html5",function(d,e){d.Lang;var l=d.bind,t=d.config.win,i=function(e){var t=e;i.superclass.constructor.apply(this,arguments),t&&i.canUpload()&&(this.get("file")||this._set("file",t),this.get("name")||this._set("name",t.name||t.fileName),this.get("size")!=(t.size||t.fileSize)&&this._set("size",t.size||t.fileSize),this.get("type")||this._set("type",t.type),t.hasOwnProperty("lastModifiedDate")&&!this.get("dateModified")&&this._set("dateModified",t.lastModifiedDate))};d.extend(i,d.Base,{initializer:function(e){this.get("id")||this._set("id",d.guid("file"))},_uploadEventHandler:function(e){var t,i,a=this.get("xhr");switch(e.type){case"progress":this.fire("uploadprogress",{originEvent:e,bytesLoaded:e.loaded,bytesTotal:this.get("size"),percentLoaded:Math.min(100,Math.round(1e4*e.loaded/this.get("size"))/100)}),this._set("bytesUploaded",e.loaded);break;case"load":200<=a.status&&a.status<=299?(this.fire("uploadcomplete",{originEvent:e,data:e.target.responseText}),t=a.upload,i=this.get("boundEventHandler"),t.removeEventListener("progress",i),t.removeEventListener("error",i),t.removeEventListener("abort",i),a.removeEventListener("load",i),a.removeEventListener("error",i),a.removeEventListener("readystatechange",i),this._set("xhr",null)):this.fire("uploaderror",{originEvent:e,data:a.responseText,status:a.status,statusText:a.statusText,source:"http"});break;case"error":this.fire("uploaderror",{originEvent:e,data:a.responseText,status:a.status,statusText:a.statusText,source:"io"});break;case"abort":this.fire("uploadcancel",{originEvent:e});break;case"readystatechange":this.fire("readystatechange",{readyState:e.target.readyState,originEvent:e})}},startUpload:function(e,t,i){this._set("bytesUploaded",0),this._set("xhr",new XMLHttpRequest),this._set("boundEventHandler",l(this._uploadEventHandler,this));var a=new FormData,i=i||"Filedata",n=this.get("xhr"),s=this.get("xhr").upload,r=this.get("boundEventHandler");d.each(t,function(e,t){a.append(t,e)}),a.append(i,this.get("file")),n.addEventListener("loadstart",r,!1),s.addEventListener("progress",r,!1),n.addEventListener("load",r,!1),n.addEventListener("error",r,!1),s.addEventListener("error",r,!1),s.addEventListener("abort",r,!1),n.addEventListener("abort",r,!1),n.addEventListener("loadend",r,!1),n.addEventListener("readystatechange",r,!1),n.open("POST",e,!0),n.withCredentials=this.get("xhrWithCredentials"),d.each(this.get("xhrHeaders"),function(e,t){n.setRequestHeader(t,e)}),n.send(a),this.fire("uploadstart",{xhr:n})},cancelUpload:function(){var e=this.get("xhr");e&&e.abort()}},{NAME:"file",TYPE:"html5",ATTRS:{id:{writeOnce:"initOnly",value:null},size:{writeOnce:"initOnly",value:0},name:{writeOnce:"initOnly",value:null},dateCreated:{writeOnce:"initOnly",value:null},dateModified:{writeOnce:"initOnly",value:null},bytesUploaded:{readOnly:!0,value:0},type:{writeOnce:"initOnly",value:null},file:{writeOnce:"initOnly",value:null},xhr:{readOnly:!0,value:null},xhrHeaders:{value:{}},xhrWithCredentials:{value:!0},boundEventHandler:{readOnly:!0,value:null}},isValidFile:function(e){return t&&t.File&&e instanceof File},canUpload:function(){return t&&t.FormData&&t.XMLHttpRequest}}),d.FileHTML5=i},"patched-v3.18.4",{requires:["base"]});