/**
	The MIT License (MIT)
	Copyright (c) 2026 UserApps.de
	Permission is hereby granted, free of charge, to any person obtaining a copy
	of this software and associated documentation files (the "Software"), to deal
	in the Software without restriction, including without limitation the rights
	to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
	copies of the Software, and to permit persons to whom the Software is
	furnished to do so, subject to the following conditions:
	The above copyright notice and this permission notice shall be included in
	all copies or substantial portions of the Software.
	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
	IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
	AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
	LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
	OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
	THE SOFTWARE.
	
	@author		Adrian Preuß <Bizarrus>, Christoph Kühl <djchrisnet>
	@tanks		Florian Berger <?>
	@docs		http://www.userapps.de/documentation/
	@version	1.1.0
	@build		Thu, 23 Apr 2026 04:05:54 +0200
*/


if(!JSON.format){Object.defineProperty(JSON,'format',{enumerable:false,configurable:false,writable:false,value:function format(object){return JSON.stringify(object,1,4).escapeKCode().replace(/\n/g,'°#°');}});}
function isTypeOf(object,toCheck){var type=undefined;try{if(typeof(object.javaClassName)!='undefined'){type=object.javaClassName;}else{type=typeof(object);}}catch(e){}
return(toCheck===undefined)?type:(toCheck==type);}
function AND(b1,b2){return((b1)&&(b2));}
function OR(b1,b2){return((b1)||(b2));}
function NOT(b1){return!(b1);}
function XOR(b1,b2){return((b1)==true&&(b2)==false)||((b1)==false&&(b2)==true);}
function clone(src){function mixin(dest,source,copyFunc){var name,s,i,empty={};for(name in source){s=source[name];if(!(name in dest)||(dest[name]!==s&&(!(name in empty)||empty[name]!==s))){dest[name]=copyFunc?copyFunc(s):s;}}
return dest;}
if(!src||typeof src!="object"||Object.prototype.toString.call(src)==="[object Function]"){return src;}
if(src instanceof Date){return new Date(src.getTime());}
if(src instanceof RegExp){return new RegExp(src);}
if(src instanceof Array){return[].concat(src);}
if(src instanceof StringBuffer){return new StringBuffer(src.toString());}
if(src instanceof KCode){return new KCode().append(src.toString());}
if(src instanceof KButton){return new KButton(src.getText(),src.getCommand()).setId(src.getId()).setProperties(src.getProperties());}
return mixin(src.constructor?new src.constructor():{},src,clone);}
if(!Number.prototype.fix){Object.defineProperty(Number.prototype,'fix',{enumerable:false,configurable:false,writable:false,value:function fix(count){return parseFloat(this.toFixed(parseInt(count,10)||2));}});}
if(!Number.prototype.format){Object.defineProperty(Number.prototype,'format',{enumerable:false,configurable:false,writable:false,value:function format(n,x,fill){if(n===undefined){n=2;}
if(x===undefined){x=3;}
if(fill===undefined){fill='.';}
return this.toFixed(Math.max(0,Math.floor(n))).replace(new RegExp('\\d(?=(\\d{'+x+'})+'+(n>0?'\\.':'$')+')','g'),'$&'+fill);}});}
if(!Number.prototype.zero){Object.defineProperty(Number.prototype,'zero',{enumerable:false,configurable:false,writable:false,value:function zero(){return(this>=10)?''+this:'0'+this;}});}
if(!String.prototype.urlencode){Object.defineProperty(String.prototype,'urlencode',{enumerable:false,configurable:false,writable:false,value:function urlencode(){return encodeURIComponent(this);}});}
if(!String.prototype.format){Object.defineProperty(String.prototype,'format',{enumerable:false,configurable:false,writable:false,value:function format(){var args=arguments;return this.replace(/{(\d+)}/g,function(match,number){return(typeof(args[number])!='undefined')?args[number]:match;});}});}
if(!String.prototype.formater){Object.defineProperty(String.prototype,'formater',{enumerable:false,configurable:false,writable:false,value:function formater(data){return this.replace(/\$[a-zA-Z0-9_\-]+/gi,function(match){return(typeof(data[match.substring(1)])!='undefined')?data[match.substring(1)]:match;});}});}
if(!Array.prototype.each){Object.defineProperty(Array.prototype,'each',{enumerable:false,configurable:false,writable:false,value:function each(callback,reverse){if(reverse==undefined){reverse=false;}
var result=true;if(reverse){for(var index=this.length-1;index>=0;index--){if(isTypeOf(this[index],'object')){if(callback.call(this,this[index],index)===false){result=false;break;}}else if(callback.apply(this,[this[index],index])===false){result=false;break;}}}else{for(var index=0;index<this.length;index++){if(isTypeOf(this[index],'object')){if(callback.call(this,this[index],index)===false){result=false;break;}}else if(callback.apply(this,[this[index],index])===false){result=false;break;}}}
return result;}});}
if(!Array.prototype.random){Object.defineProperty(Array.prototype,'random',{enumerable:false,configurable:false,writable:false,value:function random(){var random=RandomOperations.nextInt(this.length);if(this.length<=0||random>=this.length){return undefined;}
return this[random];}});}
if(!Array.prototype.shuffle){Object.defineProperty(Array.prototype,'shuffle',{enumerable:false,configurable:false,writable:false,value:function shuffle(){this.sort(function sort(a,b){return(0.5-Math.random());});}});}
if(!Array.prototype.exists){Object.defineProperty(Array.prototype,'exists',{enumerable:false,configurable:false,writable:false,value:function exists(value){return(this.indexOf(value)>-1);}});}
if(!Array.prototype.size){Object.defineProperty(Array.prototype,'size',{enumerable:false,configurable:false,writable:false,value:function size(){return this.length;}});}
if(!Array.prototype.first){Object.defineProperty(Array.prototype,'first',{enumerable:false,configurable:false,writable:false,value:function first(){return this[0];}});}
if(!Array.prototype.last){Object.defineProperty(Array.prototype,'last',{enumerable:false,configurable:false,writable:false,value:function last(){return this[this.length-1];}});}
if(!Array.prototype.clear){Object.defineProperty(Array.prototype,'clear',{enumerable:false,configurable:false,writable:false,value:function clear(){this.length=0;return this;}});}
if(!Array.prototype.remove){Object.defineProperty(Array.prototype,'remove',{enumerable:false,configurable:false,writable:false,value:function remove(removeElement){this.splice(this.indexOf(removeElement),1);return this;}});}
if(!Array.prototype.count){Object.defineProperty(Array.prototype,'count',{enumerable:false,configurable:false,writable:false,value:function count(countElement){var cnt=0;this.each(function countEach(element){if(element.equals&&countElement.equals&&element.equals(countElement)){++cnt;}
if(element===countElement){++cnt;}});return cnt;}});}
if(!Object.prototype.each){Object.defineProperty(Object.prototype,'each',{enumerable:false,configurable:false,writable:false,value:function each(callback,reverse){if(reverse==undefined){reverse=false;}
var result=true;if(reverse){var keys=[];for(var index in this){keys.push(index);}
for(var key_index=keys.length-1;key_index>=0;key_index--){var index=keys[key_index];if(!this.hasOwnProperty(index)){continue;}
if(typeof(this[index])=='object'){if(callback.call(this,this[index],index)===false){result=false;break;}}else if(callback.apply(this,[this[index],index])===false){result=false;break;}}}else{for(var index in this){if(!this.hasOwnProperty(index)){continue;}
if(typeof(this[index])=='object'){if(callback.call(this,this[index],index)===false){result=false;break;}}else if(callback.apply(this,[this[index],index])===false){result=false;break;}}}
return result;}});}
if(!Object.prototype.sort){Object.defineProperty(Object.prototype,'sort',{enumerable:false,configurable:false,writable:false,value:function sort(byKey,order){Logger.info('Object.sort(byKey, order) is DEPRECATED');if(byKey===undefined){byKey=='index';}
if(order===undefined){order=='ASC';}
var keys=[];for(var index in this){var sortby=0;if(byKey=='index'){sortby=index;}else if(byKey=='value'){sortby=this[index];}else if(this[index].hasOwnProperty(byKey)){sortby=this[index][byKey];}
keys.push({index:index,value:this[index],sortby:sortby});}
if(order=='ASC'){keys.sort(function(a,b){if(a.sortby<b.sortby)return-1;if(a.sortby>b.sortby)return 1;return 0;});}else{keys.sort(function(b,a){if(a.sortby<b.sortby)return-1;if(a.sortby>b.sortby)return 1;return 0;});}
var newObj={};for(var k in keys){if(keys[k]!=undefined){newObj[keys[k].index]=this[keys[k].index];}
delete this[keys[k].index];}
for(var key in newObj){this[key]=newObj[key];}
return newObj;}});}
if(!Object.prototype.toSortedArray){Object.defineProperty(Object.prototype,'toSortedArray',{enumerable:false,configurable:false,writable:false,value:function toSortedArray(byKey,order){if(byKey===undefined){byKey='index';}
if(order===undefined){order='ASC';}
var keys=[];for(var index in this){var sortby=0;if(byKey=='index'){sortby=index;}else if(byKey==='value'){sortby=this[index];}else if(this[index].hasOwnProperty(byKey)){sortby=this[index][byKey];}
keys.push({key:index,value:this[index],sortby:sortby});}
if(order=='ASC'){keys.sort(function(a,b){if(a.sortby<b.sortby)return-1;if(a.sortby>b.sortby)return 1;return 0;});}else{keys.sort(function(b,a){if(a.sortby<b.sortby)return-1;if(a.sortby>b.sortby)return 1;return 0;});}
return keys;}});}
if(!Object.prototype.exists){Object.defineProperty(Object.prototype,'exists',{enumerable:false,configurable:false,writable:false,value:function exists(value){return(this[value]!=undefined);}});}
if(!Object.prototype.compare){Object.defineProperty(Object.prototype,'compare',{enumerable:false,configurable:false,writable:false,value:function compare(defaultObj){for(var property in defaultObj){if(this[property]&&(typeof(this[property])=='object')&&(this[property].toString()=='[object Object]')&&defaultObj[property]){this[property].compare(defaultObj[property]);}else if(typeof this[property]=='undefined'){this[property]=defaultObj[property];}}
return this;}});}
if(!Object.prototype.size){Object.defineProperty(Object.prototype,'size',{enumerable:false,configurable:false,writable:false,value:function size(){return Object.keys(this).length;}});}
if(!Object.prototype.random){Object.defineProperty(Object.prototype,'random',{enumerable:false,configurable:false,writable:false,value:function random(){var keys=Object.keys(this);if(keys.length<=0){return undefined;}
var random=RandomOperations.nextInt(keys.length);if(keys.length<=0||random>=keys.length){return undefined;}
return this[keys[random]];}});}
if(!Object.prototype.join){Object.defineProperty(Object.prototype,'join',{enumerable:false,configurable:false,writable:false,value:function join(a,b){var string='';var length=Object.keys(this).length;var counter=0;for(var index in this){string+=index+a+this[index];if(counter+1<length){string+=b;}
++counter;}
return string;}});}
if(!User.prototype.getID){Object.defineProperty(User.prototype,'getID',{enumerable:false,configurable:false,writable:false,value:function getID(){return this.getUserId();}});}
if(!User.prototype.private){Object.defineProperty(User.prototype,'private',{enumerable:false,configurable:false,writable:false,value:function private(msg,delay){Bot.private(this,msg,delay);}});}
if(!User.prototype.post){Object.defineProperty(User.prototype,'post',{enumerable:false,configurable:false,writable:false,value:function post(topic,text){this.sendPostMessage(topic,text);}});}
if(!User.prototype.getProfilePicture){Object.defineProperty(User.prototype,'getProfilePicture',{enumerable:false,configurable:false,writable:false,value:function getProfilePicture(width,height){if(width==undefined){width=200;}
if(height==undefined){height=width;}
if(this.hasProfilePhoto()){if(this.getProfilePhoto!=undefined){return this.getProfilePhoto(width,height);}
return'http://chat.knuddels.de/pics/fotos/knuddels.de?n='+this.getNick().urlencode();}
if(this.getGender()==Gender.Female){return'nopic_79x79_f.jpg';}
return'nopic_79x79_m.jpg';}});}
if(!User.prototype.getGenderString){Object.defineProperty(User.prototype,'getGenderString',{enumerable:false,configurable:false,writable:false,value:function getGenderString(){switch(this.getGender()){case Gender.Male:return'male';break;case Gender.Female:return'female';break;}
return'none';}});}
if(!User.prototype.getKonto){Object.defineProperty(User.prototype,'getKonto',{enumerable:false,configurable:false,writable:false,value:function getKonto(){return KBank.getKonto(this.getUserId());}});}
if(!User.prototype.getKn){Object.defineProperty(User.prototype,'getKn',{enumerable:false,configurable:false,writable:false,value:function getKn(){return KBank.getKn(this.getUserId());}});}
if(!User.prototype.getTotalKn){Object.defineProperty(User.prototype,'getTotalKn',{enumerable:false,configurable:false,writable:false,value:function getTotalKn(){return KBank.getTotalKn(this.getUserId());}});}
if(!User.prototype.addKn){Object.defineProperty(User.prototype,'addKn',{enumerable:false,configurable:false,writable:false,value:function addKn(kn){return KBank.addKn(this.getUserId(),kn);}});}
if(!User.prototype.subKn){Object.defineProperty(User.prototype,'subKn',{enumerable:false,configurable:false,writable:false,value:function subKn(kn){return KBank.subKn(this.getUserId(),kn);}});}
if(!User.prototype.reqKn){Object.defineProperty(User.prototype,'reqKn',{enumerable:false,configurable:false,writable:false,value:function reqKn(kn,onSuccess,onError,reason){return KBank.reqKn(this.getUserId(),kn,onSuccess,onError,reason);}});}
if(!User.prototype.knuddel){Object.defineProperty(User.prototype,'knuddel',{enumerable:false,configurable:false,writable:false,value:function knuddel(amount,message){if(amount===undefined){return false;}
if(message===undefined){Bot.knuddel(this,amount);}else{Bot.knuddel(this,amount,message);}
return true;}});}
if(!User.prototype.getKnuddels){Object.defineProperty(User.prototype,'getKnuddels',{enumerable:false,configurable:false,writable:false,value:function getKnuddels(){return this.getKnuddelAmount().asNumber();}});}
if(!User.prototype.isVirtual){Object.defineProperty(User.prototype,'isVirtual',{enumerable:false,configurable:false,writable:false,value:function isVirtual(){return false;}});}
if(!DiceEvent.prototype.getTotal){Object.defineProperty(DiceEvent.prototype,'getTotal',{enumerable:false,configurable:false,writable:false,value:function getTotal(){return this.getDiceResult().totalSum();}});}
if(!DiceEvent.prototype.isOpenThrow){Object.defineProperty(DiceEvent.prototype,'isOpenThrow',{enumerable:false,configurable:false,writable:false,value:function isOpenThrow(){return this.getDiceResult().getDiceConfiguration().isUsingOpenThrow();}});}
if(!DiceEvent.prototype.isPrivate){Object.defineProperty(DiceEvent.prototype,'isPrivate',{enumerable:false,configurable:false,writable:false,value:function isPrivate(){return this.getDiceResult().getDiceConfiguration().isUsingPrivateThrow();}});}
if(!DiceEvent.prototype.getSingleDices){Object.defineProperty(DiceEvent.prototype,'getSingleDices',{enumerable:false,configurable:false,writable:false,value:function getSingleDices(){return this.getDiceResult().getSingleDiceResults();}});}
if(!DiceEvent.prototype.getSingleValues){Object.defineProperty(DiceEvent.prototype,'getSingleValues',{enumerable:false,configurable:false,writable:false,value:function getSingleValues(diceCount){if(diceCount===undefined){diceCount=0;}
return this.getDiceResult().getSingleDiceResults()[diceCount].valuesRolled();}});}
if(!DiceEvent.prototype.checkUser){Object.defineProperty(DiceEvent.prototype,'checkUser',{enumerable:false,configurable:false,writable:false,value:function checkUser(user){if(!isTypeOf(user,'User')){user=Users.get(user);}
return this.getUser().equals(user);}});}
if(!DiceEvent.prototype.checkConf){Object.defineProperty(DiceEvent.prototype,'checkConf',{enumerable:false,configurable:false,writable:false,value:function checkConf(conf){if(isTypeOf(conf,'string')){conf=DiceConfigurationFactory.fromString(conf);}
return this.getDiceResult().getDiceConfiguration().equals(conf);}});}
if(!DiceConfiguration.prototype.getFakeDiceEvent){Object.defineProperty(DiceConfiguration.prototype,'getFakeDiceEvent',{enumerable:false,configurable:false,writable:false,value:function getFakeDiceEvent(user){var _conf=this;var _singleResults=[];var _totalSum=0;function FakeSingleDiceResult(dice,values){var sum=0;values.each(function(val){sum+=val;});this.getDice=function getDice(){return dice;};this.valuesRolled=function valuesRolled(){return values;};this.sum=function sum(){return sum;};}
var confdices=_conf.getDices();confdices.sort(function(a,b){return a.getNumerOfSides()-b.getNumerOfSides();});var dices=[];var results=[];var count=0;confdices.each(function(dice){var curValues=[];var curDices=[];if(dice.getAmount()==1){dices.push('W'+dice.getNumerOfSides());count++;}else{dices.push(dice.getAmount()+'W'+dice.getNumerOfSides());count+=dice.getAmount();}
for(var w=0;w<dice.getAmount();w++){if(_conf.isUsingOpenThrow()){var tmpVal=0;var diceo=[];do{tmpVal=RandomOperations.nextInt(dice.getNumerOfSides())+1;curValues.push(tmpVal);diceo.push(tmpVal);_totalSum+=tmpVal;}while(tmpVal==dice.getNumerOfSides())
curDices.push(diceo.join('> '));}else{var tmpVal=RandomOperations.nextInt(dice.getNumerOfSides())+1;curValues.push(tmpVal);curDices.push(tmpVal);_totalSum+=tmpVal;}}
results.push(curDices.join(', '));_singleResults.push(new FakeSingleDiceResult(dice,curValues));});var infoLine=((!_conf.isUsingPrivateThrow())?'°BB°> ':'')+'_'+user.getProfileLink()+'_ rollt '+((count>1)?'die':'einen')+' Würfel'+((_conf.isUsingOpenThrow())?' (offener Wurf)':'')+'...';var resultLine=dices.join(' + ')+': '+results.join(' + ')+' = _'+_totalSum+'_';return(new function FakeDiceEvent(){this.checkConf=function checkConf(conf){return this.getDiceResult().getDiceConfiguration().equals(conf);};this.checkUser=function checkUser(user){return this.getUser().equals(user);};this.getDiceResult=function getDiceResult(){return(new function FakeDiceResult(){this.getDiceConfiguration=function getDiceConfiguration(){return _conf;};this.getSingleDiceResults=function getSingleDiceResults(){return _singleResults;};this.totalSum=function totalSum(){return _totalSum;};});};this.getResultLine=function getText(){return resultLine;};this.getText=function getText(){return infoLine+'°#°'+resultLine;};this.getInfoLine=function getInfoLine(){return infoLine};this.getTotal=function getTotal(){return this.getDiceResult().totalSum();};this.getUser=function getUser(){return user;};});}});};
function StringBuffer(startText){this.javaClassName='StringBuffer';var _data=startText||'';this.append=function append(data){_data+=data;return this;};this.toString=function toString(){return _data;};};
var Hash=(new function Hash(){this.javaClassName='Hash';this.decodeForm=function decodeForm(string){var chars=string.split('');var output=[];var a=97;var b=4;for(var index=0,char_index=0;index<chars.length/2;index++,char_index+=2){output.push((chars[char_index].charCodeAt(0)-a<<b|chars[char_index+1].charCodeAt(0)-a)^index&255);}
for(var index=0;index<output.length;index++){output[index]=output.fromCharCode(output[index]);}
return output.join('');};this.toString=function toString(){return'[KFramework Hash]';};});
var Hooks=(new function Hooks(){this.javaClassName='Hooks';var _hooks={};var _debug=false;this.addFilter=function addFilter(name,callback,priority){this.add(name,callback,priority,true);return this;};this.addAction=function addAction(name,callback,priority){this.add(name,callback,priority);return this;};this.add=function add(name,callback,priority,is_filter){priority=(priority==undefined?10:priority);is_filter=(is_filter==undefined?false:is_filter);if(_hooks[priority]==undefined){_hooks[priority]=[];}
if(_debug){if(Logger==undefined){KnuddelsServer.getDefaultLogger().info('[Hooks] Adding "'+name+'" with Priority of '+priority);}else{Logger.info('[Hooks] Adding "'+name+'" with Priority of '+priority);}}
_hooks[priority].push({name:name,callback:callback,is_filter:is_filter});return this;};this.remove=function remove(name,priority){priority=(priority==undefined?10:priority);if(_debug){if(Logger==undefined){KnuddelsServer.getDefaultLogger().info('[Hooks] Removing "'+name+'" with Priority of '+priority);}else{Logger.info('[Hooks] Removing "'+name+'" with Priority of '+priority);}}
if(!Object.prototype.each){for(var index in _hooks[priority]){var hook=_hooks[priority][index];if(hook.name==name){delete _hooks[priority][index];}}}else{_hooks[priority].each(function HooksPriorityEach(hook,index){if(hook.name==name){delete _hooks[priority][index];}});}
return this;};this.applyFilter=function applyFilter(name){var args=[];var args_length=arguments.size();for(var index=0;index<args_length;++index){var argument=arguments[index];if(argument==undefined||argument==null){continue;}
args.push(argument);}
args.splice(1,0,true);return this.do.apply(this,args);};this.do=function Do(name,is_filter){if(_debug){if(Logger==undefined){KnuddelsServer.getDefaultLogger().info('[Hooks] '+JSON.stringify(arguments));}else{Logger.info('[Hooks] '+JSON.stringify(arguments));}}
var is_filter_set=(is_filter==undefined||typeof(is_filter)!='boolean');var args=[];var args_length=arguments.size();var output=undefined;for(var index=0;index<args_length;++index){var argument=arguments[index];if(argument==undefined||argument==null){continue;}
args.push(argument);}
args.shift();if(!is_filter_set){args.shift();}
output=args[0];if(_debug){if(Logger==undefined){KnuddelsServer.getDefaultLogger().info('[Hooks] Execute "'+name+'" with params: '+JSON.stringify(args));}else{Logger.info('[Hooks] Execute "'+name+'" with params: '+JSON.stringify(args));}}
if(!Array.prototype.sort){if(Logger==undefined){KnuddelsServer.getDefaultLogger().warn('Hooks won\'t sort by Priority because Array.sort(); is not available. Please import framework/tools/Array.js!');}else{Logger.warn('Hooks won\'t sort by Priority because Array.sort(); is not available. Please import framework/tools/Array.js!');}}else{_hooks.sort('index','ASC');}
if(!Object.prototype.each){for(var priority in _hooks){var hooks=_hooks[priority];if(_debug){if(Logger==undefined){KnuddelsServer.getDefaultLogger().info('[Hooks] Each: PRIORITY '+priority);}else{Logger.info('[Hooks] Each: PRIORITY '+priority);}}
for(var index in hooks){var hook=hooks[index];if(hook.name==name){if(typeof(output)!='array'){output=[output];}
output=hook.callback.apply(this,((is_filter_set?false:is_filter)?output:args));}}}}else{_hooks.each(function HooksEach(hooks,priority){if(_debug){if(Logger==undefined){KnuddelsServer.getDefaultLogger().info('[Hooks] Each: PRIORITY '+priority);}else{Logger.info('[Hooks] Each: PRIORITY '+priority);}}
hooks.each(function HooksEach(hook){if(hook.name==name){if(typeof(output)!='array'){output=[output];}
output=hook.callback.apply(this,((is_filter_set?false:is_filter)?output:args));}});});}
return output;};this.toString=function toString(){return'[KFramework Hooks]';};}());
var DB=(new function Database(){this.javaClassName='Database';var _fields_global=[];var _fields_user=[];function synchronizeSchema(db,save){var schema=db.getObject('INFORMATION_SCHEMA',{user:_fields_user,global:_fields_global});_fields_user=schema.user;_fields_global=schema.global;if(save){db.setObject('INFORMATION_SCHEMA',{user:_fields_user,global:_fields_global});}};this.getUser=function getUser(user){Logger.info('DB.getUser(user) is DEPRECATED');return user.getPersistence();};this.getChannel=function getChannel(){Logger.info('DB.getChannel() is DEPRECATED');return KnuddelsServer.getPersistence();};this.load=function load(key,defaultValue,user){if(key===undefined){Logger.error('No key submitted');return false;}
var _db=KnuddelsServer.getPersistence();synchronizeSchema(_db,false);if(user!=undefined){_db=user.getPersistence();if(_fields_user.indexOf(key)==-1){_fields_user.push(key);}}else{if(_fields_global.indexOf(key)==-1){_fields_global.push(key);}}
switch(typeof defaultValue){case'string':return _db.getString(key,defaultValue);break;case'number':return _db.getNumber(key,defaultValue);break;case'object':return _db.getObject(key,defaultValue);break;case'undefined':return _db.getObject(key,{});break;}
return false;};this.save=function save(key,data,user){if(key===undefined){Logger.error('No key submitted');return false;}
if(data===undefined){Logger.error('No Data submitted');return false;}
var _db=KnuddelsServer.getPersistence();synchronizeSchema(_db,true);if(user!=undefined){_db=user.getPersistence();if(_fields_user.indexOf(key)==-1){_fields_user.push(key);}}else{if(_fields_global.indexOf(key)==-1){_fields_global.push(key);}}
switch(typeof data){case'string':_db.setString(key,data);break;case'number':_db.setNumber(key,data);break;case'object':_db.setObject(key,data);break;}
return true;};this.check=function check(key,data,user){if(key===undefined){Logger.error('No key submitted');return false;}
if(data===undefined){Logger.error('No Data submitted');return false;}
var _db=KnuddelsServer.getPersistence();if(user!=undefined){_db=user.getPersistence();}
switch(typeof data){case'string':return _db.hasString(key);break;case'number':return _db.hasNumber(key);break;case'object':return _db.hasObject(key);break;}
return false;};this.delete=function Delete(key,user,subdata){subdata=(typeof(subdata)=='undefined'?true:subdata);if(key===undefined){Logger.error('No key submitted');return false;}
var _db=KnuddelsServer.getPersistence();if(user!=undefined){_db=user.getPersistence();}
if(_db.hasString(key)){_db.deleteString(key);}
if(_db.hasNumber(key)){_db.deleteNumber(key);}
if(_db.hasObject(key)){_db.deleteObject(key);}
if(subdata){DB.loop(key,function DBLoop(entry,index,totalCount,subkey){DB.delete('_'+key+'_'+index,undefined,false);});DB.delete('_indexes_'+key,undefined,false);}};this.sum=function sum(key){if(key===undefined){Logger.error('No key submitted');return false;}
return UserPersistenceNumbers.getSum(key);};this.count=function count(key,from,to){if(key===undefined){Logger.error('No key submitted');return false;}
var options={};if(from!=undefined&&typeof(from)=='number'){options['minimumValue']=from;}
if(to!=undefined&&typeof(to)=='number'){options['maximumValue']=to;}
return UserPersistenceNumbers.getCount(key,options);};this.sorted=function sorted(key,sortBy,count,page){if(key===undefined){Logger.error('No key submitted');return false;}
var options={};if(sortBy!=undefined){options['ascending']=(sortBy=='ASC')?true:false;}
if(count!=undefined&&typeof(count)=='number'){options['count']=count;}
if(page!=undefined&&typeof(page)=='number'){options['page']=page;}
return UserPersistenceNumbers.getSortedEntries(key,options);};this.users=function users(key,callback,sortBy,from,to){if(key===undefined){Logger.error('No key submitted');return false;}
if(callback===undefined){Logger.error('No callback submitted');return false;}
var options={};if(sortBy!=undefined){options['ascending']=(sortBy=='ASC')?true:false;}
if(from!=undefined&&typeof(from)=='number'){options['minimumValue']=from;}
if(to!=undefined&&typeof(to)=='number'){options['maximumValue']=to;}
return UserPersistenceNumbers.each(key,callback,options);};this.getFields=function getFields(){return{global:_fields_global,user:_fields_user};};this.toString=function toString(){return'[KFramework Database]';};this.loop=function loop(key,callback){var name='_indexes_'+key;var id=DB.load(name,0);var totalCount=id;for(var index=1;index<=id;++index){var entry=DB.load('_'+key+'_'+index,undefined);callback.call(this,entry,index,totalCount,'_'+key+'_'+index);}};this.add=function add(key,data){var id=DB.load('_indexes_'+key,0);DB.save('_indexes_'+key,++id);DB.save('_'+key+'_'+id,data);return id;};this.update=function update(key,id,data,filter){if(typeof(filter)!='undefined'){data=filter.apply(this,[data]);}
DB.save('_'+key+'_'+id,data);};this.remove=function remove(key,id,data){DB.delete('_'+key+'_'+id);};}());
var Logger=(new function Logger(){this.javaClassName='Logger';var _logger;var _watcher;function Logger(){_logger=KnuddelsServer.getDefaultLogger();_watcher={};};this.addLogUser=function addLogUser(uid,types){Logger.info('Logger.addLogUser(uid, types) is DEPRECATED');_watcher[uid]=types||'E_ALL';};this.delLogUser=function delLogUser(uid){Logger.info('Logger.delLogUser(uid) is DEPRECATED');if(_watcher[uid]!=undefined){delete _watcher[uid];}};function getStrackTrace(){try{null.toString();}catch(e){return prettyStackTrace(e.stack);}
return'';};function prettyStackTrace(stack){var lines=stack.replace(/\t/g,'     ').replace(/\(anonymous\)/g,'').replace(/at (.*)@(.*): /g,'at ').split('\n');var output='';if(!Object.prototype.each){for(var index in lines){if(index<=1){return;}
output+='\n'+lines[index];}}else{lines.each(function LinesEach(line,index){if(index<=1){return;}
output+='\n'+line;});}
return output;};function sendLog(prefix,message){if(_watcher.size()>0){Logger.info('Logger.sendLog(prefix, message) is DEPRECATED - Don\'t use Logger.addLogUser(uid, types) or Logger.delLogUser(uid)!');}
_watcher.each(function WatcherEach(value,uid){if(value.contains(prefix)||value=='E_ALL'){Users.get(uid).sendPrivateMessage(prefix+': '+message);}});};this.debug=function debug(message){_logger.debug(message+getStrackTrace());sendLog('DEBUG',message);};this.info=function info(message){_logger.info(message+getStrackTrace());sendLog('INFO',message);};this.error=function error(message){_logger.error(message+getStrackTrace());sendLog('ERROR',message);};this.fatal=function fatal(message){_logger.fatal(message+getStrackTrace());sendLog('FATAL',message);};this.warn=function warn(message){_logger.warn(message+getStrackTrace());sendLog('WARN',message);};this.toString=function toString(){return'[KFramework Logger]';};Logger();}());
var Cron=(new function KCron(){this.javaClassName='KCron';var _cronjobs=[];var _watcher;var _offlineCheck=false;var instance=this;this.init=function init(){if(_watcher!=undefined){clearInterval(_watcher);}
_watcher=setInterval(this.run,500);};this.enableOfflineRunCheck=function enableOfflineRunCheck(){_offlineCheck=true;};this.checkOfflineRun=function checkOfflineRun(job){if(job.getLastCheck()==0){return;}
while(new Date().getTime()>=job.getLastCheck()){var time=new Date(job.getLastCheck()+500);job.setLastCheck(time);if((time.getTime()-job.getLastRun()>60000)&&instance.checkMatch(job.getMinutes(),time.getMinutes())&&instance.checkMatch(job.getHours(),time.getHours())&&instance.checkMatch(job.getDate(),time.getDate())&&instance.checkMatch(job.getMonth(),time.getMonth())&&instance.checkMatch(job.getDay(),time.getDay())){job.run(time);return;}}};this.run=function run(){var time=new Date();_cronjobs.each(function CronjobsEach(job){if(!job.isRunning()){return;}
if((time.getTime()-job.getLastRun()>60000)&&instance.checkMatch(job.getMinutes(),time.getMinutes())&&instance.checkMatch(job.getHours(),time.getHours())&&instance.checkMatch(job.getDate(),time.getDate())&&instance.checkMatch(job.getMonth(),time.getMonth())&&instance.checkMatch(job.getDay(),time.getDay())){job.run(time);}});};this.add=function add(cronjob){_cronjobs.push(cronjob);if(_offlineCheck){this.checkOfflineRun(cronjob);}};this.checkMatch=function checkMatch(a,b){var index=0;var length=a.length;for(;index<length;++index){var c=a[index];if(c[0]===-1||(b>=c[0]&&b<=c[1])){var b0=b-c[0];if(c[2]===-1||b===0||b%c[2]===0){return true;}}}
return false;};this.parse=function parse(entry){return entry.split(',').map(function ParseEntryEach(index){var z=index.split('/');var x=z[0].split('-');if(x[0]=='*'){x[0]=-1;}
if(x.length==1){x.push(x[0]);}
x[2]=z.length===1?-1:z[1];x[0]=parseInt(x[0],10);x[1]=parseInt(x[1],10);x[2]=parseInt(x[2],10);return x;});};this.saveData=function saveData(){_cronjobs.each(function CronjobsEach(cron){cron.save();});};this.onShutdown=function onShutdown(){_cronjobs.each(function CronjobsEach(cron){cron.onShutdown();});if(_watcher!=undefined){clearInterval(_watcher);}};this.toString=function toString(){return'[KFramework Cron]';};this.init();}());function Cronjob(name,cycle,callback){this.javaClassName='Cronjob';var _name='';var _cycle='* * * * *';var _cycle_data=[];var _is_running=false;var _callback=function(time){};var _last_run=undefined;var _last_check=undefined;var _time_data={minute:'*',hour:'*',date:'*',month:'*',day:'*'};function Cronjob(instance,name,cycle,callback){_name=name;_callback=callback;instance.changeCycle(cycle);if(DB==undefined){var _crondb=KnuddelsServer.getPersistence().getObject('_cron_'+_name,{run:0,check:0});}else{var _crondb=DB.load('_cron_'+_name,{run:0,check:0});}
_last_run=new Date(parseInt(_crondb.run,10));_last_check=new Date(parseInt(_crondb.check,10));Cron.add(instance);instance.start();}
this.changeCycle=function changeCycle(cycle){_cycle=cycle;_cycle_data=_cycle.match(/^([0-9,\-\/]+|\*{1}|\*{1}\/[0-9]+)\s+([0-9,\-\/]+|\*{1}|\*{1}\/[0-9]+)\s+([0-9,\-\/]+|\*{1}|\*{1}\/[0-9]+)\s+([0-9,\-\/]+|\*{1}|\*{1}\/[0-9]+)\s+([0-9,\-\/]+|\*{1}|\*{1}\/[0-9]+)\s*$/);_time_data={minute:Cron.parse(_cycle_data[1]),hour:Cron.parse(_cycle_data[2]),date:Cron.parse(_cycle_data[3]),month:Cron.parse(_cycle_data[4]),day:Cron.parse(_cycle_data[5])};};this.getLastRun=function getLastRun(){return _last_run.getTime();};this.getName=function getName(){return _name;};this.getLastCheck=function getLastCheck(){return _last_check.getTime();};this.setLastCheck=function setLastCheck(time){_last_check=time;};this.isRunning=function isRunning(){return _is_running;};this.start=function start(){_is_running=true;};this.stop=function stop(){_is_running=false;};this.run=function run(time){_last_check=time;_last_run=time;_callback(time);};this.getMinutes=function getMinutes(){return _time_data.minute;};this.getHours=function getHours(){return _time_data.hour;};this.getDate=function getDate(){return _time_data.date;};this.getMonth=function getMonth(){return _time_data.month;};this.getDay=function getDay(){return _time_data.day;};this.save=function save(){if(DB==undefined){KnuddelsServer.getPersistence().setObject('_cron_'+_name,{run:this.getLastRun(),check:this.getLastCheck()});return;}
DB.save('_cron_'+_name,{run:this.getLastRun(),check:this.getLastCheck()});};this.onShutdown=function onShutdown(){this.stop();this.save();};this.toString=function toString(){return'[KFramework Cronjob]';};Cronjob(this,name,cycle,callback);}
var Top=(new function Top(){this.javaClassName='Top';var _toplists=[];var _instance=this;var _events=[];var _size={width:476,height:522};this.setSize=function setSize(width,height){_size.width=width;_size.height=height;};this.add=function add(toplist){_toplists.push(toplist);};this.get=function get(name){if(typeof(name)=='undefined'){return _toplists;}
var toplist=undefined;_toplists.each(function(top){if(top.getName().toLowerCase()==name.toLowerCase()){toplist=top;return false;}});return toplist;};this.addEvent=function addEvent(name,callback){_events.push({name:name,callback:callback});};this.fireEvent=function fireEvent(name,user,data){_events.each(function EventsEach(event){if(event.name==name){event.callback.call(this,user,data);}});};this.handleEvent=function handleEvent(user,data){var params='';var event=false;var block=false;if(typeof(data.action)!='undefined'){switch(data.action){case'init':block=true;this.fireEvent('onOpen',user,data);break;case'close':block=true;user.sendEvent('close',block);this.fireEvent('onClose',user,data);break;case'view':if(typeof(data.name)!='undefined'){params+=data.name;if(typeof(data.page)!='undefined'){params+=':';params+=data.page;event=true;}}
break;}}else if(typeof(data.name)!='undefined'){params+=data.name;if(typeof(data.page)!='undefined'){params+=':';params+=data.page;event=true;}}
if(!block){this.handleCommand(user,params,event);}};this.getCategorys=function getCategorys(){var categorys={};_toplists.each(function(top){var cat=top.getCategorys();if(typeof(categorys[cat[0]])=='undefined'){categorys[cat[0]]=[];}
if(categorys[cat[0]].indexOf(cat[1])==-1){categorys[cat[0]].push(cat[1]);}});return categorys;};this.handleCommand=function handleCommand(user,params,event){event=(typeof(event)=='undefined'?false:event);if(params.length==0){var text=new KCode();var _categorys=_instance.getCategorys();text.append('Es gibt folgende Listen:');_categorys.each(function(categorys,name){text.newLine();text.append('°r°');text.append('_');text.append(name);text.append(':_');text.newLine();categorys.each(function(category,index){text.append(Colors.CHANNEL_BLUE);text.append('_');text.append(new KLink(category,'/toplist '+name+' '+category));text.append('_°r°');if(index+1<categorys.size()){text.append(', ');}});});user.private(text);return;}
var page=1;if(params.contains(':')){var split=params.split(':');var params=split[0];page=parseInt(split[1],10);}
var toplist=_instance.get(params);if(typeof(toplist)=='undefined'){user.private('Die Topliste \"_'+params.escapeKCode()+'_\" existiert nicht.');return;}
_instance.sendToplist(user,toplist,page,event);};this.sendToplist=function(user,toplist,page,event){var users=[];var limit=20;var entries=toplist.getEntries(limit,page);var view=new View('KFToplist');var prices=toplist.getPrices();view.setSize(_size.width,_size.height);entries.getData().each(function(entry,index){var place=entry.getPosition();users.push({place:place,nickname:entry.getUser().getNick(),bolded:entry.getUser().getID()==user.getID(),points:entry.getValue(),price:(typeof(prices[place-1])!='undefined'?prices[place-1]:{})});});if(event){user.sendEvent('name',toplist.getName());user.sendEvent('data',users);user.sendEvent('limit',limit);user.sendEvent('page',entries.getPage());user.sendEvent('pages',entries.getPages());return;}
view.addObject('name',toplist.getName());view.addObject('data',users);view.addObject('limit',limit);view.addObject('page',entries.getPage());view.addObject('pages',entries.getPages());if(!view.send(user)){var text=new KCode();text.append('_Topliste - '+toplist.getName()+'_');if(users.size()==0){text.newLine();text.append('"- Es existieren keine Einträge -"');}else{users.each(function(entry){if(user.getClientType()==ClientType.Applet){text.newLine();}else{text.append('°#r°');}
text.append('_'+entry.place+'_');text.append('     ');if(entry.bolded){text.append('°BB°_');}
text.append('°>'+entry.nickname.escapeKCode()+'|/w "<°');if(entry.bolded){text.append('_°r°');}
if(typeof(prices[entry.place-1])!='undefined'){var price=prices[entry.place-1];text.append(' (');switch(price.type){case'knuddel':text.append('°>sm_classic_00.gif<° '+price.value+' Knuddel');break;case'code':text.append(price.value+' °>features/codegenerator/code_001...mw_30.mh_15.png<°');break;}
text.append(')');}
text.append('     ');text.append(entry.points.toFixed(2));});}
var pages=entries.getPages();if(pages>=2){text.newLine();text.append('_Seiten:_ ');for(var index=1;index<=pages;++index){if(entries.getPage()==index){text.append('°BB°_');}
text.append(new KLink(''+index,'/toplist '+toplist.getName()+':'+index));if(entries.getPage()==index){text.append('_°r°');}
text.append(' ');}}
user.private(text);}};this.toString=function toString(){return'[KFramework Top]';};});function Toplist(key,categorys){this.javaClassName='Toplist';var _key='';var _instance=this;var _categorys=[];var _prices=[];var _payout_cycle=undefined;var _payout_cron=undefined;var _payout_remove=false;this.init=function init(key,categorys){_key=key;_categorys=categorys;Top.add(this);this.createCron();};this.getKey=function getKey(){return _key;};this.getName=function getName(){var name='';_categorys.each(function(category){name+=category+' ';});return name.trim();};this.setPayout=function setPayout(cycle,remove){_payout_cycle=cycle;_payout_remove=remove;this.createCron();};this.getPayout=function getPayout(){return _payout_cycle;};this.createCron=function createCron(){if(typeof(_payout_cron)=='undefined'&&typeof(_payout_cycle)!='undefined'){_payout_cron=new Cronjob('::Toplist:'+_key,_payout_cycle,this.executeCron);return;}
if(typeof(_payout_cycle)!='undefined'){_payout_cron.changeCycle(_payout_cycle);}};this.executeCron=function executeCron(){var entries=[];UserPersistenceNumbers.each(_key,function(user){entries.push({user:user,place:UserPersistenceNumbers.getPosition(_key,user,{ascending:false})});},{onEnd:function(){var index=0;var watcher=setInterval(function(){for(var i=0;i<100;++i){var entry=entries.shift();if(typeof(entry)=='undefined'){clearInterval(watcher);return;}
var user=entry.user;var place=entry.place;if(typeof(user)=='undefined'){clearInterval(watcher);return;}
var value=DB.load(_key,0,user);var text=new KCode();text.append('Hallo _'+user.getProfileLink()+'_,');text.newLine();text.newLine();var price=_prices[place-1];text.append('für die Topliste _\"');text.append(_instance.getName());text.append('\"_ im _°BB>Channel ');text.append(Channel.getName());text.append('|/go ');text.append(Channel.getName());text.append('<r°_ hast du _');text.append(value.toFixed(2));text.append(' Punkte_ erreicht');text.newLine();text.append('und machst somit den _');text.append(place);text.append('. Platz_.');if(typeof(price)!='undefined'){text.newLine();text.newLine();text.append('Für deine Platzierung erhälst du folgenden Gewinn:');text.newLine();switch(price.type){case'knuddel':text.append(' - _');text.append(new KImage('sm_classic_00.gif'));text.append(' ');text.append(price.value);text.append(' Knuddel_');Logger.info('Toplist: '+user.getNick()+', Place: '+place+', Kn: '+price.value);Bot.knuddel(user,price.value,'Toplisten-Gewinn: '+_instance.getName(),false);break;case'code':text.append(' - _');text.append(price.value);text.append(' ');text.append(new KImage('features/codegenerator/code_001.png'));text.append(' SmileyCode_');break;}}
if(typeof(price)!='undefined'){user.post('°BB°'+KnuddelsServer.getAppName()+'°r°: Topliste - '+_instance.getName(),text.toString());}
if(_payout_remove){DB.delete(_key,user);}
++index;}},5000);}});};this.getPrices=function getPrices(){return _prices;};this.addPrice=function addPrice(type,value){_prices.push({type:type,value:value});};this.getCategorys=function getCategorys(){return _categorys;};this.getEntries=function getEntries(max,page){return{getData:function getData(){return UserPersistenceNumbers.getSortedEntries(_key,{ascending:false,count:max,page:(page-1)});},getPage:function getPage(){return page;},getPages:function getPages(){return UserPersistenceNumbers.getCount(_key)/max;}};};this.toJSON=function toJSON(){return{key:_key,categorys:_categorys,prices:_prices};};this.toString=function toString(){return'[KFramework Toplist]';};this.init(key,categorys);}
var Bot=(new function Bot(){this.javaClassName='Bot';var _user=KnuddelsServer.getDefaultBotUser();var textFilter='';if(typeof(KnuddelTransferDisplayType)==='undefined'){KnuddelTransferDisplayType={Public:'Public',Post:'Post',Private:'Private'};}
this.setTextFilter=function setTextFilter(text){var countBOLD=text.split("_").length-1;if(countBOLD%2!==0){text=text.replace(/_/g,'');}
var countKUGEL=text.split("°").length-1;if(countKUGEL%2!==0){text=text.replace(/°/g,'');}
textFilter=text;return text;};this.clearTextFilter=function clearTextFilter(){textFilter='';};this.getAge=function getAge(){return _user.getAge();};this.getGender=function getGender(){return _user.getGender();};this.getKnuddelAmount=function getKnuddelAmount(){return _user.getKnuddelAmount();};this.getNick=function getNick(){return _user.getNick();};this.getUser=function getUser(){return _user;};this.getOnlineMinutes=function getOnlineMinutes(){return _user.getOnlineMinutes();};this.getProfileLink=function getProfileLink(displayText){return _user.getProfileLink(displayText==undefined?this.getNick():displayText);};this.getProfilePicture=function getProfilePicture(){return'http://chat.knuddels.de/pics/fotos/knuddels.de?n='+_user.getNick().urlencode();};this.getReadme=function getReadme(){return _user.getReadme();};this.getRegDate=function getRegDate(){return _user.getRegDate();};this.getUserId=function getUserId(){return _user.getUserId();};this.getUserStatus=function getUserStatus(){return _user.getUserStatus();};this.getUserType=function getUserType(){return _user.getUserType();};this.isAppDeveloper=function isAppDeveloper(){return _user.isAppDeveloper();};this.isAppManager=function isAppManager(){return _user.isAppManager();};this.isAway=function isAway(){return _user.isAway();};this.isChannelModerator=function isChannelModerator(){return _user.isChannelModerator();};this.isChannelOwner=function isChannelOwner(){return _user.isChannelOwner();};this.isColorMuted=function isColorMuted(){return _user.isColorMuted();};this.isEventModerator=function isEventModerator(){return _user.isEventModerator();};this.isLocked=function isLocked(){return _user.isLocked();};this.isMuted=function isMuted(){return _user.isMuted();};this.isOnline=function isOnline(){return _user.isOnline();};this.isOnlineInChannel=function isOnlineInChannel(){return _user.isOnlineInChannel();};this.join=function join(){_user.joinChannel();};this.leave=function leave(){_user.leaveChannel();};this.knuddel=function knuddel(user,amount,arg1,arg2){if(!isTypeOf(amount,'KnuddelAmount')){amount=new KnuddelAmount(amount);}
var params={};if(typeof(arg1)!='undefined'){if(isTypeOf(arg1,'string')){params['displayReasonText']=arg1;}
if(isTypeOf(arg1,'boolean')){if(isTypeOf(KnuddelTransferDisplayType,'KnuddelTransferDisplayType')){params['transferDisplayType']=(arg1)?KnuddelTransferDisplayType.Public:KnuddelTransferDisplayType.Post;}else{params['hidePublicMessage']=!(arg1);}}
if(isTypeOf(arg1,'KnuddelTransferDisplayType')){params['transferDisplayType']=arg1;}}
if(typeof(arg2)!='undefined'){if(isTypeOf(arg2,'string')){params['displayReasonText']=arg2;}
if(isTypeOf(arg2,'boolean')){if(isTypeOf(KnuddelTransferDisplayType,'KnuddelTransferDisplayType')){params['transferDisplayType']=(arg2)?KnuddelTransferDisplayType.Public:KnuddelTransferDisplayType.Post;}else{params['hidePublicMessage']=!(arg2);}}
if(isTypeOf(arg2,'KnuddelTransferDisplayType')){params['transferDisplayType']=arg2;}}
if(params.size()){_user.transferKnuddel(user,amount,params);}else{_user.transferKnuddel(user,amount);}};this.getKnuddels=function getKnuddels(){return _user.getKnuddelAmount().asNumber();};this.exception=function exception(exception){_user.sendPublicMessage(textFilter+'°RR°_Exception:_°r°#'+(exception.message==undefined?exception:exception.message));};this.publicMessage=function publicMessage(message){Logger.info('Bot.publicMessage(message) is DEPRECATED');this.public(message);}
this.postMessage=function postMessage(user,message,topic){Logger.info('Bot.postMessage(user, message, topic) is DEPRECATED');this.post(user,message,topic);}
this.privateMessage=function privateMessage(user,message){Logger.info('Bot.privateMessage(user, message) is DEPRECATED');this.private(user,message);}
this.action=function action(message,delay){if(message instanceof KCode){message=message.toString();}
if(delay){return setTimeout(function actionDelay(){_user.sendPublicActionMessage(textFilter+message);},delay);}else{_user.sendPublicActionMessage(textFilter+message);}};this.public=function public(message,delay){if(message instanceof KCode){message=message.toString();}
if(delay){return setTimeout(function publicDelay(){_user.sendPublicMessage(textFilter+message);},delay);}else{_user.sendPublicMessage(textFilter+message);}};this.post=function post(nick,message,topic){if(message instanceof KCode){message=message.toString();}
if(topic==undefined){topic='';}
if(nick==undefined){Channel.getUsers().each(function(user){user.sendPostMessage(topic,textFilter+message);});}else{if(isTypeOf(nick,'User')){nick.sendPostMessage(topic,message);}else if(isTypeOf(nick,'object')||isTypeOf(nick,'array')){nick.each(function(n){Bot.post(n,textFilter+message,topic);});}else{Users.get(nick).sendPostMessage(topic,textFilter+message);}}};this.private=function private(nick,message,delay){if(message instanceof KCode){message=message.toString();}
if(delay){return setTimeout(function privateDelay(){if(nick==undefined){Channel.getUsers().each(function(user){user.sendPrivateMessage(textFilter+message);});}else{if(isTypeOf(nick,'User')){nick.sendPrivateMessage(textFilter+message);}else if(isTypeOf(nick,'object')||isTypeOf(nick,'array')){_user.sendPrivateMessage(textFilter+message,nick);}else{nick=Users.get(nick);if(nick!=undefined){nick.sendPrivateMessage(textFilter+message);}}}},delay);}else{if(nick==undefined){Channel.getUsers().each(function(user){user.sendPrivateMessage(textFilter+message);});}else{if(isTypeOf(nick,'User')){nick.sendPrivateMessage(textFilter+message);}else if(isTypeOf(nick,'object')||isTypeOf(nick,'array')){_user.sendPrivateMessage(textFilter+message,nick);}else{nick=Users.get(nick);if(nick!=undefined){nick.sendPrivateMessage(textFilter+message);}}}}};this.exec=function exec(command){_user.sendToChannel(command);};this.toString=function toString(){return'[KFramework Bot]';};}());
var load=['KButton','KTooltip','KLink','KCountdown','KFont','KImage','KColor','KTable','KGroup'];load.each(function LoadEach(name){});var Alignment={LEFT:'°>LEFT<°',MIDDLE:'°>CENTER<°',CENTER:'°>CENTER<°',RIGHT:'°>RIGHT<°',JUSTIFY:'°>JUSTIFY<°'};function KCode(){this.javaClassName='KCode';var _buffer=[];var _debug=false;var _minify=true;var _mobilefix=false;this.append=function append(component){_buffer.push(component);return this;};this.newLine=function newLine(dotted){_buffer.push('°#');if(dotted==undefined?false:dotted){if(!_mobilefix){_buffer.push('!');}}
if(_mobilefix){}
_buffer.push('°');if(!_mobilefix){}
return this;};this.fixMobile=function fixMobile(state){_mobilefix=state;};this.newHr=function newHr(){_buffer.push('°-°');return this;};this.addDots=function addDots(){_buffer.push('.........');return this;};this.setAlignment=function setAlignment(alignment){_buffer.push(alignment);return this;};this.addImage=function addImage(file){Logger.info('KCode.addImage(file) is DEPRECATED');_buffer.push('°>'+KnuddelsServer.getFullImagePath(file)+'<°');return this;};this.disableOptimization=function disableOptimization(state){_minify=state;return this;};this.toString=function toString(){var string='';_buffer.each(function BufferEach(component){if(typeof(component)=='string'||typeof(component)=='number'){string+=component;}else if(component!=undefined&&component!=null){string+=component.toString();}});if(_debug){string=string.replace(/°/g,'\\°');}
if(_minify){string=string.replace(/°°/g,'');}
return string;};};
var KBank=(new function KBank(){this.javaClassName='KBank';var instance=this;var updateCallback=null;var payoutTaxRate=0;this.onKontoUpdate=function(call){updateCallback=call;};this.triggerKontoUpdate=function(uid){if(updateCallback){updateCallback(Users.get(parseInt(uid,10)),this.getKn(uid));}};this.setPayoutTaxRate=function setPayoutTaxRate(taxRate){if(taxRate===undefined){throw'No taxRate submitted!';}
if(isNaN(parseFloat(taxRate))){throw'taxRate "'+taxRate+'" is non Numeric';return false;}
taxRate=parseFloat(taxRate.toFixed(2));if(taxRate>100){Logger.error('taxRate "'+taxRate+'" is higher as 100');return false;}
payoutTaxRate=taxRate;return true;};this.getPayoutTaxRate=function getPayoutTaxRate(){return payoutTaxRate;};this.getKn=function getKn(uid){if(uid===undefined){throw'No UID submitted!';}
var _db=Users.get(parseInt(uid,10)).getPersistence();return parseFloat(_db.getNumber('KBank_knuddel',0.00).toFixed(2));};this.getTotalKn=function getTotalKn(uid){if(uid===undefined){throw'No UID submitted!';}
var _user=Users.get(parseInt(uid,10));return parseFloat((_user.getPersistence().getNumber('KBank_knuddel',0.00)+_user.getKnuddelAmount().asNumber()).toFixed(2));};this.getAccountKn=function getTotalKn(uid){if(uid===undefined){throw'No UID submitted!';}
var _user=Users.get(parseInt(uid,10));return parseFloat(_user.getKnuddelAmount().asNumber().toFixed(2));};this.reqKn=function reqKn(uid,kn,callSuccess,callError,reason){if(uid===undefined){throw'No UID submitted!';}
var user=Users.get(parseInt(uid,10));if(!isTypeOf(user)=='User'){throw'No User-Object found!';}
if(kn===undefined){throw'No Knuddel submitted!';}
if(callSuccess===undefined||typeof(callSuccess)!=='function'){throw'no success Callback';}
if(callError===undefined||typeof(callError)!=='function'){throw'no error Callback';}
try{kn=parseFloat(kn.toFixed(2));}catch(e){throw e.message;}
if(kn<=0.00){callError(user,'KnNullOrNeg');return false;}
if(kn<=this.getKn(uid)){if(this.subKn(uid,kn)){callSuccess(user,kn);return true;}else{callError(user,'KnCantSub');return false;}}
var diffKn=parseFloat((kn-this.getKn(uid)).toFixed(2));if(diffKn<0.01){diffKn=0.01;}
try{var requestKn=new KnuddelAmount(diffKn);}catch(e){callError(user,'KnValueToHigh');return false;}
if(requestKn>user.getKnuddelAmount().asNumber()){callError(user,'KnNotEnough');return;}
try{user.transferKnuddelToApp(requestKn,reason||'Einzahlung',{transferReason:reason||'Einzahlung',onError:function KnOnError(){callError(user,'KnTransferError');},onSuccess:function KnOnSuccess(){if(instance.subKn(uid,kn)){callSuccess(user,kn);}else{setTimeout(function timeOutCheck(){if(instance.subKn(uid,kn)){callSuccess(user,kn);}else{callError(user,'KnNotReceived');}},500);}}});}catch(e){callError(user,'KnTransferError');Logger.error(e.name+' : '+e.message);}};this.getKonto=function getKonto(uid){if(uid===undefined){throw'No UID submitted!';}
var _db=Users.get(parseInt(uid,10)).getPersistence();return{knuddel:parseFloat(_db.getNumber('KBank_knuddel',0.00).toFixed(2)),buyin:parseFloat(_db.getNumber('KBank_buyin',0.00).toFixed(2)),payout:parseFloat(_db.getNumber('KBank_payout',0.00).toFixed(2)),lock:(_db.getNumber('KBank_lock',0))};};this.resetKonto=function resetKonto(uid){if(uid===undefined){return;}
var _db=Users.get(parseInt(uid,10)).getPersistence();_db.deleteNumber('KBank_knuddel');_db.deleteNumber('KBank_buyin');_db.deleteNumber('KBank_payout');_db.deleteNumber('KBank_lock');if(updateCallback){updateCallback(Users.get(parseInt(uid,10)),this.getKn(uid));}};this.setKn=function setKn(uid,kn){if(uid===undefined){throw'No UID submitted!';}
if(kn===undefined){throw'No UID submitted!';}
if(kn<0.00){return false;}
var _db=Users.get(parseInt(uid,10)).getPersistence();_db.setNumber('KBank_knuddel',kn);if(updateCallback){updateCallback(Users.get(parseInt(uid,10)),this.getKn(uid));}};this.addKn=function addKn(uid,kn){if(uid===undefined){throw'No UID submitted!';}
if(kn===undefined){throw'No UID submitted!';}
if(kn<=0.00){return false;}
var _db=Users.get(parseInt(uid,10)).getPersistence();_db.addNumber('KBank_knuddel',kn);if(updateCallback){updateCallback(Users.get(parseInt(uid,10)),this.getKn(uid));}
return true;};this.delKn=function delKn(uid,kn){Logger.info('KBank.delKn(uid, kn) is DEPRECATED, use KBank.subKn(uid, kn)');return this.subKn(uid,kn);};this.subKn=function subKn(uid,kn){if(uid===undefined){throw'No UID submitted!';}
if(kn===undefined){throw'No KN submitted!';}
if(kn<=0.00){return false;}
if(kn>this.getKn(uid)){return false;}
var _db=Users.get(parseInt(uid,10)).getPersistence();_db.addNumber('KBank_knuddel',-kn);if(updateCallback){updateCallback(Users.get(parseInt(uid,10)),this.getKn(uid));}
return true;};this.payout=function payout(uid,kn,reason){if(uid===undefined){throw'No UID submitted!';}
if(kn===undefined){throw'No UID submitted!';}
if(kn<0){return false;}
if(kn>this.getKn(uid)){return false;}
if(kn>Bot.getKnuddels()){return false;}
if(kn>=1000000){return false;}
var _user=Users.get(parseInt(uid,10));var _db=_user.getPersistence();_db.addNumber('KBank_knuddel',-kn);_db.addNumber('KBank_payout',kn);if(payoutTaxRate){Bot.knuddel(_user,kn/100*(100-payoutTaxRate),reason);}else{Bot.knuddel(_user,kn,reason);}
if(updateCallback){updateCallback(Users.get(parseInt(uid,10)),this.getKn(uid));}
return true;};this.payToAccount=function payToAccount(uid,kn,reason){if(uid===undefined){throw'No UID submitted!';}
if(kn===undefined){throw'No UID submitted!';}
if(kn<0){return false;}
if(kn>this.getKn(uid)){return false;}
if(kn>Bot.getKnuddels()){return false;}
if(kn>=1000000){return false;}
var _user=Users.get(parseInt(uid,10));var _db=_user.getPersistence();_db.addNumber('KBank_knuddel',-kn);_db.addNumber('KBank_payout',kn);if(payoutTaxRate){Bot.knuddel(_user,kn/100*(100-payoutTaxRate),reason,KnuddelTransferDisplayType.Silent);}else{Bot.knuddel(_user,kn,reason,KnuddelTransferDisplayType.Silent);}
if(updateCallback){updateCallback(Users.get(parseInt(uid,10)),this.getKn(uid));}
return true;};this.payin=function payin(uid,kn){if(uid===undefined){throw'No UID submitted!';}
if(kn===undefined){throw'No Knuddel submitted!';}
if(kn<=0.00){throw'KnNullOrNeg!';}
var _db=Users.get(parseInt(uid,10)).getPersistence();_db.addNumber('KBank_knuddel',kn);_db.addNumber('KBank_buyin',kn);if(updateCallback){updateCallback(Users.get(parseInt(uid,10)),this.getKn(uid));}
return true;};this.isLocked=function isLocked(uid){var _db=Users.get(parseInt(uid,10)).getPersistence();return(_db.getNumber('KBank_lock',0));};this.setLock=function setLock(uid){var _db=Users.get(parseInt(uid,10)).getPersistence();_db.setNumber('KBank_lock',1);};this.unLock=function unLock(uid){var _db=Users.get(parseInt(uid,10)).getPersistence();_db.deleteNumber('KBank_lock');};this.getUsers=function getUsers(callback){if(typeof callback!=='function'){Logger.error('KBank.getUsers() is DEPRECATED, use it like this KBank.getUsers(function(userIds, total){ });');return false;}
var _users=[];UserPersistenceNumbers.each('KBank_knuddel',function UserPersistenceNumbersEach(user,value,index,total,key){_users.push(user.getUserId());},{ascending:false,onStart:function onStart(totalCount){_users=[];},onEnd:function onEnd(totalCount){callback.call(this,_users,totalCount);}});};this.getStats=function getStats(){return{users:DB.count('KBank_knuddel'),knusers:DB.count('KBank_knuddel',0.01),knuddel:parseFloat(DB.sum('KBank_knuddel')),buyin:parseFloat(DB.sum('KBank_buyin')),payout:parseFloat(DB.sum('KBank_payout')),};};this.getTransit=function getTransit(){return parseFloat(DB.sum('KBank_knuddel'));};this.getMaxPayout=function getTransit(){if(payoutTaxRate){return parseFloat(DB.sum('KBank_knuddel')/100*(100-payoutTaxRate));}
return this.getTransit();};this.toString=function toString(){return'[KFramework KBank]';};this.dataMigration=function dataMigration(){if(DB.check('_bank',{})==false){return true;}
var migrate=DB.load('_bank',{});if(!migrate.size()){DB.delete('_bank');Logger.info('KBank fully migrated! You can now delete all "KBank.saveData()" and "KBank.loadData()" calls from your AppCode');return false;};var _db=null;var migrated=[];var start=new Date().getTime();migrate.each(function MigrateEach(konto,uid){_db=Users.get(parseInt(uid,10)).getPersistence();_db.setNumber('KBank_knuddel',parseFloat(konto.knuddel.toFixed(2)));_db.setNumber('KBank_buyin',parseFloat(konto.buyin.toFixed(2)));_db.setNumber('KBank_payout',parseFloat(konto.payout.toFixed(2)));migrated.push(uid);if((new Date().getTime()-start)>9000){return false;}});if(migrate.size()==migrated.size()){DB.delete('_bank');Logger.info('KBank fully migrated! You can now delete all "KBank.loadData()" and "KBank.saveData()" calls from your AppCode');}else{migrated.each(function MigratedEach(uid){delete migrate[uid];});DB.save('_bank',migrate);Logger.info('KBank cant migrate all data at once ('+migrated.size()+' of '+migrate.size()+' finish). Please restart this App to migrate the last '+(migrate.size()-migrated.size())+' KBank Entrys');}
return false;};this.getData=function getData(){Logger.info('KBank.getData() is DEPRECATED, you dont need this all any more!');};this.loadData=function loadData(){Logger.info('KBank.loadData() is DEPRECATED, you dont need this all any more!');};this.saveData=function saveData(){Logger.info('KBank.saveData() is DEPRECATED, you dont need this all any more!');};this.resetData=function resetData(){Logger.info('KBank.resetData() is DEPRECATED, you dont need this all any more!');};this.fixData=function fixData(){Logger.info('KBank.fixData() is DEPRECATED, you dont need this all any more!');};this.cleanData=function cleanData(){Logger.info('KBank.cleanData() is DEPRECATED, you dont need this all any more!');};}());
var Files=(new function Files(){this.javaClassName='Files';var rootInstance=KnuddelsServer.getAppAccess().getOwnInstance().getRootInstance();this.require=function require(filename){if(!this.checkFile(filename)){Logger.fatal(filename+' does not exists!');return false;}
KnuddelsServer.require(filename);};this.execute=function execute(filename){if(!this.checkFile(filename)){Logger.fatal(filename+' does not exists!');return false;}
KnuddelsServer.execute(filename);};this.updateAppFiles=function updateAppFiles(){var files=rootInstance.updateAppFiles();var res=files.filter(function(filename){return filename.startsWith('www/');});if(res.size()){rootInstance.invalidateClientCache();}
return files;};this.getPath=function getPath(filename){return KnuddelsServer.getFullImagePath(filename);};this.getSystemPath=function getSystemPath(filename){return KnuddelsServer.getFullSystemImagePath(filename);};this.checkFile=function checkFile(filename){var path='';if(filename.contains('../')){return false;}
if(filename.startsWith('./')){filename=filename.substr(2);}
if(filename.startsWith('/')){filename=filename.substr(1);}
if(filename.contains('/')){path=filename.split('/');filename=path.pop();path=path.join('/');try{return KnuddelsServer.listFiles(path).exists(path+'/'+filename);}catch(e){return false;}}
try{return KnuddelsServer.listFiles(path).exists(filename);}catch(e){return false;}};this.listFiles=function listFiles(path,override){try{var files=KnuddelsServer.listFiles(path);}catch(e){return[];}
var options={showDir:false,filterPath:true,};if(override!==undefined){override.each(function(val,key){options[key]=val;});}
files=files.filter(function(file){var dir='';if(file.endsWith('/')){dir=file.split('/');dir.pop();file=dir.pop()+'/';dir=dir.join('/');}else if(file.contains('/')){dir=file.split('/');file=dir.pop();dir=dir.join('/');}
if(options.prefix!==undefined&&!file.startsWith(options.prefix)){return false;}
if(options.type!==undefined&&!file.endsWith('.'+options.type)){return false;}
if(options.showDir!==undefined&&!(options.showDir)&&file.endsWith('/')){return false;}
return true;});if(options.filterPath!==undefined&&(options.filterPath)){return files.map(function(file){if(file.endsWith('/')){dir=file.split('/');dir.pop();file=dir.pop()+'/';dir=dir.join('/');}else if(file.contains('/')){dir=file.split('/');file=dir.pop();dir=dir.join('/');}
return file;});}
return files;};this.toString=function toString(){return'[KFramework Files]';};}());
var Background={SCALED:0,SCALE_FILLED_MODE1:6,SCALE_FILLED_MODE2:10,SCALE_FILLED_MODE3:54,SCALE_COMPLETE_CENTERED:7,SCALE_HEIGHT_RIGHT:61,SCALE_HEIGHT_TOP:40,SCALE_HEIGHT_BOTTOM:56,TILED:17,TILED_ZOOM_X2:33,TILED_ZOOM_X3:59,TILED_OFFSET_HORIZONTAL:18,TILED_OFFSET_ZOOM_X2:34,TILED_OFFSET_ZOOM_X3:50,TILED_OFFSET_VERTICAL:19,TILED_OFFSET_VERTICAL_ZOOM_X2:34,TILED_OFFSET_VERTICAL_ZOOM_X3:50,CENTERED:20,CENTERED_ZOOM_X2:36,CENTERED_ZOOM_X3:52};var Channel=(new function Channel(){this.javaClassName='Channel';var _channel=KnuddelsServer.getChannel();var _configuration=_channel.getChannelConfiguration();var _restrictions=_channel.getChannelRestrictions();var _design=_channel.getChannelDesign();var _rights=_configuration.getChannelRights();var _info=_configuration.getChannelInformation();this.getName=function getName(){return _channel.getChannelName();};this.getRootName=function getRootName(){return _channel.getRootChannelName();};this.usersOnline=function usersOnline(filter){return Channel.getUsers(filter).size();};this.getOwner=function getOwner(index){index=(typeof(index)=='undefined'?0:index);var owners=this.getOwners();return owners[index];};this.setBackground=function setBackground(image,style,user,text){Bot.private(user,'°>{bgimage}'+image+'|'+(style==undefined?Background.SCALED:style)+'<°'+(text==undefined?'Das Hintergrundbild wird geändert':text));};this.getTopic=function getTopic(){return _info.getTopic();};this.setTopic=function setTopic(text,showLive){if(showLive===undefined){showLive=true;}
_info.setTopic(text||'',showLive);};this.getModerators=function getModerators(){return _rights.getChannelModerators();};this.getOwners=function getOwners(){return _rights.getChannelOwners();};this.getMods=function getMods(){return _rights.getEventModerators();};this.getCMutes=function getCMutes(){return _restrictions.getColorMutedUsers();};this.getMutes=function getMutes(){return _restrictions.getMutedUsers();};this.getCLs=function getCLs(){return _restrictions.getLockedUsers();};this.onDev=function onDev(){return KnuddelsServer.getChatServerInfo().isTestSystem();};this.isVideoChannel=function isVideoChannel(){return _channel.isVideoChannel();};this.isVisible=function isVisible(){return _channel.isVisible();};this.getServer=function getServer(){return KnuddelsServer.getChatServerInfo().getServerId();};this.getBackgroundColor=function getBackgroundColor(){return _design.getBackgroundColor();};this.getDefaultFontColor=function getDefaultFontColor(){return _design.getDefaultFontColor();};this.getDefaultFontSize=function getDefaultFontSize(){return _design.getDefaultFontSize();};this.getUsers=function getUsers(filter,randomOne){filter=filter||{};var types=[UserType.Human];if(filter.bot!=undefined){if(filter.bot){types.push(UserType.AppBot);types.push(UserType.SystemBot);}}
var users=[];var _users=_channel.getOnlineUsers(types);if(!filter.size()){return(randomOne)?RandomOperations.getRandomObject(_users):_users;}
for(var index=0;index<_users.length;index++){if(filter.away!=undefined&&filter.away!=_users[index].isAway()){continue;}
if(filter.cmute!=undefined&&filter.cmute!=_users[index].isColorMuted()){continue;}
if(filter.mute!=undefined&&filter.mute!=_users[index].isMuted()){continue;}
if(filter.cl!=undefined&&filter.cl!=_users[index].isLocked()){continue;}
if(filter.developer!=undefined&&filter.developer!=_users[index].isAppDeveloper()){continue;}
if(filter.manager!=undefined&&filter.manager!=_users[index].isAppManager()){continue;}
if(filter.owner!=undefined&&filter.owner!=_users[index].isChannelOwner()){continue;}
if(filter.event!=undefined&&filter.event!=_users[index].isEventModerator()){continue;}
if(filter.cm!=undefined&&filter.cm!=_users[index].isChannelModerator()){continue;}
if(filter.lmc!=undefined&&filter.lmc!=_users[index].isLikingChannel()){continue;}
if(filter.status!=undefined&&!filter.status.exists(_users[index].getUserStatus())){continue;}
if(filter.exclude!=undefined&&filter.exclude.size()){var result=filter.exclude.each(function FilterExcludeEach(entry){if(isTypeOf(entry)=='User'&&_users[index].equals(entry)){return false;}else if(_users[index].getUserId()==entry){return false;}});if(!result){continue;}}
if(filter.include!=undefined&&filter.include.size()){filter.include.each(function FilterIncludeEach(entry){if(isTypeOf(entry)=='User'&&_users[index].equals(entry)){return false;}else if(_users[index].getUserId()==entry){return false;}});if(result){continue;}}
if(filter.gender!=undefined&&!filter.gender.exists(_users[index].getGender())){continue;}
if(filter.video!=undefined&&filter.video!=_users[index].isStreamingVideo()){continue;}
if(filter.clientType!=undefined&&!filter.clientType.exists(_users[index].getClientType())){continue;}
if(filter.appContent!=undefined&&!_users[index].canSendAppContent(filter.appContent)){continue;}
if(filter.custom!=undefined&&typeof(filter.custom)=='function'&&!filter.custom.call(_users[index],_users[index])){continue;}
users.push(_users[index]);}
return(randomOne)?RandomOperations.getRandomObject(users):users;};this.getLink=function getLink(){var channelName=this.getName();return"°>"+channelName+"|/go "+channelName+"|/go +"+channelName+"<°";}
this.toString=function toString(){return'[KFramework Channel]';};}());
var Status={Newbie:0,Family:1,Stammi:2,Ehrenz:3,Admin:6,Sysadmin:11,Bot:-1};var Users=(new function Users(){this.javaClassName='Users';var UAC=KnuddelsServer.getUserAccess();this.getProfilePicture=function getProfilePicture(user){Logger.info('Users.getProfilePicture(user) is DEPRECATED, use user.getProfilePicture(width, height)');var nickname='';if(user.getNick==undefined){user=this.get(user);}
nickname=user.getNick();return'http://chat.knuddels.de/pics/fotos/knuddels.de?n='+nickname.urlencode();};this.nickExists=function nickExists(nickname){return UAC.exists(nickname);};this.canAccess=function canAccess(nickname){if(typeof(nickname)=='number'){return UAC.mayAccess(nickname);}
if(!UAC.exists(nickname)){return false;}
var userId=UAC.getUserId(nickname);return UAC.mayAccess(userId);};this.fixNick=function fixNick(userId){return UAC.getNick(userId);};this.getAppDeveloper=function getAppDeveloper(){return KnuddelsServer.getAppAccess().getOwnInstance().getAppInfo().getAppDeveloper();};this.getAppManagers=function getAppManagers(){return KnuddelsServer.getAppAccess().getOwnInstance().getAppInfo().getAppManagers();};this.get=function get(nickname){if(typeof(nickname)=='number'){if(UAC.mayAccess(nickname)){return UAC.getUserById(nickname);}}
if(!UAC.exists(nickname)){return undefined;}
var userId=UAC.getUserId(nickname);if(UAC.mayAccess(userId)){return UAC.getUserById(userId);}
if(typeof(nickname)=='string'){return(new function TemporaryUser(){var _nickname=nickname;var _uid=userId;this.virtual=true;this.isVirtual=function isVirtual(){return true;};this.getPersistence=function getPersistence(_uid){return(new function VirtualPersistence(uid){_uid=uid;this.addNumber=function addNumber(key,value){var userdb=DB.load('_userdb');if(userdb[_uid][key]===undefined){userdb[_uid][key]=0;}
userdb[_uid][key]+=value;DB.save('_userdb',userdb);};this.getString=function getString(key,defaults){return DB.load('_userdb')[_uid][key]||defaults;};this.getNumber=function getNumber(key,defaults){return DB.load('_userdb')[_uid][key]||defaults;};this.getObject=function getObject(key,defaults){return DB.load('_userdb')[_uid][key]||defaults;};this.deleteNumber=function deleteNumber(key){var userdb=DB.load('_userdb');delete userdb[_uid][key];DB.save('_userdb',userdb);};this.deleteObject=function deleteObject(key){var userdb=DB.load('_userdb');delete userdb[_uid][key];DB.save('_userdb',userdb);};this.deleteString=function deleteString(key){var userdb=DB.load('_userdb');delete userdb[_uid][key];DB.save('_userdb',userdb);};this.setString=function setString(key,data){var userdb=DB.load('_userdb');userdb[_uid][key]=data;DB.save('_userdb',userdb);};this.setNumber=function setNumber(key,data){var userdb=DB.load('_userdb');userdb[_uid][key]=data;DB.save('_userdb',userdb);};this.setObject=function setObject(key,data){var userdb=DB.load('_userdb');userdb[_uid][key]=data;DB.save('_userdb',userdb);};}());};this.equals=function equals(user){Logger.warn('using User.equals() on virtual User-Object');};this.getAge=function getAge(){return-1;};this.getGender=function getGender(){return Gender.Unknown;};this.getKnuddelAmount=function getKnuddelAmount(){return new KnuddelAmount(0);};this.getNick=function getNick(){return _nickname;};this.getOnlineMinutes=function getOnlineMinutes(){return-1;};this.getProfilePicture=function getProfilePicture(){return'http://chat.knuddels.de/pics/fotos/knuddels.de?n='+_nickname.urlencode();};this.getProfileLink=function getProfileLink(){return'°>_h'+_nickname.escapeKCode()+'|/w "|/serverpp "<°';};this.getReadme=function getReadme(){return'';};this.getRegDate=function getRegDate(){return new Date(0);};this.getID=function getID(){return _uid;};this.getUserId=function getUserId(){return _uid;};this.getUserStatus=function getUserStatus(){return UserStatus.Newbie;};this.getUserType=function getUserType(){return UserType.Human;};this.isAppDeveloper=function isAppDeveloper(){return false;};this.isAppManager=function isAppManager(){return false;};this.isAway=function isAway(){return false;};this.isChannelModerator=function isChannelModerator(){return false;};this.isChannelOwner=function isChannelOwner(){return false;};this.isColorMuted=function isColorMuted(){return false;};this.isEventModerator=function isEventModerator(){return false;};this.isLocked=function isLocked(){return false;};this.isMuted=function isMuted(){return false;};this.isOnline=function isOnline(){return false;};this.isOnlineInChannel=function isOnlineInChannel(){return false;};this.isProfilePhotoVerified=function isProfilePhotoVerified(){return false;};this.getKnuddels=function getKnuddels(){return 0;};this.sendPostMessage=send;this.sendPrivateMessage=send;this.private=send;this.post=send;function send(){Logger.error('Cant send message to a virtual User-Object!');};_nickname=UAC.getNick(_uid);}());}
return UAC.getNick(nickname);};this.toString=function toString(value){switch(value){case UserStatus.Newbie:return'Newbie';break;case UserStatus.Family:return'Family';break;case UserStatus.Stammi:return'Stammi';break;case UserStatus.HonoryMember:return'Ehrenz';break;case UserStatus.Admin:return'Admin';break;case UserStatus.Sysadmin:return'Sysadmin';break;case UserStatus.SystemBot:return'Bot';break;default:return'[KFramework User]';break;}
return value+'';};}());
function View(name){this.javaClassName='View';var _name=name;var _width=100;var _height=100;var _mode=AppViewMode.Overlay;var _data={};var _loading={enabled:true,text:'Bitte warten...',image:'http://www.userapps.de/images/logo-kf.png',foreground:Color.fromRGB(255,255,255),background:Color.fromRGB(80,0,0)};var _document='';var _send_callback=undefined;var _view;var _file;this.setSize=function setSize(width,height){_width=width;_height=height;};this.getMode=function getMode(){return _mode;};this.setMode=function setMode(mode){_mode=mode;};this.setLoading=function setLoading(state){this.setLoadingData('enabled',state);};this.setLoadingData=function setLoadingData(name,value){if(typeof(_loading[name])=='undefined'){Logger.warn('Configuration "'+name+'" not exists.');}
if(value instanceof KImage){value=value.toString(true);}
_loading[name]=value;};this.close=function close(user){user.sendEvent('close',true);};this.setCallback=function setCallback(callback){_send_callback=callback;};this.send=function send(user){if(AppContent.popupContent==undefined){_mode=AppViewMode.Overlay;}
switch(_mode){case AppViewMode.Overlay:this.addString('_view_mode','overlay');_document=_name+'.html';_file=new HTMLFile(_document,_data);_view=AppContent.overlayContent(_file,_width,_height);break;case AppViewMode.Popup:this.addString('_view_mode','popup');_document=_name+'.html';_file=new HTMLFile(_document,_data);_view=AppContent.popupContent(_file,_width,_height);break;default:Logger.info('Bad AppContent Mode!');return false;break;}
if(user.getClientType()==ClientType.Applet&&!user.canSendAppContent(_view)){var text=new KCode();text.newLine();text.append('°RR°_ACHTUNG:_°r° Du benötigst mindestens _Java 8_ um _'+KnuddelsServer.getAppInfo().getAppName()+'_ zu spielen.');text.newLine();text.append('Um dieses Problem zu beheben bestehen 2 Möglichkeiten:');text.newLine();text.append('_1._ Java auf eine aktuelle Version updaten: _°BB>Java updaten|https://www.java.com/de/download/<°_°r° (empfohlen)');text.newLine();text.append('_2._ Den Mini-Chat nutzen: _°BB>Zum Mini-Chat|http://www.knuddels.de/htmlchat<°_°r°');user.sendPrivateMessage(text);return false;}
this.setLoadingView();if(!user.isOnlineInChannel()||!user.canSendAppContent(_view)||!user.canShowAppViewMode(_mode)){return false;}
user.sendAppContent(_view);if(typeof(_send_callback)!='undefined'){_send_callback(this,user);}
return true;};this.setLoadingView=function setLoadingView(){var config=_view.getLoadConfiguration();config.setEnabled(_loading.enabled);if(_loading.enabled){config.setText(_loading.text);config.setBackgroundColor(_loading.background);config.setForegroundColor(_loading.foreground);config.setLoadingIndicatorImage(_loading.image);}};this.clearData=function clearData(){_data={};};this.getString=function getString(key,defaultValue){return this.getObject(key,defaultValue);};this.addString=function addString(key,value){this.addObject(key,value);};this.removeString=function removeString(key){this.removeObject(key);};this.hasString=function hasString(key){return this.hasObject(key);};this.getNumber=function getNumber(key,defaultValue){return this.getObject(key,defaultValue);};this.addNumber=function addNumber(key,value){this.addObject(key,value);};this.removeNumber=function removeNumber(key){this.removeObject(key);};this.hasNumber=function hasNumber(key){return this.hasObject(key);};this.getObject=function getObject(key,defaultValue){if(this.hasObject(key)){return _data[key];}
return defaultValue;};this.addObject=function addObject(key,value){_data[key]=value;};this.removeObject=function removeObject(key){delete _data[key];};this.hasObject=function hasObject(key){return(_data[key]!=undefined);};this.toJSON=function toJSON(){return{name:_name,loading:_loading,size:{width:_width,height:_height},ui:{mode:_mode,view:_view,file:_file,document:_document},data:_data,functions:{send_callback:_send_callback}};};this.toString=function toString(){return'View';};};
var AppInfo=(new function AppInfo(){this.javaClassName='AppInfo';var _info=KnuddelsServer.getAppInfo();var _root_instance=undefined;this.getAppDeveloper=function getAppDeveloper(){return _info.getAppDeveloper();};this.getID=function getID(){return _info.getAppId();};this.getAppId=function getAppId(){Logger.info('AppInfo.getAppId() is DEPRECATED please use AppInfo.getID()');return this.getID();};this.getKey=function getKey(){return _info.getAppKey();};this.getAppKey=function getAppKey(){Logger.info('AppInfo.getAppKey() is DEPRECATED please use AppInfo.getKey()');return this.getKey();};this.getAppManagers=function getAppManagers(){return _info.getAppManagers();};this.getName=function getName(){return _info.getAppName();};this.getAppName=function getAppName(){Logger.info('AppInfo.getAppName() is DEPRECATED please use AppInfo.getName()');return this.getName();};this.getUID=function getUID(){return _info.getAppUid();};this.getAppUid=function getAppUid(){Logger.info('AppInfo.getAppUid() is DEPRECATED please use AppInfo.getUID()');return this.getUID();};this.getVersion=function getVersion(){return _info.getAppVersion();};this.getAppVersion=function getAppVersion(){Logger.info('AppInfo.getAppVersion() is DEPRECATED please use AppInfo.getVersion()');return this.getVersion();};this.getMaxPayoutKnuddelAmount=function getMaxPayoutKnuddelAmount(){return _info.getMaxPayoutKnuddelAmount();};this.getRootUID=function getRootUID(){return _info.getRootAppUid();};this.getRootAppUid=function getRootAppUid(){Logger.info('AppInfo.getRootAppUid() is DEPRECATED please use AppInfo.getRootUID()');return _info.getRootUID();};this.getTaxRate=function getTaxRate(){return _info.getTaxRate();};this.getTotalTaxKnuddelAmount=function getTotalTaxKnuddelAmount(){return _info.getTotalTaxKnuddelAmount();};this.stopApp=function stopApp(message,logMessage){Logger.info('AppInfo.stopApp(message, logMessage) is DEPRECATED');this.setRootInstance();_root_instance.stopApp(message,logMessage);};this.updateApp=function updateApp(message,logMessage){Logger.info('AppInfo.updateApp(message, logMessage) is DEPRECATED');this.setRootInstance();_root_instance.updateApp(message,logMessage);};this.setRootInstance=function setRootInstance(){if(typeof(_root_instance)!='undefined'){return;}
_root_instance=KnuddelsServer.getAppAccess().getOwnAppInstance().getRootInstance();};this.toString=function toString(){return'[KFramework AppInfo]';};}());
var VERSION='1.1.0';var KFramework=(new function KFramework(){this.load=['tools/JSON','tools/Functions','tools/Number','tools/String','tools/Array','tools/Object','tools/User','tools/Dice','tools/StringBuffer','core/Hash','core/Hooks','core/Database','core/Logger','core/Cronjob','core/Bot','core/KCode','core/KBank','core/Files','core/Channel','core/User','core/View','core/Toplist','core/AppInfo'];for(var entry in this.load){}
this.startUp=function startUp(){KBank.dataMigration();};this.store=function store(){Cron.saveData();};this.shutDown=function shutDown(){Cron.onShutdown();};this.toString=function toString(){return'[KFramework Core]';};}());
function KButton(text,command){this.javaClassName='KButton';var _text='';var _id=-1;var _command='';var _properties={};var _fix_escaping=false;function KButton(text,command){if(text===undefined){return;}
_text=text;if(command===undefined){return;}
_command=command;return this;};this.fixEscaping=function fixEscaping(state){_fix_escaping=state;};this.setID=function setID(id){_id=id;return this;};this.getID=function getID(){return _id;};this.getCommand=function getCommand(){return _command;};this.setCommand=function setCommand(command){_command=command;return this;};this.getText=function getText(){return _text;};this.setText=function setText(text){_text=text;return this;};this.getProperties=function getProperties(){return _properties;};this.setProperties=function setProperties(properties){_properties=properties;return this;};this.setIcon=function setIcon(icon){if(icon.startsWith('https://')||icon.startsWith('http://')){icon='../'+icon;}
_properties.icon=icon;return this;};this.removeIcon=function removeIcon(){delete _properties.icon;return this;};this.setColor=function setColor(color){_properties.color=color;return this;};this.removeColor=function removeColor(){delete _properties.color;return this;};this.getHeight=function getHeight(){return _properties.height;};this.setHeight=function setHeight(height){_properties.height=height;return this;};this.removeHeight=function removeHeight(){delete _properties.height;return this;};this.getWidth=function getWidth(){return _properties.width;};this.setWidth=function setWidth(width){_properties.width=width;return this;};this.removeWidth=function removeWidth(){delete _properties.width;return this;};this.setSize=function setSize(width,height){this.setWidth(width);this.setHeight(height);return this;};this.removeSize=function removeSize(){this.removeWidth();this.removeHeight();return this;};this.getX=function getX(){return _properties.mx;};this.setX=function setX(x){_properties.mx=x;return this;};this.getY=function getY(){return _properties.my;return this;};this.setY=function setY(y){_properties.my=y;return this;};this.setPosition=function setPosition(x,y){this.setX(x);this.setY(y);return this;};this.useTextborder=function useTextborder(bool){if(bool){_properties.textborder='1';}else{delete _properties.textborder;}
return this;};this.setEnabled=function setEnabled(bool){if(bool==false){_properties.enabled='0';}else{delete _properties.enabled;}
return this;};this.toString=function toString(){var buffer=new StringBuffer('°>{button}');if(_text.length>0){buffer.append(_text+'|'+(_id>0?_id:'')+'|');}
if(_command.length>0){if(_fix_escaping){buffer.append('call|'+_command.replace(/\|/g,'\\\\\\|').replace(/°/g,'\\\°'));}else{buffer.append('call|'+_command.replace(/\|/g,'\\\\\\\\\\|').replace(/°/g,'\\\\\\\°'));}}
_properties.each(function(value,name){buffer.append('|'+name+'|'+value);});buffer.append('<°');return buffer.toString();};KButton(text,command);}
var KCODE_TOOLTIPS_INSTANCES=0;function KTooltip(content){this.javaClassName='KTooltip';var _content=new KCode();var _instance=0;var _hover_disabled=false;var _width=100;var _height=100;function KTooltip(content){if(content!=undefined){_content.append(content);}
_instance=KCODE_TOOLTIPS_INSTANCES++;};this.setSize=function setSize(width,height){_width=width;_height=height;return this;};this.setWidth=function setWidth(width){_width=width;return this;};this.setHeight=function setHeight(height){_height=height;return this;};this.append=function append(content){_content.append(content);return this;};this.newLine=function newLine(){_content.newLine();return this;};this.disableHover=function disableHover(state){_hover_disabled=state;};this.getCommand=function getCommand(text,command){if(!(text instanceof KLink)){text=new KLink(text);if(_hover_disabled){text.setCommand((command==undefined?'':'/doubleaction '+command+'|')+'/openpulldown id_'+_instance+'.w_'+_width+'.h_'+_height);}else{text.setCommand((command==undefined?'/void':command)+'{{onEnter=/openpulldown id_'+_instance+'.w_'+_width+'.h_'+_height+'}}{{onExit=/closepulldown id_'+_instance+'}}');}}
return text;};this.toString=function toString(){var output=new KCode();output.append('°>{definetext|').append(_instance).append('}<°').append(_content).append('°>{definetext|').append(_instance).append('}<°');return output;};KTooltip(content);};
function KLink(text,command_left,command_right){this.javaClassName='KLink';var _text='';var _command_left=undefined;var _command_right=undefined;var _hover=true;var _hover_image=undefined;var _connected_icon=undefined;function KLink(text,command_left,command_right){_text=text||'';_command_left=command_left;_command_right=command_right;}
function prepareLink(string){return string.toString().replace(/(<|>|\||°)/g,'\\$1');}
this.connectAsIcon=function connectAsIcon(image){_connected_icon=image;};this.getText=function getText(){return _text;};this.setCommand=function setCommand(command_left,command_right){_command_left=command_left;_command_right=command_right;return this;};this.enableHover=function enableHover(state){_hover=state;return this;};this.setHoverImage=function setHoverImage(image){if(_text instanceof KImage){_hover_image=image;}else{Logger.warn('You can only use KImage.setHoverImage(image) when you bind a KImage!');}
return this;};this.toString=function toString(){var buffer=new StringBuffer('°>');if(_text instanceof KImage){if(_hover==false){_text.noPush(true);_hover_image.noPush(true);}
buffer.append(_text.toString(true));if(_hover_image!=undefined){buffer.append('|'+_hover_image.toString(true));}
buffer.append('<>--<>');}else{if(_connected_icon!=undefined&&_connected_icon instanceof KImage){buffer.append(_connected_icon.toString(true));buffer.append('<>--<>');}
if(_hover==false){buffer.append('_h');}
buffer.append(prepareLink(_text));}
if(_command_left!=undefined){buffer.append('|'+_command_left.replace(/\|/g,'\\\\\\\\\\|'));}
if(_command_right!=undefined){buffer.append('|'+_command_right.replace(/\|/g,'\\\\\\\\\\|'));}
buffer.append('<°');return buffer.toString();};KLink(text,command_left,command_right);};
function KCountdown(){this.javaClassName='KCountdown';var _properties={};var timer=null;this.setTime=function setTime(time){_properties.time=time;return this;};this.setFormat=function setFormat(format){_properties.format=format;return this;};this.setText=function setText(text){_properties.timeUpText=text;return this;};this.setCallback=function setCallback(callback){_properties.callback=callback;return this;};this.toString=function toString(){var buffer=new StringBuffer('°>{countdown}');var index=0;var length=_properties.size();_properties.each(function(value,name){buffer.append(name+'='+value);if(index+1<length){buffer.append('|');}
index++;});buffer.append('<°');if(isTypeOf(_properties.callback,'function')&&timer===null){timer=setTimeout(_properties.callback,_properties.time);}
return buffer.toString();};}
var FontStyle={PLAIN:0x00,BOLD:0x01,ITALIC:0x02};function KFont(name,style,size){this.javaClassName='KFont';var _name='Arial';var _size=14;var _style=FontStyle.PLAIN;var _available=['Roboto-Bold','Roboto-Light','FinelinerScript','Arial','Impact'];function KFont(name,style,size){_name=name;_size=size;_style=style;}
this.toString=function toString(){var output='';if(_style&FontStyle.BOLD){output+='_';}
if(_style&FontStyle.ITALIC){output+='"';}
output+='°';if(_available.indexOf(_name)>-1){output+='>{font}'+_name+'<';}else{Logger.info('Font '+_name+' does\'nt exists!');}
output+=_size+'°';return output;};KFont(name,style,size);}
delete KImage;var KImage=KImage||(function(image){this.javaClassName='KImage';this._path='';this._name='';this._extension='';this._properties={};if(image.substring(0,7)=='http://'||image.substring(0,8)=='https://'){var split=image.split('/');var length=split.length;image=split[length-1];for(var index=0;index<length-1;++index){this._path+=split[index];this._path+='/';}}
if(image.indexOf('..')>-1){var properties=image.split('..');var instance=this;var split=image.split('.');var length=split.length;image=properties[0];image+='.';image+=split[length-1];split.each(function(name,index){if(name.length==0||index==0||index==length-1){return;}
if(name.search(/[^a-zA-Z0-9_]+/gi)!=-1){return;}
if(name.indexOf('_')!=-1){var split=name.split('_');instance._properties[split[0]]=split[1];}else{instance._properties[name]=null;}});}
var split=image.split('.');if(['png','jpg','jpeg','bmp','gif'].indexOf(split[1].toLowerCase())!=-1){this._name=split[0];this._extension=split[1];}else{this._name=image;}
this._name=this._name.replace(/&\.(png|jpeg|gif|jpg|bmp)/gi,'');var first=this._name.substring(0,1);if(first=='/'||first=='~'){this._name=this._name.substring(1);this._path=KnuddelsServer.getFullImagePath('');}
this.toString=function toString(only_path){only_path=only_path||false;var output=(only_path==true?'':'°>')+this._path+this._name;var buffer=new StringBuffer();if(this._properties.size()>0){buffer.append('..');this._properties.each(function(value,name){if(value==undefined){return;}
buffer.append('.'+name+(value==null?'':'_'+value));});}
return output+(this._extension.length==0?'&'+buffer.toString()+'.png':buffer.toString()+'.'+this._extension)+(only_path==true?'':'<°');};return this;});KImage.prototype=KImage.prototype||{};if(!KImage.prototype.addCustom){Object.defineProperty(KImage.prototype,'addCustom',{enumerable:false,configurable:false,writable:false,value:function addCustom(name,value){this._properties[name]=value;return this;}});}
if(!KImage.prototype.alwaysCopy){Object.defineProperty(KImage.prototype,'alwaysCopy',{enumerable:false,configurable:false,writable:false,value:function alwaysCopy(state){this.addCustom('alwayscopy',(state?null:undefined));return this;}});}
if(!KImage.prototype.noPush){Object.defineProperty(KImage.prototype,'noPush',{enumerable:false,configurable:false,writable:false,value:function noPush(state){this.addCustom('nopush',(state?null:undefined));return this;}});}
if(!KImage.prototype.setContainerSize){Object.defineProperty(KImage.prototype,'setContainerSize',{enumerable:false,configurable:false,writable:false,value:function setContainerSize(width,height){this.addCustom('w',width);this.addCustom('h',height);return this;}});}
if(!KImage.prototype.setSize){Object.defineProperty(KImage.prototype,'setSize',{enumerable:false,configurable:false,writable:false,value:function setSize(width,height){this.addCustom('mw',width);this.addCustom('mh',height);return this;}});}
if(!KImage.prototype.setPosition){Object.defineProperty(KImage.prototype,'setPosition',{enumerable:false,configurable:false,writable:false,value:function setPosition(x,y){this.addCustom('mx',x);this.addCustom('my',y);return this;}});}
if(!KImage.prototype.setX){Object.defineProperty(KImage.prototype,'setX',{enumerable:false,configurable:false,writable:false,value:function setX(x){this.addCustom('mx',x);return this;}});}
if(!KImage.prototype.setY){Object.defineProperty(KImage.prototype,'setY',{enumerable:false,configurable:false,writable:false,value:function setY(y){this.addCustom('my',y);return this;}});}
if(!KImage.prototype.setLabel){Object.defineProperty(KImage.prototype,'setLabel',{enumerable:false,configurable:false,writable:false,value:function setLabel(text){this.addCustom('label',text);return this;}});}
if(!KImage.prototype.setLabelPosition){Object.defineProperty(KImage.prototype,'setLabelPosition',{enumerable:false,configurable:false,writable:false,value:function setLabelPosition(x,y){this.addCustom('lmx',x);this.addCustom('lmy',y);return this;}});}
if(!KImage.prototype.setLabelColor){Object.defineProperty(KImage.prototype,'setLabelColor',{enumerable:false,configurable:false,writable:false,value:function setLabelColor(color){this.addCustom('labelcolor',color);return this;}});}
if(!KImage.prototype.setLabelSize){Object.defineProperty(KImage.prototype,'setLabelSize',{enumerable:false,configurable:false,writable:false,value:function setLabelSize(size){this.addCustom('labelfontsize',size);return this;}});}
if(!KImage.prototype.enableLabelBorder){Object.defineProperty(KImage.prototype,'enableLabelBorder',{enumerable:false,configurable:false,writable:false,value:function enableLabelBorder(bool){this.addCustom('labelborder',(bool?'1':'0'));return this;}});}
if(!KImage.prototype.setBorder){Object.defineProperty(KImage.prototype,'setBorder',{enumerable:false,configurable:false,writable:false,value:function setBorder(size){this.addCustom('border',size);return this;}});}
if(!KImage.prototype.setQuadcut){Object.defineProperty(KImage.prototype,'setQuadcut',{enumerable:false,configurable:false,writable:false,value:function setQuadcut(size){this.addCustom('quadcut',size);return this;}});}
if(!KImage.prototype.setShadow){Object.defineProperty(KImage.prototype,'setShadow',{enumerable:false,configurable:false,writable:false,value:function setShadow(position){this.addCustom('shadow',position);return this;}});}
if(!KImage.prototype.setMirror){Object.defineProperty(KImage.prototype,'setMirror',{enumerable:false,configurable:false,writable:false,value:function setMirror(state){this.addCustom('mirror',(state?null:undefined));return this;}});}
if(!KImage.prototype.setGreyscale){Object.defineProperty(KImage.prototype,'setGreyscale',{enumerable:false,configurable:false,writable:false,value:function setGreyscale(state){this.addCustom('gray',(state?null:undefined));return this;}});}
if(!KImage.prototype.setTransparency){Object.defineProperty(KImage.prototype,'setTransparency',{enumerable:false,configurable:false,writable:false,value:function setTransparency(value){this.addCustom('opacity',value);return this;}});}
if(!KImage.prototype.setMouseSize){Object.defineProperty(KImage.prototype,'setMouseSize',{enumerable:false,configurable:false,writable:false,value:function setMouseSize(width,height){this.addCustom('mousew',width);this.addCustom('mouseh',height);return this;}});}
if(!KImage.prototype.setMousePosition){Object.defineProperty(KImage.prototype,'setMousePosition',{enumerable:false,configurable:false,writable:false,value:function setMousePosition(x,y){this.addCustom('mousex',x);this.addCustom('mousey',y);return this;}});}
var Colors={CHANNEL_RED:new ColorInstance('RR',[-255,0,0]),CHANNEL_BLUE:new ColorInstance('BB',[0,0,-255]),WHITE:new ColorInstance('W',[255,255,255]),BLACK:new ColorInstance('K',[0,0,0]),GRAY:new ColorInstance('A',[128,128,128]),LIGHT_GREY:new ColorInstance('L',[192,192,192]),DARK_GREY:new ColorInstance('D',[64,64,64]),RED:new ColorInstance('R',[255,0,0]),BLUE:new ColorInstance('B',[0,0,255]),GREEN:new ColorInstance('G',[0,255,0]),DARK_GREEN:new ColorInstance('E',[0,172,0]),YELLOW:new ColorInstance('Y',[255,255,0]),CYAN:new ColorInstance('C',[0,255,255]),MAGENTA:new ColorInstance('M',[255,0,255]),PINK:new ColorInstance('P',[255,175,175]),ORANGE:new ColorInstance('O',[255,200,0]),BROWN:new ColorInstance('N',[150,74,0]),decode:function(hex){var color=new KColor();color.decode(hex);return color;}};function KColor(red,green,blue){this.javaClassName='KColor';var _red=-1;var _green=-1;var _blue=-1;function KColor(instance,red,green,blue){if(red!=undefined&&green==undefined&&blue==undefined){if(isHex(red)){instance.decode(red);return;}else if(isRGB(red)){var split=red.split(',');_red=parseInt(split[0],10);_green=parseInt(split[1],10);_blue=parseInt(split[2],10);return;}}
_red=red;_green=green;_blue=blue;};function isHex(input){return(input.match(/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i));};function isRGB(input){return(input.match(/^([\d]{1,3}),([\d]{1,3}),([\d]{1,3})$/i));};function isConstant(){for(var name in Colors){if(name=='decode'){continue;}
var _color_instance=Colors[name];if(_color_instance!=undefined){if(_color_instance.getRed()==_red&&_color_instance.getGreen()==_green&&_color_instance.getBlue()==_blue){return true;}}}
return false;};function getConstant(){for(var name in Colors){if(name=='decode'){continue;}
var _color_instance=Colors[name];if(_color_instance.getRed()==_red&&_color_instance.getGreen()==_green&&_color_instance.getBlue()==_blue){return _color_instance;}}
return'';};this.getRGB=function getRGB(){var buffer=new StringBuffer();buffer.append(_red).append(',').append(_green).append(',').append(_blue);return buffer.toString();};this.decode=function decode(hex){var result=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);_red=parseInt(result[1],16);_green=parseInt(result[2],16);_blue=parseInt(result[3],16);};this.toString=function toString(){var output=new KCode();if(isConstant()){output.append(getConstant());}else{output.append('°[').append(_red).append(',').append(_green).append(',').append(_blue).append(']°');}
return output;};KColor(this,red,green,blue);};function ColorInstance(key,rgb){this.javaClassName='ColorInstance';this.getColorKey=function getColorKey(){return key;};this.getRGB=function getRGB(){return rgb;};this.getRed=function getRed(){return rgb[0];};this.getGreen=function getGreen(){return rgb[1];};this.getBlue=function getBlue(){return rgb[2];};this.toString=function toString(){var output=new KCode();output.append('°').append(key).append('°');return output;};}
function KTable(){this.javaClassName='KTable';var _rows=[];this.add=function add(element){_rows.push(element);return this;};this.toString=function toString(){var output=new KCode();output.append('°>{table');if(_rows.length>0){output.append('|');}
_rows.each(function(row,row_index){row.getCells().each(function(cell,cell_index){output.append('|').append(cell.getSize());});return false;});output.append('}<°');_rows.each(function(row,index){output.append(row.toString(index==0));});output.append('°>{endtable}<°');return output;};}
function KRow(){this.javaClassName='KRow';var _cells=[];function KRow(){_cells=[];}
this.add=function add(cell){_cells.push(cell);return this;};this.getCells=function getCells(){return _cells;};this.toString=function toString(display){display=display||false;var output=new KCode();if(!display){output.append('°>{tr}<°');}
_cells.each(function(cell){output.append(cell);});return output;};KRow();}
function KCell(size,content){this.javaClassName='KCell';var _size=0;var _content='';function KCell(size,content){_size=size||0;_content=content||'';}
this.getSize=function getSize(){return _size;};this.toString=function toString(){var output=new KCode();output.append('°>{tc}<°').append(_content);return output;};KCell(size,content);}
var KCODE_GROUPS_INSTANCES=0;function KGroup(){this.javaClassName='KGroup';var _groups=[undefined];var _show=0;var _layout_box=false;this.add=function add(content){_groups.push(content);return this;};this.remove=function remove(index){delete _groups[index];return this;};this.update=function update(index,content){_groups[index]=content;return this;};this.show=function show(index){_show=index;return this;};this.enableBoxLayout=function enableBoxLayout(state){_layout_box=state;return this;};this.getNavigation=function getNavigation(titles){titles=(titles==undefined?[]:titles);var buffer=new StringBuffer();var size=_groups.size();buffer.append('°12BB+0000°_°>LEFT<°');_groups.each(function(content,index){if(content==undefined){return;}
var entry=parseInt(index,10)+1;var title=(titles[entry-2]==undefined?'Tab '+entry:titles[entry-2]);if(_layout_box){var left='layout/tab_i_l...w_8.mx_-1.png';var middle='layout/tab_i_c...label_'+title+'.mw_'+(title.length*1.12)+'.png';var right='layout/tab_i_r.png';buffer.append('°>'+left+'<°').append('°>'+middle+'|'+middle+'<>--<>|/tp-showgrp '+entry+'<°');buffer.append('°>'+right+'<°');}else{buffer.append('°>'+title+'|/tp-showgrp '+entry+'<°');if(entry<size){buffer.append(' - ');}}});buffer.append('°>LEFT<°_°r##°');return buffer.toString();};this.getTabCommand=function getTabCommand(index){return'/tp-showgrp '+index;};this.switchTab=function switchTab(index){return'°>{setdisplaygroup}'+index+'<°';};this.toString=function toString(){var buffer=new StringBuffer();buffer.append('°>{addDisplayGroup}').append(_show).append('<°');_groups.each(function(content,index){if(content==undefined){return;}
buffer.append('°>{displayGroup}').append(parseInt(index,10)).append('<°').append(content).append('°>{displayGroupEnd}<°');});return buffer.toString();};};