this.me 3.0.34 → 3.1.1
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 +12 -82
- package/dist/index.d.ts +1 -1
- package/dist/me.cjs +1 -8
- package/dist/me.es.js +707 -519
- package/dist/me.umd.js +1 -8
- package/dist/src/me.d.ts +3 -0
- package/dist/src/normalizeCall.d.ts +18 -0
- package/dist/src/types.d.ts +34 -0
- package/package.json +16 -7
- package/dist/src/postulate.d.ts +0 -46
package/README.md
CHANGED
|
@@ -1,44 +1,29 @@
|
|
|
1
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
|
-
|
|
5
4
|
##### **1. NPM:**
|
|
6
5
|
```bash
|
|
7
6
|
npm install this.me
|
|
8
7
|
```
|
|
9
|
-
|
|
10
|
-
<img src="https://suign.github.io/assets/imgs/monads.png" alt="Cleak Me Please" width="244">Hello, I am **.me**
|
|
11
|
-
----
|
|
12
|
-
|
|
13
|
-
## A Declarative Identity Language
|
|
14
|
-
|
|
15
|
-
###### me(username, secret, blockchain) ✅
|
|
16
|
-
> 🔄 **Update:** `.me` now includes the `blockchain` parameter as part of its identity derivation surface.
|
|
17
|
-
This allows identities to exist deterministically across different ledgers while preserving parallel universes of meaning.
|
|
18
|
-
Each blockchain becomes a **jurisdiction of identity**, enabling global usernames (via cleaker.me) and local identities (via any host), all verifiable and mathematically consistent.
|
|
19
|
-
|
|
20
|
-
Minimal, expressive and infinitely nested identity calculus.
|
|
21
|
-
|
|
22
|
-
`.me` is a **language** — a semantic engine that builds identity, meaning, structure, and **encrypted universes** through simple expressions.
|
|
23
|
-
|
|
24
|
-
Everything emerges from two primitives:
|
|
25
|
-
|
|
26
|
-
```text
|
|
27
|
-
Declare meaning
|
|
28
|
-
Resolve meaning
|
|
29
|
-
```
|
|
30
|
-
|
|
31
8
|
---
|
|
32
9
|
|
|
33
|
-
## .me in 20
|
|
10
|
+
## **Start .me in 20 seconds**
|
|
11
|
+
###### Import
|
|
12
|
+
**1) Node.js**:
|
|
13
|
+
```ts
|
|
14
|
+
import ME from "this.me";
|
|
15
|
+
const me = new ME();
|
|
16
|
+
```
|
|
17
|
+
**Other modules formats and runtime targets:** CommonJS (`require`), UMD (global/script), TypeScript types.
|
|
18
|
+
[Read more](/docs/Builds.md)
|
|
34
19
|
|
|
35
|
-
###### **Declare**
|
|
20
|
+
###### **Declare** Your Data.
|
|
36
21
|
```ts
|
|
37
22
|
me.profile.name("Abella");
|
|
38
23
|
me.profile.age(30);
|
|
39
24
|
```
|
|
40
25
|
|
|
41
|
-
###### **Read**
|
|
26
|
+
###### **Read **Your Data
|
|
42
27
|
```ts
|
|
43
28
|
me("profile.name"); // → "Abella"
|
|
44
29
|
me("profile.age"); // → 30
|
|
@@ -201,8 +186,7 @@ me.cars.keys.secret("X");
|
|
|
201
186
|
(anything you declare after calling secret)
|
|
202
187
|
→ encrypted under "X"
|
|
203
188
|
|
|
204
|
-
|
|
205
|
-
### **🧠 So to answer common questions:**
|
|
189
|
+
### **🧠 Answer to common questions:**
|
|
206
190
|
##### **✔ Yes — you can declare secrets at specific positions.**
|
|
207
191
|
##### **✔ Yes — everything under that branch becomes encrypted.**
|
|
208
192
|
##### **✔ Yes — you can put another secret deeper.**
|
|
@@ -280,58 +264,6 @@ console.log(JSON.stringify(me.export(), null, 2));
|
|
|
280
264
|
|
|
281
265
|
---
|
|
282
266
|
|
|
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
|
-
|
|
320
|
-
## ▵ The Philosophy
|
|
321
|
-
|
|
322
|
-
> **Human owns meaning. Everything else asks.**
|
|
323
|
-
|
|
324
|
-
A semantic language for identity, built from recursive declarations and symbolic paths.
|
|
325
|
-
|
|
326
|
-
`me` is ▵ **meaning** ▵ **identities** ▵ **universes**.
|
|
327
|
-
|
|
328
|
-
With one primitive:
|
|
329
|
-
|
|
330
|
-
```
|
|
331
|
-
me
|
|
332
|
-
```
|
|
333
|
-
|
|
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/)
|
|
335
267
|
|
|
336
268
|
<a href="https://www.neurons.me" target="_blank">
|
|
337
269
|
<img src="https://res.cloudinary.com/dkwnxf6gm/image/upload/v1760893633/npm-neurons-me_9b3e3a.jpg" style="zoom:16%;" /></a>
|
|
@@ -339,5 +271,3 @@ What **.me** unlocks is something the entire industry has failed to deliver: **t
|
|
|
339
271
|
##### License
|
|
340
272
|
MIT © 2025 by https://neurons.me
|
|
341
273
|
See the [LICENSE](./LICENSE) file for details.
|
|
342
|
-
|
|
343
|
-
</file>
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { ME as default } from './src/me.
|
|
1
|
+
export { ME as default } from './src/me.ts';
|
package/dist/me.cjs
CHANGED
|
@@ -1,8 +1 @@
|
|
|
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
|
-
* [js-sha3]{@link https://github.com/emn178/js-sha3}
|
|
3
|
-
*
|
|
4
|
-
* @version 0.9.3
|
|
5
|
-
* @author Chen, Yi-Cyuan [emn178@gmail.com]
|
|
6
|
-
* @copyright Chen, Yi-Cyuan 2015-2023
|
|
7
|
-
* @license MIT
|
|
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<,t[3]=nt^~ot&ct,t[12]=st^~pt&vt,t[13]=dt^~yt>,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;
|
|
1
|
+
"use strict";function ve(l){return{__ptr:l}}function N(l){return!!l&&typeof l=="object"&&typeof l.__ptr=="string"&&l.__ptr.length>0}function be(l){return{__id:l}}function Lt(l){return!!l&&typeof l=="object"&&typeof l.__id=="string"&&l.__id.length>0}function me(l){return!!l&&typeof l=="object"&&typeof l.path=="string"&&typeof l.hash=="string"&&typeof l.timestamp=="number"}function C(l){return l.length===0?{scope:[],leaf:null}:{scope:l.slice(0,-1),leaf:l[l.length-1]}}function Gt(l,n){if(n.length>l.length)return!1;for(let e=0;e<n.length;e++)if(l[e]!==n[e])return!1;return!0}function Ht(l){const n=l.trim().toLowerCase();if(n.length<3||n.length>63)throw new Error(`Invalid username length: ${n.length}. Expected 3..63 characters.`);if(!/^[a-z0-9][a-z0-9-]*[a-z0-9]$/.test(n))throw new Error(`Invalid username. Use only [a-z0-9-], and start/end with [a-z0-9]. Got: ${l}`);if(n.includes("--"))throw new Error(`Invalid username. "--" is not allowed. Got: ${l}`);return n}function I(l,n){return l[n]?.kind??null}function ke(l,n){if(l.length!==1||l[0]!=="+"||!Array.isArray(n)||n.length<2)return null;const i=String(n[0]??"").trim(),r=String(n[1]??"").trim();return!i||!r||i==="+"?null:{op:i,kind:r}}function Se(l,n,e){if(n.length===0)return null;const{scope:i,leaf:r}=C(n);return!r||I(l,r)!=="secret"||typeof e!="string"?null:{scopeKey:i.join(".")}}function Ae(l,n,e){if(n.length===0)return null;const{scope:i,leaf:r}=C(n);return!r||I(l,r)!=="noise"||typeof e!="string"?null:{scopeKey:i.join(".")}}function Be(l,n,e){if(n.length===0)return null;const{leaf:i}=C(n);if(!i||I(l,i)!=="pointer"||typeof e!="string")return null;const r=e.trim().replace(/^\./,"");return r?{targetPath:r}:null}function _e(l,n,e){if(n.length===1&&I(l,n[0])==="identity")return typeof e!="string"?null:{id:Ht(e),targetPath:[]};const{scope:i,leaf:r}=C(n);return!r||I(l,r)!=="identity"||typeof e!="string"?null:{id:Ht(e),targetPath:i}}function Pe(l,n,e){if(n.length===0)return null;const{scope:i,leaf:r}=C(n);if(!r||I(l,r)!=="eval")return null;if(typeof e=="function")return{mode:"thunk",targetPath:i,thunk:e};if(Array.isArray(e)&&e.length>=2){const u=String(e[0]??"").trim(),f=String(e[1]??"").trim();return!u||!f?null:{mode:"assign",targetPath:i,name:u,expr:f}}return null}function we(l,n,e){if(n.length===0)return null;const{scope:i,leaf:r}=C(n);if(!r||I(l,r)!=="query")return null;let u=null,f;if(Array.isArray(e)&&e.length>0)Array.isArray(e[0])&&(e.length===1||typeof e[1]=="function")?(u=e[0],f=typeof e[1]=="function"?e[1]:void 0):u=e;else return null;if(!Array.isArray(u)||u.length===0)return null;const p=u.map(s=>String(s)).map(s=>s.trim()).filter(s=>s.length>0);return p.length===0?null:{targetPath:i,paths:p,fn:f}}function xe(l,n,e){if(n.length===0)return null;const{scope:i,leaf:r}=C(n);if(!r||I(l,r)!=="remove")return null;if(e==null)return{targetPath:i};if(typeof e=="string"){const u=e.split(".").filter(Boolean);return{targetPath:[...i,...u]}}return null}var Ce=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Oe(l){return l&&l.__esModule&&Object.prototype.hasOwnProperty.call(l,"default")?l.default:l}var Yt={exports:{}};var ae;function Ee(){return ae||(ae=1,(function(l){(function(){var n="input is invalid type",e="finalize already called",i=typeof window=="object",r=i?window:{};r.JS_SHA3_NO_WINDOW&&(i=!1);var u=!i&&typeof self=="object",f=!r.JS_SHA3_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;f?r=Ce:u&&(r=self);for(var p=!r.JS_SHA3_NO_COMMON_JS&&!0&&l.exports,s=!r.JS_SHA3_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",h="0123456789abcdef".split(""),k=[31,7936,2031616,520093696],m=[4,1024,262144,67108864],S=[1,256,65536,16777216],B=[6,1536,393216,100663296],A=[0,8,16,24],x=[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],O=[224,256,384,512],E=[128,256],M=["hex","buffer","arrayBuffer","array","digest"],te={128:168,256:136},se=r.JS_SHA3_NO_NODE_JS||!Array.isArray?function(t){return Object.prototype.toString.call(t)==="[object Array]"}:Array.isArray,de=s&&(r.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)?function(t){return typeof t=="object"&&t.buffer&&t.buffer.constructor===ArrayBuffer}:ArrayBuffer.isView,Ut=function(t){var o=typeof t;if(o==="string")return[t,!0];if(o!=="object"||t===null)throw new Error(n);if(s&&t.constructor===ArrayBuffer)return[new Uint8Array(t),!1];if(!se(t)&&!de(t))throw new Error(n);return[t,!1]},ee=function(t){return Ut(t)[0].length===0},Vt=function(t){for(var o=[],c=0;c<t.length;++c)o[c]=t[c];return o},ne=function(t,o,c){return function(a){return new P(t,o,t).update(a)[c]()}},re=function(t,o,c){return function(a,d){return new P(t,o,d).update(a)[c]()}},ie=function(t,o,c){return function(a,d,y,v){return F["cshake"+t].update(a,d,y,v)[c]()}},oe=function(t,o,c){return function(a,d,y,v){return F["kmac"+t].update(a,d,y,v)[c]()}},W=function(t,o,c,a){for(var d=0;d<M.length;++d){var y=M[d];t[y]=o(c,a,y)}return t},le=function(t,o){var c=ne(t,o,"hex");return c.create=function(){return new P(t,o,t)},c.update=function(a){return c.create().update(a)},W(c,ne,t,o)},pe=function(t,o){var c=re(t,o,"hex");return c.create=function(a){return new P(t,o,a)},c.update=function(a,d){return c.create(d).update(a)},W(c,re,t,o)},ye=function(t,o){var c=te[t],a=ie(t,o,"hex");return a.create=function(d,y,v){return ee(y)&&ee(v)?F["shake"+t].create(d):new P(t,o,d).bytepad([y,v],c)},a.update=function(d,y,v,g){return a.create(y,v,g).update(d)},W(a,ie,t,o)},ge=function(t,o){var c=te[t],a=oe(t,o,"hex");return a.create=function(d,y,v){return new $t(t,o,y).bytepad(["KMAC",v],c).bytepad([d],c)},a.update=function(d,y,v,g){return a.create(d,v,g).update(y)},W(a,oe,t,o)},ue=[{name:"keccak",padding:S,bits:O,createMethod:le},{name:"sha3",padding:B,bits:O,createMethod:le},{name:"shake",padding:k,bits:E,createMethod:pe},{name:"cshake",padding:m,bits:E,createMethod:ye},{name:"kmac",padding:m,bits:E,createMethod:ge}],F={},T=[],K=0;K<ue.length;++K)for(var j=ue[K],J=j.bits,D=0;D<J.length;++D){var qt=j.name+"_"+J[D];if(T.push(qt),F[qt]=j.createMethod(J[D],j.padding),j.name!=="sha3"){var ce=j.name+J[D];T.push(ce),F[ce]=F[qt]}}function P(t,o,c){this.blocks=[],this.s=[],this.padding=o,this.outputBits=c,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=c>>5,this.extraBytes=(c&31)>>3;for(var a=0;a<50;++a)this.s[a]=0}P.prototype.update=function(t){if(this.finalized)throw new Error(e);var o=Ut(t);t=o[0];for(var c=o[1],a=this.blocks,d=this.byteCount,y=t.length,v=this.blockCount,g=0,w=this.s,b,_;g<y;){if(this.reset)for(this.reset=!1,a[0]=this.block,b=1;b<v+1;++b)a[b]=0;if(c)for(b=this.start;g<y&&b<d;++g)_=t.charCodeAt(g),_<128?a[b>>2]|=_<<A[b++&3]:_<2048?(a[b>>2]|=(192|_>>6)<<A[b++&3],a[b>>2]|=(128|_&63)<<A[b++&3]):_<55296||_>=57344?(a[b>>2]|=(224|_>>12)<<A[b++&3],a[b>>2]|=(128|_>>6&63)<<A[b++&3],a[b>>2]|=(128|_&63)<<A[b++&3]):(_=65536+((_&1023)<<10|t.charCodeAt(++g)&1023),a[b>>2]|=(240|_>>18)<<A[b++&3],a[b>>2]|=(128|_>>12&63)<<A[b++&3],a[b>>2]|=(128|_>>6&63)<<A[b++&3],a[b>>2]|=(128|_&63)<<A[b++&3]);else for(b=this.start;g<y&&b<d;++g)a[b>>2]|=t[g]<<A[b++&3];if(this.lastByteIndex=b,b>=d){for(this.start=b-d,this.block=a[v],b=0;b<v;++b)w[b]^=a[b];z(w),this.reset=!0}else this.start=b}return this},P.prototype.encode=function(t,o){var c=t&255,a=1,d=[c];for(t=t>>8,c=t&255;c>0;)d.unshift(c),t=t>>8,c=t&255,++a;return o?d.push(a):d.unshift(a),this.update(d),d.length},P.prototype.encodeString=function(t){var o=Ut(t);t=o[0];var c=o[1],a=0,d=t.length;if(c)for(var y=0;y<t.length;++y){var v=t.charCodeAt(y);v<128?a+=1:v<2048?a+=2:v<55296||v>=57344?a+=3:(v=65536+((v&1023)<<10|t.charCodeAt(++y)&1023),a+=4)}else a=d;return a+=this.encode(a*8),this.update(t),a},P.prototype.bytepad=function(t,o){for(var c=this.encode(o),a=0;a<t.length;++a)c+=this.encodeString(t[a]);var d=(o-c%o)%o,y=[];return y.length=d,this.update(y),this},P.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var t=this.blocks,o=this.lastByteIndex,c=this.blockCount,a=this.s;if(t[o>>2]|=this.padding[o&3],this.lastByteIndex===this.byteCount)for(t[0]=t[c],o=1;o<c+1;++o)t[o]=0;for(t[c-1]|=2147483648,o=0;o<c;++o)a[o]^=t[o];z(a)}},P.prototype.toString=P.prototype.hex=function(){this.finalize();for(var t=this.blockCount,o=this.s,c=this.outputBlocks,a=this.extraBytes,d=0,y=0,v="",g;y<c;){for(d=0;d<t&&y<c;++d,++y)g=o[d],v+=h[g>>4&15]+h[g&15]+h[g>>12&15]+h[g>>8&15]+h[g>>20&15]+h[g>>16&15]+h[g>>28&15]+h[g>>24&15];y%t===0&&(o=Vt(o),z(o),d=0)}return a&&(g=o[d],v+=h[g>>4&15]+h[g&15],a>1&&(v+=h[g>>12&15]+h[g>>8&15]),a>2&&(v+=h[g>>20&15]+h[g>>16&15])),v},P.prototype.arrayBuffer=function(){this.finalize();var t=this.blockCount,o=this.s,c=this.outputBlocks,a=this.extraBytes,d=0,y=0,v=this.outputBits>>3,g;a?g=new ArrayBuffer(c+1<<2):g=new ArrayBuffer(v);for(var w=new Uint32Array(g);y<c;){for(d=0;d<t&&y<c;++d,++y)w[y]=o[d];y%t===0&&(o=Vt(o),z(o))}return a&&(w[y]=o[d],g=g.slice(0,v)),g},P.prototype.buffer=P.prototype.arrayBuffer,P.prototype.digest=P.prototype.array=function(){this.finalize();for(var t=this.blockCount,o=this.s,c=this.outputBlocks,a=this.extraBytes,d=0,y=0,v=[],g,w;y<c;){for(d=0;d<t&&y<c;++d,++y)g=y<<2,w=o[d],v[g]=w&255,v[g+1]=w>>8&255,v[g+2]=w>>16&255,v[g+3]=w>>24&255;y%t===0&&(o=Vt(o),z(o))}return a&&(g=y<<2,w=o[d],v[g]=w&255,a>1&&(v[g+1]=w>>8&255),a>2&&(v[g+2]=w>>16&255)),v};function $t(t,o,c){P.call(this,t,o,c)}$t.prototype=new P,$t.prototype.finalize=function(){return this.encode(this.outputBits,!0),P.prototype.finalize.call(this)};var z=function(t){var o,c,a,d,y,v,g,w,b,_,H,U,V,q,$,L,G,Y,Q,Z,X,tt,et,nt,rt,it,ot,lt,ut,ct,at,ft,ht,st,dt,pt,yt,gt,vt,bt,mt,kt,St,At,Bt,_t,Pt,wt,xt,Ct,Ot,Et,Ft,Kt,It,jt,Nt,Mt,Tt,Dt,zt,Rt,Wt;for(a=0;a<48;a+=2)d=t[0]^t[10]^t[20]^t[30]^t[40],y=t[1]^t[11]^t[21]^t[31]^t[41],v=t[2]^t[12]^t[22]^t[32]^t[42],g=t[3]^t[13]^t[23]^t[33]^t[43],w=t[4]^t[14]^t[24]^t[34]^t[44],b=t[5]^t[15]^t[25]^t[35]^t[45],_=t[6]^t[16]^t[26]^t[36]^t[46],H=t[7]^t[17]^t[27]^t[37]^t[47],U=t[8]^t[18]^t[28]^t[38]^t[48],V=t[9]^t[19]^t[29]^t[39]^t[49],o=U^(v<<1|g>>>31),c=V^(g<<1|v>>>31),t[0]^=o,t[1]^=c,t[10]^=o,t[11]^=c,t[20]^=o,t[21]^=c,t[30]^=o,t[31]^=c,t[40]^=o,t[41]^=c,o=d^(w<<1|b>>>31),c=y^(b<<1|w>>>31),t[2]^=o,t[3]^=c,t[12]^=o,t[13]^=c,t[22]^=o,t[23]^=c,t[32]^=o,t[33]^=c,t[42]^=o,t[43]^=c,o=v^(_<<1|H>>>31),c=g^(H<<1|_>>>31),t[4]^=o,t[5]^=c,t[14]^=o,t[15]^=c,t[24]^=o,t[25]^=c,t[34]^=o,t[35]^=c,t[44]^=o,t[45]^=c,o=w^(U<<1|V>>>31),c=b^(V<<1|U>>>31),t[6]^=o,t[7]^=c,t[16]^=o,t[17]^=c,t[26]^=o,t[27]^=c,t[36]^=o,t[37]^=c,t[46]^=o,t[47]^=c,o=_^(d<<1|y>>>31),c=H^(y<<1|d>>>31),t[8]^=o,t[9]^=c,t[18]^=o,t[19]^=c,t[28]^=o,t[29]^=c,t[38]^=o,t[39]^=c,t[48]^=o,t[49]^=c,q=t[0],$=t[1],_t=t[11]<<4|t[10]>>>28,Pt=t[10]<<4|t[11]>>>28,lt=t[20]<<3|t[21]>>>29,ut=t[21]<<3|t[20]>>>29,Dt=t[31]<<9|t[30]>>>23,zt=t[30]<<9|t[31]>>>23,kt=t[40]<<18|t[41]>>>14,St=t[41]<<18|t[40]>>>14,st=t[2]<<1|t[3]>>>31,dt=t[3]<<1|t[2]>>>31,L=t[13]<<12|t[12]>>>20,G=t[12]<<12|t[13]>>>20,wt=t[22]<<10|t[23]>>>22,xt=t[23]<<10|t[22]>>>22,ct=t[33]<<13|t[32]>>>19,at=t[32]<<13|t[33]>>>19,Rt=t[42]<<2|t[43]>>>30,Wt=t[43]<<2|t[42]>>>30,Kt=t[5]<<30|t[4]>>>2,It=t[4]<<30|t[5]>>>2,pt=t[14]<<6|t[15]>>>26,yt=t[15]<<6|t[14]>>>26,Y=t[25]<<11|t[24]>>>21,Q=t[24]<<11|t[25]>>>21,Ct=t[34]<<15|t[35]>>>17,Ot=t[35]<<15|t[34]>>>17,ft=t[45]<<29|t[44]>>>3,ht=t[44]<<29|t[45]>>>3,nt=t[6]<<28|t[7]>>>4,rt=t[7]<<28|t[6]>>>4,jt=t[17]<<23|t[16]>>>9,Nt=t[16]<<23|t[17]>>>9,gt=t[26]<<25|t[27]>>>7,vt=t[27]<<25|t[26]>>>7,Z=t[36]<<21|t[37]>>>11,X=t[37]<<21|t[36]>>>11,Et=t[47]<<24|t[46]>>>8,Ft=t[46]<<24|t[47]>>>8,At=t[8]<<27|t[9]>>>5,Bt=t[9]<<27|t[8]>>>5,it=t[18]<<20|t[19]>>>12,ot=t[19]<<20|t[18]>>>12,Mt=t[29]<<7|t[28]>>>25,Tt=t[28]<<7|t[29]>>>25,bt=t[38]<<8|t[39]>>>24,mt=t[39]<<8|t[38]>>>24,tt=t[48]<<14|t[49]>>>18,et=t[49]<<14|t[48]>>>18,t[0]=q^~L&Y,t[1]=$^~G&Q,t[10]=nt^~it<,t[11]=rt^~ot&ut,t[20]=st^~pt>,t[21]=dt^~yt&vt,t[30]=At^~_t&wt,t[31]=Bt^~Pt&xt,t[40]=Kt^~jt&Mt,t[41]=It^~Nt&Tt,t[2]=L^~Y&Z,t[3]=G^~Q&X,t[12]=it^~lt&ct,t[13]=ot^~ut&at,t[22]=pt^~gt&bt,t[23]=yt^~vt&mt,t[32]=_t^~wt&Ct,t[33]=Pt^~xt&Ot,t[42]=jt^~Mt&Dt,t[43]=Nt^~Tt&zt,t[4]=Y^~Z&tt,t[5]=Q^~X&et,t[14]=lt^~ct&ft,t[15]=ut^~at&ht,t[24]=gt^~bt&kt,t[25]=vt^~mt&St,t[34]=wt^~Ct&Et,t[35]=xt^~Ot&Ft,t[44]=Mt^~Dt&Rt,t[45]=Tt^~zt&Wt,t[6]=Z^~tt&q,t[7]=X^~et&$,t[16]=ct^~ft&nt,t[17]=at^~ht&rt,t[26]=bt^~kt&st,t[27]=mt^~St&dt,t[36]=Ct^~Et&At,t[37]=Ot^~Ft&Bt,t[46]=Dt^~Rt&Kt,t[47]=zt^~Wt&It,t[8]=tt^~q&L,t[9]=et^~$&G,t[18]=ft^~nt&it,t[19]=ht^~rt&ot,t[28]=kt^~st&pt,t[29]=St^~dt&yt,t[38]=Et^~At&_t,t[39]=Ft^~Bt&Pt,t[48]=Rt^~Kt&jt,t[49]=Wt^~It&Nt,t[0]^=x[a],t[1]^=x[a+1]};if(p)l.exports=F;else for(K=0;K<T.length;++K)r[T[K]]=F[T[K]]})()})(Yt)),Yt.exports}var Fe=Ee();const Ke=Oe(Fe),{keccak256:he}=Ke;function Zt(l){return new TextEncoder().encode(l)}function Ie(l){const n=l.startsWith("0x")?l.slice(2):l,e=new Uint8Array(n.length/2);for(let i=0;i<e.length;i++)e[i]=parseInt(n.substring(i*2,i*2+2),16);return e}function je(l){let n="";for(let e=0;e<l.length;e++)n+=l[e].toString(16).padStart(2,"0");return"0x"+n}function Qt(l,n,e){const i=JSON.stringify(l),r=Zt(i),u=he(n+":"+e.join(".")),f=Zt(u),p=new Uint8Array(r.length);for(let s=0;s<r.length;s++)p[s]=r[s]^f[s%f.length];return je(p)}function Jt(l,n,e){try{const i=Ie(l),r=he(n+":"+e.join(".")),u=Zt(r),f=new Uint8Array(i.length);for(let s=0;s<i.length;s++)f[s]=i[s]^u[s%u.length];const p=new TextDecoder().decode(f);return JSON.parse(p)}catch{return null}}function Ne(l){if(typeof l!="string"||!l.startsWith("0x"))return!1;const n=l.slice(2);return n.length<2||n.length%2!==0?!1:/^[0-9a-fA-F]+$/.test(n)}function Me(l,n,e){if(n.length===0){if(e.length===1&&typeof e[0]=="string"){const k=e[0].trim(),m=k.startsWith("_")||k.startsWith("~")||k.startsWith("@"),S=k.includes("."),B=/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(k);if(S||m||B){const A=k.split(".").filter(Boolean);return l.readPath(A)}}if(e.length===0)return l.createProxy([]);const s=l.normalizeArgs(e),h=l.postulate([],s);return h!==void 0?h:l.createProxy([])}const i=l.normalizeArgs(e),r=l.postulate(n,i),{scope:u,leaf:f}=l.splitPath(n),p=f?l.opKind(f):null;if(l.isThought(r)){const s=p?u:n;return l.createProxy(s)}return r!==void 0?r:l.createProxy(n)}function Te(l,n,e={}){const{path:i,expression:r}=n,u=ke(i,r);if(u)return{kind:"return",value:{define:u}};const f=Se(l,i,r);if(f)return{kind:"commit",instructions:[{path:f.scopeKey?f.scopeKey.split(".").filter(Boolean):[],op:"secret",value:r}]};const p=Ae(l,i,r);if(p)return{kind:"commit",instructions:[{path:p.scopeKey?p.scopeKey.split(".").filter(Boolean):[],op:"noise",value:r}]};const s=Be(l,i,r);if(s){const{scope:B}=C(i);return{kind:"commit",instructions:[{path:B,op:"ptr",value:ve(s.targetPath)}]}}const h=_e(l,i,r);if(h)return{kind:"commit",instructions:[{path:h.targetPath,op:"id",value:be(h.id)}]};const k=xe(l,i,r);if(k)return{kind:"commit",instructions:[{path:k.targetPath,op:"remove",value:"-"}]};const m=Pe(l,i,r);if(m){if(m.mode==="assign")return{kind:"commit",instructions:[{path:[...m.targetPath,m.name],op:"derive",value:{kind:"expr",source:m.expr}}]};if(!e.evaluateThunk)throw new Error('Non-serializable derivation: "=" thunk requires `evaluateThunk` or serializable DNA.');const B=e.evaluateThunk(m.thunk);return m.targetPath.length===0?{kind:"return",value:B}:{kind:"commit",instructions:[{path:m.targetPath,op:"derive",value:B}]}}const S=we(l,i,r);if(S){if(!e.readPath)return{kind:"commit",instructions:[{path:S.targetPath,op:"query",value:{paths:S.paths}}]};const B=S.paths.map(x=>e.readPath(x.split(".").filter(Boolean))),A=S.fn?S.fn(...B):B;return S.targetPath.length===0?{kind:"return",value:A}:{kind:"commit",instructions:[{path:S.targetPath,op:"query",value:A}]}}return{kind:"commit",instructions:[{path:i,op:"set",value:r}]}}const fe="+";function R(l){let n=2166136261;for(let e=0;e<l.length;e++)n^=l.charCodeAt(e),n=Math.imul(n,16777619);return("00000000"+(n>>>0).toString(16)).slice(-8)}class Xt{constructor(n){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=[],n!==void 0&&this.postulate([],n),this.rebuildIndex();const e=this.createProxy([]);return Object.setPrototypeOf(e,Xt.prototype),Object.assign(e,this),e}get shortTermMemory(){return this._shortTermMemory}isRemoveCall(n,e){if(n.length===0)return null;const{scope:i,leaf:r}=C(n);if(!r||this.opKind(r)!=="remove")return null;if(e==null)return{targetPath:i};if(typeof e=="string"){const u=e.split(".").filter(Boolean);return{targetPath:[...i,...u]}}return null}createProxy(n){const e=this,i=(...r)=>Me({createProxy:u=>e.createProxy(u),normalizeArgs:u=>e.normalizeArgs(u),readPath:u=>e.readPath(u),postulate:(u,f)=>e.postulate(u,f),opKind:u=>e.opKind(u),splitPath:C,isThought:me},n,r);return new Proxy(i,{get(r,u){if(typeof u=="symbol")return r[u];if(u in e){const p=e[u];return typeof p=="function"?p.bind(e):p}const f=[...n,String(u)];return e.createProxy(f)},apply(r,u,f){return Reflect.apply(r,void 0,f)}})}normalizeArgs(n){if(n.length!==0)return n.length===1?n[0]:n}opKind(n){return this.operators[n]?.kind??null}isSecretScopeCall(n,e){if(n.length===0)return null;const{scope:i,leaf:r}=C(n);return!r||this.opKind(r)!=="secret"||typeof e!="string"?null:{scopeKey:i.join(".")}}isNoiseScopeCall(n,e){if(n.length===0)return null;const{scope:i,leaf:r}=C(n);return!r||this.opKind(r)!=="noise"||typeof e!="string"?null:{scopeKey:i.join(".")}}isPointerCall(n,e){if(n.length===0)return null;const{leaf:i}=C(n);if(!i||this.opKind(i)!=="pointer"||typeof e!="string")return null;const r=e.trim().replace(/^\./,"");return r?{targetPath:r}:null}isIdentityCall(n,e){if(n.length===1&&this.opKind(n[0])==="identity")return typeof e!="string"?null:{id:Ht(e),targetPath:[]};const{scope:i,leaf:r}=C(n);return!r||this.opKind(r)!=="identity"||typeof e!="string"?null:{id:Ht(e),targetPath:i}}isEvalCall(n,e){if(n.length===0)return null;const{scope:i,leaf:r}=C(n);if(!r||this.opKind(r)!=="eval")return null;if(typeof e=="function")return{mode:"thunk",targetPath:i,thunk:e};if(Array.isArray(e)&&e.length>=2){const u=String(e[0]??"").trim(),f=String(e[1]??"").trim();return!u||!f?null:{mode:"assign",targetPath:i,name:u,expr:f}}return null}isQueryCall(n,e){if(n.length===0)return null;const{scope:i,leaf:r}=C(n);if(!r||this.opKind(r)!=="query")return null;let u=null,f;if(Array.isArray(e)&&e.length>0)Array.isArray(e[0])&&(e.length===1||typeof e[1]=="function")?(u=e[0],f=typeof e[1]=="function"?e[1]:void 0):u=e;else return null;if(!Array.isArray(u)||u.length===0)return null;const p=u.map(s=>String(s)).map(s=>s.trim()).filter(s=>s.length>0);return p.length===0?null:{targetPath:i,paths:p,fn:f}}isDefineOpCall(n,e){if(n.length!==1||n[0]!==fe||!Array.isArray(e)||e.length<2)return null;const r=String(e[0]??"").trim(),u=String(e[1]??"").trim();return!r||!u||r===fe?null:{op:r,kind:u}}commitThoughtOnly(n,e,i,r){const u=n.join("."),f=this.computeEffectiveSecret(n),p=JSON.stringify({path:u,operator:e,expression:i,value:r,effectiveSecret:f}),s=R(p),h=Date.now(),k={path:u,operator:e,expression:i,value:r,effectiveSecret:f,hash:s,timestamp:h};return this._shortTermMemory.push(k),this.rebuildIndex(),k}commitValueMapping(n,e,i=null){let r=e;const u=n.join("."),f=this.computeEffectiveSecret(n),p=this.resolveBranchScope(n);if(p&&p.length===0&&this.localSecrets[""]&&this.localSecrets[u],p&&p.length>0){const s=this.computeEffectiveSecret(p),h=n.slice(p.length),k=this.getBranchBlob(p);let m={};if(k&&s){const S=Jt(k,s,p);S&&typeof S=="object"&&(m=S)}if(h.length===0)(typeof m!="object"||m===null)&&(m={}),m.expression=e;else{let S=m;for(let B=0;B<h.length-1;B++){const A=h[B];(!S[A]||typeof S[A]!="object")&&(S[A]={}),S=S[A]}S[h[h.length-1]]=e}if(s){const S=Qt(m,s,p);this.setBranchBlob(p,S)}r=e}else if(f){const s=i!=="="&&i!=="?";N(e)||Lt(e)||!s?r=e:r=Qt(e,f,n)}else r=e;return this.commitThoughtOnly(n,i,e,r)}commitMapping(n,e=null){switch(n.op){case"set":return this.commitValueMapping(n.path,n.value,e);case"ptr":return this.commitValueMapping(n.path,n.value,"__");case"id":return this.commitValueMapping(n.path,n.value,"@");case"secret":{if(typeof n.value!="string")return;const i=n.path.join(".");return this.localSecrets[i]=n.value,this.commitThoughtOnly(n.path,"_","***","***")}default:return}}postulate(n,e,i=null){let r=n;const u=this.isDefineOpCall(r,e);if(u){this.operators[u.op]={kind:u.kind};return}const{leaf:f}=C(r),p=f?this.opKind(f):null;if(p===null||p==="secret"||p==="pointer"||p==="identity"){const B=Te(this.operators,{path:r,expression:e});if(B.kind==="commit"){const A=new Set(["set","secret","ptr","id"]);if(B.instructions.every(O=>A.has(O.op))){let O;for(const E of B.instructions){const M=this.commitMapping(E,i);M&&(O=M)}if(O)return O}}}const h=this.isEvalCall(r,e);if(h){if(h.mode==="thunk"){const A=h.thunk();return h.targetPath.length===0?A:this.postulate(h.targetPath,A,"=")}const B=[...h.targetPath,h.name];return this.postulate(B,h.expr,"=")}const k=this.isQueryCall(r,e);if(k){const B=k.paths.map(x=>this.readPath(x.split(".").filter(Boolean))),A=k.fn?k.fn(...B):B;return k.targetPath.length===0?A:this.postulate(k.targetPath,A,"?")}const m=this.isRemoveCall(r,e);if(m){this.removeSubtree(m.targetPath);return}const S=this.isNoiseScopeCall(r,e);if(S){this.localNoises[S.scopeKey]=e;const B=S.scopeKey?S.scopeKey.split(".").filter(Boolean):[];return this.commitThoughtOnly(B,"~","***","***")}return this.commitValueMapping(r,e,i)}removeSubtree(n){const e=n.join(".");for(const h of Object.keys(this.localSecrets)){if(e===""){delete this.localSecrets[h];continue}(h===e||h.startsWith(e+"."))&&delete this.localSecrets[h]}for(const h of Object.keys(this.localNoises)){if(e===""){delete this.localNoises[h];continue}(h===e||h.startsWith(e+"."))&&delete this.localNoises[h]}for(const h of Object.keys(this.encryptedBranches)){if(e===""){delete this.encryptedBranches[h];continue}if(h===e||h.startsWith(e+".")){delete this.encryptedBranches[h];continue}const k=h.split(".").filter(Boolean);if(!Gt(n,k)||n.length<=k.length)continue;const m=this.computeEffectiveSecret(k);if(!m)continue;const S=this.getBranchBlob(k);if(!S)continue;const B=Jt(S,m,k);if(!B||typeof B!="object")continue;const A=n.slice(k.length);let x=B;for(let O=0;O<A.length-1;O++){const E=A[O];if(!x||typeof x!="object"||!(E in x)){x=null;break}x=x[E]}if(x&&typeof x=="object"){delete x[A[A.length-1]];const O=Qt(B,m,k);this.setBranchBlob(k,O)}}const i=n.join("."),r=Date.now(),u=this.computeEffectiveSecret(n),f=JSON.stringify({path:i,operator:"-",expression:"-",value:"-",effectiveSecret:u}),p=R(f),s={path:i,operator:"-",expression:"-",value:"-",effectiveSecret:u,hash:p,timestamp:r};this._shortTermMemory.push(s),this.rebuildIndex()}computeEffectiveSecret(n){let e=null,i=null;this.localNoises[""]!==void 0&&(e="",i=this.localNoises[""]);for(let u=1;u<=n.length;u++){const f=n.slice(0,u).join(".");this.localNoises[f]!==void 0&&(e=f,i=this.localNoises[f])}let r="root";i?r=R("noise::"+i):this.localSecrets[""]&&(r=R(r+"::"+this.localSecrets[""])),e===null||e===""||e.split(".").filter(Boolean).length;for(let u=1;u<=n.length;u++){const f=n.slice(0,u).join(".");if(this.localSecrets[f]){if(e!==null&&e!==""){const p=e+".";if(!(f===e||f.startsWith(p)))continue}r=R(r+"::"+this.localSecrets[f])}}return r==="root"?"":r}rebuildIndex(){const n={};for(const e of this._shortTermMemory){const i=e.path,r=i.split(".").filter(Boolean),u=this.resolveBranchScope(r),f=u&&u.length>0&&Gt(r,u);if(e.operator==="-"){if(i===""){for(const s of Object.keys(n))delete n[s];continue}const p=i+".";for(const s of Object.keys(n))(s===i||s.startsWith(p))&&delete n[s];continue}f||(n[i]=e.value)}this.index=n}getIndex(n){return this.index[n.join(".")]}setIndex(n,e){this.index[n.join(".")]=e}resolveIndexPointerPath(n,e=8){let i=n;for(let r=0;r<e;r++){const u=this.getIndex(i);if(N(u)){i=u.__ptr.split(".").filter(Boolean);continue}let f=!1;for(let p=i.length-1;p>=0;p--){const s=i.slice(0,p),h=this.getIndex(s);if(!N(h))continue;const k=h.__ptr.split(".").filter(Boolean),m=i.slice(p);i=[...k,...m],f=!0;break}if(!f)return{path:i,raw:u}}return{path:i,raw:void 0}}setBranchBlob(n,e){const i=n.join(".");this.encryptedBranches[i]=e}getBranchBlob(n){const e=n.join(".");return this.encryptedBranches[e]}resolveBranchScope(n){let e=null;this.localSecrets[""]&&(e=[]);for(let i=1;i<=n.length;i++){const r=n.slice(0,i),u=r.join(".");this.localSecrets[u]&&(e=r)}return e}readPath(n){const e=this.resolveBranchScope(n);if(e&&e.length>0&&Gt(n,e)){if(n.length===e.length)return;const p=this.computeEffectiveSecret(e);if(!p)return null;const s=this.getBranchBlob(e);if(!s)return;const h=Jt(s,p,e);if(!h||typeof h!="object")return;const k=n.slice(e.length);let m=h;for(const S of k){if(!m||typeof m!="object")return;m=m[S]}return N(m)?this.readPath(m.__ptr.split(".").filter(Boolean)):(Lt(m),m)}const i=this.getIndex(n);if(N(i))return i;const r=this.resolveIndexPointerPath(n),u=r.raw;if(u===void 0)return r.path.length===n.length&&r.path.every((s,h)=>s===n[h])?void 0:this.readPath(r.path);if(N(u))return this.readPath(u.__ptr.split(".").filter(Boolean));if(Lt(u)||!Ne(u))return u;const f=this.computeEffectiveSecret(n);return f?Jt(u,f,n):null}}module.exports=Xt;
|