-
Notifications
You must be signed in to change notification settings - Fork 0
/
gun.min.js
1 lines (1 loc) · 38.4 KB
/
gun.min.js
1
!function(){function f(e,t){return t?require(e):e.slice?f[o(e)]:function(t,n){e(t={exports:{}}),f[o(n)]=t.exports};function o(t){return t.split("/").slice(-1).toString().replace(".js","")}}if("undefined"!=typeof module)var n=module;f(function(t){String.random=function(t,n){var e="";for(t=t||24,n=n||"0123456789ABCDEFGHIJKLMNOPQRSTUVWXZabcdefghijklmnopqrstuvwxyz";0<t--;)e+=n.charAt(Math.floor(Math.random()*n.length));return e},String.match=function(t,n){var e,o;return"string"==typeof t&&("string"==typeof n&&(n={"=":n}),t===(e=(n=n||{})["="]||n["*"]||n[">"]||n["<"])||o===n["="]&&(e=n["*"]||n[">"],t.slice(0,(e||"").length)===e||o===n["*"]&&(o!==n[">"]&&o!==n["<"]?t>=n[">"]&&t<=n["<"]:o!==n[">"]&&t>=n[">"]||o!==n["<"]&&t<=n["<"])))},String.hash=function(t,n){if("string"==typeof t){if(n=n||0,!t.length)return n;for(var e=0,o=t.length;e<o;++e)n=(n<<5)-n+t.charCodeAt(e),n|=0;return n}};var n,e,o,i,r,a,s,u,c,f,l,h,p,d,g=Object.prototype.hasOwnProperty;Object.plain=function(t){return!!t&&(t instanceof Object&&t.constructor===Object||"Object"===Object.prototype.toString.call(t).match(/^\[object (\w+)\]$/)[1])},Object.empty=function(t,n){for(var e in t)if(g.call(t,e)&&(!n||-1==n.indexOf(e)))return!1;return!0},Object.keys=Object.keys||function(t){var n=[];for(var e in t)g.call(t,e)&&n.push(e);return n},n=setTimeout,o=e=0,i=typeof setImmediate!=""+void 0&&setImmediate||n,n.poll=n.poll||function(t){+new Date-e<=1&&o++<3333?t():i(function(){e=+new Date,t()},o=0)},a=setTimeout,u=(s=a.turn=a.turn||function(t){1==u.push(t)&&c(l)}).s=[],c=a.poll,f=0,l=function(){(r=u[f++])&&r(),f!=u.length&&99!=f||(u=s.s=u.slice(f),f=0),u.length&&c(l)},p=setTimeout,d=p.turn,(p.each=p.each||function(r,a,s,u){u=u||9,function t(n,e,o){if(e=(n=(r||[]).splice(0,u)).length){for(var i=0;i<e&&h===(o=a(n[i]));i++);if(h===o)return void d(t)}s&&s(o)}()})()})(f,"./shim"),f(function(t){t.exports=function t(n,e,o){if(!n)return{to:t};var i="function"==typeof e;n=(this.tag||(this.tag={}))[n]||i&&(this.tag[n]={tag:n,to:t._={next:function(t){var n;(n=this.to)&&n.next(t)}}});if(i){var r={off:t.off||(t.off=function(){if(this.next===t._.next)return!0;this===this.the.last&&(this.the.last=this.back),this.to.back=this.back,this.next=t._.next,this.back.to=this.to,this.the.last===this.the&&delete this.on.tag[this.the.tag]}),to:t._,next:e,the:n,on:this,as:o};return(r.back=n.last||n).to=r,n.last=r}return(n=n.to)&&void 0!==e&&n.next(e),n}})(f,"./onto"),f(function(t){f("./shim"),t.exports=function(t){return void 0!==t&&(null===t||t!==1/0&&(t==t&&("string"==typeof t||"boolean"==typeof t||"number"==typeof t||!(!t||"string"!=typeof(t["#"]||0)||!Object.empty(t,["#"]))&&t["#"])))}})(f,"./valid"),f(function(t){function n(){var t=+new Date;return i=i<t?(e=0,t+n.drift):t+(e+=1)/o+n.drift}f("./shim");n.drift=0;var e=0,o=999,i=-1/0;n.is=function(t,n,e){var o=n&&t&&t._&&t._[">"]||e;if(o)return"number"==typeof(o=o[n])?o:-1/0},n.ify=function(t,n,e,o,i){(t=t||{})._=t._||{},i&&(t._["#"]=i);var r=t._[">"]||(t._[">"]={});return void 0!==n&&"_"!==n&&("number"==typeof e&&(r[n]=e),void 0!==o&&(t[n]=o)),t},t.exports=n})(f,"./state"),f(function(t){f("./shim"),t.exports=function(o){var i={s:{}},r=i.s;o=o||{max:999,age:9e3},i.check=function(t){return!!r[t]&&n(t)};var n=i.track=function(t){var n=r[t]||(r[t]={});return n.was=i.now=+new Date,i.to||(i.to=setTimeout(i.drop,o.age+9)),n};return i.drop=function(e){i.to=null,i.now=+new Date;var t=Object.keys(r);console.STAT&&console.STAT(i.now,+new Date-i.now,"dup drop keys"),setTimeout.each(t,function(t){var n=r[t];n&&(e||o.age)>i.now-n.was||delete r[t]},0,99)},i}})(f,"./dup"),f(function(t){f("./onto"),t.exports=function(t,n){if(this.on){var e=(this.opt||{}).lack||9e3;if("function"!=typeof t){if(!t)return;var o=t["#"]||t,i=(this.tag||"")[o];if(!i)return;return n&&(i=this.on(o,n),clearTimeout(i.err),i.err=setTimeout(function(){i.off()},e)),!0}o=n&&n["#"]||a(9);if(!t)return o;var r=this.on(o,t,n);return r.err=r.err||setTimeout(function(){r.off(),r.next({err:"Error: No ACK yet.",lack:!0})},e),o}};var a=String.random||function(){return Math.random().toString(36).slice(2)}})(f,"./ask"),f(function(t){function c(t){return t instanceof c?(this._={$:this}).$:this instanceof c?c.create(this._={$:this,opt:t}):new c(t)}function u(t,a){var s=+new Date,n=t._||{},u=n.DBG=t.DBG,c=t["#"],f=g(9),l=Object.keys(a||"").sort(),h=((a||"")._||"")["#"],p=(l.length,t.$._.root),d=a===p.graph[h];console.STAT&&console.STAT(s,((u||n).gk=+new Date)-s,"got keys"),a&&function t(){s=+new Date;for(var n,e,o,i=0,r={};i<9&&(n=l[i++]);)O(r,n,m(a,n),a[n],h);l=l.slice(i),(e={})[h]=r,r=e,d&&((o=function(){}).ram=o.faith=!0),e=l.length,console.STAT&&console.STAT(s,-(s-(s=+new Date)),"got copied some"),u&&(u.ga=+new Date),p.on("in",{"@":c,"#":f,put:r,"%":e?f=g(9):T,$:p.$,_:o,DBG:u}),console.STAT&&console.STAT(s,+new Date-s,"got in"),e&&setTimeout.turn(t)}(),a||p.on("in",{"@":t["#"]})}c.is=function(t){return t instanceof c||t&&t._&&t===t._.$||!1},c.version=.202,(c.chain=c.prototype).toJSON=function(){},f("./shim"),c.valid=f("./valid"),c.state=f("./state"),c.on=f("./onto"),c.dup=f("./dup"),c.ask=f("./ask"),function(){function b(t){if(t)if(t.out!==b){var n,e=this.as,o=e.at||e,i=o.$,r=o.dup,a=t.DBG;if((n=t["#"])||(n=t["#"]=g(9)),!r.check(n)){if(r.track(n),n=t._,t._="function"==typeof n?n:function(){},t.$&&t.$===(t.$._||"").$||(t.$=i),t["@"]&&!t.put&&function(t){var n,e=t["@"]||"";if(!(n=e._))return;n.acks=(n.acks||0)+1,(n.err=t.err)&&(t["@"]=n["#"],$(n));n.stop||n.crack||(n.crack=n.match&&n.match.push(function(){u(n)}));u(n)}(t),!o.ask(t["@"],t)){if(a&&(a.u=+new Date),t.put)return void s(t);t.get&&c.on.get(t,i)}a&&(a.uc=+new Date),this.to.next(t),a&&(a.ua=+new Date),t.nts||t.NTS||(t.out=b,o.on("out",t),a&&(a.ue=+new Date))}}else this.to.next(t)}function s(a){if(a){var s=a._||"",t=s.root=((s.$=a.$||"")._||"").root;if(a["@"]&&s.faith&&!s.miss)return a.out=b,void t.on("out",a);s.latch=t.hatch,s.match=t.hatch=[];var u=a.put,c=s.DBG=a.DBG,f=+new Date;if(!u["#"]||!u["."]){c&&(c.p=f),s["#"]=a["#"],s.msg=a,s.all=0,s.stun=1;var l=Object.keys(u);console.STAT&&console.STAT(f,((c||s).pk=+new Date)-f,"put sort");var h,p,d,g,v,y,k,m=0;!function t(n){if(h!=m){if(!(d=l[h=m]))return console.STAT&&console.STAT(f,((c||s).pd=+new Date)-f,"put"),void $(s);(g=u[d])?(k=g._)?d!==k["#"]?y=w+j(d)+"soul not same.":(v=k[">"])||(y=w+j(d)+"no state."):y=w+j(d)+"no meta.":y=w+j(d)+"no node.",p=Object.keys(g||{})}if(y)return a.err=s.err=y,void $(s);var e,o=0;for(n=n||0;n++<9&&(e=p[o++]);)if("_"!==e){var i=g[e],r=v[e];if(T===r){y=w+j(e)+"on"+j(d)+"no state.";break}if(!S(i)){y=w+j(e)+"on"+j(d)+"bad "+typeof i+j(i);break}_(i,e,d,r,a)}(p=p.slice(o)).length?x(t):(++m,p=null,t(n))}()}}}function _(t,n,e,o,i){var r,a=i._||"",s=a.root,u=s.graph,c=u[e]||D,f=m(c,n,1),l=c[n],h=a.DBG;(r=console.STAT)&&(u[e]&&l||(r.has=(r.has||0)+1));var p=k();if(p<o)return setTimeout(function(){_(t,n,e,o,i)},(r=o-p)>y?y:r),void(console.STAT&&console.STAT((h||a).Hf=+new Date,r,"future"));if((!(o<f)||a.miss)&&(a.faith||o!==f||!(t===l||v(t)<=v(l))||a.miss)){a.stun++;var d=i["#"]+a.all++,g={toString:function(){return d},_:a};g.toJSON=g.toString,h&&(h.ph=h.ph||+new Date),s.on("put",{"#":g,"@":i["@"],put:{"#":e,".":n,":":t,">":o},_:a})}}function e(t){var n;(n=(t._||"").DBG)&&(n.pa=+new Date,n.pm=n.pm||+new Date);var e,o=this.as,i=o.graph,r=t._,a=t.put,s=a["#"],u=a["."],c=a[":"],f=a[">"];t["#"];(e=r.msg)&&(e=e.put)&&(e=e[s])&&O(e,u,f,c,s),i[s]=O(i[s],u,f,c,s),(e=(o.next||"")[s])&&e.on("in",t),$(r),this.to.next(t)}function $(t,n){var e;if(!t.stop&&(t.err||!(0<--t.stun))&&(t.stop=1,e=t.root)){var o=t.match;o.end=1,o===e.hatch&&(!(o=t.latch)||o.end?delete e.hatch:e.hatch=o),t.hatch&&t.hatch(),setTimeout.each(t.match,function(t){t&&t()}),!(n=t.msg)||t.err||n.err||(n.out=b,t.root.on("out",n))}}function u(t){t&&t.root&&(t.stun||t.acks!==t.all||t.root.on("in",{"@":t["#"],err:t.err,ok:t.err?T:{"":1}}))}c.create=function(t){t.root=t.root||t,t.graph=t.graph||{},t.on=t.on||c.on,t.ask=t.ask||c.ask,t.dup=t.dup||c.dup();var n=t.$.opt(t.opt);return t.once||(t.on("in",b,t),t.on("out",b,t),t.on("put",e,t),c.on("create",t),t.on("create",t)),t.once=1,n},c.on.put=s,console.log("BEWARE: BETA VERSION OF NEW GUN! NOT ALL FEATURES FINISHED!");var w="Error: Invalid graph!",j=function(t){return" '"+(""+t).slice(0,9)+"...' "},v=JSON.stringify,y=2147483647,k=c.state}(),c.on.get=function(t,n){var e=n._,o=t.get,i=o["#"],r=e.graph[i],a=o["."],s=((e.next||(e.next={}))[i],(t._||{}).DBG=t.DBG);if(s&&(s.g=+new Date),!r)return e.on("get",t);if(a){if("string"!=typeof a||T===r[a])return e.on("get",t);r=O({},a,m(r,a),r[a],i)}r&&u(t,r),e.on("get",t)},c.on.get.ack=u,c.chain.opt=function(t){t=t||{};var e=this._,n=t.peers||t;return Object.plain(t)||(t={}),Object.plain(e.opt)||(e.opt=t),"string"==typeof n&&(n=[n]),n instanceof Array&&(Object.plain(e.opt.peers)||(e.opt.peers={}),n.forEach(function(t){var n={};n.id=n.url=t,e.opt.peers[t]=e.opt.peers[t]||n})),e.opt.peers=e.opt.peers||{},o(t,function t(n){var e=this[n];this&&this.hasOwnProperty(n)||"string"==typeof e||Object.empty(e)?this[n]=e:(!e||e.constructor===Object||e instanceof Array)&&o(e,t)}),c.on("opt",e),e.opt.uuid=e.opt.uuid||function(t){return c.state().toString(36).replace(".","")+String.random(t||12)},this};var T,e,o=function(t,n){Object.keys(t).forEach(n,t)},g=String.random,x=setTimeout.turn,S=c.valid,m=c.state.is,O=c.state.ify,D={};(c.log=function(){return c.log.off||e.log.apply(e,arguments),[].slice.call(arguments).join(" ")}).once=function(t,n,e){return(e=c.log.once)[t]=e[t]||0,e[t]++||c.log(n)},"undefined"!=typeof window&&((window.GUN=window.Gun=c).window=window);try{void 0!==n&&(n.exports=c)}catch(t){}((t.exports=c).window||{}).console=(c.window||{}).console||{log:function(){}},(e=console).only=function(t,n){return e.only.i&&t===e.only.i&&e.only.i++&&(e.log.apply(e,arguments)||n)},c.log.once("welcome","Hello wonderful person! :) Thanks for using GUN, please ask for help on http://chat.gun.eco if anything takes you longer than 5min to figure out!")})(f,"./root"),f(function(t){f("./root").chain.back=function(t,n){if(-1===(t=t||1)||1/0===t)return this._.root.$;if(1===t)return(this._.back||this._).$;var e=this._;if("string"==typeof t&&(t=t.split(".")),t instanceof Array){for(var o=0,i=t.length,r=e;o<i;o++)r=(r||s)[t[o]];return void 0!==r?n?this:r:(r=e.back)?r.$.back(t,n):void 0}if("function"!=typeof t)return"number"==typeof t?(e.back||e).$.back(t-1):this;var a;for(r={back:e};(r=r.back)&&void 0===(a=t(r,n)););return a};var s={}})(f,"./back"),f(function(t){var u=f("./root");function l(t,n){if(n=n||this.as||t.$._,(!t.$$||this===u.on)&&t.put&&!n.soul){var e=t.put||"",o=e["="]||e[":"],i=n.root,r=i.$.get(e["#"]).get(e["."])._;if("string"==typeof(o=g(o))){if(!(r.echo||(r.echo={}))[n.id]||(i.pass||"")[n.id]){if(a=i.pass){if(a[o+n.id])return;a[o+n.id]=1}((r.echo||(r.echo={}))[n.id]=n).has&&(n.link=o);var a,s=i.$.get(r.link=o)._;(s.echo||(s.echo={}))[r.id]=r,((a=n.ask||"")[""]||n.lex)&&s.on("out",{get:{"#":o}}),setTimeout.each(Object.keys(a),function(t,n){t&&(n=a[t])&&n.on("out",{get:{"#":o,".":t}})},0,99)}}else this===u.on&&((r.echo||(r.echo={}))[n.id]=n)}}function h(t,e){var o,n,i=t.put||"",r=p!==i["="]?i["="]:i[":"],a=e.root;if(p===r){if(e.soul&&p!==e.put)return;if(n=(t.$$||t.$||"")._||"",t["@"]&&(p!==n.put||p!==e.put))return;return(o=e.link||t.linked)&&delete(a.$.get(o)._.echo||"")[e.id],e.has&&(e.link=null),e.put=p,void setTimeout.each(Object.keys(e.next||""),function(t,n){(n=e.next[t])&&(o&&delete(a.$.get(o).get(t)._.echo||"")[n.id],n.on("in",{get:t,put:p,$:n.$}))},0,99)}e.soul||t.$$||(o=g(r),n=t.$._||"",(o!==n.link&&(!e.has||n.link)||(a.pass||"")[e.id]&&"string"!=typeof o)&&(delete(n.echo||"")[e.id],h({get:e.get,put:p,$:t.$,linked:t.linked=t.linked||n.link},e)))}function a(t,n){var e=this.as,o=e.$._,i=(o.root,e.get||""),r=(t.put||"")[i["#"]]||"";if(!t.put||"string"==typeof i["."]&&p===r[i["."]]){if(p!==o.put)return;if(!o.soul&&!o.has)return;return o.ack=(o.ack||0)+1,void o.on("in",{get:o.get,put:o.put=p,$:o.$,"@":t["@"]})}(t._||{}).miss=1,u.on.put(t)}u.chain.chain=function(t){var n,e=this._,o=new(t||this).constructor(this),i=o._;return i.root=n=e.root,i.id=++n.once,i.back=this._,i.on=u.on,i.on("in",u.on.in,i),i.on("out",u.on.out,i),o},u.on.out=function(t){var n,e,o=this.as,i=o.back,r=o.root;if(t.$||(t.$=o.$),this.to.next(t),!o.err){if(n=t.get){if(r.pass&&(r.pass[o.id]=o),o.lex&&Object.keys(o.lex).forEach(function(t){e[t]=o.lex[t]},e=t.get=t.get||{}),n["#"]||o.soul){if(n["#"]=n["#"]||o.soul,t["#"]||(t["#"]=s(9)),i=r.$.get(n["#"])._,n=n["."]){if(c(i.put,n)&&(e=i.ask&&i.ask[n],(i.ask||(i.ask={}))[n]=i.$.get(n)._,i.on("in",{get:n,put:{"#":i.soul,".":n,":":i.put[n],">":v(r.graph[i.soul],n)}}),e))return}else{if(e=i.ask&&i.ask[""],(i.ask||(i.ask={}))[""]=i,p!==i.put&&(i.on("in",i),e))return;t.$=i.$}return r.ask(a,t),r.on("in",t)}if(n["."])return o.get?(t={get:{".":o.get},$:o.$},(i.ask||(i.ask={}))[o.get]=t.$._):t={get:o.lex?t.get:{},$:o.$},i.on("out",t);if(((o.ask||(o.ask={}))[""]=o).get)return n["."]=o.get,(i.ask||(i.ask={}))[o.get]=t.$._,i.on("out",t)}return i.on("out",t)}o.on("in",{put:o.put=p,$:o.$})},u.on.in=function(n,e){var t,o=(e=e||this.as).root,i=n.$||(n.$=e.$),r=(i||"")._||d,a=n.put||"",s=a["#"],u=a["."],c=p!==a["="]?a["="]:a[":"],f=a[">"]||-1/0;if(p!==n.put&&(p===a["#"]||p===a["."]||p===a[":"]&&p===a["="]||p===a[">"]))return g(a)?void e.on("in",{$:r.back.$,put:{"#":s=r.back.soul,".":u=r.has||r.get,"=":a,">":v(r.back.put,u)},via:n}):(s=((a||"")._||"")["#"])?(i=e.root.$.get(s),setTimeout.each(Object.keys(a).sort(),function(t){"_"!=t&&p!==(f=v(a,t))&&e.on("in",{$:i,put:{"#":s,".":t,"=":a[t],">":f},VIA:n})})):void console.log("chain not yet supported for",a,"...",n,e);(n.seen||"")[e.id]||(((n.seen||(n.seen=function(){}))[e.id]=e)!==r&&(Object.keys(n).forEach(function(t){a[t]=n[t]},a={}),a.get=e.get||a.get,e.soul||e.has?r.soul&&(a.$=e.$,a.$$=a.$$||r.$):a.$$$=a.$$$||e.$,n=a),h(n,e),(e.soul||n.$$)&&f>=v(o.graph[s],u)&&((a=o.$.get(s)._).put=y(a.put,u,f,c,s)),!r.soul&&f>=v(o.graph[s],u)&&(t=(o.$.get(s)._.next||"")[u])&&(t.put=c,"string"==typeof(a=g(c))&&(t.put=o.$.get(a)._.put||c)),this.to&&this.to.next(n),e.any&&setTimeout.each(Object.keys(e.any),function(t){(t=e.any[t])&&t(n)},0,99),e.echo&&setTimeout.each(Object.keys(e.echo),function(t){(t=e.echo[t])&&t.on("in",n)},0,99),((n.$$||"")._||r).soul&&(t=e.next)&&(t=t[u])&&(a={},Object.keys(n).forEach(function(t){a[t]=n[t]}),a.$=(n.$$||n.$).get(a.get=u),delete a.$$,delete a.$$$,t.on("in",a)),l(n,e))},u.on.link=l,u.on.unlink=h;var p,d={},s=String.random,g=u.valid,c=function(t,n){return t&&Object.prototype.hasOwnProperty.call(t,n)},n=u.state,v=n.is,y=n.ify})(f,"./chain"),f(function(t){var g=f("./root");function r(t){var n=this.at||this.on;if(!t||n.soul||n.has)return this.off();if(t=(t=(t=t.$||t)._||t).id){var e;n.map;if((e=this.seen||(this.seen={}))[t])return!0;e[t]=!0}}g.chain.get=function(t,n,e){var o,i;if("string"==typeof t){if(0==t.length)return(o=this.chain())._.err={err:g.log("0 length key!",t)},n&&n.call(o,o._.err),o;(o=((f=this._).next||a)[t])||(o=t&&function(t,n){var e=n._,o=e.next,i=n.chain()._;o=o||(e.next={});o[i.get=t]=i,n===e.root.$?i.soul=t:(e.soul||e.has)&&(i.has=t);return i}(t,this)),o=o&&o.$}else{if("function"==typeof t){if(!0===n)return function(t,n,e,o){var a,s=t._,u=0;if(a=s.soul||s.link)return n(a,o,s);if(s.jam)return s.jam.push([n,o]);s.jam=[[n,o]],t.get(function(t,n){if(!(v===t.put&&!s.root.opt.super&&(a=Object.keys(s.root.opt.peers).length)&&++u<=a)){n.rid(t);var e,o=(o=t.$)&&o._||{},i=0;for(a=s.jam,delete s.jam;e=a[i++];){var r=e[0];e=e[1],r&&r(o.link||o.soul||g.valid(t.put)||((t.put||{})._||{})["#"],e,t,n)}}},{out:{get:{".":!0}}})}(this,t,0,e),this;var c,f=(o=this)._,l=n||{},h=f.root;l.at=f,l.ok=t;var p={};function d(n,t,e){if(!d.stun&&(!(o=h.pass)||o[c])){var o,i=n.$._,r=(n.$$||"")._,a=(r||i).put,s=!i.has&&!i.soul,u={};if(!s&&v!==a||(a=v===((o=n.put)||"")["="]?v===(o||"")[":"]?o:o[":"]:o["="]),"string"==typeof(o=g.valid(a))&&(a=v===(o=h.$.get(o)._.put)?l.not?v:a:o),!l.not||v!==a){if(v===l.stun){if((o=h.stun)&&o.on&&(f.$.back(function(t){if(o.on(""+t.id,u={}),(u.run||0)<d.id)return u}),u.run||o.on(""+i.id,u={}),!u.run&&r&&o.on(""+r.id,u={}),d.id>u.run&&(u.stun&&!u.stun.end||(u.stun=o.on("stun"),u.stun=u.stun&&u.stun.last),u.stun&&!u.stun.end)))return void((u.stun.add||(u.stun.add={}))[c]=function(){d(n,t,1)});if(v===a&&(e=0),(o=h.hatch)&&!o.end&&v===l.hatch&&!e){if(p[i.$._.id])return;return p[i.$._.id]=1,void o.push(function(){d(n,t,1)})}p={}}if(h.pass){if(h.pass[c+i.id])return;h.pass[c+i.id]=1}l.on?l.ok.call(i.$,a,i.get,n,t||d):l.v2020?l.ok(n,t||d):(Object.keys(n).forEach(function(t){o[t]=n[t]},o={}),(n=o).put=a,l.ok.call(l.as,n,t||d))}}}return(((d.at=f).any||(f.any={}))[c=String.random(7)]=d).off=function(){d.stun=1,f.any&&delete f.any[c]},d.rid=r,d.id=l.run||++h.once,i=h.pass,(h.pass={})[c]=1,l.out=l.out||{get:{}},f.on("out",l.out),h.pass=i,o}if("number"==typeof t)return this.get(""+t,n,e);if("string"==typeof(i=s(t)))return this.get(i,n,e);(i=this.get.next)&&(o=i(this,t))}return o?n&&"function"==typeof n&&o.get(n,e):((o=this.chain())._.err={err:g.log("Invalid get request!",t)},n&&n.call(o,o._.err)),o};var v,a={},s=g.valid})(f,"./get"),f(function(t){var g=f("./root");function v(n,t){if(t){t=(t._||"").id||t;var e,o=n.root.stun||(n.root.stun={on:g.on}),i={};n.stun||(n.stun=o.on("stun",function(){})),(e=o.on(""+t))&&e.the.last.next(i),i.run>=n.run||o.on(""+t,function(t){if(n.stun.end)return this.off(),void this.to.next(t);t.run=t.run||n.run,t.stun=t.stun||n.stun})}}function s(n){if(n.err)s.end(n.stun,n.root);else if(!n.todo.length&&!n.end&&Object.empty(n.wait)){n.end=1;var t,e=n.$.back(-1)._,o=e.root,i=e.ask(function(t){o.on("ack",t),t.err&&g.log(t),++r>(n.acks||0)&&this.off(),n.ack&&n.ack(t,this)},n.opt),r=0,a=n.stun;(t=function(){a&&(s.end(a,o),setTimeout.each(Object.keys(a=a.add||""),function(t){(t=a[t])&&t()}))}).hatch=t,n.via._.on("out",{put:n.out=n.graph,opt:n.opt,"#":i,_:t})}}g.chain.put=function(t,n,p){var e=this,o=e._,i=o.root;(p=p||{}).root=o.root,p.run||(p.run=i.once),v(p,o.id),p.ack=p.ack||n,p.via=p.via||e,p.data=p.data||t,p.soul||(p.soul=o.soul||"string"==typeof n&&n);var d=p.state=p.state||g.state();return"function"==typeof t?t(function(t){p.data=t,e.put(void 0,void 0,p)}):p.soul?(p.$=i.$.get(p.soul),p.todo=[{it:p.data,ref:p.$}],p.turn=p.turn||r,p.ran=p.ran||s,function t(){var n,e,i,r,a,o=p.todo,s=o.pop(),u=s.it;s.ref&&s.ref._.id;if(v(p,s.ref),(r=s.todo)&&(u=u[e=r.pop()],r.length&&o.push(s)),e&&(o.path||(o.path=[])).push(e),!(n=k(u))&&!(a=g.is(u))){if(!Object.plain(u))return(p.ack||y).call(p,p.out={err:p.err=g.log("Invalid data: "+(u&&(r=u.constructor)&&r.name||typeof u)+" at "+(p.via.back(function(t){t.get&&r.push(t.get)},r=[])||r.join("."))+"."+(o.path||[]).join("."))}),void p.ran(p);for(var c=p.seen||(p.seen=[]),f=c.length;f--;)if(u===(r=c[f]).it){n=u=r.link;break}}if(e&&n)s.node=m(s.node,e,d,u);else{p.seen.push(i={it:u,link:{},todo:a?[]:Object.keys(u).sort().reverse(),path:(o.path||[]).slice(),up:s}),s.node=m(s.node,e,d,i.link),!a&&i.todo.length&&o.push(i);var l=p.seen.length;function h(t,n){var e=i.link["#"];n&&(n.off(),n.rid(t));var o=e||t.soul||(r=(t.$$||t.$)._||"").soul||r.link||((r=r.put||"")._||"")["#"]||r["#"]||((r=t.put||"")&&t.$$?r["#"]:(r["="]||r[":"]||"")["#"]);e||v(p,t.$),o||s.link["#"]?(o||(o=[],(t.$$||t.$).back(function(t){if(r=t.soul||t.link)return o.push(r);o.push(t.get)}),o=o.reverse().join("/")),i.link["#"]=o,a||(((p.graph||(p.graph={}))[o]=i.node||(i.node={_:{}}))._["#"]=o),delete p.wait[l],i.wait&&setTimeout.each(i.wait,function(t){t&&t()}),p.ran(p)):(s.wait||(s.wait=[])).push(function(){h(t,n)})}(p.wait||(p.wait={}))[l]="",r=(i.ref=a?u:e?s.ref.get(e):s.ref)._,(r=u&&(u._||"")["#"]||r.soul||r.link)?h({soul:r}):i.ref.get(h,{run:p.run,v2020:1,out:{get:{".":" "}}})}if(!o.length)return p.ran(p);p.turn(t)}()):function(n){var e,t=n.via._;n.via=n.via.back(function(t){if(t.soul||!t.get)return t.$;e=n.data,(n.data={})[t.get]=e}),n.via&&n.via._.soul||(n.via=t.root.$.get(((n.data||"")._||"")["#"]||t.$.back("opt.uuid")()));n.via.put(n.data,n.ack,n)}(p),e},s.end=function(t,n){t.end=y,t.the.to===t&&t===t.the.last&&delete n.stun,t.off()};var y=function(){},r=setTimeout.turn,k=g.valid,m=g.state.ify})(f,"./put"),f(function(t){var n=f("./root");f("./chain"),f("./back"),f("./put"),f("./get"),t.exports=n})(f,"./index"),f(function(t){var d=f("./index");d.chain.on=function(t,n,e,o){var i,r=this._;r.root;if("string"==typeof t)return n?(i=r.on(t,n,e||r,o),e&&e.$&&(e.subs||(e.subs=[])).push(i),this):r.on(t);var a=n;(a=!0===a?{change:!0}:a||{}).not=1,a.on=1;return this.get(t,a),this},d.chain.once=function(u,c){if(c=c||{},!u)return function(t,n,e){return d.log.once("valonce","Chainable val is experimental, its behavior and API may change moving forward. Please play with it and report bugs and ideas on how to improve it."),(e=t.chain())._.nix=t.once(function(t,n){e._.on("in",this._)}),e._.lex=t._.lex,e}(this);var f,l=this._,h=l.root,p=(l.put,String.random(7));return this.get(function(t,n,e,o){var i=this,r=i._,a=r.one||(r.one={});function s(){r.has||r.soul||(r={put:t,get:n}),void 0===(f=r.put)&&(f=((e.$$||"")._||"").put),"string"==typeof d.valid(f)&&void 0===(f=h.$.get(f)._.put)||o.stun||""!==a[p]&&(a[p]="",(l.soul||l.has)&&o.off(),u.call(i,f,r.get))}o.stun||""!==a[p]&&(!0!==(f=d.valid(t))?"string"!=typeof f&&(clearTimeout(a[p]),a[p]=setTimeout(s,c.wait||99)):s())},{on:1}),this},d.chain.off=function(){var e,t=this._,o=t.back;if(o)return t.ack=0,(e=o.next)&&e[t.get]&&delete e[t.get],(e=o.ask)&&delete e[t.get],(e=o.put)&&delete e[t.get],(e=t.soul)&&delete o.root.graph[e],(e=t.map)&&Object.keys(e).forEach(function(t,n){(n=e[t]).link&&o.root.$.get(n.link).off()}),(e=t.next)&&Object.keys(e).forEach(function(t,n){e[t].$.off()}),t.on("off",{}),this}})(f,"./on"),f(function(t){var u=f("./index"),o=u.chain.get.next;function r(t){this.to.next(t);var n,e=this.as,o=t.$._,i=t.put;(o.soul||t.$$)&&((n=e.lex)&&!String.match(t.get||(i||"")["."],n["."]||n["#"]||n)||u.on.link(t,e))}u.chain.get.next=function(t,n){var e;return Object.plain(n)?(e=((e=n["#"])||"")["="]||e)?t.get(e):((e=t.chain()._).lex=n,t.on("in",function(t){String.match(t.get||(t.put||"")["."],n["."]||n["#"]||n)&&e.on("in",t),this.to.next(t)}),e.$):(o||c)(t,n)},u.chain.map=function(a,t,n){var e,s,o=this,i=o._;return Object.plain(a)&&(e=a["."]?a:{".":a},a=void 0),a?(u.log.once("mapfn","Map functions are experimental, their behavior and API may change moving forward. Please play with it and report bugs and ideas on how to improve it."),s=o.chain(),o.map().on(function(t,n,e,o){var i=(a||c).call(this,t,n,e,o);if(void 0!==i){if(t===i)return s._.on("in",e);if(u.is(i))return s._.on("in",i._);var r={};Object.keys(e.put).forEach(function(t){r[t]=e.put[t]},r),r["="]=i,s._.on("in",{get:n,put:r})}})):(s=i.each)||((i.each=s=o.chain())._.lex=e||s._.lex||i.lex,s._.nix=o.back("nix"),o.on("in",r,s._)),s};var c=function(){}})(f,"./map"),f(function(t){var s=f("./index");s.chain.set=function(t,i,n){var e,r,a=this,o=a.back(-1);return i=i||function(){},(n=n||{}).item=n.item||t,(e=((t||"")._||"")["#"])&&((t={})["#"]=e),"string"==typeof(r=s.valid(t))?a.get(e=r).put(t,i,n):s.is(t)?(a.put(function(o){t.get(function(t,n,e){if(!t)return i.call(a,{err:s.log('Only a node can be linked! Not "'+e.put+'"!')});(r={})[t]={"#":t},o(r)},!0)}),t):(Object.plain(t)&&(t=o.get(e=a.back("opt.uuid")()).put(t)),a.get(e||o.back("opt.uuid")(7)).put(t,i,n))}})(f,"./set"),f(function(t){f("./shim");var j;try{t.exports=function(u){var g=function(){},v=u.opt||{};v.log=v.log||console.log,v.gap=v.gap||v.wait||0,v.max=v.max||.3*(v.memory?999*v.memory*999:3e8),v.pack=v.pack||.01*v.max*.01,v.puff=v.puff||9;var y=setTimeout.turn||setTimeout,i=JSON.parseAsync||function(t,n,e){try{n(void 0,JSON.parse(t,e))}catch(t){n(t)}},k=JSON.stringifyAsync||function(t,n,e,o){try{n(void 0,JSON.stringify(t,e,o))}catch(t){n(t)}},m=u.dup,b=m.check,_=m.track,s=(new Date,g.hear=function(t,a){if(t){if(v.max<=t.length)return g.say({dam:"!",err:"Message too big!"},a);g===this&&(s.d+=t.length||0,++s.c);var n,e=a.SH=+new Date,o=t[0];return"["===o?(i(t,function(t,i){if(t||!i)return g.say({dam:"!",err:"DAM JSON parse error."},a);console.STAT&&console.STAT(+new Date,i.length,"# on hear batch");var r=v.puff;!function t(){for(var n,e=+new Date,o=0;o<r&&(n=i[o++]);)s(n,a);i=i.slice(o),console.STAT&&console.STAT(e,+new Date-e,"hear loop"),$(a),i.length&&y(t,0)}()}),void(t="")):"{"===o||(t["#"]||Object.plain(t))&&(n=t)?n?s.one(n,a,e):void i(t,function(t,n){if(t||!n)return g.say({dam:"!",err:"DAM JSON parse error."},a);s.one(n,a,e)}):void 0}});function $(t){var n=t.batch,e="string"==typeof n;if(e&&(n+="]"),t.batch=t.tail=null,n&&(e?!(n.length<3):n.length)){if(!e)try{n=1===n.length?n[0]:JSON.stringify(n)}catch(t){return v.log("DAM JSON stringify error",t)}n&&w(n,t)}}function w(n,e){try{var t=e.wire;e.say?e.say(n):t.send&&t.send(n),g.say.d+=n.length||0,++g.say.c}catch(t){(e.queue=e.queue||[]).push(n)}}s.one=function(t,n,e){var o,i,r,a,s;if(t.DBG&&(t.DBG=s={DBG:t.DBG}),s&&(s.h=e),s&&(s.hp=+new Date),(o=t["#"])||(o=t["#"]=String.random(9)),!((r=b(o))||(i=t["##"])&&(r=t["@"]||t.get&&o)&&m.check(a=r+i))){if((t._=function(){}).via=g.leap=n,(r=t["><"])&&"string"==typeof r&&r.slice(0,99).split(",").forEach(function(t){this[t]=1},t._.yo={}),r=t.dam)return(r=g.hear[r])&&r(t,n,u),void _(o);e=+new Date;s&&(s.is=e),n.SI=o,u.on("in",g.last=t),s&&(s.hd=+new Date),console.STAT&&console.STAT(e,+new Date-e,t.get?"msg get":t.put?"msg put":"msg"),(r=_(o)).via=n,t.get&&(r.it=t),a&&_(a),g.leap=g.last=null}},s.c=s.d=0,function(){var h,p=0;function t(t,n){var e;return n instanceof Object?(Object.keys(n).sort().forEach(o,{to:e={},on:n}),e):n}function o(t){this.to[t]=this.on[t]}g.hash=function(i,r){var a,s,u,c=+new Date;k(i.put,function t(n,e){var o=(s=s||(u=e||"")).slice(0,32768);a=String.hash(o,a),(s=s.slice(32768))?y(t,0):(console.STAT&&console.STAT(c,+new Date-c,"say json+hash"),i._.$put=u,i["##"]=a,d(i,r),delete i._.$put)},t)};var d=g.say=function(r,t){var n;if((n=this)&&(n=n.to)&&n.next&&n.next(r),!r)return!1;var e,a,s=r["@"],u=r._||(r._=function(){}),o=r.DBG,i=+new Date;if(u.y=u.y||i,t||o&&(o.y=i),(e=r["#"])||(e=r["#"]=String.random(9)),h||_(e),r.put&&(r.err||(m.s[e]||"").err))return!1;if(r["##"]||j===r.put||u.via||!s){if(!t&&s&&(t=(n=m.s[s])&&(n.via||(n=n.it)&&(n=n._)&&n.via)||(n=g.last)&&s===n["#"]&&g.leap),!t&&s){if(m.s[s])return;return console.STAT&&console.STAT(+new Date,++p,"total no peer to ack to"),!1}if(!t&&g.way)return g.way(r);if(o&&(o.yh=+new Date),a=u.raw){if(o&&(o.yr=+new Date),!t||!t.id){if(!Object.plain(t||v.peers))return!1;i=+new Date,v.puff;var c=v.peers,f=Object.keys(t||v.peers||{});return console.STAT&&console.STAT(i,+new Date-i,"peer keys"),void function t(){var n=+new Date;h=1;var e=u.raw;u.raw=a;for(var o,i=0;i<9&&(o=(f||"")[i++]);)(o=c[o])&&d(r,o);u.raw=e,h=0,f=f.slice(i),console.STAT&&console.STAT(n,+new Date-n,"say loop"),f.length&&(y(t,0),s&&_(s))}()}if(!t.wire&&g.wire&&g.wire(t),e!==t.last){if(t.last=e,t===u.via)return!1;if((n=u.yo)&&(n[t.url]||n[t.pid]||n[t.id]))return!1;if(console.STAT&&console.STAT(i,((o||u).yp=+new Date)-(u.y||i),"say prep"),!h&&s&&_(s),t.batch){if(t.tail=(n=t.tail||0)+a.length,t.tail<=v.pack)return void(t.batch+=(n?",":"")+a);$(t)}t.batch="[";var l=+new Date;setTimeout(function(){console.STAT&&console.STAT(l,+new Date-l,"0ms TO"),$(t)},v.gap),w(a,t),console.STAT&&s===t.SI&&console.STAT(i,+new Date-t.SH,"say ack")}}else g.raw(r,t)}else g.hash(r,t)};g.say.c=g.say.d=0,g.raw=function(e,o){if(!e)return"";var i,r,a=e._||{};if(r=a.raw)return r;if("string"==typeof e)return e;var t=e["##"],n=e["@"];if(t&&n){if(!a.via&&b(n+t))return!1;if((r=(m.s[n]||"").it)||(r=g.last)&&n===r["#"]){if(t===r["##"])return!1;r["##"]||(r["##"]=t)}}if(!e.dam){var s=0,u=[];for(var c in r=v.peers){var f=r[c];if(u.push(f.url||f.pid||f.id),6<++s)break}1<s&&(e["><"]=u.join())}if(i=a.$put)return r={},Object.keys(e).forEach(function(t){r[t]=e[t]}),r.put=":])([:",void k(r,function(t,n){if(!t){var e=+new Date;r=n.indexOf('"put":":])([:"'),l(j,n=n.slice(0,r+6)+i+n.slice(r+14)),console.STAT&&console.STAT(e,+new Date-e,"say slice")}});function l(t,n){t||(a.raw=n,d(e,o))}k(e,l)}}(),g.hi=function(n){var t=n.wire||{};n.id?v.peers[n.url||n.id]=n:(t=n.id=n.id||String.random(9),g.say({dam:"?",pid:u.opt.pid},v.peers[t]=n),delete m.s[n.last]),n.met=n.met||+new Date,t.hied||u.on(t.hied="hi",n),t=n.queue,n.queue=[],setTimeout.each(t||[],function(t){w(t,n)},0,9)},g.bye=function(t){u.on("bye",t);var n=+new Date;n-=t.met||n,g.bye.time=((g.bye.time||n)+n)/2},g.hear["!"]=function(t,n){v.log("Error:",t.err)},g.hear["?"]=function(t,n){t.pid&&(n.pid||(n.pid=t.pid),t["@"])||(g.say({dam:"?",pid:v.pid,"@":t["#"]},n),delete m.s[n.last])},u.on("create",function(t){t.opt.pid=t.opt.pid||String.random(9),this.to.next(t),t.on("out",g.say)}),u.on("bye",function(t,n){t=v.peers[t.id||t]||t,this.to.next(t),t.bye?t.bye():(n=t.wire)&&n.close&&n.close(),delete v.peers[t.id],t.wire=null});var o={};return u.on("bye",function(t,n){this.to.next(t),(n=console.STAT)&&(n.peers=(n.peers||0)-1),(n=t.url)&&(o[n]=!0,setTimeout(function(){delete o[n]},v.lack||9e3))}),u.on("hi",function(n,e){this.to.next(n),(e=console.STAT)&&(e.peers=(e.peers||0)+1),(e=n.url)&&o[e]&&(delete o[e],v.super||setTimeout.each(Object.keys(u.next),function(t){u.next[t];(e={})[t]=u.graph[t],e=String.hash(e),g.say({"##":e,get:{"#":t}},n)}))}),g}}catch(t){}})(f,"./mesh"),f(function(t){var c=f("../index");c.Mesh=f("./mesh"),c.on("opt",function(t){if(this.to.next(t),!t.once){var o=t.opt;if(!1!==o.WebSocket){var n=c.window||{},e=o.WebSocket||n.WebSocket||n.webkitWebSocket||n.mozWebSocket;if(e){o.WebSocket=e;var i=o.mesh=o.mesh||c.Mesh(t);i.wire||o.wire;i.wire=o.wire=s,setTimeout(function(){o.super||t.on("out",{dam:"hi"})},1);var r=1998,a=""+void 0!=typeof document&&document}}}function s(n){try{if(!n||!n.url)return e&&e(n);var t=n.url.replace(/^http/,"ws"),e=n.wire=new o.WebSocket(t);return e.onclose=function(){o.mesh.bye(n),u(n)},e.onerror=function(t){u(n)},e.onopen=function(){o.mesh.hi(n)},e.onmessage=function(t){t&&o.mesh.hear(t.data||t,n)},e}catch(t){}}function u(n){clearTimeout(n.defer),a&&n.retry<=0||(n.retry=(n.retry||o.retry+1||60)-(-n.tried+(n.tried=+new Date)<4*r?1:0),n.defer=setTimeout(function t(){if(a&&a.hidden)return setTimeout(t,r);s(n)},r))}})})(f,"./websocket"),f(function(t){if("undefined"!=typeof Gun){var o;try{o=(Gun.window||function(){}).localStorage}catch(t){}o||(Gun.log("Warning: No localStorage exists to persist data to!"),o={setItem:function(t,n){this[t]=n},removeItem:function(t){delete this[t]},getItem:function(t){return this[t]}}),Gun.on("create",function n(e){this.to.next(e);var r,i,a=e.opt,s=(e.graph,[]);if(!1!==a.localStorage){a.prefix=a.file||"gun/";try{r=n[a.prefix]=n[a.prefix]||JSON.parse(o.getItem(a.prefix))||{}}catch(t){r=n[a.prefix]={}}e.on("get",function(t){this.to.next(t);var n,e,o,i=t.get;i&&(n=i["#"])&&((e=r[n]||void 0)&&(o=i["."])&&!Object.plain(o)&&(e=Gun.state.ify({},o,Gun.state.is(e,o),e[o],n)),Gun.on.get.ack(t,e))}),e.on("put",function(t){this.to.next(t);var n=t.put,e=n["#"],o=n["."];r[e]=Gun.state.ify(r[e],o,n[">"],n[":"],e),t["@"]||s.push(t["#"]),i=i||setTimeout(u,a.wait||1)})}function u(){var n,t=s;clearTimeout(i),i=!1,s=[];try{o.setItem(a.prefix,JSON.stringify(r))}catch(t){Gun.log((n=t||"localStorage failure")+" Consider using GUN's IndexedDB plugin for RAD for more storage space, https://gun.eco/docs/RAD#install"),e.on("localStorage:error",{err:n,get:a.prefix,put:r})}(n||Object.empty(a.peers))&&setTimeout.each(t,function(t){e.on("in",{"@":t,err:n,ok:0})})}})}})(f,"./localStorage")}(),function(){if(""+_!=typeof Gun){function l(t){console.log("Warning! Deprecated internal utility will break in next version:",t)}var n,h,p=Gun;p.fn=p.fn||{is:function(t){return l("fn"),!!t&&"function"==typeof t}},p.bi=p.bi||{is:function(t){return l("bi"),t instanceof Boolean||"boolean"==typeof t}},p.num=p.num||{is:function(t){return l("num"),!d(t)&&(0<=t-parseFloat(t)+1||1/0===t||-1/0===t)}},p.text=p.text||{is:function(t){return l("text"),"string"==typeof t}},p.text.ify=p.text.ify||function(t){return l("text.ify"),p.text.is(t)?t:"undefined"!=typeof JSON?JSON.stringify(t):t&&t.toString?t.toString():t},p.text.random=p.text.random||function(t,n){l("text.random");var e="";for(t=t||24,n=n||"0123456789ABCDEFGHIJKLMNOPQRSTUVWXZabcdefghijklmnopqrstuvwxyz";0<t;)e+=n.charAt(Math.floor(Math.random()*n.length)),t--;return e},p.text.match=p.text.match||function(t,n){var e,o;return l("text.match"),"string"==typeof t&&("string"==typeof n&&(n={"=":n}),t===(e=(n=n||{})["="]||n["*"]||n[">"]||n["<"])||o===n["="]&&(e=n["*"]||n[">"]||n["<"],t.slice(0,(e||"").length)===e||o===n["*"]&&(o!==n[">"]&&o!==n["<"]?t>=n[">"]&&t<=n["<"]:o!==n[">"]&&t>=n[">"]||o!==n["<"]&&t<=n["<"])))},p.text.hash=p.text.hash||function(t,n){if(l("text.hash"),"string"==typeof t){if(n=n||0,!t.length)return n;for(var e=0,o=t.length;e<o;++e)n=(n<<5)-n+t.charCodeAt(e),n|=0;return n}},p.list=p.list||{is:function(t){return l("list"),t instanceof Array}},p.list.slit=p.list.slit||Array.prototype.slice,p.list.sort=p.list.sort||function(e){return l("list.sort"),function(t,n){return t&&n?(t=t[e])<(n=n[e])?-1:n<t?1:0:0}},p.list.map=p.list.map||function(t,n,e){return l("list.map"),s(t,n,e)},p.list.index=1,p.obj=p.boj||{is:function(t){return l("obj"),!!t&&(t instanceof Object&&t.constructor===Object||"Object"===Object.prototype.toString.call(t).match(/^\[object (\w+)\]$/)[1])}},p.obj.put=p.obj.put||function(t,n,e){return l("obj.put"),(t||{})[n]=e,t},p.obj.has=p.obj.has||function(t,n){return l("obj.has"),t&&Object.prototype.hasOwnProperty.call(t,n)},p.obj.del=p.obj.del||function(t,n){if(l("obj.del"),t)return t[n]=null,delete t[n],t},p.obj.as=p.obj.as||function(t,n,e,o){return l("obj.as"),t[n]=t[n]||(o===e?{}:e)},p.obj.ify=p.obj.ify||function(n){if(l("obj.ify"),g(n))return n;try{n=JSON.parse(n)}catch(t){n={}}return n},p.obj.to=p.obj.to||function(t,n){return l("obj.to"),s(t,x,n=n||{}),n},p.obj.copy=p.obj.copy||function(t){return l("obj.copy"),t?JSON.parse(JSON.stringify(t)):t},p.obj.empty=p.obj.empty||function(t,n){return l("obj.empty"),!t||!s(t,S,{n:n})},h=Object.keys,Object.keys=Object.keys||function(t){return n(t,function(t,n,e){e(n)})},p.obj.map=n=p.obj.map||function(t,n,e){l("obj.map");var o,i,r,a,s,u=0,c="function"==typeof n;if(O.r=o,h&&g(t)&&(a=h(t),s=!0),e=e||{},d(t)||a)for(i=(a||t).length;u<i;u++){var f=u+p.list.index;if(c){if((r=s?n.call(e,t[a[u]],a[u],O):n.call(e,t[u],f,O))!==o)return r}else if(n===t[s?a[u]:u])return a?a[u]:f}else for(u in t)if(c){if(v(t,u)&&(r=e?n.call(e,t[u],u,O):n(t[u],u,O))!==o)return r}else if(n===t[u])return u;return c?O.r:p.list.index?0:-1},p.time=p.time||{},p.time.is=p.time.is||function(t){return l("time"),t?t instanceof Date:+(new Date).getTime()};var e=p.fn.is,d=p.list.is,g=(t=p.obj).is,v=t.has,s=t.map,u={is:function(t){return l("val.is"),t!==_&&(null===t||t!==1/0&&(!!(r(t)||i(t)||c(t))||(u.link.is(t)||!1)))}};u.link=u.rel={_:"#"},u.link.is=function(t){if(l("val.link.is"),t&&t[o]&&!t._&&g(t)){var n={};if(s(t,D,n),n.id)return n.id}return!1},u.link.ify=function(t){return l("val.link.ify"),a({},o,t)},p.obj.has._=".";var o=u.link._,i=p.bi.is,c=p.num.is,r=p.text.is,a=(g=(t=p.obj).is,t.put);s=t.map;p.val=p.val||u;var f={_:"_",soul:function(t,n){return l("node.soul"),t&&t._&&t._[n||m]}};f.soul.ify=function(t,n){return l("node.soul.ify"),n="string"==typeof n?{soul:n}:n||{},(t=t||{})._=t._||{},t._[m]=n.soul||t._[m]||k(),t},f.soul._=u.link._,f.is=function(t,n,e){var o;return l("node.is"),!!g(t)&&!!(o=f.soul(t))&&!s(t,A,{as:e,cb:n,s:o,n:t})},f.ify=function(t,n,e){return l("node.ify"),n?"string"==typeof n?n={soul:n}:"function"==typeof n&&(n={map:n}):n={},n.map&&(n.node=n.map.call(e,t,_,n.node||{})),(n.node=f.soul.ify(n.node||{},n))&&s(t,G,{o:n,as:e}),n.node};g=(t=p.obj).is;var y=t.del,k=(s=t.map,p.text.random),m=f.soul._;p.node=p.node||f;var b=p.state;b.lex=function(){return l("state.lex"),b().toString(36).replace(".","")},b.to=function(t,n,e){l("state.to");var o=(t||{})[n];return g(o)&&(o=$(o)),b.ify(e,n,b.is(t,n),o,f.soul(t))},b.map=function(i,r,a){l("state.map");var t=g(t=i||r)?t:null;return i=e(i=i||r)?i:null,t&&!i?(r=c(r)?r:b(),t[w]=t[w]||{},s(t,N,{o:t,s:r}),t):(a=a||g(r)?r:void 0,r=c(r)?r:b(),function(t,n,e,o){if(!i)return N.call({o:e,s:r},t,n),t;i.call(a||this||{},t,n,e,o),v(e,n)&&void 0===e[n]||N.call({o:e,s:r},t,n)})};(t=p.obj).as,v=t.has,g=t.is,s=t.map;var t,_,$=t.copy,w=(c=p.num.is,e=p.fn.is,f._),j={is:function(t,n,e,o){return l("graph.is"),!(!t||!g(t)||T(t)||s(t,E,{cb:n,fn:e,as:o}))},ify:function(t,n,e){l("graph.ify");var o={path:[],obj:t};return n?"string"==typeof n?n={soul:n}:"function"==typeof n&&(n.map=n):n={},"string"==typeof e&&(n.soul=n.soul||e,e=_),n.soul&&(o.link=u.link.ify(n.soul)),n.shell=(e||{}).shell,n.graph=n.graph||{},n.seen=n.seen||[],n.as=n.as||e,B(n,o),n.root=o.node,n.graph},node:function(t){l("graph.node");var n=f.soul(t);if(n)return a({},n,t)},to:function(t,n,e){if(l("graph.to"),t){var o={};return e=e||{seen:{}},s(t[n],P,{obj:o,graph:t,opt:e}),o}}},T=(e=p.fn.is,g=(t=p.obj).is,y=t.del,v=t.has,t.empty);a=t.put,s=t.map,$=t.copy;p.graph=p.graph||j}function x(t,n){v(this,n)&&void 0!==this[n]||(this[n]=t)}function S(t,n){var e=this.n;if(!e||!(n===e||g(e)&&v(e,n)))return void 0!==n||void 0}function O(t,n){2!==arguments.length?(O.r=O.r||[]).push(t):(O.r=O.r||{})[t]=n}function D(t,n){return this.id?this.id=!1:n==o&&r(t)?void(this.id=t):this.id=!1}function A(t,n){if(n!==f._)return!u.is(t)||void(this.cb&&this.cb.call(this.as,t,n,this.n,this.s))}function G(t,n){var e,o=this.o;o.map?void 0===(e=o.map.call(this.as,t,""+n,o.node))?y(o.node,n):o.node&&(o.node[n]=e):u.is(t)&&(o.node[n]=t)}function N(t,n){w!==n&&b.ify(this.o,n,this.s)}function E(t,n){if(!t||n!==f.soul(t)||!f.is(t,this.fn,this.as))return!0;this.cb&&(I.n=t,I.as=this.as,this.cb.call(I.as,t,n,I))}function I(t){t&&f.is(I.n,t,I.as)}function B(t,n){var e;return(e=function(t,n){var e,o=t.seen,i=o.length;for(;i--;)if(e=o[i],n.obj===e.obj)return e;o.push(n)}(t,n))?e:(n.env=t,n.soul=M,f.ify(n.obj,J,n)&&(n.link=n.link||u.link.ify(f.soul(n.node)),n.obj!==t.shell&&(t.graph[u.link.is(n.link)]=n.node)),n)}function J(t,n,e){var o,i,r=this,a=r.env;if(f._===n&&v(t,u.link._))return e._;if(o=W(t,n,e,r,a)){if(n||(r.node=r.node||e||{},v(t,f._)&&f.soul(t)&&(r.node._=$(t._)),r.node=f.soul.ify(r.node,u.link.is(r.link)),r.link=r.link||u.link.ify(f.soul(r.node))),(i=a.map)&&(i.call(a.as||{},t,n,e,r),v(e,n))){if(t=e[n],_===t)return void y(e,n);if(!(o=W(t,n,e,r,a)))return}if(!n)return r.node;if(!0===o)return t;if((i=B(a,{obj:t,path:r.path.concat(n)})).node)return i.link}}function M(t){var n=this,e=u.link.is(n.link),o=n.env.graph;n.link=n.link||u.link.ify(t),n.link[u.link._]=t,n.node&&n.node[f._]&&(n.node[f._][u.link._]=t),v(o,e)&&(o[t]=o[e],y(o,e))}function W(t,n,e,o,i){var r;return!!u.is(t)||(g(t)?1:(r=i.invalid)?W(t=r.call(i.as||{},t,n,e),n,e,o,i):(i.err="Invalid value at '"+o.path.concat(n).join(".")+"'!",void(p.list.is(t)&&(i.err+=" Use `.set(item)` instead of an Array."))))}function P(t,n){var e,o;if(f._!==n)(e=u.link.is(t))?(o=this.opt.seen[e])?this.obj[n]=o:this.obj[n]=this.opt.seen[e]=j.to(this.graph,e,this.opt):this.obj[n]=t;else{if(T(t,u.link._))return;this.obj[n]=$(t)}}}();