text: var data=function(){"use strict";function n(n){return function(t){return t==n}}function t(n,e,r,o){var u=r.shift();if(!b[e])return!1;if(r.length){if(!(u in n)){if("remove"==e)return!0;n[u]={}}return t(n[u],e,r,o)}return b[e](n,u,o),!0}var e=n;n.fn=function(n){return"function"==typeof n},n.str=function(n){return"string"==typeof n},n.num=function(n){return"number"==typeof n},n.obj=function(n){return"object"==typeof n},n.lit=function(n){return"object"==typeof n&&!(n instanceof Array)},n.bol=function(n){return"boolean"==typeof n},n.truthy=function(n){return 1==!!n},n.falsy=function(n){return 0==!!n},n.arr=function(n){return n instanceof Array},n.null=function(n){return null===n},n.def=function(n){return void 0!==n},n.in=function(n){return function(t){return!!n&&(n.indexOf?~n.indexOf(t):t in n)}},n.promise=function(n){return n instanceof Promise},n.stream=function(n){return!(!n||!n.next)};var r=function(n){return Object.keys(e.obj(n)||e.fn(n)?n:{})},o=function(n,t){return function(e){return t[e]=n[e],e}},u=function(n){return function(t){return r(t).map(o(t,n)),n}},i=function(n){return function(){return n}},f=function(n){return 0===n?"0":n?e.fn(n)?""+n:e.obj(n)?JSON.stringify(n):String(n):""},c=function n(t,r){var o=arguments.length>1,u=e.fn(t)?[]:f(t).split("."),c=u.shift();return function(f,a){var l={};return f?e.num(t)||t?e.arr(t)?(t.map(function(t){var r=n(t)(f);void 0!=r&&n(t,e.fn(r)?i(r):r)(l)}),l):f[t]||!u.length?o?(f[t]=e.fn(r)?r(f[t],a):r,f):e.fn(t)?t(f):f[t]:o?(n(u.join("."),r)(f[c]?f[c]:f[c]={}),f):n(u.join("."))(f[c]):f:void 0}},a=function(n,t){var e=1==arguments.length;return function(r){return r&&r.headers?e?c(n)(r.headers):c(n)(r.headers)==t:null}},l=function(n){return function(){return!n.apply(this,arguments)}},s=function(n){return function(t){return r(t).filter(l(e.in(n))).map(o(t,n)),n}},p=function n(t,r){var o=arguments.length;return e.str(t)||2!=o?e.str(t)||3!=o?function(n){var u=this||{};return n=u.nodeName||e.fn(u.node)?u:n,n=n.node?n.node():n,n=n.host||n,o>1&&!1===r?n.removeAttribute(t):o>1?(n.setAttribute(t,r),r):n.attributes.getNamedItem(t)&&n.attributes.getNamedItem(t).value}:n(arguments[1],arguments[2]).call(this,arguments[0]):n(arguments[1]).call(this,arguments[0])},d=function(){var n,t,e=new Promise(function(e,r){n=e,t=r});return arguments.length&&n(arguments[0]),e.resolve=n,e.reject=t,e},y=function n(t,e){return e instanceof Array&&(e=e.reduce(n,[])),(t=t||[]).concat(e)},h=function(n,t){return t in n},g=function(n,t,e,r){return n.host&&n.host.nodeName&&(n=n.host),t.name&&(e=t,t=t.name),!h(n,t)&&Object.defineProperty(n,t,{value:e,writable:r}),n[t]},m=function n(t){function e(n,e){return n.next?n.next(e):e instanceof Array?n.apply(t,e):n.call(t,e)}function r(n,t){for(var e=n.length;~--e;)t!=n[e]&&t!=n[e].fn&&t||n.splice(e,1)}function o(t,e){var u=n((e=e||{}).base||d());return u.i=0,u.li=[],u.fn=e.fn,u.parent=t,u.source=e.fn?u.parent.source:u,u.on("stop",function(){return u.type?u.parent.off(u.type,u):u.parent.off(u)}),u.each=function(n){var t=n.next?n:o(u,{fn:n});return u.li.push(t),t},u.pipe=function(n){return n(u)},u.map=function(n){return u.each(function(t,e,r){return r.next(n(t,e,r))})},u.filter=function(n){return u.each(function(t,e,r){return n(t,e,r)&&r.next(t)})},u.reduce=function(n,t){return u.each(function(e,r,o){return o.next(t=n(t,e,r,o))})},u.unpromise=function(){var n=o(u,{base:{},fn:function(t){return n.next(t)}});return u.li.push(n),n},u.next=function(n){return u.resolve&&u.resolve(n),u.li.length?u.li.map(function(t){return t.fn(n,t.i++,t)}):n},u.until=function(n){return n.each(function(){u.source.emit("stop")}),u},u.off=function(n){return r(u.li,n),u},u[Symbol.asyncIterator]=function(){return{next:function(){return u.wait=new Promise(function(n){u.wait=!0,u.map(function(t,e,r){delete u.wait,u.off(r),n({value:t,done:!1})}),u.emit("pull",u)})}}},u}return t=t||{},g(t,"emit",function(n,r,o){for(var u=t.on[n.split(".")[0]]||[],i=[],f=0;f<u.length;f++)u[f].ns&&o&&!o(u[f].ns)||i.push(e(u[f].isOnce?u.splice(f--,1)[0]:u[f],r));for(f=0;f<t.on["*"].length;f++)i.push(e(t.on["*"][f],[n,r]));return i.reduce(y,[])},1),g(t,"once",function(n,e){return t.on(n,e,!0)},1),g(t,"off",function(n,e){return r(t.on[n]||[],e),e&&e.ns&&delete t.on[n]["$"+e.ns],t},1),g(t,"on",function(n,e,u){function i(n){return n.isOnce=u,n.type=f,c&&(t.on[f]["$"+(n.ns=c)]=n),a.push(n),n.next?n:t}var f=n.split(".")[0],c=n.split(".")[1],a=t.on[f]=t.on[f]||[],l="function"==typeof e?e:0;return!l&&c?(l=t.on[f]["$"+c])?l:i(o(t,e)):l||c?l&&c?i((r(a,t.on[f]["$"+c]||-1),l)):!(!l||c)&&i(l):i(o(t,e))},1),t.on["*"]=t.on["*"]||[],t},b={add:function(n,t,r){e.arr(n)?n.splice(t,0,r):n[t]=r},update:function(n,t,e){n[t]=e},remove:function(n,t){e.arr(n)?n.splice(t,1):delete n[t]}},v=JSON.stringify,x=JSON.parse,w=function(n,r){return function(o,u,i){if(!e.obj(o)&&!e.fn(o))return o;if(!e.obj(n)){var f=u||o.log||[],c=o;if(e.def(i)||(i=f.max||0),i||(f=[]),i<0&&(f=f.concat(null)),i>0){var a=v(o);c=x(a),f=f.concat({type:"update",value:x(a),time:f.length})}return g(f,"max",i),c.log?c.log=f:g(m(c),"log",f,1),c}return!!e.def(n.key)&&(!!t(o,n.type,(n.key=""+n.key).split("."),n.value)&&(o.log&&o.log.max&&o.log.push((n.time=o.log.length,o.log.max>0?n:null)),!r&&o.emit&&o.emit("change",n),o))}},j=function(n){return e.fn(n)?n:new Function("return "+n)()},O={arr:function(n){return Array.prototype.slice.call(n,0)},obj:function(n){function t(n,t,o){return 0===o&&(n={}),n[e.fn(r)?r(t,o):t[r]]=t,n}var r="id";return 1==arguments.length?(r=n,t):t.apply(this,arguments)}},A="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},N="undefined"!=typeof window?window:A,S=function(n){return function(t){if(!N.console||!console.log.apply)return t;e.arr(arguments[2])&&(arguments[2]=arguments[2].length);var r=O.arr(arguments),o="[log]["+(new Date).toISOString()+"]"+n;return r.unshift(o.grey?o.grey:o),console.log.apply(console,r),t}}("[ri/types/data]"),k=c("body.on");return function(n){return S("creating"),n.on("change.data").filter(function(t){var e=t[0];return a("content-type","application/data")(n.resources[e])}).filter(function(n){var t=n[1];return t&&t.key}).map(function(t){var r=t[0],o=t[1];return n.resources[r].body.emit("change",o||null,l(e.in(["bubble"])))}),n.types["application/data"]={header:"application/data",selector:function(n){return'[data~="'+n.name+'"]'},extract:function(n){return(p("data")(n)||"").split(" ")},check:function(n){return!!e.obj(n.body)},parse:function(t){e.str(t.body)&&(t.body=j(t.body));var r=n.resources[t.name]||{};return s(t.headers)(r.headers),t.body=w()(t.body||[],r.body&&r.body.log,e.num(t.headers.log)?t.headers.log:-1),u(t.body.on)(k(r)),t.body.on("change.bubble",function(r){n.emit("change",n.change=[t.name,r],l(e.in(["data"]))),delete n.change}),t}},n}}();
  