holosphere 1.1.15 → 1.1.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,9 @@
1
1
  /**
2
- * HoloSphere ESM Bundle v1.1.15
2
+ * HoloSphere ESM Bundle v1.1.16
3
3
  * ES6 Module version with all dependencies bundled
4
4
  *
5
5
  * Usage:
6
- * import HoloSphere from 'https://unpkg.com/holosphere@1.1.15/holosphere-bundle.esm.js';
6
+ * import HoloSphere from 'https://unpkg.com/holosphere@1.1.16/holosphere-bundle.esm.js';
7
7
  * const hs = new HoloSphere('myapp');
8
8
  */
9
9
  var __create = Object.create;
@@ -32650,7 +32650,7 @@ function userName(holoInstance, holonId) {
32650
32650
  }
32651
32651
 
32652
32652
  // holosphere.js
32653
- var HOLOSPHERE_VERSION = "1.1.15";
32653
+ var HOLOSPHERE_VERSION = "1.1.16";
32654
32654
  var HoloSphere = class {
32655
32655
  /**
32656
32656
  * Initializes a new instance of the HoloSphere class.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * HoloSphere Bundle v1.1.15
2
+ * HoloSphere Bundle v1.1.16
3
3
  * Holonic Geospatial Communication Infrastructure
4
4
  *
5
5
  * Includes:
@@ -9,7 +9,7 @@
9
9
  * - Ajv (JSON schema validation)
10
10
  *
11
11
  * Usage:
12
- * <script src="https://unpkg.com/holosphere@1.1.15/holosphere-bundle.js"></script>
12
+ * <script src="https://unpkg.com/holosphere@1.1.16/holosphere-bundle.js"></script>
13
13
  * <script>
14
14
  * const hs = new HoloSphere('myapp');
15
15
  * </script>
@@ -32673,7 +32673,7 @@ ${str(snapshot)}`);
32673
32673
  }
32674
32674
 
32675
32675
  // holosphere.js
32676
- var HOLOSPHERE_VERSION = "1.1.15";
32676
+ var HOLOSPHERE_VERSION = "1.1.16";
32677
32677
  var HoloSphere = class {
32678
32678
  /**
32679
32679
  * Initializes a new instance of the HoloSphere class.
@@ -1,4 +1,4 @@
1
- /* HoloSphere Bundle v1.1.15 - Holonic Geospatial Communication Infrastructure */
1
+ /* HoloSphere Bundle v1.1.16 - Holonic Geospatial Communication Infrastructure */
2
2
  var HoloSphere=(()=>{var f1=Object.create;var As=Object.defineProperty;var c1=Object.getOwnPropertyDescriptor;var d1=Object.getOwnPropertyNames;var h1=Object.getPrototypeOf,p1=Object.prototype.hasOwnProperty;var zf=(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 pe=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),m1=(n,e)=>{for(var i in e)As(n,i,{get:e[i],enumerable:!0})},Jf=(n,e,i,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let u of d1(e))!p1.call(n,u)&&u!==i&&As(n,u,{get:()=>e[u],enumerable:!(s=c1(e,u))||s.enumerable});return n};var Ka=(n,e,i)=>(i=n!=null?f1(h1(n)):{},Jf(e||!n||!n.__esModule?As(i,"default",{value:n,enumerable:!0}):i,n)),g1=n=>Jf(As({},"__esModule",{value:!0}),n);var Xc=pe((oC,Q0)=>{(function(){function n(i,s){return s?zf(i):i.slice?n[u(i)]:function(d,m){i(d={exports:{}}),n[u(m)]=d.exports};function u(d){return d.split("/").slice(-1).toString().replace(".js","")}}if(typeof Q0<"u")var e=Q0;n(function(i){String.random=function(u,d){var m="";for(u=u||24,d=d||"0123456789ABCDEFGHIJKLMNOPQRSTUVWXZabcdefghijklmnopqrstuvwxyz";u-- >0;)m+=d.charAt(Math.floor(Math.random()*d.length));return m},String.match=function(u,d){var m,y;return typeof u!="string"?!1:(typeof d=="string"&&(d={"=":d}),d=d||{},m=d["="]||d["*"]||d[">"]||d["<"],u===m?!0:y!==d["="]?!1:(m=d["*"]||d[">"],u.slice(0,(m||"").length)===m?!0:y!==d["*"]?!1:y!==d[">"]&&y!==d["<"]?u>=d[">"]&&u<=d["<"]:y!==d[">"]&&u>=d[">"]||y!==d["<"]&&u<=d["<"]))},String.hash=function(u,d){if(typeof u=="string"){if(d=d||0,!u.length)return d;for(var m=0,y=u.length,E;m<y;++m)E=u.charCodeAt(m),d=(d<<5)-d+E,d|=0;return d}};var s=Object.prototype.hasOwnProperty;Object.plain=function(u){return u?u instanceof Object&&u.constructor===Object||Object.prototype.toString.call(u).match(/^\[object (\w+)\]$/)[1]==="Object":!1},Object.empty=function(u,d){for(var m in u)if(s.call(u,m)&&(!d||d.indexOf(m)==-1))return!1;return!0},Object.keys=Object.keys||function(u){var d=[];for(var m in u)s.call(u,m)&&d.push(m);return d},function(){var u,d=setTimeout,m=0,y=0,E=typeof setImmediate!=""+u&&setImmediate||function(w,v){return typeof MessageChannel==""+u?d:((w=new MessageChannel).port1.onmessage=function($){$.data==""&&v()},function($){v=$,w.port2.postMessage("")})}(),b=d.check=d.check||typeof performance!=""+u&&performance||{now:function(){return+new Date}};d.hold=d.hold||9,d.poll=d.poll||function(w){if(d.hold>=b.now()-m&&y++<3333){w();return}E(function(){m=b.now(),w()},y=0)}}(),function(){var u=setTimeout,d=u.turn=u.turn||function(v){m.push(v)==1&&y(w)},m=d.s=[],y=u.poll,E=0,b,w=function(){(b=m[E++])&&b(),(E==m.length||E==99)&&(m=d.s=m.slice(E),E=0),m.length&&y(w)}}(),function(){var u,d=setTimeout,m=d.turn;(d.each=d.each||function(y,E,b,w){w=w||9,function v($,S,x){if(S=($=(y||[]).splice(0,w)).length){for(var k=0;k<S&&u===(x=E($[k]));k++);if(u===x){m(v);return}}b&&b(x)}()})()}()})(n,"./shim"),n(function(i){i.exports=function s(b,d,m){if(!b)return{to:s};var y,E=typeof d=="function",b=(this.tag||(this.tag={}))[b]||E&&(this.tag[b]={tag:b,to:s._={next:function(v){var $;($=this.to)&&$.next(v)}}});if(E){var w={off:s.off||(s.off=function(){if(this.next===s._.next)return!0;this===this.the.last&&(this.the.last=this.back),this.to.back=this.back,this.next=s._.next,this.back.to=this.to,this.the.last===this.the&&delete this.on.tag[this.the.tag]}),to:s._,next:d,the:b,on:this,as:m};return(w.back=b.last||b).to=w,b.last=w}return(b=b.to)&&y!==d&&b.next(d),b}})(n,"./onto"),n(function(i){i.exports=function(s){return s===null||typeof s=="string"||typeof s=="boolean"||typeof s=="number"&&s!=1/0&&s!=-1/0&&s===s||!!s&&typeof s["#"]=="string"&&Object.keys(s).length===1&&s["#"]}})(n,"./valid"),n(function(i){n("./shim");function s(){var b=+new Date;return y<b?(d=0,y=b+s.drift):y=b+(d+=1)/m+s.drift}s.drift=0;var u=-1/0,d=0,m=999,y=u,E;s.is=function(b,w,v){var $=w&&b&&b._&&b._[">"]||v;if($)return typeof($=$[w])=="number"?$:u},s.ify=function(b,w,v,$,S){(b=b||{})._=b._||{},S&&(b._["#"]=S);var x=b._[">"]||(b._[">"]={});return E!==w&&w!=="_"&&(typeof v=="number"&&(x[w]=v),E!==$&&(b[w]=$)),b},i.exports=s})(n,"./state"),n(function(i){n("./shim");function s(u){var d={s:{}},m=d.s;u=u||{max:999,age:1e3*9},d.check=function(E){return m[E]?y(E):!1};var y=d.track=function(E){var b=m[E]||(m[E]={});return b.was=d.now=+new Date,d.to||(d.to=setTimeout(d.drop,u.age+9)),y.ed&&y.ed(E),b};return d.drop=function(E){d.to=null,d.now=+new Date;var b=Object.keys(m);console.STAT&&console.STAT(d.now,+new Date-d.now,"dup drop keys"),setTimeout.each(b,function(w){var v=m[w];v&&(E||u.age)>d.now-v.was||delete m[w]},0,99)},d}i.exports=s})(n,"./dup"),n(function(i){n("./onto"),i.exports=function(d,m){if(this.on){var y=(this.opt||{}).lack||9e3;if(typeof d!="function"){if(!d)return;var b=d["#"]||d,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["#"]||s(9);if(!d)return b;var w=this.on(b,d,m);return w.err=w.err||setTimeout(function(){w.off(),w.next({err:"Error: No ACK yet.",lack:!0})},y),b}};var s=String.random||function(){return Math.random().toString(36).slice(2)}})(n,"./ask"),n(function(i){function s(S){return S instanceof s?(this._={$:this}).$:this instanceof s?s.create(this._={$:this,opt:S}):new s(S)}s.is=function(S){return S instanceof s||S&&S._&&S===S._.$||!1},s.version=.202,s.chain=s.prototype,s.chain.toJSON=function(){},n("./shim"),s.valid=n("./valid"),s.state=n("./state"),s.on=n("./onto"),s.dup=n("./dup"),s.ask=n("./ask"),function(){s.create=function(R){R.root=R.root||R,R.graph=R.graph||{},R.on=R.on||s.on,R.ask=R.ask||s.ask,R.dup=R.dup||s.dup();var M=R.$.opt(R.opt);return R.once||(R.on("in",S,R),R.on("out",S,R),R.on("put",B,R),s.on("create",R),R.on("create",R)),R.once=1,M};function S(R){if(R){if(R.out===S){this.to.next(R);return}var M=this,Q=M.as,X=Q.at||Q,ne=X.$,Ae=X.dup,te,de=R.DBG;if((te=R["#"])||(te=R["#"]=d(9)),!Ae.check(te)){if(Ae.track(te),te=R._,R._=typeof te=="function"?te:function(){},R.$&&R.$===(R.$._||"").$||(R.$=ne),R["@"]&&!R.put&&I(R),!X.ask(R["@"],R))if(de&&(de.u=+new Date),R.put){x(R);return}else R.get&&s.on.get(R,ne);de&&(de.uc=+new Date),M.to.next(R),de&&(de.ua=+new Date),!(R.nts||R.NTS)&&(R.out=S,X.on("out",R),de&&(de.ue=+new Date))}}}function x(R){if(R){var M=R._||"",Q=M.root=((M.$=R.$||"")._||"").root;if(R["@"]&&M.faith&&!M.miss){R.out=S,Q.on("out",R);return}M.latch=Q.hatch,M.match=Q.hatch=[];var X=R.put,ne=M.DBG=R.DBG,Ae=+new Date;if(le=le||Ae,!(X["#"]&&X["."])){ne&&(ne.p=Ae),M["#"]=R["#"],M.msg=R,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 de=0,me,ve,De,At,Ke,ze,gt;(function JA(CA){if(me!=de){if(me=de,!(De=te[de])){console.STAT&&console.STAT(Ae,((ne||M).pd=+new Date)-Ae,"put"),O(M);return}(At=X[De])?(gt=At._)?De!==gt["#"]?ze=q+V(De)+"soul not same.":(Ke=gt[">"])||(ze=q+V(De)+"no state."):ze=q+V(De)+"no meta.":ze=q+V(De)+"no node.",ve=Object.keys(At||{})}if(ze){R.err=M.err=ze,O(M);return}var sA=0,aA;for(CA=CA||0;CA++<9&&(aA=ve[sA++]);)if(aA!=="_"){var SA=At[aA],DA=Ke[aA];if(w===DA){ze=q+V(aA)+"on"+V(De)+"no state.";break}if(!y(SA)){ze=q+V(aA)+"on"+V(De)+"bad "+typeof SA+V(SA);break}k(SA,aA,De,DA,R),++J}if((ve=ve.slice(sA)).length){m(JA);return}++de,ve=null,JA(CA)})()}}}s.on.put=x;function k(R,M,Q,X,ne){var Ae=ne._||"",te=Ae.root,de=te.graph,me,ve,De=de[Q]||v,At=E(De,M,1),Ke=De[M],ze=Ae.DBG;(ve=console.STAT)&&(!de[Q]||!Ke)&&(ve.has=(ve.has||0)+1);var gt=L(),JA;if(X>gt){setTimeout(function(){k(R,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&&(R===Ke||z(R)<=z(Ke))&&!Ae.miss)){Ae.stun++;var CA=ne["#"]+Ae.all++,sA={toString:function(){return CA},_:Ae};sA.toJSON=sA.toString,te.dup.track(sA)["#"]=ne["#"],ze&&(ze.ph=ze.ph||+new Date),te.on("put",{"#":sA,"@":ne["@"],put:{"#":Q,".":M,":":R,">":X},ok:ne.ok,_:Ae})}}function B(R){var M;(M=(R._||"").DBG)&&(M.pa=+new Date,M.pm=M.pm||+new Date);var Q=this,X=Q.as,ne=X.graph,Ae=R._,te=R.put,de=te["#"],me=te["."],ve=te[":"],De=te[">"],At=R["#"],Ke;(Ke=Ae.msg)&&(Ke=Ke.put)&&(Ke=Ke[de])&&b(Ke,me,De,ve,de),ne[de]=b(ne[de],me,De,ve,de),(Ke=(X.next||"")[de])&&Ke.on("in",R),O(Ae),Q.to.next(R)}function O(R,M){var Q;if(!R.stop&&!(!R.err&&0<--R.stun)&&(R.stop=1,!!(Q=R.root))){var X=R.match;X.end=1,X===Q.hatch&&(!(X=R.latch)||X.end?delete Q.hatch:Q.hatch=X),R.hatch&&R.hatch(),setTimeout.each(R.match,function(ne){ne&&ne()}),!(!(M=R.msg)||R.err||M.err)&&(M.out=S,R.root.on("out",M),ae())}}function I(R){var M=R["@"]||"",Q,X,ne;if(!(Q=M._)){var Ae=(Ae=R.$)&&(Ae=Ae._)&&(Ae=Ae.root)&&(Ae=Ae.dup);if(!(Ae=Ae.check(M)))return;R["@"]=Ae["#"]||R["@"];return}Q.acks=(Q.acks||0)+1,(Q.err=R.err)&&(R["@"]=Q["#"],O(Q)),Q.ok=R.ok||Q.ok,!Q.stop&&!Q.crack&&(Q.crack=Q.match&&Q.match.push(function(){U(Q)})),U(Q)}function U(R){!R||!R.root||R.stun||R.acks!==R.all||R.root.on("in",{"@":R["#"],err:R.err,ok:R.err?w:R.ok||{"":1}})}var q="Error: Invalid graph!",V=function(R){return" '"+(""+R).slice(0,9)+"...' "},z=JSON.stringify,re=2147483647,L=s.state,J=0,le,ae=function(){J>999&&J/-(le-(le=+new Date))>1&&(s.window&&console.log("Warning: You're syncing 1K+ records a second, faster than DOM can update - consider limiting query."),ae=function(){J=0})}}(),function(){s.on.get=function(x,k){var B=k._,O=x.get,I=O["#"],U=B.graph[I],q=O["."],V=B.next||(B.next={}),z=V[I],re=x._||{},L=re.DBG=x.DBG;if(L&&(L.g=+new Date),!U)return B.on("get",x);if(q){if((typeof q!="string"||w===U[q])&&!((z||"").next||"")[q]){B.on("get",x);return}U=b({},q,E(U,q),U[q],I)}U&&S(x,U),B.on("get",x)};function S(x,k){var B=+new Date,O=x._||{},I=O.DBG=x.DBG,U=x["#"],q=d(9),V=Object.keys(k||"").sort(),z=((k||"")._||"")["#"],re=V.length,L=0,J=x.$._.root,le=k===J.graph[z];console.STAT&&console.STAT(B,((I||O).gk=+new Date)-B,"got keys"),k&&function ae(){B=+new Date;for(var R=0,M,Q={},X;R<9&&(M=V[R++]);)b(Q,M,E(k,M),k[M],z);V=V.slice(R),(X={})[z]=Q,Q=X;var ne;le&&(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",{"@":U,"#":q,put:Q,"%":X?q=d(9):w,$:J.$,_:ne,DBG:I,FOO:1}),console.STAT&&console.STAT(B,+new Date-B,"got in"),X&&setTimeout.turn(ae)}(),k||J.on("in",{"@":x["#"]})}s.on.get.ack=S}(),function(){s.chain.opt=function(S){S=S||{};var x=this,k=x._,B=S.peers||S;return Object.plain(S)||(S={}),Object.plain(k.opt)||(k.opt=S),typeof B=="string"&&(B=[B]),Object.plain(k.opt.peers)||(k.opt.peers={}),B instanceof Array&&(S.peers={},B.forEach(function(O){var I={};I.id=I.url=O,S.peers[O]=k.opt.peers[O]=k.opt.peers[O]||I})),u(S,function O(I){var U=this[I];if(this&&this.hasOwnProperty(I)||typeof U=="string"||Object.empty(U)){this[I]=U;return}U&&U.constructor!==Object&&!(U instanceof Array)||u(U,O)}),k.opt.from=S,s.on("opt",k),k.opt.uuid=k.opt.uuid||function(I){return s.state().toString(36).replace(".","")+String.random(I||12)},x}}();var u=function(S,x){Object.keys(S).forEach(x,S)},d=String.random,m=setTimeout.turn,y=s.valid,E=s.state.is,b=s.state.ify,w,v={},$;s.log=function(){return!s.log.off&&$.log.apply($,arguments),[].slice.call(arguments).join(" ")},s.log.once=function(S,x,k){return(k=s.log.once)[S]=k[S]||0,k[S]++||s.log(x)},typeof window<"u"&&((window.GUN=window.Gun=s).window=window);try{typeof e<"u"&&(e.exports=s)}catch{}i.exports=s,(s.window||{}).console=(s.window||{}).console||{log:function(){}},($=console).only=function(S,x){return $.only.i&&S===$.only.i&&$.only.i++&&($.log.apply($,arguments)||x)},s.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 s=n("./root");s.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,w=b._;if(typeof m=="string"&&(m=m.split(".")),m instanceof Array){var v=0,$=m.length,E=w;for(v;v<$;v++)E=(E||u)[m[v]];return d!==E?y?b:E:(E=w.back)?E.$.back(m,y):void 0}if(typeof m=="function"){for(var S,E={back:w};(E=E.back)&&d===(S=m(E,y)););return S}return typeof m=="number"?(w.back||w).$.back(m-1):this};var u={},d})(n,"./back"),n(function(i){var s=n("./root");s.chain.chain=function(O){var I=this,U=I._,q=new(O||I).constructor(I),V=q._,z;return V.root=z=U.root,V.id=++z.once,V.back=I._,V.on=s.on,V.on("in",s.on.in,V),V.on("out",s.on.out,V),q};function u(O){var I,U,q=this.as,V=q.back,z=q.root,re;if(O.$||(O.$=q.$),this.to.next(O),q.err){q.on("in",{put:q.put=w,$:q.$});return}if(U=O.get){if(z.pass&&(z.pass[q.id]=q),q.lex&&Object.keys(q.lex).forEach(function(L){re[L]=q.lex[L]},re=O.get=O.get||{}),U["#"]||q.soul){if(U["#"]=U["#"]||q.soul,O["#"]||(O["#"]=v(9)),V=z.$.get(U["#"])._,U=U["."]){if(S(V.put,U)&&(re=V.ask&&V.ask[U],(V.ask||(V.ask={}))[U]=V.$.get(U)._,V.on("in",{get:U,put:{"#":V.soul,".":U,":":V.put[U],">":k(z.graph[V.soul],U)}}),re))return}else{if(re=V.ask&&V.ask[""],(V.ask||(V.ask={}))[""]=V,w!==V.put&&(V.on("in",V),re))return;O.$=V.$}return z.ask(E,O),z.on("in",O)}if(U["."])return q.get?(O={get:{".":q.get},$:q.$},(V.ask||(V.ask={}))[q.get]=O.$._,V.on("out",O)):(O={get:q.lex?O.get:{},$:q.$},V.on("out",O));if((q.ask||(q.ask={}))[""]=q,q.get)return U["."]=q.get,(V.ask||(V.ask={}))[q.get]=O.$._,V.on("out",O)}return V.on("out",O)}s.on.out=u;function d(O,I){I=I||this.as;var U=I.root,q=O.$||(O.$=I.$),V=(q||"")._||b,z=O.put||"",re=z["#"],L=z["."],J=w!==z["="]?z["="]:z[":"],le=z[">"]||-1/0,ae;if(w!==O.put&&(w===z["#"]||w===z["."]||w===z[":"]&&w===z["="]||w===z[">"])){if(!$(z)){if(!(re=((z||"")._||"")["#"])){console.log("chain not yet supported for",z,"...",O,I);return}return q=I.root.$.get(re),setTimeout.each(Object.keys(z).sort(),function(R){R=="_"||w===(le=k(z,R))||I.on("in",{$:q,put:{"#":re,".":R,"=":z[R],">":le},VIA:O})})}I.on("in",{$:V.back.$,put:{"#":re=V.back.soul,".":L=V.has||V.get,"=":z,">":k(V.back.put,L)},via:O});return}(O.seen||"")[I.id]||((O.seen||(O.seen=function(){}))[I.id]=I,I!==V&&(Object.keys(O).forEach(function(R){z[R]=O[R]},z={}),z.get=I.get||z.get,!I.soul&&!I.has?z.$$$=z.$$$||I.$:V.soul&&(z.$=I.$,z.$$=z.$$||V.$),O=z),y(O,I),(I.soul||O.$$)&&le>=k(U.graph[re],L)&&((z=U.$.get(re)._).put=B(z.put,L,le,J,re)),!V.soul&&le>=k(U.graph[re],L)&&(ae=(U.$.get(re)._.next||"")[L])&&(ae.put=J,typeof(z=$(J))=="string"&&(ae.put=U.$.get(z)._.put||J)),this.to&&this.to.next(O),I.any&&setTimeout.each(Object.keys(I.any),function(R){(R=I.any[R])&&R(O)},0,99),I.echo&&setTimeout.each(Object.keys(I.echo),function(R){(R=I.echo[R])&&R.on("in",O)},0,99),((O.$$||"")._||V).soul&&(ae=I.next)&&(ae=ae[L])&&(z={},Object.keys(O).forEach(function(R){z[R]=O[R]}),z.$=(O.$$||O.$).get(z.get=L),delete z.$$,delete z.$$$,ae.on("in",z)),m(O,I))}s.on.in=d;function m(O,I){if(I=I||this.as||O.$._,!(O.$$&&this!==s.on)&&!(!O.put||I.soul)){var U=O.put||"",q=U["="]||U[":"],L,V=I.root,z=V.$.get(U["#"]).get(U["."])._;if(typeof(q=$(q))!="string"){this===s.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[q+I.id])return;L[q+I.id]=1}(z.echo||(z.echo={}))[I.id]=I,I.has&&(I.link=q);var re=V.$.get(z.link=q)._;(re.echo||(re.echo={}))[z.id]=z;var L=I.ask||"";(L[""]||I.lex)&&re.on("out",{get:{"#":q}}),setTimeout.each(Object.keys(L),function(J,le){!J||!(le=L[J])||le.on("out",{get:{"#":q,".":J}})},0,99)}}}s.on.link=m;function y(O,I){var U=O.put||"",q=w!==U["="]?U["="]:U[":"],V=I.root,z,re;if(w===q){if(I.soul&&w!==I.put||(re=(O.$$||O.$||"")._||"",O["@"]&&(w!==re.put||w!==I.put)))return;(z=I.link||O.linked)&&delete(V.$.get(z)._.echo||"")[I.id],I.has&&(I.link=null),I.put=w,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:w,$:J.$}))},0,99);return}I.soul||O.$$||(z=$(q),re=O.$._||"",!((z===re.link||I.has&&!re.link)&&!((V.pass||"")[I.id]&&typeof z!="string"))&&(delete(re.echo||"")[I.id],y({get:I.get,put:w,$:O.$,linked:O.linked=O.linked||re.link},I)))}s.on.unlink=y;function E(O,I){var U=this.as,q=U.$._,V=q.root,z=U.get||"",re=(O.put||"")[z["#"]]||"";if(!O.put||typeof z["."]=="string"&&w===re[z["."]]){if(w!==q.put||!q.soul&&!q.has)return;q.ack=(q.ack||0)+1,q.on("in",{get:q.get,put:q.put=w,$:q.$,"@":O["@"]});return}(O._||{}).miss=1,s.on.put(O)}var b={},w,v=String.random,$=s.valid,S=function(O,I){return O&&Object.prototype.hasOwnProperty.call(O,I)},x=s.state,k=x.is,B=x.ify})(n,"./chain"),n(function(i){var s=n("./root");s.chain.get=function(w,v,$){var S,x;if(typeof w=="string"){if(w.length==0)return(S=this.chain())._.err={err:s.log("0 length key!",w)},v&&v.call(S,S._.err),S;var k=this,B=k._,O=B.next||y;(S=O[w])||(S=w&&u(w,k)),S=S&&S.$}else if(typeof w=="function"){let L=function(J,le,ae){if(!L.stun&&!((te=U.pass)&&!te[q])){var R=J.$._,M=(J.$$||"")._,Q=(M||R).put,X=!R.has&&!R.soul,ne={},Ae,te;if((X||b===Q)&&(Q=b===((te=J.put)||"")["="]?b===(te||"")[":"]?te:te[":"]:te["="]),(Ae=typeof(te=s.valid(Q))=="string")&&(Q=b===(te=U.$.get(te)._.put)?I.not?b:Q:te),!(I.not&&b===Q)){if(b===I.stun){if((te=U.stun)&&te.on&&(B.$.back(function(de){if(te.on(""+de.id,ne={}),(ne.run||0)<L.id)return ne}),!ne.run&&te.on(""+R.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={}))[q]=function(){L(J,le,1)};return}if(b===Q&&(ae=0),(te=U.hatch)&&!te.end&&b===I.hatch&&!ae){if(V[R.$._.id])return;V[R.$._.id]=1,te.push(function(){L(J,le,1)});return}V={}}if(U.pass){if(U.pass[q+R.id])return;U.pass[q+R.id]=1}if(I.on){I.ok.call(R.$,Q,R.get,J,le||L);return}if(I.v2020){I.ok(J,le||L);return}Object.keys(J).forEach(function(de){te[de]=J[de]},te={}),J=te,J.put=Q,I.ok.call(I.as,J,le||L)}}};var z=L;if(v===!0)return d(this,w,v,$),this;S=this;var B=S._,I=v||{},U=B.root,q;I.at=B,I.ok=w;var V={};return L.at=B,(B.any||(B.any={}))[q=String.random(7)]=L,L.off=function(){L.stun=1,B.any&&delete B.any[q]},L.rid=m,L.id=I.run||++U.once,x=U.pass,(U.pass={})[q]=1,I.out=I.out||{get:{}},B.on("out",I.out),U.pass=x,S}else{if(typeof w=="number")return this.get(""+w,v,$);if(typeof(x=E(w))=="string")return this.get(x,v,$);(x=this.get.next)&&(S=x(this,w))}return S?(v&&typeof v=="function"&&S.get(v,$),S):((S=this.chain())._.err={err:s.log("Invalid get request!",w)},v&&v.call(S,S._.err),S)};function u(w,v){var $=v._,S=$.next,x=v.chain(),k=x._;return S||(S=$.next={}),S[k.get=w]=k,v===$.root.$?k.soul=w:($.soul||$.has)&&(k.has=w),k}function d(w,v,$,S){var x=w._,k=0,B;return(B=x.soul||x.link)?v(B,S,x):x.jam?x.jam.push([v,S]):(x.jam=[[v,S]],w.get(function(I,U){if(!(b===I.put&&!x.root.opt.super&&(B=Object.keys(x.root.opt.peers).length)&&++k<=B)){U.rid(I);var q=(q=I.$)&&q._||{},V=0,z;for(B=x.jam,delete x.jam;z=B[V++];){var re=z[0],L;z=z[1],re&&re(L=q.link||q.soul||s.valid(I.put)||((I.put||{})._||{})["#"],z,I,U)}}},{out:{get:{".":!0}}}),w)}function m(w){var v=this.at||this.on;if(!w||v.soul||v.has)return this.off();if(w=(w=(w=w.$||w)._||w).id){var $=v.map,S,x;if(S=(x=this.seen||(this.seen={}))[w])return!0;x[w]=!0}}var y={},E=s.valid,b})(n,"./get"),n(function(i){var s=n("./root");s.chain.put=function(k,B,O){var I=this,U=I._,q=U.root;O=O||{},O.root=U.root,O.run||(O.run=q.once),u(O,U.id),O.ack=O.ack||B,O.via=O.via||I,O.data=O.data||k,O.soul||(O.soul=U.soul||typeof B=="string"&&B);var V=O.state=O.state||s.state();return typeof k=="function"?(k(function(z){O.data=z,I.put(E,E,O)}),I):O.soul?(O.$=q.$.get(O.soul),O.todo=[{it:O.data,ref:O.$}],O.turn=O.turn||v,O.ran=O.ran||d,function z(){var re=O.todo,L=re.pop(),J=L.it,le=L.ref&&L.ref._.id,ae,R,M,Q,X;if(u(O,L.ref),(Q=L.todo)&&(R=Q.pop(),J=J[R],Q.length&&re.push(L)),R&&(re.path||(re.path=[])).push(R),!(ae=$(J))&&!(X=s.is(J))){if(!Object.plain(J)){d.err(O,"Invalid data: "+y(J)+" at "+(O.via.back(function(me){me.get&&Q.push(me.get)},Q=[])||Q.join("."))+"."+(re.path||[]).join("."));return}for(var ne=O.seen||(O.seen=[]),Ae=ne.length;Ae--;)if(J===(Q=ne[Ae]).it){ae=J=Q.link;break}}if(R&&ae)L.node=S(L.node,R,V,J);else{let me=function(ve,De){var At=M.link["#"];De&&(De.off(),De.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&&u(O,ve.$),!Ke&&!L.link["#"]){(L.wait||(L.wait=[])).push(function(){me(ve,De)});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&&(((O.graph||(O.graph={}))[Ke]=M.node||(M.node={_:{}}))._["#"]=Ke),delete O.wait[te],M.wait&&setTimeout.each(M.wait,function(ze){ze&&ze()}),O.ran(O)};var de=me;if(!O.seen){d.err(O,"Data at root of graph must be a node (an object).");return}O.seen.push(M={it:J,link:{},todo:X?[]:Object.keys(J).sort().reverse(),path:(re.path||[]).slice(),up:L}),L.node=S(L.node,R,V,M.link),!X&&M.todo.length&&re.push(M);var te=O.seen.length;(O.wait||(O.wait={}))[te]="",Q=(M.ref=X?J:R?L.ref.get(R):L.ref)._,(Q=J&&(J._||"")["#"]||Q.soul||Q.link)?me({soul:Q}):M.ref.get(me,{run:O.run,v2020:1,out:{get:{".":" "}}})}if(!re.length)return O.ran(O);O.turn(z)}(),I):(m(O),I)};function u(k,B){if(B){B=(B._||"").id||B;var O=k.root.stun||(k.root.stun={on:s.on}),I={},U;k.stun||(k.stun=O.on("stun",function(){})),(U=O.on(""+B))&&U.the.last.next(I),!(I.run>=k.run)&&O.on(""+B,function(q){if(k.stun.end){this.off(),this.to.next(q);return}q.run=q.run||k.run,q.stun=q.stun||k.stun})}}function d(k){if(k.err){d.end(k.stun,k.root);return}if(!(k.todo.length||k.end||!Object.empty(k.wait))){k.end=1;var B=k.$.back(-1)._,O=B.root,I=B.ask(function(z){O.on("ack",z),z.err&&!z.lack&&s.log(z),++U>(k.acks||0)&&this.off(),k.ack&&k.ack(z,this)},k.opt),U=0,q=k.stun,V;(V=function(){q&&(d.end(q,O),setTimeout.each(Object.keys(q=q.add||""),function(z){(z=q[z])&&z()}))}).hatch=V,k.ack&&!k.ok&&(k.ok=k.acks||9),k.via._.on("out",{put:k.out=k.graph,ok:k.ok&&{"@":k.ok+1},opt:k.opt,"#":I,_:V})}}d.end=function(k,B){k.end=w,k.the.to===k&&k===k.the.last&&delete B.stun,k.off()},d.err=function(k,B){(k.ack||w).call(k,k.out={err:k.err=s.log(B)}),k.ran(k)};function m(k){var B=k.via._,O;k.via=k.via.back(function(I){if(I.soul||!I.get)return I.$;O=k.data,(k.data={})[I.get]=O}),(!k.via||!k.via._.soul)&&(k.via=B.root.$.get(((k.data||"")._||"")["#"]||B.$.back("opt.uuid")())),k.via.put(k.data,k.ack,k)}function y(k,B){return k&&(B=k.constructor)&&B.name||typeof k}var E,b={},w=function(){},v=setTimeout.turn,$=s.valid,S=s.state.ify,x=function(k,B){k.call(B||b)}})(n,"./put"),n(function(i){var s=n("./root");n("./chain"),n("./back"),n("./put"),n("./get"),i.exports=s})(n,"./index"),n(function(i){var s=n("./index");s.chain.on=function(E,b,w,v){var $=this,S=$._,x=S.root,k,B,O,I;if(typeof E=="string")return b?(k=S.on(E,b,w||S,v),w&&w.$&&(w.subs||(w.subs=[])).push(k),$):S.on(E);var U=b;(U=U===!0?{change:!0}:U||{}).not=1,U.on=1;var q={};return $.get(E,U),$},s.chain.once=function(E,b){if(b=b||{},!E)return u(this,b);var w=this,v=w._,$=v.root,S=v.put,x=String.random(7),k,B;return w.get(function(O,I,U,q){var V=this,z=V._,re=z.one||(z.one={});if(q.stun||re[x]==="")return;if((B=s.valid(O))===!0){L();return}if(typeof B=="string")return;clearTimeout((v.one||"")[x]),clearTimeout(re[x]),re[x]=setTimeout(L,b.wait||99);function L(J){if(!z.has&&!z.soul&&(z={put:O,get:I}),y===(B=z.put)&&(B=((U.$$||"")._||"").put),typeof s.valid(B)=="string"&&(B=$.$.get(B)._.put,B===y&&!J)){re[x]=setTimeout(function(){L(1)},b.wait||99);return}q.stun||re[x]!==""&&(re[x]="",(v.soul||v.has)&&q.off(),E.call(V,B,z.get),clearTimeout(re[x]))}},{on:1}),w};function u(E,b,w){return s.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."),(w=E.chain())._.nix=E.once(function(v,$){w._.on("in",this._)}),w._.lex=E._.lex,w}s.chain.off=function(){var E=this,b=E._,w,v=b.back;if(v)return b.ack=0,(w=v.next)&&w[b.get]&&delete w[b.get],(w=v.any)&&(delete v.any,v.any={}),(w=v.ask)&&delete w[b.get],(w=v.put)&&delete w[b.get],(w=b.soul)&&delete v.root.graph[w],(w=b.map)&&Object.keys(w).forEach(function($,S){S=w[$],S.link&&v.root.$.get(S.link).off()}),(w=b.next)&&Object.keys(w).forEach(function($,S){S=w[$],S.$.off()}),b.on("off",{}),E};var d={},m=function(){},y})(n,"./on"),n(function(i){var s=n("./index"),u=s.chain.get.next;s.chain.get.next=function(b,w){var v;return Object.plain(w)?(v=((v=w["#"])||"")["="]||v)?b.get(v):((v=b.chain()._).lex=w,b.on("in",function($){String.match($.get||($.put||"")["."],w["."]||w["#"]||w)&&v.on("in",$),this.to.next($)}),v.$):(u||m)(b,w)},s.chain.map=function(b,w,v){var $=this,S=$._,x,k;return Object.plain(b)&&(x=b["."]?b:{".":b},b=E),b?(s.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."),k=$.chain(),$.map().on(function(B,O,I,U){var q=(b||m).call(this,B,O,I,U);if(E!==q){if(B===q)return k._.on("in",I);if(s.is(q))return k._.on("in",q._);var V={};Object.keys(I.put).forEach(function(z){V[z]=I.put[z]},V),V["="]=q,k._.on("in",{get:O,put:V})}}),k):((k=S.each)||((S.each=k=$.chain())._.lex=x||k._.lex||S.lex,k._.nix=$.back("nix"),$.on("in",d,k._)),k)};function d(b){this.to.next(b);var w=this.as,v=b.$,$=v._,S=b.put,x;!$.soul&&!b.$$||(x=w.lex)&&!String.match(b.get||(S||"")["."],x["."]||x["#"]||x)||s.on.link(b,w)}var m=function(){},y={stun:m,off:m},E})(n,"./map"),n(function(i){var s=n("./index");s.chain.set=function(u,d,m){var y=this,E=y.back(-1),b,w;return d=d||function(){},m=m||{},m.item=m.item||u,(b=((u||"")._||"")["#"])&&((u={})["#"]=b),typeof(w=s.valid(u))=="string"?y.get(b=w).put(u,d,m):s.is(u)?(y.put(function(v){u.get(function($,S,x){if(!$)return d.call(y,{err:s.log('Only a node can be linked! Not "'+x.put+'"!')});(w={})[$]={"#":$},v(w)},!0)}),u):(Object.plain(u)&&(u=E.get(b=y.back("opt.uuid")()).put(u)),y.get(b||E.back("opt.uuid")(7)).put(u,d,m))}})(n,"./set"),n(function(i){n("./shim");var s=function(){},u=JSON.parseAsync||function(w,v,$){var S,x=+new Date;try{v(S,JSON.parse(w,$),d.sucks(+new Date-x))}catch(k){v(k)}},d=JSON.stringifyAsync||function(w,v,$,S){var x,k=+new Date;try{v(x,JSON.stringify(w,$,S),d.sucks(+new Date-k))}catch(B){v(B)}};d.sucks=function(w){w>99&&(console.log("Warning: JSON blocking CPU detected. Add `gun/lib/yson.js` to fix."),d.sucks=s)};function m(w){var v=function(){},$=w.opt||{};$.log=$.log||console.log,$.gap=$.gap||$.wait||0,$.max=$.max||($.memory?$.memory*999*999:3e8)*.3,$.pack=$.pack||$.max*.01*.01,$.puff=$.puff||9;var S=setTimeout.turn||setTimeout,x=w.dup,k=x.check,B=x.track,O=+new Date,I=O,U=v.hear=function(L,J){if(L){if($.max<=L.length)return v.say({dam:"!",err:"Message too big!"},J);v===this&&(U.d+=L.length||0,++U.c);var le=J.SH=+new Date,ae=L[0],R;if(ae==="["){u(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=$.puff;(function ne(){for(var Ae=+new Date,te=0,de;te<X&&(de=Q[te++]);)v.hear(de,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))&&(R=L)){if(R)return U.one(R,J,le);u(L,function(M,Q){if(M||!Q)return v.say({dam:"!",err:"DAM JSON parse error."},J);U.one(Q,J,le)});return}}};U.one=function(L,J,ne){var ae,R,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=k(ae))&&(R=L["##"],!(R&&(M=L["@"]||L.get&&ae)&&x.check(Q=M+R)))){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,w),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=x.s[ae])&&(Ae.via=J,L.get&&(Ae.it=L)))},w.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 q=function(L,J,le){le(L,!0)};U.c=U.d=0,function(){var L=0,J;v.hash=function(M,Q){var X,ne,Ae,te=+new Date;d(M.put,function de(me,ve){var De=(ne||(ne=Ae=ve||"")).slice(0,32768);if(X=String.hash(De,X),ne=ne.slice(32768),ne){S(de,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},le)};function le(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 R=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,de=M["@"],me=M._||(M._=function(){}),ve=M.DBG,De=+new Date;if(me.y=me.y||De,Q||ve&&(ve.y=De),(ne=M["#"])||(ne=M["#"]=String.random(9)),!J&&B(ne),!(Ae=M["##"])&&b!==M.put&&!me.via&&de){v.hash(M,Q);return}if(!Q&&de&&(Q=(X=x.s[de])&&(X.via||(X=X.it)&&(X=X._)&&X.via)||(X=v.last)&&de===X["#"]&&v.leap),!Q&&de)return x.s[de]?void 0:(console.STAT&&console.STAT(+new Date,++L,"total no peer to ack to"),!1);if(de&&!M.put&&!Ae&&((x.s[de]||"").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||$.peers))return!1;var De=+new Date,At=$.puff,Ke=$.peers,ze=Object.keys(Q||$.peers||{});console.STAT&&console.STAT(De,+new Date-De,"peer keys"),function CA(){var sA=+new Date;J=1;var aA=me.raw;me.raw=te;for(var SA=0,DA;SA<9&&(DA=(ze||"")[SA++]);)(DA=Ke[DA]||(Q||"")[DA])&&v.say(M,DA);me.raw=aA,J=0,ze=ze.slice(SA),console.STAT&&console.STAT(sA,+new Date-sA,"say loop"),ze.length&&(S(CA,0),de&&B(de))}();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(De,((ve||me).yp=+new Date)-(me.y||De),"say prep"),!J&&de&&B(de),Q.batch){if(Q.tail=(X=Q.tail||0)+te.length,Q.tail<=$.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)},$.gap),z(te,Q),console.STAT&&de===Q.SI&&console.STAT(De,+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["##"],de=M["@"];if(te&&de){if(!X.via&&k(de+te))return!1;if(Ae=(x.s[de]||"").it){if(te===Ae["##"])return!1;Ae["##"]||(Ae["##"]=te)}}if(!M.dam&&!M["@"]){var me=0,ve=[];Ae=$.peers;for(var De in Ae){var At=Ae[De];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=":])([:",d(Ae,function(ze,gt){if(!ze){var JA=+new Date;Ae=gt.indexOf('"put":":])([:"'),Ke(b,gt=gt.slice(0,Ae+6)+ne+gt.slice(Ae+14)),console.STAT&&console.STAT(JA,+new Date-JA,"say slice")}});return}d(M,Ke);function Ke(ze,gt){ze||(X.raw=gt,v.say(M,Q))}}}();function V(L){var J=L.batch,le=typeof J=="string",ae;if(le&&(J+="]"),L.batch=L.tail=null,!!J&&!(le?3>J.length:!J.length)){if(!le)try{J=J.length===1?J[0]:JSON.stringify(J)}catch(R){return $.log("DAM JSON stringify error",R)}J&&z(J,L)}}function z(L,J){try{var le=J.wire;J.say?J.say(L):le.send&&le.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,le;if(!J){v.wire(L.length&&{url:L,id:L}||L);return}L.id?$.peers[L.url||L.id]=L:(le=L.id=L.id||L.url||String.random(9),v.say({dam:"?",pid:w.opt.pid},$.peers[le]=L),delete x.s[L.last]),L.met||(v.near++,L.met=+new Date,w.on("hi",L)),le=L.queue,L.queue=[],setTimeout.each(le||[],function(ae){z(ae,L)},0,9)},v.bye=function(L){L.met&&--v.near,delete L.met,w.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){$.log("Error:",L.err)},v.hear["?"]=function(L,J){L.pid&&(J.pid||(J.pid=L.pid),L["@"])||(v.say({dam:"?",pid:$.pid,"@":L["#"]},J),delete x.s[J.last])},v.hear.mob=function(L,J){if(L.peers){var le=Object.keys(L.peers),ae=le[Math.random()*le.length>>0];ae&&(v.bye(J),v.hi(ae))}},w.on("create",function(L){L.opt.pid=L.opt.pid||String.random(9),this.to.next(L),L.on("out",v.say)}),w.on("bye",function(L,J){L=$.peers[L.id||L]||L,this.to.next(L),L.bye?L.bye():(J=L.wire)&&J.close&&J.close(),delete $.peers[L.id],L.wire=null});var re={};return w.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]},$.lack||9e3))}),w.on("hi",function(L,J){if(this.to.next(L),(J=console.STAT)&&(J.peers=v.near),!$.super){var le=Object.keys(w.next||"");le.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(le,function(ae){var R=w.next[ae];if($.super||(R.ask||"")[""]){v.say({get:{"#":ae}},L);return}setTimeout.each(Object.keys(R.ask||""),function(M){M&&v.say({"##":String.hash((w.graph[ae]||"")[M]),get:{"#":ae,".":M}},L)})})}}),v}var y={},E=!0,b;try{i.exports=m}catch{}})(n,"./mesh"),n(function(i){var s=n("./index");s.Mesh=n("./mesh"),s.on("opt",function(m){if(this.to.next(m),m.once)return;var y=m.opt;if(y.WebSocket===!1)return;var E=s.window||{},b=y.WebSocket||E.WebSocket||E.webkitWebSocket||E.mozWebSocket;if(!b)return;y.WebSocket=b;var w=y.mesh=y.mesh||s.Mesh(m),v=w.wire||y.wire;w.wire=y.wire=$;function $(B){try{if(!B||!B.url)return I&&I(B);var O=B.url.replace(/^http/,"ws"),I=B.wire=new y.WebSocket(O);return I.onclose=function(){x(B),y.mesh.bye(B)},I.onerror=function(U){x(B)},I.onopen=function(){y.mesh.hi(B)},I.onmessage=function(U){U&&y.mesh.hear(U.data||U,B)},I}catch{y.mesh.bye(B)}}setTimeout(function(){!y.super&&m.on("out",{dam:"hi"})},1);var S=2*999;function x(B){clearTimeout(B.defer),y.peers[B.url]&&(k&&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 O(){if(k&&k.hidden)return setTimeout(O,S);$(B)},S)))}var k=""+d!=typeof document&&document});var u=function(){},d})(n,"./websocket"),n(function(i){if(!(typeof Gun>"u")){var s=function(){},u,d;try{u=(Gun.window||s).localStorage}catch{}u||(Gun.log("Warning: No localStorage exists to persist data to!"),u={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,w){var v;try{b(v,JSON.parse(E,w))}catch($){b($)}},y=JSON.stringifyAsync||function(E,b,w,v){var $;try{b($,JSON.stringify(E,w,v))}catch(S){b(S)}};Gun.on("create",function E(b){this.to.next(b);var w=b.opt,v=b.graph,$=[],S,x,k,B;if(w.localStorage===!1)return;w.prefix=w.file||"gun/";try{S=E[w.prefix]=E[w.prefix]||JSON.parse(k=u.getItem(w.prefix))||{}}catch{S=E[w.prefix]={}}k=(k||"").length,b.on("get",function(I){this.to.next(I);var U=I.get,q,V,z,re;!U||!(q=U["#"])||(V=S[q]||re,V&&(z=U["."])&&!Object.plain(z)&&(V=Gun.state.ify({},z,Gun.state.is(V,z),V[z],q)),Gun.on.get.ack(I,V))}),b.on("put",function(I){this.to.next(I);var U=I.put,q=U["#"],V=U["."],z=I["#"],re=I.ok||"",L;if(S[q]=Gun.state.ify(S[q],V,U[">"],U[":"],q),B&&k>4999880){b.on("in",{"@":z,err:"localStorage max!"});return}!I["@"]&&(!I._.via||Math.random()<re["@"]/re["/"])&&$.push(z),!x&&(x=setTimeout(O,9+k/333))});function O(){if(!$.length&&((setTimeout.turn||"").s||"").length){setTimeout(O,99);return}var I,U=$;clearTimeout(x),x=!1,$=[],y(S,function(q,V){try{!q&&u.setItem(w.prefix,V)}catch(z){q=B=z||"localStorage failure"}q&&(Gun.log(q+" Consider using GUN's IndexedDB plugin for RAD for more storage space, https://gun.eco/docs/RAD#install"),b.on("localStorage:error",{err:q,get:w.prefix,put:S})),k=V.length,setTimeout.each(U,function(z){b.on("in",{"@":z,err:q,ok:0})},0,99)})}})}})(n,"./localStorage")})();(function(){var ae;if(""+ae!=typeof Gun){var n=function(R){console.warn("Warning! Deprecated internal utility will break in next version:",R)},e=Gun;e.fn=e.fn||{is:function(R){return n("fn"),!!R&&typeof R=="function"}},e.bi=e.bi||{is:function(R){return n("bi"),R instanceof Boolean||typeof R=="boolean"}},e.num=e.num||{is:function(R){return n("num"),!i(R)&&(R-parseFloat(R)+1>=0||R===1/0||R===-1/0)}},e.text=e.text||{is:function(R){return n("text"),typeof R=="string"}},e.text.ify=e.text.ify||function(R){return n("text.ify"),e.text.is(R)?R:typeof JSON<"u"?JSON.stringify(R):R&&R.toString?R.toString():R},e.text.random=e.text.random||function(R,M){n("text.random");var Q="";for(R=R||24,M=M||"0123456789ABCDEFGHIJKLMNOPQRSTUVWXZabcdefghijklmnopqrstuvwxyz";R>0;)Q+=M.charAt(Math.floor(Math.random()*M.length)),R--;return Q},e.text.match=e.text.match||function(R,M){var Q,X;return n("text.match"),typeof R!="string"?!1:(typeof M=="string"&&(M={"=":M}),M=M||{},Q=M["="]||M["*"]||M[">"]||M["<"],R===Q?!0:X!==M["="]?!1:(Q=M["*"]||M[">"]||M["<"],R.slice(0,(Q||"").length)===Q?!0:X!==M["*"]?!1:X!==M[">"]&&X!==M["<"]?R>=M[">"]&&R<=M["<"]:X!==M[">"]&&R>=M[">"]||X!==M["<"]&&R<=M["<"]))},e.text.hash=e.text.hash||function(R,M){if(n("text.hash"),typeof R=="string"){if(M=M||0,!R.length)return M;for(var Q=0,X=R.length,ne;Q<X;++Q)ne=R.charCodeAt(Q),M=(M<<5)-M+ne,M|=0;return M}},e.list=e.list||{is:function(R){return n("list"),R instanceof Array}},e.list.slit=e.list.slit||Array.prototype.slice,e.list.sort=e.list.sort||function(R){return n("list.sort"),function(M,Q){return!M||!Q?0:(M=M[R],Q=Q[R],M<Q?-1:M>Q?1:0)}},e.list.map=e.list.map||function(R,M,Q){return n("list.map"),J(R,M,Q)},e.list.index=1,e.obj=e.boj||{is:function(R){return n("obj"),R?R instanceof Object&&R.constructor===Object||Object.prototype.toString.call(R).match(/^\[object (\w+)\]$/)[1]==="Object":!1}},e.obj.put=e.obj.put||function(R,M,Q){return n("obj.put"),(R||{})[M]=Q,R},e.obj.has=e.obj.has||function(R,M){return n("obj.has"),R&&Object.prototype.hasOwnProperty.call(R,M)},e.obj.del=e.obj.del||function(R,M){if(n("obj.del"),!!R)return R[M]=null,delete R[M],R},e.obj.as=e.obj.as||function(R,M,Q,X){return n("obj.as"),R[M]=R[M]||(X===Q?{}:Q)},e.obj.ify=e.obj.ify||function(R){if(n("obj.ify"),q(R))return R;try{R=JSON.parse(R)}catch{R={}}return R},function(){var R;function M(Q,X){z(this,X)&&R!==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(R){return n("obj.copy"),R&&JSON.parse(JSON.stringify(R))},function(){function R(M,Q){var X=this.n,ne;if(!(X&&(Q===X||q(X)&&z(X,Q)))&&ne!==Q)return!0}e.obj.empty=e.obj.empty||function(M,Q){return n("obj.empty"),M?!J(M,R,{n:Q}):!0}}(),function(){function R(ne,Ae){if(arguments.length===2){R.r=R.r||{},R.r[ne]=Ae;return}R.r=R.r||[],R.r.push(ne)}var M=Object.keys,Q,X;Object.keys=Object.keys||function(ne){return Q(ne,function(Ae,te,de){de(te)})},e.obj.map=Q=e.obj.map||function(ne,Ae,te){n("obj.map");var de,me=0,ve,De,At,Ke,ze=typeof Ae=="function";if(R.r=de,M&&q(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(De=Ke?Ae.call(te,ne[At[me]],At[me],R):Ae.call(te,ne[me],gt,R),De!==de)return De}else if(Ae===ne[Ke?At[me]:me])return At?At[me]:gt}else for(me in ne)if(ze){if(z(ne,me)&&(De=te?Ae.call(te,ne[me],me,R):Ae(ne[me],me,R),De!==de))return De}else if(Ae===ne[me])return me;return ze?R.r:e.list.index?0:-1}}(),e.time=e.time||{},e.time.is=e.time.is||function(R){return n("time"),R?R instanceof Date:+new Date().getTime()};var I=e.fn.is,i=e.list.is,U=e.obj,q=U.is,z=U.has,J=U.map,s={};s.is=function(R){return n("val.is"),R===ae?!1:R===null?!0:R===1/0?!1:m(R)||d(R)||x(R)?!0:s.link.is(R)||!1},s.link=s.rel={_:"#"},function(){s.link.is=function(M){if(n("val.link.is"),M&&M[u]&&!M._&&q(M)){var Q={};if(J(M,R,Q),Q.id)return Q.id}return!1};function R(M,Q){var X=this;if(X.id)return X.id=!1;if(Q==u&&m(M))X.id=M;else return X.id=!1}}(),s.link.ify=function(R){return n("val.link.ify"),L({},u,R)},e.obj.has._=".";var u=s.link._,ae,d=e.bi.is,x=e.num.is,m=e.text.is,U=e.obj,q=U.is,L=U.put,J=U.map;e.val=e.val||s;var y={_:"_"};y.soul=function(R,M){return n("node.soul"),R&&R._&&R._[M||w]},y.soul.ify=function(R,M){return n("node.soul.ify"),M=typeof M=="string"?{soul:M}:M||{},R=R||{},R._=R._||{},R._[w]=M.soul||R._[w]||b(),R},y.soul._=s.link._,function(){y.is=function(M,Q,X){n("node.is");var ne;return q(M)&&(ne=y.soul(M))?!J(M,R,{as:X,cb:Q,s:ne,n:M}):!1};function R(M,Q){if(Q!==y._){if(!s.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,R,{o:Q,as:X}),Q.node};function R(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}s.is(M)&&(X.node[Q]=M)}}();var U=e.obj,q=U.is,V=U.del,J=U.map,E=e.text,b=E.random,w=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(R,M,Q){n("state.to");var X=(R||{})[M];return q(X)&&(X=le(X)),v.ify(Q,M,v.is(R,M),X,y.soul(R))},function(){v.map=function(M,Q,X){n("state.map");var ne,Ae=q(Ae=M||Q)?Ae:null;return M=I(M=M||Q)?M:null,Ae&&!M?(Q=x(Q)?Q:v(),Ae[B]=Ae[B]||{},J(Ae,R,{o:Ae,s:Q}),Ae):(X=X||q(Q)?Q:ne,Q=x(Q)?Q:v(),function(te,de,me,ve){if(!M)return R.call({o:me,s:Q},te,de),te;M.call(X||this||{},te,de,me,ve),!(z(me,de)&&ne===me[de])&&R.call({o:me,s:Q},te,de)})};function R(M,Q){B!==Q&&v.ify(this.o,Q,this.s)}}();var U=e.obj,$=U.as,z=U.has,q=U.is,J=U.map,le=U.copy,S=e.num,x=S.is,k=e.fn,I=k.is,B=y._,ae,O={};(function(){O.is=function(Q,X,ne,Ae){return n("graph.is"),!Q||!q(Q)||re(Q)?!1:!J(Q,R,{cb:X,fn:ne,as:Ae})};function R(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(){O.ify=function(Ae,te,de){n("graph.ify");var me={path:[],obj:Ae};return te?typeof te=="string"?te={soul:te}:typeof te=="function"&&(te.map=te):te={},typeof de=="string"&&(te.soul=te.soul||de,de=ae),te.soul&&(me.link=s.link.ify(te.soul)),te.shell=(de||{}).shell,te.graph=te.graph||{},te.seen=te.seen||[],te.as=te.as||de,R(te,me),te.root=me.node,te.graph};function R(Ae,te){var de;return(de=ne(Ae,te))?de:(te.env=Ae,te.soul=Q,y.ify(te.obj,M,te)&&(te.link=te.link||s.link.ify(y.soul(te.node)),te.obj!==Ae.shell&&(Ae.graph[s.link.is(te.link)]=te.node)),te)}function M(Ae,te,de){var me=this,ve=me.env,De,At;if(y._===te&&z(Ae,s.link._))return de._;if(De=X(Ae,te,de,me,ve)){if(te||(me.node=me.node||de||{},z(Ae,y._)&&y.soul(Ae)&&(me.node._=le(Ae._)),me.node=y.soul.ify(me.node,s.link.is(me.link)),me.link=me.link||s.link.ify(y.soul(me.node))),(At=ve.map)&&(At.call(ve.as||{},Ae,te,de,me),z(de,te))){if(Ae=de[te],ae===Ae){V(de,te);return}if(!(De=X(Ae,te,de,me,ve)))return}if(!te)return me.node;if(De===!0)return Ae;if(At=R(ve,{obj:Ae,path:me.path.concat(te)}),!!At.node)return At.link}}function Q(Ae){var te=this,de=s.link.is(te.link),me=te.env.graph;te.link=te.link||s.link.ify(Ae),te.link[s.link._]=Ae,te.node&&te.node[y._]&&(te.node[y._][s.link._]=Ae),z(me,de)&&(me[Ae]=me[de],V(me,de))}function X(Ae,te,de,me,ve){var De;if(s.is(Ae))return!0;if(q(Ae))return 1;if(De=ve.invalid)return Ae=De.call(ve.as||{},Ae,te,de),X(Ae,te,de,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 de=Ae.seen,me=de.length,ve;me--;)if(ve=de[me],te.obj===ve.obj)return ve;de.push(te)}}(),O.node=function(R){n("graph.node");var M=y.soul(R);if(M)return L({},M,R)},function(){O.to=function(M,Q,X){if(n("graph.to"),!!M){var ne={};return X=X||{seen:{}},J(M[Q],R,{obj:ne,graph:M,opt:X}),ne}};function R(M,Q){var X,ne;if(y._===Q){if(re(M,s.link._))return;this.obj[Q]=le(M);return}if(!(X=s.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]=O.to(this.graph,X,this.opt)}}();var I=e.fn.is,U=e.obj,q=U.is,V=U.del,z=U.has,re=U.empty,L=U.put,J=U.map,le=U.copy,ae;e.graph=e.graph||O}})()});var ed=pe((aC,Zc)=>{Zc.exports=Xc()});var yo=pe(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 mo=class{};nt._CodeOrName=mo;nt.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var _n=class extends mo{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=_n;var hA=class extends mo{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,s)=>`${i}${s}`,"")}get names(){var e;return(e=this._names)!==null&&e!==void 0?e:this._names=this._items.reduce((i,s)=>(s instanceof _n&&(i[s.str]=(i[s.str]||0)+1),i),{})}};nt._Code=hA;nt.nil=new hA("");function td(n,...e){let i=[n[0]],s=0;for(;s<e.length;)q0(i,e[s]),i.push(n[++s]);return new hA(i)}nt._=td;var L0=new hA("+");function Ad(n,...e){let i=[go(n[0])],s=0;for(;s<e.length;)i.push(L0),q0(i,e[s]),i.push(L0,go(n[++s]));return fw(i),new hA(i)}nt.str=Ad;function q0(n,e){e instanceof hA?n.push(...e._items):e instanceof _n?n.push(e):n.push(hw(e))}nt.addCodeArg=q0;function fw(n){let e=1;for(;e<n.length-1;){if(n[e]===L0){let i=cw(n[e-1],n[e+1]);if(i!==void 0){n.splice(e-1,3,i);continue}n[e++]="+"}e++}}function cw(n,e){if(e==='""')return n;if(n==='""')return e;if(typeof n=="string")return e instanceof _n||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 _n))return`"${n}${e.slice(1)}`}function dw(n,e){return e.emptyStr()?n:n.emptyStr()?e:Ad`${n}${e}`}nt.strConcat=dw;function hw(n){return typeof n=="number"||typeof n=="boolean"||n===null?n:go(Array.isArray(n)?n.join(","):n)}function pw(n){return new hA(go(n))}nt.stringify=pw;function go(n){return JSON.stringify(n).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}nt.safeStringify=go;function mw(n){return typeof n=="string"&&nt.IDENTIFIER.test(n)?new hA(`.${n}`):td`[${n}]`}nt.getProperty=mw;function gw(n){if(typeof n=="string"&&nt.IDENTIFIER.test(n))return new hA(`${n}`);throw new Error(`CodeGen: invalid export name: ${n}, use explicit $id name mapping`)}nt.getEsmExportName=gw;function yw(n){return new hA(n.toString())}nt.regexpCode=yw});var H0=pe(Zt=>{"use strict";Object.defineProperty(Zt,"__esModule",{value:!0});Zt.ValueScope=Zt.ValueScopeName=Zt.Scope=Zt.varKinds=Zt.UsedValueState=void 0;var Xt=yo(),U0=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},Is;(function(n){n[n.Started=0]="Started",n[n.Completed=1]="Completed"})(Is||(Zt.UsedValueState=Is={}));Zt.varKinds={const:new Xt.Name("const"),let:new Xt.Name("let"),var:new Xt.Name("var")};var Bs=class{constructor({prefixes:e,parent:i}={}){this._names={},this._prefixes=e,this._parent=i}toName(e){return e instanceof Xt.Name?e:this.name(e)}name(e){return new Xt.Name(this._newName(e))}_newName(e){let i=this._names[e]||this._nameGroup(e);return`${e}${i.index++}`}_nameGroup(e){var i,s;if(!((s=(i=this._parent)===null||i===void 0?void 0:i._prefixes)===null||s===void 0)&&s.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}}};Zt.Scope=Bs;var Ms=class extends Xt.Name{constructor(e,i){super(i),this.prefix=e}setValue(e,{property:i,itemIndex:s}){this.value=e,this.scopePath=(0,Xt._)`.${new Xt.Name(i)}[${s}]`}};Zt.ValueScopeName=Ms;var ww=(0,Xt._)`\n`,G0=class extends Bs{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?ww:Xt.nil}}get(){return this._scope}name(e){return new Ms(e,this._newName(e))}value(e,i){var s;if(i.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let u=this.toName(e),{prefix:d}=u,m=(s=i.key)!==null&&s!==void 0?s:i.ref,y=this._values[d];if(y){let w=y.get(m);if(w)return w}else y=this._values[d]=new Map;y.set(m,u);let E=this._scope[d]||(this._scope[d]=[]),b=E.length;return E[b]=i.ref,u.setValue(i,{property:d,itemIndex:b}),u}getValue(e,i){let s=this._values[e];if(s)return s.get(i)}scopeRefs(e,i=this._values){return this._reduceValues(i,s=>{if(s.scopePath===void 0)throw new Error(`CodeGen: name "${s}" has no value`);return(0,Xt._)`${e}${s.scopePath}`})}scopeCode(e=this._values,i,s){return this._reduceValues(e,u=>{if(u.value===void 0)throw new Error(`CodeGen: name "${u}" has no value`);return u.value.code},i,s)}_reduceValues(e,i,s={},u){let d=Xt.nil;for(let m in e){let y=e[m];if(!y)continue;let E=s[m]=s[m]||new Map;y.forEach(b=>{if(E.has(b))return;E.set(b,Is.Started);let w=i(b);if(w){let v=this.opts.es5?Zt.varKinds.var:Zt.varKinds.const;d=(0,Xt._)`${d}${v} ${b} = ${w};${this.opts._n}`}else if(w=u?.(b))d=(0,Xt._)`${d}${w}${this.opts._n}`;else throw new U0(b);E.set(b,Is.Completed)})}return d}};Zt.ValueScope=G0});var Ge=pe(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 Ze=yo(),EA=H0(),Ir=yo();Object.defineProperty(Je,"_",{enumerable:!0,get:function(){return Ir._}});Object.defineProperty(Je,"str",{enumerable:!0,get:function(){return Ir.str}});Object.defineProperty(Je,"strConcat",{enumerable:!0,get:function(){return Ir.strConcat}});Object.defineProperty(Je,"nil",{enumerable:!0,get:function(){return Ir.nil}});Object.defineProperty(Je,"getProperty",{enumerable:!0,get:function(){return Ir.getProperty}});Object.defineProperty(Je,"stringify",{enumerable:!0,get:function(){return Ir.stringify}});Object.defineProperty(Je,"regexpCode",{enumerable:!0,get:function(){return Ir.regexpCode}});Object.defineProperty(Je,"Name",{enumerable:!0,get:function(){return Ir.Name}});var Qs=H0();Object.defineProperty(Je,"Scope",{enumerable:!0,get:function(){return Qs.Scope}});Object.defineProperty(Je,"ValueScope",{enumerable:!0,get:function(){return Qs.ValueScope}});Object.defineProperty(Je,"ValueScopeName",{enumerable:!0,get:function(){return Qs.ValueScopeName}});Object.defineProperty(Je,"varKinds",{enumerable:!0,get:function(){return Qs.varKinds}});Je.operators={GT:new Ze._Code(">"),GTE:new Ze._Code(">="),LT:new Ze._Code("<"),LTE:new Ze._Code("<="),EQ:new Ze._Code("==="),NEQ:new Ze._Code("!=="),NOT:new Ze._Code("!"),OR:new Ze._Code("||"),AND:new Ze._Code("&&"),ADD:new Ze._Code("+")};var or=class{optimizeNodes(){return this}optimizeNames(e,i){return this}},V0=class extends or{constructor(e,i,s){super(),this.varKind=e,this.name=i,this.rhs=s}render({es5:e,_n:i}){let s=e?EA.varKinds.var:this.varKind,u=this.rhs===void 0?"":` = ${this.rhs}`;return`${s} ${this.name}${u};`+i}optimizeNames(e,i){if(e[this.name.str])return this.rhs&&(this.rhs=_i(this.rhs,e,i)),this}get names(){return this.rhs instanceof Ze._CodeOrName?this.rhs.names:{}}},js=class extends or{constructor(e,i,s){super(),this.lhs=e,this.rhs=i,this.sideEffects=s}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,i){if(!(this.lhs instanceof Ze.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=_i(this.rhs,e,i),this}get names(){let e=this.lhs instanceof Ze.Name?{}:{...this.lhs.names};return Fs(e,this.rhs)}},z0=class extends js{constructor(e,i,s,u){super(e,s,u),this.op=i}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},J0=class extends or{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},K0=class extends or{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}},W0=class extends or{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},Y0=class extends or{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,i){return this.code=_i(this.code,e,i),this}get names(){return this.code instanceof Ze._CodeOrName?this.code.names:{}}},wo=class extends or{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((i,s)=>i+s.render(e),"")}optimizeNodes(){let{nodes:e}=this,i=e.length;for(;i--;){let s=e[i].optimizeNodes();Array.isArray(s)?e.splice(i,1,...s):s?e[i]=s:e.splice(i,1)}return e.length>0?this:void 0}optimizeNames(e,i){let{nodes:s}=this,u=s.length;for(;u--;){let d=s[u];d.optimizeNames(e,i)||(_w(e,d.names),s.splice(u,1))}return s.length>0?this:void 0}get names(){return this.nodes.reduce((e,i)=>En(e,i.names),{})}},sr=class extends wo{render(e){return"{"+e._n+super.render(e)+"}"+e._n}},X0=class extends wo{},wi=class extends sr{};wi.kind="else";var vn=class n extends sr{constructor(e,i){super(i),this.condition=e}render(e){let i=`if(${this.condition})`+super.render(e);return this.else&&(i+="else "+this.else.render(e)),i}optimizeNodes(){super.optimizeNodes();let e=this.condition;if(e===!0)return this.nodes;let i=this.else;if(i){let s=i.optimizeNodes();i=this.else=Array.isArray(s)?new wi(s):s}if(i)return e===!1?i instanceof n?i:i.nodes:this.nodes.length?this:new n(rd(e),i instanceof n?[i]:i.nodes);if(!(e===!1||!this.nodes.length))return this}optimizeNames(e,i){var s;if(this.else=(s=this.else)===null||s===void 0?void 0:s.optimizeNames(e,i),!!(super.optimizeNames(e,i)||this.else))return this.condition=_i(this.condition,e,i),this}get names(){let e=super.names;return Fs(e,this.condition),this.else&&En(e,this.else.names),e}};vn.kind="if";var bn=class extends sr{};bn.kind="for";var Z0=class extends bn{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,i){if(super.optimizeNames(e,i))return this.iteration=_i(this.iteration,e,i),this}get names(){return En(super.names,this.iteration.names)}},el=class extends bn{constructor(e,i,s,u){super(),this.varKind=e,this.name=i,this.from=s,this.to=u}render(e){let i=e.es5?EA.varKinds.var:this.varKind,{name:s,from:u,to:d}=this;return`for(${i} ${s}=${u}; ${s}<${d}; ${s}++)`+super.render(e)}get names(){let e=Fs(super.names,this.from);return Fs(e,this.to)}},Ns=class extends bn{constructor(e,i,s,u){super(),this.loop=e,this.varKind=i,this.name=s,this.iterable=u}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,i){if(super.optimizeNames(e,i))return this.iterable=_i(this.iterable,e,i),this}get names(){return En(super.names,this.iterable.names)}},_o=class extends sr{constructor(e,i,s){super(),this.name=e,this.args=i,this.async=s}render(e){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(e)}};_o.kind="func";var vo=class extends wo{render(e){return"return "+super.render(e)}};vo.kind="return";var tl=class extends sr{render(e){let i="try"+super.render(e);return this.catch&&(i+=this.catch.render(e)),this.finally&&(i+=this.finally.render(e)),i}optimizeNodes(){var e,i;return super.optimizeNodes(),(e=this.catch)===null||e===void 0||e.optimizeNodes(),(i=this.finally)===null||i===void 0||i.optimizeNodes(),this}optimizeNames(e,i){var s,u;return super.optimizeNames(e,i),(s=this.catch)===null||s===void 0||s.optimizeNames(e,i),(u=this.finally)===null||u===void 0||u.optimizeNames(e,i),this}get names(){let e=super.names;return this.catch&&En(e,this.catch.names),this.finally&&En(e,this.finally.names),e}},bo=class extends sr{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};bo.kind="catch";var Eo=class extends sr{render(e){return"finally"+super.render(e)}};Eo.kind="finally";var Al=class{constructor(e,i={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...i,_n:i.lines?`
3
3
  `:""},this._extScope=e,this._scope=new EA.Scope({parent:e}),this._nodes=[new X0]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,i){let s=this._extScope.value(e,i);return(this._values[s.prefix]||(this._values[s.prefix]=new Set)).add(s),s}getScopeValue(e,i){return this._extScope.getValue(e,i)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,i,s,u){let d=this._scope.toName(i);return s!==void 0&&u&&(this._constants[d.str]=s),this._leafNode(new V0(e,d,s)),d}const(e,i,s){return this._def(EA.varKinds.const,e,i,s)}let(e,i,s){return this._def(EA.varKinds.let,e,i,s)}var(e,i,s){return this._def(EA.varKinds.var,e,i,s)}assign(e,i,s){return this._leafNode(new js(e,i,s))}add(e,i){return this._leafNode(new z0(e,Je.operators.ADD,i))}code(e){return typeof e=="function"?e():e!==Ze.nil&&this._leafNode(new Y0(e)),this}object(...e){let i=["{"];for(let[s,u]of e)i.length>1&&i.push(","),i.push(s),(s!==u||this.opts.es5)&&(i.push(":"),(0,Ze.addCodeArg)(i,u));return i.push("}"),new Ze._Code(i)}if(e,i,s){if(this._blockNode(new vn(e)),i&&s)this.code(i).else().code(s).endIf();else if(i)this.code(i).endIf();else if(s)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(e){return this._elseNode(new vn(e))}else(){return this._elseNode(new wi)}endIf(){return this._endBlockNode(vn,wi)}_for(e,i){return this._blockNode(e),i&&this.code(i).endFor(),this}for(e,i){return this._for(new Z0(e),i)}forRange(e,i,s,u,d=this.opts.es5?EA.varKinds.var:EA.varKinds.let){let m=this._scope.toName(e);return this._for(new el(d,m,i,s),()=>u(m))}forOf(e,i,s,u=EA.varKinds.const){let d=this._scope.toName(e);if(this.opts.es5){let m=i instanceof Ze.Name?i:this.var("_arr",i);return this.forRange("_i",0,(0,Ze._)`${m}.length`,y=>{this.var(d,(0,Ze._)`${m}[${y}]`),s(d)})}return this._for(new Ns("of",u,d,i),()=>s(d))}forIn(e,i,s,u=this.opts.es5?EA.varKinds.var:EA.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,Ze._)`Object.keys(${i})`,s);let d=this._scope.toName(e);return this._for(new Ns("in",u,d,i),()=>s(d))}endFor(){return this._endBlockNode(bn)}label(e){return this._leafNode(new J0(e))}break(e){return this._leafNode(new K0(e))}return(e){let i=new vo;if(this._blockNode(i),this.code(e),i.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(vo)}try(e,i,s){if(!i&&!s)throw new Error('CodeGen: "try" without "catch" and "finally"');let u=new tl;if(this._blockNode(u),this.code(e),i){let d=this.name("e");this._currNode=u.catch=new bo(d),i(d)}return s&&(this._currNode=u.finally=new Eo,this.code(s)),this._endBlockNode(bo,Eo)}throw(e){return this._leafNode(new W0(e))}block(e,i){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(i),this}endBlock(e){let i=this._blockStarts.pop();if(i===void 0)throw new Error("CodeGen: not in self-balancing block");let s=this._nodes.length-i;if(s<0||e!==void 0&&s!==e)throw new Error(`CodeGen: wrong number of nodes: ${s} vs ${e} expected`);return this._nodes.length=i,this}func(e,i=Ze.nil,s,u){return this._blockNode(new _o(e,i,s)),u&&this.code(u).endFunc(),this}endFunc(){return this._endBlockNode(_o)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,i){let s=this._currNode;if(s instanceof e||i&&s instanceof i)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${i?`${e.kind}/${i.kind}`:e.kind}"`)}_elseNode(e){let i=this._currNode;if(!(i instanceof vn))throw new Error('CodeGen: "else" without "if"');return this._currNode=i.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let i=this._nodes;i[i.length-1]=e}};Je.CodeGen=Al;function En(n,e){for(let i in e)n[i]=(n[i]||0)+(e[i]||0);return n}function Fs(n,e){return e instanceof Ze._CodeOrName?En(n,e.names):n}function _i(n,e,i){if(n instanceof Ze.Name)return s(n);if(!u(n))return n;return new Ze._Code(n._items.reduce((d,m)=>(m instanceof Ze.Name&&(m=s(m)),m instanceof Ze._Code?d.push(...m._items):d.push(m),d),[]));function s(d){let m=i[d.str];return m===void 0||e[d.str]!==1?d:(delete e[d.str],m)}function u(d){return d instanceof Ze._Code&&d._items.some(m=>m instanceof Ze.Name&&e[m.str]===1&&i[m.str]!==void 0)}}function _w(n,e){for(let i in e)n[i]=(n[i]||0)-(e[i]||0)}function rd(n){return typeof n=="boolean"||typeof n=="number"||n===null?!n:(0,Ze._)`!${rl(n)}`}Je.not=rd;var vw=nd(Je.operators.AND);function bw(...n){return n.reduce(vw)}Je.and=bw;var Ew=nd(Je.operators.OR);function $w(...n){return n.reduce(Ew)}Je.or=$w;function nd(n){return(e,i)=>e===Ze.nil?i:i===Ze.nil?e:(0,Ze._)`${rl(e)} ${n} ${rl(i)}`}function rl(n){return n instanceof Ze.Name?n:(0,Ze._)`(${n})`}});var Ye=pe(We=>{"use strict";Object.defineProperty(We,"__esModule",{value:!0});We.checkStrictMode=We.getErrorPath=We.Type=We.useFunc=We.setEvaluated=We.evaluatedPropsToName=We.mergeEvaluated=We.eachItem=We.unescapeJsonPointer=We.escapeJsonPointer=We.escapeFragment=We.unescapeFragment=We.schemaRefOrVal=We.schemaHasRulesButRef=We.schemaHasRules=We.checkUnknownRules=We.alwaysValidSchema=We.toHash=void 0;var dt=Ge(),Pw=yo();function kw(n){let e={};for(let i of n)e[i]=!0;return e}We.toHash=kw;function Cw(n,e){return typeof e=="boolean"?e:Object.keys(e).length===0?!0:(sd(n,e),!ad(e,n.self.RULES.all))}We.alwaysValidSchema=Cw;function sd(n,e=n.schema){let{opts:i,self:s}=n;if(!i.strictSchema||typeof e=="boolean")return;let u=s.RULES.keywords;for(let d in e)u[d]||fd(n,`unknown keyword: "${d}"`)}We.checkUnknownRules=sd;function ad(n,e){if(typeof n=="boolean")return!n;for(let i in n)if(e[i])return!0;return!1}We.schemaHasRules=ad;function Sw(n,e){if(typeof n=="boolean")return!n;for(let i in n)if(i!=="$ref"&&e.all[i])return!0;return!1}We.schemaHasRulesButRef=Sw;function Dw({topSchemaRef:n,schemaPath:e},i,s,u){if(!u){if(typeof i=="number"||typeof i=="boolean")return i;if(typeof i=="string")return(0,dt._)`${i}`}return(0,dt._)`${n}${e}${(0,dt.getProperty)(s)}`}We.schemaRefOrVal=Dw;function xw(n){return ld(decodeURIComponent(n))}We.unescapeFragment=xw;function Rw(n){return encodeURIComponent(il(n))}We.escapeFragment=Rw;function il(n){return typeof n=="number"?`${n}`:n.replace(/~/g,"~0").replace(/\//g,"~1")}We.escapeJsonPointer=il;function ld(n){return n.replace(/~1/g,"/").replace(/~0/g,"~")}We.unescapeJsonPointer=ld;function Tw(n,e){if(Array.isArray(n))for(let i of n)e(i);else e(n)}We.eachItem=Tw;function id({mergeNames:n,mergeToName:e,mergeValues:i,resultToName:s}){return(u,d,m,y)=>{let E=m===void 0?d:m instanceof dt.Name?(d instanceof dt.Name?n(u,d,m):e(u,d,m),m):d instanceof dt.Name?(e(u,m,d),d):i(d,m);return y===dt.Name&&!(E instanceof dt.Name)?s(u,E):E}}We.mergeEvaluated={props:id({mergeNames:(n,e,i)=>n.if((0,dt._)`${i} !== true && ${e} !== undefined`,()=>{n.if((0,dt._)`${e} === true`,()=>n.assign(i,!0),()=>n.assign(i,(0,dt._)`${i} || {}`).code((0,dt._)`Object.assign(${i}, ${e})`))}),mergeToName:(n,e,i)=>n.if((0,dt._)`${i} !== true`,()=>{e===!0?n.assign(i,!0):(n.assign(i,(0,dt._)`${i} || {}`),ol(n,i,e))}),mergeValues:(n,e)=>n===!0?!0:{...n,...e},resultToName:ud}),items:id({mergeNames:(n,e,i)=>n.if((0,dt._)`${i} !== true && ${e} !== undefined`,()=>n.assign(i,(0,dt._)`${e} === true ? true : ${i} > ${e} ? ${i} : ${e}`)),mergeToName:(n,e,i)=>n.if((0,dt._)`${i} !== true`,()=>n.assign(i,e===!0?!0:(0,dt._)`${i} > ${e} ? ${i} : ${e}`)),mergeValues:(n,e)=>n===!0?!0:Math.max(n,e),resultToName:(n,e)=>n.var("items",e)})};function ud(n,e){if(e===!0)return n.var("props",!0);let i=n.var("props",(0,dt._)`{}`);return e!==void 0&&ol(n,i,e),i}We.evaluatedPropsToName=ud;function ol(n,e,i){Object.keys(i).forEach(s=>n.assign((0,dt._)`${e}${(0,dt.getProperty)(s)}`,!0))}We.setEvaluated=ol;var od={};function Ow(n,e){return n.scopeValue("func",{ref:e,code:od[e.code]||(od[e.code]=new Pw._Code(e.code))})}We.useFunc=Ow;var nl;(function(n){n[n.Num=0]="Num",n[n.Str=1]="Str"})(nl||(We.Type=nl={}));function Iw(n,e,i){if(n instanceof dt.Name){let s=e===nl.Num;return i?s?(0,dt._)`"[" + ${n} + "]"`:(0,dt._)`"['" + ${n} + "']"`:s?(0,dt._)`"/" + ${n}`:(0,dt._)`"/" + ${n}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return i?(0,dt.getProperty)(n).toString():"/"+il(n)}We.getErrorPath=Iw;function fd(n,e,i=n.opts.strictSchema){if(i){if(e=`strict mode: ${e}`,i===!0)throw new Error(e);n.self.logger.warn(e)}}We.checkStrictMode=fd});var pA=pe(sl=>{"use strict";Object.defineProperty(sl,"__esModule",{value:!0});var qt=Ge(),Bw={data:new qt.Name("data"),valCxt:new qt.Name("valCxt"),instancePath:new qt.Name("instancePath"),parentData:new qt.Name("parentData"),parentDataProperty:new qt.Name("parentDataProperty"),rootData:new qt.Name("rootData"),dynamicAnchors:new qt.Name("dynamicAnchors"),vErrors:new qt.Name("vErrors"),errors:new qt.Name("errors"),this:new qt.Name("this"),self:new qt.Name("self"),scope:new qt.Name("scope"),json:new qt.Name("json"),jsonPos:new qt.Name("jsonPos"),jsonLen:new qt.Name("jsonLen"),jsonPart:new qt.Name("jsonPart")};sl.default=Bw});var $o=pe(Ut=>{"use strict";Object.defineProperty(Ut,"__esModule",{value:!0});Ut.extendErrors=Ut.resetErrorsCount=Ut.reportExtraError=Ut.reportError=Ut.keyword$DataError=Ut.keywordError=void 0;var tt=Ge(),Ls=Ye(),zt=pA();Ut.keywordError={message:({keyword:n})=>(0,tt.str)`must pass "${n}" keyword validation`};Ut.keyword$DataError={message:({keyword:n,schemaType:e})=>e?(0,tt.str)`"${n}" keyword must be ${e} ($data)`:(0,tt.str)`"${n}" keyword is invalid ($data)`};function Mw(n,e=Ut.keywordError,i,s){let{it:u}=n,{gen:d,compositeRule:m,allErrors:y}=u,E=hd(n,e,i);s??(m||y)?cd(d,E):dd(u,(0,tt._)`[${E}]`)}Ut.reportError=Mw;function jw(n,e=Ut.keywordError,i){let{it:s}=n,{gen:u,compositeRule:d,allErrors:m}=s,y=hd(n,e,i);cd(u,y),d||m||dd(s,zt.default.vErrors)}Ut.reportExtraError=jw;function Nw(n,e){n.assign(zt.default.errors,e),n.if((0,tt._)`${zt.default.vErrors} !== null`,()=>n.if(e,()=>n.assign((0,tt._)`${zt.default.vErrors}.length`,e),()=>n.assign(zt.default.vErrors,null)))}Ut.resetErrorsCount=Nw;function Fw({gen:n,keyword:e,schemaValue:i,data:s,errsCount:u,it:d}){if(u===void 0)throw new Error("ajv implementation error");let m=n.name("err");n.forRange("i",u,zt.default.errors,y=>{n.const(m,(0,tt._)`${zt.default.vErrors}[${y}]`),n.if((0,tt._)`${m}.instancePath === undefined`,()=>n.assign((0,tt._)`${m}.instancePath`,(0,tt.strConcat)(zt.default.instancePath,d.errorPath))),n.assign((0,tt._)`${m}.schemaPath`,(0,tt.str)`${d.errSchemaPath}/${e}`),d.opts.verbose&&(n.assign((0,tt._)`${m}.schema`,i),n.assign((0,tt._)`${m}.data`,s))})}Ut.extendErrors=Fw;function cd(n,e){let i=n.const("err",e);n.if((0,tt._)`${zt.default.vErrors} === null`,()=>n.assign(zt.default.vErrors,(0,tt._)`[${i}]`),(0,tt._)`${zt.default.vErrors}.push(${i})`),n.code((0,tt._)`${zt.default.errors}++`)}function dd(n,e){let{gen:i,validateName:s,schemaEnv:u}=n;u.$async?i.throw((0,tt._)`new ${n.ValidationError}(${e})`):(i.assign((0,tt._)`${s}.errors`,e),i.return(!1))}var $n={keyword:new tt.Name("keyword"),schemaPath:new tt.Name("schemaPath"),params:new tt.Name("params"),propertyName:new tt.Name("propertyName"),message:new tt.Name("message"),schema:new tt.Name("schema"),parentSchema:new tt.Name("parentSchema")};function hd(n,e,i){let{createErrors:s}=n.it;return s===!1?(0,tt._)`{}`:Qw(n,e,i)}function Qw(n,e,i={}){let{gen:s,it:u}=n,d=[Lw(u,i),qw(n,i)];return Uw(n,e,d),s.object(...d)}function Lw({errorPath:n},{instancePath:e}){let i=e?(0,tt.str)`${n}${(0,Ls.getErrorPath)(e,Ls.Type.Str)}`:n;return[zt.default.instancePath,(0,tt.strConcat)(zt.default.instancePath,i)]}function qw({keyword:n,it:{errSchemaPath:e}},{schemaPath:i,parentSchema:s}){let u=s?e:(0,tt.str)`${e}/${n}`;return i&&(u=(0,tt.str)`${u}${(0,Ls.getErrorPath)(i,Ls.Type.Str)}`),[$n.schemaPath,u]}function Uw(n,{params:e,message:i},s){let{keyword:u,data:d,schemaValue:m,it:y}=n,{opts:E,propertyName:b,topSchemaRef:w,schemaPath:v}=y;s.push([$n.keyword,u],[$n.params,typeof e=="function"?e(n):e||(0,tt._)`{}`]),E.messages&&s.push([$n.message,typeof i=="function"?i(n):i]),E.verbose&&s.push([$n.schema,m],[$n.parentSchema,(0,tt._)`${w}${v}`],[zt.default.data,d]),b&&s.push([$n.propertyName,b])}});var md=pe(vi=>{"use strict";Object.defineProperty(vi,"__esModule",{value:!0});vi.boolOrEmptySchema=vi.topBoolOrEmptySchema=void 0;var Gw=$o(),Hw=Ge(),Vw=pA(),zw={message:"boolean schema is false"};function Jw(n){let{gen:e,schema:i,validateName:s}=n;i===!1?pd(n,!1):typeof i=="object"&&i.$async===!0?e.return(Vw.default.data):(e.assign((0,Hw._)`${s}.errors`,null),e.return(!0))}vi.topBoolOrEmptySchema=Jw;function Kw(n,e){let{gen:i,schema:s}=n;s===!1?(i.var(e,!1),pd(n)):i.var(e,!0)}vi.boolOrEmptySchema=Kw;function pd(n,e){let{gen:i,data:s}=n,u={gen:i,keyword:"false schema",data:s,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:n};(0,Gw.reportError)(u,zw,void 0,e)}});var al=pe(bi=>{"use strict";Object.defineProperty(bi,"__esModule",{value:!0});bi.getRules=bi.isJSONType=void 0;var Ww=["string","number","integer","boolean","null","object","array"],Yw=new Set(Ww);function Xw(n){return typeof n=="string"&&Yw.has(n)}bi.isJSONType=Xw;function Zw(){let n={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...n,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},n.number,n.string,n.array,n.object],post:{rules:[]},all:{},keywords:{}}}bi.getRules=Zw});var ll=pe(Br=>{"use strict";Object.defineProperty(Br,"__esModule",{value:!0});Br.shouldUseRule=Br.shouldUseGroup=Br.schemaHasRulesForType=void 0;function e_({schema:n,self:e},i){let s=e.RULES.types[i];return s&&s!==!0&&gd(n,s)}Br.schemaHasRulesForType=e_;function gd(n,e){return e.rules.some(i=>yd(n,i))}Br.shouldUseGroup=gd;function yd(n,e){var i;return n[e.keyword]!==void 0||((i=e.definition.implements)===null||i===void 0?void 0:i.some(s=>n[s]!==void 0))}Br.shouldUseRule=yd});var Po=pe(Gt=>{"use strict";Object.defineProperty(Gt,"__esModule",{value:!0});Gt.reportTypeError=Gt.checkDataTypes=Gt.checkDataType=Gt.coerceAndCheckDataType=Gt.getJSONTypes=Gt.getSchemaTypes=Gt.DataType=void 0;var t_=al(),A_=ll(),r_=$o(),He=Ge(),wd=Ye(),Ei;(function(n){n[n.Correct=0]="Correct",n[n.Wrong=1]="Wrong"})(Ei||(Gt.DataType=Ei={}));function n_(n){let e=_d(n.type);if(e.includes("null")){if(n.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!e.length&&n.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');n.nullable===!0&&e.push("null")}return e}Gt.getSchemaTypes=n_;function _d(n){let e=Array.isArray(n)?n:n?[n]:[];if(e.every(t_.isJSONType))return e;throw new Error("type must be JSONType or JSONType[]: "+e.join(","))}Gt.getJSONTypes=_d;function i_(n,e){let{gen:i,data:s,opts:u}=n,d=o_(e,u.coerceTypes),m=e.length>0&&!(d.length===0&&e.length===1&&(0,A_.schemaHasRulesForType)(n,e[0]));if(m){let y=fl(e,s,u.strictNumbers,Ei.Wrong);i.if(y,()=>{d.length?s_(n,e,d):cl(n)})}return m}Gt.coerceAndCheckDataType=i_;var vd=new Set(["string","number","integer","boolean","null"]);function o_(n,e){return e?n.filter(i=>vd.has(i)||e==="array"&&i==="array"):[]}function s_(n,e,i){let{gen:s,data:u,opts:d}=n,m=s.let("dataType",(0,He._)`typeof ${u}`),y=s.let("coerced",(0,He._)`undefined`);d.coerceTypes==="array"&&s.if((0,He._)`${m} == 'object' && Array.isArray(${u}) && ${u}.length == 1`,()=>s.assign(u,(0,He._)`${u}[0]`).assign(m,(0,He._)`typeof ${u}`).if(fl(e,u,d.strictNumbers),()=>s.assign(y,u))),s.if((0,He._)`${y} !== undefined`);for(let b of i)(vd.has(b)||b==="array"&&d.coerceTypes==="array")&&E(b);s.else(),cl(n),s.endIf(),s.if((0,He._)`${y} !== undefined`,()=>{s.assign(u,y),a_(n,y)});function E(b){switch(b){case"string":s.elseIf((0,He._)`${m} == "number" || ${m} == "boolean"`).assign(y,(0,He._)`"" + ${u}`).elseIf((0,He._)`${u} === null`).assign(y,(0,He._)`""`);return;case"number":s.elseIf((0,He._)`${m} == "boolean" || ${u} === null
4
4
  || (${m} == "string" && ${u} && ${u} == +${u})`).assign(y,(0,He._)`+${u}`);return;case"integer":s.elseIf((0,He._)`${m} === "boolean" || ${u} === null
@@ -28,7 +28,7 @@ https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety
28
28
  `);super({baseURL:m.baseURL,timeout:m.timeout??6e5,httpAgent:m.httpAgent,maxRetries:m.maxRetries,fetch:m.fetch}),this.completions=new an(this),this.chat=new tr(this),this.embeddings=new ln(this),this.files=new Pr(this),this.images=new pn(this),this.audio=new NA(this),this.moderations=new gn(this),this.models=new Cr(this),this.fineTuning=new bA(this),this.vectorStores=new oA(this),this.beta=new vA(this),this.batches=new _r(this),this.uploads=new Rr(this),this.responses=new xr(this),this.evals=new qA(this),this._options=m,this.apiKey=i,this.organization=s,this.project=u}defaultQuery(){return this._options.defaultQuery}defaultHeaders(e){return{...super.defaultHeaders(e),"OpenAI-Organization":this.organization,"OpenAI-Project":this.project,...this._options.defaultHeaders}}authHeaders(e){return{Authorization:`Bearer ${this.apiKey}`}}stringifyQuery(e){return A0(e,{arrayFormat:"brackets"})}};Wc=qe;qe.OpenAI=Wc;qe.DEFAULT_TIMEOUT=6e5;qe.OpenAIError=$e;qe.APIError=$t;qe.APIConnectionError=pr;qe.APIConnectionTimeoutError=mr;qe.APIUserAbortError=bt;qe.NotFoundError=Ji;qe.ConflictError=Ki;qe.RateLimitError=Yi;qe.BadRequestError=Hi;qe.AuthenticationError=Vi;qe.InternalServerError=Xi;qe.PermissionDeniedError=zi;qe.UnprocessableEntityError=Wi;qe.toFile=p0;qe.fileFromPath=as;qe.Completions=an;qe.Chat=tr;qe.ChatCompletionsPage=wr;qe.Embeddings=ln;qe.Files=Pr;qe.FileObjectsPage=cn;qe.Images=pn;qe.Audio=NA;qe.Moderations=gn;qe.Models=Cr;qe.ModelsPage=mn;qe.FineTuning=bA;qe.VectorStores=oA;qe.VectorStoresPage=yn;qe.VectorStoreSearchResponsesPage=wn;qe.Beta=vA;qe.Batches=_r;qe.BatchesPage=en;qe.Uploads=Rr;qe.Responses=xr;qe.Evals=qA;qe.EvalListResponsesPage=fn;var Yc=qe;var Gm=Ka(ed(),1),Hm=Ka(Fu(),1);async function tm(n,e,i,s=null,u=null,d=!0,m={}){if(!e||!i)throw new Error("federate: Missing required space IDs");if(e===i)throw new Error("Cannot federate a space with itself");let{federate:y=[],notify:E=[]}=m;if(!Array.isArray(y)||!Array.isArray(E))throw new Error("federate: lensConfig.federate and lensConfig.notify must be arrays");let b=y,w=E;try{let v=null;try{v=await n.getGlobal("federation",e,s)}catch{}v==null&&(v={id:e,name:e,federation:[],notify:[],lensConfig:{},timestamp:Date.now()}),v.federation||(v.federation=[]),v.notify||(v.notify=[]),v.lensConfig||(v.lensConfig={}),v.federation.includes(i)||v.federation.push(i),v.notify.includes(i)||v.notify.push(i);let $={...v.lensConfig||{}};$[i]={federate:[...b],notify:[...w],timestamp:Date.now()},v.lensConfig=$,v.timestamp=Date.now();try{await n.putGlobal("federation",v,s)}catch(x){throw new Error(`Failed to create federation: ${x.message}`)}{let x=null;try{x=await n.getGlobal("federation",i,u)}catch{}x==null&&(x={id:i,name:i,federation:[],notify:[],lensConfig:{},timestamp:Date.now()}),x.federation||(x.federation=[]),x.notify||(x.notify=[]),x.lensConfig||(x.lensConfig={}),d&&!x.federation.includes(e)&&x.federation.push(e),x.notify.includes(e)||x.notify.push(e),x.lensConfig[e]={federate:d?[...b]:[],notify:d?[...w]:[],timestamp:Date.now()},x.timestamp=Date.now();try{await n.putGlobal("federation",x,u)}catch{}}let S={id:`${e}_${i}`,space1:e,space2:i,created:Date.now(),status:"active",bidirectional:d,lensConfig:{federate:[...b],notify:[...w]}};try{await n.putGlobal("federationMeta",S)}catch{}return!0}catch(v){throw v}}async function Am(n,e,i=null,s,u={}){if(!e||!s)throw new Error("subscribeFederation: Missing required parameters");let{lenses:d=["*"],throttle:m=0}=u,y=await n.getGlobal("federation",e,i);if(!y)throw new Error("No federation info found for space");let E=[],b={};if(y.federation&&y.federation.length>0)for(let w of y.federation)for(let v of d)try{let $=await n.subscribe(w,v,async S=>{try{if(!S||!S.id)return;let x=Date.now(),k=`${w}_${v}_${S.id}`;if(m>0){if(b[k]&&x-b[k]<m)return;b[k]=x}S.federation||(S.federation={origin:w,timestamp:x}),await s(S,w,v)}catch{}});$&&typeof $.unsubscribe=="function"&&E.push($)}catch{}return{unsubscribe:()=>{E.forEach(w=>{try{w&&typeof w.unsubscribe=="function"&&w.unsubscribe()}catch{}}),E.length=0,b={}},getSubscriptionCount:()=>E.length}}async function Rn(n,e,i=null){if(!e)throw new Error("getFederation: Missing space ID");return await n.getGlobal("federation",e,i)}async function rm(n,e,i,s=null){if(!n||!e||!i)throw new Error("getFederatedConfig: Missing required parameters");try{let u=await Rn(n,e,s);return u&&u.lensConfig&&u.lensConfig[i]?{federate:u.lensConfig[i].federate||[],notify:u.lensConfig[i].notify||[]}:null}catch(u){throw console.error(`Error getting federated config for ${e} -> ${i}: ${u.message}`),u}}async function nm(n,e,i,s=null,u=null){if(!e||!i)throw new Error("unfederate: Missing required space IDs");try{let d=null;try{d=await n.getGlobal("federation",e,s)}catch(E){console.error(`Error getting fedInfo1 for ${e} during unfederate: ${E.message}`)}if(!d)console.warn(`No federation info found for ${e}. Skipping its update.`);else{d.federation||(d.federation=[]),d.notify||(d.notify=[]);let E=d.federation.length,b=d.notify.length;d.federation=d.federation.filter(w=>w!==i),d.notify=d.notify.filter(w=>w!==i),d.timestamp=Date.now(),console.log(`Unfederate: Removed ${i} from ${e}: federation ${E} -> ${d.federation.length}, notify ${b} -> ${d.notify.length}`);try{await n.putGlobal("federation",d,s)}catch(w){throw console.error(`Failed to update fedInfo1 for ${e} during unfederate: ${w.message}`),w}}if(u){let E=null;try{E=await n.getGlobal("federation",i,u)}catch(b){console.error(`Error getting fedInfo2 for ${i} during unfederate: ${b.message}`)}if(!E||!E.notify)console.warn(`No notify array found for ${i} or fedInfo2 is null. Skipping its update.`);else{E.notify=E.notify.filter(b=>b!==e),E.timestamp=Date.now();try{await n.putGlobal("federation",E,u)}catch(b){throw console.error(`Failed to update fedInfo2 for ${i} during unfederate: ${b.message}`),b}}}let m=`${e}_${i}`,y=`${i}_${e}`;try{let E=await n.getGlobal("federationMeta",m)||await n.getGlobal("federationMeta",y);E&&(E.status="inactive",E.endedAt=Date.now(),await n.putGlobal("federationMeta",E))}catch(E){console.warn(`Failed to update federationMeta during unfederate: ${E.message}`)}return!0}catch(d){throw console.error(`Critical error during unfederate operation for ${e}-${i}: ${d.message}`),d}}async function im(n,e,i,s=null){if(!e||!i)throw new Error("removeNotify: Missing required space IDs");try{let u=await n.getGlobal("federation",e,s);if(!u)throw new Error(`No federation info found for ${e}`);return u.notify||(u.notify=[]),u.notify.includes(i)?(u.notify=u.notify.filter(d=>d!==i),u.timestamp=Date.now(),await n.putGlobal("federation",u,s),!0):!1}catch(u){throw u}}async function om(n,e,i,s={}){let{queryIds:u=null,aggregate:d=!1,idField:m="id",sumFields:y=[],concatArrays:E=[],removeDuplicates:b=!0,mergeStrategy:w=null,includeLocal:v=!0,includeFederated:$=!0,resolveReferences:S=!0,maxFederatedSpaces:x=-1,timeout:k=1e4}=s;if(console.log(`resolveReferences option: ${S}`),console.log("Querying specific IDs:",u?u.join(", "):"No (fetching all)"),!n||!e||!i)throw new Error("Missing required parameters: holosphere, holon, and lens are required");let O=await Rn(n,e),I=new Map,U=new Set,q=[],V=[];if(v&&V.push(e),$&&O&&O.federation&&O.federation.length>0){let re=x===-1?O.federation:O.federation.slice(0,x);V=V.concat(re)}for(let re of V)if(u&&Array.isArray(u)){console.log(`Fetching specific IDs from ${re}: ${u.join(", ")}`);for(let L of u)I.has(L)||q.push(n.get(re,i,L).then(J=>{J&&I.set(L,J)}).catch(J=>console.warn(`Error fetching item ${L} from ${re}: ${J.message}`)))}else re===e&&v&&console.warn(`getFederated: No queryIds provided. Falling back to fetching ALL items from ${re} using getAll. This can be inefficient.`),console.log(`Fetching ALL items from ${re}`),q.push(n.getAll(re,i).then(L=>{for(let J of L)J&&J[m]&&!I.has(J[m])&&I.set(J[m],J)}).catch(L=>console.warn(`Error fetching all items from ${re}: ${L.message}`)));await Promise.all(q);let z=Array.from(I.values());if(S&&z.length>0){console.log(`Resolving references for ${z.length} fetched items`);for(let re=0;re<z.length;re++){let L=z[re];if(L.soul&&L.id){console.log(`Found simple reference with soul: ${L.soul}`);try{let J=L.soul.split("/");if(J.length>=4){let le=J[1],ae=J[2],R=J[3];console.log(`Extracting from soul - holon: ${le}, lens: ${ae}, key: ${R}`);let M=await n.get(le,ae,R,null,{resolveReferences:!0});console.log("Original data found via soul path:",JSON.stringify(M)),M?z[re]={...M,_federation:{isReference:!0,resolved:!0,soul:L.soul,timestamp:Date.now()}}:z[re]={id:L.id,_federation:{isReference:!0,resolved:!1,soul:L.soul,error:"Referenced data not found",timestamp:Date.now()}}}else console.warn(`Soul doesn't match expected format: ${L.soul}`),z[re]={id:L.id,_federation:{isReference:!0,resolved:!1,soul:L.soul,error:"Invalid soul format",timestamp:Date.now()}}}catch(J){z[re]={id:L.id,_federation:{isReference:!0,resolved:!1,soul:L.soul,error:J.message||"Error resolving reference",timestamp:Date.now()}}}}else if(L._federation&&L._federation.isReference){console.log(`Found legacy reference: ${L._federation.origin}/${L._federation.lens}/${L[m]}`);try{let J=L._federation;console.log(`Getting original data from ${J.origin} / ${J.lens} / ${L[m]}`);let le=await n.get(J.origin,J.lens,L[m],null,{resolveReferences:!1});console.log("Original data found:",JSON.stringify(le)),le?z[re]={...le,_federation:{...J,resolved:!0,timestamp:Date.now()}}:console.warn("Could not resolve legacy reference: original data not found")}catch{}}}}if(d&&z.length>0){let re=z.reduce((J,le)=>{let ae=le[m];return J[ae]||(J[ae]=[]),J[ae].push(le),J},{});return Object.values(re).map(J=>{if(J.length===1)return J[0];if(w&&typeof w=="function")return w(J);let le={...J[0]};for(let ae of y)typeof le[ae]=="number"&&(le[ae]=J.reduce((R,M)=>R+(Number(M[ae])||0),0));for(let ae of E)if(Array.isArray(le[ae])){let R=J.reduce((M,Q)=>Array.isArray(Q[ae])?[...M,...Q[ae]]:M,[]);le[ae]=b?Array.from(new Set(R)):R}return le._aggregated={count:J.length,timestamp:Date.now()},le})}return z}async function sm(n,e,i,s,u={}){if(!n||!e||!i||!s)throw new Error("propagate: Missing required parameters");let{useHolograms:d=!0,targetSpaces:m=null,password:y=null,propagateToParents:E=!0,maxParentLevels:b=15}=u,w={success:0,errors:0,skipped:0,messages:[],parentPropagation:{success:0,errors:0,skipped:0,messages:[]}};try{let v=await Rn(n,e,y);if(v&&v.federation&&v.federation.length>0&&v.notify&&v.notify.length>0){let $=v.notify;if(m&&Array.isArray(m)&&m.length>0&&($=$.filter(S=>m.includes(S))),$.length>0)if($=$.filter(S=>{let x=v.lensConfig?.[S];if(!x)return w.messages.push(`No lens configuration for target space ${S}. Skipping propagation of lens '${i}'.`),w.skipped++,!1;let k=Array.isArray(x.federate)?x.federate:[],O=k.includes("*")||k.includes(i);return O||(w.messages.push(`Propagation of lens '${i}' to target space ${S} skipped: lens not in 'federate' configuration.`),w.skipped++),O}),$.length>0){let S=n.isHologram(s),x=$.map(async k=>{try{let B,O={origin:e,sourceLens:i,propagatedAt:Date.now(),originalId:s.id};return d&&!S?B={...n.createHologram(e,i,s),_federation:O}:B={...s,_federation:{...s._federation||{},...O}},await n.put(k,i,B,null,{disableHologramRedirection:!0,autoPropagate:!1}),w.success++,!0}catch(B){return w.errors++,w.messages.push(`Error propagating ${s.id} to ${k}: ${B.message}`),!1}});await Promise.all(x)}else w.messages.push("No valid target spaces for federation propagation after lens filtering.");else w.messages.push("No valid target spaces found for federation propagation.")}else w.messages.push(`No federation found for ${e} or no notification targets available.`);if(E){console.log(`[Federation] Starting parent propagation for holon: ${e}`);try{let $,S=!1;if(typeof e=="string"&&e.startsWith("8")&&e.length>=15)try{$=TA(e),$>=0&&$<=15?(S=!0,console.log(`[Federation] Holon ${e} is valid H3 hexagon with resolution: ${$}`)):console.log(`[Federation] Holon ${e} has invalid resolution: ${$}`)}catch(x){console.log(`[Federation] Holon ${e} failed H3 validation: ${x.message}`)}else console.log(`[Federation] Holon ${e} is not a valid H3 hexagon: does not start with '8' or too short`);if(S||(console.log(`[Federation] Skipping parent propagation for non-H3 holon: ${e}`),w.parentPropagation.messages.push(`Holon ${e} is not a valid H3 hexagon. Skipping parent propagation.`),w.parentPropagation.skipped++),S&&$!==void 0){let x=[],k=e,B=$,O=0;for(console.log(`[Federation] Getting parent hexagons for ${e} (resolution ${$}) up to ${b} levels`);B>0&&O<b;)try{let I=OA(k,B-1);x.push(I),console.log(`[Federation] Found parent hexagon: ${I} (resolution ${B-1})`),k=I,B--,O++}catch(I){console.error(`[Federation] Error getting parent for ${k}: ${I.message}`),w.parentPropagation.messages.push(`Error getting parent for ${k}: ${I.message}`),w.parentPropagation.errors++;break}if(x.length>0){console.log(`[Federation] Found ${x.length} parent hexagons to propagate to: ${x.join(", ")}`),w.parentPropagation.messages.push(`Found ${x.length} parent hexagons to propagate to: ${x.join(", ")}`);let I=n.isHologram(s);console.log(`[Federation] Data is already hologram: ${I}`);let U=x.map(async q=>{try{console.log(`[Federation] Propagating to parent hexagon: ${q}`);let V,z={origin:e,sourceLens:i,propagatedAt:Date.now(),originalId:s.id,propagationType:"parent",parentLevel:$-TA(q)};if(d&&!I){let re=n.createHologram(e,i,s);console.log("[Federation] Created hologram for parent propagation:",re),V={...re,_federation:z}}else V={...s,_federation:{...s._federation||{},...z}};return console.log(`[Federation] Storing in parent hexagon ${q} with payload:`,V),await n.put(q,i,V,null,{disableHologramRedirection:!0,autoPropagate:!1}),console.log(`[Federation] Successfully propagated to parent hexagon: ${q}`),w.parentPropagation.success++,!0}catch(V){return console.error(`[Federation] Error propagating ${s.id} to parent hexagon ${q}: ${V.message}`),w.parentPropagation.errors++,w.parentPropagation.messages.push(`Error propagating ${s.id} to parent hexagon ${q}: ${V.message}`),!1}});await Promise.all(U)}else console.log(`[Federation] No parent hexagons found for ${e} (already at resolution 0 or max levels reached)`),w.parentPropagation.messages.push(`No parent hexagons found for ${e} (already at resolution 0 or max levels reached)`),w.parentPropagation.skipped++}}catch($){console.error(`[Federation] Error during parent propagation: ${$.message}`),w.parentPropagation.errors++,w.parentPropagation.messages.push(`Error during parent propagation: ${$.message}`)}}else console.log(`[Federation] Parent propagation disabled for holon: ${e}`);return w.propagated=w.success>0||w.parentPropagation.success>0,w}catch(v){return{...w,error:v.message}}}async function am(n,e,i,s,u,d="generic"){let m=`${e}_${i}_fedmsgs`,y=await n.getGlobal("federation_messages",m)||{id:m,originalChatId:e,originalMessageId:i,type:d,messages:[]},E=y.messages.find(b=>b.chatId===s);E?(E.messageId=u,E.timestamp=Date.now()):y.messages.push({chatId:s,messageId:u,timestamp:Date.now()}),await n.putGlobal("federation_messages",y)}async function Qu(n,e,i){let s=`${e}_${i}_fedmsgs`;return await n.getGlobal("federation_messages",s)}async function lm(n,e,i,s){let u=await Qu(n,e,i);if(u?.messages)for(let d of u.messages)try{await s(d.chatId,d.messageId)}catch{}}async function um(n,e,i=null,s={}){if(!e)throw new Error("resetFederation: Missing required space ID");let{notifyPartners:u=!0,spaceName:d=null}=s,m={success:!1,federatedCount:0,notifyCount:0,partnersNotified:0,errors:[]};try{let y=await Rn(n,e,i);if(!y)return{...m,success:!0,message:"No federation configuration found for this space"};m.federatedCount=y.federation?.length||0,m.notifyCount=y.notify?.length||0;let E={id:e,name:d||e,federation:[],notify:[],timestamp:Date.now()};if(await n.putGlobal("federation",E,i),u&&y.federation&&y.federation.length>0){let b=y.federation.map(async w=>{try{let v=await Rn(n,w);return v?(v.federation&&(v.federation=v.federation.filter($=>$!==e.toString())),v.notify&&(v.notify=v.notify.filter($=>$!==e.toString())),v.timestamp=Date.now(),await n.putGlobal("federation",v),m.partnersNotified++,!0):!1}catch(v){return m.errors.push({partner:w,error:v.message}),!1}});await Promise.all(b)}if(y.federation&&y.federation.length>0)for(let b of y.federation)try{let w=`${e}_${b}`,v=`${b}_${e}`,$=await n.getGlobal("federationMeta",w)||await n.getGlobal("federationMeta",v);$&&($.status="inactive",$.endedAt=Date.now(),await n.putGlobal("federationMeta",$))}catch{}return m.success=!0,m}catch(y){return{...m,success:!1,error:y.message}}}var qS=Ka(Fu(),1);async function fm(n,e,i){if(!e||!i)throw new Error("setSchema: Missing required parameters");if(!i.type||typeof i.type!="string")throw new Error("setSchema: Schema must have a type field");let s={type:"object",required:["type","properties"],properties:{type:{type:"string"},properties:{type:"object",additionalProperties:{type:"object",required:["type"],properties:{type:{type:"string"}}}},required:{type:"array",items:{type:"string"}}}};if(!n.validator.validate(s,i))throw new Error(`Invalid schema structure: ${JSON.stringify(n.validator.errors)}`);if(!i.properties||typeof i.properties!="object")throw new Error("Schema must have properties in strict mode");if(!i.required||!Array.isArray(i.required)||i.required.length===0)throw new Error("Schema must have required fields in strict mode");return await n.putGlobal("schemas",{id:e,schema:i,timestamp:Date.now()}),n.schemaCache.set(e,{schema:i,timestamp:Date.now()}),!0}async function cm(n,e,i={}){if(!e)throw new Error("getSchema: Missing lens parameter");let{useCache:s=!0,maxCacheAge:u=36e5}=i;if(s&&n.schemaCache.has(e)){let m=n.schemaCache.get(e);if(Date.now()-m.timestamp<u)return m.schema}let d=await n.getGlobal("schemas",e);return!d||!d.schema?null:(n.schemaCache.set(e,{schema:d.schema,timestamp:Date.now()}),d.schema)}function dm(n,e=null){return e?n.schemaCache.delete(e):(n.schemaCache.clear(),!0)}async function hm(n,e,i,s,u=null,d={}){if(!s)throw new Error("put: Missing required data parameter");if(!e||!i)throw new Error("put: Missing required holon or lens parameters:",e,i);let{disableHologramRedirection:m=!1}=d,y=e,E=i,b=s.id;b||(b=n.generateId(),s.id=b);try{let v=await Lu(n,y,E,b,u,{resolveHolograms:!1});if(!m&&v&&n.isHologram(v)){let $=n.parseSoulPath(v.soul);$?($.appname!==n.appname&&console.warn(`Existing hologram at ${y}/${E}/${b} has appname (${$.appname}) in its soul ${v.soul} which does not match current HoloSphere instance appname (${n.appname}). Redirecting put to soul's holon/lens within this instance.`),console.log(`Redirecting put for data (ID: ${s.id}). Original target ${y}/${E}/${b} contained hologram (ID: ${v.id}, Soul: ${v.soul}). New target is ${$.holon}/${$.lens}/${$.key}.`),y=$.holon,E=$.lens,b=$.key,s.id!==b&&console.warn(`Data ID ('${s.id}') differs from redirected target key ('${b}') derived from existing hologram's soul. Data will be stored under key '${b}'.`)):console.warn(`Existing item at ${y}/${E}/${b} (ID: ${v.id}) is a hologram, but its soul ('${v.soul}') is invalid. Proceeding with original target.`)}}catch(v){v.message&&v.message.includes("RESOLVED_NULL")||console.warn(`Error checking for existing hologram at ${y}/${E}/${b}: ${v.message}. Proceeding with original target.`)}let w=n.isHologram(s);if(n.strict&&!w){let v=await n.getSchema(E);if(!v)throw new Error("Schema required in strict mode");let $=JSON.parse(JSON.stringify(s));if(!n.validator.validate(v,$)){let x=`Schema validation failed: ${JSON.stringify(n.validator.errors)}`;throw new Error(x)}}try{let v=null;return u&&(v=n.gun.user(),await new Promise(($,S)=>{let x=n.userName(y);v.auth(x,u,k=>{k.err?(console.log(`Initial auth failed for ${x} during put, attempting to create...`),v.create(x,u,B=>{B.err?B.err.includes("already created")||B.err.includes("already being created")?(console.log(`User ${x} already existed or being created during put, re-attempting auth with fresh user object.`),n.gun.user().auth(x,u,I=>{I.err&&console.log(`Auth still failed after user existed check: ${I.err}. Resolving anyway for test operations.`),$()})):(console.log(`Create user error (resolving anyway for operations): ${B.err}`),$()):(console.log(`User ${x} created successfully during put, attempting auth...`),v.auth(x,u,O=>{O.err?S(new Error(`Failed to auth after create for ${x} during put: ${O.err}`)):$()}))})):$()})})),new Promise(($,S)=>{try{let x={...s};x._meta!==void 0&&delete x._meta;let k=JSON.stringify(x),B=async I=>{if(I.err)S(new Error(I.err));else{if(w)try{if(n.parseSoulPath(s.soul)){let re=n.getNodeRef(s.soul),L=`${n.appname}/${y}/${E}/${b}`;re.get("_holograms").get(L).put(!0),console.log(`Data (ID: ${s.id}) being put is a hologram. Added its instance soul ${L} to its target ${s.soul}'s _holograms set.`)}else console.warn(`Data (ID: ${s.id}) being put is a hologram, but could not parse its soul ${s.soul} for tracking.`)}catch(z){console.warn(`Error updating _holograms set for the target of the data being put (data ID: ${s.id}, soul: ${s.soul}):`,z)}let U=[];if(!w&&!d.isHologramUpdate)try{let z=`${n.appname}/${y}/${E}/${b}`,re=n.getNodeRef(z);await new Promise(L=>{re.get("_holograms").once(async J=>{if(J){let le=Object.keys(J).filter(ae=>ae!=="_"&&J[ae]===!0);if(le.length>0){console.log(`Updating ${le.length} active holograms for data ${s.id}`);let ae=le.map(async R=>{try{let M=n.parseSoulPath(R);if(M){let Q=await n.get(M.holon,M.lens,M.key,null,{resolveHolograms:!1});if(Q){let X={...Q,updated:Date.now()};await n.put(M.holon,M.lens,X,null,{autoPropagate:!1,disableHologramRedirection:!0,isHologramUpdate:!0}),console.log(`Updated hologram at ${R} with timestamp`),U.push({soul:R,holon:M.holon,lens:M.lens,key:M.key,id:M.key,timestamp:X.updated})}}}catch(M){console.warn(`Error updating hologram ${R}:`,M)}});await Promise.all(ae)}}L()})})}catch(z){console.warn("Error checking for active holograms to update:",z)}w||n.notifySubscribers({holon:y,lens:E,...s});let q=d.autoPropagate!==!1&&!w,V=null;if(q)try{let z={useHolograms:!0,...d.propagationOptions};V=await n.propagate(y,E,s,z),V&&V.errors>0&&console.warn("Auto-propagation had errors:",V)}catch(z){console.warn("Error in auto-propagation:",z)}$({success:!0,isHologramAtPath:w,pathHolon:y,pathLens:E,pathKey:b,propagationResult:V,updatedHolograms:U})}};(u?v.get("private").get(E).get(b):n.gun.get(n.appname).get(y).get(E).get(b)).put(k,B)}catch(x){S(x)}})}catch(v){throw console.error("Error in put:",v),v}}async function Lu(n,e,i,s,u=null,d={}){if(!e||!i||!s)return console.error("get: Missing required parameters"),null;let{resolveHolograms:m=!0,validationOptions:y={},visited:E}=d,b=null;if(n.strict&&(b=await n.getSchema(i),!b))throw new Error("Schema required in strict mode");try{let w=null;return u&&(w=n.gun.user(),await new Promise((v,$)=>{let S=n.userName(e);w.auth(S,u,x=>{x.err?$(new Error(`Authentication failed for ${S} during get: ${x.err}`)):v()})})),new Promise(v=>{let $=async x=>{let k=null;if(!x){v(null);return}try{if(k=await n.parse(x),!k){v(null);return}if(m&&n.isHologram(k)){let B=await n.resolveHologram(k,{followHolograms:m,visited:E});if(console.log("### get/handleData received resolved value:",B),B===null){console.warn(`Hologram at ${e}/${i}/${s} could not be fully resolved (target not found or sub-problem). Resolving null.`),v(null);return}B!==k&&(console.log("### get/handleData using resolved data:",B),k=B)}if(b&&!n.validator.validate(b,k)&&(console.error("get: Invalid data according to schema:",n.validator.errors),n.strict)){v(null);return}v(k)}catch(B){B.message?.startsWith("CIRCULAR_REFERENCE")?(console.warn(`Caught circular reference during get/handleData for key ${s}. Resolving null.`),v(null)):(console.error("Error processing data in get/handleData:",B),v(null))}};(u?w.get("private").get(i).get(s):n.gun.get(n.appname).get(e).get(i).get(s)).once($)})}catch(w){return console.error("Error in get:",w),null}}async function pm(n,e,i,s=null){if(!e||!i)throw new Error("getAll: Missing required parameters");let u=await n.getSchema(i);if(!u&&n.strict)throw new Error("getAll: Schema required in strict mode");try{let d=null;return s&&(d=n.gun.user(),await new Promise((m,y)=>{let E=n.userName(e);d.auth(E,s,b=>{b.err?(console.log(`Initial auth failed for ${E} during getAll, attempting to create...`),d.create(E,s,w=>{w.err?w.err.includes("already created")||w.err.includes("already being created")?(console.log(`User ${E} already existed or being created during getAll, re-attempting auth with fresh user object.`),n.gun.user().auth(E,s,$=>{$.err&&console.log(`Auth still failed after user existed check: ${$.err}. Resolving anyway for test operations.`),m()})):(console.log(`Create user error (resolving anyway for operations): ${w.err}`),m()):(console.log(`User ${E} created successfully during getAll, attempting auth...`),d.auth(E,s,v=>{v.err?y(new Error(`Failed to auth after create for ${E} during getAll: ${v.err}`)):m()}))})):m()})})),new Promise(m=>{let y=new Map,E=async(v,$)=>{if(!(!v||$==="_"))try{let S=await n.parse(v);if(!S||!S.id)return;if(n.isHologram(S)){let x=await n.resolveHologram(S,{followHolograms:!0});if(x!==S){u?(n.validator.validate(u,x)||!n.strict)&&y.set(x.id,x):y.set(x.id,x);return}}u?(n.validator.validate(u,S)||!n.strict)&&y.set(S.id,S):y.set(S.id,S)}catch(S){console.error("Error processing data:",S)}},b=async v=>{if(!v){m([]);return}let $=[];Object.keys(v).filter(S=>S!=="_").forEach(S=>{$.push(E(v[S],S))});try{await Promise.all($),m(Array.from(y.values()))}catch(S){console.error("Error in getAll:",S),m([])}};(s?d.get("private").get(i):n.gun.get(n.appname).get(e).get(i)).once(b)})}catch(d){return console.error("Error in getAll:",d),[]}}async function mm(n,e){if(e==null)return console.warn("Parse received null or undefined data."),null;if(typeof e=="string")try{return JSON.parse(e)}catch{return console.warn("Data was a string but not valid JSON, returning null:",e),null}if(typeof e=="object"&&e!==null){if(e.soul&&typeof e.soul=="string"&&e.id)return e;if(n.isHologram(e))return e;if(e._){console.warn("Parsing raw Gun object with metadata (_) - attempting cleanup:",e);let i=Object.keys(e).reduce((s,u)=>(u!=="_"&&(s[u]=e[u]),s),{});return Object.keys(i).length===0?(console.warn("Raw Gun object had only metadata (_), returning null."),null):i}else return e}return console.warn("Parsing encountered unexpected data type, returning null:",typeof e,e),null}async function gm(n,e,i,s,u=null){if(!e||!i||!s)throw new Error("delete: Missing required parameters");try{let d=null;u&&(d=n.gun.user(),await new Promise((v,$)=>{let S=n.userName(e);d.auth(S,u,x=>{x.err?(console.log(`Initial auth failed for ${S} during deleteFunc, attempting to create...`),d.create(S,u,k=>{k.err?k.err.includes("already created")?(console.log(`User ${S} already existed during deleteFunc, re-attempting auth with fresh user object.`),n.gun.user().auth(S,u,O=>{O.err?$(new Error(`Failed to auth with fresh user object after create attempt (user existed) for ${S} during deleteFunc: ${O.err}`)):v()})):$(new Error(`Failed to create user ${S} during deleteFunc: ${k.err}`)):(console.log(`User ${S} created successfully during deleteFunc, attempting auth...`),d.auth(S,u,B=>{B.err?$(new Error(`Failed to auth after create for ${S} during deleteFunc: ${B.err}`)):v()}))})):v()})}));let m=u?d.get("private").get(i).get(s):n.gun.get(n.appname).get(e).get(i).get(s),y=Promise.resolve(),E=await new Promise(v=>m.once(v)),b=null;try{typeof E=="string"?b=JSON.parse(E):b=E}catch(v){console.warn("[deleteFunc] Could not JSON parse data for deletion check:",E,v),b=null}if(b&&n.isHologram(b))try{let v=b.soul;if(n.parseSoulPath(v)){let S=n.getNodeRef(v),x=`${n.appname}/${e}/${i}/${s}`;y=new Promise(k=>{S.get("_holograms").get(x).put(null,B=>{B.err&&console.warn(`[deleteFunc] Error removing hologram ${x} from target ${v}:`,B.err),console.log(`Removed hologram ${x} from target ${v}'s _holograms list`),k()})})}else console.warn(`Could not parse target soul ${v} for hologram tracking removal.`)}catch(v){console.warn(`Error initiating hologram reference removal from target ${b.soul}:`,v),y=Promise.resolve()}return await y,new Promise((v,$)=>{m.put(null,S=>{S.err?$(new Error(S.err)):v(!0)})})}catch(d){throw console.error("Error in delete:",d),d}}async function ym(n,e,i,s=null){if(!e||!i)return console.error("deleteAll: Missing holon or lens parameter"),!1;try{let u=null;return s&&(u=n.gun.user(),await new Promise((d,m)=>{let y=n.userName(e);u.auth(y,s,E=>{E.err?(console.log(`Initial auth failed for ${y} during deleteAll, attempting to create...`),u.create(y,s,b=>{b.err?b.err.includes("already created")||b.err.includes("already being created")?(console.log(`User ${y} already existed or being created during deleteAll, re-attempting auth with fresh user object.`),n.gun.user().auth(y,s,v=>{v.err&&console.log(`Auth still failed after user existed check: ${v.err}. Resolving anyway for test operations.`),d()})):(console.log(`Create user error (resolving anyway for operations): ${b.err}`),d()):(console.log(`User ${y} created successfully during deleteAll, attempting auth...`),u.auth(y,s,w=>{w.err?m(new Error(`Failed to auth after create for ${y} during deleteAll: ${w.err}`)):d()}))})):d()})})),new Promise(d=>{let m=[];(s?u.get("private").get(i):n.gun.get(n.appname).get(e).get(i)).once(async E=>{if(!E){d(!0);return}let b=Object.keys(E).filter(w=>w!=="_");for(let w of b)try{let v=s?u.get("private").get(i).get(w):n.gun.get(n.appname).get(e).get(i).get(w),$=await new Promise(k=>v.once(k)),S=null;try{typeof $=="string"?S=JSON.parse($):S=$}catch(k){console.warn("[deleteAll] Could not JSON parse data for deletion check:",$,k),S=null}if(S&&n.isHologram(S))try{let k=S.soul;if(n.parseSoulPath(k)){let O=n.getNodeRef(k),I=`${n.appname}/${e}/${i}/${w}`;await new Promise(U=>{O.get("_holograms").get(I).put(null,q=>{q.err&&console.warn(`[deleteAll] Error removing hologram ${I} from target ${k}:`,q.err),console.log(`Removed hologram ${I} from target ${k}'s _holograms list`),U()})})}else console.warn(`Could not parse target soul ${k} for hologram tracking removal during deleteAll.`)}catch(k){console.warn(`Error removing hologram reference from target ${S.soul} during deleteAll:`,k)}m.push(new Promise(k=>{(s?u.get("private").get(i).get(w):n.gun.get(n.appname).get(e).get(i).get(w)).put(null,O=>{k(!!O.ok)})}))}catch(v){console.warn(`Error processing key ${w} during deleteAll:`,v),m.push(new Promise($=>{(s?u.get("private").get(i).get(w):n.gun.get(n.appname).get(e).get(i).get(w)).put(null,x=>{$(!!x.ok)})}))}Promise.all(m).then(w=>{let v=w.every($=>$===!0);d(v)}).catch(w=>{console.error("Error in deleteAll:",w),d(!1)})})})}catch(u){return console.error("Error in deleteAll:",u),!1}}async function wm(n,e,i,s){if(!e||!i||!s)throw new Error("putNode: Missing required parameters");return new Promise((u,d)=>{try{let m=s.value&&n.isHologram(s.value);n.gun.get(n.appname).get(e).get(i).get("value").put(s.value,y=>{if(y.err)d(new Error(y.err));else{if(m)try{if(n.parseSoulPath(s.value.soul)){let b=n.getNodeRef(s.value.soul),w=`${n.appname}/${e}/${i}/value`;b.get("_holograms").get(w).put(!0),console.log(`Data (ID: ${s.id}) being put is a hologram. Added its instance soul ${w} to its target ${s.value.soul}'s _holograms set.`)}else console.warn(`Data (ID: ${s.id}) being put is a hologram, but could not parse its soul ${s.value.soul} for tracking.`)}catch(E){console.warn(`Error updating _holograms set for the target of the data being put (data ID: ${s.id}, soul: ${s.value.soul}):`,E)}u(!0)}})}catch(m){d(m)}})}async function _m(n,e,i,s){if(!e||!i||!s)throw new Error("getNode: Missing required parameters");return new Promise((u,d)=>{try{n.gun.get(n.appname).get(e).get(i).get(s).once(m=>{if(!m){u(null);return}u(m)})}catch(m){d(m)}})}function qu(n,e){if(typeof e!="string"||!e)throw new Error("getNodeRef: Invalid soul parameter");let i=e.split("/").filter(u=>{if(!u.trim()||/[<>:"/\\|?*]/.test(u))throw new Error("getNodeRef: Invalid path segment");return u.trim()});if(i.length===0)throw new Error("getNodeRef: Invalid soul format");let s=n.gun.get(n.appname);return i.forEach(u=>{s=s.get(u)}),s}async function vm(n,e){if(!e)throw new Error("getNodeBySoul: Missing soul parameter");return console.log(`getNodeBySoul: Accessing soul ${e}`),new Promise((i,s)=>{try{qu(n,e).once(d=>{if(console.log("getNodeBySoul: Retrieved data:",d),!d){i(null);return}i(d)})}catch(u){console.error("getNodeBySoul error:",u),s(u)}})}async function bm(n,e,i,s){if(!e||!i||!s)throw new Error("deleteNode: Missing required parameters");try{let u=n.gun.get(n.appname).get(e).get(i).get(s),d=Promise.resolve(),m=await new Promise(b=>u.once(b)),y=null;try{typeof m=="string"?y=JSON.parse(m):y=m}catch(b){console.warn("[deleteNode] Could not JSON parse data for deletion check:",m,b),y=null}if(y&&n.isHologram(y))try{let b=y.soul;if(n.parseSoulPath(b)){let v=n.getNodeRef(b),$=`${n.appname}/${e}/${i}/value`;d=new Promise(S=>{v.get("_holograms").get($).put(null,x=>{x.err&&console.warn(`[deleteNode] Error removing hologram ${$} from target ${b}:`,x.err),console.log(`Removed hologram ${$} from target ${b}'s _holograms list`),S()})})}else console.warn(`Could not parse target soul ${b} for hologram tracking removal during deleteNode.`)}catch(b){console.warn(`Error initiating hologram reference removal from target ${y.soul} during deleteNode:`,b),d=Promise.resolve()}return await d,new Promise((b,w)=>{u.put(null,v=>{v.err?w(new Error(v.err)):b(!0)})})}catch(u){throw console.error("Error in deleteNode:",u),u}}async function Em(n,e,i,s=null){try{if(!e||!i)throw new Error("Table name and data are required");let u=null;return s&&(u=n.gun.user(),await new Promise((d,m)=>{let y=n.userName(e);u.auth(y,s,E=>{E.err?(console.log(`Initial auth failed for ${y}, attempting to create...`),u.create(y,s,b=>{b.err?b.err.includes("already created")||b.err.includes("already being created")?(console.log(`User ${y} already existed or being created, re-attempting auth with fresh user object.`),n.gun.user().auth(y,s,v=>{v.err&&console.log(`Auth still failed after user existed check: ${v.err}. Resolving anyway for test operations.`),d()})):(console.log(`Create user error (resolving anyway for operations): ${b.err}`),d()):(console.log(`User ${y} created successfully, attempting auth...`),u.auth(y,s,w=>{w.err?m(new Error(`Failed to auth after create for ${y}: ${w.err}`)):d()}))})):d()})})),new Promise((d,m)=>{try{let y={...i};y._meta!==void 0&&delete y._meta;let E=JSON.stringify(y),b=n.isHologram(y),w=s?u.get("private").get(e):n.gun.get(n.appname).get(e);i.id?w.get(i.id).put(E,$=>{if($.err)m(new Error($.err));else{if(b)try{if(n.parseSoulPath(y.soul)){let x=n.getNodeRef(y.soul),k=`${n.appname}/${e}/${i.id}`;x.get("_holograms").get(k).put(!0),console.log(`Data (ID: ${i.id}) being put is a hologram. Added its instance soul ${k} to its target ${y.soul}'s _holograms set.`)}else console.warn(`Data (ID: ${i.id}) being put is a hologram, but could not parse its soul ${y.soul} for tracking.`)}catch(S){console.warn(`Error updating _holograms set for the target of the data being put (data ID: ${i.id}, soul: ${y.soul}):`,S)}d()}}):w.put(E,v=>{if(v.err)m(new Error(v.err));else{if(b)try{if(n.parseSoulPath(y.soul)){let S=n.getNodeRef(y.soul),x=`${n.appname}/${e}`;S.get("_holograms").get(x).put(!0),console.log(`Data being put is a hologram. Added its instance soul ${x} to its target ${y.soul}'s _holograms set.`)}else console.warn(`Data being put is a hologram, but could not parse its soul ${y.soul} for tracking.`)}catch($){console.warn(`Error updating _holograms set for the target of the data being put (soul: ${y.soul}):`,$)}d()}})}catch(y){m(y)}})}catch(u){throw console.error("Error in putGlobal:",u),u}}async function $m(n,e,i,s=null){try{let u=null;return s&&(u=n.gun.user(),await new Promise((d,m)=>{let y=n.userName(e);u.auth(y,s,E=>{E.err?(console.log(`Initial auth failed for ${y}, attempting to create...`),u.create(y,s,b=>{b.err?b.err.includes("already created")||b.err.includes("already being created")?(console.log(`User ${y} already existed or being created, re-attempting auth with fresh user object.`),n.gun.user().auth(y,s,v=>{v.err&&console.log(`Auth still failed after user existed check: ${v.err}. Resolving anyway for test operations.`),d()})):(console.log(`Create user error (resolving anyway for operations): ${b.err}`),d()):(console.log(`User ${y} created successfully, attempting auth...`),u.auth(y,s,w=>{w.err?m(new Error(`Failed to auth after create for ${y}: ${w.err}`)):d()}))})):d()})})),new Promise(async d=>{let m=async b=>{if(!b){d(null);return}try{let w=await n.parse(b);if(!w){d(null);return}if(n.isHologram(w)){let v=await n.resolveHologram(w,{followHolograms:!0});if(v===null){console.log(`Hologram at ${e}/${i} points to non-existent data. Deleting hologram.`);try{await n.deleteGlobal(e,i,s)}catch($){console.error(`Failed to delete invalid global hologram at ${e}/${i}:`,$)}d(null);return}if(v!==w){d(v);return}}d(w)}catch(w){console.error("Error parsing data in getGlobal:",w),d(null)}};(s?u.get("private").get(e):n.gun.get(n.appname).get(e)).get(i).once(m)})}catch(u){return console.error("Error in getGlobal:",u),null}}async function Pm(n,e,i=null){if(!e)throw new Error("getAllGlobal: Missing table name parameter");try{let s=null;return i&&(s=n.gun.user(),await new Promise((u,d)=>{let m=n.userName(e);s.auth(m,i,y=>{y.err?(console.log(`Initial auth failed for ${m}, attempting to create...`),s.create(m,i,E=>{E.err?E.err.includes("already created")||E.err.includes("already being created")?(console.log(`User ${m} already existed or being created, re-attempting auth with fresh user object.`),n.gun.user().auth(m,i,w=>{w.err&&console.log(`Auth still failed after user existed check: ${w.err}. Resolving anyway for test operations.`),u()})):(console.log(`Create user error (resolving anyway for operations): ${E.err}`),u()):(console.log(`User ${m} created successfully, attempting auth...`),s.auth(m,i,b=>{b.err?d(new Error(`Failed to auth after create for ${m}: ${b.err}`)):u()}))})):u()})})),new Promise(u=>{let d=[],m=!1,y=setTimeout(()=>{m||(m=!0,u(d))},5e3),E=async w=>{if(!w){clearTimeout(y),m=!0,u([]);return}let $=Object.keys(w).filter(S=>S!=="_").map(S=>new Promise(async x=>{let k=i?s.get("private").get(e).get(S):n.gun.get(n.appname).get(e).get(S),B=await new Promise(O=>{k.once(O)});if(B)try{let O=await n.parse(B);if(O)if(n.isHologram(O)){let I=await n.resolveHologram(O,{followHolograms:!0});if(I===null){console.log(`Hologram at ${e}/${S} points to non-existent data. Deleting hologram.`);try{await n.deleteGlobal(e,S,i)}catch(U){console.error(`Failed to delete invalid global hologram at ${e}/${S}:`,U)}x();return}I!==O?d.push(I):d.push(O)}else d.push(O)}catch(O){console.error("Error parsing data:",O)}x()}));await Promise.all($),clearTimeout(y),m||(m=!0,u(d))};(i?s.get("private").get(e):n.gun.get(n.appname).get(e)).once(E)})}catch(s){return console.error("Error in getAllGlobal:",s),[]}}async function km(n,e,i,s=null){if(!e||!i)throw new Error("deleteGlobal: Missing required parameters");try{let u=null;s&&(u=n.gun.user(),await new Promise((w,v)=>{let $=n.userName(e);u.auth($,s,S=>{S.err?(console.log(`Initial auth failed for ${$}, attempting to create...`),u.create($,s,x=>{x.err?x.err.includes("already created")||x.err.includes("already being created")?(console.log(`User ${$} already existed or being created, re-attempting auth with fresh user object.`),n.gun.user().auth($,s,B=>{B.err&&console.log(`Auth still failed after user existed check: ${B.err}. Resolving anyway for test operations.`),w()})):(console.log(`Create user error (resolving anyway for operations): ${x.err}`),w()):(console.log(`User ${$} created successfully, attempting auth...`),u.auth($,s,k=>{k.err?v(new Error(`Failed to auth after create for ${$}: ${k.err}`)):w()}))})):w()})}));let d=s?u.get("private").get(e).get(i):n.gun.get(n.appname).get(e).get(i),m=Promise.resolve(),y=await new Promise(w=>d.once(w)),E=null;try{typeof y=="string"?E=JSON.parse(y):E=y}catch(w){console.warn("[deleteGlobal] Could not JSON parse data for deletion check:",y,w),E=null}if(E&&n.isHologram(E))try{let w=E.soul;if(n.parseSoulPath(w)){let $=n.getNodeRef(w),S=`${n.appname}/${e}/${i}`;m=new Promise(x=>{$.get("_holograms").get(S).put(null,k=>{k.err&&console.warn(`[deleteGlobal] Error removing hologram ${S} from target ${w}:`,k.err),console.log(`Removed hologram ${S} from target ${w}'s _holograms list`),x()})})}else console.warn(`Could not parse target soul ${w} for hologram tracking removal during deleteGlobal.`)}catch(w){console.warn(`Error initiating hologram reference removal from target ${E.soul} during deleteGlobal:`,w),m=Promise.resolve()}return await m,new Promise((w,v)=>{d.put(null,$=>{$.err?(console.error("deleteGlobal - Deletion error:",$.err),v(new Error($.err))):w(!0)})})}catch(u){throw console.error("Error in deleteGlobal:",u),u}}async function Cm(n,e,i=null){if(!e)throw new Error("deleteAllGlobal: Missing table name parameter");try{let s=null;return i&&(s=n.gun.user(),await new Promise((u,d)=>{let m=n.userName(e);s.auth(m,i,y=>{y.err?(console.log(`Initial auth failed for ${m}, attempting to create...`),s.create(m,i,E=>{E.err?E.err.includes("already created")||E.err.includes("already being created")?(console.log(`User ${m} already existed or being created, re-attempting auth with fresh user object.`),n.gun.user().auth(m,i,w=>{w.err&&console.log(`Auth still failed after user existed check: ${w.err}. Resolving anyway for test cleanup.`),u()})):(console.log(`Create user error (resolving anyway for cleanup): ${E.err}`),u()):(console.log(`User ${m} created successfully, attempting auth...`),s.auth(m,i,b=>{b.err?d(new Error(`Failed to auth after create for ${m}: ${b.err}`)):u()}))})):u()})})),new Promise((u,d)=>{try{let m=new Set,y=setTimeout(()=>{m.size===0&&u(!0)},5e3),E=i?s.get("private").get(e):n.gun.get(n.appname).get(e);E.once(async b=>{if(!b){clearTimeout(y),u(!0);return}let w=Object.keys(b).filter($=>$!=="_");for(let $ of w)try{let S=i?s.get("private").get(e).get($):n.gun.get(n.appname).get(e).get($),x=await new Promise(O=>S.once(O)),k=null;try{typeof x=="string"?k=JSON.parse(x):k=x}catch(O){console.warn("[deleteAllGlobal] Could not JSON parse data for deletion check:",x,O),k=null}if(k&&n.isHologram(k))try{let O=k.soul;if(n.parseSoulPath(O)){let U=n.getNodeRef(O),q=`${n.appname}/${e}/${$}`;await new Promise(V=>{U.get("_holograms").get(q).put(null,z=>{z.err&&console.warn(`[deleteAllGlobal] Error removing hologram ${q} from target ${O}:`,z.err),console.log(`Removed hologram ${q} from target ${O}'s _holograms list`),V()})})}else console.warn(`Could not parse target soul ${O} for hologram tracking removal during deleteAllGlobal.`)}catch(O){console.warn(`Error removing hologram reference from target ${k.soul} during deleteAllGlobal:`,O)}m.add($)}catch(S){console.warn(`Error processing key ${$} during deleteAllGlobal:`,S),m.add($)}let v=w.map($=>new Promise((S,x)=>{(i?s.get("private").get(e).get($):n.gun.get(n.appname).get(e).get($)).put(null,B=>{B.err?(console.error(`Failed to delete ${$}:`,B.err),x(new Error(B.err))):S()})}));try{await Promise.all(v),E.put(null),clearTimeout(y),u(!0)}catch($){d($)}})}catch(m){d(m)}})}catch(s){throw console.error("Error in deleteAllGlobal:",s),s}}function Sm(n,e,i,s){if(ha(s))return console.warn("createHologram called with data that is already a hologram. Reusing existing soul:",s.soul),{id:s.id,soul:s.soul};if(!e||!i||!s||!s.id)throw new Error("createHologram: Missing required parameters for non-hologram data");let u=`${n.appname}/${e}/${i}/${s.id}`;return{id:s.id,soul:u}}function Uu(n){if(typeof n!="string")return null;let e=n.split("/");if(e.length<4)return null;let i=e.slice(3).join("/");return{appname:e[0],holon:e[1],lens:e[2],key:i}}function ha(n){return!n||typeof n!="object"?!1:!!(n.id&&typeof n.soul=="string"&&n.soul.length>0&&n.soul.includes("/"))}async function Dm(n,e,i={}){if(!ha(e))return e;let{followHolograms:s=!0,visited:u=new Set}=i;if(e.soul&&u.has(e.soul))throw console.warn(`!!! CIRCULAR hologram detected for soul: ${e.soul}. Returning original hologram.`),new Error(`CIRCULAR_REFERENCE:${e.soul}`);try{if(e.soul){let d=Uu(e.soul);if(!d)return console.warn(`Invalid soul format: ${e.soul}`),e;let m=new Set(u);m.add(e.soul),console.log(`Resolving hologram with soul: ${e.soul}`);let y=await n.get(d.holon,d.lens,d.key,null,{resolveHolograms:s,visited:m});return console.log("### resolveHologram received originalData:",y),y?(console.log(`### Returning RESOLVED data for soul: ${e.soul}`),{...y,_meta:{...y._meta||{},resolvedFromHologram:!0,hologramSoul:e.soul}}):(console.warn(`!!! Original data NOT FOUND for soul: ${e.soul}. Returning null.`),null)}else return console.warn("!!! resolveHologram called with object missing soul:",e),e}catch(d){return console.error(`!!! Error resolving hologram: ${d.message}`,d),e}}async function xm(n,e,i,s,u=15,d=null){let m=e,y=TA(m),E=[];for(;y>0&&u>0;)try{let b=await n.compute(m,i,s,d);b&&E.push(b),m=OA(m,y-1),y--,u--}catch(b){console.error("Error in compute hierarchy:",b);break}return E}async function Rm(n,e,i,s,u=null){if(!e||!i)throw new Error("compute: Missing required parameters");if(typeof s=="string"&&(s={operation:s}),!s?.operation)throw new Error("compute: Missing required parameters");let d;try{d=TA(e)}catch{throw new Error("compute: Invalid holon format")}if(d<1||d>15)throw new Error("compute: Invalid holon resolution (must be between 1 and 15)");let{operation:m,fields:y=[],targetField:E,depth:b,maxDepth:w}=s;if(b!==void 0&&b<0)throw new Error("compute: Invalid depth parameter");if(w!==void 0&&(w<1||w>15))throw new Error("compute: Invalid maxDepth parameter (must be between 1 and 15)");let v=["summarize","aggregate","concatenate"];if(!v.includes(m))throw new Error(`compute: Invalid operation (must be one of ${v.join(", ")})`);let $=OA(e,d-1),S=ic($,d),k=(await Promise.all(S.map(B=>n.getAll(B,i,u)))).flat().filter(Boolean);if(k.length>0)try{let B;switch(m){case"summarize":let O=y.length>0?k.map(I=>y.map(U=>I[U]).filter(Boolean).join(`
29
29
  `)).join(`
30
30
  `):JSON.stringify(k);B=await n.summarize(O);break;case"aggregate":B=y.reduce((I,U)=>(I[U]=k.reduce((q,V)=>q+(Number(V[U])||0),0),I),{});break;case"concatenate":B=y.reduce((I,U)=>(I[U]=k.reduce((q,V)=>{let z=V[U];return Array.isArray(z)?[...q,...z]:z?[...q,z]:q},[]),I[U]=Array.from(new Set(I[U])),I),{});break}if(B){let I={id:`${$}_${m}`,timestamp:Date.now()};return E?I[E]=B:typeof B=="object"?Object.assign(I,B):I.value=B,await n.put($,i,I,u),I}}catch(B){throw console.warn("Error in compute operation:",B),B}return null}async function Tm(n,e){if(!n.openai)return"OpenAI not initialized, please specify the API key in the constructor.";try{return(await n.openai.chat.completions.create({model:"gpt-4",messages:[{role:"system",content:"You are a helpful assistant that summarizes text concisely while preserving key information. Keep summaries clear and focused."},{role:"user",content:e}],temperature:.7,max_tokens:500})).choices[0].message.content.trim()}catch(i){throw console.error("Error in summarize:",i),new Error("Failed to generate summary")}}async function Om(n,e,i,s,u=15){await n.put(e,i,s);let d=TA(e);if(d===0||u<=0)return s;let m=OA(e,d-1),y=n.createHologram(e,i,s);return await n.put(m,i,y,null,{autoPropagate:!1}),d>1&&u>1?n.upcast(m,i,y,u-1):s}async function Im(n,e,i){(typeof n.getCellInfo!="function"||!n.db||typeof n.db.put!="function")&&console.warn("updateParent requires getCellInfo and db.put methods on the HoloSphere instance.");try{let s=await n.getCellInfo(e),u=TA(e),d=OA(e,u-1),m=await n.getCellInfo(d);m.wisdom[e]=i;let y=await n.summarize(Object.values(m.wisdom).join(`
31
- `));return m.summary=y,await n.db.put("cell",m),m}catch(s){throw console.error("Error during updateParent:",s),s}}async function Bm(n,e,i){return Ya(n,e,i)}function Mm(n,e){let i=[],s=Ya(n,e,14);i.push(s);for(let u=13;u>=0;u--)i.push(OA(s,u));return i}function jm(n){let e=[],i=TA(n);for(let s=i;s>=0;s--)e.push(OA(n,s));return e}async function Nm(n,e,i,s){if(!e||!i)throw new Error("subscribe: Missing holon or lens parameters:",e,i);if(!s||typeof s!="function")throw new Error("subscribe: Callback must be a function");let u=n.generateId();try{let d=n.gun.get(n.appname).get(e).get(i).map(),m=d.on(async(y,E)=>{if(n.subscriptions[u]&&y)try{let b=await n.parse(y);if(b&&n.isHologram(b)){let w=await n.resolveHologram(b,{followHolograms:!0});w!==b&&(b=w)}n.subscriptions[u]&&s(b,E)}catch(b){console.error("Error processing subscribed data:",b)}});return n.subscriptions[u]={id:u,holon:e,lens:i,callback:s,mapChain:d,gunListener:m},{unsubscribe:async()=>{let y=n.subscriptions[u];if(y)try{y.mapChain&&y.mapChain.off(),delete n.subscriptions[u]}catch(E){console.error(`Error during unsubscribe logic for ${u}:`,E)}}}}catch(d){throw console.error("Error creating subscription:",d),d}}function Fm(n,e){if(!(!e||!e.holon||!e.lens))try{Object.values(n.subscriptions).forEach(i=>{if(i.holon===e.holon&&i.lens===e.lens)try{i.callback&&typeof i.callback=="function"&&i.callback(e)}catch(s){console.warn("Error in subscription callback:",s)}})}catch(i){console.warn("Error notifying subscribers:",i)}}function Qm(){return Date.now().toString(10)+Math.random().toString(2)}async function Lm(n){try{if(n.gun){let e=Object.keys(n.subscriptions);for(let i of e)try{let s=n.subscriptions[i];s&&s.mapChain&&s.mapChain.off()}catch(s){console.warn(`Error cleaning up subscription ${i}:`,s)}if(n.subscriptions={},n.clearSchemaCache(),n.gun.back)try{let i=n.gun.back("opt.mesh");if(i){if(i.hear)try{let s=Object.keys(i.hear);for(let u of s)Array.isArray(i.hear[u])&&(i.hear[u]=[]);typeof i.hear!="function"&&(i.hear={})}catch(s){console.warn("Error cleaning up Gun mesh hear:",s)}if(i.way)try{Object.values(i.way).forEach(s=>{s&&s.wire&&s.wire.close&&s.wire.close()})}catch(s){console.warn("Error closing mesh sockets:",s)}i.opt&&i.opt.peers&&(i.opt.peers={})}if(n.gun.back("opt.web"))try{let s=n.gun.back("opt.web");s&&s.close&&s.close()}catch(s){console.warn("Error closing web server:",s)}}catch(i){console.warn("Error accessing Gun mesh:",i)}try{n.gun.off()}catch(i){console.warn("Error turning off Gun listeners:",i)}await new Promise(i=>setTimeout(i,100))}console.log("HoloSphere instance closed successfully")}catch(e){console.error("Error closing HoloSphere instance:",e)}}function qm(n,e){return e?`${n.appname}:${e}`:null}var Um="1.1.15",Gu=class{constructor(e,i=!1,s=null,u={}){console.log("HoloSphere v"+Um),this.appname=e,this.strict=i,this.validator=new Hm.default({allErrors:!0,strict:!1,validateSchema:!0});let m={...{peers:["https://gun.holons.io/gun","https://59.src.eco/gun"],axe:!1},...u};console.log("Initializing Gun with options:",m),this.gun=(0,Gm.default)(m),s!=null&&(this.openai=new Yc({apiKey:s})),this.subscriptions={},this.schemaCache=new Map}getGun(){return this.gun}async setSchema(e,i){return fm(this,e,i)}async getSchema(e,i={}){return cm(this,e,i)}clearSchemaCache(e=null){return dm(this,e)}async put(e,i,s,u=null,d={}){return hm(this,e,i,s,u,d)}async get(e,i,s,u=null,d={}){return Lu(this,e,i,s,u,d)}async getAll(e,i,s=null){return pm(this,e,i,s)}async parse(e){return mm(this,e)}async delete(e,i,s,u=null){return gm(this,e,i,s,u)}async deleteAll(e,i,s=null){return ym(this,e,i,s)}async putNode(e,i,s){return wm(this,e,i,s)}async getNode(e,i,s){return _m(this,e,i,s)}getNodeRef(e){return qu(this,e)}async getNodeBySoul(e){return vm(this,e)}async deleteNode(e,i,s){return bm(this,e,i,s)}async putGlobal(e,i,s=null){return Em(this,e,i,s)}async getGlobal(e,i,s=null){return $m(this,e,i,s)}async getAllGlobal(e,i=null){return Pm(this,e,i)}async deleteGlobal(e,i,s=null){return km(this,e,i,s)}async deleteAllGlobal(e,i=null){return Cm(this,e,i)}createHologram(e,i,s){return Sm(this,e,i,s)}parseSoulPath(e){return Uu(e)}isHologram(e){return ha(e)}async resolveHologram(e,i={}){return Dm(this,e,i)}async computeHierarchy(e,i,s,u=15,d=null){return xm(this,e,i,s,u,d)}async compute(e,i,s,u=null){return Rm(this,e,i,s,u)}async summarize(e){return Tm(this,e)}async upcast(e,i,s,u=15){return Om(this,e,i,s,u)}async updateParent(e,i){return Im(this,e,i)}async propagate(e,i,s,u={}){return sm(this,e,i,s,u)}async getHolon(e,i,s){return Bm(e,i,s)}getScalespace(e,i){return Mm(e,i)}getHolonScalespace(e){return jm(e)}async subscribe(e,i,s){return Nm(this,e,i,s)}notifySubscribers(e){return Fm(this,e)}generateId(){return Qm()}async federate(e,i,s=null,u=null,d=!0,m={}){return tm(this,e,i,s,u,d,m)}async subscribeFederation(e,i,s,u={}){return Am(this,e,i,s,u)}async getFederation(e,i=null){return Rn(this,e,i)}async getFederatedConfig(e,i,s=null){return rm(this,e,i,s)}async unfederate(e,i,s,u=null){return await nm(this,e,i,s,u)}async removeNotify(e,i,s=null){console.log(`HoloSphere.removeNotify called: ${e}, ${i}`);try{let u=await im(this,e,i,s);return console.log(`HoloSphere.removeNotify completed successfully: ${u}`),u}catch(u){throw console.error("HoloSphere.removeNotify failed:",u),u}}async getFederated(e,i,s={}){return om(this,e,i,s)}async federateMessage(e,i,s,u,d="generic"){return am(this,e,i,s,u,d)}async getFederatedMessages(e,i){return Qu(this,e,i)}async updateFederatedMessages(e,i,s){return lm(this,e,i,s)}async resetFederation(e,i=null){return um(this,e,i)}async close(){return Lm(this)}userName(e){return qm(this,e)}getVersion(){return Um}},Q8=Gu;return g1(L8);})();
31
+ `));return m.summary=y,await n.db.put("cell",m),m}catch(s){throw console.error("Error during updateParent:",s),s}}async function Bm(n,e,i){return Ya(n,e,i)}function Mm(n,e){let i=[],s=Ya(n,e,14);i.push(s);for(let u=13;u>=0;u--)i.push(OA(s,u));return i}function jm(n){let e=[],i=TA(n);for(let s=i;s>=0;s--)e.push(OA(n,s));return e}async function Nm(n,e,i,s){if(!e||!i)throw new Error("subscribe: Missing holon or lens parameters:",e,i);if(!s||typeof s!="function")throw new Error("subscribe: Callback must be a function");let u=n.generateId();try{let d=n.gun.get(n.appname).get(e).get(i).map(),m=d.on(async(y,E)=>{if(n.subscriptions[u]&&y)try{let b=await n.parse(y);if(b&&n.isHologram(b)){let w=await n.resolveHologram(b,{followHolograms:!0});w!==b&&(b=w)}n.subscriptions[u]&&s(b,E)}catch(b){console.error("Error processing subscribed data:",b)}});return n.subscriptions[u]={id:u,holon:e,lens:i,callback:s,mapChain:d,gunListener:m},{unsubscribe:async()=>{let y=n.subscriptions[u];if(y)try{y.mapChain&&y.mapChain.off(),delete n.subscriptions[u]}catch(E){console.error(`Error during unsubscribe logic for ${u}:`,E)}}}}catch(d){throw console.error("Error creating subscription:",d),d}}function Fm(n,e){if(!(!e||!e.holon||!e.lens))try{Object.values(n.subscriptions).forEach(i=>{if(i.holon===e.holon&&i.lens===e.lens)try{i.callback&&typeof i.callback=="function"&&i.callback(e)}catch(s){console.warn("Error in subscription callback:",s)}})}catch(i){console.warn("Error notifying subscribers:",i)}}function Qm(){return Date.now().toString(10)+Math.random().toString(2)}async function Lm(n){try{if(n.gun){let e=Object.keys(n.subscriptions);for(let i of e)try{let s=n.subscriptions[i];s&&s.mapChain&&s.mapChain.off()}catch(s){console.warn(`Error cleaning up subscription ${i}:`,s)}if(n.subscriptions={},n.clearSchemaCache(),n.gun.back)try{let i=n.gun.back("opt.mesh");if(i){if(i.hear)try{let s=Object.keys(i.hear);for(let u of s)Array.isArray(i.hear[u])&&(i.hear[u]=[]);typeof i.hear!="function"&&(i.hear={})}catch(s){console.warn("Error cleaning up Gun mesh hear:",s)}if(i.way)try{Object.values(i.way).forEach(s=>{s&&s.wire&&s.wire.close&&s.wire.close()})}catch(s){console.warn("Error closing mesh sockets:",s)}i.opt&&i.opt.peers&&(i.opt.peers={})}if(n.gun.back("opt.web"))try{let s=n.gun.back("opt.web");s&&s.close&&s.close()}catch(s){console.warn("Error closing web server:",s)}}catch(i){console.warn("Error accessing Gun mesh:",i)}try{n.gun.off()}catch(i){console.warn("Error turning off Gun listeners:",i)}await new Promise(i=>setTimeout(i,100))}console.log("HoloSphere instance closed successfully")}catch(e){console.error("Error closing HoloSphere instance:",e)}}function qm(n,e){return e?`${n.appname}:${e}`:null}var Um="1.1.16",Gu=class{constructor(e,i=!1,s=null,u={}){console.log("HoloSphere v"+Um),this.appname=e,this.strict=i,this.validator=new Hm.default({allErrors:!0,strict:!1,validateSchema:!0});let m={...{peers:["https://gun.holons.io/gun","https://59.src.eco/gun"],axe:!1},...u};console.log("Initializing Gun with options:",m),this.gun=(0,Gm.default)(m),s!=null&&(this.openai=new Yc({apiKey:s})),this.subscriptions={},this.schemaCache=new Map}getGun(){return this.gun}async setSchema(e,i){return fm(this,e,i)}async getSchema(e,i={}){return cm(this,e,i)}clearSchemaCache(e=null){return dm(this,e)}async put(e,i,s,u=null,d={}){return hm(this,e,i,s,u,d)}async get(e,i,s,u=null,d={}){return Lu(this,e,i,s,u,d)}async getAll(e,i,s=null){return pm(this,e,i,s)}async parse(e){return mm(this,e)}async delete(e,i,s,u=null){return gm(this,e,i,s,u)}async deleteAll(e,i,s=null){return ym(this,e,i,s)}async putNode(e,i,s){return wm(this,e,i,s)}async getNode(e,i,s){return _m(this,e,i,s)}getNodeRef(e){return qu(this,e)}async getNodeBySoul(e){return vm(this,e)}async deleteNode(e,i,s){return bm(this,e,i,s)}async putGlobal(e,i,s=null){return Em(this,e,i,s)}async getGlobal(e,i,s=null){return $m(this,e,i,s)}async getAllGlobal(e,i=null){return Pm(this,e,i)}async deleteGlobal(e,i,s=null){return km(this,e,i,s)}async deleteAllGlobal(e,i=null){return Cm(this,e,i)}createHologram(e,i,s){return Sm(this,e,i,s)}parseSoulPath(e){return Uu(e)}isHologram(e){return ha(e)}async resolveHologram(e,i={}){return Dm(this,e,i)}async computeHierarchy(e,i,s,u=15,d=null){return xm(this,e,i,s,u,d)}async compute(e,i,s,u=null){return Rm(this,e,i,s,u)}async summarize(e){return Tm(this,e)}async upcast(e,i,s,u=15){return Om(this,e,i,s,u)}async updateParent(e,i){return Im(this,e,i)}async propagate(e,i,s,u={}){return sm(this,e,i,s,u)}async getHolon(e,i,s){return Bm(e,i,s)}getScalespace(e,i){return Mm(e,i)}getHolonScalespace(e){return jm(e)}async subscribe(e,i,s){return Nm(this,e,i,s)}notifySubscribers(e){return Fm(this,e)}generateId(){return Qm()}async federate(e,i,s=null,u=null,d=!0,m={}){return tm(this,e,i,s,u,d,m)}async subscribeFederation(e,i,s,u={}){return Am(this,e,i,s,u)}async getFederation(e,i=null){return Rn(this,e,i)}async getFederatedConfig(e,i,s=null){return rm(this,e,i,s)}async unfederate(e,i,s,u=null){return await nm(this,e,i,s,u)}async removeNotify(e,i,s=null){console.log(`HoloSphere.removeNotify called: ${e}, ${i}`);try{let u=await im(this,e,i,s);return console.log(`HoloSphere.removeNotify completed successfully: ${u}`),u}catch(u){throw console.error("HoloSphere.removeNotify failed:",u),u}}async getFederated(e,i,s={}){return om(this,e,i,s)}async federateMessage(e,i,s,u,d="generic"){return am(this,e,i,s,u,d)}async getFederatedMessages(e,i){return Qu(this,e,i)}async updateFederatedMessages(e,i,s){return lm(this,e,i,s)}async resetFederation(e,i=null){return um(this,e,i)}async close(){return Lm(this)}userName(e){return qm(this,e)}getVersion(){return Um}},Q8=Gu;return g1(L8);})();
32
32
  /**
33
33
  * @module holosphere
34
34
  * @version 1.1.12
package/holosphere.js CHANGED
@@ -20,7 +20,7 @@ import * as ComputeOps from './compute.js';
20
20
  import * as Utils from './utils.js';
21
21
 
22
22
  // Define the version constant
23
- const HOLOSPHERE_VERSION = '1.1.15';
23
+ const HOLOSPHERE_VERSION = '1.1.16';
24
24
 
25
25
  class HoloSphere {
26
26
  /**
package/package.json CHANGED
@@ -1,21 +1,20 @@
1
1
  {
2
2
  "name": "holosphere",
3
- "version": "1.1.15",
3
+ "version": "1.1.16",
4
4
  "description": "Holonic Geospatial Communication Infrastructure",
5
- "main": "holosphere.js",
6
- "module": "holosphere.js",
7
- "types": "holosphere.d.ts",
5
+ "main": "./holosphere.js",
6
+ "module": "./holosphere.js",
7
+ "types": "./holosphere.d.ts",
8
8
  "type": "module",
9
+ "sideEffects": false,
9
10
  "scripts": {
10
11
  "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
11
- "build": "npm run build:browser",
12
- "prepare": "npm run build",
12
+ "build": "node build.js",
13
13
  "build:browser": "node build.js",
14
14
  "build:bundle": "node build.js",
15
- "prepublishOnly": "npm run build",
15
+ "prepublishOnly": "node build.js",
16
16
  "publish:cdn": "npm publish && echo 'Package published to npm and will be available on CDNs within minutes'",
17
- "publish:force": "npm publish --force && echo 'Package force published to npm and will be available on CDNs within minutes'",
18
- "prepublish:skip-tests": "npm run build"
17
+ "publish:force": "npm publish --force && echo 'Package force published to npm and will be available on CDNs within minutes'"
19
18
  },
20
19
  "author": "Roberto Valenti",
21
20
  "license": "GPL-3.0-or-later",
@@ -59,6 +58,7 @@
59
58
  ],
60
59
  "exports": {
61
60
  ".": {
61
+ "types": "./holosphere.d.ts",
62
62
  "import": "./holosphere.js",
63
63
  "require": "./holosphere.js",
64
64
  "default": "./holosphere.js"