UNPKG

json-object-editor

Version:

JOE the Json Object Editor | Platform Edition

8 lines 145 kB
/*/---------------------------------------------------------/*/ /*/ Craydent LLC v1.8.1 /*/ /*/ Copyright 2011 (http://craydent.com/about) /*/ /*/ Dual licensed under the MIT or GPL Version 2 licenses. /*/ /*/ (http://craydent.com/license) /*/ /*/---------------------------------------------------------/*/ function __isNewer(e,r){return e[0]==r[0]?(e.splice(0,1),r.splice(0,1),r.length&&e.length?__isNewer(e,r):!1):parseInt(e[0])<parseInt(r[0])}function __cleanUp(){try{delete $w.__current,delete $w.__thisVersion,delete $w.__thisIsNewer,delete $w.__isNewer,delete $w.__version,delete $w._ie,delete $w._droid,delete $w._amay,delete $w._browser,delete $w._os,delete $w._device,delete $w._engine}catch(e){$w.__current=void 0,$w.__thisVersion=void 0,$w.__thisIsNewer=void 0,$w.__isNewer=void 0,$w.__version=void 0,$w._ie=void 0,$w._droid=void 0,$w._amay=void 0,$w._browser=void 0,$w._os=void 0,$w._device=void 0,$w._engine=void 0}}function __add_fillTemplate_ref(e){try{var r=suid();return fillTemplate.refs["ref_"+fillTemplate.refs.length]=r,fillTemplate.refs[r]=e,fillTemplate.refs.push(e),r}catch(t){error("fillTemplate.__add_fillTemplate_ref",t)}}function __and(){try{var e=0;for(len=arguments.length;len>e;e++){var r=arguments[e];if(!r)return""}return arguments[e-1]}catch(t){error("fillTemplate.__and",t)}}function __clean_micro_templates(){var e=fillTemplate._micro_templates;for(var r in e)e.hasOwnProperty(r)&&($CSS("[data-craydent-bind*='"+r+"']").length||delete e[r])}function __contextualizeMethods(e){try{return e=e||{},e.Benchmarker=Benchmarker,e.Cursor=Cursor,e.JSZip=JSZip,e.OrderedList=OrderedList,e.Queue=Queue,e.Set=Set,e.addObjectPrototype=addObjectPrototype,e.ajax=ajax,e.cout=cout,e.cuid=cuid,e.emit=emit,e.error=error,e.fillTemplate=fillTemplate,e.foo=foo,e.isNull=isNull,e.logit=logit,e.namespace=namespace,e.next=next,e.now=now,e.parseBoolean=parseBoolean,e.parseRaw=parseRaw,e.rand=rand,e.suid=suid,e.syncroit=syncroit,e.tryEval=tryEval,e.wait=wait,e.xmlToJson=xmlToJson,e.yieldable=yieldable,e.zipit=zipit,e}catch(r){error("__contextualizeMethods",r)}}function __convert_regex_safe(e){try{return e.replace(/\\/gi,"\\\\").replace(/\$/gi,"\\$").replace(/\//gi,"\\/").replace(/\^/gi,"\\^").replace(/\./gi,"\\.").replace(/\|/gi,"\\|").replace(/\*/gi,"\\*").replace(/\+/gi,"\\+").replace(/\?/gi,"\\?").replace(/\!/gi,"\\!").replace(/\{/gi,"\\{").replace(/\}/gi,"\\}").replace(/\[/gi,"\\[").replace(/\]/gi,"\\]").replace(/\(/gi,"\\(").replace(/\)/gi,"\\)").replace("\n","\\n")}catch(r){error("__convert_regex_safe",r)}}function __count(e){try{return e.length}catch(r){error("fillTemplate.count",r)}}function __dup(e){try{for(var r in e)e.hasOwnProperty(r)&&(this[r]=e[r])}catch(t){error("__dup",t)}}function __enum(e,r,t){try{r=r||", ",t=t||["",""];var i=[],a="";if($c.isArray(e))i=e.slice(0);else if($c.isObject(e))for(var n in e)e.hasOwnProperty(n)&&i.push(n);for(var s=0,o=i.length;o>s;s++){var n=i[s],c=$c.replace_all(t[0],["{ENUM_VAR}","{ENUM_VAL}"],[n,e[n]]),l=$c.replace_all(t[1],["{ENUM_VAR}","{ENUM_VAL}"],[n,e[n]]);a+=c+n+l+r}return a.slice(0,-1*r.length)}catch(u){error("fillTemplate.enum",u)}}function __logic_parser(e,r,t){if(!e)return"";var i=$c.TEMPLATE_TAG_CONFIG,a=[],n={};e=$c.replace_all(e,i.IGNORE_CHARS,[""]),$c.eachProperty(i,function(r){if(r.begin){var t=$c.indexOfAlt(e,r.begin);a.push(t),n[t]=r}});var s=Math.min.apply(Math,$c.condense(a,[-1]));return n[s]?e.substring(0,s)+n[s].parser(e.substring(s),r,t):e}function __observe_helper(e,r,t,i){try{if($c.isObject(e))return observe(e,r,t,i);if(!$c.isArray(e))return;for(var a,n=0;a=e[n++];)$c.isObject(a)&&observe(a,r,t,i)}catch(s){error("observe.observe_helper",s)}}function __on_observable_change(e){try{var r=e[0],t=r.object,i=r.name,a=r.oldValue,n=fillTemplate._observing,s=fillTemplate._micro_templates;if(t[i]!=a){var o=n.indexOf(t),c=n["hash_"+o],l=RegExp(c+"[a-zA-Z0-9,]*."+i+";?|$"),u=Array.prototype.slice.call($CSS("[data-craydent-bind*='"+c+"']")||[]).filter(function(e){return l.test(e.getAttribute("data-craydent-bind"))});if(!$CSS("[data-craydent-bind*='"+c+"']").length)return void delete n["hash_"+o];for(var h,p=0;h=u[p++];)if(!h.isOrphan()){var d=h.getAttribute("data-craydent-bind").split(":")[0],f=$c.getProperty(n,"parents_"+o+".0")||t;u[p-1].replace(fillTemplate(s[d].template.replace_all("${craydent_bind}",c),f).toDomElement())}}}catch(m){error("observe.on_observable_change",m)}}function __or(){try{for(var e=0,r=arguments.length;r>e;e++){var t=arguments[e];if(t)return t}return""}catch(i){error("fillTemplate.__or",i)}}function __processBlocks(e,r,t,i){i=i||{};for(var a=[],n=[],s=0,o=[],c=0;-1!=(s=$c.indexOfAlt(t,e,s))&&-1!=(c=$c.indexOfAlt(t,r,c));)-1!=s&&(n.push(s),s++),-1!=c&&(o.push(c),c++);if(n.length!=o.length)return a.push({id:"##"+suid()+"##",block:"",body:"",code:t}),a;for(var l=OrderedList([],function(e,r){return e.end<r.end?-1:e.end>r.end?1:0});n.length;){for(var u=0;o[0]>n[u];)u++;u--,l.add({begin:n[u],end:o[0]}),$c.removeAt(n,u),$c.removeAt(o,0)}for(var h,p=t.match(r)[0].length,d=0;h=l[d++];){var f="##"+suid()+"##",m=t.slice(h.begin,h.end+p),_=m.match(e)[0].length,g=t.slice(h.begin+_,h.end);t=t.replace(m,f),a.push({id:f,block:m,body:g,code:t}),i[f]=m;for(var $,v=d;$=l[v++];){var y=m.length-f.length;$.end-=y,$.begin>h.end&&($.begin-=y)}}return a.reverse()}function __parseArithmeticExpr(e,r,t){try{var i;switch(t){case"$add":i=0;for(var a,n=0;a=r.$add[n++];)i+=__processExpression(e,a);return i;case"$subtract":return __processExpression(e,r.$subtract[0])-__processExpression(e,r.$subtract[1]);case"$multiply":i=1;for(var a,n=0;a=r.$multiply[n++];)i*=__processExpression(e,a)||0;return i;case"$divide":return __processExpression(e,r.$divide[0])/__processExpression(e,r.$divide[1]);case"$mod":return __processExpression(e,r.$mod[0])%__processExpression(e,r.$mod[1])}}catch(s){error("aggregate.__parseArithmeticExpr",s)}}function __parseArrayExpr(e,r,t){try{switch(t){case"$size":return(__processExpression(e,r[t],t)||[]).length}}catch(i){error("aggregate.__parseArrayExpr",i)}}function __parseBooleanExpr(e,r,t){try{var i,a=[],n=0;switch(t){case"$and":for(a=r.$and;i=a[n++];)if(!__processExpression(e,a))return!1;return!0;case"$or":for(a=r.$or;i=a[n++];)if(__processExpression(e,a))return!0;return!1;case"$not":return a=r.$not,!__processExpression(e,a[0])}}catch(s){error("aggregate.__parseBooleanExpr",s)}}function __parseComparisonExpr(e,r,t){try{var i=[void 0,null,Number,"undefined"!=typeof Symbol?Symbol:"Symbol",String,Object,Array,"undefined"!=typeof BinData?BinData:"BinData","undefined"!=typeof ObjectId?ObjectId:"ObjectId",Boolean,Date,"undefined"!=typeof Timestamp?Timestamp:"Timestamp",RegExp],a=__processExpression(e,r[t][0]),n=__processExpression(e,r[t][1]),s=null;switch(a==n&&(s=0),n>a&&(s=-1),a>n&&(s=1),$c.isNull(s)&&(a=i.indexOf(-1!=[null,void 0].indexOf(a)?a:a.constructor),n=i.indexOf(-1!=[null,void 0].indexOf(n)?n:n.constructor),n>a&&(s=-1),a>n&&(s=1)),t){case"$cmp":return s;case"$eq":return 0===s;case"$gt":return 1===s;case"$gte":return 1===s||0===s;case"$lt":return-1===s;case"$lte":return-1===s||0===s;case"$ne":return 0!==s}}catch(o){error("aggregate.__parse",o)}}function __parseCond(e,r){try{if(!$c.isObject(r)||!r.$cond)return r;var t,i,a,n=r.$cond;return $c.isArray(n)?(t=n[0],i=n[1],a=n[2]):(t=n["if"],i=n.then,a=n["else"]),__processExpression(e,t)?i:a}catch(s){error("aggregate.__parseCond",s)}}function __parseConditionalExpr(e,r,t){try{switch(t){case"$cond":return __parseCond(e,r);case"$ifNull":var i=__processExpression(e,r.$ifNull[0]);return isNull(i)?__processExpression(e,r.$ifNull[1]):i}}catch(a){error("aggregate.__parseConditionExpr",a)}}function __parseDateExpr(e,r,t){var i=__processExpression(e,r[t]);try{switch(t){case"$dayOfYear":return i.getDayOfYear();case"$dayOfMonth":return i.getDate();case"$dayOfWeek":return i.getDay()+1;case"$year":return i.getFullYear();case"$month":return i.getMonth()+1;case"$week":return i.getWeek();case"$hour":return i.getHours();case"$minute":return i.getMinutes();case"$second":return i.getSeconds();case"$millisecond":return i.getMilliseconds();case"$dateToString":return i=__processExpression(e,r[t].date),$c.format(i,r[t].format)}}catch(a){error("aggregate.__parseDateExpr",a)}}function __parseSetExpr(e,r,t){try{var i,a,n=1,s=0;switch(t){case"$setEquals":for(;i=r[t][n++];){var o=$c.duplicate(__processExpression(e,r[t][n-2])),c=$c.duplicate(__processExpression(e,i));if(!$c.isArray(o)||!$c.isArray(c))throw"Exception: All operands of $setEquals must be arrays. One argument is of type: "+(typeof($c.isArray(o)?c:o)).captialize();if($c.toSet(o),$c.toSet(c),o.length!=c.length)return!1;for(var l=o.length;l>s;s++)if(-1==c.indexOf(o[s]))return!1}return!0;case"$setIntersection":var u=$c.duplicate(__processExpression(e,r[t][0])),h="Exception: All operands of $setIntersection must be arrays. One argument is of type: ";if(!$c.isArray(u))throw h+(typeof u).captialize();for($c.toSet(u);i=r[t][n++];){var o=$c.duplicate(__processExpression(e,i));if(!$c.isArray(o))throw h+ +(typeof o).captialize();if($c.toSet(o),o.length<u.length){var p=o;o=u,u=p}for(var l=u.length;l>s;s++)-1==o.indexOf(u[s])&&($c.removeAt(u,s--),l--);if(!u.length)return u}return u;case"$setUnion":var u=$c.duplicate(__processExpression(e,r[t][0])),h="Exception: All operands of $setUnion must be arrays. One argument is of type: ";if(!$c.isArray(u))throw h+(typeof u).captialize();for(;i=r[t][n++];){var d=$c.duplicate(__processExpression(e,i));if(!$c.isArray(d))throw h+ +(typeof d).captialize();u=u.concat(d)}return $c.toSet(u);case"$setDifference":var f=$c.duplicate(__processExpression(e,r[t][0])),m=$c.duplicate(__processExpression(e,r[t][1])),u=[];if(!$c.isArray(f)||!$c.isArray(m))throw"Exception: All operands of $setEquals must be arrays. One argument is of type: "+(typeof($c.isArray(f)?m:f)).captialize();for(var l=f.length;l>s;s++){var a=f[s];-1==m.indexOf(a)&&-1==u.indexOf(a)&&u.push(a)}return u;case"$setIsSubset":var f=$c.duplicate(__processExpression(e,r[t][0])),m=$c.duplicate(__processExpression(e,r[t][1])),u=[];if(!$c.isArray(f)||!$c.isArray(m))throw"Exception: All operands of $setEquals must be arrays. One argument is of type: "+(typeof($c.isArray(f)?m:f)).captialize();return $c.isSubset(f,m);case"$anyElementTrue":for(var f=$c.duplicate(__processExpression(e,r[t][0])),_=[void 0,null,0,!1];a=f[s++];)if(-1==_.indexOf(a))return!0;return!1;case"$allElementsTrue":for(var f=$c.duplicate(__processExpression(e,r[t][0])),_=[void 0,null,0,!1],l=f.length;l>s;s++)if(-1!=_.indexOf(f[s]))return!1;return!0}}catch(g){error("aggregate.__parseSetExpr",g)}}function __parseStringExpr(e,r,t){try{switch(t){case"$concat":for(var i,a="",n=0;i=r.$concat[n++];)a+=__processExpression(e,i);return a;case"$substr":var s=r.$substr[1],o=r.$substr[2]<0?void 0:r.$substr[2];return __processExpression(e,r.$substr[0]).substr(s,o);case"$toLower":return(__processExpression(e,r.$toLower)||"").toLowerCase();case"$toUpper":return(__processExpression(e,r.$toLower)||"").toUpperCase();case"$strcasecmp":var c=""+(__processExpression(e,r.$strcasecmp[0])||""),l=""+(__processExpression(e,r.$strcasecmp[1])||"");if(c==l)return 0;if(l>c)return-1;if(c>l)return 1}}catch(u){error("aggregate.__parseStringExpr",u)}}function __parseVariableExpr(e,r,t){try{switch(t){case"$map":for(var i=__processExpression(e,r[t].input),a="$"+r[t].as,n=r[t]["in"],s=0,o=i.length;o>s;s++)e[a]=i[s],i[s]=__processExpression(e,n),delete e[a];return i;case"$let":var c=r[t].vars,l=[],u=null,s=0;for(var h in c)c.hasOwnProperty(h)&&(e["$"+h]=__processExpression(e,c[h]),l.push(h));u=__processExpression(e,r[t]["in"]);for(var s=0,o=l.length;o>s;s++)delete e[l[s]];return u}}catch(p){error("aggregate.__parseVariableExpr",p)}}function __processAccumulator(e,r,t,i){try{var a=__processExpression(e,r.$sum||r.$avg||r.$first||r.$last||r.$max||r.$min||r.$push||r.$addToSet||r.$stdDevPop||r.$stdDevSamp);switch(!0){case!!r.$sum:return(a||0)+(t||0);case!!r.$avg:return t=t||[],$c.isNull(a)||t.push(a),i.length==i.index+1&&(t=$c.average(t)),t;case!!r.$first:return $c.isNull(t)&&(t=a),t;case!!r.$last:return $c.isNull(a)?t:a;case!!r.$max:return $c.isNull(t)&&(t=-9007199254740991),$c.isNull(a)&&(a=-9007199254740991),i.length==i.index+1&&a==t==-9007199254740991?void 0:Math.max(a,t);case!!r.$min:return $c.isNull(t)&&(t=9007199254740991),$c.isNull(a)&&(a=9007199254740991),i.length==i.index+1&&a==t==9007199254740991?void 0:Math.min(a,t||9007199254740991);case!!r.$push:return t=t||[],$c.isNull(a)||t.push(a),t;case!!r.$addToSet:return t=t||[],$c.isNull(a)||-1!=t.indexOf(a)||t.push(a),t;case!!r.$stdDevSamp:return i.sample&&-1!=i.sample.indexOf(e)&&($c.isNull(a)||(t=t||[],t.push(a))),i.length==i.index+1&&(t=$c.stdev(t||[])),$c.isNull(t)?null:t;case!!r.$stdDevPop:return $c.isNull(a)||(t=t||[],t.push(a)),i.length==i.index+1&&(t=$c.stdev(t)),$c.isNull(t)?null:t}}catch(n){error("aggregate.__processAccumulator",n)}}function __processAttributes(e){try{var r={},t=e.indexOf(">"),i=e.substring(1,t),a=$c.indexOfAlt(i,/\s|>/),n=(-1==a?i:i.substring(0,$c.indexOfAlt(i,/\s|>/)),-1==a?"":i.substring($c.indexOfAlt(i,/\s|>/))),s=e.substring(t+1,e.indexOf("<",t));if(n){r["#text"]=s;for(var o=n.split(" "),c=0,l=o.length;l>c;c++){var u=o[c];if(u){var h=u.split("=");r["@attributes"]=r["@attributes"]||{},r["@attributes"][h[0].trim()]=$c.tryEval(h[1])||h[1].trim()}}}return r}catch(p){error("xmlToJson.__processAttributes",p)}}function __processChildren(e,r){try{for(var t,i=0,a={};t=r[i++];){var n=t.indexOf(">"),s=t.lastIndexOf("</"),o=__processAttributes(t),c=$c.strip(t.substring(n+1,s),"\n").trim();1==r.length?a[e]=$c.merge(xmlToJson(c),o):(a[e]=a[e]||[],a[e].push($c.merge(o,$c.xmlToJson(c))))}return a}catch(l){error("xmlToJson.__processChildren",l)}}function __processExpression(e,r){try{if($c.isString(r))return"$"==r[0]&&(r=r.substr(1)),$c.getProperty(e,r.replace("$CURRENT.",""));if(!$c.isObject(r))return r;for(var t in r)if(r.hasOwnProperty(t)){var i=r[t],a=["$literal"],n=["$and","$or","$not"],s=["$setEquals","$setIntersection","$setUnion","$setDifference","$setIsSubset","$anyElementTrue","$allElementsTrue"],o=["$cmp","$eq","$gt","$gte","$lt","$lte","$ne"],c=["$add","$subtract","$multiply","$divide","$mod"],l=["$concat","$substr","$toLower","$toUpper","$strcasecmp"],u=["$size"],h=["$map","$let"],p=["$dayOfYear","$dayOfMonth","$dayOfWeek","$year","$month","$week","$hour","$minute","$second","$millisecond","$dateToString"],d=["$cond","$ifNull"];switch(!0){case-1!=a.indexOf(t):return r;case-1!=n.indexOf(t):return __parseBooleanExpr(e,r,t);case-1!=s.indexOf(t):return __parseSetExpr(e,r,t);case-1!=o.indexOf(t):return __parseComparisonExpr(e,r,t);case-1!=c.indexOf(t):return __parseArithmeticExpr(e,r,t);case-1!=l.indexOf(t):return __parseStringExpr(e,r,t);case-1!=u.indexOf(t):return __parseArrayExpr(e,r,t);case-1!=h.indexOf(t):return __parseVariableExpr(e,r,t);case-1!=p.indexOf(t):return __parseDateExpr(e,r,t);case-1!=d.indexOf(t):return __parseConditionalExpr(e,r,t);default:__processExpression(e,i)}}}catch(f){error("aggregate.__parseExpression",f)}}function __processGroup(e,r){try{for(var t,i=r._id,a=0,n={},s=[],o={index:0,length:e.length,sample:e.sample};t=e[o.index=a++];){var c,l="null",u=null;if(i){u={};for(var h in i)i.hasOwnProperty(h)&&(u[h]=__processExpression(t,i[h]));l=JSON.stringify(u)}n[l]?c=n[l]:(c=n[l]={_id:u},s.push(c));for(var h in r)r.hasOwnProperty(h)&&"_id"!=h&&(c[h]=__processAccumulator(t,r[h],c.hasOwnProperty(h)?c[h]:void 0,o))}return s}catch(p){error("aggregate.__processGroup",p)}}function __processSiblings(e){try{var r,t=e.split("<"),i={},a="",n="";i["#text"]=i["#text"]||"";for(var s=0;s<t.length;s++){var o=t[s];if(o)if(a){if(-1!=(r=o.indexOf("/"+a+">"))){var c=$c.strip(o.substr(r+a.length+2),["\n"," "]);c&&(i["#text"]+=c),n+="<"+o.substring(0,r+a.length+2),i=$c.merge(i,xmlToJson(n)),a="",n=""}}else{if(r=o.indexOf(">"),-1==r){s?n+=o:i["#text"]+=$c.strip(o,["\n"," "]);continue}a=o.split(/\s|>/)[0],n+="<"+o}}return i["#text"]||delete i["#text"],i}catch(l){error("xmlToJson.__processSiblings",l)}}function __processStage(e,r){try{var t="",i={};for(var a in r)if(r.hasOwnProperty(a)){if(t)throw"Exception: A pipeline stage specification object must contain exactly one field.";t=a,i=r[a]}switch(a){case"$project":return $c.where(e,{},i);case"$match":return $c.where(e,i);case"$redact":return _redact(e,i);case"$limit":return e.slice(0,i);case"$skip":return e.slice(i);case"$unwind":return _unwind(e,i);case"$group":return __processGroup(e,i);case"$sort":var n=[];for(var s in i)if(i.hasOwnProperty(s)){var o="";-1==i[s]&&(o="!"),n.push(o+s)}return $c.sortBy(e,n);case"$out":var c=$c.duplicate(e,!0);return $c.isString(i)?$g[i]=c:$c.isArray(i)&&($c.removeAll(i),c=$c.merge(i,c)),c;case"$sample":for(var l=[],u=0,h=e.length-1;u<i.size;)l.push(e[Math.round($c.rand(0,h,!0))]),u++;return e.sample=l,e;case"$lookup":for(var p,u=0,l=i.from,d=i.localField,f=i.foreignField,s=i.as;p=e[u++];){var m={};m[f]=p[d]||{$exists:!1},p[s]=$c.where(l,m)}}return e}catch(_){error("aggregate.__processStage",_)}}function __pullHelper(e,r){for(var t=0,i=r.length;i>t;t++)for(var a=r[t],n=0,s=e.length;s>n;n++)$c.equals(a,e[n])&&($c.removeAt(e,n),n--,s--)}function __queryNestedProperty(e,r){if(e[r])return[e[r]];for(var t,i=r.split("."),a=[],n=0;t=i[n++];){if(!e.hasOwnProperty(t))return[];if($c.isArray(e[t])){if($c.isNull(i[n]))return e[t];for(var s=i.slice(n).join("."),o=e[t],c=0,l=o.length;l>c;c++)a=a.concat(__queryNestedProperty(o[c],s));return a}e=e[t]}return[e]}function __relativePathFinder(e){var r="",t="/";return e.startsWith("/")||/^[a-zA-Z]:\/|^\/\/.*/.test(e)||(r=Error().stack.split("\n")[3].replace(/.*?\((.*)/,"$1"),-1!=r.indexOf("\\")&&(r=r.replace(/\\/g,"/")),e=r.substring(0,r.lastIndexOf(t)+1)+e),e}function __rest_docs(e,r,t){var i={all:$c.where(this.server.routes.all,{path:{$ne:"/craydent/api/docs"}},{path:1,parameters:[]}),"delete":$c.where(this.server.routes.delete,{path:{$ne:"/craydent/api/docs"}},{path:1,parameters:[]}),get:$c.where(this.server.routes.get,{path:{$ne:"/craydent/api/docs"}},{path:1,parameters:[]}),post:$c.where(this.server.routes.post,{path:{$ne:"/craydent/api/docs"}},{path:1,parameters:[]}),put:$c.where(this.server.routes.put,{path:{$ne:"/craydent/api/docs"}},{path:1,parameters:[]})};return"post"==e.method.toLowerCase()||"json"==t.f?this.send(i):(this.header({"Content-Type":"text/html"},200),void this.end(fillTemplate($c.REST_API_TEMPLATE,i)))}function __run_replace(reg,template,use_run,obj){try{var pre="",post="",split_param="|",match;for(use_run&&(pre="RUN[",post="]",split_param=/;(?!\\)/);(match=reg.exec(template))&&match[1];){var funcValue=[],func="";for(funcValue=$c.replace_all(match[1],["\\[","\\]"],["[","]"]).split(split_param);$c.count(funcValue[0],"{")!=$c.count(funcValue[0],"}")&&!$c.tryEval(funcValue[0]);)funcValue[0]+=($c.isString(split_param)?split_param:";")+funcValue[1],funcValue.splice(1,1);func=$c.strip(funcValue.splice(0,1)[0],";");for(var i=0,len=funcValue.length;len>i;i++){var fv=funcValue[i];-1!=fv.indexOf("${")&&(funcValue[i]=fillTemplate(fv,obj));try{funcValue[i]=eval("("+$c.replace_all(fv,[";\\"],[";"])+")")}catch(e){}}funcValue=funcValue.map(function(e){return $c.tryEval(e)||e}),template=-1!=template.indexOf(match[1])?template.replace(match[1],match[1]=$c.replace_all(match[1],["\\[","\\]"],["[","]"])):template,template=$c.replace_all(template,"${"+pre+match[1]+post+"}",$c.getProperty($g,func)?$c.getProperty($g,func).apply(obj,funcValue):($c.tryEval("("+func+")")||foo).apply(obj,funcValue)||"")}return template}catch(e){error("fillTemplate.__run_replace",e)}}function __universal_trim(e){try{if($c.isString(this))return _trim(this,void 0,e);if($c.isArray(this)){var r=e,t=[],i=!1;$c.isBoolean(r)&&(i=!0);for(var a=0,n=this.length;n>a;a++){var s=this[a];$c.isString(s)&&(t[a]=(""+s).trim())||(t[a]=s),i&&(this[a]=t[a])}return t}}catch(o){return error($c.getName(this.constructor)+".trim",o),!1}}function _ajaxServerResponse(response){try{if(4==response.readyState&&200==response.status){var objResponse={};try{objResponse=eval(response.responseText.trim())}catch(e){objResponse=eval("("+response.responseText.trim()+")")}return!objResponse||objResponse.hasErrors?!1:objResponse}return!1}catch(e){return error("ajax._ajaxServerResponse",e),!1}}function _condense(e,r){try{var t=[],i=[],a=!1;r&&r.constructor==Array&&(a=!0);for(var n=0,s=e.length;s>n;n++){var o=e[n];if(r){var c=n;if(a&&-1!=r.indexOf(o)){t.push(n);continue}if(-1!=t.indexOf(n))continue;for(;-1!=(c=e.indexOf(o,c+1));)t.push(c)}""!==o&&!$c.isNull(o)&&-1==(t.indexOf&&t.indexOf(n)||_indexOf(t,n))&&!$c.isNull(o)&&i.push(o)}return i}catch(l){return error("_condence",l),!1}}function _copyWithProjection(e,r,t){var i={},a=0;if(e=e||"*",$c.isString(e)&&(e=e.split(",")),$c.isArray(e)){if(!(a=e.length))return i=$c.duplicate(r);var n=e;e={};for(var s,o=0;s=n[o++];)e[s]=1}for(var c in e)if(e.hasOwnProperty(c)&&e[c]){var l=$c.getProperty(r,c)||null;if("*"==c)i=$c.duplicate(r,!0);else if($c.parseBoolean(e[c]))(t||!$c.isNull(l))&&$c.setProperty(i,c,l);else if($c.isObject(e[c])||l)if($c.isObject(e[c])||l&&!$c.isArray(l))i[c]=__processExpression(r,e[c]);else if(l){var u=!0;if(".$"==c.slice(-2))c=c.slice(0,-2),i[c]=l.slice(0,1);else if(e[c].$elemMatch)i[c]=$c.where(l,e[c].$elemMatch).slice(0,1);else if(e[c].$slice){var h=0,p=$c.isInt(e[c].$slice)?e[c].$slice:0;$c.isArray(e[c].$slice)&&(h=e[c].$slice[0],p=e[c].$slice[1]),i[c]=l.slice(h,p)}else e[c]&&(u=!1,$c.setProperty(i,c,l));u&&!i[c].length&&delete i[c]}else i[c]=e[c];else i[c]=e[c]}return i}function _craydentSelector(e,r,t,i){try{if(!t||t===!0)return void 0;var a=$d[e](t);return i?a&&(a.length&&a[0]||a)||$w[r](t)[0]:a||$w[r](t)}catch(n){error("_craydentSelector",n)}}function _dataset(){try{var e=this.attributes,r={};for(var t in e)if(e.hasOwnProperty(t)){var i=e[t];0==i.name.indexOf("data-")&&(r[i.name.substring(5)]=i.value)}return r}catch(a){error("DOM._dataset",a)}}function _defineFunction(name,func,override){try{var args=_getFuncArgs(func),fstr=(""+func).replace(/this/g,"craydent_this"),extra_code="if(arguments.length == 0 && this == $c){return;}",fnew=0===args.length||1===args.length&&!_trim(args[0])?(""+fstr).replace(/(\(\s*?\)\s*?\{)/," (craydent_this){"+extra_code):"("+(""+fstr).replace(/\((.*?)\)\s*?\{/,"(craydent_this,$1){"+extra_code)+")";return override||"undefined"===eval("typeof("+name+")")?eval("$c."+name+" = "+fnew):void eval("$c."+name+" = "+fnew)}catch(ex){error("_defineFunction",ex)}}function _displayHelper(e,r){try{return $d.getElementById(e)&&$(e)[r]()||e instanceof HTMLElement&&e[r]()||$w["_"+r+"overwrite"](e)}catch(t){error("_displayHelper."+r,t)}}function _duplicate(obj,original,recursive){try{if($c.isString(obj)||$c.isString(original)||$c.isInt(obj)||$c.isInt(original)||$c.isFloat(obj)||$c.isFloat(original)||$c.isNumber(obj)||$c.isNumber(original))return original;var argIndex=3,ref=arguments[argIndex]||{objects:[{obj:original,path:"this"}]},current_path=arguments[argIndex+1]||"this";if((arguments[argIndex+2]||(arguments[argIndex+2]={}))&&(arguments[argIndex+2].command=arguments[argIndex+2].command||""),1!=ref.objects.length)for(var prop in obj)obj.hasOwnProperty(prop)&&delete obj[prop];var loop_func=function(e,r){if(!r.hasOwnProperty(e)||!r[e]||$c.isFunction(r[e])&&recursive){if(!r.hasOwnProperty(e))return}else{var t=$c.indexOfAlt(ref.objects,r[e],function(e,r){return e.obj===r}),i=current_path+"["+parseRaw(e)+"]";if(-1!=t)return arguments[argIndex+1].command+=i+"="+ref.objects[t].path+";";if("object"==typeof r[e]&&recursive)return obj[e]="function"==typeof r[e].constructor?new r[e].constructor:{},ref.objects.push({obj:r[e],path:i}),_duplicate(obj[e],r[e],!0,ref,i,arguments[argIndex+1])}obj[e]=r[e]};if($c.isArray(original))for(var i=0,len=original.length;i++<len;)loop_func.call(obj,i-1,original,ref,current_path,arguments[argIndex+2]);else for(var prop in original)original.hasOwnProperty(prop)&&loop_func.call(obj,prop,original,ref,current_path,arguments[argIndex+2]);return arguments[argIndex+1]||eval(arguments[argIndex+2].command),obj}catch(e){error("_duplicate",e)}}function _endsWith(){try{var e=arguments;arguments.length<3&&($c.isArray(arguments[0])||$c.isArray(arguments[1]))&&(e=arguments[1]||arguments[0]);for(var r=0,t=e.length;t>r;r++){var i=e[r];if(i!=this&&i==this.slice(-i.length))return i}return!1}catch(a){error("String.endsWith",a)}}function _ext(e,r,t,i){try{$g.__craydentNoConflict||(e.prototype[r]=e.prototype[r]||t),_df(r,t,i)}catch(a){error("_ext",a)}}function _even(e){try{return isNaN(e)?!1:!(1&e)}catch(r){error("_even",r)}}function _firstElementChild(){try{for(var e=this.childNodes,r=0,t=e.length;t>r;r++)if(1==e[r].nodeType)return e[r];return!1}catch(i){return error("DOM._firstElementChild",i),!1}}function _getBrowserVersion(e){try{var r=this.navigator.userAgent.indexOf(e);if(-1==r&&this["is"+e]())return-1;var t=parseFloat(this.navigator.userAgent.substring(r+e.length+1));return 0===t||t?t:-1}catch(i){error("_getBrowserVersion",i)}}function _getDimension(e,r){try{if(!e&&"body"==this.tagName.toLowerCase()){var t,i=$d.body.style[r];$d.body.style[r]="100%",t=$d.body[r](!0),$d.body.style[r]=i}var a=this.getClientRects&&this.getClientRects()[0];return a&&a[r]||this["offset"+r.capitalize()]||this["scroll"+r.capitalize()]}catch(n){if(!this.parentNode&&this!=$d){var s,o=this.cloneNode(!0);return o.style.visible="hidden",o.style.position="absolute",o["get"+r.capitalize()]=$d.body[r],$d.body.appendChild(o),s=o["get"+r.capitalize()](),o.remove(),s}return error("_getDimension",n),!1}}function _getFuncName(e){try{return _trim((""+e).replace(/\/\/.*?[\r\n]/gi,"").replace(/[\t\r\n]*/gi,"").replace(/\/\*.*?\*\//gi,"").replace(/.*?function\s*?(.*?)\s*?\(.*/,"$1"))}catch(r){error("_getFuncName",r)}}function _getFuncArgs(e){try{return _condense(_trim(_strip(""+e,"(")).replace(/\s*/gi,"").replace(/\/\*.*?\*\//g,"").replace(/.*?\((.*?)\).*/,"$1").split(","))||[]}catch(r){error("_getFuncArgs",r)}}function _getGMTOffset(){try{return this.getHours()-24-this.getUTCHours()}catch(e){error("_getGMTOffset",e)}}function _groupFieldHelper(e,r){for(var t,i="",a=0;t=r[a++];)i+=t+":"+$c.getProperty(e,t)+",";return i}function _indexOf(e,r){try{for(var t=e.length,i=0;t>i;){if(e[i]===r)return i;++i}return-1}catch(a){error("_indexOf",a)}}function _indexOfAlt(e,r){try{if($c.isArray(this)){for(var t=r,i=this.length,a=0;i>a;){if($c.isRegExp(e)&&e.test(this[a]))return a;if($c.isFunction(t)&&(e instanceof Object?t(this[a],e):t(this[a])===e))return a;++a}return-1}if($c.isString(this)){var n=e,s=r;if(isNull(n))return-1;s=s||0;var o=this.substring(s).search(n);return 0>o?o:o+s}}catch(c){error($c.getName(this.constructor)+".indexOfAlt",c)}}function _insertAfter(e,r){try{var t=e;if($c.isDomElement(this)){var i=$c.isFunction(e.nextElementSibling)?e.nextElementSibling():e.nextElementSibling;return i?e.parentNode.insertBefore(this,i):e.parentNode.appendChild(this),!0}if($c.isArray(this))return this.splice(t+1,0,r),!0}catch(a){return error(($c.isDomElement(this)?"DOM":_getFuncName(this.constructor))+".remove",a),!1}}function _invokeHashChange(){try{var e=$COMMIT.onhashchange||$c.onhashchange;e&&$c.isFunction(e)&&e()}catch(r){error("_invokeHashChange",r)}}function _isArray(e){try{return isNull(e)?!1:e.constructor==Array}catch(r){error("_isArray",r)}}function _isString(e){try{return isNull(e)?!1:e.constructor==String}catch(r){error("_isString",r)}}function _joinHelper(e,r,t,i){var a=[],n=[],s=r[0]||{};if($c.isString(t)){t=t.split("="),1==t.length&&(t=[t,t]);var o=$c.getName(arguments.callee.caller);t=$c.trim(t),"joinRight"==o&&(t=[t[1],t[0]])}for(var c in s)s.hasOwnProperty(c)&&n.push(c);for(var l=0,u=e.length;u>l;l++){var h,p=$c.duplicate(e[l],!0),d={};if(d[t[1]]=p[t[0]],h=$c.where(r,d),h.length>0)a.push($c.merge(p,h[0]));else if(!i){for(var f=0,m=n.length;m>f;f++)p[n[f]]=p[n[f]]||null;a.push(p)}}return a}function _makePrecedenceBlocks(e){try{var r=e.indexOf("("),t={before:"",after:"",block:{}};if(-1!=r){var i=e.lastIndexOf("(");return t.before=e.substring(0,r).trim(),t.after=e.substring(i).trim(),t.block=_makePrecedenceBlocks(e.substring(r+1,i-1)),t}return t.block=e,t}catch(a){error("_makePrecedenceBlocks",a)}}function _nextElementSibling(){try{for(var e=this.nextSibling;e&&1!=e.nodeType;)e=e.nextSibling;return e}catch(r){return error("DOM._nextElementSibling",r),!1}}function _on(e,r,t){if($c.isDomElement(this))try{if(r)this.events=this.events||{},this.events[e]=this.events[e]||[],this.events[e].push(r),!this.getAttribute("on"+e)&&this.setAttribute("on"+e,"this.on('"+e+"',null,(event || $w.event));");else for(var i,a=this.events[e],n=0;i=a[n++];)i(t)}catch(s){error("HTMLElement.on",s)}else if($c.isFunction(this))try{this["_"+e]=this["_"+e]||[],this["_"+e].push(r)}catch(s){error("Function.on",s)}else;}function _orderListHelper(e,r,t){try{var i=0,a=0,n=t.length;if(-1==r(e,t[0]))return 0;if(1===r(e,t[n-1]))return n;for(;n>1;){n=Math.ceil(n/2),i=a+n;var s=r(e,t[i]);if(0===s)return i;1===s&&(a=i++)}return i}catch(o){return error("OrderedList._orderListHelper",o),!1}}function _processClause(e){try{var r=$c.indexOfAlt(e,/between/i);-1!=r&&e.replace(/between( .*? )and( .*?)( |$)/gi,"between$1&and$2$3");for(var t,i=e.split(/ or /i),a={$or:[]},n=0;t=i[n++];){for(var s,o=t.split(/ and /i),c={$and:[]},l=0;s=o[l++];){var u=s,h={};switch(!0){case-1!=(r=u.indexOf("=")):h[u.substring(0,r).trim()]={$equals:$c.tryEval(u.substring(r+1).trim())},c.$and.push(h);break;case-1!=(r=u.indexOf("<>")):h[u.substring(0,r).trim()]={$ne:$c.tryEval(u.substring(r+1).trim())},c.$and.push(h);break;case-1!=(r=u.indexOf(">")):h[u.substring(0,r).trim()]={$gt:$c.tryEval(u.substring(r+1).trim())},c.$and.push(h);break;case-1!=(r=u.indexOf(">=")):h[u.substring(0,r).trim()]={$gte:$c.tryEval(u.substring(r+1).trim())},c.$and.push({$gte:h});break;case-1!=(r=u.indexOf("<")):h[u.substring(0,r).trim()]={$lt:$c.tryEval(u.substring(r+1).trim())},c.$and.push(h);break;case-1!=(r=u.indexOf("<=")):h[u.substring(0,r).trim()]={$lte:$c.tryEval(u.substring(r+1).trim())},c.$and.push(h);break;case 0==$c.indexOfAlt(u,/between/i):var p=u.replace(/between (.*?) &and (.*?) ( |$)/i,"$1,$2").split(",");c.$and.push({$gte:$c.tryEval(p[0])}),c.$and.push({$lte:$c.tryEval(p[1])});break;case-1!=(r=$c.indexOfAlt(u,/ in /i)):var d=$c.tryEval(u.substring(r+4).trim().replace(/\((.*)\)/,"[$1]"));if(!d)throw"Invalid syntax near 'in'";h[u.substring(0,r).trim()]=d,c.$and.push({$in:h});break;case-1!=(r=$c.indexOfAlt(u,/is null/i)):h[u.substring(0,r).trim()]=null,c.$and.push({$equals:h});break;case-1!=(r=$c.indexOfAlt(u,/is not null/i)):h[u.substring(0,r).trim()]=null,c.$and.push({$ne:h});break;case-1!=(r=$c.indexOfAlt(u,/ like /i)):var f="^"+$c.replace_all(_trim(u.substring(r+6),null,[" ","'",'"']),"%",".*?")+"$";h[u.substring(0,r).trim()]={$regex:RegExp(f,"i")},c.$and.push(h)}}a.$or.push(c)}return a}catch(m){error("where.processClause",m)}}function _querySelectorAll(e,r){var t,i=document.createStyleSheet(),a=[],n=document.all,s=0;for(i.addRule(e,"k:v");t=n[s++]&&a.length<r;)"bar"===t.currentStyle.foo&&a.push(t);return i.removeRule(0),a}function _redact(e,r){try{e=$c.isArray(e)?e:[e];for(var t,i=[],a=0;t=e[a++];){var n=__parseCond(t,r);if("$$KEEP"==n)i.push(t);else if("$$DESCEND"==n){i.push(t);for(var s in t)!t.hasOwnProperty(s)||$c.isArray(t[s])&&!$c.isObject(t[s][0])||!$c.isArray(t[s])&&!$c.isObject(t[s])||(t[s]=_redact(t[s],r),void 0===t[s]&&delete t[s])}else if("$$PRUNE"!=n)throw"exception: $redact's expression should not return anything aside from the variables $$KEEP, $$DESCEND, and $$PRUNE, but returned "+parseRaw(n)}return i.length?i:void 0}catch(o){error("aggregate._redact",o)}}function _remove(e,r){try{if($c.isDomElement(this))return this.parentNode.removeChild(this);if($c.isArray(this)){r=r||this.indexOf;var t=r.call(this,e);return-1==t?!1:this.splice(t,1)[0]}}catch(i){return error(($c.isDomElement(this)?"DOM":_getFuncName(this.constructor))+".remove",i),!1}}function _replace_all(e,r,t){try{$c.isArray(e)||(e=[e]),$c.isArray(r)||(r=[r]);for(var i=this,a=0,n=0,s=e.length;s>n;n++){var o=e[n],c=RegExp(__convert_regex_safe(o),t);$c.contains(i,c)&&(i=i.replace(c,void 0===r[n]?r[a]:r[n]),r[a+1]&&a++)}return""+i}catch(l){error("_replace_all",l)}}function _run_func_array(e,r){var t=this;!$c.isArray(e)&&(e=[e]);for(var i,a=0,n=[];i=e[a++];)try{$c.isFunction(i)?n=n.concat(i.apply(t,r)):$c.isGenerator(i)&&$c.tryEval("$c.syncroit(function *(){rtn = rtn.concat(yield func.apply(self,args));});") }catch(s){throw s}return n}function _set(e,r,t,i,a){try{r=encodeURI(r);var n=i.ignoreCase||"ignoreCase"==i?"i":"",s=RegExp("(.*)?("+e+"=)(.*?)(([&]|[@])(.*)|$)",n),o="search",c="&",l="";return o=0==e.indexOf("@")?(c="","hash"):o,$COMMIT[o]=$COMMIT[o]||"",t?($COMMIT[o]=$COMMIT[o]||$l[o],l=s.test($COMMIT[o])?$COMMIT[o].replace(s,"$1$2"+r+"$4"):$COMMIT[o]+c+e+"="+r,"&"==c&&0==l.indexOf("&")&&(l="?"+l.substring(1)),$COMMIT[o]=l,$COMMIT.update=!0):(l=s.test(a[o])?a[o].replace(s,"$1$2"+r+"$4"):a[o]+c+e+"="+r,"&"==c&&0==l.indexOf("&")&&(l="?"+l.substring(1)),a[o]=l,"hash"==o&&($COOKIE("CRAYDENTHASH","#"==a.hash[0]?a.hash.substring(1):a.hash),_invokeHashChange())),a}catch(u){error("_set",u)}}function _setDOMElementProperties(e){try{if(!e)return;for(var r in $w.HTMLElement.prototype)if($w.HTMLElement.prototype.hasOwnProperty(r))try{("dataset"==r||"firstElementChild"==r||"nextElementSibling"==r)&&(e[r]=$w["_"+r]()),e[r]=$w.HTMLElement.prototype[r]}catch(t){}}catch(t){error("_setDOMElementProperties",t)}}function _startsWith(){try{var e=arguments;arguments.length<3&&($c.isArray(arguments[0])||$c.isArray(arguments[1]))&&(e=arguments[1]||arguments[0]);for(var r=0,t=e.length;t>r;r++){var i=e[r];if(i!=this&&i==this.slice(0,i.length))return i}return!1}catch(a){error("String.startsWith",a)}}function _strip(e,r){try{return _trim(e,void 0,r)}catch(t){error("_strip",t)}}function _subFieldHelper(e,r){try{if(!$c.isObject(e))return!1;for(var t in e)if(e.hasOwnProperty(t)&&t in r)return t;return!1}catch(i){error("_subFieldHelper",i)}}function _subQuery(e,r,t){try{if(!$c.isObject(e))return-1!=r.indexOf(".")?"$c.equals($c.getProperty(record.'"+r+"'), "+$c.parseRaw(e)+")":"$c.equals(record['"+r+"'], "+$c.parseRaw(e)+")";var i="true";for(var a in e)if(e.hasOwnProperty(a))switch(a){case"$equals":case"$eq":case"$regex":case"$ne":var n=$c.getValue(e[a]),s="("+$c.parseRaw(n)+")";$c.isFunction(n)?s+="(record,'"+r+"',index)":s="$c.contains(values,"+s+")",i+=" && ((values = __queryNestedProperty(record, '"+r+"')).length && "+("$ne"==a?"!":"")+s+")";break;case"$lt":case"$lte":case"$gt":case"$gte":i+=" && ((values = __queryNestedProperty(record, '"+r+"')).length && $c.contains(values,"+$c.parseRaw(e[a])+",'"+a+"'))";break;case"$exists":i+=" && ((finished = {validPath:0}),$c.getProperty(record,'"+r+"','.',finished),finished.validPath == "+e.$exists+")";break;case"$type":var o=$c.isNull(e.$type)?"!":"";i+=" && ("+o+"(values = __queryNestedProperty(record, '"+r+"')).length && $c.contains(values,"+$c.getName(e.$type)+",'"+a+"'))";case"$text":break;case"$mod":var c=$c.isArray(e.$mod);i+=" && ((values = __queryNestedProperty(record, '"+r+"')).length && "+c+" && $c.contains(values,"+$c.parseRaw(e[a])+",'"+a+"'))";break;case"$all":var l=$c.parseRaw(e.$all)||void 0;i+=" && (values = __queryNestedProperty(record, '"+r+"')),(all = "+l+"),($c.isArray(values[0]) && $c.isArray(all)) && (function(){ for (var j = 0, jlen = all.length; j < jlen; j++){ if (!$c.contains(values[0],all[j])) { return false; }} return true;})()";break;case"$size":var u=parseInt(e.$size);i+=" && (values = __queryNestedProperty(record, '"+r+"')[0]),($c.isArray(values) && ("+u+" === values.length))";break;case"$where":var n="("+($c.isFunction(e.$where)?""+e.$where:"function(){return ("+e.$where+");}")+")";i+=" && "+n+".call(record)";break;case"$elemMatch":i+=" && (values = __queryNestedProperty(record, '"+r+"')[0]),($c.isArray(values) && !!$c.where(values,"+$c.parseRaw(e.$elemMatch)+",1).length)";break;case"$or":case"$nor":var h,p=e[a],d=0,f="";if(!$c.isArray(p))return!1;for("$nor"==a&&(f="!"),i+=" && "+f+"(";h=p[d++];)i+="("+_subQuery(h,r,t)+") || ";i+="false)";break;case"$and":var m,_=e.$and,g=0;if(!$c.isArray(_))return!1;for(i+=" && (";m=_[g++];)i+="("+_subQuery(m,r,t)+") && ";i+="true)";break;case"$not":if(!$c.isObject(e.$not)){i+=" && $c.contains(values, "+$c.parseRaw(e.$not)+")";break}i+=" && !("+_subQuery(e[a],r)+")";break;case"$in":case"$nin":i+=" && "+("$nin"==a?"!":"")+"((values = __queryNestedProperty(record, '"+r+"')[0]),$c.contains("+$c.parseRaw(e[a])+",values))";break;default:i+=" && "+_subQuery(e[a],a)}return i}catch($){error("_subQuery",$)}}function _toCurrencyNotation(e){e=e||",";var r=""+this,t="";if("."!=e){var i=r.split(".");i.length>1&&(r=i[0],t="."+i[1])}return r.replace(/\B(?=(\d{3})+(?!\d))/g,e)+t}function _trim(str,side,characters){try{var temp=str,trimChars={" ":1," ":1,"\n":1};if(characters)if(_isArray(characters)){var ch,i=0;for(trimChars={};ch=characters[i++];)trimChars[ch]=1}else _isString(characters)&&(trimChars=eval('({"'+__convert_regex_safe(characters)+'":1})'));if(!side||"l"==side)for(;temp.charAt(0)in trimChars;)temp=temp.substring(1);if(!side||"r"==side)for(;temp.charAt(temp.length-1)in trimChars;)temp=temp.substring(0,temp.length-1);return""+temp}catch(e){error("_trim",e)}}function _unwind(e,r){try{var t,i=[],a=0,n={};for($c.isObject(r)&&(n=r,r=n.path);t=e[a++];){var s=__processExpression(t,r);if(isNull(s)||$c.isArray(s)&&$c.isEmpty(s))t=$c.duplicate(t),n.includeArrayIndex&&(t[n.includeArrayIndex]=0),n.preserveNullAndEmptyArrays&&i.push(t);else{if(!$c.isArray(s))throw"Exception: Value at end of $unwind field path '"+r+"' must be an Array, but is a "+(typeof s).capitalize()+".";"$"==r[0]&&(r=r.substr(1));for(var o=0,c=s.length;c>o;o++){var l=$c.duplicate(t);n.includeArrayIndex&&(l[n.includeArrayIndex]=o),$c.setProperty(l,r,s[o]),i.push(l)}}}return i}catch(u){error("aggregate._unwind",u)}}function addObjectPrototype(name,fn,override){try{if($c.isNull($g.__craydentNoConflict)||!$g.__craydentNoConflict){var shouldOverride=!1;"undefined"==eval("typeof("+name+")")&&(shouldOverride=!0),!override&&Object.prototype[name]||Object.defineProperty(Object.prototype,name,{writable:!0,enumerable:!1,configurable:!0,value:fn}),override=shouldOverride}}catch(e){error("addPrototype",e);try{if(Array.prototype[name]=!override&&Array.prototype[name]||fn,Function.prototype[name]=!override&&Function.prototype[name]||fn,String.prototype[name]=!override&&String.prototype[name]||fn,Number.prototype[name]=!override&&Number.prototype[name]||fn,Boolean.prototype[name]=!override&&Boolean.prototype[name]||fn,navigator.geolocation){var GeoLocation=navigator.geolocation.constructor;GeoLocation.prototype[name]=!override&&GeoLocation.prototype[name]||fn}}catch(ex){error("addPrototype:Non-ECMAScript 5",e)}}return _df(name,fn,override)}function addHTMLPrototype(name,fn,override){try{var prototypeDefined=!!HTMLElement.prototype[name];prototypeDefined&&HTMLElement.prototype[name].overwritten&&(override=!0);var original=override?"":"HTMLElement.prototype."+name+" || ";eval("HTMLElement.prototype."+name+" = "+original+"fn"),(!prototypeDefined||override)&&(HTMLElement.prototype[name].overwritten=!0),$c.isFunction($w.HTMLElement)&&$d.body&&(!$d.body[name]||override)&&($d.body[name]=fn),_df(name,fn,override)}catch(e){error("addHTMLPrototype",e)}}function Benchmarker(){try{this.executionTime=0,this.start=function(){this._start=new Date,this._end=0},this.stop=function(){return this._end=new Date,this.executionTime=(this._end-this._start)/1e3},this.start()}catch(e){error("BenchMarker",e)}}function Cursor(e){try{var r=[],t=0,i=$c.duplicate(e||[],!0);if($c.isObject(i)){for(var a in i)i.hasOwnProperty(a)&&r.push(a);r.sort()}else if($c.isArray(i))for(var n=0,s=i.length;n++<s;)r.push(n-1);return i.hasNext=function(){return t<r.length},i.next=function(){return this.current=this[r[t]],{value:this[r[t++]],done:t>=this.size()}},i.reset=function(){t=0},i.setNextIndex=function(e){e=parseInt(e)||0,0>e?e=0:e<r.length||(e=r.length-1),t=e,i.current=i[r[t]]},i.current=i[r[t]],i.size=function(){return r.length},i}catch(o){error("Cursor",o)}}function OrderedList(e,r){try{r=r||function(e,r){return r>e?-1:e>r?1:0};var t=$c.duplicate(e||[],!0).sort(r),i=0;return t.add=function(e){if(!this.length)return this.push(e);var t=_orderListHelper(e,r,this);return $c.insertBefore(this,t,e)},t.next=function(){return{value:this[i++],done:i>=this.size()}},t.hasNext=function(){return i<this.size()},t.size=function(){return this.length},t}catch(a){error("OrderedList",a)}}function Queue(e){try{var r=$c.duplicate(e||[],!0),t=0;return r.enqueue=function(e){this.push(e)},r.dequeue=function(){return this.splice(0,1)[0]},r.next=function(){return{value:this[t++],done:t>=this.size()}},r.hasNext=function(){return t<this.size()},r.size=function(){return this.length},r}catch(i){error("Queue",i)}}function Set(e){try{var r=$c.duplicate(e||[]),t=0;return r.add=function(e){for(var t=!0,i=0,a=this.length;a>i;i++)if($c.equals(e,this[i])){t=!1;break}return t?!!r.push(e):!1},r.clear=function(e,r){$c.removeAll(this,e,r)},r.clean=function(){$c.toSet(this)},r.next=function(){return{value:this[t++],done:t>=this.size()}},r.hasNext=function(){return t<this.size()},r.size=function(){return this.length},r.clean(),r}catch(i){error("Set",i)}}function ajax(params,returnData){try{$c.isString(params)&&(params={url:params});var need_to_shard=!1,browser_url_limit=1500,query,url,rtn;params.dataType=params.dataType||"json",params.hitch=params.hitch||"",params.onbefore=params.onbefore||[foo],params.oncomplete=params.oncomplete||[foo],params.onerror=params.onerror||params.onresponse||[foo],params.onsuccess=params.onsuccess||params.onresponse||[foo],params.query=params.data||params.query||"",params.timeout=params.timeout||12e4,params.jsonp=(params.jsonp||"callback")+"=",$c.isArray(params.oncomplete)||(params.oncomplete=[params.oncomplete]),$c.isArray(params.onbefore)||(params.onbefore=[params.onbefore]),$c.isArray(params.onerror)||(params.onerror=[params.onerror]),$c.isArray(params.onresponse)||(params.onresponse=[params.onresponse]),$c.isArray(params.onsuccess)||(params.onsuccess=[params.onsuccess]),params.thiss=this,params.url=params.url||"";var cbk=function(res){if("jsonp"==params.dataType.toLowerCase()){for(var head=$d.getElementsByTagName("head")[0],func=params.jsonpCallback||"_cjson"+Math.floor(1e6*Math.random()),insert="insertBefore",tag=$d.createElement("script");!params.jsonpCallback&&$w[func];)func="_cjson"+Math.floor(1e6*Math.random());if(params.jsonpCallback&&(params.onsuccess=$w[func]),$w[func]=function(e){if(params.query){var r=params.thiss;delete params.thiss,ajax.call(r,params)}else{var t=e.code||500;if(!$c.isNull(e.hasErrors)&&e.hasErrors||!$c.isNull(e.hasErrors)&&!e.success?_run_func_array.call(params.context||params.thiss,params.onerror,[e,params.hitch,params.thiss,params.context,e.code||500]):_run_func_array.call(params.context||params.thiss,params.onsuccess,[e,params.hitch,params.thiss,params.context,t=200]),_run_func_array.call(params.context||this,params.oncomplete,[e,params.hitch,params.thiss,params.context,params.context,t]),params.jsonpCallback)$w[func]=params.onsuccess;else try{delete $w[func]}catch(i){$w[func]=void 0}var a=e;("response"==returnData||"res"==returnData||"request"==returnData||"req"==returnData)&&(a=tag),res(a)}},params.shard_data&&params.query&&!$c.isObject(params.query)&&params.query.length>browser_url_limit){need_to_shard=!0;var query_parts=params.query;params.query={},query_parts=0==query_parts.indexOf("?")?query_parts.substr(1):query_parts,query_parts=query_parts.split("&"),query_parts.map(function(e){var r=e.split("=");this[encodeURIComponent(r[0])]=encodeURIComponent(r[1])},params.query)}else params.query&&$c.isObject(params.query)&&(query=$c.toStringAlt(params.query,"=","&",!0),query.length>browser_url_limit?need_to_shard=!0:params.query=query);if(query=params.query,url=params.url,need_to_shard){params.__FIRST=isNull(params.__FIRST),params.__EOF=!0,query="&EOQ=false";for(var prop in params.query){if((query+prop+"xxx").length>browser_url_limit)break;if(query+="&"+encodeURIComponent(prop)+"="+encodeURIComponent(params.query[prop]),query.length>browser_url_limit){var left_over=query.substr(browser_url_limit);query=query.substr(0,browser_url_limit),params.query[prop]=left_over;break}delete params.query[prop]}}else params.__EOF&&(params.__EOF="true"),delete params.query;return query=(params.run?"&run="+params.run:"")+(query||"")+(params.__EOF&&"true"===params.__EOF&&"&EOQ=true"||"")+(params.__FIRST&&"&FIRST=true"||""),url+=(-1!=params.url.indexOf("?")?"&":"?")+(params.jsonp||"callback=")+func+(query||""),tag.type="text/javascript",tag.async="async",tag.src=url,tag.onload=tag.onreadystatechange=function(){try{(!this.readyState||/complete|loaded/.test(""+this.readyState))&&(this.onload=this.onreadystatechange=null,head&&this.parentNode&&-1==IEVersion()&&head.removeChild(this))}catch(e){error("ajax.tag.statechange",e)}},_run_func_array.call(params.context||this,params.onbefore,[tag,params.hitch,this]),head[insert](tag,head.firstChild),tag}var httpRequest=new Request,fileUpload=httpRequest.upload||{};params.method=params.method||"POST",params.headers=params.headers||[],params.query&&$c.isObject(params.query)&&(params.query=$c.toStringAlt(params.query,"=","&",!0)),params.query=(params.run?"run="+params.run:"")+(params.query||""),params.contentType=params.contentType||"application/x-www-form-urlencoded",params.onstatechange=params.onstatechange||foo,fileUpload.onload=params.onfileload||foo,fileUpload.onprogress=params.onprogress||foo,fileUpload.onabort=params.onabort||foo,fileUpload.onerror=params.onerror||foo,fileUpload.onloadstart=params.onloadstart||foo,"GET"==params.method&&(params.url+=params.query?"?"+params.query:"",params.query=void 0),_run_func_array.call(params.context||this,params.onbefore,[httpRequest,params.hitch,this]),httpRequest.onreadystatechange=function(xp){params.onstatechange(xp);var data=_ajaxServerResponse(this),done=4==this.readyState;if(data)_run_func_array.call(params.context||this,params.onsuccess,[data,params.hitch,params.thiss,params.context,this.status]);else if(done)try{_run_func_array.call(params.context||this,params.onerror,[eval(this.responseText),params.hitch,params.thiss,params.context,this.status])}catch(e){_run_func_array.call(params.context||this,params.onerror,[this.responseText,params.hitch,params.thiss,params.context,this.status])}done&&_run_func_array.call(params.context||this,params.oncomplete,[data,params.hitch,params.thiss,params.context,this.status]);var rtn=data;"response"==returnData||"res"==returnData?rtn=this:("request"==returnData||"req"==returnData)&&(rtn=httpRequest),res(rtn)},httpRequest.open(params.method,params.url,!0),httpRequest.setRequestHeader("Content-type",params.contentType);for(var i=0;i<params.headers.length;i++){var header=params.headers[i];httpRequest.setRequestHeader(header.type,header.value)}return httpRequest.send(params.query),httpRequest}.bind(this),prm={};return"undefined"!=typeof Promise&&-1!==(""+Promise).indexOf("[native code]")&&1==params.onsuccess.length&&params.onsuccess[0]===foo?(prm=new Promise(cbk),prm._then=prm.then||foo,prm.then=function(e,r){return params.onsuccess.push(e),params.onerror.push(r),this}):(prm=cbk(foo),prm.then=function(e){return params.onsuccess.push(e),this}),prm.otherwise=function(e){return params.onerror.push(e),this},prm["finally"]=function(e){return params.oncomplete.push(e),this},prm}catch(e){error("ajax",e)}}function Request(){var r;try{r=new XMLHttpRequest}catch(t){try{r=new ActiveXObject("Msxml2.XMLHTTP")}catch(t){try{r=new ActiveXObject("Microsoft.XMLHTTP")}catch(t){return error("Request",e),null}}}return r}function Responsivizer(){return this.Body=$d.getElementsByTagName("body")[0],this.resp_class="responsive ",this.respond=function(){this.updateInfo();var e=this.resp_class;this.winW>1049&&(e+="large-window "),this.winW<1050&&this.winW>700&&(e+="medium-window ",e+=this.winW>800?"landscape ":"portrait "),this.winW>700||(e+="small-window ",e+=this.winW>420?"landscape ":"portrait "),this.Body.className=e},this.updateInfo=function(){this.winW=$(window).width(),this.winH=$(window).height()},this.respond(),this}function $COOKIE(e,r,t){try{t=t||{};var i=$d.cookie,a="",n="",s=[],o=[];if(t.cookie&&(i=t.cookie),$c.isObject(e)){t=r;for(var c in e)e.hasOwnProperty(c)&&(r.push(JSON.stringify(e[c])),s.push(c))}else $c.isString(e)&&$c.isObject(r)?(t=r,r=void 0):arguments.length>1&&(s.push(e),o.push(JSON.stringify(r)));if(!i&&!o.length)return{};if(t.path&&$c.isString(t.path)&&(a="path="+t.path+";"),t.domain&&$c.isString(t.domain)&&(n="domain="+t.domain+";"),t["delete"])return $d.cookie=e+"=; expires=Thu, 01 Jan 1970 00:00:01 GMT;"+a+n,!0;if(o.length){var l=";";if($c.isInt(t.expiration)){var u=new Date;u.setDate(u.getDate()+t.expiration),l=";expires="+u.toUTCString()}for(var h=0,p=s.length;p>h;h++)$d.cookie=encodeURIComponent(s[h])+"="+encodeURIComponent(o[h])+l+a+n;return!0}for(var d={},f=i.split(/[,;]/),m=0,_=f.length;_>m;m++){var g=f[m],$=g.split(/=/,2),v=decodeURIComponent($[0]&&$[0].ltrim&&$[0].ltrim()||""),r=$.length>1?decodeURIComponent($c.rtrim($[1])):null;if(d[v]=$c.tryEval(r)||r,e&&e==v)return d[v]}return e?!1:d}catch(y){error("$COOKIE",y)}}function $GET(e,r){try{if(!e){var t={},i=function(e){if(""!=e){var r=e.split("="),i=r.length;if(i>2)for(var a,n=2;a=r[n++];)r[1]+=a;return t[r[0]]=r[1]}};return("?"==$l.search[0]?$l.search.substr(1):$l.search).split("&").map(i),("#"==$l.hash[0]?$l.hash.substr(1):$l.hash).split("@").map(i),t}r=r||{};var a=r.ignoreCase||"ignoreCase"==r?"i":"",n=/*!!$COMMIT.update && */r.defer||"defer"==r,s=RegExp("[?|&|@]"+e+"=",a),o="search",c={};if(c.hash=$l.hash,c.search=$l.search,n)c.hash=$COMMIT.hash||"",c.search=$COMMIT.search||"";else if(r.url||$c&&$c.isString&&$c.isString(r)&&(-1!=r.indexOf("?")||-1!=r.indexOf("#"))){var l,u=r.url||r,h=u.indexOf("?");-1!=h&&(