var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.checkStringArgs=function(d,f,e){if(null==d)throw new TypeError("The 'this' value for String.prototype."+e+" must not be null or undefined");if(f instanceof RegExp)throw new TypeError("First argument to String.prototype."+e+" must not be a regular expression");return d+""};$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(d,f,e){d!=Array.prototype&&d!=Object.prototype&&(d[f]=e.value)};$jscomp.getGlobal=function(d){return"undefined"!=typeof window&&window===d?d:"undefined"!=typeof global&&null!=global?global:d};$jscomp.global=$jscomp.getGlobal(this);
$jscomp.polyfill=function(d,f,e,g){if(f){e=$jscomp.global;d=d.split(".");for(g=0;g<d.length-1;g++){var l=d[g];l in e||(e[l]={});e=e[l]}d=d[d.length-1];g=e[d];f=f(g);f!=g&&null!=f&&$jscomp.defineProperty(e,d,{configurable:!0,writable:!0,value:f})}};
$jscomp.polyfill("String.prototype.startsWith",function(d){return d?d:function(d,e){var g=$jscomp.checkStringArgs(this,d,"startsWith");d+="";var f=g.length,m=d.length;e=Math.max(0,Math.min(e|0,g.length));for(var n=0;n<m&&e<f;)if(g[e++]!=d[n++])return!1;return n>=m}},"es6","es3");
(function(){function d(a,b,c){b=a.getKey(b);var h=a.uploaders[b];h&&h.destroy(c);delete a.uploaders[b]}function f(a){var b=this._ctrl;a=b._wgt;var c=a.desktop;c=zk.ajaxURI("/upload?uuid="+a.uuid+"&dtid="+c.id+"&sid="+b.sid+(b.isNative?"&native=true":""),{desktop:c,au:!0});a=this.form;a.action=c;c=a.parentNode;c.parentNode.removeChild(c);b._formDetached=!0;if(this.files&&1!=this.files.length){b=this.files;c=[];for(var h=b.length;h--;)c.unshift(b[h].name);c=c.join(",")}else c=this.value;b=this._ctrl;
h=c;c=b.getKey(b.sid);a=new zul.Uploader(b,c,a,h);zul.Upload.start(a)&&(b.uploaders[c]=a);b.sid++;b.initContent()}function e(a,b){b=a.getWidget();var c=zul.UploadViewer.flman;b&&(c&&c.desktop||(c&&c.detach(),zul.UploadViewer.flman=c=new zul.UploadManager,b.getPage().appendChild(c)),c.removeFile(a),c.addFile(a))}function g(a,b){if(zul.UploadManager)return e(a,b);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 b=a.id,c=a.flnm,d=this.getFileItem(b);if(!d){d=new zul.wgt.Div({uuid:b,children:[new zul.wgt.Label({value:c+":"}),new zul.box.Box({mold:"horizontal",children:[new zul.wgt.Progressmeter({id:b,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:b+"_total"}),new zul.wgt.Separator]});try{this.appendChild(d)}catch(k){zk.debugLog(k.message||k)}this._files[b]=d}return d},updateFile:function(a,b,d){a=a.id;var c=this.getFileItem(a);c&&(c.$f(a).setValue(b),c.$f(a+"_total").setValue(d))},removeFile:function(a){a=a.id;var b=this.getFileItem(a);b&&b.detach();delete this._files[a];a=!0;for(var c in this._files){a=!1;break}a&&this.close()},open:function(a,b){this.$super("open",a,null,b||"after_start",{sendOnOpen:!1,disableMask:!0})}});
e(a,b)})}if(zk.opera){var l=[],m,n=function(){for(var a=l.length;a--;)l[a].sync()};var q=function(a){l.length||(m=setInterval(n,1500));l.push(a)};var r=function(a){l.$remove(a);m&&!l.length&&(clearInterval(m),m=null)}}zul.Upload=zk.$extends(zk.Object,{sid:0,$init:function(a,b,c){this.uploaders={};var h;c=c.split(",");for(var d=0,e=c.length;d<e;d++){var k=c[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&&(h=k)}this._clsnm=h||"";this._wgt=a;this._parent=b;a._tooltiptext&&(this._tooltiptext=a._tooltiptext);this.initContent()},sync:function(){if(!this._formDetached){var a=this._wgt.$n(),b=this._parent,c=b?b.lastChild:a.nextSibling;b=c.firstChild.firstChild;var d=zk(a).revisedOffset(),e=jq(c).css({top:"0",left:"0"}).zk.revisedOffset(),p=b.offsetWidth-a.offsetWidth;c=c.style;c.top=d[1]-
e[1]+"px";c.left=d[0]-e[0]-p+"px";b.style.height=a.offsetHeight+"px";b.style.clip="rect(auto,auto,auto,"+p+"px)"}},initContent:function(){var a=this._wgt,b=this._parent,c=a.$n(),d='<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:'+
c.offsetHeight+'px"/></form></span>';b?jq(b).append(d):jq(a).after(d);delete this._formDetached;if(!a._autodisable_self){var e=this;setTimeout(function(){e.sync()},50)}b=this._outer=b?b.lastChild:c.nextSibling;this._inp=d=b.firstChild.firstChild;zk.opera&&(b.style.position="absolute",q(this));d.z$proxy=c;d._ctrl=this;jq(d).change(f);10>=zk.ie&&jq(d).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&&r(this);jq(this._outer).remove();this._wgt=this._parent=this._inp=null;for(var a in this.uploaders){var b=this.uploaders[a];b&&(delete this.uploaders[a],b.destroy())}},getKey:function(a){return(this._wgt?this._wgt.uuid:"")+"_uplder_"+a},cancel:function(a){d(this,a)},finish:function(a){d(this,a,!0)}},{error:function(a,b,c){var d=zk.Widget.$(b);d&&(jq.alert(a,{desktop:d.desktop,icon:"ERROR"}),zul.Upload.close(b,c))},close:function(a,b){(a=zk.Widget.$(a))&&a._uplder&&a._uplder.cancel(b)},
sendResult:function(a,b,c){(a=zk.Widget.$(a))&&a._uplder&&(a._uplder.finish(c),zAu.send(new zk.Event(a.desktop,"updateResult",{contentId:b,wid:a.uuid,sid:c})))},isFinish:function(a){a=("string"==typeof a?a:a.uuid)+"_uplder_";for(var b=zul.Upload.files,c=b.length;c--;)if(b[0].id.startsWith(a))return!1;return!0},start:function(a){var b=zul.Upload.files;a&&b.push(a);b[0]&&!b[0].isStart&&(b[0].isStart=!0,b[0].start());return!0},destroy:function(a){for(var b=zul.Upload.files,c=b.length;c--;)if(b[c].id==
a.id){b.splice(c,1);break}zul.Upload.start()},files:[]});zul.Uploader=zk.$extends(zk.Object,{$init:function(a,b,c,d){this.id=b;this.flnm=d;this._upload=a;this._form=c;this._parent=c.parentNode;this._sid=a.sid;this._wgt=a._wgt;var e,h=this;a._clsnm?zk.$import(a._clsnm,function(a){e=new a(h,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:b.desktop,au:!0}),data:e,dataType:"text",success:function(a){var c=a.split(",");a.startsWith("error:")?(d._echo=!0,zul.Uploader.clearInterval(d.id),b&&(d.cancel(),zul.Upload.error(a.substring(6,a.length),b.uuid,d._sid))):a.startsWith("ignore")||d.update(zk.parseInt(c[0]),zk.parseInt(c[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 b=this._wgt,c=this.id+"_ifm";document.body.appendChild(this._parent);jq("#"+c).length||jq.newFrame(c);this._form.target=c;this._form.submit();this._form.style.display="none";var d=this,e="cmd=uploadInfo&dtid="+b.desktop.id+"&wid="+b.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(b)},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,c,d;(a=this._wgt)&&(b=this._upload)&&(c=b._aded)&&(a._uplder=null,c.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)}})})();
