var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.checkStringArgs=function(b,f,d){if(null==b)throw new TypeError("The 'this' value for String.prototype."+d+" must not be null or undefined");if(f instanceof RegExp)throw new TypeError("First argument to String.prototype."+d+" must not be a regular expression");return b+""};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;
$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(b,f,d){b!=Array.prototype&&b!=Object.prototype&&(b[f]=d.value)};$jscomp.getGlobal=function(b){return"undefined"!=typeof window&&window===b?b:"undefined"!=typeof global&&null!=global?global:b};$jscomp.global=$jscomp.getGlobal(this);
$jscomp.polyfill=function(b,f,d,g){if(f){d=$jscomp.global;b=b.split(".");for(g=0;g<b.length-1;g++){var h=b[g];h in d||(d[h]={});d=d[h]}b=b[b.length-1];g=d[b];f=f(g);f!=g&&null!=f&&$jscomp.defineProperty(d,b,{configurable:!0,writable:!0,value:f})}};
$jscomp.polyfill("String.prototype.startsWith",function(b){return b?b:function(b,d){var f=$jscomp.checkStringArgs(this,b,"startsWith");b+="";var h=f.length,m=b.length;d=Math.max(0,Math.min(d|0,f.length));for(var n=0;n<m&&d<h;)if(f[d++]!=b[n++])return!1;return n>=m}},"es6","es3");$jscomp.SYMBOL_PREFIX="jscomp_symbol_";$jscomp.initSymbol=function(){$jscomp.initSymbol=function(){};$jscomp.global.Symbol||($jscomp.global.Symbol=$jscomp.Symbol)};$jscomp.symbolCounter_=0;
$jscomp.Symbol=function(b){return $jscomp.SYMBOL_PREFIX+(b||"")+$jscomp.symbolCounter_++};$jscomp.initSymbolIterator=function(){$jscomp.initSymbol();var b=$jscomp.global.Symbol.iterator;b||(b=$jscomp.global.Symbol.iterator=$jscomp.global.Symbol("iterator"));"function"!=typeof Array.prototype[b]&&$jscomp.defineProperty(Array.prototype,b,{configurable:!0,writable:!0,value:function(){return $jscomp.arrayIterator(this)}});$jscomp.initSymbolIterator=function(){}};
$jscomp.arrayIterator=function(b){var f=0;return $jscomp.iteratorPrototype(function(){return f<b.length?{done:!1,value:b[f++]}:{done:!0}})};$jscomp.iteratorPrototype=function(b){$jscomp.initSymbolIterator();b={next:b};b[$jscomp.global.Symbol.iterator]=function(){return this};return b};
$jscomp.iteratorFromArray=function(b,f){$jscomp.initSymbolIterator();b instanceof String&&(b+="");var d=0,g={next:function(){if(d<b.length){var h=d++;return{value:f(h,b[h]),done:!1}}g.next=function(){return{done:!0,value:void 0}};return g.next()}};g[Symbol.iterator]=function(){return g};return g};$jscomp.polyfill("Array.prototype.keys",function(b){return b?b:function(){return $jscomp.iteratorFromArray(this,function(b){return b})}},"es6","es3");
(function(){function b(a,c,e){c=a.getKey(c);var b=a.uploaders[c];b&&b.destroy(e);delete a.uploaders[c]}function f(a){var c=this._ctrl;a=c._wgt;var e=a.desktop;e=zk.ajaxURI("/upload?uuid="+a.uuid+"&dtid="+e.id+"&sid="+c.sid,{desktop:e,au:!0});a=this.form;a.action=e;e=a.parentNode;e.parentNode.removeChild(e);c._formDetached=!0;if(this.files&&1!=this.files.length){c=this.files;e=[];for(var b=c.length;b--;)e.unshift(c[b].name);e=e.join(",")}else e=this.value;c=this._ctrl;b=e;e=c.getKey(c.sid);a=new zul.Uploader(c,
e,a,b);zul.Upload.start(a)&&(c.uploaders[e]=a);c.sid++;c.initContent()}function d(a,c){c=a.getWidget();var e=zul.UploadViewer.flman;c&&(e&&e.desktop||(e&&e.detach(),zul.UploadViewer.flman=e=new zul.UploadManager,c.getPage().appendChild(e)),e.removeFile(a),e.addFile(a))}function g(a,c){if(zul.UploadManager)return d(a,c);zk.load("zul.wgt,zul.box",function(){zul.UploadManager=zk.$extends(zul.wgt.Popup,{$init:function(){this.$supers("$init",arguments);this._files={};this.setSclass("z-fileupload-manager")},
onFloatUp:function(a){this.isVisible()&&this.setTopmost()},getFileItem:function(a){return this._files[a]||zk.Widget.$(a)},addFile:function(a){var c=a.id,e=a.flnm,b=this.getFileItem(c);if(!b){b=new zul.wgt.Div({uuid:c,children:[new zul.wgt.Label({value:e+":"}),new zul.box.Box({mold:"horizontal",children:[new zul.wgt.Progressmeter({id:c,sclass:"z-fileupload-progress"}),new zul.wgt.Div({sclass:"z-fileupload-remove z-icon-times",listeners:{onClick:function(){a.cancel()}}})]}),new zul.wgt.Label({id:c+
"_total"}),new zul.wgt.Separator]});try{this.appendChild(b)}catch(k){zk.debugLog(k.message||k)}this._files[c]=b}return b},updateFile:function(a,c,b){a=a.id;var e=this.getFileItem(a);e&&(e.$f(a).setValue(c),e.$f(a+"_total").setValue(b))},removeFile:function(a){a=a.id;var c=this.getFileItem(a);c&&c.detach();delete this._files[a];0===Object.keys(this._files).length&&this.close()},open:function(a,c){this.$super("open",a,null,c||"after_start",{sendOnOpen:!1,disableMask:!0})}});d(a,c)})}if(zk.opera){var h=
[],m,n=function(){for(var a=h.length;a--;)h[a].sync()};var p=function(a){h.length||(m=setInterval(n,1500));h.push(a)};var q=function(a){h.$remove(a);m&&!h.length&&(clearInterval(m),m=null)}}zul.Upload=zk.$extends(zk.Object,{sid:0,$init:function(a,c,e){this.uploaders={};var b;e=e.split(",");for(var d=0,f=e.length;d<f;d++){var k=e[d].trim();k.startsWith("maxsize=")?this.maxsize=k.match(new RegExp(/maxsize=([^,]*)/))[1]:k.startsWith("multiple=")?this.multiple=k.match(new RegExp(/multiple=([^,]*)/))[1]:
k.startsWith("accept=")?this.accept=k.match(new RegExp(/accept=([^,]*)/))[1]:"native"==k?this.isNative=!0:"true"!=k&&(b=k)}this._clsnm=b||"";this._wgt=a;this._parent=c;a._tooltiptext&&(this._tooltiptext=a._tooltiptext);this.initContent()},sync:function(){if(!this._formDetached){var a=this._wgt.$n(),c=this._parent,b=c?c.lastChild:a.nextSibling;c=b.firstChild.firstChild;var l=zk(a).revisedOffset(),d=jq(b).css({top:"0",left:"0"}).zk.revisedOffset(),f=c.offsetWidth-a.offsetWidth;b=b.style;b.top=l[1]-
d[1]+"px";b.left=l[0]-d[0]-f+"px";c.style.height=a.offsetHeight+"px";c.style.width=a.offsetWidth+"px"}},initContent:function(){var a=this._wgt,c=this._parent,b=a.$n(),l='<span class="z-upload"'+(this._tooltiptext?' title="'+zUtl.encodeXML(this._tooltiptext)+'"':"")+'><form enctype="multipart/form-data" method="POST"><input name="file" type="file"'+("true"==this.multiple?' multiple="" multiple':"")+(this.accept?' accept="'+this.accept.replace(/\|/g,",")+'"':"")+' hidefocus="true" style="height:'+b.offsetHeight+
'px"/></form></span>';c?jq(c).append(l):jq(a).after(l);delete this._formDetached;if(!a._autodisable_self){var d=this;setTimeout(function(){d.sync()},50)}c=this._outer=c?c.lastChild:b.nextSibling;this._inp=l=c.firstChild.firstChild;zk.opera&&(c.style.position="absolute",p(this));l.z$proxy=b;l._ctrl=this;jq(l).change(f);10>=zk.ie&&jq(l).hover(function(){jq(a).addClass("z-upload-hover")},function(){jq(a).removeClass("z-upload-hover")})},openFileDialog:function(){jq(this._inp).click()},destroy:function(){zk.opera&&
q(this);jq(this._outer).remove();this._wgt=this._parent=this._inp=null;for(var a in this.uploaders){var c=this.uploaders[a];c&&(delete this.uploaders[a],c.destroy())}},getKey:function(a){return(this._wgt?this._wgt.uuid:"")+"_uplder_"+a},cancel:function(a){b(this,a)},finish:function(a){b(this,a,!0)}},{error:function(a,c,b){var e=zk.Widget.$(c);e&&(jq.alert(a,{desktop:e.desktop,icon:"ERROR"}),zul.Upload.close(c,b))},close:function(a,c){(a=zk.Widget.$(a))&&a._uplder&&a._uplder.cancel(c)},sendResult:function(a,
c,b){(a=zk.Widget.$(a))&&a._uplder&&(a._uplder.finish(b),zAu.send(new zk.Event(a.desktop,"updateResult",{contentId:c,wid:a.uuid,sid:b})))},isFinish:function(a){a=("string"==typeof a?a:a.uuid)+"_uplder_";for(var c=zul.Upload.files,b=c.length;b--;)if(c[0].id.startsWith(a))return!1;return!0},start:function(a){var c=zul.Upload.files;a&&c.push(a);c[0]&&!c[0].isStart&&(c[0].isStart=!0,c[0].start());return!0},destroy:function(a){for(var c=zul.Upload.files,b=c.length;b--;)if(c[b].id==a.id){c.splice(b,1);
break}zul.Upload.start()},files:[]});zul.Uploader=zk.$extends(zk.Object,{$init:function(a,c,b,d){this.id=c;this.flnm=d;this._upload=a;this._form=b;this._parent=b.parentNode;this._sid=a.sid;this._wgt=a._wgt;var e,f=this;a._clsnm?zk.$import(a._clsnm,function(a){e=new a(f,d)}):e=new zul.UploadViewer(this,d);this.viewer=e},getWidget:function(){return this._wgt},destroy:function(a){this.end(a);this._form&&(jq(this._form.parentNode).remove(),jq("#"+this.id+"_ifm").remove());this._form=this._upload=this._wgt=
null},start:function(){function a(){jq.ajax({type:"POST",url:zk.ajaxURI("/upload",{desktop:c.desktop,au:!0}),data:f,dataType:"text",success:function(a){var b=a.split(",");a.startsWith("error:")?(d._echo=!0,zul.Uploader.clearInterval(d.id),c&&(d.cancel(),zul.Upload.error(a.substring(6,a.length),c.uuid,d._sid))):a.startsWith("ignore")||d.update(zk.parseInt(b[0]),zk.parseInt(b[1]))||zul.Uploader.clearInterval(d.id)},complete:function(a,b){var c;if("404"==(c=a.getResponseHeader("ZK-Error"))||"410"==c||
"error"==b||404==b||405==b||410==b)if(zul.Uploader.clearInterval(d.id),a=d.getWidget())d.cancel(),zul.Upload.error(msgzk.FAILED_TO_RESPONSE,a.uuid,d._sid)}})}var c=this._wgt,b=this.id+"_ifm";document.body.appendChild(this._parent);jq("#"+b).length||jq.newFrame(b);this._form.target=b;this._form.submit();this._form.style.display="none";var d=this,f="cmd=uploadInfo&dtid="+c.desktop.id+"&wid="+c.uuid+"&sid="+this._sid;zul.Uploader._tmupload&&clearInterval(zul.Uploader._tmupload);a.id=this.id;zul.Uploader.clearInterval=
function(b){a.id==b&&(clearInterval(zul.Uploader._tmupload),zul.Uploader._tmupload=void 0)};zul.Uploader._tmupload=setInterval(a,100);zul.wgt.ADBS.autodisable(c)},cancel:function(){zul.Uploader.clearInterval(this.id);this._upload&&this._upload.cancel(this._sid)},update:function(a,b){if(!this.getWidget()||0>=b)if(this._echo)this.end();else return!0;else if(zul.Uploader._tmupload)return this._echo=!0,0<=a&&100>=a&&this.viewer.update(a,b),0<=a&&100>a;return!1},end:function(a){this.viewer.destroy(a);
zul.Upload.destroy(this);this._echo=!0;var b,e,d;(a=this._wgt)&&(b=this._upload)&&(e=b._aded)&&(a._uplder=null,e.onResponse(),b._aded=null,a._uplder.destroy(),(d=b._parent)&&!jq(d).parents("html").length&&(b._parent=a._getUploadRef(),b.initContent()),a._uplder=b,a._uplder.sync(),delete a._autodisable_self)}});zul.UploadViewer=zk.$extends(zk.Object,{$init:function(a,b){this._uplder=a;g(a,b)},update:function(a,b){var c=zul.UploadViewer.flman;c&&(c.isOpen()||c.open(this._uplder.getWidget()),c.updateFile(this._uplder,
a,msgzk.FILE_SIZE+Math.round(b/1024)+msgzk.KBYTES))},destroy:function(){var a=zul.UploadViewer.flman;a&&a.removeFile(this._uplder)}})})();
