holosphere
Version:
Holonic Geospatial Communication Infrastructure
2 lines • 507 kB
JavaScript
/* HoloSphere Bundle v1.1.21 - Holonic Geospatial Communication Infrastructure */
var HoloSphere=(()=>{var b1=Object.create;var co=Object.defineProperty;var E1=Object.getOwnPropertyDescriptor;var $1=Object.getOwnPropertyNames;var P1=Object.getPrototypeOf,k1=Object.prototype.hasOwnProperty;var ac=(n=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(n,{get:(e,i)=>(typeof require<"u"?require:e)[i]}):n)(function(n){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});var ge=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),C1=(n,e)=>{for(var i in e)co(n,i,{get:e[i],enumerable:!0})},lc=(n,e,i,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let f of $1(e))!k1.call(n,f)&&f!==i&&co(n,f,{get:()=>e[f],enumerable:!(o=E1(e,f))||o.enumerable});return n};var o0=(n,e,i)=>(i=n!=null?b1(P1(n)):{},lc(e||!n||!n.__esModule?co(i,"default",{value:n,enumerable:!0}):i,n)),S1=n=>lc(co({},"__esModule",{value:!0}),n);var dd=ge((tS,X0)=>{(function(){function n(i,o){return o?ac(i):i.slice?n[f(i)]:function(h,m){i(h={exports:{}}),n[f(m)]=h.exports};function f(h){return h.split("/").slice(-1).toString().replace(".js","")}}if(typeof X0<"u")var e=X0;n(function(i){String.random=function(f,h){var m="";for(f=f||24,h=h||"0123456789ABCDEFGHIJKLMNOPQRSTUVWXZabcdefghijklmnopqrstuvwxyz";f-- >0;)m+=h.charAt(Math.floor(Math.random()*h.length));return m},String.match=function(f,h){var m,y;return typeof f!="string"?!1:(typeof h=="string"&&(h={"=":h}),h=h||{},m=h["="]||h["*"]||h[">"]||h["<"],f===m?!0:y!==h["="]?!1:(m=h["*"]||h[">"],f.slice(0,(m||"").length)===m?!0:y!==h["*"]?!1:y!==h[">"]&&y!==h["<"]?f>=h[">"]&&f<=h["<"]:y!==h[">"]&&f>=h[">"]||y!==h["<"]&&f<=h["<"]))},String.hash=function(f,h){if(typeof f=="string"){if(h=h||0,!f.length)return h;for(var m=0,y=f.length,E;m<y;++m)E=f.charCodeAt(m),h=(h<<5)-h+E,h|=0;return h}};var o=Object.prototype.hasOwnProperty;Object.plain=function(f){return f?f instanceof Object&&f.constructor===Object||Object.prototype.toString.call(f).match(/^\[object (\w+)\]$/)[1]==="Object":!1},Object.empty=function(f,h){for(var m in f)if(o.call(f,m)&&(!h||h.indexOf(m)==-1))return!1;return!0},Object.keys=Object.keys||function(f){var h=[];for(var m in f)o.call(f,m)&&h.push(m);return h},(function(){var f,h=setTimeout,m=0,y=0,E=typeof setImmediate!=""+f&&setImmediate||(function(_,v){return typeof MessageChannel==""+f?h:((_=new MessageChannel).port1.onmessage=function(P){P.data==""&&v()},function(P){v=P,_.port2.postMessage("")})})(),b=h.check=h.check||typeof performance!=""+f&&performance||{now:function(){return+new Date}};h.hold=h.hold||9,h.poll=h.poll||function(_){if(h.hold>=b.now()-m&&y++<3333){_();return}E(function(){m=b.now(),_()},y=0)}})(),(function(){var f=setTimeout,h=f.turn=f.turn||function(v){m.push(v)==1&&y(_)},m=h.s=[],y=f.poll,E=0,b,_=function(){(b=m[E++])&&b(),(E==m.length||E==99)&&(m=h.s=m.slice(E),E=0),m.length&&y(_)}})(),(function(){var f,h=setTimeout,m=h.turn;(h.each=h.each||function(y,E,b,_){_=_||9,(function v(P,S,R){if(S=(P=(y||[]).splice(0,_)).length){for(var $=0;$<S&&f===(R=E(P[$]));$++);if(f===R){m(v);return}}b&&b(R)})()})()})()})(n,"./shim"),n(function(i){i.exports=function o(b,h,m){if(!b)return{to:o};var y,E=typeof h=="function",b=(this.tag||(this.tag={}))[b]||E&&(this.tag[b]={tag:b,to:o._={next:function(v){var P;(P=this.to)&&P.next(v)}}});if(E){var _={off:o.off||(o.off=function(){if(this.next===o._.next)return!0;this===this.the.last&&(this.the.last=this.back),this.to.back=this.back,this.next=o._.next,this.back.to=this.to,this.the.last===this.the&&delete this.on.tag[this.the.tag]}),to:o._,next:h,the:b,on:this,as:m};return(_.back=b.last||b).to=_,b.last=_}return(b=b.to)&&y!==h&&b.next(h),b}})(n,"./onto"),n(function(i){i.exports=function(o){return o===null||typeof o=="string"||typeof o=="boolean"||typeof o=="number"&&o!=1/0&&o!=-1/0&&o===o||!!o&&typeof o["#"]=="string"&&Object.keys(o).length===1&&o["#"]}})(n,"./valid"),n(function(i){n("./shim");function o(){var b=+new Date;return y<b?(h=0,y=b+o.drift):y=b+(h+=1)/m+o.drift}o.drift=0;var f=-1/0,h=0,m=999,y=f,E;o.is=function(b,_,v){var P=_&&b&&b._&&b._[">"]||v;if(P)return typeof(P=P[_])=="number"?P:f},o.ify=function(b,_,v,P,S){(b=b||{})._=b._||{},S&&(b._["#"]=S);var R=b._[">"]||(b._[">"]={});return E!==_&&_!=="_"&&(typeof v=="number"&&(R[_]=v),E!==P&&(b[_]=P)),b},i.exports=o})(n,"./state"),n(function(i){n("./shim");function o(f){var h={s:{}},m=h.s;f=f||{max:999,age:1e3*9},h.check=function(E){return m[E]?y(E):!1};var y=h.track=function(E){var b=m[E]||(m[E]={});return b.was=h.now=+new Date,h.to||(h.to=setTimeout(h.drop,f.age+9)),y.ed&&y.ed(E),b};return h.drop=function(E){h.to=null,h.now=+new Date;var b=Object.keys(m);console.STAT&&console.STAT(h.now,+new Date-h.now,"dup drop keys"),setTimeout.each(b,function(_){var v=m[_];v&&(E||f.age)>h.now-v.was||delete m[_]},0,99)},h}i.exports=o})(n,"./dup"),n(function(i){n("./onto"),i.exports=function(h,m){if(this.on){var y=(this.opt||{}).lack||9e3;if(typeof h!="function"){if(!h)return;var b=h["#"]||h,E=(this.tag||"")[b];return E?(m&&(E=this.on(b,m),clearTimeout(E.err),E.err=setTimeout(function(){E.off()},y)),!0):void 0}var b=m&&m["#"]||o(9);if(!h)return b;var _=this.on(b,h,m);return _.err=_.err||setTimeout(function(){_.off(),_.next({err:"Error: No ACK yet.",lack:!0})},y),b}};var o=String.random||function(){return Math.random().toString(36).slice(2)}})(n,"./ask"),n(function(i){function o(S){return S instanceof o?(this._={$:this}).$:this instanceof o?o.create(this._={$:this,opt:S}):new o(S)}o.is=function(S){return S instanceof o||S&&S._&&S===S._.$||!1},o.version=.202,o.chain=o.prototype,o.chain.toJSON=function(){},n("./shim"),o.valid=n("./valid"),o.state=n("./state"),o.on=n("./onto"),o.dup=n("./dup"),o.ask=n("./ask"),(function(){o.create=function(O){O.root=O.root||O,O.graph=O.graph||{},O.on=O.on||o.on,O.ask=O.ask||o.ask,O.dup=O.dup||o.dup();var M=O.$.opt(O.opt);return O.once||(O.on("in",S,O),O.on("out",S,O),O.on("put",B,O),o.on("create",O),O.on("create",O)),O.once=1,M};function S(O){if(O){if(O.out===S){this.to.next(O);return}var M=this,Q=M.as,X=Q.at||Q,ne=X.$,Ae=X.dup,te,pe=O.DBG;if((te=O["#"])||(te=O["#"]=h(9)),!Ae.check(te)){if(Ae.track(te),te=O._,O._=typeof te=="function"?te:function(){},O.$&&O.$===(O.$._||"").$||(O.$=ne),O["@"]&&!O.put&&I(O),!X.ask(O["@"],O))if(pe&&(pe.u=+new Date),O.put){R(O);return}else O.get&&o.on.get(O,ne);pe&&(pe.uc=+new Date),M.to.next(O),pe&&(pe.ua=+new Date),!(O.nts||O.NTS)&&(O.out=S,X.on("out",O),pe&&(pe.ue=+new Date))}}}function R(O){if(O){var M=O._||"",Q=M.root=((M.$=O.$||"")._||"").root;if(O["@"]&&M.faith&&!M.miss){O.out=S,Q.on("out",O);return}M.latch=Q.hatch,M.match=Q.hatch=[];var X=O.put,ne=M.DBG=O.DBG,Ae=+new Date;if(ue=ue||Ae,!(X["#"]&&X["."])){ne&&(ne.p=Ae),M["#"]=O["#"],M.msg=O,M.all=0,M.stun=1;var te=Object.keys(X);console.STAT&&console.STAT(Ae,((ne||M).pk=+new Date)-Ae,"put sort");var pe=0,me,ve,Re,At,Ke,ze,gt;(function WA(CA){if(me!=pe){if(me=pe,!(Re=te[pe])){console.STAT&&console.STAT(Ae,((ne||M).pd=+new Date)-Ae,"put"),T(M);return}(At=X[Re])?(gt=At._)?Re!==gt["#"]?ze=U+V(Re)+"soul not same.":(Ke=gt[">"])||(ze=U+V(Re)+"no state."):ze=U+V(Re)+"no meta.":ze=U+V(Re)+"no node.",ve=Object.keys(At||{})}if(ze){O.err=M.err=ze,T(M);return}var uA=0,fA;for(CA=CA||0;CA++<9&&(fA=ve[uA++]);)if(fA!=="_"){var SA=At[fA],xA=Ke[fA];if(_===xA){ze=U+V(fA)+"on"+V(Re)+"no state.";break}if(!y(SA)){ze=U+V(fA)+"on"+V(Re)+"bad "+typeof SA+V(SA);break}$(SA,fA,Re,xA,O),++J}if((ve=ve.slice(uA)).length){m(WA);return}++pe,ve=null,WA(CA)})()}}}o.on.put=R;function $(O,M,Q,X,ne){var Ae=ne._||"",te=Ae.root,pe=te.graph,me,ve,Re=pe[Q]||v,At=E(Re,M,1),Ke=Re[M],ze=Ae.DBG;(ve=console.STAT)&&(!pe[Q]||!Ke)&&(ve.has=(ve.has||0)+1);var gt=L(),WA;if(X>gt){setTimeout(function(){$(O,M,Q,X,ne)},(ve=X-gt)>re?re:ve),console.STAT&&console.STAT((ze||Ae).Hf=+new Date,ve,"future");return}if(!(X<At)&&!(!Ae.faith&&X===At&&(O===Ke||z(O)<=z(Ke))&&!Ae.miss)){Ae.stun++;var CA=ne["#"]+Ae.all++,uA={toString:function(){return CA},_:Ae};uA.toJSON=uA.toString,te.dup.track(uA)["#"]=ne["#"],ze&&(ze.ph=ze.ph||+new Date),te.on("put",{"#":uA,"@":ne["@"],put:{"#":Q,".":M,":":O,">":X},ok:ne.ok,_:Ae})}}function B(O){var M;(M=(O._||"").DBG)&&(M.pa=+new Date,M.pm=M.pm||+new Date);var Q=this,X=Q.as,ne=X.graph,Ae=O._,te=O.put,pe=te["#"],me=te["."],ve=te[":"],Re=te[">"],At=O["#"],Ke;(Ke=Ae.msg)&&(Ke=Ke.put)&&(Ke=Ke[pe])&&b(Ke,me,Re,ve,pe),ne[pe]=b(ne[pe],me,Re,ve,pe),(Ke=(X.next||"")[pe])&&Ke.on("in",O),T(Ae),Q.to.next(O)}function T(O,M){var Q;if(!O.stop&&!(!O.err&&0<--O.stun)&&(O.stop=1,!!(Q=O.root))){var X=O.match;X.end=1,X===Q.hatch&&(!(X=O.latch)||X.end?delete Q.hatch:Q.hatch=X),O.hatch&&O.hatch(),setTimeout.each(O.match,function(ne){ne&&ne()}),!(!(M=O.msg)||O.err||M.err)&&(M.out=S,O.root.on("out",M),ae())}}function I(O){var M=O["@"]||"",Q,X,ne;if(!(Q=M._)){var Ae=(Ae=O.$)&&(Ae=Ae._)&&(Ae=Ae.root)&&(Ae=Ae.dup);if(!(Ae=Ae.check(M)))return;O["@"]=Ae["#"]||O["@"];return}Q.acks=(Q.acks||0)+1,(Q.err=O.err)&&(O["@"]=Q["#"],T(Q)),Q.ok=O.ok||Q.ok,!Q.stop&&!Q.crack&&(Q.crack=Q.match&&Q.match.push(function(){q(Q)})),q(Q)}function q(O){!O||!O.root||O.stun||O.acks!==O.all||O.root.on("in",{"@":O["#"],err:O.err,ok:O.err?_:O.ok||{"":1}})}var U="Error: Invalid graph!",V=function(O){return" '"+(""+O).slice(0,9)+"...' "},z=JSON.stringify,re=2147483647,L=o.state,J=0,ue,ae=function(){J>999&&J/-(ue-(ue=+new Date))>1&&(o.window&&console.log("Warning: You're syncing 1K+ records a second, faster than DOM can update - consider limiting query."),ae=function(){J=0})}})(),(function(){o.on.get=function(R,$){var B=$._,T=R.get,I=T["#"],q=B.graph[I],U=T["."],V=B.next||(B.next={}),z=V[I],re=R._||{},L=re.DBG=R.DBG;if(L&&(L.g=+new Date),!q)return B.on("get",R);if(U){if((typeof U!="string"||_===q[U])&&!((z||"").next||"")[U]){B.on("get",R);return}q=b({},U,E(q,U),q[U],I)}q&&S(R,q),B.on("get",R)};function S(R,$){var B=+new Date,T=R._||{},I=T.DBG=R.DBG,q=R["#"],U=h(9),V=Object.keys($||"").sort(),z=(($||"")._||"")["#"],re=V.length,L=0,J=R.$._.root,ue=$===J.graph[z];console.STAT&&console.STAT(B,((I||T).gk=+new Date)-B,"got keys"),$&&(function ae(){B=+new Date;for(var O=0,M,Q={},X;O<9&&(M=V[O++]);)b(Q,M,E($,M),$[M],z);V=V.slice(O),(X={})[z]=Q,Q=X;var ne;ue&&(ne=function(){},ne.ram=ne.faith=!0),X=V.length,console.STAT&&console.STAT(B,-(B-(B=+new Date)),"got copied some"),I&&(I.ga=+new Date),J.on("in",{"@":q,"#":U,put:Q,"%":X?U=h(9):_,$:J.$,_:ne,DBG:I,FOO:1}),console.STAT&&console.STAT(B,+new Date-B,"got in"),X&&setTimeout.turn(ae)})(),$||J.on("in",{"@":R["#"]})}o.on.get.ack=S})(),(function(){o.chain.opt=function(S){S=S||{};var R=this,$=R._,B=S.peers||S;return Object.plain(S)||(S={}),Object.plain($.opt)||($.opt=S),typeof B=="string"&&(B=[B]),Object.plain($.opt.peers)||($.opt.peers={}),B instanceof Array&&(S.peers={},B.forEach(function(T){var I={};I.id=I.url=T,S.peers[T]=$.opt.peers[T]=$.opt.peers[T]||I})),f(S,function T(I){var q=this[I];if(this&&this.hasOwnProperty(I)||typeof q=="string"||Object.empty(q)){this[I]=q;return}q&&q.constructor!==Object&&!(q instanceof Array)||f(q,T)}),$.opt.from=S,o.on("opt",$),$.opt.uuid=$.opt.uuid||function(I){return o.state().toString(36).replace(".","")+String.random(I||12)},R}})();var f=function(S,R){Object.keys(S).forEach(R,S)},h=String.random,m=setTimeout.turn,y=o.valid,E=o.state.is,b=o.state.ify,_,v={},P;o.log=function(){return!o.log.off&&P.log.apply(P,arguments),[].slice.call(arguments).join(" ")},o.log.once=function(S,R,$){return($=o.log.once)[S]=$[S]||0,$[S]++||o.log(R)},typeof window<"u"&&((window.GUN=window.Gun=o).window=window);try{typeof e<"u"&&(e.exports=o)}catch{}i.exports=o,(o.window||{}).console=(o.window||{}).console||{log:function(){}},(P=console).only=function(S,R){return P.only.i&&S===P.only.i&&P.only.i++&&(P.log.apply(P,arguments)||R)},o.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!")})(n,"./root"),n(function(i){var o=n("./root");o.chain.back=function(m,y){var E;if(m=m||1,m===-1||m===1/0)return this._.root.$;if(m===1)return(this._.back||this._).$;var b=this,_=b._;if(typeof m=="string"&&(m=m.split(".")),m instanceof Array){var v=0,P=m.length,E=_;for(v;v<P;v++)E=(E||f)[m[v]];return h!==E?y?b:E:(E=_.back)?E.$.back(m,y):void 0}if(typeof m=="function"){for(var S,E={back:_};(E=E.back)&&h===(S=m(E,y)););return S}return typeof m=="number"?(_.back||_).$.back(m-1):this};var f={},h})(n,"./back"),n(function(i){var o=n("./root");o.chain.chain=function(T){var I=this,q=I._,U=new(T||I).constructor(I),V=U._,z;return V.root=z=q.root,V.id=++z.once,V.back=I._,V.on=o.on,V.on("in",o.on.in,V),V.on("out",o.on.out,V),U};function f(T){var I,q,U=this.as,V=U.back,z=U.root,re;if(T.$||(T.$=U.$),this.to.next(T),U.err){U.on("in",{put:U.put=_,$:U.$});return}if(q=T.get){if(z.pass&&(z.pass[U.id]=U),U.lex&&Object.keys(U.lex).forEach(function(L){re[L]=U.lex[L]},re=T.get=T.get||{}),q["#"]||U.soul){if(q["#"]=q["#"]||U.soul,T["#"]||(T["#"]=v(9)),V=z.$.get(q["#"])._,q=q["."]){if(S(V.put,q)&&(re=V.ask&&V.ask[q],(V.ask||(V.ask={}))[q]=V.$.get(q)._,V.on("in",{get:q,put:{"#":V.soul,".":q,":":V.put[q],">":$(z.graph[V.soul],q)}}),re))return}else{if(re=V.ask&&V.ask[""],(V.ask||(V.ask={}))[""]=V,_!==V.put&&(V.on("in",V),re))return;T.$=V.$}return z.ask(E,T),z.on("in",T)}if(q["."])return U.get?(T={get:{".":U.get},$:U.$},(V.ask||(V.ask={}))[U.get]=T.$._,V.on("out",T)):(T={get:U.lex?T.get:{},$:U.$},V.on("out",T));if((U.ask||(U.ask={}))[""]=U,U.get)return q["."]=U.get,(V.ask||(V.ask={}))[U.get]=T.$._,V.on("out",T)}return V.on("out",T)}o.on.out=f;function h(T,I){I=I||this.as;var q=I.root,U=T.$||(T.$=I.$),V=(U||"")._||b,z=T.put||"",re=z["#"],L=z["."],J=_!==z["="]?z["="]:z[":"],ue=z[">"]||-1/0,ae;if(_!==T.put&&(_===z["#"]||_===z["."]||_===z[":"]&&_===z["="]||_===z[">"])){if(!P(z)){if(!(re=((z||"")._||"")["#"])){console.log("chain not yet supported for",z,"...",T,I);return}return U=I.root.$.get(re),setTimeout.each(Object.keys(z).sort(),function(O){O=="_"||_===(ue=$(z,O))||I.on("in",{$:U,put:{"#":re,".":O,"=":z[O],">":ue},VIA:T})})}I.on("in",{$:V.back.$,put:{"#":re=V.back.soul,".":L=V.has||V.get,"=":z,">":$(V.back.put,L)},via:T});return}(T.seen||"")[I.id]||((T.seen||(T.seen=function(){}))[I.id]=I,I!==V&&(Object.keys(T).forEach(function(O){z[O]=T[O]},z={}),z.get=I.get||z.get,!I.soul&&!I.has?z.$$$=z.$$$||I.$:V.soul&&(z.$=I.$,z.$$=z.$$||V.$),T=z),y(T,I),(I.soul||T.$$)&&ue>=$(q.graph[re],L)&&((z=q.$.get(re)._).put=B(z.put,L,ue,J,re)),!V.soul&&ue>=$(q.graph[re],L)&&(ae=(q.$.get(re)._.next||"")[L])&&(ae.put=J,typeof(z=P(J))=="string"&&(ae.put=q.$.get(z)._.put||J)),this.to&&this.to.next(T),I.any&&setTimeout.each(Object.keys(I.any),function(O){(O=I.any[O])&&O(T)},0,99),I.echo&&setTimeout.each(Object.keys(I.echo),function(O){(O=I.echo[O])&&O.on("in",T)},0,99),((T.$$||"")._||V).soul&&(ae=I.next)&&(ae=ae[L])&&(z={},Object.keys(T).forEach(function(O){z[O]=T[O]}),z.$=(T.$$||T.$).get(z.get=L),delete z.$$,delete z.$$$,ae.on("in",z)),m(T,I))}o.on.in=h;function m(T,I){if(I=I||this.as||T.$._,!(T.$$&&this!==o.on)&&!(!T.put||I.soul)){var q=T.put||"",U=q["="]||q[":"],L,V=I.root,z=V.$.get(q["#"]).get(q["."])._;if(typeof(U=P(U))!="string"){this===o.on&&((z.echo||(z.echo={}))[I.id]=I);return}if(!((z.echo||(z.echo={}))[I.id]&&!(V.pass||"")[I.id])){if(L=V.pass){if(L[U+I.id])return;L[U+I.id]=1}(z.echo||(z.echo={}))[I.id]=I,I.has&&(I.link=U);var re=V.$.get(z.link=U)._;(re.echo||(re.echo={}))[z.id]=z;var L=I.ask||"";(L[""]||I.lex)&&re.on("out",{get:{"#":U}}),setTimeout.each(Object.keys(L),function(J,ue){!J||!(ue=L[J])||ue.on("out",{get:{"#":U,".":J}})},0,99)}}}o.on.link=m;function y(T,I){var q=T.put||"",U=_!==q["="]?q["="]:q[":"],V=I.root,z,re;if(_===U){if(I.soul&&_!==I.put||(re=(T.$$||T.$||"")._||"",T["@"]&&(_!==re.put||_!==I.put)))return;(z=I.link||T.linked)&&delete(V.$.get(z)._.echo||"")[I.id],I.has&&(I.link=null),I.put=_,setTimeout.each(Object.keys(I.next||""),function(L,J){(J=I.next[L])&&(z&&delete(V.$.get(z).get(L)._.echo||"")[J.id],J.on("in",{get:L,put:_,$:J.$}))},0,99);return}I.soul||T.$$||(z=P(U),re=T.$._||"",!((z===re.link||I.has&&!re.link)&&!((V.pass||"")[I.id]&&typeof z!="string"))&&(delete(re.echo||"")[I.id],y({get:I.get,put:_,$:T.$,linked:T.linked=T.linked||re.link},I)))}o.on.unlink=y;function E(T,I){var q=this.as,U=q.$._,V=U.root,z=q.get||"",re=(T.put||"")[z["#"]]||"";if(!T.put||typeof z["."]=="string"&&_===re[z["."]]){if(_!==U.put||!U.soul&&!U.has)return;U.ack=(U.ack||0)+1,U.on("in",{get:U.get,put:U.put=_,$:U.$,"@":T["@"]});return}(T._||{}).miss=1,o.on.put(T)}var b={},_,v=String.random,P=o.valid,S=function(T,I){return T&&Object.prototype.hasOwnProperty.call(T,I)},R=o.state,$=R.is,B=R.ify})(n,"./chain"),n(function(i){var o=n("./root");o.chain.get=function(_,v,P){var S,R;if(typeof _=="string"){if(_.length==0)return(S=this.chain())._.err={err:o.log("0 length key!",_)},v&&v.call(S,S._.err),S;var $=this,B=$._,T=B.next||y;(S=T[_])||(S=_&&f(_,$)),S=S&&S.$}else if(typeof _=="function"){let L=function(J,ue,ae){if(!L.stun&&!((te=q.pass)&&!te[U])){var O=J.$._,M=(J.$$||"")._,Q=(M||O).put,X=!O.has&&!O.soul,ne={},Ae,te;if((X||b===Q)&&(Q=b===((te=J.put)||"")["="]?b===(te||"")[":"]?te:te[":"]:te["="]),(Ae=typeof(te=o.valid(Q))=="string")&&(Q=b===(te=q.$.get(te)._.put)?I.not?b:Q:te),!(I.not&&b===Q)){if(b===I.stun){if((te=q.stun)&&te.on&&(B.$.back(function(pe){if(te.on(""+pe.id,ne={}),(ne.run||0)<L.id)return ne}),!ne.run&&te.on(""+O.id,ne={}),!ne.run&&M&&te.on(""+M.id,ne={}),L.id>ne.run&&((!ne.stun||ne.stun.end)&&(ne.stun=te.on("stun"),ne.stun=ne.stun&&ne.stun.last),ne.stun&&!ne.stun.end))){(ne.stun.add||(ne.stun.add={}))[U]=function(){L(J,ue,1)};return}if(b===Q&&(ae=0),(te=q.hatch)&&!te.end&&b===I.hatch&&!ae){if(V[O.$._.id])return;V[O.$._.id]=1,te.push(function(){L(J,ue,1)});return}V={}}if(q.pass){if(q.pass[U+O.id])return;q.pass[U+O.id]=1}if(I.on){I.ok.call(O.$,Q,O.get,J,ue||L);return}if(I.v2020){I.ok(J,ue||L);return}Object.keys(J).forEach(function(pe){te[pe]=J[pe]},te={}),J=te,J.put=Q,I.ok.call(I.as,J,ue||L)}}};var z=L;if(v===!0)return h(this,_,v,P),this;S=this;var B=S._,I=v||{},q=B.root,U;I.at=B,I.ok=_;var V={};return L.at=B,(B.any||(B.any={}))[U=String.random(7)]=L,L.off=function(){L.stun=1,B.any&&delete B.any[U]},L.rid=m,L.id=I.run||++q.once,R=q.pass,(q.pass={})[U]=1,I.out=I.out||{get:{}},B.on("out",I.out),q.pass=R,S}else{if(typeof _=="number")return this.get(""+_,v,P);if(typeof(R=E(_))=="string")return this.get(R,v,P);(R=this.get.next)&&(S=R(this,_))}return S?(v&&typeof v=="function"&&S.get(v,P),S):((S=this.chain())._.err={err:o.log("Invalid get request!",_)},v&&v.call(S,S._.err),S)};function f(_,v){var P=v._,S=P.next,R=v.chain(),$=R._;return S||(S=P.next={}),S[$.get=_]=$,v===P.root.$?$.soul=_:(P.soul||P.has)&&($.has=_),$}function h(_,v,P,S){var R=_._,$=0,B;return(B=R.soul||R.link)?v(B,S,R):R.jam?R.jam.push([v,S]):(R.jam=[[v,S]],_.get(function(I,q){if(!(b===I.put&&!R.root.opt.super&&(B=Object.keys(R.root.opt.peers).length)&&++$<=B)){q.rid(I);var U=(U=I.$)&&U._||{},V=0,z;for(B=R.jam,delete R.jam;z=B[V++];){var re=z[0],L;z=z[1],re&&re(L=U.link||U.soul||o.valid(I.put)||((I.put||{})._||{})["#"],z,I,q)}}},{out:{get:{".":!0}}}),_)}function m(_){var v=this.at||this.on;if(!_||v.soul||v.has)return this.off();if(_=(_=(_=_.$||_)._||_).id){var P=v.map,S,R;if(S=(R=this.seen||(this.seen={}))[_])return!0;R[_]=!0}}var y={},E=o.valid,b})(n,"./get"),n(function(i){var o=n("./root");o.chain.put=function($,B,T){var I=this,q=I._,U=q.root;T=T||{},T.root=q.root,T.run||(T.run=U.once),f(T,q.id),T.ack=T.ack||B,T.via=T.via||I,T.data=T.data||$,T.soul||(T.soul=q.soul||typeof B=="string"&&B);var V=T.state=T.state||o.state();return typeof $=="function"?($(function(z){T.data=z,I.put(E,E,T)}),I):T.soul?(T.$=U.$.get(T.soul),T.todo=[{it:T.data,ref:T.$}],T.turn=T.turn||v,T.ran=T.ran||h,(function z(){var re=T.todo,L=re.pop(),J=L.it,ue=L.ref&&L.ref._.id,ae,O,M,Q,X;if(f(T,L.ref),(Q=L.todo)&&(O=Q.pop(),J=J[O],Q.length&&re.push(L)),O&&(re.path||(re.path=[])).push(O),!(ae=P(J))&&!(X=o.is(J))){if(!Object.plain(J)){h.err(T,"Invalid data: "+y(J)+" at "+(T.via.back(function(me){me.get&&Q.push(me.get)},Q=[])||Q.join("."))+"."+(re.path||[]).join("."));return}for(var ne=T.seen||(T.seen=[]),Ae=ne.length;Ae--;)if(J===(Q=ne[Ae]).it){ae=J=Q.link;break}}if(O&&ae)L.node=S(L.node,O,V,J);else{let me=function(ve,Re){var At=M.link["#"];Re&&(Re.off(),Re.rid(ve));var Ke=At||ve.soul||(Q=(ve.$$||ve.$)._||"").soul||Q.link||((Q=Q.put||"")._||"")["#"]||Q["#"]||((Q=ve.put||"")&&ve.$$?Q["#"]:(Q["="]||Q[":"]||"")["#"]);if(!At&&f(T,ve.$),!Ke&&!L.link["#"]){(L.wait||(L.wait=[])).push(function(){me(ve,Re)});return}Ke||(Ke=[],(ve.$$||ve.$).back(function(ze){if(Q=ze.soul||ze.link)return Ke.push(Q);Ke.push(ze.get)}),Ke=Ke.reverse().join("/")),M.link["#"]=Ke,!X&&(((T.graph||(T.graph={}))[Ke]=M.node||(M.node={_:{}}))._["#"]=Ke),delete T.wait[te],M.wait&&setTimeout.each(M.wait,function(ze){ze&&ze()}),T.ran(T)};var pe=me;if(!T.seen){h.err(T,"Data at root of graph must be a node (an object).");return}T.seen.push(M={it:J,link:{},todo:X?[]:Object.keys(J).sort().reverse(),path:(re.path||[]).slice(),up:L}),L.node=S(L.node,O,V,M.link),!X&&M.todo.length&&re.push(M);var te=T.seen.length;(T.wait||(T.wait={}))[te]="",Q=(M.ref=X?J:O?L.ref.get(O):L.ref)._,(Q=J&&(J._||"")["#"]||Q.soul||Q.link)?me({soul:Q}):M.ref.get(me,{run:T.run,v2020:1,out:{get:{".":" "}}})}if(!re.length)return T.ran(T);T.turn(z)})(),I):(m(T),I)};function f($,B){if(B){B=(B._||"").id||B;var T=$.root.stun||($.root.stun={on:o.on}),I={},q;$.stun||($.stun=T.on("stun",function(){})),(q=T.on(""+B))&&q.the.last.next(I),!(I.run>=$.run)&&T.on(""+B,function(U){if($.stun.end){this.off(),this.to.next(U);return}U.run=U.run||$.run,U.stun=U.stun||$.stun})}}function h($){if($.err){h.end($.stun,$.root);return}if(!($.todo.length||$.end||!Object.empty($.wait))){$.end=1;var B=$.$.back(-1)._,T=B.root,I=B.ask(function(z){T.on("ack",z),z.err&&!z.lack&&o.log(z),++q>($.acks||0)&&this.off(),$.ack&&$.ack(z,this)},$.opt),q=0,U=$.stun,V;(V=function(){U&&(h.end(U,T),setTimeout.each(Object.keys(U=U.add||""),function(z){(z=U[z])&&z()}))}).hatch=V,$.ack&&!$.ok&&($.ok=$.acks||9),$.via._.on("out",{put:$.out=$.graph,ok:$.ok&&{"@":$.ok+1},opt:$.opt,"#":I,_:V})}}h.end=function($,B){$.end=_,$.the.to===$&&$===$.the.last&&delete B.stun,$.off()},h.err=function($,B){($.ack||_).call($,$.out={err:$.err=o.log(B)}),$.ran($)};function m($){var B=$.via._,T;$.via=$.via.back(function(I){if(I.soul||!I.get)return I.$;T=$.data,($.data={})[I.get]=T}),(!$.via||!$.via._.soul)&&($.via=B.root.$.get((($.data||"")._||"")["#"]||B.$.back("opt.uuid")())),$.via.put($.data,$.ack,$)}function y($,B){return $&&(B=$.constructor)&&B.name||typeof $}var E,b={},_=function(){},v=setTimeout.turn,P=o.valid,S=o.state.ify,R=function($,B){$.call(B||b)}})(n,"./put"),n(function(i){var o=n("./root");n("./chain"),n("./back"),n("./put"),n("./get"),i.exports=o})(n,"./index"),n(function(i){var o=n("./index");o.chain.on=function(E,b,_,v){var P=this,S=P._,R=S.root,$,B,T,I;if(typeof E=="string")return b?($=S.on(E,b,_||S,v),_&&_.$&&(_.subs||(_.subs=[])).push($),P):S.on(E);var q=b;(q=q===!0?{change:!0}:q||{}).not=1,q.on=1;var U={};return P.get(E,q),P},o.chain.once=function(E,b){if(b=b||{},!E)return f(this,b);var _=this,v=_._,P=v.root,S=v.put,R=String.random(7),$,B;return _.get(function(T,I,q,U){var V=this,z=V._,re=z.one||(z.one={});if(U.stun||re[R]==="")return;if((B=o.valid(T))===!0){L();return}if(typeof B=="string")return;clearTimeout((v.one||"")[R]),clearTimeout(re[R]),re[R]=setTimeout(L,b.wait||99);function L(J){if(!z.has&&!z.soul&&(z={put:T,get:I}),y===(B=z.put)&&(B=((q.$$||"")._||"").put),typeof o.valid(B)=="string"&&(B=P.$.get(B)._.put,B===y&&!J)){re[R]=setTimeout(function(){L(1)},b.wait||99);return}U.stun||re[R]!==""&&(re[R]="",(v.soul||v.has)&&U.off(),E.call(V,B,z.get),clearTimeout(re[R]))}},{on:1}),_};function f(E,b,_){return o.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.chain())._.nix=E.once(function(v,P){_._.on("in",this._)}),_._.lex=E._.lex,_}o.chain.off=function(){var E=this,b=E._,_,v=b.back;if(v)return b.ack=0,(_=v.next)&&_[b.get]&&delete _[b.get],(_=v.any)&&(delete v.any,v.any={}),(_=v.ask)&&delete _[b.get],(_=v.put)&&delete _[b.get],(_=b.soul)&&delete v.root.graph[_],(_=b.map)&&Object.keys(_).forEach(function(P,S){S=_[P],S.link&&v.root.$.get(S.link).off()}),(_=b.next)&&Object.keys(_).forEach(function(P,S){S=_[P],S.$.off()}),b.on("off",{}),E};var h={},m=function(){},y})(n,"./on"),n(function(i){var o=n("./index"),f=o.chain.get.next;o.chain.get.next=function(b,_){var v;return Object.plain(_)?(v=((v=_["#"])||"")["="]||v)?b.get(v):((v=b.chain()._).lex=_,b.on("in",function(P){String.match(P.get||(P.put||"")["."],_["."]||_["#"]||_)&&v.on("in",P),this.to.next(P)}),v.$):(f||m)(b,_)},o.chain.map=function(b,_,v){var P=this,S=P._,R,$;return Object.plain(b)&&(R=b["."]?b:{".":b},b=E),b?(o.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."),$=P.chain(),P.map().on(function(B,T,I,q){var U=(b||m).call(this,B,T,I,q);if(E!==U){if(B===U)return $._.on("in",I);if(o.is(U))return $._.on("in",U._);var V={};Object.keys(I.put).forEach(function(z){V[z]=I.put[z]},V),V["="]=U,$._.on("in",{get:T,put:V})}}),$):(($=S.each)||((S.each=$=P.chain())._.lex=R||$._.lex||S.lex,$._.nix=P.back("nix"),P.on("in",h,$._)),$)};function h(b){this.to.next(b);var _=this.as,v=b.$,P=v._,S=b.put,R;!P.soul&&!b.$$||(R=_.lex)&&!String.match(b.get||(S||"")["."],R["."]||R["#"]||R)||o.on.link(b,_)}var m=function(){},y={stun:m,off:m},E})(n,"./map"),n(function(i){var o=n("./index");o.chain.set=function(f,h,m){var y=this,E=y.back(-1),b,_;return h=h||function(){},m=m||{},m.item=m.item||f,(b=((f||"")._||"")["#"])&&((f={})["#"]=b),typeof(_=o.valid(f))=="string"?y.get(b=_).put(f,h,m):o.is(f)?(y.put(function(v){f.get(function(P,S,R){if(!P)return h.call(y,{err:o.log('Only a node can be linked! Not "'+R.put+'"!')});(_={})[P]={"#":P},v(_)},!0)}),f):(Object.plain(f)&&(f=E.get(b=y.back("opt.uuid")()).put(f)),y.get(b||E.back("opt.uuid")(7)).put(f,h,m))}})(n,"./set"),n(function(i){n("./shim");var o=function(){},f=JSON.parseAsync||function(_,v,P){var S,R=+new Date;try{v(S,JSON.parse(_,P),h.sucks(+new Date-R))}catch($){v($)}},h=JSON.stringifyAsync||function(_,v,P,S){var R,$=+new Date;try{v(R,JSON.stringify(_,P,S),h.sucks(+new Date-$))}catch(B){v(B)}};h.sucks=function(_){_>99&&(console.log("Warning: JSON blocking CPU detected. Add `gun/lib/yson.js` to fix."),h.sucks=o)};function m(_){var v=function(){},P=_.opt||{};P.log=P.log||console.log,P.gap=P.gap||P.wait||0,P.max=P.max||(P.memory?P.memory*999*999:3e8)*.3,P.pack=P.pack||P.max*.01*.01,P.puff=P.puff||9;var S=setTimeout.turn||setTimeout,R=_.dup,$=R.check,B=R.track,T=+new Date,I=T,q=v.hear=function(L,J){if(L){if(P.max<=L.length)return v.say({dam:"!",err:"Message too big!"},J);v===this&&(q.d+=L.length||0,++q.c);var ue=J.SH=+new Date,ae=L[0],O;if(ae==="["){f(L,function(M,Q){if(M||!Q)return v.say({dam:"!",err:"DAM JSON parse error."},J);console.STAT&&console.STAT(+new Date,Q.length,"# on hear batch");var X=P.puff;(function ne(){for(var Ae=+new Date,te=0,pe;te<X&&(pe=Q[te++]);)v.hear(pe,J);Q=Q.slice(te),console.STAT&&console.STAT(Ae,+new Date-Ae,"hear loop"),V(J),Q.length&&S(ne,0)})()}),L="";return}if(ae==="{"||(L["#"]||Object.plain(L))&&(O=L)){if(O)return q.one(O,J,ue);f(L,function(M,Q){if(M||!Q)return v.say({dam:"!",err:"DAM JSON parse error."},J);q.one(Q,J,ue)});return}}};q.one=function(L,J,ne){var ae,O,M,Q,X;if(L.DBG&&(L.DBG=X={DBG:L.DBG}),X&&(X.h=ne),X&&(X.hp=+new Date),(ae=L["#"])||(ae=L["#"]=String.random(9)),!(M=$(ae))&&(O=L["##"],!(O&&(M=L["@"]||L.get&&ae)&&R.check(Q=M+O)))){if((L._=function(){}).via=v.leap=J,(M=L["><"])&&typeof M=="string"&&M.slice(0,99).split(",").forEach(function(Ae){this[Ae]=1},L._.yo={}),M=L.dam){(M=v.hear[M])&&M(L,J,_),B(ae);return}(M=L.ok)&&(L._.near=M["/"]);var ne=+new Date;X&&(X.is=ne),J.SI=ae,B.ed=function(Ae){ae===Ae&&(B.ed=0,(Ae=R.s[ae])&&(Ae.via=J,L.get&&(Ae.it=L)))},_.on("in",v.last=L),X&&(X.hd=+new Date),console.STAT&&console.STAT(ne,+new Date-ne,L.get?"msg get":L.put?"msg put":"msg"),B(ae),Q&&B(Q),v.leap=v.last=null}};var U=function(L,J,ue){ue(L,!0)};q.c=q.d=0,(function(){var L=0,J;v.hash=function(M,Q){var X,ne,Ae,te=+new Date;h(M.put,function pe(me,ve){var Re=(ne||(ne=Ae=ve||"")).slice(0,32768);if(X=String.hash(Re,X),ne=ne.slice(32768),ne){S(pe,0);return}console.STAT&&console.STAT(te,+new Date-te,"say json+hash"),M._.$put=Ae,M["##"]=X,v.say(M,Q),delete M._.$put},ue)};function ue(M,Q){var X;return Q instanceof Object?(Object.keys(Q).sort().forEach(ae,{to:X={},on:Q}),X):Q}function ae(M){this.to[M]=this.on[M]}var O=v.say=function(M,Q){var X;if((X=this)&&(X=X.to)&&X.next&&X.next(M),!M)return!1;var ne,Ae,te,pe=M["@"],me=M._||(M._=function(){}),ve=M.DBG,Re=+new Date;if(me.y=me.y||Re,Q||ve&&(ve.y=Re),(ne=M["#"])||(ne=M["#"]=String.random(9)),!J&&B(ne),!(Ae=M["##"])&&b!==M.put&&!me.via&&pe){v.hash(M,Q);return}if(!Q&&pe&&(Q=(X=R.s[pe])&&(X.via||(X=X.it)&&(X=X._)&&X.via)||(X=v.last)&&pe===X["#"]&&v.leap),!Q&&pe)return R.s[pe]?void 0:(console.STAT&&console.STAT(+new Date,++L,"total no peer to ack to"),!1);if(pe&&!M.put&&!Ae&&((R.s[pe]||"").it||"")["##"])return!1;if(!Q&&v.way)return v.way(M);if(ve&&(ve.yh=+new Date),!(te=me.raw)){v.raw(M,Q);return}if(ve&&(ve.yr=+new Date),!Q||!Q.id){if(!Object.plain(Q||P.peers))return!1;var Re=+new Date,At=P.puff,Ke=P.peers,ze=Object.keys(Q||P.peers||{});console.STAT&&console.STAT(Re,+new Date-Re,"peer keys"),(function CA(){var uA=+new Date;J=1;var fA=me.raw;me.raw=te;for(var SA=0,xA;SA<9&&(xA=(ze||"")[SA++]);)(xA=Ke[xA]||(Q||"")[xA])&&v.say(M,xA);me.raw=fA,J=0,ze=ze.slice(SA),console.STAT&&console.STAT(uA,+new Date-uA,"say loop"),ze.length&&(S(CA,0),pe&&B(pe))})();return}if(!Q.wire&&v.wire&&v.wire(Q),ne!==Q.last){if(Q.last=ne,Q===me.via||(X=me.yo)&&(X[Q.url]||X[Q.pid]||X[Q.id]))return!1;if(console.STAT&&console.STAT(Re,((ve||me).yp=+new Date)-(me.y||Re),"say prep"),!J&&pe&&B(pe),Q.batch){if(Q.tail=(X=Q.tail||0)+te.length,Q.tail<=P.pack){Q.batch+=(X?",":"")+te;return}V(Q)}Q.batch="[";var gt=+new Date;setTimeout(function(){console.STAT&&console.STAT(gt,+new Date-gt,"0ms TO"),V(Q)},P.gap),z(te,Q),console.STAT&&pe===Q.SI&&console.STAT(Re,+new Date-Q.SH,"say ack")}};v.say.c=v.say.d=0,v.raw=function(M,Q){if(!M)return"";var X=M._||{},ne,Ae;if(Ae=X.raw)return Ae;if(typeof M=="string")return M;var te=M["##"],pe=M["@"];if(te&&pe){if(!X.via&&$(pe+te))return!1;if(Ae=(R.s[pe]||"").it){if(te===Ae["##"])return!1;Ae["##"]||(Ae["##"]=te)}}if(!M.dam&&!M["@"]){var me=0,ve=[];Ae=P.peers;for(var Re in Ae){var At=Ae[Re];if(ve.push(At.url||At.pid||At.id),++me>6)break}me>1&&(M["><"]=ve.join())}if(M.put&&(Ae=M.ok)&&(M.ok={"@":(Ae["@"]||1)-1,"/":Ae["/"]==M._.near?v.near:Ae["/"]}),ne=X.$put){Ae={},Object.keys(M).forEach(function(ze){Ae[ze]=M[ze]}),Ae.put=":])([:",h(Ae,function(ze,gt){if(!ze){var WA=+new Date;Ae=gt.indexOf('"put":":])([:"'),Ke(b,gt=gt.slice(0,Ae+6)+ne+gt.slice(Ae+14)),console.STAT&&console.STAT(WA,+new Date-WA,"say slice")}});return}h(M,Ke);function Ke(ze,gt){ze||(X.raw=gt,v.say(M,Q))}}})();function V(L){var J=L.batch,ue=typeof J=="string",ae;if(ue&&(J+="]"),L.batch=L.tail=null,!!J&&!(ue?3>J.length:!J.length)){if(!ue)try{J=J.length===1?J[0]:JSON.stringify(J)}catch(O){return P.log("DAM JSON stringify error",O)}J&&z(J,L)}}function z(L,J){try{var ue=J.wire;J.say?J.say(L):ue.send&&ue.send(L),v.say.d+=L.length||0,++v.say.c}catch{(J.queue=J.queue||[]).push(L)}}v.near=0,v.hi=function(L){var J=L.wire,ue;if(!J){v.wire(L.length&&{url:L,id:L}||L);return}L.id?P.peers[L.url||L.id]=L:(ue=L.id=L.id||L.url||String.random(9),v.say({dam:"?",pid:_.opt.pid},P.peers[ue]=L),delete R.s[L.last]),L.met||(v.near++,L.met=+new Date,_.on("hi",L)),ue=L.queue,L.queue=[],setTimeout.each(ue||[],function(ae){z(ae,L)},0,9)},v.bye=function(L){L.met&&--v.near,delete L.met,_.on("bye",L);var J=+new Date;J=J-(L.met||J),v.bye.time=((v.bye.time||J)+J)/2},v.hear["!"]=function(L,J){P.log("Error:",L.err)},v.hear["?"]=function(L,J){L.pid&&(J.pid||(J.pid=L.pid),L["@"])||(v.say({dam:"?",pid:P.pid,"@":L["#"]},J),delete R.s[J.last])},v.hear.mob=function(L,J){if(L.peers){var ue=Object.keys(L.peers),ae=ue[Math.random()*ue.length>>0];ae&&(v.bye(J),v.hi(ae))}},_.on("create",function(L){L.opt.pid=L.opt.pid||String.random(9),this.to.next(L),L.on("out",v.say)}),_.on("bye",function(L,J){L=P.peers[L.id||L]||L,this.to.next(L),L.bye?L.bye():(J=L.wire)&&J.close&&J.close(),delete P.peers[L.id],L.wire=null});var re={};return _.on("bye",function(L,J){this.to.next(L),(J=console.STAT)&&(J.peers=v.near),(J=L.url)&&(re[J]=!0,setTimeout(function(){delete re[J]},P.lack||9e3))}),_.on("hi",function(L,J){if(this.to.next(L),(J=console.STAT)&&(J.peers=v.near),!P.super){var ue=Object.keys(_.next||"");ue.length>9999&&!console.SUBS&&console.log(console.SUBS="Warning: You have more than 10K live GETs, which might use more bandwidth than your screen can show - consider `.off()`."),setTimeout.each(ue,function(ae){var O=_.next[ae];if(P.super||(O.ask||"")[""]){v.say({get:{"#":ae}},L);return}setTimeout.each(Object.keys(O.ask||""),function(M){M&&v.say({"##":String.hash((_.graph[ae]||"")[M]),get:{"#":ae,".":M}},L)})})}}),v}var y={},E=!0,b;try{i.exports=m}catch{}})(n,"./mesh"),n(function(i){var o=n("./index");o.Mesh=n("./mesh"),o.on("opt",function(m){if(this.to.next(m),m.once)return;var y=m.opt;if(y.WebSocket===!1)return;var E=o.window||{},b=y.WebSocket||E.WebSocket||E.webkitWebSocket||E.mozWebSocket;if(!b)return;y.WebSocket=b;var _=y.mesh=y.mesh||o.Mesh(m),v=_.wire||y.wire;_.wire=y.wire=P;function P(B){try{if(!B||!B.url)return I&&I(B);var T=B.url.replace(/^http/,"ws"),I=B.wire=new y.WebSocket(T);return I.onclose=function(){R(B),y.mesh.bye(B)},I.onerror=function(q){R(B)},I.onopen=function(){y.mesh.hi(B)},I.onmessage=function(q){q&&y.mesh.hear(q.data||q,B)},I}catch{y.mesh.bye(B)}}setTimeout(function(){!y.super&&m.on("out",{dam:"hi"})},1);var S=2*999;function R(B){clearTimeout(B.defer),y.peers[B.url]&&($&&B.retry<=0||(B.retry=(B.retry||y.retry+1||60)-(-B.tried+(B.tried=+new Date)<S*4?1:0),B.defer=setTimeout(function T(){if($&&$.hidden)return setTimeout(T,S);P(B)},S)))}var $=""+h!=typeof document&&document});var f=function(){},h})(n,"./websocket"),n(function(i){if(!(typeof Gun>"u")){var o=function(){},f,h;try{f=(Gun.window||o).localStorage}catch{}f||(Gun.log("Warning: No localStorage exists to persist data to!"),f={setItem:function(E,b){this[E]=b},removeItem:function(E){delete this[E]},getItem:function(E){return this[E]}});var m=JSON.parseAsync||function(E,b,_){var v;try{b(v,JSON.parse(E,_))}catch(P){b(P)}},y=JSON.stringifyAsync||function(E,b,_,v){var P;try{b(P,JSON.stringify(E,_,v))}catch(S){b(S)}};Gun.on("create",function E(b){this.to.next(b);var _=b.opt,v=b.graph,P=[],S,R,$,B;if(_.localStorage===!1)return;_.prefix=_.file||"gun/";try{S=E[_.prefix]=E[_.prefix]||JSON.parse($=f.getItem(_.prefix))||{}}catch{S=E[_.prefix]={}}$=($||"").length,b.on("get",function(I){this.to.next(I);var q=I.get,U,V,z,re;!q||!(U=q["#"])||(V=S[U]||re,V&&(z=q["."])&&!Object.plain(z)&&(V=Gun.state.ify({},z,Gun.state.is(V,z),V[z],U)),Gun.on.get.ack(I,V))}),b.on("put",function(I){this.to.next(I);var q=I.put,U=q["#"],V=q["."],z=I["#"],re=I.ok||"",L;if((b.next||"")[U]){if(S[U]=Gun.state.ify(S[U],V,q[">"],q[":"],U),B&&$>4999880){b.on("in",{"@":z,err:"localStorage max!"});return}!I["@"]&&(!I._.via||Math.random()<re["@"]/re["/"])&&P.push(z),!R&&(R=setTimeout(T,9+$/333))}});function T(){if(!P.length&&((setTimeout.turn||"").s||"").length){setTimeout(T,99);return}var I,q=P;clearTimeout(R),R=!1,P=[],y(S,function(U,V){try{!U&&f.setItem(_.prefix,V)}catch(z){U=B=z||"localStorage failure"}U&&(Gun.log(U+" Consider using GUN's IndexedDB plugin for RAD for more storage space, https://gun.eco/docs/RAD#install"),b.on("localStorage:error",{err:U,get:_.prefix,put:S})),$=V.length,setTimeout.each(q,function(z){b.on("in",{"@":z,err:U,ok:0})},0,99)})}})}})(n,"./localStorage")})();(function(){var ae;if(""+ae!=typeof Gun){var n=function(O){console.warn("Warning! Deprecated internal utility will break in next version:",O)},e=Gun;e.fn=e.fn||{is:function(O){return n("fn"),!!O&&typeof O=="function"}},e.bi=e.bi||{is:function(O){return n("bi"),O instanceof Boolean||typeof O=="boolean"}},e.num=e.num||{is:function(O){return n("num"),!i(O)&&(O-parseFloat(O)+1>=0||O===1/0||O===-1/0)}},e.text=e.text||{is:function(O){return n("text"),typeof O=="string"}},e.text.ify=e.text.ify||function(O){return n("text.ify"),e.text.is(O)?O:typeof JSON<"u"?JSON.stringify(O):O&&O.toString?O.toString():O},e.text.random=e.text.random||function(O,M){n("text.random");var Q="";for(O=O||24,M=M||"0123456789ABCDEFGHIJKLMNOPQRSTUVWXZabcdefghijklmnopqrstuvwxyz";O>0;)Q+=M.charAt(Math.floor(Math.random()*M.length)),O--;return Q},e.text.match=e.text.match||function(O,M){var Q,X;return n("text.match"),typeof O!="string"?!1:(typeof M=="string"&&(M={"=":M}),M=M||{},Q=M["="]||M["*"]||M[">"]||M["<"],O===Q?!0:X!==M["="]?!1:(Q=M["*"]||M[">"]||M["<"],O.slice(0,(Q||"").length)===Q?!0:X!==M["*"]?!1:X!==M[">"]&&X!==M["<"]?O>=M[">"]&&O<=M["<"]:X!==M[">"]&&O>=M[">"]||X!==M["<"]&&O<=M["<"]))},e.text.hash=e.text.hash||function(O,M){if(n("text.hash"),typeof O=="string"){if(M=M||0,!O.length)return M;for(var Q=0,X=O.length,ne;Q<X;++Q)ne=O.charCodeAt(Q),M=(M<<5)-M+ne,M|=0;return M}},e.list=e.list||{is:function(O){return n("list"),O instanceof Array}},e.list.slit=e.list.slit||Array.prototype.slice,e.list.sort=e.list.sort||function(O){return n("list.sort"),function(M,Q){return!M||!Q?0:(M=M[O],Q=Q[O],M<Q?-1:M>Q?1:0)}},e.list.map=e.list.map||function(O,M,Q){return n("list.map"),J(O,M,Q)},e.list.index=1,e.obj=e.boj||{is:function(O){return n("obj"),O?O instanceof Object&&O.constructor===Object||Object.prototype.toString.call(O).match(/^\[object (\w+)\]$/)[1]==="Object":!1}},e.obj.put=e.obj.put||function(O,M,Q){return n("obj.put"),(O||{})[M]=Q,O},e.obj.has=e.obj.has||function(O,M){return n("obj.has"),O&&Object.prototype.hasOwnProperty.call(O,M)},e.obj.del=e.obj.del||function(O,M){if(n("obj.del"),!!O)return O[M]=null,delete O[M],O},e.obj.as=e.obj.as||function(O,M,Q,X){return n("obj.as"),O[M]=O[M]||(X===Q?{}:Q)},e.obj.ify=e.obj.ify||function(O){if(n("obj.ify"),U(O))return O;try{O=JSON.parse(O)}catch{O={}}return O},(function(){var O;function M(Q,X){z(this,X)&&O!==this[X]||(this[X]=Q)}e.obj.to=e.obj.to||function(Q,X){return n("obj.to"),X=X||{},J(Q,M,X),X}})(),e.obj.copy=e.obj.copy||function(O){return n("obj.copy"),O&&JSON.parse(JSON.stringify(O))},(function(){function O(M,Q){var X=this.n,ne;if(!(X&&(Q===X||U(X)&&z(X,Q)))&&ne!==Q)return!0}e.obj.empty=e.obj.empty||function(M,Q){return n("obj.empty"),M?!J(M,O,{n:Q}):!0}})(),(function(){function O(ne,Ae){if(arguments.length===2){O.r=O.r||{},O.r[ne]=Ae;return}O.r=O.r||[],O.r.push(ne)}var M=Object.keys,Q,X;Object.keys=Object.keys||function(ne){return Q(ne,function(Ae,te,pe){pe(te)})},e.obj.map=Q=e.obj.map||function(ne,Ae,te){n("obj.map");var pe,me=0,ve,Re,At,Ke,ze=typeof Ae=="function";if(O.r=pe,M&&U(ne)&&(At=M(ne),Ke=!0),te=te||{},i(ne)||At)for(ve=(At||ne).length;me<ve;me++){var gt=me+e.list.index;if(ze){if(Re=Ke?Ae.call(te,ne[At[me]],At[me],O):Ae.call(te,ne[me],gt,O),Re!==pe)return Re}else if(Ae===ne[Ke?At[me]:me])return At?At[me]:gt}else for(me in ne)if(ze){if(z(ne,me)&&(Re=te?Ae.call(te,ne[me],me,O):Ae(ne[me],me,O),Re!==pe))return Re}else if(Ae===ne[me])return me;return ze?O.r:e.list.index?0:-1}})(),e.time=e.time||{},e.time.is=e.time.is||function(O){return n("time"),O?O instanceof Date:+new Date().getTime()};var I=e.fn.is,i=e.list.is,q=e.obj,U=q.is,z=q.has,J=q.map,o={};o.is=function(O){return n("val.is"),O===ae?!1:O===null?!0:O===1/0?!1:m(O)||h(O)||R(O)?!0:o.link.is(O)||!1},o.link=o.rel={_:"#"},(function(){o.link.is=function(M){if(n("val.link.is"),M&&M[f]&&!M._&&U(M)){var Q={};if(J(M,O,Q),Q.id)return Q.id}return!1};function O(M,Q){var X=this;if(X.id)return X.id=!1;if(Q==f&&m(M))X.id=M;else return X.id=!1}})(),o.link.ify=function(O){return n("val.link.ify"),L({},f,O)},e.obj.has._=".";var f=o.link._,ae,h=e.bi.is,R=e.num.is,m=e.text.is,q=e.obj,U=q.is,L=q.put,J=q.map;e.val=e.val||o;var y={_:"_"};y.soul=function(O,M){return n("node.soul"),O&&O._&&O._[M||_]},y.soul.ify=function(O,M){return n("node.soul.ify"),M=typeof M=="string"?{soul:M}:M||{},O=O||{},O._=O._||{},O._[_]=M.soul||O._[_]||b(),O},y.soul._=o.link._,(function(){y.is=function(M,Q,X){n("node.is");var ne;return U(M)&&(ne=y.soul(M))?!J(M,O,{as:X,cb:Q,s:ne,n:M}):!1};function O(M,Q){if(Q!==y._){if(!o.is(M))return!0;this.cb&&this.cb.call(this.as,M,Q,this.n,this.s)}}})(),(function(){y.ify=function(M,Q,X){return n("node.ify"),Q?typeof Q=="string"?Q={soul:Q}:typeof Q=="function"&&(Q={map:Q}):Q={},Q.map&&(Q.node=Q.map.call(X,M,ae,Q.node||{})),(Q.node=y.soul.ify(Q.node||{},Q))&&J(M,O,{o:Q,as:X}),Q.node};function O(M,Q){var X=this.o,ne,Ae;if(X.map){ne=X.map.call(this.as,M,""+Q,X.node),Ae===ne?V(X.node,Q):X.node&&(X.node[Q]=ne);return}o.is(M)&&(X.node[Q]=M)}})();var q=e.obj,U=q.is,V=q.del,J=q.map,E=e.text,b=E.random,_=y.soul._,ae;e.node=e.node||y;var v=e.state;v.lex=function(){return n("state.lex"),v().toString(36).replace(".","")},v.to=function(O,M,Q){n("state.to");var X=(O||{})[M];return U(X)&&(X=ue(X)),v.ify(Q,M,v.is(O,M),X,y.soul(O))},(function(){v.map=function(M,Q,X){n("state.map");var ne,Ae=U(Ae=M||Q)?Ae:null;return M=I(M=M||Q)?M:null,Ae&&!M?(Q=R(Q)?Q:v(),Ae[B]=Ae[B]||{},J(Ae,O,{o:Ae,s:Q}),Ae):(X=X||U(Q)?Q:ne,Q=R(Q)?Q:v(),function(te,pe,me,ve){if(!M)return O.call({o:me,s:Q},te,pe),te;M.call(X||this||{},te,pe,me,ve),!(z(me,pe)&&ne===me[pe])&&O.call({o:me,s:Q},te,pe)})};function O(M,Q){B!==Q&&v.ify(this.o,Q,this.s)}})();var q=e.obj,P=q.as,z=q.has,U=q.is,J=q.map,ue=q.copy,S=e.num,R=S.is,$=e.fn,I=$.is,B=y._,ae,T={};(function(){T.is=function(Q,X,ne,Ae){return n("graph.is"),!Q||!U(Q)||re(Q)?!1:!J(Q,O,{cb:X,fn:ne,as:Ae})};function O(Q,X){if(!Q||X!==y.soul(Q)||!y.is(Q,this.fn,this.as))return!0;this.cb&&(M.n=Q,M.as=this.as,this.cb.call(M.as,Q,X,M))}function M(Q){Q&&y.is(M.n,Q,M.as)}})(),(function(){T.ify=function(Ae,te,pe){n("graph.ify");var me={path:[],obj:Ae};return te?typeof te=="string"?te={soul:te}:typeof te=="function"&&(te.map=te):te={},typeof pe=="string"&&(te.soul=te.soul||pe,pe=ae),te.soul&&(me.link=o.link.ify(te.soul)),te.shell=(pe||{}).shell,te.graph=te.graph||{},te.seen=te.seen||[],te.as=te.as||pe,O(te,me),te.root=me.node,te.graph};function O(Ae,te){var pe;return(pe=ne(Ae,te))?pe:(te.env=Ae,te.soul=Q,y.ify(te.obj,M,te)&&(te.link=te.link||o.link.ify(y.soul(te.node)),te.obj!==Ae.shell&&(Ae.graph[o.link.is(te.link)]=te.node)),te)}function M(Ae,te,pe){var me=this,ve=me.env,Re,At;if(y._===te&&z(Ae,o.link._))return pe._;if(Re=X(Ae,te,pe,me,ve)){if(te||(me.node=me.node||pe||{},z(Ae,y._)&&y.soul(Ae)&&(me.node._=ue(Ae._)),me.node=y.soul.ify(me.node,o.link.is(me.link)),me.link=me.link||o.link.ify(y.soul(me.node))),(At=ve.map)&&(At.call(ve.as||{},Ae,te,pe,me),z(pe,te))){if(Ae=pe[te],ae===Ae){V(pe,te);return}if(!(Re=X(Ae,te,pe,me,ve)))return}if(!te)return me.node;if(Re===!0)return Ae;if(At=O(ve,{obj:Ae,path:me.path.concat(te)}),!!At.node)return At.link}}function Q(Ae){var te=this,pe=o.link.is(te.link),me=te.env.graph;te.link=te.link||o.link.ify(Ae),te.link[o.link._]=Ae,te.node&&te.node[y._]&&(te.node[y._][o.link._]=Ae),z(me,pe)&&(me[Ae]=me[pe],V(me,pe))}function X(Ae,te,pe,me,ve){var Re;if(o.is(Ae))return!0;if(U(Ae))return 1;if(Re=ve.invalid)return Ae=Re.call(ve.as||{},Ae,te,pe),X(Ae,te,pe,me,ve);ve.err="Invalid value at '"+me.path.concat(te).join(".")+"'!",e.list.is(Ae)&&(ve.err+=" Use `.set(item)` instead of an Array.")}function ne(Ae,te){for(var pe=Ae.seen,me=pe.length,ve;me--;)if(ve=pe[me],te.obj===ve.obj)return ve;pe.push(te)}})(),T.node=function(O){n("graph.node");var M=y.soul(O);if(M)return L({},M,O)},(function(){T.to=function(M,Q,X){if(n("graph.to"),!!M){var ne={};return X=X||{seen:{}},J(M[Q],O,{obj:ne,graph:M,opt:X}),ne}};function O(M,Q){var X,ne;if(y._===Q){if(re(M,o.link._))return;this.obj[Q]=ue(M);return}if(!(X=o.link.is(M))){this.obj[Q]=M;return}if(ne=this.opt.seen[X]){this.obj[Q]=ne;return}this.obj[Q]=this.opt.seen[X]=T.to(this.graph,X,this.opt)}})();var I=e.fn.is,q=e.obj,U=q.is,V=q.del,z=q.has,re=q.empty,L=q.put,J=q.map,ue=q.copy,ae;e.graph=e.graph||T}})()});var pd=ge((rS,hd)=>{hd.exports=dd()});var Cs=ge(nt=>{"use strict";Object.defineProperty(nt,"__esModule",{value:!0});nt.regexpCode=nt.getEsmExportName=nt.getProperty=nt.safeStringify=nt.stringify=nt.strConcat=nt.addCodeArg=nt.str=nt._=nt.nil=nt._Code=nt.Name=nt.IDENTIFIER=nt._CodeOrName=void 0;var Ps=class{};nt._CodeOrName=Ps;nt.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var Pn=class extends Ps{constructor(e){if(super(),!nt.IDENTIFIER.test(e))throw new Error("CodeGen: name must be a valid identifier");this.str=e}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};nt.Name=Pn;var pA=class extends Ps{constructor(e){super(),this._items=typeof e=="string"?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===""||e==='""'}get str(){var e;return(e=this._str)!==null&&e!==void 0?e:this._str=this._items.reduce((i,o)=>`${i}${o}`,"")}get names(){var e;return(e=this._names)!==null&&e!==void 0?e:this._names=this._items.reduce((i,o)=>(o instanceof Pn&&(i[o.str]=(i[o.str]||0)+1),i),{})}};nt._Code=pA;nt.nil=new pA("");function md(n,...e){let i=[n[0]],o=0;for(;o<e.length;)el(i,e[o]),i.push(n[++o]);return new pA(i)}nt._=md;var Z0=new pA("+");function gd(n,...e){let i=[ks(n[0])],o=0;for(;o<e.length;)i.push(Z0),el(i,e[o]),i.push(Z0,ks(n[++o]));return Ow(i),new pA(i)}nt.str=gd;function el(n,e){e instanceof pA?n.push(...e._items):e instanceof Pn?n.push(e):n.push(Bw(e))}nt.addCodeArg=el;function Ow(n){let e=1;for(;e<n.length-1;){if(n[e]===Z0){let i=Tw(n[e-1],n[e+1]);if(i!==void 0){n.splice(e-1,3,i);continue}n[e++]="+"}e++}}function Tw(n,e){if(e==='""')return n;if(n==='""')return e;if(typeof n=="string")return e instanceof Pn||n[n.length-1]!=='"'?void 0:typeof e!="string"?`${n.slice(0,-1)}${e}"`:e[0]==='"'?n.slice(0,-1)+e.slice(1):void 0;if(typeof e=="string"&&e[0]==='"'&&!(n instanceof Pn))return`"${n}${e.slice(1)}`}function Iw(n,e){return e.emptyStr()?n:n.emptyStr()?e:gd`${n}${e}`}nt.strConcat=Iw;function Bw(n){return typeof n=="number"||typeof n=="boolean"||n===null?n:ks(Array.isArray(n)?n.join(","):n)}function Mw(n){return new pA(ks(n))}nt.stringify=Mw;function ks(n){return JSON.stringify(n).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}nt.safeStringify=ks;function jw(n){return typeof n=="string"&&nt.IDENTIFIER.test(n)?new pA(`.${n}`):md`[${n}]`}nt.getProperty=jw;function Nw(n){if(typeof n=="string"&&nt.IDENTIFIER.test(n))return new pA(`${n}`);throw new Error(`CodeGen: invalid export name: ${n}, use explicit $id name mapping`)}nt.getEsmExportName=Nw;function Fw(n){return new pA(n.toString())}nt.regexpCode=Fw});var rl=ge(tA=>{"use strict";Object.defineProperty(tA,"__esModule",{value:!0});tA.ValueScope=tA.ValueScopeName=tA.Scope=tA.varKinds=tA.UsedValueState=void 0;var eA=Cs(),tl=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},Ho;(function(n){n[n.Started=0]="Started",n[n.Completed=1]="Completed"})(Ho||(tA.UsedValueState=Ho={}));tA.varKinds={const:new eA.Name("const"),let:new eA.Name("let"),var:new eA.Name("var")};var Vo=class{constructor({prefixes:e,parent:i}={}){this._names={},this._prefixes=e,this._parent=i}toName(e){return e instanceof eA.Name?e:this.name(e)}name(e){return new eA.Name(this._newName(e))}_newName(e){let i=this._names[e]||this._nameGroup(e);return`${e}${i.index++}`}_nameGroup(e){var i,o;if(!((o=(i=this._parent)===null||i===void 0?void 0:i._prefixes)===null||o===void 0)&&o.has(e)||this._prefixes&&!this._prefixes.has(e))throw new Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};tA.Scope=Vo;var zo=class extends eA.Name{constructor(e,i){super(i),this.prefix=e}setValue(e,{property:i,itemIndex:o}){this.value=e,this.scopePath=(0,eA._)`.${new eA.Name(i)}[${o}]`}};tA.ValueScopeName=zo;var Qw=(0,eA._)`\n`,Al=class extends Vo{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?Qw:eA.nil}}get(){return this._scope}name(e){return new zo(e,this._newName(e))}value(e,i){var o;if(i.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let f=this.toName(e),{prefix:h}=f,m=(o=i.key)!==null&&o!==void 0?o:i.ref,y=this._values[h];if(y){let _=y.get(m);if(_)return _}else y=this._values[h]=new Map;y.set(m,f);let E=this._scope[h]||(this._scope[h]=[]),b=E.length;return E[b]=i.ref,f.setValue(i,{property:h,itemIndex:b}),f}getValue(e,i){let o=this._values[e];if(o)return o.get(i)}scopeRefs(e,i=this._values){return this._reduceValues(i,o=>{if(o.scopePath===void 0)throw new Error(`CodeGen: name "${o}" has no value`);return(0,eA._)`${e}${o.scopePath}`})}scopeCode(e=this._values,i,o){return this._reduceValues(e,f=>{if(f.value===void 0)throw new Error(`CodeGen: name "${f}" has no value`);return f.value.code},i,o)}_reduceValues(e,i,o={},f){let h=eA.nil;for(let m in e){let y=e[m];if(!y)continue;let E=o[m]=o[m]||new Map;y.forEach(b=>{if(E.has(b))return;E.set(b,Ho.Started);let _=i(b);if(_){let v=this.opts.es5?tA.varKinds.var:tA.varKinds.const;h=(0,eA._)`${h}${v} ${b} = ${_};${this.opts._n}`}else if(_=f?.(b))h=(0,eA._)`${h}${_}${this.opts._n}`;else throw new tl(b);E.set(b,Ho.Completed)})}return h}};tA.ValueScope=Al});var Ge=ge(Je=>{"use strict";Object.defineProperty(Je,"__esModule",{value:!0});Je.or=Je.and=Je.not=Je.CodeGen=Je.operators=Je.varKinds=Je.ValueScopeName=Je.ValueScope=Je.Scope=Je.Name=Je.regexpCode=Je.stringify=Je.getProperty=Je.nil=Je.strConcat=Je.str=Je._=void 0;var et=Cs(),EA=rl(),Nr=Cs();Object.defineProperty(Je,"_",{enumerable:!0,get:function(){return Nr._}});Object.defineProperty(Je,"str",{enumerable:!0,get:function(){return Nr.str}})