function AdfFileUploadUtils(a,b,d){this.Init(a,b,d)}AdfObject.createSubclass(AdfFileUploadUtils,AdfFileUploadManager);
AdfFileUploadUtils.InitClass=function(){this._DELAYED_UPLOAD_CONTENT_ID="dc";this._DELAYED_UPLOAD_FORM_ID="df";this._UPLOAD_FORM_ID="f";this._MAXIMUM_FILES="maximumFiles";this._MAX_CHUNK_SIZE="_afrChunkSize";this._COOKIES="_afrCookies";this._AUTHORIZATION_HEADER="_afrAuthorization";this._STYLE_DISPLAY_NONE="none";this._STYLE_DISPLAY_INLINE="inline";this._STYLE_VISIBILITY_VISIBLE="visible";this._STYLE_VISIBILITY_HIDDEN="hidden";this._CSS_PROPERTY_DISPLAY="display";this._CSS_PROPERTY_VISIBILITY="visibility";
this._CSS_PROPERTY_OVERFLOWY="overflowY";this._MULTIPLE_UPLOAD_PARAM="org.apache.myfaces.trinidad.UploadedFiles";this._MULTIPLE_UPLOAD_CHUNK_NUM_PARAM="X-Trinidad-chunkNum";this._MULTIPLE_UPLOAD_CHUNK_COUNT_PARAM="X-Trinidad-chunkCount";this._MULTIPLE_UPLOAD_CHUNK_FILENAME_PARAM="X-Trinidad-chunkFilename";this._MULTIPART_ENCODING="multipart/form-data";this._FORM_ENCODING="application/x-www-form-urlencoded; charset\x3dUTF-8";this._MULTIPART_FRAME="_afrInputFileFrame";this._MULTIPLE_UPLOAD_FILE_PROPERTY_PARAM=
"org.apache.myfaces.trinidad.UploadedFiles.FileProperty"};
AdfFileUploadUtils.prototype.Init=function(a,b,d){AdfFileUploadUtils.superclass.Init.call(this);this._useFileApi="undefined"!=typeof File?!0:!1;void 0===AdfAgent.AGENT.slice()?this._canSlice=!1:this._canSlice=!0;this._useFormData="undefined"!=typeof FormData?!0:!1;this._useDnD="draggable"in d&&this._useFormData&&this._canSlice?!0:!1;this._maxChunkSize=b.getProperty(AdfFileUploadUtils._MAX_CHUNK_SIZE);this._maximumFiles=b.getProperty(AdfFileUploadUtils._MAXIMUM_FILES);this._cookies=b.getProperty(AdfFileUploadUtils._COOKIES);
this._authHeader=b.getProperty(AdfFileUploadUtils._AUTHORIZATION_HEADER);this._peer=a;this._clientId=b.getClientId();this._uploadQueue=[];this._uploadResult=[];this._uploadRequestQueue=[];this._itemId=null;this._percentCompleteItems=[];this._delayedResetInputFileNode=[];this._currentlyUploading=!1};
AdfFileUploadUtils.prototype.addEventListener=function(a,b,d){a==AdfFileUploadManager.EVENT_TYPE_STATUS?(this._eventStatusListeners||(this._eventStatusListeners=[]),this._eventStatusListeners.push({listener:b,instance:d})):a==AdfFileUploadManager.EVENT_TYPE_PROGRESS?(this._eventProgressListeners||(this._eventProgressListeners=[]),this._eventProgressListeners.push({listener:b,instance:d})):a==AdfFileUploadManager.EVENT_TYPE_STATE&&(this._eventStateListeners||(this._eventStateListeners=[]),this._eventStateListeners.push({listener:b,
instance:d}))};
AdfFileUploadUtils.prototype.addFileToQueue=function(a){var b=AdfAgent.AGENT;if(this._useFormData&&this._useFileApi&&a instanceof File){var d=AdfFileUploadUtils._getFilename(a.name);this._addFileToUploadQueue(d,a.size,a)}else if(null!=a.nodeType&&"INPUT"==a.nodeName){d=!1;if(this._useFormData&&this._useFileApi){for(var e=a.files,f=0;f<e.length;f++)d=AdfFileUploadUtils._getFilename(e[f].name),this._addFileToUploadQueue(d,e[f].size,e[f]);b=b.getAttribute(a,"id");null!=b&&(b==this._inputId||b==this._fallbackInputId)&&
1<e.length?this._resetInputFileNode(a):this._delayedResetInputFileNode[AdfFileUploadUtils._getFilename(e[0].name)]=a;d=!0}d||(d=AdfFileUploadUtils._getFilename(a.value),b=null,this._useFileApi&&(b=a.files[0].size),this._addFileToUploadQueue(d,b,a),null!=this._inputId?(this._delayedContentIdCount++,this._copyAndHideInputNode(a)):this._delayedResetInputFileNode[AdfFileUploadUtils._getFilename(a.value)]=a)}};
AdfFileUploadUtils.prototype.addFileUploadQueueItem=function(a){this._itemId=a.getItemId();this._uploadQueue.push(a);this._refreshListFunctions()};AdfFileUploadUtils.prototype.addFileUploadResultItem=function(a){this._itemId=a.getItemId();this._uploadResult.push(a);this._refreshListFunctions()};AdfFileUploadUtils.prototype.cancelAllUploads=function(a){this._stopUpload=!0;this.cancelCurrentUpload(a);for(a=this._uploadQueue.length-1;0<=a;a--){var b=this._uploadQueue[a].getFilename();this.deleteFileFromQueue(b)}};
AdfFileUploadUtils.prototype.cancelCurrentUpload=function(a){this._cancelCurrentUploadAttempt=!0;var b=this._stopUpload;this._useFileApi?null!=this._currentRequest.getAdfXMLRequest()&&this._currentRequest.getAdfXMLRequest().abort():AdfAgent.AGENT.getPlatform()==AdfAgent.IE_PLATFORM?AdfPage.PAGE.getDomWindow().document.execCommand("Stop"):AdfPage.PAGE.getDomWindow().stop();if(a){a=null;if(null!=this._currentRequestItemId){var d;for(d=0;d<this._uploadQueue.length;d++)if(this._uploadQueue[d].getItemId()==
this._currentRequestItemId){a=this._uploadQueue[d];break}}null!=a&&(b?this._notifyListeners(AdfFileUploadManager.EVENT_TYPE_STATUS,new AdfFileUploadEvent(this._getComponent(),AdfFileUploadManager.EVENT_TYPE_STATUS,AdfFileUploadManager.EVENT_SOURCE_UPLOAD,AdfFileUploadManager.OPERATION_CANCEL_ALL,a,100,AdfFileUploadManager.EVENT_STATUS_COMPLETE)):this._notifyListeners(AdfFileUploadManager.EVENT_TYPE_STATUS,new AdfFileUploadEvent(this._getComponent(),AdfFileUploadManager.EVENT_TYPE_STATUS,AdfFileUploadManager.EVENT_SOURCE_UPLOAD,
AdfFileUploadManager.OPERATION_CANCEL,a,100,AdfFileUploadManager.EVENT_STATUS_COMPLETE)));this._resetUpload(!0)}};AdfFileUploadUtils.prototype.deleteFileFromQueue=function(a){this._removeFileFromUploadQueue(a)};AdfFileUploadUtils.prototype.deleteUploadedFile=function(a){this._deleteUploadedFile(a)};AdfFileUploadUtils.prototype.getFileUploadQueue=function(){this._refreshListFunctions();return this._uploadQueueFunc};
AdfFileUploadUtils.prototype.getFileUploadResults=function(){this._refreshListFunctions();return this._uploadResultFunc};AdfFileUploadUtils.prototype.isBusy=function(){return this._currentlyUploading};
AdfFileUploadUtils.prototype.load=function(a){var b=AdfAgent.AGENT,d=this._peer,e=this._getComponent();if(this._uploadSettings=a)this._inputId=this._uploadSettings.inputId,this._dropAreaId=this._uploadSettings.dropAreaId,this._fallbackInputId=this._uploadSettings.fallbackInputId;this._initNonAppletMode();this._domChangeFunc||(this._domChangeFunc=function(a){d.HandleDomChange(e,a)});this._inputId&&(this._useFormData?(a=b.getElementById(this._inputId),b.addBubbleEventListener(a,"change",this._domChangeFunc)):
this._initFallbackMode(this._inputId))};AdfFileUploadUtils.prototype.unload=function(){};AdfFileUploadUtils.prototype.removeEventListener=function(a,b,d){var e=null;a==AdfFileUploadManager.EVENT_TYPE_STATUS?e=this._eventStatusListeners:a==AdfFileUploadManager.EVENT_TYPE_PROGRESS?e=this._eventProgressListeners:a==AdfFileUploadManager.EVENT_TYPE_STATE&&(e=this._eventStateListeners);if(e)for(a=e.length-1;0<=a;a--)e[a].listener===b&&e[a].instance===d&&e.splice(a,1)};
AdfFileUploadUtils.prototype.uploadFileFromQueue=function(a){this._currentlyUploading?this._uploadRequestQueue.push(a):this._uploadFileInQueue(a)};AdfFileUploadUtils.prototype.setFileProperty=function(a,b,d){for(var e=0;e<this._uploadQueue.length;e++)if(a==this._uploadQueue[e].getFilename()){this._uploadQueue[e].setProperty(b,d);break}};AdfFileUploadUtils.prototype.uploadAllFilesFromQueue=function(){this._currentlyUploading||this._uploadFileInQueue()};
AdfFileUploadUtils.prototype._addFileToUploadQueue=function(a,b,d,e){var f=this._peer,g=this._getComponent(),h=this._validateFilename(a);if(h&&g.getValid()){if(null!=b&&(h=this._validateFilesize(b),!h||!g.getValid()))return;h=e;null==h?(null==this._itemId?this._itemId=0:this._itemId++,h=this._itemId):this._itemId=e;b=new AdfFileUploadManager.FileItem(h,a,b,d);this._uploadQueue.push(b);this._refreshListFunctions();this._notifyListeners(AdfFileUploadManager.EVENT_TYPE_STATE,new AdfFileUploadEvent(this._getComponent(),
AdfFileUploadManager.EVENT_TYPE_STATE,AdfFileUploadManager.EVENT_SOURCE_QUEUE,AdfFileUploadManager.OPERATION_ADDED,b,100,AdfFileUploadManager.EVENT_STATUS_COMPLETE));"auto"==f._submitType&&(this._currentlyUploading||f._uploadFilesInQueue(g,a))}};
AdfFileUploadUtils.prototype._addFileItemToUploadResultList=function(a){this._getUploadResultItem(a.getItemId())||(this._uploadResult.push(a),this._refreshListFunctions(),this._notifyListeners(AdfFileUploadManager.EVENT_TYPE_STATUS,new AdfFileUploadEvent(this._getComponent(),AdfFileUploadManager.EVENT_TYPE_STATUS,AdfFileUploadManager.EVENT_SOURCE_UPLOAD,AdfFileUploadManager.OPERATION_UPLOAD,a,100,AdfFileUploadManager.EVENT_STATUS_COMPLETE)),a.isSuccess()&&this._notifyListeners(AdfFileUploadManager.EVENT_TYPE_PROGRESS,
new AdfFileUploadEvent(this._getComponent(),AdfFileUploadManager.EVENT_TYPE_PROGRESS,AdfFileUploadManager.EVENT_SOURCE_UPLOAD,AdfFileUploadManager.OPERATION_UPLOAD,a,100,AdfFileUploadManager.EVENT_STATUS_COMPLETE)))};
AdfFileUploadUtils.prototype._copyAndHideInputNode=function(a){var b=AdfAgent.AGENT,d=this._clientId,e=this._getComponent(),f=b.getAttribute(a,"id"),g=AdfRichUIPeer.CreateSubId(d,AdfFileUploadUtils._DELAYED_UPLOAD_FORM_ID)+this._delayedContentIdCount,e=AdfFileUploadUtils._getIframeTransferForm(e,AdfFileUploadUtils._MULTIPART_ENCODING,g),g=AdfFileUploadUtils._getIframeDoc();b.removeBubbleEventListener(a,"change",this._domChangeFunc);for(var g=g.createElement(a.nodeName),h=0;h<a.attributes.length;h++){var k=
a.attributes[h];"value"!=k.name&&b.hasAttribute(a,k)&&b.setAttribute(g,k.name,k.value)}h=AdfRichUIPeer.CreateSubId(d,AdfFileUploadUtils._DELAYED_UPLOAD_CONTENT_ID)+this._delayedContentIdCount;b.setAttribute(a,"id",h);b.setAttribute(g,"id",f);b.setAttribute(g,"name",d);e.appendChild(g);AdfAgent.AGENT.getPlatform()==AdfAgent.IE_PLATFORM&&(g.contentEditable="false");b.addBubbleEventListener(g,"change",this._domChangeFunc);b.elementsAdded(a);b.elementsAdded(g);a.style.visibility="hidden";a.style.position=
"absolute";return g};AdfFileUploadUtils.prototype._deleteUploadedFile=function(a){var b=this._clientId,d=[];d[AdfFileUploadUtils._MULTIPLE_UPLOAD_PARAM]="multipleDelete";d.itemName=b;d.fileName=a;this._currentRequestItemId=this._getItem(a).getItemId();this._currentRequestOperation=AdfFileUploadManager.OPERATION_DELETE;this._sendUploadRequest(null,null,d,null)};
AdfFileUploadUtils.prototype._dtsRequestStatusChanged=function(a){a.getStatus()==AdfDataTransferRequestEvent.STATUS_COMPLETE&&(a=a.getResponseStatusCode(),this._requestStatusChanged(a,null))};AdfFileUploadUtils.prototype._getDataTransferService=function(){null==this._dts&&(this._dts=AdfPage.PAGE.getDataTransferService(!1,!1,!0));return this._dts};AdfFileUploadUtils.prototype._getComponent=function(){var a=this._peer.getComponent();return null!=a?a:AdfPage.PAGE.findComponent(this._clientId)};
AdfFileUploadUtils.prototype._getItem=function(a){for(var b=0;b<this._uploadQueue.length;b++)if(this._uploadQueue[b].getFilename()==a)return this._uploadQueue[b];for(b=0;b<this._uploadResult.length;b++)if(this._uploadResult[b].getFilename()==a)return this._uploadResult[b];return null};AdfFileUploadUtils.prototype._getTotalRows=function(){return this._uploadQueue.length+this._uploadResult.length};
AdfFileUploadUtils.prototype._getUploadResultItem=function(a){for(var b=0;b<this._uploadResult.length;b++)if(this._uploadResult[b].getItemId()==a)return this._uploadResult[b];return null};
AdfFileUploadUtils.prototype._handleDomChange=function(a,b){var d=AdfAgent.AGENT,e=this._clientId;if(this._inputId)if(e=AdfRichUIPeer.CreateSubId(e,this._inputId),e=d.getElementById(e),this._useFormData&&this._useFileApi)for(d=e.files,e=0;e<d.length;e++)this.addFileToQueue(d[e]);else e=d.getElementById(this._inputId),this.addFileToQueue(e)};AdfFileUploadUtils.prototype._hideDropArea=function(a){AdfAgent.AGENT.getElementById(a).style.display="none"};
AdfFileUploadUtils.prototype._initFallbackMode=function(a){var b=AdfAgent.AGENT,d=this,e=b.getElementById(AdfFileUploadUtils._MULTIPART_FRAME);if(!e){var f=b.getElementById(a),e=AdfPage.PAGE.getDomDocument().createElement("iframe");b.setAttribute(e,"name",AdfFileUploadUtils._MULTIPART_FRAME);b.setAttribute(e,"id",AdfFileUploadUtils._MULTIPART_FRAME);b.setAttribute(e,"scrolling","No");b.setAttribute(e,"frameborder",0);b.setAttribute(e,"hspace",0);b.setAttribute(e,"vspace",0);a=e.style;a.width=f.offsetWidth+
"px";a.height=f.offsetHeight+"px";a.position="relative";f.parentNode.appendChild(e);b.elementsAdded(e);this._iframeInterval=setInterval(function(){var a=AdfFileUploadUtils._getIframeDoc();if("complete"==a.readyState){var e=a.getElementsByTagName("body");null!=e&&(e[0].style.margin="0px",e[0].style.padding="0px",e[0].style.border="none",e[0].style.position="relative",d._delayedContentIdCount=0,b.addBubbleEventListener(a,"keypress",function(a){var e=b.getComponentEvent(component,a,null);d.HandleComponentKeyPress(e);
b.eatEvent(a)}),f=d._copyAndHideInputNode(f),clearInterval(d._iframeInterval),d._notifyListeners(AdfFileUploadManager.EVENT_TYPE_STATE,new AdfFileUploadEvent(d._getComponent(),AdfFileUploadManager.EVENT_TYPE_STATE,AdfFileUploadManager.EVENT_SOURCE_FALLBACK,AdfFileUploadManager.OPERATION_LOAD,null,100,AdfFileUploadManager.EVENT_STATUS_COMPLETE)))}},500)}};
AdfFileUploadUtils.prototype._initNonAppletMode=function(){var a=AdfAgent.AGENT,b=this._peer,d=this._getComponent();this._uploadSettings&&(this._inputId=this._uploadSettings.inputId,this._dropAreaId=this._uploadSettings.dropAreaId);if(this._useDnD&&this._dropAreaId){this._domDropFunc||(this._domDropFunc=function(a){b.HandleDomDrop(d,a)});var e=a.getElementById(this._dropAreaId);a.addBubbleEventListener(e,"drop",this._domDropFunc);e.style.display="inline"}else!this._useDnD&&this._dropAreaId&&(this._hideDropArea(this._dropAreaId),
this._fallbackInputId&&(this._inputId=this._fallbackInputId,this._fallbackInput||(this._fallbackInput=a.getElementById(this._inputId),this._fallbackInput.style.display="inline",this._initFallbackMode(this._inputId))))};
AdfFileUploadUtils.prototype._notifyListeners=function(a,b){if(a==AdfFileUploadManager.EVENT_TYPE_STATUS){if(this._eventStatusListeners)for(var d=0;d<this._eventStatusListeners.length;d++){var e=this._eventStatusListeners[d].listener,f=this._eventStatusListeners[d].instance;null!=f?e.call(f,b):e.call(this,b)}}else if(a==AdfFileUploadManager.EVENT_TYPE_PROGRESS){if(this._eventProgressListeners){if(null!=b.getFileItem()&&null!=b.getPercentComplete()&&100==Number(b.getPercentComplete())){if(this._percentCompleteItems[b.getFileItem().getItemId()])return;
this._percentCompleteItems[b.getFileItem().getItemId()]=!0}for(d=0;d<this._eventProgressListeners.length;d++)e=this._eventProgressListeners[d].listener,f=this._eventProgressListeners[d].instance,null!=f?e.call(f,b):e.call(this,b)}}else if(a==AdfFileUploadManager.EVENT_TYPE_STATE&&this._eventStateListeners)for(d=0;d<this._eventStateListeners.length;d++)e=this._eventStateListeners[d].listener,f=this._eventStateListeners[d].instance,null!=f?e.call(f,b):e.call(this,b)};
AdfFileUploadUtils.prototype._refreshListFunctions=function(){var a=this._uploadQueue;null==this._uploadQueueFunc?this._uploadQueueFunc=new function(){this.length=a.length;this.item=function(b){return a[b]}}:this._uploadQueueFunc.length=a.length;var b=this._uploadResult;null==this._uploadResultFunc?this._uploadResultFunc=new function(){this.length=b.length;this.item=function(a){return b[a]}}:this._uploadResultFunc.length=b.length};
AdfFileUploadUtils.prototype._removeFileItemFromUploadResultList=function(a){for(var b=0;b<this._uploadResult.length;b++)if(this._uploadResult[b].getItemId()==a)return a=this._uploadResult[b],this._uploadResult.splice(b,1),this._refreshListFunctions(),this._notifyListeners(AdfFileUploadManager.EVENT_TYPE_STATUS,new AdfFileUploadEvent(this._getComponent(),AdfFileUploadManager.EVENT_TYPE_STATUS,AdfFileUploadManager.EVENT_SOURCE_UPLOAD,AdfFileUploadManager.OPERATION_DELETE,a,100,AdfFileUploadManager.EVENT_STATUS_COMPLETE)),
a;return null};
AdfFileUploadUtils.prototype._removeFileFromUploadQueue=function(a){for(var b=0;b<this._uploadQueue.length;b++)if(a==this._uploadQueue[b].getFilename()){var d=this._uploadQueue[b];this._uploadQueue.splice(b,1);this._refreshListFunctions();this._notifyListeners(AdfFileUploadManager.EVENT_TYPE_STATE,new AdfFileUploadEvent(this._getComponent(),AdfFileUploadManager.EVENT_TYPE_STATE,AdfFileUploadManager.EVENT_SOURCE_QUEUE,AdfFileUploadManager.OPERATION_DELETE,d,100,AdfFileUploadManager.EVENT_STATUS_COMPLETE));break}for(b=
0;b<this._uploadResult.length;b++)if(a==this._uploadResult[b].getFilename()){this._uploadResult.splice(b,1);this._refreshListFunctions();break}};AdfFileUploadUtils.prototype._removeIframeTransferForm=function(){var a=this._uploadForm;if(a){for(;a.firstChild;)a.removeChild(a.firstChild);a.parentNode.removeChild(a);this._uploadForm=null}};
AdfFileUploadUtils.prototype._performAutoSubmitCheck=function(){for(var a=this.getFileUploadResults(),b=!1,d=a.length,e=0;e<d;e++)if(!a.item(e).isSuccess()){b=!0;break}this._peer._autoSubmit&&0<d&&!b&&AdfAutoSubmitEvent.queue(this._getComponent())};
AdfFileUploadUtils.prototype._requestStatusChanged=function(a,b){var d=this._currentRequestItemId,e=this._currentRequestOperation;this._useFormData||this._removeIframeTransferForm();200==a?e==AdfFileUploadManager.OPERATION_UPLOAD?(d=!1,this._currentChunkNum?this._lastChunk&&(d=!0,this._currentChunkNum=null):d=!0,this._resetUpload(!1),d?0<this._uploadQueue.length&&(d=this._uploadQueue.shift(),d.setSuccess(!0),this._addFileItemToUploadResultList(d),this._uploadSingleFile?0<this._uploadRequestQueue.length?
this._uploadFileInQueue(this._uploadRequestQueue.shift()):this._performAutoSubmitCheck():this._uploadFileInQueue()):this._uploadFileInQueue()):e==AdfFileUploadManager.OPERATION_DELETE&&(this._resetUpload(!0),this._removeFileItemFromUploadResultList(d)):this._cancelCurrentUploadAttempt&&!this._stopUpload?(this._resetUpload(!0),null!=d&&(d=this._uploadQueue[0],this._notifyListeners(AdfFileUploadManager.EVENT_TYPE_STATUS,new AdfFileUploadEvent(this._getComponent(),AdfFileUploadManager.EVENT_TYPE_STATUS,
AdfFileUploadManager.EVENT_SOURCE_UPLOAD,AdfFileUploadManager.OPERATION_CANCEL,d,100,AdfFileUploadManager.EVENT_STATUS_COMPLETE)),0<this._uploadQueue.length&&this._uploadQueue[0]==d&&this._uploadQueue.shift(),!this._uploadSingleFile&&0<this._uploadQueue.length&&this._uploadFileInQueue())):(e==AdfFileUploadManager.OPERATION_UPLOAD&&(d=this._uploadQueue[0],null!=d&&(d.setSuccess(!1),this._addFileItemToUploadResultList(d),this._stopUpload?this._notifyListeners(AdfFileUploadManager.EVENT_TYPE_STATUS,
new AdfFileUploadEvent(this._getComponent(),AdfFileUploadManager.EVENT_TYPE_STATUS,AdfFileUploadManager.EVENT_SOURCE_UPLOAD,AdfFileUploadManager.OPERATION_CANCEL_ALL,d,100,AdfFileUploadManager.EVENT_STATUS_COMPLETE)):(this._notifyListeners(AdfFileUploadManager.EVENT_TYPE_STATUS,new AdfFileUploadEvent(this._getComponent(),AdfFileUploadManager.EVENT_TYPE_STATUS,AdfFileUploadManager.EVENT_SOURCE_UPLOAD,AdfFileUploadManager.OPERATION_CANCEL,d,100,AdfFileUploadManager.EVENT_STATUS_COMPLETE)),0<this._uploadQueue.length&&
this._uploadQueue[0]==d&&this._uploadQueue.shift(),this._uploadFileInQueue()))),this._resetUpload(!0))};
AdfFileUploadUtils.prototype._resetInputFileNode=function(a){var b=AdfAgent.AGENT;b.setAttribute(a,"value","");for(var d=AdfPage.PAGE.getDomDocument().createElement(a.nodeName),e=0;e<a.attributes.length;e++){var f=a.attributes[e];"value"!=f.name&&b.hasAttribute(a,f)&&b.setAttribute(d,f.name,f.value)}d.onchange=a.onchange;this._inputId&&b.addBubbleEventListener(d,"change",this._domChangeFunc);if(e=a.parentNode)e.removeChild(a),e.appendChild(d);b.elementsRemoved(a);b.elementsAdded(d);return d};
AdfFileUploadUtils.prototype._resetUpload=function(a){this._stopUpload=this._currentlyUploading=this._cancelCurrentUploadAttempt=!1;a&&(this._currentChunkNum=null)};
AdfFileUploadUtils.prototype._sendUploadRequest=function(a,b,d,e,f){var g=this._getComponent(),h=this._clientId,k=AdfDhtmlEditableValuePeer.getContentNode(g),l=AdfPage.PAGE,m=AdfDhtmlPage._POSTBACK_CHECKPOINT.start(),n=AdfCollections.copyInto({},l._busyCounts);f={};f.busyCounts=n;f.__checkPointId=m;f.retryParams=null;f.formId=k.id;m=l.getDomDocument().forms[0];k=this._getDataTransferService();l=l._getPPRURL(m);m=m[AdfDhtmlPage._STATE_PARAM_NAME];null!=m&&(d[AdfDhtmlPage._STATE_PARAM_NAME]=m.value);
var m=null,q=this,m={requestStatusChanged:function(a){q._dtsRequestStatusChanged(a)}};if(this._useFileApi&&this._useFormData){var g=new FormData,r;for(r in d)"clientId"!=r&&d.hasOwnProperty(r)&&g.append(r,d[r]);g.append(d.clientId,a);m=k.sendMultiPartRequest(f,l,b,g,null,[m],e)}else{e=null;if(a)for(;null!=a.parentNode;){e=a.parentNode;if(null!=e.nodeType&&"FORM"==e.nodeName)break;a=a.parentNode}else a=AdfRichUIPeer.CreateSubId(h,AdfFileUploadUtils._UPLOAD_FORM_ID),e=AdfFileUploadUtils._getIframeTransferForm(g,
AdfFileUploadUtils._MULTIPART_ENCODING,a);for(r in d)if("clientId"==r){delete d[r];break}this._uploadForm=e;m=k.sendMultiPartRequest(f,l,b,e,d,[m],null)}this._currentRequest=m};
AdfFileUploadUtils.prototype._uploadFileInQueue=function(a){var b=AdfAgent.AGENT,d=this._clientId;this._cancelCurrentUploadAttempt=!1;if(0<this._uploadQueue.length){this._currentlyUploading=!0;this._currentRequestOperation=AdfFileUploadManager.OPERATION_UPLOAD;var e={},f={};e.clientId=d;e[AdfFileUploadUtils._MULTIPLE_UPLOAD_PARAM]="multipleAdd";var g=!1,h=null;if(a){this._uploadSingleFile=!0;for(var k=0;k<this._uploadQueue.length;k++)if(this._uploadQueue[k].getFilename()==a){h=this._uploadQueue[k];
break}}else this._uploadSingleFile=!1,h=this._uploadQueue[0];parseInt(h.getItemId());e[AdfFileUploadUtils._MULTIPLE_UPLOAD_FILE_PROPERTY_PARAM+":"+d+":"+h.getFilename()]=AdfFileUploadUtils._marshallProperties(h.getProperties());a=h.getData();if(this._useFormData&&this._useFileApi&&(this._notifyListeners(AdfFileUploadManager.EVENT_TYPE_STATUS,new AdfFileUploadEvent(this._getComponent(),AdfFileUploadManager.EVENT_TYPE_STATUS,AdfFileUploadManager.EVENT_SOURCE_UPLOAD,AdfFileUploadManager.OPERATION_UPLOAD,
h,0,AdfFileUploadManager.EVENT_STATUS_START)),a.size>this._maxChunkSize&&this._canSlice)){var g=!0,k=this._maxChunkSize,l=Math.ceil(a.size/k);e[AdfFileUploadUtils._MULTIPLE_UPLOAD_PARAM]="multipleAddChunk";e.itemName=d;d=null;null==this._currentChunkNum&&(this._currentChunkNum=0);this._currentChunkNum<l&&(this._currentChunkNum==l-1?(d=b.slice(a,this._currentChunkNum*k,this._currentChunkNum*k+((this._currentChunkNum+1)*k-a.size)),this._lastChunk=!0):(d=b.slice(a,this._currentChunkNum*k,(this._currentChunkNum+
1)*k),this._lastChunk=!1),f[AdfFileUploadUtils._MULTIPLE_UPLOAD_CHUNK_NUM_PARAM]=this._currentChunkNum,f[AdfFileUploadUtils._MULTIPLE_UPLOAD_CHUNK_COUNT_PARAM]=l,f[AdfFileUploadUtils._MULTIPLE_UPLOAD_CHUNK_FILENAME_PARAM]=a.name,this._sendUploadRequest(d,f,e,["progress",AdfFileUploadUtils._updateProgressFunction(this,h.getFilename(),this._currentChunkNum,l)]),this._currentChunkNum++)}g||(this._currentChunkNum=null,this._sendUploadRequest(a,null,e,["progress",AdfFileUploadUtils._updateProgressFunction(this,
h.getFilename())]));this._currentRequestItemId=h.getItemId();null!=this._delayedResetInputFileNode[h.getFilename()]&&(this._resetInputFileNode(this._delayedResetInputFileNode[h.getFilename()]),this._delayedResetInputFileNode[h.getFilename()]=null)}else this._currentlyUploading=!1,this._performAutoSubmitCheck(),this._useFormData||this._removeIframeTransferForm()};
AdfFileUploadUtils.prototype._validateFilename=function(a){for(var b=this._peer,d=this._getComponent(),e=AdfPage.PAGE.getLookAndFeel(),f=null,f=0;f<this._uploadQueue.length;f++)if(this._uploadQueue[f].getFilename()==a)return a=e.getTranslatedString("af_inputFile.MSG_UPLOAD_DUPLICATE_FILENAME_ERROR"),e=e.getTranslatedString("af_inputFile.MSG_UPLOAD_DUPLICATE_FILENAME_ERROR_DETAIL"),f=new AdfFacesMessage(AdfFacesMessage.TYPE_ERROR,a,e),this._notifyListeners(AdfFileUploadManager.EVENT_TYPE_STATE,new AdfFileUploadEvent(this._getComponent(),
AdfFileUploadManager.EVENT_TYPE_STATE,AdfFileUploadManager.EVENT_SOURCE_QUEUE,AdfFileUploadManager.OPERATION_ADDED,null,0,AdfFileUploadManager.EVENT_STATUS_FAILED,f)),!1;for(f=0;f<this._uploadResult.length;f++)if(this._uploadResult[f].getFilename()==a)return a=e.getTranslatedString("af_inputFile.MSG_UPLOAD_DUPLICATE_FILENAME_ERROR"),e=e.getTranslatedString("af_inputFile.MSG_UPLOAD_DUPLICATE_FILENAME_ERROR_DETAIL"),f=new AdfFacesMessage(AdfFacesMessage.TYPE_ERROR,a,e),this._notifyListeners(AdfFileUploadManager.EVENT_TYPE_STATE,
new AdfFileUploadEvent(this._getComponent(),AdfFileUploadManager.EVENT_TYPE_STATE,AdfFileUploadManager.EVENT_SOURCE_QUEUE,AdfFileUploadManager.OPERATION_ADDED,null,0,AdfFileUploadManager.EVENT_STATUS_FAILED,f)),!1;b._handleFileChange(d,a);return!0};
AdfFileUploadUtils.prototype._validateFilesize=function(a){var b=AdfPage.PAGE.getLookAndFeel(),d=this._getComponent();if(a){for(var e=this,f=parseInt(a),g=0;g<this._uploadQueue.length;g++)f+=parseInt(this._uploadQueue[g].getFilesize());if(!AdfFileUploadUtils.validateMaxFileSizeMaxDiskSpace(d,a,f,function(a){e._notifyListeners(AdfFileUploadManager.EVENT_TYPE_STATE,new AdfFileUploadEvent(d,AdfFileUploadManager.EVENT_TYPE_STATE,AdfFileUploadManager.EVENT_SOURCE_QUEUE,AdfFileUploadManager.OPERATION_ADDED,
null,0,AdfFileUploadManager.EVENT_STATUS_FAILED,a))}))return!1}return this._getTotalRows()>this._maximumFiles-1&&0<this._maximumFiles?(a=b.getTranslatedString("af_inputFile.MSG_UPLOAD_MAXIMUM_FILES_ERROR"),b=b.getTranslatedString("af_inputFile.MSG_UPLOAD_MAXIMUM_FILES_ERROR_DETAIL"),facesMessage=new AdfFacesMessage(AdfFacesMessage.TYPE_ERROR,a,b),this._notifyListeners(AdfFileUploadManager.EVENT_TYPE_STATE,new AdfFileUploadEvent(this._getComponent(),AdfFileUploadManager.EVENT_TYPE_STATE,AdfFileUploadManager.EVENT_SOURCE_QUEUE,
AdfFileUploadManager.OPERATION_ADDED,null,0,AdfFileUploadManager.EVENT_STATUS_FAILED,facesMessage)),!1):!0};
AdfFileUploadUtils._getCSSText=function(a){for(var b=AdfAgent.AGENT,d=AdfPage.PAGE.getDomDocument(),e=0;e<d.styleSheets.length;e++){var f=d.styleSheets[e];if(b.getPlatform()==AdfAgent.IE_PLATFORM)for(var f=f.rules,g=0;g<f.length;g++){var h=f.item(g);if(h.selectorText.substr(1,a.length)==a)return"."+a+" { "+h.style.cssText+"; } "}else for(f=f.cssRules,g=0;g<f.length;g++)if(h=f[g],h.cssText.substr(1,a.length)==a)return h.cssText}};
AdfFileUploadUtils._getFilename=function(a){return-1<a.indexOf("/")?a.substring(a.lastIndexOf("/")+1,a.length):a.substring(a.lastIndexOf("\\")+1,a.length)};AdfFileUploadUtils._getIframeDoc=function(){var a=AdfAgent.AGENT.getElementById(AdfFileUploadUtils._MULTIPART_FRAME);if(!a)return null;a=a.contentWindow||a.contentDocument;a.document&&(a=a.document);return a};
AdfFileUploadUtils._getIframeTransferForm=function(a,b,d){var e=AdfAgent.AGENT,f=AdfPage.PAGE,g=AdfFileUploadUtils._getIframeDoc();g||(g=f.getDomDocument());a=null;for(var h=g.getElementsByTagName("form"),k=0;k<h.length;k++)e.getAttribute(h[k],"id")==d&&(a=h[k]);a||(a=g.createElement("form"),g.getElementsByTagName("body")[0].appendChild(a),e.setAttribute(a,"id",d),a.encoding=b,b=f.getDomDocument().forms[0].action,a.action=b,a.target=AdfFileUploadUtils._MULTIPART_FRAME,a.style.position="absolute",
a.style.top="0px",a.style.left="0px");return a};AdfFileUploadUtils._getPopupAncestor=function(a){var b=null;try{b=a.getParent()}catch(d){}if(null==b)return null;for(;null!=b;){if(b instanceof AdfRichPopup)return b;try{b=b.getParent()}catch(d){return!1}if(null==b)return!1}};AdfFileUploadUtils._isInPopup=function(a){a=AdfFileUploadUtils._getPopupAncestor(a);return null==a?null:0==a?!1:!0};
AdfFileUploadUtils._marshallProperties=function(a){var b=AdfAgent.AGENT;null==this._marshalService&&(this._marshalService=AdfMarshalingService.getDefault());var d=[],e;for(e in a)a.hasOwnProperty(e)&&(d.push(e),d.push(a[e]));a=b.createXmlDocument();e=a.createElement("TEMP");b.getPlatform()==AdfAgent.IE_PLATFORM?a.documentElement=e:a.appendChild(e);d=this._marshalService.marshal(e,d,null);return b.getNodeXml(d)};
AdfFileUploadUtils._updateProgressFunction=function(a,b,d,e){return function(f){if(f.lengthComputable){f=f.loaded/f.total;f*=100;e&&(f=f/e+100*d/e);f=Math.round(f);var g=a._getItem(b);a._notifyListeners(AdfFileUploadManager.EVENT_TYPE_PROGRESS,new AdfFileUploadEvent(a._getComponent(),AdfFileUploadManager.EVENT_TYPE_PROGRESS,AdfFileUploadManager.EVENT_SOURCE_UPLOAD,AdfFileUploadManager.OPERATION_UPLOAD,g,f,AdfFileUploadManager.EVENT_STATUS_IN_PROGRESS))}}};
AdfFileUploadUtils.validateMaxFileSizeMaxDiskSpace=function(a,b,d,e){var f;f=AdfPage.PAGE.getLookAndFeel();var g=a.getProperty(AdfDhtmlInputFilePeer._MAX_FILE_SIZE),h=a.getProperty(AdfDhtmlInputFilePeer._MAX_DISK_SPACE),k=null,l=null;b+""==d+""&&(k="af_inputFile.MSG_SELECTED_FILE_TOO_LARGE_ERROR",l="af_inputFile.MSG_SELECTED_FILE_TOO_LARGE_ERROR_DETAIL");if(b>g&&0<g){if(!k||AdfDhtmlInputFilePeer._isMultipleUpload(a))k="af_inputFile.MSG_UPLOAD_MAXIMUM_FILE_SIZE_ERROR",l="af_inputFile.MSG_UPLOAD_MAXIMUM_FILE_SIZE_ERROR_DETAIL";
b=f.getTranslatedString(k);f=f.getTranslatedString(l);f=new AdfFacesMessage(AdfFacesMessage.TYPE_ERROR,b,f);e(f);a.setProperty("valid",!1);return!1}if(d>h){if(!k||AdfDhtmlInputFilePeer._isMultipleUpload(a))k="af_inputFile.MSG_UPLOAD_MAXIMUM_DISKSPACE_ERROR",l="af_inputFile.MSG_UPLOAD_MAXIMUM_DISKSPACE_ERROR_DETAIL";b=f.getTranslatedString(k);f=f.getTranslatedString(l);f=new AdfFacesMessage(AdfFacesMessage.TYPE_ERROR,b,f);e(f);a.setProperty("valid",!1);return!1}return!0};