@origintrail-official/dkg-node-ui 10.0.10 → 10.0.12

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.
Files changed (37) hide show
  1. package/dist/db.d.ts +24 -0
  2. package/dist/db.d.ts.map +1 -1
  3. package/dist/db.js +25 -8
  4. package/dist/db.js.map +1 -1
  5. package/dist/index.d.ts +1 -1
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +3 -0
  8. package/dist/index.js.map +1 -1
  9. package/dist/operation-tracker.d.ts +2 -0
  10. package/dist/operation-tracker.d.ts.map +1 -1
  11. package/dist/operation-tracker.js +11 -3
  12. package/dist/operation-tracker.js.map +1 -1
  13. package/dist/telemetry.d.ts +56 -0
  14. package/dist/telemetry.d.ts.map +1 -1
  15. package/dist/telemetry.js +96 -6
  16. package/dist/telemetry.js.map +1 -1
  17. package/dist-ui/assets/{3d-force-graph-CQA2D9yg.js → 3d-force-graph-Bl6v-uII.js} +1 -1
  18. package/dist-ui/assets/{AgentHub-CSSV1CuQ.js → AgentHub-D2vaQxlw.js} +1 -1
  19. package/dist-ui/assets/{AgentProfilePage-C96h7Jti.js → AgentProfilePage-BgSTdsjD.js} +1 -1
  20. package/dist-ui/assets/{ApproveWalletsModal-CjNXwm4Q.js → ApproveWalletsModal-D0Ub_eiD.js} +3 -3
  21. package/dist-ui/assets/{ConvictionDetailView-DIwJDW-h.js → ConvictionDetailView-CieVypna.js} +1 -1
  22. package/dist-ui/assets/{Network--HTk881J.js → Network-DKw_XEGi.js} +1 -1
  23. package/dist-ui/assets/{OnChainProvenanceCard-B27Dv2LS.js → OnChainProvenanceCard-Dn_IEP7Q.js} +1 -1
  24. package/dist-ui/assets/{Operations-CVOxbIG3.js → Operations-BO2C3UWB.js} +34 -34
  25. package/dist-ui/assets/{PublishingConviction-Cq4tU73y.js → PublishingConviction-xKRNHbzk.js} +1 -1
  26. package/dist-ui/assets/{Settings-CAoRacEr.js → Settings-DC_d9STV.js} +1 -1
  27. package/dist-ui/assets/{ccip-Bhdk2CFT.js → ccip-zWfeQL8Q.js} +1 -1
  28. package/dist-ui/assets/{index-CqY4Svqw.js → index-CwRQnNYh.js} +3 -3
  29. package/dist-ui/assets/index-DEtfq9qv.css +1 -0
  30. package/dist-ui/assets/{index-ByKu4and.js → index-hrI-Ir4l.js} +5 -5
  31. package/dist-ui/assets/{jsonld-B67IUHNU-Be6d6eKI.js → jsonld-B67IUHNU-C3ydusi_.js} +2 -2
  32. package/dist-ui/assets/{jsonld-DAi1sJLi.js → jsonld-G-CM-8JR.js} +1 -1
  33. package/dist-ui/assets/{renderer-3d-OSESAPET-BiTfqzJc.js → renderer-3d-OSESAPET-ConXqyK6.js} +2 -2
  34. package/dist-ui/assets/{shikiHighlighter-Cie8jX4V.js → shikiHighlighter-C6lRYd1O.js} +1 -1
  35. package/dist-ui/index.html +2 -2
  36. package/package.json +3 -3
  37. package/dist-ui/assets/index-CtlCxKGP.css +0 -1
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-CqY4Svqw.js","assets/ordinal-DhEzRPdO.js","assets/OnChainProvenanceCard-B27Dv2LS.js","assets/html-pp8916En.js","assets/javascript-wDzz0qaB.js","assets/css-CLj8gQPS.js","assets/Operations-CVOxbIG3.js","assets/PublishingConviction-Cq4tU73y.js","assets/ApproveWalletsModal-CjNXwm4Q.js","assets/ConvictionDetailView-DIwJDW-h.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-CwRQnNYh.js","assets/ordinal-DhEzRPdO.js","assets/OnChainProvenanceCard-Dn_IEP7Q.js","assets/html-pp8916En.js","assets/javascript-wDzz0qaB.js","assets/css-CLj8gQPS.js","assets/Operations-BO2C3UWB.js","assets/PublishingConviction-xKRNHbzk.js","assets/ApproveWalletsModal-D0Ub_eiD.js","assets/ConvictionDetailView-CieVypna.js"])))=>i.map(i=>d[i]);
2
2
  var iT=Object.defineProperty;var sT=(e,t,n)=>t in e?iT(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var jn=(e,t,n)=>sT(e,typeof t!="symbol"?t+"":t,n);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))a(s);new MutationObserver(s=>{for(const l of s)if(l.type==="childList")for(const u of l.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&a(u)}).observe(document,{childList:!0,subtree:!0});function n(s){const l={};return s.integrity&&(l.integrity=s.integrity),s.referrerPolicy&&(l.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?l.credentials="include":s.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function a(s){if(s.ep)return;s.ep=!0;const l=n(s);fetch(s.href,l)}})();var AG=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Wl(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function TG(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var t=e.default;if(typeof t=="function"){var n=function a(){return this instanceof a?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach(function(a){var s=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(n,a,s.get?s:{enumerable:!0,get:function(){return e[a]}})}),n}var oh={exports:{}},pl={};/**
3
3
  * @license React
4
4
  * react-jsx-runtime.production.js
@@ -1283,7 +1283,7 @@ SELECT ?event ?type ?assertion ?name ?agent ?ts ?subGraphName ?assertionGraph (C
1283
1283
  } GROUP BY ?event ?type ?assertion ?name ?agent ?ts ?subGraphName ?assertionGraph
1284
1284
  ORDER BY DESC(?ts) LIMIT 5000`}function Xr(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 IM(e){return e===`${Mm}AssertionCreated`?"created":e===`${Mm}AssertionPromoted`?"promoted":null}function PM(e){const[t,n]=w.useState([]),[a,s]=w.useState(!!e),[l,u]=w.useState(null),[d,f]=w.useState(void 0),h=w.useRef(void 0),g=w.useRef(void 0);return w.useEffect(()=>{if(!e){s(!1);return}h.current!=null&&h.current!==e&&(n([]),u(null),f(void 0),g.current=void 0);let m=!1;const y=new AbortController;let b;return h.current=e,s(!0),u(null),(async()=>{var k;try{const j=new Promise((T,U)=>{b=setTimeout(()=>{y.abort(),U(new Error(`Assertion-lifecycle query timed out after ${Math.round(O1/1e3)}s`))},O1)}),N=(async()=>{const T=await fetch("/api/query",{method:"POST",headers:{"Content-Type":"application/json",...Ft()},signal:y.signal,body:JSON.stringify({sparql:$M(e),contextGraphId:e})});if(!T.ok)throw new Error(`SPARQL query failed: ${T.status}`);return T.json()})(),S=await Promise.race([N,j]);if(m||h.current!==e)return;const A=((k=S==null?void 0:S.result)==null?void 0:k.bindings)??[],E=[];for(const T of A){const U=Xr(T.event),_=Xr(T.type),z=Xr(T.assertion),q=Xr(T.name),D=Xr(T.agent),R=Xr(T.ts);if(!U||!z||!D||!R)continue;const $=IM(_);if(!$)continue;let F;if($==="promoted"){const H=Xr(T.entityCount),B=H!=null?Number(H):NaN;if(Number.isFinite(B)&&B>0)F=B;else{const W=Xr(T.subjectEntityCount),Q=W!=null?Number(W):NaN;Number.isFinite(Q)&&Q>=0&&(F=Q)}}let I=Xr(T.subGraphName);if(I===void 0){const H=Xr(T.assertionGraph);H&&(I=zM(H,e))}E.push({eventUri:U,kind:$,assertionUri:z,assertionName:q??"",agentUri:D,publishedAt:R,subGraph:I,entityCount:F})}n(E),f(e),g.current=e,u(null)}catch(j){if(m||(j==null?void 0:j.name)==="AbortError")return;u(j.message??String(j)),g.current!==e&&n([]),f(e),g.current=e}finally{b&&clearTimeout(b),m||s(!1)}})(),()=>{m=!0,y.abort(),b&&clearTimeout(b)}},[e]),w.useMemo(()=>({resultContextGraphId:d,events:t,loading:a,error:l}),[d,t,a,l])}const UM=["http://purl.org/dc/terms/created","http://dkg.io/ontology/github/mergedAt","http://dkg.io/ontology/github/closedAt","http://dkg.io/ontology/decisions/date","http://dkg.io/ontology/tasks/dueDate"],BM="http://www.w3.org/ns/prov#wasAttributedTo",FM=new Set(["http://dkg.io/ontology/decisions/Decision","http://dkg.io/ontology/tasks/Task","http://dkg.io/ontology/github/PullRequest","http://dkg.io/ontology/github/Issue","http://dkg.io/ontology/github/Commit"]);function Yg(e){const t=e.replace(/^"|"$/g,"").replace(/^"(.+)"(?:@\w+|\^\^.+)?$/,"$1"),n=new Date(t);return Number.isFinite(n.getTime())?n:null}function Qg(e,t,n,a){const s=n?n.toISOString():"no-ts";return a&&a!==t?`${e}|${t}|${a}|${s}`:`${e}|${t}|${s}`}function HM(e){for(const t of UM){const n=e.properties.get(t);if(n!=null&&n.length)for(const a of n){const s=Yg(a);if(s)return s}}return null}function qM(e){for(const t of e.connections)if(t.predicate===BM)return t.targetUri;return null}function GM(e){for(const t of e.types)if(FM.has(t))return t;return null}function VM(e){for(const t of e.subGraphs)if(t!=="meta")return t;return null}function WM(e,t={}){const{limit:n=200,agentUri:a,typeIri:s,subGraph:l,includeUndated:u=!0,excludeEvents:d}=t,f=d?[...d].sort().join(","):"";return w.useMemo(()=>{const h=d&&d.length>0?new Set(d):null,g=[];for(const m of e){const y=GM(m);if(s&&y!==s)continue;const b=HM(m);if(!b&&(!u||!y))continue;const k=qM(m);if(a&&k!==a)continue;const j=VM(m);if(l&&j!==l)continue;const N=y?"typed":"added";if(h&&h.has(N))continue;const S=Qg(N,m.uri,b);g.push({id:S,entity:m,at:b,authorUri:k,kindUri:y,subGraph:j,layer:m.trustLevel,event:N,clickable:!0})}return g.sort((m,y)=>m.at&&y.at?y.at.getTime()-m.at.getTime():m.at&&!y.at?-1:!m.at&&y.at?1:m.entity.label.localeCompare(y.entity.label)),{items:g.slice(0,n),hasMore:g.length>n}},[e,n,a,s,l,u,f])}function ZM(e,t=new Date){const n=g=>{const m=new Date(g);return m.setHours(0,0,0,0),m},a=n(t),s=new Date(a.getTime()-1440*60*1e3),l=new Date(a.getTime()-10080*60*1e3),u={},d=[],f=(g,m,y)=>{u[g]||(u[g]={key:g,label:m,items:[]},d.push(g)),u[g].items.push(y)};for(const g of e){if(!g.at){f("undated","Undated",g);continue}const m=n(g.at);if(m.getTime()===a.getTime())f("today","Today",g);else if(m.getTime()===s.getTime())f("yesterday","Yesterday",g);else if(g.at.getTime()>=l.getTime())f("this-week","Earlier this week",g);else{const y=g.at.toLocaleString(void 0,{month:"long",year:"numeric"});f(`m-${y}`,y,g)}}const h=d.indexOf("undated");return h!==-1&&h<d.length-1&&(d.splice(h,1),d.push("undated")),d.map(g=>u[g])}function KM(e,t){const{entitiesByUri:n,agentUri:a,subGraph:s,limit:l=200}=t,u=[];for(const d of e){if(a&&d.agent!==a||s&&d.subGraph!==s)continue;const f=Yg(d.publishedAt);if(!f)continue;const h=bt(d.rootUri),g=n.get(h),m=g!=null;u.push({id:Qg("promoted",d.opUri,f,h),entity:g??YM(h),at:f,authorUri:d.agent,kindUri:null,subGraph:d.subGraph??null,layer:"shared",event:"promoted",clickable:m})}return u.sort((d,f)=>d.at&&f.at?f.at.getTime()-d.at.getTime():d.at&&!f.at?-1:!d.at&&f.at?1:d.entity.label.localeCompare(f.entity.label)),u.slice(0,l)}function YM(e){return{uri:e,label:qg(e),types:[],trustLevel:"shared",layers:new Set(["shared"]),subGraphs:new Set,properties:new Map,connections:[]}}function QM(e,t={}){const{agentUri:n,subGraph:a,limit:s=200}=t,l=[];for(const u of e){if(n&&u.agentUri!==n||a&&u.subGraph!==a)continue;const d=Yg(u.publishedAt);if(!d)continue;const f=u.kind==="promoted"?"promoted":"added",h=u.kind==="promoted"?"shared":"working",g=bt(u.assertionUri);l.push({id:Qg(f,u.eventUri,d,g),entity:{uri:g,label:u.assertionName||qg(g),types:[],trustLevel:h,layers:new Set([h]),subGraphs:u.subGraph?new Set([u.subGraph]):new Set,properties:new Map,connections:[]},at:d,authorUri:u.agentUri,kindUri:null,subGraph:u.subGraph??null,layer:h,event:f,entityCount:u.entityCount,clickable:!1})}return l.sort((u,d)=>u.at&&d.at?d.at.getTime()-u.at.getTime():u.at&&!d.at?-1:!u.at&&d.at?1:u.entity.label.localeCompare(d.entity.label)),l.slice(0,s)}function XM(e,t={}){const{swmEvents:n,lifecycleEvents:a,...s}=t,l=a!=null,d=WM(e,{...s,excludeEvents:l?["added"]:void 0});return w.useMemo(()=>{const f=s.limit??200;if(t.typeIri)return{items:d.items,hasMore:d.hasMore};if(!l&&(!n||n.length===0))return{items:d.items,hasMore:d.hasMore};let h;if(l)h=QM(a,{agentUri:s.agentUri,subGraph:s.subGraph,limit:Number.POSITIVE_INFINITY});else{const y=new Map;for(const b of e)y.set(b.uri,b);h=KM(n,{entitiesByUri:y,agentUri:s.agentUri,subGraph:s.subGraph,limit:Number.POSITIVE_INFINITY})}const g=[...d.items,...h];g.sort((y,b)=>y.at&&b.at?b.at.getTime()-y.at.getTime():y.at&&!b.at?-1:!y.at&&b.at?1:y.entity.label.localeCompare(b.entity.label));const m=d.hasMore||g.length>f;return{items:g.slice(0,f),hasMore:m}},[d,n,a,l,e,s.agentUri,s.subGraph,s.limit,t.typeIri])}function kj(e,t=new Date){if(!e)return"—";const n=t.getTime()-e.getTime(),a=Math.abs(n),s=n<0,l=6e4,u=l*60,d=u*24;return a<l?s?"in a moment":"just now":a<u?s?`in ${Math.floor(a/l)}m`:`${Math.floor(a/l)}m ago`:a<d?s?`in ${Math.floor(a/u)}h`:`${Math.floor(a/u)}h ago`:a<7*d?s?`in ${Math.floor(a/d)}d`:`${Math.floor(a/d)}d ago`:e.toLocaleDateString(void 0,{month:"short",day:"numeric"})}const L1={"claude-code":"⦿",openclaw:"◈",hermes:"⬡",gemini:"✧",human:"👤"};function JM(e,t){return e&&L1[e]?L1[e]:t==="human"?"👤":"◉"}function eD(e){const t=e.trim();if(!t)return"?";const n=t.split(/[\s_-]+/).filter(Boolean);return n.length===1?n[0].slice(0,2).toUpperCase():(n[0][0]+(n[1][0]??"")).toUpperCase()}function tD(e){const t=e.trim();return t.length<=11?t:`${t.slice(0,6)}…${t.slice(-4)}`}const ts=({agent:e,fallbackUri:t,size:n="sm",showOperator:a=!1,onOpenAgent:s,className:l=""})=>{const u=cs();if(!e&&!t)return null;const d=s??(u==null?void 0:u.openAgent),f=(e==null?void 0:e.uri)??t,h=(e==null?void 0:e.name)??(t?tD(t.split(":").pop()??t):"unknown"),g=(e==null?void 0:e.kind)??"ai",m=e==null?void 0:e.framework,y=JM(m,g),b=(e==null?void 0:e.color)??"hsl(0, 0%, 55%)",k=[h,m?`framework: ${m}`:null,e!=null&&e.operatorName?`operator: ${e.operatorName}`:null,e!=null&&e.walletAddress?`wallet: ${e.walletAddress}`:null,e!=null&&e.peerId?`peer: ${e.peerId.slice(0,20)}…`:null,e!=null&&e.reputation?`— ${e.reputation}`:null,f].filter(Boolean).join(`
1285
1285
  `),j=d?()=>d(f):void 0,N=!!j;return o.jsxs("span",{className:`v10-agent-chip v10-agent-chip-${n}${N?" interactive":""} ${l}`,style:{"--agent-color":b},onClick:j?S=>{S.stopPropagation(),j()}:void 0,title:k,role:N?"button":void 0,tabIndex:N?0:void 0,children:[o.jsxs("span",{className:"v10-agent-chip-avatar",style:{background:b},children:[o.jsx("span",{className:"v10-agent-chip-initials",children:eD(h)}),o.jsx("span",{className:"v10-agent-chip-glyph",title:m??g,children:y})]}),o.jsxs("span",{className:"v10-agent-chip-body",children:[o.jsx("span",{className:"v10-agent-chip-name",children:h}),n==="lg"&&((e==null?void 0:e.operatorName)||m)&&o.jsxs("span",{className:"v10-agent-chip-sub",children:[m&&g==="ai"&&o.jsx("span",{className:"v10-agent-chip-fw",children:m}),(e==null?void 0:e.operatorName)&&g==="ai"&&o.jsxs(o.Fragment,{children:[m&&o.jsx("span",{className:"v10-agent-chip-sep",children:"·"}),o.jsxs("span",{className:"v10-agent-chip-op",children:["driven by ",e.operatorName]})]}),g==="human"&&o.jsx("span",{className:"v10-agent-chip-fw",children:"human"})]}),n==="md"&&a&&(e==null?void 0:e.operatorName)&&g==="ai"&&o.jsx("span",{className:"v10-agent-chip-sub",children:o.jsxs("span",{className:"v10-agent-chip-op",children:["· ",e.operatorName]})})]})]})},Dh={working:"#64748b",shared:"#f59e0b",verified:"#22c55e"},nD={working:"◇",shared:"◈",verified:"◉"},rD=200,aD=({entities:e,agentUri:t,typeIri:n,subGraph:a,limit:s,includeUndated:l=!0,swmEvents:u,lifecycleEvents:d,lifecycleError:f,title:h,onSelectEntity:g,onOpenAgent:m,emptyHint:y,className:b=""})=>{const{items:k,hasMore:j}=XM(e,{agentUri:t,typeIri:n,subGraph:a,limit:s,includeUndated:l,swmEvents:u,lifecycleEvents:d}),N=Ve.useMemo(()=>ZM(k),[k]),S=cs(),A=Ua(),T=j?`${s??rD}+`:String(k.length),U=f!=null&&k.length===0,_=h?o.jsxs("div",{className:"v10-activity-feed-title",children:[o.jsx("span",{className:"v10-activity-feed-title-label",children:h}),o.jsx("span",{className:"v10-activity-feed-title-count","data-state":U?"error":void 0,children:U?"—":T})]}):null,z=f?o.jsx("div",{className:"v10-activity-feed-error",role:"status","aria-live":"polite",title:f,children:"Couldn't load recent activity."}):null;return k.length===0?o.jsxs("div",{className:`v10-activity-feed v10-activity-feed-empty ${b}`,children:[_,z??o.jsx("div",{className:"v10-activity-feed-empty-hint",children:y??"No activity with a timestamp yet."})]}):o.jsxs("div",{className:`v10-activity-feed ${b}`,children:[_,z,N.map(q=>o.jsxs("div",{className:"v10-activity-feed-bucket",children:[o.jsxs("div",{className:"v10-activity-feed-bucket-head",children:[o.jsx("span",{className:"v10-activity-feed-bucket-label",children:q.label}),o.jsx("span",{className:"v10-activity-feed-bucket-count",children:q.items.length})]}),o.jsx("div",{className:"v10-activity-feed-items",children:q.items.map(D=>o.jsx(iD,{item:D,agents:S,profile:A,onSelectEntity:g,onOpenAgent:m},D.id))})]},q.key))]})};function iD({item:e,agents:t,profile:n,onSelectEntity:a,onOpenAgent:s}){const l=e.authorUri?t==null?void 0:t.get(e.authorUri):null,u=e.event==="typed",d=u&&e.kindUri?n==null?void 0:n.forType(e.kindUri):null,f=e.event==="added"?"Added":e.event==="promoted"?e.entityCount!=null&&e.entityCount>0?`Promoted to SWM · ${e.entityCount} ${e.entityCount===1?"entity":"entities"}`:"Promoted to SWM":e.event==="published"?"Published to VM":(d==null?void 0:d.label)??(e.kindUri?e.kindUri.split(/[#/]/).pop():null)??"Entity",h=e.event==="added"?"+":e.event==="promoted"?"⇡":e.event==="published"?"◉":(d==null?void 0:d.icon)??"◆",g=e.event==="promoted"?Dh.shared:e.event==="published"?Dh.verified:e.event==="added"?"#64748b":(d==null?void 0:d.color)??"#a855f7",m=Dh[e.layer],y=u?sD(e.entity):null,b=(()=>{const j=[];return e.event!=="typed"&&j.push(f),j.push(e.entity.label),e.at&&j.push(e.at.toISOString()),j.join(`
1286
- `)})(),k=o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"v10-activity-feed-layer",style:{color:m},title:`${e.layer} memory`,children:nD[e.layer]}),o.jsxs("span",{className:"v10-activity-feed-type",style:{"--type-color":g},children:[o.jsx("span",{className:"v10-activity-feed-type-icon",children:h}),o.jsx("span",{className:"v10-activity-feed-type-label",children:f})]}),o.jsx("span",{className:"v10-activity-feed-title-text",children:e.entity.label}),y&&o.jsx("span",{className:`v10-activity-feed-status status-${oD(y)}`,children:y}),(l||e.authorUri)&&o.jsx("span",{className:"v10-activity-feed-author",children:o.jsx(ts,{agent:l??void 0,fallbackUri:e.authorUri??void 0,size:"sm",onOpenAgent:s})}),o.jsx("span",{className:"v10-activity-feed-time",title:e.at?e.at.toLocaleString():"no timestamp",children:kj(e.at)})]});return e.clickable?o.jsx("button",{type:"button",className:"v10-activity-feed-row",onClick:()=>a(e.entity.uri),title:b,children:k}):o.jsx("div",{className:"v10-activity-feed-row v10-activity-feed-row-static",title:b,"aria-disabled":"true",children:k})}function sD(e){var n;const t=["http://dkg.io/ontology/decisions/status","http://dkg.io/ontology/tasks/status","http://dkg.io/ontology/github/state"];for(const a of t){const s=(n=e.properties.get(a))==null?void 0:n[0];if(s)return s}return null}function oD(e){switch(e){case"accepted":case"done":case"merged":return"good";case"proposed":case"in_progress":case"open":return"warn";case"rejected":case"superseded":case"blocked":case"cancelled":return"bad";default:return"neutral"}}const lD={wm:"working",swm:"shared",vm:"verified"};function cD(e){var y,b,k,j;const t=new Map;if(!e)return t;const n="http://dkg.io/ontology/decisions/status",a="http://dkg.io/ontology/tasks/status",s="http://dkg.io/ontology/tasks/priority",l="http://dkg.io/ontology/github/state",u="http://dkg.io/ontology/decisions/Decision",d="http://dkg.io/ontology/tasks/Task",f="http://dkg.io/ontology/github/PullRequest";let h=0,g=0,m=0;for(const N of e)if(N.types.includes(u))((y=N.properties.get(n))==null?void 0:y[0])==="proposed"&&h++;else if(N.types.includes(d)){const S=(b=N.properties.get(s))==null?void 0:b[0],A=(k=N.properties.get(a))==null?void 0:k[0];S==="p0"&&A!=="done"&&A!=="cancelled"&&g++}else N.types.includes(f)&&((j=N.properties.get(l))==null?void 0:j[0])==="open"&&m++;return h>0&&t.set("decisions",{label:`${h} proposed`,tone:"warn"}),g>0&&t.set("tasks",{label:`${g} p0`,tone:"danger"}),m>0&&t.set("github",{label:`${m} open`,tone:"info"}),t}const zh=({contextGraphId:e,profile:t,selected:n,onSelect:a,entities:s,layer:l,enabledScope:u,allTriplesTotal:d})=>{const[f,h]=Ve.useState([]),[g,m]=Ve.useState(!0),y=Ve.useMemo(()=>cD(s),[s]),b=Ve.useRef(0),k=Ve.useMemo(()=>u&&u.size>0&&u.size<3?new Set(u):u&&u.size>=3?null:l?new Set([lD[l]]):null,[u,l]),j=Ve.useMemo(()=>{if(!s)return null;const I=new Map;for(const H of s)if(!(k&&!k.has(H.trustLevel)))for(const B of H.subGraphs)I.set(B,(I.get(B)??0)+1);return I},[k,s]),N=Ve.useMemo(()=>{if(!s)return null;let I=0;for(const H of s)k&&!k.has(H.trustLevel)||I++;return I},[k,s]),S=Ve.useMemo(()=>{if(!s)return null;let I=0;for(const H of s)k&&!k.has(H.trustLevel)||H.subGraphs.size>0||I++;return I},[k,s]),A=Ve.useCallback(()=>{const I=++b.current;m(!0),Mg(e).then(H=>{I===b.current&&h(H.subGraphs??[])}).catch(()=>{}).finally(()=>{I===b.current&&m(!1)})},[e]);Ve.useEffect(()=>(A(),()=>{b.current++}),[A]),xo(e,A);const E=Ve.useMemo(()=>f.filter(Kg).map(I=>{const H=t.forSubGraph(I.name),B=j!==null?j.get(I.name)??0:I.entityCount;return{slug:I.name,icon:H.icon??"•",color:H.color??"#64748b",displayName:H.displayName??I.name,description:H.description??I.description,rank:H.rank??99,entityCount:B,tripleCount:I.tripleCount,layerScoped:j!==null}}).sort((I,H)=>I.rank-H.rank),[f,t,j]),U=S!==null&&S>0||n===$r;if(g&&E.length===0&&!U||E.length===0&&!U)return null;const _=N??E.reduce((I,H)=>I+H.entityCount,0),z=E.reduce((I,H)=>I+H.tripleCount,0),q={working:"Working Memory",shared:"Shared Working Memory",verified:"Verifiable Memory"},D=k?[...k].map(I=>q[I]).join(" + "):null,R=D?` in ${D}`:"",F=`Total distinct entities — includes those in named subgraphs (some may belong to more than one), plus Root entities not in any subgraph · ${_} entities${R}${D?"":` · ${d??z} triples`}`,K=`All — total distinct entities. Includes those in named subgraphs (some may belong to more than one), plus Root entities not in any subgraph. ${_} entities${R}.`;return o.jsxs("div",{className:"v10-subgraph-bar",children:[o.jsx("div",{className:"v10-subgraph-bar-label",children:"Subgraphs"}),o.jsxs("button",{type:"button",className:`v10-subgraph-chip${n===null?" active":""}`,onClick:()=>a(null),title:F,"aria-label":K,children:[o.jsx("span",{className:"v10-subgraph-chip-icon",children:"⊚"}),o.jsx("span",{className:"v10-subgraph-chip-label",children:"All"}),o.jsx("span",{className:"v10-subgraph-chip-count",children:_})]}),E.map(I=>{const H=y.get(I.slug);return o.jsxs("button",{type:"button",className:`v10-subgraph-chip${n===I.slug?" active":""}${H?" has-badge":""}`,onClick:()=>a(I.slug,l),title:`${I.displayName}${I.description?" · "+I.description:""} · ${I.entityCount} entities${R}${D?"":` · ${I.tripleCount} triples`}${H?" · "+H.label:""}`,style:{"--sg-color":I.color},children:[o.jsx("span",{className:"v10-subgraph-chip-icon",style:{color:I.color},children:I.icon}),o.jsx("span",{className:"v10-subgraph-chip-label",children:I.displayName}),o.jsx("span",{className:"v10-subgraph-chip-count",children:I.entityCount}),H&&o.jsxs("span",{className:`v10-subgraph-chip-badge tone-${H.tone}`,children:[o.jsx("span",{className:"v10-subgraph-chip-badge-dot"}),H.label]})]},I.slug)}),U&&(()=>{const I=S??0,H=n===$r;return o.jsxs("button",{type:"button",className:`v10-subgraph-chip v10-subgraph-chip-root${H?" active":""}`,"data-active":H,"data-count":I,onClick:()=>a($r,l),title:`Entities not in any subgraph (Context Graph root) · ${I} entities${R}`,"aria-label":"Entities not in any subgraph (Context Graph root)",children:[o.jsx("span",{className:"v10-subgraph-chip-icon",children:"⊘"}),o.jsx("span",{className:"v10-subgraph-chip-label",children:"Root"}),o.jsx("span",{className:"v10-subgraph-chip-count",children:I})]})})()]})},Xg="context-graph-primer",Sj={id:Xg,label:"What is a Context Graph?",closable:!0},jj={neutral:"var(--border-strong)",wm:"var(--layer-working, #64748b)",swm:"var(--layer-shared, #f59e0b)",vm:"var(--layer-verified, #22c55e)",danger:"var(--text-danger)",query:"#38bdf8",warning:"var(--text-warning)"};function ln({icon:e,title:t,description:n,actions:a=[],tone:s="neutral",compact:l=!1,inline:u=!1,className:d=""}){const f={"--v10-empty-accent":jj[s]};return o.jsxs("div",{className:["v10-empty-state",l?"compact":"",u?"inline":"",d].filter(Boolean).join(" "),"data-tone":s,style:f,children:[e&&o.jsx("div",{className:"v10-empty-state-icon","aria-hidden":"true",children:e}),o.jsxs("div",{className:"v10-empty-state-copy",children:[o.jsx("div",{className:"v10-empty-state-title",children:t}),n&&o.jsx("div",{className:"v10-empty-state-desc",children:n}),a.length>0&&o.jsx("div",{className:"v10-empty-state-actions",children:a.map(h=>o.jsx("button",{type:"button",className:`v10-empty-state-action ${h.variant??"secondary"}`,onClick:h.onClick,"data-testid":h.testId,children:h.label},h.label))})]})]})}function Fd({items:e,layer:t,compact:n=!1,className:a=""}){const s=t?{"--v10-stat-accent":jj[t]}:void 0;return o.jsx("div",{className:["v10-stat-strip",n?"compact":"",a].filter(Boolean).join(" "),"data-layer":t,style:s,children:e.map((l,u)=>o.jsxs("div",{className:"v10-stat-strip-cell","data-stat-id":l.id,title:l.tooltip,children:[o.jsx("span",{className:"v10-stat-strip-label",children:l.label}),o.jsx("span",{className:"v10-stat-strip-value",children:l.value}),l.hint&&o.jsx("span",{className:"v10-stat-strip-hint",children:l.hint})]},l.id??u))})}const Jg=w.lazy(()=>gt(()=>import("./index-CqY4Svqw.js").then(e=>e.h),__vite__mapDeps([0,1])).then(e=>({default:e.RdfGraph}))),uD="http://www.w3.org/1999/02/22-rdf-syntax-ns#type",dD=new Map(Hg.map((e,t)=>[e,t]));function Dm(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 Da(e){const t=e.trim();return t.startsWith("<")&&t.endsWith(">")?t.slice(1,-1):t}function pD(e){const t=new Set,n=new Map,a=new Map,s=new Map;for(const d of e){const f=Da(d.subject);t.add(f);const h=dD.get(d.predicate);if(h!==void 0){const m=Pd(d.object).trim();if(m){const y=s.get(f);(y===void 0||h<y)&&(a.set(f,m),s.set(f,h))}}if(Da(d.predicate)===uD||!Dm(d.object))continue;const g=Da(d.object);n.set(f,(n.get(f)??0)+1),n.set(g,(n.get(g)??0)+1)}const l=[...t].filter(d=>(n.get(d)??0)===0).map(d=>({uri:d,label:a.get(d)??dj(void 0,d)})).sort((d,f)=>d.label.localeCompare(f.label));if(l.length===0)return{canvasTriples:e,singletonItems:l};const u=new Set(l.map(d=>d.uri));return{canvasTriples:e.filter(d=>!u.has(Da(d.subject))&&!u.has(Da(d.object))),singletonItems:l}}function fD(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 hD({items:e,onSelect:t}){return e.length===0?null:o.jsxs("div",{className:"v10-graph-singleton-shelf","aria-label":"Standalone entities without visible links",children:[o.jsxs("div",{className:"v10-graph-singleton-head",title:"Entities with no visible links are grouped here to keep the graph readable.",children:[o.jsx("span",{children:"Standalone entities"}),o.jsx("span",{children:e.length})]}),o.jsx("div",{className:"v10-graph-singleton-list",children:e.map(({uri:n,label:a})=>o.jsx("button",{type:"button",className:"v10-graph-singleton-item",title:n,onClick:()=>t==null?void 0:t(n),children:a},n))})]})}const mD=2500;function M1(e,t=mD){if(e.length<=t)return e;const n=new Map;for(const u of e)n.set(u.subject,(n.get(u.subject)??0)+1);const a=[...n.entries()].sort((u,d)=>d[1]-u[1]).map(([u])=>u),s=new Set;let l=0;for(const u of a){const d=n.get(u)??0;l+d>t||(s.add(u),l+=d)}return s.size===0&&a.length>0&&s.add(a[0]),e.filter(u=>s.has(u.subject)).slice(0,t)}function Xu({title:e,scopeLabel:t,tone:n,className:a,rail:s,overlay:l,showScopeLabel:u=!0,singletonItems:d=[],onSingletonClick:f,renderGraph:h}){const[g,m]=w.useState(!1);w.useEffect(()=>{if(!g)return;const k=j=>{j.key==="Escape"&&m(!1)};return document.addEventListener("keydown",k),()=>document.removeEventListener("keydown",k)},[g]);const y=o.jsx("button",{type:"button",className:`v10-graph-expand-btn${u?"":" in-canvas"}`,onClick:()=>m(!0),title:`Expand ${e}`,"aria-label":`Expand ${e}`,children:"⤢"}),b=k=>o.jsxs(o.Fragment,{children:[u&&!k&&o.jsxs("div",{className:"v10-graph-shell-bar",children:[o.jsx("div",{className:"v10-graph-scope",title:t,children:t}),y]}),o.jsxs("div",{className:"v10-graph-body",children:[o.jsxs("div",{className:"v10-graph-canvas",children:[!u&&!k&&y,o.jsx("div",{className:"v10-graph-view",children:h(k)}),l&&o.jsx("div",{className:"v10-graph-overlay",children:l}),o.jsx(hD,{items:d,onSelect:f})]}),s&&o.jsx("aside",{className:"v10-graph-rail",children:s})]})]});return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:`v10-graph-shell v10-graph-shell-${n}${a?` ${a}`:""}`,children:!g&&b(!1)}),g&&o.jsx("div",{className:"v10-graph-expanded-backdrop",role:"dialog","aria-modal":"true","aria-label":`${e} expanded`,onClick:k=>{k.target===k.currentTarget&&m(!1)},children:o.jsxs("div",{className:`v10-graph-expanded-panel v10-graph-shell-${n}`,children:[o.jsxs("div",{className:"v10-graph-expanded-head",children:[o.jsxs("div",{children:[o.jsx("div",{className:"v10-graph-expanded-title",children:e}),o.jsx("div",{className:"v10-graph-expanded-subtitle",children:t})]}),o.jsx("button",{type:"button",className:"v10-graph-expanded-close",onClick:()=>m(!1),"aria-label":`Close expanded ${e}`,children:"×"})]}),o.jsx("div",{className:"v10-graph-expanded-body",children:b(!0)})]})})]})}function Cj({layer:e,triples:t,onNodeClick:n,contextGraphId:a,scopeLabel:s,trustLegendActiveLayer:l,title:u,scopeEntities:d,swmAttribution:f,layerEntities:h,nodeColorsOverride:g}){const{title:m}=zn[e],y=u??m,b=Vn(L=>L.theme),k=w.useMemo(()=>{if(e!=="vm")return;const L=new Set;for(const P of t)L.add(P.subject),Dm(P.object)&&L.add(P.object);return L},[t,e]),{anchors:j,decorationTriples:N}=L4(e==="vm"&&a?a:void 0,k),S=wj(e==="swm"&&a&&!f?a:void 0),A=f??S,E=w.useMemo(()=>{if(!h||h.length===0)return t;const L=new Set;for(const P of h)L.add(bt(P.uri));return hd(t,L)},[t,h]),T=w.useMemo(()=>{const L=new Set,P=[],G=O=>{const ne=`${O.subject}|${O.predicate}|${O.object}`;L.has(ne)||(L.add(ne),P.push({subject:O.subject,predicate:O.predicate,object:O.object}))};for(const O of E)G(O);for(const O of N)G(O);return P},[E,N]),U=T,_=w.useMemo(()=>{const L=e==="swm"?A.nodeColors:void 0;if(!(!L&&!g))return L?g?{...L,...g}:L:g},[e,A.nodeColors,g]),z=w.useMemo(()=>q4(e,_),[e,_]),{canvasTriples:q,singletonItems:D}=w.useMemo(()=>pD(U),[U]),R=w.useMemo(()=>{if(!d||d.length===0)return D;const L=new Set(D.map(G=>Da(G.uri)));for(const G of q)L.add(Da(G.subject)),Dm(G.object)&&L.add(Da(G.object));const P=[];for(const G of d){const O=Da(G.uri);L.has(O)||(L.add(O),P.push({uri:O,label:G.label||dj(void 0,O)}))}return P.length===0?D:[...D,...P].sort((G,O)=>G.label.localeCompare(O.label))},[D,q,d]),$=`${a??"context"}:${e}`,F=e==="swm"&&!!a&&A.loading,K=`${y} graph`,I=s??fD(e),H=l===null&&!!s,B=l===null?void 0:l??e,Q=e==="vm"&&j.length>0||e==="swm"&&A.palette.length>0?o.jsxs(o.Fragment,{children:[e==="vm"&&j.length>0&&o.jsx(vD,{anchors:j}),e==="swm"&&A.palette.length>0&&o.jsx(gD,{palette:A.palette,conflicts:A.conflicts.length})]}):null,V=w.useMemo(()=>({name:`${$}:${b}`,palette:b}),[$,b]);return T.length===0&&R.length===0?o.jsx(Xu,{title:K,scopeLabel:I,tone:e,className:"v10-graph-view-fill",showScopeLabel:H,renderGraph:()=>o.jsx("div",{className:"v10-layer-empty-shell",children:o.jsx(ln,{compact:!0,tone:e,icon:zn[e].icon,title:`No triples in ${y}`,description:"The graph will appear when this layer has connected triples."})})}):F?o.jsx(Xu,{title:K,scopeLabel:I,tone:"swm",className:"v10-graph-view-fill",showScopeLabel:H,renderGraph:()=>o.jsx("div",{className:"v10-layer-empty-shell",children:o.jsx(ln,{compact:!0,tone:"swm",icon:zn.swm.icon,title:"Loading Shared Working Memory attribution...",description:"Agent colors are being prepared before the graph renders."})})}):o.jsx(Xu,{title:K,scopeLabel:I,tone:e,className:"v10-graph-view-fill",overlay:Q,showScopeLabel:H,singletonItems:R,onSingletonClick:L=>n==null?void 0:n(B?{id:L,trustLayer:B}:{id:L}),renderGraph:L=>q.length>0?o.jsx(w.Suspense,{fallback:o.jsx("span",{className:"v10-graph-placeholder",children:"Loading graph..."}),children:o.jsx(Jg,{data:q,format:"triples",options:z,viewConfig:V,style:{position:"absolute",inset:0,width:"100%",height:"100%"},onNodeClick:B?P=>n==null?void 0:n({...P,trustLayer:B}):n,initialFit:!0},`${$}:${L?"expanded":"inline"}:${q.length}`)}):o.jsx("div",{className:"v10-graph-placeholder v10-graph-placeholder-centered",children:"Connected graph appears when this layer has linked entities."})})}function gD({palette:e,conflicts:t}){return o.jsxs("div",{className:"v10-swm-legend","aria-label":"SWM attribution legend",children:[o.jsxs("div",{className:"v10-swm-legend-row v10-swm-legend-head",children:[o.jsx("span",{children:"SWM attribution"}),o.jsxs("span",{className:"v10-swm-legend-count",children:[e.length," agent",e.length===1?"":"s"]})]}),e.slice(0,8).map(n=>o.jsxs("div",{className:"v10-swm-legend-row",title:n.agent,children:[o.jsx("span",{className:"v10-swm-legend-swatch",style:{background:n.color}}),o.jsx("span",{className:"v10-swm-legend-label",children:n.label}),o.jsx("span",{className:"v10-swm-legend-metric",children:n.entityCount})]},n.agent)),t>0&&o.jsxs("div",{className:"v10-swm-legend-row v10-swm-legend-conflict",children:[o.jsx("span",{className:"v10-swm-legend-swatch",style:{background:"#f59e0b"},children:"!"}),o.jsx("span",{className:"v10-swm-legend-label",children:"In review"}),o.jsx("span",{className:"v10-swm-legend-metric",children:t})]})]})}function vD({anchors:e}){var s;const t=w.useMemo(()=>{const l=new Set;for(const u of e)for(const d of u.agents)l.add(d);return l.size},[e]),n=(s=e[0])==null?void 0:s.publishedAt,a=(()=>{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 o.jsxs("div",{className:"v10-vm-legend","aria-label":"Verifiable Memory legend",children:[o.jsxs("div",{className:"v10-vm-legend-row v10-vm-legend-head",children:[o.jsx("span",{children:"VM provenance layer"}),o.jsxs("span",{className:"v10-vm-legend-count",children:[e.length," anchor",e.length===1?"":"s"]})]}),o.jsxs("div",{className:"v10-vm-legend-row",children:[o.jsx("span",{className:"v10-vm-legend-swatch",style:{background:"#f5a524"},children:"◉"}),o.jsx("span",{className:"v10-vm-legend-label",children:"On-chain anchor"})]}),o.jsxs("div",{className:"v10-vm-legend-row",children:[o.jsx("span",{className:"v10-vm-legend-swatch",style:{background:"#c084fc"},children:"◈"}),o.jsxs("span",{className:"v10-vm-legend-label",children:["Agent identity (",t,")"]})]}),o.jsxs("div",{className:"v10-vm-legend-row",children:[o.jsx("span",{className:"v10-vm-legend-swatch",style:{background:"#4ade80"},children:"—"}),o.jsx("span",{className:"v10-vm-legend-label",children:"Signed / anchored edge"})]}),a&&o.jsxs("div",{className:"v10-vm-legend-foot",children:["Latest: ",a]})]})}function yD({active:e,counts:t,onSwitch:n,onShare:a,onImport:s,onRefresh:l}){const[u,d]=w.useState(!1),f=w.useRef(null),h=g=>{d(!1),n(g)};return w.useEffect(()=>{if(!u)return;const g=m=>{var b;const y=m.target;y&&((b=f.current)!=null&&b.contains(y))||d(!1)};return document.addEventListener("pointerdown",g),()=>document.removeEventListener("pointerdown",g)},[u]),o.jsxs("div",{className:"v10-layer-switcher",children:[o.jsxs("button",{className:`v10-layer-switch-btn ${e==="overview"?"active":""}`,"data-layer":"overview","aria-label":"Overview",title:"Overview",onClick:()=>h("overview"),children:[o.jsx("span",{className:"v10-layer-switch-icon",children:"◎"}),o.jsx("span",{className:"v10-layer-switch-label",children:"Overview"})]}),o.jsx("span",{className:"v10-layer-switch-separator","aria-hidden":"true"}),o.jsxs("button",{className:`v10-layer-switch-btn ${e==="wm"?"active":""}`,"data-layer":"wm","aria-label":"Working Memory",title:"Working Memory",onClick:()=>h("wm"),children:[o.jsx("span",{className:"v10-layer-switch-icon",style:{color:"#64748b"},children:"◇"}),o.jsx("span",{className:"v10-layer-switch-label v10-layer-switch-label-full",children:"Working Memory"}),o.jsx("span",{className:"v10-layer-switch-label v10-layer-switch-label-compact",children:"WM"}),t.wm>0&&o.jsx("span",{className:"v10-layer-switch-count",children:t.wm})]}),o.jsxs("button",{className:`v10-layer-switch-btn ${e==="swm"?"active":""}`,"data-layer":"swm","aria-label":"Shared Working Memory",title:"Shared Working Memory",onClick:()=>h("swm"),children:[o.jsx("span",{className:"v10-layer-switch-icon",style:{color:"#f59e0b"},children:"◈"}),o.jsx("span",{className:"v10-layer-switch-label v10-layer-switch-label-full",children:"Shared Working Memory"}),o.jsx("span",{className:"v10-layer-switch-label v10-layer-switch-label-compact",children:"SWM"}),t.swm>0&&o.jsx("span",{className:"v10-layer-switch-count",children:t.swm})]}),o.jsxs("button",{className:`v10-layer-switch-btn ${e==="vm"?"active":""}`,"data-layer":"vm","aria-label":"Verifiable Memory",title:"Verifiable Memory",onClick:()=>h("vm"),children:[o.jsx("span",{className:"v10-layer-switch-icon",style:{color:"#22c55e"},children:"◉"}),o.jsx("span",{className:"v10-layer-switch-label v10-layer-switch-label-full",children:"Verifiable Memory"}),o.jsx("span",{className:"v10-layer-switch-label v10-layer-switch-label-compact",children:"VM"}),t.vm>0&&o.jsx("span",{className:"v10-layer-switch-count",children:t.vm})]}),o.jsx("span",{className:"v10-layer-switch-separator","aria-hidden":"true"}),o.jsxs("button",{className:`v10-layer-switch-btn ${e==="graph-overview"?"active":""}`,"data-layer":"graph-overview","aria-label":"Subgraphs",title:"Subgraphs",onClick:()=>h("graph-overview"),children:[o.jsx("span",{className:"v10-layer-switch-icon",children:"⌬"}),o.jsx("span",{className:"v10-layer-switch-label",children:"Subgraphs"})]}),o.jsxs("div",{ref:f,className:"v10-layer-more",onBlur:g=>{g.currentTarget.contains(g.relatedTarget)||d(!1)},children:[o.jsxs("button",{type:"button",className:`v10-layer-switch-btn v10-layer-more-btn ${e==="query"?"active":""}`,"data-layer":"query","aria-haspopup":"menu","aria-expanded":u,"aria-label":"More Context Graph views",title:"More Context Graph views",onClick:()=>d(g=>!g),children:[o.jsx("span",{className:"v10-layer-switch-icon",children:"⋯"}),o.jsx("span",{className:"v10-layer-switch-label",children:"More"})]}),u&&o.jsx("div",{className:"v10-layer-more-menu",role:"menu",children:o.jsxs("button",{type:"button",role:"menuitem",className:`v10-layer-more-item ${e==="query"?"active":""}`,onClick:()=>h("query"),children:[o.jsx("span",{className:"v10-layer-switch-icon",children:"⟐"}),"Query Catalogue"]})})]}),o.jsx("div",{className:"v10-layer-switcher-spacer"}),o.jsxs("div",{className:"v10-layer-switcher-actions",children:[o.jsxs("button",{className:"v10-layer-action-btn",onClick:a,"aria-label":"Share Context Graph",children:[o.jsx("span",{className:"v10-layer-action-icon",children:"⤴"}),o.jsx("span",{className:"v10-layer-action-label",children:"Share"})]}),o.jsxs("button",{className:"v10-layer-action-btn",onClick:s,"aria-label":"Import into Context Graph",children:[o.jsx("span",{className:"v10-layer-action-icon",children:"↑"}),o.jsx("span",{className:"v10-layer-action-label",children:"Import"})]}),o.jsx("button",{className:"v10-layer-action-btn",onClick:l,"aria-label":"Refresh Context Graph data",children:o.jsx("span",{className:"v10-layer-action-icon",children:"↻"})})]})]})}function bD({cg:e,profile:t,activeSubGraph:n,onClearSubGraph:a}){const s=e.name||t.displayName||e.id;return o.jsxs("div",{className:"v10-project-strip",style:{"--sg-color":(n==null?void 0:n.color)??t.primaryColor},children:[o.jsx("span",{className:"v10-project-strip-dot",style:{background:t.primaryColor}}),o.jsx("button",{type:"button",className:"v10-project-strip-name",onClick:n?a:void 0,disabled:!n,title:n?"Back to context graph overview":e.id,children:s}),n?o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"v10-project-strip-sep",children:"›"}),o.jsxs("span",{className:"v10-project-strip-sg",children:[o.jsx("span",{className:"v10-project-strip-sg-icon",style:{color:n.color},children:n.icon??"•"}),n.displayName??n.slug]}),n.description&&o.jsx("span",{className:"v10-project-strip-desc",title:n.description,children:n.description})]}):e.description&&o.jsx("span",{className:"v10-project-strip-desc",title:e.description,children:e.description})]})}function xD(e,t,n,a,s){const l=typeof(e==null?void 0:e.curator)=="string"?e.curator.trim():"",u=new Set([t==null?void 0:t.agentDid,t==null?void 0:t.agentAddress].filter(h=>typeof h=="string"&&h.trim().length>0).map(Jt)),d=u.size>0;return l&&d&&u.has(Jt(l))?{label:"Curator",title:"This agent is the curator for this Context Graph.",tone:"curator"}:(e==null?void 0:e.callerInvolved)===!0?l&&!d&&n==="loading"?{label:"Role checking",title:"This agent is involved in this Context Graph; curator status is still loading.",tone:"unknown"}:l&&!d&&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"}:s==="ok"&&a.map(h=>h.trim()).filter(Boolean).some(h=>u.has(Jt(h)))?{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 wD(e,t,n){if(es(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 s=new Set(t.map(u=>u.trim()).filter(Boolean).map(Jt)),l=typeof(e==null?void 0:e.curator)=="string"?e.curator.trim():"";return l&&s.add(Jt(l)),{id:"participants",value:s.size.toLocaleString(),label:"Agents with access",tooltip:"Includes the curator plus allowlisted participants reported by the node."}}function kD(e){const t=es(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 SD({cg:e,currentAgent:t,currentAgentStatus:n="ok"}){var d,f;const a=typeof(e==null?void 0:e.curator)=="string"?e.curator.trim():"";if(!a)return"unknown";const s=((d=t==null?void 0:t.agentDid)==null?void 0:d.trim())??"",l=((f=t==null?void 0:t.agentAddress)==null?void 0:f.trim())??"",u=s||l;return u?Jt(a)===Jt(u)?"curator":"not-curator":"unknown"}function jD(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(Jt))}function CD({cg:e,memory:t,subGraphCount:n,subGraphFetchFailed:a=!1,participants:s,participantsStatus:l="ok",currentAgent:u,currentAgentStatus:d="ok",onSwitchLayer:f,onOpenPrimer:h}){var V,L,P;const{wm:g,swm:m,vm:y}=t.counts,b=g+m+y,k=xD(e,u??null,d,s,l),j=kD(e==null?void 0:e.accessPolicy),N=wD(e,s,l),S=typeof(e==null?void 0:e.curator)=="string"?e.curator.trim():"",A=S?Jt(S):"",E=es(e==null?void 0:e.accessPolicy)==="public",T=jD(u??null),U=Object.values(t.layerStatus??{}),_=U.filter(G=>G==="error").length,z=!t.loading&&U.length===3&&_===3,q=!t.loading&&_>0,D=t.loading?"Loading memory layers...":z||t.error?"Live memory counts are unavailable.":t.partial||q?"One or more layer counts are currently a lower bound.":"Canonical current-layer entity counts.",R=z?"Unavailable":b.toLocaleString(),{total:$}=Zg(t),F=!t.loading&&(t.partial||q),K=z?"Unavailable":t.loading&&$===0?"...":F?`${$.toLocaleString()}+`:$.toLocaleString(),I=z?"Live triple counts are unavailable.":F?"One or more layer triple counts are currently a lower bound.":"Canonical triple total across all layers.",H=n==null?a?"Unavailable":"...":n.toLocaleString(),B=n==null?a?"Sub-graph list is currently unavailable.":"Sub-graph count is loading.":"Topical partitions inside this Context Graph.",W=[{key:"wm",label:"Working Memory",desc:"Private staging area",count:g,status:((V=t.layerStatus)==null?void 0:V.wm)??"ok",color:"#64748b"},{key:"swm",label:"Shared Working Memory",desc:"Collaborative review",count:m,status:((L=t.layerStatus)==null?void 0:L.swm)??"ok",color:"#f59e0b"},{key:"vm",label:"Verifiable Memory",desc:"Published on-chain",count:y,status:((P=t.layerStatus)==null?void 0:P.vm)??"ok",color:"#22c55e"}],Q=W.some(G=>G.status==="error");return o.jsxs("div",{className:"v10-po",children:[o.jsxs("div",{className:"v10-po-identity","data-section":"identity",children:[o.jsxs("div",{className:"v10-po-identity-pairs",children:[o.jsxs("div",{className:"v10-po-identity-pair",children:[o.jsx("span",{className:"v10-po-identity-label",children:"Your role:"}),o.jsx("span",{className:"v10-po-badge","data-role":k.tone,title:k.title,children:k.label})]}),o.jsxs("div",{className:"v10-po-identity-pair",children:[o.jsx("span",{className:"v10-po-identity-label",children:"Context Graph:"}),o.jsx("span",{className:"v10-po-badge","data-cg-type":j.tone,title:j.title,children:j.label})]})]}),h&&o.jsx("button",{type:"button",className:"v10-po-identity-primer",onClick:h,title:"Open the Context Graph primer",children:"What is a Context Graph?"})]}),o.jsxs("div",{"data-section":"at-a-glance",className:"v10-po-stat-block",children:[o.jsx("div",{className:"v10-po-section-title",children:"At a glance"}),o.jsx(Fd,{className:"v10-po-stat-strip",items:[{id:"entities",value:R,label:"Entities",tooltip:D},{id:"triples",value:K,label:"Triples",tooltip:I},{id:"subgraphs",value:H,label:"Subgraphs",tooltip:B},N]})]}),o.jsxs("div",{className:"v10-po-pipeline","data-section":"pipeline","aria-label":"Knowledge Pipeline",children:[o.jsx("div",{className:"v10-po-pipeline-head",children:o.jsxs("div",{children:[o.jsx("div",{className:"v10-po-section-title",children:"Knowledge Pipeline"}),o.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."})]})}),o.jsx("div",{className:"v10-po-pipeline-track","aria-hidden":"true",children:!Q&&b>0?W.map(G=>{const O=G.count>0?G.count/b*100:0;return o.jsx("span",{className:`v10-po-pipeline-seg ${G.key}`,style:{width:`${O}%`,background:G.color}},G.key)}):o.jsx("span",{className:"v10-po-pipeline-empty"})}),o.jsx("div",{className:"v10-po-pipeline-steps",children:W.map((G,O)=>o.jsxs("button",{type:"button",className:`v10-po-pipeline-step ${G.key}`,onClick:()=>f==null?void 0:f(G.key),style:{"--po-layer-color":G.color},children:[o.jsx("span",{className:"v10-po-pipeline-step-index",children:O+1}),o.jsxs("span",{className:"v10-po-pipeline-step-copy",children:[o.jsx("span",{className:"v10-po-pipeline-step-label",children:G.label}),o.jsx("span",{className:"v10-po-pipeline-step-desc",children:G.desc})]}),o.jsx("span",{className:"v10-po-pipeline-step-count",children:G.status==="error"?"Unavailable":`${G.count.toLocaleString()} ${ia(G.key,G.count)}`})]},G.key))})]}),o.jsxs("div",{className:"v10-po-people","data-section":"participants",children:[o.jsx("div",{className:"v10-po-section-title",children:"Participant agents"}),(()=>{const G="did:dkg:agent:",O=le=>le.toLowerCase().startsWith(G)?le.slice(G.length):le,ne=new Set,ue=[];if(S&&l==="ok"){const le=Jt(S);ne.add(le),ue.push({display:O(S),full:S,canonical:le})}if(l==="ok")for(const le of s){const be=Jt(le);ne.has(be)||(ne.add(be),ue.push({display:O(le),full:le,canonical:be}))}if(ue.length===0){const le=E?"This Context Graph is public — anyone can subscribe.":l==="loading"?"Loading participant agents...":l==="error"?"Participant list unavailable.":"No participant agents recorded yet.";return o.jsx("div",{className:"v10-po-people-empty",children:le})}return o.jsx("div",{className:"v10-po-participants-list",children:ue.map(({display:le,full:be,canonical:_e})=>{const Ee=T.has(_e),Ie=!!A&&_e===A,We=`${le.slice(0,6)}…${le.slice(-4)}`,Se=[We];return Ee&&Se.push("you"),Ie&&Se.push("curator"),o.jsxs("span",{className:`v10-po-participant${Ee?" is-self":""}${Ie?" is-curator":""}`,title:be,"aria-label":Se.join(" "),children:[o.jsx("span",{className:"v10-po-participant-name",children:We}),Ee&&o.jsx("span",{className:"v10-po-participant-tag",children:"you"}),Ie&&o.jsx("span",{className:"v10-po-participant-tag",children:"curator"})]},_e)})})})()]})]})}function ND({contextGraphId:e,curatorStatus:t,onParticipantsChanged:n}){const[a,s]=w.useState([]),[l,u]=w.useState(null),[d,f]=w.useState("loading"),h=w.useRef(0),g=w.useCallback(()=>{if(t!=="curator"){s([]),f("idle");return}const b=++h.current;f("loading"),RS(e).then(k=>{h.current===b&&(s(k.requests.filter(j=>j.status==="pending")),f("idle"))}).catch(()=>{h.current===b&&(s([]),f("error"))})},[e,t]);if(w.useEffect(()=>(g(),()=>{h.current++}),[g]),ss(w.useCallback(b=>{var k;b.type!=="join_request"&&b.type!=="join_approved"&&b.type!=="join_rejected"||((k=b.data)==null?void 0:k.contextGraphId)===e&&g()},[e,g])),t==="not-curator")return null;if(t==="unknown")return o.jsxs("section",{className:"v10-po-join","data-section":"join-requests",children:[o.jsx("header",{className:"v10-po-join-head",children:o.jsx("span",{className:"v10-po-section-title",children:"Pending join requests"})}),o.jsx("div",{className:"v10-po-join-empty",children:"Verifying access…"})]});const m=async b=>{u(b);try{await Ng(e,b),s(k=>k.filter(j=>j.agentAddress!==b)),n==null||n()}catch{}finally{u(null)}},y=async b=>{u(b);try{await Eg(e,b),s(k=>k.filter(j=>j.agentAddress!==b)),n==null||n()}catch{}finally{u(null)}};return o.jsxs("section",{className:"v10-po-join","data-section":"join-requests",children:[o.jsxs("header",{className:"v10-po-join-head",children:[o.jsx("span",{className:"v10-po-section-title",children:"Pending join requests"}),o.jsx("span",{className:"v10-po-join-count","data-empty":a.length===0?"true":"false",children:a.length})]}),d==="loading"?o.jsx("div",{className:"v10-po-join-empty",children:"Loading join requests..."}):d==="error"?o.jsx("div",{className:"v10-po-join-empty",children:"Join requests are currently unavailable."}):a.length===0?o.jsx("div",{className:"v10-po-join-empty",children:"No pending join requests."}):o.jsx("div",{className:"v10-po-join-list",children:a.map(b=>o.jsxs("div",{className:"v10-po-join-item",children:[o.jsxs("div",{className:"v10-po-join-info",children:[o.jsx("span",{className:"v10-po-join-name",children:b.name||`${b.agentAddress.slice(0,6)}…${b.agentAddress.slice(-4)}`}),o.jsxs("span",{className:"v10-po-join-addr",title:b.agentAddress,children:[b.agentAddress.slice(0,10),"…"]})]}),o.jsxs("div",{className:"v10-po-join-actions",children:[o.jsx("button",{className:"v10-po-join-btn approve",onClick:()=>m(b.agentAddress),disabled:l===b.agentAddress,children:l===b.agentAddress?"…":"✓ Approve"}),o.jsx("button",{className:"v10-po-join-btn reject",onClick:()=>y(b.agentAddress),disabled:l===b.agentAddress,"aria-label":"Reject join request",children:"✕"})]})]},b.agentAddress))})]})}function ED({onOpenPrimer:e}){return o.jsxs("div",{className:"v10-po-primer-footer","data-section":"primer",children:[o.jsx("span",{className:"v10-po-primer-footer-lede",children:"New here?"}),o.jsx("span",{className:"v10-po-primer-footer-arrow","aria-hidden":"true",children:"→"}),o.jsx("button",{type:"button",className:"v10-po-primer-footer-link",onClick:e,children:"What is a Context Graph?"}),o.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 AD=(e,t)=>!!e&&!!t&&e.toLowerCase()===t.toLowerCase();function TD(e,t=0){const n=Pl(u=>u.trackedIds),a=n.join(","),{data:s,loading:l}=lr(async()=>{if(n.length===0)return{wallets:[],ownerPublish:!1,resolved:!1};const u=await Lg().catch(()=>null),d=(u==null?void 0:u.wallets)??[];let f=!1;try{const{contextGraphs:g}=await Ld(),m=(g??[]).find(b=>(b==null?void 0:b.id)===e),y=m==null?void 0:m.curator;if(y){const b=await Yl().catch(()=>null);f=!!(b!=null&&b.agentDid&&Jt(y)===Jt(b.agentDid))}}catch{f=!1}return{wallets:await Promise.all(d.map(async g=>{var T;const m=(T=u==null?void 0:u.balances)==null?void 0:T.find(U=>AD(U.address,g)),y=m==null,b=m!=null&&Number(m.eth)>0,k=m!=null&&Number(m.trac)>0;let j,N=!1,S=!1,A,E=!1;for(const U of n){const _=await od(U,g,{extended:!0}).catch(()=>null);if(_===null){E=!0;continue}const z=jm(_);if(z.outcome==="inconclusive"){E=!0;continue}if(z.outcome!=="unregistered"){if(z.outcome==="covers"){j={accountId:U,discountBps:_.discountBps,untracked:!1};break}z.dead&&(N=!0,A||(A=U)),z.hasBudget||(S=!0)}}if(!j&&!E&&!N&&!S){const U=await i_(g).catch(()=>{});if(U===void 0)E=!0;else if(U.accountId!=null&&!n.includes(U.accountId)){const _=U.accountId,z=await od(_,g,{extended:!0}).catch(()=>null);if(z===null)E=!0;else{const q=jm(z);q.outcome==="covers"?j={accountId:_,discountBps:z.discountBps,untracked:!0}:q.outcome==="uncovered"?(q.dead&&(N=!0,A||(A=_)),q.hasBudget||(S=!0)):E=!0}}}return{wallet:g,covered:!!j,accountId:j==null?void 0:j.accountId,discountBps:j==null?void 0:j.discountBps,coverUntracked:(j==null?void 0:j.untracked)??!1,deadAccountId:j?void 0:A,inconclusive:!j&&E,balanceUnknown:y,gasFunded:b,hasTrac:k,sawExpired:N,sawInsolvent:S}})),ownerPublish:f,resolved:d.length>0}},[a,e],t);return w.useMemo(()=>{const u=(s==null?void 0:s.wallets)??[],d=(s==null?void 0:s.ownerPublish)??!1,f=(s==null?void 0:s.resolved)??!1;if(n.length===0||!f||u.length===0)return{verdict:"unknown",loading:l,ownerPublish:d,anyGasFunded:!1,reasons:[],conditions:{approved:!1,gasFunded:!1,notExpired:!1,solvent:!1},wallets:u};const h=u.filter(S=>S.covered),g=u.filter(S=>!S.covered),m=g.filter(S=>!S.inconclusive&&!S.balanceUnknown),y=g.filter(S=>S.inconclusive||S.balanceUnknown),b={approved:g.length===0,gasFunded:u.every(S=>S.gasFunded),notExpired:!u.some(S=>S.sawExpired),solvent:!u.some(S=>S.sawInsolvent)};let k;const j=[];if(g.length===0)h.some(S=>S.gasFunded||S.balanceUnknown)?k="eligible":(k="fallthrough-no-funds",j.push("every approved signing wallet is out of gas"));else if(m.length===0&&y.length>0)k="unknown";else{const S=u.some(A=>(A.covered||A.hasTrac)&&A.gasFunded);!S&&y.length>0?k="unknown":(k=S?"fallthrough":"fallthrough-no-funds",j.push(`${h.length} of ${u.length} signing wallets approved`),u.some(A=>A.sawExpired)&&j.push("a PCA has expired or been fully swept"),u.some(A=>A.sawInsolvent)&&j.push("a PCA is out of budget"),b.gasFunded||j.push("a signing wallet has no gas"),g.some(A=>A.inconclusive)&&j.push("a wallet’s PCA coverage couldn’t be checked"),g.some(A=>A.balanceUnknown)&&j.push("a signing wallet’s balance couldn’t be checked"))}const N=h.reduce((S,A)=>(A.discountBps??-1)>((S==null?void 0:S.discountBps)??-1)?A:S,void 0);return{verdict:k,loading:l,accountId:N==null?void 0:N.accountId,discountBps:N==null?void 0:N.discountBps,accountUntracked:N==null?void 0:N.coverUntracked,ownerPublish:d,anyGasFunded:u.some(S=>S.gasFunded||S.balanceUnknown),reasons:j,conditions:b,wallets:u}},[s,l,n.length])}function _D(e){return e.verdict==="fallthrough-no-funds"&&!(e.ownerPublish&&e.anyGasFunded)}function RD(e){const t=Pl(u=>u.trackedIds),n=TD(e,3e4),a=_D(n),s="Publish will fail — no signing wallet can fund it (coverage or gas).",l=t.length>0;return{blocked:a,reason:s,chipVisible:l,eligibility:n}}function OD({verdict:e,accountId:t,discountBps:n,accountUntracked:a,ownerPublish:s,id:l}){return o.jsx("div",{className:"v10-pca-publish-chip",id:l,"data-testid":"pca-publish-eligibility",children:o.jsx(qO,{variant:"chip",verdict:e,accountId:t,discountBps:n,accountUntracked:a,ownerPublish:s})})}function ev({title:e,agent:t,footnote:n,dismissed:a,onDismiss:s,children:l}){return o.jsxs("div",{className:`v10-gen-widget ${a?"dissolved":""}`,children:[o.jsxs("div",{className:"v10-gen-widget-header",children:[o.jsx("span",{className:"v10-gen-widget-title",children:e}),o.jsxs("div",{className:"v10-gen-widget-right",children:[t&&o.jsxs("span",{className:"v10-gen-widget-agent",children:[o.jsx("span",{className:"v10-gen-widget-agent-dot"}),t]}),s&&o.jsx("button",{className:"v10-gen-widget-dismiss",onClick:s,children:"✕"})]})]}),o.jsx("div",{className:"v10-gen-widget-body",children:l}),n&&o.jsx("div",{className:"v10-gen-widget-footnote",children:n})]})}function LD({entities:e}){const t=Ua(),n=w.useMemo(()=>{const a=new Map;for(const s of e){const{icon:l,type:u}=Bd(s,t),d=a.get(u);d?d.count++:a.set(u,{icon:l,count:1})}return[...a.entries()].sort((s,l)=>l[1].count-s[1].count)},[e,t]);return n.length===0?null:o.jsx(ev,{title:"Entity Types",children:o.jsx(Fd,{compact:!0,items:n.map(([a,{icon:s,count:l}])=>({id:a,label:`${s} ${a}`,value:l}))})})}function MD({entities:e,entityCount:t,triples:n,layer:a}){const s=w.useMemo(()=>e.filter(d=>d.properties.has("http://dkg.io/ontology/sourceContentType")).length,[e]),l=w.useMemo(()=>e.reduce((d,f)=>d+f.connections.length,0),[e]),u=e.length>0?(l/e.length).toFixed(1):"0";return o.jsx(ev,{title:"Layer Stats",children:o.jsx(Fd,{compact:!0,layer:a,items:[{id:"entities",label:ia(a,t),value:t},{id:"triples",label:"Triples",value:n},{id:"connections",label:"Connections",value:l},{id:"avg",label:"Avg. connections / entity",value:u},...s>0?[{id:"documents",label:"Documents",value:s}]:[]]})})}function Nj(e,t){const[n,a]=w.useState(!1),[s,l]=w.useState(null),[u,d]=w.useState(null),f=w.useCallback(async(h,g)=>{a(!0),d(null),l(null);try{const m=await h();l(m),e==null||e({ok:!0,text:m}),t==null||t()}catch(m){const y=g(m);d(y),e==null||e({ok:!1,text:y})}finally{a(!1)}},[e,t]);return{busy:n,result:s,error:u,run:f}}function Ej({title:e,footnote:t,context:n,result:a,error:s,extras:l,children:u}){return o.jsxs(ev,{title:e,footnote:t,children:[o.jsx("div",{className:"v10-decision-context",style:{marginBottom:10},children:n}),a&&o.jsxs("div",{"data-testid":"layer-action-result",style:{fontSize:11,color:"var(--text-success)",marginBottom:8},children:["✓ ",a]}),s&&o.jsxs("div",{"data-testid":"layer-action-error",style:{fontSize:11,color:"var(--text-danger)",marginBottom:8},children:["✕ ",s]}),l,o.jsx("div",{className:"v10-decision-actions",children:u})]})}function DD({count:e,contextGraphId:t,onComplete:n,onResult:a}){const{busy:s,result:l,error:u,run:d}=Nj(a,n),f=w.useCallback(()=>{let m=null;d(async()=>{const y=await Ql(t,"wm");let b=0;for(const j of y)m=j.name,(await lo(t,j.name,j.subGraph?{subGraphName:j.subGraph}:{})).promotedCount===0&&(b+=1);const k=y.length-b;if(k>0){const j=b>0?` (${b} already shared or still committing)`:"";return`Shared ${k} complete Knowledge Asset${k!==1?"s":""} to Shared Memory${j}`}return"No Knowledge Assets were newly shared — all were already in Shared Memory or still committing."},y=>{const b=co(m??"an assertion",y);return b?b.message:(y==null?void 0:y.message)??"Action failed"})},[t,d]);if(e===0)return null;const h="#f59e0b",g=ia("wm",e).toLowerCase();return o.jsx(Ej,{title:"Share complete Knowledge Assets",footnote:"Shares each complete owning Knowledge Asset atomically to Shared Working Memory.",context:o.jsxs(o.Fragment,{children:["The displayed ",g," will be shared through their complete owning Knowledge Assets for collaborative review."]}),result:l,error:u,children:o.jsx("button",{"data-testid":"widget-promote-all-btn",className:"v10-decision-btn approve",style:{borderColor:`${h}50`,color:"var(--text-warning)",background:`${h}15`,opacity:s?.5:1},disabled:s,onClick:f,children:s?"...":"✓ Share Complete KAs → Shared"})})}function zD({count:e,contextGraphId:t,onComplete:n,onResult:a}){const[s,l]=w.useState(null),{busy:u,result:d,error:f,run:h}=Nj(a,n),g=RD(t),m=w.useId(),y=w.useId(),b=[g.chipVisible?m:null,g.blocked?y:null].filter(Boolean).join(" ")||void 0,k=w.useCallback(()=>{g.blocked||h(async()=>{l(null);const N=await Ql(t,"swm"),S=await Tg(t,N);if(S.published>0){const A=S.failures.length?` (${S.failures.length} assertion${S.failures.length===1?"":"s"} could not be published)`:"",E=S.partial>0?` — ⚠ ${S.partial}: ${Il(S.partialError)}`:"";return l(S.convictionCostCovered??null),`Published ${S.published} knowledge asset${S.published!==1?"s":""} to Verifiable Memory${A}${E}`}if(N.length===0)return"Nothing to publish — promote assertions to Shared Memory first.";throw new Error(S.failures[0]?`${S.failures[0].name}: ${S.failures[0].error}`:"Publish failed")},N=>(N==null?void 0:N.message)??"Action failed")},[t,h,g.blocked]);if(e===0)return null;const j=ia("swm",e).toLowerCase();return o.jsx(Ej,{title:"Publish",footnote:`Moves ${j} from this layer to Verifiable Memory.`,context:o.jsxs(o.Fragment,{children:[e," ",j," in this layer can be published to Verifiable Memory on-chain."]}),result:d,error:f,extras:o.jsxs(o.Fragment,{children:[o.jsx(WS,{convictionCostCovered:s}),g.chipVisible&&o.jsx(OD,{...g.eligibility,id:m}),g.blocked&&o.jsx("span",{id:y,className:"v10-sr-only",children:g.reason})]}),children:o.jsx("button",{"data-testid":"widget-publish-vm-btn",className:"v10-decision-btn primary-cta publish-vm",style:{opacity:u||g.blocked?.5:1},disabled:u,"aria-disabled":g.blocked||void 0,title:g.blocked?g.reason:void 0,"aria-describedby":b,onClick:k,children:u?"...":"◉ Publish to Verifiable Memory"})})}function $D({layer:e,entities:t,entityCount:n,tripleCount:a,contextGraphId:s,onComplete:l}){const[u,d]=w.useState(null),f=u&&o.jsxs("div",{"data-testid":u.ok?"layer-action-result":"layer-action-error",style:{fontSize:11,color:u.ok?"var(--text-success)":"var(--text-danger)",marginBottom:8},children:[u.ok?"✓":"✕"," ",u.text]});return n===0?o.jsxs("div",{className:"v10-layer-widgets-strip empty",children:[f,o.jsx(ln,{compact:!0,tone:e,icon:zn[e].icon,title:`No ${ia(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."})]}):o.jsxs("div",{className:"v10-layer-widgets-strip",children:[o.jsxs("div",{className:"v10-layer-widgets-strip-stats",children:[o.jsx(MD,{entities:t,entityCount:n,triples:a,layer:e}),o.jsx(LD,{entities:t})]}),(e==="wm"||e==="swm")&&s&&o.jsx("div",{className:"v10-layer-widgets-strip-action",children:e==="wm"?o.jsx(DD,{count:n,contextGraphId:s,onComplete:l,onResult:d}):o.jsx(zD,{count:n,contextGraphId:s,onComplete:l,onResult:d})})]})}const tv="doc:";function ID(e,t,n){return`${tv}${e}|${t}|${n}`}function PD(e,t,n){return e?{ref:e,contentType:"text/markdown"}:t?{ref:t,contentType:n}:{ref:void 0,contentType:n}}function UD(e){const t=e.slice(tv.length),n=t.indexOf("|"),a=t.lastIndexOf("|");return n<0?{docRef:t,contentType:""}:{docRef:t.slice(n+1,a),contentType:t.slice(a+1)}}function nv(e,t){if(e.length<=t)return e;const n=t-1,a=Math.ceil(n/2),s=n-a;return`${e.slice(0,a)}…${e.slice(-s)}`}const BD={working:{layerKey:"wm",icon:"◇",label:"Working"},shared:{layerKey:"swm",icon:"◈",label:"Shared"},verified:{layerKey:"vm",icon:"◉",label:"Verifiable"}};function Aj({entities:e,layerKey:t,layerIcon:n,onSelectEntity:a,onOpenAgent:s,externallySorted:l=!1,sortLabel:u,headerExtra:d,timestampPredicate:f,perEntityTrustBadge:h=!1}){const g=Ua(),m=cs(),y=ia(t,e.length).toLowerCase(),b=w.useMemo(()=>{if(l)return e;const N=[...e];return N.sort((S,A)=>{const E=S.tripleCount??0;return(A.tripleCount??0)-E}),N},[e,l]),k=t==="vm"?"Verifiable":t==="swm"?"Shared":"Working";if(e.length===0)return o.jsx("div",{className:"v10-entity-list empty",children:o.jsx(ln,{compact:!0,tone:t,icon:n,title:`No ${ia(t,2).toLowerCase()} yet`,description:`This view will fill when matching ${ia(t,2).toLowerCase()} are available.`})});const j=u??(l?"click to open":"sorted by triples · click to open");return o.jsxs("div",{className:"v10-entity-list",children:[o.jsxs("div",{className:"v10-entity-list-header",children:[o.jsxs("span",{className:"v10-entity-list-count",children:[b.length," ",y]}),o.jsx("span",{className:"v10-entity-list-hint",children:j}),d&&o.jsx("span",{className:"v10-entity-list-extra",children:d})]}),b.map(N=>{const{icon:S,type:A}=Bd(N,g),E=N.tripleCount??0,T=Ud(N),U=T?m==null?void 0:m.get(T):null,_=f?Qu(N,f):null;return o.jsxs("div",{className:"v10-entity-card",onClick:z=>{z.stopPropagation(),a(N.uri)},children:[o.jsx("span",{className:"v10-entity-card-icon",children:S}),o.jsxs("div",{className:"v10-entity-card-main",children:[o.jsx("div",{className:"v10-entity-card-title",children:N.label}),o.jsxs("div",{className:"v10-entity-card-meta",children:[(U||T)&&o.jsx(ts,{agent:U??void 0,fallbackUri:T??void 0,size:"sm",onOpenAgent:s}),A&&A!=="Entity"&&o.jsxs("span",{className:"v10-entity-type-pill",children:[S," ",A]}),_!=null&&o.jsx("span",{className:"v10-entity-card-timestamp",title:new Date(_).toLocaleString(),children:X4(_)}),o.jsxs("span",{className:"v10-entity-card-triples",children:[E," triples"]})]})]}),h?(()=>{const z=BD[N.trustLevel];return o.jsxs("span",{className:`v10-trust-badge ${z.layerKey}`,title:`${z.label} Memory`,children:[z.icon," ",z.label]})})():o.jsxs("span",{className:`v10-trust-badge ${t}`,children:[n," ",k]})]},N.uri)})]})}function FD({layer:e,entities:t,tripleCount:n,layerTriples:a,contextGraphId:s,memory:l,activeTab:u,onTabChange:d,onSelectEntity:f,onNodeClick:h,footer:g,swmAttribution:m}){var T;const y=zn[e],b=ia(e,2),k=((T=l.layerStatus)==null?void 0:T.vm)??(l.loading?"loading":l.error?"error":"ok"),j=e==="vm"&&k==="loading"&&t.length===0,N=e==="vm"&&k==="error"&&t.length===0,S=e==="vm"&&k==="ok"&&t.length===0,A=l.counts[e],E=U=>_=>{_.stopPropagation(),d(U)};return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"v10-layer-expand-tabs",children:[o.jsx("button",{className:`v10-layer-expand-tab ${u==="items"?"active":""}`,onClick:E("items"),children:b}),e!=="vm"&&o.jsx("button",{className:`v10-layer-expand-tab ${u==="assertions"?"active":""}`,onClick:E("assertions"),children:"Assertions"}),o.jsx("button",{className:`v10-layer-expand-tab ${u==="graph"?"active":""}`,onClick:E("graph"),children:"Graph"}),o.jsx("button",{className:`v10-layer-expand-tab ${u==="docs"?"active":""}`,onClick:E("docs"),children:"Documents"})]}),u==="items"&&o.jsxs("div",{className:"v10-layer-expand-body entities-tab","data-cg-scroll-key":`layer:${e}:items`,children:[e==="vm"&&!j&&!N&&o.jsx(HD,{entities:t,tripleCount:n,contextGraphId:s}),j?o.jsx("div",{className:"v10-layer-widgets-strip empty",children:o.jsx(ln,{compact:!0,tone:"vm",icon:zn.vm.icon,title:"Loading Verifiable Memory...",description:"Knowledge Assets are being read from the verified layer."})}):N?o.jsx("div",{className:"v10-layer-widgets-strip empty",children:o.jsx(ln,{compact:!0,tone:"vm",icon:zn.vm.icon,title:"Verifiable Memory status unavailable.",description:"This node could not read the verified layer right now."})}):!S&&o.jsxs(o.Fragment,{children:[o.jsx($D,{layer:e,entities:t,entityCount:A,tripleCount:n,contextGraphId:s,onComplete:l.refresh}),o.jsx(Aj,{entities:t,layerKey:e,layerIcon:y.icon,onSelectEntity:f})]}),g]}),u==="assertions"&&e!=="vm"&&o.jsx("div",{className:"v10-layer-expand-body full-width",children:o.jsx(qD,{contextGraphId:s,layer:e,onComplete:l.refresh,scrollKey:`layer:${e}:assertions`})}),u==="graph"&&o.jsx("div",{className:"v10-layer-expand-body full-width","data-cg-scroll-key":`layer:${e}:graph`,children:o.jsx(Cj,{layer:e,triples:a,onNodeClick:h,contextGraphId:s,swmAttribution:e==="swm"?m:void 0,layerEntities:t})}),u==="docs"&&o.jsx("div",{className:"v10-layer-expand-body full-width",children:o.jsx(Tj,{entities:t,contextGraphId:s,scrollKey:`layer:${e}:docs`})})]})}function HD({entities:e,tripleCount:t,contextGraphId:n}){const a=e.length,s=new Set;for(const u of e)for(const d of u.types)s.add(d);const l=s.size;return a===0?o.jsxs("div",{className:"v10-vm-hero v10-vm-hero-empty",children:[o.jsxs("div",{className:"v10-vm-hero-title",children:[o.jsx("span",{className:"v10-vm-hero-badge",children:"◉ Verifiable Memory"}),o.jsxs("div",{className:"v10-vm-hero-heading",children:[o.jsx("span",{className:"v10-vm-hero-headline",children:"Nothing published yet"}),o.jsxs("span",{className:"v10-vm-hero-context",title:n,children:["Context Graph: ",n]})]})]}),o.jsx(ln,{compact:!0,className:"v10-vm-empty-state",tone:"vm",icon:zn.vm.icon,title:"No Knowledge Assets yet.",description:"Publish complete Knowledge Assets from Shared Working Memory to verify them on-chain."})]}):o.jsxs("div",{className:"v10-vm-hero",children:[o.jsxs("div",{className:"v10-vm-hero-title",children:[o.jsx("span",{className:"v10-vm-hero-badge",children:"◉ Verifiable Memory"}),o.jsxs("div",{className:"v10-vm-hero-heading",children:[o.jsx("span",{className:"v10-vm-hero-headline",children:"On-chain anchored · cryptographically signed"}),o.jsxs("span",{className:"v10-vm-hero-context",title:n,children:["Context Graph: ",n]})]})]}),o.jsx(Fd,{className:"v10-vm-hero-stats",layer:"vm",items:[{id:"assets",value:a,label:"Knowledge Assets"},{id:"triples",value:t.toLocaleString(),label:"Verifiable Triples"},{id:"types",value:l,label:"Entity Types"}]}),o.jsxs("div",{className:"v10-vm-hero-strip",children:[o.jsxs("div",{className:"v10-vm-hero-chip",title:"Multi-agent endorsement",children:[o.jsx("span",{className:"v10-vm-hero-chip-dot",style:{background:"#22c55e"}}),"Consensus"]}),o.jsxs("div",{className:"v10-vm-hero-chip",title:"Published to the DKG blockchain anchor",children:[o.jsx("span",{className:"v10-vm-hero-chip-dot",style:{background:"#3b82f6"}}),"On-chain"]}),o.jsxs("div",{className:"v10-vm-hero-chip",title:"Each contribution bound to a DID",children:[o.jsx("span",{className:"v10-vm-hero-chip-dot",style:{background:"#a855f7"}}),"Agent Identity"]}),o.jsxs("div",{className:"v10-vm-hero-chip",title:"Tamper-evident via content hashing",children:[o.jsx("span",{className:"v10-vm-hero-chip-dot",style:{background:"#f59e0b"}}),"Content Hash"]})]})]})}function qD({contextGraphId:e,layer:t,onComplete:n,scrollKey:a}){const{data:s,loading:l,refresh:u}=lr(()=>Ql(e,t),[e,t],0),{data:d}=lr(()=>x_(e),[e,t],0),[f,h]=w.useState(null),[g,m]=w.useState(null),[y,b]=w.useState(null),k=w.useCallback(async E=>{h(E.graphUri),m(null),b(null);try{if(t==="wm"){const T=await lo(e,E.name,E.subGraph?{subGraphName:E.subGraph}:{}),U=_g(E.name,T);m(U.message)}else{const T=await Ag(e,E.name,E.subGraph?{subGraphName:E.subGraph}:{});m(T.contextGraphError?`Published ${E.name} on-chain — ⚠ ${Il(T.contextGraphError)}`:`Published ${E.name} to Verifiable Memory`)}u(),n()}catch(T){const U=co(E.name,T);b(U?U.message:(T==null?void 0:T.message)??"Action failed")}finally{h(null)}},[e,t,u,n]),j=w.useCallback(async()=>{if(!(s!=null&&s.length))return;h("__all__"),m(null),b(null);let E=null;try{if(t==="wm"){let T=0;for(const _ of s)E=_.name,(await lo(e,_.name,_.subGraph?{subGraphName:_.subGraph}:{})).promotedCount===0&&(T+=1);const U=s.length-T;if(U>0){const _=T>0?` (${T} already shared or still committing)`:"";m(`Shared ${U} complete Knowledge Asset${U!==1?"s":""}${_}`)}else m("No Knowledge Assets were newly shared — all were already in Shared Memory or still committing.")}else{const T=await Tg(e,s);if(T.published>0){const U=T.failures.length?` (${T.failures.length} could not be published)`:"",_=T.partial>0?` — ⚠ ${T.partial}: ${Il(T.partialError)}`:"";m(`Published ${T.published} knowledge asset${T.published!==1?"s":""} to Verifiable Memory${U}${_}`)}else throw new Error(T.failures[0]?`${T.failures[0].name}: ${T.failures[0].error}`:"Publish failed")}u(),n()}catch(T){const U=co(E??"selected assertion",T);b(U?U.message:(T==null?void 0:T.message)??"Action failed")}finally{h(null)}},[s,e,t,u,n]),N={flex:1,overflow:"auto"};if(l)return o.jsx("div",{className:"v10-layer-empty-shell",style:N,"data-cg-scroll-key":a,children:o.jsx(ln,{compact:!0,tone:t,icon:zn[t].icon,title:"Loading assertions..."})});if(!(s!=null&&s.length))return o.jsx("div",{className:"v10-layer-empty-shell",style:N,"data-cg-scroll-key":a,children:o.jsx(ln,{tone:t,icon:zn[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 S=t==="wm"?"Share Complete KA → Shared":"Publish to VM",A=t==="wm"?"Share Complete KAs → Shared":"Publish all to Verifiable Memory";return o.jsxs("div",{style:N,"data-cg-scroll-key":a,children:[o.jsxs("div",{style:{padding:"8px 16px",display:"flex",alignItems:"center",justifyContent:"space-between",borderBottom:"1px solid var(--border-subtle)"},children:[o.jsxs("span",{style:{fontSize:11,color:"var(--text-tertiary)"},children:[s.length," assertion",s.length!==1?"s":""]}),o.jsx("button",{className:`v10-layer-expand-footer-btn ${t==="wm"?"promote":"publish"}`,disabled:f!==null,onClick:j,style:{opacity:f==="__all__"?.5:1},children:f==="__all__"?"...":A})]}),g&&o.jsxs("div",{"data-testid":t==="wm"?"assertion-promote-result":"assertion-publish-result",style:{padding:"6px 16px",fontSize:11,color:"var(--text-success)"},children:["✓ ",g]}),y&&o.jsxs("div",{"data-testid":t==="wm"?"assertion-promote-result":"assertion-publish-result",style:{padding:"6px 16px",fontSize:11,color:"var(--text-danger)"},children:["✕ ",y]}),s.map(E=>o.jsxs("div",{className:"v10-item-row","data-testid":"assertion-list-row",children:[o.jsx("span",{className:"v10-item-icon",children:"▤"}),o.jsxs("div",{className:"v10-item-info",children:[o.jsx("div",{className:"v10-item-name",style:{fontFamily:"var(--font-mono)",fontSize:11},children:E.name}),(d==null?void 0:d[E.name])&&o.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:d[E.name],children:d[E.name]}),o.jsxs("div",{className:"v10-item-meta-row",children:[E.tripleCount!=null&&o.jsxs("span",{className:"v10-item-count",children:[E.tripleCount," triples"]}),E.subGraph&&o.jsxs("span",{className:"v10-item-count v10-item-subgraph",title:`In sub-graph: ${E.subGraph}`,children:["› ",nv(E.subGraph,18)]})]})]}),o.jsx("button",{"data-testid":"assertion-row-action",className:`v10-layer-expand-footer-btn ${t==="wm"?"promote":"publish"}`,disabled:f!==null,onClick:T=>{T.stopPropagation(),k(E)},style:{opacity:f===E.graphUri?.5:1,flexShrink:0},children:f===E.graphUri?"...":S})]},E.graphUri))]})}function GD({layer:e,memory:t,onNodeClick:n,onSelectEntity:a,contextGraphId:s,activeTab:l,onTabChange:u,swmAttribution:d}){const f=zn[e],h=w.useMemo(()=>t.entityList.filter(m=>m.trustLevel===f.trustLevel),[t.entityList,f.trustLevel]),g=W4(t,e);return o.jsxs("div",{className:"v10-layer-detail",children:[o.jsxs("div",{className:"v10-layer-detail-header",children:[o.jsx("span",{className:"v10-layer-detail-icon",style:{color:f.color},children:f.icon}),o.jsxs("div",{children:[o.jsx("div",{className:"v10-layer-detail-title",children:f.title}),o.jsx("div",{className:"v10-layer-detail-desc",children:f.desc})]}),o.jsx("div",{className:"v10-layer-detail-actions"})]}),o.jsx("div",{className:"v10-layer-detail-body",children:o.jsx(FD,{layer:e,entities:h,tripleCount:g.length,layerTriples:g,contextGraphId:s,memory:t,activeTab:l,onTabChange:u,onSelectEntity:a,onNodeClick:n,swmAttribution:d})})]})}function Tj({entities:e,contextGraphId:t,scrollKey:n}){const a=fn(u=>u.openTab),s=w.useMemo(()=>e.filter(u=>u.properties.has(Oh)),[e]),l=u=>{var y,b,k;const d=(y=u.connections.find(j=>j.predicate===S1))==null?void 0:y.targetUri,f=(b=u.connections.find(j=>j.predicate===j1))==null?void 0:b.targetUri,h=((k=u.properties.get(Oh))==null?void 0:k[0])??"",{ref:g,contentType:m}=PD(d,f,h);a({id:ID(t??"",g??u.uri,m),label:u.label,closable:!0,icon:"📄"})};return s.length===0?o.jsx("div",{className:"v10-docs-placeholder v10-layer-empty-shell",style:{flex:1},"data-cg-scroll-key":n,children:o.jsx(ln,{compact:!0,title:"No documents in this layer yet.",description:"Import a file to add document-backed entities."})}):o.jsx("div",{className:"v10-layer-detail-content","data-cg-scroll-key":n,children:o.jsx("div",{className:"v10-items-list",children:s.map(u=>{var m,y,b,k;const d=((m=u.properties.get(Oh))==null?void 0:m[0])??"",f=(y=u.connections.find(j=>j.predicate===S1||j.predicate===j1))==null?void 0:y.targetUri,h=f?e.find(j=>j.uri===f):void 0,g=((b=h==null?void 0:h.properties.get(C1))==null?void 0:b[0])??((k=u.properties.get(C1))==null?void 0:k[0]);return o.jsxs("div",{className:"v10-item-row",onClick:()=>l(u),children:[o.jsx("span",{className:"v10-item-icon",children:"📄"}),o.jsxs("div",{className:"v10-item-info",children:[o.jsx("div",{className:"v10-item-name",children:u.label}),o.jsxs("div",{className:"v10-item-meta-row",children:[d&&o.jsx("span",{className:"v10-item-type",children:d}),g&&o.jsxs("span",{className:"v10-item-count",children:["· ",Math.round(parseInt(g)/1024),"KB"]})]})]}),o.jsx("button",{className:"v10-item-promote-btn",onClick:j=>{j.stopPropagation(),l(u)},children:"Open →"})]},u.uri)})})})}function _j(e){return`SELECT ?g ?s ?p ?o WHERE {
1286
+ `)})(),k=o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"v10-activity-feed-layer",style:{color:m},title:`${e.layer} memory`,children:nD[e.layer]}),o.jsxs("span",{className:"v10-activity-feed-type",style:{"--type-color":g},children:[o.jsx("span",{className:"v10-activity-feed-type-icon",children:h}),o.jsx("span",{className:"v10-activity-feed-type-label",children:f})]}),o.jsx("span",{className:"v10-activity-feed-title-text",children:e.entity.label}),y&&o.jsx("span",{className:`v10-activity-feed-status status-${oD(y)}`,children:y}),(l||e.authorUri)&&o.jsx("span",{className:"v10-activity-feed-author",children:o.jsx(ts,{agent:l??void 0,fallbackUri:e.authorUri??void 0,size:"sm",onOpenAgent:s})}),o.jsx("span",{className:"v10-activity-feed-time",title:e.at?e.at.toLocaleString():"no timestamp",children:kj(e.at)})]});return e.clickable?o.jsx("button",{type:"button",className:"v10-activity-feed-row",onClick:()=>a(e.entity.uri),title:b,children:k}):o.jsx("div",{className:"v10-activity-feed-row v10-activity-feed-row-static",title:b,"aria-disabled":"true",children:k})}function sD(e){var n;const t=["http://dkg.io/ontology/decisions/status","http://dkg.io/ontology/tasks/status","http://dkg.io/ontology/github/state"];for(const a of t){const s=(n=e.properties.get(a))==null?void 0:n[0];if(s)return s}return null}function oD(e){switch(e){case"accepted":case"done":case"merged":return"good";case"proposed":case"in_progress":case"open":return"warn";case"rejected":case"superseded":case"blocked":case"cancelled":return"bad";default:return"neutral"}}const lD={wm:"working",swm:"shared",vm:"verified"};function cD(e){var y,b,k,j;const t=new Map;if(!e)return t;const n="http://dkg.io/ontology/decisions/status",a="http://dkg.io/ontology/tasks/status",s="http://dkg.io/ontology/tasks/priority",l="http://dkg.io/ontology/github/state",u="http://dkg.io/ontology/decisions/Decision",d="http://dkg.io/ontology/tasks/Task",f="http://dkg.io/ontology/github/PullRequest";let h=0,g=0,m=0;for(const N of e)if(N.types.includes(u))((y=N.properties.get(n))==null?void 0:y[0])==="proposed"&&h++;else if(N.types.includes(d)){const S=(b=N.properties.get(s))==null?void 0:b[0],A=(k=N.properties.get(a))==null?void 0:k[0];S==="p0"&&A!=="done"&&A!=="cancelled"&&g++}else N.types.includes(f)&&((j=N.properties.get(l))==null?void 0:j[0])==="open"&&m++;return h>0&&t.set("decisions",{label:`${h} proposed`,tone:"warn"}),g>0&&t.set("tasks",{label:`${g} p0`,tone:"danger"}),m>0&&t.set("github",{label:`${m} open`,tone:"info"}),t}const zh=({contextGraphId:e,profile:t,selected:n,onSelect:a,entities:s,layer:l,enabledScope:u,allTriplesTotal:d})=>{const[f,h]=Ve.useState([]),[g,m]=Ve.useState(!0),y=Ve.useMemo(()=>cD(s),[s]),b=Ve.useRef(0),k=Ve.useMemo(()=>u&&u.size>0&&u.size<3?new Set(u):u&&u.size>=3?null:l?new Set([lD[l]]):null,[u,l]),j=Ve.useMemo(()=>{if(!s)return null;const I=new Map;for(const H of s)if(!(k&&!k.has(H.trustLevel)))for(const B of H.subGraphs)I.set(B,(I.get(B)??0)+1);return I},[k,s]),N=Ve.useMemo(()=>{if(!s)return null;let I=0;for(const H of s)k&&!k.has(H.trustLevel)||I++;return I},[k,s]),S=Ve.useMemo(()=>{if(!s)return null;let I=0;for(const H of s)k&&!k.has(H.trustLevel)||H.subGraphs.size>0||I++;return I},[k,s]),A=Ve.useCallback(()=>{const I=++b.current;m(!0),Mg(e).then(H=>{I===b.current&&h(H.subGraphs??[])}).catch(()=>{}).finally(()=>{I===b.current&&m(!1)})},[e]);Ve.useEffect(()=>(A(),()=>{b.current++}),[A]),xo(e,A);const E=Ve.useMemo(()=>f.filter(Kg).map(I=>{const H=t.forSubGraph(I.name),B=j!==null?j.get(I.name)??0:I.entityCount;return{slug:I.name,icon:H.icon??"•",color:H.color??"#64748b",displayName:H.displayName??I.name,description:H.description??I.description,rank:H.rank??99,entityCount:B,tripleCount:I.tripleCount,layerScoped:j!==null}}).sort((I,H)=>I.rank-H.rank),[f,t,j]),U=S!==null&&S>0||n===$r;if(g&&E.length===0&&!U||E.length===0&&!U)return null;const _=N??E.reduce((I,H)=>I+H.entityCount,0),z=E.reduce((I,H)=>I+H.tripleCount,0),q={working:"Working Memory",shared:"Shared Working Memory",verified:"Verifiable Memory"},D=k?[...k].map(I=>q[I]).join(" + "):null,R=D?` in ${D}`:"",F=`Total distinct entities — includes those in named subgraphs (some may belong to more than one), plus Root entities not in any subgraph · ${_} entities${R}${D?"":` · ${d??z} triples`}`,K=`All — total distinct entities. Includes those in named subgraphs (some may belong to more than one), plus Root entities not in any subgraph. ${_} entities${R}.`;return o.jsxs("div",{className:"v10-subgraph-bar",children:[o.jsx("div",{className:"v10-subgraph-bar-label",children:"Subgraphs"}),o.jsxs("button",{type:"button",className:`v10-subgraph-chip${n===null?" active":""}`,onClick:()=>a(null),title:F,"aria-label":K,children:[o.jsx("span",{className:"v10-subgraph-chip-icon",children:"⊚"}),o.jsx("span",{className:"v10-subgraph-chip-label",children:"All"}),o.jsx("span",{className:"v10-subgraph-chip-count",children:_})]}),E.map(I=>{const H=y.get(I.slug);return o.jsxs("button",{type:"button",className:`v10-subgraph-chip${n===I.slug?" active":""}${H?" has-badge":""}`,onClick:()=>a(I.slug,l),title:`${I.displayName}${I.description?" · "+I.description:""} · ${I.entityCount} entities${R}${D?"":` · ${I.tripleCount} triples`}${H?" · "+H.label:""}`,style:{"--sg-color":I.color},children:[o.jsx("span",{className:"v10-subgraph-chip-icon",style:{color:I.color},children:I.icon}),o.jsx("span",{className:"v10-subgraph-chip-label",children:I.displayName}),o.jsx("span",{className:"v10-subgraph-chip-count",children:I.entityCount}),H&&o.jsxs("span",{className:`v10-subgraph-chip-badge tone-${H.tone}`,children:[o.jsx("span",{className:"v10-subgraph-chip-badge-dot"}),H.label]})]},I.slug)}),U&&(()=>{const I=S??0,H=n===$r;return o.jsxs("button",{type:"button",className:`v10-subgraph-chip v10-subgraph-chip-root${H?" active":""}`,"data-active":H,"data-count":I,onClick:()=>a($r,l),title:`Entities not in any subgraph (Context Graph root) · ${I} entities${R}`,"aria-label":"Entities not in any subgraph (Context Graph root)",children:[o.jsx("span",{className:"v10-subgraph-chip-icon",children:"⊘"}),o.jsx("span",{className:"v10-subgraph-chip-label",children:"Root"}),o.jsx("span",{className:"v10-subgraph-chip-count",children:I})]})})()]})},Xg="context-graph-primer",Sj={id:Xg,label:"What is a Context Graph?",closable:!0},jj={neutral:"var(--border-strong)",wm:"var(--layer-working, #64748b)",swm:"var(--layer-shared, #f59e0b)",vm:"var(--layer-verified, #22c55e)",danger:"var(--text-danger)",query:"#38bdf8",warning:"var(--text-warning)"};function ln({icon:e,title:t,description:n,actions:a=[],tone:s="neutral",compact:l=!1,inline:u=!1,className:d=""}){const f={"--v10-empty-accent":jj[s]};return o.jsxs("div",{className:["v10-empty-state",l?"compact":"",u?"inline":"",d].filter(Boolean).join(" "),"data-tone":s,style:f,children:[e&&o.jsx("div",{className:"v10-empty-state-icon","aria-hidden":"true",children:e}),o.jsxs("div",{className:"v10-empty-state-copy",children:[o.jsx("div",{className:"v10-empty-state-title",children:t}),n&&o.jsx("div",{className:"v10-empty-state-desc",children:n}),a.length>0&&o.jsx("div",{className:"v10-empty-state-actions",children:a.map(h=>o.jsx("button",{type:"button",className:`v10-empty-state-action ${h.variant??"secondary"}`,onClick:h.onClick,"data-testid":h.testId,children:h.label},h.label))})]})]})}function Fd({items:e,layer:t,compact:n=!1,className:a=""}){const s=t?{"--v10-stat-accent":jj[t]}:void 0;return o.jsx("div",{className:["v10-stat-strip",n?"compact":"",a].filter(Boolean).join(" "),"data-layer":t,style:s,children:e.map((l,u)=>o.jsxs("div",{className:"v10-stat-strip-cell","data-stat-id":l.id,title:l.tooltip,children:[o.jsx("span",{className:"v10-stat-strip-label",children:l.label}),o.jsx("span",{className:"v10-stat-strip-value",children:l.value}),l.hint&&o.jsx("span",{className:"v10-stat-strip-hint",children:l.hint})]},l.id??u))})}const Jg=w.lazy(()=>gt(()=>import("./index-CwRQnNYh.js").then(e=>e.h),__vite__mapDeps([0,1])).then(e=>({default:e.RdfGraph}))),uD="http://www.w3.org/1999/02/22-rdf-syntax-ns#type",dD=new Map(Hg.map((e,t)=>[e,t]));function Dm(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 Da(e){const t=e.trim();return t.startsWith("<")&&t.endsWith(">")?t.slice(1,-1):t}function pD(e){const t=new Set,n=new Map,a=new Map,s=new Map;for(const d of e){const f=Da(d.subject);t.add(f);const h=dD.get(d.predicate);if(h!==void 0){const m=Pd(d.object).trim();if(m){const y=s.get(f);(y===void 0||h<y)&&(a.set(f,m),s.set(f,h))}}if(Da(d.predicate)===uD||!Dm(d.object))continue;const g=Da(d.object);n.set(f,(n.get(f)??0)+1),n.set(g,(n.get(g)??0)+1)}const l=[...t].filter(d=>(n.get(d)??0)===0).map(d=>({uri:d,label:a.get(d)??dj(void 0,d)})).sort((d,f)=>d.label.localeCompare(f.label));if(l.length===0)return{canvasTriples:e,singletonItems:l};const u=new Set(l.map(d=>d.uri));return{canvasTriples:e.filter(d=>!u.has(Da(d.subject))&&!u.has(Da(d.object))),singletonItems:l}}function fD(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 hD({items:e,onSelect:t}){return e.length===0?null:o.jsxs("div",{className:"v10-graph-singleton-shelf","aria-label":"Standalone entities without visible links",children:[o.jsxs("div",{className:"v10-graph-singleton-head",title:"Entities with no visible links are grouped here to keep the graph readable.",children:[o.jsx("span",{children:"Standalone entities"}),o.jsx("span",{children:e.length})]}),o.jsx("div",{className:"v10-graph-singleton-list",children:e.map(({uri:n,label:a})=>o.jsx("button",{type:"button",className:"v10-graph-singleton-item",title:n,onClick:()=>t==null?void 0:t(n),children:a},n))})]})}const mD=2500;function M1(e,t=mD){if(e.length<=t)return e;const n=new Map;for(const u of e)n.set(u.subject,(n.get(u.subject)??0)+1);const a=[...n.entries()].sort((u,d)=>d[1]-u[1]).map(([u])=>u),s=new Set;let l=0;for(const u of a){const d=n.get(u)??0;l+d>t||(s.add(u),l+=d)}return s.size===0&&a.length>0&&s.add(a[0]),e.filter(u=>s.has(u.subject)).slice(0,t)}function Xu({title:e,scopeLabel:t,tone:n,className:a,rail:s,overlay:l,showScopeLabel:u=!0,singletonItems:d=[],onSingletonClick:f,renderGraph:h}){const[g,m]=w.useState(!1);w.useEffect(()=>{if(!g)return;const k=j=>{j.key==="Escape"&&m(!1)};return document.addEventListener("keydown",k),()=>document.removeEventListener("keydown",k)},[g]);const y=o.jsx("button",{type:"button",className:`v10-graph-expand-btn${u?"":" in-canvas"}`,onClick:()=>m(!0),title:`Expand ${e}`,"aria-label":`Expand ${e}`,children:"⤢"}),b=k=>o.jsxs(o.Fragment,{children:[u&&!k&&o.jsxs("div",{className:"v10-graph-shell-bar",children:[o.jsx("div",{className:"v10-graph-scope",title:t,children:t}),y]}),o.jsxs("div",{className:"v10-graph-body",children:[o.jsxs("div",{className:"v10-graph-canvas",children:[!u&&!k&&y,o.jsx("div",{className:"v10-graph-view",children:h(k)}),l&&o.jsx("div",{className:"v10-graph-overlay",children:l}),o.jsx(hD,{items:d,onSelect:f})]}),s&&o.jsx("aside",{className:"v10-graph-rail",children:s})]})]});return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:`v10-graph-shell v10-graph-shell-${n}${a?` ${a}`:""}`,children:!g&&b(!1)}),g&&o.jsx("div",{className:"v10-graph-expanded-backdrop",role:"dialog","aria-modal":"true","aria-label":`${e} expanded`,onClick:k=>{k.target===k.currentTarget&&m(!1)},children:o.jsxs("div",{className:`v10-graph-expanded-panel v10-graph-shell-${n}`,children:[o.jsxs("div",{className:"v10-graph-expanded-head",children:[o.jsxs("div",{children:[o.jsx("div",{className:"v10-graph-expanded-title",children:e}),o.jsx("div",{className:"v10-graph-expanded-subtitle",children:t})]}),o.jsx("button",{type:"button",className:"v10-graph-expanded-close",onClick:()=>m(!1),"aria-label":`Close expanded ${e}`,children:"×"})]}),o.jsx("div",{className:"v10-graph-expanded-body",children:b(!0)})]})})]})}function Cj({layer:e,triples:t,onNodeClick:n,contextGraphId:a,scopeLabel:s,trustLegendActiveLayer:l,title:u,scopeEntities:d,swmAttribution:f,layerEntities:h,nodeColorsOverride:g}){const{title:m}=zn[e],y=u??m,b=Vn(L=>L.theme),k=w.useMemo(()=>{if(e!=="vm")return;const L=new Set;for(const P of t)L.add(P.subject),Dm(P.object)&&L.add(P.object);return L},[t,e]),{anchors:j,decorationTriples:N}=L4(e==="vm"&&a?a:void 0,k),S=wj(e==="swm"&&a&&!f?a:void 0),A=f??S,E=w.useMemo(()=>{if(!h||h.length===0)return t;const L=new Set;for(const P of h)L.add(bt(P.uri));return hd(t,L)},[t,h]),T=w.useMemo(()=>{const L=new Set,P=[],G=O=>{const ne=`${O.subject}|${O.predicate}|${O.object}`;L.has(ne)||(L.add(ne),P.push({subject:O.subject,predicate:O.predicate,object:O.object}))};for(const O of E)G(O);for(const O of N)G(O);return P},[E,N]),U=T,_=w.useMemo(()=>{const L=e==="swm"?A.nodeColors:void 0;if(!(!L&&!g))return L?g?{...L,...g}:L:g},[e,A.nodeColors,g]),z=w.useMemo(()=>q4(e,_),[e,_]),{canvasTriples:q,singletonItems:D}=w.useMemo(()=>pD(U),[U]),R=w.useMemo(()=>{if(!d||d.length===0)return D;const L=new Set(D.map(G=>Da(G.uri)));for(const G of q)L.add(Da(G.subject)),Dm(G.object)&&L.add(Da(G.object));const P=[];for(const G of d){const O=Da(G.uri);L.has(O)||(L.add(O),P.push({uri:O,label:G.label||dj(void 0,O)}))}return P.length===0?D:[...D,...P].sort((G,O)=>G.label.localeCompare(O.label))},[D,q,d]),$=`${a??"context"}:${e}`,F=e==="swm"&&!!a&&A.loading,K=`${y} graph`,I=s??fD(e),H=l===null&&!!s,B=l===null?void 0:l??e,Q=e==="vm"&&j.length>0||e==="swm"&&A.palette.length>0?o.jsxs(o.Fragment,{children:[e==="vm"&&j.length>0&&o.jsx(vD,{anchors:j}),e==="swm"&&A.palette.length>0&&o.jsx(gD,{palette:A.palette,conflicts:A.conflicts.length})]}):null,V=w.useMemo(()=>({name:`${$}:${b}`,palette:b}),[$,b]);return T.length===0&&R.length===0?o.jsx(Xu,{title:K,scopeLabel:I,tone:e,className:"v10-graph-view-fill",showScopeLabel:H,renderGraph:()=>o.jsx("div",{className:"v10-layer-empty-shell",children:o.jsx(ln,{compact:!0,tone:e,icon:zn[e].icon,title:`No triples in ${y}`,description:"The graph will appear when this layer has connected triples."})})}):F?o.jsx(Xu,{title:K,scopeLabel:I,tone:"swm",className:"v10-graph-view-fill",showScopeLabel:H,renderGraph:()=>o.jsx("div",{className:"v10-layer-empty-shell",children:o.jsx(ln,{compact:!0,tone:"swm",icon:zn.swm.icon,title:"Loading Shared Working Memory attribution...",description:"Agent colors are being prepared before the graph renders."})})}):o.jsx(Xu,{title:K,scopeLabel:I,tone:e,className:"v10-graph-view-fill",overlay:Q,showScopeLabel:H,singletonItems:R,onSingletonClick:L=>n==null?void 0:n(B?{id:L,trustLayer:B}:{id:L}),renderGraph:L=>q.length>0?o.jsx(w.Suspense,{fallback:o.jsx("span",{className:"v10-graph-placeholder",children:"Loading graph..."}),children:o.jsx(Jg,{data:q,format:"triples",options:z,viewConfig:V,style:{position:"absolute",inset:0,width:"100%",height:"100%"},onNodeClick:B?P=>n==null?void 0:n({...P,trustLayer:B}):n,initialFit:!0},`${$}:${L?"expanded":"inline"}:${q.length}`)}):o.jsx("div",{className:"v10-graph-placeholder v10-graph-placeholder-centered",children:"Connected graph appears when this layer has linked entities."})})}function gD({palette:e,conflicts:t}){return o.jsxs("div",{className:"v10-swm-legend","aria-label":"SWM attribution legend",children:[o.jsxs("div",{className:"v10-swm-legend-row v10-swm-legend-head",children:[o.jsx("span",{children:"SWM attribution"}),o.jsxs("span",{className:"v10-swm-legend-count",children:[e.length," agent",e.length===1?"":"s"]})]}),e.slice(0,8).map(n=>o.jsxs("div",{className:"v10-swm-legend-row",title:n.agent,children:[o.jsx("span",{className:"v10-swm-legend-swatch",style:{background:n.color}}),o.jsx("span",{className:"v10-swm-legend-label",children:n.label}),o.jsx("span",{className:"v10-swm-legend-metric",children:n.entityCount})]},n.agent)),t>0&&o.jsxs("div",{className:"v10-swm-legend-row v10-swm-legend-conflict",children:[o.jsx("span",{className:"v10-swm-legend-swatch",style:{background:"#f59e0b"},children:"!"}),o.jsx("span",{className:"v10-swm-legend-label",children:"In review"}),o.jsx("span",{className:"v10-swm-legend-metric",children:t})]})]})}function vD({anchors:e}){var s;const t=w.useMemo(()=>{const l=new Set;for(const u of e)for(const d of u.agents)l.add(d);return l.size},[e]),n=(s=e[0])==null?void 0:s.publishedAt,a=(()=>{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 o.jsxs("div",{className:"v10-vm-legend","aria-label":"Verifiable Memory legend",children:[o.jsxs("div",{className:"v10-vm-legend-row v10-vm-legend-head",children:[o.jsx("span",{children:"VM provenance layer"}),o.jsxs("span",{className:"v10-vm-legend-count",children:[e.length," anchor",e.length===1?"":"s"]})]}),o.jsxs("div",{className:"v10-vm-legend-row",children:[o.jsx("span",{className:"v10-vm-legend-swatch",style:{background:"#f5a524"},children:"◉"}),o.jsx("span",{className:"v10-vm-legend-label",children:"On-chain anchor"})]}),o.jsxs("div",{className:"v10-vm-legend-row",children:[o.jsx("span",{className:"v10-vm-legend-swatch",style:{background:"#c084fc"},children:"◈"}),o.jsxs("span",{className:"v10-vm-legend-label",children:["Agent identity (",t,")"]})]}),o.jsxs("div",{className:"v10-vm-legend-row",children:[o.jsx("span",{className:"v10-vm-legend-swatch",style:{background:"#4ade80"},children:"—"}),o.jsx("span",{className:"v10-vm-legend-label",children:"Signed / anchored edge"})]}),a&&o.jsxs("div",{className:"v10-vm-legend-foot",children:["Latest: ",a]})]})}function yD({active:e,counts:t,onSwitch:n,onShare:a,onImport:s,onRefresh:l}){const[u,d]=w.useState(!1),f=w.useRef(null),h=g=>{d(!1),n(g)};return w.useEffect(()=>{if(!u)return;const g=m=>{var b;const y=m.target;y&&((b=f.current)!=null&&b.contains(y))||d(!1)};return document.addEventListener("pointerdown",g),()=>document.removeEventListener("pointerdown",g)},[u]),o.jsxs("div",{className:"v10-layer-switcher",children:[o.jsxs("button",{className:`v10-layer-switch-btn ${e==="overview"?"active":""}`,"data-layer":"overview","aria-label":"Overview",title:"Overview",onClick:()=>h("overview"),children:[o.jsx("span",{className:"v10-layer-switch-icon",children:"◎"}),o.jsx("span",{className:"v10-layer-switch-label",children:"Overview"})]}),o.jsx("span",{className:"v10-layer-switch-separator","aria-hidden":"true"}),o.jsxs("button",{className:`v10-layer-switch-btn ${e==="wm"?"active":""}`,"data-layer":"wm","aria-label":"Working Memory",title:"Working Memory",onClick:()=>h("wm"),children:[o.jsx("span",{className:"v10-layer-switch-icon",style:{color:"#64748b"},children:"◇"}),o.jsx("span",{className:"v10-layer-switch-label v10-layer-switch-label-full",children:"Working Memory"}),o.jsx("span",{className:"v10-layer-switch-label v10-layer-switch-label-compact",children:"WM"}),t.wm>0&&o.jsx("span",{className:"v10-layer-switch-count",children:t.wm})]}),o.jsxs("button",{className:`v10-layer-switch-btn ${e==="swm"?"active":""}`,"data-layer":"swm","aria-label":"Shared Working Memory",title:"Shared Working Memory",onClick:()=>h("swm"),children:[o.jsx("span",{className:"v10-layer-switch-icon",style:{color:"#f59e0b"},children:"◈"}),o.jsx("span",{className:"v10-layer-switch-label v10-layer-switch-label-full",children:"Shared Working Memory"}),o.jsx("span",{className:"v10-layer-switch-label v10-layer-switch-label-compact",children:"SWM"}),t.swm>0&&o.jsx("span",{className:"v10-layer-switch-count",children:t.swm})]}),o.jsxs("button",{className:`v10-layer-switch-btn ${e==="vm"?"active":""}`,"data-layer":"vm","aria-label":"Verifiable Memory",title:"Verifiable Memory",onClick:()=>h("vm"),children:[o.jsx("span",{className:"v10-layer-switch-icon",style:{color:"#22c55e"},children:"◉"}),o.jsx("span",{className:"v10-layer-switch-label v10-layer-switch-label-full",children:"Verifiable Memory"}),o.jsx("span",{className:"v10-layer-switch-label v10-layer-switch-label-compact",children:"VM"}),t.vm>0&&o.jsx("span",{className:"v10-layer-switch-count",children:t.vm})]}),o.jsx("span",{className:"v10-layer-switch-separator","aria-hidden":"true"}),o.jsxs("button",{className:`v10-layer-switch-btn ${e==="graph-overview"?"active":""}`,"data-layer":"graph-overview","aria-label":"Subgraphs",title:"Subgraphs",onClick:()=>h("graph-overview"),children:[o.jsx("span",{className:"v10-layer-switch-icon",children:"⌬"}),o.jsx("span",{className:"v10-layer-switch-label",children:"Subgraphs"})]}),o.jsxs("div",{ref:f,className:"v10-layer-more",onBlur:g=>{g.currentTarget.contains(g.relatedTarget)||d(!1)},children:[o.jsxs("button",{type:"button",className:`v10-layer-switch-btn v10-layer-more-btn ${e==="query"?"active":""}`,"data-layer":"query","aria-haspopup":"menu","aria-expanded":u,"aria-label":"More Context Graph views",title:"More Context Graph views",onClick:()=>d(g=>!g),children:[o.jsx("span",{className:"v10-layer-switch-icon",children:"⋯"}),o.jsx("span",{className:"v10-layer-switch-label",children:"More"})]}),u&&o.jsx("div",{className:"v10-layer-more-menu",role:"menu",children:o.jsxs("button",{type:"button",role:"menuitem",className:`v10-layer-more-item ${e==="query"?"active":""}`,onClick:()=>h("query"),children:[o.jsx("span",{className:"v10-layer-switch-icon",children:"⟐"}),"Query Catalogue"]})})]}),o.jsx("div",{className:"v10-layer-switcher-spacer"}),o.jsxs("div",{className:"v10-layer-switcher-actions",children:[o.jsxs("button",{className:"v10-layer-action-btn",onClick:a,"aria-label":"Share Context Graph",children:[o.jsx("span",{className:"v10-layer-action-icon",children:"⤴"}),o.jsx("span",{className:"v10-layer-action-label",children:"Share"})]}),o.jsxs("button",{className:"v10-layer-action-btn",onClick:s,"aria-label":"Import into Context Graph",children:[o.jsx("span",{className:"v10-layer-action-icon",children:"↑"}),o.jsx("span",{className:"v10-layer-action-label",children:"Import"})]}),o.jsx("button",{className:"v10-layer-action-btn",onClick:l,"aria-label":"Refresh Context Graph data",children:o.jsx("span",{className:"v10-layer-action-icon",children:"↻"})})]})]})}function bD({cg:e,profile:t,activeSubGraph:n,onClearSubGraph:a}){const s=e.name||t.displayName||e.id;return o.jsxs("div",{className:"v10-project-strip",style:{"--sg-color":(n==null?void 0:n.color)??t.primaryColor},children:[o.jsx("span",{className:"v10-project-strip-dot",style:{background:t.primaryColor}}),o.jsx("button",{type:"button",className:"v10-project-strip-name",onClick:n?a:void 0,disabled:!n,title:n?"Back to context graph overview":e.id,children:s}),n?o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"v10-project-strip-sep",children:"›"}),o.jsxs("span",{className:"v10-project-strip-sg",children:[o.jsx("span",{className:"v10-project-strip-sg-icon",style:{color:n.color},children:n.icon??"•"}),n.displayName??n.slug]}),n.description&&o.jsx("span",{className:"v10-project-strip-desc",title:n.description,children:n.description})]}):e.description&&o.jsx("span",{className:"v10-project-strip-desc",title:e.description,children:e.description})]})}function xD(e,t,n,a,s){const l=typeof(e==null?void 0:e.curator)=="string"?e.curator.trim():"",u=new Set([t==null?void 0:t.agentDid,t==null?void 0:t.agentAddress].filter(h=>typeof h=="string"&&h.trim().length>0).map(Jt)),d=u.size>0;return l&&d&&u.has(Jt(l))?{label:"Curator",title:"This agent is the curator for this Context Graph.",tone:"curator"}:(e==null?void 0:e.callerInvolved)===!0?l&&!d&&n==="loading"?{label:"Role checking",title:"This agent is involved in this Context Graph; curator status is still loading.",tone:"unknown"}:l&&!d&&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"}:s==="ok"&&a.map(h=>h.trim()).filter(Boolean).some(h=>u.has(Jt(h)))?{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 wD(e,t,n){if(es(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 s=new Set(t.map(u=>u.trim()).filter(Boolean).map(Jt)),l=typeof(e==null?void 0:e.curator)=="string"?e.curator.trim():"";return l&&s.add(Jt(l)),{id:"participants",value:s.size.toLocaleString(),label:"Agents with access",tooltip:"Includes the curator plus allowlisted participants reported by the node."}}function kD(e){const t=es(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 SD({cg:e,currentAgent:t,currentAgentStatus:n="ok"}){var d,f;const a=typeof(e==null?void 0:e.curator)=="string"?e.curator.trim():"";if(!a)return"unknown";const s=((d=t==null?void 0:t.agentDid)==null?void 0:d.trim())??"",l=((f=t==null?void 0:t.agentAddress)==null?void 0:f.trim())??"",u=s||l;return u?Jt(a)===Jt(u)?"curator":"not-curator":"unknown"}function jD(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(Jt))}function CD({cg:e,memory:t,subGraphCount:n,subGraphFetchFailed:a=!1,participants:s,participantsStatus:l="ok",currentAgent:u,currentAgentStatus:d="ok",onSwitchLayer:f,onOpenPrimer:h}){var V,L,P;const{wm:g,swm:m,vm:y}=t.counts,b=g+m+y,k=xD(e,u??null,d,s,l),j=kD(e==null?void 0:e.accessPolicy),N=wD(e,s,l),S=typeof(e==null?void 0:e.curator)=="string"?e.curator.trim():"",A=S?Jt(S):"",E=es(e==null?void 0:e.accessPolicy)==="public",T=jD(u??null),U=Object.values(t.layerStatus??{}),_=U.filter(G=>G==="error").length,z=!t.loading&&U.length===3&&_===3,q=!t.loading&&_>0,D=t.loading?"Loading memory layers...":z||t.error?"Live memory counts are unavailable.":t.partial||q?"One or more layer counts are currently a lower bound.":"Canonical current-layer entity counts.",R=z?"Unavailable":b.toLocaleString(),{total:$}=Zg(t),F=!t.loading&&(t.partial||q),K=z?"Unavailable":t.loading&&$===0?"...":F?`${$.toLocaleString()}+`:$.toLocaleString(),I=z?"Live triple counts are unavailable.":F?"One or more layer triple counts are currently a lower bound.":"Canonical triple total across all layers.",H=n==null?a?"Unavailable":"...":n.toLocaleString(),B=n==null?a?"Sub-graph list is currently unavailable.":"Sub-graph count is loading.":"Topical partitions inside this Context Graph.",W=[{key:"wm",label:"Working Memory",desc:"Private staging area",count:g,status:((V=t.layerStatus)==null?void 0:V.wm)??"ok",color:"#64748b"},{key:"swm",label:"Shared Working Memory",desc:"Collaborative review",count:m,status:((L=t.layerStatus)==null?void 0:L.swm)??"ok",color:"#f59e0b"},{key:"vm",label:"Verifiable Memory",desc:"Published on-chain",count:y,status:((P=t.layerStatus)==null?void 0:P.vm)??"ok",color:"#22c55e"}],Q=W.some(G=>G.status==="error");return o.jsxs("div",{className:"v10-po",children:[o.jsxs("div",{className:"v10-po-identity","data-section":"identity",children:[o.jsxs("div",{className:"v10-po-identity-pairs",children:[o.jsxs("div",{className:"v10-po-identity-pair",children:[o.jsx("span",{className:"v10-po-identity-label",children:"Your role:"}),o.jsx("span",{className:"v10-po-badge","data-role":k.tone,title:k.title,children:k.label})]}),o.jsxs("div",{className:"v10-po-identity-pair",children:[o.jsx("span",{className:"v10-po-identity-label",children:"Context Graph:"}),o.jsx("span",{className:"v10-po-badge","data-cg-type":j.tone,title:j.title,children:j.label})]})]}),h&&o.jsx("button",{type:"button",className:"v10-po-identity-primer",onClick:h,title:"Open the Context Graph primer",children:"What is a Context Graph?"})]}),o.jsxs("div",{"data-section":"at-a-glance",className:"v10-po-stat-block",children:[o.jsx("div",{className:"v10-po-section-title",children:"At a glance"}),o.jsx(Fd,{className:"v10-po-stat-strip",items:[{id:"entities",value:R,label:"Entities",tooltip:D},{id:"triples",value:K,label:"Triples",tooltip:I},{id:"subgraphs",value:H,label:"Subgraphs",tooltip:B},N]})]}),o.jsxs("div",{className:"v10-po-pipeline","data-section":"pipeline","aria-label":"Knowledge Pipeline",children:[o.jsx("div",{className:"v10-po-pipeline-head",children:o.jsxs("div",{children:[o.jsx("div",{className:"v10-po-section-title",children:"Knowledge Pipeline"}),o.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."})]})}),o.jsx("div",{className:"v10-po-pipeline-track","aria-hidden":"true",children:!Q&&b>0?W.map(G=>{const O=G.count>0?G.count/b*100:0;return o.jsx("span",{className:`v10-po-pipeline-seg ${G.key}`,style:{width:`${O}%`,background:G.color}},G.key)}):o.jsx("span",{className:"v10-po-pipeline-empty"})}),o.jsx("div",{className:"v10-po-pipeline-steps",children:W.map((G,O)=>o.jsxs("button",{type:"button",className:`v10-po-pipeline-step ${G.key}`,onClick:()=>f==null?void 0:f(G.key),style:{"--po-layer-color":G.color},children:[o.jsx("span",{className:"v10-po-pipeline-step-index",children:O+1}),o.jsxs("span",{className:"v10-po-pipeline-step-copy",children:[o.jsx("span",{className:"v10-po-pipeline-step-label",children:G.label}),o.jsx("span",{className:"v10-po-pipeline-step-desc",children:G.desc})]}),o.jsx("span",{className:"v10-po-pipeline-step-count",children:G.status==="error"?"Unavailable":`${G.count.toLocaleString()} ${ia(G.key,G.count)}`})]},G.key))})]}),o.jsxs("div",{className:"v10-po-people","data-section":"participants",children:[o.jsx("div",{className:"v10-po-section-title",children:"Participant agents"}),(()=>{const G="did:dkg:agent:",O=le=>le.toLowerCase().startsWith(G)?le.slice(G.length):le,ne=new Set,ue=[];if(S&&l==="ok"){const le=Jt(S);ne.add(le),ue.push({display:O(S),full:S,canonical:le})}if(l==="ok")for(const le of s){const be=Jt(le);ne.has(be)||(ne.add(be),ue.push({display:O(le),full:le,canonical:be}))}if(ue.length===0){const le=E?"This Context Graph is public — anyone can subscribe.":l==="loading"?"Loading participant agents...":l==="error"?"Participant list unavailable.":"No participant agents recorded yet.";return o.jsx("div",{className:"v10-po-people-empty",children:le})}return o.jsx("div",{className:"v10-po-participants-list",children:ue.map(({display:le,full:be,canonical:_e})=>{const Ee=T.has(_e),Ie=!!A&&_e===A,We=`${le.slice(0,6)}…${le.slice(-4)}`,Se=[We];return Ee&&Se.push("you"),Ie&&Se.push("curator"),o.jsxs("span",{className:`v10-po-participant${Ee?" is-self":""}${Ie?" is-curator":""}`,title:be,"aria-label":Se.join(" "),children:[o.jsx("span",{className:"v10-po-participant-name",children:We}),Ee&&o.jsx("span",{className:"v10-po-participant-tag",children:"you"}),Ie&&o.jsx("span",{className:"v10-po-participant-tag",children:"curator"})]},_e)})})})()]})]})}function ND({contextGraphId:e,curatorStatus:t,onParticipantsChanged:n}){const[a,s]=w.useState([]),[l,u]=w.useState(null),[d,f]=w.useState("loading"),h=w.useRef(0),g=w.useCallback(()=>{if(t!=="curator"){s([]),f("idle");return}const b=++h.current;f("loading"),RS(e).then(k=>{h.current===b&&(s(k.requests.filter(j=>j.status==="pending")),f("idle"))}).catch(()=>{h.current===b&&(s([]),f("error"))})},[e,t]);if(w.useEffect(()=>(g(),()=>{h.current++}),[g]),ss(w.useCallback(b=>{var k;b.type!=="join_request"&&b.type!=="join_approved"&&b.type!=="join_rejected"||((k=b.data)==null?void 0:k.contextGraphId)===e&&g()},[e,g])),t==="not-curator")return null;if(t==="unknown")return o.jsxs("section",{className:"v10-po-join","data-section":"join-requests",children:[o.jsx("header",{className:"v10-po-join-head",children:o.jsx("span",{className:"v10-po-section-title",children:"Pending join requests"})}),o.jsx("div",{className:"v10-po-join-empty",children:"Verifying access…"})]});const m=async b=>{u(b);try{await Ng(e,b),s(k=>k.filter(j=>j.agentAddress!==b)),n==null||n()}catch{}finally{u(null)}},y=async b=>{u(b);try{await Eg(e,b),s(k=>k.filter(j=>j.agentAddress!==b)),n==null||n()}catch{}finally{u(null)}};return o.jsxs("section",{className:"v10-po-join","data-section":"join-requests",children:[o.jsxs("header",{className:"v10-po-join-head",children:[o.jsx("span",{className:"v10-po-section-title",children:"Pending join requests"}),o.jsx("span",{className:"v10-po-join-count","data-empty":a.length===0?"true":"false",children:a.length})]}),d==="loading"?o.jsx("div",{className:"v10-po-join-empty",children:"Loading join requests..."}):d==="error"?o.jsx("div",{className:"v10-po-join-empty",children:"Join requests are currently unavailable."}):a.length===0?o.jsx("div",{className:"v10-po-join-empty",children:"No pending join requests."}):o.jsx("div",{className:"v10-po-join-list",children:a.map(b=>o.jsxs("div",{className:"v10-po-join-item",children:[o.jsxs("div",{className:"v10-po-join-info",children:[o.jsx("span",{className:"v10-po-join-name",children:b.name||`${b.agentAddress.slice(0,6)}…${b.agentAddress.slice(-4)}`}),o.jsxs("span",{className:"v10-po-join-addr",title:b.agentAddress,children:[b.agentAddress.slice(0,10),"…"]})]}),o.jsxs("div",{className:"v10-po-join-actions",children:[o.jsx("button",{className:"v10-po-join-btn approve",onClick:()=>m(b.agentAddress),disabled:l===b.agentAddress,children:l===b.agentAddress?"…":"✓ Approve"}),o.jsx("button",{className:"v10-po-join-btn reject",onClick:()=>y(b.agentAddress),disabled:l===b.agentAddress,"aria-label":"Reject join request",children:"✕"})]})]},b.agentAddress))})]})}function ED({onOpenPrimer:e}){return o.jsxs("div",{className:"v10-po-primer-footer","data-section":"primer",children:[o.jsx("span",{className:"v10-po-primer-footer-lede",children:"New here?"}),o.jsx("span",{className:"v10-po-primer-footer-arrow","aria-hidden":"true",children:"→"}),o.jsx("button",{type:"button",className:"v10-po-primer-footer-link",onClick:e,children:"What is a Context Graph?"}),o.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 AD=(e,t)=>!!e&&!!t&&e.toLowerCase()===t.toLowerCase();function TD(e,t=0){const n=Pl(u=>u.trackedIds),a=n.join(","),{data:s,loading:l}=lr(async()=>{if(n.length===0)return{wallets:[],ownerPublish:!1,resolved:!1};const u=await Lg().catch(()=>null),d=(u==null?void 0:u.wallets)??[];let f=!1;try{const{contextGraphs:g}=await Ld(),m=(g??[]).find(b=>(b==null?void 0:b.id)===e),y=m==null?void 0:m.curator;if(y){const b=await Yl().catch(()=>null);f=!!(b!=null&&b.agentDid&&Jt(y)===Jt(b.agentDid))}}catch{f=!1}return{wallets:await Promise.all(d.map(async g=>{var T;const m=(T=u==null?void 0:u.balances)==null?void 0:T.find(U=>AD(U.address,g)),y=m==null,b=m!=null&&Number(m.eth)>0,k=m!=null&&Number(m.trac)>0;let j,N=!1,S=!1,A,E=!1;for(const U of n){const _=await od(U,g,{extended:!0}).catch(()=>null);if(_===null){E=!0;continue}const z=jm(_);if(z.outcome==="inconclusive"){E=!0;continue}if(z.outcome!=="unregistered"){if(z.outcome==="covers"){j={accountId:U,discountBps:_.discountBps,untracked:!1};break}z.dead&&(N=!0,A||(A=U)),z.hasBudget||(S=!0)}}if(!j&&!E&&!N&&!S){const U=await i_(g).catch(()=>{});if(U===void 0)E=!0;else if(U.accountId!=null&&!n.includes(U.accountId)){const _=U.accountId,z=await od(_,g,{extended:!0}).catch(()=>null);if(z===null)E=!0;else{const q=jm(z);q.outcome==="covers"?j={accountId:_,discountBps:z.discountBps,untracked:!0}:q.outcome==="uncovered"?(q.dead&&(N=!0,A||(A=_)),q.hasBudget||(S=!0)):E=!0}}}return{wallet:g,covered:!!j,accountId:j==null?void 0:j.accountId,discountBps:j==null?void 0:j.discountBps,coverUntracked:(j==null?void 0:j.untracked)??!1,deadAccountId:j?void 0:A,inconclusive:!j&&E,balanceUnknown:y,gasFunded:b,hasTrac:k,sawExpired:N,sawInsolvent:S}})),ownerPublish:f,resolved:d.length>0}},[a,e],t);return w.useMemo(()=>{const u=(s==null?void 0:s.wallets)??[],d=(s==null?void 0:s.ownerPublish)??!1,f=(s==null?void 0:s.resolved)??!1;if(n.length===0||!f||u.length===0)return{verdict:"unknown",loading:l,ownerPublish:d,anyGasFunded:!1,reasons:[],conditions:{approved:!1,gasFunded:!1,notExpired:!1,solvent:!1},wallets:u};const h=u.filter(S=>S.covered),g=u.filter(S=>!S.covered),m=g.filter(S=>!S.inconclusive&&!S.balanceUnknown),y=g.filter(S=>S.inconclusive||S.balanceUnknown),b={approved:g.length===0,gasFunded:u.every(S=>S.gasFunded),notExpired:!u.some(S=>S.sawExpired),solvent:!u.some(S=>S.sawInsolvent)};let k;const j=[];if(g.length===0)h.some(S=>S.gasFunded||S.balanceUnknown)?k="eligible":(k="fallthrough-no-funds",j.push("every approved signing wallet is out of gas"));else if(m.length===0&&y.length>0)k="unknown";else{const S=u.some(A=>(A.covered||A.hasTrac)&&A.gasFunded);!S&&y.length>0?k="unknown":(k=S?"fallthrough":"fallthrough-no-funds",j.push(`${h.length} of ${u.length} signing wallets approved`),u.some(A=>A.sawExpired)&&j.push("a PCA has expired or been fully swept"),u.some(A=>A.sawInsolvent)&&j.push("a PCA is out of budget"),b.gasFunded||j.push("a signing wallet has no gas"),g.some(A=>A.inconclusive)&&j.push("a wallet’s PCA coverage couldn’t be checked"),g.some(A=>A.balanceUnknown)&&j.push("a signing wallet’s balance couldn’t be checked"))}const N=h.reduce((S,A)=>(A.discountBps??-1)>((S==null?void 0:S.discountBps)??-1)?A:S,void 0);return{verdict:k,loading:l,accountId:N==null?void 0:N.accountId,discountBps:N==null?void 0:N.discountBps,accountUntracked:N==null?void 0:N.coverUntracked,ownerPublish:d,anyGasFunded:u.some(S=>S.gasFunded||S.balanceUnknown),reasons:j,conditions:b,wallets:u}},[s,l,n.length])}function _D(e){return e.verdict==="fallthrough-no-funds"&&!(e.ownerPublish&&e.anyGasFunded)}function RD(e){const t=Pl(u=>u.trackedIds),n=TD(e,3e4),a=_D(n),s="Publish will fail — no signing wallet can fund it (coverage or gas).",l=t.length>0;return{blocked:a,reason:s,chipVisible:l,eligibility:n}}function OD({verdict:e,accountId:t,discountBps:n,accountUntracked:a,ownerPublish:s,id:l}){return o.jsx("div",{className:"v10-pca-publish-chip",id:l,"data-testid":"pca-publish-eligibility",children:o.jsx(qO,{variant:"chip",verdict:e,accountId:t,discountBps:n,accountUntracked:a,ownerPublish:s})})}function ev({title:e,agent:t,footnote:n,dismissed:a,onDismiss:s,children:l}){return o.jsxs("div",{className:`v10-gen-widget ${a?"dissolved":""}`,children:[o.jsxs("div",{className:"v10-gen-widget-header",children:[o.jsx("span",{className:"v10-gen-widget-title",children:e}),o.jsxs("div",{className:"v10-gen-widget-right",children:[t&&o.jsxs("span",{className:"v10-gen-widget-agent",children:[o.jsx("span",{className:"v10-gen-widget-agent-dot"}),t]}),s&&o.jsx("button",{className:"v10-gen-widget-dismiss",onClick:s,children:"✕"})]})]}),o.jsx("div",{className:"v10-gen-widget-body",children:l}),n&&o.jsx("div",{className:"v10-gen-widget-footnote",children:n})]})}function LD({entities:e}){const t=Ua(),n=w.useMemo(()=>{const a=new Map;for(const s of e){const{icon:l,type:u}=Bd(s,t),d=a.get(u);d?d.count++:a.set(u,{icon:l,count:1})}return[...a.entries()].sort((s,l)=>l[1].count-s[1].count)},[e,t]);return n.length===0?null:o.jsx(ev,{title:"Entity Types",children:o.jsx(Fd,{compact:!0,items:n.map(([a,{icon:s,count:l}])=>({id:a,label:`${s} ${a}`,value:l}))})})}function MD({entities:e,entityCount:t,triples:n,layer:a}){const s=w.useMemo(()=>e.filter(d=>d.properties.has("http://dkg.io/ontology/sourceContentType")).length,[e]),l=w.useMemo(()=>e.reduce((d,f)=>d+f.connections.length,0),[e]),u=e.length>0?(l/e.length).toFixed(1):"0";return o.jsx(ev,{title:"Layer Stats",children:o.jsx(Fd,{compact:!0,layer:a,items:[{id:"entities",label:ia(a,t),value:t},{id:"triples",label:"Triples",value:n},{id:"connections",label:"Connections",value:l},{id:"avg",label:"Avg. connections / entity",value:u},...s>0?[{id:"documents",label:"Documents",value:s}]:[]]})})}function Nj(e,t){const[n,a]=w.useState(!1),[s,l]=w.useState(null),[u,d]=w.useState(null),f=w.useCallback(async(h,g)=>{a(!0),d(null),l(null);try{const m=await h();l(m),e==null||e({ok:!0,text:m}),t==null||t()}catch(m){const y=g(m);d(y),e==null||e({ok:!1,text:y})}finally{a(!1)}},[e,t]);return{busy:n,result:s,error:u,run:f}}function Ej({title:e,footnote:t,context:n,result:a,error:s,extras:l,children:u}){return o.jsxs(ev,{title:e,footnote:t,children:[o.jsx("div",{className:"v10-decision-context",style:{marginBottom:10},children:n}),a&&o.jsxs("div",{"data-testid":"layer-action-result",style:{fontSize:11,color:"var(--text-success)",marginBottom:8},children:["✓ ",a]}),s&&o.jsxs("div",{"data-testid":"layer-action-error",style:{fontSize:11,color:"var(--text-danger)",marginBottom:8},children:["✕ ",s]}),l,o.jsx("div",{className:"v10-decision-actions",children:u})]})}function DD({count:e,contextGraphId:t,onComplete:n,onResult:a}){const{busy:s,result:l,error:u,run:d}=Nj(a,n),f=w.useCallback(()=>{let m=null;d(async()=>{const y=await Ql(t,"wm");let b=0;for(const j of y)m=j.name,(await lo(t,j.name,j.subGraph?{subGraphName:j.subGraph}:{})).promotedCount===0&&(b+=1);const k=y.length-b;if(k>0){const j=b>0?` (${b} already shared or still committing)`:"";return`Shared ${k} complete Knowledge Asset${k!==1?"s":""} to Shared Memory${j}`}return"No Knowledge Assets were newly shared — all were already in Shared Memory or still committing."},y=>{const b=co(m??"an assertion",y);return b?b.message:(y==null?void 0:y.message)??"Action failed"})},[t,d]);if(e===0)return null;const h="#f59e0b",g=ia("wm",e).toLowerCase();return o.jsx(Ej,{title:"Share complete Knowledge Assets",footnote:"Shares each complete owning Knowledge Asset atomically to Shared Working Memory.",context:o.jsxs(o.Fragment,{children:["The displayed ",g," will be shared through their complete owning Knowledge Assets for collaborative review."]}),result:l,error:u,children:o.jsx("button",{"data-testid":"widget-promote-all-btn",className:"v10-decision-btn approve",style:{borderColor:`${h}50`,color:"var(--text-warning)",background:`${h}15`,opacity:s?.5:1},disabled:s,onClick:f,children:s?"...":"✓ Share Complete KAs → Shared"})})}function zD({count:e,contextGraphId:t,onComplete:n,onResult:a}){const[s,l]=w.useState(null),{busy:u,result:d,error:f,run:h}=Nj(a,n),g=RD(t),m=w.useId(),y=w.useId(),b=[g.chipVisible?m:null,g.blocked?y:null].filter(Boolean).join(" ")||void 0,k=w.useCallback(()=>{g.blocked||h(async()=>{l(null);const N=await Ql(t,"swm"),S=await Tg(t,N);if(S.published>0){const A=S.failures.length?` (${S.failures.length} assertion${S.failures.length===1?"":"s"} could not be published)`:"",E=S.partial>0?` — ⚠ ${S.partial}: ${Il(S.partialError)}`:"";return l(S.convictionCostCovered??null),`Published ${S.published} knowledge asset${S.published!==1?"s":""} to Verifiable Memory${A}${E}`}if(N.length===0)return"Nothing to publish — promote assertions to Shared Memory first.";throw new Error(S.failures[0]?`${S.failures[0].name}: ${S.failures[0].error}`:"Publish failed")},N=>(N==null?void 0:N.message)??"Action failed")},[t,h,g.blocked]);if(e===0)return null;const j=ia("swm",e).toLowerCase();return o.jsx(Ej,{title:"Publish",footnote:`Moves ${j} from this layer to Verifiable Memory.`,context:o.jsxs(o.Fragment,{children:[e," ",j," in this layer can be published to Verifiable Memory on-chain."]}),result:d,error:f,extras:o.jsxs(o.Fragment,{children:[o.jsx(WS,{convictionCostCovered:s}),g.chipVisible&&o.jsx(OD,{...g.eligibility,id:m}),g.blocked&&o.jsx("span",{id:y,className:"v10-sr-only",children:g.reason})]}),children:o.jsx("button",{"data-testid":"widget-publish-vm-btn",className:"v10-decision-btn primary-cta publish-vm",style:{opacity:u||g.blocked?.5:1},disabled:u,"aria-disabled":g.blocked||void 0,title:g.blocked?g.reason:void 0,"aria-describedby":b,onClick:k,children:u?"...":"◉ Publish to Verifiable Memory"})})}function $D({layer:e,entities:t,entityCount:n,tripleCount:a,contextGraphId:s,onComplete:l}){const[u,d]=w.useState(null),f=u&&o.jsxs("div",{"data-testid":u.ok?"layer-action-result":"layer-action-error",style:{fontSize:11,color:u.ok?"var(--text-success)":"var(--text-danger)",marginBottom:8},children:[u.ok?"✓":"✕"," ",u.text]});return n===0?o.jsxs("div",{className:"v10-layer-widgets-strip empty",children:[f,o.jsx(ln,{compact:!0,tone:e,icon:zn[e].icon,title:`No ${ia(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."})]}):o.jsxs("div",{className:"v10-layer-widgets-strip",children:[o.jsxs("div",{className:"v10-layer-widgets-strip-stats",children:[o.jsx(MD,{entities:t,entityCount:n,triples:a,layer:e}),o.jsx(LD,{entities:t})]}),(e==="wm"||e==="swm")&&s&&o.jsx("div",{className:"v10-layer-widgets-strip-action",children:e==="wm"?o.jsx(DD,{count:n,contextGraphId:s,onComplete:l,onResult:d}):o.jsx(zD,{count:n,contextGraphId:s,onComplete:l,onResult:d})})]})}const tv="doc:";function ID(e,t,n){return`${tv}${e}|${t}|${n}`}function PD(e,t,n){return e?{ref:e,contentType:"text/markdown"}:t?{ref:t,contentType:n}:{ref:void 0,contentType:n}}function UD(e){const t=e.slice(tv.length),n=t.indexOf("|"),a=t.lastIndexOf("|");return n<0?{docRef:t,contentType:""}:{docRef:t.slice(n+1,a),contentType:t.slice(a+1)}}function nv(e,t){if(e.length<=t)return e;const n=t-1,a=Math.ceil(n/2),s=n-a;return`${e.slice(0,a)}…${e.slice(-s)}`}const BD={working:{layerKey:"wm",icon:"◇",label:"Working"},shared:{layerKey:"swm",icon:"◈",label:"Shared"},verified:{layerKey:"vm",icon:"◉",label:"Verifiable"}};function Aj({entities:e,layerKey:t,layerIcon:n,onSelectEntity:a,onOpenAgent:s,externallySorted:l=!1,sortLabel:u,headerExtra:d,timestampPredicate:f,perEntityTrustBadge:h=!1}){const g=Ua(),m=cs(),y=ia(t,e.length).toLowerCase(),b=w.useMemo(()=>{if(l)return e;const N=[...e];return N.sort((S,A)=>{const E=S.tripleCount??0;return(A.tripleCount??0)-E}),N},[e,l]),k=t==="vm"?"Verifiable":t==="swm"?"Shared":"Working";if(e.length===0)return o.jsx("div",{className:"v10-entity-list empty",children:o.jsx(ln,{compact:!0,tone:t,icon:n,title:`No ${ia(t,2).toLowerCase()} yet`,description:`This view will fill when matching ${ia(t,2).toLowerCase()} are available.`})});const j=u??(l?"click to open":"sorted by triples · click to open");return o.jsxs("div",{className:"v10-entity-list",children:[o.jsxs("div",{className:"v10-entity-list-header",children:[o.jsxs("span",{className:"v10-entity-list-count",children:[b.length," ",y]}),o.jsx("span",{className:"v10-entity-list-hint",children:j}),d&&o.jsx("span",{className:"v10-entity-list-extra",children:d})]}),b.map(N=>{const{icon:S,type:A}=Bd(N,g),E=N.tripleCount??0,T=Ud(N),U=T?m==null?void 0:m.get(T):null,_=f?Qu(N,f):null;return o.jsxs("div",{className:"v10-entity-card",onClick:z=>{z.stopPropagation(),a(N.uri)},children:[o.jsx("span",{className:"v10-entity-card-icon",children:S}),o.jsxs("div",{className:"v10-entity-card-main",children:[o.jsx("div",{className:"v10-entity-card-title",children:N.label}),o.jsxs("div",{className:"v10-entity-card-meta",children:[(U||T)&&o.jsx(ts,{agent:U??void 0,fallbackUri:T??void 0,size:"sm",onOpenAgent:s}),A&&A!=="Entity"&&o.jsxs("span",{className:"v10-entity-type-pill",children:[S," ",A]}),_!=null&&o.jsx("span",{className:"v10-entity-card-timestamp",title:new Date(_).toLocaleString(),children:X4(_)}),o.jsxs("span",{className:"v10-entity-card-triples",children:[E," triples"]})]})]}),h?(()=>{const z=BD[N.trustLevel];return o.jsxs("span",{className:`v10-trust-badge ${z.layerKey}`,title:`${z.label} Memory`,children:[z.icon," ",z.label]})})():o.jsxs("span",{className:`v10-trust-badge ${t}`,children:[n," ",k]})]},N.uri)})]})}function FD({layer:e,entities:t,tripleCount:n,layerTriples:a,contextGraphId:s,memory:l,activeTab:u,onTabChange:d,onSelectEntity:f,onNodeClick:h,footer:g,swmAttribution:m}){var T;const y=zn[e],b=ia(e,2),k=((T=l.layerStatus)==null?void 0:T.vm)??(l.loading?"loading":l.error?"error":"ok"),j=e==="vm"&&k==="loading"&&t.length===0,N=e==="vm"&&k==="error"&&t.length===0,S=e==="vm"&&k==="ok"&&t.length===0,A=l.counts[e],E=U=>_=>{_.stopPropagation(),d(U)};return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"v10-layer-expand-tabs",children:[o.jsx("button",{className:`v10-layer-expand-tab ${u==="items"?"active":""}`,onClick:E("items"),children:b}),e!=="vm"&&o.jsx("button",{className:`v10-layer-expand-tab ${u==="assertions"?"active":""}`,onClick:E("assertions"),children:"Assertions"}),o.jsx("button",{className:`v10-layer-expand-tab ${u==="graph"?"active":""}`,onClick:E("graph"),children:"Graph"}),o.jsx("button",{className:`v10-layer-expand-tab ${u==="docs"?"active":""}`,onClick:E("docs"),children:"Documents"})]}),u==="items"&&o.jsxs("div",{className:"v10-layer-expand-body entities-tab","data-cg-scroll-key":`layer:${e}:items`,children:[e==="vm"&&!j&&!N&&o.jsx(HD,{entities:t,tripleCount:n,contextGraphId:s}),j?o.jsx("div",{className:"v10-layer-widgets-strip empty",children:o.jsx(ln,{compact:!0,tone:"vm",icon:zn.vm.icon,title:"Loading Verifiable Memory...",description:"Knowledge Assets are being read from the verified layer."})}):N?o.jsx("div",{className:"v10-layer-widgets-strip empty",children:o.jsx(ln,{compact:!0,tone:"vm",icon:zn.vm.icon,title:"Verifiable Memory status unavailable.",description:"This node could not read the verified layer right now."})}):!S&&o.jsxs(o.Fragment,{children:[o.jsx($D,{layer:e,entities:t,entityCount:A,tripleCount:n,contextGraphId:s,onComplete:l.refresh}),o.jsx(Aj,{entities:t,layerKey:e,layerIcon:y.icon,onSelectEntity:f})]}),g]}),u==="assertions"&&e!=="vm"&&o.jsx("div",{className:"v10-layer-expand-body full-width",children:o.jsx(qD,{contextGraphId:s,layer:e,onComplete:l.refresh,scrollKey:`layer:${e}:assertions`})}),u==="graph"&&o.jsx("div",{className:"v10-layer-expand-body full-width","data-cg-scroll-key":`layer:${e}:graph`,children:o.jsx(Cj,{layer:e,triples:a,onNodeClick:h,contextGraphId:s,swmAttribution:e==="swm"?m:void 0,layerEntities:t})}),u==="docs"&&o.jsx("div",{className:"v10-layer-expand-body full-width",children:o.jsx(Tj,{entities:t,contextGraphId:s,scrollKey:`layer:${e}:docs`})})]})}function HD({entities:e,tripleCount:t,contextGraphId:n}){const a=e.length,s=new Set;for(const u of e)for(const d of u.types)s.add(d);const l=s.size;return a===0?o.jsxs("div",{className:"v10-vm-hero v10-vm-hero-empty",children:[o.jsxs("div",{className:"v10-vm-hero-title",children:[o.jsx("span",{className:"v10-vm-hero-badge",children:"◉ Verifiable Memory"}),o.jsxs("div",{className:"v10-vm-hero-heading",children:[o.jsx("span",{className:"v10-vm-hero-headline",children:"Nothing published yet"}),o.jsxs("span",{className:"v10-vm-hero-context",title:n,children:["Context Graph: ",n]})]})]}),o.jsx(ln,{compact:!0,className:"v10-vm-empty-state",tone:"vm",icon:zn.vm.icon,title:"No Knowledge Assets yet.",description:"Publish complete Knowledge Assets from Shared Working Memory to verify them on-chain."})]}):o.jsxs("div",{className:"v10-vm-hero",children:[o.jsxs("div",{className:"v10-vm-hero-title",children:[o.jsx("span",{className:"v10-vm-hero-badge",children:"◉ Verifiable Memory"}),o.jsxs("div",{className:"v10-vm-hero-heading",children:[o.jsx("span",{className:"v10-vm-hero-headline",children:"On-chain anchored · cryptographically signed"}),o.jsxs("span",{className:"v10-vm-hero-context",title:n,children:["Context Graph: ",n]})]})]}),o.jsx(Fd,{className:"v10-vm-hero-stats",layer:"vm",items:[{id:"assets",value:a,label:"Knowledge Assets"},{id:"triples",value:t.toLocaleString(),label:"Verifiable Triples"},{id:"types",value:l,label:"Entity Types"}]}),o.jsxs("div",{className:"v10-vm-hero-strip",children:[o.jsxs("div",{className:"v10-vm-hero-chip",title:"Multi-agent endorsement",children:[o.jsx("span",{className:"v10-vm-hero-chip-dot",style:{background:"#22c55e"}}),"Consensus"]}),o.jsxs("div",{className:"v10-vm-hero-chip",title:"Published to the DKG blockchain anchor",children:[o.jsx("span",{className:"v10-vm-hero-chip-dot",style:{background:"#3b82f6"}}),"On-chain"]}),o.jsxs("div",{className:"v10-vm-hero-chip",title:"Each contribution bound to a DID",children:[o.jsx("span",{className:"v10-vm-hero-chip-dot",style:{background:"#a855f7"}}),"Agent Identity"]}),o.jsxs("div",{className:"v10-vm-hero-chip",title:"Tamper-evident via content hashing",children:[o.jsx("span",{className:"v10-vm-hero-chip-dot",style:{background:"#f59e0b"}}),"Content Hash"]})]})]})}function qD({contextGraphId:e,layer:t,onComplete:n,scrollKey:a}){const{data:s,loading:l,refresh:u}=lr(()=>Ql(e,t),[e,t],0),{data:d}=lr(()=>x_(e),[e,t],0),[f,h]=w.useState(null),[g,m]=w.useState(null),[y,b]=w.useState(null),k=w.useCallback(async E=>{h(E.graphUri),m(null),b(null);try{if(t==="wm"){const T=await lo(e,E.name,E.subGraph?{subGraphName:E.subGraph}:{}),U=_g(E.name,T);m(U.message)}else{const T=await Ag(e,E.name,E.subGraph?{subGraphName:E.subGraph}:{});m(T.contextGraphError?`Published ${E.name} on-chain — ⚠ ${Il(T.contextGraphError)}`:`Published ${E.name} to Verifiable Memory`)}u(),n()}catch(T){const U=co(E.name,T);b(U?U.message:(T==null?void 0:T.message)??"Action failed")}finally{h(null)}},[e,t,u,n]),j=w.useCallback(async()=>{if(!(s!=null&&s.length))return;h("__all__"),m(null),b(null);let E=null;try{if(t==="wm"){let T=0;for(const _ of s)E=_.name,(await lo(e,_.name,_.subGraph?{subGraphName:_.subGraph}:{})).promotedCount===0&&(T+=1);const U=s.length-T;if(U>0){const _=T>0?` (${T} already shared or still committing)`:"";m(`Shared ${U} complete Knowledge Asset${U!==1?"s":""}${_}`)}else m("No Knowledge Assets were newly shared — all were already in Shared Memory or still committing.")}else{const T=await Tg(e,s);if(T.published>0){const U=T.failures.length?` (${T.failures.length} could not be published)`:"",_=T.partial>0?` — ⚠ ${T.partial}: ${Il(T.partialError)}`:"";m(`Published ${T.published} knowledge asset${T.published!==1?"s":""} to Verifiable Memory${U}${_}`)}else throw new Error(T.failures[0]?`${T.failures[0].name}: ${T.failures[0].error}`:"Publish failed")}u(),n()}catch(T){const U=co(E??"selected assertion",T);b(U?U.message:(T==null?void 0:T.message)??"Action failed")}finally{h(null)}},[s,e,t,u,n]),N={flex:1,overflow:"auto"};if(l)return o.jsx("div",{className:"v10-layer-empty-shell",style:N,"data-cg-scroll-key":a,children:o.jsx(ln,{compact:!0,tone:t,icon:zn[t].icon,title:"Loading assertions..."})});if(!(s!=null&&s.length))return o.jsx("div",{className:"v10-layer-empty-shell",style:N,"data-cg-scroll-key":a,children:o.jsx(ln,{tone:t,icon:zn[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 S=t==="wm"?"Share Complete KA → Shared":"Publish to VM",A=t==="wm"?"Share Complete KAs → Shared":"Publish all to Verifiable Memory";return o.jsxs("div",{style:N,"data-cg-scroll-key":a,children:[o.jsxs("div",{style:{padding:"8px 16px",display:"flex",alignItems:"center",justifyContent:"space-between",borderBottom:"1px solid var(--border-subtle)"},children:[o.jsxs("span",{style:{fontSize:11,color:"var(--text-tertiary)"},children:[s.length," assertion",s.length!==1?"s":""]}),o.jsx("button",{className:`v10-layer-expand-footer-btn ${t==="wm"?"promote":"publish"}`,disabled:f!==null,onClick:j,style:{opacity:f==="__all__"?.5:1},children:f==="__all__"?"...":A})]}),g&&o.jsxs("div",{"data-testid":t==="wm"?"assertion-promote-result":"assertion-publish-result",style:{padding:"6px 16px",fontSize:11,color:"var(--text-success)"},children:["✓ ",g]}),y&&o.jsxs("div",{"data-testid":t==="wm"?"assertion-promote-result":"assertion-publish-result",style:{padding:"6px 16px",fontSize:11,color:"var(--text-danger)"},children:["✕ ",y]}),s.map(E=>o.jsxs("div",{className:"v10-item-row","data-testid":"assertion-list-row",children:[o.jsx("span",{className:"v10-item-icon",children:"▤"}),o.jsxs("div",{className:"v10-item-info",children:[o.jsx("div",{className:"v10-item-name",style:{fontFamily:"var(--font-mono)",fontSize:11},children:E.name}),(d==null?void 0:d[E.name])&&o.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:d[E.name],children:d[E.name]}),o.jsxs("div",{className:"v10-item-meta-row",children:[E.tripleCount!=null&&o.jsxs("span",{className:"v10-item-count",children:[E.tripleCount," triples"]}),E.subGraph&&o.jsxs("span",{className:"v10-item-count v10-item-subgraph",title:`In sub-graph: ${E.subGraph}`,children:["› ",nv(E.subGraph,18)]})]})]}),o.jsx("button",{"data-testid":"assertion-row-action",className:`v10-layer-expand-footer-btn ${t==="wm"?"promote":"publish"}`,disabled:f!==null,onClick:T=>{T.stopPropagation(),k(E)},style:{opacity:f===E.graphUri?.5:1,flexShrink:0},children:f===E.graphUri?"...":S})]},E.graphUri))]})}function GD({layer:e,memory:t,onNodeClick:n,onSelectEntity:a,contextGraphId:s,activeTab:l,onTabChange:u,swmAttribution:d}){const f=zn[e],h=w.useMemo(()=>t.entityList.filter(m=>m.trustLevel===f.trustLevel),[t.entityList,f.trustLevel]),g=W4(t,e);return o.jsxs("div",{className:"v10-layer-detail",children:[o.jsxs("div",{className:"v10-layer-detail-header",children:[o.jsx("span",{className:"v10-layer-detail-icon",style:{color:f.color},children:f.icon}),o.jsxs("div",{children:[o.jsx("div",{className:"v10-layer-detail-title",children:f.title}),o.jsx("div",{className:"v10-layer-detail-desc",children:f.desc})]}),o.jsx("div",{className:"v10-layer-detail-actions"})]}),o.jsx("div",{className:"v10-layer-detail-body",children:o.jsx(FD,{layer:e,entities:h,tripleCount:g.length,layerTriples:g,contextGraphId:s,memory:t,activeTab:l,onTabChange:u,onSelectEntity:a,onNodeClick:n,swmAttribution:d})})]})}function Tj({entities:e,contextGraphId:t,scrollKey:n}){const a=fn(u=>u.openTab),s=w.useMemo(()=>e.filter(u=>u.properties.has(Oh)),[e]),l=u=>{var y,b,k;const d=(y=u.connections.find(j=>j.predicate===S1))==null?void 0:y.targetUri,f=(b=u.connections.find(j=>j.predicate===j1))==null?void 0:b.targetUri,h=((k=u.properties.get(Oh))==null?void 0:k[0])??"",{ref:g,contentType:m}=PD(d,f,h);a({id:ID(t??"",g??u.uri,m),label:u.label,closable:!0,icon:"📄"})};return s.length===0?o.jsx("div",{className:"v10-docs-placeholder v10-layer-empty-shell",style:{flex:1},"data-cg-scroll-key":n,children:o.jsx(ln,{compact:!0,title:"No documents in this layer yet.",description:"Import a file to add document-backed entities."})}):o.jsx("div",{className:"v10-layer-detail-content","data-cg-scroll-key":n,children:o.jsx("div",{className:"v10-items-list",children:s.map(u=>{var m,y,b,k;const d=((m=u.properties.get(Oh))==null?void 0:m[0])??"",f=(y=u.connections.find(j=>j.predicate===S1||j.predicate===j1))==null?void 0:y.targetUri,h=f?e.find(j=>j.uri===f):void 0,g=((b=h==null?void 0:h.properties.get(C1))==null?void 0:b[0])??((k=u.properties.get(C1))==null?void 0:k[0]);return o.jsxs("div",{className:"v10-item-row",onClick:()=>l(u),children:[o.jsx("span",{className:"v10-item-icon",children:"📄"}),o.jsxs("div",{className:"v10-item-info",children:[o.jsx("div",{className:"v10-item-name",children:u.label}),o.jsxs("div",{className:"v10-item-meta-row",children:[d&&o.jsx("span",{className:"v10-item-type",children:d}),g&&o.jsxs("span",{className:"v10-item-count",children:["· ",Math.round(parseInt(g)/1024),"KB"]})]})]}),o.jsx("button",{className:"v10-item-promote-btn",onClick:j=>{j.stopPropagation(),l(u)},children:"Open →"})]},u.uri)})})})}function _j(e){return`SELECT ?g ?s ?p ?o WHERE {
1287
1287
  GRAPH ?g { ?s ?p ?o }
1288
1288
  ${zm(e)}
1289
1289
  }
@@ -1621,7 +1621,7 @@ ${n.join(`
1621
1621
  `);throw new Hm(s||"Unknown error")}if(e.structuredContent!=null)return e.structuredContent;const t=(a=e.content)==null?void 0:a.filter(s=>s.type==="text").map(s=>s.text??"");if(t!=null&&t.length){const s=t.join("");try{return JSON.parse(s)}catch{return s}}return null}var qm=class extends Error{constructor(t,n=[]){super(`[openui] No handler for tool "${t}". Available: ${n.join(", ")||"(none)"}`);jn(this,"toolName");jn(this,"availableTools");this.name="ToolNotFoundError",this.toolName=t,this.availableTools=n}};function kw(e){return JSON.stringify(e,(t,n)=>{if(n&&typeof n=="object"&&!Array.isArray(n)){const a={};for(const s of Object.keys(n).sort())a[s]=n[s];return a}if(n===void 0)return"__undefined__";if(typeof n=="number"){if(Number.isNaN(n))return"__NaN__";if(n===1/0)return"__Inf__";if(n===-1/0)return"__-Inf__"}return n})}function Q6(e,t,n){const a=n!=null?"::"+kw(n):"";return e+"::"+kw(t)+a}function X6(e){const t=new Map,n=new Map,a=new Map,s=new Set;let l={__openui_loading:[],__openui_refetching:[],__openui_errors:[]},u=JSON.stringify(l),d=!1,f=0;function h(){const D={__openui_loading:[],__openui_refetching:[],__openui_errors:[]};for(const[R,$]of t){const F=a.get($.cacheKey);if(F&&F.data!==void 0)D[R]=F.data;else if($.prevCacheKey){const K=a.get($.prevCacheKey);K&&K.data!==void 0?D[R]=K.data:D[R]=$.defaults}else D[R]=$.defaults;$.loading&&(D.__openui_loading.push(R),$.everFetched&&D.__openui_refetching.push(R)),$.error&&D.__openui_errors.push($.error)}for(const[R,$]of n)D[R]=$.result,$.error&&D.__openui_errors.push($.error);try{const R=JSON.stringify(D);if(R===u)return!1;l=D,u=R}catch{l=D,u=""}return!0}function g(){for(const D of[...s])D()}async function m(D,R){if(!e)return;const $=t.get(R);if(!$)return;const F=D,K=$.toolName,I=$.args;let H=a.get(F);H?H.inFlight=!0:(H={data:void 0,inFlight:!0},a.set(F,H)),$.loading=!0,h(),g();try{const B=await e.callTool(K,I??{});if(d)return;const W=t.get(R);if(!W||W.cacheKey!==F){H.inFlight=!1;return}if(H.data=B??null,W.everFetched=!0,W.error=void 0,W.prevCacheKey&&W.prevCacheKey!==F){const Q=W.prevCacheKey;W.prevCacheKey=void 0,y(Q)}}catch(B){const W=t.get(R);W&&W.cacheKey===F&&(B instanceof qm?W.error={source:"query",code:"tool-not-found",message:`Query tool "${K}" not found`,statementId:R,component:"Query",toolName:K,hint:B.availableTools.length?`Available tools: ${B.availableTools.join(", ")}`:void 0}:B instanceof Hm?W.error={source:"query",code:"mcp-error",message:`Query "${K}" returned an error: ${B.toolErrorText}`,statementId:R,component:"Query",toolName:K}:W.error={source:"query",code:"tool-error",message:`Query "${K}" failed: ${B instanceof Error?B.message:String(B)}`,statementId:R,component:"Query",toolName:K}),console.error(`Query "${K}" failed:`,B)}finally{H.inFlight=!1;const B=t.get(R);B&&B.cacheKey===F?(B.loading=!1,h()&&g(),B.needsRefetch&&(B.needsRefetch=!1,m(B.cacheKey,R))):h()&&g()}}function y(D){for(const R of t.values())if(R.cacheKey===D||R.prevCacheKey===D)return;a.delete(D)}function b(D){if(d)return;const R=new Set(D.map($=>$.statementId));for(const[$,F]of t)R.has($)||(F.timer&&clearInterval(F.timer),t.delete($),y(F.cacheKey),F.prevCacheKey&&y(F.prevCacheKey));for(const $ of D){if(!$.complete)continue;const F=Q6($.toolName,$.args,$.deps),K=t.get($.statementId);K?(K.cacheKey!==F&&(K.prevCacheKey=K.cacheKey),K.toolName=$.toolName,K.args=$.args,K.defaults=$.defaults,K.cacheKey=F):t.set($.statementId,{toolName:$.toolName,args:$.args,defaults:$.defaults,cacheKey:F,loading:!1,everFetched:!1,refreshInterval:0,needsRefetch:!1});const I=t.get($.statementId),H=a.get(F),B=H&&H.data!==void 0&&!H.inFlight;e&&!B&&!(H!=null&&H.inFlight)&&m(F,$.statementId);const W=$.refreshInterval??0;W!==I.refreshInterval&&(I.timer&&(clearInterval(I.timer),I.timer=void 0),W>0&&(I.timer=setInterval(()=>{var Q;d||!e||(Q=a.get(I.cacheKey))!=null&&Q.inFlight||m(I.cacheKey,$.statementId)},W*1e3)),I.refreshInterval=W)}h()&&g()}function k(D){const R=t.get(D);if(!R)return null;const $=a.get(R.cacheKey);if($&&$.data!==void 0)return $.data;if(R.prevCacheKey){const F=a.get(R.prevCacheKey);if(F&&F.data!==void 0)return F.data}return R.defaults}function j(D){var R;return((R=t.get(D))==null?void 0:R.loading)??!1}function N(){for(const D of t.values())if(D.loading)return!0;return!1}function S(D){var $;if(d||!e)return;const R=D!=null&&D.length?D.filter(F=>t.has(F)):[...t.keys()];for(const F of R){const K=t.get(F);K&&(($=a.get(K.cacheKey))!=null&&$.inFlight?K.needsRefetch=!0:m(K.cacheKey,F))}}function A(D){const R=new Set(D.map($=>$.statementId));for(const $ of n.keys())R.has($)||n.delete($);for(const $ of D){const F=n.get($.statementId);F?F.toolName!==$.toolName&&(F.toolName=$.toolName,F.result={status:"idle",data:null,error:null},F.error=void 0):n.set($.statementId,{toolName:$.toolName,result:{status:"idle"}})}h()&&g()}async function E(D,R,$){if(d||!e)return!1;const F=n.get(D);if(!F||F.result.status==="loading")return!1;const K=f;F.result={status:"loading"},h(),g();let I=!1;try{const H=await e.callTool(F.toolName,R);if(d||K!==f)return!1;F.result={status:"success",data:H},F.error=void 0,I=!0}catch(H){if(d||K!==f)return!1;const B=H instanceof Error?H.message:String(H);F.result={status:"error",error:B},H instanceof qm?F.error={source:"mutation",code:"tool-not-found",message:`Mutation tool "${F.toolName}" not found`,statementId:D,component:"Mutation",toolName:F.toolName,hint:H.availableTools.length?`Available tools: ${H.availableTools.join(", ")}`:void 0}:H instanceof Hm?F.error={source:"mutation",code:"mcp-error",message:`Mutation "${F.toolName}" returned an error: ${H.toolErrorText}`,statementId:D,component:"Mutation",toolName:F.toolName}:F.error={source:"mutation",code:"tool-error",message:`Mutation "${F.toolName}" failed: ${B}`,statementId:D,component:"Mutation",toolName:F.toolName}}return h(),g(),I&&($!=null&&$.length)&&S($),I}function T(D){var R;return((R=n.get(D))==null?void 0:R.result)??null}function U(D){return s.add(D),()=>s.delete(D)}function _(){return l}function z(){d=!1}function q(){d=!0,f++,s.clear();for(const D of t.values())D.timer&&(clearInterval(D.timer),D.timer=void 0),D.loading=!1,D.needsRefetch=!1;n.clear()}return{evaluateQueries:b,getResult:k,isLoading:j,isAnyLoading:N,invalidate:S,registerMutations:A,fireMutation:E,getMutationResult:T,subscribe:U,getSnapshot:_,activate:z,dispose:q}}function J6(){const e=new Map,t=new Set;let n={};function a(){const m=[...t];for(const y of m)y()}function s(){n=Object.fromEntries(e)}function l(m){return e.get(m)}function u(m,y){const b=e.get(m);if(!Object.is(b,y)){if(y&&b&&typeof y=="object"&&typeof b=="object"&&!Array.isArray(y)&&!Array.isArray(b)){const k=Object.keys(y),j=Object.keys(b);if(k.length===j.length&&k.every(N=>Object.is(y[N],b[N])))return}e.set(m,y),s(),a()}}function d(m){return t.add(m),()=>{t.delete(m)}}function f(){return n}function h(m,y){for(const b of Object.keys(y))e.set(b,y[b]);for(const b of Object.keys(m))e.has(b)||e.set(b,m[b]);s(),a()}function g(){e.clear(),t.clear(),n={}}return{get:l,set:u,subscribe:d,getSnapshot:f,initialize:h,dispose:g}}function Rr(e){return S6(e)}function eP(e){return R6(e)}const gC=w.createContext(null);function vC(){const e=w.useContext(gC);if(!e)throw new Error("useOpenUI must be used within a <Renderer /> component.");return e}function tP(){return vC().renderNode}w.createContext(void 0);function qh(e){return e&&typeof e=="object"&&!Array.isArray(e)&&"value"in e?e.value:e}function nP({response:e,library:t,isStreaming:n,onAction:a,onStateUpdate:s,initialState:l,toolProvider:u,onError:d},f){const h=w.useMemo(()=>q6(t.toJSONSchema(),t.root),[t]),g=w.useRef(null),m=w.useMemo(()=>{if(g.current=null,!e)return null;try{return h.set(e)}catch(W){return g.current={source:"parser",code:"parse-exception",message:`Parser crashed: ${W instanceof Error?W.message:String(W)}`,hint:"The response may contain syntax the parser cannot handle"},null}},[h,e]),y=w.useMemo(()=>J6(),[]),b=w.useMemo(()=>X6(u??null),[u]);w.useEffect(()=>(b.activate(),()=>b.dispose()),[b]);const k=w.useRef(Symbol());w.useEffect(()=>{if(!(m!=null&&m.stateDeclarations)&&!l)return;const W=`${JSON.stringify(m==null?void 0:m.stateDeclarations)}::${JSON.stringify(l)}`;if(k.current===W)return;k.current=W;const Q={};if(l)for(const[V,L]of Object.entries(l))V.startsWith("$")?Q[V]=L:y.set(V,L);y.initialize((m==null?void 0:m.stateDeclarations)??{},Q)},[m==null?void 0:m.stateDeclarations,y,l]);const j=w.useSyncExternalStore(y.subscribe,y.getSnapshot,y.getSnapshot),N=w.useSyncExternalStore(b.subscribe,b.getSnapshot,b.getSnapshot),S=w.useMemo(()=>({getState:W=>qh(y.get(W)),resolveRef:W=>{const Q=b.getMutationResult(W);return Q||b.getResult(W)}}),[y,b]);w.useEffect(()=>{if(n)return;const W=((m==null?void 0:m.queryStatements)??[]).map(Q=>{const V={};if(Q.deps)for(const L of Q.deps)V[L]=j[L];return{statementId:Q.statementId,toolName:Q.toolAST?vt(Q.toolAST,S):"",args:Q.argsAST?vt(Q.argsAST,S):null,defaults:Q.defaultsAST?vt(Q.defaultsAST,S):null,refreshInterval:Q.refreshAST?vt(Q.refreshAST,S):void 0,deps:Object.keys(V).length>0?V:void 0,complete:Q.complete}});b.evaluateQueries(W)},[n,m==null?void 0:m.queryStatements,S,b,j]),w.useEffect(()=>{if(n)return;const W=((m==null?void 0:m.mutationStatements)??[]).map(Q=>({statementId:Q.statementId,toolName:Q.toolAST?vt(Q.toolAST,S):""}));b.registerMutations(W)},[n,m==null?void 0:m.mutationStatements,S,b]);const A=w.useRef({onAction:a,onStateUpdate:s,onError:d});A.current={onAction:a,onStateUpdate:s,onError:d};const E=w.useRef(m);E.current=m;const T=w.useRef(null);w.useEffect(()=>(T.current=y.getSnapshot(),y.subscribe(()=>{var Q,V;const W=y.getSnapshot();W!==T.current&&(T.current=null,(V=(Q=A.current).onStateUpdate)==null||V.call(Q,W))})),[y]);const U=w.useCallback((W,Q)=>{if(!W)return qh(y.get(Q));const V=y.get(W);if(!(!V||typeof V!="object"||Array.isArray(V)))return qh(V[Q])},[y]),_=w.useCallback((W,Q,V,L,P=!0)=>{var O,ne;const G={value:L,componentType:Q};if(!W)y.set(V,G);else{const ue=y.get(W),le=ue&&typeof ue=="object"&&!Array.isArray(ue)?ue:{};y.set(W,{...le,[V]:G})}P&&((ne=(O=A.current).onStateUpdate)==null||ne.call(O,y.getSnapshot()))},[y]),z=w.useCallback(W=>{if(W){const Q=y.get(W);if(Q&&typeof Q=="object"&&!Array.isArray(Q))return{[W]:Q}}return y.getSnapshot()},[y]),q=w.useCallback(async(W,Q,V)=>{var O,ne,ue;const L=z(Q),{onAction:P}=A.current;if(V&&!("steps"in V)){const le=V.type||Lu.ContinueConversation,be={...V.params||{}};V.url&&(be.url=V.url),V.context&&(be.context=V.context),P==null||P({type:le,params:be,humanFriendlyMessage:W,formState:L,formName:Q});return}const G=V;if(G!=null&&G.steps){for(const le of G.steps)switch(le.type){case Ir.Run:if(le.refType==="mutation"){const be=(ne=(O=E.current)==null?void 0:O.mutationStatements)==null?void 0:ne.find(Ee=>Ee.statementId===le.statementId),_e=be!=null&&be.argsAST?vt(be.argsAST,S):{};if(!await b.fireMutation(le.statementId,_e))return}else b.invalidate([le.statementId]);break;case Ir.ToAssistant:P==null||P({type:Lu.ContinueConversation,params:le.context?{context:le.context}:{},humanFriendlyMessage:le.message,formState:L,formName:Q});break;case Ir.OpenUrl:P==null||P({type:Lu.OpenUrl,params:{url:le.url},humanFriendlyMessage:"",formState:L,formName:Q});break;case Ir.Set:{if(!le.valueAST){console.warn(`[openui] Set action for ${le.target} has no valueAST — skipping`);break}const be=vt(le.valueAST,S);y.set(le.target,be);break}case Ir.Reset:{const be=((ue=E.current)==null?void 0:ue.stateDeclarations)??{};for(const _e of le.targets)y.set(_e,be[_e]??null);break}}return}P==null||P({type:Lu.ContinueConversation,params:{},humanFriendlyMessage:W,formState:L,formName:Q})},[b,S,z,y]),D=w.useRef([]),R=w.useRef(n);R.current=n;const $=w.useCallback(W=>{R.current||D.current.push(W)},[]),F=w.useMemo(()=>({library:t,renderNode:f,triggerAction:q,isStreaming:n,getFieldValue:U,setFieldValue:_,store:y,evaluationContext:S,reportError:$}),[t,f,n,q,U,_,y,S,$]),K=w.useRef([]),I=w.useMemo(()=>{if(!(m!=null&&m.root))return m;const W=[],Q={ctx:S,library:t,store:y,errors:W};try{const V=hC(m.root,Q);return K.current=W,{...m,root:V}}catch(V){const L=V instanceof Error?V.message:String(V);return W.push({source:"runtime",code:"runtime-error",message:`Prop evaluation failed: ${L}`}),K.current=W,m}},[m,S,t,y,j,N]),H=N.__openui_loading.length>0,B=w.useRef("");return w.useEffect(()=>{var V,L,P,G;if(n){B.current!==""&&(B.current="",(L=(V=A.current).onError)==null||L.call(V,[]));return}const W=[];g.current&&W.push(g.current),e&&!(m!=null&&m.root)&&!g.current&&W.push({source:"parser",code:"parse-failed",message:m?"Code parsed but produced no renderable root component":"Response could not be parsed as valid openui-lang",hint:`The entire response must be valid openui-lang code starting with root = ${t.root??"Root"}(...)`}),(G=(P=m==null?void 0:m.meta)==null?void 0:P.errors)!=null&&G.length&&W.push(...V6(m.meta.errors,t.toJSONSchema(),Object.keys(t.components))),W.push(...K.current),W.push(...D.current),D.current=[],W.push(...N.__openui_errors??[]);const Q=JSON.stringify(W);if(Q!==B.current){if(B.current=Q,A.current.onError)A.current.onError(W);else if(W.length>0)for(const O of W)console.warn(`[openui] ${O.source}/${O.code}: ${O.message}`)}},[n,e,m,I,N,t]),{result:I,parseResult:m,contextValue:F,isQueryLoading:H}}var rP=class extends w.Component{constructor(t){super(t);jn(this,"lastValidChildren",null);this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidMount(){this.state.hasError||(this.lastValidChildren=this.props.children)}componentDidUpdate(t){this.state.hasError||(this.lastValidChildren=this.props.children),this.state.hasError&&t.children!==this.props.children&&this.setState({hasError:!1})}componentDidCatch(t){var a,s;const n=this.props.componentName??"Unknown";(s=(a=this.props).onError)==null||s.call(a,{source:"runtime",code:"render-error",component:n,message:`Component ${n} render failed: ${t.message}`})}render(){return this.state.hasError?this.lastValidChildren:this.props.children}};function yC(e){if(e==null)return null;if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e))return e.map((t,n)=>o.jsx(w.Fragment,{children:yC(t)},n));if(typeof e=="object"&&e!==null){const t=e;if(t.type==="element")return o.jsx(bC,{node:t})}return null}function bC({node:e}){var s;const{library:t,reportError:n}=vC(),a=(s=t.components[e.typeName])==null?void 0:s.component;return a?o.jsx(rP,{componentName:e.typeName,onError:n,children:o.jsx(aP,{el:e,Comp:a})}):null}function aP({el:e,Comp:t}){const n=tP();return o.jsx(t,{props:e.props,renderNode:n})}let Sw=!1;function iP(){if(Sw||typeof document>"u")return;Sw=!0;const e=document.createElement("style");e.textContent="@keyframes openui-spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }",document.head.appendChild(e)}const sP=()=>o.jsx("div",{style:{position:"absolute",top:8,right:8,width:16,height:16,border:"2px solid #e5e7eb",borderTopColor:"#3b82f6",borderRadius:"50%",animation:"openui-spin 0.6s linear infinite",zIndex:10}});function oP({response:e,library:t,isStreaming:n=!1,onAction:a,onStateUpdate:s,initialState:l,onParseResult:u,toolProvider:d,queryLoader:f,onError:h}){w.useInsertionEffect(()=>{iP()},[]);const g=w.useRef(u);g.current=u;const m=w.useRef(d);m.current=d;const y=w.useRef({async callTool(S,A){const E=m.current??null;if(E==null)throw new Error("[openui] toolProvider is null");if(typeof E.callTool=="function")return Y6(await E.callTool({name:S,arguments:A}));const T=E,U=T[S];if(!U)throw new qm(S,Object.keys(T));return U(A)}}),{result:b,parseResult:k,contextValue:j,isQueryLoading:N}=nP({response:e,library:t,isStreaming:n,onAction:a,onStateUpdate:s,initialState:l,toolProvider:d!=null?y.current:null,onError:h},yC);return w.useEffect(()=>{var S;(S=g.current)==null||S.call(g,k)},[k]),b!=null&&b.root?o.jsx(gC.Provider,{value:j,children:o.jsxs("div",{style:{position:"relative"},children:[N&&(f??o.jsx(sP,{})),o.jsx("div",{style:{opacity:N?.7:1,transition:"opacity 0.2s ease"},children:o.jsx(bC,{node:b.root})})]})}):null}w.createContext(null);function lP(e){if(typeof e!="string")return null;const t=e.trim();if(!t)return null;try{const n=new URL(t,"https://placeholder.invalid");return n.origin==="https://placeholder.invalid"||n.protocol==="http:"||n.protocol==="https:"||n.protocol==="mailto:"?t:null}catch{return null}}const cP=({props:e,renderNode:t})=>{const n=e.children;return o.jsxs("div",{className:"v10-genui-root",children:[e.title?o.jsx("div",{className:"v10-genui-root-title",children:e.title}):null,Array.isArray(n)?n.map((a,s)=>o.jsx(Ve.Fragment,{children:t(a)},s)):t(n)]})},uP=({props:e})=>{var t;return o.jsxs("div",{className:"v10-genui-card v10-genui-entity-card",children:[o.jsxs("div",{className:"v10-genui-card-head",children:[o.jsx("div",{className:"v10-genui-card-title",children:e.name}),e.typeLabel?o.jsx("div",{className:"v10-genui-card-type",children:e.typeLabel}):null]}),e.subtitle?o.jsx("div",{className:"v10-genui-card-subtitle",children:e.subtitle}):null,(t=e.chips)!=null&&t.length?o.jsx("div",{className:"v10-genui-chips",children:e.chips.map((n,a)=>o.jsxs("span",{className:`v10-genui-chip tone-${n.tone??"default"}`,children:[o.jsx("span",{className:"v10-genui-chip-label",children:n.label}),o.jsx("span",{className:"v10-genui-chip-value",children:n.value})]},a))}):null]})},dP=({props:e})=>o.jsx("div",{className:"v10-genui-stats-grid",children:e.stats.map((t,n)=>o.jsxs("div",{className:"v10-genui-stat",title:t.hint,children:[o.jsx("div",{className:"v10-genui-stat-value",children:t.value}),o.jsx("div",{className:"v10-genui-stat-label",children:t.label})]},n))}),pP=({props:e})=>o.jsxs("div",{className:"v10-genui-section",children:[e.heading?o.jsx("div",{className:"v10-genui-section-heading",children:e.heading}):null,o.jsx("div",{className:"v10-genui-triple-table",children:e.rows.map((t,n)=>o.jsxs("div",{className:"v10-genui-triple-row",children:[o.jsx("div",{className:"v10-genui-triple-predicate",children:hv(t.predicate)}),o.jsx("div",{className:"v10-genui-triple-object",children:wP(t.object)})]},n))})]}),fP=({props:e})=>o.jsxs("div",{className:"v10-genui-section",children:[e.heading?o.jsx("div",{className:"v10-genui-section-heading",children:e.heading}):null,o.jsx("div",{className:"v10-genui-type-groups",children:e.groups.map((t,n)=>o.jsxs("div",{className:"v10-genui-type-group",children:[o.jsxs("div",{className:"v10-genui-type-group-head",children:[t.icon?o.jsx("span",{className:"v10-genui-type-icon",children:t.icon}):null,o.jsx("span",{className:"v10-genui-type-label",children:t.typeLabel}),o.jsx("span",{className:"v10-genui-type-count",children:t.items.length})]}),o.jsx("div",{className:"v10-genui-type-items",children:t.items.map((a,s)=>o.jsxs("div",{className:"v10-genui-type-item",title:a.uri,children:[o.jsx("div",{className:"v10-genui-type-item-label",children:a.label}),a.sub?o.jsx("div",{className:"v10-genui-type-item-sub",children:a.sub}):null]},s))})]},n))})]}),hP=({props:e})=>o.jsxs("div",{className:"v10-genui-section",children:[o.jsxs("div",{className:"v10-genui-section-heading",children:[o.jsx("span",{children:e.heading}),e.predicate?o.jsxs("span",{className:"v10-genui-section-sub",children:["· ",hv(e.predicate)]}):null]}),o.jsx("div",{className:"v10-genui-crossref",children:e.items.map((t,n)=>o.jsxs("div",{className:"v10-genui-crossref-item",title:t.uri,children:[o.jsx("span",{className:"v10-genui-crossref-label",children:t.label}),t.sub?o.jsx("span",{className:"v10-genui-crossref-sub",children:t.sub}):null]},n))})]}),mP=({props:e})=>o.jsxs("div",{className:"v10-genui-card v10-genui-package-card",children:[o.jsxs("div",{className:"v10-genui-card-head",children:[o.jsx("span",{className:"v10-genui-card-icon",style:{color:"#a855f7"},children:"📦"}),o.jsx("div",{className:"v10-genui-card-title",children:e.name}),e.folder?o.jsxs("div",{className:"v10-genui-card-type",children:["packages/",e.folder]}):null]}),e.description?o.jsx("div",{className:"v10-genui-card-subtitle",children:e.description}):null,o.jsxs("div",{className:"v10-genui-stats-grid",children:[typeof e.fileCount=="number"&&o.jsx(zu,{label:"Files",value:e.fileCount}),typeof e.classCount=="number"&&o.jsx(zu,{label:"Classes",value:e.classCount}),typeof e.functionCount=="number"&&o.jsx(zu,{label:"Functions",value:e.functionCount}),typeof e.interfaceCount=="number"&&o.jsx(zu,{label:"Interfaces",value:e.interfaceCount})]})]}),gP=({props:e})=>o.jsxs("div",{className:"v10-genui-card v10-genui-file-card",children:[o.jsxs("div",{className:"v10-genui-card-head",children:[o.jsx("span",{className:"v10-genui-card-icon",style:{color:"#3b82f6"},children:"📄"}),o.jsx("div",{className:"v10-genui-card-title",children:SP(e.path)}),e.language?o.jsxs("div",{className:"v10-genui-card-type",children:[".",e.language]}):null]}),o.jsx("div",{className:"v10-genui-card-subtitle",children:e.path}),o.jsxs("div",{className:"v10-genui-chips",children:[e.packageName?o.jsxs("span",{className:"v10-genui-chip tone-info",children:[o.jsx("span",{className:"v10-genui-chip-label",children:"pkg"}),o.jsx("span",{className:"v10-genui-chip-value",children:e.packageName})]}):null,typeof e.lineCount=="number"?o.jsxs("span",{className:"v10-genui-chip",children:[o.jsx("span",{className:"v10-genui-chip-label",children:"lines"}),o.jsx("span",{className:"v10-genui-chip-value",children:e.lineCount})]}):null]})]}),vP=({props:e})=>o.jsxs("div",{className:"v10-genui-card v10-genui-decision-card",children:[o.jsxs("div",{className:"v10-genui-card-head",children:[o.jsx("span",{className:"v10-genui-card-icon",style:{color:"#ef4444"},children:"◆"}),o.jsx("div",{className:"v10-genui-card-title",children:e.title}),e.status?o.jsx("div",{className:`v10-genui-status-chip status-${e.status}`,children:e.status}):null]}),e.date?o.jsxs("div",{className:"v10-genui-card-subtitle",children:["Decided ",e.date]}):null,e.context?o.jsx($u,{heading:"Context",body:e.context}):null,e.outcome?o.jsx($u,{heading:"Outcome",body:e.outcome}):null,e.consequences?o.jsx($u,{heading:"Consequences",body:e.consequences}):null,e.alternatives?o.jsx($u,{heading:"Alternatives considered",body:e.alternatives}):null]}),yP=({props:e})=>o.jsxs("div",{className:"v10-genui-card v10-genui-pr-card",children:[o.jsxs("div",{className:"v10-genui-card-head",children:[o.jsx("span",{className:"v10-genui-card-icon",style:{color:"#f59e0b"},children:"⇄"}),o.jsxs("div",{className:"v10-genui-card-title",children:[typeof e.number=="number"?o.jsxs("span",{className:"v10-genui-pr-num",children:["#",e.number]}):null,e.title]}),e.state?o.jsx("div",{className:`v10-genui-status-chip pr-state-${e.state}`,children:e.state}):null]}),o.jsxs("div",{className:"v10-genui-chips",children:[e.author?o.jsxs("span",{className:"v10-genui-chip",children:[o.jsx("span",{className:"v10-genui-chip-label",children:"by"}),o.jsx("span",{className:"v10-genui-chip-value",children:e.author})]}):null,e.mergedAt?o.jsxs("span",{className:"v10-genui-chip tone-success",children:[o.jsx("span",{className:"v10-genui-chip-label",children:"merged"}),o.jsx("span",{className:"v10-genui-chip-value",children:e.mergedAt.split("T")[0]})]}):null,(()=>{const t=lP(e.url);return t?o.jsxs("a",{className:"v10-genui-chip tone-info",href:t,target:"_blank",rel:"noopener noreferrer",children:[o.jsx("span",{className:"v10-genui-chip-label",children:"view"}),o.jsx("span",{className:"v10-genui-chip-value",children:"github"})]}):null})()]}),e.body?o.jsx("div",{className:"v10-genui-pr-body",children:e.body}):null]}),bP=({props:e})=>o.jsxs("div",{className:"v10-genui-card v10-genui-task-card",children:[o.jsxs("div",{className:"v10-genui-card-head",children:[o.jsx("span",{className:"v10-genui-card-icon",style:{color:"#06b6d4"},children:"✓"}),o.jsx("div",{className:"v10-genui-card-title",children:e.title}),e.status?o.jsx("div",{className:`v10-genui-status-chip task-status-${e.status}`,children:e.status.replace("_"," ")}):null,e.priority?o.jsx("div",{className:`v10-genui-priority-chip priority-${e.priority}`,children:e.priority.toUpperCase()}):null]}),o.jsxs("div",{className:"v10-genui-chips",children:[e.assignee?o.jsxs("span",{className:"v10-genui-chip",children:[o.jsx("span",{className:"v10-genui-chip-label",children:"assignee"}),o.jsxs("span",{className:"v10-genui-chip-value",children:["@",e.assignee]})]}):null,typeof e.estimate=="number"?o.jsxs("span",{className:"v10-genui-chip",children:[o.jsx("span",{className:"v10-genui-chip-label",children:"est"}),o.jsxs("span",{className:"v10-genui-chip-value",children:[e.estimate,"h"]})]}):null]})]}),xP=({props:e})=>{var t;return o.jsxs("div",{className:"v10-genui-vm-panel",children:[o.jsxs("div",{className:"v10-genui-vm-panel-head",children:[o.jsxs("div",{className:"v10-genui-vm-badge",children:[o.jsx("span",{className:"v10-genui-vm-badge-dot"}),"Verifiable Memory"]}),o.jsx("div",{className:"v10-genui-vm-title",children:"On-chain provenance"})]}),o.jsxs("div",{className:"v10-genui-vm-grid",children:[e.onChain?o.jsxs("div",{className:"v10-genui-vm-block",children:[o.jsx("div",{className:"v10-genui-vm-block-heading",children:"Anchoring"}),e.onChain.txHash?o.jsx(Wi,{label:"tx",value:jw(e.onChain.txHash),mono:!0}):null,e.onChain.blockNumber?o.jsx(Wi,{label:"block",value:String(e.onChain.blockNumber),mono:!0}):null,e.onChain.chain?o.jsx(Wi,{label:"chain",value:e.onChain.chain}):null]}):null,e.consensus?o.jsxs("div",{className:"v10-genui-vm-block",children:[o.jsxs("div",{className:"v10-genui-vm-block-heading",children:["Consensus ",e.consensus.quorum?o.jsx("span",{className:"v10-genui-vm-quorum",children:e.consensus.quorum}):null]}),(e.consensus.signers??[]).map((n,a)=>o.jsxs("div",{className:"v10-genui-vm-signer",children:[o.jsx("div",{className:"v10-genui-vm-signer-dot"}),o.jsxs("div",{className:"v10-genui-vm-signer-body",children:[o.jsx("div",{className:"v10-genui-vm-signer-label",children:n.label??kP(n.did)}),o.jsx("div",{className:"v10-genui-vm-signer-did",children:n.did})]}),typeof n.reputation=="number"?o.jsxs("div",{className:"v10-genui-vm-rep",children:["rep ",n.reputation]}):null]},a))]}):null,e.knowledgeAsset?o.jsxs("div",{className:"v10-genui-vm-block",children:[o.jsx("div",{className:"v10-genui-vm-block-heading",children:"Knowledge asset"}),e.knowledgeAsset.ual?o.jsx(Wi,{label:"ual",value:e.knowledgeAsset.ual,mono:!0}):null,e.knowledgeAsset.contentHash?o.jsx(Wi,{label:"hash",value:jw(e.knowledgeAsset.contentHash),mono:!0}):null,e.knowledgeAsset.tracLocked?o.jsx(Wi,{label:"trac",value:e.knowledgeAsset.tracLocked}):null,e.knowledgeAsset.tokenId?o.jsx(Wi,{label:"nft",value:`#${e.knowledgeAsset.tokenId}`}):null]}):null,(t=e.timeline)!=null&&t.length?o.jsxs("div",{className:"v10-genui-vm-block",children:[o.jsx("div",{className:"v10-genui-vm-block-heading",children:"Timeline"}),e.timeline.map((n,a)=>o.jsxs("div",{className:"v10-genui-vm-timeline-row",children:[o.jsx("div",{className:"v10-genui-vm-timeline-dot"}),o.jsx("div",{className:"v10-genui-vm-timeline-label",children:n.label}),o.jsx("div",{className:"v10-genui-vm-timeline-at",children:n.at})]},a))]}):null]})]})},zu=({label:e,value:t})=>o.jsxs("div",{className:"v10-genui-stat",children:[o.jsx("div",{className:"v10-genui-stat-value",children:t}),o.jsx("div",{className:"v10-genui-stat-label",children:e})]}),$u=({heading:e,body:t})=>o.jsxs("div",{className:"v10-genui-decision-section",children:[o.jsx("div",{className:"v10-genui-decision-section-heading",children:e}),o.jsx("div",{className:"v10-genui-decision-section-body",children:t})]}),Wi=({label:e,value:t,mono:n})=>o.jsxs("div",{className:"v10-genui-prov-row",children:[o.jsx("span",{className:"v10-genui-prov-label",children:e}),o.jsx("span",{className:`v10-genui-prov-value${n?" mono":""}`,children:t})]});function hv(e){return e.replace(/^"|"$/g,"").replace(/^<|>$/g,"").replace("http://www.w3.org/1999/02/22-rdf-syntax-ns#","rdf:").replace("http://www.w3.org/2000/01/rdf-schema#","rdfs:").replace("http://www.w3.org/2001/XMLSchema#","xsd:").replace("http://schema.org/","schema:").replace("http://dkg.io/ontology/code/","code:").replace("http://dkg.io/ontology/github/","gh:").replace("http://dkg.io/ontology/decisions/","dec:").replace("http://dkg.io/ontology/tasks/","task:").replace("http://dkg.io/ontology/profile/","prof:")}function wP(e){return hv(e).replace(/\^\^<?.*$/,"").replace(/^"(.+)"$/,"$1")}function jw(e){return e?e.length<=16?e:`${e.slice(0,8)}…${e.slice(-6)}`:""}function kP(e){return e?e.length>22?`${e.slice(0,12)}…${e.slice(-6)}`:e:""}function SP(e){const t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}const jP=Rr({name:"EntityDetail",description:"Root container for a single-entity detail view. Accepts any number of child blocks (EntityCard, PackageCard, VerifiedProvenancePanel, etc.). Always use this as the outermost element.",props:Pt({title:$e().optional().describe("Optional top-of-panel title override (defaults to the entity rdfs:label)")}),component:cP}),CP=Rr({name:"EntityCard",description:"Compact header card for any entity: name, rdf:type label, optional subtitle, and up to 6 small stat chips.",props:Pt({name:$e().describe("Display name / label of the entity"),typeLabel:$e().optional().describe('Human-readable rdf:type label (e.g. "Package", "Pull Request")'),subtitle:$e().optional().describe("Short supporting text (e.g. path, author, date)"),chips:Ia(Pt({label:$e(),value:$e(),tone:fo(["default","success","warn","danger","info"]).optional()})).max(6).optional()}),component:uP}),NP=Rr({name:"EntityStatsGrid",description:"Grid of numeric stats with labels. Use for summarising counts (files, classes, additions, deletions).",props:Pt({stats:Ia(Pt({label:$e(),value:uv([$e(),aa()]),hint:$e().optional()})).min(1).max(8)}),component:dP}),EP=Rr({name:"TripleTable",description:"Fallback raw-triples table. Use sparingly — only when the entity has no better structured components in this library.",props:Pt({heading:$e().optional(),rows:Ia(Pt({predicate:$e(),object:$e()})).max(60)}),component:pP}),AP=Rr({name:"EntityTypeList",description:"Grouped list of child entities by rdf:type. Great for showing a File's contained classes/functions/interfaces as separate sections.",props:Pt({heading:$e().optional(),groups:Ia(Pt({typeLabel:$e(),icon:$e().optional(),items:Ia(Pt({label:$e(),uri:$e().optional(),sub:$e().optional()})).max(30)})).max(8)}),component:fP}),TP=Rr({name:"CrossRefList",description:"List of cross-references following a single predicate (e.g. code:imports, github:affects, decisions:affects). Each item can show a short subtitle.",props:Pt({heading:$e().describe('Human-readable heading (e.g. "Imports", "Affected files")'),predicate:$e().optional(),items:Ia(Pt({label:$e(),uri:$e().optional(),sub:$e().optional()})).max(40)}),component:hP}),_P=Rr({name:"PackageCard",description:"Specialised card for a code:Package entity: name, folder, description, and a mini-stats strip.",props:Pt({name:$e(),folder:$e().optional(),description:$e().optional(),fileCount:aa().optional(),classCount:aa().optional(),functionCount:aa().optional(),interfaceCount:aa().optional()}),component:mP}),RP=Rr({name:"FileCard",description:"Specialised card for a code:File entity: path, language, line count, owning package.",props:Pt({path:$e(),language:$e().optional(),lineCount:aa().optional(),packageName:$e().optional()}),component:gP}),OP=Rr({name:"DecisionCard",description:"Specialised card for a decisions:Decision entity: title, status badge, date, context/outcome quoted sections.",props:Pt({title:$e(),status:fo(["proposed","accepted","rejected","superseded"]).optional(),date:$e().optional(),context:$e().optional(),outcome:$e().optional(),consequences:$e().optional(),alternatives:$e().optional()}),component:vP}),LP=Rr({name:"PRCard",description:"Specialised card for a github:PullRequest entity: title + #number, state, author, merged badge, body preview.",props:Pt({title:$e(),number:aa().optional(),state:fo(["open","closed","merged"]).optional(),author:$e().optional(),mergedAt:$e().optional(),body:$e().optional(),url:$e().optional()}),component:yP}),MP=Rr({name:"TaskCard",description:"Specialised card for a tasks:Task entity: title, status chip, priority, assignee, estimate.",props:Pt({title:$e(),status:fo(["todo","in_progress","blocked","done","cancelled"]).optional(),priority:fo(["p0","p1","p2","p3"]).optional(),assignee:$e().optional(),estimate:aa().optional()}),component:bP}),DP=Rr({name:"VerifiedProvenancePanel",description:"The Verifiable Memory hero block. Use at the top of any entity in the VM layer. Surfaces on-chain anchor (tx hash, block), consensus (signing agents with reputation), knowledge-asset identity (UAL, content hash, TRAC locked, NFT token id), and finalisation timeline.",props:Pt({onChain:Pt({txHash:$e().optional(),blockNumber:uv([$e(),aa()]).optional(),chain:$e().optional()}).optional(),consensus:Pt({signers:Ia(Pt({did:$e(),label:$e().optional(),reputation:aa().optional(),signature:$e().optional()})).max(10).optional(),quorum:$e().optional().describe('e.g. "3 of 5"')}).optional(),knowledgeAsset:Pt({ual:$e().optional(),contentHash:$e().optional(),tracLocked:$e().optional(),tokenId:$e().optional()}).optional(),timeline:Ia(Pt({label:$e(),at:$e()})).max(6).optional()}),component:xP}),xC=eP({components:[jP,CP,NP,EP,AP,TP,_P,RP,OP,LP,MP,DP],root:"EntityDetail",componentGroups:[{name:"Generic",components:["EntityDetail","EntityCard","EntityStatsGrid","EntityTypeList","CrossRefList","TripleTable"]},{name:"Code domain",components:["PackageCard","FileCard"]},{name:"GitHub domain",components:["PRCard"]},{name:"Decisions & tasks",components:["DecisionCard","TaskCard"]},{name:"Verifiable memory",components:["VerifiedProvenancePanel"]}]});let Gh=null;function zP(){return Gh===null&&(Gh=xC.prompt({preamble:"You are composing a single-entity detail panel for the DKG Node UI. Use only the components below to build a rich, structured view. Always wrap the response in the EntityDetail root element.",additionalRules:["Prefer specialised cards (PackageCard, PRCard, DecisionCard, TaskCard, FileCard) when the rdf:type matches.","Include VerifiedProvenancePanel at the very top if the entity appears in verifiable memory or has on-chain / signature triples.","Keep the tree compact: aim for 3–8 top-level blocks.","Do not invent triple data — only use values present in the provided triples."]})),Gh}async function*$P(e){const t=await fetch("/api/genui/render",{method:"POST",headers:{"Content-Type":"application/json",...Ft()},body:JSON.stringify({contextGraphId:e.contextGraphId,entityUri:e.entityUri,libraryPrompt:e.libraryPrompt}),signal:e.signal});if(!t.ok||!t.body){let l=`HTTP ${t.status}`;try{const u=await t.json();u!=null&&u.error&&(l=u.error)}catch{}yield{type:"error",error:l};return}const n=t.body.getReader(),a=new TextDecoder;let s="";try{for(;;){const{value:l,done:u}=await n.read();if(u)break;s+=a.decode(l,{stream:!0});let d;for(;(d=s.indexOf(`
1622
1622
 
1623
1623
  `))!==-1;){const f=s.slice(0,d);s=s.slice(d+2);const h=Cw(f);h&&(yield h)}}if(s.trim()){const l=Cw(s);l&&(yield l)}}finally{n.releaseLock()}}function Cw(e){let t="message",n="";for(const a of e.split(`
1624
- `))a.startsWith("event:")?t=a.slice(6).trim():a.startsWith("data:")&&(n+=a.slice(5).trim());if(!n)return null;try{const a=JSON.parse(n);switch(t){case"start":return{type:"start",...a};case"delta":return{type:"delta",text:a.text??""};case"final":return{type:"final",content:a.content??""};case"error":return{type:"error",error:a.error??"unknown error"};case"done":return{type:"done"};default:return null}}catch{return null}}const IP=({contextGraphId:e,entityUri:t,placeholder:n,fallback:a})=>{const[s,l]=Ve.useState(""),[u,d]=Ve.useState(!0),[f,h]=Ve.useState(null);return Ve.useEffect(()=>{const g=new AbortController;let m="";return l(""),h(null),d(!0),(async()=>{try{const y=zP();for await(const b of $P({contextGraphId:e,entityUri:t,libraryPrompt:y,signal:g.signal}))if(b.type==="delta")m+=b.text,l(m);else if(b.type==="final")b.content&&(m=b.content,l(b.content));else if(b.type==="error"){h(b.error);break}else if(b.type==="done")break}catch(y){y.name!=="AbortError"&&h(y.message)}finally{d(!1)}})(),()=>g.abort()},[e,t]),f?a?o.jsx(o.Fragment,{children:a(f)}):o.jsx(UP,{error:f}):!s&&u?o.jsx(o.Fragment,{children:n??o.jsx("div",{className:"v10-genui-loading",children:"Composing detail view…"})}):o.jsx("div",{className:"v10-genui-panel",children:o.jsx(oP,{response:s,library:xC,isStreaming:u})})},PP="LLM not configured",UP=({error:e})=>{const t=fn(a=>a.openTab);return e.includes(PP)?o.jsxs("div",{className:"v10-genui-error v10-genui-error-cta",children:[o.jsxs("div",{className:"v10-genui-error-head",children:[o.jsx("span",{className:"v10-genui-error-icon",children:"⚙"}),o.jsxs("div",{children:[o.jsx("div",{className:"v10-genui-error-title",children:"Set up your LLM to enable GenUI"}),o.jsx("div",{className:"v10-genui-error-desc",children:"GenUI streams entity detail views from an OpenAI-compatible model. Add an API key in Settings and open this entity again."})]})]}),o.jsx("button",{className:"v10-genui-error-cta-btn",onClick:()=>t({id:"settings",label:"Settings",closable:!0}),children:"Open Settings →"})]}):o.jsxs("div",{className:"v10-genui-error",children:["GenUI unavailable: ",e]})};function Nw({entity:e,profile:t}){const n=w.useMemo(()=>{for(const d of e.subGraphs)if(d!=="meta")return d;return null},[e.subGraphs]);if(!n||!t)return null;const a=t.forSubGraph(n),s=(a==null?void 0:a.color)??"#64748b",l=(a==null?void 0:a.icon)??"•",u=(a==null?void 0:a.displayName)??n;return o.jsxs("span",{className:"v10-subgraph-badge",style:{"--sg-color":s},title:`In sub-graph: ${u}`,children:[o.jsx("span",{className:"v10-subgraph-badge-icon",style:{color:s},children:l}),o.jsx("span",{className:"v10-subgraph-badge-label",children:u})]})}function BP({entity:e,contextGraphId:t,onVerified:n}){const a=Ua(),[s,l]=w.useState(!1),[u,d]=w.useState(null),[f,h]=w.useState(null),[g,m]=w.useState(null),y=e.trustLevel,b=w.useMemo(()=>{if(!a)return null;for(const E of e.types){const T=a.forType(E);if(T&&(y==="working"&&(T.promoteLabel||T.promoteHint)||y==="shared"&&(T.publishLabel||T.publishHint)))return T}return null},[e.types,a,y]),k=w.useMemo(()=>{if(!a)return null;for(const E of e.subGraphs){if(E==="meta")continue;const T=a.forSubGraph(E);if(T!=null&&T.sourceAssertion)return{binding:T,subGraph:E}}return null},[e.subGraphs,a]);if(y==="verified"||!b)return null;const j=y==="working"?{kind:"promote",label:b.promoteLabel??"Promote to Shared Memory",hint:b.promoteHint??"Shares the complete owning Knowledge Asset with the team.",busyCopy:"Sharing…",disabled:!(k!=null&&k.binding.sourceAssertion),disabledReason:k!=null&&k.binding.sourceAssertion?null:`No sourceAssertion declared on the sub-graph profile — add profile:sourceAssertion to the SubGraphBinding for "${[...e.subGraphs].filter(E=>E!=="meta")[0]??"?"}".`}:{kind:"publish",label:b.publishLabel??"Verify on DKG",hint:b.publishHint??"Publishes the complete owning Knowledge Asset on-chain.",busyCopy:"Anchoring…",disabled:!(k!=null&&k.binding.sourceAssertion),disabledReason:k!=null&&k.binding.sourceAssertion?null:"This entity is not part of a named Shared-Memory asset, so it cannot be published to Verifiable Memory from here."},N=async()=>{if(j.disabled)return;l(!0),m(null),d(null),h(j.kind);const E=(k==null?void 0:k.binding.sourceAssertion)??"assertion";try{if(j.kind==="promote"){const T=await lo(t,k.binding.sourceAssertion,k.subGraph?{subGraphName:k.subGraph}:{});d(_g(E,T))}else{const T=await Ag(t,k.binding.sourceAssertion,k.subGraph?{subGraphName:k.subGraph}:{});d(T)}n()}catch(T){const U=j.kind==="promote"?co(E,T):null,_=U?U.message:(T==null?void 0:T.message)??"Action failed";m(_)}finally{l(!1)}},S=E=>!!E&&"status"in E,A=E=>!!E&&"kind"in E;return o.jsxs("div",{className:`v10-ka-verify v10-ka-verify-${j.kind}`,children:[o.jsxs("div",{className:"v10-ka-verify-head",children:[o.jsx("span",{className:"v10-ka-verify-arrow",children:j.kind==="promote"?"◈":"◉"}),o.jsx("span",{className:"v10-ka-verify-title",children:j.label})]}),o.jsx("div",{className:"v10-ka-verify-hint",children:j.hint}),j.disabledReason&&o.jsxs("div",{className:"v10-ka-verify-err",children:["! ",j.disabledReason]}),!u&&o.jsx("button",{className:`v10-ka-verify-btn ${j.kind}`,onClick:N,disabled:s||j.disabled,children:s?j.busyCopy:j.label}),g&&o.jsxs("div",{className:"v10-ka-verify-err",children:["✕ ",g]}),u&&f==="promote"&&A(u)&&u.kind==="success"&&o.jsxs("div",{className:"v10-ka-verify-ok",children:[o.jsxs("div",{className:"v10-ka-verify-ok-row",children:[o.jsx("span",{className:"v10-ka-verify-ok-lbl",children:"Promoted"}),o.jsxs("span",{className:"v10-ka-verify-ok-val",children:["✓ ",u.promotedCount," triple",u.promotedCount===1?"":"s"," now in Shared Memory"]})]}),o.jsx("div",{className:"v10-ka-verify-hint",style:{marginTop:6},children:"Refresh the entity to see the next step appear."})]}),u&&f==="promote"&&A(u)&&u.kind!=="success"&&o.jsxs("div",{className:"v10-ka-verify-err",children:["! ",u.message]}),u&&f==="publish"&&S(u)&&(()=>{var U,_;const E=u.status==="confirmed"&&!!u.txHash,T=E&&!!u.contextGraphError;return o.jsxs("div",{className:E?T?"v10-ka-verify-warn":"v10-ka-verify-ok":"v10-ka-verify-err",children:[o.jsxs("div",{className:"v10-ka-verify-ok-row",children:[o.jsx("span",{className:"v10-ka-verify-ok-lbl",children:"Status"}),o.jsxs("span",{className:"v10-ka-verify-ok-val",children:[E?T?"⚠":"✓":"✕"," ",u.status,E?T?` (${A_})`:"":" (NOT on-chain)"]})]}),T&&o.jsx("div",{className:"v10-ka-verify-hint",style:{marginTop:6},children:Il(u.contextGraphError)}),u.txHash?o.jsxs("div",{className:"v10-ka-verify-ok-row",children:[o.jsx("span",{className:"v10-ka-verify-ok-lbl",children:"TX hash"}),o.jsx("span",{className:"v10-ka-verify-ok-val mono",title:u.txHash,children:u.txHash})]}):o.jsxs("div",{className:"v10-ka-verify-ok-row",children:[o.jsx("span",{className:"v10-ka-verify-ok-lbl",children:"TX hash"}),o.jsx("span",{className:"v10-ka-verify-ok-val",children:"none — on-chain submission skipped"})]}),u.blockNumber!=null&&o.jsxs("div",{className:"v10-ka-verify-ok-row",children:[o.jsx("span",{className:"v10-ka-verify-ok-lbl",children:"Block"}),o.jsxs("span",{className:"v10-ka-verify-ok-val mono",children:["#",u.blockNumber]})]}),((_=(U=u.kas)==null?void 0:U[0])==null?void 0:_.tokenId)&&o.jsxs("div",{className:"v10-ka-verify-ok-row",children:[o.jsx("span",{className:"v10-ka-verify-ok-lbl",children:"Token"}),o.jsxs("span",{className:"v10-ka-verify-ok-val mono",children:["#",u.kas[0].tokenId]})]})]})})()]})}function FP({entity:e,allEntities:t,allTriples:n,onNavigate:a,onClose:s,contextGraphId:l,onRefresh:u,onOpenAgent:d}){const[f,h]=w.useState("content"),g=Vn(I=>I.theme),m=Ua(),y=cs(),{icon:b,type:k}=Bd(e,m),j=G4(e),N=Ud(e),S=N?(y==null?void 0:y.get(N))??null:null,A=e.trustLevel==="verified"?"vm":e.trustLevel==="shared"?"swm":"wm",E=e.trustLevel==="verified"?"Verifiable Memory":e.trustLevel==="shared"?"Shared Working Memory":"Working Memory",T=ia(e.trustLevel,1),U=w.useMemo(()=>{const I=[];for(const[,H]of t)for(const B of H.connections)B.targetUri===e.uri&&I.push({pred:Zs(B.predicate),entity:H});return I},[e.uri,t]),_=w.useMemo(()=>n.filter(I=>bt(I.subject)===e.uri||bt(I.object)===e.uri),[e.uri,n]),z=w.useMemo(()=>V4(e.uri,n,1),[e.uri,n]),q=w.useMemo(()=>{const I=new Set;for(const H of t.values())rj(H)&&I.add(bt(H.uri));return I},[t]),D=w.useMemo(()=>new Set([bt(e.uri)]),[e.uri]),R=w.useMemo(()=>hd(z,q,{focalSubjects:D}),[z,q,D]),$=w.useMemo(()=>{const I=Yi[e.trustLevel];return{labelMode:"humanized",renderer:"2d",labels:Id({minZoomForLabels:.2}),style:{namespaceColors:Vg(I),defaultNodeColor:I,defaultEdgeColor:"#475569",edgeWidth:1,fontSize:11},hexagon:{baseSize:7,minSize:4,maxSize:10,scaleWithDegree:!0},focus:{maxNodes:500,hops:999}}},[e.trustLevel]),F=w.useMemo(()=>({name:`entity-${e.uri}-${g}`,palette:g,focal:{uri:e.uri,sizeMultiplier:2.4}}),[e.uri,g]),K=_.length;return o.jsxs("div",{className:"v10-ka-detail",children:[o.jsxs("div",{className:"v10-ka-header",children:[o.jsx("button",{className:"v10-ka-back",onClick:s,children:"← Back to Context Graph"}),o.jsxs("div",{className:"v10-ka-header-left",children:[o.jsx("div",{className:"v10-ka-label",children:T}),o.jsxs("div",{className:"v10-ka-name",children:[b," ",e.label,o.jsx("span",{className:`v10-trust-badge ${A}`,children:E})]}),o.jsxs("div",{className:"v10-ka-ual",children:[e.uri," · ",k," · ",K," triples"]})]}),(S||N)&&o.jsxs("div",{className:"v10-ka-header-author",children:[o.jsx("div",{className:"v10-ka-header-author-label",children:"Proposed by"}),o.jsx(ts,{agent:S??void 0,fallbackUri:N??void 0,size:"lg",showOperator:!0,onOpenAgent:d})]})]}),o.jsxs("div",{className:"v10-ka-split",children:[o.jsxs("div",{className:"v10-ka-left",children:[o.jsxs("div",{className:"v10-content-tabs",style:{margin:"0 -20px",padding:"0 20px",background:"transparent"},children:[o.jsx("button",{className:`v10-content-tab ${f==="content"?"active":""}`,onClick:()=>h("content"),children:"Content"}),o.jsx("button",{className:`v10-content-tab ${f==="triples"?"active":""}`,onClick:()=>h("triples"),children:"Triples"}),o.jsx("button",{className:`v10-content-tab ${f==="graph"?"active":""}`,onClick:()=>h("graph"),children:"Graph"})]}),f==="content"&&o.jsxs(o.Fragment,{children:[!e.types.map(H=>m==null?void 0:m.forType(H)).find(H=>H==null?void 0:H.detailHint)||!(m!=null&&m.contextGraphId)?null:o.jsx("div",{className:"v10-ka-section",children:o.jsx(IP,{contextGraphId:m.contextGraphId,entityUri:e.uri})}),j&&o.jsx("div",{className:"v10-ka-section",children:o.jsx("div",{className:"v10-ka-desc",children:o.jsx("p",{children:j})})}),e.properties.size>0&&o.jsxs("div",{className:"v10-ka-section",children:[o.jsx("div",{className:"v10-ka-section-title",children:"Properties"}),[...e.properties].map(([I,H])=>o.jsxs("div",{className:"v10-ka-prop",children:[o.jsx("span",{className:"v10-ka-prop-key",children:Zs(I)}),o.jsx("span",{className:"v10-ka-prop-val",children:H.join(", ")})]},I))]}),e.connections.length>0&&o.jsxs("div",{className:"v10-ka-section",children:[o.jsxs("div",{className:"v10-ka-section-title",children:["References (",e.connections.length,")"]}),e.connections.map((I,H)=>{const B=t.get(I.targetUri);return o.jsxs("button",{className:"v10-ka-conn",onClick:()=>a(I.targetUri),children:[o.jsx("span",{className:"v10-ka-conn-pred",children:Zs(I.predicate)}),o.jsx("span",{className:"v10-ka-conn-arrow",children:"→"}),o.jsx("span",{className:"v10-ka-conn-target",children:I.targetLabel}),B&&o.jsx(Nw,{entity:B,profile:m})]},H)})]}),U.length>0&&o.jsxs("div",{className:"v10-ka-section",children:[o.jsxs("div",{className:"v10-ka-section-title",children:["Referenced by (",U.length,")"]}),U.map((I,H)=>o.jsxs("button",{className:"v10-ka-conn",onClick:()=>a(I.entity.uri),children:[o.jsx("span",{className:"v10-ka-conn-target",children:I.entity.label}),o.jsx(Nw,{entity:I.entity,profile:m}),o.jsx("span",{className:"v10-ka-conn-arrow",children:"→"}),o.jsx("span",{className:"v10-ka-conn-pred",children:I.pred})]},H))]}),o.jsxs("div",{className:"v10-ka-meta",children:[o.jsxs("span",{className:"v10-ka-meta-item",children:[b," ",k]}),o.jsxs("span",{className:"v10-ka-meta-item",children:[K," triples"]}),o.jsxs("span",{className:"v10-ka-meta-item",children:[e.connections.length," links"]})]})]}),f==="triples"&&o.jsxs("div",{style:{marginTop:8,overflowX:"auto",border:"1px solid var(--border-default)",borderRadius:6},children:[o.jsxs("table",{className:"v10-ka-triples-table",children:[o.jsx("thead",{children:o.jsxs("tr",{children:[o.jsx("th",{children:"Subject"}),o.jsx("th",{children:"Predicate"}),o.jsx("th",{children:"Object"})]})}),o.jsx("tbody",{children:_.slice(0,50).map((I,H)=>o.jsxs("tr",{children:[o.jsx("td",{title:I.subject,children:Zs(I.subject)}),o.jsx("td",{title:I.predicate,children:Zs(I.predicate)}),o.jsx("td",{title:I.object,children:I.object.startsWith('"')?Pd(I.object).slice(0,60):Zs(I.object)})]},H))})]}),o.jsxs("div",{style:{fontSize:10,color:"var(--text-tertiary)",fontFamily:"var(--font-mono)",padding:"6px 8px"},children:[Math.min(_.length,50)," of ",_.length," triples shown"]})]}),f==="graph"&&o.jsx(Xu,{title:`${e.label} graph`,scopeLabel:`Entity detail graph: 1-hop neighborhood around ${e.label}.`,tone:A,className:"v10-ka-graph-shell",renderGraph:I=>R.length>0?o.jsx(w.Suspense,{fallback:o.jsx("span",{className:"v10-graph-placeholder",children:"Loading graph..."}),children:o.jsx(Jg,{data:R,format:"triples",options:$,viewConfig:F,style:{position:"absolute",inset:0,width:"100%",height:"100%"},onNodeClick:H=>(H==null?void 0:H.id)&&H.id!==e.uri&&a(H.id),initialFit:!0,initialFocus:e.uri},`${e.uri}:${I?"expanded":"inline"}`)}):o.jsx("div",{className:"v10-graph-placeholder v10-graph-placeholder-centered",children:"No neighborhood data"})})]}),o.jsxs("div",{className:"v10-ka-right",children:[o.jsx(gz,{contextGraphId:l,entityUri:e.uri,enabled:e.trustLevel==="verified"}),o.jsx("div",{className:"v10-ka-section-title",children:"Provenance Trail"}),o.jsx(HP,{entity:e}),o.jsx(BP,{entity:e,contextGraphId:l,onVerified:u}),o.jsxs("div",{style:{marginTop:16,padding:"10px 12px",borderRadius:6,background:"var(--bg-surface)",border:"1px solid var(--border-subtle)"},children:[o.jsx("div",{className:"v10-ka-section-title",style:{marginBottom:6},children:"Entity Summary"}),o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:4,fontSize:10},children:[o.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[o.jsx("span",{style:{color:"var(--text-tertiary)"},children:"Type"}),o.jsx("span",{style:{color:"var(--text-primary)",fontWeight:600,fontFamily:"var(--font-mono)"},children:k})]}),o.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[o.jsx("span",{style:{color:"var(--text-tertiary)"},children:"Triples"}),o.jsx("span",{style:{color:"var(--text-primary)",fontWeight:600,fontFamily:"var(--font-mono)"},children:K})]}),o.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[o.jsx("span",{style:{color:"var(--text-tertiary)"},children:"Links"}),o.jsx("span",{style:{color:"var(--text-primary)",fontWeight:600,fontFamily:"var(--font-mono)"},children:e.connections.length})]}),o.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[o.jsx("span",{style:{color:"var(--text-tertiary)"},children:"Layer"}),o.jsx("span",{style:{color:"var(--text-primary)",fontWeight:600,fontFamily:"var(--font-mono)"},children:E.split(" ")[0]})]})]})]})]})]})]})}function HP({entity:e}){const t=cs(),n=u=>{const d=F4(e,u),f=H4(e,u),h=d?t==null?void 0:t.get(d):null;return{uri:d,at:f,agent:h}},a=n("created"),s=n("promoted"),l=n("published");return o.jsxs("div",{className:"v10-ka-timeline",children:[e.trustLevel==="verified"&&o.jsx(Vh,{toneClass:"verified",title:"Published to Verifiable Memory",actionWord:"Published",agent:l.agent,agentUri:l.uri,at:l.at}),(e.trustLevel==="shared"||e.trustLevel==="verified")&&o.jsx(Vh,{toneClass:"shared",title:"Promoted to Shared Working Memory",actionWord:"Promoted",agent:s.agent,agentUri:s.uri,at:s.at}),o.jsx(Vh,{toneClass:"created",title:"Created in Working Memory",actionWord:"Created",agent:a.agent,agentUri:a.uri,at:a.at})]})}function Vh({toneClass:e,title:t,actionWord:n,agent:a,agentUri:s,at:l}){const u=l?Y4(l):null;return o.jsxs("div",{className:"v10-ka-event",children:[o.jsx("div",{className:`v10-ka-event-dot ${e}`}),o.jsxs("div",{className:"v10-ka-event-header",children:[o.jsx("span",{className:"v10-ka-event-title",children:t}),u&&o.jsx("time",{className:"v10-ka-event-time",dateTime:l??void 0,children:u})]}),(a||s)&&o.jsxs("div",{className:"v10-ka-event-attribution",children:[o.jsxs("span",{className:"v10-ka-event-attribution-prefix",children:[n," by"]}),o.jsx(ts,{agent:a??void 0,fallbackUri:s??void 0,size:"sm"})]})]})}function Ew(){return o.jsxs("div",{className:"v10-subgraph-explorer-header",children:[o.jsx("div",{className:"v10-subgraph-explorer-title",children:"Subgraph Explorer"}),o.jsx("p",{className:"v10-subgraph-explorer-intro",children:"Subgraphs are optional topical partitions inside this Context Graph. An entity belongs to one or more memory layers and, optionally, to one or more subgraphs. Entities in no subgraph live in the context graph root."})]})}function qP({contextGraphId:e,memory:t,onNodeClick:n,onSelectSubGraph:a}){const s=Ua(),[l,u]=w.useState([]),[d,f]=w.useState(!0),[h,g]=w.useState(null);w.useEffect(()=>{let _=!1;return f(!0),g(null),Mg(e).then(z=>{_||u(z.subGraphs??[])}).catch(z=>{_||g(z instanceof Error?z.message:"Failed to load subgraphs")}).finally(()=>{_||f(!1)}),()=>{_=!0}},[e]);const{total:m}=Zg(t),y=Object.values(t.layerStatus??{}),b=t.loading||y.some(_=>_==="loading"),k=t.error!==null||t.partial||y.some(_=>_==="error"),j=w.useMemo(()=>{const _=new Map;for(const z of t.entityList){const q=bt(z.uri);for(const D of z.subGraphs){let R=_.get(D);R||(R=new Set,_.set(D,R)),R.add(q)}}return _},[t.entityList]),{triplesBySubGraph:N,tripleCountBySubGraph:S}=w.useMemo(()=>{const _=new Map;for(const D of t.allTriples){if(!D.subGraph)continue;let R=_.get(D.subGraph);R||(R=[],_.set(D.subGraph,R)),R.push(D)}for(const D of t.allTriples)if(!D.subGraph){for(const[R,$]of j)if(Tm(D,{slug:R,isRoot:!1,scopedUris:$})){let F=_.get(R);F||(F=[],_.set(R,F)),F.push(D)}}const z=new Map,q=new Map;for(const[D,R]of _){const F=_m(R,t.entities).map(K=>({subject:K.subject,predicate:K.predicate,object:K.object}));q.set(D,F.length),z.set(D,M1(F))}return{triplesBySubGraph:z,tripleCountBySubGraph:q}},[t.allTriples,t.entities,j]),A=w.useMemo(()=>{const _=new Map;for(const z of t.entityList)for(const q of z.subGraphs){let D=_.get(q);D||(D={wm:0,swm:0,vm:0},_.set(q,D)),z.trustLevel==="verified"?D.vm++:z.trustLevel==="shared"?D.swm++:D.wm++}return _},[t.entityList]),E=w.useMemo(()=>{const _=new Map;for(const z of t.entityList){const q=bt(z.uri);for(const D of z.subGraphs){let R=_.get(D);R||(R=new Map,_.set(D,R)),R.set(q,z.trustLevel),q!==z.uri&&R.set(z.uri,z.trustLevel)}}return _},[t.entityList]),T=w.useMemo(()=>l.filter(Kg).map(_=>{const z=(s==null?void 0:s.forSubGraph(_.name))??{},q=N.get(_.name)??[],D=j.get(_.name)??new Set,R=E.get(_.name)??new Map;return{slug:_.name,icon:z.icon??"•",color:z.color??"#64748b",displayName:z.displayName??_.name,description:z.description,rank:z.rank??99,entityCount:D.size>0?D.size:_.entityCount,tripleCount:S.get(_.name)??0,triples:hd(q,D),layerCounts:A.get(_.name)??{wm:0,swm:0,vm:0},entityTrustByUri:R}}).sort((_,z)=>_.rank-z.rank),[l,s,N,S,A,j,E]),U=w.useMemo(()=>{const _=[],z=new Set,q=new Map;let D=0,R=0,$=0;for(const Q of t.entityList){if(Q.subGraphs.size>0)continue;_.push(Q);const V=bt(Q.uri);z.add(V),q.set(V,Q.trustLevel),V!==Q.uri&&q.set(Q.uri,Q.trustLevel),Q.trustLevel==="verified"?$++:Q.trustLevel==="shared"?R++:D++}const F=t.allTriples.filter(Q=>!Q.subGraph),K=_m(F,t.entities).map(Q=>({subject:Q.subject,predicate:Q.predicate,object:Q.object})),I=K.length,H=hd(K,z),B=M1(H),W=(s==null?void 0:s.forSubGraph($r))??{};return{slug:$r,icon:W.icon??"⊘",color:W.color??"#64748b",displayName:W.displayName??"Root",description:W.description,rank:999,entityCount:_.length,tripleCount:I,triples:B,layerCounts:{wm:D,swm:R,vm:$},entityTrustByUri:q}},[t.entityList,t.allTriples,t.entities,s]);return d&&T.length===0?o.jsx(ln,{compact:!0,icon:"#",title:"Loading subgraphs...",className:"v10-sgov-state"}):h&&T.length===0?o.jsx(ln,{icon:"!",title:"Couldn't load subgraphs.",description:"Refresh the page to try again.",tone:"danger",className:"v10-sgov-state"}):T.length===0&&U.entityCount===0?o.jsx(ln,{icon:"#",title:"No subgraphs in this Context Graph yet.",description:o.jsxs(o.Fragment,{children:["A subgraph is a named topical slice of this Context Graph (e.g. ",o.jsx("code",{children:"recipes"}),", ",o.jsx("code",{children:"decisions"}),"). Agents create one when they scope an assertion to a subgraph. All current entities live in the Context Graph root."]}),actions:[{label:"View root",onClick:()=>a($r),variant:"primary"}],className:"v10-sgov-state"}):o.jsxs("div",{className:"v10-sgov",children:[o.jsxs("div",{className:"v10-sgov-header",children:[o.jsx("div",{className:"v10-sgov-title",children:"Subgraphs"}),o.jsxs("div",{className:"v10-sgov-sub",children:[T.length," named subgraphs · ",t.counts.total," entities · ",m," triples"]})]}),o.jsxs("div",{className:"v10-sgov-grid",children:[T.map(_=>o.jsx(Aw,{card:_,isHydrating:b,isFailedOrPartial:k,onNodeClick:n,onOpen:()=>a(_.slug)},_.slug)),o.jsx(Aw,{card:U,isHydrating:b,isFailedOrPartial:k,onNodeClick:n,onOpen:()=>a($r),variant:"root"},$r)]})]})}function Aw({card:e,isHydrating:t=!1,isFailedOrPartial:n=!1,onNodeClick:a,onOpen:s,variant:l}){const u=w.useMemo(()=>{const h={};for(const[g,m]of e.entityTrustByUri)h[g]=Yi[m];return h},[e.entityTrustByUri]),d=w.useMemo(()=>({labelMode:"humanized",renderer:"2d",labels:Id({minZoomForLabels:.8}),style:{classColors:cj,predicateColors:uj,namespaceColors:Vg(e.color),...Object.keys(u).length>0?{nodeColors:u}:{},defaultNodeColor:e.color,defaultEdgeColor:"#475569",edgeWidth:1,fontSize:12,gradient:!0,gradientIntensity:.35},hexagon:{baseSize:6,minSize:3,maxSize:16,scaleWithDegree:!0},focus:{maxNodes:5e3,hops:999}}),[e.color,u]),f=l==="root";return o.jsxs("div",{className:`v10-sgov-card${f?" root":""}`,style:f?void 0:{"--sg-color":e.color,borderColor:e.color+"55"},children:[o.jsxs("div",{className:"v10-sgov-card-head",children:[o.jsx("span",{className:"v10-sgov-card-icon",style:f?void 0:{color:e.color},children:e.icon}),o.jsxs("div",{className:"v10-sgov-card-title-wrap",children:[o.jsx("div",{className:"v10-sgov-card-title",children:e.displayName}),e.description&&o.jsx("div",{className:"v10-sgov-card-desc",title:e.description,children:e.description})]}),o.jsx("button",{type:"button",className:"v10-sgov-card-open",onClick:s,title:`Focus on ${e.displayName}`,children:"↗"})]}),o.jsxs("div",{className:"v10-sgov-card-stats",children:[o.jsxs("span",{className:"v10-sgov-card-stat",children:[o.jsx("b",{children:e.entityCount})," entities"]}),o.jsxs("span",{className:"v10-sgov-card-stat",title:t&&e.tripleCount===0?"Loading triples for this subgraph…":n?e.tripleCount===0?"Some layers unavailable; count may be incomplete.":`${e.tripleCount} triples (some layers unavailable; count may be incomplete).`:t?`${e.tripleCount} triples (still loading; count may grow).`:e.tripleCount!==e.triples.length?`${e.tripleCount} triples in this subgraph's scope; ${e.triples.length} rendered (some in-scope edges aren't drawn — either endpoints outside this subgraph, or cap-trimmed in dense buckets).`:void 0,children:[o.jsx("b",{children:t&&e.tripleCount===0?"…":e.tripleCount})," triples"]})]}),o.jsx("div",{className:"v10-sgov-card-pyramid",children:o.jsx(wC,{counts:e.layerCounts,compact:!0})}),o.jsx("div",{className:"v10-sgov-card-graph",children:e.triples.length===0?o.jsx("div",{className:"v10-sgov-card-empty",children:e.entityCount>0?"Promoted — open to view":"No data yet"}):o.jsx(w.Suspense,{fallback:o.jsx("div",{className:"v10-sgov-card-empty",children:"Loading…"}),children:o.jsx(Jg,{data:e.triples,format:"triples",options:d,style:{position:"absolute",inset:0,width:"100%",height:"100%"},onNodeClick:a,initialFit:!0})})})]})}function wC({counts:e,activeLayers:t,onClickLayer:n,compact:a=!1}){const s=e.wm+e.swm+e.vm;if(s===0)return a?null:o.jsx("div",{className:"v10-minibar v10-minibar-empty",children:"No data"});const l=[{key:"verified",short:"VM",count:e.vm,color:"#22c55e",label:"Verifiable"},{key:"shared",short:"SWM",count:e.swm,color:"#f59e0b",label:"Shared"},{key:"working",short:"WM",count:e.wm,color:"#64748b",label:"Working"}],u=!!n;return o.jsxs("div",{className:`v10-minibar${a?" compact":""}`,children:[!a&&o.jsx("div",{className:"v10-minibar-bar",children:l.filter(d=>d.count>0).map(d=>{const f=d.count/s*100,h=t?t.has(d.key):!0;return o.jsx("div",{className:`v10-minibar-seg${h?"":" dim"}`,style:{width:`${f}%`,background:d.color},title:`${d.label}: ${d.count}`},d.key)})}),o.jsx("div",{className:"v10-minibar-legend",children:l.map(d=>{const f=t?t.has(d.key):!0;return o.jsxs("button",{type:"button",className:`v10-minibar-chip${f?"":" dim"}${u?" interactive":""}`,onClick:u?()=>n(d.key):void 0,disabled:!u,title:`${d.label} Memory — ${d.count} entities${u?" (click to toggle)":""}`,children:[o.jsx("span",{className:"v10-minibar-dot",style:{background:d.color}}),o.jsx("span",{className:"v10-minibar-short",children:d.short}),o.jsx("span",{className:"v10-minibar-count",children:d.count})]},d.key)})})]})}function GP({items:e,color:t,onSelectEntity:n,scrollKey:a}){const s=Ua(),l=cs(),u=w.useMemo(()=>{const d=new Map;for(const f of e){const h=`${f.date.getFullYear()}-${String(f.date.getMonth()+1).padStart(2,"0")}`,g=d.get(h)??[];g.push(f),d.set(h,g)}return[...d.entries()].sort((f,h)=>f[0].localeCompare(h[0]))},[e]);return e.length===0?o.jsx("div",{className:"v10-subgraph-timeline-empty","data-cg-scroll-key":a,children:o.jsx(ln,{compact:!0,title:"No timeline values yet.",description:"Entities in this sub-graph do not currently expose the configured timeline field."})}):o.jsx("div",{className:"v10-subgraph-timeline","data-cg-scroll-key":a,children:u.map(([d,f])=>o.jsxs("div",{className:"v10-subgraph-timeline-bucket",children:[o.jsxs("div",{className:"v10-subgraph-timeline-bucket-head",children:[o.jsx("span",{className:"v10-subgraph-timeline-bucket-dot",style:{background:t}}),o.jsx("span",{className:"v10-subgraph-timeline-bucket-label",children:Q4(d)}),o.jsx("span",{className:"v10-subgraph-timeline-bucket-count",children:f.length})]}),o.jsx("div",{className:"v10-subgraph-timeline-items",children:f.map(({entity:h,date:g})=>{const{icon:m}=Bd(h,s),y=Ud(h),b=y?l==null?void 0:l.get(y):null;return o.jsxs("button",{className:"v10-subgraph-timeline-item",onClick:()=>n(h.uri),title:`${h.label} · ${g.toISOString().slice(0,10)}`,children:[o.jsx("span",{className:"v10-subgraph-timeline-item-icon",children:m}),o.jsx("span",{className:"v10-subgraph-timeline-item-label",children:h.label}),(b||y)&&o.jsx(ts,{agent:b??void 0,fallbackUri:y??void 0,size:"sm"}),o.jsx("span",{className:"v10-subgraph-timeline-item-date",children:g.toISOString().slice(0,10)})]},h.uri)})})]},d))})}function VP({slug:e,rawMemory:t,contextGraphId:n,onNodeClick:a,onSelectEntity:s,activeTab:l,onTabChange:u,initialLayer:d,initialEnabledLayers:f,onEnabledLayersChange:h}){const g=Ua(),m=g==null?void 0:g.forSubGraph(e),y=(g==null?void 0:g.chipsFor(e))??[],b=(g==null?void 0:g.savedQueryCatalogsFor(e))??[],k=m==null?void 0:m.timelinePredicate,[j,N]=w.useState("items"),S=l??j,A=S==="timeline"&&!k?"items":S,E=u??N,[T,U]=w.useState(m!=null&&m.timelinePredicate?"created-desc":"triples");w.useEffect(()=>{U(m!=null&&m.timelinePredicate?"created-desc":"triples")},[e,m==null?void 0:m.timelinePredicate]);const _=w.useMemo(()=>f&&f.size>0?new Set(f):d==="wm"?new Set(["working"]):d==="swm"?new Set(["shared"]):d==="vm"?new Set(["verified"]):new Set(["working","shared","verified"]),[d,f]),[z,q]=w.useState(_);w.useEffect(()=>{h==null||h(z)},[z,h]);const[D,R]=w.useState(new Map),[$,F]=w.useState(null),[K,I]=w.useState(null),[H,B]=w.useState(!1),[W,Q]=w.useState(null),V=e===$r,L=w.useMemo(()=>{const ee=[];for(const ce of t.entityList)(V?ce.subGraphs.size===0:ce.subGraphs.has(e))&&ee.push(ce);return ee},[t.entityList,e,V]),P=w.useMemo(()=>new Set(L.map(ee=>ee.uri)),[L]),G=w.useMemo(()=>t.graphTriples.filter(ee=>Tm(ee,{slug:e,isRoot:V,scopedUris:P})),[t.graphTriples,P,e,V]),O=w.useMemo(()=>{let ee=0,ce=0,he=0;for(const Le of L)Le.trustLevel==="verified"?he++:Le.trustLevel==="shared"?ce++:ee++;return{wm:ee,swm:ce,vm:he,total:L.length}},[L]),ne=w.useMemo(()=>{if(z.size!==1)return null;const ee=z.values().next().value;return ee==="verified"?"vm":ee==="shared"?"swm":ee==="working"?"wm":null},[z]),ue=w.useMemo(()=>{let ee=L;if(z.size<3&&(ee=ee.filter(ce=>z.has(ce.trustLevel))),D.size>0)for(const ce of y){const he=D.get(ce.slug);!he||he.size===0||(ee=ee.filter(Le=>{const He=Le.properties.get(ce.predicate);return!He||He.length===0?!1:He.some(Ce=>he.has(Ce))}))}return K&&(ee=ee.filter(ce=>K.has(ce.uri))),ee},[L,z,D,y,K]),le=w.useMemo(()=>new Set(ue.map(ee=>ee.uri)),[ue]),be=w.useMemo(()=>ue.length===L.length?G:G.filter(ee=>le.has(ee.subject)||le.has(ee.object)),[G,L,ue,le]),Ee=w.useMemo(()=>{if(!ne)return null;const ee=ne==="vm"?"verified":ne==="swm"?"shared":"working",ce=L.filter(Ce=>{if(!Ce.layers.has(ee))return!1;if(D.size>0)for(const Fe of y){const et=D.get(Fe.slug);if(!et||et.size===0)continue;const Ne=Ce.properties.get(Fe.predicate);if(!Ne||Ne.length===0||!Ne.some(Wt=>et.has(Wt)))return!1}return!(K&&!K.has(Ce.uri))}),he=new Set(ce.map(Ce=>Ce.uri)),Le=new Set,He=[];for(const Ce of t.allTriples){if(Ce.layer!==ee||!Tm(Ce,{slug:e,isRoot:V,scopedUris:P,requireResourceObject:!0})||!(he.has(Ce.subject)||he.has(Ce.object)))continue;const Fe=`${Ce.subject}|${Ce.predicate}|${Ce.object}`;Le.has(Fe)||(Le.add(Fe),He.push({subject:Ce.subject,predicate:Ce.predicate,object:Ce.object,subGraph:Ce.subGraph}))}return He},[ne,t.allTriples,P,e,V,L,y,D,K])??be,Ie=w.useMemo(()=>{if(ne){const ee=ne==="vm"?"verified":ne==="swm"?"shared":"working";return L.filter(ce=>{if(!ce.layers.has(ee))return!1;if(D.size>0)for(const he of y){const Le=D.get(he.slug);if(!Le||Le.size===0)continue;const He=ce.properties.get(he.predicate);if(!He||He.length===0||!He.some(Ce=>Le.has(Ce)))return!1}return!(K&&!K.has(ce.uri))})}return ue},[ne,L,ue,y,D,K]),We=w.useMemo(()=>Ie.map(ee=>({uri:ee.uri,label:ee.label})),[Ie]),Se=w.useMemo(()=>{if(ne)return;const ee={};for(const ce of Ie){ee[ce.uri]=Yi[ce.trustLevel];const he=bt(ce.uri);he!==ce.uri&&(ee[he]=Yi[ce.trustLevel])}return ee},[ne,Ie]),ft=z.size===3?"All layers":ne?zn[ne].title:Array.from(z).map(ee=>zn[ee==="verified"?"vm":ee==="shared"?"swm":"wm"].trustLabel).join(" + "),De=w.useMemo(()=>{if(!k)return[];const ee=[];for(const ce of ue){const he=Qu(ce,k);he!=null&&ee.push({entity:ce,date:new Date(he)})}return ee.sort((ce,he)=>ce.date.getTime()-he.date.getTime()),ee},[ue,k]),qe=w.useMemo(()=>{const ee=[...ue];if((T==="created-desc"||T==="created-asc")&&k){const ce=T==="created-desc"?-1:1;return ee.sort((he,Le)=>{const He=Qu(he,k),Ce=Qu(Le,k);return He==null&&Ce==null?0:He==null?1:Ce==null?-1:(He-Ce)*ce}),ee}return T==="label"?(ee.sort((ce,he)=>(ce.label??"").localeCompare(he.label??"")),ee):(ee.sort((ce,he)=>{const Le=ce.tripleCount??0;return(he.tripleCount??0)-Le}),ee)},[ue,T,k]),ke=T==="created-desc"?"newest first · click to open":T==="created-asc"?"oldest first · click to open":T==="label"?"A → Z · click to open":"sorted by triples · click to open",lt=w.useCallback(ee=>{q(ce=>{const he=new Set(ce);return he.has(ee)?he.size>1&&he.delete(ee):he.add(ee),he})},[]),xe=w.useCallback((ee,ce)=>{R(he=>{const Le=new Map(he),He=new Set(Le.get(ee)??[]);return He.has(ce)?He.delete(ce):He.add(ce),He.size===0?Le.delete(ee):Le.set(ee,He),Le})},[]),Oe=w.useCallback(()=>{F(null),I(null),Q(null)},[]),Ot=w.useCallback(async ee=>{var ce;B(!0),Q(null),F(ee.slug);try{const he=await or(ee.sparql,n),Le=((ce=he==null?void 0:he.result)==null?void 0:ce.bindings)??[],He=ee.resultColumn||"uri",Ce=new Set;for(const Fe of Le){const et=Fe[He];if(!et)continue;const Ne=typeof et=="string"?et:String(et),Wt=Ne.startsWith("<")&&Ne.endsWith(">")?Ne.slice(1,-1):Ne;Ce.add(Wt)}I(Ce)}catch(he){Q((he==null?void 0:he.message)??String(he)),I(null),F(null)}finally{B(!1)}},[n]),$t=(m==null?void 0:m.color)??(V?"var(--text-tertiary)":"#64748b"),Yt=(m==null?void 0:m.icon)??"•",qt=(m==null?void 0:m.displayName)??e,ut=m==null?void 0:m.description;w.useEffect(()=>{q(_),R(new Map),Oe()},[e,Oe,_]),w.useEffect(()=>{l||N("items")},[e,l]),w.useEffect(()=>{S!==A&&E(A)},[S,A,E]);const X=!(z.size===_.size&&[...z].every(ee=>_.has(ee)))||D.size>0||!!K,Z=()=>{q(new Set(_)),R(new Map),Oe()};return o.jsxs("div",{className:"v10-layer-detail v10-subgraph-detail",style:{"--sg-color":$t},children:[o.jsxs("div",{className:"v10-subgraph-detail-header",children:[o.jsx("span",{className:"v10-subgraph-detail-icon",style:{color:$t},children:Yt}),o.jsxs("div",{className:"v10-subgraph-detail-title-wrap",children:[o.jsx("div",{className:"v10-subgraph-detail-title",children:qt}),ut&&o.jsx("div",{className:"v10-subgraph-detail-desc",children:ut})]}),o.jsx(wC,{counts:{wm:O.wm,swm:O.swm,vm:O.vm},activeLayers:z,onClickLayer:lt,compact:!0})]}),o.jsxs("div",{className:"v10-subgraph-cross-layer",children:[o.jsx("div",{className:"v10-subgraph-cross-layer-lede",children:V?"Root entities, across the three memory layers:":"This subgraph, across the three memory layers:"}),o.jsxs("div",{className:"v10-subgraph-cross-layer-strip","data-testid":"cross-layer-strip",children:[o.jsxs("button",{type:"button",className:"v10-subgraph-cross-layer-cell","data-layer":"wm","aria-pressed":z.has("working"),onClick:()=>lt("working"),children:[o.jsx("span",{className:"v10-subgraph-cross-layer-cell-icon",style:{color:Yi.working},children:"◇"}),o.jsx("span",{className:"v10-subgraph-cross-layer-cell-label",children:"Working"}),o.jsx("span",{className:"v10-subgraph-cross-layer-cell-count",children:O.wm})]}),o.jsx("span",{className:"v10-subgraph-cross-layer-arrow","aria-hidden":"true",children:"→"}),o.jsxs("button",{type:"button",className:"v10-subgraph-cross-layer-cell","data-layer":"swm","aria-pressed":z.has("shared"),onClick:()=>lt("shared"),title:ne==="swm"?"Showing Shared Working Memory only — graph is colored by contributing agent (see legend).":void 0,children:[o.jsx("span",{className:"v10-subgraph-cross-layer-cell-icon",style:{color:Yi.shared},children:"◈"}),o.jsx("span",{className:"v10-subgraph-cross-layer-cell-label",children:"Shared"}),o.jsx("span",{className:"v10-subgraph-cross-layer-cell-count",children:O.swm})]}),o.jsx("span",{className:"v10-subgraph-cross-layer-arrow","aria-hidden":"true",children:"→"}),o.jsxs("button",{type:"button",className:"v10-subgraph-cross-layer-cell","data-layer":"vm","aria-pressed":z.has("verified"),onClick:()=>lt("verified"),children:[o.jsx("span",{className:"v10-subgraph-cross-layer-cell-icon",style:{color:Yi.verified},children:"◉"}),o.jsx("span",{className:"v10-subgraph-cross-layer-cell-label",children:"Verifiable"}),o.jsx("span",{className:"v10-subgraph-cross-layer-cell-count",children:O.vm})]})]}),o.jsxs("span",{className:`v10-subgraph-active-layer-pill${z.size===3?" all-layers":""}`,"data-testid":"active-layer-pill",children:[o.jsx("span",{className:"v10-subgraph-active-layer-pill-label",children:"Active layer:"}),o.jsx("span",{className:"v10-subgraph-active-layer-pill-value",children:ft})]})]}),b.length>0&&o.jsxs("div",{className:"v10-subgraph-savedqueries",children:[o.jsx("span",{className:"v10-subgraph-savedqueries-label",children:"Query catalog"}),b.map(ee=>o.jsxs(Ve.Fragment,{children:[o.jsx("span",{className:"v10-subgraph-savedqueries-label",title:ee.description||ee.name,style:{marginLeft:8,opacity:.8},children:ee.name}),ee.queries.map(ce=>{const he=$===ce.slug;return o.jsxs("button",{type:"button",className:`v10-subgraph-savedquery${he?" active":""}`,onClick:()=>he?Oe():Ot(ce),title:ce.description||ce.name,disabled:H&&!he,children:[o.jsx("span",{className:"v10-subgraph-savedquery-glyph",children:H&&he?"…":he?"✓":"◎"}),ce.name]},ce.slug)})]},ee.slug)),W&&o.jsx("span",{className:"v10-subgraph-savedquery-error",title:W,children:"✕ query failed"}),K&&$&&o.jsxs("span",{className:"v10-subgraph-savedquery-count",children:[K.size," match",K.size===1?"":"es"]})]}),y.length>0&&o.jsxs("div",{className:"v10-subgraph-filters",children:[y.map(ee=>{const ce=D.get(ee.slug)??new Set;return o.jsxs("div",{className:"v10-subgraph-filter-row",children:[o.jsx("span",{className:"v10-subgraph-filter-label",children:ee.label}),o.jsx("div",{className:"v10-subgraph-filter-chips",children:ee.values.map(he=>{const Le=ce.has(he);return o.jsx("button",{type:"button",className:`v10-subgraph-filter-chip${Le?" active":""}`,onClick:()=>xe(ee.slug,he),children:he},he)})})]},ee.slug)}),X&&o.jsx("button",{type:"button",className:"v10-subgraph-filter-reset",onClick:Z,children:"Reset filters"})]}),o.jsxs("div",{className:"v10-layer-detail-body",children:[o.jsxs("div",{className:"v10-layer-expand-tabs",children:[o.jsxs("button",{className:`v10-layer-expand-tab ${A==="items"?"active":""}`,onClick:()=>E("items"),children:["Entities (",ue.length,ue.length!==L.length?` / ${L.length}`:"",")"]}),o.jsx("button",{className:`v10-layer-expand-tab ${A==="graph"?"active":""}`,onClick:()=>E("graph"),children:"Graph"}),k&&o.jsx("button",{className:`v10-layer-expand-tab ${A==="timeline"?"active":""}`,onClick:()=>E("timeline"),children:"Timeline"}),o.jsx("button",{className:`v10-layer-expand-tab ${A==="docs"?"active":""}`,onClick:()=>E("docs"),children:"Documents"})]}),A==="items"&&o.jsx("div",{className:"v10-layer-expand-body entities-tab","data-cg-scroll-key":`subgraph:${e}:items`,children:o.jsx(Aj,{entities:qe,layerKey:"wm",layerIcon:Yt,onSelectEntity:s,externallySorted:!0,sortLabel:ke,timestampPredicate:k,perEntityTrustBadge:!0,headerExtra:o.jsxs("label",{className:"v10-entity-list-sort",children:[o.jsx("span",{className:"v10-entity-list-sort-label",children:"Sort"}),o.jsxs("select",{className:"v10-entity-list-sort-select",value:T,onChange:ee=>U(ee.target.value),"aria-label":"Sort entities",children:[k&&o.jsxs(o.Fragment,{children:[o.jsx("option",{value:"created-desc",children:"Newest first"}),o.jsx("option",{value:"created-asc",children:"Oldest first"})]}),o.jsx("option",{value:"triples",children:"Most triples"}),o.jsx("option",{value:"label",children:"Label (A→Z)"})]})]})})}),A==="graph"&&o.jsx("div",{className:"v10-layer-expand-body full-width","data-cg-scroll-key":`subgraph:${e}:graph`,children:o.jsx(Cj,{layer:ne??"wm",triples:Ee,onNodeClick:a,contextGraphId:n,title:qt,scopeLabel:`Subgraph graph: ${qt} entities and entity-to-entity triples from loaded subgraph data.`,trustLegendActiveLayer:ne,scopeEntities:We,layerEntities:Ie,nodeColorsOverride:Se})}),A==="timeline"&&k&&o.jsx("div",{className:"v10-layer-expand-body full-width",children:o.jsx(GP,{items:De,color:$t,onSelectEntity:s,scrollKey:`subgraph:${e}:timeline`})}),A==="docs"&&o.jsx("div",{className:"v10-layer-expand-body full-width",children:o.jsx(Tj,{entities:ue,contextGraphId:n,scrollKey:`subgraph:${e}:docs`})})]})]})}const WP={wm:"items",swm:"items",vm:"items"},Tw={wm:"working",swm:"shared",vm:"verified"};function Wh(e){return e==="wm"||e==="swm"||e==="vm"}function ZP(e){const t=new Set;return e.filter(n=>{const a=`${bt(n.subject)}|${n.predicate}|${bt(n.object)}`;return t.has(a)?!1:(t.add(a),!0)})}function _w(e,t){if(typeof document>"u")return t;const n=document.querySelectorAll("[data-cg-scroll-key]");for(const a of n)if(a.dataset.cgScrollKey===e)return a;return t}function KP({contextGraphId:e}){const{data:t,error:n,loading:a,refresh:s}=lr(Tn.fetchContextGraphs,[],3e4),[l,u]=w.useState(!1),[d,f]=w.useState(!1),[h,g]=w.useState("overview"),[m,y]=w.useState(null),[b,k]=w.useState({contextGraphId:null,list:[],status:"loading"}),[j,N]=w.useState(null),[S,A]=w.useState(!1),E=w.useRef(0),[T,U]=w.useState(null),[_,z]=w.useState(null),q=w.useRef(null),[D,R]=w.useState(null),$=w.useCallback(de=>{q.current=de,R(de)},[]),F=w.useRef(null),K=w.useCallback(de=>{F.current=de,de===null&&(q.current=null,R(null)),U(de)},[]),[I,H]=w.useState(null),B=w.useRef(null);w.useEffect(()=>{B.current=m},[m]);const[W,Q]=w.useState(WP),[V,L]=w.useState({}),P=w.useRef(null),G=w.useRef(null),O=w.useRef(null),ne=w.useRef(0),ue=CM(e),le=RM(e),be=fn(de=>de.openTab),{data:_e,loading:Ee,error:Ie}=zd(),We=w.useCallback(()=>T?`subgraph:${T}:${V[T]??"items"}`:Wh(h)?`layer:${h}:${W[h]}`:"page",[h,T,W,V]),Se=w.useCallback(de=>{const je=de??We(),Ae=_w(je,P.current);return{activeLayer:h,activeSubGraph:T,layerTabs:{...W},subGraphTabs:{...V},scroll:{key:je,top:(Ae==null?void 0:Ae.scrollTop)??0},subGraphEnabledLayers:T!==null&&q.current?new Set(q.current):null}},[h,T,We,W,V]),ft=w.useCallback(de=>{const je=()=>{const Ae=_w(de.key,P.current);Ae&&(Ae.scrollTop=de.top)};typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame(je):setTimeout(je,0)},[]),De=w.useCallback((de,je)=>{(!B.current||!G.current)&&(G.current=Se(je)),y(de)},[Se]),qe=w.useCallback(()=>{G.current=null},[]);w.useEffect(()=>{if(m)return;const de=O.current;de&&(O.current=null,ft(de))},[m,h,T,W,V,ft]),w.useEffect(()=>{const de=je=>{const Ae=je.detail;Ae&&Ae.contextGraphId===e&&typeof Ae.entityUri=="string"&&(H(null),De(Ae.entityUri))};return window.addEventListener("v10:open-entity",de),()=>window.removeEventListener("v10:open-entity",de)},[e,De]);const ke=w.useCallback(de=>{var tt;const je=de.startsWith("urn:dkg:agent:")?de.slice(14):de,Ae=((tt=le.get(de))==null?void 0:tt.name)??je;be({id:`agent:${e}|${je}`,label:`@ ${Ae}`,closable:!0})},[le,e,be]),lt=w.useMemo(()=>({...le,openAgent:ke}),[le,ke]),xe=w.useMemo(()=>{var de;return(de=t==null?void 0:t.contextGraphs)==null?void 0:de.find(je=>je.id===e)},[t,e]),Oe=Gg(e,{signalErrors:!0}),Ot=Zg(Oe).total,$t=M4({activeLayer:h,activeSubGraph:T}),Yt=wj($t?e:void 0),qt=!T&&h==="overview",ut=PM(qt?e:void 0),ye=qt?ut.resultContextGraphId===e?ut.events:[]:void 0,X=qt&&ut.resultContextGraphId===e?ut.error:null,Z=w.useCallback(()=>{const de=xe==null?void 0:xe.id;if(!de)return;const je=ne.current+1;ne.current=je,k({contextGraphId:de,list:[],status:"loading"}),Tn.listParticipants(de).then(Ae=>{ne.current===je&&k({contextGraphId:de,list:Ae.allowedAgents,status:"ok"})}).catch(()=>{ne.current===je&&k({contextGraphId:de,list:[],status:"error"})})},[xe==null?void 0:xe.id]);w.useEffect(()=>{Z()},[Z]);const ee=w.useCallback(()=>{const de=++E.current;Tn.fetchSubGraphs(e).then(je=>{if(E.current!==de)return;const Ae=(je.subGraphs??[]).filter(Kg).length;N(Ae),A(!1)}).catch(()=>{E.current===de&&(N(null),A(!0))})},[e]);w.useEffect(()=>{N(null),A(!1),ee()},[ee]),xo(e,ee);const ce=I?Tw[I]:null,he=w.useMemo(()=>ce?Oe.allTriples.filter(de=>de.layer===ce):Oe.graphTriples,[Oe.allTriples,Oe.graphTriples,ce]),Le=w.useMemo(()=>ce?ZP(he):he,[he,ce]),He=w.useMemo(()=>ce?nj(he):Oe.entities,[he,Oe.entities,ce]),Ce=w.useMemo(()=>m?He.get(m)??null:null,[m,He]);w.useEffect(()=>{!m||Ce||Oe.loading||(y(null),H(null),qe())},[m,Ce,Oe.loading,qe]);const Fe=w.useCallback((de,je)=>{const Ae=F.current;if(qe(),K(de),de===null)z(null);else if(je!==void 0){const tt=new Set([Tw[je]]);z(tt),q.current=tt,R(tt)}else{if(Ae!==null&&de===Ae)return;if(Ae!==null&&q.current){const tt=new Set(q.current);z(tt),q.current=tt,R(tt)}else z(null),q.current=null,R(null)}y(null),H(null)},[qe,K]),et=w.useCallback(de=>{qe(),g(de),y(null),H(null),K(null),z(null)},[qe,K]),Ne=w.useCallback((de,je)=>{Q(Ae=>Ae[de]===je?Ae:{...Ae,[de]:je})},[]),Wt=w.useCallback((de,je)=>{L(Ae=>Ae[de]===je?Ae:{...Ae,[de]:je})},[]),_t=w.useCallback((de,je,Ae)=>{const tt=B.current!=null;De(de,je),H(Je=>Ae??(tt?Je:null))},[De]),Hr=w.useCallback(()=>{const de=G.current;if(G.current=null,y(null),H(null),!!de){if(g(de.activeLayer),K(de.activeSubGraph),de.activeSubGraph!==null&&de.subGraphEnabledLayers){const je=new Set(de.subGraphEnabledLayers);z(je),q.current=je,R(je)}Q(de.layerTabs),L(de.subGraphTabs),O.current=de.scroll}},[K]),dr=w.useCallback(de=>{if(!(de!=null&&de.id))return;const je=Wh(de.trustLayer)?de.trustLayer:void 0;_t(de.id,void 0,je)},[_t]),Fa=w.useCallback(de=>{const je=Wh(h)?h:void 0;_t(de,void 0,je)},[h,_t]),Ha=w.useCallback(de=>{_t(de,"page")},[_t]),pr=w.useCallback(()=>{be(Sj)},[be]),qr=!!n&&/authentication|unauthor|expired|sign in|log in/i.test(n);if(!xe)return n||t&&!a?o.jsxs("div",{className:"v10-view-placeholder",children:[o.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:12,marginBottom:10},children:n?qr?n:"Failed to load context graph.":"Context graph not found."}),qr?o.jsx("button",{type:"button",className:"v10-retry-btn",onClick:()=>window.location.reload(),children:"Refresh page"}):o.jsx("button",{type:"button",className:"v10-retry-btn",onClick:s,children:"Retry"})]}):o.jsx("div",{className:"v10-view-placeholder",children:o.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:12},children:"Loading context graph..."})});const ca=T?ue.forSubGraph(T):null,qa=!Oe.loading&&!Oe.error&&!Oe.partial?Oe.entityList:void 0,Ci=Ce?"entity":T?"subgraph":h,ge=b.contextGraphId===xe.id?b.list:[],Me=b.contextGraphId===xe.id?b.status:"loading";return o.jsx(yj.Provider,{value:ue,children:o.jsx(xj.Provider,{value:lt,children:o.jsxs("div",{className:"v10-memory-explorer",children:[n&&o.jsx("div",{className:"v10-stale-banner",role:"status",children:qr?o.jsxs(o.Fragment,{children:[o.jsx("span",{children:n}),o.jsx("button",{type:"button",className:"v10-retry-btn",onClick:()=>window.location.reload(),children:"Refresh page"})]}):o.jsxs(o.Fragment,{children:[o.jsx("span",{children:"Couldn’t refresh context-graph data — showing last known values."}),o.jsx("button",{type:"button",className:"v10-retry-btn",onClick:s,children:"Retry"})]})}),o.jsx(bD,{cg:xe,profile:ue,activeSubGraph:ca,onClearSubGraph:()=>Fe(null)}),o.jsx(yD,{active:h,counts:Oe.counts,onSwitch:et,onShare:()=>f(!0),onImport:()=>u(!0),onRefresh:Oe.refresh}),o.jsxs("main",{className:"v10-memory-explorer-page","data-view":Ci,"data-cg-scroll-key":"page",ref:P,children:[Ce&&o.jsx(FP,{entity:Ce,allEntities:He,allTriples:Le,onNavigate:_t,onClose:Hr,contextGraphId:e,onRefresh:Oe.refresh}),T&&!Ce&&o.jsxs(o.Fragment,{children:[o.jsx(Ew,{}),o.jsx(zh,{contextGraphId:e,profile:ue,selected:T,entities:qa,onSelect:Fe,enabledScope:D??void 0,allTriplesTotal:Ot}),o.jsx(VP,{slug:T,rawMemory:Oe,contextGraphId:e,onNodeClick:dr,onSelectEntity:_t,activeTab:V[T]??"items",onTabChange:de=>Wt(T,de),initialEnabledLayers:_??void 0,onEnabledLayersChange:$})]}),!T&&h==="overview"&&!Ce&&o.jsxs(o.Fragment,{children:[o.jsx(CD,{cg:xe,memory:Oe,subGraphCount:j,subGraphFetchFailed:S,participants:ge,participantsStatus:Me,currentAgent:_e??null,currentAgentStatus:Ee?"loading":Ie?"error":"ok",onSwitchLayer:et,onOpenPrimer:pr}),o.jsx(ND,{contextGraphId:e,curatorStatus:SD({cg:xe,currentAgent:_e??null,currentAgentStatus:Ee?"loading":Ie?"error":"ok"}),onParticipantsChanged:Z}),Oe.loading&&o.jsx("div",{className:"v10-me-loading",children:o.jsx("div",{className:"v10-me-loading-text",children:"Loading memory..."})}),Oe.error&&o.jsxs("div",{className:"v10-me-error",children:["Error: ",Oe.error]}),o.jsx("div",{"data-section":"activity",children:o.jsx(aD,{entities:Oe.entityList,lifecycleEvents:ye,lifecycleError:X,onSelectEntity:Ha,title:"Recent activity",limit:40,includeUndated:!1,emptyHint:"Once knowledge starts being added and managed in this context graph, activities will show up here as a live feed.",className:"v10-overview-activity"})}),o.jsx(ED,{onOpenPrimer:pr})]}),!T&&h==="graph-overview"&&!Ce&&o.jsxs(o.Fragment,{children:[o.jsx(Ew,{}),o.jsx(zh,{contextGraphId:e,profile:ue,selected:null,entities:qa,onSelect:Fe,allTriplesTotal:Ot}),o.jsx(qP,{contextGraphId:e,memory:Oe,onNodeClick:dr,onSelectSubGraph:Fe})]}),!T&&h==="query"&&!Ce&&o.jsx(az,{contextGraphId:e}),!T&&(h==="wm"||h==="swm"||h==="vm")&&!Ce&&o.jsxs(o.Fragment,{children:[o.jsx(zh,{contextGraphId:e,profile:ue,selected:T,entities:qa,onSelect:Fe,layer:h}),o.jsx(GD,{layer:h,memory:Oe,onNodeClick:dr,onSelectEntity:Fa,contextGraphId:e,activeTab:W[h],onTabChange:de=>Ne(h,de),swmAttribution:Yt})]})]}),o.jsx(dM,{open:l,onClose:()=>u(!1),contextGraphId:xe.id,contextGraphName:xe.name}),o.jsx(fM,{open:d,onClose:()=>f(!1),contextGraphId:xe.id,contextGraphName:xe.name})]})})})}const YP=[{title:"Memory layers",body:"Working Memory is private staging, Shared Working Memory is the collaborative review layer, and Verifiable Memory is the published on-chain layer. Counts show where entities live now."},{title:"Subgraphs",body:"Subgraphs organize the same Context Graph by topic or source. They cut across memory layers, so a subgraph can contain Working, Shared Working, and Verifiable Memory at the same time."},{title:"Entities and Knowledge Assets",body:"Working Memory and Shared Working Memory contain entities. When published, an assertion/triple bundle is anchored as a Knowledge Asset in Verifiable Memory, giving included entities on-chain provenance."},{title:"Assertions",body:"Assertions are batches of triples that explain how entities entered or moved through the Context Graph. They are useful for reviewing provenance and lifecycle state."},{title:"Roles",body:"A curator controls access and publication policy. A participant can collaborate inside the Context Graph according to that policy."}];function QP(){const e=fn(n=>n.closeTab),t=Ve.useCallback(()=>e(Xg),[e]);return Ve.useEffect(()=>{const n=a=>{a.key==="Escape"&&(a.preventDefault(),t())};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[t]),o.jsxs("div",{className:"v10-primer-view",children:[o.jsxs("header",{className:"v10-primer-header",children:[o.jsx("button",{type:"button",className:"v10-primer-back",onClick:t,"aria-label":"Close primer and return to the previous tab",children:"← Back"}),o.jsx("p",{className:"v10-primer-kicker",children:"Context Graph Primer"}),o.jsx("h1",{children:"What is a Context Graph?"}),o.jsx("p",{children:"A Context Graph is a shared knowledge workspace where agents stage, review, organize, and publish structured memory."})]}),o.jsxs("section",{className:"v10-primer-pipeline","aria-label":"Context Graph pipeline",children:[o.jsx("span",{className:"wm",children:"Working Memory"}),o.jsx("span",{className:"connector","aria-hidden":"true"}),o.jsx("span",{className:"swm",children:"Shared Working Memory"}),o.jsx("span",{className:"connector","aria-hidden":"true"}),o.jsx("span",{className:"vm",children:"Verifiable Memory"})]}),o.jsx("div",{className:"v10-primer-sections",children:YP.map(n=>o.jsxs("section",{className:"v10-primer-section",children:[o.jsx("h2",{children:n.title}),o.jsx("p",{children:n.body})]},n.title))})]})}const XP={"application/pdf":"pdf","application/json":"text","text/plain":"text","text/csv":"text","text/markdown":"markdown","image/png":"image","image/jpeg":"image","image/gif":"image","image/webp":"image"};function Rw(e){const t=XP[e];return t?t==="markdown"?"text":t:"binary"}async function Ow(e){const t=await fetch(e,{headers:Ft()});if(!t.ok)throw new Error(`HTTP ${t.status}`);const n=await t.blob();return URL.createObjectURL(n)}function JP({open:e,onClose:t,assertionName:n,contextGraphId:a,subGraphName:s}){const[l,u]=w.useState(null),[d,f]=w.useState(null),[h,g]=w.useState(null),[m,y]=w.useState(!0),[b,k]=w.useState(null);w.useEffect(()=>{if(e)return y(!0),k(null),u(null),f(null),g(null),E_(n,a,s).then(async T=>{u(T);const U=Rw(T.detectedContentType),_=Vu(T.fileHash,T.detectedContentType);if(U==="text"){const z=await fetch(_,{headers:Ft()});z.ok&&f(await z.text())}else if(U==="pdf"||U==="image"){const z=await Ow(_);g(z)}}).catch(T=>k(T.message??"Failed to load file info")).finally(()=>y(!1)),()=>{h&&URL.revokeObjectURL(h)}},[e,n,a,s]),w.useEffect(()=>()=>{h&&URL.revokeObjectURL(h)},[h]);const{dialogRef:j,onBackdropClick:N}=Ji(e,t);if(!e)return null;const S=l?Rw(l.detectedContentType):null,A=l?Vu(l.fileHash,l.detectedContentType):null,E=async(T,U)=>{try{const _=await Ow(T),z=document.createElement("a");z.href=_,z.download=U,z.click(),URL.revokeObjectURL(_)}catch{window.open(T,"_blank")}};return o.jsx("div",{className:"v10-modal-overlay",onClick:N,role:"presentation",children:o.jsxs("div",{className:"v10-modal-box v10-file-preview-modal",ref:j,role:"dialog","aria-modal":"true","aria-labelledby":"dkg-file-preview-title",children:[o.jsxs("div",{className:"v10-modal-header",children:[o.jsx("div",{id:"dkg-file-preview-title",className:"v10-modal-title",children:n}),o.jsx("button",{type:"button",className:"v10-modal-close",onClick:t,"aria-label":"Close file preview",title:"Close (Esc)",children:"×"})]}),m&&o.jsx("div",{className:"v10-file-preview-loading",children:"Loading file preview..."}),b&&o.jsxs("div",{className:"v10-file-preview-error",children:[o.jsx("p",{children:b}),o.jsx("p",{style:{fontSize:11,marginTop:4},children:"File preview requires the extraction status to still be cached on the node. If the node was restarted, the preview metadata may be unavailable."})]}),l&&!m&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"v10-file-preview-meta",children:[o.jsx("span",{className:"v10-file-preview-meta-item",children:l.detectedContentType}),o.jsxs("span",{className:"v10-file-preview-meta-item",children:[l.tripleCount," triples extracted"]}),o.jsx("span",{className:"v10-file-preview-meta-item",children:l.pipelineUsed}),l.completedAt&&o.jsx("span",{className:"v10-file-preview-meta-item",children:new Date(l.completedAt).toLocaleString()})]}),o.jsxs("div",{className:"v10-file-preview-content",children:[S==="pdf"&&h&&o.jsx("iframe",{src:h,className:"v10-file-preview-iframe",title:`Preview: ${n}`}),S==="image"&&h&&o.jsx("img",{src:h,alt:n,className:"v10-file-preview-image"}),S==="text"&&d!=null&&o.jsx("pre",{className:"v10-file-preview-text",children:d}),S==="binary"&&o.jsxs("div",{className:"v10-file-preview-binary",children:[o.jsx("p",{children:"This file type cannot be previewed directly."}),A&&o.jsx("button",{className:"v10-file-preview-download",onClick:()=>E(A,n),children:"Download file"})]})]}),o.jsxs("div",{className:"v10-file-preview-footer",children:[A&&o.jsx("button",{className:"v10-file-preview-download",onClick:()=>E(A,n),children:"Download original"}),l.mdIntermediateHash&&o.jsx("button",{className:"v10-file-preview-download",onClick:()=>E(Vu(l.mdIntermediateHash,"text/markdown"),`${n}.md`),children:"Download markdown intermediate"})]})]})]})})}const e5=w.lazy(()=>gt(()=>import("./index-CqY4Svqw.js").then(e=>e.h),__vite__mapDeps([0,1])).then(e=>({default:e.RdfGraph}))),t5=w.lazy(()=>gt(()=>import("./index-CqY4Svqw.js").then(e=>e.h),__vite__mapDeps([0,1])).then(e=>({default:e.NodePanel}))),n5=w.lazy(()=>gt(()=>import("./OnChainProvenanceCard-B27Dv2LS.js"),__vite__mapDeps([2,0,1])).then(e=>({default:e.OnChainProvenanceCard}))),r5={wm:{label:"Working Memory",color:"var(--layer-working)",icon:"◇",description:"Private agent drafts. Fast local storage."},swm:{label:"Shared Working Memory",color:"var(--layer-shared)",icon:"◈",description:"Shared proposals with collaborators. TTL-bounded."},vm:{label:"Verifiable Memory",color:"var(--layer-verified)",icon:"◉",description:"Endorsed, published, on-chain knowledge."}},a5={labelMode:"humanized",renderer:"2d",labels:Id({extraPredicates:["http://schema.org/text"]}),style:{classColors:{"http://schema.org/Person":"#f472b6","http://schema.org/Organization":"#fb923c","http://schema.org/Place":"#34d399","http://schema.org/Product":"#c084fc","http://schema.org/Event":"#facc15","http://schema.org/CreativeWork":"#7dd3fc","http://schema.org/Thing":"#94a3b8"},defaultNodeColor:"#94a3b8",defaultEdgeColor:"#5f8598",edgeWidth:.9},hexagon:{baseSize:4,minSize:3,maxSize:6,scaleWithDegree:!0},focus:{maxNodes:3e3,hops:999}},i5=o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),o.jsx("line",{x1:"3",y1:"9",x2:"21",y2:"9"}),o.jsx("line",{x1:"3",y1:"15",x2:"21",y2:"15"}),o.jsx("line",{x1:"9",y1:"3",x2:"9",y2:"21"})]}),s5=o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("circle",{cx:"6",cy:"6",r:"3"}),o.jsx("circle",{cx:"18",cy:"6",r:"3"}),o.jsx("circle",{cx:"6",cy:"18",r:"3"}),o.jsx("circle",{cx:"18",cy:"18",r:"3"}),o.jsx("line",{x1:"8.5",y1:"7.5",x2:"15.5",y2:"16.5"}),o.jsx("line",{x1:"15.5",y1:"7.5",x2:"8.5",y2:"16.5"})]});function Zh({layer:e,contextGraphId:t,externalQuery:n,externalQueryKey:a,queryPresetOptions:s}){var Ie,We;const l=r5[e],[u,d]=w.useState("graph"),[f,h]=w.useState(""),[g,m]=w.useState(""),[y,b]=w.useState(""),[k,j]=w.useState(""),[N,S]=w.useState("any"),[A,E]=w.useState(50),[T,U]=w.useState(""),[_,z]=w.useState("any"),[q,D]=w.useState(50),[R,$]=w.useState(e!=="vm"),F=Ve.useRef(e);Ve.useEffect(()=>{F.current!==e&&(F.current=e,h(""),$(e!=="vm"),m(""),b(""),j(""),S("any"),E(50),U(""),z("any"),D(50))},[e]),Ve.useEffect(()=>{n!==void 0&&(h(""),m(n),b(n))},[n,a]);const K=w.useMemo(()=>e==="wm"?`SELECT ?s ?p ?o WHERE { GRAPH <${`did:dkg:context-graph:${t}/_meta`}> { ?g <http://dkg.io/ontology/memoryLayer> "WM" } GRAPH ?g { ?s ?p ?o } FILTER(!CONTAINS(STR(?g), "/meta/assertion/")) } LIMIT 1000`:e==="vm"?c5({query:T,field:_,limit:q}):"SELECT ?s ?p ?o WHERE { ?s ?p ?o } LIMIT 500",[t,e,_,q,T]),I=y||K,H=e==="swm"?"_shared_memory":void 0,B=e==="swm",W=e==="vm"?"verifiable-memory":void 0,Q=e==="wm"&&I===K,{data:V,loading:L,error:P,refresh:G}=lr(()=>or(I,t,B,H,W,Q),[I,t,B,H,W,Q],0);xo(t,G,{layers:[e]});const{data:O}=lr(jg,[],3e4),ne=O==null?void 0:O.blockExplorerUrl,ue=w.useCallback(()=>{const Se=g.trim();if(Se===y){G();return}b(Se)},[y,g,G]),le=w.useCallback(()=>{const Se=k!==T||N!==_||A!==q;if(Se&&(U(k),z(N),D(A)),y){b("");return}Se||G()},[y,_,q,T,N,A,k,G]),be=((Ie=V==null?void 0:V.result)==null?void 0:Ie.bindings)??((We=V==null?void 0:V.results)==null?void 0:We.bindings)??[],_e=w.useMemo(()=>be.map(Se=>({subject:Ys(Se.s)??"",predicate:Ys(Se.p)??"",object:Ys(Se.o)??""})).filter(Se=>Se.subject&&Se.predicate&&Se.object),[be]),Ee=w.useCallback(Se=>{Se!=null&&Se.id&&b(`SELECT (<${Se.id}> AS ?s) ?p ?o WHERE { <${Se.id}> ?p ?o } LIMIT 100`)},[]);return o.jsxs("div",{className:"v10-memory-layer-view",children:[o.jsxs("div",{className:"v10-mlv-header",children:[o.jsx("span",{className:"v10-mlv-icon",style:{color:l.color},children:l.icon}),o.jsxs("div",{children:[o.jsx("h2",{className:"v10-mlv-title",children:l.label}),o.jsx("p",{className:"v10-mlv-desc",children:l.description})]})]}),e==="wm"&&o.jsx(o5,{contextGraphId:t,onPromoted:G}),e==="swm"&&o.jsx(l5,{contextGraphId:t,onPublished:G}),e==="vm"&&o.jsxs("div",{className:"v10-vm-search-panel",children:[o.jsxs("div",{className:"v10-vm-search-header",children:[o.jsxs("div",{children:[o.jsx("div",{className:"v10-vm-search-title",children:"Search Verifiable Memory"}),o.jsx("div",{className:"v10-vm-search-desc",children:"Search published triples by subject, predicate, object, or across all fields."})]}),o.jsx("button",{className:"v10-vm-search-toggle",type:"button",onClick:()=>$(Se=>!Se),children:R?"Hide SPARQL":"Advanced SPARQL"})]}),o.jsxs("div",{className:"v10-vm-search-controls",children:[o.jsx("input",{type:"text",className:"v10-mlv-query-input",placeholder:"Search verifiable memory...",value:k,onChange:Se=>j(Se.target.value),onKeyDown:Se=>{Se.key==="Enter"&&le()}}),o.jsxs("select",{className:"v10-vm-search-select",value:N,onChange:Se=>S(Se.target.value),children:[o.jsx("option",{value:"any",children:"Any field"}),o.jsx("option",{value:"subject",children:"Subject"}),o.jsx("option",{value:"predicate",children:"Predicate"}),o.jsx("option",{value:"object",children:"Object"})]}),o.jsxs("select",{className:"v10-vm-search-select",value:String(A),onChange:Se=>E(Number.parseInt(Se.target.value,10)||50),children:[o.jsx("option",{value:"25",children:"25 rows"}),o.jsx("option",{value:"50",children:"50 rows"}),o.jsx("option",{value:"100",children:"100 rows"}),o.jsx("option",{value:"200",children:"200 rows"})]}),o.jsx("button",{className:"v10-mlv-run-btn",onClick:le,children:"Search"})]})]}),(e!=="vm"||R)&&o.jsxs("div",{className:"v10-mlv-query-bar",children:[s!=null&&s.length?o.jsxs("select",{className:"v10-vm-search-select",value:f,onChange:Se=>{const ft=Se.target.value;h(ft);const De=s.find(ke=>ke.label===ft),qe=(De==null?void 0:De.query)??"";m(qe),b(qe)},children:[o.jsx("option",{value:"",children:"Select common query..."}),s.map(Se=>o.jsx("option",{value:Se.label,children:Se.label},Se.label))]}):o.jsx("input",{type:"text",className:"v10-mlv-query-input",placeholder:"Custom SPARQL query...",value:g,onChange:Se=>m(Se.target.value),onKeyDown:Se=>{Se.key==="Enter"&&ue()}}),o.jsx("button",{className:"v10-mlv-run-btn",onClick:ue,children:"Run"}),y&&o.jsx("button",{className:"v10-mlv-clear-btn",onClick:()=>b(""),title:"Reset to full layer overview",children:"Reset"}),o.jsxs("div",{className:"v10-mlv-view-toggle",children:[o.jsx("button",{className:`v10-mlv-toggle-btn ${u==="table"?"active":""}`,onClick:()=>d("table"),title:"Table view",children:i5}),o.jsx("button",{className:`v10-mlv-toggle-btn ${u==="graph"?"active":""}`,onClick:()=>d("graph"),title:"Graph view",children:s5})]})]}),L&&o.jsx("p",{className:"v10-mlv-status",children:"Loading..."}),P&&o.jsxs("p",{className:"v10-mlv-status",style:{color:"var(--accent-red)"},children:["Error: ",P]}),!L&&be.length===0&&o.jsxs("div",{className:"v10-mlv-empty",children:[o.jsxs("p",{children:["No triples found in ",l.label.toLowerCase(),"."]}),o.jsxs("p",{style:{fontSize:11,marginTop:4},children:[e==="wm"&&"Import files or chat with your agent to generate working memory.",e==="swm"&&"Promote assertions from working memory to share with collaborators.",e==="vm"&&"Publish shared memory to create verified on-chain knowledge."]})]}),!L&&be.length>0&&u==="table"&&o.jsxs("div",{className:"v10-mlv-table-wrap",children:[o.jsxs("div",{className:"v10-mlv-result-count",children:[be.length," triples"]}),o.jsxs("table",{className:"v10-mlv-table",children:[o.jsx("thead",{children:o.jsxs("tr",{children:[o.jsx("th",{children:"Subject"}),o.jsx("th",{children:"Predicate"}),o.jsx("th",{children:"Object"})]})}),o.jsx("tbody",{children:be.map((Se,ft)=>o.jsxs("tr",{children:[o.jsx("td",{className:"v10-mlv-cell",children:Kh(Ys(Se.s))}),o.jsx("td",{className:"v10-mlv-cell",children:Kh(Ys(Se.p))}),o.jsx("td",{className:"v10-mlv-cell",children:Kh(Ys(Se.o))})]},ft))})]})]}),!L&&_e.length>0&&u==="graph"&&o.jsxs("div",{className:"v10-mlv-graph-container",children:[o.jsxs("div",{className:"v10-mlv-graph-info",children:[o.jsxs("span",{children:[_e.length," triples"]}),y&&o.jsx("span",{className:"v10-mlv-graph-info-custom",children:"filtered"})]}),o.jsx(w.Suspense,{fallback:o.jsx("div",{className:"v10-mlv-graph-loading",children:"Loading graph renderer..."}),children:o.jsxs(e5,{data:_e,format:"triples",options:a5,style:{width:"100%",height:"100%"},onNodeClick:Ee,initialFit:!0,children:[o.jsx(t5,{className:"v10-mlv-node-panel",showUri:!0,showTypes:!0,showProperties:!0,showMetadata:!1,maxValueLength:150}),o.jsx(n5,{contextGraphId:t,layer:e,explorerUrl:ne})]})})]})]})}function o5({contextGraphId:e,onPromoted:t}){const{data:n,loading:a,refresh:s}=lr(()=>Ql(e,"wm"),[e],0);xo(e,s,{layers:["wm"]});const[l,u]=w.useState(null),[d,f]=w.useState(null),[h,g]=w.useState(null),[m,y]=w.useState(null),b=w.useCallback(async j=>{u(j.graphUri),f(null),g(null);try{const N=await lo(e,j.name,j.subGraph?{subGraphName:j.subGraph}:{}),S=_g(j.name,N);f({message:S.message+(j.subGraph?` (in ${j.subGraph})`:""),kind:S.kind==="success"?"success":"noop",subGraph:j.subGraph}),s(),t()}catch(N){const S=co(j.name,N);g(S?{message:S.message,kind:"not-persisted"}:{message:(N==null?void 0:N.message)??"Promote failed",kind:"other"})}finally{u(null)}},[e,s,t]),k=w.useCallback(async()=>{if(!(n!=null&&n.length))return;u("__all__"),f(null),g(null);let j=0,N=null;try{for(const E of n)N=E.name,(await lo(e,E.name,E.subGraph?{subGraphName:E.subGraph}:{})).promotedCount===0&&(j+=1);const S=n.length-j,A=j>0?` (${j} already shared or still committing)`:"";f({message:S>0?`Shared ${S} complete Knowledge Asset${S===1?"":"s"} to Shared Working Memory${A}.`:"No Knowledge Assets were newly shared — all were already in Shared Working Memory or still committing.",kind:S>0?"success":"noop"}),s(),t()}catch(S){const A=co(N??"selected assertion",S);g(A?{message:A.message,kind:"not-persisted"}:{message:(S==null?void 0:S.message)??"Promote failed",kind:"other"})}finally{u(null)}},[n,e,s,t]);return a?o.jsx("div",{className:"v10-assertion-list-loading",children:"Loading assertions..."}):n!=null&&n.length?o.jsxs("div",{className:"v10-assertion-list",children:[o.jsxs("div",{className:"v10-assertion-list-header",children:[o.jsxs("span",{className:"v10-assertion-list-title",children:["Assertions in Working Memory (",n.length,")"]}),o.jsx("button",{className:"v10-btn-promote-all",disabled:l!==null,onClick:k,children:l==="__all__"?"Sharing...":"Share Complete KAs → SWM"})]}),o.jsx("div",{className:"v10-assertion-items",children:n.map(j=>o.jsxs("div",{className:"v10-assertion-item",children:[o.jsxs("div",{className:"v10-assertion-item-info",children:[o.jsx("button",{className:"v10-assertion-item-name clickable",title:j.graphUri,onClick:()=>y({name:j.name,subGraph:j.subGraph}),children:j.name}),j.tripleCount!=null&&o.jsxs("span",{className:"v10-assertion-item-count",children:[j.tripleCount," triples"]}),j.subGraph&&o.jsxs("span",{className:"v10-item-count v10-item-subgraph",title:`In sub-graph: ${j.subGraph}`,children:["› ",nv(j.subGraph,18)]})]}),o.jsx("button",{className:"v10-btn-promote",disabled:l!==null,onClick:()=>b(j),title:"Share this complete Knowledge Asset to Shared Working Memory",children:l===j.graphUri?"Promoting...":"→ SWM"})]},j.graphUri))}),d&&o.jsx("div",{className:d.kind==="success"?"v10-promote-result success":"v10-promote-result info",children:d.message}),h&&o.jsx("div",{className:"v10-promote-result error",children:h.message}),m&&o.jsx(JP,{open:!0,onClose:()=>y(null),assertionName:m.name,subGraphName:m.subGraph,contextGraphId:e})]}):null}function l5({contextGraphId:e,onPublished:t}){const{data:n,loading:a,refresh:s}=lr(()=>Ql(e,"swm"),[e],0);xo(e,s,{layers:["swm"]});const[l,u]=w.useState(new Set),[d,f]=w.useState(!1),[h,g]=w.useState(null),[m,y]=w.useState(null),b=(n==null?void 0:n.map(z=>z.graphUri))??[],k=b.length>0&&b.every(z=>l.has(z)),j=w.useCallback(z=>{u(q=>{const D=new Set(q);return D.has(z)?D.delete(z):D.add(z),D})},[]),N=w.useCallback(()=>{u(k?new Set:new Set(b))},[k,b]),S=w.useCallback(async z=>{if(z.length!==0){f(!0),g(null),y(null);try{g(await Tg(e,z)),u(new Set),s(),t()}catch(q){y((q==null?void 0:q.message)??"Publish failed")}finally{f(!1)}}},[e,s,t]),A=w.useCallback(()=>{const z=(n??[]).filter(q=>l.has(q.graphUri));return S(z)},[n,l,S]),E=w.useCallback(()=>S(n??[]),[n,S]),T=(n==null?void 0:n.reduce((z,q)=>z+(q.tripleCount??0),0))??0,U=(n==null?void 0:n.filter(z=>l.has(z.graphUri)).reduce((z,q)=>z+(q.tripleCount??0),0))??0,_=!a&&(!n||n.length===0);return a?o.jsx("div",{className:"v10-assertion-list-loading",children:"Loading SWM contents..."}):_?o.jsxs("div",{className:"v10-publish-panel",children:[o.jsx("div",{className:"v10-publish-panel-header",children:o.jsx("span",{className:"v10-publish-panel-title",children:"Publish to Verifiable Memory"})}),o.jsx("div",{className:"v10-publish-panel-empty",children:"No data in Shared Working Memory yet. Promote assertions from Working Memory first."})]}):o.jsxs("div",{className:"v10-publish-panel",children:[o.jsxs("div",{className:"v10-publish-panel-header",children:[o.jsxs("span",{className:"v10-publish-panel-title",children:["Knowledge assets in Shared Working Memory (",n.length," asset",n.length===1?"":"s"," · ",T," triples)"]}),o.jsxs("div",{className:"v10-publish-panel-header-actions",children:[o.jsx("button",{className:"v10-publish-panel-refresh",onClick:s,title:"Refresh",children:"↻"}),o.jsx("button",{className:"v10-btn-promote-all",disabled:d,onClick:E,children:d&&l.size===0?"Publishing...":"Publish All → VM"})]})]}),o.jsxs("div",{className:"v10-publish-select-bar",children:[o.jsxs("label",{className:"v10-publish-select-all",children:[o.jsx("input",{type:"checkbox",checked:k,onChange:N}),o.jsx("span",{children:"Select all"})]}),l.size>0&&o.jsx("button",{className:"v10-btn-publish",disabled:d,onClick:A,children:d?"Publishing...":`Publish ${l.size} selected (${U} triples) → VM`})]}),o.jsx("div",{className:"v10-assertion-items",children:n.map(z=>o.jsxs("div",{className:`v10-assertion-item ${l.has(z.graphUri)?"selected":""}`,children:[o.jsx("label",{className:"v10-publish-entity-check",children:o.jsx("input",{type:"checkbox",checked:l.has(z.graphUri),onChange:()=>j(z.graphUri)})}),o.jsxs("div",{className:"v10-assertion-item-info",children:[o.jsx("span",{className:"v10-assertion-item-name",title:z.graphUri,children:z.name}),z.subGraph&&o.jsxs("span",{className:"v10-item-count v10-item-subgraph",title:`In sub-graph: ${z.subGraph}`,children:["› ",nv(z.subGraph,18)]}),z.tripleCount!=null&&o.jsxs("span",{className:"v10-assertion-item-count",children:[z.tripleCount," triples"]})]})]},z.graphUri))}),h&&(()=>{const{published:z,total:q,partial:D,partialError:R,failures:$,sample:F,convictionCostCovered:K}=h,I=z===q&&z>0&&D===0,H=(F==null?void 0:F.status)==="confirmed"&&!!F.txHash;return o.jsxs("div",{className:`v10-publish-result-card ${I?"success":"error"}`,children:[o.jsx("div",{className:"v10-publish-result-title",children:z>0?`Published ${z} of ${q} knowledge asset${q===1?"":"s"} to Verifiable Memory`:"NOT published to Verifiable Memory"}),D>0&&o.jsxs("div",{className:"v10-publish-result-details",style:{marginBottom:6},children:["⚠ ",D," asset",D===1?"":"s",": ",Il(R)]}),$.length>0&&o.jsxs("div",{className:"v10-publish-result-details",style:{marginBottom:6},children:[$.length," asset",$.length===1?"":"s"," could not be published — ",$[0].name,": ",$[0].error,$.length>1?` (+${$.length-1} more)`:""]}),o.jsxs("div",{className:"v10-publish-result-details",children:[(F==null?void 0:F.kaId)!=null&&o.jsxs("div",{children:[o.jsx("span",{className:"v10-publish-result-label",children:"Knowledge Asset:"})," ",F.kaId]}),H?o.jsxs("div",{className:"v10-publish-result-tx",children:[o.jsx("span",{className:"v10-publish-result-label",children:"Tx hash:"})," ",o.jsx("span",{className:"mono",title:F.txHash,children:F.txHash}),F.blockNumber!=null&&o.jsxs("span",{className:"v10-publish-result-block",children:[" (block ",F.blockNumber,")"]})]}):o.jsxs("div",{className:"v10-publish-result-details",children:["Verifiable Memory requires a confirmed ",o.jsx("code",{children:"KCCreated"})," event. If a publish did not land on-chain, check the node logs (typically a missing publisher wallet, an unfunded signer, or a chain adapter that isn't V10-ready)."]}),o.jsx(WS,{convictionCostCovered:K})]})]})})(),m&&o.jsx("div",{className:"v10-publish-result-card error",children:m})]})}function Ys(e){if(e!=null)return typeof e=="string"?e:typeof e=="object"&&"value"in e?String(e.value):String(e)}function Kh(e){if(!e)return"—";const t=e.lastIndexOf("#"),n=e.lastIndexOf("/"),a=Math.max(t,n);return a>=0?e.slice(a+1):e}function c5(e){const t=Number.isFinite(e.limit)&&e.limit>0?Math.floor(e.limit):50,n=e.query.trim();if(!n)return`SELECT ?s ?p ?o WHERE { ?s ?p ?o } LIMIT ${t}`;const a=u5(n.toLowerCase()),s={subject:`CONTAINS(LCASE(STR(?s)), "${a}")`,predicate:`CONTAINS(LCASE(STR(?p)), "${a}")`,object:`CONTAINS(LCASE(STR(?o)), "${a}")`};return`SELECT ?s ?p ?o WHERE { ?s ?p ?o . FILTER(${e.field==="any"?`(${s.subject} || ${s.predicate} || ${s.object})`:s[e.field]}) } LIMIT ${t}`}function u5(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r")}const kC=[{key:"working",title:"Working Memory",short:"WM",icon:"◇",color:"#64748b",desc:"Private agent drafts",tabPrefix:"wm"},{key:"shared",title:"Shared Working Memory",short:"SWM",icon:"◈",color:"#f59e0b",desc:"Team proposals",tabPrefix:"swm"},{key:"verified",title:"Verifiable Memory",short:"VM",icon:"◉",color:"#22c55e",desc:"On-chain knowledge",tabPrefix:"vm"}],d5=["http://purl.org/dc/terms/created","http://dkg.io/ontology/github/mergedAt","http://dkg.io/ontology/github/closedAt","http://dkg.io/ontology/decisions/date","http://dkg.io/ontology/tasks/dueDate"];function p5(){const{contextGraphs:e}=Tr(),{hidden:t}=Fg(),n=w.useMemo(()=>e.filter(a=>!t.has(a.id)),[e,t]);return o.jsxs("div",{className:"v10-memstack",children:[o.jsxs("div",{className:"v10-memstack-head",children:[o.jsx("h1",{className:"v10-memstack-title",children:"Memory Stack"}),o.jsxs("p",{className:"v10-memstack-sub",children:["Every layer across every context graph, at a glance. ",n.length," visible context graph",n.length===1?"":"s"," · hidden context graphs are skipped."]})]}),n.length===0?o.jsx("div",{className:"v10-memstack-empty",children:"No visible context graphs. Create one from the sidebar or un-hide dismissed ones."}):o.jsxs("div",{className:"v10-memstack-table",children:[o.jsxs("div",{className:"v10-memstack-colheads",children:[o.jsx("div",{className:"v10-memstack-colhead project"}),kC.map(a=>o.jsxs("div",{className:"v10-memstack-colhead",style:{color:a.color},children:[o.jsx("span",{className:"v10-memstack-colhead-icon",children:a.icon}),o.jsx("span",{className:"v10-memstack-colhead-title",children:a.title}),o.jsx("span",{className:"v10-memstack-colhead-desc",children:a.desc})]},a.key))]}),n.map(a=>o.jsx(f5,{cg:a},a.id))]})]})}function f5({cg:e}){const t=Gg(e.id),{openTab:n}=fn(),a=gj(t),s=w.useMemo(()=>{const u={working:{entities:[],tripleCount:a.wm},shared:{entities:[],tripleCount:a.swm},verified:{entities:[],tripleCount:a.vm}};for(const d of t.entityList)u[d.trustLevel].entities.push(d);for(const d of Object.keys(u))u[d].entities.sort((f,h)=>{const g=Gm(f),m=Gm(h);return g&&m?m-g:g?-1:m?1:f.label.localeCompare(h.label)});return u},[t.entityList,a]),l=()=>n({id:`project:${e.id}`,label:e.name||e.id.slice(0,16),closable:!0});return o.jsxs("div",{className:"v10-memstack-row",children:[o.jsxs("div",{className:"v10-memstack-project",children:[o.jsxs("button",{type:"button",className:"v10-memstack-project-btn",onClick:l,children:[o.jsx("span",{className:"v10-memstack-project-dot"}),o.jsx("span",{className:"v10-memstack-project-name",children:e.name||e.id})]}),e.description&&o.jsx("div",{className:"v10-memstack-project-desc",title:e.description,children:e.description}),t.loading&&!t.entityList.length&&o.jsx("div",{className:"v10-memstack-project-status",children:"loading…"}),t.error&&o.jsx("div",{className:"v10-memstack-project-status error",children:t.error})]}),kC.map(u=>{const d=s[u.key];return o.jsx(h5,{cgId:e.id,color:u.color,layerTitle:u.title,tabPrefix:u.tabPrefix,entityCount:d.entities.length,tripleCount:d.tripleCount,recent:d.entities.slice(0,4),onOpenLayer:()=>n({id:`${u.tabPrefix}:${e.id}`,label:`${u.short} · ${e.name||e.id.slice(0,12)}`,closable:!0})},u.key)})]})}function h5({cgId:e,color:t,layerTitle:n,tabPrefix:a,entityCount:s,tripleCount:l,recent:u,onOpenLayer:d}){const f=s===0;return o.jsxs("div",{className:`v10-memstack-cell${f?" empty":""}`,style:{"--cell-color":t},children:[o.jsxs("div",{className:"v10-memstack-cell-stats",children:[o.jsx("span",{className:"v10-memstack-cell-n",children:s}),o.jsxs("span",{className:"v10-memstack-cell-n-lbl",children:["entit",s===1?"y":"ies"]}),o.jsx("span",{className:"v10-memstack-cell-sep",children:"·"}),o.jsx("span",{className:"v10-memstack-cell-t",children:l.toLocaleString()}),o.jsx("span",{className:"v10-memstack-cell-t-lbl",children:"triples"})]}),u.length>0?o.jsx("ul",{className:"v10-memstack-cell-recent",children:u.map(h=>o.jsxs("li",{className:"v10-memstack-cell-recent-item",title:h.label,children:[o.jsx("span",{className:"v10-memstack-cell-recent-bullet"}),o.jsx("span",{className:"v10-memstack-cell-recent-label",children:h.label}),o.jsx("span",{className:"v10-memstack-cell-recent-time",children:kj(m5(h))})]},h.uri))}):o.jsxs("div",{className:"v10-memstack-cell-empty-hint",children:["Nothing in ",a.toUpperCase()," yet"]}),!f&&o.jsxs("button",{type:"button",className:"v10-memstack-cell-open",onClick:d,title:`Open ${n}`,children:["Open ",a.toUpperCase()," →"]})]})}function Gm(e){var t;for(const n of d5){const a=(t=e.properties.get(n))==null?void 0:t[0];if(!a)continue;const s=new Date(a.replace(/^"|"$/g,"").replace(/^"(.+)"(?:@\w+|\^\^.+)?$/,"$1"));if(Number.isFinite(s.getTime()))return s.getTime()}return null}function m5(e){const t=Gm(e);return t?new Date(t):null}function g5(e,t){const n=t||{};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const v5=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,y5=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,b5={};function Lw(e,t){return(b5.jsx?y5:v5).test(e)}const x5=/[ \t\n\f\r]/g;function w5(e){return typeof e=="object"?e.type==="text"?Mw(e.value):!1:Mw(e)}function Mw(e){return e.replace(x5,"")===""}class nc{constructor(t,n,a){this.normal=n,this.property=t,a&&(this.space=a)}}nc.prototype.normal={};nc.prototype.property={};nc.prototype.space=void 0;function SC(e,t){const n={},a={};for(const s of e)Object.assign(n,s.property),Object.assign(a,s.normal);return new nc(n,a,t)}function Vm(e){return e.toLowerCase()}class Zn{constructor(t,n){this.attribute=n,this.property=t}}Zn.prototype.attribute="";Zn.prototype.booleanish=!1;Zn.prototype.boolean=!1;Zn.prototype.commaOrSpaceSeparated=!1;Zn.prototype.commaSeparated=!1;Zn.prototype.defined=!1;Zn.prototype.mustUseProperty=!1;Zn.prototype.number=!1;Zn.prototype.overloadedBoolean=!1;Zn.prototype.property="";Zn.prototype.spaceSeparated=!1;Zn.prototype.space=void 0;let k5=0;const Xe=ds(),on=ds(),Wm=ds(),we=ds(),Rt=ds(),oo=ds(),sr=ds();function ds(){return 2**++k5}const Zm=Object.freeze(Object.defineProperty({__proto__:null,boolean:Xe,booleanish:on,commaOrSpaceSeparated:sr,commaSeparated:oo,number:we,overloadedBoolean:Wm,spaceSeparated:Rt},Symbol.toStringTag,{value:"Module"})),Yh=Object.keys(Zm);class mv extends Zn{constructor(t,n,a,s){let l=-1;if(super(t,n),Dw(this,"space",s),typeof a=="number")for(;++l<Yh.length;){const u=Yh[l];Dw(this,Yh[l],(a&Zm[u])===Zm[u])}}}mv.prototype.defined=!0;function Dw(e,t,n){n&&(e[t]=n)}function ko(e){const t={},n={};for(const[a,s]of Object.entries(e.properties)){const l=new mv(a,e.transform(e.attributes||{},a),s,e.space);e.mustUseProperty&&e.mustUseProperty.includes(a)&&(l.mustUseProperty=!0),t[a]=l,n[Vm(a)]=a,n[Vm(l.attribute)]=a}return new nc(t,n,e.space)}const jC=ko({properties:{ariaActiveDescendant:null,ariaAtomic:on,ariaAutoComplete:null,ariaBusy:on,ariaChecked:on,ariaColCount:we,ariaColIndex:we,ariaColSpan:we,ariaControls:Rt,ariaCurrent:null,ariaDescribedBy:Rt,ariaDetails:null,ariaDisabled:on,ariaDropEffect:Rt,ariaErrorMessage:null,ariaExpanded:on,ariaFlowTo:Rt,ariaGrabbed:on,ariaHasPopup:null,ariaHidden:on,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Rt,ariaLevel:we,ariaLive:null,ariaModal:on,ariaMultiLine:on,ariaMultiSelectable:on,ariaOrientation:null,ariaOwns:Rt,ariaPlaceholder:null,ariaPosInSet:we,ariaPressed:on,ariaReadOnly:on,ariaRelevant:null,ariaRequired:on,ariaRoleDescription:Rt,ariaRowCount:we,ariaRowIndex:we,ariaRowSpan:we,ariaSelected:on,ariaSetSize:we,ariaSort:null,ariaValueMax:we,ariaValueMin:we,ariaValueNow:we,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function CC(e,t){return t in e?e[t]:t}function NC(e,t){return CC(e,t.toLowerCase())}const S5=ko({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:oo,acceptCharset:Rt,accessKey:Rt,action:null,allow:null,allowFullScreen:Xe,allowPaymentRequest:Xe,allowUserMedia:Xe,alt:null,as:null,async:Xe,autoCapitalize:null,autoComplete:Rt,autoFocus:Xe,autoPlay:Xe,blocking:Rt,capture:null,charSet:null,checked:Xe,cite:null,className:Rt,cols:we,colSpan:null,content:null,contentEditable:on,controls:Xe,controlsList:Rt,coords:we|oo,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Xe,defer:Xe,dir:null,dirName:null,disabled:Xe,download:Wm,draggable:on,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Xe,formTarget:null,headers:Rt,height:we,hidden:Wm,high:we,href:null,hrefLang:null,htmlFor:Rt,httpEquiv:Rt,id:null,imageSizes:null,imageSrcSet:null,inert:Xe,inputMode:null,integrity:null,is:null,isMap:Xe,itemId:null,itemProp:Rt,itemRef:Rt,itemScope:Xe,itemType:Rt,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Xe,low:we,manifest:null,max:null,maxLength:we,media:null,method:null,min:null,minLength:we,multiple:Xe,muted:Xe,name:null,nonce:null,noModule:Xe,noValidate:Xe,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:Xe,optimum:we,pattern:null,ping:Rt,placeholder:null,playsInline:Xe,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Xe,referrerPolicy:null,rel:Rt,required:Xe,reversed:Xe,rows:we,rowSpan:we,sandbox:Rt,scope:null,scoped:Xe,seamless:Xe,selected:Xe,shadowRootClonable:Xe,shadowRootDelegatesFocus:Xe,shadowRootMode:null,shape:null,size:we,sizes:null,slot:null,span:we,spellCheck:on,src:null,srcDoc:null,srcLang:null,srcSet:null,start:we,step:null,style:null,tabIndex:we,target:null,title:null,translate:null,type:null,typeMustMatch:Xe,useMap:null,value:on,width:we,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Rt,axis:null,background:null,bgColor:null,border:we,borderColor:null,bottomMargin:we,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Xe,declare:Xe,event:null,face:null,frame:null,frameBorder:null,hSpace:we,leftMargin:we,link:null,longDesc:null,lowSrc:null,marginHeight:we,marginWidth:we,noResize:Xe,noHref:Xe,noShade:Xe,noWrap:Xe,object:null,profile:null,prompt:null,rev:null,rightMargin:we,rules:null,scheme:null,scrolling:on,standby:null,summary:null,text:null,topMargin:we,valueType:null,version:null,vAlign:null,vLink:null,vSpace:we,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Xe,disableRemotePlayback:Xe,prefix:null,property:null,results:we,security:null,unselectable:null},space:"html",transform:NC}),j5=ko({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:sr,accentHeight:we,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:we,amplitude:we,arabicForm:null,ascent:we,attributeName:null,attributeType:null,azimuth:we,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:we,by:null,calcMode:null,capHeight:we,className:Rt,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:we,diffuseConstant:we,direction:null,display:null,dur:null,divisor:we,dominantBaseline:null,download:Xe,dx:null,dy:null,edgeMode:null,editable:null,elevation:we,enableBackground:null,end:null,event:null,exponent:we,externalResourcesRequired:null,fill:null,fillOpacity:we,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:oo,g2:oo,glyphName:oo,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:we,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:we,horizOriginX:we,horizOriginY:we,id:null,ideographic:we,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:we,k:we,k1:we,k2:we,k3:we,k4:we,kernelMatrix:sr,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:we,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:we,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:we,overlineThickness:we,paintOrder:null,panose1:null,path:null,pathLength:we,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Rt,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:we,pointsAtY:we,pointsAtZ:we,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:sr,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:sr,rev:sr,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:sr,requiredFeatures:sr,requiredFonts:sr,requiredFormats:sr,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:we,specularExponent:we,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:we,strikethroughThickness:we,string:null,stroke:null,strokeDashArray:sr,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:we,strokeOpacity:we,strokeWidth:null,style:null,surfaceScale:we,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:sr,tabIndex:we,tableValues:null,target:null,targetX:we,targetY:we,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:sr,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:we,underlineThickness:we,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:we,values:null,vAlphabetic:we,vMathematical:we,vectorEffect:null,vHanging:we,vIdeographic:we,version:null,vertAdvY:we,vertOriginX:we,vertOriginY:we,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:we,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:CC}),EC=ko({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),AC=ko({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:NC}),TC=ko({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),C5={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},N5=/[A-Z]/g,zw=/-[a-z]/g,E5=/^data[-\w.:]+$/i;function A5(e,t){const n=Vm(t);let a=t,s=Zn;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&E5.test(t)){if(t.charAt(4)==="-"){const l=t.slice(5).replace(zw,_5);a="data"+l.charAt(0).toUpperCase()+l.slice(1)}else{const l=t.slice(4);if(!zw.test(l)){let u=l.replace(N5,T5);u.charAt(0)!=="-"&&(u="-"+u),t="data"+u}}s=mv}return new s(a,t)}function T5(e){return"-"+e.toLowerCase()}function _5(e){return e.charAt(1).toUpperCase()}const R5=SC([jC,S5,EC,AC,TC],"html"),gv=SC([jC,j5,EC,AC,TC],"svg");function O5(e){return e.join(" ").trim()}var Qs={},Qh,$w;function L5(){if($w)return Qh;$w=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,s=/^:\s*/,l=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,u=/^[;\s]*/,d=/^\s+|\s+$/g,f=`
1624
+ `))a.startsWith("event:")?t=a.slice(6).trim():a.startsWith("data:")&&(n+=a.slice(5).trim());if(!n)return null;try{const a=JSON.parse(n);switch(t){case"start":return{type:"start",...a};case"delta":return{type:"delta",text:a.text??""};case"final":return{type:"final",content:a.content??""};case"error":return{type:"error",error:a.error??"unknown error"};case"done":return{type:"done"};default:return null}}catch{return null}}const IP=({contextGraphId:e,entityUri:t,placeholder:n,fallback:a})=>{const[s,l]=Ve.useState(""),[u,d]=Ve.useState(!0),[f,h]=Ve.useState(null);return Ve.useEffect(()=>{const g=new AbortController;let m="";return l(""),h(null),d(!0),(async()=>{try{const y=zP();for await(const b of $P({contextGraphId:e,entityUri:t,libraryPrompt:y,signal:g.signal}))if(b.type==="delta")m+=b.text,l(m);else if(b.type==="final")b.content&&(m=b.content,l(b.content));else if(b.type==="error"){h(b.error);break}else if(b.type==="done")break}catch(y){y.name!=="AbortError"&&h(y.message)}finally{d(!1)}})(),()=>g.abort()},[e,t]),f?a?o.jsx(o.Fragment,{children:a(f)}):o.jsx(UP,{error:f}):!s&&u?o.jsx(o.Fragment,{children:n??o.jsx("div",{className:"v10-genui-loading",children:"Composing detail view…"})}):o.jsx("div",{className:"v10-genui-panel",children:o.jsx(oP,{response:s,library:xC,isStreaming:u})})},PP="LLM not configured",UP=({error:e})=>{const t=fn(a=>a.openTab);return e.includes(PP)?o.jsxs("div",{className:"v10-genui-error v10-genui-error-cta",children:[o.jsxs("div",{className:"v10-genui-error-head",children:[o.jsx("span",{className:"v10-genui-error-icon",children:"⚙"}),o.jsxs("div",{children:[o.jsx("div",{className:"v10-genui-error-title",children:"Set up your LLM to enable GenUI"}),o.jsx("div",{className:"v10-genui-error-desc",children:"GenUI streams entity detail views from an OpenAI-compatible model. Add an API key in Settings and open this entity again."})]})]}),o.jsx("button",{className:"v10-genui-error-cta-btn",onClick:()=>t({id:"settings",label:"Settings",closable:!0}),children:"Open Settings →"})]}):o.jsxs("div",{className:"v10-genui-error",children:["GenUI unavailable: ",e]})};function Nw({entity:e,profile:t}){const n=w.useMemo(()=>{for(const d of e.subGraphs)if(d!=="meta")return d;return null},[e.subGraphs]);if(!n||!t)return null;const a=t.forSubGraph(n),s=(a==null?void 0:a.color)??"#64748b",l=(a==null?void 0:a.icon)??"•",u=(a==null?void 0:a.displayName)??n;return o.jsxs("span",{className:"v10-subgraph-badge",style:{"--sg-color":s},title:`In sub-graph: ${u}`,children:[o.jsx("span",{className:"v10-subgraph-badge-icon",style:{color:s},children:l}),o.jsx("span",{className:"v10-subgraph-badge-label",children:u})]})}function BP({entity:e,contextGraphId:t,onVerified:n}){const a=Ua(),[s,l]=w.useState(!1),[u,d]=w.useState(null),[f,h]=w.useState(null),[g,m]=w.useState(null),y=e.trustLevel,b=w.useMemo(()=>{if(!a)return null;for(const E of e.types){const T=a.forType(E);if(T&&(y==="working"&&(T.promoteLabel||T.promoteHint)||y==="shared"&&(T.publishLabel||T.publishHint)))return T}return null},[e.types,a,y]),k=w.useMemo(()=>{if(!a)return null;for(const E of e.subGraphs){if(E==="meta")continue;const T=a.forSubGraph(E);if(T!=null&&T.sourceAssertion)return{binding:T,subGraph:E}}return null},[e.subGraphs,a]);if(y==="verified"||!b)return null;const j=y==="working"?{kind:"promote",label:b.promoteLabel??"Promote to Shared Memory",hint:b.promoteHint??"Shares the complete owning Knowledge Asset with the team.",busyCopy:"Sharing…",disabled:!(k!=null&&k.binding.sourceAssertion),disabledReason:k!=null&&k.binding.sourceAssertion?null:`No sourceAssertion declared on the sub-graph profile — add profile:sourceAssertion to the SubGraphBinding for "${[...e.subGraphs].filter(E=>E!=="meta")[0]??"?"}".`}:{kind:"publish",label:b.publishLabel??"Verify on DKG",hint:b.publishHint??"Publishes the complete owning Knowledge Asset on-chain.",busyCopy:"Anchoring…",disabled:!(k!=null&&k.binding.sourceAssertion),disabledReason:k!=null&&k.binding.sourceAssertion?null:"This entity is not part of a named Shared-Memory asset, so it cannot be published to Verifiable Memory from here."},N=async()=>{if(j.disabled)return;l(!0),m(null),d(null),h(j.kind);const E=(k==null?void 0:k.binding.sourceAssertion)??"assertion";try{if(j.kind==="promote"){const T=await lo(t,k.binding.sourceAssertion,k.subGraph?{subGraphName:k.subGraph}:{});d(_g(E,T))}else{const T=await Ag(t,k.binding.sourceAssertion,k.subGraph?{subGraphName:k.subGraph}:{});d(T)}n()}catch(T){const U=j.kind==="promote"?co(E,T):null,_=U?U.message:(T==null?void 0:T.message)??"Action failed";m(_)}finally{l(!1)}},S=E=>!!E&&"status"in E,A=E=>!!E&&"kind"in E;return o.jsxs("div",{className:`v10-ka-verify v10-ka-verify-${j.kind}`,children:[o.jsxs("div",{className:"v10-ka-verify-head",children:[o.jsx("span",{className:"v10-ka-verify-arrow",children:j.kind==="promote"?"◈":"◉"}),o.jsx("span",{className:"v10-ka-verify-title",children:j.label})]}),o.jsx("div",{className:"v10-ka-verify-hint",children:j.hint}),j.disabledReason&&o.jsxs("div",{className:"v10-ka-verify-err",children:["! ",j.disabledReason]}),!u&&o.jsx("button",{className:`v10-ka-verify-btn ${j.kind}`,onClick:N,disabled:s||j.disabled,children:s?j.busyCopy:j.label}),g&&o.jsxs("div",{className:"v10-ka-verify-err",children:["✕ ",g]}),u&&f==="promote"&&A(u)&&u.kind==="success"&&o.jsxs("div",{className:"v10-ka-verify-ok",children:[o.jsxs("div",{className:"v10-ka-verify-ok-row",children:[o.jsx("span",{className:"v10-ka-verify-ok-lbl",children:"Promoted"}),o.jsxs("span",{className:"v10-ka-verify-ok-val",children:["✓ ",u.promotedCount," triple",u.promotedCount===1?"":"s"," now in Shared Memory"]})]}),o.jsx("div",{className:"v10-ka-verify-hint",style:{marginTop:6},children:"Refresh the entity to see the next step appear."})]}),u&&f==="promote"&&A(u)&&u.kind!=="success"&&o.jsxs("div",{className:"v10-ka-verify-err",children:["! ",u.message]}),u&&f==="publish"&&S(u)&&(()=>{var U,_;const E=u.status==="confirmed"&&!!u.txHash,T=E&&!!u.contextGraphError;return o.jsxs("div",{className:E?T?"v10-ka-verify-warn":"v10-ka-verify-ok":"v10-ka-verify-err",children:[o.jsxs("div",{className:"v10-ka-verify-ok-row",children:[o.jsx("span",{className:"v10-ka-verify-ok-lbl",children:"Status"}),o.jsxs("span",{className:"v10-ka-verify-ok-val",children:[E?T?"⚠":"✓":"✕"," ",u.status,E?T?` (${A_})`:"":" (NOT on-chain)"]})]}),T&&o.jsx("div",{className:"v10-ka-verify-hint",style:{marginTop:6},children:Il(u.contextGraphError)}),u.txHash?o.jsxs("div",{className:"v10-ka-verify-ok-row",children:[o.jsx("span",{className:"v10-ka-verify-ok-lbl",children:"TX hash"}),o.jsx("span",{className:"v10-ka-verify-ok-val mono",title:u.txHash,children:u.txHash})]}):o.jsxs("div",{className:"v10-ka-verify-ok-row",children:[o.jsx("span",{className:"v10-ka-verify-ok-lbl",children:"TX hash"}),o.jsx("span",{className:"v10-ka-verify-ok-val",children:"none — on-chain submission skipped"})]}),u.blockNumber!=null&&o.jsxs("div",{className:"v10-ka-verify-ok-row",children:[o.jsx("span",{className:"v10-ka-verify-ok-lbl",children:"Block"}),o.jsxs("span",{className:"v10-ka-verify-ok-val mono",children:["#",u.blockNumber]})]}),((_=(U=u.kas)==null?void 0:U[0])==null?void 0:_.tokenId)&&o.jsxs("div",{className:"v10-ka-verify-ok-row",children:[o.jsx("span",{className:"v10-ka-verify-ok-lbl",children:"Token"}),o.jsxs("span",{className:"v10-ka-verify-ok-val mono",children:["#",u.kas[0].tokenId]})]})]})})()]})}function FP({entity:e,allEntities:t,allTriples:n,onNavigate:a,onClose:s,contextGraphId:l,onRefresh:u,onOpenAgent:d}){const[f,h]=w.useState("content"),g=Vn(I=>I.theme),m=Ua(),y=cs(),{icon:b,type:k}=Bd(e,m),j=G4(e),N=Ud(e),S=N?(y==null?void 0:y.get(N))??null:null,A=e.trustLevel==="verified"?"vm":e.trustLevel==="shared"?"swm":"wm",E=e.trustLevel==="verified"?"Verifiable Memory":e.trustLevel==="shared"?"Shared Working Memory":"Working Memory",T=ia(e.trustLevel,1),U=w.useMemo(()=>{const I=[];for(const[,H]of t)for(const B of H.connections)B.targetUri===e.uri&&I.push({pred:Zs(B.predicate),entity:H});return I},[e.uri,t]),_=w.useMemo(()=>n.filter(I=>bt(I.subject)===e.uri||bt(I.object)===e.uri),[e.uri,n]),z=w.useMemo(()=>V4(e.uri,n,1),[e.uri,n]),q=w.useMemo(()=>{const I=new Set;for(const H of t.values())rj(H)&&I.add(bt(H.uri));return I},[t]),D=w.useMemo(()=>new Set([bt(e.uri)]),[e.uri]),R=w.useMemo(()=>hd(z,q,{focalSubjects:D}),[z,q,D]),$=w.useMemo(()=>{const I=Yi[e.trustLevel];return{labelMode:"humanized",renderer:"2d",labels:Id({minZoomForLabels:.2}),style:{namespaceColors:Vg(I),defaultNodeColor:I,defaultEdgeColor:"#475569",edgeWidth:1,fontSize:11},hexagon:{baseSize:7,minSize:4,maxSize:10,scaleWithDegree:!0},focus:{maxNodes:500,hops:999}}},[e.trustLevel]),F=w.useMemo(()=>({name:`entity-${e.uri}-${g}`,palette:g,focal:{uri:e.uri,sizeMultiplier:2.4}}),[e.uri,g]),K=_.length;return o.jsxs("div",{className:"v10-ka-detail",children:[o.jsxs("div",{className:"v10-ka-header",children:[o.jsx("button",{className:"v10-ka-back",onClick:s,children:"← Back to Context Graph"}),o.jsxs("div",{className:"v10-ka-header-left",children:[o.jsx("div",{className:"v10-ka-label",children:T}),o.jsxs("div",{className:"v10-ka-name",children:[b," ",e.label,o.jsx("span",{className:`v10-trust-badge ${A}`,children:E})]}),o.jsxs("div",{className:"v10-ka-ual",children:[e.uri," · ",k," · ",K," triples"]})]}),(S||N)&&o.jsxs("div",{className:"v10-ka-header-author",children:[o.jsx("div",{className:"v10-ka-header-author-label",children:"Proposed by"}),o.jsx(ts,{agent:S??void 0,fallbackUri:N??void 0,size:"lg",showOperator:!0,onOpenAgent:d})]})]}),o.jsxs("div",{className:"v10-ka-split",children:[o.jsxs("div",{className:"v10-ka-left",children:[o.jsxs("div",{className:"v10-content-tabs",style:{margin:"0 -20px",padding:"0 20px",background:"transparent"},children:[o.jsx("button",{className:`v10-content-tab ${f==="content"?"active":""}`,onClick:()=>h("content"),children:"Content"}),o.jsx("button",{className:`v10-content-tab ${f==="triples"?"active":""}`,onClick:()=>h("triples"),children:"Triples"}),o.jsx("button",{className:`v10-content-tab ${f==="graph"?"active":""}`,onClick:()=>h("graph"),children:"Graph"})]}),f==="content"&&o.jsxs(o.Fragment,{children:[!e.types.map(H=>m==null?void 0:m.forType(H)).find(H=>H==null?void 0:H.detailHint)||!(m!=null&&m.contextGraphId)?null:o.jsx("div",{className:"v10-ka-section",children:o.jsx(IP,{contextGraphId:m.contextGraphId,entityUri:e.uri})}),j&&o.jsx("div",{className:"v10-ka-section",children:o.jsx("div",{className:"v10-ka-desc",children:o.jsx("p",{children:j})})}),e.properties.size>0&&o.jsxs("div",{className:"v10-ka-section",children:[o.jsx("div",{className:"v10-ka-section-title",children:"Properties"}),[...e.properties].map(([I,H])=>o.jsxs("div",{className:"v10-ka-prop",children:[o.jsx("span",{className:"v10-ka-prop-key",children:Zs(I)}),o.jsx("span",{className:"v10-ka-prop-val",children:H.join(", ")})]},I))]}),e.connections.length>0&&o.jsxs("div",{className:"v10-ka-section",children:[o.jsxs("div",{className:"v10-ka-section-title",children:["References (",e.connections.length,")"]}),e.connections.map((I,H)=>{const B=t.get(I.targetUri);return o.jsxs("button",{className:"v10-ka-conn",onClick:()=>a(I.targetUri),children:[o.jsx("span",{className:"v10-ka-conn-pred",children:Zs(I.predicate)}),o.jsx("span",{className:"v10-ka-conn-arrow",children:"→"}),o.jsx("span",{className:"v10-ka-conn-target",children:I.targetLabel}),B&&o.jsx(Nw,{entity:B,profile:m})]},H)})]}),U.length>0&&o.jsxs("div",{className:"v10-ka-section",children:[o.jsxs("div",{className:"v10-ka-section-title",children:["Referenced by (",U.length,")"]}),U.map((I,H)=>o.jsxs("button",{className:"v10-ka-conn",onClick:()=>a(I.entity.uri),children:[o.jsx("span",{className:"v10-ka-conn-target",children:I.entity.label}),o.jsx(Nw,{entity:I.entity,profile:m}),o.jsx("span",{className:"v10-ka-conn-arrow",children:"→"}),o.jsx("span",{className:"v10-ka-conn-pred",children:I.pred})]},H))]}),o.jsxs("div",{className:"v10-ka-meta",children:[o.jsxs("span",{className:"v10-ka-meta-item",children:[b," ",k]}),o.jsxs("span",{className:"v10-ka-meta-item",children:[K," triples"]}),o.jsxs("span",{className:"v10-ka-meta-item",children:[e.connections.length," links"]})]})]}),f==="triples"&&o.jsxs("div",{style:{marginTop:8,overflowX:"auto",border:"1px solid var(--border-default)",borderRadius:6},children:[o.jsxs("table",{className:"v10-ka-triples-table",children:[o.jsx("thead",{children:o.jsxs("tr",{children:[o.jsx("th",{children:"Subject"}),o.jsx("th",{children:"Predicate"}),o.jsx("th",{children:"Object"})]})}),o.jsx("tbody",{children:_.slice(0,50).map((I,H)=>o.jsxs("tr",{children:[o.jsx("td",{title:I.subject,children:Zs(I.subject)}),o.jsx("td",{title:I.predicate,children:Zs(I.predicate)}),o.jsx("td",{title:I.object,children:I.object.startsWith('"')?Pd(I.object).slice(0,60):Zs(I.object)})]},H))})]}),o.jsxs("div",{style:{fontSize:10,color:"var(--text-tertiary)",fontFamily:"var(--font-mono)",padding:"6px 8px"},children:[Math.min(_.length,50)," of ",_.length," triples shown"]})]}),f==="graph"&&o.jsx(Xu,{title:`${e.label} graph`,scopeLabel:`Entity detail graph: 1-hop neighborhood around ${e.label}.`,tone:A,className:"v10-ka-graph-shell",renderGraph:I=>R.length>0?o.jsx(w.Suspense,{fallback:o.jsx("span",{className:"v10-graph-placeholder",children:"Loading graph..."}),children:o.jsx(Jg,{data:R,format:"triples",options:$,viewConfig:F,style:{position:"absolute",inset:0,width:"100%",height:"100%"},onNodeClick:H=>(H==null?void 0:H.id)&&H.id!==e.uri&&a(H.id),initialFit:!0,initialFocus:e.uri},`${e.uri}:${I?"expanded":"inline"}`)}):o.jsx("div",{className:"v10-graph-placeholder v10-graph-placeholder-centered",children:"No neighborhood data"})})]}),o.jsxs("div",{className:"v10-ka-right",children:[o.jsx(gz,{contextGraphId:l,entityUri:e.uri,enabled:e.trustLevel==="verified"}),o.jsx("div",{className:"v10-ka-section-title",children:"Provenance Trail"}),o.jsx(HP,{entity:e}),o.jsx(BP,{entity:e,contextGraphId:l,onVerified:u}),o.jsxs("div",{style:{marginTop:16,padding:"10px 12px",borderRadius:6,background:"var(--bg-surface)",border:"1px solid var(--border-subtle)"},children:[o.jsx("div",{className:"v10-ka-section-title",style:{marginBottom:6},children:"Entity Summary"}),o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:4,fontSize:10},children:[o.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[o.jsx("span",{style:{color:"var(--text-tertiary)"},children:"Type"}),o.jsx("span",{style:{color:"var(--text-primary)",fontWeight:600,fontFamily:"var(--font-mono)"},children:k})]}),o.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[o.jsx("span",{style:{color:"var(--text-tertiary)"},children:"Triples"}),o.jsx("span",{style:{color:"var(--text-primary)",fontWeight:600,fontFamily:"var(--font-mono)"},children:K})]}),o.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[o.jsx("span",{style:{color:"var(--text-tertiary)"},children:"Links"}),o.jsx("span",{style:{color:"var(--text-primary)",fontWeight:600,fontFamily:"var(--font-mono)"},children:e.connections.length})]}),o.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[o.jsx("span",{style:{color:"var(--text-tertiary)"},children:"Layer"}),o.jsx("span",{style:{color:"var(--text-primary)",fontWeight:600,fontFamily:"var(--font-mono)"},children:E.split(" ")[0]})]})]})]})]})]})]})}function HP({entity:e}){const t=cs(),n=u=>{const d=F4(e,u),f=H4(e,u),h=d?t==null?void 0:t.get(d):null;return{uri:d,at:f,agent:h}},a=n("created"),s=n("promoted"),l=n("published");return o.jsxs("div",{className:"v10-ka-timeline",children:[e.trustLevel==="verified"&&o.jsx(Vh,{toneClass:"verified",title:"Published to Verifiable Memory",actionWord:"Published",agent:l.agent,agentUri:l.uri,at:l.at}),(e.trustLevel==="shared"||e.trustLevel==="verified")&&o.jsx(Vh,{toneClass:"shared",title:"Promoted to Shared Working Memory",actionWord:"Promoted",agent:s.agent,agentUri:s.uri,at:s.at}),o.jsx(Vh,{toneClass:"created",title:"Created in Working Memory",actionWord:"Created",agent:a.agent,agentUri:a.uri,at:a.at})]})}function Vh({toneClass:e,title:t,actionWord:n,agent:a,agentUri:s,at:l}){const u=l?Y4(l):null;return o.jsxs("div",{className:"v10-ka-event",children:[o.jsx("div",{className:`v10-ka-event-dot ${e}`}),o.jsxs("div",{className:"v10-ka-event-header",children:[o.jsx("span",{className:"v10-ka-event-title",children:t}),u&&o.jsx("time",{className:"v10-ka-event-time",dateTime:l??void 0,children:u})]}),(a||s)&&o.jsxs("div",{className:"v10-ka-event-attribution",children:[o.jsxs("span",{className:"v10-ka-event-attribution-prefix",children:[n," by"]}),o.jsx(ts,{agent:a??void 0,fallbackUri:s??void 0,size:"sm"})]})]})}function Ew(){return o.jsxs("div",{className:"v10-subgraph-explorer-header",children:[o.jsx("div",{className:"v10-subgraph-explorer-title",children:"Subgraph Explorer"}),o.jsx("p",{className:"v10-subgraph-explorer-intro",children:"Subgraphs are optional topical partitions inside this Context Graph. An entity belongs to one or more memory layers and, optionally, to one or more subgraphs. Entities in no subgraph live in the context graph root."})]})}function qP({contextGraphId:e,memory:t,onNodeClick:n,onSelectSubGraph:a}){const s=Ua(),[l,u]=w.useState([]),[d,f]=w.useState(!0),[h,g]=w.useState(null);w.useEffect(()=>{let _=!1;return f(!0),g(null),Mg(e).then(z=>{_||u(z.subGraphs??[])}).catch(z=>{_||g(z instanceof Error?z.message:"Failed to load subgraphs")}).finally(()=>{_||f(!1)}),()=>{_=!0}},[e]);const{total:m}=Zg(t),y=Object.values(t.layerStatus??{}),b=t.loading||y.some(_=>_==="loading"),k=t.error!==null||t.partial||y.some(_=>_==="error"),j=w.useMemo(()=>{const _=new Map;for(const z of t.entityList){const q=bt(z.uri);for(const D of z.subGraphs){let R=_.get(D);R||(R=new Set,_.set(D,R)),R.add(q)}}return _},[t.entityList]),{triplesBySubGraph:N,tripleCountBySubGraph:S}=w.useMemo(()=>{const _=new Map;for(const D of t.allTriples){if(!D.subGraph)continue;let R=_.get(D.subGraph);R||(R=[],_.set(D.subGraph,R)),R.push(D)}for(const D of t.allTriples)if(!D.subGraph){for(const[R,$]of j)if(Tm(D,{slug:R,isRoot:!1,scopedUris:$})){let F=_.get(R);F||(F=[],_.set(R,F)),F.push(D)}}const z=new Map,q=new Map;for(const[D,R]of _){const F=_m(R,t.entities).map(K=>({subject:K.subject,predicate:K.predicate,object:K.object}));q.set(D,F.length),z.set(D,M1(F))}return{triplesBySubGraph:z,tripleCountBySubGraph:q}},[t.allTriples,t.entities,j]),A=w.useMemo(()=>{const _=new Map;for(const z of t.entityList)for(const q of z.subGraphs){let D=_.get(q);D||(D={wm:0,swm:0,vm:0},_.set(q,D)),z.trustLevel==="verified"?D.vm++:z.trustLevel==="shared"?D.swm++:D.wm++}return _},[t.entityList]),E=w.useMemo(()=>{const _=new Map;for(const z of t.entityList){const q=bt(z.uri);for(const D of z.subGraphs){let R=_.get(D);R||(R=new Map,_.set(D,R)),R.set(q,z.trustLevel),q!==z.uri&&R.set(z.uri,z.trustLevel)}}return _},[t.entityList]),T=w.useMemo(()=>l.filter(Kg).map(_=>{const z=(s==null?void 0:s.forSubGraph(_.name))??{},q=N.get(_.name)??[],D=j.get(_.name)??new Set,R=E.get(_.name)??new Map;return{slug:_.name,icon:z.icon??"•",color:z.color??"#64748b",displayName:z.displayName??_.name,description:z.description,rank:z.rank??99,entityCount:D.size>0?D.size:_.entityCount,tripleCount:S.get(_.name)??0,triples:hd(q,D),layerCounts:A.get(_.name)??{wm:0,swm:0,vm:0},entityTrustByUri:R}}).sort((_,z)=>_.rank-z.rank),[l,s,N,S,A,j,E]),U=w.useMemo(()=>{const _=[],z=new Set,q=new Map;let D=0,R=0,$=0;for(const Q of t.entityList){if(Q.subGraphs.size>0)continue;_.push(Q);const V=bt(Q.uri);z.add(V),q.set(V,Q.trustLevel),V!==Q.uri&&q.set(Q.uri,Q.trustLevel),Q.trustLevel==="verified"?$++:Q.trustLevel==="shared"?R++:D++}const F=t.allTriples.filter(Q=>!Q.subGraph),K=_m(F,t.entities).map(Q=>({subject:Q.subject,predicate:Q.predicate,object:Q.object})),I=K.length,H=hd(K,z),B=M1(H),W=(s==null?void 0:s.forSubGraph($r))??{};return{slug:$r,icon:W.icon??"⊘",color:W.color??"#64748b",displayName:W.displayName??"Root",description:W.description,rank:999,entityCount:_.length,tripleCount:I,triples:B,layerCounts:{wm:D,swm:R,vm:$},entityTrustByUri:q}},[t.entityList,t.allTriples,t.entities,s]);return d&&T.length===0?o.jsx(ln,{compact:!0,icon:"#",title:"Loading subgraphs...",className:"v10-sgov-state"}):h&&T.length===0?o.jsx(ln,{icon:"!",title:"Couldn't load subgraphs.",description:"Refresh the page to try again.",tone:"danger",className:"v10-sgov-state"}):T.length===0&&U.entityCount===0?o.jsx(ln,{icon:"#",title:"No subgraphs in this Context Graph yet.",description:o.jsxs(o.Fragment,{children:["A subgraph is a named topical slice of this Context Graph (e.g. ",o.jsx("code",{children:"recipes"}),", ",o.jsx("code",{children:"decisions"}),"). Agents create one when they scope an assertion to a subgraph. All current entities live in the Context Graph root."]}),actions:[{label:"View root",onClick:()=>a($r),variant:"primary"}],className:"v10-sgov-state"}):o.jsxs("div",{className:"v10-sgov",children:[o.jsxs("div",{className:"v10-sgov-header",children:[o.jsx("div",{className:"v10-sgov-title",children:"Subgraphs"}),o.jsxs("div",{className:"v10-sgov-sub",children:[T.length," named subgraphs · ",t.counts.total," entities · ",m," triples"]})]}),o.jsxs("div",{className:"v10-sgov-grid",children:[T.map(_=>o.jsx(Aw,{card:_,isHydrating:b,isFailedOrPartial:k,onNodeClick:n,onOpen:()=>a(_.slug)},_.slug)),o.jsx(Aw,{card:U,isHydrating:b,isFailedOrPartial:k,onNodeClick:n,onOpen:()=>a($r),variant:"root"},$r)]})]})}function Aw({card:e,isHydrating:t=!1,isFailedOrPartial:n=!1,onNodeClick:a,onOpen:s,variant:l}){const u=w.useMemo(()=>{const h={};for(const[g,m]of e.entityTrustByUri)h[g]=Yi[m];return h},[e.entityTrustByUri]),d=w.useMemo(()=>({labelMode:"humanized",renderer:"2d",labels:Id({minZoomForLabels:.8}),style:{classColors:cj,predicateColors:uj,namespaceColors:Vg(e.color),...Object.keys(u).length>0?{nodeColors:u}:{},defaultNodeColor:e.color,defaultEdgeColor:"#475569",edgeWidth:1,fontSize:12,gradient:!0,gradientIntensity:.35},hexagon:{baseSize:6,minSize:3,maxSize:16,scaleWithDegree:!0},focus:{maxNodes:5e3,hops:999}}),[e.color,u]),f=l==="root";return o.jsxs("div",{className:`v10-sgov-card${f?" root":""}`,style:f?void 0:{"--sg-color":e.color,borderColor:e.color+"55"},children:[o.jsxs("div",{className:"v10-sgov-card-head",children:[o.jsx("span",{className:"v10-sgov-card-icon",style:f?void 0:{color:e.color},children:e.icon}),o.jsxs("div",{className:"v10-sgov-card-title-wrap",children:[o.jsx("div",{className:"v10-sgov-card-title",children:e.displayName}),e.description&&o.jsx("div",{className:"v10-sgov-card-desc",title:e.description,children:e.description})]}),o.jsx("button",{type:"button",className:"v10-sgov-card-open",onClick:s,title:`Focus on ${e.displayName}`,children:"↗"})]}),o.jsxs("div",{className:"v10-sgov-card-stats",children:[o.jsxs("span",{className:"v10-sgov-card-stat",children:[o.jsx("b",{children:e.entityCount})," entities"]}),o.jsxs("span",{className:"v10-sgov-card-stat",title:t&&e.tripleCount===0?"Loading triples for this subgraph…":n?e.tripleCount===0?"Some layers unavailable; count may be incomplete.":`${e.tripleCount} triples (some layers unavailable; count may be incomplete).`:t?`${e.tripleCount} triples (still loading; count may grow).`:e.tripleCount!==e.triples.length?`${e.tripleCount} triples in this subgraph's scope; ${e.triples.length} rendered (some in-scope edges aren't drawn — either endpoints outside this subgraph, or cap-trimmed in dense buckets).`:void 0,children:[o.jsx("b",{children:t&&e.tripleCount===0?"…":e.tripleCount})," triples"]})]}),o.jsx("div",{className:"v10-sgov-card-pyramid",children:o.jsx(wC,{counts:e.layerCounts,compact:!0})}),o.jsx("div",{className:"v10-sgov-card-graph",children:e.triples.length===0?o.jsx("div",{className:"v10-sgov-card-empty",children:e.entityCount>0?"Promoted — open to view":"No data yet"}):o.jsx(w.Suspense,{fallback:o.jsx("div",{className:"v10-sgov-card-empty",children:"Loading…"}),children:o.jsx(Jg,{data:e.triples,format:"triples",options:d,style:{position:"absolute",inset:0,width:"100%",height:"100%"},onNodeClick:a,initialFit:!0})})})]})}function wC({counts:e,activeLayers:t,onClickLayer:n,compact:a=!1}){const s=e.wm+e.swm+e.vm;if(s===0)return a?null:o.jsx("div",{className:"v10-minibar v10-minibar-empty",children:"No data"});const l=[{key:"verified",short:"VM",count:e.vm,color:"#22c55e",label:"Verifiable"},{key:"shared",short:"SWM",count:e.swm,color:"#f59e0b",label:"Shared"},{key:"working",short:"WM",count:e.wm,color:"#64748b",label:"Working"}],u=!!n;return o.jsxs("div",{className:`v10-minibar${a?" compact":""}`,children:[!a&&o.jsx("div",{className:"v10-minibar-bar",children:l.filter(d=>d.count>0).map(d=>{const f=d.count/s*100,h=t?t.has(d.key):!0;return o.jsx("div",{className:`v10-minibar-seg${h?"":" dim"}`,style:{width:`${f}%`,background:d.color},title:`${d.label}: ${d.count}`},d.key)})}),o.jsx("div",{className:"v10-minibar-legend",children:l.map(d=>{const f=t?t.has(d.key):!0;return o.jsxs("button",{type:"button",className:`v10-minibar-chip${f?"":" dim"}${u?" interactive":""}`,onClick:u?()=>n(d.key):void 0,disabled:!u,title:`${d.label} Memory — ${d.count} entities${u?" (click to toggle)":""}`,children:[o.jsx("span",{className:"v10-minibar-dot",style:{background:d.color}}),o.jsx("span",{className:"v10-minibar-short",children:d.short}),o.jsx("span",{className:"v10-minibar-count",children:d.count})]},d.key)})})]})}function GP({items:e,color:t,onSelectEntity:n,scrollKey:a}){const s=Ua(),l=cs(),u=w.useMemo(()=>{const d=new Map;for(const f of e){const h=`${f.date.getFullYear()}-${String(f.date.getMonth()+1).padStart(2,"0")}`,g=d.get(h)??[];g.push(f),d.set(h,g)}return[...d.entries()].sort((f,h)=>f[0].localeCompare(h[0]))},[e]);return e.length===0?o.jsx("div",{className:"v10-subgraph-timeline-empty","data-cg-scroll-key":a,children:o.jsx(ln,{compact:!0,title:"No timeline values yet.",description:"Entities in this sub-graph do not currently expose the configured timeline field."})}):o.jsx("div",{className:"v10-subgraph-timeline","data-cg-scroll-key":a,children:u.map(([d,f])=>o.jsxs("div",{className:"v10-subgraph-timeline-bucket",children:[o.jsxs("div",{className:"v10-subgraph-timeline-bucket-head",children:[o.jsx("span",{className:"v10-subgraph-timeline-bucket-dot",style:{background:t}}),o.jsx("span",{className:"v10-subgraph-timeline-bucket-label",children:Q4(d)}),o.jsx("span",{className:"v10-subgraph-timeline-bucket-count",children:f.length})]}),o.jsx("div",{className:"v10-subgraph-timeline-items",children:f.map(({entity:h,date:g})=>{const{icon:m}=Bd(h,s),y=Ud(h),b=y?l==null?void 0:l.get(y):null;return o.jsxs("button",{className:"v10-subgraph-timeline-item",onClick:()=>n(h.uri),title:`${h.label} · ${g.toISOString().slice(0,10)}`,children:[o.jsx("span",{className:"v10-subgraph-timeline-item-icon",children:m}),o.jsx("span",{className:"v10-subgraph-timeline-item-label",children:h.label}),(b||y)&&o.jsx(ts,{agent:b??void 0,fallbackUri:y??void 0,size:"sm"}),o.jsx("span",{className:"v10-subgraph-timeline-item-date",children:g.toISOString().slice(0,10)})]},h.uri)})})]},d))})}function VP({slug:e,rawMemory:t,contextGraphId:n,onNodeClick:a,onSelectEntity:s,activeTab:l,onTabChange:u,initialLayer:d,initialEnabledLayers:f,onEnabledLayersChange:h}){const g=Ua(),m=g==null?void 0:g.forSubGraph(e),y=(g==null?void 0:g.chipsFor(e))??[],b=(g==null?void 0:g.savedQueryCatalogsFor(e))??[],k=m==null?void 0:m.timelinePredicate,[j,N]=w.useState("items"),S=l??j,A=S==="timeline"&&!k?"items":S,E=u??N,[T,U]=w.useState(m!=null&&m.timelinePredicate?"created-desc":"triples");w.useEffect(()=>{U(m!=null&&m.timelinePredicate?"created-desc":"triples")},[e,m==null?void 0:m.timelinePredicate]);const _=w.useMemo(()=>f&&f.size>0?new Set(f):d==="wm"?new Set(["working"]):d==="swm"?new Set(["shared"]):d==="vm"?new Set(["verified"]):new Set(["working","shared","verified"]),[d,f]),[z,q]=w.useState(_);w.useEffect(()=>{h==null||h(z)},[z,h]);const[D,R]=w.useState(new Map),[$,F]=w.useState(null),[K,I]=w.useState(null),[H,B]=w.useState(!1),[W,Q]=w.useState(null),V=e===$r,L=w.useMemo(()=>{const ee=[];for(const ce of t.entityList)(V?ce.subGraphs.size===0:ce.subGraphs.has(e))&&ee.push(ce);return ee},[t.entityList,e,V]),P=w.useMemo(()=>new Set(L.map(ee=>ee.uri)),[L]),G=w.useMemo(()=>t.graphTriples.filter(ee=>Tm(ee,{slug:e,isRoot:V,scopedUris:P})),[t.graphTriples,P,e,V]),O=w.useMemo(()=>{let ee=0,ce=0,he=0;for(const Le of L)Le.trustLevel==="verified"?he++:Le.trustLevel==="shared"?ce++:ee++;return{wm:ee,swm:ce,vm:he,total:L.length}},[L]),ne=w.useMemo(()=>{if(z.size!==1)return null;const ee=z.values().next().value;return ee==="verified"?"vm":ee==="shared"?"swm":ee==="working"?"wm":null},[z]),ue=w.useMemo(()=>{let ee=L;if(z.size<3&&(ee=ee.filter(ce=>z.has(ce.trustLevel))),D.size>0)for(const ce of y){const he=D.get(ce.slug);!he||he.size===0||(ee=ee.filter(Le=>{const He=Le.properties.get(ce.predicate);return!He||He.length===0?!1:He.some(Ce=>he.has(Ce))}))}return K&&(ee=ee.filter(ce=>K.has(ce.uri))),ee},[L,z,D,y,K]),le=w.useMemo(()=>new Set(ue.map(ee=>ee.uri)),[ue]),be=w.useMemo(()=>ue.length===L.length?G:G.filter(ee=>le.has(ee.subject)||le.has(ee.object)),[G,L,ue,le]),Ee=w.useMemo(()=>{if(!ne)return null;const ee=ne==="vm"?"verified":ne==="swm"?"shared":"working",ce=L.filter(Ce=>{if(!Ce.layers.has(ee))return!1;if(D.size>0)for(const Fe of y){const et=D.get(Fe.slug);if(!et||et.size===0)continue;const Ne=Ce.properties.get(Fe.predicate);if(!Ne||Ne.length===0||!Ne.some(Wt=>et.has(Wt)))return!1}return!(K&&!K.has(Ce.uri))}),he=new Set(ce.map(Ce=>Ce.uri)),Le=new Set,He=[];for(const Ce of t.allTriples){if(Ce.layer!==ee||!Tm(Ce,{slug:e,isRoot:V,scopedUris:P,requireResourceObject:!0})||!(he.has(Ce.subject)||he.has(Ce.object)))continue;const Fe=`${Ce.subject}|${Ce.predicate}|${Ce.object}`;Le.has(Fe)||(Le.add(Fe),He.push({subject:Ce.subject,predicate:Ce.predicate,object:Ce.object,subGraph:Ce.subGraph}))}return He},[ne,t.allTriples,P,e,V,L,y,D,K])??be,Ie=w.useMemo(()=>{if(ne){const ee=ne==="vm"?"verified":ne==="swm"?"shared":"working";return L.filter(ce=>{if(!ce.layers.has(ee))return!1;if(D.size>0)for(const he of y){const Le=D.get(he.slug);if(!Le||Le.size===0)continue;const He=ce.properties.get(he.predicate);if(!He||He.length===0||!He.some(Ce=>Le.has(Ce)))return!1}return!(K&&!K.has(ce.uri))})}return ue},[ne,L,ue,y,D,K]),We=w.useMemo(()=>Ie.map(ee=>({uri:ee.uri,label:ee.label})),[Ie]),Se=w.useMemo(()=>{if(ne)return;const ee={};for(const ce of Ie){ee[ce.uri]=Yi[ce.trustLevel];const he=bt(ce.uri);he!==ce.uri&&(ee[he]=Yi[ce.trustLevel])}return ee},[ne,Ie]),ft=z.size===3?"All layers":ne?zn[ne].title:Array.from(z).map(ee=>zn[ee==="verified"?"vm":ee==="shared"?"swm":"wm"].trustLabel).join(" + "),De=w.useMemo(()=>{if(!k)return[];const ee=[];for(const ce of ue){const he=Qu(ce,k);he!=null&&ee.push({entity:ce,date:new Date(he)})}return ee.sort((ce,he)=>ce.date.getTime()-he.date.getTime()),ee},[ue,k]),qe=w.useMemo(()=>{const ee=[...ue];if((T==="created-desc"||T==="created-asc")&&k){const ce=T==="created-desc"?-1:1;return ee.sort((he,Le)=>{const He=Qu(he,k),Ce=Qu(Le,k);return He==null&&Ce==null?0:He==null?1:Ce==null?-1:(He-Ce)*ce}),ee}return T==="label"?(ee.sort((ce,he)=>(ce.label??"").localeCompare(he.label??"")),ee):(ee.sort((ce,he)=>{const Le=ce.tripleCount??0;return(he.tripleCount??0)-Le}),ee)},[ue,T,k]),ke=T==="created-desc"?"newest first · click to open":T==="created-asc"?"oldest first · click to open":T==="label"?"A → Z · click to open":"sorted by triples · click to open",lt=w.useCallback(ee=>{q(ce=>{const he=new Set(ce);return he.has(ee)?he.size>1&&he.delete(ee):he.add(ee),he})},[]),xe=w.useCallback((ee,ce)=>{R(he=>{const Le=new Map(he),He=new Set(Le.get(ee)??[]);return He.has(ce)?He.delete(ce):He.add(ce),He.size===0?Le.delete(ee):Le.set(ee,He),Le})},[]),Oe=w.useCallback(()=>{F(null),I(null),Q(null)},[]),Ot=w.useCallback(async ee=>{var ce;B(!0),Q(null),F(ee.slug);try{const he=await or(ee.sparql,n),Le=((ce=he==null?void 0:he.result)==null?void 0:ce.bindings)??[],He=ee.resultColumn||"uri",Ce=new Set;for(const Fe of Le){const et=Fe[He];if(!et)continue;const Ne=typeof et=="string"?et:String(et),Wt=Ne.startsWith("<")&&Ne.endsWith(">")?Ne.slice(1,-1):Ne;Ce.add(Wt)}I(Ce)}catch(he){Q((he==null?void 0:he.message)??String(he)),I(null),F(null)}finally{B(!1)}},[n]),$t=(m==null?void 0:m.color)??(V?"var(--text-tertiary)":"#64748b"),Yt=(m==null?void 0:m.icon)??"•",qt=(m==null?void 0:m.displayName)??e,ut=m==null?void 0:m.description;w.useEffect(()=>{q(_),R(new Map),Oe()},[e,Oe,_]),w.useEffect(()=>{l||N("items")},[e,l]),w.useEffect(()=>{S!==A&&E(A)},[S,A,E]);const X=!(z.size===_.size&&[...z].every(ee=>_.has(ee)))||D.size>0||!!K,Z=()=>{q(new Set(_)),R(new Map),Oe()};return o.jsxs("div",{className:"v10-layer-detail v10-subgraph-detail",style:{"--sg-color":$t},children:[o.jsxs("div",{className:"v10-subgraph-detail-header",children:[o.jsx("span",{className:"v10-subgraph-detail-icon",style:{color:$t},children:Yt}),o.jsxs("div",{className:"v10-subgraph-detail-title-wrap",children:[o.jsx("div",{className:"v10-subgraph-detail-title",children:qt}),ut&&o.jsx("div",{className:"v10-subgraph-detail-desc",children:ut})]}),o.jsx(wC,{counts:{wm:O.wm,swm:O.swm,vm:O.vm},activeLayers:z,onClickLayer:lt,compact:!0})]}),o.jsxs("div",{className:"v10-subgraph-cross-layer",children:[o.jsx("div",{className:"v10-subgraph-cross-layer-lede",children:V?"Root entities, across the three memory layers:":"This subgraph, across the three memory layers:"}),o.jsxs("div",{className:"v10-subgraph-cross-layer-strip","data-testid":"cross-layer-strip",children:[o.jsxs("button",{type:"button",className:"v10-subgraph-cross-layer-cell","data-layer":"wm","aria-pressed":z.has("working"),onClick:()=>lt("working"),children:[o.jsx("span",{className:"v10-subgraph-cross-layer-cell-icon",style:{color:Yi.working},children:"◇"}),o.jsx("span",{className:"v10-subgraph-cross-layer-cell-label",children:"Working"}),o.jsx("span",{className:"v10-subgraph-cross-layer-cell-count",children:O.wm})]}),o.jsx("span",{className:"v10-subgraph-cross-layer-arrow","aria-hidden":"true",children:"→"}),o.jsxs("button",{type:"button",className:"v10-subgraph-cross-layer-cell","data-layer":"swm","aria-pressed":z.has("shared"),onClick:()=>lt("shared"),title:ne==="swm"?"Showing Shared Working Memory only — graph is colored by contributing agent (see legend).":void 0,children:[o.jsx("span",{className:"v10-subgraph-cross-layer-cell-icon",style:{color:Yi.shared},children:"◈"}),o.jsx("span",{className:"v10-subgraph-cross-layer-cell-label",children:"Shared"}),o.jsx("span",{className:"v10-subgraph-cross-layer-cell-count",children:O.swm})]}),o.jsx("span",{className:"v10-subgraph-cross-layer-arrow","aria-hidden":"true",children:"→"}),o.jsxs("button",{type:"button",className:"v10-subgraph-cross-layer-cell","data-layer":"vm","aria-pressed":z.has("verified"),onClick:()=>lt("verified"),children:[o.jsx("span",{className:"v10-subgraph-cross-layer-cell-icon",style:{color:Yi.verified},children:"◉"}),o.jsx("span",{className:"v10-subgraph-cross-layer-cell-label",children:"Verifiable"}),o.jsx("span",{className:"v10-subgraph-cross-layer-cell-count",children:O.vm})]})]}),o.jsxs("span",{className:`v10-subgraph-active-layer-pill${z.size===3?" all-layers":""}`,"data-testid":"active-layer-pill",children:[o.jsx("span",{className:"v10-subgraph-active-layer-pill-label",children:"Active layer:"}),o.jsx("span",{className:"v10-subgraph-active-layer-pill-value",children:ft})]})]}),b.length>0&&o.jsxs("div",{className:"v10-subgraph-savedqueries",children:[o.jsx("span",{className:"v10-subgraph-savedqueries-label",children:"Query catalog"}),b.map(ee=>o.jsxs(Ve.Fragment,{children:[o.jsx("span",{className:"v10-subgraph-savedqueries-label",title:ee.description||ee.name,style:{marginLeft:8,opacity:.8},children:ee.name}),ee.queries.map(ce=>{const he=$===ce.slug;return o.jsxs("button",{type:"button",className:`v10-subgraph-savedquery${he?" active":""}`,onClick:()=>he?Oe():Ot(ce),title:ce.description||ce.name,disabled:H&&!he,children:[o.jsx("span",{className:"v10-subgraph-savedquery-glyph",children:H&&he?"…":he?"✓":"◎"}),ce.name]},ce.slug)})]},ee.slug)),W&&o.jsx("span",{className:"v10-subgraph-savedquery-error",title:W,children:"✕ query failed"}),K&&$&&o.jsxs("span",{className:"v10-subgraph-savedquery-count",children:[K.size," match",K.size===1?"":"es"]})]}),y.length>0&&o.jsxs("div",{className:"v10-subgraph-filters",children:[y.map(ee=>{const ce=D.get(ee.slug)??new Set;return o.jsxs("div",{className:"v10-subgraph-filter-row",children:[o.jsx("span",{className:"v10-subgraph-filter-label",children:ee.label}),o.jsx("div",{className:"v10-subgraph-filter-chips",children:ee.values.map(he=>{const Le=ce.has(he);return o.jsx("button",{type:"button",className:`v10-subgraph-filter-chip${Le?" active":""}`,onClick:()=>xe(ee.slug,he),children:he},he)})})]},ee.slug)}),X&&o.jsx("button",{type:"button",className:"v10-subgraph-filter-reset",onClick:Z,children:"Reset filters"})]}),o.jsxs("div",{className:"v10-layer-detail-body",children:[o.jsxs("div",{className:"v10-layer-expand-tabs",children:[o.jsxs("button",{className:`v10-layer-expand-tab ${A==="items"?"active":""}`,onClick:()=>E("items"),children:["Entities (",ue.length,ue.length!==L.length?` / ${L.length}`:"",")"]}),o.jsx("button",{className:`v10-layer-expand-tab ${A==="graph"?"active":""}`,onClick:()=>E("graph"),children:"Graph"}),k&&o.jsx("button",{className:`v10-layer-expand-tab ${A==="timeline"?"active":""}`,onClick:()=>E("timeline"),children:"Timeline"}),o.jsx("button",{className:`v10-layer-expand-tab ${A==="docs"?"active":""}`,onClick:()=>E("docs"),children:"Documents"})]}),A==="items"&&o.jsx("div",{className:"v10-layer-expand-body entities-tab","data-cg-scroll-key":`subgraph:${e}:items`,children:o.jsx(Aj,{entities:qe,layerKey:"wm",layerIcon:Yt,onSelectEntity:s,externallySorted:!0,sortLabel:ke,timestampPredicate:k,perEntityTrustBadge:!0,headerExtra:o.jsxs("label",{className:"v10-entity-list-sort",children:[o.jsx("span",{className:"v10-entity-list-sort-label",children:"Sort"}),o.jsxs("select",{className:"v10-entity-list-sort-select",value:T,onChange:ee=>U(ee.target.value),"aria-label":"Sort entities",children:[k&&o.jsxs(o.Fragment,{children:[o.jsx("option",{value:"created-desc",children:"Newest first"}),o.jsx("option",{value:"created-asc",children:"Oldest first"})]}),o.jsx("option",{value:"triples",children:"Most triples"}),o.jsx("option",{value:"label",children:"Label (A→Z)"})]})]})})}),A==="graph"&&o.jsx("div",{className:"v10-layer-expand-body full-width","data-cg-scroll-key":`subgraph:${e}:graph`,children:o.jsx(Cj,{layer:ne??"wm",triples:Ee,onNodeClick:a,contextGraphId:n,title:qt,scopeLabel:`Subgraph graph: ${qt} entities and entity-to-entity triples from loaded subgraph data.`,trustLegendActiveLayer:ne,scopeEntities:We,layerEntities:Ie,nodeColorsOverride:Se})}),A==="timeline"&&k&&o.jsx("div",{className:"v10-layer-expand-body full-width",children:o.jsx(GP,{items:De,color:$t,onSelectEntity:s,scrollKey:`subgraph:${e}:timeline`})}),A==="docs"&&o.jsx("div",{className:"v10-layer-expand-body full-width",children:o.jsx(Tj,{entities:ue,contextGraphId:n,scrollKey:`subgraph:${e}:docs`})})]})]})}const WP={wm:"items",swm:"items",vm:"items"},Tw={wm:"working",swm:"shared",vm:"verified"};function Wh(e){return e==="wm"||e==="swm"||e==="vm"}function ZP(e){const t=new Set;return e.filter(n=>{const a=`${bt(n.subject)}|${n.predicate}|${bt(n.object)}`;return t.has(a)?!1:(t.add(a),!0)})}function _w(e,t){if(typeof document>"u")return t;const n=document.querySelectorAll("[data-cg-scroll-key]");for(const a of n)if(a.dataset.cgScrollKey===e)return a;return t}function KP({contextGraphId:e}){const{data:t,error:n,loading:a,refresh:s}=lr(Tn.fetchContextGraphs,[],3e4),[l,u]=w.useState(!1),[d,f]=w.useState(!1),[h,g]=w.useState("overview"),[m,y]=w.useState(null),[b,k]=w.useState({contextGraphId:null,list:[],status:"loading"}),[j,N]=w.useState(null),[S,A]=w.useState(!1),E=w.useRef(0),[T,U]=w.useState(null),[_,z]=w.useState(null),q=w.useRef(null),[D,R]=w.useState(null),$=w.useCallback(de=>{q.current=de,R(de)},[]),F=w.useRef(null),K=w.useCallback(de=>{F.current=de,de===null&&(q.current=null,R(null)),U(de)},[]),[I,H]=w.useState(null),B=w.useRef(null);w.useEffect(()=>{B.current=m},[m]);const[W,Q]=w.useState(WP),[V,L]=w.useState({}),P=w.useRef(null),G=w.useRef(null),O=w.useRef(null),ne=w.useRef(0),ue=CM(e),le=RM(e),be=fn(de=>de.openTab),{data:_e,loading:Ee,error:Ie}=zd(),We=w.useCallback(()=>T?`subgraph:${T}:${V[T]??"items"}`:Wh(h)?`layer:${h}:${W[h]}`:"page",[h,T,W,V]),Se=w.useCallback(de=>{const je=de??We(),Ae=_w(je,P.current);return{activeLayer:h,activeSubGraph:T,layerTabs:{...W},subGraphTabs:{...V},scroll:{key:je,top:(Ae==null?void 0:Ae.scrollTop)??0},subGraphEnabledLayers:T!==null&&q.current?new Set(q.current):null}},[h,T,We,W,V]),ft=w.useCallback(de=>{const je=()=>{const Ae=_w(de.key,P.current);Ae&&(Ae.scrollTop=de.top)};typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame(je):setTimeout(je,0)},[]),De=w.useCallback((de,je)=>{(!B.current||!G.current)&&(G.current=Se(je)),y(de)},[Se]),qe=w.useCallback(()=>{G.current=null},[]);w.useEffect(()=>{if(m)return;const de=O.current;de&&(O.current=null,ft(de))},[m,h,T,W,V,ft]),w.useEffect(()=>{const de=je=>{const Ae=je.detail;Ae&&Ae.contextGraphId===e&&typeof Ae.entityUri=="string"&&(H(null),De(Ae.entityUri))};return window.addEventListener("v10:open-entity",de),()=>window.removeEventListener("v10:open-entity",de)},[e,De]);const ke=w.useCallback(de=>{var tt;const je=de.startsWith("urn:dkg:agent:")?de.slice(14):de,Ae=((tt=le.get(de))==null?void 0:tt.name)??je;be({id:`agent:${e}|${je}`,label:`@ ${Ae}`,closable:!0})},[le,e,be]),lt=w.useMemo(()=>({...le,openAgent:ke}),[le,ke]),xe=w.useMemo(()=>{var de;return(de=t==null?void 0:t.contextGraphs)==null?void 0:de.find(je=>je.id===e)},[t,e]),Oe=Gg(e,{signalErrors:!0}),Ot=Zg(Oe).total,$t=M4({activeLayer:h,activeSubGraph:T}),Yt=wj($t?e:void 0),qt=!T&&h==="overview",ut=PM(qt?e:void 0),ye=qt?ut.resultContextGraphId===e?ut.events:[]:void 0,X=qt&&ut.resultContextGraphId===e?ut.error:null,Z=w.useCallback(()=>{const de=xe==null?void 0:xe.id;if(!de)return;const je=ne.current+1;ne.current=je,k({contextGraphId:de,list:[],status:"loading"}),Tn.listParticipants(de).then(Ae=>{ne.current===je&&k({contextGraphId:de,list:Ae.allowedAgents,status:"ok"})}).catch(()=>{ne.current===je&&k({contextGraphId:de,list:[],status:"error"})})},[xe==null?void 0:xe.id]);w.useEffect(()=>{Z()},[Z]);const ee=w.useCallback(()=>{const de=++E.current;Tn.fetchSubGraphs(e).then(je=>{if(E.current!==de)return;const Ae=(je.subGraphs??[]).filter(Kg).length;N(Ae),A(!1)}).catch(()=>{E.current===de&&(N(null),A(!0))})},[e]);w.useEffect(()=>{N(null),A(!1),ee()},[ee]),xo(e,ee);const ce=I?Tw[I]:null,he=w.useMemo(()=>ce?Oe.allTriples.filter(de=>de.layer===ce):Oe.graphTriples,[Oe.allTriples,Oe.graphTriples,ce]),Le=w.useMemo(()=>ce?ZP(he):he,[he,ce]),He=w.useMemo(()=>ce?nj(he):Oe.entities,[he,Oe.entities,ce]),Ce=w.useMemo(()=>m?He.get(m)??null:null,[m,He]);w.useEffect(()=>{!m||Ce||Oe.loading||(y(null),H(null),qe())},[m,Ce,Oe.loading,qe]);const Fe=w.useCallback((de,je)=>{const Ae=F.current;if(qe(),K(de),de===null)z(null);else if(je!==void 0){const tt=new Set([Tw[je]]);z(tt),q.current=tt,R(tt)}else{if(Ae!==null&&de===Ae)return;if(Ae!==null&&q.current){const tt=new Set(q.current);z(tt),q.current=tt,R(tt)}else z(null),q.current=null,R(null)}y(null),H(null)},[qe,K]),et=w.useCallback(de=>{qe(),g(de),y(null),H(null),K(null),z(null)},[qe,K]),Ne=w.useCallback((de,je)=>{Q(Ae=>Ae[de]===je?Ae:{...Ae,[de]:je})},[]),Wt=w.useCallback((de,je)=>{L(Ae=>Ae[de]===je?Ae:{...Ae,[de]:je})},[]),_t=w.useCallback((de,je,Ae)=>{const tt=B.current!=null;De(de,je),H(Je=>Ae??(tt?Je:null))},[De]),Hr=w.useCallback(()=>{const de=G.current;if(G.current=null,y(null),H(null),!!de){if(g(de.activeLayer),K(de.activeSubGraph),de.activeSubGraph!==null&&de.subGraphEnabledLayers){const je=new Set(de.subGraphEnabledLayers);z(je),q.current=je,R(je)}Q(de.layerTabs),L(de.subGraphTabs),O.current=de.scroll}},[K]),dr=w.useCallback(de=>{if(!(de!=null&&de.id))return;const je=Wh(de.trustLayer)?de.trustLayer:void 0;_t(de.id,void 0,je)},[_t]),Fa=w.useCallback(de=>{const je=Wh(h)?h:void 0;_t(de,void 0,je)},[h,_t]),Ha=w.useCallback(de=>{_t(de,"page")},[_t]),pr=w.useCallback(()=>{be(Sj)},[be]),qr=!!n&&/authentication|unauthor|expired|sign in|log in/i.test(n);if(!xe)return n||t&&!a?o.jsxs("div",{className:"v10-view-placeholder",children:[o.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:12,marginBottom:10},children:n?qr?n:"Failed to load context graph.":"Context graph not found."}),qr?o.jsx("button",{type:"button",className:"v10-retry-btn",onClick:()=>window.location.reload(),children:"Refresh page"}):o.jsx("button",{type:"button",className:"v10-retry-btn",onClick:s,children:"Retry"})]}):o.jsx("div",{className:"v10-view-placeholder",children:o.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:12},children:"Loading context graph..."})});const ca=T?ue.forSubGraph(T):null,qa=!Oe.loading&&!Oe.error&&!Oe.partial?Oe.entityList:void 0,Ci=Ce?"entity":T?"subgraph":h,ge=b.contextGraphId===xe.id?b.list:[],Me=b.contextGraphId===xe.id?b.status:"loading";return o.jsx(yj.Provider,{value:ue,children:o.jsx(xj.Provider,{value:lt,children:o.jsxs("div",{className:"v10-memory-explorer",children:[n&&o.jsx("div",{className:"v10-stale-banner",role:"status",children:qr?o.jsxs(o.Fragment,{children:[o.jsx("span",{children:n}),o.jsx("button",{type:"button",className:"v10-retry-btn",onClick:()=>window.location.reload(),children:"Refresh page"})]}):o.jsxs(o.Fragment,{children:[o.jsx("span",{children:"Couldn’t refresh context-graph data — showing last known values."}),o.jsx("button",{type:"button",className:"v10-retry-btn",onClick:s,children:"Retry"})]})}),o.jsx(bD,{cg:xe,profile:ue,activeSubGraph:ca,onClearSubGraph:()=>Fe(null)}),o.jsx(yD,{active:h,counts:Oe.counts,onSwitch:et,onShare:()=>f(!0),onImport:()=>u(!0),onRefresh:Oe.refresh}),o.jsxs("main",{className:"v10-memory-explorer-page","data-view":Ci,"data-cg-scroll-key":"page",ref:P,children:[Ce&&o.jsx(FP,{entity:Ce,allEntities:He,allTriples:Le,onNavigate:_t,onClose:Hr,contextGraphId:e,onRefresh:Oe.refresh}),T&&!Ce&&o.jsxs(o.Fragment,{children:[o.jsx(Ew,{}),o.jsx(zh,{contextGraphId:e,profile:ue,selected:T,entities:qa,onSelect:Fe,enabledScope:D??void 0,allTriplesTotal:Ot}),o.jsx(VP,{slug:T,rawMemory:Oe,contextGraphId:e,onNodeClick:dr,onSelectEntity:_t,activeTab:V[T]??"items",onTabChange:de=>Wt(T,de),initialEnabledLayers:_??void 0,onEnabledLayersChange:$})]}),!T&&h==="overview"&&!Ce&&o.jsxs(o.Fragment,{children:[o.jsx(CD,{cg:xe,memory:Oe,subGraphCount:j,subGraphFetchFailed:S,participants:ge,participantsStatus:Me,currentAgent:_e??null,currentAgentStatus:Ee?"loading":Ie?"error":"ok",onSwitchLayer:et,onOpenPrimer:pr}),o.jsx(ND,{contextGraphId:e,curatorStatus:SD({cg:xe,currentAgent:_e??null,currentAgentStatus:Ee?"loading":Ie?"error":"ok"}),onParticipantsChanged:Z}),Oe.loading&&o.jsx("div",{className:"v10-me-loading",children:o.jsx("div",{className:"v10-me-loading-text",children:"Loading memory..."})}),Oe.error&&o.jsxs("div",{className:"v10-me-error",children:["Error: ",Oe.error]}),o.jsx("div",{"data-section":"activity",children:o.jsx(aD,{entities:Oe.entityList,lifecycleEvents:ye,lifecycleError:X,onSelectEntity:Ha,title:"Recent activity",limit:40,includeUndated:!1,emptyHint:"Once knowledge starts being added and managed in this context graph, activities will show up here as a live feed.",className:"v10-overview-activity"})}),o.jsx(ED,{onOpenPrimer:pr})]}),!T&&h==="graph-overview"&&!Ce&&o.jsxs(o.Fragment,{children:[o.jsx(Ew,{}),o.jsx(zh,{contextGraphId:e,profile:ue,selected:null,entities:qa,onSelect:Fe,allTriplesTotal:Ot}),o.jsx(qP,{contextGraphId:e,memory:Oe,onNodeClick:dr,onSelectSubGraph:Fe})]}),!T&&h==="query"&&!Ce&&o.jsx(az,{contextGraphId:e}),!T&&(h==="wm"||h==="swm"||h==="vm")&&!Ce&&o.jsxs(o.Fragment,{children:[o.jsx(zh,{contextGraphId:e,profile:ue,selected:T,entities:qa,onSelect:Fe,layer:h}),o.jsx(GD,{layer:h,memory:Oe,onNodeClick:dr,onSelectEntity:Fa,contextGraphId:e,activeTab:W[h],onTabChange:de=>Ne(h,de),swmAttribution:Yt})]})]}),o.jsx(dM,{open:l,onClose:()=>u(!1),contextGraphId:xe.id,contextGraphName:xe.name}),o.jsx(fM,{open:d,onClose:()=>f(!1),contextGraphId:xe.id,contextGraphName:xe.name})]})})})}const YP=[{title:"Memory layers",body:"Working Memory is private staging, Shared Working Memory is the collaborative review layer, and Verifiable Memory is the published on-chain layer. Counts show where entities live now."},{title:"Subgraphs",body:"Subgraphs organize the same Context Graph by topic or source. They cut across memory layers, so a subgraph can contain Working, Shared Working, and Verifiable Memory at the same time."},{title:"Entities and Knowledge Assets",body:"Working Memory and Shared Working Memory contain entities. When published, an assertion/triple bundle is anchored as a Knowledge Asset in Verifiable Memory, giving included entities on-chain provenance."},{title:"Assertions",body:"Assertions are batches of triples that explain how entities entered or moved through the Context Graph. They are useful for reviewing provenance and lifecycle state."},{title:"Roles",body:"A curator controls access and publication policy. A participant can collaborate inside the Context Graph according to that policy."}];function QP(){const e=fn(n=>n.closeTab),t=Ve.useCallback(()=>e(Xg),[e]);return Ve.useEffect(()=>{const n=a=>{a.key==="Escape"&&(a.preventDefault(),t())};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[t]),o.jsxs("div",{className:"v10-primer-view",children:[o.jsxs("header",{className:"v10-primer-header",children:[o.jsx("button",{type:"button",className:"v10-primer-back",onClick:t,"aria-label":"Close primer and return to the previous tab",children:"← Back"}),o.jsx("p",{className:"v10-primer-kicker",children:"Context Graph Primer"}),o.jsx("h1",{children:"What is a Context Graph?"}),o.jsx("p",{children:"A Context Graph is a shared knowledge workspace where agents stage, review, organize, and publish structured memory."})]}),o.jsxs("section",{className:"v10-primer-pipeline","aria-label":"Context Graph pipeline",children:[o.jsx("span",{className:"wm",children:"Working Memory"}),o.jsx("span",{className:"connector","aria-hidden":"true"}),o.jsx("span",{className:"swm",children:"Shared Working Memory"}),o.jsx("span",{className:"connector","aria-hidden":"true"}),o.jsx("span",{className:"vm",children:"Verifiable Memory"})]}),o.jsx("div",{className:"v10-primer-sections",children:YP.map(n=>o.jsxs("section",{className:"v10-primer-section",children:[o.jsx("h2",{children:n.title}),o.jsx("p",{children:n.body})]},n.title))})]})}const XP={"application/pdf":"pdf","application/json":"text","text/plain":"text","text/csv":"text","text/markdown":"markdown","image/png":"image","image/jpeg":"image","image/gif":"image","image/webp":"image"};function Rw(e){const t=XP[e];return t?t==="markdown"?"text":t:"binary"}async function Ow(e){const t=await fetch(e,{headers:Ft()});if(!t.ok)throw new Error(`HTTP ${t.status}`);const n=await t.blob();return URL.createObjectURL(n)}function JP({open:e,onClose:t,assertionName:n,contextGraphId:a,subGraphName:s}){const[l,u]=w.useState(null),[d,f]=w.useState(null),[h,g]=w.useState(null),[m,y]=w.useState(!0),[b,k]=w.useState(null);w.useEffect(()=>{if(e)return y(!0),k(null),u(null),f(null),g(null),E_(n,a,s).then(async T=>{u(T);const U=Rw(T.detectedContentType),_=Vu(T.fileHash,T.detectedContentType);if(U==="text"){const z=await fetch(_,{headers:Ft()});z.ok&&f(await z.text())}else if(U==="pdf"||U==="image"){const z=await Ow(_);g(z)}}).catch(T=>k(T.message??"Failed to load file info")).finally(()=>y(!1)),()=>{h&&URL.revokeObjectURL(h)}},[e,n,a,s]),w.useEffect(()=>()=>{h&&URL.revokeObjectURL(h)},[h]);const{dialogRef:j,onBackdropClick:N}=Ji(e,t);if(!e)return null;const S=l?Rw(l.detectedContentType):null,A=l?Vu(l.fileHash,l.detectedContentType):null,E=async(T,U)=>{try{const _=await Ow(T),z=document.createElement("a");z.href=_,z.download=U,z.click(),URL.revokeObjectURL(_)}catch{window.open(T,"_blank")}};return o.jsx("div",{className:"v10-modal-overlay",onClick:N,role:"presentation",children:o.jsxs("div",{className:"v10-modal-box v10-file-preview-modal",ref:j,role:"dialog","aria-modal":"true","aria-labelledby":"dkg-file-preview-title",children:[o.jsxs("div",{className:"v10-modal-header",children:[o.jsx("div",{id:"dkg-file-preview-title",className:"v10-modal-title",children:n}),o.jsx("button",{type:"button",className:"v10-modal-close",onClick:t,"aria-label":"Close file preview",title:"Close (Esc)",children:"×"})]}),m&&o.jsx("div",{className:"v10-file-preview-loading",children:"Loading file preview..."}),b&&o.jsxs("div",{className:"v10-file-preview-error",children:[o.jsx("p",{children:b}),o.jsx("p",{style:{fontSize:11,marginTop:4},children:"File preview requires the extraction status to still be cached on the node. If the node was restarted, the preview metadata may be unavailable."})]}),l&&!m&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"v10-file-preview-meta",children:[o.jsx("span",{className:"v10-file-preview-meta-item",children:l.detectedContentType}),o.jsxs("span",{className:"v10-file-preview-meta-item",children:[l.tripleCount," triples extracted"]}),o.jsx("span",{className:"v10-file-preview-meta-item",children:l.pipelineUsed}),l.completedAt&&o.jsx("span",{className:"v10-file-preview-meta-item",children:new Date(l.completedAt).toLocaleString()})]}),o.jsxs("div",{className:"v10-file-preview-content",children:[S==="pdf"&&h&&o.jsx("iframe",{src:h,className:"v10-file-preview-iframe",title:`Preview: ${n}`}),S==="image"&&h&&o.jsx("img",{src:h,alt:n,className:"v10-file-preview-image"}),S==="text"&&d!=null&&o.jsx("pre",{className:"v10-file-preview-text",children:d}),S==="binary"&&o.jsxs("div",{className:"v10-file-preview-binary",children:[o.jsx("p",{children:"This file type cannot be previewed directly."}),A&&o.jsx("button",{className:"v10-file-preview-download",onClick:()=>E(A,n),children:"Download file"})]})]}),o.jsxs("div",{className:"v10-file-preview-footer",children:[A&&o.jsx("button",{className:"v10-file-preview-download",onClick:()=>E(A,n),children:"Download original"}),l.mdIntermediateHash&&o.jsx("button",{className:"v10-file-preview-download",onClick:()=>E(Vu(l.mdIntermediateHash,"text/markdown"),`${n}.md`),children:"Download markdown intermediate"})]})]})]})})}const e5=w.lazy(()=>gt(()=>import("./index-CwRQnNYh.js").then(e=>e.h),__vite__mapDeps([0,1])).then(e=>({default:e.RdfGraph}))),t5=w.lazy(()=>gt(()=>import("./index-CwRQnNYh.js").then(e=>e.h),__vite__mapDeps([0,1])).then(e=>({default:e.NodePanel}))),n5=w.lazy(()=>gt(()=>import("./OnChainProvenanceCard-Dn_IEP7Q.js"),__vite__mapDeps([2,0,1])).then(e=>({default:e.OnChainProvenanceCard}))),r5={wm:{label:"Working Memory",color:"var(--layer-working)",icon:"◇",description:"Private agent drafts. Fast local storage."},swm:{label:"Shared Working Memory",color:"var(--layer-shared)",icon:"◈",description:"Shared proposals with collaborators. TTL-bounded."},vm:{label:"Verifiable Memory",color:"var(--layer-verified)",icon:"◉",description:"Endorsed, published, on-chain knowledge."}},a5={labelMode:"humanized",renderer:"2d",labels:Id({extraPredicates:["http://schema.org/text"]}),style:{classColors:{"http://schema.org/Person":"#f472b6","http://schema.org/Organization":"#fb923c","http://schema.org/Place":"#34d399","http://schema.org/Product":"#c084fc","http://schema.org/Event":"#facc15","http://schema.org/CreativeWork":"#7dd3fc","http://schema.org/Thing":"#94a3b8"},defaultNodeColor:"#94a3b8",defaultEdgeColor:"#5f8598",edgeWidth:.9},hexagon:{baseSize:4,minSize:3,maxSize:6,scaleWithDegree:!0},focus:{maxNodes:3e3,hops:999}},i5=o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),o.jsx("line",{x1:"3",y1:"9",x2:"21",y2:"9"}),o.jsx("line",{x1:"3",y1:"15",x2:"21",y2:"15"}),o.jsx("line",{x1:"9",y1:"3",x2:"9",y2:"21"})]}),s5=o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("circle",{cx:"6",cy:"6",r:"3"}),o.jsx("circle",{cx:"18",cy:"6",r:"3"}),o.jsx("circle",{cx:"6",cy:"18",r:"3"}),o.jsx("circle",{cx:"18",cy:"18",r:"3"}),o.jsx("line",{x1:"8.5",y1:"7.5",x2:"15.5",y2:"16.5"}),o.jsx("line",{x1:"15.5",y1:"7.5",x2:"8.5",y2:"16.5"})]});function Zh({layer:e,contextGraphId:t,externalQuery:n,externalQueryKey:a,queryPresetOptions:s}){var Ie,We;const l=r5[e],[u,d]=w.useState("graph"),[f,h]=w.useState(""),[g,m]=w.useState(""),[y,b]=w.useState(""),[k,j]=w.useState(""),[N,S]=w.useState("any"),[A,E]=w.useState(50),[T,U]=w.useState(""),[_,z]=w.useState("any"),[q,D]=w.useState(50),[R,$]=w.useState(e!=="vm"),F=Ve.useRef(e);Ve.useEffect(()=>{F.current!==e&&(F.current=e,h(""),$(e!=="vm"),m(""),b(""),j(""),S("any"),E(50),U(""),z("any"),D(50))},[e]),Ve.useEffect(()=>{n!==void 0&&(h(""),m(n),b(n))},[n,a]);const K=w.useMemo(()=>e==="wm"?`SELECT ?s ?p ?o WHERE { GRAPH <${`did:dkg:context-graph:${t}/_meta`}> { ?g <http://dkg.io/ontology/memoryLayer> "WM" } GRAPH ?g { ?s ?p ?o } FILTER(!CONTAINS(STR(?g), "/meta/assertion/")) } LIMIT 1000`:e==="vm"?c5({query:T,field:_,limit:q}):"SELECT ?s ?p ?o WHERE { ?s ?p ?o } LIMIT 500",[t,e,_,q,T]),I=y||K,H=e==="swm"?"_shared_memory":void 0,B=e==="swm",W=e==="vm"?"verifiable-memory":void 0,Q=e==="wm"&&I===K,{data:V,loading:L,error:P,refresh:G}=lr(()=>or(I,t,B,H,W,Q),[I,t,B,H,W,Q],0);xo(t,G,{layers:[e]});const{data:O}=lr(jg,[],3e4),ne=O==null?void 0:O.blockExplorerUrl,ue=w.useCallback(()=>{const Se=g.trim();if(Se===y){G();return}b(Se)},[y,g,G]),le=w.useCallback(()=>{const Se=k!==T||N!==_||A!==q;if(Se&&(U(k),z(N),D(A)),y){b("");return}Se||G()},[y,_,q,T,N,A,k,G]),be=((Ie=V==null?void 0:V.result)==null?void 0:Ie.bindings)??((We=V==null?void 0:V.results)==null?void 0:We.bindings)??[],_e=w.useMemo(()=>be.map(Se=>({subject:Ys(Se.s)??"",predicate:Ys(Se.p)??"",object:Ys(Se.o)??""})).filter(Se=>Se.subject&&Se.predicate&&Se.object),[be]),Ee=w.useCallback(Se=>{Se!=null&&Se.id&&b(`SELECT (<${Se.id}> AS ?s) ?p ?o WHERE { <${Se.id}> ?p ?o } LIMIT 100`)},[]);return o.jsxs("div",{className:"v10-memory-layer-view",children:[o.jsxs("div",{className:"v10-mlv-header",children:[o.jsx("span",{className:"v10-mlv-icon",style:{color:l.color},children:l.icon}),o.jsxs("div",{children:[o.jsx("h2",{className:"v10-mlv-title",children:l.label}),o.jsx("p",{className:"v10-mlv-desc",children:l.description})]})]}),e==="wm"&&o.jsx(o5,{contextGraphId:t,onPromoted:G}),e==="swm"&&o.jsx(l5,{contextGraphId:t,onPublished:G}),e==="vm"&&o.jsxs("div",{className:"v10-vm-search-panel",children:[o.jsxs("div",{className:"v10-vm-search-header",children:[o.jsxs("div",{children:[o.jsx("div",{className:"v10-vm-search-title",children:"Search Verifiable Memory"}),o.jsx("div",{className:"v10-vm-search-desc",children:"Search published triples by subject, predicate, object, or across all fields."})]}),o.jsx("button",{className:"v10-vm-search-toggle",type:"button",onClick:()=>$(Se=>!Se),children:R?"Hide SPARQL":"Advanced SPARQL"})]}),o.jsxs("div",{className:"v10-vm-search-controls",children:[o.jsx("input",{type:"text",className:"v10-mlv-query-input",placeholder:"Search verifiable memory...",value:k,onChange:Se=>j(Se.target.value),onKeyDown:Se=>{Se.key==="Enter"&&le()}}),o.jsxs("select",{className:"v10-vm-search-select",value:N,onChange:Se=>S(Se.target.value),children:[o.jsx("option",{value:"any",children:"Any field"}),o.jsx("option",{value:"subject",children:"Subject"}),o.jsx("option",{value:"predicate",children:"Predicate"}),o.jsx("option",{value:"object",children:"Object"})]}),o.jsxs("select",{className:"v10-vm-search-select",value:String(A),onChange:Se=>E(Number.parseInt(Se.target.value,10)||50),children:[o.jsx("option",{value:"25",children:"25 rows"}),o.jsx("option",{value:"50",children:"50 rows"}),o.jsx("option",{value:"100",children:"100 rows"}),o.jsx("option",{value:"200",children:"200 rows"})]}),o.jsx("button",{className:"v10-mlv-run-btn",onClick:le,children:"Search"})]})]}),(e!=="vm"||R)&&o.jsxs("div",{className:"v10-mlv-query-bar",children:[s!=null&&s.length?o.jsxs("select",{className:"v10-vm-search-select",value:f,onChange:Se=>{const ft=Se.target.value;h(ft);const De=s.find(ke=>ke.label===ft),qe=(De==null?void 0:De.query)??"";m(qe),b(qe)},children:[o.jsx("option",{value:"",children:"Select common query..."}),s.map(Se=>o.jsx("option",{value:Se.label,children:Se.label},Se.label))]}):o.jsx("input",{type:"text",className:"v10-mlv-query-input",placeholder:"Custom SPARQL query...",value:g,onChange:Se=>m(Se.target.value),onKeyDown:Se=>{Se.key==="Enter"&&ue()}}),o.jsx("button",{className:"v10-mlv-run-btn",onClick:ue,children:"Run"}),y&&o.jsx("button",{className:"v10-mlv-clear-btn",onClick:()=>b(""),title:"Reset to full layer overview",children:"Reset"}),o.jsxs("div",{className:"v10-mlv-view-toggle",children:[o.jsx("button",{className:`v10-mlv-toggle-btn ${u==="table"?"active":""}`,onClick:()=>d("table"),title:"Table view",children:i5}),o.jsx("button",{className:`v10-mlv-toggle-btn ${u==="graph"?"active":""}`,onClick:()=>d("graph"),title:"Graph view",children:s5})]})]}),L&&o.jsx("p",{className:"v10-mlv-status",children:"Loading..."}),P&&o.jsxs("p",{className:"v10-mlv-status",style:{color:"var(--accent-red)"},children:["Error: ",P]}),!L&&be.length===0&&o.jsxs("div",{className:"v10-mlv-empty",children:[o.jsxs("p",{children:["No triples found in ",l.label.toLowerCase(),"."]}),o.jsxs("p",{style:{fontSize:11,marginTop:4},children:[e==="wm"&&"Import files or chat with your agent to generate working memory.",e==="swm"&&"Promote assertions from working memory to share with collaborators.",e==="vm"&&"Publish shared memory to create verified on-chain knowledge."]})]}),!L&&be.length>0&&u==="table"&&o.jsxs("div",{className:"v10-mlv-table-wrap",children:[o.jsxs("div",{className:"v10-mlv-result-count",children:[be.length," triples"]}),o.jsxs("table",{className:"v10-mlv-table",children:[o.jsx("thead",{children:o.jsxs("tr",{children:[o.jsx("th",{children:"Subject"}),o.jsx("th",{children:"Predicate"}),o.jsx("th",{children:"Object"})]})}),o.jsx("tbody",{children:be.map((Se,ft)=>o.jsxs("tr",{children:[o.jsx("td",{className:"v10-mlv-cell",children:Kh(Ys(Se.s))}),o.jsx("td",{className:"v10-mlv-cell",children:Kh(Ys(Se.p))}),o.jsx("td",{className:"v10-mlv-cell",children:Kh(Ys(Se.o))})]},ft))})]})]}),!L&&_e.length>0&&u==="graph"&&o.jsxs("div",{className:"v10-mlv-graph-container",children:[o.jsxs("div",{className:"v10-mlv-graph-info",children:[o.jsxs("span",{children:[_e.length," triples"]}),y&&o.jsx("span",{className:"v10-mlv-graph-info-custom",children:"filtered"})]}),o.jsx(w.Suspense,{fallback:o.jsx("div",{className:"v10-mlv-graph-loading",children:"Loading graph renderer..."}),children:o.jsxs(e5,{data:_e,format:"triples",options:a5,style:{width:"100%",height:"100%"},onNodeClick:Ee,initialFit:!0,children:[o.jsx(t5,{className:"v10-mlv-node-panel",showUri:!0,showTypes:!0,showProperties:!0,showMetadata:!1,maxValueLength:150}),o.jsx(n5,{contextGraphId:t,layer:e,explorerUrl:ne})]})})]})]})}function o5({contextGraphId:e,onPromoted:t}){const{data:n,loading:a,refresh:s}=lr(()=>Ql(e,"wm"),[e],0);xo(e,s,{layers:["wm"]});const[l,u]=w.useState(null),[d,f]=w.useState(null),[h,g]=w.useState(null),[m,y]=w.useState(null),b=w.useCallback(async j=>{u(j.graphUri),f(null),g(null);try{const N=await lo(e,j.name,j.subGraph?{subGraphName:j.subGraph}:{}),S=_g(j.name,N);f({message:S.message+(j.subGraph?` (in ${j.subGraph})`:""),kind:S.kind==="success"?"success":"noop",subGraph:j.subGraph}),s(),t()}catch(N){const S=co(j.name,N);g(S?{message:S.message,kind:"not-persisted"}:{message:(N==null?void 0:N.message)??"Promote failed",kind:"other"})}finally{u(null)}},[e,s,t]),k=w.useCallback(async()=>{if(!(n!=null&&n.length))return;u("__all__"),f(null),g(null);let j=0,N=null;try{for(const E of n)N=E.name,(await lo(e,E.name,E.subGraph?{subGraphName:E.subGraph}:{})).promotedCount===0&&(j+=1);const S=n.length-j,A=j>0?` (${j} already shared or still committing)`:"";f({message:S>0?`Shared ${S} complete Knowledge Asset${S===1?"":"s"} to Shared Working Memory${A}.`:"No Knowledge Assets were newly shared — all were already in Shared Working Memory or still committing.",kind:S>0?"success":"noop"}),s(),t()}catch(S){const A=co(N??"selected assertion",S);g(A?{message:A.message,kind:"not-persisted"}:{message:(S==null?void 0:S.message)??"Promote failed",kind:"other"})}finally{u(null)}},[n,e,s,t]);return a?o.jsx("div",{className:"v10-assertion-list-loading",children:"Loading assertions..."}):n!=null&&n.length?o.jsxs("div",{className:"v10-assertion-list",children:[o.jsxs("div",{className:"v10-assertion-list-header",children:[o.jsxs("span",{className:"v10-assertion-list-title",children:["Assertions in Working Memory (",n.length,")"]}),o.jsx("button",{className:"v10-btn-promote-all",disabled:l!==null,onClick:k,children:l==="__all__"?"Sharing...":"Share Complete KAs → SWM"})]}),o.jsx("div",{className:"v10-assertion-items",children:n.map(j=>o.jsxs("div",{className:"v10-assertion-item",children:[o.jsxs("div",{className:"v10-assertion-item-info",children:[o.jsx("button",{className:"v10-assertion-item-name clickable",title:j.graphUri,onClick:()=>y({name:j.name,subGraph:j.subGraph}),children:j.name}),j.tripleCount!=null&&o.jsxs("span",{className:"v10-assertion-item-count",children:[j.tripleCount," triples"]}),j.subGraph&&o.jsxs("span",{className:"v10-item-count v10-item-subgraph",title:`In sub-graph: ${j.subGraph}`,children:["› ",nv(j.subGraph,18)]})]}),o.jsx("button",{className:"v10-btn-promote",disabled:l!==null,onClick:()=>b(j),title:"Share this complete Knowledge Asset to Shared Working Memory",children:l===j.graphUri?"Promoting...":"→ SWM"})]},j.graphUri))}),d&&o.jsx("div",{className:d.kind==="success"?"v10-promote-result success":"v10-promote-result info",children:d.message}),h&&o.jsx("div",{className:"v10-promote-result error",children:h.message}),m&&o.jsx(JP,{open:!0,onClose:()=>y(null),assertionName:m.name,subGraphName:m.subGraph,contextGraphId:e})]}):null}function l5({contextGraphId:e,onPublished:t}){const{data:n,loading:a,refresh:s}=lr(()=>Ql(e,"swm"),[e],0);xo(e,s,{layers:["swm"]});const[l,u]=w.useState(new Set),[d,f]=w.useState(!1),[h,g]=w.useState(null),[m,y]=w.useState(null),b=(n==null?void 0:n.map(z=>z.graphUri))??[],k=b.length>0&&b.every(z=>l.has(z)),j=w.useCallback(z=>{u(q=>{const D=new Set(q);return D.has(z)?D.delete(z):D.add(z),D})},[]),N=w.useCallback(()=>{u(k?new Set:new Set(b))},[k,b]),S=w.useCallback(async z=>{if(z.length!==0){f(!0),g(null),y(null);try{g(await Tg(e,z)),u(new Set),s(),t()}catch(q){y((q==null?void 0:q.message)??"Publish failed")}finally{f(!1)}}},[e,s,t]),A=w.useCallback(()=>{const z=(n??[]).filter(q=>l.has(q.graphUri));return S(z)},[n,l,S]),E=w.useCallback(()=>S(n??[]),[n,S]),T=(n==null?void 0:n.reduce((z,q)=>z+(q.tripleCount??0),0))??0,U=(n==null?void 0:n.filter(z=>l.has(z.graphUri)).reduce((z,q)=>z+(q.tripleCount??0),0))??0,_=!a&&(!n||n.length===0);return a?o.jsx("div",{className:"v10-assertion-list-loading",children:"Loading SWM contents..."}):_?o.jsxs("div",{className:"v10-publish-panel",children:[o.jsx("div",{className:"v10-publish-panel-header",children:o.jsx("span",{className:"v10-publish-panel-title",children:"Publish to Verifiable Memory"})}),o.jsx("div",{className:"v10-publish-panel-empty",children:"No data in Shared Working Memory yet. Promote assertions from Working Memory first."})]}):o.jsxs("div",{className:"v10-publish-panel",children:[o.jsxs("div",{className:"v10-publish-panel-header",children:[o.jsxs("span",{className:"v10-publish-panel-title",children:["Knowledge assets in Shared Working Memory (",n.length," asset",n.length===1?"":"s"," · ",T," triples)"]}),o.jsxs("div",{className:"v10-publish-panel-header-actions",children:[o.jsx("button",{className:"v10-publish-panel-refresh",onClick:s,title:"Refresh",children:"↻"}),o.jsx("button",{className:"v10-btn-promote-all",disabled:d,onClick:E,children:d&&l.size===0?"Publishing...":"Publish All → VM"})]})]}),o.jsxs("div",{className:"v10-publish-select-bar",children:[o.jsxs("label",{className:"v10-publish-select-all",children:[o.jsx("input",{type:"checkbox",checked:k,onChange:N}),o.jsx("span",{children:"Select all"})]}),l.size>0&&o.jsx("button",{className:"v10-btn-publish",disabled:d,onClick:A,children:d?"Publishing...":`Publish ${l.size} selected (${U} triples) → VM`})]}),o.jsx("div",{className:"v10-assertion-items",children:n.map(z=>o.jsxs("div",{className:`v10-assertion-item ${l.has(z.graphUri)?"selected":""}`,children:[o.jsx("label",{className:"v10-publish-entity-check",children:o.jsx("input",{type:"checkbox",checked:l.has(z.graphUri),onChange:()=>j(z.graphUri)})}),o.jsxs("div",{className:"v10-assertion-item-info",children:[o.jsx("span",{className:"v10-assertion-item-name",title:z.graphUri,children:z.name}),z.subGraph&&o.jsxs("span",{className:"v10-item-count v10-item-subgraph",title:`In sub-graph: ${z.subGraph}`,children:["› ",nv(z.subGraph,18)]}),z.tripleCount!=null&&o.jsxs("span",{className:"v10-assertion-item-count",children:[z.tripleCount," triples"]})]})]},z.graphUri))}),h&&(()=>{const{published:z,total:q,partial:D,partialError:R,failures:$,sample:F,convictionCostCovered:K}=h,I=z===q&&z>0&&D===0,H=(F==null?void 0:F.status)==="confirmed"&&!!F.txHash;return o.jsxs("div",{className:`v10-publish-result-card ${I?"success":"error"}`,children:[o.jsx("div",{className:"v10-publish-result-title",children:z>0?`Published ${z} of ${q} knowledge asset${q===1?"":"s"} to Verifiable Memory`:"NOT published to Verifiable Memory"}),D>0&&o.jsxs("div",{className:"v10-publish-result-details",style:{marginBottom:6},children:["⚠ ",D," asset",D===1?"":"s",": ",Il(R)]}),$.length>0&&o.jsxs("div",{className:"v10-publish-result-details",style:{marginBottom:6},children:[$.length," asset",$.length===1?"":"s"," could not be published — ",$[0].name,": ",$[0].error,$.length>1?` (+${$.length-1} more)`:""]}),o.jsxs("div",{className:"v10-publish-result-details",children:[(F==null?void 0:F.kaId)!=null&&o.jsxs("div",{children:[o.jsx("span",{className:"v10-publish-result-label",children:"Knowledge Asset:"})," ",F.kaId]}),H?o.jsxs("div",{className:"v10-publish-result-tx",children:[o.jsx("span",{className:"v10-publish-result-label",children:"Tx hash:"})," ",o.jsx("span",{className:"mono",title:F.txHash,children:F.txHash}),F.blockNumber!=null&&o.jsxs("span",{className:"v10-publish-result-block",children:[" (block ",F.blockNumber,")"]})]}):o.jsxs("div",{className:"v10-publish-result-details",children:["Verifiable Memory requires a confirmed ",o.jsx("code",{children:"KCCreated"})," event. If a publish did not land on-chain, check the node logs (typically a missing publisher wallet, an unfunded signer, or a chain adapter that isn't V10-ready)."]}),o.jsx(WS,{convictionCostCovered:K})]})]})})(),m&&o.jsx("div",{className:"v10-publish-result-card error",children:m})]})}function Ys(e){if(e!=null)return typeof e=="string"?e:typeof e=="object"&&"value"in e?String(e.value):String(e)}function Kh(e){if(!e)return"—";const t=e.lastIndexOf("#"),n=e.lastIndexOf("/"),a=Math.max(t,n);return a>=0?e.slice(a+1):e}function c5(e){const t=Number.isFinite(e.limit)&&e.limit>0?Math.floor(e.limit):50,n=e.query.trim();if(!n)return`SELECT ?s ?p ?o WHERE { ?s ?p ?o } LIMIT ${t}`;const a=u5(n.toLowerCase()),s={subject:`CONTAINS(LCASE(STR(?s)), "${a}")`,predicate:`CONTAINS(LCASE(STR(?p)), "${a}")`,object:`CONTAINS(LCASE(STR(?o)), "${a}")`};return`SELECT ?s ?p ?o WHERE { ?s ?p ?o . FILTER(${e.field==="any"?`(${s.subject} || ${s.predicate} || ${s.object})`:s[e.field]}) } LIMIT ${t}`}function u5(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r")}const kC=[{key:"working",title:"Working Memory",short:"WM",icon:"◇",color:"#64748b",desc:"Private agent drafts",tabPrefix:"wm"},{key:"shared",title:"Shared Working Memory",short:"SWM",icon:"◈",color:"#f59e0b",desc:"Team proposals",tabPrefix:"swm"},{key:"verified",title:"Verifiable Memory",short:"VM",icon:"◉",color:"#22c55e",desc:"On-chain knowledge",tabPrefix:"vm"}],d5=["http://purl.org/dc/terms/created","http://dkg.io/ontology/github/mergedAt","http://dkg.io/ontology/github/closedAt","http://dkg.io/ontology/decisions/date","http://dkg.io/ontology/tasks/dueDate"];function p5(){const{contextGraphs:e}=Tr(),{hidden:t}=Fg(),n=w.useMemo(()=>e.filter(a=>!t.has(a.id)),[e,t]);return o.jsxs("div",{className:"v10-memstack",children:[o.jsxs("div",{className:"v10-memstack-head",children:[o.jsx("h1",{className:"v10-memstack-title",children:"Memory Stack"}),o.jsxs("p",{className:"v10-memstack-sub",children:["Every layer across every context graph, at a glance. ",n.length," visible context graph",n.length===1?"":"s"," · hidden context graphs are skipped."]})]}),n.length===0?o.jsx("div",{className:"v10-memstack-empty",children:"No visible context graphs. Create one from the sidebar or un-hide dismissed ones."}):o.jsxs("div",{className:"v10-memstack-table",children:[o.jsxs("div",{className:"v10-memstack-colheads",children:[o.jsx("div",{className:"v10-memstack-colhead project"}),kC.map(a=>o.jsxs("div",{className:"v10-memstack-colhead",style:{color:a.color},children:[o.jsx("span",{className:"v10-memstack-colhead-icon",children:a.icon}),o.jsx("span",{className:"v10-memstack-colhead-title",children:a.title}),o.jsx("span",{className:"v10-memstack-colhead-desc",children:a.desc})]},a.key))]}),n.map(a=>o.jsx(f5,{cg:a},a.id))]})]})}function f5({cg:e}){const t=Gg(e.id),{openTab:n}=fn(),a=gj(t),s=w.useMemo(()=>{const u={working:{entities:[],tripleCount:a.wm},shared:{entities:[],tripleCount:a.swm},verified:{entities:[],tripleCount:a.vm}};for(const d of t.entityList)u[d.trustLevel].entities.push(d);for(const d of Object.keys(u))u[d].entities.sort((f,h)=>{const g=Gm(f),m=Gm(h);return g&&m?m-g:g?-1:m?1:f.label.localeCompare(h.label)});return u},[t.entityList,a]),l=()=>n({id:`project:${e.id}`,label:e.name||e.id.slice(0,16),closable:!0});return o.jsxs("div",{className:"v10-memstack-row",children:[o.jsxs("div",{className:"v10-memstack-project",children:[o.jsxs("button",{type:"button",className:"v10-memstack-project-btn",onClick:l,children:[o.jsx("span",{className:"v10-memstack-project-dot"}),o.jsx("span",{className:"v10-memstack-project-name",children:e.name||e.id})]}),e.description&&o.jsx("div",{className:"v10-memstack-project-desc",title:e.description,children:e.description}),t.loading&&!t.entityList.length&&o.jsx("div",{className:"v10-memstack-project-status",children:"loading…"}),t.error&&o.jsx("div",{className:"v10-memstack-project-status error",children:t.error})]}),kC.map(u=>{const d=s[u.key];return o.jsx(h5,{cgId:e.id,color:u.color,layerTitle:u.title,tabPrefix:u.tabPrefix,entityCount:d.entities.length,tripleCount:d.tripleCount,recent:d.entities.slice(0,4),onOpenLayer:()=>n({id:`${u.tabPrefix}:${e.id}`,label:`${u.short} · ${e.name||e.id.slice(0,12)}`,closable:!0})},u.key)})]})}function h5({cgId:e,color:t,layerTitle:n,tabPrefix:a,entityCount:s,tripleCount:l,recent:u,onOpenLayer:d}){const f=s===0;return o.jsxs("div",{className:`v10-memstack-cell${f?" empty":""}`,style:{"--cell-color":t},children:[o.jsxs("div",{className:"v10-memstack-cell-stats",children:[o.jsx("span",{className:"v10-memstack-cell-n",children:s}),o.jsxs("span",{className:"v10-memstack-cell-n-lbl",children:["entit",s===1?"y":"ies"]}),o.jsx("span",{className:"v10-memstack-cell-sep",children:"·"}),o.jsx("span",{className:"v10-memstack-cell-t",children:l.toLocaleString()}),o.jsx("span",{className:"v10-memstack-cell-t-lbl",children:"triples"})]}),u.length>0?o.jsx("ul",{className:"v10-memstack-cell-recent",children:u.map(h=>o.jsxs("li",{className:"v10-memstack-cell-recent-item",title:h.label,children:[o.jsx("span",{className:"v10-memstack-cell-recent-bullet"}),o.jsx("span",{className:"v10-memstack-cell-recent-label",children:h.label}),o.jsx("span",{className:"v10-memstack-cell-recent-time",children:kj(m5(h))})]},h.uri))}):o.jsxs("div",{className:"v10-memstack-cell-empty-hint",children:["Nothing in ",a.toUpperCase()," yet"]}),!f&&o.jsxs("button",{type:"button",className:"v10-memstack-cell-open",onClick:d,title:`Open ${n}`,children:["Open ",a.toUpperCase()," →"]})]})}function Gm(e){var t;for(const n of d5){const a=(t=e.properties.get(n))==null?void 0:t[0];if(!a)continue;const s=new Date(a.replace(/^"|"$/g,"").replace(/^"(.+)"(?:@\w+|\^\^.+)?$/,"$1"));if(Number.isFinite(s.getTime()))return s.getTime()}return null}function m5(e){const t=Gm(e);return t?new Date(t):null}function g5(e,t){const n=t||{};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const v5=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,y5=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,b5={};function Lw(e,t){return(b5.jsx?y5:v5).test(e)}const x5=/[ \t\n\f\r]/g;function w5(e){return typeof e=="object"?e.type==="text"?Mw(e.value):!1:Mw(e)}function Mw(e){return e.replace(x5,"")===""}class nc{constructor(t,n,a){this.normal=n,this.property=t,a&&(this.space=a)}}nc.prototype.normal={};nc.prototype.property={};nc.prototype.space=void 0;function SC(e,t){const n={},a={};for(const s of e)Object.assign(n,s.property),Object.assign(a,s.normal);return new nc(n,a,t)}function Vm(e){return e.toLowerCase()}class Zn{constructor(t,n){this.attribute=n,this.property=t}}Zn.prototype.attribute="";Zn.prototype.booleanish=!1;Zn.prototype.boolean=!1;Zn.prototype.commaOrSpaceSeparated=!1;Zn.prototype.commaSeparated=!1;Zn.prototype.defined=!1;Zn.prototype.mustUseProperty=!1;Zn.prototype.number=!1;Zn.prototype.overloadedBoolean=!1;Zn.prototype.property="";Zn.prototype.spaceSeparated=!1;Zn.prototype.space=void 0;let k5=0;const Xe=ds(),on=ds(),Wm=ds(),we=ds(),Rt=ds(),oo=ds(),sr=ds();function ds(){return 2**++k5}const Zm=Object.freeze(Object.defineProperty({__proto__:null,boolean:Xe,booleanish:on,commaOrSpaceSeparated:sr,commaSeparated:oo,number:we,overloadedBoolean:Wm,spaceSeparated:Rt},Symbol.toStringTag,{value:"Module"})),Yh=Object.keys(Zm);class mv extends Zn{constructor(t,n,a,s){let l=-1;if(super(t,n),Dw(this,"space",s),typeof a=="number")for(;++l<Yh.length;){const u=Yh[l];Dw(this,Yh[l],(a&Zm[u])===Zm[u])}}}mv.prototype.defined=!0;function Dw(e,t,n){n&&(e[t]=n)}function ko(e){const t={},n={};for(const[a,s]of Object.entries(e.properties)){const l=new mv(a,e.transform(e.attributes||{},a),s,e.space);e.mustUseProperty&&e.mustUseProperty.includes(a)&&(l.mustUseProperty=!0),t[a]=l,n[Vm(a)]=a,n[Vm(l.attribute)]=a}return new nc(t,n,e.space)}const jC=ko({properties:{ariaActiveDescendant:null,ariaAtomic:on,ariaAutoComplete:null,ariaBusy:on,ariaChecked:on,ariaColCount:we,ariaColIndex:we,ariaColSpan:we,ariaControls:Rt,ariaCurrent:null,ariaDescribedBy:Rt,ariaDetails:null,ariaDisabled:on,ariaDropEffect:Rt,ariaErrorMessage:null,ariaExpanded:on,ariaFlowTo:Rt,ariaGrabbed:on,ariaHasPopup:null,ariaHidden:on,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Rt,ariaLevel:we,ariaLive:null,ariaModal:on,ariaMultiLine:on,ariaMultiSelectable:on,ariaOrientation:null,ariaOwns:Rt,ariaPlaceholder:null,ariaPosInSet:we,ariaPressed:on,ariaReadOnly:on,ariaRelevant:null,ariaRequired:on,ariaRoleDescription:Rt,ariaRowCount:we,ariaRowIndex:we,ariaRowSpan:we,ariaSelected:on,ariaSetSize:we,ariaSort:null,ariaValueMax:we,ariaValueMin:we,ariaValueNow:we,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function CC(e,t){return t in e?e[t]:t}function NC(e,t){return CC(e,t.toLowerCase())}const S5=ko({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:oo,acceptCharset:Rt,accessKey:Rt,action:null,allow:null,allowFullScreen:Xe,allowPaymentRequest:Xe,allowUserMedia:Xe,alt:null,as:null,async:Xe,autoCapitalize:null,autoComplete:Rt,autoFocus:Xe,autoPlay:Xe,blocking:Rt,capture:null,charSet:null,checked:Xe,cite:null,className:Rt,cols:we,colSpan:null,content:null,contentEditable:on,controls:Xe,controlsList:Rt,coords:we|oo,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Xe,defer:Xe,dir:null,dirName:null,disabled:Xe,download:Wm,draggable:on,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Xe,formTarget:null,headers:Rt,height:we,hidden:Wm,high:we,href:null,hrefLang:null,htmlFor:Rt,httpEquiv:Rt,id:null,imageSizes:null,imageSrcSet:null,inert:Xe,inputMode:null,integrity:null,is:null,isMap:Xe,itemId:null,itemProp:Rt,itemRef:Rt,itemScope:Xe,itemType:Rt,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Xe,low:we,manifest:null,max:null,maxLength:we,media:null,method:null,min:null,minLength:we,multiple:Xe,muted:Xe,name:null,nonce:null,noModule:Xe,noValidate:Xe,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:Xe,optimum:we,pattern:null,ping:Rt,placeholder:null,playsInline:Xe,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Xe,referrerPolicy:null,rel:Rt,required:Xe,reversed:Xe,rows:we,rowSpan:we,sandbox:Rt,scope:null,scoped:Xe,seamless:Xe,selected:Xe,shadowRootClonable:Xe,shadowRootDelegatesFocus:Xe,shadowRootMode:null,shape:null,size:we,sizes:null,slot:null,span:we,spellCheck:on,src:null,srcDoc:null,srcLang:null,srcSet:null,start:we,step:null,style:null,tabIndex:we,target:null,title:null,translate:null,type:null,typeMustMatch:Xe,useMap:null,value:on,width:we,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Rt,axis:null,background:null,bgColor:null,border:we,borderColor:null,bottomMargin:we,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Xe,declare:Xe,event:null,face:null,frame:null,frameBorder:null,hSpace:we,leftMargin:we,link:null,longDesc:null,lowSrc:null,marginHeight:we,marginWidth:we,noResize:Xe,noHref:Xe,noShade:Xe,noWrap:Xe,object:null,profile:null,prompt:null,rev:null,rightMargin:we,rules:null,scheme:null,scrolling:on,standby:null,summary:null,text:null,topMargin:we,valueType:null,version:null,vAlign:null,vLink:null,vSpace:we,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Xe,disableRemotePlayback:Xe,prefix:null,property:null,results:we,security:null,unselectable:null},space:"html",transform:NC}),j5=ko({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:sr,accentHeight:we,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:we,amplitude:we,arabicForm:null,ascent:we,attributeName:null,attributeType:null,azimuth:we,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:we,by:null,calcMode:null,capHeight:we,className:Rt,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:we,diffuseConstant:we,direction:null,display:null,dur:null,divisor:we,dominantBaseline:null,download:Xe,dx:null,dy:null,edgeMode:null,editable:null,elevation:we,enableBackground:null,end:null,event:null,exponent:we,externalResourcesRequired:null,fill:null,fillOpacity:we,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:oo,g2:oo,glyphName:oo,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:we,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:we,horizOriginX:we,horizOriginY:we,id:null,ideographic:we,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:we,k:we,k1:we,k2:we,k3:we,k4:we,kernelMatrix:sr,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:we,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:we,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:we,overlineThickness:we,paintOrder:null,panose1:null,path:null,pathLength:we,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Rt,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:we,pointsAtY:we,pointsAtZ:we,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:sr,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:sr,rev:sr,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:sr,requiredFeatures:sr,requiredFonts:sr,requiredFormats:sr,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:we,specularExponent:we,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:we,strikethroughThickness:we,string:null,stroke:null,strokeDashArray:sr,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:we,strokeOpacity:we,strokeWidth:null,style:null,surfaceScale:we,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:sr,tabIndex:we,tableValues:null,target:null,targetX:we,targetY:we,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:sr,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:we,underlineThickness:we,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:we,values:null,vAlphabetic:we,vMathematical:we,vectorEffect:null,vHanging:we,vIdeographic:we,version:null,vertAdvY:we,vertOriginX:we,vertOriginY:we,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:we,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:CC}),EC=ko({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),AC=ko({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:NC}),TC=ko({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),C5={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},N5=/[A-Z]/g,zw=/-[a-z]/g,E5=/^data[-\w.:]+$/i;function A5(e,t){const n=Vm(t);let a=t,s=Zn;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&E5.test(t)){if(t.charAt(4)==="-"){const l=t.slice(5).replace(zw,_5);a="data"+l.charAt(0).toUpperCase()+l.slice(1)}else{const l=t.slice(4);if(!zw.test(l)){let u=l.replace(N5,T5);u.charAt(0)!=="-"&&(u="-"+u),t="data"+u}}s=mv}return new s(a,t)}function T5(e){return"-"+e.toLowerCase()}function _5(e){return e.charAt(1).toUpperCase()}const R5=SC([jC,S5,EC,AC,TC],"html"),gv=SC([jC,j5,EC,AC,TC],"svg");function O5(e){return e.join(" ").trim()}var Qs={},Qh,$w;function L5(){if($w)return Qh;$w=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,s=/^:\s*/,l=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,u=/^[;\s]*/,d=/^\s+|\s+$/g,f=`
1625
1625
  `,h="/",g="*",m="",y="comment",b="declaration";function k(N,S){if(typeof N!="string")throw new TypeError("First argument must be a string");if(!N)return[];S=S||{};var A=1,E=1;function T(I){var H=I.match(t);H&&(A+=H.length);var B=I.lastIndexOf(f);E=~B?I.length-B:E+I.length}function U(){var I={line:A,column:E};return function(H){return H.position=new _(I),D(),H}}function _(I){this.start=I,this.end={line:A,column:E},this.source=S.source}_.prototype.content=N;function z(I){var H=new Error(S.source+":"+A+":"+E+": "+I);if(H.reason=I,H.filename=S.source,H.line=A,H.column=E,H.source=N,!S.silent)throw H}function q(I){var H=I.exec(N);if(H){var B=H[0];return T(B),N=N.slice(B.length),H}}function D(){q(n)}function R(I){var H;for(I=I||[];H=$();)H!==!1&&I.push(H);return I}function $(){var I=U();if(!(h!=N.charAt(0)||g!=N.charAt(1))){for(var H=2;m!=N.charAt(H)&&(g!=N.charAt(H)||h!=N.charAt(H+1));)++H;if(H+=2,m===N.charAt(H-1))return z("End of comment missing");var B=N.slice(2,H-2);return E+=2,T(B),N=N.slice(H),E+=2,I({type:y,comment:B})}}function F(){var I=U(),H=q(a);if(H){if($(),!q(s))return z("property missing ':'");var B=q(l),W=I({type:b,property:j(H[0].replace(e,m)),value:B?j(B[0].replace(e,m)):m});return q(u),W}}function K(){var I=[];R(I);for(var H;H=F();)H!==!1&&(I.push(H),R(I));return I}return D(),K()}function j(N){return N?N.replace(d,m):m}return Qh=k,Qh}var Iw;function M5(){if(Iw)return Qs;Iw=1;var e=Qs&&Qs.__importDefault||function(a){return a&&a.__esModule?a:{default:a}};Object.defineProperty(Qs,"__esModule",{value:!0}),Qs.default=n;const t=e(L5());function n(a,s){let l=null;if(!a||typeof a!="string")return l;const u=(0,t.default)(a),d=typeof s=="function";return u.forEach(f=>{if(f.type!=="declaration")return;const{property:h,value:g}=f;d?s(h,g,f):g&&(l=l||{},l[h]=g)}),l}return Qs}var wl={},Pw;function D5(){if(Pw)return wl;Pw=1,Object.defineProperty(wl,"__esModule",{value:!0}),wl.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,a=/^-(webkit|moz|ms|o|khtml)-/,s=/^-(ms)-/,l=function(h){return!h||n.test(h)||e.test(h)},u=function(h,g){return g.toUpperCase()},d=function(h,g){return"".concat(g,"-")},f=function(h,g){return g===void 0&&(g={}),l(h)?h:(h=h.toLowerCase(),g.reactCompat?h=h.replace(s,d):h=h.replace(a,d),h.replace(t,u))};return wl.camelCase=f,wl}var kl,Uw;function z5(){if(Uw)return kl;Uw=1;var e=kl&&kl.__importDefault||function(s){return s&&s.__esModule?s:{default:s}},t=e(M5()),n=D5();function a(s,l){var u={};return!s||typeof s!="string"||(0,t.default)(s,function(d,f){d&&f&&(u[(0,n.camelCase)(d,l)]=f)}),u}return a.default=a,kl=a,kl}var $5=z5();const I5=Wl($5),_C=RC("end"),vv=RC("start");function RC(e){return t;function t(n){const a=n&&n.position&&n.position[e]||{};if(typeof a.line=="number"&&a.line>0&&typeof a.column=="number"&&a.column>0)return{line:a.line,column:a.column,offset:typeof a.offset=="number"&&a.offset>-1?a.offset:void 0}}}function P5(e){const t=vv(e),n=_C(e);if(t&&n)return{start:t,end:n}}function Ml(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?Bw(e.position):"start"in e||"end"in e?Bw(e):"line"in e||"column"in e?Km(e):""}function Km(e){return Fw(e&&e.line)+":"+Fw(e&&e.column)}function Bw(e){return Km(e&&e.start)+"-"+Km(e&&e.end)}function Fw(e){return e&&typeof e=="number"?e:1}class _n extends Error{constructor(t,n,a){super(),typeof n=="string"&&(a=n,n=void 0);let s="",l={},u=!1;if(n&&("line"in n&&"column"in n?l={place:n}:"start"in n&&"end"in n?l={place:n}:"type"in n?l={ancestors:[n],place:n.position}:l={...n}),typeof t=="string"?s=t:!l.cause&&t&&(u=!0,s=t.message,l.cause=t),!l.ruleId&&!l.source&&typeof a=="string"){const f=a.indexOf(":");f===-1?l.ruleId=a:(l.source=a.slice(0,f),l.ruleId=a.slice(f+1))}if(!l.place&&l.ancestors&&l.ancestors){const f=l.ancestors[l.ancestors.length-1];f&&(l.place=f.position)}const d=l.place&&"start"in l.place?l.place.start:l.place;this.ancestors=l.ancestors||void 0,this.cause=l.cause||void 0,this.column=d?d.column:void 0,this.fatal=void 0,this.file="",this.message=s,this.line=d?d.line:void 0,this.name=Ml(l.place)||"1:1",this.place=l.place||void 0,this.reason=this.message,this.ruleId=l.ruleId||void 0,this.source=l.source||void 0,this.stack=u&&l.cause&&typeof l.cause.stack=="string"?l.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}_n.prototype.file="";_n.prototype.name="";_n.prototype.reason="";_n.prototype.message="";_n.prototype.stack="";_n.prototype.column=void 0;_n.prototype.line=void 0;_n.prototype.ancestors=void 0;_n.prototype.cause=void 0;_n.prototype.fatal=void 0;_n.prototype.place=void 0;_n.prototype.ruleId=void 0;_n.prototype.source=void 0;const yv={}.hasOwnProperty,U5=new Map,B5=/[A-Z]/g,F5=new Set(["table","tbody","thead","tfoot","tr"]),H5=new Set(["td","th"]),OC="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function q5(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let a;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");a=X5(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");a=Q5(n,t.jsx,t.jsxs)}const s={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:a,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?gv:R5,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},l=LC(s,e,void 0);return l&&typeof l!="string"?l:s.create(e,s.Fragment,{children:l||void 0},void 0)}function LC(e,t,n){if(t.type==="element")return G5(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return V5(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return Z5(e,t,n);if(t.type==="mdxjsEsm")return W5(e,t);if(t.type==="root")return K5(e,t,n);if(t.type==="text")return Y5(e,t)}function G5(e,t,n){const a=e.schema;let s=a;t.tagName.toLowerCase()==="svg"&&a.space==="html"&&(s=gv,e.schema=s),e.ancestors.push(t);const l=DC(e,t.tagName,!1),u=J5(e,t);let d=xv(e,t);return F5.has(t.tagName)&&(d=d.filter(function(f){return typeof f=="string"?!w5(f):!0})),MC(e,u,l,t),bv(u,d),e.ancestors.pop(),e.schema=a,e.create(t,l,u,n)}function V5(e,t){if(t.data&&t.data.estree&&e.evaluater){const a=t.data.estree.body[0];return a.type,e.evaluater.evaluateExpression(a.expression)}ql(e,t.position)}function W5(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);ql(e,t.position)}function Z5(e,t,n){const a=e.schema;let s=a;t.name==="svg"&&a.space==="html"&&(s=gv,e.schema=s),e.ancestors.push(t);const l=t.name===null?e.Fragment:DC(e,t.name,!0),u=eU(e,t),d=xv(e,t);return MC(e,u,l,t),bv(u,d),e.ancestors.pop(),e.schema=a,e.create(t,l,u,n)}function K5(e,t,n){const a={};return bv(a,xv(e,t)),e.create(t,e.Fragment,a,n)}function Y5(e,t){return t.value}function MC(e,t,n,a){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=a)}function bv(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function Q5(e,t,n){return a;function a(s,l,u,d){const h=Array.isArray(u.children)?n:t;return d?h(l,u,d):h(l,u)}}function X5(e,t){return n;function n(a,s,l,u){const d=Array.isArray(l.children),f=vv(a);return t(s,l,u,d,{columnNumber:f?f.column-1:void 0,fileName:e,lineNumber:f?f.line:void 0},void 0)}}function J5(e,t){const n={};let a,s;for(s in t.properties)if(s!=="children"&&yv.call(t.properties,s)){const l=tU(e,s,t.properties[s]);if(l){const[u,d]=l;e.tableCellAlignToStyle&&u==="align"&&typeof d=="string"&&H5.has(t.tagName)?a=d:n[u]=d}}if(a){const l=n.style||(n.style={});l[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=a}return n}function eU(e,t){const n={};for(const a of t.attributes)if(a.type==="mdxJsxExpressionAttribute")if(a.data&&a.data.estree&&e.evaluater){const l=a.data.estree.body[0];l.type;const u=l.expression;u.type;const d=u.properties[0];d.type,Object.assign(n,e.evaluater.evaluateExpression(d.argument))}else ql(e,t.position);else{const s=a.name;let l;if(a.value&&typeof a.value=="object")if(a.value.data&&a.value.data.estree&&e.evaluater){const d=a.value.data.estree.body[0];d.type,l=e.evaluater.evaluateExpression(d.expression)}else ql(e,t.position);else l=a.value===null?!0:a.value;n[s]=l}return n}function xv(e,t){const n=[];let a=-1;const s=e.passKeys?new Map:U5;for(;++a<t.children.length;){const l=t.children[a];let u;if(e.passKeys){const f=l.type==="element"?l.tagName:l.type==="mdxJsxFlowElement"||l.type==="mdxJsxTextElement"?l.name:void 0;if(f){const h=s.get(f)||0;u=f+"-"+h,s.set(f,h+1)}}const d=LC(e,l,u);d!==void 0&&n.push(d)}return n}function tU(e,t,n){const a=A5(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=a.commaSeparated?g5(n):O5(n)),a.property==="style"){let s=typeof n=="object"?n:nU(e,String(n));return e.stylePropertyNameCase==="css"&&(s=rU(s)),["style",s]}return[e.elementAttributeNameCase==="react"&&a.space?C5[a.property]||a.property:a.attribute,n]}}function nU(e,t){try{return I5(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const a=n,s=new _n("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:a,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw s.file=e.filePath||void 0,s.url=OC+"#cannot-parse-style-attribute",s}}function DC(e,t,n){let a;if(!n)a={type:"Literal",value:t};else if(t.includes(".")){const s=t.split(".");let l=-1,u;for(;++l<s.length;){const d=Lw(s[l])?{type:"Identifier",name:s[l]}:{type:"Literal",value:s[l]};u=u?{type:"MemberExpression",object:u,property:d,computed:!!(l&&d.type==="Literal"),optional:!1}:d}a=u}else a=Lw(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(a.type==="Literal"){const s=a.value;return yv.call(e.components,s)?e.components[s]:s}if(e.evaluater)return e.evaluater.evaluateExpression(a);ql(e)}function ql(e,t){const n=new _n("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=OC+"#cannot-handle-mdx-estrees-without-createevaluater",n}function rU(e){const t={};let n;for(n in e)yv.call(e,n)&&(t[aU(n)]=e[n]);return t}function aU(e){let t=e.replace(B5,iU);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function iU(e){return"-"+e.toLowerCase()}const Xh={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},sU={};function wv(e,t){const n=sU,a=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,s=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return zC(e,a,s)}function zC(e,t,n){if(oU(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return Hw(e.children,t,n)}return Array.isArray(e)?Hw(e,t,n):""}function Hw(e,t,n){const a=[];let s=-1;for(;++s<e.length;)a[s]=zC(e[s],t,n);return a.join("")}function oU(e){return!!(e&&typeof e=="object")}const qw=document.createElement("i");function kv(e){const t="&"+e+";";qw.innerHTML=t;const n=qw.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function cr(e,t,n,a){const s=e.length;let l=0,u;if(t<0?t=-t>s?0:s+t:t=t>s?s:t,n=n>0?n:0,a.length<1e4)u=Array.from(a),u.unshift(t,n),e.splice(...u);else for(n&&e.splice(t,n);l<a.length;)u=a.slice(l,l+1e4),u.unshift(t,0),e.splice(...u),l+=1e4,t+=1e4}function Ar(e,t){return e.length>0?(cr(e,e.length,0,t),e):t}const Gw={}.hasOwnProperty;function $C(e){const t={};let n=-1;for(;++n<e.length;)lU(t,e[n]);return t}function lU(e,t){let n;for(n in t){const s=(Gw.call(e,n)?e[n]:void 0)||(e[n]={}),l=t[n];let u;if(l)for(u in l){Gw.call(s,u)||(s[u]=[]);const d=l[u];cU(s[u],Array.isArray(d)?d:d?[d]:[])}}}function cU(e,t){let n=-1;const a=[];for(;++n<t.length;)(t[n].add==="after"?e:a).push(t[n]);cr(e,0,0,a)}function IC(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function Ur(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Dn=ji(/[A-Za-z]/),An=ji(/[\dA-Za-z]/),uU=ji(/[#-'*+\--9=?A-Z^-~]/);function wd(e){return e!==null&&(e<32||e===127)}const Ym=ji(/\d/),dU=ji(/[\dA-Fa-f]/),pU=ji(/[!-/:-@[-`{-~]/);function Pe(e){return e!==null&&e<-2}function Tt(e){return e!==null&&(e<0||e===32)}function it(e){return e===-2||e===-1||e===32}const Wd=ji(new RegExp("\\p{P}|\\p{S}","u")),as=ji(/\s/);function ji(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function So(e){const t=[];let n=-1,a=0,s=0;for(;++n<e.length;){const l=e.charCodeAt(n);let u="";if(l===37&&An(e.charCodeAt(n+1))&&An(e.charCodeAt(n+2)))s=2;else if(l<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(l))||(u=String.fromCharCode(l));else if(l>55295&&l<57344){const d=e.charCodeAt(n+1);l<56320&&d>56319&&d<57344?(u=String.fromCharCode(l,d),s=1):u="�"}else u=String.fromCharCode(l);u&&(t.push(e.slice(a,n),encodeURIComponent(u)),a=n+s+1,u=""),s&&(n+=s,s=0)}return t.join("")+e.slice(a)}function dt(e,t,n,a){const s=a?a-1:Number.POSITIVE_INFINITY;let l=0;return u;function u(f){return it(f)?(e.enter(n),d(f)):t(f)}function d(f){return it(f)&&l++<s?(e.consume(f),d):(e.exit(n),t(f))}}const fU={tokenize:hU};function hU(e){const t=e.attempt(this.parser.constructs.contentInitial,a,s);let n;return t;function a(d){if(d===null){e.consume(d);return}return e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),dt(e,t,"linePrefix")}function s(d){return e.enter("paragraph"),l(d)}function l(d){const f=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=f),n=f,u(d)}function u(d){if(d===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(d);return}return Pe(d)?(e.consume(d),e.exit("chunkText"),l):(e.consume(d),u)}}const mU={tokenize:gU},Vw={tokenize:vU};function gU(e){const t=this,n=[];let a=0,s,l,u;return d;function d(E){if(a<n.length){const T=n[a];return t.containerState=T[1],e.attempt(T[0].continuation,f,h)(E)}return h(E)}function f(E){if(a++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,s&&A();const T=t.events.length;let U=T,_;for(;U--;)if(t.events[U][0]==="exit"&&t.events[U][1].type==="chunkFlow"){_=t.events[U][1].end;break}S(a);let z=T;for(;z<t.events.length;)t.events[z][1].end={..._},z++;return cr(t.events,U+1,0,t.events.slice(T)),t.events.length=z,h(E)}return d(E)}function h(E){if(a===n.length){if(!s)return y(E);if(s.currentConstruct&&s.currentConstruct.concrete)return k(E);t.interrupt=!!(s.currentConstruct&&!s._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Vw,g,m)(E)}function g(E){return s&&A(),S(a),y(E)}function m(E){return t.parser.lazy[t.now().line]=a!==n.length,u=t.now().offset,k(E)}function y(E){return t.containerState={},e.attempt(Vw,b,k)(E)}function b(E){return a++,n.push([t.currentConstruct,t.containerState]),y(E)}function k(E){if(E===null){s&&A(),S(0),e.consume(E);return}return s=s||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:s,contentType:"flow",previous:l}),j(E)}function j(E){if(E===null){N(e.exit("chunkFlow"),!0),S(0),e.consume(E);return}return Pe(E)?(e.consume(E),N(e.exit("chunkFlow")),a=0,t.interrupt=void 0,d):(e.consume(E),j)}function N(E,T){const U=t.sliceStream(E);if(T&&U.push(null),E.previous=l,l&&(l.next=E),l=E,s.defineSkip(E.start),s.write(U),t.parser.lazy[E.start.line]){let _=s.events.length;for(;_--;)if(s.events[_][1].start.offset<u&&(!s.events[_][1].end||s.events[_][1].end.offset>u))return;const z=t.events.length;let q=z,D,R;for(;q--;)if(t.events[q][0]==="exit"&&t.events[q][1].type==="chunkFlow"){if(D){R=t.events[q][1].end;break}D=!0}for(S(a),_=z;_<t.events.length;)t.events[_][1].end={...R},_++;cr(t.events,q+1,0,t.events.slice(z)),t.events.length=_}}function S(E){let T=n.length;for(;T-- >E;){const U=n[T];t.containerState=U[1],U[0].exit.call(t,e)}n.length=E}function A(){s.write([null]),l=void 0,s=void 0,t.containerState._closeFlow=void 0}}function vU(e,t,n){return dt(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function ho(e){if(e===null||Tt(e)||as(e))return 1;if(Wd(e))return 2}function Zd(e,t,n){const a=[];let s=-1;for(;++s<e.length;){const l=e[s].resolveAll;l&&!a.includes(l)&&(t=l(t,n),a.push(l))}return t}const Qm={name:"attention",resolveAll:yU,tokenize:bU};function yU(e,t){let n=-1,a,s,l,u,d,f,h,g;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(a=n;a--;)if(e[a][0]==="exit"&&e[a][1].type==="attentionSequence"&&e[a][1]._open&&t.sliceSerialize(e[a][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[a][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[a][1].end.offset-e[a][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;f=e[a][1].end.offset-e[a][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const m={...e[a][1].end},y={...e[n][1].start};Ww(m,-f),Ww(y,f),u={type:f>1?"strongSequence":"emphasisSequence",start:m,end:{...e[a][1].end}},d={type:f>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:y},l={type:f>1?"strongText":"emphasisText",start:{...e[a][1].end},end:{...e[n][1].start}},s={type:f>1?"strong":"emphasis",start:{...u.start},end:{...d.end}},e[a][1].end={...u.start},e[n][1].start={...d.end},h=[],e[a][1].end.offset-e[a][1].start.offset&&(h=Ar(h,[["enter",e[a][1],t],["exit",e[a][1],t]])),h=Ar(h,[["enter",s,t],["enter",u,t],["exit",u,t],["enter",l,t]]),h=Ar(h,Zd(t.parser.constructs.insideSpan.null,e.slice(a+1,n),t)),h=Ar(h,[["exit",l,t],["enter",d,t],["exit",d,t],["exit",s,t]]),e[n][1].end.offset-e[n][1].start.offset?(g=2,h=Ar(h,[["enter",e[n][1],t],["exit",e[n][1],t]])):g=0,cr(e,a-1,n-a+3,h),n=a+h.length-g-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function bU(e,t){const n=this.parser.constructs.attentionMarkers.null,a=this.previous,s=ho(a);let l;return u;function u(f){return l=f,e.enter("attentionSequence"),d(f)}function d(f){if(f===l)return e.consume(f),d;const h=e.exit("attentionSequence"),g=ho(f),m=!g||g===2&&s||n.includes(f),y=!s||s===2&&g||n.includes(a);return h._open=!!(l===42?m:m&&(s||!y)),h._close=!!(l===42?y:y&&(g||!m)),t(f)}}function Ww(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const xU={name:"autolink",tokenize:wU};function wU(e,t,n){let a=0;return s;function s(b){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(b),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),l}function l(b){return Dn(b)?(e.consume(b),u):b===64?n(b):h(b)}function u(b){return b===43||b===45||b===46||An(b)?(a=1,d(b)):h(b)}function d(b){return b===58?(e.consume(b),a=0,f):(b===43||b===45||b===46||An(b))&&a++<32?(e.consume(b),d):(a=0,h(b))}function f(b){return b===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(b),e.exit("autolinkMarker"),e.exit("autolink"),t):b===null||b===32||b===60||wd(b)?n(b):(e.consume(b),f)}function h(b){return b===64?(e.consume(b),g):uU(b)?(e.consume(b),h):n(b)}function g(b){return An(b)?m(b):n(b)}function m(b){return b===46?(e.consume(b),a=0,g):b===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(b),e.exit("autolinkMarker"),e.exit("autolink"),t):y(b)}function y(b){if((b===45||An(b))&&a++<63){const k=b===45?y:m;return e.consume(b),k}return n(b)}}const rc={partial:!0,tokenize:kU};function kU(e,t,n){return a;function a(l){return it(l)?dt(e,s,"linePrefix")(l):s(l)}function s(l){return l===null||Pe(l)?t(l):n(l)}}const PC={continuation:{tokenize:jU},exit:CU,name:"blockQuote",tokenize:SU};function SU(e,t,n){const a=this;return s;function s(u){if(u===62){const d=a.containerState;return d.open||(e.enter("blockQuote",{_container:!0}),d.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(u),e.exit("blockQuoteMarker"),l}return n(u)}function l(u){return it(u)?(e.enter("blockQuotePrefixWhitespace"),e.consume(u),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(u))}}function jU(e,t,n){const a=this;return s;function s(u){return it(u)?dt(e,l,"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(u):l(u)}function l(u){return e.attempt(PC,t,n)(u)}}function CU(e){e.exit("blockQuote")}const UC={name:"characterEscape",tokenize:NU};function NU(e,t,n){return a;function a(l){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(l),e.exit("escapeMarker"),s}function s(l){return pU(l)?(e.enter("characterEscapeValue"),e.consume(l),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(l)}}const BC={name:"characterReference",tokenize:EU};function EU(e,t,n){const a=this;let s=0,l,u;return d;function d(m){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(m),e.exit("characterReferenceMarker"),f}function f(m){return m===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(m),e.exit("characterReferenceMarkerNumeric"),h):(e.enter("characterReferenceValue"),l=31,u=An,g(m))}function h(m){return m===88||m===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(m),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),l=6,u=dU,g):(e.enter("characterReferenceValue"),l=7,u=Ym,g(m))}function g(m){if(m===59&&s){const y=e.exit("characterReferenceValue");return u===An&&!kv(a.sliceSerialize(y))?n(m):(e.enter("characterReferenceMarker"),e.consume(m),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return u(m)&&s++<l?(e.consume(m),g):n(m)}}const Zw={partial:!0,tokenize:TU},Kw={concrete:!0,name:"codeFenced",tokenize:AU};function AU(e,t,n){const a=this,s={partial:!0,tokenize:U};let l=0,u=0,d;return f;function f(_){return h(_)}function h(_){const z=a.events[a.events.length-1];return l=z&&z[1].type==="linePrefix"?z[2].sliceSerialize(z[1],!0).length:0,d=_,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),g(_)}function g(_){return _===d?(u++,e.consume(_),g):u<3?n(_):(e.exit("codeFencedFenceSequence"),it(_)?dt(e,m,"whitespace")(_):m(_))}function m(_){return _===null||Pe(_)?(e.exit("codeFencedFence"),a.interrupt?t(_):e.check(Zw,j,T)(_)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),y(_))}function y(_){return _===null||Pe(_)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),m(_)):it(_)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),dt(e,b,"whitespace")(_)):_===96&&_===d?n(_):(e.consume(_),y)}function b(_){return _===null||Pe(_)?m(_):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),k(_))}function k(_){return _===null||Pe(_)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),m(_)):_===96&&_===d?n(_):(e.consume(_),k)}function j(_){return e.attempt(s,T,N)(_)}function N(_){return e.enter("lineEnding"),e.consume(_),e.exit("lineEnding"),S}function S(_){return l>0&&it(_)?dt(e,A,"linePrefix",l+1)(_):A(_)}function A(_){return _===null||Pe(_)?e.check(Zw,j,T)(_):(e.enter("codeFlowValue"),E(_))}function E(_){return _===null||Pe(_)?(e.exit("codeFlowValue"),A(_)):(e.consume(_),E)}function T(_){return e.exit("codeFenced"),t(_)}function U(_,z,q){let D=0;return R;function R(H){return _.enter("lineEnding"),_.consume(H),_.exit("lineEnding"),$}function $(H){return _.enter("codeFencedFence"),it(H)?dt(_,F,"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(H):F(H)}function F(H){return H===d?(_.enter("codeFencedFenceSequence"),K(H)):q(H)}function K(H){return H===d?(D++,_.consume(H),K):D>=u?(_.exit("codeFencedFenceSequence"),it(H)?dt(_,I,"whitespace")(H):I(H)):q(H)}function I(H){return H===null||Pe(H)?(_.exit("codeFencedFence"),z(H)):q(H)}}}function TU(e,t,n){const a=this;return s;function s(u){return u===null?n(u):(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),l)}function l(u){return a.parser.lazy[a.now().line]?n(u):t(u)}}const Jh={name:"codeIndented",tokenize:RU},_U={partial:!0,tokenize:OU};function RU(e,t,n){const a=this;return s;function s(h){return e.enter("codeIndented"),dt(e,l,"linePrefix",5)(h)}function l(h){const g=a.events[a.events.length-1];return g&&g[1].type==="linePrefix"&&g[2].sliceSerialize(g[1],!0).length>=4?u(h):n(h)}function u(h){return h===null?f(h):Pe(h)?e.attempt(_U,u,f)(h):(e.enter("codeFlowValue"),d(h))}function d(h){return h===null||Pe(h)?(e.exit("codeFlowValue"),u(h)):(e.consume(h),d)}function f(h){return e.exit("codeIndented"),t(h)}}function OU(e,t,n){const a=this;return s;function s(u){return a.parser.lazy[a.now().line]?n(u):Pe(u)?(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),s):dt(e,l,"linePrefix",5)(u)}function l(u){const d=a.events[a.events.length-1];return d&&d[1].type==="linePrefix"&&d[2].sliceSerialize(d[1],!0).length>=4?t(u):Pe(u)?s(u):n(u)}}const LU={name:"codeText",previous:DU,resolve:MU,tokenize:zU};function MU(e){let t=e.length-4,n=3,a,s;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(a=n;++a<t;)if(e[a][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(a=n-1,t++;++a<=t;)s===void 0?a!==t&&e[a][1].type!=="lineEnding"&&(s=a):(a===t||e[a][1].type==="lineEnding")&&(e[s][1].type="codeTextData",a!==s+2&&(e[s][1].end=e[a-1][1].end,e.splice(s+2,a-s-2),t-=a-s-2,a=s+2),s=void 0);return e}function DU(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function zU(e,t,n){let a=0,s,l;return u;function u(m){return e.enter("codeText"),e.enter("codeTextSequence"),d(m)}function d(m){return m===96?(e.consume(m),a++,d):(e.exit("codeTextSequence"),f(m))}function f(m){return m===null?n(m):m===32?(e.enter("space"),e.consume(m),e.exit("space"),f):m===96?(l=e.enter("codeTextSequence"),s=0,g(m)):Pe(m)?(e.enter("lineEnding"),e.consume(m),e.exit("lineEnding"),f):(e.enter("codeTextData"),h(m))}function h(m){return m===null||m===32||m===96||Pe(m)?(e.exit("codeTextData"),f(m)):(e.consume(m),h)}function g(m){return m===96?(e.consume(m),s++,g):s===a?(e.exit("codeTextSequence"),e.exit("codeText"),t(m)):(l.type="codeTextData",h(m))}}class $U{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const a=n??Number.POSITIVE_INFINITY;return a<this.left.length?this.left.slice(t,a):t>this.left.length?this.right.slice(this.right.length-a+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-a+this.left.length).reverse())}splice(t,n,a){const s=n||0;this.setCursor(Math.trunc(t));const l=this.right.splice(this.right.length-s,Number.POSITIVE_INFINITY);return a&&Sl(this.left,a),l.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),Sl(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Sl(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);Sl(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Sl(this.left,n.reverse())}}}function Sl(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function FC(e){const t={};let n=-1,a,s,l,u,d,f,h;const g=new $U(e);for(;++n<g.length;){for(;n in t;)n=t[n];if(a=g.get(n),n&&a[1].type==="chunkFlow"&&g.get(n-1)[1].type==="listItemPrefix"&&(f=a[1]._tokenizer.events,l=0,l<f.length&&f[l][1].type==="lineEndingBlank"&&(l+=2),l<f.length&&f[l][1].type==="content"))for(;++l<f.length&&f[l][1].type!=="content";)f[l][1].type==="chunkText"&&(f[l][1]._isInFirstContentOfListItem=!0,l++);if(a[0]==="enter")a[1].contentType&&(Object.assign(t,IU(g,n)),n=t[n],h=!0);else if(a[1]._container){for(l=n,s=void 0;l--;)if(u=g.get(l),u[1].type==="lineEnding"||u[1].type==="lineEndingBlank")u[0]==="enter"&&(s&&(g.get(s)[1].type="lineEndingBlank"),u[1].type="lineEnding",s=l);else if(!(u[1].type==="linePrefix"||u[1].type==="listItemIndent"))break;s&&(a[1].end={...g.get(s)[1].start},d=g.slice(s,n),d.unshift(a),g.splice(s,n-s+1,d))}}return cr(e,0,Number.POSITIVE_INFINITY,g.slice(0)),!h}function IU(e,t){const n=e.get(t)[1],a=e.get(t)[2];let s=t-1;const l=[];let u=n._tokenizer;u||(u=a.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(u._contentTypeTextTrailing=!0));const d=u.events,f=[],h={};let g,m,y=-1,b=n,k=0,j=0;const N=[j];for(;b;){for(;e.get(++s)[1]!==b;);l.push(s),b._tokenizer||(g=a.sliceStream(b),b.next||g.push(null),m&&u.defineSkip(b.start),b._isInFirstContentOfListItem&&(u._gfmTasklistFirstContentOfListItem=!0),u.write(g),b._isInFirstContentOfListItem&&(u._gfmTasklistFirstContentOfListItem=void 0)),m=b,b=b.next}for(b=n;++y<d.length;)d[y][0]==="exit"&&d[y-1][0]==="enter"&&d[y][1].type===d[y-1][1].type&&d[y][1].start.line!==d[y][1].end.line&&(j=y+1,N.push(j),b._tokenizer=void 0,b.previous=void 0,b=b.next);for(u.events=[],b?(b._tokenizer=void 0,b.previous=void 0):N.pop(),y=N.length;y--;){const S=d.slice(N[y],N[y+1]),A=l.pop();f.push([A,A+S.length-1]),e.splice(A,2,S)}for(f.reverse(),y=-1;++y<f.length;)h[k+f[y][0]]=k+f[y][1],k+=f[y][1]-f[y][0]-1;return h}const PU={resolve:BU,tokenize:FU},UU={partial:!0,tokenize:HU};function BU(e){return FC(e),e}function FU(e,t){let n;return a;function a(d){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),s(d)}function s(d){return d===null?l(d):Pe(d)?e.check(UU,u,l)(d):(e.consume(d),s)}function l(d){return e.exit("chunkContent"),e.exit("content"),t(d)}function u(d){return e.consume(d),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,s}}function HU(e,t,n){const a=this;return s;function s(u){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),dt(e,l,"linePrefix")}function l(u){if(u===null||Pe(u))return n(u);const d=a.events[a.events.length-1];return!a.parser.constructs.disable.null.includes("codeIndented")&&d&&d[1].type==="linePrefix"&&d[2].sliceSerialize(d[1],!0).length>=4?t(u):e.interrupt(a.parser.constructs.flow,n,t)(u)}}function HC(e,t,n,a,s,l,u,d,f){const h=f||Number.POSITIVE_INFINITY;let g=0;return m;function m(S){return S===60?(e.enter(a),e.enter(s),e.enter(l),e.consume(S),e.exit(l),y):S===null||S===32||S===41||wd(S)?n(S):(e.enter(a),e.enter(u),e.enter(d),e.enter("chunkString",{contentType:"string"}),j(S))}function y(S){return S===62?(e.enter(l),e.consume(S),e.exit(l),e.exit(s),e.exit(a),t):(e.enter(d),e.enter("chunkString",{contentType:"string"}),b(S))}function b(S){return S===62?(e.exit("chunkString"),e.exit(d),y(S)):S===null||S===60||Pe(S)?n(S):(e.consume(S),S===92?k:b)}function k(S){return S===60||S===62||S===92?(e.consume(S),b):b(S)}function j(S){return!g&&(S===null||S===41||Tt(S))?(e.exit("chunkString"),e.exit(d),e.exit(u),e.exit(a),t(S)):g<h&&S===40?(e.consume(S),g++,j):S===41?(e.consume(S),g--,j):S===null||S===32||S===40||wd(S)?n(S):(e.consume(S),S===92?N:j)}function N(S){return S===40||S===41||S===92?(e.consume(S),j):j(S)}}function qC(e,t,n,a,s,l){const u=this;let d=0,f;return h;function h(b){return e.enter(a),e.enter(s),e.consume(b),e.exit(s),e.enter(l),g}function g(b){return d>999||b===null||b===91||b===93&&!f||b===94&&!d&&"_hiddenFootnoteSupport"in u.parser.constructs?n(b):b===93?(e.exit(l),e.enter(s),e.consume(b),e.exit(s),e.exit(a),t):Pe(b)?(e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),g):(e.enter("chunkString",{contentType:"string"}),m(b))}function m(b){return b===null||b===91||b===93||Pe(b)||d++>999?(e.exit("chunkString"),g(b)):(e.consume(b),f||(f=!it(b)),b===92?y:m)}function y(b){return b===91||b===92||b===93?(e.consume(b),d++,m):m(b)}}function GC(e,t,n,a,s,l){let u;return d;function d(y){return y===34||y===39||y===40?(e.enter(a),e.enter(s),e.consume(y),e.exit(s),u=y===40?41:y,f):n(y)}function f(y){return y===u?(e.enter(s),e.consume(y),e.exit(s),e.exit(a),t):(e.enter(l),h(y))}function h(y){return y===u?(e.exit(l),f(u)):y===null?n(y):Pe(y)?(e.enter("lineEnding"),e.consume(y),e.exit("lineEnding"),dt(e,h,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),g(y))}function g(y){return y===u||y===null||Pe(y)?(e.exit("chunkString"),h(y)):(e.consume(y),y===92?m:g)}function m(y){return y===u||y===92?(e.consume(y),g):g(y)}}function Dl(e,t){let n;return a;function a(s){return Pe(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),n=!0,a):it(s)?dt(e,a,n?"linePrefix":"lineSuffix")(s):t(s)}}const qU={name:"definition",tokenize:VU},GU={partial:!0,tokenize:WU};function VU(e,t,n){const a=this;let s;return l;function l(b){return e.enter("definition"),u(b)}function u(b){return qC.call(a,e,d,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(b)}function d(b){return s=Ur(a.sliceSerialize(a.events[a.events.length-1][1]).slice(1,-1)),b===58?(e.enter("definitionMarker"),e.consume(b),e.exit("definitionMarker"),f):n(b)}function f(b){return Tt(b)?Dl(e,h)(b):h(b)}function h(b){return HC(e,g,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(b)}function g(b){return e.attempt(GU,m,m)(b)}function m(b){return it(b)?dt(e,y,"whitespace")(b):y(b)}function y(b){return b===null||Pe(b)?(e.exit("definition"),a.parser.defined.push(s),t(b)):n(b)}}function WU(e,t,n){return a;function a(d){return Tt(d)?Dl(e,s)(d):n(d)}function s(d){return GC(e,l,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(d)}function l(d){return it(d)?dt(e,u,"whitespace")(d):u(d)}function u(d){return d===null||Pe(d)?t(d):n(d)}}const ZU={name:"hardBreakEscape",tokenize:KU};function KU(e,t,n){return a;function a(l){return e.enter("hardBreakEscape"),e.consume(l),s}function s(l){return Pe(l)?(e.exit("hardBreakEscape"),t(l)):n(l)}}const YU={name:"headingAtx",resolve:QU,tokenize:XU};function QU(e,t){let n=e.length-2,a=3,s,l;return e[a][1].type==="whitespace"&&(a+=2),n-2>a&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(a===n-1||n-4>a&&e[n-2][1].type==="whitespace")&&(n-=a+1===n?2:4),n>a&&(s={type:"atxHeadingText",start:e[a][1].start,end:e[n][1].end},l={type:"chunkText",start:e[a][1].start,end:e[n][1].end,contentType:"text"},cr(e,a,n-a+1,[["enter",s,t],["enter",l,t],["exit",l,t],["exit",s,t]])),e}function XU(e,t,n){let a=0;return s;function s(g){return e.enter("atxHeading"),l(g)}function l(g){return e.enter("atxHeadingSequence"),u(g)}function u(g){return g===35&&a++<6?(e.consume(g),u):g===null||Tt(g)?(e.exit("atxHeadingSequence"),d(g)):n(g)}function d(g){return g===35?(e.enter("atxHeadingSequence"),f(g)):g===null||Pe(g)?(e.exit("atxHeading"),t(g)):it(g)?dt(e,d,"whitespace")(g):(e.enter("atxHeadingText"),h(g))}function f(g){return g===35?(e.consume(g),f):(e.exit("atxHeadingSequence"),d(g))}function h(g){return g===null||g===35||Tt(g)?(e.exit("atxHeadingText"),d(g)):(e.consume(g),h)}}const JU=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],Yw=["pre","script","style","textarea"],e8={concrete:!0,name:"htmlFlow",resolveTo:r8,tokenize:a8},t8={partial:!0,tokenize:s8},n8={partial:!0,tokenize:i8};function r8(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function a8(e,t,n){const a=this;let s,l,u,d,f;return h;function h(O){return g(O)}function g(O){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(O),m}function m(O){return O===33?(e.consume(O),y):O===47?(e.consume(O),l=!0,j):O===63?(e.consume(O),s=3,a.interrupt?t:L):Dn(O)?(e.consume(O),u=String.fromCharCode(O),N):n(O)}function y(O){return O===45?(e.consume(O),s=2,b):O===91?(e.consume(O),s=5,d=0,k):Dn(O)?(e.consume(O),s=4,a.interrupt?t:L):n(O)}function b(O){return O===45?(e.consume(O),a.interrupt?t:L):n(O)}function k(O){const ne="CDATA[";return O===ne.charCodeAt(d++)?(e.consume(O),d===ne.length?a.interrupt?t:F:k):n(O)}function j(O){return Dn(O)?(e.consume(O),u=String.fromCharCode(O),N):n(O)}function N(O){if(O===null||O===47||O===62||Tt(O)){const ne=O===47,ue=u.toLowerCase();return!ne&&!l&&Yw.includes(ue)?(s=1,a.interrupt?t(O):F(O)):JU.includes(u.toLowerCase())?(s=6,ne?(e.consume(O),S):a.interrupt?t(O):F(O)):(s=7,a.interrupt&&!a.parser.lazy[a.now().line]?n(O):l?A(O):E(O))}return O===45||An(O)?(e.consume(O),u+=String.fromCharCode(O),N):n(O)}function S(O){return O===62?(e.consume(O),a.interrupt?t:F):n(O)}function A(O){return it(O)?(e.consume(O),A):R(O)}function E(O){return O===47?(e.consume(O),R):O===58||O===95||Dn(O)?(e.consume(O),T):it(O)?(e.consume(O),E):R(O)}function T(O){return O===45||O===46||O===58||O===95||An(O)?(e.consume(O),T):U(O)}function U(O){return O===61?(e.consume(O),_):it(O)?(e.consume(O),U):E(O)}function _(O){return O===null||O===60||O===61||O===62||O===96?n(O):O===34||O===39?(e.consume(O),f=O,z):it(O)?(e.consume(O),_):q(O)}function z(O){return O===f?(e.consume(O),f=null,D):O===null||Pe(O)?n(O):(e.consume(O),z)}function q(O){return O===null||O===34||O===39||O===47||O===60||O===61||O===62||O===96||Tt(O)?U(O):(e.consume(O),q)}function D(O){return O===47||O===62||it(O)?E(O):n(O)}function R(O){return O===62?(e.consume(O),$):n(O)}function $(O){return O===null||Pe(O)?F(O):it(O)?(e.consume(O),$):n(O)}function F(O){return O===45&&s===2?(e.consume(O),B):O===60&&s===1?(e.consume(O),W):O===62&&s===4?(e.consume(O),P):O===63&&s===3?(e.consume(O),L):O===93&&s===5?(e.consume(O),V):Pe(O)&&(s===6||s===7)?(e.exit("htmlFlowData"),e.check(t8,G,K)(O)):O===null||Pe(O)?(e.exit("htmlFlowData"),K(O)):(e.consume(O),F)}function K(O){return e.check(n8,I,G)(O)}function I(O){return e.enter("lineEnding"),e.consume(O),e.exit("lineEnding"),H}function H(O){return O===null||Pe(O)?K(O):(e.enter("htmlFlowData"),F(O))}function B(O){return O===45?(e.consume(O),L):F(O)}function W(O){return O===47?(e.consume(O),u="",Q):F(O)}function Q(O){if(O===62){const ne=u.toLowerCase();return Yw.includes(ne)?(e.consume(O),P):F(O)}return Dn(O)&&u.length<8?(e.consume(O),u+=String.fromCharCode(O),Q):F(O)}function V(O){return O===93?(e.consume(O),L):F(O)}function L(O){return O===62?(e.consume(O),P):O===45&&s===2?(e.consume(O),L):F(O)}function P(O){return O===null||Pe(O)?(e.exit("htmlFlowData"),G(O)):(e.consume(O),P)}function G(O){return e.exit("htmlFlow"),t(O)}}function i8(e,t,n){const a=this;return s;function s(u){return Pe(u)?(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),l):n(u)}function l(u){return a.parser.lazy[a.now().line]?n(u):t(u)}}function s8(e,t,n){return a;function a(s){return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),e.attempt(rc,t,n)}}const o8={name:"htmlText",tokenize:l8};function l8(e,t,n){const a=this;let s,l,u;return d;function d(L){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(L),f}function f(L){return L===33?(e.consume(L),h):L===47?(e.consume(L),U):L===63?(e.consume(L),E):Dn(L)?(e.consume(L),q):n(L)}function h(L){return L===45?(e.consume(L),g):L===91?(e.consume(L),l=0,k):Dn(L)?(e.consume(L),A):n(L)}function g(L){return L===45?(e.consume(L),b):n(L)}function m(L){return L===null?n(L):L===45?(e.consume(L),y):Pe(L)?(u=m,W(L)):(e.consume(L),m)}function y(L){return L===45?(e.consume(L),b):m(L)}function b(L){return L===62?B(L):L===45?y(L):m(L)}function k(L){const P="CDATA[";return L===P.charCodeAt(l++)?(e.consume(L),l===P.length?j:k):n(L)}function j(L){return L===null?n(L):L===93?(e.consume(L),N):Pe(L)?(u=j,W(L)):(e.consume(L),j)}function N(L){return L===93?(e.consume(L),S):j(L)}function S(L){return L===62?B(L):L===93?(e.consume(L),S):j(L)}function A(L){return L===null||L===62?B(L):Pe(L)?(u=A,W(L)):(e.consume(L),A)}function E(L){return L===null?n(L):L===63?(e.consume(L),T):Pe(L)?(u=E,W(L)):(e.consume(L),E)}function T(L){return L===62?B(L):E(L)}function U(L){return Dn(L)?(e.consume(L),_):n(L)}function _(L){return L===45||An(L)?(e.consume(L),_):z(L)}function z(L){return Pe(L)?(u=z,W(L)):it(L)?(e.consume(L),z):B(L)}function q(L){return L===45||An(L)?(e.consume(L),q):L===47||L===62||Tt(L)?D(L):n(L)}function D(L){return L===47?(e.consume(L),B):L===58||L===95||Dn(L)?(e.consume(L),R):Pe(L)?(u=D,W(L)):it(L)?(e.consume(L),D):B(L)}function R(L){return L===45||L===46||L===58||L===95||An(L)?(e.consume(L),R):$(L)}function $(L){return L===61?(e.consume(L),F):Pe(L)?(u=$,W(L)):it(L)?(e.consume(L),$):D(L)}function F(L){return L===null||L===60||L===61||L===62||L===96?n(L):L===34||L===39?(e.consume(L),s=L,K):Pe(L)?(u=F,W(L)):it(L)?(e.consume(L),F):(e.consume(L),I)}function K(L){return L===s?(e.consume(L),s=void 0,H):L===null?n(L):Pe(L)?(u=K,W(L)):(e.consume(L),K)}function I(L){return L===null||L===34||L===39||L===60||L===61||L===96?n(L):L===47||L===62||Tt(L)?D(L):(e.consume(L),I)}function H(L){return L===47||L===62||Tt(L)?D(L):n(L)}function B(L){return L===62?(e.consume(L),e.exit("htmlTextData"),e.exit("htmlText"),t):n(L)}function W(L){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(L),e.exit("lineEnding"),Q}function Q(L){return it(L)?dt(e,V,"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(L):V(L)}function V(L){return e.enter("htmlTextData"),u(L)}}const Sv={name:"labelEnd",resolveAll:p8,resolveTo:f8,tokenize:h8},c8={tokenize:m8},u8={tokenize:g8},d8={tokenize:v8};function p8(e){let t=-1;const n=[];for(;++t<e.length;){const a=e[t][1];if(n.push(e[t]),a.type==="labelImage"||a.type==="labelLink"||a.type==="labelEnd"){const s=a.type==="labelImage"?4:2;a.type="data",t+=s}}return e.length!==n.length&&cr(e,0,e.length,n),e}function f8(e,t){let n=e.length,a=0,s,l,u,d;for(;n--;)if(s=e[n][1],l){if(s.type==="link"||s.type==="labelLink"&&s._inactive)break;e[n][0]==="enter"&&s.type==="labelLink"&&(s._inactive=!0)}else if(u){if(e[n][0]==="enter"&&(s.type==="labelImage"||s.type==="labelLink")&&!s._balanced&&(l=n,s.type!=="labelLink")){a=2;break}}else s.type==="labelEnd"&&(u=n);const f={type:e[l][1].type==="labelLink"?"link":"image",start:{...e[l][1].start},end:{...e[e.length-1][1].end}},h={type:"label",start:{...e[l][1].start},end:{...e[u][1].end}},g={type:"labelText",start:{...e[l+a+2][1].end},end:{...e[u-2][1].start}};return d=[["enter",f,t],["enter",h,t]],d=Ar(d,e.slice(l+1,l+a+3)),d=Ar(d,[["enter",g,t]]),d=Ar(d,Zd(t.parser.constructs.insideSpan.null,e.slice(l+a+4,u-3),t)),d=Ar(d,[["exit",g,t],e[u-2],e[u-1],["exit",h,t]]),d=Ar(d,e.slice(u+1)),d=Ar(d,[["exit",f,t]]),cr(e,l,e.length,d),e}function h8(e,t,n){const a=this;let s=a.events.length,l,u;for(;s--;)if((a.events[s][1].type==="labelImage"||a.events[s][1].type==="labelLink")&&!a.events[s][1]._balanced){l=a.events[s][1];break}return d;function d(y){return l?l._inactive?m(y):(u=a.parser.defined.includes(Ur(a.sliceSerialize({start:l.end,end:a.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(y),e.exit("labelMarker"),e.exit("labelEnd"),f):n(y)}function f(y){return y===40?e.attempt(c8,g,u?g:m)(y):y===91?e.attempt(u8,g,u?h:m)(y):u?g(y):m(y)}function h(y){return e.attempt(d8,g,m)(y)}function g(y){return t(y)}function m(y){return l._balanced=!0,n(y)}}function m8(e,t,n){return a;function a(m){return e.enter("resource"),e.enter("resourceMarker"),e.consume(m),e.exit("resourceMarker"),s}function s(m){return Tt(m)?Dl(e,l)(m):l(m)}function l(m){return m===41?g(m):HC(e,u,d,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(m)}function u(m){return Tt(m)?Dl(e,f)(m):g(m)}function d(m){return n(m)}function f(m){return m===34||m===39||m===40?GC(e,h,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(m):g(m)}function h(m){return Tt(m)?Dl(e,g)(m):g(m)}function g(m){return m===41?(e.enter("resourceMarker"),e.consume(m),e.exit("resourceMarker"),e.exit("resource"),t):n(m)}}function g8(e,t,n){const a=this;return s;function s(d){return qC.call(a,e,l,u,"reference","referenceMarker","referenceString")(d)}function l(d){return a.parser.defined.includes(Ur(a.sliceSerialize(a.events[a.events.length-1][1]).slice(1,-1)))?t(d):n(d)}function u(d){return n(d)}}function v8(e,t,n){return a;function a(l){return e.enter("reference"),e.enter("referenceMarker"),e.consume(l),e.exit("referenceMarker"),s}function s(l){return l===93?(e.enter("referenceMarker"),e.consume(l),e.exit("referenceMarker"),e.exit("reference"),t):n(l)}}const y8={name:"labelStartImage",resolveAll:Sv.resolveAll,tokenize:b8};function b8(e,t,n){const a=this;return s;function s(d){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(d),e.exit("labelImageMarker"),l}function l(d){return d===91?(e.enter("labelMarker"),e.consume(d),e.exit("labelMarker"),e.exit("labelImage"),u):n(d)}function u(d){return d===94&&"_hiddenFootnoteSupport"in a.parser.constructs?n(d):t(d)}}const x8={name:"labelStartLink",resolveAll:Sv.resolveAll,tokenize:w8};function w8(e,t,n){const a=this;return s;function s(u){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(u),e.exit("labelMarker"),e.exit("labelLink"),l}function l(u){return u===94&&"_hiddenFootnoteSupport"in a.parser.constructs?n(u):t(u)}}const em={name:"lineEnding",tokenize:k8};function k8(e,t){return n;function n(a){return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),dt(e,t,"linePrefix")}}const td={name:"thematicBreak",tokenize:S8};function S8(e,t,n){let a=0,s;return l;function l(h){return e.enter("thematicBreak"),u(h)}function u(h){return s=h,d(h)}function d(h){return h===s?(e.enter("thematicBreakSequence"),f(h)):a>=3&&(h===null||Pe(h))?(e.exit("thematicBreak"),t(h)):n(h)}function f(h){return h===s?(e.consume(h),a++,f):(e.exit("thematicBreakSequence"),it(h)?dt(e,d,"whitespace")(h):d(h))}}const qn={continuation:{tokenize:E8},exit:T8,name:"list",tokenize:N8},j8={partial:!0,tokenize:_8},C8={partial:!0,tokenize:A8};function N8(e,t,n){const a=this,s=a.events[a.events.length-1];let l=s&&s[1].type==="linePrefix"?s[2].sliceSerialize(s[1],!0).length:0,u=0;return d;function d(b){const k=a.containerState.type||(b===42||b===43||b===45?"listUnordered":"listOrdered");if(k==="listUnordered"?!a.containerState.marker||b===a.containerState.marker:Ym(b)){if(a.containerState.type||(a.containerState.type=k,e.enter(k,{_container:!0})),k==="listUnordered")return e.enter("listItemPrefix"),b===42||b===45?e.check(td,n,h)(b):h(b);if(!a.interrupt||b===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),f(b)}return n(b)}function f(b){return Ym(b)&&++u<10?(e.consume(b),f):(!a.interrupt||u<2)&&(a.containerState.marker?b===a.containerState.marker:b===41||b===46)?(e.exit("listItemValue"),h(b)):n(b)}function h(b){return e.enter("listItemMarker"),e.consume(b),e.exit("listItemMarker"),a.containerState.marker=a.containerState.marker||b,e.check(rc,a.interrupt?n:g,e.attempt(j8,y,m))}function g(b){return a.containerState.initialBlankLine=!0,l++,y(b)}function m(b){return it(b)?(e.enter("listItemPrefixWhitespace"),e.consume(b),e.exit("listItemPrefixWhitespace"),y):n(b)}function y(b){return a.containerState.size=l+a.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(b)}}function E8(e,t,n){const a=this;return a.containerState._closeFlow=void 0,e.check(rc,s,l);function s(d){return a.containerState.furtherBlankLines=a.containerState.furtherBlankLines||a.containerState.initialBlankLine,dt(e,t,"listItemIndent",a.containerState.size+1)(d)}function l(d){return a.containerState.furtherBlankLines||!it(d)?(a.containerState.furtherBlankLines=void 0,a.containerState.initialBlankLine=void 0,u(d)):(a.containerState.furtherBlankLines=void 0,a.containerState.initialBlankLine=void 0,e.attempt(C8,t,u)(d))}function u(d){return a.containerState._closeFlow=!0,a.interrupt=void 0,dt(e,e.attempt(qn,t,n),"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(d)}}function A8(e,t,n){const a=this;return dt(e,s,"listItemIndent",a.containerState.size+1);function s(l){const u=a.events[a.events.length-1];return u&&u[1].type==="listItemIndent"&&u[2].sliceSerialize(u[1],!0).length===a.containerState.size?t(l):n(l)}}function T8(e){e.exit(this.containerState.type)}function _8(e,t,n){const a=this;return dt(e,s,"listItemPrefixWhitespace",a.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function s(l){const u=a.events[a.events.length-1];return!it(l)&&u&&u[1].type==="listItemPrefixWhitespace"?t(l):n(l)}}const Qw={name:"setextUnderline",resolveTo:R8,tokenize:O8};function R8(e,t){let n=e.length,a,s,l;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){a=n;break}e[n][1].type==="paragraph"&&(s=n)}else e[n][1].type==="content"&&e.splice(n,1),!l&&e[n][1].type==="definition"&&(l=n);const u={type:"setextHeading",start:{...e[a][1].start},end:{...e[e.length-1][1].end}};return e[s][1].type="setextHeadingText",l?(e.splice(s,0,["enter",u,t]),e.splice(l+1,0,["exit",e[a][1],t]),e[a][1].end={...e[l][1].end}):e[a][1]=u,e.push(["exit",u,t]),e}function O8(e,t,n){const a=this;let s;return l;function l(h){let g=a.events.length,m;for(;g--;)if(a.events[g][1].type!=="lineEnding"&&a.events[g][1].type!=="linePrefix"&&a.events[g][1].type!=="content"){m=a.events[g][1].type==="paragraph";break}return!a.parser.lazy[a.now().line]&&(a.interrupt||m)?(e.enter("setextHeadingLine"),s=h,u(h)):n(h)}function u(h){return e.enter("setextHeadingLineSequence"),d(h)}function d(h){return h===s?(e.consume(h),d):(e.exit("setextHeadingLineSequence"),it(h)?dt(e,f,"lineSuffix")(h):f(h))}function f(h){return h===null||Pe(h)?(e.exit("setextHeadingLine"),t(h)):n(h)}}const L8={tokenize:M8};function M8(e){const t=this,n=e.attempt(rc,a,e.attempt(this.parser.constructs.flowInitial,s,dt(e,e.attempt(this.parser.constructs.flow,s,e.attempt(PU,s)),"linePrefix")));return n;function a(l){if(l===null){e.consume(l);return}return e.enter("lineEndingBlank"),e.consume(l),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function s(l){if(l===null){e.consume(l);return}return e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const D8={resolveAll:WC()},z8=VC("string"),$8=VC("text");function VC(e){return{resolveAll:WC(e==="text"?I8:void 0),tokenize:t};function t(n){const a=this,s=this.parser.constructs[e],l=n.attempt(s,u,d);return u;function u(g){return h(g)?l(g):d(g)}function d(g){if(g===null){n.consume(g);return}return n.enter("data"),n.consume(g),f}function f(g){return h(g)?(n.exit("data"),l(g)):(n.consume(g),f)}function h(g){if(g===null)return!0;const m=s[g];let y=-1;if(m)for(;++y<m.length;){const b=m[y];if(!b.previous||b.previous.call(a,a.previous))return!0}return!1}}}function WC(e){return t;function t(n,a){let s=-1,l;for(;++s<=n.length;)l===void 0?n[s]&&n[s][1].type==="data"&&(l=s,s++):(!n[s]||n[s][1].type!=="data")&&(s!==l+2&&(n[l][1].end=n[s-1][1].end,n.splice(l+2,s-l-2),s=l+2),l=void 0);return e?e(n,a):n}}function I8(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const a=e[n-1][1],s=t.sliceStream(a);let l=s.length,u=-1,d=0,f;for(;l--;){const h=s[l];if(typeof h=="string"){for(u=h.length;h.charCodeAt(u-1)===32;)d++,u--;if(u)break;u=-1}else if(h===-2)f=!0,d++;else if(h!==-1){l++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(d=0),d){const h={type:n===e.length||f||d<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:l?u:a.start._bufferIndex+u,_index:a.start._index+l,line:a.end.line,column:a.end.column-d,offset:a.end.offset-d},end:{...a.end}};a.end={...h.start},a.start.offset===a.end.offset?Object.assign(a,h):(e.splice(n,0,["enter",h,t],["exit",h,t]),n+=2)}n++}return e}const P8={42:qn,43:qn,45:qn,48:qn,49:qn,50:qn,51:qn,52:qn,53:qn,54:qn,55:qn,56:qn,57:qn,62:PC},U8={91:qU},B8={[-2]:Jh,[-1]:Jh,32:Jh},F8={35:YU,42:td,45:[Qw,td],60:e8,61:Qw,95:td,96:Kw,126:Kw},H8={38:BC,92:UC},q8={[-5]:em,[-4]:em,[-3]:em,33:y8,38:BC,42:Qm,60:[xU,o8],91:x8,92:[ZU,UC],93:Sv,95:Qm,96:LU},G8={null:[Qm,D8]},V8={null:[42,95]},W8={null:[]},Z8=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:V8,contentInitial:U8,disable:W8,document:P8,flow:F8,flowInitial:B8,insideSpan:G8,string:H8,text:q8},Symbol.toStringTag,{value:"Module"}));function K8(e,t,n){let a={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const s={},l=[];let u=[],d=[];const f={attempt:z(U),check:z(_),consume:A,enter:E,exit:T,interrupt:z(_,{interrupt:!0})},h={code:null,containerState:{},defineSkip:j,events:[],now:k,parser:e,previous:null,sliceSerialize:y,sliceStream:b,write:m};let g=t.tokenize.call(h,f);return t.resolveAll&&l.push(t),h;function m($){return u=Ar(u,$),N(),u[u.length-1]!==null?[]:(q(t,0),h.events=Zd(l,h.events,h),h.events)}function y($,F){return Q8(b($),F)}function b($){return Y8(u,$)}function k(){const{_bufferIndex:$,_index:F,line:K,column:I,offset:H}=a;return{_bufferIndex:$,_index:F,line:K,column:I,offset:H}}function j($){s[$.line]=$.column,R()}function N(){let $;for(;a._index<u.length;){const F=u[a._index];if(typeof F=="string")for($=a._index,a._bufferIndex<0&&(a._bufferIndex=0);a._index===$&&a._bufferIndex<F.length;)S(F.charCodeAt(a._bufferIndex));else S(F)}}function S($){g=g($)}function A($){Pe($)?(a.line++,a.column=1,a.offset+=$===-3?2:1,R()):$!==-1&&(a.column++,a.offset++),a._bufferIndex<0?a._index++:(a._bufferIndex++,a._bufferIndex===u[a._index].length&&(a._bufferIndex=-1,a._index++)),h.previous=$}function E($,F){const K=F||{};return K.type=$,K.start=k(),h.events.push(["enter",K,h]),d.push(K),K}function T($){const F=d.pop();return F.end=k(),h.events.push(["exit",F,h]),F}function U($,F){q($,F.from)}function _($,F){F.restore()}function z($,F){return K;function K(I,H,B){let W,Q,V,L;return Array.isArray(I)?G(I):"tokenize"in I?G([I]):P(I);function P(le){return be;function be(_e){const Ee=_e!==null&&le[_e],Ie=_e!==null&&le.null,We=[...Array.isArray(Ee)?Ee:Ee?[Ee]:[],...Array.isArray(Ie)?Ie:Ie?[Ie]:[]];return G(We)(_e)}}function G(le){return W=le,Q=0,le.length===0?B:O(le[Q])}function O(le){return be;function be(_e){return L=D(),V=le,le.partial||(h.currentConstruct=le),le.name&&h.parser.constructs.disable.null.includes(le.name)?ue():le.tokenize.call(F?Object.assign(Object.create(h),F):h,f,ne,ue)(_e)}}function ne(le){return $(V,L),H}function ue(le){return L.restore(),++Q<W.length?O(W[Q]):B}}}function q($,F){$.resolveAll&&!l.includes($)&&l.push($),$.resolve&&cr(h.events,F,h.events.length-F,$.resolve(h.events.slice(F),h)),$.resolveTo&&(h.events=$.resolveTo(h.events,h))}function D(){const $=k(),F=h.previous,K=h.currentConstruct,I=h.events.length,H=Array.from(d);return{from:I,restore:B};function B(){a=$,h.previous=F,h.currentConstruct=K,h.events.length=I,d=H,R()}}function R(){a.line in s&&a.column<2&&(a.column=s[a.line],a.offset+=s[a.line]-1)}}function Y8(e,t){const n=t.start._index,a=t.start._bufferIndex,s=t.end._index,l=t.end._bufferIndex;let u;if(n===s)u=[e[n].slice(a,l)];else{if(u=e.slice(n,s),a>-1){const d=u[0];typeof d=="string"?u[0]=d.slice(a):u.shift()}l>0&&u.push(e[s].slice(0,l))}return u}function Q8(e,t){let n=-1;const a=[];let s;for(;++n<e.length;){const l=e[n];let u;if(typeof l=="string")u=l;else switch(l){case-5:{u="\r";break}case-4:{u=`
1626
1626
  `;break}case-3:{u=`\r
1627
1627
  `;break}case-2:{u=t?" ":" ";break}case-1:{if(!t&&s)continue;u=" ";break}default:u=String.fromCharCode(l)}s=l===-2,a.push(u)}return a.join("")}function X8(e){const a={constructs:$C([Z8,...(e||{}).extensions||[]]),content:s(fU),defined:[],document:s(mU),flow:s(L8),lazy:{},string:s(z8),text:s($8)};return a;function s(l){return u;function u(d){return K8(a,l,d)}}}function J8(e){for(;!FC(e););return e}const Xw=/[\0\t\n\r]/g;function e9(){let e=1,t="",n=!0,a;return s;function s(l,u,d){const f=[];let h,g,m,y,b;for(l=t+(typeof l=="string"?l.toString():new TextDecoder(u||void 0).decode(l)),m=0,t="",n&&(l.charCodeAt(0)===65279&&m++,n=void 0);m<l.length;){if(Xw.lastIndex=m,h=Xw.exec(l),y=h&&h.index!==void 0?h.index:l.length,b=l.charCodeAt(y),!h){t=l.slice(m);break}if(b===10&&m===y&&a)f.push(-3),a=void 0;else switch(a&&(f.push(-5),a=void 0),m<y&&(f.push(l.slice(m,y)),e+=y-m),b){case 0:{f.push(65533),e++;break}case 9:{for(g=Math.ceil(e/4)*4,f.push(-2);e++<g;)f.push(-1);break}case 10:{f.push(-4),e=1;break}default:a=!0,e=1}m=y+1}return d&&(a&&f.push(-5),t&&f.push(t),f.push(null)),f}}const t9=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function n9(e){return e.replace(t9,r9)}function r9(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const s=n.charCodeAt(1),l=s===120||s===88;return IC(n.slice(l?2:1),l?16:10)}return kv(n)||e}const ZC={}.hasOwnProperty;function a9(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),i9(n)(J8(X8(n).document().write(e9()(e,t,!0))))}function i9(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:l(Oe),autolinkProtocol:D,autolinkEmail:D,atxHeading:l(qe),blockQuote:l(Ie),characterEscape:D,characterReference:D,codeFenced:l(We),codeFencedFenceInfo:u,codeFencedFenceMeta:u,codeIndented:l(We,u),codeText:l(Se,u),codeTextData:D,data:D,codeFlowValue:D,definition:l(ft),definitionDestinationString:u,definitionLabelString:u,definitionTitleString:u,emphasis:l(De),hardBreakEscape:l(ke),hardBreakTrailing:l(ke),htmlFlow:l(lt,u),htmlFlowData:D,htmlText:l(lt,u),htmlTextData:D,image:l(xe),label:u,link:l(Oe),listItem:l($t),listItemValue:y,listOrdered:l(Ot,m),listUnordered:l(Ot),paragraph:l(Yt),reference:O,referenceString:u,resourceDestinationString:u,resourceTitleString:u,setextHeading:l(qe),strong:l(qt),thematicBreak:l(ye)},exit:{atxHeading:f(),atxHeadingSequence:U,autolink:f(),autolinkEmail:Ee,autolinkProtocol:_e,blockQuote:f(),characterEscapeValue:R,characterReferenceMarkerHexadecimal:ue,characterReferenceMarkerNumeric:ue,characterReferenceValue:le,characterReference:be,codeFenced:f(N),codeFencedFence:j,codeFencedFenceInfo:b,codeFencedFenceMeta:k,codeFlowValue:R,codeIndented:f(S),codeText:f(H),codeTextData:R,data:R,definition:f(),definitionDestinationString:T,definitionLabelString:A,definitionTitleString:E,emphasis:f(),hardBreakEscape:f(F),hardBreakTrailing:f(F),htmlFlow:f(K),htmlFlowData:R,htmlText:f(I),htmlTextData:R,image:f(W),label:V,labelText:Q,lineEnding:$,link:f(B),listItem:f(),listOrdered:f(),listUnordered:f(),paragraph:f(),referenceString:ne,resourceDestinationString:L,resourceTitleString:P,resource:G,setextHeading:f(q),setextHeadingLineSequence:z,setextHeadingText:_,strong:f(),thematicBreak:f()}};KC(t,(e||{}).mdastExtensions||[]);const n={};return a;function a(X){let Z={type:"root",children:[]};const ee={stack:[Z],tokenStack:[],config:t,enter:d,exit:h,buffer:u,resume:g,data:n},ce=[];let he=-1;for(;++he<X.length;)if(X[he][1].type==="listOrdered"||X[he][1].type==="listUnordered")if(X[he][0]==="enter")ce.push(he);else{const Le=ce.pop();he=s(X,Le,he)}for(he=-1;++he<X.length;){const Le=t[X[he][0]];ZC.call(Le,X[he][1].type)&&Le[X[he][1].type].call(Object.assign({sliceSerialize:X[he][2].sliceSerialize},ee),X[he][1])}if(ee.tokenStack.length>0){const Le=ee.tokenStack[ee.tokenStack.length-1];(Le[1]||Jw).call(ee,void 0,Le[0])}for(Z.position={start:gi(X.length>0?X[0][1].start:{line:1,column:1,offset:0}),end:gi(X.length>0?X[X.length-2][1].end:{line:1,column:1,offset:0})},he=-1;++he<t.transforms.length;)Z=t.transforms[he](Z)||Z;return Z}function s(X,Z,ee){let ce=Z-1,he=-1,Le=!1,He,Ce,Fe,et;for(;++ce<=ee;){const Ne=X[ce];switch(Ne[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Ne[0]==="enter"?he++:he--,et=void 0;break}case"lineEndingBlank":{Ne[0]==="enter"&&(He&&!et&&!he&&!Fe&&(Fe=ce),et=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:et=void 0}if(!he&&Ne[0]==="enter"&&Ne[1].type==="listItemPrefix"||he===-1&&Ne[0]==="exit"&&(Ne[1].type==="listUnordered"||Ne[1].type==="listOrdered")){if(He){let Wt=ce;for(Ce=void 0;Wt--;){const _t=X[Wt];if(_t[1].type==="lineEnding"||_t[1].type==="lineEndingBlank"){if(_t[0]==="exit")continue;Ce&&(X[Ce][1].type="lineEndingBlank",Le=!0),_t[1].type="lineEnding",Ce=Wt}else if(!(_t[1].type==="linePrefix"||_t[1].type==="blockQuotePrefix"||_t[1].type==="blockQuotePrefixWhitespace"||_t[1].type==="blockQuoteMarker"||_t[1].type==="listItemIndent"))break}Fe&&(!Ce||Fe<Ce)&&(He._spread=!0),He.end=Object.assign({},Ce?X[Ce][1].start:Ne[1].end),X.splice(Ce||ce,0,["exit",He,Ne[2]]),ce++,ee++}if(Ne[1].type==="listItemPrefix"){const Wt={type:"listItem",_spread:!1,start:Object.assign({},Ne[1].start),end:void 0};He=Wt,X.splice(ce,0,["enter",Wt,Ne[2]]),ce++,ee++,Fe=void 0,et=!0}}}return X[Z][1]._spread=Le,ee}function l(X,Z){return ee;function ee(ce){d.call(this,X(ce),ce),Z&&Z.call(this,ce)}}function u(){this.stack.push({type:"fragment",children:[]})}function d(X,Z,ee){this.stack[this.stack.length-1].children.push(X),this.stack.push(X),this.tokenStack.push([Z,ee||void 0]),X.position={start:gi(Z.start),end:void 0}}function f(X){return Z;function Z(ee){X&&X.call(this,ee),h.call(this,ee)}}function h(X,Z){const ee=this.stack.pop(),ce=this.tokenStack.pop();if(ce)ce[0].type!==X.type&&(Z?Z.call(this,X,ce[0]):(ce[1]||Jw).call(this,X,ce[0]));else throw new Error("Cannot close `"+X.type+"` ("+Ml({start:X.start,end:X.end})+"): it’s not open");ee.position.end=gi(X.end)}function g(){return wv(this.stack.pop())}function m(){this.data.expectingFirstListItemValue=!0}function y(X){if(this.data.expectingFirstListItemValue){const Z=this.stack[this.stack.length-2];Z.start=Number.parseInt(this.sliceSerialize(X),10),this.data.expectingFirstListItemValue=void 0}}function b(){const X=this.resume(),Z=this.stack[this.stack.length-1];Z.lang=X}function k(){const X=this.resume(),Z=this.stack[this.stack.length-1];Z.meta=X}function j(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function N(){const X=this.resume(),Z=this.stack[this.stack.length-1];Z.value=X.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function S(){const X=this.resume(),Z=this.stack[this.stack.length-1];Z.value=X.replace(/(\r?\n|\r)$/g,"")}function A(X){const Z=this.resume(),ee=this.stack[this.stack.length-1];ee.label=Z,ee.identifier=Ur(this.sliceSerialize(X)).toLowerCase()}function E(){const X=this.resume(),Z=this.stack[this.stack.length-1];Z.title=X}function T(){const X=this.resume(),Z=this.stack[this.stack.length-1];Z.url=X}function U(X){const Z=this.stack[this.stack.length-1];if(!Z.depth){const ee=this.sliceSerialize(X).length;Z.depth=ee}}function _(){this.data.setextHeadingSlurpLineEnding=!0}function z(X){const Z=this.stack[this.stack.length-1];Z.depth=this.sliceSerialize(X).codePointAt(0)===61?1:2}function q(){this.data.setextHeadingSlurpLineEnding=void 0}function D(X){const ee=this.stack[this.stack.length-1].children;let ce=ee[ee.length-1];(!ce||ce.type!=="text")&&(ce=ut(),ce.position={start:gi(X.start),end:void 0},ee.push(ce)),this.stack.push(ce)}function R(X){const Z=this.stack.pop();Z.value+=this.sliceSerialize(X),Z.position.end=gi(X.end)}function $(X){const Z=this.stack[this.stack.length-1];if(this.data.atHardBreak){const ee=Z.children[Z.children.length-1];ee.position.end=gi(X.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(Z.type)&&(D.call(this,X),R.call(this,X))}function F(){this.data.atHardBreak=!0}function K(){const X=this.resume(),Z=this.stack[this.stack.length-1];Z.value=X}function I(){const X=this.resume(),Z=this.stack[this.stack.length-1];Z.value=X}function H(){const X=this.resume(),Z=this.stack[this.stack.length-1];Z.value=X}function B(){const X=this.stack[this.stack.length-1];if(this.data.inReference){const Z=this.data.referenceType||"shortcut";X.type+="Reference",X.referenceType=Z,delete X.url,delete X.title}else delete X.identifier,delete X.label;this.data.referenceType=void 0}function W(){const X=this.stack[this.stack.length-1];if(this.data.inReference){const Z=this.data.referenceType||"shortcut";X.type+="Reference",X.referenceType=Z,delete X.url,delete X.title}else delete X.identifier,delete X.label;this.data.referenceType=void 0}function Q(X){const Z=this.sliceSerialize(X),ee=this.stack[this.stack.length-2];ee.label=n9(Z),ee.identifier=Ur(Z).toLowerCase()}function V(){const X=this.stack[this.stack.length-1],Z=this.resume(),ee=this.stack[this.stack.length-1];if(this.data.inReference=!0,ee.type==="link"){const ce=X.children;ee.children=ce}else ee.alt=Z}function L(){const X=this.resume(),Z=this.stack[this.stack.length-1];Z.url=X}function P(){const X=this.resume(),Z=this.stack[this.stack.length-1];Z.title=X}function G(){this.data.inReference=void 0}function O(){this.data.referenceType="collapsed"}function ne(X){const Z=this.resume(),ee=this.stack[this.stack.length-1];ee.label=Z,ee.identifier=Ur(this.sliceSerialize(X)).toLowerCase(),this.data.referenceType="full"}function ue(X){this.data.characterReferenceType=X.type}function le(X){const Z=this.sliceSerialize(X),ee=this.data.characterReferenceType;let ce;ee?(ce=IC(Z,ee==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):ce=kv(Z);const he=this.stack[this.stack.length-1];he.value+=ce}function be(X){const Z=this.stack.pop();Z.position.end=gi(X.end)}function _e(X){R.call(this,X);const Z=this.stack[this.stack.length-1];Z.url=this.sliceSerialize(X)}function Ee(X){R.call(this,X);const Z=this.stack[this.stack.length-1];Z.url="mailto:"+this.sliceSerialize(X)}function Ie(){return{type:"blockquote",children:[]}}function We(){return{type:"code",lang:null,meta:null,value:""}}function Se(){return{type:"inlineCode",value:""}}function ft(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function De(){return{type:"emphasis",children:[]}}function qe(){return{type:"heading",depth:0,children:[]}}function ke(){return{type:"break"}}function lt(){return{type:"html",value:""}}function xe(){return{type:"image",title:null,url:"",alt:null}}function Oe(){return{type:"link",title:null,url:"",children:[]}}function Ot(X){return{type:"list",ordered:X.type==="listOrdered",start:null,spread:X._spread,children:[]}}function $t(X){return{type:"listItem",spread:X._spread,checked:null,children:[]}}function Yt(){return{type:"paragraph",children:[]}}function qt(){return{type:"strong",children:[]}}function ut(){return{type:"text",value:""}}function ye(){return{type:"thematicBreak"}}}function gi(e){return{line:e.line,column:e.column,offset:e.offset}}function KC(e,t){let n=-1;for(;++n<t.length;){const a=t[n];Array.isArray(a)?KC(e,a):s9(e,a)}}function s9(e,t){let n;for(n in t)if(ZC.call(t,n))switch(n){case"canContainEols":{const a=t[n];a&&e[n].push(...a);break}case"transforms":{const a=t[n];a&&e[n].push(...a);break}case"enter":case"exit":{const a=t[n];a&&Object.assign(e[n],a);break}}}function Jw(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+Ml({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Ml({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+Ml({start:t.start,end:t.end})+") is still open")}function o9(e){const t=this;t.parser=n;function n(a){return a9(a,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function l9(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function c9(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
@@ -1649,7 +1649,7 @@ ${n.join(`
1649
1649
  `))+1))}const u="#".repeat(s),d=n.enter("headingAtx"),f=n.enter("phrasing");l.move(u+" ");let h=n.containerPhrasing(e,{before:"# ",after:`
1650
1650
  `,...l.current()});return/^[\t ]/.test(h)&&(h=Gl(h.charCodeAt(0))+h.slice(1)),h=h?u+" "+h:u,n.options.closeAtx&&(h+=" "+u),f(),d(),h}uN.peek=AF;function uN(e){return e.value||""}function AF(){return"<"}dN.peek=TF;function dN(e,t,n,a){const s=_v(n),l=s==='"'?"Quote":"Apostrophe",u=n.enter("image");let d=n.enter("label");const f=n.createTracker(a);let h=f.move("![");return h+=f.move(n.safe(e.alt,{before:h,after:"]",...f.current()})),h+=f.move("]("),d(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(d=n.enter("destinationLiteral"),h+=f.move("<"),h+=f.move(n.safe(e.url,{before:h,after:">",...f.current()})),h+=f.move(">")):(d=n.enter("destinationRaw"),h+=f.move(n.safe(e.url,{before:h,after:e.title?" ":")",...f.current()}))),d(),e.title&&(d=n.enter(`title${l}`),h+=f.move(" "+s),h+=f.move(n.safe(e.title,{before:h,after:s,...f.current()})),h+=f.move(s),d()),h+=f.move(")"),u(),h}function TF(){return"!"}pN.peek=_F;function pN(e,t,n,a){const s=e.referenceType,l=n.enter("imageReference");let u=n.enter("label");const d=n.createTracker(a);let f=d.move("![");const h=n.safe(e.alt,{before:f,after:"]",...d.current()});f+=d.move(h+"]["),u();const g=n.stack;n.stack=[],u=n.enter("reference");const m=n.safe(n.associationId(e),{before:f,after:"]",...d.current()});return u(),n.stack=g,l(),s==="full"||!h||h!==m?f+=d.move(m+"]"):s==="shortcut"?f=f.slice(0,-1):f+=d.move("]"),f}function _F(){return"!"}fN.peek=RF;function fN(e,t,n){let a=e.value||"",s="`",l=-1;for(;new RegExp("(^|[^`])"+s+"([^`]|$)").test(a);)s+="`";for(/[^ \r\n]/.test(a)&&(/^[ \r\n]/.test(a)&&/[ \r\n]$/.test(a)||/^`|`$/.test(a))&&(a=" "+a+" ");++l<n.unsafe.length;){const u=n.unsafe[l],d=n.compilePattern(u);let f;if(u.atBreak)for(;f=d.exec(a);){let h=f.index;a.charCodeAt(h)===10&&a.charCodeAt(h-1)===13&&h--,a=a.slice(0,h)+" "+a.slice(f.index+1)}}return s+a+s}function RF(){return"`"}function hN(e,t){const n=wv(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(n===e.url||"mailto:"+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}mN.peek=OF;function mN(e,t,n,a){const s=_v(n),l=s==='"'?"Quote":"Apostrophe",u=n.createTracker(a);let d,f;if(hN(e,n)){const g=n.stack;n.stack=[],d=n.enter("autolink");let m=u.move("<");return m+=u.move(n.containerPhrasing(e,{before:m,after:">",...u.current()})),m+=u.move(">"),d(),n.stack=g,m}d=n.enter("link"),f=n.enter("label");let h=u.move("[");return h+=u.move(n.containerPhrasing(e,{before:h,after:"](",...u.current()})),h+=u.move("]("),f(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(f=n.enter("destinationLiteral"),h+=u.move("<"),h+=u.move(n.safe(e.url,{before:h,after:">",...u.current()})),h+=u.move(">")):(f=n.enter("destinationRaw"),h+=u.move(n.safe(e.url,{before:h,after:e.title?" ":")",...u.current()}))),f(),e.title&&(f=n.enter(`title${l}`),h+=u.move(" "+s),h+=u.move(n.safe(e.title,{before:h,after:s,...u.current()})),h+=u.move(s),f()),h+=u.move(")"),d(),h}function OF(e,t,n){return hN(e,n)?"<":"["}gN.peek=LF;function gN(e,t,n,a){const s=e.referenceType,l=n.enter("linkReference");let u=n.enter("label");const d=n.createTracker(a);let f=d.move("[");const h=n.containerPhrasing(e,{before:f,after:"]",...d.current()});f+=d.move(h+"]["),u();const g=n.stack;n.stack=[],u=n.enter("reference");const m=n.safe(n.associationId(e),{before:f,after:"]",...d.current()});return u(),n.stack=g,l(),s==="full"||!h||h!==m?f+=d.move(m+"]"):s==="shortcut"?f=f.slice(0,-1):f+=d.move("]"),f}function LF(){return"["}function Rv(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function MF(e){const t=Rv(e),n=e.options.bulletOther;if(!n)return t==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function DF(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function vN(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function zF(e,t,n,a){const s=n.enter("list"),l=n.bulletCurrent;let u=e.ordered?DF(n):Rv(n);const d=e.ordered?u==="."?")":".":MF(n);let f=t&&n.bulletLastUsed?u===n.bulletLastUsed:!1;if(!e.ordered){const g=e.children?e.children[0]:void 0;if((u==="*"||u==="-")&&g&&(!g.children||!g.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(f=!0),vN(n)===u&&g){let m=-1;for(;++m<e.children.length;){const y=e.children[m];if(y&&y.type==="listItem"&&y.children&&y.children[0]&&y.children[0].type==="thematicBreak"){f=!0;break}}}}f&&(u=d),n.bulletCurrent=u;const h=n.containerFlow(e,a);return n.bulletLastUsed=u,n.bulletCurrent=l,s(),h}function $F(e){const t=e.options.listItemIndent||"one";if(t!=="tab"&&t!=="one"&&t!=="mixed")throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function IF(e,t,n,a){const s=$F(n);let l=n.bulletCurrent||Rv(n);t&&t.type==="list"&&t.ordered&&(l=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+l);let u=l.length+1;(s==="tab"||s==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(u=Math.ceil(u/4)*4);const d=n.createTracker(a);d.move(l+" ".repeat(u-l.length)),d.shift(u);const f=n.enter("listItem"),h=n.indentLines(n.containerFlow(e,d.current()),g);return f(),h;function g(m,y,b){return y?(b?"":" ".repeat(u))+m:(b?l:l+" ".repeat(u-l.length))+m}}function PF(e,t,n,a){const s=n.enter("paragraph"),l=n.enter("phrasing"),u=n.containerPhrasing(e,a);return l(),s(),u}const UF=Yd(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function BF(e,t,n,a){return(e.children.some(function(u){return UF(u)})?n.containerPhrasing:n.containerFlow).call(n,e,a)}function FF(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}yN.peek=HF;function yN(e,t,n,a){const s=FF(n),l=n.enter("strong"),u=n.createTracker(a),d=u.move(s+s);let f=u.move(n.containerPhrasing(e,{after:s,before:d,...u.current()}));const h=f.charCodeAt(0),g=jd(a.before.charCodeAt(a.before.length-1),h,s);g.inside&&(f=Gl(h)+f.slice(1));const m=f.charCodeAt(f.length-1),y=jd(a.after.charCodeAt(0),m,s);y.inside&&(f=f.slice(0,-1)+Gl(m));const b=u.move(s+s);return l(),n.attentionEncodeSurroundingInfo={after:y.outside,before:g.outside},d+f+b}function HF(e,t,n){return n.options.strong||"*"}function qF(e,t,n,a){return n.safe(e.value,a)}function GF(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function VF(e,t,n){const a=(vN(n)+(n.options.ruleSpaces?" ":"")).repeat(GF(n));return n.options.ruleSpaces?a.slice(0,-1):a}const bN={blockquote:mF,break:yk,code:wF,definition:SF,emphasis:cN,hardBreak:yk,heading:EF,html:uN,image:dN,imageReference:pN,inlineCode:fN,link:mN,linkReference:gN,list:zF,listItem:IF,paragraph:PF,root:BF,strong:yN,text:qF,thematicBreak:VF};function WF(){return{enter:{table:ZF,tableData:bk,tableHeader:bk,tableRow:YF},exit:{codeText:QF,table:KF,tableData:pm,tableHeader:pm,tableRow:pm}}}function ZF(e){const t=e._align;this.enter({type:"table",align:t.map(function(n){return n==="none"?null:n}),children:[]},e),this.data.inTable=!0}function KF(e){this.exit(e),this.data.inTable=void 0}function YF(e){this.enter({type:"tableRow",children:[]},e)}function pm(e){this.exit(e)}function bk(e){this.enter({type:"tableCell",children:[]},e)}function QF(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,XF));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function XF(e,t){return t==="|"?t:e}function JF(e){const t=e||{},n=t.tableCellPadding,a=t.tablePipeAlign,s=t.stringLength,l=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
1651
1651
  `,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:y,table:u,tableCell:f,tableRow:d}};function u(b,k,j,N){return h(g(b,j,N),b.align)}function d(b,k,j,N){const S=m(b,j,N),A=h([S]);return A.slice(0,A.indexOf(`
1652
- `))}function f(b,k,j,N){const S=j.enter("tableCell"),A=j.enter("phrasing"),E=j.containerPhrasing(b,{...N,before:l,after:l});return A(),S(),E}function h(b,k){return fF(b,{align:k,alignDelimiters:a,padding:n,stringLength:s})}function g(b,k,j){const N=b.children;let S=-1;const A=[],E=k.enter("table");for(;++S<N.length;)A[S]=m(N[S],k,j);return E(),A}function m(b,k,j){const N=b.children;let S=-1;const A=[],E=k.enter("tableRow");for(;++S<N.length;)A[S]=f(N[S],b,k,j);return E(),A}function y(b,k,j){let N=bN.inlineCode(b,k,j);return j.stack.includes("tableCell")&&(N=N.replace(/\|/g,"\\$&")),N}}function eH(){return{exit:{taskListCheckValueChecked:xk,taskListCheckValueUnchecked:xk,paragraph:nH}}}function tH(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:rH}}}function xk(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function nH(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const a=n.children[0];if(a&&a.type==="text"){const s=t.children;let l=-1,u;for(;++l<s.length;){const d=s[l];if(d.type==="paragraph"){u=d;break}}u===n&&(a.value=a.value.slice(1),a.value.length===0?n.children.shift():n.position&&a.position&&typeof a.position.start.offset=="number"&&(a.position.start.column++,a.position.start.offset++,n.position.start=Object.assign({},a.position.start)))}}this.exit(e)}function rH(e,t,n,a){const s=e.children[0],l=typeof e.checked=="boolean"&&s&&s.type==="paragraph",u="["+(e.checked?"x":" ")+"] ",d=n.createTracker(a);l&&d.move(u);let f=bN.listItem(e,t,n,{...a,...d.current()});return l&&(f=f.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,h)),f;function h(g){return g+u}}function aH(){return[zB(),rF(),oF(),WF(),eH()]}function iH(e){return{extensions:[$B(),aF(e),lF(),JF(e),tH()]}}const sH={tokenize:pH,partial:!0},xN={tokenize:fH,partial:!0},wN={tokenize:hH,partial:!0},kN={tokenize:mH,partial:!0},oH={tokenize:gH,partial:!0},SN={name:"wwwAutolink",tokenize:uH,previous:CN},jN={name:"protocolAutolink",tokenize:dH,previous:NN},Ba={name:"emailAutolink",tokenize:cH,previous:EN},la={};function lH(){return{text:la}}let Zi=48;for(;Zi<123;)la[Zi]=Ba,Zi++,Zi===58?Zi=65:Zi===91&&(Zi=97);la[43]=Ba;la[45]=Ba;la[46]=Ba;la[95]=Ba;la[72]=[Ba,jN];la[104]=[Ba,jN];la[87]=[Ba,SN];la[119]=[Ba,SN];function cH(e,t,n){const a=this;let s,l;return u;function u(m){return!ng(m)||!EN.call(a,a.previous)||Ov(a.events)?n(m):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),d(m))}function d(m){return ng(m)?(e.consume(m),d):m===64?(e.consume(m),f):n(m)}function f(m){return m===46?e.check(oH,g,h)(m):m===45||m===95||An(m)?(l=!0,e.consume(m),f):g(m)}function h(m){return e.consume(m),s=!0,f}function g(m){return l&&s&&Dn(a.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(m)):n(m)}}function uH(e,t,n){const a=this;return s;function s(u){return u!==87&&u!==119||!CN.call(a,a.previous)||Ov(a.events)?n(u):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(sH,e.attempt(xN,e.attempt(wN,l),n),n)(u))}function l(u){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(u)}}function dH(e,t,n){const a=this;let s="",l=!1;return u;function u(m){return(m===72||m===104)&&NN.call(a,a.previous)&&!Ov(a.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),s+=String.fromCodePoint(m),e.consume(m),d):n(m)}function d(m){if(Dn(m)&&s.length<5)return s+=String.fromCodePoint(m),e.consume(m),d;if(m===58){const y=s.toLowerCase();if(y==="http"||y==="https")return e.consume(m),f}return n(m)}function f(m){return m===47?(e.consume(m),l?h:(l=!0,f)):n(m)}function h(m){return m===null||wd(m)||Tt(m)||as(m)||Wd(m)?n(m):e.attempt(xN,e.attempt(wN,g),n)(m)}function g(m){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(m)}}function pH(e,t,n){let a=0;return s;function s(u){return(u===87||u===119)&&a<3?(a++,e.consume(u),s):u===46&&a===3?(e.consume(u),l):n(u)}function l(u){return u===null?n(u):t(u)}}function fH(e,t,n){let a,s,l;return u;function u(h){return h===46||h===95?e.check(kN,f,d)(h):h===null||Tt(h)||as(h)||h!==45&&Wd(h)?f(h):(l=!0,e.consume(h),u)}function d(h){return h===95?a=!0:(s=a,a=void 0),e.consume(h),u}function f(h){return s||a||!l?n(h):t(h)}}function hH(e,t){let n=0,a=0;return s;function s(u){return u===40?(n++,e.consume(u),s):u===41&&a<n?l(u):u===33||u===34||u===38||u===39||u===41||u===42||u===44||u===46||u===58||u===59||u===60||u===63||u===93||u===95||u===126?e.check(kN,t,l)(u):u===null||Tt(u)||as(u)?t(u):(e.consume(u),s)}function l(u){return u===41&&a++,e.consume(u),s}}function mH(e,t,n){return a;function a(d){return d===33||d===34||d===39||d===41||d===42||d===44||d===46||d===58||d===59||d===63||d===95||d===126?(e.consume(d),a):d===38?(e.consume(d),l):d===93?(e.consume(d),s):d===60||d===null||Tt(d)||as(d)?t(d):n(d)}function s(d){return d===null||d===40||d===91||Tt(d)||as(d)?t(d):a(d)}function l(d){return Dn(d)?u(d):n(d)}function u(d){return d===59?(e.consume(d),a):Dn(d)?(e.consume(d),u):n(d)}}function gH(e,t,n){return a;function a(l){return e.consume(l),s}function s(l){return An(l)?n(l):t(l)}}function CN(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Tt(e)}function NN(e){return!Dn(e)}function EN(e){return!(e===47||ng(e))}function ng(e){return e===43||e===45||e===46||e===95||An(e)}function Ov(e){let t=e.length,n=!1;for(;t--;){const a=e[t][1];if((a.type==="labelLink"||a.type==="labelImage")&&!a._balanced){n=!0;break}if(a._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const vH={tokenize:CH,partial:!0};function yH(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:kH,continuation:{tokenize:SH},exit:jH}},text:{91:{name:"gfmFootnoteCall",tokenize:wH},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:bH,resolveTo:xH}}}}function bH(e,t,n){const a=this;let s=a.events.length;const l=a.parser.gfmFootnotes||(a.parser.gfmFootnotes=[]);let u;for(;s--;){const f=a.events[s][1];if(f.type==="labelImage"){u=f;break}if(f.type==="gfmFootnoteCall"||f.type==="labelLink"||f.type==="label"||f.type==="image"||f.type==="link")break}return d;function d(f){if(!u||!u._balanced)return n(f);const h=Ur(a.sliceSerialize({start:u.end,end:a.now()}));return h.codePointAt(0)!==94||!l.includes(h.slice(1))?n(f):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(f),e.exit("gfmFootnoteCallLabelMarker"),t(f))}}function xH(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const a={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},s={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};s.end.column++,s.end.offset++,s.end._bufferIndex++;const l={type:"gfmFootnoteCallString",start:Object.assign({},s.end),end:Object.assign({},e[e.length-1][1].start)},u={type:"chunkString",contentType:"string",start:Object.assign({},l.start),end:Object.assign({},l.end)},d=[e[n+1],e[n+2],["enter",a,t],e[n+3],e[n+4],["enter",s,t],["exit",s,t],["enter",l,t],["enter",u,t],["exit",u,t],["exit",l,t],e[e.length-2],e[e.length-1],["exit",a,t]];return e.splice(n,e.length-n+1,...d),e}function wH(e,t,n){const a=this,s=a.parser.gfmFootnotes||(a.parser.gfmFootnotes=[]);let l=0,u;return d;function d(m){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(m),e.exit("gfmFootnoteCallLabelMarker"),f}function f(m){return m!==94?n(m):(e.enter("gfmFootnoteCallMarker"),e.consume(m),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",h)}function h(m){if(l>999||m===93&&!u||m===null||m===91||Tt(m))return n(m);if(m===93){e.exit("chunkString");const y=e.exit("gfmFootnoteCallString");return s.includes(Ur(a.sliceSerialize(y)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(m),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(m)}return Tt(m)||(u=!0),l++,e.consume(m),m===92?g:h}function g(m){return m===91||m===92||m===93?(e.consume(m),l++,h):h(m)}}function kH(e,t,n){const a=this,s=a.parser.gfmFootnotes||(a.parser.gfmFootnotes=[]);let l,u=0,d;return f;function f(k){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(k),e.exit("gfmFootnoteDefinitionLabelMarker"),h}function h(k){return k===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(k),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",g):n(k)}function g(k){if(u>999||k===93&&!d||k===null||k===91||Tt(k))return n(k);if(k===93){e.exit("chunkString");const j=e.exit("gfmFootnoteDefinitionLabelString");return l=Ur(a.sliceSerialize(j)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(k),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),y}return Tt(k)||(d=!0),u++,e.consume(k),k===92?m:g}function m(k){return k===91||k===92||k===93?(e.consume(k),u++,g):g(k)}function y(k){return k===58?(e.enter("definitionMarker"),e.consume(k),e.exit("definitionMarker"),s.includes(l)||s.push(l),dt(e,b,"gfmFootnoteDefinitionWhitespace")):n(k)}function b(k){return t(k)}}function SH(e,t,n){return e.check(rc,t,e.attempt(vH,t,n))}function jH(e){e.exit("gfmFootnoteDefinition")}function CH(e,t,n){const a=this;return dt(e,s,"gfmFootnoteDefinitionIndent",5);function s(l){const u=a.events[a.events.length-1];return u&&u[1].type==="gfmFootnoteDefinitionIndent"&&u[2].sliceSerialize(u[1],!0).length===4?t(l):n(l)}}function NH(e){let n=(e||{}).singleTilde;const a={name:"strikethrough",tokenize:l,resolveAll:s};return n==null&&(n=!0),{text:{126:a},insideSpan:{null:[a]},attentionMarkers:{null:[126]}};function s(u,d){let f=-1;for(;++f<u.length;)if(u[f][0]==="enter"&&u[f][1].type==="strikethroughSequenceTemporary"&&u[f][1]._close){let h=f;for(;h--;)if(u[h][0]==="exit"&&u[h][1].type==="strikethroughSequenceTemporary"&&u[h][1]._open&&u[f][1].end.offset-u[f][1].start.offset===u[h][1].end.offset-u[h][1].start.offset){u[f][1].type="strikethroughSequence",u[h][1].type="strikethroughSequence";const g={type:"strikethrough",start:Object.assign({},u[h][1].start),end:Object.assign({},u[f][1].end)},m={type:"strikethroughText",start:Object.assign({},u[h][1].end),end:Object.assign({},u[f][1].start)},y=[["enter",g,d],["enter",u[h][1],d],["exit",u[h][1],d],["enter",m,d]],b=d.parser.constructs.insideSpan.null;b&&cr(y,y.length,0,Zd(b,u.slice(h+1,f),d)),cr(y,y.length,0,[["exit",m,d],["enter",u[f][1],d],["exit",u[f][1],d],["exit",g,d]]),cr(u,h-1,f-h+3,y),f=h+y.length-2;break}}for(f=-1;++f<u.length;)u[f][1].type==="strikethroughSequenceTemporary"&&(u[f][1].type="data");return u}function l(u,d,f){const h=this.previous,g=this.events;let m=0;return y;function y(k){return h===126&&g[g.length-1][1].type!=="characterEscape"?f(k):(u.enter("strikethroughSequenceTemporary"),b(k))}function b(k){const j=ho(h);if(k===126)return m>1?f(k):(u.consume(k),m++,b);if(m<2&&!n)return f(k);const N=u.exit("strikethroughSequenceTemporary"),S=ho(k);return N._open=!S||S===2&&!!j,N._close=!j||j===2&&!!S,d(k)}}}class EH{constructor(){this.map=[]}add(t,n,a){AH(this,t,n,a)}consume(t){if(this.map.sort(function(l,u){return l[0]-u[0]}),this.map.length===0)return;let n=this.map.length;const a=[];for(;n>0;)n-=1,a.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];a.push(t.slice()),t.length=0;let s=a.pop();for(;s;){for(const l of s)t.push(l);s=a.pop()}this.map.length=0}}function AH(e,t,n,a){let s=0;if(!(n===0&&a.length===0)){for(;s<e.map.length;){if(e.map[s][0]===t){e.map[s][1]+=n,e.map[s][2].push(...a);return}s+=1}e.map.push([t,n,a])}}function TH(e,t){let n=!1;const a=[];for(;t<e.length;){const s=e[t];if(n){if(s[0]==="enter")s[1].type==="tableContent"&&a.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(s[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const l=a.length-1;a[l]=a[l]==="left"?"center":"right"}}else if(s[1].type==="tableDelimiterRow")break}else s[0]==="enter"&&s[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return a}function _H(){return{flow:{null:{name:"table",tokenize:RH,resolveAll:OH}}}}function RH(e,t,n){const a=this;let s=0,l=0,u;return d;function d(R){let $=a.events.length-1;for(;$>-1;){const I=a.events[$][1].type;if(I==="lineEnding"||I==="linePrefix")$--;else break}const F=$>-1?a.events[$][1].type:null,K=F==="tableHead"||F==="tableRow"?_:f;return K===_&&a.parser.lazy[a.now().line]?n(R):K(R)}function f(R){return e.enter("tableHead"),e.enter("tableRow"),h(R)}function h(R){return R===124||(u=!0,l+=1),g(R)}function g(R){return R===null?n(R):Pe(R)?l>1?(l=0,a.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(R),e.exit("lineEnding"),b):n(R):it(R)?dt(e,g,"whitespace")(R):(l+=1,u&&(u=!1,s+=1),R===124?(e.enter("tableCellDivider"),e.consume(R),e.exit("tableCellDivider"),u=!0,g):(e.enter("data"),m(R)))}function m(R){return R===null||R===124||Tt(R)?(e.exit("data"),g(R)):(e.consume(R),R===92?y:m)}function y(R){return R===92||R===124?(e.consume(R),m):m(R)}function b(R){return a.interrupt=!1,a.parser.lazy[a.now().line]?n(R):(e.enter("tableDelimiterRow"),u=!1,it(R)?dt(e,k,"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(R):k(R))}function k(R){return R===45||R===58?N(R):R===124?(u=!0,e.enter("tableCellDivider"),e.consume(R),e.exit("tableCellDivider"),j):U(R)}function j(R){return it(R)?dt(e,N,"whitespace")(R):N(R)}function N(R){return R===58?(l+=1,u=!0,e.enter("tableDelimiterMarker"),e.consume(R),e.exit("tableDelimiterMarker"),S):R===45?(l+=1,S(R)):R===null||Pe(R)?T(R):U(R)}function S(R){return R===45?(e.enter("tableDelimiterFiller"),A(R)):U(R)}function A(R){return R===45?(e.consume(R),A):R===58?(u=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(R),e.exit("tableDelimiterMarker"),E):(e.exit("tableDelimiterFiller"),E(R))}function E(R){return it(R)?dt(e,T,"whitespace")(R):T(R)}function T(R){return R===124?k(R):R===null||Pe(R)?!u||s!==l?U(R):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(R)):U(R)}function U(R){return n(R)}function _(R){return e.enter("tableRow"),z(R)}function z(R){return R===124?(e.enter("tableCellDivider"),e.consume(R),e.exit("tableCellDivider"),z):R===null||Pe(R)?(e.exit("tableRow"),t(R)):it(R)?dt(e,z,"whitespace")(R):(e.enter("data"),q(R))}function q(R){return R===null||R===124||Tt(R)?(e.exit("data"),z(R)):(e.consume(R),R===92?D:q)}function D(R){return R===92||R===124?(e.consume(R),q):q(R)}}function OH(e,t){let n=-1,a=!0,s=0,l=[0,0,0,0],u=[0,0,0,0],d=!1,f=0,h,g,m;const y=new EH;for(;++n<e.length;){const b=e[n],k=b[1];b[0]==="enter"?k.type==="tableHead"?(d=!1,f!==0&&(wk(y,t,f,h,g),g=void 0,f=0),h={type:"table",start:Object.assign({},k.start),end:Object.assign({},k.end)},y.add(n,0,[["enter",h,t]])):k.type==="tableRow"||k.type==="tableDelimiterRow"?(a=!0,m=void 0,l=[0,0,0,0],u=[0,n+1,0,0],d&&(d=!1,g={type:"tableBody",start:Object.assign({},k.start),end:Object.assign({},k.end)},y.add(n,0,[["enter",g,t]])),s=k.type==="tableDelimiterRow"?2:g?3:1):s&&(k.type==="data"||k.type==="tableDelimiterMarker"||k.type==="tableDelimiterFiller")?(a=!1,u[2]===0&&(l[1]!==0&&(u[0]=u[1],m=Bu(y,t,l,s,void 0,m),l=[0,0,0,0]),u[2]=n)):k.type==="tableCellDivider"&&(a?a=!1:(l[1]!==0&&(u[0]=u[1],m=Bu(y,t,l,s,void 0,m)),l=u,u=[l[1],n,0,0])):k.type==="tableHead"?(d=!0,f=n):k.type==="tableRow"||k.type==="tableDelimiterRow"?(f=n,l[1]!==0?(u[0]=u[1],m=Bu(y,t,l,s,n,m)):u[1]!==0&&(m=Bu(y,t,u,s,n,m)),s=0):s&&(k.type==="data"||k.type==="tableDelimiterMarker"||k.type==="tableDelimiterFiller")&&(u[3]=n)}for(f!==0&&wk(y,t,f,h,g),y.consume(t.events),n=-1;++n<t.events.length;){const b=t.events[n];b[0]==="enter"&&b[1].type==="table"&&(b[1]._align=TH(t.events,n))}return e}function Bu(e,t,n,a,s,l){const u=a===1?"tableHeader":a===2?"tableDelimiter":"tableData",d="tableContent";n[0]!==0&&(l.end=Object.assign({},eo(t.events,n[0])),e.add(n[0],0,[["exit",l,t]]));const f=eo(t.events,n[1]);if(l={type:u,start:Object.assign({},f),end:Object.assign({},f)},e.add(n[1],0,[["enter",l,t]]),n[2]!==0){const h=eo(t.events,n[2]),g=eo(t.events,n[3]),m={type:d,start:Object.assign({},h),end:Object.assign({},g)};if(e.add(n[2],0,[["enter",m,t]]),a!==2){const y=t.events[n[2]],b=t.events[n[3]];if(y[1].end=Object.assign({},b[1].end),y[1].type="chunkText",y[1].contentType="text",n[3]>n[2]+1){const k=n[2]+1,j=n[3]-n[2]-1;e.add(k,j,[])}}e.add(n[3]+1,0,[["exit",m,t]])}return s!==void 0&&(l.end=Object.assign({},eo(t.events,s)),e.add(s,0,[["exit",l,t]]),l=void 0),l}function wk(e,t,n,a,s){const l=[],u=eo(t.events,n);s&&(s.end=Object.assign({},u),l.push(["exit",s,t])),a.end=Object.assign({},u),l.push(["exit",a,t]),e.add(n+1,0,l)}function eo(e,t){const n=e[t],a=n[0]==="enter"?"start":"end";return n[1][a]}const LH={name:"tasklistCheck",tokenize:DH};function MH(){return{text:{91:LH}}}function DH(e,t,n){const a=this;return s;function s(f){return a.previous!==null||!a._gfmTasklistFirstContentOfListItem?n(f):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(f),e.exit("taskListCheckMarker"),l)}function l(f){return Tt(f)?(e.enter("taskListCheckValueUnchecked"),e.consume(f),e.exit("taskListCheckValueUnchecked"),u):f===88||f===120?(e.enter("taskListCheckValueChecked"),e.consume(f),e.exit("taskListCheckValueChecked"),u):n(f)}function u(f){return f===93?(e.enter("taskListCheckMarker"),e.consume(f),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),d):n(f)}function d(f){return Pe(f)?t(f):it(f)?e.check({tokenize:zH},t,n)(f):n(f)}}function zH(e,t,n){return dt(e,a,"whitespace");function a(s){return s===null?n(s):t(s)}}function $H(e){return $C([lH(),yH(),NH(e),_H(),MH()])}const IH={};function PH(e){const t=this,n=e||IH,a=t.data(),s=a.micromarkExtensions||(a.micromarkExtensions=[]),l=a.fromMarkdownExtensions||(a.fromMarkdownExtensions=[]),u=a.toMarkdownExtensions||(a.toMarkdownExtensions=[]);s.push($H(n)),l.push(aH()),u.push(iH(n))}function UH(e){aN(e,[/\r?\n|\r/g,BH])}function BH(){return{type:"break"}}function FH(){return function(e){UH(e)}}const AN=[{aliases:{sh:"sh",shell:"sh",zsh:"sh",bash:"bash"},load:()=>gt(()=>import("./bash-Yzrsuije.js"),[])},{aliases:{css:"css"},load:()=>gt(()=>import("./css-CLj8gQPS.js"),[])},{aliases:{diff:"diff",patch:"diff"},load:()=>gt(()=>import("./diff-D97Zzqfu.js"),[])},{aliases:{dockerfile:"dockerfile",docker:"dockerfile"},load:()=>gt(()=>import("./dockerfile-BcOcwvcX.js"),[])},{aliases:{go:"go",golang:"go"},load:()=>gt(()=>import("./go-C27-OAKa.js"),[])},{aliases:{html:"html"},load:()=>gt(()=>import("./html-pp8916En.js"),__vite__mapDeps([3,4,5]))},{aliases:{js:"js",javascript:"js"},load:()=>gt(()=>import("./javascript-wDzz0qaB.js"),[])},{aliases:{json:"json"},load:()=>gt(()=>import("./json-Cp-IABpG.js"),[])},{aliases:{jsx:"jsx"},load:()=>gt(()=>import("./jsx-g9-lgVsj.js"),[])},{aliases:{md:"md",markdown:"md"},load:()=>gt(()=>import("./markdown-Cvjx9yec.js"),[])},{aliases:{py:"py",python:"py"},load:()=>gt(()=>import("./python-B6aJPvgy.js"),[])},{aliases:{rust:"rust",rs:"rust"},load:()=>gt(()=>import("./rust-B1yitclQ.js"),[])},{aliases:{solidity:"solidity",sol:"solidity"},load:()=>gt(()=>import("./solidity-rGO070M0.js"),[])},{aliases:{sparql:"sparql"},load:()=>gt(()=>import("./sparql-DVZY-KUA.js"),[])},{aliases:{sql:"sql"},load:()=>gt(()=>import("./sql-BLtJtn59.js"),[])},{aliases:{toml:"toml"},load:()=>gt(()=>import("./toml-vGWfd6FD.js"),[])},{aliases:{tsx:"tsx"},load:()=>gt(()=>import("./tsx-COt5Ahok.js"),[])},{aliases:{ts:"ts",typescript:"ts"},load:()=>gt(()=>import("./typescript-BPQ3VLAy.js"),[])},{aliases:{xml:"xml"},load:()=>gt(()=>import("./xml-B8PEiB0p.js"),[])},{aliases:{yaml:"yaml",yml:"yaml"},load:()=>gt(()=>import("./yaml-Buea-lGh.js"),[])}],TN=Object.freeze(Object.assign({},...AN.map(({aliases:e})=>e)));Object.freeze(Object.keys(TN));function HH(e){if(!e)return null;const t=e.toLowerCase().trim();return TN[t]??null}async function cV(){return(await Promise.all(AN.map(({load:t})=>t()))).flatMap(({default:t})=>t).filter((t,n,a)=>a.findIndex(s=>s.name===t.name)===n)}let Cl=null;function qH(){return Cl||(Cl=gt(()=>import("./shikiHighlighter-Cie8jX4V.js"),[]).then(e=>e.createHighlighter()).catch(e=>{throw Cl=null,e}),Cl)}function GH({code:e,lang:t}){const n=HH(t),[a,s]=w.useState(null),[l,u]=w.useState(!1),f=Vn(m=>m.theme)==="light"?"github-light":"github-dark",h=w.useRef(null);w.useEffect(()=>{if(!n){s(null);return}let m=!1;return qH().then(y=>{if(!m)try{s(y.codeToHtml(e,{lang:n,theme:f}))}catch{s(null)}}).catch(()=>{m||s(null)}),()=>{m=!0}},[e,n,f]),w.useEffect(()=>()=>{h.current&&clearTimeout(h.current)},[]);const g=async()=>{try{await navigator.clipboard.writeText(e),u(!0),h.current&&clearTimeout(h.current),h.current=setTimeout(()=>u(!1),1200)}catch{}};return o.jsxs("div",{className:"v10-md-pre",children:[o.jsx("button",{type:"button",className:"v10-md-copy",onClick:g,"aria-label":l?"Copied":"Copy code",title:l?"Copied":"Copy code",children:l?o.jsx(lO,{size:14,"aria-hidden":"true"}):o.jsx(fO,{size:14,"aria-hidden":"true"})}),o.jsx("span",{className:"v10-md-copy-announce","aria-live":"polite",children:l?"Copied":""}),n&&o.jsx("span",{className:"v10-md-pre-lang","aria-hidden":"true",children:n}),a?o.jsx("div",{className:"v10-md-pre-rendered",dangerouslySetInnerHTML:{__html:a}}):o.jsx("pre",{className:"v10-md-pre-fallback",children:o.jsx("code",{children:e})})]})}function VH(){return e=>{let t="none",n=null;const a=new Set(["img","hr","br"]),s=(d,f)=>{const h=d.children;if(Array.isArray(h))for(let g=0;g<h.length;g++){const m=h[g];if(m.type==="text"&&typeof m.value=="string"&&m.value.trim().length>0)f?t="code":(n={siblings:h,index:g},t="text");else if(m.type==="element"){const y=m.tagName;y==="pre"?(t="code",s(m,!0)):y&&a.has(y)?t="leaf":s(m,f)}}},l=e;s(l,!1);const u={type:"element",tagName:"span",properties:{className:["v10-chat-cursor"]},children:[]};if(t==="text"&&n){const{siblings:d,index:f}=n;d.splice(f+1,0,u)}else t==="leaf"&&Array.isArray(l.children)&&l.children.push(u)}}function WH(e){return e?/^https?:\/\//i.test(e)?"http":/^mailto:/i.test(e)?"mailto":"inert":"inert"}function _N({content:e,streaming:t}){return o.jsx("div",{className:"v10-md",children:o.jsx(EB,{remarkPlugins:[PH,FH],rehypePlugins:t?[VH]:[],components:{img:({src:n,alt:a,title:s})=>o.jsxs("span",{className:"v10-md-image-placeholder",title:s||(typeof n=="string"?n:void 0),children:["[image",a?`: ${a}`:"","]"]}),h1:({children:n})=>o.jsx("h1",{className:"v10-md-h1",children:n}),h2:({children:n})=>o.jsx("h2",{className:"v10-md-h2",children:n}),h3:({children:n})=>o.jsx("h3",{className:"v10-md-h3",children:n}),h4:({children:n})=>o.jsx("h4",{className:"v10-md-h4",children:n}),h5:({children:n})=>o.jsx("h5",{className:"v10-md-h5",children:n}),h6:({children:n})=>o.jsx("h6",{className:"v10-md-h6",children:n}),p:({children:n})=>o.jsx("p",{className:"v10-md-p",children:n}),ul:({children:n})=>o.jsx("ul",{className:"v10-md-ul",children:n}),ol:({children:n})=>o.jsx("ol",{className:"v10-md-ol",children:n}),li:({children:n})=>o.jsx("li",{className:"v10-md-li",children:n}),a:({href:n,children:a})=>{const s=WH(n);return s==="http"?o.jsx("a",{className:"v10-md-link",href:n,target:"_blank",rel:"noopener noreferrer",children:a}):s==="mailto"?o.jsx("a",{className:"v10-md-link",href:n,children:a}):o.jsx("span",{className:"v10-md-link v10-md-link-inert",title:n,children:a})},blockquote:({children:n})=>o.jsx("blockquote",{className:"v10-md-blockquote",children:n}),hr:()=>o.jsx("hr",{className:"v10-md-hr"}),table:({children:n})=>o.jsx("div",{className:"v10-md-table-scroll",children:o.jsx("table",{className:"v10-md-table",children:n})}),thead:({children:n,node:a,...s})=>o.jsx("thead",{className:"v10-md-thead",...s,children:n}),tbody:({children:n,node:a,...s})=>o.jsx("tbody",{className:"v10-md-tbody",...s,children:n}),tr:({children:n,node:a,...s})=>o.jsx("tr",{className:"v10-md-tr",...s,children:n}),th:({children:n,node:a,...s})=>o.jsx("th",{className:"v10-md-th",...s,children:n}),td:({children:n,node:a,...s})=>o.jsx("td",{className:"v10-md-td",...s,children:n}),pre:({children:n,node:a})=>{var l,u,d;const s=(l=a==null?void 0:a.children)==null?void 0:l[0];if((s==null?void 0:s.tagName)==="code"){const f=((d=(u=s.properties)==null?void 0:u.className)==null?void 0:d[0])??"",h=/language-([\w-]+)/.exec(f),g=(s.children??[]).map(m=>(m==null?void 0:m.value)??"").join("").replace(/\n$/,"");return o.jsx(GH,{code:g,lang:h==null?void 0:h[1]})}return o.jsx("pre",{children:n})},code:({children:n})=>o.jsx("code",{className:"v10-md-code",children:n})},children:e})})}const ZH=o.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[o.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),o.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),KH=Ve.lazy(()=>gt(()=>import("./Operations-CVOxbIG3.js"),__vite__mapDeps([6,1])).then(e=>({default:e.OperationsPage}))),YH=Ve.lazy(()=>gt(()=>import("./AgentHub-CSSV1CuQ.js"),[]).then(e=>({default:e.AgentHubPage}))),QH=Ve.lazy(()=>gt(()=>import("./Settings-CAoRacEr.js"),[]).then(e=>({default:e.SettingsPage}))),XH=Ve.lazy(()=>gt(()=>import("./AgentProfilePage-C96h7Jti.js"),[]).then(e=>({default:e.AgentProfilePage}))),JH=Ve.lazy(()=>gt(()=>import("./PublishingConviction-Cq4tU73y.js"),__vite__mapDeps([7,8])).then(e=>({default:e.PublishingConvictionPage}))),e7=Ve.lazy(()=>gt(()=>import("./ConvictionDetailView-DIwJDW-h.js"),__vite__mapDeps([9,8])).then(e=>({default:e.ConvictionDetailView})));function t7(){const{tabs:e,activeTabId:t,setActiveTab:n,closeTab:a}=fn();return o.jsx("div",{className:"v10-center-tabs",children:e.map(s=>o.jsxs("button",{className:`v10-center-tab ${s.id===t?"active":""}`,onClick:()=>n(s.id),children:[o.jsx("span",{className:"v10-center-tab-label",children:s.label}),s.closable&&o.jsx("span",{className:"v10-center-tab-close",onClick:l=>{l.stopPropagation(),a(s.id)},children:ZH})]},s.id))})}const n7=["text/","application/json","application/xml","application/javascript","application/x-yaml"];function r7(e){return n7.some(t=>e.startsWith(t))}function a7({docRef:e,contentType:t}){const{tabs:n,activeTabId:a,closeTab:s}=fn(),l=fn(R=>R.setActiveTab),[u,d]=w.useState(null),[f,h]=w.useState(null),[g,m]=w.useState(""),[y,b]=w.useState(!0),[k,j]=w.useState(null),[N,S]=w.useState("formatted"),A=e.startsWith("urn:dkg:file:"),E=n.find(R=>R.id===a),T=(E==null?void 0:E.label)??"Document",U=()=>{const R=n.find($=>$.id.startsWith("project:"));R&&l(R.id),s(a)};w.useEffect(()=>{let R=!1;if(b(!0),j(null),d(null),h(null),m(""),!A){b(!1);return}const $=e.replace("urn:dkg:file:",""),F=new AbortController;return fetch(Vu($,t||void 0),{headers:Ft(),signal:F.signal}).then(async K=>{if(!K.ok)throw new Error(`HTTP ${K.status}`);const I=K.headers.get("content-type")??"application/octet-stream";if(!R)if(m(I),r7(I)){const H=await K.text();R||(d(H),b(!1))}else if(I.startsWith("image/")){const H=await K.blob();R||(h(URL.createObjectURL(H)),b(!1))}else if(I==="application/pdf"){const H=await K.blob();R||(h(URL.createObjectURL(H)),b(!1))}else{const H=await K.text();R||(d(H),b(!1))}}).catch(K=>{R||(j(K.message),b(!1))}),()=>{R=!0,F.abort()}},[e,A,t]),w.useEffect(()=>{S("formatted")},[e]),w.useEffect(()=>{const R=f;return()=>{R&&URL.revokeObjectURL(R)}},[f]);const _=g.startsWith("image/"),z=g==="application/pdf",q=g.startsWith("text/markdown")||t.startsWith("text/markdown"),D=!y&&!k&&A&&q&&u!==null;return o.jsxs("div",{style:{height:"100%",display:"flex",flexDirection:"column",overflow:"hidden"},children:[o.jsxs("div",{style:{flexShrink:0,display:"flex",alignItems:"center",gap:10,padding:"8px 16px",borderBottom:"1px solid var(--border-subtle)",background:"var(--bg-panel)"},children:[o.jsx("button",{onClick:U,style:{border:"1px solid var(--border-default)",borderRadius:5,background:"none",color:"var(--text-secondary)",fontSize:11,fontWeight:600,padding:"4px 10px",cursor:"pointer",fontFamily:"var(--font-sans)"},children:"← Back to Project"}),o.jsxs("span",{style:{fontSize:13,fontWeight:600,color:"var(--text-primary)"},children:["📄 ",T]}),D&&o.jsx("div",{role:"group","aria-label":"Document view mode",style:{marginLeft:"auto",display:"flex",gap:2,padding:2,border:"1px solid var(--border-default)",borderRadius:6,background:"var(--bg-surface)"},children:["formatted","raw"].map(R=>{const $=N===R;return o.jsx("button",{type:"button","aria-pressed":$,onClick:()=>S(R),style:{border:"none",borderRadius:4,cursor:"pointer",padding:"3px 12px",fontSize:11,fontWeight:600,fontFamily:"var(--font-sans)",color:$?"var(--text-primary)":"var(--text-secondary)",background:$?"var(--bg-elevated)":"transparent"},children:R==="formatted"?"Formatted":"Raw"},R)})})]}),o.jsx("div",{style:{flex:1,overflow:"auto",padding:"20px 24px"},children:A?o.jsxs(o.Fragment,{children:[y&&o.jsx("div",{style:{color:"var(--text-tertiary)",fontSize:12},children:"Loading document..."}),k&&o.jsxs("div",{style:{color:"var(--accent-red)",fontSize:12},children:["Failed to load: ",k]}),!y&&_&&f&&o.jsx("img",{src:f,alt:T,style:{maxWidth:"100%",borderRadius:8}}),!y&&z&&f&&o.jsx("iframe",{src:f,title:T,style:{width:"100%",height:"100%",border:"none",borderRadius:8}}),u!==null&&!_&&!z&&q&&N==="formatted"&&o.jsx("div",{style:{background:"var(--bg-surface)",borderRadius:8,padding:"16px 20px",border:"1px solid var(--border-default)",color:"var(--text-primary)"},children:o.jsx(_N,{content:u})}),u!==null&&!_&&!z&&!(q&&N==="formatted")&&o.jsx("pre",{style:{fontFamily:"var(--font-mono)",fontSize:12,lineHeight:1.7,color:"var(--text-primary)",whiteSpace:"pre-wrap",wordBreak:"break-word",background:"var(--bg-surface)",borderRadius:8,padding:16,border:"1px solid var(--border-default)",margin:0},children:u})]}):o.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:10,height:"100%",color:"var(--text-tertiary)",textAlign:"center"},children:[o.jsx("span",{style:{fontSize:28,opacity:.6},children:"📄"}),o.jsx("span",{style:{fontSize:13,fontWeight:600,color:"var(--text-secondary)"},children:"Source file not available for this document"}),o.jsx("span",{style:{fontSize:12,maxWidth:360,lineHeight:1.6},children:"This document was indexed into the graph without a stored source file, so there is nothing to preview here. You can still explore its extracted entities and relationships in the graph."})]})})]})}function i7(){const e=fn(t=>t.activeTabId);if(e==="dashboard")return o.jsx(oM,{});if(e==="operations")return o.jsx(w.Suspense,{fallback:o.jsx("div",{className:"lazy-spinner",children:"Loading operations..."}),children:o.jsx(KH,{})});if(e==="agent-hub")return o.jsx(w.Suspense,{fallback:o.jsx("div",{className:"lazy-spinner",children:"Loading agent hub..."}),children:o.jsx(YH,{})});if(e==="settings")return o.jsx(w.Suspense,{fallback:o.jsx("div",{className:"lazy-spinner",children:"Loading settings..."}),children:o.jsx(QH,{})});if(e==="conviction")return o.jsx(w.Suspense,{fallback:o.jsx("div",{className:"lazy-spinner",children:"Loading Publisher Conviction..."}),children:o.jsx(JH,{})});if(e==="memory-stack")return o.jsx(p5,{});if(e===Xg)return o.jsx(QP,{});if(e.startsWith("project:")){const t=e.slice(8);return o.jsx(KP,{contextGraphId:t})}if(e.startsWith("conviction:")){const t=e.slice(11);return o.jsx(w.Suspense,{fallback:o.jsx("div",{className:"lazy-spinner",children:"Loading account..."}),children:o.jsx(e7,{accountId:t})})}if(e.startsWith("agent:")){const t=e.slice(6),n=t.indexOf("|");if(n>0){const a=t.slice(0,n),s=t.slice(n+1),l=s.includes(":")?s:`urn:dkg:agent:${s}`;return o.jsx(w.Suspense,{fallback:o.jsx("div",{className:"lazy-spinner",children:"Loading agent…"}),children:o.jsx(XH,{contextGraphId:a,agentUri:l})})}}if(e.startsWith(tv)){const{docRef:t,contentType:n}=UD(e);return o.jsx(a7,{docRef:t,contentType:n})}return e.startsWith("wm:")?o.jsx(Zh,{layer:"wm",contextGraphId:e.slice(3)}):e.startsWith("swm:")?o.jsx(Zh,{layer:"swm",contextGraphId:e.slice(4)}):e.startsWith("vm:")?o.jsx(Zh,{layer:"vm",contextGraphId:e.slice(3)}):o.jsx("div",{className:"v10-view-placeholder",children:o.jsxs("p",{style:{color:"var(--text-tertiary)",fontSize:12},children:['View "',e,'" coming soon.']})})}function s7(){return o.jsxs("div",{className:"v10-panel-center",children:[o.jsx(t7,{}),o.jsx("div",{className:"v10-center-content",children:o.jsx(i7,{})})]})}const o7=["Node Log","Transactions"],l7=o.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:o.jsx("polyline",{points:"6 9 12 15 18 9"})}),c7=o.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[o.jsx("polyline",{points:"15 3 21 3 21 9"}),o.jsx("polyline",{points:"9 21 3 21 3 15"}),o.jsx("line",{x1:"21",y1:"3",x2:"14",y2:"10"}),o.jsx("line",{x1:"3",y1:"21",x2:"10",y2:"14"})]}),u7=o.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[o.jsx("polyline",{points:"4 14 10 14 10 20"}),o.jsx("polyline",{points:"20 10 14 10 14 4"}),o.jsx("line",{x1:"10",y1:"14",x2:"3",y2:"21"}),o.jsx("line",{x1:"21",y1:"3",x2:"14",y2:"10"})]}),d7=/(\x1B\[[0-9;]*[mGKHFJA-Z]|\[[0-9;]*m)/g;function p7(e){return e.replace(d7,"")}function kk(e){const t=e.toLowerCase();return t.includes("error")||t.includes(" err ")||t.includes("[error]")?"error":t.includes("warn")||t.includes("[warn]")?"warn":t.includes("debug")||t.includes("[debug]")||t.includes("trace")?"debug":"info"}const f7={error:"var(--accent-red, #ef4444)",warn:"var(--accent-yellow, #f59e0b)",info:"var(--text-primary)",debug:"var(--text-tertiary)"};function h7(e){const t=w.useRef(null),n=w.useRef(!0);return w.useEffect(()=>{const a=t.current;if(!a)return;const s=()=>{n.current=a.scrollHeight-a.scrollTop-a.clientHeight<40};return a.addEventListener("scroll",s),()=>a.removeEventListener("scroll",s)},[]),w.useEffect(()=>{n.current&&t.current&&(t.current.scrollTop=t.current.scrollHeight)},[e]),t}function m7(){const[e,t]=w.useState([]),[n,a]=w.useState(""),[s,l]=w.useState("all"),u=w.useCallback(()=>{Tn.fetchNodeLog({lines:300,q:n||void 0}).then(({lines:g})=>t((g??[]).map(p7))).catch(()=>{})},[n]);w.useEffect(()=>{u();const g=setInterval(u,3e3);return()=>clearInterval(g)},[u]);const d=e.filter(g=>s==="all"||kk(g)===s),f=d.length>0?d[d.length-1]:"",h=h7(f);return o.jsxs("div",{className:"v10-log-container",children:[o.jsxs("div",{className:"v10-log-toolbar",children:[o.jsx("input",{id:"dkg-node-log-filter",name:"dkg-node-log-filter",type:"text",placeholder:"Filter logs...",className:"v10-log-filter",value:n,onChange:g=>a(g.target.value),"aria-label":"Filter node log lines"}),o.jsxs("select",{id:"dkg-node-log-level",name:"dkg-node-log-level",className:"v10-log-level-select",value:s,onChange:g=>l(g.target.value),"aria-label":"Filter node log level",children:[o.jsx("option",{value:"all",children:"All"}),o.jsx("option",{value:"error",children:"Error"}),o.jsx("option",{value:"warn",children:"Warn"}),o.jsx("option",{value:"info",children:"Info"}),o.jsx("option",{value:"debug",children:"Debug"})]})]}),o.jsxs("div",{className:"v10-log-output",ref:h,children:[d.map((g,m)=>o.jsx("div",{className:"v10-log-line",style:{color:f7[kk(g)]},children:g},m)),d.length===0&&o.jsx("div",{className:"v10-log-line",style:{color:"var(--text-tertiary)"},children:"No log output"})]})]})}const g7=new Set(["publish","publishFromSWM","update","ka-update","verify","reconstruct"]),v7={publish:"#22c55e",publishFromSWM:"#16a34a",update:"#14b8a6","ka-update":"#0d9488",verify:"#8b5cf6",reconstruct:"#fb923c"};function y7(){const[e,t]=w.useState([]),[n,a]=w.useState(null),s=w.useCallback(()=>{const l=String(Date.now()-216e5),u=[...g7].join(",");Tn.fetchOperationsWithPhases({limit:"100",from:l,names:u}).then(d=>{t((d==null?void 0:d.operations)??[])}).catch(()=>{})},[]);return w.useEffect(()=>{s();const l=setInterval(s,1e4);return()=>clearInterval(l)},[s]),e.length===0?o.jsx("div",{style:{padding:"20px 16px",color:"var(--text-tertiary)",fontSize:12},children:"No publish, update, or verify activity in the last 6 hours."}):o.jsx("div",{className:"v10-log-output",style:{overflowY:"auto",flex:1},children:o.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:11},children:[o.jsx("thead",{children:o.jsxs("tr",{style:{borderBottom:"1px solid var(--border-subtle)",color:"var(--text-secondary)",textAlign:"left"},children:[o.jsx("th",{style:{padding:"6px 12px",fontWeight:600},children:"Type"}),o.jsx("th",{style:{padding:"6px 12px",fontWeight:600},children:"ID"}),o.jsx("th",{style:{padding:"6px 12px",fontWeight:600},children:"Status"}),o.jsx("th",{style:{padding:"6px 12px",fontWeight:600},children:"Duration"}),o.jsx("th",{style:{padding:"6px 12px",fontWeight:600},children:"Time"}),o.jsx("th",{style:{padding:"6px 12px",fontWeight:600},children:"Tx Hash"})]})}),o.jsx("tbody",{children:e.map(l=>{const u=(l.phases??[]).find(h=>h.phase==="chain"),d=l.tx_hash??(u==null?void 0:u.tx_hash),f=n===l.operation_id;return o.jsxs(Ve.Fragment,{children:[o.jsxs("tr",{onClick:()=>a(h=>h===l.operation_id?null:l.operation_id),style:{borderBottom:"1px solid var(--border-subtle)",cursor:"pointer",background:f?"rgba(255,255,255,.03)":void 0},children:[o.jsx("td",{style:{padding:"7px 12px",color:v7[l.operation_name]??"var(--text-secondary)",fontWeight:600},children:l.operation_name}),o.jsx("td",{style:{padding:"7px 12px",fontFamily:"var(--font-mono)",color:"var(--text-secondary)"},children:g1(l.operation_id)}),o.jsx("td",{style:{padding:"7px 12px"},children:o.jsx("span",{style:{padding:"2px 6px",borderRadius:4,fontSize:10,fontWeight:600,background:l.status==="success"?"rgba(34,197,94,.15)":l.status==="error"?"rgba(239,68,68,.15)":"rgba(245,158,11,.15)",color:l.status==="success"?"#22c55e":l.status==="error"?"#ef4444":"#f59e0b"},children:l.status})}),o.jsx("td",{style:{padding:"7px 12px",color:"var(--text-secondary)"},children:l.duration_ms!=null?m1(l.duration_ms):"—"}),o.jsx("td",{style:{padding:"7px 12px",color:"var(--text-secondary)"},children:l.started_at?h4(l.started_at):"—"}),o.jsx("td",{style:{padding:"7px 12px",fontFamily:"var(--font-mono)",color:"var(--text-tertiary)",maxWidth:140,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:d?`${d.slice(0,10)}…`:l.status==="success"?o.jsx("span",{style:{fontFamily:"var(--font-sans)",fontStyle:"italic",color:"var(--text-tertiary)"},children:"local"}):"—"})]}),f&&o.jsx("tr",{style:{background:"rgba(0,0,0,.2)"},children:o.jsxs("td",{colSpan:6,style:{padding:"8px 16px"},children:[o.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:16,fontSize:11,color:"var(--text-secondary)"},children:[o.jsxs("span",{children:[o.jsx("b",{children:"ID:"})," ",o.jsx("span",{style:{fontFamily:"var(--font-mono)"},children:l.operation_id})]}),d&&o.jsxs("span",{children:[o.jsx("b",{children:"Tx:"})," ",o.jsx("span",{style:{fontFamily:"var(--font-mono)"},children:d})]}),l.peer_id&&o.jsxs("span",{children:[o.jsx("b",{children:"Peer:"})," ",o.jsx("span",{style:{fontFamily:"var(--font-mono)"},children:g1(l.peer_id)})]}),l.error_message&&o.jsxs("span",{style:{color:"#ef4444"},children:[o.jsx("b",{children:"Error:"})," ",l.error_message]})]}),(l.phases??[]).length>0&&o.jsx("div",{style:{marginTop:8,display:"flex",gap:6,flexWrap:"wrap"},children:l.phases.map(h=>o.jsxs("span",{style:{padding:"2px 8px",borderRadius:4,fontSize:10,fontWeight:600,background:"rgba(255,255,255,.06)",color:"var(--text-secondary)"},children:[h.phase," ",h.duration_ms!=null?m1(h.duration_ms):""]},h.phase))})]})})]},l.operation_id)})})]})})}function b7(){const{bottomCollapsed:e,toggleBottom:t,bottomMaximised:n,toggleBottomMaximised:a,bottomHeight:s,setBottomHeight:l}=Vn(),[u,d]=w.useState("Node Log"),f=w.useRef(null),h=w.useRef(s);h.current=s,w.useEffect(()=>{const m=f.current;if(!m)return;let y=0;const b=N=>{const S=y-N.clientY;y=N.clientY,l(h.current+S)},k=()=>{document.removeEventListener("mousemove",b),document.removeEventListener("mouseup",k),document.body.style.cursor="",document.body.style.userSelect="",m.classList.remove("active")},j=N=>{N.preventDefault(),y=N.clientY,document.addEventListener("mousemove",b),document.addEventListener("mouseup",k),document.body.style.cursor="row-resize",document.body.style.userSelect="none",m.classList.add("active")};return m.addEventListener("mousedown",j),()=>m.removeEventListener("mousedown",j)},[l]);const g=e?void 0:n?"80vh":Math.min(s,sd());return o.jsxs("div",{className:`v10-panel-bottom ${e?"collapsed":""} ${n?"maximised":""}`,style:e?void 0:{height:g},children:[!e&&!n&&o.jsx("div",{className:"v10-resize-handle-v",ref:f,title:"Drag to resize"}),o.jsxs("div",{className:"v10-bottom-tabs",children:[o7.map(m=>o.jsx("button",{className:`v10-bottom-tab ${m===u?"active":""}`,onClick:()=>{d(m),e&&t()},children:m},m)),o.jsx("div",{style:{flex:1}}),o.jsx("button",{className:"v10-bottom-toggle",onClick:a,title:n?"Restore":"Maximise",style:{display:e?"none":void 0},children:n?u7:c7}),o.jsx("button",{className:"v10-bottom-toggle",onClick:t,title:e?"Expand":"Collapse",children:o.jsx("span",{style:{transform:e?"rotate(180deg)":"none",display:"flex",transition:"transform 0.15s"},children:l7})})]}),!e&&o.jsxs("div",{className:"v10-bottom-content",children:[u==="Node Log"&&o.jsx(m7,{}),u==="Transactions"&&o.jsx(y7,{})]})]})}function Sk(e){const t=Math.floor(e/1e3);if(t<60)return`${t}s`;const n=Math.floor(t/60);return n<60?`${n}m`:`${Math.floor(n/60)}h ${n%60}m`}function Cd(e){if(e==null||e==="")return"";const t=e instanceof Date?e:new Date(e);return Number.isNaN(t.valueOf())?typeof e=="string"?e:"":t.toLocaleString([],{dateStyle:"medium",timeStyle:"short"})}function rg(e){if(e==null||e==="")return;const t=e instanceof Date?e:new Date(e);if(!Number.isNaN(t.valueOf()))return t.toISOString()}function x7(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function w7(e){var n;const t=((n=e.split(".").pop())==null?void 0:n.toLowerCase())??"";return["md","txt","csv","json","xml","yaml","yml"].includes(t)?"TXT":["pdf"].includes(t)?"PDF":["docx","doc"].includes(t)?"DOC":["png","jpg","jpeg","webp"].includes(t)?"IMG":["py","ts","js","tsx","jsx","java","go","rs","c","cpp"].includes(t)?"CODE":"FILE"}function ag(e,t){var n;return((n=e.find(a=>a.id===t))==null?void 0:n.name)??t}function k7(e){return e.startsWith("did:dkg:context-graph:")?e:`did:dkg:context-graph:${e}`}function S7(e){return String(e??"").replace(/[\u0000-\u001F\u007F]/g," ").replace(/\s+/g," ").trim()}function RN(e){if(e.length===0)return"";const t=e.map(n=>n.fileName);return t.length<=2?`Attached ${t.join(" and ")}.`:`Attached ${t[0]} and ${t.length-1} more files.`}function ON(e){return e.status==="queued"||e.status==="completed"||e.status==="skipped"}function LN(e){return e.name.trim()}function j7(e){if(e.status!=="completed"||!e.result)return null;const t=e.result.extraction.mdIntermediateHash,n=t??(e.result.detectedContentType==="text/markdown"?e.result.fileHash:void 0);return{id:e.id,fileName:LN(e.file),contextGraphId:e.contextGraphId,assertionName:e.assertionName,assertionUri:e.result.assertionUri,fileHash:e.result.fileHash,detectedContentType:e.result.detectedContentType,rootEntity:e.result.rootEntity,extractionStatus:"completed",tripleCount:e.result.extraction.tripleCount??e.result.extraction.triplesWritten,...t?{mdIntermediateHash:t}:{},...n?{markdownHash:n,markdownForm:`urn:dkg:file:${n}`}:{}}}function C7(e){const t=[];return{results:e.flatMap(a=>{if(a.status!=="skipped"||!a.result)return[];t.push(a.id);const s=a.result,l=s.extraction;return[{id:a.id,fileName:LN(a.file),contextGraphId:a.contextGraphId,assertionName:a.assertionName,assertionUri:s.assertionUri,fileHash:s.fileHash,detectedContentType:s.detectedContentType,extractionStatus:"skipped",pipelineUsed:l.pipelineUsed??null,tripleCount:l.tripleCount??l.triplesWritten??0,...s.rootEntity?{rootEntity:s.rootEntity}:{},...l.mdIntermediateHash?{mdIntermediateHash:l.mdIntermediateHash}:{},...l.error?{error:l.error}:{}}]}),deliveredDraftIds:t}}function MN(e){return e.length===0?"":e.length===1?`Attachment import result: ${S7(e[0].fileName)}.`:`Attached ${e.length} document import results.`}function N7(e,t){const n=[RN(e),MN(t)].filter(a=>a.length>0).map(a=>a.replace(/\.$/,""));return n.length?`${n.join("; ")}.`:""}function E7(e,t,n){const a=[];if(t){const s=ag(e,t);a.push({key:"target_context_graph",label:"Target context graph id",value:t}),a.push({key:"target_context_graph_uri",label:"Target context graph URI",value:k7(t)}),a.push({key:"target_context_graph_name",label:"Target context graph name",value:s})}return n!=null&&n.agentAddress&&a.push({key:"current_agent_address",label:"Current agent address",value:n.agentAddress}),n!=null&&n.agentDid&&a.push({key:"current_agent_did",label:"Current agent DID",value:n.agentDid}),n!=null&&n.peerId&&a.push({key:"current_agent_peer_id",label:"Current agent peer ID",value:n.peerId}),a}const A7="https://docs.openclaw.ai/",T7="https://github.com/openclaw/openclaw/releases",Xi="__add_agent__",_7=["openclaw"];function R7(e,t){const n=t instanceof Error?t.message:String(t??"Unknown error");if(t instanceof wm){if(t.code==="HERMES_BRIDGE_RESPONSE_TIMEOUT")return`${e.name} bridge response timed out.`;if(t.code==="HERMES_GATEWAY_RESPONSE_TIMEOUT")return`${e.name} gateway response timed out.`;if(t.code==="OPENCLAW_BRIDGE_RESPONSE_TIMEOUT")return`${e.name} bridge response timed out.`;if(t.code==="OPENCLAW_GATEWAY_RESPONSE_TIMEOUT")return`${e.name} gateway response timed out.`;if(t.code==="SWM_SYNC_TIMEOUT"||t.source==="background-sync")return"Background sync timed out. The chat request was not marked as failed by the local-agent bridge."}return/OpenClaw bridge unreachable/i.test(n)?`${e.name} is unavailable right now.`:/Hermes bridge unreachable/i.test(n)?`${e.name} is unavailable right now.`:/gateway response timeout/i.test(n)?`${e.name} gateway response timed out.`:/bridge response timeout/i.test(n)||/aborted due to timeout/i.test(n)?`${e.name} bridge response timed out.`:/Agent response timeout/i.test(n)?`${e.name} took too long to respond.`:/Agent returned no text response/i.test(n)||/\(no response\)/i.test(n)?`${e.name} did not return a text reply.`:n}let O7=0;function L7(e,t,n){const a=e.trim();return a?a===t?!0:n==="Request cancelled."&&a===n:!1}function M7(e,t,n,a){return e&&L7(e,t,n)?{content:e,synthesized:!0}:e?a==="hermes"?{content:e,failureNotice:t,synthesized:!1}:{content:e,synthesized:!1}:{content:"",failureNotice:t,synthesized:!0}}function jk(e,t=""){const n=e.author.toLowerCase(),a=n.includes("assistant")||n.includes("agent")?"assistant":"user",s=typeof e.failureReason=="string"&&e.failureReason.trim()?e.failureReason.trim():void 0,l=a==="assistant"&&(e.persistStatus==="failed"||!!s),u=`Error: ${s??"The local agent turn failed."}`,d=l?M7(e.text,u,s,t):null,f=(d==null?void 0:d.content)??(e.text||RN(e.attachmentRefs??[])),h=!!e.text;return{id:e.uri||`local-history:${++O7}`,uri:e.uri,turnId:e.turnId,role:a,content:f,ts:Cd(e.ts),tsRaw:rg(e.ts),attachments:e.attachmentRefs,failureNotice:d==null?void 0:d.failureNotice,synthesized:(d==null?void 0:d.synthesized)??!h}}function D7(e){return e.turnId?`turn:${e.turnId}:${e.role}`:e.uri??`${e.role}:${e.ts??""}:${e.content}`}function Ck(e,t){const n=new Set,a=[];for(const s of[...t,...e]){const l=D7(s);n.has(l)||(n.add(l),a.push(s))}return a}function Nk(e,t,n){const a=typeof n=="string"&&n.trim()?n.trim():t;return!a||a===t?e:e.map(s=>s.turnId===t?{...s,turnId:a}:s)}function Ek(e){return e.replace(/\r\n/g,`
1652
+ `))}function f(b,k,j,N){const S=j.enter("tableCell"),A=j.enter("phrasing"),E=j.containerPhrasing(b,{...N,before:l,after:l});return A(),S(),E}function h(b,k){return fF(b,{align:k,alignDelimiters:a,padding:n,stringLength:s})}function g(b,k,j){const N=b.children;let S=-1;const A=[],E=k.enter("table");for(;++S<N.length;)A[S]=m(N[S],k,j);return E(),A}function m(b,k,j){const N=b.children;let S=-1;const A=[],E=k.enter("tableRow");for(;++S<N.length;)A[S]=f(N[S],b,k,j);return E(),A}function y(b,k,j){let N=bN.inlineCode(b,k,j);return j.stack.includes("tableCell")&&(N=N.replace(/\|/g,"\\$&")),N}}function eH(){return{exit:{taskListCheckValueChecked:xk,taskListCheckValueUnchecked:xk,paragraph:nH}}}function tH(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:rH}}}function xk(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function nH(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const a=n.children[0];if(a&&a.type==="text"){const s=t.children;let l=-1,u;for(;++l<s.length;){const d=s[l];if(d.type==="paragraph"){u=d;break}}u===n&&(a.value=a.value.slice(1),a.value.length===0?n.children.shift():n.position&&a.position&&typeof a.position.start.offset=="number"&&(a.position.start.column++,a.position.start.offset++,n.position.start=Object.assign({},a.position.start)))}}this.exit(e)}function rH(e,t,n,a){const s=e.children[0],l=typeof e.checked=="boolean"&&s&&s.type==="paragraph",u="["+(e.checked?"x":" ")+"] ",d=n.createTracker(a);l&&d.move(u);let f=bN.listItem(e,t,n,{...a,...d.current()});return l&&(f=f.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,h)),f;function h(g){return g+u}}function aH(){return[zB(),rF(),oF(),WF(),eH()]}function iH(e){return{extensions:[$B(),aF(e),lF(),JF(e),tH()]}}const sH={tokenize:pH,partial:!0},xN={tokenize:fH,partial:!0},wN={tokenize:hH,partial:!0},kN={tokenize:mH,partial:!0},oH={tokenize:gH,partial:!0},SN={name:"wwwAutolink",tokenize:uH,previous:CN},jN={name:"protocolAutolink",tokenize:dH,previous:NN},Ba={name:"emailAutolink",tokenize:cH,previous:EN},la={};function lH(){return{text:la}}let Zi=48;for(;Zi<123;)la[Zi]=Ba,Zi++,Zi===58?Zi=65:Zi===91&&(Zi=97);la[43]=Ba;la[45]=Ba;la[46]=Ba;la[95]=Ba;la[72]=[Ba,jN];la[104]=[Ba,jN];la[87]=[Ba,SN];la[119]=[Ba,SN];function cH(e,t,n){const a=this;let s,l;return u;function u(m){return!ng(m)||!EN.call(a,a.previous)||Ov(a.events)?n(m):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),d(m))}function d(m){return ng(m)?(e.consume(m),d):m===64?(e.consume(m),f):n(m)}function f(m){return m===46?e.check(oH,g,h)(m):m===45||m===95||An(m)?(l=!0,e.consume(m),f):g(m)}function h(m){return e.consume(m),s=!0,f}function g(m){return l&&s&&Dn(a.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(m)):n(m)}}function uH(e,t,n){const a=this;return s;function s(u){return u!==87&&u!==119||!CN.call(a,a.previous)||Ov(a.events)?n(u):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(sH,e.attempt(xN,e.attempt(wN,l),n),n)(u))}function l(u){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(u)}}function dH(e,t,n){const a=this;let s="",l=!1;return u;function u(m){return(m===72||m===104)&&NN.call(a,a.previous)&&!Ov(a.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),s+=String.fromCodePoint(m),e.consume(m),d):n(m)}function d(m){if(Dn(m)&&s.length<5)return s+=String.fromCodePoint(m),e.consume(m),d;if(m===58){const y=s.toLowerCase();if(y==="http"||y==="https")return e.consume(m),f}return n(m)}function f(m){return m===47?(e.consume(m),l?h:(l=!0,f)):n(m)}function h(m){return m===null||wd(m)||Tt(m)||as(m)||Wd(m)?n(m):e.attempt(xN,e.attempt(wN,g),n)(m)}function g(m){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(m)}}function pH(e,t,n){let a=0;return s;function s(u){return(u===87||u===119)&&a<3?(a++,e.consume(u),s):u===46&&a===3?(e.consume(u),l):n(u)}function l(u){return u===null?n(u):t(u)}}function fH(e,t,n){let a,s,l;return u;function u(h){return h===46||h===95?e.check(kN,f,d)(h):h===null||Tt(h)||as(h)||h!==45&&Wd(h)?f(h):(l=!0,e.consume(h),u)}function d(h){return h===95?a=!0:(s=a,a=void 0),e.consume(h),u}function f(h){return s||a||!l?n(h):t(h)}}function hH(e,t){let n=0,a=0;return s;function s(u){return u===40?(n++,e.consume(u),s):u===41&&a<n?l(u):u===33||u===34||u===38||u===39||u===41||u===42||u===44||u===46||u===58||u===59||u===60||u===63||u===93||u===95||u===126?e.check(kN,t,l)(u):u===null||Tt(u)||as(u)?t(u):(e.consume(u),s)}function l(u){return u===41&&a++,e.consume(u),s}}function mH(e,t,n){return a;function a(d){return d===33||d===34||d===39||d===41||d===42||d===44||d===46||d===58||d===59||d===63||d===95||d===126?(e.consume(d),a):d===38?(e.consume(d),l):d===93?(e.consume(d),s):d===60||d===null||Tt(d)||as(d)?t(d):n(d)}function s(d){return d===null||d===40||d===91||Tt(d)||as(d)?t(d):a(d)}function l(d){return Dn(d)?u(d):n(d)}function u(d){return d===59?(e.consume(d),a):Dn(d)?(e.consume(d),u):n(d)}}function gH(e,t,n){return a;function a(l){return e.consume(l),s}function s(l){return An(l)?n(l):t(l)}}function CN(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Tt(e)}function NN(e){return!Dn(e)}function EN(e){return!(e===47||ng(e))}function ng(e){return e===43||e===45||e===46||e===95||An(e)}function Ov(e){let t=e.length,n=!1;for(;t--;){const a=e[t][1];if((a.type==="labelLink"||a.type==="labelImage")&&!a._balanced){n=!0;break}if(a._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const vH={tokenize:CH,partial:!0};function yH(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:kH,continuation:{tokenize:SH},exit:jH}},text:{91:{name:"gfmFootnoteCall",tokenize:wH},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:bH,resolveTo:xH}}}}function bH(e,t,n){const a=this;let s=a.events.length;const l=a.parser.gfmFootnotes||(a.parser.gfmFootnotes=[]);let u;for(;s--;){const f=a.events[s][1];if(f.type==="labelImage"){u=f;break}if(f.type==="gfmFootnoteCall"||f.type==="labelLink"||f.type==="label"||f.type==="image"||f.type==="link")break}return d;function d(f){if(!u||!u._balanced)return n(f);const h=Ur(a.sliceSerialize({start:u.end,end:a.now()}));return h.codePointAt(0)!==94||!l.includes(h.slice(1))?n(f):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(f),e.exit("gfmFootnoteCallLabelMarker"),t(f))}}function xH(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const a={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},s={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};s.end.column++,s.end.offset++,s.end._bufferIndex++;const l={type:"gfmFootnoteCallString",start:Object.assign({},s.end),end:Object.assign({},e[e.length-1][1].start)},u={type:"chunkString",contentType:"string",start:Object.assign({},l.start),end:Object.assign({},l.end)},d=[e[n+1],e[n+2],["enter",a,t],e[n+3],e[n+4],["enter",s,t],["exit",s,t],["enter",l,t],["enter",u,t],["exit",u,t],["exit",l,t],e[e.length-2],e[e.length-1],["exit",a,t]];return e.splice(n,e.length-n+1,...d),e}function wH(e,t,n){const a=this,s=a.parser.gfmFootnotes||(a.parser.gfmFootnotes=[]);let l=0,u;return d;function d(m){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(m),e.exit("gfmFootnoteCallLabelMarker"),f}function f(m){return m!==94?n(m):(e.enter("gfmFootnoteCallMarker"),e.consume(m),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",h)}function h(m){if(l>999||m===93&&!u||m===null||m===91||Tt(m))return n(m);if(m===93){e.exit("chunkString");const y=e.exit("gfmFootnoteCallString");return s.includes(Ur(a.sliceSerialize(y)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(m),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(m)}return Tt(m)||(u=!0),l++,e.consume(m),m===92?g:h}function g(m){return m===91||m===92||m===93?(e.consume(m),l++,h):h(m)}}function kH(e,t,n){const a=this,s=a.parser.gfmFootnotes||(a.parser.gfmFootnotes=[]);let l,u=0,d;return f;function f(k){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(k),e.exit("gfmFootnoteDefinitionLabelMarker"),h}function h(k){return k===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(k),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",g):n(k)}function g(k){if(u>999||k===93&&!d||k===null||k===91||Tt(k))return n(k);if(k===93){e.exit("chunkString");const j=e.exit("gfmFootnoteDefinitionLabelString");return l=Ur(a.sliceSerialize(j)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(k),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),y}return Tt(k)||(d=!0),u++,e.consume(k),k===92?m:g}function m(k){return k===91||k===92||k===93?(e.consume(k),u++,g):g(k)}function y(k){return k===58?(e.enter("definitionMarker"),e.consume(k),e.exit("definitionMarker"),s.includes(l)||s.push(l),dt(e,b,"gfmFootnoteDefinitionWhitespace")):n(k)}function b(k){return t(k)}}function SH(e,t,n){return e.check(rc,t,e.attempt(vH,t,n))}function jH(e){e.exit("gfmFootnoteDefinition")}function CH(e,t,n){const a=this;return dt(e,s,"gfmFootnoteDefinitionIndent",5);function s(l){const u=a.events[a.events.length-1];return u&&u[1].type==="gfmFootnoteDefinitionIndent"&&u[2].sliceSerialize(u[1],!0).length===4?t(l):n(l)}}function NH(e){let n=(e||{}).singleTilde;const a={name:"strikethrough",tokenize:l,resolveAll:s};return n==null&&(n=!0),{text:{126:a},insideSpan:{null:[a]},attentionMarkers:{null:[126]}};function s(u,d){let f=-1;for(;++f<u.length;)if(u[f][0]==="enter"&&u[f][1].type==="strikethroughSequenceTemporary"&&u[f][1]._close){let h=f;for(;h--;)if(u[h][0]==="exit"&&u[h][1].type==="strikethroughSequenceTemporary"&&u[h][1]._open&&u[f][1].end.offset-u[f][1].start.offset===u[h][1].end.offset-u[h][1].start.offset){u[f][1].type="strikethroughSequence",u[h][1].type="strikethroughSequence";const g={type:"strikethrough",start:Object.assign({},u[h][1].start),end:Object.assign({},u[f][1].end)},m={type:"strikethroughText",start:Object.assign({},u[h][1].end),end:Object.assign({},u[f][1].start)},y=[["enter",g,d],["enter",u[h][1],d],["exit",u[h][1],d],["enter",m,d]],b=d.parser.constructs.insideSpan.null;b&&cr(y,y.length,0,Zd(b,u.slice(h+1,f),d)),cr(y,y.length,0,[["exit",m,d],["enter",u[f][1],d],["exit",u[f][1],d],["exit",g,d]]),cr(u,h-1,f-h+3,y),f=h+y.length-2;break}}for(f=-1;++f<u.length;)u[f][1].type==="strikethroughSequenceTemporary"&&(u[f][1].type="data");return u}function l(u,d,f){const h=this.previous,g=this.events;let m=0;return y;function y(k){return h===126&&g[g.length-1][1].type!=="characterEscape"?f(k):(u.enter("strikethroughSequenceTemporary"),b(k))}function b(k){const j=ho(h);if(k===126)return m>1?f(k):(u.consume(k),m++,b);if(m<2&&!n)return f(k);const N=u.exit("strikethroughSequenceTemporary"),S=ho(k);return N._open=!S||S===2&&!!j,N._close=!j||j===2&&!!S,d(k)}}}class EH{constructor(){this.map=[]}add(t,n,a){AH(this,t,n,a)}consume(t){if(this.map.sort(function(l,u){return l[0]-u[0]}),this.map.length===0)return;let n=this.map.length;const a=[];for(;n>0;)n-=1,a.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];a.push(t.slice()),t.length=0;let s=a.pop();for(;s;){for(const l of s)t.push(l);s=a.pop()}this.map.length=0}}function AH(e,t,n,a){let s=0;if(!(n===0&&a.length===0)){for(;s<e.map.length;){if(e.map[s][0]===t){e.map[s][1]+=n,e.map[s][2].push(...a);return}s+=1}e.map.push([t,n,a])}}function TH(e,t){let n=!1;const a=[];for(;t<e.length;){const s=e[t];if(n){if(s[0]==="enter")s[1].type==="tableContent"&&a.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(s[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const l=a.length-1;a[l]=a[l]==="left"?"center":"right"}}else if(s[1].type==="tableDelimiterRow")break}else s[0]==="enter"&&s[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return a}function _H(){return{flow:{null:{name:"table",tokenize:RH,resolveAll:OH}}}}function RH(e,t,n){const a=this;let s=0,l=0,u;return d;function d(R){let $=a.events.length-1;for(;$>-1;){const I=a.events[$][1].type;if(I==="lineEnding"||I==="linePrefix")$--;else break}const F=$>-1?a.events[$][1].type:null,K=F==="tableHead"||F==="tableRow"?_:f;return K===_&&a.parser.lazy[a.now().line]?n(R):K(R)}function f(R){return e.enter("tableHead"),e.enter("tableRow"),h(R)}function h(R){return R===124||(u=!0,l+=1),g(R)}function g(R){return R===null?n(R):Pe(R)?l>1?(l=0,a.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(R),e.exit("lineEnding"),b):n(R):it(R)?dt(e,g,"whitespace")(R):(l+=1,u&&(u=!1,s+=1),R===124?(e.enter("tableCellDivider"),e.consume(R),e.exit("tableCellDivider"),u=!0,g):(e.enter("data"),m(R)))}function m(R){return R===null||R===124||Tt(R)?(e.exit("data"),g(R)):(e.consume(R),R===92?y:m)}function y(R){return R===92||R===124?(e.consume(R),m):m(R)}function b(R){return a.interrupt=!1,a.parser.lazy[a.now().line]?n(R):(e.enter("tableDelimiterRow"),u=!1,it(R)?dt(e,k,"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(R):k(R))}function k(R){return R===45||R===58?N(R):R===124?(u=!0,e.enter("tableCellDivider"),e.consume(R),e.exit("tableCellDivider"),j):U(R)}function j(R){return it(R)?dt(e,N,"whitespace")(R):N(R)}function N(R){return R===58?(l+=1,u=!0,e.enter("tableDelimiterMarker"),e.consume(R),e.exit("tableDelimiterMarker"),S):R===45?(l+=1,S(R)):R===null||Pe(R)?T(R):U(R)}function S(R){return R===45?(e.enter("tableDelimiterFiller"),A(R)):U(R)}function A(R){return R===45?(e.consume(R),A):R===58?(u=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(R),e.exit("tableDelimiterMarker"),E):(e.exit("tableDelimiterFiller"),E(R))}function E(R){return it(R)?dt(e,T,"whitespace")(R):T(R)}function T(R){return R===124?k(R):R===null||Pe(R)?!u||s!==l?U(R):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(R)):U(R)}function U(R){return n(R)}function _(R){return e.enter("tableRow"),z(R)}function z(R){return R===124?(e.enter("tableCellDivider"),e.consume(R),e.exit("tableCellDivider"),z):R===null||Pe(R)?(e.exit("tableRow"),t(R)):it(R)?dt(e,z,"whitespace")(R):(e.enter("data"),q(R))}function q(R){return R===null||R===124||Tt(R)?(e.exit("data"),z(R)):(e.consume(R),R===92?D:q)}function D(R){return R===92||R===124?(e.consume(R),q):q(R)}}function OH(e,t){let n=-1,a=!0,s=0,l=[0,0,0,0],u=[0,0,0,0],d=!1,f=0,h,g,m;const y=new EH;for(;++n<e.length;){const b=e[n],k=b[1];b[0]==="enter"?k.type==="tableHead"?(d=!1,f!==0&&(wk(y,t,f,h,g),g=void 0,f=0),h={type:"table",start:Object.assign({},k.start),end:Object.assign({},k.end)},y.add(n,0,[["enter",h,t]])):k.type==="tableRow"||k.type==="tableDelimiterRow"?(a=!0,m=void 0,l=[0,0,0,0],u=[0,n+1,0,0],d&&(d=!1,g={type:"tableBody",start:Object.assign({},k.start),end:Object.assign({},k.end)},y.add(n,0,[["enter",g,t]])),s=k.type==="tableDelimiterRow"?2:g?3:1):s&&(k.type==="data"||k.type==="tableDelimiterMarker"||k.type==="tableDelimiterFiller")?(a=!1,u[2]===0&&(l[1]!==0&&(u[0]=u[1],m=Bu(y,t,l,s,void 0,m),l=[0,0,0,0]),u[2]=n)):k.type==="tableCellDivider"&&(a?a=!1:(l[1]!==0&&(u[0]=u[1],m=Bu(y,t,l,s,void 0,m)),l=u,u=[l[1],n,0,0])):k.type==="tableHead"?(d=!0,f=n):k.type==="tableRow"||k.type==="tableDelimiterRow"?(f=n,l[1]!==0?(u[0]=u[1],m=Bu(y,t,l,s,n,m)):u[1]!==0&&(m=Bu(y,t,u,s,n,m)),s=0):s&&(k.type==="data"||k.type==="tableDelimiterMarker"||k.type==="tableDelimiterFiller")&&(u[3]=n)}for(f!==0&&wk(y,t,f,h,g),y.consume(t.events),n=-1;++n<t.events.length;){const b=t.events[n];b[0]==="enter"&&b[1].type==="table"&&(b[1]._align=TH(t.events,n))}return e}function Bu(e,t,n,a,s,l){const u=a===1?"tableHeader":a===2?"tableDelimiter":"tableData",d="tableContent";n[0]!==0&&(l.end=Object.assign({},eo(t.events,n[0])),e.add(n[0],0,[["exit",l,t]]));const f=eo(t.events,n[1]);if(l={type:u,start:Object.assign({},f),end:Object.assign({},f)},e.add(n[1],0,[["enter",l,t]]),n[2]!==0){const h=eo(t.events,n[2]),g=eo(t.events,n[3]),m={type:d,start:Object.assign({},h),end:Object.assign({},g)};if(e.add(n[2],0,[["enter",m,t]]),a!==2){const y=t.events[n[2]],b=t.events[n[3]];if(y[1].end=Object.assign({},b[1].end),y[1].type="chunkText",y[1].contentType="text",n[3]>n[2]+1){const k=n[2]+1,j=n[3]-n[2]-1;e.add(k,j,[])}}e.add(n[3]+1,0,[["exit",m,t]])}return s!==void 0&&(l.end=Object.assign({},eo(t.events,s)),e.add(s,0,[["exit",l,t]]),l=void 0),l}function wk(e,t,n,a,s){const l=[],u=eo(t.events,n);s&&(s.end=Object.assign({},u),l.push(["exit",s,t])),a.end=Object.assign({},u),l.push(["exit",a,t]),e.add(n+1,0,l)}function eo(e,t){const n=e[t],a=n[0]==="enter"?"start":"end";return n[1][a]}const LH={name:"tasklistCheck",tokenize:DH};function MH(){return{text:{91:LH}}}function DH(e,t,n){const a=this;return s;function s(f){return a.previous!==null||!a._gfmTasklistFirstContentOfListItem?n(f):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(f),e.exit("taskListCheckMarker"),l)}function l(f){return Tt(f)?(e.enter("taskListCheckValueUnchecked"),e.consume(f),e.exit("taskListCheckValueUnchecked"),u):f===88||f===120?(e.enter("taskListCheckValueChecked"),e.consume(f),e.exit("taskListCheckValueChecked"),u):n(f)}function u(f){return f===93?(e.enter("taskListCheckMarker"),e.consume(f),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),d):n(f)}function d(f){return Pe(f)?t(f):it(f)?e.check({tokenize:zH},t,n)(f):n(f)}}function zH(e,t,n){return dt(e,a,"whitespace");function a(s){return s===null?n(s):t(s)}}function $H(e){return $C([lH(),yH(),NH(e),_H(),MH()])}const IH={};function PH(e){const t=this,n=e||IH,a=t.data(),s=a.micromarkExtensions||(a.micromarkExtensions=[]),l=a.fromMarkdownExtensions||(a.fromMarkdownExtensions=[]),u=a.toMarkdownExtensions||(a.toMarkdownExtensions=[]);s.push($H(n)),l.push(aH()),u.push(iH(n))}function UH(e){aN(e,[/\r?\n|\r/g,BH])}function BH(){return{type:"break"}}function FH(){return function(e){UH(e)}}const AN=[{aliases:{sh:"sh",shell:"sh",zsh:"sh",bash:"bash"},load:()=>gt(()=>import("./bash-Yzrsuije.js"),[])},{aliases:{css:"css"},load:()=>gt(()=>import("./css-CLj8gQPS.js"),[])},{aliases:{diff:"diff",patch:"diff"},load:()=>gt(()=>import("./diff-D97Zzqfu.js"),[])},{aliases:{dockerfile:"dockerfile",docker:"dockerfile"},load:()=>gt(()=>import("./dockerfile-BcOcwvcX.js"),[])},{aliases:{go:"go",golang:"go"},load:()=>gt(()=>import("./go-C27-OAKa.js"),[])},{aliases:{html:"html"},load:()=>gt(()=>import("./html-pp8916En.js"),__vite__mapDeps([3,4,5]))},{aliases:{js:"js",javascript:"js"},load:()=>gt(()=>import("./javascript-wDzz0qaB.js"),[])},{aliases:{json:"json"},load:()=>gt(()=>import("./json-Cp-IABpG.js"),[])},{aliases:{jsx:"jsx"},load:()=>gt(()=>import("./jsx-g9-lgVsj.js"),[])},{aliases:{md:"md",markdown:"md"},load:()=>gt(()=>import("./markdown-Cvjx9yec.js"),[])},{aliases:{py:"py",python:"py"},load:()=>gt(()=>import("./python-B6aJPvgy.js"),[])},{aliases:{rust:"rust",rs:"rust"},load:()=>gt(()=>import("./rust-B1yitclQ.js"),[])},{aliases:{solidity:"solidity",sol:"solidity"},load:()=>gt(()=>import("./solidity-rGO070M0.js"),[])},{aliases:{sparql:"sparql"},load:()=>gt(()=>import("./sparql-DVZY-KUA.js"),[])},{aliases:{sql:"sql"},load:()=>gt(()=>import("./sql-BLtJtn59.js"),[])},{aliases:{toml:"toml"},load:()=>gt(()=>import("./toml-vGWfd6FD.js"),[])},{aliases:{tsx:"tsx"},load:()=>gt(()=>import("./tsx-COt5Ahok.js"),[])},{aliases:{ts:"ts",typescript:"ts"},load:()=>gt(()=>import("./typescript-BPQ3VLAy.js"),[])},{aliases:{xml:"xml"},load:()=>gt(()=>import("./xml-B8PEiB0p.js"),[])},{aliases:{yaml:"yaml",yml:"yaml"},load:()=>gt(()=>import("./yaml-Buea-lGh.js"),[])}],TN=Object.freeze(Object.assign({},...AN.map(({aliases:e})=>e)));Object.freeze(Object.keys(TN));function HH(e){if(!e)return null;const t=e.toLowerCase().trim();return TN[t]??null}async function cV(){return(await Promise.all(AN.map(({load:t})=>t()))).flatMap(({default:t})=>t).filter((t,n,a)=>a.findIndex(s=>s.name===t.name)===n)}let Cl=null;function qH(){return Cl||(Cl=gt(()=>import("./shikiHighlighter-C6lRYd1O.js"),[]).then(e=>e.createHighlighter()).catch(e=>{throw Cl=null,e}),Cl)}function GH({code:e,lang:t}){const n=HH(t),[a,s]=w.useState(null),[l,u]=w.useState(!1),f=Vn(m=>m.theme)==="light"?"github-light":"github-dark",h=w.useRef(null);w.useEffect(()=>{if(!n){s(null);return}let m=!1;return qH().then(y=>{if(!m)try{s(y.codeToHtml(e,{lang:n,theme:f}))}catch{s(null)}}).catch(()=>{m||s(null)}),()=>{m=!0}},[e,n,f]),w.useEffect(()=>()=>{h.current&&clearTimeout(h.current)},[]);const g=async()=>{try{await navigator.clipboard.writeText(e),u(!0),h.current&&clearTimeout(h.current),h.current=setTimeout(()=>u(!1),1200)}catch{}};return o.jsxs("div",{className:"v10-md-pre",children:[o.jsx("button",{type:"button",className:"v10-md-copy",onClick:g,"aria-label":l?"Copied":"Copy code",title:l?"Copied":"Copy code",children:l?o.jsx(lO,{size:14,"aria-hidden":"true"}):o.jsx(fO,{size:14,"aria-hidden":"true"})}),o.jsx("span",{className:"v10-md-copy-announce","aria-live":"polite",children:l?"Copied":""}),n&&o.jsx("span",{className:"v10-md-pre-lang","aria-hidden":"true",children:n}),a?o.jsx("div",{className:"v10-md-pre-rendered",dangerouslySetInnerHTML:{__html:a}}):o.jsx("pre",{className:"v10-md-pre-fallback",children:o.jsx("code",{children:e})})]})}function VH(){return e=>{let t="none",n=null;const a=new Set(["img","hr","br"]),s=(d,f)=>{const h=d.children;if(Array.isArray(h))for(let g=0;g<h.length;g++){const m=h[g];if(m.type==="text"&&typeof m.value=="string"&&m.value.trim().length>0)f?t="code":(n={siblings:h,index:g},t="text");else if(m.type==="element"){const y=m.tagName;y==="pre"?(t="code",s(m,!0)):y&&a.has(y)?t="leaf":s(m,f)}}},l=e;s(l,!1);const u={type:"element",tagName:"span",properties:{className:["v10-chat-cursor"]},children:[]};if(t==="text"&&n){const{siblings:d,index:f}=n;d.splice(f+1,0,u)}else t==="leaf"&&Array.isArray(l.children)&&l.children.push(u)}}function WH(e){return e?/^https?:\/\//i.test(e)?"http":/^mailto:/i.test(e)?"mailto":"inert":"inert"}function _N({content:e,streaming:t}){return o.jsx("div",{className:"v10-md",children:o.jsx(EB,{remarkPlugins:[PH,FH],rehypePlugins:t?[VH]:[],components:{img:({src:n,alt:a,title:s})=>o.jsxs("span",{className:"v10-md-image-placeholder",title:s||(typeof n=="string"?n:void 0),children:["[image",a?`: ${a}`:"","]"]}),h1:({children:n})=>o.jsx("h1",{className:"v10-md-h1",children:n}),h2:({children:n})=>o.jsx("h2",{className:"v10-md-h2",children:n}),h3:({children:n})=>o.jsx("h3",{className:"v10-md-h3",children:n}),h4:({children:n})=>o.jsx("h4",{className:"v10-md-h4",children:n}),h5:({children:n})=>o.jsx("h5",{className:"v10-md-h5",children:n}),h6:({children:n})=>o.jsx("h6",{className:"v10-md-h6",children:n}),p:({children:n})=>o.jsx("p",{className:"v10-md-p",children:n}),ul:({children:n})=>o.jsx("ul",{className:"v10-md-ul",children:n}),ol:({children:n})=>o.jsx("ol",{className:"v10-md-ol",children:n}),li:({children:n})=>o.jsx("li",{className:"v10-md-li",children:n}),a:({href:n,children:a})=>{const s=WH(n);return s==="http"?o.jsx("a",{className:"v10-md-link",href:n,target:"_blank",rel:"noopener noreferrer",children:a}):s==="mailto"?o.jsx("a",{className:"v10-md-link",href:n,children:a}):o.jsx("span",{className:"v10-md-link v10-md-link-inert",title:n,children:a})},blockquote:({children:n})=>o.jsx("blockquote",{className:"v10-md-blockquote",children:n}),hr:()=>o.jsx("hr",{className:"v10-md-hr"}),table:({children:n})=>o.jsx("div",{className:"v10-md-table-scroll",children:o.jsx("table",{className:"v10-md-table",children:n})}),thead:({children:n,node:a,...s})=>o.jsx("thead",{className:"v10-md-thead",...s,children:n}),tbody:({children:n,node:a,...s})=>o.jsx("tbody",{className:"v10-md-tbody",...s,children:n}),tr:({children:n,node:a,...s})=>o.jsx("tr",{className:"v10-md-tr",...s,children:n}),th:({children:n,node:a,...s})=>o.jsx("th",{className:"v10-md-th",...s,children:n}),td:({children:n,node:a,...s})=>o.jsx("td",{className:"v10-md-td",...s,children:n}),pre:({children:n,node:a})=>{var l,u,d;const s=(l=a==null?void 0:a.children)==null?void 0:l[0];if((s==null?void 0:s.tagName)==="code"){const f=((d=(u=s.properties)==null?void 0:u.className)==null?void 0:d[0])??"",h=/language-([\w-]+)/.exec(f),g=(s.children??[]).map(m=>(m==null?void 0:m.value)??"").join("").replace(/\n$/,"");return o.jsx(GH,{code:g,lang:h==null?void 0:h[1]})}return o.jsx("pre",{children:n})},code:({children:n})=>o.jsx("code",{className:"v10-md-code",children:n})},children:e})})}const ZH=o.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[o.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),o.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),KH=Ve.lazy(()=>gt(()=>import("./Operations-BO2C3UWB.js"),__vite__mapDeps([6,1])).then(e=>({default:e.OperationsPage}))),YH=Ve.lazy(()=>gt(()=>import("./AgentHub-D2vaQxlw.js"),[]).then(e=>({default:e.AgentHubPage}))),QH=Ve.lazy(()=>gt(()=>import("./Settings-DC_d9STV.js"),[]).then(e=>({default:e.SettingsPage}))),XH=Ve.lazy(()=>gt(()=>import("./AgentProfilePage-BgSTdsjD.js"),[]).then(e=>({default:e.AgentProfilePage}))),JH=Ve.lazy(()=>gt(()=>import("./PublishingConviction-xKRNHbzk.js"),__vite__mapDeps([7,8])).then(e=>({default:e.PublishingConvictionPage}))),e7=Ve.lazy(()=>gt(()=>import("./ConvictionDetailView-CieVypna.js"),__vite__mapDeps([9,8])).then(e=>({default:e.ConvictionDetailView})));function t7(){const{tabs:e,activeTabId:t,setActiveTab:n,closeTab:a}=fn();return o.jsx("div",{className:"v10-center-tabs",children:e.map(s=>o.jsxs("button",{className:`v10-center-tab ${s.id===t?"active":""}`,onClick:()=>n(s.id),children:[o.jsx("span",{className:"v10-center-tab-label",children:s.label}),s.closable&&o.jsx("span",{className:"v10-center-tab-close",onClick:l=>{l.stopPropagation(),a(s.id)},children:ZH})]},s.id))})}const n7=["text/","application/json","application/xml","application/javascript","application/x-yaml"];function r7(e){return n7.some(t=>e.startsWith(t))}function a7({docRef:e,contentType:t}){const{tabs:n,activeTabId:a,closeTab:s}=fn(),l=fn(R=>R.setActiveTab),[u,d]=w.useState(null),[f,h]=w.useState(null),[g,m]=w.useState(""),[y,b]=w.useState(!0),[k,j]=w.useState(null),[N,S]=w.useState("formatted"),A=e.startsWith("urn:dkg:file:"),E=n.find(R=>R.id===a),T=(E==null?void 0:E.label)??"Document",U=()=>{const R=n.find($=>$.id.startsWith("project:"));R&&l(R.id),s(a)};w.useEffect(()=>{let R=!1;if(b(!0),j(null),d(null),h(null),m(""),!A){b(!1);return}const $=e.replace("urn:dkg:file:",""),F=new AbortController;return fetch(Vu($,t||void 0),{headers:Ft(),signal:F.signal}).then(async K=>{if(!K.ok)throw new Error(`HTTP ${K.status}`);const I=K.headers.get("content-type")??"application/octet-stream";if(!R)if(m(I),r7(I)){const H=await K.text();R||(d(H),b(!1))}else if(I.startsWith("image/")){const H=await K.blob();R||(h(URL.createObjectURL(H)),b(!1))}else if(I==="application/pdf"){const H=await K.blob();R||(h(URL.createObjectURL(H)),b(!1))}else{const H=await K.text();R||(d(H),b(!1))}}).catch(K=>{R||(j(K.message),b(!1))}),()=>{R=!0,F.abort()}},[e,A,t]),w.useEffect(()=>{S("formatted")},[e]),w.useEffect(()=>{const R=f;return()=>{R&&URL.revokeObjectURL(R)}},[f]);const _=g.startsWith("image/"),z=g==="application/pdf",q=g.startsWith("text/markdown")||t.startsWith("text/markdown"),D=!y&&!k&&A&&q&&u!==null;return o.jsxs("div",{style:{height:"100%",display:"flex",flexDirection:"column",overflow:"hidden"},children:[o.jsxs("div",{style:{flexShrink:0,display:"flex",alignItems:"center",gap:10,padding:"8px 16px",borderBottom:"1px solid var(--border-subtle)",background:"var(--bg-panel)"},children:[o.jsx("button",{onClick:U,style:{border:"1px solid var(--border-default)",borderRadius:5,background:"none",color:"var(--text-secondary)",fontSize:11,fontWeight:600,padding:"4px 10px",cursor:"pointer",fontFamily:"var(--font-sans)"},children:"← Back to Project"}),o.jsxs("span",{style:{fontSize:13,fontWeight:600,color:"var(--text-primary)"},children:["📄 ",T]}),D&&o.jsx("div",{role:"group","aria-label":"Document view mode",style:{marginLeft:"auto",display:"flex",gap:2,padding:2,border:"1px solid var(--border-default)",borderRadius:6,background:"var(--bg-surface)"},children:["formatted","raw"].map(R=>{const $=N===R;return o.jsx("button",{type:"button","aria-pressed":$,onClick:()=>S(R),style:{border:"none",borderRadius:4,cursor:"pointer",padding:"3px 12px",fontSize:11,fontWeight:600,fontFamily:"var(--font-sans)",color:$?"var(--text-primary)":"var(--text-secondary)",background:$?"var(--bg-elevated)":"transparent"},children:R==="formatted"?"Formatted":"Raw"},R)})})]}),o.jsx("div",{style:{flex:1,overflow:"auto",padding:"20px 24px"},children:A?o.jsxs(o.Fragment,{children:[y&&o.jsx("div",{style:{color:"var(--text-tertiary)",fontSize:12},children:"Loading document..."}),k&&o.jsxs("div",{style:{color:"var(--accent-red)",fontSize:12},children:["Failed to load: ",k]}),!y&&_&&f&&o.jsx("img",{src:f,alt:T,style:{maxWidth:"100%",borderRadius:8}}),!y&&z&&f&&o.jsx("iframe",{src:f,title:T,style:{width:"100%",height:"100%",border:"none",borderRadius:8}}),u!==null&&!_&&!z&&q&&N==="formatted"&&o.jsx("div",{style:{background:"var(--bg-surface)",borderRadius:8,padding:"16px 20px",border:"1px solid var(--border-default)",color:"var(--text-primary)"},children:o.jsx(_N,{content:u})}),u!==null&&!_&&!z&&!(q&&N==="formatted")&&o.jsx("pre",{style:{fontFamily:"var(--font-mono)",fontSize:12,lineHeight:1.7,color:"var(--text-primary)",whiteSpace:"pre-wrap",wordBreak:"break-word",background:"var(--bg-surface)",borderRadius:8,padding:16,border:"1px solid var(--border-default)",margin:0},children:u})]}):o.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:10,height:"100%",color:"var(--text-tertiary)",textAlign:"center"},children:[o.jsx("span",{style:{fontSize:28,opacity:.6},children:"📄"}),o.jsx("span",{style:{fontSize:13,fontWeight:600,color:"var(--text-secondary)"},children:"Source file not available for this document"}),o.jsx("span",{style:{fontSize:12,maxWidth:360,lineHeight:1.6},children:"This document was indexed into the graph without a stored source file, so there is nothing to preview here. You can still explore its extracted entities and relationships in the graph."})]})})]})}function i7(){const e=fn(t=>t.activeTabId);if(e==="dashboard")return o.jsx(oM,{});if(e==="operations")return o.jsx(w.Suspense,{fallback:o.jsx("div",{className:"lazy-spinner",children:"Loading operations..."}),children:o.jsx(KH,{})});if(e==="agent-hub")return o.jsx(w.Suspense,{fallback:o.jsx("div",{className:"lazy-spinner",children:"Loading agent hub..."}),children:o.jsx(YH,{})});if(e==="settings")return o.jsx(w.Suspense,{fallback:o.jsx("div",{className:"lazy-spinner",children:"Loading settings..."}),children:o.jsx(QH,{})});if(e==="conviction")return o.jsx(w.Suspense,{fallback:o.jsx("div",{className:"lazy-spinner",children:"Loading Publisher Conviction..."}),children:o.jsx(JH,{})});if(e==="memory-stack")return o.jsx(p5,{});if(e===Xg)return o.jsx(QP,{});if(e.startsWith("project:")){const t=e.slice(8);return o.jsx(KP,{contextGraphId:t})}if(e.startsWith("conviction:")){const t=e.slice(11);return o.jsx(w.Suspense,{fallback:o.jsx("div",{className:"lazy-spinner",children:"Loading account..."}),children:o.jsx(e7,{accountId:t})})}if(e.startsWith("agent:")){const t=e.slice(6),n=t.indexOf("|");if(n>0){const a=t.slice(0,n),s=t.slice(n+1),l=s.includes(":")?s:`urn:dkg:agent:${s}`;return o.jsx(w.Suspense,{fallback:o.jsx("div",{className:"lazy-spinner",children:"Loading agent…"}),children:o.jsx(XH,{contextGraphId:a,agentUri:l})})}}if(e.startsWith(tv)){const{docRef:t,contentType:n}=UD(e);return o.jsx(a7,{docRef:t,contentType:n})}return e.startsWith("wm:")?o.jsx(Zh,{layer:"wm",contextGraphId:e.slice(3)}):e.startsWith("swm:")?o.jsx(Zh,{layer:"swm",contextGraphId:e.slice(4)}):e.startsWith("vm:")?o.jsx(Zh,{layer:"vm",contextGraphId:e.slice(3)}):o.jsx("div",{className:"v10-view-placeholder",children:o.jsxs("p",{style:{color:"var(--text-tertiary)",fontSize:12},children:['View "',e,'" coming soon.']})})}function s7(){return o.jsxs("div",{className:"v10-panel-center",children:[o.jsx(t7,{}),o.jsx("div",{className:"v10-center-content",children:o.jsx(i7,{})})]})}const o7=["Node Log","Transactions"],l7=o.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:o.jsx("polyline",{points:"6 9 12 15 18 9"})}),c7=o.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[o.jsx("polyline",{points:"15 3 21 3 21 9"}),o.jsx("polyline",{points:"9 21 3 21 3 15"}),o.jsx("line",{x1:"21",y1:"3",x2:"14",y2:"10"}),o.jsx("line",{x1:"3",y1:"21",x2:"10",y2:"14"})]}),u7=o.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[o.jsx("polyline",{points:"4 14 10 14 10 20"}),o.jsx("polyline",{points:"20 10 14 10 14 4"}),o.jsx("line",{x1:"10",y1:"14",x2:"3",y2:"21"}),o.jsx("line",{x1:"21",y1:"3",x2:"14",y2:"10"})]}),d7=/(\x1B\[[0-9;]*[mGKHFJA-Z]|\[[0-9;]*m)/g;function p7(e){return e.replace(d7,"")}function kk(e){const t=e.toLowerCase();return t.includes("error")||t.includes(" err ")||t.includes("[error]")?"error":t.includes("warn")||t.includes("[warn]")?"warn":t.includes("debug")||t.includes("[debug]")||t.includes("trace")?"debug":"info"}const f7={error:"var(--accent-red, #ef4444)",warn:"var(--accent-yellow, #f59e0b)",info:"var(--text-primary)",debug:"var(--text-tertiary)"};function h7(e){const t=w.useRef(null),n=w.useRef(!0);return w.useEffect(()=>{const a=t.current;if(!a)return;const s=()=>{n.current=a.scrollHeight-a.scrollTop-a.clientHeight<40};return a.addEventListener("scroll",s),()=>a.removeEventListener("scroll",s)},[]),w.useEffect(()=>{n.current&&t.current&&(t.current.scrollTop=t.current.scrollHeight)},[e]),t}function m7(){const[e,t]=w.useState([]),[n,a]=w.useState(""),[s,l]=w.useState("all"),u=w.useCallback(()=>{Tn.fetchNodeLog({lines:300,q:n||void 0}).then(({lines:g})=>t((g??[]).map(p7))).catch(()=>{})},[n]);w.useEffect(()=>{u();const g=setInterval(u,3e3);return()=>clearInterval(g)},[u]);const d=e.filter(g=>s==="all"||kk(g)===s),f=d.length>0?d[d.length-1]:"",h=h7(f);return o.jsxs("div",{className:"v10-log-container",children:[o.jsxs("div",{className:"v10-log-toolbar",children:[o.jsx("input",{id:"dkg-node-log-filter",name:"dkg-node-log-filter",type:"text",placeholder:"Filter logs...",className:"v10-log-filter",value:n,onChange:g=>a(g.target.value),"aria-label":"Filter node log lines"}),o.jsxs("select",{id:"dkg-node-log-level",name:"dkg-node-log-level",className:"v10-log-level-select",value:s,onChange:g=>l(g.target.value),"aria-label":"Filter node log level",children:[o.jsx("option",{value:"all",children:"All"}),o.jsx("option",{value:"error",children:"Error"}),o.jsx("option",{value:"warn",children:"Warn"}),o.jsx("option",{value:"info",children:"Info"}),o.jsx("option",{value:"debug",children:"Debug"})]})]}),o.jsxs("div",{className:"v10-log-output",ref:h,children:[d.map((g,m)=>o.jsx("div",{className:"v10-log-line",style:{color:f7[kk(g)]},children:g},m)),d.length===0&&o.jsx("div",{className:"v10-log-line",style:{color:"var(--text-tertiary)"},children:"No log output"})]})]})}const g7=new Set(["publish","publishFromSWM","update","ka-update","verify","reconstruct"]),v7={publish:"#22c55e",publishFromSWM:"#16a34a",update:"#14b8a6","ka-update":"#0d9488",verify:"#8b5cf6",reconstruct:"#fb923c"};function y7(){const[e,t]=w.useState([]),[n,a]=w.useState(null),s=w.useCallback(()=>{const l=String(Date.now()-216e5),u=[...g7].join(",");Tn.fetchOperationsWithPhases({limit:"100",from:l,names:u}).then(d=>{t((d==null?void 0:d.operations)??[])}).catch(()=>{})},[]);return w.useEffect(()=>{s();const l=setInterval(s,1e4);return()=>clearInterval(l)},[s]),e.length===0?o.jsx("div",{style:{padding:"20px 16px",color:"var(--text-tertiary)",fontSize:12},children:"No publish, update, or verify activity in the last 6 hours."}):o.jsx("div",{className:"v10-log-output",style:{overflowY:"auto",flex:1},children:o.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:11},children:[o.jsx("thead",{children:o.jsxs("tr",{style:{borderBottom:"1px solid var(--border-subtle)",color:"var(--text-secondary)",textAlign:"left"},children:[o.jsx("th",{style:{padding:"6px 12px",fontWeight:600},children:"Type"}),o.jsx("th",{style:{padding:"6px 12px",fontWeight:600},children:"ID"}),o.jsx("th",{style:{padding:"6px 12px",fontWeight:600},children:"Status"}),o.jsx("th",{style:{padding:"6px 12px",fontWeight:600},children:"Duration"}),o.jsx("th",{style:{padding:"6px 12px",fontWeight:600},children:"Time"}),o.jsx("th",{style:{padding:"6px 12px",fontWeight:600},children:"Tx Hash"})]})}),o.jsx("tbody",{children:e.map(l=>{const u=(l.phases??[]).find(h=>h.phase==="chain"),d=l.tx_hash??(u==null?void 0:u.tx_hash),f=n===l.operation_id;return o.jsxs(Ve.Fragment,{children:[o.jsxs("tr",{onClick:()=>a(h=>h===l.operation_id?null:l.operation_id),style:{borderBottom:"1px solid var(--border-subtle)",cursor:"pointer",background:f?"rgba(255,255,255,.03)":void 0},children:[o.jsx("td",{style:{padding:"7px 12px",color:v7[l.operation_name]??"var(--text-secondary)",fontWeight:600},children:l.operation_name}),o.jsx("td",{style:{padding:"7px 12px",fontFamily:"var(--font-mono)",color:"var(--text-secondary)"},children:g1(l.operation_id)}),o.jsx("td",{style:{padding:"7px 12px"},children:o.jsx("span",{style:{padding:"2px 6px",borderRadius:4,fontSize:10,fontWeight:600,background:l.status==="success"?"rgba(34,197,94,.15)":l.status==="error"?"rgba(239,68,68,.15)":"rgba(245,158,11,.15)",color:l.status==="success"?"#22c55e":l.status==="error"?"#ef4444":"#f59e0b"},children:l.status})}),o.jsx("td",{style:{padding:"7px 12px",color:"var(--text-secondary)"},children:l.duration_ms!=null?m1(l.duration_ms):"—"}),o.jsx("td",{style:{padding:"7px 12px",color:"var(--text-secondary)"},children:l.started_at?h4(l.started_at):"—"}),o.jsx("td",{style:{padding:"7px 12px",fontFamily:"var(--font-mono)",color:"var(--text-tertiary)",maxWidth:140,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:d?`${d.slice(0,10)}…`:l.status==="success"?o.jsx("span",{style:{fontFamily:"var(--font-sans)",fontStyle:"italic",color:"var(--text-tertiary)"},children:"local"}):"—"})]}),f&&o.jsx("tr",{style:{background:"rgba(0,0,0,.2)"},children:o.jsxs("td",{colSpan:6,style:{padding:"8px 16px"},children:[o.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:16,fontSize:11,color:"var(--text-secondary)"},children:[o.jsxs("span",{children:[o.jsx("b",{children:"ID:"})," ",o.jsx("span",{style:{fontFamily:"var(--font-mono)"},children:l.operation_id})]}),d&&o.jsxs("span",{children:[o.jsx("b",{children:"Tx:"})," ",o.jsx("span",{style:{fontFamily:"var(--font-mono)"},children:d})]}),l.peer_id&&o.jsxs("span",{children:[o.jsx("b",{children:"Peer:"})," ",o.jsx("span",{style:{fontFamily:"var(--font-mono)"},children:g1(l.peer_id)})]}),l.error_message&&o.jsxs("span",{style:{color:"#ef4444"},children:[o.jsx("b",{children:"Error:"})," ",l.error_message]})]}),(l.phases??[]).length>0&&o.jsx("div",{style:{marginTop:8,display:"flex",gap:6,flexWrap:"wrap"},children:l.phases.map(h=>o.jsxs("span",{style:{padding:"2px 8px",borderRadius:4,fontSize:10,fontWeight:600,background:"rgba(255,255,255,.06)",color:"var(--text-secondary)"},children:[h.phase," ",h.duration_ms!=null?m1(h.duration_ms):""]},h.phase))})]})})]},l.operation_id)})})]})})}function b7(){const{bottomCollapsed:e,toggleBottom:t,bottomMaximised:n,toggleBottomMaximised:a,bottomHeight:s,setBottomHeight:l}=Vn(),[u,d]=w.useState("Node Log"),f=w.useRef(null),h=w.useRef(s);h.current=s,w.useEffect(()=>{const m=f.current;if(!m)return;let y=0;const b=N=>{const S=y-N.clientY;y=N.clientY,l(h.current+S)},k=()=>{document.removeEventListener("mousemove",b),document.removeEventListener("mouseup",k),document.body.style.cursor="",document.body.style.userSelect="",m.classList.remove("active")},j=N=>{N.preventDefault(),y=N.clientY,document.addEventListener("mousemove",b),document.addEventListener("mouseup",k),document.body.style.cursor="row-resize",document.body.style.userSelect="none",m.classList.add("active")};return m.addEventListener("mousedown",j),()=>m.removeEventListener("mousedown",j)},[l]);const g=e?void 0:n?"80vh":Math.min(s,sd());return o.jsxs("div",{className:`v10-panel-bottom ${e?"collapsed":""} ${n?"maximised":""}`,style:e?void 0:{height:g},children:[!e&&!n&&o.jsx("div",{className:"v10-resize-handle-v",ref:f,title:"Drag to resize"}),o.jsxs("div",{className:"v10-bottom-tabs",children:[o7.map(m=>o.jsx("button",{className:`v10-bottom-tab ${m===u?"active":""}`,onClick:()=>{d(m),e&&t()},children:m},m)),o.jsx("div",{style:{flex:1}}),o.jsx("button",{className:"v10-bottom-toggle",onClick:a,title:n?"Restore":"Maximise",style:{display:e?"none":void 0},children:n?u7:c7}),o.jsx("button",{className:"v10-bottom-toggle",onClick:t,title:e?"Expand":"Collapse",children:o.jsx("span",{style:{transform:e?"rotate(180deg)":"none",display:"flex",transition:"transform 0.15s"},children:l7})})]}),!e&&o.jsxs("div",{className:"v10-bottom-content",children:[u==="Node Log"&&o.jsx(m7,{}),u==="Transactions"&&o.jsx(y7,{})]})]})}function Sk(e){const t=Math.floor(e/1e3);if(t<60)return`${t}s`;const n=Math.floor(t/60);return n<60?`${n}m`:`${Math.floor(n/60)}h ${n%60}m`}function Cd(e){if(e==null||e==="")return"";const t=e instanceof Date?e:new Date(e);return Number.isNaN(t.valueOf())?typeof e=="string"?e:"":t.toLocaleString([],{dateStyle:"medium",timeStyle:"short"})}function rg(e){if(e==null||e==="")return;const t=e instanceof Date?e:new Date(e);if(!Number.isNaN(t.valueOf()))return t.toISOString()}function x7(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function w7(e){var n;const t=((n=e.split(".").pop())==null?void 0:n.toLowerCase())??"";return["md","txt","csv","json","xml","yaml","yml"].includes(t)?"TXT":["pdf"].includes(t)?"PDF":["docx","doc"].includes(t)?"DOC":["png","jpg","jpeg","webp"].includes(t)?"IMG":["py","ts","js","tsx","jsx","java","go","rs","c","cpp"].includes(t)?"CODE":"FILE"}function ag(e,t){var n;return((n=e.find(a=>a.id===t))==null?void 0:n.name)??t}function k7(e){return e.startsWith("did:dkg:context-graph:")?e:`did:dkg:context-graph:${e}`}function S7(e){return String(e??"").replace(/[\u0000-\u001F\u007F]/g," ").replace(/\s+/g," ").trim()}function RN(e){if(e.length===0)return"";const t=e.map(n=>n.fileName);return t.length<=2?`Attached ${t.join(" and ")}.`:`Attached ${t[0]} and ${t.length-1} more files.`}function ON(e){return e.status==="queued"||e.status==="completed"||e.status==="skipped"}function LN(e){return e.name.trim()}function j7(e){if(e.status!=="completed"||!e.result)return null;const t=e.result.extraction.mdIntermediateHash,n=t??(e.result.detectedContentType==="text/markdown"?e.result.fileHash:void 0);return{id:e.id,fileName:LN(e.file),contextGraphId:e.contextGraphId,assertionName:e.assertionName,assertionUri:e.result.assertionUri,fileHash:e.result.fileHash,detectedContentType:e.result.detectedContentType,rootEntity:e.result.rootEntity,extractionStatus:"completed",tripleCount:e.result.extraction.tripleCount??e.result.extraction.triplesWritten,...t?{mdIntermediateHash:t}:{},...n?{markdownHash:n,markdownForm:`urn:dkg:file:${n}`}:{}}}function C7(e){const t=[];return{results:e.flatMap(a=>{if(a.status!=="skipped"||!a.result)return[];t.push(a.id);const s=a.result,l=s.extraction;return[{id:a.id,fileName:LN(a.file),contextGraphId:a.contextGraphId,assertionName:a.assertionName,assertionUri:s.assertionUri,fileHash:s.fileHash,detectedContentType:s.detectedContentType,extractionStatus:"skipped",pipelineUsed:l.pipelineUsed??null,tripleCount:l.tripleCount??l.triplesWritten??0,...s.rootEntity?{rootEntity:s.rootEntity}:{},...l.mdIntermediateHash?{mdIntermediateHash:l.mdIntermediateHash}:{},...l.error?{error:l.error}:{}}]}),deliveredDraftIds:t}}function MN(e){return e.length===0?"":e.length===1?`Attachment import result: ${S7(e[0].fileName)}.`:`Attached ${e.length} document import results.`}function N7(e,t){const n=[RN(e),MN(t)].filter(a=>a.length>0).map(a=>a.replace(/\.$/,""));return n.length?`${n.join("; ")}.`:""}function E7(e,t,n){const a=[];if(t){const s=ag(e,t);a.push({key:"target_context_graph",label:"Target context graph id",value:t}),a.push({key:"target_context_graph_uri",label:"Target context graph URI",value:k7(t)}),a.push({key:"target_context_graph_name",label:"Target context graph name",value:s})}return n!=null&&n.agentAddress&&a.push({key:"current_agent_address",label:"Current agent address",value:n.agentAddress}),n!=null&&n.agentDid&&a.push({key:"current_agent_did",label:"Current agent DID",value:n.agentDid}),n!=null&&n.peerId&&a.push({key:"current_agent_peer_id",label:"Current agent peer ID",value:n.peerId}),a}const A7="https://docs.openclaw.ai/",T7="https://github.com/openclaw/openclaw/releases",Xi="__add_agent__",_7=["openclaw"];function R7(e,t){const n=t instanceof Error?t.message:String(t??"Unknown error");if(t instanceof wm){if(t.code==="HERMES_BRIDGE_RESPONSE_TIMEOUT")return`${e.name} bridge response timed out.`;if(t.code==="HERMES_GATEWAY_RESPONSE_TIMEOUT")return`${e.name} gateway response timed out.`;if(t.code==="OPENCLAW_BRIDGE_RESPONSE_TIMEOUT")return`${e.name} bridge response timed out.`;if(t.code==="OPENCLAW_GATEWAY_RESPONSE_TIMEOUT")return`${e.name} gateway response timed out.`;if(t.code==="SWM_SYNC_TIMEOUT"||t.source==="background-sync")return"Background sync timed out. The chat request was not marked as failed by the local-agent bridge."}return/OpenClaw bridge unreachable/i.test(n)?`${e.name} is unavailable right now.`:/Hermes bridge unreachable/i.test(n)?`${e.name} is unavailable right now.`:/gateway response timeout/i.test(n)?`${e.name} gateway response timed out.`:/bridge response timeout/i.test(n)||/aborted due to timeout/i.test(n)?`${e.name} bridge response timed out.`:/Agent response timeout/i.test(n)?`${e.name} took too long to respond.`:/Agent returned no text response/i.test(n)||/\(no response\)/i.test(n)?`${e.name} did not return a text reply.`:n}let O7=0;function L7(e,t,n){const a=e.trim();return a?a===t?!0:n==="Request cancelled."&&a===n:!1}function M7(e,t,n,a){return e&&L7(e,t,n)?{content:e,synthesized:!0}:e?a==="hermes"?{content:e,failureNotice:t,synthesized:!1}:{content:e,synthesized:!1}:{content:"",failureNotice:t,synthesized:!0}}function jk(e,t=""){const n=e.author.toLowerCase(),a=n.includes("assistant")||n.includes("agent")?"assistant":"user",s=typeof e.failureReason=="string"&&e.failureReason.trim()?e.failureReason.trim():void 0,l=a==="assistant"&&(e.persistStatus==="failed"||!!s),u=`Error: ${s??"The local agent turn failed."}`,d=l?M7(e.text,u,s,t):null,f=(d==null?void 0:d.content)??(e.text||RN(e.attachmentRefs??[])),h=!!e.text;return{id:e.uri||`local-history:${++O7}`,uri:e.uri,turnId:e.turnId,role:a,content:f,ts:Cd(e.ts),tsRaw:rg(e.ts),attachments:e.attachmentRefs,failureNotice:d==null?void 0:d.failureNotice,synthesized:(d==null?void 0:d.synthesized)??!h}}function D7(e){return e.turnId?`turn:${e.turnId}:${e.role}`:e.uri??`${e.role}:${e.ts??""}:${e.content}`}function Ck(e,t){const n=new Set,a=[];for(const s of[...t,...e]){const l=D7(s);n.has(l)||(n.add(l),a.push(s))}return a}function Nk(e,t,n){const a=typeof n=="string"&&n.trim()?n.trim():t;return!a||a===t?e:e.map(s=>s.turnId===t?{...s,turnId:a}:s)}function Ek(e){return e.replace(/\r\n/g,`
1653
1653
  `).replace(/^(?:[ \t]*\n)+/,"").replace(/(?:\n[ \t]*)+$/,"")}function z7(e,t,n,a,s){const l=Ek(e),u=s?Ek(s):"";if(t==="assistant"&&a&&l.trim()===""&&!u)return o.jsx("span",{className:"v10-chat-thinking",role:"status","aria-live":"polite",children:"Thinking…"});if(t==="assistant"&&!n&&l.trim()!=="")return o.jsxs(o.Fragment,{children:[o.jsx(_N,{content:l,streaming:a&&!u}),u&&o.jsxs("span",{className:"v10-chat-plaintext v10-chat-failure-notice",children:[u,a&&o.jsx("span",{className:"v10-chat-cursor"})]})]});const d=[l,u].filter(Boolean).join(`
1654
1654
 
1655
1655
  `);return o.jsxs("span",{className:"v10-chat-plaintext",children:[d,a&&o.jsx("span",{className:"v10-chat-cursor"})]})}function ig(){return ig=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)({}).hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},ig.apply(null,arguments)}function $7(e,t){if(e==null)return{};var n={};for(var a in e)if({}.hasOwnProperty.call(e,a)){if(t.indexOf(a)!==-1)continue;n[a]=e[a]}return n}var I7=w.useLayoutEffect,P7=function(t){var n=Ve.useRef(t);return I7(function(){n.current=t}),n},Ak=function(t,n){if(typeof t=="function"){t(n);return}t.current=n},U7=function(t,n){var a=Ve.useRef();return Ve.useCallback(function(s){t.current=s,a.current&&Ak(a.current,null),a.current=n,n&&Ak(n,s)},[n])},Tk={"min-height":"0","max-height":"none",height:"0",visibility:"hidden",overflow:"hidden",position:"absolute","z-index":"-1000",top:"0",right:"0",display:"block"},B7=function(t){Object.keys(Tk).forEach(function(n){t.style.setProperty(n,Tk[n],"important")})},_k=B7,On=null,Rk=function(t,n){var a=t.scrollHeight;return n.sizingStyle.boxSizing==="border-box"?a+n.borderSize:a-n.paddingSize};function F7(e,t,n,a){n===void 0&&(n=1),a===void 0&&(a=1/0),On||(On=document.createElement("textarea"),On.setAttribute("tabindex","-1"),On.setAttribute("aria-hidden","true"),_k(On)),On.parentNode===null&&document.body.appendChild(On);var s=e.paddingSize,l=e.borderSize,u=e.sizingStyle,d=u.boxSizing;Object.keys(u).forEach(function(y){var b=y;On.style[b]=u[b]}),_k(On),On.value=t;var f=Rk(On,e);On.value=t,f=Rk(On,e),On.value="x";var h=On.scrollHeight-s,g=h*n;d==="border-box"&&(g=g+s+l),f=Math.max(g,f);var m=h*a;return d==="border-box"&&(m=m+s+l),f=Math.min(m,f),[f,h]}var Ok=function(){},H7=function(t,n){return t.reduce(function(a,s){return a[s]=n[s],a},{})},q7=["borderBottomWidth","borderLeftWidth","borderRightWidth","borderTopWidth","boxSizing","fontFamily","fontSize","fontStyle","fontWeight","letterSpacing","lineHeight","paddingBottom","paddingLeft","paddingRight","paddingTop","tabSize","textIndent","textRendering","textTransform","width","wordBreak","wordSpacing","scrollbarGutter"],G7=!!document.documentElement.currentStyle,V7=function(t){var n=window.getComputedStyle(t);if(n===null)return null;var a=H7(q7,n),s=a.boxSizing;if(s==="")return null;G7&&s==="border-box"&&(a.width=parseFloat(a.width)+parseFloat(a.borderRightWidth)+parseFloat(a.borderLeftWidth)+parseFloat(a.paddingRight)+parseFloat(a.paddingLeft)+"px");var l=parseFloat(a.paddingBottom)+parseFloat(a.paddingTop),u=parseFloat(a.borderBottomWidth)+parseFloat(a.borderTopWidth);return{sizingStyle:a,paddingSize:l,borderSize:u}},W7=V7;function Lv(e,t,n){var a=P7(n);w.useLayoutEffect(function(){var s=function(u){return a.current(u)};if(e)return e.addEventListener(t,s),function(){return e.removeEventListener(t,s)}},[])}var Z7=function(t,n){Lv(document.body,"reset",function(a){t.current.form===a.target&&n(a)})},K7=function(t){Lv(window,"resize",t)},Y7=function(t){Lv(document.fonts,"loadingdone",t)},Q7=["cacheMeasurements","maxRows","minRows","onChange","onHeightChange"],X7=function(t,n){var a=t.cacheMeasurements,s=t.maxRows,l=t.minRows,u=t.onChange,d=u===void 0?Ok:u,f=t.onHeightChange,h=f===void 0?Ok:f,g=$7(t,Q7),m=g.value!==void 0,y=w.useRef(null),b=U7(y,n),k=w.useRef(0),j=w.useRef(),N=function(){var E=y.current,T=a&&j.current?j.current:W7(E);if(T){j.current=T;var U=F7(T,E.value||E.placeholder||"x",l,s),_=U[0],z=U[1];k.current!==_&&(k.current=_,E.style.setProperty("height",_+"px","important"),h(_,{rowHeight:z}))}},S=function(E){m||N(),d(E)};return w.useLayoutEffect(N),Z7(y,function(){if(!m){var A=y.current.value;requestAnimationFrame(function(){var E=y.current;E&&A!==E.value&&N()})}}),K7(N),Y7(N),w.createElement("textarea",ig({},g,{onChange:S,ref:b}))},J7=w.forwardRef(X7),fm={exports:{}},hm,Lk;function eq(){if(Lk)return hm;Lk=1;var e="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return hm=e,hm}var mm,Mk;function tq(){if(Mk)return mm;Mk=1;var e=eq();function t(){}function n(){}return n.resetWarningCache=t,mm=function(){function a(u,d,f,h,g,m){if(m!==e){var y=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw y.name="Invariant Violation",y}}a.isRequired=a;function s(){return a}var l={array:a,bigint:a,bool:a,func:a,number:a,object:a,string:a,symbol:a,any:a,arrayOf:s,element:a,elementType:a,instanceOf:s,node:a,objectOf:s,oneOf:s,oneOfType:s,shape:s,exact:s,checkPropTypes:n,resetWarningCache:t};return l.PropTypes=l,l},mm}var Dk;function nq(){return Dk||(Dk=1,fm.exports=tq()()),fm.exports}var rq=nq();const At=Wl(rq);function ps(e,t,n,a){function s(l){return l instanceof n?l:new n(function(u){u(l)})}return new(n||(n=Promise))(function(l,u){function d(g){try{h(a.next(g))}catch(m){u(m)}}function f(g){try{h(a.throw(g))}catch(m){u(m)}}function h(g){g.done?l(g.value):s(g.value).then(d,f)}h((a=a.apply(e,t||[])).next())})}const aq=new Map([["1km","application/vnd.1000minds.decision-model+xml"],["3dml","text/vnd.in3d.3dml"],["3ds","image/x-3ds"],["3g2","video/3gpp2"],["3gp","video/3gp"],["3gpp","video/3gpp"],["3mf","model/3mf"],["7z","application/x-7z-compressed"],["7zip","application/x-7z-compressed"],["123","application/vnd.lotus-1-2-3"],["aab","application/x-authorware-bin"],["aac","audio/x-acc"],["aam","application/x-authorware-map"],["aas","application/x-authorware-seg"],["abw","application/x-abiword"],["ac","application/vnd.nokia.n-gage.ac+xml"],["ac3","audio/ac3"],["acc","application/vnd.americandynamics.acc"],["ace","application/x-ace-compressed"],["acu","application/vnd.acucobol"],["acutc","application/vnd.acucorp"],["adp","audio/adpcm"],["aep","application/vnd.audiograph"],["afm","application/x-font-type1"],["afp","application/vnd.ibm.modcap"],["ahead","application/vnd.ahead.space"],["ai","application/pdf"],["aif","audio/x-aiff"],["aifc","audio/x-aiff"],["aiff","audio/x-aiff"],["air","application/vnd.adobe.air-application-installer-package+zip"],["ait","application/vnd.dvb.ait"],["ami","application/vnd.amiga.ami"],["amr","audio/amr"],["apk","application/vnd.android.package-archive"],["apng","image/apng"],["appcache","text/cache-manifest"],["application","application/x-ms-application"],["apr","application/vnd.lotus-approach"],["arc","application/x-freearc"],["arj","application/x-arj"],["asc","application/pgp-signature"],["asf","video/x-ms-asf"],["asm","text/x-asm"],["aso","application/vnd.accpac.simply.aso"],["asx","video/x-ms-asf"],["atc","application/vnd.acucorp"],["atom","application/atom+xml"],["atomcat","application/atomcat+xml"],["atomdeleted","application/atomdeleted+xml"],["atomsvc","application/atomsvc+xml"],["atx","application/vnd.antix.game-component"],["au","audio/x-au"],["avi","video/x-msvideo"],["avif","image/avif"],["aw","application/applixware"],["azf","application/vnd.airzip.filesecure.azf"],["azs","application/vnd.airzip.filesecure.azs"],["azv","image/vnd.airzip.accelerator.azv"],["azw","application/vnd.amazon.ebook"],["b16","image/vnd.pco.b16"],["bat","application/x-msdownload"],["bcpio","application/x-bcpio"],["bdf","application/x-font-bdf"],["bdm","application/vnd.syncml.dm+wbxml"],["bdoc","application/x-bdoc"],["bed","application/vnd.realvnc.bed"],["bh2","application/vnd.fujitsu.oasysprs"],["bin","application/octet-stream"],["blb","application/x-blorb"],["blorb","application/x-blorb"],["bmi","application/vnd.bmi"],["bmml","application/vnd.balsamiq.bmml+xml"],["bmp","image/bmp"],["book","application/vnd.framemaker"],["box","application/vnd.previewsystems.box"],["boz","application/x-bzip2"],["bpk","application/octet-stream"],["bpmn","application/octet-stream"],["bsp","model/vnd.valve.source.compiled-map"],["btif","image/prs.btif"],["buffer","application/octet-stream"],["bz","application/x-bzip"],["bz2","application/x-bzip2"],["c","text/x-c"],["c4d","application/vnd.clonk.c4group"],["c4f","application/vnd.clonk.c4group"],["c4g","application/vnd.clonk.c4group"],["c4p","application/vnd.clonk.c4group"],["c4u","application/vnd.clonk.c4group"],["c11amc","application/vnd.cluetrust.cartomobile-config"],["c11amz","application/vnd.cluetrust.cartomobile-config-pkg"],["cab","application/vnd.ms-cab-compressed"],["caf","audio/x-caf"],["cap","application/vnd.tcpdump.pcap"],["car","application/vnd.curl.car"],["cat","application/vnd.ms-pki.seccat"],["cb7","application/x-cbr"],["cba","application/x-cbr"],["cbr","application/x-cbr"],["cbt","application/x-cbr"],["cbz","application/x-cbr"],["cc","text/x-c"],["cco","application/x-cocoa"],["cct","application/x-director"],["ccxml","application/ccxml+xml"],["cdbcmsg","application/vnd.contact.cmsg"],["cda","application/x-cdf"],["cdf","application/x-netcdf"],["cdfx","application/cdfx+xml"],["cdkey","application/vnd.mediastation.cdkey"],["cdmia","application/cdmi-capability"],["cdmic","application/cdmi-container"],["cdmid","application/cdmi-domain"],["cdmio","application/cdmi-object"],["cdmiq","application/cdmi-queue"],["cdr","application/cdr"],["cdx","chemical/x-cdx"],["cdxml","application/vnd.chemdraw+xml"],["cdy","application/vnd.cinderella"],["cer","application/pkix-cert"],["cfs","application/x-cfs-compressed"],["cgm","image/cgm"],["chat","application/x-chat"],["chm","application/vnd.ms-htmlhelp"],["chrt","application/vnd.kde.kchart"],["cif","chemical/x-cif"],["cii","application/vnd.anser-web-certificate-issue-initiation"],["cil","application/vnd.ms-artgalry"],["cjs","application/node"],["cla","application/vnd.claymore"],["class","application/octet-stream"],["clkk","application/vnd.crick.clicker.keyboard"],["clkp","application/vnd.crick.clicker.palette"],["clkt","application/vnd.crick.clicker.template"],["clkw","application/vnd.crick.clicker.wordbank"],["clkx","application/vnd.crick.clicker"],["clp","application/x-msclip"],["cmc","application/vnd.cosmocaller"],["cmdf","chemical/x-cmdf"],["cml","chemical/x-cml"],["cmp","application/vnd.yellowriver-custom-menu"],["cmx","image/x-cmx"],["cod","application/vnd.rim.cod"],["coffee","text/coffeescript"],["com","application/x-msdownload"],["conf","text/plain"],["cpio","application/x-cpio"],["cpp","text/x-c"],["cpt","application/mac-compactpro"],["crd","application/x-mscardfile"],["crl","application/pkix-crl"],["crt","application/x-x509-ca-cert"],["crx","application/x-chrome-extension"],["cryptonote","application/vnd.rig.cryptonote"],["csh","application/x-csh"],["csl","application/vnd.citationstyles.style+xml"],["csml","chemical/x-csml"],["csp","application/vnd.commonspace"],["csr","application/octet-stream"],["css","text/css"],["cst","application/x-director"],["csv","text/csv"],["cu","application/cu-seeme"],["curl","text/vnd.curl"],["cww","application/prs.cww"],["cxt","application/x-director"],["cxx","text/x-c"],["dae","model/vnd.collada+xml"],["daf","application/vnd.mobius.daf"],["dart","application/vnd.dart"],["dataless","application/vnd.fdsn.seed"],["davmount","application/davmount+xml"],["dbf","application/vnd.dbf"],["dbk","application/docbook+xml"],["dcr","application/x-director"],["dcurl","text/vnd.curl.dcurl"],["dd2","application/vnd.oma.dd2+xml"],["ddd","application/vnd.fujixerox.ddd"],["ddf","application/vnd.syncml.dmddf+xml"],["dds","image/vnd.ms-dds"],["deb","application/x-debian-package"],["def","text/plain"],["deploy","application/octet-stream"],["der","application/x-x509-ca-cert"],["dfac","application/vnd.dreamfactory"],["dgc","application/x-dgc-compressed"],["dic","text/x-c"],["dir","application/x-director"],["dis","application/vnd.mobius.dis"],["disposition-notification","message/disposition-notification"],["dist","application/octet-stream"],["distz","application/octet-stream"],["djv","image/vnd.djvu"],["djvu","image/vnd.djvu"],["dll","application/octet-stream"],["dmg","application/x-apple-diskimage"],["dmn","application/octet-stream"],["dmp","application/vnd.tcpdump.pcap"],["dms","application/octet-stream"],["dna","application/vnd.dna"],["doc","application/msword"],["docm","application/vnd.ms-word.template.macroEnabled.12"],["docx","application/vnd.openxmlformats-officedocument.wordprocessingml.document"],["dot","application/msword"],["dotm","application/vnd.ms-word.template.macroEnabled.12"],["dotx","application/vnd.openxmlformats-officedocument.wordprocessingml.template"],["dp","application/vnd.osgi.dp"],["dpg","application/vnd.dpgraph"],["dra","audio/vnd.dra"],["drle","image/dicom-rle"],["dsc","text/prs.lines.tag"],["dssc","application/dssc+der"],["dtb","application/x-dtbook+xml"],["dtd","application/xml-dtd"],["dts","audio/vnd.dts"],["dtshd","audio/vnd.dts.hd"],["dump","application/octet-stream"],["dvb","video/vnd.dvb.file"],["dvi","application/x-dvi"],["dwd","application/atsc-dwd+xml"],["dwf","model/vnd.dwf"],["dwg","image/vnd.dwg"],["dxf","image/vnd.dxf"],["dxp","application/vnd.spotfire.dxp"],["dxr","application/x-director"],["ear","application/java-archive"],["ecelp4800","audio/vnd.nuera.ecelp4800"],["ecelp7470","audio/vnd.nuera.ecelp7470"],["ecelp9600","audio/vnd.nuera.ecelp9600"],["ecma","application/ecmascript"],["edm","application/vnd.novadigm.edm"],["edx","application/vnd.novadigm.edx"],["efif","application/vnd.picsel"],["ei6","application/vnd.pg.osasli"],["elc","application/octet-stream"],["emf","image/emf"],["eml","message/rfc822"],["emma","application/emma+xml"],["emotionml","application/emotionml+xml"],["emz","application/x-msmetafile"],["eol","audio/vnd.digital-winds"],["eot","application/vnd.ms-fontobject"],["eps","application/postscript"],["epub","application/epub+zip"],["es","application/ecmascript"],["es3","application/vnd.eszigno3+xml"],["esa","application/vnd.osgi.subsystem"],["esf","application/vnd.epson.esf"],["et3","application/vnd.eszigno3+xml"],["etx","text/x-setext"],["eva","application/x-eva"],["evy","application/x-envoy"],["exe","application/octet-stream"],["exi","application/exi"],["exp","application/express"],["exr","image/aces"],["ext","application/vnd.novadigm.ext"],["ez","application/andrew-inset"],["ez2","application/vnd.ezpix-album"],["ez3","application/vnd.ezpix-package"],["f","text/x-fortran"],["f4v","video/mp4"],["f77","text/x-fortran"],["f90","text/x-fortran"],["fbs","image/vnd.fastbidsheet"],["fcdt","application/vnd.adobe.formscentral.fcdt"],["fcs","application/vnd.isac.fcs"],["fdf","application/vnd.fdf"],["fdt","application/fdt+xml"],["fe_launch","application/vnd.denovo.fcselayout-link"],["fg5","application/vnd.fujitsu.oasysgp"],["fgd","application/x-director"],["fh","image/x-freehand"],["fh4","image/x-freehand"],["fh5","image/x-freehand"],["fh7","image/x-freehand"],["fhc","image/x-freehand"],["fig","application/x-xfig"],["fits","image/fits"],["flac","audio/x-flac"],["fli","video/x-fli"],["flo","application/vnd.micrografx.flo"],["flv","video/x-flv"],["flw","application/vnd.kde.kivio"],["flx","text/vnd.fmi.flexstor"],["fly","text/vnd.fly"],["fm","application/vnd.framemaker"],["fnc","application/vnd.frogans.fnc"],["fo","application/vnd.software602.filler.form+xml"],["for","text/x-fortran"],["fpx","image/vnd.fpx"],["frame","application/vnd.framemaker"],["fsc","application/vnd.fsc.weblaunch"],["fst","image/vnd.fst"],["ftc","application/vnd.fluxtime.clip"],["fti","application/vnd.anser-web-funds-transfer-initiation"],["fvt","video/vnd.fvt"],["fxp","application/vnd.adobe.fxp"],["fxpl","application/vnd.adobe.fxp"],["fzs","application/vnd.fuzzysheet"],["g2w","application/vnd.geoplan"],["g3","image/g3fax"],["g3w","application/vnd.geospace"],["gac","application/vnd.groove-account"],["gam","application/x-tads"],["gbr","application/rpki-ghostbusters"],["gca","application/x-gca-compressed"],["gdl","model/vnd.gdl"],["gdoc","application/vnd.google-apps.document"],["geo","application/vnd.dynageo"],["geojson","application/geo+json"],["gex","application/vnd.geometry-explorer"],["ggb","application/vnd.geogebra.file"],["ggt","application/vnd.geogebra.tool"],["ghf","application/vnd.groove-help"],["gif","image/gif"],["gim","application/vnd.groove-identity-message"],["glb","model/gltf-binary"],["gltf","model/gltf+json"],["gml","application/gml+xml"],["gmx","application/vnd.gmx"],["gnumeric","application/x-gnumeric"],["gpg","application/gpg-keys"],["gph","application/vnd.flographit"],["gpx","application/gpx+xml"],["gqf","application/vnd.grafeq"],["gqs","application/vnd.grafeq"],["gram","application/srgs"],["gramps","application/x-gramps-xml"],["gre","application/vnd.geometry-explorer"],["grv","application/vnd.groove-injector"],["grxml","application/srgs+xml"],["gsf","application/x-font-ghostscript"],["gsheet","application/vnd.google-apps.spreadsheet"],["gslides","application/vnd.google-apps.presentation"],["gtar","application/x-gtar"],["gtm","application/vnd.groove-tool-message"],["gtw","model/vnd.gtw"],["gv","text/vnd.graphviz"],["gxf","application/gxf"],["gxt","application/vnd.geonext"],["gz","application/gzip"],["gzip","application/gzip"],["h","text/x-c"],["h261","video/h261"],["h263","video/h263"],["h264","video/h264"],["hal","application/vnd.hal+xml"],["hbci","application/vnd.hbci"],["hbs","text/x-handlebars-template"],["hdd","application/x-virtualbox-hdd"],["hdf","application/x-hdf"],["heic","image/heic"],["heics","image/heic-sequence"],["heif","image/heif"],["heifs","image/heif-sequence"],["hej2","image/hej2k"],["held","application/atsc-held+xml"],["hh","text/x-c"],["hjson","application/hjson"],["hlp","application/winhlp"],["hpgl","application/vnd.hp-hpgl"],["hpid","application/vnd.hp-hpid"],["hps","application/vnd.hp-hps"],["hqx","application/mac-binhex40"],["hsj2","image/hsj2"],["htc","text/x-component"],["htke","application/vnd.kenameaapp"],["htm","text/html"],["html","text/html"],["hvd","application/vnd.yamaha.hv-dic"],["hvp","application/vnd.yamaha.hv-voice"],["hvs","application/vnd.yamaha.hv-script"],["i2g","application/vnd.intergeo"],["icc","application/vnd.iccprofile"],["ice","x-conference/x-cooltalk"],["icm","application/vnd.iccprofile"],["ico","image/x-icon"],["ics","text/calendar"],["ief","image/ief"],["ifb","text/calendar"],["ifm","application/vnd.shana.informed.formdata"],["iges","model/iges"],["igl","application/vnd.igloader"],["igm","application/vnd.insors.igm"],["igs","model/iges"],["igx","application/vnd.micrografx.igx"],["iif","application/vnd.shana.informed.interchange"],["img","application/octet-stream"],["imp","application/vnd.accpac.simply.imp"],["ims","application/vnd.ms-ims"],["in","text/plain"],["ini","text/plain"],["ink","application/inkml+xml"],["inkml","application/inkml+xml"],["install","application/x-install-instructions"],["iota","application/vnd.astraea-software.iota"],["ipfix","application/ipfix"],["ipk","application/vnd.shana.informed.package"],["irm","application/vnd.ibm.rights-management"],["irp","application/vnd.irepository.package+xml"],["iso","application/x-iso9660-image"],["itp","application/vnd.shana.informed.formtemplate"],["its","application/its+xml"],["ivp","application/vnd.immervision-ivp"],["ivu","application/vnd.immervision-ivu"],["jad","text/vnd.sun.j2me.app-descriptor"],["jade","text/jade"],["jam","application/vnd.jam"],["jar","application/java-archive"],["jardiff","application/x-java-archive-diff"],["java","text/x-java-source"],["jhc","image/jphc"],["jisp","application/vnd.jisp"],["jls","image/jls"],["jlt","application/vnd.hp-jlyt"],["jng","image/x-jng"],["jnlp","application/x-java-jnlp-file"],["joda","application/vnd.joost.joda-archive"],["jp2","image/jp2"],["jpe","image/jpeg"],["jpeg","image/jpeg"],["jpf","image/jpx"],["jpg","image/jpeg"],["jpg2","image/jp2"],["jpgm","video/jpm"],["jpgv","video/jpeg"],["jph","image/jph"],["jpm","video/jpm"],["jpx","image/jpx"],["js","application/javascript"],["json","application/json"],["json5","application/json5"],["jsonld","application/ld+json"],["jsonl","application/jsonl"],["jsonml","application/jsonml+json"],["jsx","text/jsx"],["jxr","image/jxr"],["jxra","image/jxra"],["jxrs","image/jxrs"],["jxs","image/jxs"],["jxsc","image/jxsc"],["jxsi","image/jxsi"],["jxss","image/jxss"],["kar","audio/midi"],["karbon","application/vnd.kde.karbon"],["kdb","application/octet-stream"],["kdbx","application/x-keepass2"],["key","application/x-iwork-keynote-sffkey"],["kfo","application/vnd.kde.kformula"],["kia","application/vnd.kidspiration"],["kml","application/vnd.google-earth.kml+xml"],["kmz","application/vnd.google-earth.kmz"],["kne","application/vnd.kinar"],["knp","application/vnd.kinar"],["kon","application/vnd.kde.kontour"],["kpr","application/vnd.kde.kpresenter"],["kpt","application/vnd.kde.kpresenter"],["kpxx","application/vnd.ds-keypoint"],["ksp","application/vnd.kde.kspread"],["ktr","application/vnd.kahootz"],["ktx","image/ktx"],["ktx2","image/ktx2"],["ktz","application/vnd.kahootz"],["kwd","application/vnd.kde.kword"],["kwt","application/vnd.kde.kword"],["lasxml","application/vnd.las.las+xml"],["latex","application/x-latex"],["lbd","application/vnd.llamagraphics.life-balance.desktop"],["lbe","application/vnd.llamagraphics.life-balance.exchange+xml"],["les","application/vnd.hhe.lesson-player"],["less","text/less"],["lgr","application/lgr+xml"],["lha","application/octet-stream"],["link66","application/vnd.route66.link66+xml"],["list","text/plain"],["list3820","application/vnd.ibm.modcap"],["listafp","application/vnd.ibm.modcap"],["litcoffee","text/coffeescript"],["lnk","application/x-ms-shortcut"],["log","text/plain"],["lostxml","application/lost+xml"],["lrf","application/octet-stream"],["lrm","application/vnd.ms-lrm"],["ltf","application/vnd.frogans.ltf"],["lua","text/x-lua"],["luac","application/x-lua-bytecode"],["lvp","audio/vnd.lucent.voice"],["lwp","application/vnd.lotus-wordpro"],["lzh","application/octet-stream"],["m1v","video/mpeg"],["m2a","audio/mpeg"],["m2v","video/mpeg"],["m3a","audio/mpeg"],["m3u","text/plain"],["m3u8","application/vnd.apple.mpegurl"],["m4a","audio/x-m4a"],["m4p","application/mp4"],["m4s","video/iso.segment"],["m4u","application/vnd.mpegurl"],["m4v","video/x-m4v"],["m13","application/x-msmediaview"],["m14","application/x-msmediaview"],["m21","application/mp21"],["ma","application/mathematica"],["mads","application/mads+xml"],["maei","application/mmt-aei+xml"],["mag","application/vnd.ecowin.chart"],["maker","application/vnd.framemaker"],["man","text/troff"],["manifest","text/cache-manifest"],["map","application/json"],["mar","application/octet-stream"],["markdown","text/markdown"],["mathml","application/mathml+xml"],["mb","application/mathematica"],["mbk","application/vnd.mobius.mbk"],["mbox","application/mbox"],["mc1","application/vnd.medcalcdata"],["mcd","application/vnd.mcd"],["mcurl","text/vnd.curl.mcurl"],["md","text/markdown"],["mdb","application/x-msaccess"],["mdi","image/vnd.ms-modi"],["mdx","text/mdx"],["me","text/troff"],["mesh","model/mesh"],["meta4","application/metalink4+xml"],["metalink","application/metalink+xml"],["mets","application/mets+xml"],["mfm","application/vnd.mfmp"],["mft","application/rpki-manifest"],["mgp","application/vnd.osgeo.mapguide.package"],["mgz","application/vnd.proteus.magazine"],["mid","audio/midi"],["midi","audio/midi"],["mie","application/x-mie"],["mif","application/vnd.mif"],["mime","message/rfc822"],["mj2","video/mj2"],["mjp2","video/mj2"],["mjs","application/javascript"],["mk3d","video/x-matroska"],["mka","audio/x-matroska"],["mkd","text/x-markdown"],["mks","video/x-matroska"],["mkv","video/x-matroska"],["mlp","application/vnd.dolby.mlp"],["mmd","application/vnd.chipnuts.karaoke-mmd"],["mmf","application/vnd.smaf"],["mml","text/mathml"],["mmr","image/vnd.fujixerox.edmics-mmr"],["mng","video/x-mng"],["mny","application/x-msmoney"],["mobi","application/x-mobipocket-ebook"],["mods","application/mods+xml"],["mov","video/quicktime"],["movie","video/x-sgi-movie"],["mp2","audio/mpeg"],["mp2a","audio/mpeg"],["mp3","audio/mpeg"],["mp4","video/mp4"],["mp4a","audio/mp4"],["mp4s","application/mp4"],["mp4v","video/mp4"],["mp21","application/mp21"],["mpc","application/vnd.mophun.certificate"],["mpd","application/dash+xml"],["mpe","video/mpeg"],["mpeg","video/mpeg"],["mpg","video/mpeg"],["mpg4","video/mp4"],["mpga","audio/mpeg"],["mpkg","application/vnd.apple.installer+xml"],["mpm","application/vnd.blueice.multipass"],["mpn","application/vnd.mophun.application"],["mpp","application/vnd.ms-project"],["mpt","application/vnd.ms-project"],["mpy","application/vnd.ibm.minipay"],["mqy","application/vnd.mobius.mqy"],["mrc","application/marc"],["mrcx","application/marcxml+xml"],["ms","text/troff"],["mscml","application/mediaservercontrol+xml"],["mseed","application/vnd.fdsn.mseed"],["mseq","application/vnd.mseq"],["msf","application/vnd.epson.msf"],["msg","application/vnd.ms-outlook"],["msh","model/mesh"],["msi","application/x-msdownload"],["msl","application/vnd.mobius.msl"],["msm","application/octet-stream"],["msp","application/octet-stream"],["msty","application/vnd.muvee.style"],["mtl","model/mtl"],["mts","model/vnd.mts"],["mus","application/vnd.musician"],["musd","application/mmt-usd+xml"],["musicxml","application/vnd.recordare.musicxml+xml"],["mvb","application/x-msmediaview"],["mvt","application/vnd.mapbox-vector-tile"],["mwf","application/vnd.mfer"],["mxf","application/mxf"],["mxl","application/vnd.recordare.musicxml"],["mxmf","audio/mobile-xmf"],["mxml","application/xv+xml"],["mxs","application/vnd.triscape.mxs"],["mxu","video/vnd.mpegurl"],["n-gage","application/vnd.nokia.n-gage.symbian.install"],["n3","text/n3"],["nb","application/mathematica"],["nbp","application/vnd.wolfram.player"],["nc","application/x-netcdf"],["ncx","application/x-dtbncx+xml"],["nfo","text/x-nfo"],["ngdat","application/vnd.nokia.n-gage.data"],["nitf","application/vnd.nitf"],["nlu","application/vnd.neurolanguage.nlu"],["nml","application/vnd.enliven"],["nnd","application/vnd.noblenet-directory"],["nns","application/vnd.noblenet-sealer"],["nnw","application/vnd.noblenet-web"],["npx","image/vnd.net-fpx"],["nq","application/n-quads"],["nsc","application/x-conference"],["nsf","application/vnd.lotus-notes"],["nt","application/n-triples"],["ntf","application/vnd.nitf"],["numbers","application/x-iwork-numbers-sffnumbers"],["nzb","application/x-nzb"],["oa2","application/vnd.fujitsu.oasys2"],["oa3","application/vnd.fujitsu.oasys3"],["oas","application/vnd.fujitsu.oasys"],["obd","application/x-msbinder"],["obgx","application/vnd.openblox.game+xml"],["obj","model/obj"],["oda","application/oda"],["odb","application/vnd.oasis.opendocument.database"],["odc","application/vnd.oasis.opendocument.chart"],["odf","application/vnd.oasis.opendocument.formula"],["odft","application/vnd.oasis.opendocument.formula-template"],["odg","application/vnd.oasis.opendocument.graphics"],["odi","application/vnd.oasis.opendocument.image"],["odm","application/vnd.oasis.opendocument.text-master"],["odp","application/vnd.oasis.opendocument.presentation"],["ods","application/vnd.oasis.opendocument.spreadsheet"],["odt","application/vnd.oasis.opendocument.text"],["oga","audio/ogg"],["ogex","model/vnd.opengex"],["ogg","audio/ogg"],["ogv","video/ogg"],["ogx","application/ogg"],["omdoc","application/omdoc+xml"],["onepkg","application/onenote"],["onetmp","application/onenote"],["onetoc","application/onenote"],["onetoc2","application/onenote"],["opf","application/oebps-package+xml"],["opml","text/x-opml"],["oprc","application/vnd.palm"],["opus","audio/ogg"],["org","text/x-org"],["osf","application/vnd.yamaha.openscoreformat"],["osfpvg","application/vnd.yamaha.openscoreformat.osfpvg+xml"],["osm","application/vnd.openstreetmap.data+xml"],["otc","application/vnd.oasis.opendocument.chart-template"],["otf","font/otf"],["otg","application/vnd.oasis.opendocument.graphics-template"],["oth","application/vnd.oasis.opendocument.text-web"],["oti","application/vnd.oasis.opendocument.image-template"],["otp","application/vnd.oasis.opendocument.presentation-template"],["ots","application/vnd.oasis.opendocument.spreadsheet-template"],["ott","application/vnd.oasis.opendocument.text-template"],["ova","application/x-virtualbox-ova"],["ovf","application/x-virtualbox-ovf"],["owl","application/rdf+xml"],["oxps","application/oxps"],["oxt","application/vnd.openofficeorg.extension"],["p","text/x-pascal"],["p7a","application/x-pkcs7-signature"],["p7b","application/x-pkcs7-certificates"],["p7c","application/pkcs7-mime"],["p7m","application/pkcs7-mime"],["p7r","application/x-pkcs7-certreqresp"],["p7s","application/pkcs7-signature"],["p8","application/pkcs8"],["p10","application/x-pkcs10"],["p12","application/x-pkcs12"],["pac","application/x-ns-proxy-autoconfig"],["pages","application/x-iwork-pages-sffpages"],["pas","text/x-pascal"],["paw","application/vnd.pawaafile"],["pbd","application/vnd.powerbuilder6"],["pbm","image/x-portable-bitmap"],["pcap","application/vnd.tcpdump.pcap"],["pcf","application/x-font-pcf"],["pcl","application/vnd.hp-pcl"],["pclxl","application/vnd.hp-pclxl"],["pct","image/x-pict"],["pcurl","application/vnd.curl.pcurl"],["pcx","image/x-pcx"],["pdb","application/x-pilot"],["pde","text/x-processing"],["pdf","application/pdf"],["pem","application/x-x509-user-cert"],["pfa","application/x-font-type1"],["pfb","application/x-font-type1"],["pfm","application/x-font-type1"],["pfr","application/font-tdpfr"],["pfx","application/x-pkcs12"],["pgm","image/x-portable-graymap"],["pgn","application/x-chess-pgn"],["pgp","application/pgp"],["php","application/x-httpd-php"],["php3","application/x-httpd-php"],["php4","application/x-httpd-php"],["phps","application/x-httpd-php-source"],["phtml","application/x-httpd-php"],["pic","image/x-pict"],["pkg","application/octet-stream"],["pki","application/pkixcmp"],["pkipath","application/pkix-pkipath"],["pkpass","application/vnd.apple.pkpass"],["pl","application/x-perl"],["plb","application/vnd.3gpp.pic-bw-large"],["plc","application/vnd.mobius.plc"],["plf","application/vnd.pocketlearn"],["pls","application/pls+xml"],["pm","application/x-perl"],["pml","application/vnd.ctc-posml"],["png","image/png"],["pnm","image/x-portable-anymap"],["portpkg","application/vnd.macports.portpkg"],["pot","application/vnd.ms-powerpoint"],["potm","application/vnd.ms-powerpoint.presentation.macroEnabled.12"],["potx","application/vnd.openxmlformats-officedocument.presentationml.template"],["ppa","application/vnd.ms-powerpoint"],["ppam","application/vnd.ms-powerpoint.addin.macroEnabled.12"],["ppd","application/vnd.cups-ppd"],["ppm","image/x-portable-pixmap"],["pps","application/vnd.ms-powerpoint"],["ppsm","application/vnd.ms-powerpoint.slideshow.macroEnabled.12"],["ppsx","application/vnd.openxmlformats-officedocument.presentationml.slideshow"],["ppt","application/powerpoint"],["pptm","application/vnd.ms-powerpoint.presentation.macroEnabled.12"],["pptx","application/vnd.openxmlformats-officedocument.presentationml.presentation"],["pqa","application/vnd.palm"],["prc","application/x-pilot"],["pre","application/vnd.lotus-freelance"],["prf","application/pics-rules"],["provx","application/provenance+xml"],["ps","application/postscript"],["psb","application/vnd.3gpp.pic-bw-small"],["psd","application/x-photoshop"],["psf","application/x-font-linux-psf"],["pskcxml","application/pskc+xml"],["pti","image/prs.pti"],["ptid","application/vnd.pvi.ptid1"],["pub","application/x-mspublisher"],["pvb","application/vnd.3gpp.pic-bw-var"],["pwn","application/vnd.3m.post-it-notes"],["pya","audio/vnd.ms-playready.media.pya"],["pyv","video/vnd.ms-playready.media.pyv"],["qam","application/vnd.epson.quickanime"],["qbo","application/vnd.intu.qbo"],["qfx","application/vnd.intu.qfx"],["qps","application/vnd.publishare-delta-tree"],["qt","video/quicktime"],["qwd","application/vnd.quark.quarkxpress"],["qwt","application/vnd.quark.quarkxpress"],["qxb","application/vnd.quark.quarkxpress"],["qxd","application/vnd.quark.quarkxpress"],["qxl","application/vnd.quark.quarkxpress"],["qxt","application/vnd.quark.quarkxpress"],["ra","audio/x-realaudio"],["ram","audio/x-pn-realaudio"],["raml","application/raml+yaml"],["rapd","application/route-apd+xml"],["rar","application/x-rar"],["ras","image/x-cmu-raster"],["rcprofile","application/vnd.ipunplugged.rcprofile"],["rdf","application/rdf+xml"],["rdz","application/vnd.data-vision.rdz"],["relo","application/p2p-overlay+xml"],["rep","application/vnd.businessobjects"],["res","application/x-dtbresource+xml"],["rgb","image/x-rgb"],["rif","application/reginfo+xml"],["rip","audio/vnd.rip"],["ris","application/x-research-info-systems"],["rl","application/resource-lists+xml"],["rlc","image/vnd.fujixerox.edmics-rlc"],["rld","application/resource-lists-diff+xml"],["rm","audio/x-pn-realaudio"],["rmi","audio/midi"],["rmp","audio/x-pn-realaudio-plugin"],["rms","application/vnd.jcp.javame.midlet-rms"],["rmvb","application/vnd.rn-realmedia-vbr"],["rnc","application/relax-ng-compact-syntax"],["rng","application/xml"],["roa","application/rpki-roa"],["roff","text/troff"],["rp9","application/vnd.cloanto.rp9"],["rpm","audio/x-pn-realaudio-plugin"],["rpss","application/vnd.nokia.radio-presets"],["rpst","application/vnd.nokia.radio-preset"],["rq","application/sparql-query"],["rs","application/rls-services+xml"],["rsa","application/x-pkcs7"],["rsat","application/atsc-rsat+xml"],["rsd","application/rsd+xml"],["rsheet","application/urc-ressheet+xml"],["rss","application/rss+xml"],["rtf","text/rtf"],["rtx","text/richtext"],["run","application/x-makeself"],["rusd","application/route-usd+xml"],["rv","video/vnd.rn-realvideo"],["s","text/x-asm"],["s3m","audio/s3m"],["saf","application/vnd.yamaha.smaf-audio"],["sass","text/x-sass"],["sbml","application/sbml+xml"],["sc","application/vnd.ibm.secure-container"],["scd","application/x-msschedule"],["scm","application/vnd.lotus-screencam"],["scq","application/scvp-cv-request"],["scs","application/scvp-cv-response"],["scss","text/x-scss"],["scurl","text/vnd.curl.scurl"],["sda","application/vnd.stardivision.draw"],["sdc","application/vnd.stardivision.calc"],["sdd","application/vnd.stardivision.impress"],["sdkd","application/vnd.solent.sdkm+xml"],["sdkm","application/vnd.solent.sdkm+xml"],["sdp","application/sdp"],["sdw","application/vnd.stardivision.writer"],["sea","application/octet-stream"],["see","application/vnd.seemail"],["seed","application/vnd.fdsn.seed"],["sema","application/vnd.sema"],["semd","application/vnd.semd"],["semf","application/vnd.semf"],["senmlx","application/senml+xml"],["sensmlx","application/sensml+xml"],["ser","application/java-serialized-object"],["setpay","application/set-payment-initiation"],["setreg","application/set-registration-initiation"],["sfd-hdstx","application/vnd.hydrostatix.sof-data"],["sfs","application/vnd.spotfire.sfs"],["sfv","text/x-sfv"],["sgi","image/sgi"],["sgl","application/vnd.stardivision.writer-global"],["sgm","text/sgml"],["sgml","text/sgml"],["sh","application/x-sh"],["shar","application/x-shar"],["shex","text/shex"],["shf","application/shf+xml"],["shtml","text/html"],["sid","image/x-mrsid-image"],["sieve","application/sieve"],["sig","application/pgp-signature"],["sil","audio/silk"],["silo","model/mesh"],["sis","application/vnd.symbian.install"],["sisx","application/vnd.symbian.install"],["sit","application/x-stuffit"],["sitx","application/x-stuffitx"],["siv","application/sieve"],["skd","application/vnd.koan"],["skm","application/vnd.koan"],["skp","application/vnd.koan"],["skt","application/vnd.koan"],["sldm","application/vnd.ms-powerpoint.slide.macroenabled.12"],["sldx","application/vnd.openxmlformats-officedocument.presentationml.slide"],["slim","text/slim"],["slm","text/slim"],["sls","application/route-s-tsid+xml"],["slt","application/vnd.epson.salt"],["sm","application/vnd.stepmania.stepchart"],["smf","application/vnd.stardivision.math"],["smi","application/smil"],["smil","application/smil"],["smv","video/x-smv"],["smzip","application/vnd.stepmania.package"],["snd","audio/basic"],["snf","application/x-font-snf"],["so","application/octet-stream"],["spc","application/x-pkcs7-certificates"],["spdx","text/spdx"],["spf","application/vnd.yamaha.smaf-phrase"],["spl","application/x-futuresplash"],["spot","text/vnd.in3d.spot"],["spp","application/scvp-vp-response"],["spq","application/scvp-vp-request"],["spx","audio/ogg"],["sql","application/x-sql"],["src","application/x-wais-source"],["srt","application/x-subrip"],["sru","application/sru+xml"],["srx","application/sparql-results+xml"],["ssdl","application/ssdl+xml"],["sse","application/vnd.kodak-descriptor"],["ssf","application/vnd.epson.ssf"],["ssml","application/ssml+xml"],["sst","application/octet-stream"],["st","application/vnd.sailingtracker.track"],["stc","application/vnd.sun.xml.calc.template"],["std","application/vnd.sun.xml.draw.template"],["stf","application/vnd.wt.stf"],["sti","application/vnd.sun.xml.impress.template"],["stk","application/hyperstudio"],["stl","model/stl"],["stpx","model/step+xml"],["stpxz","model/step-xml+zip"],["stpz","model/step+zip"],["str","application/vnd.pg.format"],["stw","application/vnd.sun.xml.writer.template"],["styl","text/stylus"],["stylus","text/stylus"],["sub","text/vnd.dvb.subtitle"],["sus","application/vnd.sus-calendar"],["susp","application/vnd.sus-calendar"],["sv4cpio","application/x-sv4cpio"],["sv4crc","application/x-sv4crc"],["svc","application/vnd.dvb.service"],["svd","application/vnd.svd"],["svg","image/svg+xml"],["svgz","image/svg+xml"],["swa","application/x-director"],["swf","application/x-shockwave-flash"],["swi","application/vnd.aristanetworks.swi"],["swidtag","application/swid+xml"],["sxc","application/vnd.sun.xml.calc"],["sxd","application/vnd.sun.xml.draw"],["sxg","application/vnd.sun.xml.writer.global"],["sxi","application/vnd.sun.xml.impress"],["sxm","application/vnd.sun.xml.math"],["sxw","application/vnd.sun.xml.writer"],["t","text/troff"],["t3","application/x-t3vm-image"],["t38","image/t38"],["taglet","application/vnd.mynfc"],["tao","application/vnd.tao.intent-module-archive"],["tap","image/vnd.tencent.tap"],["tar","application/x-tar"],["tcap","application/vnd.3gpp2.tcap"],["tcl","application/x-tcl"],["td","application/urc-targetdesc+xml"],["teacher","application/vnd.smart.teacher"],["tei","application/tei+xml"],["teicorpus","application/tei+xml"],["tex","application/x-tex"],["texi","application/x-texinfo"],["texinfo","application/x-texinfo"],["text","text/plain"],["tfi","application/thraud+xml"],["tfm","application/x-tex-tfm"],["tfx","image/tiff-fx"],["tga","image/x-tga"],["tgz","application/x-tar"],["thmx","application/vnd.ms-officetheme"],["tif","image/tiff"],["tiff","image/tiff"],["tk","application/x-tcl"],["tmo","application/vnd.tmobile-livetv"],["toml","application/toml"],["torrent","application/x-bittorrent"],["tpl","application/vnd.groove-tool-template"],["tpt","application/vnd.trid.tpt"],["tr","text/troff"],["tra","application/vnd.trueapp"],["trig","application/trig"],["trm","application/x-msterminal"],["ts","video/mp2t"],["tsd","application/timestamped-data"],["tsv","text/tab-separated-values"],["ttc","font/collection"],["ttf","font/ttf"],["ttl","text/turtle"],["ttml","application/ttml+xml"],["twd","application/vnd.simtech-mindmapper"],["twds","application/vnd.simtech-mindmapper"],["txd","application/vnd.genomatix.tuxedo"],["txf","application/vnd.mobius.txf"],["txt","text/plain"],["u8dsn","message/global-delivery-status"],["u8hdr","message/global-headers"],["u8mdn","message/global-disposition-notification"],["u8msg","message/global"],["u32","application/x-authorware-bin"],["ubj","application/ubjson"],["udeb","application/x-debian-package"],["ufd","application/vnd.ufdl"],["ufdl","application/vnd.ufdl"],["ulx","application/x-glulx"],["umj","application/vnd.umajin"],["unityweb","application/vnd.unity"],["uoml","application/vnd.uoml+xml"],["uri","text/uri-list"],["uris","text/uri-list"],["urls","text/uri-list"],["usdz","model/vnd.usdz+zip"],["ustar","application/x-ustar"],["utz","application/vnd.uiq.theme"],["uu","text/x-uuencode"],["uva","audio/vnd.dece.audio"],["uvd","application/vnd.dece.data"],["uvf","application/vnd.dece.data"],["uvg","image/vnd.dece.graphic"],["uvh","video/vnd.dece.hd"],["uvi","image/vnd.dece.graphic"],["uvm","video/vnd.dece.mobile"],["uvp","video/vnd.dece.pd"],["uvs","video/vnd.dece.sd"],["uvt","application/vnd.dece.ttml+xml"],["uvu","video/vnd.uvvu.mp4"],["uvv","video/vnd.dece.video"],["uvva","audio/vnd.dece.audio"],["uvvd","application/vnd.dece.data"],["uvvf","application/vnd.dece.data"],["uvvg","image/vnd.dece.graphic"],["uvvh","video/vnd.dece.hd"],["uvvi","image/vnd.dece.graphic"],["uvvm","video/vnd.dece.mobile"],["uvvp","video/vnd.dece.pd"],["uvvs","video/vnd.dece.sd"],["uvvt","application/vnd.dece.ttml+xml"],["uvvu","video/vnd.uvvu.mp4"],["uvvv","video/vnd.dece.video"],["uvvx","application/vnd.dece.unspecified"],["uvvz","application/vnd.dece.zip"],["uvx","application/vnd.dece.unspecified"],["uvz","application/vnd.dece.zip"],["vbox","application/x-virtualbox-vbox"],["vbox-extpack","application/x-virtualbox-vbox-extpack"],["vcard","text/vcard"],["vcd","application/x-cdlink"],["vcf","text/x-vcard"],["vcg","application/vnd.groove-vcard"],["vcs","text/x-vcalendar"],["vcx","application/vnd.vcx"],["vdi","application/x-virtualbox-vdi"],["vds","model/vnd.sap.vds"],["vhd","application/x-virtualbox-vhd"],["vis","application/vnd.visionary"],["viv","video/vnd.vivo"],["vlc","application/videolan"],["vmdk","application/x-virtualbox-vmdk"],["vob","video/x-ms-vob"],["vor","application/vnd.stardivision.writer"],["vox","application/x-authorware-bin"],["vrml","model/vrml"],["vsd","application/vnd.visio"],["vsf","application/vnd.vsf"],["vss","application/vnd.visio"],["vst","application/vnd.visio"],["vsw","application/vnd.visio"],["vtf","image/vnd.valve.source.texture"],["vtt","text/vtt"],["vtu","model/vnd.vtu"],["vxml","application/voicexml+xml"],["w3d","application/x-director"],["wad","application/x-doom"],["wadl","application/vnd.sun.wadl+xml"],["war","application/java-archive"],["wasm","application/wasm"],["wav","audio/x-wav"],["wax","audio/x-ms-wax"],["wbmp","image/vnd.wap.wbmp"],["wbs","application/vnd.criticaltools.wbs+xml"],["wbxml","application/wbxml"],["wcm","application/vnd.ms-works"],["wdb","application/vnd.ms-works"],["wdp","image/vnd.ms-photo"],["weba","audio/webm"],["webapp","application/x-web-app-manifest+json"],["webm","video/webm"],["webmanifest","application/manifest+json"],["webp","image/webp"],["wg","application/vnd.pmi.widget"],["wgt","application/widget"],["wks","application/vnd.ms-works"],["wm","video/x-ms-wm"],["wma","audio/x-ms-wma"],["wmd","application/x-ms-wmd"],["wmf","image/wmf"],["wml","text/vnd.wap.wml"],["wmlc","application/wmlc"],["wmls","text/vnd.wap.wmlscript"],["wmlsc","application/vnd.wap.wmlscriptc"],["wmv","video/x-ms-wmv"],["wmx","video/x-ms-wmx"],["wmz","application/x-msmetafile"],["woff","font/woff"],["woff2","font/woff2"],["word","application/msword"],["wpd","application/vnd.wordperfect"],["wpl","application/vnd.ms-wpl"],["wps","application/vnd.ms-works"],["wqd","application/vnd.wqd"],["wri","application/x-mswrite"],["wrl","model/vrml"],["wsc","message/vnd.wfa.wsc"],["wsdl","application/wsdl+xml"],["wspolicy","application/wspolicy+xml"],["wtb","application/vnd.webturbo"],["wvx","video/x-ms-wvx"],["x3d","model/x3d+xml"],["x3db","model/x3d+fastinfoset"],["x3dbz","model/x3d+binary"],["x3dv","model/x3d-vrml"],["x3dvz","model/x3d+vrml"],["x3dz","model/x3d+xml"],["x32","application/x-authorware-bin"],["x_b","model/vnd.parasolid.transmit.binary"],["x_t","model/vnd.parasolid.transmit.text"],["xaml","application/xaml+xml"],["xap","application/x-silverlight-app"],["xar","application/vnd.xara"],["xav","application/xcap-att+xml"],["xbap","application/x-ms-xbap"],["xbd","application/vnd.fujixerox.docuworks.binder"],["xbm","image/x-xbitmap"],["xca","application/xcap-caps+xml"],["xcs","application/calendar+xml"],["xdf","application/xcap-diff+xml"],["xdm","application/vnd.syncml.dm+xml"],["xdp","application/vnd.adobe.xdp+xml"],["xdssc","application/dssc+xml"],["xdw","application/vnd.fujixerox.docuworks"],["xel","application/xcap-el+xml"],["xenc","application/xenc+xml"],["xer","application/patch-ops-error+xml"],["xfdf","application/vnd.adobe.xfdf"],["xfdl","application/vnd.xfdl"],["xht","application/xhtml+xml"],["xhtml","application/xhtml+xml"],["xhvml","application/xv+xml"],["xif","image/vnd.xiff"],["xl","application/excel"],["xla","application/vnd.ms-excel"],["xlam","application/vnd.ms-excel.addin.macroEnabled.12"],["xlc","application/vnd.ms-excel"],["xlf","application/xliff+xml"],["xlm","application/vnd.ms-excel"],["xls","application/vnd.ms-excel"],["xlsb","application/vnd.ms-excel.sheet.binary.macroEnabled.12"],["xlsm","application/vnd.ms-excel.sheet.macroEnabled.12"],["xlsx","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],["xlt","application/vnd.ms-excel"],["xltm","application/vnd.ms-excel.template.macroEnabled.12"],["xltx","application/vnd.openxmlformats-officedocument.spreadsheetml.template"],["xlw","application/vnd.ms-excel"],["xm","audio/xm"],["xml","application/xml"],["xns","application/xcap-ns+xml"],["xo","application/vnd.olpc-sugar"],["xop","application/xop+xml"],["xpi","application/x-xpinstall"],["xpl","application/xproc+xml"],["xpm","image/x-xpixmap"],["xpr","application/vnd.is-xpr"],["xps","application/vnd.ms-xpsdocument"],["xpw","application/vnd.intercon.formnet"],["xpx","application/vnd.intercon.formnet"],["xsd","application/xml"],["xsl","application/xml"],["xslt","application/xslt+xml"],["xsm","application/vnd.syncml+xml"],["xspf","application/xspf+xml"],["xul","application/vnd.mozilla.xul+xml"],["xvm","application/xv+xml"],["xvml","application/xv+xml"],["xwd","image/x-xwindowdump"],["xyz","chemical/x-xyz"],["xz","application/x-xz"],["yaml","text/yaml"],["yang","application/yang"],["yin","application/yin+xml"],["yml","text/yaml"],["ymp","text/x-suse-ymp"],["z","application/x-compress"],["z1","application/x-zmachine"],["z2","application/x-zmachine"],["z3","application/x-zmachine"],["z4","application/x-zmachine"],["z5","application/x-zmachine"],["z6","application/x-zmachine"],["z7","application/x-zmachine"],["z8","application/x-zmachine"],["zaz","application/vnd.zzazz.deck+xml"],["zip","application/zip"],["zir","application/vnd.zul"],["zirz","application/vnd.zul"],["zmm","application/vnd.handheld-entertainment+xml"],["zsh","text/x-scriptzsh"]]);function mo(e,t,n){const a=iq(e),{webkitRelativePath:s}=e,l=typeof t=="string"?t:typeof s=="string"&&s.length>0?s:`./${e.name}`;return typeof a.path!="string"&&zk(a,"path",l),zk(a,"relativePath",l),a}function iq(e){const{name:t}=e;if(t&&t.lastIndexOf(".")!==-1&&!e.type){const a=t.split(".").pop().toLowerCase(),s=aq.get(a);s&&Object.defineProperty(e,"type",{value:s,writable:!1,configurable:!1,enumerable:!0})}return e}function zk(e,t,n){Object.defineProperty(e,t,{value:n,writable:!1,configurable:!1,enumerable:!0})}const sq=[".DS_Store","Thumbs.db"];function oq(e){return ps(this,void 0,void 0,function*(){return Nd(e)&&lq(e.dataTransfer)?pq(e.dataTransfer,e.type):cq(e)?uq(e):Array.isArray(e)&&e.every(t=>"getFile"in t&&typeof t.getFile=="function")?dq(e):[]})}function lq(e){return Nd(e)}function cq(e){return Nd(e)&&Nd(e.target)}function Nd(e){return typeof e=="object"&&e!==null}function uq(e){return sg(e.target.files).map(t=>mo(t))}function dq(e){return ps(this,void 0,void 0,function*(){return(yield Promise.all(e.map(n=>n.getFile()))).map(n=>mo(n))})}function pq(e,t){return ps(this,void 0,void 0,function*(){if(e.items){const n=sg(e.items).filter(s=>s.kind==="file");if(t!=="drop")return n;const a=yield Promise.all(n.map(fq));return $k(DN(a))}return $k(sg(e.files).map(n=>mo(n)))})}function $k(e){return e.filter(t=>sq.indexOf(t.name)===-1)}function sg(e){if(e===null)return[];const t=[];for(let n=0;n<e.length;n++){const a=e[n];t.push(a)}return t}function fq(e){if(typeof e.webkitGetAsEntry!="function")return Ik(e);const t=e.webkitGetAsEntry();return t&&t.isDirectory?zN(t):Ik(e,t)}function DN(e){return e.reduce((t,n)=>[...t,...Array.isArray(n)?DN(n):[n]],[])}function Ik(e,t){return ps(this,void 0,void 0,function*(){var n;if(globalThis.isSecureContext&&typeof e.getAsFileSystemHandle=="function"){const l=yield e.getAsFileSystemHandle();if(l===null)throw new Error(`${e} is not a File`);if(l!==void 0){const u=yield l.getFile();return u.handle=l,mo(u)}}const a=e.getAsFile();if(!a)throw new Error(`${e} is not a File`);return mo(a,(n=t==null?void 0:t.fullPath)!==null&&n!==void 0?n:void 0)})}function hq(e){return ps(this,void 0,void 0,function*(){return e.isDirectory?zN(e):mq(e)})}function zN(e){const t=e.createReader();return new Promise((n,a)=>{const s=[];function l(){t.readEntries(u=>ps(this,void 0,void 0,function*(){if(u.length){const d=Promise.all(u.map(hq));s.push(d),l()}else try{const d=yield Promise.all(s);n(d)}catch(d){a(d)}}),u=>{a(u)})}l()})}function mq(e){return ps(this,void 0,void 0,function*(){return new Promise((t,n)=>{e.file(a=>{const s=mo(a,e.fullPath);t(s)},a=>{n(a)})})})}var Fu={},Pk;function gq(){return Pk||(Pk=1,Fu.__esModule=!0,Fu.default=function(e,t){if(e&&t){var n=Array.isArray(t)?t:t.split(",");if(n.length===0)return!0;var a=e.name||"",s=(e.type||"").toLowerCase(),l=s.replace(/\/.*$/,"");return n.some(function(u){var d=u.trim().toLowerCase();return d.charAt(0)==="."?a.toLowerCase().endsWith(d):d.endsWith("/*")?l===d.replace(/\/.*$/,""):s===d})}return!0}),Fu}var vq=gq();const gm=Wl(vq);function Uk(e){return xq(e)||bq(e)||IN(e)||yq()}function yq(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
@@ -1658,4 +1658,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
1658
1658
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Vq(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function Wq(e){if(Array.isArray(e))return lg(e)}function vm(e,t){return Yq(e)||Kq(e,t)||HN(e,t)||Zq()}function Zq(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
1659
1659
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function HN(e,t){if(e){if(typeof e=="string")return lg(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return lg(e,t)}}function lg(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,a=new Array(t);n<t;n++)a[n]=e[n];return a}function Kq(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var a=[],s=!0,l=!1,u,d;try{for(n=n.call(e);!(s=(u=n.next()).done)&&(a.push(u.value),!(t&&a.length===t));s=!0);}catch(f){l=!0,d=f}finally{try{!s&&n.return!=null&&n.return()}finally{if(l)throw d}}return a}}function Yq(e){if(Array.isArray(e))return e}function Wk(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,a)}return n}function zt(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Wk(Object(n),!0).forEach(function(a){cg(e,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Wk(Object(n)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(n,a))})}return e}function cg(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Ad(e,t){if(e==null)return{};var n=Qq(e,t),a,s;if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(s=0;s<l.length;s++)a=l[s],!(t.indexOf(a)>=0)&&Object.prototype.propertyIsEnumerable.call(e,a)&&(n[a]=e[a])}return n}function Qq(e,t){if(e==null)return{};var n={},a=Object.keys(e),s,l;for(l=0;l<a.length;l++)s=a[l],!(t.indexOf(s)>=0)&&(n[s]=e[s]);return n}var Mv=w.forwardRef(function(e,t){var n=e.children,a=Ad(e,Bq),s=GN(a),l=s.open,u=Ad(s,Fq);return w.useImperativeHandle(t,function(){return{open:l}},[l]),Ve.createElement(w.Fragment,null,n(zt(zt({},u),{},{open:l})))});Mv.displayName="Dropzone";var qN={disabled:!1,getFilesFromEvent:oq,maxSize:1/0,minSize:0,multiple:!0,maxFiles:0,preventDropOnDocument:!0,noClick:!1,noKeyboard:!1,noDrag:!1,noDragEventsBubbling:!1,validator:null,useFsAccessApi:!1,autoFocus:!1};Mv.defaultProps=qN;Mv.propTypes={children:At.func,accept:At.objectOf(At.arrayOf(At.string)),multiple:At.bool,preventDropOnDocument:At.bool,noClick:At.bool,noKeyboard:At.bool,noDrag:At.bool,noDragEventsBubbling:At.bool,minSize:At.number,maxSize:At.number,maxFiles:At.number,disabled:At.bool,getFilesFromEvent:At.func,onFileDialogCancel:At.func,onFileDialogOpen:At.func,useFsAccessApi:At.bool,autoFocus:At.bool,onDragEnter:At.func,onDragLeave:At.func,onDragOver:At.func,onDrop:At.func,onDropAccepted:At.func,onDropRejected:At.func,onError:At.func,validator:At.func};var ug={isFocused:!1,isFileDialogActive:!1,isDragActive:!1,isDragAccept:!1,isDragReject:!1,isDragGlobal:!1,acceptedFiles:[],fileRejections:[]};function GN(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=zt(zt({},qN),e),n=t.accept,a=t.disabled,s=t.getFilesFromEvent,l=t.maxSize,u=t.minSize,d=t.multiple,f=t.maxFiles,h=t.onDragEnter,g=t.onDragLeave,m=t.onDragOver,y=t.onDrop,b=t.onDropAccepted,k=t.onDropRejected,j=t.onFileDialogCancel,N=t.onFileDialogOpen,S=t.useFsAccessApi,A=t.autoFocus,E=t.preventDropOnDocument,T=t.noClick,U=t.noKeyboard,_=t.noDrag,z=t.noDragEventsBubbling,q=t.onError,D=t.validator,R=w.useMemo(function(){return Iq(n)},[n]),$=w.useMemo(function(){return $q(n)},[n]),F=w.useMemo(function(){return typeof N=="function"?N:Zk},[N]),K=w.useMemo(function(){return typeof j=="function"?j:Zk},[j]),I=w.useRef(null),H=w.useRef(null),B=w.useReducer(Xq,ug),W=vm(B,2),Q=W[0],V=W[1],L=Q.isFocused,P=Q.isFileDialogActive,G=w.useRef(typeof window<"u"&&window.isSecureContext&&S&&zq()),O=function(){!G.current&&P&&setTimeout(function(){if(H.current){var X=H.current.files;X.length||(V({type:"closeDialog"}),K())}},300)};w.useEffect(function(){return window.addEventListener("focus",O,!1),function(){window.removeEventListener("focus",O,!1)}},[H,P,K,G]);var ne=w.useRef([]),ue=w.useRef([]),le=function(X){I.current&&I.current.contains(X.target)||(X.preventDefault(),ne.current=[])};w.useEffect(function(){return E&&(document.addEventListener("dragover",Gk,!1),document.addEventListener("drop",le,!1)),function(){E&&(document.removeEventListener("dragover",Gk),document.removeEventListener("drop",le))}},[I,E]),w.useEffect(function(){var ye=function(he){ue.current=[].concat(Vk(ue.current),[he.target]),Nl(he)&&V({isDragGlobal:!0,type:"setDragGlobal"})},X=function(he){ue.current=ue.current.filter(function(Le){return Le!==he.target&&Le!==null}),!(ue.current.length>0)&&V({isDragGlobal:!1,type:"setDragGlobal"})},Z=function(){ue.current=[],V({isDragGlobal:!1,type:"setDragGlobal"})},ee=function(){ue.current=[],V({isDragGlobal:!1,type:"setDragGlobal"})};return document.addEventListener("dragenter",ye,!1),document.addEventListener("dragleave",X,!1),document.addEventListener("dragend",Z,!1),document.addEventListener("drop",ee,!1),function(){document.removeEventListener("dragenter",ye),document.removeEventListener("dragleave",X),document.removeEventListener("dragend",Z),document.removeEventListener("drop",ee)}},[I]),w.useEffect(function(){return!a&&A&&I.current&&I.current.focus(),function(){}},[I,A,a]);var be=w.useCallback(function(ye){q?q(ye):console.error(ye)},[q]),_e=w.useCallback(function(ye){ye.preventDefault(),ye.persist(),$t(ye),ne.current=[].concat(Vk(ne.current),[ye.target]),Nl(ye)&&Promise.resolve(s(ye)).then(function(X){if(!(Ed(ye)&&!z)){var Z=X.length,ee=Z>0&&Oq({files:X,accept:R,minSize:u,maxSize:l,multiple:d,maxFiles:f,validator:D}),ce=Z>0&&!ee;V({isDragAccept:ee,isDragReject:ce,isDragActive:!0,type:"setDraggedFiles"}),h&&h(ye)}}).catch(function(X){return be(X)})},[s,h,be,z,R,u,l,d,f,D]),Ee=w.useCallback(function(ye){ye.preventDefault(),ye.persist(),$t(ye);var X=Nl(ye);if(X&&ye.dataTransfer)try{ye.dataTransfer.dropEffect="copy"}catch{}return X&&m&&m(ye),!1},[m,z]),Ie=w.useCallback(function(ye){ye.preventDefault(),ye.persist(),$t(ye);var X=ne.current.filter(function(ee){return I.current&&I.current.contains(ee)}),Z=X.indexOf(ye.target);Z!==-1&&X.splice(Z,1),ne.current=X,!(X.length>0)&&(V({type:"setDraggedFiles",isDragActive:!1,isDragAccept:!1,isDragReject:!1}),Nl(ye)&&g&&g(ye))},[I,g,z]),We=w.useCallback(function(ye,X){var Z=[],ee=[];ye.forEach(function(ce){var he=PN(ce,R),Le=vm(he,2),He=Le[0],Ce=Le[1],Fe=UN(ce,u,l),et=vm(Fe,2),Ne=et[0],Wt=et[1],_t=D?D(ce):null;if(He&&Ne&&!_t)Z.push(ce);else{var Hr=[Ce,Wt];_t&&(Hr=Hr.concat(_t)),ee.push({file:ce,errors:Hr.filter(function(dr){return dr})})}}),(!d&&Z.length>1||d&&f>=1&&Z.length>f)&&(Z.forEach(function(ce){ee.push({file:ce,errors:[_q]})}),Z.splice(0)),V({acceptedFiles:Z,fileRejections:ee,type:"setFiles"}),y&&y(Z,ee,X),ee.length>0&&k&&k(ee,X),Z.length>0&&b&&b(Z,X)},[V,d,R,u,l,f,y,b,k,D]),Se=w.useCallback(function(ye){ye.preventDefault(),ye.persist(),$t(ye),ne.current=[],Nl(ye)&&Promise.resolve(s(ye)).then(function(X){Ed(ye)&&!z||We(X,ye)}).catch(function(X){return be(X)}),V({type:"reset"})},[s,We,be,z]),ft=w.useCallback(function(){if(G.current){V({type:"openDialog"}),F();var ye={multiple:d,types:$};window.showOpenFilePicker(ye).then(function(X){return s(X)}).then(function(X){We(X,null),V({type:"closeDialog"})}).catch(function(X){Pq(X)?(K(X),V({type:"closeDialog"})):Uq(X)?(G.current=!1,H.current?(H.current.value=null,H.current.click()):be(new Error("Cannot open the file picker because the https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API is not supported and no <input> was provided."))):be(X)});return}H.current&&(V({type:"openDialog"}),F(),H.current.value=null,H.current.click())},[V,F,K,S,We,be,$,d]),De=w.useCallback(function(ye){!I.current||!I.current.isEqualNode(ye.target)||(ye.key===" "||ye.key==="Enter"||ye.keyCode===32||ye.keyCode===13)&&(ye.preventDefault(),ft())},[I,ft]),qe=w.useCallback(function(){V({type:"focus"})},[]),ke=w.useCallback(function(){V({type:"blur"})},[]),lt=w.useCallback(function(){T||(Dq()?setTimeout(ft,0):ft())},[T,ft]),xe=function(X){return a?null:X},Oe=function(X){return U?null:xe(X)},Ot=function(X){return _?null:xe(X)},$t=function(X){z&&X.stopPropagation()},Yt=w.useMemo(function(){return function(){var ye=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},X=ye.refKey,Z=X===void 0?"ref":X,ee=ye.role,ce=ye.onKeyDown,he=ye.onFocus,Le=ye.onBlur,He=ye.onClick,Ce=ye.onDragEnter,Fe=ye.onDragOver,et=ye.onDragLeave,Ne=ye.onDrop,Wt=Ad(ye,Hq);return zt(zt(cg({onKeyDown:Oe(ea(ce,De)),onFocus:Oe(ea(he,qe)),onBlur:Oe(ea(Le,ke)),onClick:xe(ea(He,lt)),onDragEnter:Ot(ea(Ce,_e)),onDragOver:Ot(ea(Fe,Ee)),onDragLeave:Ot(ea(et,Ie)),onDrop:Ot(ea(Ne,Se)),role:typeof ee=="string"&&ee!==""?ee:"presentation"},Z,I),!a&&!U?{tabIndex:0}:{}),Wt)}},[I,De,qe,ke,lt,_e,Ee,Ie,Se,U,_,a]),qt=w.useCallback(function(ye){ye.stopPropagation()},[]),ut=w.useMemo(function(){return function(){var ye=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},X=ye.refKey,Z=X===void 0?"ref":X,ee=ye.onChange,ce=ye.onClick,he=Ad(ye,qq),Le=cg({accept:R,multiple:d,type:"file",style:{border:0,clip:"rect(0, 0, 0, 0)",clipPath:"inset(50%)",height:"1px",margin:"0 -1px -1px 0",overflow:"hidden",padding:0,position:"absolute",width:"1px",whiteSpace:"nowrap"},onChange:xe(ea(ee,Se)),onClick:xe(ea(ce,qt)),tabIndex:-1},Z,H);return zt(zt({},Le),he)}},[H,n,d,Se,a]);return zt(zt({},Q),{},{isFocused:L&&!a,getRootProps:Yt,getInputProps:ut,rootRef:I,inputRef:H,open:xe(ft)})}function Xq(e,t){switch(t.type){case"focus":return zt(zt({},e),{},{isFocused:!0});case"blur":return zt(zt({},e),{},{isFocused:!1});case"openDialog":return zt(zt({},ug),{},{isFileDialogActive:!0});case"closeDialog":return zt(zt({},e),{},{isFileDialogActive:!1});case"setDraggedFiles":return zt(zt({},e),{},{isDragActive:t.isDragActive,isDragAccept:t.isDragAccept,isDragReject:t.isDragReject});case"setFiles":return zt(zt({},e),{},{acceptedFiles:t.acceptedFiles,fileRejections:t.fileRejections,isDragReject:!1});case"setDragGlobal":return zt(zt({},e),{},{isDragGlobal:t.isDragGlobal});case"reset":return zt({},ug);default:return e}}function Zk(){}function Jq({value:e,onChange:t,options:n,placeholder:a="Select…",disabled:s=!1,className:l,ariaLabel:u,prefixIcon:d}){const[f,h]=w.useState(!1),[g,m]=w.useState(null),[y,b]=w.useState(()=>{const D=n.findIndex(R=>R.value===e);return D>=0?D:0}),k=w.useRef(null),j=w.useRef(null),N=w.useRef(null),S=n.find(D=>D.value===e),A=(S==null?void 0:S.label)??a,E=w.useCallback(()=>{var D;h(!1),(D=j.current)==null||D.focus()},[]),T=w.useCallback(()=>{const D=j.current;if(!D)return;const R=D.getBoundingClientRect(),$=Math.min(240,n.length*36+16),F=window.innerHeight-R.bottom,K=R.top,I=F<$+16&&K>F?"above":"below";m({left:R.left,top:I==="below"?R.bottom+4:R.top-4,width:R.width,placement:I})},[n.length]);w.useLayoutEffect(()=>{f&&T()},[f,T]),w.useEffect(()=>{if(!f)return;const D=()=>T(),R=()=>T(),$=K=>{var H,B;const I=K.target;(H=k.current)!=null&&H.contains(I)||(B=N.current)!=null&&B.contains(I)||h(!1)},F=K=>{K.key==="Escape"&&(K.preventDefault(),E())};return window.addEventListener("scroll",D,!0),window.addEventListener("resize",R),document.addEventListener("mousedown",$),document.addEventListener("keydown",F),()=>{window.removeEventListener("scroll",D,!0),window.removeEventListener("resize",R),document.removeEventListener("mousedown",$),document.removeEventListener("keydown",F)}},[f,E,T]),w.useEffect(()=>{if(f){const D=n.findIndex(R=>R.value===e);b(D>=0?D:0),requestAnimationFrame(()=>{var R;return(R=N.current)==null?void 0:R.focus()})}},[f,e,n]),w.useEffect(()=>{s&&f&&h(!1)},[s,f]);const U=D=>{s||(D.key==="ArrowDown"||D.key==="Enter"||D.key===" ")&&(D.preventDefault(),h(!0))},_=D=>{var R;if(D.key==="ArrowDown")D.preventDefault(),b($=>{var F;for(let K=1;K<=n.length;K++){const I=($+K)%n.length;if(!((F=n[I])!=null&&F.disabled))return I}return $});else if(D.key==="ArrowUp")D.preventDefault(),b($=>{var F;for(let K=1;K<=n.length;K++){const I=($-K+n.length)%n.length;if(!((F=n[I])!=null&&F.disabled))return I}return $});else if(D.key==="Enter"){D.preventDefault();const $=n[y];$&&!$.disabled&&(t($.value),E())}else if(D.key==="Home"){D.preventDefault();const $=n.findIndex(F=>!F.disabled);$>=0&&b($)}else if(D.key==="End"){D.preventDefault();let $=-1;for(let F=n.length-1;F>=0;F--)if(!((R=n[F])!=null&&R.disabled)){$=F;break}$>=0&&b($)}},z=["v10-select",l,s?"disabled":"",f?"open":""].filter(Boolean).join(" "),q=g?g.placement==="below"?{position:"fixed",left:g.left,top:g.top,width:g.width}:{position:"fixed",left:g.left,top:g.top,width:g.width,transform:"translateY(-100%)"}:void 0;return o.jsxs("div",{ref:k,className:z,children:[o.jsxs("button",{ref:j,type:"button",className:"v10-select-trigger",onClick:()=>!s&&h(D=>!D),onKeyDown:U,disabled:s,"aria-haspopup":"listbox","aria-expanded":f,"aria-label":u,children:[d&&o.jsx("span",{className:"v10-select-prefix","aria-hidden":"true",children:d}),o.jsx("span",{className:`v10-select-value ${S?"":"placeholder"}`,children:A}),o.jsx(uO,{className:"v10-select-caret",size:12,"aria-hidden":"true"})]}),f&&g&&W2.createPortal(o.jsxs("ul",{ref:N,className:`v10-select-menu v10-select-menu-${g.placement}`,role:"listbox",tabIndex:-1,onKeyDown:_,style:q,children:[n.length===0&&o.jsx("li",{className:"v10-select-option empty","aria-disabled":"true",children:"No options"}),n.map((D,R)=>o.jsx("li",{role:"option","aria-selected":D.value===e,title:D.label,className:["v10-select-option",D.value===e?"selected":"",R===y?"highlighted":"",D.disabled?"disabled":""].filter(Boolean).join(" "),onMouseEnter:()=>b(R),onMouseDown:$=>$.preventDefault(),onClick:()=>{s||D.disabled||(t(D.value),E())},children:D.label},D.value))]}),document.body)]})}function Kk(e){return e.bridgeOnline?"connected":e.status==="connecting"?"known":e.status==="degraded"?"degraded":"offline"}function eG(e,t){return t?"Session history":e.chatReady?`${e.name} connected`:e.status==="connecting"?`${e.name} is connecting…`:e.status==="degraded"?`${e.name} degraded`:`${e.name} is unavailable`}function tG(e){const[t,n]=w.useState(!1),[a,s]=w.useState(!1),l=w.useRef(null),u=w.useRef(null),d=w.useRef(null);w.useLayoutEffect(()=>{if(!t)return;const m=d.current,y=u.current;if(!m||!y)return;const k=(y.closest(".v10-panel-right")||document.body).getBoundingClientRect();y.getBoundingClientRect().left+m.offsetWidth>k.right-4?s(!0):s(!1)},[t]);const f=w.useCallback(()=>{var m;n(!1),(m=u.current)==null||m.focus()},[]);w.useEffect(()=>{if(!t)return;const m=b=>{var k;(k=l.current)!=null&&k.contains(b.target)||n(!1)},y=b=>{b.key==="Escape"&&(b.preventDefault(),f())};return document.addEventListener("mousedown",m),document.addEventListener("keydown",y),()=>{document.removeEventListener("mousedown",m),document.removeEventListener("keydown",y)}},[t,f]),w.useEffect(()=>{var y;if(!t)return;const m=(y=d.current)==null?void 0:y.querySelector(".v10-agent-tab-menu-item:not(:disabled)");m==null||m.focus()},[t]);const h=m=>{(m.key==="ArrowDown"||m.key==="Enter"||m.key===" ")&&(m.preventDefault(),n(!0))},g=m=>{var N,S;if(m.key==="Tab"){n(!1);return}if(m.key!=="ArrowDown"&&m.key!=="ArrowUp")return;m.preventDefault();const y=Array.from(((N=d.current)==null?void 0:N.querySelectorAll(".v10-agent-tab-menu-item:not(:disabled)"))??[]);if(y.length===0)return;const b=y.findIndex(A=>A===document.activeElement),k=m.key==="ArrowDown"?1:-1,j=b===-1?k===1?0:y.length-1:(b+k+y.length)%y.length;(S=y[j])==null||S.focus()};return o.jsxs("div",{className:"v10-agent-tab-menu",ref:l,children:[o.jsx("button",{ref:u,type:"button",className:"v10-agent-tab-menu-trigger","aria-label":`More actions for ${e.integration.name}`,"aria-haspopup":"menu","aria-expanded":t,title:`More actions for ${e.integration.name}`,onClick:m=>{m.stopPropagation(),n(y=>!y)},onKeyDown:h,children:o.jsx(mO,{"aria-hidden":"true",size:14})}),t&&o.jsxs("div",{ref:d,className:`v10-agent-tab-menu-popover${a?" align-right":""}`,role:"menu",onKeyDown:g,children:[o.jsxs("div",{className:"v10-agent-tab-menu-status","aria-hidden":"true",children:[o.jsx("span",{className:`v10-agents-stat-dot ${e.statusDotClass}`}),o.jsx("span",{children:e.statusLabel})]}),o.jsx("button",{type:"button",role:"menuitem",className:"v10-agent-tab-menu-item",disabled:e.refreshBusy,onClick:()=>{f(),e.onRefresh()},children:e.refreshBusy?"Refreshing…":"Refresh"}),e.canDisconnect&&o.jsx("button",{type:"button",role:"menuitem",className:"v10-agent-tab-menu-item danger",onClick:()=>{f(),e.onDisconnect()},children:"Disconnect"})]})]})}function VN(e,t){return(t==null?void 0:t.trim())||`integration:${e}`}function Td(e){const t=e.sessionId??e.defaultSessionId??to(e.integrationId);return{integrationId:e.integrationId,sessionId:t,stateKey:VN(e.integrationId,t)}}function WN(e,t){for(const n of t)if(e===n.id||e.startsWith(`${n.id}:`))return{id:n.id,name:n.name};return null}function ZN(e){var n;if(e.selectedSessionId==null)return!1;const t=e.integrations.find(a=>a.id===e.integrationId);return!(((n=WN(e.selectedSessionId,e.integrations))==null?void 0:n.id)!==e.integrationId||t!=null&&t.defaultSessionId&&e.selectedSessionId!==t.defaultSessionId&&rG(e.integrationId,e.selectedSessionId))}function nG(e){return ZN(e)}function rG(e,t){return t===`${e}:dkg-ui`||t.startsWith(`${e}:dkg-ui:profile-`)||t.startsWith(`${e}:dkg-ui:home-`)||t.startsWith(`${e}:dkg-ui:transport-`)}function Yk(e,t){const n=e.flatMap(a=>{var d;const s=WN(a.session,t);if(!s)return[];const l=a.messages.find(f=>f.author==="user"),u=a.messages[a.messages.length-1];return[{sessionId:a.session,integrationId:s.id,integrationName:s.name,preview:((d=l==null?void 0:l.text)==null?void 0:d.slice(0,60))||a.session,messageCount:a.messages.length,lastTs:u==null?void 0:u.ts}]});return n.sort((a,s)=>{const l=Date.parse(a.lastTs??""),u=Date.parse(s.lastTs??"");return Number.isFinite(l)&&Number.isFinite(u)?u-l:String(s.lastTs??"").localeCompare(String(a.lastTs??""))}),n}function KN(e,t,n,a,s){var u;const l=Td({integrationId:e,sessionId:t,defaultSessionId:s});return(((u=n[l.stateKey])==null?void 0:u.length)??0)>0||(l.sessionId?a.some(d=>d.sessionId===l.sessionId):!1)}function YN(e,t,n){const a=VN(e,null);return Object.entries(t).some(([s,l])=>l.length>0&&(s===a||s.startsWith(`${e}:`)))||n.some(s=>s.integrationId===e)}function aG(e){const t=[...e.integrations].sort(Xd),n=t.filter(d=>d.persistentChat),a=t.find(d=>d.id===e.selectedIntegrationId)??n[0]??null,s=a?Td({integrationId:a.id,sessionId:e.selectedSessionId,defaultSessionId:a.defaultSessionId}):null,l=a?KN(a.id,e.selectedSessionId,e.localMessagesByConversation,e.sessions,a.defaultSessionId):!1,u=a?YN(a.id,e.localMessagesByConversation,e.sessions):!1;return{sortedIntegrations:t,connectedIntegrations:n,selectedIntegration:a,selectedConversation:s,selectedHasConversation:l,selectedIntegrationHasAnyConversation:u}}function iG(e){const t=e.selectedIntegration,n=!!(t&&!t.persistentChat&&e.selectedHasConversation),a=!!(t&&!t.persistentChat&&e.selectedIntegrationHasAnyConversation),s=a?[t,...e.connectedAgents.filter(d=>d.id!==t.id)]:e.connectedAgents,l=e.selectedIntegrationId===Xi||!t&&e.connectedAgents.length===0||!!(t&&!t.persistentChat&&!e.selectedIntegrationHasAnyConversation),u=!e.localHistoryLoaded&&e.localMessagesCount===0&&!!(t!=null&&t.persistentChat||e.selectedHasConversation);return{showingSessionHistory:n,showingStoredSessions:a,visibleAgentTabs:s,showAddFlow:l,shouldShowConversationLoader:u}}function Xd(e,t){const n=e.id==="openclaw"?0:1,a=t.id==="openclaw"?0:1;return n!==a?n-a:e.persistentChat!==t.persistentChat?e.persistentChat?-1:1:e.name.localeCompare(t.name)}function nd(e,t){return[...e.filter(n=>n.id!==t.id),t].sort(Xd)}function sG(e,t){const n=e.find(u=>u.id===t);if(!n)return e;const a=n.connectSupported,s=a?"available":"coming_soon",l=a?"Ready to connect":"Coming next";return nd(e,{...n,configured:!1,detected:!1,persistentChat:!1,chatReady:!1,bridgeOnline:!1,bridgeStatusLabel:l,status:s,statusLabel:l,detail:a?`${n.name} is no longer attached to this node. Reconnect from the + tab when you want live chat again.`:n.detail,error:void 0,target:void 0})}function oG(e){const t=e.selectedItem;return e.selectedIntegrationId===Xi||t!=null&&(t.persistentChat||KN(e.selectedIntegrationId,e.selectedSessionId,e.localMessagesByConversation,e.sessionSummaries,t.defaultSessionId)||YN(e.selectedIntegrationId,e.localMessagesByConversation,e.sessionSummaries))}function lG(e){var X;const{integrations:t,selectedIntegrationId:n,selectedIntegration:a,selectedSessionId:s,selectedHasConversation:l,selectedIntegrationHasAnyConversation:u,onSelectIntegration:d,onConnectIntegration:f,onDisconnectIntegration:h,onRefreshIntegration:g,connectBusyId:m,refreshBusyId:y,connectNotice:b,connectError:k,localMessages:j,localHistoryLoaded:N,localChatEndRef:S,localInput:A,onLocalInputChange:E,onSendLocalMessage:T,onStopLocalStream:U,localSending:_,activeProjectId:z,availableProjects:q,projectsLoading:D,onSelectProject:R,attachments:$,onAddAttachments:F,onRemoveAttachment:K}=e,I=e.selectableProjects??q,H=$,B=H.some(ON),W=[...new Set(H.map(Z=>Z.contextGraphId))],Q=H.some(Z=>Z.status==="uploading"),L=j.some(Z=>Z.streaming)?"streaming":Q?"uploading":"idle",P=H.length>0&&H.some(Z=>Z.contextGraphId!==z),G=w.useRef(null),O=w.useRef(null),[ne,ue]=w.useState(null),le=w.useCallback(Z=>{O.current=Z,ue(Z)},[]),[be,_e]=w.useState(!1),Ee=w.useCallback(()=>{const Z=O.current;if(!Z)return;const ee=Z.scrollHeight-Z.scrollTop-Z.clientHeight;_e(ee>40)},[]),Ie=w.useCallback(()=>{const Z=O.current;Z&&Z.scrollTo({top:Z.scrollHeight,behavior:"smooth"})},[]);w.useEffect(()=>{const Z=O.current;if(!Z)return;const ee=requestAnimationFrame(()=>{const ce=Z.scrollHeight-Z.scrollTop-Z.clientHeight;_e(ce>40)});return()=>cancelAnimationFrame(ee)},[n,s,j.length]),w.useEffect(()=>{if(!ne||typeof MutationObserver>"u")return;const Z=()=>{const ce=ne.scrollHeight-ne.scrollTop-ne.clientHeight;_e(ce>40)};Z();const ee=new MutationObserver(Z);return ee.observe(ne,{childList:!0,subtree:!0,characterData:!0}),()=>ee.disconnect()},[ne]);const We=(X=e.selectedIntegration)!=null&&X.chatAttachments?e.activeProjectId?e.localSending?"sending":null:"noProject":"unsupported",Se=We===null,ft=w.useCallback(Z=>{Se&&F(Z)},[Se,F]),De=GN({onDrop:ft,noClick:!0,noKeyboard:!0}),qe=[...t].sort(Xd),ke=qe.filter(Z=>Z.persistentChat),lt=qe.filter(Z=>!Z.persistentChat),xe=a,{showingSessionHistory:Oe,showingStoredSessions:Ot,visibleAgentTabs:$t,showAddFlow:Yt,shouldShowConversationLoader:qt}=iG({connectedAgents:ke,selectedIntegration:a,selectedIntegrationId:n,selectedHasConversation:l,selectedIntegrationHasAnyConversation:u,localHistoryLoaded:N,localMessagesCount:j.length}),ut=_||!(xe!=null&&xe.chatReady),ye=!ut&&!Q&&(A.trim()!==""||B);return o.jsxs("div",{className:"v10-agents-tab",children:[o.jsxs("div",{className:"v10-agent-subtabs",role:"tablist","aria-label":"Integrated agents",children:[$t.map(Z=>{const ee=(xe==null?void 0:xe.id)===Z.id&&!Yt;return o.jsxs("div",{className:`v10-agent-subtab-group ${ee?"active":""}`,children:[o.jsxs("button",{className:`v10-agent-subtab ${ee?"active":""}`,onClick:()=>d(Z.id,{preserveSession:ZN({integrationId:Z.id,selectedSessionId:s,integrations:t}),sessionId:Z.defaultSessionId}),role:"tab","aria-selected":ee,children:[o.jsx("span",{className:`v10-agents-stat-dot ${Kk(Z)}`}),o.jsx("span",{children:Z.name})]}),ee&&o.jsx(tG,{integration:Z,statusLabel:eG(Z,Oe),statusDotClass:Kk(Z),refreshBusy:y===Z.id,canDisconnect:Z.persistentChat,onRefresh:()=>g(Z.id),onDisconnect:()=>h(Z.id)})]},Z.id)}),o.jsx("button",{className:`v10-agent-subtab add ${Yt?"active":""}`,onClick:()=>d(Xi),role:"tab","aria-selected":Yt,"aria-label":"Add another integrated agent",title:"Add another integrated agent",children:"+"})]}),Yt?o.jsxs("div",{className:"v10-agent-add-surface",children:[o.jsx("div",{className:"v10-agents-section-label",children:"Connect Another Agent"}),b&&o.jsx("div",{className:"v10-local-agent-notice",children:b}),k&&o.jsx("div",{className:"v10-local-agent-error",children:k}),o.jsxs("div",{className:"v10-local-agent-list","aria-label":"Available agent integrations",children:[lt.length===0&&o.jsx("div",{className:"v10-agent-empty-state",children:"No additional local agent integrations are available yet."}),lt.map(Z=>o.jsxs("div",{className:"v10-local-agent-detail v10-local-agent-choice",children:[o.jsxs("div",{className:"v10-local-agent-detail-head",children:[o.jsxs("div",{children:[o.jsx("div",{className:"v10-local-agent-title",children:Z.name}),o.jsx("div",{className:"v10-local-agent-subtitle",children:Z.description})]}),o.jsx("span",{className:`v10-local-agent-status-pill ${Z.status}`,children:Z.statusLabel})]}),o.jsx("p",{className:"v10-local-agent-copy",children:Z.detail}),Z.error&&o.jsx("div",{className:"v10-local-agent-warning offline",role:"status","data-testid":`local-agent-warning-${Z.id}`,children:Z.error}),Z.id==="openclaw"&&o.jsxs(o.Fragment,{children:[o.jsx("p",{className:"v10-local-agent-copy",children:"Connect your local OpenClaw once, then this tab becomes the persistent chat surface for that agent. The node can retry the bridge without forcing you back through setup."}),o.jsxs("div",{className:"v10-local-agent-actions",children:[o.jsx("button",{className:"v10-agent-send-btn secondary",onClick:()=>f(Z.id),disabled:m===Z.id,children:m===Z.id?"Connecting...":"Connect OpenClaw"}),o.jsx("a",{className:"v10-agent-link-btn",href:A7,target:"_blank",rel:"noreferrer",children:"Docs"}),o.jsx("a",{className:"v10-agent-link-btn",href:T7,target:"_blank",rel:"noreferrer",children:"Release Notes"})]})]}),Z.id==="hermes"&&o.jsxs(o.Fragment,{children:[o.jsx("p",{className:"v10-local-agent-copy",children:"Connect a local Hermes profile through the node, then this tab becomes the persistent chat surface for that profile."}),Z.connectSupported&&o.jsx("div",{className:"v10-local-agent-actions",children:o.jsx("button",{className:"v10-agent-send-btn secondary",onClick:()=>f(Z.id),disabled:m===Z.id,children:m===Z.id?"Connecting...":"Connect Hermes"})})]})]},Z.id))]})]}):xe&&o.jsxs("div",{...De.getRootProps({className:"v10-local-agent-chat-shell"}),children:[o.jsx("input",{...De.getInputProps()}),b&&o.jsx("div",{className:"v10-local-agent-notice",children:b}),k&&o.jsx("div",{className:"v10-local-agent-error",children:k}),!xe.chatReady&&o.jsx("div",{className:`v10-local-agent-warning ${xe.status==="connecting"?"connecting":"offline"}`,children:Oe?`${xe.name} is not currently attached to this node. Session history remains available here; reconnect from the + tab when you want live chat again.`:xe.status==="connecting"?`${xe.name} is still finishing setup. This chat tab stays in place and will go live automatically when the connection is ready.`:xe.status==="degraded"?xe.detail:Ot?`${xe.name} has saved sessions on this node. Open one from Sessions or reconnect from the + tab to resume live chat here.`:`${xe.name} is temporarily unavailable. Refresh after it recovers to resume chatting here.`}),De.isDragActive&&o.jsx("div",{className:`v10-drop-overlay active ${Se?"accept":"refuse"}`,role:"status","aria-live":"polite",children:o.jsxs("div",{className:"v10-drop-overlay-card",children:[Se?o.jsx(OO,{className:"v10-drop-overlay-icon",size:32,"aria-hidden":"true"}):o.jsx(sO,{className:"v10-drop-overlay-icon",size:32,"aria-hidden":"true"}),o.jsx("div",{className:"v10-drop-overlay-title",children:Se?`Drop files to attach to ${ag(q,z)}`:We==="sending"?"Wait for the current send to finish.":We==="unsupported"?`${xe.name} doesn't accept file attachments.`:"Choose a context graph before attaching files."}),o.jsx("div",{className:"v10-drop-overlay-hint",children:Se?"Release to upload to this conversation.":We==="sending"?"Drop will be accepted once the agent reply lands.":We==="unsupported"?"Try a different agent that supports attachments.":"Use the picker below the composer."})]})}),o.jsxs("div",{className:"v10-chat-messages v10-local-agent-messages",ref:le,onScroll:Ee,children:[qt&&o.jsx("div",{className:"v10-agent-empty-state",children:"Loading the latest conversation from DKG memory..."}),!qt&&j.length===0&&(()=>{const Z=Oe?{title:"No turns in this session yet.",hint:`Reconnect ${xe.name} from the + tab to start a new live thread.`}:Ot?{title:`${xe.name} has saved sessions.`,hint:"Open one from Sessions, or reconnect from + to start fresh."}:xe.chatReady?{title:`Start a conversation with ${xe.name}.`,hint:'Try: "What can you help me with?"'}:{title:`${xe.name} is offline.`,hint:"Conversation history stays here while the bridge reconnects."};return o.jsxs("div",{className:"v10-agent-empty-state",children:[o.jsx("div",{className:"v10-agent-empty-state-title",children:Z.title}),o.jsx("div",{className:"v10-agent-empty-state-hint",children:Z.hint})]})})(),j.map(Z=>o.jsxs("div",{className:`v10-chat-msg ${Z.role}`,children:[o.jsx("div",{className:`v10-chat-bubble ${Z.role}`,children:z7(Z.content,Z.role,!!Z.synthesized,!!Z.streaming,Z.failureNotice)}),Z.attachments&&Z.attachments.length>0&&o.jsx("div",{className:"v10-local-agent-attachment-row",style:{display:"flex",flexWrap:"wrap",gap:6,marginTop:6},children:Z.attachments.map(ee=>o.jsx("span",{className:"v10-local-agent-attachment-chip",style:{padding:"2px 8px",borderRadius:999,background:"var(--bg-elevated)",fontSize:11},children:ee.fileName},ee.id??ee.assertionUri??ee.fileHash))}),Z.ts&&o.jsx("time",{className:`v10-local-agent-msg-time ${Z.role}`,dateTime:Z.tsRaw,children:Z.ts})]},Z.id)),o.jsx("div",{ref:S}),o.jsx("button",{type:"button",className:`v10-scroll-to-bottom ${be?"visible":""}`,onClick:Ie,"aria-label":"Scroll to latest message",title:"Scroll to latest message",tabIndex:be?0:-1,"aria-hidden":!be,children:o.jsx(nO,{size:14,"aria-hidden":"true"})})]}),o.jsx("div",{className:"v10-agent-input-area",children:o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8,width:"100%"},children:[H.length>0&&o.jsx("div",{className:"v10-attachment-chips",role:"list","aria-label":"Attached files",children:H.map(Z=>{var he,Le;const ee=((he=Z.result)==null?void 0:he.extraction.tripleCount)??((Le=Z.result)==null?void 0:Le.extraction.triplesWritten),ce=Z.status==="queued"?"Queued":Z.status==="uploading"?"Importing…":Z.status==="completed"?ee!=null?`Ready · ${ee} triples`:"Ready":Z.status==="skipped"?"Stored only":Z.error??"Failed";return o.jsxs("div",{className:"v10-attachment-chip","data-status":Z.status,role:"listitem",children:[o.jsx("div",{className:"v10-attachment-chip-badge","aria-hidden":"true",children:w7(Z.file.name)}),o.jsxs("div",{className:"v10-attachment-chip-body",children:[o.jsx("div",{className:"v10-attachment-chip-name",title:Z.file.name,children:Z.file.name}),o.jsxs("div",{className:"v10-attachment-chip-meta",children:[o.jsx("span",{children:x7(Z.file.size)}),o.jsx("span",{"aria-hidden":"true",children:"·"}),o.jsx("span",{className:"v10-attachment-chip-status",children:ce})]})]}),o.jsx("button",{type:"button",className:"v10-attachment-chip-remove",onClick:()=>K(Z.id),disabled:_,"aria-label":`Remove ${Z.file.name}`,title:"Remove attachment",children:o.jsx(IO,{size:12,"aria-hidden":"true"})})]},Z.id)})}),P&&o.jsx("div",{className:"v10-local-agent-copy",style:{margin:0,color:"var(--text-tertiary)"},children:W.length>1?"Queued files keep their stored targets and may span multiple projects.":`Queued files keep their stored target (${ag(q,W[0])}), not the active project.`}),o.jsx("input",{ref:G,type:"file",multiple:!0,style:{display:"none"},onChange:Z=>{Z.target.files&&(F(Z.target.files),Z.target.value="")}}),o.jsx("div",{className:"v10-local-agent-composer-row",children:o.jsxs("div",{className:"v10-local-agent-composer-shell",children:[o.jsx(J7,{placeholder:Oe?`Reconnect ${xe.name} to resume live chat...`:xe.chatReady?`Message ${xe.name}...`:xe.status==="connecting"?`${xe.name} is still connecting...`:`${xe.name} bridge offline...`,className:"v10-agent-input",value:A,onChange:Z=>E(Z.target.value),onKeyDown:Z=>{if(!Z.nativeEvent.isComposing){if(Z.key==="Enter"&&!Z.shiftKey&&!Z.ctrlKey&&!Z.metaKey){Z.preventDefault(),ye&&T();return}if((Z.ctrlKey||Z.metaKey)&&Z.key==="Enter"){Z.preventDefault(),ye&&T();return}Z.key==="Escape"&&A.length>0&&(Z.preventDefault(),E(""))}},disabled:ut,minRows:1,maxRows:8}),o.jsxs("div",{className:"v10-composer-controls",children:[o.jsxs("div",{className:"v10-composer-controls-left",children:[o.jsx("button",{type:"button",className:"v10-composer-attach",onClick:()=>{var Z;return(Z=G.current)==null?void 0:Z.click()},disabled:!Se,title:Se?"Attach files":We==="noProject"?"Choose a context graph to attach files":We==="sending"?"Wait for the current message to send":"This agent does not support attachments","aria-label":"Attach files",children:o.jsx(CO,{size:14,"aria-hidden":"true"})}),o.jsx("div",{className:"v10-composer-target",children:o.jsx(Jq,{className:"v10-local-agent-target-select",value:z??"",onChange:R,options:[...z?[{value:"",label:"No context graph (clear selection)"}]:[],...I.map(Z=>({value:Z.id,label:Z.name}))],placeholder:D?"Loading context graphs…":"Choose a context graph",disabled:D||!z&&I.length===0,ariaLabel:"Active project",prefixIcon:o.jsx(vO,{size:12,"aria-hidden":"true"})})})]}),o.jsx("button",{type:"button",className:`v10-local-agent-inline-send v10-local-agent-inline-send-${L}`,onClick:L==="streaming"?U:T,disabled:L==="streaming"?!1:L==="uploading"?!0:!ye,"aria-label":L==="streaming"?"Stop reply":L==="uploading"?"Send message (attachments uploading)":"Send message",title:L==="streaming"?"Stop reply":L==="uploading"?"Send message (attachments uploading)…":"Send message",children:L==="streaming"?o.jsx(AO,{size:12,"aria-hidden":"true"}):L==="uploading"?o.jsx(wO,{className:"v10-local-agent-inline-send-spinner",size:14,"aria-hidden":"true"}):o.jsx(aO,{size:14,"aria-hidden":"true"})})]})]})})]})})]})]})}function ym(e){return e.length>12?e.slice(-8):e}function cG(e){if(!e)return"";const t=e.lastIndexOf(":"),n=t>=0?e.slice(t+1):e;return n.length>10?n.slice(-10):n||e.slice(-8)}function uG(e,t){const n=new Map;for(const g of t){if(!g.peerId)continue;const m=n.get(g.peerId)??[];m.push(g),n.set(g.peerId,m)}const a=new Map;for(const g of e){if(!g.peerId)continue;const m=a.get(g.peerId)??{hasDirect:!1,hasRelay:!1,openedAt:null},y=m.hasDirect||g.transport==="direct",b=m.hasRelay||g.transport==="relayed",k=g.openedAt!=null?m.openedAt!=null?Math.min(m.openedAt,g.openedAt):g.openedAt:m.openedAt;a.set(g.peerId,{hasDirect:y,hasRelay:b,openedAt:k})}const s=g=>{var m;return(m=g.find(y=>y.name))==null?void 0:m.name},l=g=>g.reduce((m,y)=>y.lastSeen!=null&&(m==null||y.lastSeen>m)?y.lastSeen:m,void 0),u=[],d=new Set;for(const[g,m]of a){const y=n.get(g)??[];u.push({peerId:g,name:s(y),transport:m.hasDirect?"direct":"relayed",hasDirect:m.hasDirect,hasRelay:m.hasRelay,openedAt:m.openedAt,connected:!0,lastSeen:l(y),agents:y}),d.add(g)}for(const[g,m]of n){if(d.has(g))continue;const y=m.filter(N=>N.connectionStatus==="connected");if(y.length===0)continue;const b=y.some(N=>N.connectionTransport==="direct"),k=y.some(N=>N.connectionTransport==="relayed"),j=k&&!b?"relayed":"direct";u.push({peerId:g,name:s(m),transport:j,hasDirect:b,hasRelay:k,openedAt:null,connected:!0,lastSeen:l(m),agents:m}),d.add(g)}const f=[];for(const[g,m]of n){if(d.has(g))continue;const y=l(m);y!=null&&f.push({peerId:g,name:s(m),transport:"direct",hasDirect:!1,hasRelay:!1,openedAt:null,connected:!1,lastSeen:y,agents:m})}f.sort((g,m)=>(m.lastSeen??0)-(g.lastSeen??0));const h=u.filter(g=>g.transport==="direct").length;return{connected:u,recentlySeen:f,directCount:h,relayedCount:u.length-h}}function dG({peer:e}){var g;const[t,n]=w.useState(!1),a=w.useId(),s=3,l=e.connected?"connected":"offline",u=((g=e.name)==null?void 0:g.trim())||ym(e.peerId),d=t?e.agents:e.agents.slice(0,s),f=e.connected?e.transport:"Disconnected",h=e.connected&&e.hasDirect&&e.hasRelay?"Direct + relay paths active — direct shown":void 0;return o.jsxs("div",{className:`v10-agent-card v10-peer-card ${l}`,children:[o.jsxs("div",{className:"v10-agent-card-header",children:[o.jsx("span",{className:`v10-agent-card-dot ${l}`}),o.jsx("span",{className:"v10-peer-card-name",children:u}),o.jsx("span",{className:"v10-agent-card-badge",title:h,children:f})]}),o.jsxs("div",{className:"v10-peer-card-meta",children:[o.jsx("span",{title:e.peerId,children:ym(e.peerId)}),e.connected&&e.openedAt!=null&&o.jsxs("span",{children:["up ",Sk(Date.now()-e.openedAt)]}),!e.connected&&e.lastSeen!=null&&o.jsxs("span",{children:[Sk(Date.now()-e.lastSeen)," ago"]}),e.agents.length>0&&o.jsxs("span",{children:[e.agents.length," agent",e.agents.length===1?"":"s"]})]}),e.agents.length>0&&o.jsxs("ul",{id:a,className:"v10-peer-card-chips","aria-label":`Agents on ${u}`,children:[d.map((m,y)=>o.jsx("li",{className:"v10-peer-chip",title:m.agentUri||"",children:o.jsx("span",{className:"v10-peer-chip-label",children:cG(m.agentUri)||ym(m.peerId)})},m.agentUri||`${e.peerId}:${y}`)),e.agents.length>s&&o.jsx("li",{children:o.jsx("button",{type:"button",className:"v10-peer-chip-more","aria-expanded":t,"aria-controls":a,onClick:()=>n(m=>!m),children:t?"Show less":`+${e.agents.length-s} more`})})]})]})}function Qk(e){const{label:t,peers:n,expanded:a,onToggle:s,emptyMessage:l}=e;return o.jsxs("div",{className:"v10-peer-group",children:[o.jsxs("button",{type:"button",className:"v10-peer-group-header",onClick:s,"aria-expanded":a,children:[o.jsx(Cm,{size:14,className:`v10-peer-group-chevron ${a?"expanded":""}`,"aria-hidden":"true"}),o.jsx("span",{className:"v10-peer-group-label",children:t}),o.jsx("span",{className:"v10-peer-group-count",children:n.length})]}),a&&o.jsx("div",{className:"v10-peer-group-body",children:n.length===0?o.jsx("div",{className:"v10-agent-empty-state",children:l}):n.map(u=>o.jsx(dG,{peer:u},u.peerId))})]})}function pG(e){const{peerAgents:t,connections:n,loading:a,onRefresh:s}=e,[l,u]=w.useState(!0),[d,f]=w.useState(!1),{connected:h,recentlySeen:g,directCount:m,relayedCount:y}=uG(n.rows,t);return o.jsxs("div",{className:"v10-agent-scroll-tab",children:[o.jsxs("div",{className:"v10-agents-summary",children:[o.jsxs("span",{className:"v10-agents-stat",children:[o.jsx("span",{className:`v10-agents-stat-dot ${h.length>0||n.total>0?"connected":"known"}`}),o.jsxs("span",{title:"Unique libp2p peers connected to this node — matches the count in the header.",children:[h.length," peer",h.length===1?"":"s"]})]}),o.jsxs("span",{className:"v10-agents-stat",title:"Preferred transport per peer (peers reachable via direct + relay are bucketed under direct)",children:[m," direct / ",y," relayed"]}),o.jsx("button",{className:"v10-agents-refresh",onClick:s,title:"Refresh network peers",children:"Refresh"})]}),a&&o.jsx("p",{className:"v10-agents-loading",children:"Loading peers..."}),!a&&h.length===0&&g.length===0&&n.total===0&&o.jsx("div",{className:"v10-agent-empty-state",children:"No network peers detected yet."}),!a&&h.length===0&&n.total>0&&o.jsxs("div",{className:"v10-agent-empty-state",children:["Connected to ",n.total," peer",n.total===1?"":"s"," (peer metadata syncing…)."]}),(h.length>0||g.length>0)&&o.jsxs(o.Fragment,{children:[o.jsx(Qk,{label:"Connected",peers:h,expanded:l,onToggle:()=>u(b=>!b),emptyMessage:"No peers currently connected."}),o.jsx(Qk,{label:"Recently seen",peers:g,expanded:d,onToggle:()=>f(b=>!b),emptyMessage:"No previously-seen peers."})]})]})}function fG(e){const{sessions:t,onOpenSession:n}=e;return o.jsx("div",{className:"v10-agent-scroll-tab",children:o.jsxs("div",{className:"v10-sessions-list",children:[o.jsx("div",{className:"v10-local-agent-copy",style:{marginBottom:12},children:"Sessions track DKG-persisted conversations for your integrated agents."}),t.length===0?o.jsx("p",{className:"v10-agent-empty-state",children:"No integrated-agent sessions yet."}):t.map(a=>o.jsxs("button",{className:"v10-session-item",onClick:()=>n(a),children:[o.jsxs("span",{className:"v10-session-preview",children:[a.integrationName,": ",a.preview]}),o.jsxs("span",{className:"v10-session-count",children:[a.messageCount," msg",a.messageCount!==1?"s":"",a.lastTs?` - ${Cd(a.lastTs)}`:""]})]},a.sessionId))]})})}function hG(){return zd().data}function mG(){const{stage:e,advance:t}=Ig(),[n,a]=w.useState("agents"),[s,l]=w.useState([]),[u,d]=w.useState([]),[f,h]=w.useState({total:0,direct:0,relayed:0,rows:[]}),[g,m]=w.useState(!0),y=hG(),[b,k]=w.useState([]),[j,N]=w.useState("openclaw"),[S,A]=w.useState(()=>to("openclaw")),[E,T]=w.useState(null),[U,_]=w.useState(null),[z,q]=w.useState(null),[D,R]=w.useState(null),[$,F]=w.useState({}),[K,I]=w.useState({}),[H,B]=w.useState({}),[W,Q]=w.useState({}),[V,L]=w.useState({}),P=w.useRef(new Map),G=w.useRef(!1),O=w.useRef(null),ne=w.useRef([]),ue=w.useRef({}),le=w.useRef("openclaw"),be=w.useRef(to("openclaw")),_e=Tr(ge=>ge.contextGraphs),Ee=Tr(ge=>ge.loading),Ie=Tr(ge=>ge.activeProjectId),We=Tr(ge=>ge.setActiveProject),Se=w.useMemo(()=>JL(_e,y?Bg(y):null,Ie),[_e,y,Ie]),ft=Yk(s,b),{selectedIntegration:De,selectedConversation:qe,selectedHasConversation:ke,selectedIntegrationHasAnyConversation:lt}=aG({integrations:b,selectedIntegrationId:j,selectedSessionId:S,localMessagesByConversation:$,sessions:ft}),xe=(qe==null?void 0:qe.stateKey)??null,Oe=xe?$[xe]??[]:[],Ot=xe?W[xe]??!1:!1,$t=xe?K[xe]??"":"",Yt=xe?H[xe]??!1:!1,qt=xe?V[xe]??[]:[],ut=w.useCallback(()=>{var ge;(ge=O.current)==null||ge.scrollIntoView({behavior:"smooth"})},[]);w.useEffect(ut,[xe,Oe,ut]),w.useEffect(()=>{ne.current=s},[s]),w.useEffect(()=>{ue.current=$},[$]),w.useEffect(()=>{le.current=j},[j]),w.useEffect(()=>{be.current=S},[S]);const ye=w.useCallback((ge,Me)=>{F(de=>({...de,[ge]:Me(de[ge]??[])}))},[]),X=w.useCallback((ge,Me)=>{ge&&I(de=>({...de,[ge]:Me}))},[]),Z=w.useCallback((ge,Me)=>{B(de=>({...de,[ge]:Me}))},[]),ee=w.useCallback((ge,Me)=>{L(de=>({...de,[ge]:Me(de[ge]??[])}))},[]),ce=w.useCallback((ge,Me,de)=>{const je=Array.from(Me);if(je.length===0)return;const Ae=new Set((V[ge]??[]).map(Ke=>`${Ke.contextGraphId}:${Ke.file.name}:${Ke.file.size}:${Ke.file.lastModified}`)),tt=je.filter(Ke=>{const pt=`${de}:${Ke.name}:${Ke.size}:${Ke.lastModified}`;return Ae.has(pt)?!1:(Ae.add(pt),!0)});if(tt.length===0)return;const Je=tt.map(Ke=>({id:`${ge}:${Ke.name}:${Ke.size}:${Ke.lastModified}:${crypto.randomUUID()}`,file:Ke,contextGraphId:de,assertionName:`${Date.now().toString(36)}-${crypto.randomUUID().slice(0,8)}-${Ke.name.replace(/[^a-zA-Z0-9._-]/g,"_")}`,status:"queued"}));ee(ge,Ke=>[...Ke,...Je])},[V,ee]),he=w.useCallback(async(ge,Me)=>{const de=[];for(const je of Me){if(je.status==="completed"||je.status==="skipped"){de.push(je);continue}ee(ge,Ae=>Ae.map(tt=>tt.id===je.id?{...tt,status:"uploading",error:void 0}:tt));try{const Ae=await OS(je.assertionName,je.contextGraphId,je.file),tt=Ae.extraction.status==="completed"?"completed":Ae.extraction.status==="skipped"?"skipped":"error",Je={...je,status:tt,result:Ae,error:Ae.extraction.error};de.push(Je),ee(ge,Ke=>Ke.map(pt=>pt.id===je.id?Je:pt))}catch(Ae){const tt={...je,status:"error",error:(Ae==null?void 0:Ae.message)??"Upload failed"};de.push(tt),ee(ge,Je=>Je.map(Ke=>Ke.id===je.id?tt:Ke))}}return de},[ee]),Le=w.useCallback((ge,Me)=>{ee(ge,de=>de.filter(je=>je.id!==Me))},[ee]),He=w.useCallback((ge,Me)=>{const de=new Set(Me);ee(ge,je=>je.filter(Ae=>!de.has(Ae.id)))},[ee]),Ce=w.useCallback((ge,Me={})=>{N(ge),ge!==Xi&&(Me.preserveSession||A(Me.sessionId??to(ge)))},[]),Fe=w.useCallback(()=>{Tn.fetchMemorySessions(50).then(({sessions:ge})=>l(ge??[])).catch(()=>{})},[]),et=w.useCallback(async()=>{try{const[ge,Me]=await Promise.all([Cg().catch(()=>({agents:[]})),l_().catch(()=>({total:0,direct:0,relayed:0,connections:[]}))]),de=(ge.agents??[]).filter(je=>je.connectionStatus!=="self");d(de),h({total:Me.total??0,direct:Me.direct??0,relayed:Me.relayed??0,rows:Array.isArray(Me.connections)?Me.connections:[]})}catch{}m(!1)},[]),Ne=w.useCallback(async()=>{try{const{integrations:ge}=await Dd();k(ge);const Me=Yk(ne.current,ge),de=[...ge].sort(Xd).filter(pt=>pt.persistentChat),je=le.current,Ae=be.current,tt=ge.find(pt=>pt.id===je)??null,Je=oG({selectedIntegrationId:je,selectedItem:tt,selectedSessionId:Ae,localMessagesByConversation:ue.current,sessionSummaries:Me});if(!Je){const pt=de[0];Ce((pt==null?void 0:pt.id)??Xi,{sessionId:(pt==null?void 0:pt.defaultSessionId)??null})}const Ke=de[0];Ke&&!G.current&&je!==Xi?(G.current=!0,Ce(Ke.id,{sessionId:Ke.defaultSessionId}),a("agents")):!Ke&&!Je&&(G.current=!1,Ce(Xi))}catch{}},[Ce]),Wt=w.useCallback(async(ge,Me=null,de=null)=>{const je=Td({integrationId:ge,sessionId:Me,defaultSessionId:de});Q(Ae=>({...Ae,[je.stateKey]:!1}));try{const tt=(await Fx(ge,100,{sessionId:je.sessionId??void 0})).map(Je=>jk(Je,ge));ye(je.stateKey,Je=>Ck(Je,tt))}catch{ye(je.stateKey,Ae=>Ae)}finally{Q(Ae=>({...Ae,[je.stateKey]:!0})),Fe()}},[Fe,ye]);w.useEffect(()=>{Fe(),et(),Ne()},[Fe,et,Ne]),w.useEffect(()=>{for(const ge of _7)Wt(ge,to(ge))},[]);const _t=w.useCallback(()=>{Fe(),et()},[Fe,et]);Xl(_t,15e3,{runImmediately:!1});const Hr=b.some(ge=>ge.persistentChat&&(!ge.chatReady||ge.status==="connecting"))?3e3:15e3;w.useEffect(()=>{const ge=setInterval(()=>{Ne()},Hr);return()=>clearInterval(ge)},[Hr,Ne]),w.useEffect(()=>{if(!(De!=null&&De.chatSupported)||!De.persistentChat&&!ke){xe&&Q(Me=>({...Me,[xe]:!1}));return}let ge=!1;return(async()=>await Wt(De.id,(qe==null?void 0:qe.sessionId)??null,De.defaultSessionId??null))(),()=>{ge=!0}},[Wt,qe==null?void 0:qe.sessionId,xe,ke,De==null?void 0:De.defaultSessionId,De==null?void 0:De.chatSupported,De==null?void 0:De.id,De==null?void 0:De.persistentChat]);const dr=w.useCallback(async()=>{const ge=De,Me=qe,de=$t.trim(),je=qt,Ae=je.some(ON);if(!(ge!=null&&ge.chatSupported)||!ge.chatReady||Yt||!Me||!de&&!Ae)return;const tt=ge.id,Je=Me.stateKey;Z(Je,!0),q(null);let Ke=null,pt="",mn="",Gt="",un="",ua=[],da=[],fs=[];try{da=await he(Je,je);const Kn=da.map(tn=>j7(tn)).filter(tn=>tn!=null),fr=C7(da);if(!de&&Kn.length===0&&fr.results.length===0)return;mn=crypto.randomUUID();const Or=MN(fr.results),Ga=[de,Or].filter(tn=>tn.length>0).join(`
1660
1660
 
1661
- `);Gt=de?Ga:N7(Kn,fr.results);const gn=de?Ga:"";ua=Kn,fs=[...Kn.map(tn=>tn.id).filter(tn=>typeof tn=="string"&&tn.length>0),...fr.deliveredDraftIds];const pa=`local:${Je}:${mn}:user`;pt=`local:${Je}:${mn}:assistant`;const hr=new Date,Lt=Cd(hr),jo=rg(hr);ye(Je,tn=>[...tn,{id:pa,turnId:mn,role:"user",content:Gt,ts:Lt,tsRaw:jo,attachments:Kn},{id:pt,turnId:mn,role:"assistant",content:"",ts:Lt,tsRaw:jo,streaming:!0}]),X(Je,""),fs.length>0&&He(Je,fs),Ke=new AbortController,P.current.set(Je,Ke);const sc=[...E7(_e,Ie,y)],mr=await X_(tt,gn,{correlationId:mn,signal:Ke==null?void 0:Ke.signal,sessionId:Me.sessionId??void 0,profile:ge.profile,persistUserMessage:gn?void 0:Gt,attachments:Kn,attachmentImportResults:fr.results,contextEntries:sc,contextGraphId:Ie??void 0,onEvent:tn=>{tn.type==="text_delta"&&(un+=tn.delta,ye(Je,gr=>gr.map(Gr=>Gr.id===pt?{...Gr,content:Gr.content+tn.delta}:Gr)))}}),fa=new Date;ye(Je,tn=>Nk(tn,mn,mr.turnId).map(gr=>{var Gr;return gr.id===pt?{...gr,content:mr.text||gr.content,turnId:((Gr=mr.turnId)==null?void 0:Gr.trim())||gr.turnId,streaming:!1,synthesized:!mr.text&&!gr.content?!0:gr.synthesized,ts:Cd(fa),tsRaw:rg(fa)}:gr})),Fe(),e===0&&t()}catch(Kn){const fr=(Kn==null?void 0:Kn.name)==="AbortError",Or=fr?"Request cancelled.":R7(ge,Kn),Ga=fr?Or:`Error: ${Or}`;pt&&ye(Je,gn=>gn.map(Nn=>Nn.id===pt?{...Nn,content:un,failureNotice:Ga,streaming:!1,synthesized:!un}:Nn)),!fr&&tt==="hermes"&&pt&&Gt&&(async()=>{try{const gn=await Q_(tt,{sessionId:Me.sessionId??void 0,correlationId:mn||void 0,userMessage:Gt,assistantReply:un,failureReason:Or,profile:ge.profile,attachments:ua,contextGraphId:Ie??void 0});gn.turnId&&ye(Je,Nn=>Nk(Nn,mn,gn.turnId)),Fe()}catch{}})(),fs.length>0&&da.length>0&&L(gn=>{const Nn=gn[Je]??[],pa=new Set(Nn.map(Lt=>Lt.id)),hr=da.filter(Lt=>!pa.has(Lt.id));return hr.length===0?gn:{...gn,[Je]:[...hr,...Nn]}}),Ne()}finally{Z(Je,!1),P.current.get(Je)===Ke&&P.current.delete(Je)}},[Ie,t,_e,y,Fe,$t,Yt,he,qt,Ne,qe,De,He,X,Z,e,ye]),Fa=w.useCallback(()=>{if(!xe)return;const ge=P.current.get(xe);ge==null||ge.abort()},[xe]),Ha=w.useCallback(async ge=>{T(ge),q(null),_(null);try{const Me=await W_(ge);k(Ae=>nd(Ae,Me.integration)),await Ne();const de=nd(b,Me.integration),je=nG({integrationId:ge,selectedSessionId:S,integrations:de});Ce(ge,{preserveSession:je,sessionId:Me.integration.defaultSessionId}),G.current=!0,_(Me.notice??(Me.integration.chatReady?`${Me.integration.name} is connected and chat-ready.`:`${Me.integration.name} attach is in progress. The node will keep checking for a live bridge.`)),a("agents")}catch(Me){await Ne(),q(Me.message)}finally{T(null)}},[b,Ne,S,Ce]),pr=w.useCallback(async ge=>{q(null),_(null);try{await Z_(ge),k(Me=>sG(Me,ge)),G.current=!1,Ce(ge,{preserveSession:j===ge}),_("The local agent was disconnected from this node. Session history remains available here."),a("agents"),await Ne()}catch(Me){q(Me.message)}},[Ne,j,Ce]),qr=w.useCallback(async ge=>{var Ae,tt,Je;if(D===ge)return;R(ge),q(null),_(null);const Me=Td({integrationId:ge,sessionId:j===ge?be.current:null,defaultSessionId:(Ae=b.find(Ke=>Ke.id===ge))==null?void 0:Ae.defaultSessionId}),[de,je]=await Promise.allSettled([K_(ge),Fx(ge,100,{sessionId:Me.sessionId??void 0})]);try{if(de.status==="fulfilled"?(k(Ke=>nd(Ke,de.value.integration)),de.value.notice&&_(de.value.notice)):q(((tt=de.reason)==null?void 0:tt.message)??"Failed to refresh integration."),je.status==="fulfilled"){const Ke=je.value.map(pt=>jk(pt,ge));ye(Me.stateKey,pt=>Ck(pt,Ke)),Q(pt=>({...pt,[Me.stateKey]:!0}))}else de.status==="fulfilled"&&q(((Je=je.reason)==null?void 0:Je.message)??"Failed to refresh conversation.")}finally{R(null)}},[b,D,j,ye]),ca=w.useCallback(ge=>{Ce(ge.integrationId,{sessionId:ge.sessionId}),a("agents")},[Ce]),ic=w.useCallback(ge=>{We(ge||null)},[We]),qa=w.useCallback(ge=>{!xe||!Ie||ce(xe,ge,Ie)},[Ie,ce,xe]),Ci=w.useCallback(ge=>{xe&&Le(xe,ge)},[Le,xe]);return o.jsxs("div",{className:"v10-panel-right",children:[o.jsxs("div",{className:"v10-agent-mode-tabs",children:[o.jsx("button",{className:`v10-agent-mode-tab ${n==="agents"?"active":""}`,onClick:()=>a("agents"),children:"Agents"}),o.jsx("button",{className:`v10-agent-mode-tab ${n==="network"?"active":""}`,onClick:()=>a("network"),children:"Network"}),o.jsx("button",{className:`v10-agent-mode-tab ${n==="sessions"?"active":""}`,onClick:()=>a("sessions"),children:"Sessions"})]}),n==="agents"&&o.jsx(lG,{integrations:b,selectedIntegrationId:j,selectedIntegration:De,selectedSessionId:S,selectedHasConversation:ke,selectedIntegrationHasAnyConversation:lt,onSelectIntegration:Ce,onConnectIntegration:Ha,onDisconnectIntegration:pr,onRefreshIntegration:qr,connectBusyId:E,refreshBusyId:D,connectNotice:U,connectError:z,localMessages:Oe,localHistoryLoaded:Ot,localChatEndRef:O,localInput:$t,onLocalInputChange:ge=>X(xe,ge),onSendLocalMessage:dr,onStopLocalStream:Fa,localSending:Yt,activeProjectId:Ie,availableProjects:_e,selectableProjects:Se,projectsLoading:Ee,onSelectProject:ic,attachments:qt,onAddAttachments:qa,onRemoveAttachment:Ci}),n==="network"&&o.jsx(pG,{peerAgents:u,connections:f,loading:g,onRefresh:et}),n==="sessions"&&o.jsx(fG,{sessions:ft,onOpenSession:ca})]})}function gG(e,t=document){const n=e==="light";t.documentElement.classList.toggle("light",n),t.body.classList.toggle("light",n)}function vG(){const{toggleLeft:e,toggleRight:t,toggleBottom:n}=Vn();w.useEffect(()=>{const a=s=>{if(s.target instanceof HTMLInputElement||s.target instanceof HTMLTextAreaElement||!(s.metaKey||s.ctrlKey))return;const u=s.key.toLowerCase();if(s.shiftKey&&u==="b"){s.preventDefault(),t();return}if(!s.shiftKey){if(u==="b"){s.preventDefault(),e();return}if(u==="j"){s.preventDefault(),n();return}}};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[e,t,n])}const Xk={"/observability":{id:"operations",label:"Observability"},"/operations":{id:"operations",label:"Observability"},"/settings":{id:"settings",label:"Settings"}},yG={operations:"/observability",settings:"/settings",dashboard:"/"};function bG(){const{pathname:e}=Fr(),t=hg(),n=fn(s=>s.openTab),a=fn(s=>s.activeTabId);w.useEffect(()=>{const s=Xk[e];s&&n({id:s.id,label:s.label,closable:!0})},[e,n]),w.useEffect(()=>{const s=yG[a];if(s){s!==e&&t(s,{replace:!0});return}Xk[e]&&t("/",{replace:!0})},[a,e,t])}function xG(){const[e,t]=w.useState(gR());return w.useEffect(()=>vR(t),[]),e?o.jsxs("div",{className:"v10-mock-banner",role:"alert","aria-live":"polite",children:[o.jsx("span",{className:"v10-mock-banner-dot","aria-hidden":"true"}),o.jsxs("span",{children:[o.jsx("strong",{children:"Demo data"})," — the node isn’t responding (it may be down, timing out, or returning errors), so the UI is showing example data, not live node state. Check the daemon, then reload."]}),o.jsx("button",{type:"button",className:"v10-mock-banner-reload",onClick:()=>window.location.reload(),children:"Reload"})]}):null}function wG(){const e=wg(t=>t.setNodeStatus);Xl(()=>{Tn.fetchStatus().then(e).catch(()=>{})},1e4)}function Jk(e){const t=w.useRef(null),n=w.useRef(e);return n.current=e,w.useEffect(()=>{const a=t.current;if(!a)return;let s=0;const l=f=>{const h=f.clientX-s;s=f.clientX,n.current(h)},u=()=>{document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",u),document.body.style.cursor="",document.body.style.userSelect="",a.classList.remove("active")},d=f=>{f.preventDefault(),s=f.clientX,document.addEventListener("mousemove",l),document.addEventListener("mouseup",u),document.body.style.cursor="col-resize",document.body.style.userSelect="none",a.classList.add("active")};return a.addEventListener("mousedown",d),()=>a.removeEventListener("mousedown",d)},[]),t}function kG(e){const t=w.useRef(e);t.current=e;const[n,a]=w.useState(null);return w.useEffect(()=>{if(!n)return;let s=0;const l=f=>{const h=f.clientY-s;s=f.clientY,t.current(h)},u=()=>{document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",u),document.body.style.cursor="",document.body.style.userSelect="",n.classList.remove("active")},d=f=>{f.preventDefault(),s=f.clientY,document.addEventListener("mousemove",l),document.addEventListener("mouseup",u),document.body.style.cursor="row-resize",document.body.style.userSelect="none",n.classList.add("active")};return n.addEventListener("mousedown",d),()=>{n.removeEventListener("mousedown",d),u()}},[n]),w.useCallback(s=>a(s),[])}function SG(){wG(),vG(),bG();const{leftCollapsed:e,rightCollapsed:t,bottomCollapsed:n,theme:a,leftWidth:s,rightWidth:l,setLeftWidth:u,setRightWidth:d,setBottomHeight:f}=Vn(),[,h]=w.useState(0);w.useEffect(()=>{gG(a)},[a]),w.useEffect(()=>{const N=()=>h(S=>S+1);return window.addEventListener("resize",N),()=>window.removeEventListener("resize",N)},[]),w.useLayoutEffect(()=>{const N=window.requestAnimationFrame(()=>{window.dispatchEvent(new Event("resize"))});return()=>window.cancelAnimationFrame(N)},[e,t]);const g=w.useCallback(N=>{const S=Vn.getState().leftWidth;u(Math.max(140,Math.min(400,S+N)))},[u]),m=w.useCallback(N=>{const S=Vn.getState().rightWidth;d(Math.max(200,Math.min(500,S-N)))},[d]),y=w.useCallback(N=>{const S=Math.min(Vn.getState().bottomHeight,sd());f(Math.min(S-N,sd()))},[f]),b=Jk(g),k=Jk(m),j=kG(y);return o.jsxs("div",{className:"v10-app",children:[o.jsx(xG,{}),o.jsx(wL,{}),o.jsxs("div",{className:"v10-app-body",children:[!e&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"v10-panel-left",style:{width:s},children:o.jsx(f4,{})}),o.jsx("div",{className:"v10-resize-handle-h",ref:b})]}),o.jsxs("div",{className:"v10-center-region",style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",overflow:"hidden"},children:[o.jsx("div",{style:{flex:1,minHeight:0,overflow:"hidden"},children:o.jsx(s7,{})}),!n&&o.jsx("div",{className:"v10-resize-handle-v",ref:j}),o.jsx(b7,{})]}),!t&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"v10-resize-handle-h",ref:k}),o.jsx("div",{className:"v10-panel-right",style:{width:l},children:o.jsx(mG,{})})]})]})]})}const jG=Ve.lazy(()=>gt(()=>import("./Network--HTk881J.js"),[]).then(e=>({default:e.NetworkPage})));function CG(){const e=fn(t=>t.openTab);return w.useLayoutEffect(()=>{e(Sj)},[e]),o.jsx(El,{to:"/",replace:!0})}function NG(){return o.jsxs(f2,{children:[o.jsx(vi,{path:"/network",element:o.jsx(Ve.Suspense,{fallback:o.jsx("div",{className:"lazy-spinner",children:"Loading..."}),children:o.jsx(jG,{})})}),o.jsx(vi,{path:"/context-graph-primer",element:o.jsx(CG,{})}),o.jsx(vi,{path:"/agent",element:o.jsx(El,{to:"/",replace:!0})}),o.jsx(vi,{path:"/explorer",element:o.jsx(El,{to:"/",replace:!0})}),o.jsx(vi,{path:"/messages",element:o.jsx(El,{to:"/",replace:!0})}),o.jsx(vi,{path:"/apps/*",element:o.jsx(El,{to:"/",replace:!0})}),o.jsx(vi,{path:"*",element:o.jsx(SG,{})})]})}mT.createRoot(document.getElementById("root")).render(o.jsx(Ve.StrictMode,{children:o.jsx($2,{basename:"/ui",children:o.jsx(NG,{})})}));export{iV as $,aD as A,tV as B,lO as C,XG as D,ln as E,JG as F,YG as G,$n as H,KG as I,QG as J,BG as K,yS as L,jg as M,eV as N,HG as O,mG as P,Lg as Q,Ve as R,Fd as S,A5 as T,lV as U,m1 as V,zO as W,J4 as X,eM as Y,PO as Z,gt as _,ts as a,h4 as a0,UO as a1,TG as a2,Wl as a3,UR as a4,FR as a5,R5 as a6,PS as a7,IG as a8,PG as a9,RM as aA,cs as aB,wg as aC,mz as aD,lr as aE,Gg as aF,Ji as aG,FS as aH,HS as aI,Pl as aJ,CM as aK,Ua as aL,Tr as aM,fn as aN,oV as aO,w5 as aP,HR as aa,aV as ab,sV as ac,o as ad,$G as ae,DG as af,s_ as ag,cV as ah,GS as ai,Em as aj,RG as ak,i_ as al,OG as am,MG as an,zR as ao,LG as ap,w as aq,g1 as ar,nV as as,g5 as at,O5 as au,gv as av,rV as aw,Ks as ax,FG as ay,qG as az,xj as b,uO as c,fO as d,wO as e,yj as f,At as g,Ft as h,mk as i,jm as j,AG as k,cn as l,_G as m,UG as n,Wx as o,Cg as p,l_ as q,WG as r,ZG as s,d_ as t,GG as u,zG as v,f_ as w,VG as x,p_ as y,od as z};
1661
+ `);Gt=de?Ga:N7(Kn,fr.results);const gn=de?Ga:"";ua=Kn,fs=[...Kn.map(tn=>tn.id).filter(tn=>typeof tn=="string"&&tn.length>0),...fr.deliveredDraftIds];const pa=`local:${Je}:${mn}:user`;pt=`local:${Je}:${mn}:assistant`;const hr=new Date,Lt=Cd(hr),jo=rg(hr);ye(Je,tn=>[...tn,{id:pa,turnId:mn,role:"user",content:Gt,ts:Lt,tsRaw:jo,attachments:Kn},{id:pt,turnId:mn,role:"assistant",content:"",ts:Lt,tsRaw:jo,streaming:!0}]),X(Je,""),fs.length>0&&He(Je,fs),Ke=new AbortController,P.current.set(Je,Ke);const sc=[...E7(_e,Ie,y)],mr=await X_(tt,gn,{correlationId:mn,signal:Ke==null?void 0:Ke.signal,sessionId:Me.sessionId??void 0,profile:ge.profile,persistUserMessage:gn?void 0:Gt,attachments:Kn,attachmentImportResults:fr.results,contextEntries:sc,contextGraphId:Ie??void 0,onEvent:tn=>{tn.type==="text_delta"&&(un+=tn.delta,ye(Je,gr=>gr.map(Gr=>Gr.id===pt?{...Gr,content:Gr.content+tn.delta}:Gr)))}}),fa=new Date;ye(Je,tn=>Nk(tn,mn,mr.turnId).map(gr=>{var Gr;return gr.id===pt?{...gr,content:mr.text||gr.content,turnId:((Gr=mr.turnId)==null?void 0:Gr.trim())||gr.turnId,streaming:!1,synthesized:!mr.text&&!gr.content?!0:gr.synthesized,ts:Cd(fa),tsRaw:rg(fa)}:gr})),Fe(),e===0&&t()}catch(Kn){const fr=(Kn==null?void 0:Kn.name)==="AbortError",Or=fr?"Request cancelled.":R7(ge,Kn),Ga=fr?Or:`Error: ${Or}`;pt&&ye(Je,gn=>gn.map(Nn=>Nn.id===pt?{...Nn,content:un,failureNotice:Ga,streaming:!1,synthesized:!un}:Nn)),!fr&&tt==="hermes"&&pt&&Gt&&(async()=>{try{const gn=await Q_(tt,{sessionId:Me.sessionId??void 0,correlationId:mn||void 0,userMessage:Gt,assistantReply:un,failureReason:Or,profile:ge.profile,attachments:ua,contextGraphId:Ie??void 0});gn.turnId&&ye(Je,Nn=>Nk(Nn,mn,gn.turnId)),Fe()}catch{}})(),fs.length>0&&da.length>0&&L(gn=>{const Nn=gn[Je]??[],pa=new Set(Nn.map(Lt=>Lt.id)),hr=da.filter(Lt=>!pa.has(Lt.id));return hr.length===0?gn:{...gn,[Je]:[...hr,...Nn]}}),Ne()}finally{Z(Je,!1),P.current.get(Je)===Ke&&P.current.delete(Je)}},[Ie,t,_e,y,Fe,$t,Yt,he,qt,Ne,qe,De,He,X,Z,e,ye]),Fa=w.useCallback(()=>{if(!xe)return;const ge=P.current.get(xe);ge==null||ge.abort()},[xe]),Ha=w.useCallback(async ge=>{T(ge),q(null),_(null);try{const Me=await W_(ge);k(Ae=>nd(Ae,Me.integration)),await Ne();const de=nd(b,Me.integration),je=nG({integrationId:ge,selectedSessionId:S,integrations:de});Ce(ge,{preserveSession:je,sessionId:Me.integration.defaultSessionId}),G.current=!0,_(Me.notice??(Me.integration.chatReady?`${Me.integration.name} is connected and chat-ready.`:`${Me.integration.name} attach is in progress. The node will keep checking for a live bridge.`)),a("agents")}catch(Me){await Ne(),q(Me.message)}finally{T(null)}},[b,Ne,S,Ce]),pr=w.useCallback(async ge=>{q(null),_(null);try{await Z_(ge),k(Me=>sG(Me,ge)),G.current=!1,Ce(ge,{preserveSession:j===ge}),_("The local agent was disconnected from this node. Session history remains available here."),a("agents"),await Ne()}catch(Me){q(Me.message)}},[Ne,j,Ce]),qr=w.useCallback(async ge=>{var Ae,tt,Je;if(D===ge)return;R(ge),q(null),_(null);const Me=Td({integrationId:ge,sessionId:j===ge?be.current:null,defaultSessionId:(Ae=b.find(Ke=>Ke.id===ge))==null?void 0:Ae.defaultSessionId}),[de,je]=await Promise.allSettled([K_(ge),Fx(ge,100,{sessionId:Me.sessionId??void 0})]);try{if(de.status==="fulfilled"?(k(Ke=>nd(Ke,de.value.integration)),de.value.notice&&_(de.value.notice)):q(((tt=de.reason)==null?void 0:tt.message)??"Failed to refresh integration."),je.status==="fulfilled"){const Ke=je.value.map(pt=>jk(pt,ge));ye(Me.stateKey,pt=>Ck(pt,Ke)),Q(pt=>({...pt,[Me.stateKey]:!0}))}else de.status==="fulfilled"&&q(((Je=je.reason)==null?void 0:Je.message)??"Failed to refresh conversation.")}finally{R(null)}},[b,D,j,ye]),ca=w.useCallback(ge=>{Ce(ge.integrationId,{sessionId:ge.sessionId}),a("agents")},[Ce]),ic=w.useCallback(ge=>{We(ge||null)},[We]),qa=w.useCallback(ge=>{!xe||!Ie||ce(xe,ge,Ie)},[Ie,ce,xe]),Ci=w.useCallback(ge=>{xe&&Le(xe,ge)},[Le,xe]);return o.jsxs("div",{className:"v10-panel-right",children:[o.jsxs("div",{className:"v10-agent-mode-tabs",children:[o.jsx("button",{className:`v10-agent-mode-tab ${n==="agents"?"active":""}`,onClick:()=>a("agents"),children:"Agents"}),o.jsx("button",{className:`v10-agent-mode-tab ${n==="network"?"active":""}`,onClick:()=>a("network"),children:"Network"}),o.jsx("button",{className:`v10-agent-mode-tab ${n==="sessions"?"active":""}`,onClick:()=>a("sessions"),children:"Sessions"})]}),n==="agents"&&o.jsx(lG,{integrations:b,selectedIntegrationId:j,selectedIntegration:De,selectedSessionId:S,selectedHasConversation:ke,selectedIntegrationHasAnyConversation:lt,onSelectIntegration:Ce,onConnectIntegration:Ha,onDisconnectIntegration:pr,onRefreshIntegration:qr,connectBusyId:E,refreshBusyId:D,connectNotice:U,connectError:z,localMessages:Oe,localHistoryLoaded:Ot,localChatEndRef:O,localInput:$t,onLocalInputChange:ge=>X(xe,ge),onSendLocalMessage:dr,onStopLocalStream:Fa,localSending:Yt,activeProjectId:Ie,availableProjects:_e,selectableProjects:Se,projectsLoading:Ee,onSelectProject:ic,attachments:qt,onAddAttachments:qa,onRemoveAttachment:Ci}),n==="network"&&o.jsx(pG,{peerAgents:u,connections:f,loading:g,onRefresh:et}),n==="sessions"&&o.jsx(fG,{sessions:ft,onOpenSession:ca})]})}function gG(e,t=document){const n=e==="light";t.documentElement.classList.toggle("light",n),t.body.classList.toggle("light",n)}function vG(){const{toggleLeft:e,toggleRight:t,toggleBottom:n}=Vn();w.useEffect(()=>{const a=s=>{if(s.target instanceof HTMLInputElement||s.target instanceof HTMLTextAreaElement||!(s.metaKey||s.ctrlKey))return;const u=s.key.toLowerCase();if(s.shiftKey&&u==="b"){s.preventDefault(),t();return}if(!s.shiftKey){if(u==="b"){s.preventDefault(),e();return}if(u==="j"){s.preventDefault(),n();return}}};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[e,t,n])}const Xk={"/observability":{id:"operations",label:"Observability"},"/operations":{id:"operations",label:"Observability"},"/settings":{id:"settings",label:"Settings"}},yG={operations:"/observability",settings:"/settings",dashboard:"/"};function bG(){const{pathname:e}=Fr(),t=hg(),n=fn(s=>s.openTab),a=fn(s=>s.activeTabId);w.useEffect(()=>{const s=Xk[e];s&&n({id:s.id,label:s.label,closable:!0})},[e,n]),w.useEffect(()=>{const s=yG[a];if(s){s!==e&&t(s,{replace:!0});return}Xk[e]&&t("/",{replace:!0})},[a,e,t])}function xG(){const[e,t]=w.useState(gR());return w.useEffect(()=>vR(t),[]),e?o.jsxs("div",{className:"v10-mock-banner",role:"alert","aria-live":"polite",children:[o.jsx("span",{className:"v10-mock-banner-dot","aria-hidden":"true"}),o.jsxs("span",{children:[o.jsx("strong",{children:"Demo data"})," — the node isn’t responding (it may be down, timing out, or returning errors), so the UI is showing example data, not live node state. Check the daemon, then reload."]}),o.jsx("button",{type:"button",className:"v10-mock-banner-reload",onClick:()=>window.location.reload(),children:"Reload"})]}):null}function wG(){const e=wg(t=>t.setNodeStatus);Xl(()=>{Tn.fetchStatus().then(e).catch(()=>{})},1e4)}function Jk(e){const t=w.useRef(null),n=w.useRef(e);return n.current=e,w.useEffect(()=>{const a=t.current;if(!a)return;let s=0;const l=f=>{const h=f.clientX-s;s=f.clientX,n.current(h)},u=()=>{document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",u),document.body.style.cursor="",document.body.style.userSelect="",a.classList.remove("active")},d=f=>{f.preventDefault(),s=f.clientX,document.addEventListener("mousemove",l),document.addEventListener("mouseup",u),document.body.style.cursor="col-resize",document.body.style.userSelect="none",a.classList.add("active")};return a.addEventListener("mousedown",d),()=>a.removeEventListener("mousedown",d)},[]),t}function kG(e){const t=w.useRef(e);t.current=e;const[n,a]=w.useState(null);return w.useEffect(()=>{if(!n)return;let s=0;const l=f=>{const h=f.clientY-s;s=f.clientY,t.current(h)},u=()=>{document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",u),document.body.style.cursor="",document.body.style.userSelect="",n.classList.remove("active")},d=f=>{f.preventDefault(),s=f.clientY,document.addEventListener("mousemove",l),document.addEventListener("mouseup",u),document.body.style.cursor="row-resize",document.body.style.userSelect="none",n.classList.add("active")};return n.addEventListener("mousedown",d),()=>{n.removeEventListener("mousedown",d),u()}},[n]),w.useCallback(s=>a(s),[])}function SG(){wG(),vG(),bG();const{leftCollapsed:e,rightCollapsed:t,bottomCollapsed:n,theme:a,leftWidth:s,rightWidth:l,setLeftWidth:u,setRightWidth:d,setBottomHeight:f}=Vn(),[,h]=w.useState(0);w.useEffect(()=>{gG(a)},[a]),w.useEffect(()=>{const N=()=>h(S=>S+1);return window.addEventListener("resize",N),()=>window.removeEventListener("resize",N)},[]),w.useLayoutEffect(()=>{const N=window.requestAnimationFrame(()=>{window.dispatchEvent(new Event("resize"))});return()=>window.cancelAnimationFrame(N)},[e,t]);const g=w.useCallback(N=>{const S=Vn.getState().leftWidth;u(Math.max(140,Math.min(400,S+N)))},[u]),m=w.useCallback(N=>{const S=Vn.getState().rightWidth;d(Math.max(200,Math.min(500,S-N)))},[d]),y=w.useCallback(N=>{const S=Math.min(Vn.getState().bottomHeight,sd());f(Math.min(S-N,sd()))},[f]),b=Jk(g),k=Jk(m),j=kG(y);return o.jsxs("div",{className:"v10-app",children:[o.jsx(xG,{}),o.jsx(wL,{}),o.jsxs("div",{className:"v10-app-body",children:[!e&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"v10-panel-left",style:{width:s},children:o.jsx(f4,{})}),o.jsx("div",{className:"v10-resize-handle-h",ref:b})]}),o.jsxs("div",{className:"v10-center-region",style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",overflow:"hidden"},children:[o.jsx("div",{style:{flex:1,minHeight:0,overflow:"hidden"},children:o.jsx(s7,{})}),!n&&o.jsx("div",{className:"v10-resize-handle-v",ref:j}),o.jsx(b7,{})]}),!t&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"v10-resize-handle-h",ref:k}),o.jsx("div",{className:"v10-panel-right",style:{width:l},children:o.jsx(mG,{})})]})]})]})}const jG=Ve.lazy(()=>gt(()=>import("./Network-DKw_XEGi.js"),[]).then(e=>({default:e.NetworkPage})));function CG(){const e=fn(t=>t.openTab);return w.useLayoutEffect(()=>{e(Sj)},[e]),o.jsx(El,{to:"/",replace:!0})}function NG(){return o.jsxs(f2,{children:[o.jsx(vi,{path:"/network",element:o.jsx(Ve.Suspense,{fallback:o.jsx("div",{className:"lazy-spinner",children:"Loading..."}),children:o.jsx(jG,{})})}),o.jsx(vi,{path:"/context-graph-primer",element:o.jsx(CG,{})}),o.jsx(vi,{path:"/agent",element:o.jsx(El,{to:"/",replace:!0})}),o.jsx(vi,{path:"/explorer",element:o.jsx(El,{to:"/",replace:!0})}),o.jsx(vi,{path:"/messages",element:o.jsx(El,{to:"/",replace:!0})}),o.jsx(vi,{path:"/apps/*",element:o.jsx(El,{to:"/",replace:!0})}),o.jsx(vi,{path:"*",element:o.jsx(SG,{})})]})}mT.createRoot(document.getElementById("root")).render(o.jsx(Ve.StrictMode,{children:o.jsx($2,{basename:"/ui",children:o.jsx(NG,{})})}));export{iV as $,aD as A,tV as B,lO as C,XG as D,ln as E,JG as F,YG as G,$n as H,KG as I,QG as J,BG as K,yS as L,jg as M,eV as N,HG as O,mG as P,Lg as Q,Ve as R,Fd as S,A5 as T,lV as U,m1 as V,zO as W,J4 as X,eM as Y,PO as Z,gt as _,ts as a,h4 as a0,UO as a1,TG as a2,Wl as a3,UR as a4,FR as a5,R5 as a6,PS as a7,IG as a8,PG as a9,RM as aA,cs as aB,wg as aC,mz as aD,lr as aE,Gg as aF,Ji as aG,FS as aH,HS as aI,Pl as aJ,CM as aK,Ua as aL,Tr as aM,fn as aN,oV as aO,w5 as aP,HR as aa,aV as ab,sV as ac,o as ad,$G as ae,DG as af,s_ as ag,cV as ah,GS as ai,Em as aj,RG as ak,i_ as al,OG as am,MG as an,zR as ao,LG as ap,w as aq,g1 as ar,nV as as,g5 as at,O5 as au,gv as av,rV as aw,Ks as ax,FG as ay,qG as az,xj as b,uO as c,fO as d,wO as e,yj as f,At as g,Ft as h,mk as i,jm as j,AG as k,cn as l,_G as m,UG as n,Wx as o,Cg as p,l_ as q,WG as r,ZG as s,d_ as t,GG as u,zG as v,f_ as w,VG as x,p_ as y,od as z};