stratagate-dsh 0.2.39 → 0.2.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.40 - 2026-08-31
4
+
5
+ - Make Knowledge Graph limits explicit, render the top 100 nodes by default, and let users reveal 100 more at a time.
6
+ - Add total-aware pagination for Events and Blocks in 40-item pages and usage audits in 100-item pages.
7
+
3
8
  ## 0.2.39 - 2026-08-31
4
9
 
5
10
  - Preview external-memory imports without writes, skip exact duplicates deterministically, and ask the configured model to adjudicate Top-K local matches.
package/dist/client.js CHANGED
@@ -365,7 +365,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
365
365
  .sg-menu{display:grid;gap:7px}.sg-menu-row{display:grid;grid-template-columns:38px minmax(0,1fr) auto;align-items:center;gap:11px;width:100%;padding:12px;border:1px solid transparent;border-radius:10px;background:color-mix(in srgb,var(--sg-surface) 48%,transparent);text-align:left;cursor:pointer}.sg-menu-row:hover{border-color:color-mix(in srgb,var(--sg-accent) 22%,var(--sg-border));background:color-mix(in srgb,var(--sg-accent) 6%,var(--sg-surface));transform:translateY(-1px);box-shadow:0 8px 20px color-mix(in srgb,var(--sg-text) 6%,transparent)}.sg-menu-row:hover .sg-menu-title,.sg-menu-row:hover .sg-chevron{color:var(--sg-accent)}.sg-menu-icon{width:32px;height:32px;display:grid;place-items:center;border:1px solid color-mix(in srgb,var(--sg-accent) 14%,var(--sg-border));border-radius:8px;background:var(--sg-soft);color:var(--sg-muted);font-weight:700}.sg-menu-title{font-weight:700}.sg-menu-subtitle{color:var(--sg-muted);font-size:12px}.sg-counts{display:flex;gap:22px;padding:5px 0 18px;border-bottom:1px solid var(--sg-border)}.sg-count-value{font-size:22px;font-weight:760;letter-spacing:-.03em}.sg-count-label{color:var(--sg-muted);font-size:12px}.sg-structured-group{padding-top:17px}.sg-raw-group{padding:12px 0;border-bottom:1px solid var(--sg-border)}.sg-raw-group summary{cursor:pointer;font-weight:680}.sg-raw-json{max-height:360px;padding:11px;margin:10px 0 0;overflow:auto;border-radius:7px;background:var(--sg-soft)}
366
366
  .sg-import-card{padding:15px;border:1px solid color-mix(in srgb,var(--sg-accent) 22%,var(--sg-border));border-radius:11px;background:color-mix(in srgb,var(--sg-surface) 72%,transparent);box-shadow:0 8px 24px color-mix(in srgb,var(--sg-text) 5%,transparent)}.sg-import-card textarea{width:100%;min-height:270px;padding:11px;border:1px solid var(--sg-border);border-radius:8px;background:var(--sg-page);resize:vertical;outline:0;font:12px/1.55 ui-monospace,SFMono-Regular,Consolas,monospace}.sg-import-card textarea:focus{border-color:var(--sg-accent);box-shadow:0 0 0 3px var(--sg-focus)}.sg-import-actions{display:flex;align-items:center;gap:10px;margin-top:11px;flex-wrap:wrap}.sg-import-button{padding:8px 13px;border:1px solid var(--sg-accent);border-radius:7px;background:var(--sg-accent);color:#fff;cursor:pointer;font-weight:680}.sg-import-button:disabled{cursor:wait;opacity:.6}.sg-import-hint{margin:8px 0 0;color:var(--sg-muted);font-size:12px}.sg-import-result{margin-top:12px;padding:10px 11px;border-radius:7px;background:var(--sg-good-soft);color:var(--sg-good);font-size:12px}.sg-import-error{margin-top:12px;padding:10px 11px;border-radius:7px;background:var(--sg-danger-soft);color:var(--sg-danger);font-size:12px}
367
367
  .sg-import-overlay{position:fixed;inset:0;z-index:40;display:flex;align-items:center;justify-content:center;padding:18px;background:rgba(0,0,0,.52);backdrop-filter:blur(2px);animation:sg-view-in var(--sg-medium) var(--sg-ease) both}.sg-import-dialog{width:min(720px,calc(100vw - 28px));max-height:calc(100vh - 36px);overflow:auto;padding:14px;border:1px solid color-mix(in srgb,var(--sg-border) 90%,#fff 10%);border-radius:12px;background:var(--sg-page);box-shadow:0 24px 80px rgba(0,0,0,.42)}.sg-import-dialog-head{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:13px}.sg-import-dialog-title{margin:0;font-size:18px;font-weight:760}.sg-import-step{padding:12px;margin-top:10px;border-radius:9px;background:color-mix(in srgb,var(--sg-surface) 78%,transparent)}.sg-import-step-head{display:flex;align-items:center;gap:9px;margin-bottom:9px}.sg-import-step-num{display:grid;place-items:center;width:25px;height:25px;border-radius:50%;background:var(--sg-text);color:var(--sg-page);font-weight:760}.sg-import-step-title{font-weight:720}.sg-import-prompt{max-height:185px;padding:10px;overflow:auto;border-radius:7px;background:var(--sg-page);color:var(--sg-muted);font:12px/1.55 ui-monospace,SFMono-Regular,Consolas,monospace;white-space:pre-wrap}.sg-import-dialog .sg-import-card{padding:0;border:0;box-shadow:none;background:transparent}.sg-import-dialog .sg-import-card textarea{min-height:165px;background:var(--sg-page)}.sg-import-dialog-foot{display:flex;justify-content:flex-end;gap:9px;margin-top:14px}.sg-import-cancel{padding:8px 18px;border:1px solid var(--sg-border);border-radius:7px;background:transparent;cursor:pointer}.sg-import-dialog .sg-import-button{padding:8px 18px}.sg-import-copy{margin-left:auto;padding:6px 11px;border:1px solid var(--sg-border);border-radius:6px;background:var(--sg-page);cursor:pointer;font-size:12px}.sg-import-copy:hover{border-color:var(--sg-accent);color:var(--sg-accent)}.sg-import-loading{color:var(--sg-muted);font-size:12px}.sg-import-preview{display:grid;gap:8px;margin-top:10px}.sg-import-preview-item{padding:10px;border:1px solid var(--sg-border);border-radius:8px;background:var(--sg-page)}.sg-import-preview-title{font-weight:700}.sg-import-preview-meta{display:flex;gap:8px;margin-top:5px;color:var(--sg-muted);font-size:12px}.sg-import-preview-reason{margin-top:5px;font-size:12px}.sg-import-review{display:flex;gap:7px;align-items:flex-start;margin-top:8px;color:var(--sg-warn);font-size:12px}
368
- .sg-audit{padding:14px 0;border-bottom:1px solid var(--sg-border)}.sg-audit summary{cursor:pointer}.sg-audit-body{margin-top:10px}.sg-audit-evidence{margin-top:9px}.sg-star{padding:14px 0;margin-top:14px;border-top:1px solid var(--sg-border)}.sg-star-actions{display:flex;gap:10px;align-items:center;margin-top:8px}.sg-link{color:var(--sg-accent);text-decoration:none}.sg-quiet-button{padding:5px 7px;border-radius:5px;color:var(--sg-muted);font-size:12px}
368
+ .sg-audit{padding:14px 0;border-bottom:1px solid var(--sg-border)}.sg-audit summary{cursor:pointer}.sg-audit-body{margin-top:10px}.sg-audit-evidence{margin-top:9px}.sg-star{padding:14px 0;margin-top:14px;border-top:1px solid var(--sg-border)}.sg-star-actions{display:flex;gap:10px;align-items:center;margin-top:8px}.sg-link{color:var(--sg-accent);text-decoration:none}.sg-quiet-button{padding:5px 7px;border-radius:5px;color:var(--sg-muted);font-size:12px}.sg-pagination{display:flex;align-items:center;justify-content:center;gap:10px;padding:14px 0;color:var(--sg-muted);font-size:12px}.sg-page-button{padding:6px 10px;border:1px solid var(--sg-border);border-radius:6px;background:var(--sg-surface);cursor:pointer}.sg-page-button:hover:not(:disabled){border-color:var(--sg-accent);color:var(--sg-accent)}.sg-page-button:disabled{cursor:not-allowed;opacity:.45}.sg-page-error{color:var(--sg-danger)}
369
369
  .sg-decay-overview{padding:15px 16px 13px;margin-bottom:12px;border:1px solid color-mix(in srgb,var(--sg-accent) 20%,var(--sg-border));border-radius:12px;background:linear-gradient(145deg,color-mix(in srgb,var(--sg-surface) 88%,transparent),color-mix(in srgb,var(--sg-accent) 4%,var(--sg-surface)));box-shadow:0 8px 24px color-mix(in srgb,var(--sg-text) 5%,transparent)}.sg-decay-title{margin:0;font-size:14px;font-weight:740;letter-spacing:-.012em}.sg-decay-copy{margin:3px 0 12px;color:var(--sg-muted);font-size:12px}.sg-distribution{display:flex;align-items:stretch;gap:4px;min-width:0;overflow-x:auto;padding:2px 0 3px}.sg-level-chip{display:grid;place-items:center;min-width:39px;height:38px;padding:0 10px;border:1px solid color-mix(in srgb,var(--sg-accent) 36%,var(--sg-border));border-radius:7px;font-weight:740;white-space:nowrap;box-shadow:inset 0 1px 0 color-mix(in srgb,var(--sg-surface) 55%,transparent)}.sg-level-chip:hover{transform:translateY(-2px)}.sg-level-chip[data-level="0"],.sg-level-badge[data-level="0"],.sg-layer-item.current[data-level="0"]{background:var(--sg-level-0)}.sg-level-chip[data-level="1"],.sg-level-badge[data-level="1"],.sg-layer-item.current[data-level="1"]{background:var(--sg-level-1)}.sg-level-chip[data-level="2"],.sg-level-badge[data-level="2"],.sg-layer-item.current[data-level="2"]{background:var(--sg-level-2)}.sg-level-chip[data-level="3"],.sg-level-badge[data-level="3"],.sg-layer-item.current[data-level="3"]{background:var(--sg-level-3)}.sg-level-chip[data-level="4"],.sg-level-badge[data-level="4"],.sg-layer-item.current[data-level="4"]{background:var(--sg-level-4)}.sg-level-chip[data-level="5"],.sg-level-badge[data-level="5"],.sg-layer-item.current[data-level="5"]{background:var(--sg-level-5)}.sg-open-chip{min-width:116px;border-style:dashed;background:transparent;color:var(--sg-text);font-weight:650;box-shadow:none}.sg-time-direction{display:flex;align-items:center;gap:9px;margin-top:9px;color:var(--sg-muted);font-size:11px}.sg-time-line{height:1px;flex:1;background:linear-gradient(90deg,var(--sg-border),var(--sg-accent))}.sg-overview-meta{display:flex;gap:18px;flex-wrap:wrap;margin-top:8px;color:var(--sg-muted);font-size:12px}
370
370
  .sg-block-list{position:relative;border:1px solid var(--sg-border);border-radius:12px;background:color-mix(in srgb,var(--sg-surface) 56%,transparent);overflow:hidden}.sg-block-header,.sg-block-toggle{display:grid;grid-template-columns:88px 98px minmax(128px,1fr) 116px 24px;align-items:center;gap:8px;width:100%;min-width:0}.sg-block-header{padding:9px 12px;border-bottom:1px solid var(--sg-border);background:color-mix(in srgb,var(--sg-soft) 48%,transparent);color:var(--sg-muted);font-size:11px}.sg-block-unit+.sg-block-unit{border-top:1px solid var(--sg-border)}.sg-block-toggle{padding:11px 12px;border:0;background:transparent;text-align:left;cursor:pointer}.sg-block-toggle:hover,.sg-block-toggle[aria-expanded="true"]{background:color-mix(in srgb,var(--sg-accent) 6%,transparent)}.sg-block-toggle:hover .sg-row-chevron{color:var(--sg-accent);transform:translateX(2px)}.sg-block-toggle[aria-expanded="true"] .sg-row-chevron{color:var(--sg-accent);transform:rotate(180deg)}.sg-level-cell{display:flex;align-items:center;gap:6px;min-width:0}.sg-level-badge{display:inline-grid;place-items:center;min-width:38px;height:25px;padding:0 8px;border:1px solid color-mix(in srgb,var(--sg-accent) 42%,var(--sg-border));border-radius:6px;font-weight:740}.sg-lifted{padding:1px 5px;border:1px solid var(--sg-border);border-radius:5px;color:var(--sg-muted);font-size:10px;white-space:nowrap}.sg-block-name{font-weight:690}.sg-block-distance,.sg-block-turn{color:var(--sg-muted);font-size:12px}.sg-row-chevron{color:var(--sg-muted);font-size:17px;text-align:right;transition:color var(--sg-fast) var(--sg-ease),transform var(--sg-medium) var(--sg-ease)}.sg-open-row{cursor:default}.sg-open-row:hover{background:transparent}.sg-open-badge{display:inline-flex;align-items:center;height:25px;padding:0 8px;border:1px dashed var(--sg-muted);border-radius:6px;white-space:nowrap}.sg-block-expanded{padding:0 10px 11px;transform-origin:top;animation:sg-expand var(--sg-medium) var(--sg-ease) both}.sg-layer-panel{padding:11px;border:1px solid var(--sg-border);border-radius:9px;background:color-mix(in srgb,var(--sg-page) 82%,var(--sg-surface));box-shadow:inset 0 1px 0 color-mix(in srgb,var(--sg-surface) 70%,transparent)}.sg-layer-heading{display:flex;justify-content:space-between;gap:10px;margin-bottom:8px}.sg-layer-heading strong{font-size:13px}.sg-layer-heading span{color:var(--sg-muted);font-size:11px}.sg-layer-stack{display:flex;flex-direction:column;gap:5px}.sg-layer-hover{position:relative}.sg-layer-hover:after{content:"";position:absolute;left:100%;top:0;width:12px;height:100%}.sg-layer-item{position:relative;display:grid;grid-template-columns:39px minmax(0,1fr) 30px;align-items:stretch;min-height:39px;border:1px solid var(--sg-border);border-radius:7px;background:color-mix(in srgb,var(--sg-soft) 55%,transparent);color:var(--sg-muted)}.sg-layer-item:hover{border-color:color-mix(in srgb,var(--sg-accent) 34%,var(--sg-border));transform:translateX(2px)}.sg-layer-item.current{border-color:color-mix(in srgb,var(--sg-accent) 72%,var(--sg-border));color:var(--sg-text);box-shadow:inset 2px 0 0 var(--sg-accent)}.sg-layer-label{display:grid;place-items:center;border-right:1px solid var(--sg-border);font-weight:720;color:inherit}.sg-layer-preview{padding:8px 10px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;font-size:12px}.sg-layer-more{width:30px;border:0;border-left:1px solid transparent;border-radius:0 6px 6px 0;background:transparent;color:inherit;cursor:pointer;font-weight:800;letter-spacing:1px}.sg-layer-more:hover,.sg-layer-more[aria-expanded="true"]{background:color-mix(in srgb,var(--sg-accent) 14%,transparent)}.sg-layer-menu{position:absolute;right:3px;top:34px;z-index:14;min-width:132px;padding:4px;border:1px solid var(--sg-border);border-radius:8px;background:var(--sg-surface);box-shadow:var(--sg-shadow);animation:sg-pop var(--sg-fast) var(--sg-ease) both}.sg-layer-menu button{width:100%;padding:7px 9px;border:0;border-radius:5px;background:transparent;text-align:left;cursor:pointer;white-space:nowrap}.sg-layer-menu button:hover:not(:disabled){background:var(--sg-soft);color:var(--sg-accent)}.sg-layer-menu button:disabled{cursor:not-allowed;opacity:.45}.sg-layer-popover{position:absolute;left:calc(100% + 11px);top:-7px;z-index:12;width:min(360px,46vw);max-height:340px;padding:12px;overflow:auto;border:1px solid color-mix(in srgb,var(--sg-accent) 32%,var(--sg-border));border-radius:10px;background:var(--sg-surface);box-shadow:var(--sg-shadow);visibility:hidden;opacity:0;transform:translateX(-4px);transition:opacity var(--sg-fast) var(--sg-ease),transform var(--sg-fast) var(--sg-ease),visibility var(--sg-fast)}.sg-layer-hover:hover .sg-layer-popover,.sg-layer-item:focus-visible + .sg-layer-popover{visibility:visible;opacity:1;transform:translateX(0)}.sg-layer-popover strong{display:block;margin-bottom:7px}.sg-layer-full{margin:0;white-space:pre-wrap;font:12px/1.55 "Segoe UI Variable Text","Segoe UI",ui-sans-serif,system-ui,-apple-system,"Microsoft YaHei",sans-serif}.sg-inline-error{padding:7px 9px;margin-bottom:7px;border-radius:6px;background:var(--sg-danger-soft);color:var(--sg-danger);font-size:12px}
371
371
  .sg-loading{padding:32px 0}.sg-skeleton{position:relative;height:12px;margin:10px 0;overflow:hidden;border-radius:5px;background:var(--sg-soft)}.sg-skeleton:after{content:"";position:absolute;inset:0;background:linear-gradient(100deg,transparent 15%,color-mix(in srgb,var(--sg-surface) 80%,transparent) 48%,transparent 82%);transform:translateX(-110%);animation:sg-shimmer 1.35s ease-in-out infinite}.sg-skeleton:nth-child(2){width:72%}.sg-empty{padding:40px 16px;text-align:center;color:var(--sg-muted)}.sg-empty strong{display:block;margin-bottom:5px;color:var(--sg-text);font-size:14px}.sg-error{padding:13px;margin-bottom:16px;border:1px solid color-mix(in srgb,var(--sg-danger) 28%,var(--sg-border));border-radius:9px;background:var(--sg-danger-soft);animation:sg-pop var(--sg-medium) var(--sg-ease) both}.sg-error-title{font-weight:700;color:var(--sg-danger)}.sg-error details{margin-top:7px;font-size:12px}
@@ -394,7 +394,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
394
394
  .sg-support-card{padding:14px 0;border-bottom:1px solid var(--sg-border)}.sg-support-card h3{margin:0;font-size:14px}.sg-support-card p{margin:4px 0 10px;color:var(--sg-muted);font-size:12px}.sg-primary-link{display:inline-flex;padding:7px 11px;border:1px solid var(--sg-accent);border-radius:6px;background:var(--sg-accent);color:#fff;text-decoration:none;cursor:pointer}.sg-check{display:flex;align-items:flex-start;gap:8px;margin:9px 0;color:var(--sg-text);font-size:12px}.sg-check input{margin-top:3px}.sg-privacy-note{padding:10px 11px;margin:12px 0;border-radius:7px;background:var(--sg-good-soft);color:var(--sg-good);font-size:12px}.sg-footer{margin-top:24px;padding-top:13px;border-top:1px solid var(--sg-border);text-align:center;color:var(--sg-muted);font-size:12px}.sg-footer button{padding:2px 4px;border:0;background:transparent;color:var(--sg-accent);cursor:pointer}.sg-virtual-note{margin-top:6px;color:var(--sg-muted);font-size:11px}
395
395
  @media (max-width:560px){.sg-decay-head{align-items:flex-start;flex-direction:column}.sg-conversation{width:100%;justify-content:flex-start}.sg-conversation select{max-width:100%;flex:1}}
396
396
  @media (prefers-reduced-motion:reduce){.sg-memory *,.sg-memory *:before,.sg-memory *:after{scroll-behavior:auto!important;animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important}.sg-processing-icon{animation:none}.sg-skeleton:after{display:none}}
397
- `;function api2(path,params,options2){let query=new URLSearchParams(params||{}),url="/api/stratagate/"+path+(query.size?"?"+query:""),attempt=0,request=()=>fetch(url,{cache:"no-store",...options2}).then(res=>res.json().catch(()=>({})).then(data4=>{if(!res.ok)throw new Error(data4&&data4.error||"HTTP "+res.status);return data4})).catch(reason=>{let message=String(reason?.message||reason);if((reason instanceof TypeError||message.includes("Failed to fetch"))&&!options2?.method&&attempt<2)return attempt+=1,new Promise(resolve2=>window.setTimeout(resolve2,attempt*300)).then(request);throw new Error(message+"\uFF08"+path+"\uFF09")});return request()}function dashboardApi(params,options2={}){let query=new URLSearchParams(params||{}),url="/api/stratagate/dashboard"+(query.size?"?"+query:""),attempt=0,request=()=>fetch(url,{cache:"no-cache",signal:options2.signal,headers:options2.etag?{"If-None-Match":options2.etag}:void 0}).then(async res=>{let etag=res.headers.get("etag")||options2.etag||"";if(res.status===304)return{notModified:!0,etag,data:null};let data4=await res.json().catch(()=>({}));if(!res.ok)throw new Error(data4&&data4.error||"HTTP "+res.status);return{notModified:!1,etag,data:data4}}).catch(reason=>{if(reason?.name==="AbortError")throw reason;let message=String(reason?.message||reason);if((reason instanceof TypeError||message.includes("Failed to fetch"))&&attempt<2)return attempt+=1,new Promise(resolve2=>window.setTimeout(resolve2,attempt*300)).then(request);throw new Error(message+"\uFF08dashboard\uFF09")});return request()}function projectName(item,workspaceTitles={}){let value=String(item?.namespace||item||"");if(value.includes(":project:")){let key=value.split(":project:").pop();return key&&workspaceTitles[key]?workspaceTitles[key]:item?.workspaceName&&item.workspaceName!=="\u5F53\u524D\u5DE5\u4F5C\u533A"?item.workspaceName:"\u5DE5\u4F5C\u533A\u540D\u79F0\u8BFB\u53D6\u4E2D\u2026"}return item?.workspaceName?item.workspaceName:value.includes(":global:")?value.split(":global:").pop()||"\u5168\u5C40\u8BB0\u5FC6":value.includes(":session:")?"\u5F53\u524D\u5BF9\u8BDD":value||"\u5F53\u524D\u5DE5\u4F5C\u533A"}function workspaceProjectKey(path){let canonical=String(path||"").replaceAll("\\","/").toLowerCase();return!canonical||!globalThis.crypto?.subtle?Promise.resolve(""):globalThis.crypto.subtle.digest("SHA-256",new TextEncoder().encode(canonical)).then(digest=>Array.from(new Uint8Array(digest).slice(0,10),byte=>byte.toString(16).padStart(2,"0")).join(""))}function formatTime(value){if(!value)return"\u65F6\u95F4\u672A\u77E5";let date=new Date(value);if(Number.isNaN(date.getTime()))return String(value);let seconds=Math.round((Date.now()-date.getTime())/1e3);if(seconds>=0&&seconds<60)return"\u521A\u521A";if(seconds>=60&&seconds<3600)return Math.floor(seconds/60)+" \u5206\u949F\u524D";let timeZone="Asia/Shanghai",dayKey=input=>new Intl.DateTimeFormat("en-CA",{timeZone,year:"numeric",month:"2-digit",day:"2-digit"}).format(input),clock=input=>new Intl.DateTimeFormat("zh-CN",{timeZone,hour:"2-digit",minute:"2-digit",hour12:!1}).format(input),now=new Date;if(dayKey(date)===dayKey(now))return"\u4ECA\u5929 "+clock(date);let yesterday=new Date(now.getTime()-1440*60*1e3);return dayKey(date)===dayKey(yesterday)?"\u6628\u5929 "+clock(date):new Intl.DateTimeFormat("zh-CN",{timeZone,month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).format(date)}function statusText(status){return status==="organized"?"\u5DF2\u6574\u7406":status==="failed"?"\u6574\u7406\u5931\u8D25":status==="waiting"?"\u7B49\u5F85\u6574\u7406":"\u6574\u7406\u4E2D"}function Loading(){return h("div",{className:"sg-loading",role:"status"},h("div",{className:"sg-skeleton"}),h("div",{className:"sg-skeleton"}),h("div",{className:"sg-skeleton"}))}function Empty({title,copy:copy3}){return h("div",{className:"sg-empty"},h("strong",null,title),h("span",null,copy3))}function BackBar({label,onBack}){return h("div",{className:"sg-backbar"},h("button",{className:"sg-back",onClick:onBack,title:"\u8FD4\u56DE"},h("span",{"aria-hidden":"true"},"\u2190"),label))}function FailureAlert({count,onOpen}){return count?h("button",{className:"sg-alert",onClick:onOpen},h("span",{className:"sg-alert-mark","aria-hidden":"true"},"\u26A0"),h("span",null,h("span",{className:"sg-alert-title"},count+" \u6761\u77ED\u671F\u8BB0\u5FC6\u5C1A\u672A\u6574\u7406\u5B8C\u6210"),h("br"),h("span",{className:"sg-alert-copy"},"\u539F\u59CB\u5185\u5BB9\u5DF2\u7ECF\u4FDD\u5B58\uFF0C\u4E0D\u4F1A\u4E22\u5931\u3002")),h("span",{className:"sg-chevron","aria-hidden":"true"},"\u203A")):null}function ProcessingAlert({visible}){return visible?h("div",{className:"sg-processing-alert",role:"status","aria-live":"polite"},h("span",{className:"sg-processing-icon","aria-hidden":"true"},"\u21BB"),h("span",null,h("span",{className:"sg-processing-title"},"\u6B63\u5728\u89E6\u53D1\u8BB0\u5FC6\u6574\u7406"),h("span",{className:"sg-processing-copy"},"Block\u3001Event \u548C\u77E5\u8BC6\u56FE\u8C31\u6B63\u5728\u751F\u6210\uFF0C\u8BF7\u7A0D\u5019\u3002"))):null}function SearchBox({value,onChange}){return h("div",{className:"sg-search"},h("span",{className:"sg-search-mark","aria-hidden":"true"},"\u2315"),h("input",{value,onChange:event3=>onChange(event3.target.value),placeholder:"\u641C\u7D22\u8BB0\u5FC6\u3001\u4EBA\u7269\u3001\u9879\u76EE\u3001\u6982\u5FF5\u2026","aria-label":"\u641C\u7D22\u957F\u671F\u8BB0\u5FC6"}))}let NODE_META={person:["\u4EBA\u7269","#8b6ccf","\u2659"],project:["\u9879\u76EE","#6f55ae","\u25A3"],organization:["\u7EC4\u7EC7","#3978cf","\u2318"],tool:["\u5DE5\u5177","#3b854d","\u25A4"],place:["\u5730\u70B9","#a9632b","\u2302"]},EVENT_TYPE_TEXT={decision:"\u51B3\u7B56",release:"\u53D1\u5E03",task_completed:"\u4EFB\u52A1\u5B8C\u6210",plan:"\u8BA1\u5212",change:"\u53D8\u66F4",cancellation:"\u53D6\u6D88",incident:"\u4E8B\u4EF6",meeting:"\u4F1A\u8BAE",collaboration:"\u534F\u4F5C",migration:"\u8FC1\u79FB",other:"\u5176\u4ED6"},EVENT_STATUS_TEXT={occurred:"\u5DF2\u53D1\u751F",planned:"\u8BA1\u5212\u4E2D",cancelled:"\u5DF2\u53D6\u6D88",ongoing:"\u8FDB\u884C\u4E2D",unknown:"\u672A\u77E5"},EVENT_RELATIONS=[["supersedesEventIds","\u53D6\u4EE3"],["conflictsWithEventIds","\u51B2\u7A81"],["sameEventId","\u540C\u4E00\u4E8B\u4EF6"],["beforeEventIds","\u4E4B\u524D"],["afterEventIds","\u4E4B\u540E"],["relatedEventIds","\u76F8\u5173"]];function exactTime(value){if(!value)return"\u672A\u77E5";let date=new Date(value);return Number.isNaN(date.getTime())?String(value):new Intl.DateTimeFormat("zh-CN",{timeZone:"Asia/Shanghai",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hour12:!1}).format(date)}function eventOccurrence(event3){let happened=event3.temporal?.happenedStart||event3.temporal?.happenedEnd;return{value:happened||event3.temporal?.mentionedAt||event3.createdAt,known:!!happened}}function NodePill({node,onClick}){let meta3=NODE_META[node.type]||["\u5B9E\u4F53","#64748b","\u2022"];return h("button",{className:"sg-entity-pill",onClick},h("span",{style:{color:meta3[1]}},meta3[2]),node.name)}function NodeSummaryBubble({node,x:x2,y:y2,width:width2,height:height2=560,onViewDetails}){if(!node)return null;let facts=(node.facts||[]).filter(fact=>fact.status==="active").slice(0,5),eventCount=new Set(node.sourceEventIds||[]).size;return h("aside",{className:"sg-node-bubble "+(x2>width2*.62?"flip":""),style:{left:x2/width2*100+"%",top:y2/height2*100+"%"}},h("div",{className:"sg-node-bubble-head"},h("h3",null,node.name),h("span",{className:"sg-status-dot"},"\u25CF "+(node.status==="active"?"\u6D3B\u8DC3":node.status||"\u672A\u77E5"))),(node.tags||[]).length?h("div",{className:"sg-node-tags"},node.tags.slice(0,4).map(tag=>h("span",{key:tag,className:"sg-node-tag"},tag))):null,h("p",{className:"sg-node-bubble-state"},node.currentState||"\u6682\u65E0\u5F53\u524D\u72B6\u6001"),facts.length?h("ul",null,facts.map(fact=>h("li",{key:fact.id},h("strong",null,fact.key+"\uFF1A"),Array.isArray(fact.value)?fact.value.join("\u3001"):fact.value))):h("p",{className:"sg-node-bubble-state"},"\u6682\u65E0\u5173\u952E\u4E8B\u5B9E"),h("div",{className:"sg-node-bubble-foot"},h("span",null,eventCount+" \u6761\u76F8\u5173\u4E8B\u4EF6"),h("button",{type:"button",onClick:onViewDetails},"\u67E5\u770B\u8BE6\u60C5 \u2192")))}let GRAPH_NODE_RADIUS={peripheral:30,normal:38,important:46,core:54},GRAPH_IMPORTANCE_TEXT={peripheral:"\u8FB9\u7F18\u8282\u70B9",normal:"\u666E\u901A\u8282\u70B9",important:"\u91CD\u8981\u8282\u70B9",core:"\u6838\u5FC3\u8282\u70B9"};function graphNameKey(value){return String(value||"").toLocaleLowerCase().replace(/[^\p{L}\p{N}]+/gu,"")}function graphTimestamp(value){let timestamp=Date.parse(String(value||""));return Number.isFinite(timestamp)?timestamp:0}function graphNodeImportance(nodes3,edges3,project){let activeEdges=edges3.filter(edge=>edge.status==="active"),activeSupportingEvents=node=>(node.supportingEvents||[]).filter(event3=>event3.status!=="forgotten"&&event3.status!=="archived"),relationCounts=new Map(nodes3.map(node=>[node.id,0])),neighbors=new Map(nodes3.map(node=>[node.id,new Set]));for(let edge of activeEdges)relationCounts.set(edge.fromNodeId,(relationCounts.get(edge.fromNodeId)||0)+1),relationCounts.set(edge.toNodeId,(relationCounts.get(edge.toNodeId)||0)+1),neighbors.get(edge.fromNodeId)?.add(edge.toNodeId),neighbors.get(edge.toNodeId)?.add(edge.fromNodeId);let projectKey=graphNameKey(project),directWorkspaceNodes=new Set(nodes3.filter(node=>projectKey&&[node.name,...node.aliases||[]].some(name=>{let key=graphNameKey(name);return key===projectKey||key.length>=5&&projectKey.length>=5&&(key.includes(projectKey)||projectKey.includes(key))})).map(node=>node.id)),workspaceAffinity=new Map(nodes3.map(node=>[node.id,directWorkspaceNodes.has(node.id)?1:0]));for(let nodeId of directWorkspaceNodes)for(let neighborId of neighbors.get(nodeId)||[]){workspaceAffinity.set(neighborId,Math.max(workspaceAffinity.get(neighborId)||0,.55));for(let secondHopId of neighbors.get(neighborId)||[])workspaceAffinity.set(secondHopId,Math.max(workspaceAffinity.get(secondHopId)||0,.25))}let supportCounts=new Map(nodes3.map(node=>{let supportingEvents=activeSupportingEvents(node);return[node.id,supportingEvents.length?new Set(supportingEvents.map(event3=>event3.id)).size:new Set(node.sourceEventIds||[]).size]})),maxSupport=Math.max(1,...supportCounts.values()),maxRelations=Math.max(1,...relationCounts.values()),latestActivity=0;for(let node of nodes3){latestActivity=Math.max(latestActivity,graphTimestamp(node.updatedAt));for(let event3 of activeSupportingEvents(node))latestActivity=Math.max(latestActivity,graphTimestamp(event3.updatedAt||event3.createdAt))}for(let edge of activeEdges)latestActivity=Math.max(latestActivity,graphTimestamp(edge.updatedAt));let halfLife=2160*60*60*1e3,recency=timestamp=>timestamp&&latestActivity?Math.exp(-Math.max(0,latestActivity-timestamp)/halfLife):0,scored=nodes3.map(node=>{let sustainedMentions=activeSupportingEvents(node).map(event3=>recency(graphTimestamp(event3.updatedAt||event3.createdAt))).sort((left,right)=>right-left).slice(0,3),recentScore=.25*recency(graphTimestamp(node.updatedAt))+.75*sustainedMentions.reduce((sum,value)=>sum+value,0)/3,supportScore=Math.log1p(supportCounts.get(node.id)||0)/Math.log1p(maxSupport),relationScore=Math.log1p(relationCounts.get(node.id)||0)/Math.log1p(maxRelations),score=.42*supportScore+.28*relationScore+.15*recentScore+.15*(workspaceAffinity.get(node.id)||0);return{id:node.id,score}}),ordered=scored.map(({score})=>score).sort((left,right)=>left-right),quantile=ratio=>ordered[Math.ceil(Math.max(0,ordered.length-1)*ratio)]||0,spread=(ordered[ordered.length-1]||0)-(ordered[0]||0),thresholds={normal:quantile(.25),important:quantile(.6),core:quantile(.85)};return new Map(scored.map(({id:id2,score})=>{let tier;return spread<.02?tier=score>=.65?"core":score>=.38?"important":"normal":score>=thresholds.core?tier="core":score>=thresholds.important?tier="important":score>=thresholds.normal?tier="normal":tier="peripheral",[id2,{score,tier,radius:GRAPH_NODE_RADIUS[tier]}]}))}function GraphCanvas({nodes:nodes3,edges:edges3,clusters,importance,selectedId,onSelect,showSummary=!1,onViewDetails}){let containerRef=React.useRef(null),graphRef=React.useRef(null),selectedIdRef=React.useRef(selectedId);selectedIdRef.current=selectedId;let[selectedPoint,setSelectedPoint]=React.useState(null),[zoomPercent,setZoomPercent]=React.useState(100),displayedNodes=[...nodes3].sort((left,right)=>(importance.get(right.id)?.score||0)-(importance.get(left.id)?.score||0)).slice(0,40),displayedIds=new Set(displayedNodes.map(node=>node.id)),visibleClusters=(clusters||[]).map(cluster=>({...cluster,nodeIds:(cluster.nodeIds||[]).filter(id2=>displayedIds.has(id2))})).filter(cluster=>cluster.nodeIds.length),assignedIds=new Set(visibleClusters.flatMap(cluster=>cluster.nodeIds));for(let node of displayedNodes.filter(item=>!assignedIds.has(item.id)))visibleClusters.push({id:"fallback-"+node.id,label:(node.tags||[])[0]||node.name,nodeIds:[node.id],tags:node.tags||[]});let membership=new Map(visibleClusters.flatMap(cluster=>cluster.nodeIds.map(id2=>[id2,cluster.id]))),activeEdges=edges3.filter(edge=>edge.status==="active"&&displayedIds.has(edge.fromNodeId)&&displayedIds.has(edge.toNodeId)),signature=JSON.stringify({nodes:displayedNodes.map(node=>[node.id,node.name,node.type,node.tags||[],importance.get(node.id)?.tier]),edges:activeEdges.map(edge=>[edge.id,edge.fromNodeId,edge.toNodeId,edge.relation,edge.confidence]),clusters:visibleClusters.map(cluster=>[cluster.id,cluster.label,cluster.nodeIds])});React.useEffect(()=>{let container2=containerRef.current;if(!container2||!cytoscape4||!displayedNodes.length)return;let computed=getComputedStyle(container2),textColor=computed.getPropertyValue("--sg-text").trim()||"#0f1115",mutedColor=computed.getPropertyValue("--sg-muted").trim()||"#64748b",borderColor=computed.getPropertyValue("--sg-border").trim()||"#d5d9df",pageColor=computed.getPropertyValue("--sg-page").trim()||"#ffffff",accentColor=computed.getPropertyValue("--sg-accent").trim()||"#4176e6",reduceMotion=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches===!0,parentIds=new Map(visibleClusters.map(cluster=>[cluster.id,"sg-parent-"+cluster.id])),clusterSizes=new Map(visibleClusters.map(cluster=>[cluster.id,cluster.nodeIds.length])),elements=[...visibleClusters.map(cluster=>({data:{id:parentIds.get(cluster.id),label:cluster.label+" \xB7 "+cluster.nodeIds.length},classes:"sg-community"})),...displayedNodes.map(node=>{let meta3=NODE_META[node.type]||["\u5B9E\u4F53","#64748b","\u2022"],semantic=(node.tags||[])[0]||meta3[0],visualImportance=importance.get(node.id)||{tier:"normal",radius:GRAPH_NODE_RADIUS.normal};return{data:{id:node.id,parent:parentIds.get(membership.get(node.id)),label:node.name+`
398
- `+semantic,color:meta3[1],size:visualImportance.radius*2,tier:visualImportance.tier},classes:"sg-memory-node"}}),...activeEdges.map(edge=>{let fromCluster=membership.get(edge.fromNodeId),toCluster=membership.get(edge.toNodeId),sameCluster=fromCluster===toCluster,labeled=sameCluster&&(clusterSizes.get(fromCluster)||0)<=6;return{data:{id:"sg-edge-"+edge.id,source:edge.fromNodeId,target:edge.toNodeId,label:edge.relation},classes:"sg-memory-edge "+(sameCluster?"same-community":"cross-community")+(labeled?" labeled":"")}})],graph=cytoscape4({container:container2,elements,wheelSensitivity:.22,minZoom:.25,maxZoom:2.4,selectionType:"single",boxSelectionEnabled:!1,style:[{selector:"node.sg-community",style:{"background-color":accentColor,"background-opacity":.045,"border-color":accentColor,"border-opacity":.28,"border-width":1,"border-style":"dashed",shape:"round-rectangle",padding:"22px",label:"data(label)",color:mutedColor,"font-size":12,"font-weight":700,"text-valign":"top","text-halign":"center","text-margin-y":-9,"text-background-color":pageColor,"text-background-opacity":.82,"text-background-padding":"3px"}},{selector:"node.sg-memory-node",style:{width:"data(size)",height:"data(size)","background-color":"data(color)","background-opacity":.28,"border-color":"data(color)","border-width":1.5,label:"data(label)",color:textColor,"font-size":11,"font-weight":650,"text-wrap":"wrap","text-max-width":96,"text-valign":"center","text-halign":"center","overlay-opacity":0,"transition-property":"border-width, border-color, underlay-opacity","transition-duration":reduceMotion?"0ms":"180ms"}},{selector:"node.sg-memory-node:selected",style:{"border-width":4,"border-color":accentColor,"underlay-color":accentColor,"underlay-opacity":.16,"underlay-padding":7}},{selector:"edge.sg-memory-edge",style:{width:1.2,"line-color":mutedColor,"target-arrow-color":mutedColor,"target-arrow-shape":"triangle","curve-style":"bezier",opacity:.58,"arrow-scale":.75,label:"","overlay-opacity":0}},{selector:"edge.sg-memory-edge.labeled",style:{label:"data(label)",color:textColor,"font-size":10,"text-background-color":pageColor,"text-background-opacity":.88,"text-background-padding":"2px","text-rotation":"autorotate"}},{selector:"edge.sg-memory-edge.cross-community",style:{opacity:.24,"line-style":"dashed"}},{selector:"edge.sg-memory-edge.selected-relation",style:{opacity:.9,width:2,label:"data(label)",color:textColor,"font-size":10,"text-background-color":pageColor,"text-background-opacity":.9,"text-background-padding":"2px"}}]});graphRef.current=graph;let updatePoint=()=>{let selected=graph.getElementById(selectedIdRef.current);if(!selected.length){setSelectedPoint(null);return}let point=selected.renderedPosition();setSelectedPoint({x:point.x,y:point.y,width:container2.clientWidth||760,height:container2.clientHeight||522})};graph.on("tap","node.sg-memory-node",event3=>onSelect(event3.target.id()));let updateZoom=()=>setZoomPercent(Math.round(graph.zoom()*100));graph.on("pan zoom resize",updatePoint),graph.on("zoom",updateZoom),graph.on("layoutstop",updatePoint),graph.on("layoutstop",updateZoom);let resizeObserver=globalThis.ResizeObserver?new globalThis.ResizeObserver(()=>{graph.resize(),updatePoint()}):null;return resizeObserver?.observe(container2),graph.layout({name:"fcose",quality:"default",randomize:!0,animate:reduceMotion?!1:"end",animationDuration:reduceMotion?0:320,animationEasing:"ease-out-cubic",fit:!0,padding:48,nodeRepulsion:5200,idealEdgeLength:edge=>edge.hasClass("cross-community")?170:78,edgeElasticity:.42,nestingFactor:1.35,gravity:.28,gravityCompound:1,gravityRangeCompound:1.5,tile:!0}).run(),()=>{resizeObserver?.disconnect(),graphRef.current=null,graph.destroy()}},[signature]),React.useEffect(()=>{let graph=graphRef.current;if(!graph)return;graph.nodes(".sg-memory-node").unselect(),graph.edges().removeClass("selected-relation");let selected=graph.getElementById(selectedId);if(!selected.length){setSelectedPoint(null);return}selected.select(),selected.connectedEdges().addClass("selected-relation");let point=selected.renderedPosition(),container2=containerRef.current;setSelectedPoint({x:point.x,y:point.y,width:container2?.clientWidth||760,height:container2?.clientHeight||522})},[selectedId,signature]);let setGraphZoom=nextPercent=>{let graph=graphRef.current,container2=containerRef.current;if(!graph||!container2)return;let percent=Math.min(240,Math.max(25,Number(nextPercent)));graph.zoom({level:percent/100,renderedPosition:{x:container2.clientWidth/2,y:container2.clientHeight/2}})};if(!nodes3.length)return h(Empty,{title:"\u77E5\u8BC6\u56FE\u8C31\u6B63\u5728\u5F62\u6210",copy:"Event \u4F1A\u5728\u540E\u53F0\u5206\u6279\u6295\u5F71\u4E3A\u8282\u70B9\u4E0E\u5173\u7CFB\u3002"});if(!cytoscape4)return h(Empty,{title:"\u56FE\u8C31\u7EC4\u4EF6\u672A\u80FD\u52A0\u8F7D",copy:"\u8BF7\u91CD\u65B0\u52A0\u8F7D\u9875\u9762\u540E\u518D\u8BD5\u3002"});let selectedNode=nodes3.find(node=>node.id===selectedId);return h("div",{className:"sg-graph-canvas",role:"img","aria-label":visibleClusters.length+" \u4E2A Leiden \u4E3B\u9898\u7FA4\u7EC4\u7684\u77E5\u8BC6\u56FE\u8C31"},h("div",{ref:containerRef,className:"sg-cytoscape"}),h("div",{className:"sg-graph-zoom",role:"group","aria-label":"\u77E5\u8BC6\u56FE\u8C31\u7F29\u653E"},h("button",{type:"button",onClick:()=>setGraphZoom(zoomPercent-20),disabled:zoomPercent<=25,title:"\u7F29\u5C0F","aria-label":"\u7F29\u5C0F\u77E5\u8BC6\u56FE\u8C31"},"\u2212"),h("input",{type:"range",min:"25",max:"240",step:"5",value:String(zoomPercent),onInput:event3=>setGraphZoom(event3.target.value),title:"\u7F29\u653E\u6BD4\u4F8B "+zoomPercent+"%","aria-label":"\u77E5\u8BC6\u56FE\u8C31\u7F29\u653E\u6BD4\u4F8B","aria-valuetext":zoomPercent+"%"}),h("button",{type:"button",onClick:()=>setGraphZoom(zoomPercent+20),disabled:zoomPercent>=240,title:"\u653E\u5927","aria-label":"\u653E\u5927\u77E5\u8BC6\u56FE\u8C31"},"+")),h("div",{className:"sg-graph-a11y","aria-label":"\u77E5\u8BC6\u56FE\u8C31\u8282\u70B9\u5217\u8868"},displayedNodes.map(node=>h("button",{key:node.id,onClick:()=>onSelect(node.id)},node.name+"\uFF0C"+((node.tags||[])[0]||(NODE_META[node.type]||["\u5B9E\u4F53"])[0])+"\uFF0C"+GRAPH_IMPORTANCE_TEXT[importance.get(node.id)?.tier||"normal"]))),showSummary&&selectedNode&&selectedPoint?h(NodeSummaryBubble,{node:selectedNode,x:selectedPoint.x,y:selectedPoint.y,width:selectedPoint.width,height:selectedPoint.height,onViewDetails}):null,h("div",{className:"sg-graph-legend"},Object.entries(NODE_META).map(([type,meta3])=>h("span",{key:type},h("i",{style:{background:meta3[1]}}),meta3[0]))))}function NodeDetailPanel({node,nodes:nodes3,edges:edges3,events,onEvent}){if(!node)return h("aside",{className:"sg-long-detail sg-placeholder-detail"},"\u9009\u62E9\u8282\u70B9\u67E5\u770B\u5F53\u524D\u72B6\u6001\u4E0E\u8BC1\u636E");let meta3=NODE_META[node.type]||["\u5B9E\u4F53","#64748b","\u2022"],relations=edges3.filter(edge=>edge.status==="active"&&(edge.fromNodeId===node.id||edge.toNodeId===node.id)),eventMap=new Map(events.map(event3=>[event3.id,event3]));return h("aside",{className:"sg-long-detail"},h("div",{className:"sg-node-head"},h("span",{className:"sg-node-avatar",style:{background:meta3[1]}},meta3[2]),h("div",null,h("h2",null,node.name),h("span",{className:"sg-muted"},meta3[0]))),(node.tags||[]).length?h("section",null,h("h3",null,"\u8BED\u4E49\u6807\u7B7E"),h("div",{className:"sg-node-tags"},node.tags.map(tag=>h("span",{key:tag,className:"sg-node-tag"},tag)))):null,h("section",null,h("h3",null,"\u5F53\u524D\u72B6\u6001"),h("span",{className:"sg-status-dot"},"\u25CF "+(node.status==="active"?"\u6D3B\u8DC3":node.status)),node.currentState?h("p",{className:"sg-detail-copy"},node.currentState):null),h("section",null,h("h3",null,"\u5173\u952E\u4E8B\u5B9E"),node.facts?.filter(fact=>fact.status==="active").length?h("ul",null,node.facts.filter(fact=>fact.status==="active").map(fact=>h("li",{key:fact.id},h("strong",null,fact.key+"\uFF1A"),Array.isArray(fact.value)?fact.value.join("\u3001"):fact.value))):h("p",{className:"sg-muted"},"\u6682\u65E0\u5173\u952E\u4E8B\u5B9E")),h("section",null,h("h3",null,"\u76F8\u5173\u5173\u7CFB"),relations.length?relations.map(edge=>{let outgoing=edge.fromNodeId===node.id,other=nodes3.find(item=>item.id===(outgoing?edge.toNodeId:edge.fromNodeId));return h("div",{key:edge.id,className:"sg-relation-row"},h("span",null,outgoing?edge.relation:"\u88AB"+edge.relation),h("strong",null,other?.name||"\u672A\u77E5\u8282\u70B9"),h("small",null,Math.round(edge.confidence*100)+"%"))}):h("p",{className:"sg-muted"},"\u6682\u65E0\u5173\u7CFB")),h("section",null,h("h3",null,"\u652F\u6491\u4E8B\u4EF6"),(node.sourceEventIds||[]).flatMap(id2=>eventMap.get(id2)||[]).slice(0,8).map(event3=>h("button",{key:event3.id,className:"sg-support-event",onClick:()=>onEvent(event3.id)},h("span",null,exactTime(eventOccurrence(event3).value)+" \xB7 "+event3.title),h("b",null,"\u203A")))))}function EventDetailPanel({event:event3,nodes:nodes3,events,onNode,openSource,className="",onMouseEnter,onMouseLeave}){if(!event3)return h("aside",{className:"sg-long-detail sg-placeholder-detail"},"\u9009\u62E9\u4E8B\u4EF6\u67E5\u770B\u5B8C\u6574\u65F6\u95F4\u3001\u5173\u7CFB\u4E0E\u8BC1\u636E");let temporal=event3.temporal||{},eventMap=new Map(events.map(item=>[item.id,item])),nodeMap=new Map(nodes3.map(node=>[node.id,node])),relations=EVENT_RELATIONS.flatMap(([key,label])=>{let value=temporal[key];return(Array.isArray(value)?value:value?[value]:[]).map(id2=>({id:id2,label}))});return h("aside",{className:"sg-long-detail "+className,onMouseEnter,onMouseLeave},h("div",{className:"sg-event-detail-head"},h("h2",null,event3.title),h("span",{className:"sg-event-status "+(temporal.status||"unknown")},EVENT_STATUS_TEXT[temporal.status]||"\u672A\u77E5")),h("span",{className:"sg-type-badge"},EVENT_TYPE_TEXT[temporal.eventType]||temporal.eventType||"\u5176\u4ED6"),h("section",null,h("h3",null,"\u6458\u8981"),h("p",{className:"sg-detail-copy"},event3.summary||"\u6682\u65E0\u6458\u8981")),event3.narrative&&event3.narrative!==event3.summary?h("section",null,h("h3",null,"\u4E8B\u4EF6\u53D9\u8FF0"),h("p",{className:"sg-detail-copy"},event3.narrative)):null,h("section",null,h("h3",null,"\u65F6\u95F4\u4FE1\u606F"),h("dl",{className:"sg-time-grid"},h("dt",null,"\u5B9E\u9645\u53D1\u751F\u65F6\u95F4"),h("dd",null,temporal.happenedStart?exactTime(temporal.happenedStart)+(temporal.happenedEnd&&temporal.happenedEnd!==temporal.happenedStart?" \u2014 "+exactTime(temporal.happenedEnd):""):"\u672A\u77E5"),h("dt",null,"\u63D0\u53CA\u65F6\u95F4"),h("dd",null,exactTime(temporal.mentionedAt||event3.createdAt)),h("dt",null,"\u65F6\u95F4\u7CBE\u5EA6"),h("dd",null,temporal.precision||"unknown"),h("dt",null,"\u539F\u59CB\u8868\u8FBE"),h("dd",null,temporal.originalText||"\u672A\u8BB0\u5F55"))),h("section",null,h("h3",null,"\u53C2\u4E0E\u5B9E\u4F53"),h("div",{className:"sg-tags"},(temporal.participantNodeIds||[]).flatMap(id2=>nodeMap.get(id2)||[]).map(node=>h(NodePill,{key:node.id,node,onClick:()=>onNode(node.id)})),(temporal.participantNodeIds||[]).length?null:(temporal.participants||[]).map(name=>h("span",{key:name,className:"sg-tag"},name)))),relations.length?h("section",null,h("h3",null,"\u4E8B\u4EF6\u5173\u7CFB"),relations.map(relation=>h("div",{key:relation.label+relation.id,className:"sg-relation-row"},h("span",null,relation.label),h("strong",null,eventMap.get(relation.id)?.title||relation.id)))):null,h("section",null,h("h3",null,"\u8BC1\u636E\u6765\u6E90"),h("div",{className:"sg-evidence-row"},h("span",null,"\u6765\u6E90 Block"),h("code",null,event3.sourceBlockId)),h("div",{className:"sg-evidence-row"},h("span",null,"\u7F6E\u4FE1\u5EA6"),h("strong",null,Math.round((event3.confidence||0)*100)+"%"))),h("button",{className:"sg-source-button",onClick:()=>openSource(event3)},"\u67E5\u770B\u6765\u6E90\u539F\u59CB\u6D88\u606F \u2192"))}function TimelineList({events,nodes:nodes3,query,filters,onSelect,selectedId,floating=!1,onNode,openSource}){let[preview,setPreview]=React.useState(null),pinnedId=React.useRef(""),hideTimer=React.useRef(null),cancelHide=()=>{hideTimer.current&&window.clearTimeout(hideTimer.current),hideTimer.current=null},hidePreview=()=>{cancelHide(),setPreview(null),pinnedId.current=""},showPreview=(event3,target,pin=!1)=>{if(!floating||!pin&&pinnedId.current)return;cancelHide();let rect=target.getBoundingClientRect(),width2=Math.min(380,window.innerWidth-24),maxHeight=Math.min(620,window.innerHeight*.72),left=rect.right+12+width2<=window.innerWidth-12?rect.right+12:Math.max(12,rect.left-width2-12),top=Math.min(Math.max(12,rect.top-8),Math.max(12,window.innerHeight-maxHeight-12));setPreview({event:event3,left,top}),pin&&(pinnedId.current=event3.id)},scheduleHide=()=>{pinnedId.current||(cancelHide(),hideTimer.current=window.setTimeout(()=>setPreview(null),140))};React.useEffect(()=>()=>cancelHide(),[]);let normalized=query.trim().toLocaleLowerCase(),now=new Date,weekAgo=now.getTime()-7*864e5,groups={\u4ECA\u5929:[],\u672C\u5468:[],\u66F4\u65E9:[]};events.filter(event3=>event3.status!=="forgotten"&&event3.status!=="archived").filter(event3=>!normalized||JSON.stringify(event3).toLocaleLowerCase().includes(normalized)).filter(event3=>!filters.type||event3.temporal?.eventType===filters.type).filter(event3=>!filters.status||event3.temporal?.status===filters.status).filter(event3=>!filters.node||(event3.temporal?.participantNodeIds||[]).includes(filters.node)).filter(event3=>{let info=eventOccurrence(event3),time2=Date.parse(info.value);return!filters.time||(filters.time==="unknown"?!info.known:filters.time==="today"?Number.isFinite(time2)&&new Date(time2).toDateString()===now.toDateString():filters.time==="week"?time2>=weekAgo:!0)}).sort((a,b)=>String(eventOccurrence(b).value).localeCompare(String(eventOccurrence(a).value))).forEach(event3=>{let info=eventOccurrence(event3),time2=Date.parse(info.value),sameDay=Number.isFinite(time2)&&new Date(time2).toDateString()===now.toDateString();groups[sameDay?"\u4ECA\u5929":time2>=weekAgo?"\u672C\u5468":"\u66F4\u65E9"].push(event3)});let nodeMap=new Map(nodes3.map(node=>[node.id,node]));return h("div",{className:"sg-timeline"},Object.entries(groups).map(([label,items])=>items.length?h("section",{key:label,className:"sg-time-group"},h("h3",null,label),items.map(event3=>{let info=eventOccurrence(event3),temporal=event3.temporal||{};return h("button",{key:event3.id,className:"sg-timeline-card "+(event3.id===selectedId?"selected":""),onMouseEnter:hover=>showPreview(event3,hover.currentTarget),onMouseLeave:scheduleHide,onFocus:focus=>showPreview(event3,focus.currentTarget),onBlur:scheduleHide,onClick:click=>{onSelect(event3.id),showPreview(event3,click.currentTarget,!0)}},h("span",{className:"sg-timeline-dot"}),h("div",{className:"sg-event-clock"},info.known?exactTime(info.value).replace(/^\d{4}\//,""):"\u53D1\u751F\u65F6\u95F4\u672A\u77E5",info.known?null:h("small",null,"\u63D0\u53CA\u4E8E "+exactTime(info.value))),h("div",{className:"sg-event-main"},h("div",{className:"sg-event-title-row"},h("strong",null,event3.title),h("span",{className:"sg-type-badge"},EVENT_TYPE_TEXT[temporal.eventType]||temporal.eventType||"\u5176\u4ED6")),h("p",null,event3.summary||"\u6682\u65E0\u6458\u8981"),h("div",{className:"sg-tags"},(temporal.participantNodeIds||[]).flatMap(id2=>nodeMap.get(id2)||[]).map(node=>h("span",{key:node.id,className:"sg-tag"},node.name)),(temporal.participantNodeIds||[]).length?null:(temporal.participants||[]).map(name=>h("span",{key:name,className:"sg-tag"},name)))),h("span",{className:"sg-event-status "+(temporal.status||"unknown")},EVENT_STATUS_TEXT[temporal.status]||"\u672A\u77E5"))})):null),floating&&preview?h("div",{className:"sg-event-popover",style:{left:preview.left+"px",top:preview.top+"px"},onMouseEnter:cancelHide,onMouseLeave:scheduleHide},h("button",{type:"button",className:"sg-popover-close","aria-label":"\u5173\u95ED\u4E8B\u4EF6\u8BE6\u60C5",onClick:hidePreview},"\xD7"),h(EventDetailPanel,{event:preview.event,nodes:nodes3,events,onNode,openSource})):null)}function LongTermPage({events,graph,project,query,setQuery,openEvent}){let[mode,setMode]=React.useState("graph"),[selectedNodeId,setSelectedNodeId]=React.useState(""),[selectedEventId,setSelectedEventId]=React.useState(""),[eventFilters,setEventFilters]=React.useState({time:"",node:"",type:"",status:""}),[nodeType,setNodeType]=React.useState(""),[nodeTag,setNodeTag]=React.useState(""),[filtersOpen,setFiltersOpen]=React.useState(!1),[fullScreen,setFullScreen]=React.useState(!1),nodes3=graph.nodes||[],edges3=graph.edges||[],clusters=graph.clusters||[],normalized=query.trim().toLocaleLowerCase(),nodeImportance=React.useMemo(()=>graphNodeImportance(nodes3,edges3,project),[nodes3,edges3,project]),nodeTags=[...new Set(nodes3.flatMap(node=>node.tags||[]))].sort((left,right)=>left.localeCompare(right));React.useEffect(()=>{if(!fullScreen)return;let previous=document.body.style.overflow;document.body.style.overflow="hidden";let onKeyDown=event3=>{event3.key==="Escape"&&(setFullScreen(!1),setFiltersOpen(!1))};return window.addEventListener("keydown",onKeyDown),()=>{document.body.style.overflow=previous,window.removeEventListener("keydown",onKeyDown)}},[fullScreen]);let visibleNodes=nodes3.filter(node=>node.status!=="archived").filter(node=>!nodeType||node.type===nodeType).filter(node=>!nodeTag||(node.tags||[]).includes(nodeTag)).filter(node=>!normalized||JSON.stringify(node).toLocaleLowerCase().includes(normalized)),selectEvent=id2=>{setSelectedEventId(id2),setMode("timeline")},selectNode=id2=>{setSelectedNodeId(id2),setMode("graph")},openExplorer=()=>{mode==="graph"&&!selectedNodeId&&visibleNodes[0]&&setSelectedNodeId(visibleNodes[0].id),mode==="timeline"&&!selectedEventId&&events[0]&&setSelectedEventId(events[0].id),setFiltersOpen(!0),setFullScreen(!0)},migration=graph.migration||{projected:events.length,total:events.length,complete:!0},activeFilterCount=mode==="graph"?+!!nodeType+ +!!nodeTag:Object.values(eventFilters).filter(Boolean).length,filterControls=mode==="graph"?h("div",{className:"sg-filterbar"},h("select",{value:nodeType,onChange:event3=>setNodeType(event3.target.value),"aria-label":"\u8282\u70B9\u7C7B\u578B"},h("option",{value:""},"\u5168\u90E8\u8282\u70B9\u7C7B\u578B"),Object.entries(NODE_META).map(([value,meta3])=>h("option",{key:value,value},meta3[0]))),h("select",{value:nodeTag,onChange:event3=>setNodeTag(event3.target.value),"aria-label":"\u8BED\u4E49\u6807\u7B7E"},h("option",{value:""},"\u5168\u90E8\u8BED\u4E49\u6807\u7B7E"),nodeTags.map(tag=>h("option",{key:tag,value:tag},tag)))):h("div",{className:"sg-filterbar"},h("select",{value:eventFilters.time,onChange:event3=>setEventFilters({...eventFilters,time:event3.target.value}),"aria-label":"\u65F6\u95F4\u8303\u56F4"},h("option",{value:""},"\u5168\u90E8\u65F6\u95F4"),h("option",{value:"today"},"\u4ECA\u5929"),h("option",{value:"week"},"\u672C\u5468"),h("option",{value:"unknown"},"\u53D1\u751F\u65F6\u95F4\u672A\u77E5")),h("select",{value:eventFilters.node,onChange:event3=>setEventFilters({...eventFilters,node:event3.target.value}),"aria-label":"\u53C2\u4E0E\u5B9E\u4F53"},h("option",{value:""},"\u5168\u90E8\u5B9E\u4F53"),nodes3.map(node=>h("option",{key:node.id,value:node.id},node.name))),h("select",{value:eventFilters.type,onChange:event3=>setEventFilters({...eventFilters,type:event3.target.value}),"aria-label":"\u4E8B\u4EF6\u7C7B\u578B"},h("option",{value:""},"\u5168\u90E8\u7C7B\u578B"),Object.entries(EVENT_TYPE_TEXT).map(([value,label])=>h("option",{key:value,value},label))),h("select",{value:eventFilters.status,onChange:event3=>setEventFilters({...eventFilters,status:event3.target.value}),"aria-label":"\u4E8B\u4EF6\u72B6\u6001"},h("option",{value:""},"\u5168\u90E8\u72B6\u6001"),Object.entries(EVENT_STATUS_TEXT).map(([value,label])=>h("option",{key:value,value},label))));return h("section",{className:"sg-long-explorer "+(fullScreen?"fullscreen":""),"aria-label":fullScreen?"\u957F\u671F\u8BB0\u5FC6\u5168\u5C4F\u63A2\u7D22":"\u957F\u671F\u8BB0\u5FC6\u6D4F\u89C8"},h("nav",{className:"sg-long-tabs"},h("button",{className:mode==="graph"?"active":"",onClick:()=>setMode("graph")},"\u77E5\u8BC6\u56FE\u8C31"),h("button",{className:mode==="timeline"?"active":"",onClick:()=>setMode("timeline")},"\u4E8B\u4EF6\u65F6\u95F4\u7EBF")),migration.complete?null:h("div",{className:"sg-migration",role:"status"},h("span",{className:"sg-processing-icon"},"\u21BB"),h("span",null,"\u6B63\u5728\u5347\u7EA7\u957F\u671F\u8BB0\u5FC6 \xB7 "+migration.projected+" / "+migration.total+" Events"),h("small",null,migration.failed?migration.failed+" \u6279\u5F85\u91CD\u8BD5":"\u540E\u53F0\u589E\u91CF\u5904\u7406\uFF0C\u4E0D\u5F71\u54CD\u5176\u4ED6\u529F\u80FD")),h("div",{className:"sg-long-toolbar"},h(SearchBox,{value:query,onChange:setQuery}),h("button",{type:"button",className:"sg-toolbar-button","aria-expanded":filtersOpen?"true":"false",onClick:()=>setFiltersOpen(!filtersOpen)},"\u7B5B\u9009 \u25BE",activeFilterCount?h("span",{className:"sg-active-filter-count"},activeFilterCount):null),h("span",{className:"sg-toolbar-count"},mode==="graph"?visibleNodes.length+" \u4E2A\u8282\u70B9 \xB7 "+edges3.filter(edge=>edge.status==="active").length+" \u6761\u5173\u7CFB":events.length+" \u6761\u4E8B\u4EF6 \xB7 "+project),h("button",{type:"button",className:"sg-toolbar-button",onClick:fullScreen?()=>{setFullScreen(!1),setFiltersOpen(!1)}:openExplorer},fullScreen?"\u9000\u51FA\u5168\u5C4F":"\u26F6 \u5168\u5C4F\u67E5\u770B"+(mode==="graph"?"\u56FE\u8C31":"\u65F6\u95F4\u7EBF"))),filtersOpen?filterControls:null,mode==="graph"?h("div",{className:"sg-long-layout "+(fullScreen?"":"sg-summary-layout")},h(GraphCanvas,{nodes:visibleNodes,edges:edges3,clusters,importance:nodeImportance,selectedId:selectedNodeId,onSelect:setSelectedNodeId,showSummary:!fullScreen,onViewDetails:openExplorer}),fullScreen?h(NodeDetailPanel,{node:nodes3.find(node=>node.id===selectedNodeId),nodes:nodes3,edges:edges3,events,onEvent:selectEvent}):null):h("div",{className:"sg-long-layout "+(fullScreen?"sg-timeline-layout":"sg-summary-layout")},h(TimelineList,{events,nodes:nodes3,query,filters:eventFilters,onSelect:setSelectedEventId,selectedId:selectedEventId,floating:!fullScreen,onNode:selectNode,openSource:openEvent}),fullScreen?h(EventDetailPanel,{event:events.find(event3=>event3.id===selectedEventId),nodes:nodes3,events,onNode:selectNode,openSource:openEvent}):null))}function previewText(value){let text=String(value||"").replace(/\s+/g," ").trim()||"\u6682\u65E0\u5185\u5BB9";return text.length>200?text.slice(0,200)+"\u2026":text}function turnRangeText(range){return!Array.isArray(range)||range.length<2||range[1]<range[0]?"\u7B49\u5F85\u65B0\u5BF9\u8BDD":"Turn "+range[0]+"\u2013"+range[1]}function LayerPreview({layer,currentLevel,expanding,menuOpen,allowExpand,onMenuToggle,onExpand}){let itemRef=React.useRef(null),hideTimer=React.useRef(null),popoverRef=React.useRef(null),level=Number(layer.level),actionable=allowExpand&&level>currentLevel,cancelHide=()=>{hideTimer.current&&window.clearTimeout(hideTimer.current),hideTimer.current=null},removePopover=()=>{popoverRef.current?.remove(),popoverRef.current=null},showPopover=()=>{cancelHide();let rect=itemRef.current?.getBoundingClientRect();if(!rect)return;let width2=Math.min(390,Math.max(240,window.innerWidth-24)),maxHeight=Math.min(520,window.innerHeight*.7),right=rect.right+12,left=right+width2<=window.innerWidth-12?right:Math.max(12,rect.left-width2-12),top=Math.min(Math.max(12,rect.top-8),Math.max(12,window.innerHeight-maxHeight-12));if(!popoverRef.current){let popover=document.createElement("aside"),title=document.createElement("strong"),content=document.createElement("p"),theme=window.getComputedStyle(itemRef.current),pageTheme=window.getComputedStyle(itemRef.current.closest(".sg-memory"));popover.className="sg-layer-popover",popover.setAttribute("role","tooltip"),popover.style.background=pageTheme.backgroundColor,popover.style.color=pageTheme.color,popover.style.borderColor=theme.borderColor,title.textContent="L"+level+" \u5B8C\u6574\u5185\u5BB9",content.className="sg-layer-full",content.textContent=String(layer.content||"\u6682\u65E0\u5185\u5BB9"),popover.append(title,content),popover.addEventListener("mouseenter",cancelHide),popover.addEventListener("mouseleave",scheduleHide),document.body.appendChild(popover),popoverRef.current=popover}popoverRef.current.style.left=left+"px",popoverRef.current.style.top=top+"px"},scheduleHide=()=>{cancelHide(),hideTimer.current=window.setTimeout(removePopover,140)};return React.useEffect(()=>()=>{cancelHide(),removePopover()},[]),h("div",{className:"sg-layer-hover"},h("div",{ref:itemRef,className:"sg-layer-item "+(level===currentLevel?"current":""),"data-level":String(level),tabIndex:0,onMouseEnter:showPopover,onMouseLeave:scheduleHide,onFocus:showPopover,onBlur:scheduleHide},h("span",{className:"sg-layer-label"},"L"+level),h("span",{className:"sg-layer-preview"},previewText(layer.content)),actionable?h("button",{className:"sg-layer-more",type:"button","aria-label":"L"+level+" \u64CD\u4F5C","aria-expanded":menuOpen?"true":"false",onClick:event3=>{event3.stopPropagation(),onMenuToggle(level)}},"\xB7\xB7\xB7"):h("span",{className:"sg-layer-more-placeholder","aria-hidden":"true"}),menuOpen?h("div",{className:"sg-layer-menu"},h("button",{type:"button",disabled:expanding,onClick:event3=>{event3.stopPropagation(),onMenuToggle(null),onExpand(level)}},expanding?"\u6B63\u5728\u5C55\u5F00\u2026":"\u5C55\u5F00\u5230\u8FD9\u4E00\u5C42")):null))}function BlockLayerPanel({block,detail,loading,expandingLevel,onExpand}){let[openMenuLevel,setOpenMenuLevel]=React.useState(null);if(React.useEffect(()=>{let closeMenu=event3=>{if(event3.key==="Escape"){setOpenMenuLevel(null);return}event3.target?.closest?.(".sg-layer-more, .sg-layer-menu")||setOpenMenuLevel(null)};return document.addEventListener("pointerdown",closeMenu),document.addEventListener("keydown",closeMenu),()=>{document.removeEventListener("pointerdown",closeMenu),document.removeEventListener("keydown",closeMenu)}},[]),loading)return h("div",{className:"sg-layer-panel"},h(Loading));let layers=Array.isArray(detail?.layers)?detail.layers:[];return h("div",{className:"sg-layer-panel"},h("div",{className:"sg-layer-heading"},h("strong",null,"\u5206\u5C42\u5185\u5BB9\u9884\u89C8"),h("span",null,"\u5F53\u524D\u5C42\u7EA7\uFF1AL"+block.currentLevel+" \xB7 \u60AC\u505C\u53EF\u67E5\u770B\u5B8C\u6574\u5185\u5BB9")),block.virtual?h("div",{className:"sg-virtual-note"},"\u65E7\u4F1A\u8BDD\u5C55\u793A\u7247\u6BB5\u4E3A\u53EA\u8BFB\u5185\u5BB9\uFF0C\u4E0D\u4F1A\u6539\u5199\u539F\u59CB\u6570\u636E\u5E93\u3002"):null,layers.length?h("div",{className:"sg-layer-stack"},layers.slice().sort((a,b)=>a.level-b.level).map(layer=>h(LayerPreview,{key:layer.level,layer,currentLevel:block.currentLevel,expanding:expandingLevel===layer.level,menuOpen:openMenuLevel===layer.level,allowExpand:!block.virtual,onMenuToggle:level=>setOpenMenuLevel(current=>current===level?null:level),onExpand}))):h("div",{className:"sg-muted"},"\u6682\u65F6\u65E0\u6CD5\u8BFB\u53D6\u8BE5 Block \u7684\u5206\u5C42\u5185\u5BB9\u3002"))}function expansionLabel(source){return source==="user"?"\u7528\u6237\u5C55\u5F00":source==="agent"?"Agent \u5C55\u5F00":source==="legacy"?"\u66FE\u5C55\u5F00":""}function ShortTermPage({blocks,openBlock,conversations,activeThreadId,namespace,onConversationChange,refresh}){let visible=[...blocks].sort((a,b)=>Number(a.sequence||0)-Number(b.sequence||0)||String(a.createdAt).localeCompare(String(b.createdAt))),distributionRef=React.useRef(null),[rail,setRail]=React.useState({value:0,max:0}),[expandedId,setExpandedId]=React.useState(""),[details,setDetails]=React.useState({}),[loadingId,setLoadingId]=React.useState(""),[expanding,setExpanding]=React.useState({blockId:"",level:-1}),[inlineError,setInlineError]=React.useState(""),currentOpen=openBlock||{turnRange:null,messages:0,status:"open"};React.useEffect(()=>{let node=distributionRef.current;if(!node)return;let updateRail=()=>{let max5=Math.max(0,node.scrollWidth-node.clientWidth);setRail({value:Math.min(max5,Math.round(node.scrollLeft)),max:max5})};node.scrollLeft=node.scrollWidth,updateRail();let observer=typeof ResizeObserver=="function"?new ResizeObserver(updateRail):null;return observer?.observe(node),()=>observer?.disconnect()},[visible.length,activeThreadId]);let toggleBlock=block=>{if(expandedId===block.id){setExpandedId("");return}setExpandedId(block.id),setInlineError(""),!details[block.id]&&(setLoadingId(block.id),api2("sources",{namespace,blockId:block.id}).then(value=>setDetails(current=>({...current,[block.id]:value}))).catch(reason=>setInlineError(String(reason.message||reason))).finally(()=>setLoadingId("")))},expandTo=(block,level)=>(setInlineError(""),setExpanding({blockId:block.id,level}),api2("blocks/expand",{namespace,blockId:block.id,level:"L"+level},{method:"PATCH"}).then(()=>refresh()).catch(reason=>setInlineError(String(reason.message||reason))).finally(()=>setExpanding({blockId:"",level:-1})));return h(React.Fragment,null,h("section",{className:"sg-decay-overview","aria-labelledby":"sg-decay-title"},h("div",{className:"sg-decay-head"},h("h2",{className:"sg-decay-title",id:"sg-decay-title"},"\u5757\u8870\u51CF\u603B\u89C8"),h("label",{className:"sg-conversation"},h("span",null,"\u5F53\u524D\u5BF9\u8BDD\uFF1A"),h("select",{value:activeThreadId||"",disabled:!conversations.length,onChange:event3=>onConversationChange(event3.target.value),"aria-label":"\u5F53\u524D\u5BF9\u8BDD"},conversations.map(conversation=>h("option",{key:conversation.id,value:conversation.id},conversation.label))))),h("p",{className:"sg-decay-copy"},"L0 \u5C42\u6700\u6D45\u6700\u7B80\u7565\uFF0CL5 \u5C42\u6700\u6DF1\u6700\u8BE6\u7EC6\uFF0C\u79BB\u5F53\u524D\u5BF9\u8BDD\u8D8A\u8FDC\uFF0CBlock \u4F1A\u9010\u6E10\u7B80\u7565\u3002"),h("div",{ref:distributionRef,className:"sg-distribution","aria-label":"Block \u5F53\u524D\u5C42\u7EA7\u5206\u5E03",onScroll:event3=>{let node=event3.currentTarget;setRail({value:Math.round(node.scrollLeft),max:Math.max(0,node.scrollWidth-node.clientWidth)})},onWheel:event3=>{rail.max<=0||(event3.preventDefault(),event3.currentTarget.scrollLeft+=event3.deltaY+event3.deltaX)}},visible.map(block=>h("span",{key:block.id,className:"sg-level-chip","data-level":String(block.currentLevel),title:"Block #"+block.sequence},"L"+block.currentLevel)),h("span",{className:"sg-level-chip sg-open-chip"},"\u5F00\u653E\u5757 \xB7 \u672A\u5C01\u5B58")),h("input",{className:"sg-distribution-rail",type:"range",min:"0",max:String(Math.max(1,rail.max)),step:"1",value:String(Math.min(rail.value,Math.max(1,rail.max))),disabled:rail.max<=0,onChange:event3=>{let value=Number(event3.target.value);distributionRef.current&&(distributionRef.current.scrollLeft=value),setRail(current=>({...current,value}))},"aria-label":"Block \u5206\u5E03\u6ED1\u8F68"}),h("div",{className:"sg-time-direction","aria-hidden":"true"},h("span",null,"\u66F4\u65E7"),h("span",{className:"sg-time-line"}),h("span",null,"\u66F4\u65B0 \u2192")),h("div",{className:"sg-overview-meta"},h("span",null,"\u5DF2\u5C01\u5B58\u5757\uFF1A"+visible.length),h("span",null,"\u5F00\u653E\u5757\uFF1A"+turnRangeText(currentOpen.turnRange)+"\uFF08\u672A\u5C01\u5B58\uFF09"))),h("section",{className:"sg-block-list","aria-label":"Block \u5217\u8868"},h("div",{className:"sg-block-header","aria-hidden":"true"},h("span",null,"\u5F53\u524D\u5C42\u7EA7"),h("span",null,"Block"),h("span",null,"\u8986\u76D6 Turn"),h("span",null,"\u8DDD\u6700\u65B0\u5C01\u5B58\u5757"),h("span")),inlineError?h("div",{className:"sg-inline-error"},"\u64CD\u4F5C\u672A\u5B8C\u6210\uFF1A"+inlineError):null,visible.map(block=>h("div",{key:block.id,className:"sg-block-unit"},h("button",{className:"sg-block-toggle",type:"button",onClick:()=>toggleBlock(block),"aria-expanded":expandedId===block.id?"true":"false"},h("span",{className:"sg-level-cell"},h("span",{className:"sg-level-badge","data-level":String(block.currentLevel)},"L"+block.currentLevel),expansionLabel(block.expansionSource)?h("span",{className:"sg-lifted"},expansionLabel(block.expansionSource)):null),h("span",{className:"sg-block-name"},(block.virtual?"\u65E7 Block #":"Block #")+block.sequence),h("span",{className:"sg-block-turn"},turnRangeText(block.turnRange)),h("span",{className:"sg-block-distance"},block.distanceFromLatest===0?"0\uFF08\u6700\u65B0\uFF09":block.distanceFromLatest+" \u4E2A Block"),h("span",{className:"sg-row-chevron","aria-hidden":"true"},expandedId===block.id?"\u2303":"\u203A")),expandedId===block.id?h("div",{className:"sg-block-expanded"},h(BlockLayerPanel,{block,detail:details[block.id],loading:loadingId===block.id,expandingLevel:expanding.blockId===block.id?expanding.level:-1,onExpand:level=>expandTo(block,level)})):null)),h("div",{className:"sg-block-unit"},h("div",{className:"sg-block-toggle sg-open-row"},h("span",{className:"sg-level-cell"},h("span",{className:"sg-open-badge"},"\u5F00\u653E\u5757")),h("span",{className:"sg-block-name"},"\u672A\u5C01\u5B58"),h("span",{className:"sg-block-turn"},turnRangeText(currentOpen.turnRange)),h("span",{className:"sg-block-distance"},"\u2014"),h("span")))))}function SourceDetails({item,source,kind}){let messages=source?.messages||[];return h("div",{className:"sg-detail-section"},h("h3",{className:"sg-section-title"},"\u6765\u6E90"),h("div",{className:"sg-source-label"},h("span",{className:"sg-source-icon","aria-hidden":"true"},"\u25A3"),h("span",null,"\u5F53\u524D DeepSeek \u5BF9\u8BDD")),h("details",{className:"sg-tech"},h("summary",null,"\u6280\u672F\u8BE6\u60C5"),h("div",{className:"sg-tech-body"},h("div",{className:"sg-tech-row"},h("span",{className:"sg-muted"},kind==="block"?"Block ID":"Event ID"),h("span",{className:"sg-code"},item.id)),kind==="block"&&item.turnRange?h("div",{className:"sg-tech-row"},h("span",{className:"sg-muted"},"Turn"),h("span",null,item.turnRange.join(" - "))):null,messages.length?messages.map(message=>h("div",{key:message.id,className:"sg-raw-message"},h("div",{className:"sg-muted"},String(message.role||"")+" \xB7 "+formatTime(message.createdAt)),h("div",{className:"sg-code"},String(message.content||"")))):h("div",{className:"sg-muted"},"\u5F53\u524D\u6570\u636E\u4E2D\u6CA1\u6709\u53EF\u663E\u793A\u7684\u6765\u6E90\u6D88\u606F\u3002"))))}function EventDetail({event:event3,project,source,onBack,backLabel}){return h(React.Fragment,null,h(BackBar,{label:backLabel,onBack}),h("header",{className:"sg-detail-header"},h("h2",{className:"sg-detail-title"},event3.title||"\u8BB0\u5FC6\u8BE6\u60C5"),event3.summary?h("p",{className:"sg-detail-subtitle"},event3.summary):null,h("div",{className:"sg-meta"},h("span",null,formatTime(event3.updatedAt||event3.createdAt)),h("span",{className:"sg-meta-sep"},project))),event3.narrative?h("div",{className:"sg-detail-section"},h("h3",{className:"sg-section-title"},"AI \u5BF9\u8FD9\u6BB5\u7ECF\u5386\u7684\u7406\u89E3"),h("p",{className:"sg-prose"},event3.narrative)):null,h("div",{className:"sg-detail-section"},h("h3",{className:"sg-section-title"},"\u53C2\u4E0E\u5B9E\u4F53"),(event3.temporal?.participants||[]).length?h("div",{className:"sg-tags"},event3.temporal.participants.map(name=>h("span",{key:name,className:"sg-tag"},name))):h("span",{className:"sg-muted"},"\u672A\u8BB0\u5F55")),h(SourceDetails,{item:event3,source,kind:"event"}))}function ElementDetail({element:element3,events,source,openEvent,onBack,backLabel}){let facts=[];element3.currentState&&facts.push(element3.currentState);for(let fact of element3.facts||[]){let value=Array.isArray(fact.value)?fact.value.join("\u3001"):fact.value;value&&!facts.includes(String(value))&&facts.push(String(value))}let related=events.filter(event3=>(element3.sourceEventIds||[]).includes(event3.id)).sort((a,b)=>String(b.updatedAt).localeCompare(String(a.updatedAt)));return h(React.Fragment,null,h(BackBar,{label:backLabel,onBack}),h("header",{className:"sg-detail-header"},h("h2",{className:"sg-detail-title"},element3.name||"\u76F8\u5173\u4E8B\u7269"),h("p",{className:"sg-detail-subtitle"},"AI \u5173\u4E8E\u5B83\u76EE\u524D\u77E5\u9053\u8FD9\u4E9B"),h("div",{className:"sg-meta"},h("span",null,"\u76F8\u5173\u7ECF\u5386 "+related.length+" \u6761"),h("span",{className:"sg-meta-sep"},"\u6700\u8FD1\u66F4\u65B0 "+formatTime(element3.updatedAt)))),h("div",{className:"sg-detail-section"},facts.length?h("ul",{className:"sg-facts"},facts.map((fact,index)=>h("li",{key:index},fact))):h("div",{className:"sg-muted"},"\u6682\u65F6\u6CA1\u6709\u5F62\u6210\u53EF\u5C55\u793A\u7684\u8BA4\u8BC6\u3002")),h("div",{className:"sg-detail-section"},h("h3",{className:"sg-section-title"},"\u76F8\u5173\u7ECF\u5386"),related.length?h("div",{className:"sg-related-list"},related.map(event3=>h("button",{key:event3.id,className:"sg-related",onClick:()=>openEvent(event3)},h("span",{className:"sg-related-name"},event3.title),h("span",{className:"sg-related-time"},formatTime(event3.updatedAt||event3.createdAt))))):h("div",{className:"sg-muted"},"\u6CA1\u6709\u5173\u8054\u7ECF\u5386\u3002")),h(SourceDetails,{item:element3,source,kind:"element"}))}function ProcessingStatus({overview,blocks,onBack,refresh}){let failures=overview.failedJobDetails||[],failedBlocks=blocks.filter(block=>block.status==="failed"),first2=failures[0];return h(React.Fragment,null,h(BackBar,{label:"\u8FD4\u56DE",onBack}),h("div",{className:"sg-intro"},h("h2",null,"\u5904\u7406\u72B6\u6001"),h("p",null,failures.length+" \u4E2A\u4EFB\u52A1\u9700\u8981\u7EE7\u7EED\u5904\u7406")),h("div",{className:"sg-safe-note"},"\u539F\u59CB\u8BB0\u5FC6\u5DF2\u4FDD\u5B58\uFF0C\u4E0D\u4F1A\u4E22\u5931\u3002"),h("div",{className:"sg-detail-section"},h("div",{className:"sg-pipeline"},h("div",{className:"sg-stage"},h("span",null,"\u8BB0\u5FC6\u4FDD\u5B58"),h("span",{className:"sg-stage-value done"},"\u2713 \u5DF2\u5B8C\u6210")),h("div",{className:"sg-stage"},h("span",null,"\u4E8B\u4EF6\u63D0\u53D6"),h("span",{className:"sg-stage-value "+(first2?.kind==="event-extraction"?"failed":"done")},first2?.kind==="event-extraction"?"\xD7 \u5931\u8D25":"\u2713 \u5DF2\u5B8C\u6210")),h("div",{className:"sg-stage"},h("span",null,"\u56FE\u8C31\u6295\u5F71"),h("span",{className:"sg-stage-value "+(first2?.kind==="graph-projection"?"failed":first2?.kind==="event-extraction"?"waiting":"done")},first2?.kind==="graph-projection"?"\xD7 \u5931\u8D25":first2?.kind==="event-extraction"?"\u2014 \u7B49\u5F85":"\u2713 \u5DF2\u5B8C\u6210")))),failedBlocks.length?h("div",{className:"sg-detail-section"},h("h3",{className:"sg-section-title"},"\u53D7\u5F71\u54CD\u7684\u77ED\u671F\u8BB0\u5FC6"),failedBlocks.map(block=>h("div",{key:block.id,className:"sg-result-event"},block.title||block.summary||"\u77ED\u671F\u8BB0\u5FC6"))):null,h("button",{className:"sg-alert",onClick:refresh,style:{marginTop:"16px"}},h("span",{className:"sg-alert-mark"},"\u21BB"),h("span",null,h("span",{className:"sg-alert-title"},"\u91CD\u65B0\u68C0\u67E5\u72B6\u6001"),h("br"),h("span",{className:"sg-alert-copy"},"\u4EFB\u52A1\u4F1A\u6CBF\u7528\u73B0\u6709\u91CD\u8BD5\u673A\u5236\u7EE7\u7EED\u5904\u7406\u3002")),h("span",{className:"sg-chevron"},"\u203A")),h("details",{className:"sg-tech"},h("summary",null,"\u6280\u672F\u9519\u8BEF\u8BE6\u60C5"),h("pre",{className:"sg-tech-body sg-code"},first2?.lastErrorFull||first2?.lastError||"\u6CA1\u6709\u8BB0\u5F55\u6280\u672F\u9519\u8BEF\u3002")))}function ImportPage({namespace,onBack,refresh}){let[text,setText]=React.useState(""),[prompt,setPrompt]=React.useState(""),[promptLoading,setPromptLoading]=React.useState(!0),[copied,setCopied]=React.useState(!1),[busy,setBusy]=React.useState(!1),[job,setJob]=React.useState(null),[choices,setChoices]=React.useState({}),[result,setResult]=React.useState(null),[error3,setError]=React.useState(""),[connectionError,setConnectionError]=React.useState("");React.useEffect(()=>{let active=!0,restoreTimer;api2("import").then(value=>{active&&setPrompt(String(value.prompt||""))}).catch(reason=>{active&&setError(String(reason?.message||reason))}).finally(()=>{active&&setPromptLoading(!1)});let restore=()=>api2("import",{operation:"status",namespace}).then(value=>{active&&(setConnectionError(""),value?.jobId&&value.status!=="undone"&&(setJob(value),value.status==="committed"&&setResult(value)))}).catch(()=>{active&&(setConnectionError("\u8FDE\u63A5\u6682\u65F6\u4E2D\u65AD\uFF0C\u6B63\u5728\u81EA\u52A8\u91CD\u8BD5\u2026"),restoreTimer=window.setTimeout(restore,2500))});restore();let onKeyDown=event3=>{event3.key==="Escape"&&onBack()};return window.addEventListener("keydown",onKeyDown),()=>{active=!1,window.clearTimeout(restoreTimer),window.removeEventListener("keydown",onKeyDown)}},[]),React.useEffect(()=>{if(!job?.jobId||!["extracting","processing"].includes(job.status))return;let active=!0,timer,poll=()=>api2("import",{operation:"status",namespace,jobId:job.jobId}).then(next2=>{active&&(setConnectionError(""),setJob(next2),["extracting","processing"].includes(next2.status)&&(timer=window.setTimeout(poll,1200)))}).catch(()=>{active&&(setConnectionError("\u8FDE\u63A5\u6682\u65F6\u4E2D\u65AD\uFF0C\u6B63\u5728\u81EA\u52A8\u91CD\u8BD5\u2026"),timer=window.setTimeout(poll,2500))});return timer=window.setTimeout(poll,600),()=>{active=!1,window.clearTimeout(timer)}},[job?.jobId,job?.status,namespace]);let copyPrompt=()=>{if(!prompt)return;(navigator.clipboard?.writeText?navigator.clipboard.writeText(prompt):Promise.reject(new Error("\u5F53\u524D\u6D4F\u89C8\u5668\u4E0D\u652F\u6301\u81EA\u52A8\u590D\u5236"))).then(()=>{setCopied(!0),window.setTimeout(()=>setCopied(!1),1600)}).catch(reason=>setError(String(reason?.message||reason)))},analyze=()=>{if(!(!text.trim()||busy))return setBusy(!0),setError(""),setResult(null),setJob(null),setChoices({}),api2("import",{namespace},{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({operation:"preview",namespace,text})}).then(setJob).catch(reason=>setError(String(reason?.message||reason))).finally(()=>setBusy(!1))},commit=()=>{if(!job||busy)return;let requestedChoices=(job.decisions||[]).flatMap((decision,index)=>decision.requiresConfirmation?[{index,action:choices[index]||decision.action||"IGNORE"}]:[]);return setBusy(!0),setError(""),api2("import",{namespace},{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({operation:"commit",namespace,jobId:job.jobId,choices:requestedChoices})}).then(next2=>(setResult(next2),setJob(next2),refresh())).catch(reason=>setError(String(reason?.message||reason))).finally(()=>setBusy(!1))},retry=()=>{if(!(!job?.jobId||busy))return setBusy(!0),setError(""),api2("import",{namespace},{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({operation:"retry",namespace,jobId:job.jobId})}).then(setJob).catch(reason=>setError(String(reason?.message||reason))).finally(()=>setBusy(!1))},undo=()=>{if(!(!result?.sourceBlockId||busy))return setBusy(!0),setError(""),api2("import",{namespace},{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({operation:"undo",namespace,sourceBlockId:result.sourceBlockId})}).then(()=>(setResult(null),setJob(null),setText(""),refresh())).catch(reason=>setError(String(reason?.message||reason))).finally(()=>setBusy(!1))},reset2=()=>{setResult(null),setJob(null),setChoices({}),setText(""),setError("")},actionLabel={ADD:"\u65B0\u589E",MERGE:"\u5408\u5E76",SUPERSEDE:"\u53D6\u4EE3\u65E7\u8BB0\u5FC6",CONFLICT:"\u4FDD\u7559\u5E76\u6807\u8BB0\u51B2\u7A81",IGNORE:"\u5FFD\u7565"},running=job&&["extracting","processing"].includes(job.status),reviewable=job&&["ready","awaiting_confirmation"].includes(job.status),emptyJob=reviewable&&Number(job.totalCount||0)===0,percent=job?job.status==="extracting"?5:job.totalCount?Math.round(job.processedCount/job.totalCount*100):100:0;return h("div",{className:"sg-import-overlay",role:"presentation",onMouseDown:event3=>{event3.target===event3.currentTarget&&onBack()}},h("section",{className:"sg-import-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"sg-import-title"},h("header",{className:"sg-import-dialog-head"},h("h2",{id:"sg-import-title",className:"sg-import-dialog-title"},"\u5C06\u8BB0\u5FC6\u5BFC\u5165 StrataGate"),h("button",{type:"button",className:"sg-icon-button",onClick:onBack,"aria-label":"\u5173\u95ED"},"\xD7")),h("div",{className:"sg-import-step"},h("div",{className:"sg-import-step-head"},h("span",{className:"sg-import-step-num"},"1"),h("span",{className:"sg-import-step-title"},"\u590D\u5236\u4EE5\u4E0B\u63D0\u793A\u8BCD\u5230\u5176\u4ED6 AI \u5BF9\u8BDD\u4E2D"),h("button",{type:"button",className:"sg-import-copy",disabled:promptLoading||!prompt,onClick:copyPrompt},copied?"\u5DF2\u590D\u5236":"\u590D\u5236")),promptLoading?h("div",{className:"sg-import-loading"},"\u6B63\u5728\u52A0\u8F7D\u63D0\u793A\u8BCD\u2026"):h("div",{className:"sg-import-prompt",tabIndex:"0"},prompt||"\u63D0\u793A\u8BCD\u6682\u65F6\u65E0\u6CD5\u8BFB\u53D6\u3002")),h("div",{className:"sg-import-step"},h("div",{className:"sg-import-step-head"},h("span",{className:"sg-import-step-num"},"2"),h("span",{className:"sg-import-step-title"},"\u7C98\u8D34\u7ED3\u679C\uFF0C\u5148\u5206\u6790\u518D\u5BFC\u5165")),h("div",{className:"sg-import-card"},h("textarea",{value:text,disabled:busy||!!job||!!result,onChange:event3=>setText(event3.target.value),placeholder:"\u7C98\u8D34 JSON\uFF1B\u683C\u5F0F\u4E0D\u5408\u683C\u65F6\u4F1A\u81EA\u52A8\u5C1D\u8BD5\u6062\u590D","aria-label":"\u5916\u90E8 AI \u8BB0\u5FC6 JSON"}))),running?h("div",{className:"sg-import-step"},h("div",{className:"sg-import-step-head"},h("span",{className:"sg-import-step-num"},"3"),h("span",{className:"sg-import-step-title"},job.status==="extracting"?"\u6B63\u5728\u4FEE\u590D\u5E76\u63D0\u53D6\u5019\u9009\u8BB0\u5FC6":"\u6B63\u5728\u68C0\u6D4B\u91CD\u590D\u4E0E\u51B2\u7A81")),h("div",{role:"progressbar","aria-valuemin":"0","aria-valuemax":"100","aria-valuenow":percent,style:{height:"9px",overflow:"hidden",borderRadius:"999px",background:"var(--sg-border)"}},h("div",{style:{width:percent+"%",height:"100%",background:"var(--sg-accent)",transition:"width .25s ease"}})),h("div",{className:"sg-import-hint",style:{marginTop:"8px"}},job.status==="extracting"?"\u539F JSON \u4E0D\u5408\u683C\uFF0C\u6B63\u5728\u4F7F\u7528\u6A21\u578B\u515C\u5E95\u3002\u53EF\u4EE5\u5173\u95ED\u9875\u9762\uFF0C\u4EFB\u52A1\u4F1A\u7EE7\u7EED\u3002":"\u5DF2\u5B8C\u6210 "+job.processedCount+"/"+job.totalCount+"\uFF0C\u6B63\u5728\u5224\u65AD\u7B2C "+Math.min(job.processedCount+1,job.totalCount)+" \u6761\uFF1B\u53EF\u4EE5\u5173\u95ED\u9875\u9762\uFF0C\u7A0D\u540E\u91CD\u65B0\u6253\u5F00\u67E5\u770B\u3002")):null,reviewable?h("div",{className:"sg-import-step"},h("div",{className:"sg-import-step-head"},h("span",{className:"sg-import-step-num"},"3"),h("span",{className:"sg-import-step-title"},"\u5BFC\u5165\u9884\u89C8")),h("div",{className:"sg-import-hint"},emptyJob?"\u6CA1\u6709\u53D1\u73B0\u53EF\u5BFC\u5165\u7684\u957F\u671F\u8BB0\u5FC6\u3002":job.recoveredFromInvalidJson?"\u8FD9\u4E9B\u5019\u9009\u7531\u515C\u5E95\u6A21\u578B\u6062\u590D\uFF0C\u5168\u90E8\u9700\u8981\u4EBA\u5DE5\u786E\u8BA4\u3002":"\u9AD8\u7F6E\u4FE1\u5EA6\u7ED3\u679C\u81EA\u52A8\u91C7\u7528\uFF1B\u4F4E\u7F6E\u4FE1\u5EA6\u7ED3\u679C\u8BF7\u4EBA\u5DE5\u9009\u62E9\u5904\u7406\u65B9\u5F0F\u3002"),h("div",{className:"sg-import-preview"},(job.decisions||[]).map((decision,index)=>h("div",{key:index,className:"sg-import-preview-item"},h("div",{className:"sg-import-preview-title"},decision.candidate?.title||"\u672A\u547D\u540D\u8BB0\u5FC6"),h("div",{className:"sg-import-preview-meta"},h("span",null,actionLabel[decision.action]||decision.action),h("span",null,"\u7F6E\u4FE1\u5EA6 "+Math.round(Number(decision.confidence||0)*100)+"%"),decision.existingEventIds?.length?h("span",null,"\u5173\u8054 "+decision.existingEventIds.length+" \u6761"):null),decision.reason?h("div",{className:"sg-import-preview-reason"},decision.reason):null,decision.requiresConfirmation?h("label",{className:"sg-import-review"},h("span",null,"\u4EBA\u5DE5\u9009\u62E9"),h("select",{value:choices[index]||decision.action,onChange:event3=>setChoices(current=>({...current,[index]:event3.target.value}))},(decision.existingEventIds?.length?["ADD","MERGE","SUPERSEDE","CONFLICT","IGNORE"]:["ADD","IGNORE"]).map(action=>h("option",{key:action,value:action},actionLabel[action])))):null)))):null,job?.status==="failed"?h("div",{className:"sg-import-error"},"\u4EFB\u52A1\u5931\u8D25\uFF1A"+(job.lastError||"\u672A\u77E5\u9519\u8BEF")):null,connectionError?h("div",{className:"sg-import-hint"},connectionError):null,error3?h("div",{className:"sg-import-error"},error3):null,result?h("div",{className:"sg-import-result"},"\u5BFC\u5165\u5B8C\u6210\uFF1A\u65B0\u589E "+Number(result.importedCount||0)+" \u6761\u8BB0\u5FC6\u3002\u53EF\u7ACB\u5373\u64A4\u9500\u672C\u6279\u6B21\u3002"):null,h("footer",{className:"sg-import-dialog-foot"},result?h("button",{type:"button",className:"sg-import-cancel",disabled:busy,onClick:undo},busy?"\u6B63\u5728\u64A4\u9500\u2026":"\u64A4\u9500\u672C\u6B21\u5BFC\u5165"):h("button",{type:"button",className:"sg-import-cancel",onClick:onBack},running?"\u5173\u95ED\uFF0C\u540E\u53F0\u7EE7\u7EED":"\u53D6\u6D88"),result?h("button",{type:"button",className:"sg-import-button",disabled:busy,onClick:reset2},"\u5BFC\u5165\u53E6\u4E00\u6279"):job?.status==="failed"?h("button",{type:"button",className:"sg-import-button",disabled:busy,onClick:retry},busy?"\u6B63\u5728\u91CD\u8BD5\u2026":"\u91CD\u8BD5"):emptyJob?h("button",{type:"button",className:"sg-import-button",onClick:reset2},"\u5BFC\u5165\u53E6\u4E00\u6279"):reviewable?h("button",{type:"button",className:"sg-import-button",disabled:busy,onClick:commit},busy?"\u6B63\u5728\u5BFC\u5165\u2026":"\u786E\u8BA4\u5BFC\u5165"):running?h("button",{type:"button",className:"sg-import-button",disabled:!0},"\u540E\u53F0\u5904\u7406\u4E2D"):h("button",{type:"button",className:"sg-import-button",disabled:busy||!text.trim(),onClick:analyze},busy?"\u6B63\u5728\u521B\u5EFA\u4EFB\u52A1\u2026":"\u5206\u6790\u5E76\u9884\u89C8"))))}function MoreHome({selected,setView}){let rows=[["import","\u21C4","\u5BFC\u5165\u522B\u7684 AI \u8BB0\u5FC6","\u7C98\u8D34\u5916\u90E8 AI \u603B\u7ED3\u5E76\u5BFC\u5165"],["structure","\u25C7","\u8BB0\u5FC6\u7ED3\u6784","\u6D4F\u89C8 Event \u4E0E\u77E5\u8BC6\u56FE\u8C31"],["system","\u2713","\u7CFB\u7EDF\u72B6\u6001","\u5904\u7406\u4EFB\u52A1\u548C\u6700\u8FD1\u6574\u7406\u65F6\u95F4"],["audit","\u2197","\u4F7F\u7528\u8BB0\u5F55","\u957F\u671F\u8BB0\u5FC6\u4F55\u65F6\u88AB\u4F7F\u7528"],["raw","{}","\u539F\u59CB\u6570\u636E","Block\u3001Event\u3001Graph \u4E0E\u6A21\u578B\u54CD\u5E94"],["settings","\u2699","\u9AD8\u7EA7\u8BBE\u7F6E","Schema\u3001\u63D0\u53D6\u95F4\u9694\u4E0E\u9879\u76EE\u7A7A\u95F4"],["support","?","\u53CD\u9988\u4E0E\u652F\u6301","\u62A5\u544A\u95EE\u9898\u3001\u63D0\u51FA\u5EFA\u8BAE\u6216\u54A8\u8BE2\u4F7F\u7528\u65B9\u6CD5"]];return h(React.Fragment,null,h("div",{className:"sg-intro"},h("h2",null,"\u66F4\u591A"),h("p",null,"\u9AD8\u7EA7\u4FE1\u606F\u4E0E\u5DE5\u7A0B\u89C6\u56FE")),h("div",{className:"sg-menu"},rows.map(([id2,icon,title,subtitle])=>h("button",{key:id2,className:"sg-menu-row",onClick:()=>setView({name:id2})},h("span",{className:"sg-menu-icon","aria-hidden":"true"},icon),h("span",null,h("span",{className:"sg-menu-title"},title),h("br"),h("span",{className:"sg-menu-subtitle"},subtitle)),h("span",{className:"sg-chevron"},"\u203A")))))}function limitedJson(value,limit2=4500){let text=JSON.stringify(value,null,2).replace(/\b(?:sk|gh[opasu]|github_pat)_[A-Za-z0-9_-]{12,}\b/g,"[REDACTED_TOKEN]").replace(/\b(Bearer\s+)[A-Za-z0-9._~+/-]{12,}={0,2}\b/gi,"$1[REDACTED]").replace(/\b(api[_-]?key|token|password|secret)\s*[:=]\s*([^\s,;]+)/gi,"$1=[REDACTED]");return text.length>limit2?text.slice(0,limit2)+`
397
+ `;function api2(path,params,options2){let query=new URLSearchParams(params||{}),url="/api/stratagate/"+path+(query.size?"?"+query:""),attempt=0,request=()=>fetch(url,{cache:"no-store",...options2}).then(res=>res.json().catch(()=>({})).then(data4=>{if(!res.ok)throw new Error(data4&&data4.error||"HTTP "+res.status);return data4})).catch(reason=>{let message=String(reason?.message||reason);if((reason instanceof TypeError||message.includes("Failed to fetch"))&&!options2?.method&&attempt<2)return attempt+=1,new Promise(resolve2=>window.setTimeout(resolve2,attempt*300)).then(request);throw new Error(message+"\uFF08"+path+"\uFF09")});return request()}function dashboardApi(params,options2={}){let query=new URLSearchParams(params||{}),url="/api/stratagate/dashboard"+(query.size?"?"+query:""),attempt=0,request=()=>fetch(url,{cache:"no-cache",signal:options2.signal,headers:options2.etag?{"If-None-Match":options2.etag}:void 0}).then(async res=>{let etag=res.headers.get("etag")||options2.etag||"";if(res.status===304)return{notModified:!0,etag,data:null};let data4=await res.json().catch(()=>({}));if(!res.ok)throw new Error(data4&&data4.error||"HTTP "+res.status);return{notModified:!1,etag,data:data4}}).catch(reason=>{if(reason?.name==="AbortError")throw reason;let message=String(reason?.message||reason);if((reason instanceof TypeError||message.includes("Failed to fetch"))&&attempt<2)return attempt+=1,new Promise(resolve2=>window.setTimeout(resolve2,attempt*300)).then(request);throw new Error(message+"\uFF08dashboard\uFF09")});return request()}function pageMeta(value,fallbackLimit){return{total:Math.max(0,Number(value?.total||0)),offset:Math.max(0,Number(value?.offset||0)),limit:Math.max(1,Number(value?.limit||fallbackLimit))}}function usePagedMemory({namespace,kind,initialItems,initialPage,fallbackLimit,extraParams={}}){let key=namespace+"\0"+kind+"\0"+JSON.stringify(extraParams),[state,setState]=React.useState(()=>({items:initialItems,page:pageMeta(initialPage,fallbackLimit)})),[loading,setLoading]=React.useState(!1),[error3,setError]=React.useState("");return React.useEffect(()=>{setState({items:initialItems,page:pageMeta(initialPage,fallbackLimit)}),setError("")},[key]),React.useEffect(()=>{setState(current=>current.page.offset===0?{items:initialItems,page:pageMeta(initialPage,fallbackLimit)}:current)},[initialItems,initialPage?.total,initialPage?.limit]),{...state,loading,error:error3,loadOffset:offset=>{setLoading(!0),setError("");let path=kind==="audit"?"audit":"memories",params={namespace,offset,limit:state.page.limit,...extraParams};return kind!=="audit"&&(params.kind=kind),api2(path,params).then(result=>{setState({items:result.items||[],page:pageMeta(result,state.page.limit)})}).catch(reason=>{setError(String(reason?.message||reason))}).finally(()=>setLoading(!1))}}}function Pagination({page,loading,error:error3,onOffset}){let totalPages=Math.max(1,Math.ceil(page.total/page.limit)),currentPage=Math.min(totalPages,Math.floor(page.offset/page.limit)+1),start=page.total?page.offset+1:0,end=Math.min(page.total,page.offset+page.limit);return h("div",{className:"sg-pagination",role:"navigation","aria-label":"\u5206\u9875"},h("button",{type:"button",className:"sg-page-button",disabled:loading||page.offset<=0,onClick:()=>onOffset(Math.max(0,page.offset-page.limit))},"\u4E0A\u4E00\u9875"),h("span",null,loading?"\u52A0\u8F7D\u4E2D\u2026":"\u7B2C "+currentPage+" / "+totalPages+" \u9875 \xB7 \u663E\u793A "+start+"\u2013"+end+" / \u5171 "+page.total+" \u6761"),h("button",{type:"button",className:"sg-page-button",disabled:loading||page.offset+page.limit>=page.total,onClick:()=>onOffset(page.offset+page.limit)},"\u4E0B\u4E00\u9875"),error3?h("span",{className:"sg-page-error"},"\u52A0\u8F7D\u5931\u8D25\uFF1A"+error3):null)}function projectName(item,workspaceTitles={}){let value=String(item?.namespace||item||"");if(value.includes(":project:")){let key=value.split(":project:").pop();return key&&workspaceTitles[key]?workspaceTitles[key]:item?.workspaceName&&item.workspaceName!=="\u5F53\u524D\u5DE5\u4F5C\u533A"?item.workspaceName:"\u5DE5\u4F5C\u533A\u540D\u79F0\u8BFB\u53D6\u4E2D\u2026"}return item?.workspaceName?item.workspaceName:value.includes(":global:")?value.split(":global:").pop()||"\u5168\u5C40\u8BB0\u5FC6":value.includes(":session:")?"\u5F53\u524D\u5BF9\u8BDD":value||"\u5F53\u524D\u5DE5\u4F5C\u533A"}function workspaceProjectKey(path){let canonical=String(path||"").replaceAll("\\","/").toLowerCase();return!canonical||!globalThis.crypto?.subtle?Promise.resolve(""):globalThis.crypto.subtle.digest("SHA-256",new TextEncoder().encode(canonical)).then(digest=>Array.from(new Uint8Array(digest).slice(0,10),byte=>byte.toString(16).padStart(2,"0")).join(""))}function formatTime(value){if(!value)return"\u65F6\u95F4\u672A\u77E5";let date=new Date(value);if(Number.isNaN(date.getTime()))return String(value);let seconds=Math.round((Date.now()-date.getTime())/1e3);if(seconds>=0&&seconds<60)return"\u521A\u521A";if(seconds>=60&&seconds<3600)return Math.floor(seconds/60)+" \u5206\u949F\u524D";let timeZone="Asia/Shanghai",dayKey=input=>new Intl.DateTimeFormat("en-CA",{timeZone,year:"numeric",month:"2-digit",day:"2-digit"}).format(input),clock=input=>new Intl.DateTimeFormat("zh-CN",{timeZone,hour:"2-digit",minute:"2-digit",hour12:!1}).format(input),now=new Date;if(dayKey(date)===dayKey(now))return"\u4ECA\u5929 "+clock(date);let yesterday=new Date(now.getTime()-1440*60*1e3);return dayKey(date)===dayKey(yesterday)?"\u6628\u5929 "+clock(date):new Intl.DateTimeFormat("zh-CN",{timeZone,month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).format(date)}function statusText(status){return status==="organized"?"\u5DF2\u6574\u7406":status==="failed"?"\u6574\u7406\u5931\u8D25":status==="waiting"?"\u7B49\u5F85\u6574\u7406":"\u6574\u7406\u4E2D"}function Loading(){return h("div",{className:"sg-loading",role:"status"},h("div",{className:"sg-skeleton"}),h("div",{className:"sg-skeleton"}),h("div",{className:"sg-skeleton"}))}function Empty({title,copy:copy3}){return h("div",{className:"sg-empty"},h("strong",null,title),h("span",null,copy3))}function BackBar({label,onBack}){return h("div",{className:"sg-backbar"},h("button",{className:"sg-back",onClick:onBack,title:"\u8FD4\u56DE"},h("span",{"aria-hidden":"true"},"\u2190"),label))}function FailureAlert({count,onOpen}){return count?h("button",{className:"sg-alert",onClick:onOpen},h("span",{className:"sg-alert-mark","aria-hidden":"true"},"\u26A0"),h("span",null,h("span",{className:"sg-alert-title"},count+" \u6761\u77ED\u671F\u8BB0\u5FC6\u5C1A\u672A\u6574\u7406\u5B8C\u6210"),h("br"),h("span",{className:"sg-alert-copy"},"\u539F\u59CB\u5185\u5BB9\u5DF2\u7ECF\u4FDD\u5B58\uFF0C\u4E0D\u4F1A\u4E22\u5931\u3002")),h("span",{className:"sg-chevron","aria-hidden":"true"},"\u203A")):null}function ProcessingAlert({visible}){return visible?h("div",{className:"sg-processing-alert",role:"status","aria-live":"polite"},h("span",{className:"sg-processing-icon","aria-hidden":"true"},"\u21BB"),h("span",null,h("span",{className:"sg-processing-title"},"\u6B63\u5728\u89E6\u53D1\u8BB0\u5FC6\u6574\u7406"),h("span",{className:"sg-processing-copy"},"Block\u3001Event \u548C\u77E5\u8BC6\u56FE\u8C31\u6B63\u5728\u751F\u6210\uFF0C\u8BF7\u7A0D\u5019\u3002"))):null}function SearchBox({value,onChange}){return h("div",{className:"sg-search"},h("span",{className:"sg-search-mark","aria-hidden":"true"},"\u2315"),h("input",{value,onChange:event3=>onChange(event3.target.value),placeholder:"\u641C\u7D22\u8BB0\u5FC6\u3001\u4EBA\u7269\u3001\u9879\u76EE\u3001\u6982\u5FF5\u2026","aria-label":"\u641C\u7D22\u957F\u671F\u8BB0\u5FC6"}))}let NODE_META={person:["\u4EBA\u7269","#8b6ccf","\u2659"],project:["\u9879\u76EE","#6f55ae","\u25A3"],organization:["\u7EC4\u7EC7","#3978cf","\u2318"],tool:["\u5DE5\u5177","#3b854d","\u25A4"],place:["\u5730\u70B9","#a9632b","\u2302"]},EVENT_TYPE_TEXT={decision:"\u51B3\u7B56",release:"\u53D1\u5E03",task_completed:"\u4EFB\u52A1\u5B8C\u6210",plan:"\u8BA1\u5212",change:"\u53D8\u66F4",cancellation:"\u53D6\u6D88",incident:"\u4E8B\u4EF6",meeting:"\u4F1A\u8BAE",collaboration:"\u534F\u4F5C",migration:"\u8FC1\u79FB",other:"\u5176\u4ED6"},EVENT_STATUS_TEXT={occurred:"\u5DF2\u53D1\u751F",planned:"\u8BA1\u5212\u4E2D",cancelled:"\u5DF2\u53D6\u6D88",ongoing:"\u8FDB\u884C\u4E2D",unknown:"\u672A\u77E5"},EVENT_RELATIONS=[["supersedesEventIds","\u53D6\u4EE3"],["conflictsWithEventIds","\u51B2\u7A81"],["sameEventId","\u540C\u4E00\u4E8B\u4EF6"],["beforeEventIds","\u4E4B\u524D"],["afterEventIds","\u4E4B\u540E"],["relatedEventIds","\u76F8\u5173"]];function exactTime(value){if(!value)return"\u672A\u77E5";let date=new Date(value);return Number.isNaN(date.getTime())?String(value):new Intl.DateTimeFormat("zh-CN",{timeZone:"Asia/Shanghai",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hour12:!1}).format(date)}function eventOccurrence(event3){let happened=event3.temporal?.happenedStart||event3.temporal?.happenedEnd;return{value:happened||event3.temporal?.mentionedAt||event3.createdAt,known:!!happened}}function NodePill({node,onClick}){let meta3=NODE_META[node.type]||["\u5B9E\u4F53","#64748b","\u2022"];return h("button",{className:"sg-entity-pill",onClick},h("span",{style:{color:meta3[1]}},meta3[2]),node.name)}function NodeSummaryBubble({node,x:x2,y:y2,width:width2,height:height2=560,onViewDetails}){if(!node)return null;let facts=(node.facts||[]).filter(fact=>fact.status==="active").slice(0,5),eventCount=new Set(node.sourceEventIds||[]).size;return h("aside",{className:"sg-node-bubble "+(x2>width2*.62?"flip":""),style:{left:x2/width2*100+"%",top:y2/height2*100+"%"}},h("div",{className:"sg-node-bubble-head"},h("h3",null,node.name),h("span",{className:"sg-status-dot"},"\u25CF "+(node.status==="active"?"\u6D3B\u8DC3":node.status||"\u672A\u77E5"))),(node.tags||[]).length?h("div",{className:"sg-node-tags"},node.tags.slice(0,4).map(tag=>h("span",{key:tag,className:"sg-node-tag"},tag))):null,h("p",{className:"sg-node-bubble-state"},node.currentState||"\u6682\u65E0\u5F53\u524D\u72B6\u6001"),facts.length?h("ul",null,facts.map(fact=>h("li",{key:fact.id},h("strong",null,fact.key+"\uFF1A"),Array.isArray(fact.value)?fact.value.join("\u3001"):fact.value))):h("p",{className:"sg-node-bubble-state"},"\u6682\u65E0\u5173\u952E\u4E8B\u5B9E"),h("div",{className:"sg-node-bubble-foot"},h("span",null,eventCount+" \u6761\u76F8\u5173\u4E8B\u4EF6"),h("button",{type:"button",onClick:onViewDetails},"\u67E5\u770B\u8BE6\u60C5 \u2192")))}let GRAPH_NODE_RADIUS={peripheral:30,normal:38,important:46,core:54},GRAPH_IMPORTANCE_TEXT={peripheral:"\u8FB9\u7F18\u8282\u70B9",normal:"\u666E\u901A\u8282\u70B9",important:"\u91CD\u8981\u8282\u70B9",core:"\u6838\u5FC3\u8282\u70B9"};function graphNameKey(value){return String(value||"").toLocaleLowerCase().replace(/[^\p{L}\p{N}]+/gu,"")}function graphTimestamp(value){let timestamp=Date.parse(String(value||""));return Number.isFinite(timestamp)?timestamp:0}function graphNodeImportance(nodes3,edges3,project){let activeEdges=edges3.filter(edge=>edge.status==="active"),activeSupportingEvents=node=>(node.supportingEvents||[]).filter(event3=>event3.status!=="forgotten"&&event3.status!=="archived"),relationCounts=new Map(nodes3.map(node=>[node.id,0])),neighbors=new Map(nodes3.map(node=>[node.id,new Set]));for(let edge of activeEdges)relationCounts.set(edge.fromNodeId,(relationCounts.get(edge.fromNodeId)||0)+1),relationCounts.set(edge.toNodeId,(relationCounts.get(edge.toNodeId)||0)+1),neighbors.get(edge.fromNodeId)?.add(edge.toNodeId),neighbors.get(edge.toNodeId)?.add(edge.fromNodeId);let projectKey=graphNameKey(project),directWorkspaceNodes=new Set(nodes3.filter(node=>projectKey&&[node.name,...node.aliases||[]].some(name=>{let key=graphNameKey(name);return key===projectKey||key.length>=5&&projectKey.length>=5&&(key.includes(projectKey)||projectKey.includes(key))})).map(node=>node.id)),workspaceAffinity=new Map(nodes3.map(node=>[node.id,directWorkspaceNodes.has(node.id)?1:0]));for(let nodeId of directWorkspaceNodes)for(let neighborId of neighbors.get(nodeId)||[]){workspaceAffinity.set(neighborId,Math.max(workspaceAffinity.get(neighborId)||0,.55));for(let secondHopId of neighbors.get(neighborId)||[])workspaceAffinity.set(secondHopId,Math.max(workspaceAffinity.get(secondHopId)||0,.25))}let supportCounts=new Map(nodes3.map(node=>{let supportingEvents=activeSupportingEvents(node);return[node.id,supportingEvents.length?new Set(supportingEvents.map(event3=>event3.id)).size:new Set(node.sourceEventIds||[]).size]})),maxSupport=Math.max(1,...supportCounts.values()),maxRelations=Math.max(1,...relationCounts.values()),latestActivity=0;for(let node of nodes3){latestActivity=Math.max(latestActivity,graphTimestamp(node.updatedAt));for(let event3 of activeSupportingEvents(node))latestActivity=Math.max(latestActivity,graphTimestamp(event3.updatedAt||event3.createdAt))}for(let edge of activeEdges)latestActivity=Math.max(latestActivity,graphTimestamp(edge.updatedAt));let halfLife=2160*60*60*1e3,recency=timestamp=>timestamp&&latestActivity?Math.exp(-Math.max(0,latestActivity-timestamp)/halfLife):0,scored=nodes3.map(node=>{let sustainedMentions=activeSupportingEvents(node).map(event3=>recency(graphTimestamp(event3.updatedAt||event3.createdAt))).sort((left,right)=>right-left).slice(0,3),recentScore=.25*recency(graphTimestamp(node.updatedAt))+.75*sustainedMentions.reduce((sum,value)=>sum+value,0)/3,supportScore=Math.log1p(supportCounts.get(node.id)||0)/Math.log1p(maxSupport),relationScore=Math.log1p(relationCounts.get(node.id)||0)/Math.log1p(maxRelations),score=.42*supportScore+.28*relationScore+.15*recentScore+.15*(workspaceAffinity.get(node.id)||0);return{id:node.id,score}}),ordered=scored.map(({score})=>score).sort((left,right)=>left-right),quantile=ratio=>ordered[Math.ceil(Math.max(0,ordered.length-1)*ratio)]||0,spread=(ordered[ordered.length-1]||0)-(ordered[0]||0),thresholds={normal:quantile(.25),important:quantile(.6),core:quantile(.85)};return new Map(scored.map(({id:id2,score})=>{let tier;return spread<.02?tier=score>=.65?"core":score>=.38?"important":"normal":score>=thresholds.core?tier="core":score>=thresholds.important?tier="important":score>=thresholds.normal?tier="normal":tier="peripheral",[id2,{score,tier,radius:GRAPH_NODE_RADIUS[tier]}]}))}function GraphCanvas({nodes:nodes3,edges:edges3,clusters,importance,selectedId,onSelect,nodeLimit=100,showSummary=!1,onViewDetails}){let containerRef=React.useRef(null),graphRef=React.useRef(null),selectedIdRef=React.useRef(selectedId);selectedIdRef.current=selectedId;let[selectedPoint,setSelectedPoint]=React.useState(null),[zoomPercent,setZoomPercent]=React.useState(100),displayedNodes=[...nodes3].sort((left,right)=>(importance.get(right.id)?.score||0)-(importance.get(left.id)?.score||0)).slice(0,nodeLimit),displayedIds=new Set(displayedNodes.map(node=>node.id)),visibleClusters=(clusters||[]).map(cluster=>({...cluster,nodeIds:(cluster.nodeIds||[]).filter(id2=>displayedIds.has(id2))})).filter(cluster=>cluster.nodeIds.length),assignedIds=new Set(visibleClusters.flatMap(cluster=>cluster.nodeIds));for(let node of displayedNodes.filter(item=>!assignedIds.has(item.id)))visibleClusters.push({id:"fallback-"+node.id,label:(node.tags||[])[0]||node.name,nodeIds:[node.id],tags:node.tags||[]});let membership=new Map(visibleClusters.flatMap(cluster=>cluster.nodeIds.map(id2=>[id2,cluster.id]))),activeEdges=edges3.filter(edge=>edge.status==="active"&&displayedIds.has(edge.fromNodeId)&&displayedIds.has(edge.toNodeId)),signature=JSON.stringify({nodes:displayedNodes.map(node=>[node.id,node.name,node.type,node.tags||[],importance.get(node.id)?.tier]),edges:activeEdges.map(edge=>[edge.id,edge.fromNodeId,edge.toNodeId,edge.relation,edge.confidence]),clusters:visibleClusters.map(cluster=>[cluster.id,cluster.label,cluster.nodeIds])});React.useEffect(()=>{let container2=containerRef.current;if(!container2||!cytoscape4||!displayedNodes.length)return;let computed=getComputedStyle(container2),textColor=computed.getPropertyValue("--sg-text").trim()||"#0f1115",mutedColor=computed.getPropertyValue("--sg-muted").trim()||"#64748b",borderColor=computed.getPropertyValue("--sg-border").trim()||"#d5d9df",pageColor=computed.getPropertyValue("--sg-page").trim()||"#ffffff",accentColor=computed.getPropertyValue("--sg-accent").trim()||"#4176e6",reduceMotion=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches===!0,parentIds=new Map(visibleClusters.map(cluster=>[cluster.id,"sg-parent-"+cluster.id])),clusterSizes=new Map(visibleClusters.map(cluster=>[cluster.id,cluster.nodeIds.length])),elements=[...visibleClusters.map(cluster=>({data:{id:parentIds.get(cluster.id),label:cluster.label+" \xB7 "+cluster.nodeIds.length},classes:"sg-community"})),...displayedNodes.map(node=>{let meta3=NODE_META[node.type]||["\u5B9E\u4F53","#64748b","\u2022"],semantic=(node.tags||[])[0]||meta3[0],visualImportance=importance.get(node.id)||{tier:"normal",radius:GRAPH_NODE_RADIUS.normal};return{data:{id:node.id,parent:parentIds.get(membership.get(node.id)),label:node.name+`
398
+ `+semantic,color:meta3[1],size:visualImportance.radius*2,tier:visualImportance.tier},classes:"sg-memory-node"}}),...activeEdges.map(edge=>{let fromCluster=membership.get(edge.fromNodeId),toCluster=membership.get(edge.toNodeId),sameCluster=fromCluster===toCluster,labeled=sameCluster&&(clusterSizes.get(fromCluster)||0)<=6;return{data:{id:"sg-edge-"+edge.id,source:edge.fromNodeId,target:edge.toNodeId,label:edge.relation},classes:"sg-memory-edge "+(sameCluster?"same-community":"cross-community")+(labeled?" labeled":"")}})],graph=cytoscape4({container:container2,elements,wheelSensitivity:.22,minZoom:.25,maxZoom:2.4,selectionType:"single",boxSelectionEnabled:!1,style:[{selector:"node.sg-community",style:{"background-color":accentColor,"background-opacity":.045,"border-color":accentColor,"border-opacity":.28,"border-width":1,"border-style":"dashed",shape:"round-rectangle",padding:"22px",label:"data(label)",color:mutedColor,"font-size":12,"font-weight":700,"text-valign":"top","text-halign":"center","text-margin-y":-9,"text-background-color":pageColor,"text-background-opacity":.82,"text-background-padding":"3px"}},{selector:"node.sg-memory-node",style:{width:"data(size)",height:"data(size)","background-color":"data(color)","background-opacity":.28,"border-color":"data(color)","border-width":1.5,label:"data(label)",color:textColor,"font-size":11,"font-weight":650,"text-wrap":"wrap","text-max-width":96,"text-valign":"center","text-halign":"center","overlay-opacity":0,"transition-property":"border-width, border-color, underlay-opacity","transition-duration":reduceMotion?"0ms":"180ms"}},{selector:"node.sg-memory-node:selected",style:{"border-width":4,"border-color":accentColor,"underlay-color":accentColor,"underlay-opacity":.16,"underlay-padding":7}},{selector:"edge.sg-memory-edge",style:{width:1.2,"line-color":mutedColor,"target-arrow-color":mutedColor,"target-arrow-shape":"triangle","curve-style":"bezier",opacity:.58,"arrow-scale":.75,label:"","overlay-opacity":0}},{selector:"edge.sg-memory-edge.labeled",style:{label:"data(label)",color:textColor,"font-size":10,"text-background-color":pageColor,"text-background-opacity":.88,"text-background-padding":"2px","text-rotation":"autorotate"}},{selector:"edge.sg-memory-edge.cross-community",style:{opacity:.24,"line-style":"dashed"}},{selector:"edge.sg-memory-edge.selected-relation",style:{opacity:.9,width:2,label:"data(label)",color:textColor,"font-size":10,"text-background-color":pageColor,"text-background-opacity":.9,"text-background-padding":"2px"}}]});graphRef.current=graph;let updatePoint=()=>{let selected=graph.getElementById(selectedIdRef.current);if(!selected.length){setSelectedPoint(null);return}let point=selected.renderedPosition();setSelectedPoint({x:point.x,y:point.y,width:container2.clientWidth||760,height:container2.clientHeight||522})};graph.on("tap","node.sg-memory-node",event3=>onSelect(event3.target.id()));let updateZoom=()=>setZoomPercent(Math.round(graph.zoom()*100));graph.on("pan zoom resize",updatePoint),graph.on("zoom",updateZoom),graph.on("layoutstop",updatePoint),graph.on("layoutstop",updateZoom);let resizeObserver=globalThis.ResizeObserver?new globalThis.ResizeObserver(()=>{graph.resize(),updatePoint()}):null;return resizeObserver?.observe(container2),graph.layout({name:"fcose",quality:"default",randomize:!0,animate:reduceMotion?!1:"end",animationDuration:reduceMotion?0:320,animationEasing:"ease-out-cubic",fit:!0,padding:48,nodeRepulsion:5200,idealEdgeLength:edge=>edge.hasClass("cross-community")?170:78,edgeElasticity:.42,nestingFactor:1.35,gravity:.28,gravityCompound:1,gravityRangeCompound:1.5,tile:!0}).run(),()=>{resizeObserver?.disconnect(),graphRef.current=null,graph.destroy()}},[signature]),React.useEffect(()=>{let graph=graphRef.current;if(!graph)return;graph.nodes(".sg-memory-node").unselect(),graph.edges().removeClass("selected-relation");let selected=graph.getElementById(selectedId);if(!selected.length){setSelectedPoint(null);return}selected.select(),selected.connectedEdges().addClass("selected-relation");let point=selected.renderedPosition(),container2=containerRef.current;setSelectedPoint({x:point.x,y:point.y,width:container2?.clientWidth||760,height:container2?.clientHeight||522})},[selectedId,signature]);let setGraphZoom=nextPercent=>{let graph=graphRef.current,container2=containerRef.current;if(!graph||!container2)return;let percent=Math.min(240,Math.max(25,Number(nextPercent)));graph.zoom({level:percent/100,renderedPosition:{x:container2.clientWidth/2,y:container2.clientHeight/2}})};if(!nodes3.length)return h(Empty,{title:"\u77E5\u8BC6\u56FE\u8C31\u6B63\u5728\u5F62\u6210",copy:"Event \u4F1A\u5728\u540E\u53F0\u5206\u6279\u6295\u5F71\u4E3A\u8282\u70B9\u4E0E\u5173\u7CFB\u3002"});if(!cytoscape4)return h(Empty,{title:"\u56FE\u8C31\u7EC4\u4EF6\u672A\u80FD\u52A0\u8F7D",copy:"\u8BF7\u91CD\u65B0\u52A0\u8F7D\u9875\u9762\u540E\u518D\u8BD5\u3002"});let selectedNode=nodes3.find(node=>node.id===selectedId);return h("div",{className:"sg-graph-canvas",role:"img","aria-label":visibleClusters.length+" \u4E2A Leiden \u4E3B\u9898\u7FA4\u7EC4\u7684\u77E5\u8BC6\u56FE\u8C31"},h("div",{ref:containerRef,className:"sg-cytoscape"}),h("div",{className:"sg-graph-zoom",role:"group","aria-label":"\u77E5\u8BC6\u56FE\u8C31\u7F29\u653E"},h("button",{type:"button",onClick:()=>setGraphZoom(zoomPercent-20),disabled:zoomPercent<=25,title:"\u7F29\u5C0F","aria-label":"\u7F29\u5C0F\u77E5\u8BC6\u56FE\u8C31"},"\u2212"),h("input",{type:"range",min:"25",max:"240",step:"5",value:String(zoomPercent),onInput:event3=>setGraphZoom(event3.target.value),title:"\u7F29\u653E\u6BD4\u4F8B "+zoomPercent+"%","aria-label":"\u77E5\u8BC6\u56FE\u8C31\u7F29\u653E\u6BD4\u4F8B","aria-valuetext":zoomPercent+"%"}),h("button",{type:"button",onClick:()=>setGraphZoom(zoomPercent+20),disabled:zoomPercent>=240,title:"\u653E\u5927","aria-label":"\u653E\u5927\u77E5\u8BC6\u56FE\u8C31"},"+")),h("div",{className:"sg-graph-a11y","aria-label":"\u77E5\u8BC6\u56FE\u8C31\u8282\u70B9\u5217\u8868"},displayedNodes.map(node=>h("button",{key:node.id,onClick:()=>onSelect(node.id)},node.name+"\uFF0C"+((node.tags||[])[0]||(NODE_META[node.type]||["\u5B9E\u4F53"])[0])+"\uFF0C"+GRAPH_IMPORTANCE_TEXT[importance.get(node.id)?.tier||"normal"]))),showSummary&&selectedNode&&selectedPoint?h(NodeSummaryBubble,{node:selectedNode,x:selectedPoint.x,y:selectedPoint.y,width:selectedPoint.width,height:selectedPoint.height,onViewDetails}):null,h("div",{className:"sg-graph-legend"},Object.entries(NODE_META).map(([type,meta3])=>h("span",{key:type},h("i",{style:{background:meta3[1]}}),meta3[0]))))}function NodeDetailPanel({node,nodes:nodes3,edges:edges3,events,onEvent}){if(!node)return h("aside",{className:"sg-long-detail sg-placeholder-detail"},"\u9009\u62E9\u8282\u70B9\u67E5\u770B\u5F53\u524D\u72B6\u6001\u4E0E\u8BC1\u636E");let meta3=NODE_META[node.type]||["\u5B9E\u4F53","#64748b","\u2022"],relations=edges3.filter(edge=>edge.status==="active"&&(edge.fromNodeId===node.id||edge.toNodeId===node.id)),eventMap=new Map(events.map(event3=>[event3.id,event3]));return h("aside",{className:"sg-long-detail"},h("div",{className:"sg-node-head"},h("span",{className:"sg-node-avatar",style:{background:meta3[1]}},meta3[2]),h("div",null,h("h2",null,node.name),h("span",{className:"sg-muted"},meta3[0]))),(node.tags||[]).length?h("section",null,h("h3",null,"\u8BED\u4E49\u6807\u7B7E"),h("div",{className:"sg-node-tags"},node.tags.map(tag=>h("span",{key:tag,className:"sg-node-tag"},tag)))):null,h("section",null,h("h3",null,"\u5F53\u524D\u72B6\u6001"),h("span",{className:"sg-status-dot"},"\u25CF "+(node.status==="active"?"\u6D3B\u8DC3":node.status)),node.currentState?h("p",{className:"sg-detail-copy"},node.currentState):null),h("section",null,h("h3",null,"\u5173\u952E\u4E8B\u5B9E"),node.facts?.filter(fact=>fact.status==="active").length?h("ul",null,node.facts.filter(fact=>fact.status==="active").map(fact=>h("li",{key:fact.id},h("strong",null,fact.key+"\uFF1A"),Array.isArray(fact.value)?fact.value.join("\u3001"):fact.value))):h("p",{className:"sg-muted"},"\u6682\u65E0\u5173\u952E\u4E8B\u5B9E")),h("section",null,h("h3",null,"\u76F8\u5173\u5173\u7CFB"),relations.length?relations.map(edge=>{let outgoing=edge.fromNodeId===node.id,other=nodes3.find(item=>item.id===(outgoing?edge.toNodeId:edge.fromNodeId));return h("div",{key:edge.id,className:"sg-relation-row"},h("span",null,outgoing?edge.relation:"\u88AB"+edge.relation),h("strong",null,other?.name||"\u672A\u77E5\u8282\u70B9"),h("small",null,Math.round(edge.confidence*100)+"%"))}):h("p",{className:"sg-muted"},"\u6682\u65E0\u5173\u7CFB")),h("section",null,h("h3",null,"\u652F\u6491\u4E8B\u4EF6"),(node.sourceEventIds||[]).flatMap(id2=>eventMap.get(id2)||[]).slice(0,8).map(event3=>h("button",{key:event3.id,className:"sg-support-event",onClick:()=>onEvent(event3.id)},h("span",null,exactTime(eventOccurrence(event3).value)+" \xB7 "+event3.title),h("b",null,"\u203A")))))}function EventDetailPanel({event:event3,nodes:nodes3,events,onNode,openSource,className="",onMouseEnter,onMouseLeave}){if(!event3)return h("aside",{className:"sg-long-detail sg-placeholder-detail"},"\u9009\u62E9\u4E8B\u4EF6\u67E5\u770B\u5B8C\u6574\u65F6\u95F4\u3001\u5173\u7CFB\u4E0E\u8BC1\u636E");let temporal=event3.temporal||{},eventMap=new Map(events.map(item=>[item.id,item])),nodeMap=new Map(nodes3.map(node=>[node.id,node])),relations=EVENT_RELATIONS.flatMap(([key,label])=>{let value=temporal[key];return(Array.isArray(value)?value:value?[value]:[]).map(id2=>({id:id2,label}))});return h("aside",{className:"sg-long-detail "+className,onMouseEnter,onMouseLeave},h("div",{className:"sg-event-detail-head"},h("h2",null,event3.title),h("span",{className:"sg-event-status "+(temporal.status||"unknown")},EVENT_STATUS_TEXT[temporal.status]||"\u672A\u77E5")),h("span",{className:"sg-type-badge"},EVENT_TYPE_TEXT[temporal.eventType]||temporal.eventType||"\u5176\u4ED6"),h("section",null,h("h3",null,"\u6458\u8981"),h("p",{className:"sg-detail-copy"},event3.summary||"\u6682\u65E0\u6458\u8981")),event3.narrative&&event3.narrative!==event3.summary?h("section",null,h("h3",null,"\u4E8B\u4EF6\u53D9\u8FF0"),h("p",{className:"sg-detail-copy"},event3.narrative)):null,h("section",null,h("h3",null,"\u65F6\u95F4\u4FE1\u606F"),h("dl",{className:"sg-time-grid"},h("dt",null,"\u5B9E\u9645\u53D1\u751F\u65F6\u95F4"),h("dd",null,temporal.happenedStart?exactTime(temporal.happenedStart)+(temporal.happenedEnd&&temporal.happenedEnd!==temporal.happenedStart?" \u2014 "+exactTime(temporal.happenedEnd):""):"\u672A\u77E5"),h("dt",null,"\u63D0\u53CA\u65F6\u95F4"),h("dd",null,exactTime(temporal.mentionedAt||event3.createdAt)),h("dt",null,"\u65F6\u95F4\u7CBE\u5EA6"),h("dd",null,temporal.precision||"unknown"),h("dt",null,"\u539F\u59CB\u8868\u8FBE"),h("dd",null,temporal.originalText||"\u672A\u8BB0\u5F55"))),h("section",null,h("h3",null,"\u53C2\u4E0E\u5B9E\u4F53"),h("div",{className:"sg-tags"},(temporal.participantNodeIds||[]).flatMap(id2=>nodeMap.get(id2)||[]).map(node=>h(NodePill,{key:node.id,node,onClick:()=>onNode(node.id)})),(temporal.participantNodeIds||[]).length?null:(temporal.participants||[]).map(name=>h("span",{key:name,className:"sg-tag"},name)))),relations.length?h("section",null,h("h3",null,"\u4E8B\u4EF6\u5173\u7CFB"),relations.map(relation=>h("div",{key:relation.label+relation.id,className:"sg-relation-row"},h("span",null,relation.label),h("strong",null,eventMap.get(relation.id)?.title||relation.id)))):null,h("section",null,h("h3",null,"\u8BC1\u636E\u6765\u6E90"),h("div",{className:"sg-evidence-row"},h("span",null,"\u6765\u6E90 Block"),h("code",null,event3.sourceBlockId)),h("div",{className:"sg-evidence-row"},h("span",null,"\u7F6E\u4FE1\u5EA6"),h("strong",null,Math.round((event3.confidence||0)*100)+"%"))),h("button",{className:"sg-source-button",onClick:()=>openSource(event3)},"\u67E5\u770B\u6765\u6E90\u539F\u59CB\u6D88\u606F \u2192"))}function TimelineList({events,nodes:nodes3,query,filters,onSelect,selectedId,floating=!1,onNode,openSource}){let[preview,setPreview]=React.useState(null),pinnedId=React.useRef(""),hideTimer=React.useRef(null),cancelHide=()=>{hideTimer.current&&window.clearTimeout(hideTimer.current),hideTimer.current=null},hidePreview=()=>{cancelHide(),setPreview(null),pinnedId.current=""},showPreview=(event3,target,pin=!1)=>{if(!floating||!pin&&pinnedId.current)return;cancelHide();let rect=target.getBoundingClientRect(),width2=Math.min(380,window.innerWidth-24),maxHeight=Math.min(620,window.innerHeight*.72),left=rect.right+12+width2<=window.innerWidth-12?rect.right+12:Math.max(12,rect.left-width2-12),top=Math.min(Math.max(12,rect.top-8),Math.max(12,window.innerHeight-maxHeight-12));setPreview({event:event3,left,top}),pin&&(pinnedId.current=event3.id)},scheduleHide=()=>{pinnedId.current||(cancelHide(),hideTimer.current=window.setTimeout(()=>setPreview(null),140))};React.useEffect(()=>()=>cancelHide(),[]);let normalized=query.trim().toLocaleLowerCase(),now=new Date,weekAgo=now.getTime()-7*864e5,groups={\u4ECA\u5929:[],\u672C\u5468:[],\u66F4\u65E9:[]};events.filter(event3=>event3.status!=="forgotten"&&event3.status!=="archived").filter(event3=>!normalized||JSON.stringify(event3).toLocaleLowerCase().includes(normalized)).filter(event3=>!filters.type||event3.temporal?.eventType===filters.type).filter(event3=>!filters.status||event3.temporal?.status===filters.status).filter(event3=>!filters.node||(event3.temporal?.participantNodeIds||[]).includes(filters.node)).filter(event3=>{let info=eventOccurrence(event3),time2=Date.parse(info.value);return!filters.time||(filters.time==="unknown"?!info.known:filters.time==="today"?Number.isFinite(time2)&&new Date(time2).toDateString()===now.toDateString():filters.time==="week"?time2>=weekAgo:!0)}).sort((a,b)=>String(eventOccurrence(b).value).localeCompare(String(eventOccurrence(a).value))).forEach(event3=>{let info=eventOccurrence(event3),time2=Date.parse(info.value),sameDay=Number.isFinite(time2)&&new Date(time2).toDateString()===now.toDateString();groups[sameDay?"\u4ECA\u5929":time2>=weekAgo?"\u672C\u5468":"\u66F4\u65E9"].push(event3)});let nodeMap=new Map(nodes3.map(node=>[node.id,node]));return h("div",{className:"sg-timeline"},Object.entries(groups).map(([label,items])=>items.length?h("section",{key:label,className:"sg-time-group"},h("h3",null,label),items.map(event3=>{let info=eventOccurrence(event3),temporal=event3.temporal||{};return h("button",{key:event3.id,className:"sg-timeline-card "+(event3.id===selectedId?"selected":""),onMouseEnter:hover=>showPreview(event3,hover.currentTarget),onMouseLeave:scheduleHide,onFocus:focus=>showPreview(event3,focus.currentTarget),onBlur:scheduleHide,onClick:click=>{onSelect(event3.id),showPreview(event3,click.currentTarget,!0)}},h("span",{className:"sg-timeline-dot"}),h("div",{className:"sg-event-clock"},info.known?exactTime(info.value).replace(/^\d{4}\//,""):"\u53D1\u751F\u65F6\u95F4\u672A\u77E5",info.known?null:h("small",null,"\u63D0\u53CA\u4E8E "+exactTime(info.value))),h("div",{className:"sg-event-main"},h("div",{className:"sg-event-title-row"},h("strong",null,event3.title),h("span",{className:"sg-type-badge"},EVENT_TYPE_TEXT[temporal.eventType]||temporal.eventType||"\u5176\u4ED6")),h("p",null,event3.summary||"\u6682\u65E0\u6458\u8981"),h("div",{className:"sg-tags"},(temporal.participantNodeIds||[]).flatMap(id2=>nodeMap.get(id2)||[]).map(node=>h("span",{key:node.id,className:"sg-tag"},node.name)),(temporal.participantNodeIds||[]).length?null:(temporal.participants||[]).map(name=>h("span",{key:name,className:"sg-tag"},name)))),h("span",{className:"sg-event-status "+(temporal.status||"unknown")},EVENT_STATUS_TEXT[temporal.status]||"\u672A\u77E5"))})):null),floating&&preview?h("div",{className:"sg-event-popover",style:{left:preview.left+"px",top:preview.top+"px"},onMouseEnter:cancelHide,onMouseLeave:scheduleHide},h("button",{type:"button",className:"sg-popover-close","aria-label":"\u5173\u95ED\u4E8B\u4EF6\u8BE6\u60C5",onClick:hidePreview},"\xD7"),h(EventDetailPanel,{event:preview.event,nodes:nodes3,events,onNode,openSource})):null)}function LongTermPage({events,eventPage,graph,project,query,setQuery,openEvent,namespace}){let[mode,setMode]=React.useState("graph"),[selectedNodeId,setSelectedNodeId]=React.useState(""),[selectedEventId,setSelectedEventId]=React.useState(""),[graphNodeLimit,setGraphNodeLimit]=React.useState(100),[eventFilters,setEventFilters]=React.useState({time:"",node:"",type:"",status:""}),[nodeType,setNodeType]=React.useState(""),[nodeTag,setNodeTag]=React.useState(""),[filtersOpen,setFiltersOpen]=React.useState(!1),[fullScreen,setFullScreen]=React.useState(!1),pagedEvents=usePagedMemory({namespace,kind:"events",initialItems:events,initialPage:eventPage,fallbackLimit:40}),timelineEvents=pagedEvents.items,nodes3=graph.nodes||[],edges3=graph.edges||[],clusters=graph.clusters||[],normalized=query.trim().toLocaleLowerCase(),nodeImportance=React.useMemo(()=>graphNodeImportance(nodes3,edges3,project),[nodes3,edges3,project]),nodeTags=[...new Set(nodes3.flatMap(node=>node.tags||[]))].sort((left,right)=>left.localeCompare(right));React.useEffect(()=>{if(!fullScreen)return;let previous=document.body.style.overflow;document.body.style.overflow="hidden";let onKeyDown=event3=>{event3.key==="Escape"&&(setFullScreen(!1),setFiltersOpen(!1))};return window.addEventListener("keydown",onKeyDown),()=>{document.body.style.overflow=previous,window.removeEventListener("keydown",onKeyDown)}},[fullScreen]);let visibleNodes=nodes3.filter(node=>node.status!=="archived").filter(node=>!nodeType||node.type===nodeType).filter(node=>!nodeTag||(node.tags||[]).includes(nodeTag)).filter(node=>!normalized||JSON.stringify(node).toLocaleLowerCase().includes(normalized)),displayedGraphIds=new Set([...visibleNodes].sort((left,right)=>(nodeImportance.get(right.id)?.score||0)-(nodeImportance.get(left.id)?.score||0)).slice(0,graphNodeLimit).map(node=>node.id)),activeEdges=edges3.filter(edge=>edge.status==="active"),displayedEdgeCount=activeEdges.filter(edge=>displayedGraphIds.has(edge.fromNodeId)&&displayedGraphIds.has(edge.toNodeId)).length,selectEvent=id2=>{setSelectedEventId(id2),setMode("timeline")},selectNode=id2=>{setSelectedNodeId(id2),setMode("graph")},openExplorer=()=>{mode==="graph"&&!selectedNodeId&&visibleNodes[0]&&setSelectedNodeId(visibleNodes[0].id),mode==="timeline"&&!selectedEventId&&timelineEvents[0]&&setSelectedEventId(timelineEvents[0].id),setFiltersOpen(!0),setFullScreen(!0)},migration=graph.migration||{projected:pagedEvents.page.total,total:pagedEvents.page.total,complete:!0},activeFilterCount=mode==="graph"?+!!nodeType+ +!!nodeTag:Object.values(eventFilters).filter(Boolean).length,filterControls=mode==="graph"?h("div",{className:"sg-filterbar"},h("select",{value:nodeType,onChange:event3=>setNodeType(event3.target.value),"aria-label":"\u8282\u70B9\u7C7B\u578B"},h("option",{value:""},"\u5168\u90E8\u8282\u70B9\u7C7B\u578B"),Object.entries(NODE_META).map(([value,meta3])=>h("option",{key:value,value},meta3[0]))),h("select",{value:nodeTag,onChange:event3=>setNodeTag(event3.target.value),"aria-label":"\u8BED\u4E49\u6807\u7B7E"},h("option",{value:""},"\u5168\u90E8\u8BED\u4E49\u6807\u7B7E"),nodeTags.map(tag=>h("option",{key:tag,value:tag},tag)))):h("div",{className:"sg-filterbar"},h("select",{value:eventFilters.time,onChange:event3=>setEventFilters({...eventFilters,time:event3.target.value}),"aria-label":"\u65F6\u95F4\u8303\u56F4"},h("option",{value:""},"\u5168\u90E8\u65F6\u95F4"),h("option",{value:"today"},"\u4ECA\u5929"),h("option",{value:"week"},"\u672C\u5468"),h("option",{value:"unknown"},"\u53D1\u751F\u65F6\u95F4\u672A\u77E5")),h("select",{value:eventFilters.node,onChange:event3=>setEventFilters({...eventFilters,node:event3.target.value}),"aria-label":"\u53C2\u4E0E\u5B9E\u4F53"},h("option",{value:""},"\u5168\u90E8\u5B9E\u4F53"),nodes3.map(node=>h("option",{key:node.id,value:node.id},node.name))),h("select",{value:eventFilters.type,onChange:event3=>setEventFilters({...eventFilters,type:event3.target.value}),"aria-label":"\u4E8B\u4EF6\u7C7B\u578B"},h("option",{value:""},"\u5168\u90E8\u7C7B\u578B"),Object.entries(EVENT_TYPE_TEXT).map(([value,label])=>h("option",{key:value,value},label))),h("select",{value:eventFilters.status,onChange:event3=>setEventFilters({...eventFilters,status:event3.target.value}),"aria-label":"\u4E8B\u4EF6\u72B6\u6001"},h("option",{value:""},"\u5168\u90E8\u72B6\u6001"),Object.entries(EVENT_STATUS_TEXT).map(([value,label])=>h("option",{key:value,value},label))));return h("section",{className:"sg-long-explorer "+(fullScreen?"fullscreen":""),"aria-label":fullScreen?"\u957F\u671F\u8BB0\u5FC6\u5168\u5C4F\u63A2\u7D22":"\u957F\u671F\u8BB0\u5FC6\u6D4F\u89C8"},h("nav",{className:"sg-long-tabs"},h("button",{className:mode==="graph"?"active":"",onClick:()=>setMode("graph")},"\u77E5\u8BC6\u56FE\u8C31"),h("button",{className:mode==="timeline"?"active":"",onClick:()=>setMode("timeline")},"\u4E8B\u4EF6\u65F6\u95F4\u7EBF")),migration.complete?null:h("div",{className:"sg-migration",role:"status"},h("span",{className:"sg-processing-icon"},"\u21BB"),h("span",null,"\u6B63\u5728\u5347\u7EA7\u957F\u671F\u8BB0\u5FC6 \xB7 "+migration.projected+" / "+migration.total+" Events"),h("small",null,migration.failed?migration.failed+" \u6279\u5F85\u91CD\u8BD5":"\u540E\u53F0\u589E\u91CF\u5904\u7406\uFF0C\u4E0D\u5F71\u54CD\u5176\u4ED6\u529F\u80FD")),h("div",{className:"sg-long-toolbar"},h(SearchBox,{value:query,onChange:setQuery}),h("button",{type:"button",className:"sg-toolbar-button","aria-expanded":filtersOpen?"true":"false",onClick:()=>setFiltersOpen(!filtersOpen)},"\u7B5B\u9009 \u25BE",activeFilterCount?h("span",{className:"sg-active-filter-count"},activeFilterCount):null),h("span",{className:"sg-toolbar-count"},mode==="graph"?"\u663E\u793A "+Math.min(graphNodeLimit,visibleNodes.length)+" / \u5171 "+visibleNodes.length+" \u4E2A\u8282\u70B9 \xB7 \u663E\u793A "+displayedEdgeCount+" / \u5171 "+activeEdges.length+" \u6761\u5173\u7CFB":"\u663E\u793A "+timelineEvents.length+" / \u5171 "+pagedEvents.page.total+" \u6761\u4E8B\u4EF6 \xB7 "+project),mode==="graph"&&graphNodeLimit<visibleNodes.length?h("button",{type:"button",className:"sg-toolbar-button",onClick:()=>setGraphNodeLimit(current=>Math.min(visibleNodes.length,current+100))},"\u518D\u663E\u793A 100 \u4E2A"):null,h("button",{type:"button",className:"sg-toolbar-button",onClick:fullScreen?()=>{setFullScreen(!1),setFiltersOpen(!1)}:openExplorer},fullScreen?"\u9000\u51FA\u5168\u5C4F":"\u26F6 \u5168\u5C4F\u67E5\u770B"+(mode==="graph"?"\u56FE\u8C31":"\u65F6\u95F4\u7EBF"))),filtersOpen?filterControls:null,mode==="graph"?h("div",{className:"sg-long-layout "+(fullScreen?"":"sg-summary-layout")},h(GraphCanvas,{nodes:visibleNodes,edges:edges3,clusters,importance:nodeImportance,selectedId:selectedNodeId,onSelect:setSelectedNodeId,nodeLimit:graphNodeLimit,showSummary:!fullScreen,onViewDetails:openExplorer}),fullScreen?h(NodeDetailPanel,{node:nodes3.find(node=>node.id===selectedNodeId),nodes:nodes3,edges:edges3,events,onEvent:selectEvent}):null):h(React.Fragment,null,h("div",{className:"sg-long-layout "+(fullScreen?"sg-timeline-layout":"sg-summary-layout")},h(TimelineList,{events:timelineEvents,nodes:nodes3,query,filters:eventFilters,onSelect:setSelectedEventId,selectedId:selectedEventId,floating:!fullScreen,onNode:selectNode,openSource:openEvent}),fullScreen?h(EventDetailPanel,{event:timelineEvents.find(event3=>event3.id===selectedEventId),nodes:nodes3,events:timelineEvents,onNode:selectNode,openSource:openEvent}):null),h(Pagination,{page:pagedEvents.page,loading:pagedEvents.loading,error:pagedEvents.error,onOffset:pagedEvents.loadOffset})))}function previewText(value){let text=String(value||"").replace(/\s+/g," ").trim()||"\u6682\u65E0\u5185\u5BB9";return text.length>200?text.slice(0,200)+"\u2026":text}function turnRangeText(range){return!Array.isArray(range)||range.length<2||range[1]<range[0]?"\u7B49\u5F85\u65B0\u5BF9\u8BDD":"Turn "+range[0]+"\u2013"+range[1]}function LayerPreview({layer,currentLevel,expanding,menuOpen,allowExpand,onMenuToggle,onExpand}){let itemRef=React.useRef(null),hideTimer=React.useRef(null),popoverRef=React.useRef(null),level=Number(layer.level),actionable=allowExpand&&level>currentLevel,cancelHide=()=>{hideTimer.current&&window.clearTimeout(hideTimer.current),hideTimer.current=null},removePopover=()=>{popoverRef.current?.remove(),popoverRef.current=null},showPopover=()=>{cancelHide();let rect=itemRef.current?.getBoundingClientRect();if(!rect)return;let width2=Math.min(390,Math.max(240,window.innerWidth-24)),maxHeight=Math.min(520,window.innerHeight*.7),right=rect.right+12,left=right+width2<=window.innerWidth-12?right:Math.max(12,rect.left-width2-12),top=Math.min(Math.max(12,rect.top-8),Math.max(12,window.innerHeight-maxHeight-12));if(!popoverRef.current){let popover=document.createElement("aside"),title=document.createElement("strong"),content=document.createElement("p"),theme=window.getComputedStyle(itemRef.current),pageTheme=window.getComputedStyle(itemRef.current.closest(".sg-memory"));popover.className="sg-layer-popover",popover.setAttribute("role","tooltip"),popover.style.background=pageTheme.backgroundColor,popover.style.color=pageTheme.color,popover.style.borderColor=theme.borderColor,title.textContent="L"+level+" \u5B8C\u6574\u5185\u5BB9",content.className="sg-layer-full",content.textContent=String(layer.content||"\u6682\u65E0\u5185\u5BB9"),popover.append(title,content),popover.addEventListener("mouseenter",cancelHide),popover.addEventListener("mouseleave",scheduleHide),document.body.appendChild(popover),popoverRef.current=popover}popoverRef.current.style.left=left+"px",popoverRef.current.style.top=top+"px"},scheduleHide=()=>{cancelHide(),hideTimer.current=window.setTimeout(removePopover,140)};return React.useEffect(()=>()=>{cancelHide(),removePopover()},[]),h("div",{className:"sg-layer-hover"},h("div",{ref:itemRef,className:"sg-layer-item "+(level===currentLevel?"current":""),"data-level":String(level),tabIndex:0,onMouseEnter:showPopover,onMouseLeave:scheduleHide,onFocus:showPopover,onBlur:scheduleHide},h("span",{className:"sg-layer-label"},"L"+level),h("span",{className:"sg-layer-preview"},previewText(layer.content)),actionable?h("button",{className:"sg-layer-more",type:"button","aria-label":"L"+level+" \u64CD\u4F5C","aria-expanded":menuOpen?"true":"false",onClick:event3=>{event3.stopPropagation(),onMenuToggle(level)}},"\xB7\xB7\xB7"):h("span",{className:"sg-layer-more-placeholder","aria-hidden":"true"}),menuOpen?h("div",{className:"sg-layer-menu"},h("button",{type:"button",disabled:expanding,onClick:event3=>{event3.stopPropagation(),onMenuToggle(null),onExpand(level)}},expanding?"\u6B63\u5728\u5C55\u5F00\u2026":"\u5C55\u5F00\u5230\u8FD9\u4E00\u5C42")):null))}function BlockLayerPanel({block,detail,loading,expandingLevel,onExpand}){let[openMenuLevel,setOpenMenuLevel]=React.useState(null);if(React.useEffect(()=>{let closeMenu=event3=>{if(event3.key==="Escape"){setOpenMenuLevel(null);return}event3.target?.closest?.(".sg-layer-more, .sg-layer-menu")||setOpenMenuLevel(null)};return document.addEventListener("pointerdown",closeMenu),document.addEventListener("keydown",closeMenu),()=>{document.removeEventListener("pointerdown",closeMenu),document.removeEventListener("keydown",closeMenu)}},[]),loading)return h("div",{className:"sg-layer-panel"},h(Loading));let layers=Array.isArray(detail?.layers)?detail.layers:[];return h("div",{className:"sg-layer-panel"},h("div",{className:"sg-layer-heading"},h("strong",null,"\u5206\u5C42\u5185\u5BB9\u9884\u89C8"),h("span",null,"\u5F53\u524D\u5C42\u7EA7\uFF1AL"+block.currentLevel+" \xB7 \u60AC\u505C\u53EF\u67E5\u770B\u5B8C\u6574\u5185\u5BB9")),block.virtual?h("div",{className:"sg-virtual-note"},"\u65E7\u4F1A\u8BDD\u5C55\u793A\u7247\u6BB5\u4E3A\u53EA\u8BFB\u5185\u5BB9\uFF0C\u4E0D\u4F1A\u6539\u5199\u539F\u59CB\u6570\u636E\u5E93\u3002"):null,layers.length?h("div",{className:"sg-layer-stack"},layers.slice().sort((a,b)=>a.level-b.level).map(layer=>h(LayerPreview,{key:layer.level,layer,currentLevel:block.currentLevel,expanding:expandingLevel===layer.level,menuOpen:openMenuLevel===layer.level,allowExpand:!block.virtual,onMenuToggle:level=>setOpenMenuLevel(current=>current===level?null:level),onExpand}))):h("div",{className:"sg-muted"},"\u6682\u65F6\u65E0\u6CD5\u8BFB\u53D6\u8BE5 Block \u7684\u5206\u5C42\u5185\u5BB9\u3002"))}function expansionLabel(source){return source==="user"?"\u7528\u6237\u5C55\u5F00":source==="agent"?"Agent \u5C55\u5F00":source==="legacy"?"\u66FE\u5C55\u5F00":""}function ShortTermPage({blocks,blockPage,openBlock,conversations,activeThreadId,namespace,onConversationChange,refresh}){let pagedBlocks=usePagedMemory({namespace,kind:"blocks",initialItems:blocks,initialPage:blockPage,fallbackLimit:40,extraParams:{threadId:activeThreadId}}),visible=[...pagedBlocks.items].sort((a,b)=>Number(a.sequence||0)-Number(b.sequence||0)||String(a.createdAt).localeCompare(String(b.createdAt))),distributionRef=React.useRef(null),[rail,setRail]=React.useState({value:0,max:0}),[expandedId,setExpandedId]=React.useState(""),[details,setDetails]=React.useState({}),[loadingId,setLoadingId]=React.useState(""),[expanding,setExpanding]=React.useState({blockId:"",level:-1}),[inlineError,setInlineError]=React.useState(""),currentOpen=openBlock||{turnRange:null,messages:0,status:"open"};React.useEffect(()=>{let node=distributionRef.current;if(!node)return;let updateRail=()=>{let max5=Math.max(0,node.scrollWidth-node.clientWidth);setRail({value:Math.min(max5,Math.round(node.scrollLeft)),max:max5})};node.scrollLeft=node.scrollWidth,updateRail();let observer=typeof ResizeObserver=="function"?new ResizeObserver(updateRail):null;return observer?.observe(node),()=>observer?.disconnect()},[visible.length,activeThreadId]);let toggleBlock=block=>{if(expandedId===block.id){setExpandedId("");return}setExpandedId(block.id),setInlineError(""),!details[block.id]&&(setLoadingId(block.id),api2("sources",{namespace,blockId:block.id}).then(value=>setDetails(current=>({...current,[block.id]:value}))).catch(reason=>setInlineError(String(reason.message||reason))).finally(()=>setLoadingId("")))},expandTo=(block,level)=>(setInlineError(""),setExpanding({blockId:block.id,level}),api2("blocks/expand",{namespace,blockId:block.id,level:"L"+level},{method:"PATCH"}).then(()=>refresh()).then(()=>pagedBlocks.page.offset>0?pagedBlocks.loadOffset(pagedBlocks.page.offset):null).catch(reason=>setInlineError(String(reason.message||reason))).finally(()=>setExpanding({blockId:"",level:-1})));return h(React.Fragment,null,h("section",{className:"sg-decay-overview","aria-labelledby":"sg-decay-title"},h("div",{className:"sg-decay-head"},h("h2",{className:"sg-decay-title",id:"sg-decay-title"},"\u5757\u8870\u51CF\u603B\u89C8"),h("label",{className:"sg-conversation"},h("span",null,"\u5F53\u524D\u5BF9\u8BDD\uFF1A"),h("select",{value:activeThreadId||"",disabled:!conversations.length,onChange:event3=>onConversationChange(event3.target.value),"aria-label":"\u5F53\u524D\u5BF9\u8BDD"},conversations.map(conversation=>h("option",{key:conversation.id,value:conversation.id},conversation.label))))),h("p",{className:"sg-decay-copy"},"L0 \u5C42\u6700\u6D45\u6700\u7B80\u7565\uFF0CL5 \u5C42\u6700\u6DF1\u6700\u8BE6\u7EC6\uFF0C\u79BB\u5F53\u524D\u5BF9\u8BDD\u8D8A\u8FDC\uFF0CBlock \u4F1A\u9010\u6E10\u7B80\u7565\u3002"),h("div",{ref:distributionRef,className:"sg-distribution","aria-label":"Block \u5F53\u524D\u5C42\u7EA7\u5206\u5E03",onScroll:event3=>{let node=event3.currentTarget;setRail({value:Math.round(node.scrollLeft),max:Math.max(0,node.scrollWidth-node.clientWidth)})},onWheel:event3=>{rail.max<=0||(event3.preventDefault(),event3.currentTarget.scrollLeft+=event3.deltaY+event3.deltaX)}},visible.map(block=>h("span",{key:block.id,className:"sg-level-chip","data-level":String(block.currentLevel),title:"Block #"+block.sequence},"L"+block.currentLevel)),h("span",{className:"sg-level-chip sg-open-chip"},"\u5F00\u653E\u5757 \xB7 \u672A\u5C01\u5B58")),h("input",{className:"sg-distribution-rail",type:"range",min:"0",max:String(Math.max(1,rail.max)),step:"1",value:String(Math.min(rail.value,Math.max(1,rail.max))),disabled:rail.max<=0,onChange:event3=>{let value=Number(event3.target.value);distributionRef.current&&(distributionRef.current.scrollLeft=value),setRail(current=>({...current,value}))},"aria-label":"Block \u5206\u5E03\u6ED1\u8F68"}),h("div",{className:"sg-time-direction","aria-hidden":"true"},h("span",null,"\u66F4\u65E7"),h("span",{className:"sg-time-line"}),h("span",null,"\u66F4\u65B0 \u2192")),h("div",{className:"sg-overview-meta"},h("span",null,"\u5DF2\u5C01\u5B58\u5757\uFF1A\u672C\u9875 "+visible.length+" / \u5171 "+pagedBlocks.page.total),h("span",null,"\u5F00\u653E\u5757\uFF1A"+turnRangeText(currentOpen.turnRange)+"\uFF08\u672A\u5C01\u5B58\uFF09"))),h("section",{className:"sg-block-list","aria-label":"Block \u5217\u8868"},h("div",{className:"sg-block-header","aria-hidden":"true"},h("span",null,"\u5F53\u524D\u5C42\u7EA7"),h("span",null,"Block"),h("span",null,"\u8986\u76D6 Turn"),h("span",null,"\u8DDD\u6700\u65B0\u5C01\u5B58\u5757"),h("span")),inlineError?h("div",{className:"sg-inline-error"},"\u64CD\u4F5C\u672A\u5B8C\u6210\uFF1A"+inlineError):null,visible.map(block=>h("div",{key:block.id,className:"sg-block-unit"},h("button",{className:"sg-block-toggle",type:"button",onClick:()=>toggleBlock(block),"aria-expanded":expandedId===block.id?"true":"false"},h("span",{className:"sg-level-cell"},h("span",{className:"sg-level-badge","data-level":String(block.currentLevel)},"L"+block.currentLevel),expansionLabel(block.expansionSource)?h("span",{className:"sg-lifted"},expansionLabel(block.expansionSource)):null),h("span",{className:"sg-block-name"},(block.virtual?"\u65E7 Block #":"Block #")+block.sequence),h("span",{className:"sg-block-turn"},turnRangeText(block.turnRange)),h("span",{className:"sg-block-distance"},block.distanceFromLatest===0?"0\uFF08\u6700\u65B0\uFF09":block.distanceFromLatest+" \u4E2A Block"),h("span",{className:"sg-row-chevron","aria-hidden":"true"},expandedId===block.id?"\u2303":"\u203A")),expandedId===block.id?h("div",{className:"sg-block-expanded"},h(BlockLayerPanel,{block,detail:details[block.id],loading:loadingId===block.id,expandingLevel:expanding.blockId===block.id?expanding.level:-1,onExpand:level=>expandTo(block,level)})):null)),h("div",{className:"sg-block-unit"},h("div",{className:"sg-block-toggle sg-open-row"},h("span",{className:"sg-level-cell"},h("span",{className:"sg-open-badge"},"\u5F00\u653E\u5757")),h("span",{className:"sg-block-name"},"\u672A\u5C01\u5B58"),h("span",{className:"sg-block-turn"},turnRangeText(currentOpen.turnRange)),h("span",{className:"sg-block-distance"},"\u2014"),h("span")))),h(Pagination,{page:pagedBlocks.page,loading:pagedBlocks.loading,error:pagedBlocks.error,onOffset:pagedBlocks.loadOffset}))}function SourceDetails({item,source,kind}){let messages=source?.messages||[];return h("div",{className:"sg-detail-section"},h("h3",{className:"sg-section-title"},"\u6765\u6E90"),h("div",{className:"sg-source-label"},h("span",{className:"sg-source-icon","aria-hidden":"true"},"\u25A3"),h("span",null,"\u5F53\u524D DeepSeek \u5BF9\u8BDD")),h("details",{className:"sg-tech"},h("summary",null,"\u6280\u672F\u8BE6\u60C5"),h("div",{className:"sg-tech-body"},h("div",{className:"sg-tech-row"},h("span",{className:"sg-muted"},kind==="block"?"Block ID":"Event ID"),h("span",{className:"sg-code"},item.id)),kind==="block"&&item.turnRange?h("div",{className:"sg-tech-row"},h("span",{className:"sg-muted"},"Turn"),h("span",null,item.turnRange.join(" - "))):null,messages.length?messages.map(message=>h("div",{key:message.id,className:"sg-raw-message"},h("div",{className:"sg-muted"},String(message.role||"")+" \xB7 "+formatTime(message.createdAt)),h("div",{className:"sg-code"},String(message.content||"")))):h("div",{className:"sg-muted"},"\u5F53\u524D\u6570\u636E\u4E2D\u6CA1\u6709\u53EF\u663E\u793A\u7684\u6765\u6E90\u6D88\u606F\u3002"))))}function EventDetail({event:event3,project,source,onBack,backLabel}){return h(React.Fragment,null,h(BackBar,{label:backLabel,onBack}),h("header",{className:"sg-detail-header"},h("h2",{className:"sg-detail-title"},event3.title||"\u8BB0\u5FC6\u8BE6\u60C5"),event3.summary?h("p",{className:"sg-detail-subtitle"},event3.summary):null,h("div",{className:"sg-meta"},h("span",null,formatTime(event3.updatedAt||event3.createdAt)),h("span",{className:"sg-meta-sep"},project))),event3.narrative?h("div",{className:"sg-detail-section"},h("h3",{className:"sg-section-title"},"AI \u5BF9\u8FD9\u6BB5\u7ECF\u5386\u7684\u7406\u89E3"),h("p",{className:"sg-prose"},event3.narrative)):null,h("div",{className:"sg-detail-section"},h("h3",{className:"sg-section-title"},"\u53C2\u4E0E\u5B9E\u4F53"),(event3.temporal?.participants||[]).length?h("div",{className:"sg-tags"},event3.temporal.participants.map(name=>h("span",{key:name,className:"sg-tag"},name))):h("span",{className:"sg-muted"},"\u672A\u8BB0\u5F55")),h(SourceDetails,{item:event3,source,kind:"event"}))}function ElementDetail({element:element3,events,source,openEvent,onBack,backLabel}){let facts=[];element3.currentState&&facts.push(element3.currentState);for(let fact of element3.facts||[]){let value=Array.isArray(fact.value)?fact.value.join("\u3001"):fact.value;value&&!facts.includes(String(value))&&facts.push(String(value))}let related=events.filter(event3=>(element3.sourceEventIds||[]).includes(event3.id)).sort((a,b)=>String(b.updatedAt).localeCompare(String(a.updatedAt)));return h(React.Fragment,null,h(BackBar,{label:backLabel,onBack}),h("header",{className:"sg-detail-header"},h("h2",{className:"sg-detail-title"},element3.name||"\u76F8\u5173\u4E8B\u7269"),h("p",{className:"sg-detail-subtitle"},"AI \u5173\u4E8E\u5B83\u76EE\u524D\u77E5\u9053\u8FD9\u4E9B"),h("div",{className:"sg-meta"},h("span",null,"\u76F8\u5173\u7ECF\u5386 "+related.length+" \u6761"),h("span",{className:"sg-meta-sep"},"\u6700\u8FD1\u66F4\u65B0 "+formatTime(element3.updatedAt)))),h("div",{className:"sg-detail-section"},facts.length?h("ul",{className:"sg-facts"},facts.map((fact,index)=>h("li",{key:index},fact))):h("div",{className:"sg-muted"},"\u6682\u65F6\u6CA1\u6709\u5F62\u6210\u53EF\u5C55\u793A\u7684\u8BA4\u8BC6\u3002")),h("div",{className:"sg-detail-section"},h("h3",{className:"sg-section-title"},"\u76F8\u5173\u7ECF\u5386"),related.length?h("div",{className:"sg-related-list"},related.map(event3=>h("button",{key:event3.id,className:"sg-related",onClick:()=>openEvent(event3)},h("span",{className:"sg-related-name"},event3.title),h("span",{className:"sg-related-time"},formatTime(event3.updatedAt||event3.createdAt))))):h("div",{className:"sg-muted"},"\u6CA1\u6709\u5173\u8054\u7ECF\u5386\u3002")),h(SourceDetails,{item:element3,source,kind:"element"}))}function ProcessingStatus({overview,blocks,onBack,refresh}){let failures=overview.failedJobDetails||[],failedBlocks=blocks.filter(block=>block.status==="failed"),first2=failures[0];return h(React.Fragment,null,h(BackBar,{label:"\u8FD4\u56DE",onBack}),h("div",{className:"sg-intro"},h("h2",null,"\u5904\u7406\u72B6\u6001"),h("p",null,failures.length+" \u4E2A\u4EFB\u52A1\u9700\u8981\u7EE7\u7EED\u5904\u7406")),h("div",{className:"sg-safe-note"},"\u539F\u59CB\u8BB0\u5FC6\u5DF2\u4FDD\u5B58\uFF0C\u4E0D\u4F1A\u4E22\u5931\u3002"),h("div",{className:"sg-detail-section"},h("div",{className:"sg-pipeline"},h("div",{className:"sg-stage"},h("span",null,"\u8BB0\u5FC6\u4FDD\u5B58"),h("span",{className:"sg-stage-value done"},"\u2713 \u5DF2\u5B8C\u6210")),h("div",{className:"sg-stage"},h("span",null,"\u4E8B\u4EF6\u63D0\u53D6"),h("span",{className:"sg-stage-value "+(first2?.kind==="event-extraction"?"failed":"done")},first2?.kind==="event-extraction"?"\xD7 \u5931\u8D25":"\u2713 \u5DF2\u5B8C\u6210")),h("div",{className:"sg-stage"},h("span",null,"\u56FE\u8C31\u6295\u5F71"),h("span",{className:"sg-stage-value "+(first2?.kind==="graph-projection"?"failed":first2?.kind==="event-extraction"?"waiting":"done")},first2?.kind==="graph-projection"?"\xD7 \u5931\u8D25":first2?.kind==="event-extraction"?"\u2014 \u7B49\u5F85":"\u2713 \u5DF2\u5B8C\u6210")))),failedBlocks.length?h("div",{className:"sg-detail-section"},h("h3",{className:"sg-section-title"},"\u53D7\u5F71\u54CD\u7684\u77ED\u671F\u8BB0\u5FC6"),failedBlocks.map(block=>h("div",{key:block.id,className:"sg-result-event"},block.title||block.summary||"\u77ED\u671F\u8BB0\u5FC6"))):null,h("button",{className:"sg-alert",onClick:refresh,style:{marginTop:"16px"}},h("span",{className:"sg-alert-mark"},"\u21BB"),h("span",null,h("span",{className:"sg-alert-title"},"\u91CD\u65B0\u68C0\u67E5\u72B6\u6001"),h("br"),h("span",{className:"sg-alert-copy"},"\u4EFB\u52A1\u4F1A\u6CBF\u7528\u73B0\u6709\u91CD\u8BD5\u673A\u5236\u7EE7\u7EED\u5904\u7406\u3002")),h("span",{className:"sg-chevron"},"\u203A")),h("details",{className:"sg-tech"},h("summary",null,"\u6280\u672F\u9519\u8BEF\u8BE6\u60C5"),h("pre",{className:"sg-tech-body sg-code"},first2?.lastErrorFull||first2?.lastError||"\u6CA1\u6709\u8BB0\u5F55\u6280\u672F\u9519\u8BEF\u3002")))}function ImportPage({namespace,onBack,refresh}){let[text,setText]=React.useState(""),[prompt,setPrompt]=React.useState(""),[promptLoading,setPromptLoading]=React.useState(!0),[copied,setCopied]=React.useState(!1),[busy,setBusy]=React.useState(!1),[job,setJob]=React.useState(null),[choices,setChoices]=React.useState({}),[result,setResult]=React.useState(null),[error3,setError]=React.useState(""),[connectionError,setConnectionError]=React.useState("");React.useEffect(()=>{let active=!0,restoreTimer;api2("import").then(value=>{active&&setPrompt(String(value.prompt||""))}).catch(reason=>{active&&setError(String(reason?.message||reason))}).finally(()=>{active&&setPromptLoading(!1)});let restore=()=>api2("import",{operation:"status",namespace}).then(value=>{active&&(setConnectionError(""),value?.jobId&&value.status!=="undone"&&(setJob(value),value.status==="committed"&&setResult(value)))}).catch(()=>{active&&(setConnectionError("\u8FDE\u63A5\u6682\u65F6\u4E2D\u65AD\uFF0C\u6B63\u5728\u81EA\u52A8\u91CD\u8BD5\u2026"),restoreTimer=window.setTimeout(restore,2500))});restore();let onKeyDown=event3=>{event3.key==="Escape"&&onBack()};return window.addEventListener("keydown",onKeyDown),()=>{active=!1,window.clearTimeout(restoreTimer),window.removeEventListener("keydown",onKeyDown)}},[]),React.useEffect(()=>{if(!job?.jobId||!["extracting","processing"].includes(job.status))return;let active=!0,timer,poll=()=>api2("import",{operation:"status",namespace,jobId:job.jobId}).then(next2=>{active&&(setConnectionError(""),setJob(next2),["extracting","processing"].includes(next2.status)&&(timer=window.setTimeout(poll,1200)))}).catch(()=>{active&&(setConnectionError("\u8FDE\u63A5\u6682\u65F6\u4E2D\u65AD\uFF0C\u6B63\u5728\u81EA\u52A8\u91CD\u8BD5\u2026"),timer=window.setTimeout(poll,2500))});return timer=window.setTimeout(poll,600),()=>{active=!1,window.clearTimeout(timer)}},[job?.jobId,job?.status,namespace]);let copyPrompt=()=>{if(!prompt)return;(navigator.clipboard?.writeText?navigator.clipboard.writeText(prompt):Promise.reject(new Error("\u5F53\u524D\u6D4F\u89C8\u5668\u4E0D\u652F\u6301\u81EA\u52A8\u590D\u5236"))).then(()=>{setCopied(!0),window.setTimeout(()=>setCopied(!1),1600)}).catch(reason=>setError(String(reason?.message||reason)))},analyze=()=>{if(!(!text.trim()||busy))return setBusy(!0),setError(""),setResult(null),setJob(null),setChoices({}),api2("import",{namespace},{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({operation:"preview",namespace,text})}).then(setJob).catch(reason=>setError(String(reason?.message||reason))).finally(()=>setBusy(!1))},commit=()=>{if(!job||busy)return;let requestedChoices=(job.decisions||[]).flatMap((decision,index)=>decision.requiresConfirmation?[{index,action:choices[index]||decision.action||"IGNORE"}]:[]);return setBusy(!0),setError(""),api2("import",{namespace},{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({operation:"commit",namespace,jobId:job.jobId,choices:requestedChoices})}).then(next2=>(setResult(next2),setJob(next2),refresh())).catch(reason=>setError(String(reason?.message||reason))).finally(()=>setBusy(!1))},retry=()=>{if(!(!job?.jobId||busy))return setBusy(!0),setError(""),api2("import",{namespace},{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({operation:"retry",namespace,jobId:job.jobId})}).then(setJob).catch(reason=>setError(String(reason?.message||reason))).finally(()=>setBusy(!1))},undo=()=>{if(!(!result?.sourceBlockId||busy))return setBusy(!0),setError(""),api2("import",{namespace},{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({operation:"undo",namespace,sourceBlockId:result.sourceBlockId})}).then(()=>(setResult(null),setJob(null),setText(""),refresh())).catch(reason=>setError(String(reason?.message||reason))).finally(()=>setBusy(!1))},reset2=()=>{setResult(null),setJob(null),setChoices({}),setText(""),setError("")},actionLabel={ADD:"\u65B0\u589E",MERGE:"\u5408\u5E76",SUPERSEDE:"\u53D6\u4EE3\u65E7\u8BB0\u5FC6",CONFLICT:"\u4FDD\u7559\u5E76\u6807\u8BB0\u51B2\u7A81",IGNORE:"\u5FFD\u7565"},running=job&&["extracting","processing"].includes(job.status),reviewable=job&&["ready","awaiting_confirmation"].includes(job.status),emptyJob=reviewable&&Number(job.totalCount||0)===0,percent=job?job.status==="extracting"?5:job.totalCount?Math.round(job.processedCount/job.totalCount*100):100:0;return h("div",{className:"sg-import-overlay",role:"presentation",onMouseDown:event3=>{event3.target===event3.currentTarget&&onBack()}},h("section",{className:"sg-import-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"sg-import-title"},h("header",{className:"sg-import-dialog-head"},h("h2",{id:"sg-import-title",className:"sg-import-dialog-title"},"\u5C06\u8BB0\u5FC6\u5BFC\u5165 StrataGate"),h("button",{type:"button",className:"sg-icon-button",onClick:onBack,"aria-label":"\u5173\u95ED"},"\xD7")),h("div",{className:"sg-import-step"},h("div",{className:"sg-import-step-head"},h("span",{className:"sg-import-step-num"},"1"),h("span",{className:"sg-import-step-title"},"\u590D\u5236\u4EE5\u4E0B\u63D0\u793A\u8BCD\u5230\u5176\u4ED6 AI \u5BF9\u8BDD\u4E2D"),h("button",{type:"button",className:"sg-import-copy",disabled:promptLoading||!prompt,onClick:copyPrompt},copied?"\u5DF2\u590D\u5236":"\u590D\u5236")),promptLoading?h("div",{className:"sg-import-loading"},"\u6B63\u5728\u52A0\u8F7D\u63D0\u793A\u8BCD\u2026"):h("div",{className:"sg-import-prompt",tabIndex:"0"},prompt||"\u63D0\u793A\u8BCD\u6682\u65F6\u65E0\u6CD5\u8BFB\u53D6\u3002")),h("div",{className:"sg-import-step"},h("div",{className:"sg-import-step-head"},h("span",{className:"sg-import-step-num"},"2"),h("span",{className:"sg-import-step-title"},"\u7C98\u8D34\u7ED3\u679C\uFF0C\u5148\u5206\u6790\u518D\u5BFC\u5165")),h("div",{className:"sg-import-card"},h("textarea",{value:text,disabled:busy||!!job||!!result,onChange:event3=>setText(event3.target.value),placeholder:"\u7C98\u8D34 JSON\uFF1B\u683C\u5F0F\u4E0D\u5408\u683C\u65F6\u4F1A\u81EA\u52A8\u5C1D\u8BD5\u6062\u590D","aria-label":"\u5916\u90E8 AI \u8BB0\u5FC6 JSON"}))),running?h("div",{className:"sg-import-step"},h("div",{className:"sg-import-step-head"},h("span",{className:"sg-import-step-num"},"3"),h("span",{className:"sg-import-step-title"},job.status==="extracting"?"\u6B63\u5728\u4FEE\u590D\u5E76\u63D0\u53D6\u5019\u9009\u8BB0\u5FC6":"\u6B63\u5728\u68C0\u6D4B\u91CD\u590D\u4E0E\u51B2\u7A81")),h("div",{role:"progressbar","aria-valuemin":"0","aria-valuemax":"100","aria-valuenow":percent,style:{height:"9px",overflow:"hidden",borderRadius:"999px",background:"var(--sg-border)"}},h("div",{style:{width:percent+"%",height:"100%",background:"var(--sg-accent)",transition:"width .25s ease"}})),h("div",{className:"sg-import-hint",style:{marginTop:"8px"}},job.status==="extracting"?"\u539F JSON \u4E0D\u5408\u683C\uFF0C\u6B63\u5728\u4F7F\u7528\u6A21\u578B\u515C\u5E95\u3002\u53EF\u4EE5\u5173\u95ED\u9875\u9762\uFF0C\u4EFB\u52A1\u4F1A\u7EE7\u7EED\u3002":"\u5DF2\u5B8C\u6210 "+job.processedCount+"/"+job.totalCount+"\uFF0C\u6B63\u5728\u5224\u65AD\u7B2C "+Math.min(job.processedCount+1,job.totalCount)+" \u6761\uFF1B\u53EF\u4EE5\u5173\u95ED\u9875\u9762\uFF0C\u7A0D\u540E\u91CD\u65B0\u6253\u5F00\u67E5\u770B\u3002")):null,reviewable?h("div",{className:"sg-import-step"},h("div",{className:"sg-import-step-head"},h("span",{className:"sg-import-step-num"},"3"),h("span",{className:"sg-import-step-title"},"\u5BFC\u5165\u9884\u89C8")),h("div",{className:"sg-import-hint"},emptyJob?"\u6CA1\u6709\u53D1\u73B0\u53EF\u5BFC\u5165\u7684\u957F\u671F\u8BB0\u5FC6\u3002":job.recoveredFromInvalidJson?"\u8FD9\u4E9B\u5019\u9009\u7531\u515C\u5E95\u6A21\u578B\u6062\u590D\uFF0C\u5168\u90E8\u9700\u8981\u4EBA\u5DE5\u786E\u8BA4\u3002":"\u9AD8\u7F6E\u4FE1\u5EA6\u7ED3\u679C\u81EA\u52A8\u91C7\u7528\uFF1B\u4F4E\u7F6E\u4FE1\u5EA6\u7ED3\u679C\u8BF7\u4EBA\u5DE5\u9009\u62E9\u5904\u7406\u65B9\u5F0F\u3002"),h("div",{className:"sg-import-preview"},(job.decisions||[]).map((decision,index)=>h("div",{key:index,className:"sg-import-preview-item"},h("div",{className:"sg-import-preview-title"},decision.candidate?.title||"\u672A\u547D\u540D\u8BB0\u5FC6"),h("div",{className:"sg-import-preview-meta"},h("span",null,actionLabel[decision.action]||decision.action),h("span",null,"\u7F6E\u4FE1\u5EA6 "+Math.round(Number(decision.confidence||0)*100)+"%"),decision.existingEventIds?.length?h("span",null,"\u5173\u8054 "+decision.existingEventIds.length+" \u6761"):null),decision.reason?h("div",{className:"sg-import-preview-reason"},decision.reason):null,decision.requiresConfirmation?h("label",{className:"sg-import-review"},h("span",null,"\u4EBA\u5DE5\u9009\u62E9"),h("select",{value:choices[index]||decision.action,onChange:event3=>setChoices(current=>({...current,[index]:event3.target.value}))},(decision.existingEventIds?.length?["ADD","MERGE","SUPERSEDE","CONFLICT","IGNORE"]:["ADD","IGNORE"]).map(action=>h("option",{key:action,value:action},actionLabel[action])))):null)))):null,job?.status==="failed"?h("div",{className:"sg-import-error"},"\u4EFB\u52A1\u5931\u8D25\uFF1A"+(job.lastError||"\u672A\u77E5\u9519\u8BEF")):null,connectionError?h("div",{className:"sg-import-hint"},connectionError):null,error3?h("div",{className:"sg-import-error"},error3):null,result?h("div",{className:"sg-import-result"},"\u5BFC\u5165\u5B8C\u6210\uFF1A\u65B0\u589E "+Number(result.importedCount||0)+" \u6761\u8BB0\u5FC6\u3002\u53EF\u7ACB\u5373\u64A4\u9500\u672C\u6279\u6B21\u3002"):null,h("footer",{className:"sg-import-dialog-foot"},result?h("button",{type:"button",className:"sg-import-cancel",disabled:busy,onClick:undo},busy?"\u6B63\u5728\u64A4\u9500\u2026":"\u64A4\u9500\u672C\u6B21\u5BFC\u5165"):h("button",{type:"button",className:"sg-import-cancel",onClick:onBack},running?"\u5173\u95ED\uFF0C\u540E\u53F0\u7EE7\u7EED":"\u53D6\u6D88"),result?h("button",{type:"button",className:"sg-import-button",disabled:busy,onClick:reset2},"\u5BFC\u5165\u53E6\u4E00\u6279"):job?.status==="failed"?h("button",{type:"button",className:"sg-import-button",disabled:busy,onClick:retry},busy?"\u6B63\u5728\u91CD\u8BD5\u2026":"\u91CD\u8BD5"):emptyJob?h("button",{type:"button",className:"sg-import-button",onClick:reset2},"\u5BFC\u5165\u53E6\u4E00\u6279"):reviewable?h("button",{type:"button",className:"sg-import-button",disabled:busy,onClick:commit},busy?"\u6B63\u5728\u5BFC\u5165\u2026":"\u786E\u8BA4\u5BFC\u5165"):running?h("button",{type:"button",className:"sg-import-button",disabled:!0},"\u540E\u53F0\u5904\u7406\u4E2D"):h("button",{type:"button",className:"sg-import-button",disabled:busy||!text.trim(),onClick:analyze},busy?"\u6B63\u5728\u521B\u5EFA\u4EFB\u52A1\u2026":"\u5206\u6790\u5E76\u9884\u89C8"))))}function MoreHome({selected,setView}){let rows=[["import","\u21C4","\u5BFC\u5165\u522B\u7684 AI \u8BB0\u5FC6","\u7C98\u8D34\u5916\u90E8 AI \u603B\u7ED3\u5E76\u5BFC\u5165"],["structure","\u25C7","\u8BB0\u5FC6\u7ED3\u6784","\u6D4F\u89C8 Event \u4E0E\u77E5\u8BC6\u56FE\u8C31"],["system","\u2713","\u7CFB\u7EDF\u72B6\u6001","\u5904\u7406\u4EFB\u52A1\u548C\u6700\u8FD1\u6574\u7406\u65F6\u95F4"],["audit","\u2197","\u4F7F\u7528\u8BB0\u5F55","\u957F\u671F\u8BB0\u5FC6\u4F55\u65F6\u88AB\u4F7F\u7528"],["raw","{}","\u539F\u59CB\u6570\u636E","Block\u3001Event\u3001Graph \u4E0E\u6A21\u578B\u54CD\u5E94"],["settings","\u2699","\u9AD8\u7EA7\u8BBE\u7F6E","Schema\u3001\u63D0\u53D6\u95F4\u9694\u4E0E\u9879\u76EE\u7A7A\u95F4"],["support","?","\u53CD\u9988\u4E0E\u652F\u6301","\u62A5\u544A\u95EE\u9898\u3001\u63D0\u51FA\u5EFA\u8BAE\u6216\u54A8\u8BE2\u4F7F\u7528\u65B9\u6CD5"]];return h(React.Fragment,null,h("div",{className:"sg-intro"},h("h2",null,"\u66F4\u591A"),h("p",null,"\u9AD8\u7EA7\u4FE1\u606F\u4E0E\u5DE5\u7A0B\u89C6\u56FE")),h("div",{className:"sg-menu"},rows.map(([id2,icon,title,subtitle])=>h("button",{key:id2,className:"sg-menu-row",onClick:()=>setView({name:id2})},h("span",{className:"sg-menu-icon","aria-hidden":"true"},icon),h("span",null,h("span",{className:"sg-menu-title"},title),h("br"),h("span",{className:"sg-menu-subtitle"},subtitle)),h("span",{className:"sg-chevron"},"\u203A")))))}function limitedJson(value,limit2=4500){let text=JSON.stringify(value,null,2).replace(/\b(?:sk|gh[opasu]|github_pat)_[A-Za-z0-9_-]{12,}\b/g,"[REDACTED_TOKEN]").replace(/\b(Bearer\s+)[A-Za-z0-9._~+/-]{12,}={0,2}\b/gi,"$1[REDACTED]").replace(/\b(api[_-]?key|token|password|secret)\s*[:=]\s*([^\s,;]+)/gi,"$1=[REDACTED]");return text.length>limit2?text.slice(0,limit2)+`
399
399
  \u2026\uFF08\u5185\u5BB9\u5DF2\u622A\u65AD\uFF09`:text}function safeErrorSummary(value){let firstLine=String(value||"").split(/\r?\n/,1)[0].trim();return firstLine.length>240?firstLine.slice(0,240)+"\u2026":firstLine}function SupportPage({overview,selected,project,data:data4,recentError,onBack}){let[includeLogs,setIncludeLogs]=React.useState(!1),[includeMemory,setIncludeMemory]=React.useState(!1),latestJobError=selected?.failedJobDetails?.[0]?.lastError||"",lines=["## \u81EA\u52A8\u8BCA\u65AD\u4FE1\u606F","","- StrataGate \u7248\u672C\uFF1A"+(overview.pluginVersion||"unknown"),"- Harness \u7248\u672C\uFF1A"+(overview.harnessVersion||"unknown"),"- \u5F53\u524D\u5DE5\u4F5C\u533A\uFF1A"+project,"- blockTurnSize\uFF1A"+(selected?.blockTurnSize??"unknown"),"- \u5DF2\u5C01\u5B58\u5757\uFF1A"+(selected?.blocks??0),"- Event / Graph Node \u6570\u91CF\uFF1A"+(selected?.events??0)+" / "+(selected?.graphNodes??0),"- \u6700\u8FD1\u9519\u8BEF\uFF1A"+(safeErrorSummary(recentError||latestJobError)||"\u65E0"),"","> \u9ED8\u8BA4\u8BCA\u65AD\u4E0D\u5305\u542B\u539F\u59CB\u804A\u5929\u3001L5\u3001Event \u6216 Graph \u5185\u5BB9\u3002"];includeLogs&&lines.push("","<details><summary>\u8BCA\u65AD\u65E5\u5FD7</summary>","","```json",limitedJson({frontendError:recentError||null,failedJobs:selected?.failedJobDetails||[]}),"```","</details>"),includeMemory&&lines.push("","<details><summary>\u7528\u6237\u4E3B\u52A8\u9644\u52A0\u7684\u8BB0\u5FC6\u6570\u636E\uFF08\u53EF\u80FD\u5305\u542B\u5BF9\u8BDD\u5185\u5BB9\uFF09</summary>","","```json",limitedJson({blocks:data4.blocks,events:data4.events,graph:data4.graph}),"```","</details>");let issueParams=new URLSearchParams({title:"[Bug] StrataGate\uFF1A",body:lines.join(`
400
- `)}),featureParams=new URLSearchParams({title:"[Feature] StrataGate\uFF1A",body:"\u8BF7\u63CF\u8FF0\u5E0C\u671B\u589E\u52A0\u7684\u80FD\u529B\u3001\u4F7F\u7528\u573A\u666F\u548C\u9884\u671F\u884C\u4E3A\u3002"});return h(React.Fragment,null,h(BackBar,{label:"\u66F4\u591A",onBack}),h("div",{className:"sg-intro"},h("h2",null,"\u53CD\u9988\u4E0E\u652F\u6301"),h("p",null,"\u9009\u62E9\u6700\u5408\u9002\u7684\u5165\u53E3\uFF0C\u6211\u4EEC\u4F1A\u5E26\u4E0A\u5FC5\u8981\u4E14\u5B89\u5168\u7684\u4E0A\u4E0B\u6587\u3002")),h("div",{className:"sg-privacy-note"},"\u57FA\u7840\u8BCA\u65AD\u4E0D\u4F1A\u9644\u5E26\u539F\u59CB\u804A\u5929\u3001L5\u3001Event \u6216 Graph \u5185\u5BB9\u3002"),h("section",{className:"sg-support-card"},h("h3",null,"\u9047\u5230\u95EE\u9898"),h("p",null,"\u63D2\u4EF6\u4F1A\u6574\u7406\u7248\u672C\u3001\u914D\u7F6E\u3001\u6570\u91CF\u548C\u6700\u8FD1\u9519\u8BEF\uFF0C\u5E2E\u52A9\u5FEB\u901F\u5B9A\u4F4D\u3002"),h("label",{className:"sg-check"},h("input",{type:"checkbox",checked:includeLogs,onChange:event3=>setIncludeLogs(event3.target.checked)}),h("span",null,"\u9644\u52A0\u8BCA\u65AD\u65E5\u5FD7")),h("label",{className:"sg-check"},h("input",{type:"checkbox",checked:includeMemory,onChange:event3=>setIncludeMemory(event3.target.checked)}),h("span",null,"\u9644\u52A0\u8BB0\u5FC6\u6570\u636E\uFF08\u53EF\u80FD\u5305\u542B\u5BF9\u8BDD\u5185\u5BB9\uFF09")),includeMemory?h("div",{className:"sg-error-note"},"\u4F60\u5DF2\u9009\u62E9\u9644\u52A0\u53EF\u80FD\u5305\u542B\u5BF9\u8BDD\u5185\u5BB9\u7684\u8BB0\u5FC6\u6570\u636E\uFF0C\u8BF7\u5728 GitHub \u63D0\u4EA4\u524D\u518D\u6B21\u68C0\u67E5\u3002"):null,h("a",{className:"sg-primary-link",href:ISSUE_URL+"?"+issueParams,target:"_blank",rel:"noopener noreferrer"},"\u5728 GitHub \u63D0\u4EA4 Issue")),h("section",{className:"sg-support-card"},h("h3",null,"\u529F\u80FD\u5EFA\u8BAE"),h("p",null,"\u63CF\u8FF0\u4F7F\u7528\u573A\u666F\u548C\u5E0C\u671B\u5B9E\u73B0\u7684\u884C\u4E3A\u3002"),h("a",{className:"sg-link",href:ISSUE_URL+"?"+featureParams,target:"_blank",rel:"noopener noreferrer"},"\u521B\u5EFA Feature Request \u2192")),h("section",{className:"sg-support-card"},h("h3",null,"\u4F7F\u7528\u7591\u95EE"),h("p",null,"\u5728 GitHub Discussion \u7684 Q&A \u533A\u4EA4\u6D41\u4F7F\u7528\u65B9\u6CD5\u3002"),h("a",{className:"sg-link",href:DISCUSSION_URL,target:"_blank",rel:"noopener noreferrer"},"\u524D\u5F80 Discussion / Q&A \u2192")))}function StructurePage({events,graph,openEvent,onBack}){return h(React.Fragment,null,h(BackBar,{label:"\u66F4\u591A",onBack}),h("div",{className:"sg-intro"},h("h2",null,"\u8BB0\u5FC6\u7ED3\u6784"),h("p",null,"\u5B8C\u6574\u6D4F\u89C8\u73B0\u6709\u7ED3\u6784\u5316\u8BB0\u5FC6")),h("div",{className:"sg-counts"},h("div",null,h("div",{className:"sg-count-value"},events.length),h("div",{className:"sg-count-label"},"\u7ECF\u5386 / Event")),h("div",null,h("div",{className:"sg-count-value"},graph.nodes.length),h("div",{className:"sg-count-label"},"\u77E5\u8BC6\u56FE\u8C31\u8282\u70B9"))),h("div",{className:"sg-structured-group"},h("h3",{className:"sg-section-title"},"\u7ECF\u5386"),events.map(event3=>h("button",{key:event3.id,className:"sg-related",onClick:()=>openEvent(event3)},h("span",null,event3.title),h("span",{className:"sg-related-time"},formatTime(event3.updatedAt))))),h("div",{className:"sg-structured-group"},h("h3",{className:"sg-section-title"},"\u56FE\u8C31\u8282\u70B9"),graph.nodes.map(node=>h("div",{key:node.id,className:"sg-related"},h("span",null,node.name),h("span",{className:"sg-related-time"},(node.sourceEventIds||[]).length+" \u6761\u652F\u6491\u4E8B\u4EF6")))))}function SystemPage({selected,blocks,onBack,refresh}){let processing=blocks.filter(block=>block.status==="processing").length;return h(React.Fragment,null,h(BackBar,{label:"\u66F4\u591A",onBack}),h("div",{className:"sg-intro"},h("h2",null,"\u7CFB\u7EDF\u72B6\u6001"),h("p",null,"\u4EC5\u5728\u8FD9\u91CC\u5C55\u793A\u8BB0\u5FC6\u5904\u7406\u7684\u5DE5\u7A0B\u72B6\u6001")),h("div",{className:"sg-pipeline"},[["Block \u6570\u91CF",selected.blocks],["\u5F85\u5904\u7406\u4EFB\u52A1",processing],["\u5931\u8D25\u4EFB\u52A1",selected.failedJobs],["\u6700\u8FD1\u6574\u7406\u65F6\u95F4",formatTime(selected.lastActivityAt)],["Event \u63D0\u53D6",selected.failedJobDetails?.some(item=>item.kind==="event-extraction")?"\u6709\u5931\u8D25":"\u6B63\u5E38"],["\u56FE\u8C31\u6295\u5F71",selected.failedJobDetails?.some(item=>item.kind==="graph-projection")?"\u6709\u5931\u8D25":"\u6B63\u5E38"]].map(([label,value])=>h("div",{key:label,className:"sg-stage"},h("span",null,label),h("span",{className:"sg-stage-value "+(label==="\u5931\u8D25\u4EFB\u52A1"&&value?"failed":"waiting")},String(value))))),h("button",{className:"sg-quiet-button",onClick:refresh,style:{marginTop:"14px"}},"\u21BB \u91CD\u65B0\u68C0\u67E5"))}function AuditPage({audit,onBack}){return h(React.Fragment,null,h(BackBar,{label:"\u66F4\u591A",onBack}),h("div",{className:"sg-intro"},h("h2",null,"\u4F7F\u7528\u8BB0\u5F55"),h("p",null,"\u957F\u671F\u8BB0\u5FC6\u88AB\u4F7F\u7528\u7684\u65F6\u95F4\u4E0E\u6765\u6E90")),audit.length?audit.map(item=>{let value=item.audit||{};return h("details",{key:item.id,className:"sg-audit"},h("summary",null,h("strong",null,"\u4F7F\u7528\u4E86 "+((item.events||[]).length+(item.elements||[]).length)+" \u6761\u8BB0\u5FC6"),h("span",{className:"sg-muted"}," \xB7 "+formatTime(item.createdAt))),h("div",{className:"sg-audit-body"},h("div",null,(item.events||[]).map(event3=>event3.title).join("\u3001")||(item.elements||[]).map(element3=>element3.name).join("\u3001")||"\u65E7\u7248\u4F7F\u7528\u8BB0\u5F55"),h("div",{className:"sg-tech-row sg-audit-evidence"},h("span",{className:"sg-muted"},"\u6765\u6E90\u4F1A\u8BDD"),h("span",{className:"sg-code"},value.sessionId||"\u672A\u8BB0\u5F55")),value.turn!==void 0?h("div",{className:"sg-tech-row"},h("span",{className:"sg-muted"},"Turn"),h("span",null,value.turn)):null))}):h(Empty,{title:"\u8FD8\u6CA1\u6709\u4F7F\u7528\u8BB0\u5F55",copy:"AI \u5728\u56DE\u7B54\u4E2D\u91C7\u7528\u957F\u671F\u8BB0\u5FC6\u540E\u4F1A\u8BB0\u5F55\u5728\u8FD9\u91CC\u3002"}))}function RawPage({data:data4,selected,onBack}){let groups=[["Block raw",data4.blocks],["Event raw",data4.events],["Graph raw",data4.graph],["Usage raw",data4.audit],["\u6A21\u578B\u54CD\u5E94",selected.successfulModelResponses||[]]];return h(React.Fragment,null,h(BackBar,{label:"\u66F4\u591A",onBack}),h("div",{className:"sg-intro"},h("h2",null,"\u539F\u59CB\u6570\u636E"),h("p",null,"\u4F9B\u6392\u67E5\u95EE\u9898\u4F7F\u7528\u7684\u5185\u90E8\u5B57\u6BB5\u4E0E JSON")),groups.map(([label,value])=>h("details",{key:label,className:"sg-raw-group"},h("summary",null,label+" ("+(Array.isArray(value)?value.length:(value.nodes?.length||0)+(value.edges?.length||0))+")"),h("pre",{className:"sg-raw-json sg-code"},JSON.stringify(value,null,2)))))}function SettingsPage({selected,namespace,onBack,updateSettings,savingSettings}){let[turnSize,setTurnSize]=React.useState(String(selected.blockTurnSize??6)),[lambda,setLambda]=React.useState(String(selected.blockDecayLambda??.3));React.useEffect(()=>{setTurnSize(String(selected.blockTurnSize??6)),setLambda(String(selected.blockDecayLambda??.3))},[selected.blockTurnSize,selected.blockDecayLambda]);let turnSizeValue=Number(turnSize),lambdaValue=Number(lambda),changed=Number.isSafeInteger(turnSizeValue)&&turnSizeValue>=1&&lambda!==""&&Number.isFinite(lambdaValue)&&lambdaValue>=0&&(turnSizeValue!==selected.blockTurnSize||lambdaValue!==selected.blockDecayLambda),suggestedLambda=Math.round((selected.blockDecayLambda??.3)*turnSizeValue/(selected.blockTurnSize||6)/.05)*.05,showSuggestion=Number.isSafeInteger(turnSizeValue)&&turnSizeValue>=1&&turnSizeValue!==selected.blockTurnSize,rows=[["Schema \u7248\u672C","v"+selected.schemaVersion],["\u6A21\u578B","\u7531 DSH \u5F53\u524D\u6A21\u578B\u914D\u7F6E\u63D0\u4F9B"],["\u5185\u90E8\u7A7A\u95F4 ID",namespace],["\u5DF2\u5904\u7406\u8F6E\u6B21",selected.currentTurn]];return h(React.Fragment,null,h(BackBar,{label:"\u66F4\u591A",onBack}),h("div",{className:"sg-intro"},h("h2",null,"\u9AD8\u7EA7\u8BBE\u7F6E"),h("p",null,"\u4FEE\u6539\u540E\u4F1A\u7ACB\u5373\u5E94\u7528\u5230\u6240\u6709\u5DF2\u6709\u5DE5\u4F5C\u533A\uFF0C\u5E76\u4F5C\u4E3A\u65B0\u5DE5\u4F5C\u533A\u7684\u9ED8\u8BA4\u503C\u3002")),h("div",{className:"sg-pipeline"},h("div",{className:"sg-stage"},h("span",null,"\u6BCF\u4E2A Block \u7684\u5BF9\u8BDD\u8F6E\u6570"),h("span",{className:"sg-lambda-control"},h("input",{className:"sg-number-input",type:"number",min:"1",step:"1",value:turnSize,onChange:event3=>setTurnSize(event3.target.value),"aria-label":"\u6BCF\u4E2A Block \u7684\u5BF9\u8BDD\u8F6E\u6570"}),h("span",{className:"sg-stage-value waiting"},"\u8F6E"))),h("p",{className:"sg-setting-note"},"1 \u8F6E\u662F\u4E00\u6B21\u7528\u6237\u63D0\u95EE\u548C AI \u5B8C\u6574\u56DE\u590D\u3002\u8F6E\u6570\u8D8A\u5C0F\uFF0CBlock \u751F\u6210\u8D8A\u9891\u7E41\uFF0C\u4E5F\u4F1A\u8BA9\u76F8\u540C\u957F\u5EA6\u7684\u5BF9\u8BDD\u8870\u51CF\u5F97\u66F4\u5FEB\uFF1B\u5DF2\u6709 Block \u4E0D\u4F1A\u91CD\u65B0\u5207\u5206\uFF0C\u5C1A\u672A\u5C01\u5B58\u7684\u5185\u5BB9\u6309\u65B0\u9608\u503C\u7EE7\u7EED\u5904\u7406\u3002"),h("div",{className:"sg-stage"},h("span",null,"Block \u8870\u51CF\u7CFB\u6570 \u03BB"),h("span",{className:"sg-lambda-control"},h("input",{className:"sg-number-input",type:"number",min:"0",step:"0.05",value:lambda,onChange:event3=>setLambda(event3.target.value),"aria-label":"Block \u8870\u51CF\u7CFB\u6570 \u03BB"}))),h("p",{className:"sg-setting-note"},"\u9ED8\u8BA4 0.3\uFF1B\u6570\u5B57\u8D8A\u5C0F\uFF0C\u8BB0\u5FC6\u9057\u5FD8\u8D8A\u6162\uFF0C\u6D88\u8017 token \u8D8A\u591A\uFF0C\u4E0D\u5EFA\u8BAE\u5927\u4E8E 0.4\u3002"),showSuggestion?h("div",{className:"sg-setting-suggestion"},h("span",null,"\u4E3A\u4FDD\u6301\u6309\u5BF9\u8BDD\u8F6E\u6570\u8BA1\u7B97\u7684\u9057\u5FD8\u901F\u5EA6\uFF0C\u5EFA\u8BAE \u03BB \u8C03\u6574\u4E3A "+suggestedLambda.toFixed(2)+"\u3002"),h("button",{type:"button",className:"sg-quiet-button",onClick:()=>setLambda(String(Number(suggestedLambda.toFixed(2))))},"\u91C7\u7528\u5EFA\u8BAE\u503C")):null,rows.map(([label,value])=>h("div",{key:label,className:"sg-stage"},h("span",null,label),h("span",{className:label==="\u5185\u90E8\u7A7A\u95F4 ID"?"sg-stage-value sg-code":"sg-stage-value"},String(value)))),h("button",{type:"button",className:"sg-save-button",disabled:!changed||savingSettings,onClick:()=>{updateSettings({blockTurnSize:turnSizeValue,blockDecayLambda:lambdaValue})}},savingSettings?"\u4FDD\u5B58\u4E2D\u2026":changed?"\u4FDD\u5B58\u8BBE\u7F6E":"\u5DF2\u4FDD\u5B58")))}function MemoryPage({useWorkspaces,useSessions}){let workspaceItems=useWorkspaces(state=>state.items),sessionById=useSessions(state=>state.byId||{}),[overview,setOverview]=React.useState({namespaces:[]}),[namespace,setNamespace]=React.useState(""),[workspaceTitles,setWorkspaceTitles]=React.useState({}),[workspaceSessionIds,setWorkspaceSessionIds]=React.useState({}),[conversationId,setConversationId]=React.useState(""),[section,setSection]=React.useState("short"),[view,setView]=React.useState({name:"root"}),[data4,setData]=React.useState({events:[],graph:{nodes:[],edges:[],migration:null},blocks:[],openBlock:null,conversations:[],activeThreadId:null,audit:[]}),[query,setQuery]=React.useState(""),[source,setSource]=React.useState(null),[loading,setLoading]=React.useState(!0),[error3,setError]=React.useState(""),[recentError,setRecentError]=React.useState(""),[savingSettings,setSavingSettings]=React.useState(!1),[pollFast,setPollFast]=React.useState(!1),dashboardRequestRef=React.useRef(null),dashboardEtagsRef=React.useRef(new Map),loadedNamespaceRef=React.useRef(""),reportError=reason=>{let message=String(reason?.message||reason);setError(message),setRecentError(message)};React.useEffect(()=>{let active=!0;return Promise.all((workspaceItems||[]).map(async workspace=>({key:await workspaceProjectKey(workspace.path),title:String(workspace.title||"").trim(),sessionIds:Array.isArray(workspace.sessionIds)?workspace.sessionIds.map(String):[]}))).then(entries=>{active&&(setWorkspaceTitles(Object.fromEntries(entries.filter(({key,title})=>key&&title).map(({key,title})=>[key,title]))),setWorkspaceSessionIds(Object.fromEntries(entries.filter(({key})=>key).map(({key,sessionIds})=>[key,sessionIds]))))}),()=>{active=!1}},[workspaceItems]);let loadDashboard=React.useCallback((activeNamespace,options2={})=>{let background=options2.background===!0;if(background&&dashboardRequestRef.current)return Promise.resolve(null);dashboardRequestRef.current?.abort();let controller=new AbortController;dashboardRequestRef.current=controller;let key=String(activeNamespace||"")+"\0"+String(options2.threadId||"");return background||setLoading(!0),background||setError(""),dashboardApi({...activeNamespace?{namespace:activeNamespace}:{},...options2.threadId?{threadId:options2.threadId}:{}},{etag:options2.force?"":dashboardEtagsRef.current.get(key),signal:controller.signal}).then(result=>{if(result.etag&&dashboardEtagsRef.current.set(key,result.etag),result.notModified||!result.data)return null;let next2=result.data;return setOverview(next2.overview||{namespaces:[]}),setPollFast(next2.processing===!0),next2.namespace&&(loadedNamespaceRef.current=next2.namespace,setNamespace(current=>next2.overview?.namespaces?.some(item=>item.namespace===current)?current:next2.namespace)),next2.data&&(setData(next2.data),setConversationId(next2.data.activeThreadId||"")),setError(""),next2}).catch(reason=>(reason?.name!=="AbortError"&&reportError(reason),null)).finally(()=>{dashboardRequestRef.current===controller&&(dashboardRequestRef.current=null),background||setLoading(!1)})},[]);React.useEffect(()=>(loadDashboard(""),()=>dashboardRequestRef.current?.abort()),[loadDashboard]),React.useEffect(()=>{!namespace||loadedNamespaceRef.current===namespace||(setConversationId(""),setView({name:"root"}),setSource(null),setData({events:[],graph:{nodes:[],edges:[],migration:null},blocks:[],openBlock:null,conversations:[],activeThreadId:null,audit:[]}),loadDashboard(namespace,{force:!0}))},[namespace,loadDashboard]),React.useEffect(()=>{if(!namespace)return;let stopped=!1,timer=null,schedule=delay2=>{stopped||document.hidden||(timer=window.setTimeout(run,delay2))},run=()=>{stopped||document.hidden||loadDashboard(namespace,{background:!0,threadId:conversationId}).finally(()=>{schedule(pollFast?2500:3e4)})},onVisibilityChange=()=>{document.hidden?(timer!==null&&window.clearTimeout(timer),timer=null,dashboardRequestRef.current?.abort()):run()};return document.addEventListener("visibilitychange",onVisibilityChange),schedule(pollFast?2500:3e4),()=>{stopped=!0,timer!==null&&window.clearTimeout(timer),document.removeEventListener("visibilitychange",onVisibilityChange)}},[namespace,conversationId,pollFast,loadDashboard]);let selected=(overview.namespaces||[]).find(item=>item.namespace===namespace),project=projectName(selected||namespace,workspaceTitles),activeProjectKey=namespace.includes(":project:")?namespace.split(":project:").pop():"",hostSessionIds=workspaceSessionIds[activeProjectKey]||[],memoryConversations=new Map(data4.conversations.map(conversation=>[conversation.id,conversation])),conversations=[],seenConversations=new Set;for(let id2 of hostSessionIds){let session=sessionById[id2];if(session?.parentId)continue;let memory=memoryConversations.get(id2),dshTitle=String(session?.title||"").trim();conversations.push({...memory||{},id:id2,label:dshTitle||memory?.label||"\u5BF9\u8BDD "+id2.slice(0,8)}),seenConversations.add(id2)}for(let memory of data4.conversations)seenConversations.has(memory.id)||conversations.push(memory);conversations.sort((left,right)=>left.id==="__legacy__"?1:right.id==="__legacy__"?-1:0);let failedCount=Number(selected?.failedJobs||0),processing=!error3&&(Number(selected?.processingJobs||0)>0||data4.blocks.some(block=>block.status==="processing")),goSection=next2=>{setSection(next2),setView({name:"root"}),setSource(null)},sourceParams=(kind,item)=>kind==="event"?{eventId:item.id}:kind==="element"?{elementId:item.id}:{blockId:item.id},loadSource=(kind,item)=>{setSource(null),api2("sources",{namespace,...sourceParams(kind,item)}).then(setSource).catch(reportError)},openWithSource=(kind,item)=>{setView(current=>({name:kind,item,back:current})),loadSource(kind,item)},openEvent=event3=>openWithSource("event",data4.events.find(item=>item.id===event3.id)||event3),goBack=()=>{let previous=view.back||{name:"root"};setView(previous),previous.item&&["event","block"].includes(previous.name)?loadSource(previous.name,previous.item):setSource(null)},backLabel=view.back?.name==="block"?"\u77ED\u671F\u8BB0\u5FC6":view.back?.name==="event"?"\u957F\u671F\u8BB0\u5FC6":view.back?.name==="structure"?"\u8BB0\u5FC6\u7ED3\u6784":section==="short"?"\u77ED\u671F\u8BB0\u5FC6":"\u957F\u671F\u8BB0\u5FC6",refresh=()=>loadDashboard(namespace,{threadId:conversationId,force:!0}),selectConversation=nextConversationId=>(setConversationId(nextConversationId),loadDashboard(namespace,{threadId:nextConversationId,force:!0})),updateSettings=values=>(setSavingSettings(!0),setError(""),api2("settings",values,{method:"PATCH"}).then(()=>loadDashboard(namespace,{threadId:conversationId,force:!0})).catch(reportError).finally(()=>setSavingSettings(!1))),moreBack=()=>setView({name:"root"}),content=null;return loading&&!selected?content=h(Loading):selected?view.name==="event"?content=h(EventDetail,{event:view.item,project,source,onBack:goBack,backLabel}):view.name==="status"?content=h(ProcessingStatus,{overview:selected,blocks:data4.blocks,onBack:()=>setView({name:"root"}),refresh}):view.name==="import"?content=h(ImportPage,{namespace,onBack:moreBack,refresh}):view.name==="structure"?content=h(StructurePage,{events:data4.events,graph:data4.graph,openEvent,onBack:moreBack}):view.name==="system"?content=h(SystemPage,{selected,blocks:data4.blocks,onBack:moreBack,refresh}):view.name==="audit"?content=h(AuditPage,{audit:data4.audit,onBack:moreBack}):view.name==="raw"?content=h(RawPage,{data:data4,selected,onBack:moreBack}):view.name==="settings"?content=h(SettingsPage,{selected,namespace,onBack:moreBack,updateSettings,savingSettings}):view.name==="support"?content=h(SupportPage,{overview,selected,project,data:data4,recentError,onBack:moreBack}):content=h(React.Fragment,null,h(FailureAlert,{count:failedCount,onOpen:()=>setView({name:"status"})}),loading?h(Loading):section==="short"?h(ShortTermPage,{key:namespace+":"+conversationId,blocks:data4.blocks,openBlock:data4.openBlock,conversations,activeThreadId:conversationId||data4.activeThreadId||"",namespace,onConversationChange:selectConversation,refresh}):section==="long"?h(LongTermPage,{events:data4.events,graph:data4.graph,project,query,setQuery,openEvent}):h(MoreHome,{setView})):content=h(Empty,{title:"\u8FD8\u6CA1\u6709\u8BB0\u5FC6",copy:"\u5B8C\u6210\u4E00\u4E9B DSH \u5BF9\u8BDD\u540E\uFF0C\u77ED\u671F\u8BB0\u5FC6\u548C\u957F\u671F\u8BB0\u5FC6\u4F1A\u51FA\u73B0\u5728\u8FD9\u91CC\u3002"}),h("main",{className:"sg-memory","data-testid":"stratagate-memory-ui"},h("style",null,css),h("header",{className:"sg-header"},h("a",{className:"sg-brand",href:STAR_REPOSITORY_URL,target:"_blank",rel:"noopener noreferrer"},h("img",{className:"sg-logo",src:MASCOT_DATA_URL,alt:"StrataGate \u5409\u7965\u7269"}),h("span",{className:"sg-brand-copy"},h("span",{className:"sg-brand-name"},"StrataGate-AgentMemory"),h("span",{className:"sg-brand-kicker"},"\u6709\u6765\u6E90\u3001\u53EF\u8FFD\u6EAF\u7684\u8DE8\u4F1A\u8BDD\u8BB0\u5FC6"))),h("div",{className:"sg-header-usage"},h("span",{className:"sg-usage-count","aria-label":"StrataGate \u5DF2\u5728\u5F53\u524D\u5DE5\u4F5C\u533A\u4E2D\u5E2E\u52A9\u4F7F\u7528\u8BB0\u5FC6 "+Number(selected?.memoryUseCount||0)+" \u6B21\u3002"},h("strong",{className:"sg-usage-number"},Number(selected?.memoryUseCount||0)),h("span",null,"\u6B21\u8BB0\u5FC6\u91C7\u7528")),h("a",{className:"sg-header-star",href:STAR_REPOSITORY_URL,target:"_blank",rel:"noopener noreferrer"},"\u4E3A StrataGate \u70B9 \u{1F31F}\u{1F31F}"))),h("div",{className:"sg-project"},h("span",{className:"sg-project-label"},"\u5F53\u524D\u5DE5\u4F5C\u533A\uFF1A"),h("select",{className:"sg-project-select",value:namespace,onChange:event3=>setNamespace(event3.target.value),"aria-label":"\u5F53\u524D\u5DE5\u4F5C\u533A"},(overview.namespaces||[]).map(item=>h("option",{key:item.namespace,value:item.namespace},projectName(item,workspaceTitles))))),h("nav",{className:"sg-tabs","aria-label":"\u8BB0\u5FC6\u89C6\u56FE"},[["short","\u77ED\u671F\u8BB0\u5FC6"],["long","\u957F\u671F\u8BB0\u5FC6"],["more","\u66F4\u591A"]].map(([id2,label])=>h("button",{key:id2,type:"button",className:"sg-tab "+(section===id2?"active":""),"aria-current":section===id2?"page":void 0,onClick:()=>goSection(id2)},label))),error3?h("div",{className:"sg-error"},h("div",{className:"sg-error-title"},"\u6682\u65F6\u65E0\u6CD5\u8BFB\u53D6\u5B8C\u6574\u8BB0\u5FC6"),h("div",null,"\u5DF2\u663E\u793A\u80FD\u591F\u8BFB\u53D6\u7684\u5185\u5BB9\uFF0C\u8BF7\u7A0D\u540E\u91CD\u65B0\u52A0\u8F7D\u3002"),h("details",null,h("summary",null,"\u6280\u672F\u8BE6\u60C5"),h("div",{className:"sg-code"},error3))):null,h(ProcessingAlert,{visible:processing}),h("section",{key:section+":"+view.name,className:"sg-view","aria-label":"StrataGate \u8BB0\u5FC6\u5185\u5BB9"},content),h("footer",{className:"sg-footer"},"\u53D1\u73B0\u95EE\u9898\uFF1F ",h("button",{type:"button",onClick:()=>{setSection("more"),setView({name:"support"}),setSource(null)}},"\u63D0\u4EA4\u53CD\u9988")))}function apply2(ctx){let slots=ctx.get("slots");slots&&slots.inject("settings.section",()=>slots.register({name:"settings.section",id:"stratagate-memory",order:32,label:()=>"StrataGate-AgentMemory"},props=>h(MemoryPage,props)))}return exports.name="stratagate-dsh",exports.inject=["slots"],exports.apply=apply2,module.exports}});})();
400
+ `)}),featureParams=new URLSearchParams({title:"[Feature] StrataGate\uFF1A",body:"\u8BF7\u63CF\u8FF0\u5E0C\u671B\u589E\u52A0\u7684\u80FD\u529B\u3001\u4F7F\u7528\u573A\u666F\u548C\u9884\u671F\u884C\u4E3A\u3002"});return h(React.Fragment,null,h(BackBar,{label:"\u66F4\u591A",onBack}),h("div",{className:"sg-intro"},h("h2",null,"\u53CD\u9988\u4E0E\u652F\u6301"),h("p",null,"\u9009\u62E9\u6700\u5408\u9002\u7684\u5165\u53E3\uFF0C\u6211\u4EEC\u4F1A\u5E26\u4E0A\u5FC5\u8981\u4E14\u5B89\u5168\u7684\u4E0A\u4E0B\u6587\u3002")),h("div",{className:"sg-privacy-note"},"\u57FA\u7840\u8BCA\u65AD\u4E0D\u4F1A\u9644\u5E26\u539F\u59CB\u804A\u5929\u3001L5\u3001Event \u6216 Graph \u5185\u5BB9\u3002"),h("section",{className:"sg-support-card"},h("h3",null,"\u9047\u5230\u95EE\u9898"),h("p",null,"\u63D2\u4EF6\u4F1A\u6574\u7406\u7248\u672C\u3001\u914D\u7F6E\u3001\u6570\u91CF\u548C\u6700\u8FD1\u9519\u8BEF\uFF0C\u5E2E\u52A9\u5FEB\u901F\u5B9A\u4F4D\u3002"),h("label",{className:"sg-check"},h("input",{type:"checkbox",checked:includeLogs,onChange:event3=>setIncludeLogs(event3.target.checked)}),h("span",null,"\u9644\u52A0\u8BCA\u65AD\u65E5\u5FD7")),h("label",{className:"sg-check"},h("input",{type:"checkbox",checked:includeMemory,onChange:event3=>setIncludeMemory(event3.target.checked)}),h("span",null,"\u9644\u52A0\u8BB0\u5FC6\u6570\u636E\uFF08\u53EF\u80FD\u5305\u542B\u5BF9\u8BDD\u5185\u5BB9\uFF09")),includeMemory?h("div",{className:"sg-error-note"},"\u4F60\u5DF2\u9009\u62E9\u9644\u52A0\u53EF\u80FD\u5305\u542B\u5BF9\u8BDD\u5185\u5BB9\u7684\u8BB0\u5FC6\u6570\u636E\uFF0C\u8BF7\u5728 GitHub \u63D0\u4EA4\u524D\u518D\u6B21\u68C0\u67E5\u3002"):null,h("a",{className:"sg-primary-link",href:ISSUE_URL+"?"+issueParams,target:"_blank",rel:"noopener noreferrer"},"\u5728 GitHub \u63D0\u4EA4 Issue")),h("section",{className:"sg-support-card"},h("h3",null,"\u529F\u80FD\u5EFA\u8BAE"),h("p",null,"\u63CF\u8FF0\u4F7F\u7528\u573A\u666F\u548C\u5E0C\u671B\u5B9E\u73B0\u7684\u884C\u4E3A\u3002"),h("a",{className:"sg-link",href:ISSUE_URL+"?"+featureParams,target:"_blank",rel:"noopener noreferrer"},"\u521B\u5EFA Feature Request \u2192")),h("section",{className:"sg-support-card"},h("h3",null,"\u4F7F\u7528\u7591\u95EE"),h("p",null,"\u5728 GitHub Discussion \u7684 Q&A \u533A\u4EA4\u6D41\u4F7F\u7528\u65B9\u6CD5\u3002"),h("a",{className:"sg-link",href:DISCUSSION_URL,target:"_blank",rel:"noopener noreferrer"},"\u524D\u5F80 Discussion / Q&A \u2192")))}function StructurePage({events,eventPage,graph,openEvent,namespace,onBack}){let pagedEvents=usePagedMemory({namespace,kind:"events",initialItems:events,initialPage:eventPage,fallbackLimit:40});return h(React.Fragment,null,h(BackBar,{label:"\u66F4\u591A",onBack}),h("div",{className:"sg-intro"},h("h2",null,"\u8BB0\u5FC6\u7ED3\u6784"),h("p",null,"\u5B8C\u6574\u6D4F\u89C8\u73B0\u6709\u7ED3\u6784\u5316\u8BB0\u5FC6")),h("div",{className:"sg-counts"},h("div",null,h("div",{className:"sg-count-value"},pagedEvents.page.total),h("div",{className:"sg-count-label"},"\u7ECF\u5386 / Event")),h("div",null,h("div",{className:"sg-count-value"},graph.nodes.length),h("div",{className:"sg-count-label"},"\u77E5\u8BC6\u56FE\u8C31\u8282\u70B9"))),h("div",{className:"sg-structured-group"},h("h3",{className:"sg-section-title"},"\u7ECF\u5386"),pagedEvents.items.map(event3=>h("button",{key:event3.id,className:"sg-related",onClick:()=>openEvent(event3)},h("span",null,event3.title),h("span",{className:"sg-related-time"},formatTime(event3.updatedAt))))),h(Pagination,{page:pagedEvents.page,loading:pagedEvents.loading,error:pagedEvents.error,onOffset:pagedEvents.loadOffset}),h("div",{className:"sg-structured-group"},h("h3",{className:"sg-section-title"},"\u56FE\u8C31\u8282\u70B9"),graph.nodes.map(node=>h("div",{key:node.id,className:"sg-related"},h("span",null,node.name),h("span",{className:"sg-related-time"},(node.sourceEventIds||[]).length+" \u6761\u652F\u6491\u4E8B\u4EF6")))))}function SystemPage({selected,blocks,onBack,refresh}){let processing=blocks.filter(block=>block.status==="processing").length;return h(React.Fragment,null,h(BackBar,{label:"\u66F4\u591A",onBack}),h("div",{className:"sg-intro"},h("h2",null,"\u7CFB\u7EDF\u72B6\u6001"),h("p",null,"\u4EC5\u5728\u8FD9\u91CC\u5C55\u793A\u8BB0\u5FC6\u5904\u7406\u7684\u5DE5\u7A0B\u72B6\u6001")),h("div",{className:"sg-pipeline"},[["Block \u6570\u91CF",selected.blocks],["\u5F85\u5904\u7406\u4EFB\u52A1",processing],["\u5931\u8D25\u4EFB\u52A1",selected.failedJobs],["\u6700\u8FD1\u6574\u7406\u65F6\u95F4",formatTime(selected.lastActivityAt)],["Event \u63D0\u53D6",selected.failedJobDetails?.some(item=>item.kind==="event-extraction")?"\u6709\u5931\u8D25":"\u6B63\u5E38"],["\u56FE\u8C31\u6295\u5F71",selected.failedJobDetails?.some(item=>item.kind==="graph-projection")?"\u6709\u5931\u8D25":"\u6B63\u5E38"]].map(([label,value])=>h("div",{key:label,className:"sg-stage"},h("span",null,label),h("span",{className:"sg-stage-value "+(label==="\u5931\u8D25\u4EFB\u52A1"&&value?"failed":"waiting")},String(value))))),h("button",{className:"sg-quiet-button",onClick:refresh,style:{marginTop:"14px"}},"\u21BB \u91CD\u65B0\u68C0\u67E5"))}function AuditPage({audit,auditPage,namespace,onBack}){let pagedAudit=usePagedMemory({namespace,kind:"audit",initialItems:audit,initialPage:auditPage,fallbackLimit:100});return h(React.Fragment,null,h(BackBar,{label:"\u66F4\u591A",onBack}),h("div",{className:"sg-intro"},h("h2",null,"\u4F7F\u7528\u8BB0\u5F55"),h("p",null,"\u957F\u671F\u8BB0\u5FC6\u88AB\u4F7F\u7528\u7684\u65F6\u95F4\u4E0E\u6765\u6E90")),pagedAudit.items.length?pagedAudit.items.map(item=>{let value=item.audit||{};return h("details",{key:item.id,className:"sg-audit"},h("summary",null,h("strong",null,"\u4F7F\u7528\u4E86 "+((item.events||[]).length+(item.elements||[]).length)+" \u6761\u8BB0\u5FC6"),h("span",{className:"sg-muted"}," \xB7 "+formatTime(item.createdAt))),h("div",{className:"sg-audit-body"},h("div",null,(item.events||[]).map(event3=>event3.title).join("\u3001")||(item.elements||[]).map(element3=>element3.name).join("\u3001")||"\u65E7\u7248\u4F7F\u7528\u8BB0\u5F55"),h("div",{className:"sg-tech-row sg-audit-evidence"},h("span",{className:"sg-muted"},"\u6765\u6E90\u4F1A\u8BDD"),h("span",{className:"sg-code"},value.sessionId||"\u672A\u8BB0\u5F55")),value.turn!==void 0?h("div",{className:"sg-tech-row"},h("span",{className:"sg-muted"},"Turn"),h("span",null,value.turn)):null))}):h(Empty,{title:"\u8FD8\u6CA1\u6709\u4F7F\u7528\u8BB0\u5F55",copy:"AI \u5728\u56DE\u7B54\u4E2D\u91C7\u7528\u957F\u671F\u8BB0\u5FC6\u540E\u4F1A\u8BB0\u5F55\u5728\u8FD9\u91CC\u3002"}),h(Pagination,{page:pagedAudit.page,loading:pagedAudit.loading,error:pagedAudit.error,onOffset:pagedAudit.loadOffset}))}function RawPage({data:data4,selected,onBack}){let groups=[["Block raw",data4.blocks,data4.pagination?.blocks?.total],["Event raw",data4.events,data4.pagination?.events?.total],["Graph raw",data4.graph],["Usage raw",data4.audit,data4.pagination?.audit?.total],["\u6A21\u578B\u54CD\u5E94",selected.successfulModelResponses||[]]];return h(React.Fragment,null,h(BackBar,{label:"\u66F4\u591A",onBack}),h("div",{className:"sg-intro"},h("h2",null,"\u539F\u59CB\u6570\u636E"),h("p",null,"\u4F9B\u6392\u67E5\u95EE\u9898\u4F7F\u7528\u7684\u5185\u90E8\u5B57\u6BB5\u4E0E JSON")),groups.map(([label,value,total])=>h("details",{key:label,className:"sg-raw-group"},h("summary",null,label+" ("+(Array.isArray(value)&&Number(total)>value.length?"\u5DF2\u52A0\u8F7D "+value.length+" / \u5171 "+total:Array.isArray(value)?value.length:(value.nodes?.length||0)+(value.edges?.length||0))+")"),h("pre",{className:"sg-raw-json sg-code"},JSON.stringify(value,null,2)))))}function SettingsPage({selected,namespace,onBack,updateSettings,savingSettings}){let[turnSize,setTurnSize]=React.useState(String(selected.blockTurnSize??6)),[lambda,setLambda]=React.useState(String(selected.blockDecayLambda??.3));React.useEffect(()=>{setTurnSize(String(selected.blockTurnSize??6)),setLambda(String(selected.blockDecayLambda??.3))},[selected.blockTurnSize,selected.blockDecayLambda]);let turnSizeValue=Number(turnSize),lambdaValue=Number(lambda),changed=Number.isSafeInteger(turnSizeValue)&&turnSizeValue>=1&&lambda!==""&&Number.isFinite(lambdaValue)&&lambdaValue>=0&&(turnSizeValue!==selected.blockTurnSize||lambdaValue!==selected.blockDecayLambda),suggestedLambda=Math.round((selected.blockDecayLambda??.3)*turnSizeValue/(selected.blockTurnSize||6)/.05)*.05,showSuggestion=Number.isSafeInteger(turnSizeValue)&&turnSizeValue>=1&&turnSizeValue!==selected.blockTurnSize,rows=[["Schema \u7248\u672C","v"+selected.schemaVersion],["\u6A21\u578B","\u7531 DSH \u5F53\u524D\u6A21\u578B\u914D\u7F6E\u63D0\u4F9B"],["\u5185\u90E8\u7A7A\u95F4 ID",namespace],["\u5DF2\u5904\u7406\u8F6E\u6B21",selected.currentTurn]];return h(React.Fragment,null,h(BackBar,{label:"\u66F4\u591A",onBack}),h("div",{className:"sg-intro"},h("h2",null,"\u9AD8\u7EA7\u8BBE\u7F6E"),h("p",null,"\u4FEE\u6539\u540E\u4F1A\u7ACB\u5373\u5E94\u7528\u5230\u6240\u6709\u5DF2\u6709\u5DE5\u4F5C\u533A\uFF0C\u5E76\u4F5C\u4E3A\u65B0\u5DE5\u4F5C\u533A\u7684\u9ED8\u8BA4\u503C\u3002")),h("div",{className:"sg-pipeline"},h("div",{className:"sg-stage"},h("span",null,"\u6BCF\u4E2A Block \u7684\u5BF9\u8BDD\u8F6E\u6570"),h("span",{className:"sg-lambda-control"},h("input",{className:"sg-number-input",type:"number",min:"1",step:"1",value:turnSize,onChange:event3=>setTurnSize(event3.target.value),"aria-label":"\u6BCF\u4E2A Block \u7684\u5BF9\u8BDD\u8F6E\u6570"}),h("span",{className:"sg-stage-value waiting"},"\u8F6E"))),h("p",{className:"sg-setting-note"},"1 \u8F6E\u662F\u4E00\u6B21\u7528\u6237\u63D0\u95EE\u548C AI \u5B8C\u6574\u56DE\u590D\u3002\u8F6E\u6570\u8D8A\u5C0F\uFF0CBlock \u751F\u6210\u8D8A\u9891\u7E41\uFF0C\u4E5F\u4F1A\u8BA9\u76F8\u540C\u957F\u5EA6\u7684\u5BF9\u8BDD\u8870\u51CF\u5F97\u66F4\u5FEB\uFF1B\u5DF2\u6709 Block \u4E0D\u4F1A\u91CD\u65B0\u5207\u5206\uFF0C\u5C1A\u672A\u5C01\u5B58\u7684\u5185\u5BB9\u6309\u65B0\u9608\u503C\u7EE7\u7EED\u5904\u7406\u3002"),h("div",{className:"sg-stage"},h("span",null,"Block \u8870\u51CF\u7CFB\u6570 \u03BB"),h("span",{className:"sg-lambda-control"},h("input",{className:"sg-number-input",type:"number",min:"0",step:"0.05",value:lambda,onChange:event3=>setLambda(event3.target.value),"aria-label":"Block \u8870\u51CF\u7CFB\u6570 \u03BB"}))),h("p",{className:"sg-setting-note"},"\u9ED8\u8BA4 0.3\uFF1B\u6570\u5B57\u8D8A\u5C0F\uFF0C\u8BB0\u5FC6\u9057\u5FD8\u8D8A\u6162\uFF0C\u6D88\u8017 token \u8D8A\u591A\uFF0C\u4E0D\u5EFA\u8BAE\u5927\u4E8E 0.4\u3002"),showSuggestion?h("div",{className:"sg-setting-suggestion"},h("span",null,"\u4E3A\u4FDD\u6301\u6309\u5BF9\u8BDD\u8F6E\u6570\u8BA1\u7B97\u7684\u9057\u5FD8\u901F\u5EA6\uFF0C\u5EFA\u8BAE \u03BB \u8C03\u6574\u4E3A "+suggestedLambda.toFixed(2)+"\u3002"),h("button",{type:"button",className:"sg-quiet-button",onClick:()=>setLambda(String(Number(suggestedLambda.toFixed(2))))},"\u91C7\u7528\u5EFA\u8BAE\u503C")):null,rows.map(([label,value])=>h("div",{key:label,className:"sg-stage"},h("span",null,label),h("span",{className:label==="\u5185\u90E8\u7A7A\u95F4 ID"?"sg-stage-value sg-code":"sg-stage-value"},String(value)))),h("button",{type:"button",className:"sg-save-button",disabled:!changed||savingSettings,onClick:()=>{updateSettings({blockTurnSize:turnSizeValue,blockDecayLambda:lambdaValue})}},savingSettings?"\u4FDD\u5B58\u4E2D\u2026":changed?"\u4FDD\u5B58\u8BBE\u7F6E":"\u5DF2\u4FDD\u5B58")))}function MemoryPage({useWorkspaces,useSessions}){let workspaceItems=useWorkspaces(state=>state.items),sessionById=useSessions(state=>state.byId||{}),[overview,setOverview]=React.useState({namespaces:[]}),[namespace,setNamespace]=React.useState(""),[workspaceTitles,setWorkspaceTitles]=React.useState({}),[workspaceSessionIds,setWorkspaceSessionIds]=React.useState({}),[conversationId,setConversationId]=React.useState(""),[section,setSection]=React.useState("short"),[view,setView]=React.useState({name:"root"}),[data4,setData]=React.useState({events:[],graph:{nodes:[],edges:[],migration:null},blocks:[],openBlock:null,conversations:[],activeThreadId:null,audit:[],pagination:{events:{total:0,offset:0,limit:40},blocks:{total:0,offset:0,limit:40},audit:{total:0,offset:0,limit:100}}}),[query,setQuery]=React.useState(""),[source,setSource]=React.useState(null),[loading,setLoading]=React.useState(!0),[error3,setError]=React.useState(""),[recentError,setRecentError]=React.useState(""),[savingSettings,setSavingSettings]=React.useState(!1),[pollFast,setPollFast]=React.useState(!1),dashboardRequestRef=React.useRef(null),dashboardEtagsRef=React.useRef(new Map),loadedNamespaceRef=React.useRef(""),reportError=reason=>{let message=String(reason?.message||reason);setError(message),setRecentError(message)};React.useEffect(()=>{let active=!0;return Promise.all((workspaceItems||[]).map(async workspace=>({key:await workspaceProjectKey(workspace.path),title:String(workspace.title||"").trim(),sessionIds:Array.isArray(workspace.sessionIds)?workspace.sessionIds.map(String):[]}))).then(entries=>{active&&(setWorkspaceTitles(Object.fromEntries(entries.filter(({key,title})=>key&&title).map(({key,title})=>[key,title]))),setWorkspaceSessionIds(Object.fromEntries(entries.filter(({key})=>key).map(({key,sessionIds})=>[key,sessionIds]))))}),()=>{active=!1}},[workspaceItems]);let loadDashboard=React.useCallback((activeNamespace,options2={})=>{let background=options2.background===!0;if(background&&dashboardRequestRef.current)return Promise.resolve(null);dashboardRequestRef.current?.abort();let controller=new AbortController;dashboardRequestRef.current=controller;let key=String(activeNamespace||"")+"\0"+String(options2.threadId||"");return background||setLoading(!0),background||setError(""),dashboardApi({...activeNamespace?{namespace:activeNamespace}:{},...options2.threadId?{threadId:options2.threadId}:{}},{etag:options2.force?"":dashboardEtagsRef.current.get(key),signal:controller.signal}).then(result=>{if(result.etag&&dashboardEtagsRef.current.set(key,result.etag),result.notModified||!result.data)return null;let next2=result.data;return setOverview(next2.overview||{namespaces:[]}),setPollFast(next2.processing===!0),next2.namespace&&(loadedNamespaceRef.current=next2.namespace,setNamespace(current=>next2.overview?.namespaces?.some(item=>item.namespace===current)?current:next2.namespace)),next2.data&&(setData(next2.data),setConversationId(next2.data.activeThreadId||"")),setError(""),next2}).catch(reason=>(reason?.name!=="AbortError"&&reportError(reason),null)).finally(()=>{dashboardRequestRef.current===controller&&(dashboardRequestRef.current=null),background||setLoading(!1)})},[]);React.useEffect(()=>(loadDashboard(""),()=>dashboardRequestRef.current?.abort()),[loadDashboard]),React.useEffect(()=>{!namespace||loadedNamespaceRef.current===namespace||(setConversationId(""),setView({name:"root"}),setSource(null),setData({events:[],graph:{nodes:[],edges:[],migration:null},blocks:[],openBlock:null,conversations:[],activeThreadId:null,audit:[],pagination:{events:{total:0,offset:0,limit:40},blocks:{total:0,offset:0,limit:40},audit:{total:0,offset:0,limit:100}}}),loadDashboard(namespace,{force:!0}))},[namespace,loadDashboard]),React.useEffect(()=>{if(!namespace)return;let stopped=!1,timer=null,schedule=delay2=>{stopped||document.hidden||(timer=window.setTimeout(run,delay2))},run=()=>{stopped||document.hidden||loadDashboard(namespace,{background:!0,threadId:conversationId}).finally(()=>{schedule(pollFast?2500:3e4)})},onVisibilityChange=()=>{document.hidden?(timer!==null&&window.clearTimeout(timer),timer=null,dashboardRequestRef.current?.abort()):run()};return document.addEventListener("visibilitychange",onVisibilityChange),schedule(pollFast?2500:3e4),()=>{stopped=!0,timer!==null&&window.clearTimeout(timer),document.removeEventListener("visibilitychange",onVisibilityChange)}},[namespace,conversationId,pollFast,loadDashboard]);let selected=(overview.namespaces||[]).find(item=>item.namespace===namespace),project=projectName(selected||namespace,workspaceTitles),activeProjectKey=namespace.includes(":project:")?namespace.split(":project:").pop():"",hostSessionIds=workspaceSessionIds[activeProjectKey]||[],memoryConversations=new Map(data4.conversations.map(conversation=>[conversation.id,conversation])),conversations=[],seenConversations=new Set;for(let id2 of hostSessionIds){let session=sessionById[id2];if(session?.parentId)continue;let memory=memoryConversations.get(id2),dshTitle=String(session?.title||"").trim();conversations.push({...memory||{},id:id2,label:dshTitle||memory?.label||"\u5BF9\u8BDD "+id2.slice(0,8)}),seenConversations.add(id2)}for(let memory of data4.conversations)seenConversations.has(memory.id)||conversations.push(memory);conversations.sort((left,right)=>left.id==="__legacy__"?1:right.id==="__legacy__"?-1:0);let failedCount=Number(selected?.failedJobs||0),processing=!error3&&(Number(selected?.processingJobs||0)>0||data4.blocks.some(block=>block.status==="processing")),goSection=next2=>{setSection(next2),setView({name:"root"}),setSource(null)},sourceParams=(kind,item)=>kind==="event"?{eventId:item.id}:kind==="element"?{elementId:item.id}:{blockId:item.id},loadSource=(kind,item)=>{setSource(null),api2("sources",{namespace,...sourceParams(kind,item)}).then(setSource).catch(reportError)},openWithSource=(kind,item)=>{setView(current=>({name:kind,item,back:current})),loadSource(kind,item)},openEvent=event3=>openWithSource("event",data4.events.find(item=>item.id===event3.id)||event3),goBack=()=>{let previous=view.back||{name:"root"};setView(previous),previous.item&&["event","block"].includes(previous.name)?loadSource(previous.name,previous.item):setSource(null)},backLabel=view.back?.name==="block"?"\u77ED\u671F\u8BB0\u5FC6":view.back?.name==="event"?"\u957F\u671F\u8BB0\u5FC6":view.back?.name==="structure"?"\u8BB0\u5FC6\u7ED3\u6784":section==="short"?"\u77ED\u671F\u8BB0\u5FC6":"\u957F\u671F\u8BB0\u5FC6",refresh=()=>loadDashboard(namespace,{threadId:conversationId,force:!0}),selectConversation=nextConversationId=>(setConversationId(nextConversationId),loadDashboard(namespace,{threadId:nextConversationId,force:!0})),updateSettings=values=>(setSavingSettings(!0),setError(""),api2("settings",values,{method:"PATCH"}).then(()=>loadDashboard(namespace,{threadId:conversationId,force:!0})).catch(reportError).finally(()=>setSavingSettings(!1))),moreBack=()=>setView({name:"root"}),content=null;return loading&&!selected?content=h(Loading):selected?view.name==="event"?content=h(EventDetail,{event:view.item,project,source,onBack:goBack,backLabel}):view.name==="status"?content=h(ProcessingStatus,{overview:selected,blocks:data4.blocks,onBack:()=>setView({name:"root"}),refresh}):view.name==="import"?content=h(ImportPage,{namespace,onBack:moreBack,refresh}):view.name==="structure"?content=h(StructurePage,{events:data4.events,eventPage:data4.pagination?.events,graph:data4.graph,openEvent,namespace,onBack:moreBack}):view.name==="system"?content=h(SystemPage,{selected,blocks:data4.blocks,onBack:moreBack,refresh}):view.name==="audit"?content=h(AuditPage,{audit:data4.audit,auditPage:data4.pagination?.audit,namespace,onBack:moreBack}):view.name==="raw"?content=h(RawPage,{data:data4,selected,onBack:moreBack}):view.name==="settings"?content=h(SettingsPage,{selected,namespace,onBack:moreBack,updateSettings,savingSettings}):view.name==="support"?content=h(SupportPage,{overview,selected,project,data:data4,recentError,onBack:moreBack}):content=h(React.Fragment,null,h(FailureAlert,{count:failedCount,onOpen:()=>setView({name:"status"})}),loading?h(Loading):section==="short"?h(ShortTermPage,{key:namespace+":"+conversationId,blocks:data4.blocks,blockPage:data4.pagination?.blocks,openBlock:data4.openBlock,conversations,activeThreadId:conversationId||data4.activeThreadId||"",namespace,onConversationChange:selectConversation,refresh}):section==="long"?h(LongTermPage,{key:namespace,events:data4.events,eventPage:data4.pagination?.events,graph:data4.graph,project,query,setQuery,openEvent,namespace}):h(MoreHome,{setView})):content=h(Empty,{title:"\u8FD8\u6CA1\u6709\u8BB0\u5FC6",copy:"\u5B8C\u6210\u4E00\u4E9B DSH \u5BF9\u8BDD\u540E\uFF0C\u77ED\u671F\u8BB0\u5FC6\u548C\u957F\u671F\u8BB0\u5FC6\u4F1A\u51FA\u73B0\u5728\u8FD9\u91CC\u3002"}),h("main",{className:"sg-memory","data-testid":"stratagate-memory-ui"},h("style",null,css),h("header",{className:"sg-header"},h("a",{className:"sg-brand",href:STAR_REPOSITORY_URL,target:"_blank",rel:"noopener noreferrer"},h("img",{className:"sg-logo",src:MASCOT_DATA_URL,alt:"StrataGate \u5409\u7965\u7269"}),h("span",{className:"sg-brand-copy"},h("span",{className:"sg-brand-name"},"StrataGate-AgentMemory"),h("span",{className:"sg-brand-kicker"},"\u6709\u6765\u6E90\u3001\u53EF\u8FFD\u6EAF\u7684\u8DE8\u4F1A\u8BDD\u8BB0\u5FC6"))),h("div",{className:"sg-header-usage"},h("span",{className:"sg-usage-count","aria-label":"StrataGate \u5DF2\u5728\u5F53\u524D\u5DE5\u4F5C\u533A\u4E2D\u5E2E\u52A9\u4F7F\u7528\u8BB0\u5FC6 "+Number(selected?.memoryUseCount||0)+" \u6B21\u3002"},h("strong",{className:"sg-usage-number"},Number(selected?.memoryUseCount||0)),h("span",null,"\u6B21\u8BB0\u5FC6\u91C7\u7528")),h("a",{className:"sg-header-star",href:STAR_REPOSITORY_URL,target:"_blank",rel:"noopener noreferrer"},"\u4E3A StrataGate \u70B9 \u{1F31F}\u{1F31F}"))),h("div",{className:"sg-project"},h("span",{className:"sg-project-label"},"\u5F53\u524D\u5DE5\u4F5C\u533A\uFF1A"),h("select",{className:"sg-project-select",value:namespace,onChange:event3=>setNamespace(event3.target.value),"aria-label":"\u5F53\u524D\u5DE5\u4F5C\u533A"},(overview.namespaces||[]).map(item=>h("option",{key:item.namespace,value:item.namespace},projectName(item,workspaceTitles))))),h("nav",{className:"sg-tabs","aria-label":"\u8BB0\u5FC6\u89C6\u56FE"},[["short","\u77ED\u671F\u8BB0\u5FC6"],["long","\u957F\u671F\u8BB0\u5FC6"],["more","\u66F4\u591A"]].map(([id2,label])=>h("button",{key:id2,type:"button",className:"sg-tab "+(section===id2?"active":""),"aria-current":section===id2?"page":void 0,onClick:()=>goSection(id2)},label))),error3?h("div",{className:"sg-error"},h("div",{className:"sg-error-title"},"\u6682\u65F6\u65E0\u6CD5\u8BFB\u53D6\u5B8C\u6574\u8BB0\u5FC6"),h("div",null,"\u5DF2\u663E\u793A\u80FD\u591F\u8BFB\u53D6\u7684\u5185\u5BB9\uFF0C\u8BF7\u7A0D\u540E\u91CD\u65B0\u52A0\u8F7D\u3002"),h("details",null,h("summary",null,"\u6280\u672F\u8BE6\u60C5"),h("div",{className:"sg-code"},error3))):null,h(ProcessingAlert,{visible:processing}),h("section",{key:section+":"+view.name,className:"sg-view","aria-label":"StrataGate \u8BB0\u5FC6\u5185\u5BB9"},content),h("footer",{className:"sg-footer"},"\u53D1\u73B0\u95EE\u9898\uFF1F ",h("button",{type:"button",onClick:()=>{setSection("more"),setView({name:"support"}),setSource(null)}},"\u63D0\u4EA4\u53CD\u9988")))}function apply2(ctx){let slots=ctx.get("slots");slots&&slots.inject("settings.section",()=>slots.register({name:"settings.section",id:"stratagate-memory",order:32,label:()=>"StrataGate-AgentMemory"},props=>h(MemoryPage,props)))}return exports.name="stratagate-dsh",exports.inject=["slots"],exports.apply=apply2,module.exports}});})();