this.me 3.0.30 → 3.0.33

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.
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- <img src="https://res.cloudinary.com/dkwnxf6gm/image/upload/v1761149332/this.me-removebg-preview_2_j1eoiy.png" alt=".me Logo" width="180" />
1
+ <img src="https://res.cloudinary.com/dkwnxf6gm/image/upload/v1761149332/this.me-removebg-preview_2_j1eoiy.png" alt=".me Logo" width="144" />
2
2
 
3
3
  # .me
4
4
 
@@ -280,10 +280,50 @@ console.log(JSON.stringify(me.export(), null, 2));
280
280
 
281
281
  ---
282
282
 
283
+ ## 🧬 Self-Semantic Runtime Invariance
284
+ The runtime of `.me` is written **in the same semantic model that it interprets**, making it a *self-describing* and *self-sustaining* identity system.
285
+ This property is known as **Self‑Semantic Runtime Invariance**.
286
+
287
+ ### Why this matters
288
+ - The language can describe itself using its own primitives.
289
+ - The runtime’s behavior is encoded in the same declarative structures users write.
290
+ - Every semantic operation becomes both:
291
+ - a computation, and
292
+ - a piece of meaning inside the identity universe.
293
+ - The system is *reflexive*: the runtime can observe, narrate, and export its own evolution.
294
+
295
+ ### In practice
296
+ Every declaration you make, `.me` writes it not only into your semantic tree, but also into:
297
+
298
+ ```
299
+ me.runtime.thoughts[]
300
+ ```
301
+
302
+ This creates a self-referential timeline of meaning — the system *thinking about what you're thinking*.
303
+
304
+ Traditional systems separate:
305
+ - language
306
+ - program
307
+ - runtime
308
+ - identity
309
+ - data model
310
+
311
+ But `.me` unifies all of them into **one semantic calculus**.
312
+
313
+ The system remains stable because it is congruent with itself:
314
+ **the runtime follows the same rules as the identities it executes.**
315
+
316
+ This is the foundation of **.me Calculus** — a universal, self-describing identity engine.
317
+
318
+ ---
319
+
283
320
  ## ▵ The Philosophy
321
+
322
+ > **Human owns meaning. Everything else asks.**
323
+
284
324
  A semantic language for identity, built from recursive declarations and symbolic paths.
285
325
 
286
- `me` is ▵ **meaning** ▵ **identities** ▵ **universes** ▵ **meaning.**
326
+ `me` is ▵ **meaning** ▵ **identities** ▵ **universes**.
287
327
 
288
328
  With one primitive:
289
329
 
@@ -291,7 +331,7 @@ With one primitive:
291
331
  me
292
332
  ```
293
333
 
294
- What **.me** unlocks is something the entire industry has failed to deliver: **true ownership of your identity**. Not through passwords, dashboards, cookie banners, or corporate “trust us” slogans — but through architecture. In **.me**, your data isn’t stored anywhere. It isn’t synced. It isn’t saved on a server you don’t control. Your identity is *derived*, meaning it only exists when *you* decide to bring it into existence. Secrets carve out private worlds inside your identity that are mathematically unreachable without your key. That means you can create layers of meaning, memory, and structure that no platform, provider, or device can see — or even detect. **No one can mine it**, leak it, subpoena it, or surveil it. Not because they’re nice, but because the system simply doesn’t expose what you don’t reveal. This is data freedom not as a policy, but as a *calculable fact*. A shift from platforms owning your life — to you owning your universes. - [suiGn](https://suign.github.io/)
334
+ What **.me** unlocks is something the entire industry has failed to deliver: **true ownership of your identity**. Not through passwords, dashboards, cookie banners, or corporate “trust us” slogans — but **through architecture**. In **.me**, your data isn’t stored anywhere. It isn’t synced. It isn’t saved on a server you don’t control. Your identity is *derived*, meaning it only exists when *you* decide to bring it into existence. Secrets carve out private worlds inside your identity that are mathematically unreachable without your key. That means you can create layers of meaning, memory, and structure that no platform, provider, or device can see — or even detect. **No one can mine it**, leak it, subpoena it, or surveil it. Not because they’re nice, but because the system simply doesn’t expose what you don’t reveal. This is data freedom not as a policy, but as a *calculable fact*. A shift from platforms owning your life — to you owning your universes. - [suiGn](https://suign.github.io/)
295
335
 
296
336
  <a href="https://www.neurons.me" target="_blank">
297
337
  <img src="https://res.cloudinary.com/dkwnxf6gm/image/upload/v1760893633/npm-neurons-me_9b3e3a.jpg" style="zoom:16%;" /></a>
@@ -300,3 +340,4 @@ What **.me** unlocks is something the entire industry has failed to deliver: **t
300
340
  MIT © 2025 by https://neurons.me
301
341
  See the [LICENSE](./LICENSE) file for details.
302
342
 
343
+ </file>
package/dist/index.d.ts CHANGED
@@ -1,2 +1 @@
1
- import { ME } from './src/me.js';
2
- export { ME };
1
+ export { ME as default } from './src/me.js';
package/dist/me.cjs CHANGED
@@ -1,8 +1,8 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var ce=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ae(E){return E&&E.__esModule&&Object.prototype.hasOwnProperty.call(E,"default")?E.default:E}var Ut={exports:{}};/**
1
+ "use strict";function ve(c){return{__ptr:c}}function Yt(c){return!!c&&typeof c=="object"&&typeof c.__ptr=="string"&&c.__ptr.length>0}function ge(c){return{__id:c}}function te(c){return!!c&&typeof c=="object"&&typeof c.__id=="string"&&c.__id.length>0}function be(c){return!!c&&typeof c=="object"&&typeof c.path=="string"&&typeof c.hash=="string"&&typeof c.timestamp=="number"}function N(c){return c.length===0?{scope:[],leaf:null}:{scope:c.slice(0,-1),leaf:c[c.length-1]}}function ce(c,r){if(r.length>c.length)return!1;for(let e=0;e<r.length;e++)if(c[e]!==r[e])return!1;return!0}function ae(c){const r=c.trim().toLowerCase();if(r.length<3||r.length>63)throw new Error(`Invalid username length: ${r.length}. Expected 3..63 characters.`);if(!/^[a-z0-9][a-z0-9-]*[a-z0-9]$/.test(r))throw new Error(`Invalid username. Use only [a-z0-9-], and start/end with [a-z0-9]. Got: ${c}`);if(r.includes("--"))throw new Error(`Invalid username. "--" is not allowed. Got: ${c}`);return r}var Se=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ke(c){return c&&c.__esModule&&Object.prototype.hasOwnProperty.call(c,"default")?c.default:c}var ee={exports:{}};/**
2
2
  * [js-sha3]{@link https://github.com/emn178/js-sha3}
3
3
  *
4
4
  * @version 0.9.3
5
5
  * @author Chen, Yi-Cyuan [emn178@gmail.com]
6
6
  * @copyright Chen, Yi-Cyuan 2015-2023
7
7
  * @license MIT
8
- */var te;function he(){return te||(te=1,(function(E){(function(){var i="input is invalid type",o="finalize already called",l=typeof window=="object",c=l?window:{};c.JS_SHA3_NO_WINDOW&&(l=!1);var y=!l&&typeof self=="object",b=!c.JS_SHA3_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;b?c=ce:y&&(c=self);for(var B=!c.JS_SHA3_NO_COMMON_JS&&!0&&E.exports,p=!c.JS_SHA3_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",d="0123456789abcdef".split(""),P=[31,7936,2031616,520093696],k=[4,1024,262144,67108864],F=[1,256,65536,16777216],w=[6,1536,393216,100663296],v=[0,8,16,24],_=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],j=[224,256,384,512],C=[128,256],A=["hex","buffer","arrayBuffer","array","digest"],K={128:168,256:136},ee=c.JS_SHA3_NO_NODE_JS||!Array.isArray?function(t){return Object.prototype.toString.call(t)==="[object Array]"}:Array.isArray,re=p&&(c.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)?function(t){return typeof t=="object"&&t.buffer&&t.buffer.constructor===ArrayBuffer}:ArrayBuffer.isView,Vt=function(t){var e=typeof t;if(e==="string")return[t,!0];if(e!=="object"||t===null)throw new Error(i);if(p&&t.constructor===ArrayBuffer)return[new Uint8Array(t),!1];if(!ee(t)&&!re(t))throw new Error(i);return[t,!1]},Gt=function(t){return Vt(t)[0].length===0},Jt=function(t){for(var e=[],r=0;r<t.length;++r)e[r]=t[r];return e},Yt=function(t,e,r){return function(n){return new g(t,e,t).update(n)[r]()}},qt=function(t,e,r){return function(n,a){return new g(t,e,a).update(n)[r]()}},$t=function(t,e,r){return function(n,a,h,u){return T["cshake"+t].update(n,a,h,u)[r]()}},Lt=function(t,e,r){return function(n,a,h,u){return T["kmac"+t].update(n,a,h,u)[r]()}},I=function(t,e,r,n){for(var a=0;a<A.length;++a){var h=A[a];t[h]=e(r,n,h)}return t},Xt=function(t,e){var r=Yt(t,e,"hex");return r.create=function(){return new g(t,e,t)},r.update=function(n){return r.create().update(n)},I(r,Yt,t,e)},ne=function(t,e){var r=qt(t,e,"hex");return r.create=function(n){return new g(t,e,n)},r.update=function(n,a){return r.create(a).update(n)},I(r,qt,t,e)},oe=function(t,e){var r=K[t],n=$t(t,e,"hex");return n.create=function(a,h,u){return Gt(h)&&Gt(u)?T["shake"+t].create(a):new g(t,e,a).bytepad([h,u],r)},n.update=function(a,h,u,f){return n.create(h,u,f).update(a)},I(n,$t,t,e)},ie=function(t,e){var r=K[t],n=Lt(t,e,"hex");return n.create=function(a,h,u){return new Wt(t,e,h).bytepad(["KMAC",u],r).bytepad([a],r)},n.update=function(a,h,u,f){return n.create(a,u,f).update(h)},I(n,Lt,t,e)},Zt=[{name:"keccak",padding:F,bits:j,createMethod:Xt},{name:"sha3",padding:w,bits:j,createMethod:Xt},{name:"shake",padding:P,bits:C,createMethod:ne},{name:"cshake",padding:k,bits:C,createMethod:oe},{name:"kmac",padding:k,bits:C,createMethod:ie}],T={},N=[],R=0;R<Zt.length;++R)for(var M=Zt[R],V=M.bits,D=0;D<V.length;++D){var zt=M.name+"_"+V[D];if(N.push(zt),T[zt]=M.createMethod(V[D],M.padding),M.name!=="sha3"){var Qt=M.name+V[D];N.push(Qt),T[Qt]=T[zt]}}function g(t,e,r){this.blocks=[],this.s=[],this.padding=e,this.outputBits=r,this.reset=!0,this.finalized=!1,this.block=0,this.start=0,this.blockCount=1600-(t<<1)>>5,this.byteCount=this.blockCount<<2,this.outputBlocks=r>>5,this.extraBytes=(r&31)>>3;for(var n=0;n<50;++n)this.s[n]=0}g.prototype.update=function(t){if(this.finalized)throw new Error(o);var e=Vt(t);t=e[0];for(var r=e[1],n=this.blocks,a=this.byteCount,h=t.length,u=this.blockCount,f=0,S=this.s,s,x;f<h;){if(this.reset)for(this.reset=!1,n[0]=this.block,s=1;s<u+1;++s)n[s]=0;if(r)for(s=this.start;f<h&&s<a;++f)x=t.charCodeAt(f),x<128?n[s>>2]|=x<<v[s++&3]:x<2048?(n[s>>2]|=(192|x>>6)<<v[s++&3],n[s>>2]|=(128|x&63)<<v[s++&3]):x<55296||x>=57344?(n[s>>2]|=(224|x>>12)<<v[s++&3],n[s>>2]|=(128|x>>6&63)<<v[s++&3],n[s>>2]|=(128|x&63)<<v[s++&3]):(x=65536+((x&1023)<<10|t.charCodeAt(++f)&1023),n[s>>2]|=(240|x>>18)<<v[s++&3],n[s>>2]|=(128|x>>12&63)<<v[s++&3],n[s>>2]|=(128|x>>6&63)<<v[s++&3],n[s>>2]|=(128|x&63)<<v[s++&3]);else for(s=this.start;f<h&&s<a;++f)n[s>>2]|=t[f]<<v[s++&3];if(this.lastByteIndex=s,s>=a){for(this.start=s-a,this.block=n[u],s=0;s<u;++s)S[s]^=n[s];H(S),this.reset=!0}else this.start=s}return this},g.prototype.encode=function(t,e){var r=t&255,n=1,a=[r];for(t=t>>8,r=t&255;r>0;)a.unshift(r),t=t>>8,r=t&255,++n;return e?a.push(n):a.unshift(n),this.update(a),a.length},g.prototype.encodeString=function(t){var e=Vt(t);t=e[0];var r=e[1],n=0,a=t.length;if(r)for(var h=0;h<t.length;++h){var u=t.charCodeAt(h);u<128?n+=1:u<2048?n+=2:u<55296||u>=57344?n+=3:(u=65536+((u&1023)<<10|t.charCodeAt(++h)&1023),n+=4)}else n=a;return n+=this.encode(n*8),this.update(t),n},g.prototype.bytepad=function(t,e){for(var r=this.encode(e),n=0;n<t.length;++n)r+=this.encodeString(t[n]);var a=(e-r%e)%e,h=[];return h.length=a,this.update(h),this},g.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var t=this.blocks,e=this.lastByteIndex,r=this.blockCount,n=this.s;if(t[e>>2]|=this.padding[e&3],this.lastByteIndex===this.byteCount)for(t[0]=t[r],e=1;e<r+1;++e)t[e]=0;for(t[r-1]|=2147483648,e=0;e<r;++e)n[e]^=t[e];H(n)}},g.prototype.toString=g.prototype.hex=function(){this.finalize();for(var t=this.blockCount,e=this.s,r=this.outputBlocks,n=this.extraBytes,a=0,h=0,u="",f;h<r;){for(a=0;a<t&&h<r;++a,++h)f=e[a],u+=d[f>>4&15]+d[f&15]+d[f>>12&15]+d[f>>8&15]+d[f>>20&15]+d[f>>16&15]+d[f>>28&15]+d[f>>24&15];h%t===0&&(e=Jt(e),H(e),a=0)}return n&&(f=e[a],u+=d[f>>4&15]+d[f&15],n>1&&(u+=d[f>>12&15]+d[f>>8&15]),n>2&&(u+=d[f>>20&15]+d[f>>16&15])),u},g.prototype.arrayBuffer=function(){this.finalize();var t=this.blockCount,e=this.s,r=this.outputBlocks,n=this.extraBytes,a=0,h=0,u=this.outputBits>>3,f;n?f=new ArrayBuffer(r+1<<2):f=new ArrayBuffer(u);for(var S=new Uint32Array(f);h<r;){for(a=0;a<t&&h<r;++a,++h)S[h]=e[a];h%t===0&&(e=Jt(e),H(e))}return n&&(S[h]=e[a],f=f.slice(0,u)),f},g.prototype.buffer=g.prototype.arrayBuffer,g.prototype.digest=g.prototype.array=function(){this.finalize();for(var t=this.blockCount,e=this.s,r=this.outputBlocks,n=this.extraBytes,a=0,h=0,u=[],f,S;h<r;){for(a=0;a<t&&h<r;++a,++h)f=h<<2,S=e[a],u[f]=S&255,u[f+1]=S>>8&255,u[f+2]=S>>16&255,u[f+3]=S>>24&255;h%t===0&&(e=Jt(e),H(e))}return n&&(f=h<<2,S=e[a],u[f]=S&255,n>1&&(u[f+1]=S>>8&255),n>2&&(u[f+2]=S>>16&255)),u};function Wt(t,e,r){g.call(this,t,e,r)}Wt.prototype=new g,Wt.prototype.finalize=function(){return this.encode(this.outputBits,!0),g.prototype.finalize.call(this)};var H=function(t){var e,r,n,a,h,u,f,S,s,x,J,z,W,U,m,G,Y,q,$,L,X,Z,Q,tt,et,rt,nt,ot,it,ct,at,ht,ft,lt,ut,st,yt,dt,bt,pt,vt,xt,gt,St,Pt,Bt,kt,At,Ft,wt,_t,jt,Ct,Ot,Et,Tt,Rt,Kt,Mt,Nt,Dt,Ht,It;for(n=0;n<48;n+=2)a=t[0]^t[10]^t[20]^t[30]^t[40],h=t[1]^t[11]^t[21]^t[31]^t[41],u=t[2]^t[12]^t[22]^t[32]^t[42],f=t[3]^t[13]^t[23]^t[33]^t[43],S=t[4]^t[14]^t[24]^t[34]^t[44],s=t[5]^t[15]^t[25]^t[35]^t[45],x=t[6]^t[16]^t[26]^t[36]^t[46],J=t[7]^t[17]^t[27]^t[37]^t[47],z=t[8]^t[18]^t[28]^t[38]^t[48],W=t[9]^t[19]^t[29]^t[39]^t[49],e=z^(u<<1|f>>>31),r=W^(f<<1|u>>>31),t[0]^=e,t[1]^=r,t[10]^=e,t[11]^=r,t[20]^=e,t[21]^=r,t[30]^=e,t[31]^=r,t[40]^=e,t[41]^=r,e=a^(S<<1|s>>>31),r=h^(s<<1|S>>>31),t[2]^=e,t[3]^=r,t[12]^=e,t[13]^=r,t[22]^=e,t[23]^=r,t[32]^=e,t[33]^=r,t[42]^=e,t[43]^=r,e=u^(x<<1|J>>>31),r=f^(J<<1|x>>>31),t[4]^=e,t[5]^=r,t[14]^=e,t[15]^=r,t[24]^=e,t[25]^=r,t[34]^=e,t[35]^=r,t[44]^=e,t[45]^=r,e=S^(z<<1|W>>>31),r=s^(W<<1|z>>>31),t[6]^=e,t[7]^=r,t[16]^=e,t[17]^=r,t[26]^=e,t[27]^=r,t[36]^=e,t[37]^=r,t[46]^=e,t[47]^=r,e=x^(a<<1|h>>>31),r=J^(h<<1|a>>>31),t[8]^=e,t[9]^=r,t[18]^=e,t[19]^=r,t[28]^=e,t[29]^=r,t[38]^=e,t[39]^=r,t[48]^=e,t[49]^=r,U=t[0],m=t[1],Bt=t[11]<<4|t[10]>>>28,kt=t[10]<<4|t[11]>>>28,ot=t[20]<<3|t[21]>>>29,it=t[21]<<3|t[20]>>>29,Nt=t[31]<<9|t[30]>>>23,Dt=t[30]<<9|t[31]>>>23,xt=t[40]<<18|t[41]>>>14,gt=t[41]<<18|t[40]>>>14,lt=t[2]<<1|t[3]>>>31,ut=t[3]<<1|t[2]>>>31,G=t[13]<<12|t[12]>>>20,Y=t[12]<<12|t[13]>>>20,At=t[22]<<10|t[23]>>>22,Ft=t[23]<<10|t[22]>>>22,ct=t[33]<<13|t[32]>>>19,at=t[32]<<13|t[33]>>>19,Ht=t[42]<<2|t[43]>>>30,It=t[43]<<2|t[42]>>>30,Ot=t[5]<<30|t[4]>>>2,Et=t[4]<<30|t[5]>>>2,st=t[14]<<6|t[15]>>>26,yt=t[15]<<6|t[14]>>>26,q=t[25]<<11|t[24]>>>21,$=t[24]<<11|t[25]>>>21,wt=t[34]<<15|t[35]>>>17,_t=t[35]<<15|t[34]>>>17,ht=t[45]<<29|t[44]>>>3,ft=t[44]<<29|t[45]>>>3,tt=t[6]<<28|t[7]>>>4,et=t[7]<<28|t[6]>>>4,Tt=t[17]<<23|t[16]>>>9,Rt=t[16]<<23|t[17]>>>9,dt=t[26]<<25|t[27]>>>7,bt=t[27]<<25|t[26]>>>7,L=t[36]<<21|t[37]>>>11,X=t[37]<<21|t[36]>>>11,jt=t[47]<<24|t[46]>>>8,Ct=t[46]<<24|t[47]>>>8,St=t[8]<<27|t[9]>>>5,Pt=t[9]<<27|t[8]>>>5,rt=t[18]<<20|t[19]>>>12,nt=t[19]<<20|t[18]>>>12,Kt=t[29]<<7|t[28]>>>25,Mt=t[28]<<7|t[29]>>>25,pt=t[38]<<8|t[39]>>>24,vt=t[39]<<8|t[38]>>>24,Z=t[48]<<14|t[49]>>>18,Q=t[49]<<14|t[48]>>>18,t[0]=U^~G&q,t[1]=m^~Y&$,t[10]=tt^~rt&ot,t[11]=et^~nt&it,t[20]=lt^~st&dt,t[21]=ut^~yt&bt,t[30]=St^~Bt&At,t[31]=Pt^~kt&Ft,t[40]=Ot^~Tt&Kt,t[41]=Et^~Rt&Mt,t[2]=G^~q&L,t[3]=Y^~$&X,t[12]=rt^~ot&ct,t[13]=nt^~it&at,t[22]=st^~dt&pt,t[23]=yt^~bt&vt,t[32]=Bt^~At&wt,t[33]=kt^~Ft&_t,t[42]=Tt^~Kt&Nt,t[43]=Rt^~Mt&Dt,t[4]=q^~L&Z,t[5]=$^~X&Q,t[14]=ot^~ct&ht,t[15]=it^~at&ft,t[24]=dt^~pt&xt,t[25]=bt^~vt&gt,t[34]=At^~wt&jt,t[35]=Ft^~_t&Ct,t[44]=Kt^~Nt&Ht,t[45]=Mt^~Dt&It,t[6]=L^~Z&U,t[7]=X^~Q&m,t[16]=ct^~ht&tt,t[17]=at^~ft&et,t[26]=pt^~xt&lt,t[27]=vt^~gt&ut,t[36]=wt^~jt&St,t[37]=_t^~Ct&Pt,t[46]=Nt^~Ht&Ot,t[47]=Dt^~It&Et,t[8]=Z^~U&G,t[9]=Q^~m&Y,t[18]=ht^~tt&rt,t[19]=ft^~et&nt,t[28]=xt^~lt&st,t[29]=gt^~ut&yt,t[38]=jt^~St&Bt,t[39]=Ct^~Pt&kt,t[48]=Ht^~Ot&Tt,t[49]=It^~Et&Rt,t[0]^=_[n],t[1]^=_[n+1]};if(B)E.exports=T;else for(R=0;R<N.length;++R)c[N[R]]=T[N[R]]})()})(Ut)),Ut.exports}var fe=he();const le=ae(fe),{keccak256:O}=le;class mt{constructor(i,o,l){this.payload={},this.declarations=[],this.secrets={},this.branchVersions={},this.username=i,this.secret=o,this.blockchain=l,this.identityRoot="0x"+O(o),this.publicKey="0x"+O("public:"+o),this.identityHash="0x"+O(this.publicKey+this.username),this.secrets[""]=o;const c=this.createProxy([]);return Object.setPrototypeOf(c,mt.prototype),Object.assign(c,this),c}createProxy(i){const o=this,l=(...c)=>o.handleCall(i,c);return new Proxy(l,{get(c,y){if(typeof y=="symbol")return c[y];if(y==="secret")return o.createProxy([...i,String(y)]);if(y in o)return o[y];const b=[...i,String(y)];return o.createProxy(b)},apply(c,y,b){return o.handleCall(i,b)}})}handleCall(i,o){if(i.length===0){if(o.length===1&&typeof o[0]=="string"){const p=o[0].split(".").filter(Boolean);return this.exportBranch(p.join("."))}return this.createProxy([])}const l=i[i.length-1];if(l==="secret"){const p=i.slice(0,-1),d=p.join("."),P=String(o[0]??"");if(!P)return this.createProxy(p);this.secrets[d]=P;const k="0x"+O(this.secret+d+"::secret-set");return this.declarations.push({key:d+".secret",value:"<secret-set>",signature:k,timestamp:Date.now()}),this.createProxy(p)}if(l==="ptr")return{__ptr:i.slice(0,-1).join(".")};const c=i.join(".");let y;o.length===0?y=void 0:o.length===1?y=o[0]:y=o,this.ensurePath(i,y);const b=this.resolveSecret(i),B="0x"+O(b+c+JSON.stringify(y));return this.declarations.push({key:c,value:y,signature:B,timestamp:Date.now()}),this.createProxy(i)}resolveSecretWithPath(i){for(let o=i.length;o>=0;o--){const l=i.slice(0,o).join(".");if(this.secrets[l])return{secret:this.secrets[l],secretPath:i.slice(0,o)}}return{secret:this.secret,secretPath:[]}}resolveSecret(i){return this.resolveSecretWithPath(i).secret}ensurePath(i,o){const{secret:l,secretPath:c}=this.resolveSecretWithPath(i),y=c.join("."),b=O(l);if(c.length>0){let k={};const F=this.branchVersions[y]?.[b],w=this.getSubPayload(c);if(F){const A=this.decryptForPath(c,F);A&&typeof A=="object"&&(k=A)}else if(typeof w=="string"){const A=this.decryptForPath(c,w);A&&typeof A=="object"&&(k=A)}else w&&typeof w=="object"&&(k=w);const v=i.slice(c.length);let _=k;for(let A=0;A<v.length-1;A++){const K=v[A];(!_[K]||typeof _[K]!="object")&&(_[K]={}),_=_[K]}const j=v[v.length-1];_[j]=o;const C=this.encryptForPath(c,k);this.branchVersions[y]||(this.branchVersions[y]={}),this.branchVersions[y][b]=C,this.writeBranchBlob(c,C);return}const p=this.encryptForPath(i,o);let d=this.payload;for(let k=0;k<i.length-1;k++){const F=i[k];(!d[F]||typeof d[F]!="object")&&(d[F]={}),d=d[F]}const P=i[i.length-1];d[P]=p}setSubPayload(i,o){if(i.length===0){this.payload=o;return}let l=this.payload;for(let y=0;y<i.length-1;y++){const b=i[y];(!l[b]||typeof l[b]!="object")&&(l[b]={}),l=l[b]}const c=i[i.length-1];l[c]=o}findNearestBranchAncestor(i){for(let o=i.length-1;o>=1;o--){const l=i.slice(0,o),c=l.join(".");if(this.branchVersions[c])return{path:l,secret:this.resolveSecret(l)}}return null}writeBranchBlob(i,o){let l=i,c=o;for(;;){const y=this.findNearestBranchAncestor(l);if(!y){this.setSubPayload(l,c);return}const{path:b,secret:B}=y,p=b.join("."),d=O(B),P=this.getSubPayload(b),k=this.branchVersions[p]?.[d]??(typeof P=="string"?P:void 0);let F={};if(k){const j=this.decryptForPath(b,k);j&&typeof j=="object"&&(F=j)}const w=l.slice(b.length);let v=F;for(let j=0;j<w.length-1;j++){const C=w[j];(!v[C]||typeof v[C]!="object")&&(v[C]={}),v=v[C]}v[w[w.length-1]]=c;const _=this.encryptForPath(b,F);this.branchVersions[p]||(this.branchVersions[p]={}),this.branchVersions[p][d]=_,l=b,c=_}}getSubPayload(i){let o=this.payload;for(const l of i){if(!o||typeof o!="object")return;o=o[l]}return o}decryptTree(i,o){if(o==null)return o;if(typeof o=="string"){if(!this.isHexString(o))return o;const c=this.decryptForPath(i,o);return c===null?o:c}if(typeof o!="object")return o;const l=Array.isArray(o)?[]:{};for(const c of Object.keys(o)){const y=[...i,c];l[c]=this.decryptTree(y,o[c])}return l}encryptForPath(i,o){const l=this.resolveSecret(i),c=JSON.stringify(o),y=new TextEncoder().encode(c),b=O(l+":"+i.join(".")),B=this.asciiToBytes(b),p=new Uint8Array(y.length);for(let P=0;P<y.length;P++)p[P]=y[P]^B[P%B.length];let d="";for(let P=0;P<p.length;P++)d+=p[P].toString(16).padStart(2,"0");return d}decryptForPath(i,o){const l=this.resolveSecret(i);try{const c=this.hexToBytes(o),y=O(l+":"+i.join(".")),b=this.asciiToBytes(y),B=new Uint8Array(c.length);for(let d=0;d<c.length;d++)B[d]=c[d]^b[d%b.length];const p=new TextDecoder().decode(B);return JSON.parse(p)}catch{return null}}asciiToBytes(i){return new TextEncoder().encode(i)}hexToBytes(i){const o=i.startsWith("0x")?i.slice(2):i,l=new Uint8Array(o.length/2);for(let c=0;c<l.length;c++)l[c]=parseInt(o.substr(c*2,2),16);return l}isHexString(i){const o=i.startsWith("0x")?i.slice(2):i;return o.length>0&&o.length%2===0&&/^[0-9a-fA-F]+$/.test(o)}export(){return{identityRoot:this.identityRoot,publicKey:this.publicKey,identityHash:this.identityHash,declarations:this.declarations,payload:this.payload}}exportBranch(i){const o=i?i.split(".").filter(Boolean):[],l=o.join("."),c=this.resolveSecret(o),y=O(c),b=this.branchVersions[l]?.[y];if(b){const p=this.decryptForPath(o,b);return this.decryptTree(o,p)}const B=this.getSubPayload(o);if(B!==void 0){if(typeof B=="string"){const p=this.decryptForPath(o,B);return this.decryptTree(o,p)}return this.decryptTree(o,B)}}}exports.ME=mt;
8
+ */var fe;function me(){return fe||(fe=1,(function(c){(function(){var r="input is invalid type",e="finalize already called",a=typeof window=="object",i=a?window:{};i.JS_SHA3_NO_WINDOW&&(a=!1);var f=!a&&typeof self=="object",p=!i.JS_SHA3_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;p?i=Se:f&&(i=self);for(var b=!i.JS_SHA3_NO_COMMON_JS&&!0&&c.exports,y=!i.JS_SHA3_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",g="0123456789abcdef".split(""),S=[31,7936,2031616,520093696],O=[4,1024,262144,67108864],W=[1,256,65536,16777216],z=[6,1536,393216,100663296],P=[0,8,16,24],D=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],E=[224,256,384,512],J=[128,256],$=["hex","buffer","arrayBuffer","array","digest"],q={128:168,256:136},Zt=i.JS_SHA3_NO_NODE_JS||!Array.isArray?function(t){return Object.prototype.toString.call(t)==="[object Array]"}:Array.isArray,L=y&&(i.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)?function(t){return typeof t=="object"&&t.buffer&&t.buffer.constructor===ArrayBuffer}:ArrayBuffer.isView,k=function(t){var n=typeof t;if(n==="string")return[t,!0];if(n!=="object"||t===null)throw new Error(r);if(y&&t.constructor===ArrayBuffer)return[new Uint8Array(t),!1];if(!Zt(t)&&!L(t))throw new Error(r);return[t,!1]},x=function(t){return k(t)[0].length===0},C=function(t){for(var n=[],o=0;o<t.length;++o)n[o]=t[o];return n},w=function(t,n,o){return function(l){return new B(t,n,t).update(l)[o]()}},_=function(t,n,o){return function(l,u){return new B(t,n,u).update(l)[o]()}},F=function(t,n,o){return function(l,u,h,d){return M["cshake"+t].update(l,u,h,d)[o]()}},I=function(t,n,o){return function(l,u,h,d){return M["kmac"+t].update(l,u,h,d)[o]()}},j=function(t,n,o,l){for(var u=0;u<$.length;++u){var h=$[u];t[h]=n(o,l,h)}return t},K=function(t,n){var o=w(t,n,"hex");return o.create=function(){return new B(t,n,t)},o.update=function(l){return o.create().update(l)},j(o,w,t,n)},de=function(t,n){var o=_(t,n,"hex");return o.create=function(l){return new B(t,n,l)},o.update=function(l,u){return o.create(u).update(l)},j(o,_,t,n)},pe=function(t,n){var o=q[t],l=F(t,n,"hex");return l.create=function(u,h,d){return x(h)&&x(d)?M["shake"+t].create(u):new B(t,n,u).bytepad([h,d],o)},l.update=function(u,h,d,s){return l.create(h,d,s).update(u)},j(l,F,t,n)},ye=function(t,n){var o=q[t],l=I(t,n,"hex");return l.create=function(u,h,d){return new Xt(t,n,h).bytepad(["KMAC",d],o).bytepad([u],o)},l.update=function(u,h,d,s){return l.create(u,d,s).update(h)},j(l,I,t,n)},oe=[{name:"keccak",padding:W,bits:E,createMethod:K},{name:"sha3",padding:z,bits:E,createMethod:K},{name:"shake",padding:S,bits:J,createMethod:de},{name:"cshake",padding:O,bits:J,createMethod:pe},{name:"kmac",padding:O,bits:J,createMethod:ye}],M={},U=[],T=0;T<oe.length;++T)for(var H=oe[T],Y=H.bits,V=0;V<Y.length;++V){var Qt=H.name+"_"+Y[V];if(U.push(Qt),M[Qt]=H.createMethod(Y[V],H.padding),H.name!=="sha3"){var le=H.name+Y[V];U.push(le),M[le]=M[Qt]}}function B(t,n,o){this.blocks=[],this.s=[],this.padding=n,this.outputBits=o,this.reset=!0,this.finalized=!1,this.block=0,this.start=0,this.blockCount=1600-(t<<1)>>5,this.byteCount=this.blockCount<<2,this.outputBlocks=o>>5,this.extraBytes=(o&31)>>3;for(var l=0;l<50;++l)this.s[l]=0}B.prototype.update=function(t){if(this.finalized)throw new Error(e);var n=k(t);t=n[0];for(var o=n[1],l=this.blocks,u=this.byteCount,h=t.length,d=this.blockCount,s=0,A=this.s,v,m;s<h;){if(this.reset)for(this.reset=!1,l[0]=this.block,v=1;v<d+1;++v)l[v]=0;if(o)for(v=this.start;s<h&&v<u;++s)m=t.charCodeAt(s),m<128?l[v>>2]|=m<<P[v++&3]:m<2048?(l[v>>2]|=(192|m>>6)<<P[v++&3],l[v>>2]|=(128|m&63)<<P[v++&3]):m<55296||m>=57344?(l[v>>2]|=(224|m>>12)<<P[v++&3],l[v>>2]|=(128|m>>6&63)<<P[v++&3],l[v>>2]|=(128|m&63)<<P[v++&3]):(m=65536+((m&1023)<<10|t.charCodeAt(++s)&1023),l[v>>2]|=(240|m>>18)<<P[v++&3],l[v>>2]|=(128|m>>12&63)<<P[v++&3],l[v>>2]|=(128|m>>6&63)<<P[v++&3],l[v>>2]|=(128|m&63)<<P[v++&3]);else for(v=this.start;s<h&&v<u;++s)l[v>>2]|=t[s]<<P[v++&3];if(this.lastByteIndex=v,v>=u){for(this.start=v-u,this.block=l[d],v=0;v<d;++v)A[v]^=l[v];G(A),this.reset=!0}else this.start=v}return this},B.prototype.encode=function(t,n){var o=t&255,l=1,u=[o];for(t=t>>8,o=t&255;o>0;)u.unshift(o),t=t>>8,o=t&255,++l;return n?u.push(l):u.unshift(l),this.update(u),u.length},B.prototype.encodeString=function(t){var n=k(t);t=n[0];var o=n[1],l=0,u=t.length;if(o)for(var h=0;h<t.length;++h){var d=t.charCodeAt(h);d<128?l+=1:d<2048?l+=2:d<55296||d>=57344?l+=3:(d=65536+((d&1023)<<10|t.charCodeAt(++h)&1023),l+=4)}else l=u;return l+=this.encode(l*8),this.update(t),l},B.prototype.bytepad=function(t,n){for(var o=this.encode(n),l=0;l<t.length;++l)o+=this.encodeString(t[l]);var u=(n-o%n)%n,h=[];return h.length=u,this.update(h),this},B.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var t=this.blocks,n=this.lastByteIndex,o=this.blockCount,l=this.s;if(t[n>>2]|=this.padding[n&3],this.lastByteIndex===this.byteCount)for(t[0]=t[o],n=1;n<o+1;++n)t[n]=0;for(t[o-1]|=2147483648,n=0;n<o;++n)l[n]^=t[n];G(l)}},B.prototype.toString=B.prototype.hex=function(){this.finalize();for(var t=this.blockCount,n=this.s,o=this.outputBlocks,l=this.extraBytes,u=0,h=0,d="",s;h<o;){for(u=0;u<t&&h<o;++u,++h)s=n[u],d+=g[s>>4&15]+g[s&15]+g[s>>12&15]+g[s>>8&15]+g[s>>20&15]+g[s>>16&15]+g[s>>28&15]+g[s>>24&15];h%t===0&&(n=C(n),G(n),u=0)}return l&&(s=n[u],d+=g[s>>4&15]+g[s&15],l>1&&(d+=g[s>>12&15]+g[s>>8&15]),l>2&&(d+=g[s>>20&15]+g[s>>16&15])),d},B.prototype.arrayBuffer=function(){this.finalize();var t=this.blockCount,n=this.s,o=this.outputBlocks,l=this.extraBytes,u=0,h=0,d=this.outputBits>>3,s;l?s=new ArrayBuffer(o+1<<2):s=new ArrayBuffer(d);for(var A=new Uint32Array(s);h<o;){for(u=0;u<t&&h<o;++u,++h)A[h]=n[u];h%t===0&&(n=C(n),G(n))}return l&&(A[h]=n[u],s=s.slice(0,d)),s},B.prototype.buffer=B.prototype.arrayBuffer,B.prototype.digest=B.prototype.array=function(){this.finalize();for(var t=this.blockCount,n=this.s,o=this.outputBlocks,l=this.extraBytes,u=0,h=0,d=[],s,A;h<o;){for(u=0;u<t&&h<o;++u,++h)s=h<<2,A=n[u],d[s]=A&255,d[s+1]=A>>8&255,d[s+2]=A>>16&255,d[s+3]=A>>24&255;h%t===0&&(n=C(n),G(n))}return l&&(s=h<<2,A=n[u],d[s]=A&255,l>1&&(d[s+1]=A>>8&255),l>2&&(d[s+2]=A>>16&255)),d};function Xt(t,n,o){B.call(this,t,n,o)}Xt.prototype=new B,Xt.prototype.finalize=function(){return this.encode(this.outputBits,!0),B.prototype.finalize.call(this)};var G=function(t){var n,o,l,u,h,d,s,A,v,m,Z,Q,X,tt,et,rt,nt,it,ot,lt,ct,at,ft,ut,ht,st,dt,pt,yt,vt,gt,bt,St,kt,mt,_t,xt,Bt,At,Pt,wt,Ct,Et,Ot,It,Ft,Nt,jt,Kt,Mt,Tt,zt,Dt,Rt,Wt,Jt,Ht,Ut,Vt,Gt,$t,qt,Lt;for(l=0;l<48;l+=2)u=t[0]^t[10]^t[20]^t[30]^t[40],h=t[1]^t[11]^t[21]^t[31]^t[41],d=t[2]^t[12]^t[22]^t[32]^t[42],s=t[3]^t[13]^t[23]^t[33]^t[43],A=t[4]^t[14]^t[24]^t[34]^t[44],v=t[5]^t[15]^t[25]^t[35]^t[45],m=t[6]^t[16]^t[26]^t[36]^t[46],Z=t[7]^t[17]^t[27]^t[37]^t[47],Q=t[8]^t[18]^t[28]^t[38]^t[48],X=t[9]^t[19]^t[29]^t[39]^t[49],n=Q^(d<<1|s>>>31),o=X^(s<<1|d>>>31),t[0]^=n,t[1]^=o,t[10]^=n,t[11]^=o,t[20]^=n,t[21]^=o,t[30]^=n,t[31]^=o,t[40]^=n,t[41]^=o,n=u^(A<<1|v>>>31),o=h^(v<<1|A>>>31),t[2]^=n,t[3]^=o,t[12]^=n,t[13]^=o,t[22]^=n,t[23]^=o,t[32]^=n,t[33]^=o,t[42]^=n,t[43]^=o,n=d^(m<<1|Z>>>31),o=s^(Z<<1|m>>>31),t[4]^=n,t[5]^=o,t[14]^=n,t[15]^=o,t[24]^=n,t[25]^=o,t[34]^=n,t[35]^=o,t[44]^=n,t[45]^=o,n=A^(Q<<1|X>>>31),o=v^(X<<1|Q>>>31),t[6]^=n,t[7]^=o,t[16]^=n,t[17]^=o,t[26]^=n,t[27]^=o,t[36]^=n,t[37]^=o,t[46]^=n,t[47]^=o,n=m^(u<<1|h>>>31),o=Z^(h<<1|u>>>31),t[8]^=n,t[9]^=o,t[18]^=n,t[19]^=o,t[28]^=n,t[29]^=o,t[38]^=n,t[39]^=o,t[48]^=n,t[49]^=o,tt=t[0],et=t[1],Ft=t[11]<<4|t[10]>>>28,Nt=t[10]<<4|t[11]>>>28,pt=t[20]<<3|t[21]>>>29,yt=t[21]<<3|t[20]>>>29,Gt=t[31]<<9|t[30]>>>23,$t=t[30]<<9|t[31]>>>23,Ct=t[40]<<18|t[41]>>>14,Et=t[41]<<18|t[40]>>>14,kt=t[2]<<1|t[3]>>>31,mt=t[3]<<1|t[2]>>>31,rt=t[13]<<12|t[12]>>>20,nt=t[12]<<12|t[13]>>>20,jt=t[22]<<10|t[23]>>>22,Kt=t[23]<<10|t[22]>>>22,vt=t[33]<<13|t[32]>>>19,gt=t[32]<<13|t[33]>>>19,qt=t[42]<<2|t[43]>>>30,Lt=t[43]<<2|t[42]>>>30,Rt=t[5]<<30|t[4]>>>2,Wt=t[4]<<30|t[5]>>>2,_t=t[14]<<6|t[15]>>>26,xt=t[15]<<6|t[14]>>>26,it=t[25]<<11|t[24]>>>21,ot=t[24]<<11|t[25]>>>21,Mt=t[34]<<15|t[35]>>>17,Tt=t[35]<<15|t[34]>>>17,bt=t[45]<<29|t[44]>>>3,St=t[44]<<29|t[45]>>>3,ut=t[6]<<28|t[7]>>>4,ht=t[7]<<28|t[6]>>>4,Jt=t[17]<<23|t[16]>>>9,Ht=t[16]<<23|t[17]>>>9,Bt=t[26]<<25|t[27]>>>7,At=t[27]<<25|t[26]>>>7,lt=t[36]<<21|t[37]>>>11,ct=t[37]<<21|t[36]>>>11,zt=t[47]<<24|t[46]>>>8,Dt=t[46]<<24|t[47]>>>8,Ot=t[8]<<27|t[9]>>>5,It=t[9]<<27|t[8]>>>5,st=t[18]<<20|t[19]>>>12,dt=t[19]<<20|t[18]>>>12,Ut=t[29]<<7|t[28]>>>25,Vt=t[28]<<7|t[29]>>>25,Pt=t[38]<<8|t[39]>>>24,wt=t[39]<<8|t[38]>>>24,at=t[48]<<14|t[49]>>>18,ft=t[49]<<14|t[48]>>>18,t[0]=tt^~rt&it,t[1]=et^~nt&ot,t[10]=ut^~st&pt,t[11]=ht^~dt&yt,t[20]=kt^~_t&Bt,t[21]=mt^~xt&At,t[30]=Ot^~Ft&jt,t[31]=It^~Nt&Kt,t[40]=Rt^~Jt&Ut,t[41]=Wt^~Ht&Vt,t[2]=rt^~it&lt,t[3]=nt^~ot&ct,t[12]=st^~pt&vt,t[13]=dt^~yt&gt,t[22]=_t^~Bt&Pt,t[23]=xt^~At&wt,t[32]=Ft^~jt&Mt,t[33]=Nt^~Kt&Tt,t[42]=Jt^~Ut&Gt,t[43]=Ht^~Vt&$t,t[4]=it^~lt&at,t[5]=ot^~ct&ft,t[14]=pt^~vt&bt,t[15]=yt^~gt&St,t[24]=Bt^~Pt&Ct,t[25]=At^~wt&Et,t[34]=jt^~Mt&zt,t[35]=Kt^~Tt&Dt,t[44]=Ut^~Gt&qt,t[45]=Vt^~$t&Lt,t[6]=lt^~at&tt,t[7]=ct^~ft&et,t[16]=vt^~bt&ut,t[17]=gt^~St&ht,t[26]=Pt^~Ct&kt,t[27]=wt^~Et&mt,t[36]=Mt^~zt&Ot,t[37]=Tt^~Dt&It,t[46]=Gt^~qt&Rt,t[47]=$t^~Lt&Wt,t[8]=at^~tt&rt,t[9]=ft^~et&nt,t[18]=bt^~ut&st,t[19]=St^~ht&dt,t[28]=Ct^~kt&_t,t[29]=Et^~mt&xt,t[38]=zt^~Ot&Ft,t[39]=Dt^~It&Nt,t[48]=qt^~Rt&Jt,t[49]=Lt^~Wt&Ht,t[0]^=D[l],t[1]^=D[l+1]};if(b)c.exports=M;else for(T=0;T<U.length;++T)i[U[T]]=M[U[T]]})()})(ee)),ee.exports}var _e=me();const xe=ke(_e),{keccak256:se}=xe;function ne(c){return new TextEncoder().encode(c)}function Be(c){const r=c.startsWith("0x")?c.slice(2):c,e=new Uint8Array(r.length/2);for(let a=0;a<e.length;a++)e[a]=parseInt(r.substring(a*2,a*2+2),16);return e}function Ae(c){let r="";for(let e=0;e<c.length;e++)r+=c[e].toString(16).padStart(2,"0");return"0x"+r}function ue(c,r,e){const a=JSON.stringify(c),i=ne(a),f=se(r+":"+e.join(".")),p=ne(f),b=new Uint8Array(i.length);for(let y=0;y<i.length;y++)b[y]=i[y]^p[y%p.length];return Ae(b)}function re(c,r,e){try{const a=Be(c),i=se(r+":"+e.join(".")),f=ne(i),p=new Uint8Array(a.length);for(let y=0;y<a.length;y++)p[y]=a[y]^f[y%f.length];const b=new TextDecoder().decode(p);return JSON.parse(b)}catch{return null}}function Pe(c){if(typeof c!="string"||!c.startsWith("0x"))return!1;const r=c.slice(2);return r.length<2||r.length%2!==0?!1:/^[0-9a-fA-F]+$/.test(r)}function we(c,r,e){if(r.length===0){if(e.length===1&&typeof e[0]=="string"){const S=e[0].trim(),O=S.startsWith("_")||S.startsWith("~")||S.startsWith("@"),W=S.includes("."),z=/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(S);if(W||O||z){const P=S.split(".").filter(Boolean);return c.readPath(P)}}if(e.length===0)return c.createProxy([]);const y=c.normalizeArgs(e),g=c.postulate([],y);return g!==void 0?g:c.createProxy([])}const a=c.normalizeArgs(e),i=c.postulate(r,a),{scope:f,leaf:p}=c.splitPath(r),b=p?c.opKind(p):null;if(c.isThought(i)){const y=b?f:r;return c.createProxy(y)}return i!==void 0?i:c.createProxy(r)}const he="+";function R(c){let r=2166136261;for(let e=0;e<c.length;e++)r^=c.charCodeAt(e),r=Math.imul(r,16777619);return("00000000"+(r>>>0).toString(16)).slice(-8)}class ie{constructor(r){this.localSecrets={},this.localNoises={},this.encryptedBranches={},this.index={},this._shortTermMemory=[],this.operators={_:{kind:"secret"},"~":{kind:"noise"},__:{kind:"pointer"},"->":{kind:"pointer"},"@":{kind:"identity"},"=":{kind:"eval"},"?":{kind:"query"},"-":{kind:"remove"}},this.localSecrets={},this.localNoises={},this.encryptedBranches={},this.index={},this.operators={_:{kind:"secret"},"~":{kind:"noise"},__:{kind:"pointer"},"->":{kind:"pointer"},"@":{kind:"identity"},"=":{kind:"eval"},"?":{kind:"query"},"-":{kind:"remove"}},this._shortTermMemory=[],r!==void 0&&this.postulate([],r),this.rebuildIndex();const e=this.createProxy([]);return Object.setPrototypeOf(e,ie.prototype),Object.assign(e,this),e}get shortTermMemory(){return this._shortTermMemory}isRemoveCall(r,e){if(r.length===0)return null;const{scope:a,leaf:i}=N(r);if(!i||this.opKind(i)!=="remove")return null;if(e==null)return{targetPath:a};if(typeof e=="string"){const f=e.split(".").filter(Boolean);return{targetPath:[...a,...f]}}return null}createProxy(r){const e=this,a=(...i)=>we({createProxy:f=>e.createProxy(f),normalizeArgs:f=>e.normalizeArgs(f),readPath:f=>e.readPath(f),postulate:(f,p)=>e.postulate(f,p),opKind:f=>e.opKind(f),splitPath:N,isThought:be},r,i);return new Proxy(a,{get(i,f){if(typeof f=="symbol")return i[f];if(f in e){const b=e[f];return typeof b=="function"?b.bind(e):b}const p=[...r,String(f)];return e.createProxy(p)},apply(i,f,p){return Reflect.apply(i,void 0,p)}})}normalizeArgs(r){if(r.length!==0)return r.length===1?r[0]:r}opKind(r){return this.operators[r]?.kind??null}isSecretScopeCall(r,e){if(r.length===0)return null;const{scope:a,leaf:i}=N(r);return!i||this.opKind(i)!=="secret"||typeof e!="string"?null:{scopeKey:a.join(".")}}isNoiseScopeCall(r,e){if(r.length===0)return null;const{scope:a,leaf:i}=N(r);return!i||this.opKind(i)!=="noise"||typeof e!="string"?null:{scopeKey:a.join(".")}}isPointerCall(r,e){if(r.length===0)return null;const{leaf:a}=N(r);if(!a||this.opKind(a)!=="pointer"||typeof e!="string")return null;const i=e.trim().replace(/^\./,"");return i?{targetPath:i}:null}isIdentityCall(r,e){if(r.length===1&&this.opKind(r[0])==="identity")return typeof e!="string"?null:{id:ae(e),targetPath:[]};const{scope:a,leaf:i}=N(r);return!i||this.opKind(i)!=="identity"||typeof e!="string"?null:{id:ae(e),targetPath:a}}isEvalCall(r,e){if(r.length===0)return null;const{scope:a,leaf:i}=N(r);if(!i||this.opKind(i)!=="eval")return null;if(typeof e=="function")return{mode:"thunk",targetPath:a,thunk:e};if(Array.isArray(e)&&e.length>=2){const f=String(e[0]??"").trim(),p=String(e[1]??"").trim();return!f||!p?null:{mode:"assign",targetPath:a,name:f,expr:p}}return null}isQueryCall(r,e){if(r.length===0)return null;const{scope:a,leaf:i}=N(r);if(!i||this.opKind(i)!=="query")return null;let f=null,p;if(Array.isArray(e)&&e.length>0)Array.isArray(e[0])&&(e.length===1||typeof e[1]=="function")?(f=e[0],p=typeof e[1]=="function"?e[1]:void 0):f=e;else return null;if(!Array.isArray(f)||f.length===0)return null;const b=f.map(y=>String(y)).map(y=>y.trim()).filter(y=>y.length>0);return b.length===0?null:{targetPath:a,paths:b,fn:p}}isDefineOpCall(r,e){if(r.length!==1||r[0]!==he||!Array.isArray(e)||e.length<2)return null;const i=String(e[0]??"").trim(),f=String(e[1]??"").trim();return!i||!f||i===he?null:{op:i,kind:f}}postulate(r,e,a=null){let i=r,f=e;const p=this.isDefineOpCall(i,e);if(p){this.operators[p.op]={kind:p.kind};return}const b=this.isEvalCall(i,e);if(b){if(b.mode==="thunk"){const x=b.thunk();return b.targetPath.length===0?x:this.postulate(b.targetPath,x,"=")}const k=[...b.targetPath,b.name];return this.postulate(k,b.expr,"=")}const y=this.isQueryCall(i,e);if(y){const k=y.paths.map(C=>this.readPath(C.split(".").filter(Boolean))),x=y.fn?y.fn(...k):k;return y.targetPath.length===0?x:this.postulate(y.targetPath,x,"?")}const g=this.isRemoveCall(i,e);if(g){this.removeSubtree(g.targetPath);return}const S=this.isSecretScopeCall(i,e);if(S){this.localSecrets[S.scopeKey]=e;const k=S.scopeKey?S.scopeKey.split(".").filter(Boolean):[],x=k.join("."),C=this.computeEffectiveSecret(k),w="***",_="***",F=JSON.stringify({path:x,operator:"_",expression:w,value:_,effectiveSecret:C}),I=R(F),j=Date.now(),K={path:x,operator:"_",expression:w,value:_,effectiveSecret:C,hash:I,timestamp:j};return this._shortTermMemory.push(K),this.rebuildIndex(),K}const O=this.isNoiseScopeCall(i,e);if(O){this.localNoises[O.scopeKey]=e;const k=O.scopeKey?O.scopeKey.split(".").filter(Boolean):[],x=k.join("."),C=this.computeEffectiveSecret(k),w="***",_="***",F=JSON.stringify({path:x,operator:"~",expression:w,value:_,effectiveSecret:C}),I=R(F),j=Date.now(),K={path:x,operator:"~",expression:w,value:_,effectiveSecret:C,hash:I,timestamp:j};return this._shortTermMemory.push(K),this.rebuildIndex(),K}const W=this.isPointerCall(i,e);if(W){const{scope:k}=N(i);i=k,e=ve(W.targetPath),f=e,a===null&&(a="__")}const z=this.isIdentityCall(i,e);z&&(i=z.targetPath,e=ge(z.id),f=e,a===null&&(a="@"));const P=i.join("."),D=this.computeEffectiveSecret(i),E=this.resolveBranchScope(i);if(E&&E.length===0&&this.localSecrets[""]&&this.localSecrets[P],E&&E.length>0){const k=this.computeEffectiveSecret(E),x=i.slice(E.length),C=this.getBranchBlob(E);let w={};if(C&&k){const _=re(C,k,E);_&&typeof _=="object"&&(w=_)}if(x.length===0)(typeof w!="object"||w===null)&&(w={}),w.expression=e;else{let _=w;for(let F=0;F<x.length-1;F++){const I=x[F];(!_[I]||typeof _[I]!="object")&&(_[I]={}),_=_[I]}_[x[x.length-1]]=e}if(k){const _=ue(w,k,E);this.setBranchBlob(E,_)}f=e}else if(D){const k=a!=="="&&a!=="?";Yt(e)||te(e)||!k?f=e:f=ue(e,D,i)}else f=e;const J=f,$=JSON.stringify({path:P,operator:a,expression:e,value:J,effectiveSecret:D}),q=R($),Zt=Date.now(),L={path:P,operator:a,expression:e,value:J,effectiveSecret:D,hash:q,timestamp:Zt};return this._shortTermMemory.push(L),this.rebuildIndex(),L}removeSubtree(r){const e=r.join(".");for(const g of Object.keys(this.localSecrets)){if(e===""){delete this.localSecrets[g];continue}(g===e||g.startsWith(e+"."))&&delete this.localSecrets[g]}for(const g of Object.keys(this.localNoises)){if(e===""){delete this.localNoises[g];continue}(g===e||g.startsWith(e+"."))&&delete this.localNoises[g]}for(const g of Object.keys(this.encryptedBranches)){if(e===""){delete this.encryptedBranches[g];continue}(g===e||g.startsWith(e+"."))&&delete this.encryptedBranches[g]}const a=r.join("."),i=Date.now(),f=this.computeEffectiveSecret(r),p=JSON.stringify({path:a,operator:"-",expression:"-",value:"-",effectiveSecret:f}),b=R(p),y={path:a,operator:"-",expression:"-",value:"-",effectiveSecret:f,hash:b,timestamp:i};this._shortTermMemory.push(y),this.rebuildIndex()}computeEffectiveSecret(r){let e=null,a=null;this.localNoises[""]!==void 0&&(e="",a=this.localNoises[""]);for(let f=1;f<=r.length;f++){const p=r.slice(0,f).join(".");this.localNoises[p]!==void 0&&(e=p,a=this.localNoises[p])}let i="root";a?i=R("noise::"+a):this.localSecrets[""]&&(i=R(i+"::"+this.localSecrets[""])),e===null||e===""||e.split(".").filter(Boolean).length;for(let f=1;f<=r.length;f++){const p=r.slice(0,f).join(".");if(this.localSecrets[p]){if(e!==null&&e!==""){const b=e+".";if(!(p===e||p.startsWith(b)))continue}i=R(i+"::"+this.localSecrets[p])}}return i==="root"?"":i}rebuildIndex(){const r={};for(const e of this._shortTermMemory){const a=e.path,i=a.split(".").filter(Boolean),f=this.resolveBranchScope(i),p=f&&f.length>0&&ce(i,f);if(e.operator==="-"){if(a===""){for(const y of Object.keys(r))delete r[y];continue}const b=a+".";for(const y of Object.keys(r))(y===a||y.startsWith(b))&&delete r[y];continue}p||(r[a]=e.value)}this.index=r}getIndex(r){return this.index[r.join(".")]}setIndex(r,e){this.index[r.join(".")]=e}resolveIndexPointerPath(r,e=8){let a=r;for(let i=0;i<e;i++){const f=this.getIndex(a);if(!Yt(f))return{path:a,raw:f};a=f.__ptr.split(".").filter(Boolean)}return{path:a,raw:void 0}}setBranchBlob(r,e){const a=r.join(".");this.encryptedBranches[a]=e}getBranchBlob(r){const e=r.join(".");return this.encryptedBranches[e]}resolveBranchScope(r){let e=null;this.localSecrets[""]&&(e=[]);for(let a=1;a<=r.length;a++){const i=r.slice(0,a),f=i.join(".");this.localSecrets[f]&&(e=i)}return e}readPath(r){const e=this.resolveBranchScope(r);if(e&&e.length>0&&ce(r,e)){if(r.length===e.length)return;const p=this.computeEffectiveSecret(e);if(!p)return null;const b=this.getBranchBlob(e);if(!b)return;const y=re(b,p,e);if(!y||typeof y!="object")return;const g=r.slice(e.length);let S=y;for(const O of g){if(!S||typeof S!="object")return;S=S[O]}return Yt(S)?this.readPath(S.__ptr.split(".").filter(Boolean)):(te(S),S)}const i=this.resolveIndexPointerPath(r).raw;if(i===void 0)return;if(Yt(i))return this.readPath(i.__ptr.split(".").filter(Boolean));if(te(i)||!Pe(i))return i;const f=this.computeEffectiveSecret(r);return f?re(i,f,r):null}}module.exports=ie;