@precisionutilityguild/liquid-shadow 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,41 +1,32 @@
1
1
  #!/usr/bin/env node
2
- var Wo=Object.create;var Vn=Object.defineProperty;var jo=Object.getOwnPropertyDescriptor;var Uo=Object.getOwnPropertyNames;var Bo=Object.getPrototypeOf,zo=Object.prototype.hasOwnProperty;var Go=(i=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(i,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):i)(function(i){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+i+'" is not supported')});var Q=(i,e)=>()=>(i&&(e=i(i=0)),e);var qo=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports),Os=(i,e)=>{for(var t in e)Vn(i,t,{get:e[t],enumerable:!0})},Jo=(i,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Uo(e))!zo.call(i,s)&&s!==t&&Vn(i,s,{get:()=>e[s],enumerable:!(n=jo(e,s))||n.enumerable});return i};var Yo=(i,e,t)=>(t=i!=null?Wo(Bo(i)):{},Jo(e||!i||!i.__esModule?Vn(t,"default",{value:i,enumerable:!0}):t,i));import Vo from"pino";var Qo,Ko,_,P=Q(()=>{"use strict";Qo={10:"TRACE",20:"DEBUG",30:"INFO",40:"WARN",50:"ERROR",60:"FATAL"},Ko=Vo({level:process.env.LOG_LEVEL||"info",base:{service:"liquid-shadow"},formatters:{level(i,e){return{level:i,severity:Qo[e]??"INFO"}}},transport:{target:"pino-pretty",options:{colorize:!0,translateTime:"HH:MM:ss",destination:2,levelKey:"severity",messageKey:"message"}}}),_=Ko});import St from"fs";import Qn from"path";import{fileURLToPath as ea}from"url";function sa(i){i.exec(`
2
+ var j_=Object.create;var ic=Object.defineProperty;var U_=Object.getOwnPropertyDescriptor;var F_=Object.getOwnPropertyNames;var Z_=Object.getPrototypeOf,H_=Object.prototype.hasOwnProperty;var W_=(n=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(n,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):n)(function(n){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});var ge=(n,e)=>()=>(n&&(e=n(n=0)),e);var B_=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),Ke=(n,e)=>{for(var r in e)ic(n,r,{get:e[r],enumerable:!0})},G_=(n,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of F_(e))!H_.call(n,t)&&t!==r&&ic(n,t,{get:()=>e[t],enumerable:!(i=U_(e,t))||i.enumerable});return n};var J_=(n,e,r)=>(r=n!=null?j_(Z_(n)):{},G_(e||!n||!n.__esModule?ic(r,"default",{value:n,enumerable:!0}):r,n));import q_ from"pino";var V_,K_,x,G=ge(()=>{"use strict";V_={10:"TRACE",20:"DEBUG",30:"INFO",40:"WARN",50:"ERROR",60:"FATAL"},K_=q_({level:process.env.LOG_LEVEL||"warn",base:{service:"liquid-shadow"},formatters:{level(n,e){return{level:n,severity:V_[e]??"INFO"}}},transport:{target:"pino-pretty",options:{colorize:!0,translateTime:"HH:MM:ss",destination:2,levelKey:"severity",messageKey:"message"}}}),x=K_});import Hr from"fs";import sc from"path";import{fileURLToPath as Q_}from"url";function nx(n){n.exec(`
3
3
  CREATE TABLE IF NOT EXISTS schema_migrations (
4
4
  version INTEGER PRIMARY KEY,
5
5
  name TEXT NOT NULL,
6
6
  applied_at REAL DEFAULT (unixepoch())
7
7
  );
8
- `)}function ia(i){sa(i);let e=i.prepare("SELECT version FROM schema_migrations ORDER BY version").all();return new Set(e.map(t=>t.version))}function ra(){let i=na;if(!St.readdirSync(i).some(r=>r.match(/^\d{3}_.*\.sql$/))){let r=Qn.resolve(i,"../../data/migrations");St.existsSync(r)&&St.readdirSync(r).some(c=>c.match(/^\d{3}_.*\.sql$/))&&(i=r)}let n=St.readdirSync(i).filter(r=>r.match(/^\d{3}_.*\.sql$/)).sort(),s=[];for(let r of n){let o=r.match(/^(\d{3})_(.+)\.sql$/);if(!o)continue;let c=parseInt(o[1],10),a=o[2],p=St.readFileSync(Qn.join(i,r),"utf-8").split(/^-- DOWN$/m),d=p[0].trim(),u=p[1]?.trim();s.push({version:c,name:a,up:d,down:u})}return s}function oa(i,e){_t.info({version:e.version,name:e.name},"Applying migration"),i.transaction(()=>{i.exec(e.up),i.prepare("INSERT INTO schema_migrations (version, name) VALUES (?, ?)").run(e.version,e.name)})(),_t.info({version:e.version},"Migration applied successfully")}function Us(i){let e=ia(i),n=ra().filter(s=>!e.has(s.version));if(n.length===0){_t.debug("No pending migrations");return}_t.info({count:n.length},"Running pending migrations");for(let s of n)oa(i,s);_t.info("All migrations complete")}var _t,ta,na,Bs=Q(()=>{"use strict";P();_t=_.child({module:"migrations"}),ta=ea(import.meta.url),na=Qn.dirname(ta)});import aa from"better-sqlite3";import Gt from"path";import Kn from"fs";import zs from"crypto";import ca from"os";function Jt(i){let e=ca.homedir(),t=Gt.join(e,".mcp-liquid-shadow"),n=Gt.join(t,"dbs");Kn.existsSync(n)||Kn.mkdirSync(n,{recursive:!0});let s=zs.createHash("sha256").update(i).digest("hex").substring(0,12),o=`${Gt.basename(i).replace(/[^a-zA-Z0-9-_]/g,"_")}_${s}.db`;return Gt.join(n,o)}function la(i,e){let t=e||Jt(i);$e.info({repoPath:i,dbPath:t},"Initializing database");let n=new aa(t);return n.pragma("journal_mode = WAL"),n.pragma("busy_timeout = 5000"),Us(n),qt.set(i,t),Me.set(t,n),$e.info({repoPath:i,dbPath:t},"Database initialized successfully"),n}function Xn(i){return zs.createHash("sha256").update(i,"utf8").digest("hex")}function Gs(i,e){return e?Xn(i)!==e:!0}function ke(i){let e=qt.get(i)||Jt(i),t=Me.get(e);if(t){if(t.open)return t;Me.delete(e)}let n=la(i);return Me.set(e,n),n}function Ve(i){let e=Jt(i);if(!Kn.existsSync(e))return!1;try{let t=ke(i);return t.prepare(`
8
+ `)}function rx(n){nx(n);let e=n.prepare("SELECT version FROM schema_migrations ORDER BY version").all();return new Set(e.map(r=>r.version))}function ix(){let n=tx;if(!Hr.readdirSync(n).some(o=>o.match(/^\d{3}_.*\.sql$/))){let o=sc.resolve(n,"../../data/migrations");Hr.existsSync(o)&&Hr.readdirSync(o).some(a=>a.match(/^\d{3}_.*\.sql$/))&&(n=o)}let i=Hr.readdirSync(n).filter(o=>o.match(/^\d{3}_.*\.sql$/)).sort(),t=[];for(let o of i){let s=o.match(/^(\d{3})_(.+)\.sql$/);if(!s)continue;let a=parseInt(s[1],10),c=s[2],u=Hr.readFileSync(sc.join(n,o),"utf-8").split(/^-- DOWN$/m),d=u[0].trim(),p=u[1]?.trim();t.push({version:a,name:c,up:d,down:p})}return t}function ox(n,e){Wr.info({version:e.version,name:e.name},"Applying migration"),n.transaction(()=>{n.exec(e.up),n.prepare("INSERT INTO schema_migrations (version, name) VALUES (?, ?)").run(e.version,e.name)})(),Wr.info({version:e.version},"Migration applied successfully")}function Af(n){let e=rx(n),i=ix().filter(t=>!e.has(t.version));if(i.length===0){Wr.debug("No pending migrations");return}Wr.info({count:i.length},"Running pending migrations");for(let t of i)ox(n,t);Wr.info("All migrations complete")}var Wr,ex,tx,Of=ge(()=>{"use strict";G();Wr=x.child({module:"migrations"}),ex=Q_(import.meta.url),tx=sc.dirname(ex)});import sx from"better-sqlite3";import Gi from"path";import ac from"fs";import Mf from"crypto";import ax from"os";function qi(n){let e=ax.homedir(),r=Gi.join(e,".mcp-liquid-shadow"),i=Gi.join(r,"dbs");ac.existsSync(i)||ac.mkdirSync(i,{recursive:!0});let t=Mf.createHash("sha256").update(n).digest("hex").substring(0,12),s=`${Gi.basename(n).replace(/[^a-zA-Z0-9-_]/g,"_")}_${t}.db`;return Gi.join(i,s)}function jf(n,e){let r=e||qi(n);Rt.debug({repoPath:n,dbPath:r},"Initializing database");let i=new sx(r);return i.pragma("journal_mode = WAL"),i.pragma("busy_timeout = 5000"),Af(i),Ji.set(n,r),Ht.set(r,i),Rt.debug({repoPath:n,dbPath:r},"Database initialized successfully"),i}function yn(n){return Mf.createHash("sha256").update(n,"utf8").digest("hex")}function cc(n,e){return e?yn(n)!==e:!0}function je(n){let e=Ji.get(n)||qi(n),r=Ht.get(e);if(r){if(r.open)return r;Ht.delete(e)}let i=jf(n);return Ht.set(e,i),i}function De(n){let e=qi(n);if(!ac.existsSync(e))return!1;try{let r=je(n);return r.prepare(`
9
9
  SELECT value FROM index_metadata
10
10
  WHERE key = 'index_completed'
11
- `).get()?.value==="true"?!0:t.prepare("SELECT COUNT(*) as count FROM files").get().count>0}catch(t){return $e.debug({repoPath:i,error:t},"Error checking index status"),!1}}function Zn(i,e){let t=ke(i);t.prepare(`
12
- INSERT OR REPLACE INTO index_metadata (key, value, updated_at)
13
- VALUES ('index_completed', 'true', unixepoch())
14
- `).run(),t.prepare(`
15
- INSERT OR REPLACE INTO index_metadata (key, value, updated_at)
16
- VALUES ('last_indexed_at', ?, unixepoch())
17
- `).run(Date.now().toString()),e&&t.prepare(`
18
- INSERT OR REPLACE INTO index_metadata (key, value, updated_at)
19
- VALUES ('last_indexed_commit', ?, unixepoch())
20
- `).run(e),$e.info({repoPath:i,commitSha:e},"Repository marked as indexed")}function xt(i){try{return ke(i).prepare(`
11
+ `).get()?.value==="true"?!0:r.prepare("SELECT COUNT(*) as count FROM files").get().count>0}catch(r){return Rt.debug({repoPath:n,error:r},"Error checking index status"),!1}}function Vi(n,e){let r=je(n),i=r.prepare("INSERT OR REPLACE INTO index_metadata (key, value, updated_at) VALUES (?, ?, unixepoch())");r.transaction(()=>{i.run("index_completed","true"),i.run("last_indexed_at",Date.now().toString()),e&&i.run("last_indexed_commit",e)})(),Rt.debug({repoPath:n,commitSha:e},"Repository marked as indexed")}function Zn(n){try{return je(n).prepare(`
21
12
  SELECT value FROM index_metadata
22
13
  WHERE key = 'last_indexed_commit'
23
- `).get()?.value||null}catch(e){return $e.debug({repoPath:i,error:e},"Error getting last indexed commit"),null}}function Yt(i){let e=qt.get(i)||Jt(i),t=Me.get(e);t&&(t.open&&($e.info({repoPath:i,dbPath:e},"Closing database connection"),t.close()),Me.delete(e)),qt.delete(i)}function qs(){for(let[i,e]of Me.entries())try{e.open&&($e.info({dbPath:i},"Closing database connection"),e.close())}catch(t){$e.error({dbPath:i,err:t},"Error closing database execution")}Me.clear()}var $e,Me,qt,Js,Qe=Q(()=>{"use strict";P();Bs();$e=_.child({module:"db"});Me=new Map,qt=new Map;process.on("exit",()=>qs());Js=i=>{$e.info({signal:i},"Received termination signal, closing databases"),qs(),process.exit(0)};process.on("SIGINT",()=>Js("SIGINT"));process.on("SIGTERM",()=>Js("SIGTERM"))});var X,Ee=Q(()=>{"use strict";X=class{db;constructor(e){this.db=e}get database(){return this.db}all(e,...t){return this.db.prepare(e).all(...t)}get(e,...t){return this.db.prepare(e).get(...t)}run(e,...t){return this.db.prepare(e).run(...t).changes}insert(e,...t){return this.db.prepare(e).run(...t).lastInsertRowid}transaction(e){return this.db.transaction(e)()}}});import pa from"path";var Vt,Ys=Q(()=>{"use strict";Ee();Vt=class extends X{findByPath(e){return this.get("SELECT * FROM files WHERE path = ?",e)}findAll(e){let t="SELECT * FROM files ORDER BY path ASC";return e&&(t+=` LIMIT ${e}`),this.all(t)}getAllPaths(){return this.all("SELECT path FROM files").map(t=>t.path)}findInSubPath(e,t){let n=pa.resolve(e,t),s=n.endsWith("/")?n:n+"/";return this.all(`
14
+ `).get()?.value||null}catch(e){return Rt.debug({repoPath:n,error:e},"Error getting last indexed commit"),null}}function Br(n){let e=Ji.get(n)||qi(n),r=Ht.get(e);r&&(r.open&&(Rt.debug({repoPath:n,dbPath:e},"Closing database connection"),r.close()),Ht.delete(e)),Ji.delete(n)}function Uf(){for(let[n,e]of Ht.entries())try{e.open&&(Rt.debug({dbPath:n},"Closing database connection"),e.close())}catch(r){Rt.error({dbPath:n,err:r},"Error closing database execution")}Ht.clear()}var Rt,Ht,Ji,Ff,st=ge(()=>{"use strict";G();Of();Rt=x.child({module:"db"});Ht=new Map,Ji=new Map;process.on("exit",()=>Uf());Ff=n=>{Rt.debug({signal:n},"Received termination signal, closing databases"),Uf(),process.exit(0)};process.on("SIGINT",()=>Ff("SIGINT"));process.on("SIGTERM",()=>Ff("SIGTERM"))});var Se,ht=ge(()=>{"use strict";Se=class{db;constructor(e){this.db=e}get database(){return this.db}all(e,...r){return this.db.prepare(e).all(...r)}get(e,...r){return this.db.prepare(e).get(...r)}run(e,...r){return this.db.prepare(e).run(...r).changes}insert(e,...r){return this.db.prepare(e).run(...r).lastInsertRowid}transaction(e){return this.db.transaction(e)()}}});import cx from"path";var Ki,Zf=ge(()=>{"use strict";ht();Ki=class extends Se{findByPath(e){return this.get("SELECT * FROM files WHERE path = ?",e)}findAll(e){let r="SELECT * FROM files ORDER BY path ASC";return e&&(r+=` LIMIT ${e}`),this.all(r)}getAllPaths(){return this.all("SELECT path FROM files").map(r=>r.path)}findInSubPath(e,r){let i=cx.resolve(e,r),t=i.endsWith("/")?i:i+"/";return this.all(`
24
15
  SELECT * FROM files
25
16
  WHERE (path LIKE ? OR path = ?)
26
17
  ORDER BY path ASC
27
- `,`${s}%`,n)}findWithEmbeddings(){return this.all("SELECT * FROM files WHERE embedding IS NOT NULL")}findFts(e,t=10){return this.all(`
18
+ `,`${t}%`,i)}findWithEmbeddings(){return this.all("SELECT * FROM files WHERE embedding IS NOT NULL")}findFts(e,r=10){return this.all(`
28
19
  SELECT files.*, files_fts.rank
29
20
  FROM files_fts
30
21
  JOIN files ON files.rowid = files_fts.rowid
31
22
  WHERE files_fts MATCH ?
32
23
  ORDER BY rank
33
24
  LIMIT ?
34
- `,e,t)}findByPathKeywords(e,t=10){let n=e.map(()=>"LOWER(path) LIKE ?").join(" OR ");return this.all(`
25
+ `,e,r)}findByPathKeywords(e,r=10){let i=e.map(()=>"LOWER(path) LIKE ?").join(" OR ");return this.all(`
35
26
  SELECT * FROM files
36
- WHERE ${n}
27
+ WHERE ${i}
37
28
  LIMIT ?
38
- `,...e.map(s=>`%${s}%`),t)}getContent(e){return this.get("SELECT content FROM file_content WHERE file_path = ?",e)?.content}findContentByToken(e,t=10){return this.all(`
29
+ `,...e.map(t=>`%${t}%`),r)}getContent(e){return this.get("SELECT content FROM file_content WHERE file_path = ?",e)?.content}findContentByToken(e,r=10){return this.all(`
39
30
  SELECT file_path
40
31
  FROM content_fts
41
32
  WHERE content_fts MATCH ?
@@ -43,28 +34,28 @@ var Wo=Object.create;var Vn=Object.defineProperty;var jo=Object.getOwnPropertyDe
43
34
  AND file_path NOT LIKE '%/test/%'
44
35
  AND file_path NOT LIKE '%.spec.%'
45
36
  LIMIT ?
46
- `,`"${e.replace(/[^a-zA-Z0-9_\/]/g," ")}"`,t).map(s=>s.file_path)}findSynapses(e){let t="SELECT * FROM event_synapses WHERE 1=1",n=[];if(e.type&&(t+=" AND type = ?",n.push(e.type)),e.name){let s=e.name;s.startsWith("/")&&(s=s.substring(1)),s.endsWith("/")&&(s=s.substring(0,s.length-1)),s.length>0&&(t+=" AND (name LIKE ? OR name LIKE ? OR name = ?)",n.push(`${s}%`),n.push(`%/${s}%`),n.push(e.name))}return e.direction&&(t+=" AND direction = ?",n.push(e.direction)),t+=` LIMIT ${e.limit||50}`,this.all(t,...n)}exists(e){return!!this.get("SELECT 1 FROM files WHERE path = ?",e)}update(e,t){let n=Object.keys(t);if(n.length===0)return;let s=n.map(o=>`${o} = ?`).join(", "),r=Object.values(t);r.push(e),this.run(`UPDATE files SET ${s} WHERE path = ?`,...r)}getStats(){let e=this.get(`
37
+ `,`"${e.replace(/[^a-zA-Z0-9_\/]/g," ")}"`,r).map(t=>t.file_path)}findSynapses(e){let r="SELECT * FROM event_synapses WHERE 1=1",i=[];if(e.type&&(r+=" AND type = ?",i.push(e.type)),e.name){let t=e.name;t.startsWith("/")&&(t=t.substring(1)),t.endsWith("/")&&(t=t.substring(0,t.length-1)),t.length>0&&(r+=" AND (name LIKE ? OR name LIKE ? OR name = ?)",i.push(`${t}%`),i.push(`%/${t}%`),i.push(e.name))}return e.direction&&(r+=" AND direction = ?",i.push(e.direction)),r+=` LIMIT ${e.limit||50}`,this.all(r,...i)}exists(e){return!!this.get("SELECT 1 FROM files WHERE path = ?",e)}update(e,r){let i=Object.keys(r);if(i.length===0)return;let t=i.map(s=>`${s} = ?`).join(", "),o=Object.values(r);o.push(e),this.run(`UPDATE files SET ${t} WHERE path = ?`,...o)}getStats(){let e=this.get(`
47
38
  SELECT
48
39
  COUNT(*) as total,
49
40
  SUM(CASE WHEN summary IS NOT NULL AND summary != '' THEN 1 ELSE 0 END) as withSummary
50
41
  FROM files
51
- `);return{total:e?.total||0,withSummary:e?.withSummary||0}}getGravityMap(e=[],t){let n={},s=`
42
+ `);return{total:e?.total||0,withSummary:e?.withSummary||0}}getGravityMap(e=[],r){let i={},t=`
52
43
  SELECT ws.file_path, m.name as mission_name, m.status
53
44
  FROM working_set ws
54
45
  JOIN missions m ON ws.mission_id = m.id
55
46
  WHERE (
56
- (m.status IN ('in-progress', 'verifying') ${t?"AND m.git_branch = ?":""})
47
+ (m.status IN ('in-progress', 'verifying') ${r?"AND m.git_branch = ?":""})
57
48
  OR m.id IN (${e.length>0?e.join(","):"-1"})
58
49
  )
59
50
  AND ws.file_path IS NOT NULL
60
- `,r=[];t&&r.push(t);let o=this.all(s,...r);for(let l of o){n[l.file_path]||(n[l.file_path]={score:1,reasons:[]});let p=l.status==="in-progress"||l.status==="verifying"?1:.5;n[l.file_path].score+=p;let d=l.status==="in-progress"||l.status==="verifying"?"Working Set":"Lineage Bleed";n[l.file_path].reasons.push(`${d}: ${l.mission_name}`)}let c=Math.floor(Date.now()/1e3)-86400,a=this.all(`
51
+ `,o=[];r&&o.push(r);let s=this.all(t,...o);for(let l of s){i[l.file_path]||(i[l.file_path]={score:1,reasons:[]});let u=l.status==="in-progress"||l.status==="verifying"?1:.5;i[l.file_path].score+=u;let d=l.status==="in-progress"||l.status==="verifying"?"Working Set":"Lineage Bleed";i[l.file_path].reasons.push(`${d}: ${l.mission_name}`)}let a=Math.floor(Date.now()/1e3)-86400,c=this.all(`
61
52
  SELECT file_path, type, mission_id
62
53
  FROM intent_logs
63
54
  WHERE (created_at > ? OR mission_id IN (${e.length>0?e.join(","):"-1"}))
64
55
  AND file_path IS NOT NULL
65
56
  ORDER BY created_at DESC
66
57
  LIMIT 100
67
- `,c);for(let l of a){n[l.file_path]||(n[l.file_path]={score:1,reasons:[]});let p=l.mission_id?e.includes(l.mission_id):!1,d=p?.1:.2;n[l.file_path].score<5&&(n[l.file_path].score+=d);let u=p?`Lineage Intent: ${l.type}`:`Recent Intent: ${l.type}`;!n[l.file_path].reasons.includes(u)&&n[l.file_path].reasons.length<5&&n[l.file_path].reasons.push(u)}return n}getCount(){return this.get("SELECT COUNT(*) as count FROM files")?.count||0}getTopDirectories(e,t=8){return this.all(`
58
+ `,a);for(let l of c){i[l.file_path]||(i[l.file_path]={score:1,reasons:[]});let u=l.mission_id?e.includes(l.mission_id):!1,d=u?.1:.2;i[l.file_path].score<5&&(i[l.file_path].score+=d);let p=u?`Lineage Intent: ${l.type}`:`Recent Intent: ${l.type}`;!i[l.file_path].reasons.includes(p)&&i[l.file_path].reasons.length<5&&i[l.file_path].reasons.push(p)}return i}getCount(){return this.get("SELECT COUNT(*) as count FROM files")?.count||0}getTopDirectories(e,r=8){return this.all(`
68
59
  SELECT
69
60
  SUBSTR(path, LENGTH(?) + 2,
70
61
  INSTR(SUBSTR(path, LENGTH(?) + 2), '/') - 1
@@ -81,14 +72,14 @@ var Wo=Object.create;var Vn=Object.defineProperty;var jo=Object.getOwnPropertyDe
81
72
  GROUP BY root
82
73
  ORDER BY total_files DESC
83
74
  LIMIT ?
84
- `,e,e,e,t)}hasFilesPattern(e){return!!this.get("SELECT 1 FROM files WHERE path LIKE ? LIMIT 1",e)}findPackageJsonChildren(e){return this.all(`
75
+ `,e,e,e,r)}hasFilesPattern(e){return!!this.get("SELECT 1 FROM files WHERE path LIKE ? LIMIT 1",e)}findPackageJsonChildren(e){return this.all(`
85
76
  SELECT
86
77
  path,
87
78
  SUBSTR(path, LENGTH(?) + 2) as relPath
88
79
  FROM files
89
80
  WHERE path LIKE ? || '/%/package.json'
90
- `,e,e)}deletePaths(e){if(e.length===0)return;let t=this.db.prepare("DELETE FROM files WHERE path = ?");this.db.transaction(s=>{for(let r of s)t.run(r)})(e)}updateMtime(e,t){this.run("UPDATE files SET mtime = ? WHERE path = ?",t,e)}batchSaveIndexResults(e,t,n,s){let r=this.db.prepare("DELETE FROM exports WHERE file_path = ?"),o=this.db.prepare("DELETE FROM imports WHERE file_path = ?"),c=this.db.prepare("DELETE FROM configs WHERE file_path = ?"),a=this.db.prepare("DELETE FROM file_content WHERE file_path = ?"),l=this.db.prepare("DELETE FROM event_synapses WHERE file_path = ?"),p=this.db.prepare("INSERT INTO exports (file_path, name, kind, signature, doc, start_line, end_line, classification, capabilities, parent_id, embedding) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"),d=this.db.prepare("INSERT INTO imports (file_path, module_specifier, imported_symbols, resolved_path) VALUES (?, ?, ?, ?)"),u=this.db.prepare("INSERT INTO configs (file_path, key, value, kind) VALUES (?, ?, ?, ?)"),m=this.db.prepare("INSERT INTO file_content (file_path, content) VALUES (?, ?)"),f=this.db.prepare("INSERT INTO event_synapses (file_path, type, name, direction, line_number, code_snippet) VALUES (?, ?, ?, ?, ?, ?)"),h=this.db.prepare(`
91
- INSERT INTO files (path, mtime, last_scanned_at, classification, summary, embedding, content_hash)
81
+ `,e,e)}deletePaths(e){if(e.length===0)return;let r=this.db.prepare("DELETE FROM files WHERE path = ?");this.db.transaction(t=>{for(let o of t)r.run(o)})(e)}updateMtime(e,r){this.run("UPDATE files SET mtime = ? WHERE path = ?",r,e)}batchSaveIndexResults(e,r,i,t){let o=this.db.prepare("DELETE FROM exports WHERE file_path = ?"),s=this.db.prepare("DELETE FROM imports WHERE file_path = ?"),a=this.db.prepare("DELETE FROM configs WHERE file_path = ?"),c=this.db.prepare("DELETE FROM file_content WHERE file_path = ?"),l=this.db.prepare("DELETE FROM event_synapses WHERE file_path = ?"),u=this.db.prepare("INSERT INTO exports (file_path, name, kind, signature, doc, start_line, end_line, classification, capabilities, parent_id, embedding) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"),d=this.db.prepare("INSERT INTO imports (file_path, module_specifier, imported_symbols, resolved_path) VALUES (?, ?, ?, ?)"),p=this.db.prepare("INSERT INTO configs (file_path, key, value, kind) VALUES (?, ?, ?, ?)"),m=this.db.prepare("INSERT INTO file_content (file_path, content) VALUES (?, ?)"),f=this.db.prepare("INSERT INTO event_synapses (file_path, type, name, direction, line_number, code_snippet) VALUES (?, ?, ?, ?, ?, ?)"),h=this.db.prepare(`
82
+ INSERT INTO files (path, mtime, last_scanned_at, classification, summary, embedding, content_hash)
92
83
  VALUES (?, ?, ?, ?, ?, ?, ?)
93
84
  ON CONFLICT(path) DO UPDATE SET
94
85
  mtime=excluded.mtime,
@@ -97,36 +88,36 @@ var Wo=Object.create;var Vn=Object.defineProperty;var jo=Object.getOwnPropertyDe
97
88
  summary=excluded.summary,
98
89
  embedding=excluded.embedding,
99
90
  content_hash=excluded.content_hash
100
- `);this.db.transaction(y=>{for(let g of y){let{meta:S,exports:R,imports:w,configs:T,events:v,content:k,classification:F,summary:x,embedding:I}=g;r.run(S.path),o.run(S.path),c.run(S.path),a.run(S.path),l.run(S.path);let M=k?n(k):null;if(h.run(S.path,S.mtime,Date.now(),F||"Unknown",x||"",I?JSON.stringify(I):null,M),R){let $=(j,H,N)=>{for(let L of H){let A=L.embedding?JSON.stringify(L.embedding):null,D=p.run(j,L.name,L.kind,L.signature,L.doc||"",L.line,L.endLine||L.line,L.classification||"Other",L.capabilities||"[]",N,A);L.members&&L.members.length>0&&$(j,L.members,D.lastInsertRowid)}};$(S.path,R,null)}if(w)for(let $ of w){let j=s($.module,S.path,t);d.run(S.path,$.module,$.name,j)}if(T)for(let $ of T)u.run(S.path,$.key,$.value,$.kind);if(k!==void 0&&m.run(S.path,k),v)for(let $ of v)f.run(S.path,$.type,$.name,$.direction,$.line,$.snippet)}})(e)}getLatestScanTime(){return this.get("SELECT MAX(last_scanned_at) as t FROM files")?.t||null}}});var Qt,Vs=Q(()=>{"use strict";Ee();Qt=class extends X{findByNameAndFile(e,t){return this.all("SELECT * FROM exports WHERE file_path = ? AND name = ?",t,e)}findByNameGlobal(e){return this.all("SELECT * FROM exports WHERE name = ?",e)}findAtLine(e,t){return this.get(`
91
+ `),_=this.db.transaction(y=>{for(let k of y){let{meta:$,exports:w,imports:I,configs:P,events:R,content:F,classification:T,summary:A,embedding:H,contentHash:J}=k;o.run($.path),s.run($.path),a.run($.path),c.run($.path),l.run($.path);let M=J??(F&&i?i(F):null);if(h.run($.path,$.mtime,Date.now(),T||"Unknown",A||"",H?JSON.stringify(H):null,M),w){let N=(W,q,Z)=>{for(let U of q){let he=U.embedding?JSON.stringify(U.embedding):null,V=u.run(W,U.name,U.kind,U.signature,U.doc||"",U.line,U.endLine||U.line,U.classification||"Other",U.capabilities||"[]",Z,he);U.members&&U.members.length>0&&N(W,U.members,V.lastInsertRowid)}};N($.path,w,null)}if(I)for(let N of I){let W=N.resolved_path!==void 0?N.resolved_path:t?.(N.module,$.path,r)??"";d.run($.path,N.module,N.name,W)}if(P)for(let N of P)p.run($.path,N.key,N.value,N.kind);if(F!==void 0&&m.run($.path,F),R)for(let N of R)f.run($.path,N.type,N.name,N.direction,N.line,N.snippet)}}),v=500;for(let y=0;y<e.length;y+=v)_(e.slice(y,y+v))}getLatestScanTime(){return this.get("SELECT MAX(last_scanned_at) as t FROM files")?.t||null}}});var Yi,Hf=ge(()=>{"use strict";ht();Yi=class extends Se{findByNameAndFile(e,r){return this.all("SELECT * FROM exports WHERE file_path = ? AND name = ?",r,e)}findByNameGlobal(e){return this.all("SELECT * FROM exports WHERE name = ?",e)}findAtLine(e,r){return this.get(`
101
92
  SELECT * FROM exports
102
93
  WHERE file_path = ? AND start_line <= ? AND end_line >= ?
103
94
  ORDER BY (end_line - start_line) ASC -- Get innermost symbol
104
95
  LIMIT 1
105
- `,e,t,t)}findById(e){return this.get("SELECT * FROM exports WHERE id = ?",e)}findHydratedById(e){let t=this.findById(e);if(!t)return;let n=this.all(`
106
- SELECT id, mission_id, type, content, created_at, confidence
96
+ `,e,r,r)}findById(e){return this.get("SELECT * FROM exports WHERE id = ?",e)}findHydratedById(e){let r=this.findById(e);if(!r)return;let i=this.all(`
97
+ SELECT id, mission_id, type, content, created_at, confidence, is_crystallized, crystal_id
107
98
  FROM intent_logs
108
99
  WHERE symbol_id = ?
109
100
  ORDER BY created_at DESC
110
- LIMIT 5
111
- `,e),r=this.get("SELECT COUNT(*) as count FROM intent_logs WHERE symbol_id = ?",e)?.count||0,o=this.all(`
101
+ LIMIT 10
102
+ `,e),o=this.get("SELECT COUNT(*) as count FROM intent_logs WHERE symbol_id = ?",e)?.count||0,s=this.all(`
112
103
  SELECT m.id, m.name, m.status
113
104
  FROM missions m
114
105
  JOIN working_set ws ON ws.mission_id = m.id
115
106
  WHERE ws.symbol_id = ?
116
107
  AND m.status IN ('in-progress', 'planned', 'verifying')
117
108
  GROUP BY m.id
118
- `,e);return{...t,recent_intents:n,intent_log_count:r,active_missions:o}}findRoutesByCapability(e){return this.all(`
109
+ `,e);return{...r,recent_intents:i,intent_log_count:o,active_missions:s}}findRoutesByCapability(e){return this.all(`
119
110
  SELECT name, file_path, signature
120
111
  FROM exports
121
112
  WHERE kind = 'HTTP Route'
122
113
  AND capabilities LIKE ?
123
- `,`%${e}%`)}findRoutesByToken(e,t=5){return this.all(`
114
+ `,`%${e}%`)}findRoutesByToken(e,r=5){return this.all(`
124
115
  SELECT *
125
116
  FROM exports
126
117
  WHERE (kind = 'HTTP Route' OR classification = 'Service Boundary')
127
118
  AND (name LIKE ? OR signature LIKE ?)
128
119
  LIMIT ?
129
- `,`%${e}%`,`%${e}%`,t)}findByFile(e){return this.all("SELECT * FROM exports WHERE file_path = ? ORDER BY start_line ASC",e)}findByFiles(e){if(e.length===0)return[];let t=e.map(()=>"?").join(", ");return this.all(`SELECT * FROM exports WHERE file_path IN (${t}) ORDER BY file_path, start_line ASC`,...e)}findSiblings(e){return this.all(`
120
+ `,`%${e}%`,`%${e}%`,r)}findByFile(e){return this.all("SELECT * FROM exports WHERE file_path = ? ORDER BY start_line ASC",e)}findByFiles(e){if(e.length===0)return[];let r=e.map(()=>"?").join(", ");return this.all(`SELECT * FROM exports WHERE file_path IN (${r}) ORDER BY file_path, start_line ASC`,...e)}findSiblings(e){return this.all(`
130
121
  SELECT name, kind, signature, start_line, end_line,
131
122
  parent_id, id,
132
123
  (SELECT name FROM exports WHERE id = e.parent_id) as parent_name
@@ -134,7 +125,7 @@ var Wo=Object.create;var Vn=Object.defineProperty;var jo=Object.getOwnPropertyDe
134
125
  WHERE file_path = ?
135
126
  AND parent_id IS NULL
136
127
  ORDER BY start_line ASC
137
- `,e)}findByName(e,t=20){return this.all("SELECT * FROM exports WHERE name = ? LIMIT ?",e,t)}findClassByName(e){return this.get("SELECT * FROM exports WHERE name = ? AND kind = 'ClassDeclaration' LIMIT 1",e)}findDefinitionCandidates(e,t){let n=[e],s=`
128
+ `,e)}findByName(e,r=20){return this.all("SELECT * FROM exports WHERE name = ? LIMIT ?",e,r)}findClassByName(e){return this.get("SELECT * FROM exports WHERE name = ? AND kind = 'ClassDeclaration' LIMIT 1",e)}findDefinitionCandidates(e,r){let i=[e],t=`
138
129
  SELECT e.id, e.name, e.kind, e.start_line, e.end_line, e.signature, e.doc,
139
130
  f.path as file_path, e.classification, e.capabilities,
140
131
  p.name as parent_name, p.kind as parent_kind
@@ -142,12 +133,12 @@ var Wo=Object.create;var Vn=Object.defineProperty;var jo=Object.getOwnPropertyDe
142
133
  JOIN files f ON e.file_path = f.path
143
134
  LEFT JOIN exports p ON e.parent_id = p.id
144
135
  WHERE e.name = ?
145
- `;return t&&(s+=" AND f.path = ?",n.push(t)),s+=`
136
+ `;return r&&(t+=" AND f.path = ?",i.push(r)),t+=`
146
137
  ORDER BY
147
138
  CASE WHEN e.parent_id IS NULL THEN 0 ELSE 1 END,
148
139
  CASE WHEN e.kind = 'ExportSpecifier' THEN 2 ELSE 0 END
149
140
  LIMIT 10
150
- `,this.all(s,...n)}findMemberCandidates(e,t,n){let s=[e,t],r=`
141
+ `,this.all(t,...i)}findMemberCandidates(e,r,i){let t=[e,r],o=`
151
142
  SELECT e.id, e.name, e.kind, e.start_line, e.end_line, e.signature, e.doc,
152
143
  f.path as file_path, e.classification, e.capabilities,
153
144
  p.name as parent_name, p.kind as parent_kind
@@ -155,12 +146,12 @@ var Wo=Object.create;var Vn=Object.defineProperty;var jo=Object.getOwnPropertyDe
155
146
  JOIN files f ON e.file_path = f.path
156
147
  LEFT JOIN exports p ON e.parent_id = p.id
157
148
  WHERE p.name = ? AND e.name = ?
158
- `;return n&&(r+=" AND f.path = ?",s.push(n)),r+=`
149
+ `;return i&&(o+=" AND f.path = ?",t.push(i)),o+=`
159
150
  ORDER BY
160
151
  CASE WHEN e.parent_id IS NULL THEN 0 ELSE 1 END,
161
152
  CASE WHEN e.kind = 'ExportSpecifier' THEN 2 ELSE 0 END
162
153
  LIMIT 10
163
- `,this.all(r,...s)}findPotentialParents(e){return this.all(`
154
+ `,this.all(o,...t)}findPotentialParents(e){return this.all(`
164
155
  SELECT name, kind, file_path
165
156
  FROM exports
166
157
  WHERE kind IN ('ClassDeclaration', 'ClassExpression', 'TsInterfaceDeclaration')
@@ -168,27 +159,27 @@ var Wo=Object.create;var Vn=Object.defineProperty;var jo=Object.getOwnPropertyDe
168
159
  SELECT rowid FROM content_fts WHERE content MATCH ?
169
160
  )
170
161
  LIMIT 3
171
- `,`"${e}"`)}findFuzzyCandidates(e){let t=e.charAt(0).toLowerCase();return this.all(`
162
+ `,`"${e}"`)}findFuzzyCandidates(e){let r=e.charAt(0).toLowerCase();return this.all(`
172
163
  SELECT DISTINCT name FROM exports
173
164
  WHERE parent_id IS NULL
174
165
  AND (name LIKE ? OR name LIKE ? OR ABS(LENGTH(name) - LENGTH(?)) <= 5)
175
166
  ORDER BY ABS(LENGTH(name) - LENGTH(?)) ASC
176
167
  LIMIT 1000
177
- `,t+"%","%"+t+"%",e,e)}findTopLevelByFile(e){return this.all(`
168
+ `,r+"%","%"+r+"%",e,e)}findTopLevelByFile(e){return this.all(`
178
169
  SELECT * FROM exports
179
170
  WHERE file_path = ? AND parent_id IS NULL
180
171
  ORDER BY start_line ASC
181
- `,e)}findFts(e,t=20){return this.all(`
172
+ `,e)}findFts(e,r=20){return this.all(`
182
173
  SELECT e.*
183
174
  FROM exports e
184
175
  JOIN exports_fts ON e.id = exports_fts.rowid
185
176
  WHERE exports_fts MATCH ?
186
177
  LIMIT ?
187
- `,e,t)}findByPartialName(e,t=20){return this.all(`
178
+ `,e,r)}findByPartialName(e,r=20){return this.all(`
188
179
  SELECT * FROM exports
189
180
  WHERE lower(name) LIKE ?
190
181
  LIMIT ?
191
- `,`%${e.toLowerCase()}%`,t)}getAllNames(e=5e3){return this.all("SELECT DISTINCT name FROM exports WHERE parent_id IS NULL LIMIT ?",e).map(n=>n.name)}countByFile(e){return this.get("SELECT COUNT(*) as count FROM exports WHERE file_path = ?",e)?.count||0}findDeadExports(e={}){let{limit:t=50,includeTests:n=!1,includeMigrations:s=!1,includeFixtures:r=!1,excludePatterns:o=[],confidenceThreshold:c="all"}=e,a=[];n||(a.push("e.file_path NOT LIKE '%/test/%'"),a.push("e.file_path NOT LIKE '%/tests/%'"),a.push("e.file_path NOT LIKE '%/__tests__/%'"),a.push("e.file_path NOT LIKE '%.spec.%'"),a.push("e.file_path NOT LIKE '%.test.%'")),s||(a.push("e.file_path NOT LIKE '%/migrations/%'"),a.push("e.file_path NOT LIKE '%/migration/%'"),a.push("e.file_path NOT LIKE '%Migration.%'")),r||(a.push("e.file_path NOT LIKE '%/__fixtures__/%'"),a.push("e.file_path NOT LIKE '%/__mocks__/%'"),a.push("e.file_path NOT LIKE '%/fixtures/%'"),a.push("e.file_path NOT LIKE '%/mocks/%'"),a.push("e.file_path NOT LIKE '%.fixture.%'"),a.push("e.file_path NOT LIKE '%.mock.%'"));for(let m of o){let f=m.replace(/\*\*/g,"%").replace(/\*/g,"%").replace(/\?/g,"_");a.push(`e.file_path NOT LIKE '${f}'`)}let l=a.length>0?`AND ${a.join(" AND ")}`:"",d=this.all(`
182
+ `,`%${e.toLowerCase()}%`,r)}getAllNames(e=5e3){return this.all("SELECT DISTINCT name FROM exports WHERE parent_id IS NULL LIMIT ?",e).map(i=>i.name)}countByFile(e){return this.get("SELECT COUNT(*) as count FROM exports WHERE file_path = ?",e)?.count||0}findDeadExports(e={}){let{limit:r=50,includeTests:i=!1,includeMigrations:t=!1,includeFixtures:o=!1,excludePatterns:s=[],confidenceThreshold:a="all"}=e,c=[];i||(c.push("e.file_path NOT LIKE '%/test/%'"),c.push("e.file_path NOT LIKE '%/tests/%'"),c.push("e.file_path NOT LIKE '%/__tests__/%'"),c.push("e.file_path NOT LIKE '%.spec.%'"),c.push("e.file_path NOT LIKE '%.test.%'")),t||(c.push("e.file_path NOT LIKE '%/migrations/%'"),c.push("e.file_path NOT LIKE '%/migration/%'"),c.push("e.file_path NOT LIKE '%Migration.%'")),o||(c.push("e.file_path NOT LIKE '%/__fixtures__/%'"),c.push("e.file_path NOT LIKE '%/__mocks__/%'"),c.push("e.file_path NOT LIKE '%/fixtures/%'"),c.push("e.file_path NOT LIKE '%/mocks/%'"),c.push("e.file_path NOT LIKE '%.fixture.%'"),c.push("e.file_path NOT LIKE '%.mock.%'"));for(let m of s){let f=m.replace(/\*\*/g,"%").replace(/\*/g,"%").replace(/\?/g,"_");c.push(`e.file_path NOT LIKE '${f}'`)}let l=c.length>0?`AND ${c.join(" AND ")}`:"",d=this.all(`
192
183
  SELECT e.name, e.kind, e.file_path, e.start_line
193
184
  FROM exports e
194
185
  WHERE e.kind IN (
@@ -202,23 +193,23 @@ var Wo=Object.create;var Vn=Object.defineProperty;var jo=Object.getOwnPropertyDe
202
193
  AND NOT EXISTS (SELECT 1 FROM imports i WHERE i.resolved_path = e.file_path AND i.imported_symbols LIKE '%*%')
203
194
  ORDER BY e.file_path, e.start_line
204
195
  LIMIT ?
205
- `,t*2).map(m=>{let{confidence:f,reason:h}=this.scoreDeadExportConfidence(m);return{...m,confidence:f,reason:h}}),u=d;return c==="high"?u=d.filter(m=>m.confidence==="high"):c==="medium"&&(u=d.filter(m=>m.confidence==="high"||m.confidence==="medium")),u.slice(0,t)}scoreDeadExportConfidence(e){let t=e.file_path.toLowerCase(),n=e.name;return t.includes("/index.")||t.endsWith("index.ts")||t.endsWith("index.js")?{confidence:"low",reason:"Barrel/index file - likely re-export"}:e.kind==="TsInterfaceDeclaration"||e.kind==="TsTypeAliasDeclaration"?{confidence:"medium",reason:"Type definition - may be used externally"}:t.includes("/entry/")||t.includes("/bin/")||t.includes("main.")||t.includes("server.")||t.includes("cli.")?{confidence:"medium",reason:"Entry point - may be invoked externally"}:n.startsWith("create")||n.endsWith("Factory")||n.endsWith("Builder")?{confidence:"medium",reason:"Factory/builder pattern - may be used dynamically"}:n.startsWith("use")&&n.length>3?{confidence:"medium",reason:"Hook pattern - may be used in components"}:{confidence:"high",reason:"No detected usage"}}getGravityMap(e=[],t){let n={},s=`
196
+ `,r*2).map(m=>{let{confidence:f,reason:h}=this.scoreDeadExportConfidence(m);return{...m,confidence:f,reason:h}}),p=d;return a==="high"?p=d.filter(m=>m.confidence==="high"):a==="medium"&&(p=d.filter(m=>m.confidence==="high"||m.confidence==="medium")),p.slice(0,r)}scoreDeadExportConfidence(e){let r=e.file_path.toLowerCase(),i=e.name;return r.includes("/index.")||r.endsWith("index.ts")||r.endsWith("index.js")?{confidence:"low",reason:"Barrel/index file - likely re-export"}:e.kind==="TsInterfaceDeclaration"||e.kind==="TsTypeAliasDeclaration"?{confidence:"medium",reason:"Type definition - may be used externally"}:r.includes("/entry/")||r.includes("/bin/")||r.includes("main.")||r.includes("server.")||r.includes("cli.")?{confidence:"medium",reason:"Entry point - may be invoked externally"}:i.startsWith("create")||i.endsWith("Factory")||i.endsWith("Builder")?{confidence:"medium",reason:"Factory/builder pattern - may be used dynamically"}:i.startsWith("use")&&i.length>3?{confidence:"medium",reason:"Hook pattern - may be used in components"}:{confidence:"high",reason:"No detected usage"}}getGravityMap(e=[],r){let i={},t=`
206
197
  SELECT ws.symbol_id, m.name as mission_name, m.status
207
198
  FROM working_set ws
208
199
  JOIN missions m ON ws.mission_id = m.id
209
200
  WHERE (
210
- (m.status IN ('in-progress', 'verifying') ${t?"AND m.git_branch = ?":""})
201
+ (m.status IN ('in-progress', 'verifying') ${r?"AND m.git_branch = ?":""})
211
202
  OR m.id IN (${e.length>0?e.join(","):"-1"})
212
203
  )
213
204
  AND ws.symbol_id IS NOT NULL
214
- `,r=[];t&&r.push(t);let o=this.all(s,...r);for(let l of o){n[l.symbol_id]||(n[l.symbol_id]={score:1,reasons:[]});let p=l.status==="in-progress"||l.status==="verifying"?1:.5;n[l.symbol_id].score+=p;let d=l.status==="in-progress"||l.status==="verifying"?"Working Set":"Lineage Bleed";n[l.symbol_id].reasons.push(`${d}: ${l.mission_name}`)}let c=Math.floor(Date.now()/1e3)-86400,a=this.all(`
205
+ `,o=[];r&&o.push(r);let s=this.all(t,...o);for(let l of s){i[l.symbol_id]||(i[l.symbol_id]={score:1,reasons:[]});let u=l.status==="in-progress"||l.status==="verifying"?1:.5;i[l.symbol_id].score+=u;let d=l.status==="in-progress"||l.status==="verifying"?"Working Set":"Lineage Bleed";i[l.symbol_id].reasons.push(`${d}: ${l.mission_name}`)}let a=Math.floor(Date.now()/1e3)-86400,c=this.all(`
215
206
  SELECT symbol_id, type, mission_id
216
207
  FROM intent_logs
217
208
  WHERE (created_at > ? OR mission_id IN (${e.length>0?e.join(","):"-1"}))
218
209
  AND symbol_id IS NOT NULL
219
210
  ORDER BY created_at DESC
220
211
  LIMIT 200
221
- `,c);for(let l of a){n[l.symbol_id]||(n[l.symbol_id]={score:1,reasons:[]});let p=l.mission_id?e.includes(l.mission_id):!1,d=p?.1:.2;n[l.symbol_id].score<5&&(n[l.symbol_id].score+=d);let u=p?`Lineage Intent: ${l.type}`:`Recent Intent: ${l.type}`;!n[l.symbol_id].reasons.includes(u)&&n[l.symbol_id].reasons.length<5&&n[l.symbol_id].reasons.push(u)}return n}getCount(){return this.get("SELECT COUNT(*) as count FROM exports")?.count||0}getKindDistribution(e=5){return this.all(`
212
+ `,a);for(let l of c){i[l.symbol_id]||(i[l.symbol_id]={score:1,reasons:[]});let u=l.mission_id?e.includes(l.mission_id):!1,d=u?.1:.2;i[l.symbol_id].score<5&&(i[l.symbol_id].score+=d);let p=u?`Lineage Intent: ${l.type}`:`Recent Intent: ${l.type}`;!i[l.symbol_id].reasons.includes(p)&&i[l.symbol_id].reasons.length<5&&i[l.symbol_id].reasons.push(p)}return i}getCount(){return this.get("SELECT COUNT(*) as count FROM exports")?.count||0}getKindDistribution(e=5){return this.all(`
222
213
  SELECT kind, COUNT(*) as c
223
214
  FROM exports
224
215
  WHERE kind IS NOT NULL AND kind != ''
@@ -231,7 +222,7 @@ var Wo=Object.create;var Vn=Object.defineProperty;var jo=Object.getOwnPropertyDe
231
222
  OR name LIKE ?
232
223
  OR name LIKE ?
233
224
  LIMIT 10
234
- `,e,`%.${e}`,`%::${e}`)}}});var Qs,Ks=Q(()=>{"use strict";Qs=`
225
+ `,e,`%.${e}`,`%::${e}`)}}});var Wf,Bf=ge(()=>{"use strict";Wf=`
235
226
  WITH RECURSIVE dependency_chain AS (
236
227
  -- Base case: Direct dependents of the target symbol
237
228
  -- Meaning: Files that import the file where the symbol is defined
@@ -282,37 +273,37 @@ SELECT DISTINCT
282
273
  dc.imported_symbols
283
274
  FROM dependency_chain dc
284
275
  ORDER BY dc.depth, dc.consumer_path;
285
- `});var Kt,Xs=Q(()=>{"use strict";Ee();Ks();Kt=class extends X{findByFile(e){return this.all("SELECT * FROM imports WHERE file_path = ?",e)}findByFiles(e){if(e.length===0)return[];let t=e.map(()=>"?").join(", ");return this.all(`SELECT * FROM imports WHERE file_path IN (${t}) ORDER BY file_path`,...e)}getAllResolved(){return this.all(`
276
+ `});var Xi,Gf=ge(()=>{"use strict";ht();Bf();Xi=class extends Se{findByFile(e){return this.all("SELECT * FROM imports WHERE file_path = ?",e)}findByFiles(e){if(e.length===0)return[];let r=e.map(()=>"?").join(", ");return this.all(`SELECT * FROM imports WHERE file_path IN (${r}) ORDER BY file_path`,...e)}getAllResolved(){return this.all(`
286
277
  SELECT * FROM imports
287
278
  WHERE resolved_path IS NOT NULL AND resolved_path != ''
288
- `)}findDependents(e){return this.all("SELECT * FROM imports WHERE resolved_path = ?",e)}countByFile(e){return this.get("SELECT COUNT(*) as count FROM imports WHERE file_path = ?",e)?.count||0}countDependents(e){return this.get("SELECT COUNT(*) as count FROM imports WHERE resolved_path = ?",e)?.count||0}getImportsForFile(e){return this.all("SELECT module_specifier, imported_symbols, resolved_path FROM imports WHERE file_path = ?",e)}findImportSource(e,t){return this.get(`
279
+ `)}findDependents(e){return this.all("SELECT * FROM imports WHERE resolved_path = ?",e)}countByFile(e){return this.get("SELECT COUNT(*) as count FROM imports WHERE file_path = ?",e)?.count||0}countDependents(e){return this.get("SELECT COUNT(*) as count FROM imports WHERE resolved_path = ?",e)?.count||0}getImportsForFile(e){return this.all("SELECT module_specifier, imported_symbols, resolved_path FROM imports WHERE file_path = ?",e)}findImportSource(e,r){return this.get(`
289
280
  SELECT *
290
281
  FROM imports
291
282
  WHERE file_path = ?
292
283
  AND (imported_symbols LIKE ? OR imported_symbols = '*')
293
284
  LIMIT 1
294
- `,e,`%${t}%`)}findProxies(e){return this.all(`
285
+ `,e,`%${r}%`)}findProxies(e){return this.all(`
295
286
  SELECT i.file_path
296
287
  FROM imports i
297
288
  JOIN exports e ON i.file_path = e.file_path
298
289
  WHERE i.resolved_path = ?
299
290
  AND (e.kind = 'ExportAllDeclaration' OR e.kind = 'ExportMapping')
300
- `,e)}findVerifiedDependents(e,t){if(e.length===0)return[];let n=e.map(()=>"?").join(", ");return this.all(`
291
+ `,e)}findVerifiedDependents(e,r){if(e.length===0)return[];let i=e.map(()=>"?").join(", ");return this.all(`
301
292
  SELECT i.file_path, i.imported_symbols, f.classification, f.summary
302
293
  FROM imports i
303
294
  JOIN files f ON i.file_path = f.path
304
- WHERE i.resolved_path IN (${n})
295
+ WHERE i.resolved_path IN (${i})
305
296
  AND (i.imported_symbols LIKE ? OR i.imported_symbols = '' OR i.imported_symbols = '*')
306
297
  LIMIT 10
307
- `,...e,`%${t}%`)}countVerifiedDependents(e,t){if(e.length===0)return 0;let n=e.map(()=>"?").join(", ");return this.get(`
298
+ `,...e,`%${r}%`)}countVerifiedDependents(e,r){if(e.length===0)return 0;let i=e.map(()=>"?").join(", ");return this.get(`
308
299
  SELECT COUNT(*) as count FROM imports
309
- WHERE resolved_path IN (${n})
300
+ WHERE resolved_path IN (${i})
310
301
  AND (imported_symbols LIKE ? OR imported_symbols = '' OR imported_symbols = '*')
311
- `,...e,`%${t}%`)?.count||0}findImpactDependents(e,t,n){return this.all(Qs,e,t,n,t)}getCount(){return this.get("SELECT COUNT(*) as count FROM imports")?.count||0}}});var Xt,Zs=Q(()=>{"use strict";Ee();Xt=class extends X{findById(e){return this.get("SELECT * FROM missions WHERE id = ?",e)}findByIds(e){if(e.length===0)return[];let t=e.map(()=>"?").join(", ");return this.all(`SELECT * FROM missions WHERE id IN (${t})`,...e)}findActive(e){let t="SELECT * FROM missions WHERE status IN ('in-progress', 'planned', 'verifying')",n=[];return e&&(t+=" AND git_branch = ?",n.push(e)),t+=` ORDER BY
302
+ `,...e,`%${r}%`)?.count||0}findImpactDependents(e,r,i){return this.all(Wf,e,r,i,r)}getCount(){return this.get("SELECT COUNT(*) as count FROM imports")?.count||0}}});var Gr,lc=ge(()=>{"use strict";ht();Gr=class extends Se{findById(e){return this.get("SELECT * FROM missions WHERE id = ?",e)}findByIds(e){if(e.length===0)return[];let r=e.map(()=>"?").join(", ");return this.all(`SELECT * FROM missions WHERE id IN (${r})`,...e)}findActive(e){let r="SELECT * FROM missions WHERE status IN ('in-progress', 'planned', 'verifying')",i=[];return e&&(r+=" AND git_branch = ?",i.push(e)),r+=` ORDER BY
312
303
  CASE WHEN status = 'in-progress' THEN 0 WHEN status = 'verifying' THEN 1 ELSE 2 END,
313
- created_at ASC`,this.all(t,...n)}findAll(e){let t="SELECT * FROM missions",n=[];return e&&(t+=" WHERE status = ?",n.push(e)),t+=` ORDER BY
304
+ created_at ASC`,this.all(r,...i)}findAll(e){let r="SELECT * FROM missions",i=[];return e&&(r+=" WHERE status = ?",i.push(e)),r+=` ORDER BY
314
305
  CASE WHEN status = 'in-progress' THEN 0 WHEN status = 'verifying' THEN 1 ELSE 2 END,
315
- created_at ASC`,this.all(t,...n)}findRecentCompleted(e=3){return this.all(`
306
+ created_at ASC`,this.all(r,...i)}findRecentCompleted(e=3){return this.all(`
316
307
  SELECT * FROM missions
317
308
  WHERE status = 'completed'
318
309
  ORDER BY updated_at DESC, id DESC
@@ -320,7 +311,7 @@ ORDER BY dc.depth, dc.consumer_path;
320
311
  `,e)}create(e){return this.insert(`
321
312
  INSERT INTO missions (name, goal, strategy_graph, status, git_branch, commit_sha, parent_id, verification_context, outcome_contract)
322
313
  VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
323
- `,e.name,e.goal,e.strategy_graph,e.status,e.git_branch,e.commit_sha,e.parent_id,e.verification_context,e.outcome_contract)}addArtifact(e,t,n,s){this.run("INSERT INTO mission_artifacts (mission_id, type, identifier, metadata) VALUES (?, ?, ?, ?)",e,t,n,s?JSON.stringify(s):null)}getArtifacts(e){return this.all("SELECT * FROM mission_artifacts WHERE mission_id = ?",e)}update(e,t){let n=Object.keys(t);if(n.length===0)return;let s=n.map(o=>`${o} = ?`).join(", "),r=Object.values(t);r.push(e),this.run(`UPDATE missions SET ${s}, updated_at = unixepoch() WHERE id = ?`,...r)}updateStatus(e,t,n){n?this.run("UPDATE missions SET status = ?, updated_at = unixepoch(), commit_sha = ? WHERE id = ?",t,n,e):this.run("UPDATE missions SET status = ?, updated_at = unixepoch() WHERE id = ?",t,e)}getWorkingSet(e){return this.all("SELECT file_path, type FROM working_set WHERE mission_id = ?",e)}clearWorkingSet(e){this.run("DELETE FROM working_set WHERE mission_id = ?",e)}addToWorkingSet(e,t,n="file"){this.run("INSERT OR IGNORE INTO files (path, mtime, last_scanned_at) VALUES (?, unixepoch(), unixepoch())",t),this.run("INSERT INTO working_set (mission_id, file_path, type) VALUES (?, ?, ?)",e,t,n)}findColdMissions(e,t=10){return this.all(`
314
+ `,e.name,e.goal,e.strategy_graph,e.status,e.git_branch,e.commit_sha,e.parent_id,e.verification_context,e.outcome_contract)}addArtifact(e,r,i,t){this.run("INSERT INTO mission_artifacts (mission_id, type, identifier, metadata) VALUES (?, ?, ?, ?)",e,r,i,t?JSON.stringify(t):null)}getArtifacts(e){return this.all("SELECT * FROM mission_artifacts WHERE mission_id = ?",e)}update(e,r){let i=Object.keys(r);if(i.length===0)return;let t=i.map(s=>`${s} = ?`).join(", "),o=Object.values(r);o.push(e),this.run(`UPDATE missions SET ${t}, updated_at = unixepoch() WHERE id = ?`,...o)}updateStatus(e,r,i){i?this.run("UPDATE missions SET status = ?, updated_at = unixepoch(), commit_sha = ? WHERE id = ?",r,i,e):this.run("UPDATE missions SET status = ?, updated_at = unixepoch() WHERE id = ?",r,e)}getWorkingSet(e){return this.all("SELECT file_path, type FROM working_set WHERE mission_id = ?",e)}clearWorkingSet(e){this.run("DELETE FROM working_set WHERE mission_id = ?",e)}addToWorkingSet(e,r,i="file"){this.run("INSERT OR IGNORE INTO files (path, mtime, last_scanned_at) VALUES (?, unixepoch(), unixepoch())",r),this.run("INSERT INTO working_set (mission_id, file_path, type) VALUES (?, ?, ?)",e,r,i)}findColdMissions(e,r=10){return this.all(`
324
315
  SELECT m.id, COUNT(il.id) as log_count
325
316
  FROM missions m
326
317
  LEFT JOIN intent_logs il ON il.mission_id = m.id
@@ -328,23 +319,23 @@ ORDER BY dc.depth, dc.consumer_path;
328
319
  AND m.status != 'distilled'
329
320
  GROUP BY m.id
330
321
  HAVING log_count > ?
331
- `,e,t).map(s=>s.id)}getStats(){let e=this.get(`
322
+ `,e,r).map(t=>t.id)}getStats(){let e=this.get(`
332
323
  SELECT
333
324
  COUNT(*) as total,
334
325
  SUM(CASE WHEN status='completed' THEN 1 ELSE 0 END) as completed,
335
326
  SUM(CASE WHEN status IN ('in-progress', 'planned', 'verifying') THEN 1 ELSE 0 END) as active
336
327
  FROM missions
337
- `);return{total:e?.total||0,completed:e?.completed||0,active:e?.active||0}}getAnalytics(){let e=this.getStats(),t=e.total>0?Math.round(e.completed/e.total*100):0,n=this.get(`
328
+ `);return{total:e?.total||0,completed:e?.completed||0,active:e?.active||0}}getAnalytics(){let e=this.getStats(),r=e.total>0?Math.round(e.completed/e.total*100):0,i=this.get(`
338
329
  SELECT AVG(updated_at - created_at) AS avg_duration
339
330
  FROM missions
340
331
  WHERE status = 'completed' AND updated_at > created_at
341
- `),s=n?.avg_duration!=null?Math.round(n.avg_duration):null,r=Math.floor(Date.now()/1e3)-168*3600,o=Math.floor(Date.now()/1e3)-720*3600,c=this.get("SELECT COUNT(*) AS n FROM missions WHERE status = 'completed' AND updated_at >= ?",r),a=this.get("SELECT COUNT(*) AS n FROM missions WHERE status = 'completed' AND updated_at >= ?",o),l=c?.n??0,p=a?.n??0,d=`${l} completed in last 7 days, ${p} in last 30 days.`;if(s!=null){let u=Math.round(s/60);d+=` Avg mission duration: ${u} min.`}return{completionRate:t,averageDurationSeconds:s,completedLast7Days:l,completedLast30Days:p,velocityNote:d}}suspendByBranch(e){this.run(`UPDATE missions
332
+ `),t=i?.avg_duration!=null?Math.round(i.avg_duration):null,o=Math.floor(Date.now()/1e3)-168*3600,s=Math.floor(Date.now()/1e3)-720*3600,a=this.get("SELECT COUNT(*) AS n FROM missions WHERE status = 'completed' AND updated_at >= ?",o),c=this.get("SELECT COUNT(*) AS n FROM missions WHERE status = 'completed' AND updated_at >= ?",s),l=a?.n??0,u=c?.n??0,d=`${l} completed in last 7 days, ${u} in last 30 days.`;if(t!=null){let p=Math.round(t/60);d+=` Avg mission duration: ${p} min.`}return{completionRate:r,averageDurationSeconds:t,completedLast7Days:l,completedLast30Days:u,velocityNote:d}}suspendByBranch(e){this.run(`UPDATE missions
342
333
  SET status = 'suspended', updated_at = unixepoch()
343
334
  WHERE git_branch = ? AND status IN ('in-progress', 'planned', 'verifying')`,e)}resumeByBranch(e){this.run(`UPDATE missions
344
335
  SET status = 'in-progress', updated_at = unixepoch()
345
- WHERE git_branch = ? AND status = 'suspended'`,e)}findMergedMissions(e,t){if(t.length===0)return[];let n=t.filter(r=>r!==e);if(n.length===0)return[];let s=n.map(()=>"?").join(",");return this.all(`SELECT * FROM missions
336
+ WHERE git_branch = ? AND status = 'suspended'`,e)}findMergedMissions(e,r){if(r.length===0)return[];let i=r.filter(o=>o!==e);if(i.length===0)return[];let t=i.map(()=>"?").join(",");return this.all(`SELECT * FROM missions
346
337
  WHERE status IN ('in-progress', 'planned', 'verifying', 'suspended')
347
- AND git_branch IN (${s})`,...n)}findByCommitShas(e){if(e.length===0)return[];let t=e.map(()=>"?").join(",");return this.all(`SELECT * FROM missions WHERE commit_sha IN (${t})`,...e)}findByParentId(e){return this.all("SELECT * FROM missions WHERE parent_id = ?",e)}hasChildren(e){return!!this.get("SELECT 1 FROM missions WHERE parent_id = ? LIMIT 1",e)}hasNoSteps(e){if(!e.strategy_graph)return!0;try{let t=JSON.parse(e.strategy_graph),n=t?.steps??t;return!Array.isArray(n)||n.length===0}catch{return!0}}findParentOnlyIds(e){return e.filter(t=>t.parent_id!=null||!this.hasChildren(t.id)?!1:this.hasNoSteps(t)).map(t=>t.id)}createLink(e,t,n,s,r){this.db.exec(`
338
+ AND git_branch IN (${t})`,...i)}findByCommitShas(e){if(e.length===0)return[];let r=e.map(()=>"?").join(",");return this.all(`SELECT * FROM missions WHERE commit_sha IN (${r})`,...e)}findByParentId(e){return this.all("SELECT * FROM missions WHERE parent_id = ?",e)}hasChildren(e){return!!this.get("SELECT 1 FROM missions WHERE parent_id = ? LIMIT 1",e)}hasNoSteps(e){if(!e.strategy_graph)return!0;try{let r=JSON.parse(e.strategy_graph),i=r?.steps??r;return!Array.isArray(i)||i.length===0}catch{return!0}}findParentOnlyIds(e){return e.filter(r=>r.parent_id!=null||!this.hasChildren(r.id)?!1:this.hasNoSteps(r)).map(r=>r.id)}createLink(e,r,i,t,o){this.db.exec(`
348
339
  CREATE TABLE IF NOT EXISTS cross_repo_links (
349
340
  id INTEGER PRIMARY KEY AUTOINCREMENT,
350
341
  mission_id INTEGER NOT NULL,
@@ -359,24 +350,32 @@ ORDER BY dc.depth, dc.consumer_path;
359
350
  `),this.run(`
360
351
  INSERT INTO cross_repo_links (mission_id, linked_repo_path, linked_mission_id, relationship, direction)
361
352
  VALUES (?, ?, ?, ?, ?)
362
- `,e,t,n,s,r)}getLinks(e){try{return this.all(`
353
+ `,e,r,i,t,o)}getLinks(e){try{return this.all(`
363
354
  SELECT linked_repo_path, linked_mission_id, relationship, direction
364
355
  FROM cross_repo_links
365
356
  WHERE mission_id = ?
366
- `,e)}catch{return[]}}findLastMission(){return this.get("SELECT * FROM missions ORDER BY updated_at DESC, id DESC LIMIT 1")}findActiveByPriority(){return this.get("SELECT * FROM missions WHERE status IN ('in-progress', 'active', 'verifying') ORDER BY CASE WHEN status = 'in-progress' THEN 0 ELSE 1 END, created_at ASC LIMIT 1")}}});var Zt,ei=Q(()=>{"use strict";Ee();Zt=class extends X{findByMission(e,t=50){return this.all(`
367
- SELECT * FROM intent_logs
357
+ `,e)}catch{return[]}}findLastMission(){return this.get("SELECT * FROM missions ORDER BY updated_at DESC, id DESC LIMIT 1")}findActiveByPriority(){return this.get("SELECT * FROM missions WHERE status IN ('in-progress', 'active', 'verifying') ORDER BY CASE WHEN status = 'in-progress' THEN 0 ELSE 1 END, created_at ASC LIMIT 1")}}});import{fileURLToPath as lx}from"node:url";import{dirname as uc,join as qf,resolve as ux}from"node:path";import{existsSync as dx}from"node:fs";function mx(){let n=Jf;for(;n!==uc(n);){if(dx(qf(n,"package.json")))return n;n=uc(n)}return ux(Jf,"..","..")}function Hn(...n){return qf(mx(),...n)}var px,Jf,Qi=ge(()=>{"use strict";px=lx(import.meta.url),Jf=uc(px)});import{Worker as fx}from"node:worker_threads";import{cpus as hx}from"node:os";import{fileURLToPath as gx}from"node:url";import{dirname as yx,join as Vf}from"node:path";import{existsSync as Kf}from"node:fs";function vx(){if(Xf.endsWith(".ts")){let e=Vf(Yf,"worker.ts");if(Kf(e))return e}let n=Vf(Yf,"worker.js");return Kf(n)?n:Hn("dist/logic/domain/embeddings/worker.js")}function vn(n){return Wn||(Wn=new Bn(n)),Wn}async function bn(){Wn&&(await Wn.shutdown(),Wn=null)}var Xf,Yf,Bn,Wn,Qf=ge(()=>{"use strict";G();Qi();Xf=gx(import.meta.url),Yf=yx(Xf);Bn=class{workers=[];taskQueue=[];pendingTasks=new Map;taskIdCounter=0;initialized=!1;initPromise;shutdownRequested=!1;numWorkers;cacheDir;initTimeout;constructor(e={}){this.numWorkers=e.numWorkers??Math.max(1,Math.min(4,hx().length-1)),this.cacheDir=e.cacheDir??"./.cache",this.initTimeout=e.initTimeout??6e4}async initialize(){if(!this.initialized)return this.initPromise?this.initPromise:(this.initPromise=this._doInitialize(),this.initPromise)}async _doInitialize(){let e;try{x.info({numWorkers:this.numWorkers},"Initializing embedding worker pool");let r=new Promise((i,t)=>{e=setTimeout(()=>t(new Error(`Worker pool initialization timed out after ${this.initTimeout}ms`)),this.initTimeout)});if(await Promise.race([this._initializeWorkers(),r]),e&&clearTimeout(e),this.shutdownRequested){this.initialized=!1,this.initPromise=void 0,x.debug("Initialization completed but shutdown was requested");return}this.initialized=!0,x.info({numWorkers:this.workers.length},"Embedding worker pool ready")}catch(r){throw e&&clearTimeout(e),this.initPromise=void 0,this.initialized=!1,await this.shutdown(),r}}async _initializeWorkers(){let e=vx();x.debug({workerPath:e},"Resolved worker path");let r=[];for(let i=0;i<this.numWorkers;i++)i>0&&await new Promise(t=>setTimeout(t,25)),r.push(this.createWorker(e,i));await Promise.all(r)}async createWorker(e,r){return new Promise((i,t)=>{let o=setTimeout(()=>{t(new Error(`Worker ${r} initialization timed out`))},this.initTimeout),s=new fx(e,{workerData:{cacheDir:this.cacheDir},execArgv:process.execArgv}),a={worker:s,busy:!1,currentTaskId:null};s.on("message",c=>{if(c.type==="ready"){if(clearTimeout(o),this.shutdownRequested){x.debug({workerIndex:r},"Worker ready but shutdown requested, terminating"),s.terminate().catch(()=>{}),i();return}this.workers.push(a),x.debug({workerIndex:r},"Worker ready"),i()}else c.type==="result"&&c.id?this.handleTaskComplete(a,c.id,c.embeddings||[]):c.type==="error"&&c.id&&this.handleTaskError(a,c.id,new Error(c.error||"Unknown error"))}),s.on("error",c=>{if(clearTimeout(o),x.error({err:c,workerIndex:r},"Worker error"),a.currentTaskId&&this.handleTaskError(a,a.currentTaskId,c),!this.initialized){t(c);return}let l=this.workers.indexOf(a);l!==-1&&this.workers.splice(l,1),!this.shutdownRequested&&this.initialized&&this.createWorker(e,r).catch(u=>{x.error({err:u},"Failed to replace crashed worker")})}),s.on("exit",c=>{c!==0&&!this.shutdownRequested&&x.warn({workerIndex:r,code:c},"Worker exited unexpectedly")})})}handleTaskComplete(e,r,i){let t=this.pendingTasks.get(r);t&&(this.pendingTasks.delete(r),t.resolve(i)),e.busy=!1,e.currentTaskId=null,this.processQueue()}handleTaskError(e,r,i){let t=this.pendingTasks.get(r);t&&(this.pendingTasks.delete(r),t.reject(i)),e.busy=!1,e.currentTaskId=null,this.processQueue()}processQueue(){if(this.taskQueue.length===0)return;let e=this.workers.find(i=>!i.busy);if(!e)return;let r=this.taskQueue.shift();r&&(e.busy=!0,e.currentTaskId=r.id,this.pendingTasks.set(r.id,r),e.worker.postMessage({type:"embed",id:r.id,texts:r.texts}))}async generateEmbeddings(e,r=128,i){if(this.initialized||await this.initialize(),e.length===0)return[];let t=[];for(let l=0;l<e.length;l+=r)t.push(e.slice(l,l+r));let o=new Array(t.length),s=0,a=t.map((l,u)=>new Promise((d,p)=>{let f={id:`task_${++this.taskIdCounter}`,texts:l,resolve:h=>{if(o[u]=h,s++,i){let _=Math.min(s*r,e.length);i(_,e.length)}d()},reject:h=>{if(o[u]=new Array(l.length).fill(null),s++,x.warn({err:h,chunkIndex:u},"Chunk embedding failed"),i){let _=Math.min(s*r,e.length);i(_,e.length)}d()}};this.taskQueue.push(f),this.processQueue()}));await Promise.all(a);let c=[];for(let l of o)c.push(...l);return x.info({total:e.length,successful:c.filter(l=>l!==null).length,workers:this.workers.length},"Parallel embedding generation complete"),c}get workerCount(){return this.workers.length}get busyWorkers(){return this.workers.filter(e=>e.busy).length}get queueSize(){return this.taskQueue.length}get isInitialized(){return this.initialized}async shutdown(){if(this.shutdownRequested=!0,this.initPromise)try{await this.initPromise}catch{}if(!this.initialized&&this.workers.length===0){this.shutdownRequested=!1,this.initPromise=void 0;return}x.info({numWorkers:this.workers.length},"Shutting down embedding worker pool");let e=this.workers.map(r=>new Promise(i=>{r.worker.postMessage({type:"shutdown"}),r.worker.once("exit",()=>i()),setTimeout(()=>{r.worker.terminate().then(()=>i())},5e3)}));await Promise.all(e),this.workers=[],this.taskQueue=[],this.pendingTasks.clear(),this.initialized=!1,this.shutdownRequested=!1,x.info("Embedding worker pool shutdown complete")}},Wn=null});var Vr={};Ke(Vr,{EmbeddingPriorityQueue:()=>eo,EmbeddingWorkerPool:()=>Bn,cosineSimilarity:()=>ro,generateEmbedding:()=>to,generateEmbeddingsBatch:()=>no,getDefaultPool:()=>vn,setUseWorkerThreads:()=>qr,shutdownDefaultPool:()=>bn});async function bx(){return Jr||(Jr=await import("@xenova/transformers"),Jr.env.cacheDir="./.cache",Jr.env.allowLocalModels=!0),Jr}function qr(n){pc=n,x.info({useWorkerThreads:n},"Worker thread mode updated")}async function th(){return dc||(dc=(async()=>{x.info("Loading embedding model (all-MiniLM-L6-v2)...");let{pipeline:n}=await bx();return await n("feature-extraction","Xenova/all-MiniLM-L6-v2")})()),dc}async function to(n){try{let r=await(await th())(n,{pooling:"mean",normalize:!0});return Array.from(r.data)}catch(e){return x.error({err:e},"Failed to generate embedding"),null}}async function no(n,e=eh,r){return n.length===0?[]:pc?vn().generateEmbeddings(n,e,r):nh(n,e,r)}async function nh(n,e,r){let i=new Array(n.length).fill(null),t=await th();for(let o=0;o<n.length;o+=e){let s=Math.min(o+e,n.length),a=n.slice(o,s);try{let c=await t(a,{pooling:"mean",normalize:!0}),[l,u]=c.dims;for(let d=0;d<l;d++){let p=d*u,m=p+u;i[o+d]=Array.from(c.data.slice(p,m))}}catch(c){x.error({err:c,batchStart:o,batchEnd:s},"Single-threaded batch embedding failed, falling back to sequential for this chunk");for(let l=0;l<a.length;l++)try{let u=a[l];if(!u||u.trim().length===0)continue;let d=await t(u,{pooling:"mean",normalize:!0});i[o+l]=Array.from(d.data)}catch{i[o+l]=null}}r&&r(s,n.length)}return x.debug({total:n.length,successful:i.filter(o=>o!==null).length},"Batch embedding complete"),i}function ro(n,e){let r=0,i=0,t=0;for(let o=0;o<n.length;o++)r+=n[o]*e[o],i+=n[o]*n[o],t+=e[o]*e[o];return r/(Math.sqrt(i)*Math.sqrt(t))}var Jr,eh,pc,dc,eo,Nt=ge(()=>{"use strict";G();Qf();Jr=null;eh=128,pc=!1;dc=null;eo=class{queue=[];processing=!1;results=new Map;enqueue(e){this.queue.push(e),this.queue.sort((r,i)=>i.priority-r.priority)}enqueueMany(e){this.queue.push(...e),this.queue.sort((r,i)=>i.priority-r.priority)}get size(){return this.queue.length}get isProcessing(){return this.processing}getResult(e){return this.results.get(e)}async processQueue(e=eh,r){if(this.processing)return x.warn("Queue processing already in progress"),this.results;this.processing=!0;let i=this.queue.length;try{pc?await this.processQueueParallel(e,i,r):await this.processQueueSequential(e,i,r)}finally{this.processing=!1}return this.results}async processQueueSequential(e,r,i){for(;this.queue.length>0;){let t=this.queue.splice(0,e),o=t.map(a=>a.text),s=await nh(o,o.length);if(t.forEach((a,c)=>{this.results.set(a.id,s[c])}),i){let a=r-this.queue.length;i(a,r)}}}async processQueueParallel(e,r,i){let t=this.queue.splice(0),o=t.map(c=>c.text),a=await vn().generateEmbeddings(o,e,(c,l)=>{i&&i(c,l)});t.forEach((c,l)=>{this.results.set(c.id,a[l])})}clear(){this.queue=[],this.results.clear()}}});var io,rh=ge(()=>{"use strict";ht();G();io=class n extends Se{findByMission(e,r=50){return this.all(`
358
+ SELECT
359
+ id, mission_id, symbol_id, file_path, type, content, confidence,
360
+ symbol_name, signature, commit_sha, is_crystallized, crystal_id,
361
+ created_at
362
+ FROM intent_logs
368
363
  WHERE mission_id = ?
369
364
  ORDER BY created_at DESC
370
365
  LIMIT ?
371
- `,e,t)}findRecentDecisionActivity(e=10){return this.all(`
372
- SELECT * FROM intent_logs
366
+ `,e,r)}findRecentDecisionActivity(e=10){return this.all(`
367
+ SELECT
368
+ id, mission_id, symbol_id, file_path, type, content, confidence,
369
+ symbol_name, signature, commit_sha, is_crystallized, crystal_id,
370
+ created_at
371
+ FROM intent_logs
373
372
  WHERE type IN ('decision', 'system', 'fix', 'heritage', 'adr')
374
373
  ORDER BY created_at DESC
375
374
  LIMIT ?
376
- `,e)}create(e){return this.insert(`
375
+ `,e)}create(e){let r=this.insert(`
377
376
  INSERT INTO intent_logs (mission_id, symbol_id, file_path, type, content, confidence, symbol_name, signature, commit_sha)
378
377
  VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
379
- `,e.mission_id,e.symbol_id,e.file_path,e.type,e.content,e.confidence,e.symbol_name,e.signature,e.commit_sha)}delete(e){this.run("DELETE FROM intent_logs WHERE id = ?",e)}update(e,t){let n=Object.keys(t);if(n.length===0)return;let s=n.map(o=>`${o} = ?`).join(", "),r=Object.values(t);r.push(e),this.run(`UPDATE intent_logs SET ${s} WHERE id = ?`,...r)}findRepairableOrphans(){return this.all(`
378
+ `,e.mission_id,e.symbol_id,e.file_path,e.type,e.content,e.confidence,e.symbol_name,e.signature,e.commit_sha);return n.EMBEDDABLE_TYPES.has(e.type)&&this.generateAndStoreEmbedding(Number(r),e).catch(i=>{x.debug({err:i,intentLogId:r},"Failed to generate intent log embedding")}),r}static EMBEDDABLE_TYPES=new Set(["decision","discovery","fix","blocker","heritage","crystal"]);static buildEmbeddingText(e){let r=[`[${e.type}]`];return e.symbol_name&&r.push(`symbol: ${e.symbol_name}`),e.file_path&&r.push(`file: ${e.file_path.split("/").pop()}`),r.push(e.content),r.join(" ")}async generateAndStoreEmbedding(e,r){let{generateEmbedding:i}=await Promise.resolve().then(()=>(Nt(),Vr)),t=n.buildEmbeddingText(r),o=await i(t);o&&this.run("UPDATE intent_logs SET embedding = ? WHERE id = ?",JSON.stringify(o),e)}findWithEmbeddings(){return this.all("SELECT * FROM intent_logs WHERE embedding IS NOT NULL AND type NOT IN ('system', 'lapsed')")}async findSemanticMatches(e,r,i){let{cosineSimilarity:t}=await Promise.resolve().then(()=>(Nt(),Vr)),o=this.findWithEmbeddings();if(o.length>5e3)return x.warn({count:o.length},"Intent log count exceeds brute-force vector scan limit (5000). Skipping semantic recall."),[];let s=[];for(let a of o)if(!(i&&a.symbol_id===i))try{let c=JSON.parse(a.embedding),l=t(e,c);l>.25&&s.push({id:a.id,mission_id:a.mission_id,type:a.type,content:a.content,symbol_name:a.symbol_name,file_path:a.file_path,similarity:l,created_at:a.created_at})}catch{}return s.sort((a,c)=>c.similarity-a.similarity).slice(0,r)}delete(e){this.run("DELETE FROM intent_logs WHERE id = ?",e)}update(e,r){let i=Object.keys(r);if(i.length===0)return;let t=i.map(s=>`${s} = ?`).join(", "),o=Object.values(r);o.push(e),this.run(`UPDATE intent_logs SET ${t} WHERE id = ?`,...o)}findRepairableOrphans(){return this.all(`
380
379
  SELECT id, file_path, symbol_name, signature
381
380
  FROM intent_logs
382
381
  WHERE symbol_id IS NULL AND symbol_name IS NOT NULL
@@ -398,34 +397,72 @@ ORDER BY dc.depth, dc.consumer_path;
398
397
  type = 'lapsed',
399
398
  content = 'Lapsed: ' || content
400
399
  WHERE id = ?
401
- `,e)}importHeritage(e,t,n,s){this.run(`
400
+ `,e)}importHeritage(e,r,i,t){this.run(`
402
401
  INSERT INTO intent_logs (type, content, commit_sha, created_at, confidence, mission_id)
403
402
  VALUES ('heritage', ?, ?, ?, ?, 0)
404
- `,e,t,n,s)}countByType(e){return this.get("SELECT COUNT(*) as count FROM intent_logs WHERE type = ?",e)?.count||0}}});var en,ti=Q(()=>{"use strict";Ee();en=class extends X{findByKey(e,t=20){return this.all(`
403
+ `,e,r,i,t)}countByType(e){return this.get("SELECT COUNT(*) as count FROM intent_logs WHERE type = ?",e)?.count||0}findRawByMission(e){return this.all(`SELECT
404
+ id, mission_id, symbol_id, file_path, type, content, confidence,
405
+ symbol_name, signature, commit_sha, is_crystallized, crystal_id,
406
+ created_at
407
+ FROM intent_logs
408
+ WHERE mission_id = ? AND is_crystallized = 0
409
+ AND type NOT IN ('adr', 'system', 'crystal', 'lapsed')
410
+ ORDER BY created_at ASC`,e)}findCrystalByMission(e){return this.get(`SELECT
411
+ id, mission_id, symbol_id, file_path, type, content, confidence,
412
+ symbol_name, signature, commit_sha, is_crystallized, crystal_id,
413
+ created_at
414
+ FROM intent_logs
415
+ WHERE mission_id = ? AND type = 'crystal'
416
+ ORDER BY created_at DESC LIMIT 1`,e)}crystallize(e,r){return this.transaction(()=>{let i=this.insert(`INSERT INTO intent_logs (mission_id, type, content, confidence, is_crystallized, symbol_id, file_path, symbol_name, signature, commit_sha)
417
+ VALUES (?, 'crystal', ?, 1.0, 0, NULL, NULL, NULL, NULL, NULL)`,e,r);return this.run(`UPDATE intent_logs
418
+ SET is_crystallized = 1, crystal_id = ?
419
+ WHERE mission_id = ? AND is_crystallized = 0 AND id != ?
420
+ AND type NOT IN ('adr', 'system', 'crystal', 'lapsed')`,i,e,i),i})}findRawBySymbol(e){return this.all(`SELECT * FROM intent_logs
421
+ WHERE symbol_id = ? AND mission_id IS NULL AND is_crystallized = 0
422
+ AND type NOT IN ('adr', 'system', 'crystal', 'lapsed')
423
+ ORDER BY created_at ASC`,e)}crystallizeBySymbol(e,r){return this.transaction(()=>{let i=this.insert(`INSERT INTO intent_logs (mission_id, symbol_id, type, content, confidence, is_crystallized, file_path, symbol_name, signature, commit_sha)
424
+ VALUES (NULL, ?, 'crystal', ?, 1.0, 0, NULL, NULL, NULL, NULL)`,e,r);return this.run(`UPDATE intent_logs
425
+ SET is_crystallized = 1, crystal_id = ?
426
+ WHERE symbol_id = ? AND mission_id IS NULL AND is_crystallized = 0 AND id != ?
427
+ AND type NOT IN ('adr', 'system', 'crystal', 'lapsed')`,i,e,i),i})}countByMissions(e){if(e.length===0)return{};let r=e.map(()=>"?").join(","),i=this.all(`SELECT mission_id, COUNT(*) as cnt
428
+ FROM intent_logs
429
+ WHERE mission_id IN (${r})
430
+ AND type NOT IN ('system', 'adr', 'lapsed')
431
+ GROUP BY mission_id`,...e),t={};for(let o of i)t[o.mission_id]=o.cnt;return t}findMissionsWithBlockers(e){if(e.length===0)return new Set;let r=e.map(()=>"?").join(","),i=this.all(`SELECT DISTINCT mission_id
432
+ FROM intent_logs
433
+ WHERE mission_id IN (${r})
434
+ AND type = 'blocker'`,...e);return new Set(i.map(t=>t.mission_id))}findByMissionPreferCrystal(e,r=50){let i=this.findCrystalByMission(e);if(i){let t=this.all(`SELECT
435
+ id, mission_id, symbol_id, file_path, type, content, confidence,
436
+ symbol_name, signature, commit_sha, is_crystallized, crystal_id,
437
+ created_at
438
+ FROM intent_logs
439
+ WHERE mission_id = ? AND is_crystallized = 0 AND type NOT IN ('adr', 'system', 'crystal', 'lapsed')
440
+ AND created_at > ?
441
+ ORDER BY created_at DESC LIMIT ?`,e,i.created_at,r-1);return[i,...t]}return this.findByMission(e,r)}async backfillEmbeddings(e=64,r){let{generateEmbeddingsBatch:i}=await Promise.resolve().then(()=>(Nt(),Vr)),t=[...n.EMBEDDABLE_TYPES].map(u=>`'${u}'`).join(","),o=this.all(`SELECT * FROM intent_logs WHERE embedding IS NULL AND type IN (${t})`);if(o.length===0)return 0;let s=o.map(u=>n.buildEmbeddingText(u)),a=await i(s,e,r),c=this.db.prepare("UPDATE intent_logs SET embedding = ? WHERE id = ?"),l=0;return this.transaction(()=>{for(let u=0;u<o.length;u++)a[u]&&(c.run(JSON.stringify(a[u]),o[u].id),l++)}),x.info({total:o.length,embedded:l},"Intent log embedding backfill complete"),l}}});var oo,ih=ge(()=>{"use strict";ht();oo=class extends Se{findByKey(e,r=20){return this.all(`
405
442
  SELECT file_path, key, value, kind
406
443
  FROM configs
407
444
  WHERE key LIKE ? OR value LIKE ?
408
445
  LIMIT ?
409
- `,`%${e}%`,`%${e}%`,t)}findByKind(e,t=50){let n="SELECT key, value, kind, file_path FROM configs",s=[];return e&&(n+=" WHERE kind = ?",s.push(e)),n+=" LIMIT ?",s.push(t),this.all(n,...s)}findEnvValue(e){return this.get("SELECT value FROM configs WHERE key LIKE ? OR key = ? LIMIT 1",`%:env:${e}`,e)?.value}countByKind(e){return this.get("SELECT COUNT(*) as count FROM configs WHERE kind = ?",e)?.count||0}getAll(){return this.all("SELECT key, value, kind, file_path FROM configs")}}});var tn,ni=Q(()=>{"use strict";Ee();tn=class extends X{search(e,t=10){return this.all(`
446
+ `,`%${e}%`,`%${e}%`,r)}findByKind(e,r=50){let i="SELECT key, value, kind, file_path FROM configs",t=[];return e&&(i+=" WHERE kind = ?",t.push(e)),i+=" LIMIT ?",t.push(r),this.all(i,...t)}findEnvValue(e){return this.get("SELECT value FROM configs WHERE key LIKE ? OR key = ? LIMIT 1",`%:env:${e}`,e)?.value}countByKind(e){return this.get("SELECT COUNT(*) as count FROM configs WHERE kind = ?",e)?.count||0}getAll(){return this.all("SELECT key, value, kind, file_path FROM configs")}}});var so,oh=ge(()=>{"use strict";ht();so=class extends Se{search(e,r=10){return this.all(`
410
447
  SELECT file_path, snippet(content_fts, 1, '<b>', '</b>', '...', 20) as snippet
411
448
  FROM content_fts
412
449
  WHERE content_fts MATCH ?
413
450
  LIMIT ?
414
- `,e,t)}}});var si,nn,ii=Q(()=>{"use strict";Ee();si=500,nn=class extends X{record(e,t,n=null){this.run("INSERT INTO search_history (query, mode, branch) VALUES (?, ?, ?)",e,t,n),this.pruneIfNeeded()}findRecent(e=20){return this.all("SELECT id, query, mode, branch, created_at FROM search_history ORDER BY created_at DESC LIMIT ?",e)}findRecentByQueryPrefix(e,t=10){return e.trim()?this.all(`SELECT id, query, mode, branch, created_at FROM search_history
415
- WHERE query LIKE ? ORDER BY created_at DESC LIMIT ?`,`${e}%`,t):this.findRecent(t)}pruneIfNeeded(){(this.get("SELECT COUNT(*) as count FROM search_history")?.count??0)<=si||this.run(`DELETE FROM search_history WHERE id NOT IN (
451
+ `,e,r)}}});var sh,ao,ah=ge(()=>{"use strict";ht();sh=500,ao=class extends Se{record(e,r,i=null){this.run("INSERT INTO search_history (query, mode, branch) VALUES (?, ?, ?)",e,r,i),this.pruneIfNeeded()}findRecent(e=20){return this.all("SELECT id, query, mode, branch, created_at FROM search_history ORDER BY created_at DESC LIMIT ?",e)}findRecentByQueryPrefix(e,r=10){return e.trim()?this.all(`SELECT id, query, mode, branch, created_at FROM search_history
452
+ WHERE query LIKE ? ORDER BY created_at DESC LIMIT ?`,`${e}%`,r):this.findRecent(r)}pruneIfNeeded(){(this.get("SELECT COUNT(*) as count FROM search_history")?.count??0)<=sh||this.run(`DELETE FROM search_history WHERE id NOT IN (
416
453
  SELECT id FROM search_history ORDER BY created_at DESC LIMIT ?
417
- )`,si)}}});var sn,ri=Q(()=>{"use strict";Ee();sn=class extends X{getSection(e){return this.get("SELECT section, data, updated_at FROM hologram_snapshot WHERE section = ?",e)}getAllSections(){return this.all("SELECT section, data, updated_at FROM hologram_snapshot ORDER BY section")}upsertSection(e,t){this.run(`
454
+ )`,sh)}}});var co,ch=ge(()=>{"use strict";ht();co=class extends Se{getSection(e){return this.get("SELECT section, data, updated_at FROM hologram_snapshot WHERE section = ?",e)}getAllSections(){return this.all("SELECT section, data, updated_at FROM hologram_snapshot ORDER BY section")}upsertSection(e,r){this.run(`
418
455
  INSERT INTO hologram_snapshot (section, data, updated_at)
419
456
  VALUES (?, ?, unixepoch())
420
457
  ON CONFLICT(section) DO UPDATE SET
421
458
  data = excluded.data,
422
459
  updated_at = excluded.updated_at
423
- `,e,t)}deleteSection(e){this.run("DELETE FROM hologram_snapshot WHERE section = ?",e)}deleteAll(){this.run("DELETE FROM hologram_snapshot")}hasSection(e){return(this.get("SELECT COUNT(*) as count FROM hologram_snapshot WHERE section = ?",e)?.count??0)>0}}});var C,U=Q(()=>{"use strict";Qe();Ys();Vs();Xs();Zs();ei();ti();ni();ii();ri();C=class{static repositoryCache=new Map;static getInstance(e){let t=this.repositoryCache.get(e);if(t){let r=ke(e),o=t.files?.database,c=!t.intentLogs||!t.searchHistory||!t.missions||!t.hologram;if(o===r&&r.open&&!c)return t;this.repositoryCache.delete(e)}let n=ke(e),s={files:new Vt(n),exports:new Qt(n),imports:new Kt(n),missions:new Xt(n),intentLogs:new Zt(n),configs:new en(n),content:new tn(n),searchHistory:new nn(n),hologram:new sn(n)};return this.repositoryCache.set(e,s),s}static closeInstance(e){this.repositoryCache.delete(e),Yt(e)}static clearCache(e){this.repositoryCache.delete(e)}}});var ci=qo((yp,es)=>{var on=process||{},oi=on.argv||[],rn=on.env||{},ua=!(rn.NO_COLOR||oi.includes("--no-color"))&&(!!rn.FORCE_COLOR||oi.includes("--color")||on.platform==="win32"||(on.stdout||{}).isTTY&&rn.TERM!=="dumb"||!!rn.CI),da=(i,e,t=i)=>n=>{let s=""+n,r=s.indexOf(e,i.length);return~r?i+ma(s,e,t,r)+e:i+s+e},ma=(i,e,t,n)=>{let s="",r=0;do s+=i.substring(r,n)+t,r=n+e.length,n=i.indexOf(e,r);while(~n);return s+i.substring(r)},ai=(i=ua)=>{let e=i?da:()=>String;return{isColorSupported:i,reset:e("\x1B[0m","\x1B[0m"),bold:e("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:e("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:e("\x1B[3m","\x1B[23m"),underline:e("\x1B[4m","\x1B[24m"),inverse:e("\x1B[7m","\x1B[27m"),hidden:e("\x1B[8m","\x1B[28m"),strikethrough:e("\x1B[9m","\x1B[29m"),black:e("\x1B[30m","\x1B[39m"),red:e("\x1B[31m","\x1B[39m"),green:e("\x1B[32m","\x1B[39m"),yellow:e("\x1B[33m","\x1B[39m"),blue:e("\x1B[34m","\x1B[39m"),magenta:e("\x1B[35m","\x1B[39m"),cyan:e("\x1B[36m","\x1B[39m"),white:e("\x1B[37m","\x1B[39m"),gray:e("\x1B[90m","\x1B[39m"),bgBlack:e("\x1B[40m","\x1B[49m"),bgRed:e("\x1B[41m","\x1B[49m"),bgGreen:e("\x1B[42m","\x1B[49m"),bgYellow:e("\x1B[43m","\x1B[49m"),bgBlue:e("\x1B[44m","\x1B[49m"),bgMagenta:e("\x1B[45m","\x1B[49m"),bgCyan:e("\x1B[46m","\x1B[49m"),bgWhite:e("\x1B[47m","\x1B[49m"),blackBright:e("\x1B[90m","\x1B[39m"),redBright:e("\x1B[91m","\x1B[39m"),greenBright:e("\x1B[92m","\x1B[39m"),yellowBright:e("\x1B[93m","\x1B[39m"),blueBright:e("\x1B[94m","\x1B[39m"),magentaBright:e("\x1B[95m","\x1B[39m"),cyanBright:e("\x1B[96m","\x1B[39m"),whiteBright:e("\x1B[97m","\x1B[39m"),bgBlackBright:e("\x1B[100m","\x1B[49m"),bgRedBright:e("\x1B[101m","\x1B[49m"),bgGreenBright:e("\x1B[102m","\x1B[49m"),bgYellowBright:e("\x1B[103m","\x1B[49m"),bgBlueBright:e("\x1B[104m","\x1B[49m"),bgMagentaBright:e("\x1B[105m","\x1B[49m"),bgCyanBright:e("\x1B[106m","\x1B[49m"),bgWhiteBright:e("\x1B[107m","\x1B[49m")}};es.exports=ai();es.exports.createColors=ai});var mr,hr,fr,gr,yr,br,Er,Sr,_r,xr,Tr,Rr,vr,wr,Ts,Ir,Cr,$r,kr=Q(()=>{"use strict";mr=[/\/pages\/(?!_)[^/]+\.(tsx?|jsx?)$/i,/\/pages\/.*\/index\.(tsx?|jsx?)$/i,/\/app\/.*\/page\.(tsx?|jsx?)$/i,/\/app\/.*\/layout\.(tsx?|jsx?)$/i,/\/app\/api\/.*\/route\.(ts|js)$/i,/\/pages\/api\/.*\.(ts|js)$/i],hr=[/\.(routes?|router|controller|handler|endpoint|api)\.(ts|js|tsx|jsx)$/i,/\/routes?\//i,/\/controllers?\//i,/index\.(ts|js|tsx|jsx)$/i],fr=[/\/components?\/.*\.(tsx|jsx)$/i,/\/features?\/.*\.(tsx|jsx)$/i,/\/views?\/.*\.(tsx|jsx)$/i,/\/screens?\/.*\.(tsx|jsx)$/i,/\/widgets?\/.*\.(tsx|jsx)$/i],gr=[/\.(service|usecase|interactor|manager|facade)\.(ts|js)$/i,/\/services?\//i,/\/usecases?\//i,/\/domain\//i,/\/business\//i],yr=[/\/mcp\/handlers?\/[^/]+\.(ts|js)$/i,/\/mcp\/tools?\/[^/]+\.(ts|js)$/i,/\/mcp\/server\.(ts|js)$/i,/\/mcp\/index\.(ts|js)$/i],br=[/\/mcp\/utils?\.(ts|js)$/i,/\/mcp\/schemas?\.(ts|js)$/i,/\/mcp\/resources?\.(ts|js)$/i],Er=[/\/commands?\/[^/]+\.(ts|js|py|php)$/i,/\/cli\/[^/]+\.(ts|js|py|php)$/i,/\/bin\/[^/]+\.(ts|js|py|php)$/i,/cli\.(ts|js|py|php)$/i,/main\.(ts|js|py|php)$/i],Sr=[/\/parser\/[^/]+\.(ts|js)$/i,/\/ast\/[^/]+\.(ts|js)$/i,/\.(parser|visitor|walker|transformer)\.(ts|js)$/i],_r=[/\/core\/[^/]+\.(ts|js)$/i,/\/engine\/[^/]+\.(ts|js)$/i,/\/processing\/[^/]+\.(ts|js)$/i,/\/analysis\/[^/]+\.(ts|js)$/i,/\.(analyzer|processor|scanner|indexer|resolver)\.(ts|js)$/i],xr=[/\/ui\/[^/]+\.(ts|js|tsx|jsx)$/i,/\/display\/[^/]+\.(ts|js)$/i,/\/output\/[^/]+\.(ts|js)$/i,/\.(formatter|renderer|printer)\.(ts|js)$/i],Tr=[/\/stores?\//i,/\/slices?\//i,/\/reducers?\//i,/\/atoms?\//i,/\/selectors?\//i,/\.(store|slice|reducer|atom|selector)\.(ts|js)$/i,/.*Slice\.(ts|js)$/i,/.*Store\.(ts|js)$/i],Rr=[/\/hooks?\//i,/\/contexts?\//i,/\/providers?\//i,/use[A-Z].*\.(ts|js)$/,/.*Context\.(ts|tsx|js|jsx)$/i,/.*Provider\.(ts|tsx|js|jsx)$/i],vr=[/\/schemas?\//i,/\/validations?\//i,/\.(schema|validation|validator)\.(ts|js)$/i],wr=[/\.(types?|dto|interface|interfaces)\.(ts|js)$/i,/types\.ts$/i,/\/types?\//i,/\/dtos?\//i,/\/interfaces?\//i,/\/contracts?\//i,/\.d\.ts$/i],Ts=[/\.(model|entity|schema|repository|repo|dao|migration|query|mutation|resolver|connection|db)\.(ts|js)$/i,/queries\.(ts|js)$/i,/mutations\.(ts|js)$/i,/resolvers\.(ts|js)$/i,/connection\.(ts|js)$/i,/\/models?\//i,/\/entities?\//i,/\/repositories?\//i,/\/repos?\//i,/\/data\//i,/\/database\//i,/\/prisma\//i,/\/drizzle\//i,/\/api\/.*client\.(ts|js|tsx)$/i,/(^|\/)[A-Z0-9_-]*API\.(tsx?|js|jsx)$/],Ir=[/\.(util|utils|helper|helpers|lib|common|shared)\.(ts|js)$/i,/\/utils?\//i,/\/helpers?\//i,/\/lib\//i,/\/common\//i,/\/shared\//i],Cr=["express","fastify","koa","hapi","restify","next","nuxt","gatsby","remix","@nestjs/common","@nestjs/core","react-router","vue-router","@angular/router","zod","joi","yup","valibot","superstruct"],$r=["prisma","@prisma/client","typeorm","sequelize","mongoose","drizzle-orm","knex","pg","mysql","sqlite","better-sqlite3","mongodb","redis","ioredis","zustand","redux","recoil","jotai","mobx"]});var Lr,Nr,Ar,Mr,Pr=Q(()=>{"use strict";Lr=[/urls\.py$/i,/wsgi\.py$/i,/asgi\.py$/i,/manage\.py$/i,/main\.py$/i,/app\.py$/i,/\/endpoints?\/.*\.py$/i,/\/commands?\/.*\.py$/i],Nr=[/views\.py$/i,/forms\.py$/i,/serializers\.py$/i,/admin\.py$/i,/apps\.py$/i,/tasks\.py$/i,/middlewares?\.py$/i,/signals?\.py$/i,/context_processors\.py$/i],Ar=[/models\.py$/i,/\/models\/.*\.py$/i,/\/migrations\/.*\.py$/i,/schema\.py$/i,/documents\.py$/i],Mr=["django.urls","django.http","flask","fastapi","chalice","tornado"]});var Dr,Or,Fr,Hr,Wr=Q(()=>{"use strict";Dr=[/\/routes?\/.*\.php$/i,/\/controllers?\/.*\.php$/i,/index\.php$/i,/server\.php$/i,/artisan$/i,/console$/i],Or=[/\/services?\/.*\.php$/i,/\/providers?\/.*\.php$/i,/\/middleware\/.*\.php$/i,/\/jobs?\/.*\.php$/i,/\/listeners?\/.*\.php$/i,/\/events?\/.*\.php$/i,/\/observers?\/.*\.php$/i,/\/console\/commands\/.*\.php$/i,/\/actions?\/.*\.php$/i,/\/traits?\/.*\.php$/i,/\/concerns?\/.*\.php$/i,/\/contracts?\/.*\.php$/i],Fr=[/\/models?\/.*\.php$/i,/\/eloquent\/.*\.php$/i,/\/migrations?\/.*\.php$/i,/\/seeders?\/.*\.php$/i,/\/factories?\/.*\.php$/i,/\/repositories?\/.*\.php$/i,/\/resources?\/.*\.php$/i],Hr=["laravel","symfony","slim","cakephp","codeigniter"]});import jr from"path";function Dt(i,e,t){let n=[],s="Unknown",r=0;t||(t=bc(i,e));let{inDegree:o,outDegree:c}=t,a=(u,m,f,h)=>{for(let b of u)if(b.test(i))return n.push(`${h}: ${b.source}`),s=m,r+=f,!0;return!1},l=!1;if(l||(l=a(mr,"Entry",45,"Next.js entry")),l||(l=a(yr,"Entry",40,"MCP handler")),l||(l=a(Er,"Entry",40,"CLI command")),l||(l=a(Ts,"Data",45,"Data layer/Repository")),l||(l=a(Tr,"Data",35,"State management")),l||(l=a(fr,"Logic",40,"React component")),l||(l=a(gr,"Logic",35,"Logic pattern")),l||(l=a(Sr,"Logic",35,"Parser/AST")),l||(l=a(_r,"Logic",35,"Core module")),l||(l=a(xr,"Logic",30,"UI layer")),l||(l=a(wr,"Types",35,"Type definition")),l||(l=a(Lr,"Entry",40,"Python Entry")),l||(l=a(Ar,"Data",40,"Python Data")),l||(l=a(Nr,"Logic",35,"Python Logic")),l||(l=a(Dr,"Entry",40,"PHP Entry")),l||(l=a(Fr,"Data",40,"PHP Data")),l||(l=a(Or,"Logic",35,"PHP Logic")),l||(l=a(Rr,"Logic",35,"Hook/Context")),!l){for(let u of br)if(u.test(i)){n.push(`MCP utility: ${u.source}`),/schemas?/i.test(i)?s="Types":/resources?/i.test(i)?s="Data":s="Utility",r+=35,l=!0;break}}l||a(vr,"Data",35,"Schema definition")&&(l=!0),l||(a(Ts,"Data",30,"Path matches data pattern")||a(Ir,"Utility",25,"Path matches utility pattern")||a(hr,"Entry",30,"Path matches entry pattern"))&&(l=!0);for(let u of fc)if(u.test(i)){n.push(`Test file: ${u.source}`),s="Test",r=50,l=!0;break}l||a(gc,"Infrastructure",40,"Infrastructure")&&(l=!0);for(let u of yc)u.test(i)&&(n.push(`Monorepo component: ${u.source}`),/\/apps\/[^/]+\/src\/pages\//i.test(i)&&(n.push("Monorepo App Entry"),s==="Unknown"&&(s="Entry"),r+=20),/\/packages\/[^/]+\/src\//i.test(i)&&(r+=10));let d=e.imports.getImportsForFile(i).map(u=>u.module_specifier.toLowerCase());for(let u of $r)if(d.some(m=>m.includes(u))){n.push(`Imports JS data library: ${u}`),(s==="Unknown"||s==="Data")&&(s="Data",r+=25);break}for(let u of Mr)if(d.some(m=>m.includes(u))){n.push(`Imports Python framework: ${u}`),(s==="Unknown"||s==="Entry")&&(s="Entry",r+=20);break}for(let u of Hr)if(d.some(m=>m.includes(u))){n.push(`Imports PHP framework: ${u}`),(s==="Unknown"||s==="Entry")&&(s="Entry",r+=20);break}for(let u of Cr)if(d.some(m=>m.includes(u))){n.push(`Imports JS framework: ${u}`),(s==="Unknown"||s==="Entry")&&(s="Entry",r+=20);break}if(o===0&&c>0&&(n.push("Entry point: nothing imports this file (in-degree=0)"),s==="Unknown"?(s="Entry",r+=30):s==="Entry"&&(r+=15)),o>5&&c<=2&&(n.push(`High reuse: ${o} files import this (candidate for Utility)`),s==="Unknown"?(s="Utility",r+=25):s==="Utility"&&(r+=10)),s==="Unknown"&&o>0&&c>0){let u=o/(o+c);u>.3&&u<.7&&(n.push(`Balanced traffic: in=${o}, out=${c} (likely Logic layer)`),s="Logic",r+=25)}return s==="Unknown"&&(n.push("No strong classification signals detected"),r=10),r=Math.min(r,100),{layer:s,confidence:r,signals:n}}function bc(i,e){let t=e.imports.countDependents(i),n=e.imports.countByFile(i);return{inDegree:t,outDegree:n}}function je(i,e){let t=i.files.getAllPaths().map(f=>({path:f})),n=new Map,s={Entry:[],Logic:[],Data:[],Utility:[],Infrastructure:[],Test:[],Types:[],Unknown:[]};for(let f of t){let h=Dt(f.path,i);n.set(f.path,h),s[h.layer].push({path:f.path,classification:h})}let r={Entry:We(s.Entry,e),Logic:We(s.Logic,e),Data:We(s.Data,e),Utility:We(s.Utility,e),Infrastructure:We(s.Infrastructure,e),Test:We(s.Test,e),Types:We(s.Types,e),Unknown:We(s.Unknown,e)},o={};t.forEach(f=>{let h=jr.extname(f.path).toLowerCase();h&&(o[h]=(o[h]||0)+1)});let c={".ts":"TypeScript",".tsx":"Typescript (React)",".js":"JavaScript",".jsx":"JavaScript (React)",".py":"Python",".php":"PHP",".go":"Go",".rs":"Rust",".java":"Java",".cs":"C#",".rb":"Ruby",".vue":"Vue"},a={};Object.entries(o).forEach(([f,h])=>{let b=c[f];b&&(a[b]=(a[b]||0)+h)});let l=Object.entries(a).sort((f,h)=>h[1]-f[1]),p=l.length>0?l[0][0]:"Unknown",{pattern:d,patternConfidence:u,insights:m}=Ec(r,t.length,i);return{pattern:d,patternConfidence:u,layers:r,insights:m,primaryStack:p}}function We(i,e){return i.sort((t,n)=>n.classification.confidence-t.classification.confidence),{count:i.length,topFiles:i.slice(0,5).map(t=>({path:jr.relative(e,t.path),confidence:t.classification.confidence,signals:t.classification.signals.slice(0,2)}))}}function Ec(i,e,t){let n=[],s="Unknown",r=0,o=i.Entry.count/e*100,c=i.Logic.count/e*100,a=i.Data.count/e*100,l=i.Utility.count/e*100,p=i.Unknown.count/e*100;o>5&&c>10&&a>5&&p<40?(s="Layered",r=60+Math.min(30,(100-p)/3),n.push(`Clear layer separation: Entry (${o.toFixed(1)}%), Logic (${c.toFixed(1)}%), Data (${a.toFixed(1)}%)`)):l>20?(s="Modular",r=50+l/2,n.push(`High shared module usage: ${l.toFixed(1)}% utility files`)):p>60&&(s="Monolithic",r=40+p/4,n.push(`Limited architectural structure: ${p.toFixed(1)}% files with unclear layer assignment`));let d=t.configs.countByKind("Service");return d>3&&(s="Microservices",r=55+d*5,n.push(`Detected ${d} service definitions (likely microservices)`)),i.Entry.count===0&&n.push("\u26A0\uFE0F No clear entry points detected - consider adding route/controller files"),i.Data.count===0&&n.push("\u26A0\uFE0F No data layer detected - repository may not use traditional ORM patterns"),l>30&&n.push(`High utility concentration (${l.toFixed(1)}%) - good reusability`),{pattern:s,patternConfidence:Math.min(100,r),insights:n}}var fc,gc,yc,Ot=Q(()=>{"use strict";kr();Pr();Wr();fc=[/\.(test|spec)\.(ts|tsx|js|jsx)$/i,/tests?\.py$/i,/\/__tests__\//i,/\/tests?\//i,/\.e2e\.(ts|js)$/i,/\.integration\.(ts|js)$/i],gc=[/Dockerfile/i,/docker-compose/i,/\.ya?ml$/i,/nginx\.conf/i,/\/infra\//i,/\/deploy\//i,/\/k8s\//i,/\/kubernetes\//i,/\/terraform\//i,/\/ansible\//i,/package\.json/i,/tsconfig.*\.json/i,/\.env/i],yc=[/\/apps\/[^/]+\//i,/\/services\/[^/]+\//i,/\/packages\/[^/]+\//i,/\/backends\/[^/]+\//i,/\/backends_python\/[^/]+\//i]});var Ur={};Os(Ur,{HologramService:()=>ue});var ye,ue,dt=Q(()=>{"use strict";U();Ot();P();ye=_.child({module:"hologram"}),ue=class{repos;repoPath;constructor(e){this.repoPath=e,this.repos=C.getInstance(e)}updateTopography(e){ye.debug({repoPath:this.repoPath},"Updating topography snapshot");let t=Object.values(e.layers).reduce((r,o)=>r+o.count,0),n={};for(let[r,o]of Object.entries(e.layers)){let c=t>0?o.count/t*100:0;n[r]={count:o.count,percentage:Math.round(c*10)/10,topFiles:o.topFiles.slice(0,3).map(a=>({path:a.path,confidence:a.confidence}))}}let s={pattern:e.pattern,patternConfidence:e.patternConfidence,layerDistribution:n,insights:e.insights,updatedAt:Date.now()};this.repos.hologram.upsertSection("topography",JSON.stringify(s)),ye.info({repoPath:this.repoPath},"Topography snapshot updated")}refreshTopography(){let e=je(this.repos,this.repoPath);this.updateTopography(e)}updateGravityZones(e){ye.debug({repoPath:this.repoPath,count:e.length},"Updating gravity zones");let t={hotspots:e.slice(0,50),updatedAt:Date.now()};this.repos.hologram.upsertSection("gravity",JSON.stringify(t)),ye.info({repoPath:this.repoPath},"Gravity zones updated")}updateGhostBridges(e){ye.debug({repoPath:this.repoPath,count:e.length},"Updating ghost bridges");let t={bridges:e.slice(0,20),updatedAt:Date.now()};this.repos.hologram.upsertSection("ghosts",JSON.stringify(t)),ye.info({repoPath:this.repoPath},"Ghost bridges updated")}getSnapshot(){let e=this.repos.hologram.getAllSections(),t={metadata:{repoPath:this.repoPath,lastUpdated:Date.now(),version:"1.0.0"}};for(let n of e)try{let s=JSON.parse(n.data);switch(n.section){case"topography":t.topography=s;break;case"gravity":t.gravity=s;break;case"ghosts":t.ghosts=s;break}}catch(s){ye.error({repoPath:this.repoPath,section:n.section,error:s},"Failed to parse hologram section")}return t}getSection(e){let t=this.repos.hologram.getSection(e);if(!t)return null;try{return JSON.parse(t.data)}catch(n){return ye.error({repoPath:this.repoPath,section:e,error:n},"Failed to parse section"),null}}computeGravityZones(){ye.debug({repoPath:this.repoPath},"Computing gravity zones from import graph");let e=this.repos.files.getAllPaths(),t=new Map;for(let s of e){let r=Dt(s,this.repos);if(r.layer==="Test"||r.layer==="Unknown")continue;let o=this.repos.exports.findByFile(s);if(o.length===0)continue;let c=this.repos.imports.countDependents(s),a=this.repos.imports.countByFile(s),l=c*2+a;if(l>0){let p=o.find(u=>u.kind!=="TsTypeAliasDeclaration"&&u.kind!=="TsInterfaceDeclaration")||o[0],d=`${s}::${p.name}`;t.set(d,{symbol:p.name,filePath:s,inDegree:c,outDegree:a,gravity:l})}}let n=Array.from(t.values()).sort((s,r)=>r.gravity-s.gravity).slice(0,50);return ye.info({repoPath:this.repoPath,count:n.length},"Gravity zones computed"),n}isInitialized(){return this.repos.hologram.getAllSections().length>0}clear(){this.repos.hologram.deleteAll(),ye.info({repoPath:this.repoPath},"Hologram cleared")}}});var Io={};Os(Io,{GraphExporterService:()=>Ps});var wo,Ps,Co=Q(()=>{"use strict";U();P();wo=_.child({module:"graph-exporter"}),Ps=class{constructor(e){this.repoPath=e;this.repos=C.getInstance(e)}repos;async generateGraph(e={}){let{includeCompleted:t=!0,format:n="mermaid",focusMissionId:s,depth:r=10,limit:o=100}=e;wo.info({focusMissionId:s,depth:r,format:n,includeCompleted:t},"Generating mission graph");let c=this.buildMissionTree(s,t,r,o);return n==="json"?JSON.stringify(c,null,2):this.generateMermaidDiagram(c)}buildMissionTree(e,t,n,s){let r;if(e){let a=this.repos.missions.findById(e);r=a?[a]:[]}else r=this.repos.missions.findAll().filter(l=>!l.parent_id),t||(r=r.filter(l=>l.status!=="completed"));let o=0,c=[];for(let a of r){if(o>=s)break;let l=this.buildNode(a,t,n,1,{count:o,max:s});l&&(c.push(l),o+=this.countNodes(l))}return c}buildNode(e,t,n,s,r){if(s>n||r.count>=r.max)return null;let o;if(e.strategy_graph)try{let p=JSON.parse(e.strategy_graph);o=this.parseStrategySteps(p)}catch(p){wo.debug({missionId:e.id,err:p},"Failed to parse strategy graph")}let c={id:e.id,name:e.name,status:e.status,goal:e.goal,branch:e.git_branch||void 0,children:[],steps:o},a=this.repos.missions.findByParentId(e.id),l=t?a:a.filter(p=>p.status!=="completed");for(let p of l){if(r.count>=r.max)break;let d=this.buildNode(p,t,n,s+1,r);d&&(c.children.push(d),r.count++)}return c}parseStrategySteps(e){let t=[];return Array.isArray(e)?e.map((n,s)=>({id:n.id||`step-${s}`,description:n.description||n.content||n.name||`Step ${s+1}`,status:n.status,dependencies:n.dependencies||n.deps})):e.steps&&Array.isArray(e.steps)?this.parseStrategySteps(e.steps):typeof e=="object"?Object.entries(e).map(([n,s])=>({id:n,description:s.description||s.content||n,status:s.status,dependencies:s.dependencies||s.deps})):t}countNodes(e){let t=1;for(let n of e.children)t+=this.countNodes(n);return t}generateMermaidDiagram(e){let t=["graph TD"];for(let n of e)this.addMermaidNode(n,t);return t.join(`
424
- `)}addMermaidNode(e,t,n){let s=`M${e.id}`,r=this.getStatusIcon(e.status),o=this.getStatusClass(e.status),c=`${r} ${e.name}`;if(t.push(` ${s}["${this.escapeMermaid(c)}"]:::${o}`),n&&t.push(` ${n} --> ${s}`),e.steps&&e.steps.length>0&&e.steps.length<=10)for(let a of e.steps){let l=`S${e.id}_${a.id}`,p=a.status||"pending",d=this.getStatusIcon(p),u=this.getStatusClass(p),m=`${d} ${a.description}`;if(t.push(` ${l}["${this.escapeMermaid(m)}"]:::${u}`),t.push(` ${s} -.-> ${l}`),a.dependencies&&a.dependencies.length>0)for(let f of a.dependencies){let h=`S${e.id}_${f}`;t.push(` ${h} --> ${l}`)}}for(let a of e.children)this.addMermaidNode(a,t,s);n||(t.push(""),t.push(" classDef completed fill:#90EE90,stroke:#2E8B57,stroke-width:2px"),t.push(" classDef inProgress fill:#87CEEB,stroke:#4682B4,stroke-width:2px"),t.push(" classDef planned fill:#FFE4B5,stroke:#DAA520,stroke-width:2px"),t.push(" classDef suspended fill:#D3D3D3,stroke:#808080,stroke-width:2px"),t.push(" classDef failed fill:#FFB6C1,stroke:#DC143C,stroke-width:2px"),t.push(" classDef pending fill:#FFF8DC,stroke:#B8860B,stroke-width:1px"))}getStatusIcon(e){return{completed:"\u2713","in-progress":"\u26A1",planned:"\u{1F4CB}",suspended:"\u23F8",failed:"\u2717",pending:"\u25CB",verifying:"\u{1F50D}"}[e]||"\u25CB"}getStatusClass(e){return{completed:"completed","in-progress":"inProgress",planned:"planned",suspended:"suspended",failed:"failed",pending:"pending",verifying:"inProgress"}[e]||"pending"}escapeMermaid(e){return e.replace(/"/g,"#quot;").replace(/\n/g," ").replace(/\[/g,"#91;").replace(/]/g,"#93;").slice(0,100)}}});import"dotenv/config";import{Cli as fl}from"clerc";P();import Fs from"fs";import Xo from"path";import Hs from"js-yaml";var Ws={ignore:[],include:[],maxDepth:10},Zo=[{name:".liquid-shadow.yaml",parse:i=>Hs.load(i)??{}},{name:".liquid-shadow.yml",parse:i=>Hs.load(i)??{}},{name:".ls.json",parse:i=>JSON.parse(i)},{name:".liquid-shadow.json",parse:i=>JSON.parse(i)},{name:".ls.rc",parse:i=>JSON.parse(i)},{name:".liquid-shadow.rc",parse:i=>JSON.parse(i)}];function Ce(i){for(let{name:e,parse:t}of Zo){let n=Xo.join(i,e);if(Fs.existsSync(n))try{let s=Fs.readFileSync(n,"utf8"),r=t(s);return _.info({repoPath:i,configFile:e},"Loaded repository configuration"),{...Ws,...r}}catch(s){_.error({repoPath:i,file:e,err:s},"Failed to parse configuration file")}}return Ws}function js(i,e){let n=Ce(i).cli??{};return{dir:e.dir??n.dir??".",level:e.level??n.level,deep:e.deep!==void 0?e.deep:n.deep}}U();import Ca from"path";var ne=Yo(ci(),1);import*as Se from"@clack/prompts";var G={red:ne.default.red,green:ne.default.green,yellow:ne.default.yellow,blue:ne.default.blue,magenta:ne.default.magenta,cyan:ne.default.cyan,white:ne.default.white,gray:ne.default.gray,bold:ne.default.bold,dim:ne.default.dim,italic:ne.default.italic,underline:ne.default.underline,inverse:ne.default.inverse},Pe=i=>i.replace(/\x1b\[[0-9;]*m/g,""),le=i=>Se.intro(ne.default.bgCyan(ne.default.black(ne.default.bold(` ${i} `)))),Tt=i=>Se.outro(ne.default.cyan(i)),se=(i,e,t="blue")=>{let n=e.split(`
425
- `),s=Pe(i),r=Math.max(s.length+4,...n.map(a=>Pe(a).length))+2,o="\u2500".repeat(r),c=G[t];console.log(c(`\u250C${o}\u2510`)),console.log(c("\u2502 ")+G.bold(i).padEnd(r+(i.length-s.length)-1)+c("\u2502")),console.log(c(`\u251C${o}\u2524`)),n.forEach(a=>{let l=Pe(a),p=" ".repeat(r-l.length-1);console.log(c("\u2502 ")+a+p+c("\u2502"))}),console.log(c(`\u2514${o}\u2518`))},an=(i,e)=>{let t=i.map((s,r)=>Math.max(Pe(s).length,...e.map(o=>Pe(o[r]||"").length))+2),n=G.cyan("\u2502");console.log(n),console.log(n+" "+i.map((s,r)=>G.bold(G.cyan(s)).padEnd(t[r]+(s.length-Pe(s).length))).join(G.gray(" "))+" "),e.forEach(s=>{console.log(n+" "+s.map((r,o)=>(r||"").padEnd(t[o]+(r.length-Pe(r).length))).join(G.gray(" "))+" ")}),console.log(n)},li=(i,e="\u2022")=>{i.forEach(t=>{console.log(`${G.cyan("\u2502")} ${G.cyan(e)} ${t}`)})},pi=(i,e=40)=>{let t=Math.max(...i.map(s=>s.value)),n=Math.max(...i.map(s=>Pe(s.label).length));console.log(G.cyan("\u2502")),i.forEach(s=>{let r=Math.round(s.value/t*e),o="\u2588".repeat(r)+G.dim("\u2591".repeat(e-r)),c=s.color?G[s.color]:G.cyan,a=s.label.padEnd(n);console.log(`${G.cyan("\u2502")} ${G.bold(a)} ${c(o)} ${G.white(s.value.toString())}`)}),console.log(G.cyan("\u2502"))},ts=(i,e="")=>{i.forEach((t,n)=>{let s=n===i.length-1,r=s?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ",o=t.color?G[t.color]:t.children?G.blue:G.white,c=t.info?` ${G.gray(`(${t.info})`)}`:"";if(console.log(`${G.cyan("\u2502")} ${e}${G.gray(r)}${o(t.name)}${c}`),t.children&&t.children.length>0){let a=e+(s?" ":"\u2502 ");ts(t.children,a)}})},de=()=>Se.spinner();async function cn(i,e,t){if(e.length===0)return;let n=await Se.select({message:i,options:e.map(s=>({value:s.value,label:s.label,...s.hint!=null&&{hint:s.hint}})),...t?.limit!=null&&{maxItems:t.limit}});if(!Se.isCancel(n))return n}var ha=i=>{console.error("");let e=i instanceof Error?i.message:String(i);console.error(` ${G.red("\u2716")} ${G.bold("Error: ")} ${e}`),i instanceof Error&&"cause"in i&&console.error(` ${G.dim("Cause: "+String(i.cause))}`),console.error(""),process.exit(1)},B=async i=>{try{await i()}catch(e){ha(e)}},E=G;P();P();import{Worker as Sa}from"node:worker_threads";import{cpus as _a}from"node:os";import{fileURLToPath as xa}from"node:url";import{dirname as Ta,join as mi}from"node:path";import{existsSync as hi}from"node:fs";import{fileURLToPath as fa}from"node:url";import{dirname as ns,join as di,resolve as ga}from"node:path";import{existsSync as ya}from"node:fs";var ba=fa(import.meta.url),ui=ns(ba);function Ea(){let i=ui;for(;i!==ns(i);){if(ya(di(i,"package.json")))return i;i=ns(i)}return ga(ui,"..","..")}function ln(...i){return di(Ea(),...i)}var gi=xa(import.meta.url),fi=Ta(gi);function Ra(){if(gi.endsWith(".ts")){let e=mi(fi,"worker.ts");if(hi(e))return e}let i=mi(fi,"worker.js");return hi(i)?i:ln("dist/logic/domain/embeddings/worker.js")}var Rt=class{workers=[];taskQueue=[];pendingTasks=new Map;taskIdCounter=0;initialized=!1;initPromise;shutdownRequested=!1;numWorkers;cacheDir;initTimeout;constructor(e={}){this.numWorkers=e.numWorkers??Math.max(1,_a().length-1),this.cacheDir=e.cacheDir??"./.cache",this.initTimeout=e.initTimeout??6e4}async initialize(){if(!this.initialized)return this.initPromise?this.initPromise:(this.initPromise=this._doInitialize(),this.initPromise)}async _doInitialize(){let e;try{_.info({numWorkers:this.numWorkers},"Initializing embedding worker pool");let t=new Promise((n,s)=>{e=setTimeout(()=>s(new Error(`Worker pool initialization timed out after ${this.initTimeout}ms`)),this.initTimeout)});if(await Promise.race([this._initializeWorkers(),t]),e&&clearTimeout(e),this.shutdownRequested){this.initialized=!1,this.initPromise=void 0,_.debug("Initialization completed but shutdown was requested");return}this.initialized=!0,_.info({numWorkers:this.workers.length},"Embedding worker pool ready")}catch(t){throw e&&clearTimeout(e),this.initPromise=void 0,this.initialized=!1,await this.shutdown(),t}}async _initializeWorkers(){let e=Ra();_.debug({workerPath:e},"Resolved worker path");for(let t=0;t<this.numWorkers;t++)await this.createWorker(e,t),await new Promise(n=>setTimeout(n,50))}async createWorker(e,t){return new Promise((n,s)=>{let r=setTimeout(()=>{s(new Error(`Worker ${t} initialization timed out`))},this.initTimeout),o=new Sa(e,{workerData:{cacheDir:this.cacheDir},execArgv:process.execArgv}),c={worker:o,busy:!1,currentTaskId:null};o.on("message",a=>{if(a.type==="ready"){if(clearTimeout(r),this.shutdownRequested){_.debug({workerIndex:t},"Worker ready but shutdown requested, terminating"),o.terminate().catch(()=>{}),n();return}this.workers.push(c),_.debug({workerIndex:t},"Worker ready"),n()}else a.type==="result"&&a.id?this.handleTaskComplete(c,a.id,a.embeddings||[]):a.type==="error"&&a.id&&this.handleTaskError(c,a.id,new Error(a.error||"Unknown error"))}),o.on("error",a=>{if(clearTimeout(r),_.error({err:a,workerIndex:t},"Worker error"),c.currentTaskId&&this.handleTaskError(c,c.currentTaskId,a),!this.initialized){s(a);return}let l=this.workers.indexOf(c);l!==-1&&this.workers.splice(l,1),!this.shutdownRequested&&this.initialized&&this.createWorker(e,t).catch(p=>{_.error({err:p},"Failed to replace crashed worker")})}),o.on("exit",a=>{a!==0&&!this.shutdownRequested&&_.warn({workerIndex:t,code:a},"Worker exited unexpectedly")})})}handleTaskComplete(e,t,n){let s=this.pendingTasks.get(t);s&&(this.pendingTasks.delete(t),s.resolve(n)),e.busy=!1,e.currentTaskId=null,this.processQueue()}handleTaskError(e,t,n){let s=this.pendingTasks.get(t);s&&(this.pendingTasks.delete(t),s.reject(n)),e.busy=!1,e.currentTaskId=null,this.processQueue()}processQueue(){if(this.taskQueue.length===0)return;let e=this.workers.find(n=>!n.busy);if(!e)return;let t=this.taskQueue.shift();t&&(e.busy=!0,e.currentTaskId=t.id,this.pendingTasks.set(t.id,t),e.worker.postMessage({type:"embed",id:t.id,texts:t.texts}))}async generateEmbeddings(e,t=32,n){if(this.initialized||await this.initialize(),e.length===0)return[];let s=[];for(let l=0;l<e.length;l+=t)s.push(e.slice(l,l+t));let r=new Array(s.length),o=0,c=s.map((l,p)=>new Promise((d,u)=>{let f={id:`task_${++this.taskIdCounter}`,texts:l,resolve:h=>{if(r[p]=h,o++,n){let b=Math.min(o*t,e.length);n(b,e.length)}d()},reject:h=>{if(r[p]=new Array(l.length).fill(null),o++,_.warn({err:h,chunkIndex:p},"Chunk embedding failed"),n){let b=Math.min(o*t,e.length);n(b,e.length)}d()}};this.taskQueue.push(f),this.processQueue()}));await Promise.all(c);let a=[];for(let l of r)a.push(...l);return _.info({total:e.length,successful:a.filter(l=>l!==null).length,workers:this.workers.length},"Parallel embedding generation complete"),a}get workerCount(){return this.workers.length}get busyWorkers(){return this.workers.filter(e=>e.busy).length}get queueSize(){return this.taskQueue.length}get isInitialized(){return this.initialized}async shutdown(){if(this.shutdownRequested=!0,this.initPromise)try{await this.initPromise}catch{}if(!this.initialized&&this.workers.length===0){this.shutdownRequested=!1,this.initPromise=void 0;return}_.info({numWorkers:this.workers.length},"Shutting down embedding worker pool");let e=this.workers.map(t=>new Promise(n=>{t.worker.postMessage({type:"shutdown"}),t.worker.once("exit",()=>n()),setTimeout(()=>{t.worker.terminate().then(()=>n())},5e3)}));await Promise.all(e),this.workers=[],this.taskQueue=[],this.pendingTasks.clear(),this.initialized=!1,this.shutdownRequested=!1,_.info("Embedding worker pool shutdown complete")}},it=null;function ss(i){return it||(it=new Rt(i)),it}async function pn(){it&&(await it.shutdown(),it=null)}var vt=null;async function va(){return vt||(vt=await import("@xenova/transformers"),vt.env.cacheDir="./.cache",vt.env.allowLocalModels=!1),vt}var wa=128,yi=!1;function un(i){yi=i,_.info({useWorkerThreads:i},"Worker thread mode updated")}var is=null;async function bi(){return is||(is=(async()=>{_.info("Loading embedding model (all-MiniLM-L6-v2)...");let{pipeline:i}=await va();return await i("feature-extraction","Xenova/all-MiniLM-L6-v2")})()),is}async function rs(i){try{let t=await(await bi())(i,{pooling:"mean",normalize:!0});return Array.from(t.data)}catch(e){return _.error({err:e},"Failed to generate embedding"),null}}async function os(i,e=wa,t){return i.length===0?[]:yi?ss().generateEmbeddings(i,e,t):Ia(i,e,t)}async function Ia(i,e,t){let n=new Array(i.length).fill(null),s=await bi();for(let r=0;r<i.length;r+=e){let o=Math.min(r+e,i.length),c=i.slice(r,o);try{let a=await s(c,{pooling:"mean",normalize:!0}),[l,p]=a.dims;for(let d=0;d<l;d++){let u=d*p,m=u+p;n[r+d]=Array.from(a.data.slice(u,m))}}catch(a){_.error({err:a,batchStart:r,batchEnd:o},"Single-threaded batch embedding failed, falling back to sequential for this chunk");for(let l=0;l<c.length;l++)try{let p=c[l];if(!p||p.trim().length===0)continue;let d=await s(p,{pooling:"mean",normalize:!0});n[r+l]=Array.from(d.data)}catch{n[r+l]=null}}t&&t(o,i.length)}return _.debug({total:i.length,successful:n.filter(r=>r!==null).length},"Batch embedding complete"),n}function as(i,e){let t=0,n=0,s=0;for(let r=0;r<i.length;r++)t+=i[r]*e[r],n+=i[r]*i[r],s+=e[r]*e[r];return t/(Math.sqrt(n)*Math.sqrt(s))}Qe();P();async function q(i){_.info("Performing graceful shutdown...");try{await pn()}catch(e){_.error({err:e},"Error shutting down worker pool")}try{i&&Yt(i)}catch(e){_.error({err:e},"Error closing database")}_.info("Shutdown complete")}async function Ei(i){let e=Ca.resolve(i);try{await B(async()=>{let t=C.getInstance(e),n=Ce(e),s=n.ignore&&n.ignore.length>0,r=t.files.getCount(),o=t.exports.getCount(),c=t.files.getLatestScanTime(),a=t.exports.getKindDistribution(5);se("Repo Status",`${E.bold("Files")}: ${E.cyan(r.toString())}
426
- ${E.bold("Symbols")}: ${E.cyan(o.toString())}
427
- ${E.bold("Last Scan")}: ${c?E.yellow(new Date(c).toLocaleString()):E.red("Never")}
428
- ${E.bold("Config")}: ${s?E.green("Active"):E.gray("Default")}`,"blue"),a.length>0&&(console.log(""),console.log(` ${E.bold("Symbol Distribution (Top 5) ")}`),pi(a.map(l=>({label:l.kind,value:l.c,color:"cyan"})),30))})}finally{await q(e)}}U();Qe();import $a from"path";P();import oe from"fs";import Ke from"path";var rt=_.child({module:"git-hooks"}),dn={"post-merge":`#!/bin/sh
460
+ `,e,r)}deleteSection(e){this.run("DELETE FROM hologram_snapshot WHERE section = ?",e)}deleteAll(){this.run("DELETE FROM hologram_snapshot")}hasSection(e){return(this.get("SELECT COUNT(*) as count FROM hologram_snapshot WHERE section = ?",e)?.count??0)>0}}});var z,X=ge(()=>{"use strict";st();Zf();Hf();Gf();lc();rh();ih();oh();ah();ch();z=class{static repositoryCache=new Map;static getInstance(e){let r=this.repositoryCache.get(e);if(r){let o=je(e),s=r.files?.database,a=!r.intentLogs||!r.searchHistory||!r.missions||!r.hologram;if(s===o&&o.open&&!a)return r;this.repositoryCache.delete(e)}let i=je(e),t={files:new Ki(i),exports:new Yi(i),imports:new Xi(i),missions:new Gr(i),intentLogs:new io(i),configs:new oo(i),content:new so(i),searchHistory:new ao(i),hologram:new co(i)};return this.repositoryCache.set(e,t),t}static closeInstance(e){this.repositoryCache.delete(e),Br(e)}static clearCache(e){this.repositoryCache.delete(e)}}});var dh=B_((AI,mc)=>{var uo=process||{},lh=uo.argv||[],lo=uo.env||{},_x=!(lo.NO_COLOR||lh.includes("--no-color"))&&(!!lo.FORCE_COLOR||lh.includes("--color")||uo.platform==="win32"||(uo.stdout||{}).isTTY&&lo.TERM!=="dumb"||!!lo.CI),xx=(n,e,r=n)=>i=>{let t=""+i,o=t.indexOf(e,n.length);return~o?n+Sx(t,e,r,o)+e:n+t+e},Sx=(n,e,r,i)=>{let t="",o=0;do t+=n.substring(o,i)+r,o=i+e.length,i=n.indexOf(e,o);while(~i);return t+n.substring(o)},uh=(n=_x)=>{let e=n?xx:()=>String;return{isColorSupported:n,reset:e("\x1B[0m","\x1B[0m"),bold:e("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:e("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:e("\x1B[3m","\x1B[23m"),underline:e("\x1B[4m","\x1B[24m"),inverse:e("\x1B[7m","\x1B[27m"),hidden:e("\x1B[8m","\x1B[28m"),strikethrough:e("\x1B[9m","\x1B[29m"),black:e("\x1B[30m","\x1B[39m"),red:e("\x1B[31m","\x1B[39m"),green:e("\x1B[32m","\x1B[39m"),yellow:e("\x1B[33m","\x1B[39m"),blue:e("\x1B[34m","\x1B[39m"),magenta:e("\x1B[35m","\x1B[39m"),cyan:e("\x1B[36m","\x1B[39m"),white:e("\x1B[37m","\x1B[39m"),gray:e("\x1B[90m","\x1B[39m"),bgBlack:e("\x1B[40m","\x1B[49m"),bgRed:e("\x1B[41m","\x1B[49m"),bgGreen:e("\x1B[42m","\x1B[49m"),bgYellow:e("\x1B[43m","\x1B[49m"),bgBlue:e("\x1B[44m","\x1B[49m"),bgMagenta:e("\x1B[45m","\x1B[49m"),bgCyan:e("\x1B[46m","\x1B[49m"),bgWhite:e("\x1B[47m","\x1B[49m"),blackBright:e("\x1B[90m","\x1B[39m"),redBright:e("\x1B[91m","\x1B[39m"),greenBright:e("\x1B[92m","\x1B[39m"),yellowBright:e("\x1B[93m","\x1B[39m"),blueBright:e("\x1B[94m","\x1B[39m"),magentaBright:e("\x1B[95m","\x1B[39m"),cyanBright:e("\x1B[96m","\x1B[39m"),whiteBright:e("\x1B[97m","\x1B[39m"),bgBlackBright:e("\x1B[100m","\x1B[49m"),bgRedBright:e("\x1B[101m","\x1B[49m"),bgGreenBright:e("\x1B[102m","\x1B[49m"),bgYellowBright:e("\x1B[103m","\x1B[49m"),bgBlueBright:e("\x1B[104m","\x1B[49m"),bgMagentaBright:e("\x1B[105m","\x1B[49m"),bgCyanBright:e("\x1B[106m","\x1B[49m"),bgWhiteBright:e("\x1B[107m","\x1B[49m")}};mc.exports=uh();mc.exports.createColors=uh});var To,Po,Xh,Ro,Qh,eg,tg,ng,rg,ig,og,sg,ag,cg,ri,No,lg,ug,Rc=ge(()=>{"use strict";To=[/\/pages\/(?!_)[^/]+\.(tsx?|jsx?)$/i,/\/pages\/.*\/index\.(tsx?|jsx?)$/i,/\/app\/.*\/page\.(tsx?|jsx?)$/i,/\/app\/.*\/layout\.(tsx?|jsx?)$/i,/\/app\/api\/.*\/route\.(ts|js)$/i,/\/pages\/api\/.*\.(ts|js)$/i],Po=[/\.(routes?|router|controller|handler|endpoint|api)\.(ts|js|tsx|jsx)$/i,/\/routes?\//i,/\/controllers?\//i,/index\.(ts|js|tsx|jsx)$/i],Xh=[/\/components?\/.*\.(tsx|jsx)$/i,/\/features?\/.*\.(tsx|jsx)$/i,/\/views?\/.*\.(tsx|jsx)$/i,/\/screens?\/.*\.(tsx|jsx)$/i,/\/widgets?\/.*\.(tsx|jsx)$/i],Ro=[/\.(service|usecase|interactor|manager|facade)\.(ts|js)$/i,/\/services?\//i,/\/usecases?\//i,/\/domain\//i,/\/business\//i],Qh=[/\/mcp\/handlers?\/[^/]+\.(ts|js)$/i,/\/mcp\/tools?\/[^/]+\.(ts|js)$/i,/\/mcp\/server\.(ts|js)$/i,/\/mcp\/index\.(ts|js)$/i],eg=[/\/mcp\/utils?\.(ts|js)$/i,/\/mcp\/schemas?\.(ts|js)$/i,/\/mcp\/resources?\.(ts|js)$/i],tg=[/\/commands?\/[^/]+\.(ts|js|py|php)$/i,/\/cli\/[^/]+\.(ts|js|py|php)$/i,/\/bin\/[^/]+\.(ts|js|py|php)$/i,/cli\.(ts|js|py|php)$/i,/main\.(ts|js|py|php)$/i],ng=[/\/parser\/[^/]+\.(ts|js)$/i,/\/ast\/[^/]+\.(ts|js)$/i,/\.(parser|visitor|walker|transformer)\.(ts|js)$/i],rg=[/\/core\/[^/]+\.(ts|js)$/i,/\/engine\/[^/]+\.(ts|js)$/i,/\/processing\/[^/]+\.(ts|js)$/i,/\/analysis\/[^/]+\.(ts|js)$/i,/\.(analyzer|processor|scanner|indexer|resolver)\.(ts|js)$/i],ig=[/\/ui\/[^/]+\.(ts|js|tsx|jsx)$/i,/\/display\/[^/]+\.(ts|js)$/i,/\/output\/[^/]+\.(ts|js)$/i,/\.(formatter|renderer|printer)\.(ts|js)$/i],og=[/\/stores?\//i,/\/slices?\//i,/\/reducers?\//i,/\/atoms?\//i,/\/selectors?\//i,/\.(store|slice|reducer|atom|selector)\.(ts|js)$/i,/.*Slice\.(ts|js)$/i,/.*Store\.(ts|js)$/i],sg=[/\/hooks?\//i,/\/contexts?\//i,/\/providers?\//i,/use[A-Z].*\.(ts|js)$/,/.*Context\.(ts|tsx|js|jsx)$/i,/.*Provider\.(ts|tsx|js|jsx)$/i],ag=[/\/schemas?\//i,/\/validations?\//i,/\.(schema|validation|validator)\.(ts|js)$/i],cg=[/\.(types?|dto|interface|interfaces)\.(ts|js)$/i,/types\.ts$/i,/\/types?\//i,/\/dtos?\//i,/\/interfaces?\//i,/\/contracts?\//i,/\.d\.ts$/i],ri=[/\.(model|entity|schema|repository|repo|dao|migration|query|mutation|resolver|connection|db)\.(ts|js)$/i,/queries\.(ts|js)$/i,/mutations\.(ts|js)$/i,/resolvers\.(ts|js)$/i,/connection\.(ts|js)$/i,/\/models?\//i,/\/entities?\//i,/\/repositories?\//i,/\/repos?\//i,/\/data\//i,/\/database\//i,/\/prisma\//i,/\/drizzle\//i,/\/api\/.*client\.(ts|js|tsx)$/i,/(^|\/)[A-Z0-9_-]*API\.(tsx?|js|jsx)$/],No=[/\.(util|utils|helper|helpers|lib|common|shared)\.(ts|js)$/i,/\/utils?\//i,/\/helpers?\//i,/\/lib\//i,/\/common\//i,/\/shared\//i],lg=["express","fastify","koa","hapi","restify","next","nuxt","gatsby","remix","@nestjs/common","@nestjs/core","react-router","vue-router","@angular/router","zod","joi","yup","valibot","superstruct"],ug=["prisma","@prisma/client","typeorm","sequelize","mongoose","drizzle-orm","knex","pg","mysql","sqlite","better-sqlite3","mongodb","redis","ioredis","zustand","redux","recoil","jotai","mobx"]});var zo,pg,Do,mg,Nc=ge(()=>{"use strict";zo=[/urls\.py$/i,/wsgi\.py$/i,/asgi\.py$/i,/manage\.py$/i,/main\.py$/i,/app\.py$/i,/\/endpoints?\/.*\.py$/i,/\/commands?\/.*\.py$/i],pg=[/views\.py$/i,/forms\.py$/i,/serializers\.py$/i,/admin\.py$/i,/apps\.py$/i,/tasks\.py$/i,/middlewares?\.py$/i,/signals?\.py$/i,/context_processors\.py$/i],Do=[/models\.py$/i,/\/models\/.*\.py$/i,/\/migrations\/.*\.py$/i,/schema\.py$/i,/documents\.py$/i],mg=["django.urls","django.http","flask","fastapi","chalice","tornado"]});var Co,hg,Lo,gg,zc=ge(()=>{"use strict";Co=[/\/routes?\/.*\.php$/i,/\/controllers?\/.*\.php$/i,/index\.php$/i,/server\.php$/i,/artisan$/i,/console$/i],hg=[/\/services?\/.*\.php$/i,/\/providers?\/.*\.php$/i,/\/middleware\/.*\.php$/i,/\/jobs?\/.*\.php$/i,/\/listeners?\/.*\.php$/i,/\/events?\/.*\.php$/i,/\/observers?\/.*\.php$/i,/\/console\/commands\/.*\.php$/i,/\/actions?\/.*\.php$/i,/\/traits?\/.*\.php$/i,/\/concerns?\/.*\.php$/i,/\/contracts?\/.*\.php$/i],Lo=[/\/models?\/.*\.php$/i,/\/eloquent\/.*\.php$/i,/\/migrations?\/.*\.php$/i,/\/seeders?\/.*\.php$/i,/\/factories?\/.*\.php$/i,/\/repositories?\/.*\.php$/i,/\/resources?\/.*\.php$/i],gg=["laravel","symfony","slim","cakephp","codeigniter"]});import vg from"path";function Xn(n,e,r){let i=[],t="Unknown",o=0;r||(r=oS(n,e));let{inDegree:s,outDegree:a}=r,c=(p,m,f,h)=>{for(let _ of p)if(_.test(n))return i.push(`${h}: ${_.source}`),t=m,o+=f,!0;return!1},l=!1;if(l||(l=c(To,"Entry",45,"Next.js entry")),l||(l=c(Qh,"Entry",40,"MCP handler")),l||(l=c(tg,"Entry",40,"CLI command")),l||(l=c(ri,"Data",45,"Data layer/Repository")),l||(l=c(og,"Data",35,"State management")),l||(l=c(Xh,"Logic",40,"React component")),l||(l=c(Ro,"Logic",35,"Logic pattern")),l||(l=c(ng,"Logic",35,"Parser/AST")),l||(l=c(rg,"Logic",35,"Core module")),l||(l=c(ig,"Logic",30,"UI layer")),l||(l=c(cg,"Types",35,"Type definition")),l||(l=c(zo,"Entry",40,"Python Entry")),l||(l=c(Do,"Data",40,"Python Data")),l||(l=c(pg,"Logic",35,"Python Logic")),l||(l=c(Co,"Entry",40,"PHP Entry")),l||(l=c(Lo,"Data",40,"PHP Data")),l||(l=c(hg,"Logic",35,"PHP Logic")),l||(l=c(sg,"Logic",35,"Hook/Context")),!l){for(let p of eg)if(p.test(n)){i.push(`MCP utility: ${p.source}`),/schemas?/i.test(n)?t="Types":/resources?/i.test(n)?t="Data":t="Utility",o+=35,l=!0;break}}l||c(ag,"Data",35,"Schema definition")&&(l=!0),l||(c(ri,"Data",30,"Path matches data pattern")||c(No,"Utility",25,"Path matches utility pattern")||c(Po,"Entry",30,"Path matches entry pattern"))&&(l=!0);for(let p of Dc)if(p.test(n)){i.push(`Test file: ${p.source}`),t="Test",o=50,l=!0;break}l||c(Cc,"Infrastructure",40,"Infrastructure")&&(l=!0);for(let p of iS)p.test(n)&&(i.push(`Monorepo component: ${p.source}`),/\/apps\/[^/]+\/src\/pages\//i.test(n)&&(i.push("Monorepo App Entry"),t==="Unknown"&&(t="Entry"),o+=20),/\/packages\/[^/]+\/src\//i.test(n)&&(o+=10));let d=e.imports.getImportsForFile(n).map(p=>p.module_specifier.toLowerCase());for(let p of ug)if(d.some(m=>m.includes(p))){i.push(`Imports JS data library: ${p}`),(t==="Unknown"||t==="Data")&&(t="Data",o+=25);break}for(let p of mg)if(d.some(m=>m.includes(p))){i.push(`Imports Python framework: ${p}`),(t==="Unknown"||t==="Entry")&&(t="Entry",o+=20);break}for(let p of gg)if(d.some(m=>m.includes(p))){i.push(`Imports PHP framework: ${p}`),(t==="Unknown"||t==="Entry")&&(t="Entry",o+=20);break}for(let p of lg)if(d.some(m=>m.includes(p))){i.push(`Imports JS framework: ${p}`),(t==="Unknown"||t==="Entry")&&(t="Entry",o+=20);break}if(s===0&&a>0&&(i.push("Entry point: nothing imports this file (in-degree=0)"),t==="Unknown"?(t="Entry",o+=30):t==="Entry"&&(o+=15)),s>5&&a<=2&&(i.push(`High reuse: ${s} files import this (candidate for Utility)`),t==="Unknown"?(t="Utility",o+=25):t==="Utility"&&(o+=10)),t==="Unknown"&&s>0&&a>0){let p=s/(s+a);p>.3&&p<.7&&(i.push(`Balanced traffic: in=${s}, out=${a} (likely Logic layer)`),t="Logic",o+=25)}return t==="Unknown"&&(i.push("No strong classification signals detected"),o=10),o=Math.min(o,100),{layer:t,confidence:o,signals:i}}function oS(n,e){let r=e.imports.countDependents(n),i=e.imports.countByFile(n);return{inDegree:r,outDegree:i}}function Ze(n,e){let r=n.files.getAllPaths().map(f=>({path:f})),i=new Map,t={Entry:[],Logic:[],Data:[],Utility:[],Infrastructure:[],Test:[],Types:[],Unknown:[]};for(let f of r){let h=Xn(f.path,n);i.set(f.path,h),t[h.layer].push({path:f.path,classification:h})}let o={Entry:Vt(t.Entry,e),Logic:Vt(t.Logic,e),Data:Vt(t.Data,e),Utility:Vt(t.Utility,e),Infrastructure:Vt(t.Infrastructure,e),Test:Vt(t.Test,e),Types:Vt(t.Types,e),Unknown:Vt(t.Unknown,e)},s={};r.forEach(f=>{let h=vg.extname(f.path).toLowerCase();h&&(s[h]=(s[h]||0)+1)});let a={".ts":"TypeScript",".tsx":"Typescript (React)",".js":"JavaScript",".jsx":"JavaScript (React)",".py":"Python",".php":"PHP",".go":"Go",".rs":"Rust",".java":"Java",".cs":"C#",".rb":"Ruby",".vue":"Vue"},c={};Object.entries(s).forEach(([f,h])=>{let _=a[f];_&&(c[_]=(c[_]||0)+h)});let l=Object.entries(c).sort((f,h)=>h[1]-f[1]),u=l.length>0?l[0][0]:"Unknown",{pattern:d,patternConfidence:p,insights:m}=sS(o,r.length,n);return{pattern:d,patternConfidence:p,layers:o,insights:m,primaryStack:u}}function Vt(n,e){return n.sort((r,i)=>i.classification.confidence-r.classification.confidence),{count:n.length,topFiles:n.slice(0,5).map(r=>({path:vg.relative(e,r.path),confidence:r.classification.confidence,signals:r.classification.signals.slice(0,2)}))}}function sS(n,e,r){let i=[],t="Unknown",o=0,s=n.Entry.count/e*100,a=n.Logic.count/e*100,c=n.Data.count/e*100,l=n.Utility.count/e*100,u=n.Unknown.count/e*100;s>5&&a>10&&c>5&&u<40?(t="Layered",o=60+Math.min(30,(100-u)/3),i.push(`Clear layer separation: Entry (${s.toFixed(1)}%), Logic (${a.toFixed(1)}%), Data (${c.toFixed(1)}%)`)):l>20?(t="Modular",o=50+l/2,i.push(`High shared module usage: ${l.toFixed(1)}% utility files`)):u>60&&(t="Monolithic",o=40+u/4,i.push(`Limited architectural structure: ${u.toFixed(1)}% files with unclear layer assignment`));let d=r.configs.countByKind("Service");return d>3&&(t="Microservices",o=55+d*5,i.push(`Detected ${d} service definitions (likely microservices)`)),n.Entry.count===0&&i.push("\u26A0\uFE0F No clear entry points detected - consider adding route/controller files"),n.Data.count===0&&i.push("\u26A0\uFE0F No data layer detected - repository may not use traditional ORM patterns"),l>30&&i.push(`High utility concentration (${l.toFixed(1)}%) - good reusability`),{pattern:t,patternConfidence:Math.min(100,o),insights:i}}var Dc,Cc,iS,_t=ge(()=>{"use strict";Rc();Nc();zc();Dc=[/\.(test|spec)\.(ts|tsx|js|jsx)$/i,/tests?\.py$/i,/\/__tests__\//i,/\/tests?\//i,/\.e2e\.(ts|js)$/i,/\.integration\.(ts|js)$/i],Cc=[/Dockerfile/i,/docker-compose/i,/\.ya?ml$/i,/nginx\.conf/i,/\/infra\//i,/\/deploy\//i,/\/k8s\//i,/\/kubernetes\//i,/\/terraform\//i,/\/ansible\//i,/package\.json/i,/tsconfig.*\.json/i,/\.env/i],iS=[/\/apps\/[^/]+\//i,/\/services\/[^/]+\//i,/\/packages\/[^/]+\//i,/\/backends\/[^/]+\//i,/\/backends_python\/[^/]+\//i]});var wg={};Ke(wg,{HologramService:()=>le});var dt,le,He=ge(()=>{"use strict";X();_t();G();dt=x.child({module:"hologram"}),le=class{repos;repoPath;constructor(e){this.repoPath=e,this.repos=z.getInstance(e)}updateTopography(e){dt.debug({repoPath:this.repoPath},"Updating topography snapshot");let r=Object.values(e.layers).reduce((o,s)=>o+s.count,0),i={};for(let[o,s]of Object.entries(e.layers)){let a=r>0?s.count/r*100:0;i[o]={count:s.count,percentage:Math.round(a*10)/10,topFiles:s.topFiles.slice(0,3).map(c=>({path:c.path,confidence:c.confidence}))}}let t={pattern:e.pattern,patternConfidence:e.patternConfidence,layerDistribution:i,insights:e.insights,updatedAt:Date.now()};this.repos.hologram.upsertSection("topography",JSON.stringify(t)),dt.info({repoPath:this.repoPath},"Topography snapshot updated")}refreshTopography(){let e=Ze(this.repos,this.repoPath);this.updateTopography(e)}updateGravityZones(e){dt.debug({repoPath:this.repoPath,count:e.length},"Updating gravity zones");let r={hotspots:e.slice(0,50),updatedAt:Date.now()};this.repos.hologram.upsertSection("gravity",JSON.stringify(r)),dt.info({repoPath:this.repoPath},"Gravity zones updated")}updateGhostBridges(e){dt.debug({repoPath:this.repoPath,count:e.length},"Updating ghost bridges");let r={bridges:e.slice(0,20),updatedAt:Date.now()};this.repos.hologram.upsertSection("ghosts",JSON.stringify(r)),dt.info({repoPath:this.repoPath},"Ghost bridges updated")}getSnapshot(){let e=this.repos.hologram.getAllSections(),r={metadata:{repoPath:this.repoPath,lastUpdated:Date.now(),version:"1.0.0"}};for(let i of e)try{let t=JSON.parse(i.data);switch(i.section){case"topography":r.topography=t;break;case"gravity":r.gravity=t;break;case"ghosts":r.ghosts=t;break}}catch(t){dt.error({repoPath:this.repoPath,section:i.section,error:t},"Failed to parse hologram section")}return r}getSection(e){let r=this.repos.hologram.getSection(e);if(!r)return null;try{return JSON.parse(r.data)}catch(i){return dt.error({repoPath:this.repoPath,section:e,error:i},"Failed to parse section"),null}}computeGravityZones(){dt.debug({repoPath:this.repoPath},"Computing gravity zones from import graph");let e=this.repos.files.getAllPaths(),r=new Map;for(let t of e){let o=Xn(t,this.repos);if(o.layer==="Test"||o.layer==="Unknown")continue;let s=this.repos.exports.findByFile(t);if(s.length===0)continue;let a=this.repos.imports.countDependents(t),c=this.repos.imports.countByFile(t),l=a*2+c;if(l>0){let u=s.find(p=>p.kind!=="TsTypeAliasDeclaration"&&p.kind!=="TsInterfaceDeclaration")||s[0],d=`${t}::${u.name}`;r.set(d,{symbol:u.name,filePath:t,inDegree:a,outDegree:c,gravity:l})}}let i=Array.from(r.values()).sort((t,o)=>o.gravity-t.gravity).slice(0,50);return dt.info({repoPath:this.repoPath,count:i.length},"Gravity zones computed"),i}isInitialized(){return this.repos.hologram.getAllSections().length>0}clear(){this.repos.hologram.deleteAll(),dt.info({repoPath:this.repoPath},"Hologram cleared")}}});var Lb={};Ke(Lb,{GraphExporterService:()=>Fa});var Cb,Fa,Gm=ge(()=>{"use strict";X();G();Cb=x.child({module:"graph-exporter"}),Fa=class{constructor(e){this.repoPath=e;this.repos=z.getInstance(e)}repos;async generateGraph(e={}){let{includeCompleted:r=!0,format:i="mermaid",focusMissionId:t,depth:o=10,limit:s=100}=e;Cb.info({focusMissionId:t,depth:o,format:i,includeCompleted:r},"Generating mission graph");let a=this.buildMissionTree(t,r,o,s);return i==="json"?JSON.stringify(a,null,2):this.generateMermaidDiagram(a)}buildMissionTree(e,r,i,t){let o;if(e){let c=this.repos.missions.findById(e);o=c?[c]:[]}else o=this.repos.missions.findAll().filter(l=>!l.parent_id),r||(o=o.filter(l=>l.status!=="completed"));let s=0,a=[];for(let c of o){if(s>=t)break;let l=this.buildNode(c,r,i,1,{count:s,max:t});l&&(a.push(l),s+=this.countNodes(l))}return a}buildNode(e,r,i,t,o){if(t>i||o.count>=o.max)return null;let s;if(e.strategy_graph)try{let u=JSON.parse(e.strategy_graph);s=this.parseStrategySteps(u)}catch(u){Cb.debug({missionId:e.id,err:u},"Failed to parse strategy graph")}let a={id:e.id,name:e.name,status:e.status,goal:e.goal,branch:e.git_branch||void 0,children:[],steps:s},c=this.repos.missions.findByParentId(e.id),l=r?c:c.filter(u=>u.status!=="completed");for(let u of l){if(o.count>=o.max)break;let d=this.buildNode(u,r,i,t+1,o);d&&(a.children.push(d),o.count++)}return a}parseStrategySteps(e){let r=[];return Array.isArray(e)?e.map((i,t)=>({id:i.id||`step-${t}`,description:i.description||i.content||i.name||`Step ${t+1}`,status:i.status,dependencies:i.dependencies||i.deps})):e.steps&&Array.isArray(e.steps)?this.parseStrategySteps(e.steps):typeof e=="object"?Object.entries(e).map(([i,t])=>({id:i,description:t.description||t.content||i,status:t.status,dependencies:t.dependencies||t.deps})):r}countNodes(e){let r=1;for(let i of e.children)r+=this.countNodes(i);return r}generateMermaidDiagram(e){let r=["graph TD"];for(let i of e)this.addMermaidNode(i,r);return r.join(`
461
+ `)}addMermaidNode(e,r,i){let t=`M${e.id}`,o=this.getStatusIcon(e.status),s=this.getStatusClass(e.status),a=`${o} ${e.name}`;if(r.push(` ${t}["${this.escapeMermaid(a)}"]:::${s}`),i&&r.push(` ${i} --> ${t}`),e.steps&&e.steps.length>0&&e.steps.length<=10)for(let c of e.steps){let l=`S${e.id}_${c.id}`,u=c.status||"pending",d=this.getStatusIcon(u),p=this.getStatusClass(u),m=`${d} ${c.description}`;if(r.push(` ${l}["${this.escapeMermaid(m)}"]:::${p}`),r.push(` ${t} -.-> ${l}`),c.dependencies&&c.dependencies.length>0)for(let f of c.dependencies){let h=`S${e.id}_${f}`;r.push(` ${h} --> ${l}`)}}for(let c of e.children)this.addMermaidNode(c,r,t);i||(r.push(""),r.push(" classDef completed fill:#90EE90,stroke:#2E8B57,stroke-width:2px"),r.push(" classDef inProgress fill:#87CEEB,stroke:#4682B4,stroke-width:2px"),r.push(" classDef planned fill:#FFE4B5,stroke:#DAA520,stroke-width:2px"),r.push(" classDef suspended fill:#D3D3D3,stroke:#808080,stroke-width:2px"),r.push(" classDef failed fill:#FFB6C1,stroke:#DC143C,stroke-width:2px"),r.push(" classDef pending fill:#FFF8DC,stroke:#B8860B,stroke-width:1px"))}getStatusIcon(e){return{completed:"\u2713","in-progress":"\u26A1",planned:"\u{1F4CB}",suspended:"\u23F8",failed:"\u2717",pending:"\u25CB",verifying:"\u{1F50D}"}[e]||"\u25CB"}getStatusClass(e){return{completed:"completed","in-progress":"inProgress",planned:"planned",suspended:"suspended",failed:"failed",pending:"pending",verifying:"inProgress"}[e]||"pending"}escapeMermaid(e){return e.replace(/"/g,"#quot;").replace(/\n/g," ").replace(/\[/g,"#91;").replace(/]/g,"#93;").slice(0,100)}}});import"dotenv/config";import{Cli as bE}from"clerc";G();import Df from"fs";import Y_ from"path";import Cf from"js-yaml";var Lf={ignore:[],include:[],maxDepth:10},X_=[{name:".liquid-shadow.yaml",parse:n=>Cf.load(n)??{}},{name:".liquid-shadow.yml",parse:n=>Cf.load(n)??{}},{name:".ls.json",parse:n=>JSON.parse(n)},{name:".liquid-shadow.json",parse:n=>JSON.parse(n)},{name:".ls.rc",parse:n=>JSON.parse(n)},{name:".liquid-shadow.rc",parse:n=>JSON.parse(n)}];function Pt(n){for(let{name:e,parse:r}of X_){let i=Y_.join(n,e);if(Df.existsSync(i))try{let t=Df.readFileSync(i,"utf8"),o=r(t);return x.debug({repoPath:n,configFile:e},"Loaded repository configuration"),{...Lf,...o}}catch(t){x.error({repoPath:n,file:e,err:t},"Failed to parse configuration file")}}return Lf}function oc(n,e){let i=Pt(n).cli??{};return{dir:e.dir??i.dir??".",level:e.level??i.level,deep:e.deep!==void 0?e.deep:i.deep}}X();import wx from"path";var Ie=J_(dh(),1);import*as gt from"@clack/prompts";var ae={red:Ie.default.red,green:Ie.default.green,yellow:Ie.default.yellow,blue:Ie.default.blue,magenta:Ie.default.magenta,cyan:Ie.default.cyan,white:Ie.default.white,gray:Ie.default.gray,bold:Ie.default.bold,dim:Ie.default.dim,italic:Ie.default.italic,underline:Ie.default.underline,inverse:Ie.default.inverse},Wt=n=>n.replace(/\x1b\[[0-9;]*m/g,""),we=n=>gt.intro(Ie.default.bgCyan(Ie.default.black(Ie.default.bold(` ${n} `)))),at=n=>gt.outro(Ie.default.cyan(n)),be=(n,e,r="blue")=>{let i=e.split(`
462
+ `),t=Wt(n),o=Math.max(t.length+4,...i.map(c=>Wt(c).length))+2,s="\u2500".repeat(o),a=ae[r];console.log(a(`\u250C${s}\u2510`)),console.log(a("\u2502 ")+ae.bold(n).padEnd(o+(n.length-t.length)-1)+a("\u2502")),console.log(a(`\u251C${s}\u2524`)),i.forEach(c=>{let l=Wt(c),u=" ".repeat(o-l.length-1);console.log(a("\u2502 ")+c+u+a("\u2502"))}),console.log(a(`\u2514${s}\u2518`))},po=(n,e)=>{let r=n.map((t,o)=>Math.max(Wt(t).length,...e.map(s=>Wt(s[o]||"").length))+2),i=ae.cyan("\u2502");console.log(i),console.log(i+" "+n.map((t,o)=>ae.bold(ae.cyan(t)).padEnd(r[o]+(t.length-Wt(t).length))).join(ae.gray(" "))+" "),e.forEach(t=>{console.log(i+" "+t.map((o,s)=>(o||"").padEnd(r[s]+(o.length-Wt(o).length))).join(ae.gray(" "))+" ")}),console.log(i)},ph=(n,e="\u2022")=>{n.forEach(r=>{console.log(`${ae.cyan("\u2502")} ${ae.cyan(e)} ${r}`)})},mo=(n,e=40)=>{let r=Math.max(...n.map(t=>t.value)),i=Math.max(...n.map(t=>Wt(t.label).length));console.log(ae.cyan("\u2502")),n.forEach(t=>{let o=Math.round(t.value/r*e),s="\u2588".repeat(o)+ae.dim("\u2591".repeat(e-o)),a=t.color?ae[t.color]:ae.cyan,c=t.label.padEnd(i);console.log(`${ae.cyan("\u2502")} ${ae.bold(c)} ${a(s)} ${ae.white(t.value.toString())}`)}),console.log(ae.cyan("\u2502"))},fc=(n,e="")=>{n.forEach((r,i)=>{let t=i===n.length-1,o=t?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ",s=r.color?ae[r.color]:r.children?ae.blue:ae.white,a=r.info?` ${ae.gray(`(${r.info})`)}`:"";if(console.log(`${ae.cyan("\u2502")} ${e}${ae.gray(o)}${s(r.name)}${a}`),r.children&&r.children.length>0){let c=e+(t?" ":"\u2502 ");fc(r.children,c)}})},Ye=()=>gt.spinner();async function fo(n,e,r){if(e.length===0)return;let i=await gt.select({message:n,options:e.map(t=>({value:t.value,label:t.label,...t.hint!=null&&{hint:t.hint}})),...r?.limit!=null&&{maxItems:r.limit}});if(!gt.isCancel(i))return i}var $x=n=>{console.error("");let e=n instanceof Error?n.message:String(n);console.error(` ${ae.red("\u2716")} ${ae.bold("Error: ")} ${e}`),n instanceof Error&&"cause"in n&&console.error(` ${ae.dim("Cause: "+String(n.cause))}`),console.error(""),process.exit(1)},re=async n=>{try{await n()}catch(e){$x(e)}},b=ae;Nt();st();G();async function ce(n){x.debug("Performing graceful shutdown...");try{await bn()}catch(e){x.error({err:e},"Error shutting down worker pool")}try{n&&Br(n)}catch(e){x.error({err:e},"Error closing database")}x.debug("Shutdown complete")}async function mh(n){let e=wx.resolve(n);try{await re(async()=>{we("\u{1F311} Liquid Shadow: Scouting Report");let r=z.getInstance(e),i=Pt(e),t=i.ignore&&i.ignore.length>0,o=r.files.getCount(),s=r.exports.getCount(),a=r.files.getLatestScanTime(),c=r.exports.getKindDistribution(5);be("Intelligence Summary",`${b.bold("\u{1F4E1} Topology")}: ${b.cyan(o.toString())} files mapped
463
+ ${b.bold("\u{1F9E9} Symbols")}: ${b.cyan(s.toString())} exports detected
464
+ ${b.bold("\u{1F552} Last Sync")}: ${a?b.yellow(new Date(a).toLocaleString()):b.red("Never")}
465
+ ${b.bold("\u2699\uFE0F Config")}: ${t?b.green("Custom Intelligence"):b.gray("Standard Sieve")}`,"blue"),c.length>0&&(console.log(""),console.log(` ${b.bold("Symbol Distribution (Top 5)")}`),mo(c.map(l=>({label:l.kind,value:l.c,color:"cyan"})),30)),console.log(""),console.log(` ${b.dim("Pro-tip: Try")} ${b.bold(b.cyan("liquid-shadow dashboard"))} ${b.dim("for the full tactical view.")}`),console.log(""),at("Scouting complete.")})}finally{await ce(e)}}X();st();import yh from"path";var hc=class{startTime=Date.now();indexRuns=0;indexCacheHits=0;lastIndexDurationMs=null;lastIndexCompletedAt=null;lastRunPhases=[];queryCount=0;lastQueryLatencyMs=null;recentLatencySumMs=0;recentLatencyCount=0;recentLatencies=[];searchHistoryFailureCount=0;recordIndexStart(){this.indexRuns+=1}recordIndexCacheHit(){this.indexCacheHits+=1}recordIndexEnd(e){this.lastIndexDurationMs=e,this.lastIndexCompletedAt=Date.now()}recordIndexPhase(e,r){this.lastRunPhases.push({phase:e,durationMs:r})}clearIndexPhases(){this.lastRunPhases=[]}recordQueryStart(){let e=performance.now();return()=>{this.queryCount+=1;let r=performance.now()-e;if(this.lastQueryLatencyMs=r,this.recentLatencies.push(r),this.recentLatencies.length>100){let i=this.recentLatencies.shift();this.recentLatencySumMs=this.recentLatencySumMs-i+r}else this.recentLatencySumMs+=r,this.recentLatencyCount=this.recentLatencies.length}}recordSearchHistoryFailure(){this.searchHistoryFailureCount+=1}getSnapshot(){let e=this.recentLatencies.length,r=e>0?this.recentLatencies.reduce((i,t)=>i+t,0)/e:null;return{index:{runs:this.indexRuns,cacheHits:this.indexCacheHits,lastDurationMs:this.lastIndexDurationMs,lastCompletedAt:this.lastIndexCompletedAt,lastRunPhases:[...this.lastRunPhases]},query:{count:this.queryCount,lastLatencyMs:this.lastQueryLatencyMs,recentLatencySumMs:this.recentLatencySumMs,recentLatencyCount:e,avgLatencyMs:r,searchHistoryFailures:this.searchHistoryFailureCount},uptimeMs:Date.now()-this.startTime}}reset(){this.indexRuns=0,this.indexCacheHits=0,this.lastIndexDurationMs=null,this.lastIndexCompletedAt=null,this.lastRunPhases=[],this.queryCount=0,this.lastQueryLatencyMs=null,this.recentLatencySumMs=0,this.recentLatencyCount=0,this.recentLatencies=[],this.searchHistoryFailureCount=0}},Bt=new hc;function fh(){Bt.recordIndexStart()}function ho(){Bt.recordIndexCacheHit()}function hh(n){Bt.recordIndexEnd(n)}function Kr(n,e){Bt.recordIndexPhase(n,e)}function gh(){Bt.clearIndexPhases()}function _n(){return Bt.recordQueryStart()}function yt(){Bt.recordSearchHistoryFailure()}function xn(){return Bt.getSnapshot()}G();import Ue from"fs";import Sn from"path";var Gn=x.child({module:"git-hooks"}),go={"post-merge":`#!/bin/sh
429
466
  # Liquid Shadow: Auto-refresh index after merge/pull
430
467
  # Generated by liquid-shadow
431
468
 
@@ -459,22 +496,30 @@ REPO_PATH="$(git rev-parse --show-toplevel)"
459
496
  nohup npx @precisionutilityguild/liquid-shadow sync "$REPO_PATH" > /dev/null 2>&1 &
460
497
 
461
498
  exit 0
462
- `};function Si(i){let{repoPath:e,enableAutoRefresh:t=!0,enableSymbolHealing:n=!0}=i,s=Ke.join(e,".git","hooks"),r=[],o=[],c=[];if(!oe.existsSync(Ke.join(e,".git")))return c.push("Not a git repository"),{installed:r,skipped:o,errors:c};oe.existsSync(s)||oe.mkdirSync(s,{recursive:!0});let a=[];t&&a.push("post-merge","post-checkout"),n&&a.push("post-commit");for(let l of a){let p=Ke.join(s,l),d=dn[l];if(!d){c.push(`No template found for hook: ${l}`);continue}try{if(oe.existsSync(p)){let u=oe.readFileSync(p,"utf-8");if(u.includes("liquid-shadow")||u.includes("mcp-liquid-shadow")){o.push(l),rt.info({hookName:l},"Hook already installed, skipping");continue}let m=`${p}.backup-${Date.now()}`;oe.copyFileSync(p,m),rt.info({hookName:l,backupPath:m},"Backed up existing hook")}oe.writeFileSync(p,d,{mode:493}),r.push(l),rt.info({hookName:l},"Installed git hook")}catch(u){c.push(`Failed to install ${l}: ${u}`),rt.error({hookName:l,err:u},"Failed to install hook")}}return{installed:r,skipped:o,errors:c}}function _i(i){let e=Ke.join(i,".git","hooks"),t=[],n=[];if(!oe.existsSync(e))return{removed:t,errors:n};let s=Object.keys(dn);for(let r of s){let o=Ke.join(e,r);try{if(oe.existsSync(o)){let c=oe.readFileSync(o,"utf-8");(c.includes("liquid-shadow")||c.includes("mcp-liquid-shadow"))&&(oe.unlinkSync(o),t.push(r),rt.info({hookName:r},"Removed git hook"))}}catch(c){n.push(`Failed to remove ${r}: ${c}`),rt.error({hookName:r,err:c},"Failed to remove hook")}}return{removed:t,errors:n}}function mn(i){let e=Ke.join(i,".git","hooks"),t=[],n=[];if(!oe.existsSync(e))return{installed:t,notInstalled:Object.keys(dn)};let s=Object.keys(dn);for(let r of s){let o=Ke.join(e,r);if(oe.existsSync(o)){let c=oe.readFileSync(o,"utf-8");c.includes("liquid-shadow")||c.includes("mcp-liquid-shadow")?t.push(r):n.push(r)}else n.push(r)}return{installed:t,notInstalled:n}}var cs=class{startTime=Date.now();indexRuns=0;indexCacheHits=0;lastIndexDurationMs=null;lastIndexCompletedAt=null;lastRunPhases=[];queryCount=0;lastQueryLatencyMs=null;recentLatencySumMs=0;recentLatencyCount=0;recentLatencies=[];searchHistoryFailureCount=0;recordIndexStart(){this.indexRuns+=1}recordIndexCacheHit(){this.indexCacheHits+=1}recordIndexEnd(e){this.lastIndexDurationMs=e,this.lastIndexCompletedAt=Date.now()}recordIndexPhase(e,t){this.lastRunPhases.push({phase:e,durationMs:t})}clearIndexPhases(){this.lastRunPhases=[]}recordQueryStart(){let e=performance.now();return()=>{this.queryCount+=1;let t=performance.now()-e;if(this.lastQueryLatencyMs=t,this.recentLatencies.push(t),this.recentLatencies.length>100){let n=this.recentLatencies.shift();this.recentLatencySumMs=this.recentLatencySumMs-n+t}else this.recentLatencySumMs+=t,this.recentLatencyCount=this.recentLatencies.length}}recordSearchHistoryFailure(){this.searchHistoryFailureCount+=1}getSnapshot(){let e=this.recentLatencies.length,t=e>0?this.recentLatencies.reduce((n,s)=>n+s,0)/e:null;return{index:{runs:this.indexRuns,cacheHits:this.indexCacheHits,lastDurationMs:this.lastIndexDurationMs,lastCompletedAt:this.lastIndexCompletedAt,lastRunPhases:[...this.lastRunPhases]},query:{count:this.queryCount,lastLatencyMs:this.lastQueryLatencyMs,recentLatencySumMs:this.recentLatencySumMs,recentLatencyCount:e,avgLatencyMs:t,searchHistoryFailures:this.searchHistoryFailureCount},uptimeMs:Date.now()-this.startTime}}reset(){this.indexRuns=0,this.indexCacheHits=0,this.lastIndexDurationMs=null,this.lastIndexCompletedAt=null,this.lastRunPhases=[],this.queryCount=0,this.lastQueryLatencyMs=null,this.recentLatencySumMs=0,this.recentLatencyCount=0,this.recentLatencies=[],this.searchHistoryFailureCount=0}},De=new cs;function xi(){De.recordIndexStart()}function ls(){De.recordIndexCacheHit()}function Ti(i){De.recordIndexEnd(i)}function hn(i,e){De.recordIndexPhase(i,e)}function Ri(){De.clearIndexPhases()}function fn(){return De.recordQueryStart()}function ot(){De.recordSearchHistoryFailure()}function vi(){return De.getSnapshot()}async function wi(i){let e=$a.resolve(i);try{await B(async()=>{let t=C.getInstance(e),n=mn(e),s=vi(),r=Math.floor(s.uptimeMs/1e3),o=Math.floor(r/60),c=Math.floor(o/60),a=c>0?`${c}h ${o%60}m`:o>0?`${o}m ${r%60}s`:`${r}s`,l=s.index.lastCompletedAt?new Date(s.index.lastCompletedAt).toLocaleString():"Never",p=s.index.lastDurationMs?`${(s.index.lastDurationMs/1e3).toFixed(2)}s`:"N/A",d=s.query.avgLatencyMs?`${s.query.avgLatencyMs.toFixed(2)}ms`:"N/A",u=s.query.lastLatencyMs?`${s.query.lastLatencyMs.toFixed(2)}ms`:"N/A",m=s.index.runs>0?(s.index.cacheHits/s.index.runs*100).toFixed(1):"0.0";se("Performance Metrics",`${E.bold("Uptime")}: ${E.cyan(a)}
463
- ${E.bold("Indexed")}: ${Ve(e)?E.green("Yes"):E.red("No")}
464
- ${E.bold("Files")}: ${E.cyan(t.files.getCount().toString())}
465
- ${E.bold("Exports")}: ${E.cyan(t.exports.getCount().toString())}
466
- ${E.bold("Imports")}: ${E.cyan(t.imports.getCount().toString())}
467
- ${E.bold("Last Indexed Commit")}: ${xt(e)?E.yellow(xt(e).substring(0,7)):E.red("None")}
468
- ${E.bold("Git Hooks")}: ${n.installed?E.green("Installed"):E.yellow("Not Installed")}`,"blue"),console.log(""),se("Index Metrics",`${E.bold("Total Runs")}: ${E.cyan(s.index.runs.toString())}
469
- ${E.bold("Cache Hits")}: ${E.cyan(s.index.cacheHits.toString())}
470
- ${E.bold("Cache Hit Rate")}: ${E.cyan(`${m}%`)}
471
- ${E.bold("Last Duration")}: ${E.yellow(p)}
472
- ${E.bold("Last Completed")}: ${E.yellow(l)}`,"cyan"),s.index.lastRunPhases.length>0&&(console.log(""),console.log(` ${E.bold("Last Index Run Phases:")}`),s.index.lastRunPhases.forEach(f=>{let h=`${(f.durationMs/1e3).toFixed(2)}s`;console.log(` ${E.gray(f.phase.padEnd(20))} ${E.cyan(h)}`)})),console.log(""),se("Query Metrics",`${E.bold("Total Queries")}: ${E.cyan(s.query.count.toString())}
473
- ${E.bold("Avg Latency")}: ${E.yellow(d)}
474
- ${E.bold("Last Latency")}: ${E.yellow(u)}
475
- ${E.bold("Search History Failures")}: ${s.query.searchHistoryFailures>0?E.red(s.query.searchHistoryFailures.toString()):E.green("0")}`,"green")})}finally{await q(e)}}import nr from"path";P();import er from"path";import tc from"ignore";import tr from"fs";import gn from"path";var ka=50;function wt(i,e,t,n){let s={name:gn.basename(e)||e,type:"directory",path:e,children:[]};return i.forEach(r=>{let c=gn.relative(e,r.path).split(gn.sep),a=s;for(let l=0;l<c.length;l++){let p=c[l];if(n!==void 0&&l>=n)return;let d=l===c.length-1;if(n===1&&l===0&&d)return;let u=n!==void 0&&l===n-1&&!d,m=gn.join(e,...c.slice(0,l+1)),f=a.children?.find(h=>h.name===p);if(!f){if(a.children&&a.children.length>=ka){a.children.find(y=>y.type==="truncated")||a.children.push({name:"... (truncated) ",type:"truncated",path:"",children:void 0});return}f={name:p,type:d?"file":"directory",path:m,children:d||u?void 0:[],summary:d?{classification:r.classification,summaryText:r.summary,exports:r.exports,imports:r.imports,chunks:r.chunks}:void 0},f.summary&&(t==="structure"||t==="signatures")&&(delete f.summary.chunks,delete f.summary.imports),a.children?.push(f)}a=f}}),s}import La from"fast-glob";import us from"fs";import Na from"ignore";import Ci from"path";var yn=["**/node_modules/**","**/.git/**","**/dist/**","**/build/**","**/vendor/**","**/.next/**","**/.cache/**","**/coverage/**","**/*.min.js"],Ii=["**/*.{ts,tsx,yaml,yml,php,py,go}","**/*.prisma","**/*.{graphql,gql}","**/Dockerfile*","**/.env*","**/package.json","**/lerna.json","**/turbo.json","**/pnpm-workspace.yaml"],at={MAX_DEPTH:10,MIN_DEPTH:1,MAX_LIMIT:500,MIN_LIMIT:1,MAX_QUERY_LENGTH:500,DEFAULT_DEPTH:3,DEFAULT_LIMIT:10},ae={FILTERED_QUERY_LIMIT_MULTIPLIER:3,SCORE_BASE:1e3,EXACT_MATCH_BONUS:500,RECENT_FILE_BOOST:80,OLDER_FILE_BOOST:30,RECENT_FILE_THRESHOLD_DAYS:7,OLDER_FILE_THRESHOLD_DAYS:30,FUZZY_MATCH_LIMIT:30,ENABLE_LEXICAL_SCORING:process.env.ENABLE_LEXICAL_SCORING!=="false",LEXICAL_WEIGHT:parseFloat(process.env.LEXICAL_WEIGHT??String(.4)),GRAVITY_STRUCTURAL_WEIGHT:.5},ps={SECONDS_PER_DAY:86400,SECONDS_PER_YEAR:31536e3},bn={DEFAULT_CONCURRENCY:parseInt(process.env.INDEX_CONCURRENCY??String(5),10)};async function ds(i,e=[]){let t=Na(),n=Ci.join(i,".gitignore");return us.existsSync(n)&&t.add(us.readFileSync(n,"utf8")),e.length>0&&t.add(e),(await La(Ii,{cwd:i,absolute:!0,ignore:yn})).filter(o=>{let c=Ci.relative(i,o);return!t.ignores(c)}).map(o=>({path:o,mtime:us.statSync(o).mtimeMs}))}import Oa from"@swc/core";import fs from"fs";function $i(i){let e=i.split(`
476
- `),t=[],n=0;for(let s of e)t.push(n),n+=s.length+1;return t}function J(i,e){for(let t=0;t<e.length;t++)if(e[t+1]>i||t===e.length-1)return t+1;return 1}function Y(i,e){return e.slice(0,i).toString("utf8").length}function ki(i,e,t){let n=i.start-e,s=i.end-e;return n<0||s>t.length?"":t.slice(n,s).toString("utf8")}function Li(i){let e=[],t=/\/\*\*[\s\S]*?\*\//g,n;for(;(n=t.exec(i))!==null;)e.push({start:n.index,end:n.index+n[0].length,text:n[0]});return e}function _e(i,e,t){for(let n of e){if(n.start===i)return n.text;if(n.start>i&&n.start<i+50){let s=t.substring(i,n.start);if(/^\s*$/.test(s))return n.text}if(n.end<=i&&n.end>i-50){let s=t.substring(n.end,i);if(/^\s*$/.test(s))return n.text}}return""}function Ni(i){if(!i)return"";let t=i.replace(/\/\*\*|\*\/|\*/g,"").trim().split(`
477
- `)[0].trim();return t.length>200?t.substring(0,197)+"...":t}function En(i,e,t){let n=i.toLowerCase(),s=e.toLowerCase();return n.includes("components/")||n.endsWith(".tsx")?"Component":n.startsWith("use")||s.startsWith("use")?"Hook":n.includes("models/")||s.endsWith("model")?"Model":n.includes("services/")||n.includes("controllers/")||n.includes("handlers/")||n.includes("mcp/")||n.endsWith("service.ts")||n.endsWith("controller.ts")||n.endsWith("handler.ts")||s.endsWith("service")||s.endsWith("controller")||s.endsWith("handler")?"Service":n.includes("repositories/")||n.includes("repos/")||n.endsWith("repository.ts")||n.endsWith("repo.ts")||s.endsWith("repository")||s.endsWith("repo")?"Repository":t==="TsInterfaceDeclaration"||t==="TsTypeAliasDeclaration"?"Type Definition":"Other"}function It(i){let e=[];return/\b(fetch|axios|superagent|got)\s*\(|import\s+.*\b(http|https|node-fetch)\b/i.test(i)&&e.push("Network"),(/\b(knex|prisma|typeorm|mongoose|sequelize|pg|mysql|sqlite3)\b/i.test(i)||/\b(SELECT\s+.*FROM|INSERT\s+INTO|UPDATE\s+.*SET|DELETE\s+FROM)\b/i.test(i)||/\.query\s*\(|\.execute\s*\(/i.test(i)&&/db|database|client|pool/i.test(i))&&e.push("Database"),(/\bfs\./i.test(i)||/\b(readFileSync|writeFileSync|readFile|writeFile|readdir)\b/.test(i)||/import\s+.*\bfs\b/.test(i))&&e.push("File System"),(/\b(localStorage|sessionStorage|indexedDB)\./.test(i)||/\bdocument\.cookie\b/.test(i))&&e.push("Browser Storage"),e}function xe(i,e){if(!i)return"";let t=i.replace(/^([\s\S]*?\*\/)?\s*/,"").replace(/^.*\} from ['"].*['"];?\s*/,"").replace(/^import .*['"];?\s*/,"").trim();if(e==="TsInterfaceDeclaration"||e==="TsTypeAliasDeclaration")return t;let n=0,s=0,r=t.length;for(let o=0;o<t.length;o++){let c=t[o];if(c==="(")n++;else if(c===")")n--;else if(c==="<")s++;else if(c===">")s--;else if(c==="{"){if(n===0&&s===0){r=o;break}}else if(c==="; "&&n===0&&s===0){r=o;break}else if(c==="="&&t[o+1]===">"&&n===0&&s===0){r=o+2;break}}return t.substring(0,r).trim()}function Ai(i){let e=[];for(let t of i)t.type==="ImportDeclaration"&&e.push({module:t.source.value,name:t.specifiers.map(n=>n.type==="ImportDefaultSpecifier"?"default":n.type==="ImportNamespaceSpecifier"?"*":n.local?.value||n.imported?.value||"*").join("","")}),t.type==="ExportAllDeclaration"&&e.push({module:t.source.value,name:"*"}),t.type==="ExportNamedDeclaration"&&t.source&&e.push({module:t.source.value,name:t.specifiers.map(n=>n.type==="ExportSpecifier"?n.orig.value:"*").join(", ")});return e}function Mi(i,e,t,n,s,r,o,c){let a=[];for(let l of i){if(l.type==="ExportDeclaration"){let p=l.declaration,d=p.type,u="";d==="VariableDeclaration"?u=p.declarations.map(g=>g.id.value).join("",""):u=p.id?.value||p.identifier?.value||"anonymous";let m=Y(l.span.start-e,t),f=Y(l.span.end-e,t),h=_e(m,r,n),b=c(l.span),y=[];if(l.type==="ExportDeclaration"&&(d==="ClassDeclaration"||d==="ClassExpression")){let g=p.body||[];for(let S of g)if(S.type==="ClassMethod"||S.type==="ClassProperty"){let R=S.key.value;if(!R)continue;let w=Y(S.span.start-e,t),T=Y(S.span.end-e,t),v=c(S.span),k=_e(w,r,n);y.push({name:R,kind:S.type,signature:xe(v,S.type),line:J(w,s),endLine:J(T,s),doc:k,classification:S.type==="ClassMethod"?"Method":"Property",capabilities:"[]"})}}else if(d==="FunctionDeclaration"&&p.body?.type==="BlockStatement")y=ms(p.body.stmts,e,t,n,s,r,c);else if(d==="VariableDeclaration"){for(let g of p.declarations)if(g.init&&(g.init.type==="ArrowFunctionExpression"||g.init.type==="FunctionExpression")&&g.init.body?.type==="BlockStatement"){y=ms(g.init.body.stmts,e,t,n,s,r,c);break}}a.push({name:u,kind:d,signature:xe(b,d),line:J(m,s),endLine:J(f,s),doc:h,classification:En(o,u,d),capabilities:JSON.stringify(It(b)),members:y})}if(l.type==="ExportNamedDeclaration"){for(let p of l.specifiers)if(p.type==="ExportSpecifier"){let d=Y(l.span.start-e,t),u=Y(l.span.end-e,t),m=_e(d,r,n);a.push({name:p.exported?.value||p.orig.value,kind:"ExportSpecifier",signature:`export { ${p.orig.value} }`,line:J(d,s),endLine:J(u,s),doc:m,classification:"Export mapping",capabilities:"[]"})}}if(l.type==="ExportDefaultDeclaration"){let p=Y(l.span.start-e,t),d=Y(l.span.end-e,t),u=_e(p,r,n),m=c(l.span),f=[];if(l.decl.type==="ClassExpression"||l.decl.type==="ClassDeclaration"){let h=l.decl.body||[];for(let b of h)if(b.type==="ClassMethod"||b.type==="ClassProperty"){let y=b.key.value;if(!y)continue;let g=Y(b.span.start-e,t),S=Y(b.span.end-e,t),R=c(b.span),w=_e(g,r,n);f.push({name:y,kind:b.type,signature:xe(R,b.type),line:J(g,s),endLine:J(S,s),doc:w,classification:b.type==="ClassMethod"?"Method":"Property",capabilities:"[]"})}}else(l.decl.type==="FunctionExpression"||l.decl.type==="FunctionDeclaration"||l.decl.type==="ArrowFunctionExpression")&&l.decl.body?.type==="BlockStatement"&&(f=ms(l.decl.body.stmts,e,t,n,s,r,c));a.push({name:"default",kind:"DefaultExport",signature:xe(m,"DefaultExport"),line:J(p,s),endLine:J(d,s),doc:u,classification:"Default Export",capabilities:JSON.stringify(It(m)),members:f})}if(l.type==="ExportAllDeclaration"){let p=Y(l.span.start-e,t),d=Y(l.span.end-e,t),u=l.source.value,m=_e(p,r,n);a.push({name:"*",kind:"ExportAllDeclaration",signature:`export * from "${u}"`,line:J(p,s),endLine:J(d,s),doc:m,classification:"Re-export",capabilities:"[]"})}}return a}function ms(i,e,t,n,s,r,o){let c=[];for(let a of i){if(a.type==="VariableDeclaration")for(let l of a.declarations){let p=[],d=u=>{if(u.type==="Identifier")p.push({name:u.value,span:u.span});else if(u.type==="ArrayPattern")for(let m of u.elements)m&&d(m);else if(u.type==="ObjectPattern")for(let m of u.properties)m.type==="AssignmentPatternProperty"?p.push({name:m.key.value,span:m.span}):m.type==="KeyValuePatternProperty"&&d(m.value)};d(l.id);for(let u of p){let m=Y(u.span.start-e,t),f=Y(u.span.end-e,t),h=o(u.span),b=_e(m,r,n);c.push({name:u.name,kind:"VariableDeclaration",signature:xe(h,"VariableDeclaration"),line:J(m,s),endLine:J(f,s),doc:b,classification:"Internal Variable",capabilities:"[]"})}}if(a.type==="FunctionDeclaration"){let l=a.identifier?.value||a.ident?.value||"anonymous",p=Y(a.span.start-e,t),d=Y(a.span.end-e,t),u=o(a.span),m=_e(p,r,n);c.push({name:l,kind:"FunctionDeclaration",signature:xe(u,"FunctionDeclaration"),line:J(p,s),endLine:J(d,s),doc:m,classification:"Internal Function",capabilities:"[]"})}if(a.type==="ReturnStatement"&&a.argument?.type==="ObjectExpression")for(let l of a.argument.properties){let p="",d=l.span||l.key?.span||l.ident?.span;if(l.type==="KeyValueProperty"){let u=l.key;p=u?.value||u?.raw||(u?.type==="Identifier"?u.value:"")}else l.type==="MethodProperty"?p=l.key?.value||l.key?.raw||"":l.type==="ShorthandProperty"?p=l.ident?.value||"":l.type==="Identifier"&&(p=l.value||"");if(p&&d){let u=Y(d.start-e,t),m=Y(d.end-e,t),f=o(d),h=_e(u,r,n);c.push({name:p,kind:"ReturnProperty",signature:xe(f,"ReturnProperty"),line:J(u,s),endLine:J(m,s),doc:h,classification:"Return Member",capabilities:"[]"})}}if(a.type==="ExpressionStatement"&&a.expression.type==="CallExpression"){let l=a.expression;if(l.callee.type==="MemberExpression"&&(l.callee.property?.value==="on"||l.callee.property?.value==="once")){let p=l.arguments[0]?.expression?.value,d=l.arguments[1]?.expression;if(p&&d&&(d.type==="ArrowFunctionExpression"||d.type==="FunctionExpression")){let u=Y(d.span.start-e,t),m=Y(d.span.end-e,t),f=o(d.span);c.push({name:`on:${p}`,kind:d.type,signature:xe(f,d.type),line:J(u,s),endLine:J(m,s),doc:"",classification:"Event Handler",capabilities:"[]"})}}if(l.callee.type==="Identifier"&&l.callee.value==="addRoute"&&l.arguments.length>=3){let p=l.arguments[2].expression;if(p.type==="StringLiteral"){let d=p.value,u=Y(l.span.start-e,t),m=Y(l.span.end-e,t),f=o(l.span);c.push({name:d,kind:"HTTP Route",signature:xe(f,"HTTP Route"),line:J(u,s),endLine:J(m,s),doc:"",classification:"Service Boundary",capabilities:JSON.stringify({path:d})})}}}}return c}function Pi(i,e,t,n,s){let r=[];function o(c){if(!(!c||typeof c!="object")){if(c.type==="CallExpression"){let a=Aa(c);if(a){let l=Y(c.span.start-e,t);r.push({...a,line:J(l,n),snippet:s(c.span)})}}for(let a of Object.keys(c)){if(a==="span")continue;let l=c[a];Array.isArray(l)?l.forEach(o):typeof l=="object"&&o(l)}}}return i.forEach(o),r}function Aa(i){let{callee:e,arguments:t}=i;if(!t||t.length===0)return null;if(e.type==="Identifier"&&e.value,e.type==="Identifier"&&e.value==="addRoute"&&t.length>=3){let n=t[2].expression;if(n.type==="StringLiteral")return{type:"api_route",name:n.value,direction:"consume"}}if(e.type==="MemberExpression"&&e.property?.type==="Identifier"){let n=e.property.value;if(n==="emit"&&t[0].expression.type==="StringLiteral")return{type:"socket_event",name:t[0].expression.value,direction:"produce"};if(n==="on"&&t[0].expression.type==="StringLiteral")return{type:"socket_event",name:t[0].expression.value,direction:"consume"};if(["get","post","put","delete","patch"].includes(n)&&t[0].expression.type==="StringLiteral"){let r=t[0].expression.value,o=e.object.type==="Identifier"?e.object.value:"";if(["axios","http","request","appApi","restApi","adminApi","client"].includes(o))return{type:"api_route",name:r,direction:"produce"};if(r.startsWith("/"))return{type:"api_route",name:r,direction:"consume"}}}return e.type==="Identifier"&&e.value==="fetch"&&t[0].expression.type==="StringLiteral"?{type:"api_route",name:t[0].expression.value,direction:"produce"}:null}function Ct(i){let{classification:e,capabilities:t,exports:n,fileName:s}=i,r={Network:"API integration",Database:"data persistence","File System":"file I/O operations","Browser Storage":"client-side storage"},o=t.map(f=>r[f]).filter(Boolean).join(" and "),a={Component:(f,h)=>{let b=h.find(g=>g.kind==="FunctionDeclaration"||g.kind==="ClassDeclaration")?.name,y=b?`React component: ${b}`:"React UI component";return f?`${y} with ${f}`:y},Hook:(f,h)=>{let b=h.find(g=>g.name.startsWith("use"))?.name,y=b?`Custom React hook: ${b}`:"Custom React hook";return f?`${y} for ${f}`:y},Service:(f,h)=>{let y=`Service layer: ${h[0]?.name||"Service"}`;return f?`${y} handling ${f}`:y},Repository:(f,h)=>`Data repository: ${h[0]?.name||"Repository"} for ${f||"data access"}`,"Type Definition":(f,h)=>`Type definitions: ${h.slice(0,3).map(y=>y.name).join("")}${h.length>3?"...":""}`,Model:(f,h)=>`Data model: ${h[0]?.name||"Model"}`,"HTTP Route":(f,h)=>{let b=h.filter(y=>y.classification==="Service Boundary");return b.length>0?`API endpoints: ${b.slice(0,3).map(y=>y.name).join("")}`:"API route handler"},"Micro IR (PHP)":(f,h)=>{let b=h.some(g=>g.classification==="Service Boundary"),y=h.find(g=>g.kind==="ClassDeclaration")?.name;return b?"PHP controller with API routes":y?`PHP class: ${y}`:"PHP module"},"Micro IR (Python)":(f,h)=>{let b=h.some(g=>g.classification==="Service Boundary"),y=h.find(g=>g.kind==="ClassDeclaration")?.name;return b?"Python API handler with routes":y?`Python class: ${y}`:"Python module"},"Micro IR (Go/TS) ":(f,h)=>{let b=h.some(g=>g.kind==="TypeDeclaration"),y=h.filter(g=>g.kind==="FunctionDeclaration");return b&&y.length>0?`Go package: types and ${y.length} function(s)`:b?"Go package: type definitions":y.length>0?`Go package: ${y[0].name} and ${y.length} function(s)`:"Go module"},"Micro IR (Rust/TS) ":(f,h)=>{let b=h.find(S=>S.kind==="TraitDeclaration")?.name,y=h.find(S=>S.kind==="StructDeclaration")?.name,g=h.filter(S=>S.kind==="FunctionDeclaration");return b?f.includes("Rust trait")?`Rust module: trait ${b}`:`Rust module: ${b}`:y?`Rust module: struct ${y}`:g.length>0?`Rust module: ${g.length} function(s)`:"Rust module"}}[e];if(a)return a(o,n);if(n.length===0)return s?`Module: ${s}`:"Module with no exports";let l=n.filter(f=>f.kind==="FunctionDeclaration"),p=n.filter(f=>f.kind==="ClassDeclaration"),d=n.filter(f=>f.kind==="TsInterfaceDeclaration"||f.kind==="TsTypeAliasDeclaration"),u=[];if(p.length>0&&u.push(`Class: ${p[0].name}`),l.length>0){let f=l.slice(0,2).map(h=>h.name).join("");u.push(`Functions: ${f}`)}d.length>0&&u.push(`Types: ${d.length}`);let m=u.length>0?u.join(" | "):`Module with ${n.length} export(s)`;return o?`${m} \u2014 ${o}`:m}function Di(i){let e=new Set;function t(n){if(!(!n||typeof n!="object")){n.typeAnnotation&&K(n.typeAnnotation,e),(n.type==="TsTypeReference"||n.type==="TsTypeAnnotation")&&K(n,e);for(let s in n){if(s==="span"||s==="comments"||s==="interpreter")continue;let r=n[s];r&&typeof r=="object"&&(Array.isArray(r)?r.forEach(t):t(r))}}}return i.forEach(n=>t(n)),Array.from(e)}function K(i,e){if(i){if(i.type==="TsTypeAnnotation"){K(i.typeAnnotation,e);return}i.type==="TsTypeReference"&&(i.typeName?.type==="Identifier"&&e.add(i.typeName.value),i.typeName?.type==="TsQualifiedName"&&Oi(i.typeName,e),i.typeParams&&K(i.typeParams,e)),i.type==="TsArrayType"&&K(i.elementType,e),i.type==="TsUnionType"&&i.types?.forEach(t=>K(t,e)),i.type==="TsIntersectionType"&&i.types?.forEach(t=>K(t,e)),i.type==="TsTupleType"&&i.elemTypes?.forEach(t=>K(t.ty,e)),(i.type==="TsFunctionType"||i.type==="TsConstructorType")&&(i.params?.forEach(t=>K(t.typeAnnotation,e)),i.typeAnnotation&&K(i.typeAnnotation,e)),i.type==="TsTypeParameterDeclaration"&&i.params?.forEach(t=>{t.constraint&&K(t.constraint,e),t.default&&K(t.default,e)}),i.type==="TsTypeParameterInstantiation"&&i.params?.forEach(t=>K(t,e)),i.type==="TsMappedType"&&i.typeAnnotation&&K(i.typeAnnotation,e),i.type==="TsIndexedAccessType"&&(K(i.objectType,e),K(i.indexType,e)),i.type==="TsConditionalType"&&(K(i.checkType,e),K(i.extendsType,e),K(i.trueType,e),K(i.falseType,e)),i.type==="TsTypeLiteral"&&i.members?.forEach(t=>{t.typeAnnotation&&K(t.typeAnnotation,e)})}}function Oi(i,e){i.type==="TsQualifiedName"?(i.left&&Oi(i.left,e),i.right?.value&&e.add(i.right.value)):i.type==="Identifier"&&e.add(i.value)}import ji from"path";import hs from"path";P();import Hi from"path";import Ma from"fs";import{fileURLToPath as Pa}from"url";import*as Xe from"web-tree-sitter";var ku=Hi.dirname(Pa(import.meta.url)),Fi=_.child({module:"parser:tree-sitter"}),Sn=class{parser=null;languages=new Map;async ensureInitialized(){if(this.parser)return;let e=Xe.Parser||Xe;await e.init(),this.parser=new e}async getLanguage(e){if(this.languages.has(e))return this.languages.get(e);let t=ln("resources","grammars",`tree-sitter-${this.getLangName(e)}.wasm`);if(!Ma.existsSync(t))return Fi.warn({grammarPath:t},"Grammar WASM not found"),null;try{let n=await Xe.Language.load(t);return this.languages.set(e,n),n}catch(n){return Fi.error({err:n,ext:e},"Failed to load language grammar"),null}}getLangName(e){switch(e.toLowerCase()){case".php":return"php";case".py":return"python";case".go":return"go";case".rs":return"rust";default:return""}}getQueries(e){switch(e.toLowerCase()){case".php":return`
499
+ `};function gc(n){let{repoPath:e,enableAutoRefresh:r=!0,enableSymbolHealing:i=!0}=n,t=Sn.join(e,".git","hooks"),o=[],s=[],a=[];if(!Ue.existsSync(Sn.join(e,".git")))return a.push("Not a git repository"),{installed:o,skipped:s,errors:a};Ue.existsSync(t)||Ue.mkdirSync(t,{recursive:!0});let c=[];r&&c.push("post-merge","post-checkout"),i&&c.push("post-commit");for(let l of c){let u=Sn.join(t,l),d=go[l];if(!d){a.push(`No template found for hook: ${l}`);continue}try{if(Ue.existsSync(u)){let p=Ue.readFileSync(u,"utf-8");if(p.includes("liquid-shadow")||p.includes("mcp-liquid-shadow")){s.push(l),Gn.info({hookName:l},"Hook already installed, skipping");continue}let m=`${u}.backup-${Date.now()}`;Ue.copyFileSync(u,m),Gn.info({hookName:l,backupPath:m},"Backed up existing hook")}Ue.writeFileSync(u,d,{mode:493}),o.push(l),Gn.info({hookName:l},"Installed git hook")}catch(p){a.push(`Failed to install ${l}: ${p}`),Gn.error({hookName:l,err:p},"Failed to install hook")}}return{installed:o,skipped:s,errors:a}}function yc(n){let e=Sn.join(n,".git","hooks"),r=[],i=[];if(!Ue.existsSync(e))return{removed:r,errors:i};let t=Object.keys(go);for(let o of t){let s=Sn.join(e,o);try{if(Ue.existsSync(s)){let a=Ue.readFileSync(s,"utf-8");(a.includes("liquid-shadow")||a.includes("mcp-liquid-shadow"))&&(Ue.unlinkSync(s),r.push(o),Gn.info({hookName:o},"Removed git hook"))}}catch(a){i.push(`Failed to remove ${o}: ${a}`),Gn.error({hookName:o,err:a},"Failed to remove hook")}}return{removed:r,errors:i}}function zt(n){let e=Sn.join(n,".git","hooks"),r=[],i=[];if(!Ue.existsSync(e))return{installed:r,notInstalled:Object.keys(go)};let t=Object.keys(go);for(let o of t){let s=Sn.join(e,o);if(Ue.existsSync(s)){let a=Ue.readFileSync(s,"utf-8");a.includes("liquid-shadow")||a.includes("mcp-liquid-shadow")?r.push(o):i.push(o)}else i.push(o)}return{installed:r,notInstalled:i}}async function vc(n){let e=yh.resolve(n);try{await re(async()=>{we("Liquid Shadow Intelligence Dashboard");let r=z.getInstance(e),i=xn(),t=zt(e),o=r.files.getCount(),s=r.exports.getCount(),a=r.files.getLatestScanTime(),c=r.exports.getKindDistribution(5);if(be("Operational Core",`${b.bold("State")}: ${De(e)?b.green("IDENTIFIED (Stable)"):b.red("UNKNOWN (Needs Index)")}
500
+ ${b.bold("Repository")}: ${b.cyan(yh.basename(e))}
501
+ ${b.bold("Infrastructure")}: ${t.installed?b.green("Git-Hooked"):b.yellow("Standalone")}
502
+ ${b.bold("Last Sync")}: ${a?b.yellow(new Date(a).toLocaleString()):b.red("Never")}`,"blue"),console.log(""),be("Intelligence Density",`${b.bold("Files Target")}: ${b.cyan(o.toString())}
503
+ ${b.bold("Symbols Mapped")}: ${b.cyan(s.toString())}
504
+ ${b.bold("Graph Edges")}: ${b.cyan(r.imports.getCount().toString())}
505
+ ${b.bold("Hotspots")}: ${b.yellow(c.length.toString())}`,"cyan"),i.query.count>0||i.index.runs>0){console.log("");let l=i.index.runs>0?(i.index.cacheHits/i.index.runs*100).toFixed(1):"0.0";be("Reasoning Efficiency",`${b.bold("Query Count")}: ${b.cyan(i.query.count.toString())}
506
+ ${b.bold("Avg Latency")}: ${b.yellow(`${i.query.avgLatencyMs?.toFixed(2)||0}ms`)}
507
+ ${b.bold("Cache Hit Rate")}: ${b.green(`${l}%`)}`,"green")}c.length>0&&(console.log(""),console.log(` ${b.bold("Intelligence Landscape")}`),mo(c.map(l=>({label:l.kind,value:l.c,color:"cyan"})),35)),console.log(""),at("Liquid Shadow is observing.")})}finally{await ce(e)}}X();st();import kx from"path";async function vh(n){let e=kx.resolve(n);try{await re(async()=>{let r=z.getInstance(e),i=zt(e),t=xn(),o=Math.floor(t.uptimeMs/1e3),s=Math.floor(o/60),a=Math.floor(s/60),c=a>0?`${a}h ${s%60}m`:s>0?`${s}m ${o%60}s`:`${o}s`,l=t.index.lastCompletedAt?new Date(t.index.lastCompletedAt).toLocaleString():"Never",u=t.index.lastDurationMs?`${(t.index.lastDurationMs/1e3).toFixed(2)}s`:"N/A",d=t.query.avgLatencyMs?`${t.query.avgLatencyMs.toFixed(2)}ms`:"N/A",p=t.query.lastLatencyMs?`${t.query.lastLatencyMs.toFixed(2)}ms`:"N/A",m=t.index.runs>0?(t.index.cacheHits/t.index.runs*100).toFixed(1):"0.0";be("Performance Metrics",`${b.bold("Uptime")}: ${b.cyan(c)}
508
+ ${b.bold("Indexed")}: ${De(e)?b.green("Yes"):b.red("No")}
509
+ ${b.bold("Files")}: ${b.cyan(r.files.getCount().toString())}
510
+ ${b.bold("Exports")}: ${b.cyan(r.exports.getCount().toString())}
511
+ ${b.bold("Imports")}: ${b.cyan(r.imports.getCount().toString())}
512
+ ${b.bold("Last Indexed Commit")}: ${Zn(e)?b.yellow(Zn(e).substring(0,7)):b.red("None")}
513
+ ${b.bold("Git Hooks")}: ${i.installed?b.green("Installed"):b.yellow("Not Installed")}`,"blue"),console.log(""),be("Index Metrics",`${b.bold("Total Runs")}: ${b.cyan(t.index.runs.toString())}
514
+ ${b.bold("Cache Hits")}: ${b.cyan(t.index.cacheHits.toString())}
515
+ ${b.bold("Cache Hit Rate")}: ${b.cyan(`${m}%`)}
516
+ ${b.bold("Last Duration")}: ${b.yellow(u)}
517
+ ${b.bold("Last Completed")}: ${b.yellow(l)}`,"cyan"),t.index.lastRunPhases.length>0&&(console.log(""),console.log(` ${b.bold("Last Index Run Phases:")}`),t.index.lastRunPhases.forEach(f=>{let h=`${(f.durationMs/1e3).toFixed(2)}s`;console.log(` ${b.gray(f.phase.padEnd(20))} ${b.cyan(h)}`)})),console.log(""),be("Query Metrics",`${b.bold("Total Queries")}: ${b.cyan(t.query.count.toString())}
518
+ ${b.bold("Avg Latency")}: ${b.yellow(d)}
519
+ ${b.bold("Last Latency")}: ${b.yellow(p)}
520
+ ${b.bold("Search History Failures")}: ${t.query.searchHistoryFailures>0?b.red(t.query.searchHistoryFailures.toString()):b.green("0")}`,"green")})}finally{await ce(e)}}import eE from"path";import Ex from"fast-glob";import _h from"fs";import Ix from"ignore";import xh from"path";var yo=["**/node_modules/**","**/.git/**","**/dist/**","**/build/**","**/vendor/**","**/.next/**","**/.cache/**","**/coverage/**","**/*.min.js"],bh=["**/*.{ts,tsx,yaml,yml,php,py,go}","**/*.prisma","**/*.{graphql,gql}","**/Dockerfile*","**/.env*","**/package.json","**/lerna.json","**/turbo.json","**/pnpm-workspace.yaml"],ke={MAX_DEPTH:10,MIN_DEPTH:1,MAX_LIMIT:500,MIN_LIMIT:1,MAX_QUERY_LENGTH:500,DEFAULT_DEPTH:3,DEFAULT_LIMIT:10},Fe={FILTERED_QUERY_LIMIT_MULTIPLIER:3,SCORE_BASE:1e3,EXACT_MATCH_BONUS:500,RECENT_FILE_BOOST:80,OLDER_FILE_BOOST:30,RECENT_FILE_THRESHOLD_DAYS:7,OLDER_FILE_THRESHOLD_DAYS:30,FUZZY_MATCH_LIMIT:30,ENABLE_LEXICAL_SCORING:process.env.ENABLE_LEXICAL_SCORING!=="false",LEXICAL_WEIGHT:parseFloat(process.env.LEXICAL_WEIGHT??String(.4)),GRAVITY_STRUCTURAL_WEIGHT:.5},bc={SECONDS_PER_DAY:86400,SECONDS_PER_YEAR:31536e3},vo={DEFAULT_CONCURRENCY:parseInt(process.env.INDEX_CONCURRENCY??String(5),10)};async function _c(n,e=[]){let r=Ix(),i=xh.join(n,".gitignore");return _h.existsSync(i)&&r.add(_h.readFileSync(i,"utf8")),e.length>0&&r.add(e),(await Ex(bh,{cwd:n,absolute:!0,ignore:yo,stats:!0})).filter(s=>{let a=xh.relative(n,s.path);return!r.ignores(a)}).map(s=>({path:s.path,mtime:s.stats.mtimeMs}))}import $c from"@swc/core";import Lh from"fs";function Sh(n){let e=n.split(`
521
+ `),r=[],i=0;for(let t of e)r.push(i),i+=t.length+1;return r}function me(n,e){for(let r=0;r<e.length;r++)if(e[r+1]>n||r===e.length-1)return r+1;return 1}function bo(n,e){return e.slice(0,n).toString("utf8").length}function $h(n){if(n.toString("utf8").length===n.length)return i=>i;let r=new Map;return i=>{let t=r.get(i);return t===void 0&&(t=n.slice(0,i).toString("utf8").length,r.set(i,t)),t}}function wh(n,e,r){let i=n.start-e,t=n.end-e;return i<0||t>r.length?"":r.slice(i,t).toString("utf8")}function kh(n){let e=[],r=/\/\*\*[\s\S]*?\*\//g,i;for(;(i=r.exec(n))!==null;)e.push({start:i.index,end:i.index+i[0].length,text:i[0]});return e}function vt(n,e,r){for(let i of e){if(i.start===n)return i.text;if(i.start>n&&i.start<n+50){let t=r.substring(n,i.start);if(/^\s*$/.test(t))return i.text}if(i.end<=n&&i.end>n-50){let t=r.substring(i.end,n);if(/^\s*$/.test(t))return i.text}}return""}function Eh(n){if(!n)return"";let r=n.replace(/\/\*\*|\*\/|\*/g,"").trim().split(`
522
+ `)[0].trim();return r.length>200?r.substring(0,197)+"...":r}function _o(n,e,r){let i=n.toLowerCase(),t=e.toLowerCase();return i.includes("components/")||i.endsWith(".tsx")?"Component":i.startsWith("use")||t.startsWith("use")?"Hook":i.includes("models/")||t.endsWith("model")?"Model":i.includes("services/")||i.includes("controllers/")||i.includes("handlers/")||i.includes("mcp/")||i.endsWith("service.ts")||i.endsWith("controller.ts")||i.endsWith("handler.ts")||t.endsWith("service")||t.endsWith("controller")||t.endsWith("handler")?"Service":i.includes("repositories/")||i.includes("repos/")||i.endsWith("repository.ts")||i.endsWith("repo.ts")||t.endsWith("repository")||t.endsWith("repo")?"Repository":r==="TsInterfaceDeclaration"||r==="TsTypeAliasDeclaration"?"Type Definition":"Other"}function Yr(n){let e=[];return/\b(fetch|axios|superagent|got)\s*\(|import\s+.*\b(http|https|node-fetch)\b/i.test(n)&&e.push("Network"),(/\b(knex|prisma|typeorm|mongoose|sequelize|pg|mysql|sqlite3)\b/i.test(n)||/\b(SELECT\s+.*FROM|INSERT\s+INTO|UPDATE\s+.*SET|DELETE\s+FROM)\b/i.test(n)||/\.query\s*\(|\.execute\s*\(/i.test(n)&&/db|database|client|pool/i.test(n))&&e.push("Database"),(/\bfs\./i.test(n)||/\b(readFileSync|writeFileSync|readFile|writeFile|readdir)\b/.test(n)||/import\s+.*\bfs\b/.test(n))&&e.push("File System"),(/\b(localStorage|sessionStorage|indexedDB)\./.test(n)||/\bdocument\.cookie\b/.test(n))&&e.push("Browser Storage"),e}function bt(n,e){if(!n)return"";let r=n.replace(/^([\s\S]*?\*\/)?\s*/,"").replace(/^.*\} from ['"].*['"];?\s*/,"").replace(/^import .*['"];?\s*/,"").trim();if(e==="TsInterfaceDeclaration"||e==="TsTypeAliasDeclaration")return r;let i=0,t=0,o=r.length;for(let s=0;s<r.length;s++){let a=r[s];if(a==="(")i++;else if(a===")")i--;else if(a==="<")t++;else if(a===">")t--;else if(a==="{"){if(i===0&&t===0){o=s;break}}else if(a==="; "&&i===0&&t===0){o=s;break}else if(a==="="&&r[s+1]===">"&&i===0&&t===0){o=s+2;break}}return r.substring(0,o).trim()}function Ih(n){let e=[];for(let r of n)r.type==="ImportDeclaration"&&e.push({module:r.source.value,name:r.specifiers.map(i=>i.type==="ImportDefaultSpecifier"?"default":i.type==="ImportNamespaceSpecifier"?"*":i.local?.value||i.imported?.value||"*").join("","")}),r.type==="ExportAllDeclaration"&&e.push({module:r.source.value,name:"*"}),r.type==="ExportNamedDeclaration"&&r.source&&e.push({module:r.source.value,name:r.specifiers.map(i=>i.type==="ExportSpecifier"?i.orig.value:"*").join(", ")});return e}function Th(n,e,r,i,t,o,s,a,c){let l=c??(d=>bo(d,r)),u=[];for(let d of n){if(d.type==="ExportDeclaration"){let p=d.declaration,m=p.type,f="";m==="VariableDeclaration"?f=p.declarations.map($=>$.id.value).join("",""):f=p.id?.value||p.identifier?.value||"anonymous";let h=l(d.span.start-e),_=l(d.span.end-e),v=vt(h,o,i),y=a(d.span),k=[];if(d.type==="ExportDeclaration"&&(m==="ClassDeclaration"||m==="ClassExpression")){let $=p.body||[];for(let w of $)if(w.type==="ClassMethod"||w.type==="ClassProperty"){let I=w.key.value;if(!I)continue;let P=l(w.span.start-e),R=l(w.span.end-e),F=a(w.span),T=vt(P,o,i);k.push({name:I,kind:w.type,signature:bt(F,w.type),line:me(P,t),endLine:me(R,t),doc:T,classification:w.type==="ClassMethod"?"Method":"Property",capabilities:"[]"})}}else if(m==="FunctionDeclaration"&&p.body?.type==="BlockStatement")k=xc(p.body.stmts,e,r,i,t,o,a,l);else if(m==="VariableDeclaration"){for(let $ of p.declarations)if($.init&&($.init.type==="ArrowFunctionExpression"||$.init.type==="FunctionExpression")&&$.init.body?.type==="BlockStatement"){k=xc($.init.body.stmts,e,r,i,t,o,a,l);break}}u.push({name:f,kind:m,signature:bt(y,m),line:me(h,t),endLine:me(_,t),doc:v,classification:_o(s,f,m),capabilities:JSON.stringify(Yr(y)),members:k})}if(d.type==="ExportNamedDeclaration"){for(let p of d.specifiers)if(p.type==="ExportSpecifier"){let m=l(d.span.start-e),f=l(d.span.end-e),h=vt(m,o,i);u.push({name:p.exported?.value||p.orig.value,kind:"ExportSpecifier",signature:`export { ${p.orig.value} }`,line:me(m,t),endLine:me(f,t),doc:h,classification:"Export mapping",capabilities:"[]"})}}if(d.type==="ExportDefaultDeclaration"){let p=l(d.span.start-e),m=l(d.span.end-e),f=vt(p,o,i),h=a(d.span),_=[];if(d.decl.type==="ClassExpression"||d.decl.type==="ClassDeclaration"){let v=d.decl.body||[];for(let y of v)if(y.type==="ClassMethod"||y.type==="ClassProperty"){let k=y.key.value;if(!k)continue;let $=l(y.span.start-e),w=l(y.span.end-e),I=a(y.span),P=vt($,o,i);_.push({name:k,kind:y.type,signature:bt(I,y.type),line:me($,t),endLine:me(w,t),doc:P,classification:y.type==="ClassMethod"?"Method":"Property",capabilities:"[]"})}}else(d.decl.type==="FunctionExpression"||d.decl.type==="FunctionDeclaration"||d.decl.type==="ArrowFunctionExpression")&&d.decl.body?.type==="BlockStatement"&&(_=xc(d.decl.body.stmts,e,r,i,t,o,a,l));u.push({name:"default",kind:"DefaultExport",signature:bt(h,"DefaultExport"),line:me(p,t),endLine:me(m,t),doc:f,classification:"Default Export",capabilities:JSON.stringify(Yr(h)),members:_})}if(d.type==="ExportAllDeclaration"){let p=l(d.span.start-e),m=l(d.span.end-e),f=d.source.value,h=vt(p,o,i);u.push({name:"*",kind:"ExportAllDeclaration",signature:`export * from "${f}"`,line:me(p,t),endLine:me(m,t),doc:h,classification:"Re-export",capabilities:"[]"})}}return u}function xc(n,e,r,i,t,o,s,a){let c=[];for(let l of n){if(l.type==="VariableDeclaration")for(let u of l.declarations){let d=[],p=m=>{if(m.type==="Identifier")d.push({name:m.value,span:m.span});else if(m.type==="ArrayPattern")for(let f of m.elements)f&&p(f);else if(m.type==="ObjectPattern")for(let f of m.properties)f.type==="AssignmentPatternProperty"?d.push({name:f.key.value,span:f.span}):f.type==="KeyValuePatternProperty"&&p(f.value)};p(u.id);for(let m of d){let f=a(m.span.start-e),h=a(m.span.end-e),_=s(m.span),v=vt(f,o,i);c.push({name:m.name,kind:"VariableDeclaration",signature:bt(_,"VariableDeclaration"),line:me(f,t),endLine:me(h,t),doc:v,classification:"Internal Variable",capabilities:"[]"})}}if(l.type==="FunctionDeclaration"){let u=l.identifier?.value||l.ident?.value||"anonymous",d=a(l.span.start-e),p=a(l.span.end-e),m=s(l.span),f=vt(d,o,i);c.push({name:u,kind:"FunctionDeclaration",signature:bt(m,"FunctionDeclaration"),line:me(d,t),endLine:me(p,t),doc:f,classification:"Internal Function",capabilities:"[]"})}if(l.type==="ReturnStatement"&&l.argument?.type==="ObjectExpression")for(let u of l.argument.properties){let d="",p=u.span||u.key?.span||u.ident?.span;if(u.type==="KeyValueProperty"){let m=u.key;d=m?.value||m?.raw||(m?.type==="Identifier"?m.value:"")}else u.type==="MethodProperty"?d=u.key?.value||u.key?.raw||"":u.type==="ShorthandProperty"?d=u.ident?.value||"":u.type==="Identifier"&&(d=u.value||"");if(d&&p){let m=a(p.start-e),f=a(p.end-e),h=s(p),_=vt(m,o,i);c.push({name:d,kind:"ReturnProperty",signature:bt(h,"ReturnProperty"),line:me(m,t),endLine:me(f,t),doc:_,classification:"Return Member",capabilities:"[]"})}}if(l.type==="ExpressionStatement"&&l.expression.type==="CallExpression"){let u=l.expression;if(u.callee.type==="MemberExpression"&&(u.callee.property?.value==="on"||u.callee.property?.value==="once")){let d=u.arguments[0]?.expression?.value,p=u.arguments[1]?.expression;if(d&&p&&(p.type==="ArrowFunctionExpression"||p.type==="FunctionExpression")){let m=a(p.span.start-e),f=a(p.span.end-e),h=s(p.span);c.push({name:`on:${d}`,kind:p.type,signature:bt(h,p.type),line:me(m,t),endLine:me(f,t),doc:"",classification:"Event Handler",capabilities:"[]"})}}if(u.callee.type==="Identifier"&&u.callee.value==="addRoute"&&u.arguments.length>=3){let d=u.arguments[2].expression;if(d.type==="StringLiteral"){let p=d.value,m=a(u.span.start-e),f=a(u.span.end-e),h=s(u.span);c.push({name:p,kind:"HTTP Route",signature:bt(h,"HTTP Route"),line:me(m,t),endLine:me(f,t),doc:"",classification:"Service Boundary",capabilities:JSON.stringify({path:p})})}}}}return c}function Ph(n,e,r,i,t,o){let s=o??(l=>bo(l,r)),a=[];function c(l){if(!(!l||typeof l!="object")){if(l.type==="CallExpression"){let u=Tx(l);if(u){let d=s(l.span.start-e);a.push({...u,line:me(d,i),snippet:t(l.span)})}}for(let u of Object.keys(l)){if(u==="span")continue;let d=l[u];Array.isArray(d)?d.forEach(c):typeof d=="object"&&c(d)}}}return n.forEach(c),a}function Tx(n){let{callee:e,arguments:r}=n;if(!r||r.length===0)return null;if(e.type==="Identifier"&&e.value,e.type==="Identifier"&&e.value==="addRoute"&&r.length>=3){let i=r[2].expression;if(i.type==="StringLiteral")return{type:"api_route",name:i.value,direction:"consume"}}if(e.type==="MemberExpression"&&e.property?.type==="Identifier"){let i=e.property.value;if(i==="emit"&&r[0].expression.type==="StringLiteral")return{type:"socket_event",name:r[0].expression.value,direction:"produce"};if(i==="on"&&r[0].expression.type==="StringLiteral")return{type:"socket_event",name:r[0].expression.value,direction:"consume"};if(["get","post","put","delete","patch"].includes(i)&&r[0].expression.type==="StringLiteral"){let o=r[0].expression.value,s=e.object.type==="Identifier"?e.object.value:"";if(["axios","http","request","appApi","restApi","adminApi","client"].includes(s))return{type:"api_route",name:o,direction:"produce"};if(o.startsWith("/"))return{type:"api_route",name:o,direction:"consume"}}}return e.type==="Identifier"&&e.value==="fetch"&&r[0].expression.type==="StringLiteral"?{type:"api_route",name:r[0].expression.value,direction:"produce"}:null}function Xr(n){let{classification:e,capabilities:r,exports:i,fileName:t}=n,o={Network:"API integration",Database:"data persistence","File System":"file I/O operations","Browser Storage":"client-side storage"},s=r.map(f=>o[f]).filter(Boolean).join(" and "),c={Component:(f,h)=>{let _=h.find(y=>y.kind==="FunctionDeclaration"||y.kind==="ClassDeclaration")?.name,v=_?`React component: ${_}`:"React UI component";return f?`${v} with ${f}`:v},Hook:(f,h)=>{let _=h.find(y=>y.name.startsWith("use"))?.name,v=_?`Custom React hook: ${_}`:"Custom React hook";return f?`${v} for ${f}`:v},Service:(f,h)=>{let v=`Service layer: ${h[0]?.name||"Service"}`;return f?`${v} handling ${f}`:v},Repository:(f,h)=>`Data repository: ${h[0]?.name||"Repository"} for ${f||"data access"}`,"Type Definition":(f,h)=>`Type definitions: ${h.slice(0,3).map(v=>v.name).join("")}${h.length>3?"...":""}`,Model:(f,h)=>`Data model: ${h[0]?.name||"Model"}`,"HTTP Route":(f,h)=>{let _=h.filter(v=>v.classification==="Service Boundary");return _.length>0?`API endpoints: ${_.slice(0,3).map(v=>v.name).join("")}`:"API route handler"},"Micro IR (PHP)":(f,h)=>{let _=h.some(y=>y.classification==="Service Boundary"),v=h.find(y=>y.kind==="ClassDeclaration")?.name;return _?"PHP controller with API routes":v?`PHP class: ${v}`:"PHP module"},"Micro IR (Python)":(f,h)=>{let _=h.some(y=>y.classification==="Service Boundary"),v=h.find(y=>y.kind==="ClassDeclaration")?.name;return _?"Python API handler with routes":v?`Python class: ${v}`:"Python module"},"Micro IR (Go/TS) ":(f,h)=>{let _=h.some(y=>y.kind==="TypeDeclaration"),v=h.filter(y=>y.kind==="FunctionDeclaration");return _&&v.length>0?`Go package: types and ${v.length} function(s)`:_?"Go package: type definitions":v.length>0?`Go package: ${v[0].name} and ${v.length} function(s)`:"Go module"},"Micro IR (Rust/TS) ":(f,h)=>{let _=h.find(k=>k.kind==="TraitDeclaration")?.name,v=h.find(k=>k.kind==="StructDeclaration")?.name,y=h.filter(k=>k.kind==="FunctionDeclaration");return _?f.includes("Rust trait")?`Rust module: trait ${_}`:`Rust module: ${_}`:v?`Rust module: struct ${v}`:y.length>0?`Rust module: ${y.length} function(s)`:"Rust module"}}[e];if(c)return c(s,i);if(i.length===0)return t?`Module: ${t}`:"Module with no exports";let l=i.filter(f=>f.kind==="FunctionDeclaration"),u=i.filter(f=>f.kind==="ClassDeclaration"),d=i.filter(f=>f.kind==="TsInterfaceDeclaration"||f.kind==="TsTypeAliasDeclaration"),p=[];if(u.length>0&&p.push(`Class: ${u[0].name}`),l.length>0){let f=l.slice(0,2).map(h=>h.name).join("");p.push(`Functions: ${f}`)}d.length>0&&p.push(`Types: ${d.length}`);let m=p.length>0?p.join(" | "):`Module with ${i.length} export(s)`;return s?`${m} \u2014 ${s}`:m}function Rh(n){let e=new Set;function r(i){if(!(!i||typeof i!="object")){i.typeAnnotation&&xe(i.typeAnnotation,e),(i.type==="TsTypeReference"||i.type==="TsTypeAnnotation")&&xe(i,e);for(let t in i){if(t==="span"||t==="comments"||t==="interpreter")continue;let o=i[t];o&&typeof o=="object"&&(Array.isArray(o)?o.forEach(r):r(o))}}}return n.forEach(i=>r(i)),Array.from(e)}function xe(n,e){if(n){if(n.type==="TsTypeAnnotation"){xe(n.typeAnnotation,e);return}n.type==="TsTypeReference"&&(n.typeName?.type==="Identifier"&&e.add(n.typeName.value),n.typeName?.type==="TsQualifiedName"&&Nh(n.typeName,e),n.typeParams&&xe(n.typeParams,e)),n.type==="TsArrayType"&&xe(n.elementType,e),n.type==="TsUnionType"&&n.types?.forEach(r=>xe(r,e)),n.type==="TsIntersectionType"&&n.types?.forEach(r=>xe(r,e)),n.type==="TsTupleType"&&n.elemTypes?.forEach(r=>xe(r.ty,e)),(n.type==="TsFunctionType"||n.type==="TsConstructorType")&&(n.params?.forEach(r=>xe(r.typeAnnotation,e)),n.typeAnnotation&&xe(n.typeAnnotation,e)),n.type==="TsTypeParameterDeclaration"&&n.params?.forEach(r=>{r.constraint&&xe(r.constraint,e),r.default&&xe(r.default,e)}),n.type==="TsTypeParameterInstantiation"&&n.params?.forEach(r=>xe(r,e)),n.type==="TsMappedType"&&n.typeAnnotation&&xe(n.typeAnnotation,e),n.type==="TsIndexedAccessType"&&(xe(n.objectType,e),xe(n.indexType,e)),n.type==="TsConditionalType"&&(xe(n.checkType,e),xe(n.extendsType,e),xe(n.trueType,e),xe(n.falseType,e)),n.type==="TsTypeLiteral"&&n.members?.forEach(r=>{r.typeAnnotation&&xe(r.typeAnnotation,e)})}}function Nh(n,e){n.type==="TsQualifiedName"?(n.left&&Nh(n.left,e),n.right?.value&&e.add(n.right.value)):n.type==="Identifier"&&e.add(n.value)}import Ah from"path";import Sc from"path";G();Qi();import Dh from"path";import Px from"fs";import{fileURLToPath as Rx}from"url";import*as $n from"web-tree-sitter";var FT=Dh.dirname(Rx(import.meta.url)),zh=x.child({module:"parser:tree-sitter"}),xo=class{parser=null;languages=new Map;async ensureInitialized(){if(this.parser)return;let e=$n.Parser||$n;await e.init(),this.parser=new e}async getLanguage(e){if(this.languages.has(e))return this.languages.get(e);let r=Hn("resources","grammars",`tree-sitter-${this.getLangName(e)}.wasm`);if(!Px.existsSync(r))return zh.warn({grammarPath:r},"Grammar WASM not found"),null;try{let i=await $n.Language.load(r);return this.languages.set(e,i),i}catch(i){return zh.error({err:i,ext:e},"Failed to load language grammar"),null}}getLangName(e){switch(e.toLowerCase()){case".php":return"php";case".py":return"python";case".go":return"go";case".rs":return"rust";default:return""}}getQueries(e){switch(e.toLowerCase()){case".php":return`
478
523
  (function_definition name: (name) @name) @func
479
524
  (class_declaration name: (name) @name) @class
480
525
  (interface_declaration name: (name) @name) @interface
@@ -498,229 +543,119 @@ ${E.bold("Search History Failures")}: ${s.query.searchHistoryFailures>0?E.red(s.
498
543
  (trait_item name: (_type_identifier) @name) @trait
499
544
  (type_item name: (_type_identifier) @name) @type
500
545
  (use_declaration argument: (_) @name) @import
501
- `;default:return""}}mapKind(e,t){if(e==="import")return"ImportDeclaration";if(t===".php"){if(e==="func")return"FunctionDeclaration";if(e==="class")return"ClassDeclaration";if(e==="interface")return"InterfaceDeclaration";if(e==="trait")return"TraitDeclaration";if(e==="method")return"MethodDeclaration"}if(t===".py"){if(e==="func")return"FunctionDeclaration";if(e==="class")return"ClassDeclaration"}if(t===".go"){if(e==="func")return"FunctionDeclaration";if(e==="type")return"TypeDeclaration"}if(t===".rs"){if(e==="func")return"FunctionDeclaration";if(e==="struct")return"StructDeclaration";if(e==="enum")return"EnumDeclaration";if(e==="trait")return"TraitDeclaration";if(e==="type")return"TypeDeclaration"}return"Unknown"}mapClassification(e){return e==="import"?"Dependency":e==="func"||e==="method"?"Function":e==="class"||e==="interface"||e==="trait"||e==="struct"||e==="enum"||e==="type"?"Class":"Other"}async parse(e,t){await this.ensureInitialized();let n=Hi.extname(e).toLowerCase(),s=await this.getLanguage(n);if(!s||!this.parser)return[];this.parser.setLanguage(s);let r=this.parser.parse(t),o=t.split(`
502
- `),c=this.getQueries(n);if(!c)return[];let l=new Xe.Query(s,c).matches(r.rootNode),p=[];for(let d of l){let u=d.captures.find(h=>h.name==="name")?.node,m=d.captures[0].node,f=d.captures[0].name;if(u){let h=m.startPosition.row+1,b=m.endPosition.row+1,y=o[m.startPosition.row].trim();p.push({name:u.text,kind:this.mapKind(f,n),classification:this.mapClassification(f),signature:y,line:h,endLine:b,doc:"",capabilities:"{}"})}}return p}};var _n=class{parse(e,t=!1){let n=[],s=[],r=e.split(`
503
- `),o="",c="",a=0,l=0,p=-1,d=-1,u=[],m=[],f=!1,h=t?"api":"",b="",y=/^namespace\s+([a-zA-Z0-9_\\]+);/,g=/^(?:abstract\s+)?(?:readonly\s+)?class\s+([a-zA-Z0-9_]+)/,S=/^interface\s+([a-zA-Z0-9_]+)/,R=/^trait\s+([a-zA-Z0-9_]+)/,w=/^(?:public|protected|private|static|\s)*function\s+([a-zA-Z0-9_]+)\s*\(/,T=/^use\s+([a-zA-Z0-9_\\]+)(?:\s+as\s+([a-zA-Z0-9_]+))?;/,v=/^#\[([a-zA-Z0-9_\\]+)(?:\((.*)\))?\]/,k=/(?:Route::|router->|\$router->|->)(get|post|put|delete|patch|match)\s*\(\s*(?:uri\s*:\s*)?['"]([^'"]+)['"]/,F=/->prefix\s*\(\s*(?:prefix\s*:\s*)?['"]([^'"]+)['"]/;for(let x=0;x<r.length;x++){let I=r[x].trim();if(!I)continue;let M=(I.match(/{/g)||[]).length,$=(I.match(/}/g)||[]).length,j=l;if(l+=M-$,c&&l<=d){let W=n.find(O=>O.name===c&&O.line===a);W&&(W.endLine=x+1),c="",d=-1}if(o&&l<=p){let W=n.find(O=>O.name===o&&(O.kind==="ClassDeclaration"||O.kind==="TraitDeclaration"||O.kind==="InterfaceDeclaration"));W&&(W.endLine=x+1),o="",p=-1}let H=I.match(F);if(H&&(h=H[1]),I.includes("});")&&(h=""),I.startsWith("/**")){f=!0,m=[];continue}if(f){I.endsWith("*/")?f=!1:m.push(I.replace(/^\*\s?/,""));continue}let N=I.match(v);if(N){u.push(N[1]);continue}let L=I.match(y);if(L){b=L[1]||"",u=[],m=[];continue}let A=I.match(g);if(A){o=A[1],p=l-M;let W={attributes:u};b&&(W.namespace=b),n.push({name:o,kind:"ClassDeclaration",classification:"Class",signature:`class ${o}`,line:x+1,endLine:x+1,doc:m.join(`
504
- `).trim(),capabilities:JSON.stringify(W),members:[]}),u=[],m=[];continue}let D=I.match(S);if(D){let W=D[1];o=W,p=l-M,n.push({name:W,kind:"InterfaceDeclaration",classification:"Interface",signature:`interface ${W}`,line:x+1,endLine:x+1,doc:m.join(`
505
- `).trim(),capabilities:JSON.stringify({attributes:u}),members:[]}),u=[],m=[];continue}let te=I.match(R);if(te){let W=te[1];o=W,p=l-M,n.push({name:W,kind:"TraitDeclaration",classification:"Trait",signature:`trait ${W}`,line:x+1,endLine:x+1,doc:m.join(`
506
- `).trim(),capabilities:JSON.stringify({attributes:u}),members:[]}),u=[],m=[];continue}let Et=I.match(w);if(Et){let W=Et[1],O=!!o;c=W,a=x+1,d=l-M;let Ye=!1,we={};for(let ie of u)ie.toLowerCase().includes("route")&&(Ye=!0,we={type:"route",method:"GET",path:"/"});let Ie=m.join(`
507
- `).trim();if(Ye){let ie=we.path||"/";n.push({name:ie,kind:"HTTP Route",classification:"Service Boundary",signature:`Function: ${W}`,line:x+1,endLine:x+1,doc:Ie,capabilities:JSON.stringify({type:"route",handler:o?`${o}@${W}`:W,...we})}),s.push({type:"api_route",name:ie,direction:"consume",line:x+1,snippet:I})}n.push({name:W,kind:O?"MethodDeclaration":"FunctionDeclaration",classification:O?"Method":"Function",signature:`${O?o+":: ":""}${W}`,line:x+1,endLine:x+1,doc:Ie,capabilities:JSON.stringify({attributes:u})}),u=[],m=[];continue}let qe=I.match(T);if(qe){let W=qe[1]||"",O=qe[2]||W.split("\\").pop()||"";n.push({name:O,kind:"ImportSpecifier",classification:"Dependency",signature:`use ${W}`,line:x+1,endLine:x+1,doc:"",capabilities:JSON.stringify({type:"use",namespace:W})}),u=[],m=[];continue}let st=I.match(k);if(st){let W=st[1].toUpperCase(),O=st[2];if(I.includes("Route::")||I.includes("router->")||I.includes("action")||I.includes(",")&&!I.includes("view(")){if(h){let Ae=h.startsWith("/")?h:`/${h}`,Yn=O.startsWith("/")?O:`/${O}`;O=(Ae+Yn).replace(/\/+/g,"/")}let we=null,Ie=I.match(/\[\s*([a-zA-Z0-9_]+)::class\s*,\s*['"]([^'"]+)['"]\s*\]/);if(Ie)we=`${Ie[1]}@${Ie[2]}`;else if(I.includes("::class")){let Ae=I.match(/([a-zA-Z0-9_]+)::class/);Ae&&(we=Ae[1])}let ie=I;!I.endsWith(");")&&x+1<r.length&&(ie+=" "+r[x+1].trim(),!ie.endsWith(");")&&x+2<r.length&&(ie+=" "+r[x+2].trim())),n.push({name:O,kind:"HTTP Route",classification:"Service Boundary",signature:ie,line:x+1,endLine:x+1,doc:"",capabilities:JSON.stringify({type:"route",method:W,path:O,handler:we})}),s.push({type:"api_route",name:O,direction:"consume",line:x+1,snippet:ie,method:W,url:O}),m=[];continue}}let zt=/(?:\$client|client|Http)::(get|post|put|delete|patch|request)\s*\(\s*(?:url\s*:\s*)?([^,)]+)|(?:\$client|client)->(request|get|post|put|delete|patch)\s*\(\s*([^,)]+)/,Je=I.match(zt);if(Je){let W=(Je[1]||Je[3]).toUpperCase(),O=(Je[2]||Je[4]).trim();(O.startsWith("'")&&O.endsWith("'")||O.startsWith('"')&&O.endsWith('"'))&&(O=O.substring(1,O.length-1)),s.push({type:"api_route",name:O,direction:"produce",line:x+1,snippet:I,method:W,url:O})}!I.startsWith("#[")&&!I.startsWith("//")&&!I.startsWith("*")&&!f&&(u=[],m=[])}return{nodes:n,events:s}}};var xn=class{currentRoutePrefix="";parse(e){this.currentRoutePrefix="";let t=[],n=[],s=e.split(`
508
- `),r=[{indent:-1,name:"root",type:"root"}],o=[],c=/^class\s+([a-zA-Z0-9_]+)/,a=/^async\s+def\s+([a-zA-Z0-9_]+)|^def\s+([a-zA-Z0-9_]+)/,l=/^(?:from\s+([a-zA-Z0-9_\.]+)\s+import|import\s+([a-zA-Z0-9_\.]+))/,p=/^@(.*)/;function d(y){return y.trim().split(/[.(]/)[0]?.trim()||y}function u(y){let g=y.decorators.map(R=>d(R.raw)),S={decorators:y.decorators,decoratorNames:g};return y.async===!0&&(S.async=!0),JSON.stringify(S)}let m=!1,f="",h=[],b=[];for(let y=0;y<s.length;y++){let g=s[y],S=g.trim();if(!S||S.startsWith("#"))continue;let R=/^([a-zA-Z0-9_]+)\s*=\s*(?:APIRouter|Blueprint)\s*\(\s*(?:prefix\s*=\s*)?['"]([^'"]+)['"]/,w=S.match(R);if(w&&(this.currentRoutePrefix=w[2]),m){if(S.endsWith(f)||S.includes(f)){m=!1;let A=S.replace(f,"").trim();A&&h.push(A);let D=r[r.length-1];D.node&&(D.node.doc=h.join(`
509
- `).trim()),h=[]}else h.push(S);continue}let T=g.search(/\S/),v=g.trim(),k=v.match(/^(['"]{3})/);if(k){let A=k[1],D=r[r.length-1];if(D.node&&!D.node.doc){if(v.substring(3).includes(A)){let te=v.replace(new RegExp(A,"g"),"").trim();D.node.doc=te}else{m=!0,f=A;let te=v.substring(3).trim();te&&h.push(te)}continue}}for(;r.length>1&&r[r.length-1].indent>=T;)r.pop();let F=r[r.length-1],x=v.match(p);if(x){o.push({raw:x[1].trim(),line:y+1});continue}let I=v.match(c);if(I){let A=I[1],D={name:A,kind:"ClassDeclaration",classification:"Class",signature:`class ${A}`,line:y+1,endLine:y+1,doc:"",capabilities:u({decorators:o}),members:[]};b.push(D),F.node?(F.node.members||(F.node.members=[]),F.node.members.push(D)):t.push(D),r.push({indent:T,name:A,type:"class",node:D}),o=[];continue}let M=v.match(a);if(M){let A=!!M[1],D=M[1]||M[2],te=F.type==="class",Et=!1,qe={};for(let O of o)if(O.raw.match(/(?:app|router)\.(get|post|put|delete|patch)/)){Et=!0;let we=["get","post","put","delete","patch"].find(Ae=>O.raw.toLowerCase().includes(`.${Ae}`))?.toUpperCase()||"GET",Ie=O.raw.match(/['"]([^'"]+)['"]/),ie=Ie?Ie[1]:"/";if(this.currentRoutePrefix){let Ae=this.currentRoutePrefix.endsWith("/")?this.currentRoutePrefix.slice(0,-1):this.currentRoutePrefix,Yn=ie.startsWith("/")?ie:`/${ie}`;ie=Ae+Yn}qe={type:"route",method:we,path:ie}}if(Et){let O=qe.path||"",Ye={name:O||D,kind:"HTTP Route",classification:"Service Boundary",signature:`Function: ${D}`,line:y+1,endLine:y+1,doc:"",capabilities:JSON.stringify({handler:te?`${F.name}.${D}`:D,async:A,...qe})};b.push(Ye),t.push(Ye),n.push({type:"api_route",name:O,direction:"consume",line:y+1,snippet:v})}let st=o.some(O=>O.raw==="staticmethod"),zt=o.some(O=>O.raw==="classmethod"),Je=`${A?"async ":""}${te?(st?"@staticmethod ":zt?"@classmethod ":"")+F.name+".":""}${D}`,W={name:D,kind:A&&te?"AsyncMethodDeclaration":A?"AsyncFunctionDeclaration":te?"MethodDeclaration":"FunctionDeclaration",classification:te?st||zt?"Static Method":"Method":"Function",signature:Je,line:y+1,endLine:y+1,doc:"",capabilities:u({decorators:o,async:A}),members:[]};b.push(W),F.node?(F.node.members||(F.node.members=[]),F.node.members.push(W)):t.push(W),r.push({indent:T,name:D,type:"function",node:W}),o=[];continue}let $=/^(?:path|re_path|url)\s*\(\s*['"]([^'"]+)['"]/,j=v.match($);if(j){let A=j[1].replace(/^\^/,""),D={name:A,kind:"HTTP Route",classification:"Service Boundary",signature:v.trim(),line:y+1,endLine:y+1,doc:"",capabilities:JSON.stringify({type:"route",method:"GET",path:A})};b.push(D),t.push(D),n.push({type:"api_route",name:A,direction:"consume",line:y+1,snippet:v});continue}let H=/(?:requests|httpx|client|http)\.(get|post|put|delete|patch|request)\s*\(\s*(?:url\s*:\s*)?([^,)]+)/,N=v.match(H);if(N){let A=N[1].toUpperCase(),D=N[2].trim();(D.startsWith("'")&&D.endsWith("'")||D.startsWith('"')&&D.endsWith('"'))&&(D=D.substring(1,D.length-1)),n.push({type:"api_route",name:D,direction:"produce",line:y+1,snippet:v,method:A,url:D})}let L=v.match(l);if(L){let A=L[1]||L[2],D={name:A,kind:"ImportSpecifier",classification:"Dependency",signature:`import ${A}`,line:y+1,endLine:y+1,doc:"",capabilities:JSON.stringify({type:"import",module:A})};b.push(D),t.push(D),o=[];continue}o=[],F.node&&(F.node.endLine=y+1)}return{nodes:b,events:n}}};var Wi=[{extension:[".php"],rules:[]},{extension:[".py"],rules:[]},{extension:[".go"],rules:[{regex:/func\s+([a-zA-Z0-9_]+)\(/g,onMatch:i=>({name:i[1],kind:"FunctionDeclaration",classification:"Function",signature:i[0]})},{regex:/func\s+\([^\)]+\)\s+([a-zA-Z0-9_]+)\(/g,onMatch:i=>({name:i[1],kind:"MethodDeclaration",classification:"Method",signature:i[0]})},{regex:/import\s+['"]([^'"]+)['"]/g,onMatch:i=>({name:i[1],kind:"ImportSpecifier",classification:"Dependency",signature:i[0],meta:{type:"import",path:i[1]}})}]},{extension:[".rs"],rules:[{regex:/fn\s+([a-zA-Z0-9_]+)\s*\(/g,onMatch:i=>({name:i[1],kind:"FunctionDeclaration",classification:"Function",signature:i[0]})},{regex:/struct\s+([a-zA-Z0-9_]+)/g,onMatch:i=>({name:i[1],kind:"StructDeclaration",classification:"Class",signature:i[0]})},{regex:/enum\s+([a-zA-Z0-9_]+)/g,onMatch:i=>({name:i[1],kind:"EnumDeclaration",classification:"Class",signature:i[0]})},{regex:/trait\s+([a-zA-Z0-9_]+)/g,onMatch:i=>({name:i[1],kind:"TraitDeclaration",classification:"Class",signature:i[0]})},{regex:/use\s+([a-zA-Z0-9_:]+(?:\s+as\s+[a-zA-Z0-9_]+)?);/g,onMatch:i=>({name:i[1].trim(),kind:"ImportDeclaration",classification:"Dependency",signature:i[0],meta:{type:"import",path:i[1].trim()}})}]},{extension:[".ts",".tsx",".js",".jsx",".mjs",".cjs"],rules:[{regex:/(?:export\s+)?(?:async\s+)?function\s+([a-zA-Z0-9_]+)\s*\(/g,onMatch:i=>({name:i[1],kind:"FunctionDeclaration",classification:"Function"})},{regex:/(?:export\s+)?class\s+([a-zA-Z0-9_]+)/g,onMatch:i=>({name:i[1],kind:"ClassDeclaration",classification:"Class"})},{regex:/(?:export\s+)?interface\s+([a-zA-Z0-9_]+)/g,onMatch:i=>({name:i[1],kind:"InterfaceDeclaration",classification:"Interface"})},{regex:/(?:export\s+)?const\s+([a-zA-Z0-9_]+)\s*=/g,onMatch:i=>({name:i[1],kind:"VariableDeclaration",classification:"Constant"})},{regex:/import\s+.*\s+from\s+['"]([^'"]+)['"]/g,onMatch:i=>({name:i[1],kind:"ImportDeclaration",classification:"Dependency",meta:{path:i[1]}})}]}];function Da(i,e){let t=[];if(i===".go"&&e.some(n=>n.kind==="TypeDeclaration")&&t.push("Go type"),i===".rs"&&(e.some(n=>n.kind==="TraitDeclaration")&&t.push("Rust trait"),e.some(n=>n.kind==="StructDeclaration")&&t.push("Rust struct"),e.some(n=>n.kind==="EnumDeclaration")&&t.push("Rust enum")),i===".py"){for(let n of e)if(n.capabilities)try{if(JSON.parse(n.capabilities).decoratorNames?.length){t.push("Python decorators");break}}catch{}e.some(n=>n.kind==="AsyncFunctionDeclaration"||n.kind==="AsyncMethodDeclaration")&&t.push("Async")}return t}var Tn=class{phpParser=new _n;pythonParser=new xn;treeSitterParser=new Sn;supports(e){return Wi.some(t=>t.extension.includes(e.toLowerCase()))}async parse(e,t){let n=hs.extname(e).toLowerCase(),s=[],r=[];if(n===".php"||n===".py"||n===".go"||n===".rs"){if(n===".py"){let a=this.pythonParser.parse(t);s=a.nodes,r=a.events}else if(n===".php"){let a=e.toLowerCase().endsWith("api.php"),l=this.phpParser.parse(t,a);s=l.nodes,r=l.events}else try{s=await this.treeSitterParser.parse(e,t)}catch{}if(s.length>0){let a=n===".php"?"Micro IR (PHP/TS) ":n===".py"?"Micro IR (Python/TS) ":n===".go"?"Micro IR (Go/TS) ":"Micro IR (Rust/TS) ",l=s.filter(m=>m.classification!=="Dependency"),p=s.filter(m=>m.classification==="Dependency"),d=Da(n,s),u=Ct({classification:a,capabilities:d,exports:l.map(m=>({name:m.name,kind:m.kind,classification:m.classification})),fileName:hs.basename(e)});return{exports:l,imports:p.map(m=>({module:m.name,name:m.name,kind:m.kind,classification:m.classification})),events:r,classification:a,summary:u||`${n.substring(1).toUpperCase()} module`,parseStatus:"success"}}}let o=Wi.find(a=>a.extension.includes(n));if(!o)return{exports:[],imports:[],classification:"Unknown",summary:"",parseStatus:"failed",parseError:`Unsupported file extension: ${n}`};for(let a of o.rules){a.regex.lastIndex=0;let l;for(;(l=a.regex.exec(t))!==null;){let p=a.onMatch(l),d=t.substring(0,l.index).split(`
510
- `).length;s.push({name:p.name||"anonymous",kind:p.kind||"Unknown",classification:p.classification||"Other",signature:p.signature||l[0],line:d,endLine:d,doc:"",capabilities:JSON.stringify(p.meta||{})})}}let c=Ct({classification:`Micro IR (${n.substring(1).toUpperCase()})`,capabilities:[],exports:s.map(a=>({name:a.name,kind:a.kind,classification:a.classification})),fileName:hs.basename(e)});return{exports:s,imports:[],classification:`Micro IR (${n.substring(1).toUpperCase()})`,summary:c||"Module",parseStatus:s.length>0?"success":"partial"}}};P();var gs=new Tn;async function $t(i){let e=ji.extname(i);if(gs.supports(e)&&e!==".ts"&&e!==".tsx")try{let r=fs.readFileSync(i,"utf-8");return await gs.parse(i,r)}catch(r){return _.error({filePath:i,error:r.message},"HeuristicParser failed"),{exports:[],imports:[],classification:"Unknown",summary:"",parseStatus:"failed",parseError:r.message}}let t;try{t=fs.readFileSync(i)}catch(r){return{exports:[],imports:[],classification:"Error",summary:"",parseStatus:"failed",parseError:`File read error: ${r.message}`}}let n=t.toString("utf8"),s=$i(n);try{let r=i.endsWith(".tsx"),o=Oa.parseSync(n,{syntax:"typescript",tsx:r,decorators:!0,comments:!0}),c=o.span.start,a=Li(n),l=y=>ki(y,c,t),p=Ai(o.body),d=Di(o.body);d.length>0&&_.debug({filePath:i,count:d.length},"Extracted type references"),d.forEach(y=>{p.push({module:"__type_reference__",name:y})});let u=Mi(o.body,c,t,n,s,a,i,l),m=Pi(o.body,c,t,s,l),f=En(i,"","Module"),h=a.length>0&&a[0].start===0?a[0].text:u.find(y=>y.doc)?.doc||"",b=Ni(h);if(!b&&u.length>0){let y=It(n);b=Ct({classification:f,capabilities:y,exports:u.map(g=>({name:g.name,kind:g.kind,classification:g.classification})),fileName:ji.basename(i)})}return{exports:u,imports:p,events:m,classification:f,summary:b,parseStatus:"success"}}catch(r){_.warn({filePath:i,error:r.message},"SWC parsing failed, using heuristic fallback");try{let o=fs.readFileSync(i,"utf-8"),c=await gs.parse(i,o);return{...c,classification:c.classification+" (Degraded)",parseStatus:"partial",parseError:`SWC failed, used heuristic fallback: ${r.message}`}}catch(o){return _.error({filePath:i,error:o.message},"All parsing strategies failed"),{exports:[],imports:[],classification:"Error",summary:"",parseStatus:"failed",parseError:`All parsing strategies failed: ${o.message}`}}}}P();import Zi from"p-limit";Qe();import Xa from"path";import Es from"fs";import Za from"os";import he from"path";import lt from"fs";import{loadConfig as Ha,createMatchPath as Wa}from"tsconfig-paths";import Oe from"path";import kt from"fs";var Fe=class extends Error{constructor(t,n,s){super(n);this.code=t;this.cause=s;this.name="FileSystemError"}};function Ui(i){let e;try{e=kt.statSync(i).isDirectory()?i:Oe.dirname(i)}catch(t){throw t.code==="ENOENT"?new Fe("FILE_NOT_FOUND",`Start path does not exist: ${i}`,t):t.code==="EACCES"||t.code==="EPERM"?new Fe("PERMISSION_DENIED",`Permission denied accessing: ${i}`,t):new Fe("UNKNOWN",`Failed to access path: ${i}`,t)}for(;e!==Oe.dirname(e);){let t=Oe.join(e,"tsconfig.json");if(kt.existsSync(t))return e;e=Oe.dirname(e)}return null}function Bi(i){let e;try{e=kt.statSync(i).isDirectory()?i:Oe.dirname(i)}catch(t){throw t.code==="ENOENT"?new Fe("FILE_NOT_FOUND",`Start path does not exist: ${i}`,t):t.code==="EACCES"||t.code==="EPERM"?new Fe("PERMISSION_DENIED",`Permission denied accessing: ${i}`,t):new Fe("UNKNOWN",`Failed to access path: ${i}`,t)}for(;e!==Oe.dirname(e);){let t=Oe.join(e,"package.json");if(kt.existsSync(t))try{if(JSON.parse(kt.readFileSync(t,"utf8")).workspaces)return e}catch{}e=Oe.dirname(e)}return null}import ct from"path";import Ze from"fs";function zi(i,e){let t=new Map,n=e.workspaces||[];for(let s of n){let r=s.replace("/*",""),o=ct.join(i,r);if(!Ze.existsSync(o))continue;let c=Ze.readdirSync(o);for(let a of c){let l=ct.join(o,a,"package.json");if(Ze.existsSync(l))try{let p=JSON.parse(Ze.readFileSync(l,"utf8"));p.name&&t.set(p.name,{name:p.name,path:ct.dirname(l),main:p.main||"dist/index.js"})}catch{}}}return t}function Gi(i){let e=new Map;try{let t=JSON.parse(Ze.readFileSync(i,"utf8")),n={...t.dependencies,...t.devDependencies};for(let[s,r]of Object.entries(n))if(typeof r=="string"&&r.startsWith("file:")){let o=r.substring(5),c=ct.dirname(i),a=ct.resolve(c,o),l=ct.join(a,"package.json");if(Ze.existsSync(l))try{let p=JSON.parse(Ze.readFileSync(l,"utf8"));e.set(s,{name:s,path:a,main:p.main||"dist/index.js"})}catch{}}}catch{}return e}import qi from"path";import me from"fs";var Fa=[".ts",".tsx",".d.ts",".js",".jsx"];function He(i){let e=qi.extname(i);if(e===".js"||e===".jsx"){let t=i.slice(0,-e.length),n=e===".jsx"?[".tsx",".ts"]:[".ts",".tsx"];for(let s of n){let r=t+s;if(me.existsSync(r)&&me.statSync(r).isFile())return r}if(me.existsSync(i)&&me.statSync(i).isFile())return i}if(me.existsSync(i)&&me.statSync(i).isFile())return i;for(let t of Fa){let n=i+t;if(me.existsSync(n)&&me.statSync(n).isFile())return n}if(me.existsSync(i)&&me.statSync(i).isDirectory())for(let t of[".ts",".tsx",".js",".jsx"]){let n=qi.join(i,"index"+t);if(me.existsSync(n))return n}return""}var vn=new Map;function Rn(i){let e=Ui(i);if(!e)return null;if(vn.has(e))return vn.get(e)||null;let t=Ha(e);if(t.resultType==="failed")return vn.set(e,null),null;let n=t,s=n.absoluteBaseUrl;!s&&n.paths&&Object.keys(n.paths).length>0&&(s=n.configFileAbsolutePath?he.dirname(n.configFileAbsolutePath):e);let r=Wa(s,n.paths,n.mainFields,n.addMatchAll),o=Bi(e),c=new Map;if(o){let d=he.join(o,"package.json");if(lt.existsSync(d))try{let u=JSON.parse(lt.readFileSync(d,"utf8"));c=zi(o,u)}catch{}}let a=he.join(e,"package.json");lt.existsSync(a)&&Gi(a).forEach((u,m)=>c.set(m,u));let l={baseUrl:s||"",paths:n.paths,matchPath:r,workspacePackages:c,imports:new Map},p=he.join(e,"package.json");if(lt.existsSync(p))try{let d=JSON.parse(lt.readFileSync(p,"utf8"));if(d.imports){for(let[u,m]of Object.entries(d.imports))if(typeof m=="string"||typeof m=="object"&&m!==null){let f=m;Array.isArray(m)&&(f=m[0]),typeof f=="object"&&(f=f.default||f.node),typeof f=="string"&&l.imports.set(u,f)}}}catch{}return vn.set(e,l),l}function Lt(i,e,t){if(!i)return"";if(i.includes(".")&&!i.startsWith(".")&&!i.startsWith("/")&&!i.endsWith(".js")&&!i.endsWith(".ts")&&!i.endsWith(".json")){let s=i.split(".")[0];if(s&&s!==i){let r=Lt(s,e,t);if(r)return r}}if(i.startsWith(".")){let s=he.dirname(e),r=he.resolve(s,i);return He(r)}let n=Rn(e);if(n){let s=n.matchPath(i);if(s)return He(s);if(!i.startsWith("@")||i.startsWith("@/")){let o=he.resolve(n.baseUrl,i),c=He(o);if(c)return c}for(let[o,c]of n.imports.entries())if(o.includes("*")){let a="^"+o.replace(/[\\^$+.()|[\]{}]/g,"\\$&").replace(/\*/g,"(.*)")+"$",l=new RegExp(a),p=i.match(l);if(p){let d=p[1],u=c.replace("*",d),m=he.resolve(n.baseUrl,u);return He(m)}}else if(o===i){let a=he.resolve(n.baseUrl,c);return He(a)}let r=n.workspacePackages.get(i);if(r){let o=he.join(r.path,"src/index.ts");if(lt.existsSync(o))return o;let c=he.join(r.path,r.main),a=He(c);if(a)return a}}return""}import ja from"fs";import Ua from"path";import Yi from"js-yaml";function Ji(i){let e=Ua.basename(i),t=ja.readFileSync(i,"utf8"),n=[];if(e.endsWith(".prisma"))return qa(t,i);if(e.endsWith(".graphql")||e.endsWith(".gql"))return Ja(t,i);let s="Configuration";return e==="lerna.json"?Va(t,i):e==="turbo.json"?Qa(t,i):e==="pnpm-workspace.yaml"?Ka(t,i):(e.includes("Dockerfile")?(s="Infrastructure (Docker) ",Ba(t,n)):e.endsWith(".yaml")||e.endsWith(".yml")?(s="Infrastructure (YAML) ",za(t,n)):e.startsWith(".env")?(s="Configuration (Env) ",Ga(t,n)):e==="package.json"&&(s="Project Manifest",Ya(t,n)),{configs:n,classification:s})}function Ba(i,e){let t=i.split(`
511
- `);for(let n of t){let s=n.trim();if(s.startsWith("FROM "))e.push({key:"base_image",value:s.substring(5).trim(),kind:"Image"});else if(s.startsWith("EXPOSE "))e.push({key:"port",value:s.substring(7).trim(),kind:"Port"});else if(s.startsWith("ENV ")){let r=s.substring(4).trim().split(/\s+|=/);if(r[0]){let o=r[0],c=r.slice(1).join("= ").trim()||"undefined",a="Env";(o.endsWith("_URI")||o.endsWith("_URL")||o.endsWith("_HOST"))&&(a="Service"),e.push({key:o,value:c,kind:a})}}}}function za(i,e){try{let t=Yi.load(i);if(!t||typeof t!="object")return;if(t.services&&typeof t.services=="object")for(let[s,r]of Object.entries(t.services)){if(!r||typeof r!="object")continue;let o=r;if(e.push({key:`service:${s}`,value:s,kind:"Service"}),o.image&&e.push({key:`service:${s}:image`,value:String(o.image),kind:"Image"}),Array.isArray(o.ports)&&o.ports.forEach(c=>{e.push({key:`service:${s}:port`,value:String(c),kind:"Port"})}),o.environment){if(Array.isArray(o.environment))o.environment.forEach(c=>{let[a,...l]=c.split("= ");a&&l.length>0&&e.push({key:`service:${s}:env:${a}`,value:l.join("= "),kind:"Env"})});else if(typeof o.environment=="object")for(let[c,a]of Object.entries(o.environment))e.push({key:`service:${s}:env:${c}`,value:String(a),kind:"Env"})}if(Array.isArray(o.depends_on))o.depends_on.forEach(c=>{e.push({key:`service:${s}:depends_on`,value:c,kind:"Dependency"})});else if(o.depends_on&&typeof o.depends_on=="object")for(let c of Object.keys(o.depends_on))e.push({key:`service:${s}:depends_on`,value:c,kind:"Dependency"})}let n=(s,r="")=>{if(!(!s||typeof s!="object"||Array.isArray(s)))for(let[o,c]of Object.entries(s)){let a=r?`${r}.${o}`:o;if(t.services&&(a.startsWith("services.")||a==="services")){c&&typeof c=="object"&&!Array.isArray(c)&&n(c,a);continue}if(c&&typeof c=="object"&&!Array.isArray(c))n(c,a);else{let l=String(c),p="Env";o.toLowerCase().includes("image")&&(p="Image"),o.toLowerCase().includes("port")&&(p="Port"),o.toLowerCase().includes("service")&&(p="Service"),(o.endsWith("_URI")||o.endsWith("_URL")||o.endsWith("_HOST"))&&(p="Service"),e.push({key:a,value:l.length>100?l.substring(0,97)+"...":l,kind:p})}}};n(t)}catch{let n=i.match(/^\s{2}([a-z0-9_-]+):/gm);n&&n.forEach(s=>{let r=s.trim().replace(" : ","");r!=="services"&&r!=="version"&&r!=="volumes"&&r!=="networks"&&e.push({key:"service",value:r,kind:"Service"})})}}function Ga(i,e){let t=i.split(`
512
- `);for(let n of t){let s=n.trim();if(s&&!s.startsWith("#")){let r=s.split("=");if(r[0]){let o=r[0].trim(),c=r.slice(1).join("=");c=c.trim().replace(/^['"](.*)['"]$/,"$1");let a="Env";(o.endsWith("_URI")||o.endsWith("_URL")||o.endsWith("_HOST"))&&(a="Service"),e.push({key:o,value:c,kind:a})}}}}function qa(i,e){let t=[],n="Contract (Prisma) ",s=/^model\s+(\w+)/gm,r;for(;(r=s.exec(i))!==null;)t.push({key:"model",value:r[1],kind:"Database Model"});let o=/^enum\s+(\w+)/gm;for(;(r=o.exec(i))!==null;)t.push({key:"enum",value:r[1],kind:"Database Enum"});let c=/provider\s*=\s*"([^"]+)"/,a=i.match(c);return a&&t.push({key:"datasource_provider",value:a[1],kind:"Database Config"}),{classification:n,configs:t}}function Ja(i,e){let t=[],n="Contract (GraphQL) ",s=/^(?:type|input|interface|enum)\s+(\w+)/gm,r;for(;(r=s.exec(i))!==null;){let o=r[0],c="GraphQL Type";o.startsWith("input")&&(c="GraphQL Input"),o.startsWith("interface")&&(c="GraphQL Interface"),o.startsWith("enum")&&(c="GraphQL Enum"),t.push({key:"type_definition",value:r[1],kind:c})}return{classification:n,configs:t}}function Ya(i,e){try{let t=JSON.parse(i);if(t.name&&e.push({key:"name",value:t.name,kind:"Service"}),t.description&&e.push({key:"description",value:t.description,kind:"Service"}),t.workspaces){let r=Array.isArray(t.workspaces)?t.workspaces.join("",""):JSON.stringify(t.workspaces);e.push({key:"workspaces",value:r,kind:"Env"})}if(t.scripts){let r=["start","dev","build","test","docker"];for(let o of Object.keys(t.scripts))r.some(c=>o.includes(c))&&e.push({key:`script:${o}`,value:t.scripts[o],kind:"Env"})}let n={...t.dependencies,...t.devDependencies},s=["react","vue","svelte","angular","next","nuxt","express","fastify","nestjs","remix","vite","webpack","tailwindcss","database"];for(let r of Object.keys(n))if(s.some(o=>r.includes(o))){let o=n[r].replace(/[\^~]/,"");e.push({key:`dep:${r}`,value:o,kind:"Service"})}}catch{}}function Va(i,e){let t=[],n="Monorepo (Lerna) ";try{let s=JSON.parse(i);t.push({key:"monorepo_type",value:"lerna",kind:"Monorepo"}),s.version&&t.push({key:"lerna_version",value:s.version,kind:"Monorepo"}),s.packages&&(Array.isArray(s.packages)?s.packages:[s.packages]).forEach(o=>{t.push({key:"package_glob",value:o,kind:"Monorepo"})}),s.npmClient&&t.push({key:"npm_client",value:s.npmClient,kind:"Monorepo"})}catch{}return{configs:t,classification:n}}function Qa(i,e){let t=[],n="Monorepo (Turborepo) ";try{let s=JSON.parse(i);if(t.push({key:"monorepo_type",value:"turborepo",kind:"Monorepo"}),s.pipeline)for(let r of Object.keys(s.pipeline)){t.push({key:`pipeline:${r}`,value:r,kind:"Monorepo"});let o=s.pipeline[r];o.dependsOn&&t.push({key:`pipeline:${r}:depends_on`,value:o.dependsOn.join("",""),kind:"Dependency"})}if(s.tasks)for(let r of Object.keys(s.tasks))t.push({key:`task:${r}`,value:r,kind:"Monorepo"})}catch{}return{configs:t,classification:n}}function Ka(i,e){let t=[],n="Monorepo (pnpm) ";try{let s=Yi.load(i);t.push({key:"monorepo_type",value:"pnpm",kind:"Monorepo"}),s&&s.packages&&(Array.isArray(s.packages)?s.packages:[s.packages]).forEach(o=>{t.push({key:"package_glob",value:o,kind:"Monorepo"})})}catch{}return{configs:t,classification:n}}U();import{execSync as et}from"child_process";import ys from"path";import bs from"fs";function re(i){try{if(!bs.existsSync(ys.join(i,".git")))return null;let e=et("git rev-parse --abbrev-ref HEAD",{cwd:i,stdio:["ignore","pipe","ignore"],encoding:"utf8"}).trim();return e==="HEAD"?et("git rev-parse --short HEAD",{cwd:i,stdio:["ignore","pipe","ignore"],encoding:"utf8"}).trim():e.replace(/[\/\\:*"<>|?]/g,"-")}catch{return null}}function fe(i){try{return bs.existsSync(ys.join(i,".git"))?et("git rev-parse HEAD",{cwd:i,stdio:["ignore","pipe","ignore"],encoding:"utf8"}).trim():null}catch{return null}}function Vi(i,e=50){try{let t=et(`git rev-list --max-count=${e} HEAD`,{cwd:i,stdio:["ignore","pipe","ignore"],encoding:"utf8"}).trim();return t?t.split(`
513
- `):[]}catch{return[]}}function Qi(i,e,t){try{return et(`git merge-tree --write-tree ${e} ${t}`,{cwd:i,stdio:["ignore","ignore","ignore"]}),!1}catch{return!0}}function Ki(i,e){try{if(!bs.existsSync(ys.join(i,".git")))return!0;let t=fe(i);return!t||e&&e!==t&&et(`git diff --name-only ${e} ${t}`,{cwd:i,stdio:["ignore","pipe","ignore"],encoding:"utf8"}).trim()?!0:et("git status --porcelain",{cwd:i,stdio:["ignore","pipe","ignore"],encoding:"utf8"}).trim().length>0}catch{return!0}}U();P();import{execSync as Xi}from"child_process";var tt=_.child({module:"nano-repair"}),Te=class{intentLogs;exports;missions;repoPath;constructor(e){let{intentLogs:t,exports:n,missions:s}=C.getInstance(e);this.intentLogs=t,this.exports=n,this.missions=s,this.repoPath=e}detectAndRepairShifts(){let e=this.intentLogs.findRepairableOrphans();if(e.length===0)return{repaired:0,failed:0};tt.info({count:e.length},"Detected orphaned intent logs. Attempting recovery...");let t=0,n=0;for(let s of e){let r=this.exports.findByNameAndFile(s.symbol_name,s.file_path);if(r.length>0){let c=r.find(a=>a.signature===s.signature)||r[0];this.intentLogs.update(s.id,{symbol_id:c.id}),tt.info({logId:s.id,symbol:s.symbol_name},"Relinked symbol in same file"),t++;continue}let o=this.exports.findByNameGlobal(s.symbol_name);if(o.length>0){let c=o.filter(a=>a.file_path!==s.file_path);if(c.length>0){let a=c.find(l=>l.signature===s.signature)||c[0];this.intentLogs.update(s.id,{symbol_id:a.id,file_path:a.file_path}),tt.info({logId:s.id,symbol:s.symbol_name,oldPath:s.file_path,newPath:a.file_path},"Detected Nano-Repair Shift (file move)"),t++;continue}}n++}return t>0&&tt.info({repaired:t,failed:n},"Nano-Repair recovery complete"),{repaired:t,failed:n}}syncLifecycle(){let e="HEAD";try{e=Xi("git rev-parse --abbrev-ref HEAD",{cwd:this.repoPath,encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).trim()}catch{return{suspended:0,resumed:0,completed:0}}if(!e)return{suspended:0,resumed:0,completed:0};let t=this.missions.findActive(),n=0;for(let o of t)o.git_branch&&o.git_branch!==e&&(this.missions.updateStatus(o.id,"suspended"),tt.info({missionId:o.id,branch:o.git_branch,current:e},"Context Pivot: Suspended mission"),n++);this.missions.resumeByBranch(e);let s=[];try{s=Xi(`git branch --merged "${e}"`,{cwd:this.repoPath,encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).split(`
514
- `).map(c=>c.trim().replace(/^\* /,"")).filter(c=>c&&c!==e)}catch{}let r=0;if(s.length>0){let o=this.missions.findMergedMissions(e,s);for(let c of o)this.missions.updateStatus(c.id,"completed"),tt.info({missionId:c.id,branch:c.git_branch},"Merge Sentinel: Auto-completed mission"),r++}return(n>0||r>0)&&tt.info({suspended:n,completed:r},"Git-Native Lifecycle Sync complete"),{suspended:n,resumed:-1,completed:r}}};var Xd=Za.cpus().length||4,ec=bn.DEFAULT_CONCURRENCY;async function z(i,e=ec,t=!1,n=!0,s){let r=C.getInstance(i),o=r.files.database,c=Ce(i),a=c.concurrency??e;if(xi(),!t&&Ve(i)){let y=xt(i),g=fe(i);if(y&&!Ki(i,y))return ls(),_.debug({repoPath:i,commit:g},"Index is current, skipping re-index (fast-path)"),o}Rn(i);let l=r.files.findAll(),p=new Map(l.map(y=>[y.path,{mtime:y.mtime,hash:y.content_hash}])),d=Date.now();s?.({phase:"scan",current:0,total:0,message:"Scanning repository..."});let u=await ds(i,c.ignore),m=new Map(u.map(y=>[y.path,y.mtime])),f=l.filter(y=>!m.has(y.path)).map(y=>y.path),h=l.length===0,b=[];if(t||h)b.push(...u);else{let y=u.filter(w=>{let T=p.get(w.path);return!T||T.mtime!==w.mtime}),g=Zi(a*4),S=y.map(w=>g(async()=>{let T=p.get(w.path);if(!T||!T.hash)return w;try{let v=await Es.promises.readFile(w.path,"utf8");return Gs(v,T.hash)?w:(r.files.updateMtime(w.path,w.mtime),null)}catch{return null}})),R=await Promise.all(S);b.push(...R.filter(w=>w!==null))}if(f.length===0&&b.length===0){if(ls(),h){let y=fe(i);Zn(i,y||void 0)}return o}if(h?_.info({totalFiles:u.length},"Starting initial repository indexing..."):_.info({toDelete:f.length,toProcess:b.length},"Syncing repository updates..."),f.length>0&&r.files.deletePaths(f),b.length>0){Ri(),n?un(!0):un(!1);let y=Zi(a),g=0,S=b.length,R=b.map(F=>y(async()=>{try{let x=Xa.basename(F.path);if(/\.(ts|tsx|php|py|go|js|jsx|mjs|cjs)$/.test(x)){let M=await $t(F.path),$=Es.readFileSync(F.path,"utf8");return g++,(g%50===0||g===S)&&_.info({completed:g,total:S},"Parsing files..."),s?.({phase:"parse",current:g,total:S,message:`Parsing ${x}`}),{meta:F,...M,content:$,embedding:null,kind:"code"}}else{let M=Ji(F.path),$=Es.readFileSync(F.path,"utf8");return g++,(g%50===0||g===S)&&_.info({completed:g,total:S},"Parsing configs..."),s?.({phase:"parse",current:g,total:S,message:`Parsing config ${x}`}),{meta:F,...M,content:$,embedding:null,kind:"config"}}}catch(x){return g++,_.error({path:F.path,error:x},"Failed to parse file"),{meta:F,exports:[],imports:[],content:"",kind:"error"}}}));_.info({total:S},"Phase 1: Parsing all files...");let w=Date.now(),T=(await Promise.all(R)).filter(Boolean),v=Date.now()-w;if(hn("parse",v),_.info({count:T.length,time:`${(v/1e3).toFixed(1)}s`},"Phase 1 complete"),n){_.info("Phase 2: Generating file semantic embeddings..."),s?.({phase:"embed",current:0,total:T.length,message:"Generating embeddings..."});let F=Date.now(),x=[];if(T.forEach((M,$)=>{"summary"in M&&M.summary&&x.push({fileIdx:$,text:M.summary})}),x.length>0){_.info({count:x.length}," \u2192 Generating file summary embeddings...");let M=x.map(j=>j.text),$=await os(M,128);x.forEach((j,H)=>{T[j.fileIdx].embedding=$[H]}),_.info({count:x.length}," \u2713 File summaries complete")}let I=Date.now()-F;hn("embed",I),_.info({time:`${(I/1e3).toFixed(1)}s`},"Phase 2 complete")}s?.({phase:"persist",current:0,total:T.length,message:"Saving to database..."});let k=Date.now();r.files.batchSaveIndexResults(T,i,Xn,Lt),hn("persist",Date.now()-k)}if(h||b.length>0){let y=fe(i);Zn(i,y||void 0)}return(b.length>0||f.length>0)&&new Te(i).detectAndRepairShifts(),Ti(Date.now()-d),s?.({phase:"complete",current:b.length,total:b.length,message:"Indexing complete"}),o}U();async function Nt(i,e=bn.DEFAULT_CONCURRENCY,t="detailed",n,s){_.info({repo:i,level:t,subPath:n},"Ensuring cache is up-to-date..."),await z(i,e);let{files:r,exports:o,imports:c}=C.getInstance(i),a=n?r.findInSubPath(i,n):r.findAll(),l=Ce(i),p=tc(),d=er.join(i,".gitignore");if(tr.existsSync(d)&&p.add(tr.readFileSync(d,"utf8")),l.ignore&&l.ignore.length>0&&p.add(l.ignore),p.add(yn),a=a.filter(g=>{let S=er.relative(i,g.path);return!p.ignores(S)}),_.info({count:a.length},"Fetching data from DB..."),t==="lite"){let g=a.map(S=>({path:S.path,mtime:S.mtime}));return wt(g,i,t,s)}if(t==="summaries"){let g=a.map(S=>({path:S.path,mtime:S.mtime,classification:S.classification||void 0,summary:S.summary||void 0}));return wt(g,i,t,s)}let u=a.map(g=>g.path),m=o.findByFiles(u),f=t==="detailed"?c.findByFiles(u):[],h=new Map;for(let g of m){let S=h.get(g.file_path)||[];S.push(g),h.set(g.file_path,S)}let b=new Map;for(let g of f){let S=b.get(g.file_path)||[];S.push(g),b.set(g.file_path,S)}let y=a.map(g=>{let R=(h.get(g.path)||[]).map(T=>({name:T.name,kind:T.kind,signature:T.signature,line:T.start_line}));t==="structure"?R=R.map(T=>({name:T.name,kind:T.kind,line:T.line})):t==="signatures"&&(R=R.map(T=>({name:T.name,kind:T.kind,signature:T.signature,line:T.line})));let w=[];return t==="detailed"&&(w=(b.get(g.path)||[]).map(v=>({module:v.module_specifier,resolved_path:v.resolved_path}))),{path:g.path,mtime:g.mtime,classification:g.classification||void 0,summary:g.summary||void 0,exports:R,imports:w.length>0?w:void 0,chunks:[]}});return _.info({count:y.length},"Building hierarchical project tree..."),wt(y,i,t,s)}async function sr(i,e){let t=nr.resolve(i),n=parseInt(e.depth);try{await B(async()=>{let s=await Nt(t,5,"lite",e.subPath,n);console.log(""),console.log(` ${E.bold("Repository Structure: ")} ${E.cyan(nr.basename(t))}`),e.subPath&&console.log(` ${E.bold("Sub-path: ")} ${E.dim(e.subPath)}`),console.log("");let r=o=>{let c=o.type==="truncated",a=o.type==="directory"&&o.children===void 0;return{name:o.name,color:o.type==="directory"?"blue":c?"gray":"white",info:o.type==="file"?o.summary?.classification:a?"truncated":void 0,children:o.children?.map(r)}};ts([r(s)]),console.log(""),n<10&&(console.log(E.gray(` (Showing depth ${n}. Use --depth to see more)`)),console.log(""))})}finally{await q(t)}}import rr from"path";import nc from"fs";P();import Z from"path";import Ss from"fs";var wn=_.child({module:"path-resolver"}),At=class{repoPath;constructor(e){this.repoPath=Z.isAbsolute(e)?Z.normalize(e):Z.resolve(process.cwd(),e)}resolve(e){if(!e)return this.repoPath;if(e.includes("\0"))throw wn.error({inputPath:e},"Path contains null bytes - possible attack"),new Error("Invalid path: contains null bytes");let t;if(Z.isAbsolute(e)?t=Z.normalize(e):t=Z.join(this.repoPath,e),t=Z.normalize(t),!this.isWithinRoot(t))throw wn.warn({inputPath:e,resolved:t},"Path traversal attempt blocked"),new Error(`Access denied: path '${e}' is outside the repository root`);return t}resolveAndValidate(e){try{let t=this.resolve(e);return Ss.existsSync(t)?t:(wn.debug({inputPath:e,resolved:t},"Path does not exist"),null)}catch(t){return wn.error({inputPath:e,error:t},"Error validating path"),null}}isWithinRoot(e){try{let t=Z.resolve(e),n=Z.resolve(this.repoPath),s=Z.relative(n,t);if(s.startsWith("..")||Z.isAbsolute(s))return!1;if(Ss.existsSync(t)){let o=Ss.realpathSync(t),c=Z.relative(n,o);if(c.startsWith("..")||Z.isAbsolute(c))return!1}return!0}catch{return!1}}getRelative(e){let t=Z.normalize(e);return Z.relative(this.repoPath,t)}resolveBatch(e){return e.map(t=>this.resolve(t))}static normalize(e){return Z.normalize(e)}static isPathWithinRoot(e,t){let n=Z.resolve(e),s=Z.resolve(t),r=Z.relative(n,s);return r===""||!r.startsWith("..")&&!Z.isAbsolute(r)}};function ir(i){return new At(i)}async function or(i,e){let t=rr.resolve(i);await B(async()=>{if(le("MCP Liquid Shadow"),console.log(` ${E.bold("Target")}: ${E.cyan(t)}`),console.log(` ${E.bold("Mode")}: ${e.output?E.magenta("File Export"):E.green("Indexing")}`),console.log(""),!e.output){let s=de();s.start("Indexing repository...");let r="",o=c=>{if(c.phase!==r){r=c.phase;let a={scan:"Scanning",parse:"Parsing",embed:"Generating embeddings",persist:"Saving to database",complete:"Complete"}[c.phase]||c.phase;s.message(`${a}...`)}if(c.total>0&&c.current>0){let a=Math.round(c.current/c.total*100);s.message(`${r==="parse"?"Parsing":"Processing"}: ${c.current}/${c.total} (${a}%)`)}};try{await z(t,void 0,e.force,e.deep??!0,o),s.message("Running symbol healing...");let a=new Te(t).detectAndRepairShifts();s.stop("Indexing complete!"),Tt("Ready to serve AI requests.")}catch(c){throw s.stop(`Indexing failed: ${c.message}`),c}finally{await q(t)}return}let n=de();n.start(`Generating export (${E.bold(e.level)})...`);try{let s=await Nt(t,5,e.level,e.subPath),r=rr.resolve(e.output);if((process.env.LIQUID_SHADOW_SANDBOX==="1"||process.env.LIQUID_SHADOW_SANDBOX==="true")&&!At.isPathWithinRoot(t,r))throw new Error("Sandbox mode: output path must be inside the repository. Set LIQUID_SHADOW_SANDBOX=0 to allow external paths.");nc.writeFileSync(r,JSON.stringify(s,null,2)),n.stop(`Export saved to ${E.bold(E.cyan(r))}`),Tt("Export complete.")}catch(s){throw n.stop(`Export failed: ${s.message}`),s}finally{await q(t)}})}import{performance as ar}from"perf_hooks";import sc from"path";U();async function cr(i){let e=sc.resolve(i);await B(async()=>{console.log(`
515
- ${E.bold("Performance Benchmark - Liquid Shadow Intelligence")}`),console.log(` ${E.gray("Repository: ")} ${e}`),console.log(` ${E.yellow("Starting fresh index (DB deleted)...")}
516
- `);let t=ar.now();try{await z(e,10,!0);let n=ar.now()-t,s=C.getInstance(e),r=s.files.getCount(),o=s.exports.getCount(),c=s.exports.getWithEmbeddingsCount();se("Benchmark Results",`${E.bold("Total Time")}: ${n.toFixed(2)}ms (${(n/1e3).toFixed(2)}s)
517
- ${E.bold("Files Processed")}: ${E.cyan(r.toString())}
518
- ${E.bold("Symbols Extracted")}: ${E.cyan(o.toString())}
519
- ${E.bold("Symbols Embedded")}: ${E.cyan(c.toString())} (${(c/o*100).toFixed(1)}%)
520
- `+"\u2500".repeat(40)+`
521
- ${E.bold("Files/sec")}: ${E.green((r/(n/1e3)).toFixed(2))}
522
- ${E.bold("Symbols/sec")}: ${E.green((o/(n/1e3)).toFixed(2))}
523
- ${E.bold("ms per file")}: ${E.yellow((n/r).toFixed(2))}`,"green")}catch(n){throw console.error(`
524
- Benchmark failed during execution:`,n),n}finally{await q(e)}})}import $n from"path";import pe from"path";import xs from"fs";var ic=/[\x00-\x1f\x7f]/g,rc=/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/g;function _s(i){if(typeof i!="string")throw new Error("Invalid path: expected string");if(i.includes("\0"))throw new Error("Invalid path: null bytes are not allowed");if(i.replace(ic,"").length!==i.length)throw new Error("Invalid path: control characters are not allowed");return i.trim()}function In(i,e=4096){if(typeof i!="string")return"";let t=i.replace(rc,"").trim();return t.length>e?t.slice(0,e):t}Qe();function oc(i){let e=pe.isAbsolute(i)?pe.normalize(i):pe.resolve(process.cwd(),i),t=pe.parse(e).root;for(;e!==t;){if(xs.existsSync(pe.join(e,".liquid-shadow.db"))||xs.existsSync(pe.join(e,".git"))||xs.existsSync(pe.join(e,"package.json")))return e;let n=pe.dirname(e);if(n===e)break;e=n}return null}function Re(i){let e=i?.repoPath?String(i.repoPath):void 0,t=i?.filePath?String(i.filePath):void 0;e&&(e=_s(e)),t&&(t=_s(t));let n;if(e)pe.isAbsolute(e)||(e=pe.resolve(process.cwd(),e)),n=e;else if(t){let o=pe.resolve(process.cwd(),t);n=oc(pe.dirname(o))||process.cwd()}else n=process.cwd();n=pe.normalize(n);let s=ir(n),r;return t&&(r=s.resolve(t)),{...i,repoPath:n,filePath:r,resolver:s}}U();P();import pr from"@swc/core";import Mt from"fs";import ge from"path";import{Visitor as ac}from"@swc/core/Visitor.js";var Cn=class extends ac{calls=new Set;apiCalls=[];imports=new Map;axiosInstances=new Map([["axios",""],["http",""],["appApi",""],["restApi",""],["adminApi",""]]);visitImportDeclaration(e){let t=e.source.value;for(let n of e.specifiers)(n.type==="ImportDefaultSpecifier"||n.type==="ImportSpecifier")&&this.imports.set(n.local.value,t);return super.visitImportDeclaration(e)}visitCallExpression(e){if(e.callee.type==="Identifier"){let t=e.callee.value;this.calls.add(t),(t==="axios"||t==="http")&&e.arguments.length>0&&this.extractApiCallFromConfig(e.arguments[0].expression)}else if(e.callee.type==="MemberExpression"){let t=e.callee.property.value,n=r=>{if(!r)return"?";if(r.type==="Identifier")return r.value;if(r.type==="ThisExpression")return"this";if(r.type==="MemberExpression"){let o=n(r.object),c=r.property.value||"?";return`${o}.${c}`}return r.type==="TsNonNullExpression"||r.type==="TsAsExpression"||r.type==="ParenthesisExpression"?n(r.expression):"?"},s=n(e.callee.object);if(s!=="?"&&t){if(this.calls.add(`${s}.${t}`),s==="axios"||s==="http"||this.axiosInstances.has(s)){let r=this.axiosInstances.get(s)||"";this.extractApiCall(t,e.arguments,r)}if((s.toLowerCase().includes("pubsub")||s==="pubSubClient"||s.endsWith(".pubSubClient"))&&t!=="subscribe"){let r=t;if((t==="publish"||t==="publishMessage"||t==="publishTaskByNameAndPayload")&&e.arguments.length>0)for(let o of e.arguments){let c=o.expression;if(c.type==="ObjectExpression"){let a=c.properties.find(l=>l.key?.type==="Identifier"&&(l.key.value==="action"||l.key.value==="type")||l.key?.type==="StringLiteral"&&(l.key.value==="action"||l.key.value==="type"));if(a&&a.value?.type==="StringLiteral"){r=a.value.value;break}}if(c.type==="CallExpression"&&c.callee.type==="MemberExpression"&&c.callee.object.value==="JSON"&&c.callee.property.value==="stringify"&&c.arguments.length>0){let a=c.arguments[0].expression;if(a.type==="ObjectExpression"){let l=a.properties.find(p=>p.key?.type==="Identifier"&&(p.key.value==="action"||p.key.value==="type")||p.key?.type==="StringLiteral"&&(p.key.value==="action"||p.key.value==="type"));if(l&&l.value?.type==="StringLiteral"){r=l.value.value;break}}}}this.apiCalls.push({method:"PUBSUB",url:r})}}}return e.callee.type==="Identifier"&&e.callee.value==="fetch"&&this.extractApiCall("GET",e.arguments),super.visitCallExpression(e)}visitNewExpression(e){return e.callee.type==="Identifier"&&this.calls.add(e.callee.value),super.visitNewExpression(e)}visitVariableDeclarator(e){if(e.init&&e.init.type==="CallExpression"){let t=e.init.callee;if(t.type==="MemberExpression"&&t.property.value==="create"&&t.object.value==="axios"){let s=e.init.arguments[0]?.expression;if(s&&s.type==="ObjectExpression"){let r=s.properties.find(o=>o.key.value==="baseURL");if(r){let o="?";r.value.type==="StringLiteral"?o=r.value.value:r.value.type==="Identifier"&&(o=`\${${r.value.value}}`),e.id.type==="Identifier"&&this.axiosInstances.set(e.id.value,o)}}}}return super.visitVariableDeclarator(e)}extractApiCallFromConfig(e){if(e&&e.type==="ObjectExpression"){let t=e.properties.find(s=>s.key.type==="Identifier"&&s.key.value==="url"||s.key.type==="StringLiteral"&&s.key.value==="url"),n=e.properties.find(s=>s.key.type==="Identifier"&&s.key.value==="method"||s.key.type==="StringLiteral"&&s.key.value==="method");if(t&&t.value){let s=n?.value?.value||"GET",r=this.resolveUrlValue(t.value);r!=="?"&&this.apiCalls.push({method:s.toUpperCase(),url:r})}}}resolveUrlValue(e){return e.type==="StringLiteral"?e.value:e.type==="TemplateLiteral"?e.quasis.map(t=>t.cooked).join("*"):"?"}visitTsType(e){return e}extractApiCall(e,t,n=""){if(t.length>0){let s=t[0].expression,r=this.resolveUrlValue(s);if(r!=="?"){if(n&&n!=="?"){let o=n.endsWith("/")||r.startsWith("/")?"":"/";r=`${n}${o}${r}`}this.apiCalls.push({method:e.toUpperCase(),url:r})}}}},pt=class{calls=new Set;apiCalls=[];imports=new Map;visit(e,t){if(t===".php"){let n=/(?:([a-zA-Z0-9_$->:\(\)]*)?(?:->|::))?([a-zA-Z0-9_]+)\s*\(([\s\S]*?)\)/g,s;for(;(s=n.exec(e))!==null;){let r=s[1]||"",o=s[2],c=s[3];if(this.calls.add(o),r&&!["$this","self","parent"].includes(r)&&this.calls.add(`${r}${r.includes("::")?"::":"->"}${o}`),["save","delete","update","create","first","all","where","get","find"].includes(o)&&r&&!["Log","Route","Cache","Config","Http"].includes(r)&&this.apiCalls.push({method:"DB",url:`${r}->${o}()`}),o==="publish"&&r&&(r.includes("topic")||r.includes("pubSub"))&&this.apiCalls.push({method:"PUBSUB",url:"publish"}),["get","post","put","delete","patch","request"].includes(o)&&(r==="Http"||r==="client"||r.endsWith("request")||r.includes("Client")||!r)){let p=c.match(/(?:url\s*:\s*)?['"]([^'"]+)['"]/),d=p?p[1]:c.split(",")[0].trim()||"unknown";this.apiCalls.push({method:o.toUpperCase(),url:d})}}}else if(t===".py"){let n=/(?:([a-zA-Z0-9_\.]+)\.)?([a-zA-Z0-9_]+)\s*\(([\s\S]*?)\)/g,s;for(;(s=n.exec(e))!==null;){let r=s[1]||"",o=s[2],c=s[3];if(this.calls.add(o),r&&r!=="self"&&r!=="cls"&&this.calls.add(`${r}.${o}`),["save","delete","update","create","first","all","filter","get"].includes(o)&&r&&!["logger","os","sys"].includes(r)&&this.apiCalls.push({method:"DB",url:`${r}.${o}()`}),o==="publish"&&r&&(r.includes("publisher")||r.includes("client"))&&this.apiCalls.push({method:"PUBSUB",url:"publish"}),["get","post","put","delete","patch","request"].includes(o)&&(r==="requests"||r==="httpx"||r==="client"||r==="http"||!r)){let p=c.match(/(?:url\s*:\s*)?['"]([^'"]+)['"]/),d=p?p[1]:c.split(",")[0].trim()||"unknown";this.apiCalls.push({method:o.toUpperCase(),url:d})}}}else if([".ts",".tsx",".js",".jsx"].includes(t)){let n=/import\s+[\s\S]*?from\s+['"](.*?)['"];?/g,s;for(;(s=n.exec(e))!==null;)this.imports.set("*",s[1]);let r=/(?:([a-zA-Z0-9_$]+)\.)?([a-zA-Z0-9_$]+)\s*\(/g,o;for(;(o=r.exec(e))!==null;){let c=o[1],a=o[2];c?(this.calls.add(`${c}.${a}`),(c.toLowerCase().includes("pubsub")||c==="pubSubClient")&&a!=="subscribe"&&this.apiCalls.push({method:"PUBSUB",url:a})):this.calls.add(a)}}else{let n=/\.([a-zA-Z0-9_]+)\s*\(/g,s;for(;(s=n.exec(e))!==null;)this.calls.add(s[1])}if(t===".php"){let n=/use\s+([a-zA-Z0-9_\\]+)(?:\s+as\s+([a-zA-Z0-9_]+))?;/g,s;for(;(s=n.exec(e))!==null;){let r=s[1],o=r.split("\\"),c=s[2]||o[o.length-1];this.imports.set(c,r)}}else if(t===".py"){let n=/from\s+([a-zA-Z0-9_\.]+)\s+import\s+([a-zA-Z0-9_,\s]+)/g,s;for(;(s=n.exec(e))!==null;){let c=s[1];s[2].split(",").map(l=>l.trim()).forEach(l=>{this.imports.set(l,c)})}let r=/^import\s+([a-zA-Z0-9_\.]+)/gm,o;for(;(o=r.exec(e))!==null;){let c=o[1],a=c.split("."),l=a[a.length-1];this.imports.set(l,c)}}}};var cc=new Set(["api","v1","v2","v3","http","https","localhost","admin","internal","public","private","app","src","get","post","put","delete","patch","user","users","id","search","list","create","update","data"]);function lr(i,e){let t=e,n=e.match(/\$\{([^}]+)\}/g);if(n)for(let p of n){let d=p.substring(2,p.length-1),u=i.configs.findEnvValue(d);u&&(t=t.replace(p,u))}let s=t.split("?")[0].split("#")[0];try{s.includes("://")&&(s=new URL(s).pathname)}catch{}s.length>1&&s.endsWith("/")&&(s=s.substring(0,s.length-1));let r=[],o=s.replace(/\*/g,"%").replace(/:[^/]+/g,"%").replace(/\{[^}]+\}/g,"%"),c=i.files.findSynapses({type:"api_route",name:o.includes("%")?o:s,direction:"consume",limit:10});for(let p of c){let d=p.name.replace(/:[^/]+/g,"[^/]+").replace(/\{[^}]+\}/g,"[^/]+").replace(/\*/g,"[^/]+");new RegExp(`^${d.replace(/\//g,"\\/")}$`).test(s.replace(/\*/g,"test-val"))&&r.push({file_path:p.file_path,start_line:p.line_number||0,signature:`[Synapse] ${p.name}`,score:1e3})}let a=s.split(/[^a-zA-Z0-9-_]/).filter(p=>p.length>=3&&!cc.has(p.toLowerCase())&&!/^\d+$/.test(p));if(a.length>0){let d=[...a].sort((m,f)=>f.length-m.length)[0],u=i.exports.findRoutesByToken(d,20);for(let m of u){let f=50,h=(m.signature||m.name||"").toLowerCase();(m.name||"").toLowerCase().includes(s.replace(/\*/g,"").toLowerCase())&&(f+=200);for(let y of a)h.includes(y.toLowerCase())&&(f+=20);r.push({file_path:m.file_path,start_line:m.start_line,signature:`[Boundary] ${m.signature||m.name}`,capabilities:m.capabilities||void 0,score:f})}}if(r.length<3){let p=a.map(d=>d.replace(/[^a-zA-Z0-9_]/g,"")).filter(d=>d.length>0).join(" AND ");if(p.length>0){let d=i.content.search(p);for(let u of d){let m=0,f=u.file_path.toLowerCase(),h=u.snippet.toLowerCase();(f.includes("route")||f.includes("controller"))&&(m+=10),(f.includes("src/api")||f.includes("services/api"))&&(m+=5),(h.includes("addroute")||h.includes("@get"))&&(m+=15),(h.includes("axios.")||h.includes("fetch("))&&(m-=10),(f.includes(".spec.")||f.includes(".test."))&&(m-=20),m>0&&r.push({file_path:u.file_path,start_line:0,signature:`[FTS Match] ${u.snippet.replace(/\n/g," ")}`,score:m})}}}let l=new Map;return r.sort((p,d)=>d.score-p.score).forEach(p=>{l.has(p.file_path)||l.set(p.file_path,p)}),Array.from(l.values()).slice(0,3)}var lc=4,Pt=50,pc=2,uc=new Set(["push","pop","shift","unshift","slice","splice","map","filter","reduce","reduceRight","forEach","find","findIndex","includes","indexOf","lastIndexOf","every","some","flat","flatMap","fill","copyWithin","entries","keys","values","join","concat","sort","reverse","at","with","toSorted","toReversed","toSpliced","toString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","charAt","charCodeAt","codePointAt","split","substring","substr","trim","trimStart","trimEnd","padStart","padEnd","repeat","replace","replaceAll","match","matchAll","search","toLowerCase","toUpperCase","localeCompare","normalize","startsWith","endsWith","then","catch","finally","get","set","has","delete","clear","size","length","call","apply","bind"]);async function ur(i){let{repoPath:e,filePath:t,symbolName:n}=Re(i);if(!t)return{isError:!0,content:[{type:"text",text:"Error: 'filePath' is required."}]};let s=t;await z(e);let r=C.getInstance(e);if(!Mt.existsSync(s))return{isError:!0,content:[{type:"text",text:`File not found: ${s}`}]};let o,c=ge.basename(s),a;if(n){let u=r.exports.findByNameAndFile(n,s);if(u.length>0){let m=u[0];o={start:m.start_line,end:m.end_line},c=m.name,a=m.start_line}}let l={type:o?"function":"file",name:c,path:ge.relative(e,s),line:a,children:[]},p=new Set;p.add(s+(n?`:${n}`:""));let d={count:0,truncated:!1};return await ut(s,l,e,r,p,1,d,o),d.truncated&&l.children.push({type:"function",name:"\u26A0\uFE0F Output Truncated",details:`Trace limited to ${Pt} nodes. Use summarize_file on specific files for deeper analysis.`,children:[]}),{content:[{type:"text",text:JSON.stringify(l,null,2)}]}}async function ut(i,e,t,n,s,r,o,c){if(!(r>lc)){if(o.count>=Pt){o.truncated=!0;return}try{let a=Mt.readFileSync(i,"utf8"),l=ge.extname(i).toLowerCase(),d=(a.match(/import\s+[\s\S]*?from\s+['"].*?['"];?/gm)||[]).join(`
525
- `);c&&(a=a.split(`
526
- `).slice(c.start-1,c.end).join(`
527
- `));let u;if(l===".ts"||l===".tsx"||l===".js"||l===".jsx"){u=new Cn;let b={syntax:"typescript",tsx:i.endsWith(".tsx"),target:"es2020"};try{let y=c?`${d}
528
- ${a}`:a,g=await pr.parse(y,b);u.visitModule(g)}catch{if(c)try{let g=`${d}
529
- class TraceContext {
530
- ${a}
531
- }`,S=await pr.parse(g,b);u.visitModule(S)}catch{let S=new pt,R=l;S.visit(a,R),u.calls=S.calls,u.apiCalls=S.apiCalls,u.imports=S.imports}else{let g=new pt;g.visit(a,l),u.calls=g.calls,u.apiCalls=g.apiCalls,u.imports=g.imports}}}else u=new pt,u.visit(a,l);_.info({file:ge.basename(i),calls:u.calls.size,apiCalls:u.apiCalls.length,depth:r},"Analyzed file");let m=u.apiCalls.slice(0,10);for(let b of m){if(o.count>=Pt)break;if(o.count++,b.method==="PUBSUB"){let R={type:"event_trigger",name:`PubSub Event: ${b.url}`,details:"Detected via PubSub client usage",children:[]};e.children.push(R);let w=n.exports.findByNameGlobal(b.url).concat(n.exports.findByMethodName(b.url));if(b.url.length>10){let v=b.url.replace(/To[A-Z][a-zA-Z]+$/,"");if(v!==b.url){let k=n.exports.findByNameGlobal(v).concat(n.exports.findByMethodName(v));w.push(...k)}}let T=new Set;for(let v of w){if(T.has(v.file_path)||v.file_path===i)continue;if(T.add(v.file_path),o.count>=Pt)break;o.count++;let k={type:"subscriber",name:`${v.name} (${ge.basename(v.file_path)})`,path:ge.relative(t,v.file_path),line:v.start_line,details:"Potential Subscriber / Handler",children:[]};R.children.push(k),Mt.existsSync(v.file_path)&&!s.has(v.file_path)&&(s.add(v.file_path),await ut(v.file_path,k,t,n,s,r+1,o))}continue}let y={type:"api_call",name:`${b.method} ${b.url}`,details:"Detected via string literal analysis",children:[]};e.children.push(y);let S=lr(n,b.url).slice(0,pc);for(let R of S){if(o.count>=Pt)break;o.count++;let w={type:"route",name:R.signature||"Route Handler",path:R.file_path,line:R.start_line,children:[]};if(y.children.push(w),Mt.existsSync(R.file_path)&&!s.has(R.file_path)&&(s.add(R.file_path),await ut(R.file_path,w,t,n,s,r+1,o)),R.capabilities)try{let T=JSON.parse(R.capabilities);if(T.handler){let[v,k]=T.handler.split("@");if(v){let x=v.split("\\").pop();if(x){let I=n.exports.findClassByName(x);if(I){let M=n.exports.findByNameAndFile(k||"",I.file_path),$,j=I.start_line;M.length>0&&($={start:M[0].start_line,end:M[0].end_line},j=M[0].start_line);let H={type:"component",name:`${x}${k?" :: "+k:""}`,path:ge.relative(t,I.file_path),line:j,details:"Controller Logic (Macro IR)",children:[]};w.children.push(H),s.has(I.file_path+(k?`:${k}`:""))||(s.add(I.file_path+(k?`:${k}`:"")),await ut(I.file_path,H,t,n,s,r+1,o,$))}}}}}catch{}}}let f=u.calls,h=Array.from(f).sort();for(let b of h)if(u.imports.has(b)){let y=u.imports.get(b);if(!y.startsWith(".")){if(["react","react-dom"].includes(y))continue;e.children.push({type:"function",name:b,details:`External: ${y}`,children:[]});continue}let g=Lt(y,i,t);if(g&&Mt.existsSync(g))if(s.has(g))e.children.push({type:"function",name:b,details:"Circular / Already Visited",path:ge.relative(t,g),children:[]});else{s.add(g);let S={type:"file",name:b,details:`Imported from ${ge.basename(g)}`,path:ge.relative(t,g),children:[]};e.children.push(S),await ut(g,S,t,n,s,r+1,o)}}else if(!["log","info","error","warn","print"].includes(b)){let y=n.exports.findByNameGlobal(b);if(y.length===0){let g=b.split(/(?:\.|->|::)+/);if(g.length>1){let S=g[g.length-1];uc.has(S)||(y=n.exports.findByMethodName(S))}}if(y.length>0){let g=y.find(R=>R.file_path===i),S=g||(y.length===1?y[0]:null);if(S){let R=`${S.file_path}:${S.name}`;if(!s.has(R)){s.add(R);let w={type:"component",name:b,details:`Resolved via global index${g?" (local)":""}`,path:ge.relative(t,S.file_path),line:S.start_line,children:[]};e.children.push(w),await ut(S.file_path,w,t,n,s,r+1,o,{start:S.start_line,end:S.end_line})}}}}}catch(a){_.error({filePath:i,error:a.message},"Trace analysis failed"),e.children.push({type:"function",name:"Error",details:a.message,children:[]})}}}async function dr(i,e){let t=$n.resolve(e.dir),n=$n.isAbsolute(i)?i:$n.resolve(t,i);await B(async()=>{le("Execution Trace");let s=de();s.start(`Tracing ${E.cyan(e.symbolName||$n.basename(n))}...`);try{let r=await ur({repoPath:t,filePath:n,symbolName:e.symbolName});s.stop("Trace complete."),r.isError?console.error(E.red(r.content[0].text)):se("Flow Results",r.content[0].text,"magenta")}catch(r){throw s.stop(`Trace failed: ${r.message}`),r}finally{await q(t)}})}import _c from"path";U();dt();P();import{execSync as Br}from"child_process";import Sc from"path";var kn=_.child({module:"shadow-trace"}),mt=class{intentLogs;exports;repoPath;hologramService;constructor(e){let{intentLogs:t,exports:n}=C.getInstance(e);this.intentLogs=t,this.exports=n,this.repoPath=e,this.hologramService=new ue(e)}analyzeGhostChanges(e){let t=e?`${e}..HEAD`:"HEAD~1..HEAD",n=[];try{let r=Br(`git diff --name-only ${t}`,{cwd:this.repoPath,encoding:"utf-8"}).split(`
532
- `).filter(o=>o.trim()!=="");if(r.length===0)return;kn.info({files:r.length,range:t},"Initiating Shadow Trace analysis...");for(let o of r){let c=Sc.join(this.repoPath,o),l=Br(`git diff -U0 ${t} -- ${o}`,{cwd:this.repoPath,encoding:"utf-8"}).matchAll(/@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/g);for(let p of l){let d=parseInt(p[2],10),u=this.exports.findAtLine(c,d);u&&(this.intentLogs.create({mission_id:0,file_path:c,symbol_id:u.id,type:"discovery",content:`Shadow Trace: Modified externally in ${t}`,confidence:.8,symbol_name:u.name,signature:u.signature,commit_sha:null}),kn.debug({symbol:u.name},"Logged ghost change"),n.push({from:"external",to:`${o}:${u.name}`,pattern:"git-delta",confidence:.8}))}}n.length>0&&this.hologramService.updateGhostBridges(n),kn.info("Shadow Trace complete.")}catch(s){kn.warn({err:s.message},"Shadow Trace failed: git diff error.")}}};U();import{execSync as ht}from"child_process";var Ln=class{constructor(e,t="refs/notes/shadow"){this.repoPath=e;this.ref=t}addNote(e,t){try{ht(`git notes --ref ${this.ref} add -f -m '${t.replace(/'/g,"'\\''")}' ${e}`,{cwd:this.repoPath,stdio:["ignore","pipe","ignore"],encoding:"utf8"})}catch(n){throw new Error(`Failed to add git note to ${e}: ${n.message}`)}}getNote(e){try{return ht(`git notes --ref ${this.ref} show ${e}`,{cwd:this.repoPath,stdio:["ignore","pipe","ignore"],encoding:"utf8"}).trim()}catch{return null}}listNotes(){let e=new Map;try{let t=ht(`git notes --ref ${this.ref} list`,{cwd:this.repoPath,stdio:["ignore","pipe","ignore"],encoding:"utf8"}).trim();if(!t)return e;let n=t.split(`
533
- `);for(let s of n){let[r,o]=s.split(" ");if(o){let c=this.getNote(o);c&&e.set(o,c)}}}catch{}return e}removeNote(e){try{ht(`git notes --ref ${this.ref} remove ${e}`,{cwd:this.repoPath,stdio:["ignore","pipe","ignore"],encoding:"utf8"})}catch{}}push(e="origin"){try{ht(`git push ${e} ${this.ref}`,{cwd:this.repoPath,stdio:["ignore","pipe","ignore"],encoding:"utf8"})}catch(t){throw new Error(`Failed to push git notes to ${e}: ${t.message}`)}}fetch(e="origin"){try{ht(`git fetch ${e} ${this.ref}:${this.ref}`,{cwd:this.repoPath,stdio:["ignore","pipe","ignore"],encoding:"utf8"})}catch{}}};P();var ft=_.child({module:"persistence-service"}),ve=class{gitNotes;repoPath;constructor(e){this.repoPath=e,this.gitNotes=new Ln(e)}async syncMissionToGitNotes(e){let{missions:t,intentLogs:n}=C.getInstance(this.repoPath),s=t.findById(e);if(!s)throw new Error(`Mission ${e} not found`);if(!s.commit_sha){ft.warn({missionId:e},"Cannot sync mission without commit_sha");return}ft.info({missionId:e,commitSha:s.commit_sha},"Syncing mission to Git Notes");let r=t.getArtifacts(e),o=n.findByMission(e,1e3),c=o.find(p=>p.type==="adr"),a=o.filter(p=>p.type==="decision").map(p=>({content:p.content,symbol_name:p.symbol_name,created_at:p.created_at})),l={version:"1.0",mission:{name:s.name,goal:s.goal,status:s.status,strategy_graph:s.strategy_graph,git_branch:s.git_branch,commit_sha:s.commit_sha,parent_id:s.parent_id,verification_context:s.verification_context,outcome_contract:s.outcome_contract,created_at:s.created_at,updated_at:s.updated_at},artifacts:r,adr:c?c.content:null,decisions:a};this.gitNotes.addNote(s.commit_sha,JSON.stringify(l,null,2))}async syncAllToGitNotes(){let{missions:e}=C.getInstance(this.repoPath),t=e.findActive(),n=e.findRecentCompleted(10),s=[...t,...n];for(let r of s)try{await this.syncMissionToGitNotes(r.id)}catch(o){ft.error({missionId:r.id,error:o},"Failed to sync mission")}}async recoverFromGitNotes(){let e=this.gitNotes.listNotes(),{missions:t,intentLogs:n}=C.getInstance(this.repoPath),s=0,r=0;for(let[o,c]of e.entries())try{let a=JSON.parse(c);if(a.version!=="1.0")continue;if(t.findByCommitShas([o]).some(u=>u.name===a.mission.name)){ft.debug({commitSha:o,missionName:a.mission.name},"Mission already exists, skipping recovery");continue}let d=t.create({name:a.mission.name,goal:a.mission.goal,status:a.mission.status,strategy_graph:a.mission.strategy_graph,git_branch:a.mission.git_branch,commit_sha:o,parent_id:a.mission.parent_id,verification_context:a.mission.verification_context,outcome_contract:a.mission.outcome_contract});if(s++,a.adr&&(n.create({mission_id:Number(d),symbol_id:null,file_path:null,type:"adr",content:a.adr,confidence:1,symbol_name:null,signature:null,commit_sha:o}),r++),a.decisions&&a.decisions.length>0)for(let u of a.decisions)n.create({mission_id:Number(d),symbol_id:null,file_path:null,type:"decision",content:u.content,confidence:1,symbol_name:u.symbol_name,signature:null,commit_sha:o}),r++;ft.info({commitSha:o,missionName:a.mission.name,logsRecovered:r},"Re-hydrated mission from Git Notes")}catch(a){ft.error({commitSha:o,error:a},"Failed to parse Git Note for recovery")}return{missionsRecovered:s,logsRecovered:r}}};U();Ot();async function zr(i){let{repoPath:e}=i;try{await z(e),new mt(e).analyzeGhostChanges();let n=new Te(e),s=n.detectAndRepairShifts(),r=n.syncLifecycle(),c=await new ve(e).recoverFromGitNotes(),{HologramService:a}=await Promise.resolve().then(()=>(dt(),Ur)),l=new a(e),p=je(C.getInstance(e),e);l.updateTopography(p);let d=l.computeGravityZones();l.updateGravityZones(d);let u="Shadow Sync complete. Code changes indexed and intent logs updated.";return u+=`
534
- \u269B\uFE0F Hologram: Refreshed architectural map (${d.length} hotspots).`,s.repaired>0&&(u+=`
535
- \u2728 Nano-Repair: Fixed ${s.repaired} links.`),c.missionsRecovered>0&&(u+=`
536
- \u{1F9EC} Re-hydration: Recovered ${c.missionsRecovered} missions.`),{content:[{type:"text",text:u}]}}catch(t){return{content:[{type:"text",text:`Error: ${t.message}`}],isError:!0}}}async function Gr(i,e){let t=_c.resolve(i);await B(async()=>{le("Shadow Sync");let n=de();n.start("Synchronizing intelligence lifecycle...");try{let s=await zr({repoPath:t});n.stop("Sync complete."),s.isError?console.error(E.red(s.content[0].text)):(console.log(""),console.log(s.content[0].text),console.log(""))}catch(s){throw n.stop(`Sync failed: ${s.message}`),s}finally{await q(t)}})}Ot();U();P();dt();import Jr from"path";U();Ot();dt();import Le from"path";async function qr(i){let{repoPath:e}=i;await z(e);let t=C.getInstance(e),n=je(t,e),r=new ue(e).getSnapshot(),o=[],c=[],a=Object.values(n.layers.Entry.topFiles).map(u=>u.path),l=new Set(Object.values(n.layers.Data.topFiles).map(u=>u.path));for(let u of a){let m=Le.isAbsolute(u)?u:Le.join(e,u),f=t.imports.findByFile(m);for(let h of f)h.resolved_path&&l.has(Le.relative(e,h.resolved_path))&&o.push(`\u2694\uFE0F LAYER BYPASS: \`${Le.relative(e,u)}\` directly imports Data layer \`${Le.relative(e,h.resolved_path)}\`. Should go through Logic.`)}let p=r.gravity?.hotspots||[];for(let u of p){let m=Dt(u.filePath,t);(m.layer==="Utility"||m.layer==="Unknown")&&u.gravity>50&&c.push(`\u{1F6A8} GRAVITY ANOMALY: \`${Le.relative(e,u.filePath)}\` has high gravity (${u.gravity.toFixed(0)}) but is classified as ${m.layer}. Consider promoting to Core Logic.`)}for(let u of a){let m=Le.isAbsolute(u)?u:Le.join(e,u),f=t.exports.findByFile(m);f.length>10&&c.push(`\u{1F388} ENTRY BLOAT: \`${Le.relative(e,u)}\` exports ${f.length} symbols. Entry handlers should be thin interfaces.`)}let d=`# \u{1F575}\uFE0F Architectural Scout Report
537
-
538
- `;return o.length===0&&c.length===0?d+=`\u2705 No significant architectural drift detected. The structure remains "Legit".
539
- `:(o.length>0&&(d+=`## \u274C Structural Violations
540
- `,o.forEach(u=>d+=`- ${u}
541
- `),d+=`
542
- `),c.length>0&&(d+=`## \u26A0\uFE0F Architectural Warnings
543
- `,c.forEach(u=>d+=`- ${u}
544
- `),d+=`
545
- `)),{content:[{type:"text",text:d}]}}async function Yr(i,e,t){let n=e?Jr.resolve(process.cwd(),e):process.cwd();if(i==="init"){_.info('Running full initialization (same as "index --force")...'),await z(n,void 0,!0,!0);return}if(i==="tree"){_.info('For tree view, please use the "tree" command.');return}if(i==="topography"){await z(n);let s=C.getInstance(n),r=je(s,n);console.log(`
546
- \u{1F3D7}\uFE0F Architecture Summary for ${Jr.basename(n)}
547
- `),console.log(`Detected Pattern: **${r.pattern}** (Confidence: ${r.patternConfidence.toFixed(0)}%)`),r.insights.length>0&&(console.log(`
548
- Insights:`),r.insights.forEach(l=>console.log(`- ${l}`))),console.log(`
549
- Layer Distribution:`);let o=["Entry","Logic","Data","Utility","Infrastructure","Test","Types","Unknown"],c=Object.values(r.layers).reduce((l,p)=>l+p.count,0),a=l=>{switch(l){case"Entry":return"\u{1F6AA}";case"Logic":return"\u2699\uFE0F";case"Data":return"\u{1F4BE}";case"Utility":return"\u{1F527}";case"Infrastructure":return"\u{1F3D7}\uFE0F";case"Test":return"\u{1F9EA}";case"Types":return"\u{1F4DD}";default:return"\u2753"}};o.forEach(l=>{let p=r.layers[l],d=c>0?(p.count/c*100).toFixed(1):"0.0";console.log(`${a(l)} ${l.padEnd(14)} | ${p.count.toString().padStart(5)} files | ${d}%`)}),console.log(`
550
- Top Files by Layer:`),o.forEach(l=>{let p=r.layers[l];p.count!==0&&(console.log(`
551
- ${a(l)} ${l}`),p.topFiles.forEach(d=>{console.log(` - ${d.path} (${d.confidence}% conf)`),d.signals.length>0&&console.log(` \u2514\u2500 ${d.signals.slice(0,1).join(", ")}`)}))});return}if(i==="scout"){let s=await qr({repoPath:n});console.log(s.content[0].text);return}if(i==="hologram"){let s=new ue(n);console.log(JSON.stringify(s.getSnapshot(),null,2));return}_.error(`Unknown recon mode: ${i}. Available: init, topography, scout, hologram`)}import jt from"path";U();var Ft=class{static extractSnippet(e,t,n=300){if(!e||!t)return"";let s=t.toLowerCase().split(/\s+/).filter(u=>u.length>2&&!["the","and","for","with","from"].includes(u));if(s.length===0)return e.slice(0,n)+"...";let r=e.split(`
552
- `),o=new Array(r.length).fill(0);for(let u=0;u<r.length;u++){let m=r[u].toLowerCase(),f=0,h=0;for(let b of s)m.includes(b)&&(f++,h++);(m.includes("export ")||m.includes("class ")||m.includes("function ")||m.includes("interface "))&&(f+=1),o[u]=h*10+f}let c=0,a=-1,l=5;for(let u=0;u<=r.length-l;u++){let m=0;for(let f=0;f<l;f++)m+=o[u+f];m>a&&(a=m,c=u)}if(a<=0)return e.slice(0,n).trim()+"...";let d=r.slice(c,c+l).join(`
553
- `).trim();return c>0&&(d=`...
554
- `+d),c+l<r.length&&(d=d+`
555
- ...`),d.length>n?d.slice(0,n)+"...":d}static calculateLexicalScore(e,t){if(!e||!t)return 0;let n=t.toLowerCase().split(/\s+/).filter(o=>o.length>2&&!["the","and","for","with","from"].includes(o));if(n.length===0)return 0;let s=0,r=e.toLowerCase();for(let o of n)if(r.includes(o)){s+=1;let c=new RegExp(`\\b${o}`,"gi"),a=r.match(c);a&&(s+=Math.min(a.length*.2,2)),new RegExp(`(class|function|export|interface|enum|type)\\s+${o}`,"i").test(e)&&(s+=1.5)}return s/n.length}};U();P();var Ue=_.child({module:"clean-sweep"}),Rs=class{files;intentLogs;constructor(e){let{files:t,intentLogs:n}=C.getInstance(e);this.files=t,this.intentLogs=n}pruneOrphans(){Ue.info("Starting orphan pruning...");let e=0,t=0,n=this.intentLogs.findOrphans();Ue.info({orphanCount:n.length},"Found orphaned logs");for(let o of n)o.file_path&&this.files.exists(o.file_path)?(this.intentLogs.markAsLapsed(o.id),t++,Ue.debug({logId:o.id,symbolName:o.symbol_name},"Converted to lapsed intent")):(this.intentLogs.delete(o.id),e++,Ue.debug({logId:o.id},"Deleted orphaned log"));let s=this.intentLogs.findLogsForMissingFiles();for(let o of s)this.intentLogs.delete(o.id),e++;let r=this.intentLogs.findRecentDecisionActivity(1e3).length;return Ue.info({deleted:e,converted:t},"Orphan pruning complete"),{deleted:e,converted:t,retained:r}}},vs=class{lambda;constructor(e=.01){this.lambda=e}calculateScore(e,t){let s=(Math.floor(Date.now()/1e3)-t)/(3600*24),r=Math.exp(-this.lambda*s);return e*r}scoreResults(e){return e.map(t=>({...t,decayed_score:this.calculateScore(t.score,t.created_at)}))}},ws=class{missions;constructor(e){let{missions:t}=C.getInstance(e);this.missions=t}findColdMissions(){let e=Math.floor(Date.now()/1e3)-604800,t=this.missions.findColdMissions(e,10);return Ue.info({count:t.length},"Found cold missions for compaction"),t}markDistilled(e){this.missions.update(e,{status:"distilled"})}},Nn=class{pruner;scorer;compactor;constructor(e){this.pruner=new Rs(e),this.scorer=new vs,this.compactor=new ws(e)}runMaintenance(){Ue.info("Initiating Clean Sweep maintenance protocol...");let e=this.pruner.pruneOrphans(),t=this.compactor.findColdMissions();return Ue.info("Clean Sweep maintenance complete"),{pruning:e,compaction:{eligible:t.length}}}getScorer(){return this.scorer}getCompactor(){return this.compactor}};U();P();var Vr=_.child({module:"lineage-service"}),nt=class{repoPath;constructor(e){this.repoPath=e}getAncestorMissionIds(e=50){try{let t=Vi(this.repoPath,e);if(t.length===0)return[];let{missions:n}=C.getInstance(this.repoPath),r=n.findByCommitShas(t).map(o=>o.id);return r.length>0&&Vr.debug({count:r.length},"Identified ancestor missions for gravity bleed"),r}catch(t){return Vr.warn({err:t.message},"Failed to identify ancestor missions"),[]}}};var xc={Solid:1,Liquid:.8,Virtual:.4,Intel:.2,Phantom:.05},be=class{static classify(e,t){let n=e.toLowerCase();if(t?.content){let s=t.content;if(s.includes("describe(")||s.includes("test(")||s.includes("it(")||s.includes("expect(")||s.includes('from "@jest/globals"')||s.includes('from "vitest"'))return"Virtual"}return t?.exports&&(t.exports.some(r=>r.kind==="ClassDeclaration"||r.kind==="Class")||t.exports.length>5),n.includes("/dist/")||n.includes("/build/")||n.includes("/.generated/")||n.includes("/node_modules/")||n.endsWith(".map")||n.endsWith(".log")?"Phantom":n.includes("/test/")||n.includes("/tests/")||n.includes("/__tests__/")||n.includes("/__mocks__/")||n.includes(".spec.")||n.includes(".test.")||n.includes("/e2e/")||n.includes("/test-utils/")?"Virtual":n.includes("/examples/")||n.includes("/fixtures/")||n.includes("/mocks/")||n.includes("/stories/")||n.includes("/samples/")||n.includes("/docs/")?"Intel":n.includes("/src/")||n.includes("/lib/")||n.includes("/app/")||n.includes("/core/")||n.includes("/logic/")||n.includes("/domain/")||n.includes("/services/")||n.includes("/controllers/")||n.includes("/handlers/")||n.includes("/repositories/")||n.includes("/models/")||n.includes("/packages/")&&!n.includes("/packages/config/")||n.includes("/backends/")||t?.exports&&(t.exports.some(s=>s.kind==="ClassDeclaration"||s.kind==="Class")||t.exports.length>5)?"Solid":"Liquid"}static mapClassificationToTier(e){let t=e.toLowerCase();return t==="service"||t==="repository"||t==="model"||t==="controller"||t==="handler"||t==="component"||t==="hook"||t==="titanium"||t==="solid"?"Solid":t==="test"||t==="iron"||t==="virtual"?"Virtual":t==="lead"||t==="intel"?"Intel":t==="ghost"||t==="error"||t==="phantom"?"Phantom":"Liquid"}static getMultiplier(e,t){let n=t?this.mapClassificationToTier(t):this.classify(e);return xc[n]}};P();function Tc(i,e){let t=[];for(let n=0;n<=e.length;n++)t[n]=[n];for(let n=0;n<=i.length;n++)t[0][n]=n;for(let n=1;n<=e.length;n++)for(let s=1;s<=i.length;s++)e.charAt(n-1)===i.charAt(s-1)?t[n][s]=t[n-1][s-1]:t[n][s]=Math.min(t[n-1][s-1]+1,t[n][s-1]+1,t[n-1][s]+1);return t[e.length][i.length]}function Rc(i,e){let t=Tc(i.toLowerCase(),e.toLowerCase()),n=Math.max(i.length,e.length);return Math.round((n-t)/n*100)}function Qr(i){let e=[],t="";for(let n=0;n<i.length;n++){let s=i[n],r=s>="A"&&s<="Z",o=s>="a"&&s<="z";r&&t.length>0?(e.push(t),t=s):o||r?t+=s:t.length>0&&(e.push(t),t="")}return t.length>0&&e.push(t),e}function vc(i,e){let t=Qr(e),n=i.toLowerCase();if(t.map(o=>o[0].toLowerCase()).join("")===n)return!0;let r=0;for(let o of t){if(r>=i.length)break;let c=o.toLowerCase();if(c.startsWith(n.slice(r))){r=i.length;break}c[0]===n[r]&&r++}return r===i.length}function wc(i,e){return Qr(e).map(s=>s[0].toLowerCase()).join("")===i.toLowerCase()}function Ic(i,e){let t=i.toLowerCase(),n=e.toLowerCase();if(i===e)return{matchType:"exact",score:100};if(t===n)return{matchType:"exact-case-insensitive",score:98};if(n.startsWith(t))return{matchType:"prefix",score:90+i.length/e.length*8};if(n.endsWith(t))return{matchType:"suffix",score:80+i.length/e.length*8};if(n.includes(t)){let r=i.length/e.length,o=n.indexOf(t)/e.length;return{matchType:"substring",score:70+r*10-o*5}}return wc(i,e)?{matchType:"acronym",score:75}:vc(i,e)?{matchType:"camel-case",score:65}:{matchType:"levenshtein",score:Rc(i,e)*.6}}function Ht(i,e,t=50,n=5){let s=[];for(let r of e){let{matchType:o,score:c}=Ic(i,r);if(c>=t){let l={exact:1e3,"exact-case-insensitive":900,prefix:800,suffix:700,substring:600,acronym:550,"camel-case":500,levenshtein:100}[o]+c;s.push({match:r,score:c,matchType:o,rank:l})}}return s.sort((r,o)=>o.rank!==r.rank?o.rank-r.rank:o.score!==r.score?o.score-r.score:r.match.length-o.match.length),s.slice(0,n)}dt();var Be=class i{constructor(e){this.repoPath=e}get filesRepo(){return C.getInstance(this.repoPath).files}get exportsRepo(){return C.getInstance(this.repoPath).exports}static normalizeFileType(e){if(e==null)return;let t=Array.isArray(e)?e:e.split(",").map(n=>n.trim().replace(/^\./,""));return t.filter(Boolean).length?t:void 0}static matchesFilters(e,t,n,s){if(t.fileType?.length){let r=e.replace(/^.*\./,"").toLowerCase();if(!t.fileType.some(o=>o.toLowerCase()===r))return!1}if(t.layer!=null||t.excludeLayers&&t.excludeLayers.length>0){let r=s!=null?be.mapClassificationToTier(s):be.classify(e);if(t.layer!=null&&r!==t.layer||t.excludeLayers?.includes(r))return!1}return!0}async searchByPath(e,t,n,s,r,o=!1){let c=e.toLowerCase().split(/\s+/).filter(Boolean),a=this.filesRepo.findByPathKeywords(c,Math.min((t??50)*(r?ae.FILTERED_QUERY_LIMIT_MULTIPLIER:1),at.MAX_LIMIT));r&&(a=a.filter(d=>i.matchesFilters(d.path,s,d.mtime,d.classification)),a=a.slice(0,t??50));let l=d=>d.replace(this.repoPath,"").replace(/^\//,"");if(a.length===0)return{content:[{type:"text",text:`No indexed files match path/filename: "${e}".
556
-
557
- If the repo is not indexed, run shadow_recon_onboard then shadow_sync_trace. Otherwise try broader keywords.`}]};if(o){let u=new ue(this.repoPath).getSection("gravity"),m=new Map;if(u?.hotspots)for(let b of u.hotspots){let y=m.get(b.filePath)||0;m.set(b.filePath,y+b.gravity)}let f=a.map(b=>{let y=m.get(b.path)||0,g=b.classification?be.mapClassificationToTier(b.classification):be.classify(b.path);return{...b,gravity:y,layer:g}});return f.sort((b,y)=>y.gravity-b.gravity),{content:[{type:"text",text:`# Resolved paths: "${e}" (Ranked by Gravity)
546
+ `;default:return""}}mapKind(e,r){if(e==="import")return"ImportDeclaration";if(r===".php"){if(e==="func")return"FunctionDeclaration";if(e==="class")return"ClassDeclaration";if(e==="interface")return"InterfaceDeclaration";if(e==="trait")return"TraitDeclaration";if(e==="method")return"MethodDeclaration"}if(r===".py"){if(e==="func")return"FunctionDeclaration";if(e==="class")return"ClassDeclaration"}if(r===".go"){if(e==="func")return"FunctionDeclaration";if(e==="type")return"TypeDeclaration"}if(r===".rs"){if(e==="func")return"FunctionDeclaration";if(e==="struct")return"StructDeclaration";if(e==="enum")return"EnumDeclaration";if(e==="trait")return"TraitDeclaration";if(e==="type")return"TypeDeclaration"}return"Unknown"}mapClassification(e){return e==="import"?"Dependency":e==="func"||e==="method"?"Function":e==="class"||e==="interface"||e==="trait"||e==="struct"||e==="enum"||e==="type"?"Class":"Other"}async parse(e,r){await this.ensureInitialized();let i=Dh.extname(e).toLowerCase(),t=await this.getLanguage(i);if(!t||!this.parser)return[];this.parser.setLanguage(t);let o=this.parser.parse(r),s=r.split(`
547
+ `),a=this.getQueries(i);if(!a)return[];let l=new $n.Query(t,a).matches(o.rootNode),u=[];for(let d of l){let p=d.captures.find(h=>h.name==="name")?.node,m=d.captures[0].node,f=d.captures[0].name;if(p){let h=m.startPosition.row+1,_=m.endPosition.row+1,v=s[m.startPosition.row].trim();u.push({name:p.text,kind:this.mapKind(f,i),classification:this.mapClassification(f),signature:v,line:h,endLine:_,doc:"",capabilities:"{}"})}}return u}};var So=class{parse(e,r=!1){let i=[],t=[],o=e.split(`
548
+ `),s="",a="",c=0,l=0,u=-1,d=-1,p=[],m=[],f=!1,h=r?"api":"",_="",v=/^namespace\s+([a-zA-Z0-9_\\]+);/,y=/^(?:abstract\s+)?(?:readonly\s+)?class\s+([a-zA-Z0-9_]+)/,k=/^interface\s+([a-zA-Z0-9_]+)/,$=/^trait\s+([a-zA-Z0-9_]+)/,w=/^(?:public|protected|private|static|\s)*function\s+([a-zA-Z0-9_]+)\s*\(/,I=/^use\s+([a-zA-Z0-9_\\]+)(?:\s+as\s+([a-zA-Z0-9_]+))?;/,P=/^#\[([a-zA-Z0-9_\\]+)(?:\((.*)\))?\]/,R=/(?:Route::|router->|\$router->|->)(get|post|put|delete|patch|match)\s*\(\s*(?:uri\s*:\s*)?['"]([^'"]+)['"]/,F=/->prefix\s*\(\s*(?:prefix\s*:\s*)?['"]([^'"]+)['"]/;for(let T=0;T<o.length;T++){let A=o[T].trim();if(!A)continue;let H=(A.match(/{/g)||[]).length,J=(A.match(/}/g)||[]).length,M=l;if(l+=H-J,a&&l<=d){let K=i.find(B=>B.name===a&&B.line===c);K&&(K.endLine=T+1),a="",d=-1}if(s&&l<=u){let K=i.find(B=>B.name===s&&(B.kind==="ClassDeclaration"||B.kind==="TraitDeclaration"||B.kind==="InterfaceDeclaration"));K&&(K.endLine=T+1),s="",u=-1}let N=A.match(F);if(N&&(h=N[1]),A.includes("});")&&(h=""),A.startsWith("/**")){f=!0,m=[];continue}if(f){A.endsWith("*/")?f=!1:m.push(A.replace(/^\*\s?/,""));continue}let W=A.match(P);if(W){p.push(W[1]);continue}let q=A.match(v);if(q){_=q[1]||"",p=[],m=[];continue}let Z=A.match(y);if(Z){s=Z[1],u=l-H;let K={attributes:p};_&&(K.namespace=_),i.push({name:s,kind:"ClassDeclaration",classification:"Class",signature:`class ${s}`,line:T+1,endLine:T+1,doc:m.join(`
549
+ `).trim(),capabilities:JSON.stringify(K),members:[]}),p=[],m=[];continue}let U=A.match(k);if(U){let K=U[1];s=K,u=l-H,i.push({name:K,kind:"InterfaceDeclaration",classification:"Interface",signature:`interface ${K}`,line:T+1,endLine:T+1,doc:m.join(`
550
+ `).trim(),capabilities:JSON.stringify({attributes:p}),members:[]}),p=[],m=[];continue}let he=A.match($);if(he){let K=he[1];s=K,u=l-H,i.push({name:K,kind:"TraitDeclaration",classification:"Trait",signature:`trait ${K}`,line:T+1,endLine:T+1,doc:m.join(`
551
+ `).trim(),capabilities:JSON.stringify({attributes:p}),members:[]}),p=[],m=[];continue}let V=A.match(w);if(V){let K=V[1],B=!!s;a=K,c=T+1,d=l-H;let Me=!1,It={};for(let Ne of p)Ne.toLowerCase().includes("route")&&(Me=!0,It={type:"route",method:"GET",path:"/"});let Tt=m.join(`
552
+ `).trim();if(Me){let Ne=It.path||"/";i.push({name:Ne,kind:"HTTP Route",classification:"Service Boundary",signature:`Function: ${K}`,line:T+1,endLine:T+1,doc:Tt,capabilities:JSON.stringify({type:"route",handler:s?`${s}@${K}`:K,...It})}),t.push({type:"api_route",name:Ne,direction:"consume",line:T+1,snippet:A})}i.push({name:K,kind:B?"MethodDeclaration":"FunctionDeclaration",classification:B?"Method":"Function",signature:`${B?s+":: ":""}${K}`,line:T+1,endLine:T+1,doc:Tt,capabilities:JSON.stringify({attributes:p})}),p=[],m=[];continue}let ne=A.match(I);if(ne){let K=ne[1]||"",B=ne[2]||K.split("\\").pop()||"";i.push({name:B,kind:"ImportSpecifier",classification:"Dependency",signature:`use ${K}`,line:T+1,endLine:T+1,doc:"",capabilities:JSON.stringify({type:"use",namespace:K})}),p=[],m=[];continue}let pe=A.match(R);if(pe){let K=pe[1].toUpperCase(),B=pe[2];if(A.includes("Route::")||A.includes("router->")||A.includes("action")||A.includes(",")&&!A.includes("view(")){if(h){let Zt=h.startsWith("/")?h:`/${h}`,rc=B.startsWith("/")?B:`/${B}`;B=(Zt+rc).replace(/\/+/g,"/")}let It=null,Tt=A.match(/\[\s*([a-zA-Z0-9_]+)::class\s*,\s*['"]([^'"]+)['"]\s*\]/);if(Tt)It=`${Tt[1]}@${Tt[2]}`;else if(A.includes("::class")){let Zt=A.match(/([a-zA-Z0-9_]+)::class/);Zt&&(It=Zt[1])}let Ne=A;!A.endsWith(");")&&T+1<o.length&&(Ne+=" "+o[T+1].trim(),!Ne.endsWith(");")&&T+2<o.length&&(Ne+=" "+o[T+2].trim())),i.push({name:B,kind:"HTTP Route",classification:"Service Boundary",signature:Ne,line:T+1,endLine:T+1,doc:"",capabilities:JSON.stringify({type:"route",method:K,path:B,handler:It})}),t.push({type:"api_route",name:B,direction:"consume",line:T+1,snippet:Ne,method:K,url:B}),m=[];continue}}let ye=/(?:\$client|client|Http)::(get|post|put|delete|patch|request)\s*\(\s*(?:url\s*:\s*)?([^,)]+)|(?:\$client|client)->(request|get|post|put|delete|patch)\s*\(\s*([^,)]+)/,de=A.match(ye);if(de){let K=(de[1]||de[3]).toUpperCase(),B=(de[2]||de[4]).trim();(B.startsWith("'")&&B.endsWith("'")||B.startsWith('"')&&B.endsWith('"'))&&(B=B.substring(1,B.length-1)),t.push({type:"api_route",name:B,direction:"produce",line:T+1,snippet:A,method:K,url:B})}!A.startsWith("#[")&&!A.startsWith("//")&&!A.startsWith("*")&&!f&&(p=[],m=[])}return{nodes:i,events:t}}};var $o=class{currentRoutePrefix="";parse(e){this.currentRoutePrefix="";let r=[],i=[],t=e.split(`
553
+ `),o=[{indent:-1,name:"root",type:"root"}],s=[],a=/^class\s+([a-zA-Z0-9_]+)/,c=/^async\s+def\s+([a-zA-Z0-9_]+)|^def\s+([a-zA-Z0-9_]+)/,l=/^(?:from\s+([a-zA-Z0-9_\.]+)\s+import|import\s+([a-zA-Z0-9_\.]+))/,u=/^@(.*)/;function d(v){return v.trim().split(/[.(]/)[0]?.trim()||v}function p(v){let y=v.decorators.map($=>d($.raw)),k={decorators:v.decorators,decoratorNames:y};return v.async===!0&&(k.async=!0),JSON.stringify(k)}let m=!1,f="",h=[],_=[];for(let v=0;v<t.length;v++){let y=t[v],k=y.trim();if(!k||k.startsWith("#"))continue;let $=/^([a-zA-Z0-9_]+)\s*=\s*(?:APIRouter|Blueprint)\s*\(\s*(?:prefix\s*=\s*)?['"]([^'"]+)['"]/,w=k.match($);if(w&&(this.currentRoutePrefix=w[2]),m){if(k.endsWith(f)||k.includes(f)){m=!1;let Z=k.replace(f,"").trim();Z&&h.push(Z);let U=o[o.length-1];U.node&&(U.node.doc=h.join(`
554
+ `).trim()),h=[]}else h.push(k);continue}let I=y.search(/\S/),P=y.trim(),R=P.match(/^(['"]{3})/);if(R){let Z=R[1],U=o[o.length-1];if(U.node&&!U.node.doc){if(P.substring(3).includes(Z)){let he=P.replace(new RegExp(Z,"g"),"").trim();U.node.doc=he}else{m=!0,f=Z;let he=P.substring(3).trim();he&&h.push(he)}continue}}for(;o.length>1&&o[o.length-1].indent>=I;)o.pop();let F=o[o.length-1],T=P.match(u);if(T){s.push({raw:T[1].trim(),line:v+1});continue}let A=P.match(a);if(A){let Z=A[1],U={name:Z,kind:"ClassDeclaration",classification:"Class",signature:`class ${Z}`,line:v+1,endLine:v+1,doc:"",capabilities:p({decorators:s}),members:[]};_.push(U),F.node?(F.node.members||(F.node.members=[]),F.node.members.push(U)):r.push(U),o.push({indent:I,name:Z,type:"class",node:U}),s=[];continue}let H=P.match(c);if(H){let Z=!!H[1],U=H[1]||H[2],he=F.type==="class",V=!1,ne={};for(let B of s)if(B.raw.match(/(?:app|router)\.(get|post|put|delete|patch)/)){V=!0;let It=["get","post","put","delete","patch"].find(Zt=>B.raw.toLowerCase().includes(`.${Zt}`))?.toUpperCase()||"GET",Tt=B.raw.match(/['"]([^'"]+)['"]/),Ne=Tt?Tt[1]:"/";if(this.currentRoutePrefix){let Zt=this.currentRoutePrefix.endsWith("/")?this.currentRoutePrefix.slice(0,-1):this.currentRoutePrefix,rc=Ne.startsWith("/")?Ne:`/${Ne}`;Ne=Zt+rc}ne={type:"route",method:It,path:Ne}}if(V){let B=ne.path||"",Me={name:B||U,kind:"HTTP Route",classification:"Service Boundary",signature:`Function: ${U}`,line:v+1,endLine:v+1,doc:"",capabilities:JSON.stringify({handler:he?`${F.name}.${U}`:U,async:Z,...ne})};_.push(Me),r.push(Me),i.push({type:"api_route",name:B,direction:"consume",line:v+1,snippet:P})}let pe=s.some(B=>B.raw==="staticmethod"),ye=s.some(B=>B.raw==="classmethod"),de=`${Z?"async ":""}${he?(pe?"@staticmethod ":ye?"@classmethod ":"")+F.name+".":""}${U}`,K={name:U,kind:Z&&he?"AsyncMethodDeclaration":Z?"AsyncFunctionDeclaration":he?"MethodDeclaration":"FunctionDeclaration",classification:he?pe||ye?"Static Method":"Method":"Function",signature:de,line:v+1,endLine:v+1,doc:"",capabilities:p({decorators:s,async:Z}),members:[]};_.push(K),F.node?(F.node.members||(F.node.members=[]),F.node.members.push(K)):r.push(K),o.push({indent:I,name:U,type:"function",node:K}),s=[];continue}let J=/^(?:path|re_path|url)\s*\(\s*['"]([^'"]+)['"]/,M=P.match(J);if(M){let Z=M[1].replace(/^\^/,""),U={name:Z,kind:"HTTP Route",classification:"Service Boundary",signature:P.trim(),line:v+1,endLine:v+1,doc:"",capabilities:JSON.stringify({type:"route",method:"GET",path:Z})};_.push(U),r.push(U),i.push({type:"api_route",name:Z,direction:"consume",line:v+1,snippet:P});continue}let N=/(?:requests|httpx|client|http)\.(get|post|put|delete|patch|request)\s*\(\s*(?:url\s*:\s*)?([^,)]+)/,W=P.match(N);if(W){let Z=W[1].toUpperCase(),U=W[2].trim();(U.startsWith("'")&&U.endsWith("'")||U.startsWith('"')&&U.endsWith('"'))&&(U=U.substring(1,U.length-1)),i.push({type:"api_route",name:U,direction:"produce",line:v+1,snippet:P,method:Z,url:U})}let q=P.match(l);if(q){let Z=q[1]||q[2],U={name:Z,kind:"ImportSpecifier",classification:"Dependency",signature:`import ${Z}`,line:v+1,endLine:v+1,doc:"",capabilities:JSON.stringify({type:"import",module:Z})};_.push(U),r.push(U),s=[];continue}s=[],F.node&&(F.node.endLine=v+1)}return{nodes:_,events:i}}};var Ch=[{extension:[".php"],rules:[]},{extension:[".py"],rules:[]},{extension:[".go"],rules:[{regex:/func\s+([a-zA-Z0-9_]+)\(/g,onMatch:n=>({name:n[1],kind:"FunctionDeclaration",classification:"Function",signature:n[0]})},{regex:/func\s+\([^\)]+\)\s+([a-zA-Z0-9_]+)\(/g,onMatch:n=>({name:n[1],kind:"MethodDeclaration",classification:"Method",signature:n[0]})},{regex:/import\s+['"]([^'"]+)['"]/g,onMatch:n=>({name:n[1],kind:"ImportSpecifier",classification:"Dependency",signature:n[0],meta:{type:"import",path:n[1]}})}]},{extension:[".rs"],rules:[{regex:/fn\s+([a-zA-Z0-9_]+)\s*\(/g,onMatch:n=>({name:n[1],kind:"FunctionDeclaration",classification:"Function",signature:n[0]})},{regex:/struct\s+([a-zA-Z0-9_]+)/g,onMatch:n=>({name:n[1],kind:"StructDeclaration",classification:"Class",signature:n[0]})},{regex:/enum\s+([a-zA-Z0-9_]+)/g,onMatch:n=>({name:n[1],kind:"EnumDeclaration",classification:"Class",signature:n[0]})},{regex:/trait\s+([a-zA-Z0-9_]+)/g,onMatch:n=>({name:n[1],kind:"TraitDeclaration",classification:"Class",signature:n[0]})},{regex:/use\s+([a-zA-Z0-9_:]+(?:\s+as\s+[a-zA-Z0-9_]+)?);/g,onMatch:n=>({name:n[1].trim(),kind:"ImportDeclaration",classification:"Dependency",signature:n[0],meta:{type:"import",path:n[1].trim()}})}]},{extension:[".ts",".tsx",".js",".jsx",".mjs",".cjs"],rules:[{regex:/(?:export\s+)?(?:async\s+)?function\s+([a-zA-Z0-9_]+)\s*\(/g,onMatch:n=>({name:n[1],kind:"FunctionDeclaration",classification:"Function"})},{regex:/(?:export\s+)?class\s+([a-zA-Z0-9_]+)/g,onMatch:n=>({name:n[1],kind:"ClassDeclaration",classification:"Class"})},{regex:/(?:export\s+)?interface\s+([a-zA-Z0-9_]+)/g,onMatch:n=>({name:n[1],kind:"InterfaceDeclaration",classification:"Interface"})},{regex:/(?:export\s+)?const\s+([a-zA-Z0-9_]+)\s*=/g,onMatch:n=>({name:n[1],kind:"VariableDeclaration",classification:"Constant"})},{regex:/import\s+.*\s+from\s+['"]([^'"]+)['"]/g,onMatch:n=>({name:n[1],kind:"ImportDeclaration",classification:"Dependency",meta:{path:n[1]}})}]}];function Nx(n,e){let r=[];if(n===".go"&&e.some(i=>i.kind==="TypeDeclaration")&&r.push("Go type"),n===".rs"&&(e.some(i=>i.kind==="TraitDeclaration")&&r.push("Rust trait"),e.some(i=>i.kind==="StructDeclaration")&&r.push("Rust struct"),e.some(i=>i.kind==="EnumDeclaration")&&r.push("Rust enum")),n===".py"){for(let i of e)if(i.capabilities)try{if(JSON.parse(i.capabilities).decoratorNames?.length){r.push("Python decorators");break}}catch{}e.some(i=>i.kind==="AsyncFunctionDeclaration"||i.kind==="AsyncMethodDeclaration")&&r.push("Async")}return r}var wo=class{phpParser=new So;pythonParser=new $o;treeSitterParser=new xo;supports(e){return Ch.some(r=>r.extension.includes(e.toLowerCase()))}async parse(e,r){let i=Sc.extname(e).toLowerCase(),t=[],o=[];if(i===".php"||i===".py"||i===".go"||i===".rs"){if(i===".py"){let c=this.pythonParser.parse(r);t=c.nodes,o=c.events}else if(i===".php"){let c=e.toLowerCase().endsWith("api.php"),l=this.phpParser.parse(r,c);t=l.nodes,o=l.events}else try{t=await this.treeSitterParser.parse(e,r)}catch{}if(t.length>0){let c=i===".php"?"Micro IR (PHP/TS) ":i===".py"?"Micro IR (Python/TS) ":i===".go"?"Micro IR (Go/TS) ":"Micro IR (Rust/TS) ",l=t.filter(m=>m.classification!=="Dependency"),u=t.filter(m=>m.classification==="Dependency"),d=Nx(i,t),p=Xr({classification:c,capabilities:d,exports:l.map(m=>({name:m.name,kind:m.kind,classification:m.classification})),fileName:Sc.basename(e)});return{exports:l,imports:u.map(m=>({module:m.name,name:m.name,kind:m.kind,classification:m.classification})),events:o,classification:c,summary:p||`${i.substring(1).toUpperCase()} module`,parseStatus:"success"}}}let s=Ch.find(c=>c.extension.includes(i));if(!s)return{exports:[],imports:[],classification:"Unknown",summary:"",parseStatus:"failed",parseError:`Unsupported file extension: ${i}`};for(let c of s.rules){c.regex.lastIndex=0;let l;for(;(l=c.regex.exec(r))!==null;){let u=c.onMatch(l),d=r.substring(0,l.index).split(`
555
+ `).length;t.push({name:u.name||"anonymous",kind:u.kind||"Unknown",classification:u.classification||"Other",signature:u.signature||l[0],line:d,endLine:d,doc:"",capabilities:JSON.stringify(u.meta||{})})}}let a=Xr({classification:`Micro IR (${i.substring(1).toUpperCase()})`,capabilities:[],exports:t.map(c=>({name:c.name,kind:c.kind,classification:c.classification})),fileName:Sc.basename(e)});return{exports:t,imports:[],classification:`Micro IR (${i.substring(1).toUpperCase()})`,summary:a||"Module",parseStatus:t.length>0?"success":"partial"}}};G();var wc=new wo;async function Qr(n){let e=Ah.extname(n);if(wc.supports(e)&&e!==".ts"&&e!==".tsx")try{let o=await Lh.promises.readFile(n,"utf-8");return{...await wc.parse(n,o),content:o}}catch(o){return x.error({filePath:n,error:o.message},"HeuristicParser failed"),{exports:[],imports:[],classification:"Unknown",summary:"",content:"",parseStatus:"failed",parseError:o.message}}let r;try{r=await Lh.promises.readFile(n)}catch(o){return{exports:[],imports:[],classification:"Error",summary:"",content:"",parseStatus:"failed",parseError:`File read error: ${o.message}`}}let i=r.toString("utf8"),t=Sh(i);try{let o=n.endsWith(".tsx"),s=n.endsWith(".d.ts")||n.endsWith(".d.tsx"),a,c={syntax:"typescript",tsx:o,decorators:!0,comments:!0};if(s)try{a=$c.parseSync(i,c)}catch{a=$c.parseSync(i,{...c,isModule:!1})}else a=$c.parseSync(i,c);let l=a.span.start,u=$h(r),d=kh(i),p=$=>wh($,l,r),m=Ih(a.body),f=Rh(a.body);f.length>0&&x.debug({filePath:n,count:f.length},"Extracted type references"),f.forEach($=>{m.push({module:"__type_reference__",name:$})});let h=Th(a.body,l,r,i,t,d,n,p,u),_=Ph(a.body,l,r,t,p,u),v=_o(n,"","Module"),y=d.length>0&&d[0].start===0?d[0].text:h.find($=>$.doc)?.doc||"",k=Eh(y);if(!k&&h.length>0){let $=Yr(i);k=Xr({classification:v,capabilities:$,exports:h.map(w=>({name:w.name,kind:w.kind,classification:w.classification})),fileName:Ah.basename(n)})}return{exports:h,imports:m,events:_,classification:v,summary:k,content:i,parseStatus:"success"}}catch(o){x.warn({filePath:n,error:o.message},"SWC parsing failed, using heuristic fallback");try{let s=await wc.parse(n,i);return{...s,content:i,classification:s.classification+" (Degraded)",parseStatus:"partial",parseError:`SWC failed, used heuristic fallback: ${o.message}`}}catch(s){return x.error({filePath:n,error:s.message},"All parsing strategies failed"),{exports:[],imports:[],classification:"Error",summary:"",content:i,parseStatus:"failed",parseError:`All parsing strategies failed: ${s.message}`}}}}import ko from"path";var zx=50;function ei(n,e,r,i){let t={name:ko.basename(e)||e,type:"directory",path:e,children:[]};return n.forEach(o=>{let a=ko.relative(e,o.path).split(ko.sep),c=t;for(let l=0;l<a.length;l++){let u=a[l];if(i!==void 0&&l>=i)return;let d=l===a.length-1;if(i===1&&l===0&&d)return;let p=i!==void 0&&l===i-1&&!d,m=ko.join(e,...a.slice(0,l+1)),f=c.children?.find(h=>h.name===u);if(!f){if(c.children&&c.children.length>=zx){c.children.find(v=>v.type==="truncated")||c.children.push({name:"... (truncated) ",type:"truncated",path:"",children:void 0});return}f={name:u,type:d?"file":"directory",path:m,children:d||p?void 0:[],summary:d?{classification:o.classification,summaryText:o.summary,exports:o.exports,imports:o.imports,chunks:o.chunks}:void 0},f.summary&&(r==="structure"||r==="signatures")&&(delete f.summary.chunks,delete f.summary.imports),c.children?.push(f)}c=f}}),t}G();import Lc from"p-limit";st();import Ac from"path";import aS from"fs";import cS from"os";import lt from"path";import Kn from"fs";import{loadConfig as Lx,createMatchPath as Ax}from"tsconfig-paths";import Gt from"path";import ti from"fs";var Jt=class extends Error{constructor(r,i,t){super(i);this.code=r;this.cause=t;this.name="FileSystemError"}};function Oh(n){let e;try{e=ti.statSync(n).isDirectory()?n:Gt.dirname(n)}catch(r){throw r.code==="ENOENT"?new Jt("FILE_NOT_FOUND",`Start path does not exist: ${n}`,r):r.code==="EACCES"||r.code==="EPERM"?new Jt("PERMISSION_DENIED",`Permission denied accessing: ${n}`,r):new Jt("UNKNOWN",`Failed to access path: ${n}`,r)}for(;e!==Gt.dirname(e);){let r=Gt.join(e,"tsconfig.json");if(ti.existsSync(r))return e;e=Gt.dirname(e)}return null}function Mh(n){let e;try{e=ti.statSync(n).isDirectory()?n:Gt.dirname(n)}catch(r){throw r.code==="ENOENT"?new Jt("FILE_NOT_FOUND",`Start path does not exist: ${n}`,r):r.code==="EACCES"||r.code==="EPERM"?new Jt("PERMISSION_DENIED",`Permission denied accessing: ${n}`,r):new Jt("UNKNOWN",`Failed to access path: ${n}`,r)}for(;e!==Gt.dirname(e);){let r=Gt.join(e,"package.json");if(ti.existsSync(r))try{if(JSON.parse(ti.readFileSync(r,"utf8")).workspaces)return e}catch{}e=Gt.dirname(e)}return null}import Jn from"path";import wn from"fs";function jh(n,e){let r=new Map,i=e.workspaces||[];for(let t of i){let o=t.replace("/*",""),s=Jn.join(n,o);if(!wn.existsSync(s))continue;let a=wn.readdirSync(s);for(let c of a){let l=Jn.join(s,c,"package.json");if(wn.existsSync(l))try{let u=JSON.parse(wn.readFileSync(l,"utf8"));u.name&&r.set(u.name,{name:u.name,path:Jn.dirname(l),main:u.main||"dist/index.js"})}catch{}}}return r}function Uh(n){let e=new Map;try{let r=JSON.parse(wn.readFileSync(n,"utf8")),i={...r.dependencies,...r.devDependencies};for(let[t,o]of Object.entries(i))if(typeof o=="string"&&o.startsWith("file:")){let s=o.substring(5),a=Jn.dirname(n),c=Jn.resolve(a,s),l=Jn.join(c,"package.json");if(wn.existsSync(l))try{let u=JSON.parse(wn.readFileSync(l,"utf8"));e.set(t,{name:t,path:c,main:u.main||"dist/index.js"})}catch{}}}catch{}return e}import Fh from"path";import ct from"fs";var Dx=[".ts",".tsx",".d.ts",".js",".jsx"];function Xe(n){let e=Fh.extname(n);if(e===".js"||e===".jsx"){let r=n.slice(0,-e.length),i=e===".jsx"?[".tsx",".ts"]:[".ts",".tsx"];for(let t of i){let o=r+t;if(ct.existsSync(o)&&ct.statSync(o).isFile())return o}if(ct.existsSync(n)&&ct.statSync(n).isFile())return n}if(ct.existsSync(n)&&ct.statSync(n).isFile())return n;for(let r of Dx){let i=n+r;if(ct.existsSync(i)&&ct.statSync(i).isFile())return i}if(ct.existsSync(n)&&ct.statSync(n).isDirectory())for(let r of[".ts",".tsx",".js",".jsx"]){let i=Fh.join(n,"index"+r);if(ct.existsSync(i))return i}return""}import qn from"path";import Cx from"fs";function Eo(n,e,r){if(n.startsWith(".")){let t=qn.dirname(e),o=qn.resolve(t,n),s=Xe(o);return s?{resolved:!0,resolvedPath:s}:{resolved:!1,error:`File not found at relative path: ${o}`,suggestion:"Check if the file exists and has a supported extension (.ts, .tsx, .js, .jsx)"}}let i=Vn(e);if(i){if(i.matchPath){let o=i.matchPath(n);if(o){let s=Xe(o);return s?{resolved:!0,resolvedPath:s}:{resolved:!1,error:`Path alias matched to '${o}' but file does not exist`,suggestion:"Check if the target file exists or if the alias mapping in tsconfig.json is correct"}}}if(!n.startsWith("@")){let o=qn.resolve(i.baseUrl,n),s=Xe(o);if(s)return{resolved:!0,resolvedPath:s}}let t=i.workspacePackages.get(n);if(t){let o=qn.join(t.path,"src/index.ts");if(Cx.existsSync(o))return{resolved:!0,resolvedPath:o};let s=qn.join(t.path,t.main),a=Xe(s);return a?{resolved:!0,resolvedPath:a}:{resolved:!1,error:`Workspace package '${n}' found at ${t.path} but entry point not found`,suggestion:`Check main field in ${qn.join(t.path,"package.json")}`}}}else return{resolved:!1,error:"No tsconfig.json found",suggestion:"Ensure a tsconfig.json exists in the project root or parent directories"};return n.startsWith("@")?{resolved:!1,error:`Path alias '${n}' not found in tsconfig.json paths`,suggestion:'Check tsconfig.json "paths" configuration'}:{resolved:!1,error:"Module not found (treated as external) ",suggestion:"Install dependency or check import path"}}var Io=new Map;function Vn(n){let e=Oh(n);if(!e)return null;if(Io.has(e))return Io.get(e)||null;let r=Lx(e);if(r.resultType==="failed")return Io.set(e,null),null;let i=r,t=i.absoluteBaseUrl;!t&&i.paths&&Object.keys(i.paths).length>0&&(t=i.configFileAbsolutePath?lt.dirname(i.configFileAbsolutePath):e);let o=Ax(t,i.paths,i.mainFields,i.addMatchAll),s=Mh(e),a=new Map;if(s){let d=lt.join(s,"package.json");if(Kn.existsSync(d))try{let p=JSON.parse(Kn.readFileSync(d,"utf8"));a=jh(s,p)}catch{}}let c=lt.join(e,"package.json");Kn.existsSync(c)&&Uh(c).forEach((p,m)=>a.set(m,p));let l={baseUrl:t||"",paths:i.paths,matchPath:o,workspacePackages:a,imports:new Map},u=lt.join(e,"package.json");if(Kn.existsSync(u))try{let d=JSON.parse(Kn.readFileSync(u,"utf8"));if(d.imports){for(let[p,m]of Object.entries(d.imports))if(typeof m=="string"||typeof m=="object"&&m!==null){let f=m;Array.isArray(m)&&(f=m[0]),typeof f=="object"&&(f=f.default||f.node),typeof f=="string"&&l.imports.set(p,f)}}}catch{}return Io.set(e,l),l}function qt(n,e,r){if(!n)return"";if(n.includes(".")&&!n.startsWith(".")&&!n.startsWith("/")&&!n.endsWith(".js")&&!n.endsWith(".ts")&&!n.endsWith(".json")){let t=n.split(".")[0];if(t&&t!==n){let o=qt(t,e,r);if(o)return o}}if(n.startsWith(".")){let t=lt.dirname(e),o=lt.resolve(t,n);return Xe(o)}let i=Vn(e);if(i){let t=i.matchPath(n);if(t)return Xe(t);if(!n.startsWith("@")||n.startsWith("@/")){let s=lt.resolve(i.baseUrl,n),a=Xe(s);if(a)return a}for(let[s,a]of i.imports.entries())if(s.includes("*")){let c="^"+s.replace(/[\\^$+.()|[\]{}]/g,"\\$&").replace(/\*/g,"(.*)")+"$",l=new RegExp(c),u=n.match(l);if(u){let d=u[1],p=a.replace("*",d),m=lt.resolve(i.baseUrl,p);return Xe(m)}}else if(s===n){let c=lt.resolve(i.baseUrl,a);return Xe(c)}let o=i.workspacePackages.get(n);if(o){let s=lt.join(o.path,"src/index.ts");if(Kn.existsSync(s))return s;let a=lt.join(o.path,o.main),c=Xe(a);if(c)return c}}return""}import Ox from"fs";import Mx from"path";import Hh from"js-yaml";function Zh(n){let e=Mx.basename(n),r=Ox.readFileSync(n,"utf8"),i=[];if(e.endsWith(".prisma"))return{...Zx(r,n),content:r};if(e.endsWith(".graphql")||e.endsWith(".gql"))return{...Hx(r,n),content:r};let t="Configuration";return e==="lerna.json"?{...Bx(r,n),content:r}:e==="turbo.json"?{...Gx(r,n),content:r}:e==="pnpm-workspace.yaml"?{...Jx(r,n),content:r}:(e.includes("Dockerfile")?(t="Infrastructure (Docker) ",jx(r,i)):e.endsWith(".yaml")||e.endsWith(".yml")?(t="Infrastructure (YAML) ",Ux(r,i)):e.startsWith(".env")?(t="Configuration (Env) ",Fx(r,i)):e==="package.json"&&(t="Project Manifest",Wx(r,i)),{configs:i,classification:t,content:r})}function jx(n,e){let r=n.split(`
556
+ `);for(let i of r){let t=i.trim();if(t.startsWith("FROM "))e.push({key:"base_image",value:t.substring(5).trim(),kind:"Image"});else if(t.startsWith("EXPOSE "))e.push({key:"port",value:t.substring(7).trim(),kind:"Port"});else if(t.startsWith("ENV ")){let o=t.substring(4).trim().split(/\s+|=/);if(o[0]){let s=o[0],a=o.slice(1).join("= ").trim()||"undefined",c="Env";(s.endsWith("_URI")||s.endsWith("_URL")||s.endsWith("_HOST"))&&(c="Service"),e.push({key:s,value:a,kind:c})}}}}function Ux(n,e){try{let r=Hh.load(n);if(!r||typeof r!="object")return;if(r.services&&typeof r.services=="object")for(let[t,o]of Object.entries(r.services)){if(!o||typeof o!="object")continue;let s=o;if(e.push({key:`service:${t}`,value:t,kind:"Service"}),s.image&&e.push({key:`service:${t}:image`,value:String(s.image),kind:"Image"}),Array.isArray(s.ports)&&s.ports.forEach(a=>{e.push({key:`service:${t}:port`,value:String(a),kind:"Port"})}),s.environment){if(Array.isArray(s.environment))s.environment.forEach(a=>{let[c,...l]=a.split("= ");c&&l.length>0&&e.push({key:`service:${t}:env:${c}`,value:l.join("= "),kind:"Env"})});else if(typeof s.environment=="object")for(let[a,c]of Object.entries(s.environment))e.push({key:`service:${t}:env:${a}`,value:String(c),kind:"Env"})}if(Array.isArray(s.depends_on))s.depends_on.forEach(a=>{e.push({key:`service:${t}:depends_on`,value:a,kind:"Dependency"})});else if(s.depends_on&&typeof s.depends_on=="object")for(let a of Object.keys(s.depends_on))e.push({key:`service:${t}:depends_on`,value:a,kind:"Dependency"})}let i=(t,o="")=>{if(!(!t||typeof t!="object"||Array.isArray(t)))for(let[s,a]of Object.entries(t)){let c=o?`${o}.${s}`:s;if(r.services&&(c.startsWith("services.")||c==="services")){a&&typeof a=="object"&&!Array.isArray(a)&&i(a,c);continue}if(a&&typeof a=="object"&&!Array.isArray(a))i(a,c);else if(a!=null){let l=String(a);if(l==="[object Object]"||l.includes("[object Object]"))continue;let u="Env",d=/^[a-z0-9_-]+$/i.test(l),p=l.includes("://");s.toLowerCase().includes("service")&&(d||p)&&(u="Service"),s.toLowerCase().includes("image")&&(u="Image"),s.toLowerCase().includes("port")&&(u="Port"),(s.endsWith("_URI")||s.endsWith("_URL")||s.endsWith("_HOST"))&&p&&(u="Service"),e.push({key:c,value:l.length>200?l.substring(0,197)+"...":l,kind:u})}}};i(r)}catch{let i=n.match(/^\s{2}([a-z0-9_-]+):/gm);i&&i.forEach(t=>{let o=t.trim().replace(" : ","");o!=="services"&&o!=="version"&&o!=="volumes"&&o!=="networks"&&e.push({key:"service",value:o,kind:"Service"})})}}function Fx(n,e){let r=n.split(`
557
+ `);for(let i of r){let t=i.trim();if(t&&!t.startsWith("#")){let o=t.split("=");if(o[0]){let s=o[0].trim(),a=o.slice(1).join("=");a=a.trim().replace(/^['"](.*)['"]$/,"$1");let c="Env",l=a.includes("://");(s.endsWith("_URI")||s.endsWith("_URL")||s.endsWith("_HOST"))&&l&&(c="Service"),e.push({key:s,value:a,kind:c})}}}}function Zx(n,e){let r=[],i="Contract (Prisma) ",t=/^model\s+(\w+)/gm,o;for(;(o=t.exec(n))!==null;)r.push({key:"model",value:o[1],kind:"Database Model"});let s=/^enum\s+(\w+)/gm;for(;(o=s.exec(n))!==null;)r.push({key:"enum",value:o[1],kind:"Database Enum"});let a=/provider\s*=\s*"([^"]+)"/,c=n.match(a);return c&&r.push({key:"datasource_provider",value:c[1],kind:"Database Config"}),{classification:i,configs:r,content:n}}function Hx(n,e){let r=[],i="Contract (GraphQL) ",t=/^(?:type|input|interface|enum)\s+(\w+)/gm,o;for(;(o=t.exec(n))!==null;){let s=o[0],a="GraphQL Type";s.startsWith("input")&&(a="GraphQL Input"),s.startsWith("interface")&&(a="GraphQL Interface"),s.startsWith("enum")&&(a="GraphQL Enum"),r.push({key:"type_definition",value:o[1],kind:a})}return{classification:i,configs:r,content:n}}function Wx(n,e){try{let r=JSON.parse(n);if(r.name&&e.push({key:"name",value:r.name,kind:"Service"}),r.description&&e.push({key:"description",value:r.description,kind:"Env"}),r.workspaces){let o=Array.isArray(r.workspaces)?r.workspaces.join("",""):JSON.stringify(r.workspaces);e.push({key:"workspaces",value:o,kind:"Env"})}if(r.scripts){let o=["start","dev","build","test","docker"];for(let s of Object.keys(r.scripts))o.some(a=>s.includes(a))&&e.push({key:`script:${s}`,value:r.scripts[s],kind:"Env"})}let i={...r.dependencies,...r.devDependencies},t=["react","vue","svelte","angular","next","nuxt","express","fastify","nestjs","remix","vite","webpack","tailwindcss","database"];for(let o of Object.keys(i))if(t.some(s=>o.includes(s))){let s=i[o].replace(/[\^~]/,"");e.push({key:`dep:${o}`,value:s,kind:"Dependency"})}}catch{}}function Bx(n,e){let r=[],i="Monorepo (Lerna) ";try{let t=JSON.parse(n);r.push({key:"monorepo_type",value:"lerna",kind:"Monorepo"}),t.version&&r.push({key:"lerna_version",value:t.version,kind:"Monorepo"}),t.packages&&(Array.isArray(t.packages)?t.packages:[t.packages]).forEach(s=>{r.push({key:"package_glob",value:s,kind:"Monorepo"})}),t.npmClient&&r.push({key:"npm_client",value:t.npmClient,kind:"Monorepo"})}catch{}return{configs:r,classification:i,content:n}}function Gx(n,e){let r=[],i="Monorepo (Turborepo) ";try{let t=JSON.parse(n);if(r.push({key:"monorepo_type",value:"turborepo",kind:"Monorepo"}),t.pipeline)for(let o of Object.keys(t.pipeline)){r.push({key:`pipeline:${o}`,value:o,kind:"Monorepo"});let s=t.pipeline[o];s.dependsOn&&r.push({key:`pipeline:${o}:depends_on`,value:s.dependsOn.join("",""),kind:"Dependency"})}if(t.tasks)for(let o of Object.keys(t.tasks))r.push({key:`task:${o}`,value:o,kind:"Monorepo"})}catch{}return{configs:r,classification:i,content:n}}function Jx(n,e){let r=[],i="Monorepo (pnpm) ";try{let t=Hh.load(n);r.push({key:"monorepo_type",value:"pnpm",kind:"Monorepo"}),t&&t.packages&&(Array.isArray(t.packages)?t.packages:[t.packages]).forEach(s=>{r.push({key:"package_glob",value:s,kind:"Monorepo"})})}catch{}return{configs:r,classification:i,content:n}}X();Nt();import{execSync as kn}from"child_process";import ni from"path";import kc from"fs";function Ee(n){try{if(!kc.existsSync(ni.join(n,".git")))return null;let e=kn("git rev-parse --abbrev-ref HEAD",{cwd:n,stdio:["ignore","pipe","ignore"],encoding:"utf8"}).trim();return e==="HEAD"?kn("git rev-parse --short HEAD",{cwd:n,stdio:["ignore","pipe","ignore"],encoding:"utf8"}).trim():e.replace(/[\/\\:*"<>|?]/g,"-")}catch{return null}}function Qe(n){try{return kc.existsSync(ni.join(n,".git"))?kn("git rev-parse HEAD",{cwd:n,stdio:["ignore","pipe","ignore"],encoding:"utf8"}).trim():null}catch{return null}}function Ec(n,e=50){try{let r=kn(`git rev-list --max-count=${e} HEAD`,{cwd:n,stdio:["ignore","pipe","ignore"],encoding:"utf8"}).trim();return r?r.split(`
558
+ `):[]}catch{return[]}}function Ic(n,e,r){try{return kn(`git merge-tree --write-tree ${e} ${r}`,{cwd:n,stdio:["ignore","ignore","ignore"]}),!1}catch{return!0}}var Bh=new Set([".ts",".tsx",".yaml",".yml",".php",".py",".go",".prisma",".graphql",".gql"]),Gh=new Set(["package.json","lerna.json","turbo.json","pnpm-workspace.yaml"]),Jh=new Set(["node_modules",".git","dist","build","vendor",".next",".cache","coverage"]);function Wh(n){let e=n.split("/");for(let t of e)if(Jh.has(t))return!1;if(n.endsWith(".min.js"))return!1;let r=ni.basename(n);if(r.startsWith("Dockerfile")||r.startsWith(".env")||Gh.has(r))return!0;let i=ni.extname(r).toLowerCase();return Bh.has(i)}function qx(n){let e=n.trim(),r=e.indexOf(" -> ");if(r!==-1)return e.substring(r+4);let i=e.split(/\s+/);return i.length>=2?i[i.length-1]:e}function Tc(n,e){try{if(!kc.existsSync(ni.join(n,".git")))return!0;let r=Qe(n);if(!r)return!0;if(e&&e!==r){let t=kn(`git diff --name-only ${e} ${r}`,{cwd:n,stdio:["ignore","pipe","ignore"],encoding:"utf8"}).trim();if(t&&t.split(`
559
+ `).some(o=>o&&Wh(o)))return!0}let i=kn("git status --porcelain",{cwd:n,stdio:["ignore","pipe","ignore"],encoding:"utf8"}).trim();return i?i.split(`
560
+ `).some(t=>t?Wh(qx(t)):!1):!1}catch{return!0}}X();G();import{execSync as qh}from"child_process";var En=x.child({module:"nano-repair"}),Pe=class{intentLogs;exports;missions;repoPath;constructor(e){let{intentLogs:r,exports:i,missions:t}=z.getInstance(e);this.intentLogs=r,this.exports=i,this.missions=t,this.repoPath=e}detectAndRepairShifts(){let e=this.intentLogs.findRepairableOrphans();if(e.length===0)return{repaired:0,failed:0};En.info({count:e.length},"Detected orphaned intent logs. Attempting recovery...");let r=0,i=0;for(let t of e){let o=this.exports.findByNameAndFile(t.symbol_name,t.file_path);if(o.length>0){let a=o.find(c=>c.signature===t.signature)||o[0];this.intentLogs.update(t.id,{symbol_id:a.id}),En.info({logId:t.id,symbol:t.symbol_name},"Relinked symbol in same file"),r++;continue}let s=this.exports.findByNameGlobal(t.symbol_name);if(s.length>0){let a=s.filter(c=>c.file_path!==t.file_path);if(a.length>0){let c=a.find(l=>l.signature===t.signature)||a[0];this.intentLogs.update(t.id,{symbol_id:c.id,file_path:c.file_path}),En.info({logId:t.id,symbol:t.symbol_name,oldPath:t.file_path,newPath:c.file_path},"Detected Nano-Repair Shift (file move)"),r++;continue}}i++}return r>0&&En.info({repaired:r,failed:i},"Nano-Repair recovery complete"),{repaired:r,failed:i}}syncLifecycle(){let e="HEAD";try{e=qh("git rev-parse --abbrev-ref HEAD",{cwd:this.repoPath,encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).trim()}catch{return{suspended:0,resumed:0,completed:0}}if(!e)return{suspended:0,resumed:0,completed:0};let r=this.missions.findActive(),i=0;for(let s of r)s.git_branch&&s.git_branch!==e&&(this.missions.updateStatus(s.id,"suspended"),En.info({missionId:s.id,branch:s.git_branch,current:e},"Context Pivot: Suspended mission"),i++);this.missions.resumeByBranch(e);let t=[];try{t=qh(`git branch --merged "${e}"`,{cwd:this.repoPath,encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).split(`
561
+ `).map(a=>a.trim().replace(/^\* /,"")).filter(a=>a&&a!==e)}catch{}let o=0;if(t.length>0){let s=this.missions.findMergedMissions(e,t);for(let a of s)this.missions.updateStatus(a.id,"completed"),En.info({missionId:a.id,branch:a.git_branch},"Merge Sentinel: Auto-completed mission"),o++}return(i>0||o>0)&&En.info({suspended:i,completed:o},"Git-Native Lifecycle Sync complete"),{suspended:i,resumed:-1,completed:o}}};G();Qi();import{Worker as Vx}from"node:worker_threads";import{cpus as Kx}from"node:os";import{fileURLToPath as Yx}from"node:url";import{dirname as Xx,join as Qx}from"node:path";import{existsSync as eS}from"node:fs";var Vh=Yx(import.meta.url),tS=Xx(Vh),nS=Vh.endsWith(".ts");function rS(){if(nS)return null;let n=Qx(tS,"worker.js");return eS(n)?n:Hn("dist/logic/parser/worker.js")}var Pc=class{workers=[];taskQueue=[];pendingTasks=new Map;taskIdCounter=0;initialized=!1;initPromise;shutdownRequested=!1;numWorkers;initTimeout;constructor(e={}){this.numWorkers=e.numWorkers??Math.max(1,Math.min(4,Kx().length-1)),this.initTimeout=e.initTimeout??3e4}async initialize(){if(!this.initialized)return this.initPromise?this.initPromise:(this.initPromise=this._doInitialize(),this.initPromise)}async _doInitialize(){let e;try{x.info({numWorkers:this.numWorkers},"Initializing parser worker pool");let r=new Promise((i,t)=>{e=setTimeout(()=>t(new Error(`Parser pool initialization timed out after ${this.initTimeout}ms`)),this.initTimeout)});if(await Promise.race([this._initializeWorkers(),r]),e&&clearTimeout(e),this.shutdownRequested){this.initialized=!1,this.initPromise=void 0;return}this.initialized=!0,x.info({numWorkers:this.workers.length},"Parser worker pool ready")}catch(r){throw e&&clearTimeout(e),this.initPromise=void 0,this.initialized=!1,await this.shutdown(),r}}async _initializeWorkers(){let e=rS();if(!e)throw new Error("Parser worker pool not available in development mode (tsx). Use main-thread fallback.");x.debug({workerPath:e},"Resolved parser worker path");let r=[];for(let i=0;i<this.numWorkers;i++)r.push(this.createWorker(e,i));await Promise.all(r)}async createWorker(e,r){return new Promise((i,t)=>{let o=setTimeout(()=>{t(new Error(`Parser worker ${r} initialization timed out`))},this.initTimeout),s=new Vx(e,{execArgv:process.execArgv}),a={worker:s,busy:!1,currentTaskId:null};s.on("message",c=>{if(c.type==="ready"){if(clearTimeout(o),this.shutdownRequested){s.terminate().catch(()=>{}),i();return}this.workers.push(a),x.debug({workerIndex:r},"Parser worker ready"),i()}else c.type==="result"&&c.id?this.handleTaskComplete(a,c.id,c.result):c.type==="error"&&c.id&&this.handleTaskError(a,c.id,new Error(c.error||"Unknown error"))}),s.on("error",c=>{if(clearTimeout(o),x.error({err:c,workerIndex:r},"Parser worker error"),a.currentTaskId&&this.handleTaskError(a,a.currentTaskId,c),!this.initialized){t(c);return}let l=this.workers.indexOf(a);l!==-1&&this.workers.splice(l,1),!this.shutdownRequested&&this.initialized&&this.createWorker(e,r).catch(u=>{x.error({err:u},"Failed to replace crashed parser worker")})}),s.on("exit",c=>{c!==0&&!this.shutdownRequested&&x.warn({workerIndex:r,code:c},"Parser worker exited unexpectedly")})})}handleTaskComplete(e,r,i){let t=this.pendingTasks.get(r);t&&(this.pendingTasks.delete(r),t.resolve(i)),e.busy=!1,e.currentTaskId=null,this.processQueue()}handleTaskError(e,r,i){let t=this.pendingTasks.get(r);t&&(this.pendingTasks.delete(r),t.reject(i)),e.busy=!1,e.currentTaskId=null,this.processQueue()}processQueue(){if(this.taskQueue.length===0)return;let e=this.workers.find(i=>!i.busy);if(!e)return;let r=this.taskQueue.shift();r&&(e.busy=!0,e.currentTaskId=r.id,this.pendingTasks.set(r.id,r),e.worker.postMessage({type:"parse",id:r.id,filePath:r.filePath}))}async parseFile(e){return this.initialized||await this.initialize(),new Promise((r,i)=>{let o={id:`parse_${++this.taskIdCounter}`,filePath:e,resolve:r,reject:i};this.taskQueue.push(o),this.processQueue()})}get workerCount(){return this.workers.length}get busyWorkers(){return this.workers.filter(e=>e.busy).length}get queueSize(){return this.taskQueue.length}get isInitialized(){return this.initialized}async shutdown(){if(this.shutdownRequested=!0,this.initPromise)try{await this.initPromise}catch{}if(!this.initialized&&this.workers.length===0){this.shutdownRequested=!1,this.initPromise=void 0;return}x.info({numWorkers:this.workers.length},"Shutting down parser worker pool");let e=this.workers.map(r=>new Promise(i=>{r.worker.postMessage({type:"shutdown"}),r.worker.once("exit",()=>i()),setTimeout(()=>{r.worker.terminate().then(()=>i())},5e3)}));await Promise.all(e),this.workers=[],this.taskQueue=[],this.pendingTasks.clear(),this.initialized=!1,this.shutdownRequested=!1,this.initPromise=void 0,x.info("Parser worker pool shutdown complete")}},Yn=null;function Kh(n){return Yn||(Yn=new Pc(n)),Yn}async function Yh(){Yn&&(await Yn.shutdown(),Yn=null)}X();G();_t();Rc();Nc();zc();import{execSync as bg}from"child_process";var Ao=x.child({module:"heritage-analyzer"}),In=class{repos;repoPath;constructor(e){this.repos=z.getInstance(e),this.repoPath=e}analyzeHeritage(e=20){try{Ao.info({limit:e},"Analyzing repository heritage...");let r=bg(`git log -n ${e} --pretty=format:"%H|%at|%an|%s"`,{cwd:this.repoPath,encoding:"utf-8"});if(!r)return;let i=r.split(`
562
+ `).filter(Boolean);for(let t of i){let[o,s,a,c]=t.split("|"),l=this.analyzeCommitImpact(o);if(l.significant){let u=Array.from(l.layers).join(", "),d=`Heritage: ${c} (by ${a}). Touched ${l.fileCount} files across [${u}].`;this.repos.intentLogs.importHeritage(d,o,parseInt(s,10),.7),Ao.debug({sha:o,subject:c},"Logged heritage move")}}Ao.info("Heritage analysis complete.")}catch(r){Ao.warn({err:r.message},"Failed to run heritage analysis")}}analyzeCommitImpact(e){let r=new Set,i=0;try{let o=bg(`git diff-tree --no-commit-id --name-only -r ${e}`,{cwd:this.repoPath,encoding:"utf-8"}).split(`
563
+ `).filter(Boolean);i=o.length;for(let c of o){let l=this.classifyPathOnly(c);l!=="Unknown"&&r.add(l)}let s=r.has("Entry")||r.has("Data")||r.has("Infrastructure"),a=r.size>=2||i>5;return{significant:s||a,layers:r,fileCount:i}}catch{return{significant:!1,layers:r,fileCount:0}}}classifyPathOnly(e){let r=e.startsWith("/")?e:"/"+e;return Dc.some(i=>i.test(r))?"Test":Po.some(i=>i.test(r))||To.some(i=>i.test(r))?"Entry":ri.some(i=>i.test(r))?"Data":No.some(i=>i.test(r))?"Utility":zo.some(i=>i.test(r))?"Entry":Do.some(i=>i.test(r))?"Data":Co.some(i=>i.test(r))?"Entry":Lo.some(i=>i.test(r))?"Data":Cc.some(i=>i.test(r))?"Infrastructure":/\.(service|logic|usecase|interactor|manager)\.(ts|js|php|py)$/i.test(r)||Ro.some(i=>i.test(r))?"Logic":"Unknown"}};var lS=cS.cpus().length||4,uS=vo.DEFAULT_CONCURRENCY;async function Q(n,e=uS,r=!1,i=!0,t){let o=z.getInstance(n),s=o.files.database,a=Pt(n),c=a.concurrency??e;if(fh(),!r&&De(n)){let v=Zn(n),y=Qe(n);if(v&&!Tc(n,v))return ho(),x.debug({repoPath:n,commit:y},"Index is current, skipping re-index (fast-path)"),s}Vn(n);let l=o.files.findAll(),u=new Map(l.map(v=>[v.path,{mtime:v.mtime,hash:v.content_hash}])),d=Date.now();t?.({phase:"scan",current:0,total:0,message:"Scanning repository..."});let p=await _c(n,a.ignore),m=new Map(p.map(v=>[v.path,v.mtime])),f=l.filter(v=>!m.has(v.path)).map(v=>v.path),h=l.length===0,_=[];if(r||h)_.push(...p);else{let v=p.filter(w=>{let I=u.get(w.path);return!I||I.mtime!==w.mtime}),y=Lc(c*4),k=v.map(w=>y(async()=>{let I=u.get(w.path);if(!I||!I.hash)return w;try{let P=await aS.promises.readFile(w.path,"utf8");return cc(P,I.hash)?w:(o.files.updateMtime(w.path,w.mtime),null)}catch{return null}})),$=await Promise.all(k);_.push(...$.filter(w=>w!==null))}if(f.length===0&&_.length===0){ho();let v=Qe(n);return Vi(n,v||void 0),s}if(h?x.info({totalFiles:p.length},"Starting initial repository indexing..."):x.info({toDelete:f.length,toProcess:_.length},"Syncing repository updates..."),f.length>0&&o.files.deletePaths(f),_.length>0){gh(),i?(qr(!0),vn().initialize().catch(()=>{})):qr(!1);let v=/\.(ts|tsx|php|py|go|js|jsx|mjs|cjs)$/,y=[],k=[];for(let N of _)v.test(Ac.basename(N.path))?y.push(N):k.push(N);let $=0,w=_.length,I=!1,P=Kh();try{await P.initialize(),I=!0,x.info({workers:P.workerCount},"Parser worker pool active")}catch(N){x.warn({err:N},"Parser worker pool failed to initialize, falling back to main-thread parsing"),I=!1}let R=(N,W)=>{let q=W.imports?.map(U=>({...U,resolved_path:qt(U.module,N.path,n)})),Z=W.content?yn(W.content):null;return $++,($%50===0||$===w)&&x.info({completed:$,total:w},"Parsing files..."),t?.({phase:"parse",current:$,total:w,message:`Parsing ${Ac.basename(N.path)}`}),{meta:N,...W,imports:q,embedding:null,kind:"code",contentHash:Z}},F;if(I)F=y.map(N=>P.parseFile(N.path).then(W=>R(N,W),W=>($++,x.error({path:N.path,error:W},"Worker parse failed"),{meta:N,exports:[],imports:[],content:"",kind:"error"})));else{let N=h?Math.max(c,Math.min(lS-1,16)):c,W=Lc(N);F=y.map(q=>W(async()=>{try{let Z=await Qr(q.path);return R(q,Z)}catch(Z){return $++,x.error({path:q.path,error:Z},"Failed to parse file"),{meta:q,exports:[],imports:[],content:"",kind:"error"}}}))}let T=Lc(c),A=k.map(N=>T(async()=>{try{let W=Zh(N.path),q=W.content?yn(W.content):null;return $++,($%50===0||$===w)&&x.info({completed:$,total:w},"Parsing configs..."),t?.({phase:"parse",current:$,total:w,message:`Parsing config ${Ac.basename(N.path)}`}),{meta:N,...W,embedding:null,kind:"config",contentHash:q}}catch(W){return $++,x.error({path:N.path,error:W},"Failed to parse config"),{meta:N,exports:[],imports:[],content:"",kind:"error"}}}));x.info({total:w,codeFiles:y.length,configFiles:k.length,useParserPool:I},"Phase 1: Parsing all files...");let H=Date.now(),J=(await Promise.all([...F,...A])).filter(Boolean),M=Date.now()-H;if(Kr("parse",M),x.info({count:J.length,time:`${(M/1e3).toFixed(1)}s`},"Phase 1 complete"),I&&Yh().catch(()=>{}),s.pragma("synchronous = NORMAL"),s.pragma("cache_size = -64000"),i){let N=[];J.forEach((pe,ye)=>{"summary"in pe&&pe.summary&&N.push({fileIdx:ye,text:pe.summary})}),x.info("Phase 2+3: Generating embeddings + persisting in parallel..."),t?.({phase:"embed",current:0,total:J.length,message:"Generating embeddings..."});let W=Date.now(),q=(async()=>{if(N.length>0){x.info({count:N.length}," \u2192 Generating file summary embeddings...");let pe=N.map(de=>de.text),ye=await no(pe,256);return x.info({count:N.length}," \u2713 File summaries complete"),ye}return[]})();t?.({phase:"persist",current:0,total:J.length,message:"Saving to database..."});let Z=Date.now();o.files.batchSaveIndexResults(J,n,yn,qt);let U=Date.now()-Z;Kr("persist",U),x.info({time:`${(U/1e3).toFixed(1)}s`},"Structural persist complete");let he=await q,V=Date.now()-W;if(Kr("embed",V),x.info({time:`${(V/1e3).toFixed(1)}s`},"Embeddings complete"),he.length>0){let pe=s.prepare("UPDATE files SET embedding = ? WHERE path = ?"),ye=s.transaction(K=>{for(let B of K)pe.run(B.embedding?JSON.stringify(B.embedding):null,B.path)}),de=N.map((K,B)=>({path:J[K.fileIdx].meta.path,embedding:he[B]}));ye(de),x.info({count:de.length},"Embedding column updated")}let ne=await o.intentLogs.backfillEmbeddings(64);ne>0&&x.info({count:ne}," \u2713 Intent log embeddings backfilled")}else{t?.({phase:"persist",current:0,total:J.length,message:"Saving to database..."});let N=Date.now();o.files.batchSaveIndexResults(J,n,yn,qt),Kr("persist",Date.now()-N)}s.pragma("synchronous = FULL"),s.pragma("cache_size = -2000")}if(h||_.length>0){let v=Qe(n);Vi(n,v||void 0)}if((_.length>0||f.length>0)&&new Pe(n).detectAndRepairShifts(),h||i)try{new In(n).analyzeHeritage(50)}catch(v){x.warn({err:v.message},"Heritage sync deferred")}return hh(Date.now()-d),t?.({phase:"complete",current:_.length,total:_.length,message:"Indexing complete"}),s}G();import _g from"path";import dS from"ignore";import xg from"fs";X();async function Tn(n,e=vo.DEFAULT_CONCURRENCY,r="detailed",i,t){x.info({repo:n,level:r,subPath:i},"Ensuring cache is up-to-date..."),await Q(n,e);let{files:o,exports:s,imports:a}=z.getInstance(n),c=i?o.findInSubPath(n,i):o.findAll(),l=Pt(n),u=dS(),d=_g.join(n,".gitignore");if(xg.existsSync(d)&&u.add(xg.readFileSync(d,"utf8")),l.ignore&&l.ignore.length>0&&u.add(l.ignore),u.add(yo),c=c.filter(y=>{let k=_g.relative(n,y.path);return!u.ignores(k)}),x.info({count:c.length},"Fetching data from DB..."),r==="lite"){let y=c.map(k=>({path:k.path,mtime:k.mtime}));return ei(y,n,r,t)}if(r==="summaries"){let y=c.map(k=>({path:k.path,mtime:k.mtime,classification:k.classification||void 0,summary:k.summary||void 0}));return ei(y,n,r,t)}let p=c.map(y=>y.path),m=s.findByFiles(p),f=r==="detailed"?a.findByFiles(p):[],h=new Map;for(let y of m){let k=h.get(y.file_path)||[];k.push(y),h.set(y.file_path,k)}let _=new Map;for(let y of f){let k=_.get(y.file_path)||[];k.push(y),_.set(y.file_path,k)}let v=c.map(y=>{let $=(h.get(y.path)||[]).map(I=>({name:I.name,kind:I.kind,signature:I.signature,line:I.start_line}));r==="structure"?$=$.map(I=>({name:I.name,kind:I.kind,line:I.line})):r==="signatures"&&($=$.map(I=>({name:I.name,kind:I.kind,signature:I.signature,line:I.line})));let w=[];return r==="detailed"&&(w=(_.get(y.path)||[]).map(P=>({module:P.module_specifier,resolved_path:P.resolved_path}))),{path:y.path,mtime:y.mtime,classification:y.classification||void 0,summary:y.summary||void 0,exports:$,imports:w.length>0?w:void 0,chunks:[]}});return x.info({count:v.length},"Building hierarchical project tree..."),ei(v,n,r,t)}Nt();X();X();var ii=class{static extractSnippet(e,r,i=300){if(!e||!r)return"";let t=r.toLowerCase().split(/\s+/).filter(p=>p.length>2&&!["the","and","for","with","from"].includes(p));if(t.length===0)return e.slice(0,i)+"...";let o=e.split(`
564
+ `),s=new Array(o.length).fill(0);for(let p=0;p<o.length;p++){let m=o[p].toLowerCase(),f=0,h=0;for(let _ of t)m.includes(_)&&(f++,h++);(m.includes("export ")||m.includes("class ")||m.includes("function ")||m.includes("interface "))&&(f+=1),s[p]=h*10+f}let a=0,c=-1,l=5;for(let p=0;p<=o.length-l;p++){let m=0;for(let f=0;f<l;f++)m+=s[p+f];m>c&&(c=m,a=p)}if(c<=0)return e.slice(0,i).trim()+"...";let d=o.slice(a,a+l).join(`
565
+ `).trim();return a>0&&(d=`...
566
+ `+d),a+l<o.length&&(d=d+`
567
+ ...`),d.length>i?d.slice(0,i)+"...":d}static calculateLexicalScore(e,r){if(!e||!r)return 0;let i=r.toLowerCase().split(/\s+/).filter(s=>s.length>2&&!["the","and","for","with","from"].includes(s));if(i.length===0)return 0;let t=0,o=e.toLowerCase();for(let s of i)if(o.includes(s)){t+=1;let a=new RegExp(`\\b${s}`,"gi"),c=o.match(a);c&&(t+=Math.min(c.length*.2,2)),new RegExp(`(class|function|export|interface|enum|type)\\s+${s}`,"i").test(e)&&(t+=1.5)}return t/i.length}};Nt();X();G();var Kt=x.child({module:"clean-sweep"}),Oc=class{files;intentLogs;constructor(e){let{files:r,intentLogs:i}=z.getInstance(e);this.files=r,this.intentLogs=i}pruneOrphans(){Kt.info("Starting orphan pruning...");let e=0,r=0,i=this.intentLogs.findOrphans();Kt.info({orphanCount:i.length},"Found orphaned logs");for(let s of i)s.file_path&&this.files.exists(s.file_path)?(this.intentLogs.markAsLapsed(s.id),r++,Kt.debug({logId:s.id,symbolName:s.symbol_name},"Converted to lapsed intent")):(this.intentLogs.delete(s.id),e++,Kt.debug({logId:s.id},"Deleted orphaned log"));let t=this.intentLogs.findLogsForMissingFiles();for(let s of t)this.intentLogs.delete(s.id),e++;let o=this.intentLogs.findRecentDecisionActivity(1e3).length;return Kt.info({deleted:e,converted:r},"Orphan pruning complete"),{deleted:e,converted:r,retained:o}}},Oo=class{lambda;constructor(e=.01){this.lambda=e}calculateScore(e,r){let t=(Math.floor(Date.now()/1e3)-r)/(3600*24),o=Math.exp(-this.lambda*t);return e*o}scoreResults(e){return e.map(r=>({...r,decayed_score:this.calculateScore(r.score,r.created_at)}))}},Mc=class{missions;constructor(e){let{missions:r}=z.getInstance(e);this.missions=r}findColdMissions(){let e=Math.floor(Date.now()/1e3)-604800,r=this.missions.findColdMissions(e,10);return Kt.info({count:r.length},"Found cold missions for compaction"),r}markDistilled(e){this.missions.update(e,{status:"distilled"})}},Pn=class{pruner;scorer;compactor;constructor(e){this.pruner=new Oc(e),this.scorer=new Oo,this.compactor=new Mc(e)}runMaintenance(){Kt.info("Initiating Clean Sweep maintenance protocol...");let e=this.pruner.pruneOrphans(),r=this.compactor.findColdMissions();return Kt.info("Clean Sweep maintenance complete"),{pruning:e,compaction:{eligible:r.length}}}getScorer(){return this.scorer}getCompactor(){return this.compactor}};X();G();var Sg=x.child({module:"lineage-service"}),oi=class{repoPath;constructor(e){this.repoPath=e}getAncestorMissionIds(e=50){try{let r=Ec(this.repoPath,e);if(r.length===0)return[];let{missions:i}=z.getInstance(this.repoPath),o=i.findByCommitShas(r).map(s=>s.id);return o.length>0&&Sg.debug({count:o.length},"Identified ancestor missions for gravity bleed"),o}catch(r){return Sg.warn({err:r.message},"Failed to identify ancestor missions"),[]}}};var pS={Solid:1,Liquid:.8,Virtual:.4,Intel:.2,Phantom:.05},ut=class{static classify(e,r){let i=e.toLowerCase();if(r?.content){let t=r.content;if(t.includes("describe(")||t.includes("test(")||t.includes("it(")||t.includes("expect(")||t.includes('from "@jest/globals"')||t.includes('from "vitest"'))return"Virtual"}return r?.exports&&(r.exports.some(o=>o.kind==="ClassDeclaration"||o.kind==="Class")||r.exports.length>5),i.includes("/dist/")||i.includes("/build/")||i.includes("/.generated/")||i.includes("/node_modules/")||i.endsWith(".map")||i.endsWith(".log")?"Phantom":i.includes("/test/")||i.includes("/tests/")||i.includes("/__tests__/")||i.includes("/__mocks__/")||i.includes(".spec.")||i.includes(".test.")||i.includes("/e2e/")||i.includes("/test-utils/")?"Virtual":i.includes("/examples/")||i.includes("/fixtures/")||i.includes("/mocks/")||i.includes("/stories/")||i.includes("/samples/")||i.includes("/docs/")?"Intel":i.includes("/src/")||i.includes("/lib/")||i.includes("/app/")||i.includes("/core/")||i.includes("/logic/")||i.includes("/domain/")||i.includes("/services/")||i.includes("/controllers/")||i.includes("/handlers/")||i.includes("/repositories/")||i.includes("/models/")||i.includes("/packages/")&&!i.includes("/packages/config/")||i.includes("/backends/")||r?.exports&&(r.exports.some(t=>t.kind==="ClassDeclaration"||t.kind==="Class")||r.exports.length>5)?"Solid":"Liquid"}static mapClassificationToTier(e){let r=e.toLowerCase();return r==="service"||r==="repository"||r==="model"||r==="controller"||r==="handler"||r==="component"||r==="hook"||r==="titanium"||r==="solid"?"Solid":r==="test"||r==="iron"||r==="virtual"?"Virtual":r==="lead"||r==="intel"?"Intel":r==="ghost"||r==="error"||r==="phantom"?"Phantom":"Liquid"}static getMultiplier(e,r){let i=r?this.mapClassificationToTier(r):this.classify(e);return pS[i]}};G();function mS(n,e){let r=[];for(let i=0;i<=e.length;i++)r[i]=[i];for(let i=0;i<=n.length;i++)r[0][i]=i;for(let i=1;i<=e.length;i++)for(let t=1;t<=n.length;t++)e.charAt(i-1)===n.charAt(t-1)?r[i][t]=r[i-1][t-1]:r[i][t]=Math.min(r[i-1][t-1]+1,r[i][t-1]+1,r[i-1][t]+1);return r[e.length][n.length]}function fS(n,e){let r=mS(n.toLowerCase(),e.toLowerCase()),i=Math.max(n.length,e.length);return Math.round((i-r)/i*100)}function $g(n){let e=[],r="";for(let i=0;i<n.length;i++){let t=n[i],o=t>="A"&&t<="Z",s=t>="a"&&t<="z";o&&r.length>0?(e.push(r),r=t):s||o?r+=t:r.length>0&&(e.push(r),r="")}return r.length>0&&e.push(r),e}function hS(n,e){let r=$g(e),i=n.toLowerCase();if(r.map(s=>s[0].toLowerCase()).join("")===i)return!0;let o=0;for(let s of r){if(o>=n.length)break;let a=s.toLowerCase();if(a.startsWith(i.slice(o))){o=n.length;break}a[0]===i[o]&&o++}return o===n.length}function gS(n,e){return $g(e).map(t=>t[0].toLowerCase()).join("")===n.toLowerCase()}function yS(n,e){let r=n.toLowerCase(),i=e.toLowerCase();if(n===e)return{matchType:"exact",score:100};if(r===i)return{matchType:"exact-case-insensitive",score:98};if(i.startsWith(r))return{matchType:"prefix",score:90+n.length/e.length*8};if(i.endsWith(r))return{matchType:"suffix",score:80+n.length/e.length*8};if(i.includes(r)){let o=n.length/e.length,s=i.indexOf(r)/e.length;return{matchType:"substring",score:70+o*10-s*5}}return gS(n,e)?{matchType:"acronym",score:75}:hS(n,e)?{matchType:"camel-case",score:65}:{matchType:"levenshtein",score:fS(n,e)*.6}}function Qn(n,e,r=50,i=5){let t=[];for(let o of e){let{matchType:s,score:a}=yS(n,o);if(a>=r){let l={exact:1e3,"exact-case-insensitive":900,prefix:800,suffix:700,substring:600,acronym:550,"camel-case":500,levenshtein:100}[s]+a;t.push({match:o,score:a,matchType:s,rank:l})}}return t.sort((o,s)=>s.rank!==o.rank?s.rank-o.rank:s.score!==o.score?s.score-o.score:o.match.length-s.match.length),t.slice(0,i)}He();var et=class n{constructor(e){this.repoPath=e}get filesRepo(){return z.getInstance(this.repoPath).files}get exportsRepo(){return z.getInstance(this.repoPath).exports}get intentLogsRepo(){return z.getInstance(this.repoPath).intentLogs}static normalizeFileType(e){if(e==null)return;let r=Array.isArray(e)?e:e.split(",").map(i=>i.trim().replace(/^\./,""));return r.filter(Boolean).length?r:void 0}static matchesFilters(e,r,i,t){if(r.fileType?.length){let o=e.replace(/^.*\./,"").toLowerCase();if(!r.fileType.some(s=>s.toLowerCase()===o))return!1}if(r.layer!=null||r.excludeLayers&&r.excludeLayers.length>0){let o=t!=null?ut.mapClassificationToTier(t):ut.classify(e);if(r.layer!=null&&o!==r.layer||r.excludeLayers?.includes(o))return!1}return!0}async searchByPath(e,r,i,t,o,s=!1){let a=e.toLowerCase().split(/\s+/).filter(Boolean),c=this.filesRepo.findByPathKeywords(a,Math.min((r??50)*(o?Fe.FILTERED_QUERY_LIMIT_MULTIPLIER:1),ke.MAX_LIMIT));o&&(c=c.filter(d=>n.matchesFilters(d.path,t,d.mtime,d.classification)),c=c.slice(0,r??50));let l=d=>d.replace(this.repoPath,"").replace(/^\//,"");if(c.length===0)return{content:[{type:"text",text:`No indexed files match path/filename: "${e}".
568
+
569
+ If the repo is not indexed, run shadow_recon_onboard then shadow_sync_trace. Otherwise try broader keywords.`}]};if(s){let p=new le(this.repoPath).getSection("gravity"),m=new Map;if(p?.hotspots)for(let _ of p.hotspots){let v=m.get(_.filePath)||0;m.set(_.filePath,v+_.gravity)}let f=c.map(_=>{let v=m.get(_.path)||0,y=_.classification?ut.mapClassificationToTier(_.classification):ut.classify(_.path);return{..._,gravity:v,layer:y}});return f.sort((_,v)=>v.gravity-_.gravity),{content:[{type:"text",text:`# Resolved paths: "${e}" (Ranked by Gravity)
558
570
 
559
571
  ${f.length} file(s):
560
572
 
561
- `+f.map((b,y)=>{let g=b.gravity>50?" \u269B\uFE0F":b.gravity>0?" \u2022":"",S=b.gravity>0?` [G:${Math.round(b.gravity)}]`:"";return`${y+1}. \`${l(b.path)}\` (${b.layer})${g}${S}`}).join(`
573
+ `+f.map((_,v)=>{let y=_.gravity>50?" \u269B\uFE0F":_.gravity>0?" \u2022":"",k=_.gravity>0?` [G:${Math.round(_.gravity)}]`:"";return`${v+1}. \`${l(_.path)}\` (${_.layer})${y}${k}`}).join(`
562
574
  `)+`
563
575
 
564
576
  > **Legend**: \u269B\uFE0F = High-gravity hotspot (>50), \u2022 = Has gravity, G = Gravity score`}]}}return{content:[{type:"text",text:`# Resolved paths: "${e}"
565
577
 
566
- ${a.length} file(s):
578
+ ${c.length} file(s):
567
579
 
568
- `+a.map((d,u)=>`${u+1}. \`${l(d.path)}\`${d.classification?` (${d.classification})`:""}`).join(`
569
- `)}]}}async searchByConcept(e,t,n,s,r,o=!1){_.info({repoPath:this.repoPath,query:e},"Searching by concept (Semantic Analysis)...");let c=await rs(e),a=g=>g.replace(this.repoPath,"").replace(/^\//,"");if(c){let g=await this.findConceptMatches(e,c,s,r,t*2,0);if(g.length>0){let S=g.length,R=g.slice(n,n+t),T=n+t<S?`
570
- > **Note**: More results available. Use \`offset: ${n+t}\` to see the next page.`:"",v=o?`
571
- > _Compact mode: snippets omitted_`:S>20&&!o?"\n> \u{1F4A1} **Tip**: Use `compact: true` to reduce output size (omits snippets).":"",k=`# Semantic Concept Search: "${e}"
580
+ `+c.map((d,p)=>`${p+1}. \`${l(d.path)}\`${d.classification?` (${d.classification})`:""}`).join(`
581
+ `)}]}}async searchByConcept(e,r,i,t,o,s=!1){x.info({repoPath:this.repoPath,query:e},"Searching by concept (Semantic Analysis)...");let a=await to(e),c=y=>y.replace(this.repoPath,"").replace(/^\//,"");if(a){let y=await this.findConceptMatches(e,a,t,o,r*2,0),k=await this.findIntentLogMatches(a,5);if(y.length>0||k.length>0){let $=y.length,w=y.slice(i,i+r),P=i+r<$?`
582
+ > **Note**: More results available. Use \`offset: ${i+r}\` to see the next page.`:"",R=s?`
583
+ > _Compact mode: snippets omitted_`:$>20&&!s?"\n> \u{1F4A1} **Tip**: Use `compact: true` to reduce output size (omits snippets).":"",F=`# Semantic Concept Search: "${e}"
572
584
 
573
- Showing ${R.length} of ${S} relevant file(s) (offset: ${n}, limit: ${t})${T}${v}
585
+ Showing ${w.length} of ${$} relevant file(s) (offset: ${i}, limit: ${r})${P}${R}
574
586
 
575
- `,x=new ue(this.repoPath).getSection("gravity"),I=new Map;if(x?.hotspots)for(let $ of x.hotspots)I.set($.filePath,$.gravity);return{content:[{type:"text",text:o?k+R.map(($,j)=>{let H=a($.path),N=Math.round(($.decayedScore||0)*100),A=I.get($.path)?" \u269B\uFE0F":"";return`${n+j+1}. \`${H}\`${A} (${N}%) - ${$.summary||"No summary"}`}).join(`
576
- `):k+R.map(($,j)=>{let H=a($.path),N=Math.round(($.decayedScore||0)*100),L=I.get($.path),A=L?" \u269B\uFE0F **CORE**":"",D=L&&L>50?`
577
- > \u26A0\uFE0F **STRATEGIC RISK**: High-gravity hotspot (${L.toFixed(0)}). Modifications may have significant architectural impact.`:"";return`## ${n+j+1}. ${H}${A} (${N}% Match)
578
- > **Rationale**: ${$.rationale}${D}
587
+ `,A=new le(this.repoPath).getSection("gravity"),H=new Map;if(A?.hotspots)for(let M of A.hotspots)H.set(M.filePath,M.gravity);let J=s?F+w.map((M,N)=>{let W=c(M.path),q=Math.round((M.decayedScore||0)*100),U=H.get(M.path)?" \u269B\uFE0F":"";return`${i+N+1}. \`${W}\`${U} (${q}%) - ${M.summary||"No summary"}`}).join(`
588
+ `):F+w.map((M,N)=>{let W=c(M.path),q=Math.round((M.decayedScore||0)*100),Z=H.get(M.path),U=Z?" \u269B\uFE0F **CORE**":"",he=Z&&Z>50?`
589
+ > \u26A0\uFE0F **STRATEGIC RISK**: High-gravity hotspot (${Z.toFixed(0)}). Modifications may have significant architectural impact.`:"";return`## ${i+N+1}. ${W}${U} (${q}% Match)
590
+ > **Rationale**: ${M.rationale}${he}
579
591
 
580
- `+($.snippet?`**Matched Snippet**:
592
+ `+(M.snippet?`**Matched Snippet**:
581
593
  \`\`\`typescript
582
- ${$.snippet}
594
+ ${M.snippet}
583
595
  \`\`\`
584
596
 
585
- `:"")+`**Summary**: ${$.summary||"No summary available"}
597
+ `:"")+`**Summary**: ${M.summary||"No summary available"}
598
+ `}).join(`
599
+ `);return k.length>0&&(J+=`
600
+
601
+ ---
602
+ ## Intent Vectors (${k.length} matching decision(s))
603
+
604
+ `,J+=k.map((M,N)=>{let W=Math.round((M.score||0)*100),q=M.symbolName?` \`${M.symbolName}\``:"",Z=M.missionId?` [Mission #${M.missionId}]`:"",U=M.content.length>200?M.content.slice(0,200)+"...":M.content;return s?`${N+1}. **[${M.type}]**${q}${Z} (${W}%) - ${U}`:`### ${N+1}. [${M.type}]${q}${Z} (${W}% Match)
605
+ > ${U}
586
606
  `}).join(`
587
- `)}]}}}let l=e.replace(/[^\w\s]/g," ").trim(),p=this.filesRepo.findFts(l,(t+n)*(r?ae.FILTERED_QUERY_LIMIT_MULTIPLIER:1));r&&(p=p.filter(g=>i.matchesFilters(g.path,s,g.mtime,g.classification)));let d=p.slice(n,n+t);if(d.length===0&&n===0){let g=this.filesRepo.getStats(),S=e.toLowerCase().split(/\s+/),R=this.filesRepo.findByPathKeywords(S,t);return r&&(R=R.filter(w=>i.matchesFilters(w.path,s,w.mtime,w.classification))),R.length>0?{content:[{type:"text",text:`# Concept Search: "${e}"
607
+ `)),{content:[{type:"text",text:J}]}}}let l=e.replace(/[^\w\s]/g," ").trim(),u=this.filesRepo.findFts(l,(r+i)*(o?Fe.FILTERED_QUERY_LIMIT_MULTIPLIER:1));o&&(u=u.filter(y=>n.matchesFilters(y.path,t,y.mtime,y.classification)));let d=u.slice(i,i+r);if(d.length===0&&i===0){let y=this.filesRepo.getStats(),k=e.toLowerCase().split(/\s+/),$=this.filesRepo.findByPathKeywords(k,r);return o&&($=$.filter(w=>n.matchesFilters(w.path,t,w.mtime,w.classification))),$.length>0?{content:[{type:"text",text:`# Concept Search: "${e}"
588
608
 
589
- \u26A0\uFE0F No semantic matches in file summaries (${g.withSummary}/${g.total} indexed).
609
+ \u26A0\uFE0F No semantic matches in file summaries (${y.withSummary}/${y.total} indexed).
590
610
 
591
- Found ${R.length} file(s) with matching paths:
611
+ Found ${$.length} file(s) with matching paths:
592
612
 
593
- `+R.map((T,v)=>`${v+1}. \`${a(T.path)}\` (${T.classification||"Unknown"})`).join(`
613
+ `+$.map((I,P)=>`${P+1}. \`${c(I.path)}\` (${I.classification||"Unknown"})`).join(`
594
614
  `)}]}:{content:[{type:"text",text:`No files found matching concept: "${e}"
595
615
 
596
- Summary Stats: ${g.withSummary}/${g.total} summaries.
616
+ Summary Stats: ${y.withSummary}/${y.total} summaries.
597
617
 
598
- Try a symbol search: shadow_search_symbol({ query: "${e}", repoPath })`}]}}let u=p.length,f=n+t<u?`
599
- > Use \`offset: ${n+t}\` for more results.`:"",h=o?`
600
- > _Compact mode_`:u>20&&!o?"\n> \u{1F4A1} Use `compact: true` to reduce output size.":"",b=`# Concept Search (FTS Fallback): "${e}"
618
+ Try a symbol search: shadow_search_symbol({ query: "${e}", repoPath })`}]}}let p=u.length,f=i+r<p?`
619
+ > Use \`offset: ${i+r}\` for more results.`:"",h=s?`
620
+ > _Compact mode_`:p>20&&!s?"\n> \u{1F4A1} Use `compact: true` to reduce output size.":"",_=`# Concept Search (FTS Fallback): "${e}"
601
621
 
602
- Showing ${d.length} of ${u} relevant file(s)${f}${h}
622
+ Showing ${d.length} of ${p} relevant file(s)${f}${h}
603
623
 
604
- `;return{content:[{type:"text",text:o?b+d.map((g,S)=>`${n+S+1}. \`${a(g.path)}\``).join(`
605
- `):b+d.map((g,S)=>`## ${n+S+1}. ${a(g.path)}
624
+ `;return{content:[{type:"text",text:s?_+d.map((y,k)=>`${i+k+1}. \`${c(y.path)}\``).join(`
625
+ `):_+d.map((y,k)=>`## ${i+k+1}. ${c(y.path)}
606
626
 
607
- **Summary**: ${g.summary||"No summary available"}
627
+ **Summary**: ${y.summary||"No summary available"}
608
628
  `).join(`
609
- `)}]}}async searchBySymbol(e,t,n,s,r,o="any"){let c=e.toLowerCase(),a=x=>x.replace(this.repoPath,"").replace(/^\//,""),l=this.buildFtsQuery(e,o),p;try{p=this.exportsRepo.findFts(l,t+50)}catch{p=this.exportsRepo.findByPartialName(e,t+50)}if(p.length===0){let x=this.exportsRepo.getAllNames(5e3),I=e.trim().split(/\s+/).filter($=>$.length>0);if(I.length>1){let $=new Map;for(let H of I){let N=Ht(H,x,40,20);for(let L of N){let A=$.get(L.match);A?(A.terms.push(H),A.bestScore=Math.max(A.bestScore,L.score)):$.set(L.match,{terms:[H],bestScore:L.score})}}let j=Array.from($.entries()).sort((H,N)=>N[1].terms.length!==H[1].terms.length?N[1].terms.length-H[1].terms.length:N[1].bestScore-H[1].bestScore).slice(0,10);if(j.length>0){let H=j.map(([N,L])=>{let A=L.terms.join(", ");return` \u2022 \`${N}\` (matches: ${A}, ${Math.round(L.bestScore)}%)`}).join(`
629
+ `)}]}}async searchBySymbol(e,r,i,t,o,s="any"){let a=e.toLowerCase(),c=T=>T.replace(this.repoPath,"").replace(/^\//,""),l=this.buildFtsQuery(e,s),u;try{u=this.exportsRepo.findFts(l,r+50)}catch{u=this.exportsRepo.findByPartialName(e,r+50)}if(u.length===0){let T=this.exportsRepo.getAllNames(5e3),A=e.trim().split(/\s+/).filter(J=>J.length>0);if(A.length>1){let J=new Map;for(let N of A){let W=Qn(N,T,40,20);for(let q of W){let Z=J.get(q.match);Z?(Z.terms.push(N),Z.bestScore=Math.max(Z.bestScore,q.score)):J.set(q.match,{terms:[N],bestScore:q.score})}}let M=Array.from(J.entries()).sort((N,W)=>W[1].terms.length!==N[1].terms.length?W[1].terms.length-N[1].terms.length:W[1].bestScore-N[1].bestScore).slice(0,10);if(M.length>0){let N=M.map(([W,q])=>{let Z=q.terms.join(", ");return` \u2022 \`${W}\` (matches: ${Z}, ${Math.round(q.bestScore)}%)`}).join(`
610
630
  `);return{content:[{type:"text",text:`No symbols found matching all terms: "${e}"
611
631
 
612
632
  **Partial matches:**
613
- ${H}
633
+ ${N}
614
634
 
615
- \u{1F4A1} Try searching for individual terms, or use shadow_search_concept for semantic search.`}]}}}else{let $=Ht(e,x,50,5);if($.length>0){let j=$.map(H=>` \u2022 \`${H.match}\` (${Math.round(H.score)}% ${H.matchType} match)`).join(`
635
+ \u{1F4A1} Try searching for individual terms, or use shadow_search_concept for semantic search.`}]}}}else{let J=Qn(e,T,50,5);if(J.length>0){let M=J.map(N=>` \u2022 \`${N.match}\` (${Math.round(N.score)}% ${N.matchType} match)`).join(`
616
636
  `);return{content:[{type:"text",text:`No symbols found matching: "${e}"
617
637
 
618
638
  **Did you mean?**
619
- ${j}
639
+ ${M}
620
640
 
621
641
  \u{1F4A1} Try shadow_search_symbol with fuzzy, or shadow_search_concept for semantic search.`}]}}}return{content:[{type:"text",text:`No symbols found matching: "${e}"
622
642
 
623
- \u{1F4A1} Try shadow_search_symbol (fuzzy) or shadow_search_concept for semantic search.`}]}}r&&(p=p.filter(x=>{let I=this.filesRepo.findByPath(x.file_path);return i.matchesFilters(x.file_path,s,I?.mtime,I?.classification)}));let d=new nt(this.repoPath),u=new ue(this.repoPath),m=d.getAncestorMissionIds(),f=re(this.repoPath)||void 0,h=this.exportsRepo.getGravityMap(m,f),b=u.getSection("gravity"),y=new Map;if(b?.hotspots)for(let x of b.hotspots)y.set(`${x.filePath}::${x.symbol}`,x.gravity);let g="\u{1F525}",S="\u26A1",R="\u269B\uFE0F",w=p.map((x,I)=>{let M=h[x.id],$=y.get(`${x.file_path}::${x.name}`),j=this.filesRepo.findByPath(x.file_path),H=be.getMultiplier(x.file_path,j?.classification),N=(ae.SCORE_BASE-I)*H;M&&(N+=M.score*ae.SCORE_BASE),$&&(N+=$*ae.SCORE_BASE*ae.GRAVITY_STRUCTURAL_WEIGHT),x.name.toLowerCase()===c&&(N+=ae.EXACT_MATCH_BONUS*H);let L=j?.mtime;if(L!=null){let D=L>1e10?L/1e3:L,te=(Date.now()/1e3-D)/ps.SECONDS_PER_DAY;te<ae.RECENT_FILE_THRESHOLD_DAYS?N+=ae.RECENT_FILE_BOOST:te<ae.OLDER_FILE_THRESHOLD_DAYS&&(N+=ae.OLDER_FILE_BOOST)}let A=[];return M&&A.push(...M.reasons),$&&A.push(`Structural Hotspot (Gravity: ${$.toFixed(1)})`),{...x,activeGravity:M,structuralGravity:$,sortScore:N,reasons:A}}).sort((x,I)=>I.sortScore-x.sortScore).slice(n,n+t),T=p.length,v=n+t<T,k=w.map((x,I)=>{let M=a(x.file_path),$=this.filesRepo.getContent(x.file_path),j="";if($){let L=$.split(`
624
- `);j=L.slice(Math.max(0,x.start_line-2),Math.min(L.length,x.start_line+3)).join(`
625
- `).trim()}let H=[];x.activeGravity&&(x.activeGravity.reasons.some(L=>L.includes("Working Set"))?H.push(g):x.activeGravity.reasons.some(L=>L.includes("Recent Intent"))&&H.push(S)),x.structuralGravity&&H.push(R);let N=H.length>0?` ${H.join("")}`:"";return{relPath:M,name:x.name,kind:x.kind,signature:x.signature,line:x.start_line,snippet:j,badgeStr:N,gravityReasons:x.reasons}});return{content:[{type:"text",text:`# Symbol Search Results: "${e}"
643
+ \u{1F4A1} Try shadow_search_symbol (fuzzy) or shadow_search_concept for semantic search.`}]}}o&&(u=u.filter(T=>{let A=this.filesRepo.findByPath(T.file_path);return n.matchesFilters(T.file_path,t,A?.mtime,A?.classification)}));let d=new oi(this.repoPath),p=new le(this.repoPath),m=d.getAncestorMissionIds(),f=Ee(this.repoPath)||void 0,h=this.exportsRepo.getGravityMap(m,f),_=p.getSection("gravity"),v=new Map;if(_?.hotspots)for(let T of _.hotspots)v.set(`${T.filePath}::${T.symbol}`,T.gravity);let y="\u{1F525}",k="\u26A1",$="\u269B\uFE0F",w=u.map((T,A)=>{let H=h[T.id],J=v.get(`${T.file_path}::${T.name}`),M=this.filesRepo.findByPath(T.file_path),N=ut.getMultiplier(T.file_path,M?.classification),W=(Fe.SCORE_BASE-A)*N;H&&(W+=H.score*Fe.SCORE_BASE),J&&(W+=J*Fe.SCORE_BASE*Fe.GRAVITY_STRUCTURAL_WEIGHT),T.name.toLowerCase()===a&&(W+=Fe.EXACT_MATCH_BONUS*N);let q=M?.mtime;if(q!=null){let U=q>1e10?q/1e3:q,he=(Date.now()/1e3-U)/bc.SECONDS_PER_DAY;he<Fe.RECENT_FILE_THRESHOLD_DAYS?W+=Fe.RECENT_FILE_BOOST:he<Fe.OLDER_FILE_THRESHOLD_DAYS&&(W+=Fe.OLDER_FILE_BOOST)}let Z=[];return H&&Z.push(...H.reasons),J&&Z.push(`Structural Hotspot (Gravity: ${J.toFixed(1)})`),{...T,activeGravity:H,structuralGravity:J,sortScore:W,reasons:Z}}).sort((T,A)=>A.sortScore-T.sortScore).slice(i,i+r),I=u.length,P=i+r<I,R=w.map((T,A)=>{let H=c(T.file_path),J=this.filesRepo.getContent(T.file_path),M="";if(J){let q=J.split(`
644
+ `);M=q.slice(Math.max(0,T.start_line-2),Math.min(q.length,T.start_line+3)).join(`
645
+ `).trim()}let N=[];T.activeGravity&&(T.activeGravity.reasons.some(q=>q.includes("Working Set"))?N.push(y):T.activeGravity.reasons.some(q=>q.includes("Recent Intent"))&&N.push(k)),T.structuralGravity&&N.push($);let W=N.length>0?` ${N.join("")}`:"";return{relPath:H,name:T.name,kind:T.kind,signature:T.signature,line:T.start_line,snippet:M,badgeStr:W,gravityReasons:T.reasons}});return{content:[{type:"text",text:`# Symbol Search Results: "${e}"
626
646
 
627
- Showing ${k.length} matching symbol(s)${v?` (use offset=${n+t} for more)`:""}:
647
+ Showing ${R.length} matching symbol(s)${P?` (use offset=${i+r} for more)`:""}:
628
648
 
629
- `+k.map((x,I)=>{let M=`## ${n+I+1}. \`${x.name}\` (${x.kind})${x.badgeStr}
630
- **File**: \`${x.relPath}:${x.line}\`
631
- `;return x.gravityReasons&&(M+=`> *${x.gravityReasons.join(", ")}*
632
- `),x.signature&&(M+=`**Signature**: \`${x.signature}\`
633
- `),x.snippet&&(M+=`
649
+ `+R.map((T,A)=>{let H=`## ${i+A+1}. \`${T.name}\` (${T.kind})${T.badgeStr}
650
+ **File**: \`${T.relPath}:${T.line}\`
651
+ `;return T.gravityReasons&&(H+=`> *${T.gravityReasons.join(", ")}*
652
+ `),T.signature&&(H+=`**Signature**: \`${T.signature}\`
653
+ `),T.snippet&&(H+=`
634
654
  \`\`\`typescript
635
- ${x.snippet}
655
+ ${T.snippet}
636
656
  \`\`\`
637
- `),M}).join(`
638
- `)}]}}async findConceptMatches(e,t,n,s,r,o=0){let c=re(this.repoPath)||void 0;if(!t)return[];let a=this.filesRepo.findWithEmbeddings(),p=new Nn(this.repoPath).getScorer(),u=new nt(this.repoPath).getAncestorMissionIds(),m=[];for(let h of a)try{let b=JSON.parse(h.embedding),y=as(t,b),g=this.filesRepo.getContent(h.path),S=ae.ENABLE_LEXICAL_SCORING&&g?Ft.calculateLexicalScore(g,e):0,R=S>0?.1:.18;if(y>R){if(s&&!i.matchesFilters(h.path,n,h.mtime,h.classification))continue;let w=h.mtime>2e9?Math.floor(h.mtime/1e3):h.mtime,T=Math.floor(Date.now()/1e3)-ps.SECONDS_PER_YEAR,v=be.getMultiplier(h.path,h.classification),k=p.calculateScore(y,w||T);k*=v;let x=this.filesRepo.getGravityMap(u,c)[h.path],I=h.classification?be.mapClassificationToTier(h.classification):be.classify(h.path,{content:g??void 0}),M=`Similarity: ${(y*100).toFixed(0)}%, Tier: ${I}${v!==1?` (${v}x)`:""}`;S>0&&(k+=S*ae.LEXICAL_WEIGHT,M+=` | Lexical: +${S.toFixed(1)}`),x&&(k+=x.score,M+=` | \u{1F525} Gravity: +${x.score.toFixed(1)} (${x.reasons.join(", ")})`);let $=g?Ft.extractSnippet(g,e):void 0;m.push({path:h.path,summary:h.summary||"",score:y,decayedScore:k,rationale:M,snippet:$})}}catch{}let f=new Map;for(let h of m){let b=h.path.split("/").pop()?.split(".")[0].replace(/(Controller|Service|Repository|Component|View|Page|Handler|Wrapper|Client|DTO|Interface)$/i,"").toLowerCase();b&&b.length>3&&(f.has(b)||f.set(b,[]),f.get(b).push(h))}for(let[h,b]of f.entries())if(new Set(b.map(g=>g.path.split(".").pop())).size>1)for(let g of b)g.decayedScore=(g.decayedScore||0)+.15,g.rationale+=` | \u{1F310} Polyglot Flow: +0.15 (Linked via '${h}')`;return m.sort((h,b)=>(b.decayedScore||0)-(h.decayedScore||0)),m}buildFtsQuery(e,t){let n=e.trim();if(!n.includes(" "))return`"${n}" OR ${n}*`;let s=n.split(/\s+/).filter(r=>r.length>0);switch(t){case"exact":return`"${n}"`;case"all":return s.map(r=>`${r}*`).join(" ");default:return s.map(r=>`${r}*`).join(" OR ")}}};P();U();function An(i){let{fileType:e,layer:t}=i,n={fileType:Be.normalizeFileType(e),layer:t},s=!!(n.fileType?.length||n.layer!=null);return{filters:n,hasFilters:s}}async function Kr(i){let e=In(i.query??""),t={...i,query:e},n=fn();try{let{repoPath:s}=Re(t),{query:r,limit:o=at.DEFAULT_LIMIT,offset:c=0,compact:a=!1}=t;await z(s);let{filters:l,hasFilters:p}=An(t),u=await new Be(s).searchByConcept(r,o,c,l,p,a);return Cc(s,r,"concept"),n(),u}catch(s){return _.error({error:s,args:i},"Concept Search failed"),n(),await ot(),{content:[{type:"text",text:`Concept Search failed: ${s instanceof Error?s.message:String(s)}`}],isError:!0}}}function Cc(i,e,t){try{let n=C.getInstance(i),s=re(i);n.searchHistory.record(e,t,s)}catch(n){let s=re(i);_.error({module:"search",repoPath:i,query:e,mode:t,error:n instanceof Error?n.message:String(n),branch:s},"Failed to record search history"),ot()}}P();U();async function Is(i){let e=In(i.query??""),t={...i,query:e},n=fn();try{let{repoPath:s}=Re(t),{query:r,limit:o=at.DEFAULT_LIMIT,offset:c=0,matchMode:a="any"}=t;await z(s);let{filters:l,hasFilters:p}=An(t),u=await new Be(s).searchBySymbol(r,o,c,l,p,a);return $c(s,r,"symbol"),n(),u}catch(s){return _.error({error:s,args:i},"Symbol Search failed"),n(),await ot(),{content:[{type:"text",text:`Symbol Search failed: ${s instanceof Error?s.message:String(s)}`}],isError:!0}}}function $c(i,e,t){try{let n=C.getInstance(i),s=re(i);n.searchHistory.record(e,t,s)}catch(n){let s=re(i);_.error({module:"search",repoPath:i,query:e,mode:t,error:n instanceof Error?n.message:String(n),branch:s},"Failed to record search history"),ot()}}U();P();import Wt from"path";function Xr(i,e){let t=i.findContentByToken(e,100);return{count:t.length,files:t}}async function Zr(i){let{repoPath:e,query:t,key:n="",kind:s,limit:r=50,showUsage:o=!1}=i,c=n||t;if(!c&&!s)return{content:[{type:"text",text:'Error: Either "key" or "kind" parameter is required.'}]};await z(e);let a=C.getInstance(e),{configs:l,files:p}=a;if(c){_.info({repoPath:e,key:c},"Searching for config key in DB...");let f=l.findByKey(c,r);if(f.length===0)return{content:[{type:"text",text:`No configuration found for key: ${c}`}]};if(o){let y=f.map(w=>{let T=Xr(p,w.key),v=T.count===0?"\u26A0\uFE0F ORPHANED":`\u2713 ${T.count} usage(s)`;return{file:Wt.relative(e,w.file_path),key:w.key,value:w.value,kind:w.kind,usageCount:T.count,usageFiles:T.files.slice(0,5).map(k=>Wt.relative(e,k)),status:v}});y.sort((w,T)=>w.usageCount===0&&T.usageCount>0?-1:T.usageCount===0&&w.usageCount>0?1:w.usageCount-T.usageCount);let g=y.filter(w=>w.usageCount===0).length;return{content:[{type:"text",text:(g>0?`# Configuration Search: "${c}" (with Usage Analysis)
639
-
640
- \u26A0\uFE0F **${g} orphaned var(s)** (defined but never used in code)
641
-
642
- Found ${f.length} match(es):
643
-
644
- `:`# Configuration Search: "${c}" (with Usage Analysis)
645
-
646
- Found ${f.length} match(es), all in use:
647
-
648
- `)+y.map(w=>{let T=`## ${w.file} (${w.kind}) ${w.status}
649
- **${w.key}**: \`${w.value}\``;return w.usageCount>0&&w.usageFiles.length>0&&(T+=`
650
- > Used in: ${w.usageFiles.map(v=>`\`${v}\``).join(", ")}${w.usageCount>5?` (+${w.usageCount-5} more)`:""}`),T}).join(`
651
-
652
- `)}]}}let h=f.map(y=>({file:Wt.relative(e,y.file_path),key:y.key,value:y.value,kind:y.kind}));return{content:[{type:"text",text:`# Configuration Search: "${c}"
653
-
654
- Found ${f.length} match(es):
655
-
656
- `+h.map(y=>`## ${y.file} (${y.kind})
657
- **${y.key}**: \`${y.value}\``).join(`
658
-
659
- `)+"\n\n> \u{1F4A1} **Tip**: Use `showUsage: true` to see usage counts and identify orphaned vars."}]}}let d=l.findByKind(s||null,r);if(o){let f=d.map(g=>{let S=Xr(p,g.key);return{file:Wt.relative(e,g.file_path),key:g.key,value:g.value,kind:g.kind,usageCount:S.count,status:S.count===0?"ORPHANED":"in-use"}});f.sort((g,S)=>g.usageCount===0&&S.usageCount>0?-1:S.usageCount===0&&g.usageCount>0?1:g.usageCount-S.usageCount);let h=f.filter(g=>g.usageCount===0).length,b=f.length,y=`# Config Discovery (${s||"all"}) with Usage Analysis
660
-
661
- `;return y+=`**Summary**: ${b} config(s) found, ${h} orphaned
662
-
663
- `,h>0&&(y+=`## \u26A0\uFE0F Orphaned (${h})
664
- `,y+=f.filter(g=>g.usageCount===0).map(g=>`- \`${g.key}\` in ${g.file}`).join(`
665
- `),y+=`
666
-
667
- `),y+=`## \u2713 In Use (${b-h})
668
- `,y+=f.filter(g=>g.usageCount>0).map(g=>`- \`${g.key}\` (${g.usageCount} usages)`).join(`
669
- `),d.length===r&&(y+=`
670
-
671
- > Results limited to ${r} entries. Use the 'limit' parameter to see more.`),{content:[{type:"text",text:y}]}}let u=d.map(f=>({...f,file:Wt.relative(e,f.file_path)})),m=JSON.stringify(u,null,2);return d.length===r&&(m=`Results limited to ${r} entries. Use the 'limit' parameter to see more.
672
-
673
- `+m),m+="\n\n> \u{1F4A1} **Tip**: Use `showUsage: true` to see usage counts and identify orphaned vars.",{content:[{type:"text",text:m}]}}U();import eo from"path";async function Mn(i){let{repoPath:e,filePath:t}=Re(i);if(!t)return{content:[{type:"text",text:"Error: filePath is required"}],isError:!0};let n=i.detailLevel||"signatures";await z(e);let{files:s,exports:r}=C.getInstance(e),o=s.findByPath(t),c=eo.basename(t),a=/\.(ts|tsx|php|py|go)$/.test(c),l;a?l=await $t(t):l={exports:r.findByFile(t),imports:[]},n==="structure"?(l.exports=l.exports.map(m=>{let f={name:m.name,kind:m.kind,line:m.start_line,classification:m.classification};return m.members&&m.members.length>0?{...f,members:m.members.map(h=>({name:`${m.name}.${h.name}`,kind:h.kind,line:h.start_line}))}:f}),delete l.imports):n==="signatures"&&(l.exports=l.exports.map(m=>{let f={name:m.name,kind:m.kind,signature:m.signature,line:m.start_line,classification:m.classification,capabilities:JSON.parse(m.capabilities||"[]")};return m.members&&m.members.length>0?{...f,members:m.members.map(h=>({name:`${m.name}.${h.name}`,kind:h.kind,signature:h.signature,line:h.start_line}))}:f}),delete l.imports);let p=eo.relative(e,t),d=l.exports?.length||0,u="";return n==="structure"&&d>0?u=`
674
-
675
- \u{1F4A1} Showing ${d} symbol names. For full signatures: shadow_inspect_file({ filePath: "${p}", detailLevel: "signatures" })`:n==="signatures"&&d>0&&(u=`
676
-
677
- \u{1F4A1} Showing ${d} complete signatures. To inspect a specific symbol: shadow_inspect_symbol({ symbolName: "...", context: "full" })`),{content:[{type:"text",text:JSON.stringify({...l,fileDescription:o?.summary||"",classification:o?.classification||"Unknown"},null,2)+u}]}}U();import to from"path";import kc from"fs";function Lc(i,e,t){let n=i.split(`
678
- `),s=[],r=0;for(let d=0;d<Math.min(n.length,50);d++){let u=n[d].trim();if(u.startsWith("import ")||u.startsWith("from ")||u.startsWith("export ")&&u.includes(" from "))r=d+1;else if(u&&!u.startsWith("//")&&!u.startsWith("/*")&&!u.startsWith("*")&&u!==""&&r>0)break}r>0&&(s.push(...n.slice(0,r)),s.push(""));let o=[...t].sort((d,u)=>d.startLine-u.startLine),c=0,a=0;for(let d of o)if(d.isTarget){s.push(`// \u2501\u2501\u2501 REQUESTED: ${d.name} \u2501\u2501\u2501`);let u=n.slice(d.startLine-1,d.endLine);s.push(...u),s.push("// \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),s.push(""),a++}else{let u=d.signature||Nc(n,d.startLine-1,d.kind);u&&(s.push(`${u}`),s.push(` /* implementation: ${d.lineCount} lines */`),s.push(""),c++)}let l=o[o.length-1];if(l)for(let d=l.endLine;d<n.length;d++){let u=n[d].trim();if(u==="}"||u==="};"){s.push(n[d]);break}else if(u&&!u.startsWith("//"))break}return{foldedSource:s.join(`
679
- `),totalOriginalLines:n.length,foldedToLines:s.length,siblingsShown:a,siblingsFolded:c}}function Nc(i,e,t){let n=i[e];if(t.includes("Function")||t.includes("Method")||t.includes("Arrow")){let s="";for(let r=e;r<Math.min(e+5,i.length);r++)if(s+=i[r],s.includes("{")||s.includes("=>")){let o=s.indexOf("{");o>0&&(s=s.substring(0,o).trim());break}return s.trim()}return n}async function gt(i){let{repoPath:e,filePath:t,resolver:n}=Re(i),s=String(i.symbolName),r=i.context||"definition";if(t&&!n.isWithinRoot(t))return{content:[{type:"text",text:`Error: Access denied. Path ${t} is outside the repository root.`}],isError:!0};await z(e);let o=C.getInstance(e),c=[];if(s.includes(".")){let[T,v]=s.split(".");c=o.exports.findMemberCandidates(T,v,t)}else c=o.exports.findDefinitionCandidates(s,t);if(c.length===0){let T=o.exports.findPotentialParents(s);if(T.length>0){let x=T.map(I=>`\`${I.name}\` (in ${n.getRelative(I.file_path)})`).join(", ");return{content:[{type:"text",text:`Symbol "${s}" not found as a top-level export.
680
- However, it likely exists inside: ${x}.
681
- Try: shadow_inspect_symbol({ symbolName: "${T[0].name}", context: "full" }) to see the class body.`}]}}let k=o.exports.findFuzzyCandidates(s).map(x=>x.name),F=Ht(s,k,50,3);if(F.length>0){let x=F.map(I=>` \u2022 \`${I.match}\` (${I.score}% match)`).join(`
682
- `);return{content:[{type:"text",text:`Error: Symbol "${s}" not found in the index.
683
-
684
- Suggestions:
685
- ${x}
686
-
687
- Next steps:
688
- \u2022 Search semantically: shadow_search_concept({ query: "${s}" })
689
- \u2022 Verify repository is indexed: shadow_sync_index({ repoPath: "${e}" })`}]}}return{content:[{type:"text",text:`Error: Symbol "${s}" not found in the index.
690
-
691
- Next steps:
692
- \u2022 Search for it: shadow_search_concept({ query: "${s}" })
693
- \u2022 Try with file path: shadow_inspect_symbol({ symbolName: "${s}", filePath: "..." })
694
- `}]}}let a=c[0];if(a.kind==="ExportSpecifier"||a.kind==="ExportAllDeclaration"){let T=o.imports.findImportSource(a.file_path,s);if(T&&T.resolved_path)return gt({...i,filePath:T.resolved_path})}let l=kc.readFileSync(a.file_path,"utf8"),p=l.split(`
695
- `),d=a.end_line-a.start_line+1,u=150,m,f=!1,h=null;if(r==="definition"&&d>u){let v=o.exports.findSiblings(a.file_path).map(k=>({name:k.name,kind:k.kind,signature:k.signature||"",startLine:k.start_line,endLine:k.end_line,lineCount:k.end_line-k.start_line+1,isTarget:k.name===a.name&&k.start_line===a.start_line,parentName:k.parent_name}));if(v.length>1){h=Lc(l,{name:a.name,startLine:a.start_line,endLine:a.end_line},v);let k=n.getRelative(a.file_path);m=h.foldedSource+`
696
-
697
- \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
698
- \u{1F4CA} Semantic Fold Applied (context: "definition")
699
-
700
- Original file: ${h.totalOriginalLines} lines
701
- Folded view: ${h.foldedToLines} lines
702
- Target Symbol: ${a.name}
703
- \u{1F4A1} Need more context?
704
- \u2022 Full symbol + dependencies + usage: shadow_inspect_symbol({ symbolName: "${a.name}", context: "full" })
705
- \u2022 ALL symbols in this file: shadow_inspect_file({ filePath: "${k}", detailLevel: "signatures" })
706
- \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501`,f=!0}else m=p.slice(a.start_line-1,a.start_line-1+u).join(`
707
- `)+`
708
-
709
- ... (truncated ${d-u} lines)`,f=!0}else m=p.slice(a.start_line-1,a.end_line).join(`
710
- `);let b=a.parent_name?`${a.parent_name}.${a.name}`:a.name,y=o.exports.findHydratedById(a.id),g={name:b,kind:a.kind,file:n.getRelative(a.file_path),startLine:a.start_line,endLine:a.end_line,totalLines:d,...f&&{truncated:!0,previewLines:u},classification:a.classification,intelligence:y?{working_set_of:y.active_missions.map(T=>`Mission #${T.id}: ${T.name}`),total_intents:y.intent_log_count,latest_intent:y.recent_intents[0]?`${y.recent_intents[0].type}: ${y.recent_intents[0].content}`:null}:void 0,source:m};if(r==="definition")return{content:[{type:"text",text:JSON.stringify(g,null,2)}]};let S={definition:g,dependencies:o.imports.getImportsForFile(a.file_path).map(T=>({module:T.module_specifier,symbols:T.imported_symbols,relativePath:T.resolved_path?to.relative(e,T.resolved_path):null}))},R=[a.file_path],w=o.imports.findVerifiedDependents(R,s);return S.verifiedUsages=w.slice(0,10).map(T=>({file:to.relative(e,T.file_path),classification:T.classification,importedSymbols:T.imported_symbols})),{content:[{type:"text",text:JSON.stringify(S,null,2)}]}}async function no(i,e){let t=jt.resolve(e.dir);await B(async()=>{le("Semantic Concept Search");let n=de();n.start(`Analyzing intent: "${E.bold(i)}"...`);try{let s=await Kr({repoPath:t,query:i});n.stop("Analysis complete.");let r=s.content[0].text;if(r.includes("Found")){let c=r.split("## ").slice(1).map(a=>{let[l,...p]=a.split(`
711
-
712
- `),[d,u]=l.split(" ( "),m=(d??"").replace(/^\d+\.\s*/,"").trim(),f=p.find(h=>h.startsWith("**Summary**: "))?.replace("**Summary**: ","")||"";return{name:m,matchPct:u??"",summaryLine:f}});if(c.forEach(({name:a,matchPct:l,summaryLine:p})=>{se(`${E.green(a)} ${E.dim("("+(l||""))}`,p,"blue"),console.log("")}),e.interactive&&c.length>1){let a=await cn("Inspect a file",c.map(l=>({value:{name:l.name},label:l.name,hint:l.summaryLine.slice(0,50)})),{limit:15});if(a){let l=a.name.startsWith(t)?a.name:jt.join(t,a.name),p=await Mn({repoPath:t,filePath:l});p.content?.[0]&&(console.log(""),se(E.bold("File summary"),p.content[0].text,"cyan"))}}}else console.log(r)}catch(s){throw n.stop(`Search failed: ${s.message}`),s}finally{await q(t)}})}async function so(i,e){let t=jt.resolve(e.dir);await B(async()=>{le("Symbol Search");let n=de();n.start(`Searching symbols: "${E.bold(i)}"...`);try{let s=await Is({repoPath:t,query:i});n.stop("Search complete.");let r=s.content[0].text;try{let o=JSON.parse(r);if(Array.isArray(o)){if(console.log(""),an(["Symbol","Kind","File","Line"],o.map(c=>[E.bold(E.green(c.name)),E.dim(c.kind??""),E.cyan(c.file??""),E.yellow(String(c.line??""))])),e.interactive&&o.length>1){let c=o.map(l=>({value:l,label:l.name,hint:`${l.file??""}:${l.line??""}`})),a=await cn("Inspect symbol",c,{limit:15});if(a){let l=await gt({repoPath:t,symbolName:a.name});l.content?.[0]&&(console.log(""),se(E.bold(a.name),l.content[0].text,"cyan"))}}}else console.log(r)}catch{console.log(r)}}catch(s){throw n.stop(`Search failed: ${s.message}`),s}finally{await q(t)}})}async function io(i,e){let t=jt.resolve(e.dir);await B(async()=>{le("Fuzzy Symbol Search");let n=de();n.start(`Fuzzy matching: "${E.bold(i)}"...`);try{let s=await Is({repoPath:t,query:i});n.stop("Search complete.");let r=s.content[0].text;if(r.includes("## ")){let c=r.split("## ").slice(1).map(a=>{let l=a.split(`
713
- `),p=l[0],d=l.find(y=>y.startsWith("**Match**:"))||"",u=l.find(y=>y.startsWith("**File**:"))||"",m=p.match(/`([^`]+)`/),f=m?m[1]:"",h=d.match(/\*\*Match\*\*: (.+) \((\d+)% confidence\)/),b=u.match(/`([^:]+):(\d+)`/);return{symbolName:f,file:b?b[1]:"",line:b?b[2]:"",matchType:h?h[1]:"",confidence:h?h[2]:""}});if(console.log(""),console.log(E.dim(`Found ${c.length} fuzzy match(es):`)),console.log(""),c.forEach((a,l)=>{console.log(`${E.dim(`${l+1}.`)} ${E.bold(E.green(a.symbolName))} ${E.dim(`(${a.matchType}, ${a.confidence}% match)`)}`),console.log(` ${E.cyan(a.file)}:${E.yellow(a.line)}`),console.log("")}),e.interactive&&c.length>1){let a=await cn("Inspect symbol",c.map(l=>({value:l,label:l.symbolName,hint:`${l.file}:${l.line}`})),{limit:15});if(a){let l=await gt({repoPath:t,symbolName:a.symbolName});l.content?.[0]&&(console.log(""),se(E.bold(a.symbolName),l.content[0].text,"cyan"))}}}else console.log(r)}catch(s){throw n.stop(`Search failed: ${s.message}`),s}finally{await q(t)}})}async function ro(i,e){let t=jt.resolve(e.dir);await B(async()=>{le("Config Search");let n=de();n.start(`Searching config: ${E.bold(i||"all")}...`);try{let s=await Zr({repoPath:t,key:i,kind:e.kind});n.stop("Search complete."),se("\u2699\uFE0F Results",s.content[0].text,"yellow")}finally{await q(t)}})}P();var Cs=_.child({module:"mcp:tools:env:hooks"});async function Pn(i){let{repoPath:e,action:t,enableAutoRefresh:n,enableSymbolHealing:s}=i;if(t==="install"){Cs.info({repoPath:e,enableAutoRefresh:n,enableSymbolHealing:s},"Installing git hooks");let r=Si({repoPath:e,enableAutoRefresh:n??!0,enableSymbolHealing:s??!0}),o=["# Git Hooks Installation","",`## Installed (${r.installed.length})`,r.installed.length>0?r.installed.map(c=>`- \`${c}\``).join(`
714
- `):"- None","",`## \u23ED\uFE0F Skipped (${r.skipped.length})`,r.skipped.length>0?r.skipped.map(c=>`- \`${c}\` (already installed)`).join(`
715
- `):"- None",""];return r.errors.length>0&&(o.push(`## Errors (${r.errors.length})`),o.push(r.errors.map(c=>`- ${c}`).join(`
716
- `)),o.push("")),o.push("---"),o.push("**What happens now?**"),(n??!0)&&o.push("- After `git pull` or `git checkout`: Index auto-refreshes in background"),(s??!0)&&o.push("- After `git commit`: Symbol shift detection runs automatically"),{content:[{type:"text",text:o.join(`
717
- `)}]}}if(t==="remove"){Cs.info({repoPath:e},"Uninstalling git hooks");let r=_i(e),o=["# Git Hooks Uninstallation","",`## Removed (${r.removed.length})`,r.removed.length>0?r.removed.map(c=>`- \`${c}\``).join(`
718
- `):"- None",""];return r.errors.length>0&&(o.push(`## Errors (${r.errors.length})`),o.push(r.errors.map(c=>`- ${c}`).join(`
719
- `))),{content:[{type:"text",text:o.join(`
720
- `)}]}}if(t==="status"){Cs.info({repoPath:e},"Checking git hooks status");let r=mn(e);return{content:[{type:"text",text:["# Git Hooks Status","",`## Installed (${r.installed.length})`,r.installed.length>0?r.installed.map(c=>`- \`${c}\``).join(`
721
- `):"- None","",`## Not Installed (${r.notInstalled.length})`,r.notInstalled.length>0?r.notInstalled.map(c=>`- \`${c}\``).join(`
722
- `):"- None","","---",'**To install hooks**: Use `shadow_env_hooks({ action: "install" })`'].join(`
723
- `)}]}}return{content:[{type:"text",text:`Unknown action: ${t}`}],isError:!0}}async function oo(i){let[e,t="."]=i;if(!e||!["install","uninstall","status"].includes(e)){console.log(""),console.log(` ${E.bold("Usage: ")} liquid-shadow hooks <install|uninstall|status> [path]`),console.log(""),console.log(` ${E.bold("Commands: ")}`),console.log(` ${E.cyan("install")} Install git hooks for automatic index refresh and symbol healing`),console.log(` ${E.cyan("uninstall")} Remove installed git hooks`),console.log(` ${E.cyan("status")} Check git hooks installation status`),console.log(""),console.log(` ${E.bold("Examples: ")}`),console.log(" liquid-shadow hooks install ."),console.log(" liquid-shadow hooks status /path/to/repo"),console.log("");return}await B(async()=>{let n=Go("path").resolve(t);switch(e){case"install":{let s=await Pn({repoPath:n,action:"install",enableAutoRefresh:!0,enableSymbolHealing:!0});if(console.log(""),console.log(` ${E.green("\u2714")} ${E.bold("Git hooks installed successfully")}`),console.log(""),s.content&&s.content[0])try{let r=JSON.parse(s.content[0].text);console.log(` ${E.bold("Installed hooks: ")}`),r.hooks.forEach(o=>{console.log(` ${E.cyan("\u2022")} ${o}`)}),console.log("")}catch{console.log(s.content[0].text)}break}case"uninstall":{await Pn({repoPath:n,action:"remove"}),console.log(""),console.log(` ${E.green("\u2714")} ${E.bold("Git hooks uninstalled successfully")}`),console.log("");break}case"status":{let s=await Pn({repoPath:n,action:"status"});if(console.log(""),console.log(` ${E.bold("Git Hooks Status")}`),console.log(""),s.content&&s.content[0])try{let r=JSON.parse(s.content[0].text);r.installed&&r.installed.length>0?(console.log(` ${E.green("\u2714")} Installed hooks:`),r.installed.forEach(o=>{console.log(` ${E.cyan("\u2022")} ${o}`)})):console.log(` ${E.yellow("\u26A0")} No hooks installed`),r.missing&&r.missing.length>0&&(console.log(""),console.log(` ${E.dim("Missing hooks: ")}`),r.missing.forEach(o=>{console.log(` ${E.dim("\u2022")} ${o}`)}))}catch{console.log(s.content[0].text)}console.log("");break}}})}U();P();import Ac from"path";import Mc from"fs";var ao=_.child({module:"mcp:tools:workspace:list"});async function co(i){let{repoPaths:e,status:t,limit:n,summarize:s=!1}=i;ao.info({repoCount:e.length,status:t,summarize:s},"Getting workspace missions");let r=[];for(let c of e)if(Mc.existsSync(c))try{let{missions:a}=C.getInstance(c),l=a.findAll(t);for(let p of l){let d=a.getLinks(p.id);r.push({...p,repo_path:c,repo_name:Ac.basename(c),cross_repo_links:d})}}catch(a){ao.error({error:a,repoPath:c},"Failed to query repo missions")}if(r.sort((c,a)=>{let l=u=>u==="in-progress"?0:u==="verifying"?1:2,p=l(c.status),d=l(a.status);return p!==d?p-d:(c.created_at||0)-(a.created_at||0)}),s||r.length>50&&!n){let c=n||20,a=r.slice(0,c),l=r.reduce((d,u)=>(d[u.status]=(d[u.status]||0)+1,d),{}),p=r.reduce((d,u)=>(d[u.repo_name]=(d[u.repo_name]||0)+1,d),{});return{content:[{type:"text",text:JSON.stringify({summary:{total_missions:r.length,by_status:l,by_repo:p,showing_top:c},top_missions:a,hint:`Showing top ${c} of ${r.length} missions. Use limit to adjust or summarize:false for full list.`},null,2)}]}}let o=n?r.slice(0,n):r;return{content:[{type:"text",text:JSON.stringify({total_missions:r.length,showing:o.length,missions:o},null,2)}]}}U();P();var Pc=_.child({module:"mcp:tools:workspace:link"});async function lo(i){let{parentRepoPath:e,parentMissionId:t,childRepoPath:n,childMissionId:s,relationship:r="related"}=i;Pc.info({parentRepoPath:e,childRepoPath:n},"Linking cross-repo missions");let{missions:o}=C.getInstance(e),{missions:c}=C.getInstance(n);try{let a=o.findById(t),l=c.findById(s);if(!a)throw new Error(`Parent mission ${t} not found`);if(!l)throw new Error(`Child mission ${s} not found`);return o.createLink(t,n,s,r,"parent"),c.createLink(s,e,t,r,"child"),{content:[{type:"text",text:JSON.stringify({status:"linked",relationship:r},null,2)}]}}catch(a){throw new Error(`Failed to link: ${a.message}`)}}P();import Gc from"path";P();Qe();import Dc from"better-sqlite3";import yt from"path";import po from"fs";import Oc from"os";import Fc from"crypto";var Hc=_.child({module:"fusion-connection"}),Dn=5,Wc=1,uo=["files","exports","imports","configs","schema_migrations"],On=class{fusionDb;attachedRepos=new Map;fusionDbPath;name;constructor(e){this.name=e.name,this.fusionDbPath=this.getFusionDbPath(e.name),Hc.info({name:e.name,path:this.fusionDbPath},"Initializing fused index connection");let t=yt.dirname(this.fusionDbPath);po.existsSync(t)||po.mkdirSync(t,{recursive:!0}),this.fusionDb=new Dc(this.fusionDbPath),this.fusionDb.pragma("journal_mode = WAL"),this.fusionDb.pragma("busy_timeout = 5000"),this.initFusionSchema();for(let n of e.repoPaths)this.attachRepo(n)}getFusionDbPath(e){let t=Oc.homedir(),n=yt.join(t,".mcp-liquid-shadow","fused"),s=e.replace(/[^a-zA-Z0-9-_]/g,"_");return yt.join(n,`${s}.db`)}initFusionSchema(){this.fusionDb.exec(`
657
+ `),H}).join(`
658
+ `)}]}}async findConceptMatches(e,r,i,t,o,s=0){let a=Ee(this.repoPath)||void 0;if(!r)return[];let c=this.filesRepo.findWithEmbeddings(),u=new Pn(this.repoPath).getScorer(),p=new oi(this.repoPath).getAncestorMissionIds(),m=[];for(let h of c)try{let _=JSON.parse(h.embedding),v=ro(r,_),y=this.filesRepo.getContent(h.path),k=Fe.ENABLE_LEXICAL_SCORING&&y?ii.calculateLexicalScore(y,e):0,$=1;if(y){let I=/\b(class|function|const|let|var|enum)\s+\w+/.test(y);if(/export\s+/.test(y)&&!I){let R=y.replace(/\/\/.*$/gm,"").replace(/\/\*[\s\S]*?\*\//g,"");/\b(class|function|const|let|var|enum)\s+\w+/.test(R)||($=.1)}}let w=k>0?.1:.18;if(v>w){if(t&&!n.matchesFilters(h.path,i,h.mtime,h.classification))continue;let I=h.mtime>2e9?Math.floor(h.mtime/1e3):h.mtime,P=Math.floor(Date.now()/1e3)-bc.SECONDS_PER_YEAR,R=ut.getMultiplier(h.path,h.classification),F=u.calculateScore(v,I||P);F*=R;let A=this.filesRepo.getGravityMap(p,a)[h.path],H=h.classification?ut.mapClassificationToTier(h.classification):ut.classify(h.path,{content:y??void 0}),J=`Similarity: ${(v*100).toFixed(0)}%, Tier: ${H}${R!==1?` (${R}x)`:""}`;k>0&&(F+=k*Fe.LEXICAL_WEIGHT,J+=` | Lexical: +${k.toFixed(1)}`),A&&(F+=A.score,J+=` | \u{1F525} Gravity: +${A.score.toFixed(1)} (${A.reasons.join(", ")})`),$<1&&(F*=$,J+=` | \u{1F4C9} Barrel: x${$}`);let M=y?ii.extractSnippet(y,e):void 0;m.push({path:h.path,summary:h.summary||"",score:v,decayedScore:F,rationale:J,snippet:M})}}catch{}let f=new Map;for(let h of m){let _=h.path.split("/").pop()?.split(".")[0].replace(/(Controller|Service|Repository|Component|View|Page|Handler|Wrapper|Client|DTO|Interface)$/i,"").toLowerCase();_&&_.length>3&&(f.has(_)||f.set(_,[]),f.get(_).push(h))}for(let[h,_]of f.entries())if(new Set(_.map(y=>y.path.split(".").pop())).size>1)for(let y of _)y.decayedScore=(y.decayedScore||0)+.15,y.rationale+=` | \u{1F310} Polyglot Flow: +0.15 (Linked via '${h}')`;return m.sort((h,_)=>(_.decayedScore||0)-(h.decayedScore||0)),m}async findIntentLogMatches(e,r){return(await this.intentLogsRepo.findSemanticMatches(e,r)).map(t=>({id:t.id,missionId:t.mission_id,type:t.type,content:t.content,symbolName:t.symbol_name,filePath:t.file_path,score:t.similarity,decayedScore:t.similarity,rationale:`Similarity: ${(t.similarity*100).toFixed(0)}%`,createdAt:t.created_at}))}buildFtsQuery(e,r){let i=e.trim();if(!i.includes(" "))return`"${i}" OR ${i}*`;let t=i.split(/\s+/).filter(o=>o.length>0);switch(r){case"exact":return`"${i}"`;case"all":return t.map(o=>`${o}*`).join(" ");default:return t.map(o=>`${o}*`).join(" OR ")}}};He();_t();function Rn(n){let{fileType:e,layer:r}=n,i={fileType:et.normalizeFileType(e),layer:r},t=!!(i.fileType?.length||i.layer!=null);return{filters:i,hasFilters:t}}X();He();import{Visitor as vS}from"@swc/core/Visitor.js";var er=class extends vS{calls=new Set;apiCalls=[];imports=new Map;axiosInstances=new Map([["axios",""],["http",""],["appApi",""],["restApi",""],["adminApi",""]]);visitImportDeclaration(e){let r=e.source.value;for(let i of e.specifiers)(i.type==="ImportDefaultSpecifier"||i.type==="ImportSpecifier")&&this.imports.set(i.local.value,r);return super.visitImportDeclaration(e)}visitCallExpression(e){if(e.callee.type==="Identifier"){let r=e.callee.value;this.calls.add(r),(r==="axios"||r==="http")&&e.arguments.length>0&&this.extractApiCallFromConfig(e.arguments[0].expression)}else if(e.callee.type==="MemberExpression"){let r=e.callee.property.value,i=o=>{if(!o)return"?";if(o.type==="Identifier")return o.value;if(o.type==="ThisExpression")return"this";if(o.type==="MemberExpression"){let s=i(o.object),a=o.property.value||"?";return`${s}.${a}`}return o.type==="TsNonNullExpression"||o.type==="TsAsExpression"||o.type==="ParenthesisExpression"?i(o.expression):"?"},t=i(e.callee.object);if(t!=="?"&&r){if(this.calls.add(`${t}.${r}`),t==="axios"||t==="http"||this.axiosInstances.has(t)){let o=this.axiosInstances.get(t)||"";this.extractApiCall(r,e.arguments,o)}if((t.toLowerCase().includes("pubsub")||t==="pubSubClient"||t.endsWith(".pubSubClient"))&&r!=="subscribe"){let o=r;if((r==="publish"||r==="publishMessage"||r==="publishTaskByNameAndPayload")&&e.arguments.length>0)for(let s of e.arguments){let a=s.expression;if(a.type==="ObjectExpression"){let c=a.properties.find(l=>l.key?.type==="Identifier"&&(l.key.value==="action"||l.key.value==="type")||l.key?.type==="StringLiteral"&&(l.key.value==="action"||l.key.value==="type"));if(c&&c.value?.type==="StringLiteral"){o=c.value.value;break}}if(a.type==="CallExpression"&&a.callee.type==="MemberExpression"&&a.callee.object.value==="JSON"&&a.callee.property.value==="stringify"&&a.arguments.length>0){let c=a.arguments[0].expression;if(c.type==="ObjectExpression"){let l=c.properties.find(u=>u.key?.type==="Identifier"&&(u.key.value==="action"||u.key.value==="type")||u.key?.type==="StringLiteral"&&(u.key.value==="action"||u.key.value==="type"));if(l&&l.value?.type==="StringLiteral"){o=l.value.value;break}}}}this.apiCalls.push({method:"PUBSUB",url:o})}}}return e.callee.type==="Identifier"&&e.callee.value==="fetch"&&this.extractApiCall("GET",e.arguments),super.visitCallExpression(e)}visitNewExpression(e){return e.callee.type==="Identifier"&&this.calls.add(e.callee.value),super.visitNewExpression(e)}visitVariableDeclarator(e){if(e.init&&e.init.type==="CallExpression"){let r=e.init.callee;if(r.type==="MemberExpression"&&r.property.value==="create"&&r.object.value==="axios"){let t=e.init.arguments[0]?.expression;if(t&&t.type==="ObjectExpression"){let o=t.properties.find(s=>s.key.value==="baseURL");if(o){let s="?";o.value.type==="StringLiteral"?s=o.value.value:o.value.type==="Identifier"&&(s=`\${${o.value.value}}`),e.id.type==="Identifier"&&this.axiosInstances.set(e.id.value,s)}}}}return super.visitVariableDeclarator(e)}extractApiCallFromConfig(e){if(e&&e.type==="ObjectExpression"){let r=e.properties.find(t=>t.key.type==="Identifier"&&t.key.value==="url"||t.key.type==="StringLiteral"&&t.key.value==="url"),i=e.properties.find(t=>t.key.type==="Identifier"&&t.key.value==="method"||t.key.type==="StringLiteral"&&t.key.value==="method");if(r&&r.value){let t=i?.value?.value||"GET",o=this.resolveUrlValue(r.value);o!=="?"&&this.apiCalls.push({method:t.toUpperCase(),url:o})}}}resolveUrlValue(e){return e.type==="StringLiteral"?e.value:e.type==="TemplateLiteral"?e.quasis.map(r=>r.cooked).join("*"):"?"}visitTsType(e){return e}extractApiCall(e,r,i=""){if(r.length>0){let t=r[0].expression,o=this.resolveUrlValue(t);if(o!=="?"){if(i&&i!=="?"){let s=i.endsWith("/")||o.startsWith("/")?"":"/";o=`${i}${s}${o}`}this.apiCalls.push({method:e.toUpperCase(),url:o})}}}},Yt=class{calls=new Set;apiCalls=[];imports=new Map;visit(e,r){if(r===".php"){let i=/(?:([a-zA-Z0-9_$->:\(\)]*)?(?:->|::))?([a-zA-Z0-9_]+)\s*\(([\s\S]*?)\)/g,t;for(;(t=i.exec(e))!==null;){let o=t[1]||"",s=t[2],a=t[3];if(this.calls.add(s),o&&!["$this","self","parent"].includes(o)&&this.calls.add(`${o}${o.includes("::")?"::":"->"}${s}`),["save","delete","update","create","first","all","where","get","find"].includes(s)&&o&&!["Log","Route","Cache","Config","Http"].includes(o)&&this.apiCalls.push({method:"DB",url:`${o}->${s}()`}),s==="publish"&&o&&(o.includes("topic")||o.includes("pubSub"))&&this.apiCalls.push({method:"PUBSUB",url:"publish"}),["get","post","put","delete","patch","request"].includes(s)&&(o==="Http"||o==="client"||o.endsWith("request")||o.includes("Client")||!o)){let u=a.match(/(?:url\s*:\s*)?['"]([^'"]+)['"]/),d=u?u[1]:a.split(",")[0].trim()||"unknown";this.apiCalls.push({method:s.toUpperCase(),url:d})}}}else if(r===".py"){let i=/(?:([a-zA-Z0-9_\.]+)\.)?([a-zA-Z0-9_]+)\s*\(([\s\S]*?)\)/g,t;for(;(t=i.exec(e))!==null;){let o=t[1]||"",s=t[2],a=t[3];if(this.calls.add(s),o&&o!=="self"&&o!=="cls"&&this.calls.add(`${o}.${s}`),["save","delete","update","create","first","all","filter","get"].includes(s)&&o&&!["logger","os","sys"].includes(o)&&this.apiCalls.push({method:"DB",url:`${o}.${s}()`}),s==="publish"&&o&&(o.includes("publisher")||o.includes("client"))&&this.apiCalls.push({method:"PUBSUB",url:"publish"}),["get","post","put","delete","patch","request"].includes(s)&&(o==="requests"||o==="httpx"||o==="client"||o==="http"||!o)){let u=a.match(/(?:url\s*:\s*)?['"]([^'"]+)['"]/),d=u?u[1]:a.split(",")[0].trim()||"unknown";this.apiCalls.push({method:s.toUpperCase(),url:d})}}}else if([".ts",".tsx",".js",".jsx"].includes(r)){let i=/import\s+[\s\S]*?from\s+['"](.*?)['"];?/g,t;for(;(t=i.exec(e))!==null;)this.imports.set("*",t[1]);let o=/(?:([a-zA-Z0-9_$]+)\.)?([a-zA-Z0-9_$]+)\s*\(/g,s;for(;(s=o.exec(e))!==null;){let a=s[1],c=s[2];a?(this.calls.add(`${a}.${c}`),(a.toLowerCase().includes("pubsub")||a==="pubSubClient")&&c!=="subscribe"&&this.apiCalls.push({method:"PUBSUB",url:c})):this.calls.add(c)}}else{let i=/\.([a-zA-Z0-9_]+)\s*\(/g,t;for(;(t=i.exec(e))!==null;)this.calls.add(t[1])}if(r===".php"){let i=/use\s+([a-zA-Z0-9_\\]+)(?:\s+as\s+([a-zA-Z0-9_]+))?;/g,t;for(;(t=i.exec(e))!==null;){let o=t[1],s=o.split("\\"),a=t[2]||s[s.length-1];this.imports.set(a,o)}}else if(r===".py"){let i=/from\s+([a-zA-Z0-9_\.]+)\s+import\s+([a-zA-Z0-9_,\s]+)/g,t;for(;(t=i.exec(e))!==null;){let a=t[1];t[2].split(",").map(l=>l.trim()).forEach(l=>{this.imports.set(l,a)})}let o=/^import\s+([a-zA-Z0-9_\.]+)/gm,s;for(;(s=o.exec(e))!==null;){let a=s[1],c=a.split("."),l=c[c.length-1];this.imports.set(l,a)}}}};G();import TS from"path";G();st();import bS from"better-sqlite3";import tr from"path";import kg from"fs";import _S from"os";import xS from"crypto";var SS=x.child({module:"fusion-connection"}),Mo=5,$S=1,Eg=["files","exports","imports","configs","schema_migrations"],jo=class{fusionDb;attachedRepos=new Map;fusionDbPath;name;constructor(e){this.name=e.name,this.fusionDbPath=this.getFusionDbPath(e.name),SS.info({name:e.name,path:this.fusionDbPath},"Initializing fused index connection");let r=tr.dirname(this.fusionDbPath);kg.existsSync(r)||kg.mkdirSync(r,{recursive:!0}),this.fusionDb=new bS(this.fusionDbPath),this.fusionDb.pragma("journal_mode = WAL"),this.fusionDb.pragma("busy_timeout = 5000"),this.initFusionSchema();for(let i of e.repoPaths)this.attachRepo(i)}getFusionDbPath(e){let r=_S.homedir(),i=tr.join(r,".mcp-liquid-shadow","fused"),t=e.replace(/[^a-zA-Z0-9-_]/g,"_");return tr.join(i,`${t}.db`)}initFusionSchema(){this.fusionDb.exec(`
724
659
  CREATE TABLE IF NOT EXISTS fused_repos (
725
660
  alias TEXT PRIMARY KEY,
726
661
  repo_path TEXT NOT NULL UNIQUE,
@@ -754,64 +689,366 @@ Target Symbol: ${a.name}
754
689
 
755
690
  CREATE INDEX IF NOT EXISTS idx_virtual_edges_source ON virtual_edges(source_repo, source_file_path);
756
691
  CREATE INDEX IF NOT EXISTS idx_virtual_edges_target ON virtual_edges(target_repo, target_file_path);
757
- `),this.fusionDb.prepare("INSERT OR REPLACE INTO fused_metadata (key, value, updated_at) VALUES ('schema_version', ?, unixepoch())").run(Wc.toString())}attachRepo(e){let t=yt.resolve(e);if(this.attachedRepos.has(t))return;if(!Ve(t))throw new Error(`Repository "${t}" is not indexed. Run shadow_recon_onboard({ repoPath: "${t}" }) then shadow_sync_trace({ repoPath: "${t}" }).`);let n=ke(t),s=n.name;this.validateSchemaCompatibility(n,t);let r=this.getSchemaVersion(n),o=this.generateAlias(t),c=3,a=100;for(let l=1;l<=c;l++)try{this.fusionDb.exec(`ATTACH DATABASE '${s}' AS ${o}`);let p={alias:o,repoPath:t,dbPath:s,schemaVersion:r,attached:!0};this.attachedRepos.set(t,p),this.fusionDb.prepare(`INSERT OR REPLACE INTO fused_repos (alias, repo_path, db_path, schema_version, attached_at, last_validated_at)
758
- VALUES (?, ?, ?, ?, unixepoch(), unixepoch())`).run(o,t,s,r);return}catch(p){let d=p instanceof Error?p.message.toLowerCase():String(p).toLowerCase();if((d.includes("locked")||d.includes("busy"))&&l<c){this.sleep(a*l);continue}throw p}}checkHealth(){let e=[];for(let t of this.attachedRepos.values())try{this.fusionDb.prepare(`SELECT 1 FROM ${t.alias}.files LIMIT 1`).get(),e.push({alias:t.alias,repoPath:t.repoPath,accessible:!0})}catch(n){e.push({alias:t.alias,repoPath:t.repoPath,accessible:!1,error:n instanceof Error?n.message:String(n)})}return{healthy:e.every(t=>t.accessible),repos:e}}detachRepo(e){let t=yt.resolve(e),n=this.attachedRepos.get(t);n&&(this.fusionDb.exec(`DETACH DATABASE ${n.alias}`),this.attachedRepos.delete(t),this.fusionDb.prepare("DELETE FROM fused_repos WHERE repo_path = ?").run(t))}refreshRepo(e){this.detachRepo(e),this.attachRepo(e)}refreshAll(){let e=Array.from(this.attachedRepos.keys());for(let t of e)this.refreshRepo(t)}validateSchemas(){let e=Array.from(this.attachedRepos.values()).map(t=>{let n=ke(t.repoPath),s=uo.filter(o=>!this.checkTableExists(n,o)),r=this.getSchemaVersion(n);return{alias:t.alias,repoPath:t.repoPath,schemaVersion:r,compatible:r>=Dn&&s.length===0,missingTables:s}});return{valid:e.every(t=>t.compatible),minVersion:Dn,repos:e}}getAttachedRepos(){return Array.from(this.attachedRepos.values())}prepare(e){return this.fusionDb.prepare(e)}exec(e){this.fusionDb.exec(e)}close(){for(let e of this.attachedRepos.values())try{this.fusionDb.exec(`DETACH DATABASE ${e.alias}`)}catch{}this.attachedRepos.clear(),this.fusionDb.open&&this.fusionDb.close()}generateAlias(e){let t=yt.basename(e).replace(/[^a-zA-Z0-9]/g,"_").toLowerCase(),n=Fc.createHash("sha256").update(e).digest("hex").substring(0,6);return`repo_${t}_${n}`}getSchemaVersion(e){try{return e.prepare("SELECT MAX(version) as version FROM schema_migrations").get()?.version||0}catch{return 0}}validateSchemaCompatibility(e,t){let n=this.getSchemaVersion(e);if(n<Dn)throw new Error(`Schema version mismatch for ${t}. Expected >= ${Dn}, got ${n}.`);let s=uo.filter(r=>!this.checkTableExists(e,r));if(s.length>0)throw new Error(`Missing tables in ${t}: ${s.join(", ")}`)}checkTableExists(e,t){try{return!!e.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name=?").get(t)}catch{return!1}}sleep(e){let t=Date.now()+e;for(;Date.now()<t;);}get nameValue(){return this.name}get dbPath(){return this.fusionDbPath}};P();var ze=_.child({module:"edge-scanner"});function $s(i){let e=i.split("?")[0].split("#")[0];return e.length>1&&e.endsWith("/")&&(e=e.slice(0,-1)),e}function jc(i){if(!i)return null;try{let e=JSON.parse(i);return e.path||e.name||null}catch{return null}}function Uc(i,e){let t=$s(i),n=$s(e);if(t===n)return!0;let s=n.replace(/:[^/]+/g,"[^/]+").replace(/\{[^}]+\}/g,"[^/]+").replace(/\$[^/]+/g,"[^/]+");return new RegExp(`^${s}$`).test(t)}function Bc(i){ze.info("Starting HTTP gap detection scan");let e=i.getAttachedRepos();if(e.length<2)return ze.warn("Need at least 2 repos for cross-repo dependency detection"),0;let t=[];for(let r of e)try{let o=`
692
+ `),this.fusionDb.prepare("INSERT OR REPLACE INTO fused_metadata (key, value, updated_at) VALUES ('schema_version', ?, unixepoch())").run($S.toString())}attachRepo(e){let r=tr.resolve(e);if(this.attachedRepos.has(r))return;if(!De(r))throw new Error(`Repository "${r}" is not indexed. Run shadow_recon_onboard({ repoPath: "${r}" }) then shadow_sync_trace({ repoPath: "${r}" }).`);let i=je(r),t=i.name;this.validateSchemaCompatibility(i,r);let o=this.getSchemaVersion(i),s=this.generateAlias(r),a=3,c=100;for(let l=1;l<=a;l++)try{this.fusionDb.exec(`ATTACH DATABASE '${t}' AS ${s}`);let u={alias:s,repoPath:r,dbPath:t,schemaVersion:o,attached:!0};this.attachedRepos.set(r,u),this.fusionDb.prepare(`INSERT OR REPLACE INTO fused_repos (alias, repo_path, db_path, schema_version, attached_at, last_validated_at)
693
+ VALUES (?, ?, ?, ?, unixepoch(), unixepoch())`).run(s,r,t,o);return}catch(u){let d=u instanceof Error?u.message.toLowerCase():String(u).toLowerCase();if((d.includes("locked")||d.includes("busy"))&&l<a){this.sleep(c*l);continue}throw u}}checkHealth(){let e=[];for(let r of this.attachedRepos.values())try{this.fusionDb.prepare(`SELECT 1 FROM ${r.alias}.files LIMIT 1`).get(),e.push({alias:r.alias,repoPath:r.repoPath,accessible:!0})}catch(i){e.push({alias:r.alias,repoPath:r.repoPath,accessible:!1,error:i instanceof Error?i.message:String(i)})}return{healthy:e.every(r=>r.accessible),repos:e}}detachRepo(e){let r=tr.resolve(e),i=this.attachedRepos.get(r);i&&(this.fusionDb.exec(`DETACH DATABASE ${i.alias}`),this.attachedRepos.delete(r),this.fusionDb.prepare("DELETE FROM fused_repos WHERE repo_path = ?").run(r))}refreshRepo(e){this.detachRepo(e),this.attachRepo(e)}refreshAll(){let e=Array.from(this.attachedRepos.keys());for(let r of e)this.refreshRepo(r)}validateSchemas(){let e=Array.from(this.attachedRepos.values()).map(r=>{let i=je(r.repoPath),t=Eg.filter(s=>!this.checkTableExists(i,s)),o=this.getSchemaVersion(i);return{alias:r.alias,repoPath:r.repoPath,schemaVersion:o,compatible:o>=Mo&&t.length===0,missingTables:t}});return{valid:e.every(r=>r.compatible),minVersion:Mo,repos:e}}getAttachedRepos(){return Array.from(this.attachedRepos.values())}prepare(e){return this.fusionDb.prepare(e)}exec(e){this.fusionDb.exec(e)}close(){for(let e of this.attachedRepos.values())try{this.fusionDb.exec(`DETACH DATABASE ${e.alias}`)}catch{}this.attachedRepos.clear(),this.fusionDb.open&&this.fusionDb.close()}generateAlias(e){let r=tr.basename(e).replace(/[^a-zA-Z0-9]/g,"_").toLowerCase(),i=xS.createHash("sha256").update(e).digest("hex").substring(0,6);return`repo_${r}_${i}`}getSchemaVersion(e){try{return e.prepare("SELECT MAX(version) as version FROM schema_migrations").get()?.version||0}catch{return 0}}validateSchemaCompatibility(e,r){let i=this.getSchemaVersion(e);if(i<Mo)throw new Error(`Schema version mismatch for ${r}. Expected >= ${Mo}, got ${i}.`);let t=Eg.filter(o=>!this.checkTableExists(e,o));if(t.length>0)throw new Error(`Missing tables in ${r}: ${t.join(", ")}`)}checkTableExists(e,r){try{return!!e.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name=?").get(r)}catch{return!1}}sleep(e){let r=Date.now()+e;for(;Date.now()<r;);}get nameValue(){return this.name}get dbPath(){return this.fusionDbPath}};G();var Xt=x.child({module:"edge-scanner"});function jc(n){let e=n.split("?")[0].split("#")[0];return e.length>1&&e.endsWith("/")&&(e=e.slice(0,-1)),e}function wS(n){if(!n)return null;try{let e=JSON.parse(n);return e.path||e.name||null}catch{return null}}function kS(n,e){let r=jc(n),i=jc(e);if(r===i)return!0;let t=i.replace(/:[^/]+/g,"[^/]+").replace(/\{[^}]+\}/g,"[^/]+").replace(/\$[^/]+/g,"[^/]+");return new RegExp(`^${t}$`).test(r)}function ES(n){Xt.info("Starting HTTP gap detection scan");let e=n.getAttachedRepos();if(e.length<2)return Xt.warn("Need at least 2 repos for cross-repo dependency detection"),0;let r=[];for(let o of e)try{let s=`
759
694
  SELECT id, name, file_path, capabilities
760
- FROM ${r.alias}.exports
695
+ FROM ${o.alias}.exports
761
696
  WHERE kind = 'HTTP Route'
762
- `,c=i.executeRawQuery(o);for(let a of c){let l=jc(a.capabilities)||a.name;l&&l.startsWith("/")&&t.push({repo:r.alias,repoPath:r.repoPath,filePath:a.file_path,symbolId:a.id,routePath:l})}}catch(o){ze.warn({repo:r.alias,error:o},"Failed to query backend routes")}ze.debug({count:t.length},"Found backend routes");let n=[];for(let r of e)try{let o=`
697
+ `,a=n.executeRawQuery(s);for(let c of a){let l=wS(c.capabilities)||c.name;l&&l.startsWith("/")&&r.push({repo:o.alias,repoPath:o.repoPath,filePath:c.file_path,symbolId:c.id,routePath:l})}}catch(s){Xt.warn({repo:o.alias,error:s},"Failed to query backend routes")}Xt.debug({count:r.length},"Found backend routes");let i=[];for(let o of e)try{let s=`
763
698
  SELECT file_path, name
764
- FROM ${r.alias}.event_synapses
699
+ FROM ${o.alias}.event_synapses
765
700
  WHERE type = 'api_route' AND direction = 'produce'
766
- `,c=i.executeRawQuery(o);for(let a of c){let l=$s(a.name);l&&l.startsWith("/")&&n.push({repo:r.alias,repoPath:r.repoPath,filePath:a.file_path,routePath:l})}}catch(o){ze.warn({repo:r.alias,error:o},"Failed to query frontend API calls")}ze.debug({count:n.length},"Found frontend API calls");let s=0;for(let r of n)for(let o of t)if(r.repoPath!==o.repoPath&&Uc(r.routePath,o.routePath))try{i.addVirtualEdge({sourceRepo:r.repoPath,sourceFilePath:r.filePath,targetRepo:o.repoPath,targetFilePath:o.filePath,targetSymbolId:o.symbolId,relationship:"api_call",metadata:{frontendPath:r.routePath,backendPath:o.routePath,method:o.method},confidence:1}),s++}catch(c){ze.debug({source:r.filePath,target:o.filePath,error:c},"Skipped duplicate edge")}return ze.info({edgesCreated:s,backendRoutes:t.length,frontendCalls:n.length},"HTTP gap detection scan completed"),s}function mo(i){let e=Bc(i);return{httpGaps:e,totalEdges:e}}P();var zc=_.child({module:"fusion-index-service"}),Fn=class{constructor(e){this.connection=e}executeFederatedQuery(e,...t){return this.connection.prepare(e).all(...t).map(r=>{let{_repo_alias:o,_repo_path:c,...a}=r;return{repo:o,repoPath:c,data:a}})}executeRawQuery(e,...t){return this.connection.prepare(e).all(...t)}buildAdvancedQuery(e){let t=this.connection.getAttachedRepos();if(t.length===0)throw new Error("No repositories attached");let{table:n,tableAlias:s,columns:r,joins:o,where:c,groupBy:a,having:l,orderBy:p,limit:d,offset:u}=e,m=s||n.charAt(0),f=r.join(", "),b=t.map(y=>{let g=`${y.alias}.${n} ${m}`,S="";o&&o.length>0&&(S=o.map(v=>{let k=v.alias||v.table.charAt(0);return`${v.type} JOIN ${y.alias}.${v.table} ${k} ON ${v.on}`}).join(`
767
- `));let R=c?`WHERE ${c}`:"",w=a&&a.length>0?`GROUP BY ${a.join(", ")}`:"",T=l?`HAVING ${l}`:"";return`SELECT '${y.alias}' as _repo_alias, '${y.repoPath}' as _repo_path, ${f} FROM ${g} ${S} ${R} ${w} ${T}`.trim()}).join(`
701
+ `,a=n.executeRawQuery(s);for(let c of a){let l=jc(c.name);l&&l.startsWith("/")&&i.push({repo:o.alias,repoPath:o.repoPath,filePath:c.file_path,routePath:l})}}catch(s){Xt.warn({repo:o.alias,error:s},"Failed to query frontend API calls")}Xt.debug({count:i.length},"Found frontend API calls");let t=0;for(let o of i)for(let s of r)if(o.repoPath!==s.repoPath&&kS(o.routePath,s.routePath))try{n.addVirtualEdge({sourceRepo:o.repoPath,sourceFilePath:o.filePath,targetRepo:s.repoPath,targetFilePath:s.filePath,targetSymbolId:s.symbolId,relationship:"api_call",metadata:{frontendPath:o.routePath,backendPath:s.routePath,method:s.method},confidence:1}),t++}catch(a){Xt.debug({source:o.filePath,target:s.filePath,error:a},"Skipped duplicate edge")}return Xt.info({edgesCreated:t,backendRoutes:r.length,frontendCalls:i.length},"HTTP gap detection scan completed"),t}function Ig(n){let e=ES(n);return{httpGaps:e,totalEdges:e}}G();var IS=x.child({module:"fusion-index-service"}),Uo=class{constructor(e){this.connection=e}executeFederatedQuery(e,...r){return this.connection.prepare(e).all(...r).map(o=>{let{_repo_alias:s,_repo_path:a,...c}=o;return{repo:s,repoPath:a,data:c}})}executeRawQuery(e,...r){return this.connection.prepare(e).all(...r)}buildAdvancedQuery(e){let r=this.connection.getAttachedRepos();if(r.length===0)throw new Error("No repositories attached");let{table:i,tableAlias:t,columns:o,joins:s,where:a,groupBy:c,having:l,orderBy:u,limit:d,offset:p}=e,m=t||i.charAt(0),f=o.join(", "),_=r.map(v=>{let y=`${v.alias}.${i} ${m}`,k="";s&&s.length>0&&(k=s.map(P=>{let R=P.alias||P.table.charAt(0);return`${P.type} JOIN ${v.alias}.${P.table} ${R} ON ${P.on}`}).join(`
702
+ `));let $=a?`WHERE ${a}`:"",w=c&&c.length>0?`GROUP BY ${c.join(", ")}`:"",I=l?`HAVING ${l}`:"";return`SELECT '${v.alias}' as _repo_alias, '${v.repoPath}' as _repo_path, ${f} FROM ${y} ${k} ${$} ${w} ${I}`.trim()}).join(`
768
703
  UNION ALL
769
- `);return p&&(b=`SELECT * FROM (${b}) AS federated_results ORDER BY ${p}`),d!==void 0&&(b+=` LIMIT ${d}`),u!==void 0&&(b+=` OFFSET ${u}`),b}buildFtsQuery(e,t,n,s,r=50){let o=this.connection.getAttachedRepos();if(o.length===0)throw new Error("No repositories attached");let c=n.replace(/"/g,'""'),a=s.map(p=>`c.${p}`).join(", ");return`${o.map(p=>`
770
- SELECT '${p.alias}' as _repo_alias, '${p.repoPath}' as _repo_path, ${a}, bm25(${p.alias}.${e}) as _fts_rank
771
- FROM ${p.alias}.${e} fts
772
- JOIN ${p.alias}.${t} c ON fts.rowid = c.id
773
- WHERE ${p.alias}.${e} MATCH '"${c}"'`).join(`
704
+ `);return u&&(_=`SELECT * FROM (${_}) AS federated_results ORDER BY ${u}`),d!==void 0&&(_+=` LIMIT ${d}`),p!==void 0&&(_+=` OFFSET ${p}`),_}buildFtsQuery(e,r,i,t,o=50){let s=this.connection.getAttachedRepos();if(s.length===0)throw new Error("No repositories attached");let a=i.replace(/"/g,'""'),c=t.map(u=>`c.${u}`).join(", ");return`${s.map(u=>`
705
+ SELECT '${u.alias}' as _repo_alias, '${u.repoPath}' as _repo_path, ${c}, bm25(${u.alias}.${e}) as _fts_rank
706
+ FROM ${u.alias}.${e} fts
707
+ JOIN ${u.alias}.${r} c ON fts.rowid = c.id
708
+ WHERE ${u.alias}.${e} MATCH '"${a}"'`).join(`
774
709
  UNION ALL
775
- `)} ORDER BY _fts_rank LIMIT ${r}`}buildCrossRepoImportsQuery(){let e=this.connection.getAttachedRepos();if(e.length<2)throw new Error("Cross-repo analysis requires at least 2 attached repositories");let t=[];for(let n of e)for(let s of e)n.alias!==s.alias&&t.push(`
710
+ `)} ORDER BY _fts_rank LIMIT ${o}`}buildCrossRepoImportsQuery(){let e=this.connection.getAttachedRepos();if(e.length<2)throw new Error("Cross-repo analysis requires at least 2 attached repositories");let r=[];for(let i of e)for(let t of e)i.alias!==t.alias&&r.push(`
776
711
  SELECT
777
- '${n.alias}' as source_repo, '${n.repoPath}' as source_repo_path,
712
+ '${i.alias}' as source_repo, '${i.repoPath}' as source_repo_path,
778
713
  i.file_path as source_file, i.module_specifier, i.imported_symbols,
779
- '${s.alias}' as target_repo, '${s.repoPath}' as target_repo_path,
714
+ '${t.alias}' as target_repo, '${t.repoPath}' as target_repo_path,
780
715
  f.path as target_file
781
- FROM ${n.alias}.imports i
782
- JOIN ${s.alias}.files f ON i.resolved_path = f.path
783
- WHERE i.resolved_path IS NOT NULL`);return t.join(`
716
+ FROM ${i.alias}.imports i
717
+ JOIN ${t.alias}.files f ON i.resolved_path = f.path
718
+ WHERE i.resolved_path IS NOT NULL`);return r.join(`
784
719
  UNION ALL
785
- `)}buildUnionQuery(e,t,n){let s=this.connection.getAttachedRepos();if(s.length===0)throw new Error("No repositories attached");let r=t.join(", "),o=n?` WHERE ${n}`:"";return s.map(c=>`SELECT '${c.alias}' as _repo_alias, '${c.repoPath}' as _repo_path, ${r} FROM ${c.alias}.${e}${o}`).join(`
720
+ `)}buildUnionQuery(e,r,i){let t=this.connection.getAttachedRepos();if(t.length===0)throw new Error("No repositories attached");let o=r.join(", "),s=i?` WHERE ${i}`:"";return t.map(a=>`SELECT '${a.alias}' as _repo_alias, '${a.repoPath}' as _repo_path, ${o} FROM ${a.alias}.${e}${s}`).join(`
786
721
  UNION ALL
787
- `)}searchExports(e,t=50){let n=this.buildUnionQuery("exports",["id","name","kind","file_path","signature"],"name LIKE ?")+` LIMIT ${t*this.connection.getAttachedRepos().length}`,s=Array(this.connection.getAttachedRepos().length).fill(`%${e}%`);return this.executeFederatedQuery(n,...s)}searchFiles(e,t=50){let n=this.buildUnionQuery("files",["path","classification","content_hash"],"path LIKE ?")+` LIMIT ${t*this.connection.getAttachedRepos().length}`,s=Array(this.connection.getAttachedRepos().length).fill(`%${e}%`);return this.executeFederatedQuery(n,...s)}getVirtualEdges(e,t){let n="SELECT * FROM virtual_edges WHERE 1=1",s=[];return e&&(n+=" AND source_repo = ?",s.push(e)),t&&(n+=" AND target_repo = ?",s.push(t)),this.connection.prepare(n).all(...s)}addVirtualEdge(e){return this.connection.prepare(`
722
+ `)}searchExports(e,r=50){let i=this.buildUnionQuery("exports",["id","name","kind","file_path","signature"],"name LIKE ?")+` LIMIT ${r*this.connection.getAttachedRepos().length}`,t=Array(this.connection.getAttachedRepos().length).fill(`%${e}%`);return this.executeFederatedQuery(i,...t)}searchFiles(e,r=50){let i=this.buildUnionQuery("files",["path","classification","content_hash"],"path LIKE ?")+` LIMIT ${r*this.connection.getAttachedRepos().length}`,t=Array(this.connection.getAttachedRepos().length).fill(`%${e}%`);return this.executeFederatedQuery(i,...t)}getVirtualEdges(e,r){let i="SELECT * FROM virtual_edges WHERE 1=1",t=[];return e&&(i+=" AND source_repo = ?",t.push(e)),r&&(i+=" AND target_repo = ?",t.push(r)),this.connection.prepare(i).all(...t)}addVirtualEdge(e){return this.connection.prepare(`
788
723
  INSERT INTO virtual_edges
789
724
  (source_repo, source_file_path, source_symbol_id, target_repo, target_file_path, target_symbol_id, relationship, metadata, confidence, updated_at)
790
725
  VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, unixepoch())
791
- `).run(e.sourceRepo,e.sourceFilePath,e.sourceSymbolId||null,e.targetRepo,e.targetFilePath,e.targetSymbolId||null,e.relationship,e.metadata?JSON.stringify(e.metadata):null,e.confidence??1).lastInsertRowid}scanEdges(){return zc.info({name:this.connection.nameValue},"Starting edge scan"),mo(this)}getAttachedRepos(){return this.connection.getAttachedRepos()}get name(){return this.connection.nameValue}};var ho=_.child({module:"fused-index"}),Ls=class{connection;service;configName;constructor(e){this.configName=e.name,this.connection=new On(e),this.service=new Fn(this.connection)}attachRepo(e){this.connection.attachRepo(e)}detachRepo(e){this.connection.detachRepo(e)}refreshRepo(e){this.connection.refreshRepo(e)}getAttachedRepos(){return this.connection.getAttachedRepos()}checkHealth(){return this.connection.checkHealth()}close(){this.connection.close(),ho.info({name:this.configName},"Fused index closed")}getStatus(){let e=this.service.executeRawQuery("SELECT COUNT(*) as count FROM virtual_edges");return{name:this.connection.nameValue,path:this.connection.dbPath,attachedRepos:this.connection.getAttachedRepos().length,repos:this.connection.getAttachedRepos(),virtualEdgesCount:e[0]?.count||0}}searchExports(e,t=50){return this.service.searchExports(e,t)}searchFiles(e,t=50){return this.service.searchFiles(e,t)}getVirtualEdges(e,t){return this.service.getVirtualEdges(e,t)}addVirtualEdge(e){return this.service.addVirtualEdge(e)}scanEdges(){return this.service.scanEdges()}buildUnionQuery(e,t,n){return this.service.buildUnionQuery(e,t,n)}executeFederatedQuery(e,...t){return this.service.executeFederatedQuery(e,...t)}executeRawQuery(e,...t){return this.service.executeRawQuery(e,...t)}buildAdvancedQuery(e){return this.service.buildAdvancedQuery(e)}buildFtsQuery(e,t,n,s,r){return this.service.buildFtsQuery(e,t,n,s,r)}buildCrossRepoImportsQuery(){return this.service.buildCrossRepoImportsQuery()}refreshAll(){this.connection.refreshAll()}validateSchemas(){return ho.debug({name:this.configName},"Delegating validateSchemas"),this.connection.validateSchemas()}},ks=new Map;function fo(i){let e=ks.get(i.name);if(e){let n=new Set(e.getAttachedRepos().map(o=>o.repoPath)),s=new Set(i.repoPaths.map(o=>Gc.resolve(o)));if(n.size===s.size&&[...n].every(o=>s.has(o)))return e;e.close(),ks.delete(i.name)}let t=new Ls(i);return ks.set(i.name,t),t}P();var qc=_.child({module:"mcp:tools:workspace:fuse"});async function go(i){let{repoPaths:e,name:t}=i;qc.info({repoCount:e.length,name:t},"Creating fused workspace index");try{let n=fo({repoPaths:e,name:t||`workspace-${Date.now()}`});return{content:[{type:"text",text:JSON.stringify({message:"Fused index created",status:n.getStatus()},null,2)}]}}catch(n){throw new Error(`Failed to fuse: ${n.message}`)}}import Hn from"path";async function yo(i){let[e,...t]=i;if(!e||!["missions","link","fuse"].includes(e)){console.log(""),console.log(` ${E.bold("Usage: ")} liquid-shadow workspace <missions|link> [options]`),console.log(""),console.log(` ${E.bold("Commands: ")}`),console.log(` ${E.cyan("missions")} <paths...> Get unified view of missions across repositories`),console.log(` ${E.cyan("link")} <args...> Link missions across repositories`),console.log(` ${E.cyan("fuse")} <paths...> Create fused index for cross-repo search (use --name for custom name)`),console.log(""),console.log(` ${E.bold("Examples: ")}`),console.log(" liquid-shadow workspace missions /frontend /backend"),console.log(" liquid-shadow workspace link /frontend 5 /backend 12"),console.log(" liquid-shadow workspace fuse /frontend /backend --name my-app"),console.log("");return}await B(async()=>{switch(e){case"missions":{if(t.length===0){console.error(` ${E.red("\u2716")} Please provide at least one repository path`);return}let n=t.map(r=>Hn.resolve(r)),s=await co({repoPaths:n});if(console.log(""),console.log(` ${E.bold("Workspace Missions")}`),console.log(""),s.content&&s.content[0]){let r=JSON.parse(s.content[0].text);r.missions&&r.missions.length>0?r.missions.forEach(o=>{console.log(` ${E.cyan("\u2022")} ${E.bold(o.name)} (ID: ${o.id})`),console.log(` ${E.dim("Repo: ")} ${o.repo_path}`),console.log(` ${E.dim("Status: ")} ${o.status}`),console.log(` ${E.dim("Branch: ")} ${o.git_branch||"N/A"}`),o.cross_repo_links&&o.cross_repo_links.length>0&&console.log(` ${E.dim("Links: ")} ${o.cross_repo_links.length} cross-repo link(s)`),console.log("")}):(console.log(` ${E.yellow("\u26A0")} No missions found`),console.log(""))}break}case"link":{if(t.length<4){console.error(""),console.error(` ${E.red("\u2716")} Usage: workspace link <parent-repo> <parent-id> <child-repo> <child-id> [relationship]`),console.error("");return}let[n,s,r,o,c]=t;await lo({parentRepoPath:Hn.resolve(n),parentMissionId:parseInt(s,10),childRepoPath:Hn.resolve(r),childMissionId:parseInt(o,10),relationship:c}),console.log(""),console.log(` ${E.green("\u2714")} ${E.bold("Missions linked successfully")}`),console.log(` ${E.dim("Parent: ")} ${n} (Mission ${s})`),console.log(` ${E.dim("Child: ")} ${r} (Mission ${o})`),c&&console.log(` ${E.dim("Relationship: ")} ${c}`),console.log("");break}case"fuse":{if(t.length===0){console.error(` ${E.red("\u2716")} Please provide at least one repository path`);return}let n,s=[];for(let o=0;o<t.length;o++)t[o]==="--name"&&o+1<t.length?(n=t[o+1],o++):s.push(Hn.resolve(t[o]));let r=await go({repoPaths:s,name:n});if(console.log(""),console.log(` ${E.green("\u2714")} ${E.bold("Fused Index Created")}`),r.content&&r.content[0]){let o=JSON.parse(r.content[0].text);console.log(` ${E.dim("Name: ")} ${o.fused_index.name}`),console.log(` ${E.dim("Path: ")} ${o.fused_index.path}`),console.log(` ${E.dim("Repos: ")} ${o.fused_index.attachedRepos}`),console.log(""),console.log(` ${E.bold("Instructions:")}`),console.log(` ${o.instructions}`)}console.log("");break}}})}P();P();var Jc=_.child({module:"strategy-normalizer"}),Ne=class{static normalize(e){if(!e)return{steps:[]};let t;if(typeof e=="string")try{t=JSON.parse(e)}catch(s){return Jc.warn({strategyInput:e,err:s},"Failed to parse strategy JSON"),{steps:[]}}else t=e;return{steps:this.normalizeSteps(t)}}static normalizeSteps(e){return Array.isArray(e)?e.map((t,n)=>typeof t=="string"?{id:`step-${n}`,description:t,status:"pending"}:typeof t=="object"&&t!==null?{id:t.id||`step-${n}`,description:t.description||t.content||t.name||`Step ${n+1}`,status:t.status||"pending",dependencies:t.dependencies||t.deps,verification:t.verification,...t}:{id:`step-${n}`,description:String(t),status:"pending"}):e.steps&&Array.isArray(e.steps)?this.normalizeSteps(e.steps):typeof e=="object"?Object.entries(e).map(([t,n],s)=>typeof n=="string"?{id:t,description:n,status:"pending"}:typeof n=="object"&&n!==null?{id:t,description:n.description||n.content||n.name||t,status:n.status||"pending",dependencies:n.dependencies||n.deps,verification:n.verification,...n}:{id:t||`step-${s}`,description:String(n),status:"pending"}):[]}static stringify(e){return JSON.stringify(e,null,2)}static validate(e){let t=[];if(!e)return{valid:!0,errors:[]};try{let n=this.normalize(e),s=new Set;for(let r of n.steps)if(s.has(r.id)&&t.push(`Duplicate step ID: ${r.id}`),s.add(r.id),r.dependencies)for(let o of r.dependencies)s.has(o)||t.push(`Step "${r.id}" depends on non-existent step "${o}"`);return{valid:t.length===0,errors:t}}catch(n){return t.push(`Strategy validation failed: ${n instanceof Error?n.message:String(n)}`),{valid:!1,errors:t}}}};P();import Ns from"fs";import bo from"path";import Yc from"os";var Vc=[{id:"step-0",description:"Analyze impact: identify dependents and call sites",status:"pending"},{id:"step-1",description:"Implement refactor and update call sites",status:"pending"},{id:"step-2",description:"Run tests and verify behavior; update docs if needed",status:"pending"}],Qc=[{id:"step-0",description:"Capture requirements and acceptance criteria",status:"pending"},{id:"step-1",description:"Implement feature with tests",status:"pending"},{id:"step-2",description:"Integrate and verify end-to-end",status:"pending"}],Kc=[{id:"step-0",description:"Reproduce the bug and document steps",status:"pending"},{id:"step-1",description:"Diagnose root cause and plan fix",status:"pending"},{id:"step-2",description:"Apply fix and add/update regression test",status:"pending"},{id:"step-3",description:"Verify fix and run full test suite",status:"pending"}],Eo=[{id:"refactoring",name:"Refactoring",description:"Impact analysis \u2192 implementation \u2192 verification",defaultGoal:"Refactor {{target}} safely with full impact analysis and verification.",steps:Vc},{id:"feature",name:"Feature",description:"Requirements \u2192 implementation \u2192 testing",defaultGoal:"Implement {{target}} with clear requirements and end-to-end verification.",steps:Qc},{id:"bug-fix",name:"Bug fix",description:"Reproduction \u2192 diagnosis \u2192 fix \u2192 regression test",defaultGoal:"Fix {{target}}: reproduce, diagnose, fix, and add regression test.",steps:Kc}],As=new Map(Eo.map(i=>[i.id,i])),Wn=!1;function Xc(){if(Wn)return;let i=bo.join(Yc.homedir(),".shadow","templates");if(!Ns.existsSync(i)){_.debug({templatesDir:i},"Custom templates directory does not exist"),Wn=!0;return}try{let e=Ns.readdirSync(i).filter(t=>t.endsWith(".json"));for(let t of e)try{let n=bo.join(i,t),s=Ns.readFileSync(n,"utf8"),r=JSON.parse(s);if(!r.id||!r.name||!r.defaultGoal||!r.steps){_.warn({file:t,template:r},"Invalid custom template structure - skipping");continue}if(!Array.isArray(r.steps)||r.steps.length===0){_.warn({file:t},"Template has no steps - skipping");continue}if(Eo.some(o=>o.id===r.id)){_.warn({file:t,templateId:r.id},"Custom template ID conflicts with built-in - skipping");continue}As.set(r.id,r),_.info({file:t,templateId:r.id},"Loaded custom template")}catch(n){_.warn({file:t,error:n},"Failed to load custom template")}Wn=!0}catch(e){_.warn({error:e,templatesDir:i},"Failed to read custom templates directory"),Wn=!0}}function Zc(i){return Xc(),As.get(i)}function el(i,e){let t=i;for(let[n,s]of Object.entries(e))t=t.replace(new RegExp(`\\{\\{${n}\\}\\}`,"g"),s);return t}function So(i,e,t={}){let n=Zc(i);if(!n)throw new Error(`Unknown template: ${i}. Use one of: ${Array.from(As.keys()).join(", ")}`);let s=t.target||"scope",r=e||(i==="refactoring"?`Refactor ${s}`:i==="feature"?`Feature: ${s}`:`Fix: ${s}`),o=el(n.defaultGoal,{...t,target:s}),c=Ne.normalize({steps:n.steps}),a=Ne.stringify(c);return{name:r,goal:o,strategy:a}}U();var jn=_.child({module:"mcp:tools:ops:plan"});async function _o(i){let{repoPath:e,name:t,goal:n,strategy:s,missionId:r,parentId:o,outcomeContract:c,templateId:a,templateVars:l}=i,{missions:p}=C.getInstance(e),d=re(e),u=fe(e);jn.info({repoPath:e,name:t,missionId:r,templateId:a},"Planning mission");try{let m=t,f=n,h=s;if(a){let S=So(a,t,l||{});m=m??S.name,f=f??S.goal,h=h??S.strategy}if(!m||!f)throw new Error("Mission requires name and goal (or templateId with optional templateVars).");let b=null;if(h){let S=Ne.normalize(h);b=Ne.stringify(S);let R=Ne.validate(b);R.valid||jn.warn({errors:R.errors,strategy:h},"Strategy validation warnings detected")}let y,g;r?(p.update(r,{name:m,goal:f,strategy_graph:b,commit_sha:u,parent_id:o!==void 0?o:void 0,outcome_contract:c}),y=r,g=`Mission "${m}" updated.`):(y=p.create({name:m,goal:f,strategy_graph:b,status:"planned",git_branch:d,commit_sha:u,parent_id:o||null,verification_context:null,outcome_contract:c||null}),g=`Mission "${m}" planned.`);try{await new ve(e).syncMissionToGitNotes(Number(y))}catch(S){jn.warn({syncError:S,missionId:y},"Git Notes sync deferred")}return{content:[{type:"text",text:JSON.stringify({missionId:y,status:"planned",message:g,strategy_saved:!!h,contract_saved:!!c,from_template:a??void 0,commit:u},null,2)}]}}catch(m){throw jn.error({error:m,repoPath:e},"Failed to plan mission"),new Error(`Failed to plan mission: ${m instanceof Error?m.message:String(m)}`)}}P();U();U();P();var tl=_.child({module:"collision-service"}),Un=class{repoPath;constructor(e){this.repoPath=e}async analyzePotentialCollisions(){let e=re(this.repoPath);if(!e)return[];let{missions:t,intentLogs:n}=C.getInstance(this.repoPath),s=t.findActive().filter(c=>c.git_branch&&c.git_branch!==e),r=[],o=new Set;for(let c of s){let a=c.git_branch;if(o.has(a))continue;o.add(a),tl.info({branch:a,currentBranch:e},"Checking predictive collisions"),Qi(this.repoPath,e,a)&&r.push({branch:a,type:"file",description:`Background merge-tree detected a file-level conflict between '${e}' and '${a}'.`});let p=t.findActive(e),d=new Set;for(let f of p)t.getWorkingSet(f.id).forEach(h=>d.add(h.file_path));let m=t.getWorkingSet(c.id).filter(f=>d.has(f.file_path));m.length>0&&r.push({branch:a,type:"intent",description:`Logical conflict: Mission '${c.name}' on '${a}' is modifying files you are currently working on.`,conflictingFiles:m.map(f=>f.file_path)})}return r}};var Ut=_.child({module:"mcp:tools:ops:briefing"});async function xo(i){let{repoPath:e,missionId:t,scope:n="mission",activeMissionsLimit:s,recentActivityLimit:r=10,compact:o=!1}=i,{missions:c,intentLogs:a}=C.getInstance(e),l=fe(e),p=re(e);Ut.info({repoPath:e,missionId:t,scope:n},"Generating briefing");try{if(n==="project"){let h=c.findActive(p||void 0),b=h.length;s&&h.length>s&&(h=h.slice(0,s));let y=c.findParentOnlyIds(h),g=new Set(y),S=h.filter(N=>!g.has(N.id)),R={};for(let N of h)N.parent_id!=null&&(R[N.parent_id]||(R[N.parent_id]=[]),R[N.parent_id].push(N));let w={},T=new Map(h.map(N=>[N.id,N])),v=Object.keys(R).map(Number),k=v.filter(N=>!T.has(N)),F=k.length>0?c.findByIds(k):[],x=new Map(T);for(let N of F)x.set(N.id,N);for(let N of v){let L=x.get(N);L&&(w[N]={id:L.id,name:L.name??"",goal:L.goal??"",status:L.status??"unknown"})}let I=o?h.map(N=>({...N,strategy_graph:void 0})):h,M=o?S.map(N=>({...N,strategy_graph:void 0})):S,$=a.findRecentDecisionActivity(r),j={scope:"project",counts:c.getStats(),analytics:c.getAnalytics(),active_missions:I,parent_only_ids:y,missions_by_parent:o?Object.fromEntries(Object.entries(R).map(([N,L])=>[N,L.map(A=>({...A,strategy_graph:void 0}))])):R,parents_summary:Object.keys(w).length?w:void 0,close_parent_when_all_children_done:'When all children of a parent are completed, call shadow_ops_track({ missionId: <parent_id>, status: "completed" }) with no stepId.',next_work_candidates:M,recent_completed:c.findRecentCompleted(),recent_activity:$,meta:{current_branch:p,current_commit:l,activeMissionsTotal:b,activeMissionsShown:h.length,hasMoreMissions:s?b>s:!1}};if(n==="project"){let N=y.map(L=>{let A=h.find(te=>te.id===L),D=R[L]??[];return{parent:A,children:D}});j.missions_grouped_by_parent=N}let H=S.length===0?{tool:"shadow_ops_plan",reason:"No open work; create a mission"}:{tool:"shadow_ops_track",reason:"Pick one from next_work_candidates and run /continue"};return{content:[{type:"text",text:JSON.stringify(j,null,2)}],suggestedNext:H}}let d;if(t?d=c.findById(t):d=c.findActive(p||void 0)[0],!d)return{content:[{type:"text",text:"No active missions found. Ready for new assignment."}]};let u="No external shadow changes detected.";try{new mt(e).analyzeGhostChanges(d.commit_sha||void 0),u="Shadow Trace completed: Checked for external modifications."}catch(h){Ut.warn({error:h},"Ghost analysis failed")}let m={repaired:0,failed:0};try{m=new Te(e).detectAndRepairShifts()}catch(h){Ut.warn({error:h},"Symbol shift repair failed")}let f={mission:{id:d.id,name:d.name,goal:d.goal,status:d.status,last_updated:new Date(d.updated_at*1e3).toISOString(),git_branch:d.git_branch,commit_sha:d.commit_sha,outcome_contract:d.outcome_contract},artifacts:c.getArtifacts(d.id),shadow_trace:{ghost_analysis:u,symbols_repaired:m.repaired,symbols_missing:m.failed},context:{current_commit:l,working_set:c.getWorkingSet(d.id).map(h=>h.file_path)},strategy_snapshot:d.strategy_graph?JSON.parse(d.strategy_graph):null,recent_activity:a.findByMission(d.id,15),ancestor_activity:[],predictive_collisions:[]};try{let h=new Un(e);f.predictive_collisions=await h.analyzePotentialCollisions()}catch(h){Ut.warn({error:h},"Predictive collision analysis failed")}if(n==="mission"){let y=new nt(e).getAncestorMissionIds().filter(g=>g!==d?.id);if(y.length>0)for(let g of y){let S=a.findByMission(g,5);f.ancestor_activity.push(...S)}}return{content:[{type:"text",text:JSON.stringify(f,null,2)}]}}catch(d){throw Ut.error({error:d,repoPath:e},"Failed to generate briefing"),new Error(`Failed to generate briefing: ${d instanceof Error?d.message:String(d)}`)}}P();U();U();P();P();var nl=_.child({module:"reasoning-engine"}),Bn=class{analyze(e){nl.debug({logCount:e.length},"Performing reasoning pass over intent logs");let t={context:[],decisions:[],consequences:[],recommendations:[],unclassified:[]};for(let n of e){let s=n.content.toLowerCase(),r=this.matchesContext(s,n.type),o=this.matchesDecision(s,n.type),c=this.matchesConsequence(s,n.type),a=this.matchesRecommendation(s,n.type);r?t.context.push(n.content):o?t.decisions.push(n.content):a?t.recommendations.push(n.content):c?t.consequences.push(n.content):n.type==="decision"?t.decisions.push(n.content):n.type==="discovery"||n.type==="fix"?t.consequences.push(n.content):t.unclassified.push(n.content)}return t}matchesContext(e,t){return["because","since","given","due to","context: ","problem: ","situation:"].some(s=>e.includes(s))||t==="blocker"}matchesDecision(e,t){return["decided","chose","implemented","integrated","using","selected","strategy:"].some(s=>e.includes(s))||t==="decision"}matchesConsequence(e,t){return["results in","enables","allows","impact: ","consequence: ","next steps: ","meaning"].some(s=>e.includes(s))||t==="fix"}matchesRecommendation(e,t){return["should","recommend","suggest","next work","future","consider","strategy advice"].some(s=>e.includes(s))}};var zn=_.child({module:"briefing-engine"}),Ge=class{intentLogs;missions;reasoningEngine;persistencePivot;constructor(e){let{intentLogs:t,missions:n}=C.getInstance(e);this.intentLogs=t,this.missions=n,this.reasoningEngine=new Bn,this.persistencePivot=new ve(e)}async distillMission(e,t=!0){zn.info({missionId:e},"Synthesizing mission intelligence into Tactical Briefing...");let n=this.gatherConsolidatedLogs(e);if(n.length===0)return{missionId:e,adr:"No intent logs found for this mission.",metrics:{totalLogs:0,symbolCount:0}};let s=this.reasoningEngine.analyze(n),r=new Set(n.map(c=>c.symbol_name).filter(Boolean)),o=`# Architectural Decision Record: Mission #${e}
792
-
793
- `;if(o+=`## Summary of Intent
794
- `,o+=`Collected ${n.length} intent events across ${r.size} symbols.
795
-
796
- `,s.context.length>0&&(o+=`### Context
797
- `,s.context.forEach(c=>{o+=`- ${c}
798
- `}),o+=`
799
- `),s.decisions.length>0&&(o+=`### Key Decisions
800
- `,s.decisions.forEach(c=>{o+=`- ${c}
801
- `}),o+=`
802
- `),s.consequences.length>0&&(o+=`### Consequences & Evolutions
803
- `,s.consequences.forEach(c=>{o+=`- ${c}
804
- `}),o+=`
805
- `),s.recommendations.length>0&&(o+=`### Strategic Recommendations
806
- `,s.recommendations.forEach(c=>{o+=`- ${c}
807
- `}),o+=`
808
- `),s.unclassified.length>0&&(o+=`### Additional Notes
809
- `,s.unclassified.forEach(c=>{o+=`- ${c}
810
- `}),o+=`
811
- `),o+=`
726
+ `).run(e.sourceRepo,e.sourceFilePath,e.sourceSymbolId||null,e.targetRepo,e.targetFilePath,e.targetSymbolId||null,e.relationship,e.metadata?JSON.stringify(e.metadata):null,e.confidence??1).lastInsertRowid}scanEdges(){return IS.info({name:this.connection.nameValue},"Starting edge scan"),Ig(this)}getAttachedRepos(){return this.connection.getAttachedRepos()}get name(){return this.connection.nameValue}};var Tg=x.child({module:"fused-index"}),Zo=class{connection;service;configName;constructor(e){this.configName=e.name,this.connection=new jo(e),this.service=new Uo(this.connection)}attachRepo(e){this.connection.attachRepo(e)}detachRepo(e){this.connection.detachRepo(e)}refreshRepo(e){this.connection.refreshRepo(e)}getAttachedRepos(){return this.connection.getAttachedRepos()}checkHealth(){return this.connection.checkHealth()}close(){this.connection.close(),Tg.info({name:this.configName},"Fused index closed")}getStatus(){let e=this.service.executeRawQuery("SELECT COUNT(*) as count FROM virtual_edges");return{name:this.connection.nameValue,path:this.connection.dbPath,attachedRepos:this.connection.getAttachedRepos().length,repos:this.connection.getAttachedRepos(),virtualEdgesCount:e[0]?.count||0}}searchExports(e,r=50){return this.service.searchExports(e,r)}searchFiles(e,r=50){return this.service.searchFiles(e,r)}getVirtualEdges(e,r){return this.service.getVirtualEdges(e,r)}addVirtualEdge(e){return this.service.addVirtualEdge(e)}scanEdges(){return this.service.scanEdges()}buildUnionQuery(e,r,i){return this.service.buildUnionQuery(e,r,i)}executeFederatedQuery(e,...r){return this.service.executeFederatedQuery(e,...r)}executeRawQuery(e,...r){return this.service.executeRawQuery(e,...r)}buildAdvancedQuery(e){return this.service.buildAdvancedQuery(e)}buildFtsQuery(e,r,i,t,o){return this.service.buildFtsQuery(e,r,i,t,o)}buildCrossRepoImportsQuery(){return this.service.buildCrossRepoImportsQuery()}refreshAll(){this.connection.refreshAll()}validateSchemas(){return Tg.debug({name:this.configName},"Delegating validateSchemas"),this.connection.validateSchemas()}},Fo=new Map;function Uc(n){let e=Fo.get(n.name);if(e){let i=new Set(e.getAttachedRepos().map(s=>s.repoPath)),t=new Set(n.repoPaths.map(s=>TS.resolve(s)));if(i.size===t.size&&[...i].every(s=>t.has(s)))return e;e.close(),Fo.delete(n.name)}let r=new Zo(n);return Fo.set(n.name,r),r}function Fc(){return Array.from(Fo.keys())}import Dt from"path";import Zc from"fs";import PS from"@swc/core";var nr=class{constructor(e){this.repoPath=e}async analyze(e,r={}){let{filePath:i,depth:t=3,limit:o=50,offset:s=0}=r,a=z.getInstance(this.repoPath),c=i?a.exports.findByNameAndFile(e,i):a.exports.findByNameGlobal(e);if(c.length===0)return[];let l=[];for(let u of c){let d=a.imports.findImpactDependents(u.file_path,`%${e}%`,t),p=[],m=new Set;for(let $ of d){let w=Dt.relative(this.repoPath,$.consumer_path);if(m.has(w))continue;let I=`Imports ${$.imported_symbols}`,P=await this.verifySymbolUsage($.consumer_path,u.name);P?I+=" (\u2705 Verified Call)":I+=" (\u26A0\uFE0F Potential Import - Usage not statically detected)",m.add(w),p.push({type:"IMPORT",file:w,depth:$.depth,details:I,verified:P})}let f=a.exports.findRoutesByCapability(e);u.kind==="HTTP Route"&&f.push({name:u.name,file_path:u.file_path,signature:u.signature});for(let $ of f){let I=$.name.split("/").filter(R=>R.length>3&&!R.includes("{")&&!R.includes("$")&&!R.includes("<")).sort((R,F)=>F.length-R.length)[0];if(!I||["admin","api","user","users","update","create","delete","list","index","show","store"].includes(I.toLowerCase()))continue;let P=a.files.findContentByToken(I,10);for(let R of P){let F=Dt.relative(this.repoPath,R);!m.has(F)&&R!==u.file_path&&(m.add(F),p.push({type:"API_USAGE",file:F,depth:2,details:`Likely calls route ${$.name} (matched token '${I}')`,verified:!1}))}}let h=a.files.findContentByToken(e,20);for(let $ of h){let w=Dt.relative(this.repoPath,$);!m.has(w)&&$!==u.file_path&&(m.add(w),p.push({type:"POTENTIAL_USAGE",file:w,depth:2,details:`Contains keyword '${e}' (Dynamic/Implicit usage)`,verified:!0}))}u.kind==="HTTP Route"&&await this.addCrossRepoImpact(p,m,u),p.sort(($,w)=>$.verified&&!w.verified?-1:!$.verified&&w.verified?1:$.depth!==w.depth?$.depth-w.depth:$.file.localeCompare(w.file));let _=p.length,v=p.slice(s,s+o),y=s+o<_,k=this.calculateRiskScore(u,_,p);l.push({symbol:e,definedIn:Dt.relative(this.repoPath,u.file_path),riskScore:k,impact:v,pagination:{total:_,offset:s,limit:o,hasMore:y}})}return l}async verifySymbolUsage(e,r){try{if(!Zc.existsSync(e))return!1;let i=Zc.readFileSync(e,"utf8"),t=Dt.extname(e).toLowerCase(),o=new Set;if(t===".ts"||t===".tsx"||t===".js"||t===".jsx"){let s=new er;try{let a=await PS.parse(i,{syntax:"typescript",tsx:e.endsWith(".tsx"),target:"es2020"});s.visitModule(a),o=s.calls}catch{return i.includes(r)}}else{let s=new Yt;s.visit(i,t),o=s.calls}if(o.has(r))return!0;for(let s of o){if(s===r)return!0;let a=s.split(/(?:\.|->|::)+/),c=a[a.length-1],l=r.split(/(?:\.|->|::)+/),u=l[l.length-1];if(c===u)return!0}return!1}catch{return!1}}async addCrossRepoImpact(e,r,i){try{let t=Fc();for(let o of t)try{let a=(await import("os")).homedir(),c=Dt.join(a,".mcp-liquid-shadow","fused"),l=o.replace(/[^a-zA-Z0-9-_]/g,"_"),u=Dt.join(c,`${l}.db`);if(!Zc.existsSync(u))continue;let d=(await import("better-sqlite3")).default,p=new d(u),m=p.prepare("SELECT source_repo, source_file_path, relationship, metadata FROM virtual_edges WHERE target_repo = ? AND target_file_path = ? AND relationship = 'api_call'").all(this.repoPath,i.file_path);p.close();for(let f of m){let h=Dt.relative(f.source_repo,f.source_file_path),_=`${f.source_repo}:${h}`;r.has(_)||(r.add(_),e.push({type:"CROSS_REPO_API_CALL",file:_,depth:1,details:`Cross-repo API call from ${Dt.basename(f.source_repo)}`,verified:!0}))}}catch{continue}}catch{}}calculateRiskScore(e,r,i){let a=(new le(this.repoPath).getSnapshot().gravity?.hotspots||[]).find(p=>p.filePath===e.file_path&&p.symbol===e.name)?.gravity||0,c=i.filter(p=>p.type==="CROSS_REPO_API_CALL").length,l=a/50+r/15+c*2,u="LOW",d="Peripheral symbol with limited usage.";return l>=8?(u="CRITICAL",d=`Core architectural pillar (Gravity: ${a.toFixed(0)}). Modification will destabilize ${r} dependents.`):l>=4?(u="HIGH",d=`High-gravity symbol with significant blast radius (${r} files).`):l>=1.5&&(u="MEDIUM",d="Standard library symbol with moderate dependency chain."),{score:Math.min(10,Math.round(l*10)/10),level:u,rationale:d}}};X();var Ho=class n{constructor(e){this.intentLogs=e}static RECENCY_HALF_LIFE_HOURS=48;static WEIGHTS={recency:.4,activity:.3,statusBoost:.2,blockerBoost:.1};score(e){if(e.length===0)return[];let r=Math.floor(Date.now()/1e3),i=e.map(c=>c.id),t=this.intentLogs.countByMissions(i),o=this.intentLogs.findMissionsWithBlockers(i),s=Math.max(1,...Object.values(t));return e.map(c=>{let l=this.computeRecency(c.updated_at,r),u=(t[c.id]||0)/s,d=this.computeStatusBoost(c.status),p=o.has(c.id)?1:0,m=n.WEIGHTS,f=l*m.recency+u*m.activity+d*m.statusBoost+p*m.blockerBoost;return{mission:c,score:Math.round(f*1e3)/1e3,breakdown:{recency:Math.round(l*1e3)/1e3,activity:Math.round(u*1e3)/1e3,blockerBoost:p,statusBoost:d}}}).sort((c,l)=>l.score-c.score)}computeRecency(e,r){let i=Math.max(0,(r-e)/3600);return Math.pow(.5,i/n.RECENCY_HALF_LIFE_HOURS)}computeStatusBoost(e){switch(e){case"in-progress":return 1;case"verifying":return .8;case"planned":return .4;default:return 0}}};X();He();G();import{execSync as Pg}from"child_process";import RS from"path";var Wo=x.child({module:"shadow-trace"}),Ct=class{intentLogs;exports;repoPath;hologramService;constructor(e){let{intentLogs:r,exports:i}=z.getInstance(e);this.intentLogs=r,this.exports=i,this.repoPath=e,this.hologramService=new le(e)}analyzeGhostChanges(e){let r=e?`${e}..HEAD`:"HEAD~1..HEAD",i=[];try{let o=Pg(`git diff --name-only ${r}`,{cwd:this.repoPath,encoding:"utf-8"}).split(`
727
+ `).filter(s=>s.trim()!=="");if(o.length===0)return;Wo.info({files:o.length,range:r},"Initiating Shadow Trace analysis...");for(let s of o){let a=RS.join(this.repoPath,s),l=Pg(`git diff -U0 ${r} -- ${s}`,{cwd:this.repoPath,encoding:"utf-8"}).matchAll(/@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/g);for(let u of l){let d=parseInt(u[2],10),p=this.exports.findAtLine(a,d);p&&(this.intentLogs.create({mission_id:0,file_path:a,symbol_id:p.id,type:"discovery",content:`Shadow Trace: Modified externally in ${r}`,confidence:.8,symbol_name:p.name,signature:p.signature,commit_sha:null}),Wo.debug({symbol:p.name},"Logged ghost change"),i.push({from:"external",to:`${s}:${p.name}`,pattern:"git-delta",confidence:.8}))}}i.length>0&&this.hologramService.updateGhostBridges(i),Wo.info("Shadow Trace complete.")}catch(t){Wo.warn({err:t.message},"Shadow Trace failed: git diff error.")}}};X();G();var NS=x.child({module:"collision-service"}),Bo=class{repoPath;constructor(e){this.repoPath=e}async analyzePotentialCollisions(){let e=Ee(this.repoPath);if(!e)return[];let{missions:r,intentLogs:i}=z.getInstance(this.repoPath),t=r.findActive().filter(a=>a.git_branch&&a.git_branch!==e),o=[],s=new Set;for(let a of t){let c=a.git_branch;if(s.has(c))continue;s.add(c),NS.info({branch:c,currentBranch:e},"Checking predictive collisions"),Ic(this.repoPath,e,c)&&o.push({branch:c,type:"file",description:`Background merge-tree detected a file-level conflict between '${e}' and '${c}'.`});let u=r.findActive(e),d=new Set;for(let f of u)r.getWorkingSet(f.id).forEach(h=>d.add(h.file_path));let m=r.getWorkingSet(a.id).filter(f=>d.has(f.file_path));m.length>0&&o.push({branch:c,type:"intent",description:`Logical conflict: Mission '${a.name}' on '${c}' is modifying files you are currently working on.`,conflictingFiles:m.map(f=>f.file_path)})}return o}};var rr=class{constructor(e){this.repoPath=e}async getBriefing(e={}){let{missionId:r,scope:i="mission",altitude:t,activeMissionsLimit:o,recentActivityLimit:s,compact:a}=e,c=a??(t==="orbit"||t==="atmosphere"),l=s??(t==="orbit"?0:t==="ground"?20:10),{missions:u,intentLogs:d}=z.getInstance(this.repoPath),p=Qe(this.repoPath),m=Ee(this.repoPath);return i==="project"?this.getProjectBriefing({altitude:t,activeMissionsLimit:o,recentActivityLimit:l,compact:c,currentBranch:m,currentCommit:p}):this.getMissionBriefing({missionId:r,altitude:t,recentActivityLimit:l,currentBranch:m,currentCommit:p})}async getProjectBriefing(e){let{repoPath:r}=this,{missions:i,intentLogs:t}=z.getInstance(r),{altitude:o,activeMissionsLimit:s,recentActivityLimit:a,compact:c,currentBranch:l,currentCommit:u}=e,d=i.findActive(l||void 0),p=d.length;s&&d.length>s&&(d=d.slice(0,s));let m=i.findParentOnlyIds(d),f=new Set(m),h=d.filter(M=>!f.has(M.id)),v=new Ho(t).score(h),y=.15,k=3,$=c&&v.length>k?v.filter((M,N)=>N<k||M.score>=y):v,w=$.map(M=>M.mission),I=new Map($.map(M=>[M.mission.id,M.score])),P=M=>({id:M.id,name:M.name,goal:M.goal,status:M.status,relevance:I.get(M.id)});if(o==="orbit")return{scope:"project",altitude:"orbit",counts:i.getStats(),next_work_candidates:w.map(P),meta:{current_branch:l,activeMissionsTotal:p}};let R={},F=[];for(let M of d)M.parent_id!=null?(R[M.parent_id]||(R[M.parent_id]=[]),R[M.parent_id].push(M)):F.push(M);let T=i.findRecentCompleted(5).map(P),A=a>0?t.findRecentDecisionActivity(a):void 0,H=m.map(M=>{let N=d.find(q=>q.id===M);return{parent:c?{...N,strategy_graph:void 0,verification_context:void 0}:N,children:R[M]??[]}}),J=F.filter(M=>!f.has(M.id));return{scope:"project",altitude:o||"atmosphere",counts:i.getStats(),analytics:i.getAnalytics(),hierarchy:H.length>0?H:void 0,standalone_active:J.length>0?J:void 0,active_missions:H.length===0?c?d.map(M=>({...M,strategy_graph:void 0})):d:void 0,next_work_candidates:w.map(P),recent_completed:T,recent_activity:A,meta:{current_branch:l,current_commit:u,activeMissionsTotal:p,active_limit_applied:!!s,relevance_filtered:$.length<v.length?{shown:$.length,total:v.length}:void 0}}}async getMissionBriefing(e){let{repoPath:r}=this,{missions:i,intentLogs:t}=z.getInstance(r),{missionId:o,altitude:s,recentActivityLimit:a,currentBranch:c,currentCommit:l}=e,u;if(o?u=i.findById(o):u=i.findActive(c||void 0)[0],!u)return null;let d=null;try{u.strategy_graph&&(d=JSON.parse(u.strategy_graph))}catch{}if(s==="orbit")return{altitude:"orbit",mission:{id:u.id,name:u.name,goal:u.goal,status:u.status,last_updated:new Date(u.updated_at*1e3).toISOString()},strategy_snapshot:d};let p="No external shadow changes detected.";try{new Ct(r).analyzeGhostChanges(u.commit_sha||void 0),p="Shadow Trace completed: Checked for external modifications."}catch{}let m={repaired:0,failed:0};try{m=new Pe(r).detectAndRepairShifts()}catch{}let f={altitude:s||"atmosphere",mission:{id:u.id,name:u.name,goal:u.goal,status:u.status,last_updated:new Date(u.updated_at*1e3).toISOString(),git_branch:u.git_branch,commit_sha:u.commit_sha,outcome_contract:u.outcome_contract},artifacts:i.getArtifacts(u.id),shadow_trace:{ghost_analysis:p,symbols_repaired:m.repaired,symbols_missing:m.failed},context:{current_commit:l,working_set:i.getWorkingSet(u.id).map(h=>h.file_path)},strategy_snapshot:d,recent_activity:s==="ground"?t.findByMission(u.id,a||20):t.findByMissionPreferCrystal(u.id,15),ancestor_activity_summary:[],predictive_collisions:[]};try{let h=new Bo(r);f.predictive_collisions=await h.analyzePotentialCollisions()}catch{}if(u.parent_id){let h=s==="ground"?t.findByMission(u.parent_id,5):t.findByMissionPreferCrystal(u.parent_id,3);f.ancestor_activity_summary=h.map(_=>({type:_.type,content:_.content,date:new Date(_.created_at*1e3).toISOString()}))}return f}};var Rg=[{name:"shadow_recon_onboard",description:"Initial onboarding for a repository. Indexes all files, extracts symbols, and detects services.",inputSchema:{type:"object",properties:{repoPath:{type:"string",description:"Absolute path to the repository root"}},required:["repoPath"]}},{name:"shadow_recon_topography",description:"Analyze architectural layers (Entry/Logic/Data/Utility). Returns layer breakdown and architectural insights.",inputSchema:{type:"object",properties:{repoPath:{type:"string",description:"Absolute path to the repository root"}},required:["repoPath"]}},{name:"shadow_recon_scout",description:"(Expert) Detect architectural drift, pattern violations, and gravity anomalies.",inputSchema:{type:"object",properties:{repoPath:{type:"string",description:"Absolute path to the repository root"}},required:["repoPath"]}},{name:"shadow_recon_tree",description:"Generate hierarchical file tree with file classifications and export summaries.",inputSchema:{type:"object",properties:{repoPath:{type:"string",description:"Absolute path to the repository root"},subPath:{type:"string",description:"Relative path to focus tree on a specific subdirectory"},maxDepth:{type:"number",description:"Maximum directory depth to traverse"}},required:["repoPath"]}},{name:"shadow_recon_hologram",description:"Get the project hologram (persistent architectural snapshot) and gravity zones.",inputSchema:{type:"object",properties:{repoPath:{type:"string",description:"Absolute path to the repository root"},compact:{type:"boolean",description:"Omit large arrays (gravity.hotspots) for lighter output"}},required:["repoPath"]}},{name:"shadow_search_concept",description:"Semantic/Vector-based intent search across file purpose and logic.",inputSchema:{type:"object",properties:{repoPath:{type:"string",description:"Absolute path to the repository"},query:{type:"string",description:"Search term or semantic intent"},limit:{type:"number",description:"Max results (default 10)"},offset:{type:"number",description:"Pagination offset"},compact:{type:"boolean",description:"Return compact output (no snippets)"},fileType:{type:"string",description:"Filter by extension(s)"},layer:{type:"string",enum:["Solid","Liquid","Virtual","Intel","Phantom"]},includeTests:{type:"boolean",description:"Include test files (Virtual)"}},required:["repoPath","query"]}},{name:"shadow_search_symbol",description:"Exact and fuzzy code symbol matching (classes, functions, methods).",inputSchema:{type:"object",properties:{repoPath:{type:"string",description:"Absolute path to the repository"},query:{type:"string",description:"Symbol name or partial name"},limit:{type:"number",description:"Max results"},offset:{type:"number",description:"Pagination offset"},fileType:{type:"string",description:"Filter by extension(s)"},matchMode:{type:"string",enum:["any","all","exact"],description:"Match mode for multi-word queries: 'any' (OR, default), 'all' (AND), 'exact' (phrase)"}},required:["repoPath","query"]}},{name:"shadow_search_config",description:"Environment and configuration discovery (ENV, Ports, Docker, YAML).",inputSchema:{type:"object",properties:{repoPath:{type:"string",description:"Absolute path to the repository"},query:{type:"string",description:"Search term for values/keys"},key:{type:"string",description:"Specific config key match"},kind:{type:"string",enum:["Service","Image","Port","Env"]},limit:{type:"number"},showUsage:{type:"boolean",description:"Cross-reference with code to show usage counts and identify orphaned vars (defined but never used)"}},required:["repoPath"]}},{name:"shadow_search_path",description:"Filename-keyword resolution using the search index.",inputSchema:{type:"object",properties:{repoPath:{type:"string",description:"Absolute path to the repository"},query:{type:"string",description:"Filename part or path keyword"},limit:{type:"number"},ranked:{type:"boolean",description:"Sort results by gravity (high-import files first) and show layer classification (Entry/Logic/Data)"}},required:["repoPath","query"]}},{name:"shadow_analyze_impact",description:"Calculate blast radius and Strategic Risk Scoring of changing a symbol.",inputSchema:{type:"object",properties:{repoPath:{type:"string"},symbolName:{type:"string",description:"Symbol to analyze"},filePath:{type:"string",description:"Specific file where symbol is defined"},depth:{type:"number",description:"Traversal depth (default 3)"},limit:{type:"number",description:"Max results per symbol (default 50)"},offset:{type:"number",description:"Pagination offset"}},required:["repoPath","symbolName"]}},{name:"shadow_analyze_flow",description:"Execution call-chain tracing (AST-based) for a specific function/method.",inputSchema:{type:"object",properties:{repoPath:{type:"string"},filePath:{type:"string",description:"File to start trace from"},symbolName:{type:"string",description:"Function/method name"}},required:["repoPath","filePath"]}},{name:"shadow_analyze_deps",description:"Direct file import/export mapping and dependency graph inspection.",inputSchema:{type:"object",properties:{repoPath:{type:"string"},filePath:{type:"string"},direction:{type:"string",enum:["imports","imported_by"]}},required:["repoPath","filePath","direction"]}},{name:"shadow_analyze_debt",description:"Recursive dead-code detection and circular import identification. For dead-code mode: excludes migrations and fixtures by default, returns results with confidence scoring.",inputSchema:{type:"object",properties:{repoPath:{type:"string"},mode:{type:"string",enum:["dead-code","circular-deps"]},limit:{type:"number"},includeTests:{type:"boolean"},excludePatterns:{type:"array",items:{type:"string"},description:"Custom glob patterns to exclude (e.g., '**/migrations/**')"},includeMigrations:{type:"boolean",description:"Include migration files (default: false)"},includeFixtures:{type:"boolean",description:"Include fixture/mock files (default: false)"},confidenceThreshold:{type:"string",enum:["all","high","medium"],description:"Filter by confidence: 'all' (default), 'high' (likely dead), 'medium' (possibly intentional)"}},required:["repoPath","mode"]}}];var Ng=[{name:"shadow_ops_plan",description:"Create a new development mission or strategic initiative with goals and strategy.",inputSchema:{type:"object",properties:{repoPath:{type:"string"},name:{type:"string",description:"Mission name"},goal:{type:"string",description:"Objective and success criteria"},strategy:{type:"string",description:"JSON strategy (steps DAG)"},parentId:{type:"number",description:"ID of parent mission"},outcomeContract:{type:"string",description:"Success verification contract"},templateId:{type:"string",enum:["refactoring","feature","bug-fix"]},templateVars:{type:"object",description:"Template variables"}},required:["repoPath"]}},{name:"shadow_ops_track",description:"Update mission step status, record progress, and track completion.",inputSchema:{type:"object",properties:{repoPath:{type:"string"},missionId:{type:"number"},stepId:{type:"string"},status:{type:"string",enum:["pending","in-progress","completed","failed","skipped"]},contextPivot:{type:"string",description:"Rationale for status change"},updates:{type:"array",items:{type:"object",properties:{stepId:{type:"string"},status:{type:"string"},contextPivot:{type:"string"}}}}},required:["repoPath","missionId"]}},{name:"shadow_ops_log",description:"Record architectural decisions, discoveries, or blockers to the intent log.",inputSchema:{type:"object",properties:{repoPath:{type:"string"},missionId:{type:"number",description:"Mission to attach this log to. Optional \u2014 if omitted, auto-resolves to the active mission or logs as standalone."},type:{type:"string",enum:["decision","blocker","discovery","fix"]},content:{type:"string"},filePath:{type:"string",description:"File path to associate with this log"},symbolName:{type:"string",description:"Symbol related to this intent"},standalone:{type:"boolean",description:"If true, log is anchored to symbolName only (no mission). Requires symbolName."}},required:["repoPath","type","content"]}},{name:"shadow_ops_briefing",description:"Active situational awareness - Get details on missions, decisions, and next steps.",inputSchema:{type:"object",properties:{repoPath:{type:"string"},missionId:{type:"number",description:"Optional specific mission ID"},scope:{type:"string",enum:["mission","project"]},altitude:{type:"string",enum:["orbit","atmosphere","ground"],description:"Zoom level: orbit (~200 tokens, counts+candidates only), atmosphere (strategy+crystals, default), ground (raw logs+working set)"},includeGroupedByParent:{type:"boolean"},activeMissionsLimit:{type:"number",description:"Limit active missions in output"},recentActivityLimit:{type:"number",description:"Limit recent activity logs"},compact:{type:"boolean",description:"Omit strategy_graph JSON for lighter output"}},required:["repoPath"]}},{name:"shadow_ops_synthesize",description:"Distill mission context and logs into an Architectural Decision Record (ADR).",inputSchema:{type:"object",properties:{repoPath:{type:"string"},missionId:{type:"number"}},required:["repoPath","missionId"]}},{name:"shadow_ops_chronicle",description:"Archive feed of the repository narrative (initiatives and standalones).",inputSchema:{type:"object",properties:{repoPath:{type:"string"},format:{type:"string",enum:["markdown","json"]},limit:{type:"number"},offset:{type:"number"},since:{type:"number"},until:{type:"number"}},required:["repoPath"]}},{name:"shadow_ops_context",description:'Session-start bundle in one call: hologram + chronicle (last 5) + briefing summary (counts, next_work_candidates). Use for "new chat, give me the world" without multiple round-trips.',inputSchema:{type:"object",properties:{repoPath:{type:"string"},compact:{type:"boolean",description:"Return lighter payload (omit full hologram.gravity.hotspots, strategy_graph)"}},required:["repoPath"]}},{name:"shadow_ops_health",description:"System health metrics and intelligence index status.",inputSchema:{type:"object",properties:{repoPath:{type:"string"}},required:["repoPath"]}},{name:"shadow_ops_crystallize",description:"Compress a mission's intent logs into a single crystal summary. Raw logs are marked as absorbed and replaced by one dense crystal node for token-efficient briefings.",inputSchema:{type:"object",properties:{repoPath:{type:"string"},missionId:{type:"number"}},required:["repoPath","missionId"]}},{name:"shadow_ops_graph",description:"Visualize mission lineage and dependencies.",inputSchema:{type:"object",properties:{repoPath:{type:"string"},missionId:{type:"number"},depth:{type:"number"},limit:{type:"number"},format:{type:"string",enum:["mermaid","json"]}},required:["repoPath"]}},{name:"shadow_working_set_check",description:"Checks which files are in active mission working sets to detect parallel editing conflicts.",inputSchema:{type:"object",properties:{repoPath:{type:"string"},filePaths:{type:"array",items:{type:"string"}}},required:["repoPath","filePaths"]}},{name:"shadow_inspect_symbol",description:"Dense code retrieval for a single symbol with semantic folding and usage context.",inputSchema:{type:"object",properties:{repoPath:{type:"string"},symbolName:{type:"string"},filePath:{type:"string"},context:{type:"string",enum:["definition","full"]}},required:["repoPath","symbolName"]}},{name:"shadow_inspect_file",description:"Token-efficient summary of ALL symbols and exports in a file.",inputSchema:{type:"object",properties:{repoPath:{type:"string"},filePath:{type:"string"},detailLevel:{type:"string",enum:["structure","signatures","summaries","detailed"]}},required:["repoPath","filePath"]}},{name:"shadow_sync_trace",description:"Full lifecycle synchronization - Repairs index, analyzes changes, and re-hydrates state.",inputSchema:{type:"object",properties:{repoPath:{type:"string"},sinceCommit:{type:"string"}},required:["repoPath"]}},{name:"shadow_sync_index",description:"Incremental code re-indexing to reflect latest file changes.",inputSchema:{type:"object",properties:{repoPath:{type:"string"},deep:{type:"boolean",description:"Force full rebuild"}},required:["repoPath"]}},{name:"shadow_sync_repair",description:"NanoRepair only - Heals broken intent links and symbol shifts.",inputSchema:{type:"object",properties:{repoPath:{type:"string"}},required:["repoPath"]}},{name:"shadow_env_hooks",description:"Install and manage Git hooks for automated intelligence maintenance.",inputSchema:{type:"object",properties:{repoPath:{type:"string"},action:{type:"string",enum:["install","remove","status"]},enableAutoRefresh:{type:"boolean"},enableSymbolHealing:{type:"boolean"}},required:["repoPath","action"]}},{name:"shadow_env_diagnose",description:"Missions and intelligence toolset health check.",inputSchema:{type:"object",properties:{repoPath:{type:"string"}},required:["repoPath"]}},{name:"shadow_workspace_list",description:"Federated view of active missions across multiple repositories.",inputSchema:{type:"object",properties:{repoPaths:{type:"array",items:{type:"string"}},status:{type:"string"}},required:["repoPaths"]}},{name:"shadow_workspace_link",description:"Establish intent-level dependencies between missions in different repos.",inputSchema:{type:"object",properties:{parentRepoPath:{type:"string"},parentMissionId:{type:"number"},childRepoPath:{type:"string"},childMissionId:{type:"number"},relationship:{type:"string"}},required:["parentRepoPath","parentMissionId","childRepoPath","childMissionId","relationship"]}},{name:"shadow_workspace_fuse",description:"Create unified cross-repo search indices using SQLite fusion.",inputSchema:{type:"object",properties:{repoPaths:{type:"array",items:{type:"string"}},name:{type:"string"}},required:["repoPaths"]}}];var g={};Ke(g,{$brand:()=>Go,$input:()=>cd,$output:()=>ad,NEVER:()=>Hc,TimePrecision:()=>pd,ZodAny:()=>tm,ZodArray:()=>om,ZodBase64:()=>ba,ZodBase64URL:()=>_a,ZodBigInt:()=>Dr,ZodBigIntFormat:()=>$a,ZodBoolean:()=>zr,ZodCIDRv4:()=>ya,ZodCIDRv6:()=>va,ZodCUID:()=>ua,ZodCUID2:()=>da,ZodCatch:()=>Im,ZodCodec:()=>Na,ZodCustom:()=>Oi,ZodCustomStringFormat:()=>Rr,ZodDate:()=>zi,ZodDefault:()=>xm,ZodDiscriminatedUnion:()=>am,ZodE164:()=>xa,ZodEmail:()=>aa,ZodEmoji:()=>ca,ZodEnum:()=>Tr,ZodError:()=>ok,ZodExactOptional:()=>vm,ZodFile:()=>gm,ZodFirstPartyTypeKind:()=>jm,ZodFunction:()=>Am,ZodGUID:()=>Ii,ZodIPv4:()=>ha,ZodIPv6:()=>ga,ZodISODate:()=>ta,ZodISODateTime:()=>ea,ZodISODuration:()=>ra,ZodISOTime:()=>na,ZodIntersection:()=>cm,ZodIssueCode:()=>ak,ZodJWT:()=>Sa,ZodKSUID:()=>fa,ZodLazy:()=>Dm,ZodLiteral:()=>hm,ZodMAC:()=>qp,ZodMap:()=>mm,ZodNaN:()=>Pm,ZodNanoID:()=>la,ZodNever:()=>rm,ZodNonOptional:()=>Pa,ZodNull:()=>Qp,ZodNullable:()=>_m,ZodNumber:()=>Nr,ZodNumberFormat:()=>Mn,ZodObject:()=>Ci,ZodOptional:()=>Ta,ZodPipe:()=>Ra,ZodPrefault:()=>$m,ZodPromise:()=>Lm,ZodReadonly:()=>Rm,ZodRealError:()=>Ge,ZodRecord:()=>Ai,ZodSet:()=>fm,ZodString:()=>Pr,ZodStringFormat:()=>se,ZodSuccess:()=>Em,ZodSymbol:()=>Yp,ZodTemplateLiteral:()=>zm,ZodTransform:()=>ym,ZodTuple:()=>um,ZodType:()=>ee,ZodULID:()=>pa,ZodURL:()=>Ni,ZodUUID:()=>wt,ZodUndefined:()=>Xp,ZodUnion:()=>Li,ZodUnknown:()=>nm,ZodVoid:()=>im,ZodXID:()=>ma,ZodXor:()=>sm,_ZodString:()=>sa,_default:()=>Sm,_function:()=>ub,any:()=>Zv,array:()=>Di,base64:()=>kv,base64url:()=>Ev,bigint:()=>Ov,boolean:()=>Kp,catch:()=>Tm,check:()=>db,cidrv4:()=>$v,cidrv6:()=>wv,clone:()=>Ce,codec:()=>ab,coerce:()=>Um,config:()=>_e,core:()=>Ot,cuid:()=>hv,cuid2:()=>gv,custom:()=>pb,date:()=>Wv,decode:()=>Fp,decodeAsync:()=>Hp,describe:()=>mb,discriminatedUnion:()=>Kv,e164:()=>Iv,email:()=>ov,emoji:()=>mv,encode:()=>Up,encodeAsync:()=>Zp,endsWith:()=>vr,enum:()=>Ea,exactOptional:()=>bm,file:()=>rb,flattenError:()=>fi,float32:()=>Dv,float64:()=>Cv,formatError:()=>hi,fromJSONSchema:()=>_b,function:()=>ub,getErrorMap:()=>lk,globalRegistry:()=>Re,gt:()=>St,gte:()=>Le,guid:()=>sv,hash:()=>zv,hex:()=>Nv,hostname:()=>Rv,httpUrl:()=>pv,includes:()=>gr,instanceof:()=>hb,int:()=>oa,int32:()=>Lv,int64:()=>Mv,intersection:()=>lm,ipv4:()=>_v,ipv6:()=>Sv,iso:()=>Ir,json:()=>yb,jwt:()=>Tv,keyof:()=>Bv,ksuid:()=>bv,lazy:()=>Cm,length:()=>An,literal:()=>nb,locales:()=>$i,looseObject:()=>qv,looseRecord:()=>Xv,lowercase:()=>fr,lt:()=>xt,lte:()=>qe,mac:()=>xv,map:()=>Qv,maxLength:()=>Ln,maxSize:()=>sn,meta:()=>fb,mime:()=>br,minLength:()=>At,minSize:()=>$t,multipleOf:()=>on,nan:()=>sb,nanoid:()=>fv,nativeEnum:()=>tb,negative:()=>Ws,never:()=>wa,nonnegative:()=>Gs,nonoptional:()=>km,nonpositive:()=>Bs,normalize:()=>_r,null:()=>em,nullable:()=>Pi,nullish:()=>ib,number:()=>Vp,object:()=>Gv,optional:()=>Ti,overwrite:()=>mt,parse:()=>Ap,parseAsync:()=>Op,partialRecord:()=>Yv,pipe:()=>Ri,positive:()=>Hs,prefault:()=>wm,preprocess:()=>vb,prettifyError:()=>tl,promise:()=>lb,property:()=>Js,readonly:()=>Nm,record:()=>pm,refine:()=>Om,regex:()=>mr,regexes:()=>nt,registry:()=>Ss,safeDecode:()=>Bp,safeDecodeAsync:()=>Jp,safeEncode:()=>Wp,safeEncodeAsync:()=>Gp,safeParse:()=>Mp,safeParseAsync:()=>jp,set:()=>eb,setErrorMap:()=>ck,size:()=>Cn,slugify:()=>wr,startsWith:()=>yr,strictObject:()=>Jv,string:()=>ia,stringFormat:()=>Pv,stringbool:()=>gb,success:()=>ob,superRefine:()=>Mm,symbol:()=>Uv,templateLiteral:()=>cb,toJSONSchema:()=>Ys,toLowerCase:()=>Sr,toUpperCase:()=>$r,transform:()=>Ia,treeifyError:()=>el,trim:()=>xr,tuple:()=>dm,uint32:()=>Av,uint64:()=>jv,ulid:()=>yv,undefined:()=>Fv,union:()=>ka,unknown:()=>On,uppercase:()=>hr,url:()=>dv,util:()=>L,uuid:()=>av,uuidv4:()=>cv,uuidv6:()=>lv,uuidv7:()=>uv,void:()=>Hv,xid:()=>vv,xor:()=>Vv});var Ot={};Ke(Ot,{$ZodAny:()=>Pu,$ZodArray:()=>Cu,$ZodAsyncError:()=>pt,$ZodBase64:()=>bu,$ZodBase64URL:()=>_u,$ZodBigInt:()=>hs,$ZodBigIntFormat:()=>ku,$ZodBoolean:()=>bi,$ZodCIDRv4:()=>gu,$ZodCIDRv6:()=>yu,$ZodCUID:()=>iu,$ZodCUID2:()=>ou,$ZodCatch:()=>Xu,$ZodCheck:()=>ue,$ZodCheckBigIntFormat:()=>Cl,$ZodCheckEndsWith:()=>Gl,$ZodCheckGreaterThan:()=>cs,$ZodCheckIncludes:()=>Wl,$ZodCheckLengthEquals:()=>Ul,$ZodCheckLessThan:()=>as,$ZodCheckLowerCase:()=>Zl,$ZodCheckMaxLength:()=>Ml,$ZodCheckMaxSize:()=>Ll,$ZodCheckMimeType:()=>ql,$ZodCheckMinLength:()=>jl,$ZodCheckMinSize:()=>Al,$ZodCheckMultipleOf:()=>zl,$ZodCheckNumberFormat:()=>Dl,$ZodCheckOverwrite:()=>Vl,$ZodCheckProperty:()=>Jl,$ZodCheckRegex:()=>Fl,$ZodCheckSizeEquals:()=>Ol,$ZodCheckStartsWith:()=>Bl,$ZodCheckStringFormat:()=>dr,$ZodCheckUpperCase:()=>Hl,$ZodCodec:()=>xi,$ZodCustom:()=>sd,$ZodCustomStringFormat:()=>$u,$ZodDate:()=>Du,$ZodDefault:()=>qu,$ZodDiscriminatedUnion:()=>Ou,$ZodE164:()=>xu,$ZodEmail:()=>eu,$ZodEmoji:()=>nu,$ZodEncodeError:()=>Qt,$ZodEnum:()=>Zu,$ZodError:()=>mi,$ZodExactOptional:()=>Gu,$ZodFile:()=>Wu,$ZodFunction:()=>rd,$ZodGUID:()=>Xl,$ZodIPv4:()=>mu,$ZodIPv6:()=>fu,$ZodISODate:()=>uu,$ZodISODateTime:()=>lu,$ZodISODuration:()=>pu,$ZodISOTime:()=>du,$ZodIntersection:()=>Mu,$ZodJWT:()=>Su,$ZodKSUID:()=>cu,$ZodLazy:()=>od,$ZodLiteral:()=>Hu,$ZodMAC:()=>hu,$ZodMap:()=>Uu,$ZodNaN:()=>Qu,$ZodNanoID:()=>ru,$ZodNever:()=>Nu,$ZodNonOptional:()=>Ku,$ZodNull:()=>Tu,$ZodNullable:()=>Ju,$ZodNumber:()=>fs,$ZodNumberFormat:()=>wu,$ZodObject:()=>iy,$ZodObjectJIT:()=>Lu,$ZodOptional:()=>ys,$ZodPipe:()=>ed,$ZodPrefault:()=>Vu,$ZodPromise:()=>id,$ZodReadonly:()=>td,$ZodRealError:()=>Be,$ZodRecord:()=>ju,$ZodRegistry:()=>xs,$ZodSet:()=>Fu,$ZodString:()=>Dn,$ZodStringFormat:()=>oe,$ZodSuccess:()=>Yu,$ZodSymbol:()=>Eu,$ZodTemplateLiteral:()=>nd,$ZodTransform:()=>Bu,$ZodTuple:()=>gs,$ZodType:()=>Y,$ZodULID:()=>su,$ZodURL:()=>tu,$ZodUUID:()=>Ql,$ZodUndefined:()=>Iu,$ZodUnion:()=>_i,$ZodUnknown:()=>Ru,$ZodVoid:()=>zu,$ZodXID:()=>au,$ZodXor:()=>Au,$brand:()=>Go,$constructor:()=>S,$input:()=>cd,$output:()=>ad,Doc:()=>vi,JSONSchema:()=>rv,JSONSchemaGenerator:()=>Xs,NEVER:()=>Hc,TimePrecision:()=>pd,_any:()=>Dd,_array:()=>Ud,_base64:()=>js,_base64url:()=>Us,_bigint:()=>Ed,_boolean:()=>wd,_catch:()=>Yw,_check:()=>nv,_cidrv4:()=>Os,_cidrv6:()=>Ms,_coercedBigint:()=>Id,_coercedBoolean:()=>kd,_coercedDate:()=>Md,_coercedNumber:()=>vd,_coercedString:()=>ud,_cuid:()=>Rs,_cuid2:()=>Ns,_custom:()=>Zd,_date:()=>Od,_decode:()=>Xo,_decodeAsync:()=>es,_default:()=>qw,_discriminatedUnion:()=>Aw,_e164:()=>Fs,_email:()=>$s,_emoji:()=>Ts,_encode:()=>Yo,_encodeAsync:()=>Qo,_endsWith:()=>vr,_enum:()=>Zw,_file:()=>Fd,_float32:()=>_d,_float64:()=>xd,_gt:()=>St,_gte:()=>Le,_guid:()=>wi,_includes:()=>gr,_int:()=>bd,_int32:()=>Sd,_int64:()=>Td,_intersection:()=>Ow,_ipv4:()=>Ls,_ipv6:()=>As,_isoDate:()=>fd,_isoDateTime:()=>md,_isoDuration:()=>gd,_isoTime:()=>hd,_jwt:()=>Zs,_ksuid:()=>Cs,_lazy:()=>tk,_length:()=>An,_literal:()=>Ww,_lowercase:()=>fr,_lt:()=>xt,_lte:()=>qe,_mac:()=>dd,_map:()=>Uw,_max:()=>qe,_maxLength:()=>Ln,_maxSize:()=>sn,_mime:()=>br,_min:()=>Le,_minLength:()=>At,_minSize:()=>$t,_multipleOf:()=>on,_nan:()=>jd,_nanoid:()=>Ps,_nativeEnum:()=>Hw,_negative:()=>Ws,_never:()=>Ld,_nonnegative:()=>Gs,_nonoptional:()=>Vw,_nonpositive:()=>Bs,_normalize:()=>_r,_null:()=>zd,_nullable:()=>Jw,_number:()=>yd,_optional:()=>Gw,_overwrite:()=>mt,_parse:()=>ar,_parseAsync:()=>cr,_pipe:()=>Xw,_positive:()=>Hs,_promise:()=>nk,_property:()=>Js,_readonly:()=>Qw,_record:()=>jw,_refine:()=>Hd,_regex:()=>mr,_safeDecode:()=>ns,_safeDecodeAsync:()=>is,_safeEncode:()=>ts,_safeEncodeAsync:()=>rs,_safeParse:()=>lr,_safeParseAsync:()=>ur,_set:()=>Fw,_size:()=>Cn,_slugify:()=>wr,_startsWith:()=>yr,_string:()=>ld,_stringFormat:()=>kr,_stringbool:()=>Jd,_success:()=>Kw,_superRefine:()=>Wd,_symbol:()=>Rd,_templateLiteral:()=>ek,_toLowerCase:()=>Sr,_toUpperCase:()=>$r,_transform:()=>Bw,_trim:()=>xr,_tuple:()=>Mw,_uint32:()=>$d,_uint64:()=>Pd,_ulid:()=>zs,_undefined:()=>Nd,_union:()=>Cw,_unknown:()=>Cd,_uppercase:()=>hr,_url:()=>ki,_uuid:()=>ws,_uuidv4:()=>ks,_uuidv6:()=>Es,_uuidv7:()=>Is,_void:()=>Ad,_xid:()=>Ds,_xor:()=>Lw,clone:()=>Ce,config:()=>_e,createStandardJSONSchemaMethod:()=>Er,createToJSONSchemaMethod:()=>qd,decode:()=>o$,decodeAsync:()=>a$,describe:()=>Bd,encode:()=>i$,encodeAsync:()=>s$,extractDefs:()=>cn,finalize:()=>ln,flattenError:()=>fi,formatError:()=>hi,globalConfig:()=>si,globalRegistry:()=>Re,initializeContext:()=>an,isValidBase64:()=>vu,isValidBase64URL:()=>ey,isValidJWT:()=>ty,locales:()=>$i,meta:()=>Gd,parse:()=>Vo,parseAsync:()=>Ko,prettifyError:()=>tl,process:()=>ie,regexes:()=>nt,registry:()=>Ss,safeDecode:()=>l$,safeDecodeAsync:()=>d$,safeEncode:()=>c$,safeEncodeAsync:()=>u$,safeParse:()=>nl,safeParseAsync:()=>rl,toDotPath:()=>Ag,toJSONSchema:()=>Ys,treeifyError:()=>el,util:()=>L,version:()=>Kl});var Hc=Object.freeze({status:"aborted"});function S(n,e,r){function i(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:s,traits:new Set},enumerable:!1}),a._zod.traits.has(n))return;a._zod.traits.add(n),e(a,c);let l=s.prototype,u=Object.keys(l);for(let d=0;d<u.length;d++){let p=u[d];p in a||(a[p]=l[p].bind(a))}}let t=r?.Parent??Object;class o extends t{}Object.defineProperty(o,"name",{value:n});function s(a){var c;let l=r?.Parent?new o:this;i(l,a),(c=l._zod).deferred??(c.deferred=[]);for(let u of l._zod.deferred)u();return l}return Object.defineProperty(s,"init",{value:i}),Object.defineProperty(s,Symbol.hasInstance,{value:a=>r?.Parent&&a instanceof r.Parent?!0:a?._zod?.traits?.has(n)}),Object.defineProperty(s,"name",{value:n}),s}var Go=Symbol("zod_brand"),pt=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Qt=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}},si={};function _e(n){return n&&Object.assign(si,n),si}var L={};Ke(L,{BIGINT_FORMAT_RANGES:()=>Qc,Class:()=>Bc,NUMBER_FORMAT_RANGES:()=>Xc,aborted:()=>rn,allowsEval:()=>qc,assert:()=>AS,assertEqual:()=>zS,assertIs:()=>CS,assertNever:()=>LS,assertNotEqual:()=>DS,assignProp:()=>tn,base64ToUint8Array:()=>Dg,base64urlToUint8Array:()=>QS,cached:()=>or,captureStackTrace:()=>qo,cleanEnum:()=>XS,cleanRegex:()=>li,clone:()=>Ce,cloneDef:()=>MS,createTransparentProxy:()=>WS,defineLazy:()=>te,esc:()=>Jo,escapeRegex:()=>tt,extend:()=>JS,finalizeIssue:()=>We,floatSafeRemainder:()=>Gc,getElementAtPath:()=>jS,getEnumValues:()=>ci,getLengthableOrigin:()=>pi,getParsedType:()=>HS,getSizableOrigin:()=>di,hexToUint8Array:()=>t$,isObject:()=>Nn,isPlainObject:()=>nn,issue:()=>sr,joinValues:()=>E,jsonStringifyReplacer:()=>ir,merge:()=>VS,mergeDefs:()=>Lt,normalizeParams:()=>O,nullish:()=>en,numKeys:()=>ZS,objectClone:()=>OS,omit:()=>GS,optionalKeys:()=>Yc,parsedType:()=>C,partial:()=>KS,pick:()=>BS,prefixIssues:()=>Je,primitiveTypes:()=>Kc,promiseAllObject:()=>US,propertyKeyTypes:()=>ui,randomString:()=>FS,required:()=>YS,safeExtend:()=>qS,shallowClone:()=>Vc,slugify:()=>Jc,stringifyPrimitive:()=>D,uint8ArrayToBase64:()=>Cg,uint8ArrayToBase64url:()=>e$,uint8ArrayToHex:()=>n$,unwrapMessage:()=>ai});function zS(n){return n}function DS(n){return n}function CS(n){}function LS(n){throw new Error("Unexpected value in exhaustive check")}function AS(n){}function ci(n){let e=Object.values(n).filter(i=>typeof i=="number");return Object.entries(n).filter(([i,t])=>e.indexOf(+i)===-1).map(([i,t])=>t)}function E(n,e="|"){return n.map(r=>D(r)).join(e)}function ir(n,e){return typeof e=="bigint"?e.toString():e}function or(n){return{get value(){{let r=n();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function en(n){return n==null}function li(n){let e=n.startsWith("^")?1:0,r=n.endsWith("$")?n.length-1:n.length;return n.slice(e,r)}function Gc(n,e){let r=(n.toString().split(".")[1]||"").length,i=e.toString(),t=(i.split(".")[1]||"").length;if(t===0&&/\d?e-\d?/.test(i)){let c=i.match(/\d?e-(\d?)/);c?.[1]&&(t=Number.parseInt(c[1]))}let o=r>t?r:t,s=Number.parseInt(n.toFixed(o).replace(".","")),a=Number.parseInt(e.toFixed(o).replace(".",""));return s%a/10**o}var zg=Symbol("evaluating");function te(n,e,r){let i;Object.defineProperty(n,e,{get(){if(i!==zg)return i===void 0&&(i=zg,i=r()),i},set(t){Object.defineProperty(n,e,{value:t})},configurable:!0})}function OS(n){return Object.create(Object.getPrototypeOf(n),Object.getOwnPropertyDescriptors(n))}function tn(n,e,r){Object.defineProperty(n,e,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Lt(...n){let e={};for(let r of n){let i=Object.getOwnPropertyDescriptors(r);Object.assign(e,i)}return Object.defineProperties({},e)}function MS(n){return Lt(n._zod.def)}function jS(n,e){return e?e.reduce((r,i)=>r?.[i],n):n}function US(n){let e=Object.keys(n),r=e.map(i=>n[i]);return Promise.all(r).then(i=>{let t={};for(let o=0;o<e.length;o++)t[e[o]]=i[o];return t})}function FS(n=10){let e="abcdefghijklmnopqrstuvwxyz",r="";for(let i=0;i<n;i++)r+=e[Math.floor(Math.random()*e.length)];return r}function Jo(n){return JSON.stringify(n)}function Jc(n){return n.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var qo="captureStackTrace"in Error?Error.captureStackTrace:(...n)=>{};function Nn(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}var qc=or(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let n=Function;return new n(""),!0}catch{return!1}});function nn(n){if(Nn(n)===!1)return!1;let e=n.constructor;if(e===void 0||typeof e!="function")return!0;let r=e.prototype;return!(Nn(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function Vc(n){return nn(n)?{...n}:Array.isArray(n)?[...n]:n}function ZS(n){let e=0;for(let r in n)Object.prototype.hasOwnProperty.call(n,r)&&e++;return e}var HS=n=>{let e=typeof n;switch(e){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(n)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(n)?"array":n===null?"null":n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?"promise":typeof Map<"u"&&n instanceof Map?"map":typeof Set<"u"&&n instanceof Set?"set":typeof Date<"u"&&n instanceof Date?"date":typeof File<"u"&&n instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${e}`)}},ui=new Set(["string","number","symbol"]),Kc=new Set(["string","number","bigint","boolean","symbol","undefined"]);function tt(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ce(n,e,r){let i=new n._zod.constr(e??n._zod.def);return(!e||r?.parent)&&(i._zod.parent=n),i}function O(n){let e=n;if(!e)return{};if(typeof e=="string")return{error:()=>e};if(e?.message!==void 0){if(e?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function WS(n){let e;return new Proxy({},{get(r,i,t){return e??(e=n()),Reflect.get(e,i,t)},set(r,i,t,o){return e??(e=n()),Reflect.set(e,i,t,o)},has(r,i){return e??(e=n()),Reflect.has(e,i)},deleteProperty(r,i){return e??(e=n()),Reflect.deleteProperty(e,i)},ownKeys(r){return e??(e=n()),Reflect.ownKeys(e)},getOwnPropertyDescriptor(r,i){return e??(e=n()),Reflect.getOwnPropertyDescriptor(e,i)},defineProperty(r,i,t){return e??(e=n()),Reflect.defineProperty(e,i,t)}})}function D(n){return typeof n=="bigint"?n.toString()+"n":typeof n=="string"?`"${n}"`:`${n}`}function Yc(n){return Object.keys(n).filter(e=>n[e]._zod.optin==="optional"&&n[e]._zod.optout==="optional")}var Xc={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},Qc={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function BS(n,e){let r=n._zod.def,i=r.checks;if(i&&i.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let o=Lt(n._zod.def,{get shape(){let s={};for(let a in e){if(!(a in r.shape))throw new Error(`Unrecognized key: "${a}"`);e[a]&&(s[a]=r.shape[a])}return tn(this,"shape",s),s},checks:[]});return Ce(n,o)}function GS(n,e){let r=n._zod.def,i=r.checks;if(i&&i.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let o=Lt(n._zod.def,{get shape(){let s={...n._zod.def.shape};for(let a in e){if(!(a in r.shape))throw new Error(`Unrecognized key: "${a}"`);e[a]&&delete s[a]}return tn(this,"shape",s),s},checks:[]});return Ce(n,o)}function JS(n,e){if(!nn(e))throw new Error("Invalid input to extend: expected a plain object");let r=n._zod.def.checks;if(r&&r.length>0){let o=n._zod.def.shape;for(let s in e)if(Object.getOwnPropertyDescriptor(o,s)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let t=Lt(n._zod.def,{get shape(){let o={...n._zod.def.shape,...e};return tn(this,"shape",o),o}});return Ce(n,t)}function qS(n,e){if(!nn(e))throw new Error("Invalid input to safeExtend: expected a plain object");let r=Lt(n._zod.def,{get shape(){let i={...n._zod.def.shape,...e};return tn(this,"shape",i),i}});return Ce(n,r)}function VS(n,e){let r=Lt(n._zod.def,{get shape(){let i={...n._zod.def.shape,...e._zod.def.shape};return tn(this,"shape",i),i},get catchall(){return e._zod.def.catchall},checks:[]});return Ce(n,r)}function KS(n,e,r){let t=e._zod.def.checks;if(t&&t.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");let s=Lt(e._zod.def,{get shape(){let a=e._zod.def.shape,c={...a};if(r)for(let l in r){if(!(l in a))throw new Error(`Unrecognized key: "${l}"`);r[l]&&(c[l]=n?new n({type:"optional",innerType:a[l]}):a[l])}else for(let l in a)c[l]=n?new n({type:"optional",innerType:a[l]}):a[l];return tn(this,"shape",c),c},checks:[]});return Ce(e,s)}function YS(n,e,r){let i=Lt(e._zod.def,{get shape(){let t=e._zod.def.shape,o={...t};if(r)for(let s in r){if(!(s in o))throw new Error(`Unrecognized key: "${s}"`);r[s]&&(o[s]=new n({type:"nonoptional",innerType:t[s]}))}else for(let s in t)o[s]=new n({type:"nonoptional",innerType:t[s]});return tn(this,"shape",o),o}});return Ce(e,i)}function rn(n,e=0){if(n.aborted===!0)return!0;for(let r=e;r<n.issues.length;r++)if(n.issues[r]?.continue!==!0)return!0;return!1}function Je(n,e){return e.map(r=>{var i;return(i=r).path??(i.path=[]),r.path.unshift(n),r})}function ai(n){return typeof n=="string"?n:n?.message}function We(n,e,r){let i={...n,path:n.path??[]};if(!n.message){let t=ai(n.inst?._zod.def?.error?.(n))??ai(e?.error?.(n))??ai(r.customError?.(n))??ai(r.localeError?.(n))??"Invalid input";i.message=t}return delete i.inst,delete i.continue,e?.reportInput||delete i.input,i}function di(n){return n instanceof Set?"set":n instanceof Map?"map":n instanceof File?"file":"unknown"}function pi(n){return Array.isArray(n)?"array":typeof n=="string"?"string":"unknown"}function C(n){let e=typeof n;switch(e){case"number":return Number.isNaN(n)?"nan":"number";case"object":{if(n===null)return"null";if(Array.isArray(n))return"array";let r=n;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&"constructor"in r&&r.constructor)return r.constructor.name}}return e}function sr(...n){let[e,r,i]=n;return typeof e=="string"?{message:e,code:"custom",input:r,inst:i}:{...e}}function XS(n){return Object.entries(n).filter(([e,r])=>Number.isNaN(Number.parseInt(e,10))).map(e=>e[1])}function Dg(n){let e=atob(n),r=new Uint8Array(e.length);for(let i=0;i<e.length;i++)r[i]=e.charCodeAt(i);return r}function Cg(n){let e="";for(let r=0;r<n.length;r++)e+=String.fromCharCode(n[r]);return btoa(e)}function QS(n){let e=n.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-e.length%4)%4);return Dg(e+r)}function e$(n){return Cg(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function t$(n){let e=n.replace(/^0x/,"");if(e.length%2!==0)throw new Error("Invalid hex string length");let r=new Uint8Array(e.length/2);for(let i=0;i<e.length;i+=2)r[i/2]=Number.parseInt(e.slice(i,i+2),16);return r}function n$(n){return Array.from(n).map(e=>e.toString(16).padStart(2,"0")).join("")}var Bc=class{constructor(...e){}};var Lg=(n,e)=>{n.name="$ZodError",Object.defineProperty(n,"_zod",{value:n._zod,enumerable:!1}),Object.defineProperty(n,"issues",{value:e,enumerable:!1}),n.message=JSON.stringify(e,ir,2),Object.defineProperty(n,"toString",{value:()=>n.message,enumerable:!1})},mi=S("$ZodError",Lg),Be=S("$ZodError",Lg,{Parent:Error});function fi(n,e=r=>r.message){let r={},i=[];for(let t of n.issues)t.path.length>0?(r[t.path[0]]=r[t.path[0]]||[],r[t.path[0]].push(e(t))):i.push(e(t));return{formErrors:i,fieldErrors:r}}function hi(n,e=r=>r.message){let r={_errors:[]},i=t=>{for(let o of t.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map(s=>i({issues:s}));else if(o.code==="invalid_key")i({issues:o.issues});else if(o.code==="invalid_element")i({issues:o.issues});else if(o.path.length===0)r._errors.push(e(o));else{let s=r,a=0;for(;a<o.path.length;){let c=o.path[a];a===o.path.length-1?(s[c]=s[c]||{_errors:[]},s[c]._errors.push(e(o))):s[c]=s[c]||{_errors:[]},s=s[c],a++}}};return i(n),r}function el(n,e=r=>r.message){let r={errors:[]},i=(t,o=[])=>{var s,a;for(let c of t.issues)if(c.code==="invalid_union"&&c.errors.length)c.errors.map(l=>i({issues:l},c.path));else if(c.code==="invalid_key")i({issues:c.issues},c.path);else if(c.code==="invalid_element")i({issues:c.issues},c.path);else{let l=[...o,...c.path];if(l.length===0){r.errors.push(e(c));continue}let u=r,d=0;for(;d<l.length;){let p=l[d],m=d===l.length-1;typeof p=="string"?(u.properties??(u.properties={}),(s=u.properties)[p]??(s[p]={errors:[]}),u=u.properties[p]):(u.items??(u.items=[]),(a=u.items)[p]??(a[p]={errors:[]}),u=u.items[p]),m&&u.errors.push(e(c)),d++}}};return i(n),r}function Ag(n){let e=[],r=n.map(i=>typeof i=="object"?i.key:i);for(let i of r)typeof i=="number"?e.push(`[${i}]`):typeof i=="symbol"?e.push(`[${JSON.stringify(String(i))}]`):/[^\w$]/.test(i)?e.push(`[${JSON.stringify(i)}]`):(e.length&&e.push("."),e.push(i));return e.join("")}function tl(n){let e=[],r=[...n.issues].sort((i,t)=>(i.path??[]).length-(t.path??[]).length);for(let i of r)e.push(`\u2716 ${i.message}`),i.path?.length&&e.push(` \u2192 at ${Ag(i.path)}`);return e.join(`
728
+ `)}var ar=n=>(e,r,i,t)=>{let o=i?Object.assign(i,{async:!1}):{async:!1},s=e._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new pt;if(s.issues.length){let a=new(t?.Err??n)(s.issues.map(c=>We(c,o,_e())));throw qo(a,t?.callee),a}return s.value},Vo=ar(Be),cr=n=>async(e,r,i,t)=>{let o=i?Object.assign(i,{async:!0}):{async:!0},s=e._zod.run({value:r,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let a=new(t?.Err??n)(s.issues.map(c=>We(c,o,_e())));throw qo(a,t?.callee),a}return s.value},Ko=cr(Be),lr=n=>(e,r,i)=>{let t=i?{...i,async:!1}:{async:!1},o=e._zod.run({value:r,issues:[]},t);if(o instanceof Promise)throw new pt;return o.issues.length?{success:!1,error:new(n??mi)(o.issues.map(s=>We(s,t,_e())))}:{success:!0,data:o.value}},nl=lr(Be),ur=n=>async(e,r,i)=>{let t=i?Object.assign(i,{async:!0}):{async:!0},o=e._zod.run({value:r,issues:[]},t);return o instanceof Promise&&(o=await o),o.issues.length?{success:!1,error:new n(o.issues.map(s=>We(s,t,_e())))}:{success:!0,data:o.value}},rl=ur(Be),Yo=n=>(e,r,i)=>{let t=i?Object.assign(i,{direction:"backward"}):{direction:"backward"};return ar(n)(e,r,t)},i$=Yo(Be),Xo=n=>(e,r,i)=>ar(n)(e,r,i),o$=Xo(Be),Qo=n=>async(e,r,i)=>{let t=i?Object.assign(i,{direction:"backward"}):{direction:"backward"};return cr(n)(e,r,t)},s$=Qo(Be),es=n=>async(e,r,i)=>cr(n)(e,r,i),a$=es(Be),ts=n=>(e,r,i)=>{let t=i?Object.assign(i,{direction:"backward"}):{direction:"backward"};return lr(n)(e,r,t)},c$=ts(Be),ns=n=>(e,r,i)=>lr(n)(e,r,i),l$=ns(Be),rs=n=>async(e,r,i)=>{let t=i?Object.assign(i,{direction:"backward"}):{direction:"backward"};return ur(n)(e,r,t)},u$=rs(Be),is=n=>async(e,r,i)=>ur(n)(e,r,i),d$=is(Be);var nt={};Ke(nt,{base64:()=>bl,base64url:()=>os,bigint:()=>kl,boolean:()=>Il,browserEmail:()=>b$,cidrv4:()=>yl,cidrv6:()=>vl,cuid:()=>il,cuid2:()=>ol,date:()=>xl,datetime:()=>$l,domain:()=>S$,duration:()=>ul,e164:()=>_l,email:()=>pl,emoji:()=>ml,extendedDuration:()=>p$,guid:()=>dl,hex:()=>$$,hostname:()=>x$,html5Email:()=>g$,idnEmail:()=>v$,integer:()=>El,ipv4:()=>fl,ipv6:()=>hl,ksuid:()=>cl,lowercase:()=>Rl,mac:()=>gl,md5_base64:()=>k$,md5_base64url:()=>E$,md5_hex:()=>w$,nanoid:()=>ll,null:()=>Tl,number:()=>ss,rfc5322Email:()=>y$,sha1_base64:()=>T$,sha1_base64url:()=>P$,sha1_hex:()=>I$,sha256_base64:()=>N$,sha256_base64url:()=>z$,sha256_hex:()=>R$,sha384_base64:()=>C$,sha384_base64url:()=>L$,sha384_hex:()=>D$,sha512_base64:()=>O$,sha512_base64url:()=>M$,sha512_hex:()=>A$,string:()=>wl,time:()=>Sl,ulid:()=>sl,undefined:()=>Pl,unicodeEmail:()=>Og,uppercase:()=>Nl,uuid:()=>zn,uuid4:()=>m$,uuid6:()=>f$,uuid7:()=>h$,xid:()=>al});var il=/^[cC][^\s-]{8,}$/,ol=/^[0-9a-z]+$/,sl=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,al=/^[0-9a-vA-V]{20}$/,cl=/^[A-Za-z0-9]{27}$/,ll=/^[a-zA-Z0-9_-]{21}$/,ul=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,p$=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,dl=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,zn=n=>n?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${n}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,m$=zn(4),f$=zn(6),h$=zn(7),pl=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,g$=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,y$=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,Og=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,v$=Og,b$=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,_$="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function ml(){return new RegExp(_$,"u")}var fl=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,hl=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,gl=n=>{let e=tt(n??":");return new RegExp(`^(?:[0-9A-F]{2}${e}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${e}){5}[0-9a-f]{2}$`)},yl=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,vl=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,bl=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,os=/^[A-Za-z0-9_-]*$/,x$=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,S$=/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,_l=/^\+[1-9]\d{6,14}$/,Mg="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",xl=new RegExp(`^${Mg}$`);function jg(n){let e="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof n.precision=="number"?n.precision===-1?`${e}`:n.precision===0?`${e}:[0-5]\\d`:`${e}:[0-5]\\d\\.\\d{${n.precision}}`:`${e}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Sl(n){return new RegExp(`^${jg(n)}$`)}function $l(n){let e=jg({precision:n.precision}),r=["Z"];n.local&&r.push(""),n.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let i=`${e}(?:${r.join("|")})`;return new RegExp(`^${Mg}T(?:${i})$`)}var wl=n=>{let e=n?`[\\s\\S]{${n?.minimum??0},${n?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)},kl=/^-?\d+n?$/,El=/^-?\d+$/,ss=/^-?\d+(?:\.\d+)?$/,Il=/^(?:true|false)$/i,Tl=/^null$/i;var Pl=/^undefined$/i;var Rl=/^[^A-Z]*$/,Nl=/^[^a-z]*$/,$$=/^[0-9a-fA-F]*$/;function gi(n,e){return new RegExp(`^[A-Za-z0-9+/]{${n}}${e}$`)}function yi(n){return new RegExp(`^[A-Za-z0-9_-]{${n}}$`)}var w$=/^[0-9a-fA-F]{32}$/,k$=gi(22,"=="),E$=yi(22),I$=/^[0-9a-fA-F]{40}$/,T$=gi(27,"="),P$=yi(27),R$=/^[0-9a-fA-F]{64}$/,N$=gi(43,"="),z$=yi(43),D$=/^[0-9a-fA-F]{96}$/,C$=gi(64,""),L$=yi(64),A$=/^[0-9a-fA-F]{128}$/,O$=gi(86,"=="),M$=yi(86);var ue=S("$ZodCheck",(n,e)=>{var r;n._zod??(n._zod={}),n._zod.def=e,(r=n._zod).onattach??(r.onattach=[])}),Fg={number:"number",bigint:"bigint",object:"date"},as=S("$ZodCheckLessThan",(n,e)=>{ue.init(n,e);let r=Fg[typeof e.value];n._zod.onattach.push(i=>{let t=i._zod.bag,o=(e.inclusive?t.maximum:t.exclusiveMaximum)??Number.POSITIVE_INFINITY;e.value<o&&(e.inclusive?t.maximum=e.value:t.exclusiveMaximum=e.value)}),n._zod.check=i=>{(e.inclusive?i.value<=e.value:i.value<e.value)||i.issues.push({origin:r,code:"too_big",maximum:typeof e.value=="object"?e.value.getTime():e.value,input:i.value,inclusive:e.inclusive,inst:n,continue:!e.abort})}}),cs=S("$ZodCheckGreaterThan",(n,e)=>{ue.init(n,e);let r=Fg[typeof e.value];n._zod.onattach.push(i=>{let t=i._zod.bag,o=(e.inclusive?t.minimum:t.exclusiveMinimum)??Number.NEGATIVE_INFINITY;e.value>o&&(e.inclusive?t.minimum=e.value:t.exclusiveMinimum=e.value)}),n._zod.check=i=>{(e.inclusive?i.value>=e.value:i.value>e.value)||i.issues.push({origin:r,code:"too_small",minimum:typeof e.value=="object"?e.value.getTime():e.value,input:i.value,inclusive:e.inclusive,inst:n,continue:!e.abort})}}),zl=S("$ZodCheckMultipleOf",(n,e)=>{ue.init(n,e),n._zod.onattach.push(r=>{var i;(i=r._zod.bag).multipleOf??(i.multipleOf=e.value)}),n._zod.check=r=>{if(typeof r.value!=typeof e.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%e.value===BigInt(0):Gc(r.value,e.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:e.value,input:r.value,inst:n,continue:!e.abort})}}),Dl=S("$ZodCheckNumberFormat",(n,e)=>{ue.init(n,e),e.format=e.format||"float64";let r=e.format?.includes("int"),i=r?"int":"number",[t,o]=Xc[e.format];n._zod.onattach.push(s=>{let a=s._zod.bag;a.format=e.format,a.minimum=t,a.maximum=o,r&&(a.pattern=El)}),n._zod.check=s=>{let a=s.value;if(r){if(!Number.isInteger(a)){s.issues.push({expected:i,format:e.format,code:"invalid_type",continue:!1,input:a,inst:n});return}if(!Number.isSafeInteger(a)){a>0?s.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:n,origin:i,inclusive:!0,continue:!e.abort}):s.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:n,origin:i,inclusive:!0,continue:!e.abort});return}}a<t&&s.issues.push({origin:"number",input:a,code:"too_small",minimum:t,inclusive:!0,inst:n,continue:!e.abort}),a>o&&s.issues.push({origin:"number",input:a,code:"too_big",maximum:o,inclusive:!0,inst:n,continue:!e.abort})}}),Cl=S("$ZodCheckBigIntFormat",(n,e)=>{ue.init(n,e);let[r,i]=Qc[e.format];n._zod.onattach.push(t=>{let o=t._zod.bag;o.format=e.format,o.minimum=r,o.maximum=i}),n._zod.check=t=>{let o=t.value;o<r&&t.issues.push({origin:"bigint",input:o,code:"too_small",minimum:r,inclusive:!0,inst:n,continue:!e.abort}),o>i&&t.issues.push({origin:"bigint",input:o,code:"too_big",maximum:i,inclusive:!0,inst:n,continue:!e.abort})}}),Ll=S("$ZodCheckMaxSize",(n,e)=>{var r;ue.init(n,e),(r=n._zod.def).when??(r.when=i=>{let t=i.value;return!en(t)&&t.size!==void 0}),n._zod.onattach.push(i=>{let t=i._zod.bag.maximum??Number.POSITIVE_INFINITY;e.maximum<t&&(i._zod.bag.maximum=e.maximum)}),n._zod.check=i=>{let t=i.value;t.size<=e.maximum||i.issues.push({origin:di(t),code:"too_big",maximum:e.maximum,inclusive:!0,input:t,inst:n,continue:!e.abort})}}),Al=S("$ZodCheckMinSize",(n,e)=>{var r;ue.init(n,e),(r=n._zod.def).when??(r.when=i=>{let t=i.value;return!en(t)&&t.size!==void 0}),n._zod.onattach.push(i=>{let t=i._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>t&&(i._zod.bag.minimum=e.minimum)}),n._zod.check=i=>{let t=i.value;t.size>=e.minimum||i.issues.push({origin:di(t),code:"too_small",minimum:e.minimum,inclusive:!0,input:t,inst:n,continue:!e.abort})}}),Ol=S("$ZodCheckSizeEquals",(n,e)=>{var r;ue.init(n,e),(r=n._zod.def).when??(r.when=i=>{let t=i.value;return!en(t)&&t.size!==void 0}),n._zod.onattach.push(i=>{let t=i._zod.bag;t.minimum=e.size,t.maximum=e.size,t.size=e.size}),n._zod.check=i=>{let t=i.value,o=t.size;if(o===e.size)return;let s=o>e.size;i.issues.push({origin:di(t),...s?{code:"too_big",maximum:e.size}:{code:"too_small",minimum:e.size},inclusive:!0,exact:!0,input:i.value,inst:n,continue:!e.abort})}}),Ml=S("$ZodCheckMaxLength",(n,e)=>{var r;ue.init(n,e),(r=n._zod.def).when??(r.when=i=>{let t=i.value;return!en(t)&&t.length!==void 0}),n._zod.onattach.push(i=>{let t=i._zod.bag.maximum??Number.POSITIVE_INFINITY;e.maximum<t&&(i._zod.bag.maximum=e.maximum)}),n._zod.check=i=>{let t=i.value;if(t.length<=e.maximum)return;let s=pi(t);i.issues.push({origin:s,code:"too_big",maximum:e.maximum,inclusive:!0,input:t,inst:n,continue:!e.abort})}}),jl=S("$ZodCheckMinLength",(n,e)=>{var r;ue.init(n,e),(r=n._zod.def).when??(r.when=i=>{let t=i.value;return!en(t)&&t.length!==void 0}),n._zod.onattach.push(i=>{let t=i._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>t&&(i._zod.bag.minimum=e.minimum)}),n._zod.check=i=>{let t=i.value;if(t.length>=e.minimum)return;let s=pi(t);i.issues.push({origin:s,code:"too_small",minimum:e.minimum,inclusive:!0,input:t,inst:n,continue:!e.abort})}}),Ul=S("$ZodCheckLengthEquals",(n,e)=>{var r;ue.init(n,e),(r=n._zod.def).when??(r.when=i=>{let t=i.value;return!en(t)&&t.length!==void 0}),n._zod.onattach.push(i=>{let t=i._zod.bag;t.minimum=e.length,t.maximum=e.length,t.length=e.length}),n._zod.check=i=>{let t=i.value,o=t.length;if(o===e.length)return;let s=pi(t),a=o>e.length;i.issues.push({origin:s,...a?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length},inclusive:!0,exact:!0,input:i.value,inst:n,continue:!e.abort})}}),dr=S("$ZodCheckStringFormat",(n,e)=>{var r,i;ue.init(n,e),n._zod.onattach.push(t=>{let o=t._zod.bag;o.format=e.format,e.pattern&&(o.patterns??(o.patterns=new Set),o.patterns.add(e.pattern))}),e.pattern?(r=n._zod).check??(r.check=t=>{e.pattern.lastIndex=0,!e.pattern.test(t.value)&&t.issues.push({origin:"string",code:"invalid_format",format:e.format,input:t.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:n,continue:!e.abort})}):(i=n._zod).check??(i.check=()=>{})}),Fl=S("$ZodCheckRegex",(n,e)=>{dr.init(n,e),n._zod.check=r=>{e.pattern.lastIndex=0,!e.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:e.pattern.toString(),inst:n,continue:!e.abort})}}),Zl=S("$ZodCheckLowerCase",(n,e)=>{e.pattern??(e.pattern=Rl),dr.init(n,e)}),Hl=S("$ZodCheckUpperCase",(n,e)=>{e.pattern??(e.pattern=Nl),dr.init(n,e)}),Wl=S("$ZodCheckIncludes",(n,e)=>{ue.init(n,e);let r=tt(e.includes),i=new RegExp(typeof e.position=="number"?`^.{${e.position}}${r}`:r);e.pattern=i,n._zod.onattach.push(t=>{let o=t._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(i)}),n._zod.check=t=>{t.value.includes(e.includes,e.position)||t.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:e.includes,input:t.value,inst:n,continue:!e.abort})}}),Bl=S("$ZodCheckStartsWith",(n,e)=>{ue.init(n,e);let r=new RegExp(`^${tt(e.prefix)}.*`);e.pattern??(e.pattern=r),n._zod.onattach.push(i=>{let t=i._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(r)}),n._zod.check=i=>{i.value.startsWith(e.prefix)||i.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:e.prefix,input:i.value,inst:n,continue:!e.abort})}}),Gl=S("$ZodCheckEndsWith",(n,e)=>{ue.init(n,e);let r=new RegExp(`.*${tt(e.suffix)}$`);e.pattern??(e.pattern=r),n._zod.onattach.push(i=>{let t=i._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(r)}),n._zod.check=i=>{i.value.endsWith(e.suffix)||i.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:e.suffix,input:i.value,inst:n,continue:!e.abort})}});function Ug(n,e,r){n.issues.length&&e.issues.push(...Je(r,n.issues))}var Jl=S("$ZodCheckProperty",(n,e)=>{ue.init(n,e),n._zod.check=r=>{let i=e.schema._zod.run({value:r.value[e.property],issues:[]},{});if(i instanceof Promise)return i.then(t=>Ug(t,r,e.property));Ug(i,r,e.property)}}),ql=S("$ZodCheckMimeType",(n,e)=>{ue.init(n,e);let r=new Set(e.mime);n._zod.onattach.push(i=>{i._zod.bag.mime=e.mime}),n._zod.check=i=>{r.has(i.value.type)||i.issues.push({code:"invalid_value",values:e.mime,input:i.value.type,inst:n,continue:!e.abort})}}),Vl=S("$ZodCheckOverwrite",(n,e)=>{ue.init(n,e),n._zod.check=r=>{r.value=e.tx(r.value)}});var vi=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e=="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let i=e.split(`
729
+ `).filter(s=>s),t=Math.min(...i.map(s=>s.length-s.trimStart().length)),o=i.map(s=>s.slice(t)).map(s=>" ".repeat(this.indent*2)+s);for(let s of o)this.content.push(s)}compile(){let e=Function,r=this?.args,t=[...(this?.content??[""]).map(o=>` ${o}`)];return new e(...r,t.join(`
730
+ `))}};var Kl={major:4,minor:3,patch:6};var Y=S("$ZodType",(n,e)=>{var r;n??(n={}),n._zod.def=e,n._zod.bag=n._zod.bag||{},n._zod.version=Kl;let i=[...n._zod.def.checks??[]];n._zod.traits.has("$ZodCheck")&&i.unshift(n);for(let t of i)for(let o of t._zod.onattach)o(n);if(i.length===0)(r=n._zod).deferred??(r.deferred=[]),n._zod.deferred?.push(()=>{n._zod.run=n._zod.parse});else{let t=(s,a,c)=>{let l=rn(s),u;for(let d of a){if(d._zod.def.when){if(!d._zod.def.when(s))continue}else if(l)continue;let p=s.issues.length,m=d._zod.check(s);if(m instanceof Promise&&c?.async===!1)throw new pt;if(u||m instanceof Promise)u=(u??Promise.resolve()).then(async()=>{await m,s.issues.length!==p&&(l||(l=rn(s,p)))});else{if(s.issues.length===p)continue;l||(l=rn(s,p))}}return u?u.then(()=>s):s},o=(s,a,c)=>{if(rn(s))return s.aborted=!0,s;let l=t(a,i,c);if(l instanceof Promise){if(c.async===!1)throw new pt;return l.then(u=>n._zod.parse(u,c))}return n._zod.parse(l,c)};n._zod.run=(s,a)=>{if(a.skipChecks)return n._zod.parse(s,a);if(a.direction==="backward"){let l=n._zod.parse({value:s.value,issues:[]},{...a,skipChecks:!0});return l instanceof Promise?l.then(u=>o(u,s,a)):o(l,s,a)}let c=n._zod.parse(s,a);if(c instanceof Promise){if(a.async===!1)throw new pt;return c.then(l=>t(l,i,a))}return t(c,i,a)}}te(n,"~standard",()=>({validate:t=>{try{let o=nl(n,t);return o.success?{value:o.data}:{issues:o.error?.issues}}catch{return rl(n,t).then(s=>s.success?{value:s.data}:{issues:s.error?.issues})}},vendor:"zod",version:1}))}),Dn=S("$ZodString",(n,e)=>{Y.init(n,e),n._zod.pattern=[...n?._zod.bag?.patterns??[]].pop()??wl(n._zod.bag),n._zod.parse=(r,i)=>{if(e.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:n}),r}}),oe=S("$ZodStringFormat",(n,e)=>{dr.init(n,e),Dn.init(n,e)}),Xl=S("$ZodGUID",(n,e)=>{e.pattern??(e.pattern=dl),oe.init(n,e)}),Ql=S("$ZodUUID",(n,e)=>{if(e.version){let i={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[e.version];if(i===void 0)throw new Error(`Invalid UUID version: "${e.version}"`);e.pattern??(e.pattern=zn(i))}else e.pattern??(e.pattern=zn());oe.init(n,e)}),eu=S("$ZodEmail",(n,e)=>{e.pattern??(e.pattern=pl),oe.init(n,e)}),tu=S("$ZodURL",(n,e)=>{oe.init(n,e),n._zod.check=r=>{try{let i=r.value.trim(),t=new URL(i);e.hostname&&(e.hostname.lastIndex=0,e.hostname.test(t.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:e.hostname.source,input:r.value,inst:n,continue:!e.abort})),e.protocol&&(e.protocol.lastIndex=0,e.protocol.test(t.protocol.endsWith(":")?t.protocol.slice(0,-1):t.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:e.protocol.source,input:r.value,inst:n,continue:!e.abort})),e.normalize?r.value=t.href:r.value=i;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:n,continue:!e.abort})}}}),nu=S("$ZodEmoji",(n,e)=>{e.pattern??(e.pattern=ml()),oe.init(n,e)}),ru=S("$ZodNanoID",(n,e)=>{e.pattern??(e.pattern=ll),oe.init(n,e)}),iu=S("$ZodCUID",(n,e)=>{e.pattern??(e.pattern=il),oe.init(n,e)}),ou=S("$ZodCUID2",(n,e)=>{e.pattern??(e.pattern=ol),oe.init(n,e)}),su=S("$ZodULID",(n,e)=>{e.pattern??(e.pattern=sl),oe.init(n,e)}),au=S("$ZodXID",(n,e)=>{e.pattern??(e.pattern=al),oe.init(n,e)}),cu=S("$ZodKSUID",(n,e)=>{e.pattern??(e.pattern=cl),oe.init(n,e)}),lu=S("$ZodISODateTime",(n,e)=>{e.pattern??(e.pattern=$l(e)),oe.init(n,e)}),uu=S("$ZodISODate",(n,e)=>{e.pattern??(e.pattern=xl),oe.init(n,e)}),du=S("$ZodISOTime",(n,e)=>{e.pattern??(e.pattern=Sl(e)),oe.init(n,e)}),pu=S("$ZodISODuration",(n,e)=>{e.pattern??(e.pattern=ul),oe.init(n,e)}),mu=S("$ZodIPv4",(n,e)=>{e.pattern??(e.pattern=fl),oe.init(n,e),n._zod.bag.format="ipv4"}),fu=S("$ZodIPv6",(n,e)=>{e.pattern??(e.pattern=hl),oe.init(n,e),n._zod.bag.format="ipv6",n._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:n,continue:!e.abort})}}}),hu=S("$ZodMAC",(n,e)=>{e.pattern??(e.pattern=gl(e.delimiter)),oe.init(n,e),n._zod.bag.format="mac"}),gu=S("$ZodCIDRv4",(n,e)=>{e.pattern??(e.pattern=yl),oe.init(n,e)}),yu=S("$ZodCIDRv6",(n,e)=>{e.pattern??(e.pattern=vl),oe.init(n,e),n._zod.check=r=>{let i=r.value.split("/");try{if(i.length!==2)throw new Error;let[t,o]=i;if(!o)throw new Error;let s=Number(o);if(`${s}`!==o)throw new Error;if(s<0||s>128)throw new Error;new URL(`http://[${t}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:n,continue:!e.abort})}}});function vu(n){if(n==="")return!0;if(n.length%4!==0)return!1;try{return atob(n),!0}catch{return!1}}var bu=S("$ZodBase64",(n,e)=>{e.pattern??(e.pattern=bl),oe.init(n,e),n._zod.bag.contentEncoding="base64",n._zod.check=r=>{vu(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:n,continue:!e.abort})}});function ey(n){if(!os.test(n))return!1;let e=n.replace(/[-_]/g,i=>i==="-"?"+":"/"),r=e.padEnd(Math.ceil(e.length/4)*4,"=");return vu(r)}var _u=S("$ZodBase64URL",(n,e)=>{e.pattern??(e.pattern=os),oe.init(n,e),n._zod.bag.contentEncoding="base64url",n._zod.check=r=>{ey(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:n,continue:!e.abort})}}),xu=S("$ZodE164",(n,e)=>{e.pattern??(e.pattern=_l),oe.init(n,e)});function ty(n,e=null){try{let r=n.split(".");if(r.length!==3)return!1;let[i]=r;if(!i)return!1;let t=JSON.parse(atob(i));return!("typ"in t&&t?.typ!=="JWT"||!t.alg||e&&(!("alg"in t)||t.alg!==e))}catch{return!1}}var Su=S("$ZodJWT",(n,e)=>{oe.init(n,e),n._zod.check=r=>{ty(r.value,e.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:n,continue:!e.abort})}}),$u=S("$ZodCustomStringFormat",(n,e)=>{oe.init(n,e),n._zod.check=r=>{e.fn(r.value)||r.issues.push({code:"invalid_format",format:e.format,input:r.value,inst:n,continue:!e.abort})}}),fs=S("$ZodNumber",(n,e)=>{Y.init(n,e),n._zod.pattern=n._zod.bag.pattern??ss,n._zod.parse=(r,i)=>{if(e.coerce)try{r.value=Number(r.value)}catch{}let t=r.value;if(typeof t=="number"&&!Number.isNaN(t)&&Number.isFinite(t))return r;let o=typeof t=="number"?Number.isNaN(t)?"NaN":Number.isFinite(t)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:t,inst:n,...o?{received:o}:{}}),r}}),wu=S("$ZodNumberFormat",(n,e)=>{Dl.init(n,e),fs.init(n,e)}),bi=S("$ZodBoolean",(n,e)=>{Y.init(n,e),n._zod.pattern=Il,n._zod.parse=(r,i)=>{if(e.coerce)try{r.value=!!r.value}catch{}let t=r.value;return typeof t=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:t,inst:n}),r}}),hs=S("$ZodBigInt",(n,e)=>{Y.init(n,e),n._zod.pattern=kl,n._zod.parse=(r,i)=>{if(e.coerce)try{r.value=BigInt(r.value)}catch{}return typeof r.value=="bigint"||r.issues.push({expected:"bigint",code:"invalid_type",input:r.value,inst:n}),r}}),ku=S("$ZodBigIntFormat",(n,e)=>{Cl.init(n,e),hs.init(n,e)}),Eu=S("$ZodSymbol",(n,e)=>{Y.init(n,e),n._zod.parse=(r,i)=>{let t=r.value;return typeof t=="symbol"||r.issues.push({expected:"symbol",code:"invalid_type",input:t,inst:n}),r}}),Iu=S("$ZodUndefined",(n,e)=>{Y.init(n,e),n._zod.pattern=Pl,n._zod.values=new Set([void 0]),n._zod.optin="optional",n._zod.optout="optional",n._zod.parse=(r,i)=>{let t=r.value;return typeof t>"u"||r.issues.push({expected:"undefined",code:"invalid_type",input:t,inst:n}),r}}),Tu=S("$ZodNull",(n,e)=>{Y.init(n,e),n._zod.pattern=Tl,n._zod.values=new Set([null]),n._zod.parse=(r,i)=>{let t=r.value;return t===null||r.issues.push({expected:"null",code:"invalid_type",input:t,inst:n}),r}}),Pu=S("$ZodAny",(n,e)=>{Y.init(n,e),n._zod.parse=r=>r}),Ru=S("$ZodUnknown",(n,e)=>{Y.init(n,e),n._zod.parse=r=>r}),Nu=S("$ZodNever",(n,e)=>{Y.init(n,e),n._zod.parse=(r,i)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:n}),r)}),zu=S("$ZodVoid",(n,e)=>{Y.init(n,e),n._zod.parse=(r,i)=>{let t=r.value;return typeof t>"u"||r.issues.push({expected:"void",code:"invalid_type",input:t,inst:n}),r}}),Du=S("$ZodDate",(n,e)=>{Y.init(n,e),n._zod.parse=(r,i)=>{if(e.coerce)try{r.value=new Date(r.value)}catch{}let t=r.value,o=t instanceof Date;return o&&!Number.isNaN(t.getTime())||r.issues.push({expected:"date",code:"invalid_type",input:t,...o?{received:"Invalid Date"}:{},inst:n}),r}});function Hg(n,e,r){n.issues.length&&e.issues.push(...Je(r,n.issues)),e.value[r]=n.value}var Cu=S("$ZodArray",(n,e)=>{Y.init(n,e),n._zod.parse=(r,i)=>{let t=r.value;if(!Array.isArray(t))return r.issues.push({expected:"array",code:"invalid_type",input:t,inst:n}),r;r.value=Array(t.length);let o=[];for(let s=0;s<t.length;s++){let a=t[s],c=e.element._zod.run({value:a,issues:[]},i);c instanceof Promise?o.push(c.then(l=>Hg(l,r,s))):Hg(c,r,s)}return o.length?Promise.all(o).then(()=>r):r}});function ms(n,e,r,i,t){if(n.issues.length){if(t&&!(r in i))return;e.issues.push(...Je(r,n.issues))}n.value===void 0?r in i&&(e.value[r]=void 0):e.value[r]=n.value}function ny(n){let e=Object.keys(n.shape);for(let i of e)if(!n.shape?.[i]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${i}": expected a Zod schema`);let r=Yc(n.shape);return{...n,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(r)}}function ry(n,e,r,i,t,o){let s=[],a=t.keySet,c=t.catchall._zod,l=c.def.type,u=c.optout==="optional";for(let d in e){if(a.has(d))continue;if(l==="never"){s.push(d);continue}let p=c.run({value:e[d],issues:[]},i);p instanceof Promise?n.push(p.then(m=>ms(m,r,d,e,u))):ms(p,r,d,e,u)}return s.length&&r.issues.push({code:"unrecognized_keys",keys:s,input:e,inst:o}),n.length?Promise.all(n).then(()=>r):r}var iy=S("$ZodObject",(n,e)=>{if(Y.init(n,e),!Object.getOwnPropertyDescriptor(e,"shape")?.get){let a=e.shape;Object.defineProperty(e,"shape",{get:()=>{let c={...a};return Object.defineProperty(e,"shape",{value:c}),c}})}let i=or(()=>ny(e));te(n._zod,"propValues",()=>{let a=e.shape,c={};for(let l in a){let u=a[l]._zod;if(u.values){c[l]??(c[l]=new Set);for(let d of u.values)c[l].add(d)}}return c});let t=Nn,o=e.catchall,s;n._zod.parse=(a,c)=>{s??(s=i.value);let l=a.value;if(!t(l))return a.issues.push({expected:"object",code:"invalid_type",input:l,inst:n}),a;a.value={};let u=[],d=s.shape;for(let p of s.keys){let m=d[p],f=m._zod.optout==="optional",h=m._zod.run({value:l[p],issues:[]},c);h instanceof Promise?u.push(h.then(_=>ms(_,a,p,l,f))):ms(h,a,p,l,f)}return o?ry(u,l,a,c,i.value,n):u.length?Promise.all(u).then(()=>a):a}}),Lu=S("$ZodObjectJIT",(n,e)=>{iy.init(n,e);let r=n._zod.parse,i=or(()=>ny(e)),t=p=>{let m=new vi(["shape","payload","ctx"]),f=i.value,h=k=>{let $=Jo(k);return`shape[${$}]._zod.run({ value: input[${$}], issues: [] }, ctx)`};m.write("const input = payload.value;");let _=Object.create(null),v=0;for(let k of f.keys)_[k]=`key_${v++}`;m.write("const newResult = {};");for(let k of f.keys){let $=_[k],w=Jo(k),P=p[k]?._zod?.optout==="optional";m.write(`const ${$} = ${h(k)};`),P?m.write(`
731
+ if (${$}.issues.length) {
732
+ if (${w} in input) {
733
+ payload.issues = payload.issues.concat(${$}.issues.map(iss => ({
734
+ ...iss,
735
+ path: iss.path ? [${w}, ...iss.path] : [${w}]
736
+ })));
737
+ }
738
+ }
739
+
740
+ if (${$}.value === undefined) {
741
+ if (${w} in input) {
742
+ newResult[${w}] = undefined;
743
+ }
744
+ } else {
745
+ newResult[${w}] = ${$}.value;
746
+ }
747
+
748
+ `):m.write(`
749
+ if (${$}.issues.length) {
750
+ payload.issues = payload.issues.concat(${$}.issues.map(iss => ({
751
+ ...iss,
752
+ path: iss.path ? [${w}, ...iss.path] : [${w}]
753
+ })));
754
+ }
755
+
756
+ if (${$}.value === undefined) {
757
+ if (${w} in input) {
758
+ newResult[${w}] = undefined;
759
+ }
760
+ } else {
761
+ newResult[${w}] = ${$}.value;
762
+ }
763
+
764
+ `)}m.write("payload.value = newResult;"),m.write("return payload;");let y=m.compile();return(k,$)=>y(p,k,$)},o,s=Nn,a=!si.jitless,l=a&&qc.value,u=e.catchall,d;n._zod.parse=(p,m)=>{d??(d=i.value);let f=p.value;return s(f)?a&&l&&m?.async===!1&&m.jitless!==!0?(o||(o=t(e.shape)),p=o(p,m),u?ry([],f,p,m,d,n):p):r(p,m):(p.issues.push({expected:"object",code:"invalid_type",input:f,inst:n}),p)}});function Wg(n,e,r,i){for(let o of n)if(o.issues.length===0)return e.value=o.value,e;let t=n.filter(o=>!rn(o));return t.length===1?(e.value=t[0].value,t[0]):(e.issues.push({code:"invalid_union",input:e.value,inst:r,errors:n.map(o=>o.issues.map(s=>We(s,i,_e())))}),e)}var _i=S("$ZodUnion",(n,e)=>{Y.init(n,e),te(n._zod,"optin",()=>e.options.some(t=>t._zod.optin==="optional")?"optional":void 0),te(n._zod,"optout",()=>e.options.some(t=>t._zod.optout==="optional")?"optional":void 0),te(n._zod,"values",()=>{if(e.options.every(t=>t._zod.values))return new Set(e.options.flatMap(t=>Array.from(t._zod.values)))}),te(n._zod,"pattern",()=>{if(e.options.every(t=>t._zod.pattern)){let t=e.options.map(o=>o._zod.pattern);return new RegExp(`^(${t.map(o=>li(o.source)).join("|")})$`)}});let r=e.options.length===1,i=e.options[0]._zod.run;n._zod.parse=(t,o)=>{if(r)return i(t,o);let s=!1,a=[];for(let c of e.options){let l=c._zod.run({value:t.value,issues:[]},o);if(l instanceof Promise)a.push(l),s=!0;else{if(l.issues.length===0)return l;a.push(l)}}return s?Promise.all(a).then(c=>Wg(c,t,n,o)):Wg(a,t,n,o)}});function Bg(n,e,r,i){let t=n.filter(o=>o.issues.length===0);return t.length===1?(e.value=t[0].value,e):(t.length===0?e.issues.push({code:"invalid_union",input:e.value,inst:r,errors:n.map(o=>o.issues.map(s=>We(s,i,_e())))}):e.issues.push({code:"invalid_union",input:e.value,inst:r,errors:[],inclusive:!1}),e)}var Au=S("$ZodXor",(n,e)=>{_i.init(n,e),e.inclusive=!1;let r=e.options.length===1,i=e.options[0]._zod.run;n._zod.parse=(t,o)=>{if(r)return i(t,o);let s=!1,a=[];for(let c of e.options){let l=c._zod.run({value:t.value,issues:[]},o);l instanceof Promise?(a.push(l),s=!0):a.push(l)}return s?Promise.all(a).then(c=>Bg(c,t,n,o)):Bg(a,t,n,o)}}),Ou=S("$ZodDiscriminatedUnion",(n,e)=>{e.inclusive=!1,_i.init(n,e);let r=n._zod.parse;te(n._zod,"propValues",()=>{let t={};for(let o of e.options){let s=o._zod.propValues;if(!s||Object.keys(s).length===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(o)}"`);for(let[a,c]of Object.entries(s)){t[a]||(t[a]=new Set);for(let l of c)t[a].add(l)}}return t});let i=or(()=>{let t=e.options,o=new Map;for(let s of t){let a=s._zod.propValues?.[e.discriminator];if(!a||a.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(s)}"`);for(let c of a){if(o.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);o.set(c,s)}}return o});n._zod.parse=(t,o)=>{let s=t.value;if(!Nn(s))return t.issues.push({code:"invalid_type",expected:"object",input:s,inst:n}),t;let a=i.value.get(s?.[e.discriminator]);return a?a._zod.run(t,o):e.unionFallback?r(t,o):(t.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:e.discriminator,input:s,path:[e.discriminator],inst:n}),t)}}),Mu=S("$ZodIntersection",(n,e)=>{Y.init(n,e),n._zod.parse=(r,i)=>{let t=r.value,o=e.left._zod.run({value:t,issues:[]},i),s=e.right._zod.run({value:t,issues:[]},i);return o instanceof Promise||s instanceof Promise?Promise.all([o,s]).then(([c,l])=>Gg(r,c,l)):Gg(r,o,s)}});function Yl(n,e){if(n===e)return{valid:!0,data:n};if(n instanceof Date&&e instanceof Date&&+n==+e)return{valid:!0,data:n};if(nn(n)&&nn(e)){let r=Object.keys(e),i=Object.keys(n).filter(o=>r.indexOf(o)!==-1),t={...n,...e};for(let o of i){let s=Yl(n[o],e[o]);if(!s.valid)return{valid:!1,mergeErrorPath:[o,...s.mergeErrorPath]};t[o]=s.data}return{valid:!0,data:t}}if(Array.isArray(n)&&Array.isArray(e)){if(n.length!==e.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let i=0;i<n.length;i++){let t=n[i],o=e[i],s=Yl(t,o);if(!s.valid)return{valid:!1,mergeErrorPath:[i,...s.mergeErrorPath]};r.push(s.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function Gg(n,e,r){let i=new Map,t;for(let a of e.issues)if(a.code==="unrecognized_keys"){t??(t=a);for(let c of a.keys)i.has(c)||i.set(c,{}),i.get(c).l=!0}else n.issues.push(a);for(let a of r.issues)if(a.code==="unrecognized_keys")for(let c of a.keys)i.has(c)||i.set(c,{}),i.get(c).r=!0;else n.issues.push(a);let o=[...i].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(o.length&&t&&n.issues.push({...t,keys:o}),rn(n))return n;let s=Yl(e.value,r.value);if(!s.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(s.mergeErrorPath)}`);return n.value=s.data,n}var gs=S("$ZodTuple",(n,e)=>{Y.init(n,e);let r=e.items;n._zod.parse=(i,t)=>{let o=i.value;if(!Array.isArray(o))return i.issues.push({input:o,inst:n,expected:"tuple",code:"invalid_type"}),i;i.value=[];let s=[],a=[...r].reverse().findIndex(u=>u._zod.optin!=="optional"),c=a===-1?0:r.length-a;if(!e.rest){let u=o.length>r.length,d=o.length<c-1;if(u||d)return i.issues.push({...u?{code:"too_big",maximum:r.length,inclusive:!0}:{code:"too_small",minimum:r.length},input:o,inst:n,origin:"array"}),i}let l=-1;for(let u of r){if(l++,l>=o.length&&l>=c)continue;let d=u._zod.run({value:o[l],issues:[]},t);d instanceof Promise?s.push(d.then(p=>ls(p,i,l))):ls(d,i,l)}if(e.rest){let u=o.slice(r.length);for(let d of u){l++;let p=e.rest._zod.run({value:d,issues:[]},t);p instanceof Promise?s.push(p.then(m=>ls(m,i,l))):ls(p,i,l)}}return s.length?Promise.all(s).then(()=>i):i}});function ls(n,e,r){n.issues.length&&e.issues.push(...Je(r,n.issues)),e.value[r]=n.value}var ju=S("$ZodRecord",(n,e)=>{Y.init(n,e),n._zod.parse=(r,i)=>{let t=r.value;if(!nn(t))return r.issues.push({expected:"record",code:"invalid_type",input:t,inst:n}),r;let o=[],s=e.keyType._zod.values;if(s){r.value={};let a=new Set;for(let l of s)if(typeof l=="string"||typeof l=="number"||typeof l=="symbol"){a.add(typeof l=="number"?l.toString():l);let u=e.valueType._zod.run({value:t[l],issues:[]},i);u instanceof Promise?o.push(u.then(d=>{d.issues.length&&r.issues.push(...Je(l,d.issues)),r.value[l]=d.value})):(u.issues.length&&r.issues.push(...Je(l,u.issues)),r.value[l]=u.value)}let c;for(let l in t)a.has(l)||(c=c??[],c.push(l));c&&c.length>0&&r.issues.push({code:"unrecognized_keys",input:t,inst:n,keys:c})}else{r.value={};for(let a of Reflect.ownKeys(t)){if(a==="__proto__")continue;let c=e.keyType._zod.run({value:a,issues:[]},i);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&ss.test(a)&&c.issues.length){let d=e.keyType._zod.run({value:Number(a),issues:[]},i);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");d.issues.length===0&&(c=d)}if(c.issues.length){e.mode==="loose"?r.value[a]=t[a]:r.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(d=>We(d,i,_e())),input:a,path:[a],inst:n});continue}let u=e.valueType._zod.run({value:t[a],issues:[]},i);u instanceof Promise?o.push(u.then(d=>{d.issues.length&&r.issues.push(...Je(a,d.issues)),r.value[c.value]=d.value})):(u.issues.length&&r.issues.push(...Je(a,u.issues)),r.value[c.value]=u.value)}}return o.length?Promise.all(o).then(()=>r):r}}),Uu=S("$ZodMap",(n,e)=>{Y.init(n,e),n._zod.parse=(r,i)=>{let t=r.value;if(!(t instanceof Map))return r.issues.push({expected:"map",code:"invalid_type",input:t,inst:n}),r;let o=[];r.value=new Map;for(let[s,a]of t){let c=e.keyType._zod.run({value:s,issues:[]},i),l=e.valueType._zod.run({value:a,issues:[]},i);c instanceof Promise||l instanceof Promise?o.push(Promise.all([c,l]).then(([u,d])=>{Jg(u,d,r,s,t,n,i)})):Jg(c,l,r,s,t,n,i)}return o.length?Promise.all(o).then(()=>r):r}});function Jg(n,e,r,i,t,o,s){n.issues.length&&(ui.has(typeof i)?r.issues.push(...Je(i,n.issues)):r.issues.push({code:"invalid_key",origin:"map",input:t,inst:o,issues:n.issues.map(a=>We(a,s,_e()))})),e.issues.length&&(ui.has(typeof i)?r.issues.push(...Je(i,e.issues)):r.issues.push({origin:"map",code:"invalid_element",input:t,inst:o,key:i,issues:e.issues.map(a=>We(a,s,_e()))})),r.value.set(n.value,e.value)}var Fu=S("$ZodSet",(n,e)=>{Y.init(n,e),n._zod.parse=(r,i)=>{let t=r.value;if(!(t instanceof Set))return r.issues.push({input:t,inst:n,expected:"set",code:"invalid_type"}),r;let o=[];r.value=new Set;for(let s of t){let a=e.valueType._zod.run({value:s,issues:[]},i);a instanceof Promise?o.push(a.then(c=>qg(c,r))):qg(a,r)}return o.length?Promise.all(o).then(()=>r):r}});function qg(n,e){n.issues.length&&e.issues.push(...n.issues),e.value.add(n.value)}var Zu=S("$ZodEnum",(n,e)=>{Y.init(n,e);let r=ci(e.entries),i=new Set(r);n._zod.values=i,n._zod.pattern=new RegExp(`^(${r.filter(t=>ui.has(typeof t)).map(t=>typeof t=="string"?tt(t):t.toString()).join("|")})$`),n._zod.parse=(t,o)=>{let s=t.value;return i.has(s)||t.issues.push({code:"invalid_value",values:r,input:s,inst:n}),t}}),Hu=S("$ZodLiteral",(n,e)=>{if(Y.init(n,e),e.values.length===0)throw new Error("Cannot create literal schema with no valid values");let r=new Set(e.values);n._zod.values=r,n._zod.pattern=new RegExp(`^(${e.values.map(i=>typeof i=="string"?tt(i):i?tt(i.toString()):String(i)).join("|")})$`),n._zod.parse=(i,t)=>{let o=i.value;return r.has(o)||i.issues.push({code:"invalid_value",values:e.values,input:o,inst:n}),i}}),Wu=S("$ZodFile",(n,e)=>{Y.init(n,e),n._zod.parse=(r,i)=>{let t=r.value;return t instanceof File||r.issues.push({expected:"file",code:"invalid_type",input:t,inst:n}),r}}),Bu=S("$ZodTransform",(n,e)=>{Y.init(n,e),n._zod.parse=(r,i)=>{if(i.direction==="backward")throw new Qt(n.constructor.name);let t=e.transform(r.value,r);if(i.async)return(t instanceof Promise?t:Promise.resolve(t)).then(s=>(r.value=s,r));if(t instanceof Promise)throw new pt;return r.value=t,r}});function Vg(n,e){return n.issues.length&&e===void 0?{issues:[],value:void 0}:n}var ys=S("$ZodOptional",(n,e)=>{Y.init(n,e),n._zod.optin="optional",n._zod.optout="optional",te(n._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),te(n._zod,"pattern",()=>{let r=e.innerType._zod.pattern;return r?new RegExp(`^(${li(r.source)})?$`):void 0}),n._zod.parse=(r,i)=>{if(e.innerType._zod.optin==="optional"){let t=e.innerType._zod.run(r,i);return t instanceof Promise?t.then(o=>Vg(o,r.value)):Vg(t,r.value)}return r.value===void 0?r:e.innerType._zod.run(r,i)}}),Gu=S("$ZodExactOptional",(n,e)=>{ys.init(n,e),te(n._zod,"values",()=>e.innerType._zod.values),te(n._zod,"pattern",()=>e.innerType._zod.pattern),n._zod.parse=(r,i)=>e.innerType._zod.run(r,i)}),Ju=S("$ZodNullable",(n,e)=>{Y.init(n,e),te(n._zod,"optin",()=>e.innerType._zod.optin),te(n._zod,"optout",()=>e.innerType._zod.optout),te(n._zod,"pattern",()=>{let r=e.innerType._zod.pattern;return r?new RegExp(`^(${li(r.source)}|null)$`):void 0}),te(n._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,null]):void 0),n._zod.parse=(r,i)=>r.value===null?r:e.innerType._zod.run(r,i)}),qu=S("$ZodDefault",(n,e)=>{Y.init(n,e),n._zod.optin="optional",te(n._zod,"values",()=>e.innerType._zod.values),n._zod.parse=(r,i)=>{if(i.direction==="backward")return e.innerType._zod.run(r,i);if(r.value===void 0)return r.value=e.defaultValue,r;let t=e.innerType._zod.run(r,i);return t instanceof Promise?t.then(o=>Kg(o,e)):Kg(t,e)}});function Kg(n,e){return n.value===void 0&&(n.value=e.defaultValue),n}var Vu=S("$ZodPrefault",(n,e)=>{Y.init(n,e),n._zod.optin="optional",te(n._zod,"values",()=>e.innerType._zod.values),n._zod.parse=(r,i)=>(i.direction==="backward"||r.value===void 0&&(r.value=e.defaultValue),e.innerType._zod.run(r,i))}),Ku=S("$ZodNonOptional",(n,e)=>{Y.init(n,e),te(n._zod,"values",()=>{let r=e.innerType._zod.values;return r?new Set([...r].filter(i=>i!==void 0)):void 0}),n._zod.parse=(r,i)=>{let t=e.innerType._zod.run(r,i);return t instanceof Promise?t.then(o=>Yg(o,n)):Yg(t,n)}});function Yg(n,e){return!n.issues.length&&n.value===void 0&&n.issues.push({code:"invalid_type",expected:"nonoptional",input:n.value,inst:e}),n}var Yu=S("$ZodSuccess",(n,e)=>{Y.init(n,e),n._zod.parse=(r,i)=>{if(i.direction==="backward")throw new Qt("ZodSuccess");let t=e.innerType._zod.run(r,i);return t instanceof Promise?t.then(o=>(r.value=o.issues.length===0,r)):(r.value=t.issues.length===0,r)}}),Xu=S("$ZodCatch",(n,e)=>{Y.init(n,e),te(n._zod,"optin",()=>e.innerType._zod.optin),te(n._zod,"optout",()=>e.innerType._zod.optout),te(n._zod,"values",()=>e.innerType._zod.values),n._zod.parse=(r,i)=>{if(i.direction==="backward")return e.innerType._zod.run(r,i);let t=e.innerType._zod.run(r,i);return t instanceof Promise?t.then(o=>(r.value=o.value,o.issues.length&&(r.value=e.catchValue({...r,error:{issues:o.issues.map(s=>We(s,i,_e()))},input:r.value}),r.issues=[]),r)):(r.value=t.value,t.issues.length&&(r.value=e.catchValue({...r,error:{issues:t.issues.map(o=>We(o,i,_e()))},input:r.value}),r.issues=[]),r)}}),Qu=S("$ZodNaN",(n,e)=>{Y.init(n,e),n._zod.parse=(r,i)=>((typeof r.value!="number"||!Number.isNaN(r.value))&&r.issues.push({input:r.value,inst:n,expected:"nan",code:"invalid_type"}),r)}),ed=S("$ZodPipe",(n,e)=>{Y.init(n,e),te(n._zod,"values",()=>e.in._zod.values),te(n._zod,"optin",()=>e.in._zod.optin),te(n._zod,"optout",()=>e.out._zod.optout),te(n._zod,"propValues",()=>e.in._zod.propValues),n._zod.parse=(r,i)=>{if(i.direction==="backward"){let o=e.out._zod.run(r,i);return o instanceof Promise?o.then(s=>us(s,e.in,i)):us(o,e.in,i)}let t=e.in._zod.run(r,i);return t instanceof Promise?t.then(o=>us(o,e.out,i)):us(t,e.out,i)}});function us(n,e,r){return n.issues.length?(n.aborted=!0,n):e._zod.run({value:n.value,issues:n.issues},r)}var xi=S("$ZodCodec",(n,e)=>{Y.init(n,e),te(n._zod,"values",()=>e.in._zod.values),te(n._zod,"optin",()=>e.in._zod.optin),te(n._zod,"optout",()=>e.out._zod.optout),te(n._zod,"propValues",()=>e.in._zod.propValues),n._zod.parse=(r,i)=>{if((i.direction||"forward")==="forward"){let o=e.in._zod.run(r,i);return o instanceof Promise?o.then(s=>ds(s,e,i)):ds(o,e,i)}else{let o=e.out._zod.run(r,i);return o instanceof Promise?o.then(s=>ds(s,e,i)):ds(o,e,i)}}});function ds(n,e,r){if(n.issues.length)return n.aborted=!0,n;if((r.direction||"forward")==="forward"){let t=e.transform(n.value,n);return t instanceof Promise?t.then(o=>ps(n,o,e.out,r)):ps(n,t,e.out,r)}else{let t=e.reverseTransform(n.value,n);return t instanceof Promise?t.then(o=>ps(n,o,e.in,r)):ps(n,t,e.in,r)}}function ps(n,e,r,i){return n.issues.length?(n.aborted=!0,n):r._zod.run({value:e,issues:n.issues},i)}var td=S("$ZodReadonly",(n,e)=>{Y.init(n,e),te(n._zod,"propValues",()=>e.innerType._zod.propValues),te(n._zod,"values",()=>e.innerType._zod.values),te(n._zod,"optin",()=>e.innerType?._zod?.optin),te(n._zod,"optout",()=>e.innerType?._zod?.optout),n._zod.parse=(r,i)=>{if(i.direction==="backward")return e.innerType._zod.run(r,i);let t=e.innerType._zod.run(r,i);return t instanceof Promise?t.then(Xg):Xg(t)}});function Xg(n){return n.value=Object.freeze(n.value),n}var nd=S("$ZodTemplateLiteral",(n,e)=>{Y.init(n,e);let r=[];for(let i of e.parts)if(typeof i=="object"&&i!==null){if(!i._zod.pattern)throw new Error(`Invalid template literal part, no pattern found: ${[...i._zod.traits].shift()}`);let t=i._zod.pattern instanceof RegExp?i._zod.pattern.source:i._zod.pattern;if(!t)throw new Error(`Invalid template literal part: ${i._zod.traits}`);let o=t.startsWith("^")?1:0,s=t.endsWith("$")?t.length-1:t.length;r.push(t.slice(o,s))}else if(i===null||Kc.has(typeof i))r.push(tt(`${i}`));else throw new Error(`Invalid template literal part: ${i}`);n._zod.pattern=new RegExp(`^${r.join("")}$`),n._zod.parse=(i,t)=>typeof i.value!="string"?(i.issues.push({input:i.value,inst:n,expected:"string",code:"invalid_type"}),i):(n._zod.pattern.lastIndex=0,n._zod.pattern.test(i.value)||i.issues.push({input:i.value,inst:n,code:"invalid_format",format:e.format??"template_literal",pattern:n._zod.pattern.source}),i)}),rd=S("$ZodFunction",(n,e)=>(Y.init(n,e),n._def=e,n._zod.def=e,n.implement=r=>{if(typeof r!="function")throw new Error("implement() must be called with a function");return function(...i){let t=n._def.input?Vo(n._def.input,i):i,o=Reflect.apply(r,this,t);return n._def.output?Vo(n._def.output,o):o}},n.implementAsync=r=>{if(typeof r!="function")throw new Error("implementAsync() must be called with a function");return async function(...i){let t=n._def.input?await Ko(n._def.input,i):i,o=await Reflect.apply(r,this,t);return n._def.output?await Ko(n._def.output,o):o}},n._zod.parse=(r,i)=>typeof r.value!="function"?(r.issues.push({code:"invalid_type",expected:"function",input:r.value,inst:n}),r):(n._def.output&&n._def.output._zod.def.type==="promise"?r.value=n.implementAsync(r.value):r.value=n.implement(r.value),r),n.input=(...r)=>{let i=n.constructor;return Array.isArray(r[0])?new i({type:"function",input:new gs({type:"tuple",items:r[0],rest:r[1]}),output:n._def.output}):new i({type:"function",input:r[0],output:n._def.output})},n.output=r=>{let i=n.constructor;return new i({type:"function",input:n._def.input,output:r})},n)),id=S("$ZodPromise",(n,e)=>{Y.init(n,e),n._zod.parse=(r,i)=>Promise.resolve(r.value).then(t=>e.innerType._zod.run({value:t,issues:[]},i))}),od=S("$ZodLazy",(n,e)=>{Y.init(n,e),te(n._zod,"innerType",()=>e.getter()),te(n._zod,"pattern",()=>n._zod.innerType?._zod?.pattern),te(n._zod,"propValues",()=>n._zod.innerType?._zod?.propValues),te(n._zod,"optin",()=>n._zod.innerType?._zod?.optin??void 0),te(n._zod,"optout",()=>n._zod.innerType?._zod?.optout??void 0),n._zod.parse=(r,i)=>n._zod.innerType._zod.run(r,i)}),sd=S("$ZodCustom",(n,e)=>{ue.init(n,e),Y.init(n,e),n._zod.parse=(r,i)=>r,n._zod.check=r=>{let i=r.value,t=e.fn(i);if(t instanceof Promise)return t.then(o=>Qg(o,r,i,n));Qg(t,r,i,n)}});function Qg(n,e,r,i){if(!n){let t={code:"custom",input:r,inst:i,path:[...i._zod.def.path??[]],continue:!i._zod.def.abort};i._zod.def.params&&(t.params=i._zod.def.params),e.issues.push(sr(t))}}var $i={};Ke($i,{ar:()=>oy,az:()=>sy,be:()=>cy,bg:()=>ly,ca:()=>uy,cs:()=>dy,da:()=>py,de:()=>my,en:()=>vs,eo:()=>fy,es:()=>hy,fa:()=>gy,fi:()=>yy,fr:()=>vy,frCA:()=>by,he:()=>_y,hu:()=>xy,hy:()=>$y,id:()=>wy,is:()=>ky,it:()=>Ey,ja:()=>Iy,ka:()=>Ty,kh:()=>Py,km:()=>bs,ko:()=>Ry,lt:()=>zy,mk:()=>Dy,ms:()=>Cy,nl:()=>Ly,no:()=>Ay,ota:()=>Oy,pl:()=>jy,ps:()=>My,pt:()=>Uy,ru:()=>Zy,sl:()=>Hy,sv:()=>Wy,ta:()=>By,th:()=>Gy,tr:()=>Jy,ua:()=>qy,uk:()=>_s,ur:()=>Vy,uz:()=>Ky,vi:()=>Yy,yo:()=>ev,zhCN:()=>Xy,zhTW:()=>Qy});var U$=()=>{let n={string:{unit:"\u062D\u0631\u0641",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"},file:{unit:"\u0628\u0627\u064A\u062A",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"},array:{unit:"\u0639\u0646\u0635\u0631",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"},set:{unit:"\u0639\u0646\u0635\u0631",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"}};function e(t){return n[t]??null}let r={regex:"\u0645\u062F\u062E\u0644",email:"\u0628\u0631\u064A\u062F \u0625\u0644\u0643\u062A\u0631\u0648\u0646\u064A",url:"\u0631\u0627\u0628\u0637",emoji:"\u0625\u064A\u0645\u0648\u062C\u064A",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u062A\u0627\u0631\u064A\u062E \u0648\u0648\u0642\u062A \u0628\u0645\u0639\u064A\u0627\u0631 ISO",date:"\u062A\u0627\u0631\u064A\u062E \u0628\u0645\u0639\u064A\u0627\u0631 ISO",time:"\u0648\u0642\u062A \u0628\u0645\u0639\u064A\u0627\u0631 ISO",duration:"\u0645\u062F\u0629 \u0628\u0645\u0639\u064A\u0627\u0631 ISO",ipv4:"\u0639\u0646\u0648\u0627\u0646 IPv4",ipv6:"\u0639\u0646\u0648\u0627\u0646 IPv6",cidrv4:"\u0645\u062F\u0649 \u0639\u0646\u0627\u0648\u064A\u0646 \u0628\u0635\u064A\u063A\u0629 IPv4",cidrv6:"\u0645\u062F\u0649 \u0639\u0646\u0627\u0648\u064A\u0646 \u0628\u0635\u064A\u063A\u0629 IPv6",base64:"\u0646\u064E\u0635 \u0628\u062A\u0631\u0645\u064A\u0632 base64-encoded",base64url:"\u0646\u064E\u0635 \u0628\u062A\u0631\u0645\u064A\u0632 base64url-encoded",json_string:"\u0646\u064E\u0635 \u0639\u0644\u0649 \u0647\u064A\u0626\u0629 JSON",e164:"\u0631\u0642\u0645 \u0647\u0627\u062A\u0641 \u0628\u0645\u0639\u064A\u0627\u0631 E.164",jwt:"JWT",template_literal:"\u0645\u062F\u062E\u0644"},i={nan:"NaN"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=C(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`\u0645\u062F\u062E\u0644\u0627\u062A \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644\u0629: \u064A\u0641\u062A\u0631\u0636 \u0625\u062F\u062E\u0627\u0644 instanceof ${t.expected}\u060C \u0648\u0644\u0643\u0646 \u062A\u0645 \u0625\u062F\u062E\u0627\u0644 ${a}`:`\u0645\u062F\u062E\u0644\u0627\u062A \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644\u0629: \u064A\u0641\u062A\u0631\u0636 \u0625\u062F\u062E\u0627\u0644 ${o}\u060C \u0648\u0644\u0643\u0646 \u062A\u0645 \u0625\u062F\u062E\u0627\u0644 ${a}`}case"invalid_value":return t.values.length===1?`\u0645\u062F\u062E\u0644\u0627\u062A \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644\u0629: \u064A\u0641\u062A\u0631\u0636 \u0625\u062F\u062E\u0627\u0644 ${D(t.values[0])}`:`\u0627\u062E\u062A\u064A\u0627\u0631 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062A\u0648\u0642\u0639 \u0627\u0646\u062A\u0642\u0627\u0621 \u0623\u062D\u062F \u0647\u0630\u0647 \u0627\u0644\u062E\u064A\u0627\u0631\u0627\u062A: ${E(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?` \u0623\u0643\u0628\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0623\u0646 \u062A\u0643\u0648\u0646 ${t.origin??"\u0627\u0644\u0642\u064A\u0645\u0629"} ${o} ${t.maximum.toString()} ${s.unit??"\u0639\u0646\u0635\u0631"}`:`\u0623\u0643\u0628\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0623\u0646 \u062A\u0643\u0648\u0646 ${t.origin??"\u0627\u0644\u0642\u064A\u0645\u0629"} ${o} ${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`\u0623\u0635\u063A\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0644\u0640 ${t.origin} \u0623\u0646 \u064A\u0643\u0648\u0646 ${o} ${t.minimum.toString()} ${s.unit}`:`\u0623\u0635\u063A\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0644\u0640 ${t.origin} \u0623\u0646 \u064A\u0643\u0648\u0646 ${o} ${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0628\u062F\u0623 \u0628\u0640 "${t.prefix}"`:o.format==="ends_with"?`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0646\u062A\u0647\u064A \u0628\u0640 "${o.suffix}"`:o.format==="includes"?`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u062A\u0636\u0645\u0651\u064E\u0646 "${o.includes}"`:o.format==="regex"?`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0637\u0627\u0628\u0642 \u0627\u0644\u0646\u0645\u0637 ${o.pattern}`:`${r[o.format]??t.format} \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644`}case"not_multiple_of":return`\u0631\u0642\u0645 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0645\u0646 \u0645\u0636\u0627\u0639\u0641\u0627\u062A ${t.divisor}`;case"unrecognized_keys":return`\u0645\u0639\u0631\u0641${t.keys.length>1?"\u0627\u062A":""} \u063A\u0631\u064A\u0628${t.keys.length>1?"\u0629":""}: ${E(t.keys,"\u060C ")}`;case"invalid_key":return`\u0645\u0639\u0631\u0641 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644 \u0641\u064A ${t.origin}`;case"invalid_union":return"\u0645\u062F\u062E\u0644 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644";case"invalid_element":return`\u0645\u062F\u062E\u0644 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644 \u0641\u064A ${t.origin}`;default:return"\u0645\u062F\u062E\u0644 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644"}}};function oy(){return{localeError:U$()}}var F$=()=>{let n={string:{unit:"simvol",verb:"olmal\u0131d\u0131r"},file:{unit:"bayt",verb:"olmal\u0131d\u0131r"},array:{unit:"element",verb:"olmal\u0131d\u0131r"},set:{unit:"element",verb:"olmal\u0131d\u0131r"}};function e(t){return n[t]??null}let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"},i={nan:"NaN"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=C(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n instanceof ${t.expected}, daxil olan ${a}`:`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n ${o}, daxil olan ${a}`}case"invalid_value":return t.values.length===1?`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n ${D(t.values[0])}`:`Yanl\u0131\u015F se\xE7im: a\u015Fa\u011F\u0131dak\u0131lardan biri olmal\u0131d\u0131r: ${E(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?`\xC7ox b\xF6y\xFCk: g\xF6zl\u0259nil\u0259n ${t.origin??"d\u0259y\u0259r"} ${o}${t.maximum.toString()} ${s.unit??"element"}`:`\xC7ox b\xF6y\xFCk: g\xF6zl\u0259nil\u0259n ${t.origin??"d\u0259y\u0259r"} ${o}${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`\xC7ox ki\xE7ik: g\xF6zl\u0259nil\u0259n ${t.origin} ${o}${t.minimum.toString()} ${s.unit}`:`\xC7ox ki\xE7ik: g\xF6zl\u0259nil\u0259n ${t.origin} ${o}${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`Yanl\u0131\u015F m\u0259tn: "${o.prefix}" il\u0259 ba\u015Flamal\u0131d\u0131r`:o.format==="ends_with"?`Yanl\u0131\u015F m\u0259tn: "${o.suffix}" il\u0259 bitm\u0259lidir`:o.format==="includes"?`Yanl\u0131\u015F m\u0259tn: "${o.includes}" daxil olmal\u0131d\u0131r`:o.format==="regex"?`Yanl\u0131\u015F m\u0259tn: ${o.pattern} \u015Fablonuna uy\u011Fun olmal\u0131d\u0131r`:`Yanl\u0131\u015F ${r[o.format]??t.format}`}case"not_multiple_of":return`Yanl\u0131\u015F \u0259d\u0259d: ${t.divisor} il\u0259 b\xF6l\xFCn\u0259 bil\u0259n olmal\u0131d\u0131r`;case"unrecognized_keys":return`Tan\u0131nmayan a\xE7ar${t.keys.length>1?"lar":""}: ${E(t.keys,", ")}`;case"invalid_key":return`${t.origin} daxilind\u0259 yanl\u0131\u015F a\xE7ar`;case"invalid_union":return"Yanl\u0131\u015F d\u0259y\u0259r";case"invalid_element":return`${t.origin} daxilind\u0259 yanl\u0131\u015F d\u0259y\u0259r`;default:return"Yanl\u0131\u015F d\u0259y\u0259r"}}};function sy(){return{localeError:F$()}}function ay(n,e,r,i){let t=Math.abs(n),o=t%10,s=t%100;return s>=11&&s<=19?i:o===1?e:o>=2&&o<=4?r:i}var Z$=()=>{let n={string:{unit:{one:"\u0441\u0456\u043C\u0432\u0430\u043B",few:"\u0441\u0456\u043C\u0432\u0430\u043B\u044B",many:"\u0441\u0456\u043C\u0432\u0430\u043B\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"},array:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u044B",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"},set:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u044B",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"},file:{unit:{one:"\u0431\u0430\u0439\u0442",few:"\u0431\u0430\u0439\u0442\u044B",many:"\u0431\u0430\u0439\u0442\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"}};function e(t){return n[t]??null}let r={regex:"\u0443\u0432\u043E\u0434",email:"email \u0430\u0434\u0440\u0430\u0441",url:"URL",emoji:"\u044D\u043C\u043E\u0434\u0437\u0456",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0434\u0430\u0442\u0430 \u0456 \u0447\u0430\u0441",date:"ISO \u0434\u0430\u0442\u0430",time:"ISO \u0447\u0430\u0441",duration:"ISO \u043F\u0440\u0430\u0446\u044F\u0433\u043B\u0430\u0441\u0446\u044C",ipv4:"IPv4 \u0430\u0434\u0440\u0430\u0441",ipv6:"IPv6 \u0430\u0434\u0440\u0430\u0441",cidrv4:"IPv4 \u0434\u044B\u044F\u043F\u0430\u0437\u043E\u043D",cidrv6:"IPv6 \u0434\u044B\u044F\u043F\u0430\u0437\u043E\u043D",base64:"\u0440\u0430\u0434\u043E\u043A \u0443 \u0444\u0430\u0440\u043C\u0430\u0446\u0435 base64",base64url:"\u0440\u0430\u0434\u043E\u043A \u0443 \u0444\u0430\u0440\u043C\u0430\u0446\u0435 base64url",json_string:"JSON \u0440\u0430\u0434\u043E\u043A",e164:"\u043D\u0443\u043C\u0430\u0440 E.164",jwt:"JWT",template_literal:"\u0443\u0432\u043E\u0434"},i={nan:"NaN",number:"\u043B\u0456\u043A",array:"\u043C\u0430\u0441\u0456\u045E"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=C(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434: \u0447\u0430\u043A\u0430\u045E\u0441\u044F instanceof ${t.expected}, \u0430\u0442\u0440\u044B\u043C\u0430\u043D\u0430 ${a}`:`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434: \u0447\u0430\u043A\u0430\u045E\u0441\u044F ${o}, \u0430\u0442\u0440\u044B\u043C\u0430\u043D\u0430 ${a}`}case"invalid_value":return t.values.length===1?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F ${D(t.values[0])}`:`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0432\u0430\u0440\u044B\u044F\u043D\u0442: \u0447\u0430\u043A\u0430\u045E\u0441\u044F \u0430\u0434\u0437\u0456\u043D \u0437 ${E(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);if(s){let a=Number(t.maximum),c=ay(a,s.unit.one,s.unit.few,s.unit.many);return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u0432\u044F\u043B\u0456\u043A\u0456: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${t.origin??"\u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435"} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 ${s.verb} ${o}${t.maximum.toString()} ${c}`}return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u0432\u044F\u043B\u0456\u043A\u0456: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${t.origin??"\u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435"} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 \u0431\u044B\u0446\u044C ${o}${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);if(s){let a=Number(t.minimum),c=ay(a,s.unit.one,s.unit.few,s.unit.many);return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u043C\u0430\u043B\u044B: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${t.origin} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 ${s.verb} ${o}${t.minimum.toString()} ${c}`}return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u043C\u0430\u043B\u044B: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${t.origin} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 \u0431\u044B\u0446\u044C ${o}${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u043F\u0430\u0447\u044B\u043D\u0430\u0446\u0446\u0430 \u0437 "${o.prefix}"`:o.format==="ends_with"?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0437\u0430\u043A\u0430\u043D\u0447\u0432\u0430\u0446\u0446\u0430 \u043D\u0430 "${o.suffix}"`:o.format==="includes"?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0437\u043C\u044F\u0448\u0447\u0430\u0446\u044C "${o.includes}"`:o.format==="regex"?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0430\u0434\u043F\u0430\u0432\u044F\u0434\u0430\u0446\u044C \u0448\u0430\u0431\u043B\u043E\u043D\u0443 ${o.pattern}`:`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B ${r[o.format]??t.format}`}case"not_multiple_of":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u043B\u0456\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0431\u044B\u0446\u044C \u043A\u0440\u0430\u0442\u043D\u044B\u043C ${t.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0441\u043F\u0430\u0437\u043D\u0430\u043D\u044B ${t.keys.length>1?"\u043A\u043B\u044E\u0447\u044B":"\u043A\u043B\u044E\u0447"}: ${E(t.keys,", ")}`;case"invalid_key":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u043A\u043B\u044E\u0447 \u0443 ${t.origin}`;case"invalid_union":return"\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434";case"invalid_element":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u0430\u0435 \u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435 \u045E ${t.origin}`;default:return"\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434"}}};function cy(){return{localeError:Z$()}}var H$=()=>{let n={string:{unit:"\u0441\u0438\u043C\u0432\u043E\u043B\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"},file:{unit:"\u0431\u0430\u0439\u0442\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"},array:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"},set:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"}};function e(t){return n[t]??null}let r={regex:"\u0432\u0445\u043E\u0434",email:"\u0438\u043C\u0435\u0439\u043B \u0430\u0434\u0440\u0435\u0441",url:"URL",emoji:"\u0435\u043C\u043E\u0434\u0436\u0438",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0432\u0440\u0435\u043C\u0435",date:"ISO \u0434\u0430\u0442\u0430",time:"ISO \u0432\u0440\u0435\u043C\u0435",duration:"ISO \u043F\u0440\u043E\u0434\u044A\u043B\u0436\u0438\u0442\u0435\u043B\u043D\u043E\u0441\u0442",ipv4:"IPv4 \u0430\u0434\u0440\u0435\u0441",ipv6:"IPv6 \u0430\u0434\u0440\u0435\u0441",cidrv4:"IPv4 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",cidrv6:"IPv6 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",base64:"base64-\u043A\u043E\u0434\u0438\u0440\u0430\u043D \u043D\u0438\u0437",base64url:"base64url-\u043A\u043E\u0434\u0438\u0440\u0430\u043D \u043D\u0438\u0437",json_string:"JSON \u043D\u0438\u0437",e164:"E.164 \u043D\u043E\u043C\u0435\u0440",jwt:"JWT",template_literal:"\u0432\u0445\u043E\u0434"},i={nan:"NaN",number:"\u0447\u0438\u0441\u043B\u043E",array:"\u043C\u0430\u0441\u0438\u0432"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=C(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434: \u043E\u0447\u0430\u043A\u0432\u0430\u043D instanceof ${t.expected}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D ${a}`:`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434: \u043E\u0447\u0430\u043A\u0432\u0430\u043D ${o}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D ${a}`}case"invalid_value":return t.values.length===1?`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434: \u043E\u0447\u0430\u043A\u0432\u0430\u043D ${D(t.values[0])}`:`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430 \u043E\u043F\u0446\u0438\u044F: \u043E\u0447\u0430\u043A\u0432\u0430\u043D\u043E \u0435\u0434\u043D\u043E \u043E\u0442 ${E(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?`\u0422\u0432\u044A\u0440\u0434\u0435 \u0433\u043E\u043B\u044F\u043C\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${t.origin??"\u0441\u0442\u043E\u0439\u043D\u043E\u0441\u0442"} \u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430 ${o}${t.maximum.toString()} ${s.unit??"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0430"}`:`\u0422\u0432\u044A\u0440\u0434\u0435 \u0433\u043E\u043B\u044F\u043C\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${t.origin??"\u0441\u0442\u043E\u0439\u043D\u043E\u0441\u0442"} \u0434\u0430 \u0431\u044A\u0434\u0435 ${o}${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`\u0422\u0432\u044A\u0440\u0434\u0435 \u043C\u0430\u043B\u043A\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${t.origin} \u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430 ${o}${t.minimum.toString()} ${s.unit}`:`\u0422\u0432\u044A\u0440\u0434\u0435 \u043C\u0430\u043B\u043A\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${t.origin} \u0434\u0430 \u0431\u044A\u0434\u0435 ${o}${t.minimum.toString()}`}case"invalid_format":{let o=t;if(o.format==="starts_with")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0437\u0430\u043F\u043E\u0447\u0432\u0430 \u0441 "${o.prefix}"`;if(o.format==="ends_with")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0437\u0430\u0432\u044A\u0440\u0448\u0432\u0430 \u0441 "${o.suffix}"`;if(o.format==="includes")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0432\u043A\u043B\u044E\u0447\u0432\u0430 "${o.includes}"`;if(o.format==="regex")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0441\u044A\u0432\u043F\u0430\u0434\u0430 \u0441 ${o.pattern}`;let s="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D";return o.format==="emoji"&&(s="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E"),o.format==="datetime"&&(s="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E"),o.format==="date"&&(s="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430"),o.format==="time"&&(s="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E"),o.format==="duration"&&(s="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430"),`${s} ${r[o.format]??t.format}`}case"not_multiple_of":return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E \u0447\u0438\u0441\u043B\u043E: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0431\u044A\u0434\u0435 \u043A\u0440\u0430\u0442\u043D\u043E \u043D\u0430 ${t.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0437\u043F\u043E\u0437\u043D\u0430\u0442${t.keys.length>1?"\u0438":""} \u043A\u043B\u044E\u0447${t.keys.length>1?"\u043E\u0432\u0435":""}: ${E(t.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043A\u043B\u044E\u0447 \u0432 ${t.origin}`;case"invalid_union":return"\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434";case"invalid_element":return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430 \u0441\u0442\u043E\u0439\u043D\u043E\u0441\u0442 \u0432 ${t.origin}`;default:return"\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434"}}};function ly(){return{localeError:H$()}}var W$=()=>{let n={string:{unit:"car\xE0cters",verb:"contenir"},file:{unit:"bytes",verb:"contenir"},array:{unit:"elements",verb:"contenir"},set:{unit:"elements",verb:"contenir"}};function e(t){return n[t]??null}let r={regex:"entrada",email:"adre\xE7a electr\xF2nica",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data i hora ISO",date:"data ISO",time:"hora ISO",duration:"durada ISO",ipv4:"adre\xE7a IPv4",ipv6:"adre\xE7a IPv6",cidrv4:"rang IPv4",cidrv6:"rang IPv6",base64:"cadena codificada en base64",base64url:"cadena codificada en base64url",json_string:"cadena JSON",e164:"n\xFAmero E.164",jwt:"JWT",template_literal:"entrada"},i={nan:"NaN"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=C(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`Tipus inv\xE0lid: s'esperava instanceof ${t.expected}, s'ha rebut ${a}`:`Tipus inv\xE0lid: s'esperava ${o}, s'ha rebut ${a}`}case"invalid_value":return t.values.length===1?`Valor inv\xE0lid: s'esperava ${D(t.values[0])}`:`Opci\xF3 inv\xE0lida: s'esperava una de ${E(t.values," o ")}`;case"too_big":{let o=t.inclusive?"com a m\xE0xim":"menys de",s=e(t.origin);return s?`Massa gran: s'esperava que ${t.origin??"el valor"} contingu\xE9s ${o} ${t.maximum.toString()} ${s.unit??"elements"}`:`Massa gran: s'esperava que ${t.origin??"el valor"} fos ${o} ${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?"com a m\xEDnim":"m\xE9s de",s=e(t.origin);return s?`Massa petit: s'esperava que ${t.origin} contingu\xE9s ${o} ${t.minimum.toString()} ${s.unit}`:`Massa petit: s'esperava que ${t.origin} fos ${o} ${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`Format inv\xE0lid: ha de comen\xE7ar amb "${o.prefix}"`:o.format==="ends_with"?`Format inv\xE0lid: ha d'acabar amb "${o.suffix}"`:o.format==="includes"?`Format inv\xE0lid: ha d'incloure "${o.includes}"`:o.format==="regex"?`Format inv\xE0lid: ha de coincidir amb el patr\xF3 ${o.pattern}`:`Format inv\xE0lid per a ${r[o.format]??t.format}`}case"not_multiple_of":return`N\xFAmero inv\xE0lid: ha de ser m\xFAltiple de ${t.divisor}`;case"unrecognized_keys":return`Clau${t.keys.length>1?"s":""} no reconeguda${t.keys.length>1?"s":""}: ${E(t.keys,", ")}`;case"invalid_key":return`Clau inv\xE0lida a ${t.origin}`;case"invalid_union":return"Entrada inv\xE0lida";case"invalid_element":return`Element inv\xE0lid a ${t.origin}`;default:return"Entrada inv\xE0lida"}}};function uy(){return{localeError:W$()}}var B$=()=>{let n={string:{unit:"znak\u016F",verb:"m\xEDt"},file:{unit:"bajt\u016F",verb:"m\xEDt"},array:{unit:"prvk\u016F",verb:"m\xEDt"},set:{unit:"prvk\u016F",verb:"m\xEDt"}};function e(t){return n[t]??null}let r={regex:"regul\xE1rn\xED v\xFDraz",email:"e-mailov\xE1 adresa",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"datum a \u010Das ve form\xE1tu ISO",date:"datum ve form\xE1tu ISO",time:"\u010Das ve form\xE1tu ISO",duration:"doba trv\xE1n\xED ISO",ipv4:"IPv4 adresa",ipv6:"IPv6 adresa",cidrv4:"rozsah IPv4",cidrv6:"rozsah IPv6",base64:"\u0159et\u011Bzec zak\xF3dovan\xFD ve form\xE1tu base64",base64url:"\u0159et\u011Bzec zak\xF3dovan\xFD ve form\xE1tu base64url",json_string:"\u0159et\u011Bzec ve form\xE1tu JSON",e164:"\u010D\xEDslo E.164",jwt:"JWT",template_literal:"vstup"},i={nan:"NaN",number:"\u010D\xEDslo",string:"\u0159et\u011Bzec",function:"funkce",array:"pole"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=C(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no instanceof ${t.expected}, obdr\u017Eeno ${a}`:`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no ${o}, obdr\u017Eeno ${a}`}case"invalid_value":return t.values.length===1?`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no ${D(t.values[0])}`:`Neplatn\xE1 mo\u017Enost: o\u010Dek\xE1v\xE1na jedna z hodnot ${E(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?`Hodnota je p\u0159\xEDli\u0161 velk\xE1: ${t.origin??"hodnota"} mus\xED m\xEDt ${o}${t.maximum.toString()} ${s.unit??"prvk\u016F"}`:`Hodnota je p\u0159\xEDli\u0161 velk\xE1: ${t.origin??"hodnota"} mus\xED b\xFDt ${o}${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`Hodnota je p\u0159\xEDli\u0161 mal\xE1: ${t.origin??"hodnota"} mus\xED m\xEDt ${o}${t.minimum.toString()} ${s.unit??"prvk\u016F"}`:`Hodnota je p\u0159\xEDli\u0161 mal\xE1: ${t.origin??"hodnota"} mus\xED b\xFDt ${o}${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED za\u010D\xEDnat na "${o.prefix}"`:o.format==="ends_with"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED kon\u010Dit na "${o.suffix}"`:o.format==="includes"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED obsahovat "${o.includes}"`:o.format==="regex"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED odpov\xEDdat vzoru ${o.pattern}`:`Neplatn\xFD form\xE1t ${r[o.format]??t.format}`}case"not_multiple_of":return`Neplatn\xE9 \u010D\xEDslo: mus\xED b\xFDt n\xE1sobkem ${t.divisor}`;case"unrecognized_keys":return`Nezn\xE1m\xE9 kl\xED\u010De: ${E(t.keys,", ")}`;case"invalid_key":return`Neplatn\xFD kl\xED\u010D v ${t.origin}`;case"invalid_union":return"Neplatn\xFD vstup";case"invalid_element":return`Neplatn\xE1 hodnota v ${t.origin}`;default:return"Neplatn\xFD vstup"}}};function dy(){return{localeError:B$()}}var G$=()=>{let n={string:{unit:"tegn",verb:"havde"},file:{unit:"bytes",verb:"havde"},array:{unit:"elementer",verb:"indeholdt"},set:{unit:"elementer",verb:"indeholdt"}};function e(t){return n[t]??null}let r={regex:"input",email:"e-mailadresse",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dato- og klokkesl\xE6t",date:"ISO-dato",time:"ISO-klokkesl\xE6t",duration:"ISO-varighed",ipv4:"IPv4-omr\xE5de",ipv6:"IPv6-omr\xE5de",cidrv4:"IPv4-spektrum",cidrv6:"IPv6-spektrum",base64:"base64-kodet streng",base64url:"base64url-kodet streng",json_string:"JSON-streng",e164:"E.164-nummer",jwt:"JWT",template_literal:"input"},i={nan:"NaN",string:"streng",number:"tal",boolean:"boolean",array:"liste",object:"objekt",set:"s\xE6t",file:"fil"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=C(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`Ugyldigt input: forventede instanceof ${t.expected}, fik ${a}`:`Ugyldigt input: forventede ${o}, fik ${a}`}case"invalid_value":return t.values.length===1?`Ugyldig v\xE6rdi: forventede ${D(t.values[0])}`:`Ugyldigt valg: forventede en af f\xF8lgende ${E(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin),a=i[t.origin]??t.origin;return s?`For stor: forventede ${a??"value"} ${s.verb} ${o} ${t.maximum.toString()} ${s.unit??"elementer"}`:`For stor: forventede ${a??"value"} havde ${o} ${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin),a=i[t.origin]??t.origin;return s?`For lille: forventede ${a} ${s.verb} ${o} ${t.minimum.toString()} ${s.unit}`:`For lille: forventede ${a} havde ${o} ${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`Ugyldig streng: skal starte med "${o.prefix}"`:o.format==="ends_with"?`Ugyldig streng: skal ende med "${o.suffix}"`:o.format==="includes"?`Ugyldig streng: skal indeholde "${o.includes}"`:o.format==="regex"?`Ugyldig streng: skal matche m\xF8nsteret ${o.pattern}`:`Ugyldig ${r[o.format]??t.format}`}case"not_multiple_of":return`Ugyldigt tal: skal v\xE6re deleligt med ${t.divisor}`;case"unrecognized_keys":return`${t.keys.length>1?"Ukendte n\xF8gler":"Ukendt n\xF8gle"}: ${E(t.keys,", ")}`;case"invalid_key":return`Ugyldig n\xF8gle i ${t.origin}`;case"invalid_union":return"Ugyldigt input: matcher ingen af de tilladte typer";case"invalid_element":return`Ugyldig v\xE6rdi i ${t.origin}`;default:return"Ugyldigt input"}}};function py(){return{localeError:G$()}}var J$=()=>{let n={string:{unit:"Zeichen",verb:"zu haben"},file:{unit:"Bytes",verb:"zu haben"},array:{unit:"Elemente",verb:"zu haben"},set:{unit:"Elemente",verb:"zu haben"}};function e(t){return n[t]??null}let r={regex:"Eingabe",email:"E-Mail-Adresse",url:"URL",emoji:"Emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-Datum und -Uhrzeit",date:"ISO-Datum",time:"ISO-Uhrzeit",duration:"ISO-Dauer",ipv4:"IPv4-Adresse",ipv6:"IPv6-Adresse",cidrv4:"IPv4-Bereich",cidrv6:"IPv6-Bereich",base64:"Base64-codierter String",base64url:"Base64-URL-codierter String",json_string:"JSON-String",e164:"E.164-Nummer",jwt:"JWT",template_literal:"Eingabe"},i={nan:"NaN",number:"Zahl",array:"Array"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=C(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`Ung\xFCltige Eingabe: erwartet instanceof ${t.expected}, erhalten ${a}`:`Ung\xFCltige Eingabe: erwartet ${o}, erhalten ${a}`}case"invalid_value":return t.values.length===1?`Ung\xFCltige Eingabe: erwartet ${D(t.values[0])}`:`Ung\xFCltige Option: erwartet eine von ${E(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?`Zu gro\xDF: erwartet, dass ${t.origin??"Wert"} ${o}${t.maximum.toString()} ${s.unit??"Elemente"} hat`:`Zu gro\xDF: erwartet, dass ${t.origin??"Wert"} ${o}${t.maximum.toString()} ist`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`Zu klein: erwartet, dass ${t.origin} ${o}${t.minimum.toString()} ${s.unit} hat`:`Zu klein: erwartet, dass ${t.origin} ${o}${t.minimum.toString()} ist`}case"invalid_format":{let o=t;return o.format==="starts_with"?`Ung\xFCltiger String: muss mit "${o.prefix}" beginnen`:o.format==="ends_with"?`Ung\xFCltiger String: muss mit "${o.suffix}" enden`:o.format==="includes"?`Ung\xFCltiger String: muss "${o.includes}" enthalten`:o.format==="regex"?`Ung\xFCltiger String: muss dem Muster ${o.pattern} entsprechen`:`Ung\xFCltig: ${r[o.format]??t.format}`}case"not_multiple_of":return`Ung\xFCltige Zahl: muss ein Vielfaches von ${t.divisor} sein`;case"unrecognized_keys":return`${t.keys.length>1?"Unbekannte Schl\xFCssel":"Unbekannter Schl\xFCssel"}: ${E(t.keys,", ")}`;case"invalid_key":return`Ung\xFCltiger Schl\xFCssel in ${t.origin}`;case"invalid_union":return"Ung\xFCltige Eingabe";case"invalid_element":return`Ung\xFCltiger Wert in ${t.origin}`;default:return"Ung\xFCltige Eingabe"}}};function my(){return{localeError:J$()}}var q$=()=>{let n={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function e(t){return n[t]??null}let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"},i={nan:"NaN"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=C(t.input),a=i[s]??s;return`Invalid input: expected ${o}, received ${a}`}case"invalid_value":return t.values.length===1?`Invalid input: expected ${D(t.values[0])}`:`Invalid option: expected one of ${E(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?`Too big: expected ${t.origin??"value"} to have ${o}${t.maximum.toString()} ${s.unit??"elements"}`:`Too big: expected ${t.origin??"value"} to be ${o}${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`Too small: expected ${t.origin} to have ${o}${t.minimum.toString()} ${s.unit}`:`Too small: expected ${t.origin} to be ${o}${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`Invalid string: must start with "${o.prefix}"`:o.format==="ends_with"?`Invalid string: must end with "${o.suffix}"`:o.format==="includes"?`Invalid string: must include "${o.includes}"`:o.format==="regex"?`Invalid string: must match pattern ${o.pattern}`:`Invalid ${r[o.format]??t.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${t.divisor}`;case"unrecognized_keys":return`Unrecognized key${t.keys.length>1?"s":""}: ${E(t.keys,", ")}`;case"invalid_key":return`Invalid key in ${t.origin}`;case"invalid_union":return"Invalid input";case"invalid_element":return`Invalid value in ${t.origin}`;default:return"Invalid input"}}};function vs(){return{localeError:q$()}}var V$=()=>{let n={string:{unit:"karaktrojn",verb:"havi"},file:{unit:"bajtojn",verb:"havi"},array:{unit:"elementojn",verb:"havi"},set:{unit:"elementojn",verb:"havi"}};function e(t){return n[t]??null}let r={regex:"enigo",email:"retadreso",url:"URL",emoji:"emo\u011Dio",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-datotempo",date:"ISO-dato",time:"ISO-tempo",duration:"ISO-da\u016Dro",ipv4:"IPv4-adreso",ipv6:"IPv6-adreso",cidrv4:"IPv4-rango",cidrv6:"IPv6-rango",base64:"64-ume kodita karaktraro",base64url:"URL-64-ume kodita karaktraro",json_string:"JSON-karaktraro",e164:"E.164-nombro",jwt:"JWT",template_literal:"enigo"},i={nan:"NaN",number:"nombro",array:"tabelo",null:"senvalora"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=C(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`Nevalida enigo: atendi\u011Dis instanceof ${t.expected}, ricevi\u011Dis ${a}`:`Nevalida enigo: atendi\u011Dis ${o}, ricevi\u011Dis ${a}`}case"invalid_value":return t.values.length===1?`Nevalida enigo: atendi\u011Dis ${D(t.values[0])}`:`Nevalida opcio: atendi\u011Dis unu el ${E(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?`Tro granda: atendi\u011Dis ke ${t.origin??"valoro"} havu ${o}${t.maximum.toString()} ${s.unit??"elementojn"}`:`Tro granda: atendi\u011Dis ke ${t.origin??"valoro"} havu ${o}${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`Tro malgranda: atendi\u011Dis ke ${t.origin} havu ${o}${t.minimum.toString()} ${s.unit}`:`Tro malgranda: atendi\u011Dis ke ${t.origin} estu ${o}${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`Nevalida karaktraro: devas komenci\u011Di per "${o.prefix}"`:o.format==="ends_with"?`Nevalida karaktraro: devas fini\u011Di per "${o.suffix}"`:o.format==="includes"?`Nevalida karaktraro: devas inkluzivi "${o.includes}"`:o.format==="regex"?`Nevalida karaktraro: devas kongrui kun la modelo ${o.pattern}`:`Nevalida ${r[o.format]??t.format}`}case"not_multiple_of":return`Nevalida nombro: devas esti oblo de ${t.divisor}`;case"unrecognized_keys":return`Nekonata${t.keys.length>1?"j":""} \u015Dlosilo${t.keys.length>1?"j":""}: ${E(t.keys,", ")}`;case"invalid_key":return`Nevalida \u015Dlosilo en ${t.origin}`;case"invalid_union":return"Nevalida enigo";case"invalid_element":return`Nevalida valoro en ${t.origin}`;default:return"Nevalida enigo"}}};function fy(){return{localeError:V$()}}var K$=()=>{let n={string:{unit:"caracteres",verb:"tener"},file:{unit:"bytes",verb:"tener"},array:{unit:"elementos",verb:"tener"},set:{unit:"elementos",verb:"tener"}};function e(t){return n[t]??null}let r={regex:"entrada",email:"direcci\xF3n de correo electr\xF3nico",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"fecha y hora ISO",date:"fecha ISO",time:"hora ISO",duration:"duraci\xF3n ISO",ipv4:"direcci\xF3n IPv4",ipv6:"direcci\xF3n IPv6",cidrv4:"rango IPv4",cidrv6:"rango IPv6",base64:"cadena codificada en base64",base64url:"URL codificada en base64",json_string:"cadena JSON",e164:"n\xFAmero E.164",jwt:"JWT",template_literal:"entrada"},i={nan:"NaN",string:"texto",number:"n\xFAmero",boolean:"booleano",array:"arreglo",object:"objeto",set:"conjunto",file:"archivo",date:"fecha",bigint:"n\xFAmero grande",symbol:"s\xEDmbolo",undefined:"indefinido",null:"nulo",function:"funci\xF3n",map:"mapa",record:"registro",tuple:"tupla",enum:"enumeraci\xF3n",union:"uni\xF3n",literal:"literal",promise:"promesa",void:"vac\xEDo",never:"nunca",unknown:"desconocido",any:"cualquiera"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=C(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`Entrada inv\xE1lida: se esperaba instanceof ${t.expected}, recibido ${a}`:`Entrada inv\xE1lida: se esperaba ${o}, recibido ${a}`}case"invalid_value":return t.values.length===1?`Entrada inv\xE1lida: se esperaba ${D(t.values[0])}`:`Opci\xF3n inv\xE1lida: se esperaba una de ${E(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin),a=i[t.origin]??t.origin;return s?`Demasiado grande: se esperaba que ${a??"valor"} tuviera ${o}${t.maximum.toString()} ${s.unit??"elementos"}`:`Demasiado grande: se esperaba que ${a??"valor"} fuera ${o}${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin),a=i[t.origin]??t.origin;return s?`Demasiado peque\xF1o: se esperaba que ${a} tuviera ${o}${t.minimum.toString()} ${s.unit}`:`Demasiado peque\xF1o: se esperaba que ${a} fuera ${o}${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`Cadena inv\xE1lida: debe comenzar con "${o.prefix}"`:o.format==="ends_with"?`Cadena inv\xE1lida: debe terminar en "${o.suffix}"`:o.format==="includes"?`Cadena inv\xE1lida: debe incluir "${o.includes}"`:o.format==="regex"?`Cadena inv\xE1lida: debe coincidir con el patr\xF3n ${o.pattern}`:`Inv\xE1lido ${r[o.format]??t.format}`}case"not_multiple_of":return`N\xFAmero inv\xE1lido: debe ser m\xFAltiplo de ${t.divisor}`;case"unrecognized_keys":return`Llave${t.keys.length>1?"s":""} desconocida${t.keys.length>1?"s":""}: ${E(t.keys,", ")}`;case"invalid_key":return`Llave inv\xE1lida en ${i[t.origin]??t.origin}`;case"invalid_union":return"Entrada inv\xE1lida";case"invalid_element":return`Valor inv\xE1lido en ${i[t.origin]??t.origin}`;default:return"Entrada inv\xE1lida"}}};function hy(){return{localeError:K$()}}var Y$=()=>{let n={string:{unit:"\u06A9\u0627\u0631\u0627\u06A9\u062A\u0631",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"},file:{unit:"\u0628\u0627\u06CC\u062A",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"},array:{unit:"\u0622\u06CC\u062A\u0645",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"},set:{unit:"\u0622\u06CC\u062A\u0645",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"}};function e(t){return n[t]??null}let r={regex:"\u0648\u0631\u0648\u062F\u06CC",email:"\u0622\u062F\u0631\u0633 \u0627\u06CC\u0645\u06CC\u0644",url:"URL",emoji:"\u0627\u06CC\u0645\u0648\u062C\u06CC",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u062A\u0627\u0631\u06CC\u062E \u0648 \u0632\u0645\u0627\u0646 \u0627\u06CC\u0632\u0648",date:"\u062A\u0627\u0631\u06CC\u062E \u0627\u06CC\u0632\u0648",time:"\u0632\u0645\u0627\u0646 \u0627\u06CC\u0632\u0648",duration:"\u0645\u062F\u062A \u0632\u0645\u0627\u0646 \u0627\u06CC\u0632\u0648",ipv4:"IPv4 \u0622\u062F\u0631\u0633",ipv6:"IPv6 \u0622\u062F\u0631\u0633",cidrv4:"IPv4 \u062F\u0627\u0645\u0646\u0647",cidrv6:"IPv6 \u062F\u0627\u0645\u0646\u0647",base64:"base64-encoded \u0631\u0634\u062A\u0647",base64url:"base64url-encoded \u0631\u0634\u062A\u0647",json_string:"JSON \u0631\u0634\u062A\u0647",e164:"E.164 \u0639\u062F\u062F",jwt:"JWT",template_literal:"\u0648\u0631\u0648\u062F\u06CC"},i={nan:"NaN",number:"\u0639\u062F\u062F",array:"\u0622\u0631\u0627\u06CC\u0647"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=C(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A instanceof ${t.expected} \u0645\u06CC\u200C\u0628\u0648\u062F\u060C ${a} \u062F\u0631\u06CC\u0627\u0641\u062A \u0634\u062F`:`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A ${o} \u0645\u06CC\u200C\u0628\u0648\u062F\u060C ${a} \u062F\u0631\u06CC\u0627\u0641\u062A \u0634\u062F`}case"invalid_value":return t.values.length===1?`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A ${D(t.values[0])} \u0645\u06CC\u200C\u0628\u0648\u062F`:`\u06AF\u0632\u06CC\u0646\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A \u06CC\u06A9\u06CC \u0627\u0632 ${E(t.values,"|")} \u0645\u06CC\u200C\u0628\u0648\u062F`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?`\u062E\u06CC\u0644\u06CC \u0628\u0632\u0631\u06AF: ${t.origin??"\u0645\u0642\u062F\u0627\u0631"} \u0628\u0627\u06CC\u062F ${o}${t.maximum.toString()} ${s.unit??"\u0639\u0646\u0635\u0631"} \u0628\u0627\u0634\u062F`:`\u062E\u06CC\u0644\u06CC \u0628\u0632\u0631\u06AF: ${t.origin??"\u0645\u0642\u062F\u0627\u0631"} \u0628\u0627\u06CC\u062F ${o}${t.maximum.toString()} \u0628\u0627\u0634\u062F`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`\u062E\u06CC\u0644\u06CC \u06A9\u0648\u0686\u06A9: ${t.origin} \u0628\u0627\u06CC\u062F ${o}${t.minimum.toString()} ${s.unit} \u0628\u0627\u0634\u062F`:`\u062E\u06CC\u0644\u06CC \u06A9\u0648\u0686\u06A9: ${t.origin} \u0628\u0627\u06CC\u062F ${o}${t.minimum.toString()} \u0628\u0627\u0634\u062F`}case"invalid_format":{let o=t;return o.format==="starts_with"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 "${o.prefix}" \u0634\u0631\u0648\u0639 \u0634\u0648\u062F`:o.format==="ends_with"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 "${o.suffix}" \u062A\u0645\u0627\u0645 \u0634\u0648\u062F`:o.format==="includes"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0634\u0627\u0645\u0644 "${o.includes}" \u0628\u0627\u0634\u062F`:o.format==="regex"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC ${o.pattern} \u0645\u0637\u0627\u0628\u0642\u062A \u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F`:`${r[o.format]??t.format} \u0646\u0627\u0645\u0639\u062A\u0628\u0631`}case"not_multiple_of":return`\u0639\u062F\u062F \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0645\u0636\u0631\u0628 ${t.divisor} \u0628\u0627\u0634\u062F`;case"unrecognized_keys":return`\u06A9\u0644\u06CC\u062F${t.keys.length>1?"\u0647\u0627\u06CC":""} \u0646\u0627\u0634\u0646\u0627\u0633: ${E(t.keys,", ")}`;case"invalid_key":return`\u06A9\u0644\u06CC\u062F \u0646\u0627\u0634\u0646\u0627\u0633 \u062F\u0631 ${t.origin}`;case"invalid_union":return"\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631";case"invalid_element":return`\u0645\u0642\u062F\u0627\u0631 \u0646\u0627\u0645\u0639\u062A\u0628\u0631 \u062F\u0631 ${t.origin}`;default:return"\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631"}}};function gy(){return{localeError:Y$()}}var X$=()=>{let n={string:{unit:"merkki\xE4",subject:"merkkijonon"},file:{unit:"tavua",subject:"tiedoston"},array:{unit:"alkiota",subject:"listan"},set:{unit:"alkiota",subject:"joukon"},number:{unit:"",subject:"luvun"},bigint:{unit:"",subject:"suuren kokonaisluvun"},int:{unit:"",subject:"kokonaisluvun"},date:{unit:"",subject:"p\xE4iv\xE4m\xE4\xE4r\xE4n"}};function e(t){return n[t]??null}let r={regex:"s\xE4\xE4nn\xF6llinen lauseke",email:"s\xE4hk\xF6postiosoite",url:"URL-osoite",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-aikaleima",date:"ISO-p\xE4iv\xE4m\xE4\xE4r\xE4",time:"ISO-aika",duration:"ISO-kesto",ipv4:"IPv4-osoite",ipv6:"IPv6-osoite",cidrv4:"IPv4-alue",cidrv6:"IPv6-alue",base64:"base64-koodattu merkkijono",base64url:"base64url-koodattu merkkijono",json_string:"JSON-merkkijono",e164:"E.164-luku",jwt:"JWT",template_literal:"templaattimerkkijono"},i={nan:"NaN"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=C(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`Virheellinen tyyppi: odotettiin instanceof ${t.expected}, oli ${a}`:`Virheellinen tyyppi: odotettiin ${o}, oli ${a}`}case"invalid_value":return t.values.length===1?`Virheellinen sy\xF6te: t\xE4ytyy olla ${D(t.values[0])}`:`Virheellinen valinta: t\xE4ytyy olla yksi seuraavista: ${E(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?`Liian suuri: ${s.subject} t\xE4ytyy olla ${o}${t.maximum.toString()} ${s.unit}`.trim():`Liian suuri: arvon t\xE4ytyy olla ${o}${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`Liian pieni: ${s.subject} t\xE4ytyy olla ${o}${t.minimum.toString()} ${s.unit}`.trim():`Liian pieni: arvon t\xE4ytyy olla ${o}${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`Virheellinen sy\xF6te: t\xE4ytyy alkaa "${o.prefix}"`:o.format==="ends_with"?`Virheellinen sy\xF6te: t\xE4ytyy loppua "${o.suffix}"`:o.format==="includes"?`Virheellinen sy\xF6te: t\xE4ytyy sis\xE4lt\xE4\xE4 "${o.includes}"`:o.format==="regex"?`Virheellinen sy\xF6te: t\xE4ytyy vastata s\xE4\xE4nn\xF6llist\xE4 lauseketta ${o.pattern}`:`Virheellinen ${r[o.format]??t.format}`}case"not_multiple_of":return`Virheellinen luku: t\xE4ytyy olla luvun ${t.divisor} monikerta`;case"unrecognized_keys":return`${t.keys.length>1?"Tuntemattomat avaimet":"Tuntematon avain"}: ${E(t.keys,", ")}`;case"invalid_key":return"Virheellinen avain tietueessa";case"invalid_union":return"Virheellinen unioni";case"invalid_element":return"Virheellinen arvo joukossa";default:return"Virheellinen sy\xF6te"}}};function yy(){return{localeError:X$()}}var Q$=()=>{let n={string:{unit:"caract\xE8res",verb:"avoir"},file:{unit:"octets",verb:"avoir"},array:{unit:"\xE9l\xE9ments",verb:"avoir"},set:{unit:"\xE9l\xE9ments",verb:"avoir"}};function e(t){return n[t]??null}let r={regex:"entr\xE9e",email:"adresse e-mail",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"date et heure ISO",date:"date ISO",time:"heure ISO",duration:"dur\xE9e ISO",ipv4:"adresse IPv4",ipv6:"adresse IPv6",cidrv4:"plage IPv4",cidrv6:"plage IPv6",base64:"cha\xEEne encod\xE9e en base64",base64url:"cha\xEEne encod\xE9e en base64url",json_string:"cha\xEEne JSON",e164:"num\xE9ro E.164",jwt:"JWT",template_literal:"entr\xE9e"},i={nan:"NaN",number:"nombre",array:"tableau"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=C(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`Entr\xE9e invalide : instanceof ${t.expected} attendu, ${a} re\xE7u`:`Entr\xE9e invalide : ${o} attendu, ${a} re\xE7u`}case"invalid_value":return t.values.length===1?`Entr\xE9e invalide : ${D(t.values[0])} attendu`:`Option invalide : une valeur parmi ${E(t.values,"|")} attendue`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?`Trop grand : ${t.origin??"valeur"} doit ${s.verb} ${o}${t.maximum.toString()} ${s.unit??"\xE9l\xE9ment(s)"}`:`Trop grand : ${t.origin??"valeur"} doit \xEAtre ${o}${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`Trop petit : ${t.origin} doit ${s.verb} ${o}${t.minimum.toString()} ${s.unit}`:`Trop petit : ${t.origin} doit \xEAtre ${o}${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`Cha\xEEne invalide : doit commencer par "${o.prefix}"`:o.format==="ends_with"?`Cha\xEEne invalide : doit se terminer par "${o.suffix}"`:o.format==="includes"?`Cha\xEEne invalide : doit inclure "${o.includes}"`:o.format==="regex"?`Cha\xEEne invalide : doit correspondre au mod\xE8le ${o.pattern}`:`${r[o.format]??t.format} invalide`}case"not_multiple_of":return`Nombre invalide : doit \xEAtre un multiple de ${t.divisor}`;case"unrecognized_keys":return`Cl\xE9${t.keys.length>1?"s":""} non reconnue${t.keys.length>1?"s":""} : ${E(t.keys,", ")}`;case"invalid_key":return`Cl\xE9 invalide dans ${t.origin}`;case"invalid_union":return"Entr\xE9e invalide";case"invalid_element":return`Valeur invalide dans ${t.origin}`;default:return"Entr\xE9e invalide"}}};function vy(){return{localeError:Q$()}}var ew=()=>{let n={string:{unit:"caract\xE8res",verb:"avoir"},file:{unit:"octets",verb:"avoir"},array:{unit:"\xE9l\xE9ments",verb:"avoir"},set:{unit:"\xE9l\xE9ments",verb:"avoir"}};function e(t){return n[t]??null}let r={regex:"entr\xE9e",email:"adresse courriel",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"date-heure ISO",date:"date ISO",time:"heure ISO",duration:"dur\xE9e ISO",ipv4:"adresse IPv4",ipv6:"adresse IPv6",cidrv4:"plage IPv4",cidrv6:"plage IPv6",base64:"cha\xEEne encod\xE9e en base64",base64url:"cha\xEEne encod\xE9e en base64url",json_string:"cha\xEEne JSON",e164:"num\xE9ro E.164",jwt:"JWT",template_literal:"entr\xE9e"},i={nan:"NaN"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=C(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`Entr\xE9e invalide : attendu instanceof ${t.expected}, re\xE7u ${a}`:`Entr\xE9e invalide : attendu ${o}, re\xE7u ${a}`}case"invalid_value":return t.values.length===1?`Entr\xE9e invalide : attendu ${D(t.values[0])}`:`Option invalide : attendu l'une des valeurs suivantes ${E(t.values,"|")}`;case"too_big":{let o=t.inclusive?"\u2264":"<",s=e(t.origin);return s?`Trop grand : attendu que ${t.origin??"la valeur"} ait ${o}${t.maximum.toString()} ${s.unit}`:`Trop grand : attendu que ${t.origin??"la valeur"} soit ${o}${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?"\u2265":">",s=e(t.origin);return s?`Trop petit : attendu que ${t.origin} ait ${o}${t.minimum.toString()} ${s.unit}`:`Trop petit : attendu que ${t.origin} soit ${o}${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`Cha\xEEne invalide : doit commencer par "${o.prefix}"`:o.format==="ends_with"?`Cha\xEEne invalide : doit se terminer par "${o.suffix}"`:o.format==="includes"?`Cha\xEEne invalide : doit inclure "${o.includes}"`:o.format==="regex"?`Cha\xEEne invalide : doit correspondre au motif ${o.pattern}`:`${r[o.format]??t.format} invalide`}case"not_multiple_of":return`Nombre invalide : doit \xEAtre un multiple de ${t.divisor}`;case"unrecognized_keys":return`Cl\xE9${t.keys.length>1?"s":""} non reconnue${t.keys.length>1?"s":""} : ${E(t.keys,", ")}`;case"invalid_key":return`Cl\xE9 invalide dans ${t.origin}`;case"invalid_union":return"Entr\xE9e invalide";case"invalid_element":return`Valeur invalide dans ${t.origin}`;default:return"Entr\xE9e invalide"}}};function by(){return{localeError:ew()}}var tw=()=>{let n={string:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA",gender:"f"},number:{label:"\u05DE\u05E1\u05E4\u05E8",gender:"m"},boolean:{label:"\u05E2\u05E8\u05DA \u05D1\u05D5\u05DC\u05D9\u05D0\u05E0\u05D9",gender:"m"},bigint:{label:"BigInt",gender:"m"},date:{label:"\u05EA\u05D0\u05E8\u05D9\u05DA",gender:"m"},array:{label:"\u05DE\u05E2\u05E8\u05DA",gender:"m"},object:{label:"\u05D0\u05D5\u05D1\u05D9\u05D9\u05E7\u05D8",gender:"m"},null:{label:"\u05E2\u05E8\u05DA \u05E8\u05D9\u05E7 (null)",gender:"m"},undefined:{label:"\u05E2\u05E8\u05DA \u05DC\u05D0 \u05DE\u05D5\u05D2\u05D3\u05E8 (undefined)",gender:"m"},symbol:{label:"\u05E1\u05D9\u05DE\u05D1\u05D5\u05DC (Symbol)",gender:"m"},function:{label:"\u05E4\u05D5\u05E0\u05E7\u05E6\u05D9\u05D4",gender:"f"},map:{label:"\u05DE\u05E4\u05D4 (Map)",gender:"f"},set:{label:"\u05E7\u05D1\u05D5\u05E6\u05D4 (Set)",gender:"f"},file:{label:"\u05E7\u05D5\u05D1\u05E5",gender:"m"},promise:{label:"Promise",gender:"m"},NaN:{label:"NaN",gender:"m"},unknown:{label:"\u05E2\u05E8\u05DA \u05DC\u05D0 \u05D9\u05D3\u05D5\u05E2",gender:"m"},value:{label:"\u05E2\u05E8\u05DA",gender:"m"}},e={string:{unit:"\u05EA\u05D5\u05D5\u05D9\u05DD",shortLabel:"\u05E7\u05E6\u05E8",longLabel:"\u05D0\u05E8\u05D5\u05DA"},file:{unit:"\u05D1\u05D9\u05D9\u05D8\u05D9\u05DD",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"},array:{unit:"\u05E4\u05E8\u05D9\u05D8\u05D9\u05DD",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"},set:{unit:"\u05E4\u05E8\u05D9\u05D8\u05D9\u05DD",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"},number:{unit:"",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"}},r=l=>l?n[l]:void 0,i=l=>{let u=r(l);return u?u.label:l??n.unknown.label},t=l=>`\u05D4${i(l)}`,o=l=>(r(l)?.gender??"m")==="f"?"\u05E6\u05E8\u05D9\u05DB\u05D4 \u05DC\u05D4\u05D9\u05D5\u05EA":"\u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA",s=l=>l?e[l]??null:null,a={regex:{label:"\u05E7\u05DC\u05D8",gender:"m"},email:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA \u05D0\u05D9\u05DE\u05D9\u05D9\u05DC",gender:"f"},url:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA \u05E8\u05E9\u05EA",gender:"f"},emoji:{label:"\u05D0\u05D9\u05DE\u05D5\u05D2'\u05D9",gender:"m"},uuid:{label:"UUID",gender:"m"},nanoid:{label:"nanoid",gender:"m"},guid:{label:"GUID",gender:"m"},cuid:{label:"cuid",gender:"m"},cuid2:{label:"cuid2",gender:"m"},ulid:{label:"ULID",gender:"m"},xid:{label:"XID",gender:"m"},ksuid:{label:"KSUID",gender:"m"},datetime:{label:"\u05EA\u05D0\u05E8\u05D9\u05DA \u05D5\u05D6\u05DE\u05DF ISO",gender:"m"},date:{label:"\u05EA\u05D0\u05E8\u05D9\u05DA ISO",gender:"m"},time:{label:"\u05D6\u05DE\u05DF ISO",gender:"m"},duration:{label:"\u05DE\u05E9\u05DA \u05D6\u05DE\u05DF ISO",gender:"m"},ipv4:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA IPv4",gender:"f"},ipv6:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA IPv6",gender:"f"},cidrv4:{label:"\u05D8\u05D5\u05D5\u05D7 IPv4",gender:"m"},cidrv6:{label:"\u05D8\u05D5\u05D5\u05D7 IPv6",gender:"m"},base64:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D1\u05D1\u05E1\u05D9\u05E1 64",gender:"f"},base64url:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D1\u05D1\u05E1\u05D9\u05E1 64 \u05DC\u05DB\u05EA\u05D5\u05D1\u05D5\u05EA \u05E8\u05E9\u05EA",gender:"f"},json_string:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA JSON",gender:"f"},e164:{label:"\u05DE\u05E1\u05E4\u05E8 E.164",gender:"m"},jwt:{label:"JWT",gender:"m"},ends_with:{label:"\u05E7\u05DC\u05D8",gender:"m"},includes:{label:"\u05E7\u05DC\u05D8",gender:"m"},lowercase:{label:"\u05E7\u05DC\u05D8",gender:"m"},starts_with:{label:"\u05E7\u05DC\u05D8",gender:"m"},uppercase:{label:"\u05E7\u05DC\u05D8",gender:"m"}},c={nan:"NaN"};return l=>{switch(l.code){case"invalid_type":{let u=l.expected,d=c[u??""]??i(u),p=C(l.input),m=c[p]??n[p]?.label??p;return/^[A-Z]/.test(l.expected)?`\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA instanceof ${l.expected}, \u05D4\u05EA\u05E7\u05D1\u05DC ${m}`:`\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${d}, \u05D4\u05EA\u05E7\u05D1\u05DC ${m}`}case"invalid_value":{if(l.values.length===1)return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05E2\u05E8\u05DA \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA ${D(l.values[0])}`;let u=l.values.map(m=>D(m));if(l.values.length===2)return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05D0\u05E4\u05E9\u05E8\u05D5\u05D9\u05D5\u05EA \u05D4\u05DE\u05EA\u05D0\u05D9\u05DE\u05D5\u05EA \u05D4\u05DF ${u[0]} \u05D0\u05D5 ${u[1]}`;let d=u[u.length-1];return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05D0\u05E4\u05E9\u05E8\u05D5\u05D9\u05D5\u05EA \u05D4\u05DE\u05EA\u05D0\u05D9\u05DE\u05D5\u05EA \u05D4\u05DF ${u.slice(0,-1).join(", ")} \u05D0\u05D5 ${d}`}case"too_big":{let u=s(l.origin),d=t(l.origin??"value");if(l.origin==="string")return`${u?.longLabel??"\u05D0\u05E8\u05D5\u05DA"} \u05DE\u05D3\u05D9: ${d} \u05E6\u05E8\u05D9\u05DB\u05D4 \u05DC\u05D4\u05DB\u05D9\u05DC ${l.maximum.toString()} ${u?.unit??""} ${l.inclusive?"\u05D0\u05D5 \u05E4\u05D7\u05D5\u05EA":"\u05DC\u05DB\u05DC \u05D4\u05D9\u05D5\u05EA\u05E8"}`.trim();if(l.origin==="number"){let f=l.inclusive?`\u05E7\u05D8\u05DF \u05D0\u05D5 \u05E9\u05D5\u05D5\u05D4 \u05DC-${l.maximum}`:`\u05E7\u05D8\u05DF \u05DE-${l.maximum}`;return`\u05D2\u05D3\u05D5\u05DC \u05DE\u05D3\u05D9: ${d} \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${f}`}if(l.origin==="array"||l.origin==="set"){let f=l.origin==="set"?"\u05E6\u05E8\u05D9\u05DB\u05D4":"\u05E6\u05E8\u05D9\u05DA",h=l.inclusive?`${l.maximum} ${u?.unit??""} \u05D0\u05D5 \u05E4\u05D7\u05D5\u05EA`:`\u05E4\u05D7\u05D5\u05EA \u05DE-${l.maximum} ${u?.unit??""}`;return`\u05D2\u05D3\u05D5\u05DC \u05DE\u05D3\u05D9: ${d} ${f} \u05DC\u05D4\u05DB\u05D9\u05DC ${h}`.trim()}let p=l.inclusive?"<=":"<",m=o(l.origin??"value");return u?.unit?`${u.longLabel} \u05DE\u05D3\u05D9: ${d} ${m} ${p}${l.maximum.toString()} ${u.unit}`:`${u?.longLabel??"\u05D2\u05D3\u05D5\u05DC"} \u05DE\u05D3\u05D9: ${d} ${m} ${p}${l.maximum.toString()}`}case"too_small":{let u=s(l.origin),d=t(l.origin??"value");if(l.origin==="string")return`${u?.shortLabel??"\u05E7\u05E6\u05E8"} \u05DE\u05D3\u05D9: ${d} \u05E6\u05E8\u05D9\u05DB\u05D4 \u05DC\u05D4\u05DB\u05D9\u05DC ${l.minimum.toString()} ${u?.unit??""} ${l.inclusive?"\u05D0\u05D5 \u05D9\u05D5\u05EA\u05E8":"\u05DC\u05E4\u05D7\u05D5\u05EA"}`.trim();if(l.origin==="number"){let f=l.inclusive?`\u05D2\u05D3\u05D5\u05DC \u05D0\u05D5 \u05E9\u05D5\u05D5\u05D4 \u05DC-${l.minimum}`:`\u05D2\u05D3\u05D5\u05DC \u05DE-${l.minimum}`;return`\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${d} \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${f}`}if(l.origin==="array"||l.origin==="set"){let f=l.origin==="set"?"\u05E6\u05E8\u05D9\u05DB\u05D4":"\u05E6\u05E8\u05D9\u05DA";if(l.minimum===1&&l.inclusive){let _=(l.origin==="set","\u05DC\u05E4\u05D7\u05D5\u05EA \u05E4\u05E8\u05D9\u05D8 \u05D0\u05D7\u05D3");return`\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${d} ${f} \u05DC\u05D4\u05DB\u05D9\u05DC ${_}`}let h=l.inclusive?`${l.minimum} ${u?.unit??""} \u05D0\u05D5 \u05D9\u05D5\u05EA\u05E8`:`\u05D9\u05D5\u05EA\u05E8 \u05DE-${l.minimum} ${u?.unit??""}`;return`\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${d} ${f} \u05DC\u05D4\u05DB\u05D9\u05DC ${h}`.trim()}let p=l.inclusive?">=":">",m=o(l.origin??"value");return u?.unit?`${u.shortLabel} \u05DE\u05D3\u05D9: ${d} ${m} ${p}${l.minimum.toString()} ${u.unit}`:`${u?.shortLabel??"\u05E7\u05D8\u05DF"} \u05DE\u05D3\u05D9: ${d} ${m} ${p}${l.minimum.toString()}`}case"invalid_format":{let u=l;if(u.format==="starts_with")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05EA\u05D7\u05D9\u05DC \u05D1 "${u.prefix}"`;if(u.format==="ends_with")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05E1\u05EA\u05D9\u05D9\u05DD \u05D1 "${u.suffix}"`;if(u.format==="includes")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05DB\u05DC\u05D5\u05DC "${u.includes}"`;if(u.format==="regex")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05EA\u05D0\u05D9\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA ${u.pattern}`;let d=a[u.format],p=d?.label??u.format,f=(d?.gender??"m")==="f"?"\u05EA\u05E7\u05D9\u05E0\u05D4":"\u05EA\u05E7\u05D9\u05DF";return`${p} \u05DC\u05D0 ${f}`}case"not_multiple_of":return`\u05DE\u05E1\u05E4\u05E8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05DE\u05DB\u05E4\u05DC\u05D4 \u05E9\u05DC ${l.divisor}`;case"unrecognized_keys":return`\u05DE\u05E4\u05EA\u05D7${l.keys.length>1?"\u05D5\u05EA":""} \u05DC\u05D0 \u05DE\u05D6\u05D5\u05D4${l.keys.length>1?"\u05D9\u05DD":"\u05D4"}: ${E(l.keys,", ")}`;case"invalid_key":return"\u05E9\u05D3\u05D4 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF \u05D1\u05D0\u05D5\u05D1\u05D9\u05D9\u05E7\u05D8";case"invalid_union":return"\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF";case"invalid_element":return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF \u05D1${t(l.origin??"array")}`;default:return"\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF"}}};function _y(){return{localeError:tw()}}var nw=()=>{let n={string:{unit:"karakter",verb:"legyen"},file:{unit:"byte",verb:"legyen"},array:{unit:"elem",verb:"legyen"},set:{unit:"elem",verb:"legyen"}};function e(t){return n[t]??null}let r={regex:"bemenet",email:"email c\xEDm",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO id\u0151b\xE9lyeg",date:"ISO d\xE1tum",time:"ISO id\u0151",duration:"ISO id\u0151intervallum",ipv4:"IPv4 c\xEDm",ipv6:"IPv6 c\xEDm",cidrv4:"IPv4 tartom\xE1ny",cidrv6:"IPv6 tartom\xE1ny",base64:"base64-k\xF3dolt string",base64url:"base64url-k\xF3dolt string",json_string:"JSON string",e164:"E.164 sz\xE1m",jwt:"JWT",template_literal:"bemenet"},i={nan:"NaN",number:"sz\xE1m",array:"t\xF6mb"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=C(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k instanceof ${t.expected}, a kapott \xE9rt\xE9k ${a}`:`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k ${o}, a kapott \xE9rt\xE9k ${a}`}case"invalid_value":return t.values.length===1?`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k ${D(t.values[0])}`:`\xC9rv\xE9nytelen opci\xF3: valamelyik \xE9rt\xE9k v\xE1rt ${E(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?`T\xFAl nagy: ${t.origin??"\xE9rt\xE9k"} m\xE9rete t\xFAl nagy ${o}${t.maximum.toString()} ${s.unit??"elem"}`:`T\xFAl nagy: a bemeneti \xE9rt\xE9k ${t.origin??"\xE9rt\xE9k"} t\xFAl nagy: ${o}${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`T\xFAl kicsi: a bemeneti \xE9rt\xE9k ${t.origin} m\xE9rete t\xFAl kicsi ${o}${t.minimum.toString()} ${s.unit}`:`T\xFAl kicsi: a bemeneti \xE9rt\xE9k ${t.origin} t\xFAl kicsi ${o}${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`\xC9rv\xE9nytelen string: "${o.prefix}" \xE9rt\xE9kkel kell kezd\u0151dnie`:o.format==="ends_with"?`\xC9rv\xE9nytelen string: "${o.suffix}" \xE9rt\xE9kkel kell v\xE9gz\u0151dnie`:o.format==="includes"?`\xC9rv\xE9nytelen string: "${o.includes}" \xE9rt\xE9ket kell tartalmaznia`:o.format==="regex"?`\xC9rv\xE9nytelen string: ${o.pattern} mint\xE1nak kell megfelelnie`:`\xC9rv\xE9nytelen ${r[o.format]??t.format}`}case"not_multiple_of":return`\xC9rv\xE9nytelen sz\xE1m: ${t.divisor} t\xF6bbsz\xF6r\xF6s\xE9nek kell lennie`;case"unrecognized_keys":return`Ismeretlen kulcs${t.keys.length>1?"s":""}: ${E(t.keys,", ")}`;case"invalid_key":return`\xC9rv\xE9nytelen kulcs ${t.origin}`;case"invalid_union":return"\xC9rv\xE9nytelen bemenet";case"invalid_element":return`\xC9rv\xE9nytelen \xE9rt\xE9k: ${t.origin}`;default:return"\xC9rv\xE9nytelen bemenet"}}};function xy(){return{localeError:nw()}}function Sy(n,e,r){return Math.abs(n)===1?e:r}function pr(n){if(!n)return"";let e=["\u0561","\u0565","\u0568","\u056B","\u0578","\u0578\u0582","\u0585"],r=n[n.length-1];return n+(e.includes(r)?"\u0576":"\u0568")}var rw=()=>{let n={string:{unit:{one:"\u0576\u0577\u0561\u0576",many:"\u0576\u0577\u0561\u0576\u0576\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"},file:{unit:{one:"\u0562\u0561\u0575\u0569",many:"\u0562\u0561\u0575\u0569\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"},array:{unit:{one:"\u057F\u0561\u0580\u0580",many:"\u057F\u0561\u0580\u0580\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"},set:{unit:{one:"\u057F\u0561\u0580\u0580",many:"\u057F\u0561\u0580\u0580\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"}};function e(t){return n[t]??null}let r={regex:"\u0574\u0578\u0582\u057F\u0584",email:"\u0567\u056C. \u0570\u0561\u057D\u0581\u0565",url:"URL",emoji:"\u0567\u0574\u0578\u057B\u056B",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0561\u0574\u057D\u0561\u0569\u056B\u057E \u0587 \u056A\u0561\u0574",date:"ISO \u0561\u0574\u057D\u0561\u0569\u056B\u057E",time:"ISO \u056A\u0561\u0574",duration:"ISO \u057F\u0587\u0578\u0572\u0578\u0582\u0569\u0575\u0578\u0582\u0576",ipv4:"IPv4 \u0570\u0561\u057D\u0581\u0565",ipv6:"IPv6 \u0570\u0561\u057D\u0581\u0565",cidrv4:"IPv4 \u0574\u056B\u057B\u0561\u056F\u0561\u0575\u0584",cidrv6:"IPv6 \u0574\u056B\u057B\u0561\u056F\u0561\u0575\u0584",base64:"base64 \u0571\u0587\u0561\u0579\u0561\u0583\u0578\u057E \u057F\u0578\u0572",base64url:"base64url \u0571\u0587\u0561\u0579\u0561\u0583\u0578\u057E \u057F\u0578\u0572",json_string:"JSON \u057F\u0578\u0572",e164:"E.164 \u0570\u0561\u0574\u0561\u0580",jwt:"JWT",template_literal:"\u0574\u0578\u0582\u057F\u0584"},i={nan:"NaN",number:"\u0569\u056B\u057E",array:"\u0566\u0561\u0576\u0563\u057E\u0561\u056E"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=C(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 instanceof ${t.expected}, \u057D\u057F\u0561\u0581\u057E\u0565\u056C \u0567 ${a}`:`\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 ${o}, \u057D\u057F\u0561\u0581\u057E\u0565\u056C \u0567 ${a}`}case"invalid_value":return t.values.length===1?`\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 ${D(t.values[1])}`:`\u054D\u056D\u0561\u056C \u057F\u0561\u0580\u0562\u0565\u0580\u0561\u056F\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 \u0570\u0565\u057F\u0587\u0575\u0561\u056C\u0576\u0565\u0580\u056B\u0581 \u0574\u0565\u056F\u0568\u055D ${E(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);if(s){let a=Number(t.maximum),c=Sy(a,s.unit.one,s.unit.many);return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0574\u0565\u056E \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${pr(t.origin??"\u0561\u0580\u056A\u0565\u0584")} \u056F\u0578\u0582\u0576\u0565\u0576\u0561 ${o}${t.maximum.toString()} ${c}`}return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0574\u0565\u056E \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${pr(t.origin??"\u0561\u0580\u056A\u0565\u0584")} \u056C\u056B\u0576\u056B ${o}${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);if(s){let a=Number(t.minimum),c=Sy(a,s.unit.one,s.unit.many);return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0583\u0578\u0584\u0580 \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${pr(t.origin)} \u056F\u0578\u0582\u0576\u0565\u0576\u0561 ${o}${t.minimum.toString()} ${c}`}return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0583\u0578\u0584\u0580 \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${pr(t.origin)} \u056C\u056B\u0576\u056B ${o}${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u057D\u056F\u057D\u057E\u056B "${o.prefix}"-\u0578\u057E`:o.format==="ends_with"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u0561\u057E\u0561\u0580\u057F\u057E\u056B "${o.suffix}"-\u0578\u057E`:o.format==="includes"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u057A\u0561\u0580\u0578\u0582\u0576\u0561\u056F\u056B "${o.includes}"`:o.format==="regex"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u0570\u0561\u0574\u0561\u057A\u0561\u057F\u0561\u057D\u056D\u0561\u0576\u056B ${o.pattern} \u0571\u0587\u0561\u0579\u0561\u0583\u056B\u0576`:`\u054D\u056D\u0561\u056C ${r[o.format]??t.format}`}case"not_multiple_of":return`\u054D\u056D\u0561\u056C \u0569\u056B\u057E\u2024 \u057A\u0565\u057F\u0584 \u0567 \u0562\u0561\u0566\u0574\u0561\u057A\u0561\u057F\u056B\u056F \u056C\u056B\u0576\u056B ${t.divisor}-\u056B`;case"unrecognized_keys":return`\u0549\u0573\u0561\u0576\u0561\u0579\u057E\u0561\u056E \u0562\u0561\u0576\u0561\u056C\u056B${t.keys.length>1?"\u0576\u0565\u0580":""}. ${E(t.keys,", ")}`;case"invalid_key":return`\u054D\u056D\u0561\u056C \u0562\u0561\u0576\u0561\u056C\u056B ${pr(t.origin)}-\u0578\u0582\u0574`;case"invalid_union":return"\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574";case"invalid_element":return`\u054D\u056D\u0561\u056C \u0561\u0580\u056A\u0565\u0584 ${pr(t.origin)}-\u0578\u0582\u0574`;default:return"\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574"}}};function $y(){return{localeError:rw()}}var iw=()=>{let n={string:{unit:"karakter",verb:"memiliki"},file:{unit:"byte",verb:"memiliki"},array:{unit:"item",verb:"memiliki"},set:{unit:"item",verb:"memiliki"}};function e(t){return n[t]??null}let r={regex:"input",email:"alamat email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"tanggal dan waktu format ISO",date:"tanggal format ISO",time:"jam format ISO",duration:"durasi format ISO",ipv4:"alamat IPv4",ipv6:"alamat IPv6",cidrv4:"rentang alamat IPv4",cidrv6:"rentang alamat IPv6",base64:"string dengan enkode base64",base64url:"string dengan enkode base64url",json_string:"string JSON",e164:"angka E.164",jwt:"JWT",template_literal:"input"},i={nan:"NaN"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=C(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`Input tidak valid: diharapkan instanceof ${t.expected}, diterima ${a}`:`Input tidak valid: diharapkan ${o}, diterima ${a}`}case"invalid_value":return t.values.length===1?`Input tidak valid: diharapkan ${D(t.values[0])}`:`Pilihan tidak valid: diharapkan salah satu dari ${E(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?`Terlalu besar: diharapkan ${t.origin??"value"} memiliki ${o}${t.maximum.toString()} ${s.unit??"elemen"}`:`Terlalu besar: diharapkan ${t.origin??"value"} menjadi ${o}${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`Terlalu kecil: diharapkan ${t.origin} memiliki ${o}${t.minimum.toString()} ${s.unit}`:`Terlalu kecil: diharapkan ${t.origin} menjadi ${o}${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`String tidak valid: harus dimulai dengan "${o.prefix}"`:o.format==="ends_with"?`String tidak valid: harus berakhir dengan "${o.suffix}"`:o.format==="includes"?`String tidak valid: harus menyertakan "${o.includes}"`:o.format==="regex"?`String tidak valid: harus sesuai pola ${o.pattern}`:`${r[o.format]??t.format} tidak valid`}case"not_multiple_of":return`Angka tidak valid: harus kelipatan dari ${t.divisor}`;case"unrecognized_keys":return`Kunci tidak dikenali ${t.keys.length>1?"s":""}: ${E(t.keys,", ")}`;case"invalid_key":return`Kunci tidak valid di ${t.origin}`;case"invalid_union":return"Input tidak valid";case"invalid_element":return`Nilai tidak valid di ${t.origin}`;default:return"Input tidak valid"}}};function wy(){return{localeError:iw()}}var ow=()=>{let n={string:{unit:"stafi",verb:"a\xF0 hafa"},file:{unit:"b\xE6ti",verb:"a\xF0 hafa"},array:{unit:"hluti",verb:"a\xF0 hafa"},set:{unit:"hluti",verb:"a\xF0 hafa"}};function e(t){return n[t]??null}let r={regex:"gildi",email:"netfang",url:"vefsl\xF3\xF0",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dagsetning og t\xEDmi",date:"ISO dagsetning",time:"ISO t\xEDmi",duration:"ISO t\xEDmalengd",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded strengur",base64url:"base64url-encoded strengur",json_string:"JSON strengur",e164:"E.164 t\xF6lugildi",jwt:"JWT",template_literal:"gildi"},i={nan:"NaN",number:"n\xFAmer",array:"fylki"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=C(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`Rangt gildi: \xDE\xFA sl\xF3st inn ${a} \xFEar sem \xE1 a\xF0 vera instanceof ${t.expected}`:`Rangt gildi: \xDE\xFA sl\xF3st inn ${a} \xFEar sem \xE1 a\xF0 vera ${o}`}case"invalid_value":return t.values.length===1?`Rangt gildi: gert r\xE1\xF0 fyrir ${D(t.values[0])}`:`\xD3gilt val: m\xE1 vera eitt af eftirfarandi ${E(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?`Of st\xF3rt: gert er r\xE1\xF0 fyrir a\xF0 ${t.origin??"gildi"} hafi ${o}${t.maximum.toString()} ${s.unit??"hluti"}`:`Of st\xF3rt: gert er r\xE1\xF0 fyrir a\xF0 ${t.origin??"gildi"} s\xE9 ${o}${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`Of l\xEDti\xF0: gert er r\xE1\xF0 fyrir a\xF0 ${t.origin} hafi ${o}${t.minimum.toString()} ${s.unit}`:`Of l\xEDti\xF0: gert er r\xE1\xF0 fyrir a\xF0 ${t.origin} s\xE9 ${o}${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`\xD3gildur strengur: ver\xF0ur a\xF0 byrja \xE1 "${o.prefix}"`:o.format==="ends_with"?`\xD3gildur strengur: ver\xF0ur a\xF0 enda \xE1 "${o.suffix}"`:o.format==="includes"?`\xD3gildur strengur: ver\xF0ur a\xF0 innihalda "${o.includes}"`:o.format==="regex"?`\xD3gildur strengur: ver\xF0ur a\xF0 fylgja mynstri ${o.pattern}`:`Rangt ${r[o.format]??t.format}`}case"not_multiple_of":return`R\xF6ng tala: ver\xF0ur a\xF0 vera margfeldi af ${t.divisor}`;case"unrecognized_keys":return`\xD3\xFEekkt ${t.keys.length>1?"ir lyklar":"ur lykill"}: ${E(t.keys,", ")}`;case"invalid_key":return`Rangur lykill \xED ${t.origin}`;case"invalid_union":return"Rangt gildi";case"invalid_element":return`Rangt gildi \xED ${t.origin}`;default:return"Rangt gildi"}}};function ky(){return{localeError:ow()}}var sw=()=>{let n={string:{unit:"caratteri",verb:"avere"},file:{unit:"byte",verb:"avere"},array:{unit:"elementi",verb:"avere"},set:{unit:"elementi",verb:"avere"}};function e(t){return n[t]??null}let r={regex:"input",email:"indirizzo email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data e ora ISO",date:"data ISO",time:"ora ISO",duration:"durata ISO",ipv4:"indirizzo IPv4",ipv6:"indirizzo IPv6",cidrv4:"intervallo IPv4",cidrv6:"intervallo IPv6",base64:"stringa codificata in base64",base64url:"URL codificata in base64",json_string:"stringa JSON",e164:"numero E.164",jwt:"JWT",template_literal:"input"},i={nan:"NaN",number:"numero",array:"vettore"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=C(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`Input non valido: atteso instanceof ${t.expected}, ricevuto ${a}`:`Input non valido: atteso ${o}, ricevuto ${a}`}case"invalid_value":return t.values.length===1?`Input non valido: atteso ${D(t.values[0])}`:`Opzione non valida: atteso uno tra ${E(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?`Troppo grande: ${t.origin??"valore"} deve avere ${o}${t.maximum.toString()} ${s.unit??"elementi"}`:`Troppo grande: ${t.origin??"valore"} deve essere ${o}${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`Troppo piccolo: ${t.origin} deve avere ${o}${t.minimum.toString()} ${s.unit}`:`Troppo piccolo: ${t.origin} deve essere ${o}${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`Stringa non valida: deve iniziare con "${o.prefix}"`:o.format==="ends_with"?`Stringa non valida: deve terminare con "${o.suffix}"`:o.format==="includes"?`Stringa non valida: deve includere "${o.includes}"`:o.format==="regex"?`Stringa non valida: deve corrispondere al pattern ${o.pattern}`:`Invalid ${r[o.format]??t.format}`}case"not_multiple_of":return`Numero non valido: deve essere un multiplo di ${t.divisor}`;case"unrecognized_keys":return`Chiav${t.keys.length>1?"i":"e"} non riconosciut${t.keys.length>1?"e":"a"}: ${E(t.keys,", ")}`;case"invalid_key":return`Chiave non valida in ${t.origin}`;case"invalid_union":return"Input non valido";case"invalid_element":return`Valore non valido in ${t.origin}`;default:return"Input non valido"}}};function Ey(){return{localeError:sw()}}var aw=()=>{let n={string:{unit:"\u6587\u5B57",verb:"\u3067\u3042\u308B"},file:{unit:"\u30D0\u30A4\u30C8",verb:"\u3067\u3042\u308B"},array:{unit:"\u8981\u7D20",verb:"\u3067\u3042\u308B"},set:{unit:"\u8981\u7D20",verb:"\u3067\u3042\u308B"}};function e(t){return n[t]??null}let r={regex:"\u5165\u529B\u5024",email:"\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9",url:"URL",emoji:"\u7D75\u6587\u5B57",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO\u65E5\u6642",date:"ISO\u65E5\u4ED8",time:"ISO\u6642\u523B",duration:"ISO\u671F\u9593",ipv4:"IPv4\u30A2\u30C9\u30EC\u30B9",ipv6:"IPv6\u30A2\u30C9\u30EC\u30B9",cidrv4:"IPv4\u7BC4\u56F2",cidrv6:"IPv6\u7BC4\u56F2",base64:"base64\u30A8\u30F3\u30B3\u30FC\u30C9\u6587\u5B57\u5217",base64url:"base64url\u30A8\u30F3\u30B3\u30FC\u30C9\u6587\u5B57\u5217",json_string:"JSON\u6587\u5B57\u5217",e164:"E.164\u756A\u53F7",jwt:"JWT",template_literal:"\u5165\u529B\u5024"},i={nan:"NaN",number:"\u6570\u5024",array:"\u914D\u5217"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=C(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`\u7121\u52B9\u306A\u5165\u529B: instanceof ${t.expected}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F\u304C\u3001${a}\u304C\u5165\u529B\u3055\u308C\u307E\u3057\u305F`:`\u7121\u52B9\u306A\u5165\u529B: ${o}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F\u304C\u3001${a}\u304C\u5165\u529B\u3055\u308C\u307E\u3057\u305F`}case"invalid_value":return t.values.length===1?`\u7121\u52B9\u306A\u5165\u529B: ${D(t.values[0])}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F`:`\u7121\u52B9\u306A\u9078\u629E: ${E(t.values,"\u3001")}\u306E\u3044\u305A\u308C\u304B\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;case"too_big":{let o=t.inclusive?"\u4EE5\u4E0B\u3067\u3042\u308B":"\u3088\u308A\u5C0F\u3055\u3044",s=e(t.origin);return s?`\u5927\u304D\u3059\u304E\u308B\u5024: ${t.origin??"\u5024"}\u306F${t.maximum.toString()}${s.unit??"\u8981\u7D20"}${o}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:`\u5927\u304D\u3059\u304E\u308B\u5024: ${t.origin??"\u5024"}\u306F${t.maximum.toString()}${o}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`}case"too_small":{let o=t.inclusive?"\u4EE5\u4E0A\u3067\u3042\u308B":"\u3088\u308A\u5927\u304D\u3044",s=e(t.origin);return s?`\u5C0F\u3055\u3059\u304E\u308B\u5024: ${t.origin}\u306F${t.minimum.toString()}${s.unit}${o}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:`\u5C0F\u3055\u3059\u304E\u308B\u5024: ${t.origin}\u306F${t.minimum.toString()}${o}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`}case"invalid_format":{let o=t;return o.format==="starts_with"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${o.prefix}"\u3067\u59CB\u307E\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:o.format==="ends_with"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${o.suffix}"\u3067\u7D42\u308F\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:o.format==="includes"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${o.includes}"\u3092\u542B\u3080\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:o.format==="regex"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: \u30D1\u30BF\u30FC\u30F3${o.pattern}\u306B\u4E00\u81F4\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:`\u7121\u52B9\u306A${r[o.format]??t.format}`}case"not_multiple_of":return`\u7121\u52B9\u306A\u6570\u5024: ${t.divisor}\u306E\u500D\u6570\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;case"unrecognized_keys":return`\u8A8D\u8B58\u3055\u308C\u3066\u3044\u306A\u3044\u30AD\u30FC${t.keys.length>1?"\u7FA4":""}: ${E(t.keys,"\u3001")}`;case"invalid_key":return`${t.origin}\u5185\u306E\u7121\u52B9\u306A\u30AD\u30FC`;case"invalid_union":return"\u7121\u52B9\u306A\u5165\u529B";case"invalid_element":return`${t.origin}\u5185\u306E\u7121\u52B9\u306A\u5024`;default:return"\u7121\u52B9\u306A\u5165\u529B"}}};function Iy(){return{localeError:aw()}}var cw=()=>{let n={string:{unit:"\u10E1\u10D8\u10DB\u10D1\u10DD\u10DA\u10DD",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"},file:{unit:"\u10D1\u10D0\u10D8\u10E2\u10D8",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"},array:{unit:"\u10D4\u10DA\u10D4\u10DB\u10D4\u10DC\u10E2\u10D8",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"},set:{unit:"\u10D4\u10DA\u10D4\u10DB\u10D4\u10DC\u10E2\u10D8",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"}};function e(t){return n[t]??null}let r={regex:"\u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0",email:"\u10D4\u10DA-\u10E4\u10DD\u10E1\u10E2\u10D8\u10E1 \u10DB\u10D8\u10E1\u10D0\u10DB\u10D0\u10E0\u10D7\u10D8",url:"URL",emoji:"\u10D4\u10DB\u10DD\u10EF\u10D8",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u10D7\u10D0\u10E0\u10D8\u10E6\u10D8-\u10D3\u10E0\u10DD",date:"\u10D7\u10D0\u10E0\u10D8\u10E6\u10D8",time:"\u10D3\u10E0\u10DD",duration:"\u10EE\u10D0\u10DC\u10D2\u10E0\u10EB\u10DA\u10D8\u10D5\u10DD\u10D1\u10D0",ipv4:"IPv4 \u10DB\u10D8\u10E1\u10D0\u10DB\u10D0\u10E0\u10D7\u10D8",ipv6:"IPv6 \u10DB\u10D8\u10E1\u10D0\u10DB\u10D0\u10E0\u10D7\u10D8",cidrv4:"IPv4 \u10D3\u10D8\u10D0\u10DE\u10D0\u10D6\u10DD\u10DC\u10D8",cidrv6:"IPv6 \u10D3\u10D8\u10D0\u10DE\u10D0\u10D6\u10DD\u10DC\u10D8",base64:"base64-\u10D9\u10DD\u10D3\u10D8\u10E0\u10D4\u10D1\u10E3\u10DA\u10D8 \u10E1\u10E2\u10E0\u10D8\u10DC\u10D2\u10D8",base64url:"base64url-\u10D9\u10DD\u10D3\u10D8\u10E0\u10D4\u10D1\u10E3\u10DA\u10D8 \u10E1\u10E2\u10E0\u10D8\u10DC\u10D2\u10D8",json_string:"JSON \u10E1\u10E2\u10E0\u10D8\u10DC\u10D2\u10D8",e164:"E.164 \u10DC\u10DD\u10DB\u10D4\u10E0\u10D8",jwt:"JWT",template_literal:"\u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0"},i={nan:"NaN",number:"\u10E0\u10D8\u10EA\u10EE\u10D5\u10D8",string:"\u10E1\u10E2\u10E0\u10D8\u10DC\u10D2\u10D8",boolean:"\u10D1\u10E3\u10DA\u10D4\u10D0\u10DC\u10D8",function:"\u10E4\u10E3\u10DC\u10E5\u10EA\u10D8\u10D0",array:"\u10DB\u10D0\u10E1\u10D8\u10D5\u10D8"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=C(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 instanceof ${t.expected}, \u10DB\u10D8\u10E6\u10D4\u10D1\u10E3\u10DA\u10D8 ${a}`:`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${o}, \u10DB\u10D8\u10E6\u10D4\u10D1\u10E3\u10DA\u10D8 ${a}`}case"invalid_value":return t.values.length===1?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${D(t.values[0])}`:`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D0\u10E0\u10D8\u10D0\u10DC\u10E2\u10D8: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8\u10D0 \u10D4\u10E0\u10D7-\u10D4\u10E0\u10D7\u10D8 ${E(t.values,"|")}-\u10D3\u10D0\u10DC`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10D3\u10D8\u10D3\u10D8: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${t.origin??"\u10DB\u10DC\u10D8\u10E8\u10D5\u10DC\u10D4\u10DA\u10DD\u10D1\u10D0"} ${s.verb} ${o}${t.maximum.toString()} ${s.unit}`:`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10D3\u10D8\u10D3\u10D8: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${t.origin??"\u10DB\u10DC\u10D8\u10E8\u10D5\u10DC\u10D4\u10DA\u10DD\u10D1\u10D0"} \u10D8\u10E7\u10DD\u10E1 ${o}${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10DE\u10D0\u10E2\u10D0\u10E0\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${t.origin} ${s.verb} ${o}${t.minimum.toString()} ${s.unit}`:`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10DE\u10D0\u10E2\u10D0\u10E0\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${t.origin} \u10D8\u10E7\u10DD\u10E1 ${o}${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E1\u10E2\u10E0\u10D8\u10DC\u10D2\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10D8\u10EC\u10E7\u10D4\u10D1\u10DD\u10D3\u10D4\u10E1 "${o.prefix}"-\u10D8\u10D7`:o.format==="ends_with"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E1\u10E2\u10E0\u10D8\u10DC\u10D2\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10DB\u10D7\u10D0\u10D5\u10E0\u10D3\u10D4\u10D1\u10DD\u10D3\u10D4\u10E1 "${o.suffix}"-\u10D8\u10D7`:o.format==="includes"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E1\u10E2\u10E0\u10D8\u10DC\u10D2\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1 "${o.includes}"-\u10E1`:o.format==="regex"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E1\u10E2\u10E0\u10D8\u10DC\u10D2\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D4\u10E1\u10D0\u10D1\u10D0\u10DB\u10D4\u10D1\u10DD\u10D3\u10D4\u10E1 \u10E8\u10D0\u10D1\u10DA\u10DD\u10DC\u10E1 ${o.pattern}`:`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 ${r[o.format]??t.format}`}case"not_multiple_of":return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E0\u10D8\u10EA\u10EE\u10D5\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10D8\u10E7\u10DD\u10E1 ${t.divisor}-\u10D8\u10E1 \u10EF\u10D4\u10E0\u10D0\u10D3\u10D8`;case"unrecognized_keys":return`\u10E3\u10EA\u10DC\u10DD\u10D1\u10D8 \u10D2\u10D0\u10E1\u10D0\u10E6\u10D4\u10D1${t.keys.length>1?"\u10D4\u10D1\u10D8":"\u10D8"}: ${E(t.keys,", ")}`;case"invalid_key":return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D2\u10D0\u10E1\u10D0\u10E6\u10D4\u10D1\u10D8 ${t.origin}-\u10E8\u10D8`;case"invalid_union":return"\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0";case"invalid_element":return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10DB\u10DC\u10D8\u10E8\u10D5\u10DC\u10D4\u10DA\u10DD\u10D1\u10D0 ${t.origin}-\u10E8\u10D8`;default:return"\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0"}}};function Ty(){return{localeError:cw()}}var lw=()=>{let n={string:{unit:"\u178F\u17BD\u17A2\u1780\u17D2\u179F\u179A",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"},file:{unit:"\u1794\u17C3",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"},array:{unit:"\u1792\u17B6\u178F\u17BB",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"},set:{unit:"\u1792\u17B6\u178F\u17BB",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"}};function e(t){return n[t]??null}let r={regex:"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B",email:"\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793\u17A2\u17CA\u17B8\u1798\u17C2\u179B",url:"URL",emoji:"\u179F\u1789\u17D2\u1789\u17B6\u17A2\u17B6\u179A\u1798\u17D2\u1798\u178E\u17CD",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u1780\u17B6\u179B\u1794\u179A\u17B7\u1785\u17D2\u1786\u17C1\u1791 \u1793\u17B7\u1784\u1798\u17C9\u17C4\u1784 ISO",date:"\u1780\u17B6\u179B\u1794\u179A\u17B7\u1785\u17D2\u1786\u17C1\u1791 ISO",time:"\u1798\u17C9\u17C4\u1784 ISO",duration:"\u179A\u1799\u17C8\u1796\u17C1\u179B ISO",ipv4:"\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv4",ipv6:"\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv6",cidrv4:"\u178A\u17C2\u1793\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv4",cidrv6:"\u178A\u17C2\u1793\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv6",base64:"\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u17A2\u17CA\u17B7\u1780\u17BC\u178A base64",base64url:"\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u17A2\u17CA\u17B7\u1780\u17BC\u178A base64url",json_string:"\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A JSON",e164:"\u179B\u17C1\u1781 E.164",jwt:"JWT",template_literal:"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B"},i={nan:"NaN",number:"\u179B\u17C1\u1781",array:"\u17A2\u17B6\u179A\u17C1 (Array)",null:"\u1782\u17D2\u1798\u17B6\u1793\u178F\u1798\u17D2\u179B\u17C3 (null)"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=C(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A instanceof ${t.expected} \u1794\u17C9\u17BB\u1793\u17D2\u178F\u17C2\u1791\u1791\u17BD\u179B\u1794\u17B6\u1793 ${a}`:`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${o} \u1794\u17C9\u17BB\u1793\u17D2\u178F\u17C2\u1791\u1791\u17BD\u179B\u1794\u17B6\u1793 ${a}`}case"invalid_value":return t.values.length===1?`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${D(t.values[0])}`:`\u1787\u1798\u17D2\u179A\u17BE\u179F\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1787\u17B6\u1798\u17BD\u1799\u1780\u17D2\u1793\u17BB\u1784\u1785\u17C6\u178E\u17C4\u1798 ${E(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?`\u1792\u17C6\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${t.origin??"\u178F\u1798\u17D2\u179B\u17C3"} ${o} ${t.maximum.toString()} ${s.unit??"\u1792\u17B6\u178F\u17BB"}`:`\u1792\u17C6\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${t.origin??"\u178F\u1798\u17D2\u179B\u17C3"} ${o} ${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`\u178F\u17BC\u1785\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${t.origin} ${o} ${t.minimum.toString()} ${s.unit}`:`\u178F\u17BC\u1785\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${t.origin} ${o} ${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1785\u17B6\u1794\u17CB\u1795\u17D2\u178F\u17BE\u1798\u178A\u17C4\u1799 "${o.prefix}"`:o.format==="ends_with"?`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1794\u1789\u17D2\u1785\u1794\u17CB\u178A\u17C4\u1799 "${o.suffix}"`:o.format==="includes"?`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1798\u17B6\u1793 "${o.includes}"`:o.format==="regex"?`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u178F\u17C2\u1795\u17D2\u1782\u17BC\u1795\u17D2\u1782\u1784\u1793\u17B9\u1784\u1791\u1798\u17D2\u179A\u1784\u17CB\u178A\u17C2\u179B\u1794\u17B6\u1793\u1780\u17C6\u178E\u178F\u17CB ${o.pattern}`:`\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 ${r[o.format]??t.format}`}case"not_multiple_of":return`\u179B\u17C1\u1781\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u178F\u17C2\u1787\u17B6\u1796\u17A0\u17BB\u1782\u17BB\u178E\u1793\u17C3 ${t.divisor}`;case"unrecognized_keys":return`\u179A\u1780\u1783\u17BE\u1789\u179F\u17C4\u1798\u17B7\u1793\u179F\u17D2\u1782\u17B6\u179B\u17CB\u17D6 ${E(t.keys,", ")}`;case"invalid_key":return`\u179F\u17C4\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u1793\u17C5\u1780\u17D2\u1793\u17BB\u1784 ${t.origin}`;case"invalid_union":return"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C";case"invalid_element":return`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u1793\u17C5\u1780\u17D2\u1793\u17BB\u1784 ${t.origin}`;default:return"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C"}}};function bs(){return{localeError:lw()}}function Py(){return bs()}var uw=()=>{let n={string:{unit:"\uBB38\uC790",verb:"to have"},file:{unit:"\uBC14\uC774\uD2B8",verb:"to have"},array:{unit:"\uAC1C",verb:"to have"},set:{unit:"\uAC1C",verb:"to have"}};function e(t){return n[t]??null}let r={regex:"\uC785\uB825",email:"\uC774\uBA54\uC77C \uC8FC\uC18C",url:"URL",emoji:"\uC774\uBAA8\uC9C0",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \uB0A0\uC9DC\uC2DC\uAC04",date:"ISO \uB0A0\uC9DC",time:"ISO \uC2DC\uAC04",duration:"ISO \uAE30\uAC04",ipv4:"IPv4 \uC8FC\uC18C",ipv6:"IPv6 \uC8FC\uC18C",cidrv4:"IPv4 \uBC94\uC704",cidrv6:"IPv6 \uBC94\uC704",base64:"base64 \uC778\uCF54\uB529 \uBB38\uC790\uC5F4",base64url:"base64url \uC778\uCF54\uB529 \uBB38\uC790\uC5F4",json_string:"JSON \uBB38\uC790\uC5F4",e164:"E.164 \uBC88\uD638",jwt:"JWT",template_literal:"\uC785\uB825"},i={nan:"NaN"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=C(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`\uC798\uBABB\uB41C \uC785\uB825: \uC608\uC0C1 \uD0C0\uC785\uC740 instanceof ${t.expected}, \uBC1B\uC740 \uD0C0\uC785\uC740 ${a}\uC785\uB2C8\uB2E4`:`\uC798\uBABB\uB41C \uC785\uB825: \uC608\uC0C1 \uD0C0\uC785\uC740 ${o}, \uBC1B\uC740 \uD0C0\uC785\uC740 ${a}\uC785\uB2C8\uB2E4`}case"invalid_value":return t.values.length===1?`\uC798\uBABB\uB41C \uC785\uB825: \uAC12\uC740 ${D(t.values[0])} \uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4`:`\uC798\uBABB\uB41C \uC635\uC158: ${E(t.values,"\uB610\uB294 ")} \uC911 \uD558\uB098\uC5EC\uC57C \uD569\uB2C8\uB2E4`;case"too_big":{let o=t.inclusive?"\uC774\uD558":"\uBBF8\uB9CC",s=o==="\uBBF8\uB9CC"?"\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4":"\uC5EC\uC57C \uD569\uB2C8\uB2E4",a=e(t.origin),c=a?.unit??"\uC694\uC18C";return a?`${t.origin??"\uAC12"}\uC774 \uB108\uBB34 \uD07D\uB2C8\uB2E4: ${t.maximum.toString()}${c} ${o}${s}`:`${t.origin??"\uAC12"}\uC774 \uB108\uBB34 \uD07D\uB2C8\uB2E4: ${t.maximum.toString()} ${o}${s}`}case"too_small":{let o=t.inclusive?"\uC774\uC0C1":"\uCD08\uACFC",s=o==="\uC774\uC0C1"?"\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4":"\uC5EC\uC57C \uD569\uB2C8\uB2E4",a=e(t.origin),c=a?.unit??"\uC694\uC18C";return a?`${t.origin??"\uAC12"}\uC774 \uB108\uBB34 \uC791\uC2B5\uB2C8\uB2E4: ${t.minimum.toString()}${c} ${o}${s}`:`${t.origin??"\uAC12"}\uC774 \uB108\uBB34 \uC791\uC2B5\uB2C8\uB2E4: ${t.minimum.toString()} ${o}${s}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${o.prefix}"(\uC73C)\uB85C \uC2DC\uC791\uD574\uC57C \uD569\uB2C8\uB2E4`:o.format==="ends_with"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${o.suffix}"(\uC73C)\uB85C \uB05D\uB098\uC57C \uD569\uB2C8\uB2E4`:o.format==="includes"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${o.includes}"\uC744(\uB97C) \uD3EC\uD568\uD574\uC57C \uD569\uB2C8\uB2E4`:o.format==="regex"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: \uC815\uADDC\uC2DD ${o.pattern} \uD328\uD134\uACFC \uC77C\uCE58\uD574\uC57C \uD569\uB2C8\uB2E4`:`\uC798\uBABB\uB41C ${r[o.format]??t.format}`}case"not_multiple_of":return`\uC798\uBABB\uB41C \uC22B\uC790: ${t.divisor}\uC758 \uBC30\uC218\uC5EC\uC57C \uD569\uB2C8\uB2E4`;case"unrecognized_keys":return`\uC778\uC2DD\uD560 \uC218 \uC5C6\uB294 \uD0A4: ${E(t.keys,", ")}`;case"invalid_key":return`\uC798\uBABB\uB41C \uD0A4: ${t.origin}`;case"invalid_union":return"\uC798\uBABB\uB41C \uC785\uB825";case"invalid_element":return`\uC798\uBABB\uB41C \uAC12: ${t.origin}`;default:return"\uC798\uBABB\uB41C \uC785\uB825"}}};function Ry(){return{localeError:uw()}}var Si=n=>n.charAt(0).toUpperCase()+n.slice(1);function Ny(n){let e=Math.abs(n),r=e%10,i=e%100;return i>=11&&i<=19||r===0?"many":r===1?"one":"few"}var dw=()=>{let n={string:{unit:{one:"simbolis",few:"simboliai",many:"simboli\u0173"},verb:{smaller:{inclusive:"turi b\u016Bti ne ilgesn\u0117 kaip",notInclusive:"turi b\u016Bti trumpesn\u0117 kaip"},bigger:{inclusive:"turi b\u016Bti ne trumpesn\u0117 kaip",notInclusive:"turi b\u016Bti ilgesn\u0117 kaip"}}},file:{unit:{one:"baitas",few:"baitai",many:"bait\u0173"},verb:{smaller:{inclusive:"turi b\u016Bti ne didesnis kaip",notInclusive:"turi b\u016Bti ma\u017Eesnis kaip"},bigger:{inclusive:"turi b\u016Bti ne ma\u017Eesnis kaip",notInclusive:"turi b\u016Bti didesnis kaip"}}},array:{unit:{one:"element\u0105",few:"elementus",many:"element\u0173"},verb:{smaller:{inclusive:"turi tur\u0117ti ne daugiau kaip",notInclusive:"turi tur\u0117ti ma\u017Eiau kaip"},bigger:{inclusive:"turi tur\u0117ti ne ma\u017Eiau kaip",notInclusive:"turi tur\u0117ti daugiau kaip"}}},set:{unit:{one:"element\u0105",few:"elementus",many:"element\u0173"},verb:{smaller:{inclusive:"turi tur\u0117ti ne daugiau kaip",notInclusive:"turi tur\u0117ti ma\u017Eiau kaip"},bigger:{inclusive:"turi tur\u0117ti ne ma\u017Eiau kaip",notInclusive:"turi tur\u0117ti daugiau kaip"}}}};function e(t,o,s,a){let c=n[t]??null;return c===null?c:{unit:c.unit[o],verb:c.verb[a][s?"inclusive":"notInclusive"]}}let r={regex:"\u012Fvestis",email:"el. pa\u0161to adresas",url:"URL",emoji:"jaustukas",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO data ir laikas",date:"ISO data",time:"ISO laikas",duration:"ISO trukm\u0117",ipv4:"IPv4 adresas",ipv6:"IPv6 adresas",cidrv4:"IPv4 tinklo prefiksas (CIDR)",cidrv6:"IPv6 tinklo prefiksas (CIDR)",base64:"base64 u\u017Ekoduota eilut\u0117",base64url:"base64url u\u017Ekoduota eilut\u0117",json_string:"JSON eilut\u0117",e164:"E.164 numeris",jwt:"JWT",template_literal:"\u012Fvestis"},i={nan:"NaN",number:"skai\u010Dius",bigint:"sveikasis skai\u010Dius",string:"eilut\u0117",boolean:"login\u0117 reik\u0161m\u0117",undefined:"neapibr\u0117\u017Eta reik\u0161m\u0117",function:"funkcija",symbol:"simbolis",array:"masyvas",object:"objektas",null:"nulin\u0117 reik\u0161m\u0117"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=C(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`Gautas tipas ${a}, o tik\u0117tasi - instanceof ${t.expected}`:`Gautas tipas ${a}, o tik\u0117tasi - ${o}`}case"invalid_value":return t.values.length===1?`Privalo b\u016Bti ${D(t.values[0])}`:`Privalo b\u016Bti vienas i\u0161 ${E(t.values,"|")} pasirinkim\u0173`;case"too_big":{let o=i[t.origin]??t.origin,s=e(t.origin,Ny(Number(t.maximum)),t.inclusive??!1,"smaller");if(s?.verb)return`${Si(o??t.origin??"reik\u0161m\u0117")} ${s.verb} ${t.maximum.toString()} ${s.unit??"element\u0173"}`;let a=t.inclusive?"ne didesnis kaip":"ma\u017Eesnis kaip";return`${Si(o??t.origin??"reik\u0161m\u0117")} turi b\u016Bti ${a} ${t.maximum.toString()} ${s?.unit}`}case"too_small":{let o=i[t.origin]??t.origin,s=e(t.origin,Ny(Number(t.minimum)),t.inclusive??!1,"bigger");if(s?.verb)return`${Si(o??t.origin??"reik\u0161m\u0117")} ${s.verb} ${t.minimum.toString()} ${s.unit??"element\u0173"}`;let a=t.inclusive?"ne ma\u017Eesnis kaip":"didesnis kaip";return`${Si(o??t.origin??"reik\u0161m\u0117")} turi b\u016Bti ${a} ${t.minimum.toString()} ${s?.unit}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`Eilut\u0117 privalo prasid\u0117ti "${o.prefix}"`:o.format==="ends_with"?`Eilut\u0117 privalo pasibaigti "${o.suffix}"`:o.format==="includes"?`Eilut\u0117 privalo \u012Ftraukti "${o.includes}"`:o.format==="regex"?`Eilut\u0117 privalo atitikti ${o.pattern}`:`Neteisingas ${r[o.format]??t.format}`}case"not_multiple_of":return`Skai\u010Dius privalo b\u016Bti ${t.divisor} kartotinis.`;case"unrecognized_keys":return`Neatpa\u017Eint${t.keys.length>1?"i":"as"} rakt${t.keys.length>1?"ai":"as"}: ${E(t.keys,", ")}`;case"invalid_key":return"Rastas klaidingas raktas";case"invalid_union":return"Klaidinga \u012Fvestis";case"invalid_element":{let o=i[t.origin]??t.origin;return`${Si(o??t.origin??"reik\u0161m\u0117")} turi klaiding\u0105 \u012Fvest\u012F`}default:return"Klaidinga \u012Fvestis"}}};function zy(){return{localeError:dw()}}var pw=()=>{let n={string:{unit:"\u0437\u043D\u0430\u0446\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"},file:{unit:"\u0431\u0430\u0458\u0442\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"},array:{unit:"\u0441\u0442\u0430\u0432\u043A\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"},set:{unit:"\u0441\u0442\u0430\u0432\u043A\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"}};function e(t){return n[t]??null}let r={regex:"\u0432\u043D\u0435\u0441",email:"\u0430\u0434\u0440\u0435\u0441\u0430 \u043D\u0430 \u0435-\u043F\u043E\u0448\u0442\u0430",url:"URL",emoji:"\u0435\u043C\u043E\u045F\u0438",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0434\u0430\u0442\u0443\u043C \u0438 \u0432\u0440\u0435\u043C\u0435",date:"ISO \u0434\u0430\u0442\u0443\u043C",time:"ISO \u0432\u0440\u0435\u043C\u0435",duration:"ISO \u0432\u0440\u0435\u043C\u0435\u0442\u0440\u0430\u0435\u045A\u0435",ipv4:"IPv4 \u0430\u0434\u0440\u0435\u0441\u0430",ipv6:"IPv6 \u0430\u0434\u0440\u0435\u0441\u0430",cidrv4:"IPv4 \u043E\u043F\u0441\u0435\u0433",cidrv6:"IPv6 \u043E\u043F\u0441\u0435\u0433",base64:"base64-\u0435\u043D\u043A\u043E\u0434\u0438\u0440\u0430\u043D\u0430 \u043D\u0438\u0437\u0430",base64url:"base64url-\u0435\u043D\u043A\u043E\u0434\u0438\u0440\u0430\u043D\u0430 \u043D\u0438\u0437\u0430",json_string:"JSON \u043D\u0438\u0437\u0430",e164:"E.164 \u0431\u0440\u043E\u0458",jwt:"JWT",template_literal:"\u0432\u043D\u0435\u0441"},i={nan:"NaN",number:"\u0431\u0440\u043E\u0458",array:"\u043D\u0438\u0437\u0430"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=C(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 instanceof ${t.expected}, \u043F\u0440\u0438\u043C\u0435\u043D\u043E ${a}`:`\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${o}, \u043F\u0440\u0438\u043C\u0435\u043D\u043E ${a}`}case"invalid_value":return t.values.length===1?`Invalid input: expected ${D(t.values[0])}`:`\u0413\u0440\u0435\u0448\u0430\u043D\u0430 \u043E\u043F\u0446\u0438\u0458\u0430: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 \u0435\u0434\u043D\u0430 ${E(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u0433\u043E\u043B\u0435\u043C: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${t.origin??"\u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442\u0430"} \u0434\u0430 \u0438\u043C\u0430 ${o}${t.maximum.toString()} ${s.unit??"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0438"}`:`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u0433\u043E\u043B\u0435\u043C: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${t.origin??"\u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442\u0430"} \u0434\u0430 \u0431\u0438\u0434\u0435 ${o}${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u043C\u0430\u043B: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${t.origin} \u0434\u0430 \u0438\u043C\u0430 ${o}${t.minimum.toString()} ${s.unit}`:`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u043C\u0430\u043B: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${t.origin} \u0434\u0430 \u0431\u0438\u0434\u0435 ${o}${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0437\u0430\u043F\u043E\u0447\u043D\u0443\u0432\u0430 \u0441\u043E "${o.prefix}"`:o.format==="ends_with"?`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0437\u0430\u0432\u0440\u0448\u0443\u0432\u0430 \u0441\u043E "${o.suffix}"`:o.format==="includes"?`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0432\u043A\u043B\u0443\u0447\u0443\u0432\u0430 "${o.includes}"`:o.format==="regex"?`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u043E\u0434\u0433\u043E\u0430\u0440\u0430 \u043D\u0430 \u043F\u0430\u0442\u0435\u0440\u043D\u043E\u0442 ${o.pattern}`:`Invalid ${r[o.format]??t.format}`}case"not_multiple_of":return`\u0413\u0440\u0435\u0448\u0435\u043D \u0431\u0440\u043E\u0458: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0431\u0438\u0434\u0435 \u0434\u0435\u043B\u0438\u0432 \u0441\u043E ${t.divisor}`;case"unrecognized_keys":return`${t.keys.length>1?"\u041D\u0435\u043F\u0440\u0435\u043F\u043E\u0437\u043D\u0430\u0435\u043D\u0438 \u043A\u043B\u0443\u0447\u0435\u0432\u0438":"\u041D\u0435\u043F\u0440\u0435\u043F\u043E\u0437\u043D\u0430\u0435\u043D \u043A\u043B\u0443\u0447"}: ${E(t.keys,", ")}`;case"invalid_key":return`\u0413\u0440\u0435\u0448\u0435\u043D \u043A\u043B\u0443\u0447 \u0432\u043E ${t.origin}`;case"invalid_union":return"\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441";case"invalid_element":return`\u0413\u0440\u0435\u0448\u043D\u0430 \u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442 \u0432\u043E ${t.origin}`;default:return"\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441"}}};function Dy(){return{localeError:pw()}}var mw=()=>{let n={string:{unit:"aksara",verb:"mempunyai"},file:{unit:"bait",verb:"mempunyai"},array:{unit:"elemen",verb:"mempunyai"},set:{unit:"elemen",verb:"mempunyai"}};function e(t){return n[t]??null}let r={regex:"input",email:"alamat e-mel",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"tarikh masa ISO",date:"tarikh ISO",time:"masa ISO",duration:"tempoh ISO",ipv4:"alamat IPv4",ipv6:"alamat IPv6",cidrv4:"julat IPv4",cidrv6:"julat IPv6",base64:"string dikodkan base64",base64url:"string dikodkan base64url",json_string:"string JSON",e164:"nombor E.164",jwt:"JWT",template_literal:"input"},i={nan:"NaN",number:"nombor"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=C(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`Input tidak sah: dijangka instanceof ${t.expected}, diterima ${a}`:`Input tidak sah: dijangka ${o}, diterima ${a}`}case"invalid_value":return t.values.length===1?`Input tidak sah: dijangka ${D(t.values[0])}`:`Pilihan tidak sah: dijangka salah satu daripada ${E(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?`Terlalu besar: dijangka ${t.origin??"nilai"} ${s.verb} ${o}${t.maximum.toString()} ${s.unit??"elemen"}`:`Terlalu besar: dijangka ${t.origin??"nilai"} adalah ${o}${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`Terlalu kecil: dijangka ${t.origin} ${s.verb} ${o}${t.minimum.toString()} ${s.unit}`:`Terlalu kecil: dijangka ${t.origin} adalah ${o}${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`String tidak sah: mesti bermula dengan "${o.prefix}"`:o.format==="ends_with"?`String tidak sah: mesti berakhir dengan "${o.suffix}"`:o.format==="includes"?`String tidak sah: mesti mengandungi "${o.includes}"`:o.format==="regex"?`String tidak sah: mesti sepadan dengan corak ${o.pattern}`:`${r[o.format]??t.format} tidak sah`}case"not_multiple_of":return`Nombor tidak sah: perlu gandaan ${t.divisor}`;case"unrecognized_keys":return`Kunci tidak dikenali: ${E(t.keys,", ")}`;case"invalid_key":return`Kunci tidak sah dalam ${t.origin}`;case"invalid_union":return"Input tidak sah";case"invalid_element":return`Nilai tidak sah dalam ${t.origin}`;default:return"Input tidak sah"}}};function Cy(){return{localeError:mw()}}var fw=()=>{let n={string:{unit:"tekens",verb:"heeft"},file:{unit:"bytes",verb:"heeft"},array:{unit:"elementen",verb:"heeft"},set:{unit:"elementen",verb:"heeft"}};function e(t){return n[t]??null}let r={regex:"invoer",email:"emailadres",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datum en tijd",date:"ISO datum",time:"ISO tijd",duration:"ISO duur",ipv4:"IPv4-adres",ipv6:"IPv6-adres",cidrv4:"IPv4-bereik",cidrv6:"IPv6-bereik",base64:"base64-gecodeerde tekst",base64url:"base64 URL-gecodeerde tekst",json_string:"JSON string",e164:"E.164-nummer",jwt:"JWT",template_literal:"invoer"},i={nan:"NaN",number:"getal"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=C(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`Ongeldige invoer: verwacht instanceof ${t.expected}, ontving ${a}`:`Ongeldige invoer: verwacht ${o}, ontving ${a}`}case"invalid_value":return t.values.length===1?`Ongeldige invoer: verwacht ${D(t.values[0])}`:`Ongeldige optie: verwacht \xE9\xE9n van ${E(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin),a=t.origin==="date"?"laat":t.origin==="string"?"lang":"groot";return s?`Te ${a}: verwacht dat ${t.origin??"waarde"} ${o}${t.maximum.toString()} ${s.unit??"elementen"} ${s.verb}`:`Te ${a}: verwacht dat ${t.origin??"waarde"} ${o}${t.maximum.toString()} is`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin),a=t.origin==="date"?"vroeg":t.origin==="string"?"kort":"klein";return s?`Te ${a}: verwacht dat ${t.origin} ${o}${t.minimum.toString()} ${s.unit} ${s.verb}`:`Te ${a}: verwacht dat ${t.origin} ${o}${t.minimum.toString()} is`}case"invalid_format":{let o=t;return o.format==="starts_with"?`Ongeldige tekst: moet met "${o.prefix}" beginnen`:o.format==="ends_with"?`Ongeldige tekst: moet op "${o.suffix}" eindigen`:o.format==="includes"?`Ongeldige tekst: moet "${o.includes}" bevatten`:o.format==="regex"?`Ongeldige tekst: moet overeenkomen met patroon ${o.pattern}`:`Ongeldig: ${r[o.format]??t.format}`}case"not_multiple_of":return`Ongeldig getal: moet een veelvoud van ${t.divisor} zijn`;case"unrecognized_keys":return`Onbekende key${t.keys.length>1?"s":""}: ${E(t.keys,", ")}`;case"invalid_key":return`Ongeldige key in ${t.origin}`;case"invalid_union":return"Ongeldige invoer";case"invalid_element":return`Ongeldige waarde in ${t.origin}`;default:return"Ongeldige invoer"}}};function Ly(){return{localeError:fw()}}var hw=()=>{let n={string:{unit:"tegn",verb:"\xE5 ha"},file:{unit:"bytes",verb:"\xE5 ha"},array:{unit:"elementer",verb:"\xE5 inneholde"},set:{unit:"elementer",verb:"\xE5 inneholde"}};function e(t){return n[t]??null}let r={regex:"input",email:"e-postadresse",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dato- og klokkeslett",date:"ISO-dato",time:"ISO-klokkeslett",duration:"ISO-varighet",ipv4:"IPv4-omr\xE5de",ipv6:"IPv6-omr\xE5de",cidrv4:"IPv4-spekter",cidrv6:"IPv6-spekter",base64:"base64-enkodet streng",base64url:"base64url-enkodet streng",json_string:"JSON-streng",e164:"E.164-nummer",jwt:"JWT",template_literal:"input"},i={nan:"NaN",number:"tall",array:"liste"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=C(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`Ugyldig input: forventet instanceof ${t.expected}, fikk ${a}`:`Ugyldig input: forventet ${o}, fikk ${a}`}case"invalid_value":return t.values.length===1?`Ugyldig verdi: forventet ${D(t.values[0])}`:`Ugyldig valg: forventet en av ${E(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?`For stor(t): forventet ${t.origin??"value"} til \xE5 ha ${o}${t.maximum.toString()} ${s.unit??"elementer"}`:`For stor(t): forventet ${t.origin??"value"} til \xE5 ha ${o}${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`For lite(n): forventet ${t.origin} til \xE5 ha ${o}${t.minimum.toString()} ${s.unit}`:`For lite(n): forventet ${t.origin} til \xE5 ha ${o}${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`Ugyldig streng: m\xE5 starte med "${o.prefix}"`:o.format==="ends_with"?`Ugyldig streng: m\xE5 ende med "${o.suffix}"`:o.format==="includes"?`Ugyldig streng: m\xE5 inneholde "${o.includes}"`:o.format==="regex"?`Ugyldig streng: m\xE5 matche m\xF8nsteret ${o.pattern}`:`Ugyldig ${r[o.format]??t.format}`}case"not_multiple_of":return`Ugyldig tall: m\xE5 v\xE6re et multiplum av ${t.divisor}`;case"unrecognized_keys":return`${t.keys.length>1?"Ukjente n\xF8kler":"Ukjent n\xF8kkel"}: ${E(t.keys,", ")}`;case"invalid_key":return`Ugyldig n\xF8kkel i ${t.origin}`;case"invalid_union":return"Ugyldig input";case"invalid_element":return`Ugyldig verdi i ${t.origin}`;default:return"Ugyldig input"}}};function Ay(){return{localeError:hw()}}var gw=()=>{let n={string:{unit:"harf",verb:"olmal\u0131d\u0131r"},file:{unit:"bayt",verb:"olmal\u0131d\u0131r"},array:{unit:"unsur",verb:"olmal\u0131d\u0131r"},set:{unit:"unsur",verb:"olmal\u0131d\u0131r"}};function e(t){return n[t]??null}let r={regex:"giren",email:"epostag\xE2h",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO heng\xE2m\u0131",date:"ISO tarihi",time:"ISO zaman\u0131",duration:"ISO m\xFCddeti",ipv4:"IPv4 ni\u015F\xE2n\u0131",ipv6:"IPv6 ni\u015F\xE2n\u0131",cidrv4:"IPv4 menzili",cidrv6:"IPv6 menzili",base64:"base64-\u015Fifreli metin",base64url:"base64url-\u015Fifreli metin",json_string:"JSON metin",e164:"E.164 say\u0131s\u0131",jwt:"JWT",template_literal:"giren"},i={nan:"NaN",number:"numara",array:"saf",null:"gayb"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=C(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`F\xE2sit giren: umulan instanceof ${t.expected}, al\u0131nan ${a}`:`F\xE2sit giren: umulan ${o}, al\u0131nan ${a}`}case"invalid_value":return t.values.length===1?`F\xE2sit giren: umulan ${D(t.values[0])}`:`F\xE2sit tercih: m\xFBteberler ${E(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?`Fazla b\xFCy\xFCk: ${t.origin??"value"}, ${o}${t.maximum.toString()} ${s.unit??"elements"} sahip olmal\u0131yd\u0131.`:`Fazla b\xFCy\xFCk: ${t.origin??"value"}, ${o}${t.maximum.toString()} olmal\u0131yd\u0131.`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`Fazla k\xFC\xE7\xFCk: ${t.origin}, ${o}${t.minimum.toString()} ${s.unit} sahip olmal\u0131yd\u0131.`:`Fazla k\xFC\xE7\xFCk: ${t.origin}, ${o}${t.minimum.toString()} olmal\u0131yd\u0131.`}case"invalid_format":{let o=t;return o.format==="starts_with"?`F\xE2sit metin: "${o.prefix}" ile ba\u015Flamal\u0131.`:o.format==="ends_with"?`F\xE2sit metin: "${o.suffix}" ile bitmeli.`:o.format==="includes"?`F\xE2sit metin: "${o.includes}" ihtiv\xE2 etmeli.`:o.format==="regex"?`F\xE2sit metin: ${o.pattern} nak\u015F\u0131na uymal\u0131.`:`F\xE2sit ${r[o.format]??t.format}`}case"not_multiple_of":return`F\xE2sit say\u0131: ${t.divisor} kat\u0131 olmal\u0131yd\u0131.`;case"unrecognized_keys":return`Tan\u0131nmayan anahtar ${t.keys.length>1?"s":""}: ${E(t.keys,", ")}`;case"invalid_key":return`${t.origin} i\xE7in tan\u0131nmayan anahtar var.`;case"invalid_union":return"Giren tan\u0131namad\u0131.";case"invalid_element":return`${t.origin} i\xE7in tan\u0131nmayan k\u0131ymet var.`;default:return"K\u0131ymet tan\u0131namad\u0131."}}};function Oy(){return{localeError:gw()}}var yw=()=>{let n={string:{unit:"\u062A\u0648\u06A9\u064A",verb:"\u0648\u0644\u0631\u064A"},file:{unit:"\u0628\u0627\u06CC\u067C\u0633",verb:"\u0648\u0644\u0631\u064A"},array:{unit:"\u062A\u0648\u06A9\u064A",verb:"\u0648\u0644\u0631\u064A"},set:{unit:"\u062A\u0648\u06A9\u064A",verb:"\u0648\u0644\u0631\u064A"}};function e(t){return n[t]??null}let r={regex:"\u0648\u0631\u0648\u062F\u064A",email:"\u0628\u0631\u06CC\u069A\u0646\u0627\u0644\u06CC\u06A9",url:"\u06CC\u0648 \u0622\u0631 \u0627\u0644",emoji:"\u0627\u06CC\u0645\u0648\u062C\u064A",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0646\u06CC\u067C\u0647 \u0627\u0648 \u0648\u062E\u062A",date:"\u0646\u06D0\u067C\u0647",time:"\u0648\u062E\u062A",duration:"\u0645\u0648\u062F\u0647",ipv4:"\u062F IPv4 \u067E\u062A\u0647",ipv6:"\u062F IPv6 \u067E\u062A\u0647",cidrv4:"\u062F IPv4 \u0633\u0627\u062D\u0647",cidrv6:"\u062F IPv6 \u0633\u0627\u062D\u0647",base64:"base64-encoded \u0645\u062A\u0646",base64url:"base64url-encoded \u0645\u062A\u0646",json_string:"JSON \u0645\u062A\u0646",e164:"\u062F E.164 \u0634\u0645\u06D0\u0631\u0647",jwt:"JWT",template_literal:"\u0648\u0631\u0648\u062F\u064A"},i={nan:"NaN",number:"\u0639\u062F\u062F",array:"\u0627\u0631\u06D0"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=C(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`\u0646\u0627\u0633\u0645 \u0648\u0631\u0648\u062F\u064A: \u0628\u0627\u06CC\u062F instanceof ${t.expected} \u0648\u0627\u06CC, \u0645\u06AB\u0631 ${a} \u062A\u0631\u0644\u0627\u0633\u0647 \u0634\u0648`:`\u0646\u0627\u0633\u0645 \u0648\u0631\u0648\u062F\u064A: \u0628\u0627\u06CC\u062F ${o} \u0648\u0627\u06CC, \u0645\u06AB\u0631 ${a} \u062A\u0631\u0644\u0627\u0633\u0647 \u0634\u0648`}case"invalid_value":return t.values.length===1?`\u0646\u0627\u0633\u0645 \u0648\u0631\u0648\u062F\u064A: \u0628\u0627\u06CC\u062F ${D(t.values[0])} \u0648\u0627\u06CC`:`\u0646\u0627\u0633\u0645 \u0627\u0646\u062A\u062E\u0627\u0628: \u0628\u0627\u06CC\u062F \u06CC\u0648 \u0644\u0647 ${E(t.values,"|")} \u0685\u062E\u0647 \u0648\u0627\u06CC`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?`\u0689\u06CC\u0631 \u0644\u0648\u06CC: ${t.origin??"\u0627\u0631\u0632\u069A\u062A"} \u0628\u0627\u06CC\u062F ${o}${t.maximum.toString()} ${s.unit??"\u0639\u0646\u0635\u0631\u0648\u0646\u0647"} \u0648\u0644\u0631\u064A`:`\u0689\u06CC\u0631 \u0644\u0648\u06CC: ${t.origin??"\u0627\u0631\u0632\u069A\u062A"} \u0628\u0627\u06CC\u062F ${o}${t.maximum.toString()} \u0648\u064A`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`\u0689\u06CC\u0631 \u06A9\u0648\u0686\u0646\u06CC: ${t.origin} \u0628\u0627\u06CC\u062F ${o}${t.minimum.toString()} ${s.unit} \u0648\u0644\u0631\u064A`:`\u0689\u06CC\u0631 \u06A9\u0648\u0686\u0646\u06CC: ${t.origin} \u0628\u0627\u06CC\u062F ${o}${t.minimum.toString()} \u0648\u064A`}case"invalid_format":{let o=t;return o.format==="starts_with"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F \u062F "${o.prefix}" \u0633\u0631\u0647 \u067E\u06CC\u0644 \u0634\u064A`:o.format==="ends_with"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F \u062F "${o.suffix}" \u0633\u0631\u0647 \u067E\u0627\u06CC \u062A\u0647 \u0648\u0631\u0633\u064A\u0696\u064A`:o.format==="includes"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F "${o.includes}" \u0648\u0644\u0631\u064A`:o.format==="regex"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F \u062F ${o.pattern} \u0633\u0631\u0647 \u0645\u0637\u0627\u0628\u0642\u062A \u0648\u0644\u0631\u064A`:`${r[o.format]??t.format} \u0646\u0627\u0633\u0645 \u062F\u06CC`}case"not_multiple_of":return`\u0646\u0627\u0633\u0645 \u0639\u062F\u062F: \u0628\u0627\u06CC\u062F \u062F ${t.divisor} \u0645\u0636\u0631\u0628 \u0648\u064A`;case"unrecognized_keys":return`\u0646\u0627\u0633\u0645 ${t.keys.length>1?"\u06A9\u0644\u06CC\u0689\u0648\u0646\u0647":"\u06A9\u0644\u06CC\u0689"}: ${E(t.keys,", ")}`;case"invalid_key":return`\u0646\u0627\u0633\u0645 \u06A9\u0644\u06CC\u0689 \u067E\u0647 ${t.origin} \u06A9\u06D0`;case"invalid_union":return"\u0646\u0627\u0633\u0645\u0647 \u0648\u0631\u0648\u062F\u064A";case"invalid_element":return`\u0646\u0627\u0633\u0645 \u0639\u0646\u0635\u0631 \u067E\u0647 ${t.origin} \u06A9\u06D0`;default:return"\u0646\u0627\u0633\u0645\u0647 \u0648\u0631\u0648\u062F\u064A"}}};function My(){return{localeError:yw()}}var vw=()=>{let n={string:{unit:"znak\xF3w",verb:"mie\u0107"},file:{unit:"bajt\xF3w",verb:"mie\u0107"},array:{unit:"element\xF3w",verb:"mie\u0107"},set:{unit:"element\xF3w",verb:"mie\u0107"}};function e(t){return n[t]??null}let r={regex:"wyra\u017Cenie",email:"adres email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data i godzina w formacie ISO",date:"data w formacie ISO",time:"godzina w formacie ISO",duration:"czas trwania ISO",ipv4:"adres IPv4",ipv6:"adres IPv6",cidrv4:"zakres IPv4",cidrv6:"zakres IPv6",base64:"ci\u0105g znak\xF3w zakodowany w formacie base64",base64url:"ci\u0105g znak\xF3w zakodowany w formacie base64url",json_string:"ci\u0105g znak\xF3w w formacie JSON",e164:"liczba E.164",jwt:"JWT",template_literal:"wej\u015Bcie"},i={nan:"NaN",number:"liczba",array:"tablica"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=C(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano instanceof ${t.expected}, otrzymano ${a}`:`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano ${o}, otrzymano ${a}`}case"invalid_value":return t.values.length===1?`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano ${D(t.values[0])}`:`Nieprawid\u0142owa opcja: oczekiwano jednej z warto\u015Bci ${E(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?`Za du\u017Ca warto\u015B\u0107: oczekiwano, \u017Ce ${t.origin??"warto\u015B\u0107"} b\u0119dzie mie\u0107 ${o}${t.maximum.toString()} ${s.unit??"element\xF3w"}`:`Zbyt du\u017C(y/a/e): oczekiwano, \u017Ce ${t.origin??"warto\u015B\u0107"} b\u0119dzie wynosi\u0107 ${o}${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`Za ma\u0142a warto\u015B\u0107: oczekiwano, \u017Ce ${t.origin??"warto\u015B\u0107"} b\u0119dzie mie\u0107 ${o}${t.minimum.toString()} ${s.unit??"element\xF3w"}`:`Zbyt ma\u0142(y/a/e): oczekiwano, \u017Ce ${t.origin??"warto\u015B\u0107"} b\u0119dzie wynosi\u0107 ${o}${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi zaczyna\u0107 si\u0119 od "${o.prefix}"`:o.format==="ends_with"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi ko\u0144czy\u0107 si\u0119 na "${o.suffix}"`:o.format==="includes"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi zawiera\u0107 "${o.includes}"`:o.format==="regex"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi odpowiada\u0107 wzorcowi ${o.pattern}`:`Nieprawid\u0142ow(y/a/e) ${r[o.format]??t.format}`}case"not_multiple_of":return`Nieprawid\u0142owa liczba: musi by\u0107 wielokrotno\u015Bci\u0105 ${t.divisor}`;case"unrecognized_keys":return`Nierozpoznane klucze${t.keys.length>1?"s":""}: ${E(t.keys,", ")}`;case"invalid_key":return`Nieprawid\u0142owy klucz w ${t.origin}`;case"invalid_union":return"Nieprawid\u0142owe dane wej\u015Bciowe";case"invalid_element":return`Nieprawid\u0142owa warto\u015B\u0107 w ${t.origin}`;default:return"Nieprawid\u0142owe dane wej\u015Bciowe"}}};function jy(){return{localeError:vw()}}var bw=()=>{let n={string:{unit:"caracteres",verb:"ter"},file:{unit:"bytes",verb:"ter"},array:{unit:"itens",verb:"ter"},set:{unit:"itens",verb:"ter"}};function e(t){return n[t]??null}let r={regex:"padr\xE3o",email:"endere\xE7o de e-mail",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data e hora ISO",date:"data ISO",time:"hora ISO",duration:"dura\xE7\xE3o ISO",ipv4:"endere\xE7o IPv4",ipv6:"endere\xE7o IPv6",cidrv4:"faixa de IPv4",cidrv6:"faixa de IPv6",base64:"texto codificado em base64",base64url:"URL codificada em base64",json_string:"texto JSON",e164:"n\xFAmero E.164",jwt:"JWT",template_literal:"entrada"},i={nan:"NaN",number:"n\xFAmero",null:"nulo"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=C(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`Tipo inv\xE1lido: esperado instanceof ${t.expected}, recebido ${a}`:`Tipo inv\xE1lido: esperado ${o}, recebido ${a}`}case"invalid_value":return t.values.length===1?`Entrada inv\xE1lida: esperado ${D(t.values[0])}`:`Op\xE7\xE3o inv\xE1lida: esperada uma das ${E(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?`Muito grande: esperado que ${t.origin??"valor"} tivesse ${o}${t.maximum.toString()} ${s.unit??"elementos"}`:`Muito grande: esperado que ${t.origin??"valor"} fosse ${o}${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`Muito pequeno: esperado que ${t.origin} tivesse ${o}${t.minimum.toString()} ${s.unit}`:`Muito pequeno: esperado que ${t.origin} fosse ${o}${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`Texto inv\xE1lido: deve come\xE7ar com "${o.prefix}"`:o.format==="ends_with"?`Texto inv\xE1lido: deve terminar com "${o.suffix}"`:o.format==="includes"?`Texto inv\xE1lido: deve incluir "${o.includes}"`:o.format==="regex"?`Texto inv\xE1lido: deve corresponder ao padr\xE3o ${o.pattern}`:`${r[o.format]??t.format} inv\xE1lido`}case"not_multiple_of":return`N\xFAmero inv\xE1lido: deve ser m\xFAltiplo de ${t.divisor}`;case"unrecognized_keys":return`Chave${t.keys.length>1?"s":""} desconhecida${t.keys.length>1?"s":""}: ${E(t.keys,", ")}`;case"invalid_key":return`Chave inv\xE1lida em ${t.origin}`;case"invalid_union":return"Entrada inv\xE1lida";case"invalid_element":return`Valor inv\xE1lido em ${t.origin}`;default:return"Campo inv\xE1lido"}}};function Uy(){return{localeError:bw()}}function Fy(n,e,r,i){let t=Math.abs(n),o=t%10,s=t%100;return s>=11&&s<=19?i:o===1?e:o>=2&&o<=4?r:i}var _w=()=>{let n={string:{unit:{one:"\u0441\u0438\u043C\u0432\u043E\u043B",few:"\u0441\u0438\u043C\u0432\u043E\u043B\u0430",many:"\u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432"},verb:"\u0438\u043C\u0435\u0442\u044C"},file:{unit:{one:"\u0431\u0430\u0439\u0442",few:"\u0431\u0430\u0439\u0442\u0430",many:"\u0431\u0430\u0439\u0442"},verb:"\u0438\u043C\u0435\u0442\u044C"},array:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432"},verb:"\u0438\u043C\u0435\u0442\u044C"},set:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432"},verb:"\u0438\u043C\u0435\u0442\u044C"}};function e(t){return n[t]??null}let r={regex:"\u0432\u0432\u043E\u0434",email:"email \u0430\u0434\u0440\u0435\u0441",url:"URL",emoji:"\u044D\u043C\u043E\u0434\u0437\u0438",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0434\u0430\u0442\u0430 \u0438 \u0432\u0440\u0435\u043C\u044F",date:"ISO \u0434\u0430\u0442\u0430",time:"ISO \u0432\u0440\u0435\u043C\u044F",duration:"ISO \u0434\u043B\u0438\u0442\u0435\u043B\u044C\u043D\u043E\u0441\u0442\u044C",ipv4:"IPv4 \u0430\u0434\u0440\u0435\u0441",ipv6:"IPv6 \u0430\u0434\u0440\u0435\u0441",cidrv4:"IPv4 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",cidrv6:"IPv6 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",base64:"\u0441\u0442\u0440\u043E\u043A\u0430 \u0432 \u0444\u043E\u0440\u043C\u0430\u0442\u0435 base64",base64url:"\u0441\u0442\u0440\u043E\u043A\u0430 \u0432 \u0444\u043E\u0440\u043C\u0430\u0442\u0435 base64url",json_string:"JSON \u0441\u0442\u0440\u043E\u043A\u0430",e164:"\u043D\u043E\u043C\u0435\u0440 E.164",jwt:"JWT",template_literal:"\u0432\u0432\u043E\u0434"},i={nan:"NaN",number:"\u0447\u0438\u0441\u043B\u043E",array:"\u043C\u0430\u0441\u0441\u0438\u0432"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=C(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0432\u043E\u0434: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C instanceof ${t.expected}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D\u043E ${a}`:`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0432\u043E\u0434: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C ${o}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D\u043E ${a}`}case"invalid_value":return t.values.length===1?`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0432\u043E\u0434: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C ${D(t.values[0])}`:`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0430\u0440\u0438\u0430\u043D\u0442: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C \u043E\u0434\u043D\u043E \u0438\u0437 ${E(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);if(s){let a=Number(t.maximum),c=Fy(a,s.unit.one,s.unit.few,s.unit.many);return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u0431\u043E\u043B\u044C\u0448\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${t.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435"} \u0431\u0443\u0434\u0435\u0442 \u0438\u043C\u0435\u0442\u044C ${o}${t.maximum.toString()} ${c}`}return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u0431\u043E\u043B\u044C\u0448\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${t.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435"} \u0431\u0443\u0434\u0435\u0442 ${o}${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);if(s){let a=Number(t.minimum),c=Fy(a,s.unit.one,s.unit.few,s.unit.many);return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u043C\u0430\u043B\u0435\u043D\u044C\u043A\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${t.origin} \u0431\u0443\u0434\u0435\u0442 \u0438\u043C\u0435\u0442\u044C ${o}${t.minimum.toString()} ${c}`}return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u043C\u0430\u043B\u0435\u043D\u044C\u043A\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${t.origin} \u0431\u0443\u0434\u0435\u0442 ${o}${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u043D\u0430\u0447\u0438\u043D\u0430\u0442\u044C\u0441\u044F \u0441 "${o.prefix}"`:o.format==="ends_with"?`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u0437\u0430\u043A\u0430\u043D\u0447\u0438\u0432\u0430\u0442\u044C\u0441\u044F \u043D\u0430 "${o.suffix}"`:o.format==="includes"?`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u0441\u043E\u0434\u0435\u0440\u0436\u0430\u0442\u044C "${o.includes}"`:o.format==="regex"?`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043E\u0432\u0430\u0442\u044C \u0448\u0430\u0431\u043B\u043E\u043D\u0443 ${o.pattern}`:`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 ${r[o.format]??t.format}`}case"not_multiple_of":return`\u041D\u0435\u0432\u0435\u0440\u043D\u043E\u0435 \u0447\u0438\u0441\u043B\u043E: \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u043A\u0440\u0430\u0442\u043D\u044B\u043C ${t.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0441\u043F\u043E\u0437\u043D\u0430\u043D\u043D${t.keys.length>1?"\u044B\u0435":"\u044B\u0439"} \u043A\u043B\u044E\u0447${t.keys.length>1?"\u0438":""}: ${E(t.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u043A\u043B\u044E\u0447 \u0432 ${t.origin}`;case"invalid_union":return"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0435 \u0432\u0445\u043E\u0434\u043D\u044B\u0435 \u0434\u0430\u043D\u043D\u044B\u0435";case"invalid_element":return`\u041D\u0435\u0432\u0435\u0440\u043D\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u0432 ${t.origin}`;default:return"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0435 \u0432\u0445\u043E\u0434\u043D\u044B\u0435 \u0434\u0430\u043D\u043D\u044B\u0435"}}};function Zy(){return{localeError:_w()}}var xw=()=>{let n={string:{unit:"znakov",verb:"imeti"},file:{unit:"bajtov",verb:"imeti"},array:{unit:"elementov",verb:"imeti"},set:{unit:"elementov",verb:"imeti"}};function e(t){return n[t]??null}let r={regex:"vnos",email:"e-po\u0161tni naslov",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datum in \u010Das",date:"ISO datum",time:"ISO \u010Das",duration:"ISO trajanje",ipv4:"IPv4 naslov",ipv6:"IPv6 naslov",cidrv4:"obseg IPv4",cidrv6:"obseg IPv6",base64:"base64 kodiran niz",base64url:"base64url kodiran niz",json_string:"JSON niz",e164:"E.164 \u0161tevilka",jwt:"JWT",template_literal:"vnos"},i={nan:"NaN",number:"\u0161tevilo",array:"tabela"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=C(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`Neveljaven vnos: pri\u010Dakovano instanceof ${t.expected}, prejeto ${a}`:`Neveljaven vnos: pri\u010Dakovano ${o}, prejeto ${a}`}case"invalid_value":return t.values.length===1?`Neveljaven vnos: pri\u010Dakovano ${D(t.values[0])}`:`Neveljavna mo\u017Enost: pri\u010Dakovano eno izmed ${E(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?`Preveliko: pri\u010Dakovano, da bo ${t.origin??"vrednost"} imelo ${o}${t.maximum.toString()} ${s.unit??"elementov"}`:`Preveliko: pri\u010Dakovano, da bo ${t.origin??"vrednost"} ${o}${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`Premajhno: pri\u010Dakovano, da bo ${t.origin} imelo ${o}${t.minimum.toString()} ${s.unit}`:`Premajhno: pri\u010Dakovano, da bo ${t.origin} ${o}${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`Neveljaven niz: mora se za\u010Deti z "${o.prefix}"`:o.format==="ends_with"?`Neveljaven niz: mora se kon\u010Dati z "${o.suffix}"`:o.format==="includes"?`Neveljaven niz: mora vsebovati "${o.includes}"`:o.format==="regex"?`Neveljaven niz: mora ustrezati vzorcu ${o.pattern}`:`Neveljaven ${r[o.format]??t.format}`}case"not_multiple_of":return`Neveljavno \u0161tevilo: mora biti ve\u010Dkratnik ${t.divisor}`;case"unrecognized_keys":return`Neprepoznan${t.keys.length>1?"i klju\u010Di":" klju\u010D"}: ${E(t.keys,", ")}`;case"invalid_key":return`Neveljaven klju\u010D v ${t.origin}`;case"invalid_union":return"Neveljaven vnos";case"invalid_element":return`Neveljavna vrednost v ${t.origin}`;default:return"Neveljaven vnos"}}};function Hy(){return{localeError:xw()}}var Sw=()=>{let n={string:{unit:"tecken",verb:"att ha"},file:{unit:"bytes",verb:"att ha"},array:{unit:"objekt",verb:"att inneh\xE5lla"},set:{unit:"objekt",verb:"att inneh\xE5lla"}};function e(t){return n[t]??null}let r={regex:"regulj\xE4rt uttryck",email:"e-postadress",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-datum och tid",date:"ISO-datum",time:"ISO-tid",duration:"ISO-varaktighet",ipv4:"IPv4-intervall",ipv6:"IPv6-intervall",cidrv4:"IPv4-spektrum",cidrv6:"IPv6-spektrum",base64:"base64-kodad str\xE4ng",base64url:"base64url-kodad str\xE4ng",json_string:"JSON-str\xE4ng",e164:"E.164-nummer",jwt:"JWT",template_literal:"mall-literal"},i={nan:"NaN",number:"antal",array:"lista"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=C(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`Ogiltig inmatning: f\xF6rv\xE4ntat instanceof ${t.expected}, fick ${a}`:`Ogiltig inmatning: f\xF6rv\xE4ntat ${o}, fick ${a}`}case"invalid_value":return t.values.length===1?`Ogiltig inmatning: f\xF6rv\xE4ntat ${D(t.values[0])}`:`Ogiltigt val: f\xF6rv\xE4ntade en av ${E(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?`F\xF6r stor(t): f\xF6rv\xE4ntade ${t.origin??"v\xE4rdet"} att ha ${o}${t.maximum.toString()} ${s.unit??"element"}`:`F\xF6r stor(t): f\xF6rv\xE4ntat ${t.origin??"v\xE4rdet"} att ha ${o}${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`F\xF6r lite(t): f\xF6rv\xE4ntade ${t.origin??"v\xE4rdet"} att ha ${o}${t.minimum.toString()} ${s.unit}`:`F\xF6r lite(t): f\xF6rv\xE4ntade ${t.origin??"v\xE4rdet"} att ha ${o}${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`Ogiltig str\xE4ng: m\xE5ste b\xF6rja med "${o.prefix}"`:o.format==="ends_with"?`Ogiltig str\xE4ng: m\xE5ste sluta med "${o.suffix}"`:o.format==="includes"?`Ogiltig str\xE4ng: m\xE5ste inneh\xE5lla "${o.includes}"`:o.format==="regex"?`Ogiltig str\xE4ng: m\xE5ste matcha m\xF6nstret "${o.pattern}"`:`Ogiltig(t) ${r[o.format]??t.format}`}case"not_multiple_of":return`Ogiltigt tal: m\xE5ste vara en multipel av ${t.divisor}`;case"unrecognized_keys":return`${t.keys.length>1?"Ok\xE4nda nycklar":"Ok\xE4nd nyckel"}: ${E(t.keys,", ")}`;case"invalid_key":return`Ogiltig nyckel i ${t.origin??"v\xE4rdet"}`;case"invalid_union":return"Ogiltig input";case"invalid_element":return`Ogiltigt v\xE4rde i ${t.origin??"v\xE4rdet"}`;default:return"Ogiltig input"}}};function Wy(){return{localeError:Sw()}}var $w=()=>{let n={string:{unit:"\u0B8E\u0BB4\u0BC1\u0BA4\u0BCD\u0BA4\u0BC1\u0B95\u0BCD\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"},file:{unit:"\u0BAA\u0BC8\u0B9F\u0BCD\u0B9F\u0BC1\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"},array:{unit:"\u0B89\u0BB1\u0BC1\u0BAA\u0BCD\u0BAA\u0BC1\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"},set:{unit:"\u0B89\u0BB1\u0BC1\u0BAA\u0BCD\u0BAA\u0BC1\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"}};function e(t){return n[t]??null}let r={regex:"\u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1",email:"\u0BAE\u0BBF\u0BA9\u0BCD\u0BA9\u0B9E\u0BCD\u0B9A\u0BB2\u0BCD \u0BAE\u0BC1\u0B95\u0BB5\u0BB0\u0BBF",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0BA4\u0BC7\u0BA4\u0BBF \u0BA8\u0BC7\u0BB0\u0BAE\u0BCD",date:"ISO \u0BA4\u0BC7\u0BA4\u0BBF",time:"ISO \u0BA8\u0BC7\u0BB0\u0BAE\u0BCD",duration:"ISO \u0B95\u0BBE\u0BB2 \u0B85\u0BB3\u0BB5\u0BC1",ipv4:"IPv4 \u0BAE\u0BC1\u0B95\u0BB5\u0BB0\u0BBF",ipv6:"IPv6 \u0BAE\u0BC1\u0B95\u0BB5\u0BB0\u0BBF",cidrv4:"IPv4 \u0BB5\u0BB0\u0BAE\u0BCD\u0BAA\u0BC1",cidrv6:"IPv6 \u0BB5\u0BB0\u0BAE\u0BCD\u0BAA\u0BC1",base64:"base64-encoded \u0B9A\u0BB0\u0BAE\u0BCD",base64url:"base64url-encoded \u0B9A\u0BB0\u0BAE\u0BCD",json_string:"JSON \u0B9A\u0BB0\u0BAE\u0BCD",e164:"E.164 \u0B8E\u0BA3\u0BCD",jwt:"JWT",template_literal:"input"},i={nan:"NaN",number:"\u0B8E\u0BA3\u0BCD",array:"\u0B85\u0BA3\u0BBF",null:"\u0BB5\u0BC6\u0BB1\u0BC1\u0BAE\u0BC8"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=C(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 instanceof ${t.expected}, \u0BAA\u0BC6\u0BB1\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${a}`:`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${o}, \u0BAA\u0BC6\u0BB1\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${a}`}case"invalid_value":return t.values.length===1?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${D(t.values[0])}`:`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0BB5\u0BBF\u0BB0\u0BC1\u0BAA\u0BCD\u0BAA\u0BAE\u0BCD: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${E(t.values,"|")} \u0B87\u0BB2\u0BCD \u0B92\u0BA9\u0BCD\u0BB1\u0BC1`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?`\u0BAE\u0BBF\u0B95 \u0BAA\u0BC6\u0BB0\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${t.origin??"\u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1"} ${o}${t.maximum.toString()} ${s.unit??"\u0B89\u0BB1\u0BC1\u0BAA\u0BCD\u0BAA\u0BC1\u0B95\u0BB3\u0BCD"} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:`\u0BAE\u0BBF\u0B95 \u0BAA\u0BC6\u0BB0\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${t.origin??"\u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1"} ${o}${t.maximum.toString()} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`\u0BAE\u0BBF\u0B95\u0B9A\u0BCD \u0B9A\u0BBF\u0BB1\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${t.origin} ${o}${t.minimum.toString()} ${s.unit} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:`\u0BAE\u0BBF\u0B95\u0B9A\u0BCD \u0B9A\u0BBF\u0BB1\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${t.origin} ${o}${t.minimum.toString()} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`}case"invalid_format":{let o=t;return o.format==="starts_with"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${o.prefix}" \u0B87\u0BB2\u0BCD \u0BA4\u0BCA\u0B9F\u0B99\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:o.format==="ends_with"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${o.suffix}" \u0B87\u0BB2\u0BCD \u0BAE\u0BC1\u0B9F\u0BBF\u0BB5\u0B9F\u0BC8\u0BAF \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:o.format==="includes"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${o.includes}" \u0B90 \u0B89\u0BB3\u0BCD\u0BB3\u0B9F\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:o.format==="regex"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: ${o.pattern} \u0BAE\u0BC1\u0BB1\u0BC8\u0BAA\u0BBE\u0B9F\u0BCD\u0B9F\u0BC1\u0B9F\u0BA9\u0BCD \u0BAA\u0BCA\u0BB0\u0BC1\u0BA8\u0BCD\u0BA4 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 ${r[o.format]??t.format}`}case"not_multiple_of":return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B8E\u0BA3\u0BCD: ${t.divisor} \u0B87\u0BA9\u0BCD \u0BAA\u0BB2\u0BAE\u0BBE\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`;case"unrecognized_keys":return`\u0B85\u0B9F\u0BC8\u0BAF\u0BBE\u0BB3\u0BAE\u0BCD \u0BA4\u0BC6\u0BB0\u0BBF\u0BAF\u0BBE\u0BA4 \u0BB5\u0BBF\u0B9A\u0BC8${t.keys.length>1?"\u0B95\u0BB3\u0BCD":""}: ${E(t.keys,", ")}`;case"invalid_key":return`${t.origin} \u0B87\u0BB2\u0BCD \u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0BB5\u0BBF\u0B9A\u0BC8`;case"invalid_union":return"\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1";case"invalid_element":return`${t.origin} \u0B87\u0BB2\u0BCD \u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1`;default:return"\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1"}}};function By(){return{localeError:$w()}}var ww=()=>{let n={string:{unit:"\u0E15\u0E31\u0E27\u0E2D\u0E31\u0E01\u0E29\u0E23",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"},file:{unit:"\u0E44\u0E1A\u0E15\u0E4C",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"},array:{unit:"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"},set:{unit:"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"}};function e(t){return n[t]??null}let r={regex:"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E35\u0E48\u0E1B\u0E49\u0E2D\u0E19",email:"\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48\u0E2D\u0E35\u0E40\u0E21\u0E25",url:"URL",emoji:"\u0E2D\u0E34\u0E42\u0E21\u0E08\u0E34",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0E27\u0E31\u0E19\u0E17\u0E35\u0E48\u0E40\u0E27\u0E25\u0E32\u0E41\u0E1A\u0E1A ISO",date:"\u0E27\u0E31\u0E19\u0E17\u0E35\u0E48\u0E41\u0E1A\u0E1A ISO",time:"\u0E40\u0E27\u0E25\u0E32\u0E41\u0E1A\u0E1A ISO",duration:"\u0E0A\u0E48\u0E27\u0E07\u0E40\u0E27\u0E25\u0E32\u0E41\u0E1A\u0E1A ISO",ipv4:"\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48 IPv4",ipv6:"\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48 IPv6",cidrv4:"\u0E0A\u0E48\u0E27\u0E07 IP \u0E41\u0E1A\u0E1A IPv4",cidrv6:"\u0E0A\u0E48\u0E27\u0E07 IP \u0E41\u0E1A\u0E1A IPv6",base64:"\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E41\u0E1A\u0E1A Base64",base64url:"\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E41\u0E1A\u0E1A Base64 \u0E2A\u0E33\u0E2B\u0E23\u0E31\u0E1A URL",json_string:"\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E41\u0E1A\u0E1A JSON",e164:"\u0E40\u0E1A\u0E2D\u0E23\u0E4C\u0E42\u0E17\u0E23\u0E28\u0E31\u0E1E\u0E17\u0E4C\u0E23\u0E30\u0E2B\u0E27\u0E48\u0E32\u0E07\u0E1B\u0E23\u0E30\u0E40\u0E17\u0E28 (E.164)",jwt:"\u0E42\u0E17\u0E40\u0E04\u0E19 JWT",template_literal:"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E35\u0E48\u0E1B\u0E49\u0E2D\u0E19"},i={nan:"NaN",number:"\u0E15\u0E31\u0E27\u0E40\u0E25\u0E02",array:"\u0E2D\u0E32\u0E23\u0E4C\u0E40\u0E23\u0E22\u0E4C (Array)",null:"\u0E44\u0E21\u0E48\u0E21\u0E35\u0E04\u0E48\u0E32 (null)"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=C(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`\u0E1B\u0E23\u0E30\u0E40\u0E20\u0E17\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19 instanceof ${t.expected} \u0E41\u0E15\u0E48\u0E44\u0E14\u0E49\u0E23\u0E31\u0E1A ${a}`:`\u0E1B\u0E23\u0E30\u0E40\u0E20\u0E17\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19 ${o} \u0E41\u0E15\u0E48\u0E44\u0E14\u0E49\u0E23\u0E31\u0E1A ${a}`}case"invalid_value":return t.values.length===1?`\u0E04\u0E48\u0E32\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19 ${D(t.values[0])}`:`\u0E15\u0E31\u0E27\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19\u0E2B\u0E19\u0E36\u0E48\u0E07\u0E43\u0E19 ${E(t.values,"|")}`;case"too_big":{let o=t.inclusive?"\u0E44\u0E21\u0E48\u0E40\u0E01\u0E34\u0E19":"\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32",s=e(t.origin);return s?`\u0E40\u0E01\u0E34\u0E19\u0E01\u0E33\u0E2B\u0E19\u0E14: ${t.origin??"\u0E04\u0E48\u0E32"} \u0E04\u0E27\u0E23\u0E21\u0E35${o} ${t.maximum.toString()} ${s.unit??"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23"}`:`\u0E40\u0E01\u0E34\u0E19\u0E01\u0E33\u0E2B\u0E19\u0E14: ${t.origin??"\u0E04\u0E48\u0E32"} \u0E04\u0E27\u0E23\u0E21\u0E35${o} ${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?"\u0E2D\u0E22\u0E48\u0E32\u0E07\u0E19\u0E49\u0E2D\u0E22":"\u0E21\u0E32\u0E01\u0E01\u0E27\u0E48\u0E32",s=e(t.origin);return s?`\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32\u0E01\u0E33\u0E2B\u0E19\u0E14: ${t.origin} \u0E04\u0E27\u0E23\u0E21\u0E35${o} ${t.minimum.toString()} ${s.unit}`:`\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32\u0E01\u0E33\u0E2B\u0E19\u0E14: ${t.origin} \u0E04\u0E27\u0E23\u0E21\u0E35${o} ${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E15\u0E49\u0E2D\u0E07\u0E02\u0E36\u0E49\u0E19\u0E15\u0E49\u0E19\u0E14\u0E49\u0E27\u0E22 "${o.prefix}"`:o.format==="ends_with"?`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E15\u0E49\u0E2D\u0E07\u0E25\u0E07\u0E17\u0E49\u0E32\u0E22\u0E14\u0E49\u0E27\u0E22 "${o.suffix}"`:o.format==="includes"?`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E15\u0E49\u0E2D\u0E07\u0E21\u0E35 "${o.includes}" \u0E2D\u0E22\u0E39\u0E48\u0E43\u0E19\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21`:o.format==="regex"?`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E15\u0E49\u0E2D\u0E07\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E17\u0E35\u0E48\u0E01\u0E33\u0E2B\u0E19\u0E14 ${o.pattern}`:`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: ${r[o.format]??t.format}`}case"not_multiple_of":return`\u0E15\u0E31\u0E27\u0E40\u0E25\u0E02\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19\u0E08\u0E33\u0E19\u0E27\u0E19\u0E17\u0E35\u0E48\u0E2B\u0E32\u0E23\u0E14\u0E49\u0E27\u0E22 ${t.divisor} \u0E44\u0E14\u0E49\u0E25\u0E07\u0E15\u0E31\u0E27`;case"unrecognized_keys":return`\u0E1E\u0E1A\u0E04\u0E35\u0E22\u0E4C\u0E17\u0E35\u0E48\u0E44\u0E21\u0E48\u0E23\u0E39\u0E49\u0E08\u0E31\u0E01: ${E(t.keys,", ")}`;case"invalid_key":return`\u0E04\u0E35\u0E22\u0E4C\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E43\u0E19 ${t.origin}`;case"invalid_union":return"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E22\u0E39\u0E40\u0E19\u0E35\u0E22\u0E19\u0E17\u0E35\u0E48\u0E01\u0E33\u0E2B\u0E19\u0E14\u0E44\u0E27\u0E49";case"invalid_element":return`\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E43\u0E19 ${t.origin}`;default:return"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07"}}};function Gy(){return{localeError:ww()}}var kw=()=>{let n={string:{unit:"karakter",verb:"olmal\u0131"},file:{unit:"bayt",verb:"olmal\u0131"},array:{unit:"\xF6\u011Fe",verb:"olmal\u0131"},set:{unit:"\xF6\u011Fe",verb:"olmal\u0131"}};function e(t){return n[t]??null}let r={regex:"girdi",email:"e-posta adresi",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO tarih ve saat",date:"ISO tarih",time:"ISO saat",duration:"ISO s\xFCre",ipv4:"IPv4 adresi",ipv6:"IPv6 adresi",cidrv4:"IPv4 aral\u0131\u011F\u0131",cidrv6:"IPv6 aral\u0131\u011F\u0131",base64:"base64 ile \u015Fifrelenmi\u015F metin",base64url:"base64url ile \u015Fifrelenmi\u015F metin",json_string:"JSON dizesi",e164:"E.164 say\u0131s\u0131",jwt:"JWT",template_literal:"\u015Eablon dizesi"},i={nan:"NaN"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=C(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`Ge\xE7ersiz de\u011Fer: beklenen instanceof ${t.expected}, al\u0131nan ${a}`:`Ge\xE7ersiz de\u011Fer: beklenen ${o}, al\u0131nan ${a}`}case"invalid_value":return t.values.length===1?`Ge\xE7ersiz de\u011Fer: beklenen ${D(t.values[0])}`:`Ge\xE7ersiz se\xE7enek: a\u015Fa\u011F\u0131dakilerden biri olmal\u0131: ${E(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?`\xC7ok b\xFCy\xFCk: beklenen ${t.origin??"de\u011Fer"} ${o}${t.maximum.toString()} ${s.unit??"\xF6\u011Fe"}`:`\xC7ok b\xFCy\xFCk: beklenen ${t.origin??"de\u011Fer"} ${o}${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`\xC7ok k\xFC\xE7\xFCk: beklenen ${t.origin} ${o}${t.minimum.toString()} ${s.unit}`:`\xC7ok k\xFC\xE7\xFCk: beklenen ${t.origin} ${o}${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`Ge\xE7ersiz metin: "${o.prefix}" ile ba\u015Flamal\u0131`:o.format==="ends_with"?`Ge\xE7ersiz metin: "${o.suffix}" ile bitmeli`:o.format==="includes"?`Ge\xE7ersiz metin: "${o.includes}" i\xE7ermeli`:o.format==="regex"?`Ge\xE7ersiz metin: ${o.pattern} desenine uymal\u0131`:`Ge\xE7ersiz ${r[o.format]??t.format}`}case"not_multiple_of":return`Ge\xE7ersiz say\u0131: ${t.divisor} ile tam b\xF6l\xFCnebilmeli`;case"unrecognized_keys":return`Tan\u0131nmayan anahtar${t.keys.length>1?"lar":""}: ${E(t.keys,", ")}`;case"invalid_key":return`${t.origin} i\xE7inde ge\xE7ersiz anahtar`;case"invalid_union":return"Ge\xE7ersiz de\u011Fer";case"invalid_element":return`${t.origin} i\xE7inde ge\xE7ersiz de\u011Fer`;default:return"Ge\xE7ersiz de\u011Fer"}}};function Jy(){return{localeError:kw()}}var Ew=()=>{let n={string:{unit:"\u0441\u0438\u043C\u0432\u043E\u043B\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"},file:{unit:"\u0431\u0430\u0439\u0442\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"},array:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"},set:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"}};function e(t){return n[t]??null}let r={regex:"\u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456",email:"\u0430\u0434\u0440\u0435\u0441\u0430 \u0435\u043B\u0435\u043A\u0442\u0440\u043E\u043D\u043D\u043E\u0457 \u043F\u043E\u0448\u0442\u0438",url:"URL",emoji:"\u0435\u043C\u043E\u0434\u0437\u0456",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0434\u0430\u0442\u0430 \u0442\u0430 \u0447\u0430\u0441 ISO",date:"\u0434\u0430\u0442\u0430 ISO",time:"\u0447\u0430\u0441 ISO",duration:"\u0442\u0440\u0438\u0432\u0430\u043B\u0456\u0441\u0442\u044C ISO",ipv4:"\u0430\u0434\u0440\u0435\u0441\u0430 IPv4",ipv6:"\u0430\u0434\u0440\u0435\u0441\u0430 IPv6",cidrv4:"\u0434\u0456\u0430\u043F\u0430\u0437\u043E\u043D IPv4",cidrv6:"\u0434\u0456\u0430\u043F\u0430\u0437\u043E\u043D IPv6",base64:"\u0440\u044F\u0434\u043E\u043A \u0443 \u043A\u043E\u0434\u0443\u0432\u0430\u043D\u043D\u0456 base64",base64url:"\u0440\u044F\u0434\u043E\u043A \u0443 \u043A\u043E\u0434\u0443\u0432\u0430\u043D\u043D\u0456 base64url",json_string:"\u0440\u044F\u0434\u043E\u043A JSON",e164:"\u043D\u043E\u043C\u0435\u0440 E.164",jwt:"JWT",template_literal:"\u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456"},i={nan:"NaN",number:"\u0447\u0438\u0441\u043B\u043E",array:"\u043C\u0430\u0441\u0438\u0432"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=C(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F instanceof ${t.expected}, \u043E\u0442\u0440\u0438\u043C\u0430\u043D\u043E ${a}`:`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F ${o}, \u043E\u0442\u0440\u0438\u043C\u0430\u043D\u043E ${a}`}case"invalid_value":return t.values.length===1?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F ${D(t.values[0])}`:`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0430 \u043E\u043F\u0446\u0456\u044F: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F \u043E\u0434\u043D\u0435 \u0437 ${E(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u0432\u0435\u043B\u0438\u043A\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${t.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F"} ${s.verb} ${o}${t.maximum.toString()} ${s.unit??"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432"}`:`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u0432\u0435\u043B\u0438\u043A\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${t.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F"} \u0431\u0443\u0434\u0435 ${o}${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u043C\u0430\u043B\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${t.origin} ${s.verb} ${o}${t.minimum.toString()} ${s.unit}`:`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u043C\u0430\u043B\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${t.origin} \u0431\u0443\u0434\u0435 ${o}${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u043F\u043E\u0447\u0438\u043D\u0430\u0442\u0438\u0441\u044F \u0437 "${o.prefix}"`:o.format==="ends_with"?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u0437\u0430\u043A\u0456\u043D\u0447\u0443\u0432\u0430\u0442\u0438\u0441\u044F \u043D\u0430 "${o.suffix}"`:o.format==="includes"?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u043C\u0456\u0441\u0442\u0438\u0442\u0438 "${o.includes}"`:o.format==="regex"?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0442\u0438 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 ${o.pattern}`:`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 ${r[o.format]??t.format}`}case"not_multiple_of":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0435 \u0447\u0438\u0441\u043B\u043E: \u043F\u043E\u0432\u0438\u043D\u043D\u043E \u0431\u0443\u0442\u0438 \u043A\u0440\u0430\u0442\u043D\u0438\u043C ${t.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u043E\u0437\u043F\u0456\u0437\u043D\u0430\u043D\u0438\u0439 \u043A\u043B\u044E\u0447${t.keys.length>1?"\u0456":""}: ${E(t.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u043A\u043B\u044E\u0447 \u0443 ${t.origin}`;case"invalid_union":return"\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456";case"invalid_element":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F \u0443 ${t.origin}`;default:return"\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456"}}};function _s(){return{localeError:Ew()}}function qy(){return _s()}var Iw=()=>{let n={string:{unit:"\u062D\u0631\u0648\u0641",verb:"\u06C1\u0648\u0646\u0627"},file:{unit:"\u0628\u0627\u0626\u0679\u0633",verb:"\u06C1\u0648\u0646\u0627"},array:{unit:"\u0622\u0626\u0679\u0645\u0632",verb:"\u06C1\u0648\u0646\u0627"},set:{unit:"\u0622\u0626\u0679\u0645\u0632",verb:"\u06C1\u0648\u0646\u0627"}};function e(t){return n[t]??null}let r={regex:"\u0627\u0646 \u067E\u0679",email:"\u0627\u06CC \u0645\u06CC\u0644 \u0627\u06CC\u0688\u0631\u06CC\u0633",url:"\u06CC\u0648 \u0622\u0631 \u0627\u06CC\u0644",emoji:"\u0627\u06CC\u0645\u0648\u062C\u06CC",uuid:"\u06CC\u0648 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",uuidv4:"\u06CC\u0648 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC \u0648\u06CC 4",uuidv6:"\u06CC\u0648 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC \u0648\u06CC 6",nanoid:"\u0646\u06CC\u0646\u0648 \u0622\u0626\u06CC \u0688\u06CC",guid:"\u062C\u06CC \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",cuid:"\u0633\u06CC \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",cuid2:"\u0633\u06CC \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC 2",ulid:"\u06CC\u0648 \u0627\u06CC\u0644 \u0622\u0626\u06CC \u0688\u06CC",xid:"\u0627\u06CC\u06A9\u0633 \u0622\u0626\u06CC \u0688\u06CC",ksuid:"\u06A9\u06D2 \u0627\u06CC\u0633 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",datetime:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u0688\u06CC\u0679 \u0679\u0627\u0626\u0645",date:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u062A\u0627\u0631\u06CC\u062E",time:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u0648\u0642\u062A",duration:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u0645\u062F\u062A",ipv4:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 4 \u0627\u06CC\u0688\u0631\u06CC\u0633",ipv6:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 6 \u0627\u06CC\u0688\u0631\u06CC\u0633",cidrv4:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 4 \u0631\u06CC\u0646\u062C",cidrv6:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 6 \u0631\u06CC\u0646\u062C",base64:"\u0628\u06CC\u0633 64 \u0627\u0646 \u06A9\u0648\u0688\u0688 \u0633\u0679\u0631\u0646\u06AF",base64url:"\u0628\u06CC\u0633 64 \u06CC\u0648 \u0622\u0631 \u0627\u06CC\u0644 \u0627\u0646 \u06A9\u0648\u0688\u0688 \u0633\u0679\u0631\u0646\u06AF",json_string:"\u062C\u06D2 \u0627\u06CC\u0633 \u0627\u0648 \u0627\u06CC\u0646 \u0633\u0679\u0631\u0646\u06AF",e164:"\u0627\u06CC 164 \u0646\u0645\u0628\u0631",jwt:"\u062C\u06D2 \u0688\u0628\u0644\u06CC\u0648 \u0679\u06CC",template_literal:"\u0627\u0646 \u067E\u0679"},i={nan:"NaN",number:"\u0646\u0645\u0628\u0631",array:"\u0622\u0631\u06D2",null:"\u0646\u0644"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=C(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: instanceof ${t.expected} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627\u060C ${a} \u0645\u0648\u0635\u0648\u0644 \u06C1\u0648\u0627`:`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: ${o} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627\u060C ${a} \u0645\u0648\u0635\u0648\u0644 \u06C1\u0648\u0627`}case"invalid_value":return t.values.length===1?`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: ${D(t.values[0])} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`:`\u063A\u0644\u0637 \u0622\u067E\u0634\u0646: ${E(t.values,"|")} \u0645\u06CC\u06BA \u0633\u06D2 \u0627\u06CC\u06A9 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?`\u0628\u06C1\u062A \u0628\u0691\u0627: ${t.origin??"\u0648\u06CC\u0644\u06CC\u0648"} \u06A9\u06D2 ${o}${t.maximum.toString()} ${s.unit??"\u0639\u0646\u0627\u0635\u0631"} \u06C1\u0648\u0646\u06D2 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u06D2`:`\u0628\u06C1\u062A \u0628\u0691\u0627: ${t.origin??"\u0648\u06CC\u0644\u06CC\u0648"} \u06A9\u0627 ${o}${t.maximum.toString()} \u06C1\u0648\u0646\u0627 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`\u0628\u06C1\u062A \u0686\u06BE\u0648\u0679\u0627: ${t.origin} \u06A9\u06D2 ${o}${t.minimum.toString()} ${s.unit} \u06C1\u0648\u0646\u06D2 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u06D2`:`\u0628\u06C1\u062A \u0686\u06BE\u0648\u0679\u0627: ${t.origin} \u06A9\u0627 ${o}${t.minimum.toString()} \u06C1\u0648\u0646\u0627 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`}case"invalid_format":{let o=t;return o.format==="starts_with"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${o.prefix}" \u0633\u06D2 \u0634\u0631\u0648\u0639 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:o.format==="ends_with"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${o.suffix}" \u067E\u0631 \u062E\u062A\u0645 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:o.format==="includes"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${o.includes}" \u0634\u0627\u0645\u0644 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:o.format==="regex"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: \u067E\u06CC\u0679\u0631\u0646 ${o.pattern} \u0633\u06D2 \u0645\u06CC\u0686 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:`\u063A\u0644\u0637 ${r[o.format]??t.format}`}case"not_multiple_of":return`\u063A\u0644\u0637 \u0646\u0645\u0628\u0631: ${t.divisor} \u06A9\u0627 \u0645\u0636\u0627\u0639\u0641 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`;case"unrecognized_keys":return`\u063A\u06CC\u0631 \u062A\u0633\u0644\u06CC\u0645 \u0634\u062F\u06C1 \u06A9\u06CC${t.keys.length>1?"\u0632":""}: ${E(t.keys,"\u060C ")}`;case"invalid_key":return`${t.origin} \u0645\u06CC\u06BA \u063A\u0644\u0637 \u06A9\u06CC`;case"invalid_union":return"\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679";case"invalid_element":return`${t.origin} \u0645\u06CC\u06BA \u063A\u0644\u0637 \u0648\u06CC\u0644\u06CC\u0648`;default:return"\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679"}}};function Vy(){return{localeError:Iw()}}var Tw=()=>{let n={string:{unit:"belgi",verb:"bo\u2018lishi kerak"},file:{unit:"bayt",verb:"bo\u2018lishi kerak"},array:{unit:"element",verb:"bo\u2018lishi kerak"},set:{unit:"element",verb:"bo\u2018lishi kerak"}};function e(t){return n[t]??null}let r={regex:"kirish",email:"elektron pochta manzili",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO sana va vaqti",date:"ISO sana",time:"ISO vaqt",duration:"ISO davomiylik",ipv4:"IPv4 manzil",ipv6:"IPv6 manzil",mac:"MAC manzil",cidrv4:"IPv4 diapazon",cidrv6:"IPv6 diapazon",base64:"base64 kodlangan satr",base64url:"base64url kodlangan satr",json_string:"JSON satr",e164:"E.164 raqam",jwt:"JWT",template_literal:"kirish"},i={nan:"NaN",number:"raqam",array:"massiv"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=C(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`Noto\u2018g\u2018ri kirish: kutilgan instanceof ${t.expected}, qabul qilingan ${a}`:`Noto\u2018g\u2018ri kirish: kutilgan ${o}, qabul qilingan ${a}`}case"invalid_value":return t.values.length===1?`Noto\u2018g\u2018ri kirish: kutilgan ${D(t.values[0])}`:`Noto\u2018g\u2018ri variant: quyidagilardan biri kutilgan ${E(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?`Juda katta: kutilgan ${t.origin??"qiymat"} ${o}${t.maximum.toString()} ${s.unit} ${s.verb}`:`Juda katta: kutilgan ${t.origin??"qiymat"} ${o}${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`Juda kichik: kutilgan ${t.origin} ${o}${t.minimum.toString()} ${s.unit} ${s.verb}`:`Juda kichik: kutilgan ${t.origin} ${o}${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`Noto\u2018g\u2018ri satr: "${o.prefix}" bilan boshlanishi kerak`:o.format==="ends_with"?`Noto\u2018g\u2018ri satr: "${o.suffix}" bilan tugashi kerak`:o.format==="includes"?`Noto\u2018g\u2018ri satr: "${o.includes}" ni o\u2018z ichiga olishi kerak`:o.format==="regex"?`Noto\u2018g\u2018ri satr: ${o.pattern} shabloniga mos kelishi kerak`:`Noto\u2018g\u2018ri ${r[o.format]??t.format}`}case"not_multiple_of":return`Noto\u2018g\u2018ri raqam: ${t.divisor} ning karralisi bo\u2018lishi kerak`;case"unrecognized_keys":return`Noma\u2019lum kalit${t.keys.length>1?"lar":""}: ${E(t.keys,", ")}`;case"invalid_key":return`${t.origin} dagi kalit noto\u2018g\u2018ri`;case"invalid_union":return"Noto\u2018g\u2018ri kirish";case"invalid_element":return`${t.origin} da noto\u2018g\u2018ri qiymat`;default:return"Noto\u2018g\u2018ri kirish"}}};function Ky(){return{localeError:Tw()}}var Pw=()=>{let n={string:{unit:"k\xFD t\u1EF1",verb:"c\xF3"},file:{unit:"byte",verb:"c\xF3"},array:{unit:"ph\u1EA7n t\u1EED",verb:"c\xF3"},set:{unit:"ph\u1EA7n t\u1EED",verb:"c\xF3"}};function e(t){return n[t]??null}let r={regex:"\u0111\u1EA7u v\xE0o",email:"\u0111\u1ECBa ch\u1EC9 email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ng\xE0y gi\u1EDD ISO",date:"ng\xE0y ISO",time:"gi\u1EDD ISO",duration:"kho\u1EA3ng th\u1EDDi gian ISO",ipv4:"\u0111\u1ECBa ch\u1EC9 IPv4",ipv6:"\u0111\u1ECBa ch\u1EC9 IPv6",cidrv4:"d\u1EA3i IPv4",cidrv6:"d\u1EA3i IPv6",base64:"chu\u1ED7i m\xE3 h\xF3a base64",base64url:"chu\u1ED7i m\xE3 h\xF3a base64url",json_string:"chu\u1ED7i JSON",e164:"s\u1ED1 E.164",jwt:"JWT",template_literal:"\u0111\u1EA7u v\xE0o"},i={nan:"NaN",number:"s\u1ED1",array:"m\u1EA3ng"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=C(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i instanceof ${t.expected}, nh\u1EADn \u0111\u01B0\u1EE3c ${a}`:`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i ${o}, nh\u1EADn \u0111\u01B0\u1EE3c ${a}`}case"invalid_value":return t.values.length===1?`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i ${D(t.values[0])}`:`T\xF9y ch\u1ECDn kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i m\u1ED9t trong c\xE1c gi\xE1 tr\u1ECB ${E(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?`Qu\xE1 l\u1EDBn: mong \u0111\u1EE3i ${t.origin??"gi\xE1 tr\u1ECB"} ${s.verb} ${o}${t.maximum.toString()} ${s.unit??"ph\u1EA7n t\u1EED"}`:`Qu\xE1 l\u1EDBn: mong \u0111\u1EE3i ${t.origin??"gi\xE1 tr\u1ECB"} ${o}${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`Qu\xE1 nh\u1ECF: mong \u0111\u1EE3i ${t.origin} ${s.verb} ${o}${t.minimum.toString()} ${s.unit}`:`Qu\xE1 nh\u1ECF: mong \u0111\u1EE3i ${t.origin} ${o}${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i b\u1EAFt \u0111\u1EA7u b\u1EB1ng "${o.prefix}"`:o.format==="ends_with"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i k\u1EBFt th\xFAc b\u1EB1ng "${o.suffix}"`:o.format==="includes"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i bao g\u1ED3m "${o.includes}"`:o.format==="regex"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i kh\u1EDBp v\u1EDBi m\u1EABu ${o.pattern}`:`${r[o.format]??t.format} kh\xF4ng h\u1EE3p l\u1EC7`}case"not_multiple_of":return`S\u1ED1 kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i l\xE0 b\u1ED9i s\u1ED1 c\u1EE7a ${t.divisor}`;case"unrecognized_keys":return`Kh\xF3a kh\xF4ng \u0111\u01B0\u1EE3c nh\u1EADn d\u1EA1ng: ${E(t.keys,", ")}`;case"invalid_key":return`Kh\xF3a kh\xF4ng h\u1EE3p l\u1EC7 trong ${t.origin}`;case"invalid_union":return"\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7";case"invalid_element":return`Gi\xE1 tr\u1ECB kh\xF4ng h\u1EE3p l\u1EC7 trong ${t.origin}`;default:return"\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7"}}};function Yy(){return{localeError:Pw()}}var Rw=()=>{let n={string:{unit:"\u5B57\u7B26",verb:"\u5305\u542B"},file:{unit:"\u5B57\u8282",verb:"\u5305\u542B"},array:{unit:"\u9879",verb:"\u5305\u542B"},set:{unit:"\u9879",verb:"\u5305\u542B"}};function e(t){return n[t]??null}let r={regex:"\u8F93\u5165",email:"\u7535\u5B50\u90AE\u4EF6",url:"URL",emoji:"\u8868\u60C5\u7B26\u53F7",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO\u65E5\u671F\u65F6\u95F4",date:"ISO\u65E5\u671F",time:"ISO\u65F6\u95F4",duration:"ISO\u65F6\u957F",ipv4:"IPv4\u5730\u5740",ipv6:"IPv6\u5730\u5740",cidrv4:"IPv4\u7F51\u6BB5",cidrv6:"IPv6\u7F51\u6BB5",base64:"base64\u7F16\u7801\u5B57\u7B26\u4E32",base64url:"base64url\u7F16\u7801\u5B57\u7B26\u4E32",json_string:"JSON\u5B57\u7B26\u4E32",e164:"E.164\u53F7\u7801",jwt:"JWT",template_literal:"\u8F93\u5165"},i={nan:"NaN",number:"\u6570\u5B57",array:"\u6570\u7EC4",null:"\u7A7A\u503C(null)"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=C(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B instanceof ${t.expected}\uFF0C\u5B9E\u9645\u63A5\u6536 ${a}`:`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B ${o}\uFF0C\u5B9E\u9645\u63A5\u6536 ${a}`}case"invalid_value":return t.values.length===1?`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B ${D(t.values[0])}`:`\u65E0\u6548\u9009\u9879\uFF1A\u671F\u671B\u4EE5\u4E0B\u4E4B\u4E00 ${E(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?`\u6570\u503C\u8FC7\u5927\uFF1A\u671F\u671B ${t.origin??"\u503C"} ${o}${t.maximum.toString()} ${s.unit??"\u4E2A\u5143\u7D20"}`:`\u6570\u503C\u8FC7\u5927\uFF1A\u671F\u671B ${t.origin??"\u503C"} ${o}${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`\u6570\u503C\u8FC7\u5C0F\uFF1A\u671F\u671B ${t.origin} ${o}${t.minimum.toString()} ${s.unit}`:`\u6570\u503C\u8FC7\u5C0F\uFF1A\u671F\u671B ${t.origin} ${o}${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u4EE5 "${o.prefix}" \u5F00\u5934`:o.format==="ends_with"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u4EE5 "${o.suffix}" \u7ED3\u5C3E`:o.format==="includes"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u5305\u542B "${o.includes}"`:o.format==="regex"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u6EE1\u8DB3\u6B63\u5219\u8868\u8FBE\u5F0F ${o.pattern}`:`\u65E0\u6548${r[o.format]??t.format}`}case"not_multiple_of":return`\u65E0\u6548\u6570\u5B57\uFF1A\u5FC5\u987B\u662F ${t.divisor} \u7684\u500D\u6570`;case"unrecognized_keys":return`\u51FA\u73B0\u672A\u77E5\u7684\u952E(key): ${E(t.keys,", ")}`;case"invalid_key":return`${t.origin} \u4E2D\u7684\u952E(key)\u65E0\u6548`;case"invalid_union":return"\u65E0\u6548\u8F93\u5165";case"invalid_element":return`${t.origin} \u4E2D\u5305\u542B\u65E0\u6548\u503C(value)`;default:return"\u65E0\u6548\u8F93\u5165"}}};function Xy(){return{localeError:Rw()}}var Nw=()=>{let n={string:{unit:"\u5B57\u5143",verb:"\u64C1\u6709"},file:{unit:"\u4F4D\u5143\u7D44",verb:"\u64C1\u6709"},array:{unit:"\u9805\u76EE",verb:"\u64C1\u6709"},set:{unit:"\u9805\u76EE",verb:"\u64C1\u6709"}};function e(t){return n[t]??null}let r={regex:"\u8F38\u5165",email:"\u90F5\u4EF6\u5730\u5740",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u65E5\u671F\u6642\u9593",date:"ISO \u65E5\u671F",time:"ISO \u6642\u9593",duration:"ISO \u671F\u9593",ipv4:"IPv4 \u4F4D\u5740",ipv6:"IPv6 \u4F4D\u5740",cidrv4:"IPv4 \u7BC4\u570D",cidrv6:"IPv6 \u7BC4\u570D",base64:"base64 \u7DE8\u78BC\u5B57\u4E32",base64url:"base64url \u7DE8\u78BC\u5B57\u4E32",json_string:"JSON \u5B57\u4E32",e164:"E.164 \u6578\u503C",jwt:"JWT",template_literal:"\u8F38\u5165"},i={nan:"NaN"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=C(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA instanceof ${t.expected}\uFF0C\u4F46\u6536\u5230 ${a}`:`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA ${o}\uFF0C\u4F46\u6536\u5230 ${a}`}case"invalid_value":return t.values.length===1?`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA ${D(t.values[0])}`:`\u7121\u6548\u7684\u9078\u9805\uFF1A\u9810\u671F\u70BA\u4EE5\u4E0B\u5176\u4E2D\u4E4B\u4E00 ${E(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?`\u6578\u503C\u904E\u5927\uFF1A\u9810\u671F ${t.origin??"\u503C"} \u61C9\u70BA ${o}${t.maximum.toString()} ${s.unit??"\u500B\u5143\u7D20"}`:`\u6578\u503C\u904E\u5927\uFF1A\u9810\u671F ${t.origin??"\u503C"} \u61C9\u70BA ${o}${t.maximum.toString()}`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`\u6578\u503C\u904E\u5C0F\uFF1A\u9810\u671F ${t.origin} \u61C9\u70BA ${o}${t.minimum.toString()} ${s.unit}`:`\u6578\u503C\u904E\u5C0F\uFF1A\u9810\u671F ${t.origin} \u61C9\u70BA ${o}${t.minimum.toString()}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u4EE5 "${o.prefix}" \u958B\u982D`:o.format==="ends_with"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u4EE5 "${o.suffix}" \u7D50\u5C3E`:o.format==="includes"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u5305\u542B "${o.includes}"`:o.format==="regex"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u7B26\u5408\u683C\u5F0F ${o.pattern}`:`\u7121\u6548\u7684 ${r[o.format]??t.format}`}case"not_multiple_of":return`\u7121\u6548\u7684\u6578\u5B57\uFF1A\u5FC5\u9808\u70BA ${t.divisor} \u7684\u500D\u6578`;case"unrecognized_keys":return`\u7121\u6CD5\u8B58\u5225\u7684\u9375\u503C${t.keys.length>1?"\u5011":""}\uFF1A${E(t.keys,"\u3001")}`;case"invalid_key":return`${t.origin} \u4E2D\u6709\u7121\u6548\u7684\u9375\u503C`;case"invalid_union":return"\u7121\u6548\u7684\u8F38\u5165\u503C";case"invalid_element":return`${t.origin} \u4E2D\u6709\u7121\u6548\u7684\u503C`;default:return"\u7121\u6548\u7684\u8F38\u5165\u503C"}}};function Qy(){return{localeError:Nw()}}var zw=()=>{let n={string:{unit:"\xE0mi",verb:"n\xED"},file:{unit:"bytes",verb:"n\xED"},array:{unit:"nkan",verb:"n\xED"},set:{unit:"nkan",verb:"n\xED"}};function e(t){return n[t]??null}let r={regex:"\u1EB9\u0300r\u1ECD \xECb\xE1w\u1ECDl\xE9",email:"\xE0d\xEDr\u1EB9\u0301s\xEC \xECm\u1EB9\u0301l\xEC",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\xE0k\xF3k\xF2 ISO",date:"\u1ECDj\u1ECD\u0301 ISO",time:"\xE0k\xF3k\xF2 ISO",duration:"\xE0k\xF3k\xF2 t\xF3 p\xE9 ISO",ipv4:"\xE0d\xEDr\u1EB9\u0301s\xEC IPv4",ipv6:"\xE0d\xEDr\u1EB9\u0301s\xEC IPv6",cidrv4:"\xE0gb\xE8gb\xE8 IPv4",cidrv6:"\xE0gb\xE8gb\xE8 IPv6",base64:"\u1ECD\u0300r\u1ECD\u0300 t\xED a k\u1ECD\u0301 n\xED base64",base64url:"\u1ECD\u0300r\u1ECD\u0300 base64url",json_string:"\u1ECD\u0300r\u1ECD\u0300 JSON",e164:"n\u1ECD\u0301mb\xE0 E.164",jwt:"JWT",template_literal:"\u1EB9\u0300r\u1ECD \xECb\xE1w\u1ECDl\xE9"},i={nan:"NaN",number:"n\u1ECD\u0301mb\xE0",array:"akop\u1ECD"};return t=>{switch(t.code){case"invalid_type":{let o=i[t.expected]??t.expected,s=C(t.input),a=i[s]??s;return/^[A-Z]/.test(t.expected)?`\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e: a n\xED l\xE1ti fi instanceof ${t.expected}, \xE0m\u1ECD\u0300 a r\xED ${a}`:`\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e: a n\xED l\xE1ti fi ${o}, \xE0m\u1ECD\u0300 a r\xED ${a}`}case"invalid_value":return t.values.length===1?`\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e: a n\xED l\xE1ti fi ${D(t.values[0])}`:`\xC0\u1E63\xE0y\xE0n a\u1E63\xEC\u1E63e: yan \u1ECD\u0300kan l\xE1ra ${E(t.values,"|")}`;case"too_big":{let o=t.inclusive?"<=":"<",s=e(t.origin);return s?`T\xF3 p\u1ECD\u0300 j\xF9: a n\xED l\xE1ti j\u1EB9\u0301 p\xE9 ${t.origin??"iye"} ${s.verb} ${o}${t.maximum} ${s.unit}`:`T\xF3 p\u1ECD\u0300 j\xF9: a n\xED l\xE1ti j\u1EB9\u0301 ${o}${t.maximum}`}case"too_small":{let o=t.inclusive?">=":">",s=e(t.origin);return s?`K\xE9r\xE9 ju: a n\xED l\xE1ti j\u1EB9\u0301 p\xE9 ${t.origin} ${s.verb} ${o}${t.minimum} ${s.unit}`:`K\xE9r\xE9 ju: a n\xED l\xE1ti j\u1EB9\u0301 ${o}${t.minimum}`}case"invalid_format":{let o=t;return o.format==="starts_with"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 b\u1EB9\u0300r\u1EB9\u0300 p\u1EB9\u0300l\xFA "${o.prefix}"`:o.format==="ends_with"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 par\xED p\u1EB9\u0300l\xFA "${o.suffix}"`:o.format==="includes"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 n\xED "${o.includes}"`:o.format==="regex"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 b\xE1 \xE0p\u1EB9\u1EB9r\u1EB9 mu ${o.pattern}`:`A\u1E63\xEC\u1E63e: ${r[o.format]??t.format}`}case"not_multiple_of":return`N\u1ECD\u0301mb\xE0 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 j\u1EB9\u0301 \xE8y\xE0 p\xEDp\xEDn ti ${t.divisor}`;case"unrecognized_keys":return`B\u1ECDt\xECn\xEC \xE0\xECm\u1ECD\u0300: ${E(t.keys,", ")}`;case"invalid_key":return`B\u1ECDt\xECn\xEC a\u1E63\xEC\u1E63e n\xEDn\xFA ${t.origin}`;case"invalid_union":return"\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e";case"invalid_element":return`Iye a\u1E63\xEC\u1E63e n\xEDn\xFA ${t.origin}`;default:return"\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e"}}};function ev(){return{localeError:zw()}}var tv,ad=Symbol("ZodOutput"),cd=Symbol("ZodInput"),xs=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...r){let i=r[0];return this._map.set(e,i),i&&typeof i=="object"&&"id"in i&&this._idmap.set(i.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let r=this._map.get(e);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(e),this}get(e){let r=e._zod.parent;if(r){let i={...this.get(r)??{}};delete i.id;let t={...i,...this._map.get(e)};return Object.keys(t).length?t:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function Ss(){return new xs}(tv=globalThis).__zod_globalRegistry??(tv.__zod_globalRegistry=Ss());var Re=globalThis.__zod_globalRegistry;function ld(n,e){return new n({type:"string",...O(e)})}function ud(n,e){return new n({type:"string",coerce:!0,...O(e)})}function $s(n,e){return new n({type:"string",format:"email",check:"string_format",abort:!1,...O(e)})}function wi(n,e){return new n({type:"string",format:"guid",check:"string_format",abort:!1,...O(e)})}function ws(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,...O(e)})}function ks(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...O(e)})}function Es(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...O(e)})}function Is(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...O(e)})}function ki(n,e){return new n({type:"string",format:"url",check:"string_format",abort:!1,...O(e)})}function Ts(n,e){return new n({type:"string",format:"emoji",check:"string_format",abort:!1,...O(e)})}function Ps(n,e){return new n({type:"string",format:"nanoid",check:"string_format",abort:!1,...O(e)})}function Rs(n,e){return new n({type:"string",format:"cuid",check:"string_format",abort:!1,...O(e)})}function Ns(n,e){return new n({type:"string",format:"cuid2",check:"string_format",abort:!1,...O(e)})}function zs(n,e){return new n({type:"string",format:"ulid",check:"string_format",abort:!1,...O(e)})}function Ds(n,e){return new n({type:"string",format:"xid",check:"string_format",abort:!1,...O(e)})}function Cs(n,e){return new n({type:"string",format:"ksuid",check:"string_format",abort:!1,...O(e)})}function Ls(n,e){return new n({type:"string",format:"ipv4",check:"string_format",abort:!1,...O(e)})}function As(n,e){return new n({type:"string",format:"ipv6",check:"string_format",abort:!1,...O(e)})}function dd(n,e){return new n({type:"string",format:"mac",check:"string_format",abort:!1,...O(e)})}function Os(n,e){return new n({type:"string",format:"cidrv4",check:"string_format",abort:!1,...O(e)})}function Ms(n,e){return new n({type:"string",format:"cidrv6",check:"string_format",abort:!1,...O(e)})}function js(n,e){return new n({type:"string",format:"base64",check:"string_format",abort:!1,...O(e)})}function Us(n,e){return new n({type:"string",format:"base64url",check:"string_format",abort:!1,...O(e)})}function Fs(n,e){return new n({type:"string",format:"e164",check:"string_format",abort:!1,...O(e)})}function Zs(n,e){return new n({type:"string",format:"jwt",check:"string_format",abort:!1,...O(e)})}var pd={Any:null,Minute:-1,Second:0,Millisecond:3,Microsecond:6};function md(n,e){return new n({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...O(e)})}function fd(n,e){return new n({type:"string",format:"date",check:"string_format",...O(e)})}function hd(n,e){return new n({type:"string",format:"time",check:"string_format",precision:null,...O(e)})}function gd(n,e){return new n({type:"string",format:"duration",check:"string_format",...O(e)})}function yd(n,e){return new n({type:"number",checks:[],...O(e)})}function vd(n,e){return new n({type:"number",coerce:!0,checks:[],...O(e)})}function bd(n,e){return new n({type:"number",check:"number_format",abort:!1,format:"safeint",...O(e)})}function _d(n,e){return new n({type:"number",check:"number_format",abort:!1,format:"float32",...O(e)})}function xd(n,e){return new n({type:"number",check:"number_format",abort:!1,format:"float64",...O(e)})}function Sd(n,e){return new n({type:"number",check:"number_format",abort:!1,format:"int32",...O(e)})}function $d(n,e){return new n({type:"number",check:"number_format",abort:!1,format:"uint32",...O(e)})}function wd(n,e){return new n({type:"boolean",...O(e)})}function kd(n,e){return new n({type:"boolean",coerce:!0,...O(e)})}function Ed(n,e){return new n({type:"bigint",...O(e)})}function Id(n,e){return new n({type:"bigint",coerce:!0,...O(e)})}function Td(n,e){return new n({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...O(e)})}function Pd(n,e){return new n({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...O(e)})}function Rd(n,e){return new n({type:"symbol",...O(e)})}function Nd(n,e){return new n({type:"undefined",...O(e)})}function zd(n,e){return new n({type:"null",...O(e)})}function Dd(n){return new n({type:"any"})}function Cd(n){return new n({type:"unknown"})}function Ld(n,e){return new n({type:"never",...O(e)})}function Ad(n,e){return new n({type:"void",...O(e)})}function Od(n,e){return new n({type:"date",...O(e)})}function Md(n,e){return new n({type:"date",coerce:!0,...O(e)})}function jd(n,e){return new n({type:"nan",...O(e)})}function xt(n,e){return new as({check:"less_than",...O(e),value:n,inclusive:!1})}function qe(n,e){return new as({check:"less_than",...O(e),value:n,inclusive:!0})}function St(n,e){return new cs({check:"greater_than",...O(e),value:n,inclusive:!1})}function Le(n,e){return new cs({check:"greater_than",...O(e),value:n,inclusive:!0})}function Hs(n){return St(0,n)}function Ws(n){return xt(0,n)}function Bs(n){return qe(0,n)}function Gs(n){return Le(0,n)}function on(n,e){return new zl({check:"multiple_of",...O(e),value:n})}function sn(n,e){return new Ll({check:"max_size",...O(e),maximum:n})}function $t(n,e){return new Al({check:"min_size",...O(e),minimum:n})}function Cn(n,e){return new Ol({check:"size_equals",...O(e),size:n})}function Ln(n,e){return new Ml({check:"max_length",...O(e),maximum:n})}function At(n,e){return new jl({check:"min_length",...O(e),minimum:n})}function An(n,e){return new Ul({check:"length_equals",...O(e),length:n})}function mr(n,e){return new Fl({check:"string_format",format:"regex",...O(e),pattern:n})}function fr(n){return new Zl({check:"string_format",format:"lowercase",...O(n)})}function hr(n){return new Hl({check:"string_format",format:"uppercase",...O(n)})}function gr(n,e){return new Wl({check:"string_format",format:"includes",...O(e),includes:n})}function yr(n,e){return new Bl({check:"string_format",format:"starts_with",...O(e),prefix:n})}function vr(n,e){return new Gl({check:"string_format",format:"ends_with",...O(e),suffix:n})}function Js(n,e,r){return new Jl({check:"property",property:n,schema:e,...O(r)})}function br(n,e){return new ql({check:"mime_type",mime:n,...O(e)})}function mt(n){return new Vl({check:"overwrite",tx:n})}function _r(n){return mt(e=>e.normalize(n))}function xr(){return mt(n=>n.trim())}function Sr(){return mt(n=>n.toLowerCase())}function $r(){return mt(n=>n.toUpperCase())}function wr(){return mt(n=>Jc(n))}function Ud(n,e,r){return new n({type:"array",element:e,...O(r)})}function Cw(n,e,r){return new n({type:"union",options:e,...O(r)})}function Lw(n,e,r){return new n({type:"union",options:e,inclusive:!1,...O(r)})}function Aw(n,e,r,i){return new n({type:"union",options:r,discriminator:e,...O(i)})}function Ow(n,e,r){return new n({type:"intersection",left:e,right:r})}function Mw(n,e,r,i){let t=r instanceof Y,o=t?i:r,s=t?r:null;return new n({type:"tuple",items:e,rest:s,...O(o)})}function jw(n,e,r,i){return new n({type:"record",keyType:e,valueType:r,...O(i)})}function Uw(n,e,r,i){return new n({type:"map",keyType:e,valueType:r,...O(i)})}function Fw(n,e,r){return new n({type:"set",valueType:e,...O(r)})}function Zw(n,e,r){let i=Array.isArray(e)?Object.fromEntries(e.map(t=>[t,t])):e;return new n({type:"enum",entries:i,...O(r)})}function Hw(n,e,r){return new n({type:"enum",entries:e,...O(r)})}function Ww(n,e,r){return new n({type:"literal",values:Array.isArray(e)?e:[e],...O(r)})}function Fd(n,e){return new n({type:"file",...O(e)})}function Bw(n,e){return new n({type:"transform",transform:e})}function Gw(n,e){return new n({type:"optional",innerType:e})}function Jw(n,e){return new n({type:"nullable",innerType:e})}function qw(n,e,r){return new n({type:"default",innerType:e,get defaultValue(){return typeof r=="function"?r():Vc(r)}})}function Vw(n,e,r){return new n({type:"nonoptional",innerType:e,...O(r)})}function Kw(n,e){return new n({type:"success",innerType:e})}function Yw(n,e,r){return new n({type:"catch",innerType:e,catchValue:typeof r=="function"?r:()=>r})}function Xw(n,e,r){return new n({type:"pipe",in:e,out:r})}function Qw(n,e){return new n({type:"readonly",innerType:e})}function ek(n,e,r){return new n({type:"template_literal",parts:e,...O(r)})}function tk(n,e){return new n({type:"lazy",getter:e})}function nk(n,e){return new n({type:"promise",innerType:e})}function Zd(n,e,r){let i=O(r);return i.abort??(i.abort=!0),new n({type:"custom",check:"custom",fn:e,...i})}function Hd(n,e,r){return new n({type:"custom",check:"custom",fn:e,...O(r)})}function Wd(n){let e=nv(r=>(r.addIssue=i=>{if(typeof i=="string")r.issues.push(sr(i,r.value,e._zod.def));else{let t=i;t.fatal&&(t.continue=!1),t.code??(t.code="custom"),t.input??(t.input=r.value),t.inst??(t.inst=e),t.continue??(t.continue=!e._zod.def.abort),r.issues.push(sr(t))}},n(r.value,r)));return e}function nv(n,e){let r=new ue({check:"custom",...O(e)});return r._zod.check=n,r}function Bd(n){let e=new ue({check:"describe"});return e._zod.onattach=[r=>{let i=Re.get(r)??{};Re.add(r,{...i,description:n})}],e._zod.check=()=>{},e}function Gd(n){let e=new ue({check:"meta"});return e._zod.onattach=[r=>{let i=Re.get(r)??{};Re.add(r,{...i,...n})}],e._zod.check=()=>{},e}function Jd(n,e){let r=O(e),i=r.truthy??["true","1","yes","on","y","enabled"],t=r.falsy??["false","0","no","off","n","disabled"];r.case!=="sensitive"&&(i=i.map(m=>typeof m=="string"?m.toLowerCase():m),t=t.map(m=>typeof m=="string"?m.toLowerCase():m));let o=new Set(i),s=new Set(t),a=n.Codec??xi,c=n.Boolean??bi,l=n.String??Dn,u=new l({type:"string",error:r.error}),d=new c({type:"boolean",error:r.error}),p=new a({type:"pipe",in:u,out:d,transform:((m,f)=>{let h=m;return r.case!=="sensitive"&&(h=h.toLowerCase()),o.has(h)?!0:s.has(h)?!1:(f.issues.push({code:"invalid_value",expected:"stringbool",values:[...o,...s],input:f.value,inst:p,continue:!1}),{})}),reverseTransform:((m,f)=>m===!0?i[0]||"true":t[0]||"false"),error:r.error});return p}function kr(n,e,r,i={}){let t=O(i),o={...O(i),check:"string_format",type:"string",format:e,fn:typeof r=="function"?r:a=>r.test(a),...t};return r instanceof RegExp&&(o.pattern=r),new n(o)}function an(n){let e=n?.target??"draft-2020-12";return e==="draft-4"&&(e="draft-04"),e==="draft-7"&&(e="draft-07"),{processors:n.processors??{},metadataRegistry:n?.metadata??Re,target:e,unrepresentable:n?.unrepresentable??"throw",override:n?.override??(()=>{}),io:n?.io??"output",counter:0,seen:new Map,cycles:n?.cycles??"ref",reused:n?.reused??"inline",external:n?.external??void 0}}function ie(n,e,r={path:[],schemaPath:[]}){var i;let t=n._zod.def,o=e.seen.get(n);if(o)return o.count++,r.schemaPath.includes(n)&&(o.cycle=r.path),o.schema;let s={schema:{},count:1,cycle:void 0,path:r.path};e.seen.set(n,s);let a=n._zod.toJSONSchema?.();if(a)s.schema=a;else{let u={...r,schemaPath:[...r.schemaPath,n],path:r.path};if(n._zod.processJSONSchema)n._zod.processJSONSchema(e,s.schema,u);else{let p=s.schema,m=e.processors[t.type];if(!m)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${t.type}`);m(n,e,p,u)}let d=n._zod.parent;d&&(s.ref||(s.ref=d),ie(d,e,u),e.seen.get(d).isParent=!0)}let c=e.metadataRegistry.get(n);return c&&Object.assign(s.schema,c),e.io==="input"&&Ae(n)&&(delete s.schema.examples,delete s.schema.default),e.io==="input"&&s.schema._prefault&&((i=s.schema).default??(i.default=s.schema._prefault)),delete s.schema._prefault,e.seen.get(n).schema}function cn(n,e){let r=n.seen.get(e);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let i=new Map;for(let s of n.seen.entries()){let a=n.metadataRegistry.get(s[0])?.id;if(a){let c=i.get(a);if(c&&c!==s[0])throw new Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);i.set(a,s[0])}}let t=s=>{let a=n.target==="draft-2020-12"?"$defs":"definitions";if(n.external){let d=n.external.registry.get(s[0])?.id,p=n.external.uri??(f=>f);if(d)return{ref:p(d)};let m=s[1].defId??s[1].schema.id??`schema${n.counter++}`;return s[1].defId=m,{defId:m,ref:`${p("__shared")}#/${a}/${m}`}}if(s[1]===r)return{ref:"#"};let l=`#/${a}/`,u=s[1].schema.id??`__schema${n.counter++}`;return{defId:u,ref:l+u}},o=s=>{if(s[1].schema.$ref)return;let a=s[1],{ref:c,defId:l}=t(s);a.def={...a.schema},l&&(a.defId=l);let u=a.schema;for(let d in u)delete u[d];u.$ref=c};if(n.cycles==="throw")for(let s of n.seen.entries()){let a=s[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
765
+
766
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let s of n.seen.entries()){let a=s[1];if(e===s[0]){o(s);continue}if(n.external){let l=n.external.registry.get(s[0])?.id;if(e!==s[0]&&l){o(s);continue}}if(n.metadataRegistry.get(s[0])?.id){o(s);continue}if(a.cycle){o(s);continue}if(a.count>1&&n.reused==="ref"){o(s);continue}}}function ln(n,e){let r=n.seen.get(e);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let i=s=>{let a=n.seen.get(s);if(a.ref===null)return;let c=a.def??a.schema,l={...c},u=a.ref;if(a.ref=null,u){i(u);let p=n.seen.get(u),m=p.schema;if(m.$ref&&(n.target==="draft-07"||n.target==="draft-04"||n.target==="openapi-3.0")?(c.allOf=c.allOf??[],c.allOf.push(m)):Object.assign(c,m),Object.assign(c,l),s._zod.parent===u)for(let h in c)h==="$ref"||h==="allOf"||h in l||delete c[h];if(m.$ref&&p.def)for(let h in c)h==="$ref"||h==="allOf"||h in p.def&&JSON.stringify(c[h])===JSON.stringify(p.def[h])&&delete c[h]}let d=s._zod.parent;if(d&&d!==u){i(d);let p=n.seen.get(d);if(p?.schema.$ref&&(c.$ref=p.schema.$ref,p.def))for(let m in c)m==="$ref"||m==="allOf"||m in p.def&&JSON.stringify(c[m])===JSON.stringify(p.def[m])&&delete c[m]}n.override({zodSchema:s,jsonSchema:c,path:a.path??[]})};for(let s of[...n.seen.entries()].reverse())i(s[0]);let t={};if(n.target==="draft-2020-12"?t.$schema="https://json-schema.org/draft/2020-12/schema":n.target==="draft-07"?t.$schema="http://json-schema.org/draft-07/schema#":n.target==="draft-04"?t.$schema="http://json-schema.org/draft-04/schema#":n.target,n.external?.uri){let s=n.external.registry.get(e)?.id;if(!s)throw new Error("Schema is missing an `id` property");t.$id=n.external.uri(s)}Object.assign(t,r.def??r.schema);let o=n.external?.defs??{};for(let s of n.seen.entries()){let a=s[1];a.def&&a.defId&&(o[a.defId]=a.def)}n.external||Object.keys(o).length>0&&(n.target==="draft-2020-12"?t.$defs=o:t.definitions=o);try{let s=JSON.parse(JSON.stringify(t));return Object.defineProperty(s,"~standard",{value:{...e["~standard"],jsonSchema:{input:Er(e,"input",n.processors),output:Er(e,"output",n.processors)}},enumerable:!1,writable:!1}),s}catch{throw new Error("Error converting schema to JSON.")}}function Ae(n,e){let r=e??{seen:new Set};if(r.seen.has(n))return!1;r.seen.add(n);let i=n._zod.def;if(i.type==="transform")return!0;if(i.type==="array")return Ae(i.element,r);if(i.type==="set")return Ae(i.valueType,r);if(i.type==="lazy")return Ae(i.getter(),r);if(i.type==="promise"||i.type==="optional"||i.type==="nonoptional"||i.type==="nullable"||i.type==="readonly"||i.type==="default"||i.type==="prefault")return Ae(i.innerType,r);if(i.type==="intersection")return Ae(i.left,r)||Ae(i.right,r);if(i.type==="record"||i.type==="map")return Ae(i.keyType,r)||Ae(i.valueType,r);if(i.type==="pipe")return Ae(i.in,r)||Ae(i.out,r);if(i.type==="object"){for(let t in i.shape)if(Ae(i.shape[t],r))return!0;return!1}if(i.type==="union"){for(let t of i.options)if(Ae(t,r))return!0;return!1}if(i.type==="tuple"){for(let t of i.items)if(Ae(t,r))return!0;return!!(i.rest&&Ae(i.rest,r))}return!1}var qd=(n,e={})=>r=>{let i=an({...r,processors:e});return ie(n,i),cn(i,n),ln(i,n)},Er=(n,e,r={})=>i=>{let{libraryOptions:t,target:o}=i??{},s=an({...t??{},target:o,io:e,processors:r});return ie(n,s),cn(s,n),ln(s,n)};var rk={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Vd=(n,e,r,i)=>{let t=r;t.type="string";let{minimum:o,maximum:s,format:a,patterns:c,contentEncoding:l}=n._zod.bag;if(typeof o=="number"&&(t.minLength=o),typeof s=="number"&&(t.maxLength=s),a&&(t.format=rk[a]??a,t.format===""&&delete t.format,a==="time"&&delete t.format),l&&(t.contentEncoding=l),c&&c.size>0){let u=[...c];u.length===1?t.pattern=u[0].source:u.length>1&&(t.allOf=[...u.map(d=>({...e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"?{type:"string"}:{},pattern:d.source}))])}},Kd=(n,e,r,i)=>{let t=r,{minimum:o,maximum:s,format:a,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=n._zod.bag;typeof a=="string"&&a.includes("int")?t.type="integer":t.type="number",typeof u=="number"&&(e.target==="draft-04"||e.target==="openapi-3.0"?(t.minimum=u,t.exclusiveMinimum=!0):t.exclusiveMinimum=u),typeof o=="number"&&(t.minimum=o,typeof u=="number"&&e.target!=="draft-04"&&(u>=o?delete t.minimum:delete t.exclusiveMinimum)),typeof l=="number"&&(e.target==="draft-04"||e.target==="openapi-3.0"?(t.maximum=l,t.exclusiveMaximum=!0):t.exclusiveMaximum=l),typeof s=="number"&&(t.maximum=s,typeof l=="number"&&e.target!=="draft-04"&&(l<=s?delete t.maximum:delete t.exclusiveMaximum)),typeof c=="number"&&(t.multipleOf=c)},Yd=(n,e,r,i)=>{r.type="boolean"},Xd=(n,e,r,i)=>{if(e.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")},Qd=(n,e,r,i)=>{if(e.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema")},ep=(n,e,r,i)=>{e.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"},tp=(n,e,r,i)=>{if(e.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},np=(n,e,r,i)=>{if(e.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema")},rp=(n,e,r,i)=>{r.not={}},ip=(n,e,r,i)=>{},op=(n,e,r,i)=>{},sp=(n,e,r,i)=>{if(e.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},ap=(n,e,r,i)=>{let t=n._zod.def,o=ci(t.entries);o.every(s=>typeof s=="number")&&(r.type="number"),o.every(s=>typeof s=="string")&&(r.type="string"),r.enum=o},cp=(n,e,r,i)=>{let t=n._zod.def,o=[];for(let s of t.values)if(s===void 0){if(e.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof s=="bigint"){if(e.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");o.push(Number(s))}else o.push(s);if(o.length!==0)if(o.length===1){let s=o[0];r.type=s===null?"null":typeof s,e.target==="draft-04"||e.target==="openapi-3.0"?r.enum=[s]:r.const=s}else o.every(s=>typeof s=="number")&&(r.type="number"),o.every(s=>typeof s=="string")&&(r.type="string"),o.every(s=>typeof s=="boolean")&&(r.type="boolean"),o.every(s=>s===null)&&(r.type="null"),r.enum=o},lp=(n,e,r,i)=>{if(e.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},up=(n,e,r,i)=>{let t=r,o=n._zod.pattern;if(!o)throw new Error("Pattern not found in template literal");t.type="string",t.pattern=o.source},dp=(n,e,r,i)=>{let t=r,o={type:"string",format:"binary",contentEncoding:"binary"},{minimum:s,maximum:a,mime:c}=n._zod.bag;s!==void 0&&(o.minLength=s),a!==void 0&&(o.maxLength=a),c?c.length===1?(o.contentMediaType=c[0],Object.assign(t,o)):(Object.assign(t,o),t.anyOf=c.map(l=>({contentMediaType:l}))):Object.assign(t,o)},pp=(n,e,r,i)=>{r.type="boolean"},mp=(n,e,r,i)=>{if(e.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},fp=(n,e,r,i)=>{if(e.unrepresentable==="throw")throw new Error("Function types cannot be represented in JSON Schema")},hp=(n,e,r,i)=>{if(e.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},gp=(n,e,r,i)=>{if(e.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},yp=(n,e,r,i)=>{if(e.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema")},vp=(n,e,r,i)=>{let t=r,o=n._zod.def,{minimum:s,maximum:a}=n._zod.bag;typeof s=="number"&&(t.minItems=s),typeof a=="number"&&(t.maxItems=a),t.type="array",t.items=ie(o.element,e,{...i,path:[...i.path,"items"]})},bp=(n,e,r,i)=>{let t=r,o=n._zod.def;t.type="object",t.properties={};let s=o.shape;for(let l in s)t.properties[l]=ie(s[l],e,{...i,path:[...i.path,"properties",l]});let a=new Set(Object.keys(s)),c=new Set([...a].filter(l=>{let u=o.shape[l]._zod;return e.io==="input"?u.optin===void 0:u.optout===void 0}));c.size>0&&(t.required=Array.from(c)),o.catchall?._zod.def.type==="never"?t.additionalProperties=!1:o.catchall?o.catchall&&(t.additionalProperties=ie(o.catchall,e,{...i,path:[...i.path,"additionalProperties"]})):e.io==="output"&&(t.additionalProperties=!1)},Vs=(n,e,r,i)=>{let t=n._zod.def,o=t.inclusive===!1,s=t.options.map((a,c)=>ie(a,e,{...i,path:[...i.path,o?"oneOf":"anyOf",c]}));o?r.oneOf=s:r.anyOf=s},_p=(n,e,r,i)=>{let t=n._zod.def,o=ie(t.left,e,{...i,path:[...i.path,"allOf",0]}),s=ie(t.right,e,{...i,path:[...i.path,"allOf",1]}),a=l=>"allOf"in l&&Object.keys(l).length===1,c=[...a(o)?o.allOf:[o],...a(s)?s.allOf:[s]];r.allOf=c},xp=(n,e,r,i)=>{let t=r,o=n._zod.def;t.type="array";let s=e.target==="draft-2020-12"?"prefixItems":"items",a=e.target==="draft-2020-12"||e.target==="openapi-3.0"?"items":"additionalItems",c=o.items.map((p,m)=>ie(p,e,{...i,path:[...i.path,s,m]})),l=o.rest?ie(o.rest,e,{...i,path:[...i.path,a,...e.target==="openapi-3.0"?[o.items.length]:[]]}):null;e.target==="draft-2020-12"?(t.prefixItems=c,l&&(t.items=l)):e.target==="openapi-3.0"?(t.items={anyOf:c},l&&t.items.anyOf.push(l),t.minItems=c.length,l||(t.maxItems=c.length)):(t.items=c,l&&(t.additionalItems=l));let{minimum:u,maximum:d}=n._zod.bag;typeof u=="number"&&(t.minItems=u),typeof d=="number"&&(t.maxItems=d)},Sp=(n,e,r,i)=>{let t=r,o=n._zod.def;t.type="object";let s=o.keyType,c=s._zod.bag?.patterns;if(o.mode==="loose"&&c&&c.size>0){let u=ie(o.valueType,e,{...i,path:[...i.path,"patternProperties","*"]});t.patternProperties={};for(let d of c)t.patternProperties[d.source]=u}else(e.target==="draft-07"||e.target==="draft-2020-12")&&(t.propertyNames=ie(o.keyType,e,{...i,path:[...i.path,"propertyNames"]})),t.additionalProperties=ie(o.valueType,e,{...i,path:[...i.path,"additionalProperties"]});let l=s._zod.values;if(l){let u=[...l].filter(d=>typeof d=="string"||typeof d=="number");u.length>0&&(t.required=u)}},$p=(n,e,r,i)=>{let t=n._zod.def,o=ie(t.innerType,e,i),s=e.seen.get(n);e.target==="openapi-3.0"?(s.ref=t.innerType,r.nullable=!0):r.anyOf=[o,{type:"null"}]},wp=(n,e,r,i)=>{let t=n._zod.def;ie(t.innerType,e,i);let o=e.seen.get(n);o.ref=t.innerType},kp=(n,e,r,i)=>{let t=n._zod.def;ie(t.innerType,e,i);let o=e.seen.get(n);o.ref=t.innerType,r.default=JSON.parse(JSON.stringify(t.defaultValue))},Ep=(n,e,r,i)=>{let t=n._zod.def;ie(t.innerType,e,i);let o=e.seen.get(n);o.ref=t.innerType,e.io==="input"&&(r._prefault=JSON.parse(JSON.stringify(t.defaultValue)))},Ip=(n,e,r,i)=>{let t=n._zod.def;ie(t.innerType,e,i);let o=e.seen.get(n);o.ref=t.innerType;let s;try{s=t.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}r.default=s},Tp=(n,e,r,i)=>{let t=n._zod.def,o=e.io==="input"?t.in._zod.def.type==="transform"?t.out:t.in:t.out;ie(o,e,i);let s=e.seen.get(n);s.ref=o},Pp=(n,e,r,i)=>{let t=n._zod.def;ie(t.innerType,e,i);let o=e.seen.get(n);o.ref=t.innerType,r.readOnly=!0},Rp=(n,e,r,i)=>{let t=n._zod.def;ie(t.innerType,e,i);let o=e.seen.get(n);o.ref=t.innerType},Ks=(n,e,r,i)=>{let t=n._zod.def;ie(t.innerType,e,i);let o=e.seen.get(n);o.ref=t.innerType},Np=(n,e,r,i)=>{let t=n._zod.innerType;ie(t,e,i);let o=e.seen.get(n);o.ref=t},qs={string:Vd,number:Kd,boolean:Yd,bigint:Xd,symbol:Qd,null:ep,undefined:tp,void:np,never:rp,any:ip,unknown:op,date:sp,enum:ap,literal:cp,nan:lp,template_literal:up,file:dp,success:pp,custom:mp,function:fp,transform:hp,map:gp,set:yp,array:vp,object:bp,union:Vs,intersection:_p,tuple:xp,record:Sp,nullable:$p,nonoptional:wp,default:kp,prefault:Ep,catch:Ip,pipe:Tp,readonly:Pp,promise:Rp,optional:Ks,lazy:Np};function Ys(n,e){if("_idmap"in n){let i=n,t=an({...e,processors:qs}),o={};for(let c of i._idmap.entries()){let[l,u]=c;ie(u,t)}let s={},a={registry:i,uri:e?.uri,defs:o};t.external=a;for(let c of i._idmap.entries()){let[l,u]=c;cn(t,u),s[l]=ln(t,u)}if(Object.keys(o).length>0){let c=t.target==="draft-2020-12"?"$defs":"definitions";s.__shared={[c]:o}}return{schemas:s}}let r=an({...e,processors:qs});return ie(n,r),cn(r,n),ln(r,n)}var Xs=class{get metadataRegistry(){return this.ctx.metadataRegistry}get target(){return this.ctx.target}get unrepresentable(){return this.ctx.unrepresentable}get override(){return this.ctx.override}get io(){return this.ctx.io}get counter(){return this.ctx.counter}set counter(e){this.ctx.counter=e}get seen(){return this.ctx.seen}constructor(e){let r=e?.target??"draft-2020-12";r==="draft-4"&&(r="draft-04"),r==="draft-7"&&(r="draft-07"),this.ctx=an({processors:qs,target:r,...e?.metadata&&{metadata:e.metadata},...e?.unrepresentable&&{unrepresentable:e.unrepresentable},...e?.override&&{override:e.override},...e?.io&&{io:e.io}})}process(e,r={path:[],schemaPath:[]}){return ie(e,this.ctx,r)}emit(e,r){r&&(r.cycles&&(this.ctx.cycles=r.cycles),r.reused&&(this.ctx.reused=r.reused),r.external&&(this.ctx.external=r.external)),cn(this.ctx,e);let i=ln(this.ctx,e),{"~standard":t,...o}=i;return o}};var rv={};var Ei={};Ke(Ei,{ZodAny:()=>tm,ZodArray:()=>om,ZodBase64:()=>ba,ZodBase64URL:()=>_a,ZodBigInt:()=>Dr,ZodBigIntFormat:()=>$a,ZodBoolean:()=>zr,ZodCIDRv4:()=>ya,ZodCIDRv6:()=>va,ZodCUID:()=>ua,ZodCUID2:()=>da,ZodCatch:()=>Im,ZodCodec:()=>Na,ZodCustom:()=>Oi,ZodCustomStringFormat:()=>Rr,ZodDate:()=>zi,ZodDefault:()=>xm,ZodDiscriminatedUnion:()=>am,ZodE164:()=>xa,ZodEmail:()=>aa,ZodEmoji:()=>ca,ZodEnum:()=>Tr,ZodExactOptional:()=>vm,ZodFile:()=>gm,ZodFunction:()=>Am,ZodGUID:()=>Ii,ZodIPv4:()=>ha,ZodIPv6:()=>ga,ZodIntersection:()=>cm,ZodJWT:()=>Sa,ZodKSUID:()=>fa,ZodLazy:()=>Dm,ZodLiteral:()=>hm,ZodMAC:()=>qp,ZodMap:()=>mm,ZodNaN:()=>Pm,ZodNanoID:()=>la,ZodNever:()=>rm,ZodNonOptional:()=>Pa,ZodNull:()=>Qp,ZodNullable:()=>_m,ZodNumber:()=>Nr,ZodNumberFormat:()=>Mn,ZodObject:()=>Ci,ZodOptional:()=>Ta,ZodPipe:()=>Ra,ZodPrefault:()=>$m,ZodPromise:()=>Lm,ZodReadonly:()=>Rm,ZodRecord:()=>Ai,ZodSet:()=>fm,ZodString:()=>Pr,ZodStringFormat:()=>se,ZodSuccess:()=>Em,ZodSymbol:()=>Yp,ZodTemplateLiteral:()=>zm,ZodTransform:()=>ym,ZodTuple:()=>um,ZodType:()=>ee,ZodULID:()=>pa,ZodURL:()=>Ni,ZodUUID:()=>wt,ZodUndefined:()=>Xp,ZodUnion:()=>Li,ZodUnknown:()=>nm,ZodVoid:()=>im,ZodXID:()=>ma,ZodXor:()=>sm,_ZodString:()=>sa,_default:()=>Sm,_function:()=>ub,any:()=>Zv,array:()=>Di,base64:()=>kv,base64url:()=>Ev,bigint:()=>Ov,boolean:()=>Kp,catch:()=>Tm,check:()=>db,cidrv4:()=>$v,cidrv6:()=>wv,codec:()=>ab,cuid:()=>hv,cuid2:()=>gv,custom:()=>pb,date:()=>Wv,describe:()=>mb,discriminatedUnion:()=>Kv,e164:()=>Iv,email:()=>ov,emoji:()=>mv,enum:()=>Ea,exactOptional:()=>bm,file:()=>rb,float32:()=>Dv,float64:()=>Cv,function:()=>ub,guid:()=>sv,hash:()=>zv,hex:()=>Nv,hostname:()=>Rv,httpUrl:()=>pv,instanceof:()=>hb,int:()=>oa,int32:()=>Lv,int64:()=>Mv,intersection:()=>lm,ipv4:()=>_v,ipv6:()=>Sv,json:()=>yb,jwt:()=>Tv,keyof:()=>Bv,ksuid:()=>bv,lazy:()=>Cm,literal:()=>nb,looseObject:()=>qv,looseRecord:()=>Xv,mac:()=>xv,map:()=>Qv,meta:()=>fb,nan:()=>sb,nanoid:()=>fv,nativeEnum:()=>tb,never:()=>wa,nonoptional:()=>km,null:()=>em,nullable:()=>Pi,nullish:()=>ib,number:()=>Vp,object:()=>Gv,optional:()=>Ti,partialRecord:()=>Yv,pipe:()=>Ri,prefault:()=>wm,preprocess:()=>vb,promise:()=>lb,readonly:()=>Nm,record:()=>pm,refine:()=>Om,set:()=>eb,strictObject:()=>Jv,string:()=>ia,stringFormat:()=>Pv,stringbool:()=>gb,success:()=>ob,superRefine:()=>Mm,symbol:()=>Uv,templateLiteral:()=>cb,transform:()=>Ia,tuple:()=>dm,uint32:()=>Av,uint64:()=>jv,ulid:()=>yv,undefined:()=>Fv,union:()=>ka,unknown:()=>On,url:()=>dv,uuid:()=>av,uuidv4:()=>cv,uuidv6:()=>lv,uuidv7:()=>uv,void:()=>Hv,xid:()=>vv,xor:()=>Vv});var Qs={};Ke(Qs,{endsWith:()=>vr,gt:()=>St,gte:()=>Le,includes:()=>gr,length:()=>An,lowercase:()=>fr,lt:()=>xt,lte:()=>qe,maxLength:()=>Ln,maxSize:()=>sn,mime:()=>br,minLength:()=>At,minSize:()=>$t,multipleOf:()=>on,negative:()=>Ws,nonnegative:()=>Gs,nonpositive:()=>Bs,normalize:()=>_r,overwrite:()=>mt,positive:()=>Hs,property:()=>Js,regex:()=>mr,size:()=>Cn,slugify:()=>wr,startsWith:()=>yr,toLowerCase:()=>Sr,toUpperCase:()=>$r,trim:()=>xr,uppercase:()=>hr});var Ir={};Ke(Ir,{ZodISODate:()=>ta,ZodISODateTime:()=>ea,ZodISODuration:()=>ra,ZodISOTime:()=>na,date:()=>Dp,datetime:()=>zp,duration:()=>Lp,time:()=>Cp});var ea=S("ZodISODateTime",(n,e)=>{lu.init(n,e),se.init(n,e)});function zp(n){return md(ea,n)}var ta=S("ZodISODate",(n,e)=>{uu.init(n,e),se.init(n,e)});function Dp(n){return fd(ta,n)}var na=S("ZodISOTime",(n,e)=>{du.init(n,e),se.init(n,e)});function Cp(n){return hd(na,n)}var ra=S("ZodISODuration",(n,e)=>{pu.init(n,e),se.init(n,e)});function Lp(n){return gd(ra,n)}var iv=(n,e)=>{mi.init(n,e),n.name="ZodError",Object.defineProperties(n,{format:{value:r=>hi(n,r)},flatten:{value:r=>fi(n,r)},addIssue:{value:r=>{n.issues.push(r),n.message=JSON.stringify(n.issues,ir,2)}},addIssues:{value:r=>{n.issues.push(...r),n.message=JSON.stringify(n.issues,ir,2)}},isEmpty:{get(){return n.issues.length===0}}})},ok=S("ZodError",iv),Ge=S("ZodError",iv,{Parent:Error});var Ap=ar(Ge),Op=cr(Ge),Mp=lr(Ge),jp=ur(Ge),Up=Yo(Ge),Fp=Xo(Ge),Zp=Qo(Ge),Hp=es(Ge),Wp=ts(Ge),Bp=ns(Ge),Gp=rs(Ge),Jp=is(Ge);var ee=S("ZodType",(n,e)=>(Y.init(n,e),Object.assign(n["~standard"],{jsonSchema:{input:Er(n,"input"),output:Er(n,"output")}}),n.toJSONSchema=qd(n,{}),n.def=e,n.type=e.type,Object.defineProperty(n,"_def",{value:e}),n.check=(...r)=>n.clone(L.mergeDefs(e,{checks:[...e.checks??[],...r.map(i=>typeof i=="function"?{_zod:{check:i,def:{check:"custom"},onattach:[]}}:i)]}),{parent:!0}),n.with=n.check,n.clone=(r,i)=>Ce(n,r,i),n.brand=()=>n,n.register=((r,i)=>(r.add(n,i),n)),n.parse=(r,i)=>Ap(n,r,i,{callee:n.parse}),n.safeParse=(r,i)=>Mp(n,r,i),n.parseAsync=async(r,i)=>Op(n,r,i,{callee:n.parseAsync}),n.safeParseAsync=async(r,i)=>jp(n,r,i),n.spa=n.safeParseAsync,n.encode=(r,i)=>Up(n,r,i),n.decode=(r,i)=>Fp(n,r,i),n.encodeAsync=async(r,i)=>Zp(n,r,i),n.decodeAsync=async(r,i)=>Hp(n,r,i),n.safeEncode=(r,i)=>Wp(n,r,i),n.safeDecode=(r,i)=>Bp(n,r,i),n.safeEncodeAsync=async(r,i)=>Gp(n,r,i),n.safeDecodeAsync=async(r,i)=>Jp(n,r,i),n.refine=(r,i)=>n.check(Om(r,i)),n.superRefine=r=>n.check(Mm(r)),n.overwrite=r=>n.check(mt(r)),n.optional=()=>Ti(n),n.exactOptional=()=>bm(n),n.nullable=()=>Pi(n),n.nullish=()=>Ti(Pi(n)),n.nonoptional=r=>km(n,r),n.array=()=>Di(n),n.or=r=>ka([n,r]),n.and=r=>lm(n,r),n.transform=r=>Ri(n,Ia(r)),n.default=r=>Sm(n,r),n.prefault=r=>wm(n,r),n.catch=r=>Tm(n,r),n.pipe=r=>Ri(n,r),n.readonly=()=>Nm(n),n.describe=r=>{let i=n.clone();return Re.add(i,{description:r}),i},Object.defineProperty(n,"description",{get(){return Re.get(n)?.description},configurable:!0}),n.meta=(...r)=>{if(r.length===0)return Re.get(n);let i=n.clone();return Re.add(i,r[0]),i},n.isOptional=()=>n.safeParse(void 0).success,n.isNullable=()=>n.safeParse(null).success,n.apply=r=>r(n),n)),sa=S("_ZodString",(n,e)=>{Dn.init(n,e),ee.init(n,e),n._zod.processJSONSchema=(i,t,o)=>Vd(n,i,t,o);let r=n._zod.bag;n.format=r.format??null,n.minLength=r.minimum??null,n.maxLength=r.maximum??null,n.regex=(...i)=>n.check(mr(...i)),n.includes=(...i)=>n.check(gr(...i)),n.startsWith=(...i)=>n.check(yr(...i)),n.endsWith=(...i)=>n.check(vr(...i)),n.min=(...i)=>n.check(At(...i)),n.max=(...i)=>n.check(Ln(...i)),n.length=(...i)=>n.check(An(...i)),n.nonempty=(...i)=>n.check(At(1,...i)),n.lowercase=i=>n.check(fr(i)),n.uppercase=i=>n.check(hr(i)),n.trim=()=>n.check(xr()),n.normalize=(...i)=>n.check(_r(...i)),n.toLowerCase=()=>n.check(Sr()),n.toUpperCase=()=>n.check($r()),n.slugify=()=>n.check(wr())}),Pr=S("ZodString",(n,e)=>{Dn.init(n,e),sa.init(n,e),n.email=r=>n.check($s(aa,r)),n.url=r=>n.check(ki(Ni,r)),n.jwt=r=>n.check(Zs(Sa,r)),n.emoji=r=>n.check(Ts(ca,r)),n.guid=r=>n.check(wi(Ii,r)),n.uuid=r=>n.check(ws(wt,r)),n.uuidv4=r=>n.check(ks(wt,r)),n.uuidv6=r=>n.check(Es(wt,r)),n.uuidv7=r=>n.check(Is(wt,r)),n.nanoid=r=>n.check(Ps(la,r)),n.guid=r=>n.check(wi(Ii,r)),n.cuid=r=>n.check(Rs(ua,r)),n.cuid2=r=>n.check(Ns(da,r)),n.ulid=r=>n.check(zs(pa,r)),n.base64=r=>n.check(js(ba,r)),n.base64url=r=>n.check(Us(_a,r)),n.xid=r=>n.check(Ds(ma,r)),n.ksuid=r=>n.check(Cs(fa,r)),n.ipv4=r=>n.check(Ls(ha,r)),n.ipv6=r=>n.check(As(ga,r)),n.cidrv4=r=>n.check(Os(ya,r)),n.cidrv6=r=>n.check(Ms(va,r)),n.e164=r=>n.check(Fs(xa,r)),n.datetime=r=>n.check(zp(r)),n.date=r=>n.check(Dp(r)),n.time=r=>n.check(Cp(r)),n.duration=r=>n.check(Lp(r))});function ia(n){return ld(Pr,n)}var se=S("ZodStringFormat",(n,e)=>{oe.init(n,e),sa.init(n,e)}),aa=S("ZodEmail",(n,e)=>{eu.init(n,e),se.init(n,e)});function ov(n){return $s(aa,n)}var Ii=S("ZodGUID",(n,e)=>{Xl.init(n,e),se.init(n,e)});function sv(n){return wi(Ii,n)}var wt=S("ZodUUID",(n,e)=>{Ql.init(n,e),se.init(n,e)});function av(n){return ws(wt,n)}function cv(n){return ks(wt,n)}function lv(n){return Es(wt,n)}function uv(n){return Is(wt,n)}var Ni=S("ZodURL",(n,e)=>{tu.init(n,e),se.init(n,e)});function dv(n){return ki(Ni,n)}function pv(n){return ki(Ni,{protocol:/^https?$/,hostname:nt.domain,...L.normalizeParams(n)})}var ca=S("ZodEmoji",(n,e)=>{nu.init(n,e),se.init(n,e)});function mv(n){return Ts(ca,n)}var la=S("ZodNanoID",(n,e)=>{ru.init(n,e),se.init(n,e)});function fv(n){return Ps(la,n)}var ua=S("ZodCUID",(n,e)=>{iu.init(n,e),se.init(n,e)});function hv(n){return Rs(ua,n)}var da=S("ZodCUID2",(n,e)=>{ou.init(n,e),se.init(n,e)});function gv(n){return Ns(da,n)}var pa=S("ZodULID",(n,e)=>{su.init(n,e),se.init(n,e)});function yv(n){return zs(pa,n)}var ma=S("ZodXID",(n,e)=>{au.init(n,e),se.init(n,e)});function vv(n){return Ds(ma,n)}var fa=S("ZodKSUID",(n,e)=>{cu.init(n,e),se.init(n,e)});function bv(n){return Cs(fa,n)}var ha=S("ZodIPv4",(n,e)=>{mu.init(n,e),se.init(n,e)});function _v(n){return Ls(ha,n)}var qp=S("ZodMAC",(n,e)=>{hu.init(n,e),se.init(n,e)});function xv(n){return dd(qp,n)}var ga=S("ZodIPv6",(n,e)=>{fu.init(n,e),se.init(n,e)});function Sv(n){return As(ga,n)}var ya=S("ZodCIDRv4",(n,e)=>{gu.init(n,e),se.init(n,e)});function $v(n){return Os(ya,n)}var va=S("ZodCIDRv6",(n,e)=>{yu.init(n,e),se.init(n,e)});function wv(n){return Ms(va,n)}var ba=S("ZodBase64",(n,e)=>{bu.init(n,e),se.init(n,e)});function kv(n){return js(ba,n)}var _a=S("ZodBase64URL",(n,e)=>{_u.init(n,e),se.init(n,e)});function Ev(n){return Us(_a,n)}var xa=S("ZodE164",(n,e)=>{xu.init(n,e),se.init(n,e)});function Iv(n){return Fs(xa,n)}var Sa=S("ZodJWT",(n,e)=>{Su.init(n,e),se.init(n,e)});function Tv(n){return Zs(Sa,n)}var Rr=S("ZodCustomStringFormat",(n,e)=>{$u.init(n,e),se.init(n,e)});function Pv(n,e,r={}){return kr(Rr,n,e,r)}function Rv(n){return kr(Rr,"hostname",nt.hostname,n)}function Nv(n){return kr(Rr,"hex",nt.hex,n)}function zv(n,e){let r=e?.enc??"hex",i=`${n}_${r}`,t=nt[i];if(!t)throw new Error(`Unrecognized hash format: ${i}`);return kr(Rr,i,t,e)}var Nr=S("ZodNumber",(n,e)=>{fs.init(n,e),ee.init(n,e),n._zod.processJSONSchema=(i,t,o)=>Kd(n,i,t,o),n.gt=(i,t)=>n.check(St(i,t)),n.gte=(i,t)=>n.check(Le(i,t)),n.min=(i,t)=>n.check(Le(i,t)),n.lt=(i,t)=>n.check(xt(i,t)),n.lte=(i,t)=>n.check(qe(i,t)),n.max=(i,t)=>n.check(qe(i,t)),n.int=i=>n.check(oa(i)),n.safe=i=>n.check(oa(i)),n.positive=i=>n.check(St(0,i)),n.nonnegative=i=>n.check(Le(0,i)),n.negative=i=>n.check(xt(0,i)),n.nonpositive=i=>n.check(qe(0,i)),n.multipleOf=(i,t)=>n.check(on(i,t)),n.step=(i,t)=>n.check(on(i,t)),n.finite=()=>n;let r=n._zod.bag;n.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,n.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,n.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),n.isFinite=!0,n.format=r.format??null});function Vp(n){return yd(Nr,n)}var Mn=S("ZodNumberFormat",(n,e)=>{wu.init(n,e),Nr.init(n,e)});function oa(n){return bd(Mn,n)}function Dv(n){return _d(Mn,n)}function Cv(n){return xd(Mn,n)}function Lv(n){return Sd(Mn,n)}function Av(n){return $d(Mn,n)}var zr=S("ZodBoolean",(n,e)=>{bi.init(n,e),ee.init(n,e),n._zod.processJSONSchema=(r,i,t)=>Yd(n,r,i,t)});function Kp(n){return wd(zr,n)}var Dr=S("ZodBigInt",(n,e)=>{hs.init(n,e),ee.init(n,e),n._zod.processJSONSchema=(i,t,o)=>Xd(n,i,t,o),n.gte=(i,t)=>n.check(Le(i,t)),n.min=(i,t)=>n.check(Le(i,t)),n.gt=(i,t)=>n.check(St(i,t)),n.gte=(i,t)=>n.check(Le(i,t)),n.min=(i,t)=>n.check(Le(i,t)),n.lt=(i,t)=>n.check(xt(i,t)),n.lte=(i,t)=>n.check(qe(i,t)),n.max=(i,t)=>n.check(qe(i,t)),n.positive=i=>n.check(St(BigInt(0),i)),n.negative=i=>n.check(xt(BigInt(0),i)),n.nonpositive=i=>n.check(qe(BigInt(0),i)),n.nonnegative=i=>n.check(Le(BigInt(0),i)),n.multipleOf=(i,t)=>n.check(on(i,t));let r=n._zod.bag;n.minValue=r.minimum??null,n.maxValue=r.maximum??null,n.format=r.format??null});function Ov(n){return Ed(Dr,n)}var $a=S("ZodBigIntFormat",(n,e)=>{ku.init(n,e),Dr.init(n,e)});function Mv(n){return Td($a,n)}function jv(n){return Pd($a,n)}var Yp=S("ZodSymbol",(n,e)=>{Eu.init(n,e),ee.init(n,e),n._zod.processJSONSchema=(r,i,t)=>Qd(n,r,i,t)});function Uv(n){return Rd(Yp,n)}var Xp=S("ZodUndefined",(n,e)=>{Iu.init(n,e),ee.init(n,e),n._zod.processJSONSchema=(r,i,t)=>tp(n,r,i,t)});function Fv(n){return Nd(Xp,n)}var Qp=S("ZodNull",(n,e)=>{Tu.init(n,e),ee.init(n,e),n._zod.processJSONSchema=(r,i,t)=>ep(n,r,i,t)});function em(n){return zd(Qp,n)}var tm=S("ZodAny",(n,e)=>{Pu.init(n,e),ee.init(n,e),n._zod.processJSONSchema=(r,i,t)=>ip(n,r,i,t)});function Zv(){return Dd(tm)}var nm=S("ZodUnknown",(n,e)=>{Ru.init(n,e),ee.init(n,e),n._zod.processJSONSchema=(r,i,t)=>op(n,r,i,t)});function On(){return Cd(nm)}var rm=S("ZodNever",(n,e)=>{Nu.init(n,e),ee.init(n,e),n._zod.processJSONSchema=(r,i,t)=>rp(n,r,i,t)});function wa(n){return Ld(rm,n)}var im=S("ZodVoid",(n,e)=>{zu.init(n,e),ee.init(n,e),n._zod.processJSONSchema=(r,i,t)=>np(n,r,i,t)});function Hv(n){return Ad(im,n)}var zi=S("ZodDate",(n,e)=>{Du.init(n,e),ee.init(n,e),n._zod.processJSONSchema=(i,t,o)=>sp(n,i,t,o),n.min=(i,t)=>n.check(Le(i,t)),n.max=(i,t)=>n.check(qe(i,t));let r=n._zod.bag;n.minDate=r.minimum?new Date(r.minimum):null,n.maxDate=r.maximum?new Date(r.maximum):null});function Wv(n){return Od(zi,n)}var om=S("ZodArray",(n,e)=>{Cu.init(n,e),ee.init(n,e),n._zod.processJSONSchema=(r,i,t)=>vp(n,r,i,t),n.element=e.element,n.min=(r,i)=>n.check(At(r,i)),n.nonempty=r=>n.check(At(1,r)),n.max=(r,i)=>n.check(Ln(r,i)),n.length=(r,i)=>n.check(An(r,i)),n.unwrap=()=>n.element});function Di(n,e){return Ud(om,n,e)}function Bv(n){let e=n._zod.def.shape;return Ea(Object.keys(e))}var Ci=S("ZodObject",(n,e)=>{Lu.init(n,e),ee.init(n,e),n._zod.processJSONSchema=(r,i,t)=>bp(n,r,i,t),L.defineLazy(n,"shape",()=>e.shape),n.keyof=()=>Ea(Object.keys(n._zod.def.shape)),n.catchall=r=>n.clone({...n._zod.def,catchall:r}),n.passthrough=()=>n.clone({...n._zod.def,catchall:On()}),n.loose=()=>n.clone({...n._zod.def,catchall:On()}),n.strict=()=>n.clone({...n._zod.def,catchall:wa()}),n.strip=()=>n.clone({...n._zod.def,catchall:void 0}),n.extend=r=>L.extend(n,r),n.safeExtend=r=>L.safeExtend(n,r),n.merge=r=>L.merge(n,r),n.pick=r=>L.pick(n,r),n.omit=r=>L.omit(n,r),n.partial=(...r)=>L.partial(Ta,n,r[0]),n.required=(...r)=>L.required(Pa,n,r[0])});function Gv(n,e){let r={type:"object",shape:n??{},...L.normalizeParams(e)};return new Ci(r)}function Jv(n,e){return new Ci({type:"object",shape:n,catchall:wa(),...L.normalizeParams(e)})}function qv(n,e){return new Ci({type:"object",shape:n,catchall:On(),...L.normalizeParams(e)})}var Li=S("ZodUnion",(n,e)=>{_i.init(n,e),ee.init(n,e),n._zod.processJSONSchema=(r,i,t)=>Vs(n,r,i,t),n.options=e.options});function ka(n,e){return new Li({type:"union",options:n,...L.normalizeParams(e)})}var sm=S("ZodXor",(n,e)=>{Li.init(n,e),Au.init(n,e),n._zod.processJSONSchema=(r,i,t)=>Vs(n,r,i,t),n.options=e.options});function Vv(n,e){return new sm({type:"union",options:n,inclusive:!1,...L.normalizeParams(e)})}var am=S("ZodDiscriminatedUnion",(n,e)=>{Li.init(n,e),Ou.init(n,e)});function Kv(n,e,r){return new am({type:"union",options:e,discriminator:n,...L.normalizeParams(r)})}var cm=S("ZodIntersection",(n,e)=>{Mu.init(n,e),ee.init(n,e),n._zod.processJSONSchema=(r,i,t)=>_p(n,r,i,t)});function lm(n,e){return new cm({type:"intersection",left:n,right:e})}var um=S("ZodTuple",(n,e)=>{gs.init(n,e),ee.init(n,e),n._zod.processJSONSchema=(r,i,t)=>xp(n,r,i,t),n.rest=r=>n.clone({...n._zod.def,rest:r})});function dm(n,e,r){let i=e instanceof Y,t=i?r:e,o=i?e:null;return new um({type:"tuple",items:n,rest:o,...L.normalizeParams(t)})}var Ai=S("ZodRecord",(n,e)=>{ju.init(n,e),ee.init(n,e),n._zod.processJSONSchema=(r,i,t)=>Sp(n,r,i,t),n.keyType=e.keyType,n.valueType=e.valueType});function pm(n,e,r){return new Ai({type:"record",keyType:n,valueType:e,...L.normalizeParams(r)})}function Yv(n,e,r){let i=Ce(n);return i._zod.values=void 0,new Ai({type:"record",keyType:i,valueType:e,...L.normalizeParams(r)})}function Xv(n,e,r){return new Ai({type:"record",keyType:n,valueType:e,mode:"loose",...L.normalizeParams(r)})}var mm=S("ZodMap",(n,e)=>{Uu.init(n,e),ee.init(n,e),n._zod.processJSONSchema=(r,i,t)=>gp(n,r,i,t),n.keyType=e.keyType,n.valueType=e.valueType,n.min=(...r)=>n.check($t(...r)),n.nonempty=r=>n.check($t(1,r)),n.max=(...r)=>n.check(sn(...r)),n.size=(...r)=>n.check(Cn(...r))});function Qv(n,e,r){return new mm({type:"map",keyType:n,valueType:e,...L.normalizeParams(r)})}var fm=S("ZodSet",(n,e)=>{Fu.init(n,e),ee.init(n,e),n._zod.processJSONSchema=(r,i,t)=>yp(n,r,i,t),n.min=(...r)=>n.check($t(...r)),n.nonempty=r=>n.check($t(1,r)),n.max=(...r)=>n.check(sn(...r)),n.size=(...r)=>n.check(Cn(...r))});function eb(n,e){return new fm({type:"set",valueType:n,...L.normalizeParams(e)})}var Tr=S("ZodEnum",(n,e)=>{Zu.init(n,e),ee.init(n,e),n._zod.processJSONSchema=(i,t,o)=>ap(n,i,t,o),n.enum=e.entries,n.options=Object.values(e.entries);let r=new Set(Object.keys(e.entries));n.extract=(i,t)=>{let o={};for(let s of i)if(r.has(s))o[s]=e.entries[s];else throw new Error(`Key ${s} not found in enum`);return new Tr({...e,checks:[],...L.normalizeParams(t),entries:o})},n.exclude=(i,t)=>{let o={...e.entries};for(let s of i)if(r.has(s))delete o[s];else throw new Error(`Key ${s} not found in enum`);return new Tr({...e,checks:[],...L.normalizeParams(t),entries:o})}});function Ea(n,e){let r=Array.isArray(n)?Object.fromEntries(n.map(i=>[i,i])):n;return new Tr({type:"enum",entries:r,...L.normalizeParams(e)})}function tb(n,e){return new Tr({type:"enum",entries:n,...L.normalizeParams(e)})}var hm=S("ZodLiteral",(n,e)=>{Hu.init(n,e),ee.init(n,e),n._zod.processJSONSchema=(r,i,t)=>cp(n,r,i,t),n.values=new Set(e.values),Object.defineProperty(n,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});function nb(n,e){return new hm({type:"literal",values:Array.isArray(n)?n:[n],...L.normalizeParams(e)})}var gm=S("ZodFile",(n,e)=>{Wu.init(n,e),ee.init(n,e),n._zod.processJSONSchema=(r,i,t)=>dp(n,r,i,t),n.min=(r,i)=>n.check($t(r,i)),n.max=(r,i)=>n.check(sn(r,i)),n.mime=(r,i)=>n.check(br(Array.isArray(r)?r:[r],i))});function rb(n){return Fd(gm,n)}var ym=S("ZodTransform",(n,e)=>{Bu.init(n,e),ee.init(n,e),n._zod.processJSONSchema=(r,i,t)=>hp(n,r,i,t),n._zod.parse=(r,i)=>{if(i.direction==="backward")throw new Qt(n.constructor.name);r.addIssue=o=>{if(typeof o=="string")r.issues.push(L.issue(o,r.value,e));else{let s=o;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=r.value),s.inst??(s.inst=n),r.issues.push(L.issue(s))}};let t=e.transform(r.value,r);return t instanceof Promise?t.then(o=>(r.value=o,r)):(r.value=t,r)}});function Ia(n){return new ym({type:"transform",transform:n})}var Ta=S("ZodOptional",(n,e)=>{ys.init(n,e),ee.init(n,e),n._zod.processJSONSchema=(r,i,t)=>Ks(n,r,i,t),n.unwrap=()=>n._zod.def.innerType});function Ti(n){return new Ta({type:"optional",innerType:n})}var vm=S("ZodExactOptional",(n,e)=>{Gu.init(n,e),ee.init(n,e),n._zod.processJSONSchema=(r,i,t)=>Ks(n,r,i,t),n.unwrap=()=>n._zod.def.innerType});function bm(n){return new vm({type:"optional",innerType:n})}var _m=S("ZodNullable",(n,e)=>{Ju.init(n,e),ee.init(n,e),n._zod.processJSONSchema=(r,i,t)=>$p(n,r,i,t),n.unwrap=()=>n._zod.def.innerType});function Pi(n){return new _m({type:"nullable",innerType:n})}function ib(n){return Ti(Pi(n))}var xm=S("ZodDefault",(n,e)=>{qu.init(n,e),ee.init(n,e),n._zod.processJSONSchema=(r,i,t)=>kp(n,r,i,t),n.unwrap=()=>n._zod.def.innerType,n.removeDefault=n.unwrap});function Sm(n,e){return new xm({type:"default",innerType:n,get defaultValue(){return typeof e=="function"?e():L.shallowClone(e)}})}var $m=S("ZodPrefault",(n,e)=>{Vu.init(n,e),ee.init(n,e),n._zod.processJSONSchema=(r,i,t)=>Ep(n,r,i,t),n.unwrap=()=>n._zod.def.innerType});function wm(n,e){return new $m({type:"prefault",innerType:n,get defaultValue(){return typeof e=="function"?e():L.shallowClone(e)}})}var Pa=S("ZodNonOptional",(n,e)=>{Ku.init(n,e),ee.init(n,e),n._zod.processJSONSchema=(r,i,t)=>wp(n,r,i,t),n.unwrap=()=>n._zod.def.innerType});function km(n,e){return new Pa({type:"nonoptional",innerType:n,...L.normalizeParams(e)})}var Em=S("ZodSuccess",(n,e)=>{Yu.init(n,e),ee.init(n,e),n._zod.processJSONSchema=(r,i,t)=>pp(n,r,i,t),n.unwrap=()=>n._zod.def.innerType});function ob(n){return new Em({type:"success",innerType:n})}var Im=S("ZodCatch",(n,e)=>{Xu.init(n,e),ee.init(n,e),n._zod.processJSONSchema=(r,i,t)=>Ip(n,r,i,t),n.unwrap=()=>n._zod.def.innerType,n.removeCatch=n.unwrap});function Tm(n,e){return new Im({type:"catch",innerType:n,catchValue:typeof e=="function"?e:()=>e})}var Pm=S("ZodNaN",(n,e)=>{Qu.init(n,e),ee.init(n,e),n._zod.processJSONSchema=(r,i,t)=>lp(n,r,i,t)});function sb(n){return jd(Pm,n)}var Ra=S("ZodPipe",(n,e)=>{ed.init(n,e),ee.init(n,e),n._zod.processJSONSchema=(r,i,t)=>Tp(n,r,i,t),n.in=e.in,n.out=e.out});function Ri(n,e){return new Ra({type:"pipe",in:n,out:e})}var Na=S("ZodCodec",(n,e)=>{Ra.init(n,e),xi.init(n,e)});function ab(n,e,r){return new Na({type:"pipe",in:n,out:e,transform:r.decode,reverseTransform:r.encode})}var Rm=S("ZodReadonly",(n,e)=>{td.init(n,e),ee.init(n,e),n._zod.processJSONSchema=(r,i,t)=>Pp(n,r,i,t),n.unwrap=()=>n._zod.def.innerType});function Nm(n){return new Rm({type:"readonly",innerType:n})}var zm=S("ZodTemplateLiteral",(n,e)=>{nd.init(n,e),ee.init(n,e),n._zod.processJSONSchema=(r,i,t)=>up(n,r,i,t)});function cb(n,e){return new zm({type:"template_literal",parts:n,...L.normalizeParams(e)})}var Dm=S("ZodLazy",(n,e)=>{od.init(n,e),ee.init(n,e),n._zod.processJSONSchema=(r,i,t)=>Np(n,r,i,t),n.unwrap=()=>n._zod.def.getter()});function Cm(n){return new Dm({type:"lazy",getter:n})}var Lm=S("ZodPromise",(n,e)=>{id.init(n,e),ee.init(n,e),n._zod.processJSONSchema=(r,i,t)=>Rp(n,r,i,t),n.unwrap=()=>n._zod.def.innerType});function lb(n){return new Lm({type:"promise",innerType:n})}var Am=S("ZodFunction",(n,e)=>{rd.init(n,e),ee.init(n,e),n._zod.processJSONSchema=(r,i,t)=>fp(n,r,i,t)});function ub(n){return new Am({type:"function",input:Array.isArray(n?.input)?dm(n?.input):n?.input??Di(On()),output:n?.output??On()})}var Oi=S("ZodCustom",(n,e)=>{sd.init(n,e),ee.init(n,e),n._zod.processJSONSchema=(r,i,t)=>mp(n,r,i,t)});function db(n){let e=new ue({check:"custom"});return e._zod.check=n,e}function pb(n,e){return Zd(Oi,n??(()=>!0),e)}function Om(n,e={}){return Hd(Oi,n,e)}function Mm(n){return Wd(n)}var mb=Bd,fb=Gd;function hb(n,e={}){let r=new Oi({type:"custom",check:"custom",fn:i=>i instanceof n,abort:!0,...L.normalizeParams(e)});return r._zod.bag.Class=n,r._zod.check=i=>{i.value instanceof n||i.issues.push({code:"invalid_type",expected:n.name,input:i.value,inst:r,path:[...r._zod.def.path??[]]})},r}var gb=(...n)=>Jd({Codec:Na,Boolean:zr,String:Pr},...n);function yb(n){let e=Cm(()=>ka([ia(n),Vp(),Kp(),em(),Di(e),pm(ia(),e)]));return e}function vb(n,e){return Ri(Ia(n),e)}var ak={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};function ck(n){_e({customError:n})}function lk(){return _e().customError}var jm;jm||(jm={});var j={...Ei,...Qs,iso:Ir},uk=new Set(["$schema","$ref","$defs","definitions","$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor","type","enum","const","anyOf","oneOf","allOf","not","properties","required","additionalProperties","patternProperties","propertyNames","minProperties","maxProperties","items","prefixItems","additionalItems","minItems","maxItems","uniqueItems","contains","minContains","maxContains","minLength","maxLength","pattern","format","minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","description","default","contentEncoding","contentMediaType","contentSchema","unevaluatedItems","unevaluatedProperties","if","then","else","dependentSchemas","dependentRequired","nullable","readOnly"]);function dk(n,e){let r=n.$schema;return r==="https://json-schema.org/draft/2020-12/schema"?"draft-2020-12":r==="http://json-schema.org/draft-07/schema#"?"draft-7":r==="http://json-schema.org/draft-04/schema#"?"draft-4":e??"draft-2020-12"}function pk(n,e){if(!n.startsWith("#"))throw new Error("External $ref is not supported, only local refs (#/...) are allowed");let r=n.slice(1).split("/").filter(Boolean);if(r.length===0)return e.rootSchema;let i=e.version==="draft-2020-12"?"$defs":"definitions";if(r[0]===i){let t=r[1];if(!t||!e.defs[t])throw new Error(`Reference not found: ${n}`);return e.defs[t]}throw new Error(`Reference not found: ${n}`)}function bb(n,e){if(n.not!==void 0){if(typeof n.not=="object"&&Object.keys(n.not).length===0)return j.never();throw new Error("not is not supported in Zod (except { not: {} } for never)")}if(n.unevaluatedItems!==void 0)throw new Error("unevaluatedItems is not supported");if(n.unevaluatedProperties!==void 0)throw new Error("unevaluatedProperties is not supported");if(n.if!==void 0||n.then!==void 0||n.else!==void 0)throw new Error("Conditional schemas (if/then/else) are not supported");if(n.dependentSchemas!==void 0||n.dependentRequired!==void 0)throw new Error("dependentSchemas and dependentRequired are not supported");if(n.$ref){let t=n.$ref;if(e.refs.has(t))return e.refs.get(t);if(e.processing.has(t))return j.lazy(()=>{if(!e.refs.has(t))throw new Error(`Circular reference not resolved: ${t}`);return e.refs.get(t)});e.processing.add(t);let o=pk(t,e),s=ze(o,e);return e.refs.set(t,s),e.processing.delete(t),s}if(n.enum!==void 0){let t=n.enum;if(e.version==="openapi-3.0"&&n.nullable===!0&&t.length===1&&t[0]===null)return j.null();if(t.length===0)return j.never();if(t.length===1)return j.literal(t[0]);if(t.every(s=>typeof s=="string"))return j.enum(t);let o=t.map(s=>j.literal(s));return o.length<2?o[0]:j.union([o[0],o[1],...o.slice(2)])}if(n.const!==void 0)return j.literal(n.const);let r=n.type;if(Array.isArray(r)){let t=r.map(o=>{let s={...n,type:o};return bb(s,e)});return t.length===0?j.never():t.length===1?t[0]:j.union(t)}if(!r)return j.any();let i;switch(r){case"string":{let t=j.string();if(n.format){let o=n.format;o==="email"?t=t.check(j.email()):o==="uri"||o==="uri-reference"?t=t.check(j.url()):o==="uuid"||o==="guid"?t=t.check(j.uuid()):o==="date-time"?t=t.check(j.iso.datetime()):o==="date"?t=t.check(j.iso.date()):o==="time"?t=t.check(j.iso.time()):o==="duration"?t=t.check(j.iso.duration()):o==="ipv4"?t=t.check(j.ipv4()):o==="ipv6"?t=t.check(j.ipv6()):o==="mac"?t=t.check(j.mac()):o==="cidr"?t=t.check(j.cidrv4()):o==="cidr-v6"?t=t.check(j.cidrv6()):o==="base64"?t=t.check(j.base64()):o==="base64url"?t=t.check(j.base64url()):o==="e164"?t=t.check(j.e164()):o==="jwt"?t=t.check(j.jwt()):o==="emoji"?t=t.check(j.emoji()):o==="nanoid"?t=t.check(j.nanoid()):o==="cuid"?t=t.check(j.cuid()):o==="cuid2"?t=t.check(j.cuid2()):o==="ulid"?t=t.check(j.ulid()):o==="xid"?t=t.check(j.xid()):o==="ksuid"&&(t=t.check(j.ksuid()))}typeof n.minLength=="number"&&(t=t.min(n.minLength)),typeof n.maxLength=="number"&&(t=t.max(n.maxLength)),n.pattern&&(t=t.regex(new RegExp(n.pattern))),i=t;break}case"number":case"integer":{let t=r==="integer"?j.number().int():j.number();typeof n.minimum=="number"&&(t=t.min(n.minimum)),typeof n.maximum=="number"&&(t=t.max(n.maximum)),typeof n.exclusiveMinimum=="number"?t=t.gt(n.exclusiveMinimum):n.exclusiveMinimum===!0&&typeof n.minimum=="number"&&(t=t.gt(n.minimum)),typeof n.exclusiveMaximum=="number"?t=t.lt(n.exclusiveMaximum):n.exclusiveMaximum===!0&&typeof n.maximum=="number"&&(t=t.lt(n.maximum)),typeof n.multipleOf=="number"&&(t=t.multipleOf(n.multipleOf)),i=t;break}case"boolean":{i=j.boolean();break}case"null":{i=j.null();break}case"object":{let t={},o=n.properties||{},s=new Set(n.required||[]);for(let[c,l]of Object.entries(o)){let u=ze(l,e);t[c]=s.has(c)?u:u.optional()}if(n.propertyNames){let c=ze(n.propertyNames,e),l=n.additionalProperties&&typeof n.additionalProperties=="object"?ze(n.additionalProperties,e):j.any();if(Object.keys(t).length===0){i=j.record(c,l);break}let u=j.object(t).passthrough(),d=j.looseRecord(c,l);i=j.intersection(u,d);break}if(n.patternProperties){let c=n.patternProperties,l=Object.keys(c),u=[];for(let p of l){let m=ze(c[p],e),f=j.string().regex(new RegExp(p));u.push(j.looseRecord(f,m))}let d=[];if(Object.keys(t).length>0&&d.push(j.object(t).passthrough()),d.push(...u),d.length===0)i=j.object({}).passthrough();else if(d.length===1)i=d[0];else{let p=j.intersection(d[0],d[1]);for(let m=2;m<d.length;m++)p=j.intersection(p,d[m]);i=p}break}let a=j.object(t);n.additionalProperties===!1?i=a.strict():typeof n.additionalProperties=="object"?i=a.catchall(ze(n.additionalProperties,e)):i=a.passthrough();break}case"array":{let t=n.prefixItems,o=n.items;if(t&&Array.isArray(t)){let s=t.map(c=>ze(c,e)),a=o&&typeof o=="object"&&!Array.isArray(o)?ze(o,e):void 0;a?i=j.tuple(s).rest(a):i=j.tuple(s),typeof n.minItems=="number"&&(i=i.check(j.minLength(n.minItems))),typeof n.maxItems=="number"&&(i=i.check(j.maxLength(n.maxItems)))}else if(Array.isArray(o)){let s=o.map(c=>ze(c,e)),a=n.additionalItems&&typeof n.additionalItems=="object"?ze(n.additionalItems,e):void 0;a?i=j.tuple(s).rest(a):i=j.tuple(s),typeof n.minItems=="number"&&(i=i.check(j.minLength(n.minItems))),typeof n.maxItems=="number"&&(i=i.check(j.maxLength(n.maxItems)))}else if(o!==void 0){let s=ze(o,e),a=j.array(s);typeof n.minItems=="number"&&(a=a.min(n.minItems)),typeof n.maxItems=="number"&&(a=a.max(n.maxItems)),i=a}else i=j.array(j.any());break}default:throw new Error(`Unsupported type: ${r}`)}return n.description&&(i=i.describe(n.description)),n.default!==void 0&&(i=i.default(n.default)),i}function ze(n,e){if(typeof n=="boolean")return n?j.any():j.never();let r=bb(n,e),i=n.type||n.enum!==void 0||n.const!==void 0;if(n.anyOf&&Array.isArray(n.anyOf)){let a=n.anyOf.map(l=>ze(l,e)),c=j.union(a);r=i?j.intersection(r,c):c}if(n.oneOf&&Array.isArray(n.oneOf)){let a=n.oneOf.map(l=>ze(l,e)),c=j.xor(a);r=i?j.intersection(r,c):c}if(n.allOf&&Array.isArray(n.allOf))if(n.allOf.length===0)r=i?r:j.any();else{let a=i?r:ze(n.allOf[0],e),c=i?0:1;for(let l=c;l<n.allOf.length;l++)a=j.intersection(a,ze(n.allOf[l],e));r=a}n.nullable===!0&&e.version==="openapi-3.0"&&(r=j.nullable(r)),n.readOnly===!0&&(r=j.readonly(r));let t={},o=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let a of o)a in n&&(t[a]=n[a]);let s=["contentEncoding","contentMediaType","contentSchema"];for(let a of s)a in n&&(t[a]=n[a]);for(let a of Object.keys(n))uk.has(a)||(t[a]=n[a]);return Object.keys(t).length>0&&e.registry.add(r,t),r}function _b(n,e){if(typeof n=="boolean")return n?j.any():j.never();let r=dk(n,e?.defaultTarget),i=n.$defs||n.definitions||{},t={version:r,defs:i,refs:new Map,processing:new Set,rootSchema:n,registry:e?.registry??Re};return ze(n,t)}var Um={};Ke(Um,{bigint:()=>gk,boolean:()=>hk,date:()=>yk,number:()=>fk,string:()=>mk});function mk(n){return ud(Pr,n)}function fk(n){return vd(Nr,n)}function hk(n){return kd(zr,n)}function gk(n){return Id(Dr,n)}function yk(n){return Md(zi,n)}_e(vs());var hC=g.object({repoPath:g.string(),mode:g.enum(["init","tree","topography","scout","hologram","tools"]),subPath:g.string().optional(),maxDepth:g.number().int().min(ke.MIN_DEPTH).max(ke.MAX_DEPTH).optional()}),gC=g.object({repoPath:g.string(),mode:g.enum(["symbol","concept","symbol-fuzzy","config","path"]).default("symbol"),query:g.string().max(ke.MAX_QUERY_LENGTH).optional(),key:g.string().optional(),kind:g.enum(["Service","Image","Port","Env"]).optional(),limit:g.number().int().min(ke.MIN_LIMIT).max(ke.MAX_LIMIT).optional(),offset:g.number().int().min(0).optional(),compact:g.boolean().optional()}).refine(n=>!(n.mode==="concept"&&(!n.query||n.query.trim().length===0)),{message:"Concept search requires a non-empty query",path:["query"]}),yC=g.object({repoPath:g.string(),mode:g.enum(["symbol","file"]),filePath:g.string().optional(),detailLevel:g.enum(["structure","signatures","summaries","detailed"]).optional(),symbolName:g.string().optional(),context:g.enum(["definition","full"]).optional()}),vC=g.object({repoPath:g.string(),mode:g.enum(["impact","deps","flow","dead-code","circular-deps"]),filePath:g.string().optional(),symbolName:g.string().optional(),direction:g.enum(["imports","imported_by"]).optional(),depth:g.number().int().min(ke.MIN_DEPTH).max(ke.MAX_DEPTH).optional(),limit:g.number().int().min(ke.MIN_LIMIT).max(ke.MAX_LIMIT).optional(),includeTests:g.boolean().optional()}),bC=g.object({repoPath:g.string(),action:g.enum(["index","repair","trace"]),deep:g.boolean().optional(),sinceCommit:g.string().optional()}),_C=g.object({repoPath:g.string(),action:g.enum(["install","remove","status"]),enableAutoRefresh:g.boolean().optional(),enableSymbolHealing:g.boolean().optional()}),xC=g.object({action:g.enum(["list","link","fuse"]),repoPaths:g.array(g.string()).optional(),name:g.string().optional(),status:g.string().optional(),parentRepoPath:g.string().optional(),parentMissionId:g.number().optional(),childRepoPath:g.string().optional(),childMissionId:g.number().optional(),relationship:g.string().optional()});var vk=[...Rg,...Ng];G();G();var bk=x.child({module:"strategy-normalizer"}),Mt=class{static normalize(e){if(!e)return{steps:[]};let r;if(typeof e=="string")try{r=JSON.parse(e)}catch(t){return bk.warn({strategyInput:e,err:t},"Failed to parse strategy JSON"),{steps:[]}}else r=e;return{steps:this.normalizeSteps(r)}}static normalizeSteps(e){return Array.isArray(e)?e.map((r,i)=>typeof r=="string"?{id:`step-${i}`,description:r,status:"pending"}:typeof r=="object"&&r!==null?{id:r.id||`step-${i}`,description:r.description||r.content||r.name||`Step ${i+1}`,status:r.status||"pending",dependencies:r.dependencies||r.deps,verification:r.verification,...r}:{id:`step-${i}`,description:String(r),status:"pending"}):e.steps&&Array.isArray(e.steps)?this.normalizeSteps(e.steps):typeof e=="object"?Object.entries(e).map(([r,i],t)=>typeof i=="string"?{id:r,description:i,status:"pending"}:typeof i=="object"&&i!==null?{id:r,description:i.description||i.content||i.name||r,status:i.status||"pending",dependencies:i.dependencies||i.deps,verification:i.verification,...i}:{id:r||`step-${t}`,description:String(i),status:"pending"}):[]}static stringify(e){return JSON.stringify(e,null,2)}static validate(e){let r=[];if(!e)return{valid:!0,errors:[]};try{let i=this.normalize(e),t=new Set;for(let o of i.steps)if(t.has(o.id)&&r.push(`Duplicate step ID: ${o.id}`),t.add(o.id),o.dependencies)for(let s of o.dependencies)t.has(s)||r.push(`Step "${o.id}" depends on non-existent step "${s}"`);return{valid:r.length===0,errors:r}}catch(i){return r.push(`Strategy validation failed: ${i instanceof Error?i.message:String(i)}`),{valid:!1,errors:r}}}};G();import Fm from"fs";import xb from"path";import _k from"os";var xk=[{id:"step-0",description:"Analyze impact: identify dependents and call sites",status:"pending"},{id:"step-1",description:"Implement refactor and update call sites",status:"pending"},{id:"step-2",description:"Run tests and verify behavior; update docs if needed",status:"pending"}],Sk=[{id:"step-0",description:"Capture requirements and acceptance criteria",status:"pending"},{id:"step-1",description:"Implement feature with tests",status:"pending"},{id:"step-2",description:"Integrate and verify end-to-end",status:"pending"}],$k=[{id:"step-0",description:"Reproduce the bug and document steps",status:"pending"},{id:"step-1",description:"Diagnose root cause and plan fix",status:"pending"},{id:"step-2",description:"Apply fix and add/update regression test",status:"pending"},{id:"step-3",description:"Verify fix and run full test suite",status:"pending"}],Sb=[{id:"refactoring",name:"Refactoring",description:"Impact analysis \u2192 implementation \u2192 verification",defaultGoal:"Refactor {{target}} safely with full impact analysis and verification.",steps:xk},{id:"feature",name:"Feature",description:"Requirements \u2192 implementation \u2192 testing",defaultGoal:"Implement {{target}} with clear requirements and end-to-end verification.",steps:Sk},{id:"bug-fix",name:"Bug fix",description:"Reproduction \u2192 diagnosis \u2192 fix \u2192 regression test",defaultGoal:"Fix {{target}}: reproduce, diagnose, fix, and add regression test.",steps:$k}],Zm=new Map(Sb.map(n=>[n.id,n])),za=!1;function wk(){if(za)return;let n=xb.join(_k.homedir(),".shadow","templates");if(!Fm.existsSync(n)){x.debug({templatesDir:n},"Custom templates directory does not exist"),za=!0;return}try{let e=Fm.readdirSync(n).filter(r=>r.endsWith(".json"));for(let r of e)try{let i=xb.join(n,r),t=Fm.readFileSync(i,"utf8"),o=JSON.parse(t);if(!o.id||!o.name||!o.defaultGoal||!o.steps){x.warn({file:r,template:o},"Invalid custom template structure - skipping");continue}if(!Array.isArray(o.steps)||o.steps.length===0){x.warn({file:r},"Template has no steps - skipping");continue}if(Sb.some(s=>s.id===o.id)){x.warn({file:r,templateId:o.id},"Custom template ID conflicts with built-in - skipping");continue}Zm.set(o.id,o),x.info({file:r,templateId:o.id},"Loaded custom template")}catch(i){x.warn({file:r,error:i},"Failed to load custom template")}za=!0}catch(e){x.warn({error:e,templatesDir:n},"Failed to read custom templates directory"),za=!0}}function $b(n){return wk(),Zm.get(n)}function kk(n,e){let r=n;for(let[i,t]of Object.entries(e))r=r.replace(new RegExp(`\\{\\{${i}\\}\\}`,"g"),t);return r}function Hm(n,e,r={}){let i=$b(n);if(!i)throw new Error(`Unknown template: ${n}. Use one of: ${Array.from(Zm.keys()).join(", ")}`);let t=r.target||"scope",o=e||(n==="refactoring"?`Refactor ${t}`:n==="feature"?`Feature: ${t}`:`Fix: ${t}`),s=kk(i.defaultGoal,{...r,target:t}),a=Mt.normalize({steps:i.steps}),c=Mt.stringify(a);return{name:o,goal:s,strategy:c}}X();X();import{execSync as Cr}from"child_process";var Mi=class{constructor(e,r="refs/notes/shadow"){this.repoPath=e;this.ref=r}addNote(e,r){try{Cr(`git notes --ref ${this.ref} add -f -m '${r.replace(/'/g,"'\\''")}' ${e}`,{cwd:this.repoPath,stdio:["ignore","pipe","ignore"],encoding:"utf8"})}catch(i){throw new Error(`Failed to add git note to ${e}: ${i.message}`)}}getNote(e){try{return Cr(`git notes --ref ${this.ref} show ${e}`,{cwd:this.repoPath,stdio:["ignore","pipe","ignore"],encoding:"utf8"}).trim()}catch{return null}}listNotes(){let e=new Map;try{let r=Cr(`git notes --ref ${this.ref} list`,{cwd:this.repoPath,stdio:["ignore","pipe","ignore"],encoding:"utf8"}).trim();if(!r)return e;let i=r.split(`
767
+ `);for(let t of i){let[o,s]=t.split(" ");if(s){let a=this.getNote(s);a&&e.set(s,a)}}}catch{}return e}removeNote(e){try{Cr(`git notes --ref ${this.ref} remove ${e}`,{cwd:this.repoPath,stdio:["ignore","pipe","ignore"],encoding:"utf8"})}catch{}}push(e="origin"){try{Cr(`git push ${e} ${this.ref}`,{cwd:this.repoPath,stdio:["ignore","pipe","ignore"],encoding:"utf8"})}catch(r){throw new Error(`Failed to push git notes to ${e}: ${r.message}`)}}fetch(e="origin"){try{Cr(`git fetch ${e} ${this.ref}:${this.ref}`,{cwd:this.repoPath,stdio:["ignore","pipe","ignore"],encoding:"utf8"})}catch{}}};G();var Lr=x.child({module:"persistence-service"}),rt=class{gitNotes;repoPath;constructor(e){this.repoPath=e,this.gitNotes=new Mi(e)}async syncMissionToGitNotes(e){let{missions:r,intentLogs:i}=z.getInstance(this.repoPath),t=r.findById(e);if(!t)throw new Error(`Mission ${e} not found`);if(!t.commit_sha){Lr.warn({missionId:e},"Cannot sync mission without commit_sha");return}Lr.info({missionId:e,commitSha:t.commit_sha},"Syncing mission to Git Notes");let o=r.getArtifacts(e),s=i.findByMission(e,1e3),a=s.find(u=>u.type==="adr"),c=s.filter(u=>u.type==="decision").map(u=>({content:u.content,symbol_name:u.symbol_name,created_at:u.created_at})),l={version:"1.0",mission:{name:t.name,goal:t.goal,status:t.status,strategy_graph:t.strategy_graph,git_branch:t.git_branch,commit_sha:t.commit_sha,parent_id:t.parent_id,verification_context:t.verification_context,outcome_contract:t.outcome_contract,created_at:t.created_at,updated_at:t.updated_at},artifacts:o,adr:a?a.content:null,decisions:c};this.gitNotes.addNote(t.commit_sha,JSON.stringify(l,null,2))}async syncAllToGitNotes(){let{missions:e}=z.getInstance(this.repoPath),r=e.findActive(),i=e.findRecentCompleted(10),t=[...r,...i];for(let o of t)try{await this.syncMissionToGitNotes(o.id)}catch(s){Lr.error({missionId:o.id,error:s},"Failed to sync mission")}}async recoverFromGitNotes(){let e=this.gitNotes.listNotes(),{missions:r,intentLogs:i}=z.getInstance(this.repoPath),t=0,o=0;for(let[s,a]of e.entries())try{let c=JSON.parse(a);if(c.version!=="1.0")continue;if(r.findByCommitShas([s]).some(p=>p.name===c.mission.name)){Lr.debug({commitSha:s,missionName:c.mission.name},"Mission already exists, skipping recovery");continue}let d=r.create({name:c.mission.name,goal:c.mission.goal,status:c.mission.status,strategy_graph:c.mission.strategy_graph,git_branch:c.mission.git_branch,commit_sha:s,parent_id:c.mission.parent_id,verification_context:c.mission.verification_context,outcome_contract:c.mission.outcome_contract});if(t++,c.adr&&(i.create({mission_id:Number(d),symbol_id:null,file_path:null,type:"adr",content:c.adr,confidence:1,symbol_name:null,signature:null,commit_sha:s}),o++),c.decisions&&c.decisions.length>0)for(let p of c.decisions)i.create({mission_id:Number(d),symbol_id:null,file_path:null,type:"decision",content:p.content,confidence:1,symbol_name:p.symbol_name,signature:null,commit_sha:s}),o++;Lr.info({commitSha:s,missionName:c.mission.name,logsRecovered:o},"Re-hydrated mission from Git Notes")}catch(c){Lr.error({commitSha:s,error:c},"Failed to parse Git Note for recovery")}return{missionsRecovered:t,logsRecovered:o}}};var Da=x.child({module:"mcp:tools:ops:plan"});async function Ca(n){let{repoPath:e,name:r,goal:i,strategy:t,missionId:o,parentId:s,outcomeContract:a,templateId:c,templateVars:l}=n,{missions:u}=z.getInstance(e),d=Ee(e),p=Qe(e);Da.info({repoPath:e,name:r,missionId:o,templateId:c},"Planning mission");try{let m=r,f=i,h=t;if(c){let k=Hm(c,r,l||{});m=m??k.name,f=f??k.goal,h=h??k.strategy}if(!m||!f)throw new Error("Mission requires name and goal (or templateId with optional templateVars).");let _=null;if(h){let k=Mt.normalize(h);_=Mt.stringify(k);let $=Mt.validate(_);$.valid||Da.warn({errors:$.errors,strategy:h},"Strategy validation warnings detected")}let v,y;o?(u.update(o,{name:m,goal:f,strategy_graph:_,commit_sha:p,parent_id:s!==void 0?s:void 0,outcome_contract:a}),v=o,y=`Mission "${m}" updated.`):(v=u.create({name:m,goal:f,strategy_graph:_,status:"planned",git_branch:d,commit_sha:p,parent_id:s||null,verification_context:null,outcome_contract:a||null}),y=`Mission "${m}" planned.`);try{await new rt(e).syncMissionToGitNotes(Number(v))}catch(k){Da.warn({syncError:k,missionId:v},"Git Notes sync deferred")}return{content:[{type:"text",text:JSON.stringify({missionId:v,status:"planned",message:y,strategy_saved:!!h,contract_saved:!!a,from_template:c??void 0,commit:p},null,2)}]}}catch(m){throw Da.error({error:m,repoPath:e},"Failed to plan mission"),new Error(`Failed to plan mission: ${m instanceof Error?m.message:String(m)}`)}}G();X();X();G();G();var Ek=x.child({module:"reasoning-engine"}),jn=class{analyze(e){Ek.debug({logCount:e.length},"Performing reasoning pass over intent logs");let r={context:[],decisions:[],consequences:[],recommendations:[],unclassified:[]};for(let i of e){let t=i.content.toLowerCase(),o=this.matchesContext(t,i.type),s=this.matchesDecision(t,i.type),a=this.matchesConsequence(t,i.type),c=this.matchesRecommendation(t,i.type);o?r.context.push(i.content):s?r.decisions.push(i.content):c?r.recommendations.push(i.content):a?r.consequences.push(i.content):i.type==="decision"?r.decisions.push(i.content):i.type==="discovery"||i.type==="fix"?r.consequences.push(i.content):r.unclassified.push(i.content)}return r}matchesContext(e,r){return["because","since","given","due to","context: ","problem: ","situation:"].some(t=>e.includes(t))||r==="blocker"}matchesDecision(e,r){return["decided","chose","implemented","integrated","using","selected","strategy:"].some(t=>e.includes(t))||r==="decision"}matchesConsequence(e,r){return["results in","enables","allows","impact: ","consequence: ","next steps: ","meaning"].some(t=>e.includes(t))||r==="fix"}matchesRecommendation(e,r){return["should","recommend","suggest","next work","future","consider","strategy advice"].some(t=>e.includes(t))}};var La=x.child({module:"briefing-engine"}),kt=class{intentLogs;missions;reasoningEngine;persistencePivot;constructor(e){let{intentLogs:r,missions:i}=z.getInstance(e);this.intentLogs=r,this.missions=i,this.reasoningEngine=new jn,this.persistencePivot=new rt(e)}async distillMission(e,r=!0){La.info({missionId:e},"Synthesizing mission intelligence into Tactical Briefing...");let i=this.gatherConsolidatedLogs(e);if(i.length===0)return{missionId:e,adr:"No intent logs found for this mission.",metrics:{totalLogs:0,symbolCount:0}};let t=this.reasoningEngine.analyze(i),o=new Set(i.map(a=>a.symbol_name).filter(Boolean)),s=`# Architectural Decision Record: Mission #${e}
768
+
769
+ `;if(s+=`## Summary of Intent
770
+ `,s+=`Collected ${i.length} intent events across ${o.size} symbols.
771
+
772
+ `,t.context.length>0&&(s+=`### Context
773
+ `,t.context.forEach(a=>{s+=`- ${a}
774
+ `}),s+=`
775
+ `),t.decisions.length>0&&(s+=`### Key Decisions
776
+ `,t.decisions.forEach(a=>{s+=`- ${a}
777
+ `}),s+=`
778
+ `),t.consequences.length>0&&(s+=`### Consequences & Evolutions
779
+ `,t.consequences.forEach(a=>{s+=`- ${a}
780
+ `}),s+=`
781
+ `),t.recommendations.length>0&&(s+=`### Strategic Recommendations
782
+ `,t.recommendations.forEach(a=>{s+=`- ${a}
783
+ `}),s+=`
784
+ `),t.unclassified.length>0&&(s+=`### Additional Notes
785
+ `,t.unclassified.forEach(a=>{s+=`- ${a}
786
+ `}),s+=`
787
+ `),s+=`
812
788
  ---
813
- *Generated by Liquid Shadow Reasoning Engine v1*`,t){this.intentLogs.create({mission_id:e,type:"adr",content:o,confidence:1,symbol_id:null,file_path:null,symbol_name:null,signature:null,commit_sha:null});try{await this.persistencePivot.syncMissionToGitNotes(e),zn.info({missionId:e},"Tactical Briefing synthesized, archived, and synced to Git Notes.")}catch(c){zn.error({missionId:e,error:c},"Failed to sync ADR to Git Notes")}}else zn.info({missionId:e},"Tactical Briefing synthesized (dry-run).");return{missionId:e,adr:o,metrics:{totalLogs:n.length,symbolCount:r.size}}}gatherConsolidatedLogs(e,t=0){let n=this.intentLogs.findByMission(e,500);if(t>2)return n;let s=this.missions.findByParentId(e);for(let r of s)n.push(...this.gatherConsolidatedLogs(r.id,t+1));return n.filter(r=>r.type!=="adr"&&r.type!=="system")}};P();import{Visitor as sl}from"@swc/core/Visitor.js";import*as To from"@swc/core";var il=_.child({module:"verification-engine"}),Ms=class extends sl{foundUsage=!1;foundImport=!1;rule;currentFunctionName=null;constructor(e){super(),this.rule=e}visitImportDeclaration(e){return this.rule.type==="import"&&e.source.value===this.rule.target&&(this.foundImport=!0),super.visitImportDeclaration(e)}visitFunctionDeclaration(e){let t=this.currentFunctionName;this.currentFunctionName=e.identifier.value;let n=super.visitFunctionDeclaration(e);return this.currentFunctionName=t,n}visitCallExpression(e){return this.rule.type==="usage"&&e.callee.type==="Identifier"&&e.callee.value===this.rule.target&&(!this.rule.context||this.currentFunctionName===this.rule.context)&&(this.foundUsage=!0),super.visitCallExpression(e)}},Gn=class{async verify(e,t){try{let n=await To.parse(e,{syntax:"typescript",tsx:!0,comments:!1}),s=new Ms(t);s.visitProgram(n);let r=!1,o=[];if(t.type==="import")r=s.foundImport,r||o.push(`Required import "${t.target}" not found.`);else if(t.type==="usage"){if(r=s.foundUsage,!r){let c=t.context?` in function "${t.context}"`:"";o.push(`Required usage of "${t.target}"${c} not found.`)}}else t.type==="pattern"&&(r=new RegExp(t.target).test(e),r||o.push(`Required pattern "${t.target}" not found.`));return{passed:r,errors:o}}catch(n){return il.error({error:n},"Verification failed due to parse error"),{passed:!1,errors:[`Parse error: ${n.message}`]}}}};import Ro from"path";import qn from"fs";var bt=_.child({module:"mcp:tools:ops:track"});async function vo(i){let{repoPath:e,missionId:t,stepId:n,status:s,contextPivot:r,updates:o,artifacts:c}=i,{missions:a,intentLogs:l}=C.getInstance(e),p=fe(e);bt.info({repoPath:e,missionId:t,singleStep:n,batchCount:o?.length,artifactCount:c?.length},"Updating mission status");try{if(c&&Array.isArray(c))for(let m of c)a.addArtifact(t,m.type,m.identifier,m.metadata);let d=[];if(o&&Array.isArray(o)&&d.push(...o),n&&s&&d.push({stepId:n,status:s,contextPivot:r}),s&&!n){if(a.updateStatus(t,s,p||void 0),l.create({mission_id:t,type:"system",content:`Mission status changed to "${s}"`,confidence:1,symbol_id:null,file_path:null,symbol_name:null,signature:null,commit_sha:p}),s==="completed")try{await new Ge(e).distillMission(t),bt.info({missionId:t},"Auto-Synthesis completed successfully")}catch(m){bt.warn({synthesisError:m,missionId:t},"Auto-Synthesis deferred or failed")}if(!d.length)return{content:[{type:"text",text:JSON.stringify({missionId:t,status:s,message:"Mission status updated successfully.",artifacts_added:c?.length||0,commit:p},null,2)}]}}if(d.length===0&&(!c||c.length===0))throw new Error("No updates provided. Must specify either 'updates', 'stepId'/'status', 'status' (top-level), or 'artifacts'.");let u=[];for(let m of d){let{stepId:f,status:h,contextPivot:b}=m,y=a.findById(t);if(!y)throw new Error(`Mission ID ${t} not found`);let g=JSON.parse(y.strategy_graph||"{}"),S=null;if(Array.isArray(g)?S=g.find(R=>R.id===f):g.nodes&&Array.isArray(g.nodes)?S=g.nodes.find(R=>R.id===f):g.steps?Array.isArray(g.steps)?S=g.steps.find(R=>R.id===f):S=g.steps[f]:g[f]&&(S=g[f]),!S)throw new Error(`Step ID "${f}" not found`);if(h==="completed"&&S.verification){let R=new Gn,w=Array.isArray(S.verification)?S.verification:[S.verification];for(let T of w){let v=T.filePath;if(v&&!Ro.isAbsolute(v)&&(v=Ro.join(e,v)),v){if(!qn.existsSync(v))throw new Error(`Verification failed: File not found at ${v}`);let k=await R.verify(qn.readFileSync(v,"utf8"),T);if(!k.passed)throw new Error(`Verification failed: ${k.errors.join("")}`)}else{let k=a.getWorkingSet(t),F=!1;for(let x of k){if(!qn.existsSync(x.file_path))continue;if((await R.verify(qn.readFileSync(x.file_path,"utf8"),T)).passed){F=!0;break}}if(!F)throw new Error(`Verification failed for rule "${T.target}" in working set.`)}}}if(S.status=h,a.update(t,{strategy_graph:JSON.stringify(g),commit_sha:p}),l.create({mission_id:t,type:"system",content:`Step "${f}" updated to "${h}"`,confidence:1,symbol_id:null,file_path:null,symbol_name:null,signature:null,commit_sha:p}),b)try{let R=JSON.parse(b);if(a.clearWorkingSet(t),R.files&&Array.isArray(R.files))for(let w of R.files)a.addToWorkingSet(t,w)}catch(R){bt.warn({error:R},"Failed to apply context pivot")}u.push({stepId:f,status:h})}try{await new ve(e).syncMissionToGitNotes(t)}catch(m){bt.warn({syncError:m,missionId:t},"Git Notes sync deferred")}return{content:[{type:"text",text:JSON.stringify({missionId:t,updates:u,artifacts_added:c?.length||0,message:"Status updated",commit:p},null,2)}]}}catch(d){throw bt.error({error:d,repoPath:e},"Failed to update status"),new Error(`Failed to update status: ${d instanceof Error?d.message:String(d)}`)}}P();var $o=_.child({module:"mcp:tools:ops:graph"});async function ko(i){let{repoPath:e,missionId:t,depth:n,limit:s,format:r="mermaid"}=i;$o.info({repoPath:e,missionId:t,format:r},"Generating mission graph");try{let{GraphExporterService:o}=await Promise.resolve().then(()=>(Co(),Io));return{content:[{type:"text",text:await new o(e).generateGraph({includeCompleted:!0,format:r,focusMissionId:t,depth:n,limit:s})}]}}catch(o){throw $o.error({error:o,repoPath:e},"Failed to generate mission graph"),new Error(`Failed to generate mission graph: ${o.message}`)}}U();P();var Bt=_.child({module:"mcp:tools:ops:log"});async function Lo(i){let{repoPath:e,missionId:t,type:n,content:s,filePath:r,symbolName:o}=i;Bt.info({repoPath:e,type:n,symbolName:o},"Logging intent");let{missions:c,exports:a,intentLogs:l}=C.getInstance(e);try{let p=t??null;if(p){if(!c.findById(p))throw new Error(`Mission ${p} not found. Use shadow_ops_briefing to see available missions.`)}else{let h=c.findActive();h.length>0?(p=h[0].id,Bt.debug({missionId:p},"Auto-resolved to active mission")):(p=null,Bt.debug("No active mission found, logging as system/unlinked intent"))}let d=null,u=null,m=o||null;if(o){let b=(r?a.findByNameAndFile(o,r):a.findByName(o))[0];b?(d=b.id,u=b.signature,m=b.name):Bt.warn({symbolName:o,filePath:r},"Symbol not found for intent linking")}let f=l.create({mission_id:p,symbol_id:d,file_path:r||null,type:n,content:s,confidence:1,symbol_name:m,signature:u,commit_sha:null});return{content:[{type:"text",text:JSON.stringify({logId:f,missionId:p,symbolId:d,status:"logged",message:d?`Intent linked to symbol "${o}"`:"Intent logged (unlinked)"},null,2)}]}}catch(p){throw Bt.error({error:p,repoPath:e},"Failed to log intent"),new Error(`Failed to log intent: ${p instanceof Error?p.message:String(p)}`)}}U();P();var No=_.child({module:"mcp:tools:ops:synthesize"});async function Ao(i){let{repoPath:e,missionId:t}=i;No.info({repoPath:e,missionId:t},"Synthesizing mission");let{missions:n}=C.getInstance(e);try{if(!n.findById(t))throw new Error(`Mission ${t} not found`);let o=await new Ge(e).distillMission(t);return{content:[{type:"text",text:JSON.stringify({missionId:t,adr:o.adr,metrics:o.metrics},null,2)}]}}catch(s){throw No.error({error:s,repoPath:e},"Failed to synthesize ADR"),new Error(`Failed to synthesize ADR: ${s instanceof Error?s.message:String(s)}`)}}import rl from"path";var V={...E,box:se,table:an,list:li};async function Mo(i){let[e,...t]=i;if(!e||!["plan","briefing","update","log","synthesize","graph"].includes(e)){console.log(""),console.log(` ${V.bold("Usage: ")} liquid-shadow mission <action> [options]`),console.log(""),console.log(` ${V.bold("Actions: ")}`),console.log(` ${V.cyan("plan")} <repo> <name> <goal> Plan a new mission`),console.log(` ${V.cyan("update")} <repo> <id> <status> Update mission status`),console.log(` ${V.cyan("log")} <repo> <id> <type> <msg> Log a mission discovery/intent`),console.log(` ${V.cyan("briefing")} <repo> [--branch] Get mission briefing`),console.log(` ${V.cyan("synthesize")} <repo> <id> Distill mission into ADR`),console.log(` ${V.cyan("graph")} <repo> [id] Generate mission lineage graph`),console.log("");return}await B(async()=>{let n=t[0]?rl.resolve(t[0]):process.cwd();switch(e){case"plan":{let[s,r,o]=t;if(!r||!o){console.error(` ${V.red("\u2716")} Usage: mission plan <repo> <name> <goal>`);return}let c=await _o({repoPath:n,name:r,goal:o}),a=JSON.parse(c.content[0].text);console.log(` ${V.green("\u2714")} Mission planned (ID: ${a.missionId})`);break}case"update":{let[s,r,o]=t;if(!r||!o){console.error(` ${V.red("\u2716")} Usage: mission update <repo> <id> <status>`);return}await vo({repoPath:n,missionId:parseInt(r),status:o}),console.log(` ${V.green("\u2714")} Status updated to ${o}`);break}case"log":{let[s,r,o,...c]=t;if(!r||!o||c.length===0){console.error(` ${V.red("\u2716")} Usage: mission log <repo> <id> <type> <message>`);return}await Lo({repoPath:n,missionId:parseInt(r),type:o,content:c.join(" ")}),console.log(` ${V.green("\u2714")} Intent logged`);break}case"synthesize":{let[s,r]=t;if(!r){console.error(` ${V.red("\u2716")} Usage: mission synthesize <repo> <id>`);return}let o=await Ao({repoPath:n,missionId:parseInt(r)});console.log(""),V.box("Mission Synthesis (ADR)",o.content[0].text,"magenta");break}case"graph":{let[s,r]=t,o=await ko({repoPath:n,missionId:r?parseInt(r):void 0,format:"mermaid"});console.log(""),console.log(o.content[0].text);break}case"briefing":{let s=await xo({repoPath:n});if(s.content&&s.content[0]){let r=s.content[0].text;try{let o=JSON.parse(r);if(o.mission){console.log(""),console.log(V.bold(V.cyan(` Mission Dashboard: ${o.mission.name} `))),V.box("Tactical Goal",o.mission.goal,"cyan");let c=o.mission.status==="completed"?"green":o.mission.status==="failed"?"red":"yellow",a=[["Status",V.bold(V[c](o.mission.status.toUpperCase()))],["ID",`#${o.mission.id}`],["Branch",o.mission.git_branch||"main"]];V.table(["Field","Value"],a),o.recent_activity&&o.recent_activity.length>0&&(console.log(` ${V.bold("Recent Activity:")}`),V.list(o.recent_activity.slice(0,5).map(l=>`${V.dim(`[${l.type.toUpperCase()}]`)} ${l.content}`)))}else console.log(r)}catch{console.log(r)}}break}}})}import Ds from"path";async function Po(i){let[e,...t]=i;if(!e||!["symbol","file"].includes(e)){console.log(""),console.log(` ${E.bold("Usage: ")} liquid-shadow inspect <symbol|file> [options]`),console.log(""),console.log(` ${E.bold("Actions: ")}`),console.log(` ${E.cyan("symbol")} <repo> <name> Read source code for a symbol`),console.log(` ${E.cyan("file")} <repo> <path> Get a token-efficient file summary`),console.log("");return}await B(async()=>{let n=t[0]?Ds.resolve(t[0]):process.cwd();if(e==="symbol"){let s=t[1];if(!s){console.error(` ${E.red("\u2716")} Please provide a symbol name`);return}let r=await gt({repoPath:n,symbolName:s});console.log(""),r.content&&r.content[0]&&console.log(r.content[0].text)}else{let s=t[1];if(!s){console.error(` ${E.red("\u2716")} Please provide a file path`);return}let r=Ds.isAbsolute(s)?s:Ds.join(n,s),o=await Mn({repoPath:n,filePath:r});console.log(""),o.content&&o.content[0]&&console.log(o.content[0].text)}})}var Do=["index","status","metrics","benchmark","tree","trace","watch","search-config","search-concept","search-symbol","search-fuzzy","hooks","workspace","mission","inspect","completion"],ol=["--help","-h","--version","-v","--dir","-d"],al={index:["--output","-o","--level","-l","--subPath","--force","--deep"],tree:["--subPath","--depth","-d"],trace:["--dir","-d"],"search-config":["--dir","-d","--kind"],"search-concept":["--dir","-d","--interactive","-i"],"search-symbol":["--dir","-d","--interactive","-i"],"search-fuzzy":["--dir","-d","--interactive","-i"]};function cl(){let i=Object.entries(al).map(([n,s])=>` ${n}) opts="${s.join(" ")}" ;;`).join(`
814
- `),e=Do.join(" ");return`# Bash completion for liquid-shadow. Usage: source <(liquid-shadow completion bash)
789
+ *Generated by Liquid Shadow Reasoning Engine v1*`,r){this.intentLogs.create({mission_id:e,type:"adr",content:s,confidence:1,symbol_id:null,file_path:null,symbol_name:null,signature:null,commit_sha:null});try{await this.persistencePivot.syncMissionToGitNotes(e),La.info({missionId:e},"Tactical Briefing synthesized, archived, and synced to Git Notes.")}catch(a){La.error({missionId:e,error:a},"Failed to sync ADR to Git Notes")}}else La.info({missionId:e},"Tactical Briefing synthesized (dry-run).");return{missionId:e,adr:s,metrics:{totalLogs:i.length,symbolCount:o.size}}}gatherConsolidatedLogs(e,r=0){let i=this.intentLogs.findByMissionPreferCrystal(e,500);if(r>2)return i;let t=this.missions.findByParentId(e);for(let o of t)i.push(...this.gatherConsolidatedLogs(o.id,r+1));return i.filter(o=>o.type!=="adr"&&o.type!=="system")}};G();import{Visitor as Ik}from"@swc/core/Visitor.js";import*as wb from"@swc/core";var Tk=x.child({module:"verification-engine"}),Wm=class extends Ik{foundUsage=!1;foundImport=!1;rule;currentFunctionName=null;constructor(e){super(),this.rule=e}visitImportDeclaration(e){return this.rule.type==="import"&&e.source.value===this.rule.target&&(this.foundImport=!0),super.visitImportDeclaration(e)}visitFunctionDeclaration(e){let r=this.currentFunctionName;this.currentFunctionName=e.identifier.value;let i=super.visitFunctionDeclaration(e);return this.currentFunctionName=r,i}visitCallExpression(e){return this.rule.type==="usage"&&e.callee.type==="Identifier"&&e.callee.value===this.rule.target&&(!this.rule.context||this.currentFunctionName===this.rule.context)&&(this.foundUsage=!0),super.visitCallExpression(e)}},Aa=class{async verify(e,r){try{let i=await wb.parse(e,{syntax:"typescript",tsx:!0,comments:!1}),t=new Wm(r);t.visitProgram(i);let o=!1,s=[];if(r.type==="import")o=t.foundImport,o||s.push(`Required import "${r.target}" not found.`);else if(r.type==="usage"){if(o=t.foundUsage,!o){let a=r.context?` in function "${r.context}"`:"";s.push(`Required usage of "${r.target}"${a} not found.`)}}else r.type==="pattern"&&(o=new RegExp(r.target).test(e),o||s.push(`Required pattern "${r.target}" not found.`));return{passed:o,errors:s}}catch(i){return Tk.error({error:i},"Verification failed due to parse error"),{passed:!1,errors:[`Parse error: ${i.message}`]}}}};import kb from"path";import Oa from"fs";var it=x.child({module:"mcp:tools:ops:track"});async function Eb(n,e,r){let{missions:i,intentLogs:t}=z.getInstance(n),o=i.findById(e);if(!o?.parent_id)return;let s=i.findByParentId(o.parent_id);if(!s.every(l=>l.status==="completed"))return;let c=i.findById(o.parent_id);if(!(!c||c.status==="completed")){it.info({parentId:c.id,childCount:s.length},"All children completed \u2014 cascading parent completion"),i.updateStatus(c.id,"completed",r||void 0),i.clearWorkingSet(c.id),t.create({mission_id:c.id,type:"system",content:`Parent auto-completed: all ${s.length} child missions finished`,confidence:1,symbol_id:null,file_path:null,symbol_name:null,signature:null,commit_sha:r});try{await new kt(n).distillMission(c.id),it.info({parentId:c.id},"Parent Auto-Synthesis completed")}catch(l){it.warn({synthesisError:l,parentId:c.id},"Parent Auto-Synthesis deferred")}try{await new rt(n).syncMissionToGitNotes(c.id)}catch(l){it.warn({syncError:l,parentId:c.id},"Parent Git Notes sync deferred")}await Eb(n,c.id,r)}}async function Ma(n){let{repoPath:e,missionId:r,stepId:i,status:t,contextPivot:o,updates:s,artifacts:a}=n,{missions:c,intentLogs:l}=z.getInstance(e),u=Qe(e);it.info({repoPath:e,missionId:r,singleStep:i,batchCount:s?.length,artifactCount:a?.length},"Updating mission status");try{if(a&&Array.isArray(a))for(let m of a)c.addArtifact(r,m.type,m.identifier,m.metadata);let d=[];if(s&&Array.isArray(s)&&d.push(...s),i&&t&&d.push({stepId:i,status:t,contextPivot:o}),t&&!i){if(c.updateStatus(r,t,u||void 0),t==="completed"&&c.clearWorkingSet(r),l.create({mission_id:r,type:"system",content:`Mission status changed to "${t}"`,confidence:1,symbol_id:null,file_path:null,symbol_name:null,signature:null,commit_sha:u}),t==="completed"){try{await new kt(e).distillMission(r),it.info({missionId:r},"Auto-Synthesis completed successfully")}catch(m){it.warn({synthesisError:m,missionId:r},"Auto-Synthesis deferred or failed")}await Eb(e,r,u)}if(!d.length)return{content:[{type:"text",text:JSON.stringify({missionId:r,status:t,message:"Mission status updated successfully.",artifacts_added:a?.length||0,commit:u},null,2)}]}}if(d.length===0&&(!a||a.length===0))throw new Error("No updates provided. Must specify either 'updates', 'stepId'/'status', 'status' (top-level), or 'artifacts'.");let p=[];for(let m of d){let{stepId:f,status:h,contextPivot:_}=m,v=c.findById(r);if(!v)throw new Error(`Mission ID ${r} not found`);let y=JSON.parse(v.strategy_graph||"{}"),k=null;if(Array.isArray(y)?k=y.find($=>$.id===f):y.nodes&&Array.isArray(y.nodes)?k=y.nodes.find($=>$.id===f):y.steps?Array.isArray(y.steps)?k=y.steps.find($=>$.id===f):k=y.steps[f]:y[f]&&(k=y[f]),!k)throw new Error(`Step ID "${f}" not found`);if(h==="completed"&&k.verification){let $=new Aa,w=Array.isArray(k.verification)?k.verification:[k.verification];for(let I of w){let P=I;if(typeof I=="string"&&(P={type:"pattern",target:I}),!P||!P.target){it.warn({rule:I},"Skipping invalid verification rule (missing target)");continue}let R=P.filePath;if(R&&!kb.isAbsolute(R)&&(R=kb.join(e,R)),R){if(!Oa.existsSync(R))throw new Error(`Verification failed: File not found at ${R}`);let F=await $.verify(Oa.readFileSync(R,"utf8"),P);if(!F.passed)throw new Error(`Verification failed: ${F.errors.join("")}`)}else{let F=c.getWorkingSet(r),T=!1;F.length===0&&it.warn("No working set files to verify against for rule");for(let A of F){if(!Oa.existsSync(A.file_path))continue;if((await $.verify(Oa.readFileSync(A.file_path,"utf8"),P)).passed){T=!0;break}}if(!T)throw new Error(`Verification failed: Rule "${P.target}" not satisfied in any working set file.`)}}}if(k.status=h,c.update(r,{strategy_graph:JSON.stringify(y),commit_sha:u}),l.create({mission_id:r,type:"system",content:`Step "${f}" updated to "${h}"`,confidence:1,symbol_id:null,file_path:null,symbol_name:null,signature:null,commit_sha:u}),_)try{let $=JSON.parse(_);if(c.clearWorkingSet(r),$.files&&Array.isArray($.files))for(let w of $.files)c.addToWorkingSet(r,w)}catch($){it.warn({error:$},"Failed to apply context pivot")}p.push({stepId:f,status:h})}try{await new rt(e).syncMissionToGitNotes(r)}catch(m){it.warn({syncError:m,missionId:r},"Git Notes sync deferred")}return{content:[{type:"text",text:JSON.stringify({missionId:r,updates:p,artifacts_added:a?.length||0,message:"Status updated",commit:u},null,2)}]}}catch(d){throw it.error({error:d,repoPath:e},"Failed to update status"),new Error(`Failed to update status: ${d instanceof Error?d.message:String(d)}`)}}G();var Ib=x.child({module:"mcp:tools:ops:briefing"});async function Ar(n){let{repoPath:e,scope:r="mission"}=n;Ib.info({repoPath:e,missionId:n.missionId,scope:r},"Generating briefing");try{let t=await new rr(e).getBriefing(n);if(!t&&r==="mission")return{content:[{type:"text",text:"No active missions found. Ready for new assignment."}]};let o;if(r==="project"){let s=t.counts;o=t.next_work_candidates.length===0&&s.active===0?{tool:"shadow_ops_plan",reason:"No open work; create a mission"}:{tool:"shadow_ops_track",reason:"Select a mission from hierarchy or next_work_candidates to execute"}}return{content:[{type:"text",text:JSON.stringify(t,null,2)}],suggestedNext:o}}catch(i){throw Ib.error({error:i,repoPath:e},"Failed to generate briefing"),new Error(`Failed to generate briefing: ${i instanceof Error?i.message:String(i)}`)}}X();G();var Tb=x.child({module:"mcp:tools:ops:synthesize"});async function ja(n){let{repoPath:e,missionId:r}=n;Tb.info({repoPath:e,missionId:r},"Synthesizing mission");let{missions:i}=z.getInstance(e);try{if(!i.findById(r))throw new Error(`Mission ${r} not found`);let s=await new kt(e).distillMission(r);return{content:[{type:"text",text:JSON.stringify({missionId:r,adr:s.adr,metrics:s.metrics},null,2)}]}}catch(t){throw Tb.error({error:t,repoPath:e},"Failed to synthesize ADR"),new Error(`Failed to synthesize ADR: ${t instanceof Error?t.message:String(t)}`)}}G();X();G();var Pk=x.child({module:"narrative-service"}),jt=class{missions;briefingEngine;repoPath;constructor(e){this.repoPath=e;let{missions:r}=z.getInstance(e);this.missions=r,this.briefingEngine=new kt(e)}async generateChronicle(e={}){Pk.info(e,"Generating Repo Chronicle...");let i=this.missions.findAll().filter(l=>l.parent_id===null&&l.status!=="planned");e.since&&(i=i.filter(l=>l.updated_at>=e.since)),e.until&&(i=i.filter(l=>l.updated_at<=e.until)),i.sort((l,u)=>u.updated_at-l.updated_at);let t=e.offset||0,o=e.limit||10;i=i.slice(t,t+o);let s=[],a=[],c=[];for(let l of i){let u=this.missions.findByParentId(l.id),d=u.length>0,p=await this.briefingEngine.distillMission(l.id,!1);if(d){let m=[];for(let h of u)m.push(await this.mapMissionToEpisode(h));m.unshift(await this.mapMissionToEpisode(l));let f={kind:"initiative",root_mission_id:l.id,title:l.name,strategy_graph:l.strategy_graph?JSON.parse(l.strategy_graph):{},episodes:e.compact?[]:m,synthesized_narrative:e.compact?this.truncateText(p.adr):p.adr||""};s.push(f),c.push(f)}else{let m=await this.mapMissionToEpisode(l,p.adr,e.compact);a.push(m),c.push(m)}}return{repo_path:this.repoPath,generated_at:Date.now(),initiatives:s,unattached_episodes:a,timeline:c}}async mapMissionToEpisode(e,r,i=!1){let t=r;return t||(t=(await this.briefingEngine.distillMission(e.id,!1)).adr),{kind:"episode",mission_id:e.id,title:e.name,goal:e.goal,outcome:e.outcome_contract,intents:[],adr_summary:i?this.truncateText(t):t}}truncateText(e,r=300){return e?e.length<=r?e:e.slice(0,r)+"... (truncated)":""}renderChronicleMarkdown(e){let r=`# Repository Chronicle
790
+
791
+ `;if(r+=`*Generated at ${new Date(e.generated_at).toISOString()}*
792
+
793
+ `,e.timeline&&e.timeline.length>0)for(let i of e.timeline)i.kind==="initiative"?(r+=`### \u{1F9EC} ${i.title} (Mission #${i.root_mission_id})
794
+ `,r+=`${i.synthesized_narrative}
795
+
796
+ `):(r+=`### \u269B\uFE0F ${i.title} (Mission #${i.mission_id})
797
+ `,r+=`${i.adr_summary}
798
+
799
+ `),r+=`---
800
+ `;return r}};var Pb=x.child({module:"mcp:tools:ops:chronicle"});async function Rb(n){let{repoPath:e,format:r="markdown",...i}=n,t=new jt(e);Pb.info({repoPath:e,format:r,filters:i},"Generating Chronicle");try{let o=await t.generateChronicle(i),s={tool:"shadow_ops_briefing",reason:"Current backlog and next work"};return r==="json"?{content:[{type:"text",text:JSON.stringify(o,null,2)}],suggestedNext:s}:{content:[{type:"text",text:t.renderChronicleMarkdown(o)}],suggestedNext:s}}catch(o){throw Pb.error({error:o,repoPath:e},"Failed to generate chronicle"),new Error(`Failed to generate chronicle: ${o instanceof Error?o.message:String(o)}`)}}He();async function Nb(n){let{repoPath:e,compact:r=!0}=n,t=new le(e).getSnapshot();r&&t.gravity?.hotspots&&(t={...t,gravity:{...t.gravity,hotspots:t.gravity.hotspots.slice(0,10),_truncated:t.gravity.hotspots.length>10,_totalHotspots:t.gravity.hotspots.length}});let a={...await new jt(e).generateChronicle({limit:5,compact:r}),initiatives:[],unattached_episodes:[]},l=(await Ar({repoPath:e,scope:"project",altitude:r?"orbit":"atmosphere",compact:r,activeMissionsLimit:r?10:void 0,recentActivityLimit:r?5:10})).content?.[0],u=l&&l.type==="text"?l.text:"{}",d={};try{d=JSON.parse(u)}catch{}let p={counts:d.counts,next_work_candidates:d.next_work_candidates??[],active_count:Array.isArray(d.active_missions)?d.active_missions.length:0};return{content:[{type:"text",text:JSON.stringify({hologram:t,chronicle:a,briefing:p},null,2)}],suggestedNext:{tool:p.next_work_candidates.length>0?"shadow_ops_track":"shadow_ops_plan",reason:p.next_work_candidates.length>0?"Pick one from next_work_candidates and run /continue":"No open work; create a mission"}}}G();st();import Bm from"path";var zb=x.child({module:"mcp:tools:ops:health"});async function Db(n){let e=n.repoPath,r=Bm.isAbsolute(e)?Bm.normalize(e):Bm.resolve(process.cwd(),e);zb.info({repoPath:r},"Health check");let i=!1,t=!1;try{je(r),i=!0,t=De(r)}catch(c){zb.debug({repoPath:r,error:c},"Health: DB check failed")}let o=xn(),s={status:i?t?"ready":"index_pending":"db_unavailable",database:i,indexed:t,metrics:{index:o.index,query:o.query,uptimeMs:o.uptimeMs}},a=t?{tool:"shadow_recon_hologram",reason:"Architecture overview"}:{tool:"shadow_recon_onboard",reason:"Index the repo first"};return{content:[{type:"text",text:JSON.stringify(s,null,2)}],suggestedNext:a}}X();G();var ji=x.child({module:"mcp:tools:ops:log"});async function Ua(n){let{repoPath:e,missionId:r,type:i,content:t,filePath:o,symbolName:s,standalone:a}=n;ji.info({repoPath:e,type:i,symbolName:s,standalone:a},"Logging intent");let{missions:c,exports:l,intentLogs:u}=z.getInstance(e);try{let d=r??null;if(a){if(!s)throw new Error('Standalone intent logs must be anchored to a symbol. Please provide "symbolName".');d=null}else if(d){if(!c.findById(d))throw new Error(`Mission ${d} not found. Use shadow_ops_briefing to see available missions.`)}else{let _=c.findActive();_.length>0?(d=_.find(v=>v.status==="in-progress")?.id||_[0].id,ji.debug({missionId:d},"Auto-resolved to active mission")):(d=null,ji.debug("No active mission found, logging as system/unlinked intent"))}let p=null,m=null,f=s||null;if(s){let v=(o?l.findByNameAndFile(s,o):l.findByName(s))[0];v?(p=v.id,m=v.signature,f=v.name):ji.warn({symbolName:s,filePath:o},"Symbol not found for intent linking")}let h=u.create({mission_id:d,symbol_id:p,file_path:o||null,type:i,content:t,confidence:1,symbol_name:f,signature:m,commit_sha:null});return{content:[{type:"text",text:JSON.stringify({logId:h,missionId:d,symbolId:p,status:"logged",message:p?`Intent linked to symbol "${s}"`:"Intent logged (unlinked)"},null,2)}]}}catch(d){throw ji.error({error:d,repoPath:e},"Failed to log intent"),new Error(`Failed to log intent: ${d instanceof Error?d.message:String(d)}`)}}G();var Ab=x.child({module:"mcp:tools:ops:graph"});async function Za(n){let{repoPath:e,missionId:r,depth:i,limit:t,format:o="mermaid"}=n;Ab.info({repoPath:e,missionId:r,format:o},"Generating mission graph");try{let{GraphExporterService:s}=await Promise.resolve().then(()=>(Gm(),Lb));return{content:[{type:"text",text:await new s(e).generateGraph({includeCompleted:!0,format:o,focusMissionId:r,depth:i,limit:t})}]}}catch(s){throw Ab.error({error:s,repoPath:e},"Failed to generate mission graph"),new Error(`Failed to generate mission graph: ${s.message}`)}}X();G();var Ob=x.child({module:"mcp:tools:ops:crystallize"});async function Mb(n){let{repoPath:e,missionId:r,symbolId:i}=n;Ob.info({repoPath:e,missionId:r,symbolId:i},"Crystallizing logs");let{intentLogs:t,missions:o,exports:s}=z.getInstance(e);if(typeof r=="number"){let a=o.findById(r);if(!a)throw new Error(`Mission ${r} not found`);let c=t.findRawByMission(r);if(c.length===0){let h=t.findCrystalByMission(r);return{content:[{type:"text",text:JSON.stringify({missionId:r,status:h?"already_crystallized":"no_logs",message:h?"Mission already has a crystal with no new raw logs to absorb.":"No raw intent logs found for this mission.",crystalId:h?.id??null},null,2)}]}}let u=new jn().analyze(c),d=new Set(c.map(h=>h.symbol_name).filter(Boolean)),p=new Set(c.map(h=>h.type)),m=`[Crystal] Mission #${r}: ${a.name}
801
+ `;m+=`Compressed ${c.length} logs across ${d.size} symbols.
802
+ `,m+=`Types: ${[...p].join(", ")}
803
+
804
+ `,u.decisions.length>0&&(m+=`Decisions: ${u.decisions.join(" | ")}
805
+ `),u.context.length>0&&(m+=`Context: ${u.context.join(" | ")}
806
+ `),u.consequences.length>0&&(m+=`Consequences: ${u.consequences.join(" | ")}
807
+ `),u.recommendations.length>0&&(m+=`Recommendations: ${u.recommendations.join(" | ")}
808
+ `);let f=t.crystallize(r,m.trim());return Ob.info({missionId:r,crystalId:f,absorbed:c.length},"Crystallization complete"),{content:[{type:"text",text:JSON.stringify({missionId:r,crystalId:f,absorbed:c.length,symbolsCompressed:d.size,status:"crystallized"},null,2)}]}}if(typeof i=="number"){let a=s.findHydratedById(i);if(!s.findById(i))throw new Error(`Symbol ${i} not found in index`);let l=t.findRawBySymbol(i);if(l.length===0)return{content:[{type:"text",text:JSON.stringify({symbolId:i,status:"no_logs",message:"No raw standalone intent logs found for this symbol."},null,2)}]};let d=new jn().analyze(l),p=new Set(l.map(h=>h.type)),m=`[Crystal] Symbol #${i}: ${a?.name||"Unknown"}
809
+ `;m+=`Compressed ${l.length} standalone insights.
810
+ `,m+=`Types: ${[...p].join(", ")}
811
+
812
+ `,d.decisions.length>0&&(m+=`Decisions: ${d.decisions.join(" | ")}
813
+ `),d.context.length>0&&(m+=`Context: ${d.context.join(" | ")}
814
+ `);let f=t.crystallizeBySymbol(i,m.trim());return{content:[{type:"text",text:JSON.stringify({symbolId:i,crystalId:f,absorbed:l.length,status:"crystallized"},null,2)}]}}throw new Error("Must provide either missionId or symbolId to crystallize.")}G();X();import Ha from"path";var Rk=x.child({module:"mcp:tools:ops:working-set-check"});async function jb(n){let{repoPath:e,filePaths:r}=n,{missions:i}=z.getInstance(e),t=i.findActive(),o=[];for(let s of t){let a=i.getWorkingSet(s.id);for(let c of a)if(r.includes(c.file_path))o.push({file_path:c.file_path,mission_id:s.id,mission_name:s.name});else{let l=Ha.isAbsolute(c.file_path)?c.file_path:Ha.join(e,c.file_path);for(let u of r){let d=Ha.isAbsolute(u)?u:Ha.join(e,u);if(l===d){o.push({file_path:c.file_path,mission_id:s.id,mission_name:s.name});break}}}}return Rk.info({repoPath:e,conflictsCount:o.length},"Working set check completed"),{content:[{type:"text",text:JSON.stringify({conflicts:o},null,2)}]}}import Ve from"path";import qm from"fs";G();import $e from"path";import Jm from"fs";var Wa=x.child({module:"path-resolver"}),un=class{repoPath;constructor(e){this.repoPath=$e.isAbsolute(e)?$e.normalize(e):$e.resolve(process.cwd(),e)}resolve(e){if(!e)return this.repoPath;if(e.includes("\0"))throw Wa.error({inputPath:e},"Path contains null bytes - possible attack"),new Error("Invalid path: contains null bytes");let r;if($e.isAbsolute(e)?r=$e.normalize(e):r=$e.join(this.repoPath,e),r=$e.normalize(r),!this.isWithinRoot(r))throw Wa.warn({inputPath:e,resolved:r},"Path traversal attempt blocked"),new Error(`Access denied: path '${e}' is outside the repository root`);return r}resolveAndValidate(e){try{let r=this.resolve(e);return Jm.existsSync(r)?r:(Wa.debug({inputPath:e,resolved:r},"Path does not exist"),null)}catch(r){return Wa.error({inputPath:e,error:r},"Error validating path"),null}}isWithinRoot(e){try{let r=$e.resolve(e),i=$e.resolve(this.repoPath),t=$e.relative(i,r);if(t.startsWith("..")||$e.isAbsolute(t))return!1;if(Jm.existsSync(r)){let s=Jm.realpathSync(r),a=$e.relative(i,s);if(a.startsWith("..")||$e.isAbsolute(a))return!1}return!0}catch{return!1}}getRelative(e){let r=$e.normalize(e);return $e.relative(this.repoPath,r)}resolveBatch(e){return e.map(r=>this.resolve(r))}static normalize(e){return $e.normalize(e)}static isPathWithinRoot(e,r){let i=$e.resolve(e),t=$e.resolve(r),o=$e.relative(i,t);return o===""||!o.startsWith("..")&&!$e.isAbsolute(o)}};function Ub(n){return new un(n)}var Nk=/[\x00-\x1f\x7f]/g,zk=/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/g;function Un(n){if(typeof n!="string")throw new Error("Invalid path: expected string");if(n.includes("\0"))throw new Error("Invalid path: null bytes are not allowed");if(n.replace(Nk,"").length!==n.length)throw new Error("Invalid path: control characters are not allowed");return n.trim()}function Fn(n,e=4096){if(typeof n!="string")return"";let r=n.replace(zk,"").trim();return r.length>e?r.slice(0,e):r}st();var Ui=`
815
+
816
+ To check repository and connection health: shadow_env_diagnose({ repoPath }).`;function dn(n,e,r){return{content:[{type:"text",text:`[${n}] ${e}`}],isError:!0,errorCode:n,errorDetails:r}}function Ck(n){let e=Ve.isAbsolute(n)?Ve.normalize(n):Ve.resolve(process.cwd(),n),r=Ve.parse(e).root;for(;e!==r;){if(qm.existsSync(Ve.join(e,".liquid-shadow.db"))||qm.existsSync(Ve.join(e,".git"))||qm.existsSync(Ve.join(e,"package.json")))return e;let i=Ve.dirname(e);if(i===e)break;e=i}return null}function ot(n){let e=n?.repoPath?String(n.repoPath):void 0,r=n?.filePath?String(n.filePath):void 0;e&&(e=Un(e)),r&&(r=Un(r));let i;if(e)Ve.isAbsolute(e)||(e=Ve.resolve(process.cwd(),e)),i=e;else if(r){let s=Ve.resolve(process.cwd(),r);i=Ck(Ve.dirname(s))||process.cwd()}else i=process.cwd();i=Ve.normalize(i);let t=Ub(i),o;return r&&(o=t.resolve(r)),{...n,repoPath:i,filePath:o,resolver:t}}function Fb(n,e){if(!De(n)){let r=`Repository not indexed yet. Run initial indexing first:
817
+
818
+ 1. shadow_recon_onboard({ repoPath: "${n}" }) // one-time
819
+ 2. shadow_sync_trace({ repoPath: "${n}" }) // then sync
820
+
821
+ After that, ${e} and other tools will work.`+Ui;return dn("FILE_NOT_FOUND",r,{repoPath:n,toolName:e,requiresIndexing:!0})}return null}G();X();async function Ba(n){let e=Fn(n.query??""),r={...n,query:e},i=_n();try{let{repoPath:t}=ot(r),{query:o,limit:s=ke.DEFAULT_LIMIT,offset:a=0,compact:c=!1}=r;await Q(t);let{filters:l,hasFilters:u}=Rn(r),p=await new et(t).searchByConcept(o,s,a,l,u,c);return Lk(t,o,"concept"),i(),p}catch(t){return x.error({error:t,args:n},"Concept Search failed"),i(),await yt(),{content:[{type:"text",text:`Concept Search failed: ${t instanceof Error?t.message:String(t)}`}],isError:!0}}}function Lk(n,e,r){try{let i=z.getInstance(n),t=Ee(n);i.searchHistory.record(e,r,t)}catch(i){let t=Ee(n);x.error({module:"search",repoPath:n,query:e,mode:r,error:i instanceof Error?i.message:String(i),branch:t},"Failed to record search history"),yt()}}G();X();async function Fi(n){let e=Fn(n.query??""),r={...n,query:e},i=_n();try{let{repoPath:t}=ot(r),{query:o,limit:s=ke.DEFAULT_LIMIT,offset:a=0,matchMode:c="any"}=r;await Q(t);let{filters:l,hasFilters:u}=Rn(r),p=await new et(t).searchBySymbol(o,s,a,l,u,c);return Ak(t,o,"symbol"),i(),p}catch(t){return x.error({error:t,args:n},"Symbol Search failed"),i(),await yt(),{content:[{type:"text",text:`Symbol Search failed: ${t instanceof Error?t.message:String(t)}`}],isError:!0}}}function Ak(n,e,r){try{let i=z.getInstance(n),t=Ee(n);i.searchHistory.record(e,r,t)}catch(i){let t=Ee(n);x.error({module:"search",repoPath:n,query:e,mode:r,error:i instanceof Error?i.message:String(i),branch:t},"Failed to record search history"),yt()}}X();G();import Zi from"path";function Zb(n,e){let r=n.findContentByToken(e,100);return{count:r.length,files:r}}async function Ga(n){let{repoPath:e,query:r,key:i="",kind:t,limit:o=50,showUsage:s=!1}=n,a=i||r;if(!a&&!t)return{content:[{type:"text",text:'Error: Either "key" or "kind" parameter is required.'}]};await Q(e);let c=z.getInstance(e),{configs:l,files:u}=c;if(a){x.info({repoPath:e,key:a},"Searching for config key in DB...");let f=l.findByKey(a,o);if(f.length===0)return{content:[{type:"text",text:`No configuration found for key: ${a}`}]};if(s){let v=f.map(w=>{let I=Zb(u,w.key),P=I.count===0?"\u26A0\uFE0F ORPHANED":`\u2713 ${I.count} usage(s)`;return{file:Zi.relative(e,w.file_path),key:w.key,value:w.value,kind:w.kind,usageCount:I.count,usageFiles:I.files.slice(0,5).map(R=>Zi.relative(e,R)),status:P}});v.sort((w,I)=>w.usageCount===0&&I.usageCount>0?-1:I.usageCount===0&&w.usageCount>0?1:w.usageCount-I.usageCount);let y=v.filter(w=>w.usageCount===0).length;return{content:[{type:"text",text:(y>0?`# Configuration Search: "${a}" (with Usage Analysis)
822
+
823
+ \u26A0\uFE0F **${y} orphaned var(s)** (defined but never used in code)
824
+
825
+ Found ${f.length} match(es):
826
+
827
+ `:`# Configuration Search: "${a}" (with Usage Analysis)
828
+
829
+ Found ${f.length} match(es), all in use:
830
+
831
+ `)+v.map(w=>{let I=`## ${w.file} (${w.kind}) ${w.status}
832
+ **${w.key}**: \`${w.value}\``;return w.usageCount>0&&w.usageFiles.length>0&&(I+=`
833
+ > Used in: ${w.usageFiles.map(P=>`\`${P}\``).join(", ")}${w.usageCount>5?` (+${w.usageCount-5} more)`:""}`),I}).join(`
834
+
835
+ `)}]}}let h=f.map(v=>({file:Zi.relative(e,v.file_path),key:v.key,value:v.value,kind:v.kind}));return{content:[{type:"text",text:`# Configuration Search: "${a}"
836
+
837
+ Found ${f.length} match(es):
838
+
839
+ `+h.map(v=>`## ${v.file} (${v.kind})
840
+ **${v.key}**: \`${v.value}\``).join(`
841
+
842
+ `)+"\n\n> \u{1F4A1} **Tip**: Use `showUsage: true` to see usage counts and identify orphaned vars."}]}}let d=l.findByKind(t||null,o);if(s){let f=d.map(y=>{let k=Zb(u,y.key);return{file:Zi.relative(e,y.file_path),key:y.key,value:y.value,kind:y.kind,usageCount:k.count,status:k.count===0?"ORPHANED":"in-use"}});f.sort((y,k)=>y.usageCount===0&&k.usageCount>0?-1:k.usageCount===0&&y.usageCount>0?1:y.usageCount-k.usageCount);let h=f.filter(y=>y.usageCount===0).length,_=f.length,v=`# Config Discovery (${t||"all"}) with Usage Analysis
843
+
844
+ `;return v+=`**Summary**: ${_} config(s) found, ${h} orphaned
845
+
846
+ `,h>0&&(v+=`## \u26A0\uFE0F Orphaned (${h})
847
+ `,v+=f.filter(y=>y.usageCount===0).map(y=>`- \`${y.key}\` in ${y.file}`).join(`
848
+ `),v+=`
849
+
850
+ `),v+=`## \u2713 In Use (${_-h})
851
+ `,v+=f.filter(y=>y.usageCount>0).map(y=>`- \`${y.key}\` (${y.usageCount} usages)`).join(`
852
+ `),d.length===o&&(v+=`
853
+
854
+ > Results limited to ${o} entries. Use the 'limit' parameter to see more.`),{content:[{type:"text",text:v}]}}let p=d.map(f=>({...f,file:Zi.relative(e,f.file_path)})),m=JSON.stringify(p,null,2);return d.length===o&&(m=`Results limited to ${o} entries. Use the 'limit' parameter to see more.
855
+
856
+ `+m),m+="\n\n> \u{1F4A1} **Tip**: Use `showUsage: true` to see usage counts and identify orphaned vars.",{content:[{type:"text",text:m}]}}G();X();async function Hb(n){let e=Fn(n.query??""),r={...n,query:e},i=_n();try{let{repoPath:t}=ot(r),{query:o,limit:s=ke.DEFAULT_LIMIT,offset:a=0,ranked:c=!1}=r;await Q(t);let{filters:l,hasFilters:u}=Rn(r),p=await new et(t).searchByPath(o,s,a,l,u,c);return Ok(t,o,"path"),i(),p}catch(t){return x.error({error:t,args:n},"Path Search failed"),i(),await yt(),{content:[{type:"text",text:`Path Search failed: ${t instanceof Error?t.message:String(t)}`}],isError:!0}}}function Ok(n,e,r){try{let i=z.getInstance(n),t=Ee(n);i.searchHistory.record(e,r,t)}catch(i){let t=Ee(n);x.error({module:"search",repoPath:n,query:e,mode:r,error:i instanceof Error?i.message:String(i),branch:t},"Failed to record search history"),yt()}}G();async function Wb(n){let{repoPath:e,filePath:r,symbolName:i,depth:t=3,limit:o=50,offset:s=0}=n;await Q(e);try{let c=await new nr(e).analyze(i,{filePath:r,depth:t,limit:o,offset:s});return c.length===0?{content:[{type:"text",text:`Symbol "${i}" not found.`}],isError:!0}:{content:[{type:"text",text:JSON.stringify(c,null,2)}]}}catch(a){return x.error({error:a,args:n},"Impact Analysis failed"),{content:[{type:"text",text:`Impact Analysis failed: ${a instanceof Error?a.message:String(a)}`}],isError:!0}}}X();G();import Bb from"@swc/core";import Hi from"fs";import ft from"path";var Mk=new Set(["api","v1","v2","v3","http","https","localhost","admin","internal","public","private","app","src","get","post","put","delete","patch","user","users","id","search","list","create","update","data"]);function Vm(n,e){let r=e,i=e.match(/\$\{([^}]+)\}/g);if(i)for(let u of i){let d=u.substring(2,u.length-1),p=n.configs.findEnvValue(d);p&&(r=r.replace(u,p))}let t=r.split("?")[0].split("#")[0];try{t.includes("://")&&(t=new URL(t).pathname)}catch{}t.length>1&&t.endsWith("/")&&(t=t.substring(0,t.length-1));let o=[],s=t.replace(/\*/g,"%").replace(/:[^/]+/g,"%").replace(/\{[^}]+\}/g,"%"),a=n.files.findSynapses({type:"api_route",name:s.includes("%")?s:t,direction:"consume",limit:10});for(let u of a){let d=u.name.replace(/:[^/]+/g,"[^/]+").replace(/\{[^}]+\}/g,"[^/]+").replace(/\*/g,"[^/]+");new RegExp(`^${d.replace(/\//g,"\\/")}$`).test(t.replace(/\*/g,"test-val"))&&o.push({file_path:u.file_path,start_line:u.line_number||0,signature:`[Synapse] ${u.name}`,score:1e3})}let c=t.split(/[^a-zA-Z0-9-_]/).filter(u=>u.length>=3&&!Mk.has(u.toLowerCase())&&!/^\d+$/.test(u));if(c.length>0){let d=[...c].sort((m,f)=>f.length-m.length)[0],p=n.exports.findRoutesByToken(d,20);for(let m of p){let f=50,h=(m.signature||m.name||"").toLowerCase();(m.name||"").toLowerCase().includes(t.replace(/\*/g,"").toLowerCase())&&(f+=200);for(let v of c)h.includes(v.toLowerCase())&&(f+=20);o.push({file_path:m.file_path,start_line:m.start_line,signature:`[Boundary] ${m.signature||m.name}`,capabilities:m.capabilities||void 0,score:f})}}if(o.length<3){let u=c.map(d=>d.replace(/[^a-zA-Z0-9_]/g,"")).filter(d=>d.length>0).join(" AND ");if(u.length>0){let d=n.content.search(u);for(let p of d){let m=0,f=p.file_path.toLowerCase(),h=p.snippet.toLowerCase();(f.includes("route")||f.includes("controller"))&&(m+=10),(f.includes("src/api")||f.includes("services/api"))&&(m+=5),(h.includes("addroute")||h.includes("@get"))&&(m+=15),(h.includes("axios.")||h.includes("fetch("))&&(m-=10),(f.includes(".spec.")||f.includes(".test."))&&(m-=20),m>0&&o.push({file_path:p.file_path,start_line:0,signature:`[FTS Match] ${p.snippet.replace(/\n/g," ")}`,score:m})}}}let l=new Map;return o.sort((u,d)=>d.score-u.score).forEach(u=>{l.has(u.file_path)||l.set(u.file_path,u)}),Array.from(l.values()).slice(0,3)}var jk=4,Wi=50,Uk=2,Fk=new Set(["push","pop","shift","unshift","slice","splice","map","filter","reduce","reduceRight","forEach","find","findIndex","includes","indexOf","lastIndexOf","every","some","flat","flatMap","fill","copyWithin","entries","keys","values","join","concat","sort","reverse","at","with","toSorted","toReversed","toSpliced","toString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","charAt","charCodeAt","codePointAt","split","substring","substr","trim","trimStart","trimEnd","padStart","padEnd","repeat","replace","replaceAll","match","matchAll","search","toLowerCase","toUpperCase","localeCompare","normalize","startsWith","endsWith","then","catch","finally","get","set","has","delete","clear","size","length","call","apply","bind"]);async function Ja(n){let{repoPath:e,filePath:r,symbolName:i}=ot(n);if(!r)return{isError:!0,content:[{type:"text",text:"Error: 'filePath' is required."}]};let t=r;await Q(e);let o=z.getInstance(e);if(!Hi.existsSync(t))return{isError:!0,content:[{type:"text",text:`File not found: ${t}`}]};let s,a=ft.basename(t),c;if(i){let p=o.exports.findByNameAndFile(i,t);if(p.length>0){let m=p[0];s={start:m.start_line,end:m.end_line},a=m.name,c=m.start_line}}let l={type:s?"function":"file",name:a,path:ft.relative(e,t),line:c,children:[]},u=new Set;u.add(t+(i?`:${i}`:""));let d={count:0,truncated:!1};return await Or(t,l,e,o,u,1,d,s),d.truncated&&l.children.push({type:"function",name:"\u26A0\uFE0F Output Truncated",details:`Trace limited to ${Wi} nodes. Use summarize_file on specific files for deeper analysis.`,children:[]}),{content:[{type:"text",text:JSON.stringify(l,null,2)}]}}async function Or(n,e,r,i,t,o,s,a){if(!(o>jk)){if(s.count>=Wi){s.truncated=!0;return}try{let c=Hi.readFileSync(n,"utf8"),l=ft.extname(n).toLowerCase(),d=(c.match(/import\s+[\s\S]*?from\s+['"].*?['"];?/gm)||[]).join(`
857
+ `);a&&(c=c.split(`
858
+ `).slice(a.start-1,a.end).join(`
859
+ `));let p;if(l===".ts"||l===".tsx"||l===".js"||l===".jsx"){p=new er;let _={syntax:"typescript",tsx:n.endsWith(".tsx"),target:"es2020"};try{let v=a?`${d}
860
+ ${c}`:c,y=await Bb.parse(v,_);p.visitModule(y)}catch{if(a)try{let y=`${d}
861
+ class TraceContext {
862
+ ${c}
863
+ }`,k=await Bb.parse(y,_);p.visitModule(k)}catch{let k=new Yt,$=l;k.visit(c,$),p.calls=k.calls,p.apiCalls=k.apiCalls,p.imports=k.imports}else{let y=new Yt;y.visit(c,l),p.calls=y.calls,p.apiCalls=y.apiCalls,p.imports=y.imports}}}else p=new Yt,p.visit(c,l);x.info({file:ft.basename(n),calls:p.calls.size,apiCalls:p.apiCalls.length,depth:o},"Analyzed file");let m=p.apiCalls.slice(0,10);for(let _ of m){if(s.count>=Wi)break;if(s.count++,_.method==="PUBSUB"){let $={type:"event_trigger",name:`PubSub Event: ${_.url}`,details:"Detected via PubSub client usage",children:[]};e.children.push($);let w=i.exports.findByNameGlobal(_.url).concat(i.exports.findByMethodName(_.url));if(_.url.length>10){let P=_.url.replace(/To[A-Z][a-zA-Z]+$/,"");if(P!==_.url){let R=i.exports.findByNameGlobal(P).concat(i.exports.findByMethodName(P));w.push(...R)}}let I=new Set;for(let P of w){if(I.has(P.file_path)||P.file_path===n)continue;if(I.add(P.file_path),s.count>=Wi)break;s.count++;let R={type:"subscriber",name:`${P.name} (${ft.basename(P.file_path)})`,path:ft.relative(r,P.file_path),line:P.start_line,details:"Potential Subscriber / Handler",children:[]};$.children.push(R),Hi.existsSync(P.file_path)&&!t.has(P.file_path)&&(t.add(P.file_path),await Or(P.file_path,R,r,i,t,o+1,s))}continue}let v={type:"api_call",name:`${_.method} ${_.url}`,details:"Detected via string literal analysis",children:[]};e.children.push(v);let k=Vm(i,_.url).slice(0,Uk);for(let $ of k){if(s.count>=Wi)break;s.count++;let w={type:"route",name:$.signature||"Route Handler",path:$.file_path,line:$.start_line,children:[]};if(v.children.push(w),Hi.existsSync($.file_path)&&!t.has($.file_path)&&(t.add($.file_path),await Or($.file_path,w,r,i,t,o+1,s)),$.capabilities)try{let I=JSON.parse($.capabilities);if(I.handler){let[P,R]=I.handler.split("@");if(P){let T=P.split("\\").pop();if(T){let A=i.exports.findClassByName(T);if(A){let H=i.exports.findByNameAndFile(R||"",A.file_path),J,M=A.start_line;H.length>0&&(J={start:H[0].start_line,end:H[0].end_line},M=H[0].start_line);let N={type:"component",name:`${T}${R?" :: "+R:""}`,path:ft.relative(r,A.file_path),line:M,details:"Controller Logic (Macro IR)",children:[]};w.children.push(N),t.has(A.file_path+(R?`:${R}`:""))||(t.add(A.file_path+(R?`:${R}`:"")),await Or(A.file_path,N,r,i,t,o+1,s,J))}}}}}catch{}}}let f=p.calls,h=Array.from(f).sort();for(let _ of h)if(p.imports.has(_)){let v=p.imports.get(_);if(!v.startsWith(".")){if(["react","react-dom"].includes(v))continue;e.children.push({type:"function",name:_,details:`External: ${v}`,children:[]});continue}let y=qt(v,n,r);if(y&&Hi.existsSync(y))if(t.has(y))e.children.push({type:"function",name:_,details:"Circular / Already Visited",path:ft.relative(r,y),children:[]});else{t.add(y);let k={type:"file",name:_,details:`Imported from ${ft.basename(y)}`,path:ft.relative(r,y),children:[]};e.children.push(k),await Or(y,k,r,i,t,o+1,s)}}else if(!["log","info","error","warn","print"].includes(_)){let v=i.exports.findByNameGlobal(_);if(v.length===0){let y=_.split(/(?:\.|->|::)+/);if(y.length>1){let k=y[y.length-1];Fk.has(k)||(v=i.exports.findByMethodName(k))}}if(v.length>0){let y=v.find($=>$.file_path===n),k=y||(v.length===1?v[0]:null);if(k){let $=`${k.file_path}:${k.name}`;if(!t.has($)){t.add($);let w={type:"component",name:_,details:`Resolved via global index${y?" (local)":""}`,path:ft.relative(r,k.file_path),line:k.start_line,children:[]};e.children.push(w),await Or(k.file_path,w,r,i,t,o+1,s,{start:k.start_line,end:k.end_line})}}}}}catch(c){x.error({filePath:n,error:c.message},"Trace analysis failed"),e.children.push({type:"function",name:"Error",details:c.message,children:[]})}}}X();import Gb from"path";async function qb(n){let{repoPath:e,filePath:r,direction:i,limit:t,offset:o=0}=n;await Q(e);let{imports:s}=z.getInstance(e);if(i==="imports"){let c=s.findByFile(r).map(p=>{let m={module:p.module_specifier,symbols:p.imported_symbols,resolvedPath:p.resolved_path,relativePath:p.resolved_path?Gb.relative(e,p.resolved_path):null,isExternal:!p.resolved_path};if(!p.resolved_path){let f=Eo(p.module_specifier,r,e);if(!f.resolved)return{...m,resolutionError:f.error,suggestion:f.suggestion}}return m}),l=[...c].sort((p,m)=>(p.relativePath||"").localeCompare(m.relativePath||"")),d={results:Jb(l,t,o),total:c.length,offset:o,limit:t||c.length,hasMore:t?o+t<c.length:!1};return{content:[{type:"text",text:JSON.stringify(d,null,2)}]}}else{let c=s.findDependents(r).map(p=>({file:p.file_path,relativePath:Gb.relative(e,p.file_path),importStatement:p.module_specifier,importedSymbols:p.imported_symbols})),l=[...c].sort((p,m)=>(p.relativePath||"").localeCompare(m.relativePath||"")),d={results:Jb(l,t,o),total:c.length,offset:o,limit:t||c.length,hasMore:t?o+t<c.length:!1};return{content:[{type:"text",text:JSON.stringify(d,null,2)}]}}}function Jb(n,e,r=0){return e?n.slice(r,r+e):n.slice(r)}X();import Vb from"path";import Zk from"fs";async function Kb(n){let{repoPath:e,mode:r,limit:i=50,includeMigrations:t=!1,includeFixtures:o=!1,excludePatterns:s=[],confidenceThreshold:a="all"}=n;await Q(e);let{exports:c,imports:l}=z.getInstance(e);if(r==="dead-code"){let p=c.findDeadExports({limit:i,includeTests:!0,includeMigrations:t,includeFixtures:o,excludePatterns:s,confidenceThreshold:a}).map(y=>({name:y.name,kind:y.kind,file:Vb.relative(e,y.file_path),line:y.start_line,confidence:y.confidence,reason:y.reason})),m={high:{},medium:{},low:{}};for(let y of p)m[y.confidence][y.file]||(m[y.confidence][y.file]=[]),m[y.confidence][y.file].push({name:y.name,kind:y.kind,line:y.line,reason:y.reason});let f=[],h=Object.values(m.high).flat().length,_=Object.values(m.medium).flat().length,v=Object.values(m.low).flat().length;return f.push(`# Dead Export Analysis
864
+ `),f.push(`Found ${p.length} potentially unused exports.`),f.push(`- **High confidence** (likely dead): ${h}`),f.push(`- **Medium confidence** (possibly intentional): ${_}`),f.push(`- **Low confidence** (likely intentional): ${v}
865
+ `),h>0&&(f.push(`## High Confidence (Likely Dead)
866
+ `),f.push(JSON.stringify(m.high,null,2))),_>0&&a!=="high"&&(f.push(`
867
+ ## Medium Confidence (Possibly Intentional)
868
+ `),f.push(JSON.stringify(m.medium,null,2))),v>0&&a==="all"&&(f.push(`
869
+ ## Low Confidence (Likely Intentional)
870
+ `),f.push(JSON.stringify(m.low,null,2))),{content:[{type:"text",text:f.join(`
871
+ `)}]}}else if(r==="circular-deps"){let v=function(w,I){if(f.length>=d)return!1;h.add(w),_.add(w),I.push(w);let P=m.get(w)||new Set;for(let R of P)if(h.has(R)){if(_.has(R)){let F=I.indexOf(R);if(F>=0){let T=I.slice(F);T.push(R),f.push(T)}}}else if(v(R,[...I]))return!0;return _.delete(w),!1};var u=v;let d=typeof i=="number"?i:20,p=l.getAllResolved(),m=new Map;for(let w of p)m.has(w.file_path)||m.set(w.file_path,new Set),m.get(w.file_path).add(w.resolved_path);let f=[],h=new Set,_=new Set;for(let w of m.keys())!h.has(w)&&f.length<d&&v(w,[]);let y=[],k=new Map;for(let w of p){let I=`${w.file_path}|${w.resolved_path}`;k.has(I)||k.set(I,[]),k.get(I).push(w)}for(let w of f){let I=!1;for(let P=0;P<w.length-1;P++){let R=w[P],F=w[P+1],T=k.get(`${R}|${F}`);if(T){for(let A of T)try{let H=Zk.readFileSync(R,"utf8"),J=A.module_specifier.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),M=new RegExp(`import\\s+type\\s+.*from\\s+['"]${J}['"]`,"i"),N=new RegExp(`import\\s+\\{.*type\\s+.*\\}.*from\\s+['"]${J}['"]`,"s");if(M.test(H)||N.test(H)){I=!0;break}let W=A.imported_symbols.split(",").map(q=>q.trim());for(let q of W){if(!q||q==="*")continue;let Z=q.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(new RegExp(`\\(\\s*\\)\\s*=>\\s*${Z}`).test(H)){I=!0;break}}}catch{}if(I)break}}I||y.push(w)}let $=y.map((w,I)=>({id:I+1,length:w.length-1,chain:w.map(P=>Vb.relative(e,P))}));return{content:[{type:"text",text:`# Circular Dependency Analysis
872
+
873
+ Found ${y.length} circular dependency chain(s).
874
+
875
+ ${JSON.stringify($,null,2)}`}]}}return{isError:!0,content:[{type:"text",text:"Invalid mode"}]}}async function Yb(n){let{repoPath:e,subPath:r,maxDepth:i=5}=n,t=5e4,o=[{level:"signatures",depth:i},{level:"summaries",depth:i,meta:{warning:"Export lists omitted for token efficiency.",action:"Use 'shadow_inspect_file' on specific files to see exports."}},{level:"structure",depth:i,meta:{warning:"Detailed signatures omitted due to repo size.",action:"Use 'shadow_inspect_file' on specific files to see details."}},{level:"summaries",depth:2,meta:{warning:"Repository is large. Showing top 2 levels with summaries only.",action:"Use 'shadow_recon_tree' with a 'subPath' to explore deeper."}},{level:"structure",depth:2,meta:{warning:"Repository is large. Showing top 2 levels structure only.",action:"Use 'shadow_recon_tree' with a 'subPath' to explore."}},{level:"lite",depth:1,meta:{warning:"Repository is massive. Showing root files only.",action:"Use 'shadow_recon_tree' with a 'subPath' to explore."}}];for(let s of o){let a=await Tn(e,5,s.level,r,s.depth);s.meta&&(a._meta=s.meta);let c=JSON.stringify(a,null,2);if(c.length<=t)return{content:[{type:"text",text:c}]}}return{content:[{type:"text",text:`Warning: The repository at ${r||"root"} is massive (exceeds ${t} chars even at minimal depth).
876
+ Please use 'shadow_recon_tree' with a more specific 'subPath' or use 'shadow_search_symbol' to find what you need.`}]}}He();async function Xb(n){let{repoPath:e,compact:r=!1}=n,t=new le(e).getSnapshot();if(r&&t.gravity?.hotspots){let o=t.gravity.hotspots.length;t={...t,gravity:{...t.gravity,hotspots:t.gravity.hotspots.slice(0,20),_truncated:o>20,_totalHotspots:o}}}return{content:[{type:"text",text:JSON.stringify(t,null,2)}],suggestedNext:{tool:"shadow_ops_chronicle",reason:"Recent decisions and ADRs"}}}X();_t();He();function Qb(n){switch(n){case"Entry":return"\u{1F6AA}";case"Logic":return"\u2699\uFE0F";case"Data":return"\u{1F4BE}";case"Utility":return"\u{1F527}";case"Infrastructure":return"\u{1F3D7}\uFE0F";case"Test":return"\u{1F9EA}";case"Types":return"\u{1F4DD}";case"Unknown":return"\u2753"}}async function e_(n){let{repoPath:e}=n;await Q(e);let r=z.getInstance(e),i=Ze(r,e);new le(e).updateTopography(i);let o=["Entry","Logic","Data","Utility","Infrastructure","Test","Types","Unknown"],s=`# \u{1F3D7}\uFE0F Architecture Summary
877
+
878
+ `;if(s+=`## Detected Pattern: **${i.pattern}**
879
+ `,s+=`Confidence: ${i.patternConfidence.toFixed(0)}%
880
+
881
+ `,i.insights.length>0){s+=`## Insights
882
+ `;for(let c of i.insights)s+=`- ${c}
883
+ `;s+=`
884
+ `}s+=`## Layer Distribution
885
+
886
+ `,s+=`| Layer | Files | % of Total |
887
+ `,s+=`|-------|------:|:----------:|
888
+ `;let a=o.reduce((c,l)=>c+i.layers[l].count,0);for(let c of o){let l=i.layers[c],u=a>0?(l.count/a*100).toFixed(1):"0.0",d=Qb(c);s+=`| ${d} ${c} | ${l.count} | ${u}% |
889
+ `}s+=`
890
+ ## Top Files by Layer
891
+
892
+ `;for(let c of o){let l=i.layers[c];if(l.count===0)continue;let u=Qb(c);if(s+=`### ${u} ${c} (${l.count} files)
893
+ `,l.topFiles.length>0)for(let d of l.topFiles)s+=`- \`${d.path}\` (${d.confidence}% conf)
894
+ `,d.signals.length>0&&(s+=` - ${d.signals.join("; ")}
895
+ `);else s+=`- _No files classified with high confidence_
896
+ `;s+=`
897
+ `}return s+=`---
898
+ `,s+=`**Next Steps:**
899
+ `,s+="- Use `shadow_inspect_file` to explore files in each layer\n",s+="- Use `shadow_analyze_flow` to trace execution from Entry \u2192 Logic \u2192 Data\n",s+="- Use `shadow_analyze_deps` to understand layer boundaries\n",{content:[{type:"text",text:s}],suggestedNext:{tool:"shadow_recon_tree",reason:"Explore a subPath or use shadow_inspect_file"}}}X();_t();He();import Ut from"path";async function qa(n){let{repoPath:e}=n;await Q(e);let r=z.getInstance(e),i=Ze(r,e),o=new le(e).getSnapshot(),s=[],a=[],c=Object.values(i.layers.Entry.topFiles).map(p=>p.path),l=new Set(Object.values(i.layers.Data.topFiles).map(p=>p.path));for(let p of c){let m=Ut.isAbsolute(p)?p:Ut.join(e,p),f=r.imports.findByFile(m);for(let h of f)h.resolved_path&&l.has(Ut.relative(e,h.resolved_path))&&s.push(`\u2694\uFE0F LAYER BYPASS: \`${Ut.relative(e,p)}\` directly imports Data layer \`${Ut.relative(e,h.resolved_path)}\`. Should go through Logic.`)}let u=o.gravity?.hotspots||[];for(let p of u){let m=Xn(p.filePath,r);(m.layer==="Utility"||m.layer==="Unknown")&&p.gravity>50&&a.push(`\u{1F6A8} GRAVITY ANOMALY: \`${Ut.relative(e,p.filePath)}\` has high gravity (${p.gravity.toFixed(0)}) but is classified as ${m.layer}. Consider promoting to Core Logic.`)}for(let p of c){let m=Ut.isAbsolute(p)?p:Ut.join(e,p),f=r.exports.findByFile(m);f.length>10&&a.push(`\u{1F388} ENTRY BLOAT: \`${Ut.relative(e,p)}\` exports ${f.length} symbols. Entry handlers should be thin interfaces.`)}let d=`# \u{1F575}\uFE0F Architectural Scout Report
900
+
901
+ `;return s.length===0&&a.length===0?d+=`\u2705 No significant architectural drift detected. The structure remains "Legit".
902
+ `:(s.length>0&&(d+=`## \u274C Structural Violations
903
+ `,s.forEach(p=>d+=`- ${p}
904
+ `),d+=`
905
+ `),a.length>0&&(d+=`## \u26A0\uFE0F Architectural Warnings
906
+ `,a.forEach(p=>d+=`- ${p}
907
+ `),d+=`
908
+ `)),{content:[{type:"text",text:d}]}}X();G();import Et from"path";He();_t();async function t_(n){let{repoPath:e}=n;x.info({repoPath:e},"Setting up repository..."),x.info({repoPath:e}," Ensuring index is up-to-date...");let r=Date.now();await Q(e,void 0,!1,!0,V=>{let ne=V.total>0?Math.round(V.current/V.total*100):0;x.info({phase:V.phase,progress:`${V.current}/${V.total}`,percentage:`${ne}%`},V.message||`Indexing progress: ${V.phase}`)});let t=((Date.now()-r)/1e3).toFixed(1);x.info({repoPath:e,indexTime:`${t}s`}," Index check complete"),await bn();let o=z.getInstance(e);x.info({repoPath:e},"Populating Project Hologram...");let s=new le(e),a=Ze(o,e);s.updateTopography(a);let c=s.computeGravityZones();s.updateGravityZones(c),x.info({repoPath:e,sections:2},"Project Hologram populated (topography + gravity)");let l=o.files.getCount(),u=o.exports.getCount(),d=o.configs.getAll(),p=o.files.getTopDirectories(e),m=[],f=[],h="Standalone",_=V=>o.files.findPackageJsonChildren(V),v=V=>{let ne=Et.join(V,"package.json"),pe=d.filter(B=>B.file_path===ne),ye=[],de=B=>pe.some(Me=>Me.key.startsWith("dep: ")&&Me.key.includes(B));de("react")&&ye.push("React"),de("vue")&&ye.push("Vue"),de("next")&&ye.push("Next.js"),de("fastify")&&ye.push("Fastify"),de("express")&&ye.push("Express"),de("nestjs")&&ye.push("NestJS"),(de("prisma")||de("typeorm"))&&ye.push("DB");let K=pe.find(B=>B.key==="description")?.value||"";return{stack:ye.join(", "),description:K.length>80?K.substring(0,77)+"...":K}},y=Et.join(e,"apps"),k=Et.join(e,"packages"),$=Et.join(e,"services"),w=o.files.hasFilesPattern(y+"/%"),I=o.files.hasFilesPattern(k+"/%"),P=o.files.hasFilesPattern($+"/%"),R=(V,ne)=>{let pe=_(V);pe.length>0&&(m.push(`| **${ne}/ (Directory)** | \uFE0F **DO NOT SUMMARIZE FULL DIR** | |`),pe.forEach(ye=>{let de=Et.dirname(ye.path),K=Et.basename(de);if(K.startsWith("_")||K.includes("template"))return;let B=Et.relative(e,de),Me=v(de);m.push(`| \u2514\u2500 \`${B}\` | ${Me.stack||"Module"} | ${Me.description} |`),f.push(B)}))};w||I||P?(h="Monorepo",R(y,"apps"),R($,"services"),R(k,"packages")):p.forEach(V=>{let ne=V.root;if(!ne||ne.startsWith("."))return;let pe=v(Et.join(e,ne));m.push(`| \`${ne}/\` | ${pe.stack||"Module"} | ${pe.description} |`)});let F=Et.join(e,"package.json"),A=d.find(V=>V.key==="name"&&V.kind==="Service"&&V.file_path===F)?.value||Et.basename(e),H=d.filter(V=>V.kind==="Service"&&(V.key.startsWith("service:")||V.file==="docker-compose.yml")),J=[...new Set(H.map(V=>V.value).filter(V=>V&&typeof V=="string"&&!V.includes("[object Object]")&&!["postgres","redis","db","worker","undefined"].includes(V.toLowerCase())))],M=J.slice(0,5),N=M.length>0?`Service Cluster: ${M.join(", ")}${J.length>5?` (+${J.length-5} others)`:""}`:"",W=l<100?"small":"large",q=W==="small"?"You can safely use `shadow_recon_tree` to view the full tree.":' **AVOID summarizing large directories like `apps/` or `services/` as a whole.**\n Instead, look for a specific component in the map below and use `shadow_recon_tree({ subPath: "apps/my-app" })` on it.\n\uFE0F **Prefer Search:** Use `shadow_search_symbol` for directly finding symbols.',Z="";try{let ne=new Pe(e).detectAndRepairShifts(),pe=new Ct(e),ye=o.missions.findLastMission();pe.analyzeGhostChanges(ye?.commit_sha||void 0),o.intentLogs.countByType("heritage")===0&&new In(e).analyzeHeritage(20);let K=o.intentLogs.countByType("heritage"),B=o.intentLogs.countByType("discovery");K>0||B>0||ne.repaired>0?Z=`
909
+ ## Shadow Engine Insights
910
+ `+(K>0?`* **Architectural Heritage**: Bootstrapped ${K} significant historical moves.
911
+ `:"")+(B>0?`* **Recent Changes**: Detected ${B} external modifications.
912
+ `:"")+(ne.repaired>0?`* **Symbol Healing**: Automatically repaired ${ne.repaired} orphaned intent links.
913
+ `:""):Z=`
914
+ ## Shadow Engine Status: **Active**
915
+ * **Integrity**: Git River matches Symbol Index.
916
+ * **Heritage**: Ready to track developer intent.
917
+ `}catch(V){Z=`
918
+ ## Shadow Engine Status: **Offline**
919
+ * Error: ${V instanceof Error?V.message:"Unknown"}
920
+ `}try{let ne=new Pn(e).runMaintenance();(ne.pruning.deleted>0||ne.pruning.converted>0)&&(Z+=`
921
+ ### Clean Sweep Cycle
922
+ * **Pruned**: ${ne.pruning.deleted} orphaned logs deleted, ${ne.pruning.converted} converted to lapsed.
923
+ `+(ne.compaction.eligible>0?`* **Compaction**: ${ne.compaction.eligible} cold missions eligible for briefing synthesis.
924
+ `:""))}catch(V){x.warn({error:V},"Metabolism maintenance failed")}let U="";try{let V=o.missions.findActiveByPriority();V?U=`
925
+ ## Active Mission: **${V.name}** (#${V.id})
926
+ * Use \`shadow_ops_briefing\` to resume context.
927
+ `:U=`
928
+ ## Mission Status: **Idle**
929
+ * No active mission. Use \`shadow_ops_plan\` to begin task tracking.
930
+ `}catch{}return{content:[{type:"text",text:`
931
+ # Repository Indexed: ${A}
932
+
933
+ \u23F1\uFE0F **Initial deep index completed in ${t}s** (one-time operation - future syncs are instant)
934
+
935
+ ## \u{1F3D7}\uFE0F Architecture: ${h}
936
+ ${N?`> ${N}
937
+ `:""}
938
+
939
+ ${Z}
940
+ ${U}
941
+
942
+ This is a ${W} repository with ${l} files.
943
+
944
+ ## System Overview
945
+ | Statistic | Value |
946
+ |-----------|-------|
947
+ | Total Files | ${l} |
948
+ | Exported Symbols | ${u} |
949
+ | Primary Stack | ${a.primaryStack} |
950
+
951
+ ## Component Map
952
+ | Component | Tech Stack | Description |
953
+ |-----------|------------|-------------|
954
+ ${m.length>20?m.slice(0,20).join(`
955
+ `)+`
956
+ | ... | ... | (*${m.length-20} more components hidden*) |`:m.join(`
957
+ `)}
958
+
959
+ ## Recommended Exploration Strategy
960
+ ${q}
961
+
962
+ ## \uFE0F Quick Reference
963
+ | Goal | Tool | Example |
964
+ |------|------|---------|
965
+ | Search for code | \`shadow_search_symbol\` | \`shadow_search_symbol({ query: "ProductController" })\` |
966
+ | Explore a *specific* component | \`shadow_recon_tree\` | \`shadow_recon_tree({ subPath: "apps/admin" })\` |
967
+ | Trace data flow | \`shadow_analyze_flow\` | \`shadow_analyze_flow({ filePath: "apps/admin/src/Admin.tsx" })\` |
968
+ | Find config/env | \`shadow_search_config\` | \`shadow_search_config({ key: "DATABASE_URL" })\` |
969
+
970
+ ---
971
+ **Ready.** What would you like to investigate first?
972
+ `}]}}X();import n_ from"path";import Hk from"fs";function Wk(n,e,r){let i=n.split(`
973
+ `),t=[],o=0;for(let d=0;d<Math.min(i.length,50);d++){let p=i[d].trim();if(p.startsWith("import ")||p.startsWith("from ")||p.startsWith("export ")&&p.includes(" from "))o=d+1;else if(p&&!p.startsWith("//")&&!p.startsWith("/*")&&!p.startsWith("*")&&p!==""&&o>0)break}o>0&&(t.push(...i.slice(0,o)),t.push(""));let s=[...r].sort((d,p)=>d.startLine-p.startLine),a=0,c=0;for(let d of s)if(d.isTarget){t.push(`// \u2501\u2501\u2501 REQUESTED: ${d.name} \u2501\u2501\u2501`);let p=i.slice(d.startLine-1,d.endLine);t.push(...p),t.push("// \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),t.push(""),c++}else{let p=d.signature||Bk(i,d.startLine-1,d.kind);p&&(t.push(`${p}`),t.push(` /* implementation: ${d.lineCount} lines */`),t.push(""),a++)}let l=s[s.length-1];if(l)for(let d=l.endLine;d<i.length;d++){let p=i[d].trim();if(p==="}"||p==="};"){t.push(i[d]);break}else if(p&&!p.startsWith("//"))break}return{foldedSource:t.join(`
974
+ `),totalOriginalLines:i.length,foldedToLines:t.length,siblingsShown:c,siblingsFolded:a}}function Bk(n,e,r){let i=n[e];if(r.includes("Function")||r.includes("Method")||r.includes("Arrow")){let t="";for(let o=e;o<Math.min(e+5,n.length);o++)if(t+=n[o],t.includes("{")||t.includes("=>")){let s=t.indexOf("{");s>0&&(t=t.substring(0,s).trim());break}return t.trim()}return i}async function pn(n){let{repoPath:e,filePath:r,resolver:i}=ot(n),t=String(n.symbolName),o=n.context||"definition";if(r&&!i.isWithinRoot(r))return{content:[{type:"text",text:`Error: Access denied. Path ${r} is outside the repository root.`}],isError:!0};await Q(e);let s=z.getInstance(e),a=[];if(t.includes(".")){let[I,P]=t.split(".");a=s.exports.findMemberCandidates(I,P,r)}else a=s.exports.findDefinitionCandidates(t,r);if(a.length===0){let I=s.exports.findPotentialParents(t);if(I.length>0){let T=I.map(A=>`\`${A.name}\` (in ${i.getRelative(A.file_path)})`).join(", ");return{content:[{type:"text",text:`Symbol "${t}" not found as a top-level export.
975
+ However, it likely exists inside: ${T}.
976
+ Try: shadow_inspect_symbol({ symbolName: "${I[0].name}", context: "full" }) to see the class body.`}]}}let R=s.exports.findFuzzyCandidates(t).map(T=>T.name),F=Qn(t,R,50,3);if(F.length>0){let T=F.map(A=>` \u2022 \`${A.match}\` (${A.score}% match)`).join(`
977
+ `);return{content:[{type:"text",text:`Error: Symbol "${t}" not found in the index.
978
+
979
+ Suggestions:
980
+ ${T}
981
+
982
+ Next steps:
983
+ \u2022 Search semantically: shadow_search_concept({ query: "${t}" })
984
+ \u2022 Verify repository is indexed: shadow_sync_index({ repoPath: "${e}" })`}]}}return{content:[{type:"text",text:`Error: Symbol "${t}" not found in the index.
985
+
986
+ Next steps:
987
+ \u2022 Search for it: shadow_search_concept({ query: "${t}" })
988
+ \u2022 Try with file path: shadow_inspect_symbol({ symbolName: "${t}", filePath: "..." })
989
+ `}]}}let c=a[0];if(c.kind==="ExportSpecifier"||c.kind==="ExportAllDeclaration"){let I=s.imports.findImportSource(c.file_path,t);if(I&&I.resolved_path)return pn({...n,filePath:I.resolved_path})}let l=Hk.readFileSync(c.file_path,"utf8"),u=l.split(`
990
+ `),d=c.end_line-c.start_line+1,p=150,m,f=!1,h=null;if(o==="definition"&&d>p){let P=s.exports.findSiblings(c.file_path).map(R=>({name:R.name,kind:R.kind,signature:R.signature||"",startLine:R.start_line,endLine:R.end_line,lineCount:R.end_line-R.start_line+1,isTarget:R.name===c.name&&R.start_line===c.start_line,parentName:R.parent_name}));if(P.length>1){h=Wk(l,{name:c.name,startLine:c.start_line,endLine:c.end_line},P);let R=i.getRelative(c.file_path);m=h.foldedSource+`
991
+
992
+ \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
993
+ \u{1F4CA} Semantic Fold Applied (context: "definition")
994
+
995
+ Original file: ${h.totalOriginalLines} lines
996
+ Folded view: ${h.foldedToLines} lines
997
+ Target Symbol: ${c.name}
998
+ \u{1F4A1} Need more context?
999
+ \u2022 Full symbol + dependencies + usage: shadow_inspect_symbol({ symbolName: "${c.name}", context: "full" })
1000
+ \u2022 ALL symbols in this file: shadow_inspect_file({ filePath: "${R}", detailLevel: "signatures" })
1001
+ \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501`,f=!0}else m=u.slice(c.start_line-1,c.start_line-1+p).join(`
1002
+ `)+`
1003
+
1004
+ ... (truncated ${d-p} lines)`,f=!0}else m=u.slice(c.start_line-1,c.end_line).join(`
1005
+ `);let _=c.parent_name?`${c.parent_name}.${c.name}`:c.name,v=s.exports.findHydratedById(c.id),y={name:_,kind:c.kind,file:i.getRelative(c.file_path),startLine:c.start_line,endLine:c.end_line,totalLines:d,...f&&{truncated:!0,previewLines:p},classification:c.classification,source:m};if(v&&v.recent_intents&&v.recent_intents.length>0){let I={},P=Date.now();for(let R of v.recent_intents){if(R.is_crystallized&&R.type!=="crystal")continue;let F=R.created_at;F<1e10&&(F*=1e3);let T=new Date(F).getTime(),A=P-T,H="just now";if(A>0){let J=Math.floor(A/1e3),M=Math.floor(J/60),N=Math.floor(M/60),W=Math.floor(N/24);W>0?H=`${W}d ago`:N>0?H=`${N}h ago`:M>0?H=`${M}m ago`:H=`${J}s ago`}I[R.type]||(I[R.type]=[]),I[R.type].push(`[${H}] ${R.content}`)}y.intelligence={working_set_of:v.active_missions.map(R=>`Mission #${R.id}: ${R.name}`),total_intents:v.intent_log_count,recent_activity:I}}else v&&(y.intelligence={working_set_of:v.active_missions.map(I=>`Mission #${I.id}: ${I.name}`),total_intents:v.intent_log_count,recent_activity:null});try{let{generateEmbedding:I}=await Promise.resolve().then(()=>(Nt(),Vr)),P=`Symbol: ${y.name}
1006
+ Signature: ${c.signature||""}
1007
+ File: ${y.file}`,R=await I(P);if(R){let F=s.intentLogs.findSemanticMatches(R,3,c.id),T=new Promise(H=>setTimeout(()=>H([]),100)),A=await Promise.race([F,T]);A&&A.length>0&&(y.intelligence||(y.intelligence={}),y.intelligence.related_knowledge=A.map(H=>({type:H.type,content:H.content,from_symbol:H.symbol_name,similarity:`${(H.similarity*100).toFixed(0)}%`})))}}catch{}if(o==="definition")return{content:[{type:"text",text:JSON.stringify(y,null,2)}]};let k={definition:y,dependencies:s.imports.getImportsForFile(c.file_path).map(I=>({module:I.module_specifier,symbols:I.imported_symbols,relativePath:I.resolved_path?n_.relative(e,I.resolved_path):null}))},$=[c.file_path],w=s.imports.findVerifiedDependents($,t);return k.verifiedUsages=w.slice(0,10).map(I=>({file:n_.relative(e,I.file_path),classification:I.classification,importedSymbols:I.imported_symbols})),{content:[{type:"text",text:JSON.stringify(k,null,2)}]}}X();import r_ from"path";async function Mr(n){let{repoPath:e,filePath:r}=ot(n);if(!r)return{content:[{type:"text",text:"Error: filePath is required"}],isError:!0};let i=n.detailLevel||"signatures";await Q(e);let{files:t,exports:o}=z.getInstance(e),s=t.findByPath(r),a=r_.basename(r),c=/\.(ts|tsx|php|py|go)$/.test(a),l;c?l=await Qr(r):l={exports:o.findByFile(r),imports:[]},i==="structure"?(l.exports=l.exports.map(m=>{let f={name:m.name,kind:m.kind,line:m.start_line,classification:m.classification};return m.members&&m.members.length>0?{...f,members:m.members.map(h=>({name:`${m.name}.${h.name}`,kind:h.kind,line:h.start_line}))}:f}),delete l.imports):i==="signatures"&&(l.exports=l.exports.map(m=>{let f={name:m.name,kind:m.kind,signature:m.signature,line:m.start_line,classification:m.classification,capabilities:JSON.parse(m.capabilities||"[]")};return m.members&&m.members.length>0?{...f,members:m.members.map(h=>({name:`${m.name}.${h.name}`,kind:h.kind,signature:h.signature,line:h.start_line}))}:f}),delete l.imports);let u=r_.relative(e,r),d=l.exports?.length||0,p="";return i==="structure"&&d>0?p=`
1008
+
1009
+ \u{1F4A1} Showing ${d} symbol names. For full signatures: shadow_inspect_file({ filePath: "${u}", detailLevel: "signatures" })`:i==="signatures"&&d>0&&(p=`
1010
+
1011
+ \u{1F4A1} Showing ${d} complete signatures. To inspect a specific symbol: shadow_inspect_symbol({ symbolName: "...", context: "full" })`),{content:[{type:"text",text:JSON.stringify({...l,fileDescription:s?.summary||"",classification:s?.classification||"Unknown"},null,2)+p}]}}X();_t();async function Va(n){let{repoPath:e}=n;try{await Q(e),new Ct(e).analyzeGhostChanges();let i=new Pe(e),t=i.detectAndRepairShifts(),o=i.syncLifecycle(),a=await new rt(e).recoverFromGitNotes(),{HologramService:c}=await Promise.resolve().then(()=>(He(),wg)),l=new c(e),u=Ze(z.getInstance(e),e);l.updateTopography(u);let d=l.computeGravityZones();l.updateGravityZones(d);let p="Shadow Sync complete. Code changes indexed and intent logs updated.";return p+=`
1012
+ \u269B\uFE0F Hologram: Refreshed architectural map (${d.length} hotspots).`,t.repaired>0&&(p+=`
1013
+ \u2728 Nano-Repair: Fixed ${t.repaired} links.`),a.missionsRecovered>0&&(p+=`
1014
+ \u{1F9EC} Re-hydration: Recovered ${a.missionsRecovered} missions.`),{content:[{type:"text",text:p}]}}catch(r){return{content:[{type:"text",text:`Error: ${r.message}`}],isError:!0}}}He();async function i_(n){let{repoPath:e,deep:r}=n;try{await Q(e,5,r);let i=new Pe(e),t=i.detectAndRepairShifts(),o=i.syncLifecycle(),s=new le(e);s.refreshTopography();let a=s.computeGravityZones();s.updateGravityZones(a);let c=`Repository at ${e} has been ${r?"deeply ":""}re-indexed.`;return t.repaired>0&&(c+=`
1015
+ \u2728 Nano-Repair: Fixed ${t.repaired} links.`),c+=`
1016
+ \u269B\uFE0F Hologram: Refreshed architectural map (${a.length} hotspots).`,{content:[{type:"text",text:c}]}}catch(i){return{content:[{type:"text",text:`Error: ${i.message}`}],isError:!0}}}async function o_(n){let{repoPath:e}=n;try{let i=new Pe(e).detectAndRepairShifts();return{content:[{type:"text",text:JSON.stringify(i,null,2)}]}}catch(r){return{content:[{type:"text",text:`Error tracing shifts: ${r.message}`}],isError:!0}}}G();var Km=x.child({module:"mcp:tools:env:hooks"});async function jr(n){let{repoPath:e,action:r,enableAutoRefresh:i,enableSymbolHealing:t}=n;if(r==="install"){Km.info({repoPath:e,enableAutoRefresh:i,enableSymbolHealing:t},"Installing git hooks");let o=gc({repoPath:e,enableAutoRefresh:i??!0,enableSymbolHealing:t??!0}),s=["# Git Hooks Installation","",`## Installed (${o.installed.length})`,o.installed.length>0?o.installed.map(a=>`- \`${a}\``).join(`
1017
+ `):"- None","",`## \u23ED\uFE0F Skipped (${o.skipped.length})`,o.skipped.length>0?o.skipped.map(a=>`- \`${a}\` (already installed)`).join(`
1018
+ `):"- None",""];return o.errors.length>0&&(s.push(`## Errors (${o.errors.length})`),s.push(o.errors.map(a=>`- ${a}`).join(`
1019
+ `)),s.push("")),s.push("---"),s.push("**What happens now?**"),(i??!0)&&s.push("- After `git pull` or `git checkout`: Index auto-refreshes in background"),(t??!0)&&s.push("- After `git commit`: Symbol shift detection runs automatically"),{content:[{type:"text",text:s.join(`
1020
+ `)}]}}if(r==="remove"){Km.info({repoPath:e},"Uninstalling git hooks");let o=yc(e),s=["# Git Hooks Uninstallation","",`## Removed (${o.removed.length})`,o.removed.length>0?o.removed.map(a=>`- \`${a}\``).join(`
1021
+ `):"- None",""];return o.errors.length>0&&(s.push(`## Errors (${o.errors.length})`),s.push(o.errors.map(a=>`- ${a}`).join(`
1022
+ `))),{content:[{type:"text",text:s.join(`
1023
+ `)}]}}if(r==="status"){Km.info({repoPath:e},"Checking git hooks status");let o=zt(e);return{content:[{type:"text",text:["# Git Hooks Status","",`## Installed (${o.installed.length})`,o.installed.length>0?o.installed.map(a=>`- \`${a}\``).join(`
1024
+ `):"- None","",`## Not Installed (${o.notInstalled.length})`,o.notInstalled.length>0?o.notInstalled.map(a=>`- \`${a}\``).join(`
1025
+ `):"- None","","---",'**To install hooks**: Use `shadow_env_hooks({ action: "install" })`'].join(`
1026
+ `)}]}}return{content:[{type:"text",text:`Unknown action: ${r}`}],isError:!0}}st();import Ka from"path";import s_ from"fs";G();var Gk=x.child({module:"mcp:tools:env:diagnose"});async function a_(n){let{repoPath:e}=n,r=Ka.isAbsolute(e)?Ka.normalize(e):Ka.resolve(process.cwd(),e);Gk.info({repoPath:r},"Running MCP diagnose");let i=["# MCP Server Health Check","",`**Repository path**: \`${r}\``,""],t=!1;try{t=s_.statSync(r).isDirectory()}catch{}i.push("## 1. Path"),i.push(t?"\u2705 Directory exists":"\u274C Path missing or not a directory"),i.push("");let o=Ka.join(r,".git"),s=t&&s_.existsSync(o);i.push("## 2. Git repository"),i.push(s?"\u2705 `.git` found":"\u274C Not a Git repository (or path invalid)"),i.push("");let a=!1,c=!1;if(t)try{je(r),a=!0,c=De(r)}catch{}i.push("## 3. Database & index"),i.push(a?"\u2705 Database connected":"\u274C Database not available"),i.push(c?"\u2705 Repository indexed":"\u26A0\uFE0F Not indexed yet"),i.push("");let l=t?zt(r):{installed:[],notInstalled:[]};return i.push("## 4. Git hooks"),i.push(l.installed.length>0?`\u2705 Installed: ${l.installed.join(", ")}`:"\u26A0\uFE0F No Shadow hooks installed"),i.push(""),i.push("## 5. Next steps"),t?c?i.push("- Index is ready. Use shadow_search_*, shadow_inspect_*, shadow_analyze_*."):i.push("- Run **shadow_recon_onboard** to populate the index."):i.push("- Use a valid repository path."),{content:[{type:"text",text:i.join(`
1027
+ `)}]}}X();G();import Jk from"path";import qk from"fs";var c_=x.child({module:"mcp:tools:workspace:list"});async function Ya(n){let{repoPaths:e,status:r,limit:i,summarize:t=!1}=n;c_.info({repoCount:e.length,status:r,summarize:t},"Getting workspace missions");let o=[];for(let a of e)if(qk.existsSync(a))try{let{missions:c}=z.getInstance(a),l=c.findAll(r);for(let u of l){let d=c.getLinks(u.id);o.push({...u,repo_path:a,repo_name:Jk.basename(a),cross_repo_links:d})}}catch(c){c_.error({error:c,repoPath:a},"Failed to query repo missions")}if(o.sort((a,c)=>{let l=p=>p==="in-progress"?0:p==="verifying"?1:2,u=l(a.status),d=l(c.status);return u!==d?u-d:(a.created_at||0)-(c.created_at||0)}),t||o.length>50&&!i){let a=i||20,c=o.slice(0,a),l=o.reduce((d,p)=>(d[p.status]=(d[p.status]||0)+1,d),{}),u=o.reduce((d,p)=>(d[p.repo_name]=(d[p.repo_name]||0)+1,d),{});return{content:[{type:"text",text:JSON.stringify({summary:{total_missions:o.length,by_status:l,by_repo:u,showing_top:a},top_missions:c,hint:`Showing top ${a} of ${o.length} missions. Use limit to adjust or summarize:false for full list.`},null,2)}]}}let s=i?o.slice(0,i):o;return{content:[{type:"text",text:JSON.stringify({total_missions:o.length,showing:s.length,missions:s},null,2)}]}}X();G();var Vk=x.child({module:"mcp:tools:workspace:link"});async function Xa(n){let{parentRepoPath:e,parentMissionId:r,childRepoPath:i,childMissionId:t,relationship:o="related"}=n;Vk.info({parentRepoPath:e,childRepoPath:i},"Linking cross-repo missions");let{missions:s}=z.getInstance(e),{missions:a}=z.getInstance(i);try{let c=s.findById(r),l=a.findById(t);if(!c)throw new Error(`Parent mission ${r} not found`);if(!l)throw new Error(`Child mission ${t} not found`);return s.createLink(r,i,t,o,"parent"),a.createLink(t,e,r,o,"child"),{content:[{type:"text",text:JSON.stringify({status:"linked",relationship:o},null,2)}]}}catch(c){throw new Error(`Failed to link: ${c.message}`)}}G();var Kk=x.child({module:"mcp:tools:workspace:fuse"});async function Qa(n){let{repoPaths:e,name:r}=n;Kk.info({repoCount:e.length,name:r},"Creating fused workspace index");try{let i=Uc({repoPaths:e,name:r||`workspace-${Date.now()}`});return{content:[{type:"text",text:JSON.stringify({message:"Fused index created",status:i.getStatus()},null,2)}]}}catch(i){throw new Error(`Failed to fuse: ${i.message}`)}}var Ym=g.object({repoPath:g.string(),name:g.string().optional(),goal:g.string().optional(),strategy:g.string().optional(),missionId:g.number().optional(),parentId:g.number().optional(),outcomeContract:g.string().optional(),templateId:g.string().optional(),templateVars:g.record(g.string(),g.string()).optional()}),Xm=g.object({repoPath:g.string(),missionId:g.number(),stepId:g.string().optional(),status:g.enum(["pending","in-progress","completed","failed","skipped"]).optional(),contextPivot:g.string().optional(),updates:g.array(g.object({stepId:g.string(),status:g.enum(["pending","in-progress","completed","failed","skipped"]),contextPivot:g.string().optional()})).optional(),artifacts:g.array(g.object({type:g.string(),identifier:g.string(),metadata:g.record(g.string(),g.any()).optional()})).optional()}),Qm=g.object({repoPath:g.string(),missionId:g.number().optional(),scope:g.enum(["mission","project"]).optional(),altitude:g.enum(["orbit","atmosphere","ground"]).optional(),activeMissionsLimit:g.number().int().positive().optional(),recentActivityLimit:g.number().int().positive().optional(),compact:g.boolean().optional()}),ef=g.object({repoPath:g.string(),missionId:g.number().optional(),type:g.enum(["decision","blocker","discovery","fix"]),content:g.string(),filePath:g.string().optional(),symbolName:g.string().optional(),standalone:g.boolean().optional()}),tf=g.object({repoPath:g.string(),missionId:g.number()}),nf=g.object({repoPath:g.string(),format:g.enum(["markdown","json"]).optional(),limit:g.number().optional(),offset:g.number().optional(),since:g.number().optional(),until:g.number().optional()}),rf=g.object({repoPath:g.string()}),of=g.object({repoPath:g.string(),compact:g.boolean().optional()}),sf=g.object({repoPath:g.string(),missionId:g.number().optional(),symbolId:g.number().optional()}),af=g.object({repoPath:g.string(),missionId:g.number().optional(),depth:g.number().optional(),limit:g.number().optional(),format:g.enum(["mermaid","json"]).optional()}),l_=g.object({repoPath:g.string(),filePaths:g.array(g.string())}),cf=g.object({repoPath:g.string(),subPath:g.string().optional(),maxDepth:g.number().int().optional()}),lf=g.object({repoPath:g.string(),compact:g.boolean().optional()}),uf=g.object({repoPath:g.string()}),df=g.object({repoPath:g.string()}),pf=g.object({repoPath:g.string()}),mf=g.object({repoPath:g.string(),query:g.string(),limit:g.number().int().optional(),offset:g.number().int().optional(),compact:g.boolean().optional(),fileType:g.string().optional(),layer:g.enum(["Solid","Liquid","Virtual","Intel","Phantom"]).optional()}),ff=g.object({repoPath:g.string(),query:g.string(),limit:g.number().int().optional(),offset:g.number().int().optional(),fileType:g.string().optional(),layer:g.enum(["Solid","Liquid","Virtual","Intel","Phantom"]).optional(),matchMode:g.enum(["any","all","exact"]).optional()}),hf=g.object({repoPath:g.string(),query:g.string().optional(),key:g.string().optional(),kind:g.enum(["Service","Image","Port","Env"]).optional(),limit:g.number().int().optional(),showUsage:g.boolean().optional()}),gf=g.object({repoPath:g.string(),query:g.string(),limit:g.number().int().optional(),offset:g.number().int().optional(),fileType:g.string().optional(),layer:g.enum(["Solid","Liquid","Virtual","Intel","Phantom"]).optional(),ranked:g.boolean().optional()}),yf=g.object({repoPath:g.string(),filePath:g.string().optional(),symbolName:g.string(),depth:g.number().int().optional(),limit:g.number().int().positive().optional(),offset:g.number().int().nonnegative().optional()}),vf=g.object({repoPath:g.string(),filePath:g.string(),symbolName:g.string().optional()}),bf=g.object({repoPath:g.string(),filePath:g.string(),direction:g.enum(["imports","imported_by"]),limit:g.number().int().positive().optional(),offset:g.number().int().nonnegative().optional()}),_f=g.object({repoPath:g.string(),mode:g.enum(["dead-code","circular-deps"]),limit:g.number().int().optional(),excludePatterns:g.array(g.string()).optional(),includeMigrations:g.boolean().optional(),includeFixtures:g.boolean().optional(),confidenceThreshold:g.enum(["all","high","medium"]).optional()}),xf=g.object({repoPath:g.string(),symbolName:g.string(),filePath:g.string().optional(),context:g.enum(["definition","full"]).optional()}),Sf=g.object({repoPath:g.string(),filePath:g.string(),detailLevel:g.enum(["structure","signatures","summaries","detailed"]).optional()}),$f=g.object({repoPath:g.string()}),wf=g.object({repoPath:g.string(),deep:g.boolean().optional()}),kf=g.object({repoPath:g.string()}),Ef=g.object({repoPath:g.string(),action:g.enum(["install","remove","status"]),enableAutoRefresh:g.boolean().optional(),enableSymbolHealing:g.boolean().optional()}),If=g.object({repoPath:g.string()}),Tf=g.object({repoPaths:g.array(g.string()),status:g.string().optional(),limit:g.number().int().positive().optional(),summarize:g.boolean().optional()}),Pf=g.object({parentRepoPath:g.string(),parentMissionId:g.number(),childRepoPath:g.string(),childMissionId:g.number(),relationship:g.string()}),Rf=g.object({repoPaths:g.array(g.string()),name:g.string().optional()});G();var Yk=["repoPath","filePath","subPath","path","parentRepoPath","childRepoPath"];function ec(n,e){if(!(!n||typeof n!="object"))for(let r in n)typeof n[r]=="string"?["filePath","subPath","path","repoPath","parentRepoPath","childRepoPath"].includes(r)&&(n[r]=e.resolve(n[r])):Array.isArray(n[r])?n[r].forEach(i=>ec(i,e)):typeof n[r]=="object"&&ec(n[r],e)}function u_(n){if(!(!n||typeof n!="object")){for(let e of Yk)if(typeof n[e]=="string")try{n[e]=Un(n[e])}catch(r){throw r}Array.isArray(n.repoPaths)&&(n.repoPaths=n.repoPaths.map(e=>typeof e=="string"?Un(e):e))}}function d_(n,e){return async r=>{let i=x.child({handler:n});try{u_(r)}catch(t){return i.warn({err:t},"Path sanitization failed"),dn("VALIDATION_ERROR",t.message,{})}try{if(r?.repoPath&&typeof r.repoPath=="string"){let o=new un(r.repoPath);ec(r,o)}i.info({args:r},"Handling tool call");let t=await e(r);return i.debug("Tool call successful"),t}catch(t){i.error({err:t},"Error in tool handler");let o=t.message?.includes("Access denied"),s=`Handler '${n}' failed: ${t.message}`;return!o&&r?.repoPath&&(s+=Ui),dn(o?"FORBIDDEN":"INTERNAL_ERROR",s,{stack:t.stack})}}}function p_(n,e,r){return async i=>{let t=x.child({handler:n});try{u_(i)}catch(s){return t.warn({err:s},"Path sanitization failed"),dn("VALIDATION_ERROR",s.message,{})}if(i?.repoPath&&typeof i.repoPath=="string"){let s=new un(i.repoPath);ec(i,s)}t.info({args:i},"Handling tool call with validation");let o=e.safeParse(i);if(!o.success){let s=o.error.issues.map(a=>`${a.path.length>0?`${a.path.join(".")}: `:""}${a.message}`).join(", ");return t.warn({validationIssues:o.error.issues},"Validation failed"),dn("VALIDATION_ERROR",`Validation error: ${s}`,{issues:o.error.issues})}try{let s=await r(o.data);return t.debug("Tool call successful"),s}catch(s){t.error({err:s},"Error in tool handler");let a=s.message?.includes("Access denied"),c=`Handler '${n}' failed: ${s.message}`,l=o.data;return!a&&l?.repoPath&&(c+=Ui),dn(a?"FORBIDDEN":"INTERNAL_ERROR",c,{stack:s.stack})}}}function Ur(n,e){return async r=>{let i=r.repoPath;if(!i)return n(r);let t=Fb(i,e);return t||n(r)}}var Xk={shadow_ops_plan:{default:Ca},shadow_ops_track:{default:Ma},shadow_ops_briefing:{default:Ar},shadow_ops_log:{default:Ua},shadow_ops_synthesize:{default:ja},shadow_ops_chronicle:{default:Rb},shadow_ops_context:{default:Ur(Nb,"shadow_ops_context")},shadow_ops_health:{default:Db},shadow_ops_graph:{default:Za},shadow_ops_crystallize:{default:Mb},shadow_working_set_check:{default:Ur(jb,"shadow_working_set_check")},shadow_recon_tree:{default:Yb},shadow_recon_hologram:{default:Xb},shadow_recon_topography:{default:e_},shadow_recon_scout:{default:qa},shadow_recon_onboard:{default:t_},shadow_search_concept:{default:Ba},shadow_search_symbol:{default:Fi},shadow_search_config:{default:Ga},shadow_search_path:{default:Hb},shadow_analyze_impact:{default:Wb},shadow_analyze_flow:{default:Ja},shadow_analyze_deps:{default:qb},shadow_analyze_debt:{default:Kb},shadow_inspect_symbol:{default:Ur(pn,"shadow_inspect_symbol")},shadow_inspect_file:{default:Ur(Mr,"shadow_inspect_file")},shadow_sync_trace:{default:Ur(Va,"shadow_sync_trace")},shadow_sync_index:{default:i_},shadow_sync_repair:{default:Ur(o_,"shadow_sync_repair")},shadow_env_hooks:{default:jr},shadow_env_diagnose:{default:a_},shadow_workspace_list:{default:Ya},shadow_workspace_link:{default:Xa},shadow_workspace_fuse:{default:Qa}},Qk={shadow_ops_plan:Ym,shadow_ops_track:Xm,shadow_ops_briefing:Qm,shadow_ops_log:ef,shadow_ops_synthesize:tf,shadow_ops_chronicle:nf,shadow_ops_context:of,shadow_ops_health:rf,shadow_ops_graph:af,shadow_ops_crystallize:sf,shadow_working_set_check:l_,shadow_recon_tree:cf,shadow_recon_hologram:lf,shadow_recon_topography:uf,shadow_recon_scout:df,shadow_recon_onboard:pf,shadow_search_concept:mf,shadow_search_symbol:ff,shadow_search_config:hf,shadow_search_path:gf,shadow_analyze_impact:yf,shadow_analyze_flow:vf,shadow_analyze_deps:bf,shadow_analyze_debt:_f,shadow_inspect_symbol:xf,shadow_inspect_file:Sf,shadow_sync_trace:$f,shadow_sync_index:wf,shadow_sync_repair:kf,shadow_env_hooks:Ef,shadow_env_diagnose:If,shadow_workspace_list:Tf,shadow_workspace_link:Pf,shadow_workspace_fuse:Rf},m_=new Map;for(let[n,e]of Object.entries(Xk)){let r=Qk[n];r?m_.set(n,p_(n,r,async i=>{if(e.default)return e.default(i);let t=i.mode||i.action;if(!t){let s=Object.keys(e);return{content:[{type:"text",text:`Missing required parameter "mode" or "action" for tool ${n}.
1028
+
1029
+ \u{1F4A1} Solution: Specify one of: ${s.join(", ")}`}],isError:!0}}let o=e[t];if(!o){let s=Object.keys(e);return{content:[{type:"text",text:`Invalid mode/action "${t}" for tool ${n}.
1030
+
1031
+ \u{1F4A1} Solution: Use one of these modes: ${s.join(", ")}`}],isError:!0}}return o(i)})):m_.set(n,d_(n,async i=>{if(e.default)return e.default(i);let t=i.mode||i.action;if(!t)throw new Error(`Missing mode/action for tool ${n}`);let o=e[t];if(!o)throw new Error(`Unknown mode/action '${t}' for tool ${n}`);return o(i)}))}X();lc();st();_t();He();Gm();async function f_(n,e){let r=eE.resolve(n);try{await re(async()=>{we("\u{1F311} Liquid Shadow: Topological Mapping");let i=parseInt(e.depth,10),t=await Tn(r,i,"detailed",e.subPath);console.log(` ${b.bold("Root")}: ${b.cyan(r)}`),e.subPath&&console.log(` ${b.bold("Subpath")}: ${b.yellow(e.subPath)}`),console.log("");let o=s=>({name:s.name,info:s.type==="directory"?`${s.children?.length||0} items`:s.size,color:s.type==="directory"?"blue":"white",children:s.children?.map(o)});fc([o(t)]),console.log(""),at("Mapping concluded.")})}finally{await ce(r)}}import h_ from"path";import tE from"fs";async function g_(n,e){let r=h_.resolve(n);await re(async()=>{if(we("\u{1F311} Liquid Shadow: Intelligence Deployment"),console.log(` ${b.bold("Target")}: ${b.cyan(r)}`),console.log(` ${b.bold("Objective")}: ${e.output?b.magenta("Data Extraction"):b.green("Semantic Mapping")}`),console.log(""),!e.output){let t=Ye();t.start("Engaging intelligence engines...");let o="",s=a=>{if(a.phase!==o){o=a.phase;let c={scan:"\u{1F4E1} Scanning topography",parse:"\u{1F9E9} Parsing symbols",embed:"\u{1F9E0} Generating vectors",persist:"\u{1F4BE} Hardening index",complete:"\u{1F3C1} Mapping complete"}[a.phase]||a.phase;t.message(`${c}...`)}if(a.total>0&&a.current>0){let c=Math.round(a.current/a.total*100);t.message(`${o==="parse"?"Parsing":"Processing"}: ${a.current}/${a.total} (${c}%)`)}};try{await Q(r,void 0,e.force,e.deep??!0,s),t.message("\u{1FA79} Running Nano-Repair healing...");let c=new Pe(r).detectAndRepairShifts();t.stop("Intelligence mapping successfully concluded."),console.log(""),console.log(` ${b.bold("Next Steps:")}`),console.log(` ${b.dim("view your repo stats")} -> ${b.bold(b.cyan("liquid-shadow dashboard"))}`),console.log(` ${b.dim("start a chat search")} -> ${b.bold(b.cyan('liquid-shadow search-concept "your query"'))}`),console.log(""),at("Liquid Shadow is online.")}catch(a){throw t.stop(`Operation failed: ${a.message}`),a}finally{await ce(r)}return}let i=Ye();i.start("Engaging intelligence engines...");try{let t=await Tn(r,5,e.level,e.subPath),o=h_.resolve(e.output);if((process.env.LIQUID_SHADOW_SANDBOX==="1"||process.env.LIQUID_SHADOW_SANDBOX==="true")&&!un.isPathWithinRoot(r,o))throw new Error("Sandbox mode: output path must be inside the repository. Set LIQUID_SHADOW_SANDBOX=0 to allow external paths.");tE.writeFileSync(o,JSON.stringify(t,null,2)),i.stop(`Data extraction saved: ${b.bold(b.cyan(o))}`),at("Extraction complete.")}catch(t){throw i.stop(`Extraction failed: ${t.message}`),t}finally{await ce(r)}})}import{performance as y_}from"perf_hooks";import nE from"path";X();async function v_(n){let e=nE.resolve(n);await re(async()=>{console.log(`
1032
+ ${b.bold("Performance Benchmark - Liquid Shadow Intelligence")}`),console.log(` ${b.gray("Repository: ")} ${e}`),console.log(` ${b.yellow("Starting fresh index (DB deleted)...")}
1033
+ `);let r=y_.now();try{await Q(e,10,!0);let i=y_.now()-r,t=z.getInstance(e),o=t.files.getCount(),s=t.exports.getCount(),a=t.exports.getWithEmbeddingsCount();be("Benchmark Results",`${b.bold("Total Time")}: ${i.toFixed(2)}ms (${(i/1e3).toFixed(2)}s)
1034
+ ${b.bold("Files Processed")}: ${b.cyan(o.toString())}
1035
+ ${b.bold("Symbols Extracted")}: ${b.cyan(s.toString())}
1036
+ ${b.bold("Symbols Embedded")}: ${b.cyan(a.toString())} (${(a/s*100).toFixed(1)}%)
1037
+ `+"\u2500".repeat(40)+`
1038
+ ${b.bold("Files/sec")}: ${b.green((o/(i/1e3)).toFixed(2))}
1039
+ ${b.bold("Symbols/sec")}: ${b.green((s/(i/1e3)).toFixed(2))}
1040
+ ${b.bold("ms per file")}: ${b.yellow((i/o).toFixed(2))}`,"green")}catch(i){throw console.error(`
1041
+ Benchmark failed during execution:`,i),i}finally{await ce(e)}})}import tc from"path";async function b_(n,e){let r=tc.resolve(e.dir),i=tc.isAbsolute(n)?n:tc.resolve(r,n);await re(async()=>{we("Execution Trace");let t=Ye();t.start(`Tracing ${b.cyan(e.symbolName||tc.basename(i))}...`);try{let o=await Ja({repoPath:r,filePath:i,symbolName:e.symbolName});t.stop("Trace complete."),o.isError?console.error(b.red(o.content[0].text)):be("Flow Results",o.content[0].text,"magenta")}catch(o){throw t.stop(`Trace failed: ${o.message}`),o}finally{await ce(r)}})}import rE from"path";async function __(n,e){let r=rE.resolve(n);await re(async()=>{we("Shadow Sync");let i=Ye();i.start("Synchronizing intelligence lifecycle...");try{let t=await Va({repoPath:r});i.stop("Sync complete."),t.isError?console.error(b.red(t.content[0].text)):(console.log(""),console.log(t.content[0].text),console.log(""))}catch(t){throw i.stop(`Sync failed: ${t.message}`),t}finally{await ce(r)}})}_t();X();G();He();import x_ from"path";async function S_(n,e,r){let i=e?x_.resolve(process.cwd(),e):process.cwd();if(n==="init"){x.info('Running full initialization (same as "index --force")...'),await Q(i,void 0,!0,!0);return}if(n==="tree"){x.info('For tree view, please use the "tree" command.');return}if(n==="topography"){await Q(i);let t=z.getInstance(i),o=Ze(t,i);console.log(`
1042
+ \u{1F3D7}\uFE0F Architecture Summary for ${x_.basename(i)}
1043
+ `),console.log(`Detected Pattern: **${o.pattern}** (Confidence: ${o.patternConfidence.toFixed(0)}%)`),o.insights.length>0&&(console.log(`
1044
+ Insights:`),o.insights.forEach(l=>console.log(`- ${l}`))),console.log(`
1045
+ Layer Distribution:`);let s=["Entry","Logic","Data","Utility","Infrastructure","Test","Types","Unknown"],a=Object.values(o.layers).reduce((l,u)=>l+u.count,0),c=l=>{switch(l){case"Entry":return"\u{1F6AA}";case"Logic":return"\u2699\uFE0F";case"Data":return"\u{1F4BE}";case"Utility":return"\u{1F527}";case"Infrastructure":return"\u{1F3D7}\uFE0F";case"Test":return"\u{1F9EA}";case"Types":return"\u{1F4DD}";default:return"\u2753"}};s.forEach(l=>{let u=o.layers[l],d=a>0?(u.count/a*100).toFixed(1):"0.0";console.log(`${c(l)} ${l.padEnd(14)} | ${u.count.toString().padStart(5)} files | ${d}%`)}),console.log(`
1046
+ Top Files by Layer:`),s.forEach(l=>{let u=o.layers[l];u.count!==0&&(console.log(`
1047
+ ${c(l)} ${l}`),u.topFiles.forEach(d=>{console.log(` - ${d.path} (${d.confidence}% conf)`),d.signals.length>0&&console.log(` \u2514\u2500 ${d.signals.slice(0,1).join(", ")}`)}))});return}if(n==="scout"){let t=await qa({repoPath:i});console.log(t.content[0].text);return}if(n==="hologram"){let t=new le(i);console.log(JSON.stringify(t.getSnapshot(),null,2));return}x.error(`Unknown recon mode: ${n}. Available: init, topography, scout, hologram`)}import Bi from"path";async function $_(n,e){let r=Bi.resolve(e.dir);await re(async()=>{we("Semantic Concept Search");let i=Ye();i.start(`Analyzing intent: "${b.bold(n)}"...`);try{let t=await Ba({repoPath:r,query:n});i.stop("Analysis complete.");let o=t.content[0].text;if(o.includes("Found")){let a=o.split("## ").slice(1).map(c=>{let[l,...u]=c.split(`
1048
+
1049
+ `),[d,p]=l.split(" ( "),m=(d??"").replace(/^\d+\.\s*/,"").trim(),f=u.find(h=>h.startsWith("**Summary**: "))?.replace("**Summary**: ","")||"";return{name:m,matchPct:p??"",summaryLine:f}});if(a.forEach(({name:c,matchPct:l,summaryLine:u})=>{be(`${b.green(c)} ${b.dim("("+(l||""))}`,u,"blue"),console.log("")}),e.interactive&&a.length>1){let c=await fo("Inspect a file",a.map(l=>({value:{name:l.name},label:l.name,hint:l.summaryLine.slice(0,50)})),{limit:15});if(c){let l=c.name.startsWith(r)?c.name:Bi.join(r,c.name),u=await Mr({repoPath:r,filePath:l});u.content?.[0]&&(console.log(""),be(b.bold("File summary"),u.content[0].text,"cyan"))}}}else console.log(o)}catch(t){throw i.stop(`Search failed: ${t.message}`),t}finally{await ce(r)}})}async function w_(n,e){let r=Bi.resolve(e.dir);await re(async()=>{we("Symbol Search");let i=Ye();i.start(`Searching symbols: "${b.bold(n)}"...`);try{let t=await Fi({repoPath:r,query:n});i.stop("Search complete.");let o=t.content[0].text;try{let s=JSON.parse(o);if(Array.isArray(s)){if(console.log(""),po(["Symbol","Kind","File","Line"],s.map(a=>[b.bold(b.green(a.name)),b.dim(a.kind??""),b.cyan(a.file??""),b.yellow(String(a.line??""))])),e.interactive&&s.length>1){let a=s.map(l=>({value:l,label:l.name,hint:`${l.file??""}:${l.line??""}`})),c=await fo("Inspect symbol",a,{limit:15});if(c){let l=await pn({repoPath:r,symbolName:c.name});l.content?.[0]&&(console.log(""),be(b.bold(c.name),l.content[0].text,"cyan"))}}}else console.log(o)}catch{console.log(o)}}catch(t){throw i.stop(`Search failed: ${t.message}`),t}finally{await ce(r)}})}async function k_(n,e){let r=Bi.resolve(e.dir);await re(async()=>{we("Fuzzy Symbol Search");let i=Ye();i.start(`Fuzzy matching: "${b.bold(n)}"...`);try{let t=await Fi({repoPath:r,query:n});i.stop("Search complete.");let o=t.content[0].text;if(o.includes("## ")){let a=o.split("## ").slice(1).map(c=>{let l=c.split(`
1050
+ `),u=l[0],d=l.find(v=>v.startsWith("**Match**:"))||"",p=l.find(v=>v.startsWith("**File**:"))||"",m=u.match(/`([^`]+)`/),f=m?m[1]:"",h=d.match(/\*\*Match\*\*: (.+) \((\d+)% confidence\)/),_=p.match(/`([^:]+):(\d+)`/);return{symbolName:f,file:_?_[1]:"",line:_?_[2]:"",matchType:h?h[1]:"",confidence:h?h[2]:""}});if(console.log(""),console.log(b.dim(`Found ${a.length} fuzzy match(es):`)),console.log(""),a.forEach((c,l)=>{console.log(`${b.dim(`${l+1}.`)} ${b.bold(b.green(c.symbolName))} ${b.dim(`(${c.matchType}, ${c.confidence}% match)`)}`),console.log(` ${b.cyan(c.file)}:${b.yellow(c.line)}`),console.log("")}),e.interactive&&a.length>1){let c=await fo("Inspect symbol",a.map(l=>({value:l,label:l.symbolName,hint:`${l.file}:${l.line}`})),{limit:15});if(c){let l=await pn({repoPath:r,symbolName:c.symbolName});l.content?.[0]&&(console.log(""),be(b.bold(c.symbolName),l.content[0].text,"cyan"))}}}else console.log(o)}catch(t){throw i.stop(`Search failed: ${t.message}`),t}finally{await ce(r)}})}async function E_(n,e){let r=Bi.resolve(e.dir);await re(async()=>{we("Config Search");let i=Ye();i.start(`Searching config: ${b.bold(n||"all")}...`);try{let t=await Ga({repoPath:r,key:n,kind:e.kind});i.stop("Search complete."),be("\u2699\uFE0F Results",t.content[0].text,"yellow")}finally{await ce(r)}})}async function I_(n){let[e,r="."]=n;if(!e||!["install","uninstall","status"].includes(e)){console.log(""),console.log(` ${b.bold("Usage: ")} liquid-shadow hooks <install|uninstall|status> [path]`),console.log(""),console.log(` ${b.bold("Commands: ")}`),console.log(` ${b.cyan("install")} Install git hooks for automatic index refresh and symbol healing`),console.log(` ${b.cyan("uninstall")} Remove installed git hooks`),console.log(` ${b.cyan("status")} Check git hooks installation status`),console.log(""),console.log(` ${b.bold("Examples: ")}`),console.log(" liquid-shadow hooks install ."),console.log(" liquid-shadow hooks status /path/to/repo"),console.log("");return}await re(async()=>{let i=W_("path").resolve(r);switch(e){case"install":{let t=await jr({repoPath:i,action:"install",enableAutoRefresh:!0,enableSymbolHealing:!0});if(console.log(""),console.log(` ${b.green("\u2714")} ${b.bold("Git hooks installed successfully")}`),console.log(""),t.content&&t.content[0])try{let o=JSON.parse(t.content[0].text);console.log(` ${b.bold("Installed hooks: ")}`),o.hooks.forEach(s=>{console.log(` ${b.cyan("\u2022")} ${s}`)}),console.log("")}catch{console.log(t.content[0].text)}break}case"uninstall":{await jr({repoPath:i,action:"remove"}),console.log(""),console.log(` ${b.green("\u2714")} ${b.bold("Git hooks uninstalled successfully")}`),console.log("");break}case"status":{let t=await jr({repoPath:i,action:"status"});if(console.log(""),console.log(` ${b.bold("Git Hooks Status")}`),console.log(""),t.content&&t.content[0])try{let o=JSON.parse(t.content[0].text);o.installed&&o.installed.length>0?(console.log(` ${b.green("\u2714")} Installed hooks:`),o.installed.forEach(s=>{console.log(` ${b.cyan("\u2022")} ${s}`)})):console.log(` ${b.yellow("\u26A0")} No hooks installed`),o.missing&&o.missing.length>0&&(console.log(""),console.log(` ${b.dim("Missing hooks: ")}`),o.missing.forEach(s=>{console.log(` ${b.dim("\u2022")} ${s}`)}))}catch{console.log(t.content[0].text)}console.log("");break}}})}import nc from"path";async function T_(n){let[e,...r]=n;if(!e||!["missions","link","fuse"].includes(e)){console.log(""),console.log(` ${b.bold("Usage: ")} liquid-shadow workspace <missions|link> [options]`),console.log(""),console.log(` ${b.bold("Commands: ")}`),console.log(` ${b.cyan("missions")} <paths...> Get unified view of missions across repositories`),console.log(` ${b.cyan("link")} <args...> Link missions across repositories`),console.log(` ${b.cyan("fuse")} <paths...> Create fused index for cross-repo search (use --name for custom name)`),console.log(""),console.log(` ${b.bold("Examples: ")}`),console.log(" liquid-shadow workspace missions /frontend /backend"),console.log(" liquid-shadow workspace link /frontend 5 /backend 12"),console.log(" liquid-shadow workspace fuse /frontend /backend --name my-app"),console.log("");return}await re(async()=>{switch(e){case"missions":{if(r.length===0){console.error(` ${b.red("\u2716")} Please provide at least one repository path`);return}let i=r.map(o=>nc.resolve(o)),t=await Ya({repoPaths:i});if(console.log(""),console.log(` ${b.bold("Workspace Missions")}`),console.log(""),t.content&&t.content[0]){let o=JSON.parse(t.content[0].text);o.missions&&o.missions.length>0?o.missions.forEach(s=>{console.log(` ${b.cyan("\u2022")} ${b.bold(s.name)} (ID: ${s.id})`),console.log(` ${b.dim("Repo: ")} ${s.repo_path}`),console.log(` ${b.dim("Status: ")} ${s.status}`),console.log(` ${b.dim("Branch: ")} ${s.git_branch||"N/A"}`),s.cross_repo_links&&s.cross_repo_links.length>0&&console.log(` ${b.dim("Links: ")} ${s.cross_repo_links.length} cross-repo link(s)`),console.log("")}):(console.log(` ${b.yellow("\u26A0")} No missions found`),console.log(""))}break}case"link":{if(r.length<4){console.error(""),console.error(` ${b.red("\u2716")} Usage: workspace link <parent-repo> <parent-id> <child-repo> <child-id> [relationship]`),console.error("");return}let[i,t,o,s,a]=r;await Xa({parentRepoPath:nc.resolve(i),parentMissionId:parseInt(t,10),childRepoPath:nc.resolve(o),childMissionId:parseInt(s,10),relationship:a}),console.log(""),console.log(` ${b.green("\u2714")} ${b.bold("Missions linked successfully")}`),console.log(` ${b.dim("Parent: ")} ${i} (Mission ${t})`),console.log(` ${b.dim("Child: ")} ${o} (Mission ${s})`),a&&console.log(` ${b.dim("Relationship: ")} ${a}`),console.log("");break}case"fuse":{if(r.length===0){console.error(` ${b.red("\u2716")} Please provide at least one repository path`);return}let i,t=[];for(let s=0;s<r.length;s++)r[s]==="--name"&&s+1<r.length?(i=r[s+1],s++):t.push(nc.resolve(r[s]));let o=await Qa({repoPaths:t,name:i});if(console.log(""),console.log(` ${b.green("\u2714")} ${b.bold("Fused Index Created")}`),o.content&&o.content[0]){let s=JSON.parse(o.content[0].text);console.log(` ${b.dim("Name: ")} ${s.fused_index.name}`),console.log(` ${b.dim("Path: ")} ${s.fused_index.path}`),console.log(` ${b.dim("Repos: ")} ${s.fused_index.attachedRepos}`),console.log(""),console.log(` ${b.bold("Instructions:")}`),console.log(` ${s.instructions}`)}console.log("");break}}})}import iE from"path";var fe={...b,box:be,table:po,list:ph};async function P_(n){let[e,...r]=n;if(!e||!["plan","briefing","update","log","synthesize","graph"].includes(e)){console.log(""),console.log(` ${fe.bold("Usage: ")} liquid-shadow mission <action> [options]`),console.log(""),console.log(` ${fe.bold("Actions: ")}`),console.log(` ${fe.cyan("plan")} <repo> <name> <goal> Plan a new mission`),console.log(` ${fe.cyan("update")} <repo> <id> <status> Update mission status`),console.log(` ${fe.cyan("log")} <repo> <id> <type> <msg> Log a mission discovery/intent`),console.log(` ${fe.cyan("briefing")} <repo> [--branch] Get mission briefing`),console.log(` ${fe.cyan("synthesize")} <repo> <id> Distill mission into ADR`),console.log(` ${fe.cyan("graph")} <repo> [id] Generate mission lineage graph`),console.log("");return}await re(async()=>{let i=r[0]?iE.resolve(r[0]):process.cwd();switch(e){case"plan":{let[t,o,s]=r;if(!o||!s){console.error(` ${fe.red("\u2716")} Usage: mission plan <repo> <name> <goal>`);return}let a=await Ca({repoPath:i,name:o,goal:s}),c=JSON.parse(a.content[0].text);console.log(` ${fe.green("\u2714")} Mission planned (ID: ${c.missionId})`);break}case"update":{let[t,o,s]=r;if(!o||!s){console.error(` ${fe.red("\u2716")} Usage: mission update <repo> <id> <status>`);return}await Ma({repoPath:i,missionId:parseInt(o),status:s}),console.log(` ${fe.green("\u2714")} Status updated to ${s}`);break}case"log":{let[t,o,s,...a]=r;if(!o||!s||a.length===0){console.error(` ${fe.red("\u2716")} Usage: mission log <repo> <id> <type> <message>`);return}await Ua({repoPath:i,missionId:parseInt(o),type:s,content:a.join(" ")}),console.log(` ${fe.green("\u2714")} Intent logged`);break}case"synthesize":{let[t,o]=r;if(!o){console.error(` ${fe.red("\u2716")} Usage: mission synthesize <repo> <id>`);return}let s=await ja({repoPath:i,missionId:parseInt(o)});console.log(""),fe.box("Mission Synthesis (ADR)",s.content[0].text,"magenta");break}case"graph":{let[t,o]=r,s=await Za({repoPath:i,missionId:o?parseInt(o):void 0,format:"mermaid"});console.log(""),console.log(s.content[0].text);break}case"briefing":{let t=await Ar({repoPath:i});if(t.content&&t.content[0]){let o=t.content[0].text;try{let s=JSON.parse(o);if(s.mission){console.log(""),console.log(fe.bold(fe.cyan(` Mission Dashboard: ${s.mission.name} `))),fe.box("Tactical Goal",s.mission.goal,"cyan");let a=s.mission.status==="completed"?"green":s.mission.status==="failed"?"red":"yellow",c=[["Status",fe.bold(fe[a](s.mission.status.toUpperCase()))],["ID",`#${s.mission.id}`],["Branch",s.mission.git_branch||"main"]];fe.table(["Field","Value"],c),s.recent_activity&&s.recent_activity.length>0&&(console.log(` ${fe.bold("Recent Activity:")}`),fe.list(s.recent_activity.slice(0,5).map(l=>`${fe.dim(`[${l.type.toUpperCase()}]`)} ${l.content}`)))}else console.log(o)}catch{console.log(o)}}break}}})}import Nf from"path";async function R_(n){let[e,...r]=n;if(!e||!["symbol","file"].includes(e)){console.log(""),console.log(` ${b.bold("Usage: ")} liquid-shadow inspect <symbol|file> [options]`),console.log(""),console.log(` ${b.bold("Actions: ")}`),console.log(` ${b.cyan("symbol")} <repo> <name> Read source code for a symbol`),console.log(` ${b.cyan("file")} <repo> <path> Get a token-efficient file summary`),console.log("");return}await re(async()=>{let i=r[0]?Nf.resolve(r[0]):process.cwd();if(e==="symbol"){let t=r[1];if(!t){console.error(` ${b.red("\u2716")} Please provide a symbol name`);return}let o=await pn({repoPath:i,symbolName:t});console.log(""),o.content&&o.content[0]&&console.log(o.content[0].text)}else{let t=r[1];if(!t){console.error(` ${b.red("\u2716")} Please provide a file path`);return}let o=Nf.isAbsolute(t)?t:Nf.join(i,t),s=await Mr({repoPath:i,filePath:o});console.log(""),s.content&&s.content[0]&&console.log(s.content[0].text)}})}var N_=["index","status","metrics","benchmark","tree","trace","watch","search-config","search-concept","search-symbol","search-fuzzy","hooks","workspace","mission","inspect","completion"],oE=["--help","-h","--version","-v","--dir","-d"],sE={index:["--output","-o","--level","-l","--subPath","--force","--deep"],tree:["--subPath","--depth","-d"],trace:["--dir","-d"],"search-config":["--dir","-d","--kind"],"search-concept":["--dir","-d","--interactive","-i"],"search-symbol":["--dir","-d","--interactive","-i"],"search-fuzzy":["--dir","-d","--interactive","-i"]};function aE(){let n=Object.entries(sE).map(([i,t])=>` ${i}) opts="${t.join(" ")}" ;;`).join(`
1051
+ `),e=N_.join(" ");return`# Bash completion for liquid-shadow. Usage: source <(liquid-shadow completion bash)
815
1052
  _liquid_shadow() {
816
1053
  local cur="\${COMP_WORDS[COMP_CWORD]}"
817
1054
  local words=("\${COMP_WORDS[@]}")
@@ -821,10 +1058,10 @@ _liquid_shadow() {
821
1058
  if [[ "\${words[$i]}" != -* ]]; then cmd="\${words[$i]}"; break; fi
822
1059
  ((i++))
823
1060
  done
824
- local opts="${ol.join(" ")}"
1061
+ local opts="${oE.join(" ")}"
825
1062
  if [ -n "$cmd" ]; then
826
1063
  case "$cmd" in
827
- ${i}
1064
+ ${n}
828
1065
  esac
829
1066
  else
830
1067
  COMPREPLY=($(compgen -W "${e}" -- "$cur"))
@@ -833,11 +1070,11 @@ ${i}
833
1070
  COMPREPLY=($(compgen -W "$opts" -- "$cur"))
834
1071
  }
835
1072
  complete -F _liquid_shadow liquid-shadow
836
- `}function ll(){return`# Zsh completion for liquid-shadow. Usage: source <(liquid-shadow completion zsh)
1073
+ `}function cE(){return`# Zsh completion for liquid-shadow. Usage: source <(liquid-shadow completion zsh)
837
1074
  # Run after compinit (e.g. in .zshrc after compinit)
838
1075
 
839
1076
  _liquid_shadow() {
840
- local -a cmds; cmds=(${Do.map(e=>`'${e}'`).join(" ")})
1077
+ local -a cmds; cmds=(${N_.map(e=>`'${e}'`).join(" ")})
841
1078
  if [ $CURRENT -eq 2 ]; then
842
1079
  _describe 'command' cmds
843
1080
  return
@@ -854,15 +1091,268 @@ _liquid_shadow() {
854
1091
  _describe 'flag' fl
855
1092
  }
856
1093
  compdef _liquid_shadow liquid-shadow
857
- `}async function Oo(i){i==="bash"?console.log(cl()):i==="zsh"?console.log(ll()):(console.error("Usage: liquid-shadow completion <bash|zsh>"),console.error("Then: source <(liquid-shadow completion bash) # or zsh"),process.exit(1))}import pl from"fs";import ul from"path";var dl=2e3;async function Fo(i){let e=ul.resolve(i);await B(async()=>{le("Watch mode");let t=Ce(e),n=null,s=()=>{n&&clearTimeout(n),n=setTimeout(async()=>{n=null;try{console.log(""),console.log(E.dim(" Changes detected, reindexing...")),await z(e,5,!1,!0),console.log(E.green(" Reindex complete."))}catch(r){console.error(E.red(" Reindex failed:"),r instanceof Error?r.message:r)}},dl)};try{pl.watch(e,{recursive:!0},(r,o)=>{o&&!o.includes("node_modules")&&s()}),console.log(E.cyan(` Watching ${e}`)),console.log(E.dim(" Ignore: "+(t.ignore?.length?t.ignore.join(", "):"default"))),Tt("Ctrl+C to stop"),await new Promise((r,o)=>{process.on("SIGINT",()=>o(new Error("SIGINT"))),process.on("SIGTERM",()=>o(new Error("SIGTERM")))}).catch(()=>{})}finally{n&&clearTimeout(n),await q(e)}})}U();P();var ml=_.child({module:"narrative-service"}),Jn=class{missions;briefingEngine;repoPath;constructor(e){this.repoPath=e;let{missions:t}=C.getInstance(e);this.missions=t,this.briefingEngine=new Ge(e)}async generateChronicle(e={}){ml.info(e,"Generating Repo Chronicle...");let n=this.missions.findAll().filter(l=>l.parent_id===null&&l.status!=="planned");e.since&&(n=n.filter(l=>l.updated_at>=e.since)),e.until&&(n=n.filter(l=>l.updated_at<=e.until)),n.sort((l,p)=>p.updated_at-l.updated_at);let s=e.offset||0,r=e.limit||10;n=n.slice(s,s+r);let o=[],c=[],a=[];for(let l of n){let p=this.missions.findByParentId(l.id),d=p.length>0,u=await this.briefingEngine.distillMission(l.id,!1);if(d){let m=[];for(let h of p)m.push(await this.mapMissionToEpisode(h));m.unshift(await this.mapMissionToEpisode(l));let f={kind:"initiative",root_mission_id:l.id,title:l.name,strategy_graph:l.strategy_graph?JSON.parse(l.strategy_graph):{},episodes:m,synthesized_narrative:u.adr};o.push(f),a.push(f)}else{let m=await this.mapMissionToEpisode(l,u.adr);c.push(m),a.push(m)}}return{repo_path:this.repoPath,generated_at:Date.now(),initiatives:o,unattached_episodes:c,timeline:a}}async mapMissionToEpisode(e,t){let n=t;return n||(n=(await this.briefingEngine.distillMission(e.id,!1)).adr),{kind:"episode",mission_id:e.id,title:e.name,goal:e.goal,outcome:e.outcome_contract,intents:[],adr_summary:n}}renderChronicleMarkdown(e){let t=`# Repository Chronicle
1094
+ `}async function z_(n){n==="bash"?console.log(aE()):n==="zsh"?console.log(cE()):(console.error("Usage: liquid-shadow completion <bash|zsh>"),console.error("Then: source <(liquid-shadow completion bash) # or zsh"),process.exit(1))}import lE from"fs";import uE from"path";var dE=2e3;async function D_(n){let e=uE.resolve(n);await re(async()=>{we("Watch mode");let r=Pt(e),i=null,t=()=>{i&&clearTimeout(i),i=setTimeout(async()=>{i=null;try{console.log(""),console.log(b.dim(" Changes detected, reindexing...")),await Q(e,5,!1,!0),console.log(b.green(" Reindex complete."))}catch(o){console.error(b.red(" Reindex failed:"),o instanceof Error?o.message:o)}},dE)};try{lE.watch(e,{recursive:!0},(o,s)=>{s&&!s.includes("node_modules")&&t()}),console.log(b.cyan(` Watching ${e}`)),console.log(b.dim(" Ignore: "+(r.ignore?.length?r.ignore.join(", "):"default"))),at("Ctrl+C to stop"),await new Promise((o,s)=>{process.on("SIGINT",()=>s(new Error("SIGINT"))),process.on("SIGTERM",()=>s(new Error("SIGTERM")))}).catch(()=>{})}finally{i&&clearTimeout(i),await ce(e)}})}G();import pE from"path";async function C_(n,e){let r=pE.resolve(n||process.cwd()),i=e.format==="json"?"json":"markdown",t=x.child({module:"cli:chronicle",repoPath:r});t.info("Generating repository chronicle...");try{let o=new jt(r),s=await o.generateChronicle({limit:e.limit,offset:e.offset,since:e.since,until:e.until});console.log(i==="json"?JSON.stringify(s,null,2):o.renderChronicleMarkdown(s))}catch(o){t.error({error:o},"Failed to generate chronicle"),console.error(`Error: ${o instanceof Error?o.message:String(o)}`),process.exit(1)}}import hn from"fs";import Fr from"path";import hE from"os";import mn from"fs";import fn from"path";import mE from"os";var L_={shadow_audit:'---\nname: audit\ndescription: Perform codebase health audits to identify dead code, circular dependencies, and technical debt. Use when auditing code quality, finding unused code, detecting circular dependencies, or when the user asks about codebase health, technical debt, or code cleanup.\n---\n\n# Codebase Audit\n\nComprehensive health audit using Shadow analyze toolkit.\n\n## \u{1F680} Workflow\n\n1. **Session Context**: `shadow_ops_context` (repoPath) \u2014 **ONE CALL** for hologram + chronicle + briefing. Get architecture baseline.\n2. **Dead Code Detection**: `shadow_analyze_debt` (mode: "dead-code", limit: 100, includeTests: false, repoPath) \u2014 Unused exports.\n3. **Circular Dependencies**: `shadow_analyze_debt` (mode: "circular-deps", limit: 20, repoPath) \u2014 Import cycles.\n4. **Layer Integrity** (optional): `shadow_recon_topography` (repoPath) \u2014 Detailed layer analysis if hologram summary isn\'t enough.\n5. **Log Findings**: `shadow_ops_log` (missionId, type: "discovery", content, repoPath).\n6. **Create Cleanup Mission** (optional): `shadow_ops_plan` (name: "Codebase Cleanup", templateId: "refactoring", templateVars, repoPath).\n\n## \u{1F6E0} Precise Tooling\n\n| Audit Target | Atomic Tool |\n| :--- | :--- |\n| **Session Start** \u{1F680} | `shadow_ops_context` (repoPath) \u2014 **START HERE** for baseline |\n| **Architecture** | `shadow_recon_hologram` (repoPath) \u2014 if you need standalone |\n| **Dead Code** | `shadow_analyze_debt` (mode: "dead-code", limit: 100, **confidenceThreshold: "high"**) |\n| **Circular Deps** | `shadow_analyze_debt` (mode: "circular-deps") |\n| **Layers** | `shadow_recon_topography` \u2014 detailed breakdown if needed |\n| **Config Audit** | `shadow_search_config` (kind: "Env", **showUsage: true**) \u2014 find orphaned env vars |\n\n## \u{1F4A1} Intelligence Options\n\n- **`shadow_analyze_debt` confidence levels**: Use `confidenceThreshold: "high"` for likely dead code, `"medium"` for possibly intentional (test fixtures, etc.), `"all"` for everything.\n- **`shadow_analyze_debt` exclusion filters**: Use `excludePatterns`, `includeMigrations: false`, `includeFixtures: false` to reduce noise.\n- **`shadow_search_config` with `showUsage: true`**: Cross-references config vars with code to show usage counts and identify orphaned vars (defined but never used).\n\n## \u{1F50D} Health Criteria\n\n- **Critical Issues**: Circular deps in core logic, >50 dead exports, orphaned env vars with secrets\n- **Warning Signs**: Layer violations (Test \u2192 Logic), >20 dead exports, >10 orphaned configs\n- **Good Health**: Clean layers, <10 dead exports, no circular deps, all configs in use\n',shadow_chronicle:`---
1095
+ name: chronicle
1096
+ description: Retrieve and analyze the repository's narrative archive as recorded in Git-native memory. Use when you need to understand historical decisions, catch up on repository progress, review recently completed missions, or when the user asks for a project history, changelog, or chronological overview of architectural changes.
1097
+ ---
1098
+
1099
+ # Repository Chronicle
1100
+
1101
+ Retrieve narrative archive from Git-native memory.
1102
+
1103
+ ## \u{1F680} Workflow
1104
+
1105
+ 1. **Recent History**: \`shadow_ops_chronicle\` (limit: 10, format: "markdown", repoPath) \u2014 Last 10 entries.
1106
+ 2. **Time-Filtered**:
1107
+ - \`shadow_ops_chronicle\` (since: &lt;unix&gt;, limit: 20, repoPath)
1108
+ - \`shadow_ops_chronicle\` (until: &lt;unix&gt;, limit: 20, repoPath)
1109
+ 3. **Structured Data**: \`shadow_ops_chronicle\` (format: "json", limit: 50, repoPath) \u2014 For processing.
1110
+ 4. **Paginated**: \`shadow_ops_chronicle\` (limit: 10, offset: 10, repoPath) \u2014 Second page.
1111
+
1112
+ ## \u{1F6E0} Precise Tooling
1113
+
1114
+ | Chronicle Query | Atomic Tool |
1115
+ | :--- | :--- |
1116
+ | **Recent (Markdown)** | \`shadow_ops_chronicle\` (limit: 10, format: "markdown") |
1117
+ | **Time Range** | \`shadow_ops_chronicle\` (since: &lt;unix&gt;, until: &lt;unix&gt;) |
1118
+ | **JSON Data** | \`shadow_ops_chronicle\` (format: "json", limit: 50) |
1119
+ | **Pagination** | \`shadow_ops_chronicle\` (limit: 10, offset: 10) |
1120
+
1121
+ ## Output Formats
1122
+
1123
+ - **\`format: "markdown"\`** (default): Human-readable narrative feed with missions grouped as Strategic Initiatives and Standalone Episodes
1124
+ - **\`format: "json"\`**: Structured data for programmatic analysis (includes missionId, steps, timestamps, ADRs)
1125
+
1126
+ ## Use Cases
1127
+
1128
+ - **Onboarding**: Read last 10 entries to catch up
1129
+ - **Release Notes**: Get completed missions since last release
1130
+ - **ADR Review**: Extract all architectural decisions
1131
+ - **Progress Reports**: Show what's been done this week
1132
+
1133
+ **Note:** Chronicle reads from Git Notes, so it's persistent across branches and clones.
1134
+ `,shadow_continue:'---\nname: continue\ndescription: Get briefing, pick one mission from next_work_candidates, then work that mission to completion with all remaining steps in one run. Use when continuing work on missions, executing mission steps, or when the user asks to continue work, finish a mission, or proceed with development tasks.\n---\n\n**In one sentence:** Get briefing (+ optional trace), pick **one mission** from **next_work_candidates** (ranked by relevance), then work that mission to completion \u2014 all remaining steps in one run. Update and log as you go. No status reports; when you\'re done with that mission, it\'s done.\n\n---\n## 1. Context\n\n- **Option A (one shot):** `shadow_ops_context` (repoPath) \u2192 returns hologram + chronicle(5) + **briefing** (counts, **next_work_candidates** ranked by relevance). Use when you want architecture + history + backlog in one call at the start of /continue.\n- **Option B:** `shadow_ops_briefing` (scope: "project", repoPath) \u2192 **next_work_candidates** (relevance-ranked), hierarchy, analytics.\n - Use **altitude** to control output density: `orbit` (~200 tokens, counts + candidates only), `atmosphere` (default, strategy + crystals), `ground` (raw logs + working set + collisions).\n- `shadow_sync_trace` (repoPath) only if you care about external changes. Otherwise skip.\n\n## 2. Pick one mission\n\n- **`next_work_candidates`** are ranked by the MissionRelevanceScorer (recency \xD7 0.4 + activity \xD7 0.3 + status \xD7 0.2 + blockers \xD7 0.1). Higher score = more relevant.\n- Choose the top-ranked candidate. Prefer in-progress over planned. Parent-only missions (umbrellas) are already filtered out.\n\n## 3. Work the whole mission\n\n- For that mission, run through **all remaining steps** (not just one):\n - **Surgical Discovery:** `shadow_analyze_flow` (symbolName, filePath, repoPath).\n - **Execute Step**: Set in-progress \u2192 implement \u2192 `shadow_ops_track` (missionId, stepId, status: "completed", contextPivot, repoPath).\n - **Atomic Logging:** At least once per step. `shadow_ops_log` (missionId, type: "decision", content, symbolName, repoPath).\n- **Seal the mission**: `shadow_ops_track` (missionId, status: "completed", repoPath).\n - This **auto-triggers**: ADR synthesis, Git Notes persistence, and cascade parent completion (if all sibling missions are also done, the parent auto-completes too).\n - No need to call `shadow_ops_synthesize` separately \u2014 it\'s automatic on completion.\n- **Optional \u2014 Crystallize** (for long-running missions with many logs): `shadow_ops_crystallize` (missionId, repoPath) compresses raw intent logs into a single crystal summary. Useful mid-mission to keep briefings lean.\n\n## \u{1F6E0} Precise Tooling\n\n| Action | Atomic Tool | Example |\n| :--- | :--- | :--- |\n| **Context (one shot)** | `shadow_ops_context` | repoPath \u2014 hologram + chronicle + briefing |\n| **Briefing** | `shadow_ops_briefing` | scope: "project", altitude: "orbit", repoPath |\n| **Flow Trace** | `shadow_analyze_flow` | symbolName: "handleRequest", filePath, repoPath |\n| **Step Update** | `shadow_ops_track` | missionId: 4, stepId: "s2", status: "completed" |\n| **Intent Log** | `shadow_ops_log` | missionId: 4, type: "fix", content: "..." |\n| **Complete Mission** | `shadow_ops_track` | missionId: 4, status: "completed" \u2014 auto-synthesizes ADR |\n| **Crystallize** | `shadow_ops_crystallize` | missionId: 4 \u2014 compress logs mid-mission |\n\n*Note: Always use `symbolName` in `shadow_ops_log` to create Liquid Anchors.*\n\n## 4. Don\'t\n\n- Don\'t do one step and stop \u2014 /continue is "finish a mission," not "do one step."\n- Don\'t call `shadow_ops_synthesize` after completing \u2014 it\'s automatic on `status: "completed"`.\n- Don\'t long status reports. Don\'t ask "what should I work on?" unless a real tie. Don\'t auto-commit.\n\n---\n\n**Tools:** `shadow_ops_context` (optional start), `shadow_ops_briefing`, `shadow_ops_track`, `shadow_ops_log`, `shadow_ops_crystallize`, `shadow_sync_trace`. For discovery: `shadow_search_*`, `shadow_recon_*`, `shadow_analyze_*`.\n',shadow_crystallize:`---
1135
+ name: crystallize
1136
+ description: Compress a mission's intent logs into a dense crystal summary for token-efficient briefings. Use when a mission has accumulated many raw logs, when briefings are too verbose, or when the user asks about log compression, crystallization, or context reduction.
1137
+ ---
1138
+
1139
+ # Intent Log Crystallization
1140
+
1141
+ Compress raw intent logs into a single crystal summary node. The crystal replaces verbose raw logs in briefings, reducing token usage while preserving the mission's key decisions, context, and consequences.
1142
+
1143
+ ## When to Crystallize
1144
+
1145
+ - A mission has **10+ raw intent logs** and briefings are getting verbose.
1146
+ - Mid-mission, before requesting a detailed briefing \u2014 keeps \`atmosphere\` altitude lean.
1147
+ - Before synthesis (optional) \u2014 produces cleaner ADRs from compressed input.
1148
+ - The briefing at \`atmosphere\` altitude already prefers crystals over raw logs (\`findByMissionPreferCrystal\`), so crystallizing makes those briefings significantly leaner.
1149
+ - A symbol has accumulated many standalone intent logs \u2014 crystallize by symbol to compress without a mission.
1150
+
1151
+ ## Workflow
1152
+
1153
+ 1. **Crystallize mission logs**: \`shadow_ops_crystallize\` (missionId, repoPath) \u2014 Compresses all raw logs for that mission into one crystal node.
1154
+ 2. **Crystallize symbol logs** (standalone): \`shadow_ops_crystallize\` (symbolId, repoPath) \u2014 Compresses standalone logs anchored to a specific symbol.
1155
+ 3. **Verify**: \`shadow_ops_briefing\` (scope: "mission", missionId, altitude: "atmosphere", repoPath) \u2014 Crystal should appear in \`recent_activity\` instead of raw logs.
1156
+
1157
+ ## Precise Tooling
1158
+
1159
+ | Action | Atomic Tool | Usage |
1160
+ | :--- | :--- | :--- |
1161
+ | **Crystallize Mission** | \`shadow_ops_crystallize\` | missionId, repoPath \u2014 compress mission logs |
1162
+ | **Crystallize Symbol** | \`shadow_ops_crystallize\` | symbolId, repoPath \u2014 compress standalone symbol logs |
1163
+ | **Check Status** | \`shadow_ops_briefing\` (altitude: "atmosphere") | Verify crystal appears in activity |
1164
+ | **Full Logs** | \`shadow_ops_briefing\` (altitude: "ground") | Still shows raw logs if needed |
1165
+
1166
+ ## What the Crystal Contains
1167
+
1168
+ - Mission name and ID (or symbol name for symbol crystals)
1169
+ - Count of compressed logs and symbols
1170
+ - Log types present (decision, fix, discovery, blocker)
1171
+ - Structured breakdown: decisions, context, consequences, recommendations
1172
+
1173
+ ## Notes
1174
+
1175
+ - Crystallization is **idempotent**: if no new raw logs exist, it reports \`already_crystallized\`.
1176
+ - New logs added after crystallization remain as raw until the next crystallize call.
1177
+ - Raw logs are **not deleted** \u2014 they're marked as absorbed. \`ground\` altitude still shows them.
1178
+ - \`symbolId\` is the internal DB id \u2014 get it from \`shadow_inspect_symbol\` output.
1179
+ `,shadow_mission:`---
1180
+ name: mission
1181
+ description: Define the objective, strategy, and success criteria for a new development mission. Use when planning strategic initiatives, creating missions, setting up development goals, or when the user asks about mission planning, strategic alignment, or outcome contracts.
1182
+ ---
1183
+
1184
+ # Mission Strategy & Setup
1185
+
1186
+ Define the objective, strategy, and success criteria for a new mission. This workflow is for **Strategic Alignment and Planning**.
1187
+
1188
+ > **IMPORTANT**: This workflow stops at the "Ready to Execute" state. For implementation and automated execution, use **/continue**.
1189
+
1190
+ ## Workflow
1191
+
1192
+ 1. **Session Context**: \`shadow_ops_context\` (repoPath) \u2014 **ONE CALL** for hologram + chronicle(5) + briefing (with relevance-ranked \`next_work_candidates\`). Check existing candidates and recent decisions before creating new work.
1193
+ 2. **Optional Expanded Context** (only if needed):
1194
+ - \`shadow_recon_topography\` (repoPath) \u2014 Detailed layer breakdown to align goal with architecture.
1195
+ - \`shadow_ops_chronicle\` (limit: 10, repoPath) \u2014 More historical ADRs if 5 isn't enough.
1196
+ - \`shadow_ops_briefing\` (scope: "project", altitude: "ground", repoPath) \u2014 Full detail with analytics, collisions, and working sets.
1197
+ 3. **Strategic Plan**: \`shadow_ops_plan\` (name, goal, outcomeContract, ...).
1198
+ * **Strategy DAG**: Define logical steps and verification rules.
1199
+ * **Initiative vs Mission**: Decide if this is a parent (Initiative) or a leaf (Mission). Parent missions auto-complete via cascade when all children finish.
1200
+ 4. **Alignment**: Present the plan to the user. Do not begin execution until the user approves the strategy.
1201
+
1202
+ ## Precise Tooling
1203
+
1204
+ | Setup Action | Precise Tool Call | Usage |
1205
+ | :--- | :--- | :--- |
1206
+ | **Session Start** | \`shadow_ops_context\` | **START HERE** \u2014 hologram + chronicle + briefing in one call |
1207
+ | **Establish Plan** | \`shadow_ops_plan\` | Create the mission and strategy. |
1208
+ | **Architectural Map** | \`shadow_recon_topography\` | Contextualize the target layers (if context wasn't enough). |
1209
+ | **Detailed Briefing** | \`shadow_ops_briefing\` (altitude: "ground") | Full analytics, collisions, working sets. |
1210
+ | **Lean Briefing** | \`shadow_ops_briefing\` (altitude: "orbit") | Counts + candidates only (~200 tokens). |
1211
+ | **Graph View** | \`shadow_ops_graph\` | Visualize the initiative's hierarchy. |
1212
+
1213
+ *Note: **Always start with \`shadow_ops_context\`** for instant mission landscape + architectural context. Ensure the \`outcomeContract\` is binary and verifiable. Parent initiatives auto-cascade on child completion \u2014 no manual closing needed.*
1214
+
1215
+ ## Briefing Altitude Levels
1216
+
1217
+ - **\`orbit\`** (~200 tokens): Counts + relevance-ranked candidates only. Use for quick checks.
1218
+ - **\`atmosphere\`** (default): Strategy graphs, crystal summaries, hierarchy, analytics.
1219
+ - **\`ground\`** (full): Raw logs, working sets, collision analysis, ancestor activity.
1220
+
1221
+ ## Intent Logging (Strategic Quality)
1222
+
1223
+ Capture the "Why" and "How" during the planning phase to ensure the final ADR has architectural depth.
1224
+
1225
+ * **Decision Logs**: Capture why a specific strategy or library was chosen.
1226
+ * **Discovery Logs**: Record insights found during initial reconnaissance.
1227
+
1228
+ **Hand-off**: Once the mission is planned and logged, the setup phase is over. Execute via \`/continue\`.
1229
+ `,shadow_onboard:'---\nname: onboard\ndescription: Initialize and analyze a new repository for deep intelligence by building semantic index, syncing state, activating git hooks, and establishing missions. Use when onboarding to a new repository, initializing Shadow Engine, setting up git hooks, or when the user asks about repository setup, initialization, or first-time configuration.\n---\n\n# Repository Onboarding\n\nInitialize and analyze a new repository for deep intelligence.\n\n## Workflow\n\n1. **Semantic Init**: `shadow_recon_onboard` (repoPath) \u2014 **Only run once** per repo to build the baseline. Auto-populates the hologram.\n2. **Read Hologram**: `shadow_recon_hologram` (repoPath) \u2014 Get instant architectural context (~1300 tokens: topography + gravity zones).\n3. **Unified Sync**: `shadow_sync_trace` (repoPath) \u2014 **The One-Stop Shop**. Performs indexing + ghost analysis + mission re-hydration.\n4. **Active Briefing**: `shadow_ops_briefing` (scope: "project", altitude: "atmosphere", repoPath) \u2014 Resumes the shared backlog with relevance-ranked candidates.\n - Use `altitude: "orbit"` for a lean overview (~200 tokens), or `altitude: "ground"` for full detail.\n5. **Architectural Deep Dive** (optional):\n - `shadow_recon_topography` (repoPath) \u2014 View layers (Entry/Logic/Data/Utility/Test).\n - `shadow_ops_chronicle` (limit: 5, repoPath) \u2014 Narrative feed.\n6. **Hooks Activation**: `shadow_env_hooks` (action: "install", repoPath).\n7. **Establish Mission**: `shadow_ops_plan` (name, goal, repoPath).\n\n## Precise Tooling\n\n| Action | Atomic Tool |\n| :--- | :--- |\n| **Index** | `shadow_recon_onboard` |\n| **Hologram** | `shadow_recon_hologram` (repoPath) |\n| **Layers** | `shadow_recon_topography` |\n| **History** | `shadow_ops_chronicle` (limit: 10) |\n| **Resume (lean)** | `shadow_ops_briefing` (scope: "project", altitude: "orbit") |\n| **Resume (full)** | `shadow_ops_briefing` (scope: "project", altitude: "atmosphere") |\n| **Hooks** | `shadow_env_hooks` (action: "install") |\n\n*Note: Always use absolute paths for `repoPath`. Call `shadow_recon_hologram` immediately after init for instant architectural context.*\n',shadow_research:`---
1230
+ name: research
1231
+ description: Conduct high-signal research for external dependencies by combining local context, web search, and Context7 documentation. Use when researching libraries, checking integration examples, verifying versions, or when the user asks about external dependencies, library documentation, or integration patterns.
1232
+ ---
1233
+
1234
+ # External Research
1235
+
1236
+ High-signal research for external dependencies.
1237
+
1238
+ ## \u{1F680} Workflow
1239
+
1240
+ 1. **Local Context**: \`shadow_search_concept\` (query: "library name", repoPath). Find existing integration examples.
1241
+ 2. **Web Search**: Use the \`WebSearch\` tool for official docs and latest versions.
1242
+ 3. **Deep Intel (Context7)**: resolve-library-id, query-docs (server: user-context7).
1243
+ 4. **Integration Check**: \`shadow_inspect_file\` (filePath, detailLevel: "signatures", repoPath).
1244
+ 5. **Log Findings**: \`shadow_ops_log\` (type: "discovery", content, repoPath).
1245
+
1246
+ ## \u{1F6E0} Precise Tooling
1247
+
1248
+ | Discovery Layer | Atomic Tool |
1249
+ | :--- | :--- |
1250
+ | **Local Usage** | \`shadow_search_concept\` (query, **compact: true** for broad search) |
1251
+ | **File Discovery** | \`shadow_search_path\` (query, **ranked: true**) \u2014 gravity-sorted with layers |
1252
+ | **Config Check** | \`shadow_search_config\` (key, **showUsage: true**) \u2014 with usage counts |
1253
+ | **External Docs**| context7 tools (user-context7) |
1254
+ | **Relational** | \`shadow_analyze_deps\` (filePath, direction) |
1255
+
1256
+ ## \u{1F4A1} Intelligence Options
1257
+
1258
+ - **\`shadow_search_concept\` with \`compact: true\`**: Returns file paths + scores without snippets (~60% token savings). Use for broad exploration.
1259
+ - **\`shadow_search_path\` with \`ranked: true\`**: Results sorted by gravity (high-import files first) with layer classification. Reveals architecturally important files.
1260
+ - **\`shadow_search_config\` with \`showUsage: true\`**: Shows usage counts per config var and identifies orphaned vars (defined but never used in code).
1261
+
1262
+ *Note: Always check \`package.json\` for the exact version before querying Context7 to ensure documentation alignment.*`,shadow_sync:`---
1263
+ name: sync
1264
+ description: Sync index and mission state after external changes. Day-to-day: index + NanoRepair run automatically when MCP tools (search, inspect, etc.) trigger reindex. Use trace after git pull/checkout/merge (or rely on hooks); use index deep:true for full rebuild.
1265
+ ---
1266
+
1267
+ # Repository Synchronization
1268
+
1269
+ **Day-to-day:** Index and NanoRepair run automatically when you use MCP tools (search, inspect, analyze, etc.) and a reindex occurs. No manual sync needed for edits or renames.
1270
+
1271
+ ## When to run sync manually
1272
+
1273
+ | Situation | Action |
1274
+ | :--- | :--- |
1275
+ | **After git pull/checkout/merge** | \`shadow_sync_trace\` (repoPath) \u2014 or rely on Git hooks if installed |
1276
+ | **Full rebuild (corruption)** | \`shadow_sync_index\` (repoPath; use deep: true if supported) |
1277
+ | **Repair only (rare)** | \`shadow_sync_repair\` (repoPath) |
1278
+
1279
+ **Note:** \`trace\` does index + ghost analysis + NanoRepair + lifecycle + mission re-hydration. Hooks run it on commit/checkout/merge.
1280
+ `,shadow_synthesize:`---
1281
+ name: synthesize
1282
+ description: Distill mission logs into Architectural Decision Records (ADRs) and persist them to the Shadow Engine and Git Notes. Use when completing missions, creating ADRs, synthesizing architectural decisions, or when the user asks about decision records, mission completion, or architectural documentation.
1283
+ ---
1284
+
1285
+ # Architectural Synthesis
1286
+
1287
+ Distill mission logs into an Architectural Decision Record (ADR) and persist it to the Shadow Engine.
1288
+
1289
+ > **AUTO-PILOT ACTIVE**: Synthesis is **automatically triggered** when a mission status is set to \`completed\` via \`shadow_ops_track\`. The system handles: ADR distillation (recursive for child missions), Git Notes persistence, and **cascade parent completion** (if all siblings are done, the parent auto-completes and synthesizes too).
1290
+
1291
+ ## Workflow
1292
+
1293
+ 1. **Complete Mission**: \`shadow_ops_track\` (missionId, status: "completed", repoPath).
1294
+ * The Shadow Engine will automatically:
1295
+ * Distill all intent logs (recursive for child missions).
1296
+ * Format the ADR using markdown and **Liquid Anchors**.
1297
+ * Persist the record to SQLite and **Git Notes**.
1298
+ * **Cascade**: If all sibling missions under the same parent are completed, the parent mission auto-completes with its own ADR synthesis.
1299
+ 2. **Verify**: Check the synthesized record via \`shadow_ops_chronicle\` (limit: 5, repoPath).
1300
+ 3. **Manual Synthesis**: Use \`shadow_ops_synthesize\` only to **re-generate** an existing record or for specific partial distillations.
1301
+ 4. **Pre-synthesis Compression** (optional): For missions with many raw logs, \`shadow_ops_crystallize\` (missionId, repoPath) compresses logs into a crystal summary before synthesis for cleaner ADRs.
1302
+
1303
+ ## Precise Tooling
1304
+
1305
+ | Action | Atomic Tool | Usage |
1306
+ | :--- | :--- | :--- |
1307
+ | **Complete & Seal** | \`shadow_ops_track\` (status: "completed") | **Primary**. Triggers auto-synthesis + cascade. |
1308
+ | **Manual Distill** | \`shadow_ops_synthesize\` | Re-run synthesis manually (re-gen only). |
1309
+ | **Crystallize First** | \`shadow_ops_crystallize\` | Compress raw logs before synthesis. |
1310
+ | **View Chronicle** | \`shadow_ops_chronicle\` | View the combined narrative feed. |
1311
+
1312
+ *Note: Synthesis consolidation includes all child missions recursively. Cascade parent completion propagates upward through the entire hierarchy.*
1313
+
1314
+ ## Cascade Parent Completion
1315
+
1316
+ When the last child mission under a parent is completed:
1317
+ 1. Parent status is set to \`completed\`
1318
+ 2. A system intent log records the cascade event
1319
+ 3. Parent ADR is synthesized (recursive child distillation)
1320
+ 4. Parent is synced to Git Notes
1321
+ 5. If the parent itself has a parent, the cascade continues upward
1322
+
1323
+ ## Tooling Strategy
1324
+
1325
+ Synthesis is the final commit of the mission's logic into the repository's permanent history. Avoid manual markdown files for ADRs; trust the **Git Notes** architecture to preserve the "Story of the Code."
1326
+ `,"shadow_trace-impact":'---\nname: trace-impact\ndescription: Map the blast radius of a change by analyzing impact, flow traces, cross-repo dependencies, and boundary maps. Use when analyzing change impact, assessing risk, tracing dependencies, or when the user asks about change impact, blast radius, or dependency analysis.\n---\n\n# Impact Analysis\n\nMap the blast radius of a change using the full Shadow analyze toolkit.\n\n## \u{1F680} Workflow\n\n1. **Session Context**: `shadow_ops_context` (repoPath) \u2014 **ONE CALL** for hologram + chronicle + briefing. Check if symbol is in gravity zones.\n2. **Impact (Blast Radius)**: `shadow_analyze_impact` (symbolName, filePath, depth: 3, repoPath) \u2014 ALL affected files.\n3. **Dependencies**:\n - `shadow_analyze_deps` (filePath, direction: "imported_by", repoPath) \u2014 Who imports this?\n - `shadow_analyze_deps` (filePath, direction: "imports", repoPath) \u2014 What does it import?\n4. **Flow Trace**: `shadow_analyze_flow` (symbolName, filePath, repoPath) \u2014 Execution path.\n5. **Health Check**:\n - `shadow_analyze_debt` (mode: "circular-deps", repoPath) \u2014 Any import cycles?\n - `shadow_analyze_debt` (mode: "dead-code", limit: 50, repoPath) \u2014 Unused exports?\n6. **Cross-Repo Check** (if multi-repo):\n - `shadow_workspace_fuse` (repoPaths, repoPath).\n - `shadow_search_symbol` (query, limit: 50, repoPath).\n7. **Boundary Map**: `shadow_recon_topography` (repoPath) \u2014 Layer crossing check.\n8. **Log Risk**: `shadow_ops_log` (missionId, type: "discovery", content, symbolName, repoPath).\n\n## \u{1F6E0} Precise Tooling\n\n| Impact Layer | Atomic Tool |\n| :--- | :--- |\n| **Session Start** \u{1F680} | `shadow_ops_context` (repoPath) \u2014 **START HERE** for context |\n| **Hologram** | `shadow_recon_hologram` (repoPath) \u2014 if you need standalone |\n| **Blast Radius** | `shadow_analyze_impact` (symbolName, depth: 3) |\n| **Dependents** | `shadow_analyze_deps` (filePath, direction: "imported_by") |\n| **Dependencies** | `shadow_analyze_deps` (filePath, direction: "imports") |\n| **Flow Path** | `shadow_analyze_flow` (symbolName, filePath) |\n| **Circular Deps** | `shadow_analyze_debt` (mode: "circular-deps") |\n| **Dead Code** | `shadow_analyze_debt` (mode: "dead-code", **confidenceThreshold: "high"**) |\n| **File Discovery** | `shadow_search_path` (query, **ranked: true**) \u2014 gravity-sorted |\n| **Workspace Fuse**| `shadow_workspace_fuse` (repoPaths, repoPath) |\n| **Topography** | `shadow_recon_topography` |\n\n## \u{1F4A1} Intelligence Options\n\n- **`shadow_search_path` with `ranked: true`**: Find related files sorted by gravity (high-import files first) with layer classification. Helps identify which affected files are architecturally critical.\n- **`shadow_analyze_debt` confidence levels**: Use `confidenceThreshold: "high"` to focus on likely dead code, avoiding noise from test fixtures and migrations.\n\n*Note: **Start with `shadow_ops_context`** for instant gravity zones + architectural context. Use depth higher than 3 for impact analysis only if the symbol is a fundamental primitive (e.g., RepositoryFactory).*\n\n## \u{1F6E0} Risk Classification\n\n- **Critical Risk**: Symbol in gravity zones (top 10) + >20 dependents + crosses layers\n- **High Risk**: >10 dependents OR crosses layers (e.g., Test -> Logic)\n- **Medium Risk**: 5-10 dependents within same layer\n- **Low Risk**: <5 dependents, same layer, no circular deps',shadow_understand:'---\nname: understand\ndescription: Find the high-signal path to understanding complex logic through intent retrieval, topological placement, relational analysis, and mechanics inspection. Use when understanding architecture, analyzing complex code, tracing logic flow, or when the user asks about how something works, architectural patterns, or code comprehension.\n---\n\n# Architectural Understanding\n\nFind the high-signal path to understanding complex logic.\n\n## Workflow\n\n1. **Session Context (The Fast Lane)**: `shadow_ops_context` (repoPath) \u2014 **ONE CALL** returns hologram + chronicle(5) + briefing (relevance-ranked candidates).\n - Skip to step 3 if you have what you need from context alone.\n2. **Optional Expanded Context** (only if shadow_ops_context wasn\'t enough):\n - `shadow_recon_topography` (repoPath) \u2014 Detailed layer breakdown beyond hologram summary.\n - `shadow_recon_tree` (subPath: "src/services", maxDepth: 2, repoPath) \u2014 Visual file hierarchy.\n - `shadow_ops_briefing` (scope: "mission", missionId, altitude: "ground") \u2014 Full mission detail with raw logs, working set, collisions.\n3. **Relational Analysis (The Who)**:\n - `shadow_analyze_impact` (symbolName, filePath, depth: 3, repoPath) \u2014 Blast radius.\n - `shadow_analyze_deps` (filePath, direction: "imported_by", repoPath) \u2014 Who depends on this?\n - `shadow_search_concept` (query, repoPath) \u2014 Semantic search.\n4. **Mechanics (The How)**:\n - **For Logic**: `shadow_analyze_flow` (symbolName, filePath, repoPath) \u2014 Trace execution.\n - **For Objects**: `shadow_inspect_file` (filePath, detailLevel: "signatures", repoPath) \u2014 All exports.\n - **For Symbol Deep Dive**: `shadow_inspect_symbol` (symbolName, filePath, context: "full", repoPath) \u2014 With deps.\n5. **Synthesis**: Log what you discovered.\n - **With an active mission**: `shadow_ops_log` (missionId, type: "discovery", content, symbolName, repoPath)\n - **No active mission / exploring freely**: `shadow_ops_log` (type: "discovery", content, symbolName, standalone: true, repoPath) \u2014 anchors the insight directly to the symbol, no mission needed. These logs appear in future `shadow_inspect_symbol` calls for that symbol.\n\n## Precise Tooling\n\n| Discovery Layer | Atomic Tool |\n| :--------------------- | :---------------------------------------------------- |\n| **Session Start** | `shadow_ops_context` (repoPath) \u2014 **START HERE** |\n| **Hologram** | `shadow_recon_hologram` (repoPath) \u2014 if you need standalone hologram |\n| **History** | `shadow_ops_chronicle` (limit: 5) \u2014 if you need more than 5 from context |\n| **Layers** | `shadow_recon_topography` \u2014 detailed breakdown |\n| **Mission Detail** | `shadow_ops_briefing` (altitude: "ground") \u2014 full logs + working set |\n| **Blast Radius** | `shadow_analyze_impact` (symbolName, depth: 3) |\n| **Dependents** | `shadow_analyze_deps` (filePath, direction: "imported_by") |\n| **Flow Trace** | `shadow_analyze_flow` (symbolName, filePath) |\n| **Structure** | `shadow_inspect_file` (detailLevel: "signatures") |\n| **Deep Dive** | `shadow_inspect_symbol` (context: "full") |\n| **File Discovery** | `shadow_search_path` (query, **ranked: true**) \u2014 gravity-sorted results with layer classification |\n| **Log (mission)** | `shadow_ops_log` (missionId, type, content, symbolName) |\n| **Log (standalone)** | `shadow_ops_log` (type, content, symbolName, **standalone: true**) \u2014 no mission required |\n\n*Note: **ALWAYS start with `shadow_ops_context`** for instant architectural context + history + mission state in ONE call. Use `context: "definition"` for token-efficient single symbol inspection.*\n\n## Intelligence Options\n\n- **`shadow_inspect_symbol` returns recent intent history**: The deep dive response now includes grouped recent intent logs (decisions, fixes, discoveries) tied to that symbol \u2014 from both missions and standalone logs. Check this first before re-investigating a symbol.\n- **Standalone intent logging**: Use `shadow_ops_log` with `standalone: true` + `symbolName` to anchor knowledge to a symbol without needing an active mission. Ideal for exploration sessions. These logs are searchable via `shadow_search_concept` and surface in `shadow_inspect_symbol`.\n- **`shadow_search_path` with `ranked: true`**: Results sorted by gravity (high-import files first) with layer classification (Entry/Logic/Data). Use when you need to find the most architecturally important files matching a pattern.\n- **`shadow_search_concept` with `compact: true`**: Omits code snippets for ~60% token savings. Use for broad exploration before deep dives.\n- **Briefing altitude levels**: Use `orbit` for quick status, `atmosphere` for strategy + crystals, `ground` for raw logs + collisions.\n- **`shadow_ops_crystallize`**: If a symbol has many standalone logs, crystallize by symbolId to compress them. If a mission has excessive raw logs, crystallize by missionId first for leaner briefings.\n',shadow_workspace:`---
1327
+ name: workspace
1328
+ description: Manage multi-repository workspaces and cross-repo mission links using the Shadow Engine. Use when working with multiple repositories, federated search across repos, linking missions across repos, or when the user asks about workspace management, multi-repo workflows, or cross-repository dependencies.
1329
+ ---
1330
+
1331
+ # Workspace Orchestration
1332
+
1333
+ Manage multi-repository workspaces and cross-repo mission links using the Shadow Engine.
1334
+
1335
+ ## \u{1F680} Workflow
1336
+
1337
+ 1. **List Workspaces**: \`shadow_workspace_list\` (repoPath, repoPaths).
1338
+ 2. **Federated Search**: \`shadow_workspace_fuse\` (repoPath, repoPaths).
1339
+ 3. **Link Missions**: \`shadow_workspace_link\` (parentRepoPath, parentMissionId, childRepoPath, childMissionId, relationship, repoPath).
1340
+ 4. **Verify Graph**: \`shadow_ops_graph\` (missionId, depth, repoPath).
1341
+
1342
+ ## \u{1F6E0} Precise Tooling
858
1343
 
859
- `;if(t+=`*Generated at ${new Date(e.generated_at).toISOString()}*
1344
+ | Action | Atomic Tool | Example |
1345
+ | :--- | :--- | :--- |
1346
+ | **List** | \`shadow_workspace_list\` | \`{ repoPath, repoPaths: [...] }\` |
1347
+ | **Fuse** | \`shadow_workspace_fuse\` | \`{ repoPath, repoPaths: [...] }\` |
1348
+ | **Link** | \`shadow_workspace_link\` | \`{ parentMissionId: 1, childMissionId: 2, ... }\` |
1349
+ | **Visualize** | \`shadow_ops_graph\` | \`{ missionId: 1, depth: 3, repoPath }\` |
860
1350
 
861
- `,e.timeline&&e.timeline.length>0)for(let n of e.timeline)n.kind==="initiative"?(t+=`### \u{1F9EC} ${n.title} (Mission #${n.root_mission_id})
862
- `,t+=`${n.synthesized_narrative}
1351
+ *Note: Use fused search after \`shadow_workspace_fuse\` to look up concepts across all repositories simultaneously.*
863
1352
 
864
- `):(t+=`### \u269B\uFE0F ${n.title} (Mission #${n.mission_id})
865
- `,t+=`${n.adr_summary}
1353
+ ## \u{1F6E0} Tooling Strategy
866
1354
 
867
- `),t+=`---
868
- `;return t}};P();import hl from"path";async function Ho(i,e){let t=hl.resolve(i||process.cwd()),n=e.format==="json"?"json":"markdown",s=_.child({module:"cli:chronicle",repoPath:t});s.info("Generating repository chronicle...");try{let r=new Jn(t),o=await r.generateChronicle({limit:e.limit,offset:e.offset,since:e.since,until:e.until});console.log(n==="json"?JSON.stringify(o,null,2):r.renderChronicleMarkdown(o))}catch(r){s.error({error:r},"Failed to generate chronicle"),console.error(`Error: ${r instanceof Error?r.message:String(r)}`),process.exit(1)}}function ce(i){let e=process.cwd();return js(e,i.flags)}process.on("unhandledRejection",i=>{console.error("\x1B[31mUnhandled Rejection:\x1B[0m",i),q().then(()=>process.exit(1))});process.on("uncaughtException",i=>{console.error("\x1B[31mUncaught Exception:\x1B[0m",i),q().then(()=>process.exit(1))});var ee=fl().name("liquid-shadow").version("1.0.2").description("Tactical Repository Intelligence Operative - Liquid Shadow Ecosystem").scriptName("liquid-shadow");ee.command("index","Index the repository for AI analysis",{parameters:["[dir]"],flags:{output:{type:String,alias:"o",description:"Export to JSON file instead of indexing"},level:{type:String,alias:"l",description:"Detail level",default:"detailed"},subPath:{type:String,description:"Only process files within this subpath"},force:{type:Boolean,description:"Force re-indexing of all files",default:!1},deep:{type:Boolean,description:"Perform deep semantic indexing (headings + symbol embeddings)",default:!0}}}).on("index",async i=>{let e=ce(i),t={...i.flags,dir:i.flags.dir??e.dir,level:i.flags.level??e.level,deep:i.flags.deep??e.deep};t.deep==="false"||t.deep===!1?t.deep=!1:t.deep=!0,await or(i.parameters.dir||e.dir,t)});ee.command("status","Show current repository intelligence status",{parameters:["[dir]"]}).on("status",async i=>{let e=ce(i);await Ei(i.parameters.dir||e.dir)});ee.command("metrics","Show performance metrics and observability data",{parameters:["[dir]"]}).on("metrics",async i=>{let e=ce(i);await wi(i.parameters.dir||e.dir)});ee.command("benchmark","Run performance benchmark on repository indexing",{parameters:["[dir]"]}).on("benchmark",async i=>{let e=ce(i);await cr(i.parameters.dir||e.dir)});ee.command("tree","Visualize repository structure as a tree",{parameters:["[dir]"],flags:{subPath:{type:String,description:"Subpath to visualize"},depth:{type:String,alias:"d",description:"Max depth",default:"3"}}}).on("tree",async i=>{let e=ce(i);await sr(i.parameters.dir||e.dir,{...i.flags,dir:i.flags.dir??e.dir})});ee.command("recon","Repository reconnaissance and architecture analysis",{parameters:["<mode>","[dir]"],flags:{subPath:{type:String,description:"Subpath to focus on"}}}).on("recon",async i=>{let e=ce(i);await Yr(i.parameters.mode,i.parameters.dir||e.dir,{...i.flags})});ee.command("trace","Trace execution flow for a given file/symbol",{parameters:["<file>","[symbolName]"],flags:{dir:{type:String,alias:"d",default:"."}}}).on("trace",async i=>{let e=ce(i);await dr(i.parameters.file,{...i.flags,dir:i.flags.dir??e.dir,symbolName:i.parameters.symbolName})});ee.command("sync","Deep synchronize intelligence lifecycle (Trace + Repair + Re-hydrate)",{parameters:["[dir]"]}).on("sync",async i=>{let e=ce(i);await Gr(i.parameters.dir||e.dir,{})});ee.command("search-config","Search for configuration values",{parameters:["[key]"],flags:{dir:{type:String,alias:"d",default:"."},kind:{type:String,description:"Filter by config kind"}}}).on("search-config",async i=>{let e=ce(i);await ro(i.parameters.key,{...i.flags,dir:i.flags.dir??e.dir})});ee.command("search-concept","Search for files by concept/intent (Semantic)",{parameters:["<query>"],flags:{dir:{type:String,alias:"d",default:"."},interactive:{type:Boolean,alias:"i",description:"Interactive TUI: pick a result to inspect",default:!1}}}).on("search-concept",async i=>{let e=ce(i);await no(i.parameters.query,{...i.flags,dir:i.flags.dir??e.dir})});ee.command("search-symbol","Search for specific code symbols",{parameters:["<query>"],flags:{dir:{type:String,alias:"d",default:"."},interactive:{type:Boolean,alias:"i",description:"Interactive TUI: pick a result to inspect",default:!1}}}).on("search-symbol",async i=>{let e=ce(i);await so(i.parameters.query,{...i.flags,dir:i.flags.dir??e.dir})});ee.command("search-fuzzy",'Fuzzy search for symbols (e.g., "usc" finds "UserServiceClient")',{parameters:["<query>"],flags:{dir:{type:String,alias:"d",default:"."},interactive:{type:Boolean,alias:"i",description:"Interactive TUI: pick a result to inspect",default:!1}}}).on("search-fuzzy",async i=>{let e=ce(i);await io(i.parameters.query,{...i.flags,dir:i.flags.dir??e.dir})});ee.command("hooks","Manage git hooks for automatic intelligence updates",{parameters:["<action>","[path]"]}).on("hooks",async i=>{await oo([i.parameters.action,i.parameters.path])});ee.command("workspace","Workspace-level mission orchestration",{parameters:["<action>","[args...]"]}).on("workspace",async i=>{await yo([i.parameters.action,...i.parameters.args])});ee.command("mission","Mission management (start, plan, briefing, distill)",{parameters:["<action>","[args...]"]}).on("mission",async i=>{await Mo([i.parameters.action,...i.parameters.args])});ee.command("inspect","Deep inspection of specific files or symbols",{parameters:["<mode>","[args...]"]}).on("inspect",async i=>{await Po([i.parameters.mode,...i.parameters.args])});ee.command("watch","Watch repo and reindex on file changes",{parameters:["[dir]"]}).on("watch",async i=>{let e=ce(i);await Fo(i.parameters.dir||e.dir)});ee.command("chronicle","Generate a repository-wide narrative feed (ADRs/Epics)",{parameters:["[dir]"],flags:{format:{type:String,alias:"f",description:"Output format (markdown|json)",default:"markdown"},limit:{type:Number,alias:"l",description:"Limit number of entries",default:10},offset:{type:Number,description:"Pagination offset",default:0},since:{type:String,description:"Show entries since date (YYYY-MM-DD)"},until:{type:String,description:"Show entries until date (YYYY-MM-DD)"}}}).on("chronicle",async i=>{let e=ce(i);await Ho(i.parameters.dir||e.dir,{...i.flags,format:i.flags.format,limit:i.flags.limit?parseInt(String(i.flags.limit),10):void 0,offset:i.flags.offset?parseInt(String(i.flags.offset),10):void 0,since:i.flags.since?Math.floor(new Date(String(i.flags.since)).getTime()/1e3):void 0,until:i.flags.until?Math.floor(new Date(String(i.flags.until)).getTime()/1e3):void 0})});ee.command("completion","Generate shell completion script (bash or zsh)",{parameters:["<shell>"]}).on("completion",async i=>{await Oo(i.parameters.shell||"")});ee.parse();
1355
+ Use **\`shadow_workspace_fuse\`** early in multi-repo sessions to unlock "X-Ray" vision across boundaries.`};import*as Ft from"@clack/prompts";function fE(n){return[{name:"Claude Code",dir:fn.join(n,".claude","skills"),folderBased:!0,createIfMissing:!1},{name:"Cursor",dir:fn.join(n,".cursor","skills"),folderBased:!0,createIfMissing:!1},{name:"Gemini CLI",dir:fn.join(n,".gemini","skills"),folderBased:!0,createIfMissing:!0},{name:"Codex",dir:fn.join(n,".codex","skills"),folderBased:!0,createIfMissing:!1},{name:"Antigravity",dir:fn.join(n,".gemini","antigravity","global_workflows"),folderBased:!1,createIfMissing:!1}]}function zf(n=!1){let e=mE.homedir(),r=fE(e),i=0;for(let t of r){if(!mn.existsSync(t.dir))if(t.createIfMissing)mn.mkdirSync(t.dir,{recursive:!0});else continue;for(let[o,s]of Object.entries(L_))if(t.folderBased){let a=fn.join(t.dir,o);mn.existsSync(a)||mn.mkdirSync(a,{recursive:!0});let c=fn.join(a,"SKILL.md");(n||!mn.existsSync(c))&&(mn.writeFileSync(c,s),i++)}else{let a=fn.join(t.dir,`${o}.md`);(n||!mn.existsSync(a))&&(mn.writeFileSync(a,s),i++)}}return i}async function A_(){Ft.intro("\u{1F311} Liquid Shadow: Skills Update");let n=Ft.spinner();n.start("Deploying latest skill definitions...");let e=zf(!0);n.stop("Done."),e>0?Ft.note(`Updated ${e} skill files across all detected targets.`,"Manifest"):Ft.note("No skill targets found (Claude Code, Cursor, Gemini CLI, Codex, Antigravity).","Manifest"),Ft.outro("\u{1F311} Skills are up to date.")}import{pino as gE}from"pino";import*as Te from"@clack/prompts";var gn=gE({transport:{target:"pino-pretty",options:{colorize:!0}}}),Zr="liquid-shadow",O_="liquid-shadow-mcp";async function M_(n=!1,e=!1){Te.intro("\u{1F311} Liquid Shadow: Tactical Onboarding");let r=hE.homedir(),i=0,t=e||await Te.confirm({message:"Deploy Autonomous Reasoning Skills? (Injects /onboard, /understand, etc.)",initialValue:!0});if(Te.isCancel(t)){Te.outro("Onboarding aborted.");return}let o=e||await Te.confirm({message:"Connect to MCP Reasoning Engines? (Claude Code, Claude Desktop, Gemini CLI, Codex)",initialValue:!0});if(Te.isCancel(o)){Te.outro("Onboarding aborted.");return}if(!t&&!o){Te.outro("No actions selected. Operational state unchanged.");return}let s=Te.spinner();s.start("Establishing intelligence assets..."),t&&(i=zf(n)),o&&(yE(r),vE(r)),s.stop("Intelligence layer established."),i>0?Te.note(`Successfully deployed ${i} tactical skills.`,"Manifest"):Te.note("No new skills deployed (up to date or scope skipped).","Manifest"),Te.outro("\u{1F311} Liquid Shadow is operational.")}function yE(n){let e=[{name:"Claude Code",path:Fr.join(n,".claude.json"),extraFields:{type:"stdio"},createIfMissing:!1},{name:"Claude Desktop",path:Fr.join(n,"Library","Application Support","Claude","claude_desktop_config.json"),createIfMissing:!1},{name:"Gemini CLI",path:Fr.join(n,".gemini","settings.json"),createIfMissing:!0},{name:"Antigravity IDE",path:Fr.join(n,".gemini","antigravity","mcp_config.json"),createIfMissing:!1}];for(let r of e){if(!hn.existsSync(r.path))if(r.createIfMissing)hn.mkdirSync(Fr.dirname(r.path),{recursive:!0}),hn.writeFileSync(r.path,"{}");else{gn.debug(`${r.name} config not found at ${r.path}, skipping.`);continue}try{let i=JSON.parse(hn.readFileSync(r.path,"utf8"));if(i.mcpServers||(i.mcpServers={}),i.mcpServers[Zr]){gn.info(`${r.name}: ${Zr} already configured.`);continue}i.mcpServers[Zr]={command:O_,args:[],env:{},...r.extraFields??{}},hn.writeFileSync(r.path,JSON.stringify(i,null,2)),gn.info(`Updated ${r.name} config at ${r.path}`)}catch(i){gn.error(`Failed to update ${r.name} config at ${r.path}: ${i}`)}}}function vE(n){let e=Fr.join(n,".codex","config.toml");if(!hn.existsSync(e)){gn.debug(`Codex config not found at ${e}, skipping.`);return}try{let r=hn.readFileSync(e,"utf8");if(r.includes(`[mcp_servers.${Zr}]`)){gn.info(`Codex: ${Zr} already configured.`);return}let i=`
1356
+ [mcp_servers.${Zr}]
1357
+ command = "${O_}"
1358
+ `;hn.writeFileSync(e,r+i),gn.info(`Updated Codex config at ${e}`)}catch(r){gn.error(`Failed to update Codex config at ${e}: ${r}`)}}function Oe(n){let e=process.cwd();return oc(e,n.flags)}process.on("unhandledRejection",n=>{console.error("\x1B[31mUnhandled Rejection:\x1B[0m",n),ce().then(()=>process.exit(1))});process.on("uncaughtException",n=>{console.error("\x1B[31mUncaught Exception:\x1B[0m",n),ce().then(()=>process.exit(1))});var ve=bE().name("liquid-shadow").version("1.0.2").description("Tactical Repository Intelligence Operative - Liquid Shadow Ecosystem").scriptName("liquid-shadow");ve.command("index","Index the repository for AI analysis",{parameters:["[dir]"],flags:{output:{type:String,alias:"o",description:"Export to JSON file instead of indexing"},level:{type:String,alias:"l",description:"Detail level",default:"detailed"},subPath:{type:String,description:"Only process files within this subpath"},force:{type:Boolean,description:"Force re-indexing of all files",default:!1},deep:{type:Boolean,description:"Perform deep semantic indexing (headings + symbol embeddings)",default:!0}}}).on("index",async n=>{let e=Oe(n),r={...n.flags,dir:n.flags.dir??e.dir,level:n.flags.level??e.level,deep:n.flags.deep??e.deep};r.deep==="false"||r.deep===!1?r.deep=!1:r.deep=!0,await g_(n.parameters.dir||e.dir,r)});ve.command("status","Show current repository intelligence status",{parameters:["[dir]"]}).on("status",async n=>{let e=Oe(n);await mh(n.parameters.dir||e.dir)});ve.command("dashboard","Operational intelligence dashboard (TUI)",{parameters:["[dir]"]}).on("dashboard",async n=>{let e=Oe(n);await vc(n.parameters.dir||e.dir)});ve.command("metrics","Show performance metrics and observability data",{parameters:["[dir]"]}).on("metrics",async n=>{let e=Oe(n);await vh(n.parameters.dir||e.dir)});ve.command("benchmark","Run performance benchmark on repository indexing",{parameters:["[dir]"]}).on("benchmark",async n=>{let e=Oe(n);await v_(n.parameters.dir||e.dir)});ve.command("tree","Visualize repository structure as a tree",{parameters:["[dir]"],flags:{subPath:{type:String,description:"Subpath to visualize"},depth:{type:String,alias:"d",description:"Max depth",default:"3"}}}).on("tree",async n=>{let e=Oe(n);await f_(n.parameters.dir||e.dir,{...n.flags,dir:n.flags.dir??e.dir})});ve.command("recon","Repository reconnaissance and architecture analysis",{parameters:["<mode>","[dir]"],flags:{subPath:{type:String,description:"Subpath to focus on"}}}).on("recon",async n=>{let e=Oe(n);await S_(n.parameters.mode,n.parameters.dir||e.dir,{...n.flags})});ve.command("trace","Trace execution flow for a given file/symbol",{parameters:["<file>","[symbolName]"],flags:{dir:{type:String,alias:"d",default:"."}}}).on("trace",async n=>{let e=Oe(n);await b_(n.parameters.file,{...n.flags,dir:n.flags.dir??e.dir,symbolName:n.parameters.symbolName})});ve.command("sync","Deep synchronize intelligence lifecycle (Trace + Repair + Re-hydrate)",{parameters:["[dir]"]}).on("sync",async n=>{let e=Oe(n);await __(n.parameters.dir||e.dir,{})});ve.command("search-config","Search for configuration values",{parameters:["[key]"],flags:{dir:{type:String,alias:"d",default:"."},kind:{type:String,description:"Filter by config kind"}}}).on("search-config",async n=>{let e=Oe(n);await E_(n.parameters.key,{...n.flags,dir:n.flags.dir??e.dir})});ve.command("search-concept","Search for files by concept/intent (Semantic)",{parameters:["<query>"],flags:{dir:{type:String,alias:"d",default:"."},interactive:{type:Boolean,alias:"i",description:"Interactive TUI: pick a result to inspect",default:!1}}}).on("search-concept",async n=>{let e=Oe(n);await $_(n.parameters.query,{...n.flags,dir:n.flags.dir??e.dir})});ve.command("search-symbol","Search for specific code symbols",{parameters:["<query>"],flags:{dir:{type:String,alias:"d",default:"."},interactive:{type:Boolean,alias:"i",description:"Interactive TUI: pick a result to inspect",default:!1}}}).on("search-symbol",async n=>{let e=Oe(n);await w_(n.parameters.query,{...n.flags,dir:n.flags.dir??e.dir})});ve.command("search-fuzzy",'Fuzzy search for symbols (e.g., "usc" finds "UserServiceClient")',{parameters:["<query>"],flags:{dir:{type:String,alias:"d",default:"."},interactive:{type:Boolean,alias:"i",description:"Interactive TUI: pick a result to inspect",default:!1}}}).on("search-fuzzy",async n=>{let e=Oe(n);await k_(n.parameters.query,{...n.flags,dir:n.flags.dir??e.dir})});ve.command("hooks","Manage git hooks for automatic intelligence updates",{parameters:["<action>","[path]"]}).on("hooks",async n=>{await I_([n.parameters.action,n.parameters.path])});ve.command("workspace","Workspace-level mission orchestration",{parameters:["<action>","[args...]"]}).on("workspace",async n=>{await T_([n.parameters.action,...n.parameters.args])});ve.command("mission","Mission management (start, plan, briefing, distill)",{parameters:["<action>","[args...]"]}).on("mission",async n=>{await P_([n.parameters.action,...n.parameters.args])});ve.command("inspect","Deep inspection of specific files or symbols",{parameters:["<mode>","[args...]"]}).on("inspect",async n=>{await R_([n.parameters.mode,...n.parameters.args])});ve.command("watch","Watch repo and reindex on file changes",{parameters:["[dir]"]}).on("watch",async n=>{let e=Oe(n);await D_(n.parameters.dir||e.dir)});ve.command("chronicle","Generate a repository-wide narrative feed (ADRs/Epics)",{parameters:["[dir]"],flags:{format:{type:String,alias:"f",description:"Output format (markdown|json)",default:"markdown"},limit:{type:Number,alias:"l",description:"Limit number of entries",default:10},offset:{type:Number,description:"Pagination offset",default:0},since:{type:String,description:"Show entries since date (YYYY-MM-DD)"},until:{type:String,description:"Show entries until date (YYYY-MM-DD)"}}}).on("chronicle",async n=>{let e=Oe(n);await C_(n.parameters.dir||e.dir,{...n.flags,format:n.flags.format,limit:n.flags.limit?parseInt(String(n.flags.limit),10):void 0,offset:n.flags.offset?parseInt(String(n.flags.offset),10):void 0,since:n.flags.since?Math.floor(new Date(String(n.flags.since)).getTime()/1e3):void 0,until:n.flags.until?Math.floor(new Date(String(n.flags.until)).getTime()/1e3):void 0})});ve.command("init","Initialize Liquid Shadow skills and configuration",{flags:{force:{type:Boolean,alias:"f",description:"Force overwrite existing skills",default:!1},yes:{type:Boolean,alias:"y",description:"Skip interactive confirmation (unsafe)",default:!1}}}).on("init",async n=>{await M_(n.flags.force,n.flags.yes)});ve.command("skills","Manage Liquid Shadow reasoning skills",{parameters:["<action>"]}).on("skills",async n=>{let e=n.parameters.action;e==="update"?await A_():(console.error(`Unknown skills action: ${e}. Available: update`),process.exit(1))});ve.command("completion","Generate shell completion script (bash or zsh)",{parameters:["<shell>"]}).on("completion",async n=>{await z_(n.parameters.shell||"")});if(process.argv.length<=2){let n=oc(process.cwd(),{});vc(n.dir)}else ve.parse();