@origintrail-official/dkg-node-ui 10.0.20 → 10.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/api.d.ts +7 -1
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +22 -1
- package/dist/api.js.map +1 -1
- package/dist/chain-cursor-stores.d.ts +11 -108
- package/dist/chain-cursor-stores.d.ts.map +1 -1
- package/dist/chain-cursor-stores.js +11 -287
- package/dist/chain-cursor-stores.js.map +1 -1
- package/dist/chain-event-log-store.d.ts +10 -112
- package/dist/chain-event-log-store.d.ts.map +1 -1
- package/dist/chain-event-log-store.js +9 -360
- package/dist/chain-event-log-store.js.map +1 -1
- package/dist/chat-memory.d.ts +1 -0
- package/dist/chat-memory.d.ts.map +1 -1
- package/dist/chat-memory.js +31 -39
- package/dist/chat-memory.js.map +1 -1
- package/dist/chat-turn-subject.d.ts +18 -0
- package/dist/chat-turn-subject.d.ts.map +1 -0
- package/dist/chat-turn-subject.js +52 -0
- package/dist/chat-turn-subject.js.map +1 -0
- package/dist/db.d.ts +2 -143
- package/dist/db.d.ts.map +1 -1
- package/dist/db.js +9 -387
- package/dist/db.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -3
- package/dist/index.js.map +1 -1
- package/dist/metrics-collector.d.ts +11 -1
- package/dist/metrics-collector.d.ts.map +1 -1
- package/dist/metrics-collector.js +77 -39
- package/dist/metrics-collector.js.map +1 -1
- package/dist/protocol-outbox-store.d.ts +9 -64
- package/dist/protocol-outbox-store.d.ts.map +1 -1
- package/dist/protocol-outbox-store.js +11 -198
- package/dist/protocol-outbox-store.js.map +1 -1
- package/dist-ui/assets/{3d-force-graph-CehOGxux.js → 3d-force-graph-DbVwxMKf.js} +1 -1
- package/dist-ui/assets/{ActivityFeed-BE4MTD8M.js → ActivityFeed-Bfg6fmQQ.js} +1 -1
- package/dist-ui/assets/{AgentHub-CT6UhLF2.js → AgentHub-DyF5Pa70.js} +1 -1
- package/dist-ui/assets/{AgentProfilePage-ygi-GXKM.js → AgentProfilePage-BPrSuKjV.js} +1 -1
- package/dist-ui/assets/{ApproveWalletsModal-YFfDrGth.js → ApproveWalletsModal-Dd_tHLRP.js} +1 -1
- package/dist-ui/assets/{ContextGraphPrimitives-Dh-w2D_i.js → ContextGraphPrimitives-BXormriD.js} +1 -1
- package/dist-ui/assets/{ConvictionDetailView-CfRmqqDD.js → ConvictionDetailView-BsPTd17P.js} +1 -1
- package/dist-ui/assets/{MemoryLayerView-DL0zLYAQ.js → MemoryLayerView-CloJeM33.js} +2 -2
- package/dist-ui/assets/{MemoryStackView-BsV_JnOe.js → MemoryStackView-BbUJ2uiM.js} +1 -1
- package/dist-ui/assets/{Network-BkxRENe4.js → Network-BKvJttOu.js} +1 -1
- package/dist-ui/assets/{OnChainProvenanceCard-CnnkMMNI.js → OnChainProvenanceCard-BV9-G1cT.js} +1 -1
- package/dist-ui/assets/{Operations-BaWWLSUw.js → Operations-LAhUQsnj.js} +1 -1
- package/dist-ui/assets/{ProjectView-BJmZ5f62.js → ProjectView-0zCSblAV.js} +3 -3
- package/dist-ui/assets/{PublishingConviction-CKB6JBYk.js → PublishingConviction-CF6352oT.js} +1 -1
- package/dist-ui/assets/{Settings-DXGMPiJk.js → Settings-runaZqPv.js} +1 -1
- package/dist-ui/assets/{browserWalletTransaction-BdmrJpK1.js → browserWalletTransaction-CBgx0i4w.js} +3 -3
- package/dist-ui/assets/{ccip-BNYiIkjs.js → ccip-BM07w5uU.js} +1 -1
- package/dist-ui/assets/{index-DOGXDQkQ.js → index-CfVUpsfM.js} +3 -3
- package/dist-ui/assets/{index-DK8XzE3T.js → index-MQh8C4aJ.js} +90 -90
- package/dist-ui/assets/index-xKO-U_eV.css +1 -0
- package/dist-ui/assets/{jsonld-32FQRO67-Ca-KnQfb.js → jsonld-32FQRO67-DBZOBQji.js} +2 -2
- package/dist-ui/assets/{jsonld-mRC9FbFR.js → jsonld-DOX7dKpf.js} +1 -1
- package/dist-ui/assets/{renderer-3d-2EVDZII7-AEMBPIY7.js → renderer-3d-2EVDZII7-CVCpAmwB.js} +2 -2
- package/dist-ui/assets/{shikiHighlighter-CUQ07vzt.js → shikiHighlighter-CzU2U2Tx.js} +1 -1
- package/dist-ui/assets/{useEntityOnChainReceipt-C8NHlPPN.js → useEntityOnChainReceipt-BvWQ6qdT.js} +1 -1
- package/dist-ui/assets/{useProjectActivity-CVFCfbMj.js → useProjectActivity-Cxr4QGX1.js} +1 -1
- package/dist-ui/index.html +2 -2
- package/package.json +6 -4
- package/dist-ui/assets/index-BLQUVvVz.css +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{x as si,az as le,bd as $,R as P,k as ne,aO as h,bz as Re,ac as Zx,ab as Jx,a9 as Qx,ad as e1,aa as t1,at as vt,a2 as r1,Z as n1,a0 as i1,a4 as a1,ag as o1,a8 as s1,an as lt,a6 as u1,a5 as c1,af as l1,bi}from"./index-DK8XzE3T.js";import{h as fd,m as dd,o as Lg,d as at,a as f1,e as Gc,c as hd,f as pd,g as d1,b as Pt,i as h1}from"./string-DtUow4KV.js";function qg(e){var t,r,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(r=qg(e[t]))&&(n&&(n+=" "),n+=r)}else for(r in e)e[r]&&(n&&(n+=" "),n+=r);return n}function te(){for(var e,t,r=0,n="",i=arguments.length;r<i;r++)(e=arguments[r])&&(t=qg(e))&&(n&&(n+=" "),n+=t);return n}var Xa,vd;function Be(){if(vd)return Xa;vd=1;var e=Array.isArray;return Xa=e,Xa}var Ya,yd;function zg(){if(yd)return Ya;yd=1;var e=typeof si=="object"&&si&&si.Object===Object&&si;return Ya=e,Ya}var Za,md;function ht(){if(md)return Za;md=1;var e=zg(),t=typeof self=="object"&&self&&self.Object===Object&&self,r=e||t||Function("return this")();return Za=r,Za}var Ja,gd;function ei(){if(gd)return Ja;gd=1;var e=ht(),t=e.Symbol;return Ja=t,Ja}var Qa,bd;function p1(){if(bd)return Qa;bd=1;var e=ei(),t=Object.prototype,r=t.hasOwnProperty,n=t.toString,i=e?e.toStringTag:void 0;function a(o){var s=r.call(o,i),u=o[i];try{o[i]=void 0;var c=!0}catch{}var f=n.call(o);return c&&(s?o[i]=u:delete o[i]),f}return Qa=a,Qa}var eo,xd;function v1(){if(xd)return eo;xd=1;var e=Object.prototype,t=e.toString;function r(n){return t.call(n)}return eo=r,eo}var to,wd;function Tt(){if(wd)return to;wd=1;var e=ei(),t=p1(),r=v1(),n="[object Null]",i="[object Undefined]",a=e?e.toStringTag:void 0;function o(s){return s==null?s===void 0?i:n:a&&a in Object(s)?t(s):r(s)}return to=o,to}var ro,_d;function Et(){if(_d)return ro;_d=1;function e(t){return t!=null&&typeof t=="object"}return ro=e,ro}var no,Od;function Hr(){if(Od)return no;Od=1;var e=Tt(),t=Et(),r="[object Symbol]";function n(i){return typeof i=="symbol"||t(i)&&e(i)==r}return no=n,no}var io,Sd;function sf(){if(Sd)return io;Sd=1;var e=Be(),t=Hr(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;function i(a,o){if(e(a))return!1;var s=typeof a;return s=="number"||s=="symbol"||s=="boolean"||a==null||t(a)?!0:n.test(a)||!r.test(a)||o!=null&&a in Object(o)}return io=i,io}var ao,jd;function qt(){if(jd)return ao;jd=1;function e(t){var r=typeof t;return t!=null&&(r=="object"||r=="function")}return ao=e,ao}var oo,Ad;function uf(){if(Ad)return oo;Ad=1;var e=Tt(),t=qt(),r="[object AsyncFunction]",n="[object Function]",i="[object GeneratorFunction]",a="[object Proxy]";function o(s){if(!t(s))return!1;var u=e(s);return u==n||u==i||u==r||u==a}return oo=o,oo}var so,Pd;function y1(){if(Pd)return so;Pd=1;var e=ht(),t=e["__core-js_shared__"];return so=t,so}var uo,Td;function m1(){if(Td)return uo;Td=1;var e=y1(),t=(function(){var n=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""})();function r(n){return!!t&&t in n}return uo=r,uo}var co,Ed;function Fg(){if(Ed)return co;Ed=1;var e=Function.prototype,t=e.toString;function r(n){if(n!=null){try{return t.call(n)}catch{}try{return n+""}catch{}}return""}return co=r,co}var lo,Md;function g1(){if(Md)return lo;Md=1;var e=uf(),t=m1(),r=qt(),n=Fg(),i=/[\\^$.*+?()[\]{}|]/g,a=/^\[object .+?Constructor\]$/,o=Function.prototype,s=Object.prototype,u=o.toString,c=s.hasOwnProperty,f=RegExp("^"+u.call(c).replace(i,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function l(d){if(!r(d)||t(d))return!1;var v=e(d)?f:a;return v.test(n(d))}return lo=l,lo}var fo,Cd;function b1(){if(Cd)return fo;Cd=1;function e(t,r){return t==null?void 0:t[r]}return fo=e,fo}var ho,Id;function lr(){if(Id)return ho;Id=1;var e=g1(),t=b1();function r(n,i){var a=t(n,i);return e(a)?a:void 0}return ho=r,ho}var po,kd;function ya(){if(kd)return po;kd=1;var e=lr(),t=e(Object,"create");return po=t,po}var vo,$d;function x1(){if($d)return vo;$d=1;var e=ya();function t(){this.__data__=e?e(null):{},this.size=0}return vo=t,vo}var yo,Nd;function w1(){if(Nd)return yo;Nd=1;function e(t){var r=this.has(t)&&delete this.__data__[t];return this.size-=r?1:0,r}return yo=e,yo}var mo,Rd;function _1(){if(Rd)return mo;Rd=1;var e=ya(),t="__lodash_hash_undefined__",r=Object.prototype,n=r.hasOwnProperty;function i(a){var o=this.__data__;if(e){var s=o[a];return s===t?void 0:s}return n.call(o,a)?o[a]:void 0}return mo=i,mo}var go,Dd;function O1(){if(Dd)return go;Dd=1;var e=ya(),t=Object.prototype,r=t.hasOwnProperty;function n(i){var a=this.__data__;return e?a[i]!==void 0:r.call(a,i)}return go=n,go}var bo,Bd;function S1(){if(Bd)return bo;Bd=1;var e=ya(),t="__lodash_hash_undefined__";function r(n,i){var a=this.__data__;return this.size+=this.has(n)?0:1,a[n]=e&&i===void 0?t:i,this}return bo=r,bo}var xo,Ld;function j1(){if(Ld)return xo;Ld=1;var e=x1(),t=w1(),r=_1(),n=O1(),i=S1();function a(o){var s=-1,u=o==null?0:o.length;for(this.clear();++s<u;){var c=o[s];this.set(c[0],c[1])}}return a.prototype.clear=e,a.prototype.delete=t,a.prototype.get=r,a.prototype.has=n,a.prototype.set=i,xo=a,xo}var wo,qd;function A1(){if(qd)return wo;qd=1;function e(){this.__data__=[],this.size=0}return wo=e,wo}var _o,zd;function cf(){if(zd)return _o;zd=1;function e(t,r){return t===r||t!==t&&r!==r}return _o=e,_o}var Oo,Fd;function ma(){if(Fd)return Oo;Fd=1;var e=cf();function t(r,n){for(var i=r.length;i--;)if(e(r[i][0],n))return i;return-1}return Oo=t,Oo}var So,Wd;function P1(){if(Wd)return So;Wd=1;var e=ma(),t=Array.prototype,r=t.splice;function n(i){var a=this.__data__,o=e(a,i);if(o<0)return!1;var s=a.length-1;return o==s?a.pop():r.call(a,o,1),--this.size,!0}return So=n,So}var jo,Ud;function T1(){if(Ud)return jo;Ud=1;var e=ma();function t(r){var n=this.__data__,i=e(n,r);return i<0?void 0:n[i][1]}return jo=t,jo}var Ao,Gd;function E1(){if(Gd)return Ao;Gd=1;var e=ma();function t(r){return e(this.__data__,r)>-1}return Ao=t,Ao}var Po,Hd;function M1(){if(Hd)return Po;Hd=1;var e=ma();function t(r,n){var i=this.__data__,a=e(i,r);return a<0?(++this.size,i.push([r,n])):i[a][1]=n,this}return Po=t,Po}var To,Kd;function ga(){if(Kd)return To;Kd=1;var e=A1(),t=P1(),r=T1(),n=E1(),i=M1();function a(o){var s=-1,u=o==null?0:o.length;for(this.clear();++s<u;){var c=o[s];this.set(c[0],c[1])}}return a.prototype.clear=e,a.prototype.delete=t,a.prototype.get=r,a.prototype.has=n,a.prototype.set=i,To=a,To}var Eo,Vd;function lf(){if(Vd)return Eo;Vd=1;var e=lr(),t=ht(),r=e(t,"Map");return Eo=r,Eo}var Mo,Xd;function C1(){if(Xd)return Mo;Xd=1;var e=j1(),t=ga(),r=lf();function n(){this.size=0,this.__data__={hash:new e,map:new(r||t),string:new e}}return Mo=n,Mo}var Co,Yd;function I1(){if(Yd)return Co;Yd=1;function e(t){var r=typeof t;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?t!=="__proto__":t===null}return Co=e,Co}var Io,Zd;function ba(){if(Zd)return Io;Zd=1;var e=I1();function t(r,n){var i=r.__data__;return e(n)?i[typeof n=="string"?"string":"hash"]:i.map}return Io=t,Io}var ko,Jd;function k1(){if(Jd)return ko;Jd=1;var e=ba();function t(r){var n=e(this,r).delete(r);return this.size-=n?1:0,n}return ko=t,ko}var $o,Qd;function $1(){if(Qd)return $o;Qd=1;var e=ba();function t(r){return e(this,r).get(r)}return $o=t,$o}var No,eh;function N1(){if(eh)return No;eh=1;var e=ba();function t(r){return e(this,r).has(r)}return No=t,No}var Ro,th;function R1(){if(th)return Ro;th=1;var e=ba();function t(r,n){var i=e(this,r),a=i.size;return i.set(r,n),this.size+=i.size==a?0:1,this}return Ro=t,Ro}var Do,rh;function ff(){if(rh)return Do;rh=1;var e=C1(),t=k1(),r=$1(),n=N1(),i=R1();function a(o){var s=-1,u=o==null?0:o.length;for(this.clear();++s<u;){var c=o[s];this.set(c[0],c[1])}}return a.prototype.clear=e,a.prototype.delete=t,a.prototype.get=r,a.prototype.has=n,a.prototype.set=i,Do=a,Do}var Bo,nh;function Wg(){if(nh)return Bo;nh=1;var e=ff(),t="Expected a function";function r(n,i){if(typeof n!="function"||i!=null&&typeof i!="function")throw new TypeError(t);var a=function(){var o=arguments,s=i?i.apply(this,o):o[0],u=a.cache;if(u.has(s))return u.get(s);var c=n.apply(this,o);return a.cache=u.set(s,c)||u,c};return a.cache=new(r.Cache||e),a}return r.Cache=e,Bo=r,Bo}var Lo,ih;function D1(){if(ih)return Lo;ih=1;var e=Wg(),t=500;function r(n){var i=e(n,function(o){return a.size===t&&a.clear(),o}),a=i.cache;return i}return Lo=r,Lo}var qo,ah;function B1(){if(ah)return qo;ah=1;var e=D1(),t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,r=/\\(\\)?/g,n=e(function(i){var a=[];return i.charCodeAt(0)===46&&a.push(""),i.replace(t,function(o,s,u,c){a.push(u?c.replace(r,"$1"):s||o)}),a});return qo=n,qo}var zo,oh;function df(){if(oh)return zo;oh=1;function e(t,r){for(var n=-1,i=t==null?0:t.length,a=Array(i);++n<i;)a[n]=r(t[n],n,t);return a}return zo=e,zo}var Fo,sh;function L1(){if(sh)return Fo;sh=1;var e=ei(),t=df(),r=Be(),n=Hr(),i=e?e.prototype:void 0,a=i?i.toString:void 0;function o(s){if(typeof s=="string")return s;if(r(s))return t(s,o)+"";if(n(s))return a?a.call(s):"";var u=s+"";return u=="0"&&1/s==-1/0?"-0":u}return Fo=o,Fo}var Wo,uh;function Ug(){if(uh)return Wo;uh=1;var e=L1();function t(r){return r==null?"":e(r)}return Wo=t,Wo}var Uo,ch;function Gg(){if(ch)return Uo;ch=1;var e=Be(),t=sf(),r=B1(),n=Ug();function i(a,o){return e(a)?a:t(a,o)?[a]:r(n(a))}return Uo=i,Uo}var Go,lh;function xa(){if(lh)return Go;lh=1;var e=Hr();function t(r){if(typeof r=="string"||e(r))return r;var n=r+"";return n=="0"&&1/r==-1/0?"-0":n}return Go=t,Go}var Ho,fh;function hf(){if(fh)return Ho;fh=1;var e=Gg(),t=xa();function r(n,i){i=e(i,n);for(var a=0,o=i.length;n!=null&&a<o;)n=n[t(i[a++])];return a&&a==o?n:void 0}return Ho=r,Ho}var Ko,dh;function Hg(){if(dh)return Ko;dh=1;var e=hf();function t(r,n,i){var a=r==null?void 0:e(r,n);return a===void 0?i:a}return Ko=t,Ko}var q1=Hg();const Je=le(q1);var Vo,hh;function z1(){if(hh)return Vo;hh=1;function e(t){return t==null}return Vo=e,Vo}var F1=z1();const Q=le(F1);var Xo,ph;function W1(){if(ph)return Xo;ph=1;var e=Tt(),t=Be(),r=Et(),n="[object String]";function i(a){return typeof a=="string"||!t(a)&&r(a)&&e(a)==n}return Xo=i,Xo}var U1=W1();const ar=le(U1);var G1=uf();const Y=le(G1);var H1=qt();const Kr=le(H1);var Yo={exports:{}},ie={};/**
|
|
1
|
+
import{x as si,az as le,bd as $,R as P,k as ne,aO as h,bz as Re,ac as Zx,ab as Jx,a9 as Qx,ad as e1,aa as t1,at as vt,a2 as r1,Z as n1,a0 as i1,a4 as a1,ag as o1,a8 as s1,an as lt,a6 as u1,a5 as c1,af as l1,bi}from"./index-MQh8C4aJ.js";import{h as fd,m as dd,o as Lg,d as at,a as f1,e as Gc,c as hd,f as pd,g as d1,b as Pt,i as h1}from"./string-DtUow4KV.js";function qg(e){var t,r,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(r=qg(e[t]))&&(n&&(n+=" "),n+=r)}else for(r in e)e[r]&&(n&&(n+=" "),n+=r);return n}function te(){for(var e,t,r=0,n="",i=arguments.length;r<i;r++)(e=arguments[r])&&(t=qg(e))&&(n&&(n+=" "),n+=t);return n}var Xa,vd;function Be(){if(vd)return Xa;vd=1;var e=Array.isArray;return Xa=e,Xa}var Ya,yd;function zg(){if(yd)return Ya;yd=1;var e=typeof si=="object"&&si&&si.Object===Object&&si;return Ya=e,Ya}var Za,md;function ht(){if(md)return Za;md=1;var e=zg(),t=typeof self=="object"&&self&&self.Object===Object&&self,r=e||t||Function("return this")();return Za=r,Za}var Ja,gd;function ei(){if(gd)return Ja;gd=1;var e=ht(),t=e.Symbol;return Ja=t,Ja}var Qa,bd;function p1(){if(bd)return Qa;bd=1;var e=ei(),t=Object.prototype,r=t.hasOwnProperty,n=t.toString,i=e?e.toStringTag:void 0;function a(o){var s=r.call(o,i),u=o[i];try{o[i]=void 0;var c=!0}catch{}var f=n.call(o);return c&&(s?o[i]=u:delete o[i]),f}return Qa=a,Qa}var eo,xd;function v1(){if(xd)return eo;xd=1;var e=Object.prototype,t=e.toString;function r(n){return t.call(n)}return eo=r,eo}var to,wd;function Tt(){if(wd)return to;wd=1;var e=ei(),t=p1(),r=v1(),n="[object Null]",i="[object Undefined]",a=e?e.toStringTag:void 0;function o(s){return s==null?s===void 0?i:n:a&&a in Object(s)?t(s):r(s)}return to=o,to}var ro,_d;function Et(){if(_d)return ro;_d=1;function e(t){return t!=null&&typeof t=="object"}return ro=e,ro}var no,Od;function Hr(){if(Od)return no;Od=1;var e=Tt(),t=Et(),r="[object Symbol]";function n(i){return typeof i=="symbol"||t(i)&&e(i)==r}return no=n,no}var io,Sd;function sf(){if(Sd)return io;Sd=1;var e=Be(),t=Hr(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;function i(a,o){if(e(a))return!1;var s=typeof a;return s=="number"||s=="symbol"||s=="boolean"||a==null||t(a)?!0:n.test(a)||!r.test(a)||o!=null&&a in Object(o)}return io=i,io}var ao,jd;function qt(){if(jd)return ao;jd=1;function e(t){var r=typeof t;return t!=null&&(r=="object"||r=="function")}return ao=e,ao}var oo,Ad;function uf(){if(Ad)return oo;Ad=1;var e=Tt(),t=qt(),r="[object AsyncFunction]",n="[object Function]",i="[object GeneratorFunction]",a="[object Proxy]";function o(s){if(!t(s))return!1;var u=e(s);return u==n||u==i||u==r||u==a}return oo=o,oo}var so,Pd;function y1(){if(Pd)return so;Pd=1;var e=ht(),t=e["__core-js_shared__"];return so=t,so}var uo,Td;function m1(){if(Td)return uo;Td=1;var e=y1(),t=(function(){var n=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""})();function r(n){return!!t&&t in n}return uo=r,uo}var co,Ed;function Fg(){if(Ed)return co;Ed=1;var e=Function.prototype,t=e.toString;function r(n){if(n!=null){try{return t.call(n)}catch{}try{return n+""}catch{}}return""}return co=r,co}var lo,Md;function g1(){if(Md)return lo;Md=1;var e=uf(),t=m1(),r=qt(),n=Fg(),i=/[\\^$.*+?()[\]{}|]/g,a=/^\[object .+?Constructor\]$/,o=Function.prototype,s=Object.prototype,u=o.toString,c=s.hasOwnProperty,f=RegExp("^"+u.call(c).replace(i,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function l(d){if(!r(d)||t(d))return!1;var v=e(d)?f:a;return v.test(n(d))}return lo=l,lo}var fo,Cd;function b1(){if(Cd)return fo;Cd=1;function e(t,r){return t==null?void 0:t[r]}return fo=e,fo}var ho,Id;function lr(){if(Id)return ho;Id=1;var e=g1(),t=b1();function r(n,i){var a=t(n,i);return e(a)?a:void 0}return ho=r,ho}var po,kd;function ya(){if(kd)return po;kd=1;var e=lr(),t=e(Object,"create");return po=t,po}var vo,$d;function x1(){if($d)return vo;$d=1;var e=ya();function t(){this.__data__=e?e(null):{},this.size=0}return vo=t,vo}var yo,Nd;function w1(){if(Nd)return yo;Nd=1;function e(t){var r=this.has(t)&&delete this.__data__[t];return this.size-=r?1:0,r}return yo=e,yo}var mo,Rd;function _1(){if(Rd)return mo;Rd=1;var e=ya(),t="__lodash_hash_undefined__",r=Object.prototype,n=r.hasOwnProperty;function i(a){var o=this.__data__;if(e){var s=o[a];return s===t?void 0:s}return n.call(o,a)?o[a]:void 0}return mo=i,mo}var go,Dd;function O1(){if(Dd)return go;Dd=1;var e=ya(),t=Object.prototype,r=t.hasOwnProperty;function n(i){var a=this.__data__;return e?a[i]!==void 0:r.call(a,i)}return go=n,go}var bo,Bd;function S1(){if(Bd)return bo;Bd=1;var e=ya(),t="__lodash_hash_undefined__";function r(n,i){var a=this.__data__;return this.size+=this.has(n)?0:1,a[n]=e&&i===void 0?t:i,this}return bo=r,bo}var xo,Ld;function j1(){if(Ld)return xo;Ld=1;var e=x1(),t=w1(),r=_1(),n=O1(),i=S1();function a(o){var s=-1,u=o==null?0:o.length;for(this.clear();++s<u;){var c=o[s];this.set(c[0],c[1])}}return a.prototype.clear=e,a.prototype.delete=t,a.prototype.get=r,a.prototype.has=n,a.prototype.set=i,xo=a,xo}var wo,qd;function A1(){if(qd)return wo;qd=1;function e(){this.__data__=[],this.size=0}return wo=e,wo}var _o,zd;function cf(){if(zd)return _o;zd=1;function e(t,r){return t===r||t!==t&&r!==r}return _o=e,_o}var Oo,Fd;function ma(){if(Fd)return Oo;Fd=1;var e=cf();function t(r,n){for(var i=r.length;i--;)if(e(r[i][0],n))return i;return-1}return Oo=t,Oo}var So,Wd;function P1(){if(Wd)return So;Wd=1;var e=ma(),t=Array.prototype,r=t.splice;function n(i){var a=this.__data__,o=e(a,i);if(o<0)return!1;var s=a.length-1;return o==s?a.pop():r.call(a,o,1),--this.size,!0}return So=n,So}var jo,Ud;function T1(){if(Ud)return jo;Ud=1;var e=ma();function t(r){var n=this.__data__,i=e(n,r);return i<0?void 0:n[i][1]}return jo=t,jo}var Ao,Gd;function E1(){if(Gd)return Ao;Gd=1;var e=ma();function t(r){return e(this.__data__,r)>-1}return Ao=t,Ao}var Po,Hd;function M1(){if(Hd)return Po;Hd=1;var e=ma();function t(r,n){var i=this.__data__,a=e(i,r);return a<0?(++this.size,i.push([r,n])):i[a][1]=n,this}return Po=t,Po}var To,Kd;function ga(){if(Kd)return To;Kd=1;var e=A1(),t=P1(),r=T1(),n=E1(),i=M1();function a(o){var s=-1,u=o==null?0:o.length;for(this.clear();++s<u;){var c=o[s];this.set(c[0],c[1])}}return a.prototype.clear=e,a.prototype.delete=t,a.prototype.get=r,a.prototype.has=n,a.prototype.set=i,To=a,To}var Eo,Vd;function lf(){if(Vd)return Eo;Vd=1;var e=lr(),t=ht(),r=e(t,"Map");return Eo=r,Eo}var Mo,Xd;function C1(){if(Xd)return Mo;Xd=1;var e=j1(),t=ga(),r=lf();function n(){this.size=0,this.__data__={hash:new e,map:new(r||t),string:new e}}return Mo=n,Mo}var Co,Yd;function I1(){if(Yd)return Co;Yd=1;function e(t){var r=typeof t;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?t!=="__proto__":t===null}return Co=e,Co}var Io,Zd;function ba(){if(Zd)return Io;Zd=1;var e=I1();function t(r,n){var i=r.__data__;return e(n)?i[typeof n=="string"?"string":"hash"]:i.map}return Io=t,Io}var ko,Jd;function k1(){if(Jd)return ko;Jd=1;var e=ba();function t(r){var n=e(this,r).delete(r);return this.size-=n?1:0,n}return ko=t,ko}var $o,Qd;function $1(){if(Qd)return $o;Qd=1;var e=ba();function t(r){return e(this,r).get(r)}return $o=t,$o}var No,eh;function N1(){if(eh)return No;eh=1;var e=ba();function t(r){return e(this,r).has(r)}return No=t,No}var Ro,th;function R1(){if(th)return Ro;th=1;var e=ba();function t(r,n){var i=e(this,r),a=i.size;return i.set(r,n),this.size+=i.size==a?0:1,this}return Ro=t,Ro}var Do,rh;function ff(){if(rh)return Do;rh=1;var e=C1(),t=k1(),r=$1(),n=N1(),i=R1();function a(o){var s=-1,u=o==null?0:o.length;for(this.clear();++s<u;){var c=o[s];this.set(c[0],c[1])}}return a.prototype.clear=e,a.prototype.delete=t,a.prototype.get=r,a.prototype.has=n,a.prototype.set=i,Do=a,Do}var Bo,nh;function Wg(){if(nh)return Bo;nh=1;var e=ff(),t="Expected a function";function r(n,i){if(typeof n!="function"||i!=null&&typeof i!="function")throw new TypeError(t);var a=function(){var o=arguments,s=i?i.apply(this,o):o[0],u=a.cache;if(u.has(s))return u.get(s);var c=n.apply(this,o);return a.cache=u.set(s,c)||u,c};return a.cache=new(r.Cache||e),a}return r.Cache=e,Bo=r,Bo}var Lo,ih;function D1(){if(ih)return Lo;ih=1;var e=Wg(),t=500;function r(n){var i=e(n,function(o){return a.size===t&&a.clear(),o}),a=i.cache;return i}return Lo=r,Lo}var qo,ah;function B1(){if(ah)return qo;ah=1;var e=D1(),t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,r=/\\(\\)?/g,n=e(function(i){var a=[];return i.charCodeAt(0)===46&&a.push(""),i.replace(t,function(o,s,u,c){a.push(u?c.replace(r,"$1"):s||o)}),a});return qo=n,qo}var zo,oh;function df(){if(oh)return zo;oh=1;function e(t,r){for(var n=-1,i=t==null?0:t.length,a=Array(i);++n<i;)a[n]=r(t[n],n,t);return a}return zo=e,zo}var Fo,sh;function L1(){if(sh)return Fo;sh=1;var e=ei(),t=df(),r=Be(),n=Hr(),i=e?e.prototype:void 0,a=i?i.toString:void 0;function o(s){if(typeof s=="string")return s;if(r(s))return t(s,o)+"";if(n(s))return a?a.call(s):"";var u=s+"";return u=="0"&&1/s==-1/0?"-0":u}return Fo=o,Fo}var Wo,uh;function Ug(){if(uh)return Wo;uh=1;var e=L1();function t(r){return r==null?"":e(r)}return Wo=t,Wo}var Uo,ch;function Gg(){if(ch)return Uo;ch=1;var e=Be(),t=sf(),r=B1(),n=Ug();function i(a,o){return e(a)?a:t(a,o)?[a]:r(n(a))}return Uo=i,Uo}var Go,lh;function xa(){if(lh)return Go;lh=1;var e=Hr();function t(r){if(typeof r=="string"||e(r))return r;var n=r+"";return n=="0"&&1/r==-1/0?"-0":n}return Go=t,Go}var Ho,fh;function hf(){if(fh)return Ho;fh=1;var e=Gg(),t=xa();function r(n,i){i=e(i,n);for(var a=0,o=i.length;n!=null&&a<o;)n=n[t(i[a++])];return a&&a==o?n:void 0}return Ho=r,Ho}var Ko,dh;function Hg(){if(dh)return Ko;dh=1;var e=hf();function t(r,n,i){var a=r==null?void 0:e(r,n);return a===void 0?i:a}return Ko=t,Ko}var q1=Hg();const Je=le(q1);var Vo,hh;function z1(){if(hh)return Vo;hh=1;function e(t){return t==null}return Vo=e,Vo}var F1=z1();const Q=le(F1);var Xo,ph;function W1(){if(ph)return Xo;ph=1;var e=Tt(),t=Be(),r=Et(),n="[object String]";function i(a){return typeof a=="string"||!t(a)&&r(a)&&e(a)==n}return Xo=i,Xo}var U1=W1();const ar=le(U1);var G1=uf();const Y=le(G1);var H1=qt();const Kr=le(H1);var Yo={exports:{}},ie={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-is.production.min.js
|
|
4
4
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-
|
|
2
|
-
var Ai=Object.defineProperty;var Ti=(e,t,n)=>t in e?Ai(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var xt=(e,t,n)=>Ti(e,typeof t!="symbol"?t+"":t,n);import{aO as s,bd as f,bG as ur,aF as Ri,q as un,aU as Oi,Q as Ii,aT as dr,bg as Pi,p as pr,bf as hr,R as Ce,n as $t,bF as mr,_ as zi,L as Oe,bC as fr,bN as Li,u as De,ak as Ht,r as Mi,aE as gr,A as vr,i as Fi,t as Ie,b0 as Gn,bx as Bn,aQ as We,bH as Ui,bK as br,bz as ft,ai as Di,X as Zi,Y as qi,a7 as cs,w as us,b5 as Gi,J as dn,aR as Yt,bb as Xt,E as en,bc as yr,b2 as xr,b3 as tn,f as Bi,bB as Wi,I as Wn,K as Vt,as as Vi,bM as Vn,S as jn,M as ds,l as ps,D as hs,bh as Qi,G as Ki,U as Ji,F as jr,aP as wr,O as kr,bQ as Hi,af as Yi,aA as Xi,bj as ut,a_ as ea,aG as ta,T as nt,a$ as Nr,aY as Sr,P as na,br as sa,bs as ra,av as ia,m as Rn,o as ms,au as aa,a as oa,C as la,by as ca,bE as ua,s as da,b as pa,bk as ha}from"./index-DK8XzE3T.js";import{e as Qn,R as Ve,h as et,f as It,a as gt,p as Nt,C as Xe,i as ma,c as nn,q as fa,d as ga,U as sn,g as va,u as ba,P as ya,b as xa,A as ja}from"./ActivityFeed-BE4MTD8M.js";import{E as xe,t as At,S as pn}from"./ContextGraphPrimitives-Dh-w2D_i.js";import{t as wa}from"./truncate-BaiMkAOo.js";import{b as ka,u as Na,a as fs,t as dt}from"./useEntityOnChainReceipt-C8NHlPPN.js";import"./useProjectActivity-CVFCfbMj.js";function Sa(e){if(typeof e!="number"||!Number.isFinite(e)||e<=0)return null;const t=e/100;return`${t.toFixed(t%1===0?0:1)}%`}const Ca={eligible:{glyph:"◉",toneClass:"v10-pca-verdict-green"},fallthrough:{glyph:"⚠",toneClass:"v10-pca-verdict-amber"},"fallthrough-no-funds":{glyph:"⚠",toneClass:"v10-pca-verdict-danger"},unknown:{glyph:"◌",toneClass:"v10-pca-verdict-neutral"}};function $a({verdict:e,accountId:t,discountBps:n,accountUntracked:r=!1,reasons:i=[],ownerPublish:a=!1,variant:o="banner",children:l,className:c=""}){const d=Ca[e],g=e==="fallthrough"||e==="fallthrough-no-funds",h=g?"alert":"status",u=g?"assertive":"polite",p=t?`PCA #${t}`:"a PCA",v=r?" (not tracked by this node)":"",y=Sa(n),w=" unless this graph’s registration escrow already covers it",m=i.length>0?` Reason: ${i.join("; ")}.`:"";if(o==="chip"){const x=e==="eligible"?`Funded by ${p}${v}${y?` (${y} discount)`:""}`:e==="fallthrough"?"⚠ No PCA discount":e==="fallthrough-no-funds"?"⚠ Publish will fail":"PCA status unknown";return s.jsx("span",{className:["v10-pca-verdict-chip",d.toneClass,c].filter(Boolean).join(" "),"data-testid":"pca-eligibility-chip","data-verdict":e,children:s.jsx("span",{className:"v10-pca-verdict-chip-label",role:h,"aria-live":u,children:x})})}let b;return e==="eligible"?b=s.jsxs(s.Fragment,{children:["This publish will use ",p,v,y?` (${y} discount)`:"",".",a?`${w}.`:""]}):e==="fallthrough"?b=s.jsxs(s.Fragment,{children:["No PCA discount on this publish — it will attempt to pay the direct cost from the signing wallet’s TRAC",y?`, forfeiting ${p}’s ${y} discount`:"",a?w:"","; the publish fails if that TRAC is below the fee.",m]}):e==="fallthrough-no-funds"?b=s.jsxs(s.Fragment,{children:["This publish will FAIL — no signing wallet can cover it",y?`, forfeiting ${p}’s ${y} discount`:"",a?w:"",".",m]}):b=s.jsx(s.Fragment,{children:"Couldn’t confirm PCA eligibility — you may pay the direct cost."}),s.jsxs("div",{className:["v10-pca-verdict-banner",d.toneClass,c].filter(Boolean).join(" "),"data-testid":"pca-eligibility-verdict","data-verdict":e,role:h,"aria-live":u,children:[s.jsxs("p",{className:"v10-pca-verdict-message",children:[s.jsx("span",{className:"v10-pca-verdict-glyph","aria-hidden":"true",children:d.glyph}),b]}),l&&s.jsx("div",{className:"v10-pca-verdict-actions",children:l})]})}const Ea=".md, .docx, .pdf, .txt, .csv, .json, .ttl, .rdf, .owl, .py, .ts, .js, .tsx, .jsx, .java, .go, .rs, .c, .cpp, .html, .xml, .yaml, .yml";function gs(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function _a(e){var n;const t=((n=e.split(".").pop())==null?void 0:n.toLowerCase())??"";return["md","txt"].includes(t)?"📝":["pdf"].includes(t)?"📕":["docx","doc"].includes(t)?"📄":["csv","json","xml","yaml","yml"].includes(t)?"📊":["ttl","rdf","owl"].includes(t)?"🔗":["py","ts","js","tsx","jsx","java","go","rs","c","cpp"].includes(t)?"💻":["png","jpg","jpeg","webp"].includes(t)?"🖼️":"📄"}function Aa({open:e,onClose:t,contextGraphId:n,contextGraphName:r}){var L;const[i,a]=f.useState([]),[o,l]=f.useState(!0),[c,d]=f.useState(!0),[g,h]=f.useState("idle"),[u,p]=f.useState(0),[v,y]=f.useState([]),[w,m]=f.useState(null),[b,x]=f.useState(!1),k=f.useRef(null),N=f.useCallback(A=>{const M=Array.from(A);a(F=>{const B=new Set(F.map(X=>`${X.file.name}:${X.file.size}`)),J=M.filter(X=>!B.has(`${X.name}:${X.size}`));return[...F,...J.map(X=>({file:X,id:`${X.name}-${X.size}-${Date.now()}`}))]})},[]),j=A=>{a(M=>M.filter(F=>F.id!==A))},_=A=>{A.preventDefault(),A.stopPropagation(),x(!0)},z=A=>{A.preventDefault(),A.stopPropagation(),x(!1)},E=A=>{A.preventDefault(),A.stopPropagation(),x(!1),A.dataTransfer.files.length>0&&N(A.dataTransfer.files)},T=async()=>{if(i.length===0)return;h("uploading"),p(0),y([]),m(null);const A=[];for(let F=0;F<i.length;F++){p(F);const{file:B}=i[F],J=B.name.replace(/[^a-zA-Z0-9._-]/g,"_"),X=`${Date.now().toString(36)}-${F}-${J}`;try{const Y=await Ri(X,n,B),V=Y.extraction.tripleCount??Y.extraction.triplesWritten;A.push({fileName:B.name,status:Y.extraction.status==="completed"?"success":Y.extraction.status==="skipped"?"skipped":"error",triplesWritten:V,error:Y.extraction.error})}catch(Y){A.push({fileName:B.name,status:"error",error:(Y==null?void 0:Y.message)??"Upload failed"})}}y(A),p(i.length);const M=A.some(F=>F.status==="error");h(M?"error":"done")},C=()=>{g!=="uploading"&&(a([]),y([]),h("idle"),m(null),p(0),t())},{dialogRef:O,onBackdropClick:Z}=ur(e,C);if(!e)return null;const $=v.reduce((A,M)=>A+(M.triplesWritten??0),0),R=v.filter(A=>A.status==="success").length,G=v.filter(A=>A.status==="skipped").length,P=v.filter(A=>A.status==="error").length;return s.jsx("div",{className:"v10-modal-overlay",onClick:Z,role:"presentation",children:s.jsxs("div",{className:"v10-modal-box",style:{maxWidth:560},ref:O,role:"dialog","aria-modal":"true","aria-labelledby":"dkg-import-modal-title",children:[s.jsxs("div",{className:"v10-modal-header",style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:12},children:[s.jsxs("div",{style:{flex:1,minWidth:0},children:[s.jsx("div",{id:"dkg-import-modal-title",className:"v10-modal-title",children:"Import to Working Memory"}),s.jsx("div",{className:"v10-modal-subtitle",children:r?s.jsxs(s.Fragment,{children:["Upload files to ",s.jsx("strong",{children:r})," — your agent will extract structured knowledge."]}):s.jsx(s.Fragment,{children:"Upload files — your agent will extract structured knowledge and add it to working memory."})})]}),s.jsx("button",{type:"button",className:"v10-modal-close",onClick:C,disabled:g==="uploading","aria-label":"Close import dialog",title:"Close (Esc)",style:{flexShrink:0,cursor:g==="uploading"?"not-allowed":"pointer"},children:"×"})]}),s.jsxs("div",{className:"v10-modal-body",children:[w&&s.jsx("div",{className:"v10-modal-error",children:w}),g==="idle"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:`v10-import-dropzone ${b?"drag-over":""}`,onClick:()=>{var A;return(A=k.current)==null?void 0:A.click()},onDragOver:_,onDragLeave:z,onDrop:E,children:[s.jsx("div",{className:"v10-import-dropzone-label",children:"Drag files here, or click to browse"}),s.jsx("div",{className:"v10-import-dropzone-hint",style:{marginTop:4},children:"Your agent will extract structured knowledge and add it to working memory."}),s.jsxs("div",{className:"v10-import-dropzone-hint",style:{marginTop:8},children:["Supported: ",Ea]}),s.jsx("input",{ref:k,type:"file",multiple:!0,style:{display:"none"},onChange:A=>{A.target.files&&N(A.target.files),A.target.value=""}})]}),i.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"v10-import-file-list",children:i.map(A=>s.jsxs("div",{className:"v10-import-file-item",children:[s.jsx("span",{className:"v10-import-file-icon",children:_a(A.file.name)}),s.jsx("span",{className:"v10-import-file-name",children:A.file.name}),s.jsx("span",{className:"v10-import-file-size",children:gs(A.file.size)}),s.jsx("button",{className:"v10-import-file-remove",onClick:()=>j(A.id),title:"Remove",children:"×"})]},A.id))}),s.jsxs("div",{style:{fontSize:11,color:"var(--text-tertiary)",marginBottom:12},children:[i.length," file",i.length!==1?"s":""," selected · ",gs(i.reduce((A,M)=>A+M.file.size,0))," total"]})]}),s.jsx("div",{className:"v10-form-divider"}),s.jsxs("div",{className:"v10-form-label",style:{marginBottom:8},children:["Ingestion Options ",s.jsx("span",{style:{fontSize:10,fontWeight:400,color:"var(--text-tertiary)"},children:"(coming soon)"})]}),s.jsxs("label",{className:"v10-import-option",style:{opacity:.5,pointerEvents:"none"},children:[s.jsx("input",{type:"checkbox",checked:c,disabled:!0,readOnly:!0}),"Store original files as Knowledge Assets"]}),s.jsxs("label",{className:"v10-import-option",style:{opacity:.5,pointerEvents:"none"},children:[s.jsx("input",{type:"checkbox",checked:o,disabled:!0,readOnly:!0}),"Let agent extract structured knowledge from content"]})]}),g==="uploading"&&s.jsxs("div",{className:"v10-import-progress",children:[s.jsxs("div",{style:{fontSize:12,color:"var(--text-secondary)",fontWeight:500},children:["Importing files… (",u+1," of ",i.length,")"]}),s.jsx("div",{style:{fontSize:11,color:"var(--text-tertiary)",marginTop:4},children:((L=i[u])==null?void 0:L.file.name)??"…"}),s.jsx("div",{className:"v10-import-progress-bar",children:s.jsx("div",{className:"v10-import-progress-fill",style:{width:`${(u+.5)/i.length*100}%`}})}),s.jsxs("div",{className:"v10-import-progress-text",children:[u," of ",i.length," files processed"]})]}),(g==="done"||g==="error")&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:`v10-import-result ${P>0?"error":"success"}`,"data-testid":"import-result","data-import-status":P>0?"error":"success","data-import-triples":$,children:P===0?s.jsxs(s.Fragment,{children:[R>0&&s.jsxs(s.Fragment,{children:["Successfully imported ",R," file",R!==1?"s":"",".",$>0&&s.jsxs(s.Fragment,{children:[" Extracted ",s.jsx("strong",{children:$.toLocaleString()})," triples into working memory."]})]}),G>0&&s.jsxs(s.Fragment,{children:[R>0?" ":"","Stored ",G," file",G!==1?"s":""," as source — no structured knowledge was extracted yet (extraction for these file types is coming soon)."]})]}):s.jsxs(s.Fragment,{children:[R," file",R!==1?"s":""," imported",G>0&&s.jsxs(s.Fragment,{children:[", ",G," stored without extraction"]}),", ",P," failed.",$>0&&s.jsxs(s.Fragment,{children:[" ",$.toLocaleString()," triples extracted."]})]})}),v.length>0&&s.jsx("div",{className:"v10-import-file-list",style:{marginTop:12},children:v.map((A,M)=>s.jsxs("div",{className:"v10-import-file-item",children:[s.jsx("span",{className:"v10-import-file-icon",children:A.status==="success"?"✓":A.status==="skipped"?"–":"✗"}),s.jsx("span",{className:"v10-import-file-name",children:A.fileName}),s.jsx("span",{className:"v10-import-file-size",style:A.status==="error"?{color:"var(--text-danger)"}:void 0,children:A.status==="success"&&A.triplesWritten!=null?`${A.triplesWritten} triples`:A.status==="skipped"?"stored (no extraction)":A.error??"failed"})]},M))})]})]}),s.jsxs("div",{className:"v10-modal-footer",children:[g==="idle"&&s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"v10-modal-btn",onClick:C,children:"Cancel"}),s.jsxs("button",{className:"v10-modal-btn primary",onClick:T,disabled:i.length===0,children:["Start Import (",i.length," file",i.length!==1?"s":"",")"]})]}),g==="uploading"&&s.jsx("button",{className:"v10-modal-btn",disabled:!0,children:"Importing…"}),(g==="done"||g==="error")&&s.jsx("button",{className:"v10-modal-btn primary",onClick:C,children:"Done"})]})]})})}function Ta(e){return e.length<=12?e:`${e.slice(0,6)}…${e.slice(-4)}`}function Ra({open:e,onClose:t,contextGraphId:n,contextGraphName:r}){const[i,a]=f.useState(null),[o,l]=f.useState(null),[c,d]=f.useState([]),[g,h]=f.useState(null),[u,p]=f.useState([]),[v,y]=f.useState([]),[w,m]=f.useState(null),[b,x]=f.useState("allowlist");f.useEffect(()=>{e&&(fetch("/api/status",{headers:un()}).then(C=>C.json()).then(C=>{typeof(C==null?void 0:C.peerId)=="string"&&C.peerId.length>0&&l(C.peerId)}).catch(()=>{}),Oi(n).then(C=>d(C.allowedAgents)).catch(()=>d([])),Ii().then(C=>{const O=(C.agents??[]).filter(Z=>Z.connectionStatus!=="self");p(O)}).catch(()=>p([])),dr(n).then(C=>y(C.requests)).catch(()=>y([])))},[e,n]);const{dialogRef:k,onBackdropClick:N}=ur(e,t);if(!e)return null;const j=o?`${n}
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-CfVUpsfM.js","assets/index-MQh8C4aJ.js","assets/index-xKO-U_eV.css","assets/string-DtUow4KV.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var Ai=Object.defineProperty;var Ti=(e,t,n)=>t in e?Ai(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var xt=(e,t,n)=>Ti(e,typeof t!="symbol"?t+"":t,n);import{aO as s,bd as f,bG as ur,aF as Ri,q as un,aU as Oi,Q as Ii,aT as dr,bg as Pi,p as pr,bf as hr,R as Ce,n as $t,bF as mr,_ as zi,L as Oe,bC as fr,bN as Li,u as De,ak as Ht,r as Mi,aE as gr,A as vr,i as Fi,t as Ie,b0 as Gn,bx as Bn,aQ as We,bH as Ui,bK as br,bz as ft,ai as Di,X as Zi,Y as qi,a7 as cs,w as us,b5 as Gi,J as dn,aR as Yt,bb as Xt,E as en,bc as yr,b2 as xr,b3 as tn,f as Bi,bB as Wi,I as Wn,K as Vt,as as Vi,bM as Vn,S as jn,M as ds,l as ps,D as hs,bh as Qi,G as Ki,U as Ji,F as jr,aP as wr,O as kr,bQ as Hi,af as Yi,aA as Xi,bj as ut,a_ as ea,aG as ta,T as nt,a$ as Nr,aY as Sr,P as na,br as sa,bs as ra,av as ia,m as Rn,o as ms,au as aa,a as oa,C as la,by as ca,bE as ua,s as da,b as pa,bk as ha}from"./index-MQh8C4aJ.js";import{e as Qn,R as Ve,h as et,f as It,a as gt,p as Nt,C as Xe,i as ma,c as nn,q as fa,d as ga,U as sn,g as va,u as ba,P as ya,b as xa,A as ja}from"./ActivityFeed-Bfg6fmQQ.js";import{E as xe,t as At,S as pn}from"./ContextGraphPrimitives-BXormriD.js";import{t as wa}from"./truncate-BaiMkAOo.js";import{b as ka,u as Na,a as fs,t as dt}from"./useEntityOnChainReceipt-BvWQ6qdT.js";import"./useProjectActivity-Cxr4QGX1.js";function Sa(e){if(typeof e!="number"||!Number.isFinite(e)||e<=0)return null;const t=e/100;return`${t.toFixed(t%1===0?0:1)}%`}const Ca={eligible:{glyph:"◉",toneClass:"v10-pca-verdict-green"},fallthrough:{glyph:"⚠",toneClass:"v10-pca-verdict-amber"},"fallthrough-no-funds":{glyph:"⚠",toneClass:"v10-pca-verdict-danger"},unknown:{glyph:"◌",toneClass:"v10-pca-verdict-neutral"}};function $a({verdict:e,accountId:t,discountBps:n,accountUntracked:r=!1,reasons:i=[],ownerPublish:a=!1,variant:o="banner",children:l,className:c=""}){const d=Ca[e],g=e==="fallthrough"||e==="fallthrough-no-funds",h=g?"alert":"status",u=g?"assertive":"polite",p=t?`PCA #${t}`:"a PCA",v=r?" (not tracked by this node)":"",y=Sa(n),w=" unless this graph’s registration escrow already covers it",m=i.length>0?` Reason: ${i.join("; ")}.`:"";if(o==="chip"){const x=e==="eligible"?`Funded by ${p}${v}${y?` (${y} discount)`:""}`:e==="fallthrough"?"⚠ No PCA discount":e==="fallthrough-no-funds"?"⚠ Publish will fail":"PCA status unknown";return s.jsx("span",{className:["v10-pca-verdict-chip",d.toneClass,c].filter(Boolean).join(" "),"data-testid":"pca-eligibility-chip","data-verdict":e,children:s.jsx("span",{className:"v10-pca-verdict-chip-label",role:h,"aria-live":u,children:x})})}let b;return e==="eligible"?b=s.jsxs(s.Fragment,{children:["This publish will use ",p,v,y?` (${y} discount)`:"",".",a?`${w}.`:""]}):e==="fallthrough"?b=s.jsxs(s.Fragment,{children:["No PCA discount on this publish — it will attempt to pay the direct cost from the signing wallet’s TRAC",y?`, forfeiting ${p}’s ${y} discount`:"",a?w:"","; the publish fails if that TRAC is below the fee.",m]}):e==="fallthrough-no-funds"?b=s.jsxs(s.Fragment,{children:["This publish will FAIL — no signing wallet can cover it",y?`, forfeiting ${p}’s ${y} discount`:"",a?w:"",".",m]}):b=s.jsx(s.Fragment,{children:"Couldn’t confirm PCA eligibility — you may pay the direct cost."}),s.jsxs("div",{className:["v10-pca-verdict-banner",d.toneClass,c].filter(Boolean).join(" "),"data-testid":"pca-eligibility-verdict","data-verdict":e,role:h,"aria-live":u,children:[s.jsxs("p",{className:"v10-pca-verdict-message",children:[s.jsx("span",{className:"v10-pca-verdict-glyph","aria-hidden":"true",children:d.glyph}),b]}),l&&s.jsx("div",{className:"v10-pca-verdict-actions",children:l})]})}const Ea=".md, .docx, .pdf, .txt, .csv, .json, .ttl, .rdf, .owl, .py, .ts, .js, .tsx, .jsx, .java, .go, .rs, .c, .cpp, .html, .xml, .yaml, .yml";function gs(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function _a(e){var n;const t=((n=e.split(".").pop())==null?void 0:n.toLowerCase())??"";return["md","txt"].includes(t)?"📝":["pdf"].includes(t)?"📕":["docx","doc"].includes(t)?"📄":["csv","json","xml","yaml","yml"].includes(t)?"📊":["ttl","rdf","owl"].includes(t)?"🔗":["py","ts","js","tsx","jsx","java","go","rs","c","cpp"].includes(t)?"💻":["png","jpg","jpeg","webp"].includes(t)?"🖼️":"📄"}function Aa({open:e,onClose:t,contextGraphId:n,contextGraphName:r}){var L;const[i,a]=f.useState([]),[o,l]=f.useState(!0),[c,d]=f.useState(!0),[g,h]=f.useState("idle"),[u,p]=f.useState(0),[v,y]=f.useState([]),[w,m]=f.useState(null),[b,x]=f.useState(!1),k=f.useRef(null),N=f.useCallback(A=>{const M=Array.from(A);a(F=>{const B=new Set(F.map(X=>`${X.file.name}:${X.file.size}`)),J=M.filter(X=>!B.has(`${X.name}:${X.size}`));return[...F,...J.map(X=>({file:X,id:`${X.name}-${X.size}-${Date.now()}`}))]})},[]),j=A=>{a(M=>M.filter(F=>F.id!==A))},_=A=>{A.preventDefault(),A.stopPropagation(),x(!0)},z=A=>{A.preventDefault(),A.stopPropagation(),x(!1)},E=A=>{A.preventDefault(),A.stopPropagation(),x(!1),A.dataTransfer.files.length>0&&N(A.dataTransfer.files)},T=async()=>{if(i.length===0)return;h("uploading"),p(0),y([]),m(null);const A=[];for(let F=0;F<i.length;F++){p(F);const{file:B}=i[F],J=B.name.replace(/[^a-zA-Z0-9._-]/g,"_"),X=`${Date.now().toString(36)}-${F}-${J}`;try{const Y=await Ri(X,n,B),V=Y.extraction.tripleCount??Y.extraction.triplesWritten;A.push({fileName:B.name,status:Y.extraction.status==="completed"?"success":Y.extraction.status==="skipped"?"skipped":"error",triplesWritten:V,error:Y.extraction.error})}catch(Y){A.push({fileName:B.name,status:"error",error:(Y==null?void 0:Y.message)??"Upload failed"})}}y(A),p(i.length);const M=A.some(F=>F.status==="error");h(M?"error":"done")},C=()=>{g!=="uploading"&&(a([]),y([]),h("idle"),m(null),p(0),t())},{dialogRef:O,onBackdropClick:Z}=ur(e,C);if(!e)return null;const $=v.reduce((A,M)=>A+(M.triplesWritten??0),0),R=v.filter(A=>A.status==="success").length,G=v.filter(A=>A.status==="skipped").length,P=v.filter(A=>A.status==="error").length;return s.jsx("div",{className:"v10-modal-overlay",onClick:Z,role:"presentation",children:s.jsxs("div",{className:"v10-modal-box",style:{maxWidth:560},ref:O,role:"dialog","aria-modal":"true","aria-labelledby":"dkg-import-modal-title",children:[s.jsxs("div",{className:"v10-modal-header",style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:12},children:[s.jsxs("div",{style:{flex:1,minWidth:0},children:[s.jsx("div",{id:"dkg-import-modal-title",className:"v10-modal-title",children:"Import to Working Memory"}),s.jsx("div",{className:"v10-modal-subtitle",children:r?s.jsxs(s.Fragment,{children:["Upload files to ",s.jsx("strong",{children:r})," — your agent will extract structured knowledge."]}):s.jsx(s.Fragment,{children:"Upload files — your agent will extract structured knowledge and add it to working memory."})})]}),s.jsx("button",{type:"button",className:"v10-modal-close",onClick:C,disabled:g==="uploading","aria-label":"Close import dialog",title:"Close (Esc)",style:{flexShrink:0,cursor:g==="uploading"?"not-allowed":"pointer"},children:"×"})]}),s.jsxs("div",{className:"v10-modal-body",children:[w&&s.jsx("div",{className:"v10-modal-error",children:w}),g==="idle"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:`v10-import-dropzone ${b?"drag-over":""}`,onClick:()=>{var A;return(A=k.current)==null?void 0:A.click()},onDragOver:_,onDragLeave:z,onDrop:E,children:[s.jsx("div",{className:"v10-import-dropzone-label",children:"Drag files here, or click to browse"}),s.jsx("div",{className:"v10-import-dropzone-hint",style:{marginTop:4},children:"Your agent will extract structured knowledge and add it to working memory."}),s.jsxs("div",{className:"v10-import-dropzone-hint",style:{marginTop:8},children:["Supported: ",Ea]}),s.jsx("input",{ref:k,type:"file",multiple:!0,style:{display:"none"},onChange:A=>{A.target.files&&N(A.target.files),A.target.value=""}})]}),i.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"v10-import-file-list",children:i.map(A=>s.jsxs("div",{className:"v10-import-file-item",children:[s.jsx("span",{className:"v10-import-file-icon",children:_a(A.file.name)}),s.jsx("span",{className:"v10-import-file-name",children:A.file.name}),s.jsx("span",{className:"v10-import-file-size",children:gs(A.file.size)}),s.jsx("button",{className:"v10-import-file-remove",onClick:()=>j(A.id),title:"Remove",children:"×"})]},A.id))}),s.jsxs("div",{style:{fontSize:11,color:"var(--text-tertiary)",marginBottom:12},children:[i.length," file",i.length!==1?"s":""," selected · ",gs(i.reduce((A,M)=>A+M.file.size,0))," total"]})]}),s.jsx("div",{className:"v10-form-divider"}),s.jsxs("div",{className:"v10-form-label",style:{marginBottom:8},children:["Ingestion Options ",s.jsx("span",{style:{fontSize:10,fontWeight:400,color:"var(--text-tertiary)"},children:"(coming soon)"})]}),s.jsxs("label",{className:"v10-import-option",style:{opacity:.5,pointerEvents:"none"},children:[s.jsx("input",{type:"checkbox",checked:c,disabled:!0,readOnly:!0}),"Store original files as Knowledge Assets"]}),s.jsxs("label",{className:"v10-import-option",style:{opacity:.5,pointerEvents:"none"},children:[s.jsx("input",{type:"checkbox",checked:o,disabled:!0,readOnly:!0}),"Let agent extract structured knowledge from content"]})]}),g==="uploading"&&s.jsxs("div",{className:"v10-import-progress",children:[s.jsxs("div",{style:{fontSize:12,color:"var(--text-secondary)",fontWeight:500},children:["Importing files… (",u+1," of ",i.length,")"]}),s.jsx("div",{style:{fontSize:11,color:"var(--text-tertiary)",marginTop:4},children:((L=i[u])==null?void 0:L.file.name)??"…"}),s.jsx("div",{className:"v10-import-progress-bar",children:s.jsx("div",{className:"v10-import-progress-fill",style:{width:`${(u+.5)/i.length*100}%`}})}),s.jsxs("div",{className:"v10-import-progress-text",children:[u," of ",i.length," files processed"]})]}),(g==="done"||g==="error")&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:`v10-import-result ${P>0?"error":"success"}`,"data-testid":"import-result","data-import-status":P>0?"error":"success","data-import-triples":$,children:P===0?s.jsxs(s.Fragment,{children:[R>0&&s.jsxs(s.Fragment,{children:["Successfully imported ",R," file",R!==1?"s":"",".",$>0&&s.jsxs(s.Fragment,{children:[" Extracted ",s.jsx("strong",{children:$.toLocaleString()})," triples into working memory."]})]}),G>0&&s.jsxs(s.Fragment,{children:[R>0?" ":"","Stored ",G," file",G!==1?"s":""," as source — no structured knowledge was extracted yet (extraction for these file types is coming soon)."]})]}):s.jsxs(s.Fragment,{children:[R," file",R!==1?"s":""," imported",G>0&&s.jsxs(s.Fragment,{children:[", ",G," stored without extraction"]}),", ",P," failed.",$>0&&s.jsxs(s.Fragment,{children:[" ",$.toLocaleString()," triples extracted."]})]})}),v.length>0&&s.jsx("div",{className:"v10-import-file-list",style:{marginTop:12},children:v.map((A,M)=>s.jsxs("div",{className:"v10-import-file-item",children:[s.jsx("span",{className:"v10-import-file-icon",children:A.status==="success"?"✓":A.status==="skipped"?"–":"✗"}),s.jsx("span",{className:"v10-import-file-name",children:A.fileName}),s.jsx("span",{className:"v10-import-file-size",style:A.status==="error"?{color:"var(--text-danger)"}:void 0,children:A.status==="success"&&A.triplesWritten!=null?`${A.triplesWritten} triples`:A.status==="skipped"?"stored (no extraction)":A.error??"failed"})]},M))})]})]}),s.jsxs("div",{className:"v10-modal-footer",children:[g==="idle"&&s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"v10-modal-btn",onClick:C,children:"Cancel"}),s.jsxs("button",{className:"v10-modal-btn primary",onClick:T,disabled:i.length===0,children:["Start Import (",i.length," file",i.length!==1?"s":"",")"]})]}),g==="uploading"&&s.jsx("button",{className:"v10-modal-btn",disabled:!0,children:"Importing…"}),(g==="done"||g==="error")&&s.jsx("button",{className:"v10-modal-btn primary",onClick:C,children:"Done"})]})]})})}function Ta(e){return e.length<=12?e:`${e.slice(0,6)}…${e.slice(-4)}`}function Ra({open:e,onClose:t,contextGraphId:n,contextGraphName:r}){const[i,a]=f.useState(null),[o,l]=f.useState(null),[c,d]=f.useState([]),[g,h]=f.useState(null),[u,p]=f.useState([]),[v,y]=f.useState([]),[w,m]=f.useState(null),[b,x]=f.useState("allowlist");f.useEffect(()=>{e&&(fetch("/api/status",{headers:un()}).then(C=>C.json()).then(C=>{typeof(C==null?void 0:C.peerId)=="string"&&C.peerId.length>0&&l(C.peerId)}).catch(()=>{}),Oi(n).then(C=>d(C.allowedAgents)).catch(()=>d([])),Ii().then(C=>{const O=(C.agents??[]).filter(Z=>Z.connectionStatus!=="self");p(O)}).catch(()=>p([])),dr(n).then(C=>y(C.requests)).catch(()=>y([])))},[e,n]);const{dialogRef:k,onBackdropClick:N}=ur(e,t);if(!e)return null;const j=o?`${n}
|
|
3
3
|
${o}`:null,_=(C,O)=>{navigator.clipboard.writeText(C).then(()=>{a(O),setTimeout(()=>a(null),2e3)}).catch(()=>{})},z=async C=>{try{await Pi(n,C),d(O=>O.filter(Z=>Z!==C))}catch{}},E=async C=>{m(C);try{await pr(n,C),y(O=>O.filter(Z=>Z.agentAddress!==C)),d(O=>[...new Set([...O,C])])}catch(O){h((O==null?void 0:O.message)||"Failed to approve")}finally{m(null)}},T=async C=>{m(C);try{await hr(n,C),y(O=>O.filter(Z=>Z.agentAddress!==C))}catch(O){h((O==null?void 0:O.message)||"Failed to reject")}finally{m(null)}};return s.jsx("div",{className:"v10-modal-overlay",onClick:N,role:"presentation",children:s.jsxs("div",{className:"v10-modal-box",style:{maxWidth:560},ref:k,role:"dialog","aria-modal":"true","aria-labelledby":"dkg-share-modal-title",children:[s.jsxs("div",{className:"v10-modal-header",style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:12},children:[s.jsxs("div",{style:{flex:1,minWidth:0},children:[s.jsx("div",{id:"dkg-share-modal-title",className:"v10-modal-title",children:"Share Context Graph"}),s.jsxs("div",{className:"v10-modal-subtitle",children:["Invite agents to collaborate on ",s.jsx("strong",{children:r}),"."]})]}),s.jsx("button",{type:"button",className:"v10-modal-close",onClick:t,"aria-label":"Close share dialog",title:"Close (Esc)",style:{flexShrink:0,cursor:"pointer"},children:"×"})]}),s.jsxs("div",{className:"v10-modal-body",children:[s.jsxs("div",{style:{display:"flex",gap:0,marginBottom:16,borderBottom:"1px solid var(--border-default)"},children:[s.jsx("button",{onClick:()=>x("allowlist"),style:{padding:"8px 16px",fontSize:12,fontWeight:b==="allowlist"?600:400,background:"none",border:"none",cursor:"pointer",color:b==="allowlist"?"var(--text-primary)":"var(--text-tertiary)",borderBottom:b==="allowlist"?"2px solid var(--accent-primary)":"2px solid transparent"},children:"Allowlist"}),s.jsxs("button",{onClick:()=>x("requests"),style:{padding:"8px 16px",fontSize:12,fontWeight:b==="requests"?600:400,background:"none",border:"none",cursor:"pointer",color:b==="requests"?"var(--text-primary)":"var(--text-tertiary)",borderBottom:b==="requests"?"2px solid var(--accent-primary)":"2px solid transparent",position:"relative"},children:["Join Requests",v.length>0&&s.jsx("span",{style:{position:"absolute",top:4,right:4,background:"var(--accent-red, #ef4444)",color:"var(--text-on-accent)",borderRadius:999,fontSize:9,fontWeight:700,padding:"1px 5px",minWidth:16,textAlign:"center"},children:v.length})]})]}),b==="allowlist"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"v10-form-group",children:[s.jsx("label",{className:"v10-form-label",children:"Allowed Agents"}),s.jsxs("div",{style:{fontSize:10,color:"var(--text-tertiary)",marginBottom:8},children:["Only agents on this list can read and write to the context graph. To add someone, share the Invite Code below — they'll send a signed join request you can approve in the ",s.jsx("strong",{children:"Join Requests"})," tab."]}),c.length>0&&s.jsx("div",{style:{marginBottom:8,display:"flex",flexDirection:"column",gap:4},children:c.map(C=>{const O=u.find(Z=>{var $;return(($=Z.agentAddress)==null?void 0:$.toLowerCase())===C.toLowerCase()});return s.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"6px 10px",borderRadius:6,fontSize:11,fontFamily:"var(--font-mono)",background:"var(--bg-surface)",border:"1px solid var(--border-default)"},children:[s.jsx("span",{style:{color:"var(--text-primary)"},children:O?s.jsxs(s.Fragment,{children:[s.jsx("span",{style:{fontFamily:"var(--font-body)",fontWeight:500},children:O.name})," ",s.jsx("span",{style:{color:"var(--text-tertiary)",fontSize:10},children:Ta(C)})]}):C}),s.jsx("button",{onClick:()=>z(C),style:{background:"none",border:"none",cursor:"pointer",color:"var(--text-tertiary)",fontSize:12,padding:"0 4px"},title:"Remove agent",children:"×"})]},C)})}),c.length===0&&s.jsx("div",{style:{padding:"8px 12px",borderRadius:6,fontSize:11,color:"var(--text-tertiary)",background:"var(--bg-surface)",border:"1px dashed var(--border-default)",marginBottom:8},children:"No agents on allowlist — context graph is open to anyone who subscribes."})]}),s.jsx("div",{className:"v10-form-divider"}),s.jsxs("div",{className:"v10-form-group",children:[s.jsx("label",{className:"v10-form-label",children:"Invite Code"}),j===null?s.jsx("div",{style:{padding:"8px 12px",borderRadius:6,fontSize:11,color:"var(--text-tertiary)",background:"var(--bg-surface)",border:"1px dashed var(--border-default)"},children:"Loading peer ID…"}):s.jsxs("div",{style:{position:"relative"},children:[s.jsx("pre",{style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)",borderRadius:6,padding:"10px 12px",fontSize:11,lineHeight:1.6,fontFamily:"var(--font-mono)",color:"var(--text-primary)",overflow:"auto",margin:0,whiteSpace:"pre-wrap",wordBreak:"break-all"},children:j}),s.jsx("button",{className:"v10-modal-btn primary",onClick:()=>_(j,"invite"),style:{position:"absolute",top:6,right:6,fontSize:10,padding:"4px 10px",height:26,cursor:"pointer"},children:i==="invite"?"Copied":"Copy Invite"})]})]})]}),b==="requests"&&s.jsxs("div",{className:"v10-form-group",children:[s.jsx("label",{className:"v10-form-label",children:"Pending Join Requests"}),s.jsx("div",{style:{fontSize:10,color:"var(--text-tertiary)",marginBottom:8},children:"Agents who submitted a signed request to join this context graph. Approve to add them to the allowlist."}),v.length===0&&s.jsx("div",{style:{padding:"16px 12px",borderRadius:6,fontSize:11,textAlign:"center",color:"var(--text-tertiary)",background:"var(--bg-surface)",border:"1px dashed var(--border-default)"},children:"No pending join requests."}),v.map(C=>s.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 10px",borderRadius:6,fontSize:11,background:"var(--bg-surface)",border:"1px solid var(--border-default)",marginBottom:4},children:[s.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:2},children:[C.name&&s.jsx("span",{style:{color:"var(--text-primary)",fontWeight:500},children:C.name}),s.jsx("span",{style:{color:"var(--text-tertiary)",fontFamily:"var(--font-mono)",fontSize:10},children:C.agentAddress}),s.jsxs("span",{style:{fontSize:9,color:"var(--text-tertiary)"},children:["Requested ",new Date(C.timestamp).toLocaleString()]})]}),s.jsxs("div",{style:{display:"flex",gap:6},children:[s.jsx("button",{onClick:()=>E(C.agentAddress),disabled:w===C.agentAddress,style:{background:"rgba(34, 197, 94, 0.15)",color:"var(--text-success)",border:"1px solid rgba(34, 197, 94, 0.3)",cursor:"pointer",borderRadius:4,fontSize:10,padding:"4px 10px",fontWeight:600},children:w===C.agentAddress?"…":"Approve"}),s.jsx("button",{onClick:()=>T(C.agentAddress),disabled:w===C.agentAddress,style:{background:"rgba(239, 68, 68, 0.1)",color:"var(--text-danger)",border:"1px solid rgba(239, 68, 68, 0.2)",cursor:"pointer",borderRadius:4,fontSize:10,padding:"4px 10px",fontWeight:600},children:"Reject"})]})]},C.agentAddress)),g&&s.jsx("div",{style:{fontSize:10,color:"var(--text-danger)",marginTop:4},children:g})]})]}),s.jsx("div",{className:"v10-modal-footer",children:s.jsx("button",{className:"v10-modal-btn",onClick:t,children:"Done"})})]})})}const St=["#6366f1","#14b8a6","#f43f5e","#facc15","#8b5cf6","#10b981","#0ea5e9","#d946ef"],vs=1e4;function jt(e){if(e!=null)return typeof e=="string"?e.startsWith('"')?e.replace(/^"/,"").replace(/"(\^\^<[^>]*>)?$/,""):e:typeof e=="object"&&e!==null&&"value"in e?String(e.value):String(e)}function Oa(e){if(e.startsWith("did:dkg:agent:")){const t=e.slice(14);return t.startsWith("0x")?t.slice(0,6)+"…"+t.slice(-4):t.slice(0,6)+"…"+t.slice(-6)}return e.length>18?e.slice(0,8)+"…"+e.slice(-6):e}function Ia(e){return e.startsWith("did:")||e.startsWith("12D3")?e:/^0x[0-9a-fA-F]{40}$/.test(e)?`did:dkg:agent:${e}`:e}function Pa(e,t){const n=`did:dkg:context-graph:${t}/`;if(!e.startsWith(n))return;const r=e.slice(n.length),i=r.indexOf("/");if(i<0)return;const a=r.slice(0,i);if(!(!a||a.startsWith("_")))return a}function za(e){return`PREFIX dkg: <http://dkg.io/ontology/>
|
|
4
4
|
PREFIX prov: <http://www.w3.org/ns/prov#>
|
|
5
5
|
SELECT ?op ?root ?agent ?publishedAt ?g WHERE {
|
|
@@ -33,7 +33,7 @@ SELECT ?event ?type ?assertion ?name ?agent ?ts ?subGraphName ?assertionGraph (C
|
|
|
33
33
|
OPTIONAL { ?assertion dkg:rootEntity ?subjRoot }
|
|
34
34
|
}
|
|
35
35
|
} GROUP BY ?event ?type ?assertion ?name ?agent ?ts ?subGraphName ?assertionGraph
|
|
36
|
-
ORDER BY DESC(?ts) LIMIT 5000`}function Ge(e){if(e!=null)return typeof e=="string"?e.startsWith('"')?e.replace(/^"/,"").replace(/"(\^\^<[^>]*>)?$/,""):e:typeof e=="object"&&e!==null&&"value"in e?String(e.value):String(e)}function Da(e){return e===`${On}AssertionCreated`?"created":e===`${On}AssertionPromoted`?"promoted":null}function Za(e){const[t,n]=f.useState([]),[r,i]=f.useState(!!e),[a,o]=f.useState(null),[l,c]=f.useState(void 0),d=f.useRef(void 0),g=f.useRef(void 0);return f.useEffect(()=>{if(!e){i(!1);return}d.current!=null&&d.current!==e&&(n([]),o(null),c(void 0),g.current=void 0);let h=!1;const u=new AbortController;let p;return d.current=e,i(!0),o(null),(async()=>{var v;try{const y=new Promise((k,N)=>{p=setTimeout(()=>{u.abort(),N(new Error(`Assertion-lifecycle query timed out after ${Math.round(bs/1e3)}s`))},bs)}),w=(async()=>{const k=await fetch("/api/query",{method:"POST",headers:{"Content-Type":"application/json",...un()},signal:u.signal,body:JSON.stringify({sparql:Ua(e),contextGraphId:e})});if(!k.ok)throw new Error(`SPARQL query failed: ${k.status}`);return k.json()})(),m=await Promise.race([w,y]);if(h||d.current!==e)return;const b=((v=m==null?void 0:m.result)==null?void 0:v.bindings)??[],x=[];for(const k of b){const N=Ge(k.event),j=Ge(k.type),_=Ge(k.assertion),z=Ge(k.name),E=Ge(k.agent),T=Ge(k.ts);if(!N||!_||!E||!T)continue;const C=Da(j);if(!C)continue;let O;if(C==="promoted"){const R=Ge(k.entityCount),G=R!=null?Number(R):NaN;if(Number.isFinite(G)&&G>0)O=G;else{const P=Ge(k.subjectEntityCount),L=P!=null?Number(P):NaN;Number.isFinite(L)&&L>=0&&(O=L)}}let $=Ge(k.subGraphName);if($===void 0){const R=Ge(k.assertionGraph);R&&($=Fa(R,e))}x.push({eventUri:N,kind:C,assertionUri:_,assertionName:z??"",agentUri:E,publishedAt:T,subGraph:$,entityCount:O})}n(x),c(e),g.current=e,o(null)}catch(y){if(h||(y==null?void 0:y.name)==="AbortError")return;o(y.message??String(y)),g.current!==e&&n([]),c(e),g.current=e}finally{p&&clearTimeout(p),h||i(!1)}})(),()=>{h=!0,u.abort(),p&&clearTimeout(p)}},[e]),f.useMemo(()=>({resultContextGraphId:l,events:t,loading:r,error:a}),[l,t,r,a])}const qa={wm:"working",swm:"shared",vm:"verified"};function Ga(e){var u,p,v,y;const t=new Map;if(!e)return t;const n="http://dkg.io/ontology/decisions/status",r="http://dkg.io/ontology/tasks/status",i="http://dkg.io/ontology/tasks/priority",a="http://dkg.io/ontology/github/state",o="http://dkg.io/ontology/decisions/Decision",l="http://dkg.io/ontology/tasks/Task",c="http://dkg.io/ontology/github/PullRequest";let d=0,g=0,h=0;for(const w of e)if(w.types.includes(o))((u=w.properties.get(n))==null?void 0:u[0])==="proposed"&&d++;else if(w.types.includes(l)){const m=(p=w.properties.get(i))==null?void 0:p[0],b=(v=w.properties.get(r))==null?void 0:v[0];m==="p0"&&b!=="done"&&b!=="cancelled"&&g++}else w.types.includes(c)&&((y=w.properties.get(a))==null?void 0:y[0])==="open"&&h++;return d>0&&t.set("decisions",{label:`${d} proposed`,tone:"warn"}),g>0&&t.set("tasks",{label:`${g} p0`,tone:"danger"}),h>0&&t.set("github",{label:`${h} open`,tone:"info"}),t}const wn=({contextGraphId:e,profile:t,selected:n,onSelect:r,entities:i,layer:a,enabledScope:o,allTriplesTotal:l})=>{const[c,d]=Ce.useState([]),[g,h]=Ce.useState(!0),u=Ce.useMemo(()=>Ga(i),[i]),p=Ce.useRef(0),v=Ce.useMemo(()=>o&&o.size>0&&o.size<3?new Set(o):o&&o.size>=3?null:a?new Set([qa[a]]):null,[o,a]),y=Ce.useMemo(()=>{if(!i)return null;const $=new Map;for(const R of i)if(!(v&&!v.has(R.trustLevel)))for(const G of R.subGraphs)$.set(G,($.get(G)??0)+1);return $},[v,i]),w=Ce.useMemo(()=>{if(!i)return null;let $=0;for(const R of i)v&&!v.has(R.trustLevel)||$++;return $},[v,i]),m=Ce.useMemo(()=>{if(!i)return null;let $=0;for(const R of i)v&&!v.has(R.trustLevel)||R.subGraphs.size>0||$++;return $},[v,i]),b=Ce.useCallback(()=>{const $=++p.current;h(!0),$t.fetchSubGraphs(e).then(R=>{$===p.current&&d(R.subGraphs??[])}).catch(()=>{}).finally(()=>{$===p.current&&h(!1)})},[e]);Ce.useEffect(()=>(b(),()=>{p.current++}),[b]),mr(e,b);const x=Ce.useMemo(()=>c.filter(Qn).map($=>{const R=t.forSubGraph($.name),G=y!==null?y.get($.name)??0:$.entityCount;return{slug:$.name,icon:R.icon??"•",color:R.color??"#64748b",displayName:R.displayName??$.name,description:R.description??$.description,rank:R.rank??99,entityCount:G,tripleCount:$.tripleCount,layerScoped:y!==null}}).sort(($,R)=>$.rank-R.rank),[c,t,y]),N=m!==null&&m>0||n===Ve;if(g&&x.length===0&&!N||x.length===0&&!N)return null;const j=w??x.reduce(($,R)=>$+R.entityCount,0),_=x.reduce(($,R)=>$+R.tripleCount,0),z={working:"Working Memory",shared:"Shared Working Memory",verified:"Verifiable Memory"},E=v?[...v].map($=>z[$]).join(" + "):null,T=E?` in ${E}`:"",O=`Total distinct entities — includes those in named subgraphs (some may belong to more than one), plus Root entities not in any subgraph · ${j} entities${T}${E?"":` · ${l??_} triples`}`,Z=`All — total distinct entities. Includes those in named subgraphs (some may belong to more than one), plus Root entities not in any subgraph. ${j} entities${T}.`;return s.jsxs("div",{className:"v10-subgraph-bar",children:[s.jsx("div",{className:"v10-subgraph-bar-label",children:"Subgraphs"}),s.jsxs("button",{type:"button",className:`v10-subgraph-chip${n===null?" active":""}`,onClick:()=>r(null),title:O,"aria-label":Z,children:[s.jsx("span",{className:"v10-subgraph-chip-icon",children:"⊚"}),s.jsx("span",{className:"v10-subgraph-chip-label",children:"All"}),s.jsx("span",{className:"v10-subgraph-chip-count",children:j})]}),x.map($=>{const R=u.get($.slug);return s.jsxs("button",{type:"button",className:`v10-subgraph-chip${n===$.slug?" active":""}${R?" has-badge":""}`,onClick:()=>r($.slug,a),title:`${$.displayName}${$.description?" · "+$.description:""} · ${$.entityCount} entities${T}${E?"":` · ${$.tripleCount} triples`}${R?" · "+R.label:""}`,style:{"--sg-color":$.color},children:[s.jsx("span",{className:"v10-subgraph-chip-icon",style:{color:$.color},children:$.icon}),s.jsx("span",{className:"v10-subgraph-chip-label",children:$.displayName}),s.jsx("span",{className:"v10-subgraph-chip-count",children:$.entityCount}),R&&s.jsxs("span",{className:`v10-subgraph-chip-badge tone-${R.tone}`,children:[s.jsx("span",{className:"v10-subgraph-chip-badge-dot"}),R.label]})]},$.slug)}),N&&(()=>{const $=m??0,R=n===Ve;return s.jsxs("button",{type:"button",className:`v10-subgraph-chip v10-subgraph-chip-root${R?" active":""}`,"data-active":R,"data-count":$,onClick:()=>r(Ve,a),title:`Entities not in any subgraph (Context Graph root) · ${$} entities${T}`,"aria-label":"Entities not in any subgraph (Context Graph root)",children:[s.jsx("span",{className:"v10-subgraph-chip-icon",children:"⊘"}),s.jsx("span",{className:"v10-subgraph-chip-label",children:"Root"}),s.jsx("span",{className:"v10-subgraph-chip-count",children:$})]})})()]})},Kn=f.lazy(()=>zi(()=>import("./index-DOGXDQkQ.js").then(e=>e.h),__vite__mapDeps([0,1,2,3])).then(e=>({default:e.RdfGraph}))),Ba="http://www.w3.org/1999/02/22-rdf-syntax-ns#type",Wa=new Map(Fi.map((e,t)=>[e,t]));function In(e){const t=e.trim();return!t||t.startsWith('"')?!1:t.startsWith("_:")||t.startsWith("<")&&t.endsWith(">")?!0:/\s/.test(t)?!1:/^[A-Za-z][A-Za-z0-9+.-]*:/.test(t)}function Qe(e){const t=e.trim();return t.startsWith("<")&&t.endsWith(">")?t.slice(1,-1):t}function Va(e){const t=new Set,n=new Map,r=new Map,i=new Map;for(const l of e){const c=Qe(l.subject);t.add(c);const d=Wa.get(l.predicate);if(d!==void 0){const h=vr(l.object).trim();if(h){const u=i.get(c);(u===void 0||d<u)&&(r.set(c,h),i.set(c,d))}}if(Qe(l.predicate)===Ba||!In(l.object))continue;const g=Qe(l.object);n.set(c,(n.get(c)??0)+1),n.set(g,(n.get(g)??0)+1)}const a=[...t].filter(l=>(n.get(l)??0)===0).map(l=>({uri:l,label:r.get(l)??gr(void 0,l)})).sort((l,c)=>l.label.localeCompare(c.label));if(a.length===0)return{canvasTriples:e,singletonItems:a};const o=new Set(a.map(l=>l.uri));return{canvasTriples:e.filter(l=>!o.has(Qe(l.subject))&&!o.has(Qe(l.object))),singletonItems:a}}function Qa(e){return e==="wm"?"Working Memory graph: local entities connected by entity-to-entity triples from loaded layer data.":e==="swm"?"Shared Working Memory graph: promoted shared entities connected by entity-to-entity triples from loaded layer data.":"Verifiable Memory graph: published knowledge assets, provenance anchors, and connected entity-to-entity triples from loaded layer data."}function Ka({items:e,onSelect:t}){return e.length===0?null:s.jsxs("div",{className:"v10-graph-singleton-shelf","aria-label":"Standalone entities without visible links",children:[s.jsxs("div",{className:"v10-graph-singleton-head",title:"Entities with no visible links are grouped here to keep the graph readable.",children:[s.jsx("span",{children:"Standalone entities"}),s.jsx("span",{children:e.length})]}),s.jsx("div",{className:"v10-graph-singleton-list",children:e.map(({uri:n,label:r})=>s.jsx("button",{type:"button",className:"v10-graph-singleton-item",title:n,onClick:()=>t==null?void 0:t(n),children:r},n))})]})}const Ja=2500;function ys(e,t=Ja){if(e.length<=t)return e;const n=new Map;for(const o of e)n.set(o.subject,(n.get(o.subject)??0)+1);const r=[...n.entries()].sort((o,l)=>l[1]-o[1]).map(([o])=>o),i=new Set;let a=0;for(const o of r){const l=n.get(o)??0;a+l>t||(i.add(o),a+=l)}return i.size===0&&r.length>0&&i.add(r[0]),e.filter(o=>i.has(o.subject)).slice(0,t)}function Qt({title:e,scopeLabel:t,tone:n,className:r,rail:i,overlay:a,showScopeLabel:o=!0,singletonItems:l=[],onSingletonClick:c,renderGraph:d}){const[g,h]=f.useState(!1);f.useEffect(()=>{if(!g)return;const v=y=>{y.key==="Escape"&&h(!1)};return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[g]);const u=s.jsx("button",{type:"button",className:`v10-graph-expand-btn${o?"":" in-canvas"}`,onClick:()=>h(!0),title:`Expand ${e}`,"aria-label":`Expand ${e}`,children:"⤢"}),p=v=>s.jsxs(s.Fragment,{children:[o&&!v&&s.jsxs("div",{className:"v10-graph-shell-bar",children:[s.jsx("div",{className:"v10-graph-scope",title:t,children:t}),u]}),s.jsxs("div",{className:"v10-graph-body",children:[s.jsxs("div",{className:"v10-graph-canvas",children:[!o&&!v&&u,s.jsx("div",{className:"v10-graph-view",children:d(v)}),a&&s.jsx("div",{className:"v10-graph-overlay",children:a}),s.jsx(Ka,{items:l,onSelect:c})]}),i&&s.jsx("aside",{className:"v10-graph-rail",children:i})]})]});return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:`v10-graph-shell v10-graph-shell-${n}${r?` ${r}`:""}`,children:!g&&p(!1)}),g&&s.jsx("div",{className:"v10-graph-expanded-backdrop",role:"dialog","aria-modal":"true","aria-label":`${e} expanded`,onClick:v=>{v.target===v.currentTarget&&h(!1)},children:s.jsxs("div",{className:`v10-graph-expanded-panel v10-graph-shell-${n}`,children:[s.jsxs("div",{className:"v10-graph-expanded-head",children:[s.jsxs("div",{children:[s.jsx("div",{className:"v10-graph-expanded-title",children:e}),s.jsx("div",{className:"v10-graph-expanded-subtitle",children:t})]}),s.jsx("button",{type:"button",className:"v10-graph-expanded-close",onClick:()=>h(!1),"aria-label":`Close expanded ${e}`,children:"×"})]}),s.jsx("div",{className:"v10-graph-expanded-body",children:p(!0)})]})})]})}function $r({layer:e,triples:t,onNodeClick:n,contextGraphId:r,scopeLabel:i,trustLegendActiveLayer:a,title:o,scopeEntities:l,swmAttribution:c,layerEntities:d,nodeColorsOverride:g}){const{title:h}=Oe[e],u=o??h,p=fr(M=>M.theme),v=f.useMemo(()=>{if(e!=="vm")return;const M=new Set;for(const F of t)M.add(F.subject),In(F.object)&&M.add(F.object);return M},[t,e]),{anchors:y,decorationTriples:w}=Li(e==="vm"&&r?r:void 0,v),m=Cr(e==="swm"&&r&&!c?r:void 0),b=c??m,x=f.useMemo(()=>{if(!d||d.length===0)return t;const M=new Set;for(const F of d)M.add(De(F.uri));return Ht(t,M)},[t,d]),k=f.useMemo(()=>{const M=new Set,F=[],B=J=>{const X=`${J.subject}|${J.predicate}|${J.object}`;M.has(X)||(M.add(X),F.push({subject:J.subject,predicate:J.predicate,object:J.object}))};for(const J of x)B(J);for(const J of w)B(J);return F},[x,w]),N=k,j=f.useMemo(()=>{const M=e==="swm"?b.nodeColors:void 0;if(!(!M&&!g))return M?g?{...M,...g}:M:g},[e,b.nodeColors,g]),_=f.useMemo(()=>Mi(e,j),[e,j]),{canvasTriples:z,singletonItems:E}=f.useMemo(()=>Va(N),[N]),T=f.useMemo(()=>{if(!l||l.length===0)return E;const M=new Set(E.map(B=>Qe(B.uri)));for(const B of z)M.add(Qe(B.subject)),In(B.object)&&M.add(Qe(B.object));const F=[];for(const B of l){const J=Qe(B.uri);M.has(J)||(M.add(J),F.push({uri:J,label:B.label||gr(void 0,J)}))}return F.length===0?E:[...E,...F].sort((B,J)=>B.label.localeCompare(J.label))},[E,z,l]),C=`${r??"context"}:${e}`,O=e==="swm"&&!!r&&b.loading,Z=`${u} graph`,$=i??Qa(e),R=a===null&&!!i,G=a===null?void 0:a??e,L=e==="vm"&&y.length>0||e==="swm"&&b.palette.length>0?s.jsxs(s.Fragment,{children:[e==="vm"&&y.length>0&&s.jsx(Ya,{anchors:y}),e==="swm"&&b.palette.length>0&&s.jsx(Ha,{palette:b.palette,conflicts:b.conflicts.length})]}):null,A=f.useMemo(()=>({name:`${C}:${p}`,palette:p}),[C,p]);return k.length===0&&T.length===0?s.jsx(Qt,{title:Z,scopeLabel:$,tone:e,className:"v10-graph-view-fill",showScopeLabel:R,renderGraph:()=>s.jsx("div",{className:"v10-layer-empty-shell",children:s.jsx(xe,{compact:!0,tone:At(e),icon:Oe[e].icon,title:`No triples in ${u}`,description:"The graph will appear when this layer has connected triples."})})}):O?s.jsx(Qt,{title:Z,scopeLabel:$,tone:"swm",className:"v10-graph-view-fill",showScopeLabel:R,renderGraph:()=>s.jsx("div",{className:"v10-layer-empty-shell",children:s.jsx(xe,{compact:!0,tone:"swm",icon:Oe.swm.icon,title:"Loading Shared Working Memory attribution...",description:"Agent colors are being prepared before the graph renders."})})}):s.jsx(Qt,{title:Z,scopeLabel:$,tone:e,className:"v10-graph-view-fill",overlay:L,showScopeLabel:R,singletonItems:T,onSingletonClick:M=>n==null?void 0:n(G?{id:M,trustLayer:G}:{id:M}),renderGraph:M=>z.length>0?s.jsx(f.Suspense,{fallback:s.jsx("span",{className:"v10-graph-placeholder",children:"Loading graph..."}),children:s.jsx(Kn,{data:z,format:"triples",options:_,viewConfig:A,style:{position:"absolute",inset:0,width:"100%",height:"100%"},onNodeClick:G?F=>n==null?void 0:n({...F,trustLayer:G}):n,initialFit:!0},`${C}:${M?"expanded":"inline"}:${z.length}`)}):s.jsx("div",{className:"v10-graph-placeholder v10-graph-placeholder-centered",children:"Connected graph appears when this layer has linked entities."})})}function Ha({palette:e,conflicts:t}){return s.jsxs("div",{className:"v10-swm-legend","aria-label":"SWM attribution legend",children:[s.jsxs("div",{className:"v10-swm-legend-row v10-swm-legend-head",children:[s.jsx("span",{children:"SWM attribution"}),s.jsxs("span",{className:"v10-swm-legend-count",children:[e.length," agent",e.length===1?"":"s"]})]}),e.slice(0,8).map(n=>s.jsxs("div",{className:"v10-swm-legend-row",title:n.agent,children:[s.jsx("span",{className:"v10-swm-legend-swatch",style:{background:n.color}}),s.jsx("span",{className:"v10-swm-legend-label",children:n.label}),s.jsx("span",{className:"v10-swm-legend-metric",children:n.entityCount})]},n.agent)),t>0&&s.jsxs("div",{className:"v10-swm-legend-row v10-swm-legend-conflict",children:[s.jsx("span",{className:"v10-swm-legend-swatch",style:{background:"#f59e0b"},children:"!"}),s.jsx("span",{className:"v10-swm-legend-label",children:"In review"}),s.jsx("span",{className:"v10-swm-legend-metric",children:t})]})]})}function Ya({anchors:e}){var i;const t=f.useMemo(()=>{const a=new Set;for(const o of e)for(const l of o.agents)a.add(l);return a.size},[e]),n=(i=e[0])==null?void 0:i.publishedAt,r=(()=>{if(!n)return null;try{return new Date(n).toLocaleString(void 0,{month:"short",day:"2-digit",hour:"2-digit",minute:"2-digit"})}catch{return null}})();return s.jsxs("div",{className:"v10-vm-legend","aria-label":"Verifiable Memory legend",children:[s.jsxs("div",{className:"v10-vm-legend-row v10-vm-legend-head",children:[s.jsx("span",{children:"VM provenance layer"}),s.jsxs("span",{className:"v10-vm-legend-count",children:[e.length," anchor",e.length===1?"":"s"]})]}),s.jsxs("div",{className:"v10-vm-legend-row",children:[s.jsx("span",{className:"v10-vm-legend-swatch",style:{background:"#f5a524"},children:"◉"}),s.jsx("span",{className:"v10-vm-legend-label",children:"On-chain anchor"})]}),s.jsxs("div",{className:"v10-vm-legend-row",children:[s.jsx("span",{className:"v10-vm-legend-swatch",style:{background:"#c084fc"},children:"◈"}),s.jsxs("span",{className:"v10-vm-legend-label",children:["Agent identity (",t,")"]})]}),s.jsxs("div",{className:"v10-vm-legend-row",children:[s.jsx("span",{className:"v10-vm-legend-swatch",style:{background:"#4ade80"},children:"—"}),s.jsx("span",{className:"v10-vm-legend-label",children:"Signed / anchored edge"})]}),r&&s.jsxs("div",{className:"v10-vm-legend-foot",children:["Latest: ",r]})]})}function Xa({active:e,counts:t,onSwitch:n,onShare:r,onImport:i,onRefresh:a}){const[o,l]=f.useState(!1),c=f.useRef(null),d=g=>{l(!1),n(g)};return f.useEffect(()=>{if(!o)return;const g=h=>{var p;const u=h.target;u&&((p=c.current)!=null&&p.contains(u))||l(!1)};return document.addEventListener("pointerdown",g),()=>document.removeEventListener("pointerdown",g)},[o]),s.jsxs("div",{className:"v10-layer-switcher",children:[s.jsxs("button",{className:`v10-layer-switch-btn ${e==="overview"?"active":""}`,"data-layer":"overview","aria-label":"Overview",title:"Overview",onClick:()=>d("overview"),children:[s.jsx("span",{className:"v10-layer-switch-icon",children:"◎"}),s.jsx("span",{className:"v10-layer-switch-label",children:"Overview"})]}),s.jsx("span",{className:"v10-layer-switch-separator","aria-hidden":"true"}),s.jsxs("button",{className:`v10-layer-switch-btn ${e==="wm"?"active":""}`,"data-layer":"wm","aria-label":"Working Memory",title:"Working Memory",onClick:()=>d("wm"),children:[s.jsx("span",{className:"v10-layer-switch-icon",style:{color:"#64748b"},children:"◇"}),s.jsx("span",{className:"v10-layer-switch-label v10-layer-switch-label-full",children:"Working Memory"}),s.jsx("span",{className:"v10-layer-switch-label v10-layer-switch-label-compact",children:"WM"}),t.wm>0&&s.jsx("span",{className:"v10-layer-switch-count",children:t.wm})]}),s.jsxs("button",{className:`v10-layer-switch-btn ${e==="swm"?"active":""}`,"data-layer":"swm","aria-label":"Shared Working Memory",title:"Shared Working Memory",onClick:()=>d("swm"),children:[s.jsx("span",{className:"v10-layer-switch-icon",style:{color:"#f59e0b"},children:"◈"}),s.jsx("span",{className:"v10-layer-switch-label v10-layer-switch-label-full",children:"Shared Working Memory"}),s.jsx("span",{className:"v10-layer-switch-label v10-layer-switch-label-compact",children:"SWM"}),t.swm>0&&s.jsx("span",{className:"v10-layer-switch-count",children:t.swm})]}),s.jsxs("button",{className:`v10-layer-switch-btn ${e==="vm"?"active":""}`,"data-layer":"vm","aria-label":"Verifiable Memory",title:"Verifiable Memory",onClick:()=>d("vm"),children:[s.jsx("span",{className:"v10-layer-switch-icon",style:{color:"#22c55e"},children:"◉"}),s.jsx("span",{className:"v10-layer-switch-label v10-layer-switch-label-full",children:"Verifiable Memory"}),s.jsx("span",{className:"v10-layer-switch-label v10-layer-switch-label-compact",children:"VM"}),t.vm>0&&s.jsx("span",{className:"v10-layer-switch-count",children:t.vm})]}),s.jsx("span",{className:"v10-layer-switch-separator","aria-hidden":"true"}),s.jsxs("button",{className:`v10-layer-switch-btn ${e==="graph-overview"?"active":""}`,"data-layer":"graph-overview","aria-label":"Subgraphs",title:"Subgraphs",onClick:()=>d("graph-overview"),children:[s.jsx("span",{className:"v10-layer-switch-icon",children:"⌬"}),s.jsx("span",{className:"v10-layer-switch-label",children:"Subgraphs"})]}),s.jsxs("div",{ref:c,className:"v10-layer-more",onBlur:g=>{g.currentTarget.contains(g.relatedTarget)||l(!1)},children:[s.jsxs("button",{type:"button",className:`v10-layer-switch-btn v10-layer-more-btn ${e==="query"?"active":""}`,"data-layer":"query","aria-haspopup":"menu","aria-expanded":o,"aria-label":"More Context Graph views",title:"More Context Graph views",onClick:()=>l(g=>!g),children:[s.jsx("span",{className:"v10-layer-switch-icon",children:"⋯"}),s.jsx("span",{className:"v10-layer-switch-label",children:"More"})]}),o&&s.jsx("div",{className:"v10-layer-more-menu",role:"menu",children:s.jsxs("button",{type:"button",role:"menuitem",className:`v10-layer-more-item ${e==="query"?"active":""}`,onClick:()=>d("query"),children:[s.jsx("span",{className:"v10-layer-switch-icon",children:"⟐"}),"Query Catalogue"]})})]}),s.jsx("div",{className:"v10-layer-switcher-spacer"}),s.jsxs("div",{className:"v10-layer-switcher-actions",children:[s.jsxs("button",{className:"v10-layer-action-btn",onClick:r,"aria-label":"Share Context Graph",children:[s.jsx("span",{className:"v10-layer-action-icon",children:"⤴"}),s.jsx("span",{className:"v10-layer-action-label",children:"Share"})]}),s.jsxs("button",{className:"v10-layer-action-btn",onClick:i,"aria-label":"Import into Context Graph",children:[s.jsx("span",{className:"v10-layer-action-icon",children:"↑"}),s.jsx("span",{className:"v10-layer-action-label",children:"Import"})]}),s.jsx("button",{className:"v10-layer-action-btn",onClick:a,"aria-label":"Refresh Context Graph data",children:s.jsx("span",{className:"v10-layer-action-icon",children:"↻"})})]})]})}function eo({cg:e,profile:t,activeSubGraph:n,onClearSubGraph:r}){const i=e.name||t.displayName||e.id;return s.jsxs("div",{className:"v10-project-strip",style:{"--sg-color":(n==null?void 0:n.color)??t.primaryColor},children:[s.jsx("span",{className:"v10-project-strip-dot",style:{background:t.primaryColor}}),s.jsx("button",{type:"button",className:"v10-project-strip-name",onClick:n?r:void 0,disabled:!n,title:n?"Back to context graph overview":e.id,children:i}),n?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"v10-project-strip-sep",children:"›"}),s.jsxs("span",{className:"v10-project-strip-sg",children:[s.jsx("span",{className:"v10-project-strip-sg-icon",style:{color:n.color},children:n.icon??"•"}),n.displayName??n.slug]}),n.description&&s.jsx("span",{className:"v10-project-strip-desc",title:n.description,children:n.description})]}):e.description&&s.jsx("span",{className:"v10-project-strip-desc",title:e.description,children:e.description})]})}function to(e,t,n,r,i){const a=typeof(e==null?void 0:e.curator)=="string"?e.curator.trim():"",o=new Set([t==null?void 0:t.agentDid,t==null?void 0:t.agentAddress].filter(d=>typeof d=="string"&&d.trim().length>0).map(Ie)),l=o.size>0;return a&&l&&o.has(Ie(a))?{label:"Curator",title:"This agent is the curator for this Context Graph.",tone:"curator"}:(e==null?void 0:e.callerInvolved)===!0?a&&!l&&n==="loading"?{label:"Role checking",title:"This agent is involved in this Context Graph; curator status is still loading.",tone:"unknown"}:a&&!l&&n==="error"?{label:"Role unknown",title:"This agent is involved in this Context Graph, but curator status could not be confirmed.",tone:"unknown"}:{label:"Joined",title:"This agent is involved in this Context Graph; curator status is shown only when identity metadata confirms it.",tone:"participant"}:(e==null?void 0:e.callerInvolved)===!1?{label:"Not joined",title:"This agent is not listed as curator or participant for this Context Graph.",tone:"viewer"}:i==="ok"&&r.map(d=>d.trim()).filter(Boolean).some(d=>o.has(Ie(d)))?{label:"Joined",title:"This agent is listed as a participant for this Context Graph.",tone:"participant"}:{label:"Role unknown",title:"The node did not provide enough role metadata for this Context Graph.",tone:"unknown"}}function no(e,t,n){if(Gn(e==null?void 0:e.accessPolicy)==="public")return{id:"participants",value:"Open",label:"Public access",tooltip:"Public Context Graphs do not have an authoritative allowlist count."};if(n==="loading")return{id:"participants",value:"...",label:"Agents with access",tooltip:"Participant list is loading."};if(n==="error")return{id:"participants",value:"Unavailable",label:"Agents with access",tooltip:"Participant list unavailable; access count is unknown."};const i=new Set(t.map(o=>o.trim()).filter(Boolean).map(Ie)),a=typeof(e==null?void 0:e.curator)=="string"?e.curator.trim():"";return a&&i.add(Ie(a)),{id:"participants",value:i.size.toLocaleString(),label:"Agents with access",tooltip:"Includes the curator plus allowlisted participants reported by the node."}}function so(e){const t=Gn(e);return t==="public"?{label:"Public",title:"Public Context Graph.",tone:"public"}:t==="private"?{label:"Curated",title:"Curated Context Graph with access controlled by the curator.",tone:"curated"}:{label:"Access unknown",title:"The node did not provide an access policy for this Context Graph.",tone:"unknown"}}function ro({cg:e,currentAgent:t,currentAgentStatus:n="ok"}){var l,c;const r=typeof(e==null?void 0:e.curator)=="string"?e.curator.trim():"";if(!r)return"unknown";const i=((l=t==null?void 0:t.agentDid)==null?void 0:l.trim())??"",a=((c=t==null?void 0:t.agentAddress)==null?void 0:c.trim())??"",o=i||a;return o?Ie(r)===Ie(o)?"curator":"not-curator":"unknown"}function io(e){return new Set([e==null?void 0:e.agentDid,e==null?void 0:e.agentAddress].filter(t=>typeof t=="string"&&t.trim().length>0).map(Ie))}function ao({cg:e,memory:t,subGraphCount:n,subGraphFetchFailed:r=!1,participants:i,participantsStatus:a="ok",currentAgent:o,currentAgentStatus:l="ok",onSwitchLayer:c,onOpenPrimer:d}){var A,M,F;const{wm:g,swm:h,vm:u}=t.counts,p=g+h+u,v=to(e,o??null,l,i,a),y=so(e==null?void 0:e.accessPolicy),w=no(e,i,a),m=typeof(e==null?void 0:e.curator)=="string"?e.curator.trim():"",b=m?Ie(m):"",x=Gn(e==null?void 0:e.accessPolicy)==="public",k=io(o??null),N=Object.values(t.layerStatus??{}),j=N.filter(B=>B==="error").length,_=!t.loading&&N.length===3&&j===3,z=!t.loading&&j>0,E=t.loading?"Loading memory layers...":_||t.error?"Live memory counts are unavailable.":t.partial||z?"One or more layer counts are currently a lower bound.":"Canonical current-layer entity counts.",T=_?"Unavailable":p.toLocaleString(),{total:C}=Bn(t),O=!t.loading&&(t.partial||z),Z=_?"Unavailable":t.loading&&C===0?"...":O?`${C.toLocaleString()}+`:C.toLocaleString(),$=_?"Live triple counts are unavailable.":O?"One or more layer triple counts are currently a lower bound.":"Canonical triple total across all layers.",R=n==null?r?"Unavailable":"...":n.toLocaleString(),G=n==null?r?"Sub-graph list is currently unavailable.":"Sub-graph count is loading.":"Topical partitions inside this Context Graph.",P=[{key:"wm",label:"Working Memory",desc:"Private staging area",count:g,status:((A=t.layerStatus)==null?void 0:A.wm)??"ok",color:"#64748b"},{key:"swm",label:"Shared Working Memory",desc:"Collaborative review",count:h,status:((M=t.layerStatus)==null?void 0:M.swm)??"ok",color:"#f59e0b"},{key:"vm",label:"Verifiable Memory",desc:"Published on-chain",count:u,status:((F=t.layerStatus)==null?void 0:F.vm)??"ok",color:"#22c55e"}],L=P.some(B=>B.status==="error");return s.jsxs("div",{className:"v10-po",children:[s.jsxs("div",{className:"v10-po-identity","data-section":"identity",children:[s.jsxs("div",{className:"v10-po-identity-pairs",children:[s.jsxs("div",{className:"v10-po-identity-pair",children:[s.jsx("span",{className:"v10-po-identity-label",children:"Your role:"}),s.jsx("span",{className:"v10-po-badge","data-role":v.tone,title:v.title,children:v.label})]}),s.jsxs("div",{className:"v10-po-identity-pair",children:[s.jsx("span",{className:"v10-po-identity-label",children:"Context Graph:"}),s.jsx("span",{className:"v10-po-badge","data-cg-type":y.tone,title:y.title,children:y.label})]})]}),d&&s.jsx("button",{type:"button",className:"v10-po-identity-primer",onClick:d,title:"Open the Context Graph primer",children:"What is a Context Graph?"})]}),s.jsxs("div",{"data-section":"at-a-glance",className:"v10-po-stat-block",children:[s.jsx("div",{className:"v10-po-section-title",children:"At a glance"}),s.jsx(pn,{className:"v10-po-stat-strip",items:[{id:"entities",value:T,label:"Entities",tooltip:E},{id:"triples",value:Z,label:"Triples",tooltip:$},{id:"subgraphs",value:R,label:"Subgraphs",tooltip:G},w]})]}),s.jsxs("div",{className:"v10-po-pipeline","data-section":"pipeline","aria-label":"Knowledge Pipeline",children:[s.jsx("div",{className:"v10-po-pipeline-head",children:s.jsxs("div",{children:[s.jsx("div",{className:"v10-po-section-title",children:"Knowledge Pipeline"}),s.jsx("div",{className:"v10-po-section-desc",children:"Entities move from private staging to shared review; published assertion bundles become Knowledge Assets with on-chain provenance."})]})}),s.jsx("div",{className:"v10-po-pipeline-track","aria-hidden":"true",children:!L&&p>0?P.map(B=>{const J=B.count>0?B.count/p*100:0;return s.jsx("span",{className:`v10-po-pipeline-seg ${B.key}`,style:{width:`${J}%`,background:B.color}},B.key)}):s.jsx("span",{className:"v10-po-pipeline-empty"})}),s.jsx("div",{className:"v10-po-pipeline-steps",children:P.map((B,J)=>s.jsxs("button",{type:"button",className:`v10-po-pipeline-step ${B.key}`,onClick:()=>c==null?void 0:c(B.key),style:{"--po-layer-color":B.color},children:[s.jsx("span",{className:"v10-po-pipeline-step-index",children:J+1}),s.jsxs("span",{className:"v10-po-pipeline-step-copy",children:[s.jsx("span",{className:"v10-po-pipeline-step-label",children:B.label}),s.jsx("span",{className:"v10-po-pipeline-step-desc",children:B.desc})]}),s.jsx("span",{className:"v10-po-pipeline-step-count",children:B.status==="error"?"Unavailable":`${B.count.toLocaleString()} ${We(B.key,B.count)}`})]},B.key))})]}),s.jsxs("div",{className:"v10-po-people","data-section":"participants",children:[s.jsx("div",{className:"v10-po-section-title",children:"Participant agents"}),(()=>{const B="did:dkg:agent:",J=V=>V.toLowerCase().startsWith(B)?V.slice(B.length):V,X=new Set,Y=[];if(m&&a==="ok"){const V=Ie(m);X.add(V),Y.push({display:J(m),full:m,canonical:V})}if(a==="ok")for(const V of i){const re=Ie(V);X.has(re)||(X.add(re),Y.push({display:J(V),full:V,canonical:re}))}if(Y.length===0){const V=x?"This Context Graph is public — anyone can subscribe.":a==="loading"?"Loading participant agents...":a==="error"?"Participant list unavailable.":"No participant agents recorded yet.";return s.jsx("div",{className:"v10-po-people-empty",children:V})}return s.jsx("div",{className:"v10-po-participants-list",children:Y.map(({display:V,full:re,canonical:ye})=>{const Ne=k.has(ye),Re=!!b&&ye===b,q=`${V.slice(0,6)}…${V.slice(-4)}`,ne=[q];return Ne&&ne.push("you"),Re&&ne.push("curator"),s.jsxs("span",{className:`v10-po-participant${Ne?" is-self":""}${Re?" is-curator":""}`,title:re,"aria-label":ne.join(" "),children:[s.jsx("span",{className:"v10-po-participant-name",children:q}),Ne&&s.jsx("span",{className:"v10-po-participant-tag",children:"you"}),Re&&s.jsx("span",{className:"v10-po-participant-tag",children:"curator"})]},ye)})})})()]})]})}function oo({contextGraphId:e,curatorStatus:t,onParticipantsChanged:n}){const[r,i]=f.useState([]),[a,o]=f.useState(null),[l,c]=f.useState("loading"),d=f.useRef(0),g=f.useCallback(()=>{if(t!=="curator"){i([]),c("idle");return}const p=++d.current;c("loading"),dr(e).then(v=>{d.current===p&&(i(v.requests.filter(y=>y.status==="pending")),c("idle"))}).catch(()=>{d.current===p&&(i([]),c("error"))})},[e,t]);if(f.useEffect(()=>(g(),()=>{d.current++}),[g]),Ui(f.useCallback(p=>{var v;p.type!=="join_request"&&p.type!=="join_approved"&&p.type!=="join_rejected"||((v=p.data)==null?void 0:v.contextGraphId)===e&&g()},[e,g])),t==="not-curator")return null;if(t==="unknown")return s.jsxs("section",{className:"v10-po-join","data-section":"join-requests",children:[s.jsx("header",{className:"v10-po-join-head",children:s.jsx("span",{className:"v10-po-section-title",children:"Pending join requests"})}),s.jsx("div",{className:"v10-po-join-empty",children:"Verifying access…"})]});const h=async p=>{o(p);try{await pr(e,p),i(v=>v.filter(y=>y.agentAddress!==p)),n==null||n()}catch{}finally{o(null)}},u=async p=>{o(p);try{await hr(e,p),i(v=>v.filter(y=>y.agentAddress!==p)),n==null||n()}catch{}finally{o(null)}};return s.jsxs("section",{className:"v10-po-join","data-section":"join-requests",children:[s.jsxs("header",{className:"v10-po-join-head",children:[s.jsx("span",{className:"v10-po-section-title",children:"Pending join requests"}),s.jsx("span",{className:"v10-po-join-count","data-empty":r.length===0?"true":"false",children:r.length})]}),l==="loading"?s.jsx("div",{className:"v10-po-join-empty",children:"Loading join requests..."}):l==="error"?s.jsx("div",{className:"v10-po-join-empty",children:"Join requests are currently unavailable."}):r.length===0?s.jsx("div",{className:"v10-po-join-empty",children:"No pending join requests."}):s.jsx("div",{className:"v10-po-join-list",children:r.map(p=>s.jsxs("div",{className:"v10-po-join-item",children:[s.jsxs("div",{className:"v10-po-join-info",children:[s.jsx("span",{className:"v10-po-join-name",children:p.name||`${p.agentAddress.slice(0,6)}…${p.agentAddress.slice(-4)}`}),s.jsxs("span",{className:"v10-po-join-addr",title:p.agentAddress,children:[p.agentAddress.slice(0,10),"…"]})]}),s.jsxs("div",{className:"v10-po-join-actions",children:[s.jsx("button",{className:"v10-po-join-btn approve",onClick:()=>h(p.agentAddress),disabled:a===p.agentAddress,children:a===p.agentAddress?"…":"✓ Approve"}),s.jsx("button",{className:"v10-po-join-btn reject",onClick:()=>u(p.agentAddress),disabled:a===p.agentAddress,"aria-label":"Reject join request",children:"✕"})]})]},p.agentAddress))})]})}function lo({onOpenPrimer:e}){return s.jsxs("div",{className:"v10-po-primer-footer","data-section":"primer",children:[s.jsx("span",{className:"v10-po-primer-footer-lede",children:"New here?"}),s.jsx("span",{className:"v10-po-primer-footer-arrow","aria-hidden":"true",children:"→"}),s.jsx("button",{type:"button",className:"v10-po-primer-footer-link",onClick:e,children:"What is a Context Graph?"}),s.jsx("div",{className:"v10-po-primer-footer-sub",children:"A short primer on context graphs, the WM → SWM → VM pipeline, and how participant agents collaborate."})]})}const co=(e,t)=>!!e&&!!t&&e.toLowerCase()===t.toLowerCase();function uo(e,t=0){const n=br(o=>o.trackedIds),r=n.join(","),{data:i,loading:a}=ft(async()=>{if(n.length===0)return{wallets:[],ownerPublish:!1,resolved:!1};const o=await Di().catch(()=>null),l=(o==null?void 0:o.wallets)??[];let c=!1;try{const{contextGraphs:g}=await Zi(),h=(g??[]).find(p=>(p==null?void 0:p.id)===e),u=h==null?void 0:h.curator;if(u){const p=await qi().catch(()=>null);c=!!(p!=null&&p.agentDid&&Ie(u)===Ie(p.agentDid))}}catch{c=!1}return{wallets:await Promise.all(l.map(async g=>{var k;const h=(k=o==null?void 0:o.balances)==null?void 0:k.find(N=>co(N.address,g)),u=h==null,p=h!=null&&Number(h.eth)>0,v=h!=null&&Number(h.trac)>0;let y,w=!1,m=!1,b,x=!1;for(const N of n){const j=await cs(N,g,{extended:!0}).catch(()=>null);if(j===null){x=!0;continue}const _=us(j);if(_.outcome==="inconclusive"){x=!0;continue}if(_.outcome!=="unregistered"){if(_.outcome==="covers"){y={accountId:N,discountBps:j.discountBps,untracked:!1};break}_.dead&&(w=!0,b||(b=N)),_.hasBudget||(m=!0)}}if(!y&&!x&&!w&&!m){const N=await Gi(g).catch(()=>{});if(N===void 0)x=!0;else if(N.accountId!=null&&!n.includes(N.accountId)){const j=N.accountId,_=await cs(j,g,{extended:!0}).catch(()=>null);if(_===null)x=!0;else{const z=us(_);z.outcome==="covers"?y={accountId:j,discountBps:_.discountBps,untracked:!0}:z.outcome==="uncovered"?(z.dead&&(w=!0,b||(b=j)),z.hasBudget||(m=!0)):x=!0}}}return{wallet:g,covered:!!y,accountId:y==null?void 0:y.accountId,discountBps:y==null?void 0:y.discountBps,coverUntracked:(y==null?void 0:y.untracked)??!1,deadAccountId:y?void 0:b,inconclusive:!y&&x,balanceUnknown:u,gasFunded:p,hasTrac:v,sawExpired:w,sawInsolvent:m}})),ownerPublish:c,resolved:l.length>0}},[r,e],t);return f.useMemo(()=>{const o=(i==null?void 0:i.wallets)??[],l=(i==null?void 0:i.ownerPublish)??!1,c=(i==null?void 0:i.resolved)??!1;if(n.length===0||!c||o.length===0)return{verdict:"unknown",loading:a,ownerPublish:l,anyGasFunded:!1,reasons:[],conditions:{approved:!1,gasFunded:!1,notExpired:!1,solvent:!1},wallets:o};const d=o.filter(m=>m.covered),g=o.filter(m=>!m.covered),h=g.filter(m=>!m.inconclusive&&!m.balanceUnknown),u=g.filter(m=>m.inconclusive||m.balanceUnknown),p={approved:g.length===0,gasFunded:o.every(m=>m.gasFunded),notExpired:!o.some(m=>m.sawExpired),solvent:!o.some(m=>m.sawInsolvent)};let v;const y=[];if(g.length===0)d.some(m=>m.gasFunded||m.balanceUnknown)?v="eligible":(v="fallthrough-no-funds",y.push("every approved signing wallet is out of gas"));else if(h.length===0&&u.length>0)v="unknown";else{const m=o.some(b=>(b.covered||b.hasTrac)&&b.gasFunded);!m&&u.length>0?v="unknown":(v=m?"fallthrough":"fallthrough-no-funds",y.push(`${d.length} of ${o.length} signing wallets approved`),o.some(b=>b.sawExpired)&&y.push("a PCA has expired or been fully swept"),o.some(b=>b.sawInsolvent)&&y.push("a PCA is out of budget"),p.gasFunded||y.push("a signing wallet has no gas"),g.some(b=>b.inconclusive)&&y.push("a wallet’s PCA coverage couldn’t be checked"),g.some(b=>b.balanceUnknown)&&y.push("a signing wallet’s balance couldn’t be checked"))}const w=d.reduce((m,b)=>(b.discountBps??-1)>((m==null?void 0:m.discountBps)??-1)?b:m,void 0);return{verdict:v,loading:a,accountId:w==null?void 0:w.accountId,discountBps:w==null?void 0:w.discountBps,accountUntracked:w==null?void 0:w.coverUntracked,ownerPublish:l,anyGasFunded:o.some(m=>m.gasFunded||m.balanceUnknown),reasons:y,conditions:p,wallets:o}},[i,a,n.length])}function po(e){return e.verdict==="fallthrough-no-funds"&&!(e.ownerPublish&&e.anyGasFunded)}function ho(e){const t=br(o=>o.trackedIds),n=uo(e,3e4),r=po(n),i="Publish will fail — no signing wallet can fund it (coverage or gas).",a=t.length>0;return{blocked:r,reason:i,chipVisible:a,eligibility:n}}function mo({verdict:e,accountId:t,discountBps:n,accountUntracked:r,ownerPublish:i,id:a}){return s.jsx("div",{className:"v10-pca-publish-chip",id:a,"data-testid":"pca-publish-eligibility",children:s.jsx($a,{variant:"chip",verdict:e,accountId:t,discountBps:n,accountUntracked:r,ownerPublish:i})})}function Jn({title:e,agent:t,footnote:n,dismissed:r,onDismiss:i,children:a}){return s.jsxs("div",{className:`v10-gen-widget ${r?"dissolved":""}`,children:[s.jsxs("div",{className:"v10-gen-widget-header",children:[s.jsx("span",{className:"v10-gen-widget-title",children:e}),s.jsxs("div",{className:"v10-gen-widget-right",children:[t&&s.jsxs("span",{className:"v10-gen-widget-agent",children:[s.jsx("span",{className:"v10-gen-widget-agent-dot"}),t]}),i&&s.jsx("button",{className:"v10-gen-widget-dismiss",onClick:i,children:"✕"})]})]}),s.jsx("div",{className:"v10-gen-widget-body",children:a}),n&&s.jsx("div",{className:"v10-gen-widget-footnote",children:n})]})}function fo({entities:e}){const t=et(),n=f.useMemo(()=>{const r=new Map;for(const i of e){const{icon:a,type:o}=dn(i,t),l=r.get(o);l?l.count++:r.set(o,{icon:a,count:1})}return[...r.entries()].sort((i,a)=>a[1].count-i[1].count)},[e,t]);return n.length===0?null:s.jsx(Jn,{title:"Entity Types",children:s.jsx(pn,{compact:!0,items:n.map(([r,{icon:i,count:a}])=>({id:r,label:`${i} ${r}`,value:a}))})})}function go({entities:e,entityCount:t,triples:n,layer:r}){const i=f.useMemo(()=>e.filter(l=>l.properties.has("http://dkg.io/ontology/sourceContentType")).length,[e]),a=f.useMemo(()=>e.reduce((l,c)=>l+c.connections.length,0),[e]),o=e.length>0?(a/e.length).toFixed(1):"0";return s.jsx(Jn,{title:"Layer Stats",children:s.jsx(pn,{compact:!0,layer:r,items:[{id:"entities",label:We(r,t),value:t},{id:"triples",label:"Triples",value:n},{id:"connections",label:"Connections",value:a},{id:"avg",label:"Avg. connections / entity",value:o},...i>0?[{id:"documents",label:"Documents",value:i}]:[]]})})}function Er(e,t){const[n,r]=f.useState(!1),[i,a]=f.useState(null),[o,l]=f.useState(null),c=f.useCallback(async(d,g)=>{r(!0),l(null),a(null);try{const h=await d();a(h),e==null||e({ok:!0,text:h}),t==null||t()}catch(h){const u=g(h);l(u),e==null||e({ok:!1,text:u})}finally{r(!1)}},[e,t]);return{busy:n,result:i,error:o,run:c}}function _r({title:e,footnote:t,context:n,result:r,error:i,extras:a,children:o}){return s.jsxs(Jn,{title:e,footnote:t,children:[s.jsx("div",{className:"v10-decision-context",style:{marginBottom:10},children:n}),r&&s.jsxs("div",{"data-testid":"layer-action-result",style:{fontSize:11,color:"var(--text-success)",marginBottom:8},children:["✓ ",r]}),i&&s.jsxs("div",{"data-testid":"layer-action-error",style:{fontSize:11,color:"var(--text-danger)",marginBottom:8},children:["✕ ",i]}),a,s.jsx("div",{className:"v10-decision-actions",children:o})]})}function vo({count:e,contextGraphId:t,onComplete:n,onResult:r}){const{busy:i,result:a,error:o,run:l}=Er(r,n),c=f.useCallback(()=>{let h=null;l(async()=>{const u=await Yt(t,"wm");let p=0;for(const y of u)h=y.name,(await Xt(t,y.name,y.subGraph?{subGraphName:y.subGraph}:{})).promotedCount===0&&(p+=1);const v=u.length-p;if(v>0){const y=p>0?` (${p} already shared or still committing)`:"";return`Shared ${v} complete Knowledge Asset${v!==1?"s":""} to Shared Memory${y}`}return"No Knowledge Assets were newly shared — all were already in Shared Memory or still committing."},u=>{const p=en(h??"an assertion",u);return p?p.message:(u==null?void 0:u.message)??"Action failed"})},[t,l]);if(e===0)return null;const d="#f59e0b",g=We("wm",e).toLowerCase();return s.jsx(_r,{title:"Share complete Knowledge Assets",footnote:"Shares each complete owning Knowledge Asset atomically to Shared Working Memory.",context:s.jsxs(s.Fragment,{children:[e," eligible ",g," will be shared through their complete owning Knowledge Assets for collaborative review."]}),result:a,error:o,children:s.jsx("button",{"data-testid":"widget-promote-all-btn",className:"v10-decision-btn approve",style:{borderColor:`${d}50`,color:"var(--text-warning)",background:`${d}15`,opacity:i?.5:1},disabled:i,onClick:c,children:i?"...":"✓ Share Complete KAs → Shared"})})}function bo({count:e,contextGraphId:t,onComplete:n,onResult:r}){const[i,a]=f.useState(null),{busy:o,result:l,error:c,run:d}=Er(r,n),g=ho(t),h=f.useId(),u=f.useId(),p=[g.chipVisible?h:null,g.blocked?u:null].filter(Boolean).join(" ")||void 0,v=f.useCallback(()=>{g.blocked||d(async()=>{a(null);const w=await Yt(t,"swm"),m=await yr(t,w),b=xr(m),x=b?` — ⚠ ${b}`:"";if(m.published>0){const k=m.failures.length?` (${m.failures.length} assertion${m.failures.length===1?"":"s"} could not be published)`:"",N=m.partial>0?` — ⚠ ${m.partial}: ${tn(m.partialError)}`:"";return a(m.convictionCostCovered??null),`Published ${m.published} knowledge asset${m.published!==1?"s":""} to Verifiable Memory${k}${N}${x}`}if(w.length===0)return"Nothing to publish — promote assertions to Shared Memory first.";if(b&&m.failures.length===0)return`⚠ ${b}`;throw new Error(`${m.failures[0]?`${m.failures[0].name}: ${m.failures[0].error}`:"Publish failed"}${x}`)},w=>(w==null?void 0:w.message)??"Action failed")},[t,d,g.blocked]);if(e===0)return null;const y=We("swm",e).toLowerCase();return s.jsx(_r,{title:"Publish",footnote:`Moves ${y} from this layer to Verifiable Memory.`,context:s.jsxs(s.Fragment,{children:[e," ",y," in this layer can be published to Verifiable Memory on-chain."]}),result:l,error:c,extras:s.jsxs(s.Fragment,{children:[s.jsx(Bi,{convictionCostCovered:i}),g.chipVisible&&s.jsx(mo,{...g.eligibility,id:h}),g.blocked&&s.jsx("span",{id:u,className:"v10-sr-only",children:g.reason})]}),children:s.jsx("button",{"data-testid":"widget-publish-vm-btn",className:"v10-decision-btn primary-cta publish-vm",style:{opacity:o||g.blocked?.5:1},disabled:o,"aria-disabled":g.blocked||void 0,title:g.blocked?g.reason:void 0,"aria-describedby":p,onClick:v,children:o?"...":"◉ Publish to Verifiable Memory"})})}function yo({layer:e,entities:t,entityCount:n,actionEntityCount:r=n,tripleCount:i,contextGraphId:a,onComplete:o}){const[l,c]=f.useState(null),d=l&&s.jsxs("div",{"data-testid":l.ok?"layer-action-result":"layer-action-error",style:{fontSize:11,color:l.ok?"var(--text-success)":"var(--text-danger)",marginBottom:8},children:[l.ok?"✓":"✕"," ",l.text]});return n===0?s.jsxs("div",{className:"v10-layer-widgets-strip empty",children:[d,s.jsx(xe,{compact:!0,tone:At(e),icon:Oe[e].icon,title:`No ${We(e,2).toLowerCase()} yet`,description:e==="wm"?"Import data or chat with agents to populate Working Memory.":e==="swm"?"Seal and share complete Knowledge Assets from Working Memory with the team.":"Publish complete Knowledge Assets from Shared Working Memory to verify them on-chain."})]}):s.jsxs("div",{className:"v10-layer-widgets-strip",children:[s.jsxs("div",{className:"v10-layer-widgets-strip-stats",children:[s.jsx(go,{entities:t,entityCount:n,triples:i,layer:e}),s.jsx(fo,{entities:t})]}),(e==="wm"||e==="swm")&&a&&r>0&&s.jsx("div",{className:"v10-layer-widgets-strip-action",children:e==="wm"?s.jsx(vo,{count:r,contextGraphId:a,onComplete:o,onResult:c}):s.jsx(bo,{count:r,contextGraphId:a,onComplete:o,onResult:c})})]})}const xo={working:{layerKey:"wm",icon:"◇",label:"Working"},shared:{layerKey:"swm",icon:"◈",label:"Shared"},verified:{layerKey:"vm",icon:"◉",label:"Verifiable"}},jo=new Set(["http://dkg.io/ontology/profile/QueryCatalog","http://dkg.io/ontology/profile/SavedQuery"]);function wo(e){return e.types.some(t=>jo.has(t))}function Ar({entities:e,layerKey:t,layerIcon:n,onSelectEntity:r,onOpenAgent:i,externallySorted:a=!1,sortLabel:o,headerExtra:l,timestampPredicate:c,perEntityTrustBadge:d=!1}){const g=et(),h=It(),u=We(t,e.length).toLowerCase(),p=f.useMemo(()=>{if(a)return e;const w=[...e];return w.sort((m,b)=>{const x=m.tripleCount??0;return(b.tripleCount??0)-x}),w},[e,a]),v=t==="vm"?"Verifiable":t==="swm"?"Shared":"Working";if(e.length===0)return s.jsx("div",{className:"v10-entity-list empty",children:s.jsx(xe,{compact:!0,tone:At(t),icon:n,title:`No ${We(t,2).toLowerCase()} yet`,description:`This view will fill when matching ${We(t,2).toLowerCase()} are available.`})});const y=o??(a?"click to open":"sorted by triples · click to open");return s.jsxs("div",{className:"v10-entity-list",children:[s.jsxs("div",{className:"v10-entity-list-header",children:[s.jsxs("span",{className:"v10-entity-list-count",children:[p.length," ",u]}),s.jsx("span",{className:"v10-entity-list-hint",children:y}),l&&s.jsx("span",{className:"v10-entity-list-extra",children:l})]}),p.map(w=>{const{icon:m,type:b}=dn(w,g),x=w.tripleCount??0,k=Wn(w),N=k?h==null?void 0:h.get(k):null,j=c?Vt(w,c):null;return s.jsxs("div",{className:"v10-entity-card",onClick:_=>{_.stopPropagation(),r(w.uri)},children:[s.jsx("span",{className:"v10-entity-card-icon",children:m}),s.jsxs("div",{className:"v10-entity-card-main",children:[s.jsx("div",{className:"v10-entity-card-title",children:w.label}),s.jsxs("div",{className:"v10-entity-card-meta",children:[(N||k)&&s.jsx(gt,{agent:N??void 0,fallbackUri:k??void 0,size:"sm",onOpenAgent:i}),b&&b!=="Entity"&&s.jsxs("span",{className:"v10-entity-type-pill",children:[m," ",b]}),j!=null&&s.jsx("span",{className:"v10-entity-card-timestamp",title:new Date(j).toLocaleString(),children:Vi(j)}),s.jsxs("span",{className:"v10-entity-card-triples",children:[x," triples"]})]})]}),d?(()=>{const _=xo[w.trustLevel];return s.jsxs("span",{className:`v10-trust-badge ${_.layerKey}`,title:`${_.label} Memory`,children:[_.icon," ",_.label]})})():s.jsxs("span",{className:`v10-trust-badge ${t}`,children:[n," ",v]})]},w.uri)})]})}function ko({layer:e,entities:t,tripleCount:n,layerTriples:r,contextGraphId:i,memory:a,activeTab:o,onTabChange:l,onSelectEntity:c,onNodeClick:d,footer:g,swmAttribution:h,showQueryCatalog:u=!1,onShowQueryCatalogChange:p}){var _;const v=Oe[e],y=We(e,2),w=f.useMemo(()=>t.filter(z=>!wo(z)).length,[t]),m=((_=a.layerStatus)==null?void 0:_.vm)??(a.loading?"loading":a.error?"error":"ok"),b=e==="vm"&&m==="loading"&&t.length===0,x=e==="vm"&&m==="error"&&t.length===0,k=e==="vm"&&m==="ok"&&t.length===0,N=a.counts[e],j=z=>E=>{E.stopPropagation(),l(z)};return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"v10-layer-expand-tabs",children:[s.jsx("button",{className:`v10-layer-expand-tab ${o==="items"?"active":""}`,onClick:j("items"),children:y}),e!=="vm"&&s.jsx("button",{className:`v10-layer-expand-tab ${o==="assertions"?"active":""}`,onClick:j("assertions"),children:"Assertions"}),s.jsx("button",{className:`v10-layer-expand-tab ${o==="graph"?"active":""}`,onClick:j("graph"),children:"Graph"}),s.jsx("button",{className:`v10-layer-expand-tab ${o==="docs"?"active":""}`,onClick:j("docs"),children:"Documents"}),e!=="vm"&&p&&s.jsxs("label",{className:"v10-query-catalog-visibility",children:[s.jsx("input",{type:"checkbox",checked:u,onChange:z=>p(z.target.checked)}),s.jsx("span",{children:"Show query catalog"})]})]}),o==="items"&&s.jsxs("div",{className:"v10-layer-expand-body entities-tab","data-cg-scroll-key":`layer:${e}:items`,children:[e==="vm"&&!b&&!x&&s.jsx(No,{entities:t,tripleCount:n,contextGraphId:i}),b?s.jsx("div",{className:"v10-layer-widgets-strip empty",children:s.jsx(xe,{compact:!0,tone:"vm",icon:Oe.vm.icon,title:"Loading Verifiable Memory...",description:"Knowledge Assets are being read from the verified layer."})}):x?s.jsx("div",{className:"v10-layer-widgets-strip empty",children:s.jsx(xe,{compact:!0,tone:"vm",icon:Oe.vm.icon,title:"Verifiable Memory status unavailable.",description:"This node could not read the verified layer right now."})}):!k&&s.jsxs(s.Fragment,{children:[s.jsx(yo,{layer:e,entities:t,entityCount:N,actionEntityCount:w,tripleCount:n,contextGraphId:i,onComplete:a.refresh}),s.jsx(Ar,{entities:t,layerKey:e,layerIcon:v.icon,onSelectEntity:c})]}),g]}),o==="assertions"&&e!=="vm"&&s.jsx("div",{className:"v10-layer-expand-body full-width",children:s.jsx(So,{contextGraphId:i,layer:e,includeQueryCatalog:u,onComplete:a.refresh,scrollKey:`layer:${e}:assertions`})}),o==="graph"&&s.jsx("div",{className:"v10-layer-expand-body full-width","data-cg-scroll-key":`layer:${e}:graph`,children:s.jsx($r,{layer:e,triples:r,onNodeClick:d,contextGraphId:i,swmAttribution:e==="swm"?h:void 0,layerEntities:t})}),o==="docs"&&s.jsx("div",{className:"v10-layer-expand-body full-width",children:s.jsx(Tr,{entities:t,contextGraphId:i,scrollKey:`layer:${e}:docs`})})]})}function No({entities:e,tripleCount:t,contextGraphId:n}){const r=e.length,i=new Set;for(const o of e)for(const l of o.types)i.add(l);const a=i.size;return r===0?s.jsxs("div",{className:"v10-vm-hero v10-vm-hero-empty",children:[s.jsxs("div",{className:"v10-vm-hero-title",children:[s.jsx("span",{className:"v10-vm-hero-badge",children:"◉ Verifiable Memory"}),s.jsxs("div",{className:"v10-vm-hero-heading",children:[s.jsx("span",{className:"v10-vm-hero-headline",children:"Nothing published yet"}),s.jsxs("span",{className:"v10-vm-hero-context",title:n,children:["Context Graph: ",n]})]})]}),s.jsx(xe,{compact:!0,className:"v10-vm-empty-state",tone:"vm",icon:Oe.vm.icon,title:"No Knowledge Assets yet.",description:"Publish complete Knowledge Assets from Shared Working Memory to verify them on-chain."})]}):s.jsxs("div",{className:"v10-vm-hero",children:[s.jsxs("div",{className:"v10-vm-hero-title",children:[s.jsx("span",{className:"v10-vm-hero-badge",children:"◉ Verifiable Memory"}),s.jsxs("div",{className:"v10-vm-hero-heading",children:[s.jsx("span",{className:"v10-vm-hero-headline",children:"On-chain anchored · cryptographically signed"}),s.jsxs("span",{className:"v10-vm-hero-context",title:n,children:["Context Graph: ",n]})]})]}),s.jsx(pn,{className:"v10-vm-hero-stats",layer:"vm",items:[{id:"assets",value:r,label:"Knowledge Assets"},{id:"triples",value:t.toLocaleString(),label:"Verifiable Triples"},{id:"types",value:a,label:"Entity Types"}]}),s.jsxs("div",{className:"v10-vm-hero-strip",children:[s.jsxs("div",{className:"v10-vm-hero-chip",title:"Multi-agent endorsement",children:[s.jsx("span",{className:"v10-vm-hero-chip-dot",style:{background:"#22c55e"}}),"Consensus"]}),s.jsxs("div",{className:"v10-vm-hero-chip",title:"Published to the DKG blockchain anchor",children:[s.jsx("span",{className:"v10-vm-hero-chip-dot",style:{background:"#3b82f6"}}),"On-chain"]}),s.jsxs("div",{className:"v10-vm-hero-chip",title:"Each contribution bound to a DID",children:[s.jsx("span",{className:"v10-vm-hero-chip-dot",style:{background:"#a855f7"}}),"Agent Identity"]}),s.jsxs("div",{className:"v10-vm-hero-chip",title:"Tamper-evident via content hashing",children:[s.jsx("span",{className:"v10-vm-hero-chip-dot",style:{background:"#f59e0b"}}),"Content Hash"]})]})]})}function So({contextGraphId:e,layer:t,includeQueryCatalog:n=!1,onComplete:r,scrollKey:i}){const{data:a,loading:o,refresh:l}=ft(()=>Yt(e,t,{includeQueryCatalog:n}),[e,t,n],0),{data:c}=ft(()=>Ji(e),[e,t],0),[d,g]=f.useState(null),[h,u]=f.useState(null),[p,v]=f.useState(null),y=f.useCallback(async N=>{g(N.graphUri),u(null),v(null);try{if(t==="wm"){const j=await Xt(e,N.name,N.subGraph?{subGraphName:N.subGraph}:{}),_=jr(N.name,j);u(_.message)}else{const j=await wr(e,N.name,N.subGraph?{subGraphName:N.subGraph}:{});u(j.contextGraphError?`Published ${N.name} on-chain — ⚠ ${tn(j.contextGraphError)}`:`Published ${N.name} to Verifiable Memory`)}l(),r()}catch(j){const _=en(N.name,j);v(_?_.message:(j==null?void 0:j.message)??"Action failed")}finally{g(null)}},[e,t,l,r]),w=f.useCallback(async()=>{g("__all__"),u(null),v(null);let N=null;try{const j=await Yt(e,t);if(j.length===0){u(t==="wm"?"No user Knowledge Assets are ready to share.":"No user Knowledge Assets are ready to publish.");return}if(t==="wm"){let _=0;for(const E of j)N=E.name,(await Xt(e,E.name,E.subGraph?{subGraphName:E.subGraph}:{})).promotedCount===0&&(_+=1);const z=j.length-_;if(z>0){const E=_>0?` (${_} already shared or still committing)`:"";u(`Shared ${z} complete Knowledge Asset${z!==1?"s":""}${E}`)}else u("No Knowledge Assets were newly shared — all were already in Shared Memory or still committing.")}else{const _=await yr(e,j),z=xr(_),E=z?` — ⚠ ${z}`:"";if(_.published>0){const T=_.failures.length?` (${_.failures.length} could not be published)`:"",C=_.partial>0?` — ⚠ ${_.partial}: ${tn(_.partialError)}`:"";u(`Published ${_.published} knowledge asset${_.published!==1?"s":""} to Verifiable Memory${T}${C}${E}`)}else if(z&&_.failures.length===0)u(`⚠ ${z}`);else throw new Error(`${_.failures[0]?`${_.failures[0].name}: ${_.failures[0].error}`:"Publish failed"}${E}`)}l(),r()}catch(j){const _=en(N??"selected assertion",j);v(_?_.message:(j==null?void 0:j.message)??"Action failed")}finally{g(null)}},[e,t,l,r]),m={flex:1,overflow:"auto"};if(o)return s.jsx("div",{className:"v10-layer-empty-shell",style:m,"data-cg-scroll-key":i,children:s.jsx(xe,{compact:!0,tone:At(t),icon:Oe[t].icon,title:"Loading assertions..."})});if(!(a!=null&&a.length))return s.jsx("div",{className:"v10-layer-empty-shell",style:m,"data-cg-scroll-key":i,children:s.jsx(xe,{tone:At(t),icon:Oe[t].icon,title:t==="swm"?"No Shared Working Memory assertions listed yet.":"No Working Memory assertions yet.",description:t==="swm"?"Promoted assertion contents are available as Shared Working Memory entities. The assertion list will populate once promoted assertions are exposed by the node.":"Create or import data to stage assertions in Working Memory."})});const b=t==="wm"?"Share Complete KA → Shared":"Publish to VM",x=t==="wm"?"Share Complete KAs → Shared":"Publish all to Verifiable Memory",k=a.filter(N=>N.subGraph!=="meta"||!N.name.startsWith("query-catalog-")).length;return s.jsxs("div",{style:m,"data-cg-scroll-key":i,children:[s.jsxs("div",{style:{padding:"8px 16px",display:"flex",alignItems:"center",justifyContent:"space-between",borderBottom:"1px solid var(--border-subtle)"},children:[s.jsxs("span",{style:{fontSize:11,color:"var(--text-tertiary)"},children:[a.length," assertion",a.length!==1?"s":""]}),k>0&&s.jsx("button",{className:`v10-layer-expand-footer-btn ${t==="wm"?"promote":"publish"}`,disabled:d!==null,onClick:w,style:{opacity:d==="__all__"?.5:1},children:d==="__all__"?"...":x})]}),h&&s.jsxs("div",{"data-testid":t==="wm"?"assertion-promote-result":"assertion-publish-result",style:{padding:"6px 16px",fontSize:11,color:"var(--text-success)"},children:["✓ ",h]}),p&&s.jsxs("div",{"data-testid":t==="wm"?"assertion-promote-result":"assertion-publish-result",style:{padding:"6px 16px",fontSize:11,color:"var(--text-danger)"},children:["✕ ",p]}),a.map(N=>s.jsxs("div",{className:"v10-item-row","data-testid":"assertion-list-row",children:[s.jsx("span",{className:"v10-item-icon",children:"▤"}),s.jsxs("div",{className:"v10-item-info",children:[s.jsx("div",{className:"v10-item-name",style:{fontFamily:"var(--font-mono)",fontSize:11},children:N.name}),(c==null?void 0:c[N.name])&&s.jsx("div",{className:"v10-item-ual",style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-tertiary)",opacity:.7,wordBreak:"break-all",marginTop:1},title:c[N.name],children:c[N.name]}),s.jsxs("div",{className:"v10-item-meta-row",children:[N.tripleCount!=null&&s.jsxs("span",{className:"v10-item-count",children:[N.tripleCount," triples"]}),N.subGraph&&s.jsxs("span",{className:"v10-item-count v10-item-subgraph",title:`In sub-graph: ${N.subGraph}`,children:["› ",wa(N.subGraph,18)]})]})]}),s.jsx("button",{"data-testid":"assertion-row-action",className:`v10-layer-expand-footer-btn ${t==="wm"?"promote":"publish"}`,disabled:d!==null,onClick:j=>{j.stopPropagation(),y(N)},style:{opacity:d===N.graphUri?.5:1,flexShrink:0},children:d===N.graphUri?"...":b})]},N.graphUri))]})}function Co({layer:e,memory:t,onNodeClick:n,onSelectEntity:r,contextGraphId:i,activeTab:a,onTabChange:o,swmAttribution:l,showQueryCatalog:c=!1,onShowQueryCatalogChange:d}){const g=Oe[e],h=f.useMemo(()=>t.entityList.filter(p=>p.trustLevel===g.trustLevel),[t.entityList,g.trustLevel]),u=Wi(t,e);return s.jsxs("div",{className:"v10-layer-detail",children:[s.jsxs("div",{className:"v10-layer-detail-header",children:[s.jsx("span",{className:"v10-layer-detail-icon",style:{color:g.color},children:g.icon}),s.jsxs("div",{children:[s.jsx("div",{className:"v10-layer-detail-title",children:g.title}),s.jsx("div",{className:"v10-layer-detail-desc",children:g.desc})]}),s.jsx("div",{className:"v10-layer-detail-actions"})]}),s.jsx("div",{className:"v10-layer-detail-body",children:s.jsx(ko,{layer:e,entities:h,tripleCount:u.length,layerTriples:u,contextGraphId:i,memory:t,activeTab:a,onTabChange:o,onSelectEntity:r,onNodeClick:n,swmAttribution:l,showQueryCatalog:c,onShowQueryCatalogChange:d})})]})}function Tr({entities:e,contextGraphId:t,scrollKey:n}){const r=Vn(o=>o.openTab),i=f.useMemo(()=>e.filter(o=>o.properties.has(jn)),[e]),a=o=>{var u,p,v;const l=(u=o.connections.find(y=>y.predicate===ds))==null?void 0:u.targetUri,c=(p=o.connections.find(y=>y.predicate===ps))==null?void 0:p.targetUri,d=((v=o.properties.get(jn))==null?void 0:v[0])??"",{ref:g,contentType:h}=Qi(l,c,d);r({id:Ki(t??"",g??o.uri,h),label:o.label,closable:!0,icon:"📄"})};return i.length===0?s.jsx("div",{className:"v10-docs-placeholder v10-layer-empty-shell",style:{flex:1},"data-cg-scroll-key":n,children:s.jsx(xe,{compact:!0,title:"No documents in this layer yet.",description:"Import a file to add document-backed entities."})}):s.jsx("div",{className:"v10-layer-detail-content","data-cg-scroll-key":n,children:s.jsx("div",{className:"v10-items-list",children:i.map(o=>{var h,u,p,v;const l=((h=o.properties.get(jn))==null?void 0:h[0])??"",c=(u=o.connections.find(y=>y.predicate===ds||y.predicate===ps))==null?void 0:u.targetUri,d=c?e.find(y=>y.uri===c):void 0,g=((p=d==null?void 0:d.properties.get(hs))==null?void 0:p[0])??((v=o.properties.get(hs))==null?void 0:v[0]);return s.jsxs("div",{className:"v10-item-row",onClick:()=>a(o),children:[s.jsx("span",{className:"v10-item-icon",children:"📄"}),s.jsxs("div",{className:"v10-item-info",children:[s.jsx("div",{className:"v10-item-name",children:o.label}),s.jsxs("div",{className:"v10-item-meta-row",children:[l&&s.jsx("span",{className:"v10-item-type",children:l}),g&&s.jsxs("span",{className:"v10-item-count",children:["· ",Math.round(parseInt(g)/1024),"KB"]})]})]}),s.jsx("button",{className:"v10-item-promote-btn",onClick:y=>{y.stopPropagation(),a(o)},children:"Open →"})]},o.uri)})})})}function Rr(e){return`SELECT ?g ?s ?p ?o WHERE {
|
|
36
|
+
ORDER BY DESC(?ts) LIMIT 5000`}function Ge(e){if(e!=null)return typeof e=="string"?e.startsWith('"')?e.replace(/^"/,"").replace(/"(\^\^<[^>]*>)?$/,""):e:typeof e=="object"&&e!==null&&"value"in e?String(e.value):String(e)}function Da(e){return e===`${On}AssertionCreated`?"created":e===`${On}AssertionPromoted`?"promoted":null}function Za(e){const[t,n]=f.useState([]),[r,i]=f.useState(!!e),[a,o]=f.useState(null),[l,c]=f.useState(void 0),d=f.useRef(void 0),g=f.useRef(void 0);return f.useEffect(()=>{if(!e){i(!1);return}d.current!=null&&d.current!==e&&(n([]),o(null),c(void 0),g.current=void 0);let h=!1;const u=new AbortController;let p;return d.current=e,i(!0),o(null),(async()=>{var v;try{const y=new Promise((k,N)=>{p=setTimeout(()=>{u.abort(),N(new Error(`Assertion-lifecycle query timed out after ${Math.round(bs/1e3)}s`))},bs)}),w=(async()=>{const k=await fetch("/api/query",{method:"POST",headers:{"Content-Type":"application/json",...un()},signal:u.signal,body:JSON.stringify({sparql:Ua(e),contextGraphId:e})});if(!k.ok)throw new Error(`SPARQL query failed: ${k.status}`);return k.json()})(),m=await Promise.race([w,y]);if(h||d.current!==e)return;const b=((v=m==null?void 0:m.result)==null?void 0:v.bindings)??[],x=[];for(const k of b){const N=Ge(k.event),j=Ge(k.type),_=Ge(k.assertion),z=Ge(k.name),E=Ge(k.agent),T=Ge(k.ts);if(!N||!_||!E||!T)continue;const C=Da(j);if(!C)continue;let O;if(C==="promoted"){const R=Ge(k.entityCount),G=R!=null?Number(R):NaN;if(Number.isFinite(G)&&G>0)O=G;else{const P=Ge(k.subjectEntityCount),L=P!=null?Number(P):NaN;Number.isFinite(L)&&L>=0&&(O=L)}}let $=Ge(k.subGraphName);if($===void 0){const R=Ge(k.assertionGraph);R&&($=Fa(R,e))}x.push({eventUri:N,kind:C,assertionUri:_,assertionName:z??"",agentUri:E,publishedAt:T,subGraph:$,entityCount:O})}n(x),c(e),g.current=e,o(null)}catch(y){if(h||(y==null?void 0:y.name)==="AbortError")return;o(y.message??String(y)),g.current!==e&&n([]),c(e),g.current=e}finally{p&&clearTimeout(p),h||i(!1)}})(),()=>{h=!0,u.abort(),p&&clearTimeout(p)}},[e]),f.useMemo(()=>({resultContextGraphId:l,events:t,loading:r,error:a}),[l,t,r,a])}const qa={wm:"working",swm:"shared",vm:"verified"};function Ga(e){var u,p,v,y;const t=new Map;if(!e)return t;const n="http://dkg.io/ontology/decisions/status",r="http://dkg.io/ontology/tasks/status",i="http://dkg.io/ontology/tasks/priority",a="http://dkg.io/ontology/github/state",o="http://dkg.io/ontology/decisions/Decision",l="http://dkg.io/ontology/tasks/Task",c="http://dkg.io/ontology/github/PullRequest";let d=0,g=0,h=0;for(const w of e)if(w.types.includes(o))((u=w.properties.get(n))==null?void 0:u[0])==="proposed"&&d++;else if(w.types.includes(l)){const m=(p=w.properties.get(i))==null?void 0:p[0],b=(v=w.properties.get(r))==null?void 0:v[0];m==="p0"&&b!=="done"&&b!=="cancelled"&&g++}else w.types.includes(c)&&((y=w.properties.get(a))==null?void 0:y[0])==="open"&&h++;return d>0&&t.set("decisions",{label:`${d} proposed`,tone:"warn"}),g>0&&t.set("tasks",{label:`${g} p0`,tone:"danger"}),h>0&&t.set("github",{label:`${h} open`,tone:"info"}),t}const wn=({contextGraphId:e,profile:t,selected:n,onSelect:r,entities:i,layer:a,enabledScope:o,allTriplesTotal:l})=>{const[c,d]=Ce.useState([]),[g,h]=Ce.useState(!0),u=Ce.useMemo(()=>Ga(i),[i]),p=Ce.useRef(0),v=Ce.useMemo(()=>o&&o.size>0&&o.size<3?new Set(o):o&&o.size>=3?null:a?new Set([qa[a]]):null,[o,a]),y=Ce.useMemo(()=>{if(!i)return null;const $=new Map;for(const R of i)if(!(v&&!v.has(R.trustLevel)))for(const G of R.subGraphs)$.set(G,($.get(G)??0)+1);return $},[v,i]),w=Ce.useMemo(()=>{if(!i)return null;let $=0;for(const R of i)v&&!v.has(R.trustLevel)||$++;return $},[v,i]),m=Ce.useMemo(()=>{if(!i)return null;let $=0;for(const R of i)v&&!v.has(R.trustLevel)||R.subGraphs.size>0||$++;return $},[v,i]),b=Ce.useCallback(()=>{const $=++p.current;h(!0),$t.fetchSubGraphs(e).then(R=>{$===p.current&&d(R.subGraphs??[])}).catch(()=>{}).finally(()=>{$===p.current&&h(!1)})},[e]);Ce.useEffect(()=>(b(),()=>{p.current++}),[b]),mr(e,b);const x=Ce.useMemo(()=>c.filter(Qn).map($=>{const R=t.forSubGraph($.name),G=y!==null?y.get($.name)??0:$.entityCount;return{slug:$.name,icon:R.icon??"•",color:R.color??"#64748b",displayName:R.displayName??$.name,description:R.description??$.description,rank:R.rank??99,entityCount:G,tripleCount:$.tripleCount,layerScoped:y!==null}}).sort(($,R)=>$.rank-R.rank),[c,t,y]),N=m!==null&&m>0||n===Ve;if(g&&x.length===0&&!N||x.length===0&&!N)return null;const j=w??x.reduce(($,R)=>$+R.entityCount,0),_=x.reduce(($,R)=>$+R.tripleCount,0),z={working:"Working Memory",shared:"Shared Working Memory",verified:"Verifiable Memory"},E=v?[...v].map($=>z[$]).join(" + "):null,T=E?` in ${E}`:"",O=`Total distinct entities — includes those in named subgraphs (some may belong to more than one), plus Root entities not in any subgraph · ${j} entities${T}${E?"":` · ${l??_} triples`}`,Z=`All — total distinct entities. Includes those in named subgraphs (some may belong to more than one), plus Root entities not in any subgraph. ${j} entities${T}.`;return s.jsxs("div",{className:"v10-subgraph-bar",children:[s.jsx("div",{className:"v10-subgraph-bar-label",children:"Subgraphs"}),s.jsxs("button",{type:"button",className:`v10-subgraph-chip${n===null?" active":""}`,onClick:()=>r(null),title:O,"aria-label":Z,children:[s.jsx("span",{className:"v10-subgraph-chip-icon",children:"⊚"}),s.jsx("span",{className:"v10-subgraph-chip-label",children:"All"}),s.jsx("span",{className:"v10-subgraph-chip-count",children:j})]}),x.map($=>{const R=u.get($.slug);return s.jsxs("button",{type:"button",className:`v10-subgraph-chip${n===$.slug?" active":""}${R?" has-badge":""}`,onClick:()=>r($.slug,a),title:`${$.displayName}${$.description?" · "+$.description:""} · ${$.entityCount} entities${T}${E?"":` · ${$.tripleCount} triples`}${R?" · "+R.label:""}`,style:{"--sg-color":$.color},children:[s.jsx("span",{className:"v10-subgraph-chip-icon",style:{color:$.color},children:$.icon}),s.jsx("span",{className:"v10-subgraph-chip-label",children:$.displayName}),s.jsx("span",{className:"v10-subgraph-chip-count",children:$.entityCount}),R&&s.jsxs("span",{className:`v10-subgraph-chip-badge tone-${R.tone}`,children:[s.jsx("span",{className:"v10-subgraph-chip-badge-dot"}),R.label]})]},$.slug)}),N&&(()=>{const $=m??0,R=n===Ve;return s.jsxs("button",{type:"button",className:`v10-subgraph-chip v10-subgraph-chip-root${R?" active":""}`,"data-active":R,"data-count":$,onClick:()=>r(Ve,a),title:`Entities not in any subgraph (Context Graph root) · ${$} entities${T}`,"aria-label":"Entities not in any subgraph (Context Graph root)",children:[s.jsx("span",{className:"v10-subgraph-chip-icon",children:"⊘"}),s.jsx("span",{className:"v10-subgraph-chip-label",children:"Root"}),s.jsx("span",{className:"v10-subgraph-chip-count",children:$})]})})()]})},Kn=f.lazy(()=>zi(()=>import("./index-CfVUpsfM.js").then(e=>e.h),__vite__mapDeps([0,1,2,3])).then(e=>({default:e.RdfGraph}))),Ba="http://www.w3.org/1999/02/22-rdf-syntax-ns#type",Wa=new Map(Fi.map((e,t)=>[e,t]));function In(e){const t=e.trim();return!t||t.startsWith('"')?!1:t.startsWith("_:")||t.startsWith("<")&&t.endsWith(">")?!0:/\s/.test(t)?!1:/^[A-Za-z][A-Za-z0-9+.-]*:/.test(t)}function Qe(e){const t=e.trim();return t.startsWith("<")&&t.endsWith(">")?t.slice(1,-1):t}function Va(e){const t=new Set,n=new Map,r=new Map,i=new Map;for(const l of e){const c=Qe(l.subject);t.add(c);const d=Wa.get(l.predicate);if(d!==void 0){const h=vr(l.object).trim();if(h){const u=i.get(c);(u===void 0||d<u)&&(r.set(c,h),i.set(c,d))}}if(Qe(l.predicate)===Ba||!In(l.object))continue;const g=Qe(l.object);n.set(c,(n.get(c)??0)+1),n.set(g,(n.get(g)??0)+1)}const a=[...t].filter(l=>(n.get(l)??0)===0).map(l=>({uri:l,label:r.get(l)??gr(void 0,l)})).sort((l,c)=>l.label.localeCompare(c.label));if(a.length===0)return{canvasTriples:e,singletonItems:a};const o=new Set(a.map(l=>l.uri));return{canvasTriples:e.filter(l=>!o.has(Qe(l.subject))&&!o.has(Qe(l.object))),singletonItems:a}}function Qa(e){return e==="wm"?"Working Memory graph: local entities connected by entity-to-entity triples from loaded layer data.":e==="swm"?"Shared Working Memory graph: promoted shared entities connected by entity-to-entity triples from loaded layer data.":"Verifiable Memory graph: published knowledge assets, provenance anchors, and connected entity-to-entity triples from loaded layer data."}function Ka({items:e,onSelect:t}){return e.length===0?null:s.jsxs("div",{className:"v10-graph-singleton-shelf","aria-label":"Standalone entities without visible links",children:[s.jsxs("div",{className:"v10-graph-singleton-head",title:"Entities with no visible links are grouped here to keep the graph readable.",children:[s.jsx("span",{children:"Standalone entities"}),s.jsx("span",{children:e.length})]}),s.jsx("div",{className:"v10-graph-singleton-list",children:e.map(({uri:n,label:r})=>s.jsx("button",{type:"button",className:"v10-graph-singleton-item",title:n,onClick:()=>t==null?void 0:t(n),children:r},n))})]})}const Ja=2500;function ys(e,t=Ja){if(e.length<=t)return e;const n=new Map;for(const o of e)n.set(o.subject,(n.get(o.subject)??0)+1);const r=[...n.entries()].sort((o,l)=>l[1]-o[1]).map(([o])=>o),i=new Set;let a=0;for(const o of r){const l=n.get(o)??0;a+l>t||(i.add(o),a+=l)}return i.size===0&&r.length>0&&i.add(r[0]),e.filter(o=>i.has(o.subject)).slice(0,t)}function Qt({title:e,scopeLabel:t,tone:n,className:r,rail:i,overlay:a,showScopeLabel:o=!0,singletonItems:l=[],onSingletonClick:c,renderGraph:d}){const[g,h]=f.useState(!1);f.useEffect(()=>{if(!g)return;const v=y=>{y.key==="Escape"&&h(!1)};return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[g]);const u=s.jsx("button",{type:"button",className:`v10-graph-expand-btn${o?"":" in-canvas"}`,onClick:()=>h(!0),title:`Expand ${e}`,"aria-label":`Expand ${e}`,children:"⤢"}),p=v=>s.jsxs(s.Fragment,{children:[o&&!v&&s.jsxs("div",{className:"v10-graph-shell-bar",children:[s.jsx("div",{className:"v10-graph-scope",title:t,children:t}),u]}),s.jsxs("div",{className:"v10-graph-body",children:[s.jsxs("div",{className:"v10-graph-canvas",children:[!o&&!v&&u,s.jsx("div",{className:"v10-graph-view",children:d(v)}),a&&s.jsx("div",{className:"v10-graph-overlay",children:a}),s.jsx(Ka,{items:l,onSelect:c})]}),i&&s.jsx("aside",{className:"v10-graph-rail",children:i})]})]});return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:`v10-graph-shell v10-graph-shell-${n}${r?` ${r}`:""}`,children:!g&&p(!1)}),g&&s.jsx("div",{className:"v10-graph-expanded-backdrop",role:"dialog","aria-modal":"true","aria-label":`${e} expanded`,onClick:v=>{v.target===v.currentTarget&&h(!1)},children:s.jsxs("div",{className:`v10-graph-expanded-panel v10-graph-shell-${n}`,children:[s.jsxs("div",{className:"v10-graph-expanded-head",children:[s.jsxs("div",{children:[s.jsx("div",{className:"v10-graph-expanded-title",children:e}),s.jsx("div",{className:"v10-graph-expanded-subtitle",children:t})]}),s.jsx("button",{type:"button",className:"v10-graph-expanded-close",onClick:()=>h(!1),"aria-label":`Close expanded ${e}`,children:"×"})]}),s.jsx("div",{className:"v10-graph-expanded-body",children:p(!0)})]})})]})}function $r({layer:e,triples:t,onNodeClick:n,contextGraphId:r,scopeLabel:i,trustLegendActiveLayer:a,title:o,scopeEntities:l,swmAttribution:c,layerEntities:d,nodeColorsOverride:g}){const{title:h}=Oe[e],u=o??h,p=fr(M=>M.theme),v=f.useMemo(()=>{if(e!=="vm")return;const M=new Set;for(const F of t)M.add(F.subject),In(F.object)&&M.add(F.object);return M},[t,e]),{anchors:y,decorationTriples:w}=Li(e==="vm"&&r?r:void 0,v),m=Cr(e==="swm"&&r&&!c?r:void 0),b=c??m,x=f.useMemo(()=>{if(!d||d.length===0)return t;const M=new Set;for(const F of d)M.add(De(F.uri));return Ht(t,M)},[t,d]),k=f.useMemo(()=>{const M=new Set,F=[],B=J=>{const X=`${J.subject}|${J.predicate}|${J.object}`;M.has(X)||(M.add(X),F.push({subject:J.subject,predicate:J.predicate,object:J.object}))};for(const J of x)B(J);for(const J of w)B(J);return F},[x,w]),N=k,j=f.useMemo(()=>{const M=e==="swm"?b.nodeColors:void 0;if(!(!M&&!g))return M?g?{...M,...g}:M:g},[e,b.nodeColors,g]),_=f.useMemo(()=>Mi(e,j),[e,j]),{canvasTriples:z,singletonItems:E}=f.useMemo(()=>Va(N),[N]),T=f.useMemo(()=>{if(!l||l.length===0)return E;const M=new Set(E.map(B=>Qe(B.uri)));for(const B of z)M.add(Qe(B.subject)),In(B.object)&&M.add(Qe(B.object));const F=[];for(const B of l){const J=Qe(B.uri);M.has(J)||(M.add(J),F.push({uri:J,label:B.label||gr(void 0,J)}))}return F.length===0?E:[...E,...F].sort((B,J)=>B.label.localeCompare(J.label))},[E,z,l]),C=`${r??"context"}:${e}`,O=e==="swm"&&!!r&&b.loading,Z=`${u} graph`,$=i??Qa(e),R=a===null&&!!i,G=a===null?void 0:a??e,L=e==="vm"&&y.length>0||e==="swm"&&b.palette.length>0?s.jsxs(s.Fragment,{children:[e==="vm"&&y.length>0&&s.jsx(Ya,{anchors:y}),e==="swm"&&b.palette.length>0&&s.jsx(Ha,{palette:b.palette,conflicts:b.conflicts.length})]}):null,A=f.useMemo(()=>({name:`${C}:${p}`,palette:p}),[C,p]);return k.length===0&&T.length===0?s.jsx(Qt,{title:Z,scopeLabel:$,tone:e,className:"v10-graph-view-fill",showScopeLabel:R,renderGraph:()=>s.jsx("div",{className:"v10-layer-empty-shell",children:s.jsx(xe,{compact:!0,tone:At(e),icon:Oe[e].icon,title:`No triples in ${u}`,description:"The graph will appear when this layer has connected triples."})})}):O?s.jsx(Qt,{title:Z,scopeLabel:$,tone:"swm",className:"v10-graph-view-fill",showScopeLabel:R,renderGraph:()=>s.jsx("div",{className:"v10-layer-empty-shell",children:s.jsx(xe,{compact:!0,tone:"swm",icon:Oe.swm.icon,title:"Loading Shared Working Memory attribution...",description:"Agent colors are being prepared before the graph renders."})})}):s.jsx(Qt,{title:Z,scopeLabel:$,tone:e,className:"v10-graph-view-fill",overlay:L,showScopeLabel:R,singletonItems:T,onSingletonClick:M=>n==null?void 0:n(G?{id:M,trustLayer:G}:{id:M}),renderGraph:M=>z.length>0?s.jsx(f.Suspense,{fallback:s.jsx("span",{className:"v10-graph-placeholder",children:"Loading graph..."}),children:s.jsx(Kn,{data:z,format:"triples",options:_,viewConfig:A,style:{position:"absolute",inset:0,width:"100%",height:"100%"},onNodeClick:G?F=>n==null?void 0:n({...F,trustLayer:G}):n,initialFit:!0},`${C}:${M?"expanded":"inline"}:${z.length}`)}):s.jsx("div",{className:"v10-graph-placeholder v10-graph-placeholder-centered",children:"Connected graph appears when this layer has linked entities."})})}function Ha({palette:e,conflicts:t}){return s.jsxs("div",{className:"v10-swm-legend","aria-label":"SWM attribution legend",children:[s.jsxs("div",{className:"v10-swm-legend-row v10-swm-legend-head",children:[s.jsx("span",{children:"SWM attribution"}),s.jsxs("span",{className:"v10-swm-legend-count",children:[e.length," agent",e.length===1?"":"s"]})]}),e.slice(0,8).map(n=>s.jsxs("div",{className:"v10-swm-legend-row",title:n.agent,children:[s.jsx("span",{className:"v10-swm-legend-swatch",style:{background:n.color}}),s.jsx("span",{className:"v10-swm-legend-label",children:n.label}),s.jsx("span",{className:"v10-swm-legend-metric",children:n.entityCount})]},n.agent)),t>0&&s.jsxs("div",{className:"v10-swm-legend-row v10-swm-legend-conflict",children:[s.jsx("span",{className:"v10-swm-legend-swatch",style:{background:"#f59e0b"},children:"!"}),s.jsx("span",{className:"v10-swm-legend-label",children:"In review"}),s.jsx("span",{className:"v10-swm-legend-metric",children:t})]})]})}function Ya({anchors:e}){var i;const t=f.useMemo(()=>{const a=new Set;for(const o of e)for(const l of o.agents)a.add(l);return a.size},[e]),n=(i=e[0])==null?void 0:i.publishedAt,r=(()=>{if(!n)return null;try{return new Date(n).toLocaleString(void 0,{month:"short",day:"2-digit",hour:"2-digit",minute:"2-digit"})}catch{return null}})();return s.jsxs("div",{className:"v10-vm-legend","aria-label":"Verifiable Memory legend",children:[s.jsxs("div",{className:"v10-vm-legend-row v10-vm-legend-head",children:[s.jsx("span",{children:"VM provenance layer"}),s.jsxs("span",{className:"v10-vm-legend-count",children:[e.length," anchor",e.length===1?"":"s"]})]}),s.jsxs("div",{className:"v10-vm-legend-row",children:[s.jsx("span",{className:"v10-vm-legend-swatch",style:{background:"#f5a524"},children:"◉"}),s.jsx("span",{className:"v10-vm-legend-label",children:"On-chain anchor"})]}),s.jsxs("div",{className:"v10-vm-legend-row",children:[s.jsx("span",{className:"v10-vm-legend-swatch",style:{background:"#c084fc"},children:"◈"}),s.jsxs("span",{className:"v10-vm-legend-label",children:["Agent identity (",t,")"]})]}),s.jsxs("div",{className:"v10-vm-legend-row",children:[s.jsx("span",{className:"v10-vm-legend-swatch",style:{background:"#4ade80"},children:"—"}),s.jsx("span",{className:"v10-vm-legend-label",children:"Signed / anchored edge"})]}),r&&s.jsxs("div",{className:"v10-vm-legend-foot",children:["Latest: ",r]})]})}function Xa({active:e,counts:t,onSwitch:n,onShare:r,onImport:i,onRefresh:a}){const[o,l]=f.useState(!1),c=f.useRef(null),d=g=>{l(!1),n(g)};return f.useEffect(()=>{if(!o)return;const g=h=>{var p;const u=h.target;u&&((p=c.current)!=null&&p.contains(u))||l(!1)};return document.addEventListener("pointerdown",g),()=>document.removeEventListener("pointerdown",g)},[o]),s.jsxs("div",{className:"v10-layer-switcher",children:[s.jsxs("button",{className:`v10-layer-switch-btn ${e==="overview"?"active":""}`,"data-layer":"overview","aria-label":"Overview",title:"Overview",onClick:()=>d("overview"),children:[s.jsx("span",{className:"v10-layer-switch-icon",children:"◎"}),s.jsx("span",{className:"v10-layer-switch-label",children:"Overview"})]}),s.jsx("span",{className:"v10-layer-switch-separator","aria-hidden":"true"}),s.jsxs("button",{className:`v10-layer-switch-btn ${e==="wm"?"active":""}`,"data-layer":"wm","aria-label":"Working Memory",title:"Working Memory",onClick:()=>d("wm"),children:[s.jsx("span",{className:"v10-layer-switch-icon",style:{color:"#64748b"},children:"◇"}),s.jsx("span",{className:"v10-layer-switch-label v10-layer-switch-label-full",children:"Working Memory"}),s.jsx("span",{className:"v10-layer-switch-label v10-layer-switch-label-compact",children:"WM"}),t.wm>0&&s.jsx("span",{className:"v10-layer-switch-count",children:t.wm})]}),s.jsxs("button",{className:`v10-layer-switch-btn ${e==="swm"?"active":""}`,"data-layer":"swm","aria-label":"Shared Working Memory",title:"Shared Working Memory",onClick:()=>d("swm"),children:[s.jsx("span",{className:"v10-layer-switch-icon",style:{color:"#f59e0b"},children:"◈"}),s.jsx("span",{className:"v10-layer-switch-label v10-layer-switch-label-full",children:"Shared Working Memory"}),s.jsx("span",{className:"v10-layer-switch-label v10-layer-switch-label-compact",children:"SWM"}),t.swm>0&&s.jsx("span",{className:"v10-layer-switch-count",children:t.swm})]}),s.jsxs("button",{className:`v10-layer-switch-btn ${e==="vm"?"active":""}`,"data-layer":"vm","aria-label":"Verifiable Memory",title:"Verifiable Memory",onClick:()=>d("vm"),children:[s.jsx("span",{className:"v10-layer-switch-icon",style:{color:"#22c55e"},children:"◉"}),s.jsx("span",{className:"v10-layer-switch-label v10-layer-switch-label-full",children:"Verifiable Memory"}),s.jsx("span",{className:"v10-layer-switch-label v10-layer-switch-label-compact",children:"VM"}),t.vm>0&&s.jsx("span",{className:"v10-layer-switch-count",children:t.vm})]}),s.jsx("span",{className:"v10-layer-switch-separator","aria-hidden":"true"}),s.jsxs("button",{className:`v10-layer-switch-btn ${e==="graph-overview"?"active":""}`,"data-layer":"graph-overview","aria-label":"Subgraphs",title:"Subgraphs",onClick:()=>d("graph-overview"),children:[s.jsx("span",{className:"v10-layer-switch-icon",children:"⌬"}),s.jsx("span",{className:"v10-layer-switch-label",children:"Subgraphs"})]}),s.jsxs("div",{ref:c,className:"v10-layer-more",onBlur:g=>{g.currentTarget.contains(g.relatedTarget)||l(!1)},children:[s.jsxs("button",{type:"button",className:`v10-layer-switch-btn v10-layer-more-btn ${e==="query"?"active":""}`,"data-layer":"query","aria-haspopup":"menu","aria-expanded":o,"aria-label":"More Context Graph views",title:"More Context Graph views",onClick:()=>l(g=>!g),children:[s.jsx("span",{className:"v10-layer-switch-icon",children:"⋯"}),s.jsx("span",{className:"v10-layer-switch-label",children:"More"})]}),o&&s.jsx("div",{className:"v10-layer-more-menu",role:"menu",children:s.jsxs("button",{type:"button",role:"menuitem",className:`v10-layer-more-item ${e==="query"?"active":""}`,onClick:()=>d("query"),children:[s.jsx("span",{className:"v10-layer-switch-icon",children:"⟐"}),"Query Catalogue"]})})]}),s.jsx("div",{className:"v10-layer-switcher-spacer"}),s.jsxs("div",{className:"v10-layer-switcher-actions",children:[s.jsxs("button",{className:"v10-layer-action-btn",onClick:r,"aria-label":"Share Context Graph",children:[s.jsx("span",{className:"v10-layer-action-icon",children:"⤴"}),s.jsx("span",{className:"v10-layer-action-label",children:"Share"})]}),s.jsxs("button",{className:"v10-layer-action-btn",onClick:i,"aria-label":"Import into Context Graph",children:[s.jsx("span",{className:"v10-layer-action-icon",children:"↑"}),s.jsx("span",{className:"v10-layer-action-label",children:"Import"})]}),s.jsx("button",{className:"v10-layer-action-btn",onClick:a,"aria-label":"Refresh Context Graph data",children:s.jsx("span",{className:"v10-layer-action-icon",children:"↻"})})]})]})}function eo({cg:e,profile:t,activeSubGraph:n,onClearSubGraph:r}){const i=e.name||t.displayName||e.id;return s.jsxs("div",{className:"v10-project-strip",style:{"--sg-color":(n==null?void 0:n.color)??t.primaryColor},children:[s.jsx("span",{className:"v10-project-strip-dot",style:{background:t.primaryColor}}),s.jsx("button",{type:"button",className:"v10-project-strip-name",onClick:n?r:void 0,disabled:!n,title:n?"Back to context graph overview":e.id,children:i}),n?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"v10-project-strip-sep",children:"›"}),s.jsxs("span",{className:"v10-project-strip-sg",children:[s.jsx("span",{className:"v10-project-strip-sg-icon",style:{color:n.color},children:n.icon??"•"}),n.displayName??n.slug]}),n.description&&s.jsx("span",{className:"v10-project-strip-desc",title:n.description,children:n.description})]}):e.description&&s.jsx("span",{className:"v10-project-strip-desc",title:e.description,children:e.description})]})}function to(e,t,n,r,i){const a=typeof(e==null?void 0:e.curator)=="string"?e.curator.trim():"",o=new Set([t==null?void 0:t.agentDid,t==null?void 0:t.agentAddress].filter(d=>typeof d=="string"&&d.trim().length>0).map(Ie)),l=o.size>0;return a&&l&&o.has(Ie(a))?{label:"Curator",title:"This agent is the curator for this Context Graph.",tone:"curator"}:(e==null?void 0:e.callerInvolved)===!0?a&&!l&&n==="loading"?{label:"Role checking",title:"This agent is involved in this Context Graph; curator status is still loading.",tone:"unknown"}:a&&!l&&n==="error"?{label:"Role unknown",title:"This agent is involved in this Context Graph, but curator status could not be confirmed.",tone:"unknown"}:{label:"Joined",title:"This agent is involved in this Context Graph; curator status is shown only when identity metadata confirms it.",tone:"participant"}:(e==null?void 0:e.callerInvolved)===!1?{label:"Not joined",title:"This agent is not listed as curator or participant for this Context Graph.",tone:"viewer"}:i==="ok"&&r.map(d=>d.trim()).filter(Boolean).some(d=>o.has(Ie(d)))?{label:"Joined",title:"This agent is listed as a participant for this Context Graph.",tone:"participant"}:{label:"Role unknown",title:"The node did not provide enough role metadata for this Context Graph.",tone:"unknown"}}function no(e,t,n){if(Gn(e==null?void 0:e.accessPolicy)==="public")return{id:"participants",value:"Open",label:"Public access",tooltip:"Public Context Graphs do not have an authoritative allowlist count."};if(n==="loading")return{id:"participants",value:"...",label:"Agents with access",tooltip:"Participant list is loading."};if(n==="error")return{id:"participants",value:"Unavailable",label:"Agents with access",tooltip:"Participant list unavailable; access count is unknown."};const i=new Set(t.map(o=>o.trim()).filter(Boolean).map(Ie)),a=typeof(e==null?void 0:e.curator)=="string"?e.curator.trim():"";return a&&i.add(Ie(a)),{id:"participants",value:i.size.toLocaleString(),label:"Agents with access",tooltip:"Includes the curator plus allowlisted participants reported by the node."}}function so(e){const t=Gn(e);return t==="public"?{label:"Public",title:"Public Context Graph.",tone:"public"}:t==="private"?{label:"Curated",title:"Curated Context Graph with access controlled by the curator.",tone:"curated"}:{label:"Access unknown",title:"The node did not provide an access policy for this Context Graph.",tone:"unknown"}}function ro({cg:e,currentAgent:t,currentAgentStatus:n="ok"}){var l,c;const r=typeof(e==null?void 0:e.curator)=="string"?e.curator.trim():"";if(!r)return"unknown";const i=((l=t==null?void 0:t.agentDid)==null?void 0:l.trim())??"",a=((c=t==null?void 0:t.agentAddress)==null?void 0:c.trim())??"",o=i||a;return o?Ie(r)===Ie(o)?"curator":"not-curator":"unknown"}function io(e){return new Set([e==null?void 0:e.agentDid,e==null?void 0:e.agentAddress].filter(t=>typeof t=="string"&&t.trim().length>0).map(Ie))}function ao({cg:e,memory:t,subGraphCount:n,subGraphFetchFailed:r=!1,participants:i,participantsStatus:a="ok",currentAgent:o,currentAgentStatus:l="ok",onSwitchLayer:c,onOpenPrimer:d}){var A,M,F;const{wm:g,swm:h,vm:u}=t.counts,p=g+h+u,v=to(e,o??null,l,i,a),y=so(e==null?void 0:e.accessPolicy),w=no(e,i,a),m=typeof(e==null?void 0:e.curator)=="string"?e.curator.trim():"",b=m?Ie(m):"",x=Gn(e==null?void 0:e.accessPolicy)==="public",k=io(o??null),N=Object.values(t.layerStatus??{}),j=N.filter(B=>B==="error").length,_=!t.loading&&N.length===3&&j===3,z=!t.loading&&j>0,E=t.loading?"Loading memory layers...":_||t.error?"Live memory counts are unavailable.":t.partial||z?"One or more layer counts are currently a lower bound.":"Canonical current-layer entity counts.",T=_?"Unavailable":p.toLocaleString(),{total:C}=Bn(t),O=!t.loading&&(t.partial||z),Z=_?"Unavailable":t.loading&&C===0?"...":O?`${C.toLocaleString()}+`:C.toLocaleString(),$=_?"Live triple counts are unavailable.":O?"One or more layer triple counts are currently a lower bound.":"Canonical triple total across all layers.",R=n==null?r?"Unavailable":"...":n.toLocaleString(),G=n==null?r?"Sub-graph list is currently unavailable.":"Sub-graph count is loading.":"Topical partitions inside this Context Graph.",P=[{key:"wm",label:"Working Memory",desc:"Private staging area",count:g,status:((A=t.layerStatus)==null?void 0:A.wm)??"ok",color:"#64748b"},{key:"swm",label:"Shared Working Memory",desc:"Collaborative review",count:h,status:((M=t.layerStatus)==null?void 0:M.swm)??"ok",color:"#f59e0b"},{key:"vm",label:"Verifiable Memory",desc:"Published on-chain",count:u,status:((F=t.layerStatus)==null?void 0:F.vm)??"ok",color:"#22c55e"}],L=P.some(B=>B.status==="error");return s.jsxs("div",{className:"v10-po",children:[s.jsxs("div",{className:"v10-po-identity","data-section":"identity",children:[s.jsxs("div",{className:"v10-po-identity-pairs",children:[s.jsxs("div",{className:"v10-po-identity-pair",children:[s.jsx("span",{className:"v10-po-identity-label",children:"Your role:"}),s.jsx("span",{className:"v10-po-badge","data-role":v.tone,title:v.title,children:v.label})]}),s.jsxs("div",{className:"v10-po-identity-pair",children:[s.jsx("span",{className:"v10-po-identity-label",children:"Context Graph:"}),s.jsx("span",{className:"v10-po-badge","data-cg-type":y.tone,title:y.title,children:y.label})]})]}),d&&s.jsx("button",{type:"button",className:"v10-po-identity-primer",onClick:d,title:"Open the Context Graph primer",children:"What is a Context Graph?"})]}),s.jsxs("div",{"data-section":"at-a-glance",className:"v10-po-stat-block",children:[s.jsx("div",{className:"v10-po-section-title",children:"At a glance"}),s.jsx(pn,{className:"v10-po-stat-strip",items:[{id:"entities",value:T,label:"Entities",tooltip:E},{id:"triples",value:Z,label:"Triples",tooltip:$},{id:"subgraphs",value:R,label:"Subgraphs",tooltip:G},w]})]}),s.jsxs("div",{className:"v10-po-pipeline","data-section":"pipeline","aria-label":"Knowledge Pipeline",children:[s.jsx("div",{className:"v10-po-pipeline-head",children:s.jsxs("div",{children:[s.jsx("div",{className:"v10-po-section-title",children:"Knowledge Pipeline"}),s.jsx("div",{className:"v10-po-section-desc",children:"Entities move from private staging to shared review; published assertion bundles become Knowledge Assets with on-chain provenance."})]})}),s.jsx("div",{className:"v10-po-pipeline-track","aria-hidden":"true",children:!L&&p>0?P.map(B=>{const J=B.count>0?B.count/p*100:0;return s.jsx("span",{className:`v10-po-pipeline-seg ${B.key}`,style:{width:`${J}%`,background:B.color}},B.key)}):s.jsx("span",{className:"v10-po-pipeline-empty"})}),s.jsx("div",{className:"v10-po-pipeline-steps",children:P.map((B,J)=>s.jsxs("button",{type:"button",className:`v10-po-pipeline-step ${B.key}`,onClick:()=>c==null?void 0:c(B.key),style:{"--po-layer-color":B.color},children:[s.jsx("span",{className:"v10-po-pipeline-step-index",children:J+1}),s.jsxs("span",{className:"v10-po-pipeline-step-copy",children:[s.jsx("span",{className:"v10-po-pipeline-step-label",children:B.label}),s.jsx("span",{className:"v10-po-pipeline-step-desc",children:B.desc})]}),s.jsx("span",{className:"v10-po-pipeline-step-count",children:B.status==="error"?"Unavailable":`${B.count.toLocaleString()} ${We(B.key,B.count)}`})]},B.key))})]}),s.jsxs("div",{className:"v10-po-people","data-section":"participants",children:[s.jsx("div",{className:"v10-po-section-title",children:"Participant agents"}),(()=>{const B="did:dkg:agent:",J=V=>V.toLowerCase().startsWith(B)?V.slice(B.length):V,X=new Set,Y=[];if(m&&a==="ok"){const V=Ie(m);X.add(V),Y.push({display:J(m),full:m,canonical:V})}if(a==="ok")for(const V of i){const re=Ie(V);X.has(re)||(X.add(re),Y.push({display:J(V),full:V,canonical:re}))}if(Y.length===0){const V=x?"This Context Graph is public — anyone can subscribe.":a==="loading"?"Loading participant agents...":a==="error"?"Participant list unavailable.":"No participant agents recorded yet.";return s.jsx("div",{className:"v10-po-people-empty",children:V})}return s.jsx("div",{className:"v10-po-participants-list",children:Y.map(({display:V,full:re,canonical:ye})=>{const Ne=k.has(ye),Re=!!b&&ye===b,q=`${V.slice(0,6)}…${V.slice(-4)}`,ne=[q];return Ne&&ne.push("you"),Re&&ne.push("curator"),s.jsxs("span",{className:`v10-po-participant${Ne?" is-self":""}${Re?" is-curator":""}`,title:re,"aria-label":ne.join(" "),children:[s.jsx("span",{className:"v10-po-participant-name",children:q}),Ne&&s.jsx("span",{className:"v10-po-participant-tag",children:"you"}),Re&&s.jsx("span",{className:"v10-po-participant-tag",children:"curator"})]},ye)})})})()]})]})}function oo({contextGraphId:e,curatorStatus:t,onParticipantsChanged:n}){const[r,i]=f.useState([]),[a,o]=f.useState(null),[l,c]=f.useState("loading"),d=f.useRef(0),g=f.useCallback(()=>{if(t!=="curator"){i([]),c("idle");return}const p=++d.current;c("loading"),dr(e).then(v=>{d.current===p&&(i(v.requests.filter(y=>y.status==="pending")),c("idle"))}).catch(()=>{d.current===p&&(i([]),c("error"))})},[e,t]);if(f.useEffect(()=>(g(),()=>{d.current++}),[g]),Ui(f.useCallback(p=>{var v;p.type!=="join_request"&&p.type!=="join_approved"&&p.type!=="join_rejected"||((v=p.data)==null?void 0:v.contextGraphId)===e&&g()},[e,g])),t==="not-curator")return null;if(t==="unknown")return s.jsxs("section",{className:"v10-po-join","data-section":"join-requests",children:[s.jsx("header",{className:"v10-po-join-head",children:s.jsx("span",{className:"v10-po-section-title",children:"Pending join requests"})}),s.jsx("div",{className:"v10-po-join-empty",children:"Verifying access…"})]});const h=async p=>{o(p);try{await pr(e,p),i(v=>v.filter(y=>y.agentAddress!==p)),n==null||n()}catch{}finally{o(null)}},u=async p=>{o(p);try{await hr(e,p),i(v=>v.filter(y=>y.agentAddress!==p)),n==null||n()}catch{}finally{o(null)}};return s.jsxs("section",{className:"v10-po-join","data-section":"join-requests",children:[s.jsxs("header",{className:"v10-po-join-head",children:[s.jsx("span",{className:"v10-po-section-title",children:"Pending join requests"}),s.jsx("span",{className:"v10-po-join-count","data-empty":r.length===0?"true":"false",children:r.length})]}),l==="loading"?s.jsx("div",{className:"v10-po-join-empty",children:"Loading join requests..."}):l==="error"?s.jsx("div",{className:"v10-po-join-empty",children:"Join requests are currently unavailable."}):r.length===0?s.jsx("div",{className:"v10-po-join-empty",children:"No pending join requests."}):s.jsx("div",{className:"v10-po-join-list",children:r.map(p=>s.jsxs("div",{className:"v10-po-join-item",children:[s.jsxs("div",{className:"v10-po-join-info",children:[s.jsx("span",{className:"v10-po-join-name",children:p.name||`${p.agentAddress.slice(0,6)}…${p.agentAddress.slice(-4)}`}),s.jsxs("span",{className:"v10-po-join-addr",title:p.agentAddress,children:[p.agentAddress.slice(0,10),"…"]})]}),s.jsxs("div",{className:"v10-po-join-actions",children:[s.jsx("button",{className:"v10-po-join-btn approve",onClick:()=>h(p.agentAddress),disabled:a===p.agentAddress,children:a===p.agentAddress?"…":"✓ Approve"}),s.jsx("button",{className:"v10-po-join-btn reject",onClick:()=>u(p.agentAddress),disabled:a===p.agentAddress,"aria-label":"Reject join request",children:"✕"})]})]},p.agentAddress))})]})}function lo({onOpenPrimer:e}){return s.jsxs("div",{className:"v10-po-primer-footer","data-section":"primer",children:[s.jsx("span",{className:"v10-po-primer-footer-lede",children:"New here?"}),s.jsx("span",{className:"v10-po-primer-footer-arrow","aria-hidden":"true",children:"→"}),s.jsx("button",{type:"button",className:"v10-po-primer-footer-link",onClick:e,children:"What is a Context Graph?"}),s.jsx("div",{className:"v10-po-primer-footer-sub",children:"A short primer on context graphs, the WM → SWM → VM pipeline, and how participant agents collaborate."})]})}const co=(e,t)=>!!e&&!!t&&e.toLowerCase()===t.toLowerCase();function uo(e,t=0){const n=br(o=>o.trackedIds),r=n.join(","),{data:i,loading:a}=ft(async()=>{if(n.length===0)return{wallets:[],ownerPublish:!1,resolved:!1};const o=await Di().catch(()=>null),l=(o==null?void 0:o.wallets)??[];let c=!1;try{const{contextGraphs:g}=await Zi(),h=(g??[]).find(p=>(p==null?void 0:p.id)===e),u=h==null?void 0:h.curator;if(u){const p=await qi().catch(()=>null);c=!!(p!=null&&p.agentDid&&Ie(u)===Ie(p.agentDid))}}catch{c=!1}return{wallets:await Promise.all(l.map(async g=>{var k;const h=(k=o==null?void 0:o.balances)==null?void 0:k.find(N=>co(N.address,g)),u=h==null,p=h!=null&&Number(h.eth)>0,v=h!=null&&Number(h.trac)>0;let y,w=!1,m=!1,b,x=!1;for(const N of n){const j=await cs(N,g,{extended:!0}).catch(()=>null);if(j===null){x=!0;continue}const _=us(j);if(_.outcome==="inconclusive"){x=!0;continue}if(_.outcome!=="unregistered"){if(_.outcome==="covers"){y={accountId:N,discountBps:j.discountBps,untracked:!1};break}_.dead&&(w=!0,b||(b=N)),_.hasBudget||(m=!0)}}if(!y&&!x&&!w&&!m){const N=await Gi(g).catch(()=>{});if(N===void 0)x=!0;else if(N.accountId!=null&&!n.includes(N.accountId)){const j=N.accountId,_=await cs(j,g,{extended:!0}).catch(()=>null);if(_===null)x=!0;else{const z=us(_);z.outcome==="covers"?y={accountId:j,discountBps:_.discountBps,untracked:!0}:z.outcome==="uncovered"?(z.dead&&(w=!0,b||(b=j)),z.hasBudget||(m=!0)):x=!0}}}return{wallet:g,covered:!!y,accountId:y==null?void 0:y.accountId,discountBps:y==null?void 0:y.discountBps,coverUntracked:(y==null?void 0:y.untracked)??!1,deadAccountId:y?void 0:b,inconclusive:!y&&x,balanceUnknown:u,gasFunded:p,hasTrac:v,sawExpired:w,sawInsolvent:m}})),ownerPublish:c,resolved:l.length>0}},[r,e],t);return f.useMemo(()=>{const o=(i==null?void 0:i.wallets)??[],l=(i==null?void 0:i.ownerPublish)??!1,c=(i==null?void 0:i.resolved)??!1;if(n.length===0||!c||o.length===0)return{verdict:"unknown",loading:a,ownerPublish:l,anyGasFunded:!1,reasons:[],conditions:{approved:!1,gasFunded:!1,notExpired:!1,solvent:!1},wallets:o};const d=o.filter(m=>m.covered),g=o.filter(m=>!m.covered),h=g.filter(m=>!m.inconclusive&&!m.balanceUnknown),u=g.filter(m=>m.inconclusive||m.balanceUnknown),p={approved:g.length===0,gasFunded:o.every(m=>m.gasFunded),notExpired:!o.some(m=>m.sawExpired),solvent:!o.some(m=>m.sawInsolvent)};let v;const y=[];if(g.length===0)d.some(m=>m.gasFunded||m.balanceUnknown)?v="eligible":(v="fallthrough-no-funds",y.push("every approved signing wallet is out of gas"));else if(h.length===0&&u.length>0)v="unknown";else{const m=o.some(b=>(b.covered||b.hasTrac)&&b.gasFunded);!m&&u.length>0?v="unknown":(v=m?"fallthrough":"fallthrough-no-funds",y.push(`${d.length} of ${o.length} signing wallets approved`),o.some(b=>b.sawExpired)&&y.push("a PCA has expired or been fully swept"),o.some(b=>b.sawInsolvent)&&y.push("a PCA is out of budget"),p.gasFunded||y.push("a signing wallet has no gas"),g.some(b=>b.inconclusive)&&y.push("a wallet’s PCA coverage couldn’t be checked"),g.some(b=>b.balanceUnknown)&&y.push("a signing wallet’s balance couldn’t be checked"))}const w=d.reduce((m,b)=>(b.discountBps??-1)>((m==null?void 0:m.discountBps)??-1)?b:m,void 0);return{verdict:v,loading:a,accountId:w==null?void 0:w.accountId,discountBps:w==null?void 0:w.discountBps,accountUntracked:w==null?void 0:w.coverUntracked,ownerPublish:l,anyGasFunded:o.some(m=>m.gasFunded||m.balanceUnknown),reasons:y,conditions:p,wallets:o}},[i,a,n.length])}function po(e){return e.verdict==="fallthrough-no-funds"&&!(e.ownerPublish&&e.anyGasFunded)}function ho(e){const t=br(o=>o.trackedIds),n=uo(e,3e4),r=po(n),i="Publish will fail — no signing wallet can fund it (coverage or gas).",a=t.length>0;return{blocked:r,reason:i,chipVisible:a,eligibility:n}}function mo({verdict:e,accountId:t,discountBps:n,accountUntracked:r,ownerPublish:i,id:a}){return s.jsx("div",{className:"v10-pca-publish-chip",id:a,"data-testid":"pca-publish-eligibility",children:s.jsx($a,{variant:"chip",verdict:e,accountId:t,discountBps:n,accountUntracked:r,ownerPublish:i})})}function Jn({title:e,agent:t,footnote:n,dismissed:r,onDismiss:i,children:a}){return s.jsxs("div",{className:`v10-gen-widget ${r?"dissolved":""}`,children:[s.jsxs("div",{className:"v10-gen-widget-header",children:[s.jsx("span",{className:"v10-gen-widget-title",children:e}),s.jsxs("div",{className:"v10-gen-widget-right",children:[t&&s.jsxs("span",{className:"v10-gen-widget-agent",children:[s.jsx("span",{className:"v10-gen-widget-agent-dot"}),t]}),i&&s.jsx("button",{className:"v10-gen-widget-dismiss",onClick:i,children:"✕"})]})]}),s.jsx("div",{className:"v10-gen-widget-body",children:a}),n&&s.jsx("div",{className:"v10-gen-widget-footnote",children:n})]})}function fo({entities:e}){const t=et(),n=f.useMemo(()=>{const r=new Map;for(const i of e){const{icon:a,type:o}=dn(i,t),l=r.get(o);l?l.count++:r.set(o,{icon:a,count:1})}return[...r.entries()].sort((i,a)=>a[1].count-i[1].count)},[e,t]);return n.length===0?null:s.jsx(Jn,{title:"Entity Types",children:s.jsx(pn,{compact:!0,items:n.map(([r,{icon:i,count:a}])=>({id:r,label:`${i} ${r}`,value:a}))})})}function go({entities:e,entityCount:t,triples:n,layer:r}){const i=f.useMemo(()=>e.filter(l=>l.properties.has("http://dkg.io/ontology/sourceContentType")).length,[e]),a=f.useMemo(()=>e.reduce((l,c)=>l+c.connections.length,0),[e]),o=e.length>0?(a/e.length).toFixed(1):"0";return s.jsx(Jn,{title:"Layer Stats",children:s.jsx(pn,{compact:!0,layer:r,items:[{id:"entities",label:We(r,t),value:t},{id:"triples",label:"Triples",value:n},{id:"connections",label:"Connections",value:a},{id:"avg",label:"Avg. connections / entity",value:o},...i>0?[{id:"documents",label:"Documents",value:i}]:[]]})})}function Er(e,t){const[n,r]=f.useState(!1),[i,a]=f.useState(null),[o,l]=f.useState(null),c=f.useCallback(async(d,g)=>{r(!0),l(null),a(null);try{const h=await d();a(h),e==null||e({ok:!0,text:h}),t==null||t()}catch(h){const u=g(h);l(u),e==null||e({ok:!1,text:u})}finally{r(!1)}},[e,t]);return{busy:n,result:i,error:o,run:c}}function _r({title:e,footnote:t,context:n,result:r,error:i,extras:a,children:o}){return s.jsxs(Jn,{title:e,footnote:t,children:[s.jsx("div",{className:"v10-decision-context",style:{marginBottom:10},children:n}),r&&s.jsxs("div",{"data-testid":"layer-action-result",style:{fontSize:11,color:"var(--text-success)",marginBottom:8},children:["✓ ",r]}),i&&s.jsxs("div",{"data-testid":"layer-action-error",style:{fontSize:11,color:"var(--text-danger)",marginBottom:8},children:["✕ ",i]}),a,s.jsx("div",{className:"v10-decision-actions",children:o})]})}function vo({count:e,contextGraphId:t,onComplete:n,onResult:r}){const{busy:i,result:a,error:o,run:l}=Er(r,n),c=f.useCallback(()=>{let h=null;l(async()=>{const u=await Yt(t,"wm");let p=0;for(const y of u)h=y.name,(await Xt(t,y.name,y.subGraph?{subGraphName:y.subGraph}:{})).promotedCount===0&&(p+=1);const v=u.length-p;if(v>0){const y=p>0?` (${p} already shared or still committing)`:"";return`Shared ${v} complete Knowledge Asset${v!==1?"s":""} to Shared Memory${y}`}return"No Knowledge Assets were newly shared — all were already in Shared Memory or still committing."},u=>{const p=en(h??"an assertion",u);return p?p.message:(u==null?void 0:u.message)??"Action failed"})},[t,l]);if(e===0)return null;const d="#f59e0b",g=We("wm",e).toLowerCase();return s.jsx(_r,{title:"Share complete Knowledge Assets",footnote:"Shares each complete owning Knowledge Asset atomically to Shared Working Memory.",context:s.jsxs(s.Fragment,{children:[e," eligible ",g," will be shared through their complete owning Knowledge Assets for collaborative review."]}),result:a,error:o,children:s.jsx("button",{"data-testid":"widget-promote-all-btn",className:"v10-decision-btn approve",style:{borderColor:`${d}50`,color:"var(--text-warning)",background:`${d}15`,opacity:i?.5:1},disabled:i,onClick:c,children:i?"...":"✓ Share Complete KAs → Shared"})})}function bo({count:e,contextGraphId:t,onComplete:n,onResult:r}){const[i,a]=f.useState(null),{busy:o,result:l,error:c,run:d}=Er(r,n),g=ho(t),h=f.useId(),u=f.useId(),p=[g.chipVisible?h:null,g.blocked?u:null].filter(Boolean).join(" ")||void 0,v=f.useCallback(()=>{g.blocked||d(async()=>{a(null);const w=await Yt(t,"swm"),m=await yr(t,w),b=xr(m),x=b?` — ⚠ ${b}`:"";if(m.published>0){const k=m.failures.length?` (${m.failures.length} assertion${m.failures.length===1?"":"s"} could not be published)`:"",N=m.partial>0?` — ⚠ ${m.partial}: ${tn(m.partialError)}`:"";return a(m.convictionCostCovered??null),`Published ${m.published} knowledge asset${m.published!==1?"s":""} to Verifiable Memory${k}${N}${x}`}if(w.length===0)return"Nothing to publish — promote assertions to Shared Memory first.";if(b&&m.failures.length===0)return`⚠ ${b}`;throw new Error(`${m.failures[0]?`${m.failures[0].name}: ${m.failures[0].error}`:"Publish failed"}${x}`)},w=>(w==null?void 0:w.message)??"Action failed")},[t,d,g.blocked]);if(e===0)return null;const y=We("swm",e).toLowerCase();return s.jsx(_r,{title:"Publish",footnote:`Moves ${y} from this layer to Verifiable Memory.`,context:s.jsxs(s.Fragment,{children:[e," ",y," in this layer can be published to Verifiable Memory on-chain."]}),result:l,error:c,extras:s.jsxs(s.Fragment,{children:[s.jsx(Bi,{convictionCostCovered:i}),g.chipVisible&&s.jsx(mo,{...g.eligibility,id:h}),g.blocked&&s.jsx("span",{id:u,className:"v10-sr-only",children:g.reason})]}),children:s.jsx("button",{"data-testid":"widget-publish-vm-btn",className:"v10-decision-btn primary-cta publish-vm",style:{opacity:o||g.blocked?.5:1},disabled:o,"aria-disabled":g.blocked||void 0,title:g.blocked?g.reason:void 0,"aria-describedby":p,onClick:v,children:o?"...":"◉ Publish to Verifiable Memory"})})}function yo({layer:e,entities:t,entityCount:n,actionEntityCount:r=n,tripleCount:i,contextGraphId:a,onComplete:o}){const[l,c]=f.useState(null),d=l&&s.jsxs("div",{"data-testid":l.ok?"layer-action-result":"layer-action-error",style:{fontSize:11,color:l.ok?"var(--text-success)":"var(--text-danger)",marginBottom:8},children:[l.ok?"✓":"✕"," ",l.text]});return n===0?s.jsxs("div",{className:"v10-layer-widgets-strip empty",children:[d,s.jsx(xe,{compact:!0,tone:At(e),icon:Oe[e].icon,title:`No ${We(e,2).toLowerCase()} yet`,description:e==="wm"?"Import data or chat with agents to populate Working Memory.":e==="swm"?"Seal and share complete Knowledge Assets from Working Memory with the team.":"Publish complete Knowledge Assets from Shared Working Memory to verify them on-chain."})]}):s.jsxs("div",{className:"v10-layer-widgets-strip",children:[s.jsxs("div",{className:"v10-layer-widgets-strip-stats",children:[s.jsx(go,{entities:t,entityCount:n,triples:i,layer:e}),s.jsx(fo,{entities:t})]}),(e==="wm"||e==="swm")&&a&&r>0&&s.jsx("div",{className:"v10-layer-widgets-strip-action",children:e==="wm"?s.jsx(vo,{count:r,contextGraphId:a,onComplete:o,onResult:c}):s.jsx(bo,{count:r,contextGraphId:a,onComplete:o,onResult:c})})]})}const xo={working:{layerKey:"wm",icon:"◇",label:"Working"},shared:{layerKey:"swm",icon:"◈",label:"Shared"},verified:{layerKey:"vm",icon:"◉",label:"Verifiable"}},jo=new Set(["http://dkg.io/ontology/profile/QueryCatalog","http://dkg.io/ontology/profile/SavedQuery"]);function wo(e){return e.types.some(t=>jo.has(t))}function Ar({entities:e,layerKey:t,layerIcon:n,onSelectEntity:r,onOpenAgent:i,externallySorted:a=!1,sortLabel:o,headerExtra:l,timestampPredicate:c,perEntityTrustBadge:d=!1}){const g=et(),h=It(),u=We(t,e.length).toLowerCase(),p=f.useMemo(()=>{if(a)return e;const w=[...e];return w.sort((m,b)=>{const x=m.tripleCount??0;return(b.tripleCount??0)-x}),w},[e,a]),v=t==="vm"?"Verifiable":t==="swm"?"Shared":"Working";if(e.length===0)return s.jsx("div",{className:"v10-entity-list empty",children:s.jsx(xe,{compact:!0,tone:At(t),icon:n,title:`No ${We(t,2).toLowerCase()} yet`,description:`This view will fill when matching ${We(t,2).toLowerCase()} are available.`})});const y=o??(a?"click to open":"sorted by triples · click to open");return s.jsxs("div",{className:"v10-entity-list",children:[s.jsxs("div",{className:"v10-entity-list-header",children:[s.jsxs("span",{className:"v10-entity-list-count",children:[p.length," ",u]}),s.jsx("span",{className:"v10-entity-list-hint",children:y}),l&&s.jsx("span",{className:"v10-entity-list-extra",children:l})]}),p.map(w=>{const{icon:m,type:b}=dn(w,g),x=w.tripleCount??0,k=Wn(w),N=k?h==null?void 0:h.get(k):null,j=c?Vt(w,c):null;return s.jsxs("div",{className:"v10-entity-card",onClick:_=>{_.stopPropagation(),r(w.uri)},children:[s.jsx("span",{className:"v10-entity-card-icon",children:m}),s.jsxs("div",{className:"v10-entity-card-main",children:[s.jsx("div",{className:"v10-entity-card-title",children:w.label}),s.jsxs("div",{className:"v10-entity-card-meta",children:[(N||k)&&s.jsx(gt,{agent:N??void 0,fallbackUri:k??void 0,size:"sm",onOpenAgent:i}),b&&b!=="Entity"&&s.jsxs("span",{className:"v10-entity-type-pill",children:[m," ",b]}),j!=null&&s.jsx("span",{className:"v10-entity-card-timestamp",title:new Date(j).toLocaleString(),children:Vi(j)}),s.jsxs("span",{className:"v10-entity-card-triples",children:[x," triples"]})]})]}),d?(()=>{const _=xo[w.trustLevel];return s.jsxs("span",{className:`v10-trust-badge ${_.layerKey}`,title:`${_.label} Memory`,children:[_.icon," ",_.label]})})():s.jsxs("span",{className:`v10-trust-badge ${t}`,children:[n," ",v]})]},w.uri)})]})}function ko({layer:e,entities:t,tripleCount:n,layerTriples:r,contextGraphId:i,memory:a,activeTab:o,onTabChange:l,onSelectEntity:c,onNodeClick:d,footer:g,swmAttribution:h,showQueryCatalog:u=!1,onShowQueryCatalogChange:p}){var _;const v=Oe[e],y=We(e,2),w=f.useMemo(()=>t.filter(z=>!wo(z)).length,[t]),m=((_=a.layerStatus)==null?void 0:_.vm)??(a.loading?"loading":a.error?"error":"ok"),b=e==="vm"&&m==="loading"&&t.length===0,x=e==="vm"&&m==="error"&&t.length===0,k=e==="vm"&&m==="ok"&&t.length===0,N=a.counts[e],j=z=>E=>{E.stopPropagation(),l(z)};return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"v10-layer-expand-tabs",children:[s.jsx("button",{className:`v10-layer-expand-tab ${o==="items"?"active":""}`,onClick:j("items"),children:y}),e!=="vm"&&s.jsx("button",{className:`v10-layer-expand-tab ${o==="assertions"?"active":""}`,onClick:j("assertions"),children:"Assertions"}),s.jsx("button",{className:`v10-layer-expand-tab ${o==="graph"?"active":""}`,onClick:j("graph"),children:"Graph"}),s.jsx("button",{className:`v10-layer-expand-tab ${o==="docs"?"active":""}`,onClick:j("docs"),children:"Documents"}),e!=="vm"&&p&&s.jsxs("label",{className:"v10-query-catalog-visibility",children:[s.jsx("input",{type:"checkbox",checked:u,onChange:z=>p(z.target.checked)}),s.jsx("span",{children:"Show query catalog"})]})]}),o==="items"&&s.jsxs("div",{className:"v10-layer-expand-body entities-tab","data-cg-scroll-key":`layer:${e}:items`,children:[e==="vm"&&!b&&!x&&s.jsx(No,{entities:t,tripleCount:n,contextGraphId:i}),b?s.jsx("div",{className:"v10-layer-widgets-strip empty",children:s.jsx(xe,{compact:!0,tone:"vm",icon:Oe.vm.icon,title:"Loading Verifiable Memory...",description:"Knowledge Assets are being read from the verified layer."})}):x?s.jsx("div",{className:"v10-layer-widgets-strip empty",children:s.jsx(xe,{compact:!0,tone:"vm",icon:Oe.vm.icon,title:"Verifiable Memory status unavailable.",description:"This node could not read the verified layer right now."})}):!k&&s.jsxs(s.Fragment,{children:[s.jsx(yo,{layer:e,entities:t,entityCount:N,actionEntityCount:w,tripleCount:n,contextGraphId:i,onComplete:a.refresh}),s.jsx(Ar,{entities:t,layerKey:e,layerIcon:v.icon,onSelectEntity:c})]}),g]}),o==="assertions"&&e!=="vm"&&s.jsx("div",{className:"v10-layer-expand-body full-width",children:s.jsx(So,{contextGraphId:i,layer:e,includeQueryCatalog:u,onComplete:a.refresh,scrollKey:`layer:${e}:assertions`})}),o==="graph"&&s.jsx("div",{className:"v10-layer-expand-body full-width","data-cg-scroll-key":`layer:${e}:graph`,children:s.jsx($r,{layer:e,triples:r,onNodeClick:d,contextGraphId:i,swmAttribution:e==="swm"?h:void 0,layerEntities:t})}),o==="docs"&&s.jsx("div",{className:"v10-layer-expand-body full-width",children:s.jsx(Tr,{entities:t,contextGraphId:i,scrollKey:`layer:${e}:docs`})})]})}function No({entities:e,tripleCount:t,contextGraphId:n}){const r=e.length,i=new Set;for(const o of e)for(const l of o.types)i.add(l);const a=i.size;return r===0?s.jsxs("div",{className:"v10-vm-hero v10-vm-hero-empty",children:[s.jsxs("div",{className:"v10-vm-hero-title",children:[s.jsx("span",{className:"v10-vm-hero-badge",children:"◉ Verifiable Memory"}),s.jsxs("div",{className:"v10-vm-hero-heading",children:[s.jsx("span",{className:"v10-vm-hero-headline",children:"Nothing published yet"}),s.jsxs("span",{className:"v10-vm-hero-context",title:n,children:["Context Graph: ",n]})]})]}),s.jsx(xe,{compact:!0,className:"v10-vm-empty-state",tone:"vm",icon:Oe.vm.icon,title:"No Knowledge Assets yet.",description:"Publish complete Knowledge Assets from Shared Working Memory to verify them on-chain."})]}):s.jsxs("div",{className:"v10-vm-hero",children:[s.jsxs("div",{className:"v10-vm-hero-title",children:[s.jsx("span",{className:"v10-vm-hero-badge",children:"◉ Verifiable Memory"}),s.jsxs("div",{className:"v10-vm-hero-heading",children:[s.jsx("span",{className:"v10-vm-hero-headline",children:"On-chain anchored · cryptographically signed"}),s.jsxs("span",{className:"v10-vm-hero-context",title:n,children:["Context Graph: ",n]})]})]}),s.jsx(pn,{className:"v10-vm-hero-stats",layer:"vm",items:[{id:"assets",value:r,label:"Knowledge Assets"},{id:"triples",value:t.toLocaleString(),label:"Verifiable Triples"},{id:"types",value:a,label:"Entity Types"}]}),s.jsxs("div",{className:"v10-vm-hero-strip",children:[s.jsxs("div",{className:"v10-vm-hero-chip",title:"Multi-agent endorsement",children:[s.jsx("span",{className:"v10-vm-hero-chip-dot",style:{background:"#22c55e"}}),"Consensus"]}),s.jsxs("div",{className:"v10-vm-hero-chip",title:"Published to the DKG blockchain anchor",children:[s.jsx("span",{className:"v10-vm-hero-chip-dot",style:{background:"#3b82f6"}}),"On-chain"]}),s.jsxs("div",{className:"v10-vm-hero-chip",title:"Each contribution bound to a DID",children:[s.jsx("span",{className:"v10-vm-hero-chip-dot",style:{background:"#a855f7"}}),"Agent Identity"]}),s.jsxs("div",{className:"v10-vm-hero-chip",title:"Tamper-evident via content hashing",children:[s.jsx("span",{className:"v10-vm-hero-chip-dot",style:{background:"#f59e0b"}}),"Content Hash"]})]})]})}function So({contextGraphId:e,layer:t,includeQueryCatalog:n=!1,onComplete:r,scrollKey:i}){const{data:a,loading:o,refresh:l}=ft(()=>Yt(e,t,{includeQueryCatalog:n}),[e,t,n],0),{data:c}=ft(()=>Ji(e),[e,t],0),[d,g]=f.useState(null),[h,u]=f.useState(null),[p,v]=f.useState(null),y=f.useCallback(async N=>{g(N.graphUri),u(null),v(null);try{if(t==="wm"){const j=await Xt(e,N.name,N.subGraph?{subGraphName:N.subGraph}:{}),_=jr(N.name,j);u(_.message)}else{const j=await wr(e,N.name,N.subGraph?{subGraphName:N.subGraph}:{});u(j.contextGraphError?`Published ${N.name} on-chain — ⚠ ${tn(j.contextGraphError)}`:`Published ${N.name} to Verifiable Memory`)}l(),r()}catch(j){const _=en(N.name,j);v(_?_.message:(j==null?void 0:j.message)??"Action failed")}finally{g(null)}},[e,t,l,r]),w=f.useCallback(async()=>{g("__all__"),u(null),v(null);let N=null;try{const j=await Yt(e,t);if(j.length===0){u(t==="wm"?"No user Knowledge Assets are ready to share.":"No user Knowledge Assets are ready to publish.");return}if(t==="wm"){let _=0;for(const E of j)N=E.name,(await Xt(e,E.name,E.subGraph?{subGraphName:E.subGraph}:{})).promotedCount===0&&(_+=1);const z=j.length-_;if(z>0){const E=_>0?` (${_} already shared or still committing)`:"";u(`Shared ${z} complete Knowledge Asset${z!==1?"s":""}${E}`)}else u("No Knowledge Assets were newly shared — all were already in Shared Memory or still committing.")}else{const _=await yr(e,j),z=xr(_),E=z?` — ⚠ ${z}`:"";if(_.published>0){const T=_.failures.length?` (${_.failures.length} could not be published)`:"",C=_.partial>0?` — ⚠ ${_.partial}: ${tn(_.partialError)}`:"";u(`Published ${_.published} knowledge asset${_.published!==1?"s":""} to Verifiable Memory${T}${C}${E}`)}else if(z&&_.failures.length===0)u(`⚠ ${z}`);else throw new Error(`${_.failures[0]?`${_.failures[0].name}: ${_.failures[0].error}`:"Publish failed"}${E}`)}l(),r()}catch(j){const _=en(N??"selected assertion",j);v(_?_.message:(j==null?void 0:j.message)??"Action failed")}finally{g(null)}},[e,t,l,r]),m={flex:1,overflow:"auto"};if(o)return s.jsx("div",{className:"v10-layer-empty-shell",style:m,"data-cg-scroll-key":i,children:s.jsx(xe,{compact:!0,tone:At(t),icon:Oe[t].icon,title:"Loading assertions..."})});if(!(a!=null&&a.length))return s.jsx("div",{className:"v10-layer-empty-shell",style:m,"data-cg-scroll-key":i,children:s.jsx(xe,{tone:At(t),icon:Oe[t].icon,title:t==="swm"?"No Shared Working Memory assertions listed yet.":"No Working Memory assertions yet.",description:t==="swm"?"Promoted assertion contents are available as Shared Working Memory entities. The assertion list will populate once promoted assertions are exposed by the node.":"Create or import data to stage assertions in Working Memory."})});const b=t==="wm"?"Share Complete KA → Shared":"Publish to VM",x=t==="wm"?"Share Complete KAs → Shared":"Publish all to Verifiable Memory",k=a.filter(N=>N.subGraph!=="meta"||!N.name.startsWith("query-catalog-")).length;return s.jsxs("div",{style:m,"data-cg-scroll-key":i,children:[s.jsxs("div",{style:{padding:"8px 16px",display:"flex",alignItems:"center",justifyContent:"space-between",borderBottom:"1px solid var(--border-subtle)"},children:[s.jsxs("span",{style:{fontSize:11,color:"var(--text-tertiary)"},children:[a.length," assertion",a.length!==1?"s":""]}),k>0&&s.jsx("button",{className:`v10-layer-expand-footer-btn ${t==="wm"?"promote":"publish"}`,disabled:d!==null,onClick:w,style:{opacity:d==="__all__"?.5:1},children:d==="__all__"?"...":x})]}),h&&s.jsxs("div",{"data-testid":t==="wm"?"assertion-promote-result":"assertion-publish-result",style:{padding:"6px 16px",fontSize:11,color:"var(--text-success)"},children:["✓ ",h]}),p&&s.jsxs("div",{"data-testid":t==="wm"?"assertion-promote-result":"assertion-publish-result",style:{padding:"6px 16px",fontSize:11,color:"var(--text-danger)"},children:["✕ ",p]}),a.map(N=>s.jsxs("div",{className:"v10-item-row","data-testid":"assertion-list-row",children:[s.jsx("span",{className:"v10-item-icon",children:"▤"}),s.jsxs("div",{className:"v10-item-info",children:[s.jsx("div",{className:"v10-item-name",style:{fontFamily:"var(--font-mono)",fontSize:11},children:N.name}),(c==null?void 0:c[N.name])&&s.jsx("div",{className:"v10-item-ual",style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-tertiary)",opacity:.7,wordBreak:"break-all",marginTop:1},title:c[N.name],children:c[N.name]}),s.jsxs("div",{className:"v10-item-meta-row",children:[N.tripleCount!=null&&s.jsxs("span",{className:"v10-item-count",children:[N.tripleCount," triples"]}),N.subGraph&&s.jsxs("span",{className:"v10-item-count v10-item-subgraph",title:`In sub-graph: ${N.subGraph}`,children:["› ",wa(N.subGraph,18)]})]})]}),s.jsx("button",{"data-testid":"assertion-row-action",className:`v10-layer-expand-footer-btn ${t==="wm"?"promote":"publish"}`,disabled:d!==null,onClick:j=>{j.stopPropagation(),y(N)},style:{opacity:d===N.graphUri?.5:1,flexShrink:0},children:d===N.graphUri?"...":b})]},N.graphUri))]})}function Co({layer:e,memory:t,onNodeClick:n,onSelectEntity:r,contextGraphId:i,activeTab:a,onTabChange:o,swmAttribution:l,showQueryCatalog:c=!1,onShowQueryCatalogChange:d}){const g=Oe[e],h=f.useMemo(()=>t.entityList.filter(p=>p.trustLevel===g.trustLevel),[t.entityList,g.trustLevel]),u=Wi(t,e);return s.jsxs("div",{className:"v10-layer-detail",children:[s.jsxs("div",{className:"v10-layer-detail-header",children:[s.jsx("span",{className:"v10-layer-detail-icon",style:{color:g.color},children:g.icon}),s.jsxs("div",{children:[s.jsx("div",{className:"v10-layer-detail-title",children:g.title}),s.jsx("div",{className:"v10-layer-detail-desc",children:g.desc})]}),s.jsx("div",{className:"v10-layer-detail-actions"})]}),s.jsx("div",{className:"v10-layer-detail-body",children:s.jsx(ko,{layer:e,entities:h,tripleCount:u.length,layerTriples:u,contextGraphId:i,memory:t,activeTab:a,onTabChange:o,onSelectEntity:r,onNodeClick:n,swmAttribution:l,showQueryCatalog:c,onShowQueryCatalogChange:d})})]})}function Tr({entities:e,contextGraphId:t,scrollKey:n}){const r=Vn(o=>o.openTab),i=f.useMemo(()=>e.filter(o=>o.properties.has(jn)),[e]),a=o=>{var u,p,v;const l=(u=o.connections.find(y=>y.predicate===ds))==null?void 0:u.targetUri,c=(p=o.connections.find(y=>y.predicate===ps))==null?void 0:p.targetUri,d=((v=o.properties.get(jn))==null?void 0:v[0])??"",{ref:g,contentType:h}=Qi(l,c,d);r({id:Ki(t??"",g??o.uri,h),label:o.label,closable:!0,icon:"📄"})};return i.length===0?s.jsx("div",{className:"v10-docs-placeholder v10-layer-empty-shell",style:{flex:1},"data-cg-scroll-key":n,children:s.jsx(xe,{compact:!0,title:"No documents in this layer yet.",description:"Import a file to add document-backed entities."})}):s.jsx("div",{className:"v10-layer-detail-content","data-cg-scroll-key":n,children:s.jsx("div",{className:"v10-items-list",children:i.map(o=>{var h,u,p,v;const l=((h=o.properties.get(jn))==null?void 0:h[0])??"",c=(u=o.connections.find(y=>y.predicate===ds||y.predicate===ps))==null?void 0:u.targetUri,d=c?e.find(y=>y.uri===c):void 0,g=((p=d==null?void 0:d.properties.get(hs))==null?void 0:p[0])??((v=o.properties.get(hs))==null?void 0:v[0]);return s.jsxs("div",{className:"v10-item-row",onClick:()=>a(o),children:[s.jsx("span",{className:"v10-item-icon",children:"📄"}),s.jsxs("div",{className:"v10-item-info",children:[s.jsx("div",{className:"v10-item-name",children:o.label}),s.jsxs("div",{className:"v10-item-meta-row",children:[l&&s.jsx("span",{className:"v10-item-type",children:l}),g&&s.jsxs("span",{className:"v10-item-count",children:["· ",Math.round(parseInt(g)/1024),"KB"]})]})]}),s.jsx("button",{className:"v10-item-promote-btn",onClick:y=>{y.stopPropagation(),a(o)},children:"Open →"})]},o.uri)})})})}function Rr(e){return`SELECT ?g ?s ?p ?o WHERE {
|
|
37
37
|
GRAPH ?g { ?s ?p ?o }
|
|
38
38
|
${Pn(e)}
|
|
39
39
|
}
|