forked from finom/seemple
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmatreshka.min.js
58 lines (57 loc) · 49.8 KB
/
matreshka.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
Matreshka v1.4.1 (2015-12-01)
JavaScript Framework by Andrey Gubanov
Released under the MIT license
More info: http://matreshka.io
*/
!function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,_,aa,ba,ca,da,ea,fa,ga;b=function(){var a=function(a){return!!a&&("[object Arguments]"===a.toString()||"object"==typeof a&&null!==a&&"length"in a&&"callee"in a)},b="undefined"!=typeof document?document.documentMode:null,c=8==b;if(b&&8>b)throw Error("Internet Explorer "+b+" doesn't support Class function");var d=function(b,e){var f,g,h=b.constructor!==Object?b.constructor:function EmptyConstructor(){},i=b["extends"]=b["extends"]||b.extend,j=i&&i.prototype,k=b["implements"]=b["implements"]||b.implement,l={};if(f=h,delete b.extend,delete b.implement,j){for(g in j)l[g]="function"==typeof j[g]?function(b){return function(c,d){return d=a(d)?d:Array.prototype.slice.call(arguments,1),b.apply(c,d)}}(j[g]):j[g];l.constructor=function(b){return function(c,d){return d=a(d)?d:Array.prototype.slice.call(arguments,1),b.apply(c,d)}}(j.constructor)}if(c?(b.prototype=null,b.constructor=null,
h=function(){if(this instanceof h){var a,b=new XDomainRequest;for(a in h.prototype)"constructor"!==a&&(b[a]=h.prototype[a]);return b.hasOwnProperty=h.prototype.hasOwnProperty,f.apply(b,arguments),b}f.apply(this,arguments)},b.constructor=h,h.prototype=h.fn=b,h.parent=l,i&&d.IEInherits(h,i)):(b.constructor=h,h.prototype=h.fn=b,h.parent=l,i&&d.inherits(h,i)),k&&k.validate(h.prototype),h.same=function(){return function(){return h.apply(this,arguments)}},e&&"object"==typeof e)for(g in e)h[g]=e[g];return this instanceof d?new h:h};return d.inherits=function(a,b){var c,d=a.prototype,e=function(){};e.prototype=b.prototype,a.prototype=new e,a.prototype.constructor=a;for(c in d)a.prototype[c]=d[c];"undefined"!=typeof Symbol&&d[Symbol.iterator]&&(a.prototype[Symbol.iterator]=d[Symbol.iterator]),a.prototype.instanceOf=function(a){return this instanceof a}},d.IEInherits=function(a,b){for(var c,d=a.prototype.hasOwnProperty,e=a.prototype.constructor,f=Object.prototype.hasOwnProperty;b;)c=c||b.prototype.hasOwnProperty,
a.prototype=function(a,b){var c,d={};for(c in a)d[c]=a[c];for(c in b)d[c]=b[c];return d}(b.prototype,a.prototype),b=b.prototype&&b.prototype["extends"]&&b.prototype["extends"].prototype;d!==f?a.prototype.hasOwnProperty=d:c!==f&&(a.prototype.hasOwnProperty=c),a.prototype.constructor=e,a.prototype.instanceOf=function(b){for(var c=a;c;){if(c===b)return!0;c=c.prototype["extends"]}return!1}},d.Interface=function Interface(a,b){var c,d,e={},f=function(a){return"object"==typeof a&&null!==a&&"length"in a};if(a instanceof Interface){for(d in a.propsMap)e[d]=1;c=f(b)?b:[].slice.call(arguments,1)}else c=f(a)?a:arguments;for(d=0;d<c.length;d++)e[c[d]]=1;this.propsMap=e,this.validate=function(a){for(d in this.propsMap)if("function"!=typeof a[d])throw Error('Interface error: Method "'+d+'" is not implemented in '+(a.constructor.name||a.name||"given")+" prototype")}},d.isXDR=c,d}(),c={},d=function(a){var b=function(a,b){var c,d;if(a)for(c=1;c<arguments.length;c++)if(b=arguments[c])for(d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);
return a},c={extend:b,trim:function(a){return a.trim?a.trim():a.replace(/^\s+|\s+$/g,"")},randomString:function(){return((new Date).getTime()-new Date(2013,4,3).getTime()).toString(36)+Math.floor(1679616*Math.random()).toString(36)},toArray:function(a,b){var c,d=[],e=a.length;for(b=b||0,c=b;e>c;c++)d[c-b]=a[c];return d},debounce:function(a,b,c){var d;return"number"!=typeof b&&(c=b,b=0),function(){var e=arguments,f=this;clearTimeout(d),d=setTimeout(function(){a.apply(c||f,e)},b||0)}},each:function(a,b,c){if(a){if(a.isMK&&"function"==typeof a.each)a.each(b,c);else if("length"in a)[].forEach.call(a,b,c);else for(var d in a)a.hasOwnProperty(d)&&b.call(c,a[d],d,a);return a}},delay:function(a,b,c,d){return"object"==typeof c&&(d=c,c=0),setTimeout(function(){b.call(d||a)},c||0),a},deepFind:function(a,b){var c,d="string"==typeof b?b.split("."):b,e=a;for(c=0;c<d.length;++c){if("undefined"==typeof e[d[c]])return void 0;e=e[d[c]]}return e},noop:function(){}};return b(a,c),c}(c),e=function(a){return"undefined"==typeof Symbol?"mk-"+a.randomString():Symbol("matreshka");
}(d),f=function(a){var b,c=function(a,b,c){for(var d,e,f=a.length,g=0,h=0,i=[];f>h;h++)e=a[h],b?(d=new FileReader,d.onloadend=function(a){e.readerResult=d.result,i[g++]=e,g==f&&c(i)},d[b](e)):(i[g++]=e,g==f&&c(i))},d="undefined"!=typeof document&&8==document.documentMode?"keyup paste":"input";return a.binders=b={innerHTML:function(){return{on:d,getValue:function(){return this.innerHTML},setValue:function(a){this.innerHTML=null===a?"":a+""}}},innerText:function(){return{on:d,getValue:function(){return this.textContent||this.innerText},setValue:function(a){this["textContent"in this?"textContent":"innerText"]=null===a?"":a+""}}},className:function(a){var b,c=0===a.indexOf("!");return c&&(a=a.replace("!","")),{on:null,getValue:function(){return b=this.classList.contains(a),c?!b:!!b},setValue:function(b){this.classList.toggle(a,c?!b:!!b)}}},property:function(a){return{on:null,getValue:function(){return this[a]},setValue:function(b){try{this[a]=b}catch(c){}}}},attribute:function(a){return{on:null,
getValue:function(){return this.getAttribute(a)},setValue:function(b){this.setAttribute(a,b)}}},dataset:function(a){function toDashed(a){return"data-"+a.replace(/([A-Z])/g,function(a){return"-"+a.toLowerCase()})}return{on:null,getValue:function(){var b=this;return b.dataset?b.dataset[a]:b.getAttribute(toDashed(a))},setValue:function(b){var c=this;c.dataset?c.dataset[a]=b:c.setAttribute(toDashed(a),b)}}},textarea:function(){return b.input("text")},progress:function(){return b.input()},input:function(a,b){var c;switch(a){case"checkbox":return{on:"click keyup",getValue:function(){return this.checked},setValue:function(a){this.checked=a}};case"radio":return{on:"click keyup",getValue:function(){return this.value},setValue:function(a){this.checked=this.value==a}};case"submit":case"button":case"image":case"reset":return{};case"hidden":c=null;break;case"file":c="change";break;case"text":case"password":c=d;break;default:c="input"}return{on:c,getValue:function(){return this.value},setValue:function(a){
this.value=a}}},output:function(){return{getValue:function(){var a=this;return a.value||a.textContent||a.innerText},setValue:function(a){var b=this;b["form"in b?"value":"textContent"in b?"textContent":"innerText"]=null===a?"":a+""}}},select:function(a){var b;return a?{on:"change",getValue:function(){return[].slice.call(this.options).filter(function(a){return a.selected}).map(function(a){return a.value})},setValue:function(a){for(a="string"==typeof a?[a]:a,b=this.options.length-1;b>=0;b--)this.options[b].selected=~a.indexOf(this.options[b].value)}}:{on:"change",getValue:function(){return this.value},setValue:function(a){var c,d=this;if(d.value=a,!a)for(c=d.options,b=c.length-1;b>=0;b--)c[b].value||(c[b].selected=!0)}}},display:function(a){return a="undefined"==typeof a?!0:a,{on:null,getValue:function(){var b=this,c=b.style.display||(window.getComputedStyle?getComputedStyle(b,null).getPropertyValue("display"):b.currentStyle.display),d="none"==c;return a?!d:!!d},setValue:function(b){this.style.display=a?b?"":"none":b?"none":"";
}}},file:function(a){if("undefined"==typeof FileReader)throw Error("FileReader is not supported by this browser");if(a&&(a="readAs"+a[0].toUpperCase()+a.slice(1),!FileReader.prototype[a]))throw Error(a+" is not supported by FileReader");return{on:function(b){var d=function(){var d=this.files;d.length?c(d,a,function(a){b(a)}):b([])};this.addEventListener("change",d)},getValue:function(a){var b=a.domEvent||[];return this.multiple?b:b[0]||null}}},style:function(a){return{getValue:function(){var b=this;return b.style[a]||(window.getComputedStyle?getComputedStyle(b,null).getPropertyValue(a):b.currentStyle[a])},setValue:function(b){this.style[a]=b}}}},b.visibility=b.display,b.html=b.innerHTML,b.text=b.innerText,b.prop=b.property,b.attr=b.attribute,b}(c),g=function(){"undefined"!=typeof window&&!function(a,b,c,d){b[c]||(Element.prototype[c]=a[c]=b[c]=function(b,c,d){return(d=this).attachEvent("on"+b,function(b){b=b||a.event,b.target=b.target||b.srcElement,b.preventDefault=b.preventDefault||function(){
b.returnValue=!1},b.stopPropagation=b.stopPropagation||function(){b.cancelBubble=!0},b.which=b.button?2===b.button?3:4===b.button?2:b.button:b.keyCode,c.call(d,b)})},Element.prototype[d]=a[d]=b[d]=function(a,b){return this.detachEvent("on"+a,b)})}(window,document,"addEventListener","removeEventListener")}(),h=function(){return"undefined"!=typeof window?function(a,b,c,d,e,f,g,h,i,j,k,l){return l=function(a,b){return new l.i(a,b)},l.i=function(d,e){c.push.apply(this,d?d.nodeType||d==a?[d]:""+d===d?/</.test(d)?((h=b.createElement(e||"div")).innerHTML=d,h.children):(e&&l(e)[0]||b).querySelectorAll(d):/f/.test(typeof d)?/c/.test(b.readyState)?d():l(b).on("DOMContentLoaded",d):"length"in d?d:[d]:c)},l.i[k="prototype"]=(l.extend=function(a){for(j=arguments,h=1;h<j.length;h++)if(k=j[h])for(i in k)a[i]=k[i];return a})(l.fn=l[k]=c,{is:function(a){return h=this[0],i=!!h&&(h.matches||h["webkit"+g]||h["moz"+g]||h["ms"+g]||h["o"+g]),!!i&&i.call(h,a)}}),l}(window,document,[],/\.(.+)/,0,"EventListener","MatchesSelector"):void 0;
}(),i=function(){function DOMTokenList(a){this.el=a;for(var b=a.className.replace(/^\s+|\s+$/g,"").split(/\s+/),c=0;c<b.length;c++)d.call(this,b[c])}function defineElementGetter(a,b,c){Object.defineProperty?Object.defineProperty(a,b,{get:c}):a.__defineGetter__(b,c)}if("undefined"!=typeof window){var a=function(a,b){return"boolean"==typeof b?this[b?"add":"remove"](a):this[this.contains(a)?"remove":"add"](a),this.contains(a)};if(window.DOMTokenList){var b=document.createElement("a");b.classList.toggle("x",!1),b.className&&(window.DOMTokenList.prototype.toggle=a)}if(!("undefined"==typeof window.Element||"classList"in document.documentElement)){var c=Array.prototype,d=c.push,e=c.splice,f=c.join;DOMTokenList.prototype={add:function(a){this.contains(a)||(d.call(this,a),this.el.className=this.toString())},contains:function(a){return-1!=this.el.className.indexOf(a)},item:function(a){return this[a]||null},remove:function(a){if(this.contains(a)){for(var b=0;b<this.length&&this[b]!=a;b++);e.call(this,b,1),
this.el.className=this.toString()}},toString:function(){return f.call(this," ")},toggle:a},window.DOMTokenList=DOMTokenList,defineElementGetter(Element.prototype,"classList",function(){return new DOMTokenList(this)})}}}(),j=function(a){if("undefined"!=typeof window){var b,c,d="classList",e=/\.(.+)/,f={},g=0;if(!a)throw new Error("Balalaika is missing");return b=a.fn.on,c=a.fn.off,a.extend(a.fn,{on:function(b,c,d){var h,i,j,k,l,m,n,o,p,q,r,s=this;for("function"==typeof c&&(d=c,c=null),c&&(h=function(b){var e,f="x"+String(Math.random()).split(".")[1],g=this;g.setAttribute(f,f),e="["+f+'="'+f+'"] '+c,a(b.target).is(e+","+e+" *")&&d.call(g,b),g.removeAttribute(f)}),b=b.split(/\s/),p=0;p<b.length;p++)for(i=b[p].split(e),j=i[1],i=i[0],q=0;q<s.length;q++){for(k=s[q],l=k.b$=k.b$||++g,m=f[i+l]=f[i+l]||[],o=!1,r=0;r<m.length;r++)if(n=m[r],d==n.handler&&(!c||c==n.selector)){o=!0;break}o||(m.push({delegate:h,handler:d,namespace:j,selector:c}),k.addEventListener(i,h||d,!1))}return s},off:function(a,b,c){
var d,g,h,i,j,k,l,m,n=this;for("function"==typeof b&&(c=b,b=null),a=a.split(/\s/),k=0;k<a.length;k++)for(d=a[k].split(e),g=d[1],d=d[0],l=0;l<n.length;l++)if(h=n[l],i=f[d+h.b$])for(m=0;m<i.length;m++){var j=i[m];c&&c!=j.handler&&c!=j.delegate||g&&g!=j.namespace||b&&b!=j.selector||(h.removeEventListener(d,j.delegate||j.handler),i.splice(m--,1))}else g||b||h.removeEventListener(d,c);return n},hasClass:function(a){return!!this[0]&&this[0][d].contains(a)},addClass:function(a){return this.forEach(function(b){var c=b[d];c.add.apply(c,a.split(/\s/))}),this},removeClass:function(a){return this.forEach(function(b){var c=b[d];c.remove.apply(c,a.split(/\s/))}),this},toggleClass:function(a,b){return this.forEach(function(c){var e=c[d];"boolean"!=typeof b&&(b=!e.contains(a)),e[b?"add":"remove"].apply(e,a.split(/\s/))}),this},add:function(b){var c,d,e,f=a(this),h={};for(b=a(b),e=0;e<f.length;e++)d=f[e],c=d.b$=d.b$||++g,h[c]=1;for(e=0;e<b.length;e++)d=b[e],c=d.b$=d.b$||++g,h[c]||(h[c]=1,f.push(d));return f;
},not:function(b){var c,d,e=a(this);for(b=a(b),d=0;d<b.length;d++)~(c=e.indexOf(b[d]))&&e.splice(c,1);return e},find:function(b){var c=a();return this.forEach(function(d){c=c.add(a(b,d))}),c}}),a.parseHTML=function(b){var c,d,e,f=document.createElement("div"),g={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],area:[1,"<map>","</map>"],_:[0,"",""]};for(b=b.replace(/^\s+|\s+$/g,""),g.optgroup=g.option,g.tbody=g.tfoot=g.colgroup=g.caption=g.thead,g.th=g.td,e=/<([\w:]+)/.exec(b),c=e&&g[e[1]]||g._,f.innerHTML=c[1]+b+c[2],d=c[0];d--;)f=f.children[0];return a(f.childNodes)},a.create=function create(a,b){var c,d,e,f;if("object"==typeof a&&(b=a,a=b.tagName),c=document.createElement(a),b)for(d in b)if(f=b[d],"attributes"==d&&"object"==typeof f)for(e in f)f.hasOwnProperty(e)&&c.setAttribute(e,f[e]);else{
if("tagName"==d)continue;if("children"==d&&f)for(e=0;e<f.length;e++)c.appendChild(create(f[e]));else if("object"==typeof c[d]&&null!==c[d]&&"object"==typeof b)for(e in f)f.hasOwnProperty(e)&&(c[d][e]=f[e]);else c[d]=f}return c},function(a,b,c,d,e,f){var g,h=a.createElement("div").children;try{[].push.apply([],h)}catch(i){g=!0}return g=g||"function"==typeof h||a.documentMode<9,g&&(f=b.i[d="prototype"],b.i=function(g,h){for(e=g?g&&g.nodeType||g==window?[g]:"string"==typeof g?/</.test(g)?((c=a.createElement("div")).innerHTML=g,c.children):(h&&b(h)[0]||a).querySelectorAll(g):!/f/.test(typeof g)||g[0]||g[0].nodeType?g:/c/.test(a.readyState)?g():!function r(b){/in/(a.readyState)?setTimeout(r,9,b):b()}(g):f,d=[],c=e?e.length:0;c--;d[c]=e[c]);f.push.apply(this,d)},b.i[d]=f,f.is=function(a){var b,c=this[0],d=c.parentNode.querySelectorAll(a);for(b=0;b<d.length;b++)if(d[b]===c)return!0;return!1}),b}(document,a),a}}(h),k=function(a){if("undefined"!=typeof window){var b,c="on off is hasClass addClass removeClass toggleClass add not find".split(/\s+/),d="function"==typeof window.$?window.$:null,e=!0;
if(d){for(b=0;b<c.length;b++)if(!d.prototype[c[b]]){e=!1;break}d.parseHTML||(e=!1)}else e=!1;return e?d:a}}(j),l=function(a,b,c){var d=function(){return[]};a.$=c||d,a.$b=a.balalaika=b||d,a.useAs$=function(b){return a.$=this.$=c=b}}(c,j,k),m="undefined"!=typeof document&&8==document.documentMode,n=function(a,b,c){var d=a.initMK=function(a){return a[b]||Object.defineProperty(a,b,{value:{events:{},special:{},id:"mk"+Math.random()},enumerable:c,configurable:c,writable:c}),a};return function(a){return a._initMK?a._initMK():d(a),a}}(c,e,m),o=function(a,b,c){a._defineSpecial=function(d,e,f){if(!d||"object"!=typeof d||!d[b])return d;var g=d[b].special[e];return g||(g=d[b].special[e]={$nodes:a.$(),value:d[e],getter:null,setter:null,mediator:null},f||"sandbox"==e||Object.defineProperty(d,e,{configurable:!0,enumerable:!c,get:function(){return g.getter?g.getter.call(d):g.value},set:function(b){g.setter?g.setter.call(d,b):a.set(d,e,b,{fromSetter:!0})}})),g}}(c,e,m),p=function(a,b){var c,d,e;c=a.define=function(a,b,d){
if(!a||"object"!=typeof a)return a;var e;if("object"==typeof b){for(e in b)c(a,e,b[e]);return a}return Object.defineProperty(a,b,d),a},d=a.defineGetter=function(c,e,f){if(!c||"object"!=typeof c)return c;b(c);var g,h;if("object"==typeof e){for(g in e)e.hasOwnProperty(g)&&d(c,g,e[g]);return c}return h=a._defineSpecial(c,e),h.getter=function(){return f.call(c,{value:h.value,key:e,self:c})},c},e=a.defineSetter=function(c,d,f){if(!c||"object"!=typeof c)return c;b(c);var g;if("object"==typeof d){for(g in d)d.hasOwnProperty(g)&&e(c,g,d[g]);return c}return a._defineSpecial(c,d).setter=function(a){return f.call(c,a,{value:a,key:d,self:c})},c}}(c,n),q=function(a,b,c,d){a.linkProps=function(e,f,g,h,i,j){function getEvtName(a){var b,c;return a.length>1?(c=a.length-1,b=a.slice(0,c).join(".")+"@_rundependencies:"+a[c]):b="_rundependencies:"+a,b}if(!e||"object"!=typeof e)return e;c(e),g="string"==typeof g?g.split(/\s/):g,j=j||{};var k,l,m,n,o,p,q=function(c){var i=[],p=c._protect=c._protect||{};if(c.fromDependency=!0,
!(f+e[b].id in p)){if("object"==typeof g[0])for(n=0;n<g.length;n+=2)for(k=g[n],m="string"==typeof g[n+1]?g[n+1].split(/\s/):g[n+1],o=0;o<m.length;o++)i.push(d.deepFind(k,m[o]));else for(n=0;n<g.length;n++)l=g[n],k=e,i.push(d.deepFind(k,l));p[f+e[b].id]=1,a._defineSpecial(e,f,j.hideProperty),a.set(e,f,h.apply(e,i),c)}};if(h=h||function(a){return a},"object"==typeof g[0])for(n=0;n<g.length;n+=2)for(k=c(g[n]),m="string"==typeof g[n+1]?g[n+1].split(/\s/):g[n+1],o=0;o<m.length;o++)p=m[o].split("."),a[p.length>1?"on":"_fastAddListener"](k,getEvtName(p),q);else for(n=0;n<g.length;n++)l=g[n],k=e,p=l.split("."),a[p.length>1?"on":"_fastAddListener"](k,getEvtName(p),q);return i!==!1&&q.call("object"==typeof g[0]?g[0]:e,{key:"object"==typeof g[0]?g[1]:g[0]}),e}}(c,e,n,d),r=function(a,b){a.mediate=function(c,d,e){if(!c||"object"!=typeof c)return c;b(c);var f,g,h=typeof d;if("object"==h&&!(d instanceof Array)){for(f in d)d.hasOwnProperty(f)&&a.mediate(c,f,d[f]);return c}for(d="string"==h?d.split(/\s/):d,
f=0;f<d.length;f++)(function(b){g=a._defineSpecial(c,b),g.mediator=function(a){return e.call(c,a,g.value,b,c)},a.set(c,b,g.mediator(g.value),{fromMediator:!0})})(d[f]);return c},a.setClassFor=function(c,d,e,f){if(!c||"object"!=typeof c)return c;b(c);var g,h=typeof d;if("object"==h&&!(d instanceof Array)){for(g in d)d.hasOwnProperty(g)&&a.setClassFor(c,g,d[g],e);return c}for(d="string"==h?d.split(/\s/):d,f=f||function(a,b){var c;if(a.isMKArray)a.recreate(b);else if(a.isMKObject)a.jset(b);else for(c in b)b.hasOwnProperty(c)&&(a[c]=b[c])},g=0;g<d.length;g++)a.mediate(c,d[g],function(a,b,d){var g;return b&&(b.instanceOf?b.instanceOf(e):b instanceof e)?(f.call(c,b,a,d),g=b):g=new e(a,c,d),g});return c}}(c,n),s=function(a,b){var c;a.get=function(a,b){return a&&a[b]},c=a.set=function(d,e,f,g){if(!d||"object"!=typeof d)return d;var h,i,j,k,l,m,n,o=typeof e,p=Number.isNaN||function(a){return"number"==typeof a&&isNaN(a)};if("undefined"==o)return d;if("object"==o){for(l in e)e.hasOwnProperty(l)&&c(d,l,e[l],f);
return d}if(!d[b]||!d[b].special||!d[b].special[e])return d[e]=f,d;if(h=d[b].special[e],i=d[b].events,j=h.value,k=!h.mediator||f===j||g&&(g.skipMediator||g.fromMediator)?f:h.mediator(f,j,e,d),m={value:k,previousValue:j,key:e,node:h.$nodes[0]||null,$nodes:h.$nodes,self:d},g&&"object"==typeof g)for(l in g)m[l]=g[l];return n=(k!==j||m.force)&&!m.silent,n&&(i["beforechange:"+e]&&a._fastTrigger(d,"beforechange:"+e,m),i.beforechange&&a._fastTrigger(d,"beforechange",m)),h.value=k,(k!==j||m.force||m.forceHTML||k!==f&&!p(k))&&(m.silentHTML||i["_runbindings:"+e]&&a._fastTrigger(d,"_runbindings:"+e,m)),n&&(i["change:"+e]&&a._fastTrigger(d,"change:"+e,m),i.change&&a._fastTrigger(d,"change",m)),k===j&&!m.force&&!m.forceHTML||m.skipLinks||i["_rundependencies:"+e]&&a._fastTrigger(d,"_rundependencies:"+e,m),d},a.remove=function(c,d,e){if(!c||"object"!=typeof c)return null;var f,g,h=String(d).split(/\s/),i={keys:h};if(e&&"object"==typeof e)for(g in e)i[g]=e[g];for(g=0;g<h.length;g++)if(d=h[g],f=d in c){
i.key=d,i.value=c[d];try{delete c[d]}catch(j){}c[b]&&(a.unbindNode(c,d),a.off(c,"change:"+d+" beforechange:"+d+" _runbindings:"+d+" _rundependencies:"+d),delete c[b].special[d],i.silent||(a._fastTrigger(c,"delete",i),a._fastTrigger(c,"delete:"+d,i)))}return c}}(c,e),t=function(a,b,c,d){var e,f;e=a.defaultBinders=[function(b){var c,d=b.tagName,e=a.binders;return"INPUT"==d?c=e.input(b.type):"TEXTAREA"==d?c=e.textarea():"SELECT"==d?c=e.select(b.multiple):"PROGRESS"==d?c=e.progress():"OUTPUT"==d&&(c=e.output()),c}],f=a.lookForBinder=function(a){var b,c,d=e;for(c=0;c<d.length;c++)if(b=d[c].call(a,a))return b},a.bindOptionalNode=function(a,b,c,d,e){return"object"==typeof b?g(a,b,c,d,!0):g(a,b,c,d,e,!0),a};var g=a.bindNode=function(d,e,h,i,j,k){function initBinding(c){var g,h={self:d,key:e,$nodes:m,node:c};if(null===i)g={};else if(w=f(c)){if(i)for(p in i)w[p]=i[p];g=w}else g=i||{};if(g.initialize){u={value:q.value};for(p in h)u[p]=h[p];g.initialize.call(c,u)}if(g.setValue&&(v=function(a){var f=d[b].special[e].value,i=a&&"string"==typeof a.onChangeValue&&"number"==typeof f?String(f):f;
if(!a||a.changedNode!=c||a.onChangeValue!=i){u={value:f};for(p in h)u[p]=h[p];g.setValue.call(c,f,u)}},a._fastAddListener(d,"_runbindings:"+e,v,null,{node:c}),!l&&v()),g.getValue&&(l&&j.assignDefaultValue!==!1||j.assignDefaultValue===!0)){x={fromNode:!0};for(p in j)x[p]=j[p];a.set(d,e,g.getValue.call(c,h),x)}g.getValue&&g.on&&(t={node:c,on:g.on,instance:d,key:e,mkHandler:v,handler:function(b){if(!t.removed){var f,i,j=d[e],k={value:j,domEvent:b,originalEvent:b.originalEvent||b,preventDefault:function(){b.preventDefault()},stopPropagation:function(){b.stopPropagation()},which:b.which,target:b.target};for(i in h)k[i]=h[i];f=g.getValue.call(c,k),f!==j&&a.set(d,e,f,{fromNode:!0,changedNode:c,onChangeValue:f})}}},a.domEvents.add(t))}if(!d||"object"!=typeof d)return d;c(d);var l,m,n,o,p,q,r,s,t,u,v,w,x,y="undefined"!=typeof window?window:null;if(e instanceof Array){for(o=0;o<e.length;o++)g(d,e[o][0],e[o][1],e[o][2]||j,h);return d}if("string"==typeof e&&(n=e.split(/\s+/),n.length>1)){for(o=0;o<n.length;o++)g(d,n[o],h,i,j,k);
return d}if("object"==typeof e){for(o in e)e.hasOwnProperty(o)&&g(d,o,e[o],h,i,j);return d}if(h&&2==h.length&&h!==y&&!h[1].nodeName&&(h[1].setValue||h[1].getValue))return g(d,e,h[0],h[1],i,k);if(m=a._getNodes(d,h),!m.length){if(k)return d;throw Error('Binding error: node is missing for "'+e+'".'+("string"==typeof h?' The selector is "'+h+'"':""))}if(~e.indexOf("."))return r=e.split("."),s=function(b){var c=b&&b.value;if(!c){c=d;for(var e=0;e<r.length-1;e++)c=c[r[e]]}g(c,r[r.length-1],m,i,b,k),b&&b.previousValue&&a.unbindNode(b.previousValue,r[r.length-1],m)},a._delegateListener(d,r.slice(0,r.length-2).join("."),"change:"+r[r.length-2],s),s(),d;if(j=j||{},q=a._defineSpecial(d,e),l="undefined"==typeof q.value,q.$nodes=q.$nodes.length?q.$nodes.add(m):m,d.isMK&&("sandbox"==e&&(d.$sandbox=m,d.sandbox=m[0]),d.$nodes[e]=q.$nodes,d.nodes[e]=q.$nodes[0]),"sandbox"!=e)for(o=0;o<m.length;o++)initBinding(m[o]);if(!j.silent){x={key:e,$nodes:m,node:m[0]||null};for(o in j)x[o]=j[o];a._fastTrigger(d,"bind:"+e,x),
a._fastTrigger(d,"bind",x)}return d}}(c,e,n,d),u=function(a,b,c){var d=a.unbindNode=function(e,f,g,h){if(!e||"object"!=typeof e)return e;c(e);var i,j,k,l,m,n,o=typeof f,p=e[b].special[f];if(f instanceof Array){for(k=0;k<f.length;k++)h=g,d(e,f[k][0],f[k][1]||h,h);return e}if("string"==o&&(j=f.split(/\s/),j.length>1)){for(k=0;k<j.length;k++)d(e,j[k],g,h);return e}if(l=f.indexOf("."),~l){m=f.split(".");var q=e;for(k=0;k<m.length-1;k++)q=q[m[k]];return a._undelegateListener(e,m.slice(0,m.length-2),"change:"+m[m.length-2]),d(q,m[m.length-1],g,h),e}if(null===f){for(f in e[b].special)e[b].special.hasOwnProperty(f)&&d(e,f,g,h);return e}if("object"==o){for(k in f)f.hasOwnProperty(k)&&d(e,k,f[k],g);return e}if(!g)return p&&p.$nodes?d(e,f,p.$nodes,h):e;if(2==g.length&&!g[1].nodeName&&(g[1].setValue||g[1].getValue||g[1].on))return d(e,f,g[0],h);if(!p)return e;for(i=a._getNodes(e,g),k=0;k<i.length;k++)a.domEvents.remove({key:f,node:i[k],instance:e}),p.$nodes=p.$nodes.not(i[k]),function(b){a._removeListener(e,"_runbindings:"+f,null,null,{
node:b,howToRemove:function(a,b){return a.node==b.node}})}(i[k]);if(e.isMK&&(e.$nodes[f]=p.$nodes,e.nodes[f]=p.$nodes[0]||null,"sandbox"==f&&(e.sandbox=p.$nodes[0]||null,e.$sandbox=p.$nodes)),!h||!h.silent){n={key:f,$nodes:i,node:i[0]||null};for(k in h)n[k]=h[k];a._fastTrigger(e,"unbind:"+f,n),a._fastTrigger(e,"unbind",n)}return e}}(c,e,n),v=function(a,b,c,d){a.parseBindings=function(e,f){function initLink(b,c,f){a.linkProps(e,b,c,function(){var a,b=f;for(a=0;a<c.length;a++)b=b.replace(new RegExp("{{"+c[a]+"}}","g"),d.deepFind(e,c[a]));return b},!0,{hideProperty:!0})}var g=a.$;if(!e||"object"!=typeof e)return g();if("string"==typeof f){if(!~f.indexOf("{{"))return g.parseHTML(f.replace(/^\s+|\s+$/g,""));f=g.parseHTML(f.replace(/^\s+|\s+$/g,""))}else if(f)f=g(f);else if(f=e[b]&&e[b].special&&e[b].special.sandbox&&e[b].special.sandbox.$nodes,!f||!f.length)return e;c(e);var h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w=[],x=0;for(i=0;i<f.length;i++)if(k=f[i],!k.outerHTML||~k.outerHTML.indexOf("{{")||~k.outerHTML.indexOf("%7B%7B")){
for(h=k.getElementsByTagName("*"),j=0;j<h.length;j++)w[x++]=h[j];w[x++]=k}if(!w.length)return g();for(j=0;j<w.length;j++)if(k=w[j],"TEXTAREA"!=k.tagName)for(i=0;i<k.childNodes.length;i++)if(u=k.childNodes[i],s=u.previousSibling,3==u.nodeType&&~u.nodeValue.indexOf("{{")){t=u.nodeValue.replace(/{{([^}]*)}}/g,'<span mk-html="$1"></span>');try{s?s.insertAdjacentHTML("afterend",t):k.insertAdjacentHTML("afterbegin",t)}catch(y){v=document.body,s?(v.appendChild(s),s.insertAdjacentHTML("afterend",t),v.removeChild(s)):(v.appendChild(k),k.insertAdjacentHTML("afterbegin",t),v.removeChild(k))}k.removeChild(u)}for(i=0;i<f.length;i++)for(h=f[i].querySelectorAll("[mk-html]"),j=0;j<h.length;j++)w[x++]=h[j];for(i=0;i<w.length;i++)for(k=w[i],l=k.getAttribute("mk-html"),l&&(k.removeAttribute("mk-html"),a.bindNode(e,l,k,{setValue:function(a){this.innerHTML=a}})),m=k.attributes,j=0;j<m.length;j++)n=m[j],o=n.value,p=n.name,~o.indexOf("{{")&&(q=o.match(/{{[^}]*}}/g).map(function(a){return a.replace(/{{(.*)}}/,"$1");
}),1==q.length&&/^{{[^}]*}}$/g.test(o)?r=q[0]:(r=a.randomString(),initLink(r,q,o)),("value"==p&&"checkbox"!=k.type||"checked"==p&&"checkbox"==k.type)&&a.lookForBinder(k)?(k.setAttribute(p,""),a.bindNode(e,r,k)):a.bindNode(e,r,k,a.binders.attr(p)));return f}}(c,e,n,d),w=function(a,b,c,d){function selectNodes(c,d){var e,f,g,h,i,j,k,l,m,n=a.$();if(!c||!c[b])return n;for(d=d.split(","),i=0;i<d.length;i++)if(h=d[i],e=/\s*:bound\(([^(]*)\)\s*([\S\s]*)\s*|\s*:sandbox\s*([\S\s]*)\s*/.exec(h)){if(m=void 0!==e[3]?"sandbox":e[1],l=void 0!==e[3]?e[3]:e[2],f=c[b].special[m]&&c[b].special[m].$nodes,!f||!f.length)continue;if(l)if(0===l.indexOf(">"))for(j=0;j<f.length;j++)g=f[j],k=a.randomString(),g.setAttribute(k,k),n=n.add($("["+k+'="'+k+'"]'+l,g)),g.removeAttribute(k);else n=n.add(f.find(l));else n=n.add(f)}else n=n.add(h);return n}var e,f,g;e=a.selectAll=function(c,d){var e;return c&&c[b]&&"string"==typeof d?/:sandbox|:bound\(([^(]*)\)/.test(d)?selectNodes(c,d):(e=c&&c[b]&&c[b].special,e=e&&e.sandbox&&e.sandbox.$nodes,
e&&e.find(d)):a.$()},a.select=function(c,d){var e;return c&&c[b]&&"string"==typeof d?/:sandbox|:bound\(([^(]*)\)/.test(d)?selectNodes(c,d)[0]||null:(e=c&&c[b]&&c[b].special,e=e&&e.sandbox&&e.sandbox.$nodes&&e.sandbox.$nodes[0],e&&e.querySelector(d)):a.$()},f=a.boundAll=function(e,g){var h,i,j,k,l=a.$;if(!e||"object"!=typeof e)return l();if(g&&~g.indexOf("."))return i=g.split("."),g=i.splice(-1)[0],f(d.deepFind(e,i),g);if(c(e),h=e[b].special,g=g?g:"sandbox",i="string"==typeof g?g.split(/\s+/):g,i.length<=1)return i[0]in h?h[i[0]].$nodes:l();for(j=l(),k=0;k<i.length;k++)j=j.add(h[i[k]].$nodes);return j},a.$bound=function(a,b){return f(a,b)},g=a.bound=function(a,e){var f,h,i;if(!a||"object"!=typeof a)return null;if(e&&~e.indexOf("."))return h=e.split("."),e=h.splice(-1)[0],g(d.deepFind(a,h),e);if(c(a),f=a[b].special,e=e?e:"sandbox",h="string"==typeof e?e.split(/\s+/):e,h.length<=1)return h[0]in f?f[h[0]].$nodes[0]||null:null;for(i=0;i<h.length;i++)if(h[i]in f&&f[h[i]].$nodes.length)return f[h[i]].$nodes[0];
return null},a._getNodes=function(b,c){return"string"==typeof c&&!/</.test(c)&&/:sandbox|:bound\(([^(]*)\)/.test(c)?selectNodes(b,c):a.$(c)}}(c,e,n,d),x=/([^\:\:]+)(::([^\(\)]+)?(\((.*)\))?)?/,y=function(a,b,c,d){var e=function(a,b,c){var d,e=document;if(e.createEvent)d=e.createEvent("Event"),d.initEvent(b,!0,!0),d.mkArgs=c,a.dispatchEvent(d);else if("undefined"==typeof Event||a.fireEvent){if(!a.fireEvent)throw Error("Cannot trigger DOM event");d=e.createEventObject(),d.mkArgs=c,a.fireEvent("on"+b,d)}else d=new Event(b,{bubbles:!0,cancelable:!0}),d.mkArgs=c,a.dispatchEvent(d);return d};a.trigger=function(f,g){var h,i,j,k,l,m,n,o,p,q,r,s=f&&"object"==typeof f&&f[b]&&f[b].events;if(g&&s)for(h=c.toArray(arguments,2),g=g.split(/\s/),i=0;i<g.length;i++)if(n=g[i],~n.indexOf("::")){if(o=d.exec(n),p=f[b].special[o[3]||"sandbox"],p=p&&p.$nodes,q=a.$(),r=o[5])for(j=0;j<p.length;j++)q=q.add(p.find(r));else q=p;for(j=0;j<q.length;j++)e(q[i],o[1],h)}else if(l=s[n])for(j=-1,k=l.length;++j<k;)(m=l[j]).callback.apply(m.ctx,h);
return f},a._fastTrigger=function(a,c,d){var e,f,g,h=a[b].events[c];if(h)for(e=-1,f=h.length;++e<f;)(g=h[e]).callback.call(g.ctx,d)}}(c,e,d,x),z=function(a,b,c){var d=a.on=function(e,f,g,h,i,j){if(!e)return e;b(e);var k,l,m,n,o;if("object"==typeof f&&!(f instanceof Array)){for(l in f)f.hasOwnProperty(l)&&d(e,l,f[l],g,h);return e}if(!g)throw Error('callback is not function for event(s) "'+f+'"');for(f=f instanceof Array?f:c.trim(f).replace(/\s+/g," ").split(/\s(?![^(]*\))/g),"boolean"!=typeof h&&"undefined"!=typeof h&&(k=i,i=h,h=k),l=0;l<f.length;l++)m=f[l],o=m.lastIndexOf("@"),~o?(n=m.slice(0,o),n?~n.indexOf("@")&&(n=n.replace(/([^@]*)@/g,function(a,b){return(b||"*")+"."}).replace(/\.$/,".*")||"*"):n="*",m=m.slice(o+1),a._delegateListener(e,n,m,g,i||e,j)):a._addListener(e,m,g,i,j);return h===!0&&g.call(i||e,{triggeredOnInit:!0}),e}}(c,n,d),A=function(a,b,c,d){var e=a.off=function(b,f,g,h){if(!b||"object"!=typeof b||!b[d])return b;var i,j,k,l;if("object"==typeof f&&!(f instanceof Array)){
for(i in f)f.hasOwnProperty(i)&&e(b,i,f[i],g);return b}if(!f&&!g&&!h&&b[d])return b[d].events={},b;if(f=c.trim(f).replace(/\s+/g," ").split(/\s(?![^(]*\))/g),"object"!=typeof b)return b;for(i=0;i<f.length;i++)l=f[i],k=l.lastIndexOf("@"),~k?(j=l.slice(0,k),l=l.slice(k+1).replace(/@/g,"."),a._undelegateListener(b,j,l,g,h)):a._removeListener(b,l,g,h);return b}}(c,n,d,e),B=/_rundependencies:|_runbindings:|change:/,C=function(a,b,c,d,e){var f;a._fastAddListener=function(b,e,f,g,h){var i=b[c].events,j=i[e]||(i[e]=[]);return j.push({callback:f,context:g,ctx:g||b,name:e,node:h&&h.node}),d.test(e)&&a._defineSpecial(b,e.replace(d,"")),b},f=a._addListener=function(f,g,h,i,j){if(!f||"object"!=typeof f)return!1;b(f);var k,l,m,n,o=i||f,p=f[c].events,q=p[g]||(p[g]=[]),r=q.length,s={callback:h,context:i,ctx:o,name:g};for(k=0;r>k;k++)if(l=q[k],(l.callback==h||l.callback==h._callback)&&l.context==i)return!1;if(j){m={};for(k in j)m[k]=j[k];for(k in s)m[k]=s[k]}else m=s;return q.push(m),n=e.exec(g),n&&n[2]?a._addDOMListener(f,n[3]||"sandbox",n[1],n[5],h,o,m):d.test(g)&&a._defineSpecial(f,g.replace(d,"")),
a._fastTrigger(f,"addevent:"+g,m),a._fastTrigger(f,"addevent",m),!0}}(c,n,e,B,x),D=function(a,b){a._removeListener=function(c,d,e,f,g){if(!c||"object"!=typeof c||!c[b]||!c[b].events)return c;var h,i,j,k,l,m=c[b].events[d]||[],n=c[b].events[d]=[],o=/([^\:\:]+)(::([^\(\)]+)(\((.*)\))?)?/,p=0,q=m.length;if(g=g||{},j=o.exec(d),j&&j[2])a._removeDOMListener(c,j[3],j[1],j[5],e,f);else{for(i=0;q>i;i++)h=m[i],k=h.howToRemove||g.howToRemove,(k?!k(h,g):e&&e!==h.callback&&e._callback!==h.callback||f&&f!==h.context)?n[p++]=h:(l={name:d,callback:h.callback,context:h.context},a._fastTrigger(c,"removeevent:"+d,l),a._fastTrigger(c,"removeevent",l));n.length||delete c[b].events[d]}return c}}(c,e),E=function(a,b,c,d){var e=a._delegateTreeListener=function(b,c,d,g,h,i){if(!b||"object"!=typeof b)return b;var j;return j=function(a){var j=b[a.key];j&&(f(j,c,d,g,h,i),e(j,c,d,g,h,i))},each(b,function(a){f(a,c,d,g,h,i),e(a,c,d,g,h,i)}),j._callback=g,a._addListener(b,"change",j,h,i),b},f=a._delegateListener=function(e,g,h,i,j,k){
if(!e||"object"!=typeof e)return e;b(e);var l,m=/([^\.]+)\.(.*)/.exec(g),n=m?m[1]:g;g=m?m[2]:"",k=k||{},n?"*"==n?e.isMKArray?(l=function(a){(a&&a.added?a.added:e).forEach(function(a){a&&f(a,g,h,i,j,k)})},l._callback=i,a._addListener(e,"add",l,j,k),l()):e.isMKObject&&(l=function(a){var b=e[a.key];b&&a&&a.key in e[c].keys&&f(b,g,h,i,j,k)},e.each(function(a){f(a,g,h,i,j,k)}),l._callback=i,a._addListener(e,"change",l,j,k)):(l=function(b){if(!b||!b._silent){var l,m,o,p=e[n],q=!0;if(k.path=g,k.previousValue=b&&b.previousValue||k.previousValue&&k.previousValue[n],b&&b.previousValue&&b.previousValue[c]&&a._undelegateListener(b.previousValue,g,h,i,j,k),"object"==typeof p&&p&&f(p,g,h,i,j,k),d.test(h)&&(l=h.replace(d,""),!g&&k.previousValue&&k.previousValue[l]!==p[l])){if(o=k.previousValue[c].events[h])for(m=0;m<o.length;m++)o[m].path===g&&(q=!1);q&&a.set(p,l,p[l],{force:!0,previousValue:k.previousValue[l],previousObject:k.previousValue,_silent:!0})}}},l._callback=i,a._addListener(e,"change:"+n,l,j,k),
l()):a._addListener(e,h,i,j,k)}}(c,n,e,B),F=function(a,b){var c=a._undelegateListener=function(d,e,f,g,h,i){if(!d||"object"!=typeof d)return d;var j,k,l=/([^\.]+)\.(.*)/.exec(e),m=l?l[1]:e,n=e;if(e=l?l[2]:"",m)if("*"==m){if(d.isMKArray){if(g)c(d,e,"add",g,h,i);else for(j=d[b].events.add||[],k=0;k<j.length;k++)j[k].path==n&&c(d,e,"add",j[k].callback);d.forEach(function(a){a&&c(a,e,f,g,h)})}else if(d.isMKObject){if(g)c(d,e,"change",g,h);else for(j=d[b].events.change||[],k=0;k<j.length;k++)j[k].path==n&&c(d,e,"change",j[k].callback);d.each(function(a){a&&c(a,e,f,g,h)})}}else{if(g)a._removeListener(d,"change:"+m,g,h,i);else for(j=d[b].events["change:"+m]||[],k=0;k<j.length;k++)j[k].path==n&&a._removeListener(d,"change:"+m,j[k].callback);"object"==typeof d[m]&&c(d[m],e,f,g,h,i)}else a._removeListener(d,f,g,h,i)}}(c,e),G=function(a,b){var c={};a.domEvents={add:function(d){var e=a.$;d.node&&("function"==typeof d.on?d.on.call(d.node,d.handler):e(d.node).on(d.on.split(/\s/).join(".mk ")+".mk",d.handler)),
(c[d.instance[b].id]=c[d.instance[b].id]||[]).push(d)},remove:function(d){var e,f,g=c[d.instance[b].id],h=a.$;if(g)for(f=0;f<g.length;f++)e=g[f],e.node===d.node&&(e.mkHandler&&a._removeListener(d.instance,"_runbindings:"+d.key,e.mkHandler),"string"==typeof e.on&&h(d.node).off(e.on+".mk",e.handler),e.removed=!0,c[d.instance[b].id].splice(f--,1))}}}(c,e),H=function(a,b,c){a._addDOMListener=function(d,e,f,g,h,i,j){if(!d||"object"!=typeof d)return d;b(d),g=g||null,j=j||{};var k=function(b){var c=this,f=a.$,g=f(c),j=b.originalEvent?b.originalEvent.mkArgs:b.mkArgs,k={self:d,node:c,$nodes:g,key:e,domEvent:b,originalEvent:b.originalEvent||b,preventDefault:function(){b.preventDefault()},stopPropagation:function(){b.stopPropagation()},which:b.which,target:b.target};h.apply(i,j?j:[k])},l=f+"."+d[c].id+e,m=function(a){a&&a.$nodes&&a.$nodes.on(l,g,k)},n=function(a){a&&a.$nodes&&a.$nodes.off(l,g,k)};return k._callback=h,a._defineSpecial(d,e),m._callback=n._callback=h,a._addListener(d,"bind:"+e,m,i,j)&&a._addListener(d,"unbind:"+e,n,i,j)&&m({
$nodes:d[c].special[e]&&d[c].special[e].$nodes}),d}}(c,n,e),I=function(a,b){a._removeDOMListener=function(c,d,e,f,g,h,i){return c&&"object"==typeof c&&c[b]&&c[b].events?(f=f||null,i=i||{},d&&c[b].special[d]&&(c[b].special[d].$nodes.off(e+"."+c[b].id+d,f,g),a._removeListener(c,"bind:"+d,g,h,i),a._removeListener(c,"unbind:"+d,g,h,i)),c):c}}(c,e),J=function(a,b){var c=a.once=function(d,e,f,g,h){var i;if(!d||"object"!=typeof d)return d;if("object"==typeof e){for(i in e)e.hasOwnProperty(i)&&c(d,i,e[i],f,g);return d}if(!f)throw Error('callback is not function for event "'+e+'"');for(b(d),e=e.split(/\s/),i=0;i<e.length;i++)!function(b){var c=function(a){var b,c=!1;return function(){return c?b:(c=!0,b=a.apply(this,arguments),a=null,b)}}(f);c._callback=f,a.on(d,b,c,g)}(e[i]);return d}}(c,n),K=function(a,b,c){var d=a.onDebounce=function(b,e,f,g,h,i,j){if(!b||"object"!=typeof b)return b;var k,l;if("object"==typeof e){for(l in e)e.hasOwnProperty(l)&&d(b,l,e[l],f,g,h,i);return b}return"number"!=typeof g&&(j=i,
i=h,h=g,g=0),k=c.debounce(f,g),k._callback=f,a.on(b,e,k,h,i,j)}}(c,n,d),L=function(a,b){return a.sym=b,a}(c,e),M=function(a,b){return{isMK:!0,on:function(b,c,d,e,f){return a.on(this,b,c,d,e,f)},onDebounce:function(b,c,d,e,f,g){return a.onDebounce(this,b,c,d,e,f,g)},once:function(b,c,d){return a.once(this,b,c,d)},off:function(b,c,d){return a.off(this,b,c,d)},trigger:function(){var b=a.toArray(arguments);return b.unshift(this),a.trigger.apply(a,b)},bindNode:function(b,c,d,e,f){return a.bindNode(this,b,c,d,e,f)},bindOptionalNode:function(b,c,d,e){return a.bindOptionalNode(this,b,c,d,e)},unbindNode:function(b,c,d){return a.unbindNode(this,b,c,d)},boundAll:function(b){return a.boundAll(this,b)},$bound:function(b){return a.boundAll(this,b)},bound:function(b){return a.bound(this,b)},selectAll:function(b){return a.selectAll(this,b)},$:function(b){return a.selectAll(this,b)},select:function(b){return a.select(this,b)},eq:function(a){return"object"==typeof a&&null!==a&&this[b]&&a[b]&&this[b].id==a[b].id;
},defineGetter:function(b,c){return a.defineGetter(this,b,c)},defineSetter:function(b,c){return a.defineSetter(this,b,c)},mediate:function(b,c){return a.mediate(this,b,c)},setClassFor:function(b,c,d){return a.setClassFor(this,b,c,d)},linkProps:function(b,c,d,e){return a.linkProps(this,b,c,d,e)},get:function(a){return this[a]},set:function(b,c,d){return a.set(this,b,c,d)},remove:function(b,c){return a.remove(this,b,c)},define:function(b,c){return a.define(this,b,c)},delay:function(b,c,d){return a.delay(this,b,c,d)},parseBindings:function(b){return a.parseBindings(this,b)},_initMK:function(){var c=this;return c[b]?c:(a.initMK(c),c.nodes={},c.$nodes={},c.sandbox=null,c.$sandbox=a.$(),c)},toString:function(){return"[object Matreshka]"},constructor:function Matreshka(){return this._initMK()}}}(L,e),N=function(a){return{version:"dev",Class:a,isXDR:a.isXDR}}(b),O=function(a,b,c,d){if(!a)throw Error("Class function is missing");if(![].forEach)throw Error("Internet Explorer 8 requires to use es5-shim: https://github.com/es-shims/es5-shim");
d.to=function(a){var b,c;if("object"==typeof a)if("length"in a){for(b=[],c=0;c<a.length;c++)b[c]=e.to(a[c]);b=(new e.Array).recreate(b)}else{b={};for(c in a)a.hasOwnProperty(c)&&(b[c]=e.to(a[c]));b=new e.Object(b)}else b=a;return b};var e=a(c);return b.extend(e.Matreshka=e.prototype.Matreshka=e,b,d)}(b,L,M,N),P=function(a,b){return{keys:function(){var b,c=this._initMK(),d=c[a].keys,e=[];for(b in d)d.hasOwnProperty(b)&&e.push(b);return e},toObject:function(){var b,c=this._initMK(),d={},e=c[a].keys;for(b in e)e.hasOwnProperty(b)&&(d[b]=c[b]);return d},toNative:function(){return this.toObject()},toJSON:function(){var b,c=this._initMK(),d={},e=c[a].keys;for(b in e)e.hasOwnProperty(b)&&(d[b]=c[b]&&c[b].toJSON?c[b].toJSON():c[b]);return d},keyOf:function(b){var c,d=this._initMK(),e=d[a].keys;for(c in e)if(e.hasOwnProperty(c))if(b&&b.isMK){if(b.eq(d[c]))return c}else if(b===d[c])return c;return null},jset:function(c,d,e){var f,g=this._initMK(),h=typeof c;if("undefined"==h)return g;if(c&&"object"==h){
c=c.toJSON?c.toJSON():c;for(f in c)g[a].keys[f]=1,b._defineSpecial(g,f),g.set(f,c[f],d);return g}return g[a].keys[c]=1,b._defineSpecial(g,c),g.set(c,d,e)},addDataKeys:function(c){var d,e=this._initMK(),f=arguments;if(!f.length||!c)return e;for(c=f.length>1?f:c instanceof Array?c:b.trim(c).split(/\s+/),d=0;d<c.length;d++)e[a].keys[c[d]]=1,b._defineSpecial(e,c[d]);return e},removeDataKeys:function(c){var d,e=this._initMK(),f=arguments;if(!f.length||!c)return e;for(c=f.length>1?f:c instanceof Array?c:b.trim(c).split(/\s+/),d=0;d<c.length;d++)delete e[a].keys[c[d]];return e},each:function(b,c){var d,e=this._initMK();for(d in e[a].keys)e[a].keys.hasOwnProperty(d)&&b.call(c,e[d],d,e);return e}}}(e,O),Q=function(){var a=this,b=a.keys(),c=0;return{next:function(){return c>b.length-1?{done:!0}:{done:!1,value:a[b[c++]]}}}},R="undefined"!=typeof Symbol?Symbol.iterator:"@@iterator",S=function(a,b,c,d){if(!a)throw new Error("Matreshka is missing");var e=a.sym,f={"extends":a,isMKObject:!0,renderer:null,
constructor:function MatreshkaObject(a){return this.jset(a)},_initMK:function(){var b,c=this;return c[e]?c:(a.prototype._initMK.call(c,arguments),c[e].keys={},a._fastAddListener(c,"addevent:modify",function(d){b||(a._fastAddListener(c,"change",function(b){b&&b.key in c[e].keys&&!b.silent&&a._fastTrigger(c,"modify",b)}),a._fastAddListener(c,"delete",function(b){b&&b.key in c[e].keys&&(c.removeDataKeys(b.key),b.silent||a._fastTrigger(c,"modify",b))}),b=!0)}),c)},hasOwnProperty:function(a){return this._initMK()[e].keys.hasOwnProperty(a)}};return a.extend(f,b),f[c]=d,a.Object=a.Class(f)}(O,P,Q,R),T=function(a,b,c){var d=function(d,e,f){if(e&&"object"==typeof e&&d.renderIfPossible&&!f.dontRender){e[a]||b(e);var g,h,i,j,k,l,m=d[a].id,n=e.renderer||d.itemRenderer,o=n===e.renderer?e:d,p=e[a].arraysNodes=e[a].arraysNodes||{},q=p[m];if(n){if(f.moveSandbox&&(q=c.bound(e,["sandbox"]))&&(p[m]=q),q&&f.forceRerender){for(j=c.boundAll(e,["sandbox"]),k=0;k<j.length;k++)if(q==j[k]){c.unbindNode(e,"sandbox",q);
break}q=p[m]=null}if(!q){if("function"==typeof n&&(n=n.call(o,e)),"string"!=typeof n||/<|{{/.test(n))h=n;else{if(h=c._getNodes(o,n),!(h=h&&h[0]))throw Error("renderer node is missing: "+n);h=h.innerHTML}if("string"==typeof h){if(g=c.$.parseHTML(c.trim(h)),g.length>1){for(l=document.createElement("span"),k=0;k<g.length;k++)l.appendChild(g[k]);g=g=c.$(l)}d.useBindingsParser!==!1&&c.parseBindings(e,g)}else g=c.$(h);if(!g.length)throw Error("renderer node is missing");e.bindRenderedAsSandbox!==!1&&c.bindNode(e,"sandbox",g),q=g[0],p[m]=q,f.silent||(i={node:q,$nodes:g,self:e,parentArray:d},e.onRender&&e.onRender(i),d.onItemRender&&d.onItemRender(e,i),c._fastTrigger(e,"render",i),e[a].events.afterrender&&setTimeout(function(){c._fastTrigger(e,"afterrender",i)},0))}return q}}};return function(b,c){var e,f,g,h=b[a],i=h.id,j=b.length,k=c.added,l=c.removed,m=h.special.container||h.special.sandbox;if(m=m&&m.$nodes,m=m&&m[0],!m)return b;switch(c.method){case"push":for(f=j-k.length;j>f;f++)(e=d(b,b[f],c))&&m.appendChild(e);
break;case"unshift":for(f=k.length-1;f+1;f--)(e=d(b,b[f],c))&&(m.firstChild?m.insertBefore(e,m.firstChild):m.appendChild(e));break;case"pull":case"pop":case"shift":for(f=0;f<l.length;f++)g=l[f],e=g&&g[a]&&g[a].arraysNodes&&g[a].arraysNodes[i],e&&m.removeChild(e);break;case"sort":case"reverse":for(f=0;j>f;f++)g=b[f],(e=g&&g[a]&&g[a].arraysNodes[i])&&m.appendChild(e);break;case"rerender":if(c.forceRerender)for(f=0;j>f;f++)g=b[f],e=g&&g[a]&&g[a].arraysNodes&&g[a].arraysNodes[i],e&&m.removeChild(e);for(f=0;j>f;f++)(e=d(b,b[f],c))&&m.appendChild(e);break;case"recreate":case"splice":for(f=0;f<l.length;f++)g=l[f],e=g&&g[a]&&g[a].arraysNodes&&g[a].arraysNodes[i],e&&m.removeChild(e);for(f=0;j>f;f++)(e=d(b,b[f],c))&&m.appendChild(e)}return b}}(e,n,O),U=function(a,b,c){return function(d,e,f){var g,h=e.added,i=e.removed,j=d[b].events,k=e.method,l=h.length||i.length||"sort"==k||"reverse"==k;if(!e.silent){if(f&&j[f]&&a._fastTrigger(d,f,e),h.length&&(j.add&&a._fastTrigger(d,"add",e),j.addone))for(g=0;g<h.length;g++)a._fastTrigger(d,"addone",{
self:d,added:h[g]});if(i.length&&(j.remove&&a._fastTrigger(d,"remove",e),j.removeone))for(g=0;g<i.length;g++)a._fastTrigger(d,"removeone",{self:d,removed:i[g]});l&&j.modify&&a._fastTrigger(d,"modify",e)}l&&!e.dontRender&&c(d,e)}}(O,e,T),V=function(a){return a?function(a){var b,c,d=this,e=d.length,f=a&&a.isMK;for(b=0;e>b;b++)if(c=d[b],f?a.eq(c):a===c)return b;return-1}:Array.prototype.indexOf}(m),W=function(a){return a?function(a){var b,c,d=this,e=d.length,f=a&&a.isMK;for(b=e-1;b>=0;b--)if(c=d[b],f?a.eq(c):a===c)return b;return-1}:Array.prototype.lastIndexOf}(m),X=function(a,b){b=b||[];var c,d=a.length-b.length;for(c=0;c<b.length;c++)a[c]=b[c];for(c=0;d>c;c++)a.remove(c+b.length,{silent:!0});return a.length=b.length,a},Y=function(a,b,c,d,e,f,g){function createMethod(c,e){var f,h;switch(c){case"forEach":return function(){var a=this;return i[c].apply(b?j(a):a,arguments),a};case"map":case"filter":case"slice":return function(){var d=this;return a.Array.from(i[c].apply(b?j(d):d,arguments))};case"every":
case"some":case"reduce":case"reduceRight":case"join":return function(){var a=this;return i[c].apply(b?j(a):a,arguments)};case"sort":case"reverse":return function(){if(this.length<=1)return k;var a,k=this._initMK(),l=arguments,m=j(l),n=e?l[l.length-1]||{}:{},o=j(k);e&&m.pop(),b?(o=j(k),a=i[c].apply(o,m),g(k,o)):a=i[c].apply(k,m),h={returns:a,args:m,originalArgs:l,method:c,self:k,added:[],removed:[]};for(f in n)h[f]=n[f];return d(k,h,c),k};case"pop":case"shift":return function(){if(this.length){var a,k,l,m,n=this._initMK(),o=arguments,p=j(o),q=e?o[o.length-1]||{}:{};e&&p.pop(),b?(a=j(n),k=i[c].apply(a,p),g(n,a)):k=i[c].apply(n,p),h={returns:k,args:p,originalArgs:o,method:c,self:n,added:l=[],removed:m=[k]};for(f in q)h[f]=q[f];return d(n,h,c),k}};case"push":case"unshift":return function(){var a,k,l,m,n=this._initMK(),o=arguments,p=j(o),q=e?o[o.length-1]||{}:{};if(e&&p.pop(),!p.length)return n.length;if(!q.skipMediator&&"function"==typeof n._itemMediator)for(f=0;f<p.length;f++)p[f]=n._itemMediator.call(n,p[f],f);
b?(a=j(n),k=i[c].apply(a,p),g(n,a)):k=i[c].apply(n,p),h={returns:k,args:p,originalArgs:o,method:c,self:n,added:l=p,removed:m=[]};for(f in q)h[f]=q[f];return d(n,h,c),k};case"splice":return function(){var k,l,m,n=this._initMK(),o=arguments,p=j(o),q=e?o[o.length-1]||{}:{},r=j(p,2);if(e&&p.pop(),!q.skipMediator&&"function"==typeof n._itemMediator)for(f=2;f<p.length;f++)p[f]=n._itemMediator.call(n,p[f],f);if(b?(k=j(n),l=i[c].apply(k,p),g(n,k)):l=i[c].apply(n,p),m=l,r.length||m.length){h={returns:l,args:p,originalArgs:o,method:c,self:n,added:r,removed:m};for(f in q)h[f]=q[f];d(n,h,c)}return a.Array.from(l)}}}var h={},i=Array.prototype,j=c.toArray;return"push pop unshift shift sort reverse splice map filter slice every some reduce reduceRight forEach join".split(" ").forEach(function(a){h[a]=createMethod(a)}),"push pop unshift shift sort reverse splice".split(" ").forEach(function(a){h[a+"_"]=createMethod(a,1)}),h.each=h.forEach,h.concat=function(){var b,c,d,e=arguments,f=this.toArray();for(c=0;c<e.length;c++)if(b=e[c],
b instanceof Array||b instanceof a.Array||b&&b.instanceOf&&b.instanceOf(a.Array))for(d=0;d<b.length;d++)f.push(b[d]);return a.Array.from(f)},h.toString=function(){return this.toArray().join(",")},h.indexOf=e,h.lastIndexOf=f,h}(O,m,d,U,V,W,X),Z=function(a){return{of:function(){var b,c=new a.Array,d=arguments;for(c.length=d.length,b=0;b<d.length;b++)c[b]=d[b];return c},from:function(b,c,d){var e,f=new a.Array;for(f.length=b.length,e=0;e<b.length;e++)f[e]=c?c.call(d,b[e],e,b):b[e];return f}}}(O),_=function(a,b,c,d,e,f,g){return{mediateItem:function(a){var b,c=this,d=c.length;for(c._itemMediator=a,b=0;d>b;b++)c[b]=a.call(c,c[b],b);return c},recreate:function(b,c){function update(a,b){var c;if(a.isMKArray)a.recreate(b);else if(a.isMKObject)a.jset(b);else for(c in b)b.hasOwnProperty(c)&&(a[c]=b[c]);return a}b=b||[];var e,g,h,i,j,k,l,m,n=this._initMK(),o=b.length,p=n.length-o,q=n.toArray(),r=n.trackBy;if(c=c||{},r)if(j={},"$index"==r)for(g=0;o>g;g++)b[g]=n[g]?update(n[g],b[g]):b[g];else{for(g=0;g<n.length;g++)j[n[g][r]]=n[g];
for(g=0;o>g;g++)b[g][r]in j&&(b[g]=update(j[b[g][r]],b[g]))}if(n._itemMediator&&!c.skipMediator){for(e=[],g=0;o>g;g++)e[g]=n._itemMediator.call(n,b[g],g);b=e}for(g=0;o>g;g++)n[g]=b[g];for(g=0;p>g;g++){try{delete n[g+o]}catch(s){}delete n[a].special[g+o]}if(n.length=o,c.silent&&c.dontRender)return n;if(m=n.toArray(),m.length)for(l=[],h=0,g=0;g<q.length;g++)~f.call(m,q[g])||(l[h++]=q[g]);else l=q;if(q.length)for(k=[],h=0,g=0;g<m.length;g++)~f.call(q,m[g])||(k[h++]=m[g]);else k=m;i={added:k,removed:l,was:q,now:m,method:"recreate",self:n};for(g in c)i[g]=c[g];return d(n,i,"recreate"),n},toArray:function(){var a,b=this,c=[],d=b.length;for(c=[],a=0;d>a;a++)c[a]=b[a];return c},toNative:function(){return this.toArray()},rerender:function(a){var b,d={method:"rerender"};if(a&&"object"==typeof a)for(b in a)d[b]=a[b];return c(this,d)},toJSON:function(){var a,b=this,c=[],d=b.length;for(a=0;d>a;a++)b[a]&&b[a].toJSON?c.push(b[a].toJSON()):c.push(b[a]);return c},pull:function(a,b){var c,f,g,h,i=this._initMK(),j=i.toArray(),k=a,l=typeof a;
if("number"!=l&&"string"!=l&&(a=i.indexOf(a),!~a))return null;if(c=j.splice(a,1)[0]||null){b=b||{},e(i,j,b),g={returns:c,args:[k],method:"pull",self:i,added:[],removed:f=c?[c]:[]};for(h in b)g[h]=b[h];d(i,g,"pull")}return c},restore:function(c,d){var e,f,h,i,j,k,l,m,n=this._initMK(),o=n[a],p=o.id,q=n.Model;if(c?e=b._getNodes(n,c):(h=o.special.container||o.special.sandbox,h=h&&h.$nodes,h=h&&h[0],e=h&&h.children),e&&e.length){for(m=[],i=0;i<e.length;i++)f=e[i],j=q?new q:{},g(j),k=j[a].arraysNodes={},k[p]=f,j.bindRenderedAsSandbox!==!1&&b.bindNode(j,"sandbox",f),d&&d.silent||(l={node:f,$nodes:b.$(f),self:j,parentArray:n},j.onRender&&j.onRender(l),n.onItemRender&&n.onItemRender(j,l),b._fastTrigger(j,"render",l)),m[i]=j;n.recreate(m,d)}return n}}}(e,O,T,U,X,V,n),aa=function(){var a=this,b=0;return{next:function(){return b>a.length-1?{done:!0}:{done:!1,value:a[b++]}}}},ba=function(a,b,c,d,e,f,g,h,i){if(!a)throw new Error("Matreshka is missing");var j={"extends":a,isMKArray:!0,length:0,itemRenderer:null,
renderIfPossible:!0,Model:null,constructor:function MatreshkaArray(a){var b,c=this._initMK(),d=arguments.length;if(1==d&&"number"==typeof a)c.length=a;else{for(b=0;d>b;b++)c[b]=arguments[b];c.length=arguments.length}return c},_initMK:function(){var c,d=this;return d[b]?d:(c=function(){var a=d.Model;a&&d.mediateItem(function(b,c){return b&&(b.instanceOf?b.instanceOf(a):b instanceof a)?b:new a(b&&b.toJSON?b.toJSON():b,d,c)})},a.prototype._initMK.call(d),a._fastAddListener(d,"change:Model",c),a._fastAddListener(d,"change:itemRenderer",function(a){d.rerender({forceRerender:a&&"forceRerender"in a?a.forceRerender:!0})}),c(),d)},toJSON:function(){var a,b=this,c=[],d=b.length;for(a=0;d>a;a++)b[a]&&b[a].toJSON?c[a]=b[a].toJSON():c[a]=b[a];return c},hasOwnProperty:function(a){return"length"==a||a<this.length&&a>=0}};return a.extend(j,c,e),j[i]=h,a.Array=a.Class(j),a.extend(a.Array,d),a.Array}(O,e,Y,Z,_,U,T,aa,R),ca=function(a,b,c,d){return a}(O,S,ba),da=function(a){return a}(j),ea=function(a){return a;
}(b),fa=function(a){return a}(L),ga=function(a){return a}(ca),ga.version="1.4.1",function(){var b="define";"undefined"!=typeof a&&("function"==typeof define&&define.amd?(a[b]&&(a[b]("matreshka",function(){return ga}),a[b]("balalaika",function(){return ga.$b}),a[b]("xclass",function(){return ga.Class}),a[b]("matreshka-magic",function(){return matreshka_magic})),define(function(){return ga})):"object"==typeof exports?module.exports=ga:(a.Matreshka=a.MK=ga,a.$b=ga.$b,a.Class=ga.Class))}()}("undefined"!=typeof window?window:Function("return this")());
//# sourceMappingURL=matreshka.min.map