@runweave/server-linux-arm64 0.0.0-stage → 0.1.2
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/manifest.json +1993 -0
- package/native.tar.gz +0 -0
- package/package.json +22 -4
- package/payload/app-server/build-info.json +8 -0
- package/payload/app-server/configuration-compatibility.json +1 -0
- package/payload/app-server/index.cjs +43560 -0
- package/payload/app-server/index.cjs.map +1 -0
- package/payload/backend/activity-sqlite-worker.cjs +6730 -0
- package/payload/backend/build-info.json +8 -0
- package/payload/backend/dev-resources/control.cjs +14727 -0
- package/payload/backend/evolution-sqlite-worker.cjs +2073 -0
- package/payload/backend/index.cjs +135617 -0
- package/payload/backend/ios-simulators/device_shutdown.py +22 -0
- package/payload/backend/ios-simulators/monitor.py +204 -0
- package/payload/backend/ios-simulators/pool.py +600 -0
- package/payload/backend/scheduled-tasks-sqlite-worker.cjs +29203 -0
- package/payload/bin/runtime.cjs +95 -0
- package/payload/frontend/dist/assets/_baseUniq-B6OtH5JH.js +1 -0
- package/payload/frontend/dist/assets/access-CpH3nCnI.js +1 -0
- package/payload/frontend/dist/assets/advanced-U5MqNTD5.js +1 -0
- package/payload/frontend/dist/assets/appearance-Cb8XjaOT.js +1 -0
- package/payload/frontend/dist/assets/arc-CEnFQNMK.js +1 -0
- package/payload/frontend/dist/assets/architectureDiagram-Q4EWVU46-T438RyEG.js +36 -0
- package/payload/frontend/dist/assets/blockDiagram-DXYQGD6D-B6Mqb9og.js +132 -0
- package/payload/frontend/dist/assets/browser-CIEzmzuD.js +8 -0
- package/payload/frontend/dist/assets/c4Diagram-AHTNJAMY-CO3eA3hw.js +10 -0
- package/payload/frontend/dist/assets/channel-D7VgadXd.js +1 -0
- package/payload/frontend/dist/assets/chunk-4BX2VUAB-1vjsV_mH.js +1 -0
- package/payload/frontend/dist/assets/chunk-4TB4RGXK-CtMNFDLV.js +206 -0
- package/payload/frontend/dist/assets/chunk-55IACEB6-DVWWqMjZ.js +1 -0
- package/payload/frontend/dist/assets/chunk-EDXVE4YY-BBf3C6eJ.js +1 -0
- package/payload/frontend/dist/assets/chunk-FMBD7UC4-BUQfXSvf.js +15 -0
- package/payload/frontend/dist/assets/chunk-OYMX7WX6-DM1nFyON.js +231 -0
- package/payload/frontend/dist/assets/chunk-QZHKN3VN-Bz3CUNpU.js +1 -0
- package/payload/frontend/dist/assets/chunk-YZCP3GAM-Bb6CnKMv.js +1 -0
- package/payload/frontend/dist/assets/classDiagram-6PBFFD2Q-DHRHkXVC.js +1 -0
- package/payload/frontend/dist/assets/classDiagram-v2-HSJHXN6E-DHRHkXVC.js +1 -0
- package/payload/frontend/dist/assets/clone-BzLTnNJj.js +1 -0
- package/payload/frontend/dist/assets/companion-BLgWW1ka.css +1 -0
- package/payload/frontend/dist/assets/companion-CRS3Tmyt.js +2 -0
- package/payload/frontend/dist/assets/connection-ChK196PA.js +12 -0
- package/payload/frontend/dist/assets/connections-1OP6Izpn.js +1 -0
- package/payload/frontend/dist/assets/cose-bilkent-S5V4N54A-DvX1W1oQ.js +1 -0
- package/payload/frontend/dist/assets/css.worker-B4z49cGk.js +93 -0
- package/payload/frontend/dist/assets/cytoscape.esm-DxGcaOPV.js +331 -0
- package/payload/frontend/dist/assets/dagre-KV5264BT-BYV7l80W.js +4 -0
- package/payload/frontend/dist/assets/defaultLocale-DX6XiGOO.js +1 -0
- package/payload/frontend/dist/assets/desktop-DKYPd_Z3.js +1 -0
- package/payload/frontend/dist/assets/diagram-5BDNPKRD-BU_VxMcA.js +10 -0
- package/payload/frontend/dist/assets/diagram-G4DWMVQ6-6jnkLcPr.js +24 -0
- package/payload/frontend/dist/assets/diagram-MMDJMWI5-DAjbbS4T.js +43 -0
- package/payload/frontend/dist/assets/diagram-TYMM5635-p2T86-Pr.js +24 -0
- package/payload/frontend/dist/assets/editor.worker-DyuDvpVp.js +26 -0
- package/payload/frontend/dist/assets/erDiagram-SMLLAGMA-DcZPoxkO.js +85 -0
- package/payload/frontend/dist/assets/flowDiagram-DWJPFMVM-CDB-5IUB.js +162 -0
- package/payload/frontend/dist/assets/ganttDiagram-T4ZO3ILL-imCnxO5S.js +292 -0
- package/payload/frontend/dist/assets/gitGraphDiagram-UUTBAWPF-DW7bWVfm.js +106 -0
- package/payload/frontend/dist/assets/graph-rPoUAwm2.js +1 -0
- package/payload/frontend/dist/assets/html.worker-DtiGdgqp.js +470 -0
- package/payload/frontend/dist/assets/image-pt4OUNUX.js +1 -0
- package/payload/frontend/dist/assets/index-BJDOs8Sk.css +1 -0
- package/payload/frontend/dist/assets/index-CpU0rt1e.js +455 -0
- package/payload/frontend/dist/assets/index-D9-cSGu-.js +49 -0
- package/payload/frontend/dist/assets/infoDiagram-42DDH7IO-C6DYDEhQ.js +2 -0
- package/payload/frontend/dist/assets/init-Gi6I4Gst.js +1 -0
- package/payload/frontend/dist/assets/ishikawaDiagram-UXIWVN3A-o3dlbDPW.js +70 -0
- package/payload/frontend/dist/assets/journeyDiagram-VCZTEJTY-ukG3M2cI.js +139 -0
- package/payload/frontend/dist/assets/json.worker-leyajbqV.js +58 -0
- package/payload/frontend/dist/assets/kanban-definition-6JOO6SKY-CzFLztFd.js +89 -0
- package/payload/frontend/dist/assets/katex-DkKDou_j.js +257 -0
- package/payload/frontend/dist/assets/layout-C8SEMYSj.js +1 -0
- package/payload/frontend/dist/assets/linear-DY8vPita.js +1 -0
- package/payload/frontend/dist/assets/main-B_ifx48h.js +693 -0
- package/payload/frontend/dist/assets/main-C-ZLrzMh.css +33 -0
- package/payload/frontend/dist/assets/min-9StlgeN8.js +1 -0
- package/payload/frontend/dist/assets/mindmap-definition-QFDTVHPH-CyJisFtS.js +96 -0
- package/payload/frontend/dist/assets/monitoring-Bjm0etKL.js +1 -0
- package/payload/frontend/dist/assets/notifications-DhRLCgMU.js +1 -0
- package/payload/frontend/dist/assets/ordinal-Cboi1Yqb.js +1 -0
- package/payload/frontend/dist/assets/pieDiagram-DEJITSTG-DHSht7rk.js +30 -0
- package/payload/frontend/dist/assets/quadrantDiagram-34T5L4WZ-92xIujrE.js +7 -0
- package/payload/frontend/dist/assets/record-content-Cy_dPSdi.js +1 -0
- package/payload/frontend/dist/assets/requirementDiagram-MS252O5E-CXuOqrNd.js +84 -0
- package/payload/frontend/dist/assets/sankeyDiagram-XADWPNL6-DR-mjY0Y.js +10 -0
- package/payload/frontend/dist/assets/sequenceDiagram-FGHM5R23-DmmUpAoP.js +157 -0
- package/payload/frontend/dist/assets/shortcuts-BNrV46nh.js +1 -0
- package/payload/frontend/dist/assets/stateDiagram-FHFEXIEX-CKoqQ0-j.js +1 -0
- package/payload/frontend/dist/assets/stateDiagram-v2-QKLJ7IA2-BfZc0BCX.js +1 -0
- package/payload/frontend/dist/assets/status-B__OyRqS.js +1 -0
- package/payload/frontend/dist/assets/suiji-nz2Jwmpc.js +1 -0
- package/payload/frontend/dist/assets/svg-BpvEgtI3.js +21 -0
- package/payload/frontend/dist/assets/tabs-BjCNEXFA.js +1 -0
- package/payload/frontend/dist/assets/timeline-definition-GMOUNBTQ-CHT2sQNz.js +120 -0
- package/payload/frontend/dist/assets/ts.worker-59MjiAqk.js +67731 -0
- package/payload/frontend/dist/assets/vennDiagram-DHZGUBPP-Bvnh5q4I.js +34 -0
- package/payload/frontend/dist/assets/wardley-RL74JXVD-DeQXKB6h.js +162 -0
- package/payload/frontend/dist/assets/wardleyDiagram-NUSXRM2D-jWo5oC0L.js +20 -0
- package/payload/frontend/dist/assets/workbox-window.prod.es5-BIl4cyR9.js +2 -0
- package/payload/frontend/dist/assets/xychartDiagram-5P7HB3ND-Btji0cq9.js +7 -0
- package/payload/frontend/dist/build-info.json +8 -0
- package/payload/frontend/dist/companion.html +15 -0
- package/payload/frontend/dist/icons/apple-touch-icon.png +0 -0
- package/payload/frontend/dist/icons/icon-192.png +0 -0
- package/payload/frontend/dist/icons/icon-512.png +0 -0
- package/payload/frontend/dist/icons/maskable-icon-512.png +0 -0
- package/payload/frontend/dist/index.html +19 -0
- package/payload/frontend/dist/manifest.webmanifest +28 -0
- package/payload/frontend/dist/sw.js +1 -0
- package/payload/frontend/dist/workbox-632bafe5.js +1 -0
- package/payload/server/index.cjs +8620 -0
- package/payload/start.mjs +50 -0
- package/README.md +0 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as r}from"./graph-rPoUAwm2.js";var e=4;function a(o){return r(o,e)}export{a as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
:root{color-scheme:dark;background:transparent!important;--companion-surface: #0a1420;--companion-surface-3: #132131;--companion-line: #203044;--companion-line-soft: rgba(122, 153, 185, .18);--companion-text: #f2f7fb;--companion-muted: #90a2b5;--companion-dim: #607386;--companion-cyan: #58d7ef;--companion-cyan-soft: rgba(88, 215, 239, .14);--companion-rose: #ff607f;--companion-rose-soft: rgba(255, 96, 127, .14);--companion-amber: #ffbf4b;--companion-amber-soft: rgba(255, 191, 75, .14);--companion-green: #40d9a0;--companion-green-soft: rgba(64, 217, 160, .14)}html,body,#root{width:100%;min-height:100%;margin:0;background:transparent!important}body{overflow:hidden}.desktop-companion,.desktop-companion *{box-sizing:border-box}.desktop-companion{display:flex;width:410px;max-height:480px;flex-direction:column;align-items:flex-end;overflow:hidden;padding:12px 8px;color:var(--companion-text);font-family:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif;line-height:normal}.desktop-companion.is-compact{width:92px}.desktop-companion button{border:0;color:inherit;cursor:pointer;font:inherit}.desktop-companion button:focus-visible{outline:2px solid var(--companion-cyan);outline-offset:-2px}.companion-open-notice{width:394px;margin:0 0 8px;border:1px solid rgba(255,191,75,.56);border-radius:8px;padding:8px 10px;background:#071019f5;color:#ffd681;font-size:10px}.companion-panel{width:394px;min-height:0;flex:0 1 auto;overflow:hidden;border:1px solid rgba(127,160,190,.36);border-radius:17px 17px 5px;background:#071019f0;box-shadow:0 18px 52px #0000008a,inset 0 1px #ffffff09;-webkit-backdrop-filter:blur(24px) saturate(1.15);backdrop-filter:blur(24px) saturate(1.15)}.companion-panel-head{display:flex;min-height:50px;flex:0 0 auto;align-items:center;gap:10px;border-bottom:1px solid var(--companion-line-soft);padding:9px 11px}.companion-panel-title{min-width:0;flex:1}.companion-panel-title strong,.companion-panel-title span{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.companion-panel-title strong{font-size:12px}.companion-panel-title span{margin-top:2px;color:var(--companion-muted);font-size:9px}.companion-close{display:grid;width:26px;height:26px;flex:0 0 auto;place-items:center;border-radius:6px;background:transparent;color:var(--companion-dim)!important;font-size:16px!important}.companion-close:hover{background:var(--companion-surface-3);color:var(--companion-text)!important}.companion-slots{min-height:0;flex:1 1 auto;overflow-x:hidden;overflow-y:auto;overscroll-behavior:contain;padding:6px 4px 6px 6px;scrollbar-color:rgba(96,115,134,.72) transparent;scrollbar-gutter:stable;scrollbar-width:thin}.companion-slots::-webkit-scrollbar{width:5px}.companion-slots::-webkit-scrollbar-thumb{border-radius:999px;background:#607386b8}.companion-slots::-webkit-scrollbar-track{background:transparent}.companion-tray{display:flex;max-height:380px;flex-direction:column}.companion-slot{display:grid;width:100%;min-height:78.5px;grid-template-columns:8px minmax(0,1fr) auto;align-items:start;gap:9px;border-radius:9px;padding:10px;background:transparent;text-align:left}.companion-slot:hover,.companion-slot:first-child{background:#122231db}.companion-slot-main{min-width:0;min-height:58.5px}.companion-slot-title{display:flex;min-width:0;align-items:center;gap:7px}.companion-slot-title strong{min-width:0;overflow:hidden;font-size:11px;text-overflow:ellipsis;white-space:nowrap}.companion-slot-task,.companion-slot-path{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.companion-slot-task{margin-top:7px;color:var(--companion-muted);font-size:9px;line-height:10.5px}.companion-slot-path{margin-top:9.5px;color:var(--companion-dim);font-family:SFMono-Regular,Consolas,monospace;font-size:8px;line-height:9.5px}.companion-slot-target{display:flex;align-items:center;gap:4px;border:1px solid var(--companion-line);border-radius:5px;padding:4px 6px;color:var(--companion-muted);font-size:8px;white-space:nowrap}.status-pill{display:inline-flex;flex:0 0 auto;align-items:center;gap:6px;border-radius:999px;padding:4px 7px;font-size:9px;font-weight:750}.status-pill.needs_action{background:var(--companion-amber-soft);color:#ffd681}.status-pill.blocked{background:var(--companion-rose-soft);color:#ff91a6}.status-pill.completed{background:var(--companion-green-soft);color:#79edc2}.status-pill.failed{background:#ff7a6324;color:#ff9d8c}.status-pill.working{background:var(--companion-cyan-soft);color:#8aeafa}.state-dot{width:6px;height:6px;flex:0 0 auto;border-radius:50%;background:var(--companion-dim)}.state-dot.needs_action{background:var(--companion-amber);box-shadow:0 0 9px #ffbf4bc2}.state-dot.blocked{background:var(--companion-rose);box-shadow:0 0 9px #ff607fb3}.state-dot.completed{background:var(--companion-green);box-shadow:0 0 9px #40d9a09e}.state-dot.failed{background:#ff7a63;box-shadow:0 0 9px #ff7a63ad}.state-dot.working{background:var(--companion-cyan);box-shadow:0 0 9px #58d7efad;animation:companion-breathe 1.8s ease-in-out infinite}.companion-card{width:382px;margin-right:12px}.companion-card-body{padding:14px}.companion-card-body h2{margin:9px 0 6px;font-size:16px;line-height:1.25}.companion-card-body p{margin:0;color:#b5c3cf;font-size:10px;line-height:1.55}.companion-card-actions{display:flex;justify-content:flex-end;gap:7px;margin-top:13px}.companion-primary,.companion-ghost{display:inline-flex;min-height:31px;align-items:center;justify-content:center;border-radius:7px;padding:0 11px;font-size:10px!important}.companion-primary{background:var(--companion-cyan);color:#031217!important;font-weight:850!important}.companion-ghost{border:1px solid var(--companion-line)!important;background:var(--companion-surface);color:var(--companion-muted)!important}.companion-pet{position:relative;display:grid;width:76px;height:76px;flex:0 0 auto;place-items:center;border-radius:24px;background:transparent;cursor:grab!important;filter:drop-shadow(0 15px 18px rgba(0,0,0,.48));touch-action:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}.companion-pet:active{cursor:grabbing!important}.pet-aura{position:absolute;top:9px;right:9px;bottom:9px;left:9px;border-radius:50%;background:radial-gradient(circle,rgba(88,215,239,.35),transparent 68%);animation:companion-aura 2.4s ease-in-out infinite}.pet-shadow{position:absolute;right:10px;bottom:2px;left:10px;height:8px;border-radius:50%;background:#00000080;filter:blur(5px)}.pet-body{position:relative;width:54px;height:52px;border:1px solid rgba(173,229,240,.62);border-radius:18px 18px 21px 21px;background:linear-gradient(145deg,#bef2faf2,#3493b1fa 56%,#13455dfa);box-shadow:inset 0 1px #ffffff94,0 0 24px #58d7ef45}.pet-ear{position:absolute;top:-7px;width:16px;height:18px;border:1px solid rgba(173,229,240,.5);background:#4aa9c2;transform:rotate(45deg)}.pet-ear.left{left:4px;border-radius:5px 2px 4px}.pet-ear.right{right:4px;border-radius:2px 5px 2px 4px}.pet-face{position:absolute;top:14px;right:8px;bottom:8px;left:8px;border-radius:13px;background:#03121bc7}.pet-eye{position:absolute;top:10px;width:6px;height:8px;border-radius:50%;background:#dfffff;box-shadow:0 0 9px #d0ffffcc}.pet-eye.left{left:9px}.pet-eye.right{right:9px}.pet-mouth{position:absolute;bottom:8px;left:50%;width:9px;height:4px;border-bottom:1px solid #b8eef4;border-radius:0 0 8px 8px;transform:translate(-50%)}.pet-state-badge{position:absolute;top:0;right:0;display:grid;min-width:24px;height:24px;place-items:center;border:2px solid #07111b;border-radius:999px;padding:0 5px;background:var(--companion-amber);color:#2a1600;font-size:10px;font-weight:900;box-shadow:0 0 16px #ffbf4b7a}.pet-state-badge.blocked{background:var(--companion-rose);color:#26020b;box-shadow:0 0 16px #ff607f7a}.pet-state-badge.completed{background:var(--companion-green);color:#032117;box-shadow:0 0 16px #40d9a070}.pet-state-badge.failed{background:#ff7a63;color:#2b0803;box-shadow:0 0 16px #ff7a6375}.pet-mode-working .pet-body{animation:companion-pet-working 1.7s ease-in-out infinite}.pet-mode-completed .pet-mouth{height:6px;border-bottom-width:2px}.pet-mode-blocked .pet-face{box-shadow:inset 0 0 18px #ff607f2e}.pet-mode-blocked .pet-eye{background:#ffadc0;box-shadow:0 0 9px #ff607fc7}.pet-mode-failed .pet-face{box-shadow:inset 0 0 18px #ff7a632e}.pet-mode-failed .pet-eye{background:#ffc0b5;box-shadow:0 0 9px #ff7a63b8}.pet-mode-idle .pet-aura,.pet-mode-disconnected .pet-aura{opacity:.18;animation:none}.pet-mode-idle .pet-body,.pet-mode-disconnected .pet-body{filter:saturate(.52) brightness(.8)}.pet-mode-idle .pet-eye{top:13px;height:2px;border-radius:999px;box-shadow:none}.pet-disconnected-mark,.pet-checking-mark{position:absolute;color:var(--companion-text);font-size:20px;font-weight:800}.pet-checking-mark{animation:companion-breathe 1.2s ease-in-out infinite}@keyframes companion-breathe{0%,to{opacity:.62;transform:scale(.85)}50%{opacity:1;transform:scale(1.08)}}@keyframes companion-aura{0%,to{opacity:.48;transform:scale(.88)}50%{opacity:.9;transform:scale(1.08)}}@keyframes companion-pet-working{0%,to{transform:translateY(0) rotate(-1deg)}50%{transform:translateY(-3px) rotate(1deg)}}@media(prefers-reduced-motion:reduce){.desktop-companion *,.desktop-companion *:before,.desktop-companion *:after{animation-duration:1ms!important;animation-iteration-count:1!important}}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{d as z,r as l,u as f,j as e,c as V}from"./index-D9-cSGu-.js";const B="viewer.desktop-companion.failure-seen.v1",F=500,Z=720*60*60*1e3;function L(n){return n.length>0&&n.length<=512}function H(){try{const n=JSON.parse(z.getItem(B)??"[]"),a=Date.now()-Z;return Array.isArray(n)?n.filter(s=>typeof(s==null?void 0:s.key)=="string"&&typeof(s==null?void 0:s.seenAt)=="number"&&s.seenAt>=a).slice(-F):[]}catch{return[]}}function W(n,a){return`${n}
|
|
2
|
+
${a}`}function ee(n,a){return H().some(s=>s.key===W(n,a))}function ne(n,a){if(!L(n)||!L(a))return;const s=W(n,a),i=H().filter(I=>I.key!==s);i.push({key:s,seenAt:Date.now()}),z.setItem(B,JSON.stringify(i.slice(-F)))}const O=new Set(["needs_action","blocked"]),te=4,X={needs_action:"待决定",blocked:"验收受阻",failed:"异常退出",completed:"完成待查看",working:"执行中"};function Y(n){const a=Math.max(0,Math.floor((Date.now()-Date.parse(n))/1e3));if(!Number.isFinite(a))return"-";if(a<60)return a<10?"刚刚":`${a} 秒前`;const s=Math.floor(a/60);if(s<60)return`${s} 分钟前`;const i=Math.floor(s/60);return i<24?`${i} 小时前`:`${Math.floor(i/24)} 天前`}function se(n){return n.state==="needs_action"?"需要你决定":n.state==="blocked"?"验收受阻":n.state==="completed"?"完成待查看":n.state==="failed"?"异常退出":"执行中"}function T(){return"Terminal"}function ae(n){return[n.contextName,n.sessionLabel,n.panelLabel].filter(Boolean).join(" / ")}function U({slot:n}){return e.jsxs("span",{className:`status-pill ${n.state}`,children:[e.jsx("span",{className:`state-dot ${n.state}`}),se(n)]})}function b(n){const a=l.useRef(null),s=l.useRef(!1),i=f(o=>{o.button!==0||!window.companionAPI||(s.current=!1,a.current={pointerId:o.pointerId,startX:o.screenX,startY:o.screenY,moved:!1},o.currentTarget.setPointerCapture(o.pointerId),window.companionAPI.dragWindow({phase:"start",screenX:o.screenX,screenY:o.screenY}))}),I=f(o=>{var p;const c=a.current;!c||c.pointerId!==o.pointerId||!c.moved&&Math.hypot(o.screenX-c.startX,o.screenY-c.startY)<te||(c.moved=!0,s.current=!0,(p=window.companionAPI)==null||p.dragWindow({phase:"move",screenX:o.screenX,screenY:o.screenY}))}),w=f(o=>{var p;const c=a.current;!c||c.pointerId!==o.pointerId||(a.current=null,o.currentTarget.hasPointerCapture(o.pointerId)&&o.currentTarget.releasePointerCapture(o.pointerId),(p=window.companionAPI)==null||p.dragWindow({phase:"end"}))}),C=f(o=>{s.current=!1,w(o)}),R=f(o=>{var p;const c=a.current;!c||c.pointerId!==o.pointerId||(a.current=null,(p=window.companionAPI)==null||p.dragWindow({phase:"end"}))}),k=f(o=>{var c;if(s.current||n.disabled){s.current=!1,o.preventDefault(),o.stopPropagation();return}(c=n.onClick)==null||c.call(n)});return e.jsxs("button",{className:`companion-pet pet-mode-${n.state}`,"data-companion-interactive":!0,type:"button","aria-disabled":n.disabled||void 0,"aria-label":n.label,tabIndex:n.disabled?-1:void 0,onClick:k,onLostPointerCapture:R,onPointerCancel:C,onPointerDown:i,onPointerMove:I,onPointerUp:w,children:[e.jsx("span",{className:"pet-aura"}),e.jsx("span",{className:"pet-shadow"}),e.jsxs("span",{className:"pet-body","aria-hidden":"true",children:[e.jsx("span",{className:"pet-ear left"}),e.jsx("span",{className:"pet-ear right"}),e.jsxs("span",{className:"pet-face",children:[e.jsx("span",{className:"pet-eye left"}),e.jsx("span",{className:"pet-eye right"}),e.jsx("span",{className:"pet-mouth"})]})]}),n.count>0?e.jsx("span",{className:`pet-state-badge ${n.state}`,children:n.count}):null,n.state==="disconnected"?e.jsx("span",{className:"pet-disconnected-mark",children:"×"}):null,n.state==="checking"?e.jsx("span",{className:"pet-checking-mark",children:"…"}):null]})}function oe(n){var $;const{connectionId:a,snapshot:s,state:i}=n.presentation,[I,w]=l.useState(!1),[C,R]=l.useState(()=>new Set),[k,o]=l.useState(!1),[c,p]=l.useState(null),E=l.useRef(null),P=l.useRef(null),m=l.useMemo(()=>((s==null?void 0:s.slots)??[]).filter(t=>t.state!=="failed"||!a||!ee(a,t.attentionId)),[a,s]),h=m.find(t=>O.has(t.state)&&!C.has(t.attentionId)),x=l.useMemo(()=>m.reduce((t,d)=>({...t,[d.state]:t[d.state]+1}),{needs_action:0,blocked:0,failed:0,completed:0,working:0}),[m]),N=x.needs_action+x.blocked+x.failed+x.completed,M=(($=m[0])==null?void 0:$.state)??"idle",G=N?`${N} 个 Slot 需要关注`:`${x.working} 个 Slot 正在执行`,q=Object.keys(X).filter(t=>x[t]>0).map(t=>`${x[t]} ${X[t]}`).join(" · ");l.useEffect(()=>{i==="ready"&&m.length>0&&!k&&(w(!1),o(!0))},[k,m.length,i]),l.useEffect(()=>{const t=E.current;if(!t)return;const d=new ResizeObserver(()=>{var r;const u=t.getBoundingClientRect();(r=window.companionAPI)==null||r.reportContentSize({width:Math.ceil(u.width),height:Math.ceil(u.height)})});return d.observe(t),()=>d.disconnect()},[]),l.useEffect(()=>{const t=r=>{var D;if(P.current===r)return;P.current=r;const g=(D=window.companionAPI)==null?void 0:D.setMousePassthrough(r);g&&g.catch(()=>{P.current===r&&(P.current=null)})},d=r=>{const g=document.elementFromPoint(r.clientX,r.clientY);t(!(g!=null&&g.closest("[data-companion-interactive]")))},u=()=>t(!0);return window.addEventListener("mousemove",d),window.addEventListener("mouseleave",u),()=>{var r;window.removeEventListener("mousemove",d),window.removeEventListener("mouseleave",u),(r=window.companionAPI)==null||r.setMousePassthrough(!1)}},[]);const _=f(async t=>{var r;if(!a)return;p(null);const d={requestId:crypto.randomUUID(),connectionId:a,attentionId:t.attentionId,projectId:t.projectId,terminalSessionId:t.terminalSessionId,panelId:t.panelId,targetSurface:t.targetSurface,completionRevision:t.completionRevision},u=await((r=window.companionAPI)==null?void 0:r.openSlot(d));(u==null?void 0:u.status)==="opened_with_panel_fallback"&&p(u.message),t.state==="failed"&&u&&(u.status==="opened"||u.status==="opened_with_panel_fallback")&&ne(a,t.attentionId)}),A=f(()=>{R(t=>new Set([...t,...m.filter(d=>O.has(d.state)).map(d=>d.attentionId)])),w(!1)}),J=f(()=>w(!1)),K=f(()=>w(!0));let y=null,j;i==="checking"?j=e.jsx(b,{state:"checking",count:0,disabled:!0,label:"正在检查"}):i==="disconnected"?j=e.jsx(b,{state:"disconnected",count:0,disabled:!0,label:"未连接"}):m.length===0?j=e.jsx(b,{state:"idle",count:0,disabled:!0,label:"所有 Slot 均安静"}):h?(y=e.jsxs("section",{className:"companion-panel companion-card","data-companion-interactive":!0,"data-state":h.state,children:[e.jsxs("header",{className:"companion-panel-head",children:[e.jsx(U,{slot:h}),e.jsxs("div",{className:"companion-panel-title",children:[e.jsxs("strong",{children:[h.projectName," / ",h.contextName]}),e.jsx("span",{children:Y(h.updatedAt)})]}),e.jsx("button",{className:"companion-close",type:"button",onClick:A,"aria-label":"收起",children:"×"})]}),e.jsxs("div",{className:"companion-card-body",children:[e.jsx("h2",{children:h.title}),e.jsx("p",{children:h.detail}),e.jsxs("div",{className:"companion-card-actions",children:[e.jsx("button",{className:"companion-ghost",type:"button",onClick:A,children:"暂时收起"}),e.jsxs("button",{className:"companion-primary",type:"button",onClick:()=>void _(h),children:["打开 ",T()," →"]})]})]})]}),j=e.jsx(b,{state:M,count:N,label:"收起 Slot companion",onClick:A})):I?j=e.jsx(b,{state:M,count:N,label:`展开 ${m.length} 个 Slot`,onClick:J}):(y=e.jsxs("section",{className:"companion-panel companion-tray","data-companion-interactive":!0,children:[e.jsxs("header",{className:"companion-panel-head",children:[e.jsxs("div",{className:"companion-panel-title",children:[e.jsx("strong",{children:G}),e.jsx("span",{children:q})]}),e.jsx("button",{className:"companion-close",type:"button",onClick:()=>w(!0),"aria-label":"收起",children:"×"})]}),e.jsx("div",{className:"companion-slots",children:m.map(t=>e.jsxs("button",{className:"companion-slot","data-state":t.state,type:"button",onClick:()=>void _(t),children:[e.jsx("span",{className:`state-dot ${t.state}`}),e.jsxs("span",{className:"companion-slot-main",children:[e.jsxs("span",{className:"companion-slot-title",children:[e.jsx("strong",{children:t.sessionLabel}),e.jsx(U,{slot:t})]}),e.jsx("span",{className:"companion-slot-task",children:t.title}),e.jsxs("span",{className:"companion-slot-path",children:[ae(t)," · ",Y(t.updatedAt)]})]}),e.jsxs("span",{className:"companion-slot-target",children:["↗ ",T()]})]},t.attentionId))})]}),j=e.jsx(b,{state:M,count:N,label:"收起 Slot companion",onClick:K}));const Q=y===null&&c===null;return e.jsxs("div",{ref:E,className:`desktop-companion${Q?" is-compact":""}`,"data-testid":"desktop-companion",children:[c?e.jsx("p",{className:"companion-open-notice","data-companion-interactive":!0,role:"status",children:c}):null,y,j]})}const ie={connectionId:null,snapshot:null,state:"checking"},S=new Map;function v(n){var a,s,i;(i=(s=(a=window.webkit)==null?void 0:a.messageHandlers)==null?void 0:s.runweave)==null||i.postMessage(n)}const ce={reportContentSize:({width:n,height:a})=>(v({type:"resize",width:n,height:a}),Promise.resolve()),setMousePassthrough:()=>Promise.resolve(),dragWindow:n=>v({type:"drag",request:n}),openSlot:n=>new Promise(a=>{const s=crypto.randomUUID();S.set(s,a),v({type:"openSlot",commandId:s,intent:n})})};window.companionAPI=ce;function re(){const[n,a]=l.useState(ie);return l.useEffect(()=>(window.runweaveCompanionReceive=s=>{if(s.type==="presentation"){a(s.presentation);return}const i=S.get(s.commandId);i&&(S.delete(s.commandId),i(s.result))},v({type:"ready"}),()=>{delete window.runweaveCompanionReceive,S.clear()}),[]),e.jsx(oe,{presentation:n})}V.createRoot(document.getElementById("root")).render(e.jsx(re,{}));
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
var We=Object.defineProperty;var Je=(a,t,s)=>t in a?We(a,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[t]=s;var P=(a,t,s)=>Je(a,typeof t!="symbol"?t+"":t,s);import{j as e,r as p,u as z}from"./index-D9-cSGu-.js";import{s as Pe,t as se,B as h,I as G,v as _e,w as Ge,x as Qe,y as Ze,E as Xe,P as Ye,N as et,G as tt,J as st,K as it,h as at,r as rt,O as nt,X as ot,Q as we}from"./main-B_ifx48h.js";import{S as Ae,r as he,R as Ne,a as Be}from"./record-content-Cy_dPSdi.js";/**
|
|
2
|
+
* @license lucide-react v0.484.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const lt=[["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M16 6V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v2",key:"1ksdt3"}],["path",{d:"M22 13a18.15 18.15 0 0 1-20 0",key:"12hx5q"}],["rect",{width:"20",height:"14",x:"2",y:"6",rx:"2",key:"i6l2r4"}]],ct=Pe("briefcase-business",lt);/**
|
|
7
|
+
* @license lucide-react v0.484.0 - ISC
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the ISC license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/const dt=[["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]],ut=Pe("list-checks",dt),ye={progress:"有进展",discussed:"讨论",documented:"已记录",attempted:"尝试","agent-reported":"Agent 反馈",verified:"已验证"},Fe=()=>new Intl.DateTimeFormat("en-CA",{timeZone:"Asia/Shanghai",year:"numeric",month:"2-digit",day:"2-digit"}).format(new Date),re="/api/suiji/v1/work-facts",W=a=>a instanceof Error?a.message:"操作失败";class ht{constructor(t,s){P(this,"state",{items:[],days:[],cursor:null,from:"",to:"",loading:!1,busy:!1,error:""});P(this,"listeners",new Set);P(this,"generation",0);P(this,"alive",!0);P(this,"writable",!1);P(this,"read");P(this,"writes",Promise.resolve());P(this,"subscribe",t=>(this.listeners.add(t),()=>{this.listeners.delete(t)}));P(this,"snapshot",()=>this.state);this.client=t,this.store=s}set(t){this.alive&&this.client.active&&(this.state={...this.state,...t},this.listeners.forEach(s=>s()))}persist(t,s){const i=structuredClone(s),r=this.writes.catch(()=>{}).then(()=>this.store.set(t,i));return this.writes=r,r}dispose(){var t;this.alive=!1,++this.generation,(t=this.read)==null||t.abort()}async settled(){await this.writes.catch(()=>{})}async initialize(){this.alive=!0;try{const[t,s,i]=await Promise.all([this.store.get("work:dates"),this.store.get("work:reclassify:active"),this.store.get("work:reclassify:undo")]),r=s?await this.store.get("work:reclassify:"+s):void 0;this.set({...t??{},batch:r,undo:i}),await this.load()}catch(t){this.set({error:W(t)})}}async load(t=!1,s=!0){var l;if(t&&(!this.state.cursor||this.state.loading))return;(l=this.read)==null||l.abort(),this.read=new AbortController;const i=++this.generation,{from:r,to:o,cursor:d}=this.state;this.set({loading:!0,error:"",...t?{}:{items:[],days:[],cursor:null}});const c=new URLSearchParams({...r?{from:r}:{},...o?{to:o}:{},...t&&d?{cursor:d}:{}});try{const u=await this.client.request(re+"?"+c,"GET",void 0,void 0,this.read.signal);if(!this.alive||i!==this.generation)return;const m=t?Object.values(Object.fromEntries([...this.state.days,...u.days].map(g=>[g.date,g]))):u.days;this.set({items:t?[...this.state.items,...u.items]:u.items,days:m,cursor:u.nextCursor})}catch(u){if(!this.alive||i!==this.generation)return;if(u instanceof se&&u.detail.error.code==="WORK_FEED_CHANGED"&&s){await this.load(!1,!1);return}this.set({error:W(u)})}finally{i===this.generation&&this.set({loading:!1})}}async dates(t,s){if(t&&s&&t>s){this.set({error:"开始日期不能晚于结束日期"});return}await this.persist("work:dates",{from:t,to:s}),this.set({from:t,to:s}),await this.load()}async detail(t){try{const s=await this.client.request(re+"/"+t);this.set({detail:s.fact})}catch(s){this.set({error:W(s)})}}closeDetail(){this.set({detail:void 0})}async edit(t){try{await this.writes;const s=(t==null?void 0:t.id)??"new",i=s==="new"?"work:new":"work:edit:"+s,r=await this.store.get(i)??{id:s,fields:t?{workDate:t.workDate,title:t.title,statement:t.statement,status:t.status,project:t.project}:{workDate:Fe(),title:"",statement:"",status:"progress",project:null},...t?{base:t}:{}};await this.persist(i,r),this.set({draft:r,error:""})}catch(s){this.set({error:W(s)})}}update(t){const s=this.state.draft;if(!this.writable||!s||s.pending||this.state.busy)return;const i={...s,fields:{...s.fields,...t}};this.set({draft:i}),this.persist(i.id==="new"?"work:new":"work:edit:"+i.id,i).catch(r=>this.set({error:W(r)}))}closeEditor(){this.state.busy||this.set({draft:void 0})}async discardEditor(){const t=this.state.draft;if(!(!t||t.pending||this.state.busy))try{await this.writes,await this.store.remove(t.id==="new"?"work:new":"work:edit:"+t.id),this.set({draft:void 0})}catch(s){this.set({error:W(s)})}}async refreshVersion(){const t=this.state.draft;if(!(!(t!=null&&t.base)||t.pending||this.state.busy))try{const{fact:s}=await this.client.request(re+"/"+t.id),i={...t,base:s};await this.persist("work:edit:"+t.id,i),this.set({draft:i,detail:s,error:"已读取当前版本,下方保留你的草稿;请核对最新事实后再保存。"})}catch(s){this.set({error:W(s)})}}async save(){var i,r;let t=this.state.draft;if(!this.writable||!t||this.state.busy)return;this.set({busy:!0,error:""});const s=t.id==="new"?"work:new":"work:edit:"+t.id;try{if(await this.writes,!t.pending){const c=t.fields;if(!c.title.trim()||!c.statement.trim()||[...c.title.trim()].length>80||[...c.statement].length>4e3||[...((i=c.project)==null?void 0:i.trim())??""].length>80||!/^\d{4}-\d\d-\d\d$/.test(c.workDate))throw new Error("请填写有效工作日期、1–80字标题及1–4000字正文;项目最多80字");const l={...c,title:c.title.trim(),project:((r=c.project)==null?void 0:r.trim())||null},u=t.base?{expectedVersion:t.base.version,...Object.fromEntries(Object.entries(l).filter(([m,g])=>g!==t.base[m]))}:l;if(t.base&&Object.keys(u).length===1){this.set({draft:void 0});return}t={...t,pending:{key:crypto.randomUUID(),method:t.base?"PATCH":"POST",path:re+(t.base?"/"+t.id:""),data:u}},await this.persist(s,t),this.set({draft:t})}const o=t.pending,{fact:d}=await this.client.request(o.path,o.method,o.data,o.key);if(!(d!=null&&d.id)||t.base&&d.id!==t.id||Object.entries(o.data).some(([c,l])=>c!=="expectedVersion"&&d[c]!==l))throw new Error("保存回执不匹配,请手动确认原请求");await this.store.remove(s),this.set({draft:void 0,detail:d}),await this.dates(d.workDate,d.workDate)}catch(o){o instanceof se&&!o.uncertain&&t.pending&&(t={...t,pending:void 0},await this.persist(s,t),this.set({draft:t})),this.set({error:W(o)})}finally{this.set({busy:!1})}}async beginBatch(t,s=!1){if(!(this.state.batch||this.state.busy))try{const i={id:crypto.randomUUID(),rows:t,project:"",...s?{undo:s}:{}};await this.persist("work:reclassify:"+i.id,i),await this.persist("work:reclassify:active",i.id),this.set({batch:i,error:""})}catch(i){this.set({error:W(i)})}}updateBatch(t,s){const i=this.state.batch;if(!i||i.pending||this.state.busy)return;const r={...i,rows:t,project:s};this.set({batch:r}),this.persist("work:reclassify:"+i.id,r).catch(o=>this.set({error:W(o)}))}async refreshBatch(){const t=this.state.batch;if(!(!this.writable||!t||t.undo||t.pending||this.state.busy))try{const s=await Promise.all(t.rows.map(async r=>(await this.client.request(re+"/"+r.id)).fact)),i={...t,rows:s};await this.persist("work:reclassify:"+t.id,i),this.set({batch:i,error:"已读取所选事实的最新版本,请核对后再确认归类。"})}catch(s){this.set({error:W(s)})}}async cancelBatch(){const t=this.state.batch;if(!(!t||t.pending||this.state.busy))try{await this.writes,await this.store.remove("work:reclassify:"+t.id),await this.store.remove("work:reclassify:active"),this.set({batch:void 0})}catch(s){this.set({error:W(s)})}}async undo(){this.state.undo&&!this.state.batch&&await this.beginBatch([],!0)}async commitBatch(){let t=this.state.batch;if(!this.writable||!t||this.state.busy)return;this.set({busy:!0,error:""});const s="work:reclassify:"+t.id;try{if(await this.writes,!t.pending){if(!t.undo&&(t.rows.length<1||t.rows.length>100))throw new Error("请选择1–100条已加载记录");const l=t.undo?this.state.undo:{items:t.rows.map(u=>({id:u.id,expectedVersion:u.version})),project:t.project.trim()||null};if(!l)throw new Error("没有可撤销的项目调整");t={...t,pending:{path:re+(t.undo?"/reclassify/undo":"/reclassify"),method:"POST",data:l,key:crypto.randomUUID()}},await this.persist(s,t),this.set({batch:t})}const i=t.pending,{facts:r}=await this.client.request(i.path,i.method,i.data,i.key),o=i.data;if(!Array.isArray(r)||r.length!==o.items.length||o.items.some(l=>!r.some(u=>u.id===l.id&&u.version===l.expectedVersion+1&&u.project===("project"in l?l.project:o.project))))throw new Error("归类回执不匹配,请手动确认原请求");const d=t.undo?void 0:{items:r.map(l=>({id:l.id,expectedVersion:l.version,project:t.rows.find(u=>u.id===l.id).project}))};d?await this.persist("work:reclassify:undo",d):await this.store.remove("work:reclassify:undo"),await this.store.remove(s),await this.store.remove("work:reclassify:active");const c=r.find(l=>{var u;return l.id===((u=this.state.detail)==null?void 0:u.id)})??this.state.detail;this.set({batch:void 0,undo:d,detail:c}),await this.load()}catch(i){i instanceof se&&!i.uncertain&&t.pending&&(t={...t,pending:void 0},await this.persist(s,t),this.set({batch:t})),this.set({error:W(i)})}finally{this.set({busy:!1})}}}function ft({model:a,writable:t}){const{draft:s,busy:i,error:r,detail:o}=a.state;if(!s)return null;const d=!t||i||!!s.pending,c=(l,u)=>a.update({[l]:u});return e.jsxs("section",{className:"flex min-h-0 flex-1 flex-col","aria-label":"工作事实编辑",children:[e.jsxs("header",{className:"flex items-center justify-between border-b p-4",children:[e.jsx(h,{variant:"ghost",disabled:i,onClick:()=>a.closeEditor(),children:"返回"}),e.jsx("h2",{children:s.base?"编辑事实":"补记事实"}),e.jsx(h,{disabled:i||!t,onClick:()=>void a.save(),children:i?"保存中…":s.pending?"手动确认原请求":"保存"})]}),e.jsxs("div",{className:"flex flex-1 flex-col gap-5 overflow-y-auto p-5",children:[r?e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:r}):null,s.pending?e.jsx("p",{role:"status",className:"text-sm",children:"保存结果待确认。原请求已保存在本机,返回或重启不会自动发送。"}):null,e.jsxs("label",{className:"space-y-2 text-sm",children:["工作日期",e.jsx(G,{type:"date","aria-label":"工作日期",disabled:d,value:s.fields.workDate,onChange:l=>c("workDate",l.target.value)})]}),e.jsxs("label",{className:"space-y-2 text-sm",children:["标题",e.jsx(G,{"aria-label":"事实标题",disabled:d,value:s.fields.title,onChange:l=>c("title",l.target.value)})]}),e.jsxs("label",{className:"space-y-2 text-sm",children:["事实正文",e.jsx("textarea",{"aria-label":"事实正文",disabled:d,className:"min-h-48 w-full rounded-xl border bg-background p-3",value:s.fields.statement,onChange:l=>c("statement",l.target.value)})]}),e.jsxs("label",{className:"space-y-2 text-sm",children:["实际状态",e.jsx("select",{"aria-label":"事实状态",disabled:d,className:"w-full rounded-xl border bg-background p-3",value:s.fields.status,onChange:l=>a.update({status:l.target.value}),children:Object.entries(ye).map(([l,u])=>e.jsx("option",{value:l,children:u},l))})]}),e.jsxs("label",{className:"space-y-2 text-sm",children:["项目(可选)",e.jsx(G,{"aria-label":"事实项目",placeholder:"未归类",disabled:d,value:s.fields.project??"",onChange:l=>a.update({project:l.target.value||null})})]}),s.base&&!s.pending?e.jsxs(e.Fragment,{children:[e.jsx(h,{variant:"outline",disabled:i,onClick:()=>void a.refreshVersion(),children:"读取最新版本并保留草稿"}),(o==null?void 0:o.id)===s.id?e.jsxs("div",{className:"whitespace-pre-wrap rounded-xl bg-secondary p-3 text-sm",children:[e.jsxs("p",{children:["服务当前 v",o.version," · ",o.workDate," ·"," ",o.project??"未归类"]}),e.jsx("strong",{children:o.title}),e.jsx("p",{children:o.statement})]}):null]}):null,e.jsx(h,{variant:"ghost",disabled:d,onClick:()=>void a.discardEditor(),children:"丢弃未保存草稿"})]})]})}function pt({model:a,writable:t}){const{batch:s,items:i,busy:r,error:o,undo:d}=a.state;if(!s)return null;const c=!t||r||!!s.pending,l=new Set(s.rows.map(m=>m.id)),u=[...s.rows,...i.filter(m=>!l.has(m.id))];return e.jsxs("section",{className:"flex min-h-0 flex-1 flex-col","aria-label":"重新归类",children:[e.jsxs("header",{className:"flex items-center justify-between border-b p-4",children:[e.jsx("h2",{children:s.undo?"撤销本次归类":"重新归类"}),e.jsx(h,{variant:"ghost",disabled:c,onClick:()=>void a.cancelBatch(),children:"取消"})]}),e.jsxs("div",{className:"flex flex-1 flex-col gap-4 overflow-y-auto p-5",children:[o?e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:o}):null,s.pending?e.jsx("p",{children:"操作结果待确认,原请求已保存在本机;不会自动重发。"}):null,s.undo?e.jsxs("p",{children:["按原成功回执的版本还原 ",(d==null?void 0:d.items.length)??0," ","条记录的项目;任何一条版本变化将整批停止。"]}):e.jsxs(e.Fragment,{children:[e.jsx(h,{variant:"ghost",disabled:c,onClick:()=>void a.refreshBatch(),children:"读取所选事实最新版本"}),e.jsxs("p",{className:"text-sm",children:["已选 ",s.rows.length," 条。仅修改项目,正文、日期和状态保持。"]}),e.jsx(h,{variant:"outline",disabled:c||i.length>100,onClick:()=>a.updateBatch([...new Map([...s.rows,...i].map(m=>[m.id,m])).values()],s.project),children:"全选已加载记录"}),a.state.cursor?e.jsx("p",{className:"text-sm text-muted-foreground",children:"还有未加载记录;返回列表加载后再选择。"}):null,e.jsxs("label",{className:"text-sm",children:["目标项目(留空为未归类)",e.jsx(G,{"aria-label":"目标项目",list:"work-projects",disabled:c,value:s.project,onChange:m=>a.updateBatch(s.rows,m.target.value)})]}),e.jsx("datalist",{id:"work-projects",children:[...new Set(i.map(m=>m.project).filter(m=>!!m))].map(m=>e.jsx("option",{value:m},m))}),e.jsx("div",{className:"flex flex-col gap-3",children:u.map(m=>e.jsxs("label",{className:"flex items-start gap-3 rounded-xl border p-3 text-sm",children:[e.jsx("input",{type:"checkbox","aria-label":`选择 ${m.title}`,disabled:c||!l.has(m.id)&&s.rows.length>=100,checked:l.has(m.id),onChange:g=>a.updateBatch(g.target.checked?[...s.rows,m]:s.rows.filter(n=>n.id!==m.id),s.project)}),e.jsxs("span",{children:[e.jsx("strong",{children:m.title}),e.jsx("br",{}),m.workDate," · ",m.project??"未归类",e.jsx("br",{}),e.jsx("small",{children:m.id})]})]},m.id))})]})]}),e.jsx("div",{className:"shrink-0 border-t bg-background p-4",children:e.jsx(h,{className:"h-auto min-h-10 w-full whitespace-normal break-words",disabled:!t||r||!s.undo&&!s.rows.length,onClick:()=>void a.commitBatch(),children:r?"保存中…":s.pending?"手动确认原请求":s.undo?"确认撤销项目调整":`确认 ${s.rows.length} 条 → ${s.project.trim()||"未归类"}`})})]})}function xt({model:a,active:t,writable:s,onReview:i}){const r=p.useSyncExternalStore(a.subscribe,a.snapshot),[o,d]=p.useState(!1),[c,l]=p.useState(""),[u,m]=p.useState(""),[g,n]=p.useState(!1);p.useEffect(()=>{a.writable=s},[a,s]),p.useEffect(()=>{t&&a.load()},[t,a]);const{detail:x,draft:k,batch:S}=r,v=j=>{const N=Math.round((Date.parse(Fe()+"T00:00:00Z")-Date.parse(j+"T00:00:00Z"))/864e5);return`${N===0?"今天 · ":N===1?"昨天 · ":N===2?"前天 · ":""}${j}`},b=()=>{const j=r.from&&r.to?Math.floor((Date.parse(r.to)-Date.parse(r.from))/864e5)+1:0;return j>0&&r.days.length===j&&r.days.every(N=>N.coverage==="complete"&&N.count===0)?"已导入范围内没有记录":r.days.some(N=>N.coverage==="partial")?"记录尚未完整导入":"这个日期范围尚未导入工作记录"};return e.jsxs("div",{className:"relative flex min-h-0 flex-1 flex-col",children:[e.jsxs("div",{className:k||S||x?"hidden":"flex min-h-0 flex-1 flex-col",children:[e.jsxs("header",{className:"flex shrink-0 items-center justify-between px-5 py-3",children:[e.jsx("h1",{className:"text-lg font-semibold",children:"工作"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(h,{variant:"ghost",size:"sm",onClick:()=>{l(r.from),m(r.to),d(j=>!j)},children:"日期"}),e.jsx(h,{variant:"ghost",size:"sm","aria-label":"工作更多",onClick:()=>n(j=>!j),children:"更多"})]})]}),g?e.jsxs("div",{className:"flex flex-wrap gap-2 border-y px-5 py-2",children:[e.jsx(h,{variant:"ghost",size:"sm",disabled:r.loading,onClick:()=>{n(!1),a.load()},children:"刷新工作"}),e.jsx(h,{variant:"ghost",size:"sm",onClick:()=>{n(!1),i()},children:"AI 回顾"}),e.jsx(h,{variant:"ghost",size:"sm",disabled:!s,onClick:()=>{n(!1),a.beginBatch([])},children:"重新归类"}),r.undo?e.jsx(h,{variant:"ghost",size:"sm",disabled:!s,onClick:()=>{n(!1),a.undo()},children:"撤销上次归类"}):null]}):null,o?e.jsxs("form",{className:"flex flex-col gap-3 border-y p-5",onSubmit:j=>{j.preventDefault(),(!c||!u||c<=u)&&(d(!1),a.dates(c,u))},children:[e.jsxs("label",{className:"text-sm",children:["开始日期",e.jsx(G,{type:"date","aria-label":"开始日期",value:c,onChange:j=>l(j.target.value)})]}),e.jsxs("label",{className:"text-sm",children:["结束日期",e.jsx(G,{type:"date","aria-label":"结束日期",value:u,onChange:j=>m(j.target.value)})]}),c&&u&&c>u?e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:"开始日期不能晚于结束日期"}):null,e.jsxs("div",{className:"flex gap-2",children:[e.jsx(h,{type:"submit",disabled:!!(c&&u&&c>u),children:"应用日期"}),e.jsx(h,{type:"button",variant:"outline",onClick:()=>{d(!1),a.dates("","")},children:"清空日期"}),e.jsx(h,{type:"button",variant:"ghost",onClick:()=>d(!1),children:"取消"})]})]}):null,r.from||r.to?e.jsxs("p",{className:"px-5 pb-2 text-sm text-muted-foreground",children:[r.from||"最早"," 至 ",r.to||"最近"]}):null,e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-5 pb-24","aria-label":"工作事实列表",children:[r.error?e.jsx("p",{role:"alert",className:"py-3 text-sm text-destructive",children:r.error}):null,[...new Set(r.items.map(j=>j.workDate))].map(j=>{var N;return e.jsxs("section",{className:"pb-5",children:[e.jsxs("h2",{className:"mb-3 text-sm font-medium text-muted-foreground",children:[v(j)," ",e.jsxs("span",{children:["· ",((N=r.days.find(C=>C.date===j))==null?void 0:N.count)??"…"," 条"]})]}),e.jsx("div",{className:"flex flex-col gap-3",children:r.items.filter(C=>C.workDate===j).map(C=>e.jsxs("button",{type:"button",onClick:()=>void a.detail(C.id),className:"rounded-2xl border bg-card p-4 text-left",children:[e.jsxs("p",{className:"mb-2 text-xs text-muted-foreground",children:[C.project??"未归类"," · ",ye[C.status]]}),e.jsx("h3",{className:"mb-2 font-semibold",children:C.title}),e.jsx("p",{className:"whitespace-pre-wrap break-words text-sm leading-7",children:C.statement})]},C.id))})]},j)}),!r.loading&&!r.items.length?e.jsx("p",{className:"py-16 text-center text-muted-foreground",children:b()}):null,r.loading?e.jsx("p",{role:"status",className:"py-8 text-center",children:"正在读取工作事实…"}):null,r.cursor?e.jsx(h,{variant:"outline",className:"w-full",disabled:r.loading,onClick:()=>void a.load(!0),children:"加载更多工作记录"}):null]}),e.jsx(h,{"aria-label":"补记工作事实",className:"absolute bottom-5 right-5 size-12 rounded-full text-2xl shadow-lg",disabled:!s,onClick:()=>void a.edit(),children:"+"})]}),x&&!k&&!S?e.jsxs("section",{className:"flex min-h-0 flex-1 flex-col","aria-label":"工作事实详情",children:[e.jsxs("header",{className:"flex items-center justify-between border-b p-4",children:[e.jsx(h,{variant:"ghost",onClick:()=>a.closeDetail(),children:"返回工作"}),e.jsx(h,{variant:"ghost",disabled:!s,onClick:()=>void a.edit(x),children:"编辑事实"})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-5",children:[e.jsxs("p",{className:"mb-3 text-sm text-muted-foreground",children:[x.workDate," · ",x.project??"未归类"," ·"," ",ye[x.status]]}),e.jsx("h2",{className:"mb-4 text-xl font-semibold",children:x.title}),e.jsx("p",{className:"mb-6 whitespace-pre-wrap break-words leading-8",children:x.statement}),e.jsx(h,{variant:"outline",disabled:!s,onClick:()=>void a.beginBatch([x]),children:"重新归类这条"})]})]}):null,k?e.jsx(ft,{model:a,writable:s}):S?e.jsx(pt,{model:a,writable:s}):null]})}const de={bodyScalars:2e4,attachmentBytes:5*1024*1024,imagesPerRecord:1,markdownPerRecord:1,defaultPageSize:20,maxPageSize:100,tagsPerRecord:2,tagScalars:20};function Me(a){if(a.length>de.tagsPerRecord)throw new Error("最多 2 个标签");const t=a.map(s=>s.trim());if(t.some(s=>!s||[...s].length>de.tagScalars||/[\u0000-\u001f\u007f\uD800-\uDFFF]/u.test(s)))throw new Error("标签须为 1–20 个字符,不能包含控制字符或无效 Unicode");if(new Set(t).size!==t.length)throw new Error("标签不能重复");return t}function mt(a,t){var s,i;return(((s=a==null?void 0:a.latest)==null?void 0:s.sequence)??0)>(((i=t==null?void 0:t.latest)==null?void 0:i.sequence)??0)?a:t??a}function gt(a){return`使用随记 Skill 处理这条记录。先读取最新原文、全部跟进和相关附件,按我本次要求执行;成功后只追加最终成果,不记录过程或失败。未经我确认,不标记完成。
|
|
12
|
+
`+JSON.stringify({format:"suiji-handoff-v1",...a},null,2)}class Ue{constructor(t,s,i,r,o=!1){P(this,"listeners",new Set);P(this,"queue",Promise.resolve());P(this,"writes",0);P(this,"active",!0);P(this,"state");P(this,"correctionAbort");P(this,"correctionKey");P(this,"subscribe",t=>(this.listeners.add(t),()=>{this.listeners.delete(t)}));P(this,"snapshot",()=>this.state);this.client=s,this.store=i,this.followupRecordId=r,this.historySupported=o,this.state={draft:t,busy:!1,localSaving:!1,message:t.frozen?"保存结果待确认,请手动重试;输入暂时锁定":"",localError:!1,conflict:!1}}get storeKey(){return this.followupRecordId?"followup:"+this.followupRecordId:"draft:"+this.state.draft.id}dispose(){var t;this.active=!1,(t=this.correctionAbort)==null||t.abort(),this.listeners.clear()}settled(){return this.queue}initialize(){return this.loadFeedbackState(),this.persist()}async discard(){if(!(this.state.busy||this.state.draft.frozen)){this.patch({busy:!0});try{await this.queue,this.check(),await this.store.remove(this.storeKey),this.patch({discarded:!0})}catch(t){this.patch({message:t instanceof Error?t.message:"放弃草稿失败"})}finally{this.patch({busy:!1})}}}check(){if(!this.active||!this.client.active)throw new DOMException("编辑会话已结束","AbortError")}patch(t){this.state={...this.state,...t},this.listeners.forEach(s=>s())}persist(t=this.state.draft){const s=structuredClone(t);++this.writes,this.patch({localSaving:!0});const i=this.queue.then(()=>this.store.set(this.storeKey,s));return this.queue=i.catch(()=>{}),i.then(()=>this.patch({localError:!1})).catch(r=>{throw this.patch({message:r instanceof Error?r.message:"本机草稿未保存",localError:!0}),r}).finally(()=>{--this.writes,this.patch({localSaving:this.writes>0})})}edit(t){if(this.state.busy||this.state.draft.frozen)return;const s={...this.state.draft,...t};this.patch({draft:s,...t.body!==void 0&&t.body!==this.state.draft.body?{correction:void 0,correctionSource:void 0}:{}}),this.persist(s).catch(()=>{})}async loadLexicon(){try{const t=await this.store.get("lexicon-intent");this.check(),this.patch({lexiconPending:!!t});const s=await this.client.request("/api/suiji/v1/correction-lexicon");this.check(),this.patch({lexicon:s})}catch(t){this.active&&this.patch({correctionMessage:t instanceof Error?t.message:"词库读取失败"})}}async correct(){const t=this.state.draft.body;if(this.state.busy||this.state.draft.frozen||!t.trim()||this.state.correctionBusy)return;if(this.correctionKey&&this.state.correctionSource!==t){this.patch({correctionMessage:"原请求结果待确认;请先取消,再对新正文发起纠错"});return}const s=new AbortController;this.correctionAbort=s;const i=this.correctionKey??crypto.randomUUID();this.correctionKey=i,this.patch({correctionBusy:!0,correction:void 0,correctionSource:t,correctionMessage:"正在纠正文字…"});try{let r=await this.client.request("/api/suiji/v1/corrections","POST",{text:t,...this.historySupported&&!this.followupRecordId?{feedbackCapable:!0,...this.state.draft.id!=="new"?{recordId:this.state.draft.id}:{}}:{}},i,s.signal);for(this.check(),this.patch({correction:r});r.status==="running"&&!s.signal.aborted;)await new Promise(o=>setTimeout(o,1e3)),this.check(),r=await this.client.request("/api/suiji/v1/corrections/"+r.id,"GET",void 0,void 0,s.signal),this.patch({correction:r});if(this.check(),s.signal.aborted)return;this.correctionKey=void 0,this.patch({correction:r,correctionMessage:r.status==="completed"?"":r.error??"纠错未完成"})}catch(r){this.active&&!s.signal.aborted&&this.patch({correctionMessage:"纠错结果待确认;再次点击会沿用同一请求。"+(r instanceof Error?r.message:"")})}finally{this.correctionAbort===s&&(this.correctionAbort=void 0,this.patch({correctionBusy:!1}))}}async cancelCorrection(){var s,i;const t=(s=this.state.correction)==null?void 0:s.id;(i=this.correctionAbort)==null||i.abort(),t&&await this.client.request("/api/suiji/v1/corrections/"+t,"DELETE").catch(()=>{}),this.correctionKey=void 0,this.patch({correction:void 0,correctionSource:void 0,correctionBusy:!1,correctionMessage:""})}applyCorrection(){const{correction:t,correctionSource:s,draft:i}=this.state;if(!t||t.status!=="completed"||!t.correctedText||s!==i.body||i.frozen||this.state.busy||!this.active||!this.client.active){this.patch({correctionMessage:"正文或编辑会话已变化,请重新纠错"});return}const r={...i,body:t.correctedText,correctionTrace:t.historyId&&this.state.correctionSource?{correctionId:t.id,inputText:this.state.correctionSource,correctedText:t.correctedText,applied:!0}:void 0};this.patch({draft:r,correction:void 0,correctionSource:void 0}),this.persist(r).catch(()=>{}),this.patch({correctionMessage:"已应用到本机草稿;点击保存才会更新记录"})}async putLexicon(t){this.check();const s=this.state.lexicon;if(!s)throw new Error("请先读取词库");const r=await this.store.get("lexicon-intent")??{key:crypto.randomUUID(),data:{expectedVersion:s.version,entries:t}};await this.store.set("lexicon-intent",r),this.patch({lexiconPending:!0});try{const o=await this.client.request("/api/suiji/v1/correction-lexicon","PUT",r.data,r.key);this.check(),await this.store.remove("lexicon-intent"),this.patch({lexicon:o,lexiconPending:!1,correctionMessage:"已记住;可在词库中撤销"})}catch(o){throw o instanceof se&&!o.uncertain&&(await this.store.remove("lexicon-intent"),this.patch({lexiconPending:!1})),this.patch({correctionMessage:o instanceof Error?o.message:"词库结果待确认,请手动重试"}),o}}async addFile(t){try{if(this.check(),t.size>de.attachmentBytes)throw new Error("每个附件最多 5 MiB");const s=["image/jpeg","image/png"].includes(t.type);if(!s&&!/\.md$/i.test(t.name))throw new Error("仅支持 JPEG、PNG 和 Markdown");s||new TextDecoder("utf-8",{fatal:!0}).decode(await t.arrayBuffer()),this.check();const i=this.state.draft,r=s?"image":"markdown";if(i.existing.some(o=>o.kind===r)||i.files.some(o=>(o.file.type.startsWith("image/")?"image":"markdown")===r))throw new Error("每条最多一张图片和一个 Markdown,请先移除原附件");s||(t=new File([t],t.name,{type:"text/markdown",lastModified:t.lastModified})),this.edit({files:[...i.files,{id:crypto.randomUUID(),file:t,key:crypto.randomUUID()}]})}catch(s){this.patch({message:s instanceof Error?s.message:"附件读取失败"})}}async save(){var t,s;if(!(this.state.busy||this.state.saved||this.state.savedFollowup)){this.patch({busy:!0,message:""});try{this.check();let i=this.state.draft;if(!this.followupRecordId&&!i.pending&&i.tags!==void 0&&(i={...i,tags:Me(i.tags)},this.patch({draft:i})),[...i.body].length>de.bodyScalars)throw new Error("正文最多 20,000 个字符");if(!i.body.trim()&&!i.existing.length&&!i.files.length)throw new Error("请输入正文或添加附件");if(await this.persist(i),this.check(),!i.pending){i={...i,frozen:!0},this.patch({draft:i}),await this.persist(i);for(const[d,c]of i.files.entries()){if(c.uploaded)continue;this.check();const l=new FormData;l.append("file",c.file,c.file.name);const u=await this.client.request("/api/suiji/v1/uploads","POST",l,c.key);this.check(),i={...i,files:i.files.map((m,g)=>g===d?{...m,uploaded:u.attachment}:m)},this.patch({draft:i}),await this.persist(i)}i={...i,pending:{path:this.followupRecordId?`/api/suiji/v1/records/${this.followupRecordId}/followups`:"/api/suiji/v1/records"+(i.id==="new"?"":"/"+i.id),method:this.followupRecordId||i.id==="new"?"POST":"PATCH",key:crypto.randomUUID(),data:{...this.followupRecordId?{}:{kind:i.kind,...i.id==="new"?{}:{expectedVersion:i.version}},body:i.body,...this.followupRecordId||i.tags===void 0?{}:{tags:i.tags},attachmentIds:[...i.existing.map(d=>d.id),...i.files.map(d=>d.uploaded.id)]}}},this.patch({draft:i}),await this.persist(i)}this.check();const r=i.pending,o=await this.client.request(r.path,r.method,r.data,r.key);if(this.check(),this.followupRecordId&&(!("followup"in o)||o.followup.recordId!==this.followupRecordId||o.followup.body!==i.body||JSON.stringify(o.followup.attachments.map(d=>d.id))!==JSON.stringify(i.files.map(d=>d.uploaded.id))||((t=o.followupSummary.latest)==null?void 0:t.sequence)!==o.followup.sequence))throw new Error("跟进响应与保存内容不一致,请手动重试确认");if("record"in o&&(o.record.body!==i.body||i.id!=="new"&&o.record.id!==i.id))throw new Error("记录响应与保存正文不一致,请手动重试确认");"record"in o&&((s=i.correctionTrace)!=null&&s.applied)&&(i.version===void 0||o.record.version>i.version)&&await this.enqueueFeedback({correctionId:i.correctionTrace.correctionId,key:crypto.randomUUID(),recordId:o.record.id,recordVersion:o.record.version,saveKey:r.key}).catch(()=>{}),await this.store.remove(this.storeKey),"record"in o&&this.retryFeedback(),"followup"in o?this.patch({savedFollowup:o}):this.patch({saved:o.record})}catch(i){if(!this.active)return;if(i instanceof se&&!i.uncertain){const r=i.detail.error.code==="VERSION_CONFLICT",o={...this.state.draft,frozen:!1,pending:void 0};this.patch({draft:o,conflict:r,message:i.message}),await this.persist(o).catch(()=>{})}else this.patch({message:(this.state.draft.frozen?"保存结果待确认,手动重试会沿用同一次请求。":"")+(i instanceof Error?i.message:"保存失败")})}finally{this.patch({busy:!1})}}}async loadPreferences(){if(this.historySupported)try{const t=await this.client.request("/api/suiji/v1/correction-preferences");this.check(),this.patch({preferences:t})}catch(t){this.patch({correctionMessage:t instanceof Error?t.message:"读取历史设置失败"})}}async setHistoryEnabled(t){const s=this.state.preferences;if(s)try{const i=await this.client.request("/api/suiji/v1/correction-preferences","PUT",{expectedVersion:s.version,historyEnabled:t},crypto.randomUUID());this.check(),this.patch({preferences:i})}catch(i){this.patch({correctionMessage:i instanceof Error?i.message:"设置失败"})}}async loadHistory(t){if(this.historySupported)try{const s=await this.client.request("/api/suiji/v1/correction-history"+(t?"?cursor="+encodeURIComponent(t):""));this.check(),this.patch({history:t&&this.state.history?{items:[...this.state.history.items,...s.items],nextCursor:s.nextCursor}:s})}catch(s){this.patch({correctionMessage:s instanceof Error?s.message:"历史读取失败"})}}async deleteHistory(t){try{await this.client.request("/api/suiji/v1/correction-history"+(t?"/"+t:""),"DELETE",void 0,crypto.randomUUID()),this.check(),await this.loadHistory(),await this.loadPreferences()}catch(s){this.patch({correctionMessage:s instanceof Error?s.message:"删除失败"})}}async loadFeedbackState(){const t=await this.store.get("feedback-intents").catch(()=>{});this.active&&this.patch({feedbackPending:!!(t!=null&&t.length)})}async enqueueFeedback(t){const s=await this.store.get("feedback-intents")??[];await this.store.set("feedback-intents",[...s,t]),this.patch({feedbackPending:!0})}async retryFeedback(){const t=await this.store.get("feedback-intents").catch(()=>{});if(!(t!=null&&t.length))return;const s=[];for(const i of t)try{await this.client.request("/api/suiji/v1/corrections/"+i.correctionId+"/feedback","POST",{recordId:i.recordId,recordVersion:i.recordVersion,saveKey:i.saveKey},i.key)}catch(r){(!(r instanceof se)||r.uncertain)&&s.push(i)}s.length?await this.store.set("feedback-intents",s):await this.store.remove("feedback-intents"),this.patch({feedbackPending:!!s.length})}async loadLatest(){if(!(this.state.busy||this.state.draft.id==="new"))try{const{record:t}=await this.client.request("/api/suiji/v1/records/"+this.state.draft.id);this.check(),this.patch({latest:t})}catch(t){this.patch({message:t instanceof Error?t.message:"读取最新版本失败"})}}acceptLatestVersion(){const t=this.state.latest;if(!t||this.state.busy||this.state.draft.frozen)return;const s={...this.state.draft,version:t.version,existing:t.attachments,files:[]};if(this.state.draft.files.length){this.patch({message:"本机还有新增附件,请先保存其文件并移除,再采用最新附件版本"});return}this.patch({draft:s,latest:void 0,conflict:!1,message:"已采用最新版本号与附件,本机正文、类型和标签选择保留;请比较后手动保存"}),this.persist(s).catch(()=>{})}}function vt({client:a,store:t,writable:s,alive:i,models:r,setEditor:o,setItems:d,setDetail:c,setMessage:l}){const u=z(g=>{if(!i.current||!a.active)return;const n=x=>({...x.version>g.version?x:g,followupSummary:mt(x.followupSummary,g.followupSummary)});d(x=>x.map(k=>k.id===g.id?n(k):k)),c(x=>(x==null?void 0:x.record.id)===g.id?{...x,record:n(x.record)}:x)}),m=z(async g=>{if(!(!s||g.deletedAt))try{const n="followup:"+g.id;let x=r.current.get(n);if(!x){const k=await t.get(n)??{id:g.id,kind:"note",body:"",existing:[],files:[]};if(!i.current)return;x=new Ue(k,a,t,g.id),r.current.set(n,x),await x.initialize()}i.current&&o(x)}catch(n){i.current&&l(n instanceof Error?n.message:"跟进草稿读取失败")}});return{acceptRecord:u,editFollowup:m}}function bt({client:a,store:t,writable:s,statusBusy:i,alive:r,setStatusBusy:o,setMessage:d,setPending:c,acceptRecord:l,setDetail:u,load:m}){return z(async(g,n)=>{var x;if(!(!s||i)){o(!0),d("");try{const k=await t.get("status:"+g.id);if(!k&&((x=await t.get("draft:"+g.id))!=null&&x.frozen))throw new Error("正文保存结果待确认,请先在编辑器确认");const S=k??{path:`/api/suiji/v1/records/${g.id}${"tags"in n?"":"trashed"in n?"/trash":"/task-status"}`,method:"tags"in n?"PATCH":"POST",key:crypto.randomUUID(),data:{expectedVersion:g.version,...n}};if(await t.set("status:"+g.id,S),!r.current)return;c(b=>new Set([...b,g.id]));const v=await a.request(S.path,S.method,S.data,S.key);if(!r.current)return;await t.remove("status:"+g.id),c(b=>{const j=new Set(b);return j.delete(g.id),j}),l(v.record),u(b=>(b==null?void 0:b.record.id)!==g.id?b:S.path.endsWith("/trash")||S.path.endsWith("/task-status")&&v.record.taskStatus==="done"?void 0:b),await m()}catch(k){if(!r.current)return;if(k instanceof se&&!k.uncertain)try{await t.remove("status:"+g.id),c(S=>{const v=new Set(S);return v.delete(g.id),v})}catch{d("本机状态确认写入失败,请手动重试");return}if(k instanceof se&&k.detail.error.code==="VERSION_CONFLICT"){try{const S=await a.request(`/api/suiji/v1/records/${g.id}`);l(S.record),d("记录已在其他地方更新,已显示最新内容,请重新选择标签或操作")}catch{d("记录已有新版本,读取失败,请返回列表重新打开后再操作")}return}d(k instanceof Error?k.message:"操作结果待确认")}finally{r.current&&o(!1)}}})}const De=["bg-emerald-100 text-emerald-900 dark:bg-emerald-950 dark:text-emerald-200","bg-blue-100 text-blue-900 dark:bg-blue-950 dark:text-blue-200","bg-purple-100 text-purple-900 dark:bg-purple-950 dark:text-purple-200","bg-pink-100 text-pink-900 dark:bg-pink-950 dark:text-pink-200","bg-orange-100 text-orange-900 dark:bg-orange-950 dark:text-orange-200","bg-teal-100 text-teal-900 dark:bg-teal-950 dark:text-teal-200"];function ke(a){let t=0;for(const s of a)t=(t*31+s.codePointAt(0))%De.length;return De[t]}function ue({tags:a=[],onSelect:t}){return a.length?e.jsx("div",{className:"relative flex flex-wrap gap-2",children:a.map(s=>t?e.jsx("button",{type:"button",className:`rounded-full px-2.5 py-1 text-xs break-all ${ke(s)}`,"aria-label":`筛选标签:${s}`,onClick:()=>t(s),children:s},s):e.jsx("span",{className:`rounded-full px-2.5 py-1 text-xs break-all ${ke(s)}`,children:s},s))}):null}function Le({selected:a=[],available:t,onChange:s}){const[i,r]=p.useState(!1),[o,d]=p.useState(""),[c,l]=p.useState(""),u=t.slice(0,6),m=n=>{try{s(Me([...a,n])),d(""),l(""),r(!1)}catch(x){l(x.message)}},g=n=>{s(a.filter(x=>x!==n)),l("")};return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.filter(n=>!u.includes(n)).map(n=>e.jsxs("button",{type:"button","aria-label":`移除标签:${n}`,className:`rounded-full px-2.5 py-1 text-sm break-all ${ke(n)}`,onClick:()=>g(n),children:[n," ×"]},n)),e.jsx(h,{type:"button",variant:"ghost",size:"sm",disabled:a.length>=2,"aria-expanded":i,onClick:()=>r(!i),children:"+标签"}),a.length>=2?e.jsx("span",{className:"text-xs text-muted-foreground",children:"最多 2 个标签"}):null]}),u.length?e.jsxs("div",{role:"group","aria-label":"最近使用的标签",className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"最近使用"}),u.map(n=>{const x=a.includes(n);return e.jsxs(h,{type:"button",variant:x?"default":"outline",size:"sm","aria-pressed":x,disabled:!x&&a.length>=2,onClick:()=>x?g(n):m(n),children:[n,x?" ✓":""]},n)})]}):null,i&&a.length<2?e.jsxs("div",{className:"flex flex-col gap-2 rounded-xl border p-3",children:[e.jsx(G,{"aria-label":"标签名称",placeholder:"搜索或创建标签",value:o,onChange:n=>d(n.target.value),onKeyDown:n=>{n.key==="Enter"&&!n.nativeEvent.isComposing&&(n.preventDefault(),m(o))}}),e.jsx("div",{className:"flex max-h-40 flex-wrap gap-2 overflow-y-auto",children:t.filter(n=>!a.includes(n)&&n.includes(o.trim())).map(n=>e.jsx(h,{type:"button",variant:"outline",size:"sm",onClick:()=>m(n),children:n},n))}),o.trim()&&!t.includes(o.trim())?e.jsxs(h,{type:"button",variant:"outline",size:"sm",onClick:()=>m(o),children:["创建「",o.trim(),"」"]}):null]}):null,c?e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:c}):null]})}function jt({available:a,selected:t,onSelect:s}){const[i,r]=p.useState(!1),[o,d]=p.useState(""),c=a.slice(0,5);if(t&&!c.includes(t)&&c.push(t),!c.length)return null;const l=u=>{s(u===t?"":u),r(!1),d("")};return e.jsxs("div",{className:"mb-4 flex flex-col gap-2","aria-label":"标签筛选",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[c.map(u=>e.jsxs(h,{type:"button",size:"sm",variant:t===u?"default":"outline","aria-pressed":t===u,onClick:()=>l(u),children:[u,t===u?" ×":""]},u)),e.jsx(h,{type:"button",variant:"ghost",size:"sm","aria-expanded":i,onClick:()=>r(!i),children:"更多标签"})]}),i?e.jsxs("div",{className:"flex flex-col gap-2 rounded-xl border p-3",children:[e.jsx(G,{"aria-label":"搜索标签",placeholder:"搜索已有标签",value:o,onChange:u=>d(u.target.value)}),e.jsx("div",{className:"flex max-h-48 flex-wrap gap-2 overflow-y-auto",children:a.filter(u=>u.includes(o.trim())).map(u=>e.jsx(h,{type:"button",size:"sm",variant:t===u?"default":"outline",onClick:()=>l(u),children:u},u))})]}):null]})}function wt(a,t){const s=[...new Set(t.map(r=>r.canonical))].filter(Boolean).sort((r,o)=>o.length-r.length),i=[];for(let r=0;r<a.length;){const o=s.find(d=>a.startsWith(d,r));if(o)i.push({text:o,term:t.find(d=>d.canonical===o)}),r+=o.length;else{const d=i.at(-1);d&&!d.term?d.text+=a.charAt(r):i.push({text:a.charAt(r)}),r++}}return i}function yt({model:a,selectedText:t,available:s}){var D,A,L,B,J,y;const i=p.useSyncExternalStore(a.subscribe,a.snapshot),[r,o]=p.useState(!1),[d,c]=p.useState(!1),[l,u]=p.useState(!1),[m,g]=p.useState(),[n,x]=p.useState(),[k,S]=p.useState("");p.useEffect(()=>{a.loadLexicon(),a.loadPreferences()},[a]);const v=((D=i.lexicon)==null?void 0:D.entries)??[],b=async()=>{if(!m||!i.lexicon)return;const w=m.canonical.trim(),I=m.variant.trim();if(!w)return;const F=structuredClone(v),M=structuredClone(v),$=M.find(E=>E.canonical===w);if($?I&&!$.variants.includes(I)&&$.variants.push(I):M.push({canonical:w,variants:I?[I]:[]}),JSON.stringify(M)===JSON.stringify(v)){S("这个写法已在词库中"),g(void 0);return}try{await a.putLexicon(M),x(F),g(void 0)}catch{}},j=async w=>{try{await a.putLexicon(v.filter(I=>I.canonical!==w))}catch{}},N=i.correction,C=(N==null?void 0:N.status)==="completed"&&N.correctedText;return e.jsxs("section",{className:"space-y-3 rounded-xl border p-4 text-sm","aria-label":"文字纠错",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(h,{type:"button",variant:"outline",disabled:!s||!i.draft.body.trim()||i.correctionBusy||i.draft.frozen,onClick:()=>void a.correct(),children:i.correctionBusy?"正在纠正…":"纠正文字"}),e.jsx(h,{type:"button",variant:"ghost",onClick:()=>c(!d),children:"纠错词库"}),a.historySupported?e.jsx(h,{type:"button",variant:"ghost",onClick:()=>{u(!l),l||a.loadHistory()},children:"历史辅助"}):null,t?e.jsx(h,{type:"button",variant:"ghost",onClick:()=>g({canonical:t,variant:""}),children:"记住选词"}):null]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"点击后,本次文字和专有词库会经 Codex CLI 发送给模型提供方。"}),s?null:e.jsx("p",{className:"text-xs text-muted-foreground",children:"此服务尚未启用文字纠错;词库仍可管理。"}),i.correctionMessage||k?e.jsx("p",{role:"status",children:k||i.correctionMessage}):null,i.feedbackPending?e.jsx(h,{type:"button",variant:"outline",onClick:()=>void a.retryFeedback(),children:"手动重试历史反馈"}):null,l&&a.historySupported?e.jsxs("div",{className:"space-y-2 rounded-lg border p-3",children:[e.jsx("strong",{children:"历史辅助"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"开启后,随记服务端会保存纠错前文本、候选和应用后实际保存的正文; 下次纠错会将少量相关修改示例连同本次文字发送给模型提供方。不会自动修改正式词库。"}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:((A=i.preferences)==null?void 0:A.historyEnabled)??!1,disabled:!i.preferences,onChange:w=>void a.setHistoryEnabled(w.target.checked)}),"启用历史辅助"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"关闭后不再新增或使用历史。清空只删除纠错派生记录,不删除随记正文或词库。"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(h,{type:"button",variant:"outline",onClick:()=>void a.loadHistory(),children:"刷新历史"}),e.jsx(h,{type:"button",variant:"outline",disabled:!((L=i.history)!=null&&L.items.length),onClick:()=>void a.deleteHistory(),children:"清空纠错历史"})]}),(B=i.history)==null?void 0:B.items.map(w=>e.jsxs("div",{className:"space-y-1 rounded border p-2",children:[e.jsxs("p",{className:"whitespace-pre-wrap break-words",children:["候选:",w.correctedText]}),e.jsxs("p",{className:"whitespace-pre-wrap break-words",children:["保存:",w.finalText]}),e.jsx(h,{type:"button",variant:"ghost",onClick:()=>void a.deleteHistory(w.id),children:"删除"})]},w.id)),(J=i.history)!=null&&J.nextCursor?e.jsx(h,{type:"button",variant:"outline",onClick:()=>{var w;return void a.loadHistory((w=i.history)==null?void 0:w.nextCursor)},children:"加载更多"}):null]}):null,i.lexiconPending?e.jsx(h,{type:"button",variant:"outline",onClick:()=>void a.putLexicon(v).then(()=>{x(v),g(void 0),S("")}).catch(()=>{}),children:"手动重试确认词库写入"}):null,C?e.jsxs("div",{className:"space-y-3 rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("strong",{children:"纠错预览"}),e.jsx(h,{type:"button",variant:"ghost",onClick:()=>o(!r),children:r?"收起原文":"查看原文"})]}),r?e.jsx("p",{className:"whitespace-pre-wrap break-words",children:i.correctionSource}):null,e.jsx("p",{className:"whitespace-pre-wrap break-words",children:wt(N.correctedText,N.suggestedTerms??[]).map((w,I)=>w.term?e.jsx("button",{type:"button",className:"decoration-dotted underline underline-offset-4",onClick:()=>g(w.term),children:w.text},I):e.jsx("span",{children:w.text},I))}),(y=N.uncertainTerms)!=null&&y.length?e.jsxs("p",{children:["仍不确定:",N.uncertainTerms.join("、"),"。请核对原文。"]}):null,e.jsxs("div",{className:"flex gap-2",children:[e.jsx(h,{type:"button",onClick:()=>a.applyCorrection(),disabled:i.draft.body!==i.correctionSource||i.draft.frozen,children:"应用到草稿"}),e.jsx(h,{type:"button",variant:"outline",onClick:()=>void a.cancelCorrection(),children:"取消"})]})]}):null,m?e.jsxs("div",{className:"space-y-2 rounded-lg border p-3",children:[e.jsx("strong",{children:"记住这个写法"}),e.jsxs("label",{className:"block",children:["正确写法",e.jsx("input",{className:"w-full rounded border bg-background p-2",value:m.canonical,onChange:w=>g({...m,canonical:w.target.value})})]}),e.jsxs("label",{className:"block",children:["误识别写法(可留空)",e.jsx("input",{className:"w-full rounded border bg-background p-2",value:m.variant,onChange:w=>g({...m,variant:w.target.value})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(h,{type:"button",disabled:i.lexiconPending||!i.lexicon,onClick:()=>void b(),children:"加入词库"}),e.jsx(h,{type:"button",variant:"ghost",onClick:()=>g(void 0),children:"取消"})]})]}):null,n?e.jsx(h,{type:"button",variant:"ghost",onClick:()=>{a.putLexicon(n).then(()=>x(void 0)).catch(()=>{})},children:"撤销本次添加"}):null,d?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("strong",{children:"纠错词库"}),e.jsx(h,{type:"button",variant:"ghost",onClick:()=>void a.loadLexicon(),children:"刷新"})]}),v.map(w=>e.jsxs("div",{className:"flex items-center justify-between gap-2 rounded border p-2",children:[e.jsxs("span",{children:[w.canonical,w.variants.length?` ← ${w.variants.join("、")}`:""]}),e.jsx(h,{type:"button",variant:"ghost",onClick:()=>void j(w.canonical),children:"移除"})]},w.canonical)),e.jsx(h,{type:"button",variant:"outline",onClick:()=>g({canonical:"",variant:""}),children:"新增词条"})]}):null]})}function kt({model:a,onClose:t,onSaved:s,onFollowupSaved:i,onDiscard:r,availableTags:o,correctionAvailable:d}){const c=p.useSyncExternalStore(a.subscribe,a.snapshot),{draft:l,busy:u}=c,m=z(s),[g,n]=p.useState(""),x=z(v=>{const b=Array.from(v.clipboardData.files).find(j=>j.type.startsWith("image/"));b&&(v.preventDefault(),v.stopPropagation(),!u&&!l.frozen&&a.addFile(b))}),k=z(v=>i==null?void 0:i(v));p.useEffect(()=>{c.savedFollowup&&k(c.savedFollowup)},[c.savedFollowup,k]);const S=z(r);return p.useEffect(()=>{c.saved&&m(c.saved)},[c.saved,m]),p.useEffect(()=>{c.discarded&&S()},[c.discarded,S]),e.jsxs(Ae,{title:a.followupRecordId?"追加跟进":l.id==="new"?"记下一点什么":"编辑记录",onBack:t,busy:u,onPaste:x,description:l.frozen?"保存结果待确认,请手动重试":"草稿自动保留,点保存后上传。",children:[e.jsxs("fieldset",{disabled:u||l.frozen,className:"flex flex-col gap-4",children:[a.followupRecordId?null:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{children:"类型"}),e.jsx("div",{role:"group","aria-label":"记录类型",className:"inline-flex gap-1 rounded-xl bg-secondary p-1",children:[["note","想法"],["task","待办"]].map(([v,b])=>e.jsx(h,{type:"button",size:"sm",variant:l.kind===v?"default":"ghost","aria-pressed":l.kind===v,onClick:()=>a.edit({kind:v}),children:b},v))})]}),!a.followupRecordId&&l.id!=="new"?e.jsx("p",{className:"text-sm text-muted-foreground",children:"切换为待办时设为未完成;切换为想法时清除待办状态。"}):null,e.jsxs("label",{className:"flex flex-col gap-2",children:[a.followupRecordId?"跟进内容":"原文",e.jsx("textarea",{"aria-label":a.followupRecordId?"跟进内容":"原文",value:l.body,onChange:v=>a.edit({body:v.target.value}),onSelect:v=>{const b=v.currentTarget;n(b.value.slice(b.selectionStart,b.selectionEnd).trim().slice(0,80))},placeholder:"此刻的想法、一个链接,或者以后想做的事……",className:"min-h-56 resize-y rounded-xl border bg-background p-4 leading-relaxed outline-none focus:ring-2 focus:ring-ring"})]}),d!==void 0?e.jsx(yt,{model:a,selectedText:g,available:d}):null,a.followupRecordId?null:e.jsx(Le,{selected:l.tags,available:o,onChange:v=>a.edit({tags:v})}),e.jsxs("span",{className:"text-right text-xs text-muted-foreground",children:[[...l.body].length.toLocaleString()," / 20,000"]}),e.jsxs("label",{className:"flex flex-col gap-2 text-sm",children:["添加图片或 Markdown",e.jsx("span",{className:"text-xs text-muted-foreground",children:"可在编辑区按 ⌘V / Ctrl+V 粘贴图片。"}),e.jsx("input",{"aria-label":"添加附件",type:"file",accept:"image/jpeg,image/png,.md",onChange:v=>{var j;const b=(j=v.target.files)==null?void 0:j[0];v.target.value="",b&&a.addFile(b)}})]}),[...l.existing.map(v=>({id:v.id,name:v.fileName,existing:!0})),...l.files.map(v=>({id:v.id,name:v.file.name,existing:!1}))].map(v=>e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-lg border p-3",children:[e.jsx("span",{className:"truncate",children:v.name}),e.jsx(h,{type:"button",size:"sm",variant:"ghost",onClick:()=>a.edit(v.existing?{existing:l.existing.filter(b=>b.id!==v.id)}:{files:l.files.filter(b=>b.id!==v.id)}),children:"移除"})]},v.id))]}),c.message?e.jsx("p",{role:"alert",className:"whitespace-pre-wrap text-sm text-destructive",children:c.message}):null,c.conflict?e.jsx(h,{variant:"outline",onClick:()=>void a.loadLatest(),children:"查看最新原文"}):null,c.latest?e.jsxs("section",{className:"flex flex-col gap-3 rounded-xl border p-4",children:[e.jsx("p",{children:"云端标签"}),e.jsx(ue,{tags:c.latest.tags}),e.jsxs("p",{children:["本机标签",l.tags===void 0?":未修改,保存时保留云端标签":""]}),e.jsx(ue,{tags:l.tags}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["服务端版本 ",c.latest.version,",类型:",c.latest.kind==="note"?"想法":"待办","。请与上方本机草稿比较"]}),e.jsx("p",{className:"whitespace-pre-wrap break-words",children:c.latest.body}),e.jsx(h,{variant:"outline",onClick:()=>a.acceptLatestVersion(),children:"保留本机正文、类型和标签选择,采用最新版本继续编辑"})]}):null,e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{role:"status",className:"text-xs text-muted-foreground",children:c.localError?"本机草稿未保存":c.localSaving?"正在保存本机草稿…":"本机草稿已保存"}),e.jsx(h,{disabled:u,onClick:()=>void a.save(),children:u?"正在保存…":l.frozen?"手动重试确认":"保存"})]}),e.jsx(h,{variant:"ghost",disabled:u||l.frozen,onClick:()=>{window.confirm("放弃这份本机草稿?已保存的记录不会改变。")&&a.discard()},children:"放弃本机草稿"})]})}function Nt({record:a,client:t,writable:s,onAdd:i,onRecord:r,onOpenLink:o}){var v;const[d,c]=p.useState([]),[l,u]=p.useState(null),[m,g]=p.useState(!1),[n,x]=p.useState(""),k=p.useRef(0),S=z(async(b=!1)=>{const j=++k.current;g(!0),x("");try{const N=`/api/suiji/v1/records/${a.id}`,[C,D]=await Promise.all([t.request(N+"/followups"+(b&&l?"?cursor="+encodeURIComponent(l):"")),b?void 0:t.request(N)]);if(!t.active||j!==k.current)return;c(A=>b?[...A,...C.items.filter(L=>!A.some(B=>B.id===L.id))]:C.items),u(C.nextCursor),D&&r(D.record)}catch(N){j===k.current&&x(N instanceof Error?N.message:"跟进读取失败")}finally{j===k.current&&g(!1)}});return p.useEffect(()=>{const b=k;return S(),()=>{++b.current}},[S,a.id,t]),e.jsxs("section",{className:"flex flex-col gap-4 border-t pt-4","aria-label":"跟进",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("h3",{children:["跟进 ",((v=a.followupSummary)==null?void 0:v.count)??d.length," 条"]}),e.jsx(h,{variant:"ghost",disabled:m,onClick:()=>void S(),children:"刷新跟进"}),a.deletedAt?null:e.jsx(h,{disabled:!s,onClick:i,children:"追加跟进"})]}),n?e.jsx("p",{role:"alert",className:"text-destructive",children:n}):null,d.map(b=>e.jsxs("article",{className:"flex flex-col gap-2 rounded-xl border p-4",children:[e.jsxs("p",{className:"text-xs text-muted-foreground",children:[b.source.actor==="app"?"你":`Agent${b.source.agentName?" · "+b.source.agentName:""}`," ","· ",he(b.createdAt)]}),b.source.sessionId?e.jsxs("p",{className:"break-all text-xs text-muted-foreground",children:["会话:",b.source.sessionId]}):null,e.jsx(Ne,{body:b.body,onOpenLink:o}),b.attachments.map(j=>e.jsx(Be,{attachment:j,client:t},j.id))]},b.id)),m?e.jsx("p",{role:"status",children:"正在读取跟进…"}):null,l?e.jsx(h,{variant:"outline",disabled:m,onClick:()=>void S(!0),children:"加载更早跟进"}):null]})}const Se=a=>a.kind==="note"?"想法":{open:"未完成",done:"已完成",archived:"不再做"}[a.taskStatus??"open"];function St({record:a,onOpenLink:t,client:s,onTag:i,availableTags:r,onTagsChange:o,message:d,onClose:c,onEdit:l,onStatus:u,onTrash:m,onReview:g,onRecreate:n,info:x,onFollowup:k,onRecord:S,writable:v,pending:b,busy:j,citedVersion:N}){var F,M;const[C,D]=p.useState(!1),[A,L]=p.useState(!1),[B,J]=p.useState(!1),[y,w]=p.useState("");p.useEffect(()=>{w("")},[a.id,a.body]),p.useEffect(()=>{if(!y)return;const $=window.setTimeout(()=>w(""),2500);return()=>window.clearTimeout($)},[y]);const I=z(async()=>{J(!0),w("");try{await navigator.clipboard.writeText(a.body),w(a.attachments.length?"正文已复制,附件未包含":"正文已复制")}catch{w("复制失败,请重试或选择正文手动复制")}finally{J(!1)}});return e.jsxs(Ae,{title:Se(a),description:he(a.createdAt),onBack:c,actions:e.jsxs(e.Fragment,{children:[e.jsx(h,{variant:"ghost",size:"icon","aria-label":"复制",title:a.body?"复制":"暂无正文可复制",disabled:!a.body||B,onClick:()=>void I(),children:e.jsx(_e,{className:"size-4"})}),e.jsx(h,{variant:"ghost",disabled:!v||b||j||!!a.deletedAt,onClick:l,children:"编辑"})]}),feedback:y?e.jsx("div",{className:"pointer-events-none absolute inset-x-4 bottom-5 z-10 flex justify-center",children:e.jsx("p",{role:"status",className:"rounded-full border bg-popover px-4 py-2.5 text-center text-sm text-popover-foreground shadow-lg",children:y})}):null,children:[N!==void 0&&N!==a.version?e.jsxs("p",{role:"status",className:"text-sm text-muted-foreground",children:["此记录已更新;回答引用的是版本 ",N,",下方是当前原文。"]}):null,e.jsx(Ne,{body:a.body,onOpenLink:t}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(ue,{tags:a.tags,onSelect:i}),a.deletedAt?null:e.jsx(h,{variant:"ghost",size:"sm",disabled:!v||b||j,"aria-expanded":A,onClick:()=>L(!A),children:A?"收起标签":(((F=a.tags)==null?void 0:F.length)??0)>=2?"管理标签":"添加标签"})]}),A&&!a.deletedAt?e.jsxs("fieldset",{disabled:!v||b||j,"aria-label":"快速编辑标签",className:"min-w-0 space-y-2 rounded-xl border p-3 disabled:opacity-60",children:[e.jsx(Le,{selected:a.tags,available:r,onChange:o}),e.jsx("p",{role:"status",className:"text-xs text-muted-foreground",children:j?"正在保存标签…":b?"保存结果待确认,请手动确认":"选择或移除后自动保存,最多 2 个标签"})]}):null,d?e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:d}):null,e.jsx("div",{className:"flex flex-wrap gap-2",children:a.attachments.map($=>e.jsx(Be,{attachment:$,client:s},$.id))}),(M=x.features)!=null&&M.followups?e.jsxs(e.Fragment,{children:[a.deletedAt?null:e.jsx(h,{variant:"outline",onClick:()=>{navigator.clipboard.writeText(gt({endpoint:s.endpoint,serverId:x.serverId,ownerId:x.ownerId,recordId:a.id})).then(()=>w("交接指令已复制"),()=>w("复制失败,请重试"))},children:"交给 Agent"}),e.jsx(Nt,{record:a,client:s,writable:v,onAdd:k,onRecord:S,onOpenLink:t})]}):null,a.deletedAt?e.jsx("p",{role:"status",children:"已在回收站,恢复后可继续编辑。"}):null,b?e.jsx(h,{disabled:!v||j,onClick:()=>u("done"),children:"操作结果待确认 · 手动确认"}):null,e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(h,{variant:"outline",disabled:!!a.deletedAt,onClick:g,children:"聊聊这条"}),!a.deletedAt&&a.kind==="task"&&(a.taskStatus==="open"||b)?e.jsxs(e.Fragment,{children:[e.jsx(h,{disabled:!v||j,onClick:()=>u("done"),children:b?"手动确认操作":"标记完成"}),b?null:e.jsx(h,{variant:"outline",disabled:!v||j,onClick:()=>u("archived"),children:"不再做"})]}):!a.deletedAt&&a.taskStatus==="done"?e.jsx(h,{disabled:!v||j||b,onClick:()=>u("open"),children:"撤销完成"}):!a.deletedAt&&a.kind==="task"?e.jsx(h,{disabled:!v,onClick:n,children:"再次想做"}):null,a.deletedAt?e.jsx(h,{disabled:!v||b||j,onClick:()=>m(!1),children:"恢复记录"}):C?e.jsxs("div",{className:"flex flex-wrap items-center gap-2",role:"alert",children:[e.jsx("span",{children:"移入回收站后可恢复,正文和附件会保留。"}),e.jsx(h,{variant:"destructive",disabled:!v||b||j,onClick:()=>{D(!1),m(!0)},children:"确认移入回收站"}),e.jsx(h,{variant:"ghost",onClick:()=>D(!1),children:"取消"})]}):e.jsx(h,{variant:"destructive",disabled:!v||b||j,onClick:()=>D(!0),children:"移入回收站"})]})]})}function Ct({record:a,pending:t,onOpen:s,onOpenLink:i,onTag:r}){var o;return e.jsxs("article",{className:"relative flex flex-col gap-3 rounded-2xl border bg-card p-4 text-left shadow-sm transition-colors hover:bg-accent",children:[e.jsx("button",{type:"button","aria-label":`查看记录:${a.body||"附件记录"}`,onClick:s,className:"absolute inset-0 rounded-2xl focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"}),e.jsxs("span",{className:"pointer-events-none relative flex items-center justify-between gap-3 text-xs text-muted-foreground",children:[e.jsxs("span",{children:[Se(a),t?" · 状态待确认":""]}),e.jsx("time",{children:he(a.createdAt)})]}),e.jsx(Ne,{onOpenLink:i,body:a.body||"附件记录",className:"pointer-events-none relative line-clamp-5"}),a.attachments.length?e.jsx("span",{className:"pointer-events-none relative text-xs text-muted-foreground",children:a.attachments.map(d=>d.fileName).join(" · ")}):null,(o=a.followupSummary)!=null&&o.latest?e.jsxs("p",{className:"pointer-events-none relative truncate text-sm text-muted-foreground",children:["跟进 ",a.followupSummary.count," 条 · ",a.followupSummary.latest.excerpt]}):null,e.jsx(ue,{tags:a.tags,onSelect:r})]})}function Et({client:a,info:t,scope:s,onScope:i,onOpen:r,onSave:o,writable:d,onLockedChange:c}){var J;const[l,u]=p.useState(""),[m,g]=p.useState([]),[n,x]=p.useState(),[k,S]=p.useState(!1),[v,b]=p.useState(""),j=p.useRef(void 0),N=p.useRef(!0);p.useEffect(()=>{c==null||c(!!(j.current||k||(n==null?void 0:n.status)==="running"))},[k,n,v,c]),p.useEffect(()=>(N.current=!0,()=>{N.current=!1}),[]);const C=z(async()=>{if(!(k||(n==null?void 0:n.status)==="running")){S(!0),b(""),j.current??(j.current={key:crypto.randomUUID(),input:{question:l,scope:s,history:m.flatMap(y=>{var w;return[{role:"user",text:y.question},{role:"assistant",text:((w=y.job.answer)==null?void 0:w.text)??""}]}).slice(-6)}});try{const y=await a.request("/api/suiji/v1/reviews","POST",j.current.input,j.current.key);N.current&&x(y)}catch(y){N.current&&b((y instanceof Error?y.message:"回顾请求失败")+"。问题保留,点击手动确认可重查同一次请求。")}finally{N.current&&S(!1)}}}),D=z(y=>{x(y),y.status!=="running"&&(y.status==="completed"?(g(w=>{var I;return[...w,{question:((I=j.current)==null?void 0:I.input.question)??l,job:y}]}),u(""),b("")):b(y.error??(y.status==="cancelled"?"已取消,原问题保留":"回顾未完成")),j.current=void 0)});p.useEffect(()=>{if(!n)return;if(n.status!=="running"){j.current&&D(n);return}let y=!0,w;const I=async()=>{try{const F=await a.request("/api/suiji/v1/reviews/"+n.id);if(!y)return;F.status!=="running"?D(F):w=setTimeout(()=>void I(),1500)}catch(F){y&&b((F instanceof Error?F.message:"无法读取进度")+"。可手动查询此回顾的进度。")}};return w=setTimeout(()=>void I(),800),()=>{y=!1,clearTimeout(w)}},[a,n,D]);const A=z(async()=>{if(n)try{D(await a.request("/api/suiji/v1/reviews/"+n.id)),b("")}catch(y){b(y instanceof Error?y.message:"查询失败")}}),L=z(async()=>{if(n)try{D(await a.request("/api/suiji/v1/reviews/"+n.id,"DELETE"))}catch(y){b(y instanceof Error?y.message:"取消失败,请手动重试")}}),B=k||(n==null?void 0:n.status)==="running";return(J=t.ai)!=null&&J.enabled?e.jsxs("section",{className:"flex flex-col gap-7",children:[e.jsxs("header",{className:"flex flex-col gap-2",children:[e.jsx("h2",{className:"text-xl font-semibold",children:"从记录里,接着想"}),e.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:"主动发问后才检索。回答引用实际原文,保存结论由你决定。"})]}),m.map(y=>e.jsxs("article",{className:"flex flex-col gap-4",children:[e.jsx("p",{className:"ml-8 rounded-2xl bg-secondary p-4 whitespace-pre-wrap",children:y.question}),e.jsxs("div",{className:"flex flex-col gap-4 rounded-2xl border bg-card p-5",children:[e.jsx("p",{className:"whitespace-pre-wrap break-words leading-7",children:y.job.answer.text}),y.job.answer.citations.map((w,I)=>e.jsxs("button",{className:"flex flex-col gap-1 rounded-xl border p-3 text-left hover:bg-accent",onClick:()=>r(w.recordId,w.version),children:[e.jsxs("span",{className:"text-xs text-muted-foreground",children:["[",I+1,"] ",he(w.createdAt)," ·"," ",Se(w)," · 版本 ",w.version,w.attachment?` · ${w.attachment.fileName}`:""]}),e.jsx("span",{className:"whitespace-pre-wrap break-words text-sm",children:w.quote||"已读取图片附件"})]},I)),e.jsxs("p",{className:"text-xs leading-5 text-muted-foreground",children:["本次查看 ",y.job.answer.coverage.listedRecords," 条摘要、",y.job.answer.coverage.readRecords," 条原文、",y.job.answer.coverage.attachmentReads," ","段附件。关键词检索,未启用向量索引,未读取外链。"]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(h,{variant:"outline",size:"sm",disabled:!d,onClick:()=>o(y.job.answer.text,"note"),children:"另存笔记"}),e.jsx(h,{variant:"outline",size:"sm",disabled:!d,onClick:()=>o(y.job.answer.text,"task"),children:"新建待办"})]})]})]},y.job.id)),e.jsxs("form",{className:"flex flex-col gap-3 rounded-2xl border bg-card p-5",onSubmit:y=>{y.preventDefault(),C()},children:[e.jsxs("label",{className:"flex items-center gap-3 text-sm",children:["回顾范围",e.jsxs("select",{"aria-label":"回顾范围",disabled:B||!!j.current,value:s.kind,onChange:y=>i({kind:y.target.value}),className:"rounded-lg border bg-background p-2",children:[e.jsx("option",{value:"all",children:"全部历史"}),e.jsx("option",{value:"open",children:"当前待办"}),s.kind==="record"?e.jsx("option",{value:"record",children:"这条记录"}):null]})]}),e.jsx("label",{className:"sr-only",htmlFor:"suiji-question",children:"向随记提问"}),e.jsx("textarea",{id:"suiji-question",value:l,disabled:B||!!j.current,onChange:y=>u(y.target.value),maxLength:4e3,placeholder:"以前有哪些想做、后来放下的事?",className:"min-h-28 resize-y rounded-xl border bg-background p-3 leading-6"}),B?e.jsx("p",{role:"status",className:"text-sm text-muted-foreground",children:"正在检索与回顾,可以继续浏览记录…"}):null,v?e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:v}):null,e.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[v&&!k?e.jsx(h,{type:"button",variant:"ghost",onClick:()=>{j.current=void 0,x(void 0),b("")},children:"结束此次等待,重新提问"}):null,(n==null?void 0:n.status)==="running"?e.jsxs(e.Fragment,{children:[e.jsx(h,{type:"button",variant:"outline",onClick:()=>void A(),children:"查询进度"}),e.jsx(h,{type:"button",variant:"outline",onClick:()=>void L(),children:"取消回顾"})]}):e.jsx(h,{type:"submit",disabled:k||!l.trim(),children:j.current?"手动确认请求":"发送"})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"对话仅保留在当前页面会话,刷新后不会自动重新执行。服务上的回顾结果保留 30 分钟。"})]}):e.jsxs("section",{className:"flex flex-col gap-3 py-16 text-center",children:[e.jsx("h2",{className:"text-xl",children:"AI 回顾尚未启用"}),e.jsx("p",{className:"text-muted-foreground",children:"当前服务没有可用的回顾模型。记录和待办仍可正常使用。"})]})}function It({active:a,disabled:t,loading:s,cursor:i,load:r}){const o=p.useRef(null),d=p.useRef(null),c=p.useRef(null),[l,u]=p.useState(!1);return p.useEffect(()=>{const m=o.current,g=d.current;if(!a||t||s||!i||l||!m||!g)return;const n=new IntersectionObserver(([x])=>{x!=null&&x.isIntersecting&&(n.disconnect(),r(!0))},{root:m,rootMargin:"0px 0px 200px 0px"});return n.observe(g),()=>n.disconnect()},[a,t,s,i,l,o,d,r]),{failed:l,scrollContainer:o,trigger:d,begin:(m,g,n)=>m&&(!g||n||c.current===g)?!1:(c.current=m?g:null,u(!1),!0),fail:m=>{m&&(c.current=null,u(!0))}}}function Rt({cursor:a,failed:t,loading:s,trigger:i,onRetry:r}){return e.jsx("div",{ref:i,className:"flex min-h-px justify-center gap-3",children:a&&t?e.jsx(h,{variant:"outline",disabled:s,onClick:r,children:"重试加载"}):null})}function Tt({connection:a,active:t=!0,headerActions:s,onOpenLink:i}){var Te,qe,ze;const{client:r,info:o,store:d}=a,[c]=p.useState(()=>new ht(r,d)),[l,u]=p.useState(!1),[m,g]=p.useState(),[n,x]=p.useState("records"),[k,S]=p.useState(""),[v,b]=p.useState("open"),[j,N]=p.useState(""),[C,D]=p.useState(""),[A,L]=p.useState([]),[B,J]=p.useState(!1),y=Ge(j,{wait:250}),w=p.useRef(0),[I,F]=p.useState([]),[M,$]=p.useState(null),[E,ne]=p.useState(!1),[fe,Y]=p.useState(""),[q,ee]=p.useState(),[V,ae]=p.useState(),[$e,Ce]=p.useState({kind:"all"}),[pe,xe]=p.useState(new Set),[Ee,Ve]=p.useState(!1),[te,Oe]=p.useState(!1),O=p.useRef(!0),Z=p.useRef(0),me=p.useRef(!1),le=p.useRef(void 0),ie=p.useRef(new Map),ge=z(async()=>{if(!(me.current||!navigator.locks)){me.current=!0;try{await navigator.locks.request("suiji-editor:"+d.scope,{ifAvailable:!0},async f=>{!f||!O.current||(Oe(!0),await new Promise(R=>{le.current=R}))})}finally{me.current=!1}}});p.useEffect(()=>{var R;O.current=!0,ge(),(R=o.features)!=null&&R.workRecords&&c.initialize();const f=ie.current;return()=>{O.current=!1,f.forEach(T=>T.dispose()),c.dispose(),Promise.all([...f.values()].map(T=>T.settled()).concat(c.settled())).finally(()=>{var T;(T=le.current)==null||T.call(le),d.close()})}},[ge,d,c,o]);const X=z(async(f=!1)=>{if(n==="ai"||n==="work"||!oe.begin(f,M,E))return;const R=++Z.current;ne(!0),Y(""),f||(F([]),$(null));const T=new URLSearchParams;n==="tasks"?(T.set("kind","task"),T.set("taskStatus",v)):k&&T.set("kind",k),n==="trash"&&T.set("trash","true"),y&&T.set("q",y),C&&T.set("tag",C),f&&M&&T.set("cursor",M);try{const[_,U]=await Promise.all([r.request("/api/suiji/v1/records?"+T),f?void 0:r.request("/api/suiji/v1/tags")]);if(!O.current||R!==Z.current)return;U&&L(U.items);const Q=await Promise.all(_.items.map(async H=>await d.get("status:"+H.id)?H.id:void 0));if(!O.current||R!==Z.current)return;F(H=>f?[...H,..._.items.filter(K=>!H.some(Ke=>Ke.id===K.id))]:_.items),$(_.nextCursor),xe(H=>new Set([...f?H:[],...Q.filter(K=>!!K)]))}catch(_){O.current&&R===Z.current&&(oe.fail(f),Y(_ instanceof Error?_.message:"读取失败"))}finally{O.current&&R===Z.current&&ne(!1)}});p.useEffect(()=>{t&&X()},[X,n,k,v,y,C,t]);const oe=It({active:t,disabled:n==="ai"||n==="work"||!!(q||V),loading:E,cursor:M,load:X}),ve=z(f=>{++Z.current,++w.current,F([]),$(null),ee(void 0),n==="ai"&&x("records"),f===C?X():D(f)}),Ie=z(async(f,R)=>{const T=Z.current,_=++w.current;try{const{record:U}=await r.request("/api/suiji/v1/records/"+f),Q=await d.get("status:"+f);if(!O.current||T!==Z.current||_!==w.current)return;xe(H=>{const K=new Set(H);return Q?K.add(f):K.delete(f),K}),F(H=>H.map(K=>K.id===U.id&&K.version<=U.version?U:K)),ee({record:U,citedVersion:R})}catch(U){O.current&&Y(U instanceof Error?U.message:"读取失败")}}),ce=z(async(f,R="task",T="")=>{var _;if(!(!te||f!=null&&f.deletedAt))try{if(f&&await d.get("status:"+f.id))throw new Error("记录操作待确认,请先手动确认");const U=(f==null?void 0:f.id)??"new";let Q=ie.current.get(U);if(Q&&T&&Y("已恢复原有草稿;新结论未覆盖它。请先处理当前草稿,再另存结论。"),!Q){const H=await d.get("draft:"+U);if(!O.current)return;const K=H??{id:U,kind:(f==null?void 0:f.kind)??R,body:(f==null?void 0:f.body)??T,tags:(f==null?void 0:f.tags)??[],version:f==null?void 0:f.version,existing:(f==null?void 0:f.attachments)??[],files:[]};Q=new Ue(K,r,d,void 0,((_=o.features)==null?void 0:_.correctionHistory)===!0),ie.current.set(U,Q),H&&T&&Y("已恢复原有草稿;新结论未覆盖它。请先处理当前草稿,再另存结论。"),await Q.initialize()}O.current&&ae(Q)}catch(U){O.current&&Y(U instanceof Error?U.message:"草稿读取失败")}}),{acceptRecord:be,editFollowup:He}=vt({client:r,store:d,writable:te,alive:O,models:ie,setEditor:ae,setItems:F,setDetail:ee,setMessage:Y}),je=bt({client:r,store:d,writable:te,statusBusy:Ee,alive:O,setStatusBusy:Ve,setMessage:Y,setPending:xe,acceptRecord:be,setDetail:ee,load:X}),Re=I.filter(f=>!!f.deletedAt==(n==="trash")&&(!C||(f.tags??[]).includes(C))&&(n==="tasks"?f.kind==="task"&&f.taskStatus===v:!k||f.kind===k)&&(n!=="records"||f.taskStatus!=="done"&&f.taskStatus!=="archived"||pe.has(f.id)));return e.jsxs("main",{className:"relative flex h-full min-h-0 flex-col bg-background text-foreground",children:[s&&n!=="ai"&&n!=="work"&&!q&&!V?Qe.createPortal(e.jsx(h,{variant:"ghost",size:"icon","aria-label":E?"刷新中":"刷新",title:"刷新",disabled:E,onClick:()=>void X(),children:e.jsx(Ze,{className:`size-4 ${E?"animate-spin":""}`})}),s):null,e.jsxs("div",{className:q||V?"hidden":"flex min-h-0 flex-1 flex-col",children:[(Te=o.features)!=null&&Te.workRecords?e.jsx("div",{className:n==="work"?"flex min-h-0 flex-1 flex-col":"hidden",children:e.jsx(xt,{model:c,active:n==="work",writable:te,onReview:()=>{g({tab:"work"}),x("ai")}})}):null,e.jsxs("div",{ref:oe.scrollContainer,className:n==="work"?"hidden":"min-h-0 flex-1 overflow-y-auto px-5 pt-4",children:[te?null:e.jsxs("div",{className:"flex items-center justify-between gap-4 rounded-xl border p-4 text-sm",children:[e.jsx("p",{children:"另一随记页面正在编辑,当前可浏览。关闭那一页后可接管编辑。"}),e.jsx(h,{variant:"outline",size:"sm",onClick:()=>void ge(),children:"接管编辑"})]}),fe?e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:fe}):null,e.jsxs("div",{hidden:n!=="ai",className:"pb-6",children:[m?e.jsxs(h,{variant:"ghost",onClick:()=>{x(m.tab),ee(m.detail),g(void 0)},children:["返回",m.detail?"原记录":"工作"]}):null,e.jsx(Et,{client:r,info:o,scope:$e,onScope:Ce,onOpen:(f,R)=>void Ie(f,R),onSave:(f,R)=>void ce(void 0,R,f),writable:te,onLockedChange:u})]}),n!=="ai"&&n!=="work"?e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"mb-4 flex flex-wrap items-center justify-between gap-3",children:[n==="tasks"?e.jsxs("label",{className:"flex items-center gap-3 text-sm",children:["状态",e.jsxs("select",{"aria-label":"待办状态",value:v,onChange:f=>b(f.target.value),className:"rounded-xl border bg-card p-2",children:[e.jsx("option",{value:"open",children:"未完成"}),e.jsx("option",{value:"done",children:"已完成"}),e.jsx("option",{value:"archived",children:"不再做"})]})]}):e.jsx("div",{className:"flex items-center gap-3 text-sm",children:e.jsx("div",{role:"group","aria-label":"类型筛选",className:"inline-flex gap-1 rounded-xl bg-secondary p-1",children:[["","全部"],["note","想法"],["task","待办"]].map(([f,R])=>e.jsx(h,{type:"button",size:"sm",variant:k===f?"default":"ghost","aria-pressed":k===f,onClick:()=>S(f),children:R},f))})}),e.jsx(h,{variant:"ghost",size:"icon","aria-label":"搜索记录","aria-pressed":B,onClick:()=>{B&&N(""),J(f=>!f)},children:e.jsx(Xe,{className:"size-4"})}),B?e.jsx(G,{autoFocus:!0,"aria-label":"搜索原文",placeholder:"搜索正文关键词",value:j,onChange:f=>N(f.target.value),className:"w-full"}):null]}),e.jsx(jt,{available:A,selected:C,onSelect:ve}),e.jsxs("section",{className:"flex flex-col gap-4 pb-20",children:[Re.map(f=>e.jsx(Ct,{record:f,pending:pe.has(f.id),onOpen:()=>void Ie(f.id),onOpenLink:i,onTag:ve},f.id)),E?e.jsx("p",{role:"status",className:"py-8 text-center text-muted-foreground",children:"正在读取记录…"}):Re.length===0?e.jsxs("div",{className:"flex flex-col gap-3 py-16 text-center",children:[e.jsx("h2",{className:"text-xl",children:j||C?"没有找到匹配的原文":n==="trash"?"回收站为空":"留一点想法在这里"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:j||C?"试试其他标签或更短的关键词。":n==="trash"?"删除的记录会保留在这里,可随时恢复。":"点右下角加号,记下一句想到的事。"})]}):null,e.jsx(Rt,{cursor:M,failed:oe.failed,loading:E,trigger:oe.trigger,onRetry:()=>void X(!0)})]})]}):null]}),n!=="trash"&&n!=="ai"&&n!=="work"?e.jsx(h,{"aria-label":"新增记录",className:"absolute bottom-20 right-5 size-12 rounded-full shadow-lg",disabled:!te,onClick:()=>void ce(),children:e.jsx(Ye,{})}):null,e.jsx("nav",{"aria-label":"随记导航",className:"grid shrink-0 grid-cols-4 border-t bg-background px-2 py-2",children:[["records","记录",et],["tasks","待办",ut],["trash","回收站",tt],(qe=o.features)!=null&&qe.workRecords?["work","工作",ct]:["ai","AI",st]].map(([f,R,T])=>e.jsxs("button",{type:"button","aria-current":n===f?"page":void 0,className:`flex flex-col items-center gap-1 rounded-lg py-2 text-xs ${n===f?"bg-secondary text-primary":"text-muted-foreground hover:bg-accent"}`,onClick:()=>{++Z.current,x(f)},children:[e.jsx(T,{className:"size-5"}),R]},f))})]}),q&&!V?e.jsx(St,{onOpenLink:i,...q,client:r,info:o,onFollowup:()=>void He(q.record),onRecord:be,onTag:ve,availableTags:A,onTagsChange:f=>void je(q.record,{tags:f}),message:fe,onClose:()=>ee(void 0),onEdit:()=>void ce(q.record),onStatus:f=>void je(q.record,{targetStatus:f}),onTrash:f=>void je(q.record,{trashed:f}),onReview:()=>{g({tab:n,detail:q}),l||Ce({kind:"record",recordId:q.record.id}),ee(void 0),x("ai")},onRecreate:()=>void ce(void 0,"task",q.record.body),writable:te,pending:pe.has(q.record.id),busy:Ee},q.record.id):null,V?e.jsx(kt,{model:V,correctionAvailable:(ze=o.features)==null?void 0:ze.correction,availableTags:A,onClose:()=>{V.cancelCorrection(),ae(void 0)},onDiscard:()=>{ie.current.delete(V.followupRecordId?"followup:"+V.followupRecordId:V.state.draft.id),V.dispose(),ae(void 0)},onFollowupSaved:f=>{const R=f.followup.recordId;ie.current.delete("followup:"+R),V.dispose(),ae(void 0),(q==null?void 0:q.record.id)===R&&be({...q.record,followupSummary:f.followupSummary}),X()},onSaved:f=>{q&&ee({record:f}),ie.current.delete(V.followupRecordId?"followup:"+V.followupRecordId:V.state.draft.id),V.dispose(),ae(void 0),X()}}):null]})}function At({active:a=!0,accountOnly:t=!1,onClose:s,onOpenLink:i}){const{accounts:r,endpoint:o,setEndpoint:d,username:c,setUsername:l,password:u,setPassword:m,busy:g,message:n,connection:x,needsLogin:k,setNeedsLogin:S,ensure:v,initialize:b,connect:j,switchEnvironment:N,logout:C,editAccount:D,isCurrent:A}=it(),[L,B]=p.useState(t),[J,y]=p.useState(null),w=p.useRef(!0);p.useEffect(()=>(w.current=!0,v(),()=>{w.current=!1}),[v]),p.useEffect(()=>{x&&B(t)},[x,t]);const I=z(E=>{const ne=x==null?void 0:x.client;i==null||i(E,()=>w.current&&!!ne&&A(ne))}),F=z(async E=>{$&&!window.confirm("放弃当前环境未保存的账户修改?")||await N(E)}),M=r==null?void 0:r.profiles[r.active],$=t&&!!M&&!x&&(o!==M.endpoint||c!==M.username||u!==(M.password??""));return at($,t&&g&&$),e.jsxs("section",{className:"suiji-theme flex h-full min-h-0 flex-col bg-background text-foreground","aria-label":"随记内容",children:[e.jsxs("header",{className:"flex h-14 shrink-0 items-center gap-2 border-b px-4",children:[L&&x&&!t?e.jsx(h,{variant:"ghost",size:"icon","aria-label":"返回随记",onClick:()=>B(!1),children:e.jsx(rt,{className:"size-4"})}):null,e.jsx("h1",{className:"font-semibold",children:L?"账户设置":"随记"}),(r==null?void 0:r.active)==="development"?e.jsx("span",{className:"rounded bg-secondary px-2 py-0.5 text-xs",children:"开发"}):null,e.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[L?null:e.jsx("div",{ref:y,className:"flex"}),x&&!L?e.jsx(h,{variant:"ghost",size:"icon","aria-label":"随记设置",onClick:()=>B(!0),children:e.jsx(nt,{className:"size-4"})}):null,s?e.jsx(h,{variant:"ghost",size:"icon","aria-label":"关闭随记",onClick:s,children:e.jsx(ot,{className:"size-4"})}):null]})]}),x&&!t?e.jsx("div",{hidden:L,className:"min-h-0 flex-1",children:e.jsx(Tt,{connection:x,active:a,headerActions:J,onOpenLink:i?I:void 0},x.store.scope)}):null,t||L||!x?e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto p-5",children:[r?e.jsxs(e.Fragment,{children:[e.jsx("fieldset",{disabled:g,className:"mb-6 flex gap-2","aria-label":"账户环境",children:["production","development"].map(E=>e.jsx(h,{className:"flex-1",variant:r.active===E?"default":"outline","aria-pressed":r.active===E,onClick:()=>void F(E),children:we(E)},E))}),e.jsx("p",{className:"mb-5 text-sm text-muted-foreground",children:x?"切换环境会保留各自的账户和草稿。":"首次登录后,下次打开会自动连接。"}),x?e.jsxs("div",{className:"flex flex-col gap-4 text-sm",children:[e.jsxs("p",{children:["已登录",we(r.active),"环境 · ",c]}),e.jsx("p",{className:"break-all text-muted-foreground",children:o}),e.jsx(h,{variant:"outline",disabled:g,onClick:D,children:"修改账户配置"}),e.jsxs(h,{variant:"destructive",disabled:g,onClick:()=>void C(),children:["退出",we(r.active),"账户"]})]}):k?e.jsxs("form",{className:"flex flex-col gap-5",onSubmit:E=>{E.preventDefault(),j(r,!0)},children:[e.jsxs("label",{className:"flex flex-col gap-2 text-sm",children:["服务地址",e.jsx(G,{"aria-label":"随记服务地址",type:"url",value:o,required:!0,disabled:g,onChange:E=>d(E.target.value),placeholder:"https://你的随记服务"})]}),e.jsxs("label",{className:"flex flex-col gap-2 text-sm",children:["账号",e.jsx(G,{"aria-label":"随记账号",autoComplete:"username",value:c,required:!0,disabled:g,onChange:E=>l(E.target.value)})]}),e.jsxs("label",{className:"flex flex-col gap-2 text-sm",children:["密码",e.jsx(G,{"aria-label":"随记密码",type:"password",autoComplete:"current-password",value:u,required:!0,disabled:g,onChange:E=>m(E.target.value)})]}),e.jsx(h,{type:"submit",disabled:g,children:g?"正在连接…":"登录随记"})]}):e.jsxs("div",{className:"flex flex-col gap-4 text-sm",children:[e.jsx("p",{children:g?"正在恢复已保存的账户…":"暂时无法连接,账户和草稿已保留。"}),e.jsx(h,{variant:"outline",disabled:g,onClick:()=>S(!0),children:"修改账户配置"})]})]}):null,g?e.jsx("p",{role:"status",className:"mt-4 text-sm",children:"正在连接…"}):null,n?e.jsxs("div",{className:"mt-4 flex flex-col gap-3",children:[e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:n}),e.jsx(h,{variant:"outline",disabled:g,onClick:()=>void b(),children:"重试连接"})]}):null]}):null]})}export{At as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as n}from"./index-D9-cSGu-.js";import{e as m,o as u,T as h,p as l}from"./main-B_ifx48h.js";import{S as x}from"./tabs-BjCNEXFA.js";function R(t){var i,r;const e=m(),s=u(),o=new URLSearchParams(e.search),c=o.get("section")??"saved";return(i=window.electronAPI)!=null&&i.isElectron?n.jsxs(n.Fragment,{children:[n.jsx(x,{items:[["saved","连接"],["hosts","SSH 主机与通道"]],active:c}),c==="hosts"?n.jsx(h,{embedded:!0}):n.jsx(l,{embedded:!0,onManageTunnels:()=>{const a=new URLSearchParams(e.search);a.set("section","hosts"),s(`${e.pathname}?${a}`,{state:e.state})},connections:t.connections,activeId:o.get("target")??((r=t.activeConnection)==null?void 0:r.id)??null,onAdd:t.onAdd,onRemove:t.onRemove,onEdit:t.onEdit,onReconnect:t.onReconnect,onSelect:a=>{const d=new URLSearchParams(e.search);d.set("target",a),s(`${e.pathname}?${d}`,{state:e.state})}})]}):n.jsx("p",{className:"text-sm text-muted-foreground",children:"连接与 SSH 通道由桌面应用管理。"})}export{R as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{_ as V,l as $,e as lt}from"./index-CpU0rt1e.js";import{c as tt}from"./cytoscape.esm-DxGcaOPV.js";import{g as gt}from"./index-D9-cSGu-.js";import"./main-B_ifx48h.js";import"./record-content-Cy_dPSdi.js";var k={exports:{}},Z={exports:{}},Q={exports:{}},ut=Q.exports,j;function ft(){return j||(j=1,(function(G,b){(function(I,T){G.exports=T()})(ut,function(){return(function(N){var I={};function T(o){if(I[o])return I[o].exports;var e=I[o]={i:o,l:!1,exports:{}};return N[o].call(e.exports,e,e.exports,T),e.l=!0,e.exports}return T.m=N,T.c=I,T.i=function(o){return o},T.d=function(o,e,t){T.o(o,e)||Object.defineProperty(o,e,{configurable:!1,enumerable:!0,get:t})},T.n=function(o){var e=o&&o.__esModule?function(){return o.default}:function(){return o};return T.d(e,"a",e),e},T.o=function(o,e){return Object.prototype.hasOwnProperty.call(o,e)},T.p="",T(T.s=26)})([(function(N,I,T){function o(){}o.QUALITY=1,o.DEFAULT_CREATE_BENDS_AS_NEEDED=!1,o.DEFAULT_INCREMENTAL=!1,o.DEFAULT_ANIMATION_ON_LAYOUT=!0,o.DEFAULT_ANIMATION_DURING_LAYOUT=!1,o.DEFAULT_ANIMATION_PERIOD=50,o.DEFAULT_UNIFORM_LEAF_NODE_SIZES=!1,o.DEFAULT_GRAPH_MARGIN=15,o.NODE_DIMENSIONS_INCLUDE_LABELS=!1,o.SIMPLE_NODE_SIZE=40,o.SIMPLE_NODE_HALF_SIZE=o.SIMPLE_NODE_SIZE/2,o.EMPTY_COMPOUND_NODE_SIZE=40,o.MIN_EDGE_LENGTH=1,o.WORLD_BOUNDARY=1e6,o.INITIAL_WORLD_BOUNDARY=o.WORLD_BOUNDARY/1e3,o.WORLD_CENTER_X=1200,o.WORLD_CENTER_Y=900,N.exports=o}),(function(N,I,T){var o=T(2),e=T(8),t=T(9);function i(g,n,d){o.call(this,d),this.isOverlapingSourceAndTarget=!1,this.vGraphObject=d,this.bendpoints=[],this.source=g,this.target=n}i.prototype=Object.create(o.prototype);for(var l in o)i[l]=o[l];i.prototype.getSource=function(){return this.source},i.prototype.getTarget=function(){return this.target},i.prototype.isInterGraph=function(){return this.isInterGraph},i.prototype.getLength=function(){return this.length},i.prototype.isOverlapingSourceAndTarget=function(){return this.isOverlapingSourceAndTarget},i.prototype.getBendpoints=function(){return this.bendpoints},i.prototype.getLca=function(){return this.lca},i.prototype.getSourceInLca=function(){return this.sourceInLca},i.prototype.getTargetInLca=function(){return this.targetInLca},i.prototype.getOtherEnd=function(g){if(this.source===g)return this.target;if(this.target===g)return this.source;throw"Node is not incident with this edge"},i.prototype.getOtherEndInGraph=function(g,n){for(var d=this.getOtherEnd(g),r=n.getGraphManager().getRoot();;){if(d.getOwner()==n)return d;if(d.getOwner()==r)break;d=d.getOwner().getParent()}return null},i.prototype.updateLength=function(){var g=new Array(4);this.isOverlapingSourceAndTarget=e.getIntersection(this.target.getRect(),this.source.getRect(),g),this.isOverlapingSourceAndTarget||(this.lengthX=g[0]-g[2],this.lengthY=g[1]-g[3],Math.abs(this.lengthX)<1&&(this.lengthX=t.sign(this.lengthX)),Math.abs(this.lengthY)<1&&(this.lengthY=t.sign(this.lengthY)),this.length=Math.sqrt(this.lengthX*this.lengthX+this.lengthY*this.lengthY))},i.prototype.updateLengthSimple=function(){this.lengthX=this.target.getCenterX()-this.source.getCenterX(),this.lengthY=this.target.getCenterY()-this.source.getCenterY(),Math.abs(this.lengthX)<1&&(this.lengthX=t.sign(this.lengthX)),Math.abs(this.lengthY)<1&&(this.lengthY=t.sign(this.lengthY)),this.length=Math.sqrt(this.lengthX*this.lengthX+this.lengthY*this.lengthY)},N.exports=i}),(function(N,I,T){function o(e){this.vGraphObject=e}N.exports=o}),(function(N,I,T){var o=T(2),e=T(10),t=T(13),i=T(0),l=T(16),g=T(4);function n(r,h,a,p){a==null&&p==null&&(p=h),o.call(this,p),r.graphManager!=null&&(r=r.graphManager),this.estimatedSize=e.MIN_VALUE,this.inclusionTreeDepth=e.MAX_VALUE,this.vGraphObject=p,this.edges=[],this.graphManager=r,a!=null&&h!=null?this.rect=new t(h.x,h.y,a.width,a.height):this.rect=new t}n.prototype=Object.create(o.prototype);for(var d in o)n[d]=o[d];n.prototype.getEdges=function(){return this.edges},n.prototype.getChild=function(){return this.child},n.prototype.getOwner=function(){return this.owner},n.prototype.getWidth=function(){return this.rect.width},n.prototype.setWidth=function(r){this.rect.width=r},n.prototype.getHeight=function(){return this.rect.height},n.prototype.setHeight=function(r){this.rect.height=r},n.prototype.getCenterX=function(){return this.rect.x+this.rect.width/2},n.prototype.getCenterY=function(){return this.rect.y+this.rect.height/2},n.prototype.getCenter=function(){return new g(this.rect.x+this.rect.width/2,this.rect.y+this.rect.height/2)},n.prototype.getLocation=function(){return new g(this.rect.x,this.rect.y)},n.prototype.getRect=function(){return this.rect},n.prototype.getDiagonal=function(){return Math.sqrt(this.rect.width*this.rect.width+this.rect.height*this.rect.height)},n.prototype.getHalfTheDiagonal=function(){return Math.sqrt(this.rect.height*this.rect.height+this.rect.width*this.rect.width)/2},n.prototype.setRect=function(r,h){this.rect.x=r.x,this.rect.y=r.y,this.rect.width=h.width,this.rect.height=h.height},n.prototype.setCenter=function(r,h){this.rect.x=r-this.rect.width/2,this.rect.y=h-this.rect.height/2},n.prototype.setLocation=function(r,h){this.rect.x=r,this.rect.y=h},n.prototype.moveBy=function(r,h){this.rect.x+=r,this.rect.y+=h},n.prototype.getEdgeListToNode=function(r){var h=[],a=this;return a.edges.forEach(function(p){if(p.target==r){if(p.source!=a)throw"Incorrect edge source!";h.push(p)}}),h},n.prototype.getEdgesBetween=function(r){var h=[],a=this;return a.edges.forEach(function(p){if(!(p.source==a||p.target==a))throw"Incorrect edge source and/or target";(p.target==r||p.source==r)&&h.push(p)}),h},n.prototype.getNeighborsList=function(){var r=new Set,h=this;return h.edges.forEach(function(a){if(a.source==h)r.add(a.target);else{if(a.target!=h)throw"Incorrect incidency!";r.add(a.source)}}),r},n.prototype.withChildren=function(){var r=new Set,h,a;if(r.add(this),this.child!=null)for(var p=this.child.getNodes(),v=0;v<p.length;v++)h=p[v],a=h.withChildren(),a.forEach(function(D){r.add(D)});return r},n.prototype.getNoOfChildren=function(){var r=0,h;if(this.child==null)r=1;else for(var a=this.child.getNodes(),p=0;p<a.length;p++)h=a[p],r+=h.getNoOfChildren();return r==0&&(r=1),r},n.prototype.getEstimatedSize=function(){if(this.estimatedSize==e.MIN_VALUE)throw"assert failed";return this.estimatedSize},n.prototype.calcEstimatedSize=function(){return this.child==null?this.estimatedSize=(this.rect.width+this.rect.height)/2:(this.estimatedSize=this.child.calcEstimatedSize(),this.rect.width=this.estimatedSize,this.rect.height=this.estimatedSize,this.estimatedSize)},n.prototype.scatter=function(){var r,h,a=-i.INITIAL_WORLD_BOUNDARY,p=i.INITIAL_WORLD_BOUNDARY;r=i.WORLD_CENTER_X+l.nextDouble()*(p-a)+a;var v=-i.INITIAL_WORLD_BOUNDARY,D=i.INITIAL_WORLD_BOUNDARY;h=i.WORLD_CENTER_Y+l.nextDouble()*(D-v)+v,this.rect.x=r,this.rect.y=h},n.prototype.updateBounds=function(){if(this.getChild()==null)throw"assert failed";if(this.getChild().getNodes().length!=0){var r=this.getChild();if(r.updateBounds(!0),this.rect.x=r.getLeft(),this.rect.y=r.getTop(),this.setWidth(r.getRight()-r.getLeft()),this.setHeight(r.getBottom()-r.getTop()),i.NODE_DIMENSIONS_INCLUDE_LABELS){var h=r.getRight()-r.getLeft(),a=r.getBottom()-r.getTop();this.labelWidth>h&&(this.rect.x-=(this.labelWidth-h)/2,this.setWidth(this.labelWidth)),this.labelHeight>a&&(this.labelPos=="center"?this.rect.y-=(this.labelHeight-a)/2:this.labelPos=="top"&&(this.rect.y-=this.labelHeight-a),this.setHeight(this.labelHeight))}}},n.prototype.getInclusionTreeDepth=function(){if(this.inclusionTreeDepth==e.MAX_VALUE)throw"assert failed";return this.inclusionTreeDepth},n.prototype.transform=function(r){var h=this.rect.x;h>i.WORLD_BOUNDARY?h=i.WORLD_BOUNDARY:h<-i.WORLD_BOUNDARY&&(h=-i.WORLD_BOUNDARY);var a=this.rect.y;a>i.WORLD_BOUNDARY?a=i.WORLD_BOUNDARY:a<-i.WORLD_BOUNDARY&&(a=-i.WORLD_BOUNDARY);var p=new g(h,a),v=r.inverseTransformPoint(p);this.setLocation(v.x,v.y)},n.prototype.getLeft=function(){return this.rect.x},n.prototype.getRight=function(){return this.rect.x+this.rect.width},n.prototype.getTop=function(){return this.rect.y},n.prototype.getBottom=function(){return this.rect.y+this.rect.height},n.prototype.getParent=function(){return this.owner==null?null:this.owner.getParent()},N.exports=n}),(function(N,I,T){function o(e,t){e==null&&t==null?(this.x=0,this.y=0):(this.x=e,this.y=t)}o.prototype.getX=function(){return this.x},o.prototype.getY=function(){return this.y},o.prototype.setX=function(e){this.x=e},o.prototype.setY=function(e){this.y=e},o.prototype.getDifference=function(e){return new DimensionD(this.x-e.x,this.y-e.y)},o.prototype.getCopy=function(){return new o(this.x,this.y)},o.prototype.translate=function(e){return this.x+=e.width,this.y+=e.height,this},N.exports=o}),(function(N,I,T){var o=T(2),e=T(10),t=T(0),i=T(6),l=T(3),g=T(1),n=T(13),d=T(12),r=T(11);function h(p,v,D){o.call(this,D),this.estimatedSize=e.MIN_VALUE,this.margin=t.DEFAULT_GRAPH_MARGIN,this.edges=[],this.nodes=[],this.isConnected=!1,this.parent=p,v!=null&&v instanceof i?this.graphManager=v:v!=null&&v instanceof Layout&&(this.graphManager=v.graphManager)}h.prototype=Object.create(o.prototype);for(var a in o)h[a]=o[a];h.prototype.getNodes=function(){return this.nodes},h.prototype.getEdges=function(){return this.edges},h.prototype.getGraphManager=function(){return this.graphManager},h.prototype.getParent=function(){return this.parent},h.prototype.getLeft=function(){return this.left},h.prototype.getRight=function(){return this.right},h.prototype.getTop=function(){return this.top},h.prototype.getBottom=function(){return this.bottom},h.prototype.isConnected=function(){return this.isConnected},h.prototype.add=function(p,v,D){if(v==null&&D==null){var u=p;if(this.graphManager==null)throw"Graph has no graph mgr!";if(this.getNodes().indexOf(u)>-1)throw"Node already in graph!";return u.owner=this,this.getNodes().push(u),u}else{var E=p;if(!(this.getNodes().indexOf(v)>-1&&this.getNodes().indexOf(D)>-1))throw"Source or target not in graph!";if(!(v.owner==D.owner&&v.owner==this))throw"Both owners must be this graph!";return v.owner!=D.owner?null:(E.source=v,E.target=D,E.isInterGraph=!1,this.getEdges().push(E),v.edges.push(E),D!=v&&D.edges.push(E),E)}},h.prototype.remove=function(p){var v=p;if(p instanceof l){if(v==null)throw"Node is null!";if(!(v.owner!=null&&v.owner==this))throw"Owner graph is invalid!";if(this.graphManager==null)throw"Owner graph manager is invalid!";for(var D=v.edges.slice(),u,E=D.length,y=0;y<E;y++)u=D[y],u.isInterGraph?this.graphManager.remove(u):u.source.owner.remove(u);var O=this.nodes.indexOf(v);if(O==-1)throw"Node not in owner node list!";this.nodes.splice(O,1)}else if(p instanceof g){var u=p;if(u==null)throw"Edge is null!";if(!(u.source!=null&&u.target!=null))throw"Source and/or target is null!";if(!(u.source.owner!=null&&u.target.owner!=null&&u.source.owner==this&&u.target.owner==this))throw"Source and/or target owner is invalid!";var s=u.source.edges.indexOf(u),f=u.target.edges.indexOf(u);if(!(s>-1&&f>-1))throw"Source and/or target doesn't know this edge!";u.source.edges.splice(s,1),u.target!=u.source&&u.target.edges.splice(f,1);var O=u.source.owner.getEdges().indexOf(u);if(O==-1)throw"Not in owner's edge list!";u.source.owner.getEdges().splice(O,1)}},h.prototype.updateLeftTop=function(){for(var p=e.MAX_VALUE,v=e.MAX_VALUE,D,u,E,y=this.getNodes(),O=y.length,s=0;s<O;s++){var f=y[s];D=f.getTop(),u=f.getLeft(),p>D&&(p=D),v>u&&(v=u)}return p==e.MAX_VALUE?null:(y[0].getParent().paddingLeft!=null?E=y[0].getParent().paddingLeft:E=this.margin,this.left=v-E,this.top=p-E,new d(this.left,this.top))},h.prototype.updateBounds=function(p){for(var v=e.MAX_VALUE,D=-e.MAX_VALUE,u=e.MAX_VALUE,E=-e.MAX_VALUE,y,O,s,f,c,L=this.nodes,A=L.length,m=0;m<A;m++){var C=L[m];p&&C.child!=null&&C.updateBounds(),y=C.getLeft(),O=C.getRight(),s=C.getTop(),f=C.getBottom(),v>y&&(v=y),D<O&&(D=O),u>s&&(u=s),E<f&&(E=f)}var R=new n(v,u,D-v,E-u);v==e.MAX_VALUE&&(this.left=this.parent.getLeft(),this.right=this.parent.getRight(),this.top=this.parent.getTop(),this.bottom=this.parent.getBottom()),L[0].getParent().paddingLeft!=null?c=L[0].getParent().paddingLeft:c=this.margin,this.left=R.x-c,this.right=R.x+R.width+c,this.top=R.y-c,this.bottom=R.y+R.height+c},h.calculateBounds=function(p){for(var v=e.MAX_VALUE,D=-e.MAX_VALUE,u=e.MAX_VALUE,E=-e.MAX_VALUE,y,O,s,f,c=p.length,L=0;L<c;L++){var A=p[L];y=A.getLeft(),O=A.getRight(),s=A.getTop(),f=A.getBottom(),v>y&&(v=y),D<O&&(D=O),u>s&&(u=s),E<f&&(E=f)}var m=new n(v,u,D-v,E-u);return m},h.prototype.getInclusionTreeDepth=function(){return this==this.graphManager.getRoot()?1:this.parent.getInclusionTreeDepth()},h.prototype.getEstimatedSize=function(){if(this.estimatedSize==e.MIN_VALUE)throw"assert failed";return this.estimatedSize},h.prototype.calcEstimatedSize=function(){for(var p=0,v=this.nodes,D=v.length,u=0;u<D;u++){var E=v[u];p+=E.calcEstimatedSize()}return p==0?this.estimatedSize=t.EMPTY_COMPOUND_NODE_SIZE:this.estimatedSize=p/Math.sqrt(this.nodes.length),this.estimatedSize},h.prototype.updateConnected=function(){var p=this;if(this.nodes.length==0){this.isConnected=!0;return}var v=new r,D=new Set,u=this.nodes[0],E,y,O=u.withChildren();for(O.forEach(function(m){v.push(m),D.add(m)});v.length!==0;){u=v.shift(),E=u.getEdges();for(var s=E.length,f=0;f<s;f++){var c=E[f];if(y=c.getOtherEndInGraph(u,this),y!=null&&!D.has(y)){var L=y.withChildren();L.forEach(function(m){v.push(m),D.add(m)})}}}if(this.isConnected=!1,D.size>=this.nodes.length){var A=0;D.forEach(function(m){m.owner==p&&A++}),A==this.nodes.length&&(this.isConnected=!0)}},N.exports=h}),(function(N,I,T){var o,e=T(1);function t(i){o=T(5),this.layout=i,this.graphs=[],this.edges=[]}t.prototype.addRoot=function(){var i=this.layout.newGraph(),l=this.layout.newNode(null),g=this.add(i,l);return this.setRootGraph(g),this.rootGraph},t.prototype.add=function(i,l,g,n,d){if(g==null&&n==null&&d==null){if(i==null)throw"Graph is null!";if(l==null)throw"Parent node is null!";if(this.graphs.indexOf(i)>-1)throw"Graph already in this graph mgr!";if(this.graphs.push(i),i.parent!=null)throw"Already has a parent!";if(l.child!=null)throw"Already has a child!";return i.parent=l,l.child=i,i}else{d=g,n=l,g=i;var r=n.getOwner(),h=d.getOwner();if(!(r!=null&&r.getGraphManager()==this))throw"Source not in this graph mgr!";if(!(h!=null&&h.getGraphManager()==this))throw"Target not in this graph mgr!";if(r==h)return g.isInterGraph=!1,r.add(g,n,d);if(g.isInterGraph=!0,g.source=n,g.target=d,this.edges.indexOf(g)>-1)throw"Edge already in inter-graph edge list!";if(this.edges.push(g),!(g.source!=null&&g.target!=null))throw"Edge source and/or target is null!";if(!(g.source.edges.indexOf(g)==-1&&g.target.edges.indexOf(g)==-1))throw"Edge already in source and/or target incidency list!";return g.source.edges.push(g),g.target.edges.push(g),g}},t.prototype.remove=function(i){if(i instanceof o){var l=i;if(l.getGraphManager()!=this)throw"Graph not in this graph mgr";if(!(l==this.rootGraph||l.parent!=null&&l.parent.graphManager==this))throw"Invalid parent node!";var g=[];g=g.concat(l.getEdges());for(var n,d=g.length,r=0;r<d;r++)n=g[r],l.remove(n);var h=[];h=h.concat(l.getNodes());var a;d=h.length;for(var r=0;r<d;r++)a=h[r],l.remove(a);l==this.rootGraph&&this.setRootGraph(null);var p=this.graphs.indexOf(l);this.graphs.splice(p,1),l.parent=null}else if(i instanceof e){if(n=i,n==null)throw"Edge is null!";if(!n.isInterGraph)throw"Not an inter-graph edge!";if(!(n.source!=null&&n.target!=null))throw"Source and/or target is null!";if(!(n.source.edges.indexOf(n)!=-1&&n.target.edges.indexOf(n)!=-1))throw"Source and/or target doesn't know this edge!";var p=n.source.edges.indexOf(n);if(n.source.edges.splice(p,1),p=n.target.edges.indexOf(n),n.target.edges.splice(p,1),!(n.source.owner!=null&&n.source.owner.getGraphManager()!=null))throw"Edge owner graph or owner graph manager is null!";if(n.source.owner.getGraphManager().edges.indexOf(n)==-1)throw"Not in owner graph manager's edge list!";var p=n.source.owner.getGraphManager().edges.indexOf(n);n.source.owner.getGraphManager().edges.splice(p,1)}},t.prototype.updateBounds=function(){this.rootGraph.updateBounds(!0)},t.prototype.getGraphs=function(){return this.graphs},t.prototype.getAllNodes=function(){if(this.allNodes==null){for(var i=[],l=this.getGraphs(),g=l.length,n=0;n<g;n++)i=i.concat(l[n].getNodes());this.allNodes=i}return this.allNodes},t.prototype.resetAllNodes=function(){this.allNodes=null},t.prototype.resetAllEdges=function(){this.allEdges=null},t.prototype.resetAllNodesToApplyGravitation=function(){this.allNodesToApplyGravitation=null},t.prototype.getAllEdges=function(){if(this.allEdges==null){var i=[],l=this.getGraphs();l.length;for(var g=0;g<l.length;g++)i=i.concat(l[g].getEdges());i=i.concat(this.edges),this.allEdges=i}return this.allEdges},t.prototype.getAllNodesToApplyGravitation=function(){return this.allNodesToApplyGravitation},t.prototype.setAllNodesToApplyGravitation=function(i){if(this.allNodesToApplyGravitation!=null)throw"assert failed";this.allNodesToApplyGravitation=i},t.prototype.getRoot=function(){return this.rootGraph},t.prototype.setRootGraph=function(i){if(i.getGraphManager()!=this)throw"Root not in this graph mgr!";this.rootGraph=i,i.parent==null&&(i.parent=this.layout.newNode("Root node"))},t.prototype.getLayout=function(){return this.layout},t.prototype.isOneAncestorOfOther=function(i,l){if(!(i!=null&&l!=null))throw"assert failed";if(i==l)return!0;var g=i.getOwner(),n;do{if(n=g.getParent(),n==null)break;if(n==l)return!0;if(g=n.getOwner(),g==null)break}while(!0);g=l.getOwner();do{if(n=g.getParent(),n==null)break;if(n==i)return!0;if(g=n.getOwner(),g==null)break}while(!0);return!1},t.prototype.calcLowestCommonAncestors=function(){for(var i,l,g,n,d,r=this.getAllEdges(),h=r.length,a=0;a<h;a++){if(i=r[a],l=i.source,g=i.target,i.lca=null,i.sourceInLca=l,i.targetInLca=g,l==g){i.lca=l.getOwner();continue}for(n=l.getOwner();i.lca==null;){for(i.targetInLca=g,d=g.getOwner();i.lca==null;){if(d==n){i.lca=d;break}if(d==this.rootGraph)break;if(i.lca!=null)throw"assert failed";i.targetInLca=d.getParent(),d=i.targetInLca.getOwner()}if(n==this.rootGraph)break;i.lca==null&&(i.sourceInLca=n.getParent(),n=i.sourceInLca.getOwner())}if(i.lca==null)throw"assert failed"}},t.prototype.calcLowestCommonAncestor=function(i,l){if(i==l)return i.getOwner();var g=i.getOwner();do{if(g==null)break;var n=l.getOwner();do{if(n==null)break;if(n==g)return n;n=n.getParent().getOwner()}while(!0);g=g.getParent().getOwner()}while(!0);return g},t.prototype.calcInclusionTreeDepths=function(i,l){i==null&&l==null&&(i=this.rootGraph,l=1);for(var g,n=i.getNodes(),d=n.length,r=0;r<d;r++)g=n[r],g.inclusionTreeDepth=l,g.child!=null&&this.calcInclusionTreeDepths(g.child,l+1)},t.prototype.includesInvalidEdge=function(){for(var i,l=this.edges.length,g=0;g<l;g++)if(i=this.edges[g],this.isOneAncestorOfOther(i.source,i.target))return!0;return!1},N.exports=t}),(function(N,I,T){var o=T(0);function e(){}for(var t in o)e[t]=o[t];e.MAX_ITERATIONS=2500,e.DEFAULT_EDGE_LENGTH=50,e.DEFAULT_SPRING_STRENGTH=.45,e.DEFAULT_REPULSION_STRENGTH=4500,e.DEFAULT_GRAVITY_STRENGTH=.4,e.DEFAULT_COMPOUND_GRAVITY_STRENGTH=1,e.DEFAULT_GRAVITY_RANGE_FACTOR=3.8,e.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR=1.5,e.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION=!0,e.DEFAULT_USE_SMART_REPULSION_RANGE_CALCULATION=!0,e.DEFAULT_COOLING_FACTOR_INCREMENTAL=.3,e.COOLING_ADAPTATION_FACTOR=.33,e.ADAPTATION_LOWER_NODE_LIMIT=1e3,e.ADAPTATION_UPPER_NODE_LIMIT=5e3,e.MAX_NODE_DISPLACEMENT_INCREMENTAL=100,e.MAX_NODE_DISPLACEMENT=e.MAX_NODE_DISPLACEMENT_INCREMENTAL*3,e.MIN_REPULSION_DIST=e.DEFAULT_EDGE_LENGTH/10,e.CONVERGENCE_CHECK_PERIOD=100,e.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR=.1,e.MIN_EDGE_LENGTH=1,e.GRID_CALCULATION_CHECK_PERIOD=10,N.exports=e}),(function(N,I,T){var o=T(12);function e(){}e.calcSeparationAmount=function(t,i,l,g){if(!t.intersects(i))throw"assert failed";var n=new Array(2);this.decideDirectionsForOverlappingNodes(t,i,n),l[0]=Math.min(t.getRight(),i.getRight())-Math.max(t.x,i.x),l[1]=Math.min(t.getBottom(),i.getBottom())-Math.max(t.y,i.y),t.getX()<=i.getX()&&t.getRight()>=i.getRight()?l[0]+=Math.min(i.getX()-t.getX(),t.getRight()-i.getRight()):i.getX()<=t.getX()&&i.getRight()>=t.getRight()&&(l[0]+=Math.min(t.getX()-i.getX(),i.getRight()-t.getRight())),t.getY()<=i.getY()&&t.getBottom()>=i.getBottom()?l[1]+=Math.min(i.getY()-t.getY(),t.getBottom()-i.getBottom()):i.getY()<=t.getY()&&i.getBottom()>=t.getBottom()&&(l[1]+=Math.min(t.getY()-i.getY(),i.getBottom()-t.getBottom()));var d=Math.abs((i.getCenterY()-t.getCenterY())/(i.getCenterX()-t.getCenterX()));i.getCenterY()===t.getCenterY()&&i.getCenterX()===t.getCenterX()&&(d=1);var r=d*l[0],h=l[1]/d;l[0]<h?h=l[0]:r=l[1],l[0]=-1*n[0]*(h/2+g),l[1]=-1*n[1]*(r/2+g)},e.decideDirectionsForOverlappingNodes=function(t,i,l){t.getCenterX()<i.getCenterX()?l[0]=-1:l[0]=1,t.getCenterY()<i.getCenterY()?l[1]=-1:l[1]=1},e.getIntersection2=function(t,i,l){var g=t.getCenterX(),n=t.getCenterY(),d=i.getCenterX(),r=i.getCenterY();if(t.intersects(i))return l[0]=g,l[1]=n,l[2]=d,l[3]=r,!0;var h=t.getX(),a=t.getY(),p=t.getRight(),v=t.getX(),D=t.getBottom(),u=t.getRight(),E=t.getWidthHalf(),y=t.getHeightHalf(),O=i.getX(),s=i.getY(),f=i.getRight(),c=i.getX(),L=i.getBottom(),A=i.getRight(),m=i.getWidthHalf(),C=i.getHeightHalf(),R=!1,M=!1;if(g===d){if(n>r)return l[0]=g,l[1]=a,l[2]=d,l[3]=L,!1;if(n<r)return l[0]=g,l[1]=D,l[2]=d,l[3]=s,!1}else if(n===r){if(g>d)return l[0]=h,l[1]=n,l[2]=f,l[3]=r,!1;if(g<d)return l[0]=p,l[1]=n,l[2]=O,l[3]=r,!1}else{var S=t.height/t.width,Y=i.height/i.width,w=(r-n)/(d-g),x=void 0,F=void 0,U=void 0,P=void 0,_=void 0,X=void 0;if(-S===w?g>d?(l[0]=v,l[1]=D,R=!0):(l[0]=p,l[1]=a,R=!0):S===w&&(g>d?(l[0]=h,l[1]=a,R=!0):(l[0]=u,l[1]=D,R=!0)),-Y===w?d>g?(l[2]=c,l[3]=L,M=!0):(l[2]=f,l[3]=s,M=!0):Y===w&&(d>g?(l[2]=O,l[3]=s,M=!0):(l[2]=A,l[3]=L,M=!0)),R&&M)return!1;if(g>d?n>r?(x=this.getCardinalDirection(S,w,4),F=this.getCardinalDirection(Y,w,2)):(x=this.getCardinalDirection(-S,w,3),F=this.getCardinalDirection(-Y,w,1)):n>r?(x=this.getCardinalDirection(-S,w,1),F=this.getCardinalDirection(-Y,w,3)):(x=this.getCardinalDirection(S,w,2),F=this.getCardinalDirection(Y,w,4)),!R)switch(x){case 1:P=a,U=g+-y/w,l[0]=U,l[1]=P;break;case 2:U=u,P=n+E*w,l[0]=U,l[1]=P;break;case 3:P=D,U=g+y/w,l[0]=U,l[1]=P;break;case 4:U=v,P=n+-E*w,l[0]=U,l[1]=P;break}if(!M)switch(F){case 1:X=s,_=d+-C/w,l[2]=_,l[3]=X;break;case 2:_=A,X=r+m*w,l[2]=_,l[3]=X;break;case 3:X=L,_=d+C/w,l[2]=_,l[3]=X;break;case 4:_=c,X=r+-m*w,l[2]=_,l[3]=X;break}}return!1},e.getCardinalDirection=function(t,i,l){return t>i?l:1+l%4},e.getIntersection=function(t,i,l,g){if(g==null)return this.getIntersection2(t,i,l);var n=t.x,d=t.y,r=i.x,h=i.y,a=l.x,p=l.y,v=g.x,D=g.y,u=void 0,E=void 0,y=void 0,O=void 0,s=void 0,f=void 0,c=void 0,L=void 0,A=void 0;return y=h-d,s=n-r,c=r*d-n*h,O=D-p,f=a-v,L=v*p-a*D,A=y*f-O*s,A===0?null:(u=(s*L-f*c)/A,E=(O*c-y*L)/A,new o(u,E))},e.angleOfVector=function(t,i,l,g){var n=void 0;return t!==l?(n=Math.atan((g-i)/(l-t)),l<t?n+=Math.PI:g<i&&(n+=this.TWO_PI)):g<i?n=this.ONE_AND_HALF_PI:n=this.HALF_PI,n},e.doIntersect=function(t,i,l,g){var n=t.x,d=t.y,r=i.x,h=i.y,a=l.x,p=l.y,v=g.x,D=g.y,u=(r-n)*(D-p)-(v-a)*(h-d);if(u===0)return!1;var E=((D-p)*(v-n)+(a-v)*(D-d))/u,y=((d-h)*(v-n)+(r-n)*(D-d))/u;return 0<E&&E<1&&0<y&&y<1},e.HALF_PI=.5*Math.PI,e.ONE_AND_HALF_PI=1.5*Math.PI,e.TWO_PI=2*Math.PI,e.THREE_PI=3*Math.PI,N.exports=e}),(function(N,I,T){function o(){}o.sign=function(e){return e>0?1:e<0?-1:0},o.floor=function(e){return e<0?Math.ceil(e):Math.floor(e)},o.ceil=function(e){return e<0?Math.floor(e):Math.ceil(e)},N.exports=o}),(function(N,I,T){function o(){}o.MAX_VALUE=2147483647,o.MIN_VALUE=-2147483648,N.exports=o}),(function(N,I,T){var o=(function(){function n(d,r){for(var h=0;h<r.length;h++){var a=r[h];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(d,a.key,a)}}return function(d,r,h){return r&&n(d.prototype,r),h&&n(d,h),d}})();function e(n,d){if(!(n instanceof d))throw new TypeError("Cannot call a class as a function")}var t=function(d){return{value:d,next:null,prev:null}},i=function(d,r,h,a){return d!==null?d.next=r:a.head=r,h!==null?h.prev=r:a.tail=r,r.prev=d,r.next=h,a.length++,r},l=function(d,r){var h=d.prev,a=d.next;return h!==null?h.next=a:r.head=a,a!==null?a.prev=h:r.tail=h,d.prev=d.next=null,r.length--,d},g=(function(){function n(d){var r=this;e(this,n),this.length=0,this.head=null,this.tail=null,d!=null&&d.forEach(function(h){return r.push(h)})}return o(n,[{key:"size",value:function(){return this.length}},{key:"insertBefore",value:function(r,h){return i(h.prev,t(r),h,this)}},{key:"insertAfter",value:function(r,h){return i(h,t(r),h.next,this)}},{key:"insertNodeBefore",value:function(r,h){return i(h.prev,r,h,this)}},{key:"insertNodeAfter",value:function(r,h){return i(h,r,h.next,this)}},{key:"push",value:function(r){return i(this.tail,t(r),null,this)}},{key:"unshift",value:function(r){return i(null,t(r),this.head,this)}},{key:"remove",value:function(r){return l(r,this)}},{key:"pop",value:function(){return l(this.tail,this).value}},{key:"popNode",value:function(){return l(this.tail,this)}},{key:"shift",value:function(){return l(this.head,this).value}},{key:"shiftNode",value:function(){return l(this.head,this)}},{key:"get_object_at",value:function(r){if(r<=this.length()){for(var h=1,a=this.head;h<r;)a=a.next,h++;return a.value}}},{key:"set_object_at",value:function(r,h){if(r<=this.length()){for(var a=1,p=this.head;a<r;)p=p.next,a++;p.value=h}}}]),n})();N.exports=g}),(function(N,I,T){function o(e,t,i){this.x=null,this.y=null,e==null&&t==null&&i==null?(this.x=0,this.y=0):typeof e=="number"&&typeof t=="number"&&i==null?(this.x=e,this.y=t):e.constructor.name=="Point"&&t==null&&i==null&&(i=e,this.x=i.x,this.y=i.y)}o.prototype.getX=function(){return this.x},o.prototype.getY=function(){return this.y},o.prototype.getLocation=function(){return new o(this.x,this.y)},o.prototype.setLocation=function(e,t,i){e.constructor.name=="Point"&&t==null&&i==null?(i=e,this.setLocation(i.x,i.y)):typeof e=="number"&&typeof t=="number"&&i==null&&(parseInt(e)==e&&parseInt(t)==t?this.move(e,t):(this.x=Math.floor(e+.5),this.y=Math.floor(t+.5)))},o.prototype.move=function(e,t){this.x=e,this.y=t},o.prototype.translate=function(e,t){this.x+=e,this.y+=t},o.prototype.equals=function(e){if(e.constructor.name=="Point"){var t=e;return this.x==t.x&&this.y==t.y}return this==e},o.prototype.toString=function(){return new o().constructor.name+"[x="+this.x+",y="+this.y+"]"},N.exports=o}),(function(N,I,T){function o(e,t,i,l){this.x=0,this.y=0,this.width=0,this.height=0,e!=null&&t!=null&&i!=null&&l!=null&&(this.x=e,this.y=t,this.width=i,this.height=l)}o.prototype.getX=function(){return this.x},o.prototype.setX=function(e){this.x=e},o.prototype.getY=function(){return this.y},o.prototype.setY=function(e){this.y=e},o.prototype.getWidth=function(){return this.width},o.prototype.setWidth=function(e){this.width=e},o.prototype.getHeight=function(){return this.height},o.prototype.setHeight=function(e){this.height=e},o.prototype.getRight=function(){return this.x+this.width},o.prototype.getBottom=function(){return this.y+this.height},o.prototype.intersects=function(e){return!(this.getRight()<e.x||this.getBottom()<e.y||e.getRight()<this.x||e.getBottom()<this.y)},o.prototype.getCenterX=function(){return this.x+this.width/2},o.prototype.getMinX=function(){return this.getX()},o.prototype.getMaxX=function(){return this.getX()+this.width},o.prototype.getCenterY=function(){return this.y+this.height/2},o.prototype.getMinY=function(){return this.getY()},o.prototype.getMaxY=function(){return this.getY()+this.height},o.prototype.getWidthHalf=function(){return this.width/2},o.prototype.getHeightHalf=function(){return this.height/2},N.exports=o}),(function(N,I,T){var o=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};function e(){}e.lastID=0,e.createID=function(t){return e.isPrimitive(t)?t:(t.uniqueID!=null||(t.uniqueID=e.getString(),e.lastID++),t.uniqueID)},e.getString=function(t){return t==null&&(t=e.lastID),"Object#"+t},e.isPrimitive=function(t){var i=typeof t>"u"?"undefined":o(t);return t==null||i!="object"&&i!="function"},N.exports=e}),(function(N,I,T){function o(a){if(Array.isArray(a)){for(var p=0,v=Array(a.length);p<a.length;p++)v[p]=a[p];return v}else return Array.from(a)}var e=T(0),t=T(6),i=T(3),l=T(1),g=T(5),n=T(4),d=T(17),r=T(27);function h(a){r.call(this),this.layoutQuality=e.QUALITY,this.createBendsAsNeeded=e.DEFAULT_CREATE_BENDS_AS_NEEDED,this.incremental=e.DEFAULT_INCREMENTAL,this.animationOnLayout=e.DEFAULT_ANIMATION_ON_LAYOUT,this.animationDuringLayout=e.DEFAULT_ANIMATION_DURING_LAYOUT,this.animationPeriod=e.DEFAULT_ANIMATION_PERIOD,this.uniformLeafNodeSizes=e.DEFAULT_UNIFORM_LEAF_NODE_SIZES,this.edgeToDummyNodes=new Map,this.graphManager=new t(this),this.isLayoutFinished=!1,this.isSubLayout=!1,this.isRemoteUse=!1,a!=null&&(this.isRemoteUse=a)}h.RANDOM_SEED=1,h.prototype=Object.create(r.prototype),h.prototype.getGraphManager=function(){return this.graphManager},h.prototype.getAllNodes=function(){return this.graphManager.getAllNodes()},h.prototype.getAllEdges=function(){return this.graphManager.getAllEdges()},h.prototype.getAllNodesToApplyGravitation=function(){return this.graphManager.getAllNodesToApplyGravitation()},h.prototype.newGraphManager=function(){var a=new t(this);return this.graphManager=a,a},h.prototype.newGraph=function(a){return new g(null,this.graphManager,a)},h.prototype.newNode=function(a){return new i(this.graphManager,a)},h.prototype.newEdge=function(a){return new l(null,null,a)},h.prototype.checkLayoutSuccess=function(){return this.graphManager.getRoot()==null||this.graphManager.getRoot().getNodes().length==0||this.graphManager.includesInvalidEdge()},h.prototype.runLayout=function(){this.isLayoutFinished=!1,this.tilingPreLayout&&this.tilingPreLayout(),this.initParameters();var a;return this.checkLayoutSuccess()?a=!1:a=this.layout(),e.ANIMATE==="during"?!1:(a&&(this.isSubLayout||this.doPostLayout()),this.tilingPostLayout&&this.tilingPostLayout(),this.isLayoutFinished=!0,a)},h.prototype.doPostLayout=function(){this.incremental||this.transform(),this.update()},h.prototype.update2=function(){if(this.createBendsAsNeeded&&(this.createBendpointsFromDummyNodes(),this.graphManager.resetAllEdges()),!this.isRemoteUse){for(var a=this.graphManager.getAllEdges(),p=0;p<a.length;p++)a[p];for(var v=this.graphManager.getRoot().getNodes(),p=0;p<v.length;p++)v[p];this.update(this.graphManager.getRoot())}},h.prototype.update=function(a){if(a==null)this.update2();else if(a instanceof i){var p=a;if(p.getChild()!=null)for(var v=p.getChild().getNodes(),D=0;D<v.length;D++)update(v[D]);if(p.vGraphObject!=null){var u=p.vGraphObject;u.update(p)}}else if(a instanceof l){var E=a;if(E.vGraphObject!=null){var y=E.vGraphObject;y.update(E)}}else if(a instanceof g){var O=a;if(O.vGraphObject!=null){var s=O.vGraphObject;s.update(O)}}},h.prototype.initParameters=function(){this.isSubLayout||(this.layoutQuality=e.QUALITY,this.animationDuringLayout=e.DEFAULT_ANIMATION_DURING_LAYOUT,this.animationPeriod=e.DEFAULT_ANIMATION_PERIOD,this.animationOnLayout=e.DEFAULT_ANIMATION_ON_LAYOUT,this.incremental=e.DEFAULT_INCREMENTAL,this.createBendsAsNeeded=e.DEFAULT_CREATE_BENDS_AS_NEEDED,this.uniformLeafNodeSizes=e.DEFAULT_UNIFORM_LEAF_NODE_SIZES),this.animationDuringLayout&&(this.animationOnLayout=!1)},h.prototype.transform=function(a){if(a==null)this.transform(new n(0,0));else{var p=new d,v=this.graphManager.getRoot().updateLeftTop();if(v!=null){p.setWorldOrgX(a.x),p.setWorldOrgY(a.y),p.setDeviceOrgX(v.x),p.setDeviceOrgY(v.y);for(var D=this.getAllNodes(),u,E=0;E<D.length;E++)u=D[E],u.transform(p)}}},h.prototype.positionNodesRandomly=function(a){if(a==null)this.positionNodesRandomly(this.getGraphManager().getRoot()),this.getGraphManager().getRoot().updateBounds(!0);else for(var p,v,D=a.getNodes(),u=0;u<D.length;u++)p=D[u],v=p.getChild(),v==null||v.getNodes().length==0?p.scatter():(this.positionNodesRandomly(v),p.updateBounds())},h.prototype.getFlatForest=function(){for(var a=[],p=!0,v=this.graphManager.getRoot().getNodes(),D=!0,u=0;u<v.length;u++)v[u].getChild()!=null&&(D=!1);if(!D)return a;var E=new Set,y=[],O=new Map,s=[];for(s=s.concat(v);s.length>0&&p;){for(y.push(s[0]);y.length>0&&p;){var f=y[0];y.splice(0,1),E.add(f);for(var c=f.getEdges(),u=0;u<c.length;u++){var L=c[u].getOtherEnd(f);if(O.get(f)!=L)if(!E.has(L))y.push(L),O.set(L,f);else{p=!1;break}}}if(!p)a=[];else{var A=[].concat(o(E));a.push(A);for(var u=0;u<A.length;u++){var m=A[u],C=s.indexOf(m);C>-1&&s.splice(C,1)}E=new Set,O=new Map}}return a},h.prototype.createDummyNodesForBendpoints=function(a){for(var p=[],v=a.source,D=this.graphManager.calcLowestCommonAncestor(a.source,a.target),u=0;u<a.bendpoints.length;u++){var E=this.newNode(null);E.setRect(new Point(0,0),new Dimension(1,1)),D.add(E);var y=this.newEdge(null);this.graphManager.add(y,v,E),p.add(E),v=E}var y=this.newEdge(null);return this.graphManager.add(y,v,a.target),this.edgeToDummyNodes.set(a,p),a.isInterGraph()?this.graphManager.remove(a):D.remove(a),p},h.prototype.createBendpointsFromDummyNodes=function(){var a=[];a=a.concat(this.graphManager.getAllEdges()),a=[].concat(o(this.edgeToDummyNodes.keys())).concat(a);for(var p=0;p<a.length;p++){var v=a[p];if(v.bendpoints.length>0){for(var D=this.edgeToDummyNodes.get(v),u=0;u<D.length;u++){var E=D[u],y=new n(E.getCenterX(),E.getCenterY()),O=v.bendpoints.get(u);O.x=y.x,O.y=y.y,E.getOwner().remove(E)}this.graphManager.add(v,v.source,v.target)}}},h.transform=function(a,p,v,D){if(v!=null&&D!=null){var u=p;if(a<=50){var E=p/v;u-=(p-E)/50*(50-a)}else{var y=p*D;u+=(y-p)/50*(a-50)}return u}else{var O,s;return a<=50?(O=9*p/500,s=p/10):(O=9*p/50,s=-8*p),O*a+s}},h.findCenterOfTree=function(a){var p=[];p=p.concat(a);var v=[],D=new Map,u=!1,E=null;(p.length==1||p.length==2)&&(u=!0,E=p[0]);for(var y=0;y<p.length;y++){var O=p[y],s=O.getNeighborsList().size;D.set(O,O.getNeighborsList().size),s==1&&v.push(O)}var f=[];for(f=f.concat(v);!u;){var c=[];c=c.concat(f),f=[];for(var y=0;y<p.length;y++){var O=p[y],L=p.indexOf(O);L>=0&&p.splice(L,1);var A=O.getNeighborsList();A.forEach(function(R){if(v.indexOf(R)<0){var M=D.get(R),S=M-1;S==1&&f.push(R),D.set(R,S)}})}v=v.concat(f),(p.length==1||p.length==2)&&(u=!0,E=p[0])}return E},h.prototype.setGraphManager=function(a){this.graphManager=a},N.exports=h}),(function(N,I,T){function o(){}o.seed=1,o.x=0,o.nextDouble=function(){return o.x=Math.sin(o.seed++)*1e4,o.x-Math.floor(o.x)},N.exports=o}),(function(N,I,T){var o=T(4);function e(t,i){this.lworldOrgX=0,this.lworldOrgY=0,this.ldeviceOrgX=0,this.ldeviceOrgY=0,this.lworldExtX=1,this.lworldExtY=1,this.ldeviceExtX=1,this.ldeviceExtY=1}e.prototype.getWorldOrgX=function(){return this.lworldOrgX},e.prototype.setWorldOrgX=function(t){this.lworldOrgX=t},e.prototype.getWorldOrgY=function(){return this.lworldOrgY},e.prototype.setWorldOrgY=function(t){this.lworldOrgY=t},e.prototype.getWorldExtX=function(){return this.lworldExtX},e.prototype.setWorldExtX=function(t){this.lworldExtX=t},e.prototype.getWorldExtY=function(){return this.lworldExtY},e.prototype.setWorldExtY=function(t){this.lworldExtY=t},e.prototype.getDeviceOrgX=function(){return this.ldeviceOrgX},e.prototype.setDeviceOrgX=function(t){this.ldeviceOrgX=t},e.prototype.getDeviceOrgY=function(){return this.ldeviceOrgY},e.prototype.setDeviceOrgY=function(t){this.ldeviceOrgY=t},e.prototype.getDeviceExtX=function(){return this.ldeviceExtX},e.prototype.setDeviceExtX=function(t){this.ldeviceExtX=t},e.prototype.getDeviceExtY=function(){return this.ldeviceExtY},e.prototype.setDeviceExtY=function(t){this.ldeviceExtY=t},e.prototype.transformX=function(t){var i=0,l=this.lworldExtX;return l!=0&&(i=this.ldeviceOrgX+(t-this.lworldOrgX)*this.ldeviceExtX/l),i},e.prototype.transformY=function(t){var i=0,l=this.lworldExtY;return l!=0&&(i=this.ldeviceOrgY+(t-this.lworldOrgY)*this.ldeviceExtY/l),i},e.prototype.inverseTransformX=function(t){var i=0,l=this.ldeviceExtX;return l!=0&&(i=this.lworldOrgX+(t-this.ldeviceOrgX)*this.lworldExtX/l),i},e.prototype.inverseTransformY=function(t){var i=0,l=this.ldeviceExtY;return l!=0&&(i=this.lworldOrgY+(t-this.ldeviceOrgY)*this.lworldExtY/l),i},e.prototype.inverseTransformPoint=function(t){var i=new o(this.inverseTransformX(t.x),this.inverseTransformY(t.y));return i},N.exports=e}),(function(N,I,T){function o(r){if(Array.isArray(r)){for(var h=0,a=Array(r.length);h<r.length;h++)a[h]=r[h];return a}else return Array.from(r)}var e=T(15),t=T(7),i=T(0),l=T(8),g=T(9);function n(){e.call(this),this.useSmartIdealEdgeLengthCalculation=t.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION,this.idealEdgeLength=t.DEFAULT_EDGE_LENGTH,this.springConstant=t.DEFAULT_SPRING_STRENGTH,this.repulsionConstant=t.DEFAULT_REPULSION_STRENGTH,this.gravityConstant=t.DEFAULT_GRAVITY_STRENGTH,this.compoundGravityConstant=t.DEFAULT_COMPOUND_GRAVITY_STRENGTH,this.gravityRangeFactor=t.DEFAULT_GRAVITY_RANGE_FACTOR,this.compoundGravityRangeFactor=t.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR,this.displacementThresholdPerNode=3*t.DEFAULT_EDGE_LENGTH/100,this.coolingFactor=t.DEFAULT_COOLING_FACTOR_INCREMENTAL,this.initialCoolingFactor=t.DEFAULT_COOLING_FACTOR_INCREMENTAL,this.totalDisplacement=0,this.oldTotalDisplacement=0,this.maxIterations=t.MAX_ITERATIONS}n.prototype=Object.create(e.prototype);for(var d in e)n[d]=e[d];n.prototype.initParameters=function(){e.prototype.initParameters.call(this,arguments),this.totalIterations=0,this.notAnimatedIterations=0,this.useFRGridVariant=t.DEFAULT_USE_SMART_REPULSION_RANGE_CALCULATION,this.grid=[]},n.prototype.calcIdealEdgeLengths=function(){for(var r,h,a,p,v,D,u=this.getGraphManager().getAllEdges(),E=0;E<u.length;E++)r=u[E],r.idealLength=this.idealEdgeLength,r.isInterGraph&&(a=r.getSource(),p=r.getTarget(),v=r.getSourceInLca().getEstimatedSize(),D=r.getTargetInLca().getEstimatedSize(),this.useSmartIdealEdgeLengthCalculation&&(r.idealLength+=v+D-2*i.SIMPLE_NODE_SIZE),h=r.getLca().getInclusionTreeDepth(),r.idealLength+=t.DEFAULT_EDGE_LENGTH*t.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR*(a.getInclusionTreeDepth()+p.getInclusionTreeDepth()-2*h))},n.prototype.initSpringEmbedder=function(){var r=this.getAllNodes().length;this.incremental?(r>t.ADAPTATION_LOWER_NODE_LIMIT&&(this.coolingFactor=Math.max(this.coolingFactor*t.COOLING_ADAPTATION_FACTOR,this.coolingFactor-(r-t.ADAPTATION_LOWER_NODE_LIMIT)/(t.ADAPTATION_UPPER_NODE_LIMIT-t.ADAPTATION_LOWER_NODE_LIMIT)*this.coolingFactor*(1-t.COOLING_ADAPTATION_FACTOR))),this.maxNodeDisplacement=t.MAX_NODE_DISPLACEMENT_INCREMENTAL):(r>t.ADAPTATION_LOWER_NODE_LIMIT?this.coolingFactor=Math.max(t.COOLING_ADAPTATION_FACTOR,1-(r-t.ADAPTATION_LOWER_NODE_LIMIT)/(t.ADAPTATION_UPPER_NODE_LIMIT-t.ADAPTATION_LOWER_NODE_LIMIT)*(1-t.COOLING_ADAPTATION_FACTOR)):this.coolingFactor=1,this.initialCoolingFactor=this.coolingFactor,this.maxNodeDisplacement=t.MAX_NODE_DISPLACEMENT),this.maxIterations=Math.max(this.getAllNodes().length*5,this.maxIterations),this.totalDisplacementThreshold=this.displacementThresholdPerNode*this.getAllNodes().length,this.repulsionRange=this.calcRepulsionRange()},n.prototype.calcSpringForces=function(){for(var r=this.getAllEdges(),h,a=0;a<r.length;a++)h=r[a],this.calcSpringForce(h,h.idealLength)},n.prototype.calcRepulsionForces=function(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0,h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,a,p,v,D,u=this.getAllNodes(),E;if(this.useFRGridVariant)for(this.totalIterations%t.GRID_CALCULATION_CHECK_PERIOD==1&&r&&this.updateGrid(),E=new Set,a=0;a<u.length;a++)v=u[a],this.calculateRepulsionForceOfANode(v,E,r,h),E.add(v);else for(a=0;a<u.length;a++)for(v=u[a],p=a+1;p<u.length;p++)D=u[p],v.getOwner()==D.getOwner()&&this.calcRepulsionForce(v,D)},n.prototype.calcGravitationalForces=function(){for(var r,h=this.getAllNodesToApplyGravitation(),a=0;a<h.length;a++)r=h[a],this.calcGravitationalForce(r)},n.prototype.moveNodes=function(){for(var r=this.getAllNodes(),h,a=0;a<r.length;a++)h=r[a],h.move()},n.prototype.calcSpringForce=function(r,h){var a=r.getSource(),p=r.getTarget(),v,D,u,E;if(this.uniformLeafNodeSizes&&a.getChild()==null&&p.getChild()==null)r.updateLengthSimple();else if(r.updateLength(),r.isOverlapingSourceAndTarget)return;v=r.getLength(),v!=0&&(D=this.springConstant*(v-h),u=D*(r.lengthX/v),E=D*(r.lengthY/v),a.springForceX+=u,a.springForceY+=E,p.springForceX-=u,p.springForceY-=E)},n.prototype.calcRepulsionForce=function(r,h){var a=r.getRect(),p=h.getRect(),v=new Array(2),D=new Array(4),u,E,y,O,s,f,c;if(a.intersects(p)){l.calcSeparationAmount(a,p,v,t.DEFAULT_EDGE_LENGTH/2),f=2*v[0],c=2*v[1];var L=r.noOfChildren*h.noOfChildren/(r.noOfChildren+h.noOfChildren);r.repulsionForceX-=L*f,r.repulsionForceY-=L*c,h.repulsionForceX+=L*f,h.repulsionForceY+=L*c}else this.uniformLeafNodeSizes&&r.getChild()==null&&h.getChild()==null?(u=p.getCenterX()-a.getCenterX(),E=p.getCenterY()-a.getCenterY()):(l.getIntersection(a,p,D),u=D[2]-D[0],E=D[3]-D[1]),Math.abs(u)<t.MIN_REPULSION_DIST&&(u=g.sign(u)*t.MIN_REPULSION_DIST),Math.abs(E)<t.MIN_REPULSION_DIST&&(E=g.sign(E)*t.MIN_REPULSION_DIST),y=u*u+E*E,O=Math.sqrt(y),s=this.repulsionConstant*r.noOfChildren*h.noOfChildren/y,f=s*u/O,c=s*E/O,r.repulsionForceX-=f,r.repulsionForceY-=c,h.repulsionForceX+=f,h.repulsionForceY+=c},n.prototype.calcGravitationalForce=function(r){var h,a,p,v,D,u,E,y;h=r.getOwner(),a=(h.getRight()+h.getLeft())/2,p=(h.getTop()+h.getBottom())/2,v=r.getCenterX()-a,D=r.getCenterY()-p,u=Math.abs(v)+r.getWidth()/2,E=Math.abs(D)+r.getHeight()/2,r.getOwner()==this.graphManager.getRoot()?(y=h.getEstimatedSize()*this.gravityRangeFactor,(u>y||E>y)&&(r.gravitationForceX=-this.gravityConstant*v,r.gravitationForceY=-this.gravityConstant*D)):(y=h.getEstimatedSize()*this.compoundGravityRangeFactor,(u>y||E>y)&&(r.gravitationForceX=-this.gravityConstant*v*this.compoundGravityConstant,r.gravitationForceY=-this.gravityConstant*D*this.compoundGravityConstant))},n.prototype.isConverged=function(){var r,h=!1;return this.totalIterations>this.maxIterations/3&&(h=Math.abs(this.totalDisplacement-this.oldTotalDisplacement)<2),r=this.totalDisplacement<this.totalDisplacementThreshold,this.oldTotalDisplacement=this.totalDisplacement,r||h},n.prototype.animate=function(){this.animationDuringLayout&&!this.isSubLayout&&(this.notAnimatedIterations==this.animationPeriod?(this.update(),this.notAnimatedIterations=0):this.notAnimatedIterations++)},n.prototype.calcNoOfChildrenForAllNodes=function(){for(var r,h=this.graphManager.getAllNodes(),a=0;a<h.length;a++)r=h[a],r.noOfChildren=r.getNoOfChildren()},n.prototype.calcGrid=function(r){var h=0,a=0;h=parseInt(Math.ceil((r.getRight()-r.getLeft())/this.repulsionRange)),a=parseInt(Math.ceil((r.getBottom()-r.getTop())/this.repulsionRange));for(var p=new Array(h),v=0;v<h;v++)p[v]=new Array(a);for(var v=0;v<h;v++)for(var D=0;D<a;D++)p[v][D]=new Array;return p},n.prototype.addNodeToGrid=function(r,h,a){var p=0,v=0,D=0,u=0;p=parseInt(Math.floor((r.getRect().x-h)/this.repulsionRange)),v=parseInt(Math.floor((r.getRect().width+r.getRect().x-h)/this.repulsionRange)),D=parseInt(Math.floor((r.getRect().y-a)/this.repulsionRange)),u=parseInt(Math.floor((r.getRect().height+r.getRect().y-a)/this.repulsionRange));for(var E=p;E<=v;E++)for(var y=D;y<=u;y++)this.grid[E][y].push(r),r.setGridCoordinates(p,v,D,u)},n.prototype.updateGrid=function(){var r,h,a=this.getAllNodes();for(this.grid=this.calcGrid(this.graphManager.getRoot()),r=0;r<a.length;r++)h=a[r],this.addNodeToGrid(h,this.graphManager.getRoot().getLeft(),this.graphManager.getRoot().getTop())},n.prototype.calculateRepulsionForceOfANode=function(r,h,a,p){if(this.totalIterations%t.GRID_CALCULATION_CHECK_PERIOD==1&&a||p){var v=new Set;r.surrounding=new Array;for(var D,u=this.grid,E=r.startX-1;E<r.finishX+2;E++)for(var y=r.startY-1;y<r.finishY+2;y++)if(!(E<0||y<0||E>=u.length||y>=u[0].length)){for(var O=0;O<u[E][y].length;O++)if(D=u[E][y][O],!(r.getOwner()!=D.getOwner()||r==D)&&!h.has(D)&&!v.has(D)){var s=Math.abs(r.getCenterX()-D.getCenterX())-(r.getWidth()/2+D.getWidth()/2),f=Math.abs(r.getCenterY()-D.getCenterY())-(r.getHeight()/2+D.getHeight()/2);s<=this.repulsionRange&&f<=this.repulsionRange&&v.add(D)}}r.surrounding=[].concat(o(v))}for(E=0;E<r.surrounding.length;E++)this.calcRepulsionForce(r,r.surrounding[E])},n.prototype.calcRepulsionRange=function(){return 0},N.exports=n}),(function(N,I,T){var o=T(1),e=T(7);function t(l,g,n){o.call(this,l,g,n),this.idealLength=e.DEFAULT_EDGE_LENGTH}t.prototype=Object.create(o.prototype);for(var i in o)t[i]=o[i];N.exports=t}),(function(N,I,T){var o=T(3);function e(i,l,g,n){o.call(this,i,l,g,n),this.springForceX=0,this.springForceY=0,this.repulsionForceX=0,this.repulsionForceY=0,this.gravitationForceX=0,this.gravitationForceY=0,this.displacementX=0,this.displacementY=0,this.startX=0,this.finishX=0,this.startY=0,this.finishY=0,this.surrounding=[]}e.prototype=Object.create(o.prototype);for(var t in o)e[t]=o[t];e.prototype.setGridCoordinates=function(i,l,g,n){this.startX=i,this.finishX=l,this.startY=g,this.finishY=n},N.exports=e}),(function(N,I,T){function o(e,t){this.width=0,this.height=0,e!==null&&t!==null&&(this.height=t,this.width=e)}o.prototype.getWidth=function(){return this.width},o.prototype.setWidth=function(e){this.width=e},o.prototype.getHeight=function(){return this.height},o.prototype.setHeight=function(e){this.height=e},N.exports=o}),(function(N,I,T){var o=T(14);function e(){this.map={},this.keys=[]}e.prototype.put=function(t,i){var l=o.createID(t);this.contains(l)||(this.map[l]=i,this.keys.push(t))},e.prototype.contains=function(t){return o.createID(t),this.map[t]!=null},e.prototype.get=function(t){var i=o.createID(t);return this.map[i]},e.prototype.keySet=function(){return this.keys},N.exports=e}),(function(N,I,T){var o=T(14);function e(){this.set={}}e.prototype.add=function(t){var i=o.createID(t);this.contains(i)||(this.set[i]=t)},e.prototype.remove=function(t){delete this.set[o.createID(t)]},e.prototype.clear=function(){this.set={}},e.prototype.contains=function(t){return this.set[o.createID(t)]==t},e.prototype.isEmpty=function(){return this.size()===0},e.prototype.size=function(){return Object.keys(this.set).length},e.prototype.addAllTo=function(t){for(var i=Object.keys(this.set),l=i.length,g=0;g<l;g++)t.push(this.set[i[g]])},e.prototype.size=function(){return Object.keys(this.set).length},e.prototype.addAll=function(t){for(var i=t.length,l=0;l<i;l++){var g=t[l];this.add(g)}},N.exports=e}),(function(N,I,T){var o=(function(){function l(g,n){for(var d=0;d<n.length;d++){var r=n[d];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(g,r.key,r)}}return function(g,n,d){return n&&l(g.prototype,n),d&&l(g,d),g}})();function e(l,g){if(!(l instanceof g))throw new TypeError("Cannot call a class as a function")}var t=T(11),i=(function(){function l(g,n){e(this,l),(n!==null||n!==void 0)&&(this.compareFunction=this._defaultCompareFunction);var d=void 0;g instanceof t?d=g.size():d=g.length,this._quicksort(g,0,d-1)}return o(l,[{key:"_quicksort",value:function(n,d,r){if(d<r){var h=this._partition(n,d,r);this._quicksort(n,d,h),this._quicksort(n,h+1,r)}}},{key:"_partition",value:function(n,d,r){for(var h=this._get(n,d),a=d,p=r;;){for(;this.compareFunction(h,this._get(n,p));)p--;for(;this.compareFunction(this._get(n,a),h);)a++;if(a<p)this._swap(n,a,p),a++,p--;else return p}}},{key:"_get",value:function(n,d){return n instanceof t?n.get_object_at(d):n[d]}},{key:"_set",value:function(n,d,r){n instanceof t?n.set_object_at(d,r):n[d]=r}},{key:"_swap",value:function(n,d,r){var h=this._get(n,d);this._set(n,d,this._get(n,r)),this._set(n,r,h)}},{key:"_defaultCompareFunction",value:function(n,d){return d>n}}]),l})();N.exports=i}),(function(N,I,T){var o=(function(){function i(l,g){for(var n=0;n<g.length;n++){var d=g[n];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(l,d.key,d)}}return function(l,g,n){return g&&i(l.prototype,g),n&&i(l,n),l}})();function e(i,l){if(!(i instanceof l))throw new TypeError("Cannot call a class as a function")}var t=(function(){function i(l,g){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,d=arguments.length>3&&arguments[3]!==void 0?arguments[3]:-1,r=arguments.length>4&&arguments[4]!==void 0?arguments[4]:-1;e(this,i),this.sequence1=l,this.sequence2=g,this.match_score=n,this.mismatch_penalty=d,this.gap_penalty=r,this.iMax=l.length+1,this.jMax=g.length+1,this.grid=new Array(this.iMax);for(var h=0;h<this.iMax;h++){this.grid[h]=new Array(this.jMax);for(var a=0;a<this.jMax;a++)this.grid[h][a]=0}this.tracebackGrid=new Array(this.iMax);for(var p=0;p<this.iMax;p++){this.tracebackGrid[p]=new Array(this.jMax);for(var v=0;v<this.jMax;v++)this.tracebackGrid[p][v]=[null,null,null]}this.alignments=[],this.score=-1,this.computeGrids()}return o(i,[{key:"getScore",value:function(){return this.score}},{key:"getAlignments",value:function(){return this.alignments}},{key:"computeGrids",value:function(){for(var g=1;g<this.jMax;g++)this.grid[0][g]=this.grid[0][g-1]+this.gap_penalty,this.tracebackGrid[0][g]=[!1,!1,!0];for(var n=1;n<this.iMax;n++)this.grid[n][0]=this.grid[n-1][0]+this.gap_penalty,this.tracebackGrid[n][0]=[!1,!0,!1];for(var d=1;d<this.iMax;d++)for(var r=1;r<this.jMax;r++){var h=void 0;this.sequence1[d-1]===this.sequence2[r-1]?h=this.grid[d-1][r-1]+this.match_score:h=this.grid[d-1][r-1]+this.mismatch_penalty;var a=this.grid[d-1][r]+this.gap_penalty,p=this.grid[d][r-1]+this.gap_penalty,v=[h,a,p],D=this.arrayAllMaxIndexes(v);this.grid[d][r]=v[D[0]],this.tracebackGrid[d][r]=[D.includes(0),D.includes(1),D.includes(2)]}this.score=this.grid[this.iMax-1][this.jMax-1]}},{key:"alignmentTraceback",value:function(){var g=[];for(g.push({pos:[this.sequence1.length,this.sequence2.length],seq1:"",seq2:""});g[0];){var n=g[0],d=this.tracebackGrid[n.pos[0]][n.pos[1]];d[0]&&g.push({pos:[n.pos[0]-1,n.pos[1]-1],seq1:this.sequence1[n.pos[0]-1]+n.seq1,seq2:this.sequence2[n.pos[1]-1]+n.seq2}),d[1]&&g.push({pos:[n.pos[0]-1,n.pos[1]],seq1:this.sequence1[n.pos[0]-1]+n.seq1,seq2:"-"+n.seq2}),d[2]&&g.push({pos:[n.pos[0],n.pos[1]-1],seq1:"-"+n.seq1,seq2:this.sequence2[n.pos[1]-1]+n.seq2}),n.pos[0]===0&&n.pos[1]===0&&this.alignments.push({sequence1:n.seq1,sequence2:n.seq2}),g.shift()}return this.alignments}},{key:"getAllIndexes",value:function(g,n){for(var d=[],r=-1;(r=g.indexOf(n,r+1))!==-1;)d.push(r);return d}},{key:"arrayAllMaxIndexes",value:function(g){return this.getAllIndexes(g,Math.max.apply(null,g))}}]),i})();N.exports=t}),(function(N,I,T){var o=function(){};o.FDLayout=T(18),o.FDLayoutConstants=T(7),o.FDLayoutEdge=T(19),o.FDLayoutNode=T(20),o.DimensionD=T(21),o.HashMap=T(22),o.HashSet=T(23),o.IGeometry=T(8),o.IMath=T(9),o.Integer=T(10),o.Point=T(12),o.PointD=T(4),o.RandomSeed=T(16),o.RectangleD=T(13),o.Transform=T(17),o.UniqueIDGeneretor=T(14),o.Quicksort=T(24),o.LinkedList=T(11),o.LGraphObject=T(2),o.LGraph=T(5),o.LEdge=T(1),o.LGraphManager=T(6),o.LNode=T(3),o.Layout=T(15),o.LayoutConstants=T(0),o.NeedlemanWunsch=T(25),N.exports=o}),(function(N,I,T){function o(){this.listeners=[]}var e=o.prototype;e.addListener=function(t,i){this.listeners.push({event:t,callback:i})},e.removeListener=function(t,i){for(var l=this.listeners.length;l>=0;l--){var g=this.listeners[l];g.event===t&&g.callback===i&&this.listeners.splice(l,1)}},e.emit=function(t,i){for(var l=0;l<this.listeners.length;l++){var g=this.listeners[l];t===g.event&&g.callback(i)}},N.exports=o})])})})(Q)),Q.exports}var ct=Z.exports,z;function pt(){return z||(z=1,(function(G,b){(function(I,T){G.exports=T(ft())})(ct,function(N){return(function(I){var T={};function o(e){if(T[e])return T[e].exports;var t=T[e]={i:e,l:!1,exports:{}};return I[e].call(t.exports,t,t.exports,o),t.l=!0,t.exports}return o.m=I,o.c=T,o.i=function(e){return e},o.d=function(e,t,i){o.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:i})},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="",o(o.s=7)})([(function(I,T){I.exports=N}),(function(I,T,o){var e=o(0).FDLayoutConstants;function t(){}for(var i in e)t[i]=e[i];t.DEFAULT_USE_MULTI_LEVEL_SCALING=!1,t.DEFAULT_RADIAL_SEPARATION=e.DEFAULT_EDGE_LENGTH,t.DEFAULT_COMPONENT_SEPERATION=60,t.TILE=!0,t.TILING_PADDING_VERTICAL=10,t.TILING_PADDING_HORIZONTAL=10,t.TREE_REDUCTION_ON_INCREMENTAL=!1,I.exports=t}),(function(I,T,o){var e=o(0).FDLayoutEdge;function t(l,g,n){e.call(this,l,g,n)}t.prototype=Object.create(e.prototype);for(var i in e)t[i]=e[i];I.exports=t}),(function(I,T,o){var e=o(0).LGraph;function t(l,g,n){e.call(this,l,g,n)}t.prototype=Object.create(e.prototype);for(var i in e)t[i]=e[i];I.exports=t}),(function(I,T,o){var e=o(0).LGraphManager;function t(l){e.call(this,l)}t.prototype=Object.create(e.prototype);for(var i in e)t[i]=e[i];I.exports=t}),(function(I,T,o){var e=o(0).FDLayoutNode,t=o(0).IMath;function i(g,n,d,r){e.call(this,g,n,d,r)}i.prototype=Object.create(e.prototype);for(var l in e)i[l]=e[l];i.prototype.move=function(){var g=this.graphManager.getLayout();this.displacementX=g.coolingFactor*(this.springForceX+this.repulsionForceX+this.gravitationForceX)/this.noOfChildren,this.displacementY=g.coolingFactor*(this.springForceY+this.repulsionForceY+this.gravitationForceY)/this.noOfChildren,Math.abs(this.displacementX)>g.coolingFactor*g.maxNodeDisplacement&&(this.displacementX=g.coolingFactor*g.maxNodeDisplacement*t.sign(this.displacementX)),Math.abs(this.displacementY)>g.coolingFactor*g.maxNodeDisplacement&&(this.displacementY=g.coolingFactor*g.maxNodeDisplacement*t.sign(this.displacementY)),this.child==null?this.moveBy(this.displacementX,this.displacementY):this.child.getNodes().length==0?this.moveBy(this.displacementX,this.displacementY):this.propogateDisplacementToChildren(this.displacementX,this.displacementY),g.totalDisplacement+=Math.abs(this.displacementX)+Math.abs(this.displacementY),this.springForceX=0,this.springForceY=0,this.repulsionForceX=0,this.repulsionForceY=0,this.gravitationForceX=0,this.gravitationForceY=0,this.displacementX=0,this.displacementY=0},i.prototype.propogateDisplacementToChildren=function(g,n){for(var d=this.getChild().getNodes(),r,h=0;h<d.length;h++)r=d[h],r.getChild()==null?(r.moveBy(g,n),r.displacementX+=g,r.displacementY+=n):r.propogateDisplacementToChildren(g,n)},i.prototype.setPred1=function(g){this.pred1=g},i.prototype.getPred1=function(){return pred1},i.prototype.getPred2=function(){return pred2},i.prototype.setNext=function(g){this.next=g},i.prototype.getNext=function(){return next},i.prototype.setProcessed=function(g){this.processed=g},i.prototype.isProcessed=function(){return processed},I.exports=i}),(function(I,T,o){var e=o(0).FDLayout,t=o(4),i=o(3),l=o(5),g=o(2),n=o(1),d=o(0).FDLayoutConstants,r=o(0).LayoutConstants,h=o(0).Point,a=o(0).PointD,p=o(0).Layout,v=o(0).Integer,D=o(0).IGeometry,u=o(0).LGraph,E=o(0).Transform;function y(){e.call(this),this.toBeTiled={}}y.prototype=Object.create(e.prototype);for(var O in e)y[O]=e[O];y.prototype.newGraphManager=function(){var s=new t(this);return this.graphManager=s,s},y.prototype.newGraph=function(s){return new i(null,this.graphManager,s)},y.prototype.newNode=function(s){return new l(this.graphManager,s)},y.prototype.newEdge=function(s){return new g(null,null,s)},y.prototype.initParameters=function(){e.prototype.initParameters.call(this,arguments),this.isSubLayout||(n.DEFAULT_EDGE_LENGTH<10?this.idealEdgeLength=10:this.idealEdgeLength=n.DEFAULT_EDGE_LENGTH,this.useSmartIdealEdgeLengthCalculation=n.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION,this.springConstant=d.DEFAULT_SPRING_STRENGTH,this.repulsionConstant=d.DEFAULT_REPULSION_STRENGTH,this.gravityConstant=d.DEFAULT_GRAVITY_STRENGTH,this.compoundGravityConstant=d.DEFAULT_COMPOUND_GRAVITY_STRENGTH,this.gravityRangeFactor=d.DEFAULT_GRAVITY_RANGE_FACTOR,this.compoundGravityRangeFactor=d.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR,this.prunedNodesAll=[],this.growTreeIterations=0,this.afterGrowthIterations=0,this.isTreeGrowing=!1,this.isGrowthFinished=!1,this.coolingCycle=0,this.maxCoolingCycle=this.maxIterations/d.CONVERGENCE_CHECK_PERIOD,this.finalTemperature=d.CONVERGENCE_CHECK_PERIOD/this.maxIterations,this.coolingAdjuster=1)},y.prototype.layout=function(){var s=r.DEFAULT_CREATE_BENDS_AS_NEEDED;return s&&(this.createBendpoints(),this.graphManager.resetAllEdges()),this.level=0,this.classicLayout()},y.prototype.classicLayout=function(){if(this.nodesWithGravity=this.calculateNodesToApplyGravitationTo(),this.graphManager.setAllNodesToApplyGravitation(this.nodesWithGravity),this.calcNoOfChildrenForAllNodes(),this.graphManager.calcLowestCommonAncestors(),this.graphManager.calcInclusionTreeDepths(),this.graphManager.getRoot().calcEstimatedSize(),this.calcIdealEdgeLengths(),this.incremental){if(n.TREE_REDUCTION_ON_INCREMENTAL){this.reduceTrees(),this.graphManager.resetAllNodesToApplyGravitation();var f=new Set(this.getAllNodes()),c=this.nodesWithGravity.filter(function(m){return f.has(m)});this.graphManager.setAllNodesToApplyGravitation(c)}}else{var s=this.getFlatForest();if(s.length>0)this.positionNodesRadially(s);else{this.reduceTrees(),this.graphManager.resetAllNodesToApplyGravitation();var f=new Set(this.getAllNodes()),c=this.nodesWithGravity.filter(function(L){return f.has(L)});this.graphManager.setAllNodesToApplyGravitation(c),this.positionNodesRandomly()}}return this.initSpringEmbedder(),this.runSpringEmbedder(),!0},y.prototype.tick=function(){if(this.totalIterations++,this.totalIterations===this.maxIterations&&!this.isTreeGrowing&&!this.isGrowthFinished)if(this.prunedNodesAll.length>0)this.isTreeGrowing=!0;else return!0;if(this.totalIterations%d.CONVERGENCE_CHECK_PERIOD==0&&!this.isTreeGrowing&&!this.isGrowthFinished){if(this.isConverged())if(this.prunedNodesAll.length>0)this.isTreeGrowing=!0;else return!0;this.coolingCycle++,this.layoutQuality==0?this.coolingAdjuster=this.coolingCycle:this.layoutQuality==1&&(this.coolingAdjuster=this.coolingCycle/3),this.coolingFactor=Math.max(this.initialCoolingFactor-Math.pow(this.coolingCycle,Math.log(100*(this.initialCoolingFactor-this.finalTemperature))/Math.log(this.maxCoolingCycle))/100*this.coolingAdjuster,this.finalTemperature),this.animationPeriod=Math.ceil(this.initialAnimationPeriod*Math.sqrt(this.coolingFactor))}if(this.isTreeGrowing){if(this.growTreeIterations%10==0)if(this.prunedNodesAll.length>0){this.graphManager.updateBounds(),this.updateGrid(),this.growTree(this.prunedNodesAll),this.graphManager.resetAllNodesToApplyGravitation();var s=new Set(this.getAllNodes()),f=this.nodesWithGravity.filter(function(A){return s.has(A)});this.graphManager.setAllNodesToApplyGravitation(f),this.graphManager.updateBounds(),this.updateGrid(),this.coolingFactor=d.DEFAULT_COOLING_FACTOR_INCREMENTAL}else this.isTreeGrowing=!1,this.isGrowthFinished=!0;this.growTreeIterations++}if(this.isGrowthFinished){if(this.isConverged())return!0;this.afterGrowthIterations%10==0&&(this.graphManager.updateBounds(),this.updateGrid()),this.coolingFactor=d.DEFAULT_COOLING_FACTOR_INCREMENTAL*((100-this.afterGrowthIterations)/100),this.afterGrowthIterations++}var c=!this.isTreeGrowing&&!this.isGrowthFinished,L=this.growTreeIterations%10==1&&this.isTreeGrowing||this.afterGrowthIterations%10==1&&this.isGrowthFinished;return this.totalDisplacement=0,this.graphManager.updateBounds(),this.calcSpringForces(),this.calcRepulsionForces(c,L),this.calcGravitationalForces(),this.moveNodes(),this.animate(),!1},y.prototype.getPositionsData=function(){for(var s=this.graphManager.getAllNodes(),f={},c=0;c<s.length;c++){var L=s[c].rect,A=s[c].id;f[A]={id:A,x:L.getCenterX(),y:L.getCenterY(),w:L.width,h:L.height}}return f},y.prototype.runSpringEmbedder=function(){this.initialAnimationPeriod=25,this.animationPeriod=this.initialAnimationPeriod;var s=!1;if(d.ANIMATE==="during")this.emit("layoutstarted");else{for(;!s;)s=this.tick();this.graphManager.updateBounds()}},y.prototype.calculateNodesToApplyGravitationTo=function(){var s=[],f,c=this.graphManager.getGraphs(),L=c.length,A;for(A=0;A<L;A++)f=c[A],f.updateConnected(),f.isConnected||(s=s.concat(f.getNodes()));return s},y.prototype.createBendpoints=function(){var s=[];s=s.concat(this.graphManager.getAllEdges());var f=new Set,c;for(c=0;c<s.length;c++){var L=s[c];if(!f.has(L)){var A=L.getSource(),m=L.getTarget();if(A==m)L.getBendpoints().push(new a),L.getBendpoints().push(new a),this.createDummyNodesForBendpoints(L),f.add(L);else{var C=[];if(C=C.concat(A.getEdgeListToNode(m)),C=C.concat(m.getEdgeListToNode(A)),!f.has(C[0])){if(C.length>1){var R;for(R=0;R<C.length;R++){var M=C[R];M.getBendpoints().push(new a),this.createDummyNodesForBendpoints(M)}}C.forEach(function(S){f.add(S)})}}}if(f.size==s.length)break}},y.prototype.positionNodesRadially=function(s){for(var f=new h(0,0),c=Math.ceil(Math.sqrt(s.length)),L=0,A=0,m=0,C=new a(0,0),R=0;R<s.length;R++){R%c==0&&(m=0,A=L,R!=0&&(A+=n.DEFAULT_COMPONENT_SEPERATION),L=0);var M=s[R],S=p.findCenterOfTree(M);f.x=m,f.y=A,C=y.radialLayout(M,S,f),C.y>L&&(L=Math.floor(C.y)),m=Math.floor(C.x+n.DEFAULT_COMPONENT_SEPERATION)}this.transform(new a(r.WORLD_CENTER_X-C.x/2,r.WORLD_CENTER_Y-C.y/2))},y.radialLayout=function(s,f,c){var L=Math.max(this.maxDiagonalInTree(s),n.DEFAULT_RADIAL_SEPARATION);y.branchRadialLayout(f,null,0,359,0,L);var A=u.calculateBounds(s),m=new E;m.setDeviceOrgX(A.getMinX()),m.setDeviceOrgY(A.getMinY()),m.setWorldOrgX(c.x),m.setWorldOrgY(c.y);for(var C=0;C<s.length;C++){var R=s[C];R.transform(m)}var M=new a(A.getMaxX(),A.getMaxY());return m.inverseTransformPoint(M)},y.branchRadialLayout=function(s,f,c,L,A,m){var C=(L-c+1)/2;C<0&&(C+=180);var R=(C+c)%360,M=R*D.TWO_PI/360,S=A*Math.cos(M),Y=A*Math.sin(M);s.setCenter(S,Y);var w=[];w=w.concat(s.getEdges());var x=w.length;f!=null&&x--;for(var F=0,U=w.length,P,_=s.getEdgesBetween(f);_.length>1;){var X=_[0];_.splice(0,1);var H=w.indexOf(X);H>=0&&w.splice(H,1),U--,x--}f!=null?P=(w.indexOf(_[0])+1)%U:P=0;for(var W=Math.abs(L-c)/x,B=P;F!=x;B=++B%U){var K=w[B].getOtherEnd(s);if(K!=f){var q=(c+F*W)%360,ht=(q+W)%360;y.branchRadialLayout(K,s,q,ht,A+m,m),F++}}},y.maxDiagonalInTree=function(s){for(var f=v.MIN_VALUE,c=0;c<s.length;c++){var L=s[c],A=L.getDiagonal();A>f&&(f=A)}return f},y.prototype.calcRepulsionRange=function(){return 2*(this.level+1)*this.idealEdgeLength},y.prototype.groupZeroDegreeMembers=function(){var s=this,f={};this.memberGroups={},this.idToDummyNode={};for(var c=[],L=this.graphManager.getAllNodes(),A=0;A<L.length;A++){var m=L[A],C=m.getParent();this.getNodeDegreeWithChildren(m)===0&&(C.id==null||!this.getToBeTiled(C))&&c.push(m)}for(var A=0;A<c.length;A++){var m=c[A],R=m.getParent().id;typeof f[R]>"u"&&(f[R]=[]),f[R]=f[R].concat(m)}Object.keys(f).forEach(function(M){if(f[M].length>1){var S="DummyCompound_"+M;s.memberGroups[S]=f[M];var Y=f[M][0].getParent(),w=new l(s.graphManager);w.id=S,w.paddingLeft=Y.paddingLeft||0,w.paddingRight=Y.paddingRight||0,w.paddingBottom=Y.paddingBottom||0,w.paddingTop=Y.paddingTop||0,s.idToDummyNode[S]=w;var x=s.getGraphManager().add(s.newGraph(),w),F=Y.getChild();F.add(w);for(var U=0;U<f[M].length;U++){var P=f[M][U];F.remove(P),x.add(P)}}})},y.prototype.clearCompounds=function(){var s={},f={};this.performDFSOnCompounds();for(var c=0;c<this.compoundOrder.length;c++)f[this.compoundOrder[c].id]=this.compoundOrder[c],s[this.compoundOrder[c].id]=[].concat(this.compoundOrder[c].getChild().getNodes()),this.graphManager.remove(this.compoundOrder[c].getChild()),this.compoundOrder[c].child=null;this.graphManager.resetAllNodes(),this.tileCompoundMembers(s,f)},y.prototype.clearZeroDegreeMembers=function(){var s=this,f=this.tiledZeroDegreePack=[];Object.keys(this.memberGroups).forEach(function(c){var L=s.idToDummyNode[c];f[c]=s.tileNodes(s.memberGroups[c],L.paddingLeft+L.paddingRight),L.rect.width=f[c].width,L.rect.height=f[c].height})},y.prototype.repopulateCompounds=function(){for(var s=this.compoundOrder.length-1;s>=0;s--){var f=this.compoundOrder[s],c=f.id,L=f.paddingLeft,A=f.paddingTop;this.adjustLocations(this.tiledMemberPack[c],f.rect.x,f.rect.y,L,A)}},y.prototype.repopulateZeroDegreeMembers=function(){var s=this,f=this.tiledZeroDegreePack;Object.keys(f).forEach(function(c){var L=s.idToDummyNode[c],A=L.paddingLeft,m=L.paddingTop;s.adjustLocations(f[c],L.rect.x,L.rect.y,A,m)})},y.prototype.getToBeTiled=function(s){var f=s.id;if(this.toBeTiled[f]!=null)return this.toBeTiled[f];var c=s.getChild();if(c==null)return this.toBeTiled[f]=!1,!1;for(var L=c.getNodes(),A=0;A<L.length;A++){var m=L[A];if(this.getNodeDegree(m)>0)return this.toBeTiled[f]=!1,!1;if(m.getChild()==null){this.toBeTiled[m.id]=!1;continue}if(!this.getToBeTiled(m))return this.toBeTiled[f]=!1,!1}return this.toBeTiled[f]=!0,!0},y.prototype.getNodeDegree=function(s){s.id;for(var f=s.getEdges(),c=0,L=0;L<f.length;L++){var A=f[L];A.getSource().id!==A.getTarget().id&&(c=c+1)}return c},y.prototype.getNodeDegreeWithChildren=function(s){var f=this.getNodeDegree(s);if(s.getChild()==null)return f;for(var c=s.getChild().getNodes(),L=0;L<c.length;L++){var A=c[L];f+=this.getNodeDegreeWithChildren(A)}return f},y.prototype.performDFSOnCompounds=function(){this.compoundOrder=[],this.fillCompexOrderByDFS(this.graphManager.getRoot().getNodes())},y.prototype.fillCompexOrderByDFS=function(s){for(var f=0;f<s.length;f++){var c=s[f];c.getChild()!=null&&this.fillCompexOrderByDFS(c.getChild().getNodes()),this.getToBeTiled(c)&&this.compoundOrder.push(c)}},y.prototype.adjustLocations=function(s,f,c,L,A){f+=L,c+=A;for(var m=f,C=0;C<s.rows.length;C++){var R=s.rows[C];f=m;for(var M=0,S=0;S<R.length;S++){var Y=R[S];Y.rect.x=f,Y.rect.y=c,f+=Y.rect.width+s.horizontalPadding,Y.rect.height>M&&(M=Y.rect.height)}c+=M+s.verticalPadding}},y.prototype.tileCompoundMembers=function(s,f){var c=this;this.tiledMemberPack=[],Object.keys(s).forEach(function(L){var A=f[L];c.tiledMemberPack[L]=c.tileNodes(s[L],A.paddingLeft+A.paddingRight),A.rect.width=c.tiledMemberPack[L].width,A.rect.height=c.tiledMemberPack[L].height})},y.prototype.tileNodes=function(s,f){var c=n.TILING_PADDING_VERTICAL,L=n.TILING_PADDING_HORIZONTAL,A={rows:[],rowWidth:[],rowHeight:[],width:0,height:f,verticalPadding:c,horizontalPadding:L};s.sort(function(R,M){return R.rect.width*R.rect.height>M.rect.width*M.rect.height?-1:R.rect.width*R.rect.height<M.rect.width*M.rect.height?1:0});for(var m=0;m<s.length;m++){var C=s[m];A.rows.length==0?this.insertNodeToRow(A,C,0,f):this.canAddHorizontal(A,C.rect.width,C.rect.height)?this.insertNodeToRow(A,C,this.getShortestRowIndex(A),f):this.insertNodeToRow(A,C,A.rows.length,f),this.shiftToLastRow(A)}return A},y.prototype.insertNodeToRow=function(s,f,c,L){var A=L;if(c==s.rows.length){var m=[];s.rows.push(m),s.rowWidth.push(A),s.rowHeight.push(0)}var C=s.rowWidth[c]+f.rect.width;s.rows[c].length>0&&(C+=s.horizontalPadding),s.rowWidth[c]=C,s.width<C&&(s.width=C);var R=f.rect.height;c>0&&(R+=s.verticalPadding);var M=0;R>s.rowHeight[c]&&(M=s.rowHeight[c],s.rowHeight[c]=R,M=s.rowHeight[c]-M),s.height+=M,s.rows[c].push(f)},y.prototype.getShortestRowIndex=function(s){for(var f=-1,c=Number.MAX_VALUE,L=0;L<s.rows.length;L++)s.rowWidth[L]<c&&(f=L,c=s.rowWidth[L]);return f},y.prototype.getLongestRowIndex=function(s){for(var f=-1,c=Number.MIN_VALUE,L=0;L<s.rows.length;L++)s.rowWidth[L]>c&&(f=L,c=s.rowWidth[L]);return f},y.prototype.canAddHorizontal=function(s,f,c){var L=this.getShortestRowIndex(s);if(L<0)return!0;var A=s.rowWidth[L];if(A+s.horizontalPadding+f<=s.width)return!0;var m=0;s.rowHeight[L]<c&&L>0&&(m=c+s.verticalPadding-s.rowHeight[L]);var C;s.width-A>=f+s.horizontalPadding?C=(s.height+m)/(A+f+s.horizontalPadding):C=(s.height+m)/s.width,m=c+s.verticalPadding;var R;return s.width<f?R=(s.height+m)/f:R=(s.height+m)/s.width,R<1&&(R=1/R),C<1&&(C=1/C),C<R},y.prototype.shiftToLastRow=function(s){var f=this.getLongestRowIndex(s),c=s.rowWidth.length-1,L=s.rows[f],A=L[L.length-1],m=A.width+s.horizontalPadding;if(s.width-s.rowWidth[c]>m&&f!=c){L.splice(-1,1),s.rows[c].push(A),s.rowWidth[f]=s.rowWidth[f]-m,s.rowWidth[c]=s.rowWidth[c]+m,s.width=s.rowWidth[instance.getLongestRowIndex(s)];for(var C=Number.MIN_VALUE,R=0;R<L.length;R++)L[R].height>C&&(C=L[R].height);f>0&&(C+=s.verticalPadding);var M=s.rowHeight[f]+s.rowHeight[c];s.rowHeight[f]=C,s.rowHeight[c]<A.height+s.verticalPadding&&(s.rowHeight[c]=A.height+s.verticalPadding);var S=s.rowHeight[f]+s.rowHeight[c];s.height+=S-M,this.shiftToLastRow(s)}},y.prototype.tilingPreLayout=function(){n.TILE&&(this.groupZeroDegreeMembers(),this.clearCompounds(),this.clearZeroDegreeMembers())},y.prototype.tilingPostLayout=function(){n.TILE&&(this.repopulateZeroDegreeMembers(),this.repopulateCompounds())},y.prototype.reduceTrees=function(){for(var s=[],f=!0,c;f;){var L=this.graphManager.getAllNodes(),A=[];f=!1;for(var m=0;m<L.length;m++)c=L[m],c.getEdges().length==1&&!c.getEdges()[0].isInterGraph&&c.getChild()==null&&(A.push([c,c.getEdges()[0],c.getOwner()]),f=!0);if(f==!0){for(var C=[],R=0;R<A.length;R++)A[R][0].getEdges().length==1&&(C.push(A[R]),A[R][0].getOwner().remove(A[R][0]));s.push(C),this.graphManager.resetAllNodes(),this.graphManager.resetAllEdges()}}this.prunedNodesAll=s},y.prototype.growTree=function(s){for(var f=s.length,c=s[f-1],L,A=0;A<c.length;A++)L=c[A],this.findPlaceforPrunedNode(L),L[2].add(L[0]),L[2].add(L[1],L[1].source,L[1].target);s.splice(s.length-1,1),this.graphManager.resetAllNodes(),this.graphManager.resetAllEdges()},y.prototype.findPlaceforPrunedNode=function(s){var f,c,L=s[0];L==s[1].source?c=s[1].target:c=s[1].source;var A=c.startX,m=c.finishX,C=c.startY,R=c.finishY,M=0,S=0,Y=0,w=0,x=[M,Y,S,w];if(C>0)for(var F=A;F<=m;F++)x[0]+=this.grid[F][C-1].length+this.grid[F][C].length-1;if(m<this.grid.length-1)for(var F=C;F<=R;F++)x[1]+=this.grid[m+1][F].length+this.grid[m][F].length-1;if(R<this.grid[0].length-1)for(var F=A;F<=m;F++)x[2]+=this.grid[F][R+1].length+this.grid[F][R].length-1;if(A>0)for(var F=C;F<=R;F++)x[3]+=this.grid[A-1][F].length+this.grid[A][F].length-1;for(var U=v.MAX_VALUE,P,_,X=0;X<x.length;X++)x[X]<U?(U=x[X],P=1,_=X):x[X]==U&&P++;if(P==3&&U==0)x[0]==0&&x[1]==0&&x[2]==0?f=1:x[0]==0&&x[1]==0&&x[3]==0?f=0:x[0]==0&&x[2]==0&&x[3]==0?f=3:x[1]==0&&x[2]==0&&x[3]==0&&(f=2);else if(P==2&&U==0){var H=Math.floor(Math.random()*2);x[0]==0&&x[1]==0?H==0?f=0:f=1:x[0]==0&&x[2]==0?H==0?f=0:f=2:x[0]==0&&x[3]==0?H==0?f=0:f=3:x[1]==0&&x[2]==0?H==0?f=1:f=2:x[1]==0&&x[3]==0?H==0?f=1:f=3:H==0?f=2:f=3}else if(P==4&&U==0){var H=Math.floor(Math.random()*4);f=H}else f=_;f==0?L.setCenter(c.getCenterX(),c.getCenterY()-c.getHeight()/2-d.DEFAULT_EDGE_LENGTH-L.getHeight()/2):f==1?L.setCenter(c.getCenterX()+c.getWidth()/2+d.DEFAULT_EDGE_LENGTH+L.getWidth()/2,c.getCenterY()):f==2?L.setCenter(c.getCenterX(),c.getCenterY()+c.getHeight()/2+d.DEFAULT_EDGE_LENGTH+L.getHeight()/2):L.setCenter(c.getCenterX()-c.getWidth()/2-d.DEFAULT_EDGE_LENGTH-L.getWidth()/2,c.getCenterY())},I.exports=y}),(function(I,T,o){var e={};e.layoutBase=o(0),e.CoSEConstants=o(1),e.CoSEEdge=o(2),e.CoSEGraph=o(3),e.CoSEGraphManager=o(4),e.CoSELayout=o(6),e.CoSENode=o(5),I.exports=e})])})})(Z)),Z.exports}var dt=k.exports,J;function vt(){return J||(J=1,(function(G,b){(function(I,T){G.exports=T(pt())})(dt,function(N){return(function(I){var T={};function o(e){if(T[e])return T[e].exports;var t=T[e]={i:e,l:!1,exports:{}};return I[e].call(t.exports,t,t.exports,o),t.l=!0,t.exports}return o.m=I,o.c=T,o.i=function(e){return e},o.d=function(e,t,i){o.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:i})},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="",o(o.s=1)})([(function(I,T){I.exports=N}),(function(I,T,o){var e=o(0).layoutBase.LayoutConstants,t=o(0).layoutBase.FDLayoutConstants,i=o(0).CoSEConstants,l=o(0).CoSELayout,g=o(0).CoSENode,n=o(0).layoutBase.PointD,d=o(0).layoutBase.DimensionD,r={ready:function(){},stop:function(){},quality:"default",nodeDimensionsIncludeLabels:!1,refresh:30,fit:!0,padding:10,randomize:!0,nodeRepulsion:4500,idealEdgeLength:50,edgeElasticity:.45,nestingFactor:.1,gravity:.25,numIter:2500,tile:!0,animate:"end",animationDuration:500,tilingPaddingVertical:10,tilingPaddingHorizontal:10,gravityRangeCompound:1.5,gravityCompound:1,gravityRange:3.8,initialEnergyOnIncremental:.5};function h(D,u){var E={};for(var y in D)E[y]=D[y];for(var y in u)E[y]=u[y];return E}function a(D){this.options=h(r,D),p(this.options)}var p=function(u){u.nodeRepulsion!=null&&(i.DEFAULT_REPULSION_STRENGTH=t.DEFAULT_REPULSION_STRENGTH=u.nodeRepulsion),u.idealEdgeLength!=null&&(i.DEFAULT_EDGE_LENGTH=t.DEFAULT_EDGE_LENGTH=u.idealEdgeLength),u.edgeElasticity!=null&&(i.DEFAULT_SPRING_STRENGTH=t.DEFAULT_SPRING_STRENGTH=u.edgeElasticity),u.nestingFactor!=null&&(i.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR=t.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR=u.nestingFactor),u.gravity!=null&&(i.DEFAULT_GRAVITY_STRENGTH=t.DEFAULT_GRAVITY_STRENGTH=u.gravity),u.numIter!=null&&(i.MAX_ITERATIONS=t.MAX_ITERATIONS=u.numIter),u.gravityRange!=null&&(i.DEFAULT_GRAVITY_RANGE_FACTOR=t.DEFAULT_GRAVITY_RANGE_FACTOR=u.gravityRange),u.gravityCompound!=null&&(i.DEFAULT_COMPOUND_GRAVITY_STRENGTH=t.DEFAULT_COMPOUND_GRAVITY_STRENGTH=u.gravityCompound),u.gravityRangeCompound!=null&&(i.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR=t.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR=u.gravityRangeCompound),u.initialEnergyOnIncremental!=null&&(i.DEFAULT_COOLING_FACTOR_INCREMENTAL=t.DEFAULT_COOLING_FACTOR_INCREMENTAL=u.initialEnergyOnIncremental),u.quality=="draft"?e.QUALITY=0:u.quality=="proof"?e.QUALITY=2:e.QUALITY=1,i.NODE_DIMENSIONS_INCLUDE_LABELS=t.NODE_DIMENSIONS_INCLUDE_LABELS=e.NODE_DIMENSIONS_INCLUDE_LABELS=u.nodeDimensionsIncludeLabels,i.DEFAULT_INCREMENTAL=t.DEFAULT_INCREMENTAL=e.DEFAULT_INCREMENTAL=!u.randomize,i.ANIMATE=t.ANIMATE=e.ANIMATE=u.animate,i.TILE=u.tile,i.TILING_PADDING_VERTICAL=typeof u.tilingPaddingVertical=="function"?u.tilingPaddingVertical.call():u.tilingPaddingVertical,i.TILING_PADDING_HORIZONTAL=typeof u.tilingPaddingHorizontal=="function"?u.tilingPaddingHorizontal.call():u.tilingPaddingHorizontal};a.prototype.run=function(){var D,u,E=this.options;this.idToLNode={};var y=this.layout=new l,O=this;O.stopped=!1,this.cy=this.options.cy,this.cy.trigger({type:"layoutstart",layout:this});var s=y.newGraphManager();this.gm=s;var f=this.options.eles.nodes(),c=this.options.eles.edges();this.root=s.addRoot(),this.processChildrenList(this.root,this.getTopMostNodes(f),y);for(var L=0;L<c.length;L++){var A=c[L],m=this.idToLNode[A.data("source")],C=this.idToLNode[A.data("target")];if(m!==C&&m.getEdgesBetween(C).length==0){var R=s.add(y.newEdge(),m,C);R.id=A.id()}}var M=function(w,x){typeof w=="number"&&(w=x);var F=w.data("id"),U=O.idToLNode[F];return{x:U.getRect().getCenterX(),y:U.getRect().getCenterY()}},S=function Y(){for(var w=function(){E.fit&&E.cy.fit(E.eles,E.padding),D||(D=!0,O.cy.one("layoutready",E.ready),O.cy.trigger({type:"layoutready",layout:O}))},x=O.options.refresh,F,U=0;U<x&&!F;U++)F=O.stopped||O.layout.tick();if(F){y.checkLayoutSuccess()&&!y.isSubLayout&&y.doPostLayout(),y.tilingPostLayout&&y.tilingPostLayout(),y.isLayoutFinished=!0,O.options.eles.nodes().positions(M),w(),O.cy.one("layoutstop",O.options.stop),O.cy.trigger({type:"layoutstop",layout:O}),u&&cancelAnimationFrame(u),D=!1;return}var P=O.layout.getPositionsData();E.eles.nodes().positions(function(_,X){if(typeof _=="number"&&(_=X),!_.isParent()){for(var H=_.id(),W=P[H],B=_;W==null&&(W=P[B.data("parent")]||P["DummyCompound_"+B.data("parent")],P[H]=W,B=B.parent()[0],B!=null););return W!=null?{x:W.x,y:W.y}:{x:_.position("x"),y:_.position("y")}}}),w(),u=requestAnimationFrame(Y)};return y.addListener("layoutstarted",function(){O.options.animate==="during"&&(u=requestAnimationFrame(S))}),y.runLayout(),this.options.animate!=="during"&&(O.options.eles.nodes().not(":parent").layoutPositions(O,O.options,M),D=!1),this},a.prototype.getTopMostNodes=function(D){for(var u={},E=0;E<D.length;E++)u[D[E].id()]=!0;var y=D.filter(function(O,s){typeof O=="number"&&(O=s);for(var f=O.parent()[0];f!=null;){if(u[f.id()])return!1;f=f.parent()[0]}return!0});return y},a.prototype.processChildrenList=function(D,u,E){for(var y=u.length,O=0;O<y;O++){var s=u[O],f=s.children(),c,L=s.layoutDimensions({nodeDimensionsIncludeLabels:this.options.nodeDimensionsIncludeLabels});if(s.outerWidth()!=null&&s.outerHeight()!=null?c=D.add(new g(E.graphManager,new n(s.position("x")-L.w/2,s.position("y")-L.h/2),new d(parseFloat(L.w),parseFloat(L.h)))):c=D.add(new g(this.graphManager)),c.id=s.data("id"),c.paddingLeft=parseInt(s.css("padding")),c.paddingTop=parseInt(s.css("padding")),c.paddingRight=parseInt(s.css("padding")),c.paddingBottom=parseInt(s.css("padding")),this.options.nodeDimensionsIncludeLabels&&s.isParent()){var A=s.boundingBox({includeLabels:!0,includeNodes:!1}).w,m=s.boundingBox({includeLabels:!0,includeNodes:!1}).h,C=s.css("text-halign");c.labelWidth=A,c.labelHeight=m,c.labelPos=C}if(this.idToLNode[s.data("id")]=c,isNaN(c.rect.x)&&(c.rect.x=0),isNaN(c.rect.y)&&(c.rect.y=0),f!=null&&f.length>0){var R;R=E.getGraphManager().add(E.newGraph(),c),this.processChildrenList(R,f,E)}}},a.prototype.stop=function(){return this.stopped=!0,this};var v=function(u){u("layout","cose-bilkent",a)};typeof cytoscape<"u"&&v(cytoscape),I.exports=v})])})})(k)),k.exports}var yt=vt();const Et=gt(yt);tt.use(Et);function et(G,b){G.forEach(N=>{const I={id:N.id,labelText:N.label,height:N.height,width:N.width,padding:N.padding??0};Object.keys(N).forEach(T=>{["id","label","height","width","padding","x","y"].includes(T)||(I[T]=N[T])}),b.add({group:"nodes",data:I,position:{x:N.x??0,y:N.y??0}})})}V(et,"addNodes");function rt(G,b){G.forEach(N=>{const I={id:N.id,source:N.start,target:N.end};Object.keys(N).forEach(T=>{["id","start","end"].includes(T)||(I[T]=N[T])}),b.add({group:"edges",data:I})})}V(rt,"addEdges");function it(G){return new Promise(b=>{const N=lt("body").append("div").attr("id","cy").attr("style","display:none"),I=tt({container:document.getElementById("cy"),style:[{selector:"edge",style:{"curve-style":"bezier"}}]});N.remove(),et(G.nodes,I),rt(G.edges,I),I.nodes().forEach(function(o){o.layoutDimensions=()=>{const e=o.data();return{w:e.width,h:e.height}}});const T={name:"cose-bilkent",quality:"proof",styleEnabled:!1,animate:!1};I.layout(T).run(),I.ready(o=>{$.info("Cytoscape ready",o),b(I)})})}V(it,"createCytoscapeInstance");function nt(G){return G.nodes().map(b=>{const N=b.data(),I=b.position(),T={id:N.id,x:I.x,y:I.y};return Object.keys(N).forEach(o=>{o!=="id"&&(T[o]=N[o])}),T})}V(nt,"extractPositionedNodes");function ot(G){return G.edges().map(b=>{const N=b.data(),I=b._private.rscratch,T={id:N.id,source:N.source,target:N.target,startX:I.startX,startY:I.startY,midX:I.midX,midY:I.midY,endX:I.endX,endY:I.endY};return Object.keys(N).forEach(o=>{["id","source","target"].includes(o)||(T[o]=N[o])}),T})}V(ot,"extractPositionedEdges");async function st(G,b){$.debug("Starting cose-bilkent layout algorithm");try{at(G);const N=await it(G),I=nt(N),T=ot(N);return $.debug(`Layout completed: ${I.length} nodes, ${T.length} edges`),{nodes:I,edges:T}}catch(N){throw $.error("Error in cose-bilkent layout algorithm:",N),N}}V(st,"executeCoseBilkentLayout");function at(G){if(!G)throw new Error("Layout data is required");if(!G.config)throw new Error("Configuration is required in layout data");if(!G.rootNode)throw new Error("Root node is required");if(!G.nodes||!Array.isArray(G.nodes))throw new Error("No nodes found in layout data");if(!Array.isArray(G.edges))throw new Error("Edges array is required in layout data");return!0}V(at,"validateLayoutData");var Lt=V(async(G,b,{insertCluster:N,insertEdge:I,insertEdgeLabel:T,insertMarkers:o,insertNode:e,log:t,positionEdgeLabel:i},{algorithm:l})=>{const g={},n={},d=b.select("g");o(d,G.markers,G.type,G.diagramId);const r=d.insert("g").attr("class","subgraphs"),h=d.insert("g").attr("class","edgePaths"),a=d.insert("g").attr("class","edgeLabels"),p=d.insert("g").attr("class","nodes");t.debug("Inserting nodes into DOM for dimension calculation"),await Promise.all(G.nodes.map(async u=>{if(u.isGroup){const E={...u};n[u.id]=E,g[u.id]=E,await N(r,u)}else{const E={...u};g[u.id]=E;const y=await e(p,u,{config:G.config,dir:G.direction||"TB"}),O=y.node().getBBox();E.width=O.width,E.height=O.height,E.domId=y,t.debug(`Node ${u.id} dimensions: ${O.width}x${O.height}`)}})),t.debug("Running cose-bilkent layout algorithm");const v={...G,nodes:G.nodes.map(u=>{const E=g[u.id];return{...u,width:E.width,height:E.height}})},D=await st(v,G.config);t.debug("Positioning nodes based on layout results"),D.nodes.forEach(u=>{const E=g[u.id];E!=null&&E.domId&&(E.domId.attr("transform",`translate(${u.x}, ${u.y})`),E.x=u.x,E.y=u.y,t.debug(`Positioned node ${E.id} at center (${u.x}, ${u.y})`))}),D.edges.forEach(u=>{const E=G.edges.find(y=>y.id===u.id);E&&(E.points=[{x:u.startX,y:u.startY},{x:u.midX,y:u.midY},{x:u.endX,y:u.endY}])}),t.debug("Inserting and positioning edges"),await Promise.all(G.edges.map(async u=>{await T(a,u);const E=g[u.start??""],y=g[u.end??""];if(E&&y){const O=D.edges.find(s=>s.id===u.id);if(O){t.debug("APA01 positionedEdge",O);const s={...u},f=I(h,s,n,G.type,E,y,G.diagramId);i(s,f)}else{const s={...u,points:[{x:E.x||0,y:E.y||0},{x:y.x||0,y:y.y||0}]},f=I(h,s,n,G.type,E,y,G.diagramId);i(s,f)}}})),t.debug("Cose-bilkent rendering completed")},"render"),It=Lt;export{It as render};
|